Changes layout for accounts
This commit is contained in:
parent
6a5fe95956
commit
513513046d
|
@ -41,6 +41,7 @@ dependencies {
|
|||
compile 'com.github.chrisbanes:PhotoView:2.0.0'
|
||||
compile 'com.google.code.gson:gson:2.8.0'
|
||||
compile 'org.jsoup:jsoup:1.10.3'
|
||||
compile 'de.hdodenhof:circleimageview:2.2.0'
|
||||
safetynetCompile 'com.google.android.gms:play-services-safetynet:11.0.4'
|
||||
safetynetCompile 'io.github.kobakei:ratethisapp:1.2.0'
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ import android.support.v4.view.PagerAdapter;
|
|||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.text.SpannableString;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.util.Log;
|
||||
|
@ -74,6 +75,7 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import de.hdodenhof.circleimageview.CircleImageView;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.PostActionAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountsAsyncTask;
|
||||
|
@ -131,6 +133,8 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
|
|||
private ImageView header_edit_profile;
|
||||
private List<Status> pins;
|
||||
private String accountUrl;
|
||||
private int maxScrollSize;
|
||||
private boolean avatarShown = true;
|
||||
public enum action{
|
||||
FOLLOW,
|
||||
UNFOLLOW,
|
||||
|
@ -147,9 +151,9 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
|
|||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||
if( theme == Helper.THEME_LIGHT){
|
||||
setTheme(R.style.AppTheme);
|
||||
setTheme(R.style.AppTheme_NoActionBar);
|
||||
}else {
|
||||
setTheme(R.style.AppThemeDark);
|
||||
setTheme(R.style.AppThemeDark_NoActionBar);
|
||||
}
|
||||
setContentView(R.layout.activity_show_account);
|
||||
setTitle("");
|
||||
|
@ -189,13 +193,10 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
|
|||
int positionSpinnerTrans = sharedpreferences.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_YANDEX);
|
||||
|
||||
statusListAdapter = new StatusListAdapter(getApplicationContext(), RetrieveFeedsAsyncTask.Type.USER, accountId, isOnWifi, behaviorWithAttachments, positionSpinnerTrans, this.statuses);
|
||||
options = new DisplayImageOptions.Builder().displayer(new RoundedBitmapDisplayer(80)).cacheInMemory(false)
|
||||
options = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false)
|
||||
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
|
||||
|
||||
|
||||
if( getSupportActionBar() != null)
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
|
||||
tabLayout = (TabLayout) findViewById(R.id.account_tabLayout);
|
||||
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.toots)));
|
||||
|
@ -411,7 +412,7 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
|
|||
}
|
||||
|
||||
accountUrl = account.getUrl();
|
||||
ImageView account_pp = (ImageView) findViewById(R.id.account_pp);
|
||||
final CircleImageView account_pp = (CircleImageView) findViewById(R.id.account_pp);
|
||||
TextView account_dn = (TextView) findViewById(R.id.account_dn);
|
||||
TextView account_un = (TextView) findViewById(R.id.account_un);
|
||||
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
|
@ -435,17 +436,16 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
|
|||
@Override
|
||||
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
|
||||
super.onLoadingComplete(imageUri, view, loadedImage);
|
||||
LinearLayout main_header_container = (LinearLayout) findViewById(R.id.main_header_container);
|
||||
ImageView banner_pp = (ImageView) findViewById(R.id.banner_pp);
|
||||
Bitmap workingBitmap = Bitmap.createBitmap(loadedImage);
|
||||
Bitmap mutableBitmap = workingBitmap.copy(Bitmap.Config.ARGB_8888, true);
|
||||
Canvas canvas = new Canvas(mutableBitmap);
|
||||
Paint p = new Paint(Color.BLACK);
|
||||
ColorFilter filter = new LightingColorFilter(0xFF7F7F7F, 0x00000000);
|
||||
|
||||
p.setColorFilter(filter);
|
||||
canvas.drawBitmap(mutableBitmap, new Matrix(), p);
|
||||
BitmapDrawable background = new BitmapDrawable(getResources(), mutableBitmap);
|
||||
main_header_container.setBackground(background);
|
||||
banner_pp.setImageDrawable(background);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -466,16 +466,14 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
|
|||
account_dn.setCompoundDrawables( null, null, null, null);
|
||||
}
|
||||
|
||||
final ActionBar actionBar = getSupportActionBar();
|
||||
Toolbar actionBar = (Toolbar) findViewById(R.id.toolbar);
|
||||
LayoutInflater mInflater = LayoutInflater.from(ShowAccountActivity.this);
|
||||
if( actionBar != null && account != null){
|
||||
@SuppressLint("InflateParams") View show_account_actionbar = mInflater.inflate(R.layout.showaccount_actionbar, null);
|
||||
TextView actionbar_title = (TextView) show_account_actionbar.findViewById(R.id.show_account_title);
|
||||
if( account.getAcct() != null)
|
||||
actionbar_title.setText(account.getAcct());
|
||||
actionBar.setCustomView(show_account_actionbar);
|
||||
actionBar.setDisplayShowCustomEnabled(true);
|
||||
pp_actionBar = (ImageView) actionBar.getCustomView().findViewById(R.id.pp_actionBar);
|
||||
pp_actionBar = (ImageView) actionBar.findViewById(R.id.pp_actionBar);
|
||||
String url = account.getAvatar();
|
||||
if( url.startsWith("/") ){
|
||||
url = "https://" + Helper.getLiveInstance(getApplicationContext()) + account.getAvatar();
|
||||
|
@ -498,13 +496,28 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
|
|||
if( Build.VERSION.SDK_INT >= 21) {
|
||||
|
||||
AppBarLayout appBar = (AppBarLayout) findViewById(R.id.appBar);
|
||||
maxScrollSize = appBar.getTotalScrollRange();
|
||||
appBar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
|
||||
@Override
|
||||
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
|
||||
if (Math.abs(verticalOffset)-appBarLayout.getTotalScrollRange() == 0) {
|
||||
pp_actionBar.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
pp_actionBar.setVisibility(View.GONE);
|
||||
if (maxScrollSize == 0)
|
||||
maxScrollSize = appBarLayout.getTotalScrollRange();
|
||||
|
||||
int percentage = (Math.abs(verticalOffset)) * 100 / maxScrollSize;
|
||||
|
||||
if (percentage >= 20 && avatarShown) {
|
||||
avatarShown = false;
|
||||
|
||||
account_pp.animate()
|
||||
.scaleY(0).scaleX(0)
|
||||
.setDuration(200)
|
||||
.start();
|
||||
}
|
||||
if (percentage <= 20 && !avatarShown) {
|
||||
avatarShown = true;
|
||||
account_pp.animate()
|
||||
.scaleY(1).scaleX(1)
|
||||
.start();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -148,7 +148,14 @@
|
|||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
</android.support.design.widget.CollapsingToolbarLayout>
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/materialup.toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
app:theme="@style/ThemeOverlay.AppCompat.Light"
|
||||
app:layout_scrollFlags="scroll|enterAlways|snap"
|
||||
/>
|
||||
<android.support.design.widget.TabLayout
|
||||
android:id="@+id/account_tabLayout"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
-->
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context="fr.gouv.etalab.mastodon.activities.ShowAccountActivity">
|
||||
<android.support.design.widget.AppBarLayout
|
||||
|
@ -34,13 +34,72 @@
|
|||
android:id="@+id/collapsingToolbarLayout"
|
||||
android:layout_height="@dimen/layout_height_header"
|
||||
android:fitsSystemWindows="true"
|
||||
app:layout_scrollFlags="scroll|enterAlwaysCollapsed">
|
||||
app:expandedTitleMarginStart="48dp"
|
||||
app:expandedTitleMarginEnd="64dp"
|
||||
app:layout_scrollFlags="scroll|snap">
|
||||
<ImageView
|
||||
android:id="@+id/banner_pp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
app:layout_collapseMode="parallax"
|
||||
/>
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:layout_gravity="end|bottom"
|
||||
android:visibility="gone"
|
||||
app:fabSize="mini"
|
||||
android:id="@+id/account_follow"
|
||||
android:textAllCaps="false"
|
||||
android:gravity="end|bottom"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
/>
|
||||
</android.support.design.widget.CollapsingToolbarLayout>
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
app:theme="@style/ThemeOverlay.AppCompat.Light"
|
||||
app:layout_scrollFlags="scroll|enterAlways|snap"
|
||||
>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="UseCompoundDrawables">
|
||||
<ImageView
|
||||
android:visibility="gone"
|
||||
android:id="@+id/pp_actionBar"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
tools:ignore="ContentDescription" />
|
||||
<TextView
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:id="@+id/show_account_title"
|
||||
android:maxLines="1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="?attr/actionBarTextColor"
|
||||
/>
|
||||
</LinearLayout>
|
||||
</android.support.v7.widget.Toolbar>
|
||||
<LinearLayout
|
||||
android:id="@+id/main_header_container"
|
||||
android:background="@color/mastodonC1"
|
||||
android:gravity="center_horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/layout_height_header"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
android:gravity="center"
|
||||
app:layout_scrollFlags="scroll|enterAlways|snap"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:id="@+id/header_container"
|
||||
|
@ -50,16 +109,12 @@
|
|||
android:orientation="horizontal"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
<ImageView
|
||||
android:padding="10dp"
|
||||
android:id="@+id/account_pp"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="80dp"
|
||||
tools:ignore="ContentDescription" />
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center_horizontal"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView
|
||||
android:id="@+id/account_dn"
|
||||
|
@ -126,22 +181,12 @@
|
|||
/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:layout_gravity="center"
|
||||
android:visibility="gone"
|
||||
app:fabSize="mini"
|
||||
android:id="@+id/account_follow"
|
||||
android:textAllCaps="false"
|
||||
android:gravity="center"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:id="@+id/account_note"
|
||||
android:padding="10dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:gravity="center"
|
||||
android:textColor="?attr/color_in_account_header"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -149,16 +194,14 @@
|
|||
android:autoLink="web"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
</android.support.design.widget.CollapsingToolbarLayout>
|
||||
|
||||
<android.support.design.widget.TabLayout
|
||||
android:id="@+id/account_tabLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"
|
||||
app:tabMode="fixed"
|
||||
app:tabGravity="fill"
|
||||
/>
|
||||
<android.support.design.widget.TabLayout
|
||||
android:id="@+id/account_tabLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"
|
||||
app:tabMode="fixed"
|
||||
app:tabGravity="fill"
|
||||
/>
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
<android.support.v4.view.ViewPager
|
||||
android:id="@+id/account_viewpager"
|
||||
|
@ -167,4 +210,17 @@
|
|||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
/>
|
||||
|
||||
<de.hdodenhof.circleimageview.CircleImageView
|
||||
android:padding="10dp"
|
||||
android:id="@+id/account_pp"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="150dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
app:layout_anchor="@id/main_header_container"
|
||||
android:elevation="8dp"
|
||||
app:civ_border_width="2dp"
|
||||
app:civ_border_color="#FFF"
|
||||
app:layout_scrollFlags="scroll"
|
||||
app:layout_anchorGravity="top|center_horizontal"
|
||||
/>
|
||||
</android.support.design.widget.CoordinatorLayout>
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="layout_height_header">250dp</dimen>
|
||||
<dimen name="layout_height_header">200dp</dimen>
|
||||
</resources>
|
|
@ -6,5 +6,5 @@
|
|||
<dimen name="activity_vertical_margin">30dp</dimen>
|
||||
<dimen name="activity_padding_top_header">16dp</dimen>
|
||||
<bool name="isTablet">true</bool>
|
||||
<dimen name="layout_height_header">300dp</dimen>
|
||||
<dimen name="layout_height_header">250dp</dimen>
|
||||
</resources>
|
|
@ -9,5 +9,5 @@
|
|||
<dimen name="drawer_padding">2dp</dimen>
|
||||
<dimen name="toot_padding">20dp</dimen>
|
||||
<bool name="isTablet">false</bool>
|
||||
<dimen name="layout_height_header">250dp</dimen>
|
||||
<dimen name="layout_height_header">200dp</dimen>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue