Search in sources :

Example 61 with SwitchView

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

the class CPUHotplugFragment method thunderPlugInit.

private void thunderPlugInit(List<RecyclerViewItem> items) {
    CardView thunderPlug = new CardView(getActivity());
    if (ThunderPlug.hasThunderPlugVersion()) {
        thunderPlug.setTitle(ThunderPlug.getThunderPlugVersion());
    } else {
        thunderPlug.setTitle(getString(R.string.thunderplug));
    }
    if (ThunderPlug.hasThunderPlugEnable()) {
        SwitchView enable = new SwitchView();
        enable.setTitle(getString(R.string.thunderplug));
        enable.setSummary(getString(R.string.thunderplug_summary));
        enable.setChecked(ThunderPlug.isThunderPlugEnabled());
        enable.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                if (isChecked) {
                    SamsungPlug.enableSamsungPlug(false, getActivity());
                    ThunderPlug.enableStateNotifier(true, getActivity());
                    ThunderPlug.enableThunderPlug(true, getActivity());
                } else {
                    ThunderPlug.enableThunderPlug(false, getActivity());
                    ThunderPlug.enableStateNotifier(false, getActivity());
                    SamsungPlug.enableSamsungPlug(true, getActivity());
                }
                refreshHotPlugs();
            }
        });
        thunderPlug.addItem(enable);
        mEnableViews.add(enable);
    }
    if (ThunderPlug.hasThunderPlugSuspendCpus()) {
        SeekBarView suspendCpus = new SeekBarView();
        suspendCpus.setTitle(getString(R.string.min_cpu_online_screen_off));
        suspendCpus.setSummary(getString(R.string.min_cpu_online_screen_off_summary));
        suspendCpus.setMax(CPUFreq.getCpuCount());
        suspendCpus.setMin(1);
        suspendCpus.setProgress(ThunderPlug.getThunderPlugSuspendCpus() - 1);
        suspendCpus.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

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

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                ThunderPlug.setThunderPlugSuspendCpus(position + 1, getActivity());
            }
        });
        thunderPlug.addItem(suspendCpus);
    }
    if (ThunderPlug.hasThunderPlugEnduranceLevel()) {
        SelectView enduranceLevel = new SelectView();
        enduranceLevel.setTitle(getString(R.string.endurance_level));
        enduranceLevel.setSummary(getString(R.string.endurance_level_summary));
        enduranceLevel.setItems(Arrays.asList(getResources().getStringArray(R.array.endurance_level_items)));
        enduranceLevel.setItem(ThunderPlug.getThunderPlugEnduranceLevel());
        enduranceLevel.setOnItemSelected(new SelectView.OnItemSelected() {

            @Override
            public void onItemSelected(SelectView selectView, int position, String item) {
                ThunderPlug.setThunderPlugEnduranceLevel(position, getActivity());
            }
        });
        thunderPlug.addItem(enduranceLevel);
    }
    if (ThunderPlug.hasThunderPlugSamplingRate()) {
        SeekBarView samplingRate = new SeekBarView();
        samplingRate.setTitle(getString(R.string.sampling_rate));
        samplingRate.setMax(500);
        samplingRate.setMin(10);
        samplingRate.setOffset(10);
        samplingRate.setProgress(ThunderPlug.getThunderPlugSamplingRate() / 10 - 1);
        samplingRate.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

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

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                ThunderPlug.setThunderPlugSamplingRate((position + 1) * 10, getActivity());
            }
        });
        thunderPlug.addItem(samplingRate);
    }
    if (ThunderPlug.hasThunderPlugLoadThreshold()) {
        SeekBarView loadThreadshold = new SeekBarView();
        loadThreadshold.setTitle(getString(R.string.load_threshold));
        loadThreadshold.setSummary(getString(R.string.load_threshold_summary));
        loadThreadshold.setMin(11);
        loadThreadshold.setProgress(ThunderPlug.getThunderPlugLoadThreshold() - 11);
        loadThreadshold.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

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

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                ThunderPlug.setThunderPlugLoadThreshold(position + 11, getActivity());
            }
        });
        thunderPlug.addItem(loadThreadshold);
    }
    if (ThunderPlug.hasThunderPlugTouchBoost()) {
        SwitchView touchBoost = new SwitchView();
        touchBoost.setTitle(getString(R.string.touch_boost));
        touchBoost.setSummary(getString(R.string.touch_boost_summary));
        touchBoost.setChecked(ThunderPlug.isThunderPlugTouchBoostEnabled());
        touchBoost.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                ThunderPlug.enableThunderPlugTouchBoost(isChecked, getActivity());
            }
        });
        thunderPlug.addItem(touchBoost);
    }
    if (ThunderPlug.hasThunderPlugCpusBoosted()) {
        SeekBarView cpusBoosted = new SeekBarView();
        cpusBoosted.setTitle(getString(R.string.cpus_boosted));
        cpusBoosted.setSummary(getString(R.string.cpus_boosted_summary));
        cpusBoosted.setMax(8);
        cpusBoosted.setMin(1);
        cpusBoosted.setProgress(ThunderPlug.getThunderPlugCpusBoosted() - 1);
        cpusBoosted.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

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

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                ThunderPlug.setThunderPlugLoadCpusBoosted(position + 1, getActivity());
            }
        });
        thunderPlug.addItem(cpusBoosted);
    }
    if (thunderPlug.size() > 0) {
        items.add(thunderPlug);
    }
}
Also used : SwitchView(com.moro.mtweaks.views.recyclerview.SwitchView) CardView(com.moro.mtweaks.views.recyclerview.CardView) SeekBarView(com.moro.mtweaks.views.recyclerview.SeekBarView) SelectView(com.moro.mtweaks.views.recyclerview.SelectView)

Example 62 with SwitchView

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

the class CPUVoltageCl1Fragment method addItems.

@Override
protected void addItems(List<RecyclerViewItem> items) {
    mVoltages.clear();
    final List<String> freqs = VoltageCl1.getFreqs();
    final List<String> voltages = VoltageCl1.getVoltages();
    final List<String> voltagesStock = VoltageCl1.getStockVoltages();
    if (freqs != null && voltages != null && voltagesStock != null && freqs.size() == voltages.size()) {
        CardView freqCard = new CardView(getActivity());
        freqCard.setTitle(getString(R.string.cpuCl1_volt_control));
        List<String> progress = new ArrayList<>();
        for (float i = -100000f; i < 31250f; i += 6250) {
            String global = String.valueOf(i / VoltageCl1.getOffset());
            progress.add(global);
        }
        seekbarProfInit(mSeekbarProf, freqs, voltages, voltagesStock, progress);
        freqCard.addItem(mSeekbarProf);
        Boolean enableGlobal = Prefs.getBoolean("CpuCl1_global_volts", true, getActivity());
        SwitchView voltControl = new SwitchView();
        voltControl.setTitle(getString(R.string.cpu_manual_volt));
        voltControl.setSummaryOn(getString(R.string.cpu_manual_volt_summaryOn));
        voltControl.setSummaryOff(getString(R.string.cpu_manual_volt_summaryOff));
        voltControl.setChecked(enableGlobal);
        voltControl.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                if (isChecked) {
                    Prefs.saveBoolean("CpuCl1_global_volts", true, getActivity());
                    Prefs.saveBoolean("CpuCl1_individual_volts", false, getActivity());
                    reload();
                } else {
                    Prefs.saveBoolean("CpuCl1_global_volts", false, getActivity());
                    Prefs.saveBoolean("CpuCl1_individual_volts", true, getActivity());
                    Prefs.saveInt("CpuCl1_seekbarPref_value", 16, getActivity());
                    reload();
                }
            }
        });
        freqCard.addItem(voltControl);
        if (freqCard.size() > 0) {
            items.add(freqCard);
        }
        TitleView tunables = new TitleView();
        tunables.setText(getString(R.string.cpuCl1_volt));
        items.add(tunables);
        for (int i = 0; i < freqs.size(); i++) {
            SeekBarView seekbar = new SeekBarView();
            seekbarInit(seekbar, freqs.get(i), voltages.get(i), voltagesStock.get(i));
            mVoltages.add(seekbar);
        }
    }
    items.addAll(mVoltages);
}
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) TitleView(com.moro.mtweaks.views.recyclerview.TitleView)

Example 63 with SwitchView

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

the class GPUFragment method voltageInit.

private void voltageInit(List<RecyclerViewItem> items) {
    List<Integer> freqs = GPUFreq.getAvailableFreqs();
    List<String> voltages = GPUFreq.getVoltages();
    List<String> voltagesStock = GPUFreq.getStockVoltages();
    if (freqs != null && voltages != null && voltagesStock != null && freqs.size() == voltages.size()) {
        CardView voltCard = new CardView(getActivity());
        voltCard.setTitle(getString(R.string.gpu_voltage));
        List<String> progress = new ArrayList<>();
        for (float i = -100000f; i < 31250f; i += 6250) {
            String global = String.valueOf(i / GPUFreq.getVoltageOffset());
            progress.add(global);
        }
        seekbarProfInit(mSeekbarProf, freqs, voltages, voltagesStock, progress);
        voltCard.addItem(mSeekbarProf);
        Boolean enableGlobal = Prefs.getBoolean("gpu_global_volts", true, getActivity());
        SwitchView voltControl = new SwitchView();
        voltControl.setTitle(getString(R.string.cpu_manual_volt));
        voltControl.setSummaryOn(getString(R.string.cpu_manual_volt_summaryOn));
        voltControl.setSummaryOff(getString(R.string.cpu_manual_volt_summaryOff));
        voltControl.setChecked(enableGlobal);
        voltControl.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                if (isChecked) {
                    Prefs.saveBoolean("gpu_global_volts", true, getActivity());
                    Prefs.saveBoolean("gpu_individual_volts", false, getActivity());
                    reload();
                } else {
                    Prefs.saveBoolean("gpu_global_volts", false, getActivity());
                    Prefs.saveBoolean("gpu_individual_volts", true, getActivity());
                    Prefs.saveInt("gpu_seekbarPref_value", 16, getActivity());
                    reload();
                }
            }
        });
        voltCard.addItem(voltControl);
        if (voltCard.size() > 0) {
            items.add(voltCard);
        }
        TitleView tunables = new TitleView();
        tunables.setText(getString(R.string.cpuCl1_volt));
        items.add(tunables);
        for (int i = 0; i < freqs.size(); i++) {
            SeekBarView seekbar = new SeekBarView();
            seekbarInit(seekbar, freqs.get(i), voltages.get(i), voltagesStock.get(i));
            mVoltages.add(seekbar);
        }
        items.addAll(mVoltages);
    }
}
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) TitleView(com.moro.mtweaks.views.recyclerview.TitleView)

Example 64 with SwitchView

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

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