parent
d443558495
commit
96a2fd46ff
|
@ -494,13 +494,18 @@ public class ComposeActivity extends ThemedFragmentActivity implements OnMenuIte
|
||||||
final float x = ev.getRawX(), y = ev.getRawY();
|
final float x = ev.getRawX(), y = ev.getRawY();
|
||||||
if (isAccountSelectorVisible()) {
|
if (isAccountSelectorVisible()) {
|
||||||
if (!TwidereViewUtils.hitView(x, y, mAccountSelectorButton)) {
|
if (!TwidereViewUtils.hitView(x, y, mAccountSelectorButton)) {
|
||||||
for (int i = 0, j = mAccountSelector.getChildCount(); i < j; i++) {
|
boolean clickedItem = false;
|
||||||
if (TwidereViewUtils.hitView(x, y, mAccountSelector.getChildAt(i))) {
|
final RecyclerView.LayoutManager layoutManager = mAccountSelector.getLayoutManager();
|
||||||
|
for (int i = 0, j = layoutManager.getChildCount(); i < j; i++) {
|
||||||
|
if (TwidereViewUtils.hitView(x, y, layoutManager.getChildAt(i))) {
|
||||||
|
clickedItem = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setAccountSelectorVisible(false);
|
if (!clickedItem) {
|
||||||
return true;
|
setAccountSelectorVisible(false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -464,6 +464,8 @@ public class SignInActivity extends BaseAppCompatActivity implements OnClickList
|
||||||
Toast.makeText(this, R.string.wrong_api_key, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.wrong_api_key, Toast.LENGTH_SHORT).show();
|
||||||
} else if (result.exception instanceof WrongUserPassException) {
|
} else if (result.exception instanceof WrongUserPassException) {
|
||||||
Toast.makeText(this, R.string.wrong_username_password, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.wrong_username_password, Toast.LENGTH_SHORT).show();
|
||||||
|
} else if (result.exception instanceof SignInTask.WrongBasicCredentialException) {
|
||||||
|
Toast.makeText(this, R.string.wrong_username_password, Toast.LENGTH_SHORT).show();
|
||||||
} else if (result.exception instanceof LoginVerificationException) {
|
} else if (result.exception instanceof LoginVerificationException) {
|
||||||
Toast.makeText(this, R.string.login_verification_failed, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.login_verification_failed, Toast.LENGTH_SHORT).show();
|
||||||
} else if (result.exception instanceof AuthenticationException) {
|
} else if (result.exception instanceof AuthenticationException) {
|
||||||
|
@ -730,17 +732,29 @@ public class SignInActivity extends BaseAppCompatActivity implements OnClickList
|
||||||
} catch (final AuthenticationException e) {
|
} catch (final AuthenticationException e) {
|
||||||
Log.w(LOGTAG, e);
|
Log.w(LOGTAG, e);
|
||||||
return new SignInResponse(false, false, e);
|
return new SignInResponse(false, false, e);
|
||||||
|
} catch (final WrongBasicCredentialException e) {
|
||||||
|
Log.w(LOGTAG, e);
|
||||||
|
return new SignInResponse(false, false, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private SignInResponse authBasic() throws TwitterException {
|
private SignInResponse authBasic() throws TwitterException, WrongUserPassException,
|
||||||
|
WrongBasicCredentialException {
|
||||||
final SignInActivity activity = activityRef.get();
|
final SignInActivity activity = activityRef.get();
|
||||||
if (activity == null) return new SignInResponse(false, false, null);
|
if (activity == null) return new SignInResponse(false, false, null);
|
||||||
final String versionSuffix = noVersionSuffix ? null : "1.1";
|
final String versionSuffix = noVersionSuffix ? null : "1.1";
|
||||||
final Endpoint endpoint = new Endpoint(TwitterAPIFactory.getApiUrl(apiUrlFormat, "api", versionSuffix));
|
final Endpoint endpoint = new Endpoint(TwitterAPIFactory.getApiUrl(apiUrlFormat, "api", versionSuffix));
|
||||||
final Authorization auth = new BasicAuthorization(username, password);
|
final Authorization auth = new BasicAuthorization(username, password);
|
||||||
final Twitter twitter = TwitterAPIFactory.getInstance(activity, endpoint, auth, Twitter.class);
|
final Twitter twitter = TwitterAPIFactory.getInstance(activity, endpoint, auth, Twitter.class);
|
||||||
final User user = twitter.verifyCredentials();
|
User user = null;
|
||||||
|
try {
|
||||||
|
user = twitter.verifyCredentials();
|
||||||
|
} catch (TwitterException e) {
|
||||||
|
if (e.getStatusCode() == 401) {
|
||||||
|
throw new WrongBasicCredentialException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (user == null) throw new NullPointerException();
|
||||||
final long userId = user.getId();
|
final long userId = user.getId();
|
||||||
if (userId <= 0) return new SignInResponse(false, false, null);
|
if (userId <= 0) return new SignInResponse(false, false, null);
|
||||||
if (isUserLoggedIn(activity, userId)) return new SignInResponse(true, false, null);
|
if (isUserLoggedIn(activity, userId)) return new SignInResponse(true, false, null);
|
||||||
|
@ -749,6 +763,10 @@ public class SignInActivity extends BaseAppCompatActivity implements OnClickList
|
||||||
color, apiUrlFormat, noVersionSuffix);
|
color, apiUrlFormat, noVersionSuffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class WrongBasicCredentialException extends Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private SignInResponse authOAuth() throws AuthenticationException, TwitterException {
|
private SignInResponse authOAuth() throws AuthenticationException, TwitterException {
|
||||||
final SignInActivity activity = activityRef.get();
|
final SignInActivity activity = activityRef.get();
|
||||||
if (activity == null) return new SignInResponse(false, false, null);
|
if (activity == null) return new SignInResponse(false, false, null);
|
||||||
|
|
|
@ -44,7 +44,6 @@ import android.nfc.NfcAdapter.CreateNdefMessageCallback;
|
||||||
import android.nfc.NfcEvent;
|
import android.nfc.NfcEvent;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Parcelable;
|
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
|
@ -122,13 +121,13 @@ import org.mariotaku.twidere.util.HtmlSpanBuilder;
|
||||||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler;
|
import org.mariotaku.twidere.util.KeyboardShortcutsHandler;
|
||||||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler.KeyboardShortcutCallback;
|
import org.mariotaku.twidere.util.KeyboardShortcutsHandler.KeyboardShortcutCallback;
|
||||||
import org.mariotaku.twidere.util.LinkCreator;
|
import org.mariotaku.twidere.util.LinkCreator;
|
||||||
import org.mariotaku.twidere.util.TwidereMathUtils;
|
|
||||||
import org.mariotaku.twidere.util.MenuUtils;
|
import org.mariotaku.twidere.util.MenuUtils;
|
||||||
import org.mariotaku.twidere.util.ParseUtils;
|
import org.mariotaku.twidere.util.ParseUtils;
|
||||||
import org.mariotaku.twidere.util.ThemeUtils;
|
import org.mariotaku.twidere.util.ThemeUtils;
|
||||||
import org.mariotaku.twidere.util.TwidereColorUtils;
|
import org.mariotaku.twidere.util.TwidereColorUtils;
|
||||||
import org.mariotaku.twidere.util.TwidereLinkify;
|
import org.mariotaku.twidere.util.TwidereLinkify;
|
||||||
import org.mariotaku.twidere.util.TwidereLinkify.OnLinkClickListener;
|
import org.mariotaku.twidere.util.TwidereLinkify.OnLinkClickListener;
|
||||||
|
import org.mariotaku.twidere.util.TwidereMathUtils;
|
||||||
import org.mariotaku.twidere.util.TwitterAPIFactory;
|
import org.mariotaku.twidere.util.TwitterAPIFactory;
|
||||||
import org.mariotaku.twidere.util.Utils;
|
import org.mariotaku.twidere.util.Utils;
|
||||||
import org.mariotaku.twidere.util.menu.TwidereMenuInfo;
|
import org.mariotaku.twidere.util.menu.TwidereMenuInfo;
|
||||||
|
@ -526,8 +525,10 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
|
||||||
mMediaLoader.displayProfileImage(mProfileImageView, Utils.getOriginalTwitterProfileImage(user.profile_image_url));
|
mMediaLoader.displayProfileImage(mProfileImageView, Utils.getOriginalTwitterProfileImage(user.profile_image_url));
|
||||||
if (userColor != 0) {
|
if (userColor != 0) {
|
||||||
setUiColor(userColor);
|
setUiColor(userColor);
|
||||||
} else {
|
} else if (user.link_color != 0) {
|
||||||
setUiColor(user.link_color);
|
setUiColor(user.link_color);
|
||||||
|
} else if (activity instanceof IThemedActivity) {
|
||||||
|
setUiColor(((IThemedActivity) activity).getCurrentThemeColor());
|
||||||
}
|
}
|
||||||
final int defWidth = resources.getDisplayMetrics().widthPixels;
|
final int defWidth = resources.getDisplayMetrics().widthPixels;
|
||||||
final int width = mBannerWidth > 0 ? mBannerWidth : defWidth;
|
final int width = mBannerWidth > 0 ? mBannerWidth : defWidth;
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
package org.mariotaku.twidere.util;
|
package org.mariotaku.twidere.util;
|
||||||
|
|
||||||
import android.support.annotation.IntDef;
|
import android.support.annotation.IntDef;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
|
@ -106,22 +107,23 @@ public final class TwidereLinkify implements Constants {
|
||||||
setHighlightOption(highlightOption);
|
setHighlightOption(highlightOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpannableString applyAllLinks(CharSequence text, final long accountId, final long extraId, final boolean sensitive) {
|
public SpannableString applyAllLinks(@Nullable CharSequence text, final long accountId, final long extraId, final boolean sensitive) {
|
||||||
return applyAllLinks(text, mOnLinkClickListener, accountId, extraId, sensitive, mHighlightOption);
|
return applyAllLinks(text, mOnLinkClickListener, accountId, extraId, sensitive, mHighlightOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpannableString applyAllLinks(CharSequence text, final long accountId, final boolean sensitive) {
|
public SpannableString applyAllLinks(@Nullable CharSequence text, final long accountId, final boolean sensitive) {
|
||||||
return applyAllLinks(text, mOnLinkClickListener, accountId, -1, sensitive, mHighlightOption);
|
return applyAllLinks(text, mOnLinkClickListener, accountId, -1, sensitive, mHighlightOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpannableString applyAllLinks(CharSequence text, final long accountId, final long extraId,
|
public SpannableString applyAllLinks(@Nullable CharSequence text, final long accountId, final long extraId,
|
||||||
final boolean sensitive, final int highlightOption) {
|
final boolean sensitive, final int highlightOption) {
|
||||||
return applyAllLinks(text, mOnLinkClickListener, accountId, extraId, sensitive, highlightOption);
|
return applyAllLinks(text, mOnLinkClickListener, accountId, extraId, sensitive, highlightOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpannableString applyAllLinks(final CharSequence text, final OnLinkClickListener listener,
|
public SpannableString applyAllLinks(@Nullable final CharSequence text, final OnLinkClickListener listener,
|
||||||
final long accountId, final long extraId, final boolean sensitive,
|
final long accountId, final long extraId, final boolean sensitive,
|
||||||
final int highlightOption) {
|
final int highlightOption) {
|
||||||
|
if (text == null) return null;
|
||||||
final SpannableString string = SpannableString.valueOf(text);
|
final SpannableString string = SpannableString.valueOf(text);
|
||||||
for (final int type : ALL_LINK_TYPES) {
|
for (final int type : ALL_LINK_TYPES) {
|
||||||
addLinks(string, accountId, extraId, type, sensitive, listener, highlightOption);
|
addLinks(string, accountId, extraId, type, sensitive, listener, highlightOption);
|
||||||
|
|
|
@ -12,6 +12,6 @@ public class TwidereViewUtils {
|
||||||
int[] location = new int[2];
|
int[] location = new int[2];
|
||||||
view.getLocationOnScreen(location);
|
view.getLocationOnScreen(location);
|
||||||
return TwidereMathUtils.inRange(x, location[0], location[0] + view.getWidth(), TwidereMathUtils.RANGE_INCLUSIVE_INCLUSIVE) &&
|
return TwidereMathUtils.inRange(x, location[0], location[0] + view.getWidth(), TwidereMathUtils.RANGE_INCLUSIVE_INCLUSIVE) &&
|
||||||
TwidereMathUtils.inRange(x, location[1], location[1] + view.getHeight(), TwidereMathUtils.RANGE_INCLUSIVE_INCLUSIVE);
|
TwidereMathUtils.inRange(y, location[1], location[1] + view.getHeight(), TwidereMathUtils.RANGE_INCLUSIVE_INCLUSIVE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue