Search in sources :

Example 41 with SwitchView

use of com.moro.mtweaks.views.recyclerview.SwitchView in project MTweaks-KernelAdiutorMOD by morogoku.

the class ThermalFragment method msmThermalInit.

private void msmThermalInit(List<RecyclerViewItem> items) {
    if (MSMThermal.hasIntelliThermalEnable()) {
        SwitchView intelliThermal = new SwitchView();
        intelliThermal.setTitle(getString(R.string.intellithermal));
        intelliThermal.setSummary(getString(R.string.intellithermal_summary));
        intelliThermal.setChecked(MSMThermal.isIntelliThermalEnabled());
        intelliThermal.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                MSMThermal.enableIntelliThermal(isChecked, getActivity());
            }
        });
        items.add(intelliThermal);
    }
    if (MSMThermal.hasIntelliThermalOptimizedEnable()) {
        SwitchView intelliThermalOptimized = new SwitchView();
        intelliThermalOptimized.setTitle(getString(R.string.intellithermal_optimized));
        intelliThermalOptimized.setSummary(getString(R.string.intellithermal_optimized_summary));
        intelliThermalOptimized.setChecked(MSMThermal.isIntelliThermalOptimizedEnabled());
        intelliThermalOptimized.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                MSMThermal.enableIntelliThermalOptimized(isChecked, getActivity());
            }
        });
        items.add(intelliThermalOptimized);
    }
    if (MSMThermal.hasThermalDebugMode()) {
        SwitchView debugMode = new SwitchView();
        debugMode.setTitle(getString(R.string.debug_mask));
        debugMode.setSummary(getString(R.string.thermal_debug_mask_summary));
        debugMode.setChecked(MSMThermal.isThermalDebugModeEnabled());
        debugMode.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                MSMThermal.enableThermalDebugMode(isChecked, getActivity());
            }
        });
        items.add(debugMode);
    }
    if (MSMThermal.hasCoreControl()) {
        SwitchView coreControl = new SwitchView();
        coreControl.setSummary(getString(R.string.core_control));
        coreControl.setChecked(MSMThermal.isCoreControlEnabled());
        coreControl.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                MSMThermal.enableCoreControl(isChecked, getActivity());
            }
        });
        items.add(coreControl);
    }
    if (MSMThermal.hasVddRestrictionEnable()) {
        SwitchView vddRestriction = new SwitchView();
        vddRestriction.setSummary(getString(R.string.vdd_restriction));
        vddRestriction.setChecked(MSMThermal.isVddRestrictionEnabled());
        vddRestriction.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                MSMThermal.enableVddRestriction(isChecked, getActivity());
            }
        });
        items.add(vddRestriction);
    }
    if (MSMThermal.hasLimitTempDegC()) {
        boolean fahrenheit = Utils.useFahrenheit(getActivity());
        List<String> list = new ArrayList<>();
        for (int i = 50; i <= 100; i++) {
            list.add(String.valueOf(Utils.roundTo2Decimals(fahrenheit ? Utils.celsiusToFahrenheit(i) : i)));
        }
        SeekBarView limitTempDegC = new SeekBarView();
        limitTempDegC.setTitle(getString(R.string.freq_throttle_temp));
        limitTempDegC.setSummary(getString(R.string.freq_throttle_temp_summary));
        limitTempDegC.setUnit(getString(fahrenheit ? R.string.fahrenheit : R.string.celsius));
        limitTempDegC.setItems(list);
        limitTempDegC.setProgress(MSMThermal.getLimitTempDegC() - 50);
        limitTempDegC.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                MSMThermal.setLimitTempDegC(position + 50, getActivity());
            }
        });
        items.add(limitTempDegC);
    }
    if (MSMThermal.hasCoreLimitTempDegC()) {
        boolean fahrenheit = Utils.useFahrenheit(getActivity());
        List<String> list = new ArrayList<>();
        for (int i = 50; i <= 100; i++) {
            list.add(String.valueOf(Utils.roundTo2Decimals(fahrenheit ? Utils.celsiusToFahrenheit(i) : i)));
        }
        SeekBarView coreLimitTempDegC = new SeekBarView();
        coreLimitTempDegC.setTitle(getString(R.string.cpu_throttle_temp));
        coreLimitTempDegC.setSummary(getString(R.string.cpu_throttle_temp_summary));
        coreLimitTempDegC.setUnit(getString(fahrenheit ? R.string.fahrenheit : R.string.celsius));
        coreLimitTempDegC.setItems(list);
        coreLimitTempDegC.setProgress(MSMThermal.getCoreLimitTempDegC() - 50);
        coreLimitTempDegC.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                MSMThermal.setCoreLimitTempDegC(position + 50, getActivity());
            }
        });
        items.add(coreLimitTempDegC);
    }
    if (MSMThermal.hasCoreTempHysteresisDegC()) {
        boolean fahrenheit = Utils.useFahrenheit(getActivity());
        List<String> list = new ArrayList<>();
        for (int i = 0; i <= 20; i++) {
            list.add(String.valueOf(Utils.roundTo2Decimals(fahrenheit ? Utils.celsiusToFahrenheit(i) : i)));
        }
        SeekBarView coreTempHysteresisDegC = new SeekBarView();
        coreTempHysteresisDegC.setTitle(getString(R.string.cpu_temp_hysteresis));
        coreTempHysteresisDegC.setUnit(getString(fahrenheit ? R.string.fahrenheit : R.string.celsius));
        coreTempHysteresisDegC.setItems(list);
        coreTempHysteresisDegC.setProgress(MSMThermal.getCoreTempHysteresisDegC());
        coreTempHysteresisDegC.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                MSMThermal.setCoreTempHysteresisDegC(position, getActivity());
            }
        });
        items.add(coreTempHysteresisDegC);
    }
    if (MSMThermal.hasFreqStep()) {
        SeekBarView freqStep = new SeekBarView();
        freqStep.setTitle(getString(R.string.freq_step));
        freqStep.setMax(10);
        freqStep.setMin(1);
        freqStep.setProgress(MSMThermal.getFreqStep() - 1);
        freqStep.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                MSMThermal.setFreqStep(position + 1, getActivity());
            }
        });
        items.add(freqStep);
    }
    if (MSMThermal.hasImmediatelyLimitStop()) {
        SwitchView immediatelyLimitStop = new SwitchView();
        immediatelyLimitStop.setSummary(getString(R.string.immediately_limit_stop));
        immediatelyLimitStop.setChecked(MSMThermal.isImmediatelyLimitStopEnabled());
        immediatelyLimitStop.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                MSMThermal.enableImmediatelyLimitStop(isChecked, getActivity());
            }
        });
        items.add(immediatelyLimitStop);
    }
    if (MSMThermal.hasPollMs()) {
        SeekBarView pollMs = new SeekBarView();
        pollMs.setTitle(getString(R.string.poll));
        pollMs.setUnit(getString(R.string.ms));
        pollMs.setMax(3000);
        pollMs.setOffset(10);
        pollMs.setProgress(MSMThermal.getPollMs() / 10);
        pollMs.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                MSMThermal.setPollMs(position * 10, getActivity());
            }
        });
        items.add(pollMs);
    }
    if (MSMThermal.hasTempHysteresisDegC()) {
        boolean fahrenheit = Utils.useFahrenheit(getActivity());
        List<String> list = new ArrayList<>();
        for (int i = 0; i <= 20; i++) {
            list.add(String.valueOf(Utils.roundTo2Decimals(fahrenheit ? Utils.celsiusToFahrenheit(i) : i)));
        }
        SeekBarView tempHysteresisDegC = new SeekBarView();
        tempHysteresisDegC.setTitle(getString(R.string.temp_hysteresis));
        tempHysteresisDegC.setUnit(getString(fahrenheit ? R.string.fahrenheit : R.string.celsius));
        tempHysteresisDegC.setItems(list);
        tempHysteresisDegC.setProgress(MSMThermal.getTempHysteresisDegC());
        tempHysteresisDegC.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                MSMThermal.setTempHysteresisDegC(position, getActivity());
            }
        });
        items.add(tempHysteresisDegC);
    }
    if (MSMThermal.hasThermalLimitLow()) {
        SeekBarView limitLow = new SeekBarView();
        limitLow.setTitle(getString(R.string.thermal_limit_low));
        limitLow.setMax(30);
        limitLow.setMin(1);
        limitLow.setProgress(MSMThermal.getThermalLimitLow() - 1);
        limitLow.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                MSMThermal.setThermalLimitLow(position + 1, getActivity());
            }
        });
        items.add(limitLow);
    }
    if (MSMThermal.hasThermalLimitHigh()) {
        SeekBarView limitHigh = new SeekBarView();
        limitHigh.setTitle(getString(R.string.thermal_limit_high));
        limitHigh.setMax(30);
        limitHigh.setMin(1);
        limitHigh.setProgress(MSMThermal.getThermalLimitHigh() - 1);
        limitHigh.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                MSMThermal.setThermalLimitHigh(position + 1, getActivity());
            }
        });
        items.add(limitHigh);
    }
    if (MSMThermal.hasTempSafety()) {
        SwitchView tempSafety = new SwitchView();
        tempSafety.setSummary(getString(R.string.temp_safety));
        tempSafety.setChecked(MSMThermal.isTempSafetyEnabled());
        tempSafety.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                MSMThermal.enableTempSafety(isChecked, getActivity());
            }
        });
        items.add(tempSafety);
    }
    if (MSMThermal.hasTempThrottleEnable()) {
        SwitchView tempThrottle = new SwitchView();
        tempThrottle.setTitle(getString(R.string.temp_throttle));
        tempThrottle.setSummary(getString(R.string.temp_throttle_summary));
        tempThrottle.setChecked(MSMThermal.isTempThrottleEnabled());
        tempThrottle.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                MSMThermal.enableTempThrottle(isChecked, getActivity());
            }
        });
        items.add(tempThrottle);
    }
    if (MSMThermal.hasTempLimit()) {
        boolean fahrenheit = Utils.useFahrenheit(getActivity());
        SeekBarView tempLimit = new SeekBarView();
        tempLimit.setTitle(getString(R.string.temp_limit));
        tempLimit.setSummary(getString(R.string.temp_limit_summary));
        tempLimit.setUnit(getString(fahrenheit ? R.string.fahrenheit : R.string.celsius));
        tempLimit.setItems(MSMThermal.getTempLimitList(fahrenheit));
        tempLimit.setProgress(MSMThermal.getCurTempLimit() - MSMThermal.getTempLimitMin());
        tempLimit.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                MSMThermal.setTempLimit(position + MSMThermal.getTempLimitMin(), getActivity());
            }
        });
        items.add(tempLimit);
    }
    if (MSMThermal.hasFreqLimitDebug()) {
        SwitchView freqLimitDebug = new SwitchView();
        freqLimitDebug.setTitle(getString(R.string.freq_limit_debug));
        freqLimitDebug.setSummary(getString(R.string.freq_limit_debug_summary));
        freqLimitDebug.setChecked(MSMThermal.isFreqLimitDebugEnabled());
        freqLimitDebug.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                MSMThermal.enableFreqLimitDebug(isChecked, getActivity());
            }
        });
        items.add(freqLimitDebug);
    }
    if (MSMThermal.hasMinFreqIndex() && CPUFreq.getFreqs() != null) {
        SelectView minFreqIndex = new SelectView();
        minFreqIndex.setTitle(getString(R.string.temp_limit_min_freq));
        minFreqIndex.setSummary(getString(R.string.temp_limit_min_freq_summary));
        minFreqIndex.setItems(CPUFreq.getAdjustedFreq(getActivity()));
        minFreqIndex.setItem((MSMThermal.getMinFreqIndex() / 1000) + getString(R.string.mhz));
        minFreqIndex.setOnItemSelected(new SelectView.OnItemSelected() {

            @Override
            public void onItemSelected(SelectView selectView, int position, String item) {
                MSMThermal.setMinFreqIndex(CPUFreq.getFreqs().get(position), getActivity());
            }
        });
        items.add(minFreqIndex);
    }
    if (MSMThermal.hasAllowedLowLow()) {
        boolean fahrenheit = Utils.useFahrenheit(getActivity());
        List<String> list = new ArrayList<>();
        for (int i = 40; i <= 100; i++) {
            list.add(String.valueOf(Utils.roundTo2Decimals(fahrenheit ? Utils.celsiusToFahrenheit(i) : i)));
        }
        SeekBarView allowedLowLow = new SeekBarView();
        allowedLowLow.setTitle(getString(R.string.allowed_low_low));
        allowedLowLow.setUnit(getString(fahrenheit ? R.string.fahrenheit : R.string.celsius));
        allowedLowLow.setItems(list);
        allowedLowLow.setProgress(MSMThermal.getAllowedLowLow() - 40);
        allowedLowLow.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                MSMThermal.setAllowedLowLow(position + 40, getActivity());
            }
        });
        items.add(allowedLowLow);
    }
    if (MSMThermal.hasAllowedLowHigh()) {
        boolean fahrenheit = Utils.useFahrenheit(getActivity());
        List<String> list = new ArrayList<>();
        for (int i = 40; i <= 100; i++) {
            list.add(String.valueOf(Utils.roundTo2Decimals(fahrenheit ? Utils.celsiusToFahrenheit(i) : i)));
        }
        SeekBarView allowedLowHigh = new SeekBarView();
        allowedLowHigh.setTitle(getString(R.string.allowed_low_high));
        allowedLowHigh.setUnit(getString(fahrenheit ? R.string.fahrenheit : R.string.celsius));
        allowedLowHigh.setItems(list);
        allowedLowHigh.setProgress(MSMThermal.getAllowedLowHigh() - 40);
        allowedLowHigh.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                MSMThermal.setAllowedLowHigh(position + 40, getActivity());
            }
        });
        items.add(allowedLowHigh);
    }
    if (MSMThermal.hasAllowedLowFreq() && CPUFreq.getFreqs() != null) {
        SelectView allowedLowFreq = new SelectView();
        allowedLowFreq.setSummary(getString(R.string.allowed_low_freq));
        allowedLowFreq.setItems(CPUFreq.getAdjustedFreq(getActivity()));
        allowedLowFreq.setItem((MSMThermal.getAllowedLowFreq() / 1000) + getString(R.string.mhz));
        allowedLowFreq.setOnItemSelected(new SelectView.OnItemSelected() {

            @Override
            public void onItemSelected(SelectView selectView, int position, String item) {
                MSMThermal.setAllowedLowFreq(CPUFreq.getFreqs().get(position), getActivity());
            }
        });
        items.add(allowedLowFreq);
    }
    if (MSMThermal.hasAllowedMidLow()) {
        boolean fahrenheit = Utils.useFahrenheit(getActivity());
        List<String> list = new ArrayList<>();
        for (int i = 40; i <= 100; i++) {
            list.add(String.valueOf(Utils.roundTo2Decimals(fahrenheit ? Utils.celsiusToFahrenheit(i) : i)));
        }
        SeekBarView alloweMidLow = new SeekBarView();
        alloweMidLow.setTitle(getString(R.string.allowed_mid_low));
        alloweMidLow.setUnit(getString(fahrenheit ? R.string.fahrenheit : R.string.celsius));
        alloweMidLow.setItems(list);
        alloweMidLow.setProgress(MSMThermal.getAllowedMidLow() - 40);
        alloweMidLow.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                MSMThermal.setAllowedMidLow(position + 40, getActivity());
            }
        });
        items.add(alloweMidLow);
    }
    if (MSMThermal.hasAllowedMidHigh()) {
        boolean fahrenheit = Utils.useFahrenheit(getActivity());
        List<String> list = new ArrayList<>();
        for (int i = 40; i <= 100; i++) {
            list.add(String.valueOf(Utils.roundTo2Decimals(fahrenheit ? Utils.celsiusToFahrenheit(i) : i)));
        }
        SeekBarView allowedMidHigh = new SeekBarView();
        allowedMidHigh.setTitle(getString(R.string.allowed_mid_high));
        allowedMidHigh.setUnit(getString(fahrenheit ? R.string.fahrenheit : R.string.celsius));
        allowedMidHigh.setItems(list);
        allowedMidHigh.setProgress(MSMThermal.getAllowedMidHigh() - 40);
        allowedMidHigh.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                MSMThermal.setAllowedMidHigh(position + 40, getActivity());
            }
        });
        items.add(allowedMidHigh);
    }
    if (MSMThermal.hasAllowedMidFreq() && CPUFreq.getFreqs() != null) {
        SelectView allowedMidFreq = new SelectView();
        allowedMidFreq.setSummary(getString(R.string.allowed_mid_freq));
        allowedMidFreq.setItems(CPUFreq.getAdjustedFreq(getActivity()));
        allowedMidFreq.setItem((MSMThermal.getAllowedMidFreq() / 1000) + getString(R.string.mhz));
        allowedMidFreq.setOnItemSelected(new SelectView.OnItemSelected() {

            @Override
            public void onItemSelected(SelectView selectView, int position, String item) {
                MSMThermal.setAllowedMidFreq(CPUFreq.getFreqs().get(position), getActivity());
            }
        });
        items.add(allowedMidFreq);
    }
    if (MSMThermal.hasAllowedMaxLow()) {
        boolean fahrenheit = Utils.useFahrenheit(getActivity());
        List<String> list = new ArrayList<>();
        for (int i = 40; i <= 100; i++) {
            list.add(String.valueOf(Utils.roundTo2Decimals(fahrenheit ? Utils.celsiusToFahrenheit(i) : i)));
        }
        SeekBarView alloweMaxLow = new SeekBarView();
        alloweMaxLow.setTitle(getString(R.string.allowed_max_low));
        alloweMaxLow.setUnit(getString(fahrenheit ? R.string.fahrenheit : R.string.celsius));
        alloweMaxLow.setItems(list);
        alloweMaxLow.setProgress(MSMThermal.getAllowedMaxLow() - 40);
        alloweMaxLow.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                MSMThermal.setAllowedMaxLow(position + 40, getActivity());
            }
        });
        items.add(alloweMaxLow);
    }
    if (MSMThermal.hasAllowedMaxHigh()) {
        boolean fahrenheit = Utils.useFahrenheit(getActivity());
        List<String> list = new ArrayList<>();
        for (int i = 40; i <= 100; i++) {
            list.add(String.valueOf(Utils.roundTo2Decimals(fahrenheit ? Utils.celsiusToFahrenheit(i) : i)));
        }
        SeekBarView allowedMaxHigh = new SeekBarView();
        allowedMaxHigh.setTitle(getString(R.string.allowed_max_high));
        allowedMaxHigh.setUnit(getString(fahrenheit ? R.string.fahrenheit : R.string.celsius));
        allowedMaxHigh.setItems(list);
        allowedMaxHigh.setProgress(MSMThermal.getAllowedMaxHigh() - 40);
        allowedMaxHigh.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                MSMThermal.setAllowedMaxHigh(position + 40, getActivity());
            }
        });
        items.add(allowedMaxHigh);
    }
    if (MSMThermal.hasAllowedMaxFreq() && CPUFreq.getFreqs() != null) {
        SelectView allowedMaxFreq = new SelectView();
        allowedMaxFreq.setSummary(getString(R.string.allowed_max_freq));
        allowedMaxFreq.setItems(CPUFreq.getAdjustedFreq(getActivity()));
        allowedMaxFreq.setItem((MSMThermal.getAllowedMaxFreq() / 1000) + getString(R.string.mhz));
        allowedMaxFreq.setOnItemSelected(new SelectView.OnItemSelected() {

            @Override
            public void onItemSelected(SelectView selectView, int position, String item) {
                MSMThermal.setAllowedMaxFreq(CPUFreq.getFreqs().get(position), getActivity());
            }
        });
        items.add(allowedMaxFreq);
    }
    if (MSMThermal.hasCheckIntervalMs()) {
        SeekBarView checkIntervalMs = new SeekBarView();
        checkIntervalMs.setTitle(getString(R.string.check_interval));
        checkIntervalMs.setUnit(getString(R.string.ms));
        checkIntervalMs.setMax(3000);
        checkIntervalMs.setOffset(50);
        checkIntervalMs.setProgress(MSMThermal.getCheckIntervalMs() / 50);
        checkIntervalMs.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                MSMThermal.setCheckIntervalMs(position * 50, getActivity());
            }
        });
        items.add(checkIntervalMs);
    }
    if (MSMThermal.hasShutdownTemp()) {
        boolean fahrenheit = Utils.useFahrenheit(getActivity());
        List<String> list = new ArrayList<>();
        for (int i = 40; i <= 100; i++) {
            list.add(String.valueOf(Utils.roundTo2Decimals(fahrenheit ? Utils.celsiusToFahrenheit(i) : i)));
        }
        SeekBarView shutDownTemp = new SeekBarView();
        shutDownTemp.setTitle(getString(R.string.shutdown_temp));
        shutDownTemp.setUnit(getString(fahrenheit ? R.string.fahrenheit : R.string.celsius));
        shutDownTemp.setItems(list);
        shutDownTemp.setProgress(MSMThermal.getShutdownTemp() - 40);
        shutDownTemp.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                MSMThermal.setShutdownTemp(position + 40, getActivity());
            }
        });
        items.add(shutDownTemp);
    }
}
Also used : SwitchView(com.moro.mtweaks.views.recyclerview.SwitchView) ArrayList(java.util.ArrayList) SeekBarView(com.moro.mtweaks.views.recyclerview.SeekBarView) SelectView(com.moro.mtweaks.views.recyclerview.SelectView)

Example 42 with SwitchView

use of com.moro.mtweaks.views.recyclerview.SwitchView in project MTweaks-KernelAdiutorMOD by morogoku.

the class VMFragment method zswapInit.

private void zswapInit(List<RecyclerViewItem> items) {
    CardView zswapCard = new CardView(getActivity());
    zswapCard.setTitle(getString(R.string.zswap));
    if (ZSwap.hasEnable()) {
        SwitchView zswap = new SwitchView();
        zswap.setTitle(getString(R.string.zswap));
        zswap.setSummary(getString(R.string.zswap_summary));
        zswap.setChecked(ZSwap.isEnabled());
        zswap.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                ZSwap.enable(isChecked, getActivity());
            }
        });
        zswapCard.addItem(zswap);
    }
    if (ZSwap.hasMaxPoolPercent()) {
        if (!Prefs.getBoolean("memory_pool_percent", false, getActivity())) {
            SeekBarView maxPoolPercent = new SeekBarView();
            maxPoolPercent.setTitle(getString(R.string.memory_pool));
            maxPoolPercent.setSummary(getString(R.string.memory_pool_summary));
            maxPoolPercent.setUnit("%");
            maxPoolPercent.setMax(ZSwap.getStockMaxPoolPercent() / 10);
            maxPoolPercent.setProgress(ZSwap.getMaxPoolPercent() / 10);
            maxPoolPercent.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

                @Override
                public void onStop(SeekBarView seekBarView, int position, String value) {
                    ZSwap.setMaxPoolPercent(position * 10, getActivity());
                }

                @Override
                public void onMove(SeekBarView seekBarView, int position, String value) {
                }
            });
            zswapCard.addItem(maxPoolPercent);
        } else {
            SeekBarView maxPoolPercent = new SeekBarView();
            maxPoolPercent.setTitle(getString(R.string.memory_pool));
            maxPoolPercent.setSummary(getString(R.string.memory_pool_summary));
            maxPoolPercent.setUnit("%");
            maxPoolPercent.setMax(ZSwap.getStockMaxPoolPercent());
            maxPoolPercent.setProgress(ZSwap.getMaxPoolPercent());
            maxPoolPercent.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

                @Override
                public void onStop(SeekBarView seekBarView, int position, String value) {
                    ZSwap.setMaxPoolPercent(position, getActivity());
                }

                @Override
                public void onMove(SeekBarView seekBarView, int position, String value) {
                }
            });
            zswapCard.addItem(maxPoolPercent);
        }
    }
    if (ZSwap.hasMaxCompressionRatio()) {
        SeekBarView maxCompressionRatio = new SeekBarView();
        maxCompressionRatio.setTitle(getString(R.string.maximum_compression_ratio));
        maxCompressionRatio.setSummary(getString(R.string.maximum_compression_ratio_summary));
        maxCompressionRatio.setUnit("%");
        maxCompressionRatio.setProgress(ZSwap.getMaxCompressionRatio());
        maxCompressionRatio.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                ZSwap.setMaxCompressionRatio(position, getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        zswapCard.addItem(maxCompressionRatio);
    }
    if (zswapCard.size() > 0) {
        items.add(zswapCard);
    }
}
Also used : SwitchView(com.moro.mtweaks.views.recyclerview.SwitchView) CardView(com.moro.mtweaks.views.recyclerview.CardView) SeekBarView(com.moro.mtweaks.views.recyclerview.SeekBarView)

Example 43 with SwitchView

use of com.moro.mtweaks.views.recyclerview.SwitchView in project MTweaks-KernelAdiutorMOD by morogoku.

the class DataSharingFragment method addItems.

@Override
protected void addItems(List<RecyclerViewItem> items) {
    SwitchView datasharing = new SwitchView();
    datasharing.setSummary(getString(R.string.sharing_enable));
    datasharing.setChecked(Prefs.getBoolean("data_sharing", false, getActivity()));
    datasharing.addOnSwitchListener(new SwitchView.OnSwitchListener() {

        @Override
        public void onChanged(SwitchView switchView, boolean isChecked) {
            if (isChecked) {
                Utils.startService(getActivity(), new Intent(getActivity(), Monitor.class));
            } else {
                getActivity().stopService(new Intent(getActivity(), Monitor.class));
            }
            Prefs.saveBoolean("data_sharing", isChecked, getActivity());
        }
    });
    items.add(datasharing);
}
Also used : SwitchView(com.moro.mtweaks.views.recyclerview.SwitchView) Intent(android.content.Intent)

Example 44 with SwitchView

use of com.moro.mtweaks.views.recyclerview.SwitchView 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 45 with SwitchView

use of com.moro.mtweaks.views.recyclerview.SwitchView in project MTweaks-KernelAdiutorMOD by morogoku.

the class WakeFrament method cameraInit.

private void cameraInit(List<RecyclerViewItem> items) {
    SwitchView camera = new SwitchView();
    camera.setTitle(getString(R.string.camera_gesture));
    camera.setSummary(getString(R.string.camera_gesture_summary));
    camera.setChecked(Misc.isCameraEnabled());
    camera.addOnSwitchListener(new SwitchView.OnSwitchListener() {

        @Override
        public void onChanged(SwitchView switchView, boolean isChecked) {
            Misc.enableCamera(isChecked, getActivity());
        }
    });
    items.add(camera);
}
Also used : SwitchView(com.moro.mtweaks.views.recyclerview.SwitchView)

Aggregations

SwitchView (com.moro.mtweaks.views.recyclerview.SwitchView)64 SeekBarView (com.moro.mtweaks.views.recyclerview.SeekBarView)31 CardView (com.moro.mtweaks.views.recyclerview.CardView)23 ArrayList (java.util.ArrayList)19 TitleView (com.moro.mtweaks.views.recyclerview.TitleView)16 RecyclerViewItem (com.moro.mtweaks.views.recyclerview.RecyclerViewItem)15 SelectView (com.moro.mtweaks.views.recyclerview.SelectView)14 DescriptionView (com.moro.mtweaks.views.recyclerview.DescriptionView)4 GenericSelectView2 (com.moro.mtweaks.views.recyclerview.GenericSelectView2)3 GenericSelectView (com.moro.mtweaks.views.recyclerview.GenericSelectView)2 Intent (android.content.Intent)1 Controls (com.moro.mtweaks.database.tools.customcontrols.Controls)1 BoefflaWakelock (com.moro.mtweaks.utils.kernel.boefflawakelock.BoefflaWakelock)1 Wakelocks (com.moro.mtweaks.utils.kernel.misc.Wakelocks)1 CustomControlException (com.moro.mtweaks.utils.tools.customcontrols.CustomControlException)1 XYGraphView (com.moro.mtweaks.views.recyclerview.XYGraphView)1 ErrorView (com.moro.mtweaks.views.recyclerview.customcontrols.ErrorView)1 ConcurrentModificationException (java.util.ConcurrentModificationException)1