@Override void executeOnUiThread(MessageContextMenu menu, MessageEditorData editorData) { Uri uri = MatchedUri.getUserListUri( editorData.ma.getUserId(), UserListType.USERS_OF_MESSAGE, menu.messageList.isTimelineCombined(), menu.getMsgId()); if (MyLog.isLoggable(this, MyLog.DEBUG)) { MyLog.d(this, "onItemClick, startActivity=" + uri); } menu.messageList.getActivity().startActivity(MyAction.VIEW_USERS.getIntent(uri)); }
@Override protected void setUp() throws Exception { super.setUp(); TestSuite.initializeWithData(this); iteration = (iteration >= 4 ? 1 : iteration + 1); switch (iteration) { case 2: showAttachedImages = showAttachedImagesOld; showAvatars = !showAvatarsOld; break; case 3: showAttachedImages = !showAttachedImagesOld; showAvatars = showAvatarsOld; break; case 4: showAttachedImages = !showAttachedImagesOld; showAvatars = !showAvatarsOld; break; default: showAttachedImagesOld = MyPreferences.showAttachedImages(); showAvatarsOld = MyPreferences.showAvatars(); showAttachedImages = showAttachedImagesOld; showAvatars = showAvatarsOld; break; } setPreferences(); MyLog.setLogToFile(true); logStartStop("setUp started"); MyAccount ma = MyContextHolder.get() .persistentAccounts() .fromAccountName(TestSuite.CONVERSATION_ACCOUNT_NAME); assertTrue(ma.isValid()); MyContextHolder.get().persistentAccounts().setCurrentAccount(ma); Intent intent = new Intent( Intent.ACTION_VIEW, MatchedUri.getTimelineUri(ma.getUserId(), TimelineType.HOME, false, 0)); setActivityIntent(intent); activity = getActivity(); assertTrue("MyService is available", MyServiceManager.isServiceAvailable()); logStartStop("setUp ended"); }
@Override void executeOnUiThread(MessageContextMenu menu, MessageEditorData editorData) { Uri uri = MatchedUri.getTimelineItemUri( editorData.ma.getUserId(), menu.messageList.getTimelineType(), menu.messageList.isTimelineCombined(), menu.messageList.getSelectedUserId(), menu.getMsgId()); String action = menu.messageList.getActivity().getIntent().getAction(); if (Intent.ACTION_PICK.equals(action) || Intent.ACTION_GET_CONTENT.equals(action)) { if (MyLog.isLoggable(this, MyLog.DEBUG)) { MyLog.d(this, "onItemClick, setData=" + uri); } menu.messageList.getActivity().setResult(Activity.RESULT_OK, new Intent().setData(uri)); } else { if (MyLog.isLoggable(this, MyLog.DEBUG)) { MyLog.d(this, "onItemClick, startActivity=" + uri); } menu.messageList.getActivity().startActivity(MyAction.VIEW_CONVERSATION.getIntent(uri)); } }
private void notify(TimelineType timelineType, int messageTitleResId, String messageText) { String ringtone = MyPreferences.getString(MyPreferences.KEY_RINGTONE_PREFERENCE, null); Uri sound = TextUtils.isEmpty(ringtone) ? null : Uri.parse(ringtone); Notification.Builder builder = new Notification.Builder(myContext.context()) .setSmallIcon( MyPreferences.getBoolean(MyPreferences.KEY_NOTIFICATION_ICON_ALTERNATIVE, false) ? R.drawable.notification_icon_circle : R.drawable.notification_icon) .setContentTitle(myContext.context().getText(messageTitleResId)) .setContentText(messageText) .setSound(sound); if (mNotificationsVibrate) { builder.setVibrate(new long[] {200, 300, 200, 300}); } builder.setLights(Color.GREEN, 500, 1000); // Prepare "intent" to launch timeline activities exactly like in // org.andstatus.app.TimelineActivity.onOptionsItemSelected Intent intent = new Intent(myContext.context(), TimelineActivity.class); intent.setData( Uri.withAppendedPath( MatchedUri.getTimelineUri( 0, timelineType, myContext.persistentAccounts().size() > 1, 0), "rnd/" + android.os.SystemClock.elapsedRealtime())); PendingIntent pendingIntent = PendingIntent.getActivity( myContext.context(), timelineType.hashCode(), intent, PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentIntent(pendingIntent); myContext.notify(timelineType, builder.build()); }