mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-26 22:31:16 +00:00
Fixed back button not working if disabled dialog is open.
This commit is contained in:
parent
e59934a071
commit
ba3623785f
3 changed files with 34 additions and 34 deletions
|
@ -304,7 +304,6 @@ public class FolderPickerActivity extends SyncthingActivity
|
||||||
public void onApiChange(SyncthingService.State currentState) {
|
public void onApiChange(SyncthingService.State currentState) {
|
||||||
if (!isFinishing() && currentState != SyncthingService.State.ACTIVE) {
|
if (!isFinishing() && currentState != SyncthingService.State.ACTIVE) {
|
||||||
setResult(Activity.RESULT_CANCELED);
|
setResult(Activity.RESULT_CANCELED);
|
||||||
SyncthingService.showDisabledDialog(this);
|
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,7 @@ public class MainActivity extends SyncthingActivity
|
||||||
case DISABLED:
|
case DISABLED:
|
||||||
dismissLoadingDialog();
|
dismissLoadingDialog();
|
||||||
if (!isFinishing()) {
|
if (!isFinishing()) {
|
||||||
mDisabledDialog = SyncthingService.showDisabledDialog(MainActivity.this);
|
showDisabledDialog();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -328,6 +328,39 @@ public class MainActivity extends SyncthingActivity
|
||||||
mDrawerToggle.onConfigurationChanged(newConfig);
|
mDrawerToggle.onConfigurationChanged(newConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showDisabledDialog() {
|
||||||
|
mDisabledDialog = new AlertDialog.Builder(this)
|
||||||
|
.setTitle(R.string.syncthing_disabled_title)
|
||||||
|
.setMessage(R.string.syncthing_disabled_message)
|
||||||
|
.setPositiveButton(R.string.syncthing_disabled_change_settings,
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
|
finish();
|
||||||
|
Intent intent = new Intent(MainActivity.this, SettingsActivity.class)
|
||||||
|
.setAction(SettingsActivity.ACTION_APP_SETTINGS);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.setNegativeButton(R.string.exit,
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
|
@Override
|
||||||
|
public void onCancel(DialogInterface dialogInterface) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.show();
|
||||||
|
mDisabledDialog.setCanceledOnTouchOutside(false);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
return mDrawerToggle.onOptionsItemSelected(item) || super.onOptionsItemSelected(item);
|
return mDrawerToggle.onOptionsItemSelected(item) || super.onOptionsItemSelected(item);
|
||||||
|
|
|
@ -592,38 +592,6 @@ public class SyncthingService extends Service implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Dialog to be shown when attempting to start syncthing while it is disabled according
|
|
||||||
* to settings (because the device is not charging or wifi is disconnected).
|
|
||||||
*/
|
|
||||||
public static AlertDialog showDisabledDialog(final Activity activity) {
|
|
||||||
AlertDialog dialog = new AlertDialog.Builder(activity)
|
|
||||||
.setTitle(R.string.syncthing_disabled_title)
|
|
||||||
.setMessage(R.string.syncthing_disabled_message)
|
|
||||||
.setPositiveButton(R.string.syncthing_disabled_change_settings,
|
|
||||||
new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
|
||||||
activity.finish();
|
|
||||||
Intent intent = new Intent(activity, SettingsActivity.class)
|
|
||||||
.setAction(SettingsActivity.ACTION_APP_SETTINGS);
|
|
||||||
activity.startActivity(intent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.setNegativeButton(R.string.exit,
|
|
||||||
new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
|
||||||
activity.finish();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.show();
|
|
||||||
dialog.setCancelable(false);
|
|
||||||
return dialog;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getWebGuiUrl() {
|
public String getWebGuiUrl() {
|
||||||
return mConfig.getWebGuiUrl();
|
return mConfig.getWebGuiUrl();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue