Search in sources :

Example 6 with ActivityOptions

use of android.app.ActivityOptions in project GeekNews by codeestX.

the class TechDetailActivity method launch.

public static void launch(Builder builder) {
    if (builder.shareView != null) {
        Intent intent = new Intent();
        intent.setClass(builder.mContext, TechDetailActivity.class);
        intent.putExtra(Constants.IT_DETAIL_URL, builder.url);
        intent.putExtra(Constants.IT_DETAIL_IMG_URL, builder.imgUrl);
        intent.putExtra(Constants.IT_DETAIL_TITLE, builder.title);
        intent.putExtra(Constants.IT_DETAIL_ID, builder.id);
        intent.putExtra(Constants.IT_DETAIL_TYPE, builder.type);
        ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(builder.mActivity, builder.shareView, "shareView");
        builder.mContext.startActivity(intent, options.toBundle());
    } else {
        Intent intent = new Intent();
        intent.setClass(builder.mContext, TechDetailActivity.class);
        intent.putExtra(Constants.IT_DETAIL_URL, builder.url);
        intent.putExtra(Constants.IT_DETAIL_IMG_URL, builder.imgUrl);
        intent.putExtra(Constants.IT_DETAIL_TITLE, builder.title);
        intent.putExtra(Constants.IT_DETAIL_ID, builder.id);
        intent.putExtra(Constants.IT_DETAIL_TYPE, builder.type);
        builder.mContext.startActivity(intent);
    }
}
Also used : Intent(android.content.Intent) ActivityOptions(android.app.ActivityOptions)

Example 7 with ActivityOptions

use of android.app.ActivityOptions in project android_frameworks_base by ParanoidAndroid.

the class SearchPanelView method startAssistActivity.

private void startAssistActivity() {
    if (!mBar.isDeviceProvisioned())
        return;
    // Close Recent Apps if needed
    mBar.animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_SEARCH_PANEL);
    boolean isKeyguardShowing = false;
    try {
        isKeyguardShowing = mWm.isKeyguardLocked();
    } catch (RemoteException e) {
    }
    if (isKeyguardShowing) {
        // Have keyguard show the bouncer and launch the activity if the user succeeds.
        try {
            mWm.showAssistant();
        } catch (RemoteException e) {
        // too bad, so sad...
        }
        onAnimationStarted();
    } else {
        // Otherwise, keyguard isn't showing so launch it from here.
        Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE)).getAssistIntent(mContext, true, UserHandle.USER_CURRENT);
        if (intent == null)
            return;
        try {
            ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity();
        } catch (RemoteException e) {
        // too bad, so sad...
        }
        try {
            ActivityOptions opts = ActivityOptions.makeCustomAnimation(mContext, R.anim.search_launch_enter, R.anim.search_launch_exit, getHandler(), this);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            mContext.startActivityAsUser(intent, opts.toBundle(), new UserHandle(UserHandle.USER_CURRENT));
        } catch (ActivityNotFoundException e) {
            Slog.w(TAG, "Activity not found for " + intent.getAction());
            onAnimationStarted();
        }
    }
}
Also used : SearchManager(android.app.SearchManager) ActivityNotFoundException(android.content.ActivityNotFoundException) UserHandle(android.os.UserHandle) Intent(android.content.Intent) RemoteException(android.os.RemoteException) ActivityOptions(android.app.ActivityOptions)

Example 8 with ActivityOptions

use of android.app.ActivityOptions in project android_frameworks_base by ParanoidAndroid.

the class BaseStatusBar method toggleRecentsActivity.

protected void toggleRecentsActivity() {
    try {
        TaskDescription firstTask = RecentTasksLoader.getInstance(mContext).getFirstTask();
        Intent intent = new Intent(RecentsActivity.TOGGLE_RECENTS_INTENT);
        intent.setClassName("com.android.systemui", "com.android.systemui.recent.RecentsActivity");
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
        if (firstTask == null) {
            if (RecentsActivity.forceOpaqueBackground(mContext)) {
                ActivityOptions opts = ActivityOptions.makeCustomAnimation(mContext, R.anim.recents_launch_from_launcher_enter, R.anim.recents_launch_from_launcher_exit);
                mContext.startActivityAsUser(intent, opts.toBundle(), new UserHandle(UserHandle.USER_CURRENT));
            } else {
                // The correct window animation will be applied via the activity's style
                mContext.startActivityAsUser(intent, new UserHandle(UserHandle.USER_CURRENT));
            }
        } else {
            Bitmap first = firstTask.getThumbnail();
            final Resources res = mContext.getResources();
            float thumbWidth = res.getDimensionPixelSize(R.dimen.status_bar_recents_thumbnail_width);
            float thumbHeight = res.getDimensionPixelSize(R.dimen.status_bar_recents_thumbnail_height);
            if (first == null) {
                throw new RuntimeException("Recents thumbnail is null");
            }
            if (first.getWidth() != thumbWidth || first.getHeight() != thumbHeight) {
                first = Bitmap.createScaledBitmap(first, (int) thumbWidth, (int) thumbHeight, true);
                if (first == null) {
                    throw new RuntimeException("Recents thumbnail is null");
                }
            }
            DisplayMetrics dm = new DisplayMetrics();
            mDisplay.getMetrics(dm);
            // calculate it here, but consider moving it elsewhere
            // first, determine which orientation you're in.
            // todo: move the system_bar layouts to sw600dp ?
            final Configuration config = res.getConfiguration();
            int x, y;
            if (config.orientation == Configuration.ORIENTATION_PORTRAIT) {
                float appLabelLeftMargin = res.getDimensionPixelSize(R.dimen.status_bar_recents_app_label_left_margin);
                float appLabelWidth = res.getDimensionPixelSize(R.dimen.status_bar_recents_app_label_width);
                float thumbLeftMargin = res.getDimensionPixelSize(R.dimen.status_bar_recents_thumbnail_left_margin);
                float thumbBgPadding = res.getDimensionPixelSize(R.dimen.status_bar_recents_thumbnail_bg_padding);
                float width = appLabelLeftMargin + +appLabelWidth + thumbLeftMargin + thumbWidth + 2 * thumbBgPadding;
                x = (int) ((dm.widthPixels - width) / 2f + appLabelLeftMargin + appLabelWidth + thumbBgPadding + thumbLeftMargin);
                y = (int) (dm.heightPixels - res.getDimensionPixelSize(R.dimen.status_bar_recents_thumbnail_height) - thumbBgPadding);
                if (mLayoutDirection == View.LAYOUT_DIRECTION_RTL) {
                    x = dm.widthPixels - x - res.getDimensionPixelSize(R.dimen.status_bar_recents_thumbnail_width);
                }
            } else {
                // if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
                float thumbTopMargin = res.getDimensionPixelSize(R.dimen.status_bar_recents_thumbnail_top_margin);
                float thumbBgPadding = res.getDimensionPixelSize(R.dimen.status_bar_recents_thumbnail_bg_padding);
                float textPadding = res.getDimensionPixelSize(R.dimen.status_bar_recents_text_description_padding);
                float labelTextSize = res.getDimensionPixelSize(R.dimen.status_bar_recents_app_label_text_size);
                Paint p = new Paint();
                p.setTextSize(labelTextSize);
                float labelTextHeight = p.getFontMetricsInt().bottom - p.getFontMetricsInt().top;
                float descriptionTextSize = res.getDimensionPixelSize(R.dimen.status_bar_recents_app_description_text_size);
                p.setTextSize(descriptionTextSize);
                float descriptionTextHeight = p.getFontMetricsInt().bottom - p.getFontMetricsInt().top;
                float statusBarHeight = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height);
                float recentsItemTopPadding = statusBarHeight;
                float height = thumbTopMargin + thumbHeight + 2 * thumbBgPadding + textPadding + labelTextHeight + recentsItemTopPadding + textPadding + descriptionTextHeight;
                float recentsItemRightPadding = res.getDimensionPixelSize(R.dimen.status_bar_recents_item_padding);
                float recentsScrollViewRightPadding = res.getDimensionPixelSize(R.dimen.status_bar_recents_right_glow_margin);
                x = (int) (dm.widthPixels - res.getDimensionPixelSize(R.dimen.status_bar_recents_thumbnail_width) - thumbBgPadding - recentsItemRightPadding - recentsScrollViewRightPadding);
                y = (int) ((dm.heightPixels - statusBarHeight - height) / 2f + thumbTopMargin + recentsItemTopPadding + thumbBgPadding + statusBarHeight);
            }
            ActivityOptions opts = ActivityOptions.makeThumbnailScaleDownAnimation(getStatusBarView(), first, x, y, new ActivityOptions.OnAnimationStartedListener() {

                public void onAnimationStarted() {
                    Intent intent = new Intent(RecentsActivity.WINDOW_ANIMATION_START_INTENT);
                    intent.setPackage("com.android.systemui");
                    mContext.sendBroadcastAsUser(intent, new UserHandle(UserHandle.USER_CURRENT));
                }
            });
            intent.putExtra(RecentsActivity.WAITING_FOR_WINDOW_ANIMATION_PARAM, true);
            mContext.startActivityAsUser(intent, opts.toBundle(), new UserHandle(UserHandle.USER_CURRENT));
        }
        return;
    } catch (ActivityNotFoundException e) {
        Log.e(TAG, "Failed to launch RecentAppsIntent", e);
    }
}
Also used : Configuration(android.content.res.Configuration) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) Paint(android.graphics.Paint) DisplayMetrics(android.util.DisplayMetrics) Paint(android.graphics.Paint) Bitmap(android.graphics.Bitmap) TaskDescription(com.android.systemui.recent.TaskDescription) ActivityNotFoundException(android.content.ActivityNotFoundException) UserHandle(android.os.UserHandle) Resources(android.content.res.Resources) ActivityOptions(android.app.ActivityOptions)

Example 9 with ActivityOptions

use of android.app.ActivityOptions in project android_frameworks_base by ParanoidAndroid.

the class PieControlPanel method launchAssistAction.

private void launchAssistAction() {
    Intent intent = getAssistIntent();
    if (intent != null) {
        try {
            ActivityOptions opts = ActivityOptions.makeCustomAnimation(mContext, R.anim.search_launch_enter, R.anim.search_launch_exit);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            mContext.startActivityAsUser(intent, opts.toBundle(), new UserHandle(UserHandle.USER_CURRENT));
        } catch (ActivityNotFoundException e) {
        }
    }
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) UserHandle(android.os.UserHandle) Intent(android.content.Intent) ActivityOptions(android.app.ActivityOptions)

Example 10 with ActivityOptions

use of android.app.ActivityOptions in project Fairphone by Kwamecorp.

the class LauncherTransitionable method startActivity.

public boolean startActivity(View v, Intent intent, Object tag) {
    ComponentName component = intent != null ? intent.getComponent() : null;
    String packageName = intent != null ? ItemInfo.getPackageName(intent) : "implicit Intent.";
    Log.d(TAG, "Start Activity >>> " + (component != null ? component.toString() : packageName));
    boolean explicitIntent = component != null;
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    try {
        // Only launch using the new animation if the shortcut has not opted
        // out (this is a
        // private contract between launcher and may be ignored in the
        // future).
        boolean useLaunchAnimation = (v != null) && !intent.hasExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION);
        if (useLaunchAnimation) {
            ActivityOptions opts = ActivityOptions.makeScaleUpAnimation(v, 0, 0, v.getMeasuredWidth(), v.getMeasuredHeight());
            startActivity(intent, opts.toBundle());
        } else {
            startActivity(intent);
        }
        if (explicitIntent) {
            updateActivityInfoViaExplicitIntent(component);
        } else {
            Log.i(TAG, "Could not log this, implicit intent.");
        }
        return true;
    } catch (SecurityException e) {
        Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
        Log.e(TAG, "Launcher does not have the permission to launch " + intent + ". Make sure to create a MAIN intent-filter for the corresponding activity " + "or use the exported attribute for this activity. " + "tag=" + tag + " intent=" + intent, e);
    }
    return false;
}
Also used : ComponentName(android.content.ComponentName) ActivityOptions(android.app.ActivityOptions)

Aggregations

ActivityOptions (android.app.ActivityOptions)178 Intent (android.content.Intent)88 RemoteException (android.os.RemoteException)33 Point (android.graphics.Point)30 RecentsTaskLoader (com.android.systemui.recents.model.RecentsTaskLoader)20 TaskStack (com.android.systemui.recents.model.TaskStack)20 PendingIntent (android.app.PendingIntent)18 SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)15 ActivityManager (android.app.ActivityManager)14 ComponentName (android.content.ComponentName)13 ActivityInfo (android.content.pm.ActivityInfo)13 ResolveInfo (android.content.pm.ResolveInfo)12 UserHandle (android.os.UserHandle)12 Configuration (android.content.res.Configuration)10 ReferrerIntent (com.android.internal.content.ReferrerIntent)10 RecentsTaskLoadPlan (com.android.systemui.recents.model.RecentsTaskLoadPlan)10 Task (com.android.systemui.recents.model.Task)10 Bundle (android.os.Bundle)9 ActivityNotFoundException (android.content.ActivityNotFoundException)8 RecyclerView (android.support.v7.widget.RecyclerView)8