Java Code Examples for android.widget.EditText#setImeOptions()

The following examples show how to use android.widget.EditText#setImeOptions() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QueryRequestActivity.java    From commcare-android with Apache License 2.0 6 votes vote down vote up
private void buildPromptEntry(LinearLayout promptsLayout, String promptId,
                              DisplayUnit displayUnit, boolean isLastPrompt) {
    Hashtable<String, String> userAnswers =
            remoteQuerySessionManager.getUserAnswers();
    promptsLayout.addView(createPromptMedia(displayUnit));

    EditText promptEditText = new EditText(this);
    if (userAnswers.containsKey(promptId)) {
        promptEditText.setText(userAnswers.get(promptId));
    }
    promptEditText.setBackgroundResource(R.drawable.login_edit_text);
    // needed to allow 'done' and 'next' keyboard action
    promptEditText.setSingleLine();

    if (isLastPrompt) {
        promptEditText.setImeOptions(EditorInfo.IME_ACTION_DONE);
    } else {
        // replace 'done' on keyboard with 'next'
        promptEditText.setImeOptions(EditorInfo.IME_ACTION_NEXT);
    }
    promptsLayout.addView(promptEditText);
    promptsBoxes.put(promptId, promptEditText);
}
 
Example 2
Source File: ValidatedEditTextPreference.java    From oversec with GNU General Public License v3.0 6 votes vote down vote up
private void initialize(AttributeSet attrs) {
	// setup edit text
	mEditText = new EditText(getContext(), attrs);
	mEditText.setImeOptions(EditorInfo.IME_ACTION_DONE);
	mEditText.setEnabled(true);
	mEditText.setLayoutParams(new ViewGroup.LayoutParams(
			ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
	
	// setup layout for edit text
	int dip = (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10,
			getContext().getResources().getDisplayMetrics()) + 0.5f);
	
	mEditTextlayout = new LinearLayout(getContext());
	mEditTextlayout.setLayoutParams(new ViewGroup.LayoutParams(
			ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
	mEditTextlayout.setPadding(dip, dip, dip, dip);
	mEditTextlayout.addView(mEditText);
}
 
Example 3
Source File: DialogHelper.java    From Onosendai with Apache License 2.0 6 votes vote down vote up
public static void askString (final Context context, final String msg,
		final String oldValue, final boolean multiLine, final boolean spellCheck,
		final Listener<String> onString) {
	final AlertDialog.Builder dlgBld = new AlertDialog.Builder(context);
	dlgBld.setMessage(msg);
	final EditText editText = new EditText(context);
	editText.setSelectAllOnFocus(true);
	if (oldValue != null) editText.setText(oldValue);
	if (!multiLine) editText.setSingleLine();
	if (!spellCheck) editText.setInputType(editText.getInputType() | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
	editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
	dlgBld.setView(editText);
	dlgBld.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
		@Override
		public void onClick (final DialogInterface dialog, final int which) {
			dialog.dismiss();
			onString.onAnswer(editText.getText().toString().trim());
		}
	});
	dlgBld.setNegativeButton(android.R.string.cancel, DLG_CANCEL_CLICK_LISTENER);
	dlgBld.show();
}
 
Example 4
Source File: TimelineActivity.java    From twittererer with Apache License 2.0 6 votes vote down vote up
private void showNewTweetDialog() {
    final EditText tweetText = new EditText(this);
    tweetText.setId(R.id.tweet_text);
    tweetText.setSingleLine();
    tweetText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
    tweetText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(140)});
    tweetText.setImeOptions(EditorInfo.IME_ACTION_DONE);

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(R.string.label_what_is_happening);
    builder.setPositiveButton(R.string.action_tweet, (dialog, which) -> presenter.tweet(tweetText.getText().toString()));

    AlertDialog alert = builder.create();
    alert.setView(tweetText, 64, 0, 64, 0);
    alert.show();

    tweetText.setOnEditorActionListener((v, actionId, event) -> {
        if (actionId == EditorInfo.IME_ACTION_DONE) {
            alert.getButton(DialogInterface.BUTTON_POSITIVE).callOnClick();
            return true;
        }
        return false;
    });
}
 
Example 5
Source File: EnterPhoneNumberFragment.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
private void setUpNumberInput() {
  EditText numberInput = number.getInput();

  numberInput.addTextChangedListener(new NumberChangedListener());

  number.setOnFocusChangeListener((v, hasFocus) -> {
    if (hasFocus) {
      scrollView.postDelayed(() -> scrollView.smoothScrollTo(0, register.getBottom()), 250);
    }
  });

  numberInput.setImeOptions(EditorInfo.IME_ACTION_DONE);
  numberInput.setOnEditorActionListener((v, actionId, event) -> {
    if (actionId == EditorInfo.IME_ACTION_DONE) {
      hideKeyboard(requireContext(), v);
      handleRegister(requireContext());
      return true;
    }
    return false;
  });
}
 
Example 6
Source File: AnagramsActivity.java    From jterm-cswithandroid with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_anagrams);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    AssetManager assetManager = getAssets();
    try {
        InputStream inputStream = assetManager.open("words.txt");
        dictionary = new AnagramDictionary(inputStream);
    } catch (IOException e) {
        Toast toast = Toast.makeText(this, "Could not load dictionary", Toast.LENGTH_LONG);
        toast.show();
    }
    // Set up the EditText box to process the content of the box when the user hits 'enter'
    final EditText editText = (EditText) findViewById(R.id.editText);
    editText.setRawInputType(InputType.TYPE_CLASS_TEXT);
    editText.setImeOptions(EditorInfo.IME_ACTION_GO);
    editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            boolean handled = false;
            if (actionId == EditorInfo.IME_ACTION_GO) {
                processWord(editText);
                handled = true;
            }
            return handled;
        }
    });
}
 
Example 7
Source File: DialogUtils.java    From RedReader with GNU General Public License v3.0 5 votes vote down vote up
public static void showSearchDialog (Context context, int titleRes, final OnSearchListener listener) {
	final AlertDialog.Builder alertBuilder = new AlertDialog.Builder(context);
	final EditText editText = (EditText) LayoutInflater.from(context).inflate(R.layout.dialog_editbox, null);

	TextView.OnEditorActionListener onEnter = new TextView.OnEditorActionListener() {
		@Override
		public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
			performSearch(editText, listener);
			return true;
		}
	};
	editText.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
	editText.setOnEditorActionListener(onEnter);

	alertBuilder.setView(editText);
	alertBuilder.setTitle(titleRes);

	alertBuilder.setPositiveButton(R.string.action_search, new DialogInterface.OnClickListener() {
		@Override
		public void onClick(DialogInterface dialog, int which) {
			performSearch(editText, listener);
		}
	});

	alertBuilder.setNegativeButton(R.string.dialog_cancel, null);

	final AlertDialog alertDialog = alertBuilder.create();
	alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
	alertDialog.show();
}
 
Example 8
Source File: ViewMatchersTest.java    From android-test with Apache License 2.0 5 votes vote down vote up
@UiThreadTest
@Test
public void hasImeActionTest() {
  EditText editText = new EditText(context);
  assertFalse(hasImeAction(EditorInfo.IME_ACTION_GO).matches(editText));
  editText.setImeOptions(EditorInfo.IME_ACTION_NEXT);
  assertFalse(hasImeAction(EditorInfo.IME_ACTION_GO).matches(editText));
  assertTrue(hasImeAction(EditorInfo.IME_ACTION_NEXT).matches(editText));
}
 
Example 9
Source File: DialogHelper.java    From matlog with GNU General Public License v3.0 5 votes vote down vote up
public static void initFilenameInputDialog(MaterialDialog show) {
    final EditText editText = show.getInputEditText();
    editText.setSingleLine();
    editText.setInputType(InputType.TYPE_TEXT_VARIATION_FILTER);
    editText.setImeOptions(EditorInfo.IME_ACTION_DONE);

    // create an initial filename to suggest to the user
    String filename = createLogFilename();
    editText.setText(filename);

    // highlight everything but the .txt at the end
    editText.setSelection(0, filename.length() - 4);
}
 
Example 10
Source File: TimePickerTextInputKeyController.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
/** Prepare Text inputs to receive key events and IME actions. */
public void bind() {
  TextInputLayout hourLayout = hourLayoutComboView.getTextInput();
  TextInputLayout minuteLayout = minuteLayoutComboView.getTextInput();
  EditText hourEditText = hourLayout.getEditText();
  EditText minuteEditText = minuteLayout.getEditText();

  hourEditText.setImeOptions(IME_ACTION_NEXT | IME_FLAG_NO_EXTRACT_UI);
  minuteEditText.setImeOptions(IME_ACTION_DONE | IME_FLAG_NO_EXTRACT_UI);

  hourEditText.setOnEditorActionListener(this);
  hourEditText.setOnKeyListener(this);
  minuteEditText.setOnKeyListener(this);
}
 
Example 11
Source File: AnagramsActivity.java    From jterm-cswithandroid with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_anagrams);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    AssetManager assetManager = getAssets();
    try {
        InputStream inputStream = assetManager.open("words.txt");
        dictionary = new AnagramDictionary(inputStream);
    } catch (IOException e) {
        Toast toast = Toast.makeText(this, "Could not load dictionary", Toast.LENGTH_LONG);
        toast.show();
    }
    // Set up the EditText box to process the content of the box when the user hits 'enter'
    final EditText editText = (EditText) findViewById(R.id.editText);
    editText.setRawInputType(InputType.TYPE_CLASS_TEXT);
    editText.setImeOptions(EditorInfo.IME_ACTION_GO);
    editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            boolean handled = false;
            if (actionId == EditorInfo.IME_ACTION_GO) {
                processWord(editText);
                handled = true;
            }
            return handled;
        }
    });
}
 
Example 12
Source File: LabelDetailsFragment.java    From science-journal with Apache License 2.0 5 votes vote down vote up
protected void setupCaption(View rootView) {
  caption = (EditText) rootView.findViewById(R.id.caption);
  caption.setText(originalLabel.getCaptionText());
  caption.setImeOptions(EditorInfo.IME_ACTION_DONE);
  caption.setRawInputType(InputType.TYPE_CLASS_TEXT);
  caption.setOnEditorActionListener(
      (textView, i, keyEvent) -> {
        if (i == EditorInfo.IME_ACTION_DONE) {
          caption.clearFocus();
          caption.setFocusable(false);
        }
        return false;
      });
  caption.setOnTouchListener(
      (v, motionEvent) -> {
        caption.setFocusableInTouchMode(true);
        caption.requestFocus();
        return false;
      });

  caption.setEnabled(false);
  experiment
      .firstElement()
      .subscribe(
          experiment -> {
            caption.setEnabled(true);
            // Move the cursor to the end
            caption.post(() -> caption.setSelection(caption.getText().toString().length()));

            saved
                .happens()
                .subscribe(o -> saveCaptionChanges(experiment, caption.getText().toString()));
          });
}
 
Example 13
Source File: GeocodingBaseActivity.java    From mobile-android-samples with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    inputField = new EditText(this);
    inputField.setTextColor(Color.WHITE);
    inputField.setBackgroundColor(Colors.DARK_TRANSPARENT_GRAY);
    inputField.setHint("Type address...");
    inputField.setHintTextColor(Color.LTGRAY);
    inputField.setSingleLine();
    inputField.setImeOptions(EditorInfo.IME_ACTION_DONE);

    int totalWidth = getResources().getDisplayMetrics().widthPixels;
    int padding = (int)(5 * getResources().getDisplayMetrics().density);

    int width = totalWidth - 2 * padding;
    int height = (int)(45 * getResources().getDisplayMetrics().density);

    RelativeLayout.LayoutParams parameters = new RelativeLayout.LayoutParams(width, height);
    parameters.setMargins(padding, padding, 0, 0);
    addContentView(inputField, parameters);

    resultTable = new ListView(this);
    resultTable.setBackgroundColor(Colors.LIGHT_TRANSPARENT_GRAY);

    height = (int)(200 * getResources().getDisplayMetrics().density);

    parameters = new RelativeLayout.LayoutParams(width, height);
    parameters.setMargins(padding, 2 * padding + inputField.getLayoutParams().height, 0, 0);

    addContentView(resultTable, parameters);

    adapter = new GeocodingResultAdapter(this);
    adapter.width = width;
    resultTable.setAdapter(adapter);

    hideTable();
}
 
Example 14
Source File: BoardItemListFragment.java    From mimi-reader with Apache License 2.0 5 votes vote down vote up
private void showAddBoardDialog() {
    if (getActivity() == null) {
        return;
    }

    final MaterialAlertDialogBuilder alertBuilder = new MaterialAlertDialogBuilder(getActivity());
    final EditText input = new EditText(getActivity());

    input.setHint(R.string.board_name_input_hint);
    input.setSingleLine();
    input.setImeOptions(EditorInfo.IME_ACTION_DONE);

    alertBuilder.setView(input);
    alertBuilder.setPositiveButton(R.string.add, (dialog, which) -> addBoard(input.getText().toString()));
    alertBuilder.setNegativeButton(R.string.cancel, (dialog, which) -> Log.v(LOG_TAG, "Cancelled adding a board"));

    alertBuilder.setTitle(R.string.add_board);

    AlertDialog d = alertBuilder.create();
    d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    d.show();

    input.setOnEditorActionListener((v, actionId, event) -> {
        if (actionId == EditorInfo.IME_ACTION_DONE) {
            addBoard(input.getText().toString());
            d.dismiss();
        }
        return true;
    });
}
 
Example 15
Source File: DialogHelper.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public static void initFilenameInputDialog(MaterialDialog show) {
    final EditText editText = show.getInputEditText();
    editText.setSingleLine();
    editText.setInputType(InputType.TYPE_TEXT_VARIATION_FILTER);
    editText.setImeOptions(EditorInfo.IME_ACTION_DONE);

    // create an initial filename to suggest to the user
    String filename = createLogFilename();
    editText.setText(filename);

    // highlight everything but the .txt at the end
    editText.setSelection(0, filename.length() - 4);
}
 
Example 16
Source File: AuthenticatorActivity.java    From Cirrus_depricated with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 
 * @param savedInstanceState        Saved activity state, as in {{@link #onCreate(Bundle)}
 */
private void initAuthorizationPreFragment(Bundle savedInstanceState) {
    
    /// step 0 - get UI elements in layout
    mOAuth2Check = (CheckBox) findViewById(R.id.oauth_onOff_check);
    mOAuthAuthEndpointText = (TextView)findViewById(R.id.oAuthEntryPoint_1);
    mOAuthTokenEndpointText = (TextView)findViewById(R.id.oAuthEntryPoint_2);
    mUsernameInput = (EditText) findViewById(R.id.account_username);
    mPasswordInput = (EditText) findViewById(R.id.account_password);
    mPasswordInput.setTypeface(mUsernameInput.getTypeface());
    mAuthStatusView = (TextView) findViewById(R.id.auth_status_text); 
    
    /// step 1 - load and process relevant inputs (resources, intent, savedInstanceState)
    String presetUserName = null;
    boolean isPasswordExposed = false;
    if (savedInstanceState == null) {
        if (mAccount != null) {
            presetUserName = mAccount.name.substring(0, mAccount.name.lastIndexOf('@'));
        }
        
    } else {
        isPasswordExposed = savedInstanceState.getBoolean(KEY_PASSWORD_EXPOSED, false);
        mAuthStatusText = savedInstanceState.getInt(KEY_AUTH_STATUS_TEXT);
        mAuthStatusIcon = savedInstanceState.getInt(KEY_AUTH_STATUS_ICON);
        mAuthToken = savedInstanceState.getString(KEY_AUTH_TOKEN);
    }
    
    /// step 2 - set properties of UI elements (text, visibility, enabled...)
    mOAuth2Check.setChecked(
            AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType())
                .equals(mAuthTokenType));
    if (presetUserName != null) {
        mUsernameInput.setText(presetUserName);
    }
    if (mAction != ACTION_CREATE) {
        mUsernameInput.setEnabled(false);
        mUsernameInput.setFocusable(false);
    }
    mPasswordInput.setText(""); // clean password to avoid social hacking
    if (isPasswordExposed) {
        showPassword();
    }
    updateAuthenticationPreFragmentVisibility();
    showAuthStatus();
    mOkButton.setEnabled(mServerIsValid);

    
    /// step 3 - bind listeners
    // bindings for password input field
    mPasswordInput.setOnFocusChangeListener(this);
    mPasswordInput.setImeOptions(EditorInfo.IME_ACTION_DONE);
    mPasswordInput.setOnEditorActionListener(this);
    mPasswordInput.setOnTouchListener(new RightDrawableOnTouchListener() {
        @Override
        public boolean onDrawableTouch(final MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_UP) {
                AuthenticatorActivity.this.onViewPasswordClick();
            }
            return true;
        }
    });
    
}
 
Example 17
Source File: LoginActivity.java    From CameraV with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	packageName = this.getPackageName();

	setContentView(R.layout.activity_login);
	rootView = findViewById(R.id.llRoot);
	
	boolean prefStealthIcon = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("prefStealthIcon",false);
	if (prefStealthIcon)
	{
		ImageView iv = (ImageView)findViewById(R.id.loginLogo);
		iv.setImageResource(R.drawable.ic_launcher_alt);
	}

	password = (EditText) findViewById(R.id.login_password);
	password.setImeOptions(EditorInfo.IME_ACTION_DONE);
	password.setOnEditorActionListener(new OnEditorActionListener ()
	{
		@Override
		public boolean onEditorAction(TextView arg0, int actionId, KeyEvent event) {
			 if (actionId == EditorInfo.IME_ACTION_SEARCH ||
		                actionId == EditorInfo.IME_ACTION_DONE ||
		                event.getAction() == KeyEvent.ACTION_DOWN &&
		                event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {			
						doLogin ();
						
					}
				   return true;
		}
		
	});

	/**
	commit = (Button) findViewById(R.id.login_commit);
	commit.setOnClickListener(this);
	*/

	waiter = (ProgressBar) findViewById(R.id.login_waiter);
	
	checkForCrashes();
	checkForUpdates();
}
 
Example 18
Source File: LocalIMEKeyboard.java    From WaniKani-for-Android with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor
 * @param wav parent activity
 * @param wv the integrated browser
 */
public LocalIMEKeyboard (WebReviewActivity wav, FocusWebView wv)
{
    Resources res;

    this.wav = wav;
    this.wv = wv;

    editable = true;
    bpos = new BoxPosition ();

    imm = (InputMethodManager) wav.getSystemService (Context.INPUT_METHOD_SERVICE);

    disableSuggestions = PrefManager.getNoSuggestion() | PrefManager.getRomaji();

    dm = wav.getResources ().getDisplayMetrics ();

    ime = new JapaneseIME ();

    ew = (EditText) wav.findViewById (R.id.ime);
    divw = wav.findViewById (R.id.ime_div);
    imel = new IMEListener ();
    ew.addTextChangedListener (imel);
    ew.setInputType (InputType.TYPE_CLASS_TEXT);
    ew.setOnEditorActionListener (imel);
    ew.setGravity (Gravity.CENTER);
    ew.setImeActionLabel (">>", EditorInfo.IME_ACTION_DONE);
    ew.setImeOptions (EditorInfo.IME_ACTION_DONE);

    qvw = (TextView) wav.findViewById (R.id.txt_question_override);

    next = (Button) wav.findViewById (R.id.ime_next);
    next.setOnClickListener (imel);

    srsv = wav.findViewById (R.id.v_srs);

    jsl = new JSListener ();
    wv.addJavascriptInterface (jsl, "wknJSListener");

    wki = new WaniKaniImprove (wav, wv);
    wv.registerListener (new WebViewListener ());

    res = wav.getResources ();
    correctFG = res.getColor (R.color.correctfg);
    incorrectFG = res.getColor (R.color.incorrectfg);
    ignoredFG = res.getColor (R.color.ignoredfg);

    setupSRSColors (res);

    correctBG = R.drawable.card_reviews_edittext_correct;
    incorrectBG = R.drawable.card_reviews_edittext_incorrect;
    ignoredBG = R.drawable.card_reviews_edittext_ignored;

    cmap = new EnumMap<WaniKaniItem.Type, Integer> (WaniKaniItem.Type.class);
    cmap.put (WaniKaniItem.Type.RADICAL, res.getColor (R.color.wanikani_radical));
    cmap.put (WaniKaniItem.Type.KANJI, res.getColor (R.color.wanikani_kanji));
    cmap.put (WaniKaniItem.Type.VOCABULARY, res.getColor (R.color.wanikani_vocabulary));
}
 
Example 19
Source File: AlgDialog.java    From TwistyTimer with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onClick(View view) {
    final DatabaseHandler dbHandler = TwistyTimer.getDBHandler();

    switch (view.getId()) {
        case R.id.editButton:
            MaterialDialog dialog = ThemeUtils.roundDialog(mContext, new MaterialDialog.Builder(mContext)
                    .title(R.string.edit_algorithm)
                    .input("", algorithm.getAlgs(), (dialog1, input) -> {
                        algorithm.setAlgs(input.toString());
                        dbHandler.updateAlgorithmAlg(mId, input.toString());
                        algText.setText(input.toString());
                        updateList();
                    })
                    .inputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE)
                    .positiveText(R.string.action_done)
                    .negativeText(R.string.action_cancel)
                    .build());
            EditText editText = dialog.getInputEditText();
            if (editText != null) {
                editText.setSingleLine(false);
                editText.setLines(5);
                editText.setImeOptions(EditorInfo.IME_FLAG_NO_ENTER_ACTION);
                editText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
            }
            dialog.show();
            break;

        case R.id.progressButton:
            final AppCompatSeekBar seekBar = (AppCompatSeekBar) LayoutInflater.from(mContext).inflate(R.layout.dialog_progress, null);
            seekBar.setProgress(algorithm.getProgress());
            ThemeUtils.roundAndShowDialog(mContext, new MaterialDialog.Builder(mContext)
                    .title(R.string.dialog_set_progress)
                    .customView(seekBar, false)
                    .positiveText(R.string.action_update)
                    .negativeText(R.string.action_cancel)
                    .onPositive((dialog12, which) -> {
                        int seekProgress = seekBar.getProgress();
                        algorithm.setProgress(seekProgress);
                        dbHandler.updateAlgorithmProgress(mId, seekProgress);
                        progressBar.setProgress(seekProgress);
                        updateList();
                    })
                    .build());
            break;

        case R.id.revertButton:
            ThemeUtils.roundAndShowDialog(mContext, new MaterialDialog.Builder(mContext)
                    .title(R.string.dialog_revert_title_confirmation)
                    .content(R.string.dialog_revert_content_confirmation)
                    .positiveText(R.string.action_reset)
                    .negativeText(R.string.action_cancel)
                    .onPositive((dialog13, which) -> {
                        algorithm.setAlgs(AlgUtils.getDefaultAlgs(algorithm.getSubset(), algorithm.getName()));
                        dbHandler.updateAlgorithmAlg(mId, algorithm.getAlgs());
                        algText.setText(algorithm.getAlgs());
                    })
                    .build());
            break;
    }
}
 
Example 20
Source File: BblContentFragment.java    From BubbleAlert with MIT License 4 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    clickHandler = new ClickHandler(this);

    txtDialogTitle = (TextView) view.findViewById(R.id.txtDialogTitle);
    txtContent = (TextView) view.findViewById(R.id.txtContent);
    btnOk = (TextView) view.findViewById(R.id.btnOk);
    btnExit = (TextView) view.findViewById(R.id.btnExit);
    btnCancel = (TextView) view.findViewById(R.id.btnCancel);
    edtLibName = (EditText) view.findViewById(R.id.edtLibName);

    btnOk.setOnClickListener(clickHandler);
    btnExit.setOnClickListener(clickHandler);
    btnCancel.setOnClickListener(clickHandler);

    txtContent.setText(content);
    btnOk.setText(ok);
    btnCancel.setText(cancel);
    btnExit.setText(exit);
    if (!TextUtils.isEmpty(sDialogTitle)) {
        txtDialogTitle.setText(sDialogTitle);
    }

    if (btnCount == 1) {
        btnCancel.setVisibility(View.GONE);
    } else if (btnCount == 3) {
        btnExit.setVisibility(View.VISIBLE);
    }

    int visibility = hasEditText ? View.VISIBLE : View.GONE;

    edtLibName.setVisibility(visibility);
    if (!TextUtils.isEmpty(textContent)) {

        edtLibName.setText(textContent);
    }

    if (!TextUtils.isEmpty(hintText)) {

        edtLibName.setHint(hintText);
    }

    if (isMultiLineEditText) {
        edtLibName.setMaxLines(1);
        edtLibName.setImeOptions(EditorInfo.IME_FLAG_NO_ENTER_ACTION);
        edtLibName.setScroller(new Scroller(getContext()));
        edtLibName.setVerticalScrollBarEnabled(true);
        edtLibName.setMovementMethod(new ScrollingMovementMethod());
    }

}