mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-06 18:55:31 +08:00
Fixed: Fix typos and refactor
This commit is contained in:
@@ -44,14 +44,6 @@
|
||||
android:supportsRtl="false"
|
||||
android:theme="@style/Theme.Termux">
|
||||
|
||||
<!--
|
||||
This (or rather, value 2.1 or higher) is needed to make the Samsung Galaxy S8
|
||||
mark the app with "This app is optimized to run in full screen."
|
||||
-->
|
||||
<meta-data
|
||||
android:name="android.max_aspect"
|
||||
android:value="10.0" />
|
||||
|
||||
<activity
|
||||
android:name=".app.TermuxActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|uiMode|keyboard|keyboardHidden|navigation"
|
||||
@@ -143,6 +135,7 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
|
||||
<provider
|
||||
android:name=".filepicker.TermuxDocumentsProvider"
|
||||
android:authorities="${TERMUX_PACKAGE_NAME}.documents"
|
||||
@@ -154,9 +147,23 @@
|
||||
</intent-filter>
|
||||
</provider>
|
||||
|
||||
<provider
|
||||
android:name=".app.TermuxOpenReceiver$ContentProvider"
|
||||
android:authorities="${TERMUX_PACKAGE_NAME}.files"
|
||||
android:exported="true"
|
||||
android:grantUriPermissions="true"
|
||||
android:permission="${TERMUX_PACKAGE_NAME}.permission.RUN_COMMAND" />
|
||||
|
||||
|
||||
<receiver android:name=".app.TermuxOpenReceiver" android:exported="false" />
|
||||
|
||||
<receiver android:name=".shared.activities.ReportActivity$ReportActivityBroadcastReceiver" android:exported="false" />
|
||||
|
||||
|
||||
<service
|
||||
android:name=".app.TermuxService"
|
||||
android:exported="false" />
|
||||
|
||||
<service
|
||||
android:name=".app.RunCommandService"
|
||||
android:exported="true"
|
||||
@@ -166,23 +173,19 @@
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<receiver android:name=".app.TermuxOpenReceiver" />
|
||||
|
||||
<receiver android:name=".shared.activities.ReportActivity$ReportActivityBroadcastReceiver" android:exported="false" />
|
||||
|
||||
<provider
|
||||
android:name=".app.TermuxOpenReceiver$ContentProvider"
|
||||
android:authorities="${TERMUX_PACKAGE_NAME}.files"
|
||||
android:exported="true"
|
||||
android:grantUriPermissions="true"
|
||||
android:readPermission="android.permission.permRead" />
|
||||
|
||||
<!-- This (or rather, value 2.1 or higher) is needed to make the Samsung Galaxy S8 mark the
|
||||
app with "This app is optimized to run in full screen." -->
|
||||
<meta-data
|
||||
android:name="android.max_aspect"
|
||||
android:value="10.0" />
|
||||
<meta-data
|
||||
android:name="com.sec.android.support.multiwindow"
|
||||
android:value="true" />
|
||||
<meta-data
|
||||
android:name="com.samsung.android.multidisplay.keep_process_alive"
|
||||
android:value="true" />
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
@@ -13,6 +13,7 @@ import android.os.ParcelFileDescriptor;
|
||||
import android.provider.MediaStore;
|
||||
import android.webkit.MimeTypeMap;
|
||||
|
||||
import com.termux.shared.data.IntentUtils;
|
||||
import com.termux.shared.logger.Logger;
|
||||
import com.termux.shared.termux.TermuxConstants;
|
||||
|
||||
@@ -34,6 +35,8 @@ public class TermuxOpenReceiver extends BroadcastReceiver {
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.logVerbose(LOG_TAG, "Intent Received:\n" + IntentUtils.getIntentString(intent));
|
||||
|
||||
final String filePath = data.getPath();
|
||||
final String contentTypeExtra = intent.getStringExtra("content-type");
|
||||
final boolean useChooser = intent.getBooleanExtra("chooser", false);
|
||||
@@ -111,6 +114,8 @@ public class TermuxOpenReceiver extends BroadcastReceiver {
|
||||
|
||||
public static class ContentProvider extends android.content.ContentProvider {
|
||||
|
||||
private static final String LOG_TAG = "TermuxContentProvider";
|
||||
|
||||
@Override
|
||||
public boolean onCreate() {
|
||||
return true;
|
||||
@@ -178,6 +183,7 @@ public class TermuxOpenReceiver extends BroadcastReceiver {
|
||||
File file = new File(uri.getPath());
|
||||
try {
|
||||
String path = file.getCanonicalPath();
|
||||
Logger.logDebug(LOG_TAG, "Open file request received for \"" + path + "\" with mode \"" + mode + "\"");
|
||||
String storagePath = Environment.getExternalStorageDirectory().getCanonicalPath();
|
||||
// See https://support.google.com/faqs/answer/7496913:
|
||||
if (!(path.startsWith(TermuxConstants.TERMUX_FILES_DIR_PATH) || path.startsWith(storagePath))) {
|
||||
@@ -186,7 +192,8 @@ public class TermuxOpenReceiver extends BroadcastReceiver {
|
||||
} catch (IOException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
return ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
|
||||
|
||||
return ParcelFileDescriptor.open(file, ParcelFileDescriptor.parseMode(mode));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -19,6 +19,8 @@ import android.os.PowerManager;
|
||||
import android.provider.Settings;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.termux.R;
|
||||
import com.termux.app.settings.properties.TermuxAppSharedProperties;
|
||||
import com.termux.app.terminal.TermuxTerminalSessionClient;
|
||||
@@ -47,8 +49,6 @@ import com.termux.terminal.TerminalSessionClient;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* A service holding a list of {@link TermuxSession} in {@link #mTermuxSessions} and background {@link TermuxTask}
|
||||
* in {@link #mTermuxTasks}, showing a foreground notification while running so that it is not terminated.
|
||||
|
@@ -2,6 +2,8 @@ package com.termux.app.settings.properties;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.termux.app.terminal.io.KeyboardShortcut;
|
||||
import com.termux.shared.terminal.io.extrakeys.ExtraKeysConstants;
|
||||
import com.termux.shared.terminal.io.extrakeys.ExtraKeysConstants.EXTRA_KEY_DISPLAY_MAPS;
|
||||
@@ -17,8 +19,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TermuxAppSharedProperties extends TermuxSharedProperties {
|
||||
|
||||
private ExtraKeysInfo mExtraKeysInfo;
|
||||
@@ -26,7 +26,7 @@ public class TermuxAppSharedProperties extends TermuxSharedProperties {
|
||||
|
||||
private static final String LOG_TAG = "TermuxAppSharedProperties";
|
||||
|
||||
public TermuxAppSharedProperties(@Nonnull Context context) {
|
||||
public TermuxAppSharedProperties(@NonNull Context context) {
|
||||
super(context, TermuxConstants.TERMUX_APP_NAME, TermuxPropertyConstants.getTermuxPropertiesFile(),
|
||||
TermuxPropertyConstants.TERMUX_PROPERTIES_LIST, new SharedPropertiesParserClient());
|
||||
}
|
||||
|
@@ -13,6 +13,7 @@
|
||||
]>
|
||||
|
||||
<resources>
|
||||
|
||||
<string name="application_name">&TERMUX_APP_NAME;</string>
|
||||
<string name="shared_user_label">&TERMUX_APP_NAME; user</string>
|
||||
|
||||
@@ -21,7 +22,7 @@
|
||||
<!-- Termux RUN_COMMAND permission -->
|
||||
<string name="permission_run_command_label">Run commands in &TERMUX_APP_NAME; environment</string>
|
||||
<string name="permission_run_command_description">execute arbitrary commands within &TERMUX_APP_NAME;
|
||||
environment</string>
|
||||
environment and access files</string>
|
||||
|
||||
|
||||
|
||||
@@ -193,25 +194,25 @@
|
||||
|
||||
|
||||
|
||||
<!-- Termux API App Preferences -->
|
||||
<!-- Termux:API App Preferences -->
|
||||
<string name="termux_api_preferences_title">&TERMUX_API_APP_NAME;</string>
|
||||
<string name="termux_api_preferences_summary">Preferences for &TERMUX_API_APP_NAME; app</string>
|
||||
|
||||
|
||||
|
||||
<!-- Termux Float App Preferences -->
|
||||
<!-- Termux:Float App Preferences -->
|
||||
<string name="termux_float_preferences_title">&TERMUX_FLOAT_APP_NAME;</string>
|
||||
<string name="termux_float_preferences_summary">Preferences for &TERMUX_FLOAT_APP_NAME; app</string>
|
||||
|
||||
|
||||
|
||||
<!-- Termux Tasker App Preferences -->
|
||||
<!-- Termux:Tasker App Preferences -->
|
||||
<string name="termux_tasker_preferences_title">&TERMUX_TASKER_APP_NAME;</string>
|
||||
<string name="termux_tasker_preferences_summary">Preferences for &TERMUX_TASKER_APP_NAME; app</string>
|
||||
|
||||
|
||||
|
||||
<!-- Termux Widget App Preferences -->
|
||||
<!-- Termux:Widget App Preferences -->
|
||||
<string name="termux_widget_preferences_title">&TERMUX_WIDGET_APP_NAME;</string>
|
||||
<string name="termux_widget_preferences_summary">Preferences for &TERMUX_WIDGET_APP_NAME; app</string>
|
||||
|
||||
|
@@ -9,6 +9,7 @@ import android.content.pm.PackageManager;
|
||||
import android.os.UserManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.termux.shared.R;
|
||||
import com.termux.shared.data.DataUtils;
|
||||
@@ -19,8 +20,6 @@ import com.termux.shared.termux.TermuxConstants;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class PackageUtils {
|
||||
|
||||
private static final String LOG_TAG = "PackageUtils";
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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 {
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -49,7 +49,7 @@ import java.util.List;
|
||||
* `TERMUX_WIDGET_DEFAULT_PREFERENCES_FILE_BASENAME_WITHOUT_EXTENSION`.
|
||||
*
|
||||
* - 0.5.0 (2021-03-16)
|
||||
* - Renamed "Termux Plugin app" labels to "Termux Tasker app".
|
||||
* - Renamed "Termux Plugin app" labels to "Termux:Tasker app".
|
||||
*
|
||||
* - 0.6.0 (2021-03-16)
|
||||
* - Added `TERMUX_FILE_SHARE_URI_AUTHORITY`.
|
||||
@@ -276,87 +276,87 @@ public final class TermuxConstants {
|
||||
public static final String TERMUX_FDROID_PACKAGE_URL = FDROID_PACKAGES_BASE_URL + "/" + TERMUX_PACKAGE_NAME; // Default: "https://f-droid.org/en/packages/com.termux"
|
||||
|
||||
|
||||
/** Termux API app name */
|
||||
/** Termux:API app name */
|
||||
public static final String TERMUX_API_APP_NAME = "Termux:API"; // Default: "Termux:API"
|
||||
/** Termux API app package name */
|
||||
/** Termux:API app package name */
|
||||
public static final String TERMUX_API_PACKAGE_NAME = TERMUX_PACKAGE_NAME + ".api"; // Default: "com.termux.api"
|
||||
/** Termux API Github repo name */
|
||||
/** Termux:API Github repo name */
|
||||
public static final String TERMUX_API_GITHUB_REPO_NAME = "termux-api"; // Default: "termux-api"
|
||||
/** Termux API Github repo url */
|
||||
/** Termux:API Github repo url */
|
||||
public static final String TERMUX_API_GITHUB_REPO_URL = TERMUX_GITHUB_ORGANIZATION_URL + "/" + TERMUX_API_GITHUB_REPO_NAME; // Default: "https://github.com/termux/termux-api"
|
||||
/** Termux API Github issues repo url */
|
||||
/** Termux:API Github issues repo url */
|
||||
public static final String TERMUX_API_GITHUB_ISSUES_REPO_URL = TERMUX_API_GITHUB_REPO_URL + "/issues"; // Default: "https://github.com/termux/termux-api/issues"
|
||||
/** Termux API F-Droid package url */
|
||||
/** Termux:API F-Droid package url */
|
||||
public static final String TERMUX_API_FDROID_PACKAGE_URL = FDROID_PACKAGES_BASE_URL + "/" + TERMUX_API_PACKAGE_NAME; // Default: "https://f-droid.org/en/packages/com.termux.api"
|
||||
|
||||
|
||||
/** Termux Boot app name */
|
||||
/** Termux:Boot app name */
|
||||
public static final String TERMUX_BOOT_APP_NAME = "Termux:Boot"; // Default: "Termux:Boot"
|
||||
/** Termux Boot app package name */
|
||||
/** Termux:Boot app package name */
|
||||
public static final String TERMUX_BOOT_PACKAGE_NAME = TERMUX_PACKAGE_NAME + ".boot"; // Default: "com.termux.boot"
|
||||
/** Termux Boot Github repo name */
|
||||
/** Termux:Boot Github repo name */
|
||||
public static final String TERMUX_BOOT_GITHUB_REPO_NAME = "termux-boot"; // Default: "termux-boot"
|
||||
/** Termux Boot Github repo url */
|
||||
/** Termux:Boot Github repo url */
|
||||
public static final String TERMUX_BOOT_GITHUB_REPO_URL = TERMUX_GITHUB_ORGANIZATION_URL + "/" + TERMUX_BOOT_GITHUB_REPO_NAME; // Default: "https://github.com/termux/termux-boot"
|
||||
/** Termux Boot Github issues repo url */
|
||||
/** Termux:Boot Github issues repo url */
|
||||
public static final String TERMUX_BOOT_GITHUB_ISSUES_REPO_URL = TERMUX_BOOT_GITHUB_REPO_URL + "/issues"; // Default: "https://github.com/termux/termux-boot/issues"
|
||||
/** Termux Boot F-Droid package url */
|
||||
/** Termux:Boot F-Droid package url */
|
||||
public static final String TERMUX_BOOT_FDROID_PACKAGE_URL = FDROID_PACKAGES_BASE_URL + "/" + TERMUX_BOOT_PACKAGE_NAME; // Default: "https://f-droid.org/en/packages/com.termux.boot"
|
||||
|
||||
|
||||
/** Termux Float app name */
|
||||
/** Termux:Float app name */
|
||||
public static final String TERMUX_FLOAT_APP_NAME = "Termux:Float"; // Default: "Termux:Float"
|
||||
/** Termux Float app package name */
|
||||
/** Termux:Float app package name */
|
||||
public static final String TERMUX_FLOAT_PACKAGE_NAME = TERMUX_PACKAGE_NAME + ".window"; // Default: "com.termux.window"
|
||||
/** Termux Float Github repo name */
|
||||
/** Termux:Float Github repo name */
|
||||
public static final String TERMUX_FLOAT_GITHUB_REPO_NAME = "termux-float"; // Default: "termux-float"
|
||||
/** Termux Float Github repo url */
|
||||
/** Termux:Float Github repo url */
|
||||
public static final String TERMUX_FLOAT_GITHUB_REPO_URL = TERMUX_GITHUB_ORGANIZATION_URL + "/" + TERMUX_FLOAT_GITHUB_REPO_NAME; // Default: "https://github.com/termux/termux-float"
|
||||
/** Termux Float Github issues repo url */
|
||||
/** Termux:Float Github issues repo url */
|
||||
public static final String TERMUX_FLOAT_GITHUB_ISSUES_REPO_URL = TERMUX_FLOAT_GITHUB_REPO_URL + "/issues"; // Default: "https://github.com/termux/termux-float/issues"
|
||||
/** Termux Float F-Droid package url */
|
||||
/** Termux:Float F-Droid package url */
|
||||
public static final String TERMUX_FLOAT_FDROID_PACKAGE_URL = FDROID_PACKAGES_BASE_URL + "/" + TERMUX_FLOAT_PACKAGE_NAME; // Default: "https://f-droid.org/en/packages/com.termux.window"
|
||||
|
||||
|
||||
/** Termux Styling app name */
|
||||
/** Termux:Styling app name */
|
||||
public static final String TERMUX_STYLING_APP_NAME = "Termux:Styling"; // Default: "Termux:Styling"
|
||||
/** Termux Styling app package name */
|
||||
/** Termux:Styling app package name */
|
||||
public static final String TERMUX_STYLING_PACKAGE_NAME = TERMUX_PACKAGE_NAME + ".styling"; // Default: "com.termux.styling"
|
||||
/** Termux Styling Github repo name */
|
||||
/** Termux:Styling Github repo name */
|
||||
public static final String TERMUX_STYLING_GITHUB_REPO_NAME = "termux-styling"; // Default: "termux-styling"
|
||||
/** Termux Styling Github repo url */
|
||||
/** Termux:Styling Github repo url */
|
||||
public static final String TERMUX_STYLING_GITHUB_REPO_URL = TERMUX_GITHUB_ORGANIZATION_URL + "/" + TERMUX_STYLING_GITHUB_REPO_NAME; // Default: "https://github.com/termux/termux-styling"
|
||||
/** Termux Styling Github issues repo url */
|
||||
/** Termux:Styling Github issues repo url */
|
||||
public static final String TERMUX_STYLING_GITHUB_ISSUES_REPO_URL = TERMUX_STYLING_GITHUB_REPO_URL + "/issues"; // Default: "https://github.com/termux/termux-styling/issues"
|
||||
/** Termux Styling F-Droid package url */
|
||||
/** Termux:Styling F-Droid package url */
|
||||
public static final String TERMUX_STYLING_FDROID_PACKAGE_URL = FDROID_PACKAGES_BASE_URL + "/" + TERMUX_STYLING_PACKAGE_NAME; // Default: "https://f-droid.org/en/packages/com.termux.styling"
|
||||
|
||||
|
||||
/** Termux Tasker app name */
|
||||
/** Termux:Tasker app name */
|
||||
public static final String TERMUX_TASKER_APP_NAME = "Termux:Tasker"; // Default: "Termux:Tasker"
|
||||
/** Termux Tasker app package name */
|
||||
/** Termux:Tasker app package name */
|
||||
public static final String TERMUX_TASKER_PACKAGE_NAME = TERMUX_PACKAGE_NAME + ".tasker"; // Default: "com.termux.tasker"
|
||||
/** Termux Tasker Github repo name */
|
||||
/** Termux:Tasker Github repo name */
|
||||
public static final String TERMUX_TASKER_GITHUB_REPO_NAME = "termux-tasker"; // Default: "termux-tasker"
|
||||
/** Termux Tasker Github repo url */
|
||||
/** Termux:Tasker Github repo url */
|
||||
public static final String TERMUX_TASKER_GITHUB_REPO_URL = TERMUX_GITHUB_ORGANIZATION_URL + "/" + TERMUX_TASKER_GITHUB_REPO_NAME; // Default: "https://github.com/termux/termux-tasker"
|
||||
/** Termux Tasker Github issues repo url */
|
||||
/** Termux:Tasker Github issues repo url */
|
||||
public static final String TERMUX_TASKER_GITHUB_ISSUES_REPO_URL = TERMUX_TASKER_GITHUB_REPO_URL + "/issues"; // Default: "https://github.com/termux/termux-tasker/issues"
|
||||
/** Termux Tasker F-Droid package url */
|
||||
/** Termux:Tasker F-Droid package url */
|
||||
public static final String TERMUX_TASKER_FDROID_PACKAGE_URL = FDROID_PACKAGES_BASE_URL + "/" + TERMUX_TASKER_PACKAGE_NAME; // Default: "https://f-droid.org/en/packages/com.termux.tasker"
|
||||
|
||||
|
||||
/** Termux Widget app name */
|
||||
/** Termux:Widget app name */
|
||||
public static final String TERMUX_WIDGET_APP_NAME = "Termux:Widget"; // Default: "Termux:Widget"
|
||||
/** Termux Widget app package name */
|
||||
/** Termux:Widget app package name */
|
||||
public static final String TERMUX_WIDGET_PACKAGE_NAME = TERMUX_PACKAGE_NAME + ".widget"; // Default: "com.termux.widget"
|
||||
/** Termux Widget Github repo name */
|
||||
/** Termux:Widget Github repo name */
|
||||
public static final String TERMUX_WIDGET_GITHUB_REPO_NAME = "termux-widget"; // Default: "termux-widget"
|
||||
/** Termux Widget Github repo url */
|
||||
/** Termux:Widget Github repo url */
|
||||
public static final String TERMUX_WIDGET_GITHUB_REPO_URL = TERMUX_GITHUB_ORGANIZATION_URL + "/" + TERMUX_WIDGET_GITHUB_REPO_NAME; // Default: "https://github.com/termux/termux-widget"
|
||||
/** Termux Widget Github issues repo url */
|
||||
/** Termux:Widget Github issues repo url */
|
||||
public static final String TERMUX_WIDGET_GITHUB_ISSUES_REPO_URL = TERMUX_WIDGET_GITHUB_REPO_URL + "/issues"; // Default: "https://github.com/termux/termux-widget/issues"
|
||||
/** Termux Widget F-Droid package url */
|
||||
/** Termux:Widget F-Droid package url */
|
||||
public static final String TERMUX_WIDGET_FDROID_PACKAGE_URL = FDROID_PACKAGES_BASE_URL + "/" + TERMUX_WIDGET_PACKAGE_NAME; // Default: "https://f-droid.org/en/packages/com.termux.widget"
|
||||
|
||||
|
||||
@@ -621,22 +621,22 @@ public final class TermuxConstants {
|
||||
/** Termux app default SharedPreferences file basename without extension */
|
||||
public static final String TERMUX_DEFAULT_PREFERENCES_FILE_BASENAME_WITHOUT_EXTENSION = TERMUX_PACKAGE_NAME + "_preferences"; // Default: "com.termux_preferences"
|
||||
|
||||
/** Termux API app default SharedPreferences file basename without extension */
|
||||
/** Termux:API app default SharedPreferences file basename without extension */
|
||||
public static final String TERMUX_API_DEFAULT_PREFERENCES_FILE_BASENAME_WITHOUT_EXTENSION = TERMUX_API_PACKAGE_NAME + "_preferences"; // Default: "com.termux.api_preferences"
|
||||
|
||||
/** Termux Boot app default SharedPreferences file basename without extension */
|
||||
/** Termux:Boot app default SharedPreferences file basename without extension */
|
||||
public static final String TERMUX_BOOT_DEFAULT_PREFERENCES_FILE_BASENAME_WITHOUT_EXTENSION = TERMUX_BOOT_PACKAGE_NAME + "_preferences"; // Default: "com.termux.boot_preferences"
|
||||
|
||||
/** Termux Float app default SharedPreferences file basename without extension */
|
||||
/** Termux:Float app default SharedPreferences file basename without extension */
|
||||
public static final String TERMUX_FLOAT_DEFAULT_PREFERENCES_FILE_BASENAME_WITHOUT_EXTENSION = TERMUX_FLOAT_PACKAGE_NAME + "_preferences"; // Default: "com.termux.window_preferences"
|
||||
|
||||
/** Termux Styling app default SharedPreferences file basename without extension */
|
||||
/** Termux:Styling app default SharedPreferences file basename without extension */
|
||||
public static final String TERMUX_STYLING_DEFAULT_PREFERENCES_FILE_BASENAME_WITHOUT_EXTENSION = TERMUX_STYLING_PACKAGE_NAME + "_preferences"; // Default: "com.termux.styling_preferences"
|
||||
|
||||
/** Termux Tasker app default SharedPreferences file basename without extension */
|
||||
/** Termux:Tasker app default SharedPreferences file basename without extension */
|
||||
public static final String TERMUX_TASKER_DEFAULT_PREFERENCES_FILE_BASENAME_WITHOUT_EXTENSION = TERMUX_TASKER_PACKAGE_NAME + "_preferences"; // Default: "com.termux.tasker_preferences"
|
||||
|
||||
/** Termux Widget app default SharedPreferences file basename without extension */
|
||||
/** Termux:Widget app default SharedPreferences file basename without extension */
|
||||
public static final String TERMUX_WIDGET_DEFAULT_PREFERENCES_FILE_BASENAME_WITHOUT_EXTENSION = TERMUX_WIDGET_PACKAGE_NAME + "_preferences"; // Default: "com.termux.widget_preferences"
|
||||
|
||||
|
||||
@@ -651,14 +651,14 @@ public final class TermuxConstants {
|
||||
public static final File TERMUX_PROPERTIES_SECONDARY_FILE = new File(TERMUX_PROPERTIES_SECONDARY_FILE_PATH);
|
||||
|
||||
|
||||
/** Termux Float app termux.properties primary file path */
|
||||
/** Termux:Float app termux.properties primary file path */
|
||||
public static final String TERMUX_FLOAT_PROPERTIES_PRIMARY_FILE_PATH = TERMUX_DATA_HOME_DIR_PATH + "/termux.float.properties"; // Default: "/data/data/com.termux/files/home/.termux/termux.float.properties"
|
||||
/** Termux Float app termux.properties primary file */
|
||||
/** Termux:Float app termux.properties primary file */
|
||||
public static final File TERMUX_FLOAT_PROPERTIES_PRIMARY_FILE = new File(TERMUX_FLOAT_PROPERTIES_PRIMARY_FILE_PATH);
|
||||
|
||||
/** Termux Float app termux.properties secondary file path */
|
||||
/** Termux:Float app termux.properties secondary file path */
|
||||
public static final String TERMUX_FLOAT_PROPERTIES_SECONDARY_FILE_PATH = TERMUX_CONFIG_HOME_DIR_PATH + "/termux.float.properties"; // Default: "/data/data/com.termux/files/home/.config/termux/termux.float.properties"
|
||||
/** Termux Float app termux.properties secondary file */
|
||||
/** Termux:Float app termux.properties secondary file */
|
||||
public static final File TERMUX_FLOAT_PROPERTIES_SECONDARY_FILE = new File(TERMUX_FLOAT_PROPERTIES_SECONDARY_FILE_PATH);
|
||||
|
||||
|
||||
@@ -1110,15 +1110,15 @@ public final class TermuxConstants {
|
||||
|
||||
|
||||
/**
|
||||
* Termux Float app constants.
|
||||
* Termux:Float app constants.
|
||||
*/
|
||||
public static final class TERMUX_FLOAT_APP {
|
||||
|
||||
/** Termux Float app core service name. */
|
||||
/** Termux:Float app core service name. */
|
||||
public static final String TERMUX_FLOAT_SERVICE_NAME = TERMUX_FLOAT_PACKAGE_NAME + ".TermuxFloatService"; // Default: "com.termux.window.TermuxFloatService"
|
||||
|
||||
/**
|
||||
* Termux Float app core service.
|
||||
* Termux:Float app core service.
|
||||
*/
|
||||
public static final class TERMUX_FLOAT_SERVICE {
|
||||
|
||||
@@ -1140,7 +1140,7 @@ public final class TermuxConstants {
|
||||
|
||||
|
||||
/**
|
||||
* Termux Styling app constants.
|
||||
* Termux:Styling app constants.
|
||||
*/
|
||||
public static final class TERMUX_STYLING {
|
||||
|
||||
@@ -1154,15 +1154,15 @@ public final class TermuxConstants {
|
||||
|
||||
|
||||
/**
|
||||
* Termux Widget app constants.
|
||||
* Termux:Widget app constants.
|
||||
*/
|
||||
public static final class TERMUX_WIDGET {
|
||||
|
||||
/** Intent {@code String} extra for the token of the Termux Widget app shortcuts. */
|
||||
/** Intent {@code String} extra for the token of the Termux:Widget app shortcuts. */
|
||||
public static final String EXTRA_TOKEN_NAME = TERMUX_PACKAGE_NAME + ".shortcut.token"; // Default: "com.termux.shortcut.token"
|
||||
|
||||
/**
|
||||
* Termux Widget app {@link android.appwidget.AppWidgetProvider} class.
|
||||
* Termux:Widget app {@link android.appwidget.AppWidgetProvider} class.
|
||||
*/
|
||||
public static final class TERMUX_WIDGET_PROVIDER {
|
||||
|
||||
@@ -1181,5 +1181,4 @@ public final class TermuxConstants {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user