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.memetro.android.MainActivity.java

public void showRecoverPassDialog(final Context context) {

    final Dialog mDialog = new Dialog(context);
    mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    mDialog.setContentView(R.layout.dialog_recover);
    mDialog.setCancelable(true);/*from  ww w.j a  va  2 s .  co  m*/

    final EditText emailText = (EditText) mDialog.findViewById(R.id.email);
    Button sendButton = (Button) mDialog.findViewById(R.id.send);

    sendButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            RecoverPassUtils.recoverPass(context, emailText.getText().toString(), new OAuthHandler() {
                public void onStart() {
                    pdialog.show();
                }

                public void onSuccess() {
                    mDialog.dismiss();
                    MemetroDialog.showDialog(MainActivity.this, null, getString(R.string.recover_ok));
                }

                public void onFailure() {
                    MemetroDialog.showDialog(MainActivity.this, null, getString(R.string.recover_ko));
                }

                public void onFinish() {
                    pdialog.dismiss();
                }
            });
        }
    });

    mDialog.show();
}

From source file:com.wrmndfzzy.atomize.intro.IntroActivity.java

protected void permissionsDialog() {
    final Dialog pDialog = new Dialog(IntroActivity.this);
    pDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    pDialog.setTitle("Missing Permissions");
    pDialog.setContentView(R.layout.intro_permissions_dialog);
    pDialogConfirm = (Button) pDialog.findViewById(R.id.ipDialogConfirm);
    pDialogConfirm.setOnClickListener(new View.OnClickListener() {
        @Override/*from ww w.ja  v a  2s. c  om*/
        public void onClick(View v) {
            pDialog.dismiss();
            IntroActivity.this.finish();
        }
    });
    pDialog.show();
}

From source file:com.ivalentin.margolariak.SettingsLayout.java

private void showDialog(String title, String text) {
    //Create the dialog
    final Dialog dialog = new Dialog(getActivity());

    //Set up dialog window
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.dialog_settings);

    //Set the custom dialog components - text, image and button
    TextView tvTitle = (TextView) dialog.findViewById(R.id.tv_dialog_settings_title);
    WebView wvText = (WebView) dialog.findViewById(R.id.wv_dialog_settings_text);

    if (Build.VERSION.SDK_INT >= 19) {
        wvText.setLayerType(View.LAYER_TYPE_HARDWARE, null);
    } else {/*w  ww. j  ava 2  s  .c om*/
        wvText.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }

    Button btClose = (Button) dialog.findViewById(R.id.bt_dialog_settings_close);

    //Set text
    tvTitle.setText(title);
    wvText.loadDataWithBaseURL(null, text, "text/html", "utf-8", null);

    //Set close button
    btClose.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });

    //Set parameters
    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
    lp.copyFrom(dialog.getWindow().getAttributes());
    lp.width = WindowManager.LayoutParams.MATCH_PARENT;
    lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
    lp.gravity = Gravity.CENTER;
    lp.dimAmount = 0.4f;
    dialog.getWindow().setAttributes(lp);

    //Show dialog
    dialog.show();

}

From source file:de.domjos.schooltools.activities.LearningCardOverviewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.learning_card_overview_activity);
    this.initControls();

    this.cmdLearningCardQueryStart.setOnClickListener(new View.OnClickListener() {
        @Override//w  w  w .  j av a  2s.com
        public void onClick(View v) {
            final LearningCardQueryTraining learningCardQueryTraining = new LearningCardQueryTraining();
            if (cmdLearningCardQueryStart.getText().equals(getString(R.string.learningCard_query))) {
                final Dialog dialog = new Dialog(LearningCardOverviewActivity.this);
                dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                dialog.setContentView(R.layout.learning_card_dialog);
                dialog.setCancelable(true);

                final Spinner spLearningCardQuery = dialog.findViewById(R.id.spLearningCardQueries);
                final ArrayAdapter<LearningCardQuery> learningCardQueries = new ArrayAdapter<>(
                        getApplicationContext(), android.R.layout.simple_spinner_item,
                        MainActivity.globals.getSqLite().getLearningCardQueries(""));
                spLearningCardQuery.setAdapter(learningCardQueries);
                learningCardQueries.notifyDataSetChanged();

                final Button btnStartSop = dialog.findViewById(R.id.cmdStart);
                btnStartSop.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        learningCardQueryTraining.setLearningCardQuery(
                                learningCardQueries.getItem(spLearningCardQuery.getSelectedItemPosition()));
                        learningCardQueryTraining.setID(MainActivity.globals.getSqLite()
                                .insertOrUpdateLearningCardQueryTraining(learningCardQueryTraining));
                        cmdLearningCardQueryStart.setText(getString(R.string.learningCard_query_end));
                        fragmentAdapter.setQuery(learningCardQueryTraining);
                        viewPager.setAdapter(fragmentAdapter);
                        dialog.dismiss();
                    }
                });
                dialog.show();
            } else {
                int wrongCards = 0, rightCards = 0, firstTry = 0, secondTry = 0, thirdTry = 0;
                LearningCardQueryTraining reloadedTraining = MainActivity.globals.getSqLite()
                        .getLearningCardQueryTraining("ID=" + learningCardQueryTraining.getID()).get(0);
                for (LearningCardQueryResult result : reloadedTraining.getResults()) {
                    if (result.isResult1() || result.isResult2() || result.isResult3()) {
                        rightCards++;
                        if (result.isResult1()) {
                            firstTry++;
                        } else if (result.isResult2()) {
                            secondTry++;
                        } else {
                            thirdTry++;
                        }
                    } else {
                        wrongCards++;
                    }
                }
                AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
                        LearningCardOverviewActivity.this);
                alertDialogBuilder.setTitle(R.string.learningCard_result);
                String content = String.format("%s %s%n%s %s%n%s %s%n%s %s%n%s %s%n",
                        getString(R.string.learningCard_result_right), rightCards,
                        getString(R.string.learningCard_result_wrong), wrongCards,
                        getString(R.string.learningCard_result_firstTry), firstTry,
                        getString(R.string.learningCard_result_secondTry), secondTry,
                        getString(R.string.learningCard_result_thirdTry), thirdTry);
                alertDialogBuilder.setMessage(content);
                alertDialogBuilder.create().show();

                cmdLearningCardQueryStart.setText(getString(R.string.learningCard_query));
                fragmentAdapter.setQuery(null);
                viewPager.setAdapter(fragmentAdapter);
            }
        }
    });
}

From source file:com.minerva.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    checkAndRequestPermissions();//from w ww .  j av a  2 s  .  co m

    LOG_TAG = MainActivity.this.getClass().getSimpleName();

    Log.i(LOG_TAG, "Creating application Main Activity...");

    // *** Setting up the Toolbar ***
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    // *** Handling navigation buttons and clicks ***
    BottomNavigationView bottomNavigationVew = (BottomNavigationView) findViewById(R.id.navigation);
    bottomNavigationVew
            .setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
                @Override
                public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                    switch (item.getItemId()) {
                    case R.id.action_camera:
                        Log.i(LOG_TAG, "Accessing Camera Activity...");
                        Intent cameraIntent = new Intent(MainActivity.this, CameraActivity.class);
                        startActivity(cameraIntent);
                        break;
                    case R.id.action_gallery:
                        Log.i(LOG_TAG, "Accessing Gallery Activity...");
                        Intent galleryIntent = new Intent(MainActivity.this, GalleryActivity.class);
                        startActivity(galleryIntent);
                        break;
                    case R.id.action_home:
                        break;
                    }

                    return false;
                }
            });

    // *** Handling first time use ***

    SharedPreferences settings = getSharedPreferences(PREFS_NAME1, 0);

    //if (settings.getBoolean("my_first_time1", false)) {
    //the app is being launched for first time, do something

    // *** First time task ***
    final Dialog alertDialog = new Dialog(this);
    alertDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    alertDialog.setContentView(R.layout.navigation);
    alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    alertDialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.MATCH_PARENT);

    alertDialog.show();

    Button gotIt = (Button) alertDialog.findViewById(R.id.gotIt);
    gotIt.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            alertDialog.dismiss();
        }
    });
    // record the fact that the app has been started at least once
    //  settings.edit().putBoolean("my_first_time", false).commit();
}

From source file:com.cerema.cloud2.ui.dialog.SslUntrustedCertDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Log_OC.d(TAG, "onCreateDialog, savedInstanceState is " + savedInstanceState);
    final Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    return dialog;
}

From source file:com.wrmndfzzy.atomize.intro.IntroActivity.java

protected void applicenseDialog() {
    final Dialog aLDialog = new Dialog(IntroActivity.this);
    aLDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    aLDialog.setTitle("License Agreement");
    aLDialog.setCancelable(false);/* w  ww.j av a 2 s. com*/
    aLDialog.setCanceledOnTouchOutside(false);
    aLDialog.setContentView(R.layout.app_license_dialog);
    WebView lic = (WebView) aLDialog.findViewById(R.id.atomizeLic);
    Button disagree = (Button) aLDialog.findViewById(R.id.alDialogDisagree);
    Button agree = (Button) aLDialog.findViewById(R.id.alDialogAgree);
    lic.getSettings().setUseWideViewPort(true);
    lic.loadUrl("file:///android_asset/atomizeLicense.html");
    disagree.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            aLDialog.dismiss();
            SharedPreferences.Editor e = getPrefs.edit();
            e.putBoolean("agreedToLicense", false);
            e.apply();
            Intent homeIntent = new Intent(Intent.ACTION_MAIN);
            homeIntent.addCategory(Intent.CATEGORY_HOME);
            homeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(homeIntent);
            IntroActivity.this.finish();
            MainActivity.getInstance().finish();
        }
    });
    agree.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            SharedPreferences.Editor e = getPrefs.edit();
            e.putBoolean("agreedToLicense", true);
            e.apply();
            aLDialog.dismiss();
        }
    });
    aLDialog.show();
}

From source file:com.tgaubert.blefinder.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    if (id == R.id.action_reset) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.activity_main_reset_title);
        builder.setMessage(R.string.activity_main_reset_text);
        builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
            @Override//from www.ja  v  a2 s .co  m
            public void onClick(DialogInterface dialog, int which) {
                BeaconIO.getSeenBeacons().clear();
                Snackbar.make(findViewById(R.id.floating_btn), R.string.activity_main_reset_done,
                        Snackbar.LENGTH_LONG).show();
            }
        });
        builder.setNegativeButton(R.string.no, null);
        builder.show();
    }

    if (id == R.id.action_about) {
        final Dialog dialog = new Dialog(this);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.dialog_about);
        WindowManager.LayoutParams params = dialog.getWindow().getAttributes();
        params.width = WindowManager.LayoutParams.MATCH_PARENT;
        dialog.getWindow().setAttributes(params);
        dialog.show();

        PackageInfo pInfo = null;
        try {
            pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }

        if (pInfo != null)
            ((TextView) dialog.findViewById(R.id.appVersion)).setText(pInfo.versionName);

        dialog.findViewById(R.id.dialogLicenses).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();

                final Dialog licenseDialog = new Dialog(v.getContext());
                licenseDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                licenseDialog.setContentView(R.layout.dialog_licenses);
                WindowManager.LayoutParams licenseParams = licenseDialog.getWindow().getAttributes();
                licenseParams.width = WindowManager.LayoutParams.MATCH_PARENT;
                licenseDialog.getWindow().setAttributes(licenseParams);
                licenseDialog.show();

                String licenses = "<h3>android-beacon-library</h3>" + "<p>Copyright 2014 Radius Networks</p>\n"
                        + "\n" + "   <p>Licensed under the Apache License, Version 2.0 (the \"License\");\n"
                        + "   you may not use this file except in compliance with the License.\n"
                        + "   You may obtain a copy of the License at</p>\n" + "\n"
                        + "       <p>http://www.apache.org/licenses/LICENSE-2.0</p>\n" + "\n"
                        + "   <p>Unless required by applicable law or agreed to in writing, software\n"
                        + "   distributed under the License is distributed on an \"AS IS\" BASIS,\n"
                        + "   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"
                        + "   See the License for the specific language governing permissions and\n"
                        + "   limitations under the License.</p>" + "<h3>BottomSheet</h3>"
                        + "<p>Copyright 2011, 2015 Kai Liao</p>\n" + "\n"
                        + "<p>Licensed under the Apache License, Version 2.0 (the \"License\");\n"
                        + "you may not use this file except in compliance with the License.\n"
                        + "You may obtain a copy of the License at</p>\n" + "\n"
                        + "   <p>http://www.apache.org/licenses/LICENSE-2.0</p>\n" + "\n"
                        + "<p>Unless required by applicable law or agreed to in writing, software\n"
                        + "distributed under the License is distributed on an \"AS IS\" BASIS,\n"
                        + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"
                        + "See the License for the specific language governing permissions and\n"
                        + "limitations under the License.</p>";

                ((TextView) licenseDialog.findViewById(R.id.dialogText)).setText(Html.fromHtml(licenses));

                licenseDialog.findViewById(R.id.licenseOk).setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        licenseDialog.dismiss();
                    }
                });
            }
        });

        return true;
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.procleus.brime.ui.LabelsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    ((MainActivity) getActivity()).setActionBarTitle("Labels");
    ((MainActivity) getActivity()).showFloatingActionButton(true);
    final View v = inflater.inflate(R.layout.labels_gragment, container, false);
    final NotesDbHelperOld tn = new NotesDbHelperOld(getActivity());

    labelsRetrieved = new ArrayList<String>();
    labelsRetrieved = tn.retrieveLabel();

    listView = (ListView) v.findViewById(R.id.listLabel);
    final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getContext(),
            android.R.layout.simple_list_item_1, labelsRetrieved);
    listView.setAdapter(arrayAdapter);//from w w w .j  a v  a2  s .  c o  m
    ImageButton addLabelBtn = (ImageButton) v.findViewById(R.id.addLabelBtn);

    addLabelBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            addLabelFunc(v, tn);
        }
    });

    /*/WORK OF LONG ITEM CLICK LISTENER*/

    listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(final AdapterView<?> parent, View view, final int position, long id) {

            final Dialog dialog = new Dialog(getContext());
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
            dialog.setCancelable(false);
            dialog.setContentView(R.layout.dialog_label);
            dialog.show();

            final Button negative = (Button) dialog.findViewById(R.id.btn_no_label);
            final Button positive = (Button) dialog.findViewById(R.id.btn_yes_label);

            negative.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    dialog.dismiss();

                }
            });

            positive.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    Log.i("brinjal", "Yes");

                    tn.deleteTextNote(String.valueOf(parent.getItemAtPosition(position)));
                    final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getContext(),
                            android.R.layout.simple_list_item_1, labelsRetrieved);
                    listView.setAdapter(arrayAdapter);
                    dialog.dismiss();

                }

            });

            return true;

        }
    });

    return v;
}

From source file:com.procleus.brime.ui.LabelsFragment.java

@Override
public void onResume() {
    super.onResume();
    NotesDbHelperOld tn = new NotesDbHelperOld(getContext());
    labelsRetrieved = tn.retrieveLabel();
    listView = (ListView) getView().findViewById(R.id.listLabel);
    final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getContext(),
            android.R.layout.simple_list_item_1, labelsRetrieved);
    listView.setAdapter(arrayAdapter);/*from ww w  . ja v a2s.  c  om*/

    listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(final AdapterView<?> parent, View view, final int position, long id) {

            final Dialog dialog = new Dialog(getContext());
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
            dialog.setCancelable(false);
            dialog.setContentView(R.layout.dialog_label);
            dialog.show();

            final Button negative = (Button) dialog.findViewById(R.id.btn_no_label);
            final Button positive = (Button) dialog.findViewById(R.id.btn_yes_label);

            /*/This is Database Spinner Retreival*/
            /* Spinner getting Data from dataBase*/

            negative.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    dialog.dismiss();

                }
            });

            positive.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    Log.i("brinjalResume", "Yes");

                    NotesDbHelperOld tn = new NotesDbHelperOld(getActivity());
                    tn.deleteTextNote(String.valueOf(parent.getItemAtPosition(position)));
                    labelsRetrieved = tn.retrieveLabel();
                    final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getContext(),
                            android.R.layout.simple_list_item_1, labelsRetrieved);
                    listView.setAdapter(arrayAdapter);
                    dialog.dismiss();
                }

            });

            return true;

        }
    });

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            Toast.makeText(getActivity(),
                    "Inside in label" + ":" + String.valueOf(parent.getItemAtPosition(position)),
                    Toast.LENGTH_SHORT).show();
            Intent i = new Intent(getActivity(), LabelOpenActivity.class);
            i.putExtra("label", String.valueOf(parent.getItemAtPosition(position)));
            startActivity(i);

        }
    });

}