From 2149c94fa0980d476a78c4f845ec9364144868d4 Mon Sep 17 00:00:00 2001 From: Nishith Khanna Date: Thu, 5 May 2022 11:39:21 +0530 Subject: [PATCH] Move all toast message to strings.xml so that they can be translated --- .../features/weather/WeatherPreferences.java | 2 +- .../core/blur/BlurWallpaperProvider.kt | 3 ++- .../features/launcher/LauncherActivity.java | 14 +++++++------- .../features/widgets/WidgetPicker.java | 2 +- app/src/main/res/values/strings.xml | 10 ++++++++++ 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/app/src/apiOreo/java/foundation/e/blisslauncher/features/weather/WeatherPreferences.java b/app/src/apiOreo/java/foundation/e/blisslauncher/features/weather/WeatherPreferences.java index 4b11985e79..4952ceed51 100644 --- a/app/src/apiOreo/java/foundation/e/blisslauncher/features/weather/WeatherPreferences.java +++ b/app/src/apiOreo/java/foundation/e/blisslauncher/features/weather/WeatherPreferences.java @@ -250,7 +250,7 @@ public class WeatherPreferences extends PreferenceActivity implements if (requestCode == 203) { LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); if (!lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) { - Toast.makeText(this, "Set custom location in weather wettings.", + Toast.makeText(this, getString(R.string.toast_custom_location), Toast.LENGTH_SHORT).show(); } else { startService(new Intent(this, WeatherUpdateService.class) diff --git a/app/src/main/java/foundation/e/blisslauncher/core/blur/BlurWallpaperProvider.kt b/app/src/main/java/foundation/e/blisslauncher/core/blur/BlurWallpaperProvider.kt index d3b3b34b74..d495931e69 100644 --- a/app/src/main/java/foundation/e/blisslauncher/core/blur/BlurWallpaperProvider.kt +++ b/app/src/main/java/foundation/e/blisslauncher/core/blur/BlurWallpaperProvider.kt @@ -14,6 +14,7 @@ import android.util.Log import android.view.WindowManager import android.widget.Toast import androidx.core.app.ActivityCompat +import foundation.e.blisslauncher.R import foundation.e.blisslauncher.core.Utilities import foundation.e.blisslauncher.core.runOnMainThread import foundation.e.blisslauncher.core.safeForEach @@ -124,7 +125,7 @@ class BlurWallpaperProvider(val context: Context) { } else { if (error is OutOfMemoryError) { runOnMainThread { - Toast.makeText(context, "Failed", Toast.LENGTH_LONG).show() + Toast.makeText(context, context.getString(R.string.toast_failed), Toast.LENGTH_LONG).show() notifyWallpaperChanged() } } diff --git a/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java b/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java index 09b30bcc4c..f2152588f0 100755 --- a/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java @@ -605,7 +605,7 @@ public class LauncherActivity extends AppCompatActivity implements moveTo = -1; updateOrAddShortcut(shortcutAddEvent.getShortcutItem()); DatabaseManager.getManager(this).saveLayouts(pages, mDock); - Toast.makeText(this, "Shortcut has been added", Toast.LENGTH_SHORT).show(); + Toast.makeText(this, getString(R.string.toast_shortcut_added), Toast.LENGTH_SHORT).show(); if (moveTo != -1) { mHorizontalPager.setCurrentPage(moveTo); moveTo = -1; @@ -1069,7 +1069,7 @@ public class LauncherActivity extends AppCompatActivity implements @Override public void onError(Throwable e) { - Toast.makeText(LauncherActivity.this, "Recreating Launcher", + Toast.makeText(LauncherActivity.this, getString(R.string.toast_recreating_launcher), Toast.LENGTH_SHORT).show(); e.printStackTrace(); recreate(); @@ -1556,7 +1556,7 @@ public class LauncherActivity extends AppCompatActivity implements if (requestCode == REQUEST_LOCATION_SOURCE_SETTING) { LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); if (!lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) { - Toast.makeText(this, "Set custom location in weather settings.", + Toast.makeText(this, getString(R.string.toast_custom_location), Toast.LENGTH_SHORT).show(); } else { startService(new Intent(this, WeatherUpdateService.class) @@ -1816,7 +1816,7 @@ public class LauncherActivity extends AppCompatActivity implements } else { ApplicationItem applicationItem = (ApplicationItem) launcherItem; if (applicationItem.isDisabled) { - Toast.makeText(this, "Package not available or disabled", Toast.LENGTH_SHORT).show(); + Toast.makeText(this, getString(R.string.toast_package_unavailable), Toast.LENGTH_SHORT).show(); } else { if (user == null || user.equals(Process.myUserHandle())) { context.startActivity(intent); @@ -1993,7 +1993,7 @@ public class LauncherActivity extends AppCompatActivity implements // System applications cannot be installed. For now, show a toast explaining // that. // We may give them the option of disabling apps this way. - Toast.makeText(this, "Can not uninstall this app", Toast.LENGTH_SHORT).show(); + Toast.makeText(this, getString(R.string.toast_cannot_uninstall), Toast.LENGTH_SHORT).show(); } else { Uri packageUri = Uri.fromParts("package", componentName.getPackageName(), componentName.getClassName()); @@ -2181,7 +2181,7 @@ public class LauncherActivity extends AppCompatActivity implements if (movingApp.getParent() == null) { if (mDock.getChildCount() >= mDeviceProfile.numColumns) { Toast.makeText(LauncherActivity.this, - "Dock is already full", + getString(R.string.toast_dock_full), Toast.LENGTH_SHORT).show(); } else { addAppToDock(movingApp, EMPTY_LOCATION_DRAG); @@ -2477,7 +2477,7 @@ public class LauncherActivity extends AppCompatActivity implements private void removeAppFromFolder() { if (pages.get(getCurrentAppsPageNumber()).getChildCount() >= mDeviceProfile.maxAppsPerPage) { - Toast.makeText(this, "No more room in page", Toast.LENGTH_SHORT).show(); + Toast.makeText(this, getString(R.string.toast_no_room), Toast.LENGTH_SHORT).show(); movingApp.setVisibility(View.VISIBLE); int currentItem = mFolderAppsViewPager.getCurrentItem(); makeAppWobble(movingApp, true, diff --git a/app/src/main/java/foundation/e/blisslauncher/features/widgets/WidgetPicker.java b/app/src/main/java/foundation/e/blisslauncher/features/widgets/WidgetPicker.java index 6c99bc829f..f537c675ee 100644 --- a/app/src/main/java/foundation/e/blisslauncher/features/widgets/WidgetPicker.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/widgets/WidgetPicker.java @@ -207,7 +207,7 @@ public class WidgetPicker extends Activity implements WidgetPickerAdapter.OnClic if (resultCode == RESULT_OK) { setResultData(RESULT_OK, null); } else { - Toast.makeText(this, "Permission denied", Toast.LENGTH_SHORT).show(); + Toast.makeText(this, getString(R.string.toast_permission_denied), Toast.LENGTH_SHORT).show(); setResultData(RESULT_CANCELED, null); } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5cc01d9cdb..0b81e240b3 100755 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -177,4 +177,14 @@ Do you want to uninstall this shortcut? ok Widget is not resizable + + Permission denied + Set custom location in weather settings. + Failed to set blur wallpaper + Shortcut has been added + Recreating Launcher + Package not available or disabled + Can not uninstall this app + Dock is already full + No more room in page -- GitLab