use of com.moro.mtweaks.views.recyclerview.DescriptionView in project MTweaks-KernelAdiutorMOD by morogoku.
the class InputsFragment method addItems.
@Override
protected void addItems(List<RecyclerViewItem> items) {
List<Device.Input.Item> inputs = Device.Input.getItems();
for (Device.Input.Item input : inputs) {
String name;
if ((name = input.getName()) != null) {
String[][] list = { { getString(R.string.bus), input.getBus() }, { getString(R.string.vendor), input.getVendor() }, { getString(R.string.product), input.getProduct() }, { getString(R.string.version), input.getVersion() }, { getString(R.string.sysfs), input.getSysfs() }, { getString(R.string.handlers), input.getHandlers() } };
List<RecyclerViewItem> inputItems = new ArrayList<>();
for (String[] inputsList : list) {
if (inputsList[1] != null) {
DescriptionView inputView = new DescriptionView();
inputView.setTitle(inputsList[0]);
inputView.setSummary(inputsList[1]);
inputItems.add(inputView);
}
}
if (inputItems.size() > 0) {
TitleView inputTile = new TitleView();
inputTile.setText(name);
items.add(inputTile);
items.addAll(inputItems);
}
}
}
}
use of com.moro.mtweaks.views.recyclerview.DescriptionView in project MTweaks-KernelAdiutorMOD by morogoku.
the class MemoryFragment method addItems.
@Override
protected void addItems(List<RecyclerViewItem> items) {
List<String> mems = Device.MemInfo.getItems();
for (String mem : mems) {
DescriptionView memView = new DescriptionView();
memView.setTitle(mem);
memView.setSummary(Device.MemInfo.getItem(mem).replace(" ", "").replace("kB", getString(R.string.kb)));
items.add(memView);
}
}
use of com.moro.mtweaks.views.recyclerview.DescriptionView in project MTweaks-KernelAdiutorMOD by morogoku.
the class OverallFragment method updateView.
private void updateView(CpuStateMonitor monitor, CardView card) {
if (!isAdded() || card == null)
return;
card.clearItems();
// update the total state time
DescriptionView totalTime = new DescriptionView();
totalTime.setTitle(getString(R.string.uptime));
totalTime.setSummary(sToString(monitor.getTotalStateTime() / 100L));
card.addItem(totalTime);
/**
* Get the CpuStateMonitor from the app, and iterate over all states,
* creating a row if the duration is > 0 or otherwise marking it in
* extraStates (missing)
*/
List<String> extraStates = new ArrayList<>();
for (CpuStateMonitor.CpuState state : monitor.getStates()) {
if (state.getDuration() > 0) {
generateStateRow(monitor, state, card);
} else {
if (state.getFreq() == 0) {
extraStates.add(getString(R.string.deep_sleep));
} else {
extraStates.add(state.getFreq() / 1000 + getString(R.string.mhz));
}
}
}
if (monitor.getStates().size() == 0) {
card.clearItems();
DescriptionView errorView = new DescriptionView();
errorView.setTitle(getString(R.string.error_frequencies));
card.addItem(errorView);
return;
}
// for all the 0 duration states, add the the Unused State area
if (extraStates.size() > 0) {
int n = 0;
String str = "";
for (String s : extraStates) {
if (n++ > 0)
str += ", ";
str += s;
}
DescriptionView unusedText = new DescriptionView();
unusedText.setTitle(getString(R.string.unused_frequencies));
unusedText.setSummary(str);
card.addItem(unusedText);
}
}
use of com.moro.mtweaks.views.recyclerview.DescriptionView in project MTweaks-KernelAdiutorMOD by morogoku.
the class BuildpropFragment method load.
private void load(final List<RecyclerViewItem> items) {
if (mProps == null)
return;
String[] titles = mProps.keySet().toArray(new String[mProps.size()]);
for (int i = 0; i < mProps.size(); i++) {
final String title = titles[i];
final String value = mProps.values().toArray(new String[mProps.size()])[i];
if ((mKeyText != null && !title.contains(mKeyText) || (mValueText != null && !value.contains(mValueText)))) {
continue;
}
int color = ViewUtils.getThemeAccentColor(getActivity());
String colorCode = "#" + Integer.toHexString(Color.red(color)) + Integer.toHexString(Color.green(color)) + Integer.toHexString(Color.blue(color));
DescriptionView descriptionView = new DescriptionView();
if (mKeyText != null && !mKeyText.isEmpty()) {
descriptionView.setTitle(Utils.htmlFrom(title.replace(mKeyText, "<b><font color=\"" + colorCode + "\">" + mKeyText + "</font></b>")));
} else {
descriptionView.setTitle(title);
}
if (mValueText != null && !mValueText.isEmpty()) {
descriptionView.setSummary(Utils.htmlFrom(value.replace(mValueText, "<b><font color=\"" + colorCode + "\">" + mKeyText + "</font></b>")));
} else {
descriptionView.setSummary(value);
}
descriptionView.setOnItemClickListener(new RecyclerViewItem.OnItemClickListener() {
@Override
public void onClick(RecyclerViewItem item) {
mItemOptionsDialog = new Dialog(getActivity()).setItems(getResources().getStringArray(R.array.build_prop_item_options), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
switch(i) {
case 0:
modify(title, value);
break;
case 1:
delete(title, value);
break;
}
}
}).setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
mItemOptionsDialog = null;
}
});
mItemOptionsDialog.show();
}
});
items.add(descriptionView);
}
Activity activity;
if (mSearchFragment != null && (activity = getActivity()) != null) {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (isAdded()) {
mSearchFragment.setCount(items.size());
}
}
});
}
}
use of com.moro.mtweaks.views.recyclerview.DescriptionView in project MTweaks-KernelAdiutorMOD by morogoku.
the class InitdFragment method load.
private void load(List<RecyclerViewItem> items) {
for (final String initd : Initd.list()) {
CardView cardView = new CardView(getActivity());
cardView.setOnMenuListener(new CardView.OnMenuListener() {
@Override
public void onMenuReady(CardView cardView, PopupMenu popupMenu) {
Menu menu = popupMenu.getMenu();
menu.add(Menu.NONE, 0, Menu.NONE, getString(R.string.edit));
menu.add(Menu.NONE, 1, Menu.NONE, getString(R.string.delete));
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()) {
case 0:
mEditInitd = initd;
Intent intent = new Intent(getActivity(), EditorActivity.class);
intent.putExtra(EditorActivity.TITLE_INTENT, initd);
intent.putExtra(EditorActivity.TEXT_INTENT, Initd.read(initd));
startActivityForResult(intent, 0);
break;
case 1:
mDeleteDialog = ViewUtils.dialogBuilder(getString(R.string.sure_question), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
}, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Initd.delete(initd);
reload();
}
}, new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
mDeleteDialog = null;
}
}, getActivity());
mDeleteDialog.show();
break;
}
return false;
}
});
}
});
DescriptionView descriptionView = new DescriptionView();
descriptionView.setSummary(initd);
descriptionView.setOnItemClickListener(new RecyclerViewItem.OnItemClickListener() {
@Override
public void onClick(RecyclerViewItem item) {
mExecuteDialog = ViewUtils.dialogBuilder(getString(R.string.exceute_question, initd), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
}, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
execute(initd);
}
}, new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
mExecuteDialog = null;
}
}, getActivity());
mExecuteDialog.show();
}
});
cardView.addItem(descriptionView);
items.add(cardView);
}
}
Aggregations