Remove storage error activity
We fall back to the internal memory silently, so these code paths are never actually called.
This commit is contained in:
parent
4f2ba0b58e
commit
8dc9dd888e
@ -158,8 +158,6 @@
|
|||||||
android:resource="@xml/player_widget_info"/>
|
android:resource="@xml/player_widget_info"/>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
<activity android:name=".activity.StorageErrorActivity">
|
|
||||||
</activity>
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.OpmlImportActivity"
|
android:name=".activity.OpmlImportActivity"
|
||||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||||
|
@ -50,7 +50,6 @@ import de.danoeh.antennapod.event.MessageEvent;
|
|||||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||||
import de.danoeh.antennapod.core.receiver.MediaButtonReceiver;
|
import de.danoeh.antennapod.core.receiver.MediaButtonReceiver;
|
||||||
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
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.core.util.download.AutoUpdateManager;
|
||||||
import de.danoeh.antennapod.dialog.RatingDialog;
|
import de.danoeh.antennapod.dialog.RatingDialog;
|
||||||
import de.danoeh.antennapod.fragment.AddFeedFragment;
|
import de.danoeh.antennapod.fragment.AddFeedFragment;
|
||||||
@ -112,7 +111,6 @@ public class MainActivity extends CastEnabledActivity {
|
|||||||
ensureGeneratedViewIdGreaterThan(savedInstanceState.getInt(KEY_GENERATED_VIEW_ID, 0));
|
ensureGeneratedViewIdGreaterThan(savedInstanceState.getInt(KEY_GENERATED_VIEW_ID, 0));
|
||||||
}
|
}
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
StorageUtils.checkStorageAvailability(this);
|
|
||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
recycledViewPool.setMaxRecycledViews(R.id.view_type_episode_item, 25);
|
recycledViewPool.setMaxRecycledViews(R.id.view_type_episode_item, 25);
|
||||||
|
|
||||||
@ -414,7 +412,6 @@ public class MainActivity extends CastEnabledActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
StorageUtils.checkStorageAvailability(this);
|
|
||||||
handleNavIntent();
|
handleNavIntent();
|
||||||
RatingDialog.check();
|
RatingDialog.check();
|
||||||
|
|
||||||
|
@ -56,7 +56,6 @@ import de.danoeh.antennapod.parser.feed.FeedHandler;
|
|||||||
import de.danoeh.antennapod.parser.feed.FeedHandlerResult;
|
import de.danoeh.antennapod.parser.feed.FeedHandlerResult;
|
||||||
import de.danoeh.antennapod.model.download.DownloadError;
|
import de.danoeh.antennapod.model.download.DownloadError;
|
||||||
import de.danoeh.antennapod.core.util.IntentUtils;
|
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.URLChecker;
|
||||||
import de.danoeh.antennapod.core.util.syndication.FeedDiscoverer;
|
import de.danoeh.antennapod.core.util.syndication.FeedDiscoverer;
|
||||||
import de.danoeh.antennapod.core.util.syndication.HtmlToPlainText;
|
import de.danoeh.antennapod.core.util.syndication.HtmlToPlainText;
|
||||||
@ -122,7 +121,6 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
setTheme(UserPreferences.getTranslucentTheme());
|
setTheme(UserPreferences.getTranslucentTheme());
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
StorageUtils.checkStorageAvailability(this);
|
|
||||||
|
|
||||||
viewBinding = OnlinefeedviewActivityBinding.inflate(getLayoutInflater());
|
viewBinding = OnlinefeedviewActivityBinding.inflate(getLayoutInflater());
|
||||||
setContentView(viewBinding.getRoot());
|
setContentView(viewBinding.getRoot());
|
||||||
|
@ -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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
@ -50,7 +50,6 @@ import de.danoeh.antennapod.core.util.Converter;
|
|||||||
import de.danoeh.antennapod.core.util.FeedItemUtil;
|
import de.danoeh.antennapod.core.util.FeedItemUtil;
|
||||||
import de.danoeh.antennapod.core.util.IntentUtils;
|
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||||
import de.danoeh.antennapod.core.util.ShareUtils;
|
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.TimeSpeedConverter;
|
||||||
import de.danoeh.antennapod.core.util.gui.PictureInPictureUtil;
|
import de.danoeh.antennapod.core.util.gui.PictureInPictureUtil;
|
||||||
import de.danoeh.antennapod.core.util.playback.PlaybackController;
|
import de.danoeh.antennapod.core.util.playback.PlaybackController;
|
||||||
@ -107,7 +106,6 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
Log.d(TAG, "onCreate()");
|
Log.d(TAG, "onCreate()");
|
||||||
StorageUtils.checkStorageAvailability(this);
|
|
||||||
|
|
||||||
getWindow().setFormat(PixelFormat.TRANSPARENT);
|
getWindow().setFormat(PixelFormat.TRANSPARENT);
|
||||||
viewBinding = VideoplayerActivityBinding.inflate(LayoutInflater.from(this));
|
viewBinding = VideoplayerActivityBinding.inflate(LayoutInflater.from(this));
|
||||||
@ -120,7 +118,6 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
|
|||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
StorageUtils.checkStorageAvailability(this);
|
|
||||||
switchToAudioOnly = false;
|
switchToAudioOnly = false;
|
||||||
if (PlaybackService.isCasting()) {
|
if (PlaybackService.isCasting()) {
|
||||||
Intent intent = PlaybackService.getPlayerActivityIntent(this);
|
Intent intent = PlaybackService.getPlayerActivityIntent(this);
|
||||||
|
@ -2,11 +2,8 @@ package de.danoeh.antennapod.config;
|
|||||||
|
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
|
|
||||||
import de.danoeh.antennapod.PodcastApp;
|
import de.danoeh.antennapod.PodcastApp;
|
||||||
import de.danoeh.antennapod.activity.StorageErrorActivity;
|
|
||||||
import de.danoeh.antennapod.core.ApplicationCallbacks;
|
import de.danoeh.antennapod.core.ApplicationCallbacks;
|
||||||
|
|
||||||
public class ApplicationCallbacksImpl implements ApplicationCallbacks {
|
public class ApplicationCallbacksImpl implements ApplicationCallbacks {
|
||||||
@ -15,10 +12,4 @@ public class ApplicationCallbacksImpl implements ApplicationCallbacks {
|
|||||||
public Application getApplicationInstance() {
|
public Application getApplicationInstance() {
|
||||||
return PodcastApp.getInstance();
|
return PodcastApp.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Intent getStorageErrorActivity(Context context) {
|
|
||||||
return new Intent(context, StorageErrorActivity.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,15 +29,8 @@ public class ChooseDataFolderDialog {
|
|||||||
});
|
});
|
||||||
((RecyclerView) content.findViewById(R.id.recyclerView)).setAdapter(adapter);
|
((RecyclerView) content.findViewById(R.id.recyclerView)).setAdapter(adapter);
|
||||||
|
|
||||||
if (adapter.getItemCount() > 0) {
|
if (adapter.getItemCount() != 0) {
|
||||||
dialog.show();
|
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
@ -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>
|
|
@ -1,8 +1,6 @@
|
|||||||
package de.danoeh.antennapod.core;
|
package de.danoeh.antennapod.core;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callbacks related to the application in general
|
* Callbacks related to the application in general
|
||||||
@ -13,11 +11,4 @@ public interface ApplicationCallbacks {
|
|||||||
* Returns a non-null instance of the application class
|
* Returns a non-null instance of the application class
|
||||||
*/
|
*/
|
||||||
Application getApplicationInstance();
|
Application getApplicationInstance();
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a non-null intent that starts the storage error
|
|
||||||
* activity.
|
|
||||||
*/
|
|
||||||
Intent getStorageErrorActivity(Context context);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -113,9 +113,6 @@ public class HttpDownloader extends Downloader {
|
|||||||
} else if (!response.isSuccessful() || response.body() == null) {
|
} else if (!response.isSuccessful() || response.body() == null) {
|
||||||
callOnFailByResponseCode(response);
|
callOnFailByResponseCode(response);
|
||||||
return;
|
return;
|
||||||
} else if (!StorageUtils.storageAvailable()) {
|
|
||||||
onFail(DownloadError.ERROR_DEVICE_NOT_FOUND, null);
|
|
||||||
return;
|
|
||||||
} else if (request.getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA
|
} else if (request.getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA
|
||||||
&& isContentTypeTextAndSmallerThan100kb(response)) {
|
&& isContentTypeTextAndSmallerThan100kb(response)) {
|
||||||
onFail(DownloadError.ERROR_FILE_TYPE, null);
|
onFail(DownloadError.ERROR_FILE_TYPE, null);
|
||||||
|
@ -1,50 +1,16 @@
|
|||||||
package de.danoeh.antennapod.core.util;
|
package de.danoeh.antennapod.core.util;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.os.StatFs;
|
import android.os.StatFs;
|
||||||
import android.util.Log;
|
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import de.danoeh.antennapod.core.ClientConfig;
|
|
||||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility functions for handling storage errors
|
* Utility functions for handling storage errors
|
||||||
*/
|
*/
|
||||||
public class StorageUtils {
|
public class StorageUtils {
|
||||||
private 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.
|
* Get the number of free bytes that are available on the external storage.
|
||||||
*/
|
*/
|
||||||
|
@ -95,7 +95,6 @@
|
|||||||
<string name="error_label">Error</string>
|
<string name="error_label">Error</string>
|
||||||
<string name="error_msg_prefix">An error occurred:</string>
|
<string name="error_msg_prefix">An error occurred:</string>
|
||||||
<string name="refresh_label">Refresh</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="chapters_label">Chapters</string>
|
||||||
<string name="chapter_duration">Duration: %1$s</string>
|
<string name="chapter_duration">Duration: %1$s</string>
|
||||||
<string name="description_label">Description</string>
|
<string name="description_label">Description</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user