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

Improved behaviour for add device/add folder (fixes #650)

- Added confirm dialog when exiting without saving
- Replaced floppy disk icon with checkmark
This commit is contained in:
Felix Ableitner 2016-09-07 12:39:07 +02:00
parent 2868f25fc9
commit c60968d207
10 changed files with 37 additions and 32 deletions

View file

@ -2,9 +2,9 @@ package com.nutomic.syncthingandroid.activities;
import android.app.Fragment; import android.app.Fragment;
import android.app.FragmentManager; import android.app.FragmentManager;
import android.content.Intent; import android.content.DialogInterface;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import com.nutomic.syncthingandroid.R; import com.nutomic.syncthingandroid.R;
import com.nutomic.syncthingandroid.fragments.DeviceFragment; import com.nutomic.syncthingandroid.fragments.DeviceFragment;
import com.nutomic.syncthingandroid.fragments.FolderFragment; import com.nutomic.syncthingandroid.fragments.FolderFragment;
@ -90,4 +90,23 @@ public class SettingsActivity extends SyncthingActivity {
public boolean getIsCreate() { public boolean getIsCreate() {
return getIntent().getBooleanExtra(EXTRA_IS_CREATE, false); 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();
}
}
} }

View file

@ -13,17 +13,11 @@ import android.text.Editable;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.*;
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.CompoundButton;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.google.zxing.integration.android.IntentIntegrator; import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult; import com.google.zxing.integration.android.IntentResult;
import com.nutomic.syncthingandroid.R; import com.nutomic.syncthingandroid.R;
@ -343,7 +337,7 @@ public class DeviceFragment extends Fragment implements
.show(); .show();
return true; return true;
case android.R.id.home: case android.R.id.home:
getActivity().finish(); getActivity().onBackPressed();
return true; return true;
default: default:
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);

View file

@ -12,18 +12,8 @@ import android.text.Editable;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.*;
import android.view.Menu; import android.widget.*;
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 com.nutomic.syncthingandroid.R; import com.nutomic.syncthingandroid.R;
import com.nutomic.syncthingandroid.activities.FolderPickerActivity; import com.nutomic.syncthingandroid.activities.FolderPickerActivity;
import com.nutomic.syncthingandroid.activities.SettingsActivity; import com.nutomic.syncthingandroid.activities.SettingsActivity;
@ -346,7 +336,7 @@ public class FolderFragment extends Fragment
.show(); .show();
return true; return true;
case android.R.id.home: case android.R.id.home:
getActivity().finish(); getActivity().onBackPressed();
return true; return true;
default: default:
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 237 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 270 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 390 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 498 B

View file

@ -6,7 +6,7 @@
<item <item
android:id="@+id/create" android:id="@+id/create"
android:title="@string/add" android:title="@string/add"
android:icon="@drawable/ic_save_white_24dp_active" android:icon="@drawable/ic_done_white_24dp"
app:showAsAction="always" /> app:showAsAction="always" />
<item <item

View file

@ -5,7 +5,7 @@
<item <item
android:id="@+id/create" android:id="@+id/create"
android:icon="@drawable/ic_save_white_24dp_active" android:icon="@drawable/ic_done_white_24dp"
android:title="@string/create" android:title="@string/create"
app:showAsAction="always" /> app:showAsAction="always" />

View file

@ -113,7 +113,7 @@ Please report any problems you encounter via Github.</string>
<string name="dialog_confirm_restart">Do you want to restart Syncthing?</string> <string name="dialog_confirm_restart">Do you want to restart Syncthing?</string>
<!-- FolderSettingsFragment --> <!-- FolderFragment -->
<!-- Setting title --> <!-- Setting title -->
@ -155,13 +155,9 @@ Please report any problems you encounter via Github.</string>
<!-- Toast shown when trying to create a folder with an empty path --> <!-- Toast shown when trying to create a folder with an empty path -->
<string name="folder_path_required">The folder path must not be empty</string> <string name="folder_path_required">The folder path must not be empty</string>
<!-- Dialog shown before config export --> <string name="dialog_discard_changes">Discard your changes?</string>
<string name="dialog_confirm_export">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.</string>
<!-- Dialog shown before config import --> <!-- DeviceFragment -->
<string name="dialog_confirm_import">Do you really want to import a new configuration? Existing files will be overwritten.</string>
<!-- DeviceSettingsFragment -->
<!-- Setting title --> <!-- Setting title -->
@ -313,6 +309,12 @@ Please report any problems you encounter via Github.</string>
<string name="use_tor_summary">Force all traffic through Tor for increased privacy. Requires Orbot</string> <string name="use_tor_summary">Force all traffic through Tor for increased privacy. Requires Orbot</string>
<!-- Dialog shown before config export -->
<string name="dialog_confirm_export">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.</string>
<!-- Dialog shown before config import -->
<string name="dialog_confirm_import">Do you really want to import a new configuration? Existing files will be overwritten.</string>
<!-- Toast shown after config was successfully exported --> <!-- Toast shown after config was successfully exported -->
<string name="config_export_successful">Config was exported to %1$s</string> <string name="config_export_successful">Config was exported to %1$s</string>