Browse Source

Haptic feedbacc on reconnection, also make sure we don't show empty snaccbars xd

Wazakindjes 3 months ago
parent
commit
176d82e406

BIN
app/rem0t0.apk


+ 1 - 1
app/src/app_rem0t0/src/main/AndroidManifest.xml

@@ -2,7 +2,7 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
 	xmlns:tools="http://schemas.android.com/tools"
 	package="com.jemoeder.lief.rem0t0"
-	android:versionName="1.1.4">
+	android:versionName="1.1.5">
 
 	<!-- Need an internet connection to work 0bv lol -->
 	<uses-permission android:name="android.permission.INTERNET" />

+ 25 - 31
app/src/app_rem0t0/src/main/java/com/jemoeder/lief/rem0t0/MainActivity.java

@@ -72,6 +72,7 @@ public class MainActivity extends AppCompatActivity {
 	private boolean lastpref_rem0t0_stereo = false;
 	private boolean lastpref_rem0t0_tv = false;
 	private boolean lastpref_rem0t0_esp12e_ac = false;
+	private boolean hapticc;
 
 	// Socket shit fam
 	private boolean coldstart = true;
@@ -109,12 +110,10 @@ public class MainActivity extends AppCompatActivity {
 	private static String cmdprefix_esp12e_ac = null;
 	private static String cmdsuffix_hold = null;
 	private static String cmdsuffix_holdstop = null;
-	private static final int vibems_tap = 50;
-	private static final int vibems_hold = 300;
-	private static final int ms_hold = 500;
 	private TabLayout tabberin0;
 	private ViewPager viewPager;
 	private static final int seekbar_stepsize = 10;
+	private static final int ms_holddelay = 500;
 
 	// Actionbar hecks
 	private TextView muhconnstatus;
@@ -266,6 +265,7 @@ public class MainActivity extends AppCompatActivity {
 		serbur = wrapass.muhprefs.getString("prefs_serbur", "LOLNOPE");
 		pot = wrapass.muhprefs.getString("prefs_pot", "6970");
 		wrapass.pref_notifactive = wrapass.muhprefs.getBoolean("prefs_notifactive", false);
+		hapticc = wrapass.muhprefs.getBoolean("prefs_rem0t0_haptic", true);
 
 		// Some integer values are stored as a string so try to convert that shit, also make sure the result isn't out of dem pre-set bounds
 		String ping_s = wrapass.muhprefs.getString("prefs_ping", "30");
@@ -330,6 +330,8 @@ public class MainActivity extends AppCompatActivity {
 				// Don't do double reconnects ;]
 				if(connecting)
 					return false;
+
+				doHapticc(wrapass.VIBEMS_TOGGLE);
 				connectem();
 				return true;
 
@@ -339,8 +341,24 @@ public class MainActivity extends AppCompatActivity {
 		return false;
 	}
 
+	void doHapticc(long vibems) {
+		if(!hapticc)
+			return;
+
+		try {
+			((Vibrator)getSystemService(VIBRATOR_SERVICE)).vibrate(vibems);
+		}
+		catch(Exception fuckoff) {
+			doSnackbar("Unable to get vibrator service kek", Snackbar.LENGTH_INDEFINITE, true);
+		}
+	}
+
 	// Also a simple wrappur for displaying em snackbars
 	private void _dosnackbar(String pm, int pl, boolean waserr) {
+		pm = pm.trim();
+		if(pm.length() == 0)
+			return;
+
 		Snackbar allahu_snackbar = Snackbar.make(muhparent, pm, pl);
 		TextView tv = allahu_snackbar.getView().findViewById(android.support.design.R.id.snackbar_text);
 		if(waserr)
@@ -667,18 +685,8 @@ public class MainActivity extends AppCompatActivity {
 			private boolean ourpress = false;
 			private final String cmdbase;
 
-			private Vibrator vib0 = null;
-
 			rem0t0TouchListener(int pos, String cb) {
 				muhmain = (MainActivity)getActivity();
-				try {
-					//noinspection ConstantConditions
-					vib0 = (Vibrator)muhmain.getSystemService(VIBRATOR_SERVICE);
-				}
-				catch(Exception fuckoff) {
-					if(muhmain != null) // Silences the goddamn warning about hurrrr durrr possible null pointer exception
-						muhmain.doSnackbar("Unable to get vibrator service kek", Snackbar.LENGTH_INDEFINITE, true);
-				}
 				tabpos = pos;
 				cmdbase = cb;
 			}
@@ -727,12 +735,11 @@ public class MainActivity extends AppCompatActivity {
 									return;
 
 								longpress = true;
-								if(vib0 != null && wrapass.muhprefs.getBoolean("prefs_rem0t0_haptic", true))
-									vib0.vibrate(vibems_hold);
+								muhmain.doHapticc(wrapass.VIBEMS_LONG);
 								v.performClick();
 								muhmain.muhcmds.add(cmdbase + cmdsuffix_hold + " " + cmd);
 							}
-						}, ms_hold);
+						}, ms_holddelay);
 						break;
 
 					case MotionEvent.ACTION_UP:
@@ -752,9 +759,7 @@ public class MainActivity extends AppCompatActivity {
 							return false;
 						}
 
-						if(vib0 != null && wrapass.muhprefs.getBoolean("prefs_rem0t0_haptic", true))
-							vib0.vibrate(vibems_tap);
-
+						muhmain.doHapticc(wrapass.VIBEMS_DEFAULT);
 						if(longpress)
 							muhmain.muhcmds.add(cmdbase + cmdsuffix_holdstop + " " + cmd);
 						else {
@@ -776,18 +781,8 @@ public class MainActivity extends AppCompatActivity {
 			private int sb_last;
 			private final TextView sb_label;
 
-			private Vibrator vib0;
-
 			rem0t0TouchListener_SeekBar(SeekBar sb, String cb, View sl) {
 				muhmain = (MainActivity)getActivity();
-				try {
-					//noinspection ConstantConditions
-					vib0 = (Vibrator)muhmain.getSystemService(VIBRATOR_SERVICE);
-				}
-				catch(Exception fuckoff) {
-					if(muhmain != null) // Silences the goddamn warning about hurrrr durrr possible null pointer exception
-						muhmain.doSnackbar("Unable to get vibrator service kek", Snackbar.LENGTH_INDEFINITE, true);
-				}
 				cmdbase = cb;
 				sb_label = (TextView)sl;
 
@@ -807,8 +802,7 @@ public class MainActivity extends AppCompatActivity {
 					wrapass.muhprefs_ed.putInt("lastval_esp12e_ac_servo_rotate", progress);
 					wrapass.muhprefs_ed.commit();
 
-					if(vib0 != null && wrapass.muhprefs.getBoolean("prefs_rem0t0_haptic", true))
-						vib0.vibrate(vibems_tap);
+					muhmain.doHapticc(wrapass.VIBEMS_DEFAULT);
 					muhmain.muhcmds.add(cmdbase + " " + cmd + " " + rotatem);
 				}
 			}

+ 5 - 0
app/src/app_rem0t0/src/main/java/com/jemoeder/lief/rem0t0/rem0t0Wrapper.java

@@ -23,4 +23,9 @@ public class rem0t0Wrapper extends Application {
 	public final String iaction_removenotif = "rem0t0_removenotif";
 	public NotificationManager notifMan;
 	public Notification nActive;
+
+	// Misc
+	public final long VIBEMS_DEFAULT = 50; // For e.g. any button tap
+	public final long VIBEMS_LONG = 300; // For "long clicks"
+	public final long VIBEMS_TOGGLE = 500; // For e.g. reconnections
 }

+ 2 - 2
app/src/app_rem0t0/version.properties

@@ -1,2 +1,2 @@
-#Sat Aug 15 18:17:31 CEST 2020
-VERSION_CODE=364
+#Sat Jul 17 14:06:18 CEST 2021
+VERSION_CODE=368