fixed some crashes

This commit is contained in:
Mariotaku Lee 2015-05-13 14:45:52 +08:00
parent 2fe5ca0c85
commit d56cda1b37
23 changed files with 206 additions and 75 deletions

View File

@ -129,7 +129,9 @@ public final class RestMethodInfo {
private static void checkMethod(RestMethod restMethod, Body body, HashMap<Form, Object> forms, HashMap<Part, Object> parts, FileValue file) {
if (restMethod == null)
throw new NotImplementedException("Method must has annotation annotated with @RestMethod");
if (!restMethod.hasBody() && body != null) {
if (restMethod.hasBody() && body == null) {
throw new IllegalArgumentException("@Body required for method " + restMethod.value());
} else if (!restMethod.hasBody() && body != null) {
throw new IllegalArgumentException(restMethod.value() + " does not allow body");
}
if (body == null) return;

View File

@ -37,6 +37,7 @@ public class Endpoint {
}
public static String constructUrl(String endpoint, String path, List<Pair<String, String>> queries) {
if (endpoint == null) throw new NullPointerException("Endpoint is null");
final StringBuilder urlBuilder = new StringBuilder();
if (endpoint.charAt(endpoint.length() - 1) == '/') {
urlBuilder.append(endpoint.substring(0, endpoint.length() - 1));

View File

@ -32,19 +32,19 @@ import org.mariotaku.twidere.api.twitter.auth.OAuthToken;
*/
public interface TwitterOAuth {
@Body(BodyType.FORM)
@POST("/oauth/request_token")
@Body(BodyType.FORM)
OAuthToken getRequestToken(@Form("oauth_callback") String oauthCallback) throws TwitterException;
@Body(BodyType.FORM)
@POST("/oauth/access_token")
@Body(BodyType.FORM)
OAuthToken getAccessToken(@Form("x_auth_username") String xauthUsername,
@Form("x_auth_password") String xauthPassword,
@Form("x_auth_mode") XAuthMode xauthMode)throws TwitterException;
@Body(BodyType.FORM)
@POST("/oauth/access_token")
@Body(BodyType.FORM)
OAuthToken getAccessToken(@Extra({"oauth_token", "oauth_token_secret"}) OAuthToken requestToken, @Form("oauth_verifier") String oauthVerifier)throws TwitterException;
enum XAuthMode {

View File

@ -19,7 +19,9 @@
package org.mariotaku.twidere.api.twitter.api;
import org.mariotaku.simplerestapi.http.BodyType;
import org.mariotaku.simplerestapi.method.POST;
import org.mariotaku.simplerestapi.param.Body;
import org.mariotaku.simplerestapi.param.Path;
import org.mariotaku.twidere.api.twitter.TwitterException;
@ -27,9 +29,11 @@ import org.mariotaku.twidere.api.twitter.TwitterException;
public interface PrivateDirectMessagesResources extends PrivateResources {
@POST("/dm/conversation/{conversation_id}/delete.json")
@Body(BodyType.FORM)
void destroyDirectMessagesConversation(@Path("conversation_id") String conversationId) throws TwitterException;
@POST("/dm/conversation/{account_id}-{user_id}/delete.json")
@Body(BodyType.FORM)
void destroyDirectMessagesConversation(@Path("account_id") long accountId, @Path("user_id") long userId) throws TwitterException;
}

View File

@ -32,10 +32,10 @@ import org.mariotaku.twidere.api.twitter.model.TranslationResult;
@SuppressWarnings("RedundantThrows")
public interface PrivateTweetResources extends PrivateResources {
@GET("/statuses{id}/activity/summary.json")
@GET("/statuses/{id}/activity/summary.json")
StatusActivitySummary getStatusActivitySummary(@Path("id") long statusId) throws TwitterException;
@GET("/statuses{id}/activity/summary.json")
@GET("/statuses/{id}/activity/summary.json")
StatusActivitySummary getStatusActivitySummary(@Path("id") long statusId, boolean includeUserEntities) throws TwitterException;
@GET("/conversation/show.json")

View File

@ -36,6 +36,7 @@ import org.mariotaku.twidere.api.twitter.model.StatusUpdate;
@SuppressWarnings("RedundantThrows")
public interface TweetResources {
@POST("/statuses/destroy/{id}.json")
@Body(BodyType.FORM)
Status destroyStatus(@Path("id") long statusId) throws TwitterException;
@GET("/statuses/retweeters/ids.json")
@ -45,6 +46,7 @@ public interface TweetResources {
ResponseList<Status> getRetweets(@Path("id") long statusId, @Query Paging paging) throws TwitterException;
@POST("/statuses/retweet/{id}.json")
@Body(BodyType.FORM)
Status retweetStatus(@Path("id") long statusId) throws TwitterException;
@GET("/statuses/show.json")

View File

@ -95,12 +95,14 @@ public interface UsersResources {
ResponseList<User> getUserSuggestions(String categorySlug) throws TwitterException;
@POST("/users/lookup.json")
@Body(BodyType.FORM)
ResponseList<User> lookupUsers(@Form("id") long[] ids) throws TwitterException;
@GET("/users/lookup.json")
ResponseList<User> lookupUsers(@Form("id") String[] screenNames) throws TwitterException;
@POST("/account/remove_profile_banner.json")
@Body(BodyType.FORM)
void removeProfileBannerImage() throws TwitterException;
@GET("/users/search.json")

View File

@ -21,18 +21,18 @@ package org.mariotaku.twidere.api.twitter.model;
public interface StatusActivitySummary extends TwitterResponse {
public long getDescendentReplyCount();
long getDescendentReplyCount();
public IDs getFavoriters();
IDs getFavoriters();
public long getFavoritersCount();
long getFavoritersCount();
public IDs getRepliers();
IDs getRepliers();
public long getRepliersCount();
long getRepliersCount();
public IDs getRetweeters();
IDs getRetweeters();
public long getRetweetersCount();
long getRetweetersCount();
}

View File

@ -20,6 +20,7 @@
package org.mariotaku.twidere.api.twitter.model.impl;
import com.bluelinelabs.logansquare.JsonMapper;
import com.bluelinelabs.logansquare.typeconverters.TypeConverter;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
@ -35,6 +36,18 @@ import java.util.List;
*/
public class IDsImpl extends TwitterResponseImpl implements IDs {
public static final TypeConverter<IDs> CONVERTER = new TypeConverter<IDs>() {
@Override
public IDs parse(JsonParser jsonParser) throws IOException {
return MAPPER.parse(jsonParser);
}
@Override
public void serialize(IDs object, String fieldName, boolean writeFieldNameForObject, JsonGenerator jsonGenerator) {
throw new UnsupportedOperationException();
}
};
public static final JsonMapper<IDs> MAPPER = new JsonMapper<IDs>() {
@SuppressWarnings("TryWithIdenticalCatches")
@Override

View File

@ -0,0 +1,84 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.api.twitter.model.impl;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.twidere.api.twitter.model.IDs;
import org.mariotaku.twidere.api.twitter.model.StatusActivitySummary;
/**
* Created by mariotaku on 15/5/13.
*/
@JsonObject
public class StatusActivitySummaryImpl extends TwitterResponseImpl implements StatusActivitySummary {
@JsonField(name = "favoriters")
IDs favoriters;
@JsonField(name = "repliers")
IDs repliers;
@JsonField(name = "retweeters")
IDs retweeters;
@JsonField(name = "favoriters_count")
long favoritersCount;
@JsonField(name = "repliers_count")
long repliersCount;
@JsonField(name = "retweeters_count")
long retweetersCount;
@JsonField(name = "descendent_reply_count")
long descendentReplyCount;
@Override
public IDs getFavoriters() {
return favoriters;
}
@Override
public IDs getRepliers() {
return repliers;
}
@Override
public IDs getRetweeters() {
return retweeters;
}
@Override
public long getFavoritersCount() {
return favoritersCount;
}
@Override
public long getRepliersCount() {
return repliersCount;
}
@Override
public long getRetweetersCount() {
return retweetersCount;
}
@Override
public long getDescendentReplyCount() {
return descendentReplyCount;
}
}

View File

@ -65,6 +65,7 @@ public class TypeConverterMapper<T> implements TypeConverter<T> {
}
}
@SuppressWarnings({"TryWithIdenticalCatches"})
public static <T> void register(Class<T> cls, Class<? extends T> impl, JsonMapper<? extends T> mapper) {
LoganSquare.registerTypeConverter(cls, new TypeConverterMapper<>(impl));

View File

@ -50,6 +50,7 @@ import org.mariotaku.twidere.api.twitter.model.Relationship;
import org.mariotaku.twidere.api.twitter.model.ResponseList;
import org.mariotaku.twidere.api.twitter.model.SavedSearch;
import org.mariotaku.twidere.api.twitter.model.Status;
import org.mariotaku.twidere.api.twitter.model.StatusActivitySummary;
import org.mariotaku.twidere.api.twitter.model.TranslationResult;
import org.mariotaku.twidere.api.twitter.model.Trend;
import org.mariotaku.twidere.api.twitter.model.Trends;
@ -75,6 +76,7 @@ import org.mariotaku.twidere.api.twitter.model.impl.RelationshipImpl;
import org.mariotaku.twidere.api.twitter.model.impl.RelationshipWrapper;
import org.mariotaku.twidere.api.twitter.model.impl.ResponseListImpl;
import org.mariotaku.twidere.api.twitter.model.impl.SavedSearchImpl;
import org.mariotaku.twidere.api.twitter.model.impl.StatusActivitySummaryImpl;
import org.mariotaku.twidere.api.twitter.model.impl.StatusImpl;
import org.mariotaku.twidere.api.twitter.model.impl.TranslationResultImpl;
import org.mariotaku.twidere.api.twitter.model.impl.TrendImpl;
@ -134,12 +136,14 @@ public class TwitterConverter implements Converter {
TypeConverterMapper.register(Trends.class, TrendsImpl.class);
TypeConverterMapper.register(Location.class, LocationImpl.class);
TypeConverterMapper.register(Location.PlaceType.class, LocationImpl.PlaceTypeImpl.class);
TypeConverterMapper.register(StatusActivitySummary.class, StatusActivitySummaryImpl.class);
TypeConverterMapper.register(IDs.class, IDsImpl.class, IDsImpl.MAPPER);
TypeConverterMapper.register(Activity.class, ActivityImpl.class, ActivityImpl.MAPPER);
LoganSquare.registerTypeConverter(Indices.class, Indices.CONVERTER);
LoganSquare.registerTypeConverter(GeoLocation.class, GeoLocation.CONVERTER);
LoganSquare.registerTypeConverter(CardEntity.BindingValue.class, CardEntityImpl.BindingValueWrapper.CONVERTER);
LoganSquare.registerTypeConverter(IDs.class, IDsImpl.CONVERTER);
LoganSquare.registerTypeConverter(MediaEntity.Type.class, EnumConverter.get(MediaEntity.Type.class));
LoganSquare.registerTypeConverter(UserList.Mode.class, EnumConverter.get(UserList.Mode.class));
LoganSquare.registerTypeConverter(Activity.Action.class, EnumConverter.get(Activity.Action.class));

View File

@ -242,13 +242,8 @@ public abstract class BasePreferenceActivity extends AppCompatPreferenceActivity
}
@Override
protected void onApplyThemeResource(@NonNull Resources.Theme theme, int resid, boolean first) {
mCurrentThemeColor = getThemeColor();
mCurrentThemeBackgroundAlpha = getThemeBackgroundAlpha();
mProfileImageStyle = Utils.getProfileImageStyle(this);
mCurrentThemeBackgroundOption = getThemeBackgroundOption();
mCurrentThemeFontFamily = getThemeFontFamily();
super.onApplyThemeResource(theme, resid, first);
public void setTheme(int resid) {
super.setTheme(mCurrentThemeResource = getThemeResourceId());
if (shouldApplyWindowBackground()) {
ThemeUtils.applyWindowBackground(this, getWindow(), mCurrentThemeResource,
mCurrentThemeBackgroundOption, mCurrentThemeBackgroundAlpha);
@ -256,8 +251,13 @@ public abstract class BasePreferenceActivity extends AppCompatPreferenceActivity
}
@Override
public void setTheme(int resid) {
super.setTheme(mCurrentThemeResource = getThemeResourceId());
protected void onApplyThemeResource(@NonNull Resources.Theme theme, int resid, boolean first) {
mCurrentThemeColor = getThemeColor();
mCurrentThemeBackgroundAlpha = getThemeBackgroundAlpha();
mProfileImageStyle = Utils.getProfileImageStyle(this);
mCurrentThemeBackgroundOption = getThemeBackgroundOption();
mCurrentThemeFontFamily = getThemeFontFamily();
super.onApplyThemeResource(theme, resid, first);
}
@Override

View File

@ -109,6 +109,10 @@ public abstract class BaseThemedActivity extends Activity implements IThemedActi
public void setTheme(int resId) {
final int themeResourceId = getThemeResourceId();
super.setTheme(mCurrentThemeResource = themeResourceId != 0 ? themeResourceId : resId);
if (shouldApplyWindowBackground()) {
ThemeUtils.applyWindowBackground(this, getWindow(), mCurrentThemeResource,
mCurrentThemeBackgroundOption, mCurrentThemeBackgroundAlpha);
}
}
@Override
@ -119,10 +123,6 @@ public abstract class BaseThemedActivity extends Activity implements IThemedActi
mCurrentThemeBackgroundOption = getThemeBackgroundOption();
mProfileImageStyle = Utils.getProfileImageStyle(this);
super.onApplyThemeResource(theme, resId, first);
if (shouldApplyWindowBackground()) {
ThemeUtils.applyWindowBackground(this, getWindow(), mCurrentThemeResource,
mCurrentThemeBackgroundOption, mCurrentThemeBackgroundAlpha);
}
}
protected boolean shouldApplyWindowBackground() {

View File

@ -35,6 +35,7 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
@ -45,6 +46,7 @@ import android.support.v7.internal.widget.NativeActionModeAwareLayout;
import android.support.v7.widget.ActionMenuView;
import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.Menu;
import android.view.MenuItem;
@ -109,6 +111,7 @@ public class SignInActivity extends BaseAppCompatActivity implements TwitterCons
public static final String FRAGMENT_TAG_SIGN_IN_PROGRESS = "sign_in_progress";
private static final String DEFAULT_TWITTER_API_URL_FORMAT = "https://[DOMAIN.]twitter.com/";
@Nullable
private String mAPIUrlFormat;
private int mAuthType;
private String mConsumerKey, mConsumerSecret;
@ -126,7 +129,6 @@ public class SignInActivity extends BaseAppCompatActivity implements TwitterCons
private ContentResolver mResolver;
private AbstractSignInTask mTask;
private TintedStatusLayout mMainContent;
private TwidereActionModeForChildListener mTwidereActionModeForChildListener;
@Override
public void afterTextChanged(final Editable s) {
@ -311,9 +313,9 @@ public class SignInActivity extends BaseAppCompatActivity implements TwitterCons
setContentView(R.layout.activity_sign_in);
setSupportActionBar((Toolbar) findViewById(R.id.action_bar));
mTwidereActionModeForChildListener = new TwidereActionModeForChildListener(this, this, false);
TwidereActionModeForChildListener actionModeForChildListener = new TwidereActionModeForChildListener(this, this, false);
final NativeActionModeAwareLayout layout = (NativeActionModeAwareLayout) findViewById(android.R.id.content);
layout.setActionModeForChildListener(mTwidereActionModeForChildListener);
layout.setActionModeForChildListener(actionModeForChildListener);
ThemeUtils.setCompatContentViewOverlay(this, new EmptyDrawable());
final View actionBarContainer = findViewById(R.id.twidere_action_bar_container);
@ -354,8 +356,10 @@ public class SignInActivity extends BaseAppCompatActivity implements TwitterCons
}
saveEditedText();
setDefaultAPI();
mTask = new SignInTask(this, mUsername, mPassword, mAuthType, new OAuthToken(mConsumerKey,
mConsumerSecret), mAPIUrlFormat, mSameOAuthSigningUrl, mNoVersionSuffix);
final OAuthToken consumerKey = new OAuthToken(mConsumerKey, mConsumerSecret);
final String apiUrlFormat = TextUtils.isEmpty(mAPIUrlFormat) ? DEFAULT_TWITTER_API_URL_FORMAT : mAPIUrlFormat;
mTask = new SignInTask(this, mUsername, mPassword, mAuthType, consumerKey, apiUrlFormat,
mSameOAuthSigningUrl, mNoVersionSuffix);
AsyncTaskUtils.executeTask(mTask);
}
@ -366,11 +370,12 @@ public class SignInActivity extends BaseAppCompatActivity implements TwitterCons
}
saveEditedText();
setDefaultAPI();
final String requestToken = intent.getStringExtra(EXTRA_REQUEST_TOKEN);
final String requestTokenSecret = intent.getStringExtra(EXTRA_REQUEST_TOKEN_SECRET);
final String verifier = intent.getStringExtra(EXTRA_OAUTH_VERIFIER);
mTask = new BrowserSignInTask(this, new OAuthToken(mConsumerKey, mConsumerSecret),
new OAuthToken(requestToken, requestTokenSecret), verifier, mAPIUrlFormat,
final OAuthToken consumerKey = new OAuthToken(mConsumerKey, mConsumerSecret);
final OAuthToken requestToken = new OAuthToken(intent.getStringExtra(EXTRA_REQUEST_TOKEN),
intent.getStringExtra(EXTRA_REQUEST_TOKEN_SECRET));
final String apiUrlFormat = TextUtils.isEmpty(mAPIUrlFormat) ? DEFAULT_TWITTER_API_URL_FORMAT : mAPIUrlFormat;
mTask = new BrowserSignInTask(this, consumerKey, requestToken, verifier, apiUrlFormat,
mSameOAuthSigningUrl, mNoVersionSuffix);
AsyncTaskUtils.executeTask(mTask);
}
@ -384,7 +389,7 @@ public class SignInActivity extends BaseAppCompatActivity implements TwitterCons
private void setDefaultAPI() {
final long apiLastChange = mPreferences.getLong(KEY_API_LAST_CHANGE, mAPIChangeTimestamp);
final boolean defaultApiChanged = apiLastChange != mAPIChangeTimestamp;
final String apiUrlFormat = getNonEmptyString(mPreferences, KEY_API_URL_FORMAT, null);
final String apiUrlFormat = getNonEmptyString(mPreferences, KEY_API_URL_FORMAT, DEFAULT_TWITTER_API_URL_FORMAT);
final int authType = mPreferences.getInt(KEY_AUTH_TYPE, Accounts.AUTH_TYPE_OAUTH);
final boolean sameOAuthSigningUrl = mPreferences.getBoolean(KEY_SAME_OAUTH_SIGNING_URL, false);
final boolean noVersionSuffix = mPreferences.getBoolean(KEY_NO_VERSION_SUFFIX, false);
@ -489,10 +494,6 @@ public class SignInActivity extends BaseAppCompatActivity implements TwitterCons
});
}
protected TintedStatusLayout getMainContent() {
return mMainContent;
}
protected boolean isActionBarOutlineEnabled() {
return true;
}
@ -570,13 +571,14 @@ public class SignInActivity extends BaseAppCompatActivity implements TwitterCons
private final String oauthVerifier;
private final Context context;
@NonNull
private final String apiUrlFormat;
private final boolean sameOauthSigningUrl, noVersionSuffix;
private final OAuthToken consumerKey, requestToken;
public BrowserSignInTask(final SignInActivity context, OAuthToken consumerKey,
final OAuthToken requestToken,
final String oauthVerifier, final String apiUrlFormat,
final String oauthVerifier, @NonNull final String apiUrlFormat,
final boolean sameOauthSigningUrl, final boolean noVersionSuffix) {
super(context);
this.context = context;
@ -630,21 +632,22 @@ public class SignInActivity extends BaseAppCompatActivity implements TwitterCons
public static class SignInTask extends AbstractSignInTask {
private final String username, password;
private final int auth_type;
private final int authType;
private final Context context;
@NonNull
private final String apiUrlFormat;
private final boolean sameOAuthSigningUrl, noVersionSuffix;
private final OAuthToken consumerKey;
public SignInTask(final SignInActivity context, final String username, final String password, final int auth_type,
final OAuthToken consumerKey, final String apiUrlFormat, final boolean sameOAuthSigningUrl,
public SignInTask(final SignInActivity context, final String username, final String password, final int authType,
final OAuthToken consumerKey, @NonNull final String apiUrlFormat, final boolean sameOAuthSigningUrl,
final boolean noVersionSuffix) {
super(context);
this.context = context;
this.username = username;
this.password = password;
this.auth_type = auth_type;
this.authType = authType;
this.consumerKey = consumerKey;
this.apiUrlFormat = apiUrlFormat;
this.sameOAuthSigningUrl = sameOAuthSigningUrl;
@ -654,7 +657,7 @@ public class SignInActivity extends BaseAppCompatActivity implements TwitterCons
@Override
protected SignInResponse doInBackground(final Object... params) {
try {
switch (auth_type) {
switch (authType) {
case Accounts.AUTH_TYPE_OAUTH:
return authOAuth();
case Accounts.AUTH_TYPE_XAUTH:
@ -680,9 +683,9 @@ public class SignInActivity extends BaseAppCompatActivity implements TwitterCons
final Authorization auth = new BasicAuthorization(username, password);
final Twitter twitter = TwitterAPIUtils.getInstance(context, endpoint, auth, Twitter.class);
final User user = twitter.verifyCredentials();
final long user_id = user.getId();
if (user_id <= 0) return new SignInResponse(false, false, null);
if (isUserLoggedIn(context, user_id)) return new SignInResponse(true, false, null);
final long userId = user.getId();
if (userId <= 0) return new SignInResponse(false, false, null);
if (isUserLoggedIn(context, userId)) return new SignInResponse(true, false, null);
final int color = analyseUserProfileColor(user);
return new SignInResponse(username, password, user, color, apiUrlFormat,
noVersionSuffix);
@ -701,9 +704,9 @@ public class SignInActivity extends BaseAppCompatActivity implements TwitterCons
final TwitterOAuth oauth = TwitterAPIUtils.getInstance(context, endpoint, auth, TwitterOAuth.class);
final OAuthPasswordAuthenticator authenticator = new OAuthPasswordAuthenticator(oauth);
final OAuthToken accessToken = authenticator.getOAuthAccessToken(username, password);
final long user_id = accessToken.getUserId();
if (user_id <= 0) return new SignInResponse(false, false, null);
if (isUserLoggedIn(context, user_id)) return new SignInResponse(true, false, null);
final long userId = accessToken.getUserId();
if (userId <= 0) return new SignInResponse(false, false, null);
if (isUserLoggedIn(context, userId)) return new SignInResponse(true, false, null);
final String versionSuffix = noVersionSuffix ? null : "1.1";
endpointUrl = Utils.getApiUrl(apiUrlFormat, "api", versionSuffix);
@ -728,9 +731,9 @@ public class SignInActivity extends BaseAppCompatActivity implements TwitterCons
final Authorization auth = new EmptyAuthorization();
final Twitter twitter = TwitterAPIUtils.getInstance(context, endpoint, auth, Twitter.class);
final User user = twitter.verifyCredentials();
final long user_id = user.getId();
if (user_id <= 0) return new SignInResponse(false, false, null);
if (isUserLoggedIn(context, user_id)) return new SignInResponse(true, false, null);
final long userId = user.getId();
if (userId <= 0) return new SignInResponse(false, false, null);
if (isUserLoggedIn(context, userId)) return new SignInResponse(true, false, null);
final int color = analyseUserProfileColor(user);
return new SignInResponse(user, color, apiUrlFormat, noVersionSuffix);
}
@ -741,12 +744,11 @@ public class SignInActivity extends BaseAppCompatActivity implements TwitterCons
OAuthAuthorization auth = new OAuthAuthorization(consumerKey.getOauthToken(), consumerKey.getOauthTokenSecret());
final TwitterOAuth oauth = TwitterAPIUtils.getInstance(context, endpoint, auth, TwitterOAuth.class);
final OAuthToken accessToken = oauth.getAccessToken(username, password, TwitterOAuth.XAuthMode.CLIENT);
final long user_id = accessToken.getUserId();
if (user_id <= 0) return new SignInResponse(false, false, null);
if (isUserLoggedIn(context, user_id)) return new SignInResponse(true, false, null);
final long userId = accessToken.getUserId();
if (userId <= 0) return new SignInResponse(false, false, null);
if (isUserLoggedIn(context, userId)) return new SignInResponse(true, false, null);
auth = new OAuthAuthorization(consumerKey.getOauthToken(), consumerKey.getOauthTokenSecret(), accessToken);
final Twitter twitter = TwitterAPIUtils.getInstance(context, endpoint,
auth, Twitter.class);
final Twitter twitter = TwitterAPIUtils.getInstance(context, endpoint, auth, Twitter.class);
final User user = twitter.verifyCredentials();
final int color = analyseUserProfileColor(user);
return new SignInResponse(auth, user, Accounts.AUTH_TYPE_XAUTH, color, apiUrlFormat,

View File

@ -122,6 +122,10 @@ public abstract class ThemedAppCompatActivity extends AppCompatActivity implemen
@Override
public void setTheme(int resid) {
super.setTheme(mCurrentThemeResource = getThemeResourceId());
if (shouldApplyWindowBackground()) {
ThemeUtils.applyWindowBackground(this, getWindow(), resid, mCurrentThemeBackgroundOption,
mCurrentThemeBackgroundAlpha);
}
}
@Override
@ -132,10 +136,6 @@ public abstract class ThemedAppCompatActivity extends AppCompatActivity implemen
mCurrentThemeBackgroundOption = getThemeBackgroundOption();
mCurrentThemeFontFamily = getThemeFontFamily();
super.onApplyThemeResource(theme, resid, first);
if (shouldApplyWindowBackground()) {
ThemeUtils.applyWindowBackground(this, getWindow(), resid, mCurrentThemeBackgroundOption,
mCurrentThemeBackgroundAlpha);
}
}
@Override

View File

@ -134,6 +134,10 @@ public abstract class ThemedFragmentActivity extends FragmentActivity implements
@Override
public void setTheme(int resid) {
super.setTheme(mCurrentThemeResource = getThemeResourceId());
if (shouldApplyWindowBackground()) {
ThemeUtils.applyWindowBackground(this, getWindow(), mCurrentThemeResource,
mCurrentThemeBackgroundOption, mCurrentThemeBackgroundAlpha);
}
}
@Override
@ -144,10 +148,6 @@ public abstract class ThemedFragmentActivity extends FragmentActivity implements
mCurrentThemeBackgroundOption = getThemeBackgroundOption();
mProfileImageStyle = Utils.getProfileImageStyle(this);
super.onApplyThemeResource(theme, resId, first);
if (shouldApplyWindowBackground()) {
ThemeUtils.applyWindowBackground(this, getWindow(), mCurrentThemeResource,
mCurrentThemeBackgroundOption, mCurrentThemeBackgroundAlpha);
}
}
@Override

View File

@ -46,6 +46,7 @@ import com.squareup.otto.Bus;
import org.acra.ACRA;
import org.acra.annotation.ReportsCrashes;
import org.acra.sender.HttpSender;
import org.mariotaku.twidere.BuildConfig;
import org.mariotaku.twidere.Constants;
import org.mariotaku.twidere.activity.AssistLauncherActivity;
import org.mariotaku.twidere.activity.MainActivity;
@ -82,7 +83,8 @@ import static org.mariotaku.twidere.util.Utils.startUsageStatisticsServiceIfNeed
reportType = HttpSender.Type.JSON,
httpMethod = HttpSender.Method.PUT,
formUriBasicAuthLogin = "membeentlyposedistderryb",
formUriBasicAuthPassword = "oYETEB0KXUThmyXketa8V4XY")
formUriBasicAuthPassword = "oYETEB0KXUThmyXketa8V4XY",
buildConfigClass = BuildConfig.class)
public class TwidereApplication extends MultiDexApplication implements Constants,
OnSharedPreferenceChangeListener {

View File

@ -30,9 +30,9 @@ public class StatusFavoritersListFragment extends CursorSupportUsersListFragment
@Override
public IDsUsersLoader onCreateUsersLoader(final Context context, final Bundle args, boolean fromUser) {
if (args == null) return null;
final long account_id = args.getLong(EXTRA_ACCOUNT_ID, -1);
final long status_id = args.getLong(EXTRA_STATUS_ID, -1);
return new StatusFavoritersLoader(context, account_id, status_id, getNextCursor(), getData(), false);
final long accountId = args.getLong(EXTRA_ACCOUNT_ID, -1);
final long statusId = args.getLong(EXTRA_STATUS_ID, -1);
return new StatusFavoritersLoader(context, accountId, statusId, getNextCursor(), getData(), false);
}
}

View File

@ -863,6 +863,16 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
Utils.openStatusRetweeters(activity, status.account_id, status.id);
break;
}
case R.id.favorites_container: {
final FragmentActivity activity = fragment.getActivity();
if (!Utils.isOfficialCredentials(activity, adapter.getStatusAccount())) return;
if (status.is_retweet) {
Utils.openStatusFavoriters(activity, status.account_id, status.retweet_id);
} else {
Utils.openStatusFavoriters(activity, status.account_id, status.id);
}
break;
}
case R.id.retweeted_by_container: {
if (status.retweet_id > 0) {
Utils.openUserProfile(adapter.getContext(), status.account_id, status.retweeted_by_user_id,

View File

@ -197,7 +197,7 @@ public class ThemeUtils implements Constants {
}
}
public static void applyWindowBackground(Context context, Window window, int theme, String option, int alpha) {
public static void applyWindowBackground(@NonNull Context context, @NonNull Window window, int theme, String option, int alpha) {
if (isWindowFloating(context, theme)) return;
final int normalTheme = getThemeResource(theme);
if (VALUE_THEME_BACKGROUND_TRANSPARENT.equals(option)) {

View File

@ -46,7 +46,11 @@
android:hint="@string/comment_hint"
android:inputType="text"
android:visibility="visible"
app:met_maxCharacters="140">
app:met_baseColor="?android:textColorSecondary"
app:met_helperTextColor="?android:textColorSecondary"
app:met_maxCharacters="140"
app:met_textColor="?android:textColorPrimary"
app:met_textColorHint="?android:textColorSecondary">
<requestFocus />
</org.mariotaku.twidere.view.themed.BackgroundTintMaterialEditText>

View File

@ -64,7 +64,7 @@
android:id="@+id/label_auth_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/auth_type"
android:text="@string/authType"
android:textAppearance="?android:attr/textAppearanceSmall" />
<HorizontalScrollView