use of com.moro.mtweaks.views.recyclerview.SeekBarView in project MTweaks-KernelAdiutorMOD by morogoku.
the class VMFragment method zramInit.
private void zramInit(List<RecyclerViewItem> items) {
CardView zramCard = new CardView(getActivity());
zramCard.setTitle(getString(R.string.zram));
SeekBarView zram = new SeekBarView();
zram.setTitle(getString(R.string.disksize));
zram.setSummary(getString(R.string.disksize_summary));
zram.setUnit(getString(R.string.mb));
zram.setMax(2048);
zram.setOffset(10);
zram.setProgress(ZRAM.getDisksize() / 10);
zram.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {
@Override
public void onStop(SeekBarView seekBarView, int position, String value) {
ZRAM.setDisksize(position * 10, getActivity());
}
@Override
public void onMove(SeekBarView seekBarView, int position, String value) {
}
});
zramCard.addItem(zram);
if (zramCard.size() > 0) {
items.add(zramCard);
}
}
use of com.moro.mtweaks.views.recyclerview.SeekBarView in project MTweaks-KernelAdiutorMOD by morogoku.
the class CustomControlsFragment method load.
private void load(List<RecyclerViewItem> items) {
mControlsProvider = new Controls(getActivity());
for (final Controls.ControlItem item : mControlsProvider.getAllControls()) {
CardView cardView = getCard(item);
cardView.clearItems();
try {
String title = item.getTitle();
String description = item.getDescription();
if (item.getControl() == Items.Control.SWITCH) {
SwitchView switchView = new SwitchView();
if (description != null) {
switchView.setTitle(title);
switchView.setSummary(description);
} else {
switchView.setSummary(title);
}
switchView.setChecked(Values.getBool(item.getString("enable")));
switchView.addOnSwitchListener(new SwitchView.OnSwitchListener() {
@Override
public void onChanged(SwitchView switchView, boolean isChecked) {
Values.run(item.getApply(), item, isChecked ? "1" : "0");
mControlsProvider.commit();
}
});
cardView.addItem(switchView);
} else if (item.getControl() == Items.Control.SEEKBAR) {
SeekBarView seekBarView = new SeekBarView();
seekBarView.setTitle(title);
if (description != null) {
seekBarView.setSummary(description);
}
seekBarView.setMax(item.getInt("max"));
seekBarView.setMin(item.getInt("min"));
seekBarView.setProgress(Values.getInt(item.getString("progress")));
seekBarView.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {
@Override
public void onStop(SeekBarView seekBarView, int position, String value) {
Values.run(item.getApply(), item, String.valueOf(position));
mControlsProvider.commit();
}
@Override
public void onMove(SeekBarView seekBarView, int position, String value) {
}
});
cardView.addItem(seekBarView);
} else if (item.getControl() == Items.Control.GENERIC) {
GenericSelectView genericSelectView = new GenericSelectView();
if (description != null) {
genericSelectView.setTitle(title);
genericSelectView.setSummary(description);
} else {
genericSelectView.setSummary(title);
}
genericSelectView.setValue(Values.getString(item.getString("value")));
genericSelectView.setValueRaw(genericSelectView.getValue());
genericSelectView.setOnGenericValueListener(new GenericSelectView.OnGenericValueListener() {
@Override
public void onGenericValueSelected(GenericSelectView genericSelectView, String value) {
Values.run(item.getApply(), item, value);
genericSelectView.setValue(value);
mControlsProvider.commit();
}
});
cardView.addItem(genericSelectView);
}
} catch (CustomControlException e) {
ErrorView errorView = new ErrorView();
errorView.setException(e);
cardView.addItem(errorView);
}
items.add(cardView);
}
}
use of com.moro.mtweaks.views.recyclerview.SeekBarView in project MTweaks-KernelAdiutorMOD by morogoku.
the class WakelockFragment method wakelocksInit.
private void wakelocksInit(List<RecyclerViewItem> items) {
CardView wake = new CardView(getActivity());
wake.setTitle(getString(R.string.wkl_control));
if (Wakelock.hasSensorHub()) {
SwitchView sh = new SwitchView();
sh.setTitle(getString(R.string.wkl_sensorhub));
sh.setSummary(getString(R.string.wkl_sensorhub_summary));
sh.setChecked(Wakelock.isSensorHubEnabled());
sh.addOnSwitchListener(new SwitchView.OnSwitchListener() {
@Override
public void onChanged(SwitchView switchView, boolean isChecked) {
Wakelock.enableSensorHub(isChecked, getActivity());
}
});
wake.addItem(sh);
}
if (Wakelock.hasSSP()) {
SwitchView ssp = new SwitchView();
ssp.setTitle(getString(R.string.wkl_ssp));
ssp.setSummary(getString(R.string.wkl_ssp_summary));
ssp.setChecked(Wakelock.isSSPEnabled());
ssp.addOnSwitchListener(new SwitchView.OnSwitchListener() {
@Override
public void onChanged(SwitchView switchView, boolean isChecked) {
Wakelock.enableSSP(isChecked, getActivity());
}
});
wake.addItem(ssp);
}
if (Wakelock.hasGPS()) {
SwitchView gps = new SwitchView();
gps.setTitle(getString(R.string.wkl_gps));
gps.setSummary(getString(R.string.wkl_gps_summary));
gps.setChecked(Wakelock.isGPSEnabled());
gps.addOnSwitchListener(new SwitchView.OnSwitchListener() {
@Override
public void onChanged(SwitchView switchView, boolean isChecked) {
Wakelock.enableGPS(isChecked, getActivity());
}
});
wake.addItem(gps);
}
if (Wakelock.hasWireless()) {
SwitchView wifi = new SwitchView();
wifi.setTitle(getString(R.string.wkl_wireless));
wifi.setSummary(getString(R.string.wkl_wireless_summary));
wifi.setChecked(Wakelock.isWirelessEnabled());
wifi.addOnSwitchListener(new SwitchView.OnSwitchListener() {
@Override
public void onChanged(SwitchView switchView, boolean isChecked) {
Wakelock.enableWireless(isChecked, getActivity());
}
});
wake.addItem(wifi);
}
if (Wakelock.hasBluetooth()) {
SwitchView bt = new SwitchView();
bt.setTitle(getString(R.string.wkl_bluetooth));
bt.setSummary(getString(R.string.wkl_bluetooth_summary));
bt.setChecked(Wakelock.isBluetoothEnabled());
bt.addOnSwitchListener(new SwitchView.OnSwitchListener() {
@Override
public void onChanged(SwitchView switchView, boolean isChecked) {
Wakelock.enableBluetooth(isChecked, getActivity());
}
});
wake.addItem(bt);
}
if (Wakelock.hasBattery()) {
SeekBarView bat = new SeekBarView();
bat.setTitle(getString(R.string.wkl_battery));
bat.setSummary(getString(R.string.wkl_battery_summary));
bat.setMax(15);
bat.setMin(1);
bat.setProgress(Utils.strToInt(Wakelock.getBattery()) - 1);
bat.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {
@Override
public void onStop(SeekBarView seekBarView, int position, String value) {
Wakelock.setBattery((position + 1), getActivity());
}
@Override
public void onMove(SeekBarView seekBarView, int position, String value) {
}
});
wake.addItem(bat);
}
if (Wakelock.hasNFC()) {
SeekBarView nfc = new SeekBarView();
nfc.setTitle(getString(R.string.wkl_nfc));
nfc.setSummary(getString(R.string.wkl_nfc_summary));
nfc.setMax(3);
nfc.setMin(1);
nfc.setProgress(Utils.strToInt(Wakelock.getNFC()) - 1);
nfc.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {
@Override
public void onStop(SeekBarView seekBarView, int position, String value) {
Wakelock.setNFC((position + 1), getActivity());
}
@Override
public void onMove(SeekBarView seekBarView, int position, String value) {
}
});
wake.addItem(nfc);
}
if (wake.size() > 0) {
items.add(wake);
}
}
use of com.moro.mtweaks.views.recyclerview.SeekBarView in project MTweaks-KernelAdiutorMOD by morogoku.
the class BatteryFragment method blxInit.
private void blxInit(List<RecyclerViewItem> items) {
List<String> list = new ArrayList<>();
list.add(getString(R.string.disabled));
for (int i = 0; i <= 100; i++) {
list.add(String.valueOf(i));
}
SeekBarView blx = new SeekBarView();
blx.setTitle(getString(R.string.blx));
blx.setSummary(getString(R.string.blx_summary));
blx.setItems(list);
blx.setProgress(Battery.getBlx());
blx.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {
@Override
public void onStop(SeekBarView seekBarView, int position, String value) {
Battery.setBlx(position, getActivity());
}
@Override
public void onMove(SeekBarView seekBarView, int position, String value) {
}
});
items.add(blx);
}
use of com.moro.mtweaks.views.recyclerview.SeekBarView in project MTweaks-KernelAdiutorMOD by morogoku.
the class BatteryFragment method chargeRateInit.
private void chargeRateInit(List<RecyclerViewItem> items) {
CardView chargeRateCard = new CardView(getActivity());
chargeRateCard.setTitle(getString(R.string.charge_rate));
if (Battery.hasChargeRateEnable()) {
SwitchView chargeRate = new SwitchView();
chargeRate.setSummary(getString(R.string.charge_rate));
chargeRate.setChecked(Battery.isChargeRateEnabled());
chargeRate.addOnSwitchListener(new SwitchView.OnSwitchListener() {
@Override
public void onChanged(SwitchView switchView, boolean isChecked) {
Battery.enableChargeRate(isChecked, getActivity());
}
});
chargeRateCard.addItem(chargeRate);
}
if (Battery.hasChargingCurrent()) {
SeekBarView chargingCurrent = new SeekBarView();
chargingCurrent.setTitle(getString(R.string.charging_current));
chargingCurrent.setSummary(getString(R.string.charging_current_summary));
chargingCurrent.setUnit(getString(R.string.ma));
chargingCurrent.setMax(1500);
chargingCurrent.setMin(100);
chargingCurrent.setOffset(10);
chargingCurrent.setProgress(Battery.getChargingCurrent() / 10 - 10);
chargingCurrent.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {
@Override
public void onStop(SeekBarView seekBarView, int position, String value) {
Battery.setChargingCurrent((position + 10) * 10, getActivity());
}
@Override
public void onMove(SeekBarView seekBarView, int position, String value) {
}
});
chargeRateCard.addItem(chargingCurrent);
}
if (chargeRateCard.size() > 0) {
items.add(chargeRateCard);
}
}
Aggregations