Replaced the custom implementation with the new color chooser dialog from material dialogs.
This commit is contained in:
parent
2849346fff
commit
a8570a1139
6 changed files with 21 additions and 688 deletions
|
|
@ -25,6 +25,12 @@
|
||||||
|
|
||||||
<p>You can view the changelog dialog again at any time from the <i>about</i> section.</p>
|
<p>You can view the changelog dialog again at any time from the <i>about</i> section.</p>
|
||||||
|
|
||||||
|
<h3>Version 0.9.47 beta 1</h3>
|
||||||
|
|
||||||
|
<ol>
|
||||||
|
<li><b>NEW:</b> HEX color chooser! (Once again you can thank Aidan Follestad for that)</li>
|
||||||
|
</ol>
|
||||||
|
|
||||||
<h3>Version 0.9.46 beta 6</h3>
|
<h3>Version 0.9.46 beta 6</h3>
|
||||||
|
|
||||||
<ol>
|
<ol>
|
||||||
|
|
|
||||||
|
|
@ -1,280 +0,0 @@
|
||||||
package com.kabouzeid.gramophone.dialogs;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.Dialog;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.annotation.ColorInt;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.annotation.StringRes;
|
|
||||||
import android.util.DisplayMetrics;
|
|
||||||
import android.util.TypedValue;
|
|
||||||
import android.view.Gravity;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.BaseAdapter;
|
|
||||||
import android.widget.GridView;
|
|
||||||
|
|
||||||
import com.afollestad.materialdialogs.DialogAction;
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog;
|
|
||||||
import com.kabouzeid.gramophone.R;
|
|
||||||
import com.kabouzeid.gramophone.views.SelectableColorView;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Aidan Follestad (afollestad), Karim Abou Zeid (kabouzeid)
|
|
||||||
*/
|
|
||||||
public class ColorChooserDialog extends LeakDetectDialogFragment implements View.OnClickListener {
|
|
||||||
|
|
||||||
private ColorSetWithHeaders colorSetWithHeaders;
|
|
||||||
|
|
||||||
public ColorChooserDialog() {
|
|
||||||
}
|
|
||||||
|
|
||||||
private int mCircleSize;
|
|
||||||
private ColorCallback mCallback;
|
|
||||||
private GridView mGrid;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttach(Activity activity) {
|
|
||||||
super.onAttach(activity);
|
|
||||||
if (!(activity instanceof ColorCallback))
|
|
||||||
throw new IllegalStateException("ColorChooserDialog needs to be shown from an Activity implementing ColorCallback.");
|
|
||||||
mCallback = (ColorCallback) activity;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isInSub() {
|
|
||||||
return getArguments().getBoolean("in_sub", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setInSub(boolean value) {
|
|
||||||
getArguments().putBoolean("in_sub", value);
|
|
||||||
if (value) {
|
|
||||||
((MaterialDialog) getDialog()).setActionButton(DialogAction.NEUTRAL, R.string.back);
|
|
||||||
} else {
|
|
||||||
((MaterialDialog) getDialog()).setActionButton(DialogAction.NEUTRAL, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getTopIndex() {
|
|
||||||
return getArguments().getInt("top_index", -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setTopIndex(int value) {
|
|
||||||
if (getTopIndex() != value)
|
|
||||||
setSubIndex(colorSetWithHeaders.headerColorIndexes[value]);
|
|
||||||
getArguments().putInt("top_index", value);
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getSubIndex() {
|
|
||||||
return getArguments().getInt("sub_index", -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setSubIndex(int value) {
|
|
||||||
getArguments().putInt("sub_index", value);
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getPreselectColor() {
|
|
||||||
return getArguments().getInt("color_preselect", -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (v.getTag() != null) {
|
|
||||||
final int index = (Integer) v.getTag();
|
|
||||||
if (isInSub()) {
|
|
||||||
setSubIndex(index);
|
|
||||||
} else {
|
|
||||||
setTopIndex(index);
|
|
||||||
setInSub(true);
|
|
||||||
}
|
|
||||||
invalidateGrid();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface ColorCallback {
|
|
||||||
void onColorSelection(@NonNull ColorChooserDialog dialog, @ColorInt int selectedColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setColors() {
|
|
||||||
colorSetWithHeaders = ColorSetWithHeaders.fromBundle(getArguments());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setIndexesFor(@ColorInt int color) {
|
|
||||||
if (getTopIndex() != -1) return;
|
|
||||||
if (color != 0) {
|
|
||||||
for (int i = 0; i < colorSetWithHeaders.colors.length; i++) {
|
|
||||||
for (int z = 0; z < colorSetWithHeaders.colors[i].length; z++) {
|
|
||||||
if (color == colorSetWithHeaders.colors[i][z]) {
|
|
||||||
setTopIndex(i);
|
|
||||||
setSubIndex(z);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTitleRes() {
|
|
||||||
return getArguments().getInt("title", 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
|
||||||
setColors();
|
|
||||||
setIndexesFor(getPreselectColor());
|
|
||||||
|
|
||||||
final DisplayMetrics dm = getResources().getDisplayMetrics();
|
|
||||||
mCircleSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 56, dm);
|
|
||||||
mGrid = new GridView(getContext());
|
|
||||||
mGrid.setLayoutParams(new ViewGroup.LayoutParams(
|
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
|
||||||
mGrid.setColumnWidth(mCircleSize);
|
|
||||||
mGrid.setNumColumns(GridView.AUTO_FIT);
|
|
||||||
|
|
||||||
final int eightDp = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, dm);
|
|
||||||
mGrid.setVerticalSpacing(eightDp);
|
|
||||||
mGrid.setHorizontalSpacing(eightDp);
|
|
||||||
|
|
||||||
final int sixteenDp = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, dm);
|
|
||||||
mGrid.setPadding(sixteenDp, sixteenDp, sixteenDp, sixteenDp);
|
|
||||||
mGrid.setClipToPadding(false);
|
|
||||||
mGrid.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
|
|
||||||
mGrid.setGravity(Gravity.CENTER);
|
|
||||||
|
|
||||||
MaterialDialog dialog = new MaterialDialog.Builder(getActivity())
|
|
||||||
.title(getTitleRes())
|
|
||||||
.autoDismiss(false)
|
|
||||||
.customView(mGrid, false)
|
|
||||||
.positiveText(R.string.select)
|
|
||||||
.callback(new MaterialDialog.ButtonCallback() {
|
|
||||||
@Override
|
|
||||||
public void onPositive(MaterialDialog dialog) {
|
|
||||||
super.onPositive(dialog);
|
|
||||||
mCallback.onColorSelection(ColorChooserDialog.this, getSelectedColor());
|
|
||||||
dismiss();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNeutral(MaterialDialog dialog) {
|
|
||||||
super.onNeutral(dialog);
|
|
||||||
setInSub(false);
|
|
||||||
invalidateGrid();
|
|
||||||
}
|
|
||||||
}).build();
|
|
||||||
invalidateGrid();
|
|
||||||
if (isInSub()) {
|
|
||||||
dialog.setActionButton(DialogAction.NEUTRAL, R.string.back);
|
|
||||||
}
|
|
||||||
return dialog;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ColorInt
|
|
||||||
private int getSelectedColor() {
|
|
||||||
int selectedColor = 0;
|
|
||||||
int topIndex = getTopIndex();
|
|
||||||
int subIndex = getSubIndex();
|
|
||||||
if (topIndex != -1 && subIndex != -1) {
|
|
||||||
selectedColor = colorSetWithHeaders.colors[topIndex][subIndex];
|
|
||||||
}
|
|
||||||
return selectedColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void invalidateGrid() {
|
|
||||||
if (mGrid.getAdapter() == null) {
|
|
||||||
mGrid.setAdapter(new ColorGridAdapter());
|
|
||||||
} else {
|
|
||||||
((BaseAdapter) mGrid.getAdapter()).notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ColorGridAdapter extends BaseAdapter {
|
|
||||||
|
|
||||||
public ColorGridAdapter() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getCount() {
|
|
||||||
if (isInSub()) {
|
|
||||||
return colorSetWithHeaders.colors[getTopIndex()].length;
|
|
||||||
} else {
|
|
||||||
return colorSetWithHeaders.colors.length;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getItem(int position) {
|
|
||||||
if (isInSub()) {
|
|
||||||
return colorSetWithHeaders.colors[getTopIndex()][position];
|
|
||||||
} else {
|
|
||||||
return colorSetWithHeaders.colors[position][colorSetWithHeaders.headerColorIndexes[position]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getItemId(int position) {
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
|
||||||
if (convertView == null) {
|
|
||||||
convertView = new SelectableColorView(getContext());
|
|
||||||
convertView.setLayoutParams(new GridView.LayoutParams(mCircleSize, mCircleSize));
|
|
||||||
}
|
|
||||||
SelectableColorView child = (SelectableColorView) convertView;
|
|
||||||
if (isInSub()) {
|
|
||||||
child.setColor(colorSetWithHeaders.colors[getTopIndex()][position]);
|
|
||||||
child.setSelected(getSubIndex() == position);
|
|
||||||
} else {
|
|
||||||
child.setColor(colorSetWithHeaders.colors[position][colorSetWithHeaders.headerColorIndexes[position]]);
|
|
||||||
child.setSelected(getTopIndex() == position);
|
|
||||||
}
|
|
||||||
child.setTag(position);
|
|
||||||
child.setOnClickListener(ColorChooserDialog.this);
|
|
||||||
return convertView;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ColorChooserDialog create(@StringRes int title, @NonNull ColorSetWithHeaders colorSetWithHeaders, @ColorInt int preselectColor) {
|
|
||||||
ColorChooserDialog dialog = new ColorChooserDialog();
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putInt("title", title);
|
|
||||||
args.putInt("color_preselect", preselectColor);
|
|
||||||
|
|
||||||
ColorSetWithHeaders.toBundle(colorSetWithHeaders, args);
|
|
||||||
|
|
||||||
dialog.setArguments(args);
|
|
||||||
return dialog;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final class ColorSetWithHeaders {
|
|
||||||
final int[] headerColorIndexes;
|
|
||||||
final int[][] colors;
|
|
||||||
|
|
||||||
public ColorSetWithHeaders(int[] headerColorIndexes, int[][] colors) {
|
|
||||||
if (headerColorIndexes.length != colors.length) {
|
|
||||||
throw new IllegalArgumentException("int[] headerColorIndexes and int[][] colors must have the same length");
|
|
||||||
}
|
|
||||||
this.headerColorIndexes = headerColorIndexes;
|
|
||||||
this.colors = colors;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void toBundle(ColorSetWithHeaders colorSetWithHeaders, Bundle bundle) {
|
|
||||||
bundle.putIntArray("top_colors", colorSetWithHeaders.headerColorIndexes);
|
|
||||||
for (int i = 0; i < colorSetWithHeaders.colors.length; i++) {
|
|
||||||
bundle.putIntArray("sub_colors_" + i, colorSetWithHeaders.colors[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorSetWithHeaders fromBundle(Bundle bundle) {
|
|
||||||
int[] headerColorIndexes = bundle.getIntArray("top_colors");
|
|
||||||
if (headerColorIndexes == null)
|
|
||||||
return new ColorSetWithHeaders(new int[]{}, new int[][]{});
|
|
||||||
int[][] colors = new int[headerColorIndexes.length][];
|
|
||||||
for (int i = 0; i < colors.length; i++) {
|
|
||||||
colors[i] = bundle.getIntArray("sub_colors_" + i);
|
|
||||||
}
|
|
||||||
return new ColorSetWithHeaders(headerColorIndexes, colors);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,389 +0,0 @@
|
||||||
package com.kabouzeid.gramophone.helper;
|
|
||||||
|
|
||||||
import android.graphics.Color;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Karim Abou Zeid (kabouzeid)
|
|
||||||
*/
|
|
||||||
public class ColorPalette {
|
|
||||||
public static int[] MAIN_PRIMARY_COLOR_INDEXES = new int[]{
|
|
||||||
5,
|
|
||||||
5,
|
|
||||||
5,
|
|
||||||
5,
|
|
||||||
5,
|
|
||||||
5,
|
|
||||||
5,
|
|
||||||
5,
|
|
||||||
5,
|
|
||||||
5,
|
|
||||||
5,
|
|
||||||
5,
|
|
||||||
5,
|
|
||||||
5,
|
|
||||||
5,
|
|
||||||
5,
|
|
||||||
5,
|
|
||||||
6,
|
|
||||||
5
|
|
||||||
};
|
|
||||||
|
|
||||||
public static int[][] PRIMARY_COLORS = new int[][]{
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#FFEBEE"),
|
|
||||||
Color.parseColor("#FFCDD2"),
|
|
||||||
Color.parseColor("#EF9A9A"),
|
|
||||||
Color.parseColor("#E57373"),
|
|
||||||
Color.parseColor("#EF5350"),
|
|
||||||
Color.parseColor("#F44336"),
|
|
||||||
Color.parseColor("#E53935"),
|
|
||||||
Color.parseColor("#D32F2F"),
|
|
||||||
Color.parseColor("#C62828"),
|
|
||||||
Color.parseColor("#B71C1C")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#FCE4EC"),
|
|
||||||
Color.parseColor("#F8BBD0"),
|
|
||||||
Color.parseColor("#F48FB1"),
|
|
||||||
Color.parseColor("#F06292"),
|
|
||||||
Color.parseColor("#EC407A"),
|
|
||||||
Color.parseColor("#E91E63"),
|
|
||||||
Color.parseColor("#D81B60"),
|
|
||||||
Color.parseColor("#C2185B"),
|
|
||||||
Color.parseColor("#AD1457"),
|
|
||||||
Color.parseColor("#880E4F")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#F3E5F5"),
|
|
||||||
Color.parseColor("#E1BEE7"),
|
|
||||||
Color.parseColor("#CE93D8"),
|
|
||||||
Color.parseColor("#BA68C8"),
|
|
||||||
Color.parseColor("#AB47BC"),
|
|
||||||
Color.parseColor("#9C27B0"),
|
|
||||||
Color.parseColor("#8E24AA"),
|
|
||||||
Color.parseColor("#7B1FA2"),
|
|
||||||
Color.parseColor("#6A1B9A"),
|
|
||||||
Color.parseColor("#4A148C")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#EDE7F6"),
|
|
||||||
Color.parseColor("#D1C4E9"),
|
|
||||||
Color.parseColor("#B39DDB"),
|
|
||||||
Color.parseColor("#9575CD"),
|
|
||||||
Color.parseColor("#7E57C2"),
|
|
||||||
Color.parseColor("#673AB7"),
|
|
||||||
Color.parseColor("#5E35B1"),
|
|
||||||
Color.parseColor("#512DA8"),
|
|
||||||
Color.parseColor("#4527A0"),
|
|
||||||
Color.parseColor("#311B92")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#E8EAF6"),
|
|
||||||
Color.parseColor("#C5CAE9"),
|
|
||||||
Color.parseColor("#9FA8DA"),
|
|
||||||
Color.parseColor("#7986CB"),
|
|
||||||
Color.parseColor("#5C6BC0"),
|
|
||||||
Color.parseColor("#3F51B5"),
|
|
||||||
Color.parseColor("#3949AB"),
|
|
||||||
Color.parseColor("#303F9F"),
|
|
||||||
Color.parseColor("#283593"),
|
|
||||||
Color.parseColor("#1A237E")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#E3F2FD"),
|
|
||||||
Color.parseColor("#BBDEFB"),
|
|
||||||
Color.parseColor("#90CAF9"),
|
|
||||||
Color.parseColor("#64B5F6"),
|
|
||||||
Color.parseColor("#42A5F5"),
|
|
||||||
Color.parseColor("#2196F3"),
|
|
||||||
Color.parseColor("#1E88E5"),
|
|
||||||
Color.parseColor("#1976D2"),
|
|
||||||
Color.parseColor("#1565C0"),
|
|
||||||
Color.parseColor("#0D47A1")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#E1F5FE"),
|
|
||||||
Color.parseColor("#B3E5FC"),
|
|
||||||
Color.parseColor("#81D4FA"),
|
|
||||||
Color.parseColor("#4FC3F7"),
|
|
||||||
Color.parseColor("#29B6F6"),
|
|
||||||
Color.parseColor("#03A9F4"),
|
|
||||||
Color.parseColor("#039BE5"),
|
|
||||||
Color.parseColor("#0288D1"),
|
|
||||||
Color.parseColor("#0277BD"),
|
|
||||||
Color.parseColor("#01579B")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#E0F7FA"),
|
|
||||||
Color.parseColor("#B2EBF2"),
|
|
||||||
Color.parseColor("#80DEEA"),
|
|
||||||
Color.parseColor("#4DD0E1"),
|
|
||||||
Color.parseColor("#26C6DA"),
|
|
||||||
Color.parseColor("#00BCD4"),
|
|
||||||
Color.parseColor("#00ACC1"),
|
|
||||||
Color.parseColor("#0097A7"),
|
|
||||||
Color.parseColor("#00838F"),
|
|
||||||
Color.parseColor("#006064")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#E0F2F1"),
|
|
||||||
Color.parseColor("#B2DFDB"),
|
|
||||||
Color.parseColor("#80CBC4"),
|
|
||||||
Color.parseColor("#4DB6AC"),
|
|
||||||
Color.parseColor("#26A69A"),
|
|
||||||
Color.parseColor("#009688"),
|
|
||||||
Color.parseColor("#00897B"),
|
|
||||||
Color.parseColor("#00796B"),
|
|
||||||
Color.parseColor("#00695C"),
|
|
||||||
Color.parseColor("#004D40")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#E8F5E9"),
|
|
||||||
Color.parseColor("#C8E6C9"),
|
|
||||||
Color.parseColor("#A5D6A7"),
|
|
||||||
Color.parseColor("#81C784"),
|
|
||||||
Color.parseColor("#66BB6A"),
|
|
||||||
Color.parseColor("#4CAF50"),
|
|
||||||
Color.parseColor("#43A047"),
|
|
||||||
Color.parseColor("#388E3C"),
|
|
||||||
Color.parseColor("#2E7D32"),
|
|
||||||
Color.parseColor("#1B5E20")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#F1F8E9"),
|
|
||||||
Color.parseColor("#DCEDC8"),
|
|
||||||
Color.parseColor("#C5E1A5"),
|
|
||||||
Color.parseColor("#AED581"),
|
|
||||||
Color.parseColor("#9CCC65"),
|
|
||||||
Color.parseColor("#8BC34A"),
|
|
||||||
Color.parseColor("#7CB342"),
|
|
||||||
Color.parseColor("#689F38"),
|
|
||||||
Color.parseColor("#558B2F"),
|
|
||||||
Color.parseColor("#33691E")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#F9FBE7"),
|
|
||||||
Color.parseColor("#F0F4C3"),
|
|
||||||
Color.parseColor("#E6EE9C"),
|
|
||||||
Color.parseColor("#DCE775"),
|
|
||||||
Color.parseColor("#D4E157"),
|
|
||||||
Color.parseColor("#CDDC39"),
|
|
||||||
Color.parseColor("#C0CA33"),
|
|
||||||
Color.parseColor("#AFB42B"),
|
|
||||||
Color.parseColor("#9E9D24"),
|
|
||||||
Color.parseColor("#827717")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#FFFDE7"),
|
|
||||||
Color.parseColor("#FFF9C4"),
|
|
||||||
Color.parseColor("#FFF59D"),
|
|
||||||
Color.parseColor("#FFF176"),
|
|
||||||
Color.parseColor("#FFEE58"),
|
|
||||||
Color.parseColor("#FFEB3B"),
|
|
||||||
Color.parseColor("#FDD835"),
|
|
||||||
Color.parseColor("#FBC02D"),
|
|
||||||
Color.parseColor("#F9A825"),
|
|
||||||
Color.parseColor("#F57F17")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#FFF8E1"),
|
|
||||||
Color.parseColor("#FFECB3"),
|
|
||||||
Color.parseColor("#FFE082"),
|
|
||||||
Color.parseColor("#FFD54F"),
|
|
||||||
Color.parseColor("#FFCA28"),
|
|
||||||
Color.parseColor("#FFC107"),
|
|
||||||
Color.parseColor("#FFB300"),
|
|
||||||
Color.parseColor("#FFA000"),
|
|
||||||
Color.parseColor("#FF8F00"),
|
|
||||||
Color.parseColor("#FF6F00")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#FFF3E0"),
|
|
||||||
Color.parseColor("#FFE0B2"),
|
|
||||||
Color.parseColor("#FFCC80"),
|
|
||||||
Color.parseColor("#FFB74D"),
|
|
||||||
Color.parseColor("#FFA726"),
|
|
||||||
Color.parseColor("#FF9800"),
|
|
||||||
Color.parseColor("#FB8C00"),
|
|
||||||
Color.parseColor("#F57C00"),
|
|
||||||
Color.parseColor("#EF6C00"),
|
|
||||||
Color.parseColor("#E65100")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#FBE9E7"),
|
|
||||||
Color.parseColor("#FFCCBC"),
|
|
||||||
Color.parseColor("#FFAB91"),
|
|
||||||
Color.parseColor("#FF8A65"),
|
|
||||||
Color.parseColor("#FF7043"),
|
|
||||||
Color.parseColor("#FF5722"),
|
|
||||||
Color.parseColor("#F4511E"),
|
|
||||||
Color.parseColor("#E64A19"),
|
|
||||||
Color.parseColor("#D84315"),
|
|
||||||
Color.parseColor("#BF360C")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#EFEBE9"),
|
|
||||||
Color.parseColor("#D7CCC8"),
|
|
||||||
Color.parseColor("#BCAAA4"),
|
|
||||||
Color.parseColor("#A1887F"),
|
|
||||||
Color.parseColor("#8D6E63"),
|
|
||||||
Color.parseColor("#795548"),
|
|
||||||
Color.parseColor("#6D4C41"),
|
|
||||||
Color.parseColor("#5D4037"),
|
|
||||||
Color.parseColor("#4E342E"),
|
|
||||||
Color.parseColor("#3E2723")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#FFFFFF"), // not in the original palette
|
|
||||||
Color.parseColor("#FAFAFA"),
|
|
||||||
Color.parseColor("#F5F5F5"),
|
|
||||||
Color.parseColor("#EEEEEE"),
|
|
||||||
Color.parseColor("#E0E0E0"),
|
|
||||||
Color.parseColor("#BDBDBD"),
|
|
||||||
Color.parseColor("#9E9E9E"),
|
|
||||||
Color.parseColor("#757575"),
|
|
||||||
Color.parseColor("#616161"),
|
|
||||||
Color.parseColor("#424242"),
|
|
||||||
Color.parseColor("#212121"),
|
|
||||||
Color.parseColor("#000000") // not in the original palette
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#ECEFF1"),
|
|
||||||
Color.parseColor("#CFD8DC"),
|
|
||||||
Color.parseColor("#B0BEC5"),
|
|
||||||
Color.parseColor("#90A4AE"),
|
|
||||||
Color.parseColor("#78909C"),
|
|
||||||
Color.parseColor("#607D8B"),
|
|
||||||
Color.parseColor("#546E7A"),
|
|
||||||
Color.parseColor("#455A64"),
|
|
||||||
Color.parseColor("#37474F"),
|
|
||||||
Color.parseColor("#263238")
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public static int[] MAIN_ACCENT_COLOR_INDEXES = new int[]{
|
|
||||||
2,
|
|
||||||
1,
|
|
||||||
2,
|
|
||||||
2,
|
|
||||||
2,
|
|
||||||
2,
|
|
||||||
2,
|
|
||||||
2,
|
|
||||||
2,
|
|
||||||
2,
|
|
||||||
2,
|
|
||||||
2,
|
|
||||||
2,
|
|
||||||
2,
|
|
||||||
2,
|
|
||||||
2,
|
|
||||||
2
|
|
||||||
};
|
|
||||||
|
|
||||||
public static int[][] ACCENT_COLORS = new int[][]{
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#ff8a80"),
|
|
||||||
Color.parseColor("#ff5252"),
|
|
||||||
Color.parseColor("#ff1744"),
|
|
||||||
Color.parseColor("#d50000")
|
|
||||||
},
|
|
||||||
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#ff80ab"),
|
|
||||||
Color.parseColor("#ff4081"),
|
|
||||||
Color.parseColor("#f50057"),
|
|
||||||
Color.parseColor("#c51162")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#ea80fc"),
|
|
||||||
Color.parseColor("#e040fb"),
|
|
||||||
Color.parseColor("#d500f9"),
|
|
||||||
Color.parseColor("#aa00ff")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#b388ff"),
|
|
||||||
Color.parseColor("#7c4dff"),
|
|
||||||
Color.parseColor("#651fff"),
|
|
||||||
Color.parseColor("#6200ea")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#8c9eff"),
|
|
||||||
Color.parseColor("#536dfe"),
|
|
||||||
Color.parseColor("#3d5afe"),
|
|
||||||
Color.parseColor("#304ffe")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#82b1ff"),
|
|
||||||
Color.parseColor("#448aff"),
|
|
||||||
Color.parseColor("#2979ff"),
|
|
||||||
Color.parseColor("#2962ff")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#80d8ff"),
|
|
||||||
Color.parseColor("#40c4ff"),
|
|
||||||
Color.parseColor("#00b0ff"),
|
|
||||||
Color.parseColor("#0091ea")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#84ffff"),
|
|
||||||
Color.parseColor("#18ffff"),
|
|
||||||
Color.parseColor("#00e5ff"),
|
|
||||||
Color.parseColor("#00b8d4")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#a7ffeb"),
|
|
||||||
Color.parseColor("#64ffda"),
|
|
||||||
Color.parseColor("#1de9b6"),
|
|
||||||
Color.parseColor("#00bfa5")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#b9f6ca"),
|
|
||||||
Color.parseColor("#69f0ae"),
|
|
||||||
Color.parseColor("#00e676"),
|
|
||||||
Color.parseColor("#00c853")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#ccff90"),
|
|
||||||
Color.parseColor("#b2ff59"),
|
|
||||||
Color.parseColor("#76ff03"),
|
|
||||||
Color.parseColor("#64dd17")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#f4ff81"),
|
|
||||||
Color.parseColor("#eeff41"),
|
|
||||||
Color.parseColor("#c6ff00"),
|
|
||||||
Color.parseColor("#aeea00")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#ffff8d"),
|
|
||||||
Color.parseColor("#ffff00"),
|
|
||||||
Color.parseColor("#ffea00"),
|
|
||||||
Color.parseColor("#ffd600")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#ffe57f"),
|
|
||||||
Color.parseColor("#ffd740"),
|
|
||||||
Color.parseColor("#ffc400"),
|
|
||||||
Color.parseColor("#ffab00")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#ffd180"),
|
|
||||||
Color.parseColor("#ffab40"),
|
|
||||||
Color.parseColor("#ff9100"),
|
|
||||||
Color.parseColor("#ff6d00")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#ff9e80"),
|
|
||||||
Color.parseColor("#ff6e40"),
|
|
||||||
Color.parseColor("#ff3d00"),
|
|
||||||
Color.parseColor("#dd2c00")
|
|
||||||
},
|
|
||||||
new int[]{
|
|
||||||
Color.parseColor("#FFFFFF"), // not in the original palette
|
|
||||||
Color.parseColor("#9E9E9E"), // not in the original palette
|
|
||||||
Color.parseColor("#424242"), // not in the original palette
|
|
||||||
Color.parseColor("#000000") // not in the original palette
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -18,12 +18,10 @@ import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
import com.afollestad.materialdialogs.color.ColorChooserDialog;
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
import com.kabouzeid.gramophone.dialogs.ColorChooserDialog;
|
|
||||||
import com.kabouzeid.gramophone.helper.ColorPalette;
|
|
||||||
import com.kabouzeid.gramophone.prefs.ColorChooserPreference;
|
import com.kabouzeid.gramophone.prefs.ColorChooserPreference;
|
||||||
import com.kabouzeid.gramophone.ui.activities.base.AbsBaseActivity;
|
import com.kabouzeid.gramophone.ui.activities.base.AbsBaseActivity;
|
||||||
import com.kabouzeid.gramophone.util.ColorUtil;
|
|
||||||
import com.kabouzeid.gramophone.util.NavigationUtil;
|
import com.kabouzeid.gramophone.util.NavigationUtil;
|
||||||
import com.kabouzeid.gramophone.util.PreferenceUtil;
|
import com.kabouzeid.gramophone.util.PreferenceUtil;
|
||||||
import com.kabouzeid.gramophone.util.ViewUtil;
|
import com.kabouzeid.gramophone.util.ViewUtil;
|
||||||
|
|
@ -60,7 +58,7 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onColorSelection(@NonNull ColorChooserDialog dialog, @ColorInt int selectedColor) {
|
public void onColorSelection(@NonNull ColorChooserDialog dialog, @ColorInt int selectedColor) {
|
||||||
switch (dialog.getTitleRes()) {
|
switch (dialog.getTitle()) {
|
||||||
case R.string.primary_color:
|
case R.string.primary_color:
|
||||||
PreferenceUtil.getInstance(this).setThemeColorPrimary(selectedColor);
|
PreferenceUtil.getInstance(this).setThemeColorPrimary(selectedColor);
|
||||||
break;
|
break;
|
||||||
|
|
@ -153,12 +151,11 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
||||||
primaryColor.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
primaryColor.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceClick(@NonNull Preference preference) {
|
public boolean onPreferenceClick(@NonNull Preference preference) {
|
||||||
ColorChooserDialog
|
new ColorChooserDialog.Builder(((SettingsActivity) getActivity()), R.string.primary_color)
|
||||||
.create(preference.getTitleRes(),
|
.accentMode(false)
|
||||||
new ColorChooserDialog.ColorSetWithHeaders(ColorPalette.MAIN_PRIMARY_COLOR_INDEXES, ColorPalette.PRIMARY_COLORS),
|
.allowUserColorInput(true)
|
||||||
PreferenceUtil.getInstance(getActivity()).getThemeColorPrimary(getActivity())
|
.preselect(PreferenceUtil.getInstance(getActivity()).getThemeColorPrimary(getActivity()))
|
||||||
)
|
.show();
|
||||||
.show(((SettingsActivity) getActivity()).getSupportFragmentManager(), "COLOR_CHOOSER");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -168,12 +165,11 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
||||||
accentColor.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
accentColor.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceClick(@NonNull Preference preference) {
|
public boolean onPreferenceClick(@NonNull Preference preference) {
|
||||||
ColorChooserDialog
|
new ColorChooserDialog.Builder(((SettingsActivity) getActivity()), R.string.accent_color)
|
||||||
.create(preference.getTitleRes(),
|
.accentMode(true)
|
||||||
new ColorChooserDialog.ColorSetWithHeaders(ColorPalette.MAIN_ACCENT_COLOR_INDEXES, ColorPalette.ACCENT_COLORS),
|
.allowUserColorInput(true)
|
||||||
PreferenceUtil.getInstance(getActivity()).getThemeColorAccent(getActivity())
|
.preselect(PreferenceUtil.getInstance(getActivity()).getThemeColorAccent(getActivity()))
|
||||||
)
|
.show();
|
||||||
.show(((SettingsActivity) getActivity()).getSupportFragmentManager(), "COLOR_CHOOSER");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,7 @@ public final class PreferenceUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getThemeColorAccent(Context context) {
|
public int getThemeColorAccent(Context context) {
|
||||||
return mPreferences.getInt("accent_color", ContextCompat.getColor(context, R.color.pink_A200));
|
return mPreferences.getInt("accent_color", ContextCompat.getColor(context, R.color.pink_A400));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("CommitPrefEdits")
|
@SuppressLint("CommitPrefEdits")
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<color name="pink_A200">#ff4081</color>
|
<color name="pink_A400">#F50057</color>
|
||||||
<color name="indigo_500">#3f51b5</color>
|
<color name="indigo_500">#3F51B5</color>
|
||||||
|
|
||||||
<color name="grey_700">#616161</color>
|
<color name="grey_700">#616161</color>
|
||||||
<color name="grey_900">#212121</color>
|
<color name="grey_900">#212121</color>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue