added profile toolbar blur effect

This commit is contained in:
nuclearfog 2021-01-18 21:23:00 +01:00
parent 2d80392d17
commit 5d9b7e66d4
No known key found for this signature in database
GPG Key ID: D5490E4A81F97B14
4 changed files with 157 additions and 151 deletions

View File

@ -46,6 +46,7 @@ dependencies {
implementation 'org.twitter4j:twitter4j-core:4.0.7' implementation 'org.twitter4j:twitter4j-core:4.0.7'
implementation 'com.squareup.picasso:picasso:2.71828' implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.kyleduo.switchbutton:library:2.0.3' implementation 'com.kyleduo.switchbutton:library:2.0.3'
implementation 'com.github.open-android:Picasso-transformations:0.1.0'
implementation 'com.github.QuadFlask:colorpicker:0.0.15' implementation 'com.github.QuadFlask:colorpicker:0.0.15'
implementation 'com.github.nuclearfog:ZoomView:1.0.2' implementation 'com.github.nuclearfog:ZoomView:1.0.2'
implementation 'com.github.nuclearfog:Tagger:2.2' implementation 'com.github.nuclearfog:Tagger:2.2'

View File

@ -8,6 +8,7 @@ import android.graphics.Point;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.text.Spanned; import android.text.Spanned;
import android.view.Gravity;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
@ -46,11 +47,13 @@ import org.nuclearfog.twidda.database.GlobalSettings;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import jp.wasabeef.picasso.transformations.BlurTransformation;
import jp.wasabeef.picasso.transformations.RoundedCornersTransformation;
import static android.content.Intent.ACTION_VIEW; import static android.content.Intent.ACTION_VIEW;
import static android.os.AsyncTask.Status.RUNNING; import static android.os.AsyncTask.Status.RUNNING;
import static android.view.View.GONE; import static android.view.View.GONE;
import static android.view.View.VISIBLE; import static android.view.View.VISIBLE;
import static android.widget.LinearLayout.LayoutParams.WRAP_CONTENT;
import static android.widget.Toast.LENGTH_SHORT; 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_LINK;
import static org.nuclearfog.twidda.activity.MediaViewer.KEY_MEDIA_TYPE; import static org.nuclearfog.twidda.activity.MediaViewer.KEY_MEDIA_TYPE;
@ -122,6 +125,7 @@ public class UserProfile extends AppCompatActivity implements OnClickListener, O
*/ */
private static final int TRANSPARENCY = 0xafffffff; private static final int TRANSPARENCY = 0xafffffff;
private Point displaySize;
private FragmentAdapter adapter; private FragmentAdapter adapter;
private GlobalSettings settings; private GlobalSettings settings;
private UserAction profileAsync; private UserAction profileAsync;
@ -130,8 +134,8 @@ public class UserProfile extends AppCompatActivity implements OnClickListener, O
private TextView txtUser, txtScrName; private TextView txtUser, txtScrName;
private TextView txtLocation, txtCreated, lnkTxt, bioTxt, follow_back; private TextView txtLocation, txtCreated, lnkTxt, bioTxt, follow_back;
private Button following, follower; private Button following, follower;
private ImageView profileImage, bannerImage; private ImageView profileImage, bannerImage, toolbarBackground;
private View profile_head, profile_layer; private View profile_head;
private ViewPager pager; private ViewPager pager;
private TabLayout tabLayout; private TabLayout tabLayout;
private Dialog unfollowConfirm, blockConfirm, muteConfirm; private Dialog unfollowConfirm, blockConfirm, muteConfirm;
@ -148,6 +152,7 @@ public class UserProfile extends AppCompatActivity implements OnClickListener, O
setContentView(R.layout.page_profile); setContentView(R.layout.page_profile);
Toolbar tool = findViewById(R.id.profile_toolbar); Toolbar tool = findViewById(R.id.profile_toolbar);
View root = findViewById(R.id.user_view); View root = findViewById(R.id.user_view);
View profile_layer = findViewById(R.id.profile_layer);
tabLayout = findViewById(R.id.profile_tab); tabLayout = findViewById(R.id.profile_tab);
bioTxt = findViewById(R.id.bio); bioTxt = findViewById(R.id.bio);
following = findViewById(R.id.following); following = findViewById(R.id.following);
@ -155,17 +160,24 @@ public class UserProfile extends AppCompatActivity implements OnClickListener, O
lnkTxt = findViewById(R.id.links); lnkTxt = findViewById(R.id.links);
profileImage = findViewById(R.id.profile_img); profileImage = findViewById(R.id.profile_img);
bannerImage = findViewById(R.id.profile_banner); bannerImage = findViewById(R.id.profile_banner);
toolbarBackground = findViewById(R.id.profile_toolbar_background);
txtUser = findViewById(R.id.profile_username); txtUser = findViewById(R.id.profile_username);
txtScrName = findViewById(R.id.profile_screenname); txtScrName = findViewById(R.id.profile_screenname);
txtLocation = findViewById(R.id.location); txtLocation = findViewById(R.id.location);
profile_head = findViewById(R.id.profile_header); profile_head = findViewById(R.id.profile_header);
profile_layer = findViewById(R.id.profile_layer);
txtCreated = findViewById(R.id.profile_date); txtCreated = findViewById(R.id.profile_date);
follow_back = findViewById(R.id.follow_back); follow_back = findViewById(R.id.follow_back);
pager = findViewById(R.id.profile_pager); pager = findViewById(R.id.profile_pager);
settings = GlobalSettings.getInstance(this); displaySize = new Point();
getWindowManager().getDefaultDisplay().getSize(displaySize);
int layoutHeight = displaySize.x / 3;
int buttonHeight = (int) getResources().getDimension(R.dimen.profile_button_height);
int layerPadding = (int) getResources().getDimension(R.dimen.profile_layer_padding);
profile_layer.getLayoutParams().height = layoutHeight + buttonHeight + layerPadding;
profile_layer.requestLayout();
settings = GlobalSettings.getInstance(this);
following.setCompoundDrawablesWithIntrinsicBounds(R.drawable.following, 0, 0, 0); following.setCompoundDrawablesWithIntrinsicBounds(R.drawable.following, 0, 0, 0);
follower.setCompoundDrawablesWithIntrinsicBounds(R.drawable.follower, 0, 0, 0); follower.setCompoundDrawablesWithIntrinsicBounds(R.drawable.follower, 0, 0, 0);
txtCreated.setCompoundDrawablesWithIntrinsicBounds(R.drawable.calendar, 0, 0, 0); txtCreated.setCompoundDrawablesWithIntrinsicBounds(R.drawable.calendar, 0, 0, 0);
@ -590,23 +602,21 @@ public class UserProfile extends AppCompatActivity implements OnClickListener, O
} }
if (settings.getImageLoad()) { if (settings.getImageLoad()) {
if (user.hasBannerImage()) { if (user.hasBannerImage()) {
Point displaySize = new Point();
getWindowManager().getDefaultDisplay().getSize(displaySize);
int layoutHeight = displaySize.x / 3;
int buttonHeight = (int) getResources().getDimension(R.dimen.profile_button_height);
profile_layer.getLayoutParams().height = layoutHeight + buttonHeight;
String bannerLink = user.getBannerLink() + settings.getBannerSuffix(); String bannerLink = user.getBannerLink() + settings.getBannerSuffix();
Picasso.get().load(bannerLink).error(R.drawable.no_banner).into(bannerImage); Picasso.get().load(bannerLink).error(R.drawable.no_banner).into(bannerImage);
int toolbarHeight = (int) getResources().getDimension(R.dimen.profile_toolbar_height);
Picasso.get().load(bannerLink).resize(displaySize.x, toolbarHeight).centerCrop(Gravity.TOP)
.transform(new BlurTransformation(this, 10)).error(R.drawable.no_banner).into(toolbarBackground);
} else { } else {
bannerImage.setImageResource(0); bannerImage.setImageResource(0);
profile_layer.getLayoutParams().height = WRAP_CONTENT;
} }
profile_layer.requestLayout();
if (user.hasProfileImage()) { if (user.hasProfileImage()) {
String imgLink = user.getImageLink(); String imgLink = user.getImageLink();
if (!user.hasDefaultProfileImage()) if (!user.hasDefaultProfileImage())
imgLink += PROFILE_IMG_HIGH_RES; imgLink += PROFILE_IMG_HIGH_RES;
Picasso.get().load(imgLink).error(R.drawable.no_image).into(profileImage); Picasso.get().load(imgLink).transform(new RoundedCornersTransformation(5, 0)).error(R.drawable.no_image).into(profileImage);
} else {
profileImage.setImageResource(0);
} }
} }
} }

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/user_view" android:id="@+id/user_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -16,16 +17,6 @@
android:layout_height="match_parent" android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"> app:layout_scrollFlags="scroll|exitUntilCollapsed">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar
android:id="@+id/profile_toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/profile_toolbar_height" />
<LinearLayout <LinearLayout
android:id="@+id/profile_header" android:id="@+id/profile_header"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -36,18 +27,29 @@
<FrameLayout <FrameLayout
android:id="@+id/profile_layer" android:id="@+id/profile_layer"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="180dp">
<ImageView <ImageView
android:id="@+id/profile_banner" android:id="@+id/profile_banner"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:contentDescription="@string/profile_banner"
android:paddingLeft="@dimen/profile_banner_padding"
android:paddingRight="@dimen/profile_banner_padding"
android:adjustViewBounds="true" android:adjustViewBounds="true"
android:contentDescription="@string/profile_banner"
android:scaleType="centerCrop" /> android:scaleType="centerCrop" />
<ImageView
android:id="@+id/profile_toolbar_background"
android:layout_width="match_parent"
android:layout_height="@dimen/profile_toolbar_height"
android:gravity="top"
tools:ignore="ContentDescription" />
<androidx.appcompat.widget.Toolbar
android:id="@+id/profile_toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/profile_toolbar_height"
android:gravity="top" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -56,18 +58,12 @@
android:paddingLeft="@dimen/profile_layout_padding" android:paddingLeft="@dimen/profile_layout_padding"
android:paddingRight="@dimen/profile_layout_padding"> android:paddingRight="@dimen/profile_layout_padding">
<androidx.cardview.widget.CardView
android:layout_width="@dimen/profile_image"
android:layout_height="@dimen/profile_image">
<ImageView <ImageView
android:id="@+id/profile_img" android:id="@+id/profile_img"
android:layout_width="@dimen/profile_image" android:layout_width="@dimen/profile_image"
android:layout_height="@dimen/profile_image" android:layout_height="@dimen/profile_image"
android:contentDescription="@string/profile_image" /> android:contentDescription="@string/profile_image" />
</androidx.cardview.widget.CardView>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -79,10 +75,10 @@
android:id="@+id/profile_username" android:id="@+id/profile_username"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="@dimen/profile_textsize_big"
android:drawablePadding="@dimen/profile_padding_drawable" android:drawablePadding="@dimen/profile_padding_drawable"
android:padding="@dimen/profile_tv_padding" android:padding="@dimen/profile_tv_padding"
android:singleLine="true" /> android:singleLine="true"
android:textSize="@dimen/profile_textsize_big" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -93,20 +89,20 @@
android:id="@+id/profile_screenname" android:id="@+id/profile_screenname"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="@dimen/profile_textsize_big"
android:drawablePadding="@dimen/profile_padding_drawable" android:drawablePadding="@dimen/profile_padding_drawable"
android:padding="@dimen/profile_tv_padding" android:padding="@dimen/profile_tv_padding"
android:singleLine="true" /> android:singleLine="true"
android:textSize="@dimen/profile_textsize_big" />
<TextView <TextView
android:id="@+id/follow_back" android:id="@+id/follow_back"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="@dimen/profile_textsize_big"
android:drawablePadding="@dimen/profile_padding_drawable" android:drawablePadding="@dimen/profile_padding_drawable"
android:padding="@dimen/profile_tv_padding" android:padding="@dimen/profile_tv_padding"
android:singleLine="true" android:singleLine="true"
android:text="@string/follows_you" android:text="@string/follows_you"
android:textSize="@dimen/profile_textsize_big"
android:visibility="invisible" /> android:visibility="invisible" />
</LinearLayout> </LinearLayout>
@ -120,25 +116,25 @@
<Button <Button
android:id="@+id/following" android:id="@+id/following"
style="@style/FeedbackButton"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="@dimen/profile_button_height" android:layout_height="@dimen/profile_button_height"
android:layout_marginLeft="@dimen/profile_button_margin" android:layout_marginLeft="@dimen/profile_button_margin"
android:layout_marginRight="@dimen/profile_button_margin" android:layout_marginRight="@dimen/profile_button_margin"
android:layout_weight="1" android:layout_weight="1"
android:paddingLeft="@dimen/profile_button_padding" android:paddingLeft="@dimen/profile_button_padding"
android:paddingRight="@dimen/profile_button_padding" android:paddingRight="@dimen/profile_button_padding" />
style="@style/FeedbackButton" />
<Button <Button
android:id="@+id/follower" android:id="@+id/follower"
style="@style/FeedbackButton"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="@dimen/profile_button_height" android:layout_height="@dimen/profile_button_height"
android:layout_marginLeft="@dimen/profile_button_margin" android:layout_marginLeft="@dimen/profile_button_margin"
android:layout_marginRight="@dimen/profile_button_margin" android:layout_marginRight="@dimen/profile_button_margin"
android:layout_weight="1" android:layout_weight="1"
android:paddingLeft="@dimen/profile_button_padding" android:paddingLeft="@dimen/profile_button_padding"
android:paddingRight="@dimen/profile_button_padding" android:paddingRight="@dimen/profile_button_padding" />
style="@style/FeedbackButton" />
</LinearLayout> </LinearLayout>
@ -200,8 +196,6 @@
</LinearLayout> </LinearLayout>
</LinearLayout>
</com.google.android.material.appbar.CollapsingToolbarLayout> </com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout> </com.google.android.material.appbar.AppBarLayout>

View File

@ -55,6 +55,7 @@
<dimen name="profile_button_padding">5dp</dimen> <dimen name="profile_button_padding">5dp</dimen>
<dimen name="profile_textsize_big">14sp</dimen> <dimen name="profile_textsize_big">14sp</dimen>
<dimen name="profile_textsize_small">12sp</dimen> <dimen name="profile_textsize_small">12sp</dimen>
<dimen name="profile_layer_padding">5dp</dimen>
<integer name="profile_text_bio_lines">3</integer> <integer name="profile_text_bio_lines">3</integer>
<!--dimens of page_editprofile.xml--> <!--dimens of page_editprofile.xml-->