diff --git a/app/src/main/java/ru/vtosters/lite/ui/PreferencesUtil.java b/app/src/main/java/ru/vtosters/lite/ui/PreferencesUtil.java index d0823587e..aea4fd979 100644 --- a/app/src/main/java/ru/vtosters/lite/ui/PreferencesUtil.java +++ b/app/src/main/java/ru/vtosters/lite/ui/PreferencesUtil.java @@ -2,9 +2,11 @@ package ru.vtosters.lite.ui; import static ru.vtosters.lite.utils.Globals.convertDpToPixel; import static ru.vtosters.lite.utils.Globals.getContext; +import static ru.vtosters.lite.utils.Themes.*; import android.app.AlertDialog; import android.content.Context; +import android.content.DialogInterface; import android.content.res.ColorStateList; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; @@ -32,7 +34,7 @@ import ru.vtosters.lite.utils.Themes; public class PreferencesUtil{ public static Drawable setTint(Context ctx, Drawable d){ - d.setColorFilter(Themes.getAccentColor(), PorterDuff.Mode.SRC_ATOP); + d.setColorFilter(getAccentColor(), PorterDuff.Mode.SRC_ATOP); return d; } @@ -172,18 +174,15 @@ public class PreferencesUtil{ editText.setHint(title); editText.setHintTextColor(PreferencesUtil.getSTextColor(getContext())); - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ - editText.setBackgroundTintList(ColorStateList.valueOf(PreferencesUtil.getTextColor(getContext()))); - } else { - ViewCompat.setBackgroundTintList(editText, ColorStateList.valueOf(PreferencesUtil.getTextColor(getContext()))); - } + editText.setBackgroundTintList(ColorStateList.valueOf(getAccentColor())); + linearLayout.addView(editText); editText.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT; ViewGroup.MarginLayoutParams margin = ((ViewGroup.MarginLayoutParams) editText.getLayoutParams()); - margin.setMargins(convertDpToPixel(24f), 0, convertDpToPixel(24f), 0); + margin.setMargins(convertDpToPixel(20f), 0, convertDpToPixel(20f), 0); editText.setLayoutParams(margin); - AlertDialog.Builder builder = new AlertDialog.Builder(fragment.getContext()); + AlertDialog.Builder builder = new AlertDialog.Builder(fragment.getContext(), com.vtosters.lite.R.style.Base_Theme_MaterialComponents_Dialog_Alert); builder.setTitle(title); builder.setView(linearLayout); builder.setPositiveButton("OK", (dialog, which) -> { @@ -196,7 +195,10 @@ public class PreferencesUtil{ .putString(key, editText.getText().toString()) .apply(); }); - builder.show(); + + var alert = builder.create(); + alert.show(); + alert.getButton(DialogInterface.BUTTON_POSITIVE).setTextColor(getAccentColor()); return false; }); // preference.setOnPreferenceClickListener(listener) @@ -205,13 +207,13 @@ public class PreferencesUtil{ public static int getTextColor(Context ctx){ TypedValue typedValue = new TypedValue(); - ctx.getTheme().resolveAttribute(Themes.getTextAttr(), typedValue, true); + ctx.getTheme().resolveAttribute(getTextAttr(), typedValue, true); return typedValue.data; } public static int getSTextColor(Context ctx){ TypedValue typedValue = new TypedValue(); - ctx.getTheme().resolveAttribute(Themes.getSTextAttr(), typedValue, true); + ctx.getTheme().resolveAttribute(getSTextAttr(), typedValue, true); return typedValue.data; } diff --git a/app/src/main/java/ru/vtosters/lite/ui/fragments/MediaFragment.java b/app/src/main/java/ru/vtosters/lite/ui/fragments/MediaFragment.java index 56823022e..d0d3e0111 100644 --- a/app/src/main/java/ru/vtosters/lite/ui/fragments/MediaFragment.java +++ b/app/src/main/java/ru/vtosters/lite/ui/fragments/MediaFragment.java @@ -1,9 +1,13 @@ package ru.vtosters.lite.ui.fragments; +import static ru.vtosters.lite.utils.Globals.convertDpToPixel; import static ru.vtosters.lite.utils.Globals.getIdentifier; import android.content.Context; +import android.content.DialogInterface; +import android.content.res.ColorStateList; import android.os.Bundle; +import android.widget.Button; import android.widget.EditText; import android.widget.LinearLayout; @@ -13,21 +17,31 @@ import androidx.preference.Preference; import com.vtosters.lite.general.fragments.MaterialPreferenceToolbarFragment; import ru.vtosters.lite.downloaders.VideoDownloader; +import ru.vtosters.lite.utils.Themes; public class MediaFragment extends MaterialPreferenceToolbarFragment{ public static void download(Context ctx){ - AlertDialog.Builder alertDialog = new AlertDialog.Builder(ctx); + AlertDialog.Builder alertDialog = new AlertDialog.Builder(ctx, com.vtosters.lite.R.style.Base_Theme_MaterialComponents_Dialog_Alert); alertDialog.setTitle("Введите ссылку на видео"); final EditText input = new EditText(ctx); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); + input.setLayoutParams(lp); + + input.setBackgroundTintList(ColorStateList.valueOf(Themes.getAccentColor())); + alertDialog.setView(input); alertDialog.setPositiveButton("Скачать", (dialog, which) -> VideoDownloader.parseVideoLink(input.getText().toString(), ctx)); - alertDialog.show(); + + var alert = alertDialog.create(); + + alert.show(); + + alert.getButton(DialogInterface.BUTTON_POSITIVE).setTextColor(Themes.getAccentColor()); } @Override diff --git a/app/src/main/java/ru/vtosters/lite/utils/RenameTool.java b/app/src/main/java/ru/vtosters/lite/utils/RenameTool.java index 6b1b1617c..c94657b04 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/RenameTool.java +++ b/app/src/main/java/ru/vtosters/lite/utils/RenameTool.java @@ -5,6 +5,7 @@ import static ru.vtosters.lite.utils.Globals.convertDpToPixel; import static ru.vtosters.lite.utils.Globals.fromEup; import static ru.vtosters.lite.utils.Globals.getContext; import static ru.vtosters.lite.utils.Globals.getGroupName; +import static ru.vtosters.lite.utils.Globals.getResources; import static ru.vtosters.lite.utils.Globals.getUserFirstName; import static ru.vtosters.lite.utils.Globals.getUserID; import static ru.vtosters.lite.utils.Globals.getUserId; @@ -12,6 +13,7 @@ import static ru.vtosters.lite.utils.Globals.getUserLastName; import static ru.vtosters.lite.utils.Globals.sendToast; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.content.res.ColorStateList; import android.database.Cursor; @@ -159,17 +161,17 @@ public class RenameTool{ final EditText fn = new EditText(ctx); fn.setHint("Имя"); fn.setHintTextColor(getSTextColor(ctx)); - fn.setBackgroundTintList(ColorStateList.valueOf(getTextColor(ctx))); + fn.setBackgroundTintList(ColorStateList.valueOf(Themes.getAccentColor())); linearLayout.addView(fn); fn.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT; ViewGroup.MarginLayoutParams margin = ((ViewGroup.MarginLayoutParams) fn.getLayoutParams()); - margin.setMargins(convertDpToPixel(24f), 0, convertDpToPixel(24f), 0); + margin.setMargins(convertDpToPixel(20f), 0, convertDpToPixel(20f), 0); fn.setLayoutParams(margin); final EditText ln = new EditText(ctx); ln.setHint("Фамилия"); ln.setHintTextColor(getSTextColor(ctx)); - ln.setBackgroundTintList(ColorStateList.valueOf(getTextColor(ctx))); + ln.setBackgroundTintList(ColorStateList.valueOf(Themes.getAccentColor())); linearLayout.addView(ln); ln.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT; ln.setLayoutParams(margin); @@ -180,7 +182,7 @@ public class RenameTool{ int id = getUserID(profile); - AlertDialog.Builder builder = new AlertDialog.Builder(ctx); + AlertDialog.Builder builder = new AlertDialog.Builder(ctx, com.vtosters.lite.R.style.Base_Theme_MaterialComponents_Dialog_Alert); builder.setTitle("Смена имени"); builder.setMessage("Это локальное изменение, которое будет отображатся только в данном клиенте."); builder.setView(linearLayout); @@ -214,7 +216,13 @@ public class RenameTool{ ctx.sendBroadcast(new Intent("com.vkontakte.android.ACTION_PROFILE_UPDATED").putExtra("uid", id)); sendToast("Пользователь успешно удален из базы данных!"); }); - builder.show(); + + var alert = builder.create(); + + alert.show(); + + alert.getButton(DialogInterface.BUTTON_POSITIVE).setTextColor(Themes.getAccentColor()); + alert.getButton(DialogInterface.BUTTON_NEUTRAL).setTextColor(getResources().getColor(com.vtosters.lite.R.color.red)); } public static void createDialogGroup(ExtendedCommunityProfile eup, final Context ctx){ @@ -224,11 +232,11 @@ public class RenameTool{ final EditText fn = new EditText(ctx); fn.setHint("Имя"); fn.setHintTextColor(getSTextColor(ctx)); - fn.setBackgroundTintList(ColorStateList.valueOf(getTextColor(ctx))); + fn.setBackgroundTintList(ColorStateList.valueOf(Themes.getAccentColor())); linearLayout.addView(fn); fn.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT; ViewGroup.MarginLayoutParams margin = ((ViewGroup.MarginLayoutParams) fn.getLayoutParams()); - margin.setMargins(convertDpToPixel(24f), 0, convertDpToPixel(24f), 0); + margin.setMargins(convertDpToPixel(20f), 0, convertDpToPixel(20f), 0); fn.setLayoutParams(margin); final UserProfile profile = fromEup(eup); @@ -239,7 +247,7 @@ public class RenameTool{ final int id = fid; - AlertDialog.Builder builder = new AlertDialog.Builder(ctx); + AlertDialog.Builder builder = new AlertDialog.Builder(ctx, com.vtosters.lite.R.style.Base_Theme_MaterialComponents_Dialog_Alert); builder.setTitle("Смена имени"); builder.setMessage("Это локальное изменение, которое будет отображатся только в данном клиенте"); builder.setView(linearLayout); @@ -263,7 +271,13 @@ public class RenameTool{ updateRequested = true; sendToast("Сообщество успешно удалено из базы данных!"); }); - builder.show(); + + var alert = builder.create(); + + alert.show(); + + alert.getButton(DialogInterface.BUTTON_POSITIVE).setTextColor(Themes.getAccentColor()); + alert.getButton(DialogInterface.BUTTON_NEUTRAL).setTextColor(getResources().getColor(com.vtosters.lite.R.color.red)); } public static boolean isChangedName(int uid){