use of com.moro.mtweaks.views.recyclerview.CardView in project MTweaks-KernelAdiutorMOD by morogoku.
the class DeviceFragment method addItems.
@Override
protected void addItems(List<RecyclerViewItem> items) {
String[][] deviceInfos = { { getString(R.string.android_version), Device.getVersion() }, { getString(R.string.android_api_level), String.valueOf(Device.getSDK()) }, { getString(R.string.android_codename), Device.getCodename() }, { getString(R.string.fingerprint), Device.getFingerprint() }, { getString(R.string.build_display_id), Device.getBuildDisplayId() }, { getString(R.string.baseband), Device.getBaseBand() }, { getString(R.string.bootloader), Device.getBootloader() }, { getString(R.string.rom), Device.ROMInfo.getVersion() }, { getString(R.string.trustzone), Device.TrustZone.getVersion() }, { getString(R.string.asv), Device.getAsv() } };
String[][] boardInfos = { { getString(R.string.hardware), Device.getHardware() }, { getString(R.string.architecture), Device.getArchitecture() }, { getString(R.string.kernel), Device.getKernelVersion(true) } };
CardView deviceCard = new CardView(getActivity());
String vendor = Device.getVendor();
vendor = vendor.substring(0, 1).toUpperCase() + vendor.substring(1);
deviceCard.setTitle(vendor + " " + Device.getModel());
CardView boardCard = new CardView(getActivity());
boardCard.setTitle(Device.getBoard().toUpperCase());
for (String[] deviceInfo : deviceInfos) {
if (deviceInfo[1] != null && deviceInfo[1].isEmpty()) {
continue;
}
DescriptionView info = new DescriptionView();
info.setTitle(deviceInfo[0]);
info.setSummary(deviceInfo[1]);
deviceCard.addItem(info);
}
for (String[] boardInfo : boardInfos) {
if (boardInfo[1] != null && boardInfo[1].isEmpty()) {
continue;
}
DescriptionView info = new DescriptionView();
info.setTitle(boardInfo[0]);
info.setSummary(boardInfo[1]);
boardCard.addItem(info);
}
items.add(deviceCard);
items.add(boardCard);
}
use of com.moro.mtweaks.views.recyclerview.CardView in project MTweaks-KernelAdiutorMOD by morogoku.
the class OverallFragment method frequenciesInit.
private void frequenciesInit(List<RecyclerViewItem> items) {
FrequencyButtonView frequencyButtonView = new FrequencyButtonView();
frequencyButtonView.setRefreshListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
updateFrequency();
}
});
frequencyButtonView.setResetListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CpuStateMonitor cpuStateMonitor = mCpuSpyBig.getCpuStateMonitor();
CpuStateMonitor cpuStateMonitorLITTLE = null;
if (mCpuSpyLITTLE != null) {
cpuStateMonitorLITTLE = mCpuSpyLITTLE.getCpuStateMonitor();
}
try {
cpuStateMonitor.setOffsets();
if (cpuStateMonitorLITTLE != null) {
cpuStateMonitorLITTLE.setOffsets();
}
} catch (CpuStateMonitor.CpuStateMonitorException ignored) {
}
mCpuSpyBig.saveOffsets(getActivity());
if (mCpuSpyLITTLE != null) {
mCpuSpyLITTLE.saveOffsets(getActivity());
}
updateView(cpuStateMonitor, mFreqBig);
if (cpuStateMonitorLITTLE != null) {
updateView(cpuStateMonitorLITTLE, mFreqLITTLE);
}
adjustScrollPosition();
}
});
frequencyButtonView.setRestoreListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CpuStateMonitor cpuStateMonitor = mCpuSpyBig.getCpuStateMonitor();
CpuStateMonitor cpuStateMonitorLITTLE = null;
if (mCpuSpyLITTLE != null) {
cpuStateMonitorLITTLE = mCpuSpyLITTLE.getCpuStateMonitor();
}
cpuStateMonitor.removeOffsets();
if (cpuStateMonitorLITTLE != null) {
cpuStateMonitorLITTLE.removeOffsets();
}
mCpuSpyBig.saveOffsets(getActivity());
if (mCpuSpyLITTLE != null) {
mCpuSpyLITTLE.saveOffsets(getActivity());
}
updateView(cpuStateMonitor, mFreqBig);
if (mCpuSpyLITTLE != null) {
updateView(cpuStateMonitorLITTLE, mFreqLITTLE);
}
adjustScrollPosition();
}
});
items.add(frequencyButtonView);
mFreqBig = new CardView(getActivity());
if (CPUFreq.isBigLITTLE()) {
mFreqBig.setTitle(getString(R.string.cluster_big));
} else {
mFreqBig.setFullSpan(true);
}
items.add(mFreqBig);
if (CPUFreq.isBigLITTLE()) {
mFreqLITTLE = new CardView(getActivity());
mFreqLITTLE.setTitle(getString(R.string.cluster_little));
items.add(mFreqLITTLE);
}
mCpuSpyBig = new CpuSpyApp(CPUFreq.getBigCpu(), getActivity());
if (CPUFreq.isBigLITTLE()) {
mCpuSpyLITTLE = new CpuSpyApp(CPUFreq.getLITTLECpu(), getActivity());
}
updateFrequency();
}
use of com.moro.mtweaks.views.recyclerview.CardView 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);
}
}
use of com.moro.mtweaks.views.recyclerview.CardView in project MTweaks-KernelAdiutorMOD by morogoku.
the class CustomControlsFragment method getCard.
private CardView getCard(final Controls.ControlItem controlItem) {
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));
final MenuItem onBoot = menu.add(Menu.NONE, 1, Menu.NONE, getString(R.string.on_boot)).setCheckable(true);
onBoot.setChecked(controlItem.isOnBootEnabled());
menu.add(Menu.NONE, 2, Menu.NONE, getString(R.string.export));
menu.add(Menu.NONE, 3, Menu.NONE, getString(R.string.delete));
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()) {
case 0:
edit(controlItem);
break;
case 1:
onBoot.setChecked(!onBoot.isChecked());
controlItem.enableOnBoot(onBoot.isChecked());
mControlsProvider.commit();
break;
case 2:
mExportItem = controlItem;
requestPermission(0, Manifest.permission.WRITE_EXTERNAL_STORAGE);
break;
case 3:
mDeleteDialog = ViewUtils.dialogBuilder(getString(R.string.sure_question), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
delete(controlItem.getUniqueId());
}
}, new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
mDeleteDialog = null;
}
}, getActivity()).setTitle(getString(R.string.delete));
mDeleteDialog.show();
break;
}
return false;
}
});
}
});
return cardView;
}
use of com.moro.mtweaks.views.recyclerview.CardView in project MTweaks-KernelAdiutorMOD by morogoku.
the class KSMFragment method addItems.
@Override
protected void addItems(List<RecyclerViewItem> items) {
infoInit(items);
CardView ksm = new CardView(getActivity());
if (KSM.isUKSM()) {
ksm.setTitle(getString(R.string.uksm_name));
} else {
ksm.setTitle(getString(R.string.ksm));
}
ksm.setFullSpan(true);
if (KSM.hasEnable()) {
SwitchView enable = new SwitchView();
if (KSM.isUKSM()) {
enable.setTitle(getString(R.string.uksm_name));
} else {
enable.setTitle(getString(R.string.ksm));
}
enable.setSummary(getString(R.string.ksm_summary));
enable.setChecked(KSM.isEnabled());
enable.addOnSwitchListener(new SwitchView.OnSwitchListener() {
@Override
public void onChanged(SwitchView switchView, boolean isChecked) {
KSM.enableKsm(isChecked, getActivity());
}
});
ksm.addItem(enable);
}
if (KSM.hasCpuGovernor()) {
SelectView governor = new SelectView();
governor.setTitle(getString(R.string.uksm_governor));
governor.setSummary(getString(R.string.uksm_governor_summary));
governor.setItems(KSM.getCpuGovernors());
governor.setItem(KSM.getCpuGovernor());
governor.setOnItemSelected(new SelectView.OnItemSelected() {
@Override
public void onItemSelected(SelectView selectView, int position, String item) {
KSM.setCpuGovernor(item, getActivity());
}
});
ksm.addItem(governor);
}
if (KSM.hasDeferredTimer()) {
SwitchView deferredTimer = new SwitchView();
deferredTimer.setTitle(getString(R.string.deferred_timer));
deferredTimer.setSummary(getString(R.string.deferred_timer_summary));
deferredTimer.setChecked(KSM.isDeferredTimerEnabled());
deferredTimer.addOnSwitchListener(new SwitchView.OnSwitchListener() {
@Override
public void onChanged(SwitchView switchView, boolean isChecked) {
KSM.enableDeferredTimer(isChecked, getActivity());
}
});
ksm.addItem(deferredTimer);
}
if (KSM.hasPagesToScan()) {
SeekBarView pagesToScan = new SeekBarView();
pagesToScan.setTitle(getString(R.string.pages_to_scan));
pagesToScan.setMax(1024);
pagesToScan.setProgress(KSM.getPagesToScan());
pagesToScan.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {
@Override
public void onStop(SeekBarView seekBarView, int position, String value) {
KSM.setPagesToScan(position, getActivity());
}
@Override
public void onMove(SeekBarView seekBarView, int position, String value) {
}
});
ksm.addItem(pagesToScan);
}
if (KSM.hasSleepMilliseconds()) {
SeekBarView sleepMilliseconds = new SeekBarView();
sleepMilliseconds.setTitle(getString(R.string.sleep_milliseconds));
sleepMilliseconds.setUnit(getString(R.string.ms));
sleepMilliseconds.setMax(5000);
sleepMilliseconds.setOffset(50);
sleepMilliseconds.setProgress(KSM.getSleepMilliseconds() / 50);
sleepMilliseconds.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {
@Override
public void onStop(SeekBarView seekBarView, int position, String value) {
KSM.setSleepMilliseconds(position * 50, getActivity());
}
@Override
public void onMove(SeekBarView seekBarView, int position, String value) {
}
});
ksm.addItem(sleepMilliseconds);
}
if (KSM.hasMaxCpuPercentage()) {
SeekBarView maxCpuPercentage = new SeekBarView();
maxCpuPercentage.setTitle(getString(R.string.max_cpu_usage));
maxCpuPercentage.setSummary(getString(R.string.max_cpu_usage_summary));
maxCpuPercentage.setUnit("%");
maxCpuPercentage.setProgress(KSM.getMaxCpuPercentage());
maxCpuPercentage.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {
@Override
public void onStop(SeekBarView seekBarView, int position, String value) {
KSM.setMaxCpuPercentage(position, getActivity());
}
@Override
public void onMove(SeekBarView seekBarView, int position, String value) {
}
});
ksm.addItem(maxCpuPercentage);
}
if (ksm.size() > 0) {
items.add(ksm);
}
}
Aggregations