Search in sources :

Example 56 with AlertDialog

use of android.app.AlertDialog in project WordPress-Android by wordpress-mobile.

the class JetpackUtils method showJetpackNonConnectedAlert.

public static void showJetpackNonConnectedAlert(final Activity activity, final SiteModel site) {
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    if (site.isSelfHostedAdmin()) {
        builder.setMessage(activity.getString(R.string.jetpack_not_connected_message)).setTitle(activity.getString(R.string.jetpack_not_connected));
        builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int id) {
                String stringToLoad = site.getAdminUrl();
                String jetpackConnectPageAdminPath = "admin.php?page=jetpack";
                stringToLoad = stringToLoad.endsWith("/") ? stringToLoad + jetpackConnectPageAdminPath : stringToLoad + "/" + jetpackConnectPageAdminPath;
                String authURL = WPWebViewActivity.getSiteLoginUrl(site);
                Intent jetpackIntent = new Intent(activity, WPWebViewActivity.class);
                jetpackIntent.putExtra(WPWebViewActivity.AUTHENTICATION_USER, site.getUsername());
                jetpackIntent.putExtra(WPWebViewActivity.AUTHENTICATION_PASSWD, site.getPassword());
                jetpackIntent.putExtra(WPWebViewActivity.URL_TO_LOAD, stringToLoad);
                jetpackIntent.putExtra(WPWebViewActivity.AUTHENTICATION_URL, authURL);
                activity.startActivityForResult(jetpackIntent, RequestCodes.REQUEST_JETPACK);
                // TODO: rename STATS_SELECTED_CONNECT_JETPACK to something more generic
                AnalyticsTracker.track(AnalyticsTracker.Stat.STATS_SELECTED_CONNECT_JETPACK);
            }
        });
        builder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int id) {
                // User cancelled the dialog. Hide current activity.
                activity.finish();
            }
        });
    } else {
        builder.setMessage(activity.getString(R.string.jetpack_message_not_admin)).setTitle(activity.getString(R.string.jetpack_not_found));
        builder.setPositiveButton(R.string.yes, null);
    }
    AlertDialog dialog = builder.create();
    dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            // User pressed the back key. Hide current activity.
            activity.finish();
        }
    });
    dialog.show();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent) WPWebViewActivity(org.wordpress.android.ui.WPWebViewActivity)

Example 57 with AlertDialog

use of android.app.AlertDialog in project XobotOS by xamarin.

the class ShutdownThread method shutdown.

/**
     * Request a clean shutdown, waiting for subsystems to clean up their
     * state etc.  Must be called from a Looper thread in which its UI
     * is shown.
     *
     * @param context Context used to display the shutdown progress dialog.
     * @param confirm true if user confirmation is needed before shutting down.
     */
public static void shutdown(final Context context, boolean confirm) {
    // any additional calls are just returned
    synchronized (sIsStartedGuard) {
        if (sIsStarted) {
            Log.d(TAG, "Request to shutdown already running, returning.");
            return;
        }
    }
    final int longPressBehavior = context.getResources().getInteger(com.android.internal.R.integer.config_longPressOnPowerBehavior);
    final int resourceId = longPressBehavior == 2 ? com.android.internal.R.string.shutdown_confirm_question : com.android.internal.R.string.shutdown_confirm;
    Log.d(TAG, "Notifying thread to start shutdown longPressBehavior=" + longPressBehavior);
    if (confirm) {
        final CloseDialogReceiver closer = new CloseDialogReceiver(context);
        final AlertDialog dialog = new AlertDialog.Builder(context).setTitle(com.android.internal.R.string.power_off).setMessage(resourceId).setPositiveButton(com.android.internal.R.string.yes, new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                beginShutdownSequence(context);
            }
        }).setNegativeButton(com.android.internal.R.string.no, null).create();
        closer.dialog = dialog;
        dialog.setOnDismissListener(closer);
        dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
        dialog.show();
    } else {
        beginShutdownSequence(context);
    }
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface)

Example 58 with AlertDialog

use of android.app.AlertDialog in project WordPress-Android by wordpress-mobile.

the class ReaderSearchSuggestionAdapter method confirmClearSavedSearches.

private void confirmClearSavedSearches(Context context) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setMessage(R.string.dlg_confirm_clear_search_history).setCancelable(true).setNegativeButton(R.string.no, null).setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {
            clearSavedSearches();
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface)

Example 59 with AlertDialog

use of android.app.AlertDialog in project JamsMusicPlayer by psaravan.

the class EqualizerActivity method buildSavePresetDialog.

/**
	 * Builds the "Save Preset" dialog. Does not call the show() method, so you 
	 * should do this manually when calling this method.
	 * 
	 * @return A fully built AlertDialog reference.
	 */
private AlertDialog buildSavePresetDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    View dialogView = getLayoutInflater().inflate(R.layout.add_new_equalizer_preset_dialog_layout, null);
    final EditText newPresetNameField = (EditText) dialogView.findViewById(R.id.new_preset_name_text_field);
    newPresetNameField.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Light"));
    newPresetNameField.setPaintFlags(newPresetNameField.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    //Set the dialog title.
    builder.setTitle(R.string.save_preset);
    builder.setView(dialogView);
    builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int arg1) {
            dialog.dismiss();
        }
    });
    builder.setPositiveButton(R.string.done, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            //Get the preset name from the text field.
            String presetName = newPresetNameField.getText().toString();
            //Add the preset and it's values to the DB.
            mApp.getDBAccessHelper().addNewEQPreset(presetName, fiftyHertzLevel, oneThirtyHertzLevel, threeTwentyHertzLevel, eightHundredHertzLevel, twoKilohertzLevel, fiveKilohertzLevel, twelvePointFiveKilohertzLevel, (short) virtualizerSeekBar.getProgress(), (short) bassBoostSeekBar.getProgress(), (short) reverbSpinner.getSelectedItemPosition());
            Toast.makeText(mContext, R.string.preset_saved, Toast.LENGTH_SHORT).show();
            dialog.dismiss();
        }
    });
    return builder.create();
}
Also used : AlertDialog(android.app.AlertDialog) EditText(android.widget.EditText) DialogInterface(android.content.DialogInterface) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) Paint(android.graphics.Paint)

Example 60 with AlertDialog

use of android.app.AlertDialog in project JamsMusicPlayer by psaravan.

the class EqualizerActivity method buildLoadPresetDialog.

/**
	 * Builds the "Load Preset" dialog. Does not call the show() method, so this 
	 * should be done manually after calling this method.
	 * 
	 * @return A fully built AlertDialog reference.
	 */
private AlertDialog buildLoadPresetDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    //Get a cursor with the list of EQ presets.
    final Cursor cursor = mApp.getDBAccessHelper().getAllEQPresets();
    //Set the dialog title.
    builder.setTitle(R.string.load_preset);
    builder.setCursor(cursor, new DialogInterface.OnClickListener() {

        @SuppressWarnings("unchecked")
        @Override
        public void onClick(DialogInterface dialog, int which) {
            cursor.moveToPosition(which);
            //Close the dialog.
            dialog.dismiss();
            //Pass on the equalizer values to the appropriate fragment.
            fiftyHertzLevel = cursor.getInt(cursor.getColumnIndex(DBAccessHelper.EQ_50_HZ));
            oneThirtyHertzLevel = cursor.getInt(cursor.getColumnIndex(DBAccessHelper.EQ_130_HZ));
            threeTwentyHertzLevel = cursor.getInt(cursor.getColumnIndex(DBAccessHelper.EQ_320_HZ));
            eightHundredHertzLevel = cursor.getInt(cursor.getColumnIndex(DBAccessHelper.EQ_800_HZ));
            twoKilohertzLevel = cursor.getInt(cursor.getColumnIndex(DBAccessHelper.EQ_2000_HZ));
            fiveKilohertzLevel = cursor.getInt(cursor.getColumnIndex(DBAccessHelper.EQ_5000_HZ));
            twelvePointFiveKilohertzLevel = cursor.getInt(cursor.getColumnIndex(DBAccessHelper.EQ_12500_HZ));
            virtualizerLevel = cursor.getShort(cursor.getColumnIndex(DBAccessHelper.VIRTUALIZER));
            bassBoostLevel = cursor.getShort(cursor.getColumnIndex(DBAccessHelper.BASS_BOOST));
            reverbSetting = cursor.getShort(cursor.getColumnIndex(DBAccessHelper.REVERB));
            //Save the new equalizer settings to the DB.
            @SuppressWarnings({ "rawtypes" }) AsyncTask task = new AsyncTask() {

                @Override
                protected Object doInBackground(Object... arg0) {
                    setEQValuesForSong(mApp.getService().getCurrentSong().getId());
                    return null;
                }

                @Override
                public void onPostExecute(Object result) {
                    super.onPostExecute(result);
                    //Reinitialize the UI elements to apply the new equalizer settings.
                    new AsyncInitSlidersTask().execute();
                }
            };
            task.execute();
            if (cursor != null)
                cursor.close();
        }
    }, DBAccessHelper.PRESET_NAME);
    return builder.create();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) AsyncTask(android.os.AsyncTask) Cursor(android.database.Cursor) Paint(android.graphics.Paint)

Aggregations

AlertDialog (android.app.AlertDialog)1029 DialogInterface (android.content.DialogInterface)573 View (android.view.View)278 TextView (android.widget.TextView)213 Intent (android.content.Intent)172 EditText (android.widget.EditText)160 Test (org.junit.Test)148 ShadowAlertDialog (org.robolectric.shadows.ShadowAlertDialog)111 Context (android.content.Context)96 ListView (android.widget.ListView)87 ImageView (android.widget.ImageView)86 LayoutInflater (android.view.LayoutInflater)80 Button (android.widget.Button)78 AdapterView (android.widget.AdapterView)72 Activity (android.app.Activity)66 SuppressLint (android.annotation.SuppressLint)61 Bundle (android.os.Bundle)56 OnClickListener (android.content.DialogInterface.OnClickListener)54 ArrayList (java.util.ArrayList)50 Dialog (android.app.Dialog)46