Example usage for android.app AlertDialog THEME_HOLO_DARK

List of usage examples for android.app AlertDialog THEME_HOLO_DARK

Introduction

In this page you can find the example usage for android.app AlertDialog THEME_HOLO_DARK.

Prototype

int THEME_HOLO_DARK

To view the source code for android.app AlertDialog THEME_HOLO_DARK.

Click Source Link

Document

Special theme constant for #AlertDialog(Context,int) : use the holographic alert theme with a dark background.

Usage

From source file:com.roque.rueda.cashflows.fragments.AddMovementFragment.java

/**
 * Create a date time dialog to allow the user choose the date for the movement.
 *
 *//* w  w w  .ja  va2s  .c o m*/
private void createDateTimeDialog() {

    // Add a listener to display a dialog when the user taps on this view.
    mDateText.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            // Set the current date if it's one the saved instance object.
            final Calendar c = Calendar.getInstance();
            c.setTimeInMillis(mCurrentDate);

            // Dialog settings.
            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), AlertDialog.THEME_HOLO_DARK);
            LayoutInflater layoutInflater = getActivity().getLayoutInflater();
            builder.setTitle(R.string.time_date_dialog_title);
            // Custom view used to display date picker and time picker.
            View dateTimeLayout = layoutInflater.inflate(R.layout.date_time_layout, null);

            // Text used to display the selected date.
            final TextView selectedDate = (TextView) dateTimeLayout.findViewById(R.id.selected_date);
            final Date selectedDateByUser = new Date(getInputDate());

            selectedDate.setText(StringFormatter.formatDate(selectedDateByUser));
            final DatePicker datePicker = (DatePicker) dateTimeLayout.findViewById(R.id.date_picker);
            final TimePicker timePicker = (TimePicker) dateTimeLayout.findViewById(R.id.time_picker);
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(selectedDateByUser);
            int year = calendar.get(Calendar.YEAR);
            int month = calendar.get(Calendar.MONTH);
            int day = calendar.get(Calendar.DAY_OF_MONTH);
            int hourOfTheDay = calendar.get(Calendar.HOUR_OF_DAY);
            int minute = calendar.get(Calendar.MINUTE);
            timePicker.setCurrentHour(hourOfTheDay);
            timePicker.setCurrentMinute(minute);

            // Initialize the date picker, also add a listener to
            // update the label when user change the values.
            datePicker.init(year, month, day, new DatePicker.OnDateChangedListener() {
                @Override
                public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                    Calendar calendar = Calendar.getInstance();
                    calendar.set(Calendar.YEAR, year);
                    calendar.set(Calendar.MONTH, monthOfYear);
                    calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
                    calendar.set(Calendar.HOUR_OF_DAY, timePicker.getCurrentHour());
                    calendar.set(Calendar.MINUTE, timePicker.getCurrentMinute());
                    calendar.set(Calendar.SECOND, 0);
                    Date modifyDate = calendar.getTime();
                    // Update the text view.
                    selectedDate.setText(StringFormatter.formatDate(modifyDate));
                }
            });

            // Listener used to update the values when time is selected.
            timePicker.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() {
                @Override
                public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
                    Calendar calendar = Calendar.getInstance();
                    calendar.set(Calendar.YEAR, datePicker.getYear());
                    calendar.set(Calendar.MONTH, datePicker.getMonth());
                    calendar.set(Calendar.DAY_OF_MONTH, datePicker.getDayOfMonth());
                    calendar.set(Calendar.HOUR_OF_DAY, hourOfDay);
                    calendar.set(Calendar.MINUTE, minute);
                    calendar.set(Calendar.SECOND, 0);
                    Date modifyDate = calendar.getTime();
                    // Update the text view.
                    selectedDate.setText(StringFormatter.formatDate(modifyDate));
                }
            });

            // Set the view to the dialog.
            builder.setView(dateTimeLayout);

            // Accept button behaviour.
            builder.setPositiveButton(R.string.accept, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    Calendar dialogDate = Calendar.getInstance();
                    dialogDate.set(Calendar.YEAR, datePicker.getYear());
                    dialogDate.set(Calendar.MONTH, datePicker.getMonth());
                    dialogDate.set(Calendar.DAY_OF_MONTH, datePicker.getDayOfMonth());
                    dialogDate.set(Calendar.HOUR_OF_DAY, timePicker.getCurrentHour());
                    dialogDate.set(Calendar.MINUTE, timePicker.getCurrentMinute());
                    dialogDate.set(Calendar.SECOND, 0);

                    setCurrentDateText(dialogDate.getTime());
                    dialog.dismiss();
                }
            });

            // Cancel button behaviour.
            builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {

                    dialog.cancel();
                }
            });

            // Create and display the dialog.
            Dialog dateDialog = builder.create();
            dateDialog.show();

        }
    });
}

From source file:radu.pidroid.Controller.java

@Override
public void onBackPressed() {
    new AlertDialog.Builder(this, AlertDialog.THEME_HOLO_DARK).setTitle("Disconnect")
            .setMessage("Are you sure you want to disconnect?").setIcon(android.R.drawable.ic_dialog_alert)
            .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialogInterface, int i) {
                    mMessenger.updateRoverSpeed(roverSpeed = 0);
                    mMessenger.stopMessenger();
                    finish();/*from   w w  w .j a v  a2 s . c  o m*/
                } // onClick
            }) // .setPositiveButton
            .setNegativeButton(android.R.string.cancel, null).create().show();

    videoFeedMjpegView.stopPlayback();
}

From source file:com.htc.dotdesign.DrawingView.java

private void selectPhotoSourceDialog() {
    if (mContext == null) {
        return;/*w  w  w  .j a v  a 2s  . c  om*/
    }
    if (mAlertDialog != null) {
        mAlertDialog.dismiss();
        mAlertDialog = null;
    }
    String[] selectPhotoFrom = getResources().getStringArray(R.array.items_select_template_from);
    mAlertDialog = new AlertDialog.Builder(mContext, AlertDialog.THEME_HOLO_DARK)
            .setTitle(R.string.title_choose_template_from).setCancelable(true)
            .setOnCancelListener(new DialogInterface.OnCancelListener() {
                public void onCancel(DialogInterface dialog) {
                    if (mAlertDialog != null) {
                        mAlertDialog.dismiss();
                        mAlertDialog = null;
                        showHideToolBar(true);
                    }
                };
            }).setItems(selectPhotoFrom, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    if (mAlertDialog != null) {
                        mAlertDialog.dismiss();
                        mAlertDialog = null;
                    }
                    switch (which) {
                    case 0: {
                        selectTemplate();
                    }
                        break;
                    case 1: {
                        selectFreeSketch();
                    }
                        break;
                    case 2: {
                        DotDesignUtil.selectTemplateFromGallery(mActivity);
                    }
                        break;
                    case 3: {
                        DotDesignUtil.selectTemplateFromCamera(mActivity);
                    }
                        break;
                    default:
                        break;
                    }
                }
            }).create();
    mAlertDialog.show();
    showHideToolBar(false);
}

From source file:com.roque.rueda.cashflows.fragments.AddMovementFragment.java

/**
 * Creates the input amount dialog./*from   ww w . j ava2 s. co  m*/
 * @param parentActivity Activity used to access application resources.
 */
private void buildInputMoneyDialog(Activity parentActivity) {
    AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity, AlertDialog.THEME_HOLO_DARK);
    builder.setTitle(getString(R.string.amount_dialog_title));
    builder.setMessage(getString(R.string.amount_dialog_label));
    builder.setPositiveButton(getString(R.string.save_amount), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

            // Set text of the dialog edit text to the amount button.
            double amountText = 0;
            String dialogText = mAmountTextDago.getText().toString();
            if (dialogText != null && !dialogText.isEmpty()) {
                amountText = Double.valueOf(dialogText);
            }

            // Close this dialog.
            dialog.dismiss();
            mButtonAmount.setText(StringFormatter.formatCurrency(amountText));
        }
    });

    builder.setNegativeButton(getString(R.string.cancel_amount), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            // Cancel this dialog.
            dialog.cancel();
        }
    });

    // Setup the input for the user.
    mAmountTextDago = new EditText(parentActivity);
    mAmountTextDago.setTextSize(TypedValue.COMPLEX_UNIT_SP, 25);
    mAmountTextDago.setGravity(Gravity.RIGHT);
    mAmountTextDago.setFilters(new InputFilter[] { new DecimalDigitsInputFiler(16, 2) });
    mAmountTextDago.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_CLASS_NUMBER);
    mAmountTextDago.setTextColor(getResources().getColor(R.color.text_white));

    mAmountTextDago.setTypeface(StringFormatter.createLightFont());

    // Assign this view to the dialog.
    builder.setView(mAmountTextDago);
    mInputMoneyDialog = builder.create();

    displayDialogKeyboard();

}

From source file:com.htc.dotdesign.DrawingView.java

public void exitDialog() {
    if (mContext == null) {
        return;/*from   w ww.  j av  a  2  s . c  o  m*/
    }
    if (mAlertDialog != null) {
        mAlertDialog.dismiss();
        mAlertDialog = null;
    }
    mAlertDialog = new AlertDialog.Builder(mContext, AlertDialog.THEME_HOLO_DARK).setTitle(R.string.title_exit)
            .setCancelable(true).setMessage(R.string.exit_dialog_message)
            .setOnCancelListener(new DialogInterface.OnCancelListener() {
                public void onCancel(DialogInterface dialog) {
                    if (mAlertDialog != null) {
                        mAlertDialog.dismiss();
                        mAlertDialog = null;
                        showHideToolBar(true);
                    }
                };
            }).setNegativeButton(R.string.button_not_save, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (mActivity != null) {
                        mActivity.finish();
                    }
                }
            }).setPositiveButton(R.string.button_save, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    isUserPressFinsih = true;
                    new HandleFilesTask().execute("");
                }
            }).create();
    mAlertDialog.show();
    showHideToolBar(false);
}

From source file:radu.pidroid.Controller.java

private void createDrawerRows() {
    /*/*from w  ww  .j  ava 2s  . co  m*/
     NOTE:  1. These constants must be in accordance with StringArray
            "drawer_items_list" in res/values/strings.xml
        2. Used only to help automate the creation process of drawer items
    */
    final int DRAWER_HEADER = 0, DRAWER_ROW = 1, DRAWER_SETTINGS_ROW = 2;

    //
    parentData = new ArrayList<DrawerItem>();
    childData = new HashMap<DrawerItem, List<DrawerItem>>();

    LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    //
    DrawerItem parent = null, child = null;
    List<DrawerItem> children;

    //
    for (int index = 0; index < mDrawerItemsList.length; index++) {

        //
        String[] parts = mDrawerItemsList[index].split(",");
        children = new ArrayList<DrawerItem>();

        //
        switch (Integer.parseInt(parts[0])) {

        case DRAWER_HEADER:
            parent = new DrawerHeader(this, inflater.inflate(R.layout.drawer_header, null));
            ((DrawerHeader) parent).setHeaderText(parts[1]);
            parentData.add(parent);
            break;

        case DRAWER_ROW:
            parent = new DrawerRow(this, inflater.inflate(R.layout.drawer_row, null));
            ((DrawerRow) parent).setRowText(parts[1]);
            ((DrawerRow) parent).setIconResource(android.R.drawable.ic_menu_always_landscape_portrait);
            parentData.add(parent);
            break;

        case DRAWER_SETTINGS_ROW:
            parent = new DrawerRow(this, inflater.inflate(R.layout.drawer_row, null));
            ((DrawerRow) parent).setRowText(parts[1]);
            ((DrawerRow) parent).setIconResource(android.R.drawable.ic_menu_always_landscape_portrait);
            parentData.add(parent);

            child = new DrawerSettingsRow(this, inflater.inflate(R.layout.drawer_settings_row, null));
            children.add(child);
            break;

        default:
            // invalid drawer item type
            Log.e("createDrawerRows(): ", "Check strings.xml");
        } // switch

        //
        childData.put(parent, children);
    } // for

    /*  The next part defines the behaviour of the drawer items.
            
    Because of the different types of rows, hard-coding these is the easiest
     approach as opposed to further complicating things to simply create them.
     */
    // TOUCH CONTROLS
    ((DrawerRow) parentData.get(1)).setRowFunction(new DrawerRow.ToggleSettings() {
        @Override
        public void toggle() {
            setControls(TOUCH_CONTROLS);
            mDrawerLayout.closeDrawer(mDrawerListView);
            Toast.makeText(parentData.get(1).getUIContext(), "Touch controls have been set", Toast.LENGTH_SHORT)
                    .show();
        } // toggle
    });

    // SLIDER CONTROLS
    ((DrawerRow) parentData.get(2)).setRowFunction(new DrawerRow.ToggleSettings() {
        @Override
        public void toggle() {
            setControls(SLIDER_CONTROLS);
            mDrawerLayout.closeDrawer(mDrawerListView);
            Toast.makeText(parentData.get(2).getUIContext(), "Slider controls have been set",
                    Toast.LENGTH_SHORT).show();
        } // toggle
    });

    // JOYSTICK CONTROLS
    ((DrawerRow) parentData.get(3)).setRowFunction(new DrawerRow.ToggleSettings() {
        @Override
        public void toggle() {
            setControls(JOYSTICK_CONTROLS);
            mDrawerLayout.closeDrawer(mDrawerListView);
            Toast.makeText(parentData.get(3).getUIContext(), "Joystick controls have been set",
                    Toast.LENGTH_SHORT).show();
        } // toggle
    });

    // MAXIMUM TILT ANGLE
    ((DrawerSettingsRow) childData.get(parentData.get(5)).get(0))
            .setSettingsFunction(new DrawerSettingsRow.SliderSettings() {
                @Override
                public String calculate(int progress) {
                    maxTiltAngle = (int) (progress * 0.8 + 10) / 10 * 10;
                    return Controller.maxTiltAngle + "";
                } // calculate
            });
    ((DrawerSettingsRow) childData.get(parentData.get(5)).get(0))
            .initialise((int) ((maxTiltAngle / 10 * 10 - 10) / 0.8));

    // ACCELERATION TIME
    ((DrawerSettingsRow) childData.get(parentData.get(6)).get(0))
            .setSettingsFunction(new DrawerSettingsRow.SliderSettings() {
                @Override
                public String calculate(int progress) {
                    accelerationTime = progress / 10 * 250;
                    return accelerationTime + "ms";
                } // calculate
            });
    ((DrawerSettingsRow) childData.get(parentData.get(6)).get(0)).initialise(accelerationTime / 250 * 10);

    // DECELERATION TIME
    ((DrawerSettingsRow) childData.get(parentData.get(7)).get(0))
            .setSettingsFunction(new DrawerSettingsRow.SliderSettings() {
                @Override
                public String calculate(int progress) {
                    decelerationTime = progress / 10 * 250;
                    return decelerationTime + "ms";
                } // calculate
            });
    ((DrawerSettingsRow) childData.get(parentData.get(7)).get(0)).initialise(decelerationTime / 250 * 10);

    // TOUCH RESPONSIVENESS
    ((DrawerSettingsRow) childData.get(parentData.get(8)).get(0))
            .setSettingsFunction(new DrawerSettingsRow.SliderSettings() {
                @Override
                public String calculate(int progress) {
                    touchResponsiveness = progress / 10 * 50;
                    return touchResponsiveness + "ms";
                } // calculate
            });
    ((DrawerSettingsRow) childData.get(parentData.get(8)).get(0)).initialise(touchResponsiveness / 50 * 10);

    // TURN SENSITIVITY
    ((DrawerSettingsRow) childData.get(parentData.get(10)).get(0))
            .setSettingsFunction(new DrawerSettingsRow.SliderSettings() {
                @Override
                public String calculate(int progress) {
                    turnSensitivity = progress / 25 + 1;
                    mMessenger.updateTurnSensitivity(turnSensitivity);
                    return turnSensitivity + "";
                } // calculate
            });
    ((DrawerSettingsRow) childData.get(parentData.get(10)).get(0)).initialise((turnSensitivity - 1) * 25);

    // LEARN NEW OBJECT
    ((DrawerRow) parentData.get(11)).setRowFunction(new DrawerRow.ToggleSettings() {
        @Override
        public void toggle() {
            mDrawerLayout.closeDrawer(mDrawerListView);

            // Before we fire of the learning process, ask the user what this new object is
            new AlertDialog.Builder(parentData.get(11).getUIContext(), AlertDialog.THEME_HOLO_DARK)
                    .setTitle("What is this new object?").setIcon(android.R.drawable.ic_dialog_info)
                    .setItems(R.array.object_names, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int index) {
                            new LearningTask(parentData.get(11).getUIContext(), LearningTask.PIDROID_LEARN,
                                    index).execute();
                        } // onClick
                    }).setCancelable(false).create().show();
        } // toggle
    });

    // RECOGNISE OBJECT
    ((DrawerRow) parentData.get(12)).setRowFunction(new DrawerRow.ToggleSettings() {
        @Override
        public void toggle() {
            mDrawerLayout.closeDrawer(mDrawerListView);
            new LearningTask(parentData.get(12).getUIContext(), LearningTask.PIDROID_RECOGNISE).execute();
        } // toggle
    });

    // CLEAR LEARNING DATA
    ((DrawerRow) parentData.get(13)).setRowFunction(new DrawerRow.ToggleSettings() {
        @Override
        public void toggle() {
            new AlertDialog.Builder(parentData.get(13).getUIContext(), AlertDialog.THEME_HOLO_DARK)
                    .setTitle("Clear Data").setMessage("Are you sure you want to delete all learned data?")
                    .setIcon(android.R.drawable.ic_dialog_alert)
                    .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialogInterface, int i) {
                            mMessenger.clearLearningData();
                        } // onClick
                    }) // .setPositiveButton
                    .setNegativeButton(android.R.string.cancel, null).create().show();
        } // toggle
    });

    // CAMERA STABILISATION
    ((DrawerRow) parentData.get(15)).setRowFunction(new DrawerRow.ToggleSettings() {
        @Override
        public void toggle() {
            mDrawerLayout.closeDrawer(mDrawerListView);
            cameraStabilisationOn = !cameraStabilisationOn;
            videoFeedMjpegView.setCameraStabilisation(cameraStabilisationOn);

            if (cameraStabilisationOn)
                Toast.makeText(parentData.get(15).getUIContext(), "Camera stabilisation is now ON",
                        Toast.LENGTH_LONG).show();
            else
                Toast.makeText(parentData.get(15).getUIContext(), "Camera stabilisation is now OFF",
                        Toast.LENGTH_LONG).show();
        } // toggle
    });

    // CHANGE HUD
    ((DrawerRow) parentData.get(16)).setRowFunction(new DrawerRow.ToggleSettings() {
        @Override
        public void toggle() {
            if (++currentHudResource == hudResources.length)
                currentHudResource = 0;
            hudImageView.setImageResource(hudResources[currentHudResource]);
        } // toggle
    });

    // LEVEL INDICATOR
    ((DrawerRow) parentData.get(17)).setRowFunction(new DrawerRow.ToggleSettings() {
        @Override
        public void toggle() {
            if (levelIndicatorImageView.getVisibility() == View.VISIBLE)
                levelIndicatorImageView.setVisibility(View.INVISIBLE);
            else
                levelIndicatorImageView.setVisibility(View.VISIBLE);
        } // toggle
    });

    // TUTORIALS
    ((DrawerRow) parentData.get(18)).setRowFunction(new DrawerRow.ToggleSettings() {
        @Override
        public void toggle() {
            tutorialsOn = !tutorialsOn;
            mDrawerLayout.closeDrawer(mDrawerListView);

            if (tutorialsOn)
                Toast.makeText(parentData.get(18).getUIContext(), "Tutorials are now ON", Toast.LENGTH_LONG)
                        .show();
            else
                Toast.makeText(parentData.get(18).getUIContext(), "Tutorials are now OFF", Toast.LENGTH_LONG)
                        .show();
        } // toggle
    });
}