/** * Prepares the help menu item by doing the following. - If the helpUrlString is empty or null, * the help menu item is made invisible. - Otherwise, this makes the help menu item visible and * sets the intent for the help menu item to view the URL. * * @return returns whether the help menu item has been made visible. */ public static boolean prepareHelpMenuItem( Context context, MenuItem helpMenuItem, String helpUrlString) { if (TextUtils.isEmpty(helpUrlString)) { // The help url string is empty or null, so set the help menu item to be invisible. helpMenuItem.setVisible(false); // return that the help menu item is not visible (i.e. false) return false; } else { // The help url string exists, so first add in some extra query parameters. final Uri fullUri = uriWithAddedParameters(context, Uri.parse(helpUrlString)); // Then, create an intent that will be fired when the user // selects this help menu item. Intent intent = new Intent(Intent.ACTION_VIEW, fullUri); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); // Set the intent to the help menu item, show the help menu item in the overflow // menu, and make it visible. ComponentName component = intent.resolveActivity(context.getPackageManager()); if (component != null) { helpMenuItem.setIntent(intent); helpMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); helpMenuItem.setVisible(true); } else { helpMenuItem.setVisible(false); return false; } // return that the help menu item is visible (i.e., true) return true; } }
protected void setRefreshActionButtonState(boolean refreshing) { if (mOptionsMenu == null) { // mPendingMenuRefreshState=refreshing; return; } final MenuItem refreshItem = mOptionsMenu.findItem(R.id.menu_refresh); if (refreshItem != null) { if (refreshing) { View actionView = MenuItemCompat.getActionView(refreshItem); if (actionView == null || actionView.findViewById(R.id.progress_circular_ab) == null) { MenuItemCompat.setActionView(refreshItem, R.layout.actionbar_indeterminate_progress); actionView = MenuItemCompat.getActionView(refreshItem); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // Framework bug https://code.google.com/p/android/issues/detail?id=162416 ProgressBar progressBar = (ProgressBar) actionView.findViewById(R.id.progress_circular_ab); progressBar.setIndeterminate(true); progressBar.setIndeterminateTintMode(PorterDuff.Mode.SRC_IN); progressBar.setIndeterminateTintList( getResources().getColorStateList(R.color.action_bar_title)); // progressBar.setBackgroundTintList(getResources().getColorStateList(R.color.action_bar_title)); } } refreshItem.setVisible(true); } else { MenuItemCompat.setActionView(refreshItem, null); if (mHasFeatureIndeterminateProgress) refreshItem.setVisible(false); } } mPendingMenuRefreshState = null; // if(mHasFeatureIndeterminateProgress) // setSupportProgressBarIndeterminateVisibility(refreshing); }
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuItem menuItem = menu.findItem(R.id.action_search); if (TextUtils.isEmpty(currentCity)) { menuItem.setVisible(false); } else { menuItem.setVisible(true); MenuItemCompat.setOnActionExpandListener( menuItem, new MenuItemCompat.OnActionExpandListener() { @Override public boolean onMenuItemActionExpand(MenuItem item) { if (listView != null && searchAdapter != null) { listView.setAdapter(searchAdapter); searchAdapter.reload(""); initActionView(item); searchView.requestFocus(); mFootUpdate.dismiss(); } return true; } @Override public boolean onMenuItemActionCollapse(MenuItem item) { if (listView != null && chooseAdapter != null) { listView.setAdapter(chooseAdapter); } return true; } }); } return super.onCreateOptionsMenu(menu); }
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main_menu, menu); if (Constants.MENUITEM_HOME_DISABLED) { MenuItem item = menu.findItem(R.id.home); if (item != null) { item.setVisible(false); } } if (Constants.MENUITEM_RESET_DISABLED) { MenuItem item = menu.findItem(R.id.reset); if (item != null) { item.setVisible(false); } } if (Constants.MENUITEM_SETTINGS_DISABLED) { MenuItem item = menu.findItem(R.id.settings); if (item != null) { item.setVisible(false); } } if (Constants.MENUITEM_HELP_DISABLED) { MenuItem item = menu.findItem(R.id.help); if (item != null) { item.setVisible(false); } } return true; }
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); hackForSubmenus = menu; if (progress != null && (actionBarCompat == null || actionBarCompat.hasMenuButton())) return false; // not safe/useful until game is loaded MenuItem item; item = menu.findItem(R.id.solve); item.setEnabled(solveEnabled); if (actionBarCompat != null) item.setVisible(solveEnabled); MenuItem undoItem = menu.findItem(R.id.undo), redoItem = menu.findItem(R.id.redo); undoItem.setEnabled(undoEnabled); redoItem.setEnabled(redoEnabled); undoItem.setIcon( undoEnabled ? R.drawable.sym_keyboard_undo : R.drawable.sym_keyboard_undo_disabled); redoItem.setIcon( redoEnabled ? R.drawable.sym_keyboard_redo : R.drawable.sym_keyboard_redo_disabled); item = menu.findItem(R.id.type); item.setEnabled(!gameTypes.isEmpty() || customVisible); if (actionBarCompat != null) item.setVisible(item.isEnabled()); typeMenu = item.getSubMenu(); for (Integer i : gameTypes.keySet()) { if (menu.findItem(i) == null) typeMenu.add(R.id.typeGroup, i, Menu.NONE, gameTypes.get(i)); } MenuItem customItem = menu.findItem(R.id.custom); customItem.setVisible(customVisible); typeMenu.setGroupCheckable(R.id.typeGroup, true, true); if (currentType < 0) customItem.setChecked(true); else if (currentType < gameTypes.size()) menu.findItem((Integer) gameTypes.keySet().toArray()[currentType]).setChecked(true); menu.findItem(R.id.thisgame) .setTitle( MessageFormat.format(getString(R.string.help_on_game), new Object[] {this.getTitle()})); return true; }
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { mSpinnerAdapter.swapCursor(data); if (listIdToSelect > -1 || listIdToSelect == ALL_NOTES_ID) { int position = getPosOfId(listIdToSelect); if (position > -1) { currentListPos = position; currentListId = listIdToSelect; getActionBar().setSelectedNavigationItem(position); } listIdToSelect = -1; } if (optionsMenu != null) { MenuItem createNote = optionsMenu.findItem(R.id.menu_add); if (createNote != null) { // Only show this button if there is a list to create notes in if (mSpinnerAdapter.getCount() == 0) { createNote.setVisible(false); } else { createNote.setVisible(true); } } } beforeBoot = false; // Need to do it here }
@UiThread private void updatePowerMenuItems(boolean canPowerOn, boolean canPowerOff) { boolean connected = isConnected(); // The fragment may no longer be attached to the parent activity. If so, do nothing. if (!isAdded()) { return; } if (menu_item_poweron != null) { if (canPowerOn && connected) { Player player = getActivePlayer(); String playerName = player != null ? player.getName() : ""; menu_item_poweron.setTitle(getString(R.string.menu_item_poweron, playerName)); menu_item_poweron.setVisible(true); } else { menu_item_poweron.setVisible(false); } } if (menu_item_poweroff != null) { if (canPowerOff && connected) { Player player = getActivePlayer(); String playerName = player != null ? player.getName() : ""; menu_item_poweroff.setTitle(getString(R.string.menu_item_poweroff, playerName)); menu_item_poweroff.setVisible(true); } else { menu_item_poweroff.setVisible(false); } } }
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_base, menu); setupWindowAnimations(); MenuItem countItem = menu.findItem(R.id.pending_goals); MenuItemCompat.setActionView(countItem, R.layout.feed_update_count); if (mPendingCount > 0) { countItem.setVisible(true); buttonPending = (Button) MenuItemCompat.getActionView(countItem); buttonPending.setText(String.valueOf(mPendingCount)); buttonPending.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { Intent i = new Intent(getApplicationContext(), ReminderListActivity.class); startActivity( i, ActivityOptions.makeSceneTransitionAnimation(HistoryBaseActivity.this) .toBundle()); } }); } else { countItem.setVisible(false); } return super.onCreateOptionsMenu(menu); }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_scan: rcycAdaptDevices.getBlData().clear(); rcycAdaptDevices.notifyDataSetChanged(); if (service == null) { startService(new Intent(this, ServiceScan.class)); bindService(new Intent(ActScan.this, ServiceScan.class), ActScan.this, BIND_AUTO_CREATE); } item.setVisible(false); menu.findItem(R.id.menu_stop).setVisible(true); break; case R.id.menu_stop: item.setVisible(false); menu.findItem(R.id.menu_scan).setVisible(true); // scanLeDevice(false); stopService(new Intent(this, ServiceScan.class)); // Deactivate updates to us so that we dont get callbacks no more. service.deregisterServiceListener(this); // Finally stop the service unbindService(this); service = null; break; } return true; }
/** * Callback method from {@link ProjectListFragment.Callbacks} indicating that the item with the * given ID was selected. */ public void onItemSelected(Project p) { MenuItem charts = this.actionBarmenu.findItem(R.id.action_charts); charts.setEnabled(true); charts.setVisible(true); MenuItem item = this.actionBarmenu.findItem(R.id.action_all_tasks); item.setVisible(false); this.selectedProject = p; Bundle arguments = new Bundle(); ProjectDetailFragment fragment = new ProjectDetailFragment(); arguments.putBoolean("TwoPane", mGlobalVariables.ismTwoPane()); fragment.setArguments(arguments); // currFragment=fragment; getFragmentManager() .beginTransaction() .replace( mGlobalVariables.ismTwoPane() ? R.id.twopane_detail_container : R.id.main_fragment_container, fragment) .commit(); // If in two pane mode, we cannot go up. if (!mGlobalVariables.ismTwoPane()) { this.fragmentStack.push(fragment); } getActionBar().setDisplayHomeAsUpEnabled(!mGlobalVariables.ismTwoPane()); }
private void updateDrawer(boolean updateFavorites) { NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); assert navigationView != null : "Navigation view is null"; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) navigationView.setItemIconTintList(null); MenuItem stats = navigationView.getMenu().findItem(R.id.nav_stats); if (ProSettings.checkEnabled(ProSettings.STATISTICS_KEY)) stats.setVisible(true); else stats.setVisible(false); MenuItem notes = navigationView.getMenu().findItem(R.id.nav_notes); if (ProSettings.checkEnabled(ProSettings.NOTES_KEY)) notes.setVisible(true); else notes.setVisible(false); if (updateFavorites) { SubMenu fab_menu = navigationView.getMenu().findItem(R.id.nav_header_favorites).getSubMenu(); fab_menu.clear(); Sites favorites = dataManager.getFavoriteSites(); for (Site site : favorites) { MenuItem mi = fab_menu.add(2, site.code, Menu.NONE, site.name); configureMenuItem(mi, site); } } navigationView.invalidate(); }
@Override public boolean onPrepareOptionsMenu(Menu menu) { MenuItem item = menu.findItem(R.id.action_sending); ParseUser currentUser = ParseUser.getCurrentUser(); String[] list = getResources().getStringArray(R.array.admin_mail_address); item.setVisible(false); if (currentUser != null) { Log.e("Name", currentUser.getUsername()); Log.e("Name", currentUser.getEmail()); } else { Log.e("NULL USER", "NOT LOGGED IN"); } if (currentUser != null) { for (String s : list) { if (currentUser.getEmail().equals(s)) { item.setVisible(true); Log.e("Vis", "TRUE"); break; } } } super.onPrepareOptionsMenu(menu); return true; }
protected void updateUserHeader() { final MenuItem userHeaderMenu = (mOptionsMenu != null) ? mOptionsMenu.findItem(R.id.menu_user_header) : null; if (userHeaderMenu != null) { View userHeaderView = MenuItemCompat.getActionView(userHeaderMenu); if (userHeaderView == null) { userHeaderView = getLayoutInflater().inflate(R.layout.actionbar_user_header, null, false); userHeaderView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { onOptionsItemSelected(userHeaderMenu); } }); MenuItemCompat.setShowAsAction(userHeaderMenu, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); MenuItemCompat.setActionView(userHeaderMenu, userHeaderView); } UserHeader header = Session.getInstance().getCustomerHeader(); if (header != null) { ((TextView) userHeaderView.findViewById(R.id.text1)).setText("hi"); userHeaderMenu.setTitle(header.userName.getUserNameDisplay()); userHeaderMenu.setVisible(true); } else { userHeaderMenu.setTitle("Login"); userHeaderMenu.setVisible(false); } } }
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); mZoomingMenuItem.setVisible(!mZooming); mCroppingMenuItem.setVisible(mZooming); return true; }
@Override public boolean onMenuOpened(int featureId, Menu menu) { if (menu != null) { MenuItem miSwitch = menu.findItem(SWITCH_MODE_INDEX); if (firstTime) { miSwitch.setEnabled(false); } else { miSwitch.setEnabled(true); } MenuItem miMute = menu.findItem(MUTE_INDEX); if (viewMode == VIEW_KEYPAD) { miMute.setVisible(true); if (mute) { miMute.setTitle(R.string.sounds); miMute.setIcon(android.R.drawable.ic_lock_silent_mode_off); } else { miMute.setTitle(R.string.mute); miMute.setIcon(android.R.drawable.ic_lock_silent_mode); } } else { miMute.setVisible(false); } } return super.onMenuOpened(featureId, menu); }
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. int resMenu = R.menu.menu_profile_detail; switch (which) { case HOME_FRAGMENT: resMenu = R.menu.menu_profile_detail; break; case DIET_FRAGMENT: resMenu = R.menu.diet_fragment_menu; break; case GENERAL_FRAGMENT: resMenu = R.menu.menu_general_fragment; break; } getMenuInflater().inflate(resMenu, menu); if (which == GENERAL_FRAGMENT) { MenuItem editItem = menu.getItem(0); MenuItem saveItem = menu.getItem(1); if (mode == SAVE_MODE) { editItem.setVisible(false); saveItem.setVisible(true); } else if (mode == EDIT_MODE) { editItem.setVisible(true); saveItem.setVisible(false); } } return true; }
@Override public void onPrepareOptionsMenu(Menu menu) { boolean isDrawerOpen = ((BaseActivity) getActivity()).isDrawerOpen(); MenuItem refreshItem = menu.findItem(R.id.menu_refresh); refreshItem.setVisible(!isDrawerOpen); setRefreshIndicationState(updateManager.isUpdating(UpdateManager.UpdateType.NODES)); MenuItem searchItem = menu.findItem(R.id.action_search); searchItem.setVisible(!isDrawerOpen); }
private void showMenuItems(boolean visible) { mSearchMenuItem.setVisible(visible); mContributorInfoMenuItem.setVisible(mSelectedContributor != -1 && visible); mContributionsInfoMenuItem.setVisible(visible); if (!visible) { mSearchView.setQuery("", false); mSearchMenuItem.collapseActionView(); } }
@Override public boolean onMenuItemActionExpand(MenuItem item) { if (item.getItemId() == mSearchMenuItem.getItemId()) { animateFadeOutFadeIn(mImageView, mSearchResults); mContributorInfoMenuItem.setVisible(false); mContributionsInfoMenuItem.setVisible(false); } return true; }
@Override protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); if (l.getCheckedItemCount() > 0) { mSendMenuItem.setVisible(true); } else { mSendMenuItem.setVisible(false); } }
public void setStopButtonVisible(boolean visible) { if (stopItem == null) { if (menu != null) { stopItem = menu.findItem(R.id.stop_guide); stopItem.setVisible(visible); } } else { stopItem.setVisible(visible); } }
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); actionSettings = menu.findItem(R.id.action_settings); if ("2".equals(hotelCode)) { actionSettings.setVisible(true); } else actionSettings.setVisible(false); return true; }
@Override public boolean onPrepareOptionsMenu(Menu menu) { boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerListView); MenuItem item; item = menu.findItem(R.id.menu_search); if (item != null) item.setVisible(!drawerOpen); item = menu.findItem(R.id.menu_refresh); if (item != null) item.setVisible(!drawerOpen); return super.onPrepareOptionsMenu(menu); }
private void a(MenuItem menuItem) { if (this.Lo != null) { YellowPage bl = this.Lo.bl(); if (!(bl == null || bl.getPhones() == null)) { menuItem.setVisible(true); return; } } menuItem.setVisible(false); }
@Override public boolean onPrepareOptionsMenu(Menu menu) { MenuItem loginAsItem = menu.findItem(R.id.menu_loginas); if (NBSyncService.isStaff == Boolean.TRUE) { loginAsItem.setVisible(true); } else { loginAsItem.setVisible(false); } return super.onPrepareOptionsMenu(menu); }
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); Bundle args = new Bundle(); //noinspection SimplifiableIfStatement if (id == R.id.action_delete) { args.putString("action", "deleteMode"); can.setVisible(true); con.setVisible(true); del.setVisible(false); loadFragment(R.id.fragment_1, new Portfolio(), true, args); } if (id == R.id.action_cancel) { args.putString("action", "cancel"); can.setVisible(false); con.setVisible(false); del.setVisible(true); loadFragment(R.id.fragment_1, new Portfolio(), true, args); } if (id == R.id.action_confirm) { args.putString("action", "confirm"); can.setVisible(false); con.setVisible(false); del.setVisible(true); loadFragment(R.id.fragment_1, new Portfolio(), true, args); } return super.onOptionsItemSelected(item); }
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { in_ogl_anim = false; if (pos == 0 || pos > 2) { rid1 = MyApplication.space.split(rid_arr_loc[pos])[0]; tdwr_s = UtilityNexrad.GetTDWRFromRID(rid1); if (tdwr_s.equals("")) tdwr.setVisible(false); else tdwr.setVisible(true); if (tilt_option) tilt_menu.setVisible(true); else tilt_menu.setVisible(false); old_state = state; old_sector = sector; old_onek = onek; state = MyApplication.comma.split(MyApplication.preferences.getString("RID_LOC_" + rid1, ""))[0]; sector = MyApplication.preferences.getString("COD_SECTOR_" + state, ""); state = MyApplication.preferences.getString("STATE_CODE_" + state, ""); onek = MyApplication.preferences.getString("COD_1KM_" + rid1, ""); if (prod.equals("2k")) { img_url = img_url.replace(old_sector, sector); img_url = img_url.replace(old_state, state); img_url = img_url.replace(old_onek, onek); } if (!restarted && !(MyApplication.wxogl_remember_location && first_run)) { img.resetZoom(); img.setZoom(init_zoom); OGLR.setZoom(((float) MyApplication.wxogl_size) / 10.0f); glview.mScaleFactor = ((float) MyApplication.wxogl_size / 10.0f); OGLR.mPositionX = 0.0f; OGLR.mPositionY = 0.0f; } restarted = false; rid_changed = true; new GetContent().execute(); } else if (pos == 1) { Intent dtx_srm = new Intent(getApplicationContext(), RIDAddFavActivity.class); startActivity(dtx_srm); } else if (pos == 2) { Intent dtx_srm2 = new Intent(getApplicationContext(), RIDRemoveFavActivity.class); startActivity(dtx_srm2); } if (first_time) { UtilityToolbar.FullScreenMode(toolbar, toolbar_bottom); first_time = false; } }
@Override public boolean onMenuItemActionCollapse(MenuItem item) { if (item.getItemId() == mSearchMenuItem.getItemId()) { animateFadeOutFadeIn(mSearchResults, mImageView); if (mSelectedContributor != -1) { mContributorInfoMenuItem.setVisible(true); } mContributionsInfoMenuItem.setVisible(true); } return true; }
public static void setLoadingState(boolean refreshing) { if (mProgressMenu != null) { if (refreshing) { mProgressMenu.setActionView(R.layout.actionbar_indeterminate_progress); mProgressMenu.setVisible(true); } else { mProgressMenu.setVisible(false); mProgressMenu.setActionView(null); } } }
@Override public void afterTextChanged(Editable s) { String title = etTitle.getText().toString().trim(); String name = etUserName.getText().toString().trim(); String password = etPassWord.getText().toString().trim(); if (TextUtils.isEmpty(title) || TextUtils.isEmpty(name) || TextUtils.isEmpty(password)) { menuItem.setVisible(false); } else { menuItem.setVisible(true); } }