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) {
}
}
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));
}
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.");
}
}
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;
}
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();
}
Aggregations