Example usage for android.app Dialog requestWindowFeature

List of usage examples for android.app Dialog requestWindowFeature

Introduction

In this page you can find the example usage for android.app Dialog requestWindowFeature.

Prototype

public final boolean requestWindowFeature(int featureId) 

Source Link

Document

Enable extended window features.

Usage

From source file:com.entertailion.android.launcher.Dialogs.java

/**
 * Utility method to display an alert dialog. Use instead of AlertDialog to
 * get the right styling.//from   w  w w .  j a va 2  s  .c om
 * 
 * @param context
 * @param message
 */
public static void displayAlert(final Launcher context, String message) {
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.alert);

    final TextView alertTextView = (TextView) dialog.findViewById(R.id.alertText);
    alertTextView.setText(message);
    Button alertButton = (Button) dialog.findViewById(R.id.alertButton);
    alertButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            context.showCover(false);
            dialog.dismiss();
        }

    });
    dialog.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            context.showCover(false);
        }

    });
    context.showCover(true);
    dialog.show();
}

From source file:com.kircherelectronics.gyroscopeexplorer.activity.GyroscopeActivity.java

private void showHelpDialog() {
    Dialog helpDialog = new Dialog(this);

    helpDialog.setCancelable(true);//from   www. ja  va2s. c o  m
    helpDialog.setCanceledOnTouchOutside(true);
    helpDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

    View view = getLayoutInflater().inflate(R.layout.layout_help_home, null);

    helpDialog.setContentView(view);

    helpDialog.show();
}

From source file:com.entertailion.android.launcher.Dialogs.java

/**
 * Display the list of Spotlight web apps:
 * https://www.google.com/tv/spotlight-gallery.html Allow the user to launch
 * a web app in the browser.// ww  w  . j  ava 2 s .  c  o m
 * 
 * @param context
 */
public static void displayAllSpotlight(final Launcher context) {
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.spotlight_grid);

    final GridView gridView = (GridView) dialog.findViewById(R.id.grid);
    final ArrayList<SpotlightInfo> spotlights = SpotlightTable.getAllSpotlights(context);
    gridView.setAdapter(new AllSpotlightAdapter(context, spotlights));
    gridView.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            SpotlightInfo spotlightInfo = (SpotlightInfo) parent.getAdapter().getItem(position);
            spotlightInfo.invoke(context);
            context.showCover(false);
            dialog.dismiss();
            Analytics.logEvent(Analytics.INVOKE_SPOTLIGHT_WEB_APP);
        }

    });
    gridView.setDrawingCacheEnabled(true);
    gridView.setOnKeyListener(onKeyListener);
    dialog.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            context.showCover(false);
        }

    });
    context.showCover(true);
    dialog.show();
    Analytics.logEvent(Analytics.DIALOG_SPOTLIGHT_WEB_APPS);
}

From source file:com.entertailion.android.launcher.Dialogs.java

/**
 * Display introduction to the user for first time launch
 * /*from w  w  w .j a  va 2s.co  m*/
 * @param context
 */
public static void displayIntroduction(final Launcher context) {
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.introduction);

    Typeface lightTypeface = ((LauncherApplication) context.getApplicationContext()).getLightTypeface(context);

    TextView titleTextView = (TextView) dialog.findViewById(R.id.intro_title);
    titleTextView.setTypeface(lightTypeface);
    TextView textView1 = (TextView) dialog.findViewById(R.id.intro_text1);
    textView1.setTypeface(lightTypeface);
    TextView textView2 = (TextView) dialog.findViewById(R.id.intro_text2);
    textView2.setTypeface(lightTypeface);

    ((Button) dialog.findViewById(R.id.intro_button)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            context.showCover(false);
            dialog.dismiss();
        }

    });
    dialog.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            context.showCover(false);
        }

    });
    context.showCover(true);
    dialog.show();
    Analytics.logEvent(Analytics.DIALOG_INTRODUCTION);
}

From source file:com.gumgoose.app.quakebuddy.EarthquakeActivity.java

private void showWhatsNewDialog() {
    // Display the change log for QuakeBuddy on-screen
    Dialog dialog = new Dialog(this, android.R.style.Theme_Dialog);
    dialog.setCanceledOnTouchOutside(true);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    dialog.setContentView(R.layout.dialog_change_log);
    dialog.show();/*from  w  ww  .ja va 2s.  c  o m*/
}

From source file:it.andreale.mdatetimepicker.time.TimePickerDialog.java

@NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // restore old state if not null
    if (savedInstanceState != null) {
        mHeaderColor = savedInstanceState.getInt(SAVED_HEADER_COLOR, DEFAULT_ACCENT_COLOR);
        mPositiveColor = savedInstanceState.getInt(SAVED_POSITIVE_COLOR, DEFAULT_ACCENT_COLOR);
        mNegativeColor = savedInstanceState.getInt(SAVED_NEGATIVE_COLOR, DEFAULT_ACCENT_COLOR);
        mDarkTheme = savedInstanceState.getBoolean(SAVED_DARK_MODE, false);
        mCircleColor = savedInstanceState.getInt(SAVED_CIRCLE_COLOR,
                mDarkTheme ? Color.parseColor("#555555") : Color.parseColor("#eeeeee"));
        mSelectorColor = savedInstanceState.getInt(SAVED_SELECTOR_COLOR, DEFAULT_ACCENT_COLOR);
        mDefaultTextColor = savedInstanceState.getInt(SAVED_TEXT_COLOR, mDarkTheme ? Color.BLACK : Color.WHITE);
        mSelectedTextColor = savedInstanceState.getInt(SAVED_SELECTED_TEXT_COLOR,
                mDarkTheme ? Color.WHITE : Color.BLACK);
        mCalendar = (Calendar) savedInstanceState.getSerializable(SAVED_CALENDAR);
        mPositiveText = savedInstanceState.getString(SAVED_POSITIVE_TEXT, getString(android.R.string.ok));
        mNegativeText = savedInstanceState.getString(SAVED_NEGATIVE_TEXT, getString(android.R.string.cancel));
        m24HourMode = savedInstanceState.getBoolean(SAVED_HOUR_MODE, false);
        mBuilderFlag = true;/*from  w  w  w. j ava  2  s  .  c om*/
    } else {
        // check builder flag
        if (!mBuilderFlag) {
            throw new IllegalStateException("You must initialize TimePickerDialog throw Builder class");
        }
    }
    // inflate view
    View view = inflatePickerView(savedInstanceState);
    // style views
    mHeaderView.setBackgroundColor(mHeaderColor);
    view.setBackgroundColor(mDarkTheme ? BACKGROUND_DARK : BACKGROUND_LIGHT);
    // create dialog
    Dialog dialog = new Dialog(getActivity());
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(view);
    return dialog;
}

From source file:com.entertailion.android.launcher.Dialogs.java

/**
 * Display a dialog to confirm that the user wants to delete an item.
 * /*from ww  w .  j  a v  a  2s.c o m*/
 * @param context
 */
public static void displayDeleteItem(final Launcher context) {
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.confirmation);

    TextView confirmationTextView = (TextView) dialog.findViewById(R.id.confirmationText);
    confirmationTextView.setText(context.getString(R.string.dialog_delete_item_message));
    Button buttonYes = (Button) dialog.findViewById(R.id.button1);
    buttonYes.setText(context.getString(R.string.dialog_yes));
    buttonYes.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            context.deleteCurrentItem();
            context.showCover(false);
            dialog.dismiss();
        }

    });
    Button buttonNo = (Button) dialog.findViewById(R.id.button2);
    buttonNo.setText(context.getString(R.string.dialog_no));
    buttonNo.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            context.showCover(false);
            dialog.dismiss();
        }

    });
    dialog.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            context.showCover(false);
        }

    });
    context.showCover(true);
    dialog.show();
    Analytics.logEvent(Analytics.DIALOG_DELETE_ITEM);
}

From source file:com.entertailion.android.launcher.Dialogs.java

/**
 * Display a dialog to confirm that a user wants to delete a row.
 * //ww  w. j a v a  2 s  .  c  om
 * @param context
 */
public static void displayDeleteRow(final Launcher context) {
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.confirmation);

    TextView confirmationTextView = (TextView) dialog.findViewById(R.id.confirmationText);
    confirmationTextView.setText(context.getString(R.string.dialog_delete_row_message));
    Button buttonYes = (Button) dialog.findViewById(R.id.button1);
    buttonYes.setText(context.getString(R.string.dialog_yes));
    buttonYes.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            context.deleteCurrentRow();
            context.showCover(false);
            dialog.dismiss();
        }

    });
    Button buttonNo = (Button) dialog.findViewById(R.id.button2);
    buttonNo.setText(context.getString(R.string.dialog_no));
    buttonNo.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            context.showCover(false);
            dialog.dismiss();
        }

    });
    dialog.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            context.showCover(false);
        }

    });
    context.showCover(true);
    dialog.show();
    Analytics.logEvent(Analytics.DIALOG_DELETE_ROW);
}

From source file:com.entertailion.android.launcher.Dialogs.java

/**
 * Display the list of browser history.//from  ww  w.jav a  2  s  .c om
 * 
 * @param context
 */
public static void displayBrowserHistory(final Launcher context) {
    final ArrayList<BookmarkInfo> bookmarks = loadBrowserHistory(context);
    if (bookmarks.size() > 0) {
        final Dialog dialog = new Dialog(context);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.bookmarks_list);

        ListView listView = (ListView) dialog.findViewById(R.id.list);
        listView.setAdapter(new BookmarkAdapter(context, bookmarks));
        listView.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                BookmarkInfo bookmark = (BookmarkInfo) parent.getAdapter().getItem(position);
                Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(bookmark.getUrl()));
                context.startActivity(browserIntent);
                context.showCover(false);
                dialog.dismiss();
                Analytics.logEvent(Analytics.INVOKE_BOOKMARK);
            }

        });
        listView.setDrawingCacheEnabled(true);
        listView.setOnKeyListener(onKeyListener);
        dialog.setOnDismissListener(new OnDismissListener() {

            @Override
            public void onDismiss(DialogInterface dialog) {
                context.showCover(false);
            }

        });
        context.showCover(true);
        dialog.show();
        Analytics.logEvent(Analytics.DIALOG_BOOKMARKS);
    } else {
        displayAlert(context, context.getString(R.string.dialog_no_browser_history));
    }
}

From source file:com.hacktx.android.activities.EventDetailActivity.java

private void setupCards() {
    final CardView rateEventCard = (CardView) findViewById(R.id.rateEventCard);

    View.OnClickListener feedbackOnClickListener = new View.OnClickListener() {
        @Override/* w  w w . j  a v a  2s  .  c o m*/
        public void onClick(View v) {
            if (!UserStateStore.getFeedbackSubmitted(EventDetailActivity.this, event.getId())) {
                final Dialog dialog = new Dialog(EventDetailActivity.this);
                dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                dialog.setContentView(R.layout.dialog_feedback);
                WindowManager.LayoutParams params = dialog.getWindow().getAttributes();
                params.width = WindowManager.LayoutParams.MATCH_PARENT;
                dialog.getWindow().setAttributes(params);
                dialog.show();

                final RatingBar ratingBar = (RatingBar) dialog.findViewById(R.id.feedbackDialogRatingBar);
                dialog.findViewById(R.id.feedbackDialogCancel).setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        mMetricsManager.logEvent(R.string.analytics_event_feedback_cancel, null);
                        dialog.dismiss();
                    }
                });
                dialog.findViewById(R.id.feedbackDialogSubmit).setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        HackTxService hackTxService = HackTxClient.getInstance().getApiService();
                        hackTxService.sendFeedback(event.getId(), (int) ratingBar.getRating(),
                                new Callback<EventFeedback>() {
                                    @Override
                                    public void success(EventFeedback feedback, Response response) {
                                        mMetricsManager.logEvent(R.string.analytics_event_feedback_submit,
                                                null);
                                        UserStateStore.setFeedbackSubmitted(EventDetailActivity.this,
                                                event.getId(), true);
                                        findViewById(R.id.rateEventCard).setVisibility(View.GONE);
                                        dialog.dismiss();
                                        Snackbar.make(findViewById(android.R.id.content),
                                                R.string.event_feedback_submitted, Snackbar.LENGTH_SHORT)
                                                .show();
                                    }

                                    @Override
                                    public void failure(RetrofitError error) {
                                        Log.e("EventDetailActivity",
                                                "Error when submitting feedback: " + error.getMessage());
                                        dialog.dismiss();
                                        Snackbar.make(findViewById(android.R.id.content),
                                                R.string.event_feedback_failed, Snackbar.LENGTH_SHORT).show();
                                    }
                                });
                    }
                });
            } else {
                mMetricsManager.logEvent(R.string.analytics_event_feedback_already_submitted, null);
                Snackbar.make(findViewById(android.R.id.content), R.string.event_feedback_already_submitted,
                        Snackbar.LENGTH_SHORT).show();
            }
        }
    };

    if (shouldShowFeedbackCard()) {
        findViewById(R.id.rateEventCardOk).setOnClickListener(feedbackOnClickListener);

        findViewById(R.id.rateEventCardNoThanks).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mMetricsManager.logEvent(R.string.analytics_event_feedback_no_thanks, null);
                UserStateStore.setFeedbackIgnored(EventDetailActivity.this, event.getId(), true);
                rateEventCard.setVisibility(View.GONE);
            }
        });
    } else {
        findViewById(R.id.rateEventCard).setVisibility(View.GONE);
    }

    if (!mConfigManager.getValue(ConfigParam.EVENT_FEEDBACK)) {
        findViewById(R.id.rateEventCard).setVisibility(View.GONE);
    }
}