Loading QKSMS/src/main/java/com/moez/QKSMS/ui/ThemeManager.java +39 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ import android.graphics.drawable.Drawable; import android.os.Build; import android.preference.PreferenceManager; import android.support.v4.content.ContextCompat; import android.support.v4.view.ViewPager; import android.util.Log; import android.view.LayoutInflater; import android.view.View; Loading @@ -34,9 +35,11 @@ import com.moez.QKSMS.common.utils.ColorUtils; import com.moez.QKSMS.enums.QKPreference; import com.moez.QKSMS.receiver.IconColorReceiver; import com.moez.QKSMS.ui.base.QKActivity; import com.moez.QKSMS.ui.dialog.ColorPickerPagerAdapter; import com.moez.QKSMS.ui.dialog.QKDialog; import com.moez.QKSMS.ui.settings.SettingsFragment; import com.moez.QKSMS.ui.view.QKTextView; import com.moez.QKSMS.ui.view.colorpicker.ColorPickerPalette; import com.moez.QKSMS.ui.widget.WidgetProvider; public class ThemeManager { Loading Loading @@ -480,9 +483,35 @@ public class ThemeManager { private static void showColorPicker(QKActivity context, View.OnClickListener saveListener) { final QKDialog dialog = new QKDialog(); View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_color_picker_rgb, null, false); View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_color_picker_pager, null, false); ColorPickerViewHolder holder = new ColorPickerViewHolder(view); holder.mTab1.setOnClickListener(v -> holder.mPager.setCurrentItem(0)); holder.mTab2.setOnClickListener(v -> holder.mPager.setCurrentItem(1)); ColorPickerPagerAdapter adapter = new ColorPickerPagerAdapter(context); holder.mPager.setAdapter(adapter); holder.mPager.setOffscreenPageLimit(1); holder.mPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @SuppressWarnings("ResourceAsColor") @Override public void onPageSelected(int position) { super.onPageSelected(position); holder.mTab1.setTextColor(position == 0 ? getColor() : getTextOnBackgroundPrimary()); holder.mTab2.setTextColor(position == 1 ? getColor() : getTextOnBackgroundPrimary()); } }); holder.mPalette.init(19, 4, color -> { holder.mPalette.init(getSwatch(color).length, 4, color2 -> { setColor(context, color2); dialog.dismiss(); }); holder.mPalette.drawPalette(getSwatch(color), mColor); }); holder.mPalette.drawPalette(PALETTE, getSwatchColor(mColor)); SeekBar.OnSeekBarChangeListener seekListener = new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { Loading Loading @@ -515,6 +544,11 @@ public class ThemeManager { holder.mRed.getProgressDrawable().setColorFilter(ThemeManager.getColor(), PorterDuff.Mode.MULTIPLY); holder.mGreen.getProgressDrawable().setColorFilter(ThemeManager.getColor(), PorterDuff.Mode.MULTIPLY); holder.mBlue.getProgressDrawable().setColorFilter(ThemeManager.getColor(), PorterDuff.Mode.MULTIPLY); if (holder.mPager.getCurrentItem() == 0) { holder.mTab1.setTextColor(getColor()); } else { holder.mTab2.setTextColor(getColor()); } }); holder.mRed.setThumb(thumbRed); Loading Loading @@ -664,6 +698,10 @@ public class ThemeManager { } static class ColorPickerViewHolder { @Bind(R.id.tab_1) QKTextView mTab1; @Bind(R.id.tab_2) QKTextView mTab2; @Bind(R.id.pager) ViewPager mPager; @Bind(R.id.palette_view) ColorPickerPalette mPalette; @Bind(R.id.preview) View mPreview; @Bind(R.id.red) SeekBar mRed; @Bind(R.id.red_value) QKTextView mRedValue; Loading QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/ColorPickerPagerAdapter.java 0 → 100644 +57 −0 Original line number Diff line number Diff line package com.moez.QKSMS.ui.dialog; import android.support.v4.view.PagerAdapter; import android.view.View; import android.view.ViewGroup; import com.moez.QKSMS.R; import com.moez.QKSMS.ui.base.QKActivity; public class ColorPickerPagerAdapter extends PagerAdapter { private QKActivity mContext; public ColorPickerPagerAdapter(QKActivity context) { mContext = context; } public Object instantiateItem(ViewGroup collection, int position) { int resId = 0; switch (position) { case 0: resId = R.id.palette; break; case 1: resId = R.id.rgb; break; } return collection.findViewById(resId); } @Override public CharSequence getPageTitle(int position) { int resId = 0; switch (position) { case 0: resId = R.string.title_palette; break; case 1: resId = R.string.title_rgb; break; } return mContext.getString(resId); } @Override public int getCount() { return 2; } @Override public boolean isViewFromObject(View arg0, Object arg1) { return arg0 == ((View) arg1); } } QKSMS/src/main/res/layout/dialog_color_picker_pager.xml 0 → 100644 +67 −0 Original line number Diff line number Diff line <?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"> <LinearLayout android:layout_width="match_parent" android:layout_height="48dp" android:paddingLeft="16dp" android:paddingRight="16dp"> <com.moez.QKSMS.ui.view.QKTextView android:id="@+id/tab_1" android:layout_width="wrap_content" android:layout_height="match_parent" android:background="?android:attr/selectableItemBackground" android:gravity="center" android:paddingLeft="16dp" android:paddingRight="16dp" android:text="@string/title_palette" app:type="primary_bold" /> <com.moez.QKSMS.ui.view.QKTextView android:id="@+id/tab_2" android:layout_width="wrap_content" android:layout_height="match_parent" android:background="?android:attr/selectableItemBackground" android:gravity="center" android:paddingLeft="16dp" android:paddingRight="16dp" android:text="@string/title_rgb" app:type="primary_bold" /> </LinearLayout> <android.support.v4.view.ViewPager android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="320dp"> <FrameLayout android:id="@+id/palette" android:layout_width="match_parent" android:layout_height="match_parent"> <com.moez.QKSMS.ui.view.colorpicker.ColorPickerPalette android:id="@+id/palette_view" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" /> </FrameLayout> <FrameLayout android:id="@+id/rgb" android:layout_width="match_parent" android:layout_height="match_parent"> <include layout="@layout/dialog_color_picker_rgb" /> </FrameLayout> </android.support.v4.view.ViewPager> </LinearLayout> No newline at end of file QKSMS/src/main/res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -313,6 +313,8 @@ <string name="title_block_address">Block number</string> <string name="title_unblock_address">Unblock number</string> <string name="title_conversations_selected">%s selected</string> <string name="title_palette">Palette</string> <string name="title_rgb">RGB</string> <!-- Menu shown in the context menu when long pressing on a message when the message contains one or more phone numbers and/or email addresses and the number or email is new to Loading Loading
QKSMS/src/main/java/com/moez/QKSMS/ui/ThemeManager.java +39 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ import android.graphics.drawable.Drawable; import android.os.Build; import android.preference.PreferenceManager; import android.support.v4.content.ContextCompat; import android.support.v4.view.ViewPager; import android.util.Log; import android.view.LayoutInflater; import android.view.View; Loading @@ -34,9 +35,11 @@ import com.moez.QKSMS.common.utils.ColorUtils; import com.moez.QKSMS.enums.QKPreference; import com.moez.QKSMS.receiver.IconColorReceiver; import com.moez.QKSMS.ui.base.QKActivity; import com.moez.QKSMS.ui.dialog.ColorPickerPagerAdapter; import com.moez.QKSMS.ui.dialog.QKDialog; import com.moez.QKSMS.ui.settings.SettingsFragment; import com.moez.QKSMS.ui.view.QKTextView; import com.moez.QKSMS.ui.view.colorpicker.ColorPickerPalette; import com.moez.QKSMS.ui.widget.WidgetProvider; public class ThemeManager { Loading Loading @@ -480,9 +483,35 @@ public class ThemeManager { private static void showColorPicker(QKActivity context, View.OnClickListener saveListener) { final QKDialog dialog = new QKDialog(); View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_color_picker_rgb, null, false); View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_color_picker_pager, null, false); ColorPickerViewHolder holder = new ColorPickerViewHolder(view); holder.mTab1.setOnClickListener(v -> holder.mPager.setCurrentItem(0)); holder.mTab2.setOnClickListener(v -> holder.mPager.setCurrentItem(1)); ColorPickerPagerAdapter adapter = new ColorPickerPagerAdapter(context); holder.mPager.setAdapter(adapter); holder.mPager.setOffscreenPageLimit(1); holder.mPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @SuppressWarnings("ResourceAsColor") @Override public void onPageSelected(int position) { super.onPageSelected(position); holder.mTab1.setTextColor(position == 0 ? getColor() : getTextOnBackgroundPrimary()); holder.mTab2.setTextColor(position == 1 ? getColor() : getTextOnBackgroundPrimary()); } }); holder.mPalette.init(19, 4, color -> { holder.mPalette.init(getSwatch(color).length, 4, color2 -> { setColor(context, color2); dialog.dismiss(); }); holder.mPalette.drawPalette(getSwatch(color), mColor); }); holder.mPalette.drawPalette(PALETTE, getSwatchColor(mColor)); SeekBar.OnSeekBarChangeListener seekListener = new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { Loading Loading @@ -515,6 +544,11 @@ public class ThemeManager { holder.mRed.getProgressDrawable().setColorFilter(ThemeManager.getColor(), PorterDuff.Mode.MULTIPLY); holder.mGreen.getProgressDrawable().setColorFilter(ThemeManager.getColor(), PorterDuff.Mode.MULTIPLY); holder.mBlue.getProgressDrawable().setColorFilter(ThemeManager.getColor(), PorterDuff.Mode.MULTIPLY); if (holder.mPager.getCurrentItem() == 0) { holder.mTab1.setTextColor(getColor()); } else { holder.mTab2.setTextColor(getColor()); } }); holder.mRed.setThumb(thumbRed); Loading Loading @@ -664,6 +698,10 @@ public class ThemeManager { } static class ColorPickerViewHolder { @Bind(R.id.tab_1) QKTextView mTab1; @Bind(R.id.tab_2) QKTextView mTab2; @Bind(R.id.pager) ViewPager mPager; @Bind(R.id.palette_view) ColorPickerPalette mPalette; @Bind(R.id.preview) View mPreview; @Bind(R.id.red) SeekBar mRed; @Bind(R.id.red_value) QKTextView mRedValue; Loading
QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/ColorPickerPagerAdapter.java 0 → 100644 +57 −0 Original line number Diff line number Diff line package com.moez.QKSMS.ui.dialog; import android.support.v4.view.PagerAdapter; import android.view.View; import android.view.ViewGroup; import com.moez.QKSMS.R; import com.moez.QKSMS.ui.base.QKActivity; public class ColorPickerPagerAdapter extends PagerAdapter { private QKActivity mContext; public ColorPickerPagerAdapter(QKActivity context) { mContext = context; } public Object instantiateItem(ViewGroup collection, int position) { int resId = 0; switch (position) { case 0: resId = R.id.palette; break; case 1: resId = R.id.rgb; break; } return collection.findViewById(resId); } @Override public CharSequence getPageTitle(int position) { int resId = 0; switch (position) { case 0: resId = R.string.title_palette; break; case 1: resId = R.string.title_rgb; break; } return mContext.getString(resId); } @Override public int getCount() { return 2; } @Override public boolean isViewFromObject(View arg0, Object arg1) { return arg0 == ((View) arg1); } }
QKSMS/src/main/res/layout/dialog_color_picker_pager.xml 0 → 100644 +67 −0 Original line number Diff line number Diff line <?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"> <LinearLayout android:layout_width="match_parent" android:layout_height="48dp" android:paddingLeft="16dp" android:paddingRight="16dp"> <com.moez.QKSMS.ui.view.QKTextView android:id="@+id/tab_1" android:layout_width="wrap_content" android:layout_height="match_parent" android:background="?android:attr/selectableItemBackground" android:gravity="center" android:paddingLeft="16dp" android:paddingRight="16dp" android:text="@string/title_palette" app:type="primary_bold" /> <com.moez.QKSMS.ui.view.QKTextView android:id="@+id/tab_2" android:layout_width="wrap_content" android:layout_height="match_parent" android:background="?android:attr/selectableItemBackground" android:gravity="center" android:paddingLeft="16dp" android:paddingRight="16dp" android:text="@string/title_rgb" app:type="primary_bold" /> </LinearLayout> <android.support.v4.view.ViewPager android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="320dp"> <FrameLayout android:id="@+id/palette" android:layout_width="match_parent" android:layout_height="match_parent"> <com.moez.QKSMS.ui.view.colorpicker.ColorPickerPalette android:id="@+id/palette_view" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" /> </FrameLayout> <FrameLayout android:id="@+id/rgb" android:layout_width="match_parent" android:layout_height="match_parent"> <include layout="@layout/dialog_color_picker_rgb" /> </FrameLayout> </android.support.v4.view.ViewPager> </LinearLayout> No newline at end of file
QKSMS/src/main/res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -313,6 +313,8 @@ <string name="title_block_address">Block number</string> <string name="title_unblock_address">Unblock number</string> <string name="title_conversations_selected">%s selected</string> <string name="title_palette">Palette</string> <string name="title_rgb">RGB</string> <!-- Menu shown in the context menu when long pressing on a message when the message contains one or more phone numbers and/or email addresses and the number or email is new to Loading