Search in sources :

Example 11 with Toast

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;
}
Also used : PackageManager(android.content.pm.PackageManager) Toast(android.widget.Toast) TextView(android.widget.TextView)

Example 12 with Toast

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();
    }
}
Also used : Toast(android.widget.Toast) ActivityManager(android.app.ActivityManager) RemoteException(android.os.RemoteException) Point(android.graphics.Point) ActivityOptions(android.app.ActivityOptions)

Example 13 with Toast

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;
}
Also used : Context(android.content.Context) Rect(android.graphics.Rect) Toast(android.widget.Toast)

Example 14 with Toast

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();
}
Also used : Toast(android.widget.Toast)

Example 15 with Toast

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;
}
Also used : Context(android.content.Context) Rect(android.graphics.Rect) Toast(android.widget.Toast)

Aggregations

Toast (android.widget.Toast)485 Context (android.content.Context)89 View (android.view.View)86 TextView (android.widget.TextView)74 Intent (android.content.Intent)55 Rect (android.graphics.Rect)34 LayoutInflater (android.view.LayoutInflater)31 SuppressLint (android.annotation.SuppressLint)30 JSONObject (org.json.JSONObject)23 ImageView (android.widget.ImageView)21 RequestQueue (com.android.volley.RequestQueue)20 Response (com.android.volley.Response)20 EditText (android.widget.EditText)19 JSONException (org.json.JSONException)18 VolleyError (com.android.volley.VolleyError)17 JsonObjectRequest (com.android.volley.toolbox.JsonObjectRequest)17 User (model.User)16 PendingIntent (android.app.PendingIntent)15 File (java.io.File)15 HashMap (java.util.HashMap)15