Java Code Examples for androidx.appcompat.widget.Toolbar#setPopupTheme()
The following examples show how to use
androidx.appcompat.widget.Toolbar#setPopupTheme() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HelpActivity.java From habpanelviewer with GNU General Public License v3.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_help); Toolbar myToolbar = findViewById(R.id.toolbar); setSupportActionBar(myToolbar); ActionBar ab = getSupportActionBar(); if (ab != null) { ab.setDisplayHomeAsUpEnabled(true); } final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); String theme = prefs.getString(Constants.PREF_THEME, "dark"); if ("dark".equals(theme)) { myToolbar.setPopupTheme(R.style.Theme_AppCompat_NoActionBar); } else { myToolbar.setPopupTheme(R.style.Theme_AppCompat_Light_NoActionBar); } showHelp(); }
Example 2
Source File: LogActivity.java From habpanelviewer with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_log); mLogTextView = findViewById(R.id.log); mProgressBar = findViewById(R.id.progressBar); mScrollView = findViewById(R.id.scrollview); mEmptyView = findViewById(android.R.id.empty); Toolbar myToolbar = findViewById(R.id.toolbar); setSupportActionBar(myToolbar); ActionBar ab = getSupportActionBar(); if (ab != null) { ab.setDisplayHomeAsUpEnabled(true); } final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); String theme = prefs.getString(Constants.PREF_THEME, "dark"); if ("dark".equals(theme)) { myToolbar.setPopupTheme(R.style.ThemeOverlay_AppCompat_Dark); } else { myToolbar.setPopupTheme(R.style.ThemeOverlay_AppCompat_Light); } setUiState(true, false); }
Example 3
Source File: CommandLogActivity.java From habpanelviewer with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); executor = Executors.newSingleThreadScheduledExecutor(); executor.scheduleWithFixedDelay(() -> runOnUiThread(() -> { if (adapter != null) { adapter.notifyDataSetChanged(); } if (mClearItem != null && mClearItem.isEnabled() != adapter.getCount() > 0) { mClearItem.setEnabled(adapter.getCount() > 0); } }), 0, 1, TimeUnit.SECONDS); setContentView(R.layout.activity_commandlog); Toolbar myToolbar = findViewById(R.id.toolbar); setSupportActionBar(myToolbar); ActionBar ab = getSupportActionBar(); if (ab != null) { ab.setDisplayHomeAsUpEnabled(true); } final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); String theme = prefs.getString(Constants.PREF_THEME, "dark"); if ("dark".equals(theme)) { myToolbar.setPopupTheme(R.style.ThemeOverlay_AppCompat_Dark); } else { myToolbar.setPopupTheme(R.style.ThemeOverlay_AppCompat_Light); } EventBus.getDefault().post(logClient); }
Example 4
Source File: MainActivity.java From revolution-irc with GNU General Public License v3.0 | 5 votes |
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); StyledAttributesHelper ta = StyledAttributesHelper.obtainStyledAttributes(this, new int[] { R.attr.actionBarSize }); ViewGroup.LayoutParams params = mFakeToolbar.getLayoutParams(); params.height = ta.getDimensionPixelSize(R.attr.actionBarSize, 0); mFakeToolbar.setLayoutParams(params); ta.recycle(); if (mToolbar != null) { ViewGroup group = (ViewGroup) mToolbar.getParent(); int i = group.indexOfChild(mToolbar); group.removeViewAt(i); Toolbar replacement = new Toolbar(group.getContext()); replacement.setPopupTheme(mToolbar.getPopupTheme()); AppBarLayout.LayoutParams toolbarParams = new AppBarLayout.LayoutParams( AppBarLayout.LayoutParams.MATCH_PARENT, params.height); replacement.setLayoutParams(toolbarParams); for (int j = 0; j < mToolbar.getChildCount(); j++) { View v = mToolbar.getChildAt(j); if (v instanceof TabLayout) { mToolbar.removeViewAt(j); replacement.addView(v); j--; } } group.addView(replacement, i); setSupportActionBar(replacement); addActionBarDrawerToggle(replacement); } }
Example 5
Source File: PreferencesActivity.java From TowerCollector with Mozilla Public License 2.0 | 5 votes |
private void setupActionBar() { Toolbar toolbar = findViewById(R.id.preferences_toolbar); toolbar.setPopupTheme(MyApplication.getCurrentPopupTheme()); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); } }
Example 6
Source File: CandyBarMainActivity.java From candybar with Apache License 2.0 | 4 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.setTheme(Preferences.get(this).isDarkTheme() ? R.style.AppThemeDark : R.style.AppTheme); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ColorHelper.setupStatusBarIconColor(this); ColorHelper.setNavigationBarColor(this, ContextCompat.getColor(this, Preferences.get(this).isDarkTheme() ? R.color.navigationBarDark : R.color.navigationBar)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !Preferences.get(this).isDarkTheme()) { int flags = 0; if (ColorHelper.isLightColor(ContextCompat.getColor(this, R.color.navigationBar))) flags = flags | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; if (ColorHelper.isLightColor(ContextCompat.getColor(this, R.color.colorPrimaryDark))) flags = flags | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; if (flags != 0) { this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); this.getWindow().getDecorView().setSystemUiVisibility(flags); this.getWindow().setStatusBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark)); } } registerBroadcastReceiver(); startService(new Intent(this, CandyBarService.class)); //Todo: wait until google fix the issue, then enable wallpaper crop again on API 26+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { Preferences.get(this).setCropWallpaper(false); } mConfig = onInit(); InAppBillingProcessor.get(this).init(mConfig.getLicenseKey()); mDrawerLayout = findViewById(R.id.drawer_layout); mNavigationView = findViewById(R.id.navigation_view); Toolbar toolbar = findViewById(R.id.toolbar); mToolbarTitle = findViewById(R.id.toolbar_title); toolbar.setPopupTheme(Preferences.get(this).isDarkTheme() ? R.style.AppThemeDark : R.style.AppTheme); toolbar.setTitle(""); setSupportActionBar(toolbar); mFragManager = getSupportFragmentManager(); initNavigationView(toolbar); initNavigationViewHeader(); mPosition = mLastPosition = 0; if (savedInstanceState != null) { mPosition = mLastPosition = savedInstanceState.getInt(Extras.EXTRA_POSITION, 0); onSearchExpanded(false); } Bundle bundle = getIntent().getExtras(); if (bundle != null) { int position = bundle.getInt(Extras.EXTRA_POSITION, -1); if (position >= 0 && position < 5) { mPosition = mLastPosition = position; } } IntentHelper.sAction = IntentHelper.getAction(getIntent()); if (IntentHelper.sAction == IntentHelper.ACTION_DEFAULT) { setFragment(getFragment(mPosition)); } else { setFragment(getActionFragment(IntentHelper.sAction)); } checkWallpapers(); IconRequestTask.start(this, AsyncTask.THREAD_POOL_EXECUTOR); IconsLoaderTask.start(this); new PlaystoreCheckHelper(this).run(); if (Preferences.get(this).isFirstRun() && mConfig.isLicenseCheckerEnabled()) { mLicenseHelper = new LicenseHelper(this); mLicenseHelper.run(mConfig.getLicenseKey(), mConfig.getRandomString(), new LicenseCallbackHelper(this)); return; } if (!Preferences.get(this).isPlaystoreCheckEnabled() && !mConfig.isLicenseCheckerEnabled()) { if (Preferences.get(this).isNewVersion()) { ChangelogFragment.showChangelog(mFragManager); File cache = this.getCacheDir(); FileHelper.clearDirectory(cache); } } if (mConfig.isLicenseCheckerEnabled() && !Preferences.get(this).isLicensed()) { finish(); } }
Example 7
Source File: MainActivity.java From TowerCollector with Mozilla Public License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { setTheme(MyApplication.getCurrentAppTheme()); super.onCreate(savedInstanceState); Timber.d("onCreate(): Creating activity"); // set fixed screen orientation if (!ApkUtils.isRunningOnBuggyOreoSetRequestedOrientation(this)) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setContentView(R.layout.main); activityView = findViewById(R.id.main_root); //setup toolbar Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar); toolbar.setPopupTheme(MyApplication.getCurrentPopupTheme()); setSupportActionBar(toolbar); // setup tabbed layout MainActivityPagerAdapter pageAdapter = new MainActivityPagerAdapter(getSupportFragmentManager(), getApplication()); viewPager = (ViewPager) findViewById(R.id.main_pager); viewPager.setAdapter(pageAdapter); tabLayout = (TabLayout) findViewById(R.id.main_tab_layout); tabLayout.setupWithViewPager(viewPager); tabLayout.addOnTabSelectedListener(this); backgroundTaskHelper = new BackgroundTaskHelper(this); displayNotCompatibleDialog(); // show latest developer's messages displayDevelopersMessages(); // show introduction displayIntroduction(); processOnStartIntent(getIntent()); // check for availability of new version checkForNewVersionAvailability(); registerReceiver(airplaneModeBroadcastReceiver, new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { batterySaverBroadcastReceiver = new BatterySaverBroadcastReceiver(); registerReceiver(batterySaverBroadcastReceiver, new IntentFilter(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED)); } }
Example 8
Source File: BaseActivity.java From Easy_xkcd with Apache License 2.0 | 4 votes |
/** * Sets up the colors of toolbar, status bar and nav drawer */ protected void setupToolbar(Toolbar toolbar) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Bitmap ic = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_easy_xkcd_recents); int color = themePrefs.getPrimaryColor(false); ActivityManager.TaskDescription description = new ActivityManager.TaskDescription("Easy xkcd", ic, color); setTaskDescription(description); if (!(this instanceof MainActivity)) { getWindow().setStatusBarColor(themePrefs.getPrimaryDarkColor()); } int navBarColor; int uiOptions = getWindow().getDecorView().getSystemUiVisibility(); int flagForLightNavBar = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR : 0; TypedValue backgroundColor = new TypedValue(); getTheme().resolveAttribute(android.R.attr.windowBackground, backgroundColor, true); if (themePrefs.nightThemeEnabled()) { uiOptions = uiOptions & Integer.reverse(flagForLightNavBar); if (themePrefs.amoledThemeEnabled()) { navBarColor = Color.BLACK; } else if (backgroundColor.type >= TypedValue.TYPE_FIRST_COLOR_INT && backgroundColor.type <= TypedValue.TYPE_LAST_COLOR_INT) { navBarColor = backgroundColor.data; } else { navBarColor = Color.BLACK; } } else { uiOptions = uiOptions | flagForLightNavBar; if (backgroundColor.type >= TypedValue.TYPE_FIRST_COLOR_INT && backgroundColor.type <= TypedValue.TYPE_LAST_COLOR_INT && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { navBarColor = backgroundColor.data; } else { navBarColor = Color.BLACK; } } getWindow().setNavigationBarColor(navBarColor); getWindow().getDecorView().setSystemUiVisibility(uiOptions); } setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); toolbar.setBackgroundColor(themePrefs.getPrimaryColor(false)); if (themePrefs.amoledThemeEnabled()) { toolbar.setPopupTheme(R.style.ThemeOverlay_AmoledBackground); } }