Java Code Examples for android.support.v7.widget.Toolbar#setPopupTheme()

The following examples show how to use android.support.v7.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: ToolbarHandler.java    From NightOwl with Apache License 2.0 6 votes vote down vote up
@Override
public void draw(@NonNull View view, @NonNull Object value) {
    Toolbar toolbar = (Toolbar) view;
    int themeId = (int) value;
    try {
        ActionMenuView actionMenuView = (ActionMenuView) sActionMenuViewField.get(toolbar);
        if ( actionMenuView == null ){
            toolbar.getContext().setTheme(themeId);
        } else {
            MenuPresenter presenter = (MenuPresenter) sPresenterField.get(actionMenuView);
            Context context = (Context) sContextField.get(presenter);
            context.setTheme(themeId);
        }

    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    toolbar.setPopupTheme((Integer) value);
}
 
Example 2
Source File: MainActivity.java    From SoundRecorder with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(new MyAdapter(getSupportFragmentManager()));
    tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs);
    tabs.setViewPager(pager);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setPopupTheme(R.style.ThemeOverlay_AppCompat_Light);
    if (toolbar != null) {
        setSupportActionBar(toolbar);
    }
}
 
Example 3
Source File: SettingsActivity.java    From SoundRecorder with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_preferences);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setPopupTheme(R.style.ThemeOverlay_AppCompat_Light);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setTitle(R.string.action_settings);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowHomeEnabled(true);
    }

    getFragmentManager()
            .beginTransaction()
            .replace(R.id.container, new SettingsFragment())
            .commit();
}
 
Example 4
Source File: BaseListActivity.java    From OmniList with GNU Affero General Public License v3.0 5 votes vote down vote up
private void configToolbar() {
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (!isDarkTheme()) toolbar.setPopupTheme(R.style.AppTheme_PopupOverlay);
    if (actionBar != null) {
        actionBar.setTitle(getActionbarTitle());
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeAsUpIndicator(R.drawable.ic_menu_white);
    }
}
 
Example 5
Source File: DirectoryActivity.java    From OmniList with GNU Affero General Public License v3.0 5 votes vote down vote up
private void configToolbar() {
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar ab = getSupportActionBar();
    if (!isDarkTheme()) toolbar.setPopupTheme(R.style.AppTheme_PopupOverlay);
    if (ab != null) {
        ab.setTitle(R.string.text_folder_explore);
        ab.setDisplayHomeAsUpEnabled(true);
    }
}
 
Example 6
Source File: FabSortActivity.java    From OmniList with GNU Affero General Public License v3.0 5 votes vote down vote up
private void configToolbar() {
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar ab = getSupportActionBar();
    if (ab != null) {
        ab.setTitle(R.string.fab_sort_custom_fab);
        ab.setDisplayHomeAsUpEnabled(true);
    }
    if (!isDarkTheme()) toolbar.setPopupTheme(R.style.AppTheme_PopupOverlay);
}
 
Example 7
Source File: MainActivity.java    From OmniList with GNU Affero General Public License v3.0 5 votes vote down vote up
private void configToolbar() {
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeAsUpIndicator(R.drawable.ic_menu_white);
    }
    if (!isDarkTheme()) toolbar.setPopupTheme(R.style.AppTheme_PopupOverlay);
}
 
Example 8
Source File: SettingsActivity.java    From OmniList with GNU Affero General Public License v3.0 5 votes vote down vote up
private void configToolbar() {
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setTitle(R.string.text_settings);
    }
    if (!isDarkTheme()) {
        toolbar.setPopupTheme(R.style.AppTheme_PopupOverlay);
    }
}
 
Example 9
Source File: UserInfoActivity.java    From OmniList with GNU Affero General Public License v3.0 5 votes vote down vote up
private void configToolbar() {
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setTitle(R.string.user_info);
    }
    if (!isDarkTheme()) toolbar.setPopupTheme(R.style.AppTheme_PopupOverlay);
}
 
Example 10
Source File: BaseActivity.java    From KA27 with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Check if darktheme is in use and cache it as boolean
    if (Utils.DARKTHEME = Utils.getBoolean("darktheme", false, this)) {
        super.setTheme(getDarkTheme());
        getWindow().getDecorView().getRootView().setBackgroundColor(ContextCompat.getColor(this, R.color.black));
    }

    if (getParentViewId() != 0) setContentView(getParentViewId());
    else if (getParentView() != null) setContentView(getParentView());

    Toolbar toolbar;
    if ((toolbar = getToolbar()) != null) {
        if (Utils.DARKTHEME) toolbar.setPopupTheme(R.style.ThemeOverlay_AppCompat_Dark);
        try {
            setSupportActionBar(toolbar);
        } catch (NoClassDefFoundError e) {
            Utils.toast(e.getMessage(), this, Toast.LENGTH_LONG);
            finish();
        }
    }

    ActionBar actionBar;
    if ((actionBar = getSupportActionBar()) != null)
        actionBar.setDisplayHomeAsUpEnabled(getDisplayHomeAsUpEnabled());

    setStatusBarColor();
}
 
Example 11
Source File: ThemeManager.java    From OneTapVideoDownload with GNU General Public License v3.0 5 votes vote down vote up
public static void applyTheme(AppCompatActivity activity) {
    activity.setTheme(ThemeManager.getTheme(activity));
    Toolbar toolbar = activity.findViewById(R.id.toolbar);
    toolbar.setBackgroundColor(ThemeManager.getPrimaryColor(activity));
    toolbar.setPopupTheme(getPopupMenuTheme(activity));
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        activity.getWindow().setStatusBarColor(ThemeManager.getPrimaryDarkColor(activity));
        activity.getWindow().setNavigationBarColor(ThemeManager.getNavigationBarColor(activity));
    }
}
 
Example 12
Source File: BaseActivity.java    From kernel_adiutor with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Set english as default language if option is enabled
    if (Utils.getBoolean("forceenglish", false, this)) Utils.setLocale("en_US", this);

    // Check if darktheme is in use and cache it as boolean
    if (Utils.DARKTHEME = Utils.getBoolean("darktheme", false, this)) {
        super.setTheme(getDarkTheme());
        getWindow().getDecorView().getRootView().setBackgroundColor(getResources().getColor(R.color.black));
    }

    if (getParentViewId() != 0) setContentView(getParentViewId());
    else if (getParentView() != null) setContentView(getParentView());

    Toolbar toolbar;
    if ((toolbar = getToolbar()) != null) {
        if (Utils.DARKTHEME) toolbar.setPopupTheme(R.style.ThemeOverlay_AppCompat_Dark);
        try {
            setSupportActionBar(toolbar);
        } catch (NoClassDefFoundError e) {
            Utils.toast(e.getMessage(), this, Toast.LENGTH_LONG);
            finish();
        }
    }

    ActionBar actionBar;
    if ((actionBar = getSupportActionBar()) != null)
        actionBar.setDisplayHomeAsUpEnabled(getDisplayHomeAsUpEnabled());

    setStatusBarColor();
}
 
Example 13
Source File: TumblrPager.java    From Slide with GNU General Public License v3.0 5 votes vote down vote up
public void onCreate(Bundle savedInstanceState) {
    overrideSwipeFromAnywhere();
    super.onCreate(savedInstanceState);
    getTheme().applyStyle(
            new ColorPreferences(this).getDarkThemeSubreddit(ColorPreferences.FONT_STYLE),
            true);
    setContentView(R.layout.album_pager);

    //Keep the screen on
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    mToolbar.setTitle(R.string.type_album);
    ToolbarColorizeHelper.colorizeToolbar(mToolbar, Color.WHITE, this);
    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    if(getIntent().hasExtra(SUBREDDIT)){
        this.subreddit = getIntent().getStringExtra(SUBREDDIT);
    }

    mToolbar.setPopupTheme(
            new ColorPreferences(this).getDarkThemeSubreddit(ColorPreferences.FONT_STYLE));

    adapterPosition = getIntent().getIntExtra(MediaView.ADAPTER_POSITION, -1);

    String url = getIntent().getExtras().getString("url", "");
    setShareUrl(url);
    new LoadIntoPager(url, this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

    if (!Reddit.appRestart.contains("tutorialSwipe")) {
        startActivityForResult(new Intent(this, SwipeTutorial.class), 3);
    }

}
 
Example 14
Source File: AlbumPager.java    From Slide with GNU General Public License v3.0 5 votes vote down vote up
public void onCreate(Bundle savedInstanceState) {
    overrideSwipeFromAnywhere();
    super.onCreate(savedInstanceState);
    getTheme().applyStyle(
            new ColorPreferences(this).getDarkThemeSubreddit(ColorPreferences.FONT_STYLE),
            true);
    setContentView(R.layout.album_pager);

    //Keep the screen on
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    if(getIntent().hasExtra(SUBREDDIT)){
        this.subreddit = getIntent().getStringExtra(SUBREDDIT);
    }

    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    mToolbar.setTitle(R.string.type_album);
    ToolbarColorizeHelper.colorizeToolbar(mToolbar, Color.WHITE, this);
    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mToolbar.setPopupTheme(
            new ColorPreferences(this).getDarkThemeSubreddit(ColorPreferences.FONT_STYLE));

    adapterPosition = getIntent().getIntExtra(MediaView.ADAPTER_POSITION, -1);

    String url = getIntent().getExtras().getString("url", "");
    setShareUrl(url);
    pagerLoad = new LoadIntoPager(url, this);
    pagerLoad.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

    if (!Reddit.appRestart.contains("tutorialSwipe")) {
        startActivityForResult(new Intent(this, SwipeTutorial.class), 3);
    }

}
 
Example 15
Source File: CandyBarMainActivity.java    From candybar-library with Apache License 2.0 4 votes vote down vote up
@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));
    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);
    }

    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);

    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).isNewVersion())
        ChangelogFragment.showChangelog(mFragManager);

    if (mConfig.isLicenseCheckerEnabled() && !Preferences.get(this).isLicensed()) {
        finish();
    }
}
 
Example 16
Source File: PickerActivity.java    From MultiImagePicker with MIT License 4 votes vote down vote up
private void initTheme() {
    setTheme(mPickOptions.themeResId);
    mToolbar = new Toolbar(new ContextThemeWrapper(mPickOptions.context, Util.getToolbarThemeResId(this)));
    mToolbar.setPopupTheme(mPickOptions.popupThemeResId);
}