diff --git a/README.md b/README.md index ea918c70e..0f004ced4 100644 --- a/README.md +++ b/README.md @@ -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 . ``` + +Any violations to the license can be reported either by opening an issue or writing a mail to us directly. \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index b9684b3f2..fc5897483 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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' diff --git a/app/src/main/java/com/itsaky/androidide/app/StudioApp.java b/app/src/main/java/com/itsaky/androidide/app/StudioApp.java index 8c5de9a6d..05c1f4874 100644 --- a/app/src/main/java/com/itsaky/androidide/app/StudioApp.java +++ b/app/src/main/java/com/itsaky/androidide/app/StudioApp.java @@ -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); - } - } } diff --git a/app/src/main/java/com/itsaky/androidide/fragments/EditorFragment.java b/app/src/main/java/com/itsaky/androidide/fragments/EditorFragment.java index 97e3eea61..9b6792bb3 100644 --- a/app/src/main/java/com/itsaky/androidide/fragments/EditorFragment.java +++ b/app/src/main/java/com/itsaky/androidide/fragments/EditorFragment.java @@ -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 . * **************************************************************************************/ - - 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); diff --git a/app/src/main/java/com/itsaky/androidide/fragments/preferences/EditorPreferences.java b/app/src/main/java/com/itsaky/androidide/fragments/preferences/EditorPreferences.java index 9b43fdb11..9a26f7149 100644 --- a/app/src/main/java/com/itsaky/androidide/fragments/preferences/EditorPreferences.java +++ b/app/src/main/java/com/itsaky/androidide/fragments/preferences/EditorPreferences.java @@ -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 . * **************************************************************************************/ - - 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); diff --git a/app/src/main/java/com/itsaky/androidide/fragments/preferences/GeneralPreferences.java b/app/src/main/java/com/itsaky/androidide/fragments/preferences/GeneralPreferences.java index 1bf57122d..b63c3a0e6 100644 --- a/app/src/main/java/com/itsaky/androidide/fragments/preferences/GeneralPreferences.java +++ b/app/src/main/java/com/itsaky/androidide/fragments/preferences/GeneralPreferences.java @@ -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 . * **************************************************************************************/ - - 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); diff --git a/app/src/main/java/com/itsaky/androidide/handlers/BuildServiceHandler.java b/app/src/main/java/com/itsaky/androidide/handlers/BuildServiceHandler.java index a05429823..f68d584e0 100644 --- a/app/src/main/java/com/itsaky/androidide/handlers/BuildServiceHandler.java +++ b/app/src/main/java/com/itsaky/androidide/handlers/BuildServiceHandler.java @@ -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 . * **************************************************************************************/ - - package com.itsaky.androidide.handlers; import android.view.View; diff --git a/app/src/main/java/com/itsaky/androidide/handlers/FileOptionsHandler.java b/app/src/main/java/com/itsaky/androidide/handlers/FileOptionsHandler.java index 570601434..8ec61f295 100644 --- a/app/src/main/java/com/itsaky/androidide/handlers/FileOptionsHandler.java +++ b/app/src/main/java/com/itsaky/androidide/handlers/FileOptionsHandler.java @@ -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 . * **************************************************************************************/ - - package com.itsaky.androidide.handlers; import android.view.LayoutInflater; diff --git a/app/src/main/java/com/itsaky/androidide/handlers/IDEHandler.java b/app/src/main/java/com/itsaky/androidide/handlers/IDEHandler.java index bf41b8b93..f74760969 100644 --- a/app/src/main/java/com/itsaky/androidide/handlers/IDEHandler.java +++ b/app/src/main/java/com/itsaky/androidide/handlers/IDEHandler.java @@ -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 . * **************************************************************************************/ - - package com.itsaky.androidide.handlers; import com.itsaky.androidide.EditorActivity; diff --git a/app/src/main/java/com/itsaky/androidide/interfaces/DexResultListener.java b/app/src/main/java/com/itsaky/androidide/interfaces/DexResultListener.java index fd010fa4b..b7a94efe5 100644 --- a/app/src/main/java/com/itsaky/androidide/interfaces/DexResultListener.java +++ b/app/src/main/java/com/itsaky/androidide/interfaces/DexResultListener.java @@ -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 . * **************************************************************************************/ - - package com.itsaky.androidide.interfaces; import androidx.core.util.Pair; diff --git a/app/src/main/java/com/itsaky/androidide/interfaces/DiagnosticClickListener.java b/app/src/main/java/com/itsaky/androidide/interfaces/DiagnosticClickListener.java index 07c7fbb96..b6c72eeb9 100644 --- a/app/src/main/java/com/itsaky/androidide/interfaces/DiagnosticClickListener.java +++ b/app/src/main/java/com/itsaky/androidide/interfaces/DiagnosticClickListener.java @@ -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 . * **************************************************************************************/ - - package com.itsaky.androidide.interfaces; import com.itsaky.androidide.models.DiagnosticGroup; diff --git a/app/src/main/java/com/itsaky/androidide/interfaces/EditorActivityProvider.java b/app/src/main/java/com/itsaky/androidide/interfaces/EditorActivityProvider.java index 9bba22286..b68f60c1b 100644 --- a/app/src/main/java/com/itsaky/androidide/interfaces/EditorActivityProvider.java +++ b/app/src/main/java/com/itsaky/androidide/interfaces/EditorActivityProvider.java @@ -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 . * **************************************************************************************/ - - package com.itsaky.androidide.interfaces; import com.itsaky.androidide.EditorActivity; diff --git a/app/src/main/java/com/itsaky/androidide/language/groovy/GroovyLanguage.java b/app/src/main/java/com/itsaky/androidide/language/groovy/GroovyLanguage.java index 0d039ff27..bc9495ac2 100644 --- a/app/src/main/java/com/itsaky/androidide/language/groovy/GroovyLanguage.java +++ b/app/src/main/java/com/itsaky/androidide/language/groovy/GroovyLanguage.java @@ -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 . * **************************************************************************************/ - - 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; diff --git a/app/src/main/java/com/itsaky/androidide/language/java/JavaLanguage.java b/app/src/main/java/com/itsaky/androidide/language/java/JavaLanguage.java index 0c91b2ff0..2af870551 100644 --- a/app/src/main/java/com/itsaky/androidide/language/java/JavaLanguage.java +++ b/app/src/main/java/com/itsaky/androidide/language/java/JavaLanguage.java @@ -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; diff --git a/app/src/main/java/com/itsaky/androidide/language/xml/XMLLanguage.java b/app/src/main/java/com/itsaky/androidide/language/xml/XMLLanguage.java index 8fb224f8a..a3eb073bb 100644 --- a/app/src/main/java/com/itsaky/androidide/language/xml/XMLLanguage.java +++ b/app/src/main/java/com/itsaky/androidide/language/xml/XMLLanguage.java @@ -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 . * **************************************************************************************/ - - 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; diff --git a/app/src/main/java/com/itsaky/androidide/models/ApkMetadata.java b/app/src/main/java/com/itsaky/androidide/models/ApkMetadata.java index afdc23fc7..7dca21012 100644 --- a/app/src/main/java/com/itsaky/androidide/models/ApkMetadata.java +++ b/app/src/main/java/com/itsaky/androidide/models/ApkMetadata.java @@ -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 . * **************************************************************************************/ - - package com.itsaky.androidide.models; import java.util.List; diff --git a/app/src/main/java/com/itsaky/androidide/models/DiagnosticGroup.java b/app/src/main/java/com/itsaky/androidide/models/DiagnosticGroup.java index 640b0c517..46b49860c 100644 --- a/app/src/main/java/com/itsaky/androidide/models/DiagnosticGroup.java +++ b/app/src/main/java/com/itsaky/androidide/models/DiagnosticGroup.java @@ -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 . * **************************************************************************************/ - - package com.itsaky.androidide.models; import java.io.File; diff --git a/app/src/main/java/com/itsaky/androidide/models/License.java b/app/src/main/java/com/itsaky/androidide/models/License.java index 95dcbde7f..d45a622f5 100644 --- a/app/src/main/java/com/itsaky/androidide/models/License.java +++ b/app/src/main/java/com/itsaky/androidide/models/License.java @@ -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 . * **************************************************************************************/ - - package com.itsaky.androidide.models; import com.google.gson.annotations.SerializedName; diff --git a/app/src/main/java/com/itsaky/androidide/models/LogLine.java b/app/src/main/java/com/itsaky/androidide/models/LogLine.java index 1f597a664..e4644c4b4 100644 --- a/app/src/main/java/com/itsaky/androidide/models/LogLine.java +++ b/app/src/main/java/com/itsaky/androidide/models/LogLine.java @@ -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 . * **************************************************************************************/ - - package com.itsaky.androidide.models; import android.content.Context; diff --git a/app/src/main/java/com/itsaky/androidide/models/NewProjectDetails.java b/app/src/main/java/com/itsaky/androidide/models/NewProjectDetails.java index 693fbc03f..ad0427b0e 100644 --- a/app/src/main/java/com/itsaky/androidide/models/NewProjectDetails.java +++ b/app/src/main/java/com/itsaky/androidide/models/NewProjectDetails.java @@ -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 . * **************************************************************************************/ - - package com.itsaky.androidide.models; public class NewProjectDetails { diff --git a/app/src/main/java/com/itsaky/androidide/models/ProjectTemplate.java b/app/src/main/java/com/itsaky/androidide/models/ProjectTemplate.java index 6d3dcc5db..82ecd1aa5 100644 --- a/app/src/main/java/com/itsaky/androidide/models/ProjectTemplate.java +++ b/app/src/main/java/com/itsaky/androidide/models/ProjectTemplate.java @@ -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 . * **************************************************************************************/ - - package com.itsaky.androidide.models; import androidx.annotation.DrawableRes; diff --git a/app/src/main/java/com/itsaky/androidide/models/SearchResult.java b/app/src/main/java/com/itsaky/androidide/models/SearchResult.java index 74770fec6..425211e95 100644 --- a/app/src/main/java/com/itsaky/androidide/models/SearchResult.java +++ b/app/src/main/java/com/itsaky/androidide/models/SearchResult.java @@ -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 . * **************************************************************************************/ - - package com.itsaky.androidide.models; import java.io.File; diff --git a/app/src/main/java/com/itsaky/androidide/models/SuggestItem.java b/app/src/main/java/com/itsaky/androidide/models/SuggestItem.java index cc8f4a3d0..156582e7c 100644 --- a/app/src/main/java/com/itsaky/androidide/models/SuggestItem.java +++ b/app/src/main/java/com/itsaky/androidide/models/SuggestItem.java @@ -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 . * **************************************************************************************/ - - package com.itsaky.androidide.models; import io.github.rosemoe.editor.widget.CodeEditor; diff --git a/app/src/main/java/com/itsaky/androidide/project/IDEModule.java b/app/src/main/java/com/itsaky/androidide/project/IDEModule.java index 72fc2a349..31c6abdbc 100644 --- a/app/src/main/java/com/itsaky/androidide/project/IDEModule.java +++ b/app/src/main/java/com/itsaky/androidide/project/IDEModule.java @@ -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 . * **************************************************************************************/ - - package com.itsaky.androidide.project; import com.google.gson.annotations.SerializedName; diff --git a/app/src/main/java/com/itsaky/androidide/project/IDEProject.java b/app/src/main/java/com/itsaky/androidide/project/IDEProject.java index 32959795e..a7634884b 100644 --- a/app/src/main/java/com/itsaky/androidide/project/IDEProject.java +++ b/app/src/main/java/com/itsaky/androidide/project/IDEProject.java @@ -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 . * **************************************************************************************/ - - package com.itsaky.androidide.project; import com.google.gson.annotations.SerializedName; diff --git a/app/src/main/java/com/itsaky/androidide/project/IDETask.java b/app/src/main/java/com/itsaky/androidide/project/IDETask.java index a802529c6..ae27d1712 100644 --- a/app/src/main/java/com/itsaky/androidide/project/IDETask.java +++ b/app/src/main/java/com/itsaky/androidide/project/IDETask.java @@ -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 . * **************************************************************************************/ - - package com.itsaky.androidide.project; import com.google.gson.annotations.SerializedName; diff --git a/app/src/main/java/com/itsaky/androidide/project/ProjectResourceFinder.java b/app/src/main/java/com/itsaky/androidide/project/ProjectResourceFinder.java index e763e9782..2a7794087 100644 --- a/app/src/main/java/com/itsaky/androidide/project/ProjectResourceFinder.java +++ b/app/src/main/java/com/itsaky/androidide/project/ProjectResourceFinder.java @@ -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 . * **************************************************************************************/ - - package com.itsaky.androidide.project; import com.itsaky.androidide.ui.inflater.IResourceFinder; diff --git a/app/src/main/java/com/itsaky/androidide/sockets/SocketConnection.java b/app/src/main/java/com/itsaky/androidide/sockets/SocketConnection.java deleted file mode 100644 index 272683cb5..000000000 --- a/app/src/main/java/com/itsaky/androidide/sockets/SocketConnection.java +++ /dev/null @@ -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 . - * -**************************************************************************************/ - - -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(); -} diff --git a/app/src/main/java/com/itsaky/androidide/utils/RuntimeTypeAdapterFactory.java b/app/src/main/java/com/itsaky/androidide/utils/RuntimeTypeAdapterFactory.java index f8f46b7f6..e7c86e9ff 100644 --- a/app/src/main/java/com/itsaky/androidide/utils/RuntimeTypeAdapterFactory.java +++ b/app/src/main/java/com/itsaky/androidide/utils/RuntimeTypeAdapterFactory.java @@ -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 . - * -**************************************************************************************/ - - -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; diff --git a/app/src/main/java/com/itsaky/androidide/views/NonSwipableViewPager.java b/app/src/main/java/com/itsaky/androidide/views/NonSwipableViewPager.java index cb0360b5c..1df313972 100644 --- a/app/src/main/java/com/itsaky/androidide/views/NonSwipableViewPager.java +++ b/app/src/main/java/com/itsaky/androidide/views/NonSwipableViewPager.java @@ -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 . * **************************************************************************************/ - - package com.itsaky.androidide.views; import android.annotation.SuppressLint; diff --git a/app/src/main/java/com/itsaky/androidide/views/transition/ArcMotionPlus.java b/app/src/main/java/com/itsaky/androidide/views/transition/ArcMotionPlus.java index c59d45494..2f5e385d8 100644 --- a/app/src/main/java/com/itsaky/androidide/views/transition/ArcMotionPlus.java +++ b/app/src/main/java/com/itsaky/androidide/views/transition/ArcMotionPlus.java @@ -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 . - * -**************************************************************************************/ - - /* * Copyright (C) 2016 Neil Davies * diff --git a/app/src/main/java/com/itsaky/androidide/views/transition/CubicBezierArc.java b/app/src/main/java/com/itsaky/androidide/views/transition/CubicBezierArc.java index d138cba4f..d24615e8d 100644 --- a/app/src/main/java/com/itsaky/androidide/views/transition/CubicBezierArc.java +++ b/app/src/main/java/com/itsaky/androidide/views/transition/CubicBezierArc.java @@ -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 . - * -**************************************************************************************/ - - /* * Copyright (C) 2016 Neil Davies * diff --git a/app/src/main/java/com/itsaky/androidide/views/transition/ProgressTransition.java b/app/src/main/java/com/itsaky/androidide/views/transition/ProgressTransition.java index 3a3012aba..56b288cbd 100644 --- a/app/src/main/java/com/itsaky/androidide/views/transition/ProgressTransition.java +++ b/app/src/main/java/com/itsaky/androidide/views/transition/ProgressTransition.java @@ -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 . * **************************************************************************************/ - - package com.itsaky.androidide.views.transition; import android.animation.Animator; diff --git a/app/src/main/java/io/github/rosemoe/editor/widget/EditorAutoCompleteWindow.java b/app/src/main/java/io/github/rosemoe/editor/widget/EditorAutoCompleteWindow.java index 8be809005..891678a20 100644 --- a/app/src/main/java/io/github/rosemoe/editor/widget/EditorAutoCompleteWindow.java +++ b/app/src/main/java/io/github/rosemoe/editor/widget/EditorAutoCompleteWindow.java @@ -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 { diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index aa63d7fb5..3f60d3285 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -11,7 +11,6 @@ #70ffffff #50ffffff #f0ffffff - #90424242 #ffffff #373737 #505050 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fc828faa3..6ca163cfa 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -230,10 +230,6 @@ Can\'t proceed without storage permissions Storage permissions granted! - - Notifications from Developers - App Update Notifications - Undo Redo @@ -279,4 +275,4 @@ Please choose default font size of editor : 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? - \ No newline at end of file + diff --git a/shell/.gitignore b/common/.gitignore similarity index 100% rename from shell/.gitignore rename to common/.gitignore diff --git a/shell/build.gradle b/common/build.gradle similarity index 57% rename from shell/build.gradle rename to common/build.gradle index 912323779..228e023f7 100644 --- a/shell/build.gradle +++ b/common/build.gradle @@ -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' } diff --git a/shell/proguard-rules.pro b/common/proguard-rules.pro similarity index 100% rename from shell/proguard-rules.pro rename to common/proguard-rules.pro diff --git a/common/src/main/AndroidManifest.xml b/common/src/main/AndroidManifest.xml new file mode 100644 index 000000000..30dfa1b9b --- /dev/null +++ b/common/src/main/AndroidManifest.xml @@ -0,0 +1 @@ + diff --git a/common/src/main/java/com/itsaky/androidide/app/BaseActivity.java b/common/src/main/java/com/itsaky/androidide/app/BaseActivity.java new file mode 100644 index 000000000..672132afb --- /dev/null +++ b/common/src/main/java/com/itsaky/androidide/app/BaseActivity.java @@ -0,0 +1,4 @@ +package com.itsaky.androidide.app; + +public class BaseActivity { +} diff --git a/common/src/main/java/com/itsaky/androidide/app/BaseApplication.java b/common/src/main/java/com/itsaky/androidide/app/BaseApplication.java new file mode 100644 index 000000000..41690c84f --- /dev/null +++ b/common/src/main/java/com/itsaky/androidide/app/BaseApplication.java @@ -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 . + * + **************************************************************************************/ +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); + } + } +} diff --git a/app/src/main/java/com/itsaky/androidide/interfaces/Filter.java b/common/src/main/java/com/itsaky/androidide/interfaces/Filter.java similarity index 98% rename from app/src/main/java/com/itsaky/androidide/interfaces/Filter.java rename to common/src/main/java/com/itsaky/androidide/interfaces/Filter.java index 1df311cbc..7d5886222 100644 --- a/app/src/main/java/com/itsaky/androidide/interfaces/Filter.java +++ b/common/src/main/java/com/itsaky/androidide/interfaces/Filter.java @@ -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 . * **************************************************************************************/ - - package com.itsaky.androidide.interfaces; public interface Filter { diff --git a/app/src/main/java/com/itsaky/androidide/interfaces/ProjectWriterCallback.java b/common/src/main/java/com/itsaky/androidide/interfaces/ProjectWriterCallback.java similarity index 98% rename from app/src/main/java/com/itsaky/androidide/interfaces/ProjectWriterCallback.java rename to common/src/main/java/com/itsaky/androidide/interfaces/ProjectWriterCallback.java index 1c1255fd8..10b68e0fe 100644 --- a/app/src/main/java/com/itsaky/androidide/interfaces/ProjectWriterCallback.java +++ b/common/src/main/java/com/itsaky/androidide/interfaces/ProjectWriterCallback.java @@ -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 . * **************************************************************************************/ - - package com.itsaky.androidide.interfaces; import java.io.File; diff --git a/app/src/main/java/com/itsaky/androidide/managers/PreferenceManager.java b/common/src/main/java/com/itsaky/androidide/managers/PreferenceManager.java similarity index 90% rename from app/src/main/java/com/itsaky/androidide/managers/PreferenceManager.java rename to common/src/main/java/com/itsaky/androidide/managers/PreferenceManager.java index d631af99e..3a7a8f6fe 100644 --- a/app/src/main/java/com/itsaky/androidide/managers/PreferenceManager.java +++ b/common/src/main/java/com/itsaky/androidide/managers/PreferenceManager.java @@ -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 . * **************************************************************************************/ - - 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); - } - } diff --git a/app/src/main/java/com/itsaky/androidide/managers/ToolsManager.java b/common/src/main/java/com/itsaky/androidide/managers/ToolsManager.java similarity index 98% rename from app/src/main/java/com/itsaky/androidide/managers/ToolsManager.java rename to common/src/main/java/com/itsaky/androidide/managers/ToolsManager.java index 55f3313c7..9f287d60c 100644 --- a/app/src/main/java/com/itsaky/androidide/managers/ToolsManager.java +++ b/common/src/main/java/com/itsaky/androidide/managers/ToolsManager.java @@ -15,13 +15,12 @@ * along with AndroidIDE. If not, see . * **************************************************************************************/ - 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); diff --git a/app/src/main/java/com/itsaky/androidide/managers/VersionedFileManager.java b/common/src/main/java/com/itsaky/androidide/managers/VersionedFileManager.java similarity index 99% rename from app/src/main/java/com/itsaky/androidide/managers/VersionedFileManager.java rename to common/src/main/java/com/itsaky/androidide/managers/VersionedFileManager.java index 074a19149..519f87e0c 100644 --- a/app/src/main/java/com/itsaky/androidide/managers/VersionedFileManager.java +++ b/common/src/main/java/com/itsaky/androidide/managers/VersionedFileManager.java @@ -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 . * **************************************************************************************/ - - package com.itsaky.androidide.managers; import java.io.File; diff --git a/app/src/main/java/com/itsaky/androidide/models/ConstantsBridge.java b/common/src/main/java/com/itsaky/androidide/models/ConstantsBridge.java similarity index 79% rename from app/src/main/java/com/itsaky/androidide/models/ConstantsBridge.java rename to common/src/main/java/com/itsaky/androidide/models/ConstantsBridge.java index d5ab0c4ad..bc7941fcc 100644 --- a/app/src/main/java/com/itsaky/androidide/models/ConstantsBridge.java +++ b/common/src/main/java/com/itsaky/androidide/models/ConstantsBridge.java @@ -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 . * **************************************************************************************/ - - 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 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 "; diff --git a/app/src/main/java/com/itsaky/androidide/models/DexPair.java b/common/src/main/java/com/itsaky/androidide/models/DexPair.java similarity index 99% rename from app/src/main/java/com/itsaky/androidide/models/DexPair.java rename to common/src/main/java/com/itsaky/androidide/models/DexPair.java index eb3a083a3..c7a938ee2 100644 --- a/app/src/main/java/com/itsaky/androidide/models/DexPair.java +++ b/common/src/main/java/com/itsaky/androidide/models/DexPair.java @@ -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 . * **************************************************************************************/ - - package com.itsaky.androidide.models; import android.os.Parcelable; diff --git a/app/src/main/java/com/itsaky/androidide/models/SaveResult.java b/common/src/main/java/com/itsaky/androidide/models/SaveResult.java similarity index 99% rename from app/src/main/java/com/itsaky/androidide/models/SaveResult.java rename to common/src/main/java/com/itsaky/androidide/models/SaveResult.java index 310b4360a..1f1d1eb15 100644 --- a/app/src/main/java/com/itsaky/androidide/models/SaveResult.java +++ b/common/src/main/java/com/itsaky/androidide/models/SaveResult.java @@ -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 . * **************************************************************************************/ - - package com.itsaky.androidide.models; /** diff --git a/app/src/main/java/com/itsaky/androidide/models/SheetOption.java b/common/src/main/java/com/itsaky/androidide/models/SheetOption.java similarity index 99% rename from app/src/main/java/com/itsaky/androidide/models/SheetOption.java rename to common/src/main/java/com/itsaky/androidide/models/SheetOption.java index 5cd99b339..faf5ea91c 100644 --- a/app/src/main/java/com/itsaky/androidide/models/SheetOption.java +++ b/common/src/main/java/com/itsaky/androidide/models/SheetOption.java @@ -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 . * **************************************************************************************/ - - package com.itsaky.androidide.models; public final class SheetOption { diff --git a/shell/src/main/java/com/itsaky/androidide/shell/CommonProcessExecutor.java b/common/src/main/java/com/itsaky/androidide/shell/CommonProcessExecutor.java similarity index 100% rename from shell/src/main/java/com/itsaky/androidide/shell/CommonProcessExecutor.java rename to common/src/main/java/com/itsaky/androidide/shell/CommonProcessExecutor.java diff --git a/shell/src/main/java/com/itsaky/androidide/shell/IProcessExecutor.java b/common/src/main/java/com/itsaky/androidide/shell/IProcessExecutor.java similarity index 100% rename from shell/src/main/java/com/itsaky/androidide/shell/IProcessExecutor.java rename to common/src/main/java/com/itsaky/androidide/shell/IProcessExecutor.java diff --git a/shell/src/main/java/com/itsaky/androidide/shell/IProcessExitListener.java b/common/src/main/java/com/itsaky/androidide/shell/IProcessExitListener.java similarity index 100% rename from shell/src/main/java/com/itsaky/androidide/shell/IProcessExitListener.java rename to common/src/main/java/com/itsaky/androidide/shell/IProcessExitListener.java diff --git a/shell/src/main/java/com/itsaky/androidide/shell/ProcessExecutorFactory.java b/common/src/main/java/com/itsaky/androidide/shell/ProcessExecutorFactory.java similarity index 100% rename from shell/src/main/java/com/itsaky/androidide/shell/ProcessExecutorFactory.java rename to common/src/main/java/com/itsaky/androidide/shell/ProcessExecutorFactory.java diff --git a/shell/src/main/java/com/itsaky/androidide/shell/ProcessStreamsHolder.java b/common/src/main/java/com/itsaky/androidide/shell/ProcessStreamsHolder.java similarity index 100% rename from shell/src/main/java/com/itsaky/androidide/shell/ProcessStreamsHolder.java rename to common/src/main/java/com/itsaky/androidide/shell/ProcessStreamsHolder.java diff --git a/shell/src/main/java/com/itsaky/androidide/shell/ShellServer.java b/common/src/main/java/com/itsaky/androidide/shell/ShellServer.java similarity index 100% rename from shell/src/main/java/com/itsaky/androidide/shell/ShellServer.java rename to common/src/main/java/com/itsaky/androidide/shell/ShellServer.java diff --git a/app/src/main/java/com/itsaky/androidide/utils/Environment.java b/common/src/main/java/com/itsaky/androidide/utils/Environment.java similarity index 96% rename from app/src/main/java/com/itsaky/androidide/utils/Environment.java rename to common/src/main/java/com/itsaky/androidide/utils/Environment.java index f78ce607c..b38727742 100644 --- a/app/src/main/java/com/itsaky/androidide/utils/Environment.java +++ b/common/src/main/java/com/itsaky/androidide/utils/Environment.java @@ -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 . + * along with AndroidIDE. If not, see . * **************************************************************************************/ - - 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 blacklist = new ArrayList<>(); + private static List blacklistedVariables() { if(blacklist.isEmpty()) { blacklist.add("HOME"); diff --git a/app/src/main/java/com/itsaky/androidide/utils/FileUtil.java b/common/src/main/java/com/itsaky/androidide/utils/FileUtil.java similarity index 100% rename from app/src/main/java/com/itsaky/androidide/utils/FileUtil.java rename to common/src/main/java/com/itsaky/androidide/utils/FileUtil.java diff --git a/app/src/main/java/com/itsaky/androidide/utils/InputStreamLineReader.java b/common/src/main/java/com/itsaky/androidide/utils/InputStreamLineReader.java similarity index 100% rename from app/src/main/java/com/itsaky/androidide/utils/InputStreamLineReader.java rename to common/src/main/java/com/itsaky/androidide/utils/InputStreamLineReader.java diff --git a/app/src/main/java/com/itsaky/androidide/utils/InputStreamWriter.java b/common/src/main/java/com/itsaky/androidide/utils/InputStreamWriter.java similarity index 100% rename from app/src/main/java/com/itsaky/androidide/utils/InputStreamWriter.java rename to common/src/main/java/com/itsaky/androidide/utils/InputStreamWriter.java diff --git a/app/src/main/java/com/itsaky/androidide/utils/IntProperty.java b/common/src/main/java/com/itsaky/androidide/utils/IntProperty.java similarity index 100% rename from app/src/main/java/com/itsaky/androidide/utils/IntProperty.java rename to common/src/main/java/com/itsaky/androidide/utils/IntProperty.java diff --git a/app/src/main/java/com/itsaky/androidide/utils/JavaCharacter.java b/common/src/main/java/com/itsaky/androidide/utils/JavaCharacter.java similarity index 97% rename from app/src/main/java/com/itsaky/androidide/utils/JavaCharacter.java rename to common/src/main/java/com/itsaky/androidide/utils/JavaCharacter.java index 1b0340753..96e4df0c6 100644 --- a/app/src/main/java/com/itsaky/androidide/utils/JavaCharacter.java +++ b/common/src/main/java/com/itsaky/androidide/utils/JavaCharacter.java @@ -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 . * **************************************************************************************/ - - -package com.itsaky.androidide.language.java.manager; +package com.itsaky.androidide.utils; import java.util.Arrays; diff --git a/app/src/main/java/com/itsaky/androidide/utils/Logger.java b/common/src/main/java/com/itsaky/androidide/utils/Logger.java similarity index 97% rename from app/src/main/java/com/itsaky/androidide/utils/Logger.java rename to common/src/main/java/com/itsaky/androidide/utils/Logger.java index 1ff5a1147..85d2e06da 100644 --- a/app/src/main/java/com/itsaky/androidide/utils/Logger.java +++ b/common/src/main/java/com/itsaky/androidide/utils/Logger.java @@ -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 . * **************************************************************************************/ - - 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(); diff --git a/app/src/main/java/com/itsaky/androidide/utils/StudioUtils.java b/common/src/main/java/com/itsaky/androidide/utils/StudioUtils.java similarity index 99% rename from app/src/main/java/com/itsaky/androidide/utils/StudioUtils.java rename to common/src/main/java/com/itsaky/androidide/utils/StudioUtils.java index 98001ce1c..655d56b71 100644 --- a/app/src/main/java/com/itsaky/androidide/utils/StudioUtils.java +++ b/common/src/main/java/com/itsaky/androidide/utils/StudioUtils.java @@ -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 . * **************************************************************************************/ - - 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; diff --git a/app/src/main/java/com/itsaky/androidide/utils/TypefaceUtils.java b/common/src/main/java/com/itsaky/androidide/utils/TypefaceUtils.java similarity index 74% rename from app/src/main/java/com/itsaky/androidide/utils/TypefaceUtils.java rename to common/src/main/java/com/itsaky/androidide/utils/TypefaceUtils.java index 4ad398c5c..0fad7085e 100644 --- a/app/src/main/java/com/itsaky/androidide/utils/TypefaceUtils.java +++ b/common/src/main/java/com/itsaky/androidide/utils/TypefaceUtils.java @@ -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 . * **************************************************************************************/ - - 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"); } } diff --git a/app/src/main/java/com/itsaky/toaster/ToastWrapper.java b/common/src/main/java/com/itsaky/toaster/ToastWrapper.java similarity index 100% rename from app/src/main/java/com/itsaky/toaster/ToastWrapper.java rename to common/src/main/java/com/itsaky/toaster/ToastWrapper.java diff --git a/app/src/main/java/com/itsaky/toaster/Toaster.java b/common/src/main/java/com/itsaky/toaster/Toaster.java similarity index 89% rename from app/src/main/java/com/itsaky/toaster/Toaster.java rename to common/src/main/java/com/itsaky/toaster/Toaster.java index 1a1737fd7..357f07cca 100644 --- a/app/src/main/java/com/itsaky/toaster/Toaster.java +++ b/common/src/main/java/com/itsaky/toaster/Toaster.java @@ -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 . * **************************************************************************************/ - - 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); diff --git a/app/src/main/res/drawable/ic_error.xml b/common/src/main/res/drawable/ic_error.xml similarity index 100% rename from app/src/main/res/drawable/ic_error.xml rename to common/src/main/res/drawable/ic_error.xml diff --git a/app/src/main/res/drawable/ic_ok.xml b/common/src/main/res/drawable/ic_ok.xml similarity index 100% rename from app/src/main/res/drawable/ic_ok.xml rename to common/src/main/res/drawable/ic_ok.xml diff --git a/app/src/main/res/layout/layout_toast.xml b/common/src/main/res/layout/layout_toast.xml similarity index 100% rename from app/src/main/res/layout/layout_toast.xml rename to common/src/main/res/layout/layout_toast.xml diff --git a/common/src/main/res/values/colors.xml b/common/src/main/res/values/colors.xml new file mode 100644 index 000000000..34825eb2d --- /dev/null +++ b/common/src/main/res/values/colors.xml @@ -0,0 +1,3 @@ + + #90424242 + diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml new file mode 100644 index 000000000..27694f71a --- /dev/null +++ b/common/src/main/res/values/strings.xml @@ -0,0 +1,4 @@ + + Notifications from Developers + App Update Notifications + diff --git a/gradle.properties b/gradle.properties index 92f68a18e..036dbdbd5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle new file mode 100644 index 000000000..07adbac5f --- /dev/null +++ b/gradle/dependencies.gradle @@ -0,0 +1,9 @@ +ext { + + // Common dependencies across all subprojects + common { + utilcode = 'com.blankj:utilcodex:1.30.6' + + } + +} diff --git a/settings.gradle b/settings.gradle index 6a0246d40..b32d1feb8 100644 --- a/settings.gradle +++ b/settings.gradle @@ -6,6 +6,6 @@ include ':lsp' include ':sdk-info' include ':layout-inflater' include ':lexers' -include ':shell' +include ':common' rootProject.name = "AndroidIDE" diff --git a/shell/src/main/AndroidManifest.xml b/shell/src/main/AndroidManifest.xml deleted file mode 100644 index 7ef69d377..000000000 --- a/shell/src/main/AndroidManifest.xml +++ /dev/null @@ -1 +0,0 @@ -