Java Code Examples for android.support.v7.app.ActionBar#setHomeButtonEnabled()

The following examples show how to use android.support.v7.app.ActionBar#setHomeButtonEnabled() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my_workflows);

    ButterKnife.bind(this);

    setSupportActionBar(mToolbar);
    ActionBar actionbar = getSupportActionBar();

    if (actionbar != null) {
        actionbar.setHomeButtonEnabled(true);
        actionbar.setDisplayHomeAsUpEnabled(true);
        actionbar.setTitle(R.string.title_nav_my_workflows);
    }

    if (savedInstanceState == null) {
        ActivityUtils.addFragmentToActivity(getSupportFragmentManager(),
                new MyWorkflowFragment(), R.id.frame_container);
    }
}
 
Example 2
@Override
protected void onStart() {
    super.onStart();

    mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawer, 0, 0);
    mDrawer.setDrawerListener(mDrawerToggle);

    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowHomeEnabled(true);
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setDisplayUseLogoEnabled(false);
        actionBar.setHomeButtonEnabled(true);
    }
}
 
Example 3
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.dialog_book_info_read_more, container, false);

    Bundle args = getArguments();
    String title = args.getString(KEY_DIALOG_FRAGMENT_TITLE, getResources().getString(R.string.authors));
    Toolbar toolbar = rootView.findViewById(R.id.toolbar);
    toolbar.setTitle(title);

    ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);

    ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);

        Drawable drawable = getResources()
                .getDrawable(R.drawable.ic_close_white_24dp);
        drawable = DrawableCompat.wrap(drawable);
        DrawableCompat.setTint(drawable, Color.WHITE);
        actionBar.setHomeAsUpIndicator(drawable);
    }


    String body = args.getString(KEY_DIALOG_BODY, getResources().getString(R.string.authors));
    TextView bodyTextView = rootView.findViewById(R.id.more_dialog_body_text_view);
    bodyTextView.setText(body);
    setHasOptionsMenu(true);
    return rootView;
}
 
Example 4
Source Project: multi-copy   File: NewNoteActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_note_edit_actvity);
    Toolbar toolbar = (Toolbar) findViewById(R.id.my_toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);
    actionBar.setTitle("New Note");
    toolbar.setTitleTextColor(Color.WHITE);
    etNotes = (EditText) findViewById(R.id.etNoteEdit);
}
 
Example 5
private void initCustomActionBar() {
    ActionBar actionBar = getSupportActionBar();
    actionBar.setHomeButtonEnabled(false);
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayHomeAsUpEnabled(false);
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setCustomView(R.layout.material_menu_action_bar);
    materialMenu = (MaterialMenuView) actionBar.getCustomView().findViewById(R.id.action_bar_menu);
    materialMenu.setOnClickListener(this);
}
 
Example 6
Source Project: BlueBoard   File: ViewUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 显示Toolbar 默认标题
 */
public static void setToolbar(AppCompatActivity context, Toolbar toolbar, Boolean WithHomeButton) {
    context.setSupportActionBar(toolbar);
    if (WithHomeButton) {
        ActionBar actionBar = context.getSupportActionBar();
        if (actionBar != null) {
            actionBar.setHomeButtonEnabled(true);
            actionBar.setDisplayHomeAsUpEnabled(true);
        }
    }
}
 
Example 7
Source Project: Nimingban   File: AbsActivity.java    License: Apache License 2.0 5 votes vote down vote up
public void setActionBarUpIndicator(Drawable drawable) {
    ActionBarDrawerToggle.Delegate delegate = getDrawerToggleDelegate();
    if (delegate != null) {
        delegate.setActionBarUpIndicator(drawable, 0);
    }
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
    }
}
 
Example 8
Source Project: droidkaigi2016   File: SearchActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void initToolbar() {
    setSupportActionBar(binding.searchToolbar.getToolbar());

    ActionBar bar = getSupportActionBar();
    if (bar != null) {
        bar.setDisplayHomeAsUpEnabled(true);
        bar.setDisplayShowHomeEnabled(true);
        bar.setDisplayShowTitleEnabled(false);
        bar.setHomeButtonEnabled(true);
    }

    binding.searchToolbar.addTextChangedListener(this);
    binding.searchToolbar.setOnEditorActionListener(this);
}
 
Example 9
private void setupToolbar() {
    mToolbar = ButterKnife.findById(this, R.id.toolbar);
    if(mToolbar == null) {
        LOGD(this, "Didn't find a toolbar");
        return;
    }
    setSupportActionBar(mToolbar);
    ActionBar actionBar = getSupportActionBar();
    if(actionBar == null) return;
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);
}
 
Example 10
Source Project: UltimateAndroid   File: ListFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onResume() {
    super.onResume();

    ActionBar actionBar = ((ProgressLayoutActivity) getActivity()).getSupportActionBar();

    actionBar.setDisplayHomeAsUpEnabled(false);
    actionBar.setHomeButtonEnabled(false);
}
 
Example 11
private void initToolbar(String title) {
    setSupportActionBar(binding.toolbar);

    ActionBar bar = getSupportActionBar();
    if (bar != null) {
        bar.setDisplayHomeAsUpEnabled(true);
        bar.setDisplayShowHomeEnabled(true);
        bar.setDisplayShowTitleEnabled(false);
        bar.setHomeButtonEnabled(true);
    }

    binding.toolbar.setTitle(title);
}
 
Example 12
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    currentThemeIsDark = App.get().isDarkTheme();
    setTheme(currentThemeIsDark ? R.style.PreferenceAppThemeDark : R.style.PreferenceAppThemeLight);
    setContentView(R.layout.activity_settings);

    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setHomeButtonEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setTitle(R.string.activity_title_settings);
    }
    PreferenceFragmentCompat fragment = null;
    Intent intent = getIntent();
    if (intent != null) {
        String settingsArgument = intent.getStringExtra(ARG_NEW_PREFERENCE_SCREEN);
        if (settingsArgument != null) {
            if (settingsArgument.equals(NotificationsSettingsFragment.PREFERENCE_SCREEN_NAME)) {
                fragment = new NotificationsSettingsFragment();
            }
        }
    }
    if (fragment == null) {
        fragment = new SettingsFragment();
    }

    getSupportFragmentManager().beginTransaction().replace(R.id.fragment_content, fragment).commit();

    /*View view = findViewById(R.id.fragment_content);
    view.setBackgroundColor(Color.TRANSPARENT);
    view.setBackgroundColor(Color.rgb(4, 26, 55));*/

    App.get().addPreferenceChangeObserver(appThemeChangeObserver);
}
 
Example 13
Source Project: Paginate   File: BaseActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void setupBasicUI() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);
    actionBar.setDisplayShowTitleEnabled(false);

    DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.drawer_open, R.string.drawer_closed);
    drawerLayout.setDrawerListener(drawerToggle);
    drawerToggle.syncState();
}
 
Example 14
private void initToolbar(SearchGroup searchGroup) {
    setSupportActionBar(binding.toolbar);

    ActionBar bar = getSupportActionBar();
    if (bar != null) {
        bar.setDisplayHomeAsUpEnabled(true);
        bar.setDisplayShowHomeEnabled(true);
        bar.setDisplayShowTitleEnabled(false);
        bar.setHomeButtonEnabled(true);
    }

    binding.toolbar.setTitle(searchGroup.getName());
}
 
Example 15
Source Project: Hews   File: CommentsActivity.java    License: MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Set theme
    prefs = PreferenceManager.getDefaultSharedPreferences(this);
    String theme = SharedPrefsManager.getTheme(prefs);
    switch (theme) {
        case SharedPrefsManager.THEME_SEPIA:
            setTheme(R.style.AppTheme_Sepia);
            break;
        case SharedPrefsManager.THEME_DARK:
            setTheme(R.style.AppTheme_Dark);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                getWindow().setStatusBarColor(getResources().getColor(R.color.grey_900));
            }
            break;
        case SharedPrefsManager.THEME_AMOLED_BLACK:
            setTheme(R.style.AppTheme_AMOLEDBlack);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                getWindow().setStatusBarColor(getResources().getColor(android.R.color.black));
            }
            break;
    }
    setContentView(R.layout.activity_comments);
    Firebase.setAndroidContext(this);
    appbar = (AppBarLayout) findViewById(R.id.appbar);
    appbar.addOnOffsetChangedListener(this);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setTitle("Comments");
        actionBar.setHomeButtonEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    mWindow = new PopupFloatingWindow(this, toolbar);
    mFab = (FloatingScrollDownButton) findViewById(R.id.fab);
    coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinator_layout);
    layoutReply = (LinearLayout) findViewById(R.id.layout_reply);
    btnReplySend = (FloatingActionButton) findViewById(R.id.btn_reply_send);
    etReply = (EditText) findViewById(R.id.et_reply);

    Intent intent = getIntent();
    CommentsFragment commentsFragment = null;
    Parcelable postParcel = intent.getParcelableExtra(Constants.KEY_POST_PARCEL);
    if (postParcel != null) {
        commentsFragment = CommentsFragment.newInstance(postParcel,
            intent.getBooleanExtra(Constants.KEY_IS_BOOKMARKED, false));
        Post post = Parcels.unwrap(postParcel);
        //FIXME how the url could be null?!
        mUrl = (post.getUrl() != null ? post.getUrl() : "https://news.ycombinator.com/");
        mPostId = post.getId();
    } else {
        final Uri data = intent.getData();
        if (data != null && data.getQueryParameter("id") != null) {
            long storyId = Long.parseLong(data.getQueryParameter("id"));
            commentsFragment = CommentsFragment.newInstance(storyId);
            mPostId = storyId;
        }
    }

    if (savedInstanceState == null) {
        if (commentsFragment != null) {
            getFragmentManager().beginTransaction()
                .add(R.id.container, commentsFragment, Constants.FRAGMENT_TAG_COMMENT)
                .commit();
        }
    }

    mDataManager = new DataManager();
    mCompositeSubscription = new CompositeSubscription();
}
 
Example 16
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(getLayoutResId());

    mToolbar = (Toolbar) findViewById(R.id.toolbar);

    setSupportActionBar(mToolbar);
    ViewHelper.setScaleY(mToolbar, 0);
    ActionBar ab = getSupportActionBar();
    if (ab != null) {
        ab.setHomeButtonEnabled(true);
        ab.setDisplayHomeAsUpEnabled(true);
        ab.setTitle("");
    }

    mToolbarColor = getResources().getColor(R.color.primary);
    mToolbar.setBackgroundColor(Color.TRANSPARENT);
    mToolbar.setTitle("");

    mFlexibleSpaceImageHeight = getResources().getDimensionPixelSize(R.dimen.flexible_space_image_height);
    mIntersectionHeight = getResources().getDimensionPixelSize(R.dimen.intersection_height);
    mHeaderBarHeight = getResources().getDimensionPixelSize(R.dimen.header_bar_height);
    mSlidingSlop = getResources().getDimensionPixelSize(R.dimen.sliding_slop);
    mActionBarSize = getActionBarSize();
    mColorPrimary = getResources().getColor(R.color.primary);
    mSlidingHeaderBlueSize = getResources().getDimensionPixelSize(R.dimen.sliding_overlay_blur_size);

    mHeader = findViewById(R.id.header);
    mHeaderBar = findViewById(R.id.header_bar);
    mHeaderOverlay = findViewById(R.id.header_overlay);
    mHeaderFlexibleSpace = findViewById(R.id.header_flexible_space);
    mImageView = findViewById(R.id.image);
    mImageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            slideOnClick();
        }
    });
    mScrollable = createScrollable();

    mFab = findViewById(R.id.fab);
    mFab.setOnClickListener(fabClickListener);
    mFabMargin = getResources().getDimensionPixelSize(R.dimen.margin_standard);

    mInterceptionLayout = (TouchInterceptionFrameLayout) findViewById(R.id.scroll_wrapper);
    mInterceptionLayout.setScrollInterceptionListener(mInterceptionListener);
    mTitle = (TextView) findViewById(R.id.title);
    mTitle.setText(getTitle());
    mToolbarTitle = (TextView) findViewById(R.id.toolbar_title);
    mToolbarTitle.setText(mTitle.getText());
    ViewHelper.setAlpha(mToolbarTitle, 0);
    ViewHelper.setTranslationY(mTitle, (mHeaderBarHeight - mActionBarSize) / 2);

    if (savedInstanceState == null) {
        mSlidingState = SLIDING_STATE_BOTTOM;
    }

    ScrollUtils.addOnGlobalLayoutListener(mInterceptionLayout, new Runnable() {
        @Override
        public void run() {
            if (mFab != null) {
                ViewHelper.setTranslationX(mFab, mTitle.getWidth() - mFabMargin - mFab.getWidth());
                ViewHelper.setTranslationY(mFab, ViewHelper.getX(mTitle) - (mFab.getHeight() / 2));
            }
            changeSlidingState(mSlidingState, false);
        }
    });
}
 
Example 17
private void initViews() {
        ActionBar actionBar = getSupportActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);
        // actionBar.setHomeAsUpIndicator(R.drawable.ic_drawer);
        actionBar.setHomeButtonEnabled(true);
//        actionBar.setDisplayShowHomeEnabled(false);
        mPlanetTitles = getResources().getStringArray(R.array.items_name);
        mTitle = mDrawerTitle = getTitle();

        mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
                R.string.drawer_open, R.string.drawer_close) {

            /** Called when a drawer has settled in a completely closed state. */
            public void onDrawerClosed(View view) {
                super.onDrawerClosed(view);
                getSupportActionBar().setTitle(mTitle);
                invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
            }

            /** Called when a drawer has settled in a completely open state. */
            public void onDrawerOpened(View drawerView) {
                super.onDrawerOpened(drawerView);
                getSupportActionBar().setTitle(mDrawerTitle);
                invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
            }
        };

        // Set the drawer toggle as the DrawerListener
        Logs.d("mDrawerLayout  " + (mDrawerLayout != null)
                + "    " + "mDrawerToggle  " + (mDrawerToggle != null));
        mDrawerLayout.setDrawerListener(mDrawerToggle);
        //mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.CLIP_VERTICAL);
        //mDrawerLayout.setScrimColor(getResources().getColor(R.color.babyBlueColor));
//        mDrawerList.setAdapter(new ArrayAdapter<String>(this,
//                R.layout.left_menu, mPlanetTitles));
        //mDrawerList.setAdapter(new SimpleAdapter(this,null,R.layout.left_menu_layout,null,null));
        mDrawerList.setAdapter(new ArrayAdapter<String>(this,
                R.layout.left_menu_layout, mPlanetTitles));
        // Set the list's click listener
        mDrawerList.setOnItemClickListener(new DrawerItemClickListener());

        // getSupportParentActivityIntent();
    }
 
Example 18
private void initViews() {
        ActionBar actionBar = getSupportActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);
        // actionBar.setHomeAsUpIndicator(R.drawable.ic_drawer);
        actionBar.setHomeButtonEnabled(true);
//        actionBar.setDisplayShowHomeEnabled(false);
        mPlanetTitles = getResources().getStringArray(R.array.items_name);
        mTitle = mDrawerTitle = getTitle();

        mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
                R.string.drawer_open, R.string.drawer_close) {

            /** Called when a drawer has settled in a completely closed state. */
            public void onDrawerClosed(View view) {
                super.onDrawerClosed(view);
                getSupportActionBar().setTitle(mTitle);
                invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
            }

            /** Called when a drawer has settled in a completely open state. */
            public void onDrawerOpened(View drawerView) {
                super.onDrawerOpened(drawerView);
                getSupportActionBar().setTitle(mDrawerTitle);
                invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
            }
        };

        // Set the drawer toggle as the DrawerListener
        Logs.d("mDrawerLayout  " + (mDrawerLayout != null)
                + "    " + "mDrawerToggle  " + (mDrawerToggle != null));
        mDrawerLayout.setDrawerListener(mDrawerToggle);
        //mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.CLIP_VERTICAL);
        //mDrawerLayout.setScrimColor(getResources().getColor(R.color.babyBlueColor));
//        mDrawerList.setAdapter(new ArrayAdapter<String>(this,
//                R.layout.left_menu, mPlanetTitles));
        //mDrawerList.setAdapter(new SimpleAdapter(this,null,R.layout.left_menu_layout,null,null));
        mDrawerList.setAdapter(new ArrayAdapter<String>(this,
                R.layout.left_menu_layout, mPlanetTitles));
        // Set the list's click listener
        mDrawerList.setOnItemClickListener(new DrawerItemClickListener());

        // getSupportParentActivityIntent();
    }
 
Example 19
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setTitle("");
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);
    getMenuInflater().inflate(R.menu.menu_search, menu);
    // Get the SearchView and set the searchable configuration
    final MaterialSuggestionsSearchView materialSearchView =
            findViewById(R.id.material_search_view);
    materialSearchView.setOnQueryTextListener(new MaterialSearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(final String query) {
            materialSearchView.setSuggestions(null);
            materialSearchView.requestFocus();
            materialSearchView.post(() -> ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE))
                    .hideSoftInputFromWindow(materialSearchView.getWindowToken(), 0));
            materialSearchView.postDelayed(() -> {
                SearchActivity.this.searchQuery = query;
                refresh();
            }, 90);
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return true;
        }
    });

    materialSearchView.setOnSearchViewListener(new MaterialSearchView.SearchViewListener() {
        @Override
        public void onSearchViewShown() {
        }

        @Override
        public void onSearchViewClosed() {
            onBackPressed();
        }
    });
    materialSearchView.setMenuItem(menu.findItem(R.id.search_view));
    materialSearchView.setHint(getResources().getString(R.string.search_hint));
    materialSearchView.showSearch();
    materialSearchView.setQuery(this.searchQuery, false);
    return true;
}
 
Example 20
/**
 * {@inheritDoc}
 */
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mFragmentContainerView = getActivity().findViewById(mDrawerConfig.fragmentContainerId);
    View view = getActivity().findViewById(mDrawerConfig.drawerLayoutViewId);
    if (view != null && view instanceof DrawerLayout) {
        mDrawerLayout = (DrawerLayout)view;
    }

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);

    if (mDrawerLayout != null) {

        // set a custom shadow that overlays the main content when the drawer opens
        if (mDrawerConfig.drawerShadowResourceId != 0)
            mDrawerLayout.setDrawerShadow(mDrawerConfig.drawerShadowResourceId, GravityCompat.START);

        createActionBarDrawerToggle();

        // If the user hasn't 'learned' about the drawer, open it to introduce them to the drawer,
        // per the navigation drawer design guidelines.
        if (!mUserLearnedDrawer && !mFromSavedInstanceState) {
            mDrawerLayout.openDrawer(mFragmentContainerView);
        }

        // Defer code dependent on restoration of previous instance state.
        mDrawerLayout.post(new Runnable() {
            @Override
            public void run() {
                mDrawerToggle.syncState();
            }
        });

        mDrawerLayout.setDrawerListener(mDrawerToggle);
    }

    initUpIcon();

}