fix all RadioButtons and SwitchCompats buttons

This commit is contained in:
gdlbo
2023-03-15 21:29:50 +03:00
parent 507dbee4c0
commit 46ad8635f1
7 changed files with 45 additions and 6 deletions
@@ -1,6 +1,5 @@
package ru.vtosters.lite.hooks;
import static ru.vtosters.lite.ui.dialogs.MessageSettings.argDialog;
import static ru.vtosters.lite.ui.dialogs.MessageSettings.bombCount;
import static ru.vtosters.lite.ui.dialogs.MessageSettings.isSilentEnabled;
import static ru.vtosters.lite.utils.Preferences.autoalltranslate;
@@ -17,6 +16,7 @@ import java.util.ArrayList;
import java.util.regex.Pattern;
import ru.vtosters.lite.translators.BaseTranslator;
import ru.vtosters.lite.ui.dialogs.MessageSettings;
import ru.vtosters.lite.utils.LifecycleUtils;
public class MessagesHook {
@@ -70,7 +70,7 @@ public class MessagesHook {
public static void onLongClick(View view) {
view.setOnLongClickListener(v -> {
argDialog(v.getContext());
MessageSettings.argDialog(v.getContext());
return true;
});
}
@@ -35,6 +35,11 @@ public class ProxyHook {
RadioButton rgRandomProxy = new RadioButton(new ContextThemeWrapper(ctx, com.vtosters.lite.R.style.Widget_AppCompat_CompoundButton_RadioButton));
RadioButton rgVika = new RadioButton(new ContextThemeWrapper(ctx, com.vtosters.lite.R.style.Widget_AppCompat_CompoundButton_RadioButton));
SwitchHook.setCompoundButton(rgDefault);
SwitchHook.setCompoundButton(rgZaborona);
SwitchHook.setCompoundButton(rgRandomProxy);
SwitchHook.setCompoundButton(rgVika);
rg.addView(rgDefault);
rg.addView(rgVika);
rg.addView(rgZaborona);
@@ -2,10 +2,12 @@ package ru.vtosters.lite.hooks;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.widget.CompoundButton;
import android.widget.Switch;
import androidx.appcompat.widget.SwitchCompat;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat;
import androidx.core.widget.CompoundButtonCompat;
import com.vk.core.ui.themes.VKThemeHelper;
import com.vk.core.util.ColorUtils;
import ru.vtosters.lite.utils.AndroidUtils;
@@ -34,8 +36,8 @@ public class SwitchHook {
switchCompat.setThumbDrawable(setTintList(getCustomThumb(), new ColorStateList(createTrackColorStateList(), SWITCH_COLORS)));
switchCompat.setTrackDrawable(setTintList(getCustomTrack(), new ColorStateList(createTrackColorStateList(), TRACK_COLORS)));
} else {
DrawableCompat.setTintList(DrawableCompat.wrap(switchCompat.getThumbDrawable()), new ColorStateList(createTrackColorStateList(), SWITCH_COLORS));
DrawableCompat.setTintList(DrawableCompat.wrap(switchCompat.getTrackDrawable()), new ColorStateList(createTrackColorStateList(), TRACK_COLORS));
setTintList(switchCompat.getThumbDrawable(), new ColorStateList(createTrackColorStateList(), SWITCH_COLORS));
setTintList(switchCompat.getTrackDrawable(), new ColorStateList(createTrackColorStateList(), TRACK_COLORS));
}
}
@@ -44,11 +46,23 @@ public class SwitchHook {
drawableCompat.setThumbDrawable(setTintList(getCustomThumb(), new ColorStateList(createTrackColorStateList(), SWITCH_COLORS)));
drawableCompat.setTrackDrawable(setTintList(getCustomTrack(), new ColorStateList(createTrackColorStateList(), TRACK_COLORS)));
} else {
DrawableCompat.setTintList(DrawableCompat.wrap(drawableCompat.getThumbDrawable()), new ColorStateList(createTrackColorStateList(), SWITCH_COLORS));
DrawableCompat.setTintList(DrawableCompat.wrap(drawableCompat.getTrackDrawable()), new ColorStateList(createTrackColorStateList(), TRACK_COLORS));
setTintList(drawableCompat.getThumbDrawable(), new ColorStateList(createTrackColorStateList(), SWITCH_COLORS));
setTintList(drawableCompat.getTrackDrawable(), new ColorStateList(createTrackColorStateList(), TRACK_COLORS));
}
}
public static void setCompoundButton(CompoundButton compoundButton) {
CompoundButtonCompat.setButtonTintList(
compoundButton,
new ColorStateList(
createTrackColorStateList(),
new int[]{
ColorUtils.b(ThemesUtils.getColorFromAttr(com.vtosters.lite.R.attr.selection_off_icon), 0.4f),
ColorUtils.b(ThemesUtils.getAccentColor(), 0.4f),
ThemesUtils.getColorFromAttr(com.vtosters.lite.R.attr.selection_off_icon),
ThemesUtils.getAccentColor()}));
}
private static int[][] createTrackColorStateList() {
return new int[][]{
new int[]{-android.R.attr.state_enabled, -android.R.attr.state_checked},
@@ -24,6 +24,7 @@ import com.vk.stickers.details.StickerDetailsAdapter;
import com.vk.stickers.details.StickerDetailsView;
import com.vtosters.lite.R;
import org.json.JSONException;
import ru.vtosters.lite.hooks.SwitchHook;
import ru.vtosters.lite.tgs.TGPref;
import ru.vtosters.lite.tgs.TGRoot;
import ru.vtosters.lite.ui.components.IItemMovingListener;
@@ -140,6 +141,8 @@ public class StickerPackAdapter extends RecyclerView.Adapter<StickerPackAdapter.
mSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> sService.setPackEnabled(pack, isChecked, true));
mStickersCount.setText(pack.stickersCount + " " + mStickersCount.getContext().getString(R.string.stickerscount));
SwitchHook.setSwitchCompatColors(mSwitch);
// Color костыль
int color = getTextAttr();
int secondary = getSTextAttr();
@@ -16,6 +16,7 @@ import androidx.appcompat.widget.SwitchCompat;
import com.vk.core.dialogs.alert.VkAlertDialog;
import com.vtosters.lite.R;
import ru.vtosters.lite.hooks.SwitchHook;
import ru.vtosters.lite.utils.LayoutUtils;
public class MessageSettings {
@@ -37,6 +38,13 @@ public class MessageSettings {
RadioButton four = new RadioButton(new ContextThemeWrapper(context, R.style.Widget_AppCompat_CompoundButton_RadioButton));
RadioButton five = new RadioButton(new ContextThemeWrapper(context, R.style.Widget_AppCompat_CompoundButton_RadioButton));
SwitchHook.setCompoundButton(zero);
SwitchHook.setCompoundButton(one);
SwitchHook.setCompoundButton(two);
SwitchHook.setCompoundButton(three);
SwitchHook.setCompoundButton(four);
SwitchHook.setCompoundButton(five);
rg.addView(zero);
rg.addView(one);
rg.addView(two);
@@ -86,6 +94,8 @@ public class MessageSettings {
silentSwitch.setPadding(dp2px(24f), dp2px(12f), dp2px(18f), dp2px(12f));
SwitchHook.setSwitchCompatColors(silentSwitch);
mContainer.setLayoutParams(LayoutUtils.createLinear(-1, -1));
mContainer.setOrientation(LinearLayout.VERTICAL);
@@ -16,6 +16,7 @@ import androidx.core.content.res.ResourcesCompat;
import com.vk.core.dialogs.alert.VkAlertDialog;
import com.vtosters.lite.R;
import ru.vtosters.lite.hooks.SwitchHook;
import ru.vtosters.lite.ui.PreferenceFragmentUtils;
import ru.vtosters.lite.ui.components.IconManager;
import ru.vtosters.lite.utils.AndroidUtils;
@@ -34,6 +35,10 @@ public class IconsFragment extends TrackedMaterialPreferenceToolbarFragment {
RadioButton rgVK = new RadioButton(new ContextThemeWrapper(ctx, R.style.Widget_AppCompat_CompoundButton_RadioButton));
RadioButton rgVKontakte = new RadioButton(new ContextThemeWrapper(ctx, R.style.Widget_AppCompat_CompoundButton_RadioButton));
SwitchHook.setCompoundButton(rgDefault);
SwitchHook.setCompoundButton(rgVK);
SwitchHook.setCompoundButton(rgVKontakte);
rg.addView(rgDefault);
rg.addView(rgVK);
rg.addView(rgVKontakte);
@@ -53,6 +53,7 @@ import java.io.IOException;
import b.h.g.m.FileUtils;
import ru.vtosters.lite.deviceinfo.DeviceInfoCollector;
import ru.vtosters.lite.hooks.SwitchHook;
import ru.vtosters.lite.ssfs.UsersList;
import ru.vtosters.lite.ui.activities.VKAdminTokenActivity;
import ru.vtosters.lite.ui.components.BackupManager;
@@ -242,6 +243,7 @@ public class OtherFragment extends TrackedMaterialPreferenceToolbarFragment {
for (int item = 0; item <= 5; item++) {
RadioButton rb = new RadioButton(new ContextThemeWrapper(getContext(), com.vtosters.lite.R.style.Widget_AppCompat_CompoundButton_RadioButton));
SwitchHook.setCompoundButton(rb);
rg.addView(rb);
rb.setId(item);
rb.setTextSize(TypedValue.COMPLEX_UNIT_PX, dp2px(14f));