Search in sources :

Example 1 with ViewEventHandler

use of com.spazedog.mounts2sd.tools.ViewEventHandler in project mounts2sd by SpazeDog.

the class ActivityAppSettings method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    mPreferences = Preferences.getInstance((Context) this);
    setTheme(mPreferences.theme());
    super.onCreate(savedInstanceState);
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    ExtendedLayout layoutOuter = (ExtendedLayout) inflater.inflate(R.layout.activity_app_settings, null);
    if (mPreferences.applicationSettings.use_tablet_settings() || getResources().getString(R.string.config_screen_type).equals("xlarge")) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setBackgroundDrawable(new ColorDrawable(0));
        layoutOuter.setOnMeasure(this);
        setContentView(layoutOuter, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
    } else {
        ViewGroup layout = (ViewGroup) ((ViewGroup) layoutOuter.getChildAt(0)).getChildAt(0);
        ((ViewGroup) layoutOuter.getChildAt(0)).removeView(layout);
        setContentView(layout, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
    }
    mCheckboxTheme = (LinearLayout) findViewById(R.id.settings_style_item_theme);
    mCheckboxTheme.setOnTouchListener(new ViewEventHandler(this));
    mCheckboxLayout = (LinearLayout) findViewById(R.id.settings_style_item_layout);
    mCheckboxLayout.setOnTouchListener(new ViewEventHandler(this));
    mCheckboxDialog = (LinearLayout) findViewById(R.id.settings_style_item_dialog);
    if (getResources().getString(R.string.config_screen_type).equals("normal")) {
        mCheckboxDialog.setOnTouchListener(new ViewEventHandler(this));
    } else {
        Utils.removeView(mCheckboxDialog, false);
    }
    mCheckboxBusybox = (LinearLayout) findViewById(R.id.settings_general_item_busybox);
    if (mPreferences.deviceSetup.environment_multiple_binaries() && mPreferences.isUserOwner()) {
        mCheckboxBusybox.setOnTouchListener(new ViewEventHandler(this));
    } else {
        mCheckboxBusybox.setEnabled(false);
    }
    mTextScriptButton = (TextView) findViewById(R.id.settings_script_item_button);
    if (mPreferences.isUserOwner()) {
        mTextScriptButton.setOnTouchListener(new ViewEventHandler(this));
    } else {
        mTextScriptButton.setEnabled(false);
    }
    mViewSqlite = (LinearLayout) findViewById(R.id.settings_general_item_sqlite);
    if (mPreferences.isUserOwner()) {
        mViewSqlite.setOnTouchListener(new ViewEventHandler(this));
    } else {
        mViewSqlite.setEnabled(false);
    }
    mTextScriptInstalled = (TextView) findViewById(R.id.settings_script_item_installed);
    mTextScriptBundled = (TextView) findViewById(R.id.settings_script_item_bundled);
    handleViewContent();
}
Also used : Context(android.content.Context) ColorDrawable(android.graphics.drawable.ColorDrawable) ViewEventHandler(com.spazedog.mounts2sd.tools.ViewEventHandler) ViewGroup(android.view.ViewGroup) LayoutInflater(android.view.LayoutInflater) ExtendedLayout(com.spazedog.mounts2sd.tools.ExtendedLayout) LinearLayout(android.widget.LinearLayout)

Example 2 with ViewEventHandler

use of com.spazedog.mounts2sd.tools.ViewEventHandler in project mounts2sd by SpazeDog.

the class FragmentTabAppManager method buildApplicationList.

private void buildApplicationList() {
    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    Boolean divider = false;
    ViewGroup container = (ViewGroup) ((ViewGroup) getView()).getChildAt(0);
    for (String key : oPackages.keySet()) {
        ViewGroup itemView = (ViewGroup) inflater.inflate(R.layout.inflate_appmanager_item, container, false);
        ((ImageView) itemView.findViewById(R.id.item_package_icon)).setImageDrawable((Drawable) oPackages.get(key).getObject("icon"));
        ((TextView) itemView.findViewById(R.id.item_package_label)).setText((String) oPackages.get(key).getObject("label"));
        ((TextView) itemView.findViewById(R.id.item_package_name)).setText(oPackages.get(key).name());
        ((ImageView) itemView.findViewById(R.id.item_package_type)).setImageResource((Boolean) oPackages.get(key).getObject("isSystem") ? R.drawable.app_manager_system : R.drawable.app_manager_regular);
        itemView.setSelected((Boolean) oPackages.get(key).getObject("isSystem"));
        itemView.setTag(oPackages.get(key).name());
        if (divider) {
            inflater.inflate(R.layout.inflate_dialog_divider, container);
        } else {
            divider = true;
        }
        itemView.setOnTouchListener(new ViewEventHandler(this));
        container.addView(itemView);
    }
}
Also used : ViewEventHandler(com.spazedog.mounts2sd.tools.ViewEventHandler) ViewGroup(android.view.ViewGroup) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) ImageView(android.widget.ImageView)

Example 3 with ViewEventHandler

use of com.spazedog.mounts2sd.tools.ViewEventHandler in project mounts2sd by SpazeDog.

the class FragmentTabConfigure method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    onHiddenChanged(false);
    mOptionContentApps = (ViewGroup) view.findViewById(R.id.option_content_item_apps);
    mOptionContentApps.setOnTouchListener(new ViewEventHandler(this));
    mOptionContentApps.setSelected(mPreferences.deviceProperties.move_apps());
    mOptionContentSysApps = (ViewGroup) view.findViewById(R.id.option_content_item_sysapps);
    mOptionContentSysApps.setOnTouchListener(new ViewEventHandler(this));
    mOptionContentSysApps.setSelected(mPreferences.deviceProperties.move_sysapps());
    mOptionContentLibs = (ViewGroup) view.findViewById(R.id.option_content_item_libs);
    mOptionContentLibs.setOnTouchListener(new ViewEventHandler(this));
    mOptionContentLibs.setSelected(mPreferences.deviceProperties.move_libs());
    mOptionContentData = (ViewGroup) view.findViewById(R.id.option_content_item_data);
    mOptionContentData.setOnTouchListener(new ViewEventHandler(this));
    mOptionContentData.setSelected(mPreferences.deviceProperties.move_data());
    mOptionContentDalvik = (ViewGroup) view.findViewById(R.id.option_content_item_dalvik);
    mOptionContentDalvik.setOnTouchListener(new ViewEventHandler(this));
    mOptionContentDalvik.setSelected(mPreferences.deviceProperties.move_dalvik());
    mOptionContentSystem = (ViewGroup) view.findViewById(R.id.option_content_item_system);
    mOptionContentSystem.setOnTouchListener(new ViewEventHandler(this));
    mOptionContentSystem.setSelected(mPreferences.deviceProperties.move_system());
    mOptionContentMedia = (ViewGroup) view.findViewById(R.id.option_content_item_media);
    mOptionContentMedia.setOnTouchListener(new ViewEventHandler(this));
    mOptionContentMedia.setSelected(mPreferences.deviceProperties.move_media());
    mOptionMemorySwap = (ViewGroup) view.findViewById(R.id.option_memory_item_swap);
    mOptionMemorySwap.setOnTouchListener(new ViewEventHandler(this));
    mOptionMemorySwap.setSelected(mPreferences.deviceProperties.enable_swap());
    mOptionFilesystemFschk = (ViewGroup) view.findViewById(R.id.option_filesystem_item_fschk);
    mOptionFilesystemFschk.setOnTouchListener(new ViewEventHandler(this));
    mOptionFilesystemFschk.setSelected(mPreferences.deviceProperties.run_sdext_fschk());
    mOptionMiscSafemode = (ViewGroup) view.findViewById(R.id.option_misc_item_safemode);
    mOptionMiscSafemode.setOnTouchListener(new ViewEventHandler(this));
    mOptionMiscSafemode.setSelected(mPreferences.deviceProperties.disable_safemode());
    mOptionMiscDebug = (ViewGroup) view.findViewById(R.id.option_misc_item_debug);
    mOptionMiscDebug.setOnTouchListener(new ViewEventHandler(this));
    mOptionMiscDebug.setSelected(mPreferences.deviceProperties.enable_debug());
    mOptionMemoryZram = (ViewGroup) view.findViewById(R.id.option_memory_item_zram);
    mOptionMemoryZram.setOnTouchListener(new ViewEventHandler(this));
    mOptionMemoryZram.setTag(new String[] { "zram", "" + mPreferences.deviceProperties.set_zram_compression() });
    ((TextView) mOptionMemoryZram.findViewById(R.id.item_value)).setText(Utils.getSelectorValue(getActivity(), "zram", "" + mPreferences.deviceProperties.set_zram_compression()));
    mOptionMemorySwappiness = (ViewGroup) view.findViewById(R.id.option_memory_item_swappiness);
    mOptionMemorySwappiness.setOnTouchListener(new ViewEventHandler(this));
    mOptionMemorySwappiness.setTag(new String[] { "swappiness", "" + mPreferences.deviceProperties.set_swap_level() });
    ((TextView) mOptionMemorySwappiness.findViewById(R.id.item_value)).setText(Utils.getSelectorValue(getActivity(), "swappiness", "" + mPreferences.deviceProperties.set_swap_level()));
    mOptionFilesystemFstype = (ViewGroup) view.findViewById(R.id.option_filesystem_item_fstype);
    mOptionFilesystemFstype.setOnTouchListener(new ViewEventHandler(this));
    mOptionFilesystemFstype.setTag(new String[] { "filesystem", "" + mPreferences.deviceProperties.set_sdext_fstype() });
    ((TextView) mOptionFilesystemFstype.findViewById(R.id.item_value)).setText(Utils.getSelectorValue(getActivity(), "filesystem", "" + mPreferences.deviceProperties.set_sdext_fstype()));
    mOptionFilesystemJournal = (ViewGroup) view.findViewById(R.id.option_filesystem_item_journal);
    mOptionFilesystemJournal.setOnTouchListener(new ViewEventHandler(this));
    mOptionFilesystemJournal.setTag(new String[] { "journal", "" + mPreferences.deviceProperties.enable_sdext_journal() });
    ((TextView) mOptionFilesystemJournal.findViewById(R.id.item_value)).setText(Utils.getSelectorValue(getActivity(), "journal", "" + mPreferences.deviceProperties.enable_sdext_journal()));
    mOptionStorageCache = (ViewGroup) view.findViewById(R.id.option_storage_item_cache);
    mOptionStorageCache.setOnTouchListener(new ViewEventHandler(this));
    mOptionStorageCache.setTag(new String[] { "cache", "" + mPreferences.deviceProperties.enable_cache() });
    ((TextView) mOptionStorageCache.findViewById(R.id.item_value)).setText(Utils.getSelectorValue(getActivity(), "cache", "" + mPreferences.deviceProperties.enable_cache()));
    mOptionImmcScheduler = (ViewGroup) view.findViewById(R.id.option_immc_item_scheduler);
    mOptionImmcScheduler.setOnTouchListener(new ViewEventHandler(this));
    mOptionImmcScheduler.setTag(new String[] { "scheduler", "" + mPreferences.deviceProperties.set_immc_scheduler() });
    ((TextView) mOptionImmcScheduler.findViewById(R.id.item_value)).setText(Utils.getSelectorValue(getActivity(), "scheduler", "" + mPreferences.deviceProperties.set_immc_scheduler()));
    mOptionImmcReadahead = (ViewGroup) view.findViewById(R.id.option_immc_item_readahead);
    mOptionImmcReadahead.setOnTouchListener(new ViewEventHandler(this));
    mOptionImmcReadahead.setTag(new String[] { "readahead", "" + mPreferences.deviceProperties.set_immc_readahead() });
    ((TextView) mOptionImmcReadahead.findViewById(R.id.item_value)).setText(Utils.getSelectorValue(getActivity(), "readahead", "" + mPreferences.deviceProperties.set_immc_readahead()));
    mOptionEmmcScheduler = (ViewGroup) view.findViewById(R.id.option_emmc_item_scheduler);
    mOptionEmmcScheduler.setOnTouchListener(new ViewEventHandler(this));
    mOptionEmmcScheduler.setTag(new String[] { "scheduler", "" + mPreferences.deviceProperties.set_emmc_scheduler() });
    ((TextView) mOptionEmmcScheduler.findViewById(R.id.item_value)).setText(Utils.getSelectorValue(getActivity(), "scheduler", "" + mPreferences.deviceProperties.set_emmc_scheduler()));
    mOptionEmmcReadahead = (ViewGroup) view.findViewById(R.id.option_emmc_item_readahead);
    mOptionEmmcReadahead.setOnTouchListener(new ViewEventHandler(this));
    mOptionEmmcReadahead.setTag(new String[] { "readahead", "" + mPreferences.deviceProperties.set_emmc_readahead() });
    ((TextView) mOptionEmmcReadahead.findViewById(R.id.item_value)).setText(Utils.getSelectorValue(getActivity(), "readahead", "" + mPreferences.deviceProperties.set_emmc_readahead()));
    mOptionSystemThreshold = (ViewGroup) view.findViewById(R.id.option_system_item_threshold);
    mOptionSystemThreshold.setOnTouchListener(new ViewEventHandler(this));
    mOptionSystemThreshold.setTag(new String[] { "threshold", "" + mPreferences.deviceProperties.set_storage_threshold() });
    ((TextView) mOptionSystemThreshold.findViewById(R.id.item_value)).setText(Utils.getSelectorValue(getActivity(), "threshold", "" + mPreferences.deviceProperties.set_storage_threshold()));
    handleEnabledState();
}
Also used : ViewEventHandler(com.spazedog.mounts2sd.tools.ViewEventHandler) TextView(android.widget.TextView)

Example 4 with ViewEventHandler

use of com.spazedog.mounts2sd.tools.ViewEventHandler in project mounts2sd by SpazeDog.

the class FragmentDialog method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    super.onCreateDialog(savedInstanceState);
    mArguments = getArguments();
    if (savedInstanceState != null) {
        mExtra = savedInstanceState.getBundle("extra");
    } else {
        mExtra = mArguments.getBundle("extra");
        if (mExtra == null) {
            mExtra = new Bundle();
        }
    }
    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    Dialog dialog = (Dialog) new Dialog(getActivity(), Preferences.getInstance(getActivity()).theme());
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(0));
    dialog.setCanceledOnTouchOutside(false);
    ExtendedLayout layout = null;
    if (mArguments.getString("type").equals("message")) {
        layout = (ExtendedLayout) inflater.inflate(R.layout.dialog_message, null);
        layout.findViewById(R.id.dialog_close_button).setOnTouchListener(new ViewEventHandler(this));
    } else {
        layout = (ExtendedLayout) inflater.inflate(R.layout.dialog_confirm, null);
        layout.findViewById(R.id.dialog_cancel_button).setOnTouchListener(new ViewEventHandler(this));
        layout.findViewById(R.id.dialog_okay_button).setOnTouchListener(new ViewEventHandler(this));
    }
    ((TextView) layout.findViewById(R.id.dialog_title)).setText(mArguments.getString("title"));
    if (mArguments.getBoolean("custom")) {
        ViewGroup scroller = (ViewGroup) layout.findViewById(R.id.dialog_textbox).getParent();
        scroller.removeView(layout.findViewById(R.id.dialog_textbox));
        scroller.addView(((IDialogCustomLayout) mListener).onDialogCreateView(mArguments.getString("tag"), inflater, scroller, mExtra));
    } else {
        ((TextView) layout.findViewById(R.id.dialog_textbox)).setText(mArguments.getString("message"));
    }
    layout.setOnMeasure(this);
    dialog.addContentView(layout, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
    return dialog;
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) ViewEventHandler(com.spazedog.mounts2sd.tools.ViewEventHandler) Bundle(android.os.Bundle) Dialog(android.app.Dialog) ViewGroup(android.view.ViewGroup) LayoutInflater(android.view.LayoutInflater) FrameLayout(android.widget.FrameLayout) ExtendedLayout(com.spazedog.mounts2sd.tools.ExtendedLayout) TextView(android.widget.TextView)

Example 5 with ViewEventHandler

use of com.spazedog.mounts2sd.tools.ViewEventHandler in project mounts2sd by SpazeDog.

the class FragmentTabConfigure method onDialogCreateView.

@Override
public View onDialogCreateView(String tag, LayoutInflater inflater, ViewGroup container, final Bundle extra) {
    ViewGroup placeholder = (ViewGroup) inflater.inflate(R.layout.inflate_dialog_placeholder, container, false);
    String selectorType = extra.getString("type");
    String selectorValue = extra.getString("value");
    String[] selectorEnabledValues = getEnabledSelectorValues(extra.getInt("viewId"));
    Integer selectorNamesId = getResources().getIdentifier("selector_" + selectorType + "_names", "array", getActivity().getPackageName());
    Integer selectorValuesId = getResources().getIdentifier("selector_" + selectorType + "_values", "array", getActivity().getPackageName());
    Integer selectorCommentsId = getResources().getIdentifier("selector_" + selectorType + "_comments", "array", getActivity().getPackageName());
    if (selectorNamesId != 0 && selectorValuesId != 0) {
        String[] selectorNames = getResources().getStringArray(selectorNamesId);
        String[] selectorValues = getResources().getStringArray(selectorValuesId);
        String[] selectorComments = selectorCommentsId != 0 ? getResources().getStringArray(selectorCommentsId) : new String[selectorNames.length];
        for (int i = 0; i < selectorNames.length; i++) {
            ViewGroup itemView = (ViewGroup) inflater.inflate(R.layout.inflate_selector_item, (ViewGroup) placeholder, false);
            Boolean enabled = true;
            if (selectorEnabledValues != null) {
                for (int x = 0; x < selectorEnabledValues.length; x++) {
                    if (selectorEnabledValues[x].equals(selectorValues[i])) {
                        enabled = true;
                        break;
                    }
                    enabled = false;
                }
            }
            if (selectorType.equals("threshold")) {
                selectorComments[i] = Common.convertPrifix((mPreferences.deviceConfig.size_storage_data() * (Double.parseDouble(selectorValues[i]) / 100)));
            } else if (selectorType.equals("zram")) {
                if (oMemoryUsage == null) {
                    RootFW rootfw = Root.initiate();
                    MemStat memstat = rootfw.memory().getUsage();
                    oMemoryUsage = memstat != null ? memstat.memTotal().doubleValue() : 0D;
                    Root.release();
                }
                selectorComments[i] = Common.convertPrifix((oMemoryUsage * (Double.parseDouble(selectorValues[i]) / 100)));
            }
            ((TextView) itemView.findViewById(R.id.item_name)).setText(selectorNames[i]);
            if (selectorComments[i] != null && !selectorComments[i].equals("")) {
                ((TextView) itemView.findViewById(R.id.item_description)).setText(selectorComments[i]);
            }
            itemView.setSelected(selectorValues[i].equals(selectorValue));
            itemView.setEnabled(enabled);
            itemView.setTag(selectorValues[i]);
            itemView.setOnTouchListener(new ViewEventHandler(new ViewClickListener() {

                @Override
                public void onViewClick(View v) {
                    extra.putString("value", (String) v.getTag());
                    ViewGroup view = (ViewGroup) v.getParent();
                    for (int i = 0; i < view.getChildCount(); i++) {
                        View child = view.getChildAt(i);
                        if (child == v) {
                            child.setSelected(true);
                        } else {
                            child.setSelected(false);
                        }
                    }
                }
            }));
            if (i > 0) {
                inflater.inflate(R.layout.inflate_dialog_divider, placeholder);
            }
            placeholder.addView(itemView);
        }
    }
    return placeholder;
}
Also used : ViewEventHandler(com.spazedog.mounts2sd.tools.ViewEventHandler) ViewGroup(android.view.ViewGroup) ViewClickListener(com.spazedog.mounts2sd.tools.ViewEventHandler.ViewClickListener) MemStat(com.spazedog.lib.rootfw3.extenders.MemoryExtender.MemStat) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) RootFW(com.spazedog.lib.rootfw3.RootFW)

Aggregations

ViewEventHandler (com.spazedog.mounts2sd.tools.ViewEventHandler)5 ViewGroup (android.view.ViewGroup)4 TextView (android.widget.TextView)4 LayoutInflater (android.view.LayoutInflater)3 ColorDrawable (android.graphics.drawable.ColorDrawable)2 ExtendedLayout (com.spazedog.mounts2sd.tools.ExtendedLayout)2 Dialog (android.app.Dialog)1 Context (android.content.Context)1 Bundle (android.os.Bundle)1 View (android.view.View)1 FrameLayout (android.widget.FrameLayout)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 RootFW (com.spazedog.lib.rootfw3.RootFW)1 MemStat (com.spazedog.lib.rootfw3.extenders.MemoryExtender.MemStat)1 ViewClickListener (com.spazedog.mounts2sd.tools.ViewEventHandler.ViewClickListener)1