Remove unnecessary library and legacy support for system bar tinting

This commit is contained in:
Moez Bhatti
2015-12-06 22:33:38 -05:00
parent cf2aa7869a
commit 9ac185998e
7 changed files with 9 additions and 110 deletions
@@ -10,15 +10,14 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.PorterDuff;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.preference.PreferenceManager;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.animation.DecelerateInterpolator;
import android.widget.LinearLayout;
import com.moez.QKSMS.R;
@@ -33,7 +32,6 @@ import com.moez.QKSMS.ui.view.QKTextView;
import com.moez.QKSMS.ui.view.colorpicker.ColorPickerPalette;
import com.moez.QKSMS.ui.view.colorpicker.ColorPickerSwatch;
import com.moez.QKSMS.ui.widget.WidgetProvider;
import com.readystatesoftware.systembartint.SystemBarTintManager;
import java.util.Set;
@@ -87,17 +85,14 @@ public class ThemeManager {
private static int sReceivedBubbleColor;
private static Drawable sRippleBackground;
private static SystemBarTintManager sTintManager;
private static Drawable sStatusBarTintDrawable;
private static Resources sResources;
private static SharedPreferences sPrefs;
private static boolean status_tint = false;
private static boolean status_compat = true;
private static boolean system_flat = false;
private static QKActivity mActivity;
private static Context mContext;
private static Window mWindow;
// Colours copied from http://www.google.com/design/spec/style/color.html#color-ui-color-palette
private static final int[][] COLOURS = {{
@@ -263,30 +258,17 @@ public class ThemeManager {
if (context instanceof QKActivity) {
mActivity = (QKActivity) context;
mActivity.getSupportActionBar().setBackgroundDrawable(new ColorDrawable(sColor));
mWindow = mActivity.getWindow();
}
initializeTheme(Theme.fromString(sPrefs.getString(SettingsFragment.BACKGROUND, "offwhite")));
status_tint = sPrefs.getBoolean(SettingsFragment.STATUS_TINT, Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP);
status_compat = sPrefs.getBoolean(SettingsFragment.STATUS_COMPAT, false);
system_flat = sPrefs.getBoolean(SettingsFragment.SYSTEM_BAR_FLAT, false);
if (mActivity != null) {
sTintManager = new SystemBarTintManager(mActivity);
sTintManager.setStatusBarTintEnabled(!status_compat);
sTintManager.setNavigationBarTintEnabled(false);
sTintManager.setStatusBarTintColor(status_tint ? sColor : sResources.getColor(R.color.black));
sTintManager.setNavigationBarTintColor(sResources.getColor(R.color.black));
mWindow.setStatusBarColor(status_tint ? sColor : sResources.getColor(R.color.black));
}
sStatusBarTintDrawable = ContextCompat.getDrawable(context, R.drawable.status_bar_background);
if (sStatusBarTintDrawable != null) {
sStatusBarTintDrawable.setColorFilter(status_tint ? sColor : sResources.getColor(R.color.black), PorterDuff.Mode.MULTIPLY);
}
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT && system_flat) {
sTintManager.setStatusBarTintDrawable(sStatusBarTintDrawable);
}
}
public static void setTheme(Theme theme) {
@@ -599,31 +581,13 @@ public class ThemeManager {
colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
sTintManager.setStatusBarTintColor((Integer) animation.getAnimatedValue());
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT && system_flat) {
sStatusBarTintDrawable.setColorFilter((Integer) animation.getAnimatedValue(), PorterDuff.Mode.MULTIPLY);
sTintManager.setStatusBarTintDrawable(sStatusBarTintDrawable);
}
mWindow.setStatusBarColor((Integer) animation.getAnimatedValue());
}
});
colorAnimation.start();
}
}
public static void setSystemBarFlatEnabled(boolean enabled) {
system_flat = enabled;
if (status_tint) {
status_tint = false;
setStatusBarTintEnabled(true);
}
}
public static void setStatusBarTintCompat(boolean enabled) {
sTintManager.setStatusBarTintEnabled(!enabled);
}
public static String getColorString(int color) {
return String.format("#%08x", color).toUpperCase();
}
@@ -672,12 +636,7 @@ public class ThemeManager {
}
if (status_tint) {
sTintManager.setStatusBarTintColor(color);
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT && system_flat) {
sStatusBarTintDrawable.setColorFilter(color, PorterDuff.Mode.MULTIPLY);
sTintManager.setStatusBarTintDrawable(sStatusBarTintDrawable);
}
mWindow.setStatusBarColor(color);
}
}
});
@@ -74,15 +74,10 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O
public static final String CATEGORY_MMS = "pref_key_category_mms";
public static final String CATEGORY_QUICKREPLY = "pref_key_category_quickreply";
public static final String CATEGORY_QUICKCOMPOSE = "pref_key_category_quickcompose";
public static final String CATEGORY_ADVANCED = "pref_key_category_advanced";
public static final String CATEGORY_ABOUT = "pref_key_category_about";
// Sub-categories
public static final String CATEGORY_APPEARANCE_STATUS_BARS = "pref_key_category_appearance_status_bars";
/**
* The category which holds the advanced preferences in settings_main.xml
*/
public static final String CATEGORY_ADVANCED_HOLDER = "pref_key_category_advanced_holder";
public static final String THEME = "pref_key_theme";
public static final String ICON = "pref_key_icon";
@@ -153,8 +148,6 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O
public static final String QUICKREPLY_TAP_DISMISS = "pref_key_quickreply_dismiss";
public static final String QUICKCOMPOSE = "pref_key_quickcompose";
public static final String STRIP_UNICODE = "pref_key_strip_unicode";
public static final String SYSTEM_BAR_FLAT = "pref_key_system_bar_flat";
public static final String STATUS_COMPAT = "pref_key_status_compat";
public static final String VERSION = "pref_key_version";
public static final String CHANGELOG = "pref_key_changelog";
public static final String THANKS = "pref_key_thanks";
@@ -338,15 +331,9 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O
}
// Status and nav bar tinting are only supported on kit kat or above.
if (!hasKitKat()) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
removePreference(CATEGORY_APPEARANCE_STATUS_BARS);
removePreference(CATEGORY_ADVANCED_HOLDER);
}
}
private boolean hasKitKat() {
return Build.VERSION_CODES.KITKAT <= Build.VERSION.SDK_INT;
}
/**
@@ -476,12 +463,6 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O
// Update the SMS helper static class with the new option
SmsHelper.setMaxAttachmentSizeSetting(mContext, (String) newValue);
break;
case SYSTEM_BAR_FLAT:
ThemeManager.setSystemBarFlatEnabled((Boolean) newValue);
break;
case STATUS_COMPAT:
ThemeManager.setStatusBarTintCompat((Boolean) newValue);
break;
case DELAY_DURATION:
try {
int duration = Integer.parseInt((String) newValue);
@@ -526,9 +507,6 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O
case CATEGORY_QUICKCOMPOSE:
resId = R.xml.settings_quickcompose;
break;
case CATEGORY_ADVANCED:
resId = R.xml.settings_advanced;
break;
case CATEGORY_ABOUT:
resId = R.xml.settings_about;
break;