v 1.7.5 new Profile editor, fixed default profile image bug
This commit is contained in:
parent
65fd98fd79
commit
d14f69b09d
@ -8,8 +8,8 @@ android {
|
||||
applicationId 'org.nuclearfog.twidda'
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 29
|
||||
versionCode 12
|
||||
versionName '1.7.4'
|
||||
versionCode 13
|
||||
versionName '1.7.5'
|
||||
vectorDrawables.useSupportLibrary true
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
@ -36,11 +37,8 @@ import static android.content.Intent.ACTION_PICK;
|
||||
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
||||
import static android.os.AsyncTask.Status.RUNNING;
|
||||
import static android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
|
||||
import static android.view.View.INVISIBLE;
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
import static org.nuclearfog.twidda.activity.MediaViewer.KEY_MEDIA_LINK;
|
||||
import static org.nuclearfog.twidda.activity.MediaViewer.KEY_MEDIA_TYPE;
|
||||
import static org.nuclearfog.twidda.activity.MediaViewer.MEDIAVIEWER_IMAGE;
|
||||
import static org.nuclearfog.twidda.activity.MediaViewer.MEDIAVIEWER_IMG_STORAGE;
|
||||
|
||||
|
||||
public class ProfileEditor extends AppCompatActivity implements OnClickListener {
|
||||
@ -48,13 +46,14 @@ public class ProfileEditor extends AppCompatActivity implements OnClickListener
|
||||
private static final String[] PERM_READ = {READ_EXTERNAL_STORAGE};
|
||||
private static final String[] MEDIA_MODE = {MediaStore.Images.Media.DATA};
|
||||
private static final int REQ_PERM = 3;
|
||||
private static final int REQ_PB = 4;
|
||||
private static final int REQ_PROFILE_IMG = 4;
|
||||
private static final int REQ_PROFILE_BANNER = 5;
|
||||
|
||||
private ProfileUpdater editorAsync;
|
||||
private TwitterUser user;
|
||||
private ImageView pb_image;
|
||||
private ImageView profile_image, profile_banner;
|
||||
private EditText name, link, loc, bio;
|
||||
private Button txtImg;
|
||||
private Button add_banner_btn;
|
||||
private String profileLink, bannerLink;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -62,8 +61,9 @@ public class ProfileEditor extends AppCompatActivity implements OnClickListener
|
||||
setContentView(R.layout.page_editprofile);
|
||||
Toolbar toolbar = findViewById(R.id.editprofile_toolbar);
|
||||
View root = findViewById(R.id.page_edit);
|
||||
pb_image = findViewById(R.id.edit_pb);
|
||||
txtImg = findViewById(R.id.edit_upload);
|
||||
profile_image = findViewById(R.id.edit_pb);
|
||||
profile_banner = findViewById(R.id.edit_banner);
|
||||
add_banner_btn = findViewById(R.id.edit_add_banner);
|
||||
name = findViewById(R.id.edit_name);
|
||||
link = findViewById(R.id.edit_link);
|
||||
loc = findViewById(R.id.edit_location);
|
||||
@ -75,8 +75,9 @@ public class ProfileEditor extends AppCompatActivity implements OnClickListener
|
||||
GlobalSettings settings = GlobalSettings.getInstance(this);
|
||||
FontTool.setViewFontAndColor(settings, root);
|
||||
root.setBackgroundColor(settings.getBackgroundColor());
|
||||
txtImg.setOnClickListener(this);
|
||||
pb_image.setOnClickListener(this);
|
||||
profile_image.setOnClickListener(this);
|
||||
profile_banner.setOnClickListener(this);
|
||||
add_banner_btn.setOnClickListener(this);
|
||||
}
|
||||
|
||||
|
||||
@ -128,11 +129,10 @@ public class ProfileEditor extends AppCompatActivity implements OnClickListener
|
||||
String userLink = link.getText().toString();
|
||||
String userLoc = loc.getText().toString();
|
||||
String userBio = bio.getText().toString();
|
||||
String imgLink = txtImg.getText().toString();
|
||||
if (username.trim().isEmpty()) {
|
||||
Toast.makeText(this, R.string.error_empty_name, LENGTH_SHORT).show();
|
||||
} else {
|
||||
UserHolder userHolder = new UserHolder(username, userLink, userLoc, userBio, imgLink);
|
||||
UserHolder userHolder = new UserHolder(username, userLink, userLoc, userBio, profileLink, bannerLink);
|
||||
editorAsync = new ProfileUpdater(this, userHolder);
|
||||
editorAsync.execute();
|
||||
}
|
||||
@ -145,14 +145,20 @@ public class ProfileEditor extends AppCompatActivity implements OnClickListener
|
||||
@Override
|
||||
protected void onActivityResult(int reqCode, int returnCode, Intent intent) {
|
||||
super.onActivityResult(reqCode, returnCode, intent);
|
||||
if (reqCode == REQ_PB && returnCode == RESULT_OK) {
|
||||
if (returnCode == RESULT_OK && (reqCode == REQ_PROFILE_IMG || reqCode == REQ_PROFILE_BANNER)) {
|
||||
if (intent != null && intent.getData() != null) {
|
||||
Cursor c = getContentResolver().query(intent.getData(), MEDIA_MODE, null, null, null);
|
||||
if (c != null && c.moveToFirst()) {
|
||||
int index = c.getColumnIndex(MEDIA_MODE[0]);
|
||||
String mediaPath = c.getString(index);
|
||||
pb_image.setImageBitmap(BitmapFactory.decodeFile(mediaPath));
|
||||
txtImg.setText(mediaPath);
|
||||
Bitmap image = BitmapFactory.decodeFile(mediaPath);
|
||||
if (reqCode == REQ_PROFILE_IMG) {
|
||||
profile_image.setImageBitmap(image);
|
||||
profileLink = mediaPath;
|
||||
} else {
|
||||
profile_banner.setImageBitmap(image);
|
||||
bannerLink = mediaPath;
|
||||
}
|
||||
c.close();
|
||||
}
|
||||
}
|
||||
@ -163,54 +169,50 @@ public class ProfileEditor extends AppCompatActivity implements OnClickListener
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
if (requestCode == REQ_PERM && grantResults[0] == PERMISSION_GRANTED)
|
||||
getMedia();
|
||||
getMedia(requestCode);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.edit_upload:
|
||||
getMedia();
|
||||
case R.id.edit_pb:
|
||||
getMedia(REQ_PROFILE_IMG);
|
||||
break;
|
||||
|
||||
case R.id.edit_pb:
|
||||
if (user != null) {
|
||||
Intent image = new Intent(getApplicationContext(), MediaViewer.class);
|
||||
if (!txtImg.getText().toString().isEmpty()) {
|
||||
String[] mediaLink = new String[]{txtImg.getText().toString()};
|
||||
image.putExtra(KEY_MEDIA_LINK, mediaLink);
|
||||
image.putExtra(KEY_MEDIA_TYPE, MEDIAVIEWER_IMG_STORAGE);
|
||||
} else {
|
||||
String[] mediaLink = new String[]{user.getImageLink()};
|
||||
image.putExtra(KEY_MEDIA_LINK, mediaLink);
|
||||
image.putExtra(KEY_MEDIA_TYPE, MEDIAVIEWER_IMAGE);
|
||||
}
|
||||
startActivity(image);
|
||||
}
|
||||
case R.id.edit_add_banner:
|
||||
case R.id.edit_banner:
|
||||
getMedia(REQ_PROFILE_BANNER);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setUser(TwitterUser user) {
|
||||
String pbLink = user.getImageLink() + "_bigger";
|
||||
Picasso.get().load(pbLink).into(pb_image);
|
||||
String pbLink = user.getImageLink();
|
||||
String bnLink = user.getBannerLink() + "/600x200";
|
||||
|
||||
if (!user.hasDefaultProfileImage())
|
||||
pbLink += "_bigger";
|
||||
Picasso.get().load(pbLink).into(profile_image);
|
||||
if (user.hasBannerImg()) {
|
||||
Picasso.get().load(bnLink).into(profile_banner);
|
||||
add_banner_btn.setVisibility(INVISIBLE);
|
||||
}
|
||||
name.setText(user.getUsername());
|
||||
link.setText(user.getLink());
|
||||
loc.setText(user.getLocation());
|
||||
bio.setText(user.getBio());
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
|
||||
private void getMedia() {
|
||||
private void getMedia(int request) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
int check = checkSelfPermission(READ_EXTERNAL_STORAGE);
|
||||
if (check == PackageManager.PERMISSION_GRANTED) {
|
||||
Intent media = new Intent(ACTION_PICK, EXTERNAL_CONTENT_URI);
|
||||
if (media.resolveActivity(getPackageManager()) != null)
|
||||
startActivityForResult(media, REQ_PB);
|
||||
startActivityForResult(media, request);
|
||||
else
|
||||
Toast.makeText(getApplicationContext(), R.string.error_no_media_app, LENGTH_SHORT).show();
|
||||
} else {
|
||||
@ -219,7 +221,7 @@ public class ProfileEditor extends AppCompatActivity implements OnClickListener
|
||||
} else {
|
||||
Intent media = new Intent(ACTION_PICK, EXTERNAL_CONTENT_URI);
|
||||
if (media.resolveActivity(getPackageManager()) != null)
|
||||
startActivityForResult(media, REQ_PB);
|
||||
startActivityForResult(media, request);
|
||||
else
|
||||
Toast.makeText(getApplicationContext(), R.string.error_no_media_app, LENGTH_SHORT).show();
|
||||
}
|
||||
|
@ -406,7 +406,10 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener, O
|
||||
videoButton.setVisibility(VISIBLE);
|
||||
}
|
||||
if (settings.getImageLoad()) {
|
||||
Picasso.get().load(author.getImageLink() + "_bigger").into(profile_img);
|
||||
String pbLink = author.getImageLink();
|
||||
if (!author.hasDefaultProfileImage())
|
||||
pbLink += "_bigger";
|
||||
Picasso.get().load(pbLink).into(profile_img);
|
||||
}
|
||||
String placeName = tweet.getLocationName();
|
||||
if (placeName != null && !placeName.isEmpty()) {
|
||||
|
@ -531,15 +531,13 @@ public class UserProfile extends AppCompatActivity implements OnClickListener,
|
||||
String bannerLink = user.getBannerLink() + "/600x200";
|
||||
Picasso.get().load(bannerLink).into(banner);
|
||||
profile_layer.getLayoutParams().height = (int) getResources().getDimension(R.dimen.profile_banner_height);
|
||||
profile_layer.requestLayout();
|
||||
} else {
|
||||
} else
|
||||
profile_layer.getLayoutParams().height = WRAP_CONTENT;
|
||||
profile_layer.requestLayout();
|
||||
}
|
||||
if (user.hasProfileImage()) {
|
||||
String imgLink = user.getImageLink() + "_bigger";
|
||||
Picasso.get().load(imgLink).into(profile);
|
||||
}
|
||||
profile_layer.requestLayout();
|
||||
String imgLink = user.getImageLink();
|
||||
if (!user.hasDefaultProfileImage())
|
||||
imgLink += "_bigger";
|
||||
Picasso.get().load(imgLink).into(profile);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,8 +161,12 @@ public class ListAdapter extends Adapter<ListAdapter.ListHolder> {
|
||||
vh.createdAt.setText(StringTools.getTimeString(item.getCreatedAt()));
|
||||
vh.memberCount.setText(formatter.format(item.getMemberCount()));
|
||||
vh.subscriberCount.setText(formatter.format(item.getSubscriberCount()));
|
||||
if (settings.getImageLoad())
|
||||
Picasso.get().load(owner.getImageLink() + "_mini").into(vh.pb_image);
|
||||
if (settings.getImageLoad()) {
|
||||
String pbLink = owner.getImageLink();
|
||||
if (!owner.hasDefaultProfileImage())
|
||||
pbLink += "_mini";
|
||||
Picasso.get().load(pbLink).into(vh.pb_image);
|
||||
}
|
||||
if (item.isFollowing())
|
||||
vh.followList.setText(R.string.user_unfollow);
|
||||
else
|
||||
|
@ -145,8 +145,12 @@ public class MessageAdapter extends Adapter<MessageAdapter.MessageHolder> {
|
||||
vh.screenname.setCompoundDrawablesWithIntrinsicBounds(R.drawable.lock, 0, 0, 0);
|
||||
else
|
||||
vh.screenname.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
|
||||
if (settings.getImageLoad())
|
||||
Picasso.get().load(sender.getImageLink() + "_mini").into(vh.profile_img);
|
||||
if (settings.getImageLoad()) {
|
||||
String pbLink = sender.getImageLink();
|
||||
if (!sender.hasDefaultProfileImage())
|
||||
pbLink += "_mini";
|
||||
Picasso.get().load(pbLink).into(vh.profile_img);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -148,8 +148,12 @@ public class TweetAdapter extends Adapter<TweetAdapter.ItemHolder> {
|
||||
vh.screenname.setCompoundDrawablesWithIntrinsicBounds(R.drawable.lock, 0, 0, 0);
|
||||
else
|
||||
vh.screenname.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
|
||||
if (settings.getImageLoad())
|
||||
Picasso.get().load(user.getImageLink() + "_mini").into(vh.profile);
|
||||
if (settings.getImageLoad()) {
|
||||
String pbLink = user.getImageLink();
|
||||
if (!user.hasDefaultProfileImage())
|
||||
pbLink += "_mini";
|
||||
Picasso.get().load(pbLink).into(vh.profile);
|
||||
}
|
||||
else
|
||||
vh.profile.setImageResource(0);
|
||||
}
|
||||
|
@ -86,7 +86,10 @@ public class UserAdapter extends Adapter<UserAdapter.ItemHolder> {
|
||||
vh.username.setText(user.getUsername());
|
||||
vh.screenname.setText(user.getScreenname());
|
||||
if (settings.getImageLoad()) {
|
||||
Picasso.get().load(user.getImageLink() + "_mini").into(vh.profileImg);
|
||||
String pbLink = user.getImageLink();
|
||||
if (!user.hasDefaultProfileImage())
|
||||
pbLink += "_mini";
|
||||
Picasso.get().load(pbLink).into(vh.profileImg);
|
||||
}
|
||||
if (user.isVerified()) {
|
||||
vh.username.setCompoundDrawablesWithIntrinsicBounds(R.drawable.verify, 0, 0, 0);
|
||||
|
@ -85,8 +85,6 @@ public class ProfileUpdater extends AsyncTask<Void, Void, TwitterUser> {
|
||||
if (userHolder == null) {
|
||||
return mTwitter.getCurrentUser();
|
||||
} else {
|
||||
if (userHolder.hasProfileImage())
|
||||
mTwitter.updateProfileImage(userHolder.getImageLink());
|
||||
TwitterUser user = mTwitter.updateProfile(userHolder);
|
||||
db.storeUser(user);
|
||||
}
|
||||
|
@ -771,6 +771,15 @@ public class TwitterEngine {
|
||||
*/
|
||||
TwitterUser updateProfile(UserHolder userHolder) throws EngineException {
|
||||
try {
|
||||
if (userHolder.hasProfileImage()) {
|
||||
File profileImage = new File(userHolder.getProfileImage());
|
||||
twitter.updateProfileImage(profileImage);
|
||||
twitter.removeProfileBanner();
|
||||
}
|
||||
if (userHolder.hasProfileBanner()) {
|
||||
File profileBanner = new File(userHolder.getProfileBanner());
|
||||
twitter.updateProfileBanner(profileBanner);
|
||||
}
|
||||
String username = userHolder.getName();
|
||||
String user_link = userHolder.getLink();
|
||||
String user_loc = userHolder.getLocation();
|
||||
@ -783,22 +792,6 @@ public class TwitterEngine {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update user profile image_add
|
||||
*
|
||||
* @param path image path
|
||||
* @throws EngineException if access is unavailable
|
||||
*/
|
||||
void updateProfileImage(String path) throws EngineException {
|
||||
try {
|
||||
File image = new File(path);
|
||||
twitter.updateProfileImage(image);
|
||||
} catch (TwitterException err) {
|
||||
throw new EngineException(err);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get user list
|
||||
*
|
||||
|
@ -26,7 +26,7 @@ public class Message {
|
||||
this.receiver = new TwitterUser(receiver);
|
||||
messageId = dm.getId();
|
||||
time = dm.getCreatedAt().getTime();
|
||||
message = "" + getText(dm);
|
||||
message = getText(dm);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -97,14 +97,18 @@ public class Message {
|
||||
* @return Tweet string with resolved URL entities
|
||||
*/
|
||||
private String getText(DirectMessage message) {
|
||||
URLEntity[] entities = message.getURLEntities();
|
||||
StringBuilder text = new StringBuilder(message.getText());
|
||||
|
||||
for (int i = entities.length - 1; i >= 0; i--) {
|
||||
URLEntity entity = entities[i];
|
||||
text.replace(entity.getStart(), entity.getEnd(), entity.getExpandedURL());
|
||||
String text = message.getText();
|
||||
if (text != null && !text.isEmpty()) {
|
||||
URLEntity[] entities = message.getURLEntities();
|
||||
StringBuilder messageBuilder = new StringBuilder(message.getText());
|
||||
for (int i = entities.length - 1; i >= 0; i--) {
|
||||
URLEntity entity = entities[i];
|
||||
messageBuilder.replace(entity.getStart(), entity.getEnd(), entity.getExpandedURL());
|
||||
}
|
||||
return messageBuilder.toString();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
return text.toString();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -22,15 +22,17 @@ public class TwitterList {
|
||||
private final int subscriberCnt;
|
||||
|
||||
public TwitterList(UserList list, long homeId, boolean isFollowing) {
|
||||
String description = list.getDescription();
|
||||
String title = list.getName();
|
||||
id = list.getId();
|
||||
title = "" + list.getName();
|
||||
createdAt = list.getCreatedAt().getTime();
|
||||
description = "" + list.getDescription();
|
||||
owner = new TwitterUser(list.getUser());
|
||||
isPrivate = !list.isPublic();
|
||||
memberCount = list.getMemberCount();
|
||||
subscriberCnt = list.getSubscriberCount();
|
||||
isOwner = homeId != owner.getId();
|
||||
this.title = title != null ? title : "";
|
||||
this.description = description != null ? description : "";
|
||||
this.isFollowing = isFollowing;
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ public class TwitterUser {
|
||||
private final boolean isVerified;
|
||||
private final boolean isLocked;
|
||||
private final boolean isFollowReqSent;
|
||||
private final boolean hasDefaultImage;
|
||||
|
||||
private final int following;
|
||||
private final int follower;
|
||||
@ -69,11 +70,12 @@ public class TwitterUser {
|
||||
tweetCount = user.getStatusesCount();
|
||||
favorCount = user.getFavouritesCount();
|
||||
isFollowReqSent = user.isFollowRequestSent();
|
||||
hasDefaultImage = user.isDefaultProfileImage();
|
||||
}
|
||||
|
||||
public TwitterUser(long userID, String username, String screenname, String profileImg, String bio, String location,
|
||||
boolean isVerified, boolean isLocked, boolean isFollowReqSent, String link, String bannerImg,
|
||||
long created, int following, int follower, int tweetCount, int favorCount) {
|
||||
boolean isVerified, boolean isLocked, boolean isFollowReqSent, boolean hasDefaultImage, String link,
|
||||
String bannerImg, long created, int following, int follower, int tweetCount, int favorCount) {
|
||||
|
||||
this.userID = userID;
|
||||
this.username = username != null ? username : "";
|
||||
@ -91,6 +93,7 @@ public class TwitterUser {
|
||||
this.tweetCount = tweetCount;
|
||||
this.favorCount = favorCount;
|
||||
this.isFollowReqSent = isFollowReqSent;
|
||||
this.hasDefaultImage = hasDefaultImage;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -226,8 +229,8 @@ public class TwitterUser {
|
||||
*
|
||||
* @return true if user has a profile image set
|
||||
*/
|
||||
public boolean hasProfileImage() {
|
||||
return !profileImg.isEmpty();
|
||||
public boolean hasDefaultProfileImage() {
|
||||
return hasDefaultImage;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -7,7 +7,7 @@ import androidx.annotation.NonNull;
|
||||
*/
|
||||
public class UserHolder {
|
||||
|
||||
private final String name, link, location, bio, imageLink;
|
||||
private final String name, link, location, bio, profileImage, profileBanner;
|
||||
|
||||
/**
|
||||
* create user information holder
|
||||
@ -16,14 +16,17 @@ public class UserHolder {
|
||||
* @param link profile link
|
||||
* @param location profile location string
|
||||
* @param bio description string
|
||||
* @param imageLink local profile image path
|
||||
* @param profileImage local profile image path
|
||||
* @param profileBanner local profile image path
|
||||
*/
|
||||
public UserHolder(String name, String link, String location, String bio, String imageLink) {
|
||||
public UserHolder(String name, String link, String location, String bio, String profileImage, String profileBanner) {
|
||||
this.name = name;
|
||||
this.bio = bio;
|
||||
this.link = link;
|
||||
this.location = location;
|
||||
this.imageLink = imageLink;
|
||||
this.bio = bio;
|
||||
this.profileImage = profileImage;
|
||||
this.profileBanner = profileBanner;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -62,17 +65,34 @@ public class UserHolder {
|
||||
* get local image path
|
||||
* @return image path
|
||||
*/
|
||||
public String getImageLink() {
|
||||
return imageLink;
|
||||
public String getProfileImage() {
|
||||
return profileImage;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if profile image path is included
|
||||
*
|
||||
* @return true if image path is included
|
||||
*/
|
||||
public boolean hasProfileImage() {
|
||||
return !imageLink.isEmpty();
|
||||
return profileImage != null && !profileImage.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* getprofile banner path
|
||||
*
|
||||
* @return image path
|
||||
*/
|
||||
public String getProfileBanner() {
|
||||
return profileBanner;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if profile banner path is included
|
||||
*
|
||||
* @return true if path is included
|
||||
*/
|
||||
public boolean hasProfileBanner() {
|
||||
return profileBanner != null && !profileBanner.isEmpty();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -31,6 +31,7 @@ public class AppDatabase {
|
||||
private static final int LCK_MASK = 1 << 1; // USER LOCKED MASK
|
||||
private static final int FRQ_MASK = 1 << 2; // USER REQUEST FOLLOW
|
||||
private static final int EXCL_USR = 1 << 3; // EXCLUDE USERS TWEETS
|
||||
private static final int DEF_IMG = 1 << 4; // DEFAULT PROFILE IMAGE
|
||||
|
||||
private final int limit; // DATABASE ENTRY limit
|
||||
private final long homeId;
|
||||
@ -586,8 +587,9 @@ public class AppDatabase {
|
||||
boolean isVerified = (userRegister & VER_MASK) > 0;
|
||||
boolean isLocked = (userRegister & LCK_MASK) > 0;
|
||||
boolean isReq = (userRegister & FRQ_MASK) > 0;
|
||||
boolean defaultImg = (userRegister & DEF_IMG) > 0;
|
||||
return new TwitterUser(userId, username, screenname, profileImg, bio, location, isVerified,
|
||||
isLocked, isReq, link, banner, createdAt, following, follower, tCount, fCount);
|
||||
isLocked, isReq, defaultImg, link, banner, createdAt, following, follower, tCount, fCount);
|
||||
}
|
||||
|
||||
|
||||
@ -606,6 +608,10 @@ public class AppDatabase {
|
||||
userRegister |= FRQ_MASK;
|
||||
else
|
||||
userRegister &= ~FRQ_MASK;
|
||||
if (user.hasDefaultProfileImage())
|
||||
userRegister |= DEF_IMG;
|
||||
else
|
||||
userRegister &= ~DEF_IMG;
|
||||
|
||||
userColumn.put("userID", user.getId());
|
||||
userColumn.put("username", user.getUsername());
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/page_edit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@ -21,119 +20,135 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/padding_editprofile"
|
||||
android:paddingRight="@dimen/padding_editprofile">
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="@dimen/profile_banner_height"
|
||||
android:layout_marginBottom="@dimen/margin_layout"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:padding="@dimen/padding_side">
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<Button
|
||||
android:id="@+id/edit_add_banner"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/button_height"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginLeft="@dimen/button_margin"
|
||||
android:layout_marginRight="@dimen/button_margin"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/button"
|
||||
android:paddingLeft="@dimen/button_padding"
|
||||
android:paddingRight="@dimen/button_padding"
|
||||
android:text="@string/editprofile_add_banner"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/edit_banner"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
android:contentDescription="@string/profile_banner"
|
||||
android:paddingLeft="@dimen/profile_banner_padding"
|
||||
android:paddingRight="@dimen/profile_banner_padding"
|
||||
android:scaleType="centerCrop" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/edit_pb"
|
||||
android:layout_width="@dimen/profile_image"
|
||||
android:layout_height="@dimen/profile_image"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_marginStart="@dimen/padding_side"
|
||||
android:layout_marginLeft="@dimen/padding_side"
|
||||
android:adjustViewBounds="true"
|
||||
android:contentDescription="@string/image_preview" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/edit_upload"
|
||||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/margin_upload_btn"
|
||||
android:layout_marginLeft="@dimen/margin_upload_btn"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/button"
|
||||
android:maxLines="2"
|
||||
android:paddingStart="@dimen/editprofile_upload_button_padding"
|
||||
android:paddingLeft="@dimen/editprofile_upload_button_padding"
|
||||
android:paddingEnd="@dimen/button_padding"
|
||||
android:paddingRight="@dimen/button_padding"
|
||||
app:drawableLeftCompat="@drawable/upload"
|
||||
app:drawableStartCompat="@drawable/upload" />
|
||||
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="@dimen/edittext_background_padding"
|
||||
android:paddingRight="@dimen/edittext_background_padding"
|
||||
android:text="@string/enter_username" />
|
||||
android:layout_marginLeft="@dimen/padding_editprofile"
|
||||
android:layout_marginRight="@dimen/padding_editprofile"
|
||||
android:padding="@dimen/edittext_background_padding"
|
||||
android:text="@string/username" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/edit_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/margin_layout"
|
||||
android:background="@color/half_transparent"
|
||||
android:hint="@string/username"
|
||||
android:inputType="text"
|
||||
android:layout_marginLeft="@dimen/padding_editprofile"
|
||||
android:layout_marginRight="@dimen/padding_editprofile"
|
||||
android:padding="@dimen/edittext_background_padding"
|
||||
android:background="@color/half_transparent"
|
||||
android:hint="@string/enter_username"
|
||||
android:inputType="text"
|
||||
android:singleLine="true"
|
||||
android:textSize="@dimen/textsize_profileedit" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="@dimen/edittext_background_padding"
|
||||
android:paddingRight="@dimen/edittext_background_padding"
|
||||
android:layout_marginLeft="@dimen/padding_editprofile"
|
||||
android:layout_marginRight="@dimen/padding_editprofile"
|
||||
android:padding="@dimen/edittext_background_padding"
|
||||
android:text="@string/profile_location" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/edit_location"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/margin_layout"
|
||||
android:layout_marginLeft="@dimen/padding_editprofile"
|
||||
android:layout_marginRight="@dimen/padding_editprofile"
|
||||
android:padding="@dimen/edittext_background_padding"
|
||||
android:background="@color/half_transparent"
|
||||
android:ems="10"
|
||||
android:hint="@string/edit_location_hint"
|
||||
android:inputType="text"
|
||||
android:padding="@dimen/edittext_background_padding"
|
||||
android:singleLine="true"
|
||||
android:textSize="@dimen/textsize_profileedit" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="@dimen/edittext_background_padding"
|
||||
android:paddingRight="@dimen/edittext_background_padding"
|
||||
android:layout_marginLeft="@dimen/padding_editprofile"
|
||||
android:layout_marginRight="@dimen/padding_editprofile"
|
||||
android:padding="@dimen/edittext_background_padding"
|
||||
android:text="@string/profile_link" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/edit_link"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/margin_layout"
|
||||
android:layout_marginLeft="@dimen/padding_editprofile"
|
||||
android:layout_marginRight="@dimen/padding_editprofile"
|
||||
android:padding="@dimen/edittext_background_padding"
|
||||
android:background="@color/half_transparent"
|
||||
android:ems="10"
|
||||
android:hint="@string/edit_hint_link"
|
||||
android:inputType="text"
|
||||
android:padding="@dimen/edittext_background_padding"
|
||||
android:singleLine="true"
|
||||
android:textSize="@dimen/textsize_profileedit" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="@dimen/edittext_background_padding"
|
||||
android:paddingRight="@dimen/edittext_background_padding"
|
||||
android:layout_marginLeft="@dimen/padding_editprofile"
|
||||
android:layout_marginRight="@dimen/padding_editprofile"
|
||||
android:padding="@dimen/edittext_background_padding"
|
||||
android:text="@string/profile_bio" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/edit_bio"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/text_bio_height"
|
||||
android:layout_marginLeft="@dimen/padding_editprofile"
|
||||
android:layout_marginRight="@dimen/padding_editprofile"
|
||||
android:padding="@dimen/edittext_background_padding"
|
||||
android:background="@color/half_transparent"
|
||||
android:ems="10"
|
||||
android:gravity="top"
|
||||
android:hint="@string/edit_hint_enter_descr"
|
||||
android:inputType="textMultiLine"
|
||||
android:padding="@dimen/edittext_background_padding"
|
||||
android:textSize="@dimen/textsize_profileedit" />
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -42,10 +42,10 @@
|
||||
android:id="@+id/profile_banner"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
android:contentDescription="@string/profile_banner"
|
||||
android:paddingLeft="@dimen/profile_banner_padding"
|
||||
android:paddingRight="@dimen/profile_banner_padding"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop" />
|
||||
|
||||
<LinearLayout
|
||||
@ -92,8 +92,6 @@
|
||||
android:id="@+id/profile_screenname"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/text_padding"
|
||||
android:layout_marginRight="@dimen/text_padding"
|
||||
android:drawablePadding="@dimen/padding_drawable"
|
||||
android:padding="@dimen/profile_tv_padding"
|
||||
android:singleLine="true" />
|
||||
|
@ -67,7 +67,7 @@
|
||||
<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">140dp</dimen>
|
||||
<dimen name="profile_banner_height">144dp</dimen>
|
||||
<dimen name="profile_tv_margin">2dp</dimen>
|
||||
<dimen name="profile_banner_padding">5dp</dimen>
|
||||
<dimen name="profile_tv_padding">2dp</dimen>
|
||||
|
@ -148,4 +148,5 @@
|
||||
<string name="error_connection_failed">Connection failed!</string>
|
||||
<string name="enter_username">Enter username</string>
|
||||
<string name="profile_banner">Profile banner image</string>
|
||||
<string name="editprofile_add_banner">add banner</string>
|
||||
</resources>
|
Loading…
x
Reference in New Issue
Block a user