add keyaboard popup

This commit is contained in:
Vologhat
2022-12-27 16:20:31 +03:00
parent 8d9812ebe0
commit 92edbd4686
2 changed files with 42 additions and 8 deletions
@@ -1,8 +1,11 @@
package ru.vtosters.lite.ui.fragments;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.WindowManager;
import androidx.preference.PreferenceCategory;
import com.vk.core.dialogs.alert.VkAlertDialog;
import com.vk.core.fragments.FragmentImpl;
@@ -130,12 +133,22 @@ public class ThemesFragment extends MaterialPreferenceToolbarFragment {
void showColorPicker() {
final var colorPickerView = new ColorPickerView(requireContext());
colorPickerView.setColor(ThemesUtils.getAccentColor());
new VkAlertDialog.Builder(requireContext())
.setTitle(AndroidUtils.getString("select_color"))
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.select, (dialog, which) -> setAccentColor(colorPickerView.getColor()))
.setView(colorPickerView)
.show();
var alertDialog = new VkAlertDialog.Builder(requireContext()).create();
alertDialog.setTitle(AndroidUtils.getString("select_color"));
alertDialog.setButton(
DialogInterface.BUTTON_NEGATIVE,
requireContext().getString(R.string.cancel),
(DialogInterface.OnClickListener) null
);
alertDialog.setButton(
DialogInterface.BUTTON_POSITIVE,
requireContext().getString(R.string.select),
(dialog, which) -> setAccentColor(colorPickerView.getColor())
);
alertDialog.setView(colorPickerView);
alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
alertDialog.show();
}
void showPalettesDialog() {
@@ -9,8 +9,14 @@ import android.widget.EditText;
class HexEdit {
private static InputFilter[] withoutAlphaDigits = {new ColorPasteLengthFilter()};
private static InputFilter[] withAlphaDigits = {new InputFilter.LengthFilter(8)};
private static InputFilter[] withoutAlphaDigits = {
new ColorPasteLengthFilter(),
new HexFilter()
};
private static InputFilter[] withAlphaDigits = {
new InputFilter.LengthFilter(8),
new HexFilter()
};
public static void setUpListeners(final EditText hexEdit, final ObservableColor observableColor) {
@@ -93,4 +99,19 @@ class HexEdit {
}
}
private static class HexFilter implements InputFilter {
@Override
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
var state = true;
for (int i = start; i < end; i++) {
char ch = source.charAt(i);
if (ch < '0' || ch> '9' && ch < 'A' || ch > 'F' && ch < 'a' || ch > 'f') {
state = false;
break;
}
}
return state ? source.subSequence(start, end) : "";
}
}
}