Search in sources :

Example 1 with GenericSelectView

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

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

the class ScreenFragment method kgammaInit.

private void kgammaInit(List<RecyclerViewItem> items) {
    if (mKGammaBlue == null) {
        mKGammaBlue = new GenericSelectView();
        mKGammaBlue.setSummary(getString(R.string.blue));
        mKGammaBlue.setOnGenericValueListener(new GenericSelectView.OnGenericValueListener() {

            @Override
            public void onGenericValueSelected(GenericSelectView genericSelectView, String value) {
                Gamma.setKGammaBlue(value, getActivity());
                kgammaInit(null);
            }
        });
    }
    String blue = Gamma.getKGammaBlue();
    mKGammaBlue.setValue(blue);
    mKGammaBlue.setValueRaw(blue);
    if (items != null) {
        items.add(mKGammaBlue);
    }
    if (mKGammaGreen == null) {
        mKGammaGreen = new GenericSelectView();
        mKGammaGreen.setSummary(getString(R.string.green));
        mKGammaGreen.setOnGenericValueListener(new GenericSelectView.OnGenericValueListener() {

            @Override
            public void onGenericValueSelected(GenericSelectView genericSelectView, String value) {
                Gamma.setKGammaGreen(value, getActivity());
                kgammaInit(null);
            }
        });
    }
    String green = Gamma.getKGammaGreen();
    mKGammaGreen.setValue(green);
    mKGammaGreen.setValueRaw(green);
    if (items != null) {
        items.add(mKGammaGreen);
    }
    if (mKGammaRed == null) {
        mKGammaRed = new GenericSelectView();
        mKGammaRed.setSummary(getString(R.string.red));
        mKGammaRed.setOnGenericValueListener(new GenericSelectView.OnGenericValueListener() {

            @Override
            public void onGenericValueSelected(GenericSelectView genericSelectView, String value) {
                Gamma.setKGammaRed(value, getActivity());
                kgammaInit(null);
            }
        });
    }
    String red = Gamma.getKGammaRed();
    mKGammaRed.setValue(red);
    mKGammaRed.setValueRaw(red);
    if (items != null) {
        items.add(mKGammaRed);
    }
    if (items != null) {
        List<String> profileList = new ArrayList<>();
        final GammaProfiles.KGammaProfiles gammaProfiles = Gamma.getKGammaProfiles(getActivity());
        for (int i = 0; i < gammaProfiles.length(); i++) {
            profileList.add(gammaProfiles.getName(i));
        }
        DropDownView profiles = new DropDownView();
        profiles.setTitle(getString(R.string.profile));
        profiles.setSummary(getString(R.string.gamma_profiles_summary));
        profiles.setItems(profileList);
        profiles.setSelection(Prefs.getInt("kgamma_profile", -1, getActivity()));
        profiles.setOnDropDownListener(new DropDownView.OnDropDownListener() {

            @Override
            public void onSelect(DropDownView dropDownView, int position, String value) {
                Gamma.setKGammaProfile(position, gammaProfiles, getActivity());
                kgammaInit(null);
                Prefs.saveInt("kgamma_profile", position, getActivity());
            }
        });
        items.add(profiles);
    }
}
Also used : GammaProfiles(com.moro.mtweaks.utils.kernel.screen.GammaProfiles) ArrayList(java.util.ArrayList) DropDownView(com.moro.mtweaks.views.recyclerview.DropDownView) GenericSelectView(com.moro.mtweaks.views.recyclerview.GenericSelectView)

Example 3 with GenericSelectView

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

the class ScreenFragment method dsipanelInit.

private void dsipanelInit(List<RecyclerViewItem> items) {
    if (mDsiPanelBlueNegative == null) {
        mDsiPanelBlueNegative = new GenericSelectView();
        mDsiPanelBlueNegative.setSummary(getString(R.string.blue_negative));
        mDsiPanelBlueNegative.setOnGenericValueListener(new GenericSelectView.OnGenericValueListener() {

            @Override
            public void onGenericValueSelected(GenericSelectView genericSelectView, String value) {
                Gamma.setBlueNegative(value, getActivity());
            }
        });
    }
    String blueNegative = Gamma.getBlueNegative();
    mDsiPanelBlueNegative.setValue(blueNegative);
    mDsiPanelBlueNegative.setValueRaw(blueNegative);
    if (items != null) {
        items.add(mDsiPanelBlueNegative);
    }
    if (mDsiPanelBluePositive == null) {
        mDsiPanelBluePositive = new GenericSelectView();
        mDsiPanelBluePositive.setSummary(getString(R.string.blue_positive));
        mDsiPanelBluePositive.setOnGenericValueListener(new GenericSelectView.OnGenericValueListener() {

            @Override
            public void onGenericValueSelected(GenericSelectView genericSelectView, String value) {
                Gamma.setBluePositive(value, getActivity());
            }
        });
    }
    String bluePositive = Gamma.getBluePositive();
    mDsiPanelBluePositive.setValue(bluePositive);
    mDsiPanelBluePositive.setValueRaw(bluePositive);
    if (items != null) {
        items.add(mDsiPanelBluePositive);
    }
    if (mDsiPanelGreenNegative == null) {
        mDsiPanelGreenNegative = new GenericSelectView();
        mDsiPanelGreenNegative.setSummary(getString(R.string.green_negative));
        mDsiPanelGreenNegative.setOnGenericValueListener(new GenericSelectView.OnGenericValueListener() {

            @Override
            public void onGenericValueSelected(GenericSelectView genericSelectView, String value) {
                Gamma.setGreenNegative(value, getActivity());
            }
        });
    }
    String greenNegative = Gamma.getGreenNegative();
    mDsiPanelGreenNegative.setValue(greenNegative);
    mDsiPanelGreenNegative.setValueRaw(greenNegative);
    if (items != null) {
        items.add(mDsiPanelGreenNegative);
    }
    if (mDsiPanelGreenPositive == null) {
        mDsiPanelGreenPositive = new GenericSelectView();
        mDsiPanelGreenPositive.setSummary(getString(R.string.green_positive));
        mDsiPanelGreenPositive.setOnGenericValueListener(new GenericSelectView.OnGenericValueListener() {

            @Override
            public void onGenericValueSelected(GenericSelectView genericSelectView, String value) {
                Gamma.setGreenPositive(value, getActivity());
            }
        });
    }
    String greenPositive = Gamma.getGreenPositive();
    mDsiPanelGreenPositive.setValue(greenPositive);
    mDsiPanelGreenPositive.setValueRaw(greenPositive);
    if (items != null) {
        items.add(mDsiPanelGreenPositive);
    }
    if (mDsiPanelRedNegative == null) {
        mDsiPanelRedNegative = new GenericSelectView();
        mDsiPanelRedNegative.setSummary(getString(R.string.red_negative));
        mDsiPanelRedNegative.setOnGenericValueListener(new GenericSelectView.OnGenericValueListener() {

            @Override
            public void onGenericValueSelected(GenericSelectView genericSelectView, String value) {
                Gamma.setRedNegative(value, getActivity());
            }
        });
    }
    String redNegative = Gamma.getRedNegative();
    mDsiPanelRedNegative.setValue(redNegative);
    mDsiPanelRedNegative.setValueRaw(redNegative);
    if (items != null) {
        items.add(mDsiPanelRedNegative);
    }
    if (mDsiPanelRedPositive == null) {
        mDsiPanelRedPositive = new GenericSelectView();
        mDsiPanelRedPositive.setSummary(getString(R.string.red_positive));
        mDsiPanelRedPositive.setOnGenericValueListener(new GenericSelectView.OnGenericValueListener() {

            @Override
            public void onGenericValueSelected(GenericSelectView genericSelectView, String value) {
                Gamma.setRedPositive(value, getActivity());
            }
        });
    }
    String redPositive = Gamma.getRedPositive();
    mDsiPanelRedPositive.setValue(redPositive);
    mDsiPanelRedPositive.setValueRaw(redPositive);
    if (items != null) {
        items.add(mDsiPanelRedPositive);
    }
    if (mDsiPanelWhitePoint == null) {
        mDsiPanelWhitePoint = new GenericSelectView();
        mDsiPanelWhitePoint.setSummary(getString(R.string.white_point));
        mDsiPanelWhitePoint.setOnGenericValueListener(new GenericSelectView.OnGenericValueListener() {

            @Override
            public void onGenericValueSelected(GenericSelectView genericSelectView, String value) {
                Gamma.setWhitePoint(value, getActivity());
            }
        });
    }
    String whitePoint = Gamma.getWhitePoint();
    mDsiPanelWhitePoint.setValue(whitePoint);
    mDsiPanelWhitePoint.setValueRaw(whitePoint);
    if (items != null) {
        items.add(mDsiPanelWhitePoint);
    }
    if (items != null) {
        List<String> profileList = new ArrayList<>();
        final GammaProfiles.DsiPanelProfiles gammaProfiles = Gamma.getDsiPanelProfiles(getActivity());
        for (int i = 0; i < gammaProfiles.length(); i++) {
            profileList.add(gammaProfiles.getName(i));
        }
        DropDownView profiles = new DropDownView();
        profiles.setTitle(getString(R.string.profile));
        profiles.setSummary(getString(R.string.gamma_profiles_summary));
        profiles.setItems(profileList);
        profiles.setSelection(Prefs.getInt("dsi_panel_profile", -1, getActivity()));
        profiles.setOnDropDownListener(new DropDownView.OnDropDownListener() {

            @Override
            public void onSelect(DropDownView dropDownView, int position, String value) {
                Gamma.setDsiPanelProfile(position, gammaProfiles, getActivity());
                dsipanelInit(null);
                Prefs.saveInt("dsi_panel_profile", position, getActivity());
            }
        });
        items.add(profiles);
    }
}
Also used : GammaProfiles(com.moro.mtweaks.utils.kernel.screen.GammaProfiles) ArrayList(java.util.ArrayList) DropDownView(com.moro.mtweaks.views.recyclerview.DropDownView) GenericSelectView(com.moro.mtweaks.views.recyclerview.GenericSelectView)

Example 4 with GenericSelectView

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

the class ScreenFragment method gammacontrolInit.

private void gammacontrolInit(List<RecyclerViewItem> items) {
    if (mGammaControlRedGreys == null) {
        mGammaControlRedGreys = new GenericSelectView();
        mGammaControlRedGreys.setSummary(getString(R.string.red_greys));
        mGammaControlRedGreys.setOnGenericValueListener(new GenericSelectView.OnGenericValueListener() {

            @Override
            public void onGenericValueSelected(GenericSelectView genericSelectView, String value) {
                Gamma.setRedGreys(value, getActivity());
                gammacontrolInit(null);
            }
        });
    }
    String redGreys = Gamma.getRedGreys();
    mGammaControlRedGreys.setValue(redGreys);
    mGammaControlRedGreys.setValueRaw(redGreys);
    if (items != null) {
        items.add(mGammaControlRedGreys);
    }
    if (mGammaControlRedMids == null) {
        mGammaControlRedMids = new GenericSelectView();
        mGammaControlRedMids.setSummary(getString(R.string.red_mids));
        mGammaControlRedMids.setOnGenericValueListener(new GenericSelectView.OnGenericValueListener() {

            @Override
            public void onGenericValueSelected(GenericSelectView genericSelectView, String value) {
                Gamma.setRedMids(value, getActivity());
                gammacontrolInit(null);
            }
        });
    }
    String redMids = Gamma.getRedMids();
    mGammaControlRedMids.setValue(redMids);
    mGammaControlRedMids.setValueRaw(redMids);
    if (items != null) {
        items.add(mGammaControlRedMids);
    }
    if (mGammaControlRedBlacks == null) {
        mGammaControlRedBlacks = new GenericSelectView();
        mGammaControlRedBlacks.setSummary(getString(R.string.red_blacks));
        mGammaControlRedBlacks.setOnGenericValueListener(new GenericSelectView.OnGenericValueListener() {

            @Override
            public void onGenericValueSelected(GenericSelectView genericSelectView, String value) {
                Gamma.setRedBlacks(value, getActivity());
                gammacontrolInit(null);
            }
        });
    }
    String redBlacks = Gamma.getRedBlacks();
    mGammaControlRedBlacks.setValue(redBlacks);
    mGammaControlRedBlacks.setValueRaw(redBlacks);
    if (items != null) {
        items.add(mGammaControlRedBlacks);
    }
    if (mGammaControlRedWhites == null) {
        mGammaControlRedWhites = new GenericSelectView();
        mGammaControlRedWhites.setSummary(getString(R.string.red_whites));
        mGammaControlRedWhites.setOnGenericValueListener(new GenericSelectView.OnGenericValueListener() {

            @Override
            public void onGenericValueSelected(GenericSelectView genericSelectView, String value) {
                Gamma.setRedWhites(value, getActivity());
                gammacontrolInit(null);
            }
        });
    }
    String redWhites = Gamma.getRedWhites();
    mGammaControlRedWhites.setValue(redWhites);
    mGammaControlRedWhites.setValueRaw(redWhites);
    if (items != null) {
        items.add(mGammaControlRedWhites);
    }
    if (mGammaControlGreenGreys == null) {
        mGammaControlGreenGreys = new GenericSelectView();
        mGammaControlGreenGreys.setSummary(getString(R.string.green_greys));
        mGammaControlGreenGreys.setOnGenericValueListener(new GenericSelectView.OnGenericValueListener() {

            @Override
            public void onGenericValueSelected(GenericSelectView genericSelectView, String value) {
                Gamma.setGreenGreys(value, getActivity());
                gammacontrolInit(null);
            }
        });
    }
    String greenGreys = Gamma.getGreenGreys();
    mGammaControlGreenGreys.setValue(greenGreys);
    mGammaControlGreenGreys.setValueRaw(greenGreys);
    if (items != null) {
        items.add(mGammaControlGreenGreys);
    }
    if (mGammaControlGreenMids == null) {
        mGammaControlGreenMids = new GenericSelectView();
        mGammaControlGreenMids.setSummary(getString(R.string.green_mids));
        mGammaControlGreenMids.setOnGenericValueListener(new GenericSelectView.OnGenericValueListener() {

            @Override
            public void onGenericValueSelected(GenericSelectView genericSelectView, String value) {
                Gamma.setGreenMids(value, getActivity());
                gammacontrolInit(null);
            }
        });
    }
    String greenMids = Gamma.getGreenMids();
    mGammaControlGreenMids.setValue(greenMids);
    mGammaControlGreenMids.setValueRaw(greenMids);
    if (items != null) {
        items.add(mGammaControlGreenMids);
    }
    if (mGammaControlGreenBlacks == null) {
        mGammaControlGreenBlacks = new GenericSelectView();
        mGammaControlGreenBlacks.setSummary(getString(R.string.green_blacks));
        mGammaControlGreenBlacks.setOnGenericValueListener(new GenericSelectView.OnGenericValueListener() {

            @Override
            public void onGenericValueSelected(GenericSelectView genericSelectView, String value) {
                Gamma.setGreenBlacks(value, getActivity());
                gammacontrolInit(null);
            }
        });
    }
    String greenBlacks = Gamma.getGreenBlacks();
    mGammaControlGreenBlacks.setValue(greenBlacks);
    mGammaControlGreenBlacks.setValueRaw(greenBlacks);
    if (items != null) {
        items.add(mGammaControlGreenBlacks);
    }
    if (mGammaControlGreenWhites == null) {
        mGammaControlGreenWhites = new GenericSelectView();
        mGammaControlGreenWhites.setSummary(getString(R.string.green_whites));
        mGammaControlGreenWhites.setOnGenericValueListener(new GenericSelectView.OnGenericValueListener() {

            @Override
            public void onGenericValueSelected(GenericSelectView genericSelectView, String value) {
                Gamma.setGreenWhites(value, getActivity());
                gammacontrolInit(null);
            }
        });
    }
    String greenWhites = Gamma.getGreenWhites();
    mGammaControlGreenWhites.setValue(greenWhites);
    mGammaControlGreenWhites.setValueRaw(greenWhites);
    if (items != null) {
        items.add(mGammaControlGreenWhites);
    }
    if (mGammaControlBlueGreys == null) {
        mGammaControlBlueGreys = new GenericSelectView();
        mGammaControlBlueGreys.setSummary(getString(R.string.blue_greys));
        mGammaControlBlueGreys.setOnGenericValueListener(new GenericSelectView.OnGenericValueListener() {

            @Override
            public void onGenericValueSelected(GenericSelectView genericSelectView, String value) {
                Gamma.setBlueGreys(value, getActivity());
                gammacontrolInit(null);
            }
        });
    }
    String blueGreys = Gamma.getBlueGreys();
    mGammaControlBlueGreys.setValue(blueGreys);
    mGammaControlBlueGreys.setValueRaw(blueGreys);
    if (items != null) {
        items.add(mGammaControlBlueGreys);
    }
    if (mGammaControlBlueMids == null) {
        mGammaControlBlueMids = new GenericSelectView();
        mGammaControlBlueMids.setSummary(getString(R.string.blue_mids));
        mGammaControlBlueMids.setOnGenericValueListener(new GenericSelectView.OnGenericValueListener() {

            @Override
            public void onGenericValueSelected(GenericSelectView genericSelectView, String value) {
                Gamma.setBlueMids(value, getActivity());
                gammacontrolInit(null);
            }
        });
    }
    String blueMids = Gamma.getBlueMids();
    mGammaControlBlueMids.setValue(blueMids);
    mGammaControlBlueMids.setValueRaw(blueMids);
    if (items != null) {
        items.add(mGammaControlBlueMids);
    }
    if (mGammaControlBlueBlacks == null) {
        mGammaControlBlueBlacks = new GenericSelectView();
        mGammaControlBlueBlacks.setSummary(getString(R.string.blue_blacks));
        mGammaControlBlueBlacks.setOnGenericValueListener(new GenericSelectView.OnGenericValueListener() {

            @Override
            public void onGenericValueSelected(GenericSelectView genericSelectView, String value) {
                Gamma.setBlueBlacks(value, getActivity());
                gammacontrolInit(null);
            }
        });
    }
    String blueBlacks = Gamma.getBlueBlacks();
    mGammaControlBlueBlacks.setValue(blueBlacks);
    mGammaControlBlueBlacks.setValueRaw(blueBlacks);
    if (items != null) {
        items.add(mGammaControlBlueBlacks);
    }
    if (mGammaControlBlueWhites == null) {
        mGammaControlBlueWhites = new GenericSelectView();
        mGammaControlBlueWhites.setSummary(getString(R.string.blue_whites));
        mGammaControlBlueWhites.setOnGenericValueListener(new GenericSelectView.OnGenericValueListener() {

            @Override
            public void onGenericValueSelected(GenericSelectView genericSelectView, String value) {
                Gamma.setBlueWhites(value, getActivity());
                gammacontrolInit(null);
            }
        });
    }
    String blueWhites = Gamma.getBlueWhites();
    mGammaControlBlueWhites.setValue(blueWhites);
    mGammaControlBlueWhites.setValueRaw(blueWhites);
    if (items != null) {
        items.add(mGammaControlBlueWhites);
    }
    if (mGammaControlContrast == null) {
        mGammaControlContrast = new GenericSelectView();
        mGammaControlContrast.setSummary(getString(R.string.contrast));
        mGammaControlContrast.setOnGenericValueListener(new GenericSelectView.OnGenericValueListener() {

            @Override
            public void onGenericValueSelected(GenericSelectView genericSelectView, String value) {
                Gamma.setGammaContrast(value, getActivity());
                gammacontrolInit(null);
            }
        });
    }
    String contrast = Gamma.getGammaContrast();
    mGammaControlContrast.setValue(contrast);
    mGammaControlContrast.setValueRaw(contrast);
    if (items != null) {
        items.add(mGammaControlContrast);
    }
    if (mGammaControlBrightness == null) {
        mGammaControlBrightness = new GenericSelectView();
        mGammaControlBrightness.setSummary(getString(R.string.brightness));
        mGammaControlBrightness.setOnGenericValueListener(new GenericSelectView.OnGenericValueListener() {

            @Override
            public void onGenericValueSelected(GenericSelectView genericSelectView, String value) {
                Gamma.setGammaBrightness(value, getActivity());
                gammacontrolInit(null);
            }
        });
    }
    String brightness = Gamma.getGammaBrightness();
    mGammaControlBrightness.setValue(brightness);
    mGammaControlBrightness.setValueRaw(brightness);
    if (items != null) {
        items.add(mGammaControlBrightness);
    }
    if (mGammaControlSaturation == null) {
        mGammaControlSaturation = new GenericSelectView();
        mGammaControlSaturation.setSummary(getString(R.string.saturation_intensity));
        mGammaControlSaturation.setOnGenericValueListener(new GenericSelectView.OnGenericValueListener() {

            @Override
            public void onGenericValueSelected(GenericSelectView genericSelectView, String value) {
                Gamma.setGammaSaturation(value, getActivity());
                gammacontrolInit(null);
            }
        });
    }
    String saturation = Gamma.getGammaSaturation();
    mGammaControlSaturation.setValue(saturation);
    mGammaControlSaturation.setValueRaw(saturation);
    if (items != null) {
        items.add(mGammaControlSaturation);
    }
    if (items != null) {
        List<String> profileList = new ArrayList<>();
        final GammaProfiles.GammaControlProfiles gammaProfiles = Gamma.getGammaControlProfiles(getActivity());
        for (int i = 0; i < gammaProfiles.length(); i++) {
            profileList.add(gammaProfiles.getName(i));
        }
        DropDownView profiles = new DropDownView();
        profiles.setTitle(getString(R.string.profile));
        profiles.setSummary(getString(R.string.gamma_profiles_summary));
        profiles.setItems(profileList);
        profiles.setSelection(Prefs.getInt("gamma_control_profile", -1, getActivity()));
        profiles.setOnDropDownListener(new DropDownView.OnDropDownListener() {

            @Override
            public void onSelect(DropDownView dropDownView, int position, String value) {
                Gamma.setGammaControlProfile(position, gammaProfiles, getActivity());
                gammacontrolInit(null);
                Prefs.saveInt("gamma_control_profile", position, getActivity());
            }
        });
        items.add(profiles);
    }
}
Also used : GammaProfiles(com.moro.mtweaks.utils.kernel.screen.GammaProfiles) ArrayList(java.util.ArrayList) DropDownView(com.moro.mtweaks.views.recyclerview.DropDownView) GenericSelectView(com.moro.mtweaks.views.recyclerview.GenericSelectView)

Example 5 with GenericSelectView

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

the class CustomControlsFragment method load.

private void load(List<RecyclerViewItem> items) {
    mControlsProvider = new Controls(getActivity());
    for (final Controls.ControlItem item : mControlsProvider.getAllControls()) {
        CardView cardView = getCard(item);
        cardView.clearItems();
        try {
            String title = item.getTitle();
            String description = item.getDescription();
            if (item.getControl() == Items.Control.SWITCH) {
                SwitchView switchView = new SwitchView();
                if (description != null) {
                    switchView.setTitle(title);
                    switchView.setSummary(description);
                } else {
                    switchView.setSummary(title);
                }
                switchView.setChecked(Values.getBool(item.getString("enable")));
                switchView.addOnSwitchListener(new SwitchView.OnSwitchListener() {

                    @Override
                    public void onChanged(SwitchView switchView, boolean isChecked) {
                        Values.run(item.getApply(), item, isChecked ? "1" : "0");
                        mControlsProvider.commit();
                    }
                });
                cardView.addItem(switchView);
            } else if (item.getControl() == Items.Control.SEEKBAR) {
                SeekBarView seekBarView = new SeekBarView();
                seekBarView.setTitle(title);
                if (description != null) {
                    seekBarView.setSummary(description);
                }
                seekBarView.setMax(item.getInt("max"));
                seekBarView.setMin(item.getInt("min"));
                seekBarView.setProgress(Values.getInt(item.getString("progress")));
                seekBarView.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

                    @Override
                    public void onStop(SeekBarView seekBarView, int position, String value) {
                        Values.run(item.getApply(), item, String.valueOf(position));
                        mControlsProvider.commit();
                    }

                    @Override
                    public void onMove(SeekBarView seekBarView, int position, String value) {
                    }
                });
                cardView.addItem(seekBarView);
            } else if (item.getControl() == Items.Control.GENERIC) {
                GenericSelectView genericSelectView = new GenericSelectView();
                if (description != null) {
                    genericSelectView.setTitle(title);
                    genericSelectView.setSummary(description);
                } else {
                    genericSelectView.setSummary(title);
                }
                genericSelectView.setValue(Values.getString(item.getString("value")));
                genericSelectView.setValueRaw(genericSelectView.getValue());
                genericSelectView.setOnGenericValueListener(new GenericSelectView.OnGenericValueListener() {

                    @Override
                    public void onGenericValueSelected(GenericSelectView genericSelectView, String value) {
                        Values.run(item.getApply(), item, value);
                        genericSelectView.setValue(value);
                        mControlsProvider.commit();
                    }
                });
                cardView.addItem(genericSelectView);
            }
        } catch (CustomControlException e) {
            ErrorView errorView = new ErrorView();
            errorView.setException(e);
            cardView.addItem(errorView);
        }
        items.add(cardView);
    }
}
Also used : CustomControlException(com.moro.mtweaks.utils.tools.customcontrols.CustomControlException) SwitchView(com.moro.mtweaks.views.recyclerview.SwitchView) CardView(com.moro.mtweaks.views.recyclerview.CardView) SeekBarView(com.moro.mtweaks.views.recyclerview.SeekBarView) GenericSelectView(com.moro.mtweaks.views.recyclerview.GenericSelectView) Controls(com.moro.mtweaks.database.tools.customcontrols.Controls) ErrorView(com.moro.mtweaks.views.recyclerview.customcontrols.ErrorView)

Aggregations

GenericSelectView (com.moro.mtweaks.views.recyclerview.GenericSelectView)5 GammaProfiles (com.moro.mtweaks.utils.kernel.screen.GammaProfiles)3 DropDownView (com.moro.mtweaks.views.recyclerview.DropDownView)3 ArrayList (java.util.ArrayList)3 CardView (com.moro.mtweaks.views.recyclerview.CardView)2 Controls (com.moro.mtweaks.database.tools.customcontrols.Controls)1 CustomControlException (com.moro.mtweaks.utils.tools.customcontrols.CustomControlException)1 DescriptionView (com.moro.mtweaks.views.recyclerview.DescriptionView)1 SeekBarView (com.moro.mtweaks.views.recyclerview.SeekBarView)1 SelectView (com.moro.mtweaks.views.recyclerview.SelectView)1 SwitchView (com.moro.mtweaks.views.recyclerview.SwitchView)1 ErrorView (com.moro.mtweaks.views.recyclerview.customcontrols.ErrorView)1