Dbrant has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/373296 )

Change subject: Make DownloadManager notification clickable.
......................................................................

Make DownloadManager notification clickable.

This creates an app-wide receiver for DownloadManager events, and watches
for clicks of the DownloadManager notification. If one of the files being
downloaded is a compilation, we launch the LocalCompilations activity.

This also makes the LocalCompilationsActivity into a "singleTask"
activity, since it doesn't really make sense to have multiple instances of
this activity in the app's stack.

Bug: T172860
Change-Id: Ic7a932f411d2b09ee535719a54b859ab6832d6bf
---
M app/src/main/AndroidManifest.xml
A app/src/main/java/org/wikipedia/offline/DownloadManagerReceiver.java
2 files changed, 35 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia 
refs/changes/96/373296/1

diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index d1b8ef7..8ca32f2 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -188,7 +188,8 @@
         <activity
             android:name=".offline.LocalCompilationsActivity"
             android:theme="@style/AppTheme"
-            android:windowSoftInputMode="adjustResize"/>
+            android:windowSoftInputMode="adjustResize"
+            android:launchMode="singleTask"/>
 
         <activity
             android:name=".offline.RemoteCompilationsActivity"
@@ -270,6 +271,12 @@
             </intent-filter>
         </receiver>
 
+        <receiver android:name=".offline.DownloadManagerReceiver">
+            <intent-filter>
+                <action 
android:name="android.intent.action.DOWNLOAD_NOTIFICATION_CLICKED" />
+            </intent-filter>
+        </receiver>
+
         <service
             android:name=".useroption.sync.UserOptionSyncService"
             android:exported="false">
diff --git 
a/app/src/main/java/org/wikipedia/offline/DownloadManagerReceiver.java 
b/app/src/main/java/org/wikipedia/offline/DownloadManagerReceiver.java
new file mode 100644
index 0000000..c37a207
--- /dev/null
+++ b/app/src/main/java/org/wikipedia/offline/DownloadManagerReceiver.java
@@ -0,0 +1,27 @@
+package org.wikipedia.offline;
+
+import android.app.DownloadManager;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+
+public class DownloadManagerReceiver extends BroadcastReceiver {
+    @Override
+    public void onReceive(Context context, Intent intent) {
+        String action = intent.getAction();
+        if (DownloadManager.ACTION_NOTIFICATION_CLICKED.equals(action)) {
+            if (intent.getExtras() == null || 
!intent.hasExtra(DownloadManager.EXTRA_NOTIFICATION_CLICK_DOWNLOAD_IDS)) {
+                return;
+            }
+            long[] ids = 
intent.getLongArrayExtra(DownloadManager.EXTRA_NOTIFICATION_CLICK_DOWNLOAD_IDS);
+
+            DownloadManager downloadManager = (DownloadManager) 
context.getSystemService(Context.DOWNLOAD_SERVICE);
+            for (long id : ids) {
+                if 
(Compilation.MIME_TYPE.equals(downloadManager.getMimeTypeForDownloadedFile(id)))
 {
+                    
context.startActivity(LocalCompilationsActivity.newIntent(context));
+                    break;
+                }
+            }
+        }
+    }
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/373296
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic7a932f411d2b09ee535719a54b859ab6832d6bf
Gerrit-PatchSet: 1
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Dbrant <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to