diff --git a/src/main/java/com/nutomic/syncthingandroid/activities/SettingsActivity.java b/src/main/java/com/nutomic/syncthingandroid/activities/SettingsActivity.java index 35d5986f..34aedc52 100644 --- a/src/main/java/com/nutomic/syncthingandroid/activities/SettingsActivity.java +++ b/src/main/java/com/nutomic/syncthingandroid/activities/SettingsActivity.java @@ -2,9 +2,9 @@ package com.nutomic.syncthingandroid.activities; import android.app.Fragment; import android.app.FragmentManager; -import android.content.Intent; +import android.content.DialogInterface; import android.os.Bundle; - +import android.support.v7.app.AlertDialog; import com.nutomic.syncthingandroid.R; import com.nutomic.syncthingandroid.fragments.DeviceFragment; import com.nutomic.syncthingandroid.fragments.FolderFragment; @@ -90,4 +90,23 @@ public class SettingsActivity extends SyncthingActivity { public boolean getIsCreate() { return getIntent().getBooleanExtra(EXTRA_IS_CREATE, false); } + + @Override + public void onBackPressed() { + if (getIsCreate() && (mFragment instanceof DeviceFragment || mFragment instanceof FolderFragment)) { + new AlertDialog.Builder(this) + .setMessage(R.string.dialog_discard_changes) + .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + finish(); + } + }) + .setNegativeButton(android.R.string.cancel, null) + .show(); + } + else { + finish(); + } + } } diff --git a/src/main/java/com/nutomic/syncthingandroid/fragments/DeviceFragment.java b/src/main/java/com/nutomic/syncthingandroid/fragments/DeviceFragment.java index 77d23e3a..69f824c0 100644 --- a/src/main/java/com/nutomic/syncthingandroid/fragments/DeviceFragment.java +++ b/src/main/java/com/nutomic/syncthingandroid/fragments/DeviceFragment.java @@ -13,17 +13,11 @@ import android.text.Editable; import android.text.TextUtils; import android.text.TextWatcher; import android.util.Log; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.View; -import android.view.ViewGroup; +import android.view.*; import android.widget.CompoundButton; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; - import com.google.zxing.integration.android.IntentIntegrator; import com.google.zxing.integration.android.IntentResult; import com.nutomic.syncthingandroid.R; @@ -343,7 +337,7 @@ public class DeviceFragment extends Fragment implements .show(); return true; case android.R.id.home: - getActivity().finish(); + getActivity().onBackPressed(); return true; default: return super.onOptionsItemSelected(item); diff --git a/src/main/java/com/nutomic/syncthingandroid/fragments/FolderFragment.java b/src/main/java/com/nutomic/syncthingandroid/fragments/FolderFragment.java index f38f9a7e..ec12f521 100644 --- a/src/main/java/com/nutomic/syncthingandroid/fragments/FolderFragment.java +++ b/src/main/java/com/nutomic/syncthingandroid/fragments/FolderFragment.java @@ -12,18 +12,8 @@ import android.text.Editable; import android.text.TextUtils; import android.text.TextWatcher; import android.util.Log; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.View; -import android.view.ViewGroup; -import android.widget.CompoundButton; -import android.widget.EditText; -import android.widget.LinearLayout; -import android.widget.TextView; -import android.widget.Toast; - +import android.view.*; +import android.widget.*; import com.nutomic.syncthingandroid.R; import com.nutomic.syncthingandroid.activities.FolderPickerActivity; import com.nutomic.syncthingandroid.activities.SettingsActivity; @@ -346,7 +336,7 @@ public class FolderFragment extends Fragment .show(); return true; case android.R.id.home: - getActivity().finish(); + getActivity().onBackPressed(); return true; default: return super.onOptionsItemSelected(item); diff --git a/src/main/res/drawable-hdpi/ic_save_white_24dp_active.png b/src/main/res/drawable-hdpi/ic_save_white_24dp_active.png deleted file mode 100644 index adbcc516..00000000 Binary files a/src/main/res/drawable-hdpi/ic_save_white_24dp_active.png and /dev/null differ diff --git a/src/main/res/drawable-xhdpi/ic_save_white_24dp_active.png b/src/main/res/drawable-xhdpi/ic_save_white_24dp_active.png deleted file mode 100644 index 49450526..00000000 Binary files a/src/main/res/drawable-xhdpi/ic_save_white_24dp_active.png and /dev/null differ diff --git a/src/main/res/drawable-xxhdpi/ic_save_white_24dp_active.png b/src/main/res/drawable-xxhdpi/ic_save_white_24dp_active.png deleted file mode 100644 index 03544b8e..00000000 Binary files a/src/main/res/drawable-xxhdpi/ic_save_white_24dp_active.png and /dev/null differ diff --git a/src/main/res/drawable-xxxhdpi/ic_save_white_24dp_active.png b/src/main/res/drawable-xxxhdpi/ic_save_white_24dp_active.png deleted file mode 100644 index 3ecc97c7..00000000 Binary files a/src/main/res/drawable-xxxhdpi/ic_save_white_24dp_active.png and /dev/null differ diff --git a/src/main/res/menu/device_settings.xml b/src/main/res/menu/device_settings.xml index 2d398ded..ce4590b4 100644 --- a/src/main/res/menu/device_settings.xml +++ b/src/main/res/menu/device_settings.xml @@ -6,7 +6,7 @@ diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 03fae020..a60e30e0 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -113,7 +113,7 @@ Please report any problems you encounter via Github. Do you want to restart Syncthing? - + @@ -155,13 +155,9 @@ Please report any problems you encounter via Github. The folder path must not be empty - - Do you really want to export your configuration? Existing files will be overwritten.\n\nWARNING! Other applications may be able to read the private key from the backup location and use it to download/modify synchronized files. + Discard your changes? - - Do you really want to import a new configuration? Existing files will be overwritten. - - + @@ -313,6 +309,12 @@ Please report any problems you encounter via Github. Force all traffic through Tor for increased privacy. Requires Orbot + + Do you really want to export your configuration? Existing files will be overwritten.\n\nWARNING! Other applications may be able to read the private key from the backup location and use it to download/modify synchronized files. + + + Do you really want to import a new configuration? Existing files will be overwritten. + Config was exported to %1$s