use of android.widget.Toast in project android_frameworks_base by ResurrectionRemix.
the class HeadsUpManager method snooze.
public void snooze() {
for (String key : mHeadsUpEntries.keySet()) {
HeadsUpEntry entry = mHeadsUpEntries.get(key);
String packageName = entry.entry.notification.getPackageName();
mSnoozedPackages.put(snoozeKey(packageName, mUser), SystemClock.elapsedRealtime() + mSnoozeLengthMs);
if (mSnoozeLengthMs != 0) {
String appName = null;
try {
appName = (String) mContext.getPackageManager().getApplicationLabel(mContext.getPackageManager().getApplicationInfo(packageName, PackageManager.GET_META_DATA));
} catch (PackageManager.NameNotFoundException e) {
appName = packageName;
}
if (mSnoozeLengthMs == 60000) {
Toast toast = Toast.makeText(mContext, mContext.getString(R.string.heads_up_snooze_message_one_minute, appName), Toast.LENGTH_LONG);
TextView v = (TextView) toast.getView().findViewById(android.R.id.message);
if (v != null)
v.setGravity(Gravity.CENTER);
toast.show();
} else {
Toast toast = Toast.makeText(mContext, mContext.getString(R.string.heads_up_snooze_message, appName, mSnoozeLengthMs / 60 / 1000), Toast.LENGTH_LONG);
TextView v = (TextView) toast.getView().findViewById(android.R.id.message);
if (v != null)
v.setGravity(Gravity.CENTER);
toast.show();
}
}
}
mReleaseOnExpandFinish = true;
}
use of android.widget.Toast in project android_frameworks_base by ResurrectionRemix.
the class RecentController method openLastApptoBottom.
public void openLastApptoBottom() {
int taskid = 0;
boolean doWeHaveAtask = true;
final ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
ActivityManager.RunningTaskInfo lastTask = getLastTask(am);
if (lastTask != null) {
//user already ran another app in this session, we can dock it to the other side
taskid = lastTask.id;
} else {
//no last app for this session, let's search in the previous session recent apps
List<ActivityManager.RecentTaskInfo> recentTasks = am.getRecentTasksForUser(ActivityManager.getMaxRecentTasksStatic(), ActivityManager.RECENT_IGNORE_HOME_STACK_TASKS | ActivityManager.RECENT_INGORE_DOCKED_STACK_TOP_TASK | ActivityManager.RECENT_INGORE_PINNED_STACK_TASKS | ActivityManager.RECENT_IGNORE_UNAVAILABLE | ActivityManager.RECENT_INCLUDE_PROFILES, UserHandle.CURRENT.getIdentifier());
if (recentTasks != null && recentTasks.size() > 1) {
ActivityManager.RecentTaskInfo recentInfo = recentTasks.get(1);
taskid = recentInfo.persistentId;
} else {
//user cleared all apps, we don't have any taskid to choose
doWeHaveAtask = false;
}
}
if (doWeHaveAtask) {
try {
ActivityOptions options = ActivityOptions.makeBasic();
ActivityManagerNative.getDefault().startActivityFromRecents(taskid, options.toBundle());
} catch (RemoteException e) {
}
} else {
Toast noLastapp = Toast.makeText(mContext, R.string.recents_multiwin_nolastapp, Toast.LENGTH_LONG);
noLastapp.show();
}
}
use of android.widget.Toast in project android_frameworks_base by ResurrectionRemix.
the class ActionMenuItemView method onLongClick.
@Override
public boolean onLongClick(View v) {
if (hasText()) {
// Don't show the cheat sheet for items that already show text.
return false;
}
final int[] screenPos = new int[2];
final Rect displayFrame = new Rect();
getLocationOnScreen(screenPos);
getWindowVisibleDisplayFrame(displayFrame);
final Context context = getContext();
final int width = getWidth();
final int height = getHeight();
final int midy = screenPos[1] + height / 2;
int referenceX = screenPos[0] + width / 2;
if (v.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR) {
final int screenWidth = context.getResources().getDisplayMetrics().widthPixels;
// mirror
referenceX = screenWidth - referenceX;
}
Toast cheatSheet = Toast.makeText(context, mItemData.getTitle(), Toast.LENGTH_SHORT);
if (midy < displayFrame.height()) {
// Show along the top; follow action buttons
cheatSheet.setGravity(Gravity.TOP | Gravity.END, referenceX, screenPos[1] + height - displayFrame.top);
} else {
// Show along the bottom center
cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, height);
}
cheatSheet.show();
return true;
}
use of android.widget.Toast in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SystemappRemover method toast.
public void toast(String text) {
// easy toasts for all!
Toast toast = Toast.makeText(getView().getContext(), text, Toast.LENGTH_SHORT);
toast.show();
}
use of android.widget.Toast in project android_frameworks_base by ResurrectionRemix.
the class MediaRouteButton method performLongClick.
@Override
public boolean performLongClick() {
if (super.performLongClick()) {
return true;
}
if (!mCheatSheetEnabled) {
return false;
}
final CharSequence contentDesc = getContentDescription();
if (TextUtils.isEmpty(contentDesc)) {
// Don't show the cheat sheet if we have no description
return false;
}
final int[] screenPos = new int[2];
final Rect displayFrame = new Rect();
getLocationOnScreen(screenPos);
getWindowVisibleDisplayFrame(displayFrame);
final Context context = getContext();
final int width = getWidth();
final int height = getHeight();
final int midy = screenPos[1] + height / 2;
final int screenWidth = context.getResources().getDisplayMetrics().widthPixels;
Toast cheatSheet = Toast.makeText(context, contentDesc, Toast.LENGTH_SHORT);
if (midy < displayFrame.height()) {
// Show along the top; follow action buttons
cheatSheet.setGravity(Gravity.TOP | Gravity.END, screenWidth - screenPos[0] - width / 2, height);
} else {
// Show along the bottom center
cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, height);
}
cheatSheet.show();
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
return true;
}
Aggregations