Beispiel #1
0
 public String getPodcastEmailSummary() {
   StringBuilder sb = new StringBuilder();
   if (currentPodcastInPlayer < metaHolder.getSize()) {
     MetaFile mf = currentMeta();
     if (mf != null) {
       sb.append("\nWanted to let you know about this podcast:\n\n");
       sb.append("\nTitle: " + mf.getTitle());
       String searchName = mf.getFeedName();
       sb.append("\nFeed Title: " + searchName);
       List<Subscription> subs = getSubscriptions();
       for (Subscription sub : subs) {
         if (sub.name.equals(searchName)) {
           sb.append("\nFeed URL: " + sub.url);
           break;
         }
       }
       if (mf.getUrl() != null) {
         sb.append("\nPodcast URL: " + mf.getUrl());
       }
     }
   }
   sb.append("\n\n\n");
   sb.append("This email sent from " + CarCastApplication.getAppTitle() + ".");
   return sb.toString();
 }
Beispiel #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.recorder);

    setTitle(CarCastApplication.getAppTitle() + ": Audio Note Recorder");

    setReadyToRecord(true);

    fb(R.id.audioRecorderRecordButton)
        .setOnClickListener(
            new OnClickListener() {
              @Override
              public void onClick(View v) {
                Recording.record();
                // transition to record mode
                setReadyToRecord(false);
              }
            });

    fb(R.id.audioRecorderCancelButton)
        .setOnClickListener(
            new OnClickListener() {
              @Override
              public void onClick(View v) {
                Recording.cancel();
                // transition back to ready
                setReadyToRecord(true);
              }
            });

    fb(R.id.audioRecorderSaveButton)
        .setOnClickListener(
            new OnClickListener() {
              @Override
              public void onClick(View v) {
                Recording.save(AudioRecorder.this);

                // transition back to ready
                setReadyToRecord(true);
                showRecordings();
              }
            });

    ListView listView = (ListView) findViewById(R.id.audioRecorderListing);

    listView.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
            Recording.getRecordings().get(position).play();
          }
        });

    registerForContextMenu(listView);

    showRecordings();
  }
Beispiel #3
0
  @Override
  public void onCreate() {
    super.onCreate();
    ExceptionHandler.register(this);

    partialWakeLock =
        ((PowerManager) getSystemService(Context.POWER_SERVICE))
            .newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, CarCastApplication.getAppTitle());
    partialWakeLock.setReferenceCounted(false);

    PhoneStateListener phoneStateListener =
        new PhoneStateListener() {
          @Override
          public void onCallStateChanged(int state, String incomingNumber) {
            super.onCallStateChanged(state, incomingNumber);

            if (state == TelephonyManager.CALL_STATE_OFFHOOK
                || state == TelephonyManager.CALL_STATE_RINGING) {
              if (mediaPlayer.isPlaying()) {
                wasPausedByPhoneCall = true;
                pauseNow();
              }
            }

            if (state == TelephonyManager.CALL_STATE_IDLE && wasPausedByPhoneCall) {
              wasPausedByPhoneCall = false;
              pauseOrPlay();
            }
          }
        };

    final TelephonyManager telMgr =
        (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
    telMgr.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);

    Config.PodcastsRoot.mkdirs();
    metaHolder = new MetaHolder();
    mediaPlayer.setOnCompletionListener(this);

    // restore state;
    currentPodcastInPlayer = 0;

    restoreState();

    // Due to some crazy quirks in Android, this cannot be done in the
    // manifest and must be done manually like this. See
    // http://groups.google.com/group/android-developers/browse_thread/thread/6d0dda99b4f42c8f/d7de082acdb0da25
    headsetReceiver = new HeadsetReceiver(this);
    registerReceiver(headsetReceiver, new IntentFilter(Intent.ACTION_HEADSET_PLUG));
    remoteControlReceiver = new RemoteControlReceiver(this);
    registerReceiver(headsetReceiver, new IntentFilter(Intent.ACTION_MEDIA_BUTTON));

    // foreground stuff
    try {
      mStartForeground = getClass().getMethod("startForeground", mStartForegroundSignature);
      mStopForeground = getClass().getMethod("stopForeground", mStopForegroundSignature);
    } catch (NoSuchMethodException e) {
      // Running on an older platform.
      mStartForeground = mStopForeground = null;
      try {
        mSetForeground = getClass().getMethod("setForeground", mSetForegroundSignature);
      } catch (NoSuchMethodException e1) {
        throw new IllegalStateException(
            "OS doesn't have Service.startForeground OR Service.setForeground!");
      }
    }
  }