use of android.content.ActivityNotFoundException 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);
}
}
use of android.content.ActivityNotFoundException 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) {
}
}
}
use of android.content.ActivityNotFoundException in project android_frameworks_base by ParanoidAndroid.
the class PhoneFallbackEventHandler method onKeyDown.
boolean onKeyDown(int keyCode, KeyEvent event) {
/* ****************************************************************************
* HOW TO DECIDE WHERE YOUR KEY HANDLING GOES.
* See the comment in PhoneWindow.onKeyDown
* ****************************************************************************/
final KeyEvent.DispatcherState dispatcher = mView.getKeyDispatcherState();
switch(keyCode) {
case KeyEvent.KEYCODE_VOLUME_UP:
case KeyEvent.KEYCODE_VOLUME_DOWN:
case KeyEvent.KEYCODE_VOLUME_MUTE:
{
getAudioManager().handleKeyDown(event, AudioManager.USE_DEFAULT_STREAM_TYPE);
return true;
}
case KeyEvent.KEYCODE_MEDIA_PLAY:
case KeyEvent.KEYCODE_MEDIA_PAUSE:
case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
/* Suppress PLAY/PAUSE toggle when phone is ringing or in-call
* to avoid music playback */
if (getTelephonyManager().getCallState() != TelephonyManager.CALL_STATE_IDLE) {
// suppress key event
return true;
}
case KeyEvent.KEYCODE_MUTE:
case KeyEvent.KEYCODE_HEADSETHOOK:
case KeyEvent.KEYCODE_MEDIA_STOP:
case KeyEvent.KEYCODE_MEDIA_NEXT:
case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
case KeyEvent.KEYCODE_MEDIA_REWIND:
case KeyEvent.KEYCODE_MEDIA_RECORD:
case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
{
handleMediaKeyEvent(event);
return true;
}
case KeyEvent.KEYCODE_CALL:
{
if (getKeyguardManager().inKeyguardRestrictedInputMode() || dispatcher == null) {
break;
}
if (event.getRepeatCount() == 0) {
dispatcher.startTracking(event, this);
} else if (event.isLongPress() && dispatcher.isTracking(event)) {
dispatcher.performedLongPress(event);
mView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
// launch the VoiceDialer
Intent intent = new Intent(Intent.ACTION_VOICE_COMMAND);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
sendCloseSystemWindows();
mContext.startActivity(intent);
} catch (ActivityNotFoundException e) {
startCallActivity();
}
}
return true;
}
case KeyEvent.KEYCODE_CAMERA:
{
if (getKeyguardManager().inKeyguardRestrictedInputMode() || dispatcher == null) {
break;
}
if (event.getRepeatCount() == 0) {
dispatcher.startTracking(event, this);
} else if (event.isLongPress() && dispatcher.isTracking(event)) {
dispatcher.performedLongPress(event);
mView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
sendCloseSystemWindows();
// Broadcast an intent that the Camera button was longpressed
Intent intent = new Intent(Intent.ACTION_CAMERA_BUTTON, null);
intent.putExtra(Intent.EXTRA_KEY_EVENT, event);
mContext.sendOrderedBroadcastAsUser(intent, UserHandle.CURRENT_OR_SELF, null, null, null, 0, null, null);
}
return true;
}
case KeyEvent.KEYCODE_SEARCH:
{
if (getKeyguardManager().inKeyguardRestrictedInputMode() || dispatcher == null) {
break;
}
if (event.getRepeatCount() == 0) {
dispatcher.startTracking(event, this);
} else if (event.isLongPress() && dispatcher.isTracking(event)) {
Configuration config = mContext.getResources().getConfiguration();
if (config.keyboard == Configuration.KEYBOARD_NOKEYS || config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES) {
// launch the search activity
Intent intent = new Intent(Intent.ACTION_SEARCH_LONG_PRESS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
mView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
sendCloseSystemWindows();
getSearchManager().stopSearch();
mContext.startActivity(intent);
// Only clear this if we successfully start the
// activity; otherwise we will allow the normal short
// press action to be performed.
dispatcher.performedLongPress(event);
return true;
} catch (ActivityNotFoundException e) {
// Ignore
}
}
}
break;
}
}
return false;
}
use of android.content.ActivityNotFoundException in project android_frameworks_base by ParanoidAndroid.
the class PhoneFallbackEventHandler method startCallActivity.
void startCallActivity() {
sendCloseSystemWindows();
Intent intent = new Intent(Intent.ACTION_CALL_BUTTON);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
mContext.startActivity(intent);
} catch (ActivityNotFoundException e) {
Slog.w(TAG, "No activity found for android.intent.action.CALL_BUTTON.");
}
}
use of android.content.ActivityNotFoundException in project android_frameworks_base by ParanoidAndroid.
the class RecentApplicationsDialog method switchTo.
private void switchTo(RecentTag tag) {
if (tag.info.id >= 0) {
// This is an active task; it should just go to the foreground.
final ActivityManager am = (ActivityManager) getContext().getSystemService(Context.ACTIVITY_SERVICE);
am.moveTaskToFront(tag.info.id, ActivityManager.MOVE_TASK_WITH_HOME);
} else if (tag.intent != null) {
tag.intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY | Intent.FLAG_ACTIVITY_TASK_ON_HOME);
try {
getContext().startActivity(tag.intent);
} catch (ActivityNotFoundException e) {
Log.w("Recent", "Unable to launch recent task", e);
}
}
}
Aggregations