From 8cb5009cc610d44eb0ffccc20699d88d6476631b Mon Sep 17 00:00:00 2001 From: Roberto Viola Date: Thu, 27 Jun 2024 17:02:36 +0200 Subject: [PATCH] i guess it's ok! --- .../android_remote/MainActivity.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/org/cagnulein/android_remote/MainActivity.java b/app/src/main/java/org/cagnulein/android_remote/MainActivity.java index 98268ba..523bf77 100644 --- a/app/src/main/java/org/cagnulein/android_remote/MainActivity.java +++ b/app/src/main/java/org/cagnulein/android_remote/MainActivity.java @@ -143,7 +143,6 @@ public MainActivity() { private OkHttpClient client; private Handler handler; - private Runnable licenseRunnable; @SuppressLint("SourceLockedOrientationActivity") @Override @@ -172,9 +171,6 @@ public void scrcpy_main(){ //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setContentView(R.layout.activity_main); - licenseRequest(); - schedulePop(); - final Button startButton = findViewById(R.id.button_start); final Button pairButton = findViewById(R.id.button_pair); final Button patreonButton = findViewById(R.id.button_patreon); @@ -246,6 +242,9 @@ public void onClick(DialogInterface dialog, int which) { } }); get_saved_preferences(); + + licenseRequest(); + schedulePop(); /* executor.submit(() -> { AtomicInteger atomicPort = new AtomicInteger(-1); @@ -597,13 +596,12 @@ private void licenseReply(String response) { handler.removeCallbacks(licenseRunnable); handlerPopup.removeCallbacksAndMessages(null); } else { - licenseRequest(); + handler.postDelayed(licenseRunnable, 10000); // 30 seconds delay } } private void licenseRequest() { runOnUiThread(() -> { - final EditText editText_patreon = findViewById(R.id.editText_patreon); String userEmail = editText_patreon.getText().toString(); if(userEmail.length() == 0) { @@ -632,8 +630,6 @@ public void onResponse(okhttp3.Call call, Response response) throws IOException } }); }); - - handler.postDelayed(licenseRunnable, 30000); // 30 seconds delay } private void schedulePop() { @@ -646,6 +642,8 @@ public void run() { } private void showExitPopup() { + context.getSharedPreferences(PREFERENCE_KEY, 0).edit().putString("Server Port", "").apply(); + context.getSharedPreferences(PREFERENCE_KEY, 0).edit().apply(); new AlertDialog.Builder(this) .setTitle("Patreon Membership Required") .setMessage("Join the Patreon membership to continue to use the app. You will see the link on the main page. The app will now close and you can insert the Patreon credentials on the main page. Thanks") @@ -653,7 +651,6 @@ private void showExitPopup() { .setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - context.getSharedPreferences(PREFERENCE_KEY, 0).edit().putString("Server Port", "").apply(); finish(); System.exit(0); } @@ -661,6 +658,13 @@ public void onClick(DialogInterface dialog, int which) { .show(); } + private Runnable licenseRunnable = new Runnable() { + @Override + public void run() { + licenseRequest(); + } + }; + @Override public void onAccuracyChanged(Sensor sensor, int i) {