use appcompat dayNight theme, alertDialogs and popupMenus

This commit is contained in:
Helium314 2023-09-01 10:19:09 +02:00
parent 2a19114ccb
commit 70a86d9326
18 changed files with 27 additions and 41 deletions

View file

@ -55,8 +55,9 @@ android {
}
dependencies {
implementation 'androidx.recyclerview:recyclerview:1.3.1'
implementation 'androidx.core:core-ktx:1.10.1'
implementation 'androidx.preference:preference:1.2.1' // includes appcompat
implementation 'androidx.recyclerview:recyclerview:1.3.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.13.2'
}

View file

@ -16,7 +16,6 @@
package org.dslul.openboard.inputmethod.latin;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@ -102,6 +101,7 @@ import static org.dslul.openboard.inputmethod.latin.common.Constants.ImeOption.N
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
/**
* Input method implementation for Qwerty'ish keyboard.
@ -211,7 +211,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
final RestartAfterDeviceUnlockReceiver mRestartAfterDeviceUnlockReceiver = new RestartAfterDeviceUnlockReceiver();
private AlertDialog mOptionsDialog;
private AlertDialog mOptionsDialog; // todo: this is always null -> remove?
private final boolean mIsHardwareAcceleratedDrawingEnabled;

View file

@ -17,7 +17,6 @@
package org.dslul.openboard.inputmethod.latin.settings;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@ -27,6 +26,8 @@ import android.os.Build;
import android.os.Bundle;
import android.preference.Preference;
import androidx.appcompat.app.AlertDialog;
import org.dslul.openboard.inputmethod.latin.AudioAndHapticFeedbackManager;
import org.dslul.openboard.inputmethod.latin.R;
import org.dslul.openboard.inputmethod.latin.SystemBroadcastReceiver;

View file

@ -15,7 +15,6 @@
*/
package org.dslul.openboard.inputmethod.latin.settings
import android.app.AlertDialog
import android.content.SharedPreferences
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
import android.content.res.Configuration
@ -26,6 +25,7 @@ import android.preference.ListPreference
import android.preference.Preference
import android.preference.TwoStatePreference
import android.util.Log
import androidx.appcompat.app.AlertDialog
import androidx.core.content.edit
import org.dslul.openboard.inputmethod.keyboard.KeyboardSwitcher
import org.dslul.openboard.inputmethod.keyboard.KeyboardTheme

View file

@ -17,7 +17,6 @@
// adapted from https://github.com/rkkr/simple-keyboard/blob/master/app/src/main/java/rkr/simplekeyboard/inputmethod/latin/settings/ColorDialogPreference.java
package org.dslul.openboard.inputmethod.latin.settings;
import android.app.AlertDialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Color;
@ -26,6 +25,8 @@ import android.view.View;
import android.widget.SeekBar;
import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
import org.dslul.openboard.inputmethod.latin.R;
public class ColorPickerDialog extends AlertDialog implements SeekBar.OnSeekBarChangeListener {

View file

@ -1,15 +1,14 @@
package org.dslul.openboard.inputmethod.latin.settings
import android.app.AlertDialog
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.text.Html
import android.text.method.LinkMovementMethod
import android.view.ContextThemeWrapper
import android.view.LayoutInflater
import android.view.View
import android.widget.*
import androidx.appcompat.app.AlertDialog
import androidx.core.view.isGone
import androidx.core.view.isVisible
import androidx.core.view.size
@ -28,8 +27,7 @@ class LanguageSettingsDialog(
private val fragment: LanguageSettingsFragment?,
private val onlySystemLocales: Boolean,
private val onSubtypesChanged: () -> Unit
) : AlertDialog(ContextThemeWrapper(context, R.style.platformDialogTheme)), LanguageSettingsFragment.Listener {
private val context = ContextThemeWrapper(context, R.style.platformDialogTheme)
) : AlertDialog(context), LanguageSettingsFragment.Listener {
private val prefs = DeviceProtectedUtils.getSharedPreferences(context)!!
private val view = LayoutInflater.from(context).inflate(R.layout.locale_settings_dialog, null)
private val mainLocaleString = infos.first().subtype.locale

View file

@ -18,7 +18,6 @@ package org.dslul.openboard.inputmethod.latin.settings;
import android.app.ActionBar;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
@ -32,6 +31,8 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.inputmethod.InputMethodSubtype;
import androidx.appcompat.app.AlertDialog;
import org.dslul.openboard.inputmethod.latin.BuildConfig;
import org.dslul.openboard.inputmethod.latin.R;
import org.dslul.openboard.inputmethod.latin.common.FileUtils;

View file

@ -36,7 +36,6 @@ import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.accessibility.AccessibilityEvent;
import android.widget.ImageButton;
import android.widget.PopupMenu;
import android.widget.RelativeLayout;
import android.widget.TextView;
@ -59,6 +58,7 @@ import org.dslul.openboard.inputmethod.latin.utils.DialogUtils;
import java.util.ArrayList;
import androidx.appcompat.widget.PopupMenu;
import androidx.core.view.ViewCompat;
public final class SuggestionStripView extends RelativeLayout implements OnClickListener,

View file

@ -26,9 +26,10 @@ public final class DialogUtils {
// This utility class is not publicly instantiable.
}
// this is necessary for dialogs and popup menus created outside an activity
public static Context getPlatformDialogThemeContext(final Context context) {
// Because {@link AlertDialog.Builder.create()} doesn't honor the specified theme with
// createThemeContextWrapper=false, the result dialog box has unneeded paddings around it.
return new ContextThemeWrapper(context, R.style.platformDialogTheme);
return new ContextThemeWrapper(context, R.style.platformActivityTheme);
}
}

View file

@ -1,11 +1,11 @@
package org.dslul.openboard.inputmethod.latin.utils
import android.app.AlertDialog
import android.content.Context
import android.text.Html
import android.text.method.LinkMovementMethod
import android.view.View
import android.widget.TextView
import androidx.appcompat.app.AlertDialog
import androidx.core.content.edit
import org.dslul.openboard.inputmethod.latin.BinaryDictionaryGetter
import org.dslul.openboard.inputmethod.latin.R

View file

@ -1,6 +1,5 @@
package org.dslul.openboard.inputmethod.latin.utils
import android.app.AlertDialog
import android.os.IBinder
import android.text.Spannable
import android.text.SpannableString
@ -9,6 +8,7 @@ import android.text.style.RelativeSizeSpan
import android.view.WindowManager
import android.view.inputmethod.InputMethodInfo
import android.view.inputmethod.InputMethodSubtype
import androidx.appcompat.app.AlertDialog
import org.dslul.openboard.inputmethod.latin.LatinIME
import org.dslul.openboard.inputmethod.latin.R
import org.dslul.openboard.inputmethod.latin.RichInputMethodManager

View file

@ -1,10 +1,10 @@
package org.dslul.openboard.inputmethod.latin.utils
import android.app.AlertDialog
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import org.dslul.openboard.inputmethod.dictionarypack.DictionaryPackConstants
import org.dslul.openboard.inputmethod.latin.R
import org.dslul.openboard.inputmethod.latin.common.FileUtils

View file

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="platformActivityTheme" parent="@android:style/Theme.Material">
<item name="android:colorAccent">@color/highlight_color_lxx_dark</item>
</style>
<style name="platformDialogTheme" parent="@android:style/Theme.Material.Dialog">
<item name="android:colorAccent">@color/highlight_color_lxx_dark</item>
</style>
</resources>

View file

@ -5,4 +5,6 @@
<color name="foreground">#FFF</color>
<color name="foreground_weak">#BBB</color>
<color name="almost_background">#666</color>
<color name="accent">@color/highlight_color_lxx_dark</color>
</resources>

View file

@ -19,10 +19,8 @@
-->
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="platformActivityTheme" parent="@android:style/Theme.DeviceDefault.Light">
<item name="android:colorAccent">@color/highlight_color_lxx_light</item>
</style>
<style name="platformDialogTheme" parent="@android:style/Theme.DeviceDefault.Light.Dialog">
<item name="android:colorAccent">@color/highlight_color_lxx_light</item>
<style name="platformActivityTheme" parent="Theme.AppCompat.DayNight">
<item name="android:colorAccent">@color/accent</item>
<item name="colorAccent">@color/accent</item>
</style>
</resources>

View file

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="platformActivityTheme" parent="@android:style/Theme.Material.Light">
<item name="android:colorAccent">@android:color/system_accent1_400</item>
</style>
<style name="platformDialogTheme" parent="@android:style/Theme.Material.Light.Dialog">
<item name="android:colorAccent">@android:color/system_accent1_400</item>
</style>
</resources>

View file

@ -117,4 +117,6 @@
<color name="foreground">#000</color>
<color name="foreground_weak">#555</color>
<color name="almost_background">#AAA</color>
<color name="accent">@color/highlight_color_lxx_light</color>
</resources>

View file

@ -19,6 +19,5 @@
-->
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="platformActivityTheme" parent="@android:style/Theme.Holo" />
<style name="platformDialogTheme" parent="@android:style/Theme.Holo.Dialog" />
<style name="platformActivityTheme" parent="Theme.AppCompat.DayNight" />
</resources>