Moved common clases to a separate module

This commit is contained in:
Akash Yadav
2021-12-06 11:11:42 +05:30
parent 86e30dbfbe
commit 1db1871ca6
77 changed files with 439 additions and 770 deletions
+2
View File
@@ -93,3 +93,5 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
```
Any violations to the license can be reported either by opening an issue or writing a mail to us directly.
+1 -3
View File
@@ -92,7 +92,6 @@ dependencies {
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
implementation 'com.blankj:utilcodex:1.30.6'
implementation 'com.elvishew:xlog:1.8.0'
implementation 'com.github.abhishekti7:UnicornFilePicker:1.0.2'
implementation 'com.github.bumptech.glide:glide:4.12.0'
implementation 'com.github.megatronking.stringfog:xor:1.1.0'
@@ -112,7 +111,6 @@ dependencies {
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
implementation 'androidx.drawerlayout:drawerlayout:1.1.1'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.preference:preference:1.1.1'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
@@ -132,7 +130,7 @@ dependencies {
implementation project(':lsp')
implementation project(':layout-inflater')
implementation project(':lexers')
implementation project(':shell')
implementation project(':common')
// LSP4J
implementation 'org.eclipse.lsp4j:org.eclipse.lsp4j:0.12.0'
@@ -17,54 +17,25 @@
**************************************************************************************/
package com.itsaky.androidide.app;
import android.annotation.SuppressLint;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import androidx.core.app.NotificationManagerCompat;
import androidx.multidex.MultiDexApplication;
import com.blankj.utilcode.util.EncodeUtils;
import com.blankj.utilcode.util.ResourceUtils;
import com.blankj.utilcode.util.ThrowableUtils;
import com.google.firebase.messaging.FirebaseMessaging;
import com.itsaky.androidide.R;
import com.itsaky.androidide.app.StudioApp;
import com.itsaky.androidide.language.java.manager.JavaCharacter;
import com.itsaky.androidide.language.xml.completion.XMLCompletionService;
import com.itsaky.androidide.managers.PreferenceManager;
import com.itsaky.androidide.managers.ToolsManager;
import com.itsaky.androidide.services.MessagingService;
import com.itsaky.androidide.shell.ShellServer;
import com.itsaky.androidide.ui.inflater.ILayoutInflater;
import com.itsaky.androidide.ui.inflater.LayoutInflaterConfiguration;
import com.itsaky.androidide.utils.Environment;
import com.itsaky.androidide.utils.FileUtil;
import com.itsaky.androidide.utils.Logger;
import com.itsaky.androidide.utils.StudioUtils;
import com.itsaky.apiinfo.ApiInfo;
import com.itsaky.attrinfo.AttrInfo;
import com.itsaky.toaster.Toaster;
import com.itsaky.widgets.WidgetInfo;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Arrays;
public class StudioApp extends MultiDexApplication {
public class StudioApp extends BaseApplication {
private static StudioApp instance;
private StudioUtils mUtils;
private PreferenceManager mPrefsManager;
private NotificationManager mNotificationManager;
private boolean stopGradleDaemon = true;
private static String sArch = "";
private static ApiInfo mApiInfo;
private static AttrInfo mAttrInfo;
private static WidgetInfo mWidgetInfo;
@@ -73,42 +44,14 @@ public class StudioApp extends MultiDexApplication {
private static ILayoutInflater mLayoutInflater;
public static final boolean DEBUG = com.itsaky.androidide.BuildConfig.DEBUG;
public static final long BUSYBOX_VERSION = 1;
public static final String TAG = "StudioApp";
public static final String ASSETS_DATA_DIR = "data/";
public static final String NOTIFICATION_ID_UPDATE = "17571";
public static final String NOTIFICATION_ID_DEVS = "17572";
public static final String TELEGRAM_GROUP_URL = "https://t.me/androidide_discussions";
public static final String SUGGESTIONS_URL = "https://github.com/itsaky/AndroidIDE";
public static final String WEBSITE = "https://androidide.com";
public static final String EMAIL = "contact@androidide.com";
private Thread.UncaughtExceptionHandler uncaughtExceptionHandler;
private static final Logger LOG = Logger.instance("StudioApp");
@Override
public void onCreate() {
this.instance = this;
this.uncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler((thread, ex) -> handleCrash(thread, ex));
super.onCreate();
mPrefsManager = new PreferenceManager(this);
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
JavaCharacter.initMap();
ToolsManager.init(this, null);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
createNotificationChannels();
}
FirebaseMessaging.getInstance().subscribeToTopic(MessagingService.TOPIC_UPDATE);
FirebaseMessaging.getInstance().subscribeToTopic(MessagingService.TOPIC_DEV_MSGS);
@@ -128,39 +71,6 @@ public class StudioApp extends MultiDexApplication {
os.close();
} catch (IOException e) {}
}
@SuppressLint("NewApi")
private void createNotificationChannels() {
NotificationChannel updateChannel = new NotificationChannel(NOTIFICATION_ID_UPDATE, getNotificationChannelNameForId(NOTIFICATION_ID_UPDATE), NotificationManager.IMPORTANCE_HIGH);
updateChannel.enableLights(true);
updateChannel.enableVibration(true);
updateChannel.setLightColor(Color.RED);
updateChannel.setVibrationPattern(new long[]{10, 50, 10});
NotificationManagerCompat.from(this).createNotificationChannel(updateChannel);
NotificationChannel devsChannels = new NotificationChannel(NOTIFICATION_ID_DEVS, getNotificationChannelNameForId(NOTIFICATION_ID_DEVS), NotificationManager.IMPORTANCE_MIN);
devsChannels.enableLights(true);
devsChannels.enableVibration(true);
devsChannels.setLightColor(Color.BLUE);
devsChannels.setVibrationPattern(new long[]{10, 50, 10});
NotificationManagerCompat.from(this).createNotificationChannel(devsChannels);
}
public String getNotificationChannelNameForId(String id) {
if(id.equals(NOTIFICATION_ID_UPDATE))
return getUpdateNotificationChannelName();
else if(id.equals(NOTIFICATION_ID_DEVS))
return getDevNotificationChannelName();
else return "AndroidIDE Notifications";
}
private String getUpdateNotificationChannelName() {
return getString(R.string.cms_channel_id_update);
}
private String getDevNotificationChannelName() {
return getString(R.string.cms_channel_id_devs);
}
public void createInflater (LayoutInflaterConfiguration config) {
this.mLayoutInflater = ILayoutInflater.newInstance(config);
@@ -222,223 +132,4 @@ public class StudioApp extends MultiDexApplication {
public static StudioApp getInstance() {
return instance;
}
public ShellServer newShell(ShellServer.Callback callback) {
return newShell(callback, true);
}
public ShellServer newShell(ShellServer.Callback callback, boolean redirectErrors) {
ShellServer shellServer = new ShellServer(callback, "sh", Environment.mkdirIfNotExits(getRootDir()).getAbsolutePath(), Environment.getEnvironment(true), redirectErrors);
shellServer.start();
return shellServer;
}
public void writeException(Throwable th) {
FileUtil.writeFile(new File(FileUtil.getExternalStorageDir(), "idelog.txt").getAbsolutePath(), ThrowableUtils.getFullStackTrace(th));
}
public File getIndexedDir() {
return Environment.mkdirIfNotExits(new File(getRootDir(), "indexed"));
}
public File getD8Jar() {
File f = new File(getRootDir(), "d8.jar");
if(f.exists() && f.isFile())
return f;
if(ResourceUtils.copyFileFromAssets(ToolsManager.getCommonAsset("d8.jar"), f.getAbsolutePath())) {
return f;
}
return null;
}
public File getRootDir() {
return new File(getIDEDataDir(), "framework");
}
public File getRootDirOld() {
return new File(getFilesDir(), "framework");
}
@SuppressLint("SdCardPath")
public File getIDEDataDir() {
return Environment.mkdirIfNotExits(new File("/data/data/com.itsaky.androidide/files"));
}
public final File getLogSenderDir() {
return new File(getRootDir(), "logsender");
}
public final File getToolsDownloadDirectory() {
return new File(getRootDir(), "downloads");
}
public final File getTempProjectDir() {
return Environment.mkdirIfNotExits(new File(Environment.TMP_DIR, "tempProject"));
}
public final File getTempClassesDir() {
return Environment.mkdirIfNotExits(new File(FileUtil.getExternalStorageDir() /*getTempProjectDir() */, "classes"));
}
public final String getDownloadRequestUrl() {
return new String(EncodeUtils.base64Decode("aHR0cHM6Ly9hbmRyb2lkaWRlLmNvbS9idWlsZC90b29scy9kb3dubG9hZC8="));
}
public boolean isFrameworkDownloaded() {
return getToolsDownloadDirectory().exists() && mPrefsManager.isFrameworkDownloaded();
}
public boolean isFrameworkInstalled() {
return getRootDir().exists() && mPrefsManager.isFrameworkInstalled();
}
public PreferenceManager getPrefManager() {
return mPrefsManager;
}
public File getProjectsDir() {
return Environment.PROJECTS_DIR;
}
public File[] listProjects() {
return getProjectsDir().listFiles(p1 -> p1.isDirectory());
}
public static boolean is64Bit() {
return isAarch64();
}
public static boolean is32Bit() {
return isArmv7a();
}
public static boolean isAbiSupported () {
return isAarch64() || isArmv7a();
}
public static boolean isAarch64 () {
return Arrays.stream(android.os.Build.SUPPORTED_ABIS).anyMatch("arm64-v8a"::equals);
}
public static boolean isArmv7a () {
return Arrays.stream(android.os.Build.SUPPORTED_ABIS).anyMatch("armeabi-v7a"::equals);
}
public static String getArch() {
if (StudioApp.isAarch64()) {
return "arm64-v8a";
} else if (StudioApp.isArmv7a()) {
return "armeabi-v7a";
}
throw new UnsupportedOperationException ("Device not supported");
}
private void handleCrash(Thread thread, Throwable th) {
writeException(th);
if(this.uncaughtExceptionHandler != null) {
this.uncaughtExceptionHandler.uncaughtException(thread, th);
}
// TODO Show exception in another activity
try {
android.os.Process.killProcess(android.os.Process.myPid());
} catch (Throwable ignored) {
// ignored
}
}
public String getAssetsDataFile() {
return ASSETS_DATA_DIR;
}
public String getAssetsDataFile(String str) {
return new StringBuffer().append(getAssetsDataFile()).append(str).toString();
}
public StudioUtils getUtils() {
return mUtils == null ? mUtils = new StudioUtils(this) : mUtils;
}
public void toast(String msg, Toaster.Type type) {
getUtils().toast(msg, type);
}
public void toast(int msg, Toaster.Type type) {
getUtils().toast(msg, type);
}
public void toastLong(String msg, Toaster.Type type) {
getUtils().toastLong(msg, type);
}
public void toastLong(int msg, Toaster.Type type) {
getUtils().toastLong(msg, type);
}
public static File getCompilerOut() {
return new File(FileUtil.getExternalStorageDir(), "ide_xlog/compiler_out.txt");
}
public static File getCompilerError() {
return new File(FileUtil.getExternalStorageDir(), "ide_xlog/compiler_err.txt");
}
public void openTelegramGroup() {
try {
Intent open = new Intent();
open.setAction(Intent.ACTION_VIEW);
open.setData(Uri.parse(StudioApp.TELEGRAM_GROUP_URL));
open.setPackage("org.telegram.messenger");
open.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(open);
} catch (Throwable th) {
try {
Intent open = new Intent();
open.setAction(Intent.ACTION_VIEW);
open.setData(Uri.parse(StudioApp.TELEGRAM_GROUP_URL));
open.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(open);
} catch (Throwable th2) {
toast(th2.getMessage(), Toaster.Type.ERROR);
}
}
}
public void openIssueTracker() {
try {
Intent open = new Intent();
open.setAction(Intent.ACTION_VIEW);
open.setData(Uri.parse(StudioApp.SUGGESTIONS_URL));
open.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(open);
} catch (Throwable th) {
toast(th.getMessage(), Toaster.Type.ERROR);
}
}
public void openWebsite() {
try {
Intent open = new Intent();
open.setAction(Intent.ACTION_VIEW);
open.setData(Uri.parse(StudioApp.WEBSITE));
open.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(open);
} catch (Throwable th) {
toast(th.getMessage(), Toaster.Type.ERROR);
}
}
public void emailUs() {
try {
Intent open = new Intent();
open.setAction(Intent.ACTION_VIEW);
open.setData(Uri.parse("mailto:" + EMAIL));
open.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(open);
} catch (Throwable th) {
toast(th.getMessage(), Toaster.Type.ERROR);
}
}
}
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.fragments;
import android.os.Bundle;
@@ -69,8 +65,8 @@ public class EditorFragment extends BaseFragment implements EditorEventListener
private FileOpenListener mOpenListener;
private static AndroidProject mProject;
public static final String KEY_FILE_PATH = "file_path";
public static final String KEY_PROJECT = "project";
public static final String KEY_FILE_PATH = "file_path";
public static final String KEY_PROJECT = "project";
public static final String KEY_LINE_START = "line_start";
public static final String KEY_LINE_END = "line_end";
public static final String KEY_COLUMN_START = "col_start";
@@ -226,7 +222,7 @@ public class EditorFragment extends BaseFragment implements EditorEventListener
boolean drawHexChanged = isFirstCreate || ConstantsBridge.EDITORPREF_DRAW_HEX_CHANGED;
final PreferenceManager prefs = getStudioActivity().getApp().getPrefManager();
if(sizeChanged) {
float textSize = prefs.getFloat(EditorPreferences.KEY_EDITOR_FONT_SIZE);
float textSize = prefs.getFloat(PreferenceManager.KEY_EDITOR_FONT_SIZE);
if(textSize < 6 || textSize > 32)
textSize = 14;
mBinding.editor.setTextSize(textSize);
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.fragments.preferences;
import android.content.DialogInterface;
@@ -36,12 +32,6 @@ import static com.itsaky.androidide.managers.PreferenceManager.*;
public class EditorPreferences extends BasePreferenceFragment implements Preference.OnPreferenceChangeListener, Preference.OnPreferenceClickListener {
public static final String KEY_EDITOR_FONT_SIZE = "idepref_editor_fontSize";
public static final String KEY_EDITOR_PRINTABLE_CHARS = "idepref_editor_nonPrintableFlags";
public static final String KEY_EDITOR_DRAW_HEX = "idepref_editor_drawHexColors";
public static final String KEY_EDITOR_TAB_SIZE = "idepref_editor_tabSize";
public static final String KEY_EDITOR_JAVADOC_ENABLED = "idepref_editor_javadocEnabled";
@Override
public void onCreatePreferences(Bundle p1, String p2) {
super.onCreatePreferences(p1, p2);
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.fragments.preferences;
import android.os.Bundle;
@@ -27,11 +23,10 @@ import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
import com.itsaky.androidide.R;
import static com.itsaky.androidide.managers.PreferenceManager.*;
public class GeneralPreferences extends BasePreferenceFragment implements Preference.OnPreferenceChangeListener {
public static final String KEY_OPEN_PROJECTS = "idepref_general_autoOpenProjects";
public static final String KEY_CONFIRM_PROJECT_OPEN = "idepref_general_confirmProjectOpen";
@Override
public void onCreatePreferences(Bundle p1, String p2) {
super.onCreatePreferences(p1, p2);
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.handlers;
import android.view.View;
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.handlers;
import android.view.LayoutInflater;
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.handlers;
import com.itsaky.androidide.EditorActivity;
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.interfaces;
import androidx.core.util.Pair;
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.interfaces;
import com.itsaky.androidide.models.DiagnosticGroup;
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.interfaces;
import com.itsaky.androidide.EditorActivity;
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,14 +15,12 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.language.groovy;
import com.itsaky.androidide.language.BaseLanguage;
import com.itsaky.androidide.language.java.manager.JavaCharacter;
import com.itsaky.androidide.lexers.groovy.GroovyLexer;
import com.itsaky.androidide.lsp.LSPProvider;
import com.itsaky.androidide.utils.JavaCharacter;
import com.itsaky.lsp.services.IDELanguageServer;
import io.github.rosemoe.editor.interfaces.AutoCompleteProvider;
import io.github.rosemoe.editor.interfaces.CodeAnalyzer;
@@ -17,12 +17,12 @@
**************************************************************************************/
package com.itsaky.androidide.language.java;
import com.itsaky.androidide.language.BaseLanguage;
import com.itsaky.androidide.lexers.java.JavaLexer;
import com.itsaky.androidide.lexers.java.JavaParser;
import com.itsaky.androidide.language.BaseLanguage;
import com.itsaky.androidide.language.java.manager.JavaCharacter;
import com.itsaky.androidide.lsp.LSPProvider;
import com.itsaky.androidide.syntax.lexer.impls.java.JavaLexerImpl;
import com.itsaky.androidide.utils.JavaCharacter;
import com.itsaky.lsp.services.IDELanguageServer;
import io.github.rosemoe.editor.interfaces.AutoCompleteProvider;
import io.github.rosemoe.editor.interfaces.CodeAnalyzer;
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,19 +15,16 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.language.xml;
import com.itsaky.androidide.language.BaseLanguage;
import com.itsaky.androidide.language.java.manager.JavaCharacter;
import com.itsaky.androidide.lexers.xml.XMLLexer;
import com.itsaky.androidide.lsp.LSPProvider;
import com.itsaky.androidide.utils.JavaCharacter;
import com.itsaky.lsp.services.IDELanguageServer;
import io.github.rosemoe.editor.interfaces.AutoCompleteProvider;
import io.github.rosemoe.editor.interfaces.CodeAnalyzer;
import io.github.rosemoe.editor.interfaces.NewlineHandler;
import io.github.rosemoe.editor.text.TextUtils;
import io.github.rosemoe.editor.widget.SymbolPairMatch;
import java.io.File;
import java.io.StringReader;
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.models;
import java.util.List;
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.models;
import java.io.File;
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.models;
import com.google.gson.annotations.SerializedName;
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.models;
import android.content.Context;
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.models;
public class NewProjectDetails {
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.models;
import androidx.annotation.DrawableRes;
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.models;
import java.io.File;
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.models;
import io.github.rosemoe.editor.widget.CodeEditor;
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.project;
import com.google.gson.annotations.SerializedName;
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.project;
import com.google.gson.annotations.SerializedName;
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.project;
import com.google.gson.annotations.SerializedName;
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.project;
import com.itsaky.androidide.ui.inflater.IResourceFinder;
@@ -1,108 +0,0 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.sockets;
import com.blankj.utilcode.util.CloseUtils;
import com.blankj.utilcode.util.ThrowableUtils;
import com.google.gson.Gson;
import com.itsaky.androidide.utils.Logger;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Socket;
public abstract class SocketConnection extends Thread {
private final String host;
private final int port;
protected Socket mSocket;
protected BufferedOutputStream mWriter;
public static final String LOCALHOST = "localhost";
public SocketConnection(int port) {
this(LOCALHOST, port);
}
public SocketConnection(String host, int port) {
this.host = host;
this.port = port;
}
protected abstract void onConnected();
protected abstract void onDisconnected();
protected abstract void onFailedToConnect(Throwable exception);
protected abstract void onResponse(String line);
protected void write(Object msg) {
writeString(GSON.toJson(msg));
}
protected void writeString(String msg) {
new Thread(() -> {
try {
final String message = msg + "\n";
mWriter.write(message.getBytes());
mWriter.flush();
} catch (Throwable e) {
}
}).start();
}
@Override
public void run() {
try {
mSocket = tryConnect();
onConnected();
final BufferedReader reader = new BufferedReader(new InputStreamReader(mSocket.getInputStream()));
String line;
while((line = reader.readLine()) != null) {
onResponse(line);
}
CloseUtils.closeIOQuietly(mWriter, mSocket);
onDisconnected();
} catch (Throwable e) {
onFailedToConnect(e);
}
}
private Socket tryConnect() {
Socket socket = null;
while(socket == null || !socket.isConnected() || mWriter == null) {
try {
socket = new Socket(host, port);
OutputStream os = socket.getOutputStream();
if(os != null)
mWriter = new BufferedOutputStream(os);
} catch (Throwable th){}
}
return socket;
}
protected String ex(Throwable th) {
return ThrowableUtils.getFullStackTrace(th);
}
protected static final Logger LOG = Logger.instance("SocketConnection");
protected static Gson GSON = new Gson();
}
@@ -1,26 +1,3 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.utils;
/*
* Copyright (C) 2011 Google Inc.
*
@@ -36,6 +13,7 @@ package com.itsaky.androidide.utils;
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.itsaky.androidide.utils;
import java.io.IOException;
import java.util.LinkedHashMap;
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.views;
import android.annotation.SuppressLint;
@@ -1,24 +1,3 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
/*
* Copyright (C) 2016 Neil Davies
*
@@ -1,24 +1,3 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
/*
* Copyright (C) 2016 Neil Davies
*
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.views.transition;
import android.animation.Animator;
@@ -27,19 +27,18 @@ import android.view.LayoutInflater;
import android.view.View;
import android.widget.Toast;
import com.itsaky.androidide.databinding.LayoutCompletionWindowBinding;
import com.itsaky.androidide.language.java.manager.JavaCharacter;
import com.itsaky.androidide.utils.JavaCharacter;
import io.github.rosemoe.editor.interfaces.AutoCompleteProvider;
import io.github.rosemoe.editor.text.CharPosition;
import io.github.rosemoe.editor.text.Content;
import io.github.rosemoe.editor.text.TextAnalyzeResult;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.lsp4j.Command;
import org.eclipse.lsp4j.CompletionItem;
import org.eclipse.lsp4j.Position;
import org.eclipse.lsp4j.Range;
import org.eclipse.lsp4j.TextEdit;
import org.eclipse.lsp4j.Command;
import io.github.rosemoe.editor.text.ContentLine;
public class EditorAutoCompleteWindow extends EditorBasePopupWindow {
-1
View File
@@ -11,7 +11,6 @@
<color name="secondaryTextColor">#70ffffff</color>
<color name="secondaryTextColor_light">#50ffffff</color>
<color name="secondaryTextColor_lighter">#f0ffffff</color>
<color name="color_toast_background">#90424242</color>
<color name="primaryIconColor">#ffffff</color>
<color name="completionList_background">#373737</color>
<color name="completionList_backgroundSelected">#505050</color>
+1 -5
View File
@@ -230,10 +230,6 @@
<string name="msg_storage_denied">Can\'t proceed without storage permissions</string>
<string name="msg_storage_granted">Storage permissions granted!</string>
<!-- Notifications -->
<string name="cms_channel_id_devs">Notifications from Developers</string>
<string name="cms_channel_id_update">App Update Notifications</string>
<!-- Code Editor -->
<string name="undo">Undo</string>
<string name="redo">Redo</string>
@@ -279,4 +275,4 @@
<string name="msg_editor_font_size">Please choose default font size of editor :</string>
<string name="msg_clear_cache">This will delete caches directory created by Gradle. If you delete it, the next build may take a bit longer than normal as Gradle will download required files again.\nIMPORTANT: This will also delete AAPT2. You will need to reinstall it otherwise you\'ll end up with a build failure.\n\nAre you sure you want to delete caches?</string>
</resources>
</resources>
@@ -11,6 +11,8 @@ android {
versionName rootProject.ext.versionName
}
buildFeatures.viewBinding true
compileOptions {
sourceCompatibility rootProject.ext.javaSourceVersion
targetCompatibility rootProject.ext.javaTargetVersion
@@ -25,4 +27,15 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.blankj:utilcodex:1.30.6'
implementation 'com.elvishew:xlog:1.8.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'androidx.preference:preference:1.1.1'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
implementation 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
api 'androidx.multidex:multidex:2.0.1'
}
+1
View File
@@ -0,0 +1 @@
<manifest package="com.itsaky.androidide.common"/>
@@ -0,0 +1,4 @@
package com.itsaky.androidide.app;
public class BaseActivity {
}
@@ -0,0 +1,325 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.app;
import android.annotation.SuppressLint;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import androidx.core.app.NotificationManagerCompat;
import androidx.multidex.MultiDexApplication;
import com.blankj.utilcode.util.EncodeUtils;
import com.blankj.utilcode.util.ResourceUtils;
import com.blankj.utilcode.util.ThrowableUtils;
import com.itsaky.androidide.managers.PreferenceManager;
import com.itsaky.androidide.managers.ToolsManager;
import com.itsaky.androidide.shell.ShellServer;
import com.itsaky.androidide.utils.Environment;
import com.itsaky.androidide.utils.FileUtil;
import com.itsaky.androidide.utils.JavaCharacter;
import com.itsaky.androidide.utils.StudioUtils;
import com.itsaky.toaster.Toaster;
import java.io.File;
import java.util.Arrays;
public abstract class BaseApplication extends MultiDexApplication {
private static BaseApplication instance;
private StudioUtils mUtils;
private PreferenceManager mPrefsManager;
private NotificationManager mNotificationManager;
private Thread.UncaughtExceptionHandler uncaughtExceptionHandler;
public static final long BUSYBOX_VERSION = 1;
public static final String TAG = "StudioApp";
public static final String ASSETS_DATA_DIR = "data/";
public static final String NOTIFICATION_ID_UPDATE = "17571";
public static final String NOTIFICATION_ID_DEVS = "17572";
public static final String TELEGRAM_GROUP_URL = "https://t.me/androidide_discussions";
public static final String SUGGESTIONS_URL = "https://github.com/itsaky/AndroidIDE";
public static final String WEBSITE = "https://androidide.com";
public static final String EMAIL = "contact@androidide.com";
@Override
public void onCreate() {
this.instance = this;
this.uncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler((thread, ex) -> handleCrash(thread, ex));
super.onCreate();
mPrefsManager = new PreferenceManager(this);
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
JavaCharacter.initMap();
ToolsManager.init(this, null);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
createNotificationChannels();
}
}
@SuppressLint("NewApi")
private void createNotificationChannels() {
NotificationChannel updateChannel = new NotificationChannel(NOTIFICATION_ID_UPDATE, getNotificationChannelNameForId(NOTIFICATION_ID_UPDATE), NotificationManager.IMPORTANCE_HIGH);
updateChannel.enableLights(true);
updateChannel.enableVibration(true);
updateChannel.setLightColor(Color.RED);
updateChannel.setVibrationPattern(new long[]{10, 50, 10});
NotificationManagerCompat.from(this).createNotificationChannel(updateChannel);
NotificationChannel devsChannels = new NotificationChannel(NOTIFICATION_ID_DEVS, getNotificationChannelNameForId(NOTIFICATION_ID_DEVS), NotificationManager.IMPORTANCE_MIN);
devsChannels.enableLights(true);
devsChannels.enableVibration(true);
devsChannels.setLightColor(Color.BLUE);
devsChannels.setVibrationPattern(new long[]{10, 50, 10});
NotificationManagerCompat.from(this).createNotificationChannel(devsChannels);
}
public String getNotificationChannelNameForId(String id) {
if(id.equals(NOTIFICATION_ID_UPDATE))
return getUpdateNotificationChannelName();
else if(id.equals(NOTIFICATION_ID_DEVS))
return getDevNotificationChannelName();
else return "AndroidIDE Notifications";
}
private String getUpdateNotificationChannelName() {
return getString(com.itsaky.androidide.common.R.string.cms_channel_id_update);
}
private String getDevNotificationChannelName() {
return getString(com.itsaky.androidide.common.R.string.cms_channel_id_devs);
}
public static BaseApplication getBaseInstance () {
return instance;
}
public ShellServer newShell(ShellServer.Callback callback) {
return newShell(callback, true);
}
public ShellServer newShell(ShellServer.Callback callback, boolean redirectErrors) {
ShellServer shellServer = new ShellServer(callback, "sh", Environment.mkdirIfNotExits(getRootDir()).getAbsolutePath(), Environment.getEnvironment(true), redirectErrors);
shellServer.start();
return shellServer;
}
public void writeException(Throwable th) {
FileUtil.writeFile(new File(FileUtil.getExternalStorageDir(), "idelog.txt").getAbsolutePath(), ThrowableUtils.getFullStackTrace(th));
}
public File getIndexedDir() {
return Environment.mkdirIfNotExits(new File(getRootDir(), "indexed"));
}
public File getD8Jar() {
File f = new File(getRootDir(), "d8.jar");
if(f.exists() && f.isFile())
return f;
if(ResourceUtils.copyFileFromAssets(ToolsManager.getCommonAsset("d8.jar"), f.getAbsolutePath())) {
return f;
}
return null;
}
public File getRootDir() {
return new File(getIDEDataDir(), "framework");
}
public File getRootDirOld() {
return new File(getFilesDir(), "framework");
}
@SuppressLint("SdCardPath")
public File getIDEDataDir() {
return Environment.mkdirIfNotExits(new File("/data/data/com.itsaky.androidide/files"));
}
public final File getLogSenderDir() {
return new File(getRootDir(), "logsender");
}
public final File getToolsDownloadDirectory() {
return new File(getRootDir(), "downloads");
}
public final File getTempProjectDir() {
return Environment.mkdirIfNotExits(new File(Environment.TMP_DIR, "tempProject"));
}
public final File getTempClassesDir() {
return Environment.mkdirIfNotExits(new File(FileUtil.getExternalStorageDir() /*getTempProjectDir() */, "classes"));
}
public final String getDownloadRequestUrl() {
return new String(EncodeUtils.base64Decode("aHR0cHM6Ly9hbmRyb2lkaWRlLmNvbS9idWlsZC90b29scy9kb3dubG9hZC8="));
}
public boolean isFrameworkDownloaded() {
return getToolsDownloadDirectory().exists() && mPrefsManager.isFrameworkDownloaded();
}
public boolean isFrameworkInstalled() {
return getRootDir().exists() && mPrefsManager.isFrameworkInstalled();
}
public PreferenceManager getPrefManager() {
return mPrefsManager;
}
public File getProjectsDir() {
return Environment.PROJECTS_DIR;
}
public File[] listProjects() {
return getProjectsDir().listFiles(p1 -> p1.isDirectory());
}
public static boolean is64Bit() {
return isAarch64();
}
public static boolean is32Bit() {
return isArmv7a();
}
public static boolean isAbiSupported () {
return isAarch64() || isArmv7a();
}
public static boolean isAarch64 () {
return Arrays.stream(android.os.Build.SUPPORTED_ABIS).anyMatch("arm64-v8a"::equals);
}
public static boolean isArmv7a () {
return Arrays.stream(android.os.Build.SUPPORTED_ABIS).anyMatch("armeabi-v7a"::equals);
}
public static String getArch() {
if (BaseApplication.isAarch64()) {
return "arm64-v8a";
} else if (BaseApplication.isArmv7a()) {
return "armeabi-v7a";
}
throw new UnsupportedOperationException ("Device not supported");
}
private void handleCrash(Thread thread, Throwable th) {
writeException(th);
if(this.uncaughtExceptionHandler != null) {
this.uncaughtExceptionHandler.uncaughtException(thread, th);
}
// TODO Show exception in another activity
try {
android.os.Process.killProcess(android.os.Process.myPid());
} catch (Throwable ignored) {
// ignored
}
}
public String getAssetsDataFile() {
return ASSETS_DATA_DIR;
}
public String getAssetsDataFile(String str) {
return new StringBuffer().append(getAssetsDataFile()).append(str).toString();
}
public StudioUtils getUtils() {
return mUtils == null ? mUtils = new StudioUtils(this) : mUtils;
}
public void toast(String msg, Toaster.Type type) {
getUtils().toast(msg, type);
}
public void toast(int msg, Toaster.Type type) {
getUtils().toast(msg, type);
}
public void toastLong(String msg, Toaster.Type type) {
getUtils().toastLong(msg, type);
}
public void toastLong(int msg, Toaster.Type type) {
getUtils().toastLong(msg, type);
}
public void openTelegramGroup() {
try {
Intent open = new Intent();
open.setAction(Intent.ACTION_VIEW);
open.setData(Uri.parse(BaseApplication.TELEGRAM_GROUP_URL));
open.setPackage("org.telegram.messenger");
open.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(open);
} catch (Throwable th) {
try {
Intent open = new Intent();
open.setAction(Intent.ACTION_VIEW);
open.setData(Uri.parse(BaseApplication.TELEGRAM_GROUP_URL));
open.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(open);
} catch (Throwable th2) {
toast(th2.getMessage(), Toaster.Type.ERROR);
}
}
}
public void openIssueTracker() {
try {
Intent open = new Intent();
open.setAction(Intent.ACTION_VIEW);
open.setData(Uri.parse(BaseApplication.SUGGESTIONS_URL));
open.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(open);
} catch (Throwable th) {
toast(th.getMessage(), Toaster.Type.ERROR);
}
}
public void openWebsite() {
try {
Intent open = new Intent();
open.setAction(Intent.ACTION_VIEW);
open.setData(Uri.parse(BaseApplication.WEBSITE));
open.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(open);
} catch (Throwable th) {
toast(th.getMessage(), Toaster.Type.ERROR);
}
}
public void emailUs() {
try {
Intent open = new Intent();
open.setAction(Intent.ACTION_VIEW);
open.setData(Uri.parse("mailto:" + EMAIL));
open.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(open);
} catch (Throwable th) {
toast(th.getMessage(), Toaster.Type.ERROR);
}
}
}
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.interfaces;
public interface Filter<T> {
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.interfaces;
import java.io.File;
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,15 +15,11 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.managers;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import com.itsaky.androidide.fragments.preferences.EditorPreferences;
import com.itsaky.androidide.fragments.preferences.GeneralPreferences;
public class PreferenceManager {
@@ -36,13 +30,19 @@ public class PreferenceManager {
public static final String KEY_FRAMEWORK_DOWNLOADED = "framework_downloaded";
public static final String KEY_FRAMEWORK_INSTALLED = "framework_installed";
public static final String KEY_IS_FIRST_PROJECT_BUILD = "project_isFirstBuild";
public static final String KEY_OPEN_PROJECTS = "idepref_general_autoOpenProjects";
public static final String KEY_CONFIRM_PROJECT_OPEN = "idepref_general_confirmProjectOpen";
public static final String KEY_EDITORFLAG_WS_LEADING = "idepref_editor_wsLeading";
public static final String KEY_EDITORFLAG_WS_TRAILING = "idepref_editor_wsTrailing";
public static final String KEY_EDITORFLAG_WS_INNER = "idepref_editor_wsInner";
public static final String KEY_EDITORFLAG_WS_EMPTY_LINE = "idepref_editor_wsEmptyLine";
public static final String KEY_EDITORFLAG_LINE_BREAK = "idepref_editor_lineBreak";
public static final String KEY_EDITOR_DRAW_HEX = "idepref_editor_drawHexColors";
public static final String KEY_EDITOR_FONT_SIZE = "idepref_editor_fontSize";
public static final String KEY_EDITOR_PRINTABLE_CHARS = "idepref_editor_nonPrintableFlags";
public static final String KEY_EDITOR_TAB_SIZE = "idepref_editor_tabSize";
public static final String KEY_GRADLE_CURRENT_DIR = "idepref_customGradle_currentFolder";
public static final String KEY_GRADLE_FILENAMES = "idepref_customGradle_folderNames";
@@ -175,23 +175,14 @@ public class PreferenceManager {
}
public int getEditorTabSize() {
return getInt(EditorPreferences.KEY_EDITOR_TAB_SIZE, 4);
return getInt(KEY_EDITOR_TAB_SIZE, 4);
}
public boolean autoOpenProject() {
return getBoolean(GeneralPreferences.KEY_OPEN_PROJECTS, true);
return getBoolean(KEY_OPEN_PROJECTS, true);
}
public boolean confirmProjectOpen() {
return getBoolean(GeneralPreferences.KEY_CONFIRM_PROJECT_OPEN, false);
return getBoolean(KEY_CONFIRM_PROJECT_OPEN, false);
}
public void setJavadocHighlightEnabled (boolean enabled) {
putBoolean(EditorPreferences.KEY_EDITOR_JAVADOC_ENABLED, enabled);
}
public boolean isJavadocHighlightEnabled() {
return getBoolean(EditorPreferences.KEY_EDITOR_JAVADOC_ENABLED, true);
}
}
@@ -15,13 +15,12 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.managers;
import com.blankj.utilcode.util.FileIOUtils;
import com.blankj.utilcode.util.ResourceUtils;
import com.blankj.utilcode.util.ZipUtils;
import com.itsaky.androidide.app.StudioApp;
import com.itsaky.androidide.app.BaseApplication;
import com.itsaky.androidide.utils.Environment;
import com.itsaky.androidide.utils.Logger;
import java.io.File;
@@ -41,10 +40,10 @@ public class ToolsManager {
public static final String KEY_CLEANER_VERSION = "tools_cleanerVersion";
public static final String KEY_GRADLE_API_VERSION = "tools_gradleApiVersion";
public static String ARCH_SPECIFIC_ASSET_DATA_DIR = "data/" + StudioApp.getArch();
public static String ARCH_SPECIFIC_ASSET_DATA_DIR = "data/" + BaseApplication.getArch();
public static String COMMON_ASSET_DATA_DIR = "data/common";
public static void init(StudioApp app, Runnable onFinish) {
public static void init(BaseApplication app, Runnable onFinish) {
prefs = app.getPrefManager();
copyBusyboxIfNeeded();
extractJlsIfNeeded();
@@ -87,7 +86,6 @@ public class ToolsManager {
FileIOUtils.writeFileFromString(Environment.INIT_SCRIPT, INIT_SCRIPT);
}
private static void extractJlsIfNeeded() {
final boolean isOld = JLS_VERSION > prefs.getInt(KEY_JLS_VERSION, 0);
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.managers;
import java.io.File;
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.models;
import java.util.List;
@@ -32,17 +28,6 @@ public class ConstantsBridge {
public static boolean SPLASH_TO_MAIN = false;
public static List<String> PROJECT_DEXES = null;
// Password unzipping the JLS stored in assets
// Real password is admin@androidide.com
// This will he further encrypted by StringFog at compile time
public static final String JLS_ZIP_PASSWORD_HASH = "865dabea6f06fea1a3dd572e58a4a81c";
// Password for GradleApi zip
// Real password is gradle-api@admin@androidide
public static final String GRADLE_API_ZIP_PASSWORD_HASH = "b50b462f8e8c5789f32428d7e1967da2";
// Always compared in lowercase
public static final String CUSTOM_COMMENT_WARNING_TOKEN = "#warn ";
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.models;
import android.os.Parcelable;
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.models;
/**
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.models;
public final class SheetOption {
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -14,18 +12,15 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.utils;
import android.annotation.SuppressLint;
import android.os.Build;
import com.blankj.utilcode.util.FileIOUtils;
import com.blankj.utilcode.util.FileUtils;
import com.itsaky.androidide.app.StudioApp;
import java.io.File;
import java.io.StringReader;
import java.util.ArrayList;
@@ -33,6 +28,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import com.itsaky.androidide.app.BaseApplication;
@SuppressLint("SdCardPath")
public final class Environment {
@@ -77,7 +73,7 @@ public final class Environment {
private static final Logger LOG = Logger.instance("Environment");
static {
final StudioApp app = StudioApp.getInstance();
final BaseApplication app = BaseApplication.getBaseInstance();
ROOT = app.getIDEDataDir();
SYSROOT = mkdirIfNotExits(new File(app.getIDEDataDir(), "sysroot"));
HOME = mkdirIfNotExits(app.getRootDir());
@@ -158,7 +154,7 @@ public final class Environment {
ENV_VARS.put("LC_ALL", "en_US.UTF-8");
if(!publicUse) {
// These environment variables must not be accessed to users
// These environment variables are not supposed to be accessed by users
ENV_VARS.put("JLS_HOME", JLS_HOME.getAbsolutePath());
}
@@ -180,7 +176,7 @@ public final class Environment {
ld += LIBDIR.getAbsolutePath();
ENV_VARS.put("LD_LIBRARY_PATH", ld);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && StudioApp.isAarch64()) {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && BaseApplication.isAarch64()) {
ENV_VARS.put("LD_PRELOAD", LIBHOOK.getAbsolutePath());
}
@@ -257,6 +253,7 @@ public final class Environment {
}
private static final List<String> blacklist = new ArrayList<>();
private static List<String> blacklistedVariables() {
if(blacklist.isEmpty()) {
blacklist.add("HOME");
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,9 +15,7 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.language.java.manager;
package com.itsaky.androidide.utils;
import java.util.Arrays;
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.utils;
import com.elvishew.xlog.LogConfiguration;
@@ -51,7 +47,7 @@ public class Logger {
LogConfiguration config = new LogConfiguration.Builder()
.disableStackTrace()
.disableThreadInfo()
.logLevel(com.itsaky.androidide.BuildConfig.DEBUG ? LogLevel.ALL : LogLevel.NONE)
.logLevel(LogLevel.ALL)
.tag("AndroidIDE")
.disableBorder()
.build();
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,12 +15,11 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.utils;
import android.content.Context;
import com.itsaky.toaster.Toaster;
import android.util.TypedValue;
import com.itsaky.toaster.Toaster;
public class StudioUtils {
private Context mContext;
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,24 +15,22 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.utils;
import android.graphics.Typeface;
import com.itsaky.androidide.app.StudioApp;
import com.itsaky.androidide.app.BaseApplication;
public class TypefaceUtils {
public static Typeface quicksand() {
return Typeface.createFromAsset(StudioApp.getInstance().getAssets(), "fonts/quicksand.ttf");
return Typeface.createFromAsset(BaseApplication.getBaseInstance().getAssets(), "fonts/quicksand.ttf");
}
public static Typeface jetbrainsMono() {
return Typeface.createFromAsset(StudioApp.getInstance().getAssets(), "fonts/jetbrains-mono.ttf");
return Typeface.createFromAsset(BaseApplication.getBaseInstance().getAssets(), "fonts/jetbrains-mono.ttf");
}
public static Typeface josefinSans() {
return Typeface.createFromAsset(StudioApp.getInstance().getAssets(), "fonts/josefin-sans.ttf");
return Typeface.createFromAsset(BaseApplication.getBaseInstance().getAssets(), "fonts/josefin-sans.ttf");
}
}
@@ -1,8 +1,6 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
*
*
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.toaster;
import android.content.Context;
@@ -28,20 +24,13 @@ import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.core.content.ContextCompat;
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat;
import com.itsaky.androidide.R;
import com.itsaky.androidide.databinding.LayoutToastBinding;
import android.os.Looper;
import com.blankj.utilcode.util.ThreadUtils;
public class Toaster {
private LayoutToastBinding binding;
private com.itsaky.androidide.common.databinding.LayoutToastBinding binding;
private Toast mToast;
private Context mContext;
@@ -69,20 +58,20 @@ public class Toaster {
}
protected void createView() {
binding = LayoutToastBinding.inflate(LayoutInflater.from(mContext));
binding = com.itsaky.androidide.common.databinding.LayoutToastBinding.inflate(LayoutInflater.from(mContext));
binding.toastToastWrapper.setToasterInstance(this);
}
protected Drawable createBackgroundDrawable() {
GradientDrawable drawable = new GradientDrawable();
drawable.setShape(GradientDrawable.RECTANGLE);
drawable.setColor(ContextCompat.getColor(mContext, R.color.color_toast_background));
drawable.setColor(ContextCompat.getColor(mContext, com.itsaky.androidide.common.R.color.color_toast_background));
drawable.setCornerRadius(25);
return drawable;
}
protected AnimatedVectorDrawableCompat createToastIconAnimation(int tintColor) {
AnimatedVectorDrawableCompat imageDrawable = AnimatedVectorDrawableCompat.create(mContext, mType == Type.SUCCESS ? R.drawable.ic_ok : R.drawable.ic_error);
AnimatedVectorDrawableCompat imageDrawable = AnimatedVectorDrawableCompat.create(mContext, mType == Type.SUCCESS ? com.itsaky.androidide.common.R.drawable.ic_ok : com.itsaky.androidide.common.R.drawable.ic_error);
imageDrawable.setTint(tintColor);
imageDrawable.setTintMode(PorterDuff.Mode.SRC_ATOP);
binding.toastImage.setImageDrawable(imageDrawable);
+3
View File
@@ -0,0 +1,3 @@
<resources>
<color name="color_toast_background">#90424242</color>
</resources>
+4
View File
@@ -0,0 +1,4 @@
<resources>
<string name="cms_channel_id_devs">Notifications from Developers</string>
<string name="cms_channel_id_update">App Update Notifications</string>
</resources>
+1 -16
View File
@@ -1,19 +1,4 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Build configuration
org.gradle.jvmargs=-Xmx1024m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
+9
View File
@@ -0,0 +1,9 @@
ext {
// Common dependencies across all subprojects
common {
utilcode = 'com.blankj:utilcodex:1.30.6'
}
}
+1 -1
View File
@@ -6,6 +6,6 @@ include ':lsp'
include ':sdk-info'
include ':layout-inflater'
include ':lexers'
include ':shell'
include ':common'
rootProject.name = "AndroidIDE"
-1
View File
@@ -1 +0,0 @@
<manifest package="com.itsaky.androidide.shell"/>