forked from upstream-mirrors/OpenTracks
Modify the sharing flow to first show a list of applications.
Store preferred account as a sharing setting. Remove share url only option. Apply share url only if twitter is selected.
This commit is contained in:
@@ -16,6 +16,9 @@
|
||||
|
||||
package com.google.android.apps.mytracks.util;
|
||||
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
@@ -26,6 +29,9 @@ import android.content.Intent;
|
||||
*/
|
||||
public class IntentUtils {
|
||||
|
||||
public static final String TEXT_PLAIN_TYPE = "text/plain";
|
||||
private static final String TWITTER_PACKAGE_NAME = "com.twitter.android";
|
||||
|
||||
private IntentUtils() {}
|
||||
|
||||
/**
|
||||
@@ -39,4 +45,23 @@ public class IntentUtils {
|
||||
return new Intent(context, cls).addFlags(
|
||||
Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an intent to share a url with a sharing app.
|
||||
*
|
||||
* @param context the context
|
||||
* @param url the url
|
||||
* @param packageName the sharing app package name
|
||||
* @param className the sharing app class name
|
||||
*/
|
||||
public static final Intent newShareUrlIntent(
|
||||
Context context, String url, String packageName, String className) {
|
||||
return new Intent(Intent.ACTION_SEND)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP)
|
||||
.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.share_track_subject))
|
||||
.putExtra(Intent.EXTRA_TEXT, TWITTER_PACKAGE_NAME.equals(packageName)
|
||||
? url : context.getString(R.string.share_track_url_body_format, url))
|
||||
.setComponent(new ComponentName(packageName, className))
|
||||
.setType(TEXT_PLAIN_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user