modified profile layout, fixed crash, bug fix

This commit is contained in:
nuclearfog 2020-04-29 02:39:52 +02:00
parent 3f317b2312
commit 65fd98fd79
No known key found for this signature in database
GPG Key ID: ED35E22099354A64
5 changed files with 54 additions and 47 deletions

View File

@ -71,8 +71,9 @@ public class UserProfile extends AppCompatActivity implements OnClickListener,
OnTouchListener, OnTagClickListener, OnTabSelectedListener {
public static final String KEY_PROFILE_ID = "profile_uid";
private static final int REQUEST_PROFILE_CHANGED = 1;
public static final int RETURN_PROFILE_CHANGED = 2;
private static final int REQUEST_PROFILE_CHANGED = 1;
private static final int TRANSPARENCY = 0xafffffff;
private ProfileLoader profileAsync;
private FragmentAdapter adapter;
@ -130,6 +131,9 @@ public class UserProfile extends AppCompatActivity implements OnClickListener,
getSupportActionBar().setDisplayShowTitleEnabled(false);
FontTool.setViewFontAndColor(settings, root);
txtUser.setBackgroundColor(settings.getBackgroundColor() & TRANSPARENCY);
txtScrName.setBackgroundColor(settings.getBackgroundColor() & TRANSPARENCY);
follow_back.setBackgroundColor(settings.getBackgroundColor() & TRANSPARENCY);
bioTxt.setMovementMethod(LinkMovementMethod.getInstance());
tab.setSelectedTabIndicatorColor(settings.getHighlightColor());
bioTxt.setLinkTextColor(settings.getHighlightColor());
@ -431,6 +435,7 @@ public class UserProfile extends AppCompatActivity implements OnClickListener,
image.putExtra(KEY_MEDIA_TYPE, MEDIAVIEWER_IMAGE);
startActivity(image);
}
break;
case R.id.profile_banner:
if (user != null) {

View File

@ -121,23 +121,24 @@ public class Tweet {
public Tweet(long tweetID, int retweetCount, int favoriteCount, TwitterUser user, String tweet, long time,
String replyName, long replyUserId, String[] medias, String source, long replyID,
Tweet embedded, long myRetweetId, boolean retweeted, boolean favored, String place, String geo) {
this.tweetID = tweetID;
this.user = user;
this.retweetCount = retweetCount;
this.favoriteCount = favoriteCount;
this.tweet = tweet;
this.time = time;
this.replyID = replyID;
this.embedded = embedded;
this.replyName = replyName;
this.medias = medias;
this.source = source;
this.retweeted = retweeted;
this.favored = favored;
this.myRetweetId = myRetweetId;
this.replyUserId = replyUserId;
this.locationName = place;
this.locationCoordinates = geo;
this.tweet = tweet != null ? tweet : "";
this.source = source != null ? source : "";
this.replyName = replyName != null ? replyName : "";
this.locationName = place != null ? place : "";
this.locationCoordinates = geo != null ? geo : "";
}
/**

View File

@ -30,23 +30,37 @@ public class TwitterUser {
private final String bannerImg;
public TwitterUser(User user) {
userID = user.getId();
username = "" + user.getName();
screenname = '@' + user.getScreenName();
link = "" + user.getURLEntity().getExpandedURL();
location = "" + user.getLocation();
bio = getBio(user);
String profileLink = user.getOriginalProfileImageURLHttps();
String username = user.getName();
String screenname = user.getScreenName();
String link = user.getURLEntity().getExpandedURL();
String location = user.getLocation();
String profileImg = user.getOriginalProfileImageURLHttps();
String bannerLink = user.getProfileBannerURL();
if (profileLink != null)
profileImg = user.getOriginalProfileImageURLHttps();
else
profileImg = "";
String bio = user.getDescription();
this.username = username != null ? username : "";
this.screenname = screenname != null ? '@' + user.getScreenName() : "";
this.link = link != null ? link : "";
this.location = location != null ? location : "";
this.profileImg = profileImg != null ? profileImg : "";
if (bio != null && !bio.isEmpty()) {
URLEntity[] entities = user.getDescriptionURLEntities();
StringBuilder bioBuilder = new StringBuilder(user.getDescription());
for (int i = entities.length - 1; i >= 0; i--) {
URLEntity entity = entities[i];
bioBuilder.replace(entity.getStart(), entity.getEnd(), entity.getExpandedURL());
}
this.bio = bioBuilder.toString();
} else {
this.bio = "";
}
if (bannerLink != null && bannerLink.length() > 4)
bannerImg = bannerLink.substring(0, bannerLink.length() - 4);
else
bannerImg = "";
userID = user.getId();
isVerified = user.isVerified();
isLocked = user.isProtected();
created = user.getCreatedAt().getTime();
@ -62,13 +76,13 @@ public class TwitterUser {
long created, int following, int follower, int tweetCount, int favorCount) {
this.userID = userID;
this.username = username;
this.screenname = screenname;
this.profileImg = profileImg;
this.bio = bio;
this.link = link;
this.location = location;
this.bannerImg = bannerImg;
this.username = username != null ? username : "";
this.screenname = screenname != null ? screenname : "";
this.profileImg = profileImg != null ? profileImg : "";
this.bio = bio != null ? bio : "";
this.link = link != null ? link : "";
this.location = location != null ? location : "";
this.bannerImg = bannerImg != null ? bannerImg : "";
this.isVerified = isVerified;
this.isLocked = isLocked;
this.created = created;
@ -225,21 +239,6 @@ public class TwitterUser {
return !bannerImg.isEmpty();
}
/**
* Resolve shortened links from user description
* @param user Twitter user
* @return Description String
*/
private String getBio(User user) {
URLEntity[] entities = user.getDescriptionURLEntities();
StringBuilder bio = new StringBuilder("" + user.getDescription());
for (int i = entities.length - 1; i >= 0; i--) {
URLEntity entity = entities[i];
bio.replace(entity.getStart(), entity.getEnd(), entity.getExpandedURL());
}
return bio.toString();
}
@NonNull
@Override
public String toString() {

View File

@ -77,9 +77,10 @@
<TextView
android:id="@+id/profile_username"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawablePadding="@dimen/padding_drawable"
android:padding="@dimen/profile_tv_padding"
android:singleLine="true" />
<LinearLayout
@ -89,20 +90,20 @@
<TextView
android:id="@+id/profile_screenname"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/text_padding"
android:layout_marginRight="@dimen/text_padding"
android:layout_weight="2"
android:drawablePadding="@dimen/padding_drawable"
android:padding="@dimen/profile_tv_padding"
android:singleLine="true" />
<TextView
android:id="@+id/follow_back"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawablePadding="@dimen/padding_drawable"
android:padding="@dimen/profile_tv_padding"
android:singleLine="true"
android:text="@string/follows_you"
android:visibility="invisible"

View File

@ -67,7 +67,8 @@
<dimen name="edittext_background_padding">5dp</dimen>
<dimen name="settings_edittext_margin">1dp</dimen>
<dimen name="button_edge">1dp</dimen>
<dimen name="profile_banner_height">155dp</dimen>
<dimen name="profile_banner_height">140dp</dimen>
<dimen name="profile_tv_margin">2dp</dimen>
<dimen name="profile_banner_padding">40dp</dimen>
<dimen name="profile_banner_padding">5dp</dimen>
<dimen name="profile_tv_padding">2dp</dimen>
</resources>