Search in sources :

Example 1 with Toast

use of android.widget.Toast in project cw-omnibus by commonsguy.

the class SidecarTileService method toast.

private void toast(int msg) {
    Toast t = Toast.makeText(this, msg, Toast.LENGTH_LONG);
    t.setGravity(Gravity.END | Gravity.BOTTOM, 32, 32);
    t.show();
}
Also used : Toast(android.widget.Toast)

Example 2 with Toast

use of android.widget.Toast in project restful-android by jeremyhaberman.

the class TimelineActivity method showToast.

private void showToast(String message) {
    if (!isFinishing()) {
        Toast toast = Toast.makeText(this, message, Toast.LENGTH_SHORT);
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.show();
    }
}
Also used : Toast(android.widget.Toast)

Example 3 with Toast

use of android.widget.Toast in project k-9 by k9mail.

the class RemoteControlService method startService.

@Override
public int startService(final Intent intent, final int startId) {
    Timber.i("RemoteControlService started with startId = %d", startId);
    final Preferences preferences = Preferences.getPreferences(this);
    if (RESCHEDULE_ACTION.equals(intent.getAction())) {
        Timber.i("RemoteControlService requesting MailService poll reschedule");
        MailService.actionReschedulePoll(this, null);
    }
    if (PUSH_RESTART_ACTION.equals(intent.getAction())) {
        Timber.i("RemoteControlService requesting MailService push restart");
        MailService.actionRestartPushers(this, null);
    } else if (RemoteControlService.SET_ACTION.equals(intent.getAction())) {
        Timber.i("RemoteControlService got request to change settings");
        execute(getApplication(), new Runnable() {

            public void run() {
                try {
                    boolean needsReschedule = false;
                    boolean needsPushRestart = false;
                    String uuid = intent.getStringExtra(K9_ACCOUNT_UUID);
                    boolean allAccounts = intent.getBooleanExtra(K9_ALL_ACCOUNTS, false);
                    if (allAccounts) {
                        Timber.i("RemoteControlService changing settings for all accounts");
                    } else {
                        Timber.i("RemoteControlService changing settings for account with UUID %s", uuid);
                    }
                    List<Account> accounts = preferences.getAccounts();
                    for (Account account : accounts) {
                        //warning: account may not be isAvailable()
                        if (allAccounts || account.getUuid().equals(uuid)) {
                            Timber.i("RemoteControlService changing settings for account %s", account.getDescription());
                            String notificationEnabled = intent.getStringExtra(K9_NOTIFICATION_ENABLED);
                            String ringEnabled = intent.getStringExtra(K9_RING_ENABLED);
                            String vibrateEnabled = intent.getStringExtra(K9_VIBRATE_ENABLED);
                            String pushClasses = intent.getStringExtra(K9_PUSH_CLASSES);
                            String pollClasses = intent.getStringExtra(K9_POLL_CLASSES);
                            String pollFrequency = intent.getStringExtra(K9_POLL_FREQUENCY);
                            if (notificationEnabled != null) {
                                account.setNotifyNewMail(Boolean.parseBoolean(notificationEnabled));
                            }
                            if (ringEnabled != null) {
                                account.getNotificationSetting().setRing(Boolean.parseBoolean(ringEnabled));
                            }
                            if (vibrateEnabled != null) {
                                account.getNotificationSetting().setVibrate(Boolean.parseBoolean(vibrateEnabled));
                            }
                            if (pushClasses != null) {
                                needsPushRestart |= account.setFolderPushMode(FolderMode.valueOf(pushClasses));
                            }
                            if (pollClasses != null) {
                                needsReschedule |= account.setFolderSyncMode(FolderMode.valueOf(pollClasses));
                            }
                            if (pollFrequency != null) {
                                String[] allowedFrequencies = getResources().getStringArray(R.array.account_settings_check_frequency_values);
                                for (String allowedFrequency : allowedFrequencies) {
                                    if (allowedFrequency.equals(pollFrequency)) {
                                        Integer newInterval = Integer.parseInt(allowedFrequency);
                                        needsReschedule |= account.setAutomaticCheckIntervalMinutes(newInterval);
                                    }
                                }
                            }
                            account.save(Preferences.getPreferences(RemoteControlService.this));
                        }
                    }
                    Timber.i("RemoteControlService changing global settings");
                    String backgroundOps = intent.getStringExtra(K9_BACKGROUND_OPERATIONS);
                    if (K9RemoteControl.K9_BACKGROUND_OPERATIONS_ALWAYS.equals(backgroundOps) || K9RemoteControl.K9_BACKGROUND_OPERATIONS_NEVER.equals(backgroundOps) || K9RemoteControl.K9_BACKGROUND_OPERATIONS_WHEN_CHECKED_AUTO_SYNC.equals(backgroundOps)) {
                        BACKGROUND_OPS newBackgroundOps = BACKGROUND_OPS.valueOf(backgroundOps);
                        boolean needsReset = K9.setBackgroundOps(newBackgroundOps);
                        needsPushRestart |= needsReset;
                        needsReschedule |= needsReset;
                    }
                    String theme = intent.getStringExtra(K9_THEME);
                    if (theme != null) {
                        K9.setK9Theme(K9RemoteControl.K9_THEME_DARK.equals(theme) ? K9.Theme.DARK : K9.Theme.LIGHT);
                    }
                    Storage storage = preferences.getStorage();
                    StorageEditor editor = storage.edit();
                    K9.save(editor);
                    editor.commit();
                    if (needsReschedule) {
                        Intent i = new Intent(RemoteControlService.this, RemoteControlService.class);
                        i.setAction(RESCHEDULE_ACTION);
                        long nextTime = System.currentTimeMillis() + 10000;
                        BootReceiver.scheduleIntent(RemoteControlService.this, nextTime, i);
                    }
                    if (needsPushRestart) {
                        Intent i = new Intent(RemoteControlService.this, RemoteControlService.class);
                        i.setAction(PUSH_RESTART_ACTION);
                        long nextTime = System.currentTimeMillis() + 10000;
                        BootReceiver.scheduleIntent(RemoteControlService.this, nextTime, i);
                    }
                } catch (Exception e) {
                    Timber.e(e, "Could not handle K9_SET");
                    Toast toast = Toast.makeText(RemoteControlService.this, e.getMessage(), Toast.LENGTH_LONG);
                    toast.show();
                }
            }
        }, RemoteControlService.REMOTE_CONTROL_SERVICE_WAKE_LOCK_TIMEOUT, startId);
    }
    return START_NOT_STICKY;
}
Also used : Account(com.fsck.k9.Account) Intent(android.content.Intent) StorageEditor(com.fsck.k9.preferences.StorageEditor) BACKGROUND_OPS(com.fsck.k9.K9.BACKGROUND_OPS) Storage(com.fsck.k9.preferences.Storage) Toast(android.widget.Toast) Preferences(com.fsck.k9.Preferences)

Example 4 with Toast

use of android.widget.Toast in project material-dialogs by afollestad.

the class CircleView method showHint.

public void showHint(int color) {
    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 (ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_LTR) {
        final int screenWidth = context.getResources().getDisplayMetrics().widthPixels;
        // mirror
        referenceX = screenWidth - referenceX;
    }
    Toast cheatSheet = Toast.makeText(context, String.format("#%06X", 0xFFFFFF & color), Toast.LENGTH_SHORT);
    if (midy < displayFrame.height()) {
        // Show along the top; follow action buttons
        cheatSheet.setGravity(Gravity.TOP | GravityCompat.END, referenceX, screenPos[1] + height - displayFrame.top);
    } else {
        // Show along the bottom center
        cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, height);
    }
    cheatSheet.show();
}
Also used : Context(android.content.Context) Rect(android.graphics.Rect) Toast(android.widget.Toast) Paint(android.graphics.Paint)

Example 5 with Toast

use of android.widget.Toast in project android_frameworks_base by ParanoidAndroid.

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