mirror of
https://github.com/nuclearfog/Shitter.git
synced 2025-02-07 15:48:39 +01:00
bug fix, removed option for high res images, code cleanup
This commit is contained in:
parent
50e7b3c52d
commit
c1872f8e34
@ -14,6 +14,7 @@ import androidx.cardview.widget.CardView;
|
||||
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
|
||||
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.squareup.picasso.Transformation;
|
||||
|
||||
import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.backend.utils.AppStyles;
|
||||
@ -89,14 +90,10 @@ public class AccountHolder extends ViewHolder implements OnClickListener {
|
||||
username.setText(user.getUsername());
|
||||
screenname.setText(user.getScreenname());
|
||||
// set profile image
|
||||
if (settings.imagesEnabled() && !user.getProfileUrl().isEmpty()) {
|
||||
String profileImageUrl;
|
||||
if (!user.hasDefaultProfileImage() && account.getApiType() == Account.API_TWITTER) {
|
||||
profileImageUrl = StringTools.buildImageLink(user.getImageUrl(), settings.getImageSuffix());
|
||||
} else {
|
||||
profileImageUrl = user.getImageUrl();
|
||||
}
|
||||
picasso.load(profileImageUrl).transform(new RoundedCornersTransformation(2, 0)).error(R.drawable.no_image).into(profile);
|
||||
String profileImageUrl = user.getProfileImageThumbnailUrl();
|
||||
if (settings.imagesEnabled() && !profileImageUrl.isEmpty()) {
|
||||
Transformation roundCorner = new RoundedCornersTransformation(2, 0);
|
||||
picasso.load(profileImageUrl).transform(roundCorner).error(R.drawable.no_image).into(profile);
|
||||
} else {
|
||||
profile.setImageResource(0);
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import androidx.cardview.widget.CardView;
|
||||
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
|
||||
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.squareup.picasso.Transformation;
|
||||
|
||||
import org.nuclearfog.tag.Tagger;
|
||||
import org.nuclearfog.tag.Tagger.OnTagClickListener;
|
||||
@ -140,14 +141,10 @@ public class MessageHolder extends ViewHolder implements OnClickListener, OnTagC
|
||||
} else {
|
||||
mediaButton.setVisibility(View.GONE);
|
||||
}
|
||||
if (settings.imagesEnabled() && !sender.getImageUrl().isEmpty()) {
|
||||
String profileImageUrl;
|
||||
if (!sender.hasDefaultProfileImage()) {
|
||||
profileImageUrl = StringTools.buildImageLink(sender.getImageUrl(), settings.getImageSuffix());
|
||||
} else {
|
||||
profileImageUrl = sender.getImageUrl();
|
||||
}
|
||||
picasso.load(profileImageUrl).transform(new RoundedCornersTransformation(2, 0)).error(R.drawable.no_image).into(profile);
|
||||
String profileImageUrl = sender.getProfileImageThumbnailUrl();
|
||||
if (settings.imagesEnabled() && !profileImageUrl.isEmpty()) {
|
||||
Transformation roundCorner = new RoundedCornersTransformation(2, 0);
|
||||
picasso.load(profileImageUrl).transform(roundCorner).error(R.drawable.no_image).into(profile);
|
||||
} else {
|
||||
profile.setImageResource(0);
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import androidx.cardview.widget.CardView;
|
||||
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
|
||||
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.squareup.picasso.Transformation;
|
||||
|
||||
import org.nuclearfog.tag.Tagger;
|
||||
import org.nuclearfog.twidda.R;
|
||||
@ -152,14 +153,10 @@ public class StatusHolder extends ViewHolder implements OnClickListener {
|
||||
} else {
|
||||
lockedIcon.setVisibility(View.GONE);
|
||||
}
|
||||
if (settings.imagesEnabled() && !user.getImageUrl().isEmpty()) {
|
||||
String profileImageUrl;
|
||||
if (!user.hasDefaultProfileImage()) {
|
||||
profileImageUrl = StringTools.buildImageLink(user.getImageUrl(), settings.getImageSuffix());
|
||||
} else {
|
||||
profileImageUrl = user.getImageUrl();
|
||||
}
|
||||
picasso.load(profileImageUrl).transform(new RoundedCornersTransformation(2, 0)).error(R.drawable.no_image).into(profile);
|
||||
String profileImageUrl = user.getProfileImageThumbnailUrl();
|
||||
if (settings.imagesEnabled() && !profileImageUrl.isEmpty()) {
|
||||
Transformation roundCorner = new RoundedCornersTransformation(2, 0);
|
||||
picasso.load(profileImageUrl).transform(roundCorner).error(R.drawable.no_image).into(profile);
|
||||
} else {
|
||||
profile.setImageResource(0);
|
||||
}
|
||||
|
@ -17,10 +17,10 @@ import androidx.cardview.widget.CardView;
|
||||
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
|
||||
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.squareup.picasso.Transformation;
|
||||
|
||||
import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.backend.utils.AppStyles;
|
||||
import org.nuclearfog.twidda.backend.utils.StringTools;
|
||||
import org.nuclearfog.twidda.database.GlobalSettings;
|
||||
import org.nuclearfog.twidda.model.Notification;
|
||||
import org.nuclearfog.twidda.model.User;
|
||||
@ -117,14 +117,10 @@ public class UserHolder extends ViewHolder implements OnClickListener {
|
||||
} else {
|
||||
lockedIcon.setVisibility(GONE);
|
||||
}
|
||||
if (settings.imagesEnabled() && !user.getImageUrl().isEmpty()) {
|
||||
String profileImageUrl;
|
||||
if (!user.hasDefaultProfileImage()) {
|
||||
profileImageUrl = StringTools.buildImageLink(user.getImageUrl(), settings.getImageSuffix());
|
||||
} else {
|
||||
profileImageUrl = user.getImageUrl();
|
||||
}
|
||||
picasso.load(profileImageUrl).transform(new RoundedCornersTransformation(2, 0)).error(R.drawable.no_image).into(profileImg);
|
||||
String profileImageUrl = user.getProfileImageThumbnailUrl();
|
||||
if (settings.imagesEnabled() && !profileImageUrl.isEmpty()) {
|
||||
Transformation roundCorner = new RoundedCornersTransformation(2, 0);
|
||||
picasso.load(profileImageUrl).transform(roundCorner).error(R.drawable.no_image).into(profileImg);
|
||||
} else {
|
||||
profileImg.setImageResource(0);
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import androidx.cardview.widget.CardView;
|
||||
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
|
||||
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.squareup.picasso.Transformation;
|
||||
|
||||
import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.backend.utils.AppStyles;
|
||||
@ -99,14 +100,10 @@ public class UserlistHolder extends ViewHolder implements OnClickListener {
|
||||
date.setText(StringTools.formatCreationTime(itemView.getResources(), userlist.getTimestamp()));
|
||||
member.setText(NUM_FORMAT.format(userlist.getMemberCount()));
|
||||
subscriber.setText(NUM_FORMAT.format(userlist.getSubscriberCount()));
|
||||
if (settings.imagesEnabled() && !owner.getImageUrl().isEmpty()) {
|
||||
String profileImageUrl;
|
||||
if (!owner.hasDefaultProfileImage()) {
|
||||
profileImageUrl = StringTools.buildImageLink(owner.getImageUrl(), settings.getImageSuffix());
|
||||
} else {
|
||||
profileImageUrl = owner.getImageUrl();
|
||||
}
|
||||
picasso.load(profileImageUrl).transform(new RoundedCornersTransformation(3, 0)).error(R.drawable.no_image).into(profile);
|
||||
String profileImageUrl = owner.getProfileImageThumbnailUrl();
|
||||
if (settings.imagesEnabled() && !profileImageUrl.isEmpty()) {
|
||||
Transformation roundCorner = new RoundedCornersTransformation(3, 0);
|
||||
picasso.load(profileImageUrl).transform(roundCorner).error(R.drawable.no_image).into(profile);
|
||||
} else {
|
||||
profile.setImageResource(0);
|
||||
}
|
||||
|
@ -92,13 +92,25 @@ public class MastodonUser implements User {
|
||||
|
||||
|
||||
@Override
|
||||
public String getImageUrl() {
|
||||
public String getOriginalProfileImageUrl() {
|
||||
return profileUrl;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getBannerUrl() {
|
||||
public String getProfileImageThumbnailUrl() {
|
||||
return profileUrl;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getOriginalBannerImageUrl() {
|
||||
return bannerUrl;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getBannerImageThumbnailUrl() {
|
||||
return bannerUrl;
|
||||
}
|
||||
|
||||
|
@ -82,96 +82,133 @@ public class UserV1 implements User {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getScreenname() {
|
||||
return screenName;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long getCreatedAt() {
|
||||
return created;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getImageUrl() {
|
||||
public String getOriginalProfileImageUrl() {
|
||||
return profileImageUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBannerUrl() {
|
||||
return profileBannerUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return description;
|
||||
public String getProfileImageThumbnailUrl() {
|
||||
if (defaultImage || profileImageUrl.isEmpty())
|
||||
return profileImageUrl;
|
||||
return profileImageUrl + "_bigger";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProfileUrl() {
|
||||
return url;
|
||||
public String getOriginalBannerImageUrl() {
|
||||
if (profileBannerUrl.isEmpty())
|
||||
return "";
|
||||
return profileBannerUrl + "/1500x500";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVerified() {
|
||||
return isVerified;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isProtected() {
|
||||
return isLocked;
|
||||
public String getBannerImageThumbnailUrl() {
|
||||
if (profileBannerUrl.isEmpty())
|
||||
return "";
|
||||
return profileBannerUrl + "/600x200";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean followRequested() {
|
||||
return followReqSent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFollowing() {
|
||||
return following;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFollower() {
|
||||
return follower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatusCount() {
|
||||
return tweetCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFavoriteCount() {
|
||||
return favoriteCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDefaultProfileImage() {
|
||||
return defaultImage;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getProfileUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isVerified() {
|
||||
return isVerified;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isProtected() {
|
||||
return isLocked;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean followRequested() {
|
||||
return followReqSent;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getFollowing() {
|
||||
return following;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getFollower() {
|
||||
return follower;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getStatusCount() {
|
||||
return tweetCount;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getFavoriteCount() {
|
||||
return favoriteCount;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isCurrentUser() {
|
||||
return isCurrentUser;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (!(obj instanceof User))
|
||||
@ -179,6 +216,7 @@ public class UserV1 implements User {
|
||||
return ((User) obj).getId() == id;
|
||||
}
|
||||
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -79,98 +79,135 @@ public class UserV2 implements User {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getScreenname() {
|
||||
return screenName;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long getCreatedAt() {
|
||||
return created;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getImageUrl() {
|
||||
public String getOriginalProfileImageUrl() {
|
||||
return profileImageUrl;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getBannerUrl() {
|
||||
return profileBannerUrl;
|
||||
public String getProfileImageThumbnailUrl() {
|
||||
if (defaultImage || profileImageUrl.isEmpty())
|
||||
return profileImageUrl;
|
||||
return profileImageUrl + "_bigger";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getOriginalBannerImageUrl() {
|
||||
if (profileBannerUrl.isEmpty())
|
||||
return "";
|
||||
return profileBannerUrl + "/1500x500";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getBannerImageThumbnailUrl() {
|
||||
if (profileBannerUrl.isEmpty())
|
||||
return "";
|
||||
return profileBannerUrl + "/600x200";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasDefaultProfileImage() {
|
||||
return defaultImage;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getProfileUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isVerified() {
|
||||
return isVerified;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isProtected() {
|
||||
return isProtected;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean followRequested() {
|
||||
// todo not yet implemented in API V2
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getFollowing() {
|
||||
return following;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getFollower() {
|
||||
return follower;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getStatusCount() {
|
||||
return tweetCount;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getFavoriteCount() {
|
||||
// todo not yet implemented in API V2
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDefaultProfileImage() {
|
||||
return defaultImage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCurrentUser() {
|
||||
return isCurrentUser;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (!(obj instanceof User))
|
||||
@ -178,12 +215,14 @@ public class UserV2 implements User {
|
||||
return ((User) obj).getId() == id;
|
||||
}
|
||||
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return "name=\"" + screenName + "\"";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* expand URLs of the user description
|
||||
*
|
||||
|
@ -243,25 +243,6 @@ public final class StringTools {
|
||||
return offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* append resolution string to image link
|
||||
*
|
||||
* @param link link to image
|
||||
* @param resolution resolution string to append
|
||||
* @return image string with resolution information
|
||||
*/
|
||||
public static String buildImageLink(String link, String resolution) {
|
||||
int lastSeg = link.lastIndexOf('/');
|
||||
if (lastSeg >= 0) {
|
||||
int pos = link.indexOf('.', lastSeg);
|
||||
if (pos > 0) {
|
||||
String ext = link.substring(pos);
|
||||
return link.substring(0, pos) + resolution + ext;
|
||||
}
|
||||
}
|
||||
return link;
|
||||
}
|
||||
|
||||
/**
|
||||
* get current timestamp in seconds
|
||||
*
|
||||
|
@ -25,6 +25,7 @@ import org.nuclearfog.twidda.database.impl.NotificationImpl;
|
||||
import org.nuclearfog.twidda.database.impl.StatusImpl;
|
||||
import org.nuclearfog.twidda.database.impl.TrendImpl;
|
||||
import org.nuclearfog.twidda.database.impl.UserImpl;
|
||||
import org.nuclearfog.twidda.model.Account;
|
||||
import org.nuclearfog.twidda.model.Message;
|
||||
import org.nuclearfog.twidda.model.Notification;
|
||||
import org.nuclearfog.twidda.model.Status;
|
||||
@ -568,14 +569,14 @@ public class AppDatabase {
|
||||
* @return notification lsit
|
||||
*/
|
||||
public List<Notification> getNotifications() {
|
||||
long currentId = settings.getLogin().getId();
|
||||
String[] args = {Long.toString(currentId), Integer.toString(settings.getListSize())};
|
||||
Account login = settings.getLogin();
|
||||
String[] args = {Long.toString(login.getId()), Integer.toString(settings.getListSize())};
|
||||
SQLiteDatabase db = getDbRead();
|
||||
List<Notification> result = new LinkedList<>();
|
||||
Cursor cursor = db.rawQuery(NOTIFICATION_QUERY, args);
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
NotificationImpl notification = new NotificationImpl(cursor, currentId);
|
||||
NotificationImpl notification = new NotificationImpl(cursor, login.getId(), login.getApiType());
|
||||
switch (notification.getType()) {
|
||||
case Notification.TYPE_FAVORITE:
|
||||
case Notification.TYPE_REPOST:
|
||||
@ -702,15 +703,15 @@ public class AppDatabase {
|
||||
* @return list of direct messages
|
||||
*/
|
||||
public Messages getMessages() {
|
||||
long currentId = settings.getLogin().getId();
|
||||
String homeIdStr = Long.toString(currentId);
|
||||
Account login = settings.getLogin();
|
||||
String homeIdStr = Long.toString(login.getId());
|
||||
String[] args = {homeIdStr, homeIdStr, Integer.toString(settings.getListSize())};
|
||||
Messages result = new Messages(null, null);
|
||||
SQLiteDatabase db = getDbRead();
|
||||
Cursor cursor = db.rawQuery(MESSAGE_QUERY, args);
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
result.add(new MessageImpl(cursor, currentId));
|
||||
result.add(new MessageImpl(cursor, login.getId(), login.getApiType()));
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
@ -802,7 +803,8 @@ public class AppDatabase {
|
||||
* @return status
|
||||
*/
|
||||
private Status getStatus(Cursor cursor) {
|
||||
StatusImpl result = new StatusImpl(cursor, settings.getLogin().getId());
|
||||
Account login = settings.getLogin();
|
||||
StatusImpl result = new StatusImpl(cursor, login.getId(), login.getApiType());
|
||||
// check if there is an embedded status
|
||||
if (result.getEmbeddedStatusId() > 1)
|
||||
result.setEmbeddedStatus(getStatus(result.getEmbeddedStatusId()));
|
||||
@ -818,7 +820,7 @@ public class AppDatabase {
|
||||
@Nullable
|
||||
private User getUser(Cursor cursor) {
|
||||
if (cursor.moveToFirst())
|
||||
return new UserImpl(cursor, settings.getLogin().getId());
|
||||
return new UserImpl(cursor, settings.getLogin().getId(), settings.getLogin().getApiType());
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -852,11 +854,11 @@ public class AppDatabase {
|
||||
userColumn.put(UserTable.ID, user.getId());
|
||||
userColumn.put(UserTable.USERNAME, user.getUsername());
|
||||
userColumn.put(UserTable.SCREENNAME, user.getScreenname());
|
||||
userColumn.put(UserTable.IMAGE, user.getImageUrl());
|
||||
userColumn.put(UserTable.IMAGE, user.getOriginalProfileImageUrl());
|
||||
userColumn.put(UserTable.DESCRIPTION, user.getDescription());
|
||||
userColumn.put(UserTable.LINK, user.getProfileUrl());
|
||||
userColumn.put(UserTable.LOCATION, user.getLocation());
|
||||
userColumn.put(UserTable.BANNER, user.getBannerUrl());
|
||||
userColumn.put(UserTable.BANNER, user.getOriginalBannerImageUrl());
|
||||
userColumn.put(UserTable.SINCE, user.getCreatedAt());
|
||||
userColumn.put(UserTable.FRIENDS, user.getFollowing());
|
||||
userColumn.put(UserTable.FOLLOWER, user.getFollower());
|
||||
@ -960,11 +962,11 @@ public class AppDatabase {
|
||||
ContentValues userUpdate = new ContentValues(9);
|
||||
userUpdate.put(UserTable.USERNAME, user.getUsername());
|
||||
userUpdate.put(UserTable.SCREENNAME, user.getScreenname());
|
||||
userUpdate.put(UserTable.IMAGE, user.getImageUrl());
|
||||
userUpdate.put(UserTable.IMAGE, user.getOriginalProfileImageUrl());
|
||||
userUpdate.put(UserTable.DESCRIPTION, user.getDescription());
|
||||
userUpdate.put(UserTable.LINK, user.getProfileUrl());
|
||||
userUpdate.put(UserTable.LOCATION, user.getLocation());
|
||||
userUpdate.put(UserTable.BANNER, user.getBannerUrl());
|
||||
userUpdate.put(UserTable.BANNER, user.getOriginalBannerImageUrl());
|
||||
userUpdate.put(UserTable.FRIENDS, user.getFollowing());
|
||||
userUpdate.put(UserTable.FOLLOWER, user.getFollower());
|
||||
|
||||
|
@ -31,26 +31,6 @@ import java.util.List;
|
||||
*/
|
||||
public class GlobalSettings {
|
||||
|
||||
/**
|
||||
* media link suffix used by Twitter for low resolution profile images
|
||||
*/
|
||||
public static final String PROFILE_IMG_LOW_RES = "_mini";
|
||||
|
||||
/**
|
||||
* media link suffix used by Twitter for high resolution profile images
|
||||
*/
|
||||
public static final String PROFILE_IMG_HIGH_RES = "_bigger";
|
||||
|
||||
/**
|
||||
* media link suffix used by Twitter for low resolution banner images
|
||||
*/
|
||||
public static final String BANNER_IMG_LOW_RES = "/300x100";
|
||||
|
||||
/**
|
||||
* media link suffix used by Twitter for standard banner image resolution
|
||||
*/
|
||||
public static final String BANNER_IMG_MID_RES = "/600x200";
|
||||
|
||||
/**
|
||||
* alternative Twitter service
|
||||
*/
|
||||
@ -525,53 +505,6 @@ public class GlobalSettings {
|
||||
edit.apply();
|
||||
}
|
||||
|
||||
/**
|
||||
* sets image quality
|
||||
*
|
||||
* @return true if thumbnails should be in high resolution
|
||||
*/
|
||||
public boolean getImageQuality() {
|
||||
return hqImages;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the twitter image suffix depending on the resolution
|
||||
*
|
||||
* @return suffix string
|
||||
*/
|
||||
public String getImageSuffix() {
|
||||
if (account.getApiType() == Account.API_MASTODON)
|
||||
return "";
|
||||
if (hqImages)
|
||||
return PROFILE_IMG_HIGH_RES;
|
||||
return PROFILE_IMG_LOW_RES;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the suffix for the banner image link
|
||||
*
|
||||
* @return suffix string
|
||||
*/
|
||||
public String getBannerSuffix() {
|
||||
if (account.getApiType() == Account.API_MASTODON)
|
||||
return "";
|
||||
if (hqImages)
|
||||
return BANNER_IMG_MID_RES;
|
||||
return BANNER_IMG_LOW_RES;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the image quality
|
||||
*
|
||||
* @param enable true if small thumbnails should be in high resolution
|
||||
*/
|
||||
public void setHighQualityImage(boolean enable) {
|
||||
hqImages = enable;
|
||||
Editor edit = settings.edit();
|
||||
edit.putBoolean(IMAGE_QUALITY, enable);
|
||||
edit.apply();
|
||||
}
|
||||
|
||||
/**
|
||||
* answer loading enabled
|
||||
*
|
||||
|
@ -28,8 +28,8 @@ public class MessageImpl implements Message {
|
||||
* @param cursor database cursor containing UserTable column
|
||||
* @param currentId Id of the current user
|
||||
*/
|
||||
public MessageImpl(Cursor cursor, long currentId) {
|
||||
sender = new UserImpl(cursor, currentId);
|
||||
public MessageImpl(Cursor cursor, long currentId, int apiType) {
|
||||
sender = new UserImpl(cursor, currentId, apiType);
|
||||
text = cursor.getString(cursor.getColumnIndexOrThrow(MessageTable.MESSAGE));
|
||||
time = cursor.getLong(cursor.getColumnIndexOrThrow(MessageTable.SINCE));
|
||||
id = cursor.getLong(cursor.getColumnIndexOrThrow(MessageTable.ID));
|
||||
|
@ -30,8 +30,8 @@ public class NotificationImpl implements Notification {
|
||||
* @param cursor database cursor containing Notification table column
|
||||
* @param currentId current user's ID
|
||||
*/
|
||||
public NotificationImpl(Cursor cursor, long currentId) {
|
||||
user = new UserImpl(cursor, currentId);
|
||||
public NotificationImpl(Cursor cursor, long currentId, int apiType) {
|
||||
user = new UserImpl(cursor, currentId, apiType);
|
||||
id = cursor.getLong(cursor.getColumnIndexOrThrow(NotificationTable.ID));
|
||||
itemId = cursor.getLong(cursor.getColumnIndexOrThrow(NotificationTable.ITEM));
|
||||
type = cursor.getInt(cursor.getColumnIndexOrThrow(NotificationTable.TYPE));
|
||||
|
@ -61,8 +61,8 @@ public class StatusImpl implements Status {
|
||||
* @param cursor database cursor
|
||||
* @param currentUserId user ID of the current login
|
||||
*/
|
||||
public StatusImpl(Cursor cursor, long currentUserId) {
|
||||
author = new UserImpl(cursor, currentUserId);
|
||||
public StatusImpl(Cursor cursor, long currentUserId, int apiType) {
|
||||
author = new UserImpl(cursor, currentUserId, apiType);
|
||||
time = cursor.getLong(cursor.getColumnIndexOrThrow(DatabaseAdapter.StatusTable.SINCE));
|
||||
text = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseAdapter.StatusTable.TEXT));
|
||||
repostCount = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseAdapter.StatusTable.REPOST));
|
||||
|
@ -12,6 +12,7 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import org.nuclearfog.twidda.database.DatabaseAdapter.UserRegisterTable;
|
||||
import org.nuclearfog.twidda.database.DatabaseAdapter.UserTable;
|
||||
import org.nuclearfog.twidda.model.Account;
|
||||
import org.nuclearfog.twidda.model.User;
|
||||
|
||||
/**
|
||||
@ -29,29 +30,34 @@ public class UserImpl implements User {
|
||||
private int follower;
|
||||
private int statusCount;
|
||||
private int favorCount;
|
||||
private int apiType;
|
||||
private String username;
|
||||
private String screenName;
|
||||
private String bio;
|
||||
private String location;
|
||||
private String link;
|
||||
private String profileImg;
|
||||
private String bannerImg;
|
||||
private String profileImageUrl;
|
||||
private String profileBannerUrl;
|
||||
private boolean isCurrentUser;
|
||||
private boolean isVerified;
|
||||
private boolean isLocked;
|
||||
private boolean followReqSent;
|
||||
private boolean defaultImage;
|
||||
|
||||
|
||||
public UserImpl(Cursor cursor, long currentUserId) {
|
||||
/**
|
||||
* @param cursor database cursor containing user column
|
||||
* @param currentUserId ID of the current user
|
||||
* @param apiType current used API type
|
||||
*/
|
||||
public UserImpl(Cursor cursor, long currentUserId, int apiType) {
|
||||
id = cursor.getLong(cursor.getColumnIndexOrThrow(UserTable.ID));
|
||||
username = cursor.getString(cursor.getColumnIndexOrThrow(UserTable.USERNAME));
|
||||
screenName = cursor.getString(cursor.getColumnIndexOrThrow(UserTable.SCREENNAME));
|
||||
profileImg = cursor.getString(cursor.getColumnIndexOrThrow(UserTable.IMAGE));
|
||||
profileImageUrl = cursor.getString(cursor.getColumnIndexOrThrow(UserTable.IMAGE));
|
||||
bio = cursor.getString(cursor.getColumnIndexOrThrow(UserTable.DESCRIPTION));
|
||||
link = cursor.getString(cursor.getColumnIndexOrThrow(UserTable.LINK));
|
||||
location = cursor.getString(cursor.getColumnIndexOrThrow(UserTable.LOCATION));
|
||||
bannerImg = cursor.getString(cursor.getColumnIndexOrThrow(UserTable.BANNER));
|
||||
profileBannerUrl = cursor.getString(cursor.getColumnIndexOrThrow(UserTable.BANNER));
|
||||
created = cursor.getLong(cursor.getColumnIndexOrThrow(UserTable.SINCE));
|
||||
following = cursor.getInt(cursor.getColumnIndexOrThrow(UserTable.FRIENDS));
|
||||
follower = cursor.getInt(cursor.getColumnIndexOrThrow(UserTable.FOLLOWER));
|
||||
@ -63,6 +69,7 @@ public class UserImpl implements User {
|
||||
followReqSent = (register & FOLLOW_REQUEST_MASK) != 0;
|
||||
defaultImage = (register & DEFAULT_IMAGE_MASK) != 0;
|
||||
isCurrentUser = currentUserId == id;
|
||||
this.apiType = apiType;
|
||||
}
|
||||
|
||||
|
||||
@ -71,91 +78,127 @@ public class UserImpl implements User {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getScreenname() {
|
||||
return screenName;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long getCreatedAt() {
|
||||
return created;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getImageUrl() {
|
||||
return profileImg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBannerUrl() {
|
||||
return bannerImg;
|
||||
public String getOriginalProfileImageUrl() {
|
||||
return profileImageUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return bio;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocation() {
|
||||
return location;
|
||||
public String getProfileImageThumbnailUrl() {
|
||||
if (apiType != Account.API_TWITTER || defaultImage || profileImageUrl.isEmpty())
|
||||
return profileImageUrl;
|
||||
return profileImageUrl + "_bigger";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProfileUrl() {
|
||||
return link;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVerified() {
|
||||
return isVerified;
|
||||
public String getOriginalBannerImageUrl() {
|
||||
if (apiType != Account.API_TWITTER || profileBannerUrl.isEmpty())
|
||||
return profileBannerUrl;
|
||||
return profileBannerUrl + "/1500x500";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isProtected() {
|
||||
return isLocked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean followRequested() {
|
||||
return followReqSent;
|
||||
public String getBannerImageThumbnailUrl() {
|
||||
if (apiType != Account.API_TWITTER || profileBannerUrl.isEmpty())
|
||||
return profileBannerUrl;
|
||||
return profileBannerUrl + "/600x200";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFollowing() {
|
||||
return following;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFollower() {
|
||||
return follower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatusCount() {
|
||||
return statusCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFavoriteCount() {
|
||||
return favorCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDefaultProfileImage() {
|
||||
return defaultImage;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return bio;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getProfileUrl() {
|
||||
return link;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isVerified() {
|
||||
return isVerified;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isProtected() {
|
||||
return isLocked;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean followRequested() {
|
||||
return followReqSent;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getFollowing() {
|
||||
return following;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getFollower() {
|
||||
return follower;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getStatusCount() {
|
||||
return statusCount;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getFavoriteCount() {
|
||||
return favorCount;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isCurrentUser() {
|
||||
return isCurrentUser;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (!(obj instanceof User))
|
||||
@ -163,9 +206,10 @@ public class UserImpl implements User {
|
||||
return ((User) obj).getId() == id;
|
||||
}
|
||||
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return "name=\"" + screenName + "\"";
|
||||
}
|
||||
}
|
||||
}
|
@ -32,12 +32,27 @@ public interface User extends Serializable {
|
||||
/**
|
||||
* @return profile image url
|
||||
*/
|
||||
String getImageUrl();
|
||||
String getOriginalProfileImageUrl();
|
||||
|
||||
/**
|
||||
* @return profile banner url
|
||||
* @return small profile image url
|
||||
*/
|
||||
String getBannerUrl();
|
||||
String getProfileImageThumbnailUrl();
|
||||
|
||||
/**
|
||||
* @return profile banner url in the highest available resolution
|
||||
*/
|
||||
String getOriginalBannerImageUrl();
|
||||
|
||||
/**
|
||||
* @return small banner image url
|
||||
*/
|
||||
String getBannerImageThumbnailUrl();
|
||||
|
||||
/**
|
||||
* @return true if user has a default profile image
|
||||
*/
|
||||
boolean hasDefaultProfileImage();
|
||||
|
||||
/**
|
||||
* @return profile description (bio)
|
||||
@ -89,11 +104,6 @@ public interface User extends Serializable {
|
||||
*/
|
||||
int getFavoriteCount();
|
||||
|
||||
/**
|
||||
* @return true if user has a default profile image
|
||||
*/
|
||||
boolean hasDefaultProfileImage();
|
||||
|
||||
/**
|
||||
* @return true if the user is the same as the current user
|
||||
*/
|
||||
|
@ -24,6 +24,7 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout.OnRefreshListener;
|
||||
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.squareup.picasso.Transformation;
|
||||
|
||||
import org.nuclearfog.tag.Tagger;
|
||||
import org.nuclearfog.tag.Tagger.OnTagClickListener;
|
||||
@ -130,12 +131,10 @@ public class MetricsActivity extends AppCompatActivity implements OnClickListene
|
||||
if (data instanceof Status) {
|
||||
status = (Status) data;
|
||||
User author = status.getAuthor();
|
||||
if (settings.imagesEnabled() && !author.getImageUrl().isEmpty()) {
|
||||
String profileImageUrl = author.getImageUrl();
|
||||
if (!author.hasDefaultProfileImage())
|
||||
profileImageUrl += settings.getImageSuffix();
|
||||
picasso.load(profileImageUrl).transform(new RoundedCornersTransformation(4, 0))
|
||||
.error(R.drawable.no_image).into(profile);
|
||||
String profileImageUrl = author.getProfileImageThumbnailUrl();
|
||||
if (settings.imagesEnabled() && !profileImageUrl.isEmpty()) {
|
||||
Transformation roundCorner = new RoundedCornersTransformation(4, 0);
|
||||
picasso.load(profileImageUrl).transform(roundCorner).error(R.drawable.no_image).into(profile);
|
||||
} else {
|
||||
profile.setImageResource(0);
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import static android.view.View.GONE;
|
||||
import static android.view.View.OnClickListener;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
import static org.nuclearfog.twidda.database.GlobalSettings.PROFILE_IMG_HIGH_RES;
|
||||
import static org.nuclearfog.twidda.ui.activities.MessageEditor.KEY_DM_PREFIX;
|
||||
import static org.nuclearfog.twidda.ui.activities.SearchActivity.KEY_SEARCH_QUERY;
|
||||
import static org.nuclearfog.twidda.ui.activities.StatusActivity.KEY_STATUS_ID;
|
||||
@ -49,6 +48,7 @@ import com.google.android.material.tabs.TabLayout.OnTabSelectedListener;
|
||||
import com.google.android.material.tabs.TabLayout.Tab;
|
||||
import com.squareup.picasso.Callback;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.squareup.picasso.Transformation;
|
||||
|
||||
import org.nuclearfog.tag.Tagger;
|
||||
import org.nuclearfog.tag.Tagger.OnTagClickListener;
|
||||
@ -60,9 +60,7 @@ import org.nuclearfog.twidda.backend.async.UserAction;
|
||||
import org.nuclearfog.twidda.backend.utils.AppStyles;
|
||||
import org.nuclearfog.twidda.backend.utils.ErrorHandler;
|
||||
import org.nuclearfog.twidda.backend.utils.PicassoBuilder;
|
||||
import org.nuclearfog.twidda.backend.utils.StringTools;
|
||||
import org.nuclearfog.twidda.database.GlobalSettings;
|
||||
import org.nuclearfog.twidda.model.Account;
|
||||
import org.nuclearfog.twidda.model.Relation;
|
||||
import org.nuclearfog.twidda.model.User;
|
||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog;
|
||||
@ -497,8 +495,8 @@ public class ProfileActivity extends AppCompatActivity implements OnClickListene
|
||||
}
|
||||
// open profile image
|
||||
else if (v.getId() == R.id.profile_img) {
|
||||
if (user != null && !user.getImageUrl().isEmpty()) {
|
||||
Uri[] uris = {Uri.parse(user.getImageUrl())};
|
||||
if (user != null && !user.getOriginalProfileImageUrl().isEmpty()) {
|
||||
Uri[] uris = {Uri.parse(user.getOriginalProfileImageUrl())};
|
||||
Intent imageIntent = new Intent(this, ImageViewer.class);
|
||||
imageIntent.putExtra(ImageViewer.IMAGE_URIS, uris);
|
||||
imageIntent.putExtra(ImageViewer.IMAGE_DOWNLOAD, true);
|
||||
@ -507,8 +505,8 @@ public class ProfileActivity extends AppCompatActivity implements OnClickListene
|
||||
}
|
||||
// open banner image
|
||||
else if (v.getId() == R.id.profile_banner) {
|
||||
if (user != null && !user.getBannerUrl().isEmpty()) {
|
||||
Uri[] uris = {Uri.parse(user.getBannerUrl())};
|
||||
if (user != null && !user.getOriginalBannerImageUrl().isEmpty()) {
|
||||
Uri[] uris = {Uri.parse(user.getOriginalBannerImageUrl())};
|
||||
Intent imageIntent = new Intent(this, ImageViewer.class);
|
||||
imageIntent.putExtra(ImageViewer.IMAGE_URIS, uris);
|
||||
imageIntent.putExtra(ImageViewer.IMAGE_DOWNLOAD, true);
|
||||
@ -635,21 +633,17 @@ public class ProfileActivity extends AppCompatActivity implements OnClickListene
|
||||
user_website.setVisibility(GONE);
|
||||
}
|
||||
if (settings.imagesEnabled()) {
|
||||
if (!user.getBannerUrl().isEmpty()) {
|
||||
String bannerLink = user.getBannerUrl() + settings.getBannerSuffix();
|
||||
picasso.load(bannerLink).error(R.drawable.no_banner).into(bannerImage, this);
|
||||
String profileImageUrl = user.getBannerImageThumbnailUrl();
|
||||
String bannerImageUrl = user.getProfileImageThumbnailUrl();
|
||||
if (!profileImageUrl.isEmpty()) {
|
||||
picasso.load(profileImageUrl).error(R.drawable.no_banner).into(bannerImage, this);
|
||||
} else {
|
||||
bannerImage.setImageResource(0);
|
||||
toolbarBackground.setImageResource(0);
|
||||
}
|
||||
if (!user.getImageUrl().isEmpty()) {
|
||||
String profileImageUrl;
|
||||
if (!user.hasDefaultProfileImage() && settings.getLogin().getApiType() == Account.API_TWITTER) {
|
||||
profileImageUrl = StringTools.buildImageLink(user.getImageUrl(), PROFILE_IMG_HIGH_RES);
|
||||
} else {
|
||||
profileImageUrl = user.getImageUrl();
|
||||
}
|
||||
picasso.load(profileImageUrl).transform(new RoundedCornersTransformation(5, 0)).error(R.drawable.no_image).into(profileImage);
|
||||
if (!bannerImageUrl.isEmpty()) {
|
||||
Transformation roundCorner = new RoundedCornersTransformation(5, 0);
|
||||
picasso.load(bannerImageUrl).transform(roundCorner).error(R.drawable.no_image).into(profileImage);
|
||||
} else {
|
||||
profileImage.setImageResource(0);
|
||||
}
|
||||
|
@ -3,8 +3,6 @@ package org.nuclearfog.twidda.ui.activities;
|
||||
import static android.os.AsyncTask.Status.RUNNING;
|
||||
import static android.view.View.INVISIBLE;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static org.nuclearfog.twidda.database.GlobalSettings.BANNER_IMG_MID_RES;
|
||||
import static org.nuclearfog.twidda.database.GlobalSettings.PROFILE_IMG_HIGH_RES;
|
||||
import static org.nuclearfog.twidda.ui.activities.ProfileActivity.TOOLBAR_TRANSPARENCY;
|
||||
|
||||
import android.content.Context;
|
||||
@ -32,6 +30,7 @@ import androidx.constraintlayout.widget.ConstraintSet;
|
||||
|
||||
import com.squareup.picasso.Callback;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.squareup.picasso.Transformation;
|
||||
|
||||
import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.backend.api.ConnectionException;
|
||||
@ -40,7 +39,6 @@ import org.nuclearfog.twidda.backend.update.ProfileUpdate;
|
||||
import org.nuclearfog.twidda.backend.utils.AppStyles;
|
||||
import org.nuclearfog.twidda.backend.utils.ErrorHandler;
|
||||
import org.nuclearfog.twidda.backend.utils.PicassoBuilder;
|
||||
import org.nuclearfog.twidda.backend.utils.StringTools;
|
||||
import org.nuclearfog.twidda.database.GlobalSettings;
|
||||
import org.nuclearfog.twidda.model.User;
|
||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog;
|
||||
@ -318,18 +316,14 @@ public class ProfileEditor extends MediaActivity implements OnClickListener, OnP
|
||||
* Set current user's information
|
||||
*/
|
||||
private void setUser() {
|
||||
if (!user.getImageUrl().isEmpty()) {
|
||||
String profileImageUrl;
|
||||
if (!user.hasDefaultProfileImage()) {
|
||||
profileImageUrl = StringTools.buildImageLink(user.getImageUrl(), PROFILE_IMG_HIGH_RES);
|
||||
} else {
|
||||
profileImageUrl = user.getImageUrl();
|
||||
}
|
||||
picasso.load(profileImageUrl).transform(new RoundedCornersTransformation(5, 0)).into(profile_image);
|
||||
String profileImageUrl = user.getProfileImageThumbnailUrl();
|
||||
String bannerImageUrl = user.getBannerImageThumbnailUrl();
|
||||
if (!profileImageUrl.isEmpty()) {
|
||||
Transformation roundCorner = new RoundedCornersTransformation(5, 0);
|
||||
picasso.load(profileImageUrl).transform(roundCorner).into(profile_image);
|
||||
}
|
||||
if (!user.getBannerUrl().isEmpty()) {
|
||||
String bannerLink = user.getBannerUrl() + BANNER_IMG_MID_RES;
|
||||
picasso.load(bannerLink).into(profile_banner, this);
|
||||
if (!bannerImageUrl.isEmpty()) {
|
||||
picasso.load(bannerImageUrl).into(profile_banner, this);
|
||||
addBannerBtn.setVisibility(INVISIBLE);
|
||||
changeBannerBtn.setVisibility(VISIBLE);
|
||||
} else {
|
||||
|
@ -102,9 +102,9 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen
|
||||
private Dialog color_dialog_selector, appInfo, license;
|
||||
private ConfirmDialog confirmDialog;
|
||||
|
||||
private View hqImageText, enableAuthTxt;
|
||||
private View enableAuthTxt;
|
||||
private EditText proxyAddr, proxyPort, proxyUser, proxyPass;
|
||||
private SwitchButton enableProxy, enableAuth, hqImage;
|
||||
private SwitchButton enableProxy, enableAuth;
|
||||
private Spinner locationSpinner;
|
||||
private TextView list_size;
|
||||
private ViewGroup root;
|
||||
@ -142,9 +142,7 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen
|
||||
Spinner scaleSelector = findViewById(R.id.spinner_scale);
|
||||
enableProxy = findViewById(R.id.settings_enable_proxy);
|
||||
enableAuth = findViewById(R.id.settings_enable_auth);
|
||||
hqImage = findViewById(R.id.settings_image_hq);
|
||||
locationSpinner = findViewById(R.id.spinner_woeid);
|
||||
hqImageText = findViewById(R.id.settings_image_hq_descr);
|
||||
enableAuthTxt = findViewById(R.id.settings_enable_auth_descr);
|
||||
colorButtons[COLOR_BACKGROUND] = findViewById(R.id.color_background);
|
||||
colorButtons[COLOR_TEXT] = findViewById(R.id.color_text);
|
||||
@ -202,10 +200,6 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen
|
||||
proxyUser.setVisibility(GONE);
|
||||
proxyPass.setVisibility(GONE);
|
||||
}
|
||||
if (!settings.imagesEnabled()) {
|
||||
hqImageText.setVisibility(GONE);
|
||||
hqImage.setVisibility(GONE);
|
||||
}
|
||||
if (settings.likeEnabled()) {
|
||||
colorButtons[COLOR_FAVORITE].setText(R.string.settings_color_like);
|
||||
} else {
|
||||
@ -220,8 +214,6 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen
|
||||
enableStatusIcons.setCheckedImmediately(settings.statusIndicatorsEnabled());
|
||||
enableProxy.setCheckedImmediately(settings.isProxyEnabled());
|
||||
enableAuth.setCheckedImmediately(settings.isProxyAuthSet());
|
||||
hqImage.setCheckedImmediately(settings.imagesEnabled());
|
||||
hqImage.setCheckedImmediately(settings.getImageQuality());
|
||||
proxyAddr.setText(settings.getProxyHost());
|
||||
proxyPort.setText(settings.getProxyPort());
|
||||
proxyUser.setText(settings.getProxyUser());
|
||||
@ -242,7 +234,6 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen
|
||||
enablePreview.setOnCheckedChangeListener(this);
|
||||
enableProxy.setOnCheckedChangeListener(this);
|
||||
enableAuth.setOnCheckedChangeListener(this);
|
||||
hqImage.setOnCheckedChangeListener(this);
|
||||
toolbarOverlap.setOnCheckedChangeListener(this);
|
||||
fontSelector.setOnItemSelectedListener(this);
|
||||
scaleSelector.setOnItemSelectedListener(this);
|
||||
@ -478,22 +469,11 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen
|
||||
// toggle image loading
|
||||
if (c.getId() == R.id.toggleImg) {
|
||||
settings.setImageLoad(checked);
|
||||
if (checked) {
|
||||
hqImageText.setVisibility(VISIBLE);
|
||||
hqImage.setVisibility(VISIBLE);
|
||||
} else {
|
||||
hqImageText.setVisibility(GONE);
|
||||
hqImage.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
// toggle automatic answer load
|
||||
else if (c.getId() == R.id.toggleAns) {
|
||||
settings.setAnswerLoad(checked);
|
||||
}
|
||||
// enable high quality images
|
||||
else if (c.getId() == R.id.settings_image_hq) {
|
||||
settings.setHighQualityImage(checked);
|
||||
}
|
||||
// enable toolbar overlap
|
||||
else if (c.getId() == R.id.settings_toolbar_ov) {
|
||||
settings.setToolbarOverlap(checked);
|
||||
|
@ -43,6 +43,7 @@ import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.squareup.picasso.Transformation;
|
||||
|
||||
import org.nuclearfog.tag.Tagger;
|
||||
import org.nuclearfog.tag.Tagger.OnTagClickListener;
|
||||
@ -53,7 +54,6 @@ import org.nuclearfog.twidda.backend.async.StatusAction;
|
||||
import org.nuclearfog.twidda.backend.utils.AppStyles;
|
||||
import org.nuclearfog.twidda.backend.utils.ErrorHandler;
|
||||
import org.nuclearfog.twidda.backend.utils.PicassoBuilder;
|
||||
import org.nuclearfog.twidda.backend.utils.StringTools;
|
||||
import org.nuclearfog.twidda.database.GlobalSettings;
|
||||
import org.nuclearfog.twidda.model.Status;
|
||||
import org.nuclearfog.twidda.model.User;
|
||||
@ -711,14 +711,10 @@ public class StatusActivity extends AppCompatActivity implements OnClickListener
|
||||
break;
|
||||
}
|
||||
AppStyles.setDrawableColor(mediaButton, settings.getIconColor());
|
||||
if (settings.imagesEnabled() && !author.getImageUrl().isEmpty()) {
|
||||
String profileImageUrl;
|
||||
if (!author.hasDefaultProfileImage()) {
|
||||
profileImageUrl = StringTools.buildImageLink(author.getImageUrl(), settings.getImageSuffix());
|
||||
} else {
|
||||
profileImageUrl = author.getImageUrl();
|
||||
}
|
||||
picasso.load(profileImageUrl).transform(new RoundedCornersTransformation(4, 0)).error(R.drawable.no_image).into(profileImage);
|
||||
String profileImageUrl = author.getProfileImageThumbnailUrl();
|
||||
if (settings.imagesEnabled() && !profileImageUrl.isEmpty()) {
|
||||
Transformation roundCorner = new RoundedCornersTransformation(4, 0);
|
||||
picasso.load(profileImageUrl).transform(roundCorner).error(R.drawable.no_image).into(profileImage);
|
||||
} else {
|
||||
profileImage.setImageResource(0);
|
||||
}
|
||||
|
@ -341,7 +341,7 @@
|
||||
android:layout_marginEnd="@dimen/settings_switch_margin"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/settings_data_text"
|
||||
app:layout_constraintBottom_toTopOf="@id/settings_image_hq"
|
||||
app:layout_constraintBottom_toTopOf="@id/toggleAns"
|
||||
app:layout_constraintEnd_toStartOf="@id/toggleImg_descr" />
|
||||
|
||||
<TextView
|
||||
@ -357,30 +357,6 @@
|
||||
app:layout_constraintBottom_toBottomOf="@id/toggleImg"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<com.kyleduo.switchbutton.SwitchButton
|
||||
android:id="@+id/settings_image_hq"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/settings_column_margin"
|
||||
android:layout_marginEnd="@dimen/settings_switch_margin"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/toggleImg"
|
||||
app:layout_constraintBottom_toTopOf="@id/toggleAns"
|
||||
app:layout_constraintEnd_toStartOf="@id/settings_image_hq_descr" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/settings_image_hq_descr"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:singleLine="true"
|
||||
android:text="@string/settings_enable_hq_img"
|
||||
android:textSize="@dimen/settings_textsize_small"
|
||||
app:layout_constraintStart_toEndOf="@id/settings_image_hq"
|
||||
app:layout_constraintTop_toTopOf="@id/settings_image_hq"
|
||||
app:layout_constraintBottom_toBottomOf="@id/settings_image_hq"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<com.kyleduo.switchbutton.SwitchButton
|
||||
android:id="@+id/toggleAns"
|
||||
android:layout_width="wrap_content"
|
||||
@ -388,7 +364,7 @@
|
||||
android:layout_marginBottom="@dimen/settings_column_margin"
|
||||
android:layout_marginEnd="@dimen/settings_switch_margin"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/settings_image_hq"
|
||||
app:layout_constraintTop_toBottomOf="@id/toggleImg"
|
||||
app:layout_constraintBottom_toTopOf="@id/settings_enable_prev"
|
||||
app:layout_constraintEnd_toStartOf="@id/toggleAns_descr" />
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user