use of com.cpjd.roblu.io.IO in project Roblu by wdavies973.
the class RUICheckPreference method onBindView.
@Override
protected void onBindView(View view) {
super.onBindView(view);
RUI rui = new IO(getContext()).loadSettings().getRui();
TextView titleView = view.findViewById(android.R.id.title);
titleView.setTextColor(rui.getText());
TextView subtitle = view.findViewById(android.R.id.summary);
subtitle.setTextColor(rui.darker(rui.getText(), 0.60f));
try {
AppCompatCheckBox checkbox = view.findViewById(android.R.id.checkbox);
checkbox.animate();
ColorStateList colorStateList = new ColorStateList(new int[][] { // unchecked
new int[] { -android.R.attr.state_checked }, // checked
new int[] { android.R.attr.state_checked } }, new int[] { rui.getText(), rui.getAccent() });
CompoundButtonCompat.setButtonTintList(checkbox, colorStateList);
} catch (Exception e) {
}
}
use of com.cpjd.roblu.io.IO in project Roblu by wdavies973.
the class RUIEditPreference method onBindView.
@Override
protected void onBindView(View view) {
super.onBindView(view);
RUI rui = new IO(getContext()).loadSettings().getRui();
TextView titleView = view.findViewById(android.R.id.title);
titleView.setTextColor(rui.getText());
TextView subtitle = view.findViewById(android.R.id.summary);
subtitle.setTextColor(rui.darker(rui.getText(), 0.60f));
}
use of com.cpjd.roblu.io.IO in project Roblu by wdavies973.
the class RUIPreference method onBindView.
@Override
protected void onBindView(View view) {
super.onBindView(view);
try {
RUI rui = new IO(view.getContext()).loadSettings().getRui();
TextView titleView = view.findViewById(android.R.id.title);
titleView.setTextColor(rui.getText());
TextView subtitle = view.findViewById(android.R.id.summary);
subtitle.setTextColor(rui.darker(rui.getText(), 0.60f));
} catch (Exception e) {
Log.d("RBS", "Failed to bind UI to settings preference.");
}
}
use of com.cpjd.roblu.io.IO in project Roblu by wdavies973.
the class BTServer method messageReceived.
@Override
public void messageReceived(String header, String message) {
IO io = new IO(bluetooth.getActivity());
switch(header) {
case "SCOUTING_DATA":
// Process scouting data
try {
JSONParser parser = new JSONParser();
org.json.simple.JSONArray array = (org.json.simple.JSONArray) parser.parse(message);
String[] received = new String[array.size()];
for (int i = 0; i < array.size(); i++) received[i] = array.get(i).toString();
syncHelper.unpackCheckouts(syncHelper.convertStringSerialToCloudCheckouts(received), null);
Log.d("RBS", "Received " + array.size() + " checkouts from Roblu Scouter.");
} catch (Exception e) {
Log.d("RBS", "Failed to process checkouts received over Bluetooth: " + e.getMessage());
}
break;
case "requestForm":
Log.d("RBS", "Roblu Scouter requested form, responding with it.");
try {
bluetooth.send("FORM", mapper.writeValueAsString(io.loadForm(event.getID())));
} catch (Exception e) {
Log.d("RBS", "Failed to parse form as JSON.");
}
break;
case "requestUI":
Log.d("RBS", "Roblu Scouter requested ui, responding with it.");
try {
bluetooth.send("UI", mapper.writeValueAsString(io.loadSettings().getRui()));
} catch (Exception e) {
Log.d("RBS", "Failed to parse form as JSON.");
}
break;
case "requestCheckouts":
Log.d("RBS", "Roblu Scouter requested checkouts, responding with them.");
// Get the timestamp
long time = Long.parseLong(message.split(":")[1]);
ArrayList<RCheckout> checkouts = syncHelper.generateCheckoutsFromEvent(io.loadTeams(event.getID()), time);
try {
bluetooth.send("CHECKOUTS", syncHelper.packCheckouts(checkouts));
} catch (Exception e) {
Log.d("RBS", "Failed to map checkouts to Bluetooth output stream. " + e.getMessage());
}
break;
case "requestNumber":
Log.d("RBS", "Roblu Scouter requested team number, responding with it.");
bluetooth.send("NUMBER", String.valueOf(io.loadSettings().getTeamNumber()));
break;
case "requestEventName":
Log.d("RBS", "Roblu Scouter requested event name, responding with it.");
bluetooth.send("EVENT_NAME", event.getName());
break;
case "DONE":
Log.d("RBS", "Roblu Scouter requested DONE. Confirming.");
bluetooth.send("DONE", "noParams");
pd.dismiss();
bluetooth.disconnect();
if (bluetooth.isEnabled()) {
bluetooth.startServer();
} else
bluetooth.enable();
break;
}
}
use of com.cpjd.roblu.io.IO in project Roblu by wdavies973.
the class MetricEditor method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_element);
/*
* Load dependencies
*/
rui = new IO(getApplicationContext()).loadSettings().getRui();
if (getIntent().getSerializableExtra("form") != null)
form = (RForm) getIntent().getSerializableExtra("form");
tab = getIntent().getIntExtra("tab", 0);
/*
* Setup UI
*/
// Toolbar
Toolbar toolbar = findViewById(R.id.support_toolbar);
setSupportActionBar(toolbar);
if (getSupportActionBar() != null) {
getSupportActionBar().setHomeAsUpIndicator(R.drawable.clear);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle("Add metric");
}
// layout
layout = findViewById(R.id.add_element_layout);
// RMetric to UI
rMetricToUI = new RMetricToUI(this, rui, true);
rMetricToUI.setListener(this);
/*
* Check if the user actually wants to edit
*/
if (getIntent().getSerializableExtra("metric") != null) {
metric = (RMetric) getIntent().getSerializableExtra("metric");
if (getSupportActionBar() != null)
getSupportActionBar().setTitle("Edit metric");
/*
* The modified variable DOES NOT matter in the form, so always, always make sure it's true
* so N.O. tags don't show up
*/
metric.setModified(true);
addMetricPreviewToToolbar();
buildConfigLayout();
} else {
// add a RBoolean type, it's the default loaded type until the user selects a different one
metric = new RBoolean(0, "Boolean", false);
/*
* The modified variable DOES NOT matter in the form, so always, always make sure it's true
* so N.O. tags don't show up
*/
metric.setModified(true);
layout.addView(initMetricSelector());
}
// Sync UI with color preferences
new UIHandler(this, toolbar).update();
}
Aggregations