Commit f85cfd7a authored by Donald's avatar Donald

color pickers clean

parent 404aac5f
......@@ -82,7 +82,7 @@ public class SettingsActivity extends ThemedActivity {
findViewById(R.id.ll_basic_theme).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new ColorsSetting(SettingsActivity.this, SP).choseBaseTheme();
new ColorsSetting(SettingsActivity.this, SP).chooseBaseTheme();
}
});
......@@ -108,7 +108,23 @@ public class SettingsActivity extends ThemedActivity {
findViewById(R.id.ll_primaryColor).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new ColorsSetting(SP).chosePrimaryColor(SettingsActivity.this);
new ColorsSetting(SettingsActivity.this, SP).chooseColor(R.string.primary_color, new ColorsSetting.ColorChooser() {
@Override
public void onColorSelected(int color) {
SP.putInt(getString(R.string.preference_primary_color), color);
//updateViewsWithAccentColor(color);
}
@Override
public void onDialogDismiss() {
updateViewsWithPrimaryColor(getPrimaryColor());
}
@Override
public void onColorChanged(int color) {
updateViewsWithPrimaryColor(color);
}
}, getPrimaryColor());
}
});
......@@ -116,7 +132,23 @@ public class SettingsActivity extends ThemedActivity {
findViewById(R.id.ll_accentColor).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new ColorsSetting(SP).choseAccentColor(SettingsActivity.this);
new ColorsSetting(SettingsActivity.this, SP).chooseColor(R.string.accent_color, new ColorsSetting.ColorChooser() {
@Override
public void onColorSelected(int color) {
SP.putInt(getString(R.string.preference_accent_color), color);
//updateViewsWithAccentColor(color);
}
@Override
public void onDialogDismiss() {
updateViewsWithAccentColor(getAccentColor());
}
@Override
public void onColorChanged(int color) {
updateViewsWithAccentColor(color);
}
}, getAccentColor());
}
});
......
package org.horaapps.leafpic.settings;
import android.content.DialogInterface;
import android.support.annotation.StringRes;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.CardView;
import android.view.LayoutInflater;
......@@ -8,7 +9,6 @@ import android.view.View;
import android.widget.TextView;
import org.horaapps.leafpic.R;
import org.horaapps.leafpic.activities.SettingsActivity;
import org.horaapps.leafpic.activities.base.ThemedActivity;
import org.horaapps.leafpic.util.ColorPalette;
import org.horaapps.leafpic.util.PreferenceUtil;
......@@ -30,14 +30,10 @@ public class ColorsSetting extends ThemedSetting {
super(activity, SP);
}
public ColorsSetting(PreferenceUtil SP) {
super(SP);
}
public void choseBaseTheme() {
public void chooseBaseTheme() {
final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), getActivity().getDialogStyle());
final View dialogLayout = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_basic_theme, null);
final View dialogLayout = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_base_theme, null);
final TextView dialogTitle = (TextView) dialogLayout.findViewById(R.id.basic_theme_title);
final CardView dialogCardView = (CardView) dialogLayout.findViewById(R.id.basic_theme_card);
......@@ -70,116 +66,74 @@ public class ColorsSetting extends ThemedSetting {
dialogLayout.findViewById(R.id.ll_dark_amoled_basic_theme).setOnClickListener(listener);
}
public void chosePrimaryColor(final SettingsActivity activity) {
final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(activity, activity.getDialogStyle());
public interface ColorChooser {
void onColorSelected(int color);
void onDialogDismiss();
void onColorChanged(int color);
}
public void chooseColor(@StringRes int title, final ColorChooser chooser, int defaultColor) {
final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), getActivity().getDialogStyle());
final View dialogLayout = LayoutInflater.from(activity).inflate(R.layout.color_piker_primary, null);
View dialogLayout = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_color_picker, null);
final LineColorPicker colorPicker = (LineColorPicker) dialogLayout.findViewById(R.id.color_picker_primary);
final LineColorPicker colorPicker2 = (LineColorPicker) dialogLayout.findViewById(R.id.color_picker_primary_2);
final TextView dialogTitle = (TextView) dialogLayout.findViewById(R.id.cp_primary_title);
CardView dialogCardView = (CardView) dialogLayout.findViewById(R.id.cp_primary_card);
dialogCardView.setCardBackgroundColor(activity.getCardBackgroundColor());
colorPicker.setColors(ColorPalette.getBaseColors(activity));
for (int i : colorPicker.getColors())
for (int i2 : ColorPalette.getColors(activity, i))
if (i2 == activity.getPrimaryColor()) {
colorPicker.setSelectedColor(i);
colorPicker2.setColors(ColorPalette.getColors(activity, i));
colorPicker2.setSelectedColor(i2);
break;
}
dialogTitle.setBackgroundColor(activity.getPrimaryColor());
final TextView dialogTitle = (TextView) dialogLayout.findViewById(R.id.dialog_title);
dialogTitle.setText(title);
((CardView) dialogLayout.findViewById(R.id.dialog_card)).setCardBackgroundColor(getActivity().getCardBackgroundColor());
colorPicker2.setOnColorChangedListener(new OnColorChangedListener() {
@Override
public void onColorChanged(int c) {
activity.updateViewsWithPrimaryColor(c);
dialogTitle.setBackgroundColor(c);
chooser.onColorChanged(c);
}
});
colorPicker.setOnColorChangedListener(new OnColorChangedListener() {
@Override
public void onColorChanged(int c) {
colorPicker2.setColors(ColorPalette.getColors(activity, colorPicker.getColor()));
colorPicker2.setColors(ColorPalette.getColors(getActivity(), colorPicker.getColor()));
colorPicker2.setSelectedColor(colorPicker.getColor());
}
});
int[] baseColors = ColorPalette.getBaseColors(getActivity());
colorPicker.setColors(baseColors);
for (int i : baseColors) {
for (int i2 : ColorPalette.getColors(getActivity(), i))
if (i2 == defaultColor) {
colorPicker.setSelectedColor(i);
colorPicker2.setColors(ColorPalette.getColors(getActivity(), i));
colorPicker2.setSelectedColor(i2);
break;
}
}
dialogBuilder.setView(dialogLayout);
dialogBuilder.setNeutralButton(activity.getString(R.string.cancel).toUpperCase(), new DialogInterface.OnClickListener() {
dialogBuilder.setNegativeButton(getActivity().getString(R.string.cancel).toUpperCase(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
activity.updateViewsWithPrimaryColor(activity.getPrimaryColor());
dialog.cancel();
chooser.onDialogDismiss();
}
});
dialogBuilder.setPositiveButton(activity.getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {
dialogBuilder.setPositiveButton(getActivity().getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
getSP().putInt(activity.getString(R.string.preference_primary_color), colorPicker2.getColor());
activity.updateTheme();
activity.updateViewsWithPrimaryColor(activity.getPrimaryColor());
chooser.onColorSelected(colorPicker2.getColor());
}
});
dialogBuilder.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
activity.updateViewsWithPrimaryColor(activity.getPrimaryColor());
chooser.onDialogDismiss();
}
});
dialogBuilder.show();
}
public void choseAccentColor(final SettingsActivity activity) {
final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(activity, activity.getDialogStyle());
final View dialogLayout = LayoutInflater.from(activity).inflate(R.layout.color_piker_accent, null);
final LineColorPicker colorPicker = (LineColorPicker) dialogLayout.findViewById(R.id.color_picker_accent);
final TextView dialogTitle = (TextView) dialogLayout.findViewById(R.id.cp_accent_title);
CardView cv = (CardView) dialogLayout.findViewById(R.id.cp_accent_card);
cv.setCardBackgroundColor(activity.getCardBackgroundColor());
colorPicker.setColors(ColorPalette.getAccentColors(activity.getApplicationContext()));
colorPicker.setSelectedColor(activity.getAccentColor());
dialogTitle.setBackgroundColor(activity.getAccentColor());
colorPicker.setOnColorChangedListener(new OnColorChangedListener() {
@Override
public void onColorChanged(int c) {
dialogTitle.setBackgroundColor(c);
// TODO: 12/9/16 callback
activity.updateViewsWithAccentColor(colorPicker.getColor());
}
});
dialogBuilder.setView(dialogLayout);
dialogBuilder.setNeutralButton(activity.getString(R.string.cancel).toUpperCase(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
activity.updateViewsWithAccentColor(activity.getAccentColor());
}
});
dialogBuilder.setPositiveButton(activity.getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
getSP().putInt(activity.getString(R.string.preference_accent_color), colorPicker.getColor());
activity.updateTheme();
activity.updateViewsWithAccentColor(activity.getAccentColor());
}
});
dialogBuilder.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
activity.updateViewsWithAccentColor(activity.getAccentColor());
}
});
dialogBuilder.show();
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="2dp"
android:id="@+id/cp_accent_card"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/cp_accent_title"
android:layout_width="match_parent"
android:textColor="@color/md_dark_primary_text"
android:layout_height="wrap_content"
android:background="@color/md_red_500"
android:padding="@dimen/big_spacing"
android:text="@string/accent_color"
android:textSize="18sp"
android:textStyle="bold" />
<RelativeLayout
android:id="@+id/container_edit_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/big_spacing">
<uz.shift.colorpicker.LineColorPicker
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/color_picker_accent"
android:layout_width="match_parent"
android:layout_height="60dp"
app:orientation="horizontal"
app:selectedColorIndex="0" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
</android.support.v7.widget.CardView>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="1dp"
android:id="@+id/cp_primary_card"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/cp_primary_title"
android:layout_width="match_parent"
android:textColor="@color/md_dark_primary_text"
android:layout_height="wrap_content"
android:background="@color/md_red_500"
android:padding="@dimen/big_spacing"
android:text="@string/primary_color"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:id="@+id/container_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/big_spacing">
<uz.shift.colorpicker.LineColorPicker
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/color_picker_primary"
android:layout_width="match_parent"
android:layout_height="60dp"
app:orientation="horizontal"
app:selectedColorIndex="0" />
<uz.shift.colorpicker.LineColorPicker
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/color_picker_primary_2"
android:layout_width="match_parent"
android:layout_height="40dp"
app:orientation="horizontal"
app:selectedColorIndex="0"
android:layout_marginTop="10dp"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</android.support.v7.widget.CardView>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="1dp"
android:id="@+id/dialog_card">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/dialog_title"
android:layout_width="match_parent"
android:textColor="@color/md_dark_primary_text"
android:layout_height="wrap_content"
android:background="@color/md_red_500"
android:padding="@dimen/big_spacing"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:id="@+id/container_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/medium_spacing">
<uz.shift.colorpicker.LineColorPicker
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/color_picker_primary"
android:layout_width="match_parent"
android:layout_height="60dp"
app:orientation="horizontal" />
<uz.shift.colorpicker.LineColorPicker
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/color_picker_primary_2"
android:layout_width="match_parent"
android:layout_height="45dp"
app:orientation="horizontal"
android:layout_marginTop="14dp" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</android.support.v7.widget.CardView>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
android:id="@+id/ll_explorer_dialog_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
>
<TextView
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/md_dark_primary_text"
android:id="@+id/current_path"
android:textSize="18sp"
android:text="/"
android:layout_marginEnd="112dp"
android:layout_marginTop="@dimen/big_spacing"
android:layout_marginBottom="@dimen/big_spacing"
android:layout_marginLeft="@dimen/big_spacing"
android:ellipsize="start"
android:focusable="true"
android:focusableInTouchMode="true"
android:scrollHorizontally="true"
/>
<com.mikepenz.iconics.view.IconicsImageView
android:id="@+id/directory_up"
app:iiv_icon="gmd-keyboard-arrow-up"
android:layout_height="@dimen/icon_width_height"
android:layout_width="@dimen/icon_width_height"
android:hapticFeedbackEnabled="true"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="68dp"
android:layout_marginTop="@dimen/big_spacing"
android:layout_marginBottom="@dimen/big_spacing"
android:layout_marginLeft="@dimen/big_spacing"
app:iiv_color="@color/md_white_1000"
android:clickable="true"
android:background="?attr/selectableItemBackgroundBorderless"
/>
<com.mikepenz.iconics.view.IconicsImageView
android:id="@+id/toggle_create_new_folder_icon"
android:layout_height="@dimen/icon_width_height"
android:layout_width="@dimen/icon_width_height"
android:hapticFeedbackEnabled="true"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:layout_margin="@dimen/big_spacing"
app:iiv_icon="gmd-create-new-folder"
app:iiv_color="@color/md_white_1000"
android:clickable="true"
android:background="?attr/selectableItemBackgroundBorderless"
/>
</RelativeLayout>
<!--NEW FOLDER EDIT TEXT-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/new_folder_layout"
android:visibility="gone"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/md_dark_primary_text"
android:id="@+id/txt_new_folder_description"
android:textSize="@dimen/medium_text"
android:text="@string/new_folder_message"
android:layout_marginTop="@dimen/big_spacing"
android:layout_marginBottom="@dimen/small_spacing"
android:layout_marginLeft="@dimen/big_spacing"
android:layout_marginRight="@dimen/big_spacing"
/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<com.mikepenz.iconics.view.IconicsImageView
android:id="@+id/folder"
android:layout_height="20dp"
android:layout_width="20dp"
android:layout_gravity="center"
app:iiv_icon="gmd-folder"
android:layout_marginRight="@dimen/big_spacing"
android:layout_marginLeft="@dimen/big_spacing"
android:layout_marginTop="@dimen/small_spacing"
android:layout_marginBottom="@dimen/small_spacing"
/>
<EditText
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/folder_name_edit_text"
android:text="folder_name"
android:layout_marginRight="@dimen/big_spacing"
android:layout_marginTop="@dimen/small_spacing"
android:layout_marginBottom="@dimen/small_spacing"
/>
</LinearLayout>
</LinearLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/folder_list"
android:divider="@null"
android:dividerHeight="0dp"
android:scrollbars="vertical"
android:scrollbarThumbVertical="@drawable/ic_scrollbar"
>
</ListView>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!--android:background="@color/toolbar"-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/album_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginBottom="10dp"
android:gravity="center"
android:maxLines="1"
android:textColor="@android:color/white"
android:textSize="30sp"
android:text=""
/>
<View
android:id="@+id/album_card_divider"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@android:color/white"
android:layout_marginStart="30dp"
android:layout_marginEnd="30dp"
/>
<TextView
android:id="@+id/album_photos_count"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center"
android:layout_marginBottom="30dp"
android:maxLines="1"
android:textColor="@android:color/white"
android:textSize="16sp"
android:text=""
/>
</LinearLayout>
</RelativeLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment