Search in sources :

Example 1 with FloatingActionButton

use of com.android.settings.rr.fab.FloatingActionButton in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class MainSettingsLayout method onCreateView.

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mContainer = container;
    View view = inflater.inflate(R.layout.rr_main, container, false);
    mFab = (FloatingActionsMenu) view.findViewById(R.id.fab_menu);
    mLayout = (LinearLayout) view.findViewById(R.id.main_content);
    mViewPager = (ViewPager) view.findViewById(R.id.viewpager);
    mTabs = (PagerSlidingTabStrip) view.findViewById(R.id.tabs);
    mSettingsObserver = new SettingsObserver(new Handler());
    mInterceptorFrame = (FrameLayout) view.findViewById(R.id.fl_interceptor);
    FloatingActionButton mFab1 = (FloatingActionButton) view.findViewById(R.id.fab_event);
    FloatingActionButton mFab2 = (FloatingActionButton) view.findViewById(R.id.fab_restart);
    FloatingActionButton mFab3 = (FloatingActionButton) view.findViewById(R.id.fab_reset);
    FloatingActionButton mFab4 = (FloatingActionButton) view.findViewById(R.id.fab_info);
    FloatingActionButton mFab5 = (FloatingActionButton) view.findViewById(R.id.fab_config);
    mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mTabs.setViewPager(mViewPager);
    mSettingsObserver.observe();
    mContext = getActivity().getApplicationContext();
    ContentResolver resolver = getActivity().getContentResolver();
    mInterceptorFrame.getBackground().setAlpha(0);
    int which = Settings.System.getInt(getActivity().getContentResolver(), Settings.System.RR_CONFIG_STYLE, 0);
    if (which == 1) {
        mTabs.setVisibility(View.GONE);
        mFab5.setTitle(getString(R.string.fab_layout_toggle));
    } else if (which == 0) {
        mTabs.setVisibility(View.VISIBLE);
        mFab5.setTitle(getString(R.string.fab_layout_update));
    }
    boolean isShowing = Settings.System.getInt(resolver, Settings.System.RR_OTA_FAB, 1) == 1;
    mFab1.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent fabIntent = new Intent();
            fabIntent.setClassName("com.resurrection.ota", "com.resurrection.ota.MainActivity");
            startActivity(fabIntent);
        }
    });
    mFab2.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Helpers.showSystemUIrestartDialog(getActivity());
        }
    });
    mFab3.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();
            alertDialog.setTitle(getString(R.string.rr_reset_settings));
            alertDialog.setMessage(getString(R.string.rr_reset_message));
            alertDialog.setButton(getString(R.string.rr_reset_yes), new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    stockitems();
                }
            });
            alertDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(R.string.rr_reset_cancel), new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    return;
                }
            });
            alertDialog.show();
        }
    });
    mFab4.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent fabIntent = new Intent();
            fabIntent.setClassName("com.android.settings", "com.android.settings.Settings$AboutSettingsActivity");
            startActivity(fabIntent);
        }
    });
    mFab5.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (which == 0) {
                Settings.System.putInt(getActivity().getContentResolver(), Settings.System.RR_CONFIG_STYLE, 1);
            } else if (which == 1) {
                Settings.System.putInt(getActivity().getContentResolver(), Settings.System.RR_CONFIG_STYLE, 0);
            }
            finish();
            startActivity(getIntent());
        }
    });
    if (isShowing) {
        mFab.setVisibility(View.VISIBLE);
    } else {
        mFab.setVisibility(View.GONE);
    }
    mFab.setOnFloatingActionsMenuUpdateListener(new FloatingActionsMenu.OnFloatingActionsMenuUpdateListener() {

        @Override
        public void onMenuExpanded() {
            mInterceptorFrame.getBackground().setAlpha(240);
            mInterceptorFrame.setOnTouchListener(new View.OnTouchListener() {

                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    mFab.collapse();
                    return true;
                }
            });
        }

        @Override
        public void onMenuCollapsed() {
            mInterceptorFrame.getBackground().setAlpha(0);
            mInterceptorFrame.setOnTouchListener(null);
        }
    });
    mInterceptorFrame.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (mFab.isExpanded()) {
                mFab.collapse();
                return true;
            }
            return false;
        }
    });
    return view;
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) FloatingActionsMenu(com.android.settings.rr.fab.FloatingActionsMenu) Handler(android.os.Handler) Intent(android.content.Intent) View(android.view.View) ContentResolver(android.content.ContentResolver) MotionEvent(android.view.MotionEvent) FloatingActionButton(com.android.settings.rr.fab.FloatingActionButton)

Example 2 with FloatingActionButton

use of com.android.settings.rr.fab.FloatingActionButton in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class MainSettingsLayout method createTabsLayout.

public void createTabsLayout() {
    view = mInflater.inflate(R.layout.rr_main, mContainer, false);
    FloatingActionButton mFab1 = (FloatingActionButton) view.findViewById(R.id.fab_event);
    FloatingActionButton mFab2 = (FloatingActionButton) view.findViewById(R.id.fab_restart);
    FloatingActionButton mFab3 = (FloatingActionButton) view.findViewById(R.id.fab_reset);
    FloatingActionButton mFab4 = (FloatingActionButton) view.findViewById(R.id.fab_info);
    FloatingActionButton mFab5 = (FloatingActionButton) view.findViewById(R.id.fab_config);
    FloatingActionButton mFab6 = (FloatingActionButton) view.findViewById(R.id.fab_picker);
    mFab = (FloatingActionsMenu) view.findViewById(R.id.fab_menu);
    mLayout = (LinearLayout) view.findViewById(R.id.main_content);
    mViewPager = (ViewPager) view.findViewById(R.id.viewpager);
    mTabs = (PagerSlidingTabStrip) view.findViewById(R.id.tabs);
    mInterceptorFrame = (FrameLayout) view.findViewById(R.id.fl_interceptor);
    final ActionBar ab = getActivity().getActionBar();
    if (ab != null) {
        ab.setTitle(R.string.rr_title);
    }
    mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.setClipChildren(true);
    mViewPager.setClipToPadding(true);
    mTabs.setViewPager(mViewPager);
    mContext = getActivity().getApplicationContext();
    ContentResolver resolver = getActivity().getContentResolver();
    mInterceptorFrame.getBackground().setAlpha(0);
    if (mStyle == 0) {
        mTabs.setVisibility(View.VISIBLE);
        mFab5.setTitle(getString(R.string.fab_layout_update));
    } else if (mStyle == 1) {
        mTabs.setVisibility(View.GONE);
        mFab5.setTitle(getString(R.string.fab_layout_toggle));
    }
    int accent = Utils.getColorAccentDefaultColor(getContext());
    mFab1.setColorFilter(accent);
    mFab2.setColorFilter(accent);
    mFab3.setColorFilter(accent);
    mFab4.setColorFilter(accent);
    mFab5.setColorFilter(accent);
    mFab6.setColorFilter(accent);
    mFab1.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent settings = new Intent(Intent.ACTION_MAIN);
            settings.setClassName(UPDATER_PACKAGE_NAME, UPDATER_PACKAGE_ACTIVITY);
            startActivity(settings);
        }
    });
    mFab2.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();
            alertDialog.setTitle(getString(R.string.restart_systemui));
            alertDialog.setMessage(getString(R.string.restart_settings_warning));
            alertDialog.setButton(getString(R.string.rr_reset_yes), new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    Process.killProcess(Process.myPid());
                }
            });
            alertDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(R.string.rr_reset_cancel), new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    return;
                }
            });
            alertDialog.show();
        }
    });
    mFab3.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();
            alertDialog.setTitle(getString(R.string.rr_reset_settings));
            alertDialog.setMessage(getString(R.string.rr_reset_message));
            alertDialog.setButton(getString(R.string.rr_reset_yes), new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();
                    alertDialog.setTitle(getString(R.string.rr_reset_settings));
                    alertDialog.setMessage(getString(R.string.rr_reset_message_warning));
                    alertDialog.setButton(getString(R.string.rr_reset_yes), new DialogInterface.OnClickListener() {

                        public void onClick(DialogInterface dialog, int which) {
                            stockitems();
                        }
                    });
                    alertDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(R.string.rr_reset_cancel), new DialogInterface.OnClickListener() {

                        public void onClick(DialogInterface dialog, int which) {
                            return;
                        }
                    });
                    alertDialog.show();
                }
            });
            alertDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(R.string.rr_reset_cancel), new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    return;
                }
            });
            alertDialog.show();
        }
    });
    mFab4.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent settings = new Intent(Intent.ACTION_MAIN);
            settings.setClassName(SETTINGS_FRAG, ABOUT_FRAG_ACT);
            startActivity(settings);
        }
    });
    mFab6.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent settings = new Intent(Intent.ACTION_MAIN);
            settings.setClassName(SETTINGS_FRAG, SETTINGS_ACCENT);
            startActivity(settings);
        }
    });
    mFab5.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mStyle == 0) {
                showDialogForClassic(getActivity());
            } else if (mStyle == 1) {
                showDialogForNav(getActivity());
            }
        }
    });
    mFab.setOnFloatingActionsMenuUpdateListener(new FloatingActionsMenu.OnFloatingActionsMenuUpdateListener() {

        @Override
        public void onMenuExpanded() {
            mInterceptorFrame.getBackground().setAlpha(240);
            mInterceptorFrame.setOnTouchListener(new View.OnTouchListener() {

                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    mFab.collapse();
                    return true;
                }
            });
        }

        @Override
        public void onMenuCollapsed() {
            mInterceptorFrame.getBackground().setAlpha(0);
            mInterceptorFrame.setOnTouchListener(null);
        }
    });
    mInterceptorFrame.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (mFab.isExpanded()) {
                mFab.collapse();
                return true;
            }
            return false;
        }
    });
    mFab.setVisibility(View.VISIBLE);
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) FloatingActionsMenu(com.android.settings.rr.fab.FloatingActionsMenu) Intent(android.content.Intent) View(android.view.View) ContentResolver(android.content.ContentResolver) MotionEvent(android.view.MotionEvent) FloatingActionButton(com.android.settings.rr.fab.FloatingActionButton) ActionBar(android.app.ActionBar)

Aggregations

AlertDialog (android.app.AlertDialog)2 ContentResolver (android.content.ContentResolver)2 DialogInterface (android.content.DialogInterface)2 Intent (android.content.Intent)2 MotionEvent (android.view.MotionEvent)2 View (android.view.View)2 FloatingActionButton (com.android.settings.rr.fab.FloatingActionButton)2 FloatingActionsMenu (com.android.settings.rr.fab.FloatingActionsMenu)2 ActionBar (android.app.ActionBar)1 Handler (android.os.Handler)1