Search in sources :

Example 6 with Intent

use of android.content.Intent in project Launcher3 by chislon.

the class WallpaperCropActivity method init.

protected void init() {
    setContentView(R.layout.wallpaper_cropper);
    mCropView = (CropView) findViewById(R.id.cropView);
    Intent cropIntent = getIntent();
    final Uri imageUri = cropIntent.getData();
    if (imageUri == null) {
        Log.e(LOGTAG, "No URI passed in intent, exiting WallpaperCropActivity");
        finish();
        return;
    }
    int rotation = getRotationFromExif(this, imageUri);
    mCropView.setTileSource(new BitmapRegionTileSource(this, imageUri, 1024, rotation), null);
    mCropView.setTouchEnabled(true);
    // Action bar
    // Show the custom action bar view
    final ActionBar actionBar = getActionBar();
    actionBar.setCustomView(R.layout.actionbar_set_wallpaper);
    actionBar.getCustomView().setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean finishActivityWhenDone = true;
            cropImageAndSetWallpaper(imageUri, null, finishActivityWhenDone);
        }
    });
}
Also used : Intent(android.content.Intent) Uri(android.net.Uri) View(android.view.View) Point(android.graphics.Point) Paint(android.graphics.Paint) BitmapRegionTileSource(com.android.photos.BitmapRegionTileSource) ActionBar(android.app.ActionBar)

Example 7 with Intent

use of android.content.Intent in project Launcher3 by chislon.

the class ShortcutInfo method setActivity.

/**
     * Creates the application intent based on a component name and various launch flags.
     * Sets {@link #itemType} to {@link LauncherSettings.BaseLauncherColumns#ITEM_TYPE_APPLICATION}.
     *
     * @param className the class name of the component representing the intent
     * @param launchFlags the launch flags
     */
final void setActivity(Context context, ComponentName className, int launchFlags) {
    intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    intent.setComponent(className);
    intent.setFlags(launchFlags);
    itemType = LauncherSettings.BaseLauncherColumns.ITEM_TYPE_APPLICATION;
    initFlagsAndFirstInstallTime(getPackageInfo(context, intent.getComponent().getPackageName()));
}
Also used : Intent(android.content.Intent)

Example 8 with Intent

use of android.content.Intent in project Launcher3 by chislon.

the class Stats method recordLaunch.

public void recordLaunch(Intent intent, ShortcutInfo shortcut) {
    intent = new Intent(intent);
    intent.setSourceBounds(null);
    final String flat = intent.toUri(0);
    Intent broadcastIntent = new Intent(ACTION_LAUNCH).putExtra(EXTRA_INTENT, flat);
    if (shortcut != null) {
        broadcastIntent.putExtra(EXTRA_CONTAINER, shortcut.container).putExtra(EXTRA_SCREEN, shortcut.screenId).putExtra(EXTRA_CELLX, shortcut.cellX).putExtra(EXTRA_CELLY, shortcut.cellY);
    }
    mLauncher.sendBroadcast(broadcastIntent, PERM_LAUNCH);
    incrementLaunch(flat);
    if (FLUSH_IMMEDIATELY) {
        saveStats();
    }
    if (LOCAL_LAUNCH_LOG && mLog != null) {
        try {
            mLog.writeInt(LOG_TAG_LAUNCH);
            mLog.writeLong(System.currentTimeMillis());
            if (shortcut == null) {
                mLog.writeShort(0);
                mLog.writeShort(0);
                mLog.writeShort(0);
                mLog.writeShort(0);
            } else {
                mLog.writeShort((short) shortcut.container);
                mLog.writeShort((short) shortcut.screenId);
                mLog.writeShort((short) shortcut.cellX);
                mLog.writeShort((short) shortcut.cellY);
            }
            mLog.writeUTF(flat);
            if (FLUSH_IMMEDIATELY) {
                // TODO: delayed writes
                mLog.flush();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
Also used : Intent(android.content.Intent)

Example 9 with Intent

use of android.content.Intent in project Launcher3 by chislon.

the class UninstallShortcutReceiver method removeShortcut.

private static void removeShortcut(Context context, Intent data) {
    Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
    String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
    boolean duplicate = data.getBooleanExtra(Launcher.EXTRA_SHORTCUT_DUPLICATE, true);
    if (intent != null && name != null) {
        final ContentResolver cr = context.getContentResolver();
        Cursor c = cr.query(LauncherSettings.Favorites.CONTENT_URI, new String[] { LauncherSettings.Favorites._ID, LauncherSettings.Favorites.INTENT }, LauncherSettings.Favorites.TITLE + "=?", new String[] { name }, null);
        final int intentIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.INTENT);
        final int idIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites._ID);
        boolean changed = false;
        try {
            while (c.moveToNext()) {
                try {
                    if (intent.filterEquals(Intent.parseUri(c.getString(intentIndex), 0))) {
                        final long id = c.getLong(idIndex);
                        final Uri uri = LauncherSettings.Favorites.getContentUri(id, false);
                        cr.delete(uri, null, null);
                        changed = true;
                        if (!duplicate) {
                            break;
                        }
                    }
                } catch (URISyntaxException e) {
                // Ignore
                }
            }
        } finally {
            c.close();
        }
        if (changed) {
            cr.notifyChange(LauncherSettings.Favorites.CONTENT_URI, null);
            Toast.makeText(context, context.getString(R.string.shortcut_uninstalled, name), Toast.LENGTH_SHORT).show();
        }
    }
}
Also used : Intent(android.content.Intent) URISyntaxException(java.net.URISyntaxException) Cursor(android.database.Cursor) Uri(android.net.Uri) ContentResolver(android.content.ContentResolver)

Example 10 with Intent

use of android.content.Intent in project Launcher3 by chislon.

the class Workspace method updateShortcuts.

void updateShortcuts(ArrayList<AppInfo> apps) {
    ArrayList<ShortcutAndWidgetContainer> childrenLayouts = getAllShortcutAndWidgetContainers();
    for (ShortcutAndWidgetContainer layout : childrenLayouts) {
        int childCount = layout.getChildCount();
        for (int j = 0; j < childCount; j++) {
            final View view = layout.getChildAt(j);
            Object tag = view.getTag();
            if (LauncherModel.isShortcutInfoUpdateable((ItemInfo) tag)) {
                ShortcutInfo info = (ShortcutInfo) tag;
                final Intent intent = info.intent;
                final ComponentName name = intent.getComponent();
                final int appCount = apps.size();
                for (int k = 0; k < appCount; k++) {
                    AppInfo app = apps.get(k);
                    if (app.componentName.equals(name)) {
                        BubbleTextView shortcut = (BubbleTextView) view;
                        info.updateIcon(mIconCache);
                        info.title = app.title.toString();
                        shortcut.applyFromShortcutInfo(info, mIconCache);
                    }
                }
            }
        }
    }
}
Also used : Intent(android.content.Intent) ComponentName(android.content.ComponentName) View(android.view.View) TextView(android.widget.TextView) AppWidgetHostView(android.appwidget.AppWidgetHostView) Point(android.graphics.Point)

Aggregations

Intent (android.content.Intent)13686 PendingIntent (android.app.PendingIntent)2730 View (android.view.View)1004 ComponentName (android.content.ComponentName)943 Bundle (android.os.Bundle)841 ResolveInfo (android.content.pm.ResolveInfo)743 Uri (android.net.Uri)707 Context (android.content.Context)663 RemoteException (android.os.RemoteException)657 TextView (android.widget.TextView)624 PackageManager (android.content.pm.PackageManager)524 Test (org.junit.Test)509 IntentFilter (android.content.IntentFilter)496 ArrayList (java.util.ArrayList)465 ActivityNotFoundException (android.content.ActivityNotFoundException)376 ImageView (android.widget.ImageView)375 BroadcastReceiver (android.content.BroadcastReceiver)354 IOException (java.io.IOException)353 File (java.io.File)337 Notification (android.app.Notification)283