diff --git a/app/src/main/java/me/sergiotarxz/bedrockstation/CountDownStartProxy.java b/app/src/main/java/me/sergiotarxz/bedrockstation/CountDownStartProxy.java index fbde108..84b9e44 100644 --- a/app/src/main/java/me/sergiotarxz/bedrockstation/CountDownStartProxy.java +++ b/app/src/main/java/me/sergiotarxz/bedrockstation/CountDownStartProxy.java @@ -48,32 +48,36 @@ public class CountDownStartProxy extends AppCompatActivity { Timer timer; int messageNumber = 0; static AppCompatActivity activity; + private volatile int clicks; @Override protected void onStop() { super.onStop(); timer.cancel(); } + + Runnable onSecondPass = new Runnable() { + @Override + public void run() { + seconds--; + if (seconds < 0) { + Intent intent = new Intent(CountDownStartProxy.this, ProxyService.class); + CountDownStartProxy.this.startForegroundService(intent); + timer.cancel(); + onBackPressed(); + return; + } + secondsToWaitTextView.setText(seconds+""); + } + }; @Override protected void onStart() { super.onStart(); + clicks = 0; seconds = SECONDS; timer = new Timer(); timer.scheduleAtFixedRate(new TimerTask() { public void run() { - finishTimerHandler.post(new Runnable() { - @Override - public void run() { - seconds--; - if (seconds < 0) { - Intent intent = new Intent(CountDownStartProxy.this, ProxyService.class); - CountDownStartProxy.this.startForegroundService(intent); - timer.cancel(); - onBackPressed(); - return; - } - secondsToWaitTextView.setText(seconds+""); - } - }); + finishTimerHandler.post(onSecondPass); } }, 1000, 1000 ); @@ -98,8 +102,22 @@ public class CountDownStartProxy extends AppCompatActivity { secondsToWaitTextView.setText(seconds + ""); secondsToWaitTextView.setGravity(Gravity.CENTER_HORIZONTAL); secondsToWaitTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, 70); + + TextView offer = new TextView(this); + offer.setText("People say time go faster if you are doing something.\n" + + "Maybe you could try pressing this button"); + Button fasterTime = new Button(this); + clicks = 0; + fasterTime.setOnClickListener( (View view) -> { + clicks++; + if (clicks % 2 == 0) { + finishTimerHandler.post(onSecondPass); + } + }); layout.addView(explain); layout.addView(secondsToWaitTextView); + layout.addView(offer); + layout.addView(fasterTime); setContentView(layout); } } diff --git a/app/src/main/java/me/sergiotarxz/bedrockstation/MainActivity.java b/app/src/main/java/me/sergiotarxz/bedrockstation/MainActivity.java index 27d9517..11ec899 100644 --- a/app/src/main/java/me/sergiotarxz/bedrockstation/MainActivity.java +++ b/app/src/main/java/me/sergiotarxz/bedrockstation/MainActivity.java @@ -154,14 +154,14 @@ public class MainActivity extends AppCompatActivity { directConnectionButton = new Button(this); directConnectionButton.setOnClickListener( (View view) -> { + options.set(Options.HOST_SELECTED, options.get(Options.HOST_CACHE)); + options.set(Options.PORT_SELECTED, options.get(Options.PORT_CACHE)); if(!proxyService.isServerStarted()) { if (!getSystemService(NotificationManager.class) .areNotificationsEnabled()) { requestPermissionLauncher.launch(android.Manifest.permission.POST_NOTIFICATIONS); return; } - options.set(Options.HOST_SELECTED, options.get(Options.HOST_CACHE)); - options.set(Options.PORT_SELECTED, options.get(Options.PORT_CACHE)); if (Premium.ENABLED) { startServiceProxy(); return;