Search in sources :

Example 6 with CardView

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

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

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

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

Example 10 with CardView

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

the class ScreenFragment method mdnieGlobalInit.

private void mdnieGlobalInit(List<RecyclerViewItem> items) {
    CardView mdnieCard = new CardView(getActivity());
    mdnieCard.setTitle(getString(R.string.mdnie_global_controls));
    if (Misc.hasRegisterHook()) {
        SwitchView registerHook = new SwitchView();
        registerHook.setTitle(getString(R.string.register_hook));
        registerHook.setSummary(getString(R.string.register_hook_summary));
        registerHook.setChecked(Misc.isRegisterHookEnabled());
        registerHook.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                Misc.enableRegisterHook(isChecked, getActivity());
            }
        });
        mdnieCard.addItem(registerHook);
    }
    if (Misc.hasMasterSequence()) {
        SwitchView masterSequence = new SwitchView();
        masterSequence.setTitle(getString(R.string.master_sequence));
        masterSequence.setSummary(getString(R.string.master_sequence_summary));
        masterSequence.setChecked(Misc.isMasterSequenceEnable());
        masterSequence.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                Misc.enableMasterSequence(isChecked, getActivity());
            }
        });
        mdnieCard.addItem(masterSequence);
    }
    if (mdnieCard.size() > 0) {
        items.add(mdnieCard);
    }
}
Also used : SwitchView(com.moro.mtweaks.views.recyclerview.SwitchView) CardView(com.moro.mtweaks.views.recyclerview.CardView)

Aggregations

CardView (com.moro.mtweaks.views.recyclerview.CardView)51 SeekBarView (com.moro.mtweaks.views.recyclerview.SeekBarView)23 SwitchView (com.moro.mtweaks.views.recyclerview.SwitchView)23 SelectView (com.moro.mtweaks.views.recyclerview.SelectView)20 DescriptionView (com.moro.mtweaks.views.recyclerview.DescriptionView)13 RecyclerViewItem (com.moro.mtweaks.views.recyclerview.RecyclerViewItem)9 ArrayList (java.util.ArrayList)8 TitleView (com.moro.mtweaks.views.recyclerview.TitleView)6 PopupMenu (android.support.v7.widget.PopupMenu)4 MenuItem (android.view.MenuItem)4 GenericSelectView (com.moro.mtweaks.views.recyclerview.GenericSelectView)4 DialogInterface (android.content.DialogInterface)3 Menu (android.view.Menu)3 Intent (android.content.Intent)2 GenericSelectView2 (com.moro.mtweaks.views.recyclerview.GenericSelectView2)2 XYGraphView (com.moro.mtweaks.views.recyclerview.XYGraphView)2 AppWidgetManager (android.appwidget.AppWidgetManager)1 ComponentName (android.content.ComponentName)1 View (android.view.View)1 TextView (android.widget.TextView)1