Skip to content

Commit

Permalink
add jgit
Browse files Browse the repository at this point in the history
  • Loading branch information
appt2 committed Apr 27, 2024
1 parent 65f5b10 commit 4c4e396
Show file tree
Hide file tree
Showing 10 changed files with 597 additions and 314 deletions.
35 changes: 35 additions & 0 deletions .androidide/editor/openedFiles.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"allFiles": [
{
"file": "/storage/emulated/0/AndroidIDEProjects/Ghost-web-ide/app/src/main/java/Ninja/coder/Ghostemane/code/git/GitUtils.java",
"selection": {
"end": {
"column": 31,
"index": 7615,
"line": 249
},
"start": {
"column": 31,
"index": 7615,
"line": 249
}
}
},
{
"file": "/storage/emulated/0/AndroidIDEProjects/Ghost-web-ide/app/src/main/java/Ninja/coder/Ghostemane/code/git/GitListSheet.java",
"selection": {
"end": {
"column": 0,
"index": 0,
"line": 0
},
"start": {
"column": 0,
"index": 0,
"line": 0
}
}
}
],
"selectedFile": "/storage/emulated/0/AndroidIDEProjects/Ghost-web-ide/app/src/main/java/Ninja/coder/Ghostemane/code/git/GitUtils.java"
}
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ public static String runOffline(Context context, File phpFile) throws Exception
+ new File(context.getFilesDir(), "php.ini").getPath()
+ "\""
});

return command != null ? command : "";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1529,7 +1529,7 @@ public void _fabCl() {

} else {
if (shp.getString("pos_path", "").contains(".php")) {
getmd.setClass(getApplicationContext(), PhpActivity.class);
getmd.setClass(getApplicationContext(), TerminalActivity.class);
getmd.putExtra("phpcode", shp.getString("pos_path", ""));
startActivity(getmd);
} else if (shp.getString("pos_path", "").contains(".scss")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import Ninja.coder.Ghostemane.code.filehelper.CreatorModule;
import Ninja.coder.Ghostemane.code.filehelper.FactoryModelProject;
import Ninja.coder.Ghostemane.code.folder.FileIconHelper;
import Ninja.coder.Ghostemane.code.git.GitTaskUtils;
import Ninja.coder.Ghostemane.code.git.GitListSheet;
import Ninja.coder.Ghostemane.code.interfaces.FileCallBack;
import Ninja.coder.Ghostemane.code.layoutmanager.EmptyRecyclerView;
import Ninja.coder.Ghostemane.code.layoutmanager.NavigationViewCompnet;
Expand Down Expand Up @@ -56,11 +56,9 @@
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.provider.Settings;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -78,7 +76,6 @@
import androidx.core.content.ContextCompat;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
Expand All @@ -94,9 +91,7 @@
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.hzy.lib7z.Z7Extractor;
import com.skydoves.powermenu.CircularEffect;
import com.skydoves.powermenu.PowerMenu;
import com.skydoves.powermenu.PowerMenuItem;
import com.zip4j.progress.ProgressMonitor;
import ninjacoder.ghostide.androidtools.r8.android.R8Tools;
import storage.sdcard.SdCardUtil;
Expand Down Expand Up @@ -2499,7 +2494,7 @@ public void WorkTotalEvent(int a) {}
}
case 9:
{
GitTaskUtils task = new GitTaskUtils(FileDirActivity.this, Folder);
GitListSheet task = new GitListSheet(new File(Folder),FileDirActivity.this);
sh.getDismiss(true);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
Expand All @@ -25,6 +27,7 @@ public class PhpActivity extends BaseCompat {
private Toolbar _toolbar;
private AppBarLayout _app_bar;
private CoordinatorLayout _coordinator;
private PHPServerHelper phpserverHelper;

private WebView web;

Expand All @@ -34,6 +37,15 @@ protected void onCreate(Bundle _savedInstanceState) {
setContentView(R.layout.php);
initialize(_savedInstanceState);
initializeLogic();
var myfile = new File(getIntent().getStringExtra("phpcode"));
phpserverHelper = new PHPServerHelper(this, myfile.getParentFile());
phpserverHelper.startServer(
new Handler(Looper.getMainLooper()),
new Runnable() {

@Override
public void run() {}
});
}

private void initialize(Bundle _savedInstanceState) {
Expand Down Expand Up @@ -87,10 +99,10 @@ private void initializeLogic() {

web.loadUrl(PHPServerHelper.runOffline(getApplicationContext(), file));

Intent intent = new Intent(this, PHPProcess.class);
intent.putExtra("port", 8080);
intent.putExtra("projectPath", file.getAbsolutePath());
startService(intent);
// Intent intent = new Intent(this, PHPProcess.class);
// intent.putExtra("port", 8080);
// intent.putExtra("projectPath", file.getAbsolutePath());
// startService(intent);

web.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
web.getSettings().setJavaScriptEnabled(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package Ninja.coder.Ghostemane.code.config;

import android.content.Context
import java.io.*

object CommandCompat {
fun getBasicCommand(context: Context): String {
Expand Down Expand Up @@ -28,4 +29,11 @@ object CommandCompat {
val pythonLibDirPath = "$pythonBuildDirPath/lib"
return "export PATH=\$PATH:$appLibDirPath && export PYTHONHOME=$pythonBuildDirPath && export PYTHONPATH=$appLibDirPath && export LD_LIBRARY_PATH=\"\$LD_LIBRARY_PATH:\" && export LD_LIBRARY_PATH=\"\$LD_LIBRARY_PATH${pythonLibDirPath}\" && clear && libpython3.so && echo \'[Enter to Exit]\' && read junk && exit"
}
fun getRunPhpCommand(context: Context, phpFile: File): String {
val appLibDirPath = context.applicationInfo.nativeLibraryDir
val appFileDirPath = context.filesDir.absolutePath
val phpLibDirPath = "$appFileDirPath/lib"
val phpIniPath = File(context.filesDir, "php.ini").path
return "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:$phpLibDirPath && \"$appLibDirPath/libphp-8.2.8.so\" -f \"${phpFile.path}\" -c \"$phpIniPath\" && echo \'[Enter to Exit]\' && read junk && exit"
}
}
164 changes: 164 additions & 0 deletions app/src/main/java/Ninja/coder/Ghostemane/code/git/GitListSheet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
package Ninja.coder.Ghostemane.code.git;

import Ninja.coder.Ghostemane.code.databinding.MakefolderBinding;
import Ninja.coder.Ghostemane.code.model.ListSheet;
import android.content.Context;
import android.content.DialogInterface;
import android.view.LayoutInflater;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import java.io.File;
import java.io.IOException;
import org.eclipse.jgit.api.errors.GitAPIException;

public class GitListSheet {
protected ListSheet listItem;
protected File fileDir;
protected Context ctx;
protected GitUtils utils;
private MaterialAlertDialogBuilder dialog;
private MakefolderBinding bin;

public GitListSheet(File fileDir, Context ctx) {
this.fileDir = fileDir;
this.ctx = ctx;
try {
utils = new GitUtils(fileDir);
} catch (IOException err) {
err.printStackTrace();
}
setVaribaleGit();
}

void setVaribaleGit() {
listItem = new ListSheet();
listItem.setSheetDialog(ctx);
listItem.addItem("Git init", 0, utils.isGitinit(fileDir) || utils.isRep(fileDir));
listItem.addItem("Git CreateBranch");
listItem.addItem("Git MergeBranch");
listItem.addItem("Git CommitChanges");
listItem.addItem("Git Pull");
listItem.addItem("Git Push");
listItem.addItem("Git AddAll");
listItem.addItem("Git Status");

listItem.setOnItemClickLabe(
new ListSheet.OnItemClick() {

@Override
public void OnItemClick(int pos) {
switch (pos) {
case 0:
{
try {
utils.init(fileDir);
} catch (Exception err) {
err.printStackTrace();
}
break;
}
case 1:
{
MaterialDialogHelper(
new DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface arg0, int arg1) {
try {
utils.createBranch(bin.editor.getText().toString());
} catch (Exception err) {

}
}
});

break;
}
case 2:
{
MaterialDialogHelper(
(c, d) -> {
try {
utils.mergeBranch(bin.editor.getText().toString());
} catch (Exception err) {

}
});

break;
}
case 3:
{
MaterialDialogHelper(
(c, d) -> {
try {
utils.commitChanges(bin.editor.getText().toString());
} catch (Exception err) {

}
});
break;
}

case 4:
{
MaterialDialogHelper(
(c, d) -> {
try {
utils.pull(bin.editor.getText().toString());
} catch (Exception err) {

}
});

break;
}
case 5:
{
MaterialDialogHelper(
(c, d) -> {
try {
utils.push(bin.editor.getText().toString());
} catch (Exception err) {

}
});

break;
}
case 6:
{
try {
utils.addAllFiles();
} catch (Exception err) {

}
break;
}
case 7:
{
try {
MaterialDialogHelper(null);
bin.editor.setText(utils.getUncommittedChangesAsString());
} catch (Exception err) {

}

break;
}
}
}
});
}

void MaterialDialogHelper(DialogInterface.OnClickListener di) {
// makefolder
bin = MakefolderBinding.inflate(LayoutInflater.from(ctx));
dialog = new MaterialAlertDialogBuilder(ctx);
dialog.setView(bin.getRoot());
dialog.setTitle("Helper");
dialog.setNegativeButton(android.R.string.ok, di);
if (dialog != null) {
dialog.show();
}
}
}
Loading

0 comments on commit 4c4e396

Please sign in to comment.