Example usage for android.content Intent setSourceBounds

List of usage examples for android.content Intent setSourceBounds

Introduction

In this page you can find the example usage for android.content Intent setSourceBounds.

Prototype

public void setSourceBounds(@Nullable Rect r) 

Source Link

Document

Set the bounds of the sender of this intent, in screen coordinates.

Usage

From source file:com.android.contacts.activities.PhotoSelectionActivity.java

/**
 * Builds a well-formed intent for invoking this activity.
 * @param context The context./* www  .j  a va  2 s . c  om*/
 * @param photoUri The URI of the current photo (may be null, in which case the default
 *     avatar image will be displayed).
 * @param photoBitmap The bitmap of the current photo (may be null, in which case the default
 *     avatar image will be displayed).
 * @param photoBytes The bytes for the current photo (may be null, in which case the default
 *     avatar image will be displayed).
 * @param photoBounds The pixel bounds of the current photo.
 * @param delta The entity delta list for the contact.
 * @param isProfile Whether the contact is the user's profile.
 * @param isDirectoryContact Whether the contact comes from a directory (non-editable).
 * @param expandPhotoOnClick Whether the photo should be expanded on click or not (generally,
 *     this should be true for phones, and false for tablets).
 * @return An intent that can be used to invoke the photo selection activity.
 */
public static Intent buildIntent(Context context, Uri photoUri, Bitmap photoBitmap, byte[] photoBytes,
        Rect photoBounds, RawContactDeltaList delta, boolean isProfile, boolean isDirectoryContact,
        boolean expandPhotoOnClick) {
    Intent intent = new Intent(context, PhotoSelectionActivity.class);
    if (photoUri != null && photoBitmap != null && photoBytes != null) {
        intent.putExtra(PHOTO_URI, photoUri);
    }
    intent.setSourceBounds(photoBounds);
    intent.putExtra(ENTITY_DELTA_LIST, (Parcelable) delta);
    intent.putExtra(IS_PROFILE, isProfile);
    intent.putExtra(IS_DIRECTORY_CONTACT, isDirectoryContact);
    intent.putExtra(EXPAND_PHOTO, expandPhotoOnClick);
    return intent;
}

From source file:com.android.leanlauncher.LauncherTransitionable.java

private void startAppShortcutOrInfoActivity(View v) {
    Object tag = v.getTag();/*from  w w w .j a v  a  2s.  co  m*/
    final ShortcutInfo shortcut;
    final Intent intent;
    if (tag instanceof ShortcutInfo) {
        shortcut = (ShortcutInfo) tag;
        intent = shortcut.intent;
        int[] pos = new int[2];
        v.getLocationOnScreen(pos);
        intent.setSourceBounds(new Rect(pos[0], pos[1], pos[0] + v.getWidth(), pos[1] + v.getHeight()));

    } else if (tag instanceof AppInfo) {
        shortcut = null;
        intent = ((AppInfo) tag).intent;
    } else {
        throw new IllegalArgumentException("Input must be a Shortcut or AppInfo");
    }

    boolean success = startActivitySafely(v, intent, tag);

    if (success && v instanceof BubbleTextView) {
        mWaitingForResume = (BubbleTextView) v;
        mWaitingForResume.setStayPressed(true);
    }
}

From source file:com.android.launcher2.Launcher.java

/**
 * Launches the intent referred by the clicked shortcut.
 *
 * @param v The view representing the clicked shortcut.
 *///from   w  w  w .j  ava2s . co  m
public void onClick(View v) {
    // Make sure that rogue clicks don't get through while allapps is launching, or after the
    // view has detached (it's possible for this to happen if the view is removed mid touch).
    if (v.getWindowToken() == null) {
        return;
    }

    if (!mWorkspace.isFinishedSwitchingState()) {
        return;
    }

    Object tag = v.getTag();
    if (tag instanceof ShortcutInfo) {
        // Open shortcut
        final Intent intent = ((ShortcutInfo) tag).intent;
        int[] pos = new int[2];
        v.getLocationOnScreen(pos);
        intent.setSourceBounds(new Rect(pos[0], pos[1], pos[0] + v.getWidth(), pos[1] + v.getHeight()));

        boolean success = startActivitySafely(v, intent, tag);

        if (success && v instanceof BubbleTextView) {
            mWaitingForResume = (BubbleTextView) v;
            mWaitingForResume.setStayPressed(true);
        }
    } else if (tag instanceof FolderInfo) {
        if (v instanceof FolderIcon) {
            FolderIcon fi = (FolderIcon) v;
            handleFolderClick(fi);
        }
    } else if (v == mAllAppsButton) {
        if (isAllAppsVisible()) {
            showWorkspace(true);
        } else {
            onClickAllAppsButton(v);
        }
    }
}

From source file:com.android.launcher2.Launcher.java

/**
 * Starts the global search activity. This code is a copied from SearchManager
 *///from  w w  w .j a v a 2  s.c o m
public void startGlobalSearch(String initialQuery, boolean selectInitialQuery, Bundle appSearchData,
        Rect sourceBounds) {
    final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    ComponentName globalSearchActivity = searchManager.getGlobalSearchActivity();
    if (globalSearchActivity == null) {
        Log.w(TAG, "No global search activity found.");
        return;
    }
    Intent intent = new Intent(SearchManager.INTENT_ACTION_GLOBAL_SEARCH);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setComponent(globalSearchActivity);
    // Make sure that we have a Bundle to put source in
    if (appSearchData == null) {
        appSearchData = new Bundle();
    } else {
        appSearchData = new Bundle(appSearchData);
    }
    // Set source to package name of app that starts global search, if not set already.
    if (!appSearchData.containsKey("source")) {
        appSearchData.putString("source", getPackageName());
    }
    intent.putExtra(SearchManager.APP_DATA, appSearchData);
    if (!TextUtils.isEmpty(initialQuery)) {
        intent.putExtra(SearchManager.QUERY, initialQuery);
    }
    if (selectInitialQuery) {
        intent.putExtra(SearchManager.EXTRA_SELECT_QUERY, selectInitialQuery);
    }
    intent.setSourceBounds(sourceBounds);
    try {
        startActivity(intent);
    } catch (ActivityNotFoundException ex) {
        Log.e(TAG, "Global search activity not found: " + globalSearchActivity);
    }
}

From source file:com.android.launcher3.Launcher.java

/**
 * Event handler for a click on the settings button that appears after a long press
 * on the home screen./* w  w  w  .  j a v  a  2s. c o  m*/
 */
public void onClickSettingsButton(View v) {
    if (LOGD)
        Log.d(TAG, "onClickSettingsButton");
    Intent intent = new Intent(Intent.ACTION_APPLICATION_PREFERENCES).setPackage(getPackageName());
    intent.setSourceBounds(getViewBounds(v));
    startActivity(intent, getActivityLaunchOptions(v));
}

From source file:com.android.launcher3.Launcher.java

/**
 * Event handler for the wallpaper picker button that appears after a long press
 * on the home screen.// w ww. j  a v  a 2  s  . com
 */
public void onClickWallpaperPicker(View v) {
    if (!Utilities.isWallapaperAllowed(this)) {
        Toast.makeText(this, R.string.msg_disabled_by_admin, Toast.LENGTH_SHORT).show();
        return;
    }

    /*String pickerPackage = getString(R.string.wallpaper_picker_package);
    if (TextUtils.isEmpty(pickerPackage)) {
    pickerPackage =  PackageManagerHelper.getWallpaperPickerPackage(getPackageManager());
    }*/

    int pageScroll = mWorkspace.getScrollForPage(mWorkspace.getPageNearestToCenterOfScreen());
    float offset = mWorkspace.mWallpaperOffset.wallpaperOffsetForScroll(pageScroll);

    setWaitingForResult(new PendingRequestArgs(new ItemInfo()));
    Intent intent = new Intent(Intent.ACTION_SET_WALLPAPER)
            //.setPackage(pickerPackage)
            .putExtra(Utilities.EXTRA_WALLPAPER_OFFSET, offset);
    intent.setSourceBounds(getViewBounds(v));
    startActivityForResult(intent, REQUEST_PICK_WALLPAPER, getActivityLaunchOptions(v));
}

From source file:com.klinker.android.launcher.launcher3.Launcher.java

@Thunk
void startAppShortcutOrInfoActivity(View v) {
    Object tag = v.getTag();/*  w w  w  .  ja va  2 s  .c o  m*/
    final ShortcutInfo shortcut;
    final Intent intent;
    if (tag instanceof ShortcutInfo) {
        shortcut = (ShortcutInfo) tag;
        intent = shortcut.intent;
        int[] pos = new int[2];
        v.getLocationOnScreen(pos);
        intent.setSourceBounds(new Rect(pos[0], pos[1], pos[0] + v.getWidth(), pos[1] + v.getHeight()));

    } else if (tag instanceof AppInfo) {
        shortcut = null;
        intent = ((AppInfo) tag).intent;
    } else {
        throw new IllegalArgumentException("Input must be a Shortcut or AppInfo");
    }

    boolean success = startActivitySafely(v, intent, tag);
    mStats.recordLaunch(v, intent, shortcut);

    if (success && v instanceof BubbleTextView) {
        mWaitingForResume = (BubbleTextView) v;
        mWaitingForResume.setStayPressed(true);
    }
}

From source file:com.cognizant.trumobi.PersonaLauncher.java

/**
 * Launches the intent referred by the clicked shortcut.
 * //  w w  w.  j  a  v a2s .co m
 * @param v
 *            The view representing the clicked shortcut.
 */
public void onClick(View v) {
    Object tag = v.getTag();
    // ADW: Check if the tag is a special action (the app drawer category
    // navigation)
    if (tag instanceof Integer) {
        navigateCatalogs(Integer.parseInt(tag.toString()));
        return;
    }
    // TODO:ADW Check whether to display a toast if clicked mLAB or mRAB
    // withount binding
    if (tag == null && v instanceof PersonaActionButton) {
        Toast t = Toast.makeText(this, R.string.toast_no_application_def, Toast.LENGTH_SHORT);
        t.show();
        return;
    }
    if (tag instanceof PersonaApplicationInfo) {
        // Open shortcut
        final PersonaApplicationInfo info = (PersonaApplicationInfo) tag;
        final Intent intent = info.intent;
        int[] pos = new int[2];
        v.getLocationOnScreen(pos);
        try {
            intent.setSourceBounds(new Rect(pos[0], pos[1], pos[0] + v.getWidth(), pos[1] + v.getHeight()));
        } catch (NoSuchMethodError e) {
        }
        ;
        startActivitySafely(intent);
        // Close dockbar if setting says so
        if (info.container == PersonaLauncherSettings.Favorites.CONTAINER_DOCKBAR && isDockBarOpen()
                && autoCloseDockbar) {
            mDockBar.close();
        }
    } else if (tag instanceof PersonaFolderInfo) {
        handleFolderClick((PersonaFolderInfo) tag);
    }
}

From source file:com.android.launcher3.Launcher.java

/**
 * Starts the global search activity. This code is a copied from SearchManager
 *///from   w w w.j  a v a 2s. c  o  m
public void startGlobalSearch(String initialQuery, boolean selectInitialQuery, Bundle appSearchData,
        Rect sourceBounds) {
    final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    ComponentName globalSearchActivity = searchManager.getGlobalSearchActivity();
    if (globalSearchActivity == null) {
        Log.w(TAG, "No global search activity found.");
        return;
    }
    Intent intent = new Intent(SearchManager.INTENT_ACTION_GLOBAL_SEARCH);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setComponent(globalSearchActivity);
    // Make sure that we have a Bundle to put source in
    if (appSearchData == null) {
        appSearchData = new Bundle();
    } else {
        appSearchData = new Bundle(appSearchData);
    }
    // Set source to package name of app that starts global search if not set already.
    if (!appSearchData.containsKey("source")) {
        appSearchData.putString("source", getPackageName());
    }
    intent.putExtra(SearchManager.APP_DATA, appSearchData);
    if (!TextUtils.isEmpty(initialQuery)) {
        intent.putExtra(SearchManager.QUERY, initialQuery);
    }
    if (selectInitialQuery) {
        intent.putExtra(SearchManager.EXTRA_SELECT_QUERY, selectInitialQuery);
    }
    intent.setSourceBounds(sourceBounds);
    try {
        startActivity(intent);
    } catch (ActivityNotFoundException ex) {
        Log.e(TAG, "Global search activity not found: " + globalSearchActivity);
    }
}

From source file:com.klinker.android.launcher.launcher3.Launcher.java

/**
 * Starts the global search activity. This code is a copied from SearchManager
 *///from  w  ww.j  av  a  2 s.  c  o m
private void startGlobalSearch(String initialQuery, boolean selectInitialQuery, Bundle appSearchData,
        Rect sourceBounds) {
    final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    ComponentName globalSearchActivity = searchManager.getGlobalSearchActivity();
    if (globalSearchActivity == null) {
        Log.w(TAG, "No global search activity found.");
        return;
    }
    Intent intent = new Intent(SearchManager.INTENT_ACTION_GLOBAL_SEARCH);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setComponent(globalSearchActivity);
    // Make sure that we have a Bundle to put source in
    if (appSearchData == null) {
        appSearchData = new Bundle();
    } else {
        appSearchData = new Bundle(appSearchData);
    }
    // Set source to package name of app that starts global search if not set already.
    if (!appSearchData.containsKey("source")) {
        appSearchData.putString("source", getPackageName());
    }
    intent.putExtra(SearchManager.APP_DATA, appSearchData);
    if (!TextUtils.isEmpty(initialQuery)) {
        intent.putExtra(SearchManager.QUERY, initialQuery);
    }
    if (selectInitialQuery) {
        intent.putExtra(SearchManager.EXTRA_SELECT_QUERY, selectInitialQuery);
    }
    intent.setSourceBounds(sourceBounds);
    try {
        startActivity(intent);
    } catch (ActivityNotFoundException ex) {
        Log.e(TAG, "Global search activity not found: " + globalSearchActivity);
    }
}