Search in sources :

Example 1 with Profiles

use of com.moro.mtweaks.database.tools.profiles.Profiles in project MTweaks-KernelAdiutorMOD by morogoku.

the class OnBootFragment method load.

private void load(List<RecyclerViewItem> items) {
    List<RecyclerViewItem> applyOnBoot = new ArrayList<>();
    TitleView applyOnBootTitle = new TitleView();
    applyOnBootTitle.setText(getString(R.string.apply_on_boot));
    List<Settings.SettingsItem> settings = mSettings.getAllSettings();
    HashMap<String, Boolean> applyOnBootEnabled = new HashMap<>();
    List<ApplyOnBootItem> applyOnBootItems = new ArrayList<>();
    for (int i = 0; i < settings.size(); i++) {
        if (!applyOnBootEnabled.containsKey(settings.get(i).getCategory())) {
            applyOnBootEnabled.put(settings.get(i).getCategory(), Prefs.getBoolean(settings.get(i).getCategory(), false, getActivity()));
        }
        if (applyOnBootEnabled.get(settings.get(i).getCategory())) {
            applyOnBootItems.add(new ApplyOnBootItem(settings.get(i).getSetting(), settings.get(i).getCategory(), i));
        }
    }
    for (int i = 0; i < applyOnBootItems.size(); i++) {
        final ApplyOnBootItem applyOnBootItem = applyOnBootItems.get(i);
        DescriptionView applyOnBootView = new DescriptionView();
        applyOnBootView.setSummary((i + 1) + ". " + applyOnBootItem.mCategory.replace("_onboot", "") + ": " + applyOnBootItem.mCommand);
        applyOnBootView.setOnItemClickListener(new RecyclerViewItem.OnItemClickListener() {

            @Override
            public void onClick(RecyclerViewItem item) {
                mDeleteDialog = ViewUtils.dialogBuilder(getString(R.string.delete_question, applyOnBootItem.mCommand), new DialogInterface.OnClickListener() {

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

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

                    @Override
                    public void onDismiss(DialogInterface dialogInterface) {
                        mDeleteDialog = null;
                    }
                }, getActivity());
                mDeleteDialog.show();
            }
        });
        applyOnBoot.add(applyOnBootView);
    }
    if (applyOnBoot.size() > 0) {
        items.add(applyOnBootTitle);
        items.addAll(applyOnBoot);
    }
    List<RecyclerViewItem> customControls = new ArrayList<>();
    TitleView customControlTitle = new TitleView();
    customControlTitle.setText(getString(R.string.custom_controls));
    for (final Controls.ControlItem controlItem : mControls.getAllControls()) {
        if (controlItem.isOnBootEnabled() && controlItem.getArguments() != null) {
            DescriptionView controlView = new DescriptionView();
            controlView.setTitle(controlItem.getTitle());
            controlView.setSummary(getString(R.string.arguments, controlItem.getArguments()));
            controlView.setOnItemClickListener(new RecyclerViewItem.OnItemClickListener() {

                @Override
                public void onClick(RecyclerViewItem item) {
                    mDeleteDialog = ViewUtils.dialogBuilder(getString(R.string.disable_question, controlItem.getTitle()), new DialogInterface.OnClickListener() {

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

                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            controlItem.enableOnBoot(false);
                            mControls.commit();
                            reload();
                        }
                    }, new DialogInterface.OnDismissListener() {

                        @Override
                        public void onDismiss(DialogInterface dialogInterface) {
                            mDeleteDialog = null;
                        }
                    }, getActivity());
                    mDeleteDialog.show();
                }
            });
            customControls.add(controlView);
        }
    }
    if (customControls.size() > 0) {
        items.add(customControlTitle);
        items.addAll(customControls);
    }
    List<RecyclerViewItem> profiles = new ArrayList<>();
    TitleView profileTitle = new TitleView();
    profileTitle.setText(getString(R.string.profile));
    for (final Profiles.ProfileItem profileItem : mProfiles.getAllProfiles()) {
        if (profileItem.isOnBootEnabled()) {
            DescriptionView profileView = new DescriptionView();
            profileView.setSummary(profileItem.getName());
            profileView.setOnItemClickListener(new RecyclerViewItem.OnItemClickListener() {

                @Override
                public void onClick(RecyclerViewItem item) {
                    mDeleteDialog = ViewUtils.dialogBuilder(getString(R.string.disable_question, profileItem.getName()), new DialogInterface.OnClickListener() {

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

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

                        @Override
                        public void onDismiss(DialogInterface dialogInterface) {
                            mDeleteDialog = null;
                        }
                    }, getActivity());
                    mDeleteDialog.show();
                }
            });
            profiles.add(profileView);
        }
    }
    if (profiles.size() > 0) {
        items.add(profileTitle);
        items.addAll(profiles);
    }
    if (Prefs.getBoolean("initd_onboot", false, getActivity())) {
        TitleView initdTitle = new TitleView();
        initdTitle.setText(getString(R.string.initd));
        items.add(initdTitle);
        DescriptionView emulateInitd = new DescriptionView();
        emulateInitd.setSummary(getString(R.string.emulate_initd));
        emulateInitd.setOnItemClickListener(new RecyclerViewItem.OnItemClickListener() {

            @Override
            public void onClick(RecyclerViewItem item) {
                mDeleteDialog = ViewUtils.dialogBuilder(getString(R.string.disable_question, getString(R.string.emulate_initd)), new DialogInterface.OnClickListener() {

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

                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        Prefs.saveBoolean("initd_onboot", false, getActivity());
                        reload();
                    }
                }, new DialogInterface.OnDismissListener() {

                    @Override
                    public void onDismiss(DialogInterface dialogInterface) {
                        mDeleteDialog = null;
                    }
                }, getActivity());
                mDeleteDialog.show();
            }
        });
        items.add(emulateInitd);
    }
}
Also used : HashMap(java.util.HashMap) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) RecyclerViewItem(com.moro.mtweaks.views.recyclerview.RecyclerViewItem) DescriptionView(com.moro.mtweaks.views.recyclerview.DescriptionView) Profiles(com.moro.mtweaks.database.tools.profiles.Profiles) Controls(com.moro.mtweaks.database.tools.customcontrols.Controls) TitleView(com.moro.mtweaks.views.recyclerview.TitleView)

Example 2 with Profiles

use of com.moro.mtweaks.database.tools.profiles.Profiles in project MTweaks-KernelAdiutorMOD by morogoku.

the class OnBootFragment method addItems.

@Override
protected void addItems(List<RecyclerViewItem> items) {
    if (mSettings == null) {
        mSettings = new Settings(getActivity());
    }
    if (mControls == null) {
        mControls = new Controls(getActivity());
    }
    if (mProfiles == null) {
        mProfiles = new Profiles(getActivity());
    }
    if (!mLoaded) {
        mLoaded = true;
        load(items);
    }
}
Also used : Profiles(com.moro.mtweaks.database.tools.profiles.Profiles) Controls(com.moro.mtweaks.database.tools.customcontrols.Controls) Settings(com.moro.mtweaks.database.Settings)

Example 3 with Profiles

use of com.moro.mtweaks.database.tools.profiles.Profiles in project MTweaks-KernelAdiutorMOD by morogoku.

the class ApplyOnBoot method apply.

public static boolean apply(final Context context, final ApplyOnBootListener listener) {
    // Initialize AppUpdate check
    AppUpdaterTask.appCheckNotification(context);
    // Initialize Boeffla Wakelock Blocker Files
    if (BoefflaWakelock.supported()) {
        BoefflaWakelock.CopyWakelockBlockerDefault();
    }
    // Check if kernel is changed
    String kernel_old = Prefs.getString("kernel_version_old", "", context);
    String kernel_new = Device.getKernelVersion(true);
    // If is changed save voltage files
    if (!kernel_old.equals(kernel_new)) {
        // Save backup of Cluster0 stock voltages
        if (VoltageCl0.supported()) {
            RootUtils.runCommand("cp " + VoltageCl0.CL0_VOLTAGE + " " + VoltageCl0.BACKUP);
            Prefs.saveBoolean("cl0_voltage_saved", true, context);
        }
        // Save backup of Cluster1 stock voltages
        if (VoltageCl1.supported()) {
            RootUtils.runCommand("cp " + VoltageCl1.CL1_VOLTAGE + " " + VoltageCl1.BACKUP);
            Prefs.saveBoolean("cl1_voltage_saved", true, context);
        }
        // Save backup of GPU stock voltages
        if (GPUFreq.supported() && GPUFreq.hasVoltage()) {
            RootUtils.runCommand("cp " + GPUFreq.AVAILABLE_VOLTS + " " + GPUFreq.BACKUP);
            Prefs.saveBoolean("gpu_voltage_saved", true, context);
        }
        RootUtils.runCommand("setprop mtweaks.voltage_saved 1");
    }
    if (!Prefs.getBoolean(ApplyOnBootFragment.getAssignment(CPUHotplugFragment.class), false, context)) {
        Prefs.remove("core_ctl_min_cpus_big", context);
    }
    boolean enabled = false;
    final Settings settings = new Settings(context);
    Controls controls = new Controls(context);
    final HashMap<String, Boolean> mCategoryEnabled = new HashMap<>();
    final HashMap<String, String> mCustomControls = new HashMap<>();
    final List<String> mProfiles = new ArrayList<>();
    List<Profiles.ProfileItem> profiles = new Profiles(context).getAllProfiles();
    Tile.publishProfileTile(profiles, context);
    for (Settings.SettingsItem item : settings.getAllSettings()) {
        if (!mCategoryEnabled.containsKey(item.getCategory())) {
            boolean categoryEnabled = Prefs.getBoolean(item.getCategory(), false, context);
            mCategoryEnabled.put(item.getCategory(), categoryEnabled);
            if (!enabled && categoryEnabled) {
                enabled = true;
            }
        }
    }
    for (Controls.ControlItem item : controls.getAllControls()) {
        if (item.isOnBootEnabled() && item.getArguments() != null) {
            mCustomControls.put(item.getApply(), item.getArguments());
        }
    }
    for (Profiles.ProfileItem profileItem : profiles) {
        if (profileItem.isOnBootEnabled()) {
            for (Profiles.ProfileItem.CommandItem commandItem : profileItem.getCommands()) {
                mProfiles.add(commandItem.getCommand());
            }
        }
    }
    final boolean initdEnabled = Prefs.getBoolean("initd_onboot", false, context);
    enabled = enabled || mCustomControls.size() > 0 || mProfiles.size() > 0 || initdEnabled;
    if (!enabled) {
        return false;
    }
    final int seconds = Utils.strToInt(Prefs.getString("applyonbootdelay", "10", context));
    final boolean hideNotification = Prefs.getBoolean("applyonboothide", false, context);
    final boolean confirmationNotification = Prefs.getBoolean("applyonbootconfirmationnotification", true, context);
    final boolean toast = Prefs.getBoolean("applyonboottoast", false, context);
    final boolean script = Prefs.getBoolean("applyonbootscript", false, context);
    PendingIntent cancelIntent = PendingIntent.getBroadcast(context, 1, new Intent(context, CancelReceiver.class), PendingIntent.FLAG_UPDATE_CURRENT);
    Intent launchIntent = new Intent(context, MainActivity.class);
    PendingIntent contentIntent = PendingIntent.getActivity(context, 0, launchIntent, 0);
    final NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    final NotificationCompat.Builder builder = new NotificationCompat.Builder(context, ApplyOnBootService.CHANNEL_ID);
    if (!hideNotification) {
        builder.setContentTitle(context.getString(R.string.app_name)).setContentText(context.getString(R.string.apply_on_boot_text, seconds)).setSmallIcon(R.mipmap.ic_launcher).addAction(0, context.getString(R.string.cancel), cancelIntent).setOngoing(true).setWhen(0);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            builder.setPriority(Notification.PRIORITY_MAX);
        }
    }
    final NotificationCompat.Builder builderComplete = new NotificationCompat.Builder(context, ApplyOnBootService.CHANNEL_ID);
    if (!hideNotification) {
        builderComplete.setContentTitle(context.getString(R.string.app_name)).setSmallIcon(R.mipmap.ic_launcher).setContentIntent(contentIntent).setAutoCancel(true);
    }
    final Handler handler = new Handler();
    new Thread(new Runnable() {

        @Override
        public void run() {
            sCancel = false;
            for (int i = 0; i < seconds; i++) {
                if (!hideNotification) {
                    if (sCancel) {
                        break;
                    }
                    builder.setContentText(context.getString(R.string.apply_on_boot_text, seconds - i));
                    builder.setProgress(seconds, i, false);
                    notificationManager.notify(NotificationId.APPLY_ON_BOOT, builder.build());
                }
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            if (!hideNotification) {
                notificationManager.cancel(NotificationId.APPLY_ON_BOOT);
                if (confirmationNotification) {
                    builderComplete.setContentText(context.getString(sCancel ? R.string.apply_on_boot_canceled : R.string.apply_on_boot_complete));
                    notificationManager.notify(NotificationId.APPLY_ON_BOOT_CONFIRMATION, builderComplete.build());
                }
                if (sCancel) {
                    sCancel = false;
                    listener.onFinish();
                    return;
                }
            }
            RootUtils.SU su = new RootUtils.SU(true, TAG);
            if (initdEnabled) {
                RootUtils.mount(true, "/system", su);
                su.runCommand("for i in `ls /system/etc/init.d`;do chmod 755 $i;done");
                su.runCommand("[ -d /system/etc/init.d ] && run-parts /system/etc/init.d");
                RootUtils.mount(false, "/system", su);
            }
            List<String> commands = new ArrayList<>();
            for (Settings.SettingsItem item : settings.getAllSettings()) {
                String category = item.getCategory();
                String setting = item.getSetting();
                String id = item.getId();
                CPUFreq.ApplyCpu applyCpu;
                if (mCategoryEnabled.get(category)) {
                    if (category.equals(ApplyOnBootFragment.CPU) && id.contains("%d") && setting.startsWith("#") && ((applyCpu = new CPUFreq.ApplyCpu(setting.substring(1))).toString() != null)) {
                        synchronized (this) {
                            commands.addAll(getApplyCpu(applyCpu, su, context));
                        }
                    } else {
                        commands.add(setting);
                    }
                }
            }
            if (script) {
                StringBuilder s = new StringBuilder("#!/system/bin/sh\n\n");
                for (String command : commands) {
                    s.append(command).append("\n");
                }
                RootFile file = new RootFile("/data/local/tmp/kerneladiutortmp.sh", su);
                file.mkdir();
                file.write(s.toString(), false);
                file.execute();
            } else {
                for (String command : commands) {
                    synchronized (this) {
                        su.runCommand(command);
                    }
                }
            }
            for (String script : mCustomControls.keySet()) {
                RootFile file = new RootFile("/data/local/tmp/kerneladiutortmp.sh", su);
                file.mkdir();
                file.write(script, false);
                file.execute(mCustomControls.get(script));
            }
            List<String> profileCommands = new ArrayList<>();
            for (String command : mProfiles) {
                CPUFreq.ApplyCpu applyCpu;
                if (command.startsWith("#") && ((applyCpu = new CPUFreq.ApplyCpu(command.substring(1))).toString() != null)) {
                    synchronized (this) {
                        profileCommands.addAll(getApplyCpu(applyCpu, su, context));
                    }
                }
                profileCommands.add(command);
            }
            if (script) {
                StringBuilder s = new StringBuilder("#!/system/bin/sh\n\n");
                for (String command : profileCommands) {
                    s.append(command).append("\n");
                }
                RootFile file = new RootFile("/data/local/tmp/kerneladiutortmp.sh", su);
                file.mkdir();
                file.write(s.toString(), false);
                file.execute();
            } else {
                for (String command : profileCommands) {
                    synchronized (this) {
                        su.runCommand(command);
                    }
                }
            }
            su.close();
            if (toast) {
                handler.post(new Runnable() {

                    @Override
                    public void run() {
                        Utils.toast(R.string.apply_on_boot_complete, context);
                    }
                });
            }
            listener.onFinish();
        }
    }).start();
    return true;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Profiles(com.moro.mtweaks.database.tools.profiles.Profiles) Controls(com.moro.mtweaks.database.tools.customcontrols.Controls) NotificationCompat(android.support.v4.app.NotificationCompat) Settings(com.moro.mtweaks.database.Settings) NotificationManager(android.app.NotificationManager) Handler(android.os.Handler) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) CPUFreq(com.moro.mtweaks.utils.kernel.cpu.CPUFreq) RootUtils(com.moro.mtweaks.utils.root.RootUtils) PendingIntent(android.app.PendingIntent) RootFile(com.moro.mtweaks.utils.root.RootFile)

Example 4 with Profiles

use of com.moro.mtweaks.database.tools.profiles.Profiles 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)

Aggregations

Profiles (com.moro.mtweaks.database.tools.profiles.Profiles)4 Controls (com.moro.mtweaks.database.tools.customcontrols.Controls)3 DialogInterface (android.content.DialogInterface)2 Intent (android.content.Intent)2 Settings (com.moro.mtweaks.database.Settings)2 CPUFreq (com.moro.mtweaks.utils.kernel.cpu.CPUFreq)2 DescriptionView (com.moro.mtweaks.views.recyclerview.DescriptionView)2 RecyclerViewItem (com.moro.mtweaks.views.recyclerview.RecyclerViewItem)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 NotificationManager (android.app.NotificationManager)1 PendingIntent (android.app.PendingIntent)1 AppWidgetManager (android.appwidget.AppWidgetManager)1 ComponentName (android.content.ComponentName)1 Handler (android.os.Handler)1 NotificationCompat (android.support.v4.app.NotificationCompat)1 PopupMenu (android.support.v7.widget.PopupMenu)1 Menu (android.view.Menu)1 MenuItem (android.view.MenuItem)1 Widget (com.moro.mtweaks.services.profile.Widget)1