Example usage for android.text InputType TYPE_CLASS_TEXT

List of usage examples for android.text InputType TYPE_CLASS_TEXT

Introduction

In this page you can find the example usage for android.text InputType TYPE_CLASS_TEXT.

Prototype

int TYPE_CLASS_TEXT

To view the source code for android.text InputType TYPE_CLASS_TEXT.

Click Source Link

Document

Class for normal text.

Usage

From source file:org.telegram.ui.ChannelEditActivity.java

@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);

    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override//from   w ww .  ja  va 2 s . c  om
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            } else if (id == done_button) {
                if (donePressed) {
                    return;
                }
                if (nameTextView.length() == 0) {
                    Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE);
                    if (v != null) {
                        v.vibrate(200);
                    }
                    AndroidUtilities.shakeView(nameTextView, 2, 0);
                    return;
                }
                donePressed = true;

                if (avatarUpdater.uploadingAvatar != null) {
                    createAfterUpload = true;
                    progressDialog = new ProgressDialog(getParentActivity());
                    progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading));
                    progressDialog.setCanceledOnTouchOutside(false);
                    progressDialog.setCancelable(false);
                    progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE,
                            LocaleController.getString("Cancel", R.string.Cancel),
                            new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    createAfterUpload = false;
                                    progressDialog = null;
                                    donePressed = false;
                                    try {
                                        dialog.dismiss();
                                    } catch (Exception e) {
                                        FileLog.e("tmessages", e);
                                    }
                                }
                            });
                    progressDialog.show();
                    return;
                }
                if (!currentChat.title.equals(nameTextView.getText().toString())) {
                    MessagesController.getInstance().changeChatTitle(chatId, nameTextView.getText().toString());
                }
                if (info != null && !info.about.equals(descriptionTextView.getText().toString())) {
                    MessagesController.getInstance().updateChannelAbout(chatId,
                            descriptionTextView.getText().toString(), info);
                }
                if (signMessages != currentChat.signatures) {
                    currentChat.signatures = true;
                    MessagesController.getInstance().toogleChannelSignatures(chatId, signMessages);
                }
                if (uploadedAvatar != null) {
                    MessagesController.getInstance().changeChatAvatar(chatId, uploadedAvatar);
                } else if (avatar == null && currentChat.photo instanceof TLRPC.TL_chatPhoto) {
                    MessagesController.getInstance().changeChatAvatar(chatId, null);
                }
                finishFragment();
            }
        }
    });

    ActionBarMenu menu = actionBar.createMenu();
    doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));

    LinearLayout linearLayout;

    fragmentView = new ScrollView(context);
    fragmentView.setBackgroundColor(ContextCompat.getColor(context, R.color.settings_background));
    ScrollView scrollView = (ScrollView) fragmentView;
    scrollView.setFillViewport(true);
    linearLayout = new LinearLayout(context);
    scrollView.addView(linearLayout, new ScrollView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    linearLayout.setOrientation(LinearLayout.VERTICAL);

    actionBar.setTitle(LocaleController.getString("ChannelEdit", R.string.ChannelEdit));

    LinearLayout linearLayout2 = new LinearLayout(context);
    linearLayout2.setOrientation(LinearLayout.VERTICAL);
    linearLayout2.setElevation(AndroidUtilities.dp(2));
    linearLayout2.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background));
    linearLayout.addView(linearLayout2,
            LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));

    FrameLayout frameLayout = new FrameLayout(context);
    linearLayout2.addView(frameLayout,
            LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));

    avatarImage = new BackupImageView(context);
    avatarImage.setRoundRadius(AndroidUtilities.dp(32));
    avatarDrawable.setInfo(5, null, null, false);
    avatarDrawable.setDrawPhoto(true);
    frameLayout.addView(avatarImage,
            LayoutHelper.createFrame(64, 64,
                    Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT),
                    LocaleController.isRTL ? 0 : 16, 12, LocaleController.isRTL ? 16 : 0, 12));
    avatarImage.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (getParentActivity() == null) {
                return;
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());

            CharSequence[] items;

            if (avatar != null) {
                items = new CharSequence[] { LocaleController.getString("FromCamera", R.string.FromCamera),
                        LocaleController.getString("FromGalley", R.string.FromGalley),
                        LocaleController.getString("DeletePhoto", R.string.DeletePhoto) };
            } else {
                items = new CharSequence[] { LocaleController.getString("FromCamera", R.string.FromCamera),
                        LocaleController.getString("FromGalley", R.string.FromGalley) };
            }

            builder.setItems(items, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    if (i == 0) {
                        avatarUpdater.openCamera();
                    } else if (i == 1) {
                        avatarUpdater.openGallery();
                    } else if (i == 2) {
                        avatar = null;
                        uploadedAvatar = null;
                        avatarImage.setImage(avatar, "50_50", avatarDrawable);
                    }
                }
            });
            showDialog(builder.create());
        }
    });

    nameTextView = new EditText(context);
    if (currentChat.megagroup) {
        nameTextView.setHint(LocaleController.getString("GroupName", R.string.GroupName));
    } else {
        nameTextView.setHint(LocaleController.getString("EnterChannelName", R.string.EnterChannelName));
    }
    nameTextView.setMaxLines(4);
    nameTextView.setGravity(Gravity.CENTER_VERTICAL | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    //nameTextView.setHintTextColor(0xff979797);
    nameTextView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
    nameTextView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
    nameTextView.setPadding(0, 0, 0, AndroidUtilities.dp(8));
    InputFilter[] inputFilters = new InputFilter[1];
    inputFilters[0] = new InputFilter.LengthFilter(100);
    nameTextView.setFilters(inputFilters);
    AndroidUtilities.clearCursorDrawable(nameTextView);
    nameTextView.setTextColor(ContextCompat.getColor(context, R.color.primary_text));
    frameLayout.addView(nameTextView,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT,
                    Gravity.CENTER_VERTICAL, LocaleController.isRTL ? 16 : 96, 0,
                    LocaleController.isRTL ? 96 : 16, 0));
    nameTextView.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {

        }

        @Override
        public void afterTextChanged(Editable s) {
            avatarDrawable.setInfo(5, nameTextView.length() > 0 ? nameTextView.getText().toString() : null,
                    null, false);
            avatarImage.invalidate();
        }
    });

    View lineView = new View(context);
    lineView.setBackgroundColor(ContextCompat.getColor(context, R.color.card_divider));
    linearLayout.addView(lineView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1));

    linearLayout2 = new LinearLayout(context);
    linearLayout2.setOrientation(LinearLayout.VERTICAL);
    linearLayout2.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background));
    linearLayout2.setElevation(AndroidUtilities.dp(2));
    linearLayout.addView(linearLayout2,
            LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));

    descriptionTextView = new EditText(context);
    descriptionTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    //descriptionTextView.setHintTextColor(0xff979797);
    descriptionTextView.setTextColor(ContextCompat.getColor(context, R.color.primary_text));
    descriptionTextView.setPadding(0, 0, 0, AndroidUtilities.dp(6));
    descriptionTextView.setBackgroundDrawable(null);
    descriptionTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    descriptionTextView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES
            | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
    descriptionTextView.setImeOptions(EditorInfo.IME_ACTION_DONE);
    inputFilters = new InputFilter[1];
    inputFilters[0] = new InputFilter.LengthFilter(255);
    descriptionTextView.setFilters(inputFilters);
    descriptionTextView.setHint(LocaleController.getString("DescriptionOptionalPlaceholder",
            R.string.DescriptionOptionalPlaceholder));
    AndroidUtilities.clearCursorDrawable(descriptionTextView);
    linearLayout2.addView(descriptionTextView,
            LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 17, 12, 17, 6));
    descriptionTextView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_DONE && doneButton != null) {
                doneButton.performClick();
                return true;
            }
            return false;
        }
    });
    descriptionTextView.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {

        }

        @Override
        public void afterTextChanged(Editable editable) {

        }
    });

    ShadowSectionCell sectionCell = new ShadowSectionCell(context);
    sectionCell.setSize(20);
    linearLayout.addView(sectionCell,
            LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));

    if (currentChat.megagroup || !currentChat.megagroup) {
        frameLayout = new FrameLayout(context);
        frameLayout.setElevation(AndroidUtilities.dp(2));
        frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background));
        linearLayout.addView(frameLayout,
                LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));

        typeCell = new TextSettingsCell(context);
        updateTypeCell();
        typeCell.setForeground(R.drawable.list_selector);
        frameLayout.addView(typeCell,
                LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));

        lineView = new View(context);
        lineView.setBackgroundColor(ContextCompat.getColor(context, R.color.card_divider));
        linearLayout.addView(lineView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1));

        frameLayout = new FrameLayout(context);
        frameLayout.setElevation(AndroidUtilities.dp(2));
        frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background));
        linearLayout.addView(frameLayout,
                LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));

        if (!currentChat.megagroup) {
            TextCheckCell textCheckCell = new TextCheckCell(context);
            textCheckCell.setForeground(R.drawable.list_selector);
            textCheckCell.setTextAndCheck(
                    LocaleController.getString("ChannelSignMessages", R.string.ChannelSignMessages),
                    signMessages, false);
            frameLayout.addView(textCheckCell,
                    LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
            textCheckCell.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    signMessages = !signMessages;
                    ((TextCheckCell) v).setChecked(signMessages);
                }
            });

            TextInfoPrivacyCell infoCell = new TextInfoPrivacyCell(context);
            //infoCell.setBackgroundResource(R.drawable.greydivider);
            infoCell.setText(
                    LocaleController.getString("ChannelSignMessagesInfo", R.string.ChannelSignMessagesInfo));
            linearLayout.addView(infoCell,
                    LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
        } else {
            adminCell = new TextSettingsCell(context);
            updateAdminCell();
            adminCell.setForeground(R.drawable.list_selector);
            frameLayout.addView(adminCell,
                    LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
            adminCell.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Bundle args = new Bundle();
                    args.putInt("chat_id", chatId);
                    args.putInt("type", 1);
                    presentFragment(new ChannelUsersActivity(args));
                }
            });

            sectionCell = new ShadowSectionCell(context);
            sectionCell.setSize(20);
            linearLayout.addView(sectionCell,
                    LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
            /*if (!currentChat.creator) {
            sectionCell.setBackgroundResource(R.drawable.greydivider_bottom);
            }*/
        }
    }

    if (currentChat.creator) {
        frameLayout = new FrameLayout(context);
        frameLayout.setElevation(AndroidUtilities.dp(2));
        frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background));
        linearLayout.addView(frameLayout,
                LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));

        TextSettingsCell textCell = new TextSettingsCell(context);
        textCell.setTextColor(0xffed3d39);
        textCell.setBackgroundResource(R.drawable.list_selector);
        if (currentChat.megagroup) {
            textCell.setText(LocaleController.getString("DeleteMega", R.string.DeleteMega), false);
        } else {
            textCell.setText(LocaleController.getString("ChannelDelete", R.string.ChannelDelete), false);
        }
        frameLayout.addView(textCell,
                LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
        textCell.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                if (currentChat.megagroup) {
                    builder.setMessage(LocaleController.getString("MegaDeleteAlert", R.string.MegaDeleteAlert));
                } else {
                    builder.setMessage(
                            LocaleController.getString("ChannelDeleteAlert", R.string.ChannelDeleteAlert));
                }
                builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
                builder.setPositiveButton(LocaleController.getString("OK", R.string.OK),
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int i) {
                                NotificationCenter.getInstance().removeObserver(this,
                                        NotificationCenter.closeChats);
                                if (AndroidUtilities.isTablet()) {
                                    NotificationCenter.getInstance().postNotificationName(
                                            NotificationCenter.closeChats, -(long) chatId);
                                } else {
                                    NotificationCenter.getInstance()
                                            .postNotificationName(NotificationCenter.closeChats);
                                }
                                MessagesController.getInstance().deleteUserFromChat(chatId,
                                        MessagesController.getInstance().getUser(UserConfig.getClientUserId()),
                                        info);
                                finishFragment();
                            }
                        });
                builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                showDialog(builder.create());
            }
        });

        TextInfoPrivacyCell infoCell = new TextInfoPrivacyCell(context);
        //infoCell.setBackgroundResource(R.drawable.greydivider_bottom);
        if (currentChat.megagroup) {
            infoCell.setText(LocaleController.getString("MegaDeleteInfo", R.string.MegaDeleteInfo));
        } else {
            infoCell.setText(LocaleController.getString("ChannelDeleteInfo", R.string.ChannelDeleteInfo));
        }
        linearLayout.addView(infoCell,
                LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
    }

    nameTextView.setText(currentChat.title);
    nameTextView.setSelection(nameTextView.length());
    if (info != null) {
        descriptionTextView.setText(info.about);
    }
    if (currentChat.photo != null) {
        avatar = currentChat.photo.photo_small;
        avatarImage.setImage(avatar, "50_50", avatarDrawable);
    } else {
        avatarImage.setImageDrawable(avatarDrawable);
    }

    return fragmentView;
}

From source file:edu.mum.ml.group7.guessasketch.android.EasyPaint.java

public void refreshLabels(JSONObject jObject) {

    /* Button btn = new Button(this);
      btn.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
    getResources().getDimensionPixelSize(R.dimen.prediction_text_view_height) ));
    btn.setTextSize(pixels);//from   w w w  . j a  v a  2s. c o  m
    btn.setText("Cat");
    predictions.addView(btn); */
    final List<RadioButton> buttons = new ArrayList<>();

    String result = "I think it's: ";
    try {
        JSONArray jArray = jObject.getJSONArray("data");
        for (int i = 0; i < jArray.length(); i++) {
            JSONObject prediction = jArray.getJSONObject(i);
            // Pulling items from the array
            int score = prediction.getInt("score");
            if (score < Constants.minScoreThershold) {
                continue;
            }
            String label = prediction.getString("label");

            result += "\"" + label + "\" : " + score + "% ";

            RadioButton radioButton = new RadioButton(EasyPaint.this);
            radioButton.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                    getResources().getDimensionPixelSize(R.dimen.prediction_text_view_height)));
            radioButton.setTextSize(pixels5);
            radioButton.setText(label + " (" + score + "%)");
            radioButton.setTag(label);
            //radioButton.set
            //predictions.addView(radioButton);
            radioButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    saveButton.setTag(view.getTag());
                    feedbackType = ApiCallType.POSITIVE_FEEDBACK;
                }
            });

            buttons.add(radioButton);

        }

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

    final RadioButton radioButton = new RadioButton(EasyPaint.this);
    radioButton.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            getResources().getDimensionPixelSize(R.dimen.prediction_text_view_height)));
    radioButton.setTextSize(pixels5);
    radioButton.setText(R.string.other_label);
    buttons.add(radioButton);

    radioButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            AlertDialog.Builder builder = new AlertDialog.Builder(EasyPaint.this);
            builder.setTitle(R.string.other_label);

            // Set up the input
            final EditText input = new EditText(EasyPaint.this);
            // Specify the type of input expected; this, for example, sets the input as a password, and will mask the text
            input.setInputType(InputType.TYPE_CLASS_TEXT);
            builder.setView(input);

            // Set up the buttons
            builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (input.getText().toString().length() > 0) {
                        radioButton.setText(input.getText().toString());
                        saveButton.setTag(input.getText().toString());
                        feedbackType = ApiCallType.NEGATIVE_FEEDBACK;
                    } else {
                        EasyPaint.this.runOnUiThread(new Runnable() {
                            public void run() {
                                Toast.makeText(getApplicationContext(),
                                        "You didn't specify a name, try again please", Toast.LENGTH_LONG)
                                        .show();
                            }
                        });
                        saveButton.setTag("");
                        feedbackType = ApiCallType.POSITIVE_FEEDBACK;
                        dialog.cancel();
                    }
                }
            });
            builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    saveButton.setTag("");
                    feedbackType = ApiCallType.POSITIVE_FEEDBACK;
                    dialog.cancel();
                }
            });

            builder.show();
        }
    });

    saveButton.setOnClickListener(otherLabelOnClickListener);

    toastMessage = result;

    EasyPaint.this.runOnUiThread(new Runnable() {
        public void run() {
            resetPredictionsView(predictions, false);
            Toast.makeText(getApplicationContext(), toastMessage, Toast.LENGTH_LONG).show();
            for (RadioButton r : buttons) {
                predictions.addView(r);
            }
        }
    });

}

From source file:org.eatabrick.vecna.Vecna.java

protected void onListItemLongClick(AdapterView parent, View v, int pos, long id) {
    // show a crazy dialog for the entry
    final Entry entry = (Entry) adapter.getItem(pos);

    AlertDialog.Builder builder = new AlertDialog.Builder(this);

    LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
    final View layout = inflater.inflate(R.layout.entry, (ViewGroup) findViewById(R.id.layout_root));

    ((TextView) layout.findViewById(R.id.account)).setText(entry.account);
    ((TextView) layout.findViewById(R.id.user)).setText(entry.user);
    ((TextView) layout.findViewById(R.id.password)).setText(entry.password);

    builder.setView(layout);//  w ww .  j  a va  2 s  .c o m

    builder.setPositiveButton(R.string.show_entry_copy, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            copyPassword(entry);
        }
    });

    builder.setNegativeButton(R.string.show_entry_close, null);
    builder.setNeutralButton(R.string.show_entry_show, null);

    final AlertDialog dialog = builder.create();

    dialog.setOnShowListener(new DialogInterface.OnShowListener() {
        public void onShow(DialogInterface dialogInterface) {
            final Button show = dialog.getButton(AlertDialog.BUTTON_NEUTRAL);
            show.setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {
                    EditText password = (EditText) layout.findViewById(R.id.password);

                    if (show.getText().equals(getString(R.string.show_entry_show))) {
                        Log.d(TAG, "Show clicked");
                        password.setInputType(
                                InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
                        show.setText(R.string.show_entry_hide);
                    } else {
                        Log.d(TAG, "Hide clicked");
                        password.setInputType(
                                InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
                        show.setText(R.string.show_entry_show);
                    }
                }
            });
        }
    });

    dialog.show();
}

From source file:at.tomtasche.reader.ui.activity.DocumentActivity.java

public void handleError(Throwable error, final Uri uri) {
    Log.e("OpenDocument Reader", "Error opening file at " + uri.toString(), error);

    final Uri cacheUri = AndroidFileCache.getCacheFileUri();

    for (LoadingListener listener : loadingListeners) {
        listener.onError(error, uri);/*  w  w w .j  a va  2s.c om*/

        // TODO: return here, but only if the listener was registered by a
        // JUnit test
    }

    int errorDescription;
    if (error == null) {
        return;
    } else if (error instanceof EncryptedDocumentException) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.toast_error_password_protected);

        final EditText input = new EditText(this);
        input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
        builder.setView(input);

        builder.setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int whichButton) {
                loadUri(cacheUri, input.getText().toString());

                dialog.dismiss();
            }
        });
        builder.setNegativeButton(getString(android.R.string.cancel), null);
        builder.show();

        return;
    } else if (error instanceof IllegalMimeTypeException || error instanceof ZipException
            || error instanceof ZipEntryNotFoundException || error instanceof UnsupportedMimeTypeException) {
        /*AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.toast_error_illegal_file);
        builder.setMessage(R.string.dialog_upload_file);
        builder.setPositiveButton(getString(android.R.string.ok),
              new DialogInterface.OnClickListener() {
                
          @Override
          public void onClick(DialogInterface dialog,
                int whichButton) {
             uploadUri(cacheUri);
                
             dialog.dismiss();
          }
              });
        builder.setNegativeButton(getString(android.R.string.cancel), null);
        builder.show();*/

        return;
    } else if (error instanceof FileNotFoundException) {
        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED_READ_ONLY)
                || Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
            errorDescription = R.string.toast_error_find_file;
        } else {
            errorDescription = R.string.toast_error_storage;
        }
    } else if (error instanceof IllegalArgumentException) {
        errorDescription = R.string.toast_error_illegal_file;
    } else if (error instanceof OutOfMemoryError) {
        errorDescription = R.string.toast_error_out_of_memory;
    } else {
        errorDescription = R.string.toast_error_generic;
    }

    showCrouton(errorDescription, null, AppMsg.STYLE_ALERT);

}

From source file:com.example.cuisoap.agrimac.homePage.machineDetail.driverInfoFragment.java

private void Unlock() {
    driver_male.setOnClickListener(myOnClickListener);
    driver_female.setOnClickListener(myOnClickListener);
    drive_type1.setOnClickListener(myOnClickListener);
    drive_type2.setOnClickListener(myOnClickListener);
    license_pic.setOnClickListener(myOnClickListener);
    driver_name.setInputType(InputType.TYPE_CLASS_TEXT);
    driver_name.setFocusableInTouchMode(true);
    driver_age.setInputType(InputType.TYPE_CLASS_TEXT);
    driver_age.setFocusableInTouchMode(true);
    if (drive_type.getCheckedRadioButtonId() == R.id.machine_drivetype_1)
        drive_type2.setEnabled(true);// ww w. j  a  va2s .c o  m
    else
        drive_type1.setEnabled(true);
    if (driver_gender.getCheckedRadioButtonId() == R.id.driver_male)
        driver_female.setEnabled(true);
    else
        driver_male.setEnabled(true);
    license_pic.setEnabled(true);
    license_type.setEnabled(true);
}

From source file:com.crearo.gpslogger.GpsMainActivity.java

public void setUpNavigationDrawer(Bundle savedInstanceState) {

    final DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, getToolbar(), R.string.navigation_drawer_open,
            R.string.navigation_drawer_close) {

        public void onDrawerClosed(View view) {
            invalidateOptionsMenu();//from   ww w  .  j  a  v  a2 s . c o  m
        }

        public void onDrawerOpened(View drawerView) {
            invalidateOptionsMenu();
        }
    };

    drawerHeader = new AccountHeaderBuilder().withActivity(this).withCompactStyle(true)
            .withAccountHeader(R.layout.smaller_header).withSavedInstance(savedInstanceState)
            .withProfileImagesVisible(false)
            .withHeaderBackground(new ColorDrawable(getResources().getColor(R.color.accentColor)))
            .withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() {

                @Override
                public boolean onProfileChanged(View view, IProfile profile, boolean currentProfile) {

                    //Add new profile
                    if (profile.getIdentifier() == 101) {
                        new MaterialDialog.Builder(GpsMainActivity.this)
                                .title(getString(R.string.profile_create_new))
                                .inputType(InputType.TYPE_CLASS_TEXT).negativeText(R.string.cancel)
                                .input("", "", false, new MaterialDialog.InputCallback() {
                                    @Override
                                    public void onInput(@NonNull MaterialDialog materialDialog,
                                            CharSequence charSequence) {
                                        String profileName = charSequence.toString().trim();
                                        if (!Strings.isNullOrEmpty(profileName)) {
                                            final String[] ReservedChars = { "|", "\\", "?", "*", "<", "\"",
                                                    ":", ">", ".", "/", "'", ";" };

                                            for (String c : ReservedChars) {
                                                profileName = profileName.replace(c, "");
                                            }

                                            EventBus.getDefault()
                                                    .post(new ProfileEvents.CreateNewProfile(profileName));
                                        }
                                    }
                                }).show();
                        return true;
                    }

                    //Clicked on profile name
                    String newProfileName = profile.getName().getText();
                    EventBus.getDefault().post(new ProfileEvents.SwitchToProfile(newProfileName));

                    refreshProfileIcon(profile.getName().getText());
                    return true;
                }
            })
            .withOnAccountHeaderItemLongClickListener(new AccountHeader.OnAccountHeaderItemLongClickListener() {
                @Override
                public boolean onProfileLongClick(View view, final IProfile iProfile, boolean b) {
                    if (iProfile.getIdentifier() > 150) {

                        if (preferenceHelper.getCurrentProfileName().equals(iProfile.getName().getText())) {
                            Dialogs.alert(getString(R.string.sorry),
                                    getString(R.string.profile_switch_before_delete), GpsMainActivity.this);
                        } else {
                            new MaterialDialog.Builder(GpsMainActivity.this)
                                    .title(getString(R.string.profile_delete))
                                    .content(iProfile.getName().getText()).positiveText(R.string.ok)
                                    .negativeText(R.string.cancel)
                                    .onPositive(new MaterialDialog.SingleButtonCallback() {
                                        @Override
                                        public void onClick(@NonNull MaterialDialog materialDialog,
                                                @NonNull DialogAction dialogAction) {
                                            EventBus.getDefault().post(new ProfileEvents.DeleteProfile(
                                                    iProfile.getName().getText()));
                                        }
                                    }).show();
                        }
                    }
                    return false;
                }
            }).build();

    populateProfilesList();

    materialDrawer = new DrawerBuilder().withActivity(this).withSavedInstance(savedInstanceState)
            .withToolbar(getToolbar()).withActionBarDrawerToggle(drawerToggle).withDrawerGravity(Gravity.LEFT)
            .withAccountHeader(drawerHeader).withSelectedItem(-1).build();

    materialDrawer.addItem(GpsLoggerDrawerItem.newPrimary(R.string.pref_general_title,
            R.string.pref_general_summary, R.drawable.settings, 1000));
    materialDrawer.addItem(GpsLoggerDrawerItem.newPrimary(R.string.pref_logging_title,
            R.string.pref_logging_summary, R.drawable.loggingsettings, 1001));
    materialDrawer.addItem(GpsLoggerDrawerItem.newPrimary(R.string.pref_performance_title,
            R.string.pref_performance_summary, R.drawable.performance, 1002));
    materialDrawer.addItem(new DividerDrawerItem());

    materialDrawer.addItem(GpsLoggerDrawerItem.newPrimary(R.string.pref_autosend_title,
            R.string.pref_autosend_summary, R.drawable.autosend, 1003));
    materialDrawer.addItem(
            GpsLoggerDrawerItem.newSecondary(R.string.gdocs_setup_title, R.drawable.googledrive, 1004));
    materialDrawer
            .addItem(GpsLoggerDrawerItem.newSecondary(R.string.dropbox_setup_title, R.drawable.dropbox, 1005));
    materialDrawer.addItem(GpsLoggerDrawerItem.newSecondary(R.string.autoemail_title, R.drawable.email, 1006));
    materialDrawer
            .addItem(GpsLoggerDrawerItem.newSecondary(R.string.autoftp_setup_title, R.drawable.ftp, 1007));
    materialDrawer
            .addItem(GpsLoggerDrawerItem.newSecondary(R.string.opengts_setup_title, R.drawable.opengts, 1008));
    materialDrawer.addItem(
            GpsLoggerDrawerItem.newSecondary(R.string.osm_setup_title, R.drawable.openstreetmap, 1009));
    materialDrawer.addItem(
            GpsLoggerDrawerItem.newSecondary(R.string.owncloud_setup_title, R.drawable.owncloud, 1010));
    materialDrawer.addItem(new DividerDrawerItem());

    materialDrawer
            .addStickyFooterItem(GpsLoggerDrawerItem.newSecondary(R.string.menu_faq, R.drawable.helpfaq, 1011));
    materialDrawer
            .addStickyFooterItem(GpsLoggerDrawerItem.newSecondary(R.string.menu_exit, R.drawable.exit, 1012));

    materialDrawer.setOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
        @Override
        public boolean onItemClick(View view, int i, IDrawerItem iDrawerItem) {

            switch (iDrawerItem.getIdentifier()) {
            case 1000:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.GENERAL);
                break;
            case 1001:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.LOGGING);
                break;
            case 1002:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.PERFORMANCE);
                break;
            case 1003:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.UPLOAD);
                break;
            case 1004:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.GDOCS);
                break;
            case 1005:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.DROPBOX);
                break;
            case 1006:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.EMAIL);
                break;
            case 1007:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.FTP);
                break;
            case 1008:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.OPENGTS);
                break;
            case 1009:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.OSM);
                break;
            case 1010:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.OWNCLOUD);
                break;
            case 1011:
                Intent faqtivity = new Intent(getApplicationContext(), Faqtivity.class);
                startActivity(faqtivity);
                break;
            case 1012:
                EventBus.getDefault().post(new CommandEvents.RequestStartStop(false));
                finish();
                break;

            }
            return false;
        }
    });

    ImageButton helpButton = (ImageButton) findViewById(R.id.imgHelp);
    helpButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent faqtivity = new Intent(getApplicationContext(), Faqtivity.class);
            startActivity(faqtivity);
        }
    });

}

From source file:org.runnerup.export.SyncManager.java

private void askUsernamePassword(final Synchronizer sync, boolean showPassword) {
    AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
    builder.setTitle(sync.getName());/*from   w  w  w .  j  a  v a 2s  . co m*/

    final View view = View.inflate(mActivity, R.layout.userpass, null);
    final CheckBox cb = (CheckBox) view.findViewById(R.id.showpass);
    final TextView tv1 = (TextView) view.findViewById(R.id.username);
    final TextView tv2 = (TextView) view.findViewById(R.id.password_input);
    final TextView tvAuthNotice = (TextView) view.findViewById(R.id.textViewAuthNotice);
    String authConfigStr = sync.getAuthConfig();
    final JSONObject authConfig = newObj(authConfigStr);
    String username = authConfig.optString("username", "");
    String password = authConfig.optString("password", "");
    tv1.setText(username);
    tv2.setText(password);
    cb.setChecked(showPassword);
    tv2.setInputType(InputType.TYPE_CLASS_TEXT | (showPassword ? 0 : InputType.TYPE_TEXT_VARIATION_PASSWORD));
    cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            tv2.setInputType(
                    InputType.TYPE_CLASS_TEXT | (isChecked ? 0 : InputType.TYPE_TEXT_VARIATION_PASSWORD));
        }
    });
    if (sync.getAuthNotice() != null) {
        tvAuthNotice.setVisibility(View.VISIBLE);
        tvAuthNotice.setText(sync.getAuthNotice());
    } else {
        tvAuthNotice.setVisibility(View.GONE);
    }

    // Inflate and set the layout for the dialog
    // Pass null as the parent view because its going in the dialog layout
    builder.setView(view);
    builder.setPositiveButton(getResources().getString(R.string.OK), new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            try {
                authConfig.put("username", tv1.getText());
                authConfig.put("password", tv2.getText());
            } catch (JSONException e) {
                e.printStackTrace();
            }
            testUserPass(sync, authConfig, cb.isChecked());
        }
    });
    builder.setNeutralButton("Skip", new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            handleAuthComplete(sync, Status.SKIP);
        }
    });
    builder.setNegativeButton(getResources().getString(R.string.Cancel), new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            handleAuthComplete(sync, Status.SKIP);
        }
    });
    builder.setOnKeyListener(new DialogInterface.OnKeyListener() {
        @Override
        public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
            if (i == KeyEvent.KEYCODE_BACK && keyEvent.getAction() == KeyEvent.ACTION_UP) {
                handleAuthComplete(sync, Status.CANCEL);
            }
            return false;
        }
    });
    final AlertDialog dialog = builder.create();
    dialog.show();
}

From source file:es.ugr.swad.swadroid.modules.tests.TestsMake.java

/**
 * Shows a test question on screen/*w  w w.  ja  v a  2  s  .c o m*/
 *
 * @param pos Question's position in questions's list of the test
 */
private void showQuestion(int pos) {
    TestQuestion question = test.getQuestions().get(pos);
    List<TestAnswer> answers = question.getAnswers();
    TestAnswer a;
    ScrollView scrollContent = (ScrollView) findViewById(R.id.testMakeScroll);
    LinearLayout testMakeList = (LinearLayout) findViewById(R.id.testMakeList);
    TextView stem = (TextView) findViewById(R.id.testMakeQuestionStem);
    TextView questionFeedback = (TextView) findViewById(R.id.testMakeQuestionFeedback);
    TextView answerFeedback = (TextView) findViewById(R.id.testMakeAnswerFeedback);
    TextView score = (TextView) findViewById(R.id.testMakeQuestionScore);
    TextView textCorrectAnswer = (TextView) findViewById(R.id.testMakeCorrectAnswer);
    EditText textAnswer = (EditText) findViewById(R.id.testMakeEditText);
    ImageView img = (ImageView) findViewById(R.id.testMakeCorrectAnswerImage);
    MenuItem actionScoreItem = menu.findItem(R.id.action_score);
    CheckedAnswersArrayAdapter checkedAnswersAdapter;
    String answerType = question.getAnswerType();
    String feedback = test.getFeedback();
    String questionFeedbackText = question.getFeedback();
    String correctAnswer = "";
    int numAnswers = answers.size();
    Float questionScore;
    DecimalFormat df = new DecimalFormat("0.00");
    int feedbackLevel;
    int mediumFeedbackLevel = Test.FEEDBACK_VALUES.indexOf(Test.FEEDBACK_MEDIUM);
    int maxFeedbackLevel = Test.FEEDBACK_VALUES.indexOf(Test.FEEDBACK_MAX);

    scrollContent.setOnTouchListener(new View.OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            findViewById(R.id.testMakeList).getParent().requestDisallowInterceptTouchEvent(false);
            return false;
        }
    });
    testMakeList.setOnTouchListener(new View.OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            // Disallow the touch request for parent scroll on touch of child view
            v.getParent().requestDisallowInterceptTouchEvent(true);
            return false;
        }
    });

    questionFeedback.setVisibility(View.GONE);
    answerFeedback.setVisibility(View.GONE);
    textAnswer.setVisibility(View.GONE);
    textCorrectAnswer.setVisibility(View.GONE);
    testMakeList.setVisibility(View.GONE);
    img.setVisibility(View.GONE);

    testMakeList.removeAllViews();
    stem.setText(Html.fromHtml(question.getStem()));

    if ((questionFeedbackText != null) && (!questionFeedbackText.equals(Constants.NULL_VALUE))) {
        questionFeedback.setText(Html.fromHtml(questionFeedbackText));
    }

    feedbackLevel = Test.FEEDBACK_VALUES.indexOf(feedback);

    if (test.isEvaluated() && (feedbackLevel == maxFeedbackLevel)
            && !question.getFeedback().equals(Constants.NULL_VALUE)) {
        questionFeedback.setVisibility(View.VISIBLE);
    } else {
        questionFeedback.setVisibility(View.GONE);
    }

    if (answerType.equals(TestAnswer.TYPE_TEXT) || answerType.equals(TestAnswer.TYPE_INT)
            || answerType.equals(TestAnswer.TYPE_FLOAT)) {

        if (answerType.equals(TestAnswer.TYPE_INT)) {
            textAnswer.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED);
        } else if (answerType.equals(TestAnswer.TYPE_FLOAT)) {
            textAnswer.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL
                    | InputType.TYPE_NUMBER_FLAG_SIGNED);
        } else {
            textAnswer.setInputType(InputType.TYPE_CLASS_TEXT);
        }

        a = answers.get(0);
        textAnswer.setText(a.getUserAnswer());
        textAnswer.setVisibility(View.VISIBLE);

        answerFeedback.setText(Html.fromHtml(a.getFeedback()));

        if (test.isEvaluated() && (feedbackLevel > mediumFeedbackLevel)) {
            if (answerType.equals(TestAnswer.TYPE_FLOAT)) {
                correctAnswer = "[" + a.getAnswer() + ";" + answers.get(1).getAnswer() + "]";

                if ((feedbackLevel == maxFeedbackLevel) && !a.getFeedback().equals(Constants.NULL_VALUE)) {
                    answerFeedback.setVisibility(View.VISIBLE);
                } else {
                    answerFeedback.setVisibility(View.GONE);
                }
            } else {
                for (int i = 0; i < numAnswers; i++) {
                    a = answers.get(i);

                    if ((feedbackLevel == maxFeedbackLevel) && !a.getFeedback().equals(Constants.NULL_VALUE)) {
                        correctAnswer += "<strong>" + a.getAnswer() + "</strong><br/>";
                        correctAnswer += "<i>" + a.getFeedback() + "</i><br/><br/>";
                    } else {
                        correctAnswer += a.getAnswer() + "<br/>";
                    }
                }
            }

            textCorrectAnswer.setText(Html.fromHtml(correctAnswer));
            textCorrectAnswer.setVisibility(View.VISIBLE);
        }
    } else if (answerType.equals(TestAnswer.TYPE_MULTIPLE_CHOICE)) {
        checkedAnswersAdapter = new CheckedAnswersArrayAdapter(this, R.layout.list_item_multiple_choice,
                answers, test.isEvaluated(), test.getFeedback(), answerType);

        for (int i = 0; i < numAnswers; i++) {
            a = answers.get(i);
            CheckableLinearLayout item = (CheckableLinearLayout) checkedAnswersAdapter.getView(i, null, null);
            item.setChecked(Utils.parseStringBool(a.getUserAnswer()));
            testMakeList.addView(item);
        }

        testMakeList.setVisibility(View.VISIBLE);
    } else {
        if (answerType.equals(TestAnswer.TYPE_TRUE_FALSE) && (numAnswers < 2)) {
            if (answers.get(0).getAnswer().equals(TestAnswer.VALUE_TRUE)) {
                answers.add(1,
                        new TestAnswer(0, 1, 0, false, TestAnswer.VALUE_FALSE, answers.get(0).getFeedback()));
            } else {
                answers.add(0,
                        new TestAnswer(0, 0, 0, false, TestAnswer.VALUE_TRUE, answers.get(0).getFeedback()));
            }

            numAnswers = 2;
        }

        checkedAnswersAdapter = new CheckedAnswersArrayAdapter(this, R.layout.list_item_single_choice, answers,
                test.isEvaluated(), test.getFeedback(), answerType);

        for (int i = 0; i < numAnswers; i++) {
            a = answers.get(i);
            CheckableLinearLayout item = (CheckableLinearLayout) checkedAnswersAdapter.getView(i, null, null);
            item.setChecked(a.getAnswer().equals(answers.get(0).getUserAnswer()));
            testMakeList.addView(item);
        }

        testMakeList.setVisibility(View.VISIBLE);
    }

    if (test.isEvaluated() && (feedbackLevel > mediumFeedbackLevel)) {
        textAnswer.setEnabled(false);
        textAnswer.setOnClickListener(null);

        if (feedback.equals(Test.FEEDBACK_HIGH)) {
            img.setImageResource(R.drawable.btn_check_buttonless_on);
            if (!answerType.equals(TestAnswer.TYPE_TRUE_FALSE)
                    && !answerType.equals(TestAnswer.TYPE_MULTIPLE_CHOICE)
                    && !answerType.equals(TestAnswer.TYPE_UNIQUE_CHOICE)) {

                if (!answers.get(0).isCorrectAnswered()) {
                    img.setImageResource(android.R.drawable.ic_delete);
                }

                img.setVisibility(View.VISIBLE);
            }
        }

        questionScore = test.getQuestionScore(pos);
        if (questionScore > 0) {
            score.setTextColor(getResources().getColor(R.color.green));
        } else if (questionScore < 0) {
            score.setTextColor(getResources().getColor(R.color.red));
        } else {
            score.setTextColor(Color.BLACK);
        }

        score.setText(df.format(questionScore));

        MenuItemCompat.setActionView(actionScoreItem, score);
        actionScoreItem.setVisible(true);
    }
}

From source file:nl.hnogames.domoticz.QRCodeSettingsActivity.java

public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (data != null && resultCode == RESULT_OK) {
        final String QR_Code_ID = data.getStringExtra("QRCODE");

        boolean newTagFound = true;
        if (qrcodeList != null && qrcodeList.size() > 0) {
            for (QRCodeInfo n : qrcodeList) {
                if (n.getId().equals(QR_Code_ID))
                    newTagFound = false;
            }/*from ww w .j a va  2 s  .c o m*/
        }

        if (newTagFound) {
            UsefulBits.showSnackbar(this, coordinatorLayout,
                    getString(R.string.qrcode_found) + ": " + QR_Code_ID, Snackbar.LENGTH_SHORT);
            new MaterialDialog.Builder(this).title(R.string.qrcode_found).content(R.string.qrcode_name)
                    .inputType(InputType.TYPE_CLASS_TEXT)
                    .input(R.string.category_QRCode, 0, new MaterialDialog.InputCallback() {
                        @Override
                        public void onInput(@NonNull MaterialDialog dialog, CharSequence input) {
                            if (!UsefulBits.isEmpty(String.valueOf(input))) {
                                UsefulBits.showSnackbar(QRCodeSettingsActivity.this, coordinatorLayout,
                                        getString(R.string.qrcode_saved) + ": " + input, Snackbar.LENGTH_SHORT);
                                QRCodeInfo qrCodeInfo = new QRCodeInfo();
                                qrCodeInfo.setId(QR_Code_ID);
                                qrCodeInfo.setName(String.valueOf(input));
                                updateQRCode(qrCodeInfo);
                            }
                        }
                    }).show();
        } else {
            UsefulBits.showSnackbar(this, coordinatorLayout, R.string.qrcode_exists, Snackbar.LENGTH_SHORT);
        }
    }
    permissionHelper.onActivityForResult(requestCode);
}