1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-26 14:21:16 +00:00

Fixed back button not working if disabled dialog is open.

This commit is contained in:
Felix Ableitner 2016-07-21 15:17:50 +02:00
parent e59934a071
commit ba3623785f
3 changed files with 34 additions and 34 deletions

View file

@ -304,7 +304,6 @@ public class FolderPickerActivity extends SyncthingActivity
public void onApiChange(SyncthingService.State currentState) {
if (!isFinishing() && currentState != SyncthingService.State.ACTIVE) {
setResult(Activity.RESULT_CANCELED);
SyncthingService.showDisabledDialog(this);
finish();
}
}

View file

@ -123,7 +123,7 @@ public class MainActivity extends SyncthingActivity
case DISABLED:
dismissLoadingDialog();
if (!isFinishing()) {
mDisabledDialog = SyncthingService.showDisabledDialog(MainActivity.this);
showDisabledDialog();
}
break;
}
@ -328,6 +328,39 @@ public class MainActivity extends SyncthingActivity
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
public boolean onOptionsItemSelected(MenuItem item) {
return mDrawerToggle.onOptionsItemSelected(item) || super.onOptionsItemSelected(item);

View file

@ -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() {
return mConfig.getWebGuiUrl();
}