Example usage for android.app Dialog setContentView

List of usage examples for android.app Dialog setContentView

Introduction

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

Prototype

public void setContentView(@NonNull View view) 

Source Link

Document

Set the screen content to an explicit view.

Usage

From source file:com.nanostuffs.yurdriver.fragment.RegisterFragment.java

private void datepicker() {

    final Dialog dialog = new Dialog(getActivity());
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCanceledOnTouchOutside(true);
    dialog.setContentView(R.layout.datepicker_layout);
    final DatePicker date = (DatePicker) dialog.findViewById(R.id.datePicker1);
    final Calendar c = Calendar.getInstance();
    c.add(Calendar.DAY_OF_YEAR, -1 * (16 * 365));
    date.setMaxDate(c.getTimeInMillis());

    Button text = (Button) dialog.findViewById(R.id.ok);
    text.setOnClickListener(new OnClickListener() {
        @Override//w ww .j a  va 2  s  . co m
        public void onClick(View v) {
            v.bringToFront();

            String dateString = String
                    .valueOf(date.getYear() + "-" + (date.getMonth() + 1) + "-" + date.getDayOfMonth());
            etDOB.setText(dateString);

            dialog.dismiss();
        }
    });
    Button cancel = (Button) dialog.findViewById(R.id.cancel);
    cancel.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            v.bringToFront();
            dialog.dismiss();
        }
    });
    dialog.show();

}

From source file:github.popeen.dsub.activity.SubsonicFragmentActivity.java

private void showLoginDialog() {
    final Dialog login = new Dialog(this);
    login.setContentView(R.layout.dialog_signin);

    Button btnLogin = (Button) login.findViewById(R.id.btnLogin);
    Button btnCancel = (Button) login.findViewById(R.id.btnCancel);

    btnLogin.setOnClickListener(new View.OnClickListener() {
        @Override/*from  w w  w.ja  va  2 s .  com*/
        public void onClick(View view) {
            //Test server connection.
            EditText username = (EditText) login.findViewById(R.id.username);
            EditText password = (EditText) login.findViewById(R.id.password);
            EditText server = (EditText) login.findViewById(R.id.server);

            String strUsername = username.getText().toString();
            String strPassword = password.getText().toString();
            String strServer = server.getText().toString();

            if (strUsername.length() > 0 && strPassword.length() > 0 && strServer.length() > 0) {
                Util.setRestCredentials(SubsonicFragmentActivity.this, null, strUsername, strPassword,
                        strServer);
                login.dismiss();
                //recreate();
                SubsonicFragmentActivity.super.restart();
            }
        }
    });

    btnCancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            login.dismiss();
        }
    });

    login.show();
}

From source file:org.glucosio.android.activity.MainActivity.java

public void showExportCsvDialog() {
    final Dialog exportDialog = new Dialog(MainActivity.this, R.style.GlucosioTheme);

    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
    lp.copyFrom(exportDialog.getWindow().getAttributes());
    lp.width = WindowManager.LayoutParams.WRAP_CONTENT;
    lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
    exportDialog.setContentView(R.layout.dialog_export);
    exportDialog.getWindow().setAttributes(lp);
    exportDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    exportDialog.getWindow().setDimAmount(0.5f);
    exportDialog.show();/*www .  j  a v  a 2 s  .c  o m*/

    exportDialogDateFrom = (TextView) exportDialog.findViewById(R.id.activity_export_date_from);
    exportDialogDateTo = (TextView) exportDialog.findViewById(R.id.activity_export_date_to);
    exportRangeButton = (RadioButton) exportDialog.findViewById(R.id.activity_export_range);
    final RadioButton exportAllButton = (RadioButton) exportDialog.findViewById(R.id.activity_export_all);
    final TextView exportButton = (TextView) exportDialog.findViewById(R.id.dialog_export_add);
    final TextView cancelButton = (TextView) exportDialog.findViewById(R.id.dialog_export_cancel);

    exportRangeButton.setChecked(true);

    exportDialogDateFrom.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Calendar now = Calendar.getInstance();
            DatePickerDialog dpd = DatePickerDialog.newInstance(MainActivity.this, now.get(Calendar.YEAR),
                    now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH));
            dpd.show(getFragmentManager(), "fromDateDialog");
            dpd.setMaxDate(now);
        }
    });

    exportDialogDateTo.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Calendar now = Calendar.getInstance();
            DatePickerDialog dpd = DatePickerDialog.newInstance(MainActivity.this, now.get(Calendar.YEAR),
                    now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH));
            dpd.show(getFragmentManager(), "toDateDialog");
            dpd.setMaxDate(now);
        }
    });

    exportRangeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            boolean isChecked = exportRangeButton.isChecked();
            exportDialogDateFrom.setEnabled(true);
            exportDialogDateTo.setEnabled(true);
            exportAllButton.setChecked(!isChecked);
        }
    });

    exportAllButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            boolean isChecked = exportAllButton.isChecked();
            exportDialogDateFrom.setEnabled(false);
            exportDialogDateTo.setEnabled(false);
            exportRangeButton.setChecked(!isChecked);
            exportButton.setEnabled(true);
        }
    });

    exportButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (validateExportDialog()) {
                exportPresenter.onExportClicked(exportAllButton.isChecked());
                exportDialog.dismiss();
            } else {
                showSnackBar(getResources().getString(R.string.dialog_error), Snackbar.LENGTH_LONG);
            }
        }
    });

    cancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            exportDialog.dismiss();
        }
    });

}

From source file:com.allwinner.theatreplayer.launcher.activity.LaunchActivity.java

public void openDialog() {
    //      Dialog dialog = null;
    //      Builder builder = new Dialog.Builder(this).setTitle("?").setMessage("??");
    //      dialog = builder.create();
    //      dialog.show();

    Dialog dialog = new Dialog(this, R.style.CustomDialog);
    dialog.setContentView(R.layout.launcher_fail);
    dialog.setOnKeyListener(keylistener);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setCancelable(false);//from  w w w. j a  v  a2s .  c  om
    dialog.show();
}

From source file:com.owncloud.android.ui.adapter.FileListListAdapter.java

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    View view = convertView;//from   www .  j  a va  2 s . c  om
    if (view == null) {
        LayoutInflater inflator = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = inflator.inflate(R.layout.list_item, null);
    }

    if (mFiles != null && mFiles.size() > position) {
        OCFile file = mFiles.get(position);
        TextView fileName = (TextView) view.findViewById(R.id.Filename);
        String name = file.getFileName();
        if (dataSourceShareFile == null)
            dataSourceShareFile = new DbShareFile(mContext);

        Account account = AccountUtils.getCurrentOwnCloudAccount(mContext);
        String[] accountNames = account.name.split("@");

        if (accountNames.length > 2) {
            accountName = accountNames[0] + "@" + accountNames[1];
            url = accountNames[2];
        }
        Map<String, String> fileSharers = dataSourceShareFile.getUsersWhoSharedFilesWithMe(accountName);
        TextView sharer = (TextView) view.findViewById(R.id.sharer);
        ImageView shareButton = (ImageView) view.findViewById(R.id.shareItem);
        fileName.setText(name);
        ImageView fileIcon = (ImageView) view.findViewById(R.id.imageView1);
        fileIcon.setImageResource(DisplayUtils.getResourceId(file.getMimetype()));
        ImageView localStateView = (ImageView) view.findViewById(R.id.imageView2);
        FileDownloaderBinder downloaderBinder = mTransferServiceGetter.getFileDownloaderBinder();
        FileUploaderBinder uploaderBinder = mTransferServiceGetter.getFileUploaderBinder();
        if (fileSharers.size() != 0 && (!file.equals("Shared") && file.getRemotePath().contains("Shared"))) {
            if (fileSharers.containsKey(name)) {
                sharer.setText(fileSharers.get(name));
                fileSharers.remove(name);
            } else {
                sharer.setText(" ");
            }
        } else {
            sharer.setText(" ");
        }

        if (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, file)) {
            localStateView.setImageResource(R.drawable.downloading_file_indicator);
            localStateView.setVisibility(View.VISIBLE);
        } else if (uploaderBinder != null && uploaderBinder.isUploading(mAccount, file)) {
            localStateView.setImageResource(R.drawable.uploading_file_indicator);
            localStateView.setVisibility(View.VISIBLE);
        } else if (file.isDown()) {
            localStateView.setImageResource(R.drawable.local_file_indicator);
            localStateView.setVisibility(View.VISIBLE);
        } else {
            localStateView.setVisibility(View.INVISIBLE);
        }

        TextView fileSizeV = (TextView) view.findViewById(R.id.file_size);
        TextView lastModV = (TextView) view.findViewById(R.id.last_mod);
        ImageView checkBoxV = (ImageView) view.findViewById(R.id.custom_checkbox);
        shareButton.setOnClickListener(new OnClickListener() {
            String shareStatusDisplay;
            int flagShare = 0;

            @Override
            public void onClick(View v) {
                final Dialog dialog = new Dialog(mContext);
                final OCFile fileToBeShared = (OCFile) getItem(position);
                final ArrayAdapter<String> shareWithFriends;
                final ArrayAdapter<String> shareAdapter;
                final String filePath;
                sharedWith = new ArrayList<String>();
                dataSource = new DbFriends(mContext);
                dataSourceShareFile = new DbShareFile(mContext);
                dialog.setContentView(R.layout.share_file_with);
                dialog.setTitle("Share");
                Account account = AccountUtils.getCurrentOwnCloudAccount(mContext);
                String[] accountNames = account.name.split("@");

                if (accountNames.length > 2) {
                    accountName = accountNames[0] + "@" + accountNames[1];
                    url = accountNames[2];
                }

                final AutoCompleteTextView textView = (AutoCompleteTextView) dialog
                        .findViewById(R.id.autocompleteshare);
                Button shareBtn = (Button) dialog.findViewById(R.id.ShareBtn);
                Button doneBtn = (Button) dialog.findViewById(R.id.ShareDoneBtn);
                final ListView listview = (ListView) dialog.findViewById(R.id.alreadySharedWithList);

                textView.setThreshold(2);
                final String itemType;

                filePath = "files" + String.valueOf(fileToBeShared.getRemotePath());
                final String fileName = fileToBeShared.getFileName();
                final String fileRemotePath = fileToBeShared.getRemotePath();
                if (dataSourceShareFile == null)
                    dataSourceShareFile = new DbShareFile(mContext);
                sharedWith = dataSourceShareFile.getUsersWithWhomIhaveSharedFile(fileName, fileRemotePath,
                        accountName, String.valueOf(1));
                shareAdapter = new ArrayAdapter<String>(mContext, android.R.layout.simple_list_item_1,
                        sharedWith);
                listview.setAdapter(shareAdapter);
                final String itemSource;
                if (fileToBeShared.isDirectory()) {
                    itemType = "folder";
                    int lastSlashInFolderPath = filePath.lastIndexOf('/');
                    itemSource = filePath.substring(0, lastSlashInFolderPath);
                } else {
                    itemType = "file";
                    itemSource = filePath;
                }

                //Permissions disabled with friends app
                ArrayList<String> friendList = dataSource.getFriendList(accountName);
                dataSource.close();
                shareWithFriends = new ArrayAdapter<String>(mContext, android.R.layout.simple_list_item_1,
                        friendList);
                textView.setAdapter(shareWithFriends);
                textView.setFocusableInTouchMode(true);
                dialog.show();
                textView.setOnItemClickListener(new OnItemClickListener() {

                    @Override
                    public void onItemClick(AdapterView<?> parent, View v, int position, long id) {

                    }
                });
                final Handler finishedHandler = new Handler() {
                    @Override
                    public void handleMessage(Message msg) {
                        shareAdapter.notifyDataSetChanged();
                        Toast.makeText(mContext, shareStatusDisplay, Toast.LENGTH_SHORT).show();

                    }
                };
                shareBtn.setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        final String shareWith = textView.getText().toString();

                        if (shareWith.equals("")) {
                            textView.setHint("Share With");
                            Toast.makeText(mContext,
                                    "Please enter the friends name with whom you want to share",
                                    Toast.LENGTH_SHORT).show();
                        } else if (sharedWith.contains(shareWith)) {
                            textView.setHint("Share With");
                            Toast.makeText(mContext, "You have shared the file with that person",
                                    Toast.LENGTH_SHORT).show();
                        } else {

                            textView.setText("");
                            Runnable runnable = new Runnable() {
                                @Override
                                public void run() {
                                    HttpPost post = new HttpPost(
                                            "http://" + url + "/owncloud/androidshare.php");
                                    final ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();

                                    params.add(new BasicNameValuePair("itemType", itemType));
                                    params.add(new BasicNameValuePair("itemSource", itemSource));
                                    params.add(new BasicNameValuePair("shareType", shareType));
                                    params.add(new BasicNameValuePair("shareWith", shareWith));
                                    params.add(new BasicNameValuePair("permission", permissions));
                                    params.add(new BasicNameValuePair("uidOwner", accountName));
                                    HttpEntity entity;
                                    String shareSuccess = "false";
                                    try {
                                        entity = new UrlEncodedFormEntity(params, "utf-8");
                                        HttpClient client = new DefaultHttpClient();
                                        post.setEntity(entity);
                                        HttpResponse response = client.execute(post);

                                        if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                                            HttpEntity entityresponse = response.getEntity();
                                            String jsonentity = EntityUtils.toString(entityresponse);
                                            JSONObject obj = new JSONObject(jsonentity);
                                            shareSuccess = obj.getString("SHARE_STATUS");
                                            flagShare = 1;
                                            if (shareSuccess.equals("true")) {
                                                dataSourceShareFile.putNewShares(fileName, fileRemotePath,
                                                        accountName, shareWith);
                                                sharedWith.add(shareWith);
                                                shareStatusDisplay = "File share succeeded";
                                            } else if (shareSuccess.equals("INVALID_FILE")) {
                                                shareStatusDisplay = "File you are trying to share does not exist";
                                            } else if (shareSuccess.equals("INVALID_SHARETYPE")) {
                                                shareStatusDisplay = "File Share type is invalid";
                                            } else {
                                                shareStatusDisplay = "Share did not succeed. Please check your internet connection";
                                            }

                                            finishedHandler.sendEmptyMessage(flagShare);

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

                                }
                            };
                            new Thread(runnable).start();

                        }

                        if (flagShare == 1) {
                        }

                    }

                });
                doneBtn.setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        dialog.dismiss();
                        //dataSourceShareFile.close();
                    }
                });
            }

        });
        //dataSourceShareFile.close();
        if (!file.isDirectory()) {
            fileSizeV.setVisibility(View.VISIBLE);
            fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));
            lastModV.setVisibility(View.VISIBLE);
            lastModV.setText(DisplayUtils.unixTimeToHumanReadable(file.getModificationTimestamp()));
            // this if-else is needed even thoe fav icon is visible by default
            // because android reuses views in listview
            if (!file.keepInSync()) {
                view.findViewById(R.id.imageView3).setVisibility(View.GONE);
            } else {
                view.findViewById(R.id.imageView3).setVisibility(View.VISIBLE);
            }

            ListView parentList = (ListView) parent;
            if (parentList.getChoiceMode() == ListView.CHOICE_MODE_NONE) {
                checkBoxV.setVisibility(View.GONE);
            } else {
                if (parentList.isItemChecked(position)) {
                    checkBoxV.setImageResource(android.R.drawable.checkbox_on_background);
                } else {
                    checkBoxV.setImageResource(android.R.drawable.checkbox_off_background);
                }
                checkBoxV.setVisibility(View.VISIBLE);
            }

        } else {

            fileSizeV.setVisibility(View.VISIBLE);
            fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));
            lastModV.setVisibility(View.VISIBLE);
            lastModV.setText(DisplayUtils.unixTimeToHumanReadable(file.getModificationTimestamp()));
            checkBoxV.setVisibility(View.GONE);
            view.findViewById(R.id.imageView3).setVisibility(View.GONE);
        }
    }

    return view;
}

From source file:com.pimp.companionforband.activities.main.MainActivity.java

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

    sContext = getApplicationContext();//from  ww  w  .j a  v a 2  s.  c  o m
    sActivity = this;

    sharedPreferences = getApplicationContext().getSharedPreferences("MyPrefs", 0);
    editor = sharedPreferences.edit();

    bandSensorData = new BandSensorData();

    mDestinationUri = Uri.fromFile(new File(getCacheDir(), SAMPLE_CROPPED_IMAGE_NAME));

    SectionsPagerAdapter mSectionsPagerAdapter;
    ViewPager mViewPager;

    if (!checkCameraPermission(true))
        requestCameraPermission(true);
    if (!checkCameraPermission(false))
        requestCameraPermission(false);

    FiveStarsDialog fiveStarsDialog = new FiveStarsDialog(this, "pimplay69@gmail.com");
    fiveStarsDialog.setTitle(getString(R.string.rate_dialog_title))
            .setRateText(getString(R.string.rate_dialog_text)).setForceMode(false).setUpperBound(4)
            .setNegativeReviewListener(this).showAfter(5);

    AnalyticsApplication application = (AnalyticsApplication) getApplication();
    mTracker = application.getDefaultTracker();

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.setOffscreenPageLimit(2);
    mViewPager.setPageTransformer(true, new ZoomOutPageTransformer());
    mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
            String name;
            switch (position) {
            case 0:
                name = "THEME";
                break;
            case 1:
                name = "SENSORS";
                break;
            case 2:
                name = "EXTRAS";
                break;
            default:
                name = "CfB";
            }

            mTracker.setScreenName("Image~" + name);
            mTracker.send(new HitBuilders.ScreenViewBuilder().build());

            logSwitch = (Switch) findViewById(R.id.log_switch);
            backgroundLogSwitch = (Switch) findViewById(R.id.backlog_switch);
            logStatus = (TextView) findViewById(R.id.logStatus);
            backgroundLogStatus = (TextView) findViewById(R.id.backlogStatus);
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);

    Drawable headerBackground = null;
    String encoded = sharedPreferences.getString("me_tile_image", "null");
    if (!encoded.equals("null")) {
        byte[] imageAsBytes = Base64.decode(encoded.getBytes(), Base64.DEFAULT);
        headerBackground = new BitmapDrawable(
                BitmapFactory.decodeByteArray(imageAsBytes, 0, imageAsBytes.length));
    }

    AccountHeader accountHeader = new AccountHeaderBuilder().withActivity(this).withCompactStyle(true)
            .withHeaderBackground((headerBackground == null) ? getResources().getDrawable(R.drawable.pipboy)
                    : headerBackground)
            .addProfiles(new ProfileDrawerItem()
                    .withName(sharedPreferences.getString("device_name", "Companion For Band"))
                    .withEmail(sharedPreferences.getString("device_mac", "pimplay69@gmail.com"))
                    .withIcon(getResources().getDrawable(R.drawable.band)))
            .build();

    result = new DrawerBuilder().withActivity(this).withToolbar(toolbar).withActionBarDrawerToggleAnimated(true)
            .withAccountHeader(accountHeader)
            .addDrawerItems(
                    new PrimaryDrawerItem().withName(getString(R.string.drawer_cloud))
                            .withIcon(GoogleMaterial.Icon.gmd_cloud).withIdentifier(1),
                    new DividerDrawerItem(),
                    new PrimaryDrawerItem().withName(getString(R.string.rate))
                            .withIcon(GoogleMaterial.Icon.gmd_rate_review).withIdentifier(2),
                    new PrimaryDrawerItem().withName(getString(R.string.feedback))
                            .withIcon(GoogleMaterial.Icon.gmd_feedback).withIdentifier(3),
                    new DividerDrawerItem(),
                    new PrimaryDrawerItem().withName(getString(R.string.share))
                            .withIcon(GoogleMaterial.Icon.gmd_share).withIdentifier(4),
                    new PrimaryDrawerItem().withName(getString(R.string.other))
                            .withIcon(GoogleMaterial.Icon.gmd_apps).withIdentifier(5),
                    new DividerDrawerItem(),
                    new PrimaryDrawerItem().withName(getString(R.string.report))
                            .withIcon(GoogleMaterial.Icon.gmd_bug_report).withIdentifier(6),
                    new PrimaryDrawerItem().withName(getString(R.string.translate))
                            .withIcon(GoogleMaterial.Icon.gmd_translate).withIdentifier(9),
                    new DividerDrawerItem(),
                    new PrimaryDrawerItem().withName(getString(R.string.support))
                            .withIcon(GoogleMaterial.Icon.gmd_attach_money).withIdentifier(7),
                    new PrimaryDrawerItem().withName(getString(R.string.aboutLib))
                            .withIcon(GoogleMaterial.Icon.gmd_info).withIdentifier(8))
            .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                @Override
                public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                    boolean flag;
                    if (drawerItem != null) {
                        flag = true;
                        switch ((int) drawerItem.getIdentifier()) {
                        case 1:
                            mTracker.send(new HitBuilders.EventBuilder().setCategory("Action")
                                    .setAction("Cloud").build());

                            if (!sharedPreferences.getString("access_token", "hi").equals("hi"))
                                startActivity(new Intent(getApplicationContext(), CloudActivity.class));
                            else
                                startActivity(new Intent(getApplicationContext(), WebviewActivity.class));
                            break;
                        case 2:
                            mTracker.send(new HitBuilders.EventBuilder().setCategory("Action")
                                    .setAction("Rate and Review").build());
                            String MARKET_URL = "https://play.google.com/store/apps/details?id=";
                            String PlayStoreListing = getPackageName();
                            Intent rate = new Intent(Intent.ACTION_VIEW,
                                    Uri.parse(MARKET_URL + PlayStoreListing));
                            startActivity(rate);
                            break;
                        case 3:
                            mTracker.send(new HitBuilders.EventBuilder().setCategory("Action")
                                    .setAction("Feedback").build());
                            final StringBuilder emailBuilder = new StringBuilder();
                            Intent intent = new Intent(Intent.ACTION_VIEW,
                                    Uri.parse("mailto:pimplay69@gmail.com"));
                            intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.app_name));

                            emailBuilder.append("\n \n \nOS Version: ").append(System.getProperty("os.version"))
                                    .append("(").append(Build.VERSION.INCREMENTAL).append(")");
                            emailBuilder.append("\nOS API Level: ").append(Build.VERSION.SDK_INT);
                            emailBuilder.append("\nDevice: ").append(Build.DEVICE);
                            emailBuilder.append("\nManufacturer: ").append(Build.MANUFACTURER);
                            emailBuilder.append("\nModel (and Product): ").append(Build.MODEL).append(" (")
                                    .append(Build.PRODUCT).append(")");
                            PackageInfo appInfo = null;
                            try {
                                appInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
                            } catch (PackageManager.NameNotFoundException e) {
                                e.printStackTrace();
                            }
                            assert appInfo != null;
                            emailBuilder.append("\nApp Version Name: ").append(appInfo.versionName);
                            emailBuilder.append("\nApp Version Code: ").append(appInfo.versionCode);

                            intent.putExtra(Intent.EXTRA_TEXT, emailBuilder.toString());
                            startActivity(Intent.createChooser(intent, "Send via"));
                            break;
                        case 4:
                            mTracker.send(new HitBuilders.EventBuilder().setCategory("Action")
                                    .setAction("Share").build());
                            Intent i = new AppInviteInvitation.IntentBuilder(
                                    getString(R.string.invitation_title))
                                            .setMessage(getString(R.string.invitation_message))
                                            .setCallToActionText(getString(R.string.invitation_cta)).build();
                            startActivityForResult(i, REQUEST_INVITE);
                            break;
                        case 5:
                            mTracker.send(new HitBuilders.EventBuilder().setCategory("Action")
                                    .setAction("Other Apps").build());
                            String PlayStoreDevAccount = "https://play.google.com/store/apps/developer?id=P.I.M.P.";
                            Intent devPlay = new Intent(Intent.ACTION_VIEW, Uri.parse(PlayStoreDevAccount));
                            startActivity(devPlay);
                            break;
                        case 6:
                            mTracker.send(new HitBuilders.EventBuilder().setCategory("Action")
                                    .setAction("Report Bugs").build());
                            startActivity(new Intent(MainActivity.this, GittyActivity.class));
                            break;
                        case 7:
                            mTracker.send(new HitBuilders.EventBuilder().setCategory("Action")
                                    .setAction("Donate").build());

                            String base64EncodedPublicKey = getString(R.string.base64);
                            mHelper = new IabHelper(getApplicationContext(), base64EncodedPublicKey);
                            mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
                                public void onIabSetupFinished(IabResult result) {
                                    if (!result.isSuccess()) {
                                        Toast.makeText(MainActivity.this,
                                                "Problem setting up In-app Billing: " + result,
                                                Toast.LENGTH_LONG).show();
                                    }
                                }
                            });

                            final Dialog dialog = new Dialog(MainActivity.this);
                            dialog.setContentView(R.layout.dialog_donate);
                            dialog.setTitle("Donate");

                            String[] title = { "Coke", "Coffee", "Burger", "Pizza", "Meal" };
                            String[] price = { "Rs. 10.00", "Rs. 50.00", "Rs. 100.00", "Rs. 500.00",
                                    "Rs. 1,000.00" };

                            ListView listView = (ListView) dialog.findViewById(R.id.list);
                            listView.setAdapter(new DonateListAdapter(MainActivity.this, title, price));
                            listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                                @Override
                                public void onItemClick(AdapterView<?> parent, View view, int position,
                                        long id) {
                                    switch (position) {
                                    case 0:
                                        mHelper.launchPurchaseFlow(MainActivity.this, SKU_COKE, 1,
                                                mPurchaseFinishedListener, "payload");
                                        break;
                                    case 1:
                                        mHelper.launchPurchaseFlow(MainActivity.this, SKU_COFFEE, 1,
                                                mPurchaseFinishedListener, "payload");
                                        break;
                                    case 2:
                                        mHelper.launchPurchaseFlow(MainActivity.this, SKU_BURGER, 1,
                                                mPurchaseFinishedListener, "payload");
                                        break;
                                    case 3:
                                        mHelper.launchPurchaseFlow(MainActivity.this, SKU_PIZZA, 1,
                                                mPurchaseFinishedListener, "payload");
                                        break;
                                    case 4:
                                        mHelper.launchPurchaseFlow(MainActivity.this, SKU_MEAL, 1,
                                                mPurchaseFinishedListener, "payload");
                                        break;
                                    }
                                }
                            });

                            dialog.show();
                            break;
                        case 8:
                            mTracker.send(new HitBuilders.EventBuilder().setCategory("Action")
                                    .setAction("About").build());
                            new LibsBuilder().withLicenseShown(true).withVersionShown(true)
                                    .withActivityStyle(Libs.ActivityStyle.DARK).withAboutVersionShown(true)
                                    .withActivityTitle(getString(R.string.app_name)).withAboutIconShown(true)
                                    .withListener(libsListener).start(MainActivity.this);
                            break;
                        case 9:
                            mTracker.send(new HitBuilders.EventBuilder().setCategory("Action")
                                    .setAction("Translate").build());
                            Intent translate = new Intent(Intent.ACTION_VIEW,
                                    Uri.parse("https://poeditor.com/join/project/AZQxDV2440"));
                            startActivity(translate);
                            break;
                        default:
                            break;
                        }
                    } else {
                        flag = false;
                    }
                    return flag;
                }
            }).withSavedInstance(savedInstanceState).build();

    AppUpdater appUpdater = new AppUpdater(this);
    appUpdater.start();

    final DirectoryChooserConfig config = DirectoryChooserConfig.builder()
            .allowNewDirectoryNameModification(true).newDirectoryName("CfBCamera")
            .initialDirectory(
                    sharedPreferences.getString("pic_location", "/storage/emulated/0/CompanionForBand/Camera"))
            .build();
    mDialog = DirectoryChooserFragment.newInstance(config);

    new BandUtils().execute();

    CustomActivityOnCrash.install(this);
}

From source file:com.aegiswallet.actions.MainActivity.java

private void doBackupReminder() {

    if (System.currentTimeMillis() - application.lastReminderTime < 60000)
        return;//from w  w w  .j a v  a  2  s.c  o m

    String lastBackupString = prefs.getString(Constants.LAST_BACKUP_DATE, null);
    int lastBackupNumAddresses = prefs.getInt(Constants.LAST_BACKUP_NUM_ADDRESSES, 0);

    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.backup_reminder_prompt);

    TextView backupText = (TextView) dialog.findViewById(R.id.backup_reminder_prompt_text);

    Button cancelButton = (Button) dialog.findViewById(R.id.backup_reminder_prompt_cancel_button);
    cancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dialog.dismiss();
        }
    });

    final Button okayButton = (Button) dialog.findViewById(R.id.backup_reminder_prompt_ok_button);

    okayButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dialog.dismiss();

            if (nfcEnabled) {
                Intent intent = new Intent(context, NFCActivity.class);
                intent.putExtra("nfc_action", "backup");
                startActivity(intent);
            } else
                application.showPasswordPrompt(context, Constants.ACTION_BACKUP);
        }
    });

    try {

        if (dialog.isShowing())
            return;

        if (lastBackupString != null) {
            Date lastBackupDate = Constants.backupDateFormat.parse(lastBackupString);
            long currentDate = System.currentTimeMillis();
            long difference = currentDate - lastBackupDate.getTime();

            long days = TimeUnit.MILLISECONDS.toDays(difference);
            int keyChainSize = wallet.getKeychainSize();

            if (days > 6) {
                dialog.show();
                application.lastReminderTime = System.currentTimeMillis();
            } else if (!prefs.contains(Constants.LAST_BACKUP_NUM_ADDRESSES)) {
                dialog.show();
                application.lastReminderTime = System.currentTimeMillis();

            } else if (keyChainSize > lastBackupNumAddresses) {
                backupText.setText(getString(R.string.backup_reminder_new_address));
                dialog.show();
                application.lastReminderTime = System.currentTimeMillis();
            }

        } else {
            application.lastReminderTime = System.currentTimeMillis();
            dialog.show();
        }

    } catch (ParseException e) {
        Log.d(TAG, e.getMessage());
    }
}

From source file:com.example.pyrkesa.frag.User_Fragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    setRetainInstance(true);//from  w  w w . ja  v a  2s.co  m
    rootView = inflater.inflate(R.layout.user_fragment, container, false);
    userList = (ListView) rootView.findViewById(R.id.lt_user);

    // custom dialog
    final Dialog dialog = new Dialog(rootView.getContext());
    d = dialog;
    userIcons = getResources().obtainTypedArray(R.array.userIcons);// load icons from
    userIcons1 = getResources().obtainTypedArray(R.array.userIcons1);

    userItems = new ArrayList<UserItem>();
    adapter = new UserAdapter(getActivity(), userItems, getActivity());
    userList.setAdapter(adapter);
    ImageButton addButton = (ImageButton) rootView.findViewById(R.id.add);
    addButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ModelFactory model = (ModelFactory) ModelFactory.getContext();
            if (model.user.type == 1) {

                dialog.setContentView(R.layout.adduser_dialog);
                dialog.setTitle("Ajouter un utilisateur ");
                dialogTypes = getResources().getStringArray(R.array.user_type_dialog); // load
                Button dialogButtonOk = (Button) dialog.findViewById(R.id.button_ok);
                Button dialogButtonCancel = (Button) dialog.findViewById(R.id.button_cancel);
                final EditText Newlogin = (EditText) dialog.findViewById(R.id.dialogLogin);
                final EditText NewPW = (EditText) dialog.findViewById(R.id.dialogPW);
                final Spinner NewType = (Spinner) dialog.findViewById(R.id.dialogType);

                ArrayList<String> types = new ArrayList<String>();

                for (String t : dialogTypes) {
                    types.add(t);
                }

                NewType.setAdapter(new ArrayAdapter<String>(rootView.getContext(),
                        android.R.layout.simple_spinner_dropdown_item, types));
                dialogButtonCancel.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog.dismiss();
                    }
                });
                dialogButtonOk.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                        ArrayList<String> temp = new ArrayList<String>();
                        String login = Newlogin.getText().toString();
                        String password = NewPW.getText().toString();
                        String type = NewType.getSelectedItem().toString();

                        if (login.equalsIgnoreCase("") && password.equalsIgnoreCase("") && type != null) {
                            new AlertDialog.Builder(v.getContext()).setTitle("Attention")
                                    .setMessage("Veuillez remplir toutes les informations.").show();

                        } else {
                            temp.add(login);
                            temp.add(password);

                            if (type.equalsIgnoreCase("admin")) {
                                temp.add("1");
                            } else if (type.equalsIgnoreCase("utilisateur")) {
                                temp.add("0");
                            } else {
                                temp.add("0");
                            }

                        }

                        new addUser().execute(temp);
                    }
                });
                dialog.show();

            } else {
                new AlertDialog.Builder(v.getContext()).setTitle("Attention")
                        .setMessage("Opration interdite : Droits d'administration requis.").show();
            }

        }
    });
    // adding user items

    new LoadAllUser().execute();

    return rootView;

}

From source file:com.cloverstudio.spika.GroupProfileActivity.java

private void getImageDialog() {
    final Dialog imageDialog = new Dialog(GroupProfileActivity.this, R.style.TransparentDialogTheme);
    imageDialog.getWindow().setGravity(Gravity.BOTTOM);
    imageDialog.setContentView(R.layout.dialog_get_image);
    WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
    Window window = imageDialog.getWindow();
    layoutParams.copyFrom(window.getAttributes());
    layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
    layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
    window.setAttributes(layoutParams);//  w  ww . j av a 2s .co m

    final Button btnGallery = (Button) imageDialog.findViewById(R.id.btnGallery);
    btnGallery.setTypeface(SpikaApp.getTfMyriadProBold(), Typeface.BOLD);
    btnGallery.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {

            Intent galleryIntent = new Intent(GroupProfileActivity.this, CameraCropActivity.class);
            galleryIntent.putExtra("type", "gallery");
            galleryIntent.putExtra("groupUpdate", true);
            GroupProfileActivity.this.startActivityForResult(galleryIntent, UPDATE_IMAGE_REQUEST_CODE);
            imageDialog.dismiss();

        }
    });

    final Button btnCamera = (Button) imageDialog.findViewById(R.id.btnCamera);
    btnCamera.setTypeface(SpikaApp.getTfMyriadProBold(), Typeface.BOLD);
    btnCamera.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {

            Intent cameraIntent = new Intent(GroupProfileActivity.this, CameraCropActivity.class);
            cameraIntent.putExtra("type", "camera");
            cameraIntent.putExtra("groupUpdate", true);
            GroupProfileActivity.this.startActivityForResult(cameraIntent, UPDATE_IMAGE_REQUEST_CODE);
            imageDialog.dismiss();

        }
    });

    final Button btnRemovePhoto = (Button) imageDialog.findViewById(R.id.btnRemovePhoto);
    btnRemovePhoto.setTypeface(SpikaApp.getTfMyriadProBold(), Typeface.BOLD);
    btnRemovePhoto.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {

            mGroupAvatarId = "";
            gGroupImage = null;
            Utils.displayImage(mGroupAvatarId, mIvGroupImage, mPbLoading, ImageLoader.LARGE,
                    R.drawable.group_stub_large, false);
            imageDialog.dismiss();

        }
    });

    imageDialog.show();
}

From source file:info.hl.mediam.GroupProfileActivity.java

private void getImageDialog() {
    final Dialog imageDialog = new Dialog(GroupProfileActivity.this, R.style.TransparentDialogTheme);
    imageDialog.getWindow().setGravity(Gravity.BOTTOM);
    imageDialog.setContentView(R.layout.dialog_get_image);
    WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
    Window window = imageDialog.getWindow();
    layoutParams.copyFrom(window.getAttributes());
    layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
    layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
    window.setAttributes(layoutParams);/*from w w w  .j a  v  a  2s . c  o  m*/

    final Button btnGallery = (Button) imageDialog.findViewById(R.id.btnGallery);
    btnGallery.setTypeface(MediamApp.getTfMyriadProBold(), Typeface.BOLD);
    btnGallery.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {

            Intent galleryIntent = new Intent(GroupProfileActivity.this, CameraCropActivity.class);
            galleryIntent.putExtra("type", "gallery");
            galleryIntent.putExtra("groupUpdate", true);
            GroupProfileActivity.this.startActivityForResult(galleryIntent, UPDATE_IMAGE_REQUEST_CODE);
            imageDialog.dismiss();

        }
    });

    final Button btnCamera = (Button) imageDialog.findViewById(R.id.btnCamera);
    btnCamera.setTypeface(MediamApp.getTfMyriadProBold(), Typeface.BOLD);
    btnCamera.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {

            Intent cameraIntent = new Intent(GroupProfileActivity.this, CameraCropActivity.class);
            cameraIntent.putExtra("type", "camera");
            cameraIntent.putExtra("groupUpdate", true);
            GroupProfileActivity.this.startActivityForResult(cameraIntent, UPDATE_IMAGE_REQUEST_CODE);
            imageDialog.dismiss();

        }
    });

    final Button btnRemovePhoto = (Button) imageDialog.findViewById(R.id.btnRemovePhoto);
    btnRemovePhoto.setTypeface(MediamApp.getTfMyriadProBold(), Typeface.BOLD);
    btnRemovePhoto.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {

            mGroupAvatarId = "";
            gGroupImage = null;
            Utils.displayImage(mGroupAvatarId, mIvGroupImage, mPbLoading, ImageLoader.LARGE,
                    R.drawable.group_stub_large, false);
            imageDialog.dismiss();

        }
    });

    imageDialog.show();
}