/**
  * Stops the recording.
  *
  * @param context the context
  * @param trackRecordingServiceConnection the track recording service connection
  * @param showEditor true to show the editor
  */
 public static void stopRecording(
     Context context,
     TrackRecordingServiceConnection trackRecordingServiceConnection,
     boolean showEditor) {
   ITrackRecordingService trackRecordingService =
       trackRecordingServiceConnection.getServiceIfBound();
   if (trackRecordingService != null) {
     try {
       if (showEditor) {
         /*
          * Need to remember the recordingTrackId before calling
          * endCurrentTrack. endCurrentTrack sets the value to -1L.
          */
         long recordingTrackId =
             PreferencesUtils.getLong(context, R.string.recording_track_id_key);
         trackRecordingService.endCurrentTrack();
         if (recordingTrackId != PreferencesUtils.RECORDING_TRACK_ID_DEFAULT) {
           Intent intent =
               IntentUtils.newIntent(context, TrackEditActivity.class)
                   .putExtra(TrackEditActivity.EXTRA_TRACK_ID, recordingTrackId)
                   .putExtra(TrackEditActivity.EXTRA_NEW_TRACK, true);
           context.startActivity(intent);
         }
       } else {
         trackRecordingService.endCurrentTrack();
       }
     } catch (Exception e) {
       Log.e(TAG, "Unable to stop recording.", e);
     }
   } else {
     resetRecordingState(context);
   }
   trackRecordingServiceConnection.unbindAndStop();
 }
Esempio n. 2
0
  @Test
  public void testGetEnvVarMap() throws Exception {
    final HashMap<String, String> actual = IntentUtils.getEnvVarMap(testIntent);
    for (final String actualEnvVarName : actual.keySet()) {
      assertTrue(
          "Actual key exists in test data: " + actualEnvVarName,
          TEST_ENV_VAR_MAP.containsKey(actualEnvVarName));

      final String expectedValue = TEST_ENV_VAR_MAP.get(actualEnvVarName);
      final String actualValue = actual.get(actualEnvVarName);
      assertEquals("Actual env var value matches test data", expectedValue, actualValue);
    }
  }
Esempio n. 3
0
 public static Intent createDefaultClickIntent(Context paramContext, String paramString1, String paramString2, String paramString3, String paramString4)
 {
   Intent localIntent = new Intent();
   localIntent.setClass(paramContext, MainActivity.class);
   if (!TextUtils.isEmpty(paramString1))
   {
     localIntent = IntentUtils.createViewDocumentUrlIntent(paramContext, paramString4);
     localIntent.putExtra("error_doc_id", paramString1);
   }
   if (!TextUtils.isEmpty(paramString2)) {
     localIntent.putExtra("error_title", paramString2);
   }
   if (!TextUtils.isEmpty(paramString3)) {
     localIntent.putExtra("error_html_message", paramString3);
   }
   return localIntent;
 }
 @TargetApi(14)
 public MMJSResponse addEvent(Map map) {
   MMLog.b(d, "addEvent parameters: " + map);
   if (VERSION.SDK_INT < 14) {
     return MMJSResponse.b("Not supported");
   }
   if (!(map == null || map.get("parameters") == null)) {
     try {
       String str;
       String str2;
       String str3;
       String str4;
       Date date;
       Date parseDate;
       JSONObject jSONObject = new JSONObject((String) map.get("parameters"));
       try {
         str = jSONObject.getString(PlusShare.KEY_CONTENT_DEEP_LINK_METADATA_DESCRIPTION);
       } catch (JSONException e) {
         MMLog.e(d, "Unable to get calendar event description");
         str = null;
       }
       try {
         str2 = jSONObject.getString("summary");
       } catch (JSONException e2) {
         MMLog.b(d, "Unable to get calendar event description");
         str2 = null;
       }
       try {
         String str5 = jSONObject.getString("transparency");
       } catch (JSONException e3) {
         MMLog.b(d, "Unable to get calendar event transparency");
         boolean z = false;
       }
       try {
         String str6 = jSONObject.getString("reminder");
       } catch (JSONException e4) {
         MMLog.b(d, "Unable to get calendar event reminder");
         boolean z2 = false;
       }
       try {
         str3 = jSONObject.getString("location");
       } catch (JSONException e5) {
         MMLog.b(d, "Unable to get calendar event location");
         str3 = null;
       }
       try {
         String str7 = jSONObject.getString("status");
       } catch (JSONException e6) {
         MMLog.b(d, "Unable to get calendar event status");
         boolean z3 = false;
       }
       try {
         str4 = a(jSONObject.getJSONObject("recurrence"));
       } catch (JSONException e7) {
         MMLog.b(d, "Unable to get calendar event recurrence");
         str4 = null;
       }
       try {
         date = DateUtils.parseDate(jSONObject.getString("start"), e);
       } catch (DateParseException e8) {
         MMLog.e(d, "Error parsing calendar event start date");
         date = null;
       } catch (JSONException e9) {
         MMLog.e(d, "Unable to get calendar event start date");
         date = null;
       }
       try {
         parseDate = DateUtils.parseDate(jSONObject.getString("end"), e);
       } catch (DateParseException e10) {
         MMLog.e(d, "Error parsing calendar event end date");
         parseDate = null;
       } catch (JSONException e11) {
         MMLog.b(d, "Unable to get calendar event end date");
         parseDate = null;
       }
       MMLog.b(
           d,
           String.format(
               "Creating calendar event: title: %s, location: %s, start: %s, end: %s, status: %s, summary: %s, rrule: %s",
               new Object[] {str, str3, date, parseDate, obj, str2, str4}));
       if (str == null || date == null) {
         MMLog.e(d, "Description and start must be provided to create calendar event.");
         return MMJSResponse.b("Calendar Event Creation Failed.  Minimum parameters not provided");
       } else {
         Intent data = new Intent("android.intent.action.INSERT").setData(Events.CONTENT_URI);
         if (date != null) {
           data.putExtra("beginTime", date.getTime());
         }
         if (parseDate != null) {
           data.putExtra(Event.END_TIME, parseDate.getTime());
         }
         if (str != null) {
           data.putExtra(PlusShare.KEY_CONTENT_DEEP_LINK_METADATA_TITLE, str);
         }
         if (str2 != null) {
           data.putExtra(PlusShare.KEY_CONTENT_DEEP_LINK_METADATA_DESCRIPTION, str2);
         }
         if (str3 != null) {
           data.putExtra("eventLocation", str3);
         }
         if (str4 != null) {
           data.putExtra("rrule", str4);
         }
         if (obj != null) {
           MMLog.d(d, "Calendar addEvent does not support status");
         }
         if (i != 0) {
           MMLog.d(d, "Calendar addEvent does not support transparency");
         }
         if (i != 0) {
           MMLog.d(d, "Calendar addEvent does not support reminder");
         }
         Context context = (Context) this.b.get();
         if (context != null) {
           IntentUtils.c(context, data);
           Event.a(
               context, Event.INTENT_CALENDAR_EVENT, b((String) map.get("PROPERTY_EXPANDING")));
           return MMJSResponse.a("Calendar Event Created");
         }
       }
     } catch (JSONException e12) {
       MMLog.e(d, "Unable to parse calendar addEvent parameters");
       return MMJSResponse.b("Calendar Event Creation Failed.  Invalid parameters");
     }
   }
   return null;
 }
  @Override
  public void onLinkClick(
      final String link,
      final String orig,
      final long accountId,
      final long extraId,
      final int type,
      final boolean sensitive,
      final int start,
      final int end) {
    if (manager != null && manager.isActive()) return;
    if (!isPrivateData()) {
      // BEGIN HotMobi
      final LinkEvent event = LinkEvent.create(context, link, type);
      HotMobiLogger.getInstance(context).log(accountId, event);
      // END HotMobi
    }

    switch (type) {
      case TwidereLinkify.LINK_TYPE_MENTION:
        {
          IntentUtils.openUserProfile(context, accountId, -1, link, null, true);
          break;
        }
      case TwidereLinkify.LINK_TYPE_HASHTAG:
        {
          Utils.openTweetSearch(context, accountId, "#" + link);
          break;
        }
      case TwidereLinkify.LINK_TYPE_LINK:
        {
          if (PreviewMediaExtractor.isSupported(link)) {
            openMedia(accountId, extraId, sensitive, link, start, end);
          } else {
            openLink(link);
          }
          break;
        }
      case TwidereLinkify.LINK_TYPE_LIST:
        {
          final String[] mentionList = link.split("/");
          if (mentionList.length != 2) {
            break;
          }
          Utils.openUserListDetails(context, accountId, -1, -1, mentionList[0], mentionList[1]);
          break;
        }
      case TwidereLinkify.LINK_TYPE_CASHTAG:
        {
          Utils.openTweetSearch(context, accountId, link);
          break;
        }
      case TwidereLinkify.LINK_TYPE_USER_ID:
        {
          IntentUtils.openUserProfile(
              context, accountId, NumberUtils.toLong(link, -1), null, null, true);
          break;
        }
      case TwidereLinkify.LINK_TYPE_STATUS:
        {
          Utils.openStatus(context, accountId, NumberUtils.toLong(link, -1));
          break;
        }
    }
  }