mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-22 20:31:16 +00:00
Use ActionBar icon instead of preference item for delete repo/node.
This commit is contained in:
parent
d78319ee00
commit
76e87932f9
10 changed files with 44 additions and 49 deletions
|
@ -68,8 +68,6 @@ public class NodeSettingsFragment extends PreferenceFragment implements
|
|||
|
||||
private Preference mCurrentAddress;
|
||||
|
||||
private Preference mDelete;
|
||||
|
||||
private boolean mIsCreate;
|
||||
|
||||
@Override
|
||||
|
@ -96,9 +94,7 @@ public class NodeSettingsFragment extends PreferenceFragment implements
|
|||
mVersion = findPreference("version");
|
||||
mVersion.setSummary("?");
|
||||
mCurrentAddress = findPreference("current_address");
|
||||
mDelete = findPreference("delete");
|
||||
mCurrentAddress.setSummary("?");
|
||||
mDelete.setOnPreferenceClickListener(this);
|
||||
}
|
||||
|
||||
getActivity().bindService(new Intent(getActivity(), SyncthingService.class),
|
||||
|
@ -152,6 +148,7 @@ public class NodeSettingsFragment extends PreferenceFragment implements
|
|||
public void onPrepareOptionsMenu(Menu menu) {
|
||||
menu.findItem(R.id.create).setVisible(mIsCreate);
|
||||
menu.findItem(R.id.share_node_id).setVisible(!mIsCreate);
|
||||
menu.findItem(R.id.delete).setVisible(!mIsCreate);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -173,6 +170,19 @@ public class NodeSettingsFragment extends PreferenceFragment implements
|
|||
case R.id.share_node_id:
|
||||
RestApi.shareNodeId(getActivity(), mNode.NodeID);
|
||||
return true;
|
||||
case R.id.delete:
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setMessage(R.string.delete_node_confirm)
|
||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
mSyncthingService.getApi().deleteNode(mNode, getActivity());
|
||||
getActivity().finish();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, null)
|
||||
.show();
|
||||
return true;
|
||||
case android.R.id.home:
|
||||
getActivity().finish();
|
||||
return true;
|
||||
|
@ -214,21 +224,7 @@ public class NodeSettingsFragment extends PreferenceFragment implements
|
|||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
if (preference.equals(mDelete)) {
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setMessage(R.string.delete_node_confirm)
|
||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
mSyncthingService.getApi().deleteNode(mNode, getActivity());
|
||||
getActivity().finish();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, null)
|
||||
.show();
|
||||
return true;
|
||||
}
|
||||
else if (preference.equals(mNodeId)) {
|
||||
if (preference.equals(mNodeId)) {
|
||||
mSyncthingService.getApi().copyNodeId(mNode.NodeID);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -77,8 +77,6 @@ public class RepoSettingsFragment extends PreferenceFragment
|
|||
|
||||
private EditTextPreference mVersioningKeep;
|
||||
|
||||
private Preference mDelete;
|
||||
|
||||
private boolean mIsCreate;
|
||||
|
||||
@Override
|
||||
|
@ -107,10 +105,6 @@ public class RepoSettingsFragment extends PreferenceFragment
|
|||
mVersioning.setOnPreferenceChangeListener(this);
|
||||
mVersioningKeep = (EditTextPreference) findPreference("versioning_keep");
|
||||
mVersioningKeep.setOnPreferenceChangeListener(this);
|
||||
if (!mIsCreate) {
|
||||
mDelete = findPreference("delete");
|
||||
mDelete.setOnPreferenceClickListener(this);
|
||||
}
|
||||
|
||||
getActivity().bindService(new Intent(getActivity(), SyncthingService.class),
|
||||
mSyncthingServiceConnection, Context.BIND_AUTO_CREATE);
|
||||
|
@ -182,6 +176,7 @@ public class RepoSettingsFragment extends PreferenceFragment
|
|||
@Override
|
||||
public void onPrepareOptionsMenu(Menu menu) {
|
||||
menu.findItem(R.id.create).setVisible(mIsCreate);
|
||||
menu.findItem(R.id.delete).setVisible(!mIsCreate);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -201,6 +196,19 @@ public class RepoSettingsFragment extends PreferenceFragment
|
|||
mSyncthingService.getApi().editRepo(mRepo, true, getActivity());
|
||||
getActivity().finish();
|
||||
return true;
|
||||
case R.id.delete:
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setMessage(R.string.delete_repo_confirm)
|
||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
mSyncthingService.getApi().deleteRepo(mRepo, getActivity());
|
||||
getActivity().finish();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, null)
|
||||
.show();
|
||||
return true;
|
||||
case android.R.id.home:
|
||||
getActivity().finish();
|
||||
return true;
|
||||
|
@ -291,20 +299,6 @@ public class RepoSettingsFragment extends PreferenceFragment
|
|||
Toast.makeText(getActivity(), R.string.no_nodes, Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
}
|
||||
else if (preference.equals(mDelete)) {
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setMessage(R.string.delete_repo_confirm)
|
||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
mSyncthingService.getApi().deleteRepo(mRepo, getActivity());
|
||||
getActivity().finish();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, null)
|
||||
.show();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
BIN
src/main/res/drawable-hdpi/ic_delete.png
Normal file
BIN
src/main/res/drawable-hdpi/ic_delete.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 450 B |
BIN
src/main/res/drawable-mdpi/ic_delete.png
Normal file
BIN
src/main/res/drawable-mdpi/ic_delete.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 324 B |
BIN
src/main/res/drawable-xhdpi/ic_delete.png
Normal file
BIN
src/main/res/drawable-xhdpi/ic_delete.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 543 B |
BIN
src/main/res/drawable-xxhdpi/ic_delete.png
Normal file
BIN
src/main/res/drawable-xxhdpi/ic_delete.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 765 B |
|
@ -12,6 +12,12 @@
|
|||
android:id="@+id/share_node_id"
|
||||
android:icon="@android:drawable/ic_menu_share"
|
||||
android:title="@string/share_node_id"
|
||||
app:showAsAction="always" />
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
<item
|
||||
android:id="@+id/delete"
|
||||
android:icon="@drawable/ic_delete"
|
||||
android:title="@string/delete_node"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
</menu>
|
||||
|
|
|
@ -7,4 +7,11 @@
|
|||
android:id="@+id/create"
|
||||
android:title="@string/create"
|
||||
app:showAsAction="always" />
|
||||
|
||||
<item
|
||||
android:id="@+id/delete"
|
||||
android:icon="@drawable/ic_delete"
|
||||
android:title="@string/delete_repo"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
</menu>
|
||||
|
|
|
@ -24,8 +24,4 @@
|
|||
android:title="@string/current_address"
|
||||
style="?android:preferenceInformationStyle" />
|
||||
|
||||
<Preference
|
||||
android:key="delete"
|
||||
android:title="@string/delete_node" />
|
||||
|
||||
</PreferenceScreen>
|
||||
</PreferenceScreen>
|
||||
|
|
|
@ -31,8 +31,4 @@
|
|||
android:title="@string/keep_versions"
|
||||
android:inputType="numberDecimal" />
|
||||
|
||||
<Preference
|
||||
android:key="delete"
|
||||
android:title="@string/delete_repo" />
|
||||
|
||||
</PreferenceScreen>
|
||||
|
|
Loading…
Reference in a new issue