use of com.moro.mtweaks.views.recyclerview.SwitchView in project MTweaks-KernelAdiutorMOD by morogoku.
the class VMFragment method CardVmTunablesInit.
private void CardVmTunablesInit(final CardView card) {
card.clearItems();
mVMs.clear();
mCompleteList = Prefs.getBoolean("vm_show_complete_list", false, getActivity());
SwitchView sv = new SwitchView();
sv.setTitle(getString(R.string.vm_tun_switch_title));
sv.setSummary(getString(R.string.vm_tun_switch_summary));
sv.setChecked(mCompleteList);
sv.addOnSwitchListener(new SwitchView.OnSwitchListener() {
@Override
public void onChanged(SwitchView switchView, boolean isChecked) {
mCompleteList = isChecked;
Prefs.saveBoolean("vm_show_complete_list", mCompleteList, getActivity());
getHandler().postDelayed(new Runnable() {
@Override
public void run() {
CardVmTunablesInit(card);
}
}, 250);
}
});
card.addItem(sv);
TitleView tit = new TitleView();
if (mCompleteList) {
tit.setText(getString(R.string.vm_tun_tit_all));
} else {
tit.setText(getString(R.string.vm_tun_tit_common));
}
card.addItem(tit);
for (int i = 0; i < VM.size(mCompleteList); i++) {
GenericSelectView2 vm = new GenericSelectView2();
vm.setTitle(VM.getName(i, mCompleteList));
vm.setValue(VM.getValue(i, mCompleteList));
vm.setValueRaw(vm.getValue());
vm.setInputType(InputType.TYPE_CLASS_NUMBER);
final int position = i;
vm.setOnGenericValueListener(new GenericSelectView2.OnGenericValueListener() {
@Override
public void onGenericValueSelected(GenericSelectView2 genericSelectView, String value) {
VM.setValue(value, position, getActivity(), mCompleteList);
genericSelectView.setValue(value);
refreshVMs();
}
});
card.addItem(vm);
mVMs.add(vm);
}
}
use of com.moro.mtweaks.views.recyclerview.SwitchView in project MTweaks-KernelAdiutorMOD by morogoku.
the class CPUFragment method freqInit.
private void freqInit(List<RecyclerViewItem> items) {
CardView bigCard = new CardView(getActivity());
if (CPUFreq.isBigLITTLE()) {
bigCard.setTitle(getString(R.string.cluster_big));
}
mCPUUsageBig = new XYGraphView();
mCPUUsageBig.setTitle(getString(R.string.cpu_usage));
bigCard.addItem(mCPUUsageBig);
final List<Integer> bigCores = CPUFreq.getBigCpuRange();
mCoresBig.clear();
for (final int core : bigCores) {
SwitchView coreSwitch = new SwitchView();
coreSwitch.setSummary(getString(R.string.core, core + 1));
mCoresBig.put(core, coreSwitch);
bigCard.addItem(coreSwitch);
}
mCPUMaxBig = new SelectView();
mCPUMaxBig.setTitle(getString(R.string.cpu_max_freq));
mCPUMaxBig.setSummary(getString(R.string.cpu_max_freq_summary));
mCPUMaxBig.setItems(CPUFreq.getAdjustedFreq(getActivity()));
mCPUMaxBig.setOnItemSelected(new SelectView.OnItemSelected() {
@Override
public void onItemSelected(SelectView selectView, int position, String item) {
CPUFreq.setMaxFreq(CPUFreq.getFreqs().get(position), bigCores.get(0), bigCores.get(bigCores.size() - 1), getActivity());
}
});
bigCard.addItem(mCPUMaxBig);
mCPUMinBig = new SelectView();
mCPUMinBig.setTitle(getString(R.string.cpu_min_freq));
mCPUMinBig.setSummary(getString(R.string.cpu_min_freq_summary));
mCPUMinBig.setItems(CPUFreq.getAdjustedFreq(getActivity()));
mCPUMinBig.setOnItemSelected(new SelectView.OnItemSelected() {
@Override
public void onItemSelected(SelectView selectView, int position, String item) {
CPUFreq.setMinFreq(CPUFreq.getFreqs().get(position), bigCores.get(0), bigCores.get(bigCores.size() - 1), getActivity());
}
});
bigCard.addItem(mCPUMinBig);
if (CPUFreq.hasMaxScreenOffFreq()) {
mCPUMaxScreenOffBig = new SelectView();
mCPUMaxScreenOffBig.setTitle(getString(R.string.cpu_max_screen_off_freq));
mCPUMaxScreenOffBig.setSummary(getString(R.string.cpu_max_screen_off_freq_summary));
mCPUMaxScreenOffBig.setItems(CPUFreq.getAdjustedFreq(getActivity()));
mCPUMaxScreenOffBig.setOnItemSelected(new SelectView.OnItemSelected() {
@Override
public void onItemSelected(SelectView selectView, int position, String item) {
CPUFreq.setMaxScreenOffFreq(CPUFreq.getFreqs().get(position), bigCores.get(0), bigCores.get(bigCores.size() - 1), getActivity());
}
});
bigCard.addItem(mCPUMaxScreenOffBig);
}
mCPUGovernorBig = new SelectView();
mCPUGovernorBig.setTitle(getString(R.string.cpu_governor));
mCPUGovernorBig.setSummary(getString(R.string.cpu_governor_summary));
mCPUGovernorBig.setItems(CPUFreq.getGovernors());
mCPUGovernorBig.setOnItemSelected(new SelectView.OnItemSelected() {
@Override
public void onItemSelected(SelectView selectView, int position, String item) {
CPUFreq.setGovernor(item, bigCores.get(0), bigCores.get(bigCores.size() - 1), getActivity());
}
});
bigCard.addItem(mCPUGovernorBig);
DescriptionView governorTunablesBig = new DescriptionView();
governorTunablesBig.setTitle(getString(R.string.cpu_governor_tunables));
governorTunablesBig.setSummary(getString(R.string.governor_tunables_summary));
governorTunablesBig.setOnItemClickListener(new RecyclerViewItem.OnItemClickListener() {
@Override
public void onClick(RecyclerViewItem item) {
showGovernorTunables(bigCores.get(0), bigCores.get(bigCores.size() - 1));
}
});
bigCard.addItem(governorTunablesBig);
items.add(bigCard);
if (CPUFreq.isBigLITTLE()) {
CardView LITTLECard = new CardView(getActivity());
LITTLECard.setTitle(getString(R.string.cluster_little));
mCPUUsageLITTLE = new XYGraphView();
mCPUUsageLITTLE.setTitle(getString(R.string.cpu_usage));
LITTLECard.addItem(mCPUUsageLITTLE);
final List<Integer> LITTLECores = CPUFreq.getLITTLECpuRange();
mCoresLITTLE.clear();
for (final int core : LITTLECores) {
SwitchView coreSwitch = new SwitchView();
coreSwitch.setSummary(getString(R.string.core, core + 1));
mCoresLITTLE.put(core, coreSwitch);
LITTLECard.addItem(coreSwitch);
}
mCPUMaxLITTLE = new SelectView();
mCPUMaxLITTLE.setTitle(getString(R.string.cpu_max_freq));
mCPUMaxLITTLE.setSummary(getString(R.string.cpu_max_freq_summary));
mCPUMaxLITTLE.setItems(CPUFreq.getAdjustedFreq(CPUFreq.getLITTLECpu(), getActivity()));
mCPUMaxLITTLE.setOnItemSelected(new SelectView.OnItemSelected() {
@Override
public void onItemSelected(SelectView selectView, int position, String item) {
CPUFreq.setMaxFreq(CPUFreq.getFreqs(CPUFreq.getLITTLECpu()).get(position), LITTLECores.get(0), LITTLECores.get(LITTLECores.size() - 1), getActivity());
}
});
LITTLECard.addItem(mCPUMaxLITTLE);
mCPUMinLITTLE = new SelectView();
mCPUMinLITTLE.setTitle(getString(R.string.cpu_min_freq));
mCPUMinLITTLE.setSummary(getString(R.string.cpu_min_freq_summary));
mCPUMinLITTLE.setItems(CPUFreq.getAdjustedFreq(CPUFreq.getLITTLECpu(), getActivity()));
mCPUMinLITTLE.setOnItemSelected(new SelectView.OnItemSelected() {
@Override
public void onItemSelected(SelectView selectView, int position, String item) {
CPUFreq.setMinFreq(CPUFreq.getFreqs(CPUFreq.getLITTLECpu()).get(position), LITTLECores.get(0), LITTLECores.get(LITTLECores.size() - 1), getActivity());
}
});
LITTLECard.addItem(mCPUMinLITTLE);
if (CPUFreq.hasMaxScreenOffFreq(CPUFreq.getLITTLECpu())) {
mCPUMaxScreenOffLITTLE = new SelectView();
mCPUMaxScreenOffLITTLE.setTitle(getString(R.string.cpu_max_screen_off_freq));
mCPUMaxScreenOffLITTLE.setSummary(getString(R.string.cpu_max_screen_off_freq_summary));
mCPUMaxScreenOffLITTLE.setItems(CPUFreq.getAdjustedFreq(CPUFreq.getLITTLECpu(), getActivity()));
mCPUMaxScreenOffLITTLE.setOnItemSelected(new SelectView.OnItemSelected() {
@Override
public void onItemSelected(SelectView selectView, int position, String item) {
CPUFreq.setMaxScreenOffFreq(CPUFreq.getFreqs(CPUFreq.getLITTLECpu()).get(position), LITTLECores.get(0), LITTLECores.get(LITTLECores.size() - 1), getActivity());
}
});
LITTLECard.addItem(mCPUMaxScreenOffLITTLE);
}
mCPUGovernorLITTLE = new SelectView();
mCPUGovernorLITTLE.setTitle(getString(R.string.cpu_governor));
mCPUGovernorLITTLE.setSummary(getString(R.string.cpu_governor_summary));
mCPUGovernorLITTLE.setItems(CPUFreq.getGovernors());
mCPUGovernorLITTLE.setOnItemSelected(new SelectView.OnItemSelected() {
@Override
public void onItemSelected(SelectView selectView, int position, String item) {
CPUFreq.setGovernor(item, LITTLECores.get(0), LITTLECores.get(LITTLECores.size() - 1), getActivity());
}
});
LITTLECard.addItem(mCPUGovernorLITTLE);
DescriptionView governorTunablesLITTLE = new DescriptionView();
governorTunablesLITTLE.setTitle(getString(R.string.cpu_governor_tunables));
governorTunablesLITTLE.setSummary(getString(R.string.governor_tunables_summary));
governorTunablesLITTLE.setOnItemClickListener(new RecyclerViewItem.OnItemClickListener() {
@Override
public void onClick(RecyclerViewItem item) {
showGovernorTunables(LITTLECores.get(0), LITTLECores.get(LITTLECores.size() - 1));
}
});
LITTLECard.addItem(governorTunablesLITTLE);
items.add(LITTLECard);
}
}
use of com.moro.mtweaks.views.recyclerview.SwitchView in project MTweaks-KernelAdiutorMOD by morogoku.
the class CPUFragment method refreshCores.
private void refreshCores(SparseArray<SwitchView> array) {
try {
for (int i = 0; i < array.size(); i++) {
SwitchView switchView = array.valueAt(i);
if (switchView != null) {
final int core = array.keyAt(i);
int freq = CPUFreq.getCurFreq(core);
String freqText = freq == 0 ? getString(R.string.offline) : (freq / 1000) + getString(R.string.mhz);
switchView.clearOnSwitchListener();
switchView.setChecked(freq != 0);
switchView.setSummary(getString(R.string.core, core + 1) + " - " + freqText);
switchView.addOnSwitchListener(new SwitchView.OnSwitchListener() {
@Override
public void onChanged(SwitchView switchView, boolean isChecked) {
if (core == 0) {
Utils.toast(R.string.no_offline_core, getActivity());
} else {
CPUFreq.onlineCpu(core, isChecked, true, getActivity());
}
}
});
}
}
} catch (ConcurrentModificationException ignored) {
}
}
use of com.moro.mtweaks.views.recyclerview.SwitchView in project MTweaks-KernelAdiutorMOD by morogoku.
the class CPUHotplugFragment method mpdecisionInit.
private void mpdecisionInit(List<RecyclerViewItem> items) {
SwitchView mpdecision = new SwitchView();
mpdecision.setTitle(getString(R.string.mpdecision));
mpdecision.setSummary(getString(R.string.mpdecision_summary));
mpdecision.setChecked(MPDecision.isMpdecisionEnabled());
mpdecision.addOnSwitchListener(new SwitchView.OnSwitchListener() {
@Override
public void onChanged(SwitchView switchView, boolean isChecked) {
MPDecision.enableMpdecision(isChecked, getActivity());
}
});
items.add(mpdecision);
mEnableViews.add(mpdecision);
}
use of com.moro.mtweaks.views.recyclerview.SwitchView in project MTweaks-KernelAdiutorMOD by morogoku.
the class CPUHotplugFragment method makoHotplugInit.
private void makoHotplugInit(List<RecyclerViewItem> items) {
List<RecyclerViewItem> makoHotplug = new ArrayList<>();
TitleView title = new TitleView();
title.setText(getString(R.string.mako_hotplug));
if (MakoHotplug.hasMakoHotplugEnable()) {
SwitchView enable = new SwitchView();
enable.setTitle(getString(R.string.mako_hotplug));
enable.setSummary(getString(R.string.mako_hotplug_summary));
enable.setChecked(MakoHotplug.isMakoHotplugEnabled());
enable.addOnSwitchListener(new SwitchView.OnSwitchListener() {
@Override
public void onChanged(SwitchView switchView, boolean isChecked) {
MakoHotplug.enableMakoHotplug(isChecked, getActivity());
}
});
makoHotplug.add(enable);
mEnableViews.add(enable);
}
if (MakoHotplug.hasMakoHotplugCoresOnTouch()) {
SeekBarView coresOnTouch = new SeekBarView();
coresOnTouch.setTitle(getString(R.string.cpus_on_touch));
coresOnTouch.setSummary(getString(R.string.cpus_on_touch_summary));
coresOnTouch.setMax(CPUFreq.getCpuCount());
coresOnTouch.setMin(1);
coresOnTouch.setProgress(MakoHotplug.getMakoHotplugCoresOnTouch() - 1);
coresOnTouch.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {
@Override
public void onMove(SeekBarView seekBarView, int position, String value) {
}
@Override
public void onStop(SeekBarView seekBarView, int position, String value) {
MakoHotplug.setMakoHotplugCoresOnTouch(position + 1, getActivity());
}
});
makoHotplug.add(coresOnTouch);
}
if (MakoHotplug.hasMakoHotplugCpuFreqUnplugLimit() && CPUFreq.getFreqs() != null) {
SelectView cpufreqUnplugLimit = new SelectView();
cpufreqUnplugLimit.setSummary(getString(R.string.cpu_freq_unplug_limit));
cpufreqUnplugLimit.setItems(CPUFreq.getAdjustedFreq(getActivity()));
cpufreqUnplugLimit.setItem((MakoHotplug.getMakoHotplugCpuFreqUnplugLimit() / 1000) + getString(R.string.mhz));
cpufreqUnplugLimit.setOnItemSelected(new SelectView.OnItemSelected() {
@Override
public void onItemSelected(SelectView selectView, int position, String item) {
MakoHotplug.setMakoHotplugCpuFreqUnplugLimit(CPUFreq.getFreqs().get(position), getActivity());
}
});
makoHotplug.add(cpufreqUnplugLimit);
}
if (MakoHotplug.hasMakoHotplugFirstLevel()) {
SeekBarView firstLevel = new SeekBarView();
firstLevel.setTitle(getString(R.string.first_level));
firstLevel.setSummary(getString(R.string.first_level_summary));
firstLevel.setUnit("%");
firstLevel.setProgress(MakoHotplug.getMakoHotplugFirstLevel());
firstLevel.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {
@Override
public void onMove(SeekBarView seekBarView, int position, String value) {
}
@Override
public void onStop(SeekBarView seekBarView, int position, String value) {
MakoHotplug.setMakoHotplugFirstLevel(position, getActivity());
}
});
makoHotplug.add(firstLevel);
}
if (MakoHotplug.hasMakoHotplugHighLoadCounter()) {
SeekBarView highLoadCounter = new SeekBarView();
highLoadCounter.setTitle(getString(R.string.high_load_counter));
highLoadCounter.setProgress(MakoHotplug.getMakoHotplugHighLoadCounter());
highLoadCounter.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {
@Override
public void onMove(SeekBarView seekBarView, int position, String value) {
}
@Override
public void onStop(SeekBarView seekBarView, int position, String value) {
MakoHotplug.setMakoHotplugHighLoadCounter(position, getActivity());
}
});
makoHotplug.add(highLoadCounter);
}
if (MakoHotplug.hasMakoHotplugLoadThreshold()) {
SeekBarView loadThreshold = new SeekBarView();
loadThreshold.setTitle(getString(R.string.load_threshold));
loadThreshold.setSummary(getString(R.string.load_threshold_summary));
loadThreshold.setUnit("%");
loadThreshold.setProgress(MakoHotplug.getMakoHotplugLoadThreshold());
loadThreshold.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {
@Override
public void onMove(SeekBarView seekBarView, int position, String value) {
}
@Override
public void onStop(SeekBarView seekBarView, int position, String value) {
MakoHotplug.setMakoHotplugLoadThreshold(position, getActivity());
}
});
makoHotplug.add(loadThreshold);
}
if (MakoHotplug.hasMakoHotplugMaxLoadCounter()) {
SeekBarView maxLoadCounter = new SeekBarView();
maxLoadCounter.setTitle(getString(R.string.max_load_counter));
maxLoadCounter.setProgress(MakoHotplug.getMakoHotplugMaxLoadCounter());
maxLoadCounter.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {
@Override
public void onMove(SeekBarView seekBarView, int position, String value) {
}
@Override
public void onStop(SeekBarView seekBarView, int position, String value) {
MakoHotplug.setMakoHotplugMaxLoadCounter(position, getActivity());
}
});
makoHotplug.add(maxLoadCounter);
}
if (MakoHotplug.hasMakoHotplugMinTimeCpuOnline()) {
SeekBarView minTimeCpuOnline = new SeekBarView();
minTimeCpuOnline.setTitle(getString(R.string.min_time_cpu_online));
minTimeCpuOnline.setProgress(MakoHotplug.getMakoHotplugMinTimeCpuOnline());
minTimeCpuOnline.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {
@Override
public void onMove(SeekBarView seekBarView, int position, String value) {
}
@Override
public void onStop(SeekBarView seekBarView, int position, String value) {
MakoHotplug.setMakoHotplugMinTimeCpuOnline(position, getActivity());
}
});
makoHotplug.add(minTimeCpuOnline);
}
if (MakoHotplug.hasMakoHotplugMinCoresOnline()) {
SeekBarView minCoresOnline = new SeekBarView();
minCoresOnline.setTitle(getString(R.string.min_cpu_online));
minCoresOnline.setSummary(getString(R.string.min_cpu_online_summary));
minCoresOnline.setMax(CPUFreq.getCpuCount());
minCoresOnline.setMin(1);
minCoresOnline.setProgress(MakoHotplug.getMakoHotplugMinCoresOnline() - 1);
minCoresOnline.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {
@Override
public void onMove(SeekBarView seekBarView, int position, String value) {
}
@Override
public void onStop(SeekBarView seekBarView, int position, String value) {
MakoHotplug.setMakoHotplugMinCoresOnline(position + 1, getActivity());
}
});
makoHotplug.add(minCoresOnline);
}
if (MakoHotplug.hasMakoHotplugTimer()) {
SeekBarView timer = new SeekBarView();
timer.setTitle(getString(R.string.timer));
timer.setProgress(MakoHotplug.getMakoHotplugTimer());
timer.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {
@Override
public void onMove(SeekBarView seekBarView, int position, String value) {
}
@Override
public void onStop(SeekBarView seekBarView, int position, String value) {
MakoHotplug.setMakoHotplugTimer(position, getActivity());
}
});
makoHotplug.add(timer);
}
if (MakoHotplug.hasMakoHotplugSuspendFreq() && CPUFreq.getFreqs() != null) {
SelectView suspendFreq = new SelectView();
suspendFreq.setTitle(getString(R.string.cpu_max_screen_off_freq));
suspendFreq.setSummary(getString(R.string.cpu_max_screen_off_freq_summary));
suspendFreq.setItems(CPUFreq.getAdjustedFreq(getActivity()));
suspendFreq.setItem((MakoHotplug.getMakoHotplugSuspendFreq() / 1000) + getString(R.string.mhz));
suspendFreq.setOnItemSelected(new SelectView.OnItemSelected() {
@Override
public void onItemSelected(SelectView selectView, int position, String item) {
MakoHotplug.setMakoHotplugSuspendFreq(CPUFreq.getFreqs().get(position), getActivity());
}
});
makoHotplug.add(suspendFreq);
}
if (makoHotplug.size() > 0) {
items.add(title);
items.addAll(makoHotplug);
}
}
Aggregations