Search in sources :

Example 21 with CardView

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

the class DeviceFragment method addItems.

@Override
protected void addItems(List<RecyclerViewItem> items) {
    String[][] deviceInfos = { { getString(R.string.android_version), Device.getVersion() }, { getString(R.string.android_api_level), String.valueOf(Device.getSDK()) }, { getString(R.string.android_codename), Device.getCodename() }, { getString(R.string.fingerprint), Device.getFingerprint() }, { getString(R.string.build_display_id), Device.getBuildDisplayId() }, { getString(R.string.baseband), Device.getBaseBand() }, { getString(R.string.bootloader), Device.getBootloader() }, { getString(R.string.rom), Device.ROMInfo.getVersion() }, { getString(R.string.trustzone), Device.TrustZone.getVersion() }, { getString(R.string.asv), Device.getAsv() } };
    String[][] boardInfos = { { getString(R.string.hardware), Device.getHardware() }, { getString(R.string.architecture), Device.getArchitecture() }, { getString(R.string.kernel), Device.getKernelVersion(true) } };
    CardView deviceCard = new CardView(getActivity());
    String vendor = Device.getVendor();
    vendor = vendor.substring(0, 1).toUpperCase() + vendor.substring(1);
    deviceCard.setTitle(vendor + " " + Device.getModel());
    CardView boardCard = new CardView(getActivity());
    boardCard.setTitle(Device.getBoard().toUpperCase());
    for (String[] deviceInfo : deviceInfos) {
        if (deviceInfo[1] != null && deviceInfo[1].isEmpty()) {
            continue;
        }
        DescriptionView info = new DescriptionView();
        info.setTitle(deviceInfo[0]);
        info.setSummary(deviceInfo[1]);
        deviceCard.addItem(info);
    }
    for (String[] boardInfo : boardInfos) {
        if (boardInfo[1] != null && boardInfo[1].isEmpty()) {
            continue;
        }
        DescriptionView info = new DescriptionView();
        info.setTitle(boardInfo[0]);
        info.setSummary(boardInfo[1]);
        boardCard.addItem(info);
    }
    items.add(deviceCard);
    items.add(boardCard);
}
Also used : DescriptionView(com.moro.mtweaks.views.recyclerview.DescriptionView) CardView(com.moro.mtweaks.views.recyclerview.CardView)

Example 22 with CardView

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

the class OverallFragment method frequenciesInit.

private void frequenciesInit(List<RecyclerViewItem> items) {
    FrequencyButtonView frequencyButtonView = new FrequencyButtonView();
    frequencyButtonView.setRefreshListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            updateFrequency();
        }
    });
    frequencyButtonView.setResetListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            CpuStateMonitor cpuStateMonitor = mCpuSpyBig.getCpuStateMonitor();
            CpuStateMonitor cpuStateMonitorLITTLE = null;
            if (mCpuSpyLITTLE != null) {
                cpuStateMonitorLITTLE = mCpuSpyLITTLE.getCpuStateMonitor();
            }
            try {
                cpuStateMonitor.setOffsets();
                if (cpuStateMonitorLITTLE != null) {
                    cpuStateMonitorLITTLE.setOffsets();
                }
            } catch (CpuStateMonitor.CpuStateMonitorException ignored) {
            }
            mCpuSpyBig.saveOffsets(getActivity());
            if (mCpuSpyLITTLE != null) {
                mCpuSpyLITTLE.saveOffsets(getActivity());
            }
            updateView(cpuStateMonitor, mFreqBig);
            if (cpuStateMonitorLITTLE != null) {
                updateView(cpuStateMonitorLITTLE, mFreqLITTLE);
            }
            adjustScrollPosition();
        }
    });
    frequencyButtonView.setRestoreListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            CpuStateMonitor cpuStateMonitor = mCpuSpyBig.getCpuStateMonitor();
            CpuStateMonitor cpuStateMonitorLITTLE = null;
            if (mCpuSpyLITTLE != null) {
                cpuStateMonitorLITTLE = mCpuSpyLITTLE.getCpuStateMonitor();
            }
            cpuStateMonitor.removeOffsets();
            if (cpuStateMonitorLITTLE != null) {
                cpuStateMonitorLITTLE.removeOffsets();
            }
            mCpuSpyBig.saveOffsets(getActivity());
            if (mCpuSpyLITTLE != null) {
                mCpuSpyLITTLE.saveOffsets(getActivity());
            }
            updateView(cpuStateMonitor, mFreqBig);
            if (mCpuSpyLITTLE != null) {
                updateView(cpuStateMonitorLITTLE, mFreqLITTLE);
            }
            adjustScrollPosition();
        }
    });
    items.add(frequencyButtonView);
    mFreqBig = new CardView(getActivity());
    if (CPUFreq.isBigLITTLE()) {
        mFreqBig.setTitle(getString(R.string.cluster_big));
    } else {
        mFreqBig.setFullSpan(true);
    }
    items.add(mFreqBig);
    if (CPUFreq.isBigLITTLE()) {
        mFreqLITTLE = new CardView(getActivity());
        mFreqLITTLE.setTitle(getString(R.string.cluster_little));
        items.add(mFreqLITTLE);
    }
    mCpuSpyBig = new CpuSpyApp(CPUFreq.getBigCpu(), getActivity());
    if (CPUFreq.isBigLITTLE()) {
        mCpuSpyLITTLE = new CpuSpyApp(CPUFreq.getLITTLECpu(), getActivity());
    }
    updateFrequency();
}
Also used : FrequencyButtonView(com.moro.mtweaks.views.recyclerview.overallstatistics.FrequencyButtonView) CpuStateMonitor(com.bvalosek.cpuspy.CpuStateMonitor) CpuSpyApp(com.bvalosek.cpuspy.CpuSpyApp) CardView(com.moro.mtweaks.views.recyclerview.CardView) CardView(com.moro.mtweaks.views.recyclerview.CardView) View(android.view.View) TemperatureView(com.moro.mtweaks.views.recyclerview.overallstatistics.TemperatureView) DescriptionView(com.moro.mtweaks.views.recyclerview.DescriptionView) StatsView(com.moro.mtweaks.views.recyclerview.StatsView) FrequencyButtonView(com.moro.mtweaks.views.recyclerview.overallstatistics.FrequencyButtonView) TextView(android.widget.TextView) FrequencyTableView(com.moro.mtweaks.views.recyclerview.overallstatistics.FrequencyTableView)

Example 23 with CardView

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

the class InitdFragment method load.

private void load(List<RecyclerViewItem> items) {
    for (final String initd : Initd.list()) {
        CardView cardView = new CardView(getActivity());
        cardView.setOnMenuListener(new CardView.OnMenuListener() {

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

                    @Override
                    public boolean onMenuItemClick(MenuItem item) {
                        switch(item.getItemId()) {
                            case 0:
                                mEditInitd = initd;
                                Intent intent = new Intent(getActivity(), EditorActivity.class);
                                intent.putExtra(EditorActivity.TITLE_INTENT, initd);
                                intent.putExtra(EditorActivity.TEXT_INTENT, Initd.read(initd));
                                startActivityForResult(intent, 0);
                                break;
                            case 1:
                                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) {
                                        Initd.delete(initd);
                                        reload();
                                    }
                                }, new DialogInterface.OnDismissListener() {

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

            @Override
            public void onClick(RecyclerViewItem item) {
                mExecuteDialog = ViewUtils.dialogBuilder(getString(R.string.exceute_question, initd), new DialogInterface.OnClickListener() {

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

                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        execute(initd);
                    }
                }, new DialogInterface.OnDismissListener() {

                    @Override
                    public void onDismiss(DialogInterface dialogInterface) {
                        mExecuteDialog = null;
                    }
                }, getActivity());
                mExecuteDialog.show();
            }
        });
        cardView.addItem(descriptionView);
        items.add(cardView);
    }
}
Also used : DialogInterface(android.content.DialogInterface) CardView(com.moro.mtweaks.views.recyclerview.CardView) MenuItem(android.view.MenuItem) Intent(android.content.Intent) RecyclerViewItem(com.moro.mtweaks.views.recyclerview.RecyclerViewItem) DescriptionView(com.moro.mtweaks.views.recyclerview.DescriptionView) Menu(android.view.Menu) PopupMenu(android.support.v7.widget.PopupMenu) PopupMenu(android.support.v7.widget.PopupMenu)

Example 24 with CardView

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

the class CustomControlsFragment method getCard.

private CardView getCard(final Controls.ControlItem controlItem) {
    CardView cardView = new CardView(getActivity());
    cardView.setOnMenuListener(new CardView.OnMenuListener() {

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

                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    switch(item.getItemId()) {
                        case 0:
                            edit(controlItem);
                            break;
                        case 1:
                            onBoot.setChecked(!onBoot.isChecked());
                            controlItem.enableOnBoot(onBoot.isChecked());
                            mControlsProvider.commit();
                            break;
                        case 2:
                            mExportItem = controlItem;
                            requestPermission(0, Manifest.permission.WRITE_EXTERNAL_STORAGE);
                            break;
                        case 3:
                            mDeleteDialog = ViewUtils.dialogBuilder(getString(R.string.sure_question), new DialogInterface.OnClickListener() {

                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                }
                            }, new DialogInterface.OnClickListener() {

                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    delete(controlItem.getUniqueId());
                                }
                            }, new DialogInterface.OnDismissListener() {

                                @Override
                                public void onDismiss(DialogInterface dialog) {
                                    mDeleteDialog = null;
                                }
                            }, getActivity()).setTitle(getString(R.string.delete));
                            mDeleteDialog.show();
                            break;
                    }
                    return false;
                }
            });
        }
    });
    return cardView;
}
Also used : DialogInterface(android.content.DialogInterface) CardView(com.moro.mtweaks.views.recyclerview.CardView) MenuItem(android.view.MenuItem) Menu(android.view.Menu) PopupMenu(android.support.v7.widget.PopupMenu) PopupMenu(android.support.v7.widget.PopupMenu)

Example 25 with CardView

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

the class KSMFragment method addItems.

@Override
protected void addItems(List<RecyclerViewItem> items) {
    infoInit(items);
    CardView ksm = new CardView(getActivity());
    if (KSM.isUKSM()) {
        ksm.setTitle(getString(R.string.uksm_name));
    } else {
        ksm.setTitle(getString(R.string.ksm));
    }
    ksm.setFullSpan(true);
    if (KSM.hasEnable()) {
        SwitchView enable = new SwitchView();
        if (KSM.isUKSM()) {
            enable.setTitle(getString(R.string.uksm_name));
        } else {
            enable.setTitle(getString(R.string.ksm));
        }
        enable.setSummary(getString(R.string.ksm_summary));
        enable.setChecked(KSM.isEnabled());
        enable.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                KSM.enableKsm(isChecked, getActivity());
            }
        });
        ksm.addItem(enable);
    }
    if (KSM.hasCpuGovernor()) {
        SelectView governor = new SelectView();
        governor.setTitle(getString(R.string.uksm_governor));
        governor.setSummary(getString(R.string.uksm_governor_summary));
        governor.setItems(KSM.getCpuGovernors());
        governor.setItem(KSM.getCpuGovernor());
        governor.setOnItemSelected(new SelectView.OnItemSelected() {

            @Override
            public void onItemSelected(SelectView selectView, int position, String item) {
                KSM.setCpuGovernor(item, getActivity());
            }
        });
        ksm.addItem(governor);
    }
    if (KSM.hasDeferredTimer()) {
        SwitchView deferredTimer = new SwitchView();
        deferredTimer.setTitle(getString(R.string.deferred_timer));
        deferredTimer.setSummary(getString(R.string.deferred_timer_summary));
        deferredTimer.setChecked(KSM.isDeferredTimerEnabled());
        deferredTimer.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                KSM.enableDeferredTimer(isChecked, getActivity());
            }
        });
        ksm.addItem(deferredTimer);
    }
    if (KSM.hasPagesToScan()) {
        SeekBarView pagesToScan = new SeekBarView();
        pagesToScan.setTitle(getString(R.string.pages_to_scan));
        pagesToScan.setMax(1024);
        pagesToScan.setProgress(KSM.getPagesToScan());
        pagesToScan.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                KSM.setPagesToScan(position, getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        ksm.addItem(pagesToScan);
    }
    if (KSM.hasSleepMilliseconds()) {
        SeekBarView sleepMilliseconds = new SeekBarView();
        sleepMilliseconds.setTitle(getString(R.string.sleep_milliseconds));
        sleepMilliseconds.setUnit(getString(R.string.ms));
        sleepMilliseconds.setMax(5000);
        sleepMilliseconds.setOffset(50);
        sleepMilliseconds.setProgress(KSM.getSleepMilliseconds() / 50);
        sleepMilliseconds.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                KSM.setSleepMilliseconds(position * 50, getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        ksm.addItem(sleepMilliseconds);
    }
    if (KSM.hasMaxCpuPercentage()) {
        SeekBarView maxCpuPercentage = new SeekBarView();
        maxCpuPercentage.setTitle(getString(R.string.max_cpu_usage));
        maxCpuPercentage.setSummary(getString(R.string.max_cpu_usage_summary));
        maxCpuPercentage.setUnit("%");
        maxCpuPercentage.setProgress(KSM.getMaxCpuPercentage());
        maxCpuPercentage.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                KSM.setMaxCpuPercentage(position, getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        ksm.addItem(maxCpuPercentage);
    }
    if (ksm.size() > 0) {
        items.add(ksm);
    }
}
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)

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