Allow the FAB color to be changed

multisite
Floens 10 years ago
parent 3834084b29
commit b8d459d142
  1. 20
      Clover/app/src/main/java/org/floens/chan/core/settings/ChanSettings.java
  2. 2
      Clover/app/src/main/java/org/floens/chan/ui/controller/AlbumDownloadController.java
  3. 2
      Clover/app/src/main/java/org/floens/chan/ui/controller/BoardEditController.java
  4. 1
      Clover/app/src/main/java/org/floens/chan/ui/controller/FiltersController.java
  5. 197
      Clover/app/src/main/java/org/floens/chan/ui/controller/ThemeSettingsController.java
  6. 2
      Clover/app/src/main/java/org/floens/chan/ui/layout/ThreadLayout.java
  7. 8
      Clover/app/src/main/java/org/floens/chan/ui/theme/Theme.java
  8. 105
      Clover/app/src/main/java/org/floens/chan/ui/theme/ThemeHelper.java
  9. 12
      Clover/app/src/main/java/org/floens/chan/ui/view/FloatingMenu.java
  10. 4
      Clover/app/src/main/res/layout/controller_theme.xml
  11. 3
      Clover/app/src/main/res/values/strings.xml
  12. 8
      Clover/app/src/main/res/values/styles.xml

@ -19,6 +19,7 @@ package org.floens.chan.core.settings;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Environment; import android.os.Environment;
import android.text.TextUtils;
import org.floens.chan.Chan; import org.floens.chan.Chan;
import org.floens.chan.R; import org.floens.chan.R;
@ -235,22 +236,25 @@ public class ChanSettings {
String theme = themeRaw; String theme = themeRaw;
String color = null; String color = null;
String accentColor = null;
String[] splitted = themeRaw.split(","); String[] splitted = themeRaw.split(",");
if (splitted.length == 2) { if (splitted.length >= 2) {
theme = splitted[0]; theme = splitted[0];
color = splitted[1]; color = splitted[1];
if (splitted.length == 3) {
accentColor = splitted[2];
}
} }
return new ThemeColor(theme, color); return new ThemeColor(theme, color, accentColor);
} }
public static void setThemeAndColor(ThemeColor themeColor) { public static void setThemeAndColor(ThemeColor themeColor) {
if (themeColor.color != null) { if (TextUtils.isEmpty(themeColor.color) || TextUtils.isEmpty(themeColor.accentColor)) {
ChanSettings.theme.set(themeColor.theme + "," + themeColor.color); throw new IllegalArgumentException();
} else {
ChanSettings.theme.set(themeColor.theme);
} }
ChanSettings.theme.set(themeColor.theme + "," + themeColor.color + "," + themeColor.accentColor);
} }
/** /**
@ -273,10 +277,12 @@ public class ChanSettings {
public static class ThemeColor { public static class ThemeColor {
public String theme; public String theme;
public String color; public String color;
public String accentColor;
public ThemeColor(String theme, String color) { public ThemeColor(String theme, String color, String accentColor) {
this.theme = theme; this.theme = theme;
this.color = color; this.color = color;
this.accentColor = accentColor;
} }
} }
} }

@ -48,6 +48,7 @@ import org.floens.chan.utils.RecyclerUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static org.floens.chan.ui.theme.ThemeHelper.theme;
import static org.floens.chan.utils.AndroidUtils.dp; import static org.floens.chan.utils.AndroidUtils.dp;
public class AlbumDownloadController extends Controller implements ToolbarMenuItem.ToolbarMenuItemCallback, View.OnClickListener { public class AlbumDownloadController extends Controller implements ToolbarMenuItem.ToolbarMenuItemCallback, View.OnClickListener {
@ -83,6 +84,7 @@ public class AlbumDownloadController extends Controller implements ToolbarMenuIt
download = (FloatingActionButton) view.findViewById(R.id.download); download = (FloatingActionButton) view.findViewById(R.id.download);
download.setOnClickListener(this); download.setOnClickListener(this);
theme().applyFabColor(download);
recyclerView = (GridRecyclerView) view.findViewById(R.id.recycler_view); recyclerView = (GridRecyclerView) view.findViewById(R.id.recycler_view);
recyclerView.setHasFixedSize(true); recyclerView.setHasFixedSize(true);
gridLayoutManager = new GridLayoutManager(context, 3); gridLayoutManager = new GridLayoutManager(context, 3);

@ -58,6 +58,7 @@ import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import static org.floens.chan.ui.theme.ThemeHelper.theme;
import static org.floens.chan.utils.AndroidUtils.dp; import static org.floens.chan.utils.AndroidUtils.dp;
import static org.floens.chan.utils.AndroidUtils.fixSnackbarText; import static org.floens.chan.utils.AndroidUtils.fixSnackbarText;
import static org.floens.chan.utils.AndroidUtils.getString; import static org.floens.chan.utils.AndroidUtils.getString;
@ -95,6 +96,7 @@ public class BoardEditController extends Controller implements View.OnClickListe
recyclerView.setLayoutManager(new LinearLayoutManager(context)); recyclerView.setLayoutManager(new LinearLayoutManager(context));
add = (FloatingActionButton) view.findViewById(R.id.add); add = (FloatingActionButton) view.findViewById(R.id.add);
add.setOnClickListener(this); add.setOnClickListener(this);
theme().applyFabColor(add);
boards = boardManager.getSavedBoards(); boards = boardManager.getSavedBoards();

@ -115,6 +115,7 @@ public class FiltersController extends Controller implements ToolbarMenuItem.Too
add = (FloatingActionButton) view.findViewById(R.id.add); add = (FloatingActionButton) view.findViewById(R.id.add);
add.setOnClickListener(this); add.setOnClickListener(this);
theme().applyFabColor(add);
adapter = new FilterAdapter(); adapter = new FilterAdapter();
recyclerView.setAdapter(adapter); recyclerView.setAdapter(adapter);

@ -19,10 +19,15 @@ package org.floens.chan.ui.controller;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Color; import android.graphics.Color;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
import android.support.v7.view.ContextThemeWrapper; import android.support.v7.view.ContextThemeWrapper;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.view.Gravity; import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -57,58 +62,60 @@ import java.util.List;
import static org.floens.chan.utils.AndroidUtils.dp; import static org.floens.chan.utils.AndroidUtils.dp;
import static org.floens.chan.utils.AndroidUtils.getAttrColor; import static org.floens.chan.utils.AndroidUtils.getAttrColor;
import static org.floens.chan.utils.AndroidUtils.getString;
public class ThemeSettingsController extends Controller implements View.OnClickListener { public class ThemeSettingsController extends Controller implements View.OnClickListener {
private ViewPager pager; private static PostCell.PostCellCallback DUMMY_POST_CALLBACK = new PostCell.PostCellCallback() {
private FloatingActionButton done; private Loadable loadable = new Loadable("g", 1234);
private Adapter adapter;
private ThemeHelper themeHelper;
private List<ThemeHelper.PrimaryColor> colors = new ArrayList<>(); @Override
public Loadable getLoadable() {
return loadable;
}
private PostCell.PostCellCallback DUMMY_POST_CALLBACK; @Override
public void onPostClicked(Post post) {
}
public ThemeSettingsController(Context context) { @Override
super(context); public void onThumbnailClicked(Post post, ThumbnailView thumbnail) {
}
DUMMY_POST_CALLBACK = new PostCell.PostCellCallback() { @Override
private Loadable loadable = new Loadable("g", 1234); public void onShowPostReplies(Post post) {
}
@Override @Override
public Loadable getLoadable() { public void onPopulatePostOptions(Post post, List<FloatingMenuItem> menu) {
return loadable; menu.add(new FloatingMenuItem(1, "Option"));
} }
@Override @Override
public void onPostClicked(Post post) { public void onPostOptionClicked(Post post, Object id) {
} }
@Override @Override
public void onThumbnailClicked(Post post, ThumbnailView thumbnail) { public void onPostLinkableClicked(PostLinkable linkable) {
} }
@Override @Override
public void onShowPostReplies(Post post) { public void onPostNoClicked(Post post) {
} }
};
@Override private ViewPager pager;
public void onPopulatePostOptions(Post post, List<FloatingMenuItem> menu) { private FloatingActionButton done;
menu.add(new FloatingMenuItem(1, "Option")); private TextView textView;
}
@Override private Adapter adapter;
public void onPostOptionClicked(Post post, Object id) { private ThemeHelper themeHelper;
}
@Override private List<Theme> themes;
public void onPostLinkableClicked(PostLinkable linkable) { private List<ThemeHelper.PrimaryColor> selectedPrimaryColors = new ArrayList<>();
} private ThemeHelper.PrimaryColor selectedAccentColor;
@Override public ThemeSettingsController(Context context) {
public void onPostNoClicked(Post post) { super(context);
}
};
} }
@Override @Override
@ -120,42 +127,101 @@ public class ThemeSettingsController extends Controller implements View.OnClickL
view = inflateRes(R.layout.controller_theme); view = inflateRes(R.layout.controller_theme);
themeHelper = ThemeHelper.getInstance(); themeHelper = ThemeHelper.getInstance();
themes = themeHelper.getThemes();
pager = (ViewPager) view.findViewById(R.id.pager); pager = (ViewPager) view.findViewById(R.id.pager);
done = (FloatingActionButton) view.findViewById(R.id.add); done = (FloatingActionButton) view.findViewById(R.id.add);
done.setOnClickListener(this); done.setOnClickListener(this);
textView = (TextView) view.findViewById(R.id.text);
SpannableString changeAccentColor = new SpannableString(getString(R.string.setting_theme_accent));
changeAccentColor.setSpan(new ClickableSpan() {
@Override
public void onClick(View widget) {
showAccentColorPicker();
}
}, 0, changeAccentColor.length(), 0);
textView.setText(TextUtils.concat(getString(R.string.setting_theme_explanation), changeAccentColor));
textView.setMovementMethod(LinkMovementMethod.getInstance());
adapter = new Adapter(); adapter = new Adapter();
pager.setAdapter(adapter); pager.setAdapter(adapter);
ChanSettings.ThemeColor currentSettingsTheme = ChanSettings.getThemeAndColor(); ChanSettings.ThemeColor currentSettingsTheme = ChanSettings.getThemeAndColor();
for (int i = 0; i < themeHelper.getThemes().size(); i++) { for (int i = 0; i < themeHelper.getThemes().size(); i++) {
Theme theme = themeHelper.getThemes().get(i); Theme theme = themeHelper.getThemes().get(i);
ThemeHelper.PrimaryColor color = theme.primaryColor; ThemeHelper.PrimaryColor primaryColor = theme.primaryColor;
if (theme.name.equals(currentSettingsTheme.theme)) { if (theme.name.equals(currentSettingsTheme.theme)) {
// Current theme
pager.setCurrentItem(i, false); pager.setCurrentItem(i, false);
if (currentSettingsTheme.color != null) {
color = themeHelper.getColor(currentSettingsTheme.color);
}
} }
colors.add(color); selectedPrimaryColors.add(primaryColor);
} }
selectedAccentColor = themeHelper.getTheme().accentColor;
done.setBackgroundTintList(ColorStateList.valueOf(selectedAccentColor.color));
} }
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (v == done) { if (v == done) {
Theme theme = themeHelper.getThemes().get(pager.getCurrentItem()); saveTheme();
themeHelper.changeTheme(theme, colors.get(pager.getCurrentItem()));
((StartActivity) context).restart();
} }
} }
private class Adapter extends ViewPagerAdapter { private void saveTheme() {
private List<Theme> themes; int currentItem = pager.getCurrentItem();
Theme selectedTheme = themeHelper.getThemes().get(currentItem);
ThemeHelper.PrimaryColor selectedColor = selectedPrimaryColors.get(currentItem);
themeHelper.changeTheme(selectedTheme, selectedColor, selectedAccentColor);
((StartActivity) context).restart();
}
private void showAccentColorPicker() {
List<FloatingMenuItem> items = new ArrayList<>();
FloatingMenuItem selected = null;
for (ThemeHelper.PrimaryColor color : themeHelper.getColors()) {
FloatingMenuItem floatingMenuItem = new FloatingMenuItem(new ColorsAdapterItem(color, color.color), color.displayName);
items.add(floatingMenuItem);
if (color == selectedAccentColor) {
selected = floatingMenuItem;
}
}
FloatingMenu menu = getColorsMenu(items, selected, textView);
menu.setCallback(new FloatingMenu.FloatingMenuCallback() {
@Override
public void onFloatingMenuItemClicked(FloatingMenu menu, FloatingMenuItem item) {
ColorsAdapterItem colorItem = (ColorsAdapterItem) item.getId();
selectedAccentColor = colorItem.color;
done.setBackgroundTintList(ColorStateList.valueOf(selectedAccentColor.color));
}
@Override
public void onFloatingMenuDismissed(FloatingMenu menu) {
}
});
menu.setPopupWidth(dp(200));
menu.setPopupHeight(dp(300));
menu.show();
}
private FloatingMenu getColorsMenu(List<FloatingMenuItem> items, FloatingMenuItem selected, View anchor) {
FloatingMenu menu = new FloatingMenu(context);
menu.setItems(items);
menu.setAdapter(new ColorsAdapter(items));
menu.setSelectedItem(selected);
menu.setAnchor(anchor, Gravity.CENTER, 0, dp(5));
menu.setPopupWidth(anchor.getWidth());
return menu;
}
private class Adapter extends ViewPagerAdapter {
public Adapter() { public Adapter() {
themes = themeHelper.getThemes();
} }
@Override @Override
@ -197,25 +263,20 @@ public class ThemeSettingsController extends Controller implements View.OnClickL
List<FloatingMenuItem> items = new ArrayList<>(); List<FloatingMenuItem> items = new ArrayList<>();
FloatingMenuItem selected = null; FloatingMenuItem selected = null;
for (ThemeHelper.PrimaryColor color : themeHelper.getColors()) { for (ThemeHelper.PrimaryColor color : themeHelper.getColors()) {
FloatingMenuItem floatingMenuItem = new FloatingMenuItem(color, color.displayName); FloatingMenuItem floatingMenuItem = new FloatingMenuItem(new ColorsAdapterItem(color, color.color500), color.displayName);
items.add(floatingMenuItem); items.add(floatingMenuItem);
if (color == colors.get(position)) { if (color == selectedPrimaryColors.get(position)) {
selected = floatingMenuItem; selected = floatingMenuItem;
} }
} }
FloatingMenu menu = new FloatingMenu(context); FloatingMenu menu = getColorsMenu(items, selected, toolbar);
menu.setItems(items);
menu.setAdapter(new ColorsAdapter(items));
menu.setSelectedItem(selected);
menu.setAnchor(toolbar, Gravity.CENTER, 0, dp(5));
menu.setPopupWidth(toolbar.getWidth());
menu.setCallback(new FloatingMenu.FloatingMenuCallback() { menu.setCallback(new FloatingMenu.FloatingMenuCallback() {
@Override @Override
public void onFloatingMenuItemClicked(FloatingMenu menu, FloatingMenuItem item) { public void onFloatingMenuItemClicked(FloatingMenu menu, FloatingMenuItem item) {
ThemeHelper.PrimaryColor primaryColor = (ThemeHelper.PrimaryColor) item.getId(); ColorsAdapterItem colorItem = (ColorsAdapterItem) item.getId();
colors.set(position, primaryColor); selectedPrimaryColors.set(position, colorItem.color);
toolbar.setBackgroundColor(primaryColor.color); toolbar.setBackgroundColor(colorItem.color.color);
} }
@Override @Override
@ -281,10 +342,10 @@ public class ThemeSettingsController extends Controller implements View.OnClickL
textView.setText(getItem(position)); textView.setText(getItem(position));
textView.setTypeface(AndroidUtils.ROBOTO_MEDIUM); textView.setTypeface(AndroidUtils.ROBOTO_MEDIUM);
ThemeHelper.PrimaryColor color = (ThemeHelper.PrimaryColor) items.get(position).getId(); ColorsAdapterItem color = (ColorsAdapterItem) items.get(position).getId();
textView.setBackgroundColor(color.color); textView.setBackgroundColor(color.bg);
boolean lightColor = (Color.red(color.color) * 0.299f) + (Color.green(color.color) * 0.587f) + (Color.blue(color.color) * 0.114f) > 125f; boolean lightColor = (Color.red(color.bg) * 0.299f) + (Color.green(color.bg) * 0.587f) + (Color.blue(color.bg) * 0.114f) > 125f;
textView.setTextColor(lightColor ? 0xff000000 : 0xffffffff); textView.setTextColor(lightColor ? 0xff000000 : 0xffffffff);
return textView; return textView;
@ -305,4 +366,14 @@ public class ThemeSettingsController extends Controller implements View.OnClickL
return position; return position;
} }
} }
private static class ColorsAdapterItem {
public ThemeHelper.PrimaryColor color;
public int bg;
public ColorsAdapterItem(ThemeHelper.PrimaryColor color, int bg) {
this.color = color;
this.bg = bg;
}
}
} }

@ -69,6 +69,7 @@ import java.util.List;
import javax.net.ssl.SSLException; import javax.net.ssl.SSLException;
import static org.floens.chan.ui.theme.ThemeHelper.theme;
import static org.floens.chan.utils.AndroidUtils.fixSnackbarText; import static org.floens.chan.utils.AndroidUtils.fixSnackbarText;
import static org.floens.chan.utils.AndroidUtils.getString; import static org.floens.chan.utils.AndroidUtils.getString;
@ -144,6 +145,7 @@ public class ThreadLayout extends CoordinatorLayout implements ThreadPresenter.T
} else { } else {
replyButton.setOnClickListener(this); replyButton.setOnClickListener(this);
replyButton.setToolbar(callback.getToolbar()); replyButton.setToolbar(callback.getToolbar());
theme().applyFabColor(replyButton);
} }
switchVisible(Visible.LOADING); switchVisible(Visible.LOADING);

@ -18,9 +18,11 @@
package org.floens.chan.ui.theme; package org.floens.chan.ui.theme;
import android.content.Context; import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources; import android.content.res.Resources;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.support.design.widget.FloatingActionButton;
import android.widget.ImageView; import android.widget.ImageView;
import org.floens.chan.R; import org.floens.chan.R;
@ -37,6 +39,7 @@ public class Theme {
public final int resValue; public final int resValue;
public boolean isLightTheme = true; public boolean isLightTheme = true;
public ThemeHelper.PrimaryColor primaryColor; public ThemeHelper.PrimaryColor primaryColor;
public ThemeHelper.PrimaryColor accentColor;
public int textPrimary; public int textPrimary;
public int textSecondary; public int textSecondary;
@ -71,6 +74,7 @@ public class Theme {
this.name = name; this.name = name;
this.resValue = resValue; this.resValue = resValue;
this.primaryColor = primaryColor; this.primaryColor = primaryColor;
accentColor = ThemeHelper.PrimaryColor.TEAL;
resolveSpanColors(); resolveSpanColors();
resolveDrawables(); resolveDrawables();
@ -88,6 +92,10 @@ public class Theme {
helpDrawable = new ThemeDrawable(R.drawable.ic_help_outline_black_24dp, 0.54f); helpDrawable = new ThemeDrawable(R.drawable.ic_help_outline_black_24dp, 0.54f);
} }
public void applyFabColor(FloatingActionButton fab) {
fab.setBackgroundTintList(ColorStateList.valueOf(accentColor.color));
}
private void resolveSpanColors() { private void resolveSpanColors() {
Resources.Theme theme = AndroidUtils.getAppContext().getResources().newTheme(); Resources.Theme theme = AndroidUtils.getAppContext().getResources().newTheme();
theme.applyStyle(R.style.Chan_Theme, true); theme.applyStyle(R.style.Chan_Theme, true);

@ -58,21 +58,20 @@ public class ThemeHelper {
themes.add(new Theme("Photon", "photon", R.style.Chan_Theme_Photon, PrimaryColor.ORANGE)); themes.add(new Theme("Photon", "photon", R.style.Chan_Theme_Photon, PrimaryColor.ORANGE));
ChanSettings.ThemeColor settingTheme = ChanSettings.getThemeAndColor(); ChanSettings.ThemeColor settingTheme = ChanSettings.getThemeAndColor();
if (settingTheme.color != null) { for (Theme theme : themes) {
for (Theme theme : themes) { if (theme.name.equals(settingTheme.theme)) {
if (theme.name.equals(settingTheme.theme)) { patchTheme(theme, settingTheme);
theme.primaryColor = getColor(settingTheme.color); break;
break;
}
} }
} }
updateCurrentTheme(); updateCurrentTheme();
} }
public void changeTheme(Theme theme, PrimaryColor primaryColor) { public void changeTheme(Theme theme, PrimaryColor primaryColor, PrimaryColor accentColor) {
ChanSettings.setThemeAndColor(new ChanSettings.ThemeColor(theme.name, primaryColor.name)); ChanSettings.ThemeColor setting = new ChanSettings.ThemeColor(theme.name, primaryColor.name, accentColor.name);
theme.primaryColor = primaryColor; ChanSettings.setThemeAndColor(setting);
patchTheme(theme, setting);
updateCurrentTheme(); updateCurrentTheme();
} }
@ -89,6 +88,16 @@ public class ThemeHelper {
theme = themes.get(0); theme = themes.get(0);
} }
private void patchTheme(Theme theme, ChanSettings.ThemeColor setting) {
// Patch the theme primary and accent color when set in the settings
if (setting.color != null) {
theme.primaryColor = getColor(setting.color, PrimaryColor.BLACK);
}
if (setting.accentColor != null) {
theme.accentColor = getColor(setting.accentColor, PrimaryColor.TEAL);
}
}
public Theme getTheme() { public Theme getTheme() {
return theme; return theme;
} }
@ -110,15 +119,15 @@ public class ThemeHelper {
} }
} }
public PrimaryColor getColor(String name) { public PrimaryColor getColor(String name, PrimaryColor defaultColor) {
for (PrimaryColor primaryColor : PrimaryColor.values()) { for (PrimaryColor primaryColor : PrimaryColor.values()) {
if (primaryColor.name.equals(name)) { if (primaryColor.name.equals(name)) {
return primaryColor; return primaryColor;
} }
} }
Logger.e(TAG, "No color found for setting " + name + ", using a default color"); Logger.e(TAG, "No color found for setting " + name);
return PrimaryColor.BLACK; return defaultColor;
} }
public List<PrimaryColor> getColors() { public List<PrimaryColor> getColors() {
@ -126,39 +135,59 @@ public class ThemeHelper {
} }
public enum PrimaryColor { public enum PrimaryColor {
RED("Red", "red", 0xFFF44336, 0xFFD32F2F), RED("Red", "red", 0xFFFFEBEE, 0xFFFFCDD2, 0xFFEF9A9A, 0xFFE57373, 0xFFEF5350, 0xFFF44336, 0xFFE53935, 0xFFD32F2F, 0xFFD32F2F, 0xFFB71C1C),
PINK("Pink", "pink", 0xFFE91E63, 0xFFC2185B), PINK("Pink", "pink", 0xFFFCE4EC, 0xFFF8BBD0, 0xFFF48FB1, 0xFFF06292, 0xFFEC407A, 0xFFE91E63, 0xFFD81B60, 0xFFC2185B, 0xFFC2185B, 0xFF880E4F),
PURPLE("Purple", "purple", 0xFF9C27B0, 0xFF7B1FA2), PURPLE("Purple", "purple", 0xFFF3E5F5, 0xFFE1BEE7, 0xFFCE93D8, 0xFFBA68C8, 0xFFAB47BC, 0xFF9C27B0, 0xFF8E24AA, 0xFF7B1FA2, 0xFF7B1FA2, 0xFF4A148C),
DEEP_PURPLE("Deep purple", "deep_purple", 0xFF673AB7, 0xFF512DA8), DEEP_PURPLE("Deep Purple", "deep_purple", 0xFFEDE7F6, 0xFFD1C4E9, 0xFFB39DDB, 0xFF9575CD, 0xFF7E57C2, 0xFF673AB7, 0xFF5E35B1, 0xFF512DA8, 0xFF512DA8, 0xFF311B92),
INDIGO("Indigo", "indigo", 0xFF3F51B5, 0xFF303F9F), INDIGO("Indigo", "indigo", 0xFFE8EAF6, 0xFFC5CAE9, 0xFF9FA8DA, 0xFF7986CB, 0xFF5C6BC0, 0xFF3F51B5, 0xFF3949AB, 0xFF303F9F, 0xFF303F9F, 0xFF1A237E),
BLUE("Blue", "blue", 0xFF2196F3, 0xFF1976D2), BLUE("Blue", "blue", 0xFFE3F2FD, 0xFFBBDEFB, 0xFF90CAF9, 0xFF64B5F6, 0xFF42A5F5, 0xFF2196F3, 0xFF1E88E5, 0xFF1976D2, 0xFF1976D2, 0xFF0D47A1),
LIGHT_BLUE("Light blue", "light_blue", 0xFF03A9F4, 0xFF0288D1), LIGHT_BLUE("Light Blue", "light_blue", 0xFFE1F5FE, 0xFFB3E5FC, 0xFF81D4FA, 0xFF4FC3F7, 0xFF29B6F6, 0xFF03A9F4, 0xFF039BE5, 0xFF0288D1, 0xFF0288D1, 0xFF01579B),
CYAN("Cyan", "cyan", 0xFF00BCD4, 0xFF0097A7), CYAN("Cyan", "cyan", 0xFFE0F7FA, 0xFFB2EBF2, 0xFF80DEEA, 0xFF4DD0E1, 0xFF26C6DA, 0xFF00BCD4, 0xFF00ACC1, 0xFF0097A7, 0xFF0097A7, 0xFF006064),
TEAL("Teal", "teal", 0xFF009688, 0xFF00796B), TEAL("Teal", "teal", 0xFFE0F2F1, 0xFFB2DFDB, 0xFF80CBC4, 0xFF4DB6AC, 0xFF26A69A, 0xFF009688, 0xFF00897B, 0xFF00796B, 0xFF00796B, 0xFF004D40),
GREEN("Green", "green", 0xFF4CAF50, 0xFF388E3C), GREEN("Green", "green", 0xFFE8F5E9, 0xFFC8E6C9, 0xFFA5D6A7, 0xFF81C784, 0xFF66BB6A, 0xFF4CAF50, 0xFF43A047, 0xFF388E3C, 0xFF388E3C, 0xFF1B5E20),
LIGHT_GREEN("Light green", "light_green", 0xFF8BC34A, 0xFF689F38), LIGHT_GREEN("Light Green", "light_green", 0xFFF1F8E9, 0xFFDCEDC8, 0xFFC5E1A5, 0xFFAED581, 0xFF9CCC65, 0xFF8BC34A, 0xFF7CB342, 0xFF689F38, 0xFF689F38, 0xFF33691E),
LIME("Lime", "lime", 0xFFCDDC39, 0xFFAFB42B), LIME("Lime", "lime", 0xFFF9FBE7, 0xFFF0F4C3, 0xFFE6EE9C, 0xFFDCE775, 0xFFD4E157, 0xFFCDDC39, 0xFFC0CA33, 0xFFAFB42B, 0xFFAFB42B, 0xFF827717),
YELLOW("Yellow", "yellow", 0xFFFFEB3B, 0xFFFBC02D), YELLOW("Yellow", "yellow", 0xFFFFFDE7, 0xFFFFF9C4, 0xFFFFF59D, 0xFFFFF176, 0xFFFFEE58, 0xFFFFEB3B, 0xFFFDD835, 0xFFFBC02D, 0xFFFBC02D, 0xFFF57F17),
AMBER("Amber", "amber", 0xFFFFC107, 0xFFFFA000), AMBER("Amber", "amber", 0xFFFFF8E1, 0xFFFFECB3, 0xFFFFE082, 0xFFFFD54F, 0xFFFFCA28, 0xFFFFC107, 0xFFFFB300, 0xFFFFA000, 0xFFFFA000, 0xFFFF6F00),
ORANGE("Orange", "orange", 0xFFFF9800, 0xFFF57C00), ORANGE("Orange", "orange", 0xFFFFF3E0, 0xFFFFE0B2, 0xFFFFCC80, 0xFFFFB74D, 0xFFFFA726, 0xFFFF9800, 0xFFFB8C00, 0xFFF57C00, 0xFFF57C00, 0xFFE65100),
DEEP_ORANGE("Deep orange", "deep_orange", 0xFFFF5722, 0xFFE64A19), DEEP_ORANGE("Deep Orange", "deep_orange", 0xFFFBE9E7, 0xFFFFCCBC, 0xFFFFAB91, 0xFFFF8A65, 0xFFFF7043, 0xFFFF5722, 0xFFF4511E, 0xFFE64A19, 0xFFE64A19, 0xFFBF360C),
BROWN("Brown", "brown", 0xFF795548, 0xFF5D4037), BROWN("Brown", "brown", 0xFFEFEBE9, 0xFFD7CCC8, 0xFFBCAAA4, 0xFFA1887F, 0xFF8D6E63, 0xFF795548, 0xFF6D4C41, 0xFF5D4037, 0xFF5D4037, 0xFF3E2723),
GREY("Grey", "grey", 0xFF9E9E9E, 0xFF616161), GREY("Grey", "grey", 0xFFFAFAFA, 0xFFF5F5F5, 0xFFEEEEEE, 0xFFE0E0E0, 0xFFBDBDBD, 0xFF9E9E9E, 0xFF757575, 0xFF616161, 0xFF616161, 0xFF212121),
BLUE_GREY("Blue grey", "blue_grey", 0xFF607D8B, 0xFF455A64), BLUE_GREY("Blue Grey", "blue_grey", 0xFFECEFF1, 0xFFCFD8DC, 0xFFB0BEC5, 0xFF90A4AE, 0xFF78909C, 0xFF607D8B, 0xFF546E7A, 0xFF455A64, 0xFF455A64, 0xFF263238),
DARK("Dark", "dark", 0xff212121, 0xff000000), DARK("Dark", "dark", 0xff212121, 0xff212121, 0xff212121, 0xff212121, 0xff212121, 0xff212121, 0xff000000, 0xff000000, 0xff000000, 0xff000000),
BLACK("Black", "black", 0xff000000, 0xff000000); BLACK("Black", "black", 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000);
public final String displayName; public final String displayName;
public final String name; public final String name;
public final int color; public final int color;
public final int dark; public final int dark;
public final int color50;
PrimaryColor(String displayName, String name, int color, int dark) { public final int color100;
public final int color200;
public final int color300;
public final int color400;
public final int color500;
public final int color600;
public final int color700;
public final int color800;
public final int color900;
PrimaryColor(String displayName, String name, int color50, int color100, int color200, int color300, int color400, int color500, int color600, int color700, int color800, int color900) {
this.displayName = displayName; this.displayName = displayName;
this.name = name; this.name = name;
this.color = color; this.color = color500;
this.dark = dark; this.dark = color700;
this.color50 = color50;
this.color100 = color100;
this.color200 = color200;
this.color300 = color300;
this.color400 = color400;
this.color500 = color500;
this.color600 = color600;
this.color700 = color700;
this.color800 = color800;
this.color900 = color900;
} }
} }
} }

@ -49,6 +49,7 @@ public class FloatingMenu {
private int anchorOffsetX; private int anchorOffsetX;
private int anchorOffsetY; private int anchorOffsetY;
private int popupWidth = POPUP_WIDTH_AUTO; private int popupWidth = POPUP_WIDTH_AUTO;
private int popupHeight = -1;
private List<FloatingMenuItem> items; private List<FloatingMenuItem> items;
private FloatingMenuItem selectedItem; private FloatingMenuItem selectedItem;
private ListAdapter adapter; private ListAdapter adapter;
@ -84,6 +85,13 @@ public class FloatingMenu {
} }
} }
public void setPopupHeight(int height) {
this.popupHeight = height;
if (popupWindow != null) {
popupWindow.setHeight(height);
}
}
public void setItems(List<FloatingMenuItem> items) { public void setItems(List<FloatingMenuItem> items) {
this.items = items; this.items = items;
if (popupWindow != null) { if (popupWindow != null) {
@ -118,6 +126,10 @@ public class FloatingMenu {
popupWindow.setContentWidth(popupWidth); popupWindow.setContentWidth(popupWidth);
} }
if (popupHeight > 0) {
popupWindow.setHeight(popupHeight);
}
int selectedPosition = 0; int selectedPosition = 0;
for (int i = 0; i < items.size(); i++) { for (int i = 0; i < items.size(); i++) {
if (items.get(i) == selectedItem) { if (items.get(i) == selectedItem) {

@ -27,10 +27,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
android:id="@+id/text"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="16dp" android:padding="16dp" />
android:text="@string/setting_theme_explanation" />
<android.support.v4.view.ViewPager <android.support.v4.view.ViewPager
android:id="@+id/pager" android:id="@+id/pager"

@ -325,7 +325,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<string name="settings_group_browsing">Browsing</string> <string name="settings_group_browsing">Browsing</string>
<string name="setting_theme">Theme</string> <string name="setting_theme">Theme</string>
<string name="setting_theme_explanation">Swipe to change the theme.\nTap the toolbar to change its color.</string> <string name="setting_theme_explanation">Swipe to change the theme.\nTap the toolbar to change its color.\n</string>
<string name="setting_theme_accent">Click here to change the FAB color</string>
<string name="setting_font_size">Font size</string> <string name="setting_font_size">Font size</string>
<string name="setting_font_size_default">(default)</string> <string name="setting_font_size_default">(default)</string>
<string name="setting_font_condensed">Use condensed font</string> <string name="setting_font_condensed">Use condensed font</string>

@ -16,13 +16,13 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
--> -->
<resources> <resources>
<color name="primary">#ff4caf50</color> <!--<color name="primary">#ff4caf50</color>-->
<color name="primary_dark">#ff388e3c</color> <!--<color name="primary_dark">#ff388e3c</color>-->
<color name="accent">#ff009688</color> <!--<color name="accent">#ff009688</color>-->
<!-- Main light theme --> <!-- Main light theme -->
<style name="Chan.Theme" parent="Theme.AppCompat.Light.NoActionBar"> <style name="Chan.Theme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorAccent">#ff009688</item> <!--<item name="colorAccent">#ff009688</item>-->
<item name="android:windowBackground">@android:color/white</item> <item name="android:windowBackground">@android:color/white</item>
<item name="windowActionModeOverlay">true</item> <item name="windowActionModeOverlay">true</item>

Loading…
Cancel
Save