public static Intent createShareIntent(Context context, MovieEntity entity) {
    Activity activity;
    String message =
        "Check out "
            + entity.getTitle()
            + " at https://www.themoviedb.org/movie/"
            + String.valueOf(entity.getId());

    if (context instanceof Activity) {
      activity = (android.app.Activity) context;

      ShareCompat.IntentBuilder intentBuilder =
          ShareCompat.IntentBuilder.from(activity).setType("text/plain").setText(message);

      return intentBuilder.getIntent();
    }
    return null;
  }
 // This is the share menu
 public boolean onCreateOptionsMenu(Menu menu) {
   // Inflate the menu; this adds items to the action bar if it is present.
   getMenuInflater().inflate(R.menu.share_menu, menu);
   MenuItem item = menu.findItem(R.id.menu_item_share);
   mShareActionProvider = (ShareActionProvider) item.getActionProvider();
   // Create the share Intent
   String playStoreLink = " https://play.google.com/store/apps/details?id=" + getPackageName();
   String yourShareText = getString(R.string.share_this) + playStoreLink;
   Intent shareIntent =
       ShareCompat.IntentBuilder.from(this)
           .setType("text/plain")
           .setText(yourShareText)
           .getIntent();
   // Set the share Intent
   mShareActionProvider.setShareIntent(shareIntent);
   return true;
 }
예제 #3
0
  private void sendSound(int position) {

    String path = sounds[position].getPath().replace("/data/data/de.tuete.soundboard/files/", "");
    final File file = new File(getFilesDir(), path);
    Log.d(TAG, "File path: " + file.getPath());

    final Uri uri = FileProvider.getUriForFile(this, "com.mydomain.fileprovider", file);
    Log.d(TAG, uri.toString());

    final Intent intent =
        ShareCompat.IntentBuilder.from(this)
            .setType("audio/*")
            .setStream(uri)
            .createChooserIntent()
            //		    .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)
            .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

    startActivity(intent);
  }
예제 #4
0
  private void submitReport(Report report, File logs) {
    DisplayMetrics dm = context.getResources().getDisplayMetrics();
    String densityBucket = getDensityString(dm);

    ShareCompat.IntentBuilder intent =
        ShareCompat.IntentBuilder.from(context)
            .setType("message/rfc822")
            // TODO: .addEmailTo("*****@*****.**")
            .setSubject(report.title);

    StringBuilder body = new StringBuilder();
    if (!Strings.isBlank(report.description)) {
      body.append("{panel:title=Description}\n").append(report.description).append("\n{panel}\n\n");
    }

    body.append("{panel:title=App}\n");
    body.append("Version: ").append(BuildConfig.VERSION_NAME).append('\n');
    body.append("Version code: ").append(BuildConfig.VERSION_CODE).append('\n');
    body.append("{panel}\n\n");

    body.append("{panel:title=Device}\n");
    body.append("Make: ").append(Build.MANUFACTURER).append('\n');
    body.append("Model: ").append(Build.MODEL).append('\n');
    body.append("Resolution: ")
        .append(dm.heightPixels)
        .append("x")
        .append(dm.widthPixels)
        .append('\n');
    body.append("Density: ")
        .append(dm.densityDpi)
        .append("dpi (")
        .append(densityBucket)
        .append(")\n");
    body.append("Release: ").append(Build.VERSION.RELEASE).append('\n');
    body.append("API: ").append(Build.VERSION.SDK_INT).append('\n');
    body.append("{panel}");

    intent.setText(body.toString());

    if (screenshot != null && report.includeScreenshot) {
      intent.addStream(Uri.fromFile(screenshot));
    }
    if (logs != null) {
      intent.addStream(Uri.fromFile(logs));
    }

    Intents.maybeStartActivity(context, intent.getIntent());
  }
  @Override
  public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);

    String[] toList = new String[] {mAddress.getText().toString()};

    // IntentBuilder をインスタンス化
    ShareCompat.IntentBuilder builder = ShareCompat.IntentBuilder.from(CustomSendActivity.this);
    // データをセットする
    builder.setChooserTitle("Choose Send App");
    builder.setEmailTo(toList);
    builder.setSubject(mSubject.getText().toString());
    builder.setText(mMessage.getText().toString());
    builder.setType("text/plain");

    ShareCompat.configureMenuItem(menu, R.id.menu_share, builder);

    return true;
  }
  @TargetApi(11)
  private void fillData() {
    TextView seriesname = (TextView) findViewById(R.id.title);
    TextView overview = (TextView) findViewById(R.id.TextViewShowInfoOverview);
    TextView airstime = (TextView) findViewById(R.id.TextViewShowInfoAirtime);
    TextView network = (TextView) findViewById(R.id.TextViewShowInfoNetwork);
    TextView status = (TextView) findViewById(R.id.TextViewShowInfoStatus);

    final Series show = DBUtils.getShow(this, String.valueOf(getShowId()));
    if (show == null) {
      finish();
      return;
    }

    // Name
    seriesname.setText(show.getSeriesName());

    // Overview
    if (show.getOverview().length() == 0) {
      overview.setText("");
    } else {
      overview.setText(show.getOverview());
    }

    // Airtimes
    if (show.getAirsDayOfWeek().length() == 0 || show.getAirsTime() == -1) {
      airstime.setText(getString(R.string.show_noairtime));
    } else {
      String[] values =
          Utils.parseMillisecondsToTime(
              show.getAirsTime(), show.getAirsDayOfWeek(), getApplicationContext());
      airstime.setText(getString(R.string.show_airs) + " " + values[1] + " " + values[0]);
    }

    // Network
    if (show.getNetwork().length() == 0) {
      network.setText("");
    } else {
      network.setText(getString(R.string.show_network) + " " + show.getNetwork());
    }

    // Running state
    if (show.getStatus() == 1) {
      status.setTextColor(Color.GREEN);
      status.setText(getString(R.string.show_isalive));
    } else if (show.getStatus() == 0) {
      status.setTextColor(Color.GRAY);
      status.setText(getString(R.string.show_isnotalive));
    }

    // first airdate
    long airtime = Utils.buildEpisodeAirtime(show.getFirstAired(), show.getAirsTime());
    Utils.setValueOrPlaceholder(
        findViewById(R.id.TextViewShowInfoFirstAirdate), Utils.formatToDate(airtime, this));

    // Others
    Utils.setValueOrPlaceholder(
        findViewById(R.id.TextViewShowInfoActors), Utils.splitAndKitTVDBStrings(show.getActors()));
    Utils.setValueOrPlaceholder(
        findViewById(R.id.TextViewShowInfoContentRating), show.getContentRating());
    Utils.setValueOrPlaceholder(
        findViewById(R.id.TextViewShowInfoGenres), Utils.splitAndKitTVDBStrings(show.getGenres()));
    Utils.setValueOrPlaceholder(
        findViewById(R.id.TextViewShowInfoRuntime),
        show.getRuntime() + " " + getString(R.string.show_airtimeunit));

    // TVDb rating
    String ratingText = show.getRating();
    if (ratingText != null && ratingText.length() != 0) {
      RatingBar ratingBar = (RatingBar) findViewById(R.id.bar);
      ratingBar.setProgress((int) (Double.valueOf(ratingText) / 0.1));
      TextView rating = (TextView) findViewById(R.id.value);
      rating.setText(ratingText + "/10");
    }

    // IMDb button
    View imdbButton = (View) findViewById(R.id.buttonShowInfoIMDB);
    final String imdbid = show.getImdbId();
    if (imdbButton != null) {
      imdbButton.setOnClickListener(
          new OnClickListener() {
            public void onClick(View v) {
              fireTrackerEvent("Show IMDb page");

              if (imdbid.length() != 0) {
                Intent myIntent =
                    new Intent(Intent.ACTION_VIEW, Uri.parse("imdb:///title/" + imdbid + "/"));
                try {
                  startActivity(myIntent);
                } catch (ActivityNotFoundException e) {
                  myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(IMDB_TITLE_URL + imdbid));
                  startActivity(myIntent);
                }
              } else {
                Toast.makeText(
                        getApplicationContext(),
                        getString(R.string.show_noimdbentry),
                        Toast.LENGTH_LONG)
                    .show();
              }
            }
          });
    }

    // TVDb button
    View tvdbButton = (View) findViewById(R.id.buttonTVDB);
    final String tvdbId = show.getId();
    if (tvdbButton != null) {
      tvdbButton.setOnClickListener(
          new OnClickListener() {
            public void onClick(View v) {
              fireTrackerEvent("Show TVDb page");
              Intent i =
                  new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.TVDB_SHOW_URL + tvdbId));
              startActivity(i);
            }
          });
    }

    // Shout button
    findViewById(R.id.buttonShouts)
        .setOnClickListener(
            new OnClickListener() {
              @Override
              public void onClick(View v) {
                fireTrackerEvent("Show Trakt Shouts");
                TraktShoutsFragment newFragment =
                    TraktShoutsFragment.newInstance(show.getSeriesName(), Integer.valueOf(tvdbId));

                newFragment.show(getSupportFragmentManager(), "shouts-dialog");
              }
            });

    // Share intent
    mShareIntentBuilder =
        ShareCompat.IntentBuilder.from(this)
            .setChooserTitle(R.string.share)
            .setText(
                getString(R.string.share_checkout)
                    + " \""
                    + show.getSeriesName()
                    + "\" via @SeriesGuide "
                    + ShowInfoActivity.IMDB_TITLE_URL
                    + imdbid)
            .setType("text/plain");

    // Poster
    final ImageView poster = (ImageView) findViewById(R.id.ImageViewShowInfoPoster);
    ImageProvider.getInstance(this).loadImage(poster, show.getPoster(), false);

    // trakt ratings
    TraktSummaryTask task = new TraktSummaryTask(this, findViewById(R.id.ratingbar)).show(tvdbId);
    AndroidUtils.executeAsyncTask(task, new Void[] {null});
  }