Search in sources :

Example 1 with SelectView

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

the class BoefflaWakelockFragment method boefflaWakelockInit.

private void boefflaWakelockInit(List<RecyclerViewItem> items) {
    mWakeCard.clear();
    TitleView bwbT = new TitleView();
    bwbT.setText(getString(R.string.boeffla_wakelock) + " v" + BoefflaWakelock.getVersion());
    items.add(bwbT);
    DescriptionView bwbD = new DescriptionView();
    bwbD.setSummary(getString(R.string.boeffla_wakelock_summary));
    items.add(bwbD);
    SelectView bwOrder = new SelectView();
    bwOrder.setTitle(getString(R.string.wkl_order));
    bwOrder.setSummary(getString(R.string.wkl_order_summary));
    bwOrder.setItems(Arrays.asList(getResources().getStringArray(R.array.b_wakelocks_oder)));
    bwOrder.setItem(getString(R.string.wkl_time));
    bwOrder.setOnItemSelected(new SelectView.OnItemSelected() {

        @Override
        public void onItemSelected(SelectView selectView, int position, String item) {
            BoefflaWakelock.setWakelockOrder(position);
            bwCardReload();
        }
    });
    items.add(bwOrder);
    List<BoefflaWakelock.ListWake> wakelocksB = BoefflaWakelock.getWakelockListBlocked();
    String titleB = getString(R.string.wkl_blocked);
    CardView cardB = new CardView(getActivity());
    bwCardInit(cardB, titleB, wakelocksB);
    mWakeCard.add(cardB);
    List<BoefflaWakelock.ListWake> wakelocksA = BoefflaWakelock.getWakelockListAllowed();
    String titleA = getString(R.string.wkl_allowed);
    CardView cardA = new CardView(getActivity());
    bwCardInit(cardA, titleA, wakelocksA);
    mWakeCard.add(cardA);
    items.addAll(mWakeCard);
}
Also used : DescriptionView(com.moro.mtweaks.views.recyclerview.DescriptionView) CardView(com.moro.mtweaks.views.recyclerview.CardView) TitleView(com.moro.mtweaks.views.recyclerview.TitleView) SelectView(com.moro.mtweaks.views.recyclerview.SelectView)

Example 2 with SelectView

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

the class MiscFragment method powersuspendInit.

private void powersuspendInit(List<RecyclerViewItem> items) {
    String v = PowerSuspend.getVersion().replace("version: ", " v");
    CardView ps = new CardView(getActivity());
    ps.setTitle(getString(R.string.power_suspend) + v);
    if (PowerSuspend.hasMode()) {
        SelectView mode = new SelectView();
        mode.setTitle(getString(R.string.power_suspend_mode));
        mode.setSummary(getString(R.string.power_suspend_mode_summary));
        if (v.contains("1.5") || v.contains("1.8")) {
            mode.setItems(Arrays.asList(getResources().getStringArray(R.array.powersuspend_items)));
        } else {
            mode.setItems(Arrays.asList(getResources().getStringArray(R.array.powersuspend_items_lite)));
        }
        mode.setItem(PowerSuspend.getMode());
        mode.setOnItemSelected(new SelectView.OnItemSelected() {

            @Override
            public void onItemSelected(SelectView selectView, int position, String item) {
                PowerSuspend.setMode(position, getActivity());
            }
        });
        ps.addItem(mode);
    }
    if (PowerSuspend.hasState()) {
        final SwitchView state = new SwitchView();
        state.setTitle(getString(R.string.power_suspend_state));
        state.setSummary(getString(R.string.power_suspend_state_summary));
        state.setChecked(PowerSuspend.isStateEnabled());
        state.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, final boolean isChecked) {
                PowerSuspend.enableState(isChecked, getActivity());
                getHandler().postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        state.setChecked(PowerSuspend.isStateEnabled());
                        if (isChecked != PowerSuspend.isStateEnabled())
                            Utils.toast(getString(R.string.power_suspend_state_toast), getActivity());
                    }
                }, 500);
            }
        });
        ps.addItem(state);
    }
    if (ps.size() > 0) {
        items.add(ps);
    }
}
Also used : SwitchView(com.moro.mtweaks.views.recyclerview.SwitchView) CardView(com.moro.mtweaks.views.recyclerview.CardView) SelectView(com.moro.mtweaks.views.recyclerview.SelectView) GenericSelectView(com.moro.mtweaks.views.recyclerview.GenericSelectView)

Example 3 with SelectView

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

the class MiscFragment method networkInit.

private void networkInit(List<RecyclerViewItem> items) {
    CardView networkCard = new CardView(getActivity());
    networkCard.setTitle(getString(R.string.network));
    try {
        SelectView tcp = new SelectView();
        tcp.setTitle(getString(R.string.tcp));
        tcp.setSummary(getString(R.string.tcp_summary));
        tcp.setItems(Misc.getTcpAvailableCongestions());
        tcp.setItem(Misc.getTcpCongestion());
        tcp.setOnItemSelected(new SelectView.OnItemSelected() {

            @Override
            public void onItemSelected(SelectView selectView, int position, String item) {
                Misc.setTcpCongestion(item, getActivity());
            }
        });
        networkCard.addItem(tcp);
    } catch (Exception ignored) {
    }
    GenericSelectView hostname = new GenericSelectView();
    hostname.setSummary(getString(R.string.hostname));
    hostname.setValue(Misc.getHostname());
    hostname.setValueRaw(hostname.getValue());
    hostname.setOnGenericValueListener(new GenericSelectView.OnGenericValueListener() {

        @Override
        public void onGenericValueSelected(GenericSelectView genericSelectView, String value) {
            Misc.setHostname(value, getActivity());
        }
    });
    networkCard.addItem(hostname);
    if (Misc.hasWireguard()) {
        DescriptionView wireguard = new DescriptionView();
        wireguard.setTitle(getString(R.string.wireguard_title));
        wireguard.setSummary(getString(R.string.version) + ": " + Misc.getWireguard());
        networkCard.addItem(wireguard);
    }
    items.add(networkCard);
}
Also used : DescriptionView(com.moro.mtweaks.views.recyclerview.DescriptionView) CardView(com.moro.mtweaks.views.recyclerview.CardView) SelectView(com.moro.mtweaks.views.recyclerview.SelectView) GenericSelectView(com.moro.mtweaks.views.recyclerview.GenericSelectView) GenericSelectView(com.moro.mtweaks.views.recyclerview.GenericSelectView)

Example 4 with SelectView

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

the class MiscFragment method selinuxInit.

private void selinuxInit(List<RecyclerViewItem> items) {
    CardView sl = new CardView(getActivity());
    sl.setTitle(getString(R.string.selinux));
    final SelectView mode = new SelectView();
    mode.setTitle(getString(R.string.selinux));
    mode.setSummary(getString(R.string.selinux_summary));
    mode.setItems(Arrays.asList(getResources().getStringArray(R.array.selinux_states)));
    mode.setItem(Selinux.getStringEnforceMode());
    mode.setOnItemSelected(new SelectView.OnItemSelected() {

        @Override
        public void onItemSelected(SelectView selectView, final int position, String item) {
            Selinux.setEnforceMode(position, getActivity());
            getHandler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    mode.setItem(Selinux.getStringEnforceMode());
                    if (position != Selinux.getEnforceMode())
                        Utils.toast(getString(R.string.selinux_no_kernel_toast), getActivity());
                }
            }, 500);
        }
    });
    sl.addItem(mode);
    if (sl.size() > 0) {
        items.add(sl);
    }
}
Also used : CardView(com.moro.mtweaks.views.recyclerview.CardView) SelectView(com.moro.mtweaks.views.recyclerview.SelectView) GenericSelectView(com.moro.mtweaks.views.recyclerview.GenericSelectView)

Example 5 with SelectView

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

the class CPUFragment method freqInit.

private void freqInit(List<RecyclerViewItem> items) {
    CardView bigCard = new CardView(getActivity());
    if (CPUFreq.isBigLITTLE()) {
        bigCard.setTitle(getString(R.string.cluster_big));
    }
    mCPUUsageBig = new XYGraphView();
    mCPUUsageBig.setTitle(getString(R.string.cpu_usage));
    bigCard.addItem(mCPUUsageBig);
    final List<Integer> bigCores = CPUFreq.getBigCpuRange();
    mCoresBig.clear();
    for (final int core : bigCores) {
        SwitchView coreSwitch = new SwitchView();
        coreSwitch.setSummary(getString(R.string.core, core + 1));
        mCoresBig.put(core, coreSwitch);
        bigCard.addItem(coreSwitch);
    }
    mCPUMaxBig = new SelectView();
    mCPUMaxBig.setTitle(getString(R.string.cpu_max_freq));
    mCPUMaxBig.setSummary(getString(R.string.cpu_max_freq_summary));
    mCPUMaxBig.setItems(CPUFreq.getAdjustedFreq(getActivity()));
    mCPUMaxBig.setOnItemSelected(new SelectView.OnItemSelected() {

        @Override
        public void onItemSelected(SelectView selectView, int position, String item) {
            CPUFreq.setMaxFreq(CPUFreq.getFreqs().get(position), bigCores.get(0), bigCores.get(bigCores.size() - 1), getActivity());
        }
    });
    bigCard.addItem(mCPUMaxBig);
    mCPUMinBig = new SelectView();
    mCPUMinBig.setTitle(getString(R.string.cpu_min_freq));
    mCPUMinBig.setSummary(getString(R.string.cpu_min_freq_summary));
    mCPUMinBig.setItems(CPUFreq.getAdjustedFreq(getActivity()));
    mCPUMinBig.setOnItemSelected(new SelectView.OnItemSelected() {

        @Override
        public void onItemSelected(SelectView selectView, int position, String item) {
            CPUFreq.setMinFreq(CPUFreq.getFreqs().get(position), bigCores.get(0), bigCores.get(bigCores.size() - 1), getActivity());
        }
    });
    bigCard.addItem(mCPUMinBig);
    if (CPUFreq.hasMaxScreenOffFreq()) {
        mCPUMaxScreenOffBig = new SelectView();
        mCPUMaxScreenOffBig.setTitle(getString(R.string.cpu_max_screen_off_freq));
        mCPUMaxScreenOffBig.setSummary(getString(R.string.cpu_max_screen_off_freq_summary));
        mCPUMaxScreenOffBig.setItems(CPUFreq.getAdjustedFreq(getActivity()));
        mCPUMaxScreenOffBig.setOnItemSelected(new SelectView.OnItemSelected() {

            @Override
            public void onItemSelected(SelectView selectView, int position, String item) {
                CPUFreq.setMaxScreenOffFreq(CPUFreq.getFreqs().get(position), bigCores.get(0), bigCores.get(bigCores.size() - 1), getActivity());
            }
        });
        bigCard.addItem(mCPUMaxScreenOffBig);
    }
    mCPUGovernorBig = new SelectView();
    mCPUGovernorBig.setTitle(getString(R.string.cpu_governor));
    mCPUGovernorBig.setSummary(getString(R.string.cpu_governor_summary));
    mCPUGovernorBig.setItems(CPUFreq.getGovernors());
    mCPUGovernorBig.setOnItemSelected(new SelectView.OnItemSelected() {

        @Override
        public void onItemSelected(SelectView selectView, int position, String item) {
            CPUFreq.setGovernor(item, bigCores.get(0), bigCores.get(bigCores.size() - 1), getActivity());
        }
    });
    bigCard.addItem(mCPUGovernorBig);
    DescriptionView governorTunablesBig = new DescriptionView();
    governorTunablesBig.setTitle(getString(R.string.cpu_governor_tunables));
    governorTunablesBig.setSummary(getString(R.string.governor_tunables_summary));
    governorTunablesBig.setOnItemClickListener(new RecyclerViewItem.OnItemClickListener() {

        @Override
        public void onClick(RecyclerViewItem item) {
            showGovernorTunables(bigCores.get(0), bigCores.get(bigCores.size() - 1));
        }
    });
    bigCard.addItem(governorTunablesBig);
    items.add(bigCard);
    if (CPUFreq.isBigLITTLE()) {
        CardView LITTLECard = new CardView(getActivity());
        LITTLECard.setTitle(getString(R.string.cluster_little));
        mCPUUsageLITTLE = new XYGraphView();
        mCPUUsageLITTLE.setTitle(getString(R.string.cpu_usage));
        LITTLECard.addItem(mCPUUsageLITTLE);
        final List<Integer> LITTLECores = CPUFreq.getLITTLECpuRange();
        mCoresLITTLE.clear();
        for (final int core : LITTLECores) {
            SwitchView coreSwitch = new SwitchView();
            coreSwitch.setSummary(getString(R.string.core, core + 1));
            mCoresLITTLE.put(core, coreSwitch);
            LITTLECard.addItem(coreSwitch);
        }
        mCPUMaxLITTLE = new SelectView();
        mCPUMaxLITTLE.setTitle(getString(R.string.cpu_max_freq));
        mCPUMaxLITTLE.setSummary(getString(R.string.cpu_max_freq_summary));
        mCPUMaxLITTLE.setItems(CPUFreq.getAdjustedFreq(CPUFreq.getLITTLECpu(), getActivity()));
        mCPUMaxLITTLE.setOnItemSelected(new SelectView.OnItemSelected() {

            @Override
            public void onItemSelected(SelectView selectView, int position, String item) {
                CPUFreq.setMaxFreq(CPUFreq.getFreqs(CPUFreq.getLITTLECpu()).get(position), LITTLECores.get(0), LITTLECores.get(LITTLECores.size() - 1), getActivity());
            }
        });
        LITTLECard.addItem(mCPUMaxLITTLE);
        mCPUMinLITTLE = new SelectView();
        mCPUMinLITTLE.setTitle(getString(R.string.cpu_min_freq));
        mCPUMinLITTLE.setSummary(getString(R.string.cpu_min_freq_summary));
        mCPUMinLITTLE.setItems(CPUFreq.getAdjustedFreq(CPUFreq.getLITTLECpu(), getActivity()));
        mCPUMinLITTLE.setOnItemSelected(new SelectView.OnItemSelected() {

            @Override
            public void onItemSelected(SelectView selectView, int position, String item) {
                CPUFreq.setMinFreq(CPUFreq.getFreqs(CPUFreq.getLITTLECpu()).get(position), LITTLECores.get(0), LITTLECores.get(LITTLECores.size() - 1), getActivity());
            }
        });
        LITTLECard.addItem(mCPUMinLITTLE);
        if (CPUFreq.hasMaxScreenOffFreq(CPUFreq.getLITTLECpu())) {
            mCPUMaxScreenOffLITTLE = new SelectView();
            mCPUMaxScreenOffLITTLE.setTitle(getString(R.string.cpu_max_screen_off_freq));
            mCPUMaxScreenOffLITTLE.setSummary(getString(R.string.cpu_max_screen_off_freq_summary));
            mCPUMaxScreenOffLITTLE.setItems(CPUFreq.getAdjustedFreq(CPUFreq.getLITTLECpu(), getActivity()));
            mCPUMaxScreenOffLITTLE.setOnItemSelected(new SelectView.OnItemSelected() {

                @Override
                public void onItemSelected(SelectView selectView, int position, String item) {
                    CPUFreq.setMaxScreenOffFreq(CPUFreq.getFreqs(CPUFreq.getLITTLECpu()).get(position), LITTLECores.get(0), LITTLECores.get(LITTLECores.size() - 1), getActivity());
                }
            });
            LITTLECard.addItem(mCPUMaxScreenOffLITTLE);
        }
        mCPUGovernorLITTLE = new SelectView();
        mCPUGovernorLITTLE.setTitle(getString(R.string.cpu_governor));
        mCPUGovernorLITTLE.setSummary(getString(R.string.cpu_governor_summary));
        mCPUGovernorLITTLE.setItems(CPUFreq.getGovernors());
        mCPUGovernorLITTLE.setOnItemSelected(new SelectView.OnItemSelected() {

            @Override
            public void onItemSelected(SelectView selectView, int position, String item) {
                CPUFreq.setGovernor(item, LITTLECores.get(0), LITTLECores.get(LITTLECores.size() - 1), getActivity());
            }
        });
        LITTLECard.addItem(mCPUGovernorLITTLE);
        DescriptionView governorTunablesLITTLE = new DescriptionView();
        governorTunablesLITTLE.setTitle(getString(R.string.cpu_governor_tunables));
        governorTunablesLITTLE.setSummary(getString(R.string.governor_tunables_summary));
        governorTunablesLITTLE.setOnItemClickListener(new RecyclerViewItem.OnItemClickListener() {

            @Override
            public void onClick(RecyclerViewItem item) {
                showGovernorTunables(LITTLECores.get(0), LITTLECores.get(LITTLECores.size() - 1));
            }
        });
        LITTLECard.addItem(governorTunablesLITTLE);
        items.add(LITTLECard);
    }
}
Also used : SwitchView(com.moro.mtweaks.views.recyclerview.SwitchView) CardView(com.moro.mtweaks.views.recyclerview.CardView) RecyclerViewItem(com.moro.mtweaks.views.recyclerview.RecyclerViewItem) XYGraphView(com.moro.mtweaks.views.recyclerview.XYGraphView) DescriptionView(com.moro.mtweaks.views.recyclerview.DescriptionView) SelectView(com.moro.mtweaks.views.recyclerview.SelectView)

Aggregations

SelectView (com.moro.mtweaks.views.recyclerview.SelectView)29 CardView (com.moro.mtweaks.views.recyclerview.CardView)20 SwitchView (com.moro.mtweaks.views.recyclerview.SwitchView)14 SeekBarView (com.moro.mtweaks.views.recyclerview.SeekBarView)12 ArrayList (java.util.ArrayList)10 RecyclerViewItem (com.moro.mtweaks.views.recyclerview.RecyclerViewItem)8 TitleView (com.moro.mtweaks.views.recyclerview.TitleView)7 DescriptionView (com.moro.mtweaks.views.recyclerview.DescriptionView)5 GenericSelectView (com.moro.mtweaks.views.recyclerview.GenericSelectView)3 GenericSelectView2 (com.moro.mtweaks.views.recyclerview.GenericSelectView2)2 XYGraphView (com.moro.mtweaks.views.recyclerview.XYGraphView)2