mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-04 13:50:42 +00:00
remove more unused code, solve some warnings, ...
This commit is contained in:
parent
92c08e40ef
commit
7c5b96a034
40 changed files with 94 additions and 500 deletions
|
@ -125,10 +125,6 @@
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<!-- Unexported activity used for tests. -->
|
|
||||||
<activity android:name=".settings.TestFragmentActivity"
|
|
||||||
android:exported="false" />
|
|
||||||
|
|
||||||
<!-- Broadcast receivers -->
|
<!-- Broadcast receivers -->
|
||||||
<receiver android:name="SystemBroadcastReceiver"
|
<receiver android:name="SystemBroadcastReceiver"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
|
|
|
@ -10,7 +10,7 @@ import android.os.Build
|
||||||
import android.os.Build.VERSION_CODES
|
import android.os.Build.VERSION_CODES
|
||||||
import android.view.inputmethod.InputMethodSubtype
|
import android.view.inputmethod.InputMethodSubtype
|
||||||
import org.dslul.openboard.inputmethod.latin.common.LocaleUtils
|
import org.dslul.openboard.inputmethod.latin.common.LocaleUtils
|
||||||
import org.dslul.openboard.inputmethod.latin.settings.locale
|
import org.dslul.openboard.inputmethod.latin.utils.locale
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
object InputMethodSubtypeCompatUtils {
|
object InputMethodSubtypeCompatUtils {
|
||||||
|
|
|
@ -131,7 +131,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
.setNumberRowEnabled(settingsValues.mShowsNumberRow)
|
.setNumberRowEnabled(settingsValues.mShowsNumberRow)
|
||||||
.setLanguageSwitchKeyEnabled(settingsValues.isLanguageSwitchKeyEnabled())
|
.setLanguageSwitchKeyEnabled(settingsValues.isLanguageSwitchKeyEnabled())
|
||||||
.setEmojiKeyEnabled(settingsValues.mShowsEmojiKey)
|
.setEmojiKeyEnabled(settingsValues.mShowsEmojiKey)
|
||||||
.setSplitLayoutEnabled(ProductionFlags.IS_SPLIT_KEYBOARD_SUPPORTED && settingsValues.mIsSplitKeyboardEnabled)
|
.setSplitLayoutEnabled(settingsValues.mIsSplitKeyboardEnabled)
|
||||||
.setOneHandedModeEnabled(oneHandedModeEnabled)
|
.setOneHandedModeEnabled(oneHandedModeEnabled)
|
||||||
.build();
|
.build();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -69,7 +69,6 @@ import org.dslul.openboard.inputmethod.latin.permissions.PermissionsManager;
|
||||||
import org.dslul.openboard.inputmethod.latin.personalization.PersonalizationHelper;
|
import org.dslul.openboard.inputmethod.latin.personalization.PersonalizationHelper;
|
||||||
import org.dslul.openboard.inputmethod.latin.settings.Settings;
|
import org.dslul.openboard.inputmethod.latin.settings.Settings;
|
||||||
import org.dslul.openboard.inputmethod.latin.settings.SettingsActivity;
|
import org.dslul.openboard.inputmethod.latin.settings.SettingsActivity;
|
||||||
import org.dslul.openboard.inputmethod.latin.settings.SubtypeSettingsKt;
|
|
||||||
import org.dslul.openboard.inputmethod.latin.settings.SettingsValues;
|
import org.dslul.openboard.inputmethod.latin.settings.SettingsValues;
|
||||||
import org.dslul.openboard.inputmethod.latin.suggestions.SuggestionStripView;
|
import org.dslul.openboard.inputmethod.latin.suggestions.SuggestionStripView;
|
||||||
import org.dslul.openboard.inputmethod.latin.suggestions.SuggestionStripViewAccessor;
|
import org.dslul.openboard.inputmethod.latin.suggestions.SuggestionStripViewAccessor;
|
||||||
|
@ -84,6 +83,7 @@ import org.dslul.openboard.inputmethod.latin.utils.Log;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.StatsUtils;
|
import org.dslul.openboard.inputmethod.latin.utils.StatsUtils;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.StatsUtilsManager;
|
import org.dslul.openboard.inputmethod.latin.utils.StatsUtilsManager;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.SubtypeLocaleUtils;
|
import org.dslul.openboard.inputmethod.latin.utils.SubtypeLocaleUtils;
|
||||||
|
import org.dslul.openboard.inputmethod.latin.utils.SubtypeSettingsKt;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.ViewLayoutUtils;
|
import org.dslul.openboard.inputmethod.latin.utils.ViewLayoutUtils;
|
||||||
|
|
||||||
import java.io.FileDescriptor;
|
import java.io.FileDescriptor;
|
||||||
|
|
|
@ -19,11 +19,11 @@ import android.view.inputmethod.InputMethodSubtype;
|
||||||
import org.dslul.openboard.inputmethod.annotations.UsedForTesting;
|
import org.dslul.openboard.inputmethod.annotations.UsedForTesting;
|
||||||
import org.dslul.openboard.inputmethod.compat.InputMethodSubtypeCompatUtils;
|
import org.dslul.openboard.inputmethod.compat.InputMethodSubtypeCompatUtils;
|
||||||
import org.dslul.openboard.inputmethod.latin.settings.Settings;
|
import org.dslul.openboard.inputmethod.latin.settings.Settings;
|
||||||
import org.dslul.openboard.inputmethod.latin.settings.SubtypeSettingsKt;
|
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.DeviceProtectedUtils;
|
import org.dslul.openboard.inputmethod.latin.utils.DeviceProtectedUtils;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.LanguageOnSpacebarUtils;
|
import org.dslul.openboard.inputmethod.latin.utils.LanguageOnSpacebarUtils;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.ScriptUtils;
|
import org.dslul.openboard.inputmethod.latin.utils.ScriptUtils;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.SubtypeLocaleUtils;
|
import org.dslul.openboard.inputmethod.latin.utils.SubtypeLocaleUtils;
|
||||||
|
import org.dslul.openboard.inputmethod.latin.utils.SubtypeSettingsKt;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
|
@ -74,16 +74,6 @@ public class UserBinaryDictionary extends ExpandableBinaryDictionary {
|
||||||
ContentResolver cres = context.getContentResolver();
|
ContentResolver cres = context.getContentResolver();
|
||||||
|
|
||||||
mObserver = new ContentObserver(null) {
|
mObserver = new ContentObserver(null) {
|
||||||
@Override
|
|
||||||
public void onChange(final boolean self) {
|
|
||||||
// This hook is deprecated as of API level 16 (Build.VERSION_CODES.JELLY_BEAN),
|
|
||||||
// but should still be supported for cases where the IME is running on an older
|
|
||||||
// version of the platform.
|
|
||||||
onChange(self, null);
|
|
||||||
}
|
|
||||||
// The following hook is only available as of API level 16
|
|
||||||
// (Build.VERSION_CODES.JELLY_BEAN), and as such it will only work on JellyBean+
|
|
||||||
// devices. On older versions of the platform, the hook above will be called instead.
|
|
||||||
@Override
|
@Override
|
||||||
public void onChange(final boolean self, final Uri uri) {
|
public void onChange(final boolean self, final Uri uri) {
|
||||||
setNeedsToRecreate();
|
setNeedsToRecreate();
|
||||||
|
@ -98,9 +88,7 @@ public class UserBinaryDictionary extends ExpandableBinaryDictionary {
|
||||||
public static UserBinaryDictionary getDictionary(
|
public static UserBinaryDictionary getDictionary(
|
||||||
final Context context, final Locale locale, final File dictFile,
|
final Context context, final Locale locale, final File dictFile,
|
||||||
final String dictNamePrefix, @Nullable final String account) {
|
final String dictNamePrefix, @Nullable final String account) {
|
||||||
return new UserBinaryDictionary(
|
return new UserBinaryDictionary(context, locale, false, dictFile, dictNamePrefix + NAME);
|
||||||
context, locale, false /* alsoUseMoreRestrictiveLocales */,
|
|
||||||
dictFile, dictNamePrefix + NAME);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2011 The Android Open Source Project
|
|
||||||
* modified
|
|
||||||
* SPDX-License-Identifier: Apache-2.0 AND GPL-3.0-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.dslul.openboard.inputmethod.latin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Information container for a word list.
|
|
||||||
*/
|
|
||||||
public final class WordListInfo {
|
|
||||||
public final String mId;
|
|
||||||
public final String mLocale;
|
|
||||||
public final String mRawChecksum;
|
|
||||||
public WordListInfo(final String id, final String locale, final String rawChecksum) {
|
|
||||||
mId = id;
|
|
||||||
mLocale = locale;
|
|
||||||
mRawChecksum = rawChecksum;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2011 The Android Open Source Project
|
|
||||||
* modified
|
|
||||||
* SPDX-License-Identifier: Apache-2.0 AND GPL-3.0-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.dslul.openboard.inputmethod.latin.define
|
|
||||||
|
|
||||||
object JniLibName {
|
|
||||||
const val JNI_LIB_NAME = "jni_latinime"
|
|
||||||
const val JNI_LIB_NAME_GOOGLE = "jni_latinimegoogle"
|
|
||||||
const val JNI_LIB_IMPORT_FILE_NAME = "libjni_latinime.so"
|
|
||||||
}
|
|
|
@ -16,9 +16,4 @@ object ProductionFlags {
|
||||||
* [org.dslul.openboard.inputmethod.latin.SuggestedWords.mRawSuggestions].
|
* [org.dslul.openboard.inputmethod.latin.SuggestedWords.mRawSuggestions].
|
||||||
*/
|
*/
|
||||||
const val INCLUDE_RAW_SUGGESTIONS = false
|
const val INCLUDE_RAW_SUGGESTIONS = false
|
||||||
|
|
||||||
/**
|
|
||||||
* When `false`, the split keyboard is not yet ready to be enabled.
|
|
||||||
*/
|
|
||||||
const val IS_SPLIT_KEYBOARD_SUPPORTED = true
|
|
||||||
}
|
}
|
|
@ -1,47 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2013 The Android Open Source Project
|
|
||||||
* modified
|
|
||||||
* SPDX-License-Identifier: Apache-2.0 AND GPL-3.0-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.dslul.openboard.inputmethod.latin.settings;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.preference.PreferenceFragment;
|
|
||||||
import android.view.inputmethod.InputMethodSubtype;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import org.dslul.openboard.inputmethod.latin.RichInputMethodManager;
|
|
||||||
import org.dslul.openboard.inputmethod.latin.RichInputMethodSubtype;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Utility class for managing additional features settings.
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public class AdditionalFeaturesSettingUtils {
|
|
||||||
public static final int ADDITIONAL_FEATURES_SETTINGS_SIZE = 0;
|
|
||||||
|
|
||||||
private AdditionalFeaturesSettingUtils() {
|
|
||||||
// This utility class is not publicly instantiable.
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addAdditionalFeaturesPreferences(
|
|
||||||
final Context context, final PreferenceFragment settingsFragment) {
|
|
||||||
// do nothing.
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void readAdditionalFeaturesPreferencesIntoArray(final Context context,
|
|
||||||
final SharedPreferences prefs, final int[] additionalFeaturesPreferences) {
|
|
||||||
// do nothing.
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
public static RichInputMethodSubtype createRichInputMethodSubtype(
|
|
||||||
@NonNull final RichInputMethodManager imm,
|
|
||||||
@NonNull final InputMethodSubtype subtype,
|
|
||||||
final Context context) {
|
|
||||||
return new RichInputMethodSubtype(subtype);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -25,8 +25,9 @@ import org.dslul.openboard.inputmethod.latin.BuildConfig
|
||||||
import org.dslul.openboard.inputmethod.latin.R
|
import org.dslul.openboard.inputmethod.latin.R
|
||||||
import org.dslul.openboard.inputmethod.latin.SystemBroadcastReceiver
|
import org.dslul.openboard.inputmethod.latin.SystemBroadcastReceiver
|
||||||
import org.dslul.openboard.inputmethod.latin.common.FileUtils
|
import org.dslul.openboard.inputmethod.latin.common.FileUtils
|
||||||
import org.dslul.openboard.inputmethod.latin.define.JniLibName
|
|
||||||
import org.dslul.openboard.inputmethod.latin.settings.SeekBarDialogPreference.ValueProxy
|
import org.dslul.openboard.inputmethod.latin.settings.SeekBarDialogPreference.ValueProxy
|
||||||
|
import org.dslul.openboard.inputmethod.latin.utils.JniUtils
|
||||||
|
import org.dslul.openboard.inputmethod.latin.utils.infoDialog
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileInputStream
|
import java.io.FileInputStream
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
@ -118,7 +119,7 @@ class AdvancedSettingsFragment : SubScreenFragment() {
|
||||||
libraryFilePicker.launch(intent)
|
libraryFilePicker.launch(intent)
|
||||||
}
|
}
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
libfile = File(requireContext().filesDir.absolutePath + File.separator + JniLibName.JNI_LIB_IMPORT_FILE_NAME)
|
libfile = File(requireContext().filesDir.absolutePath + File.separator + JniUtils.JNI_LIB_IMPORT_FILE_NAME)
|
||||||
if (libfile?.exists() == true) {
|
if (libfile?.exists() == true) {
|
||||||
builder.setNeutralButton(R.string.load_gesture_library_button_delete) { _, _ ->
|
builder.setNeutralButton(R.string.load_gesture_library_button_delete) { _, _ ->
|
||||||
libfile?.delete()
|
libfile?.delete()
|
||||||
|
|
|
@ -86,7 +86,7 @@ class AppearanceSettingsFragment : SubScreenFragment() {
|
||||||
val metrics = requireContext().resources.displayMetrics
|
val metrics = requireContext().resources.displayMetrics
|
||||||
val widthDp = metrics.widthPixels / metrics.density
|
val widthDp = metrics.widthPixels / metrics.density
|
||||||
val heightDp = metrics.heightPixels / metrics.density
|
val heightDp = metrics.heightPixels / metrics.density
|
||||||
if (!ProductionFlags.IS_SPLIT_KEYBOARD_SUPPORTED || (min(widthDp, heightDp) < 600 && max(widthDp, heightDp) < 720)) {
|
if ((min(widthDp, heightDp) < 600 && max(widthDp, heightDp) < 720)) {
|
||||||
removePreference(Settings.PREF_ENABLE_SPLIT_KEYBOARD)
|
removePreference(Settings.PREF_ENABLE_SPLIT_KEYBOARD)
|
||||||
removePreference(Settings.PREF_SPLIT_SPACER_SCALE)
|
removePreference(Settings.PREF_SPLIT_SPACER_SCALE)
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import org.dslul.openboard.inputmethod.latin.utils.ApplicationUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "Debug mode" settings sub screen.
|
* "Debug mode" settings sub screen.
|
||||||
*
|
* <p>
|
||||||
* This settings sub screen handles a several preference options for debugging.
|
* This settings sub screen handles a several preference options for debugging.
|
||||||
*/
|
*/
|
||||||
public final class DebugSettingsFragment extends SubScreenFragment
|
public final class DebugSettingsFragment extends SubScreenFragment
|
||||||
|
@ -73,8 +73,7 @@ public final class DebugSettingsFragment extends SubScreenFragment
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceClick(@NonNull final Preference pref) {
|
public boolean onPreferenceClick(@NonNull final Preference pref) {
|
||||||
if (pref instanceof DictDumpPreference) {
|
if (pref instanceof final DictDumpPreference dictDumpPref) {
|
||||||
final DictDumpPreference dictDumpPref = (DictDumpPreference)pref;
|
|
||||||
final String dictName = dictDumpPref.mDictName;
|
final String dictName = dictDumpPref.mDictName;
|
||||||
final Intent intent = new Intent(
|
final Intent intent = new Intent(
|
||||||
DictionaryDumpBroadcastReceiver.DICTIONARY_DUMP_INTENT_ACTION);
|
DictionaryDumpBroadcastReceiver.DICTIONARY_DUMP_INTENT_ACTION);
|
||||||
|
@ -95,7 +94,7 @@ public final class DebugSettingsFragment extends SubScreenFragment
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) {
|
public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) {
|
||||||
if (key.equals(DebugSettings.PREF_DEBUG_MODE) && mDebugMode != null) {
|
if (DebugSettings.PREF_DEBUG_MODE.equals(key) && mDebugMode != null) {
|
||||||
final boolean enabled = prefs.getBoolean(DebugSettings.PREF_DEBUG_MODE, false);
|
final boolean enabled = prefs.getBoolean(DebugSettings.PREF_DEBUG_MODE, false);
|
||||||
mDebugMode.setChecked(enabled);
|
mDebugMode.setChecked(enabled);
|
||||||
findPreference(DebugSettings.PREF_SHOW_SUGGESTION_INFOS).setVisible(enabled);
|
findPreference(DebugSettings.PREF_SHOW_SUGGESTION_INFOS).setVisible(enabled);
|
||||||
|
|
|
@ -7,14 +7,13 @@
|
||||||
package org.dslul.openboard.inputmethod.latin.settings;
|
package org.dslul.openboard.inputmethod.latin.settings;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import org.dslul.openboard.inputmethod.latin.R;
|
import org.dslul.openboard.inputmethod.latin.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "Gesture typing preferences" settings sub screen.
|
* "Gesture typing preferences" settings sub screen.
|
||||||
*
|
* <p>
|
||||||
* This settings sub screen handles the following gesture typing preferences.
|
* This settings sub screen handles the following gesture typing preferences.
|
||||||
* - Enable gesture typing
|
* - Enable gesture typing
|
||||||
* - Dynamic floating preview
|
* - Dynamic floating preview
|
||||||
|
@ -36,12 +35,8 @@ public final class GestureSettingsFragment extends SubScreenFragment {
|
||||||
|
|
||||||
private void refreshSettingsEnablement() {
|
private void refreshSettingsEnablement() {
|
||||||
final SharedPreferences prefs = getSharedPreferences();
|
final SharedPreferences prefs = getSharedPreferences();
|
||||||
final Resources res = getResources();
|
setPreferenceVisible(Settings.PREF_GESTURE_PREVIEW_TRAIL, Settings.readGestureInputEnabled(prefs));
|
||||||
setPreferenceVisible(Settings.PREF_GESTURE_PREVIEW_TRAIL,
|
setPreferenceVisible(Settings.PREF_GESTURE_FLOATING_PREVIEW_TEXT, Settings.readGestureInputEnabled(prefs));
|
||||||
Settings.readGestureInputEnabled(prefs));
|
setPreferenceVisible(Settings.PREF_GESTURE_SPACE_AWARE, Settings.readGestureInputEnabled(prefs));
|
||||||
setPreferenceVisible(Settings.PREF_GESTURE_FLOATING_PREVIEW_TEXT,
|
|
||||||
Settings.readGestureInputEnabled(prefs));
|
|
||||||
setPreferenceVisible(Settings.PREF_GESTURE_SPACE_AWARE,
|
|
||||||
Settings.readGestureInputEnabled(prefs));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,10 @@ import org.dslul.openboard.inputmethod.latin.R
|
||||||
import org.dslul.openboard.inputmethod.latin.common.LocaleUtils
|
import org.dslul.openboard.inputmethod.latin.common.LocaleUtils
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.DeviceProtectedUtils
|
import org.dslul.openboard.inputmethod.latin.utils.DeviceProtectedUtils
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.SubtypeLocaleUtils
|
import org.dslul.openboard.inputmethod.latin.utils.SubtypeLocaleUtils
|
||||||
|
import org.dslul.openboard.inputmethod.latin.utils.addEnabledSubtype
|
||||||
|
import org.dslul.openboard.inputmethod.latin.utils.isAdditionalSubtype
|
||||||
|
import org.dslul.openboard.inputmethod.latin.utils.locale
|
||||||
|
import org.dslul.openboard.inputmethod.latin.utils.removeEnabledSubtype
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.showMissingDictionaryDialog
|
import org.dslul.openboard.inputmethod.latin.utils.showMissingDictionaryDialog
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.toLocale
|
import org.dslul.openboard.inputmethod.latin.utils.toLocale
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,11 @@ package org.dslul.openboard.inputmethod.latin.settings
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.text.InputType
|
import android.os.Build
|
||||||
import android.text.method.LinkMovementMethod
|
import android.text.method.LinkMovementMethod
|
||||||
import android.util.TypedValue
|
import android.util.TypedValue
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.EditText
|
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.ScrollView
|
import android.widget.ScrollView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
@ -19,7 +18,6 @@ import androidx.core.view.get
|
||||||
import androidx.core.view.isGone
|
import androidx.core.view.isGone
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.view.size
|
import androidx.core.view.size
|
||||||
import androidx.core.widget.doAfterTextChanged
|
|
||||||
import org.dslul.openboard.inputmethod.dictionarypack.DictionaryPackConstants
|
import org.dslul.openboard.inputmethod.dictionarypack.DictionaryPackConstants
|
||||||
import org.dslul.openboard.inputmethod.keyboard.KeyboardLayoutSet
|
import org.dslul.openboard.inputmethod.keyboard.KeyboardLayoutSet
|
||||||
import org.dslul.openboard.inputmethod.keyboard.KeyboardSwitcher
|
import org.dslul.openboard.inputmethod.keyboard.KeyboardSwitcher
|
||||||
|
@ -45,7 +43,7 @@ class LanguageSettingsDialog(
|
||||||
private val mainLocaleString = infos.first().subtype.locale()
|
private val mainLocaleString = infos.first().subtype.locale()
|
||||||
private val mainLocale = mainLocaleString.toLocale()
|
private val mainLocale = mainLocaleString.toLocale()
|
||||||
private var hasInternalDictForLanguage = false
|
private var hasInternalDictForLanguage = false
|
||||||
private lateinit var userDicts: MutableSet<File>
|
private val userDicts = mutableSetOf<File>()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
setTitle(infos.first().displayName)
|
setTitle(infos.first().displayName)
|
||||||
|
@ -282,9 +280,9 @@ class LanguageSettingsDialog(
|
||||||
dialog.show()
|
dialog.show()
|
||||||
(dialog.findViewById<View>(android.R.id.message) as? TextView)?.movementMethod = LinkMovementMethod.getInstance()
|
(dialog.findViewById<View>(android.R.id.message) as? TextView)?.movementMethod = LinkMovementMethod.getInstance()
|
||||||
}
|
}
|
||||||
val (_userDicts, _hasInternalDictForLanguage) = getUserAndInternalDictionaries(context, mainLocaleString)
|
val userDictsAndHasInternal = getUserAndInternalDictionaries(context, mainLocaleString)
|
||||||
userDicts = _userDicts.toMutableSet()
|
hasInternalDictForLanguage = userDictsAndHasInternal.second
|
||||||
hasInternalDictForLanguage = _hasInternalDictForLanguage
|
userDicts.addAll(userDictsAndHasInternal.first)
|
||||||
if (hasInternalDictForLanguage) {
|
if (hasInternalDictForLanguage) {
|
||||||
binding.dictionaries.addView(TextView(context, null, R.style.PreferenceCategoryTitleText).apply {
|
binding.dictionaries.addView(TextView(context, null, R.style.PreferenceCategoryTitleText).apply {
|
||||||
setText(R.string.internal_dictionary_summary)
|
setText(R.string.internal_dictionary_summary)
|
||||||
|
@ -332,8 +330,13 @@ class LanguageSettingsDialog(
|
||||||
}
|
}
|
||||||
rowBinding.languageText.setOnClickListener {
|
rowBinding.languageText.setOnClickListener {
|
||||||
if (header == null) return@setOnClickListener
|
if (header == null) return@setOnClickListener
|
||||||
|
val locale = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
context.resources.configuration.locales[0]
|
||||||
|
} else {
|
||||||
|
@Suppress("Deprecation") context.resources.configuration.locale
|
||||||
|
}
|
||||||
Builder(context)
|
Builder(context)
|
||||||
.setMessage(header.info(context.resources.configuration.locale))
|
.setMessage(header.info(locale))
|
||||||
.setPositiveButton(android.R.string.ok, null)
|
.setPositiveButton(android.R.string.ok, null)
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,11 @@ import org.dslul.openboard.inputmethod.latin.common.LocaleUtils
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.DeviceProtectedUtils
|
import org.dslul.openboard.inputmethod.latin.utils.DeviceProtectedUtils
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.DictionaryInfoUtils
|
import org.dslul.openboard.inputmethod.latin.utils.DictionaryInfoUtils
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.SubtypeLocaleUtils
|
import org.dslul.openboard.inputmethod.latin.utils.SubtypeLocaleUtils
|
||||||
|
import org.dslul.openboard.inputmethod.latin.utils.getAllAvailableSubtypes
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.getDictionaryLocales
|
import org.dslul.openboard.inputmethod.latin.utils.getDictionaryLocales
|
||||||
|
import org.dslul.openboard.inputmethod.latin.utils.getEnabledSubtypes
|
||||||
|
import org.dslul.openboard.inputmethod.latin.utils.getSystemLocales
|
||||||
|
import org.dslul.openboard.inputmethod.latin.utils.locale
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
// not a SettingsFragment, because with androidx.preferences it's very complicated or
|
// not a SettingsFragment, because with androidx.preferences it's very complicated or
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.dslul.openboard.inputmethod.latin.AudioAndHapticFeedbackManager;
|
||||||
import org.dslul.openboard.inputmethod.latin.R;
|
import org.dslul.openboard.inputmethod.latin.R;
|
||||||
import org.dslul.openboard.inputmethod.latin.RichInputMethodManager;
|
import org.dslul.openboard.inputmethod.latin.RichInputMethodManager;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.MoreKeysUtilsKt;
|
import org.dslul.openboard.inputmethod.latin.utils.MoreKeysUtilsKt;
|
||||||
|
import org.dslul.openboard.inputmethod.latin.utils.SubtypeSettingsKt;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.ToolbarUtilsKt;
|
import org.dslul.openboard.inputmethod.latin.utils.ToolbarUtilsKt;
|
||||||
|
|
||||||
import kotlin.collections.ArraysKt;
|
import kotlin.collections.ArraysKt;
|
||||||
|
|
|
@ -37,6 +37,7 @@ import org.dslul.openboard.inputmethod.latin.utils.JniUtils;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.ResourceUtils;
|
import org.dslul.openboard.inputmethod.latin.utils.ResourceUtils;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.RunInLocale;
|
import org.dslul.openboard.inputmethod.latin.utils.RunInLocale;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.StatsUtils;
|
import org.dslul.openboard.inputmethod.latin.utils.StatsUtils;
|
||||||
|
import org.dslul.openboard.inputmethod.latin.utils.SubtypeSettingsKt;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.ToolbarKey;
|
import org.dslul.openboard.inputmethod.latin.utils.ToolbarKey;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.ToolbarUtilsKt;
|
import org.dslul.openboard.inputmethod.latin.utils.ToolbarUtilsKt;
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ import android.os.Bundle;
|
||||||
import org.dslul.openboard.inputmethod.latin.permissions.PermissionsManager;
|
import org.dslul.openboard.inputmethod.latin.permissions.PermissionsManager;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.NewDictionaryAdder;
|
import org.dslul.openboard.inputmethod.latin.utils.NewDictionaryAdder;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.ActionBar;
|
import androidx.appcompat.app.ActionBar;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
|
@ -24,12 +25,7 @@ public final class SettingsActivity extends AppCompatActivity
|
||||||
private static final String DEFAULT_FRAGMENT = SettingsFragment.class.getName();
|
private static final String DEFAULT_FRAGMENT = SettingsFragment.class.getName();
|
||||||
|
|
||||||
public static final String EXTRA_ENTRY_KEY = "entry";
|
public static final String EXTRA_ENTRY_KEY = "entry";
|
||||||
public static final String EXTRA_ENTRY_VALUE_LONG_PRESS_COMMA = "long_press_comma";
|
|
||||||
public static final String EXTRA_ENTRY_VALUE_APP_ICON = "app_icon";
|
public static final String EXTRA_ENTRY_VALUE_APP_ICON = "app_icon";
|
||||||
public static final String EXTRA_ENTRY_VALUE_NOTICE_DIALOG = "important_notice";
|
|
||||||
public static final String EXTRA_ENTRY_VALUE_SYSTEM_SETTINGS = "system_settings";
|
|
||||||
|
|
||||||
private boolean mShowHomeAsUp;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(final Bundle savedState) {
|
protected void onCreate(final Bundle savedState) {
|
||||||
|
@ -68,7 +64,7 @@ public final class SettingsActivity extends AppCompatActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
PermissionsManager.get(this).onRequestPermissionsResult(requestCode, permissions, grantResults);
|
PermissionsManager.get(this).onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,14 +12,10 @@ import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.Settings.Secure;
|
import android.provider.Settings.Secure;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.inputmethod.InputMethodSubtype;
|
import android.view.inputmethod.InputMethodSubtype;
|
||||||
|
|
||||||
import androidx.activity.result.ActivityResultLauncher;
|
import androidx.activity.result.ActivityResultLauncher;
|
||||||
import androidx.activity.result.contract.ActivityResultContracts;
|
import androidx.activity.result.contract.ActivityResultContracts;
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.ActionBar;
|
import androidx.appcompat.app.ActionBar;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
@ -36,8 +32,8 @@ import org.dslul.openboard.inputmethod.latin.utils.ApplicationUtils;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.DeviceProtectedUtils;
|
import org.dslul.openboard.inputmethod.latin.utils.DeviceProtectedUtils;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.DictionaryUtilsKt;
|
import org.dslul.openboard.inputmethod.latin.utils.DictionaryUtilsKt;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.ExecutorUtils;
|
import org.dslul.openboard.inputmethod.latin.utils.ExecutorUtils;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.FeedbackUtils;
|
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.JniUtils;
|
import org.dslul.openboard.inputmethod.latin.utils.JniUtils;
|
||||||
|
import org.dslul.openboard.inputmethod.latin.utils.SubtypeSettingsKt;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
|
@ -50,13 +46,6 @@ import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
public final class SettingsFragment extends PreferenceFragmentCompat {
|
public final class SettingsFragment extends PreferenceFragmentCompat {
|
||||||
// We don't care about menu grouping.
|
|
||||||
private static final int NO_MENU_GROUP = Menu.NONE;
|
|
||||||
// The first menu item id and order.
|
|
||||||
private static final int MENU_ABOUT = Menu.FIRST;
|
|
||||||
// The second menu item id and order.
|
|
||||||
private static final int MENU_HELP_AND_FEEDBACK = Menu.FIRST + 1;
|
|
||||||
// for storing crash report files, so onActivityResult can actually use them
|
|
||||||
private final ArrayList<File> crashReportFiles = new ArrayList<>();
|
private final ArrayList<File> crashReportFiles = new ArrayList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -100,41 +89,6 @@ public final class SettingsFragment extends PreferenceFragmentCompat {
|
||||||
askAboutCrashReports();
|
askAboutCrashReports();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreateOptionsMenu(@NonNull final Menu menu, @NonNull final MenuInflater inflater) {
|
|
||||||
if (FeedbackUtils.isHelpAndFeedbackFormSupported()) {
|
|
||||||
menu.add(NO_MENU_GROUP, MENU_HELP_AND_FEEDBACK /* itemId */,
|
|
||||||
MENU_HELP_AND_FEEDBACK /* order */, R.string.help_and_feedback);
|
|
||||||
}
|
|
||||||
final int aboutResId = FeedbackUtils.getAboutKeyboardTitleResId();
|
|
||||||
if (aboutResId != 0) {
|
|
||||||
menu.add(NO_MENU_GROUP, MENU_ABOUT /* itemId */, MENU_ABOUT /* order */, aboutResId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
|
|
||||||
final Activity activity = getActivity();
|
|
||||||
if (!isUserSetupComplete(activity)) {
|
|
||||||
// If setup is not complete, it's not safe to launch Help or other activities
|
|
||||||
// because they might go to the Play Store. See b/19866981.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final int itemId = item.getItemId();
|
|
||||||
if (itemId == MENU_HELP_AND_FEEDBACK) {
|
|
||||||
FeedbackUtils.showHelpAndFeedbackForm(activity);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (itemId == MENU_ABOUT) {
|
|
||||||
final Intent aboutIntent = FeedbackUtils.getAboutKeyboardIntent(activity);
|
|
||||||
if (aboutIntent != null) {
|
|
||||||
startActivity(aboutIntent);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isUserSetupComplete(final Activity activity) {
|
private static boolean isUserSetupComplete(final Activity activity) {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.dslul.openboard.inputmethod.latin.spellcheck.AndroidSpellCheckerServi
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.AsyncResultHolder;
|
import org.dslul.openboard.inputmethod.latin.utils.AsyncResultHolder;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.MoreKeysUtilsKt;
|
import org.dslul.openboard.inputmethod.latin.utils.MoreKeysUtilsKt;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.ScriptUtils;
|
import org.dslul.openboard.inputmethod.latin.utils.ScriptUtils;
|
||||||
|
import org.dslul.openboard.inputmethod.latin.utils.SubtypeSettingsKt;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.TargetPackageInfoGetterTask;
|
import org.dslul.openboard.inputmethod.latin.utils.TargetPackageInfoGetterTask;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
|
@ -8,7 +8,6 @@ package org.dslul.openboard.inputmethod.latin.settings;
|
||||||
|
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
|
||||||
import org.dslul.openboard.inputmethod.annotations.UsedForTesting;
|
|
||||||
import org.dslul.openboard.inputmethod.keyboard.internal.MoreKeySpec;
|
import org.dslul.openboard.inputmethod.keyboard.internal.MoreKeySpec;
|
||||||
import org.dslul.openboard.inputmethod.latin.PunctuationSuggestions;
|
import org.dslul.openboard.inputmethod.latin.PunctuationSuggestions;
|
||||||
import org.dslul.openboard.inputmethod.latin.R;
|
import org.dslul.openboard.inputmethod.latin.R;
|
||||||
|
@ -61,25 +60,6 @@ public final class SpacingAndPunctuations {
|
||||||
mSuggestPuncList = PunctuationSuggestions.newPunctuationSuggestions(suggestPuncsSpec);
|
mSuggestPuncList = PunctuationSuggestions.newPunctuationSuggestions(suggestPuncsSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UsedForTesting
|
|
||||||
public SpacingAndPunctuations(final SpacingAndPunctuations model,
|
|
||||||
final int[] overrideSortedWordSeparators) {
|
|
||||||
mSortedSymbolsPrecededBySpace = model.mSortedSymbolsPrecededBySpace;
|
|
||||||
mSortedSymbolsFollowedBySpace = model.mSortedSymbolsFollowedBySpace;
|
|
||||||
mSortedSymbolsClusteringTogether = model.mSortedSymbolsClusteringTogether;
|
|
||||||
mSortedWordConnectors = model.mSortedWordConnectors;
|
|
||||||
mSortedSometimesWordConnectors = model.mSortedSometimesWordConnectors;
|
|
||||||
mSortedWordSeparators = overrideSortedWordSeparators;
|
|
||||||
mSortedSentenceTerminators = model.mSortedSentenceTerminators;
|
|
||||||
mSuggestPuncList = model.mSuggestPuncList;
|
|
||||||
mSentenceSeparator = model.mSentenceSeparator;
|
|
||||||
mAbbreviationMarker = model.mAbbreviationMarker;
|
|
||||||
mSentenceSeparatorAndSpace = model.mSentenceSeparatorAndSpace;
|
|
||||||
mCurrentLanguageHasSpaces = model.mCurrentLanguageHasSpaces;
|
|
||||||
mUsesAmericanTypography = model.mUsesAmericanTypography;
|
|
||||||
mUsesGermanRules = model.mUsesGermanRules;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isWordSeparator(final int code) {
|
public boolean isWordSeparator(final int code) {
|
||||||
return Arrays.binarySearch(mSortedWordSeparators, code) >= 0;
|
return Arrays.binarySearch(mSortedWordSeparators, code) >= 0;
|
||||||
}
|
}
|
||||||
|
@ -130,27 +110,25 @@ public final class SpacingAndPunctuations {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String dump() {
|
public String dump() {
|
||||||
final StringBuilder sb = new StringBuilder();
|
return "mSortedSymbolsPrecededBySpace = " +
|
||||||
sb.append("mSortedSymbolsPrecededBySpace = ");
|
"" + Arrays.toString(mSortedSymbolsPrecededBySpace) +
|
||||||
sb.append("" + Arrays.toString(mSortedSymbolsPrecededBySpace));
|
"\n mSortedSymbolsFollowedBySpace = " +
|
||||||
sb.append("\n mSortedSymbolsFollowedBySpace = ");
|
"" + Arrays.toString(mSortedSymbolsFollowedBySpace) +
|
||||||
sb.append("" + Arrays.toString(mSortedSymbolsFollowedBySpace));
|
"\n mSortedWordConnectors = " +
|
||||||
sb.append("\n mSortedWordConnectors = ");
|
"" + Arrays.toString(mSortedWordConnectors) +
|
||||||
sb.append("" + Arrays.toString(mSortedWordConnectors));
|
"\n mSortedWordSeparators = " +
|
||||||
sb.append("\n mSortedWordSeparators = ");
|
"" + Arrays.toString(mSortedWordSeparators) +
|
||||||
sb.append("" + Arrays.toString(mSortedWordSeparators));
|
"\n mSuggestPuncList = " +
|
||||||
sb.append("\n mSuggestPuncList = ");
|
"" + mSuggestPuncList +
|
||||||
sb.append("" + mSuggestPuncList);
|
"\n mSentenceSeparator = " +
|
||||||
sb.append("\n mSentenceSeparator = ");
|
"" + mSentenceSeparator +
|
||||||
sb.append("" + mSentenceSeparator);
|
"\n mSentenceSeparatorAndSpace = " +
|
||||||
sb.append("\n mSentenceSeparatorAndSpace = ");
|
"" + mSentenceSeparatorAndSpace +
|
||||||
sb.append("" + mSentenceSeparatorAndSpace);
|
"\n mCurrentLanguageHasSpaces = " +
|
||||||
sb.append("\n mCurrentLanguageHasSpaces = ");
|
"" + mCurrentLanguageHasSpaces +
|
||||||
sb.append("" + mCurrentLanguageHasSpaces);
|
"\n mUsesAmericanTypography = " +
|
||||||
sb.append("\n mUsesAmericanTypography = ");
|
"" + mUsesAmericanTypography +
|
||||||
sb.append("" + mUsesAmericanTypography);
|
"\n mUsesGermanRules = " +
|
||||||
sb.append("\n mUsesGermanRules = ");
|
"" + mUsesGermanRules;
|
||||||
sb.append("" + mUsesGermanRules);
|
|
||||||
return sb.toString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,14 +11,12 @@ import android.app.backup.BackupManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.Log;
|
import org.dslul.openboard.inputmethod.latin.utils.Log;
|
||||||
|
|
||||||
import androidx.appcompat.app.ActionBar;
|
import androidx.appcompat.app.ActionBar;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.preference.ListPreference;
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceCategory;
|
import androidx.preference.PreferenceCategory;
|
||||||
import androidx.preference.PreferenceFragmentCompat;
|
import androidx.preference.PreferenceFragmentCompat;
|
||||||
|
@ -53,19 +51,6 @@ public abstract class SubScreenFragment extends PreferenceFragmentCompat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void updateListPreferenceSummaryToCurrentValue(final String prefKey,
|
|
||||||
final PreferenceScreen screen) {
|
|
||||||
// Because the "%s" summary trick of {@link ListPreference} doesn't work properly before
|
|
||||||
// KitKat, we need to update the summary programmatically.
|
|
||||||
final ListPreference listPreference = (ListPreference)screen.findPreference(prefKey);
|
|
||||||
if (listPreference == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final CharSequence[] entries = listPreference.getEntries();
|
|
||||||
final int entryIndex = listPreference.findIndexOfValue(listPreference.getValue());
|
|
||||||
listPreference.setSummary(entryIndex < 0 ? null : entries[entryIndex]);
|
|
||||||
}
|
|
||||||
|
|
||||||
final void setPreferenceVisible(final String prefKey, final boolean visible) {
|
final void setPreferenceVisible(final String prefKey, final boolean visible) {
|
||||||
setPreferenceVisible(prefKey, visible, getPreferenceScreen());
|
setPreferenceVisible(prefKey, visible, getPreferenceScreen());
|
||||||
}
|
}
|
||||||
|
@ -74,24 +59,10 @@ public abstract class SubScreenFragment extends PreferenceFragmentCompat
|
||||||
removePreference(prefKey, getPreferenceScreen());
|
removePreference(prefKey, getPreferenceScreen());
|
||||||
}
|
}
|
||||||
|
|
||||||
final void updateListPreferenceSummaryToCurrentValue(final String prefKey) {
|
|
||||||
updateListPreferenceSummaryToCurrentValue(prefKey, getPreferenceScreen());
|
|
||||||
}
|
|
||||||
|
|
||||||
final SharedPreferences getSharedPreferences() {
|
final SharedPreferences getSharedPreferences() {
|
||||||
return getPreferenceManager().getSharedPreferences();
|
return getPreferenceManager().getSharedPreferences();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the application name to display on the UI.
|
|
||||||
*/
|
|
||||||
final String getApplicationName() {
|
|
||||||
final Context context = getActivity();
|
|
||||||
final Resources res = getResources();
|
|
||||||
final int applicationLabelRes = context.getApplicationInfo().labelRes;
|
|
||||||
return res.getString(applicationLabelRes);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreatePreferences(final Bundle savedInstanceState, final String s) {
|
public void onCreatePreferences(final Bundle savedInstanceState, final String s) {
|
||||||
// this must be overridden, but is useless, because it's called during onCreate
|
// this must be overridden, but is useless, because it's called during onCreate
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2014 The Android Open Source Project
|
|
||||||
* modified
|
|
||||||
* SPDX-License-Identifier: Apache-2.0 AND GPL-3.0-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.dslul.openboard.inputmethod.latin.settings;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.Fragment;
|
|
||||||
import android.app.FragmentManager;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test activity to use when testing preference fragments. <br/>
|
|
||||||
* Usage: <br/>
|
|
||||||
* Create an ActivityInstrumentationTestCase2 for this activity
|
|
||||||
* and call setIntent() with an intent that specifies the fragment to load in the activity.
|
|
||||||
* The fragment can then be obtained from this activity and used for testing/verification.
|
|
||||||
*/
|
|
||||||
public final class TestFragmentActivity extends Activity {
|
|
||||||
/**
|
|
||||||
* The fragment name that should be loaded when starting this activity.
|
|
||||||
* This must be specified when starting this activity, as this activity is only
|
|
||||||
* meant to test fragments from instrumentation tests.
|
|
||||||
*/
|
|
||||||
public static final String EXTRA_SHOW_FRAGMENT = "show_fragment";
|
|
||||||
|
|
||||||
public Fragment mFragment;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(final Bundle savedState) {
|
|
||||||
super.onCreate(savedState);
|
|
||||||
final Intent intent = getIntent();
|
|
||||||
final String fragmentName = intent.getStringExtra(EXTRA_SHOW_FRAGMENT);
|
|
||||||
if (fragmentName == null) {
|
|
||||||
throw new IllegalArgumentException("No fragment name specified for testing");
|
|
||||||
}
|
|
||||||
|
|
||||||
mFragment = Fragment.instantiate(this, fragmentName);
|
|
||||||
FragmentManager fragmentManager = getFragmentManager();
|
|
||||||
fragmentManager.beginTransaction().add(mFragment, fragmentName).commit();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -30,10 +30,10 @@ import org.dslul.openboard.inputmethod.latin.common.StringUtils;
|
||||||
import org.dslul.openboard.inputmethod.latin.define.DebugFlags;
|
import org.dslul.openboard.inputmethod.latin.define.DebugFlags;
|
||||||
import com.android.inputmethod.latin.utils.BinaryDictionaryUtils;
|
import com.android.inputmethod.latin.utils.BinaryDictionaryUtils;
|
||||||
|
|
||||||
import org.dslul.openboard.inputmethod.latin.settings.SubtypeSettingsKt;
|
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.DeviceProtectedUtils;
|
import org.dslul.openboard.inputmethod.latin.utils.DeviceProtectedUtils;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.ScriptUtils;
|
import org.dslul.openboard.inputmethod.latin.utils.ScriptUtils;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.StatsUtils;
|
import org.dslul.openboard.inputmethod.latin.utils.StatsUtils;
|
||||||
|
import org.dslul.openboard.inputmethod.latin.utils.SubtypeSettingsKt;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.SuggestionResults;
|
import org.dslul.openboard.inputmethod.latin.utils.SuggestionResults;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
|
@ -58,7 +58,7 @@ import org.dslul.openboard.inputmethod.latin.settings.Settings;
|
||||||
import org.dslul.openboard.inputmethod.latin.settings.SettingsValues;
|
import org.dslul.openboard.inputmethod.latin.settings.SettingsValues;
|
||||||
import org.dslul.openboard.inputmethod.latin.suggestions.MoreSuggestionsView.MoreSuggestionsListener;
|
import org.dslul.openboard.inputmethod.latin.suggestions.MoreSuggestionsView.MoreSuggestionsListener;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.DeviceProtectedUtils;
|
import org.dslul.openboard.inputmethod.latin.utils.DeviceProtectedUtils;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.DialogUtils;
|
import org.dslul.openboard.inputmethod.latin.utils.DialogUtilsKt;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.ToolbarKey;
|
import org.dslul.openboard.inputmethod.latin.utils.ToolbarKey;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.ToolbarUtilsKt;
|
import org.dslul.openboard.inputmethod.latin.utils.ToolbarUtilsKt;
|
||||||
|
|
||||||
|
@ -439,7 +439,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
// apparently toast is not working on some Android versions, probably
|
// apparently toast is not working on some Android versions, probably
|
||||||
// Android 13 with the notification permission
|
// Android 13 with the notification permission
|
||||||
// Toast.makeText(getContext(), text, Toast.LENGTH_LONG).show();
|
// Toast.makeText(getContext(), text, Toast.LENGTH_LONG).show();
|
||||||
final PopupMenu uglyWorkaround = new PopupMenu(DialogUtils.getPlatformDialogThemeContext(getContext()), wordView);
|
final PopupMenu uglyWorkaround = new PopupMenu(DialogUtilsKt.getPlatformDialogThemeContext(getContext()), wordView);
|
||||||
uglyWorkaround.getMenu().add(Menu.NONE, 1, Menu.NONE, text);
|
uglyWorkaround.getMenu().add(Menu.NONE, 1, Menu.NONE, text);
|
||||||
uglyWorkaround.show();
|
uglyWorkaround.show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ import org.dslul.openboard.inputmethod.keyboard.internal.keyboard_parser.MORE_KE
|
||||||
import org.dslul.openboard.inputmethod.keyboard.internal.keyboard_parser.SimpleKeyboardParser
|
import org.dslul.openboard.inputmethod.keyboard.internal.keyboard_parser.SimpleKeyboardParser
|
||||||
import org.dslul.openboard.inputmethod.keyboard.internal.keyboard_parser.addLocaleKeyTextsToParams
|
import org.dslul.openboard.inputmethod.keyboard.internal.keyboard_parser.addLocaleKeyTextsToParams
|
||||||
import org.dslul.openboard.inputmethod.latin.R
|
import org.dslul.openboard.inputmethod.latin.R
|
||||||
import org.dslul.openboard.inputmethod.latin.settings.infoDialog
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.math.BigInteger
|
import java.math.BigInteger
|
||||||
|
|
|
@ -6,26 +6,10 @@
|
||||||
|
|
||||||
package org.dslul.openboard.inputmethod.latin.utils;
|
package org.dslul.openboard.inputmethod.latin.utils;
|
||||||
|
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.Log;
|
|
||||||
|
|
||||||
import org.dslul.openboard.inputmethod.latin.define.DebugFlags;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class for logging and debugging utility methods.
|
* A class for logging and debugging utility methods.
|
||||||
*/
|
*/
|
||||||
public final class DebugLogUtils {
|
public final class DebugLogUtils {
|
||||||
private final static String TAG = DebugLogUtils.class.getSimpleName();
|
|
||||||
private final static boolean sDBG = DebugFlags.DEBUG_ENABLED;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calls .toString() on its non-null argument or returns "null"
|
|
||||||
* @param o the object to convert to a string
|
|
||||||
* @return the result of .toString() or null
|
|
||||||
*/
|
|
||||||
public static String s(final Object o) {
|
|
||||||
return null == o ? "null" : o.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the string representation of the current stack trace, for debugging purposes.
|
* Get the string representation of the current stack trace, for debugging purposes.
|
||||||
* @return a readable, carriage-return-separated string for the current stack trace.
|
* @return a readable, carriage-return-separated string for the current stack trace.
|
||||||
|
@ -47,7 +31,7 @@ public final class DebugLogUtils {
|
||||||
final StackTraceElement[] frames = e.getStackTrace();
|
final StackTraceElement[] frames = e.getStackTrace();
|
||||||
// Start at 1 because the first frame is here and we don't care about it
|
// Start at 1 because the first frame is here and we don't care about it
|
||||||
for (int j = 1; j < frames.length && j < limit + 1; ++j) {
|
for (int j = 1; j < frames.length && j < limit + 1; ++j) {
|
||||||
sb.append(frames[j].toString() + "\n");
|
sb.append(frames[j].toString()).append("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
|
@ -66,40 +50,4 @@ public final class DebugLogUtils {
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper log method to ease null-checks and adding spaces.
|
|
||||||
*
|
|
||||||
* This sends all arguments to the log, separated by spaces. Any null argument is converted
|
|
||||||
* to the "null" string. It uses a very visible tag and log level for debugging purposes.
|
|
||||||
*
|
|
||||||
* @param args the stuff to send to the log
|
|
||||||
*/
|
|
||||||
public static void l(final Object... args) {
|
|
||||||
if (!sDBG) return;
|
|
||||||
final StringBuilder sb = new StringBuilder();
|
|
||||||
for (final Object o : args) {
|
|
||||||
sb.append(s(o));
|
|
||||||
sb.append(" ");
|
|
||||||
}
|
|
||||||
Log.e(TAG, sb.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper log method to put stuff in red.
|
|
||||||
*
|
|
||||||
* This does the same as #l but prints in red
|
|
||||||
*
|
|
||||||
* @param args the stuff to send to the log
|
|
||||||
*/
|
|
||||||
public static void r(final Object... args) {
|
|
||||||
if (!sDBG) return;
|
|
||||||
final StringBuilder sb = new StringBuilder("\u001B[31m");
|
|
||||||
for (final Object o : args) {
|
|
||||||
sb.append(s(o));
|
|
||||||
sb.append(" ");
|
|
||||||
}
|
|
||||||
sb.append("\u001B[0m");
|
|
||||||
Log.e(TAG, sb.toString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2014 The Android Open Source Project
|
|
||||||
* modified
|
|
||||||
* SPDX-License-Identifier: Apache-2.0 AND GPL-3.0-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.dslul.openboard.inputmethod.latin.utils;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.view.ContextThemeWrapper;
|
|
||||||
|
|
||||||
import org.dslul.openboard.inputmethod.latin.R;
|
|
||||||
|
|
||||||
public final class DialogUtils {
|
|
||||||
private 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.platformActivityTheme);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +1,15 @@
|
||||||
package org.dslul.openboard.inputmethod.latin.settings
|
package org.dslul.openboard.inputmethod.latin.utils
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
|
import androidx.appcompat.view.ContextThemeWrapper
|
||||||
|
import org.dslul.openboard.inputmethod.latin.R
|
||||||
|
|
||||||
// maybe rather put to DialogUtils (and convert that to kotlin)
|
fun getPlatformDialogThemeContext(context: 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 ContextThemeWrapper(context, R.style.platformActivityTheme)
|
||||||
|
}
|
||||||
|
|
||||||
fun confirmDialog(context: Context, message: String, confirmButton: String, onConfirmed: (() -> Unit)) {
|
fun confirmDialog(context: Context, message: String, confirmButton: String, onConfirmed: (() -> Unit)) {
|
||||||
AlertDialog.Builder(context)
|
AlertDialog.Builder(context)
|
||||||
|
@ -19,6 +25,7 @@ fun infoDialog(context: Context, messageId: Int) {
|
||||||
.setNegativeButton(android.R.string.ok, null)
|
.setNegativeButton(android.R.string.ok, null)
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun infoDialog(context: Context, message: String) {
|
fun infoDialog(context: Context, message: String) {
|
||||||
AlertDialog.Builder(context)
|
AlertDialog.Builder(context)
|
||||||
.setMessage(message)
|
.setMessage(message)
|
|
@ -11,8 +11,6 @@ import androidx.core.content.edit
|
||||||
import org.dslul.openboard.inputmethod.latin.BinaryDictionaryGetter
|
import org.dslul.openboard.inputmethod.latin.BinaryDictionaryGetter
|
||||||
import org.dslul.openboard.inputmethod.latin.R
|
import org.dslul.openboard.inputmethod.latin.R
|
||||||
import org.dslul.openboard.inputmethod.latin.settings.Settings
|
import org.dslul.openboard.inputmethod.latin.settings.Settings
|
||||||
import org.dslul.openboard.inputmethod.latin.settings.getEnabledSubtypes
|
|
||||||
import org.dslul.openboard.inputmethod.latin.settings.locale
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.collections.HashSet
|
import kotlin.collections.HashSet
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2013 The Android Open Source Project
|
|
||||||
* modified
|
|
||||||
* SPDX-License-Identifier: Apache-2.0 AND GPL-3.0-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.dslul.openboard.inputmethod.latin.utils;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public class FeedbackUtils {
|
|
||||||
public static boolean isHelpAndFeedbackFormSupported() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void showHelpAndFeedbackForm(Context context) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getAboutKeyboardTitleResId() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Intent getAboutKeyboardIntent(Context context) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2013 The Android Open Source Project
|
|
||||||
* modified
|
|
||||||
* SPDX-License-Identifier: Apache-2.0 AND GPL-3.0-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.dslul.openboard.inputmethod.latin.utils;
|
|
||||||
|
|
||||||
import org.dslul.openboard.inputmethod.latin.settings.AdvancedSettingsFragment;
|
|
||||||
import org.dslul.openboard.inputmethod.latin.settings.AppearanceSettingsFragment;
|
|
||||||
import org.dslul.openboard.inputmethod.latin.settings.CorrectionSettingsFragment;
|
|
||||||
import org.dslul.openboard.inputmethod.latin.settings.DebugSettingsFragment;
|
|
||||||
import org.dslul.openboard.inputmethod.latin.settings.GestureSettingsFragment;
|
|
||||||
import org.dslul.openboard.inputmethod.latin.settings.LanguageSettingsFragment;
|
|
||||||
import org.dslul.openboard.inputmethod.latin.settings.PreferencesSettingsFragment;
|
|
||||||
import org.dslul.openboard.inputmethod.latin.settings.SettingsFragment;
|
|
||||||
import org.dslul.openboard.inputmethod.latin.settings.AboutFragment;
|
|
||||||
import org.dslul.openboard.inputmethod.latin.spellcheck.SpellCheckerSettingsFragment;
|
|
||||||
import org.dslul.openboard.inputmethod.latin.userdictionary.UserDictionaryAddWordFragment;
|
|
||||||
import org.dslul.openboard.inputmethod.latin.userdictionary.UserDictionaryList;
|
|
||||||
import org.dslul.openboard.inputmethod.latin.userdictionary.UserDictionaryLocalePicker;
|
|
||||||
import org.dslul.openboard.inputmethod.latin.userdictionary.UserDictionarySettings;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
public class FragmentUtils {
|
|
||||||
private static final HashSet<String> sLatinImeFragments = new HashSet<>();
|
|
||||||
static {
|
|
||||||
sLatinImeFragments.add(PreferencesSettingsFragment.class.getName());
|
|
||||||
sLatinImeFragments.add(AppearanceSettingsFragment.class.getName());
|
|
||||||
sLatinImeFragments.add(GestureSettingsFragment.class.getName());
|
|
||||||
sLatinImeFragments.add(CorrectionSettingsFragment.class.getName());
|
|
||||||
sLatinImeFragments.add(AdvancedSettingsFragment.class.getName());
|
|
||||||
sLatinImeFragments.add(DebugSettingsFragment.class.getName());
|
|
||||||
sLatinImeFragments.add(SettingsFragment.class.getName());
|
|
||||||
sLatinImeFragments.add(AboutFragment.class.getName());
|
|
||||||
sLatinImeFragments.add(SpellCheckerSettingsFragment.class.getName());
|
|
||||||
sLatinImeFragments.add(UserDictionaryAddWordFragment.class.getName());
|
|
||||||
sLatinImeFragments.add(UserDictionaryList.class.getName());
|
|
||||||
sLatinImeFragments.add(UserDictionaryLocalePicker.class.getName());
|
|
||||||
sLatinImeFragments.add(UserDictionarySettings.class.getName());
|
|
||||||
sLatinImeFragments.add(LanguageSettingsFragment.class.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isValidFragment(String fragmentName) {
|
|
||||||
return sLatinImeFragments.contains(fragmentName);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -58,7 +58,7 @@ fun createInputMethodPickerDialog(latinIme: LatinIME, richImm: RichInputMethodMa
|
||||||
items.add(SpannableStringBuilder().append(title).append(subtitle))
|
items.add(SpannableStringBuilder().append(title).append(subtitle))
|
||||||
}
|
}
|
||||||
|
|
||||||
val dialog = AlertDialog.Builder(DialogUtils.getPlatformDialogThemeContext(latinIme))
|
val dialog = AlertDialog.Builder(getPlatformDialogThemeContext(latinIme))
|
||||||
.setTitle(R.string.select_input_method)
|
.setTitle(R.string.select_input_method)
|
||||||
.setSingleChoiceItems(items.toTypedArray(), currentSubtypeIndex) { di, i ->
|
.setSingleChoiceItems(items.toTypedArray(), currentSubtypeIndex) { di, i ->
|
||||||
di.dismiss()
|
di.dismiss()
|
||||||
|
|
|
@ -7,14 +7,16 @@
|
||||||
package org.dslul.openboard.inputmethod.latin.utils;
|
package org.dslul.openboard.inputmethod.latin.utils;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.Log;
|
|
||||||
|
|
||||||
import org.dslul.openboard.inputmethod.latin.BuildConfig;
|
import org.dslul.openboard.inputmethod.latin.BuildConfig;
|
||||||
import org.dslul.openboard.inputmethod.latin.define.JniLibName;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
public final class JniUtils {
|
public final class JniUtils {
|
||||||
private static final String TAG = JniUtils.class.getSimpleName();
|
private static final String TAG = JniUtils.class.getSimpleName();
|
||||||
|
public static final String JNI_LIB_NAME = "jni_latinime";
|
||||||
|
public static final String JNI_LIB_NAME_GOOGLE = "jni_latinimegoogle";
|
||||||
|
public static final String JNI_LIB_IMPORT_FILE_NAME = "libjni_latinime.so";
|
||||||
|
|
||||||
|
|
||||||
public static boolean sHaveGestureLib = false;
|
public static boolean sHaveGestureLib = false;
|
||||||
static {
|
static {
|
||||||
|
@ -28,10 +30,10 @@ public final class JniUtils {
|
||||||
// fall back to hardcoded default path, may not work on all phones
|
// fall back to hardcoded default path, may not work on all phones
|
||||||
filesDir = "/data/data/" + BuildConfig.APPLICATION_ID + "/files";
|
filesDir = "/data/data/" + BuildConfig.APPLICATION_ID + "/files";
|
||||||
}
|
}
|
||||||
final File userSuppliedLibrary = new File(filesDir + File.separator + JniLibName.JNI_LIB_IMPORT_FILE_NAME);
|
final File userSuppliedLibrary = new File(filesDir + File.separator + JNI_LIB_IMPORT_FILE_NAME);
|
||||||
if (userSuppliedLibrary.exists()) {
|
if (userSuppliedLibrary.exists()) {
|
||||||
try {
|
try {
|
||||||
System.load(filesDir + File.separator + JniLibName.JNI_LIB_IMPORT_FILE_NAME);
|
System.load(filesDir + File.separator + JNI_LIB_IMPORT_FILE_NAME);
|
||||||
sHaveGestureLib = true; // this is an assumption, any way to actually check?
|
sHaveGestureLib = true; // this is an assumption, any way to actually check?
|
||||||
} catch (Throwable t) { // catch everything, maybe provided library simply doesn't work
|
} catch (Throwable t) { // catch everything, maybe provided library simply doesn't work
|
||||||
Log.w(TAG, "Could not load user-supplied library", t);
|
Log.w(TAG, "Could not load user-supplied library", t);
|
||||||
|
@ -41,18 +43,18 @@ public final class JniUtils {
|
||||||
if (!sHaveGestureLib) {
|
if (!sHaveGestureLib) {
|
||||||
// try loading google library, will fail unless it's in system and this is a system app
|
// try loading google library, will fail unless it's in system and this is a system app
|
||||||
try {
|
try {
|
||||||
System.loadLibrary(JniLibName.JNI_LIB_NAME_GOOGLE);
|
System.loadLibrary(JNI_LIB_NAME_GOOGLE);
|
||||||
sHaveGestureLib = true;
|
sHaveGestureLib = true;
|
||||||
} catch (UnsatisfiedLinkError ul) {
|
} catch (UnsatisfiedLinkError ul) {
|
||||||
Log.w(TAG, "Could not load system glide typing library " + JniLibName.JNI_LIB_NAME_GOOGLE, ul);
|
Log.w(TAG, "Could not load system glide typing library " + JNI_LIB_NAME_GOOGLE, ul);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!sHaveGestureLib) {
|
if (!sHaveGestureLib) {
|
||||||
// try loading built-in library
|
// try loading built-in library
|
||||||
try {
|
try {
|
||||||
System.loadLibrary(JniLibName.JNI_LIB_NAME);
|
System.loadLibrary(JNI_LIB_NAME);
|
||||||
} catch (UnsatisfiedLinkError ul) {
|
} catch (UnsatisfiedLinkError ul) {
|
||||||
Log.w(TAG, "Could not load native library " + JniLibName.JNI_LIB_NAME, ul);
|
Log.w(TAG, "Could not load native library " + JNI_LIB_NAME, ul);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
package org.dslul.openboard.inputmethod.latin.settings
|
package org.dslul.openboard.inputmethod.latin.utils
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
|
@ -11,15 +11,10 @@ import android.widget.Toast
|
||||||
import androidx.core.app.LocaleManagerCompat
|
import androidx.core.app.LocaleManagerCompat
|
||||||
import androidx.core.content.edit
|
import androidx.core.content.edit
|
||||||
import org.dslul.openboard.inputmethod.keyboard.KeyboardSwitcher
|
import org.dslul.openboard.inputmethod.keyboard.KeyboardSwitcher
|
||||||
import org.dslul.openboard.inputmethod.latin.BuildConfig
|
|
||||||
import org.dslul.openboard.inputmethod.latin.R
|
import org.dslul.openboard.inputmethod.latin.R
|
||||||
import org.dslul.openboard.inputmethod.latin.RichInputMethodManager
|
import org.dslul.openboard.inputmethod.latin.RichInputMethodManager
|
||||||
import org.dslul.openboard.inputmethod.latin.define.DebugFlags
|
import org.dslul.openboard.inputmethod.latin.define.DebugFlags
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.AdditionalSubtypeUtils
|
import org.dslul.openboard.inputmethod.latin.settings.Settings
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.CUSTOM_LAYOUT_PREFIX
|
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.DeviceProtectedUtils
|
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.Log
|
|
||||||
import org.dslul.openboard.inputmethod.latin.utils.SubtypeLocaleUtils
|
|
||||||
import org.xmlpull.v1.XmlPullParser
|
import org.xmlpull.v1.XmlPullParser
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
import java.util.*
|
|
@ -37,8 +37,7 @@ public final class ViewLayoutUtils {
|
||||||
public static void placeViewAt(final View view, final int x, final int y, final int w,
|
public static void placeViewAt(final View view, final int x, final int y, final int w,
|
||||||
final int h) {
|
final int h) {
|
||||||
final ViewGroup.LayoutParams lp = view.getLayoutParams();
|
final ViewGroup.LayoutParams lp = view.getLayoutParams();
|
||||||
if (lp instanceof MarginLayoutParams) {
|
if (lp instanceof final MarginLayoutParams marginLayoutParams) {
|
||||||
final MarginLayoutParams marginLayoutParams = (MarginLayoutParams)lp;
|
|
||||||
marginLayoutParams.width = w;
|
marginLayoutParams.width = w;
|
||||||
marginLayoutParams.height = h;
|
marginLayoutParams.height = h;
|
||||||
marginLayoutParams.setMargins(x, y, 0, 0);
|
marginLayoutParams.setMargins(x, y, 0, 0);
|
||||||
|
@ -63,14 +62,12 @@ public final class ViewLayoutUtils {
|
||||||
|
|
||||||
public static void updateLayoutGravityOf(final View view, final int layoutGravity) {
|
public static void updateLayoutGravityOf(final View view, final int layoutGravity) {
|
||||||
final ViewGroup.LayoutParams lp = view.getLayoutParams();
|
final ViewGroup.LayoutParams lp = view.getLayoutParams();
|
||||||
if (lp instanceof LinearLayout.LayoutParams) {
|
if (lp instanceof final LinearLayout.LayoutParams params) {
|
||||||
final LinearLayout.LayoutParams params = (LinearLayout.LayoutParams)lp;
|
|
||||||
if (params.gravity != layoutGravity) {
|
if (params.gravity != layoutGravity) {
|
||||||
params.gravity = layoutGravity;
|
params.gravity = layoutGravity;
|
||||||
view.setLayoutParams(params);
|
view.setLayoutParams(params);
|
||||||
}
|
}
|
||||||
} else if (lp instanceof FrameLayout.LayoutParams) {
|
} else if (lp instanceof final FrameLayout.LayoutParams params) {
|
||||||
final FrameLayout.LayoutParams params = (FrameLayout.LayoutParams)lp;
|
|
||||||
if (params.gravity != layoutGravity) {
|
if (params.gravity != layoutGravity) {
|
||||||
params.gravity = layoutGravity;
|
params.gravity = layoutGravity;
|
||||||
view.setLayoutParams(params);
|
view.setLayoutParams(params);
|
||||||
|
|
|
@ -18,36 +18,24 @@ public final class XmlParseUtils {
|
||||||
// This utility class is not publicly instantiable.
|
// This utility class is not publicly instantiable.
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public static class ParseException extends XmlPullParserException {
|
public static class ParseException extends XmlPullParserException {
|
||||||
public ParseException(final String msg, final XmlPullParser parser) {
|
public ParseException(final String msg, final XmlPullParser parser) {
|
||||||
super(msg + " at " + parser.getPositionDescription());
|
super(msg + " at " + parser.getPositionDescription());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public static final class IllegalStartTag extends ParseException {
|
public static final class IllegalStartTag extends ParseException {
|
||||||
public IllegalStartTag(final XmlPullParser parser, final String tag, final String parent) {
|
public IllegalStartTag(final XmlPullParser parser, final String tag, final String parent) {
|
||||||
super("Illegal start tag " + tag + " in " + parent, parser);
|
super("Illegal start tag " + tag + " in " + parent, parser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public static final class IllegalEndTag extends ParseException {
|
public static final class IllegalEndTag extends ParseException {
|
||||||
public IllegalEndTag(final XmlPullParser parser, final String tag, final String parent) {
|
public IllegalEndTag(final XmlPullParser parser, final String tag, final String parent) {
|
||||||
super("Illegal end tag " + tag + " in " + parent, parser);
|
super("Illegal end tag " + tag + " in " + parent, parser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public static final class IllegalAttribute extends ParseException {
|
|
||||||
public IllegalAttribute(final XmlPullParser parser, final String tag,
|
|
||||||
final String attribute) {
|
|
||||||
super("Tag " + tag + " has illegal attribute " + attribute, parser);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public static final class NonEmptyTag extends ParseException{
|
public static final class NonEmptyTag extends ParseException{
|
||||||
public NonEmptyTag(final XmlPullParser parser, final String tag) {
|
public NonEmptyTag(final XmlPullParser parser, final String tag) {
|
||||||
super(tag + " must be empty tag", parser);
|
super(tag + " must be empty tag", parser);
|
||||||
|
|
|
@ -101,7 +101,7 @@
|
||||||
zz: QWERTY/qwerty
|
zz: QWERTY/qwerty
|
||||||
-->
|
-->
|
||||||
<!-- TODO: use <lang>_keyboard icon instead of a common keyboard icon. -->
|
<!-- TODO: use <lang>_keyboard icon instead of a common keyboard icon. -->
|
||||||
<!-- TODO: Remove "AsciiCapable" from the extra values when we can stop supporting JB-MR1 -->
|
<!-- "AsciiCapable" is kept in extra values, as per recommendation in Android documentation -->
|
||||||
<!-- Note: SupportTouchPositionCorrection extra value is obsolete and maintained for backward
|
<!-- Note: SupportTouchPositionCorrection extra value is obsolete and maintained for backward
|
||||||
compatibility. -->
|
compatibility. -->
|
||||||
<!-- If IME doesn't have an applicable subtype, the first subtype will be used as a default
|
<!-- If IME doesn't have an applicable subtype, the first subtype will be used as a default
|
||||||
|
@ -437,7 +437,7 @@
|
||||||
android:imeSubtypeExtraValue="KeyboardLayoutSet=hindi_compact,EmojiCapable"
|
android:imeSubtypeExtraValue="KeyboardLayoutSet=hindi_compact,EmojiCapable"
|
||||||
android:isAsciiCapable="false"
|
android:isAsciiCapable="false"
|
||||||
/>
|
/>
|
||||||
<!-- TODO: This Hinglish keyboard is a preliminary layout.
|
<!-- This Hinglish keyboard is a preliminary layout.
|
||||||
This isn't based on the final specification.
|
This isn't based on the final specification.
|
||||||
Was disabled because there is no LM yet, and this layout does not offer anything different. -->
|
Was disabled because there is no LM yet, and this layout does not offer anything different. -->
|
||||||
<subtype android:icon="@drawable/ic_ime_switcher"
|
<subtype android:icon="@drawable/ic_ime_switcher"
|
||||||
|
@ -804,7 +804,7 @@
|
||||||
android:imeSubtypeExtraValue="KeyboardLayoutSet=sr,SupportTouchPositionCorrection,EmojiCapable"
|
android:imeSubtypeExtraValue="KeyboardLayoutSet=sr,SupportTouchPositionCorrection,EmojiCapable"
|
||||||
android:isAsciiCapable="false"
|
android:isAsciiCapable="false"
|
||||||
/>
|
/>
|
||||||
<!-- TODO: This Serbian Latin keyboard is a preliminary layout.
|
<!-- This Serbian Latin keyboard is a preliminary layout.
|
||||||
This isn't based on the final specification. -->
|
This isn't based on the final specification. -->
|
||||||
<subtype android:icon="@drawable/ic_ime_switcher"
|
<subtype android:icon="@drawable/ic_ime_switcher"
|
||||||
android:label="@string/subtype_sr_ZZ"
|
android:label="@string/subtype_sr_ZZ"
|
||||||
|
@ -917,7 +917,7 @@
|
||||||
android:imeSubtypeExtraValue="KeyboardLayoutSet=urdu,EmojiCapable"
|
android:imeSubtypeExtraValue="KeyboardLayoutSet=urdu,EmojiCapable"
|
||||||
android:isAsciiCapable="false"
|
android:isAsciiCapable="false"
|
||||||
/>
|
/>
|
||||||
<!-- TODO: This Uzbek keyboard is a preliminary layout.
|
<!-- This Uzbek keyboard is a preliminary layout.
|
||||||
This isn't based on the final specification. -->
|
This isn't based on the final specification. -->
|
||||||
<subtype android:icon="@drawable/ic_ime_switcher"
|
<subtype android:icon="@drawable/ic_ime_switcher"
|
||||||
android:label="@string/subtype_generic"
|
android:label="@string/subtype_generic"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue