use of android.support.v7.widget.AppCompatEditText in project vlc-android by GeoffreyMetais.
the class FileBrowserFragment method showAddDirectoryDialog.
public void showAddDirectoryDialog() {
final Context context = getActivity();
AlertDialog.Builder builder = new AlertDialog.Builder(context);
final AppCompatEditText input = new AppCompatEditText(context);
input.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
builder.setTitle(R.string.add_custom_path);
builder.setMessage(R.string.add_custom_path_description);
builder.setView(input);
builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int which) {
}
});
builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String path = input.getText().toString().trim();
File f = new File(path);
if (!f.exists() || !f.isDirectory()) {
UiTools.snacker(getView(), getString(R.string.directorynotfound, path));
return;
}
try {
CustomDirectories.addCustomDirectory(f.getCanonicalPath());
((AudioPlayerContainerActivity) getActivity()).updateLib();
} catch (IOException ignored) {
}
}
});
mAlertDialog = builder.show();
}
use of android.support.v7.widget.AppCompatEditText in project fuckView by w568w.
the class PreferencesActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("theme", false)) {
setTheme(R.style.DayTheme);
}
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preference);
findPreference("super_mode").setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
MainActivity.writePreferences(o.toString(), SUPER_MODE_NAME);
return true;
}
});
findPreference("only_once").setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
MainActivity.writePreferences(newValue.toString(), ONLY_ONCE_NAME);
return true;
}
});
findPreference("standard_mode").setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
MainActivity.writePreferences(newValue.toString(), STANDARD_MODE_NAME);
return true;
}
});
findPreference("import").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
final AppCompatEditText editText = new AppCompatEditText(PreferencesActivity.this);
editText.setHint(R.string.import_rules);
new AlertDialog.Builder(PreferencesActivity.this).setTitle(R.string.conf_import_rules_name).setView(editText).setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
MainActivity.appendPreferences("\n" + editText.getText().toString(), MainActivity.LIST_NAME);
}
}).setNegativeButton(R.string.cancel, null).show();
return false;
}
});
findPreference("online_rules").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
setResult(RESULT_OK);
finish();
return false;
}
});
findPreference("about").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
clickTime++;
if (clickTime >= 5 * 59) {
clickTime = 0;
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getPackageName())));
} catch (Throwable ignored) {
}
Toast.makeText(PreferencesActivity.this, R.string.give_me_five_stars, Toast.LENGTH_LONG).show();
}
preference.setSummary(String.format(Locale.CHINA, getString(R.string.conf_joke), clickTime / 59, clickTime % 59));
return false;
}
});
findPreference("version").setSummary(getVersionName(this));
findPreference("pay").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Toast.makeText(PreferencesActivity.this, R.string.no_donate, Toast.LENGTH_SHORT).show();
return false;
}
});
findPreference("source").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
new AlertDialog.Builder(PreferencesActivity.this).setTitle("Open Source").setMessage("Nothing").setPositiveButton(getString(R.string.OK), null).show();
return false;
}
});
findPreference("qq").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://jq.qq.com/?_wv=1027&k=4EepPOs")));
} catch (Throwable ignored) {
}
return false;
}
});
findPreference("guide").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://w568.wodemo.net/entry/467891")));
} catch (ActivityNotFoundException a) {
a.printStackTrace();
Toast.makeText(PreferencesActivity.this, getString(R.string.unsupport_of_package), Toast.LENGTH_SHORT).show();
}
return false;
}
});
findPreference("log").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
new Thread(new Runnable() {
@Override
public void run() {
final String bug = String.format(Locale.CHINA, "Logcat:\n\n%s\n\n" + "=================\n\n" + "XposedLog:\n\n%s\n\n" + "=================\n\n" + "Phone:\n\n%s\n\n", getLogcatInfo(), getXposedLogInfo(), getPhoneInfo());
runOnUiThread(new Runnable() {
@Override
public void run() {
shareText(bug);
}
});
}
}).start();
return false;
}
});
findPreference("theme").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
finish();
Intent restart = new Intent(PreferencesActivity.this, MainActivity.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
restart.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
} else {
restart.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
startActivity(restart);
return false;
}
});
findPreference("enable_log").setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
MainActivity.writePreferences(newValue.toString(), ENABLE_LOG_NAME);
return true;
}
});
}
use of android.support.v7.widget.AppCompatEditText in project krypton-android by kryptco.
the class SelectIndividualsFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.fragment_teams_individual_emails_invite, container, false);
ArrayAdapter emailsAdapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_list_item_1, new ArrayList<>());
ListViewCompat emailsList = rootView.findViewById(R.id.emailResultsList);
AppCompatEditText emailText = rootView.findViewById(R.id.emailAddInput);
AppCompatImageButton addButton = rootView.findViewById(R.id.addEmailButton);
createButton = rootView.findViewById(R.id.createIndividualLink);
cancelButton = rootView.findViewById(R.id.cancelIndividualLinkButton);
emailsList.setAdapter(emailsAdapter);
addButton.setEnabled(false);
addButton.setOnClickListener(v -> {
emailsAdapter.add(emailText.getText().toString());
emailText.setText("");
createButton.setEnabled(emailsAdapter.getCount() > 0);
});
Email.colorValidEmail(emailText);
emailText.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) {
addButton.setEnabled(Email.verifyEmailPattern.matcher(s.toString()).matches());
}
});
createButton.setEnabled(false);
createButton.setOnClickListener(v -> {
List<String> emails = new ArrayList<String>();
for (int i = 0; i < emailsAdapter.getCount(); i++) {
emails.add((String) emailsAdapter.getItem(i));
}
inviteRestriction = new Sigchain.IndirectInvitationRestriction(emails.toArray(new String[0]));
EventBus.getDefault().post(new TeamService.RequestTeamOperation(new Sigchain.RequestableTeamOperation(inviteRestriction), C.withConfirmStatusCallback(getActivity(), this::onCreateInvite)));
});
cancelButton.setOnClickListener(v -> {
getFragmentManager().popBackStack();
});
return rootView;
}
use of android.support.v7.widget.AppCompatEditText in project Roblu by wdavies973.
the class MetricEditor method getConfigField.
/**
* Generates a configuration field for the layout with the specified settings.
* The config field will detect the instance type of RMetric metric above and decide
* what to update. Acceptable names:
* -"title"
* -"min"
* -"max"
* -"increment"
* -"comma"
*/
private TextInputLayout getConfigField(final String name, RelativeLayout layout, int position) {
TextInputLayout inputLayout = new TextInputLayout(this);
inputLayout.setHint(name);
inputLayout.setId(Utils.generateViewId());
AppCompatEditText nameInput = new AppCompatEditText(this);
Utils.setInputTextLayoutColor(rui.getAccent(), inputLayout, nameInput);
nameInput.setTextColor(rui.getText());
nameInput.setHighlightColor(rui.getAccent());
nameInput.setId(Utils.generateViewId());
if (name.equalsIgnoreCase("minimum")) {
nameInput.setInputType(InputType.TYPE_CLASS_NUMBER);
if (metric instanceof RSlider)
nameInput.setText(String.valueOf(((RSlider) metric).getMin()));
} else if (name.equalsIgnoreCase("maximum")) {
nameInput.setInputType(InputType.TYPE_CLASS_NUMBER);
if (metric instanceof RSlider)
nameInput.setText(String.valueOf(((RSlider) metric).getMax()));
} else if (name.equalsIgnoreCase("increment")) {
nameInput.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
if (metric instanceof RCounter)
nameInput.setText(String.valueOf(((RCounter) metric).getIncrement()));
} else if (name.equalsIgnoreCase("calculation")) {
if (metric instanceof RCalculation)
nameInput.setText(((RCalculation) metric).getCalculation());
} else if (name.startsWith("Comma separated list")) {
if (metric instanceof RCheckbox) {
StringBuilder text = new StringBuilder();
RCheckbox checkbox = ((RCheckbox) metric);
if (checkbox.getValues() != null) {
for (Object o : checkbox.getValues().keySet()) {
text.append(o).append(",");
}
}
if (text.toString().length() > 0)
nameInput.setText(text.toString().substring(0, text.toString().length() - 1));
} else if (metric instanceof RChooser) {
StringBuilder text = new StringBuilder();
RChooser chooser = ((RChooser) metric);
if (chooser.getValues() != null) {
for (String s : chooser.getValues()) text.append(s).append(",");
}
if (text.toString().length() > 0)
nameInput.setText(text.toString().substring(0, text.toString().length() - 1));
}
} else
nameInput.setText(metric.getTitle());
nameInput.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
if (name.equalsIgnoreCase("title")) {
metric.setTitle(charSequence.toString());
} else if (name.equalsIgnoreCase("minimum") && metric instanceof RSlider) {
((RSlider) metric).setMin((int) processTextAsNumber(charSequence, 0));
} else if (name.equalsIgnoreCase("maximum") && metric instanceof RSlider) {
((RSlider) metric).setMax((int) processTextAsNumber(charSequence, 100));
} else if (name.equalsIgnoreCase("increment") && metric instanceof RCounter) {
((RCounter) metric).setIncrement(processTextAsNumber(charSequence, 1));
} else if (name.startsWith("Comma")) {
if (metric instanceof RCheckbox) {
String[] tokens = charSequence.toString().split(",");
LinkedHashMap<String, Boolean> hash = new LinkedHashMap<>();
for (String s : tokens) hash.put(s, false);
((RCheckbox) metric).setValues(hash);
} else if (metric instanceof RChooser) {
String[] tokens = charSequence.toString().split(",");
((RChooser) metric).setValues(tokens);
}
} else if (name.equalsIgnoreCase("calculation")) {
((RCalculation) metric).setCalculation(charSequence.toString());
}
addMetricPreviewToToolbar();
/*Toolbar tl = findViewById(R.id.toolbar);
ViewGroup view = (ViewGroup) tl.getChildAt(0);
RelativeLayout t = (RelativeLayout) view.getChildAt(0);
TextView text = (TextView) t.getChildAt(0);
text.setText(charSequence);
metric.setTitle(charSequence.toString());*/
}
@Override
public void afterTextChanged(Editable editable) {
}
});
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
if (position > 0)
params.addRule(RelativeLayout.BELOW, layout.getChildAt(position - 1).getId());
inputLayout.setLayoutParams(params);
inputLayout.addView(nameInput);
inputLayout.requestFocus();
return inputLayout;
}
use of android.support.v7.widget.AppCompatEditText in project Roblu by wdavies973.
the class RMetricToUI method getCounter.
/**
* Gets the Counter UI card from an RCounter reference
* @param counter RCounter reference to be set to the UI
* @return a UI CardView
*/
public CardView getCounter(final RCounter counter) {
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.CENTER_VERTICAL);
TextView title = new TextView(activity);
title.setTextColor(rui.getText());
title.setTextSize(20);
title.setId(Utils.generateViewId());
title.setText(counter.getTitle());
title.setMaxWidth(width);
title.setPadding(Utils.DPToPX(activity, 8), title.getPaddingTop(), title.getPaddingRight(), title.getPaddingBottom());
title.setLayoutParams(params);
final TextView observed = new TextView(activity);
RelativeLayout.LayoutParams oParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
final RelativeLayout layout = new RelativeLayout(activity);
layout.addView(title);
if (!counter.isVerboseInput()) {
Drawable add = ContextCompat.getDrawable(activity, R.drawable.add_small);
if (add != null) {
add.mutate();
add.setColorFilter(rui.getButtons(), PorterDuff.Mode.SRC_IN);
}
Drawable minus = ContextCompat.getDrawable(activity, R.drawable.minus_small);
if (minus != null) {
minus.mutate();
minus.setColorFilter(rui.getButtons(), PorterDuff.Mode.SRC_IN);
}
params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
params.addRule(RelativeLayout.CENTER_VERTICAL);
ImageView addButton = new ImageView(activity);
addButton.setId(Utils.generateViewId());
addButton.setEnabled(editable);
addButton.setBackground(add);
addButton.setPadding(Utils.DPToPX(activity, 4), Utils.DPToPX(activity, 3), Utils.DPToPX(activity, 4), Utils.DPToPX(activity, 3));
addButton.setScaleX(1.5f);
addButton.setScaleY(1.5f);
addButton.setLayoutParams(params);
final TextView number = new TextView(activity);
ImageView minusButton = new ImageView(activity);
params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.LEFT_OF, addButton.getId());
params.addRule(RelativeLayout.CENTER_VERTICAL);
number.setTextSize(25);
number.setTextColor(rui.getText());
number.setId(Utils.generateViewId());
number.setText(String.valueOf(counter.getTextValue()));
number.setLayoutParams(params);
number.setPadding(Utils.DPToPX(activity, 20), number.getPaddingTop(), Utils.DPToPX(activity, 20), number.getPaddingBottom());
addButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
layout.removeView(observed);
counter.add();
number.setText(counter.getTextValue());
listener.changeMade(counter);
}
});
params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.LEFT_OF, number.getId());
params.addRule(RelativeLayout.CENTER_VERTICAL);
minusButton.setBackground(minus);
minusButton.setId(Utils.generateViewId());
minusButton.setEnabled(editable);
minusButton.setScaleY(1.5f);
minusButton.setScaleX(1.5f);
minusButton.setLayoutParams(params);
minusButton.setPadding(Utils.DPToPX(activity, 4), Utils.DPToPX(activity, 3), Utils.DPToPX(activity, 4), Utils.DPToPX(activity, 3));
minusButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
layout.removeView(observed);
counter.minus();
number.setText(String.valueOf(counter.getTextValue()));
listener.changeMade(counter);
}
});
// observed params
oParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
oParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
oParams.addRule(RelativeLayout.BELOW, number.getId());
observed.setPadding(0, Utils.DPToPX(activity, 20), 0, 0);
observed.setLayoutParams(oParams);
layout.addView(minusButton);
layout.addView(number);
layout.addView(addButton);
} else {
params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
title.setTextSize(14f);
params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
title.setLayoutParams(params);
params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.BELOW, title.getId());
AppCompatEditText et = new AppCompatEditText(activity);
Utils.setCursorColor(et, rui.getAccent());
et.setText(String.valueOf(counter.getValue()));
et.setEnabled(editable);
et.setTextColor(rui.getText());
et.setId(Utils.generateViewId());
et.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_CLASS_NUMBER);
et.setRawInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_CLASS_NUMBER);
et.setSingleLine();
et.setMaxLines(1);
et.setHighlightColor(rui.getAccent());
Drawable d = et.getBackground();
d.setColorFilter(rui.getText(), PorterDuff.Mode.SRC_ATOP);
et.setBackground(d);
et.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
layout.removeView(observed);
try {
counter.setValue(Double.parseDouble(charSequence.toString()));
} catch (NumberFormatException e) {
counter.setValue(0);
}
listener.changeMade(counter);
}
@Override
public void afterTextChanged(Editable editable) {
}
});
et.setImeOptions(EditorInfo.IME_FLAG_NO_ENTER_ACTION);
et.setFocusableInTouchMode(true);
et.setLayoutParams(params);
layout.addView(et);
oParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
oParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
oParams.addRule(RelativeLayout.BELOW, et.getId());
observed.setPadding(0, Utils.DPToPX(activity, 20), 0, 0);
observed.setLayoutParams(oParams);
}
// Observed field
observed.setTextColor(rui.getText());
observed.setText(R.string.not_observed_yet);
observed.setTextSize(10);
observed.setId(Utils.generateViewId());
observed.setTag("N.O.");
observed.setPadding(0, Utils.DPToPX(activity, 20), 0, 0);
observed.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!editable)
return;
layout.removeView(observed);
listener.changeMade(counter);
}
});
if (!counter.isModified())
layout.addView(observed);
return getCard(layout);
}
Aggregations