Search in sources :

Example 36 with ActionBar

use of android.app.ActionBar in project android_packages_apps_Settings by SudaMod.

the class SettingsActivity method onCreate.

@Override
protected void onCreate(Bundle savedState) {
    super.onCreate(savedState);
    long startTime = System.currentTimeMillis();
    final FeatureFactory factory = FeatureFactory.getFactory(this);
    mDashboardFeatureProvider = factory.getDashboardFeatureProvider(this);
    mMetricsFeatureProvider = factory.getMetricsFeatureProvider();
    // Should happen before any call to getIntent()
    getMetaData();
    final Intent intent = getIntent();
    if (intent.hasExtra(EXTRA_UI_OPTIONS)) {
        getWindow().setUiOptions(intent.getIntExtra(EXTRA_UI_OPTIONS, 0));
    }
    mDevelopmentPreferences = getSharedPreferences(DevelopmentSettings.PREF_FILE, Context.MODE_PRIVATE);
    // Getting Intent properties can only be done after the super.onCreate(...)
    final String initialFragmentName = intent.getStringExtra(EXTRA_SHOW_FRAGMENT);
    mIsShortcut = isShortCutIntent(intent) || isLikeShortCutIntent(intent) || intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SHORTCUT, false);
    final ComponentName cn = intent.getComponent();
    final String className = cn.getClassName();
    mIsShowingDashboard = className.equals(Settings.class.getName());
    // This is a "Sub Settings" when:
    // - this is a real SubSettings
    // - or :settings:show_fragment_as_subsetting is passed to the Intent
    final boolean isSubSettings = this instanceof SubSettings || intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, false);
    // insets
    if (isSubSettings) {
        setTheme(R.style.Theme_SubSettings);
    }
    setContentView(mIsShowingDashboard ? R.layout.settings_main_dashboard : R.layout.settings_main_prefs);
    mContent = findViewById(R.id.main_content);
    getFragmentManager().addOnBackStackChangedListener(this);
    if (savedState != null) {
        // We are restarting from a previous saved state; used that to initialize, instead
        // of starting fresh.
        setTitleFromIntent(intent);
        ArrayList<DashboardCategory> categories = savedState.getParcelableArrayList(SAVE_KEY_CATEGORIES);
        if (categories != null) {
            mCategories.clear();
            mCategories.addAll(categories);
            setTitleFromBackStack();
        }
        mDisplayHomeAsUpEnabled = savedState.getBoolean(SAVE_KEY_SHOW_HOME_AS_UP);
    } else {
        launchSettingFragment(initialFragmentName, isSubSettings, intent);
    }
    if (mIsShowingDashboard) {
        findViewById(R.id.search_bar).setVisibility(View.VISIBLE);
        findViewById(R.id.action_bar).setVisibility(View.GONE);
        Toolbar toolbar = findViewById(R.id.search_action_bar);
        toolbar.setOnClickListener(this);
        setActionBar(toolbar);
        // Please forgive me for what I am about to do.
        // 
        // Need to make the navigation icon non-clickable so that the entire card is clickable
        // and goes to the search UI. Also set the background to null so there's no ripple.
        View navView = toolbar.getNavigationView();
        navView.setClickable(false);
        navView.setBackground(null);
    }
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(mDisplayHomeAsUpEnabled);
        actionBar.setHomeButtonEnabled(mDisplayHomeAsUpEnabled);
    }
    mSwitchBar = findViewById(R.id.switch_bar);
    if (mSwitchBar != null) {
        mSwitchBar.setMetricsTag(getMetricsTag());
    }
    // see if we should show Back/Next buttons
    if (intent.getBooleanExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false)) {
        View buttonBar = findViewById(R.id.button_bar);
        if (buttonBar != null) {
            buttonBar.setVisibility(View.VISIBLE);
            Button backButton = (Button) findViewById(R.id.back_button);
            backButton.setOnClickListener(new OnClickListener() {

                public void onClick(View v) {
                    setResult(RESULT_CANCELED, null);
                    finish();
                }
            });
            Button skipButton = (Button) findViewById(R.id.skip_button);
            skipButton.setOnClickListener(new OnClickListener() {

                public void onClick(View v) {
                    setResult(RESULT_OK, null);
                    finish();
                }
            });
            mNextButton = (Button) findViewById(R.id.next_button);
            mNextButton.setOnClickListener(new OnClickListener() {

                public void onClick(View v) {
                    setResult(RESULT_OK, null);
                    finish();
                }
            });
            // set our various button parameters
            if (intent.hasExtra(EXTRA_PREFS_SET_NEXT_TEXT)) {
                String buttonText = intent.getStringExtra(EXTRA_PREFS_SET_NEXT_TEXT);
                if (TextUtils.isEmpty(buttonText)) {
                    mNextButton.setVisibility(View.GONE);
                } else {
                    mNextButton.setText(buttonText);
                }
            }
            if (intent.hasExtra(EXTRA_PREFS_SET_BACK_TEXT)) {
                String buttonText = intent.getStringExtra(EXTRA_PREFS_SET_BACK_TEXT);
                if (TextUtils.isEmpty(buttonText)) {
                    backButton.setVisibility(View.GONE);
                } else {
                    backButton.setText(buttonText);
                }
            }
            if (intent.getBooleanExtra(EXTRA_PREFS_SHOW_SKIP, false)) {
                skipButton.setVisibility(View.VISIBLE);
            }
        }
    }
    if (DEBUG_TIMING) {
        Log.d(LOG_TAG, "onCreate took " + (System.currentTimeMillis() - startTime) + " ms");
    }
}
Also used : DashboardCategory(com.android.settingslib.drawer.DashboardCategory) Intent(android.content.Intent) View(android.view.View) Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) ComponentName(android.content.ComponentName) ActionBar(android.app.ActionBar) FeatureFactory(com.android.settings.overlay.FeatureFactory) Toolbar(android.widget.Toolbar)

Example 37 with ActionBar

use of android.app.ActionBar in project android_packages_apps_Settings by SudaMod.

the class InputMethodAndSubtypeEnablerActivity method onCreate.

@Override
protected void onCreate(final Bundle savedState) {
    super.onCreate(savedState);
    final ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
    }
}
Also used : ActionBar(android.app.ActionBar)

Example 38 with ActionBar

use of android.app.ActionBar in project android_packages_apps_Gallery2 by LineageOS.

the class FilterShowActivity method onMediaPickerStarted.

public void onMediaPickerStarted() {
    toggleComparisonButtonVisibility();
    ActionBar actionBar = getActionBar();
    actionBar.hide();
    if (mMediaPicker == null)
        mMediaPicker = MediaPickerFragment.newInstance(getApplicationContext());
    getSupportFragmentManager().beginTransaction().replace(R.id.main_panel_container, mMediaPicker).commit();
}
Also used : ActionBar(android.app.ActionBar)

Example 39 with ActionBar

use of android.app.ActionBar in project android_packages_apps_Gallery2 by LineageOS.

the class FilterShowActivity method setActionBar.

public void setActionBar() {
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.edit_actionbar_background)));
    ActionBar.LayoutParams lp = new ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.MATCH_PARENT, Gravity.CENTER);
    View customView = getLayoutInflater().inflate(R.layout.filtershow_actionbar, null);
    actionBar.setCustomView(customView, lp);
    mSaveButton = actionBar.getCustomView().findViewById(R.id.filtershow_done);
    mSaveButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View view) {
            saveImage();
        }
    });
    showSaveButtonIfNeed();
    View exitButton = actionBar.getCustomView().findViewById(R.id.filtershow_exit);
    exitButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mImageShow.hasModifications()) {
                if (mBackAlertDialogBuilder == null) {
                    createBackDialog();
                }
                mBackAlertDialogBuilder.show();
            } else {
                done();
            }
        }
    });
    invalidateOptionsMenu();
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) OnClickListener(android.view.View.OnClickListener) CategoryView(com.android.gallery3d.filtershow.category.CategoryView) SwipableView(com.android.gallery3d.filtershow.category.SwipableView) WaterMarkView(com.android.gallery3d.filtershow.category.WaterMarkView) View(android.view.View) AdapterView(android.widget.AdapterView) ActionBar(android.app.ActionBar)

Example 40 with ActionBar

use of android.app.ActionBar in project android_packages_apps_Gallery2 by LineageOS.

the class ActivityState method resume.

// should only be called by StateManager
void resume() {
    AbstractGalleryActivity activity = mActivity;
    ActionBar actionBar = activity.getActionBar();
    if (actionBar != null) {
        if ((mFlags & FLAG_HIDE_ACTION_BAR) != 0) {
            actionBar.hide();
        } else {
            actionBar.show();
        }
        int stateCount = mActivity.getStateManager().getStateCount();
    }
    activity.invalidateOptionsMenu();
    setScreenFlags();
    boolean lightsOut = ((mFlags & FLAG_HIDE_STATUS_BAR) != 0);
    mActivity.getGLRoot().setLightsOutMode(lightsOut);
    ResultEntry entry = mReceivedResults;
    if (entry != null) {
        mReceivedResults = null;
        onStateResult(entry.requestCode, entry.resultCode, entry.resultData);
    }
    if (0 != (mFlags & FLAG_SCREEN_ON_WHEN_PLUGGED)) {
        // we need to know whether the device is plugged in to do this correctly
        final IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_BATTERY_CHANGED);
        activity.registerReceiver(mPowerIntentReceiver, filter);
    }
    onResume();
    // the transition store should be cleared after resume;
    mActivity.getTransitionStore().clear();
}
Also used : IntentFilter(android.content.IntentFilter) ActionBar(android.app.ActionBar)

Aggregations

ActionBar (android.app.ActionBar)265 View (android.view.View)58 Intent (android.content.Intent)35 TextView (android.widget.TextView)21 ColorDrawable (android.graphics.drawable.ColorDrawable)20 OnClickListener (android.view.View.OnClickListener)14 AdapterView (android.widget.AdapterView)14 ListView (android.widget.ListView)12 Bundle (android.os.Bundle)10 Test (org.junit.Test)10 SharedPreferences (android.content.SharedPreferences)9 Uri (android.net.Uri)9 Button (android.widget.Button)9 AlertDialog (android.app.AlertDialog)8 DialogInterface (android.content.DialogInterface)8 ViewPager (android.support.v4.view.ViewPager)8 SpannableString (android.text.SpannableString)8 ComponentName (android.content.ComponentName)7 ArrayAdapter (android.widget.ArrayAdapter)7 FrameLayout (android.widget.FrameLayout)7