From 33e5d3106e3c6e4eed5c881243ba5affe18c8566 Mon Sep 17 00:00:00 2001 From: paul-loedige Date: Sun, 27 Dec 2020 13:57:30 +0100 Subject: [PATCH] moved XML submodule to resources --- .gitmodules | 4 +- .../aped/utils/ExternalStorageHandler.java | 53 +++++++++++++++++++ APED/app/src/main/java/com/example/aped/xml | 1 - APED/app/src/main/res/raw/XML | 1 + 4 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 APED/app/src/main/java/com/example/aped/utils/ExternalStorageHandler.java delete mode 160000 APED/app/src/main/java/com/example/aped/xml create mode 160000 APED/app/src/main/res/raw/XML diff --git a/.gitmodules b/.gitmodules index 74fcc03..e7b6f15 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "APED/app/src/main/java/com/example/aped/xml"] - path = APED/app/src/main/java/com/example/aped/xml +[submodule "APED/app/src/main/res/raw/XML"] + path = APED/app/src/main/res/raw/XML url = https://its-gitlab.init.hs-owl.de/mo_b_l/aped_xml_configs.git diff --git a/APED/app/src/main/java/com/example/aped/utils/ExternalStorageHandler.java b/APED/app/src/main/java/com/example/aped/utils/ExternalStorageHandler.java new file mode 100644 index 0000000..886478b --- /dev/null +++ b/APED/app/src/main/java/com/example/aped/utils/ExternalStorageHandler.java @@ -0,0 +1,53 @@ +package com.example.aped.utils; + +import android.content.Context; +import android.os.Environment; + +import java.io.File; +import java.io.FileNotFoundException; + +/** + * Utility for getting information related to the external storage. + */ +public final class ExternalStorageHandler { + + private ExternalStorageHandler() { } + + /** + * Checks whether the external storage is mounted. + * @return boolean value + */ + public static boolean isExternalStorageMounted() { + return Environment.MEDIA_MOUNTED.equals( + Environment.getExternalStorageState() + ); + } + + /** + * Checks whether the external storage is read only. + * @return boolean value + */ + public static boolean isExternalStorageReadOnly() { + return Environment.MEDIA_MOUNTED_READ_ONLY.equals( + Environment.getExternalStorageState() + ); + } + + /** + * Returns the external private storage base directory path for an activity. + * @param context the relevant activity + * @return the path to the base of the external private storage + * @throws FileNotFoundException checks if the directory is mounted + */ + public static String getExternalPrivateStorageDir(final Context context) + throws FileNotFoundException { + if (isExternalStorageMounted()) { + File file = context.getExternalCacheDir(); + return file.getAbsolutePath(); + } else { + throw new FileNotFoundException( + "The relevant storage is not available." + ); + } + } +} diff --git a/APED/app/src/main/java/com/example/aped/xml b/APED/app/src/main/java/com/example/aped/xml deleted file mode 160000 index 3600828..0000000 --- a/APED/app/src/main/java/com/example/aped/xml +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3600828925b4f02fcf472797c5cf526d24f53f63 diff --git a/APED/app/src/main/res/raw/XML b/APED/app/src/main/res/raw/XML new file mode 160000 index 0000000..ce8ce41 --- /dev/null +++ b/APED/app/src/main/res/raw/XML @@ -0,0 +1 @@ +Subproject commit ce8ce41609a1a7ef9282cbcdda3358f9c2ec6939