[Android] Do not notify devices added on startup
Geoffrey Métais
git at videolan.org
Fri May 19 11:19:39 CEST 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri May 19 09:51:46 2017 +0200| [96ac3134ce64eb64f5b76d250236d99ca3b8ad6f] | committer: Geoffrey Métais
Do not notify devices added on startup
> https://code.videolan.org/videolan/vlc-android/commit/96ac3134ce64eb64f5b76d250236d99ca3b8ad6f
---
medialibrary/jni/AndroidMediaLibrary.cpp | 4 ++--
medialibrary/jni/AndroidMediaLibrary.h | 2 +-
medialibrary/jni/medialibrary.cpp | 6 +++---
medialibrary/src/org/videolan/medialibrary/Medialibrary.java | 6 +++---
vlc-android/src/org/videolan/vlc/MediaParsingService.java | 4 ++--
.../src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java | 2 +-
vlc-android/src/org/videolan/vlc/gui/tv/browser/BaseTvActivity.java | 2 +-
7 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/medialibrary/jni/AndroidMediaLibrary.cpp b/medialibrary/jni/AndroidMediaLibrary.cpp
index c38381e..8444389 100644
--- a/medialibrary/jni/AndroidMediaLibrary.cpp
+++ b/medialibrary/jni/AndroidMediaLibrary.cpp
@@ -68,10 +68,10 @@ AndroidMediaLibrary::start()
}
bool
-AndroidMediaLibrary::addDevice(const std::string& uuid, const std::string& path, bool removable)
+AndroidMediaLibrary::addDevice(const std::string& uuid, const std::string& path, bool removable, bool notify)
{
p_lister->addDevice(uuid, path, removable);
- return p_DeviceListerCb != nullptr && p_DeviceListerCb->onDevicePlugged(uuid, path);
+ return notify && p_DeviceListerCb != nullptr && p_DeviceListerCb->onDevicePlugged(uuid, path);
}
std::vector<std::tuple<std::string, std::string, bool>>
diff --git a/medialibrary/jni/AndroidMediaLibrary.h b/medialibrary/jni/AndroidMediaLibrary.h
index 96b1e0e..ef3d4ec 100644
--- a/medialibrary/jni/AndroidMediaLibrary.h
+++ b/medialibrary/jni/AndroidMediaLibrary.h
@@ -30,7 +30,7 @@ public:
bool initML(const std::string& dbPath, const std::string& thumbsPath);
void start();
- bool addDevice(const std::string& uuid, const std::string& path, bool removable);
+ bool addDevice(const std::string& uuid, const std::string& path, bool removable, bool notif);
std::vector<std::tuple<std::string, std::string, bool>> devices();
bool removeDevice(const std::string& uuid);
void banFolder(const std::string& path);
diff --git a/medialibrary/jni/medialibrary.cpp b/medialibrary/jni/medialibrary.cpp
index da9701f..e78d597 100644
--- a/medialibrary/jni/medialibrary.cpp
+++ b/medialibrary/jni/medialibrary.cpp
@@ -65,12 +65,12 @@ banFolder(JNIEnv* env, jobject thiz, jstring folderPath)
}
jboolean
-addDevice(JNIEnv* env, jobject thiz, jstring uuid, jstring storagePath, jboolean removable)
+addDevice(JNIEnv* env, jobject thiz, jstring uuid, jstring storagePath, jboolean removable, jboolean notify)
{
AndroidMediaLibrary *aml = MediaLibrary_getInstance(env, thiz);
const char *uuidChar = env->GetStringUTFChars(uuid, JNI_FALSE);
const char *path = env->GetStringUTFChars(storagePath, JNI_FALSE);
- jboolean isNew = aml->addDevice(uuidChar, path, removable);
+ jboolean isNew = aml->addDevice(uuidChar, path, removable, notify);
env->ReleaseStringUTFChars(uuid, uuidChar);
env->ReleaseStringUTFChars(storagePath, path);
return isNew;
@@ -745,7 +745,7 @@ static JNINativeMethod methods[] = {
{"nativeInit", "(Ljava/lang/String;Ljava/lang/String;)Z", (void*)init },
{"nativeStart", "()V", (void*)start },
{"nativeRelease", "()V", (void*)release },
- {"nativeAddDevice", "(Ljava/lang/String;Ljava/lang/String;Z)Z", (void*)addDevice },
+ {"nativeAddDevice", "(Ljava/lang/String;Ljava/lang/String;ZZ)Z", (void*)addDevice },
{"nativeDevices", "()[Ljava/lang/String;", (void*)devices },
{"nativeDiscover", "(Ljava/lang/String;)V", (void*)discover },
{"nativeRemoveEntryPoint", "(Ljava/lang/String;)V", (void*)removeEntryPoint },
diff --git a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
index 75c86db..1113412 100644
--- a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
+++ b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
@@ -94,8 +94,8 @@ public class Medialibrary {
return mIsInitiated ? nativeDevices() : new String[0];
}
- public boolean addDevice(String uuid, String path, boolean removable) {
- return nativeAddDevice(uuid, Tools.encodeVLCMrl(path), removable);
+ public boolean addDevice(String uuid, String path, boolean removable, boolean notify) {
+ return nativeAddDevice(uuid, Tools.encodeVLCMrl(path), removable, notify);
}
public void discover(String path) {
@@ -557,7 +557,7 @@ public class Medialibrary {
private native void nativeStart();
private native void nativeRelease();
private native void nativeBanFolder(String path);
- private native boolean nativeAddDevice(String uuid, String path, boolean removable);
+ private native boolean nativeAddDevice(String uuid, String path, boolean removable, boolean notify);
private native String[] nativeDevices();
private native void nativeDiscover(String path);
private native void nativeRemoveEntryPoint(String path);
diff --git a/vlc-android/src/org/videolan/vlc/MediaParsingService.java b/vlc-android/src/org/videolan/vlc/MediaParsingService.java
index ec8bc85..c4fcfa3 100644
--- a/vlc-android/src/org/videolan/vlc/MediaParsingService.java
+++ b/vlc-android/src/org/videolan/vlc/MediaParsingService.java
@@ -177,7 +177,7 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
String uuid = FileUtils.getFileNameFromPath(path);
if (TextUtils.isEmpty(uuid))
uuid = "root";
- mMedialibrary.addDevice(uuid, path, true);
+ mMedialibrary.addDevice(uuid, path, true, true);
}
}
}
@@ -208,7 +208,7 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
for (String device : devices) {
boolean isMainStorage = TextUtils.equals(device, AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY);
String uuid = FileUtils.getFileNameFromPath(device);
- boolean isNew = mMedialibrary.addDevice(isMainStorage ? "main-storage" : uuid, device, !isMainStorage);
+ boolean isNew = mMedialibrary.addDevice(isMainStorage ? "main-storage" : uuid, device, !isMainStorage, false);
boolean isIgnored = sharedPreferences.getBoolean("ignore_"+ uuid, false);
if (!isMainStorage && isNew && !isIgnored) {
startActivity(new Intent(MediaParsingService.this, DialogActivity.class)
diff --git a/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java b/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
index c6b2fe9..88e1c27 100644
--- a/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
@@ -416,7 +416,7 @@ public class AudioPlayerContainerActivity extends BaseActivity implements Playba
String path = ((Uri) msg.obj).getPath();
removeMessages(ACTION_MEDIA_UNMOUNTED);
if (!PreferenceManager.getDefaultSharedPreferences(owner).getBoolean("ignore_"+ uuid, false)) {
- if (VLCApplication.getMLInstance().addDevice(uuid, path, true)) {
+ if (VLCApplication.getMLInstance().addDevice(uuid, path, true, true)) {
owner.startActivity(new Intent(owner, DialogActivity.class)
.setAction(DialogActivity.KEY_STORAGE)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
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 189742d..9f2e156 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
@@ -141,7 +141,7 @@ public abstract class BaseTvActivity extends PlaybackServiceActivity {
String path = intent.getData().getPath();
String uuid = intent.getData().getLastPathSegment();
boolean isIgnored = mSettings.getBoolean("ignore_"+ uuid, false);
- if (!isIgnored && mMediaLibrary.addDevice(uuid, path, true)) {
+ if (!isIgnored && mMediaLibrary.addDevice(uuid, path, true, 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