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);
}
});
}
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()));
}
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();
}
}
}
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();
}
}
}
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);
}
}
}
}
}
}
Aggregations