Search in sources :

Example 26 with IO

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) {
    }
}
Also used : IO(com.cpjd.roblu.io.IO) RUI(com.cpjd.roblu.models.RUI) ColorStateList(android.content.res.ColorStateList) TextView(android.widget.TextView) AppCompatCheckBox(android.support.v7.widget.AppCompatCheckBox)

Example 27 with IO

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));
}
Also used : IO(com.cpjd.roblu.io.IO) RUI(com.cpjd.roblu.models.RUI) TextView(android.widget.TextView)

Example 28 with IO

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.");
    }
}
Also used : IO(com.cpjd.roblu.io.IO) RUI(com.cpjd.roblu.models.RUI) TextView(android.widget.TextView)

Example 29 with IO

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;
    }
}
Also used : IO(com.cpjd.roblu.io.IO) RCheckout(com.cpjd.roblu.models.RCheckout) JSONParser(org.json.simple.parser.JSONParser)

Example 30 with IO

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();
}
Also used : RBoolean(com.cpjd.roblu.models.metrics.RBoolean) RForm(com.cpjd.roblu.models.RForm) UIHandler(com.cpjd.roblu.ui.UIHandler) IO(com.cpjd.roblu.io.IO) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

IO (com.cpjd.roblu.io.IO)59 TextView (android.widget.TextView)18 Intent (android.content.Intent)15 View (android.view.View)14 ArrayList (java.util.ArrayList)13 REvent (com.cpjd.roblu.models.REvent)11 Toolbar (android.support.v7.widget.Toolbar)10 RForm (com.cpjd.roblu.models.RForm)10 RTeam (com.cpjd.roblu.models.RTeam)10 RUI (com.cpjd.roblu.models.RUI)10 RCheckout (com.cpjd.roblu.models.RCheckout)8 RTab (com.cpjd.roblu.models.RTab)8 RMetric (com.cpjd.roblu.models.metrics.RMetric)8 UIHandler (com.cpjd.roblu.ui.UIHandler)8 RecyclerView (android.support.v7.widget.RecyclerView)7 Dialog (android.app.Dialog)6 Bundle (android.os.Bundle)6 Button (android.widget.Button)6 RSettings (com.cpjd.roblu.models.RSettings)6 AlertDialog (android.app.AlertDialog)5