Search in sources :

Example 11 with ShortcutIconResource

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();
    }
}
Also used : Bitmap(android.graphics.Bitmap) ShortcutIconResource(android.content.Intent.ShortcutIconResource) Intent(android.content.Intent)

Example 12 with ShortcutIconResource

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();
}
Also used : ShortcutIconResource(android.content.Intent.ShortcutIconResource) Intent(android.content.Intent)

Example 13 with ShortcutIconResource

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);
}
Also used : Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) ShortcutIconResource(android.content.Intent.ShortcutIconResource) Intent(android.content.Intent)

Example 14 with ShortcutIconResource

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);
}
Also used : Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) ShortcutIconResource(android.content.Intent.ShortcutIconResource) Intent(android.content.Intent) LauncherIntent(mobi.intuitit.android.content.LauncherIntent)

Example 15 with ShortcutIconResource

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;
}
Also used : Bitmap(android.graphics.Bitmap) PackageManager(android.content.pm.PackageManager) ShortcutIconResource(android.content.Intent.ShortcutIconResource) Intent(android.content.Intent) Parcelable(android.os.Parcelable) Resources(android.content.res.Resources) URISyntaxException(java.net.URISyntaxException) RemoteException(android.os.RemoteException)

Aggregations

ShortcutIconResource (android.content.Intent.ShortcutIconResource)23 Intent (android.content.Intent)22 ArrayList (java.util.ArrayList)11 Resources (android.content.res.Resources)10 Bitmap (android.graphics.Bitmap)10 Bundle (android.os.Bundle)9 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)8 PackageManager (android.content.pm.PackageManager)7 Parcelable (android.os.Parcelable)7 RemoteException (android.os.RemoteException)5 URISyntaxException (java.net.URISyntaxException)5 Drawable (android.graphics.drawable.Drawable)4 BitmapDrawable (android.graphics.drawable.BitmapDrawable)3 ComponentName (android.content.ComponentName)2 ActivityInfo (android.content.pm.ActivityInfo)2 Paint (android.graphics.Paint)2 PaintDrawable (android.graphics.drawable.PaintDrawable)2 LauncherIntent (mobi.intuitit.android.content.LauncherIntent)2 AlertDialog (android.app.AlertDialog)1 Dialog (android.app.Dialog)1