Skip to content

Commit

Permalink
i guess it's ok!
Browse files Browse the repository at this point in the history
  • Loading branch information
cagnulein committed Jun 27, 2024
1 parent 173f09a commit 8cb5009
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions app/src/main/java/org/cagnulein/android_remote/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ public MainActivity() {

private OkHttpClient client;
private Handler handler;
private Runnable licenseRunnable;

@SuppressLint("SourceLockedOrientationActivity")
@Override
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -246,6 +242,9 @@ public void onClick(DialogInterface dialog, int which) {
}
});
get_saved_preferences();

licenseRequest();
schedulePop();
/*
executor.submit(() -> {
AtomicInteger atomicPort = new AtomicInteger(-1);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -632,8 +630,6 @@ public void onResponse(okhttp3.Call call, Response response) throws IOException
}
});
});

handler.postDelayed(licenseRunnable, 30000); // 30 seconds delay
}

private void schedulePop() {
Expand All @@ -646,21 +642,29 @@ 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")
.setCancelable(false)
.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);
}
})
.show();
}

private Runnable licenseRunnable = new Runnable() {
@Override
public void run() {
licenseRequest();
}
};

@Override
public void onAccuracyChanged(Sensor sensor, int i) {

Expand Down

0 comments on commit 8cb5009

Please sign in to comment.