mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-23 12:51: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 mCurrentAddress;
|
||||||
|
|
||||||
private Preference mDelete;
|
|
||||||
|
|
||||||
private boolean mIsCreate;
|
private boolean mIsCreate;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -96,9 +94,7 @@ public class NodeSettingsFragment extends PreferenceFragment implements
|
||||||
mVersion = findPreference("version");
|
mVersion = findPreference("version");
|
||||||
mVersion.setSummary("?");
|
mVersion.setSummary("?");
|
||||||
mCurrentAddress = findPreference("current_address");
|
mCurrentAddress = findPreference("current_address");
|
||||||
mDelete = findPreference("delete");
|
|
||||||
mCurrentAddress.setSummary("?");
|
mCurrentAddress.setSummary("?");
|
||||||
mDelete.setOnPreferenceClickListener(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getActivity().bindService(new Intent(getActivity(), SyncthingService.class),
|
getActivity().bindService(new Intent(getActivity(), SyncthingService.class),
|
||||||
|
@ -152,6 +148,7 @@ public class NodeSettingsFragment extends PreferenceFragment implements
|
||||||
public void onPrepareOptionsMenu(Menu menu) {
|
public void onPrepareOptionsMenu(Menu menu) {
|
||||||
menu.findItem(R.id.create).setVisible(mIsCreate);
|
menu.findItem(R.id.create).setVisible(mIsCreate);
|
||||||
menu.findItem(R.id.share_node_id).setVisible(!mIsCreate);
|
menu.findItem(R.id.share_node_id).setVisible(!mIsCreate);
|
||||||
|
menu.findItem(R.id.delete).setVisible(!mIsCreate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -173,6 +170,19 @@ public class NodeSettingsFragment extends PreferenceFragment implements
|
||||||
case R.id.share_node_id:
|
case R.id.share_node_id:
|
||||||
RestApi.shareNodeId(getActivity(), mNode.NodeID);
|
RestApi.shareNodeId(getActivity(), mNode.NodeID);
|
||||||
return true;
|
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:
|
case android.R.id.home:
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
return true;
|
return true;
|
||||||
|
@ -214,21 +224,7 @@ public class NodeSettingsFragment extends PreferenceFragment implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
if (preference.equals(mDelete)) {
|
if (preference.equals(mNodeId)) {
|
||||||
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)) {
|
|
||||||
mSyncthingService.getApi().copyNodeId(mNode.NodeID);
|
mSyncthingService.getApi().copyNodeId(mNode.NodeID);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,8 +77,6 @@ public class RepoSettingsFragment extends PreferenceFragment
|
||||||
|
|
||||||
private EditTextPreference mVersioningKeep;
|
private EditTextPreference mVersioningKeep;
|
||||||
|
|
||||||
private Preference mDelete;
|
|
||||||
|
|
||||||
private boolean mIsCreate;
|
private boolean mIsCreate;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -107,10 +105,6 @@ public class RepoSettingsFragment extends PreferenceFragment
|
||||||
mVersioning.setOnPreferenceChangeListener(this);
|
mVersioning.setOnPreferenceChangeListener(this);
|
||||||
mVersioningKeep = (EditTextPreference) findPreference("versioning_keep");
|
mVersioningKeep = (EditTextPreference) findPreference("versioning_keep");
|
||||||
mVersioningKeep.setOnPreferenceChangeListener(this);
|
mVersioningKeep.setOnPreferenceChangeListener(this);
|
||||||
if (!mIsCreate) {
|
|
||||||
mDelete = findPreference("delete");
|
|
||||||
mDelete.setOnPreferenceClickListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
getActivity().bindService(new Intent(getActivity(), SyncthingService.class),
|
getActivity().bindService(new Intent(getActivity(), SyncthingService.class),
|
||||||
mSyncthingServiceConnection, Context.BIND_AUTO_CREATE);
|
mSyncthingServiceConnection, Context.BIND_AUTO_CREATE);
|
||||||
|
@ -182,6 +176,7 @@ public class RepoSettingsFragment extends PreferenceFragment
|
||||||
@Override
|
@Override
|
||||||
public void onPrepareOptionsMenu(Menu menu) {
|
public void onPrepareOptionsMenu(Menu menu) {
|
||||||
menu.findItem(R.id.create).setVisible(mIsCreate);
|
menu.findItem(R.id.create).setVisible(mIsCreate);
|
||||||
|
menu.findItem(R.id.delete).setVisible(!mIsCreate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -201,6 +196,19 @@ public class RepoSettingsFragment extends PreferenceFragment
|
||||||
mSyncthingService.getApi().editRepo(mRepo, true, getActivity());
|
mSyncthingService.getApi().editRepo(mRepo, true, getActivity());
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
return true;
|
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:
|
case android.R.id.home:
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
return true;
|
return true;
|
||||||
|
@ -291,20 +299,6 @@ public class RepoSettingsFragment extends PreferenceFragment
|
||||||
Toast.makeText(getActivity(), R.string.no_nodes, Toast.LENGTH_SHORT)
|
Toast.makeText(getActivity(), R.string.no_nodes, Toast.LENGTH_SHORT)
|
||||||
.show();
|
.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;
|
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:id="@+id/share_node_id"
|
||||||
android:icon="@android:drawable/ic_menu_share"
|
android:icon="@android:drawable/ic_menu_share"
|
||||||
android:title="@string/share_node_id"
|
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>
|
</menu>
|
||||||
|
|
|
@ -7,4 +7,11 @@
|
||||||
android:id="@+id/create"
|
android:id="@+id/create"
|
||||||
android:title="@string/create"
|
android:title="@string/create"
|
||||||
app:showAsAction="always" />
|
app:showAsAction="always" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/delete"
|
||||||
|
android:icon="@drawable/ic_delete"
|
||||||
|
android:title="@string/delete_repo"
|
||||||
|
app:showAsAction="ifRoom" />
|
||||||
|
|
||||||
</menu>
|
</menu>
|
||||||
|
|
|
@ -24,8 +24,4 @@
|
||||||
android:title="@string/current_address"
|
android:title="@string/current_address"
|
||||||
style="?android:preferenceInformationStyle" />
|
style="?android:preferenceInformationStyle" />
|
||||||
|
|
||||||
<Preference
|
|
||||||
android:key="delete"
|
|
||||||
android:title="@string/delete_node" />
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
|
@ -31,8 +31,4 @@
|
||||||
android:title="@string/keep_versions"
|
android:title="@string/keep_versions"
|
||||||
android:inputType="numberDecimal" />
|
android:inputType="numberDecimal" />
|
||||||
|
|
||||||
<Preference
|
|
||||||
android:key="delete"
|
|
||||||
android:title="@string/delete_repo" />
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
Loading…
Reference in a new issue