Skip to content

Commit

Permalink
Remove scribing
Browse files Browse the repository at this point in the history
Change-Id: Ie3e897773c58d39693dc4025d59f049362d1eefa
  • Loading branch information
Eric Frohnhoefer committed May 9, 2018
1 parent 756d94b commit cd1550c
Show file tree
Hide file tree
Showing 122 changed files with 20 additions and 8,268 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import com.example.app.BaseActivity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
*/
public class TimelineActivity extends BaseActivity {

final WeakReference<Activity> activityRef = new WeakReference<Activity>(TimelineActivity.this);
final WeakReference<Activity> activityRef = new WeakReference<>(TimelineActivity.this);

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.view.View;
import android.widget.Button;

import com.example.app.BaseActivity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class ComposerController {
composerView.setTweetText(generateText(text, hashtags));
setProfilePhoto();
setImageView(imageUri);
dependencyProvider.getScribeClient().impression();
}

String generateText(String text, String hashtags) {
Expand Down Expand Up @@ -121,7 +120,6 @@ public void onTextChanged(String text) {

@Override
public void onTweetPost(String text) {
dependencyProvider.getScribeClient().click(ScribeConstants.SCRIBE_TWEET_ELEMENT);
final Intent intent = new Intent(composerView.getContext(), TweetUploadService.class);
intent.putExtra(TweetUploadService.EXTRA_USER_TOKEN, session.getAuthToken());
intent.putExtra(TweetUploadService.EXTRA_TWEET_TEXT, text);
Expand All @@ -137,7 +135,6 @@ public void onCloseClick() {
}

void onClose() {
dependencyProvider.getScribeClient().click(ScribeConstants.SCRIBE_CANCEL_ELEMENT);
sendCancelBroadcast();
finisher.finish();
}
Expand Down Expand Up @@ -187,9 +184,5 @@ TwitterApiClient getApiClient(TwitterSession session) {
Validator getTweetValidator() {
return tweetValidator;
}

ComposerScribeClient getScribeClient() {
return new ComposerScribeClientImpl(TweetComposer.getInstance().getScribeClient());
}
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
import com.twitter.sdk.android.core.TwitterCore;
import com.twitter.sdk.android.core.TwitterSession;
import com.twitter.sdk.android.core.internal.network.UrlUtils;
import com.twitter.sdk.android.core.internal.scribe.DefaultScribeClient;
import com.twitter.sdk.android.core.internal.scribe.ScribeConfig;

import java.net.URL;
import java.util.List;
Expand All @@ -47,12 +45,10 @@ public class TweetComposer {
private static final String MIME_TYPE_JPEG = "image/jpeg";
private static final String TWITTER_PACKAGE_NAME = "com.twitter.android";
private static final String WEB_INTENT = "https://twitter.com/intent/tweet?text=%s&url=%s";
private static final String KIT_SCRIBE_NAME = "TweetComposer";

SessionManager<TwitterSession> sessionManager;
GuestSessionProvider guestSessionProvider;
Context context;
ScribeClient scribeClient;

public static TweetComposer getInstance() {
if (instance == null) {
Expand All @@ -66,35 +62,19 @@ public static TweetComposer getInstance() {
}

TweetComposer() {
scribeClient = new ScribeClientImpl(null);

sessionManager = TwitterCore.getInstance().getSessionManager();
guestSessionProvider = TwitterCore.getInstance().getGuestSessionProvider();
context = Twitter.getInstance().getContext(getIdentifier());

setUpScribeClient();
}

public String getVersion() {
return BuildConfig.VERSION_NAME + "." + BuildConfig.BUILD_NUMBER;
}

private void setUpScribeClient() {
final ScribeConfig config =
DefaultScribeClient.getScribeConfig(KIT_SCRIBE_NAME, getVersion());
scribeClient = new ScribeClientImpl(new DefaultScribeClient(context,
sessionManager, guestSessionProvider, Twitter.getInstance().getIdManager(),
config));
}

public String getIdentifier() {
return BuildConfig.GROUP + ":" + BuildConfig.ARTIFACT_ID;
}

ScribeClient getScribeClient() {
return scribeClient;
}

/**
* The TweetComposer Builder will use the installed Twitter instance and fall back to a browser
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public class ComposerControllerTest {
private TwitterSession mockTwitterSession;
private AccountService mockAccountService;
private ComposerActivity.Finisher mockFinisher;
private ComposerScribeClient mockComposerScribeClient;
private ComposerController.DependencyProvider mockDependencyProvider;

@Before
Expand All @@ -81,13 +80,11 @@ public void setUp() throws Exception {
.thenReturn(mock(Call.class));
when(mockTwitterApiClient.getAccountService()).thenReturn(mockAccountService);

mockComposerScribeClient = mock(ComposerScribeClient.class);

mockDependencyProvider = mock(ComposerController.DependencyProvider.class);
when(mockDependencyProvider.getApiClient(any(TwitterSession.class)))
.thenReturn(mockTwitterApiClient);
when(mockDependencyProvider.getTweetValidator()).thenReturn(new Validator());
when(mockDependencyProvider.getScribeClient()).thenReturn(mockComposerScribeClient);
}

@Test
Expand All @@ -100,13 +97,11 @@ public void testComposerController() {
// - sets initial Tweet text and cursor position
// - gets a TwitterApiClient AccountService to set the profile photo
// - sets card view in composer
// - scribes a Tweet Composer impression
verify(mockComposerView).setCallbacks(any(ComposerController.ComposerCallbacks.class));
verify(mockComposerView).setTweetText(ANY_TEXT + " " + ANY_HASHTAG);
verify(mockComposerView).setImageView(Uri.EMPTY);
verify(mockDependencyProvider).getApiClient(mockTwitterSession);
verify(mockAccountService).verifyCredentials(eq(false), eq(true), eq(false));
verify(mockComposerScribeClient).impression();
}

@Test
Expand Down Expand Up @@ -189,15 +184,13 @@ public void testComposerCallbacksImpl_onTweetPost() {
// assert that
// - context is used to start the TweetUploadService
// - intent extras contain the session token and tweet text and card
// - scribes a Tweet Composer Tweet Click
final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
verify(mockContext).startService(intentCaptor.capture());
final Intent intent = intentCaptor.getValue();
assertEquals(TweetUploadService.class.getCanonicalName(),
intent.getComponent().getClassName());
assertEquals(mockAuthToken, intent.getParcelableExtra(TweetUploadService.EXTRA_USER_TOKEN));
assertEquals(Uri.EMPTY, intent.getParcelableExtra(TweetUploadService.EXTRA_IMAGE_URI));
verify(mockComposerScribeClient).click(eq(ScribeConstants.SCRIBE_TWEET_ELEMENT));
}

@Test
Expand All @@ -209,9 +202,7 @@ public void testComposerCallbacksImpl_onClose() {
callbacks.onCloseClick();
// assert that
// - finishes the activity
// - scribes a Tweet Composer Cancel click
verify(mockFinisher).finish();
verify(mockComposerScribeClient).click(eq(ScribeConstants.SCRIBE_CANCEL_ELEMENT));
}

@Test
Expand Down
Loading

0 comments on commit cd1550c

Please sign in to comment.