Search in sources :

Example 11 with DescriptionView

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

the class InputsFragment method addItems.

@Override
protected void addItems(List<RecyclerViewItem> items) {
    List<Device.Input.Item> inputs = Device.Input.getItems();
    for (Device.Input.Item input : inputs) {
        String name;
        if ((name = input.getName()) != null) {
            String[][] list = { { getString(R.string.bus), input.getBus() }, { getString(R.string.vendor), input.getVendor() }, { getString(R.string.product), input.getProduct() }, { getString(R.string.version), input.getVersion() }, { getString(R.string.sysfs), input.getSysfs() }, { getString(R.string.handlers), input.getHandlers() } };
            List<RecyclerViewItem> inputItems = new ArrayList<>();
            for (String[] inputsList : list) {
                if (inputsList[1] != null) {
                    DescriptionView inputView = new DescriptionView();
                    inputView.setTitle(inputsList[0]);
                    inputView.setSummary(inputsList[1]);
                    inputItems.add(inputView);
                }
            }
            if (inputItems.size() > 0) {
                TitleView inputTile = new TitleView();
                inputTile.setText(name);
                items.add(inputTile);
                items.addAll(inputItems);
            }
        }
    }
}
Also used : Device(com.moro.mtweaks.utils.Device) ArrayList(java.util.ArrayList) RecyclerViewItem(com.moro.mtweaks.views.recyclerview.RecyclerViewItem) RecyclerViewItem(com.moro.mtweaks.views.recyclerview.RecyclerViewItem) DescriptionView(com.moro.mtweaks.views.recyclerview.DescriptionView) TitleView(com.moro.mtweaks.views.recyclerview.TitleView)

Example 12 with DescriptionView

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

the class MemoryFragment method addItems.

@Override
protected void addItems(List<RecyclerViewItem> items) {
    List<String> mems = Device.MemInfo.getItems();
    for (String mem : mems) {
        DescriptionView memView = new DescriptionView();
        memView.setTitle(mem);
        memView.setSummary(Device.MemInfo.getItem(mem).replace(" ", "").replace("kB", getString(R.string.kb)));
        items.add(memView);
    }
}
Also used : DescriptionView(com.moro.mtweaks.views.recyclerview.DescriptionView)

Example 13 with DescriptionView

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

the class OverallFragment method updateView.

private void updateView(CpuStateMonitor monitor, CardView card) {
    if (!isAdded() || card == null)
        return;
    card.clearItems();
    // update the total state time
    DescriptionView totalTime = new DescriptionView();
    totalTime.setTitle(getString(R.string.uptime));
    totalTime.setSummary(sToString(monitor.getTotalStateTime() / 100L));
    card.addItem(totalTime);
    /**
     * Get the CpuStateMonitor from the app, and iterate over all states,
     * creating a row if the duration is > 0 or otherwise marking it in
     * extraStates (missing)
     */
    List<String> extraStates = new ArrayList<>();
    for (CpuStateMonitor.CpuState state : monitor.getStates()) {
        if (state.getDuration() > 0) {
            generateStateRow(monitor, state, card);
        } else {
            if (state.getFreq() == 0) {
                extraStates.add(getString(R.string.deep_sleep));
            } else {
                extraStates.add(state.getFreq() / 1000 + getString(R.string.mhz));
            }
        }
    }
    if (monitor.getStates().size() == 0) {
        card.clearItems();
        DescriptionView errorView = new DescriptionView();
        errorView.setTitle(getString(R.string.error_frequencies));
        card.addItem(errorView);
        return;
    }
    // for all the 0 duration states, add the the Unused State area
    if (extraStates.size() > 0) {
        int n = 0;
        String str = "";
        for (String s : extraStates) {
            if (n++ > 0)
                str += ", ";
            str += s;
        }
        DescriptionView unusedText = new DescriptionView();
        unusedText.setTitle(getString(R.string.unused_frequencies));
        unusedText.setSummary(str);
        card.addItem(unusedText);
    }
}
Also used : DescriptionView(com.moro.mtweaks.views.recyclerview.DescriptionView) CpuStateMonitor(com.bvalosek.cpuspy.CpuStateMonitor) ArrayList(java.util.ArrayList)

Example 14 with DescriptionView

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

the class BuildpropFragment method load.

private void load(final List<RecyclerViewItem> items) {
    if (mProps == null)
        return;
    String[] titles = mProps.keySet().toArray(new String[mProps.size()]);
    for (int i = 0; i < mProps.size(); i++) {
        final String title = titles[i];
        final String value = mProps.values().toArray(new String[mProps.size()])[i];
        if ((mKeyText != null && !title.contains(mKeyText) || (mValueText != null && !value.contains(mValueText)))) {
            continue;
        }
        int color = ViewUtils.getThemeAccentColor(getActivity());
        String colorCode = "#" + Integer.toHexString(Color.red(color)) + Integer.toHexString(Color.green(color)) + Integer.toHexString(Color.blue(color));
        DescriptionView descriptionView = new DescriptionView();
        if (mKeyText != null && !mKeyText.isEmpty()) {
            descriptionView.setTitle(Utils.htmlFrom(title.replace(mKeyText, "<b><font color=\"" + colorCode + "\">" + mKeyText + "</font></b>")));
        } else {
            descriptionView.setTitle(title);
        }
        if (mValueText != null && !mValueText.isEmpty()) {
            descriptionView.setSummary(Utils.htmlFrom(value.replace(mValueText, "<b><font color=\"" + colorCode + "\">" + mKeyText + "</font></b>")));
        } else {
            descriptionView.setSummary(value);
        }
        descriptionView.setOnItemClickListener(new RecyclerViewItem.OnItemClickListener() {

            @Override
            public void onClick(RecyclerViewItem item) {
                mItemOptionsDialog = new Dialog(getActivity()).setItems(getResources().getStringArray(R.array.build_prop_item_options), new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        switch(i) {
                            case 0:
                                modify(title, value);
                                break;
                            case 1:
                                delete(title, value);
                                break;
                        }
                    }
                }).setOnDismissListener(new DialogInterface.OnDismissListener() {

                    @Override
                    public void onDismiss(DialogInterface dialogInterface) {
                        mItemOptionsDialog = null;
                    }
                });
                mItemOptionsDialog.show();
            }
        });
        items.add(descriptionView);
    }
    Activity activity;
    if (mSearchFragment != null && (activity = getActivity()) != null) {
        activity.runOnUiThread(new Runnable() {

            @Override
            public void run() {
                if (isAdded()) {
                    mSearchFragment.setCount(items.size());
                }
            }
        });
    }
}
Also used : DialogInterface(android.content.DialogInterface) Activity(android.app.Activity) RecyclerViewItem(com.moro.mtweaks.views.recyclerview.RecyclerViewItem) Dialog(com.moro.mtweaks.views.dialog.Dialog) DescriptionView(com.moro.mtweaks.views.recyclerview.DescriptionView)

Example 15 with DescriptionView

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

Aggregations

DescriptionView (com.moro.mtweaks.views.recyclerview.DescriptionView)26 RecyclerViewItem (com.moro.mtweaks.views.recyclerview.RecyclerViewItem)16 CardView (com.moro.mtweaks.views.recyclerview.CardView)12 TitleView (com.moro.mtweaks.views.recyclerview.TitleView)7 ArrayList (java.util.ArrayList)6 DialogInterface (android.content.DialogInterface)5 SelectView (com.moro.mtweaks.views.recyclerview.SelectView)5 SeekBarView (com.moro.mtweaks.views.recyclerview.SeekBarView)4 SwitchView (com.moro.mtweaks.views.recyclerview.SwitchView)4 PopupMenu (android.support.v7.widget.PopupMenu)3 MenuItem (android.view.MenuItem)3 Intent (android.content.Intent)2 Menu (android.view.Menu)2 Profiles (com.moro.mtweaks.database.tools.profiles.Profiles)2 RootFile (com.moro.mtweaks.utils.root.RootFile)2 Dialog (com.moro.mtweaks.views.dialog.Dialog)2 File (java.io.File)2 Activity (android.app.Activity)1 ProgressDialog (android.app.ProgressDialog)1 AppWidgetManager (android.appwidget.AppWidgetManager)1