mirror of
https://github.com/nix-community/nix-on-droid-app.git
synced 2025-12-19 15:31:18 +01:00
Define TermuxConstants class to store all shared constants of Termux app and its plugins
This commit removes almost all hardcoded paths in Termux app and moves the references to the `TermuxConstants` class. The `TermuxConstants` class should be imported by other termux plugin apps instead of copying and defining their own constants. The 3rd party apps can also import it for interacting with termux apps. App and sub class specific constants are defined in their own nested classes to keep them segregated from each other and for better readability.
This commit is contained in:
parent
395759cc0a
commit
14c49867f7
14 changed files with 361 additions and 120 deletions
|
|
@ -12,7 +12,7 @@ import android.provider.DocumentsProvider;
|
|||
import android.webkit.MimeTypeMap;
|
||||
|
||||
import com.termux.R;
|
||||
import com.termux.app.TermuxService;
|
||||
import com.termux.app.TermuxConstants;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
|
|
@ -35,7 +35,7 @@ public class TermuxDocumentsProvider extends DocumentsProvider {
|
|||
|
||||
private static final String ALL_MIME_TYPES = "*/*";
|
||||
|
||||
private static final File BASE_DIR = new File(TermuxService.HOME_PATH);
|
||||
private static final File BASE_DIR = new File(TermuxConstants.HOME_PATH);
|
||||
|
||||
|
||||
// The default columns to return information about a root if no specific
|
||||
|
|
@ -171,7 +171,7 @@ public class TermuxDocumentsProvider extends DocumentsProvider {
|
|||
// through the whole SD card).
|
||||
boolean isInsideHome;
|
||||
try {
|
||||
isInsideHome = file.getCanonicalPath().startsWith(TermuxService.HOME_PATH);
|
||||
isInsideHome = file.getCanonicalPath().startsWith(TermuxConstants.HOME_PATH);
|
||||
} catch (IOException e) {
|
||||
isInsideHome = true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue