diff options
author | ByteHamster <info@bytehamster.com> | 2022-07-30 21:42:07 +0200 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2022-07-30 21:50:14 +0200 |
commit | 8dc9dd888e1e1252fe422341720f7e45f05954cd (patch) | |
tree | b4b135a5d678ff533366c63ae8d3e2fa97dd39c4 | |
parent | 4f2ba0b58eadcda69693025319e96cfee79b2ce7 (diff) | |
download | AntennaPod-8dc9dd888e1e1252fe422341720f7e45f05954cd.zip |
Remove storage error activity
We fall back to the internal memory silently, so these code paths are
never actually called.
12 files changed, 3 insertions, 188 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 93f1494f2..50ed82646 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -158,8 +158,6 @@ android:resource="@xml/player_widget_info"/> </receiver> - <activity android:name=".activity.StorageErrorActivity"> - </activity> <activity android:name=".activity.OpmlImportActivity" android:configChanges="keyboardHidden|orientation|screenSize" diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java index 19b08fc02..fe5d8733a 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java @@ -50,7 +50,6 @@ import de.danoeh.antennapod.event.MessageEvent; import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.receiver.MediaButtonReceiver; import de.danoeh.antennapod.core.service.playback.PlaybackService; -import de.danoeh.antennapod.core.util.StorageUtils; import de.danoeh.antennapod.core.util.download.AutoUpdateManager; import de.danoeh.antennapod.dialog.RatingDialog; import de.danoeh.antennapod.fragment.AddFeedFragment; @@ -112,7 +111,6 @@ public class MainActivity extends CastEnabledActivity { ensureGeneratedViewIdGreaterThan(savedInstanceState.getInt(KEY_GENERATED_VIEW_ID, 0)); } super.onCreate(savedInstanceState); - StorageUtils.checkStorageAvailability(this); setContentView(R.layout.main); recycledViewPool.setMaxRecycledViews(R.id.view_type_episode_item, 25); @@ -414,7 +412,6 @@ public class MainActivity extends CastEnabledActivity { @Override protected void onResume() { super.onResume(); - StorageUtils.checkStorageAvailability(this); handleNavIntent(); RatingDialog.check(); diff --git a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java index 3b28a5e27..67647b999 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java @@ -56,7 +56,6 @@ import de.danoeh.antennapod.parser.feed.FeedHandler; import de.danoeh.antennapod.parser.feed.FeedHandlerResult; import de.danoeh.antennapod.model.download.DownloadError; import de.danoeh.antennapod.core.util.IntentUtils; -import de.danoeh.antennapod.core.util.StorageUtils; import de.danoeh.antennapod.core.util.URLChecker; import de.danoeh.antennapod.core.util.syndication.FeedDiscoverer; import de.danoeh.antennapod.core.util.syndication.HtmlToPlainText; @@ -122,7 +121,6 @@ public class OnlineFeedViewActivity extends AppCompatActivity { protected void onCreate(Bundle savedInstanceState) { setTheme(UserPreferences.getTranslucentTheme()); super.onCreate(savedInstanceState); - StorageUtils.checkStorageAvailability(this); viewBinding = OnlinefeedviewActivityBinding.inflate(getLayoutInflater()); setContentView(viewBinding.getRoot()); diff --git a/app/src/main/java/de/danoeh/antennapod/activity/StorageErrorActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/StorageErrorActivity.java deleted file mode 100644 index 4947f478a..000000000 --- a/app/src/main/java/de/danoeh/antennapod/activity/StorageErrorActivity.java +++ /dev/null @@ -1,79 +0,0 @@ -package de.danoeh.antennapod.activity; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.os.Bundle; -import android.text.TextUtils; -import android.util.Log; -import android.widget.Button; -import androidx.appcompat.app.AppCompatActivity; -import de.danoeh.antennapod.R; -import de.danoeh.antennapod.core.preferences.UserPreferences; -import de.danoeh.antennapod.core.util.StorageUtils; -import de.danoeh.antennapod.dialog.ChooseDataFolderDialog; - -/** - * Is show if there is now external storage available. - */ -public class StorageErrorActivity extends AppCompatActivity { - private static final String TAG = "StorageErrorActivity"; - - @Override - protected void onCreate(Bundle savedInstanceState) { - setTheme(UserPreferences.getTheme()); - super.onCreate(savedInstanceState); - - setContentView(R.layout.storage_error); - - Button btnChooseDataFolder = findViewById(R.id.btnChooseDataFolder); - btnChooseDataFolder.setOnClickListener(v -> - ChooseDataFolderDialog.showDialog(this, path -> { - UserPreferences.setDataFolder(path); - leaveErrorState(); - })); - } - - @Override - protected void onResume() { - super.onResume(); - if (StorageUtils.storageAvailable()) { - leaveErrorState(); - } else { - registerReceiver(mediaUpdate, new IntentFilter(Intent.ACTION_MEDIA_MOUNTED)); - } - } - - @Override - protected void onPause() { - super.onPause(); - try { - unregisterReceiver(mediaUpdate); - } catch (IllegalArgumentException e) { - Log.e(TAG, Log.getStackTraceString(e)); - } - } - - private void leaveErrorState() { - finish(); - startActivity(new Intent(this, MainActivity.class)); - } - - private final BroadcastReceiver mediaUpdate = new BroadcastReceiver() { - - @Override - public void onReceive(Context context, Intent intent) { - if (TextUtils.equals(intent.getAction(), Intent.ACTION_MEDIA_MOUNTED)) { - if (intent.getBooleanExtra("read-only", true)) { - Log.d(TAG, "Media was mounted; Finishing activity"); - leaveErrorState(); - } else { - Log.d(TAG, "Media seemed to have been mounted read only"); - } - } - } - - }; - -} diff --git a/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java index 9ffade1ca..048d04939 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java @@ -50,7 +50,6 @@ import de.danoeh.antennapod.core.util.Converter; import de.danoeh.antennapod.core.util.FeedItemUtil; import de.danoeh.antennapod.core.util.IntentUtils; import de.danoeh.antennapod.core.util.ShareUtils; -import de.danoeh.antennapod.core.util.StorageUtils; import de.danoeh.antennapod.core.util.TimeSpeedConverter; import de.danoeh.antennapod.core.util.gui.PictureInPictureUtil; import de.danoeh.antennapod.core.util.playback.PlaybackController; @@ -107,7 +106,6 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar. super.onCreate(savedInstanceState); Log.d(TAG, "onCreate()"); - StorageUtils.checkStorageAvailability(this); getWindow().setFormat(PixelFormat.TRANSPARENT); viewBinding = VideoplayerActivityBinding.inflate(LayoutInflater.from(this)); @@ -120,7 +118,6 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar. @Override protected void onResume() { super.onResume(); - StorageUtils.checkStorageAvailability(this); switchToAudioOnly = false; if (PlaybackService.isCasting()) { Intent intent = PlaybackService.getPlayerActivityIntent(this); diff --git a/app/src/main/java/de/danoeh/antennapod/config/ApplicationCallbacksImpl.java b/app/src/main/java/de/danoeh/antennapod/config/ApplicationCallbacksImpl.java index 008aacfa5..e9dfd66e0 100644 --- a/app/src/main/java/de/danoeh/antennapod/config/ApplicationCallbacksImpl.java +++ b/app/src/main/java/de/danoeh/antennapod/config/ApplicationCallbacksImpl.java @@ -2,11 +2,8 @@ package de.danoeh.antennapod.config; import android.app.Application; -import android.content.Context; -import android.content.Intent; import de.danoeh.antennapod.PodcastApp; -import de.danoeh.antennapod.activity.StorageErrorActivity; import de.danoeh.antennapod.core.ApplicationCallbacks; public class ApplicationCallbacksImpl implements ApplicationCallbacks { @@ -15,10 +12,4 @@ public class ApplicationCallbacksImpl implements ApplicationCallbacks { public Application getApplicationInstance() { return PodcastApp.getInstance(); } - - @Override - public Intent getStorageErrorActivity(Context context) { - return new Intent(context, StorageErrorActivity.class); - } - } diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/ChooseDataFolderDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/ChooseDataFolderDialog.java index 2c375f5cd..fc34292cf 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/ChooseDataFolderDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/ChooseDataFolderDialog.java @@ -29,15 +29,8 @@ public class ChooseDataFolderDialog { }); ((RecyclerView) content.findViewById(R.id.recyclerView)).setAdapter(adapter); - if (adapter.getItemCount() > 0) { + if (adapter.getItemCount() != 0) { dialog.show(); - } else { - new AlertDialog.Builder(context) - .setTitle(R.string.error_label) - .setMessage(R.string.external_storage_error_msg) - .setPositiveButton(android.R.string.ok, null) - .show(); } } - -}
\ No newline at end of file +} diff --git a/app/src/main/res/layout/storage_error.xml b/app/src/main/res/layout/storage_error.xml deleted file mode 100644 index 6a7fda341..000000000 --- a/app/src/main/res/layout/storage_error.xml +++ /dev/null @@ -1,33 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" - android:gravity="center" - android:padding="16dp"> - - <ImageView - android:id="@+id/imageView1" - android:contentDescription="@string/external_storage_error_msg" - android:layout_width="36dp" - android:layout_height="36dp" - android:layout_margin="8dp" - app:srcCompat="@drawable/ic_storage" /> - - <TextView - android:id="@+id/textView1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_margin="8dp" - android:text="@string/external_storage_error_msg" /> - - <Button - android:id="@+id/btnChooseDataFolder" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_margin="8dp" - android:text="@string/choose_data_directory"/> - -</LinearLayout> diff --git a/core/src/main/java/de/danoeh/antennapod/core/ApplicationCallbacks.java b/core/src/main/java/de/danoeh/antennapod/core/ApplicationCallbacks.java index 3acc84e3b..3b591363f 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/ApplicationCallbacks.java +++ b/core/src/main/java/de/danoeh/antennapod/core/ApplicationCallbacks.java @@ -1,8 +1,6 @@ package de.danoeh.antennapod.core; import android.app.Application; -import android.content.Context; -import android.content.Intent; /** * Callbacks related to the application in general @@ -13,11 +11,4 @@ public interface ApplicationCallbacks { * Returns a non-null instance of the application class */ Application getApplicationInstance(); - - /** - * Returns a non-null intent that starts the storage error - * activity. - */ - Intent getStorageErrorActivity(Context context); - } diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/HttpDownloader.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/HttpDownloader.java index 3238ce5f1..9a2a10490 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/HttpDownloader.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/HttpDownloader.java @@ -113,9 +113,6 @@ public class HttpDownloader extends Downloader { } else if (!response.isSuccessful() || response.body() == null) { callOnFailByResponseCode(response); return; - } else if (!StorageUtils.storageAvailable()) { - onFail(DownloadError.ERROR_DEVICE_NOT_FOUND, null); - return; } else if (request.getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA && isContentTypeTextAndSmallerThan100kb(response)) { onFail(DownloadError.ERROR_FILE_TYPE, null); diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/StorageUtils.java b/core/src/main/java/de/danoeh/antennapod/core/util/StorageUtils.java index cf049ed80..c15d80b6f 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/StorageUtils.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/StorageUtils.java @@ -1,50 +1,16 @@ package de.danoeh.antennapod.core.util; -import android.app.Activity; import android.os.StatFs; -import android.util.Log; +import de.danoeh.antennapod.core.preferences.UserPreferences; import java.io.File; -import de.danoeh.antennapod.core.ClientConfig; -import de.danoeh.antennapod.core.preferences.UserPreferences; - /** * Utility functions for handling storage errors */ public class StorageUtils { private StorageUtils(){} - private static final String TAG = "StorageUtils"; - - public static boolean storageAvailable() { - File dir = UserPreferences.getDataFolder(null); - if (dir != null) { - return dir.exists() && dir.canRead() && dir.canWrite(); - } else { - Log.d(TAG, "Storage not available: data folder is null"); - return false; - } - } - - /** - * Checks if external storage is available. If external storage isn't - * available, the current activity is finsished an an error activity is - * launched. - * - * @param activity the activity which would be finished if no storage is - * available - * @return true if external storage is available - */ - public static boolean checkStorageAvailability(Activity activity) { - boolean storageAvailable = storageAvailable(); - if (!storageAvailable) { - activity.finish(); - activity.startActivity(ClientConfig.applicationCallbacks.getStorageErrorActivity(activity)); - } - return storageAvailable; - } - /** * Get the number of free bytes that are available on the external storage. */ diff --git a/ui/i18n/src/main/res/values/strings.xml b/ui/i18n/src/main/res/values/strings.xml index a41367e24..564c24bb6 100644 --- a/ui/i18n/src/main/res/values/strings.xml +++ b/ui/i18n/src/main/res/values/strings.xml @@ -95,7 +95,6 @@ <string name="error_label">Error</string> <string name="error_msg_prefix">An error occurred:</string> <string name="refresh_label">Refresh</string> - <string name="external_storage_error_msg">No external storage is available. Please make sure that external storage is mounted so that the app can work properly.</string> <string name="chapters_label">Chapters</string> <string name="chapter_duration">Duration: %1$s</string> <string name="description_label">Description</string> |