add a switch to enable/disable same sorting for files and dirs
This commit is contained in:
parent
9612e53dbb
commit
5bc11afc69
|
@ -30,6 +30,14 @@ public class Config {
|
|||
mPrefs.edit().putBoolean(Constants.IS_DARK_THEME, isDarkTheme).apply();
|
||||
}
|
||||
|
||||
public boolean getIsSameSorting() {
|
||||
return mPrefs.getBoolean(Constants.IS_SAME_SORTING, true);
|
||||
}
|
||||
|
||||
public void setIsSameSorting(boolean isSameSorting) {
|
||||
mPrefs.edit().putBoolean(Constants.IS_SAME_SORTING, isSameSorting).apply();
|
||||
}
|
||||
|
||||
public int getSorting() {
|
||||
return mPrefs.getInt(Constants.SORT_ORDER, Constants.SORT_BY_DATE | Constants.SORT_DESCENDING);
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ public class Constants {
|
|||
public static final String PREFS_KEY = "Gallery";
|
||||
public static final String IS_FIRST_RUN = "is_first_run";
|
||||
public static final String IS_DARK_THEME = "is_dark_theme";
|
||||
public static final String IS_SAME_SORTING = "is_same_sorting";
|
||||
public static final String SORT_ORDER = "sort_order";
|
||||
public static final String DIRECTORY_SORT_ORDER = "directory_sort_order";
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import butterknife.OnClick;
|
|||
|
||||
public class SettingsActivity extends SimpleActivity {
|
||||
@BindView(R.id.settings_dark_theme) SwitchCompat mDarkThemeSwitch;
|
||||
@BindView(R.id.settings_same_sorting) SwitchCompat mSameSortingSwitch;
|
||||
|
||||
private static Config mConfig;
|
||||
|
||||
|
@ -24,12 +25,17 @@ public class SettingsActivity extends SimpleActivity {
|
|||
ButterKnife.bind(this);
|
||||
|
||||
setupDarkTheme();
|
||||
setupSameSorting();
|
||||
}
|
||||
|
||||
private void setupDarkTheme() {
|
||||
mDarkThemeSwitch.setChecked(mConfig.getIsDarkTheme());
|
||||
}
|
||||
|
||||
private void setupSameSorting() {
|
||||
mSameSortingSwitch.setChecked(mConfig.getIsSameSorting());
|
||||
}
|
||||
|
||||
@OnClick(R.id.settings_dark_theme_holder)
|
||||
public void handleDarkTheme() {
|
||||
mDarkThemeSwitch.setChecked(!mDarkThemeSwitch.isChecked());
|
||||
|
@ -37,6 +43,12 @@ public class SettingsActivity extends SimpleActivity {
|
|||
restartActivity();
|
||||
}
|
||||
|
||||
@OnClick(R.id.settings_same_sorting_holder)
|
||||
public void handleSameSorting() {
|
||||
mSameSortingSwitch.setChecked(!mSameSortingSwitch.isChecked());
|
||||
mConfig.setIsSameSorting(mSameSortingSwitch.isChecked());
|
||||
}
|
||||
|
||||
private void restartActivity() {
|
||||
TaskStackBuilder.create(getApplicationContext()).addNextIntentWithParentStack(getIntent()).startActivities();
|
||||
}
|
||||
|
|
|
@ -36,5 +36,31 @@
|
|||
android:clickable="false"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_same_sorting_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/settings_padding"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:padding="@dimen/activity_margin">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/settings_same_sorting_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:paddingLeft="@dimen/settings_padding"
|
||||
android:text="@string/same_sorting"/>
|
||||
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/settings_same_sorting"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:background="@null"
|
||||
android:clickable="false"/>
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
<!-- Settings -->
|
||||
<string name="settings">Impostazioni</string>
|
||||
<string name="dark_theme">Tema scuro</string>
|
||||
<string name="same_sorting">Same sorting for files and folders</string>
|
||||
|
||||
<!--License-->
|
||||
<string name="notice">Questa app usa le seguenti librerie di terze parti per semplificarmi la vita. Grazie.</string>
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
<!-- Settings -->
|
||||
<string name="settings">設定</string>
|
||||
<string name="dark_theme">ダークテーマ</string>
|
||||
<string name="same_sorting">Same sorting for files and folders</string>
|
||||
|
||||
<!--License-->
|
||||
<string name="notice">このアプリは、私の人生を容易にするために、次のサードパーティのライブラリーを使用しています。 ありがとうございます。</string>
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
<!-- Settings -->
|
||||
<string name="settings">Inställningar</string>
|
||||
<string name="dark_theme">Mörkt tema</string>
|
||||
<string name="same_sorting">Same sorting for files and folders</string>
|
||||
|
||||
<!--License-->
|
||||
<string name="notice">Denna app använder följande tredjepartsbibliotek för att göra mitt liv enklare. Tack.</string>
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
<!-- Settings -->
|
||||
<string name="settings">Settings</string>
|
||||
<string name="dark_theme">Dark theme</string>
|
||||
<string name="same_sorting">Same sorting for files and folders</string>
|
||||
|
||||
<!--License-->
|
||||
<string name="notice">This app uses the following third party libraries to make my life easier. Thank you.</string>
|
||||
|
|
Loading…
Reference in New Issue