mirror of
https://github.com/syncthing/syncthing-android.git
synced 2025-01-11 04:25:53 +00:00
WIP - Directly go to SettingsActivity#Run_Conditions screen
after the "change run condition" button has been clicked in StateDialogActivity during STATE_DISABLED
This commit is contained in:
parent
9ecfec9f78
commit
7f187a18f3
3 changed files with 37 additions and 3 deletions
|
@ -19,6 +19,7 @@ import android.support.annotation.NonNull;
|
|||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
@ -48,11 +49,18 @@ import eu.chainfire.libsuperuser.Shell;
|
|||
|
||||
public class SettingsActivity extends SyncthingActivity {
|
||||
|
||||
public static final String EXTRA_OPEN_SUB_PREF_SCREEN =
|
||||
"com.nutomic.syncthingandroid.activities.SettingsActivity.OPEN_SUB_PREF_SCREEN";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
SettingsFragment settingsFragment = new SettingsFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(EXTRA_OPEN_SUB_PREF_SCREEN, getIntent().getStringExtra(EXTRA_OPEN_SUB_PREF_SCREEN));
|
||||
settingsFragment.setArguments(bundle);
|
||||
getFragmentManager().beginTransaction()
|
||||
.replace(android.R.id.content, new SettingsFragment())
|
||||
.replace(android.R.id.content, settingsFragment)
|
||||
.commit();
|
||||
}
|
||||
|
||||
|
@ -253,6 +261,30 @@ public class SettingsActivity extends SyncthingActivity {
|
|||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.d(TAG, "Failed to get app version name");
|
||||
}
|
||||
|
||||
openSubPrefScreen(screen);
|
||||
}
|
||||
|
||||
private void openSubPrefScreen(PreferenceScreen prefScreen) {
|
||||
Bundle bundle = getArguments();
|
||||
if (bundle == null) {
|
||||
return;
|
||||
}
|
||||
String openSubPrefScreen = bundle.getString(EXTRA_OPEN_SUB_PREF_SCREEN, "");
|
||||
// Open sub preferences screen if EXTRA_OPEN_SUB_PREF_SCREEN was passed in bundle.
|
||||
if (openSubPrefScreen != null && !TextUtils.isEmpty(openSubPrefScreen)) {
|
||||
Log.v(TAG, "Transitioning to pref screen " + openSubPrefScreen);
|
||||
PreferenceScreen categoryRunConditions = (PreferenceScreen) findPreference(openSubPrefScreen);
|
||||
final ListAdapter listAdapter = prefScreen.getRootAdapter();
|
||||
final int itemsCount = listAdapter.getCount();
|
||||
for (int itemNumber = 0; itemNumber < itemsCount; ++itemNumber) {
|
||||
if (listAdapter.getItem(itemNumber).equals(categoryRunConditions)) {
|
||||
//simulates click on the sub-preference
|
||||
prefScreen.onItemClick(null, null, itemNumber, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -98,7 +98,9 @@ public abstract class StateDialogActivity extends SyncthingActivity {
|
|||
.setMessage(R.string.syncthing_disabled_message)
|
||||
.setPositiveButton(R.string.syncthing_disabled_change_settings,
|
||||
(dialogInterface, i) -> {
|
||||
startActivity(new Intent(this, SettingsActivity.class));
|
||||
Intent intent = new Intent(this, SettingsActivity.class);
|
||||
intent.putExtra(SettingsActivity.EXTRA_OPEN_SUB_PREF_SCREEN, "category_run_conditions");
|
||||
startActivity(intent);
|
||||
}
|
||||
)
|
||||
.setNegativeButton(R.string.exit,
|
||||
|
|
|
@ -616,7 +616,7 @@ Please report any problems you encounter via Github.</string>
|
|||
<string name="syncthing_disabled_title">Syncthing is disabled</string>
|
||||
|
||||
<!-- Message of the "syncthing disabled" dialog -->
|
||||
<string name="syncthing_disabled_message">Do you want to change your preferences?</string>
|
||||
<string name="syncthing_disabled_message">Do you want to change the run conditions?</string>
|
||||
|
||||
<!-- Button text on the "syncthing disabled" dialog -->
|
||||
<string name="syncthing_disabled_change_settings">Change Settings</string>
|
||||
|
|
Loading…
Reference in a new issue