Search in sources :

Example 1 with GenericSelectView2

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

the class VMFragment method CardVmTunablesInit.

private void CardVmTunablesInit(final CardView card) {
    card.clearItems();
    mVMs.clear();
    mCompleteList = Prefs.getBoolean("vm_show_complete_list", false, getActivity());
    SwitchView sv = new SwitchView();
    sv.setTitle(getString(R.string.vm_tun_switch_title));
    sv.setSummary(getString(R.string.vm_tun_switch_summary));
    sv.setChecked(mCompleteList);
    sv.addOnSwitchListener(new SwitchView.OnSwitchListener() {

        @Override
        public void onChanged(SwitchView switchView, boolean isChecked) {
            mCompleteList = isChecked;
            Prefs.saveBoolean("vm_show_complete_list", mCompleteList, getActivity());
            getHandler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    CardVmTunablesInit(card);
                }
            }, 250);
        }
    });
    card.addItem(sv);
    TitleView tit = new TitleView();
    if (mCompleteList) {
        tit.setText(getString(R.string.vm_tun_tit_all));
    } else {
        tit.setText(getString(R.string.vm_tun_tit_common));
    }
    card.addItem(tit);
    for (int i = 0; i < VM.size(mCompleteList); i++) {
        GenericSelectView2 vm = new GenericSelectView2();
        vm.setTitle(VM.getName(i, mCompleteList));
        vm.setValue(VM.getValue(i, mCompleteList));
        vm.setValueRaw(vm.getValue());
        vm.setInputType(InputType.TYPE_CLASS_NUMBER);
        final int position = i;
        vm.setOnGenericValueListener(new GenericSelectView2.OnGenericValueListener() {

            @Override
            public void onGenericValueSelected(GenericSelectView2 genericSelectView, String value) {
                VM.setValue(value, position, getActivity(), mCompleteList);
                genericSelectView.setValue(value);
                refreshVMs();
            }
        });
        card.addItem(vm);
        mVMs.add(vm);
    }
}
Also used : GenericSelectView2(com.moro.mtweaks.views.recyclerview.GenericSelectView2) SwitchView(com.moro.mtweaks.views.recyclerview.SwitchView) TitleView(com.moro.mtweaks.views.recyclerview.TitleView)

Example 2 with GenericSelectView2

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

the class CPUFragment method cpuBoostInit.

private void cpuBoostInit(List<RecyclerViewItem> items) {
    CardView cpuBoostCard = new CardView(getActivity());
    cpuBoostCard.setTitle(getString(R.string.ib_enabled));
    if (CPUBoost.hasEnable()) {
        SwitchView enable = new SwitchView();
        enable.setTitle(getString(R.string.ib_enabled));
        enable.setSummaryOn(getString(R.string.cpu_boost_summary_on));
        enable.setSummaryOff(getString(R.string.cpu_boost_summary_off));
        enable.setChecked(CPUBoost.isEnabled());
        enable.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                CPUBoost.enableCpuBoost(isChecked, getActivity());
            }
        });
        cpuBoostCard.addItem(enable);
    }
    if (CPUBoost.hasCpuBoostExynosInputMs()) {
        GenericSelectView2 ms = new GenericSelectView2();
        ms.setTitle(getString(R.string.ib_duration_ms));
        ms.setValue(CPUBoost.getCpuBootExynosInputMs() + " ms");
        ms.setValueRaw(ms.getValue().replace(" ms", ""));
        ms.setInputType(InputType.TYPE_CLASS_NUMBER);
        ms.setOnGenericValueListener(new GenericSelectView2.OnGenericValueListener() {

            @Override
            public void onGenericValueSelected(GenericSelectView2 genericSelectView, String value) {
                CPUBoost.setCpuBoostExynosInputMs(Utils.strToInt(value), getActivity());
                genericSelectView.setValue(value + " ms");
            }
        });
        cpuBoostCard.addItem(ms);
    }
    if (CPUBoost.hasCpuBoostExynosInputFreq()) {
        List<String> freqs = CPUBoost.getCpuBootExynosInputFreq();
        final String[] littleFreq = { freqs.get(0) };
        final String[] bigFreq = { freqs.get(1) };
        GenericSelectView2 little = new GenericSelectView2();
        little.setTitle(getString(R.string.ib_freq_little));
        little.setValue(littleFreq[0] + " Hz");
        little.setValueRaw(little.getValue().replace(" Hz", ""));
        little.setInputType(InputType.TYPE_CLASS_NUMBER);
        little.setOnGenericValueListener(new GenericSelectView2.OnGenericValueListener() {

            @Override
            public void onGenericValueSelected(GenericSelectView2 genericSelectView, String value) {
                CPUBoost.setCpuBoostExynosInputFreq(value, bigFreq[0], getActivity());
                genericSelectView.setValue(value + " Hz");
                littleFreq[0] = value;
            }
        });
        cpuBoostCard.addItem(little);
        GenericSelectView2 big = new GenericSelectView2();
        big.setTitle(getString(R.string.ib_freq_big));
        big.setValue(bigFreq[0] + " Hz");
        big.setValueRaw(big.getValue().replace(" Hz", ""));
        big.setInputType(InputType.TYPE_CLASS_NUMBER);
        big.setOnGenericValueListener(new GenericSelectView2.OnGenericValueListener() {

            @Override
            public void onGenericValueSelected(GenericSelectView2 genericSelectView, String value) {
                CPUBoost.setCpuBoostExynosInputFreq(littleFreq[0], value, getActivity());
                genericSelectView.setValue(value + " Hz");
                bigFreq[0] = value;
            }
        });
        cpuBoostCard.addItem(big);
    }
    if (CPUBoost.hasCpuBoostDebugMask()) {
        SwitchView debugMask = new SwitchView();
        debugMask.setTitle(getString(R.string.debug_mask));
        debugMask.setSummary(getString(R.string.debug_mask_summary));
        debugMask.setChecked(CPUBoost.isCpuBoostDebugMaskEnabled());
        debugMask.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                CPUBoost.enableCpuBoostDebugMask(isChecked, getActivity());
            }
        });
        cpuBoostCard.addItem(debugMask);
    }
    if (CPUBoost.hasCpuBoostMs()) {
        SeekBarView ms = new SeekBarView();
        ms.setTitle(getString(R.string.interval));
        ms.setSummary(getString(R.string.interval_summary));
        ms.setUnit(getString(R.string.ms));
        ms.setMax(5000);
        ms.setOffset(10);
        ms.setProgress(CPUBoost.getCpuBootMs() / 10);
        ms.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

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

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                CPUBoost.setCpuBoostMs(position * 10, getActivity());
            }
        });
        cpuBoostCard.addItem(ms);
    }
    if (CPUBoost.hasCpuBoostSyncThreshold() && CPUFreq.getFreqs() != null) {
        List<String> list = new ArrayList<>();
        list.add(getString(R.string.disabled));
        list.addAll(CPUFreq.getAdjustedFreq(getActivity()));
        SelectView syncThreshold = new SelectView();
        syncThreshold.setTitle(getString(R.string.sync_threshold));
        syncThreshold.setSummary(getString(R.string.sync_threshold_summary));
        syncThreshold.setItems(list);
        syncThreshold.setItem(CPUBoost.getCpuBootSyncThreshold());
        syncThreshold.setOnItemSelected(new SelectView.OnItemSelected() {

            @Override
            public void onItemSelected(SelectView selectView, int position, String item) {
                CPUBoost.setCpuBoostSyncThreshold(position == 0 ? 0 : CPUFreq.getFreqs().get(position - 1), getActivity());
            }
        });
        cpuBoostCard.addItem(syncThreshold);
    }
    if (CPUBoost.hasCpuBoostInputMs()) {
        SeekBarView inputMs = new SeekBarView();
        inputMs.setTitle(getString(R.string.input_interval));
        inputMs.setSummary(getString(R.string.input_interval_summary));
        inputMs.setUnit(getString(R.string.ms));
        inputMs.setMax(5000);
        inputMs.setOffset(10);
        inputMs.setProgress(CPUBoost.getCpuBootInputMs() / 10);
        inputMs.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

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

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                CPUBoost.setCpuBoostInputMs(position * 10, getActivity());
            }
        });
        cpuBoostCard.addItem(inputMs);
    }
    if (CPUBoost.hasCpuBoostInputFreq()) {
        List<Integer> freqs = CPUBoost.getCpuBootInputFreq();
        for (int i = 0; i < freqs.size(); i++) {
            List<String> list = new ArrayList<>();
            list.add(getString(R.string.disabled));
            list.addAll(CPUFreq.getAdjustedFreq(i, getActivity()));
            SelectView inputCard = new SelectView();
            if (freqs.size() > 1) {
                inputCard.setTitle(getString(R.string.input_boost_freq_core, i + 1));
            } else {
                inputCard.setTitle(getString(R.string.input_boost_freq));
            }
            inputCard.setSummary(getString(R.string.input_boost_freq_summary));
            inputCard.setItems(list);
            inputCard.setItem(freqs.get(i));
            final int core = i;
            inputCard.setOnItemSelected(new SelectView.OnItemSelected() {

                @Override
                public void onItemSelected(SelectView selectView, int position, String item) {
                    CPUBoost.setCpuBoostInputFreq(position == 0 ? 0 : CPUFreq.getFreqs(core).get(position - 1), core, getActivity());
                }
            });
            cpuBoostCard.addItem(inputCard);
        }
    }
    if (CPUBoost.hasCpuBoostWakeup()) {
        SwitchView wakeup = new SwitchView();
        wakeup.setTitle(getString(R.string.wakeup_boost));
        wakeup.setSummary(getString(R.string.wakeup_boost_summary));
        wakeup.setChecked(CPUBoost.isCpuBoostWakeupEnabled());
        wakeup.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                CPUBoost.enableCpuBoostWakeup(isChecked, getActivity());
            }
        });
        cpuBoostCard.addItem(wakeup);
    }
    if (CPUBoost.hasCpuBoostHotplug()) {
        SwitchView hotplug = new SwitchView();
        hotplug.setTitle(getString(R.string.hotplug_boost));
        hotplug.setSummary(getString(R.string.hotplug_boost_summary));
        hotplug.setChecked(CPUBoost.isCpuBoostHotplugEnabled());
        hotplug.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                CPUBoost.enableCpuBoostHotplug(isChecked, getActivity());
            }
        });
        cpuBoostCard.addItem(hotplug);
    }
    if (cpuBoostCard.size() > 0) {
        items.add(cpuBoostCard);
    }
}
Also used : SwitchView(com.moro.mtweaks.views.recyclerview.SwitchView) CardView(com.moro.mtweaks.views.recyclerview.CardView) ArrayList(java.util.ArrayList) SeekBarView(com.moro.mtweaks.views.recyclerview.SeekBarView) GenericSelectView2(com.moro.mtweaks.views.recyclerview.GenericSelectView2) SelectView(com.moro.mtweaks.views.recyclerview.SelectView)

Example 3 with GenericSelectView2

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

the class IOFragment method storageInit.

private void storageInit(final IO.Storage storage, List<RecyclerViewItem> items) {
    CardView io = new CardView(getActivity());
    io.setTitle(getString(storage == IO.Storage.Internal ? R.string.internal_storage : R.string.external_storage));
    if (IO.hasScheduler(storage)) {
        SelectView scheduler = new SelectView();
        scheduler.setTitle(getString(R.string.scheduler));
        scheduler.setSummary(getString(R.string.scheduler_summary));
        scheduler.setItems(IO.getSchedulers(storage));
        scheduler.setItem(IO.getScheduler(storage));
        scheduler.setOnItemSelected(new SelectView.OnItemSelected() {

            @Override
            public void onItemSelected(SelectView selectView, int position, String item) {
                IO.setScheduler(storage, item, getActivity());
            }
        });
        io.addItem(scheduler);
        DescriptionView tunable = new DescriptionView();
        tunable.setTitle(getString(R.string.scheduler_tunable));
        tunable.setSummary(getString(R.string.scheduler_tunable_summary));
        tunable.setOnItemClickListener(new RecyclerViewItem.OnItemClickListener() {

            @Override
            public void onClick(RecyclerViewItem item) {
                showTunables(IO.getScheduler(storage), IO.getIOSched(storage));
            }
        });
        io.addItem(tunable);
    }
    if (IO.hasReadahead(storage)) {
        SeekBarView readahead = new SeekBarView();
        readahead.setTitle(getString(R.string.read_ahead));
        readahead.setSummary(getString(R.string.read_ahead_summary));
        readahead.setUnit(getString(R.string.kb));
        readahead.setMax(8192);
        readahead.setMin(128);
        readahead.setOffset(128);
        readahead.setProgress(IO.getReadahead(storage) / 128 - 1);
        readahead.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                IO.setReadahead(storage, (position + 1) * 128, getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        io.addItem(readahead);
    }
    if (IO.hasRotational(storage)) {
        SwitchView rotational = new SwitchView();
        rotational.setTitle(getString(R.string.rotational));
        rotational.setSummary(getString(R.string.rotational_summary));
        rotational.setChecked(IO.isRotationalEnabled(storage));
        rotational.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                IO.enableRotational(storage, isChecked, getActivity());
            }
        });
        io.addItem(rotational);
    }
    if (IO.hasIOStats(storage)) {
        SwitchView iostats = new SwitchView();
        iostats.setTitle(getString(R.string.iostats));
        iostats.setSummary(getString(R.string.iostats_summary));
        iostats.setChecked(IO.isIOStatsEnabled(storage));
        iostats.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                IO.enableIOstats(storage, isChecked, getActivity());
            }
        });
        io.addItem(iostats);
    }
    if (IO.hasAddRandom(storage)) {
        SwitchView addRandom = new SwitchView();
        addRandom.setTitle(getString(R.string.add_random));
        addRandom.setSummary(getString(R.string.add_random_summary));
        addRandom.setChecked(IO.isAddRandomEnabled(storage));
        addRandom.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                IO.enableAddRandom(storage, isChecked, getActivity());
            }
        });
        io.addItem(addRandom);
    }
    if (IO.hasRqAffinity(storage)) {
        SeekBarView rqAffinity = new SeekBarView();
        rqAffinity.setTitle(getString(R.string.rq_affitiny));
        rqAffinity.setSummary(getString(R.string.rq_affinity_summary));
        rqAffinity.setMax(2);
        rqAffinity.setProgress(IO.getRqAffinity(storage));
        rqAffinity.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                IO.setRqAffinity(storage, position, getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        io.addItem(rqAffinity);
    }
    if (IO.hasNomerges(storage)) {
        SeekBarView Nomerges = new SeekBarView();
        Nomerges.setTitle(getString(R.string.nomerges));
        Nomerges.setSummary(getString(R.string.nomerges_summary));
        Nomerges.setMax(2);
        Nomerges.setProgress(IO.getNomerges(storage));
        Nomerges.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                IO.setNomerges(storage, position, getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        io.addItem(Nomerges);
    }
    if (IO.hasNrRequests(storage)) {
        GenericSelectView2 NrRequests = new GenericSelectView2();
        NrRequests.setTitle(getString(R.string.nr_requests));
        NrRequests.setValue(IO.getNrRequests(storage));
        NrRequests.setValueRaw(NrRequests.getValue());
        NrRequests.setInputType(InputType.TYPE_CLASS_NUMBER);
        NrRequests.setOnGenericValueListener(new GenericSelectView2.OnGenericValueListener() {

            @Override
            public void onGenericValueSelected(GenericSelectView2 genericSelectView, String value) {
                IO.setNrRequests(storage, value, getActivity());
                genericSelectView.setValue(value);
            }
        });
        io.addItem(NrRequests);
    }
    if (io.size() > 0) {
        items.add(io);
    }
}
Also used : SwitchView(com.moro.mtweaks.views.recyclerview.SwitchView) CardView(com.moro.mtweaks.views.recyclerview.CardView) RecyclerViewItem(com.moro.mtweaks.views.recyclerview.RecyclerViewItem) SeekBarView(com.moro.mtweaks.views.recyclerview.SeekBarView) GenericSelectView2(com.moro.mtweaks.views.recyclerview.GenericSelectView2) DescriptionView(com.moro.mtweaks.views.recyclerview.DescriptionView) SelectView(com.moro.mtweaks.views.recyclerview.SelectView)

Aggregations

GenericSelectView2 (com.moro.mtweaks.views.recyclerview.GenericSelectView2)3 SwitchView (com.moro.mtweaks.views.recyclerview.SwitchView)3 CardView (com.moro.mtweaks.views.recyclerview.CardView)2 SeekBarView (com.moro.mtweaks.views.recyclerview.SeekBarView)2 SelectView (com.moro.mtweaks.views.recyclerview.SelectView)2 DescriptionView (com.moro.mtweaks.views.recyclerview.DescriptionView)1 RecyclerViewItem (com.moro.mtweaks.views.recyclerview.RecyclerViewItem)1 TitleView (com.moro.mtweaks.views.recyclerview.TitleView)1 ArrayList (java.util.ArrayList)1