diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml new file mode 100644 index 0000000..8931591 --- /dev/null +++ b/.idea/deploymentTargetDropDown.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index e9969a1..7b46144 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -14,7 +14,6 @@ - diff --git a/app/src/main/java/io/github/virresh/matvt/engine/impl/MouseEmulationEngine.java b/app/src/main/java/io/github/virresh/matvt/engine/impl/MouseEmulationEngine.java index 2e738db..d6a9e0f 100644 --- a/app/src/main/java/io/github/virresh/matvt/engine/impl/MouseEmulationEngine.java +++ b/app/src/main/java/io/github/virresh/matvt/engine/impl/MouseEmulationEngine.java @@ -73,6 +73,8 @@ public class MouseEmulationEngine { public static int scrollSpeed; + public static boolean isHideToastsOptionEnabled; + public static boolean isBossKeyDisabled; public static boolean isBossKeySetToToggle; @@ -277,8 +279,7 @@ public boolean perform (KeyEvent keyEvent) { waitToChange(); if (isEnabled){ isInScrollMode = !isInScrollMode; - Toast.makeText(mService, isInScrollMode ? "Scroll Mode: Enabled" : "Scroll Mode: Disabled", - Toast.LENGTH_SHORT).show(); + showToast(isInScrollMode ? "Scroll Mode: Enabled" : "Scroll Mode: Disabled"); return true; } } @@ -292,7 +293,7 @@ else if (keyEvent.getKeyCode() == bossKey && !isBossKeyDisabled && isBossKeySetT isInScrollMode = false; } else if (isEnabled && !isInScrollMode) { // Mouse Mode -> Scroll Mode - Toast.makeText(mService, "Scroll Mode", Toast.LENGTH_SHORT).show(); + showToast("Scroll Mode"); isInScrollMode = true; } else if (!isEnabled) { // Dpad mode -> Mouse mode @@ -313,14 +314,14 @@ else if (keyEvent.getKeyCode() == bossKey && isBossKeyDisabled) { // mouse already enabled, disable it and make it go away this.isEnabled = false; mPointerControl.disappear(); - Toast.makeText(mService, "Dpad Mode", Toast.LENGTH_SHORT).show(); + showToast("D-Pad Mode"); return true; } else { // mouse is disabled, enable it, reset it and show it this.isEnabled = true; mPointerControl.reset(); mPointerControl.reappear(); - Toast.makeText(mService, "Mouse/Scroll", Toast.LENGTH_SHORT).show(); + showToast("Mouse/Scroll mode"); } } @@ -508,16 +509,28 @@ private void setMouseModeEnabled(boolean enable) { isInScrollMode = false; mPointerControl.reset(); mPointerControl.reappear(); - Toast.makeText(mService, "Mouse Mode", Toast.LENGTH_SHORT).show(); + showToast("Mouse Mode"); } else { // Disable Mouse Mode this.isEnabled = false; mPointerControl.disappear(); - Toast.makeText(mService, "D-Pad Mode", Toast.LENGTH_SHORT).show(); + showToast("D-Pad Mode"); + } + } + + private void showToast(String message){ + + if(!isHideToastsOptionEnabled){ + Toast.makeText(mService,message,Toast.LENGTH_SHORT).show(); + }else { + Log.i(LOG_TAG,message); } + } + + /** * Simple count down timer for checking keypress duration */ diff --git a/app/src/main/java/io/github/virresh/matvt/gui/GuiActivity.java b/app/src/main/java/io/github/virresh/matvt/gui/GuiActivity.java index fdeee7e..6b0e4eb 100644 --- a/app/src/main/java/io/github/virresh/matvt/gui/GuiActivity.java +++ b/app/src/main/java/io/github/virresh/matvt/gui/GuiActivity.java @@ -32,7 +32,7 @@ public class GuiActivity extends AppCompatActivity { CountDownTimer repopulate; - CheckBox cb_mouse_bordered, cb_disable_bossKey, cb_behaviour_bossKey; + CheckBox cb_mouse_bordered, cb_disable_bossKey, cb_behaviour_bossKey, cb_hide_toasts; TextView gui_acc_perm, gui_acc_serv, gui_overlay_perm, gui_overlay_serv, gui_about; EditText et_override; @@ -60,6 +60,7 @@ protected void onCreate(Bundle savedInstanceState) { et_override = findViewById(R.id.et_override); cb_mouse_bordered = findViewById(R.id.cb_border_window); + cb_hide_toasts = findViewById(R.id.cb_hide_toasts); cb_disable_bossKey = findViewById(R.id.cb_disable_bossKey); cb_behaviour_bossKey = findViewById(R.id.cb_behaviour_bossKey); @@ -147,6 +148,11 @@ public void onStopTrackingTouch(SeekBar seekBar) {} PointerControl.isBordered = b; }); + cb_hide_toasts.setOnCheckedChangeListener(((compoundButton, value) -> { + Helper.setHideToastsOptionEnabled(getApplicationContext(), value); + MouseEmulationEngine.isHideToastsOptionEnabled = value; + })); + cb_disable_bossKey.setOnCheckedChangeListener(((compoundButton, value) -> { Helper.setBossKeyDisabled(getApplicationContext(), value); MouseEmulationEngine.isBossKeyDisabled = value; @@ -181,6 +187,11 @@ private void checkValues(IconStyleSpinnerAdapter adapter) { boolean bordered = Helper.getMouseBordered(ctx); cb_mouse_bordered.setChecked(bordered); + boolean toastVisibility = Helper.isHideToastOptionEnabled(ctx); + + cb_hide_toasts.setChecked(toastVisibility); + + boolean bossKeyStatus = Helper.isBossKeyDisabled(ctx); cb_disable_bossKey.setChecked(bossKeyStatus); @@ -280,4 +291,4 @@ public void onFinish() { public void callDetect(View view) { startActivity(new Intent(this, KeyDetection.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); } -} \ No newline at end of file +} diff --git a/app/src/main/java/io/github/virresh/matvt/helper/Helper.java b/app/src/main/java/io/github/virresh/matvt/helper/Helper.java index c05ef43..d75f9d9 100644 --- a/app/src/main/java/io/github/virresh/matvt/helper/Helper.java +++ b/app/src/main/java/io/github/virresh/matvt/helper/Helper.java @@ -11,6 +11,7 @@ import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; + import androidx.annotation.RequiresApi; import com.tananaev.adblib.AdbBase64; @@ -29,6 +30,7 @@ public class Helper { public static Context helperContext; static final String PREFS_ID = "MATVT"; + static final String PREF_ALERTS_HIDE_TOASTS = "HIDE_ALERTS"; static final String PREF_KEY_CB_OVERRIDE_STAT = "CB_OVERRIDE_STAT"; static final String PREF_KEY_CB_OVERRIDE_VAL = "CB_OVERRIDE_VAL"; static final String PREF_KEY_MOUSE_ICON = "MOUSE_ICON"; @@ -40,7 +42,6 @@ public class Helper { static final String IO_PUBLICKEY_FILENAME = "public_key.bin"; static final String IO_PRIVATEKEY_FILENAME = "private_key.bin"; - public static boolean isAccessibilityDisabled(Context ctx) { return !isAccServiceInstalled(ctx.getPackageName() + "/.services.MouseEventService", ctx); } @@ -145,6 +146,18 @@ public static boolean getMouseBordered(Context ctx) { SharedPreferences sp = ctx.getSharedPreferences(PREFS_ID, Context.MODE_PRIVATE); return sp.getBoolean(PREF_KEY_MOUSE_BORDERED, false); } + @SuppressLint("ApplySharedPref") + public static void setHideToastsOptionEnabled(Context ctx, Boolean val){ + SharedPreferences sp = ctx.getSharedPreferences(PREFS_ID,Context.MODE_PRIVATE); + SharedPreferences.Editor editor = sp.edit(); + editor.putBoolean(PREF_ALERTS_HIDE_TOASTS,val); + editor.commit(); + } + + public static boolean isHideToastOptionEnabled(Context ctx){ + SharedPreferences sp = ctx.getSharedPreferences(PREFS_ID, Context.MODE_PRIVATE); + return sp.getBoolean(PREF_ALERTS_HIDE_TOASTS, false); + } @SuppressLint("ApplySharedPref") public static void setBossKeyDisabled(Context ctx, Boolean val) { diff --git a/app/src/main/java/io/github/virresh/matvt/services/MouseEventService.java b/app/src/main/java/io/github/virresh/matvt/services/MouseEventService.java index 44faa07..eed8173 100644 --- a/app/src/main/java/io/github/virresh/matvt/services/MouseEventService.java +++ b/app/src/main/java/io/github/virresh/matvt/services/MouseEventService.java @@ -71,6 +71,7 @@ protected void onServiceConnected() { bossKey = KeyEvent.KEYCODE_VOLUME_MUTE; PointerControl.isBordered = Helper.getMouseBordered(this); scrollSpeed = Helper.getScrollSpeed(this); + MouseEmulationEngine.isHideToastsOptionEnabled = Helper.isHideToastOptionEnabled(this); MouseEmulationEngine.isBossKeyDisabled = Helper.isBossKeyDisabled(this); MouseEmulationEngine.isBossKeySetToToggle = Helper.isBossKeySetToToggle(this); if (Helper.isOverriding(this)) bossKey = Helper.getBossKeyValue(this); diff --git a/app/src/main/res/layout/activity_main_gui.xml b/app/src/main/res/layout/activity_main_gui.xml index 858c74c..16f3dbb 100644 --- a/app/src/main/res/layout/activity_main_gui.xml +++ b/app/src/main/res/layout/activity_main_gui.xml @@ -217,6 +217,18 @@ android:textColor="@color/white" android:textSize="20sp" /> + +