Search in sources :

Example 1 with SeekBarView

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

the class BatteryFragment method chargeS7Init.

private void chargeS7Init(List<RecyclerViewItem> items) {
    CardView unsCharge = new CardView(getActivity());
    unsCharge.setTitle(getString(R.string.unstable_charge_card));
    unsCharge.setFullSpan(true);
    if (Battery.hasUnstableCharge()) {
        SwitchView uCharge = new SwitchView();
        uCharge.setTitle(getString(R.string.enable_unstable_charge));
        uCharge.setSummary(getString(R.string.enable_unstable_charge_summary));
        uCharge.setChecked(Battery.isUnstableChargeEnabled());
        uCharge.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                Battery.enableUnstableCharge(isChecked, getActivity());
            }
        });
        unsCharge.addItem(uCharge);
    }
    if (unsCharge.size() > 0) {
        items.add(unsCharge);
    }
    CardView storeCard = new CardView(getActivity());
    storeCard.setTitle(getString(R.string.store_mode));
    storeCard.setFullSpan(true);
    if (Battery.hasS7StoreMode()) {
        SwitchView sMode = new SwitchView();
        sMode.setTitle(getString(R.string.store_mode));
        sMode.setSummary(getString(R.string.store_mode_summary));
        sMode.setChecked(Battery.isS7StoreModeEnabled());
        sMode.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                Battery.enableS7StoreMode(isChecked, getActivity());
            }
        });
        storeCard.addItem(sMode);
        SeekBarView smMax = new SeekBarView();
        smMax.setTitle(getString(R.string.store_mode_max));
        smMax.setSummary(getString(R.string.store_mode_max_summary));
        smMax.setMax(100);
        smMax.setMin(1);
        smMax.setUnit(getString(R.string.percent));
        smMax.setProgress(Utils.strToInt(Battery.getS7StoreModeMax()) - 1);
        smMax.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                Battery.setS7StoreModeMax(position + 1, getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        storeCard.addItem(smMax);
        SeekBarView smMin = new SeekBarView();
        smMin.setTitle(getString(R.string.store_mode_min));
        smMin.setSummary(getString(R.string.store_mode_min_summary));
        smMin.setMax(100);
        smMin.setMin(1);
        smMin.setUnit(getString(R.string.percent));
        smMin.setProgress(Utils.strToInt(Battery.getS7StoreModeMin()) - 1);
        smMin.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                Battery.setS7StoreModeMin(position + 1, getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        storeCard.addItem(smMin);
    }
    if (storeCard.size() > 0) {
        items.add(storeCard);
    }
    CardView hvPower = new CardView(getActivity());
    hvPower.setTitle(getString(R.string.hv_power_supply));
    hvPower.setFullSpan(true);
    if (Battery.hasS7HvInput()) {
        SeekBarView hv_input = new SeekBarView();
        hv_input.setTitle(getString(R.string.hv_input));
        hv_input.setSummary(getString(R.string.def) + ": " + Prefs.getString("bat_s7_hv_input", "", getActivity()) + getString(R.string.ma));
        hv_input.setMax(3000);
        hv_input.setMin(400);
        hv_input.setUnit(getString(R.string.ma));
        hv_input.setOffset(25);
        hv_input.setProgress(Utils.strToInt(Battery.getS7HvInput()) / 25 - 16);
        hv_input.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                Battery.setS7HvInput((position + 16) * 25, getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        hvPower.addItem(hv_input);
    }
    if (Battery.hasS7HvCharge()) {
        SeekBarView hv_charge = new SeekBarView();
        hv_charge.setTitle(getString(R.string.hv_charge));
        hv_charge.setSummary(getString(R.string.def) + ": " + Prefs.getString("bat_s7_hv_charge", "", getActivity()) + getString(R.string.ma));
        hv_charge.setMax(3150);
        hv_charge.setMin(1000);
        hv_charge.setUnit(getString(R.string.ma));
        hv_charge.setOffset(25);
        hv_charge.setProgress(Utils.strToInt(Battery.getS7HvCharge()) / 25 - 40);
        hv_charge.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                Battery.setS7HvCharge((position + 40) * 25, getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        hvPower.addItem(hv_charge);
    }
    if (hvPower.size() > 0) {
        items.add(hvPower);
    }
    CardView acMains = new CardView(getActivity());
    acMains.setTitle(getString(R.string.ac_mains));
    acMains.setFullSpan(true);
    if (Battery.hasS7AcInput()) {
        SeekBarView ac_input = new SeekBarView();
        ac_input.setTitle(getString(R.string.ac_input));
        ac_input.setSummary(getString(R.string.def) + ": " + Prefs.getString("bat_s7_ac_input", "", getActivity()) + getString(R.string.ma));
        ac_input.setMax(3150);
        ac_input.setMin(400);
        ac_input.setUnit(getString(R.string.ma));
        ac_input.setOffset(25);
        ac_input.setProgress(Utils.strToInt(Battery.getS7AcInput()) / 25 - 16);
        ac_input.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                Battery.setS7AcInput((position + 16) * 25, getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        acMains.addItem(ac_input);
    }
    if (Battery.hasS7AcCharge()) {
        SeekBarView ac_charge = new SeekBarView();
        ac_charge.setTitle(getString(R.string.ac_charge));
        ac_charge.setSummary(getString(R.string.def) + ": " + Prefs.getString("bat_s7_ac_charge", "", getActivity()) + getString(R.string.ma));
        ac_charge.setMax(3150);
        ac_charge.setMin(400);
        ac_charge.setUnit(getString(R.string.ma));
        ac_charge.setOffset(25);
        ac_charge.setProgress(Utils.strToInt(Battery.getS7AcCharge()) / 25 - 16);
        ac_charge.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                Battery.setS7AcCharge((position + 16) * 25, getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        acMains.addItem(ac_charge);
    }
    if (Battery.hasS7AcInputScreen()) {
        SeekBarView ac_input_screen = new SeekBarView();
        ac_input_screen.setTitle(getString(R.string.ac_input_screen));
        ac_input_screen.setSummary(getString(R.string.def) + ": " + Prefs.getString("bat_s7_ac_input_screen", "", getActivity()) + getString(R.string.ma));
        ac_input_screen.setMax(3150);
        ac_input_screen.setMin(400);
        ac_input_screen.setUnit(getString(R.string.ma));
        ac_input_screen.setOffset(25);
        ac_input_screen.setProgress(Utils.strToInt(Battery.getS7AcInputScreen()) / 25 - 16);
        ac_input_screen.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                Battery.setS7AcInputScreen((position + 16) * 25, getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        acMains.addItem(ac_input_screen);
    }
    if (Battery.hasS7AcChargeScreen()) {
        SeekBarView ac_charge_screen = new SeekBarView();
        ac_charge_screen.setTitle(getString(R.string.ac_charge_screen));
        ac_charge_screen.setSummary(getString(R.string.def) + ": " + Prefs.getString("bat_s7_ac_charge_screen", "", getActivity()) + getString(R.string.ma));
        ac_charge_screen.setMax(3150);
        ac_charge_screen.setMin(400);
        ac_charge_screen.setUnit(getString(R.string.ma));
        ac_charge_screen.setOffset(25);
        ac_charge_screen.setProgress(Utils.strToInt(Battery.getS7AcChargeScreen()) / 25 - 16);
        ac_charge_screen.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                Battery.setS7AcChargeScreen((position + 16) * 25, getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        acMains.addItem(ac_charge_screen);
    }
    if (acMains.size() > 0) {
        items.add(acMains);
    }
    CardView usbCard = new CardView(getActivity());
    usbCard.setTitle(getString(R.string.usb_port));
    usbCard.setFullSpan(true);
    if (Battery.hasS7UsbInput()) {
        SeekBarView usb_input = new SeekBarView();
        usb_input.setTitle(getString(R.string.usb_input));
        usb_input.setSummary(getString(R.string.def) + ": " + Prefs.getString("bat_s7_usb_input", "", getActivity()) + getString(R.string.ma));
        usb_input.setMax(1200);
        usb_input.setMin(100);
        usb_input.setUnit(getString(R.string.ma));
        usb_input.setOffset(25);
        usb_input.setProgress(Utils.strToInt(Battery.getS7UsbInput()) / 25 - 4);
        usb_input.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                Battery.setS7UsbInput((position + 4) * 25, getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        usbCard.addItem(usb_input);
    }
    if (Battery.hasS7UsbCharge()) {
        SeekBarView usb_charge = new SeekBarView();
        usb_charge.setTitle(getString(R.string.usb_charge));
        usb_charge.setSummary(getString(R.string.def) + ": " + Prefs.getString("bat_s7_usb_charge", "", getActivity()) + getString(R.string.ma));
        usb_charge.setMax(1200);
        usb_charge.setMin(100);
        usb_charge.setUnit(getString(R.string.ma));
        usb_charge.setOffset(25);
        usb_charge.setProgress(Utils.strToInt(Battery.getS7UsbCharge()) / 25 - 4);
        usb_charge.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                Battery.setS7UsbCharge((position + 4) * 25, getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        usbCard.addItem(usb_charge);
    }
    if (usbCard.size() > 0) {
        items.add(usbCard);
    }
    CardView carCard = new CardView(getActivity());
    carCard.setTitle(getString(R.string.car_dock));
    carCard.setFullSpan(true);
    if (Battery.hasS7CarInput()) {
        SeekBarView car_input = new SeekBarView();
        car_input.setTitle(getString(R.string.car_input));
        car_input.setSummary(getString(R.string.def) + ": " + Prefs.getString("bat_s7_car_input", "", getActivity()) + getString(R.string.ma));
        car_input.setMax(2300);
        car_input.setMin(800);
        car_input.setUnit(getString(R.string.ma));
        car_input.setOffset(25);
        car_input.setProgress(Utils.strToInt(Battery.getS7CarInput()) / 25 - 32);
        car_input.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                Battery.setS7CarInput((position + 32) * 25, getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        carCard.addItem(car_input);
    }
    if (Battery.hasS7CarCharge()) {
        SeekBarView car_charge = new SeekBarView();
        car_charge.setTitle(getString(R.string.car_charge));
        car_charge.setSummary(getString(R.string.def) + ": " + Prefs.getString("bat_s7_car_charge", "", getActivity()) + getString(R.string.ma));
        car_charge.setMax(2300);
        car_charge.setMin(800);
        car_charge.setUnit(getString(R.string.ma));
        car_charge.setOffset(25);
        car_charge.setProgress(Utils.strToInt(Battery.getS7CarCharge()) / 25 - 32);
        car_charge.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                Battery.setS7CarCharge((position + 32) * 25, getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        carCard.addItem(car_charge);
    }
    if (carCard.size() > 0) {
        items.add(carCard);
    }
    CardView wcCard = new CardView(getActivity());
    wcCard.setTitle(getString(R.string.wireless_power));
    wcCard.setFullSpan(true);
    if (Battery.hasS7WcInput()) {
        SeekBarView wc_input = new SeekBarView();
        wc_input.setTitle(getString(R.string.wc_input));
        wc_input.setSummary(getString(R.string.def) + ": " + Prefs.getString("bat_s7_wc_input", "", getActivity()) + getString(R.string.ma));
        wc_input.setMax(1500);
        wc_input.setMin(800);
        wc_input.setUnit(getString(R.string.ma));
        wc_input.setOffset(25);
        wc_input.setProgress(Utils.strToInt(Battery.getS7WcInput()) / 25 - 32);
        wc_input.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                Battery.setS7WcInput((position + 32) * 25, getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        wcCard.addItem(wc_input);
    }
    if (Battery.hasS7WcCharge()) {
        SeekBarView wc_charge = new SeekBarView();
        wc_charge.setTitle(getString(R.string.wc_charge));
        wc_charge.setSummary(getString(R.string.def) + ": " + Prefs.getString("bat_s7_wc_charge", "", getActivity()) + getString(R.string.ma));
        wc_charge.setMax(2300);
        wc_charge.setMin(800);
        wc_charge.setUnit(getString(R.string.ma));
        wc_charge.setOffset(25);
        wc_charge.setProgress(Utils.strToInt(Battery.getS7WcCharge()) / 25 - 32);
        wc_charge.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                Battery.setS7WcCharge((position + 32) * 25, getActivity());
            }

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

Example 2 with SeekBarView

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

the class LEDFragment method fadeInit.

private void fadeInit(List<RecyclerViewItem> items) {
    if (LED.hasFade()) {
        SwitchView fade = new SwitchView();
        fade.setTitle(getString(R.string.fade));
        fade.setSummary(getString(R.string.fade_summary));
        fade.setChecked(LED.isFadeEnabled());
        fade.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                LED.enableFade(isChecked, getActivity());
            }
        });
        items.add(fade);
    }
    CardView fadeCard = new CardView(getActivity());
    fadeCard.setTitle(getString(R.string.fade));
    if (Sec.hasNotificationRampControl()) {
        SwitchView notificationRampControl = new SwitchView();
        notificationRampControl.setTitle(getString(R.string.fade_ramp_control));
        notificationRampControl.setSummary(getString(R.string.fade_ramp_control_summary));
        notificationRampControl.setChecked(Sec.isNotificationRampControlEnabled());
        notificationRampControl.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                Sec.enableNotificationRampControl(isChecked, getActivity());
            }
        });
        fadeCard.addItem(notificationRampControl);
    }
    if (Sec.hasNotificationRampUp()) {
        SeekBarView notificationRampUp = new SeekBarView();
        notificationRampUp.setTitle(getString(R.string.fade_in));
        notificationRampUp.setSummary(getString(R.string.fade_in_summary));
        notificationRampUp.setUnit(getString(R.string.ms));
        notificationRampUp.setMax(1900);
        notificationRampUp.setOffset(100);
        notificationRampUp.setProgress(Sec.getNotificationRampUp() / 100);
        notificationRampUp.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                Sec.setNotificationRampUp(position * 100, getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        fadeCard.addItem(notificationRampUp);
    }
    if (Sec.hasNotificationRampDown()) {
        SeekBarView notificationRampDown = new SeekBarView();
        notificationRampDown.setTitle(getString(R.string.fade_out));
        notificationRampDown.setSummary(getString(R.string.fade_out_summary));
        notificationRampDown.setUnit(getString(R.string.ms));
        notificationRampDown.setMax(1900);
        notificationRampDown.setOffset(100);
        notificationRampDown.setProgress(Sec.getNotificationRampDown() / 100);
        notificationRampDown.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                Sec.setNotificationRampDown(position * 100, getActivity());
            }

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

Example 3 with SeekBarView

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

the class LEDFragment method brightnessInit.

private void brightnessInit(List<RecyclerViewItem> items) {
    CardView brightnessCard = new CardView(getActivity());
    brightnessCard.setTitle(getString(R.string.brightness));
    if (Sec.hasHighpowerCurrent()) {
        SeekBarView highpowerCurrent = new SeekBarView();
        highpowerCurrent.setTitle(getString(R.string.bright_light_environment));
        highpowerCurrent.setSummary(getString(R.string.bright_light_environment_summary));
        highpowerCurrent.setUnit(getString(R.string.ma));
        highpowerCurrent.setMax(250);
        highpowerCurrent.setOffset(5);
        highpowerCurrent.setProgress(Sec.getHighpowerCurrent() / 5);
        highpowerCurrent.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                Sec.setHighpowerCurrent(position * 5, getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        brightnessCard.addItem(highpowerCurrent);
    }
    if (Sec.hasLowpowerCurrent()) {
        SeekBarView lowpowerCurrent = new SeekBarView();
        lowpowerCurrent.setTitle(getString(R.string.low_light_environment));
        lowpowerCurrent.setSummary(getString(R.string.low_light_environment_summary));
        lowpowerCurrent.setUnit(getString(R.string.ma));
        lowpowerCurrent.setMax(250);
        lowpowerCurrent.setOffset(5);
        lowpowerCurrent.setProgress(Sec.getLowpowerCurrent() / 5);
        lowpowerCurrent.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                Sec.setLowpowerCurrent(position * 5, getActivity());
            }

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

Example 4 with SeekBarView

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

the class LMKFragment method swapWait.

private void swapWait(List<RecyclerViewItem> items) {
    if (LMK.hasSwapWait()) {
        SwitchView swapWait = new SwitchView();
        swapWait.setTitle(getString(R.string.kill_lmk));
        swapWait.setSummary(getString(R.string.kill_lmk_summary));
        swapWait.setChecked(LMK.isSwapWaitEnabled());
        swapWait.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                LMK.enableSwapWait(isChecked, getActivity());
            }
        });
        items.add(swapWait);
    }
    if (LMK.hasSwapWaitPercent()) {
        Integer[] percentages = { 0, 50, 66, 75, 80, 90 };
        final Integer[] values = { 1, 2, 3, 4, 5, 10 };
        List<String> list = new ArrayList<>();
        for (int i : percentages) {
            list.add(i + "%");
        }
        SeekBarView swapWaitPercent = new SeekBarView();
        swapWaitPercent.setTitle(getString(R.string.kill_lmk_threshold));
        swapWaitPercent.setSummary(getString(R.string.kill_lmk_threshold_summary));
        swapWaitPercent.setItems(list);
        swapWaitPercent.setProgress(Arrays.asList(values).indexOf(LMK.getSwapWaitPercent()));
        swapWaitPercent.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                LMK.setSwapWaitPercent(values[position], getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        items.add(swapWaitPercent);
    }
}
Also used : SwitchView(com.moro.mtweaks.views.recyclerview.SwitchView) ArrayList(java.util.ArrayList) SeekBarView(com.moro.mtweaks.views.recyclerview.SeekBarView)

Example 5 with SeekBarView

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

the class ScreenFragment method screenColorInit.

private void screenColorInit(List<RecyclerViewItem> items) {
    if (Calibration.hasColors()) {
        CardView screenColor = new CardView(getActivity());
        screenColor.setTitle(getString(R.string.screen_color));
        List<String> colors = Calibration.getColors();
        final List<String> limits = Calibration.getLimits();
        mColors = new SeekBarView[colors.size()];
        for (int i = 0; i < colors.size(); i++) {
            mColors[i] = new SeekBarView();
            mColors[i].setTitle(getResources().getStringArray(R.array.colors)[i]);
            mColors[i].setItems(limits);
            mColors[i].setProgress(limits.indexOf(colors.get(i)));
            mColors[i].setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

                @Override
                public void onMove(SeekBarView seekBarView, int position, String value) {
                    if (mMinColor != null && position < mMinColor.getProgress()) {
                        mMinColor.setProgress(position);
                    }
                }

                @Override
                public void onStop(SeekBarView seekBarView, int position, String value) {
                    if (mMinColor != null) {
                        int current = Utils.strToInt(Calibration.getLimits().get(position));
                        if (Calibration.getMinColor() > current) {
                            Calibration.setMinColor(current, getActivity());
                        }
                    }
                    int r = mColors[0].getProgress();
                    int g = mColors[1].getProgress();
                    int b = mColors[2].getProgress();
                    Calibration.setColors(limits.get(r) + " " + limits.get(g) + " " + limits.get(b), getActivity());
                }
            });
            screenColor.addItem(mColors[i]);
        }
        items.add(screenColor);
        if (Calibration.hasMinColor()) {
            mMinColor = new SeekBarView();
            mMinColor.setTitle(getString(R.string.min_rgb));
            mMinColor.setItems(Calibration.getLimits());
            mMinColor.setProgress(Calibration.getLimits().indexOf(String.valueOf(Calibration.getMinColor())));
            mMinColor.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

                @Override
                public void onStop(SeekBarView seekBarView, int position, String value) {
                    Calibration.setMinColor(Utils.strToInt(value), getActivity());
                    StringBuilder colors = new StringBuilder();
                    for (String color : Calibration.getColors()) {
                        if (Utils.strToInt(value) > Utils.strToInt(color)) {
                            colors.append(value).append(" ");
                        } else {
                            colors.append(color).append(" ");
                        }
                    }
                    colors.setLength(colors.length() - 1);
                    Calibration.setColors(colors.toString(), getActivity());
                }

                @Override
                public void onMove(SeekBarView seekBarView, int position, String value) {
                    for (SeekBarView color : mColors) {
                        if (position > color.getProgress()) {
                            color.setProgress(position);
                        }
                    }
                }
            });
            items.add(mMinColor);
        }
    }
    if (Calibration.hasInvertScreen()) {
        SwitchView invertScreen = new SwitchView();
        invertScreen.setSummary(getString(R.string.invert_screen));
        invertScreen.setChecked(Calibration.isInvertScreenEnabled());
        invertScreen.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                Calibration.enableInvertScreen(isChecked, getActivity());
            }
        });
        items.add(invertScreen);
    }
    if (Calibration.hasSaturationIntensity()) {
        int saturation = Calibration.getSaturationIntensity();
        final SeekBarView saturationIntensity = new SeekBarView();
        saturationIntensity.setTitle(getString(R.string.saturation_intensity));
        saturationIntensity.setMax(158);
        saturationIntensity.setProgress(saturation == 128 ? 30 : saturation - 225);
        saturationIntensity.setEnabled(saturation != 128);
        saturationIntensity.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                Calibration.setSaturationIntensity(position + 225, getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        items.add(saturationIntensity);
        SwitchView grayscaleMode = new SwitchView();
        grayscaleMode.setSummary(getString(R.string.grayscale_mode));
        grayscaleMode.setChecked(saturation == 128);
        grayscaleMode.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                saturationIntensity.setEnabled(!isChecked);
                Calibration.enableGrayscaleMode(isChecked, getActivity());
                if (!isChecked) {
                    saturationIntensity.setProgress(30);
                }
            }
        });
        items.add(grayscaleMode);
    }
    if (Calibration.hasScreenHue()) {
        SeekBarView screenHue = new SeekBarView();
        screenHue.setTitle(getString(R.string.screen_hue));
        screenHue.setSummary(getString(R.string.screen_hue_summary));
        screenHue.setMax(1536);
        screenHue.setProgress(Calibration.getScreenHue());
        screenHue.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

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

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        items.add(screenHue);
    }
    if (Calibration.hasScreenValue()) {
        SeekBarView screenValue = new SeekBarView();
        screenValue.setTitle(getString(R.string.screen_value));
        screenValue.setMax(255);
        screenValue.setProgress(Calibration.getScreenValue() - 128);
        screenValue.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                Calibration.setScreenValue(position + 128, getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        items.add(screenValue);
    }
    if (Calibration.hasScreenContrast()) {
        SeekBarView screenContrast = new SeekBarView();
        screenContrast.setTitle(getString(R.string.screen_contrast));
        screenContrast.setMax(255);
        screenContrast.setProgress(Calibration.getScreenContrast() - 128);
        screenContrast.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                Calibration.setScreenContrast(position + 128, getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        items.add(screenContrast);
    }
    if (Calibration.hasScreenHBM()) {
        SwitchView screenHBM = new SwitchView();
        screenHBM.setSummary(getString(R.string.high_brightness_mode));
        screenHBM.setChecked(Calibration.isScreenHBMEnabled());
        screenHBM.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                Calibration.enableScreenHBM(isChecked, getActivity());
            }
        });
        items.add(screenHBM);
    }
    if (Calibration.hasSRGB()) {
        SwitchView sRGB = new SwitchView();
        sRGB.setSummary(getString(R.string.srgb));
        sRGB.setChecked(Calibration.isSRGBEnabled());
        sRGB.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                Calibration.enableSRGB(isChecked, getActivity());
            }
        });
        items.add(sRGB);
    }
}
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