Initial commit
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
package com.twitter.sdk.android.tweetcomposer;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.squareup.picasso.RequestCreator;
|
||||
import com.twitter.sdk.android.tweetcomposer.RoundedCornerTransformation;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AppCardView extends LinearLayout {
|
||||
ImageView a;
|
||||
TextView b;
|
||||
TextView c;
|
||||
|
||||
public AppCardView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
void a(Context context) {
|
||||
setOrientation(1);
|
||||
LinearLayout.inflate(context, R$layout.tw__app_card, this);
|
||||
a();
|
||||
b();
|
||||
}
|
||||
|
||||
void b() {
|
||||
this.b.setTextColor(getResources().getColor(R$color.tw__composer_blue_text));
|
||||
}
|
||||
|
||||
@Override // android.widget.LinearLayout, android.view.View
|
||||
protected void onMeasure(int i, int i2) {
|
||||
int dimensionPixelSize = getResources().getDimensionPixelSize(R$dimen.tw__card_maximum_width);
|
||||
int size = View.MeasureSpec.getSize(i);
|
||||
if (dimensionPixelSize > 0 && dimensionPixelSize < size) {
|
||||
i = View.MeasureSpec.makeMeasureSpec(dimensionPixelSize, View.MeasureSpec.getMode(i));
|
||||
}
|
||||
super.onMeasure(i, i2);
|
||||
}
|
||||
|
||||
void setAppName(String str) {
|
||||
this.c.setText(str);
|
||||
}
|
||||
|
||||
void setCard(Card card) {
|
||||
setImage(Uri.parse(card.imageUri));
|
||||
setAppName(card.appName);
|
||||
}
|
||||
|
||||
void setImage(Uri uri) {
|
||||
int dimensionPixelSize = getResources().getDimensionPixelSize(R$dimen.tw__card_radius_medium);
|
||||
RoundedCornerTransformation.Builder builder = new RoundedCornerTransformation.Builder();
|
||||
builder.a(dimensionPixelSize, dimensionPixelSize, 0, 0);
|
||||
RoundedCornerTransformation a = builder.a();
|
||||
RequestCreator a2 = Picasso.a(getContext()).a(uri);
|
||||
a2.a(a);
|
||||
a2.b();
|
||||
a2.a();
|
||||
a2.a(this.a);
|
||||
}
|
||||
|
||||
public AppCardView(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
a(context);
|
||||
}
|
||||
|
||||
void a() {
|
||||
this.a = (ImageView) findViewById(R$id.tw__app_image);
|
||||
this.c = (TextView) findViewById(R$id.tw__app_name);
|
||||
this.b = (TextView) findViewById(R$id.tw__app_install_button);
|
||||
}
|
||||
}
|
42
sources/com/twitter/sdk/android/tweetcomposer/Card.java
Normal file
42
sources/com/twitter/sdk/android/tweetcomposer/Card.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package com.twitter.sdk.android.tweetcomposer;
|
||||
|
||||
import android.content.Context;
|
||||
import java.io.Serializable;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Card implements Serializable {
|
||||
public static final String APP_CARD_TYPE = "promo_image_app";
|
||||
final String appGooglePlayId;
|
||||
final String appIPadId;
|
||||
final String appIPhoneId;
|
||||
final String appName;
|
||||
final String cardType;
|
||||
final String imageUri;
|
||||
|
||||
Card(String str, String str2, String str3, String str4, String str5, String str6) {
|
||||
this.cardType = str;
|
||||
this.imageUri = str2;
|
||||
this.appName = str3;
|
||||
this.appIPadId = str5;
|
||||
this.appIPhoneId = str4;
|
||||
this.appGooglePlayId = str6;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public static String getApplicationName(Context context) {
|
||||
return context.getApplicationInfo().loadLabel(context.getPackageManager()).toString();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public static String getPackageName(Context context) {
|
||||
return context.getPackageName();
|
||||
}
|
||||
|
||||
static boolean isAppCard(Card card) {
|
||||
return (card == null || card.getCardType() == null || !card.getCardType().equals(APP_CARD_TYPE)) ? false : true;
|
||||
}
|
||||
|
||||
public String getCardType() {
|
||||
return this.cardType;
|
||||
}
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package com.twitter.sdk.android.tweetcomposer;
|
||||
|
||||
import com.twitter.sdk.android.tweetcomposer.internal.CardData;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class CardDataFactory {
|
||||
static CardData a(Card card, Long l, String str) {
|
||||
CardData.Builder builder = new CardData.Builder();
|
||||
builder.d(Card.APP_CARD_TYPE);
|
||||
builder.h(a(l));
|
||||
builder.c(card.appIPhoneId);
|
||||
builder.b(card.appIPadId);
|
||||
builder.a(card.appGooglePlayId);
|
||||
builder.e("{}");
|
||||
builder.f("open");
|
||||
builder.g(str);
|
||||
return builder.a();
|
||||
}
|
||||
|
||||
static String a(Long l) {
|
||||
return "media://" + Long.toString(l.longValue());
|
||||
}
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
package com.twitter.sdk.android.tweetcomposer;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class CardViewFactory {
|
||||
CardViewFactory() {
|
||||
}
|
||||
|
||||
View a(Context context, Card card) {
|
||||
if (!card.cardType.equals(Card.APP_CARD_TYPE)) {
|
||||
return null;
|
||||
}
|
||||
AppCardView appCardView = new AppCardView(context);
|
||||
appCardView.setCard(card);
|
||||
return appCardView;
|
||||
}
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
package com.twitter.sdk.android.tweetcomposer;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import com.twitter.sdk.android.core.TwitterAuthToken;
|
||||
import com.twitter.sdk.android.core.TwitterSession;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ComposerActivity extends Activity {
|
||||
|
||||
interface Finisher {
|
||||
void a();
|
||||
}
|
||||
|
||||
class FinisherImpl implements Finisher {
|
||||
FinisherImpl() {
|
||||
}
|
||||
|
||||
@Override // com.twitter.sdk.android.tweetcomposer.ComposerActivity.Finisher
|
||||
public void a() {
|
||||
ComposerActivity.this.finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
protected void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
Intent intent = getIntent();
|
||||
TwitterSession twitterSession = new TwitterSession((TwitterAuthToken) intent.getParcelableExtra("EXTRA_USER_TOKEN"), -1L, "");
|
||||
Card card = (Card) intent.getSerializableExtra("EXTRA_CARD");
|
||||
String stringExtra = intent.getStringExtra("EXTRA_HASHTAGS");
|
||||
setTheme(intent.getIntExtra("EXTRA_THEME", R$style.ComposerLight));
|
||||
setContentView(R$layout.tw__activity_composer);
|
||||
new ComposerController((ComposerView) findViewById(R$id.tw__composer_view), twitterSession, card, stringExtra, new FinisherImpl());
|
||||
}
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
package com.twitter.sdk.android.tweetcomposer;
|
||||
|
||||
import com.twitter.sdk.android.core.TwitterApiClient;
|
||||
import com.twitter.sdk.android.core.TwitterSession;
|
||||
import com.twitter.sdk.android.tweetcomposer.internal.CardService;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class ComposerApiClient extends TwitterApiClient {
|
||||
ComposerApiClient(TwitterSession twitterSession) {
|
||||
super(twitterSession);
|
||||
}
|
||||
|
||||
CardService d() {
|
||||
return (CardService) a(CardService.class);
|
||||
}
|
||||
|
||||
StatusesService e() {
|
||||
return (StatusesService) a(StatusesService.class);
|
||||
}
|
||||
}
|
@@ -0,0 +1,145 @@
|
||||
package com.twitter.sdk.android.tweetcomposer;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import com.twitter.Validator;
|
||||
import com.twitter.sdk.android.core.Callback;
|
||||
import com.twitter.sdk.android.core.Result;
|
||||
import com.twitter.sdk.android.core.TwitterApiClient;
|
||||
import com.twitter.sdk.android.core.TwitterCore;
|
||||
import com.twitter.sdk.android.core.TwitterException;
|
||||
import com.twitter.sdk.android.core.TwitterSession;
|
||||
import com.twitter.sdk.android.core.models.User;
|
||||
import com.twitter.sdk.android.tweetcomposer.ComposerActivity;
|
||||
import com.ubt.jimu.base.dialog.SimpleQuestionDialog;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class ComposerController {
|
||||
final ComposerView a;
|
||||
final TwitterSession b;
|
||||
final Card c;
|
||||
final ComposerActivity.Finisher d;
|
||||
final DependencyProvider e;
|
||||
|
||||
public interface ComposerCallbacks {
|
||||
void a();
|
||||
|
||||
void a(String str);
|
||||
|
||||
void b(String str);
|
||||
}
|
||||
|
||||
static class DependencyProvider {
|
||||
final CardViewFactory a = new CardViewFactory();
|
||||
final Validator b = new Validator();
|
||||
|
||||
DependencyProvider() {
|
||||
}
|
||||
|
||||
TwitterApiClient a(TwitterSession twitterSession) {
|
||||
return TwitterCore.z().a(twitterSession);
|
||||
}
|
||||
|
||||
ComposerScribeClient b() {
|
||||
return new ComposerScribeClientImpl(TweetComposer.s().q());
|
||||
}
|
||||
|
||||
Validator c() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
CardViewFactory a() {
|
||||
return this.a;
|
||||
}
|
||||
}
|
||||
|
||||
ComposerController(ComposerView composerView, TwitterSession twitterSession, Card card, String str, ComposerActivity.Finisher finisher) {
|
||||
this(composerView, twitterSession, card, str, finisher, new DependencyProvider());
|
||||
}
|
||||
|
||||
static boolean a(int i) {
|
||||
return i > 0 && i <= 140;
|
||||
}
|
||||
|
||||
static boolean b(int i) {
|
||||
return i > 140;
|
||||
}
|
||||
|
||||
static int c(int i) {
|
||||
return 140 - i;
|
||||
}
|
||||
|
||||
void a() {
|
||||
this.e.a(this.b).a().verifyCredentials(false, true).enqueue(new Callback<User>() { // from class: com.twitter.sdk.android.tweetcomposer.ComposerController.1
|
||||
@Override // com.twitter.sdk.android.core.Callback
|
||||
public void a(Result<User> result) {
|
||||
ComposerController.this.a.setProfilePhotoView(result.a);
|
||||
}
|
||||
|
||||
@Override // com.twitter.sdk.android.core.Callback
|
||||
public void a(TwitterException twitterException) {
|
||||
ComposerController.this.a.setProfilePhotoView(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ComposerController(ComposerView composerView, TwitterSession twitterSession, Card card, String str, ComposerActivity.Finisher finisher, DependencyProvider dependencyProvider) {
|
||||
this.a = composerView;
|
||||
this.b = twitterSession;
|
||||
this.c = card;
|
||||
this.d = finisher;
|
||||
this.e = dependencyProvider;
|
||||
composerView.setCallbacks(new ComposerCallbacksImpl());
|
||||
composerView.setTweetText(str);
|
||||
a();
|
||||
a(card);
|
||||
dependencyProvider.b().a(card);
|
||||
}
|
||||
|
||||
void a(Card card) {
|
||||
if (card != null) {
|
||||
this.a.setCardView(this.e.a().a(this.a.getContext(), card));
|
||||
}
|
||||
}
|
||||
|
||||
int a(String str) {
|
||||
if (TextUtils.isEmpty(str)) {
|
||||
return 0;
|
||||
}
|
||||
return this.e.c().a(str);
|
||||
}
|
||||
|
||||
class ComposerCallbacksImpl implements ComposerCallbacks {
|
||||
ComposerCallbacksImpl() {
|
||||
}
|
||||
|
||||
@Override // com.twitter.sdk.android.tweetcomposer.ComposerController.ComposerCallbacks
|
||||
public void a(String str) {
|
||||
int a = ComposerController.this.a(str);
|
||||
ComposerController.this.a.setCharCount(ComposerController.c(a));
|
||||
if (ComposerController.b(a)) {
|
||||
ComposerController.this.a.setCharCountTextStyle(R$style.tw__ComposerCharCountOverflow);
|
||||
} else {
|
||||
ComposerController.this.a.setCharCountTextStyle(R$style.tw__ComposerCharCount);
|
||||
}
|
||||
ComposerController.this.a.a(ComposerController.a(a));
|
||||
}
|
||||
|
||||
@Override // com.twitter.sdk.android.tweetcomposer.ComposerController.ComposerCallbacks
|
||||
public void b(String str) {
|
||||
ComposerController.this.e.b().a(ComposerController.this.c, "tweet");
|
||||
Intent intent = new Intent(ComposerController.this.a.getContext(), (Class<?>) TweetUploadService.class);
|
||||
intent.putExtra("EXTRA_USER_TOKEN", ComposerController.this.b.a());
|
||||
intent.putExtra("EXTRA_TWEET_TEXT", str);
|
||||
intent.putExtra("EXTRA_TWEET_CARD", ComposerController.this.c);
|
||||
ComposerController.this.a.getContext().startService(intent);
|
||||
ComposerController.this.d.a();
|
||||
}
|
||||
|
||||
@Override // com.twitter.sdk.android.tweetcomposer.ComposerController.ComposerCallbacks
|
||||
public void a() {
|
||||
ComposerController.this.e.b().a(ComposerController.this.c, SimpleQuestionDialog.KEY_CANCELBUTTON);
|
||||
ComposerController.this.d.a();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package com.twitter.sdk.android.tweetcomposer;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
interface ComposerScribeClient {
|
||||
void a(Card card);
|
||||
|
||||
void a(Card card, String str);
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
package com.twitter.sdk.android.tweetcomposer;
|
||||
|
||||
import com.twitter.sdk.android.core.internal.scribe.EventNamespace;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class ComposerScribeClientImpl implements ComposerScribeClient {
|
||||
private final ScribeClient a;
|
||||
|
||||
ComposerScribeClientImpl(ScribeClient scribeClient) {
|
||||
if (scribeClient == null) {
|
||||
throw new NullPointerException("scribeClient must not be null");
|
||||
}
|
||||
this.a = scribeClient;
|
||||
}
|
||||
|
||||
@Override // com.twitter.sdk.android.tweetcomposer.ComposerScribeClient
|
||||
public void a(Card card) {
|
||||
EventNamespace.Builder builder = ScribeConstants.a;
|
||||
builder.c("");
|
||||
builder.d("");
|
||||
builder.a("impression");
|
||||
EventNamespace a = builder.a();
|
||||
ArrayList arrayList = new ArrayList();
|
||||
arrayList.add(ScribeConstants.a(card));
|
||||
this.a.a(a, arrayList);
|
||||
}
|
||||
|
||||
@Override // com.twitter.sdk.android.tweetcomposer.ComposerScribeClient
|
||||
public void a(Card card, String str) {
|
||||
EventNamespace.Builder builder = ScribeConstants.a;
|
||||
builder.c("");
|
||||
builder.d(str);
|
||||
builder.a("click");
|
||||
EventNamespace a = builder.a();
|
||||
ArrayList arrayList = new ArrayList();
|
||||
arrayList.add(ScribeConstants.a(card));
|
||||
this.a.a(a, arrayList);
|
||||
}
|
||||
}
|
159
sources/com/twitter/sdk/android/tweetcomposer/ComposerView.java
Normal file
159
sources/com/twitter/sdk/android/tweetcomposer/ComposerView.java
Normal file
@@ -0,0 +1,159 @@
|
||||
package com.twitter.sdk.android.tweetcomposer;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.squareup.picasso.RequestCreator;
|
||||
import com.twitter.sdk.android.core.internal.UserUtils;
|
||||
import com.twitter.sdk.android.core.models.User;
|
||||
import com.twitter.sdk.android.tweetcomposer.ComposerController;
|
||||
import com.twitter.sdk.android.tweetcomposer.internal.util.ObservableScrollView;
|
||||
import java.util.Locale;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ComposerView extends LinearLayout {
|
||||
ImageView a;
|
||||
ImageView b;
|
||||
EditText c;
|
||||
TextView d;
|
||||
Button e;
|
||||
ObservableScrollView f;
|
||||
View g;
|
||||
ColorDrawable h;
|
||||
ViewGroup i;
|
||||
ComposerController.ComposerCallbacks j;
|
||||
private Picasso k;
|
||||
|
||||
public ComposerView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
private void a(Context context) {
|
||||
this.k = Picasso.a(getContext());
|
||||
this.h = new ColorDrawable(context.getResources().getColor(R$color.tw__composer_light_gray));
|
||||
LinearLayout.inflate(context, R$layout.tw__composer_view, this);
|
||||
}
|
||||
|
||||
String getTweetText() {
|
||||
return this.c.getText().toString();
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
a();
|
||||
this.b.setOnClickListener(new View.OnClickListener() { // from class: com.twitter.sdk.android.tweetcomposer.ComposerView.1
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
ComposerView.this.j.a();
|
||||
}
|
||||
});
|
||||
this.e.setOnClickListener(new View.OnClickListener() { // from class: com.twitter.sdk.android.tweetcomposer.ComposerView.2
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
ComposerView composerView = ComposerView.this;
|
||||
composerView.j.b(composerView.getTweetText());
|
||||
}
|
||||
});
|
||||
this.c.setOnEditorActionListener(new TextView.OnEditorActionListener() { // from class: com.twitter.sdk.android.tweetcomposer.ComposerView.3
|
||||
@Override // android.widget.TextView.OnEditorActionListener
|
||||
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
|
||||
ComposerView composerView = ComposerView.this;
|
||||
composerView.j.b(composerView.getTweetText());
|
||||
return true;
|
||||
}
|
||||
});
|
||||
this.c.addTextChangedListener(new TextWatcher() { // from class: com.twitter.sdk.android.tweetcomposer.ComposerView.4
|
||||
@Override // android.text.TextWatcher
|
||||
public void afterTextChanged(Editable editable) {
|
||||
ComposerView composerView = ComposerView.this;
|
||||
composerView.j.a(composerView.getTweetText());
|
||||
}
|
||||
|
||||
@Override // android.text.TextWatcher
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
|
||||
}
|
||||
|
||||
@Override // android.text.TextWatcher
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
|
||||
}
|
||||
});
|
||||
this.f.setScrollViewListener(new ObservableScrollView.ScrollViewListener() { // from class: com.twitter.sdk.android.tweetcomposer.ComposerView.5
|
||||
@Override // com.twitter.sdk.android.tweetcomposer.internal.util.ObservableScrollView.ScrollViewListener
|
||||
public void a(int i) {
|
||||
if (i > 0) {
|
||||
ComposerView.this.g.setVisibility(0);
|
||||
} else {
|
||||
ComposerView.this.g.setVisibility(4);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void setCallbacks(ComposerController.ComposerCallbacks composerCallbacks) {
|
||||
this.j = composerCallbacks;
|
||||
}
|
||||
|
||||
void setCardView(View view) {
|
||||
this.i.addView(view);
|
||||
this.i.setVisibility(0);
|
||||
}
|
||||
|
||||
void setCharCount(int i) {
|
||||
this.d.setText(String.format(Locale.getDefault(), "%d", Integer.valueOf(i)));
|
||||
}
|
||||
|
||||
void setCharCountTextStyle(int i) {
|
||||
this.d.setTextAppearance(getContext(), i);
|
||||
}
|
||||
|
||||
void setProfilePhotoView(User user) {
|
||||
String a = UserUtils.a(user, UserUtils.AvatarSize.REASONABLY_SMALL);
|
||||
Picasso picasso = this.k;
|
||||
if (picasso != null) {
|
||||
RequestCreator a2 = picasso.a(a);
|
||||
a2.a(this.h);
|
||||
a2.a(this.a);
|
||||
}
|
||||
}
|
||||
|
||||
void setTweetText(String str) {
|
||||
this.c.setText(str);
|
||||
}
|
||||
|
||||
public ComposerView(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
a(context);
|
||||
}
|
||||
|
||||
public ComposerView(Context context, AttributeSet attributeSet, int i) {
|
||||
super(context, attributeSet, i);
|
||||
a(context);
|
||||
}
|
||||
|
||||
void a() {
|
||||
this.a = (ImageView) findViewById(R$id.tw__author_avatar);
|
||||
this.b = (ImageView) findViewById(R$id.tw__composer_close);
|
||||
this.c = (EditText) findViewById(R$id.tw__edit_tweet);
|
||||
this.d = (TextView) findViewById(R$id.tw__char_count);
|
||||
this.e = (Button) findViewById(R$id.tw__post_tweet);
|
||||
this.f = (ObservableScrollView) findViewById(R$id.tw__composer_scroll_view);
|
||||
this.g = findViewById(R$id.tw__composer_profile_divider);
|
||||
this.i = (ViewGroup) findViewById(R$id.tw__card_view);
|
||||
}
|
||||
|
||||
void a(boolean z) {
|
||||
this.e.setEnabled(z);
|
||||
}
|
||||
}
|
89
sources/com/twitter/sdk/android/tweetcomposer/FileUtils.java
Normal file
89
sources/com/twitter/sdk/android/tweetcomposer/FileUtils.java
Normal file
@@ -0,0 +1,89 @@
|
||||
package com.twitter.sdk.android.tweetcomposer;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.provider.DocumentsContract;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.TextUtils;
|
||||
import android.webkit.MimeTypeMap;
|
||||
import java.io.File;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class FileUtils {
|
||||
@TargetApi(19)
|
||||
static String a(Context context, Uri uri) {
|
||||
if ((Build.VERSION.SDK_INT >= 19) && c(uri)) {
|
||||
String[] split = DocumentsContract.getDocumentId(uri).split(":");
|
||||
if ("image".equals(split[0])) {
|
||||
return a(context, MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "_id=?", new String[]{split[1]});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (a(uri)) {
|
||||
return a(context, uri, null, null);
|
||||
}
|
||||
if (b(uri)) {
|
||||
return uri.getPath();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean b(Uri uri) {
|
||||
return "file".equalsIgnoreCase(uri.getScheme());
|
||||
}
|
||||
|
||||
public static boolean c(Uri uri) {
|
||||
return "com.android.providers.media.documents".equalsIgnoreCase(uri.getAuthority());
|
||||
}
|
||||
|
||||
public static boolean a(Uri uri) {
|
||||
return "content".equalsIgnoreCase(uri.getScheme());
|
||||
}
|
||||
|
||||
static String a(Context context, Uri uri, String str, String[] strArr) {
|
||||
Cursor cursor;
|
||||
try {
|
||||
cursor = context.getContentResolver().query(uri, new String[]{"_data"}, str, strArr, null);
|
||||
if (cursor != null) {
|
||||
try {
|
||||
if (cursor.moveToFirst()) {
|
||||
String string = cursor.getString(cursor.getColumnIndexOrThrow("_data"));
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
return string;
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
return null;
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
cursor = null;
|
||||
}
|
||||
}
|
||||
|
||||
static String a(File file) {
|
||||
String a = a(file.getName());
|
||||
return !TextUtils.isEmpty(a) ? MimeTypeMap.getSingleton().getMimeTypeFromExtension(a) : "application/octet-stream";
|
||||
}
|
||||
|
||||
static String a(String str) {
|
||||
if (str == null) {
|
||||
return null;
|
||||
}
|
||||
int lastIndexOf = str.lastIndexOf(".");
|
||||
return lastIndexOf < 0 ? "" : str.substring(lastIndexOf + 1);
|
||||
}
|
||||
}
|
18
sources/com/twitter/sdk/android/tweetcomposer/R$color.java
Normal file
18
sources/com/twitter/sdk/android/tweetcomposer/R$color.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.twitter.sdk.android.tweetcomposer;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class R$color {
|
||||
public static final int tw__blue_default = 2131099986;
|
||||
public static final int tw__blue_pressed = 2131099987;
|
||||
public static final int tw__blue_pressed_light = 2131099988;
|
||||
public static final int tw__composer_black = 2131099989;
|
||||
public static final int tw__composer_blue = 2131099990;
|
||||
public static final int tw__composer_blue_text = 2131099991;
|
||||
public static final int tw__composer_deep_gray = 2131099992;
|
||||
public static final int tw__composer_light_gray = 2131099993;
|
||||
public static final int tw__composer_red = 2131099994;
|
||||
public static final int tw__composer_white = 2131099995;
|
||||
public static final int tw__light_gray = 2131099998;
|
||||
public static final int tw__solid_white = 2131100001;
|
||||
public static final int tw__transparent = 2131100002;
|
||||
}
|
37
sources/com/twitter/sdk/android/tweetcomposer/R$dimen.java
Normal file
37
sources/com/twitter/sdk/android/tweetcomposer/R$dimen.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package com.twitter.sdk.android.tweetcomposer;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class R$dimen {
|
||||
public static final int tw__btn_bar_margin_left = 2131172304;
|
||||
public static final int tw__btn_bar_margin_right = 2131172305;
|
||||
public static final int tw__card_font_size_medium = 2131172306;
|
||||
public static final int tw__card_font_size_small = 2131172307;
|
||||
public static final int tw__card_maximum_width = 2131172308;
|
||||
public static final int tw__card_radius_medium = 2131172309;
|
||||
public static final int tw__card_radius_small = 2131172310;
|
||||
public static final int tw__card_spacing_large = 2131172311;
|
||||
public static final int tw__card_spacing_medium = 2131172312;
|
||||
public static final int tw__card_spacing_small = 2131172313;
|
||||
public static final int tw__composer_avatar_size = 2131172342;
|
||||
public static final int tw__composer_char_count_height = 2131172343;
|
||||
public static final int tw__composer_close_size = 2131172344;
|
||||
public static final int tw__composer_divider_height = 2131172345;
|
||||
public static final int tw__composer_font_size_small = 2131172346;
|
||||
public static final int tw__composer_logo_height = 2131172347;
|
||||
public static final int tw__composer_logo_width = 2131172348;
|
||||
public static final int tw__composer_spacing_large = 2131172349;
|
||||
public static final int tw__composer_spacing_medium = 2131172350;
|
||||
public static final int tw__composer_spacing_small = 2131172351;
|
||||
public static final int tw__composer_tweet_btn_height = 2131172352;
|
||||
public static final int tw__composer_tweet_btn_radius = 2131172353;
|
||||
public static final int tw__login_btn_drawable_padding = 2131172359;
|
||||
public static final int tw__login_btn_height = 2131172360;
|
||||
public static final int tw__login_btn_left_padding = 2131172361;
|
||||
public static final int tw__login_btn_radius = 2131172362;
|
||||
public static final int tw__login_btn_right_padding = 2131172363;
|
||||
public static final int tw__login_btn_text_size = 2131172364;
|
||||
public static final int tw__padding_permission_horizontal_container = 2131172367;
|
||||
public static final int tw__padding_permission_vertical_container = 2131172368;
|
||||
public static final int tw__permission_description_text_size = 2131172369;
|
||||
public static final int tw__permission_title_text_size = 2131172370;
|
||||
}
|
31
sources/com/twitter/sdk/android/tweetcomposer/R$id.java
Normal file
31
sources/com/twitter/sdk/android/tweetcomposer/R$id.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package com.twitter.sdk.android.tweetcomposer;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class R$id {
|
||||
public static final int height = 2131296692;
|
||||
public static final int imageView = 2131296818;
|
||||
public static final int tw__allow_btn = 2131297842;
|
||||
public static final int tw__app_image = 2131297843;
|
||||
public static final int tw__app_info_layout = 2131297844;
|
||||
public static final int tw__app_install_button = 2131297845;
|
||||
public static final int tw__app_name = 2131297846;
|
||||
public static final int tw__app_store_name = 2131297847;
|
||||
public static final int tw__author_avatar = 2131297850;
|
||||
public static final int tw__card_view = 2131297851;
|
||||
public static final int tw__char_count = 2131297852;
|
||||
public static final int tw__composer_close = 2131297853;
|
||||
public static final int tw__composer_header = 2131297854;
|
||||
public static final int tw__composer_profile_divider = 2131297855;
|
||||
public static final int tw__composer_scroll_view = 2131297856;
|
||||
public static final int tw__composer_toolbar = 2131297857;
|
||||
public static final int tw__composer_toolbar_divider = 2131297858;
|
||||
public static final int tw__composer_view = 2131297859;
|
||||
public static final int tw__edit_tweet = 2131297862;
|
||||
public static final int tw__not_now_btn = 2131297865;
|
||||
public static final int tw__post_tweet = 2131297866;
|
||||
public static final int tw__share_email_desc = 2131297868;
|
||||
public static final int tw__spinner = 2131297869;
|
||||
public static final int tw__twitter_logo = 2131297881;
|
||||
public static final int tw__web_view = 2131297884;
|
||||
public static final int width = 2131297983;
|
||||
}
|
10
sources/com/twitter/sdk/android/tweetcomposer/R$layout.java
Normal file
10
sources/com/twitter/sdk/android/tweetcomposer/R$layout.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.twitter.sdk.android.tweetcomposer;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class R$layout {
|
||||
public static final int tw__activity_composer = 2131493363;
|
||||
public static final int tw__activity_oauth = 2131493364;
|
||||
public static final int tw__activity_share_email = 2131493365;
|
||||
public static final int tw__app_card = 2131493366;
|
||||
public static final int tw__composer_view = 2131493367;
|
||||
}
|
25
sources/com/twitter/sdk/android/tweetcomposer/R$style.java
Normal file
25
sources/com/twitter/sdk/android/tweetcomposer/R$style.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.twitter.sdk.android.tweetcomposer;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class R$style {
|
||||
public static final int ComposerDark = 2131886286;
|
||||
public static final int ComposerLight = 2131886287;
|
||||
public static final int tw__Button = 2131886756;
|
||||
public static final int tw__ButtonBar = 2131886758;
|
||||
public static final int tw__Button_Light = 2131886757;
|
||||
public static final int tw__CardAppInfoLayout = 2131886759;
|
||||
public static final int tw__CardAppName = 2131886760;
|
||||
public static final int tw__CardAppStoreName = 2131886761;
|
||||
public static final int tw__CardInstallButton = 2131886762;
|
||||
public static final int tw__ComposerAvatar = 2131886764;
|
||||
public static final int tw__ComposerCharCount = 2131886765;
|
||||
public static final int tw__ComposerCharCountOverflow = 2131886766;
|
||||
public static final int tw__ComposerClose = 2131886767;
|
||||
public static final int tw__ComposerDivider = 2131886768;
|
||||
public static final int tw__ComposerToolbar = 2131886769;
|
||||
public static final int tw__ComposerTweetButton = 2131886770;
|
||||
public static final int tw__EditTweet = 2131886771;
|
||||
public static final int tw__Permission_Container = 2131886772;
|
||||
public static final int tw__Permission_Description = 2131886773;
|
||||
public static final int tw__Permission_Title = 2131886774;
|
||||
}
|
@@ -0,0 +1,67 @@
|
||||
package com.twitter.sdk.android.tweetcomposer;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapShader;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Shader;
|
||||
import com.squareup.picasso.Transformation;
|
||||
import java.util.Arrays;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class RoundedCornerTransformation implements Transformation {
|
||||
final float[] a;
|
||||
|
||||
RoundedCornerTransformation(float[] fArr) {
|
||||
this.a = fArr;
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.Transformation
|
||||
public Bitmap a(Bitmap bitmap) {
|
||||
RectF rectF = new RectF(0.0f, 0.0f, bitmap.getWidth(), bitmap.getHeight());
|
||||
Bitmap createBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig());
|
||||
Shader.TileMode tileMode = Shader.TileMode.CLAMP;
|
||||
BitmapShader bitmapShader = new BitmapShader(bitmap, tileMode, tileMode);
|
||||
Paint paint = new Paint();
|
||||
paint.setAntiAlias(true);
|
||||
paint.setShader(bitmapShader);
|
||||
Path path = new Path();
|
||||
path.addRoundRect(rectF, this.a, Path.Direction.CCW);
|
||||
new Canvas(createBitmap).drawPath(path, paint);
|
||||
bitmap.recycle();
|
||||
return createBitmap;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
int a;
|
||||
int b;
|
||||
int c;
|
||||
int d;
|
||||
|
||||
public Builder a(int i, int i2, int i3, int i4) {
|
||||
this.a = i;
|
||||
this.b = i2;
|
||||
this.c = i3;
|
||||
this.d = i4;
|
||||
return this;
|
||||
}
|
||||
|
||||
RoundedCornerTransformation a() {
|
||||
int i;
|
||||
int i2;
|
||||
int i3;
|
||||
int i4 = this.a;
|
||||
if (i4 >= 0 && (i = this.b) >= 0 && (i2 = this.c) >= 0 && (i3 = this.d) >= 0) {
|
||||
return new RoundedCornerTransformation(new float[]{i4, i4, i, i, i2, i2, i3, i3});
|
||||
}
|
||||
throw new IllegalStateException("Radius must not be negative");
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.Transformation
|
||||
public String a() {
|
||||
return "RoundedCornerTransformation(" + Arrays.toString(this.a) + ")";
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
package com.twitter.sdk.android.tweetcomposer;
|
||||
|
||||
import com.twitter.sdk.android.core.internal.scribe.EventNamespace;
|
||||
import com.twitter.sdk.android.core.internal.scribe.ScribeItem;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
interface ScribeClient {
|
||||
void a(EventNamespace eventNamespace, List<ScribeItem> list);
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package com.twitter.sdk.android.tweetcomposer;
|
||||
|
||||
import com.twitter.sdk.android.core.internal.scribe.DefaultScribeClient;
|
||||
import com.twitter.sdk.android.core.internal.scribe.EventNamespace;
|
||||
import com.twitter.sdk.android.core.internal.scribe.ScribeItem;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class ScribeClientImpl implements ScribeClient {
|
||||
private final DefaultScribeClient a;
|
||||
|
||||
public ScribeClientImpl(DefaultScribeClient defaultScribeClient) {
|
||||
this.a = defaultScribeClient;
|
||||
}
|
||||
|
||||
@Override // com.twitter.sdk.android.tweetcomposer.ScribeClient
|
||||
public void a(EventNamespace eventNamespace, List<ScribeItem> list) {
|
||||
DefaultScribeClient defaultScribeClient = this.a;
|
||||
if (defaultScribeClient != null) {
|
||||
defaultScribeClient.a(eventNamespace, list);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
package com.twitter.sdk.android.tweetcomposer;
|
||||
|
||||
import com.twitter.sdk.android.core.internal.scribe.EventNamespace;
|
||||
import com.twitter.sdk.android.core.internal.scribe.ScribeItem;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class ScribeConstants {
|
||||
static final EventNamespace.Builder a;
|
||||
|
||||
static {
|
||||
EventNamespace.Builder builder = new EventNamespace.Builder();
|
||||
builder.b("tfw");
|
||||
builder.e("android");
|
||||
builder.f("composer");
|
||||
a = builder;
|
||||
}
|
||||
|
||||
static ScribeItem a(Card card) {
|
||||
ScribeItem.Builder builder = new ScribeItem.Builder();
|
||||
builder.a(0);
|
||||
builder.a(new ScribeItem.CardEvent(8));
|
||||
return builder.a();
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
package com.twitter.sdk.android.tweetcomposer;
|
||||
|
||||
import com.twitter.sdk.android.core.models.Tweet;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface StatusesService {
|
||||
@FormUrlEncoded
|
||||
@POST("/1.1/statuses/update.json")
|
||||
Call<Tweet> update(@Field("status") String str, @Field("card_uri") String str2);
|
||||
}
|
159
sources/com/twitter/sdk/android/tweetcomposer/TweetComposer.java
Normal file
159
sources/com/twitter/sdk/android/tweetcomposer/TweetComposer.java
Normal file
@@ -0,0 +1,159 @@
|
||||
package com.twitter.sdk.android.tweetcomposer;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import com.twitter.sdk.android.core.GuestSessionProvider;
|
||||
import com.twitter.sdk.android.core.Session;
|
||||
import com.twitter.sdk.android.core.SessionManager;
|
||||
import com.twitter.sdk.android.core.TwitterCore;
|
||||
import com.twitter.sdk.android.core.TwitterSession;
|
||||
import com.twitter.sdk.android.core.internal.scribe.DefaultScribeClient;
|
||||
import io.fabric.sdk.android.Fabric;
|
||||
import io.fabric.sdk.android.Kit;
|
||||
import io.fabric.sdk.android.services.concurrency.DependsOn;
|
||||
import io.fabric.sdk.android.services.network.UrlUtils;
|
||||
import java.net.URL;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@DependsOn({TwitterCore.class})
|
||||
/* loaded from: classes.dex */
|
||||
public class TweetComposer extends Kit<Void> {
|
||||
String h;
|
||||
SessionManager<TwitterSession> i;
|
||||
GuestSessionProvider j;
|
||||
private final ConcurrentHashMap<Session, ComposerApiClient> g = new ConcurrentHashMap<>();
|
||||
private ScribeClient k = new ScribeClientImpl(null);
|
||||
|
||||
private static void r() {
|
||||
if (Fabric.a(TweetComposer.class) == null) {
|
||||
throw new IllegalStateException("Must start Twitter Kit with Fabric.with() first");
|
||||
}
|
||||
}
|
||||
|
||||
public static TweetComposer s() {
|
||||
r();
|
||||
return (TweetComposer) Fabric.a(TweetComposer.class);
|
||||
}
|
||||
|
||||
public ComposerApiClient a(TwitterSession twitterSession) {
|
||||
r();
|
||||
if (!this.g.containsKey(twitterSession)) {
|
||||
this.g.putIfAbsent(twitterSession, new ComposerApiClient(twitterSession));
|
||||
}
|
||||
return this.g.get(twitterSession);
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.Kit
|
||||
public String g() {
|
||||
return "com.twitter.sdk.android:tweet-composer";
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.Kit
|
||||
public String i() {
|
||||
return "2.3.1.165";
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.Kit
|
||||
protected boolean o() {
|
||||
this.i = TwitterCore.z().u();
|
||||
this.j = TwitterCore.z().s();
|
||||
return super.o();
|
||||
}
|
||||
|
||||
String p() {
|
||||
return this.h;
|
||||
}
|
||||
|
||||
protected ScribeClient q() {
|
||||
return this.k;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: protected */
|
||||
@Override // io.fabric.sdk.android.Kit
|
||||
public Void c() {
|
||||
this.h = f().a();
|
||||
this.k = new ScribeClientImpl(new DefaultScribeClient(this, "TweetComposer", this.i, this.j, f()));
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private final Context a;
|
||||
private String b;
|
||||
private URL c;
|
||||
private Uri d;
|
||||
|
||||
public Builder(Context context) {
|
||||
if (context == null) {
|
||||
throw new IllegalArgumentException("Context must not be null.");
|
||||
}
|
||||
this.a = context;
|
||||
}
|
||||
|
||||
public Builder a(String str) {
|
||||
if (str == null) {
|
||||
throw new IllegalArgumentException("text must not be null.");
|
||||
}
|
||||
if (this.b != null) {
|
||||
throw new IllegalStateException("text already set.");
|
||||
}
|
||||
this.b = str;
|
||||
return this;
|
||||
}
|
||||
|
||||
Intent b() {
|
||||
Intent intent = new Intent("android.intent.action.SEND");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (!TextUtils.isEmpty(this.b)) {
|
||||
sb.append(this.b);
|
||||
}
|
||||
if (this.c != null) {
|
||||
if (sb.length() > 0) {
|
||||
sb.append(' ');
|
||||
}
|
||||
sb.append(this.c.toString());
|
||||
}
|
||||
intent.putExtra("android.intent.extra.TEXT", sb.toString());
|
||||
intent.setType("text/plain");
|
||||
Uri uri = this.d;
|
||||
if (uri != null) {
|
||||
intent.putExtra("android.intent.extra.STREAM", uri);
|
||||
intent.setType("image/jpeg");
|
||||
}
|
||||
for (ResolveInfo resolveInfo : this.a.getPackageManager().queryIntentActivities(intent, 65536)) {
|
||||
if (resolveInfo.activityInfo.packageName.startsWith("com.twitter.android")) {
|
||||
intent.setClassName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name);
|
||||
return intent;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Intent c() {
|
||||
URL url = this.c;
|
||||
return new Intent("android.intent.action.VIEW", Uri.parse(String.format("https://twitter.com/intent/tweet?text=%s&url=%s", UrlUtils.c(this.b), UrlUtils.c(url == null ? "" : url.toString()))));
|
||||
}
|
||||
|
||||
public void d() {
|
||||
this.a.startActivity(a());
|
||||
}
|
||||
|
||||
public Builder a(Uri uri) {
|
||||
if (uri != null) {
|
||||
if (this.d == null) {
|
||||
this.d = uri;
|
||||
return this;
|
||||
}
|
||||
throw new IllegalStateException("imageUri already set.");
|
||||
}
|
||||
throw new IllegalArgumentException("imageUri must not be null.");
|
||||
}
|
||||
|
||||
public Intent a() {
|
||||
Intent b = b();
|
||||
return b == null ? c() : b;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,152 @@
|
||||
package com.twitter.sdk.android.tweetcomposer;
|
||||
|
||||
import android.app.IntentService;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import com.twitter.sdk.android.core.Callback;
|
||||
import com.twitter.sdk.android.core.Result;
|
||||
import com.twitter.sdk.android.core.TwitterAuthToken;
|
||||
import com.twitter.sdk.android.core.TwitterException;
|
||||
import com.twitter.sdk.android.core.TwitterSession;
|
||||
import com.twitter.sdk.android.core.models.Media;
|
||||
import com.twitter.sdk.android.core.models.Tweet;
|
||||
import com.twitter.sdk.android.tweetcomposer.internal.CardCreate;
|
||||
import io.fabric.sdk.android.Fabric;
|
||||
import java.io.File;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class TweetUploadService extends IntentService {
|
||||
DependencyProvider a;
|
||||
TwitterSession b;
|
||||
String c;
|
||||
Card d;
|
||||
Intent e;
|
||||
|
||||
static class DependencyProvider {
|
||||
DependencyProvider() {
|
||||
}
|
||||
|
||||
ComposerApiClient a(TwitterSession twitterSession) {
|
||||
return TweetComposer.s().a(twitterSession);
|
||||
}
|
||||
|
||||
String a() {
|
||||
return TweetComposer.s().p();
|
||||
}
|
||||
}
|
||||
|
||||
public TweetUploadService() {
|
||||
this(new DependencyProvider());
|
||||
}
|
||||
|
||||
void a(TwitterSession twitterSession, String str) {
|
||||
this.a.a(twitterSession).e().update(str, null).enqueue(new Callback<Tweet>() { // from class: com.twitter.sdk.android.tweetcomposer.TweetUploadService.1
|
||||
@Override // com.twitter.sdk.android.core.Callback
|
||||
public void a(Result<Tweet> result) {
|
||||
TweetUploadService.this.a(result.a.a());
|
||||
TweetUploadService.this.stopSelf();
|
||||
}
|
||||
|
||||
@Override // com.twitter.sdk.android.core.Callback
|
||||
public void a(TwitterException twitterException) {
|
||||
TweetUploadService.this.a(twitterException);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override // android.app.IntentService
|
||||
protected void onHandleIntent(Intent intent) {
|
||||
TwitterAuthToken twitterAuthToken = (TwitterAuthToken) intent.getParcelableExtra("EXTRA_USER_TOKEN");
|
||||
this.e = intent;
|
||||
this.b = new TwitterSession(twitterAuthToken, -1L, "");
|
||||
this.c = intent.getStringExtra("EXTRA_TWEET_TEXT");
|
||||
this.d = (Card) intent.getSerializableExtra("EXTRA_TWEET_CARD");
|
||||
if (Card.isAppCard(this.d)) {
|
||||
a(this.b, this.c, this.d);
|
||||
} else {
|
||||
a(this.b, this.c);
|
||||
}
|
||||
}
|
||||
|
||||
/* renamed from: com.twitter.sdk.android.tweetcomposer.TweetUploadService$2, reason: invalid class name */
|
||||
class AnonymousClass2 extends Callback<Media> {
|
||||
final /* synthetic */ Card a;
|
||||
final /* synthetic */ ComposerApiClient b;
|
||||
final /* synthetic */ String c;
|
||||
|
||||
AnonymousClass2(Card card, ComposerApiClient composerApiClient, String str) {
|
||||
this.a = card;
|
||||
this.b = composerApiClient;
|
||||
this.c = str;
|
||||
}
|
||||
|
||||
@Override // com.twitter.sdk.android.core.Callback
|
||||
public void a(Result<Media> result) {
|
||||
this.b.d().create(CardDataFactory.a(this.a, Long.valueOf(result.a.a), TweetUploadService.this.a.a())).enqueue(new Callback<CardCreate>() { // from class: com.twitter.sdk.android.tweetcomposer.TweetUploadService.2.1
|
||||
@Override // com.twitter.sdk.android.core.Callback
|
||||
public void a(Result<CardCreate> result2) {
|
||||
AnonymousClass2.this.b.e().update(AnonymousClass2.this.c, result2.a.a).enqueue(new Callback<Tweet>() { // from class: com.twitter.sdk.android.tweetcomposer.TweetUploadService.2.1.1
|
||||
@Override // com.twitter.sdk.android.core.Callback
|
||||
public void a(Result<Tweet> result3) {
|
||||
TweetUploadService.this.a(result3.a.a());
|
||||
TweetUploadService.this.stopSelf();
|
||||
}
|
||||
|
||||
@Override // com.twitter.sdk.android.core.Callback
|
||||
public void a(TwitterException twitterException) {
|
||||
TweetUploadService.this.a(twitterException);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override // com.twitter.sdk.android.core.Callback
|
||||
public void a(TwitterException twitterException) {
|
||||
TweetUploadService.this.a(twitterException);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override // com.twitter.sdk.android.core.Callback
|
||||
public void a(TwitterException twitterException) {
|
||||
TweetUploadService.this.a(twitterException);
|
||||
}
|
||||
}
|
||||
|
||||
TweetUploadService(DependencyProvider dependencyProvider) {
|
||||
super("TweetUploadService");
|
||||
this.a = dependencyProvider;
|
||||
}
|
||||
|
||||
void a(TwitterSession twitterSession, String str, Card card) {
|
||||
ComposerApiClient a = this.a.a(twitterSession);
|
||||
String a2 = FileUtils.a(this, Uri.parse(card.imageUri));
|
||||
if (a2 == null) {
|
||||
a(new TwitterException("Uri file path resolved to null"));
|
||||
return;
|
||||
}
|
||||
File file = new File(a2);
|
||||
a.c().upload(RequestBody.create(MediaType.parse(FileUtils.a(file)), file), null, null).enqueue(new AnonymousClass2(card, a, str));
|
||||
}
|
||||
|
||||
void a(TwitterException twitterException) {
|
||||
a(this.e);
|
||||
Fabric.g().b("TweetUploadService", "Post Tweet failed", twitterException);
|
||||
stopSelf();
|
||||
}
|
||||
|
||||
void a(long j) {
|
||||
Intent intent = new Intent("com.twitter.sdk.android.tweetcomposer.UPLOAD_SUCCESS");
|
||||
intent.putExtra("EXTRA_TWEET_ID", j);
|
||||
intent.setPackage(getApplicationContext().getPackageName());
|
||||
sendBroadcast(intent);
|
||||
}
|
||||
|
||||
void a(Intent intent) {
|
||||
Intent intent2 = new Intent("com.twitter.sdk.android.tweetcomposer.UPLOAD_FAILURE");
|
||||
intent2.putExtra("EXTRA_RETRY_INTENT", intent);
|
||||
intent2.setPackage(getApplicationContext().getPackageName());
|
||||
sendBroadcast(intent2);
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
package com.twitter.sdk.android.tweetcomposer.internal;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class CardCreate {
|
||||
|
||||
@SerializedName("card_uri")
|
||||
public final String a;
|
||||
}
|
@@ -0,0 +1,92 @@
|
||||
package com.twitter.sdk.android.tweetcomposer.internal;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class CardData {
|
||||
private static Serializer a;
|
||||
|
||||
public static class Builder {
|
||||
private String a;
|
||||
private String b;
|
||||
private String c;
|
||||
private String d;
|
||||
private String e;
|
||||
private String f;
|
||||
private String g;
|
||||
private String h;
|
||||
private String i;
|
||||
private String j;
|
||||
private String k;
|
||||
private String l;
|
||||
|
||||
public Builder a(String str) {
|
||||
this.k = str;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder b(String str) {
|
||||
this.j = str;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder c(String str) {
|
||||
this.i = str;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder d(String str) {
|
||||
this.a = str;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder e(String str) {
|
||||
this.e = str;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder f(String str) {
|
||||
this.g = str;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder g(String str) {
|
||||
this.h = str;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder h(String str) {
|
||||
this.b = str;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CardData a() {
|
||||
return new CardData(this.a, this.b, this.c, this.d, this.e, this.f, this.g, this.h, this.i, this.j, this.k, this.l);
|
||||
}
|
||||
}
|
||||
|
||||
static class Serializer {
|
||||
private final Gson a = new Gson();
|
||||
|
||||
Serializer() {
|
||||
}
|
||||
|
||||
String a(CardData cardData) {
|
||||
return this.a.toJson(cardData);
|
||||
}
|
||||
}
|
||||
|
||||
Serializer a() {
|
||||
if (a == null) {
|
||||
a = new Serializer();
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return a().a(this);
|
||||
}
|
||||
|
||||
private CardData(String str, String str2, String str3, String str4, String str5, String str6, String str7, String str8, String str9, String str10, String str11, String str12) {
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
package com.twitter.sdk.android.tweetcomposer.internal;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface CardService {
|
||||
@FormUrlEncoded
|
||||
@POST("https://caps.twitter.com/v2/cards/create.json")
|
||||
Call<CardCreate> create(@Field("card_data") CardData cardData);
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
package com.twitter.sdk.android.tweetcomposer.internal.util;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ScrollView;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ObservableScrollView extends ScrollView {
|
||||
ScrollViewListener a;
|
||||
|
||||
public interface ScrollViewListener {
|
||||
void a(int i);
|
||||
}
|
||||
|
||||
public ObservableScrollView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected void onScrollChanged(int i, int i2, int i3, int i4) {
|
||||
super.onScrollChanged(i, i2, i3, i4);
|
||||
ScrollViewListener scrollViewListener = this.a;
|
||||
if (scrollViewListener != null) {
|
||||
scrollViewListener.a(i2);
|
||||
}
|
||||
}
|
||||
|
||||
public void setScrollViewListener(ScrollViewListener scrollViewListener) {
|
||||
this.a = scrollViewListener;
|
||||
}
|
||||
|
||||
public ObservableScrollView(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
}
|
||||
|
||||
public ObservableScrollView(Context context, AttributeSet attributeSet, int i) {
|
||||
super(context, attributeSet, i);
|
||||
}
|
||||
|
||||
@TargetApi(21)
|
||||
public ObservableScrollView(Context context, AttributeSet attributeSet, int i, int i2) {
|
||||
super(context, attributeSet, i, i2);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user