Search in sources :

Example 6 with RUI

use of com.cpjd.roblu.models.RUI 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 7 with RUI

use of com.cpjd.roblu.models.RUI 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 8 with RUI

use of com.cpjd.roblu.models.RUI 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 9 with RUI

use of com.cpjd.roblu.models.RUI in project Roblu by wdavies973.

the class IO method init.

/**
 * Must be called at application startup, ASAP
 *
 * Does the following:
 * -Makes sure settings file exists, if not, creates default
 * -Ensures /checkouts/ exists
 * -Removes old data (from older prefixes)
 *
 * @return true if this is first launch (based on if the settings file had to be created)
 */
public static boolean init(Context context) {
    // Create prefix directory
    if (!new File(context.getFilesDir(), PREFIX).exists()) {
        if (new File(context.getFilesDir(), PREFIX).mkdir())
            Log.d("RBS", "Prefix dir could not be created.");
    }
    /*
         * Create parent directories
         */
    File eventDir = new File(context.getFilesDir(), PREFIX + File.separator + "events" + File.separator);
    File checkoutsDir = new File(context.getFilesDir(), PREFIX + File.separator + "checkouts" + File.separator);
    File pending = new File(context.getFilesDir(), PREFIX + File.separator + "pending" + File.separator);
    if (!eventDir.exists()) {
        if (eventDir.mkdir())
            Log.d("RBS", "/events/ dir successfully created.");
    }
    if (!checkoutsDir.exists()) {
        if (checkoutsDir.mkdir())
            Log.d("RBS", "/checkouts/ dir successfully created.");
    }
    if (!pending.exists()) {
        if (pending.mkdir())
            Log.d("RBS", "/pending/ dir successfully created.");
    }
    // Purge old data
    // File dir = new File(context.getFilesDir(), File.separator);
    // if(dir.listFiles() != null && dir.listFiles().length > 0) for(File file : dir.listFiles()) if(!file.getName().equals(PREFIX)) delete(dir);
    // Check settings
    RSettings settings = new IO(context).loadSettings();
    if (settings == null) {
        settings = new RSettings();
        settings.setRui(new RUI());
        settings.setMaster(Utils.createEmpty());
        new IO(context).saveCloudSettings(new RSyncSettings());
        new IO(context).saveSettings(settings);
        return true;
    }
    return false;
}
Also used : RUI(com.cpjd.roblu.models.RUI) RSyncSettings(com.cpjd.roblu.models.RSyncSettings) File(java.io.File) RSettings(com.cpjd.roblu.models.RSettings)

Example 10 with RUI

use of com.cpjd.roblu.models.RUI in project Roblu by wdavies973.

the class FormViewer method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_create_form);
    /*
		 * Load dependencies
		 */
    /*
         Stores the user's UI preferences
        */
    RUI rui = new IO(getApplicationContext()).loadSettings().getRui();
    /*
		 * Setup UI
		 */
    // Toolbar
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setTitle("Form editor");
        if (getIntent().getBooleanExtra("master", false))
            getSupportActionBar().setSubtitle("Master form");
    }
    // Bottom bar - selector that lets the user switch between PIT and MATCH forms
    BottomBar bBar = findViewById(R.id.bottomBar);
    bBar.setOnTabSelectListener(this);
    BottomBarTab tab = bBar.getTabAtPosition(0);
    BottomBarTab tab2 = bBar.getTabAtPosition(1);
    tab.setBarColorWhenSelected(rui.getPrimaryColor());
    tab2.setBarColorWhenSelected(rui.getPrimaryColor());
    bBar.selectTabAtPosition(0);
    // Add the "New metric" button
    FloatingActionButton fab = findViewById(R.id.fab);
    fab.setOnClickListener(this);
    // Recycler view setup
    RecyclerView rv = findViewById(R.id.movie_recycler_view);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    rv.setLayoutManager(linearLayoutManager);
    ((SimpleItemAnimator) rv.getItemAnimator()).setSupportsChangeAnimations(false);
    metricsAdapter = new FormRecyclerAdapter(this, this);
    rv.setAdapter(metricsAdapter);
    // Gesture helper
    ItemTouchHelper.Callback callback = new FormRecyclerTouchHelper(metricsAdapter);
    ItemTouchHelper helper = new ItemTouchHelper(callback);
    helper.attachToRecyclerView(rv);
    /*
         * Check to see if we received a form from a different class or
         * if we need to create a new one
         */
    if (getIntent().getSerializableExtra("form") != null) {
        form = (RForm) getIntent().getSerializableExtra("form");
    } else {
        RTextfield name = new RTextfield(0, "Team name", false, true, "");
        RTextfield number = new RTextfield(1, "Team number", true, true, "");
        ArrayList<RMetric> pit = new ArrayList<>();
        pit.add(name);
        pit.add(number);
        form = new RForm(pit, new ArrayList<RMetric>());
    }
    loadViews(true, 0);
    new UIHandler(this, toolbar, fab).update();
}
Also used : SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) UIHandler(com.cpjd.roblu.ui.UIHandler) IO(com.cpjd.roblu.io.IO) RTextfield(com.cpjd.roblu.models.metrics.RTextfield) RUI(com.cpjd.roblu.models.RUI) ArrayList(java.util.ArrayList) RMetric(com.cpjd.roblu.models.metrics.RMetric) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) BottomBar(com.roughike.bottombar.BottomBar) RForm(com.cpjd.roblu.models.RForm) BottomBarTab(com.roughike.bottombar.BottomBarTab) FloatingActionButton(android.support.design.widget.FloatingActionButton) RecyclerView(android.support.v7.widget.RecyclerView) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

RUI (com.cpjd.roblu.models.RUI)11 IO (com.cpjd.roblu.io.IO)10 TextView (android.widget.TextView)6 RSettings (com.cpjd.roblu.models.RSettings)3 AlertDialog (android.app.AlertDialog)2 DialogInterface (android.content.DialogInterface)2 ColorDrawable (android.graphics.drawable.ColorDrawable)2 StrictMode (android.os.StrictMode)2 Toolbar (android.support.v7.widget.Toolbar)2 REvent (com.cpjd.roblu.models.REvent)2 RForm (com.cpjd.roblu.models.RForm)2 RSyncSettings (com.cpjd.roblu.models.RSyncSettings)2 UIHandler (com.cpjd.roblu.ui.UIHandler)2 ArrayList (java.util.ArrayList)2 ColorStateList (android.content.res.ColorStateList)1 Drawable (android.graphics.drawable.Drawable)1 FloatingActionButton (android.support.design.widget.FloatingActionButton)1 AppCompatCheckBox (android.support.v7.widget.AppCompatCheckBox)1 AppCompatEditText (android.support.v7.widget.AppCompatEditText)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1