Tpt has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/95061


Change subject: Allow to open Wikipedia pages directly in the app
......................................................................

Allow to open Wikipedia pages directly in the app

Change-Id: Ibe22c40848bb2d0e2e843352d287b5cd4765e06e
---
M wikipedia/AndroidManifest.xml
M wikipedia/src/main/java/org/wikimedia/wikipedia/PageActivity.java
2 files changed, 20 insertions(+), 3 deletions(-)


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

diff --git a/wikipedia/AndroidManifest.xml b/wikipedia/AndroidManifest.xml
index 3a1b3d9..cb99bb2 100644
--- a/wikipedia/AndroidManifest.xml
+++ b/wikipedia/AndroidManifest.xml
@@ -18,9 +18,16 @@
         <activity android:name=".PageActivity" >
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
-
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
+
+            <intent-filter>
+                <action android:name="android.intent.action.VIEW" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <category android:name="android.intent.category.BROWSABLE" />
+                <data android:host="*.wikipedia.org" 
android:pathPrefix="/wiki/" android:scheme="http" />
+                <data android:host="*.wikipedia.org" 
android:pathPrefix="/wiki/" android:scheme="https" />
+            </intent-filter>
         </activity>
     </application>
 
diff --git a/wikipedia/src/main/java/org/wikimedia/wikipedia/PageActivity.java 
b/wikipedia/src/main/java/org/wikimedia/wikipedia/PageActivity.java
index 179394f..0903be7 100644
--- a/wikipedia/src/main/java/org/wikimedia/wikipedia/PageActivity.java
+++ b/wikipedia/src/main/java/org/wikimedia/wikipedia/PageActivity.java
@@ -1,9 +1,8 @@
 package org.wikimedia.wikipedia;
 
+import android.content.Intent;
 import android.os.Bundle;
 import android.support.v4.app.FragmentActivity;
-import android.view.*;
-import android.widget.*;
 import com.squareup.otto.Bus;
 import com.squareup.otto.Subscribe;
 
@@ -17,8 +16,19 @@
         setContentView(R.layout.activity_main);
 
         app = ((WikipediaApp)getApplicationContext());
+
+               Intent intent = getIntent();
+               if (Intent.ACTION_VIEW.equals(intent.getAction())) {
+                       answerToViewIntent(intent);
+               }
     }
 
+       private void answerToViewIntent(Intent intent) {
+               Site site = new Site(intent.getData().getAuthority());
+               PageTitle title = 
site.titleForInternalLink(intent.getData().getPath());
+               displayNewPage(title);
+       }
+
     private void displayNewPage(PageTitle title) {
         PageViewFragment pageFragment = new PageViewFragment(title);
         getSupportFragmentManager().beginTransaction()

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

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

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

Reply via email to