mirror of
				https://github.com/SimpleMobileTools/Simple-Flashlight.git
				synced 2025-06-05 21:59:19 +02:00 
			
		
		
		
	add a setting for displaying Stroboscope button
This commit is contained in:
		| @@ -10,7 +10,7 @@ public class Config { | ||||
|         return new Config(context); | ||||
|     } | ||||
|  | ||||
|     public Config(Context context) { | ||||
|     private Config(Context context) { | ||||
|         mPrefs = context.getSharedPreferences(Constants.PREFS_KEY, Context.MODE_PRIVATE); | ||||
|     } | ||||
|  | ||||
| @@ -37,4 +37,12 @@ public class Config { | ||||
|     public void setBrightDisplay(boolean brightDisplay) { | ||||
|         mPrefs.edit().putBoolean(Constants.BRIGHT_DISPLAY, brightDisplay).apply(); | ||||
|     } | ||||
|  | ||||
|     public boolean getStroboscope() { | ||||
|         return mPrefs.getBoolean(Constants.STROBOSCOPE, true); | ||||
|     } | ||||
|  | ||||
|     public void setStroboscope(boolean stroboscope) { | ||||
|         mPrefs.edit().putBoolean(Constants.STROBOSCOPE, stroboscope).apply(); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -6,5 +6,6 @@ public class Constants { | ||||
|     public static final String IS_FIRST_RUN = "is_first_run"; | ||||
|     public static final String IS_DARK_THEME = "is_dark_theme"; | ||||
|     public static final String BRIGHT_DISPLAY = "bright_display"; | ||||
|     public static final String STROBOSCOPE = "stroboscope"; | ||||
|     public static final String WIDGET_COLOR = "widget_color"; | ||||
| } | ||||
|   | ||||
| @@ -14,6 +14,7 @@ import butterknife.OnClick; | ||||
| public class SettingsActivity extends SimpleActivity { | ||||
|     @BindView(R.id.settings_dark_theme) SwitchCompat mDarkThemeSwitch; | ||||
|     @BindView(R.id.settings_bright_display) SwitchCompat mBrightDisplaySwitch; | ||||
|     @BindView(R.id.settings_stroboscope) SwitchCompat mStroboscopeSwitch; | ||||
|  | ||||
|     private static Config mConfig; | ||||
|  | ||||
| @@ -26,6 +27,7 @@ public class SettingsActivity extends SimpleActivity { | ||||
|  | ||||
|         setupDarkTheme(); | ||||
|         setupBrightDisplay(); | ||||
|         setupStroboscope(); | ||||
|     } | ||||
|  | ||||
|     private void setupDarkTheme() { | ||||
| @@ -36,6 +38,10 @@ public class SettingsActivity extends SimpleActivity { | ||||
|         mBrightDisplaySwitch.setChecked(mConfig.getBrightDisplay()); | ||||
|     } | ||||
|  | ||||
|     private void setupStroboscope() { | ||||
|         mStroboscopeSwitch.setChecked(mConfig.getStroboscope()); | ||||
|     } | ||||
|  | ||||
|     @OnClick(R.id.settings_dark_theme_holder) | ||||
|     public void handleDarkTheme() { | ||||
|         mDarkThemeSwitch.setChecked(!mDarkThemeSwitch.isChecked()); | ||||
| @@ -49,6 +55,12 @@ public class SettingsActivity extends SimpleActivity { | ||||
|         mConfig.setBrightDisplay(mBrightDisplaySwitch.isChecked()); | ||||
|     } | ||||
|  | ||||
|     @OnClick(R.id.settings_stroboscope_holder) | ||||
|     public void handleStroboscope() { | ||||
|         mStroboscopeSwitch.setChecked(!mStroboscopeSwitch.isChecked()); | ||||
|         mConfig.setStroboscope(mStroboscopeSwitch.isChecked()); | ||||
|     } | ||||
|  | ||||
|     private void restartActivity() { | ||||
|         TaskStackBuilder.create(getApplicationContext()).addNextIntentWithParentStack(getIntent()).startActivities(); | ||||
|     } | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <ScrollView | ||||
|     android:id="@+id/settings_scrollview" | ||||
|     xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     android:id="@+id/settings_scrollview" | ||||
|     android:layout_width="match_parent" | ||||
|     android:layout_height="wrap_content"> | ||||
|  | ||||
| @@ -62,5 +62,31 @@ | ||||
|                 android:clickable="false"/> | ||||
|  | ||||
|         </RelativeLayout> | ||||
|  | ||||
|         <RelativeLayout | ||||
|             android:id="@+id/settings_stroboscope_holder" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:layout_marginTop="@dimen/settings_padding" | ||||
|             android:background="?attr/selectableItemBackground" | ||||
|             android:padding="@dimen/activity_margin"> | ||||
|  | ||||
|             <TextView | ||||
|                 android:id="@+id/settings_stroboscope_label" | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:layout_centerVertical="true" | ||||
|                 android:paddingLeft="@dimen/settings_padding" | ||||
|                 android:text="@string/stroboscope"/> | ||||
|  | ||||
|             <android.support.v7.widget.SwitchCompat | ||||
|                 android:id="@+id/settings_stroboscope" | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:layout_alignParentRight="true" | ||||
|                 android:background="@null" | ||||
|                 android:clickable="false"/> | ||||
|  | ||||
|         </RelativeLayout> | ||||
|     </LinearLayout> | ||||
| </ScrollView> | ||||
|   | ||||
| @@ -8,6 +8,7 @@ | ||||
|     <string name="settings">Einstellungen</string> | ||||
|     <string name="dark_theme">Dunkles Thema</string> | ||||
|     <string name="bright_display">Zeige Knopf für helles Display</string> | ||||
|     <string name="stroboscope">Show a stroboscope button</string> | ||||
|  | ||||
|     <!-- About --> | ||||
|     <string name="about">Über</string> | ||||
|   | ||||
| @@ -8,6 +8,7 @@ | ||||
|     <string name="settings">Impostazioni</string> | ||||
|     <string name="dark_theme">Tema scuro</string> | ||||
|     <string name="bright_display">Mostra un pulsante per schermo luminoso</string> | ||||
|     <string name="stroboscope">Show a stroboscope button</string> | ||||
|  | ||||
|     <!-- About --> | ||||
|     <string name="about">Informazioni</string> | ||||
|   | ||||
| @@ -8,6 +8,7 @@ | ||||
|     <string name="settings">設定</string> | ||||
|     <string name="dark_theme">ダークテーマ</string> | ||||
|     <string name="bright_display">Show a bright display button</string> | ||||
|     <string name="stroboscope">Show a stroboscope button</string> | ||||
|  | ||||
|     <!-- About --> | ||||
|     <string name="about">アプリについて</string> | ||||
|   | ||||
| @@ -8,6 +8,7 @@ | ||||
|     <string name="settings">Inställningar</string> | ||||
|     <string name="dark_theme">Mörkt tema</string> | ||||
|     <string name="bright_display">Show a bright display button</string> | ||||
|     <string name="stroboscope">Show a stroboscope button</string> | ||||
|  | ||||
|     <!-- About --> | ||||
|     <string name="about">Om</string> | ||||
|   | ||||
| @@ -8,6 +8,7 @@ | ||||
|     <string name="settings">Settings</string> | ||||
|     <string name="dark_theme">Dark theme</string> | ||||
|     <string name="bright_display">Show a bright display button</string> | ||||
|     <string name="stroboscope">Show a stroboscope button</string> | ||||
|  | ||||
|     <!-- About --> | ||||
|     <string name="about">About</string> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user