mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-18 11:58:52 +01:00
Added view to display hex code and edit manually
This commit is contained in:
@@ -24,6 +24,8 @@ import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.SeekBar;
|
||||
import butterknife.Bind;
|
||||
@@ -34,12 +36,14 @@ import com.moez.QKSMS.common.CIELChEvaluator;
|
||||
import com.moez.QKSMS.common.ConversationPrefsHelper;
|
||||
import com.moez.QKSMS.common.LiveViewManager;
|
||||
import com.moez.QKSMS.common.utils.ColorUtils;
|
||||
import com.moez.QKSMS.common.utils.KeyboardUtils;
|
||||
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.QKEditText;
|
||||
import com.moez.QKSMS.ui.view.QKTextView;
|
||||
import com.moez.QKSMS.ui.view.colorpicker.ColorPickerPalette;
|
||||
import com.moez.QKSMS.ui.widget.WidgetProvider;
|
||||
@@ -251,7 +255,7 @@ public class ThemeManager {
|
||||
mPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
mResources = context.getResources();
|
||||
|
||||
mColor = Integer.parseInt(mPrefs.getString(SettingsFragment.THEME, "" + ThemeManager.DEFAULT_COLOR));
|
||||
mColor = Integer.parseInt(mPrefs.getString(SettingsFragment.THEME, "" + DEFAULT_COLOR));
|
||||
mActiveColor = mColor;
|
||||
|
||||
initializeTheme(Theme.fromString(mPrefs.getString(SettingsFragment.BACKGROUND, "offwhite")));
|
||||
@@ -538,7 +542,7 @@ public class ThemeManager {
|
||||
SeekBar.OnSeekBarChangeListener seekListener = new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
int color = ThemeManager.getColor();
|
||||
int color = getColor();
|
||||
color = Color.rgb(seekBar == holder.mRed ? progress : Color.red(color),
|
||||
seekBar == holder.mGreen ? progress : Color.green(color),
|
||||
seekBar == holder.mBlue ? progress : Color.blue(color));
|
||||
@@ -547,7 +551,9 @@ public class ThemeManager {
|
||||
if (seekBar == holder.mGreen) holder.mGreenValue.setText(String.valueOf(progress));
|
||||
if (seekBar == holder.mBlue) holder.mBlueValue.setText(String.valueOf(progress));
|
||||
|
||||
ThemeManager.setActiveColor(color);
|
||||
setActiveColor(color);
|
||||
String colorString = Integer.toHexString(color);
|
||||
holder.mHex.setText(colorString.substring(colorString.length() > 6 ? colorString.length() - 6 : 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -563,10 +569,10 @@ public class ThemeManager {
|
||||
Drawable thumbGreen = ContextCompat.getDrawable(mContext, R.drawable.seek_thumb);
|
||||
Drawable thumbBlue = ContextCompat.getDrawable(mContext, R.drawable.seek_thumb);
|
||||
LiveViewManager.registerView(QKPreference.THEME, holder.mPreview, key -> {
|
||||
holder.mPreview.setBackgroundColor(ThemeManager.getColor());
|
||||
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);
|
||||
holder.mPreview.setBackgroundColor(getColor());
|
||||
holder.mRed.getProgressDrawable().setColorFilter(getColor(), PorterDuff.Mode.MULTIPLY);
|
||||
holder.mGreen.getProgressDrawable().setColorFilter(getColor(), PorterDuff.Mode.MULTIPLY);
|
||||
holder.mBlue.getProgressDrawable().setColorFilter(getColor(), PorterDuff.Mode.MULTIPLY);
|
||||
if (holder.mPager.getCurrentItem() == 0) {
|
||||
holder.mTab1.setTextColor(getColor());
|
||||
} else {
|
||||
@@ -574,6 +580,11 @@ public class ThemeManager {
|
||||
}
|
||||
});
|
||||
|
||||
LiveViewManager.registerView(QKPreference.BACKGROUND, holder.mHex, key -> {
|
||||
holder.mHex.getBackground().setColorFilter(0x22888888, PorterDuff.Mode.MULTIPLY);
|
||||
holder.mError.setColorFilter(getTextOnBackgroundSecondary(), PorterDuff.Mode.SRC_ATOP);
|
||||
});
|
||||
|
||||
holder.mRed.setThumb(thumbRed);
|
||||
holder.mRed.setOnSeekBarChangeListener(seekListener);
|
||||
holder.mGreen.setThumb(thumbGreen);
|
||||
@@ -581,13 +592,36 @@ public class ThemeManager {
|
||||
holder.mBlue.setThumb(thumbBlue);
|
||||
holder.mBlue.setOnSeekBarChangeListener(seekListener);
|
||||
|
||||
holder.mRed.setProgress(Color.red(ThemeManager.getColor()));
|
||||
holder.mGreen.setProgress(Color.green(ThemeManager.getColor()));
|
||||
holder.mBlue.setProgress(Color.blue(ThemeManager.getColor()));
|
||||
holder.mRed.setProgress(Color.red(getColor()));
|
||||
holder.mGreen.setProgress(Color.green(getColor()));
|
||||
holder.mBlue.setProgress(Color.blue(getColor()));
|
||||
|
||||
String colorString = Integer.toHexString(getColor());
|
||||
holder.mHex.setText(colorString.substring(colorString.length() > 6 ? colorString.length() - 6 : 0));
|
||||
holder.mHex.setOnEditorActionListener((v, actionId, event) -> {
|
||||
if (actionId == EditorInfo.IME_ACTION_DONE) {
|
||||
holder.mHex.clearFocus();
|
||||
KeyboardUtils.hide(mContext, holder.mHex);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
holder.mHex.setTextChangedListener(s -> {
|
||||
try {
|
||||
int color = Color.parseColor("#" + s.toString());
|
||||
holder.mError.setVisibility(View.INVISIBLE);
|
||||
if (color != getColor()) {
|
||||
holder.mRed.setProgress(Color.red(color));
|
||||
holder.mGreen.setProgress(Color.green(color));
|
||||
holder.mBlue.setProgress(Color.blue(color));
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
holder.mError.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
dialog.setContext(context)
|
||||
.setCustomView(view)
|
||||
.setNegativeButton(R.string.cancel, v -> ThemeManager.setActiveColor(ThemeManager.getThemeColor()))
|
||||
.setNegativeButton(R.string.cancel, v -> setActiveColor(getThemeColor()))
|
||||
.setPositiveButton(R.string.save, saveListener)
|
||||
.show();
|
||||
}
|
||||
@@ -732,6 +766,8 @@ public class ThemeManager {
|
||||
@Bind(R.id.green_value) QKTextView mGreenValue;
|
||||
@Bind(R.id.blue) SeekBar mBlue;
|
||||
@Bind(R.id.blue_value) QKTextView mBlueValue;
|
||||
@Bind(R.id.hex) QKEditText mHex;
|
||||
@Bind(R.id.error) ImageView mError;
|
||||
|
||||
public ColorPickerViewHolder(View view) {
|
||||
ButterKnife.bind(this, view);
|
||||
|
||||
@@ -1,21 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<item
|
||||
android:id="@+id/edittext_background">
|
||||
<shape android:shape="rectangle" >
|
||||
<solid android:color="@color/red_light" />
|
||||
<padding android:bottom="1dp" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape android:shape="rectangle" >
|
||||
<solid android:color="@color/white_pure"/>
|
||||
<padding android:bottom="4dp"
|
||||
android:left="4dp"
|
||||
android:right="4dp"
|
||||
android:top="4dp" />
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/white_pure" />
|
||||
<corners android:radius="2dp" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
</layer-list>
|
||||
@@ -161,6 +161,46 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusableInTouchMode="true"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<com.moez.QKSMS.ui.view.QKTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:text="@string/hint_hex"
|
||||
app:type="primary" />
|
||||
|
||||
<com.moez.QKSMS.ui.view.QKEditText
|
||||
android:id="@+id/hex"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:background="@drawable/edittext"
|
||||
android:digits="1234567890abcdef"
|
||||
android:imeOptions="actionDone"
|
||||
android:lines="1"
|
||||
android:maxLength="6"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingTop="8dp"
|
||||
android:selectAllOnFocus="true"
|
||||
android:singleLine="true" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/error"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:src="@drawable/ic_error"
|
||||
android:visibility="invisible" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.v4.view.ViewPager>
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
<string name="hint_reply">Enter a message</string>
|
||||
<!--Hint for code redemption-->
|
||||
<string name="hint_redeem">Enter code</string>
|
||||
<string name="hint_hex">Hex</string>
|
||||
|
||||
<!--Text shown for single new message in notification-->
|
||||
<string name="new_message">New message</string>
|
||||
|
||||
Reference in New Issue
Block a user