supports place full name displaying in status detail
fixed location validation some features with "force using private apis" should work
This commit is contained in:
parent
7fc3055acd
commit
07b3ed7998
|
@ -69,18 +69,18 @@ public class ParcelableLocation implements Serializable, Parcelable, JSONParcela
|
|||
}
|
||||
|
||||
public ParcelableLocation(@Nullable final GeoLocation location) {
|
||||
latitude = location != null ? location.getLatitude() : -1;
|
||||
longitude = location != null ? location.getLongitude() : -1;
|
||||
latitude = location != null ? location.getLatitude() : Double.NaN;
|
||||
longitude = location != null ? location.getLongitude() : Double.NaN;
|
||||
}
|
||||
|
||||
public ParcelableLocation(@NonNull final JSONParcel in) {
|
||||
latitude = in.readDouble("latitude", -1);
|
||||
longitude = in.readDouble("longutude", -1);
|
||||
latitude = in.readDouble("latitude", Double.NaN);
|
||||
longitude = in.readDouble("longutude", Double.NaN);
|
||||
}
|
||||
|
||||
public ParcelableLocation(@Nullable final Location location) {
|
||||
latitude = location != null ? location.getLatitude() : -1;
|
||||
longitude = location != null ? location.getLongitude() : -1;
|
||||
latitude = location != null ? location.getLatitude() : Double.NaN;
|
||||
longitude = location != null ? location.getLongitude() : Double.NaN;
|
||||
}
|
||||
|
||||
public ParcelableLocation(final Parcel in) {
|
||||
|
@ -90,14 +90,14 @@ public class ParcelableLocation implements Serializable, Parcelable, JSONParcela
|
|||
|
||||
public ParcelableLocation(final String locationString) {
|
||||
if (locationString == null) {
|
||||
latitude = -1;
|
||||
longitude = -1;
|
||||
latitude = Double.NaN;
|
||||
longitude = Double.NaN;
|
||||
return;
|
||||
}
|
||||
final String[] longlat = locationString.split(",");
|
||||
if (longlat.length != 2) {
|
||||
latitude = -1;
|
||||
longitude = -1;
|
||||
latitude = Double.NaN;
|
||||
longitude = Double.NaN;
|
||||
} else {
|
||||
latitude = ParseUtils.parseDouble(longlat[0]);
|
||||
longitude = ParseUtils.parseDouble(longlat[1]);
|
||||
|
@ -122,6 +122,12 @@ public class ParcelableLocation implements Serializable, Parcelable, JSONParcela
|
|||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ParcelableLocation fromGeoLocation(@Nullable GeoLocation geoLocation) {
|
||||
if (geoLocation == null) return null;
|
||||
return new ParcelableLocation(geoLocation);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ParcelableLocation fromLocation(@Nullable Location location) {
|
||||
if (location == null) return null;
|
||||
|
@ -147,7 +153,7 @@ public class ParcelableLocation implements Serializable, Parcelable, JSONParcela
|
|||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return latitude >= 0 || longitude >= 0;
|
||||
return Double.isNaN(latitude) && Double.isNaN(longitude);
|
||||
}
|
||||
|
||||
public GeoLocation toGeoLocation() {
|
||||
|
@ -186,7 +192,7 @@ public class ParcelableLocation implements Serializable, Parcelable, JSONParcela
|
|||
}
|
||||
|
||||
public static String toString(final ParcelableLocation location) {
|
||||
if (location == null) return null;
|
||||
if (!isValidLocation(location)) return null;
|
||||
return location.latitude + "," + location.longitude;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import android.database.Cursor;
|
|||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import org.json.JSONException;
|
||||
|
@ -48,6 +49,7 @@ import twitter4j.CardEntity.BooleanValue;
|
|||
import twitter4j.CardEntity.ImageValue;
|
||||
import twitter4j.CardEntity.StringValue;
|
||||
import twitter4j.CardEntity.UserValue;
|
||||
import twitter4j.Place;
|
||||
import twitter4j.Status;
|
||||
import twitter4j.User;
|
||||
|
||||
|
@ -110,6 +112,8 @@ public class ParcelableStatus implements TwidereParcelable, Comparable<Parcelabl
|
|||
|
||||
public final ParcelableLocation location;
|
||||
|
||||
public final String place_full_name;
|
||||
|
||||
public final ParcelableUserMention[] mentions;
|
||||
|
||||
public final ParcelableMedia[] media;
|
||||
|
@ -154,6 +158,7 @@ public class ParcelableStatus implements TwidereParcelable, Comparable<Parcelabl
|
|||
user_is_following = ContentValuesUtils.getAsBoolean(values, Statuses.IS_FOLLOWING, false);
|
||||
mentions = SimpleValueSerializer.fromSerializedString(values.getAsString(Statuses.MENTIONS_LIST), ParcelableUserMention.SIMPLE_CREATOR);
|
||||
card = ParcelableCardEntity.fromJSONString(values.getAsString(Statuses.CARD));
|
||||
place_full_name = values.getAsString(Statuses.PLACE_FULL_NAME);
|
||||
card_name = card != null ? card.name : null;
|
||||
}
|
||||
|
||||
|
@ -198,6 +203,7 @@ public class ParcelableStatus implements TwidereParcelable, Comparable<Parcelabl
|
|||
user_is_following = idx.is_following != -1 && c.getInt(idx.is_following) == 1;
|
||||
mentions = idx.mentions != -1 ? ParcelableUserMention.fromJSONString(c.getString(idx.mentions)) : null;
|
||||
card = idx.card != -1 ? ParcelableCardEntity.fromJSONString(c.getString(idx.card)) : null;
|
||||
place_full_name = idx.place_full_name != -1 ? c.getString(idx.place_full_name) : null;
|
||||
card_name = card != null ? card.name : null;
|
||||
}
|
||||
|
||||
|
@ -239,6 +245,7 @@ public class ParcelableStatus implements TwidereParcelable, Comparable<Parcelabl
|
|||
user_is_following = in.readBoolean("is_following");
|
||||
mentions = in.readParcelableArray("mentions", ParcelableUserMention.JSON_CREATOR);
|
||||
card = in.readParcelable("card", ParcelableCardEntity.JSON_CREATOR);
|
||||
place_full_name = in.readString("place_full_name");
|
||||
card_name = card != null ? card.name : null;
|
||||
}
|
||||
|
||||
|
@ -280,6 +287,7 @@ public class ParcelableStatus implements TwidereParcelable, Comparable<Parcelabl
|
|||
in_reply_to_name = in.readString();
|
||||
mentions = in.createTypedArray(ParcelableUserMention.CREATOR);
|
||||
card = in.readParcelable(ParcelableCardEntity.class.getClassLoader());
|
||||
place_full_name = in.readString();
|
||||
card_name = card != null ? card.name : null;
|
||||
}
|
||||
|
||||
|
@ -322,6 +330,7 @@ public class ParcelableStatus implements TwidereParcelable, Comparable<Parcelabl
|
|||
in_reply_to_name = orig.in_reply_to_name;
|
||||
mentions = orig.mentions;
|
||||
card = orig.card;
|
||||
place_full_name = orig.place_full_name;
|
||||
card_name = card != null ? card.name : null;
|
||||
}
|
||||
|
||||
|
@ -405,16 +414,23 @@ public class ParcelableStatus implements TwidereParcelable, Comparable<Parcelabl
|
|||
in_reply_to_status_id = status.getInReplyToStatusId();
|
||||
in_reply_to_user_id = status.getInReplyToUserId();
|
||||
source = status.getSource();
|
||||
location = new ParcelableLocation(status.getGeoLocation());
|
||||
location = ParcelableLocation.fromGeoLocation(status.getGeoLocation());
|
||||
is_favorite = status.isFavorited();
|
||||
text_unescaped = HtmlEscapeHelper.toPlainText(text_html);
|
||||
my_retweet_id = retweeted_by_id == account_id ? id : status.getCurrentUserRetweet();
|
||||
is_possibly_sensitive = status.isPossiblySensitive();
|
||||
mentions = ParcelableUserMention.fromUserMentionEntities(status.getUserMentionEntities());
|
||||
card = ParcelableCardEntity.fromCardEntity(status.getCard(), account_id);
|
||||
place_full_name = getPlaceFullName(status.getPlace());
|
||||
card_name = card != null ? card.name : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getPlaceFullName(@Nullable Place place) {
|
||||
if (place == null) return null;
|
||||
return place.getFullName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@NonNull final ParcelableStatus another) {
|
||||
final long diff = another.id - id;
|
||||
|
@ -485,6 +501,7 @@ public class ParcelableStatus implements TwidereParcelable, Comparable<Parcelabl
|
|||
out.writeBoolean("is_following", user_is_following);
|
||||
out.writeParcelableArray("mentions", mentions);
|
||||
out.writeParcelable("card", card);
|
||||
out.writeString("place_full_name", place_full_name);
|
||||
}
|
||||
|
||||
private static long getTime(final Date date) {
|
||||
|
@ -500,7 +517,7 @@ public class ParcelableStatus implements TwidereParcelable, Comparable<Parcelabl
|
|||
retweeted_by_user_screen_name, retweeted_by_user_profile_image, retweet_id, retweet_timestamp,
|
||||
retweeted_by_user_id, user_id, source, retweet_count, favorite_count, reply_count,
|
||||
descendent_reply_count, is_possibly_sensitive, is_following, media, mentions,
|
||||
card_name, card;
|
||||
card_name, card, place_full_name;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -544,6 +561,7 @@ public class ParcelableStatus implements TwidereParcelable, Comparable<Parcelabl
|
|||
", mentions=" + mentions +
|
||||
", card_name=" + card_name +
|
||||
", card=" + card +
|
||||
", place_full_name=" + place_full_name +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
@ -587,6 +605,7 @@ public class ParcelableStatus implements TwidereParcelable, Comparable<Parcelabl
|
|||
mentions = cursor.getColumnIndex(Statuses.MENTIONS_LIST);
|
||||
card_name = cursor.getColumnIndex(Statuses.CARD_NAME);
|
||||
card = cursor.getColumnIndex(Statuses.MENTIONS_LIST);
|
||||
place_full_name = cursor.getColumnIndex(Statuses.PLACE_FULL_NAME);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -630,6 +649,7 @@ public class ParcelableStatus implements TwidereParcelable, Comparable<Parcelabl
|
|||
out.writeString(in_reply_to_name);
|
||||
out.writeTypedArray(mentions, flags);
|
||||
out.writeParcelable(card, flags);
|
||||
out.writeString(place_full_name);
|
||||
}
|
||||
|
||||
public static final class ParcelableCardEntity implements TwidereParcelable {
|
||||
|
|
|
@ -736,6 +736,8 @@ public interface TwidereDataStore {
|
|||
|
||||
public static final String LOCATION = "location";
|
||||
|
||||
public static final String PLACE_FULL_NAME = "place_full_name";
|
||||
|
||||
/**
|
||||
* User's ID of the status.<br>
|
||||
* Type: INTEGER (long)
|
||||
|
@ -799,14 +801,15 @@ public interface TwidereDataStore {
|
|||
DESCENDENT_REPLY_COUNT, RETWEET_ID, RETWEET_TIMESTAMP, RETWEETED_BY_USER_ID,
|
||||
RETWEETED_BY_USER_NAME, RETWEETED_BY_USER_SCREEN_NAME, RETWEETED_BY_USER_PROFILE_IMAGE,
|
||||
MY_RETWEET_ID, IS_RETWEET, IS_FAVORITE, IS_PROTECTED, IS_VERIFIED, IS_FOLLOWING, IS_GAP,
|
||||
IS_POSSIBLY_SENSITIVE, MEDIA_LIST, MENTIONS_LIST, CARD_NAME, CARD};
|
||||
IS_POSSIBLY_SENSITIVE, MEDIA_LIST, MENTIONS_LIST, CARD_NAME, CARD, PLACE_FULL_NAME};
|
||||
|
||||
public static final String[] TYPES = new String[]{TYPE_PRIMARY_KEY, TYPE_INT, TYPE_INT,
|
||||
TYPE_INT, TYPE_INT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT,
|
||||
TYPE_INT, TYPE_INT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_INT, TYPE_INT,
|
||||
TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_TEXT, TYPE_TEXT,
|
||||
TYPE_TEXT, TYPE_INT, TYPE_BOOLEAN, TYPE_BOOLEAN, TYPE_BOOLEAN, TYPE_BOOLEAN,
|
||||
TYPE_BOOLEAN, TYPE_BOOLEAN, TYPE_BOOLEAN, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT};
|
||||
TYPE_BOOLEAN, TYPE_BOOLEAN, TYPE_BOOLEAN, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT,
|
||||
TYPE_TEXT};
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ import java.util.List;
|
|||
|
||||
import twitter4j.DirectMessage;
|
||||
import twitter4j.GeoLocation;
|
||||
import twitter4j.Place;
|
||||
import twitter4j.Relationship;
|
||||
import twitter4j.SavedSearch;
|
||||
import twitter4j.Status;
|
||||
|
@ -357,6 +358,10 @@ public final class ContentValuesCreator implements TwidereConstants {
|
|||
if (location != null) {
|
||||
values.put(Statuses.LOCATION, location.getLatitude() + "," + location.getLongitude());
|
||||
}
|
||||
final Place place = status.getPlace();
|
||||
if (place != null) {
|
||||
values.put(Statuses.PLACE_FULL_NAME, place.getFullName());
|
||||
}
|
||||
values.put(Statuses.IS_RETWEET, isRetweet);
|
||||
values.put(Statuses.IS_FAVORITE, status.isFavorited());
|
||||
final ParcelableMedia[] media = ParcelableMedia.fromEntities(status);
|
||||
|
|
|
@ -33,7 +33,7 @@ import static org.mariotaku.twidere.annotation.Preference.Type.STRING;
|
|||
public interface Constants extends TwidereConstants {
|
||||
|
||||
String DATABASES_NAME = "twidere.sqlite";
|
||||
int DATABASES_VERSION = 92;
|
||||
int DATABASES_VERSION = 93;
|
||||
|
||||
int MENU_GROUP_STATUS_EXTENSION = 10;
|
||||
int MENU_GROUP_COMPOSE_EXTENSION = 11;
|
||||
|
|
|
@ -63,6 +63,7 @@ import org.mariotaku.twidere.activity.support.CustomTabEditorActivity;
|
|||
import org.mariotaku.twidere.model.CustomTabConfiguration;
|
||||
import org.mariotaku.twidere.model.CustomTabConfiguration.CustomTabConfigurationComparator;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Tabs;
|
||||
import org.mariotaku.twidere.util.SharedPreferencesWrapper;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
import org.mariotaku.twidere.view.holder.TwoLineWithIconViewHolder;
|
||||
|
@ -93,6 +94,7 @@ public class CustomTabsFragment extends BaseFragment implements LoaderCallbacks<
|
|||
private View mListContainer, mProgressContainer;
|
||||
private TextView mEmptyText;
|
||||
private ImageView mEmptyIcon;
|
||||
private SharedPreferencesWrapper mPreferences;
|
||||
|
||||
|
||||
@Override
|
||||
|
@ -111,6 +113,7 @@ public class CustomTabsFragment extends BaseFragment implements LoaderCallbacks<
|
|||
@Override
|
||||
public void onActivityCreated(final Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
mPreferences = SharedPreferencesWrapper.getInstance(getActivity(), SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
setHasOptionsMenu(true);
|
||||
mResolver = getContentResolver();
|
||||
final View view = getView();
|
||||
|
@ -266,7 +269,8 @@ public class CustomTabsFragment extends BaseFragment implements LoaderCallbacks<
|
|||
public void onPrepareOptionsMenu(final Menu menu) {
|
||||
final Resources res = getResources();
|
||||
final boolean hasOfficialKeyAccounts = Utils.hasAccountSignedWithOfficialKeys(getActivity());
|
||||
final long[] account_ids = getAccountIds(getActivity());
|
||||
final boolean forcePrivateAPI = mPreferences.getBoolean(KEY_FORCE_USING_PRIVATE_APIS, false);
|
||||
final long[] accountIds = getAccountIds(getActivity());
|
||||
final MenuItem itemAdd = menu.findItem(R.id.add_submenu);
|
||||
if (itemAdd != null && itemAdd.hasSubMenu()) {
|
||||
final SubMenu subMenu = itemAdd.getSubMenu();
|
||||
|
@ -289,9 +293,10 @@ public class CustomTabsFragment extends BaseFragment implements LoaderCallbacks<
|
|||
intent.putExtra(EXTRA_OFFICIAL_KEY_ONLY, isOfficiakKeyAccountRequired);
|
||||
|
||||
final MenuItem subItem = subMenu.add(conf.getDefaultTitle());
|
||||
final boolean shouldDisable = conf.isSingleTab() && isTabAdded(getActivity(), type)
|
||||
|| isOfficiakKeyAccountRequired && !hasOfficialKeyAccounts || accountIdRequired
|
||||
&& account_ids.length == 0;
|
||||
final boolean disabledByNoAccount = accountIdRequired && accountIds.length == 0;
|
||||
final boolean disabledByNoOfficialKey = !forcePrivateAPI && isOfficiakKeyAccountRequired && !hasOfficialKeyAccounts;
|
||||
final boolean disabledByDuplicateTab = conf.isSingleTab() && isTabAdded(getActivity(), type);
|
||||
final boolean shouldDisable = disabledByDuplicateTab || disabledByNoOfficialKey || disabledByNoAccount;
|
||||
subItem.setVisible(!shouldDisable);
|
||||
subItem.setEnabled(!shouldDisable);
|
||||
final Drawable icon = ResourcesCompat.getDrawable(res, conf.getDefaultIcon(), null);
|
||||
|
|
|
@ -95,6 +95,7 @@ import org.mariotaku.twidere.util.CompareUtils;
|
|||
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.TransitionUtils;
|
||||
import org.mariotaku.twidere.util.UserColorNameUtils;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
import org.mariotaku.twidere.util.content.SupportFragmentReloadCursorObserver;
|
||||
import org.mariotaku.twidere.view.ShapedImageView;
|
||||
|
@ -209,13 +210,25 @@ public class AccountsDashboardFragment extends BaseSupportListFragment implement
|
|||
}
|
||||
mAccountsAdapter.setAccounts(accounts);
|
||||
mAccountsAdapter.setSelectedAccountId(mPreferences.getLong(KEY_DEFAULT_ACCOUNT_ID, defaultId));
|
||||
mAccountOptionsAdapter.setSelectedAccount(mAccountsAdapter.getSelectedAccount());
|
||||
mAccountActionProvider.setAccounts(accounts);
|
||||
mAccountActionProvider.setSelectedAccountIds(ArrayUtils.toPrimitive(activatedIds.toArray(new Long[activatedIds.size()])));
|
||||
|
||||
initAccountActionsAdapter(accounts);
|
||||
updateAccountOptionsSeparatorLabel(null);
|
||||
updateDefaultAccountState();
|
||||
}
|
||||
|
||||
void initAccountActionsAdapter(ParcelableAccount[] accounts) {
|
||||
mAccountOptionsAdapter.clear();
|
||||
mAccountOptionsAdapter.add(new OptionItem(android.R.string.search_go, R.drawable.ic_action_search, MENU_SEARCH));
|
||||
if (accounts.length > 1) {
|
||||
mAccountOptionsAdapter.add(new OptionItem(R.string.compose, R.drawable.ic_action_status_compose, MENU_COMPOSE));
|
||||
}
|
||||
mAccountOptionsAdapter.add(new OptionItem(R.string.favorites, R.drawable.ic_action_star, MENU_FAVORITES));
|
||||
mAccountOptionsAdapter.add(new OptionItem(R.string.lists, R.drawable.ic_action_list, MENU_LISTS));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(final Loader<Cursor> loader) {
|
||||
}
|
||||
|
@ -496,6 +509,7 @@ public class AccountsDashboardFragment extends BaseSupportListFragment implement
|
|||
editor.putLong(KEY_DEFAULT_ACCOUNT_ID, account.account_id);
|
||||
editor.apply();
|
||||
mAccountsAdapter.setSelectedAccountId(account.account_id);
|
||||
mAccountOptionsAdapter.setSelectedAccount(account);
|
||||
updateAccountOptionsSeparatorLabel(clickedDrawable);
|
||||
snapshotView.setVisibility(View.INVISIBLE);
|
||||
snapshotView.setImageDrawable(null);
|
||||
|
@ -547,21 +561,27 @@ public class AccountsDashboardFragment extends BaseSupportListFragment implement
|
|||
|
||||
private static final class AccountOptionsAdapter extends OptionItemsAdapter {
|
||||
|
||||
private static final ArrayList<OptionItem> sOptions = new ArrayList<>();
|
||||
|
||||
static {
|
||||
sOptions.add(new OptionItem(android.R.string.search_go, R.drawable.ic_action_search, MENU_SEARCH));
|
||||
sOptions.add(new OptionItem(R.string.compose, R.drawable.ic_action_status_compose, MENU_COMPOSE));
|
||||
sOptions.add(new OptionItem(R.string.favorites, R.drawable.ic_action_star, MENU_FAVORITES));
|
||||
sOptions.add(new OptionItem(R.string.lists, R.drawable.ic_action_list, MENU_LISTS));
|
||||
}
|
||||
private ParcelableAccount mSelectedAccount;
|
||||
|
||||
public AccountOptionsAdapter(final Context context) {
|
||||
super(context);
|
||||
clear();
|
||||
addAll(sOptions);
|
||||
}
|
||||
|
||||
public void setSelectedAccount(ParcelableAccount account) {
|
||||
mSelectedAccount = account;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTitle(int position, OptionItem option) {
|
||||
final ParcelableAccount account = mSelectedAccount;
|
||||
if (account != null && option.id == MENU_COMPOSE) {
|
||||
final Context context = getContext();
|
||||
return context.getString(R.string.tweet_with_name,
|
||||
UserColorNameUtils.getDisplayName(context, -1, account.name, account.screen_name));
|
||||
}
|
||||
return super.getTitle(position, option);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class AppMenuAdapter extends OptionItemsAdapter {
|
||||
|
@ -774,11 +794,15 @@ public class AccountsDashboardFragment extends BaseSupportListFragment implement
|
|||
final OptionItem option = getItem(position);
|
||||
final TextView text1 = (TextView) view.findViewById(android.R.id.text1);
|
||||
final ImageView icon = (ImageView) view.findViewById(android.R.id.icon);
|
||||
text1.setText(option.name);
|
||||
text1.setText(getTitle(position, option));
|
||||
icon.setImageDrawable(ResourcesCompat.getDrawable(icon.getResources(), option.icon, null));
|
||||
icon.setColorFilter(mActionIconColor, Mode.SRC_ATOP);
|
||||
return view;
|
||||
}
|
||||
|
||||
protected String getTitle(int position, OptionItem option) {
|
||||
return getContext().getString(option.name);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -49,6 +49,7 @@ import android.support.v7.widget.RecyclerView.Adapter;
|
|||
import android.support.v7.widget.RecyclerView.LayoutParams;
|
||||
import android.support.v7.widget.RecyclerView.ViewHolder;
|
||||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuInflater;
|
||||
|
@ -780,7 +781,7 @@ public class StatusFragment extends BaseSupportFragment
|
|||
case VIEW_TYPE_DETAIL_STATUS: {
|
||||
final ParcelableStatus status = getStatus(position);
|
||||
final DetailStatusViewHolder detailHolder = (DetailStatusViewHolder) holder;
|
||||
detailHolder.showStatus(status);
|
||||
detailHolder.displayStatus(status);
|
||||
break;
|
||||
}
|
||||
case VIEW_TYPE_LIST_STATUS: {
|
||||
|
@ -1059,7 +1060,7 @@ public class StatusFragment extends BaseSupportFragment
|
|||
return Utils.handleMenuItemClick(activity, fragment, fm, twitter, status, item);
|
||||
}
|
||||
|
||||
public void showStatus(ParcelableStatus status) {
|
||||
public void displayStatus(ParcelableStatus status) {
|
||||
if (status == null) return;
|
||||
final StatusFragment fragment = adapter.getFragment();
|
||||
final Context context = adapter.getContext();
|
||||
|
@ -1104,7 +1105,18 @@ public class StatusFragment extends BaseSupportFragment
|
|||
}
|
||||
timeSourceView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
locationView.setVisibility(ParcelableLocation.isValidLocation(status.location) ? View.VISIBLE : View.GONE);
|
||||
if (!TextUtils.isEmpty(status.place_full_name)) {
|
||||
locationView.setVisibility(View.VISIBLE);
|
||||
locationView.setText(status.place_full_name);
|
||||
locationView.setClickable(ParcelableLocation.isValidLocation(status.location));
|
||||
} else if (ParcelableLocation.isValidLocation(status.location)) {
|
||||
locationView.setVisibility(View.VISIBLE);
|
||||
locationView.setText(R.string.view_map);
|
||||
locationView.setClickable(true);
|
||||
} else {
|
||||
locationView.setVisibility(View.GONE);
|
||||
locationView.setText(null);
|
||||
}
|
||||
|
||||
retweetsContainer.setVisibility(!status.user_is_protected ? View.VISIBLE : View.GONE);
|
||||
repliesContainer.setVisibility(status.reply_count < 0 ? View.GONE : View.VISIBLE);
|
||||
|
|
|
@ -3571,7 +3571,9 @@ public final class Utils implements Constants, TwitterConstants {
|
|||
final MenuItem translate = menu.findItem(MENU_TRANSLATE);
|
||||
if (translate != null) {
|
||||
final boolean isOfficialKey = isOfficialCredentials(context, account);
|
||||
setMenuItemAvailability(menu, MENU_TRANSLATE, isOfficialKey);
|
||||
final SharedPreferencesWrapper prefs = SharedPreferencesWrapper.getInstance(context, SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
final boolean forcePrivateApis = prefs.getBoolean(KEY_FORCE_USING_PRIVATE_APIS, false);
|
||||
setMenuItemAvailability(menu, MENU_TRANSLATE, forcePrivateApis || isOfficialKey);
|
||||
}
|
||||
menu.removeGroup(MENU_GROUP_STATUS_EXTENSION);
|
||||
addIntentToMenuForExtension(context, menu, MENU_GROUP_STATUS_EXTENSION, INTENT_ACTION_EXTENSION_OPEN_STATUS,
|
||||
|
|
|
@ -230,7 +230,7 @@ public class StatusViewHolder extends RecyclerView.ViewHolder implements Constan
|
|||
favoriteCountView.setText(null);
|
||||
}
|
||||
if (shouldDisplayExtraType) {
|
||||
displayExtraTypeIcon(status.card_name, status.media, status.location);
|
||||
displayExtraTypeIcon(status.card_name, status.media, status.location, status.place_full_name);
|
||||
} else {
|
||||
extraTypeView.setVisibility(View.GONE);
|
||||
}
|
||||
|
@ -267,6 +267,7 @@ public class StatusViewHolder extends RecyclerView.ViewHolder implements Constan
|
|||
final String in_reply_to_name = cursor.getString(indices.in_reply_to_user_name);
|
||||
final String in_reply_to_screen_name = cursor.getString(indices.in_reply_to_user_screen_name);
|
||||
final String card_name = cursor.getString(indices.card_name);
|
||||
final String place_full_name = cursor.getString(indices.place_full_name);
|
||||
|
||||
final ParcelableMedia[] media = SimpleValueSerializer.fromSerializedString(
|
||||
cursor.getString(indices.media), ParcelableMedia.SIMPLE_CREATOR);
|
||||
|
@ -374,7 +375,7 @@ public class StatusViewHolder extends RecyclerView.ViewHolder implements Constan
|
|||
} else {
|
||||
favoriteCountView.setText(null);
|
||||
}
|
||||
displayExtraTypeIcon(card_name, media, location);
|
||||
displayExtraTypeIcon(card_name, media, location, place_full_name);
|
||||
}
|
||||
|
||||
public CardView getCardView() {
|
||||
|
@ -454,7 +455,7 @@ public class StatusViewHolder extends RecyclerView.ViewHolder implements Constan
|
|||
mediaPreviewContainer.setStyle(adapter.getMediaPreviewStyle());
|
||||
}
|
||||
|
||||
private void displayExtraTypeIcon(String cardName, ParcelableMedia[] media, ParcelableLocation location) {
|
||||
private void displayExtraTypeIcon(String cardName, ParcelableMedia[] media, ParcelableLocation location, String placeFullName) {
|
||||
if (TwitterCardUtils.CARD_NAME_AUDIO.equals(cardName)) {
|
||||
extraTypeView.setImageResource(R.drawable.ic_action_music);
|
||||
extraTypeView.setVisibility(View.VISIBLE);
|
||||
|
|
|
@ -733,6 +733,7 @@
|
|||
<string name="user_type_verified">Verified</string>
|
||||
<string name="user_type_protected">Protected</string>
|
||||
<string name="tweet_hashtag">Tweet #<xliff:g id="text">%1$s</xliff:g></string>
|
||||
<string name="tweet_with_name">Tweet with<xliff:g id="text">%1$s</xliff:g></string>
|
||||
|
||||
|
||||
</resources>
|
Loading…
Reference in New Issue