use of android.support.v7.widget.AppCompatEditText in project Roblu by wdavies973.
the class TeamViewer method showMatchCreator.
/**
* Opens the manual match creator
*/
private void showMatchCreator() {
if (!editable) {
Toast.makeText(getApplicationContext(), "Can't create match in read only mode.", Toast.LENGTH_LONG).show();
return;
}
final Dialog d = new Dialog(this);
d.setTitle("Create match");
d.setContentView(R.layout.match_create_dialog);
final AppCompatEditText number = d.findViewById(R.id.editText);
Utils.setInputTextLayoutColor(rui.getAccent(), null, number);
TextView spinnerTip = d.findViewById(R.id.spinner_tip);
spinnerTip.setTextColor(rui.getText());
TextView numberTip = d.findViewById(R.id.number_tip);
numberTip.setTextColor(rui.getText());
TextView colorTip = d.findViewById(R.id.color_tip);
colorTip.setTextColor(rui.getText());
Button button = d.findViewById(R.id.button7);
button.setTextColor(rui.getText());
button.setBackgroundColor(rui.getBackground());
String[] values = { "Quals", "Quarters 1", "Quarters 2", "Quarters 3", "Quarters 4", "Semis 1", "Semis 2", "Finals" };
final Spinner spinner = d.findViewById(R.id.type);
spinner.getBackground().setColorFilter(rui.getText(), PorterDuff.Mode.SRC_ATOP);
ArrayAdapter<String> adp = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, values);
adp.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adp);
final Spinner spinner2 = d.findViewById(R.id.spinner2);
spinner2.getBackground().setColorFilter(rui.getText(), PorterDuff.Mode.SRC_ATOP);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Check for duplicates!!
final String processedName = processName(spinner, number);
if (doesExist(processedName)) {
new FastDialogBuilder().setTitle("Match already exists").setMessage("Would you like to go to its tab?").setPositiveButtonText("Yes").setNegativeButtonText("No").setFastDialogListener(new FastDialogBuilder.FastDialogListener() {
@Override
public void accepted() {
d.dismiss();
pager.setCurrentItem(getPosition(processedName));
}
@Override
public void denied() {
}
@Override
public void neutral() {
}
}).build(TeamViewer.this);
} else {
boolean isRed = spinner2.getSelectedItemPosition() == 0;
pager.setCurrentItem(tabAdapter.createMatch(processedName, isRed));
d.dismiss();
}
}
});
if (d.getWindow() != null) {
d.getWindow().getAttributes().windowAnimations = rui.getDialogDirection();
d.getWindow().setBackgroundDrawable(new ColorDrawable(rui.getBackground()));
}
d.getWindow().getAttributes().windowAnimations = rui.getDialogDirection();
d.show();
}
use of android.support.v7.widget.AppCompatEditText in project Roblu by wdavies973.
the class EventCreateMethodPicker method importPublicRobluCloudEvent.
private void importPublicRobluCloudEvent() {
// check for an internet connection
if (!Utils.hasInternetConnection(getApplicationContext())) {
Utils.showSnackbar(findViewById(R.id.advsettings), getApplicationContext(), "You are not connected to the internet", true, 0);
return;
}
/*
* We need to make sure that this thread has access to the internet
*/
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitNetwork().build();
StrictMode.setThreadPolicy(policy);
final RSettings settings = new IO(getApplicationContext()).loadSettings();
RUI rui = settings.getRui();
AlertDialog.Builder builder = new AlertDialog.Builder(EventCreateMethodPicker.this);
LinearLayout layout = new LinearLayout(EventCreateMethodPicker.this);
layout.setOrientation(LinearLayout.VERTICAL);
// this is the team code input edit text
final AppCompatEditText input = new AppCompatEditText(EventCreateMethodPicker.this);
Utils.setInputTextLayoutColor(rui.getAccent(), null, input);
input.setHighlightColor(rui.getAccent());
input.setHintTextColor(rui.getText());
input.setTextColor(rui.getText());
input.setInputType(InputType.TYPE_CLASS_NUMBER);
InputFilter[] FilterArray = new InputFilter[1];
FilterArray[0] = new InputFilter.LengthFilter(30);
input.setFilters(FilterArray);
layout.addView(input);
builder.setView(layout);
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
importRobluCloudEvent(Integer.parseInt(input.getText().toString()));
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
TextView view = new TextView(EventCreateMethodPicker.this);
view.setTextSize(Utils.DPToPX(getApplicationContext(), 5));
view.setPadding(Utils.DPToPX(getApplicationContext(), 18), Utils.DPToPX(getApplicationContext(), 18), Utils.DPToPX(getApplicationContext(), 18), Utils.DPToPX(getApplicationContext(), 18));
view.setText("FRC team number:");
view.setTextColor(rui.getText());
AlertDialog dialog = builder.create();
dialog.setCustomTitle(view);
if (dialog.getWindow() != null) {
dialog.getWindow().getAttributes().windowAnimations = rui.getAnimation();
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(rui.getBackground()));
}
dialog.show();
dialog.getButton(Dialog.BUTTON_NEGATIVE).setTextColor(rui.getAccent());
dialog.getButton(Dialog.BUTTON_POSITIVE).setTextColor(rui.getAccent());
}
use of android.support.v7.widget.AppCompatEditText in project Roblu by wdavies973.
the class EventEditor method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/*
* Load dependencies
*/
editing = getIntent().getBooleanExtra("editing", false);
RUI rui = new IO(getApplicationContext()).loadSettings().getRui();
// decide whether to use create event or edit event UI scheme
if (editing)
setContentView(R.layout.activity_edit_event);
else
setContentView(R.layout.activity_create_event);
/*
* Setup UI
*/
// Toolbar
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
if (getSupportActionBar() != null) {
getSupportActionBar().setHomeAsUpIndicator(R.drawable.clear);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if (editing)
getSupportActionBar().setTitle("Edit event");
else
getSupportActionBar().setTitle("Create event");
}
// event name
eventName = findViewById(R.id.event_create_name_edit);
/*
* Bind user color preferences to the UI elements
*/
Utils.setInputTextLayoutColor(rui.getAccent(), (TextInputLayout) findViewById(R.id.name_wrapper), (AppCompatEditText) findViewById(R.id.event_create_name_edit));
/*
* Setup editing/non-editing UI specifics
*/
if (!editing) {
TextView t = findViewById(R.id.event_create_form_label);
t.setTextColor(rui.getAccent());
if (getIntent().getSerializableExtra("tbaEvent") != null) {
/*
* This item will be set if this activity is called form the TBAEventSelector activity, all it's saying is that
* all the data within this Event model should be included when creating the REvent
*/
Event event = (Event) getIntent().getSerializableExtra("tbaEvent");
eventName.setText(event.name);
findViewById(R.id.switch1).setVisibility(View.VISIBLE);
}
} else {
RelativeLayout layout = findViewById(R.id.create_layout);
for (int i = 0; i < layout.getChildCount(); i++) {
if (layout.getChildAt(i).getId() == R.id.form_type || layout.getChildAt(i).getId() == R.id.event_create_form_label) {
layout.removeViewAt(i);
i = 0;
}
}
tbaKeyText = findViewById(R.id.key_edit);
tbaKeyText.setText(getIntent().getStringExtra("key"));
eventName.setText(getIntent().getStringExtra("name"));
}
// General UI syncing
new UIHandler(this, toolbar).update();
}
use of android.support.v7.widget.AppCompatEditText in project FaceSlim by indywidualny.
the class MainActivity method addLauncherShortcut.
private void addLauncherShortcut() {
final Intent shortcut = new Intent(this, CustomShortcutActivity.class);
shortcut.putExtra(CustomShortcutActivity.URL_FIELD, webView.getUrl());
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(getString(R.string.label));
final AppCompatEditText input = new AppCompatEditText(this);
input.setHint(webView.getTitle());
input.setSingleLine();
FrameLayout container = new FrameLayout(this);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.leftMargin = 50;
params.rightMargin = 50;
input.setLayoutParams(params);
container.addView(input);
builder.setView(container);
builder.setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
String label = input.getText().toString();
if (TextUtils.isEmpty(label))
label = webView.getTitle();
shortcut.putExtra(CustomShortcutActivity.NAME_FIELD, label);
startActivity(shortcut);
Toast.makeText(getApplicationContext(), "\uD83D\uDC4C", Toast.LENGTH_SHORT).show();
}
});
builder.setNegativeButton(getString(android.R.string.cancel), null);
AlertDialog alertDialog = builder.create();
alertDialog.show();
alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextColor(ContextCompat.getColor(this, R.color.colorAccent));
alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE).setTextColor(ContextCompat.getColor(this, R.color.colorAccent));
}
use of android.support.v7.widget.AppCompatEditText in project Rashr by DsLNeXuS.
the class BackupActivity method createBackup.
public void createBackup(final boolean RecoveryBackup) {
String prefix;
String CurrentName;
String EXT;
if (RecoveryBackup) {
prefix = "recovery";
EXT = App.Device.getRecoveryExt();
CurrentName = App.Device.getRecoveryVersion();
} else {
prefix = "kernel";
EXT = App.Device.getKernelExt();
CurrentName = App.Device.getKernelVersion();
}
final AppCompatDialog dialog = new AppCompatDialog(mContext);
dialog.setTitle(R.string.setname);
dialog.setContentView(R.layout.dialog_input);
final AppCompatButton bGoBackup = dialog.findViewById(R.id.bGoBackup);
final AppCompatEditText etFileName = dialog.findViewById(R.id.etFileName);
final AppCompatCheckBox optName = dialog.findViewById(R.id.cbOptInput);
if (bGoBackup == null || etFileName == null || optName == null)
return;
final String NameHint = prefix + "-from-" + Calendar.getInstance().get(Calendar.DATE) + "-" + Calendar.getInstance().get(Calendar.MONTH) + "-" + Calendar.getInstance().get(Calendar.YEAR) + "-" + Calendar.getInstance().get(Calendar.HOUR_OF_DAY) + "-" + Calendar.getInstance().get(Calendar.MINUTE) + EXT;
optName.setText(CurrentName);
optName.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
etFileName.setEnabled(!optName.isChecked());
}
});
etFileName.setHint(NameHint);
bGoBackup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String EXT;
File Path;
final int JOB;
if (RecoveryBackup) {
EXT = App.Device.getRecoveryExt();
Path = App.PathToRecoveryBackups;
JOB = FlashUtil.JOB_BACKUP_RECOVERY;
} else {
EXT = App.Device.getKernelExt();
Path = App.PathToKernelBackups;
JOB = FlashUtil.JOB_BACKUP_KERNEL;
}
String Name;
if (optName.isChecked()) {
// Using preset name as filename
Name = optName.getText() + EXT;
} else {
if (etFileName.getText() != null && !etFileName.getText().toString().equals("")) {
// Use edittext as name
Name = etFileName.getText().toString();
} else {
// Use hint as name
Name = String.valueOf(etFileName.getHint());
}
}
// Adding extension to chosen name
if (!Name.endsWith(EXT)) {
Name = Name + EXT;
}
final File fBACKUP = new File(Path, Name);
if (fBACKUP.exists()) {
// Backup exists already do not create new.
Toast.makeText(mActivity, R.string.backupalready, Toast.LENGTH_SHORT).show();
} else {
final FlashUtil BackupCreator = new FlashUtil(mActivity, fBACKUP, JOB);
BackupCreator.setOnFlashListener(new FlashUtil.OnFlashListener() {
@Override
public void onSuccess() {
mAdapter.loadBackups();
}
@Override
public void onFail(Exception e) {
String msg;
if (e != null) {
msg = e.toString();
} else {
msg = getString(R.string.bak_error);
}
Toast.makeText(mContext, msg, Toast.LENGTH_SHORT).show();
}
});
BackupCreator.execute();
}
dialog.dismiss();
}
});
dialog.show();
}
Aggregations