[Android] Check if storage is ignored before showing popup
Geoffrey Métais
git at videolan.org
Wed May 10 16:44:26 CEST 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed May 10 15:46:50 2017 +0200| [1b27419f22ac9d3ec88f5af66c74df4ea2a1d92b] | committer: Geoffrey Métais
Check if storage is ignored before showing popup
> https://code.videolan.org/videolan/vlc-android/commit/1b27419f22ac9d3ec88f5af66c74df4ea2a1d92b
---
.../src/org/videolan/vlc/MediaParsingService.java | 9 +++++++--
.../videolan/vlc/gui/AudioPlayerContainerActivity.java | 17 ++++++++++-------
.../org/videolan/vlc/gui/tv/browser/BaseTvActivity.java | 3 ++-
3 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/MediaParsingService.java b/vlc-android/src/org/videolan/vlc/MediaParsingService.java
index 3dd4fbf..e7b4403 100644
--- a/vlc-android/src/org/videolan/vlc/MediaParsingService.java
+++ b/vlc-android/src/org/videolan/vlc/MediaParsingService.java
@@ -7,6 +7,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Binder;
import android.os.IBinder;
@@ -15,6 +16,7 @@ import android.support.annotation.Nullable;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationManagerCompat;
import android.support.v4.content.LocalBroadcastManager;
+import android.support.v7.preference.PreferenceManager;
import android.text.TextUtils;
import android.util.Log;
@@ -188,10 +190,13 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
List<String> devices = new ArrayList<>();
devices.add(AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY);
devices.addAll(AndroidDevices.getExternalStorageDirectories());
+ SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(MediaParsingService.this);
for (String device : devices) {
boolean isMainStorage = TextUtils.equals(device, AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY);
- boolean isNew = mMedialibrary.addDevice(isMainStorage ? "main-storage" : FileUtils.getFileNameFromPath(device), device, !isMainStorage);
- if (!isMainStorage && isNew) {
+ String uuid = FileUtils.getFileNameFromPath(device);
+ boolean isNew = mMedialibrary.addDevice(isMainStorage ? "main-storage" : uuid, device, !isMainStorage);
+ boolean isIgnored = sharedPreferences.getBoolean("ignore_"+ uuid, false);
+ if (!isMainStorage && isNew && !isIgnored) {
startActivity(new Intent(MediaParsingService.this, DialogActivity.class)
.setAction(DialogActivity.KEY_STORAGE)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
diff --git a/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java b/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
index f6d1a8c..7e1128f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
@@ -39,6 +39,7 @@ import android.support.design.widget.BottomSheetBehavior;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.LocalBroadcastManager;
+import android.support.v7.preference.PreferenceManager;
import android.support.v7.widget.Toolbar;
import android.support.v7.widget.ViewStubCompat;
import android.view.MenuItem;
@@ -354,14 +355,16 @@ public class AudioPlayerContainerActivity extends BaseActivity implements Playba
case ACTION_MEDIA_MOUNTED:
String path = ((Uri) msg.obj).getPath();
removeMessages(ACTION_MEDIA_UNMOUNTED);
- if (VLCApplication.getMLInstance().addDevice(uuid, path, true)) {
- owner.startActivity(new Intent(owner, DialogActivity.class)
- .setAction(DialogActivity.KEY_STORAGE)
- .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+ if (!PreferenceManager.getDefaultSharedPreferences(owner).getBoolean("ignore_"+ uuid, false)) {
+ if (VLCApplication.getMLInstance().addDevice(uuid, path, true)) {
+ owner.startActivity(new Intent(owner, DialogActivity.class)
+ .setAction(DialogActivity.KEY_STORAGE)
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+ .putExtra(MediaParsingService.EXTRA_PATH, path));
+ } else
+ owner.startService(new Intent(MediaParsingService.ACTION_RELOAD, null, owner, MediaParsingService.class)
.putExtra(MediaParsingService.EXTRA_PATH, path));
- } else
- owner.startService(new Intent(MediaParsingService.ACTION_RELOAD, null, owner, MediaParsingService.class)
- .putExtra(MediaParsingService.EXTRA_PATH, path));
+ }
break;
case ACTION_MEDIA_UNMOUNTED:
VLCApplication.getMLInstance().removeDevice(uuid);
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/BaseTvActivity.java b/vlc-android/src/org/videolan/vlc/gui/tv/browser/BaseTvActivity.java
index 79ad55a..189742d 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/BaseTvActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/BaseTvActivity.java
@@ -140,7 +140,8 @@ public abstract class BaseTvActivity extends PlaybackServiceActivity {
} else if (action.equalsIgnoreCase(Intent.ACTION_MEDIA_MOUNTED)) {
String path = intent.getData().getPath();
String uuid = intent.getData().getLastPathSegment();
- if (mMediaLibrary.addDevice(uuid, path, true)) {
+ boolean isIgnored = mSettings.getBoolean("ignore_"+ uuid, false);
+ if (!isIgnored && mMediaLibrary.addDevice(uuid, path, true)) {
startActivity(new Intent(BaseTvActivity.this, DialogActivity.class)
.setAction(DialogActivity.KEY_STORAGE)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
More information about the Android
mailing list