mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-01 20:34:30 +00:00
remove unused code
This commit is contained in:
parent
958e253c87
commit
fa04c393c8
4 changed files with 4 additions and 109 deletions
|
@ -1,29 +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.compat
|
||||
|
||||
import android.content.pm.PackageInfo
|
||||
|
||||
/**
|
||||
* A class to encapsulate work-arounds specific to particular apps.
|
||||
*/
|
||||
class AppWorkaroundsUtils(private val mPackageInfo: PackageInfo?) {
|
||||
override fun toString(): String {
|
||||
if (mPackageInfo?.applicationInfo == null) {
|
||||
return ""
|
||||
}
|
||||
val s = StringBuilder()
|
||||
s.append("Target application : ")
|
||||
.append(mPackageInfo.applicationInfo.name)
|
||||
.append("\nPackage : ")
|
||||
.append(mPackageInfo.applicationInfo.packageName)
|
||||
.append("\nTarget app sdk version : ")
|
||||
.append(mPackageInfo.applicationInfo.targetSdkVersion)
|
||||
return s.toString()
|
||||
}
|
||||
|
||||
}
|
|
@ -16,11 +16,10 @@ import android.net.Uri;
|
|||
import org.dslul.openboard.inputmethod.latin.utils.Log;
|
||||
|
||||
import org.dslul.openboard.inputmethod.dictionarypack.DictionaryPackConstants;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.TargetPackageInfoGetterTask;
|
||||
|
||||
/**
|
||||
* Receives broadcasts pertaining to dictionary management and takes the appropriate action.
|
||||
*
|
||||
* <p>
|
||||
* This object receives three types of broadcasts.
|
||||
* - Package installed/added. When a dictionary provider application is added or removed, we
|
||||
* need to query the dictionaries.
|
||||
|
@ -55,7 +54,7 @@ public final class DictionaryPackInstallBroadcastReceiver extends BroadcastRecei
|
|||
final PackageManager manager = context.getPackageManager();
|
||||
|
||||
// We need to reread the dictionary if a new dictionary package is installed.
|
||||
if (action.equals(Intent.ACTION_PACKAGE_ADDED)) {
|
||||
if (Intent.ACTION_PACKAGE_ADDED.equals(action)) {
|
||||
if (null == mService) {
|
||||
Log.e(TAG, "Called with intent " + action + " but we don't know the service: this "
|
||||
+ "should never happen");
|
||||
|
@ -65,8 +64,6 @@ public final class DictionaryPackInstallBroadcastReceiver extends BroadcastRecei
|
|||
if (null == packageUri) return; // No package name : we can't do anything
|
||||
final String packageName = packageUri.getSchemeSpecificPart();
|
||||
if (null == packageName) return;
|
||||
// TODO: do this in a more appropriate place
|
||||
TargetPackageInfoGetterTask.removeCachedPackageInfo(packageName);
|
||||
final PackageInfo packageInfo;
|
||||
try {
|
||||
packageInfo = manager.getPackageInfo(packageName, PackageManager.GET_PROVIDERS);
|
||||
|
@ -85,7 +82,7 @@ public final class DictionaryPackInstallBroadcastReceiver extends BroadcastRecei
|
|||
}
|
||||
// If we come here none of the authorities matched the one we searched for.
|
||||
// We can exit safely.
|
||||
} else if (action.equals(Intent.ACTION_PACKAGE_REMOVED)
|
||||
} else if (Intent.ACTION_PACKAGE_REMOVED.equals(action)
|
||||
&& !intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) {
|
||||
if (null == mService) {
|
||||
Log.e(TAG, "Called with intent " + action + " but we don't know the service: this "
|
||||
|
@ -102,7 +99,7 @@ public final class DictionaryPackInstallBroadcastReceiver extends BroadcastRecei
|
|||
// TODO: Only reload dictionary on REMOVED when the removed package is the one we
|
||||
// read dictionary from?
|
||||
mService.resetSuggestMainDict();
|
||||
} else if (action.equals(DictionaryPackConstants.NEW_DICTIONARY_INTENT_ACTION)) {
|
||||
} else if (DictionaryPackConstants.NEW_DICTIONARY_INTENT_ACTION.equals(action)) {
|
||||
if (null == mService) {
|
||||
Log.e(TAG, "Called with intent " + action + " but we don't know the service: this "
|
||||
+ "should never happen");
|
||||
|
|
|
@ -8,7 +8,6 @@ package org.dslul.openboard.inputmethod.latin.settings;
|
|||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
|
@ -17,20 +16,17 @@ import android.view.inputmethod.InputMethodSubtype;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dslul.openboard.inputmethod.compat.AppWorkaroundsUtils;
|
||||
import org.dslul.openboard.inputmethod.keyboard.internal.keyboard_parser.LocaleKeyTextsKt;
|
||||
import org.dslul.openboard.inputmethod.latin.InputAttributes;
|
||||
import org.dslul.openboard.inputmethod.latin.R;
|
||||
import org.dslul.openboard.inputmethod.latin.RichInputMethodManager;
|
||||
import org.dslul.openboard.inputmethod.latin.common.Colors;
|
||||
import org.dslul.openboard.inputmethod.latin.spellcheck.AndroidSpellCheckerService;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.AsyncResultHolder;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.InputTypeUtils;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.Log;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.MoreKeysUtilsKt;
|
||||
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 java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -121,7 +117,6 @@ public class SettingsValues {
|
|||
private final boolean mOverrideShowingSuggestions;
|
||||
public final SettingsValuesForSuggestion mSettingsValuesForSuggestion;
|
||||
public final boolean mIncognitoModeEnabled;
|
||||
private final AsyncResultHolder<AppWorkaroundsUtils> mAppWorkarounds;
|
||||
|
||||
// User-defined colors
|
||||
public final Colors mColors;
|
||||
|
@ -197,15 +192,6 @@ public class SettingsValues {
|
|||
|| mInputAttributes.mIsPasswordField;
|
||||
mKeyboardHeightScale = prefs.getFloat(Settings.PREF_KEYBOARD_HEIGHT_SCALE, DEFAULT_SIZE_SCALE);
|
||||
mDisplayOrientation = res.getConfiguration().orientation;
|
||||
mAppWorkarounds = new AsyncResultHolder<>("AppWorkarounds");
|
||||
final PackageInfo packageInfo = TargetPackageInfoGetterTask.getCachedPackageInfo(
|
||||
mInputAttributes.mTargetApplicationPackageName);
|
||||
if (null != packageInfo) {
|
||||
mAppWorkarounds.set(new AppWorkaroundsUtils(packageInfo));
|
||||
} else {
|
||||
new TargetPackageInfoGetterTask(context, mAppWorkarounds)
|
||||
.execute(mInputAttributes.mTargetApplicationPackageName);
|
||||
}
|
||||
mSpaceTrackpadEnabled = Settings.readSpaceTrackpadEnabled(prefs);
|
||||
mDeleteSwipeEnabled = Settings.readDeleteSwipeEnabled(prefs);
|
||||
mAutospaceAfterPunctuationEnabled = Settings.readAutospaceAfterPunctuationEnabled(prefs);
|
||||
|
@ -407,8 +393,6 @@ public class SettingsValues {
|
|||
sb.append("\n mDisplayOrientation = ");
|
||||
sb.append("" + mDisplayOrientation);
|
||||
sb.append("\n mAppWorkarounds = ");
|
||||
final AppWorkaroundsUtils awu = mAppWorkarounds.get(null, 0);
|
||||
sb.append("" + (null == awu ? "null" : awu.toString()));
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2012 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.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.LruCache;
|
||||
|
||||
import org.dslul.openboard.inputmethod.compat.AppWorkaroundsUtils;
|
||||
|
||||
public final class TargetPackageInfoGetterTask extends
|
||||
AsyncTask<String, Void, PackageInfo> {
|
||||
private static final int MAX_CACHE_ENTRIES = 64; // arbitrary
|
||||
private static final LruCache<String, PackageInfo> sCache = new LruCache<>(MAX_CACHE_ENTRIES);
|
||||
|
||||
public static PackageInfo getCachedPackageInfo(final String packageName) {
|
||||
if (null == packageName) return null;
|
||||
return sCache.get(packageName);
|
||||
}
|
||||
|
||||
public static void removeCachedPackageInfo(final String packageName) {
|
||||
sCache.remove(packageName);
|
||||
}
|
||||
|
||||
private Context mContext;
|
||||
private final AsyncResultHolder<AppWorkaroundsUtils> mResult;
|
||||
|
||||
public TargetPackageInfoGetterTask(final Context context,
|
||||
final AsyncResultHolder<AppWorkaroundsUtils> result) {
|
||||
mContext = context;
|
||||
mResult = result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PackageInfo doInBackground(final String... packageName) {
|
||||
final PackageManager pm = mContext.getPackageManager();
|
||||
mContext = null; // Bazooka-powered anti-leak device
|
||||
try {
|
||||
final PackageInfo packageInfo = pm.getPackageInfo(packageName[0], 0 /* flags */);
|
||||
sCache.put(packageName[0], packageInfo);
|
||||
return packageInfo;
|
||||
} catch (android.content.pm.PackageManager.NameNotFoundException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final PackageInfo info) {
|
||||
mResult.set(new AppWorkaroundsUtils(info));
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue