added profile banner view

This commit is contained in:
nuclearfog 2020-04-27 16:49:28 +02:00
parent d52bc3453f
commit 3f317b2312
No known key found for this signature in database
GPG Key ID: ED35E22099354A64
6 changed files with 210 additions and 129 deletions

View File

@ -51,6 +51,7 @@ import static android.view.MotionEvent.ACTION_DOWN;
import static android.view.MotionEvent.ACTION_UP;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
import static android.widget.LinearLayout.LayoutParams.WRAP_CONTENT;
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;
@ -80,8 +81,8 @@ public class UserProfile extends AppCompatActivity implements OnClickListener,
private TextView tweetTabTxt, favorTabTxt, txtUser, txtScrName;
private TextView txtLocation, txtCreated, lnkTxt, bioTxt, follow_back;
private Button following, follower;
private ImageView profile;
private View profile_head;
private ImageView profile, banner;
private View profile_head, profile_layer;
private ViewPager pager;
@Nullable
@ -112,10 +113,12 @@ public class UserProfile extends AppCompatActivity implements OnClickListener,
follower = findViewById(R.id.follower);
lnkTxt = findViewById(R.id.links);
profile = findViewById(R.id.profile_img);
banner = findViewById(R.id.profile_banner);
txtUser = findViewById(R.id.profile_username);
txtScrName = findViewById(R.id.profile_screenname);
txtLocation = findViewById(R.id.location);
profile_head = findViewById(R.id.profile_header);
profile_layer = findViewById(R.id.profile_layer);
txtCreated = findViewById(R.id.profile_date);
follow_back = findViewById(R.id.follow_back);
pager = findViewById(R.id.profile_pager);
@ -159,6 +162,7 @@ public class UserProfile extends AppCompatActivity implements OnClickListener,
following.setOnClickListener(this);
follower.setOnClickListener(this);
profile.setOnClickListener(this);
banner.setOnClickListener(this);
lnkTxt.setOnClickListener(this);
bioTxt.setOnTouchListener(this);
}
@ -427,6 +431,15 @@ public class UserProfile extends AppCompatActivity implements OnClickListener,
image.putExtra(KEY_MEDIA_TYPE, MEDIAVIEWER_IMAGE);
startActivity(image);
}
case R.id.profile_banner:
if (user != null) {
Intent image = new Intent(this, MediaViewer.class);
image.putExtra(KEY_MEDIA_LINK, new String[]{user.getBannerLink() + "/1500x500"});
image.putExtra(KEY_MEDIA_TYPE, MEDIAVIEWER_IMAGE);
startActivity(image);
}
break;
}
}
@ -509,8 +522,19 @@ public class UserProfile extends AppCompatActivity implements OnClickListener,
lnkTxt.setVisibility(GONE);
}
if (settings.getImageLoad()) {
String link = user.getImageLink() + "_bigger";
Picasso.get().load(link).into(profile);
if (user.hasBannerImg()) {
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 {
profile_layer.getLayoutParams().height = WRAP_CONTENT;
profile_layer.requestLayout();
}
if (user.hasProfileImage()) {
String imgLink = user.getImageLink() + "_bigger";
Picasso.get().load(imgLink).into(profile);
}
}
}

View File

@ -33,11 +33,20 @@ public class TwitterUser {
userID = user.getId();
username = "" + user.getName();
screenname = '@' + user.getScreenName();
profileImg = "" + user.getOriginalProfileImageURLHttps();
bio = getBio(user);
link = "" + user.getURLEntity().getExpandedURL();
location = "" + user.getLocation();
bannerImg = "" + user.getProfileBannerURL();
bio = getBio(user);
String profileLink = user.getOriginalProfileImageURLHttps();
String bannerLink = user.getProfileBannerURL();
if (profileLink != null)
profileImg = user.getOriginalProfileImageURLHttps();
else
profileImg = "";
if (bannerLink != null && bannerLink.length() > 4)
bannerImg = bannerLink.substring(0, bannerLink.length() - 4);
else
bannerImg = "";
isVerified = user.isVerified();
isLocked = user.isProtected();
created = user.getCreatedAt().getTime();
@ -198,6 +207,24 @@ public class TwitterUser {
return favorCount;
}
/**
* check if User has Profile image
*
* @return true if user has a profile image set
*/
public boolean hasProfileImage() {
return !profileImg.isEmpty();
}
/**
* check if user has a banner image
*
* @return true if user has a banner image set
*/
public boolean hasBannerImg() {
return !bannerImg.isEmpty();
}
/**
* Resolve shortened links from user description
* @param user Twitter user

View File

@ -31,157 +31,182 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="@dimen/padding_side"
android:paddingRight="@dimen/padding_side"
android:visibility="invisible">
<LinearLayout
<FrameLayout
android:id="@+id/profile_layer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/margin_layout"
android:orientation="horizontal">
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:layout_width="@dimen/profile_image"
android:layout_height="@dimen/profile_image">
<ImageView
android:id="@+id/profile_img"
android:layout_width="@dimen/profile_image"
android:layout_height="@dimen/profile_image"
android:contentDescription="@string/profile_image" />
</androidx.cardview.widget.CardView>
<ImageView
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:scaleType="centerCrop" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/margin_layout"
android:layout_marginLeft="@dimen/margin_layout"
android:orientation="vertical">
android:gravity="bottom"
android:orientation="horizontal"
android:paddingLeft="@dimen/padding_side"
android:paddingRight="@dimen/padding_side">
<TextView
android:id="@+id/profile_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawablePadding="@dimen/padding_drawable"
android:singleLine="true" />
<androidx.cardview.widget.CardView
android:layout_width="@dimen/profile_image"
android:layout_height="@dimen/profile_image">
<ImageView
android:id="@+id/profile_img"
android:layout_width="@dimen/profile_image"
android:layout_height="@dimen/profile_image"
android:contentDescription="@string/profile_image" />
</androidx.cardview.widget.CardView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:layout_marginStart="@dimen/margin_layout"
android:layout_marginLeft="@dimen/margin_layout"
android:orientation="vertical">
<TextView
android:id="@+id/profile_screenname"
android:layout_width="0dp"
android:id="@+id/profile_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:drawablePadding="@dimen/padding_drawable"
android:singleLine="true" />
<TextView
android:id="@+id/follow_back"
android:layout_width="0dp"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/text_padding"
android:layout_marginLeft="@dimen/text_padding"
android:layout_weight="1"
android:drawablePadding="@dimen/padding_drawable"
android:singleLine="true"
android:text="@string/follows_you"
android:visibility="invisible"
app:drawableLeftCompat="@drawable/followback"
app:drawableStartCompat="@drawable/followback" />
android:orientation="horizontal">
</LinearLayout>
<TextView
android:id="@+id/profile_screenname"
android:layout_width="0dp"
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:singleLine="true" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_layout"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/follow_back"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawablePadding="@dimen/padding_drawable"
android:singleLine="true"
android:text="@string/follows_you"
android:visibility="invisible"
app:drawableLeftCompat="@drawable/followback"
app:drawableStartCompat="@drawable/followback" />
<Button
android:id="@+id/following"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="0dp"
android:layout_height="@dimen/button_height"
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:singleLine="true"
app:drawableLeftCompat="@drawable/following"
app:drawableStartCompat="@drawable/following" />
</LinearLayout>
<Button
android:id="@+id/follower"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="0dp"
android:layout_height="@dimen/button_height"
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:singleLine="true"
app:drawableLeftCompat="@drawable/follower"
app:drawableStartCompat="@drawable/follower" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_layout"
android:gravity="center_vertical"
android:orientation="horizontal">
<Button
android:id="@+id/following"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="0dp"
android:layout_height="@dimen/button_height"
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:singleLine="true"
app:drawableLeftCompat="@drawable/following"
app:drawableStartCompat="@drawable/following" />
<Button
android:id="@+id/follower"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="0dp"
android:layout_height="@dimen/button_height"
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:singleLine="true"
app:drawableLeftCompat="@drawable/follower"
app:drawableStartCompat="@drawable/follower" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="@dimen/padding_side"
android:paddingRight="@dimen/padding_side">
<TextView
android:id="@+id/bio"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/profile_tv_margin"
android:fadeScrollbars="false"
android:linksClickable="true"
android:maxLines="@integer/text_bio_lines"
android:scrollbars="vertical" />
<TextView
android:id="@+id/location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/profile_tv_margin"
android:drawablePadding="@dimen/padding_drawable"
android:singleLine="true"
android:textSize="@dimen/textsize_profile"
app:drawableLeftCompat="@drawable/userlocation"
app:drawableStartCompat="@drawable/userlocation" />
<TextView
android:id="@+id/links"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/profile_tv_margin"
android:drawablePadding="@dimen/padding_drawable"
android:linksClickable="true"
android:singleLine="true"
android:textSize="@dimen/textsize_profile"
app:drawableLeftCompat="@drawable/link"
app:drawableStartCompat="@drawable/link" />
<TextView
android:id="@+id/profile_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/profile_tv_margin"
android:drawablePadding="@dimen/padding_drawable"
android:singleLine="true"
android:textSize="@dimen/textsize_profile"
app:drawableLeftCompat="@drawable/calendar"
app:drawableStartCompat="@drawable/calendar" />
</LinearLayout>
<TextView
android:id="@+id/bio"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fadeScrollbars="false"
android:linksClickable="true"
android:maxLines="@integer/text_bio_lines"
android:scrollbars="vertical" />
<TextView
android:id="@+id/location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_layout"
android:drawablePadding="@dimen/padding_drawable"
android:singleLine="true"
android:textSize="@dimen/textsize_profile"
app:drawableLeftCompat="@drawable/userlocation"
app:drawableStartCompat="@drawable/userlocation" />
<TextView
android:id="@+id/links"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_layout"
android:drawablePadding="@dimen/padding_drawable"
android:linksClickable="true"
android:singleLine="true"
android:textSize="@dimen/textsize_profile"
app:drawableLeftCompat="@drawable/link"
app:drawableStartCompat="@drawable/link" />
<TextView
android:id="@+id/profile_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_layout"
android:drawablePadding="@dimen/padding_drawable"
android:singleLine="true"
android:textSize="@dimen/textsize_profile"
app:drawableLeftCompat="@drawable/calendar"
app:drawableStartCompat="@drawable/calendar" />
</LinearLayout>
</LinearLayout>

View File

@ -146,4 +146,5 @@
<string name="trend_range">Tweets</string>
<string name="error_connection_failed">Verbindung fehlgeschlagen!</string>
<string name="enter_username">Nutzernamen eingeben</string>
<string name="profile_banner">Profilbanner</string>
</resources>

View File

@ -3,7 +3,7 @@
<dimen name="toolbar_height">45dp</dimen>
<dimen name="divider">2dp</dimen>
<dimen name="profile_image">64dp</dimen>
<dimen name="profile_image">80dp</dimen>
<dimen name="profile_middle">40dp</dimen>
<dimen name="profile_small">36dp</dimen>
<dimen name="tweet_profile">56dp</dimen>
@ -39,7 +39,7 @@
<dimen name="tweet_textsize_api">12sp</dimen>
<dimen name="textsize_settings_small">11sp</dimen>
<integer name="text_tweet_lines">9</integer>
<integer name="text_bio_lines">5</integer>
<integer name="text_bio_lines">3</integer>
<dimen name="button_dm">40dp</dimen>
<dimen name="button_settings_color">40dp</dimen>
@ -67,4 +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">155dp</dimen>
<dimen name="profile_tv_margin">2dp</dimen>
<dimen name="profile_banner_padding">40dp</dimen>
</resources>

View File

@ -147,4 +147,5 @@
<string name="trend_range">Tweets</string>
<string name="error_connection_failed">Connection failed!</string>
<string name="enter_username">Enter username</string>
<string name="profile_banner">Profile banner image</string>
</resources>