diff --git a/README.md b/README.md index eb02ed43..e2a1decf 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,6 @@ Floating mod menu for il2cpp and other native android games. KittyMemory, MSHook Support Android 4.4.x up to Android S Preview. ARMv7, x86 and ARM64 architecture supported. -# Preview - ![](https://i.imgur.com/zeumkBG.gif) # Known bug @@ -17,11 +15,23 @@ Download this repo as ZIP, or clone using any git tools Or download Releases here https://github.com/LGLTeam/Android-Mod-Menu/releases -# Get started +# Getting started **Go to this Wiki page to start reading:** https://github.com/LGLTeam/Android-Mod-Menu/wiki +# Help, Support, FAQ + +See: [Frequently Asked Questions (FAQ)](https://github.com/LGLTeam/Android-Mod-Menu/wiki/FAQ) where common questions are answered. + +If you have installation or usage problems, try asking your questions on the forum sites, [Platinmods](https://platinmods.com/forums/modding-questions-discussions.11/), or [UnknownCheats](https://www.unknowncheats.me/forum/android/) or others. + +For example, if you have an issue with Hooking and game crashes, you should go to the **support forums**. Here there are no teachers who can help you with such issues. + +Issues are disabled permanently due to peoples who have no mind (mostly newbies) aren't even able to fill proper issue templates nor are they able to read the instructions. I get so many useless issues, even useless pull-requests. + +As a result, the contact infomation has been removed as well. However you can find me in our Telegram channel. I will only talk to peoples who are very skilled, have proper brain and have patience! I will BLOCK if I feel like you are annoying, disrespectful and acting like a kid + # Credits Thanks to the following individuals whose code helped me develop this mod menu diff --git a/app/build.gradle b/app/build.gradle index 835eed68..e4daf641 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,7 +7,7 @@ android { minSdkVersion 19 targetSdkVersion 32 versionCode 1 - versionName "3.0" + versionName "3.1" ndk { abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86' } diff --git a/app/src/main/java/com/android/support/CrashHandler.java b/app/src/main/java/com/android/support/CrashHandler.java new file mode 100644 index 00000000..e93f3c90 --- /dev/null +++ b/app/src/main/java/com/android/support/CrashHandler.java @@ -0,0 +1,144 @@ +//Credit: Raunak Mods - https://t.me/raunakmods786 + +package com.android.support; + +import android.app.Activity; +import android.app.AlertDialog; +import android.app.Application; +import android.content.ActivityNotFoundException; +import android.content.ClipData; +import android.content.ClipboardManager; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; +import android.content.res.Resources; +import android.os.Build; +import android.os.Bundle; +import android.text.Html; +import android.text.InputFilter; +import android.text.InputType; +import android.text.TextUtils; +import android.text.method.DigitsKeyListener; +import android.util.Log; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.view.inputmethod.InputMethodManager; +import android.widget.EditText; +import android.widget.HorizontalScrollView; +import android.widget.LinearLayout; +import android.widget.ScrollView; +import android.widget.TextView; +import android.widget.Toast; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.lang.Thread.UncaughtExceptionHandler; +import java.text.SimpleDateFormat; +import java.util.Date; + +public final class CrashHandler { + + public static final UncaughtExceptionHandler DEFAULT_UNCAUGHT_EXCEPTION_HANDLER = Thread.getDefaultUncaughtExceptionHandler(); + + public static void init(final Context app, final boolean overlayRequired) { + Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + + @Override + public void uncaughtException(Thread thread, Throwable throwable) { + Log.e("AppCrash", "Error just lunched "); + try { + tryUncaughtException(thread, throwable); + } catch (Throwable e) { + e.printStackTrace(); + if (DEFAULT_UNCAUGHT_EXCEPTION_HANDLER != null) + DEFAULT_UNCAUGHT_EXCEPTION_HANDLER.uncaughtException(thread, throwable); + else + System.exit(2); + } + } + + private void tryUncaughtException(Thread thread, Throwable throwable) { + Log.e("AppCrash", "Try saving log"); + + final String time = new SimpleDateFormat("yyyy_MM_dd-HH_mm_ss").format(new Date()); + String fileName = "mod_menu_crash_" + time + ".txt"; + String dirName; + + if (Build.VERSION.SDK_INT >= 30) { //Android R. AIDE didn't support Build.VERSION_CODES.R + dirName = "/storage/emulated/0/Documents/"; + } else { + dirName = String.valueOf(app.getExternalFilesDir(null)); + } + + File crashFile = new File(dirName, fileName); + + String versionName = "unknown"; + long versionCode = 0; + try { + PackageInfo packageInfo = app.getPackageManager().getPackageInfo(app.getPackageName(), 0); + versionName = packageInfo.versionName; + versionCode = Build.VERSION.SDK_INT >= 28 ? packageInfo.getLongVersionCode() + : packageInfo.versionCode; + } catch (PackageManager.NameNotFoundException ignored) { + } + + String fullStackTrace; + { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + throwable.printStackTrace(pw); + fullStackTrace = sw.toString(); + pw.close(); + } + + StringBuilder devInfo = new StringBuilder(); + devInfo.append("************* Crash Head ****************\n"); + devInfo.append("Time Of Crash : ").append(time).append("\n"); + devInfo.append("Device Manufacturer: ").append(Build.MANUFACTURER).append("\n"); + devInfo.append("Device Model : ").append(Build.MODEL).append("\n"); + devInfo.append("Android Version : ").append(Build.VERSION.RELEASE).append("\n"); + devInfo.append("Android SDK : ").append(Build.VERSION.SDK_INT).append("\n"); + devInfo.append("App VersionName : ").append(versionName).append("\n"); + devInfo.append("App VersionCode : ").append(versionCode).append("\n"); + devInfo.append("************* Crash Head ****************\n"); + devInfo.append("\n").append(fullStackTrace); + + String errorLog = devInfo.toString(); + + try { + writeFile(crashFile, errorLog); + } catch (IOException ignored) { + } + + Toast.makeText(app, "Game has crashed unexpectedly", Toast.LENGTH_LONG).show(); + Toast.makeText(app, "Log saved to: " + String.valueOf(crashFile).replace("/storage/emulated/0/", ""), Toast.LENGTH_LONG).show(); + + Log.e("AppCrash", "Done"); + + System.exit(2); + } + + private void writeFile(File file, String content) throws IOException { + File parentFile = file.getParentFile(); + if (parentFile != null && !parentFile.exists()) { + parentFile.mkdirs(); + } + file.createNewFile(); + FileOutputStream fos = new FileOutputStream(file); + fos.write(content.getBytes()); + try { + fos.close(); + } catch (IOException e) { + } + } + }); + } +} + diff --git a/app/src/main/java/com/android/support/Launcher.java b/app/src/main/java/com/android/support/Launcher.java index a8c67160..a1de4842 100644 --- a/app/src/main/java/com/android/support/Launcher.java +++ b/app/src/main/java/com/android/support/Launcher.java @@ -66,4 +66,9 @@ public void onTaskRemoved(Intent intent) { } stopSelf(); } + + //Override our Start Command so the Service doesnt try to recreate itself when the App is closed + public int onStartCommand(Intent intent, int i, int i2) { + return Service.START_NOT_STICKY; + } } diff --git a/app/src/main/java/com/android/support/Main.java b/app/src/main/java/com/android/support/Main.java index 8d74cc3e..517d19ce 100644 --- a/app/src/main/java/com/android/support/Main.java +++ b/app/src/main/java/com/android/support/Main.java @@ -21,7 +21,7 @@ public class Main { private static native void CheckOverlayPermission(Context context); public static void StartWithoutPermission(Context context) { - + CrashHandler.init(context, true); if (context instanceof Activity) { //Check if context is an Activity. Menu menu = new Menu(context); @@ -34,6 +34,8 @@ public static void StartWithoutPermission(Context context) { } public static void Start(Context context) { + CrashHandler.init(context, false); + CheckOverlayPermission(context); } } diff --git a/app/src/main/java/com/android/support/MainActivity.java b/app/src/main/java/com/android/support/MainActivity.java index 3aacfcec..2eedc4c9 100644 --- a/app/src/main/java/com/android/support/MainActivity.java +++ b/app/src/main/java/com/android/support/MainActivity.java @@ -15,6 +15,14 @@ public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + /*Thread.setDefaultUncaughtExceptionHandler( + new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread thread, Throwable e) { + Log.e("AppCrash", "Error just lunched "); + } + });*/ + //To launch game activity if (!hasLaunched) { @@ -33,6 +41,7 @@ protected void onCreate(Bundle savedInstanceState) { } //Launch mod menu. - Main.StartWithoutPermission(this); + // Main.StartWithoutPermission(this); + Main.Start(this); } } diff --git a/app/src/main/java/com/android/support/Menu.java b/app/src/main/java/com/android/support/Menu.java index 71a77bea..97344bc7 100644 --- a/app/src/main/java/com/android/support/Menu.java +++ b/app/src/main/java/com/android/support/Menu.java @@ -2,6 +2,7 @@ package com.android.support; +import android.annotation.SuppressLint; import android.app.Activity; import android.app.AlertDialog; import android.app.Service; @@ -55,13 +56,14 @@ import java.util.Arrays; import java.util.LinkedList; import java.util.List; -import java.util.Objects; import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; import static android.widget.RelativeLayout.ALIGN_PARENT_LEFT; import static android.widget.RelativeLayout.ALIGN_PARENT_RIGHT; +import org.xml.sax.ErrorHandler; + public class Menu { //********** Here you can easly change the menu appearance **********// @@ -101,7 +103,7 @@ public class Menu { ImageView startimage; FrameLayout rootFrame; ScrollView scrollView; - boolean stopChecking; + boolean stopChecking, overlayRequired; Context getContext; //initialize methods from the native library @@ -120,6 +122,7 @@ public class Menu { //Here we write the code for our Menu // Reference: https://www.androidhive.info/2016/11/android-floating-widget-like-facebook-chat-head/ public Menu(Context context) { + getContext = context; Preferences.context = context; rootFrame = new FrameLayout(context); // Global markup @@ -343,6 +346,7 @@ public void run() { }, 500); } + @SuppressLint("WrongConstant") public void SetWindowManagerWindowService() { //Variable to check later if the phone supports Draw over other apps permission int iparams = Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O ? 2038 : 2002; @@ -354,8 +358,11 @@ public void SetWindowManagerWindowService() { mWindowManager = (WindowManager) getContext.getSystemService(getContext.WINDOW_SERVICE); mWindowManager.addView(rootFrame, vmParams); + + overlayRequired = true; } + @SuppressLint("WrongConstant") public void SetWindowManagerActivity() { vmParams = new WindowManager.LayoutParams( WindowManager.LayoutParams.WRAP_CONTENT, @@ -436,9 +443,9 @@ private void featureList(String[] listFT, LinearLayout linearLayout) { boolean switchedOn = false; //Log.i("featureList", listFT[i]); String feature = listFT[i]; - if (feature.contains("True_")) { + if (feature.contains("_True")) { switchedOn = true; - feature = feature.replaceFirst("True_", ""); + feature = feature.replaceFirst("_True", ""); } linearLayout = llBak; @@ -477,13 +484,13 @@ private void featureList(String[] listFT, LinearLayout linearLayout) { Spinner(linearLayout, featNum, strSplit[1], strSplit[2]); break; case "InputText": - TextField(linearLayout, featNum, strSplit[1], false, 0); + InputText(linearLayout, featNum, strSplit[1]); break; case "InputValue": if (strSplit.length == 3) - TextField(linearLayout, featNum, strSplit[2], true, Integer.parseInt(strSplit[1])); + InputNum(linearLayout, featNum, strSplit[2], Integer.parseInt(strSplit[1])); if (strSplit.length == 2) - TextField(linearLayout, featNum, strSplit[1], true, 0); + InputNum(linearLayout, featNum, strSplit[1], 0); break; case "CheckBox": CheckBox(linearLayout, featNum, strSplit[1], switchedOn); @@ -492,7 +499,7 @@ private void featureList(String[] listFT, LinearLayout linearLayout) { RadioButton(linearLayout, featNum, strSplit[1], strSplit[2]); break; case "Collapse": - Collapse(linearLayout, strSplit[1]); + Collapse(linearLayout, strSplit[1], switchedOn); subFeat++; break; case "ButtonLink": @@ -697,7 +704,7 @@ private void Spinner(LinearLayout linLayout, final int featNum, final String fea // to keep the down arrow symbol. No arrow symbol if setBackgroundColor set LinearLayout linearLayout2 = new LinearLayout(getContext); LinearLayout.LayoutParams layoutParams2 = new LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT); - layoutParams2.setMargins(7, 2, 7, 5); + layoutParams2.setMargins(7, 2, 7, 2); linearLayout2.setOrientation(LinearLayout.VERTICAL); linearLayout2.setBackgroundColor(BTN_COLOR); linearLayout2.setLayoutParams(layoutParams2); @@ -726,23 +733,14 @@ public void onNothingSelected(AdapterView parent) { linLayout.addView(linearLayout2); } - private void TextField(LinearLayout linLayout, final int featNum, final String featName, final boolean numOnly, final int maxValue) { - final EditTextString edittextstring = new EditTextString(); - final EditTextNum edittextnum = new EditTextNum(); + private void InputNum(LinearLayout linLayout, final int featNum, final String featName, final int maxValue) { LinearLayout linearLayout = new LinearLayout(getContext); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT); layoutParams.setMargins(7, 5, 7, 5); final Button button = new Button(getContext); - if (numOnly) { - int num = Preferences.loadPrefInt(featName, featNum); - edittextnum.setNum((num == 0) ? 1 : num); - button.setText(Html.fromHtml(featName + ": " + ((num == 0) ? 1 : num) + "")); - } else { - String string = Preferences.loadPrefString(featName, featNum); - edittextstring.setString((string == "") ? "" : string); - button.setText(Html.fromHtml(featName + ": " + string + "")); - } + int num = Preferences.loadPrefInt(featName, featNum); + button.setText(Html.fromHtml(featName + ": " + ((num == 0) ? 1 : num) + "")); button.setAllCaps(false); button.setLayoutParams(layoutParams); button.setBackgroundColor(BTN_COLOR); @@ -750,45 +748,99 @@ private void TextField(LinearLayout linLayout, final int featNum, final String f button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - final AlertDialog alert = new AlertDialog.Builder(getContext, 2).create(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - Objects.requireNonNull(alert.getWindow()).setType(Build.VERSION.SDK_INT >= 26 ? 2038 : 2002); - } - alert.setOnCancelListener(new DialogInterface.OnCancelListener() { - public void onCancel(DialogInterface dialog) { + AlertDialog.Builder alertName = new AlertDialog.Builder(getContext); + final EditText editText = new EditText(getContext); + if (maxValue != 0) + editText.setHint("Max value: " + maxValue); + editText.setInputType(InputType.TYPE_CLASS_NUMBER); + editText.setKeyListener(DigitsKeyListener.getInstance("0123456789-")); + InputFilter[] FilterArray = new InputFilter[1]; + FilterArray[0] = new InputFilter.LengthFilter(10); + editText.setFilters(FilterArray); + editText.setOnFocusChangeListener(new View.OnFocusChangeListener() { + @Override + public void onFocusChange(View v, boolean hasFocus) { InputMethodManager imm = (InputMethodManager) getContext.getSystemService(getContext.INPUT_METHOD_SERVICE); - imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); + if (hasFocus) { + imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY); + } else { + imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); + } } }); + editText.requestFocus(); + + alertName.setTitle("Input number"); + alertName.setView(editText); + LinearLayout layoutName = new LinearLayout(getContext); + layoutName.setOrientation(LinearLayout.VERTICAL); + layoutName.addView(editText); // displays the user input bar + alertName.setView(layoutName); + + alertName.setPositiveButton("OK", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int whichButton) { + int num; + try { + num = Integer.parseInt(TextUtils.isEmpty(editText.getText().toString()) ? "0" : editText.getText().toString()); + if (maxValue != 0 && num >= maxValue) + num = maxValue; + } catch (NumberFormatException ex) { + if (maxValue != 0) + num = maxValue; + else + num = 2147483640; + } - //LinearLayout - LinearLayout linearLayout1 = new LinearLayout(getContext.getApplicationContext()); - linearLayout1.setPadding(5, 5, 5, 5); - linearLayout1.setOrientation(LinearLayout.VERTICAL); - linearLayout1.setBackgroundColor(MENU_FEATURE_BG_COLOR); + button.setText(Html.fromHtml(featName + ": " + num + "")); + Preferences.changeFeatureInt(featName, featNum, num); - //TextView - final TextView TextViewNote = new TextView(getContext.getApplicationContext()); - TextViewNote.setText("Tap OK to apply changes. Tap outside to cancel"); - if (maxValue != 0) - TextViewNote.setText("Tap OK to apply changes. Tap outside to cancel\nMax value: " + maxValue); - TextViewNote.setTextColor(TEXT_COLOR_2); - - //Edit text - final EditText edittext = new EditText(getContext.getApplicationContext()); - edittext.setMaxLines(1); - edittext.setWidth(convertDipToPixels(300)); - edittext.setTextColor(TEXT_COLOR_2); - if (numOnly) { - edittext.setInputType(InputType.TYPE_CLASS_NUMBER); - edittext.setKeyListener(DigitsKeyListener.getInstance("0123456789-")); - InputFilter[] FilterArray = new InputFilter[1]; - FilterArray[0] = new InputFilter.LengthFilter(10); - edittext.setFilters(FilterArray); + editText.setFocusable(false); + } + }); + + alertName.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int whichButton) { + // dialog.cancel(); // closes dialog + InputMethodManager imm = (InputMethodManager) getContext.getSystemService(getContext.INPUT_METHOD_SERVICE); + imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); + } + }); + + if (overlayRequired) { + AlertDialog dialog = alertName.create(); // display the dialog + dialog.getWindow().setType(Build.VERSION.SDK_INT >= 26 ? 2038 : 2002); + dialog.show(); } else { - edittext.setText(edittextstring.getString()); + alertName.show(); } - edittext.setOnFocusChangeListener(new View.OnFocusChangeListener() { + } + }); + + linearLayout.addView(button); + linLayout.addView(linearLayout); + } + + private void InputText(LinearLayout linLayout, final int featNum, final String featName) { + LinearLayout linearLayout = new LinearLayout(getContext); + LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT); + layoutParams.setMargins(7, 5, 7, 5); + + final Button button = new Button(getContext); + + String string = Preferences.loadPrefString(featName, featNum); + button.setText(Html.fromHtml(featName + ": " + string + "")); + + button.setAllCaps(false); + button.setLayoutParams(layoutParams); + button.setBackgroundColor(BTN_COLOR); + button.setTextColor(TEXT_COLOR_2); + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + AlertDialog.Builder alertName = new AlertDialog.Builder(getContext); + + final EditText editText = new EditText(getContext); + editText.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { InputMethodManager imm = (InputMethodManager) getContext.getSystemService(getContext.INPUT_METHOD_SERVICE); @@ -799,45 +851,40 @@ public void onFocusChange(View v, boolean hasFocus) { } } }); - edittext.requestFocus(); - - //Button - Button btndialog = new Button(getContext); - btndialog.setBackgroundColor(BTN_COLOR); - btndialog.setTextColor(TEXT_COLOR_2); - btndialog.setText("OK"); - btndialog.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if (numOnly) { - int num; - try { - num = Integer.parseInt(TextUtils.isEmpty(edittext.getText().toString()) ? "0" : edittext.getText().toString()); - if (maxValue != 0 && num >= maxValue) - num = maxValue; - } catch (NumberFormatException ex) { - num = 2147483640; - } - edittextnum.setNum(num); - button.setText(Html.fromHtml(featName + ": " + num + "")); - alert.dismiss(); - Preferences.changeFeatureInt(featName, featNum, num); - } else { - String str = edittext.getText().toString(); - edittextstring.setString(edittext.getText().toString()); - button.setText(Html.fromHtml(featName + ": " + str + "")); - alert.dismiss(); - Preferences.changeFeatureString(featName, featNum, str); - } - edittext.setFocusable(false); + editText.requestFocus(); + + alertName.setTitle("Input text"); + alertName.setView(editText); + LinearLayout layoutName = new LinearLayout(getContext); + layoutName.setOrientation(LinearLayout.VERTICAL); + layoutName.addView(editText); // displays the user input bar + alertName.setView(layoutName); + + alertName.setPositiveButton("OK", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int whichButton) { + String str = editText.getText().toString(); + button.setText(Html.fromHtml(featName + ": " + str + "")); + Preferences.changeFeatureString(featName, featNum, str); + editText.setFocusable(false); + } + }); + + alertName.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int whichButton) { + //dialog.cancel(); // closes dialog + InputMethodManager imm = (InputMethodManager) getContext.getSystemService(getContext.INPUT_METHOD_SERVICE); + imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); } }); - linearLayout1.addView(TextViewNote); - linearLayout1.addView(edittext); - linearLayout1.addView(btndialog); - alert.setView(linearLayout1); - alert.show(); + + if (overlayRequired) { + AlertDialog dialog = alertName.create(); // display the dialog + dialog.getWindow().setType(Build.VERSION.SDK_INT >= 26 ? 2038 : 2002); + dialog.show(); + } else { + alertName.show(); + } } }); @@ -904,7 +951,7 @@ public void onClick(View v) { linLayout.addView(radioGroup); } - private void Collapse(LinearLayout linLayout, final String text) { + private void Collapse(LinearLayout linLayout, final String text, final boolean expanded) { LinearLayout.LayoutParams layoutParamsLL = new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT); layoutParamsLL.setMargins(0, 5, 0, 0); @@ -928,8 +975,14 @@ private void Collapse(LinearLayout linLayout, final String text) { textView.setTextColor(TEXT_COLOR_2); textView.setTypeface(null, Typeface.BOLD); textView.setPadding(0, 20, 0, 20); + + if (expanded) { + collapseSub.setVisibility(View.VISIBLE); + textView.setText("△ " + text + " △"); + } + textView.setOnClickListener(new View.OnClickListener() { - boolean isChecked; + boolean isChecked = expanded; @Override public void onClick(View v) { @@ -978,11 +1031,6 @@ private void WebTextView(LinearLayout linLayout, String text) { linLayout.addView(wView); } - //Override our Start Command so the Service doesnt try to recreate itself when the App is closed - public int onStartCommand(Intent intent, int i, int i2) { - return Service.START_NOT_STICKY; - } - private boolean isViewCollapsed() { return rootFrame == null || mCollapsed.getVisibility() == View.VISIBLE; } @@ -993,7 +1041,7 @@ private int convertDipToPixels(int i) { } private int dp(int i) { - return (int) TypedValue.applyDimension(1, (float) i, getContext.getResources().getDisplayMetrics()); + return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) i, getContext.getResources().getDisplayMetrics()); } public void setVisibility(int view) { @@ -1007,29 +1055,4 @@ public void onDestroy() { mWindowManager.removeView(rootFrame); } } - - private class EditTextString { - private String text; - - public void setString(String s) { - text = s; - } - - public String getString() { - return text; - } - } - - private class EditTextNum { - private int val; - - public void setNum(int i) { - val = i; - } - - public int getNum() { - return val; - } - } - } \ No newline at end of file diff --git a/app/src/main/jni/Main.cpp b/app/src/main/jni/Main.cpp index 2a690400..9350fc03 100644 --- a/app/src/main/jni/Main.cpp +++ b/app/src/main/jni/Main.cpp @@ -170,7 +170,7 @@ jobjectArray GetFeatureList(JNIEnv *env, jobject context) { OBFUSCATE("CollapseAdd_Button_The button"), //Create new collapse again - OBFUSCATE("Collapse_Collapse 2"), + OBFUSCATE("Collapse_Collapse 2_True"), OBFUSCATE("CollapseAdd_SeekBar_The slider_1_100"), OBFUSCATE("CollapseAdd_InputValue_Input number"), diff --git a/app/src/main/jni/Menu/Setup.h b/app/src/main/jni/Menu/Setup.h index 93e38462..9a57e1fc 100644 --- a/app/src/main/jni/Menu/Setup.h +++ b/app/src/main/jni/Menu/Setup.h @@ -1,5 +1,6 @@ #include #include "Menu/Menu.h" +#include "Menu/get_device_api_level_inlines.h" //Jni stuff from MrDarkRX https://github.com/MrDarkRXx/DarkMod-Floating void setDialog(jobject ctx, JNIEnv *env, const char *title, const char *msg){ @@ -84,18 +85,22 @@ void CheckOverlayPermission(JNIEnv *env, jclass thiz, jobject ctx){ LOGI(OBFUSCATE("Check overlay permission")); - jclass Settigs = env->FindClass(OBFUSCATE("android/provider/Settings")); - jmethodID canDraw =env->GetStaticMethodID(Settigs,OBFUSCATE("canDrawOverlays"),OBFUSCATE("(Landroid/content/Context;)Z")); - if (!env->CallStaticBooleanMethod(Settigs, canDraw, ctx)){ - Toast(env,ctx,OBFUSCATE("Overlay permission is required in order to show mod menu."),1); - Toast(env,ctx,OBFUSCATE("Overlay permission is required in order to show mod menu."),1); - startActivityPermisson(env, ctx); - - pthread_t ptid; - pthread_create(&ptid, NULL, exit_thread, NULL); - return; + int sdkVer = api_level(); + if (sdkVer >= 23){ //Android 6.0 + jclass Settings = env->FindClass(OBFUSCATE("android/provider/Settings")); + jmethodID canDraw =env->GetStaticMethodID(Settings, OBFUSCATE("canDrawOverlays"), OBFUSCATE("(Landroid/content/Context;)Z")); + if (!env->CallStaticBooleanMethod(Settings, canDraw, ctx)){ + Toast(env,ctx,OBFUSCATE("Overlay permission is required in order to show mod menu."),1); + Toast(env,ctx,OBFUSCATE("Overlay permission is required in order to show mod menu."),1); + startActivityPermisson(env, ctx); + + pthread_t ptid; + pthread_create(&ptid, NULL, exit_thread, NULL); + return; + } } + LOGI(OBFUSCATE("Start service")); //StartMod Normal diff --git a/app/src/main/jni/Menu/get_device_api_level_inlines.h b/app/src/main/jni/Menu/get_device_api_level_inlines.h new file mode 100644 index 00000000..817dd77f --- /dev/null +++ b/app/src/main/jni/Menu/get_device_api_level_inlines.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#pragma once + + +#include + +__BEGIN_DECLS + +// Avoid circular dependencies since this is exposed from . +int __system_property_get(const char* __name, char* __value); +int atoi(const char* __s) __attribute_pure__; + +int api_level() { + char value[92] = { 0 }; + if (__system_property_get("ro.build.version.sdk", value) < 1) return -1; + int api_level = atoi(value); + return (api_level > 0) ? api_level : -1; +} + +__END_DECLS +