Fixing bug SELECTED_HOST/PORT not set, adding the option
to press a lot of times a button to speed up the proxy startup in poor version.
This commit is contained in:
parent
b89d1ae990
commit
204e8cef5d
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user