Example usage for android.app Dialog Dialog

List of usage examples for android.app Dialog Dialog

Introduction

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

Prototype

public Dialog(@NonNull Context context) 

Source Link

Document

Creates a dialog window that uses the default dialog theme.

Usage

From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java

public void promptPasswordForExport(final String fpath, final NotifyEvent ntfy_pswd) {

    // ??// ww w . j  a v  a 2  s.  c  o  m
    final Dialog dialog = new Dialog(mContext);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setContentView(R.layout.password_input_dlg);

    LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.password_input_dlg_view);
    ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color);

    final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.password_input_title_view);
    final TextView title = (TextView) dialog.findViewById(R.id.password_input_title);
    title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color);
    title.setTextColor(mGp.themeColorList.text_color_dialog_title);

    final TextView dlg_msg = (TextView) dialog.findViewById(R.id.password_input_msg);
    final CheckedTextView ctv_protect = (CheckedTextView) dialog.findViewById(R.id.password_input_ctv_protect);
    final Button btn_ok = (Button) dialog.findViewById(R.id.password_input_ok_btn);
    final Button btn_cancel = (Button) dialog.findViewById(R.id.password_input_cancel_btn);
    final EditText et_password = (EditText) dialog.findViewById(R.id.password_input_password);
    final EditText et_confirm = (EditText) dialog.findViewById(R.id.password_input_password_confirm);

    dlg_msg.setText(mContext.getString(R.string.msgs_export_import_pswd_specify_password));

    CommonDialog.setDlgBoxSizeCompact(dialog);

    ctv_protect.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            ctv_protect.toggle();
            boolean isChecked = ctv_protect.isChecked();
            setPasswordFieldVisibility(isChecked, et_password, et_confirm, btn_ok, dlg_msg);
        }
    });

    ctv_protect.setChecked(mGp.settingExportedProfileEncryptRequired);
    setPasswordFieldVisibility(mGp.settingExportedProfileEncryptRequired, et_password, et_confirm, btn_ok,
            dlg_msg);

    et_password.setEnabled(true);
    et_confirm.setEnabled(false);
    et_password.addTextChangedListener(new TextWatcher() {
        @Override
        public void afterTextChanged(Editable arg0) {
            btn_ok.setEnabled(false);
            setPasswordPromptOkButton(et_password, et_confirm, btn_ok, dlg_msg);
        }

        @Override
        public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
        }

        @Override
        public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
        }
    });

    et_confirm.addTextChangedListener(new TextWatcher() {
        @Override
        public void afterTextChanged(Editable arg0) {
            btn_ok.setEnabled(false);
            setPasswordPromptOkButton(et_password, et_confirm, btn_ok, dlg_msg);
        }

        @Override
        public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
        }

        @Override
        public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
        }
    });

    //OK button
    btn_ok.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            String passwd = et_password.getText().toString();
            if ((ctv_protect.isChecked() && !mGp.settingExportedProfileEncryptRequired)
                    || (!ctv_protect.isChecked() && mGp.settingExportedProfileEncryptRequired)) {
                mGp.settingExportedProfileEncryptRequired = ctv_protect.isChecked();
                SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
                prefs.edit().putBoolean(mContext.getString(R.string.settings_exported_profile_encryption),
                        ctv_protect.isChecked()).commit();
            }
            if (!ctv_protect.isChecked()) {
                dialog.dismiss();
                ntfy_pswd.notifyToListener(true, new Object[] { "" });
            } else {
                if (!passwd.equals(et_confirm.getText().toString())) {
                    //Unmatch
                    dlg_msg.setText(
                            mContext.getString(R.string.msgs_export_import_pswd_unmatched_confirm_pswd));
                } else {
                    dialog.dismiss();
                    ntfy_pswd.notifyToListener(true, new Object[] { passwd });
                }
            }
        }
    });
    // CANCEL?
    btn_cancel.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dialog.dismiss();
            ntfy_pswd.notifyToListener(false, null);
        }
    });
    // Cancel?
    dialog.setOnCancelListener(new Dialog.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface arg0) {
            btn_cancel.performClick();
        }
    });
    //      dialog.setCancelable(false);
    //      dialog.setOnKeyListener(new DialogOnKeyListener(context));
    dialog.show();

}

From source file:co.taqat.call.StatusFragment.java

public void showZRTPDialog(final LinphoneCall call) {
    if (getActivity() == null) {
        Log.w("Can't display ZRTP popup, no Activity");
        return;/*w w w.ja  v a 2s  .c o  m*/
    }

    if (ZRTPdialog == null || !ZRTPdialog.isShowing()) {
        ZRTPdialog = new Dialog(getActivity());
        ZRTPdialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        Drawable d = new ColorDrawable(ContextCompat.getColor(getActivity(), R.color.colorC));
        d.setAlpha(200);
        ZRTPdialog.setContentView(R.layout.dialog);
        ZRTPdialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
                WindowManager.LayoutParams.MATCH_PARENT);
        ZRTPdialog.getWindow().setBackgroundDrawable(d);

        TextView customText = (TextView) ZRTPdialog.findViewById(R.id.customText);
        String newText = getString(R.string.zrtp_dialog).replace("%s", call.getAuthenticationToken());
        customText.setText(newText);
        Button delete = (Button) ZRTPdialog.findViewById(R.id.delete_button);
        delete.setText(R.string.accept);
        Button cancel = (Button) ZRTPdialog.findViewById(R.id.cancel);
        cancel.setText(R.string.deny);

        delete.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                call.setAuthenticationTokenVerified(true);
                if (encryption != null) {
                    encryption.setImageResource(R.drawable.security_ok);
                }
                ZRTPdialog.dismiss();
            }
        });

        cancel.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                if (call != null) {
                    call.setAuthenticationTokenVerified(false);
                    if (encryption != null) {
                        encryption.setImageResource(R.drawable.security_ko);
                    }
                }
                ZRTPdialog.dismiss();
            }
        });
        ZRTPdialog.show();
    }
}

From source file:com.zen.androidhtmleditor.AHEActivity.java

@SuppressLint("NewApi")
@Override//from   w  w  w  . j ava2  s  . com
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
            WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    setContentView(R.layout.main);
    SystemBarTintManager tintManager = new SystemBarTintManager(this);
    // enable status bar tint
    tintManager.setStatusBarTintEnabled(true);
    tintManager.setTintColor(Color.parseColor("#4acab4"));

    SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
    Settings.init(settings);
    //Uncomment this for non Market installs. This will allow version checking.
    //new Version(this,getVersionName(this,DeveloperToolsActivity.class),"http://androidhtmleditor.com/version.php").execute();
    deviceId = Secure.getString(this.getContentResolver(), Secure.ANDROID_ID);
    getOverflowMenu();
    getActionBar().setIcon(R.drawable.icon_white);

    tabactivity = (TabActivity) this;
    tabHost = tabactivity.getTabHost();
    hsv = (HorizontalScrollView) tabactivity.findViewById(R.id.topmenu);

    mLicenseCheckerCallback = new MyLicenseCheckerCallback();
    mChecker = new LicenseChecker(this,
            new ServerManagedPolicy(this, new AESObfuscator(SALT, getPackageName(), deviceId)),
            BASE64_PUBLIC_KEY // Your public licensing key.
    );

    mHandler = new Handler();
    // doCheck();

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (LinearLayout) findViewById(R.id.l1);

    // ActionBarDrawerToggle ties together the the proper interactions
    // between the sliding drawer and the action bar app icon
    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
            R.string.drawer_open, /* "open drawer" description for accessibility */
            R.string.drawer_close /* "close drawer" description for accessibility */
    ) {
        public void onDrawerClosed(View view) {
            getActionBar().setTitle("File(s)");
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }

        public void onDrawerOpened(View drawerView) {
            getActionBar().setTitle("Server");
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    Button button1 = (Button) findViewById(R.id.button1);

    button1.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            onButtonClickEvent(v);
        }
    });
    Button disconnect_button = (Button) findViewById(R.id.disconnect_button);

    disconnect_button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            disconnect();
        }
    });

    /* Button button2 = (Button)findViewById(R.id.button2);
     button2.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
               
       hsv.setVisibility(View.GONE);
       v.setVisibility(View.GONE);
       RelativeLayout rl = (RelativeLayout)v.getParent();
       Button button1 = (Button)findViewById(R.id.button1);
       button1.setVisibility(View.VISIBLE);
       Button button3 = (Button)findViewById(R.id.button3);
       button3.setVisibility(View.VISIBLE);
               
       ImageView logo = (ImageView)findViewById(R.id.logo);
       logo.setVisibility(View.VISIBLE);
               
       TextView slogan = (TextView)findViewById(R.id.appSlogan);
       slogan.setVisibility(View.VISIBLE);
               
       ScrollView frontLayout = (ScrollView)findViewById(R.id.front);
       frontLayout.setVisibility(View.VISIBLE);
               
       TextView appTitle = (TextView)findViewById(R.id.appTitle);
       appTitle.setVisibility(View.VISIBLE);
               
       Button backButton = (Button)rl.findViewById(R.id.backButton);
       backButton.setVisibility(View.GONE);
       arrayAdapter.clear();
       arrayAdapter.notifyDataSetChanged();
       TextView pathInfo = (TextView)rl.findViewById(R.id.path);
        pathInfo.setText("");
        folderPath = "";
       //new MyFetchTask("zenstudio.com.au", "zenstudi", ".-x$%Wmd5b#C","folder",folderPath).execute();
        connectedTo = -1;
                
                
                
                
        Toast.makeText(AHEActivity.this, "Disconnected", Toast.LENGTH_SHORT).show();
    }
     });*/

    Button button3 = (Button) findViewById(R.id.button3);
    button3.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent SettingsIntent = new Intent(AHEActivity.this, Settings.class);
            startActivity(SettingsIntent);
        }
    });

    /*Button backButton = (Button)findViewById(R.id.backButton);
    backButton.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
       String[] pathBits = folderPath.split("/");
       folderPath = "";
       for(int i=0;i<pathBits.length-1;i++){
          folderPath += pathBits[i]+"/";
       }
       arrayAdapter.clear();
               
       //connectedTo
       SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
        String currentServers = settings.getString("Accounts", "");
        if(currentServers.equals("")){}else{
       Gson gson = new Gson();
        SearchResponse response = gson.fromJson(currentServers, SearchResponse.class);
        List<Result> results = response.data;
        Result l = results.get(connectedTo);
                
       if(l.serverName!="" && l.userName!="" && l.port.trim()!=""){
               
          if(l.sftp.equals("0") || l.sftp.equals("1") || l.sftp.equals("2")){
             new MyFetchTask(l.serverName, l.userName, l.passWord,"folder",folderPath,l.sftp,l.port).execute();
          }else if(l.sftp.equals("3")){
             new FetchSSLTask(l.serverName, l.userName, l.passWord,"folder",folderPath,l.sftp,l.port).execute();
          }
               
       }
                
        }
    }
    });*/

    TextView pathInfo = (TextView) findViewById(R.id.path);
    pathInfo.setText(folderPath);

    lstTest = (ListView) findViewById(R.id.list);
    // lstTest.setDividerHeight(10);
    lstTest.setPadding(0, 5, 0, 5);
    alrts = new ArrayList<String[]>();
    arrayAdapter = new FetchAdapter(AHEActivity.this, R.layout.listitems, alrts);
    lstTest.setAdapter(arrayAdapter);

    lstTest.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        public boolean onItemLongClick(AdapterView<?> av, View v, int pos, long id) {
            final View d = v;
            final CharSequence[] items = { "Delete", "Rename", "Chmod", "Download" };

            TextView t = (TextView) v.findViewById(R.id.fileFolderName);
            final String oldName = t.getText().toString();

            final int position = pos;

            AlertDialog.Builder builder = new AlertDialog.Builder(AHEActivity.this);
            builder.setTitle("Choose Action");
            builder.setItems(items, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int item) {

                    if (item == 0) {
                        AlertDialog.Builder dbuilder = new AlertDialog.Builder(AHEActivity.this);
                        dbuilder.setMessage("Delete this file?").setCancelable(false)
                                .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int id) {

                                        deleteFile(d);
                                        dialog.cancel();
                                    }
                                }).setNegativeButton("No", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int id) {
                                        dialog.cancel();

                                    }
                                });
                        AlertDialog dalert = dbuilder.create();
                        dalert.show();

                    } else if (item == 1) {

                        final Dialog renameDialog = new Dialog(AHEActivity.this);
                        renameDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                        renameDialog.setContentView(R.layout.renamediag);

                        renameDialog.setCancelable(true);

                        Button closeServer = (Button) renameDialog.findViewById(R.id.closeServer);
                        closeServer.setOnClickListener(new OnClickListener() {
                            public void onClick(View v) {

                                renameDialog.cancel();
                            }
                        });

                        Button saveServer = (Button) renameDialog.findViewById(R.id.saveServer);
                        saveServer.setOnClickListener(new OnClickListener() {
                            public void onClick(View v) {

                                EditText themeUrl = (EditText) renameDialog.findViewById(R.id.themeLink);
                                String newName = themeUrl.getText().toString();
                                //connectedTo
                                SharedPreferences settings = getSharedPreferences(PREFS_NAME,
                                        Context.MODE_PRIVATE);
                                String currentServers = settings.getString("Accounts", "");
                                if (currentServers.equals("")) {
                                } else {
                                    Gson gson = new Gson();
                                    SearchResponse response = gson.fromJson(currentServers,
                                            SearchResponse.class);
                                    List<Result> results = response.data;
                                    Result l = results.get(connectedTo);

                                    if (l.serverName != "" && l.userName != "" && l.port.trim() != "") {

                                        new RenameTask(l.serverName, l.userName, l.passWord, oldName, newName,
                                                folderPath, l.sftp, l.port, position).execute();

                                        renameDialog.cancel();
                                    }
                                }
                            }
                        });
                        renameDialog.show();
                    } else if (item == 2) {

                        final Dialog chmodDialog = new Dialog(AHEActivity.this);
                        chmodDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                        chmodDialog.setContentView(R.layout.chmoddiag);

                        chmodDialog.setCancelable(true);

                        Button closeServer = (Button) chmodDialog.findViewById(R.id.closeServer);
                        closeServer.setOnClickListener(new OnClickListener() {
                            public void onClick(View v) {

                                chmodDialog.cancel();
                            }
                        });

                        Button saveServer = (Button) chmodDialog.findViewById(R.id.saveServer);
                        saveServer.setOnClickListener(new OnClickListener() {
                            public void onClick(View v) {

                                EditText themeUrl = (EditText) chmodDialog.findViewById(R.id.themeLink);
                                String perms = themeUrl.getText().toString();
                                //connectedTo
                                SharedPreferences settings = getSharedPreferences(PREFS_NAME,
                                        Context.MODE_PRIVATE);
                                String currentServers = settings.getString("Accounts", "");
                                if (currentServers.equals("")) {
                                } else {
                                    Gson gson = new Gson();
                                    SearchResponse response = gson.fromJson(currentServers,
                                            SearchResponse.class);
                                    List<Result> results = response.data;
                                    Result l = results.get(connectedTo);

                                    if (l.serverName != "" && l.userName != "" && l.port.trim() != "") {

                                        if (l.sftp.equals("0") || l.sftp.equals("1") || l.sftp.equals("2")) {
                                            new ChmodTask(l.serverName, l.userName, l.passWord, oldName, perms,
                                                    folderPath, l.sftp, l.port, position).execute();
                                        } else {
                                            Toast.makeText(AHEActivity.this,
                                                    "CHMOD could not be performed on your server via sftp",
                                                    Toast.LENGTH_SHORT).show();
                                        }
                                        chmodDialog.cancel();
                                    }
                                }
                            }
                        });
                        chmodDialog.show();

                    } else if (item == 3) {

                        //Make new class to download a file
                        SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
                        String currentServers = settings.getString("Accounts", "");
                        if (currentServers.equals("")) {
                        } else {
                            Gson gson = new Gson();
                            SearchResponse response = gson.fromJson(currentServers, SearchResponse.class);
                            List<Result> results = response.data;
                            Result l = results.get(connectedTo);

                            if (l.serverName != "" && l.userName != "" && l.port.trim() != "") {

                                if (l.sftp.equals("0") || l.sftp.equals("1") || l.sftp.equals("2")) {
                                    new DlTask(l.serverName, l.userName, l.passWord, oldName, l.sftp, l.port)
                                            .execute();

                                }
                            }
                        }
                    }

                    //Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();

                }
            });
            AlertDialog alert = builder.create();
            alert.show();
            return true;

        }
    });

    lstTest.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> av, View v, int pos, long id) {

            loadFileFolder(v);

        }
    });

}

From source file:com.BeatYourRecord.SubmitActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    final Dialog dialog = new Dialog(SubmitActivity.this);

    switch (id) {
    case 10:/*from   www.jav a2  s .c  o  m*/
        // Create out AlterDialog
        /*  Builder builder = new AlertDialog.Builder(this);
          dialog4.setContentView(R.layout.legal1);
          builder.setMessage();
          builder.setCancelable(true);
                
          AlertDialog dialog4 = builder.create();
          dialog4.show();
          return super.onCreateDialog(id);*/

        dialog.setContentView(R.layout.okbutton);

        TextView legalText1 = (TextView) dialog.findViewById(R.id.legal);

        legalText1.setText("Please Login using your email and password.");

        dialog.findViewById(R.id.agree).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.cancel();
            }

        });
        break;
    case 11:

        dialog.setContentView(R.layout.okbutton);
        dialog.setTitle("Note");
        TextView legalText12 = (TextView) dialog.findViewById(R.id.legal);

        legalText12.setText(
                "You are not connected to wifi. Upload times on 3g/4g can be long. To upload later click ok and then back");

        dialog.findViewById(R.id.agree).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.cancel();
            }

        });
        break;

    //break;
    case DIALOG_LEGAL:
        //dialog.setTitle("Terms of Service");
        dialog.setContentView(R.layout.legal);

        TextView legalText = (TextView) dialog.findViewById(R.id.legal);

        legalText.setText(Util.readFile(this, R.raw.legal).toString());

        dialog.findViewById(R.id.agree).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.cancel();
                ///////////////////////////////////////////////////////////////////////
                File f = new File("/data/data/com.BeatYourRecord/shared_prefs/Tester15.xml");
                if (f.exists() && logout.equals("yes") == false) {
                    Log.v("androids a bitch", "das");
                } else {
                    iregistered();
                }

                getAuthTokenWithPermission(youTubeName);
            }
        });
        dialog.findViewById(R.id.notagree).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.cancel();
            }
        });

        break;
    }

    return dialog;
}

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

/**
 * Display the list of browser bookmarks. Allow user to load bookmarked web
 * site./*ww  w .j  a  v  a 2s  .c  o m*/
 * 
 * @param context
 */
public static void displayBookmarks(final Launcher context) {
    final ArrayList<BookmarkInfo> bookmarks = loadBookmarks(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);
        Collections.sort(bookmarks, new Comparator<BookmarkInfo>() {

            @Override
            public int compare(BookmarkInfo lhs, BookmarkInfo rhs) {
                return lhs.getTitle().toLowerCase().compareTo(rhs.getTitle().toLowerCase());
            }

        });
        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_bookmarks));
    }
}

From source file:com.sentaroh.android.Utilities.Dialog.FileSelectDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (mDebugEnable)
        Log.v(APPLICATION_TAG, "onCreateDialog");
    mDialog = new Dialog(getActivity());//, MiscUtil.getAppTheme(getActivity()));
    mDialog.setCanceledOnTouchOutside(false);
    mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

    if (!mTerminateRequired) {
        initViewWidget();//from w  w  w.j  ava 2s  . c o  m
        restoreViewContents();
    }
    //       setShowsDialog(true);

    return mDialog;
}

From source file:de.mkrtchyan.recoverytools.RecoveryTools.java

/**
 * Buttons on FlashRecovery and FlashKernel Dialog
 */// ww  w.  j  a v a 2 s . co  m
public void FlashSupportedRecovery(View view) {
    fRECOVERY = null;
    final File path;
    ArrayList<String> Versions;
    if (!mDevice.downloadUtils(mContext)) {
        /**
         * If there files be needed to flash download it and listing device specified recovery
         * file for example recovery-clockwork-touch-6.0.3.1-grouper.img(read out from IMG_SUMS)
         */
        String SYSTEM = view.getTag().toString();
        if (SYSTEM.equals("clockwork")) {
            Versions = mDevice.getCWMVersions();
            path = PathToCWM;
        } else if (SYSTEM.equals("twrp")) {
            Versions = mDevice.getTWRPVersions();
            path = PathToTWRP;
        } else if (SYSTEM.equals("philz")) {
            Versions = mDevice.getPHILZVersions();
            path = PathToPhilz;
        } else {
            return;
        }

        final Dialog recoveries = new Dialog(mContext);
        recoveries.setTitle(SYSTEM);
        ListView lv = new ListView(mContext);
        recoveries.setContentView(lv);
        lv.setAdapter(new ArrayAdapter<String>(mContext, android.R.layout.simple_list_item_1, Versions));
        recoveries.show();
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

                recoveries.dismiss();
                final String fileName = ((TextView) view).getText().toString();

                if (fileName != null) {
                    fRECOVERY = new File(path, fileName);

                    if (!fRECOVERY.exists()) {
                        Downloader RecoveryDownloader = new Downloader(mContext, RECOVERY_HOST_URL, fRECOVERY,
                                rRecoveryFlasher);
                        RecoveryDownloader.setRetry(true);
                        RecoveryDownloader.setAskBeforeDownload(true);
                        RecoveryDownloader.setChecksumFile(RecoveryCollectionFile);
                        RecoveryDownloader.ask();
                    } else {
                        rRecoveryFlasher.run();
                    }
                }
            }
        });
    }
}

From source file:com.corporatetaxi.TaxiArrived_Acitivity.java

private void initiatePopupWindowcanceltaxi() {
    try {//from   w  w w .  ja v  a 2s.com
        dialog = new Dialog(TaxiArrived_Acitivity.this);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // before
        dialog.setContentView(R.layout.canceltaxi_popup);

        cross = (ImageButton) dialog.findViewById(R.id.cross);
        cross.setOnClickListener(cancle_btn_click_listener);
        rd1 = (RadioButton) dialog.findViewById(R.id.radioButton);
        rd2 = (RadioButton) dialog.findViewById(R.id.radioButton2);
        rd3 = (RadioButton) dialog.findViewById(R.id.radioButton3);
        btn_confirm = (Button) dialog.findViewById(R.id.btn_acceptor);
        TextView txt = (TextView) dialog.findViewById(R.id.textView);
        textheader = (TextView) dialog.findViewById(R.id.popup_text);
        Typeface tf = Typeface.createFromAsset(this.getAssets(), "Montserrat-Regular.ttf");
        rd1.setTypeface(tf);
        rd2.setTypeface(tf);
        rd3.setTypeface(tf);
        btn_confirm.setTypeface(tf);
        txt.setTypeface(tf);
        textheader.setTypeface(tf);
        btn_confirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (rd1.isChecked()) {
                    canceltaxirequest = getResources().getString(R.string.prompt_cancel_reason_one);

                } else if (rd2.isChecked()) {
                    canceltaxirequest = getResources().getString(R.string.prompt_cancel_reason_two);

                } else if (rd3.isChecked()) {
                    canceltaxirequest = getResources().getString(R.string.prompt_cancel_reason_three);

                }

                Allbeans allbeans = new Allbeans();

                allbeans.setCanceltaxirequest(canceltaxirequest);

                new CancelTaxiAsynch(allbeans).execute();

            }
        });
        dialog.show();

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.example.android.navigationdrawer.QRCode.java

public void onQR(View v) {
    switch (v.getId()) {
    case R.id.button1:
        String qrInputText = MidiFile.readString;

        //Find screen size
        WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE);
        Display display = manager.getDefaultDisplay();
        Point point = new Point();
        display.getSize(point);/*from w w  w.  ja v a  2  s .c  o m*/
        int width = point.x;
        int height = point.y;
        int smallerDimension = width < height ? width : height;
        smallerDimension = smallerDimension * 3 / 4;
        //Encode with a QR Code image
        QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(qrInputText, null, Contents.Type.TEXT,
                BarcodeFormat.QR_CODE.toString(), smallerDimension);
        try {
            Bitmap bitmap = qrCodeEncoder.encodeAsBitmap();
            ImageView myImage = (ImageView) findViewById(R.id.imageView1);
            myImage.setImageBitmap(bitmap);

            // Get screen size
            Display display1 = this.getWindowManager().getDefaultDisplay();
            Point size = new Point();
            display1.getSize(size);
            int screenWidth = size.x;
            int screenHeight = size.y;

            // Get target image size
            Bitmap bitmap1 = qrCodeEncoder.encodeAsBitmap();
            int bitmapHeight = bitmap1.getHeight();
            int bitmapWidth = bitmap1.getWidth();

            // Scale the image down to fit perfectly into the screen
            // The value (250 in this case) must be adjusted for phone/tables displays
            while (bitmapHeight > (screenHeight - 250) || bitmapWidth > (screenWidth - 250)) {
                bitmapHeight = bitmapHeight / 2;
                bitmapWidth = bitmapWidth / 2;
            }

            // Create resized bitmap image
            BitmapDrawable resizedBitmap = new BitmapDrawable(this.getResources(),
                    Bitmap.createScaledBitmap(bitmap, bitmapWidth, bitmapHeight, false));

            // Create dialog
            Dialog dialog = new Dialog(this);
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setContentView(R.layout.thumbnail);

            ImageView image = (ImageView) dialog.findViewById(R.id.imageview);

            // !!! Do here setBackground() instead of setImageDrawable() !!! //
            image.setBackground(resizedBitmap);

            // Without this line there is a very small border around the image (1px)
            // In my opinion it looks much better without it, so the choice is up to you.
            dialog.getWindow().setBackgroundDrawable(null);
            dialog.show();

        } catch (WriterException e) {
            e.printStackTrace();
        }
        break;
    }
}

From source file:com.mibr.android.intelligentreminder.INeedToo.java

@Override
public Dialog onCreateDialog(int id) {
    switch (id) {
    case DIALOG_REMINDER_CONTACTS_SERVICE_FAILED_LICENSING:
        AlertDialog.Builder buildersvc = new AlertDialog.Builder(this);
        buildersvc.setMessage(//ww  w  . j  a  va 2 s  . com
                "The Reminder Contact Service add-on that you've got installed is not a licensed version");
        buildersvc.setCancelable(false)
                .setNeutralButton(R.string.msg_cus, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        String[] mailto = { "info@intelligentreminder.com", "" };
                        Intent sendIntent = new Intent(Intent.ACTION_SEND);
                        sendIntent.putExtra(Intent.EXTRA_EMAIL, mailto);
                        sendIntent.putExtra(Intent.EXTRA_SUBJECT, "".toString());
                        sendIntent.putExtra(Intent.EXTRA_TEXT, "".toString());
                        sendIntent.setType("text/plain");
                        startActivity(Intent.createChooser(sendIntent, "Send EMail..."));
                    }
                }).setPositiveButton(R.string.msg_register, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {

                        if (INeedToo.IS_ANDROID_VERSION) {
                            String uri = getString(R.string.indeedtopayforservice);
                            Intent ii3 = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
                            startActivity(ii3);
                        } else {
                            Uri uri = Uri.parse(
                                    "http://www.amazon.com/gp/mas/dl/android?p=com.mibr.android.remindercontacts");
                            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                            startActivity(intent);
                        }

                        isReminderContactsAvailable = true;
                        iDidReminderContacts = false;
                    }
                }).setNegativeButton(R.string.msg_cancel, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                    }
                });
        AlertDialog alert = buildersvc.create();
        return alert;

    case DOING_SAMPLE_NEEDS_DIALOG:
        if (allItems == null) {
            return null;
        }
        dialogDoingSamples = new Dialog(this);
        dialogDoingSamples.setOwnerActivity(this);
        dialogDoingSamples.setContentView(R.layout.ineedvoiceprogress);
        dialogDoingSamples.setTitle("Working ...");
        ((Button) dialogDoingSamples.findViewById(R.id.needvoiceprogress_cancel)).setEnabled(true);
        ((Button) dialogDoingSamples.findViewById(R.id.needvoiceprogress_ok)).setEnabled(false);
        ;
        //         dialogDoingSamples.show();
        ArrayList stuff = new ArrayList();
        stuff.add(dialogDoingSamples);
        stuff.add(getApplicationContext());
        stuff.add(this);
        stuff.add(getLocationManager());
        stuff.add(getDbAdapter());
        stuff.add(allItems.get(whereImAtInAllItems));
        stuff.add(new Integer(1));
        new NeedByVoiceProgress().execute(stuff);
        return dialogDoingSamples;

    case DIALOG_SAMPLES:
        Dialog aDialog = null;
        AlertDialog.Builder builder2;
        LayoutInflater inflater2 = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
        View layout2 = inflater2.inflate(R.layout.ineedsamples, (ViewGroup) findViewById(R.id.hijklmnop));
        builder2 = new AlertDialog.Builder(this);
        builder2.setView(layout2);
        builder2.setTitle("Build Sample Data Set");
        builder2.setPositiveButton("Okay", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                allItems = new ArrayList<ArrayList<String>>();
                Boolean doit = false;
                StringBuilder sb = new StringBuilder();
                StringBuilder sb2 = new StringBuilder();
                StringBuilder sb3 = new StringBuilder();
                int cnt = 0;
                Boolean dw = false;
                ArrayList<String> jdmatchesSS = null;
                ;
                sb.append("I need Print Cartridges description HP 28 and 48 ");
                if (mWalmart != null && mWalmart.isChecked()) {
                    sb.append(" location Walmart ");
                    dw = true;
                }
                if (mWalgreens != null && mWalgreens.isChecked()) {
                    sb.append(" location Walgreens ");
                    dw = true;
                }
                if (dw) { // they checked something
                    doit = true;
                    jdmatchesSS = new ArrayList<String>();
                    jdmatchesSS.add(sb.toString());
                    allItems.add(jdmatchesSS);
                    cnt++;
                }
                if (mSevenEleven != null && mSevenEleven.isChecked()) {
                    sb3.append("I need Energy Drink description Red Bull location 7-Eleven ");
                    ArrayList<String> jdmatches = new ArrayList<String>();
                    jdmatches.add(sb3.toString());
                    allItems.add(jdmatches);
                    cnt++;
                    doit = true;
                }

                if (mStarbucks != null && mStarbucks.isChecked()) {
                    sb2.append("I need Coffee description French Roast location Starbucks");
                    ArrayList<String> jdmatches = new ArrayList<String>();
                    jdmatches.add(sb2.toString());
                    allItems.add(jdmatches);
                    cnt++;
                    doit = true;
                }
                if (doit) {
                    whereImAtInAllItems = 0;
                    INeedToo.this.showDialog(DOING_SAMPLE_NEEDS_DIALOG);
                }

            }
        });
        mWalmart = (CheckBox) layout2.findViewById(R.id.BuildWalmart);
        mWalgreens = (CheckBox) layout2.findViewById(R.id.BuildWalgreens);
        mSevenEleven = (CheckBox) layout2.findViewById(R.id.Build7Eleven);
        mStarbucks = (CheckBox) layout2.findViewById(R.id.BuildStarbucks);

        aDialog = builder2.create();
        return aDialog;

    case DIALOG_SPLASH:
        /*
        jdd=new Dialog(mContext);
        jdd.setContentView(R.layout.ineed2splash);
        jdd.setTitle("W E L C O M E");
        */

        AlertDialog.Builder builder;
        LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
        View layout = inflater.inflate(R.layout.ineed2splashv2,
                (ViewGroup) findViewById(R.id.ScrollView01lmnop2));
        builder = new AlertDialog.Builder(this);

        builder.setPositiveButton("Okay", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                if (mWantSample != null) {
                    if (mWantSample.isChecked()) {
                        showDialog(DIALOG_SAMPLES);
                    }
                }
            }
        });
        builder.setTitle("W E L C O M E");
        if (getDbAdapter().thereAreSomeLocationsOnSystem()) {
            LinearLayout ll = (LinearLayout) layout.findViewById(R.id.CreateDefaultValues);
            ll.setVisibility(View.INVISIBLE);
        } else {
            mWantSample = (CheckBox) layout.findViewById(R.id.BuildDefaultValues);
        }
        builder.setView(layout);
        jdd = builder.create();
        //Button butt=(Button)jdd.findViewById(R.id.Button01);
        /*butt.setOnClickListener(new View.OnClickListener() {
                   
           @Override
           public void onClick(View v) {
              jdd.cancel();
           }
        });
        */
        break;
    default:
        return null;
    }
    return jdd;

}