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

    // And implement a share action
    // Fetch/store provider
    // But only if there is data to share
    MenuItem item = menu.findItem(R.id.menu_item_share);

    if (mbShowShare == true) {

      ShareActionProvider shareAction =
          (ShareActionProvider) MenuItemCompat.getActionProvider(item);

      if (shareAction != null) {
        shareAction.setShareIntent(createShareIntent());
      }
    } else {
      // hide the share
      item.setVisible(false);
    }

    return true;
  }
示例#2
0
  public static void setStatusShareMenu(MenuItem shareItem, StatusContent status) {
    String url = null;

    if (status.getPic_urls() != null && status.getPic_urls().length > 0) {
      url = status.getPic_urls()[0].getThumbnail_pic();
    } else if (!TextUtils.isEmpty(status.getThumbnail_pic())) {
      url = status.getThumbnail_pic();
    }
    if (!TextUtils.isEmpty(url)) {
      File file = BitmapLoader.getInstance().getCacheFile(url.replace("thumbnail", "large"));
      if (file.exists()) {
        url = url.replace("thumbnail", "large");
      } else {
        file = BitmapLoader.getInstance().getCacheFile(url.replace("thumbnail", "bmiddle"));
        if (file.exists()) {
          url = url.replace("thumbnail", "bmiddle");
        }
      }
    }

    Intent shareIntent = Utils.getShareIntent(status.getText(), status.getText(), url);

    ShareActionProvider shareProvider =
        (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);
    shareProvider.setShareHistoryFileName("channe_share.xml");
    shareProvider.setShareIntent(shareIntent);
  }
示例#3
0
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   Fragment fragment = fm.findFragmentById(R.id.fragment_container);
   MenuInflater menuInflater = getMenuInflater();
   // ListView Menu - edit list, get new list, about
   if (fragment instanceof TkkListViewFragment) {
     menuInflater.inflate(R.menu.menu_tkk, menu);
     listEditEnabled = false;
     ((TkkListViewFragment) fragment).getListView().setRearrangeEnabled(false);
   } else if (fragment instanceof TkkWebViewFragment) {
     // WebView Menu - share button
     menuInflater.inflate(R.menu.menu_webview, menu);
     MenuItem item = menu.findItem(R.id.menu_item_share);
     ShareActionProvider mShareActionProvider =
         (ShareActionProvider) MenuItemCompat.getActionProvider(item);
     Intent shareIntent = new Intent(Intent.ACTION_SEND);
     shareIntent.setType("text/plain");
     shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(getString(R.string.app_icon_url)));
     shareIntent.putExtra(Intent.EXTRA_TITLE, getString(R.string.app_name));
     shareIntent.putExtra(
         Intent.EXTRA_TEXT,
         getString(R.string.share_message)
             + " "
             + getString(R.string.subtitle)
             + '\n'
             + fragment.getArguments().getString("name")
             + '\n'
             + getString(R.string.get_message)
             + '\n'
             + getString(R.string.download_url));
     mShareActionProvider.setShareIntent(shareIntent);
   }
   return true;
 }
 public boolean onMenuItemClick(MenuItem paramMenuItem) {
   Intent localIntent =
       ActivityChooserModel.a(ShareActionProvider.a(this.a), ShareActionProvider.b(this.a))
           .b(paramMenuItem.getItemId());
   if (localIntent != null) {
     localIntent.addFlags(524288);
     ShareActionProvider.a(this.a).startActivity(localIntent);
   }
   return true;
 }
示例#5
0
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   getMenuInflater().inflate(R.menu.menu_web, menu);
   ShareActionProvider shareActionProvider =
       (ShareActionProvider) MenuItemCompat.getActionProvider(menu.findItem(R.id.menu_share));
   shareActionProvider.setShareIntent(
       AppUtils.makeShareIntent(
           getString(R.string.share_format, mItem.getDisplayedTitle(), mItem.getUrl())));
   return super.onCreateOptionsMenu(menu);
 }
 @Override
 public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
   inflater.inflate(R.menu.detail_fragment, menu);
   MenuItem menuItem = menu.findItem(R.id.action_share);
   ShareActionProvider mShareActionProvider =
       (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);
   if (mShareActionProvider != null) {
     mShareActionProvider.setShareIntent(createShareIntent());
   } else {
     Log.d(TAG, "Share action provider is null?");
   }
 }
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.share_action_provider, menu);

    // Set file with share history to the provider and set the share intent.
    MenuItem menuItem_Share = menu.findItem(R.id.action_share);
    ShareActionProvider shareAction =
        (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem_Share);
    shareAction.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
    // Note that you can set/change the intent any time,
    // say when the user has selected an image.
    shareAction.setShareIntent(createShareIntent());
  }
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   getMenuInflater().inflate(R.menu.image, menu);
   MenuItem actionItem = menu.findItem(R.id.menu_item_share_action_provider_action_bar);
   if (ActionBarUtil.hasSB()) {
     MenuItemCompat.setShowAsAction(actionItem, MenuItemCompat.SHOW_AS_ACTION_NEVER);
   }
   ShareActionProvider actionProvider =
       (ShareActionProvider) MenuItemCompat.getActionProvider(actionItem);
   actionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
   actionProvider.setShareIntent(createShareIntent());
   return super.onCreateOptionsMenu(menu);
 }
 public void setShareIntent(ClimbingArea area) {
   if (menu != null) {
     MenuItem shareItem = menu.findItem(R.id.menu_item_details_share);
     ShareActionProvider mShareActionProvider =
         (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);
     Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
     sharingIntent.setType(AppConstants.MIME_TEXT_PLAIN);
     String shareBody = "";
     sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Klettergebiet Empfehlung");
     sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
     mShareActionProvider.setShareIntent(sharingIntent);
   }
 }
 private void setUpShareAction() {
   String sendingText =
       String.format(
           getString(R.string.action_share_send_text),
           book.getAvailableTitle(),
           NHentaiUrl.getBookDetailsUrl(book.bookId));
   Intent intent = new Intent(Intent.ACTION_SEND);
   intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
   intent.putExtra(Intent.EXTRA_TEXT, sendingText);
   intent.setType("text/plain");
   if (mShareActionProvider != null) {
     mShareActionProvider.setShareHistoryFileName("custom_share_history.xml");
     mShareActionProvider.setShareIntent(intent);
   }
 }
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // Inflate the menu; this adds items to the action bar if it is present.
    inflater.inflate(R.menu.menu_detail, menu);

    MenuItem menuItem = menu.findItem(R.id.action_share);

    ShareActionProvider mShareActionProvider =
        (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);

    if (mShareActionProvider != null) {
      mShareActionProvider.setShareIntent(createShareForecastIntent());
    } else {
      Log.d(LOG_TAG, "Share Action Provider is null?");
    }
  }
  /**
   * Overridden method to display the share action button in the options menu
   *
   * @param menu the options menu
   * @return boolean - if options were created for the menu
   */
  @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_detail, menu);

    Movie selectedMovie = getIntent().getParcelableExtra(DetailActivity.EXTRASCURRENTMOVIE);
    if (selectedMovie.getFavorite() != null && !selectedMovie.getFavorite().isEmpty()) {
      // Locate MenuItem for Favorite/Bookmark button
      MenuItem favItem = menu.findItem(R.id.menu_item_bookmark);
      favItem.setIcon(R.drawable.bookmark_plus);
      favItem.setChecked(true);
    }

    // Locate MenuItem with ShareActionProvider
    MenuItem shareItem = menu.findItem(R.id.menu_item_share);
    // Fetch and store ShareActionProvider
    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);

    if (mShareActionProvider != null) {
      mShareActionProvider.setShareIntent(getDefaultShareIntent());
    } else {
      Log.d(LOG_TAG, "ShareActionProvider is null");
      return false;
    }
    return true;
  }
示例#13
0
 @Override
 public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
   inflater.inflate(R.menu.detail, menu);
   MenuItem menuItem = menu.findItem(R.id.action_share);
   mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);
   if (mVideos != null) mShareActionProvider.setShareIntent(createShareIntent());
 }
 @Override
 public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
   // Inflate the menu
   inflater.inflate(R.menu.menu_financial, menu);
   // Retrieve the share menu item
   MenuItem menuItem = menu.findItem(R.id.action_share);
   // Get the provider and hold onto it to set/change the share intent
   ShareActionProvider mShareActionProvider =
       (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);
   // Attach an intent to this ShareActionProvider.
   if (mShareActionProvider != null) {
     mShareActionProvider.setShareIntent(createShareCompanyIntent());
   } else {
     Log.d(LOG_TAG, "Share Action Provider is null");
   }
 }
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    if (mMovie != null) {
      inflater.inflate(R.menu.menu_fragment_detail, menu);

      final MenuItem action_favorite = menu.findItem(R.id.action_favorite);
      MenuItem action_share = menu.findItem(R.id.action_share);
      /*
      action_favorite.setIcon(Utility.isFavorited(getActivity(), mMovie.getId()) == 1 ?
              R.drawable.abc_btn_rating_star_on_mtrl_alpha :
              R.drawable.abc_btn_rating_star_off_mtrl_alpha);
      */
      new AsyncTask<Void, Void, Integer>() {
        @Override
        protected Integer doInBackground(Void... params) {
          return Utility.isFavorited(getActivity(), mMovie.getId());
        }

        @Override
        protected void onPostExecute(Integer isFavorited) {
          action_favorite.setIcon(
              isFavorited == 1
                  ? R.drawable.ic_favorite_white_18dp
                  : R.drawable.ic_favorite_border_white_18dp);
        }
      }.execute();

      mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(action_share);

      if (mTrailer != null) {
        mShareActionProvider.setShareIntent(createShareMovieIntent());
      }
    }
  }
  @Override
  public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    if (data.moveToFirst()) {
      detailString = convertCursorRowToUXFormat(data);
      if (shareProvider != null) {
        shareProvider.setShareIntent(createForecastShareIntent());
      }
      mWeatherId = data.getInt(COL_WEATHER_ID);

      long date = data.getLong(ForecastFragment.COL_WEATHER_DATE);
      // POPULATE THE text views
      mDay.setText(Utility.getDayName(getActivity(), date));
      mDate.setText(Utility.getFormattedMonthDay(getActivity(), date));

      mHigh.setText(
          getString(R.string.format_degrees, data.getFloat(ForecastFragment.COL_WEATHER_MAX_TEMP)));
      mLow.setText(
          getString(R.string.format_degrees, data.getFloat(ForecastFragment.COL_WEATHER_MIN_TEMP)));
      mHumidity.setText(getString(R.string.format_humidity, data.getFloat(COL_HUMIDITY)));
      mPressure.setText(getString(R.string.format_pressure, data.getFloat(COL_PRESSURE)));
      mIcon.setImageResource(Utility.weatherCodeToArtPath(mWeatherId));

      float windSpeed = data.getFloat(COL_WIND_SPEED);
      String windDirection = getWindDirection(data.getFloat(COL_DEGREES));
      mWind.setText(getString(R.string.format_wind_kmh, windSpeed, windDirection));
      if (mCompass != null) {
        mCompass.setAngle(degreesToRadians(data.getFloat(COL_DEGREES)));
      }

      mDescription.setText(data.getString(ForecastFragment.COL_WEATHER_DESC));
    }
  }
示例#17
0
  @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_aboutus, menu);

    // Inflate the menu; this adds items to the action bar if it is present.

    MenuItem shareItem = menu.findItem(R.id.menu_share);
    myShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);
    myShareActionProvider.setShareHistoryFileName(
        ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
    myShareActionProvider.setShareIntent(Shareintent());

    return super.onCreateOptionsMenu(menu);
  }
 public void onLoadFinished(Loader<Drawable> loader, Drawable data) {
   swipeRefreshLayout.setRefreshing(false);
   mImage.setImageDrawable(data);
   try {
     shareAction.setShareIntent(createShareIntent());
   } catch (NullPointerException e) {
     Log.e(TAG, "createShareIntent() returned NULL: " + e.getStackTrace());
   }
 }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_activity_player, menu);

    MenuItem shareItem = menu.findItem(R.id.ss_action_share);
    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);
    mShareActionProvider.setShareIntent(getDefaultIntent());
    return super.onCreateOptionsMenu(menu);
  }
示例#20
0
 private void updateShareIntent() {
   // If the ShareActionProvider has been created in onCreateOptionsMenu() and the movieDetails
   // have
   // been initialized in onLoadFinished(), we can set the shareIntent.
   if (shareActionProvider != null && movieDetails != null && !movieDetails.trailers.isEmpty()) {
     String firstTrailerKey = movieDetails.trailers.get(0).key;
     shareActionProvider.setShareIntent(createShareFirstTrailerIntent(firstTrailerKey));
   }
 }
示例#21
0
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // Inflate the menu; this adds items to the action bar if it is present.
    inflater.inflate(R.menu.detail_fragment, menu);

    // Retrieve the share menu item
    MenuItem menuItem = menu.findItem(R.id.action_share);

    // Get the provider and hold onto it to set/change the share intent.
    ShareActionProvider mShareActionProvider =
        (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);

    // Attach an intent to this ShareActionProvider. You can update this at any time,
    // like when the user selects a new piece of data they might like to share.
    if (mShareActionProvider != null) {
      mShareActionProvider.setShareIntent(createShareForecastIntent());
    }
  }
示例#22
0
  @Override
  public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    if (data != null && data.moveToFirst()) {
      // Read weather condition ID from cursor
      int weatherId = data.getInt(data.getColumnIndex(WeatherEntry.COLUMN_WEATHER_ID));
      // Use placeholder Image
      mIconView.setImageResource(Utility.getArtResourceForWeatherCondition(weatherId));

      // Read date from cursor and update views for day of week and date
      String date = data.getString(data.getColumnIndex(WeatherEntry.COLUMN_DATETEXT));
      String friendlyDateText = Utility.getDayName(getActivity(), date);
      String dateText = Utility.getFormattedMonthDay(getActivity(), date);
      mFriendlyDateView.setText(friendlyDateText);
      mDateView.setText(dateText);

      // Read description from cursor and update view
      String description = data.getString(data.getColumnIndex(WeatherEntry.COLUMN_SHORT_DESC));
      mDescriptionView.setText(description);

      // For accessibility, add a content description to the icon field.
      mIconView.setContentDescription(description);

      // Read high temperature from cursor and update view
      boolean isMetric = Utility.isMetric(getActivity());

      double high = data.getDouble(data.getColumnIndex(WeatherEntry.COLUMN_MAX_TEMP));
      String highString = Utility.formatTemperature(getActivity(), high, isMetric);
      mHighTempView.setText(highString);

      // Read low temperature from cursor and update view
      double low = data.getDouble(data.getColumnIndex(WeatherEntry.COLUMN_MIN_TEMP));
      String lowString = Utility.formatTemperature(getActivity(), low, isMetric);
      mLowTempView.setText(lowString);

      // Read humidity from cursor and update view
      float humidity = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_HUMIDITY));
      mHumidityView.setText(getActivity().getString(R.string.format_humidity, humidity));

      // Read wind speed and direction from cursor and update view
      float windSpeedStr = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_WIND_SPEED));
      float windDirStr = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_DEGREES));
      mWindView.setText(Utility.getFormattedWind(getActivity(), windSpeedStr, windDirStr));

      // Read pressure from cursor and update view
      float pressure = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_PRESSURE));
      mPressureView.setText(getActivity().getString(R.string.format_pressure, pressure));

      // We still need this for the share intent
      mForecast = String.format("%s - %s - %s/%s", dateText, description, high, low);

      // If onCreateOptionsMenu has already happened, we need to update the share intent now.
      if (mShareActionProvider != null) {
        mShareActionProvider.setShareIntent(createShareForecastIntent());
      }
    }
  }
  // @SuppressWarnings("ConstantConditions")
  @Override
  // @TargetApi(14)
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // Inflate menu resource file.
    inflater.inflate(R.menu.menu_detail_fragment, menu);

    /* Locate MenuItem with ShareActionProvider */
    MenuItem menuItem = menu.findItem(R.id.action_share);

    // Fetch and store ShareActionProvider

    ShareActionProvider mShareActionProvider =
        (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);
    if (mShareActionProvider != null) {
      mShareActionProvider.setShareIntent(createShareForecastIntent());
    } else {
      Log.d(LOG_TAG, "----> mShareActionProvider is null");
    }
  }
示例#24
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {

    getMenuInflater().inflate(R.menu.menu_article, menu);

    MenuItem item = menu.findItem(R.id.action_share);
    actionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
    actionProvider.setShareIntent(shareIntent);
    return true;
  }
示例#25
0
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // Inflate the menu; this adds items to the action bar if it is present.
    inflater.inflate(R.menu.detailfragment, menu);

    MenuItem shareItem = menu.findItem(R.id.action_share);
    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);

    if (mForecast != null) {
      mShareActionProvider.setShareIntent(createShareForecastIntent());
    }
  }
    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
      // Inflate the menu; this adds items to the action bar if it is present.
      inflater.inflate(R.menu.detailfragment, menu);

      // Obtiene el elemento de menu
      MenuItem menuItem = menu.findItem(R.id.action_share);

      // Obtiene el provider y lo mantiene para establecer o cambiar el lIntent
      ShareActionProvider mShareActionProvider =
          (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);

      /*Casa el intento con el provider, se puedde actualizar en cada momento, como cuando
      el usuario cambia datos que qeere compartir*/
      if (mShareActionProvider != null) {
        mShareActionProvider.setShareIntent(createShareForecastIntent());
      } else {
        Log.d(LOG_TAG, "Share Action Provder is null?");
      }
    }
示例#27
0
  private void setShareIntent(int position) {

    if (mShareActionProvider != null) {
      // Get the currently selected item, and retrieve it's share intent
      ContentItem item = mItems.get(position);
      Intent shareIntent = item.getShareIntent(MainActivity.this);

      // Now update the ShareActionProvider with the new share intent
      mShareActionProvider.setShareIntent(shareIntent);
    }
  }
 public boolean onCreateOptionsMenu(Menu menu) {
   // Inflate the menu items for use in the action bar
   MenuInflater inflater = getMenuInflater();
   inflater.inflate(R.menu.product_detail, menu);
   // Get the menu item.
   MenuItem menuItem = menu.findItem(R.id.action_share);
   // Get the provider and hold onto it to set/change the share intent.
   mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);
   mShareActionProvider.setShareIntent(getDefaultIntent());
   return super.onCreateOptionsMenu(menu);
 }
示例#29
0
  @Override
  public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    if (!data.moveToFirst()) return;
    transformCursorData(data);
    fillUI();
    if (mShareActionProvider != null) {
      mShareActionProvider.setShareIntent(createShareIntent());
    }
    // Adjust Image View on Phone

  }
示例#30
0
  private void setShareIntent() {

    // create an Intent with the contents of the TextView
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Book Recommendation!");
    shareIntent.putExtra(Intent.EXTRA_TEXT, mImageURL);

    // Make sure the provider knows
    // it should work with that Intent
    mShareActionProvider.setShareIntent(shareIntent);
  }