Skip to content

Commit

Permalink
Add "Show FAB" setting
Browse files Browse the repository at this point in the history
  • Loading branch information
javiersantos committed Jun 2, 2015
1 parent 9bca4a0 commit 193e3ef
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
14 changes: 10 additions & 4 deletions app/src/main/java/com/javiersantos/mlmanager/SettingsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,26 @@
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;

import com.javiersantos.mlmanager.utils.AppPreferences;
import com.javiersantos.mlmanager.utils.UtilsApp;
import com.javiersantos.mlmanager.utils.UtilsDialog;
import com.javiersantos.mlmanager.utils.UtilsUI;

import yuku.ambilwarna.widget.AmbilWarnaPreference;

public class SettingsActivity extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
// Load Settings
AppPreferences appPreferences;

// Settings variables
private SharedPreferences prefs;
private Preference prefVersion, prefPrimaryColor, prefFABColor, prefDeleteAll, prefDefaultValues, prefNavigationBlack;
private Preference prefVersion, prefDeleteAll, prefDefaultValues, prefNavigationBlack;
private AmbilWarnaPreference prefPrimaryColor, prefFABColor;
private CheckBoxPreference prefFABShow;
private String versionName;
private int versionCode;
private Context context;
Expand All @@ -36,8 +40,9 @@ public void onCreate(Bundle savedInstanceState) {
prefs.registerOnSharedPreferenceChangeListener(this);

prefVersion = findPreference("prefVersion");
prefPrimaryColor = findPreference("prefPrimaryColor");
prefFABColor = findPreference("prefFABColor");
prefPrimaryColor = (AmbilWarnaPreference) findPreference("prefPrimaryColor");
prefFABColor = (AmbilWarnaPreference) findPreference("prefFABColor");
prefFABShow = (CheckBoxPreference) findPreference("prefFABShow");
prefDeleteAll = findPreference("prefDeleteAll");
prefDefaultValues = findPreference("prefDefaultValues");
prefNavigationBlack = findPreference("prefNavigationBlack");
Expand Down Expand Up @@ -84,6 +89,7 @@ public boolean onPreferenceClick(Preference preference) {
public boolean onPreferenceClick(Preference preference) {
appPreferences.setPrimaryColorPref(getResources().getColor(R.color.primary));
appPreferences.setFABColorPref(getResources().getColor(R.color.fab));
prefFABShow.setChecked(false);
return true;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class AppPreferences {
public static final String KeyStartDelete = "prefStartDelete";
public static final String KeyPrimaryColor = "prefPrimaryColor";
public static final String KeyFABColor = "prefFABColor";
public static final String KeyFABShow = "prefFABShow";
public static final String KeyNavigationBlack = "prefNavigationBlack";

public AppPreferences(Context context) {
Expand Down Expand Up @@ -54,4 +55,12 @@ public void setNavigationBlackPref(Boolean res) {
editor.commit();
}

public Boolean getFABShowPref() {
return sharedPreferences.getBoolean(KeyFABShow, false);
}
public void setFABShowPref(Boolean res) {
editor.putBoolean(KeyFABShow, res);
editor.commit();
}

}
5 changes: 5 additions & 0 deletions app/src/main/res/xml/activity_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
android:defaultValue="@color/fab"
android:title="@string/settings_fab_color"
android:summary="@string/settings_fab_color_description"/>
<CheckBoxPreference
android:key="prefFABShow"
android:title="@string/settings_fab_show"
android:summary="@string/settings_fab_show_description"
android:defaultValue="false" />
<CheckBoxPreference
android:key="prefNavigationBlack"
android:title="@string/settings_navigation_black"
Expand Down

0 comments on commit 193e3ef

Please sign in to comment.