From 62167a499dba2457e1931a01c003d468f994ebc5 Mon Sep 17 00:00:00 2001 From: Jonas Mayer Date: Tue, 2 Apr 2024 10:55:53 +0200 Subject: [PATCH] Fix by Alper Signed-off-by: Jonas Mayer --- .../java/com/owncloud/android/MainApp.java | 21 ++++++++++++------- .../SystemDefaultStoragePointProvider.java | 2 +- .../owncloud/android/utils/DisplayUtils.java | 2 +- .../android/utils/theme/ThemeUtils.java | 2 +- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/MainApp.java b/app/src/main/java/com/owncloud/android/MainApp.java index 96293e2e4577..a8b19e9eaeda 100644 --- a/app/src/main/java/com/owncloud/android/MainApp.java +++ b/app/src/main/java/com/owncloud/android/MainApp.java @@ -647,6 +647,13 @@ && getAppContext() != null) { } } + public static String string(int id) { + return getAppContext().getString(id); + } + + public static String string(int id, Object args) { + return getAppContext().getString(id, args); + } public static Context getAppContext() { return MainApp.mContext; @@ -674,32 +681,32 @@ public static String getAccountType(Context context) { // From AccountAuthenticator // public static final String AUTHORITY = "org.owncloud"; public static String getAuthority() { - return getAppContext().getResources().getString(R.string.authority); + return string(R.string.authority); } // From AccountAuthenticator // public static final String AUTH_TOKEN_TYPE = "org.owncloud"; public static String getAuthTokenType() { - return getAppContext().getResources().getString(R.string.authority); + return string(R.string.authority); } // From ProviderMeta // public static final String DB_FILE = "owncloud.db"; public static String getDBFile() { - return getAppContext().getResources().getString(R.string.db_file); + return string(R.string.db_file); } // From ProviderMeta // private final String mDatabaseName = "ownCloud"; public static String getDBName() { - return getAppContext().getResources().getString(R.string.db_name); + return string(R.string.db_name); } /** * name of data_folder, e.g., "owncloud" */ public static String getDataFolder() { - return getAppContext().getResources().getString(R.string.data_folder); + return string(R.string.data_folder); } public static void showOnlyFilesOnDevice(boolean state) { @@ -725,8 +732,8 @@ public static String getUserAgent() { // user agent private static String getUserAgent(@StringRes int agent) { - String appString = getAppContext().getResources().getString(agent); - String brandedName = getAppContext().getString(R.string.name_for_branded_user_agent); + String appString = string(agent); + String brandedName = string(R.string.name_for_branded_user_agent); String packageName = getAppContext().getPackageName(); String version = ""; diff --git a/app/src/main/java/com/owncloud/android/datastorage/providers/SystemDefaultStoragePointProvider.java b/app/src/main/java/com/owncloud/android/datastorage/providers/SystemDefaultStoragePointProvider.java index cbaee1a1b826..231cf27d81f3 100644 --- a/app/src/main/java/com/owncloud/android/datastorage/providers/SystemDefaultStoragePointProvider.java +++ b/app/src/main/java/com/owncloud/android/datastorage/providers/SystemDefaultStoragePointProvider.java @@ -40,7 +40,7 @@ public boolean canProvideStoragePoints() { public Vector getAvailableStoragePoint() { Vector result = new Vector<>(); - final String defaultStringDesc = MainApp.getAppContext().getString(R.string.storage_description_default); + final String defaultStringDesc = MainApp.string(R.string.storage_description_default); // Add private internal storage data directory. result.add(new StoragePoint(defaultStringDesc, MainApp.getAppContext().getFilesDir().getAbsolutePath(), StoragePoint.StorageType.INTERNAL, diff --git a/app/src/main/java/com/owncloud/android/utils/DisplayUtils.java b/app/src/main/java/com/owncloud/android/utils/DisplayUtils.java index 4a39b5ba1517..009b3ed0f885 100644 --- a/app/src/main/java/com/owncloud/android/utils/DisplayUtils.java +++ b/app/src/main/java/com/owncloud/android/utils/DisplayUtils.java @@ -180,7 +180,7 @@ private DisplayUtils() { */ public static String bytesToHumanReadable(long bytes) { if (bytes < 0) { - return MainApp.getAppContext().getString(R.string.common_pending); + return MainApp.string(R.string.common_pending); } else { double result = bytes; int suffixIndex = 0; diff --git a/app/src/main/java/com/owncloud/android/utils/theme/ThemeUtils.java b/app/src/main/java/com/owncloud/android/utils/theme/ThemeUtils.java index 37facb9963ed..b19bbe7eb37b 100644 --- a/app/src/main/java/com/owncloud/android/utils/theme/ThemeUtils.java +++ b/app/src/main/java/com/owncloud/android/utils/theme/ThemeUtils.java @@ -43,7 +43,7 @@ public String getDefaultDisplayNameForRootFolder(Context context) { OCCapability capability = CapabilityUtils.getCapability(context); if (MainApp.isOnlyOnDevice()) { - return MainApp.getAppContext().getString(R.string.drawer_item_on_device); + return MainApp.string(R.string.drawer_item_on_device); } else { if (capability.getServerName() == null || capability.getServerName().isEmpty()) { return MainApp.getAppContext().getResources().getString(R.string.default_display_name_for_root_folder);