Search in sources :

Example 21 with SeekBarView

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

the class LEDFragment method delayInit.

private void delayInit(List<RecyclerViewItem> items) {
    CardView delayCard = new CardView(getActivity());
    delayCard.setTitle(getString(R.string.delay));
    if (Sec.hasNotificationDelayOn()) {
        SeekBarView notificationDelayOn = new SeekBarView();
        notificationDelayOn.setTitle(getString(R.string.on));
        notificationDelayOn.setUnit(getString(R.string.ms));
        notificationDelayOn.setMax(5000);
        notificationDelayOn.setOffset(100);
        notificationDelayOn.setProgress(Sec.getNotificationDelayOn() / 100);
        notificationDelayOn.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

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

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        delayCard.addItem(notificationDelayOn);
    }
    if (Sec.hasNotificationDelayOff()) {
        SeekBarView notificationDelayOff = new SeekBarView();
        notificationDelayOff.setTitle(getString(R.string.off));
        notificationDelayOff.setUnit(getString(R.string.ms));
        notificationDelayOff.setMax(5000);
        notificationDelayOff.setOffset(100);
        notificationDelayOff.setProgress(Sec.getNotificationDelayOff() / 100);
        notificationDelayOff.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

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

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

Example 22 with SeekBarView

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

the class LMKFragment method minfreeInit.

private void minfreeInit(List<RecyclerViewItem> items) {
    mMinFrees.clear();
    List<String> minfrees = LMK.getMinFrees();
    String[] descriptions = getResources().getStringArray(R.array.lmk_names);
    for (int i = 0; i < minfrees.size(); i++) {
        if (i == descriptions.length)
            break;
        SeekBarView minfree = new SeekBarView();
        minfree.setTitle(descriptions[i]);
        minfree.setUnit(getString(R.string.mb));
        minfree.setMax(1024);
        minfree.setProgress(Math.round(Utils.strToInt(minfrees.get(i)) / 256));
        final int minfreeposition = i;
        minfree.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                List<String> minfrees = LMK.getMinFrees();
                StringBuilder values = new StringBuilder();
                for (int i = 0; i < minfrees.size(); i++) {
                    values.append(minfreeposition == i ? position * 256 : minfrees.get(i)).append(",");
                }
                values.setLength(values.length() - 1);
                LMK.setMinFree(values.toString(), getActivity());
                refreshMinFree();
            }

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

Example 23 with SeekBarView

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

the class MiscFragment method wakelockInit.

private void wakelockInit(List<RecyclerViewItem> items) {
    List<RecyclerViewItem> wakelocks = new ArrayList<>();
    for (final Wakelocks.Wakelock wakelock : Wakelocks.getWakelocks()) {
        if (!wakelock.exists())
            continue;
        String description = wakelock.getDescription(getActivity());
        SwitchView switchView = new SwitchView();
        if (description == null) {
            switchView.setSummary(wakelock.getTitle(getActivity()));
        } else {
            switchView.setTitle(wakelock.getTitle(getActivity()));
            switchView.setSummary(description);
        }
        switchView.setChecked(wakelock.isEnabled());
        switchView.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                wakelock.enable(isChecked, getActivity());
            }
        });
        wakelocks.add(switchView);
    }
    if (Wakelocks.hasWlanrxDivider()) {
        List<String> list = new ArrayList<>();
        for (int i = 1; i < 17; i++) {
            list.add((100 / i) + "%");
        }
        list.add("0%");
        SeekBarView wlanrxDivider = new SeekBarView();
        wlanrxDivider.setTitle(getString(R.string.wlan_rx_wakelock_divider));
        wlanrxDivider.setItems(list);
        wlanrxDivider.setProgress(Wakelocks.getWlanrxDivider());
        wlanrxDivider.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

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

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        wakelocks.add(wlanrxDivider);
    }
    if (Wakelocks.hasWlanctrlDivider()) {
        List<String> list = new ArrayList<>();
        for (int i = 1; i < 17; i++) {
            list.add((100 / i) + "%");
        }
        list.add("0%");
        SeekBarView wlanctrlDivider = new SeekBarView();
        wlanctrlDivider.setTitle(getString(R.string.wlan_ctrl_wakelock_divider));
        wlanctrlDivider.setItems(list);
        wlanctrlDivider.setProgress(Wakelocks.getWlanctrlDivider());
        wlanctrlDivider.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

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

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        wakelocks.add(wlanctrlDivider);
    }
    if (Wakelocks.hasMsmHsicDivider()) {
        List<String> list = new ArrayList<>();
        for (int i = 1; i < 17; i++) {
            list.add((100 / i) + "%");
        }
        list.add("0%");
        SeekBarView msmHsicDivider = new SeekBarView();
        msmHsicDivider.setTitle(getString(R.string.msm_hsic_wakelock_divider));
        msmHsicDivider.setItems(list);
        msmHsicDivider.setProgress(Wakelocks.getMsmHsicDivider());
        msmHsicDivider.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

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

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        wakelocks.add(msmHsicDivider);
    }
    if (Wakelocks.hasBCMDHDDivider()) {
        SeekBarView bcmdhdDivider = new SeekBarView();
        bcmdhdDivider.setTitle(getString(R.string.bcmdhd_wakelock_divider));
        bcmdhdDivider.setMax(9);
        bcmdhdDivider.setMin(1);
        bcmdhdDivider.setProgress(Wakelocks.getBCMDHDDivider() - 1);
        bcmdhdDivider.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

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

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        wakelocks.add(bcmdhdDivider);
    }
    if (wakelocks.size() > 0) {
        TitleView wakelockTitle = new TitleView();
        wakelockTitle.setText(getString(R.string.wakelock));
        items.add(wakelockTitle);
        items.addAll(wakelocks);
    }
}
Also used : SwitchView(com.moro.mtweaks.views.recyclerview.SwitchView) ArrayList(java.util.ArrayList) Wakelocks(com.moro.mtweaks.utils.kernel.misc.Wakelocks) RecyclerViewItem(com.moro.mtweaks.views.recyclerview.RecyclerViewItem) SeekBarView(com.moro.mtweaks.views.recyclerview.SeekBarView) TitleView(com.moro.mtweaks.views.recyclerview.TitleView)

Example 24 with SeekBarView

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

the class MiscFragment method vibrationInit.

private void vibrationInit(List<RecyclerViewItem> items) {
    final Vibrator vibrator = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE);
    final int min = Vibration.getMin();
    int max = Vibration.getMax();
    final float offset = (max - min) / 100f;
    SeekBarView vibration = new SeekBarView();
    vibration.setTitle(getString(R.string.vibration_strength));
    vibration.setUnit("%");
    vibration.setProgress(Math.round((Vibration.get() - min) / offset));
    vibration.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

        @Override
        public void onStop(SeekBarView seekBarView, int position, String value) {
            Vibration.setVibration(Math.round(position * offset + min), getActivity());
            getHandler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    if (vibrator != null) {
                        vibrator.vibrate(300);
                    }
                }
            }, 250);
        }

        @Override
        public void onMove(SeekBarView seekBarView, int position, String value) {
        }
    });
    items.add(vibration);
}
Also used : Vibrator(android.os.Vibrator) SeekBarView(com.moro.mtweaks.views.recyclerview.SeekBarView)

Example 25 with SeekBarView

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

the class ScreenFragment method lcdBackLightInit.

private void lcdBackLightInit(List<RecyclerViewItem> items) {
    CardView lcdBackLightCard = new CardView(getActivity());
    lcdBackLightCard.setTitle(getString(R.string.lcd_backlight));
    if (Misc.hasBrightnessMode()) {
        SwitchView brightnessMode = new SwitchView();
        brightnessMode.setSummary(getString(R.string.brightness_mode));
        brightnessMode.setChecked(Misc.isBrightnessModeEnabled());
        brightnessMode.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                Misc.enableBrightnessMode(isChecked, getActivity());
            }
        });
        lcdBackLightCard.addItem(brightnessMode);
    }
    if (Misc.hasLcdMinBrightness()) {
        SeekBarView lcdMinBrightness = new SeekBarView();
        lcdMinBrightness.setTitle(getString(R.string.min_brightness));
        lcdMinBrightness.setSummary(getString(R.string.min_brightness_summary));
        lcdMinBrightness.setMax(114);
        lcdMinBrightness.setMin(2);
        lcdMinBrightness.setProgress(Misc.getLcdMinBrightness() - 2);
        lcdMinBrightness.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                Misc.setLcdMinBrightness(position + 2, getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        lcdBackLightCard.addItem(lcdMinBrightness);
    }
    if (Misc.hasLcdMaxBrightness()) {
        SeekBarView lcdMaxBrightness = new SeekBarView();
        lcdMaxBrightness.setTitle(getString(R.string.max_brightness));
        lcdMaxBrightness.setSummary(getString(R.string.max_brightness_summary));
        lcdMaxBrightness.setMax(114);
        lcdMaxBrightness.setMin(2);
        lcdMaxBrightness.setProgress(Misc.getLcdMaxBrightness() - 2);
        lcdMaxBrightness.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                Misc.setLcdMaxBrightness(position + 2, getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        lcdBackLightCard.addItem(lcdMaxBrightness);
    }
    if (lcdBackLightCard.size() > 0) {
        items.add(lcdBackLightCard);
    }
}
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