Add "save to file" option for screenshots (+ lots of XML formatting)

This commit is contained in:
fkloft
2014-03-01 22:43:26 +01:00
parent 83ead3a358
commit f43cfeb5aa
20 changed files with 113 additions and 67 deletions

View File

@ -7,6 +7,7 @@ import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Build;
import com.cradle.iitc_mobile.Log;
import com.cradle.iitc_mobile.R;
@ -136,6 +137,14 @@ public class IntentGenerator {
return targets;
}
/**
* get a list of intents capable of sharing a plain text string
*
* @param title
* description of the shared string
* @param text
* the string to be shared
*/
public ArrayList<Intent> getShareIntents(final String title, final String text) {
final Intent intent = new Intent(Intent.ACTION_SEND)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)
@ -155,11 +164,29 @@ public class IntentGenerator {
return targets;
}
public ArrayList<Intent> getShareIntents(final String title, final Uri uri, final String type) {
return resolveTargets(new Intent(Intent.ACTION_SEND)
/**
* get a list of intents capable of sharing the given content
*
* @param uri
* URI of a file to share
* @param type
* MIME type of the file
*/
public ArrayList<Intent> getShareIntents(final Uri uri, final String type) {
final Intent intent = new Intent(Intent.ACTION_SEND)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)
.setType(type)
.putExtra(Intent.EXTRA_SUBJECT, title)
.putExtra(Intent.EXTRA_STREAM, uri));
.putExtra(Intent.EXTRA_SUBJECT, uri.getLastPathSegment())
.putExtra(Intent.EXTRA_STREAM, uri);
final ArrayList<Intent> targets = resolveTargets(intent);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
targets.add(new Intent(intent)
.setComponent(new ComponentName(mContext, SaveToFile.class))
.putExtra(EXTRA_FLAG_TITLE, mContext.getString(R.string.activity_save_to_file)));
}
return targets;
}
}