@Override
 public MenuInflater getMenuInflater() {
   if (mFrom == DLConstants.FROM_INTERNAL) {
     return super.getMenuInflater();
   } else {
     return mProxyActivity.getMenuInflater();
   }
 }
Пример #2
0
  public static BottomBarTab[] inflateMenuFromResource(Activity activity, @MenuRes int menuRes) {
    PopupMenu popupMenu = new PopupMenu(activity, null);
    Menu menu = popupMenu.getMenu();
    activity.getMenuInflater().inflate(menuRes, menu);

    int menuSize = menu.size();
    BottomBarTab[] tabs = new BottomBarTab[menuSize];

    for (int i = 0; i < menuSize; i++) {
      MenuItem item = menu.getItem(i);
      BottomBarTab tab = new BottomBarTab(item.getIcon(), String.valueOf(item.getTitle()));
      tab.id = item.getItemId();
      tabs[i] = tab;
    }
    return tabs;
  }
  @Override
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {

    View targetView = getTargetView(menuInfo);
    if (!(targetView instanceof HistoryItem)) {
      return;
    }
    HistoryItem historyItem = (HistoryItem) targetView;

    // Inflate the menu
    Activity parent = getActivity();
    MenuInflater inflater = parent.getMenuInflater();
    inflater.inflate(R.menu.historycontext, menu);

    // Setup the header
    if (mContextHeader == null) {
      mContextHeader = new HistoryItem(parent, false);
      mContextHeader.setEnableScrolling(true);
    } else if (mContextHeader.getParent() != null) {
      ((ViewGroup) mContextHeader.getParent()).removeView(mContextHeader);
    }
    historyItem.copyTo(mContextHeader);
    menu.setHeaderView(mContextHeader);

    // Only show open in new tab if it was not explicitly disabled
    if (mDisableNewWindow) {
      menu.findItem(R.id.new_window_context_menu_id).setVisible(false);
    }
    // For a bookmark, provide the option to remove it from bookmarks
    if (historyItem.isBookmark()) {
      MenuItem item = menu.findItem(R.id.save_to_bookmarks_menu_id);
      item.setTitle(R.string.remove_from_bookmarks);
    }
    // decide whether to show the share link option
    PackageManager pm = parent.getPackageManager();
    Intent send = new Intent(Intent.ACTION_SEND);
    send.setType("text/plain");
    ResolveInfo ri = pm.resolveActivity(send, PackageManager.MATCH_DEFAULT_ONLY);
    menu.findItem(R.id.share_link_context_menu_id).setVisible(ri != null);

    super.onCreateContextMenu(menu, v, menuInfo);
  }
Пример #4
0
  public EntryDialog(Activity context) {
    super(context, android.R.style.Theme_Light);
    mMenuInflater = context.getMenuInflater();

    // Request a progress bar to display while the HTML content is loading.
    Window window = getWindow();
    ProgressMonitor.requestWindowFeatures(window);

    setContentView(R.layout.atom_entry);

    // Find the ScrollView
    mScrollView = (ScrollView) findViewById(android.R.id.tabcontent);

    // Find the title view, and make it a clickable link
    mTitleView = (TextView) findViewById(android.R.id.text1);
    addLinkMovementMethod(mTitleView);

    // Find the content view, and configure the progress monitor.
    mContentView = (WebView) findViewById(android.R.id.text2);
    WebChromeClient monitor = new ProgressMonitor(window);
    mContentView.setWebChromeClient(monitor);
  }
Пример #5
0
 protected Menu getMenu() {
   MenuBuilder menu = new MenuBuilder(mActivity);
   mActivity.getMenuInflater().inflate(R.menu.browser, menu);
   return menu;
 }
Пример #6
0
 public boolean onCreateOptionsMenu(Menu menu) {
   MenuInflater inflater = activity.getMenuInflater();
   inflater.inflate(R.menu.action_bar_menu, menu);
   return true;
 }