Search in sources :

Example 31 with CardView

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

the class VMFragment method vmTunablesInit.

private void vmTunablesInit(List<RecyclerViewItem> items) {
    final CardView CardVm = new CardView(getActivity());
    CardVm.setTitle(getString(R.string.vm_tunables));
    CardVmTunablesInit(CardVm);
    if (CardVm.size() > 0) {
        items.add(CardVm);
    }
}
Also used : CardView(com.moro.mtweaks.views.recyclerview.CardView)

Example 32 with CardView

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

the class VMFragment method zramInit.

private void zramInit(List<RecyclerViewItem> items) {
    CardView zramCard = new CardView(getActivity());
    zramCard.setTitle(getString(R.string.zram));
    SeekBarView zram = new SeekBarView();
    zram.setTitle(getString(R.string.disksize));
    zram.setSummary(getString(R.string.disksize_summary));
    zram.setUnit(getString(R.string.mb));
    zram.setMax(2048);
    zram.setOffset(10);
    zram.setProgress(ZRAM.getDisksize() / 10);
    zram.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

        @Override
        public void onStop(SeekBarView seekBarView, int position, String value) {
            ZRAM.setDisksize(position * 10, getActivity());
        }

        @Override
        public void onMove(SeekBarView seekBarView, int position, String value) {
        }
    });
    zramCard.addItem(zram);
    if (zramCard.size() > 0) {
        items.add(zramCard);
    }
}
Also used : CardView(com.moro.mtweaks.views.recyclerview.CardView) SeekBarView(com.moro.mtweaks.views.recyclerview.SeekBarView)

Example 33 with CardView

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

the class ProfileFragment method load.

private void load(List<RecyclerViewItem> items) {
    mProfiles = new Profiles(getActivity());
    List<Profiles.ProfileItem> profileItems = mProfiles.getAllProfiles();
    if (mTaskerMode && profileItems.size() == 0) {
        Snackbar.make(getRootView(), R.string.no_profiles, Snackbar.LENGTH_LONG).show();
        return;
    }
    for (int i = 0; i < profileItems.size(); i++) {
        final int position = i;
        final CardView cardView = new CardView(getActivity());
        cardView.setOnMenuListener(new CardView.OnMenuListener() {

            @Override
            public void onMenuReady(final CardView cardView, PopupMenu popupMenu) {
                Menu menu = popupMenu.getMenu();
                menu.add(Menu.NONE, 0, Menu.NONE, getString(R.string.append));
                menu.add(Menu.NONE, 1, Menu.NONE, getString(R.string.edit));
                menu.add(Menu.NONE, 2, Menu.NONE, getString(R.string.details));
                final MenuItem onBoot = menu.add(Menu.NONE, 3, Menu.NONE, getString(R.string.on_boot)).setCheckable(true);
                onBoot.setChecked(mProfiles.getAllProfiles().get(position).isOnBootEnabled());
                menu.add(Menu.NONE, 4, Menu.NONE, getString(R.string.export));
                menu.add(Menu.NONE, 5, Menu.NONE, getString(R.string.delete));
                popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

                    @Override
                    public boolean onMenuItemClick(MenuItem item) {
                        List<Profiles.ProfileItem> items = mProfiles.getAllProfiles();
                        switch(item.getItemId()) {
                            case 0:
                                if (Utils.DONATED) {
                                    Intent intent = new Intent(getActivity(), ProfileActivity.class);
                                    intent.putExtra(ProfileActivity.POSITION_INTENT, position);
                                    startActivityForResult(intent, 2);
                                } else {
                                    mDonateDialog = ViewUtils.dialogDonate(getActivity());
                                    mDonateDialog.show();
                                }
                                break;
                            case 1:
                                if (Utils.DONATED) {
                                    Intent intent = new Intent(getActivity(), ProfileEditActivity.class);
                                    intent.putExtra(ProfileEditActivity.POSITION_INTENT, position);
                                    startActivityForResult(intent, 3);
                                } else {
                                    mDonateDialog = ViewUtils.dialogDonate(getActivity());
                                    mDonateDialog.show();
                                }
                                break;
                            case 2:
                                if (items.get(position).getName() != null) {
                                    List<Profiles.ProfileItem.CommandItem> commands = items.get(position).getCommands();
                                    if (commands.size() > 0) {
                                        setForegroundText(items.get(position).getName().toUpperCase());
                                        mDetailsFragment.setText(commands);
                                        showForeground();
                                    } else {
                                        Utils.toast(R.string.profile_empty, getActivity());
                                    }
                                }
                                break;
                            case 3:
                                onBoot.setChecked(!onBoot.isChecked());
                                items.get(position).enableOnBoot(onBoot.isChecked());
                                mProfiles.commit();
                                break;
                            case 4:
                                mExportProfile = items.get(position);
                                requestPermission(0, Manifest.permission.WRITE_EXTERNAL_STORAGE);
                                break;
                            case 5:
                                mDeleteDialog = ViewUtils.dialogBuilder(getString(R.string.sure_question), new DialogInterface.OnClickListener() {

                                    @Override
                                    public void onClick(DialogInterface dialogInterface, int i) {
                                    }
                                }, new DialogInterface.OnClickListener() {

                                    @Override
                                    public void onClick(DialogInterface dialogInterface, int i) {
                                        mProfiles.delete(position);
                                        mProfiles.commit();
                                        reload();
                                    }
                                }, new DialogInterface.OnDismissListener() {

                                    @Override
                                    public void onDismiss(DialogInterface dialogInterface) {
                                        mDeleteDialog = null;
                                    }
                                }, getActivity());
                                mDeleteDialog.show();
                                break;
                        }
                        return false;
                    }
                });
            }
        });
        final DescriptionView descriptionView = new DescriptionView();
        descriptionView.setSummary(profileItems.get(i).getName());
        descriptionView.setOnItemClickListener(new RecyclerViewItem.OnItemClickListener() {

            @Override
            public void onClick(RecyclerViewItem item) {
                if (mTaskerMode) {
                    mSelectDialog = ViewUtils.dialogBuilder(getString(R.string.select_question, descriptionView.getSummary()), new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                        }
                    }, new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            ((ProfileTaskerActivity) getActivity()).finish(descriptionView.getSummary().toString(), mProfiles.getAllProfiles().get(position).getCommands());
                        }
                    }, new DialogInterface.OnDismissListener() {

                        @Override
                        public void onDismiss(DialogInterface dialogInterface) {
                            mSelectDialog = null;
                        }
                    }, getActivity());
                    mSelectDialog.show();
                } else {
                    mApplyDialog = ViewUtils.dialogBuilder(getString(R.string.apply_question, descriptionView.getSummary()), new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                        }
                    }, new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            for (Profiles.ProfileItem.CommandItem command : mProfiles.getAllProfiles().get(position).getCommands()) {
                                CPUFreq.ApplyCpu applyCpu;
                                if (command.getCommand().startsWith("#") && ((applyCpu = new CPUFreq.ApplyCpu(command.getCommand().substring(1))).toString() != null)) {
                                    for (String applyCpuCommand : ApplyOnBoot.getApplyCpu(applyCpu, RootUtils.getSU())) {
                                        Control.runSetting(applyCpuCommand, null, null, null);
                                    }
                                } else {
                                    Control.runSetting(command.getCommand(), null, null, null);
                                }
                            }
                        }
                    }, new DialogInterface.OnDismissListener() {

                        @Override
                        public void onDismiss(DialogInterface dialogInterface) {
                            mApplyDialog = null;
                        }
                    }, getActivity());
                    try {
                        mApplyDialog.show();
                    } catch (NullPointerException ignored) {
                    }
                }
            }
        });
        if (mTaskerMode) {
            items.add(descriptionView);
        } else {
            cardView.addItem(descriptionView);
            items.add(cardView);
        }
    }
    if (!mTaskerMode) {
        AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(getActivity());
        int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(getActivity(), Widget.class));
        appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.profile_list);
        Tile.publishProfileTile(profileItems, getActivity());
    }
}
Also used : DialogInterface(android.content.DialogInterface) Widget(com.moro.mtweaks.services.profile.Widget) Profiles(com.moro.mtweaks.database.tools.profiles.Profiles) ComponentName(android.content.ComponentName) PopupMenu(android.support.v7.widget.PopupMenu) Menu(android.view.Menu) CardView(com.moro.mtweaks.views.recyclerview.CardView) AppWidgetManager(android.appwidget.AppWidgetManager) MenuItem(android.view.MenuItem) Intent(android.content.Intent) RecyclerViewItem(com.moro.mtweaks.views.recyclerview.RecyclerViewItem) CPUFreq(com.moro.mtweaks.utils.kernel.cpu.CPUFreq) DescriptionView(com.moro.mtweaks.views.recyclerview.DescriptionView) PopupMenu(android.support.v7.widget.PopupMenu)

Example 34 with CardView

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

the class RecoveryFragment method addAction.

private void addAction(Recovery.RECOVERY_COMMAND recovery_command, String path) {
    String summary = null;
    switch(recovery_command) {
        case WIPE_DATA:
            summary = getString(R.string.wipe_data);
            break;
        case WIPE_CACHE:
            summary = getString(R.string.wipe_cache);
            break;
        case FLASH_ZIP:
            summary = new File(path).getName();
            break;
    }
    final Recovery recovery = new Recovery(recovery_command, path == null ? null : new File(path));
    mCommands.add(recovery);
    CardView cardView = new CardView(getActivity());
    cardView.setOnMenuListener(new CardView.OnMenuListener() {

        @Override
        public void onMenuReady(final CardView cardView, PopupMenu popupMenu) {
            popupMenu.getMenu().add(Menu.NONE, 0, Menu.NONE, getString(R.string.delete));
            popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    if (item.getItemId() == 0) {
                        mCommands.remove(recovery);
                        removeItem(cardView);
                    }
                    return false;
                }
            });
        }
    });
    DescriptionView descriptionView = new DescriptionView();
    if (path != null) {
        descriptionView.setTitle(getString(R.string.flash_zip));
    }
    descriptionView.setSummary(summary);
    cardView.addItem(descriptionView);
    addItem(cardView);
}
Also used : DescriptionView(com.moro.mtweaks.views.recyclerview.DescriptionView) CardView(com.moro.mtweaks.views.recyclerview.CardView) MenuItem(android.view.MenuItem) RootFile(com.moro.mtweaks.utils.root.RootFile) File(java.io.File) Recovery(com.moro.mtweaks.utils.tools.Recovery) PopupMenu(android.support.v7.widget.PopupMenu)

Example 35 with CardView

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

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