use of android.content.Intent.ShortcutIconResource in project ADW.Theme-Template by AnderWeb.
the class IconPack method onItemClick.
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
if (mPickerMode) {
Intent intent = new Intent();
if (!mResourceMode) {
Bitmap bitmap = null;
try {
bitmap = (Bitmap) adapterView.getAdapter().getItem(position);
} catch (Exception e) {
}
if (bitmap != null) {
intent.putExtra("icon", bitmap);
setResult(RESULT_OK, intent);
} else {
setResult(RESULT_CANCELED, intent);
}
} else {
ShortcutIconResource res = ((IconsAdapter) adapterView.getAdapter()).getResource(position);
if (res != null) {
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, res);
setResult(RESULT_OK, intent);
} else {
setResult(RESULT_CANCELED, intent);
}
}
finish();
}
}
use of android.content.Intent.ShortcutIconResource in project Telecine by JakeWharton.
the class TelecineShortcutConfigureActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((TelecineApplication) getApplication()).injector().inject(this);
analytics.send(//
new HitBuilders.EventBuilder().setCategory(//
Analytics.CATEGORY_SHORTCUT).setAction(//
Analytics.ACTION_SHORTCUT_ADDED).build());
Intent launchIntent = new Intent(this, TelecineShortcutLaunchActivity.class);
ShortcutIconResource icon = ShortcutIconResource.fromContext(this, R.drawable.ic_launcher);
Intent intent = new Intent();
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.shortcut_name));
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, launchIntent);
setResult(RESULT_OK, intent);
finish();
}
use of android.content.Intent.ShortcutIconResource in project android_frameworks_base by crdroidandroid.
the class ShortcutPickHelper method pickShortcut.
public void pickShortcut(String[] names, ShortcutIconResource[] icons, int fragmentId) {
Bundle bundle = new Bundle();
ArrayList<String> shortcutNames = new ArrayList<String>();
if (names != null) {
for (String s : names) {
shortcutNames.add(s);
}
}
shortcutNames.add(mParent.getString(R.string.profile_applist_title));
shortcutNames.add(mParent.getString(R.string.picker_activities));
bundle.putStringArrayList(Intent.EXTRA_SHORTCUT_NAME, shortcutNames);
ArrayList<ShortcutIconResource> shortcutIcons = new ArrayList<ShortcutIconResource>();
if (icons != null) {
for (ShortcutIconResource s : icons) {
shortcutIcons.add(s);
}
}
shortcutIcons.add(ShortcutIconResource.fromContext(mParent, android.R.drawable.sym_def_app_icon));
shortcutIcons.add(ShortcutIconResource.fromContext(mParent, R.drawable.activities_icon));
bundle.putParcelableArrayList(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, shortcutIcons);
Intent pickIntent = new Intent(Intent.ACTION_PICK_ACTIVITY);
pickIntent.putExtra(Intent.EXTRA_INTENT, new Intent(Intent.ACTION_CREATE_SHORTCUT));
pickIntent.putExtra(Intent.EXTRA_TITLE, mParent.getText(R.string.select_custom_app_title));
pickIntent.putExtras(bundle);
lastFragmentId = fragmentId;
startFragmentOrActivity(pickIntent, REQUEST_PICK_SHORTCUT);
}
use of android.content.Intent.ShortcutIconResource in project ADWLauncher2 by boombuler.
the class Launcher method pickShortcut.
private void pickShortcut() {
Bundle bundle = new Bundle();
ArrayList<String> shortcutNames = new ArrayList<String>();
shortcutNames.add(getString(R.string.group_applications));
bundle.putStringArrayList(Intent.EXTRA_SHORTCUT_NAME, shortcutNames);
ArrayList<ShortcutIconResource> shortcutIcons = new ArrayList<ShortcutIconResource>();
shortcutIcons.add(ShortcutIconResource.fromContext(Launcher.this, R.drawable.ic_launcher_application));
bundle.putParcelableArrayList(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, shortcutIcons);
Intent pickIntent = new Intent(Intent.ACTION_PICK_ACTIVITY);
pickIntent.putExtra(Intent.EXTRA_INTENT, new Intent(Intent.ACTION_CREATE_SHORTCUT));
pickIntent.putExtra(Intent.EXTRA_TITLE, getText(R.string.title_select_shortcut));
pickIntent.putExtras(bundle);
startActivityForResult(pickIntent, REQUEST_PICK_SHORTCUT);
}
use of android.content.Intent.ShortcutIconResource in project ADWLauncher2 by boombuler.
the class LauncherModel method infoFromShortcutIntent.
private ShortcutInfo infoFromShortcutIntent(Context context, Intent data) {
Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
Parcelable bitmap = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON);
Bitmap icon = null;
ShortcutIconResource iconResource = null;
if (bitmap != null && bitmap instanceof Bitmap) {
icon = Utilities.createIconBitmap(new FastBitmapDrawable((Bitmap) bitmap), context);
} else {
Parcelable extra = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);
if (extra != null && extra instanceof ShortcutIconResource) {
try {
iconResource = (ShortcutIconResource) extra;
final PackageManager packageManager = context.getPackageManager();
Resources resources = packageManager.getResourcesForApplication(iconResource.packageName);
final int id = resources.getIdentifier(iconResource.resourceName, null, null);
icon = Utilities.createIconBitmap(resources.getDrawable(id), context);
} catch (Exception e) {
Log.w(TAG, "Could not load shortcut icon: " + extra);
}
}
}
final ShortcutInfo info = new ShortcutInfo();
info.setIcon(icon);
info.setTitle(name);
info.intent = intent;
return info;
}
Aggregations