Incoming swap URI's (from the web browser) go to correct place.
The
This commit is contained in:
parent
b0586384f8
commit
ddb9791e11
@ -105,15 +105,41 @@
|
||||
<data android:pathPrefix="/repository/browse" />
|
||||
</intent-filter>
|
||||
|
||||
<!--
|
||||
This intent serves two purposes: Swapping apps between devices and adding a
|
||||
repo from a website (e.g. https://guardianproject.info/fdroid/repo).
|
||||
We intercept both of these situations in the FDroid activity, and then redirect
|
||||
to the appropriate handler (swap handling, manage repos respectively) from there.
|
||||
|
||||
The reason for this is that the only differentiating factor is the presence
|
||||
of a "swap=1" in the query string, and intent-filter is unable to deal with
|
||||
query parameters. An alternative would be to do something like fdroidswap:// as
|
||||
a scheme, but then we. Need to copy/paste all of this intent-filter stuff and
|
||||
keep it up to date when it changes or a bug is found.
|
||||
-->
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
<!--
|
||||
Android's scheme matcher is case-sensitive, so include
|
||||
ALL CAPS versions to support ALL CAPS URLs in QR Codes.
|
||||
QR Codes have a special ALL CAPS mode that uses a reduced
|
||||
character set, making for more compact QR Codes.
|
||||
-->
|
||||
<data android:scheme="http" />
|
||||
<data android:scheme="HTTP" />
|
||||
<data android:scheme="https" />
|
||||
<data android:scheme="HTTPS" />
|
||||
<data android:scheme="fdroidrepo" />
|
||||
<data android:scheme="FDROIDREPO" />
|
||||
<data android:scheme="fdroidrepos" />
|
||||
<data android:scheme="FDROIDREPOS" />
|
||||
|
||||
<data android:host="*" />
|
||||
|
||||
<!--
|
||||
The pattern matcher here is poorly implemented, in particular the * is
|
||||
non-greedy, so you have to do stupid tricks to match patterns that have
|
||||
@ -159,10 +185,6 @@
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".FDroid" />
|
||||
</activity>
|
||||
<!--
|
||||
The title for ManageReposActivity is "F-Droid" here, but "Repositories"
|
||||
when viewing the Activity itself in the app.
|
||||
-->
|
||||
<activity
|
||||
android:name=".views.ManageReposActivity"
|
||||
android:label="@string/app_name"
|
||||
@ -171,24 +193,6 @@
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".FDroid" />
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
<!--
|
||||
Android's scheme matcher is case-sensitive, so include
|
||||
ALL CAPS versions to support ALL CAPS URLs in QR Codes.
|
||||
QR Codes have a special ALL CAPS mode that uses a reduced
|
||||
character set, making for more compact QR Codes.
|
||||
-->
|
||||
<data android:scheme="fdroidrepo" />
|
||||
<data android:scheme="FDROIDREPO" />
|
||||
<data android:scheme="fdroidrepos" />
|
||||
<data android:scheme="FDROIDREPOS" />
|
||||
</intent-filter>
|
||||
<!-- Handle NFC tags detected from outside our application -->
|
||||
<intent-filter>
|
||||
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
|
||||
|
@ -1,61 +0,0 @@
|
||||
package org.fdroid.fdroid.compat;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.os.Environment;
|
||||
|
||||
public abstract class ContextCompat extends Compatibility {
|
||||
|
||||
public static ContextCompat create(Context context) {
|
||||
if (hasApi(8)) {
|
||||
return new FroyoContextCompatImpl(context);
|
||||
} else {
|
||||
return new OldContextCompatImpl(context);
|
||||
}
|
||||
}
|
||||
|
||||
protected final Context context;
|
||||
|
||||
public ContextCompat(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see android.content.Context#getExternalCacheDir()
|
||||
*/
|
||||
public abstract File getExternalCacheDir();
|
||||
|
||||
}
|
||||
|
||||
class OldContextCompatImpl extends ContextCompat {
|
||||
|
||||
public OldContextCompatImpl(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getExternalCacheDir() {
|
||||
File file = new File(Environment.getExternalStorageDirectory(),
|
||||
"Android/data/org.fdroid.fdroid/cache");
|
||||
if (!file.exists())
|
||||
file.mkdirs();
|
||||
return file;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TargetApi(8)
|
||||
class FroyoContextCompatImpl extends ContextCompat {
|
||||
|
||||
public FroyoContextCompatImpl(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getExternalCacheDir() {
|
||||
return context.getExternalCacheDir();
|
||||
}
|
||||
|
||||
}
|
@ -5,6 +5,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import org.fdroid.fdroid.R;
|
||||
|
||||
import java.util.Arrays;
|
||||
@ -12,6 +13,8 @@ import java.util.Locale;
|
||||
|
||||
public class NewRepoConfig {
|
||||
|
||||
private static final String TAG = "org.fdroid.fdroid.data.NewRepoConfig";
|
||||
|
||||
private String errorMessage;
|
||||
private boolean isValidRepo = false;
|
||||
|
||||
@ -41,6 +44,8 @@ public class NewRepoConfig {
|
||||
return;
|
||||
}
|
||||
|
||||
Log.d(TAG, "Parsing incoming intent looking for repo: " + incomingUri);
|
||||
|
||||
// scheme and host should only ever be pure ASCII aka Locale.ENGLISH
|
||||
scheme = uri.getScheme();
|
||||
host = uri.getHost();
|
||||
|
Loading…
x
Reference in New Issue
Block a user