Skip to content

Commit

Permalink
Fixed: Fix typos and refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
agnostic-apollo committed Sep 4, 2021
1 parent 23b707a commit b62645c
Show file tree
Hide file tree
Showing 17 changed files with 124 additions and 131 deletions.
39 changes: 21 additions & 18 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -143,6 +135,7 @@
</intent-filter>
</activity>


<provider
android:name=".filepicker.TermuxDocumentsProvider"
android:authorities="${TERMUX_PACKAGE_NAME}.documents"
Expand All @@ -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"
Expand All @@ -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>
9 changes: 8 additions & 1 deletion app/src/main/java/com/termux/app/TermuxOpenReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
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;

Expand All @@ -34,6 +35,8 @@ public void onReceive(Context context, Intent intent) {
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);
Expand Down Expand Up @@ -111,6 +114,8 @@ public void onReceive(Context context, Intent intent) {

public static class ContentProvider extends android.content.ContentProvider {

private static final String LOG_TAG = "TermuxContentProvider";

@Override
public boolean onCreate() {
return true;
Expand Down Expand Up @@ -178,6 +183,7 @@ public ParcelFileDescriptor openFile(@NonNull Uri uri, @NonNull String mode) thr
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))) {
Expand All @@ -186,7 +192,8 @@ public ParcelFileDescriptor openFile(@NonNull Uri uri, @NonNull String mode) thr
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
return ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);

return ParcelFileDescriptor.open(file, ParcelFileDescriptor.parseMode(mode));
}
}

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/termux/app/TermuxService.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
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;
Expand Down Expand Up @@ -47,8 +49,6 @@
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

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;
Expand All @@ -17,16 +19,14 @@
import java.util.List;
import java.util.Map;

import javax.annotation.Nonnull;

public class TermuxAppSharedProperties extends TermuxSharedProperties {

private ExtraKeysInfo mExtraKeysInfo;
private List<KeyboardShortcut> mSessionShortcuts = new ArrayList<>();

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());
}
Expand Down
11 changes: 6 additions & 5 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
]>

<resources>

<string name="application_name">&TERMUX_APP_NAME;</string>
<string name="shared_user_label">&TERMUX_APP_NAME; user</string>

Expand All @@ -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>



Expand Down Expand Up @@ -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>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.os.UserManager;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.termux.shared.R;
import com.termux.shared.data.DataUtils;
Expand All @@ -19,8 +20,6 @@
import java.security.MessageDigest;
import java.util.List;

import javax.annotation.Nullable;

public class PackageUtils {

private static final String LOG_TAG = "PackageUtils";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
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;
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@
import android.util.TypedValue;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.termux.shared.packages.PackageUtils;
import com.termux.shared.termux.TermuxConstants;
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;
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
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;
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@
import android.content.SharedPreferences;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.termux.shared.data.DataUtils;
import com.termux.shared.logger.Logger;
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;
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public static final class TERMUX_APP {


/**
* Termux API app constants.
* Termux:API app constants.
*/
public static final class TERMUX_API_APP {

Expand All @@ -177,7 +177,7 @@ public static final class TERMUX_API_APP {


/**
* Termux Boot app constants.
* Termux:Boot app constants.
*/
public static final class TERMUX_BOOT_APP {

Expand All @@ -191,7 +191,7 @@ public static final class TERMUX_BOOT_APP {


/**
* Termux Float app constants.
* Termux:Float app constants.
*/
public static final class TERMUX_FLOAT_APP {

Expand Down Expand Up @@ -236,7 +236,7 @@ public static final class TERMUX_FLOAT_APP {


/**
* Termux Styling app constants.
* Termux:Styling app constants.
*/
public static final class TERMUX_STYLING_APP {

Expand All @@ -250,7 +250,7 @@ public static final class TERMUX_STYLING_APP {


/**
* Termux Tasker app constants.
* Termux:Tasker app constants.
*/
public static final class TERMUX_TASKER_APP {

Expand All @@ -264,7 +264,7 @@ public static final class TERMUX_TASKER_APP {


/**
* Termux Widget app constants.
* Termux:Widget app constants.
*/
public static final class TERMUX_WIDGET_APP {

Expand Down
Loading

0 comments on commit b62645c

Please sign in to comment.