mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-26 14:21:16 +00:00
Fixed disabled dialog behaviour
This commit is contained in:
parent
a7742103e1
commit
05326f2b60
1 changed files with 23 additions and 3 deletions
|
@ -3,7 +3,9 @@ package com.nutomic.syncthingandroid.activities;
|
|||
import android.app.AlertDialog;
|
||||
import android.content.Intent;
|
||||
import android.databinding.DataBindingUtil;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.view.View;
|
||||
|
||||
|
@ -23,17 +25,32 @@ public abstract class StateDialogActivity extends SyncthingActivity {
|
|||
|
||||
private AlertDialog mLoadingDialog;
|
||||
private AlertDialog mDisabledDialog;
|
||||
private boolean mIsPaused = true;
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
registerOnServiceConnectedListener(() ->
|
||||
getService().registerOnApiChangeListener(this::onApiChange));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mIsPaused = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mIsPaused = true;
|
||||
dismissDisabledDialog();
|
||||
dismissLoadingDialog();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (getService() != null) {
|
||||
getService().unregisterOnApiChangeListener(this::onApiChange);
|
||||
}
|
||||
|
@ -61,6 +78,9 @@ public abstract class StateDialogActivity extends SyncthingActivity {
|
|||
}
|
||||
|
||||
private void showDisabledDialog() {
|
||||
if (mIsPaused)
|
||||
return;
|
||||
|
||||
mDisabledDialog = new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.syncthing_disabled_title)
|
||||
.setMessage(R.string.syncthing_disabled_message)
|
||||
|
@ -86,7 +106,7 @@ public abstract class StateDialogActivity extends SyncthingActivity {
|
|||
* Shows the loading dialog with the correct text ("creating keys" or "loading").
|
||||
*/
|
||||
private void showLoadingDialog() {
|
||||
if (isFinishing() || mLoadingDialog != null)
|
||||
if (mIsPaused || mLoadingDialog != null)
|
||||
return;
|
||||
|
||||
DialogLoadingBinding binding = DataBindingUtil.inflate(
|
||||
|
|
Loading…
Reference in a new issue