List of usage examples for android.view MenuItem setTitle
public MenuItem setTitle(@StringRes int title);
From source file:org.mariotaku.twidere.fragment.support.UserFragment.java
@Override public void onPrepareOptionsMenu(final Menu menu) { final AsyncTwitterWrapper twitter = getTwitterWrapper(); final ParcelableUser user = getUser(); final Relationship relationship = mRelationship; if (twitter == null || user == null) return;/*from ww w.j av a 2 s . c o m*/ final boolean isMyself = user.account_id == user.id; final MenuItem mentionItem = menu.findItem(MENU_MENTION); if (mentionItem != null) { final String displayName = mUserColorNameManager.getDisplayName(user, mNameFirst, true); mentionItem.setTitle(getString(R.string.mention_user_name, displayName)); } MenuUtils.setMenuItemAvailability(menu, MENU_MENTION, !isMyself); MenuUtils.setMenuItemAvailability(menu, R.id.incoming_friendships, isMyself); MenuUtils.setMenuItemAvailability(menu, R.id.saved_searches, isMyself); // final MenuItem followItem = menu.findItem(MENU_FOLLOW); // followItem.setVisible(!isMyself); // final boolean shouldShowFollowItem = !creatingFriendship && !destroyingFriendship && !isMyself // && relationship != null; // followItem.setEnabled(shouldShowFollowItem); // if (shouldShowFollowItem) { // followItem.setTitle(isFollowing ? R.string.unfollow : isProtected ? R.string.send_follow_request // : R.string.follow); // followItem.setIcon(isFollowing ? R.drawable.ic_action_cancel : R.drawable.ic_action_add); // } else { // followItem.setTitle(null); // followItem.setIcon(null); // } if (!isMyself && relationship != null) { MenuUtils.setMenuItemAvailability(menu, MENU_SEND_DIRECT_MESSAGE, relationship.canSourceDMTarget()); MenuUtils.setMenuItemAvailability(menu, MENU_BLOCK, true); MenuUtils.setMenuItemAvailability(menu, MENU_MUTE_USER, true); final MenuItem blockItem = menu.findItem(MENU_BLOCK); if (blockItem != null) { final boolean blocking = relationship.isSourceBlockingTarget(); ActionIconDrawable.setMenuHighlight(blockItem, new TwidereMenuInfo(blocking)); blockItem.setTitle(blocking ? R.string.unblock : R.string.block); } final MenuItem muteItem = menu.findItem(MENU_MUTE_USER); if (muteItem != null) { final boolean muting = relationship.isSourceMutingTarget(); ActionIconDrawable.setMenuHighlight(muteItem, new TwidereMenuInfo(muting)); muteItem.setTitle(muting ? R.string.unmute : R.string.mute); } final MenuItem filterItem = menu.findItem(MENU_ADD_TO_FILTER); if (filterItem != null) { final boolean filtering = Utils.isFilteringUser(getActivity(), user.id); ActionIconDrawable.setMenuHighlight(filterItem, new TwidereMenuInfo(filtering)); filterItem.setTitle(filtering ? R.string.remove_from_filter : R.string.add_to_filter); } final MenuItem wantRetweetsItem = menu.findItem(MENU_ENABLE_RETWEETS); if (wantRetweetsItem != null) { wantRetweetsItem.setChecked(relationship.isSourceWantRetweetsFromTarget()); } } else { MenuUtils.setMenuItemAvailability(menu, MENU_SEND_DIRECT_MESSAGE, false); MenuUtils.setMenuItemAvailability(menu, MENU_ENABLE_RETWEETS, false); MenuUtils.setMenuItemAvailability(menu, MENU_BLOCK, false); MenuUtils.setMenuItemAvailability(menu, MENU_MUTE_USER, false); MenuUtils.setMenuItemAvailability(menu, MENU_REPORT_SPAM, false); } MenuUtils.setMenuItemAvailability(menu, R.id.muted_users, isMyself); MenuUtils.setMenuItemAvailability(menu, R.id.blocked_users, isMyself); final Intent intent = new Intent(INTENT_ACTION_EXTENSION_OPEN_USER); final Bundle extras = new Bundle(); extras.putParcelable(EXTRA_USER, user); intent.putExtras(extras); menu.removeGroup(MENU_GROUP_USER_EXTENSION); Utils.addIntentToMenu(getActivity(), menu, intent, MENU_GROUP_USER_EXTENSION); final HeaderDrawerLayout drawer = mHeaderDrawerLayout; if (drawer != null) { final int offset = drawer.getPaddingTop() - drawer.getHeaderTop(); mPreviousActionBarItemIsDark = 0; mPreviousTabItemIsDark = 0; updateScrollOffset(offset); } }
From source file:com.github.akinaru.hcidebugger.activity.HciDebuggerActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { boolean ret = super.onPrepareOptionsMenu(menu); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { toolbar.getMenu().findItem(R.id.scan_btn).setVisible(false); toolbar.getMenu().findItem(R.id.state_bt_btn).setVisible(false); toolbar.getMenu().findItem(R.id.reset_snoop_file).setVisible(false); nvDrawer.getMenu().findItem(R.id.scan_btn_nv).setVisible(true); if (mScanType == ScanType.CLASSIC_SCAN) { nvDrawer.getMenu().findItem(R.id.change_settings) .setTitle(getString(R.string.scan_settings_type_classic_scan)); } else {// w w w . j a va2 s. c o m nvDrawer.getMenu().findItem(R.id.change_settings) .setTitle(getString(R.string.scan_settings_type_ble_scan)); } if (Build.VERSION.SDK_INT <= 22) { nvDrawer.getMenu().findItem(R.id.reset_snoop_file_nv).setVisible(true); } MenuItem stateBtn = nvDrawer.getMenu().findItem(R.id.state_bt_btn_nv); stateBtn.setVisible(true); if (mBluetoothAdapter.isEnabled()) { stateBtn.setIcon(R.drawable.ic_bluetooth); } else { stateBtn.setIcon(R.drawable.ic_bluetooth_disabled); } stateBtn.setTitle(getResources().getString(R.string.menu_item_title_enable_bluetooth_portrait)); } return ret; }
From source file:cgeo.geocaching.cgeocaches.java
private void setMenuItemLabel(final Menu menu, final int menuId, final int resIdSelection, final int resId) { final MenuItem menuItem = menu.findItem(menuId); if (menuItem == null) { return;/*www . j ava 2 s . c o m*/ } boolean hasSelection = adapter != null && adapter.getCheckedCount() > 0; if (hasSelection) { menuItem.setTitle(res.getString(resIdSelection) + " (" + adapter.getCheckedCount() + ")"); } else { menuItem.setTitle(res.getString(resId)); } }
From source file:com.github.akinaru.hcidebugger.activity.HciDebuggerActivity.java
private void startScanSetup() { MenuItem item; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { item = nvDrawer.getMenu().findItem(R.id.scan_btn_nv); } else {//from w ww .java 2 s . c o m item = toolbar.getMenu().findItem(R.id.scan_btn); } if (item != null) { item.setIcon(R.drawable.ic_portable_wifi_off); item.setTitle(getResources().getString(R.string.menu_item_title_stop_scan)); } Toast.makeText(HciDebuggerActivity.this, getResources().getString(R.string.toast_scan_start), Toast.LENGTH_SHORT).show(); }
From source file:com.openatk.planting.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. if (addIsShowing == 1) { if (mCurrentState == STATE_LIST_VIEW) { getMenuInflater().inflate(R.menu.add_field_list_view, menu); } else {/* w ww. j a v a 2 s. co m*/ getMenuInflater().inflate(R.menu.add_field, menu); } } else if (mCurrentState == STATE_LIST_VIEW) { getMenuInflater().inflate(R.menu.list_view, menu); } else { getMenuInflater().inflate(R.menu.main, menu); } this.menu = menu; MenuItem layers = menu.findItem(R.id.main_menu_layers); if (layers != null) { if (showingHazards == true) { layers.setTitle("Hide Hazards"); } else { layers.setTitle("Show Hazards"); } } return true; }
From source file:com.geecko.QuickLyric.fragment.LyricsViewFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); MainActivity mainActivity = (MainActivity) getActivity(); if (mainActivity == null) return;/*w ww . j a va2s .c om*/ CollapsingToolbarLayout toolbarLayout = (CollapsingToolbarLayout) mainActivity .findViewById(R.id.toolbar_layout); toolbarLayout.setTitle(getString(R.string.app_name)); if (((DrawerLayout) mainActivity.drawer) // drawer is locked .getDrawerLockMode(mainActivity.drawerView) == DrawerLayout.LOCK_MODE_LOCKED_CLOSED) return; inflater.inflate(lyrics, menu); // Get the SearchView and set the searchable configuration final MaterialSuggestionsSearchView materialSearchView = (MaterialSuggestionsSearchView) mainActivity .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(new Runnable() { @Override public void run() { ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(materialSearchView.getWindowToken(), 0); } }); materialSearchView.postDelayed(new Runnable() { @Override public void run() { ((MainActivity) getActivity()).search(query); materialSearchView.setSuggestions(null); } }, 90); mExpandedSearchView = false; return true; } @Override public boolean onQueryTextChange(String newText) { if (!materialSearchView.hasSuggestions()) materialSearchView.setSuggestions(materialSearchView.getHistory()); return true; } }); materialSearchView.setOnSearchViewListener(new MaterialSearchView.SearchViewListener() { @Override public void onSearchViewShown() { if (getActivity() == null) return; ((ControllableAppBarLayout) getActivity().findViewById(R.id.appbar)).expandToolbar(true); mExpandedSearchView = true; } @Override public void onSearchViewClosed() { mExpandedSearchView = false; } }); final Resources resources = getResources(); final int resourceId = resources.getIdentifier("status_bar_height", "dimen", "android"); int statusBarHeight; if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP) statusBarHeight = 0; else if (resourceId > 0) statusBarHeight = resources.getDimensionPixelSize(resourceId); else statusBarHeight = (int) Math.ceil((Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? 24 : 25) * resources.getDisplayMetrics().density); CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) materialSearchView.getLayoutParams(); lp.setMargins(lp.leftMargin, statusBarHeight, lp.rightMargin, lp.bottomMargin); materialSearchView.setLayoutParams(lp); MenuItem searchItem = menu.findItem(R.id.action_search); materialSearchView.setMenuItem(searchItem); if (!materialSearchView.isSearchOpen() && mExpandedSearchView) { materialSearchView.showSearch(); mExpandedSearchView = false; } else if (!mExpandedSearchView) materialSearchView.closeSearch(); materialSearchView.setHint(getString(R.string.search_hint)); if (mSearchQuery != null && !mSearchQuery.equals("")) { searchItem.expandActionView(); materialSearchView.setQuery(mSearchQuery, false); if (mSearchFocused) materialSearchView.requestFocus(); else materialSearchView.clearFocus(); mSearchQuery = null; } Lyrics storedLyrics = mLyrics == null ? null : DatabaseHelper.getInstance(getActivity()).get(new String[] { mLyrics.getArtist(), mLyrics.getTitle(), mLyrics.getOriginalArtist(), mLyrics.getOriginalTrack() }); MenuItem saveMenuItem = menu.findItem(R.id.save_action); if (saveMenuItem != null) { SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity()); if (mLyrics == null) saveMenuItem.setVisible(false); else if (mLyrics.getFlag() == Lyrics.POSITIVE_RESULT && sharedPref.getBoolean("pref_auto_save", true)) { if (storedLyrics == null || (mLyrics.isLRC() && !storedLyrics.isLRC())) { lyricsPresentInDB = true; new WriteToDatabaseTask().execute(this, saveMenuItem, mLyrics); } saveMenuItem.setVisible(false); } else { saveMenuItem.setIcon(lyricsPresentInDB ? R.drawable.ic_trash : R.drawable.ic_save); saveMenuItem.setTitle(lyricsPresentInDB ? R.string.remove_action : R.string.save_action); } } MenuItem resyncMenuItem = menu.findItem(R.id.resync_action); MenuItem convertMenuItem = menu.findItem(R.id.convert_action); if (resyncMenuItem != null) resyncMenuItem.setVisible(mLyrics != null && mLyrics.isLRC()); if (convertMenuItem != null) { Lyrics stored = mLyrics == null || mLyrics.isLRC() ? null : storedLyrics; convertMenuItem .setVisible((mLyrics != null && (mLyrics.isLRC())) || (stored != null && stored.isLRC())); convertMenuItem.setTitle(stored == null ? R.string.full_text_action : R.string.pref_lrc); } MenuItem shareMenuItem = menu.findItem(R.id.share_action); if (shareMenuItem != null) shareMenuItem.setVisible( mLyrics != null && mLyrics.getFlag() == Lyrics.POSITIVE_RESULT && mLyrics.getURL() != null); }
From source file:github.popeen.dsub.activity.SubsonicActivity.java
private void populateTabs() { drawerList.getMenu().clear();/*from w w w .j a v a2s. c o m*/ drawerList.inflateMenu(R.menu.drawer_navigation); SharedPreferences prefs = Util.getPreferences(this); boolean podcastsEnabled = prefs.getBoolean(Constants.PREFERENCES_KEY_PODCASTS_ENABLED, true); boolean bookmarksEnabled = prefs.getBoolean(Constants.PREFERENCES_KEY_BOOKMARKS_ENABLED, true) && !Util.isOffline(this) && ServerInfo.canBookmark(this); boolean internetRadioEnabled = prefs.getBoolean(Constants.PREFERENCES_KEY_INTERNET_RADIO_ENABLED, true) && !Util.isOffline(this) && ServerInfo.canInternetRadio(this); boolean sharedEnabled = prefs.getBoolean(Constants.PREFERENCES_KEY_SHARED_ENABLED, true) && !Util.isOffline(this); boolean chatEnabled = prefs.getBoolean(Constants.PREFERENCES_KEY_CHAT_ENABLED, true) && !Util.isOffline(this); boolean adminEnabled = prefs.getBoolean(Constants.PREFERENCES_KEY_ADMIN_ENABLED, true) && !Util.isOffline(this); MenuItem offlineMenuItem = drawerList.getMenu().findItem(R.id.drawer_offline); if (Util.isOffline(this)) { setDrawerItemVisible(R.id.drawer_home, false); if (lastSelectedPosition == 0 || lastSelectedPosition == R.id.drawer_home) { String newFragment = Util.openToTab(this); if (newFragment == null || "Home".equals(newFragment)) { newFragment = "Artist"; } lastSelectedPosition = getDrawerItemId(newFragment); drawerItemSelected(newFragment); } offlineMenuItem.setTitle(R.string.main_online); } else { offlineMenuItem.setTitle(R.string.main_offline); } if (!podcastsEnabled) { setDrawerItemVisible(R.id.drawer_podcasts, false); } if (!bookmarksEnabled) { setDrawerItemVisible(R.id.drawer_bookmarks, false); } if (!internetRadioEnabled) { setDrawerItemVisible(R.id.drawer_internet_radio_stations, false); } if (!sharedEnabled) { setDrawerItemVisible(R.id.drawer_shares, false); } if (!chatEnabled) { setDrawerItemVisible(R.id.drawer_chat, false); } if (!adminEnabled) { setDrawerItemVisible(R.id.drawer_admin, false); } if (lastSelectedPosition != 0) { MenuItem item = drawerList.getMenu().findItem(lastSelectedPosition); if (item != null) { item.setChecked(true); } } drawerHeaderToggle.setImageResource(R.drawable.main_select_server_dark); showingTabs = true; }
From source file:org.totschnig.myexpenses.fragment.TransactionList.java
@Override public void onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); if (mAccount == null || getActivity() == null) { //mAccount seen in report 3331195c529454ca6b25a4c5d403beda //getActivity seen in report 68a501c984bdfcc95b40050af4f815bf return;//from www.j a v a 2 s .com } MenuItem searchMenu = menu.findItem(R.id.SEARCH_COMMAND); if (searchMenu != null) { String title; Drawable searchMenuIcon = searchMenu.getIcon(); if (!mFilter.isEmpty()) { if (searchMenuIcon != null) { searchMenuIcon.setColorFilter(Color.GREEN, PorterDuff.Mode.MULTIPLY); } else { AcraHelper.report(new Exception("Search menu icon not found")); } searchMenu.setChecked(true); title = mAccount.label + " ( " + mFilter.prettyPrint() + " )"; } else { if (searchMenuIcon != null) { searchMenuIcon.setColorFilter(null); } else { AcraHelper.report(new Exception("Search menu icon not found")); } searchMenu.setChecked(false); title = mAccount.label; } ((MyExpenses) getActivity()).setTitle(title); SubMenu filterMenu = searchMenu.getSubMenu(); for (int i = 0; i < filterMenu.size(); i++) { MenuItem filterItem = filterMenu.getItem(i); boolean enabled = true; switch (filterItem.getItemId()) { case R.id.FILTER_CATEGORY_COMMAND: enabled = mappedCategories; break; case R.id.FILTER_STATUS_COMMAND: enabled = !mAccount.type.equals(AccountType.CASH); break; case R.id.FILTER_PAYEE_COMMAND: enabled = mappedPayees; break; case R.id.FILTER_METHOD_COMMAND: enabled = mappedMethods; break; case R.id.FILTER_TRANSFER_COMMAND: enabled = hasTransfers; break; } Criteria c = mFilter.get(filterItem.getItemId()); Utils.menuItemSetEnabledAndVisible(filterItem, enabled || c != null); if (c != null) { filterItem.setChecked(true); filterItem.setTitle(c.prettyPrint()); } } } else { AcraHelper.report(new Exception("Search menu not found")); } }
From source file:com.openatk.planting.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.main_menu_add) { // Check if have an operation if (operationsList.isEmpty()) { // Show dialog to create operation createOperation(new Callable<Void>() { public Void call() { return addFieldMapView(); }/* ww w.j a v a 2s .c om*/ }); } else { addFieldMapView(); } } else if (item.getItemId() == R.id.main_menu_current_location) { Location myLoc = map.getMyLocation(); if (myLoc == null) { Toast.makeText(this, "Still searching for your location", Toast.LENGTH_SHORT).show(); } else { CameraPosition oldPos = map.getCameraPosition(); CameraPosition newPos = new CameraPosition(new LatLng(myLoc.getLatitude(), myLoc.getLongitude()), map.getMaxZoomLevel(), oldPos.tilt, oldPos.bearing); map.animateCamera(CameraUpdateFactory.newCameraPosition(newPos)); } } else if (item.getItemId() == R.id.main_menu_layers) { MenuItem layers = menu.findItem(R.id.main_menu_layers); if (showingHazards == false) { showingHazards = true; layers.setTitle("Hide Hazards"); } else { showingHazards = false; layers.setTitle("Show Hazards"); } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean("showingHazards", showingHazards); editor.commit(); drawHazards(); } else if (item.getItemId() == R.id.main_menu_list_view) { if (mCurrentState == STATE_LIST_VIEW) { // Show map view Log.d("MainActivity", "Showing map view"); setState(STATE_DEFAULT); //item.setIcon(R.drawable.list_view); this.invalidateOptionsMenu(); } else { // Show list view Log.d("MainActivity", "Showing list view"); setState(STATE_LIST_VIEW); //item.setIcon(R.drawable.map_view); this.invalidateOptionsMenu(); } } else if (item.getItemId() == R.id.main_menu_help) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Help"); WebView wv = new WebView(this); wv.loadUrl("file:///android_asset/Help.html"); wv.getSettings().setSupportZoom(true); wv.getSettings().setBuiltInZoomControls(true); wv.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }); alert.setView(wv); alert.setNegativeButton("Close", null); alert.show(); } else if (item.getItemId() == R.id.main_menu_legal) { CharSequence licence = "The MIT License (MIT)\n" + "\n" + "Copyright (c) 2013 Purdue University\n" + "\n" + "Permission is hereby granted, free of charge, to any person obtaining a copy " + "of this software and associated documentation files (the \"Software\"), to deal " + "in the Software without restriction, including without limitation the rights " + "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell " + "copies of the Software, and to permit persons to whom the Software is " + "furnished to do so, subject to the following conditions:" + "\n" + "The above copyright notice and this permission notice shall be included in " + "all copies or substantial portions of the Software.\n" + "\n" + "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR " + "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, " + "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE " + "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER " + "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, " + "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN " + "THE SOFTWARE.\n"; new AlertDialog.Builder(this).setTitle("Legal").setMessage(licence) .setIcon(android.R.drawable.ic_dialog_alert).setPositiveButton("Close", null).show(); } return true; }
From source file:org.mariotaku.twidere.fragment.UserFragment.java
@Override @UiThread/* w w w . ja va 2 s . c o m*/ public void onPrepareOptionsMenu(final Menu menu) { final AsyncTwitterWrapper twitter = mTwitterWrapper; final ParcelableUser user = getUser(); if (twitter == null || user == null) return; final boolean isMyself = user.account_key.maybeEquals(user.key); final MenuItem mentionItem = menu.findItem(R.id.mention); if (mentionItem != null) { final String displayName = UserColorNameManager.decideDisplayName(user.nickname, user.name, user.screen_name, mNameFirst); mentionItem.setTitle(getString(R.string.mention_user_name, displayName)); } MenuUtils.setMenuItemAvailability(menu, R.id.mention, !isMyself); MenuUtils.setMenuItemAvailability(menu, R.id.incoming_friendships, isMyself); MenuUtils.setMenuItemAvailability(menu, R.id.saved_searches, isMyself); MenuUtils.setMenuItemAvailability(menu, R.id.scheduled_statuses, isMyself && MicroBlogAPIFactory .getOfficialKeyType(getActivity(), user.account_key) == ConsumerKeyType.TWEETDECK); MenuUtils.setMenuItemAvailability(menu, R.id.muted_users, isMyself); MenuUtils.setMenuItemAvailability(menu, R.id.blocked_users, isMyself); MenuUtils.setMenuItemAvailability(menu, R.id.block, !isMyself); MenuUtils.setMenuItemAvailability(menu, R.id.mute_user, !isMyself); MenuUtils.setMenuItemAvailability(menu, R.id.report_spam, !isMyself); MenuUtils.setMenuItemAvailability(menu, R.id.enable_retweets, !isMyself); if (mAccount != null) { MenuUtils.setMenuItemAvailability(menu, R.id.add_to_list, TextUtils .equals(ParcelableAccount.Type.TWITTER, ParcelableAccountUtils.getAccountType(mAccount))); } else { MenuUtils.setMenuItemAvailability(menu, R.id.add_to_list, false); } final UserRelationship userRelationship = mRelationship; if (userRelationship != null) { final MenuItem filterItem = menu.findItem(R.id.add_to_filter); if (filterItem != null) { filterItem.setChecked(userRelationship.filtering); } if (isMyself) { MenuUtils.setMenuItemAvailability(menu, R.id.send_direct_message, false); } else { MenuUtils.setMenuItemAvailability(menu, R.id.send_direct_message, userRelationship.can_dm); MenuUtils.setMenuItemAvailability(menu, R.id.block, true); final MenuItem blockItem = menu.findItem(R.id.block); if (blockItem != null) { ActionIconDrawable.setMenuHighlight(blockItem, new TwidereMenuInfo(userRelationship.blocking)); blockItem.setTitle(userRelationship.blocking ? R.string.unblock : R.string.block); } final MenuItem muteItem = menu.findItem(R.id.mute_user); if (muteItem != null) { muteItem.setChecked(userRelationship.muting); } final MenuItem wantRetweetsItem = menu.findItem(R.id.enable_retweets); if (wantRetweetsItem != null) { wantRetweetsItem.setChecked(userRelationship.retweet_enabled); } } } else { MenuUtils.setMenuItemAvailability(menu, R.id.send_direct_message, false); } final Intent intent = new Intent(INTENT_ACTION_EXTENSION_OPEN_USER); final Bundle extras = new Bundle(); extras.putParcelable(EXTRA_USER, user); intent.putExtras(extras); menu.removeGroup(MENU_GROUP_USER_EXTENSION); MenuUtils.addIntentToMenu(getActivity(), menu, intent, MENU_GROUP_USER_EXTENSION); final HeaderDrawerLayout drawer = mHeaderDrawerLayout; if (drawer != null) { final int offset = drawer.getPaddingTop() - drawer.getHeaderTop(); mPreviousActionBarItemIsDark = 0; mPreviousTabItemIsDark = 0; updateScrollOffset(offset); } }