Search in sources :

Example 36 with SeekBarView

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);
    }
}
Also used : CardView(com.moro.mtweaks.views.recyclerview.CardView) SeekBarView(com.moro.mtweaks.views.recyclerview.SeekBarView)

Example 37 with SeekBarView

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);
    }
}
Also used : CustomControlException(com.moro.mtweaks.utils.tools.customcontrols.CustomControlException) SwitchView(com.moro.mtweaks.views.recyclerview.SwitchView) CardView(com.moro.mtweaks.views.recyclerview.CardView) SeekBarView(com.moro.mtweaks.views.recyclerview.SeekBarView) GenericSelectView(com.moro.mtweaks.views.recyclerview.GenericSelectView) Controls(com.moro.mtweaks.database.tools.customcontrols.Controls) ErrorView(com.moro.mtweaks.views.recyclerview.customcontrols.ErrorView)

Example 38 with SeekBarView

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);
    }
}
Also used : SwitchView(com.moro.mtweaks.views.recyclerview.SwitchView) CardView(com.moro.mtweaks.views.recyclerview.CardView) SeekBarView(com.moro.mtweaks.views.recyclerview.SeekBarView)

Example 39 with SeekBarView

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);
}
Also used : ArrayList(java.util.ArrayList) SeekBarView(com.moro.mtweaks.views.recyclerview.SeekBarView)

Example 40 with SeekBarView

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);
    }
}
Also used : SwitchView(com.moro.mtweaks.views.recyclerview.SwitchView) CardView(com.moro.mtweaks.views.recyclerview.CardView) SeekBarView(com.moro.mtweaks.views.recyclerview.SeekBarView)

Aggregations

SeekBarView (com.moro.mtweaks.views.recyclerview.SeekBarView)53 SwitchView (com.moro.mtweaks.views.recyclerview.SwitchView)31 CardView (com.moro.mtweaks.views.recyclerview.CardView)23 ArrayList (java.util.ArrayList)23 TitleView (com.moro.mtweaks.views.recyclerview.TitleView)18 RecyclerViewItem (com.moro.mtweaks.views.recyclerview.RecyclerViewItem)14 SelectView (com.moro.mtweaks.views.recyclerview.SelectView)12 DescriptionView (com.moro.mtweaks.views.recyclerview.DescriptionView)4 GenericSelectView2 (com.moro.mtweaks.views.recyclerview.GenericSelectView2)2 Vibrator (android.os.Vibrator)1 Controls (com.moro.mtweaks.database.tools.customcontrols.Controls)1 Wakelocks (com.moro.mtweaks.utils.kernel.misc.Wakelocks)1 CustomControlException (com.moro.mtweaks.utils.tools.customcontrols.CustomControlException)1 GenericSelectView (com.moro.mtweaks.views.recyclerview.GenericSelectView)1 ErrorView (com.moro.mtweaks.views.recyclerview.customcontrols.ErrorView)1 List (java.util.List)1