Fixed: Fix typos and refactor

This commit is contained in:
agnostic-apollo
2021-09-05 03:37:07 +05:00
parent 23b707a819
commit b62645cd03
17 changed files with 124 additions and 131 deletions

View File

@@ -5,15 +5,13 @@ import android.content.Context;
import android.content.SharedPreferences;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.termux.shared.logger.Logger;
import com.termux.shared.packages.PackageUtils;
import com.termux.shared.settings.preferences.TermuxPreferenceConstants.TERMUX_API_APP;
import com.termux.shared.termux.TermuxConstants;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class TermuxAPIAppSharedPreferences {
private final Context mContext;
@@ -23,7 +21,7 @@ public class TermuxAPIAppSharedPreferences {
private static final String LOG_TAG = "TermuxAPIAppSharedPreferences";
private TermuxAPIAppSharedPreferences(@Nonnull Context context) {
private TermuxAPIAppSharedPreferences(@NonNull Context context) {
mContext = context;
mSharedPreferences = getPrivateSharedPreferences(mContext);
mMultiProcessSharedPreferences = getPrivateAndMultiProcessSharedPreferences(mContext);

View File

@@ -6,6 +6,7 @@ import android.content.SharedPreferences;
import android.util.TypedValue;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.termux.shared.packages.PackageUtils;
import com.termux.shared.termux.TermuxConstants;
@@ -13,9 +14,6 @@ import com.termux.shared.logger.Logger;
import com.termux.shared.data.DataUtils;
import com.termux.shared.settings.preferences.TermuxPreferenceConstants.TERMUX_APP;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class TermuxAppSharedPreferences {
private final Context mContext;
@@ -27,7 +25,7 @@ public class TermuxAppSharedPreferences {
private static final String LOG_TAG = "TermuxAppSharedPreferences";
private TermuxAppSharedPreferences(@Nonnull Context context) {
private TermuxAppSharedPreferences(@NonNull Context context) {
mContext = context;
mSharedPreferences = getPrivateSharedPreferences(mContext);

View File

@@ -5,15 +5,13 @@ import android.content.Context;
import android.content.SharedPreferences;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.termux.shared.logger.Logger;
import com.termux.shared.packages.PackageUtils;
import com.termux.shared.settings.preferences.TermuxPreferenceConstants.TERMUX_BOOT_APP;
import com.termux.shared.termux.TermuxConstants;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class TermuxBootAppSharedPreferences {
private final Context mContext;
@@ -23,7 +21,7 @@ public class TermuxBootAppSharedPreferences {
private static final String LOG_TAG = "TermuxBootAppSharedPreferences";
private TermuxBootAppSharedPreferences(@Nonnull Context context) {
private TermuxBootAppSharedPreferences(@NonNull Context context) {
mContext = context;
mSharedPreferences = getPrivateSharedPreferences(mContext);
mMultiProcessSharedPreferences = getPrivateAndMultiProcessSharedPreferences(mContext);

View File

@@ -5,6 +5,7 @@ import android.content.Context;
import android.content.SharedPreferences;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.termux.shared.data.DataUtils;
import com.termux.shared.logger.Logger;
@@ -12,9 +13,6 @@ import com.termux.shared.packages.PackageUtils;
import com.termux.shared.settings.preferences.TermuxPreferenceConstants.TERMUX_FLOAT_APP;
import com.termux.shared.termux.TermuxConstants;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class TermuxFloatAppSharedPreferences {
private final Context mContext;
@@ -27,7 +25,7 @@ public class TermuxFloatAppSharedPreferences {
private static final String LOG_TAG = "TermuxFloatAppSharedPreferences";
private TermuxFloatAppSharedPreferences(@Nonnull Context context) {
private TermuxFloatAppSharedPreferences(@NonNull Context context) {
mContext = context;
mSharedPreferences = getPrivateSharedPreferences(mContext);
mMultiProcessSharedPreferences = getPrivateAndMultiProcessSharedPreferences(mContext);

View File

@@ -163,7 +163,7 @@ public final class TermuxPreferenceConstants {
/**
* Termux API app constants.
* Termux:API app constants.
*/
public static final class TERMUX_API_APP {
@@ -177,7 +177,7 @@ public final class TermuxPreferenceConstants {
/**
* Termux Boot app constants.
* Termux:Boot app constants.
*/
public static final class TERMUX_BOOT_APP {
@@ -191,7 +191,7 @@ public final class TermuxPreferenceConstants {
/**
* Termux Float app constants.
* Termux:Float app constants.
*/
public static final class TERMUX_FLOAT_APP {
@@ -236,7 +236,7 @@ public final class TermuxPreferenceConstants {
/**
* Termux Styling app constants.
* Termux:Styling app constants.
*/
public static final class TERMUX_STYLING_APP {
@@ -250,7 +250,7 @@ public final class TermuxPreferenceConstants {
/**
* Termux Tasker app constants.
* Termux:Tasker app constants.
*/
public static final class TERMUX_TASKER_APP {
@@ -264,7 +264,7 @@ public final class TermuxPreferenceConstants {
/**
* Termux Widget app constants.
* Termux:Widget app constants.
*/
public static final class TERMUX_WIDGET_APP {

View File

@@ -5,15 +5,13 @@ import android.content.Context;
import android.content.SharedPreferences;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.termux.shared.logger.Logger;
import com.termux.shared.packages.PackageUtils;
import com.termux.shared.settings.preferences.TermuxPreferenceConstants.TERMUX_STYLING_APP;
import com.termux.shared.termux.TermuxConstants;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class TermuxStylingAppSharedPreferences {
private final Context mContext;
@@ -23,7 +21,7 @@ public class TermuxStylingAppSharedPreferences {
private static final String LOG_TAG = "TermuxStylingAppSharedPreferences";
private TermuxStylingAppSharedPreferences(@Nonnull Context context) {
private TermuxStylingAppSharedPreferences(@NonNull Context context) {
mContext = context;
mSharedPreferences = getPrivateSharedPreferences(mContext);
mMultiProcessSharedPreferences = getPrivateAndMultiProcessSharedPreferences(mContext);

View File

@@ -5,15 +5,13 @@ import android.content.Context;
import android.content.SharedPreferences;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.termux.shared.packages.PackageUtils;
import com.termux.shared.termux.TermuxConstants;
import com.termux.shared.settings.preferences.TermuxPreferenceConstants.TERMUX_TASKER_APP;
import com.termux.shared.logger.Logger;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class TermuxTaskerAppSharedPreferences {
private final Context mContext;
@@ -23,7 +21,7 @@ public class TermuxTaskerAppSharedPreferences {
private static final String LOG_TAG = "TermuxTaskerAppSharedPreferences";
private TermuxTaskerAppSharedPreferences(@Nonnull Context context) {
private TermuxTaskerAppSharedPreferences(@NonNull Context context) {
mContext = context;
mSharedPreferences = getPrivateSharedPreferences(mContext);
mMultiProcessSharedPreferences = getPrivateAndMultiProcessSharedPreferences(mContext);

View File

@@ -5,6 +5,7 @@ import android.content.Context;
import android.content.SharedPreferences;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.termux.shared.logger.Logger;
import com.termux.shared.packages.PackageUtils;
@@ -13,9 +14,6 @@ import com.termux.shared.termux.TermuxConstants;
import java.util.UUID;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class TermuxWidgetAppSharedPreferences {
private final Context mContext;
@@ -25,7 +23,7 @@ public class TermuxWidgetAppSharedPreferences {
private static final String LOG_TAG = "TermuxWidgetAppSharedPreferences";
private TermuxWidgetAppSharedPreferences(@Nonnull Context context) {
private TermuxWidgetAppSharedPreferences(@NonNull Context context) {
mContext = context;
mSharedPreferences = getPrivateSharedPreferences(mContext);
mMultiProcessSharedPreferences = getPrivateAndMultiProcessSharedPreferences(mContext);

View File

@@ -3,6 +3,9 @@ package com.termux.shared.settings.properties;
import android.content.Context;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.common.collect.BiMap;
import com.google.common.collect.ImmutableBiMap;
import com.google.common.primitives.Primitives;
@@ -17,9 +20,6 @@ import java.util.Map;
import java.util.Properties;
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* An implementation similar to android's {@link android.content.SharedPreferences} interface for
* reading and writing to and from ".properties" files which also maintains an in-memory cache for
@@ -90,7 +90,7 @@ public class SharedProperties {
* {@code propertiesFile} will be read by {@link #loadPropertiesFromDisk()}
* @param sharedPropertiesParser The implementation of the {@link SharedPropertiesParser} interface.
*/
public SharedProperties(@Nonnull Context context, @Nullable File propertiesFile, Set<String> propertiesList, @Nonnull SharedPropertiesParser sharedPropertiesParser) {
public SharedProperties(@NonNull Context context, @Nullable File propertiesFile, Set<String> propertiesList, @NonNull SharedPropertiesParser sharedPropertiesParser) {
mContext = context;
mPropertiesFile = propertiesFile;
mPropertiesList = propertiesList;
@@ -275,7 +275,7 @@ public class SharedProperties {
* @return Returns the {@link String} Object returned by the call to
* {@link SharedPropertiesParser#getInternalPropertyValueFromValue(Context,String,String)}.
*/
public static Object getInternalProperty(Context context, File propertiesFile, String key, @Nonnull SharedPropertiesParser sharedPropertiesParser) {
public static Object getInternalProperty(Context context, File propertiesFile, String key, @NonNull SharedPropertiesParser sharedPropertiesParser) {
String value = (String) getDefaultIfNull(getPropertiesFromFile(context, propertiesFile), new Properties()).get(key);
// Call the {@link SharedPropertiesParser#getInternalPropertyValueFromValue(Context,String,String)}
@@ -464,7 +464,7 @@ public class SharedProperties {
* @return Returns the value for the {@code inputValue} key from the map if it exists. Otherwise
* returns default value.
*/
public static Object getDefaultIfNotInMap(String key, @Nonnull BiMap<?, ?> map, Object inputValue, Object defaultOutputValue, boolean logErrorOnInvalidValue, String logTag) {
public static Object getDefaultIfNotInMap(String key, @NonNull BiMap<?, ?> map, Object inputValue, Object defaultOutputValue, boolean logErrorOnInvalidValue, String logTag) {
Object outputValue = map.get(inputValue);
if (outputValue == null) {
Object defaultInputValue = map.inverse().get(defaultOutputValue);
@@ -549,7 +549,7 @@ public class SharedProperties {
* @param def The default {@link Object}.
* @return Returns {@code object} if it is not {@code null}, otherwise returns {@code def}.
*/
public static <T> T getDefaultIfNull(@androidx.annotation.Nullable T object, @androidx.annotation.Nullable T def) {
public static <T> T getDefaultIfNull(@Nullable T object, @Nullable T def) {
return (object == null) ? def : object;
}
@@ -560,7 +560,7 @@ public class SharedProperties {
* @param def The default {@link String}.
* @return Returns {@code object} if it is not {@code null}, otherwise returns {@code def}.
*/
public static String getDefaultIfNullOrEmpty(@androidx.annotation.Nullable String object, @androidx.annotation.Nullable String def) {
public static String getDefaultIfNullOrEmpty(@Nullable String object, @Nullable String def) {
return (object == null || object.isEmpty()) ? def : object;
}

View File

@@ -14,8 +14,6 @@ import java.util.Map;
import java.util.Properties;
import java.util.Set;
import javax.annotation.Nonnull;
public abstract class TermuxSharedProperties {
protected final Context mContext;
@@ -25,7 +23,7 @@ public abstract class TermuxSharedProperties {
public static final String LOG_TAG = "TermuxSharedProperties";
public TermuxSharedProperties(@Nonnull Context context, @NonNull String label, File propertiesFile,
public TermuxSharedProperties(@NonNull Context context, @NonNull String label, File propertiesFile,
@NonNull Set<String> propertiesList, @NonNull SharedPropertiesParser sharedPropertiesParser) {
mContext = context;
mLabel = label;