Skip to content

Commit

Permalink
Add pref to enable expert mode (fixes #256) (#328)
Browse files Browse the repository at this point in the history
* Add prefs: verbose_log, expert_mode

* Update prefs in Constants

* Add service.AppPrefs

* Update fragments to read verbose log pref

* Update classes with context or inject to read verbose log pref

* Inherit ENABLE_VERBOSE_LOG from RestApi to Completion

* Restart whole app if verbose log pref was changed

* A line too much

* Revert expert mode pref (DELTA REVERT)

* Add expert mode pref (ref #256)

* Make ignoreDelete an expert option

* Make pullOrder and ignoreDelete expert options

* Make deviceCompression an expert option

* Import de translation
  • Loading branch information
Catfriend1 authored Mar 9, 2019
1 parent dbe7838 commit def8773
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ public void onCreate(Bundle savedInstanceState) {
getWindow().setSoftInputMode(SOFT_INPUT_STATE_ALWAYS_HIDDEN);
mNameView.requestFocus();
}

// Show expert options conditionally.
Boolean prefExpertMode = mPreferences.getBoolean(Constants.PREF_EXPERT_MODE, false);
mCompressionContainer.setVisibility(prefExpertMode ? View.VISIBLE : View.GONE);
}

private void restoreDialogStates(Bundle savedInstanceState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,13 @@ public class FolderActivity extends SyncthingActivity {
private SwitchCompat mCustomSyncConditionsSwitch;
private TextView mCustomSyncConditionsDescription;
private TextView mCustomSyncConditionsDialog;
private ViewGroup mPullOrderContainer;
private TextView mPullOrderTypeView;
private TextView mPullOrderDescriptionView;
private TextView mVersioningDescriptionView;
private TextView mVersioningTypeView;
private SwitchCompat mVariableSizeBlocks;
private ViewGroup mIgnoreDeleteContainer;
private SwitchCompat mIgnoreDelete;
private TextView mEditIgnoreListTitle;
private EditText mEditIgnoreListContent;
Expand Down Expand Up @@ -208,11 +210,13 @@ public void onCreate(Bundle savedInstanceState) {
mCustomSyncConditionsSwitch = findViewById(R.id.customSyncConditionsSwitch);
mCustomSyncConditionsDescription = findViewById(R.id.customSyncConditionsDescription);
mCustomSyncConditionsDialog = findViewById(R.id.customSyncConditionsDialog);
mPullOrderContainer = findViewById(R.id.pullOrderContainer);
mPullOrderTypeView = findViewById(R.id.pullOrderType);
mPullOrderDescriptionView = findViewById(R.id.pullOrderDescription);
mVersioningDescriptionView = findViewById(R.id.versioningDescription);
mVersioningTypeView = findViewById(R.id.versioningType);
mVariableSizeBlocks = findViewById(R.id.variableSizeBlocks);
mIgnoreDeleteContainer = findViewById(R.id.ignoreDeleteContainer);
mIgnoreDelete = findViewById(R.id.ignoreDelete);
mDevicesContainer = findViewById(R.id.devicesContainer);
mEditIgnoreListTitle = findViewById(R.id.edit_ignore_list_title);
Expand All @@ -222,7 +226,7 @@ public void onCreate(Bundle savedInstanceState) {
mCustomSyncConditionsDialog.setOnClickListener(view -> onCustomSyncConditionsDialogClick());

findViewById(R.id.folderTypeContainer).setOnClickListener(v -> showFolderTypeDialog());
findViewById(R.id.pullOrderContainer).setOnClickListener(v -> showPullOrderDialog());
mPullOrderContainer.setOnClickListener(v -> showPullOrderDialog());
findViewById(R.id.versioningContainer).setOnClickListener(v -> showVersioningDialog());

if (savedInstanceState != null) {
Expand Down Expand Up @@ -282,6 +286,11 @@ public void onCreate(Bundle savedInstanceState) {
checkWriteAndUpdateUI();
updateViewsAndSetListeners();

// Show expert options conditionally.
Boolean prefExpertMode = mPreferences.getBoolean(Constants.PREF_EXPERT_MODE, false);
mPullOrderContainer.setVisibility(prefExpertMode ? View.VISIBLE : View.GONE);
mIgnoreDeleteContainer.setVisibility(prefExpertMode ? View.VISIBLE : View.GONE);

// Open keyboard on label view in edit mode.
mLabelView.requestFocus();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public class Constants {
public static final String PREF_SUGGEST_NEW_FOLDER_ROOT_DATA = "external_android_data";
public static final String PREF_SUGGEST_NEW_FOLDER_ROOT_MEDIA = "external_android_media";

public static final String PREF_EXPERT_MODE = "expert_mode";

// Preferences - Troubleshooting
public static final String PREF_VERBOSE_LOG = "verbose_log";
public static final String PREF_ENVIRONMENT_VARIABLES = "environment_variables";
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,10 @@ Bitte melden Sie auftretende Probleme via GitHub.</string>
<item>[Ext_Speicher]/Android/media</item>
</string-array>

<string name="expert_mode_title">Expertenmodus</string>

<string name="expert_mode_summary">Durch Aktivieren dieser Option werden erweiterte Konfigurationsoptionen angezeigt. Du solltest Dir zuerst die Syncthing-Dokumentation ansehen, um sicherzustellen, dass Du weißt, wie sie richtig verwendet werden. Falsche Einstellungen können zu hohem Batterieverbrauch, Erschöpfung der Systemressourcen oder unvollständiger Synchronisation führen.</string>

<string name="preference_language_title">Sprache</string>

<string name="preference_language_summary">Anwendungssprache ändern</string>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,10 @@ Please report any problems you encounter via Github.</string>
<item>[external_storage]/Android/media</item>
</string-array>

<string name="expert_mode_title">Expert mode</string>

<string name="expert_mode_summary">Enabling this option will show advanced configuration options. You should have a look at the Syncthing Docs first to make sure you know how to use them correctly. Incorrect settings may cause battery drain, system resource exhaust or incomplete synchronization.</string>

<string name="preference_language_title">Language</string>

<string name="preference_language_summary">Change the app language</string>
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/xml/app_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@
android:summary="@null"
android:defaultValue="external_android_data" />

<!-- Expert mode -->
<CheckBoxPreference
android:key="expert_mode"
android:title="@string/expert_mode_title"
android:summary="@string/expert_mode_summary"
android:defaultValue="false" />

<ListPreference
android:key="pref_current_language"
android:title="@string/preference_language_title"
Expand Down

0 comments on commit def8773

Please sign in to comment.