Some fixes
This commit is contained in:
parent
f095922970
commit
5aeffb8ad7
|
@ -109,7 +109,6 @@ import static fr.gouv.etalab.mastodon.helper.Helper.PREF_KEY_ID;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
|
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.changeHamburgerIcon;
|
import static fr.gouv.etalab.mastodon.helper.Helper.changeHamburgerIcon;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.changeUser;
|
import static fr.gouv.etalab.mastodon.helper.Helper.changeUser;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.loadPPInActionBar;
|
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.menuAccounts;
|
import static fr.gouv.etalab.mastodon.helper.Helper.menuAccounts;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.unCheckAllMenuItems;
|
import static fr.gouv.etalab.mastodon.helper.Helper.unCheckAllMenuItems;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.updateHeaderAccountInfo;
|
import static fr.gouv.etalab.mastodon.helper.Helper.updateHeaderAccountInfo;
|
||||||
|
@ -406,8 +405,17 @@ public class MainActivity extends AppCompatActivity
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
toolbar_search.setQuery("", false);
|
toolbar_search.setQuery("", false);
|
||||||
toolbar_search.setIconified(true);
|
toolbar_search.setIconified(true);
|
||||||
toolbarTitle.setVisibility(View.VISIBLE);
|
if( main_app_container.getVisibility() == View.VISIBLE){
|
||||||
tabLayout.setVisibility(View.VISIBLE);
|
main_app_container.setVisibility(View.VISIBLE);
|
||||||
|
viewPager.setVisibility(View.GONE);
|
||||||
|
tabLayout.setVisibility(View.GONE);
|
||||||
|
toolbarTitle.setVisibility(View.VISIBLE);
|
||||||
|
}else {
|
||||||
|
main_app_container.setVisibility(View.GONE);
|
||||||
|
viewPager.setVisibility(View.VISIBLE);
|
||||||
|
tabLayout.setVisibility(View.VISIBLE);
|
||||||
|
toolbarTitle.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
@ -496,15 +504,12 @@ public class MainActivity extends AppCompatActivity
|
||||||
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
||||||
drawer.addDrawerListener(toggle);
|
drawer.addDrawerListener(toggle);
|
||||||
toggle.setDrawerIndicatorEnabled(false);
|
toggle.setDrawerIndicatorEnabled(false);
|
||||||
changeHamburgerIcon(MainActivity.this, account.getAvatar(), toggle);
|
changeHamburgerIcon(MainActivity.this, account.getAvatar());
|
||||||
toggle.syncState();
|
toggle.syncState();
|
||||||
|
|
||||||
|
|
||||||
headerLayout = navigationView.getHeaderView(0);
|
headerLayout = navigationView.getHeaderView(0);
|
||||||
|
|
||||||
|
|
||||||
updateHeaderAccountInfo(MainActivity.this, account, headerLayout, imageLoader, options);
|
updateHeaderAccountInfo(MainActivity.this, account, headerLayout, imageLoader, options);
|
||||||
loadPPInActionBar(MainActivity.this, account.getAvatar());
|
|
||||||
//Locked account can see follow request
|
//Locked account can see follow request
|
||||||
if (account.isLocked()) {
|
if (account.isLocked()) {
|
||||||
navigationView.getMenu().findItem(R.id.nav_follow_request).setVisible(true);
|
navigationView.getMenu().findItem(R.id.nav_follow_request).setVisible(true);
|
||||||
|
|
|
@ -20,6 +20,8 @@ package fr.gouv.etalab.mastodon.helper;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.PorterDuffXfermode;
|
import android.graphics.PorterDuffXfermode;
|
||||||
|
import android.graphics.Rect;
|
||||||
|
import android.graphics.RectF;
|
||||||
import android.support.annotation.RequiresApi;
|
import android.support.annotation.RequiresApi;
|
||||||
import android.support.v7.app.ActionBarDrawerToggle;
|
import android.support.v7.app.ActionBarDrawerToggle;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
|
@ -959,12 +961,26 @@ public class Helper {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap,int roundPixelSize) {
|
||||||
|
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
|
||||||
|
Canvas canvas = new Canvas(output);
|
||||||
|
final Paint paint = new Paint();
|
||||||
|
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
|
||||||
|
final RectF rectF = new RectF(rect);
|
||||||
|
final float roundPx = roundPixelSize;
|
||||||
|
paint.setAntiAlias(true);
|
||||||
|
canvas.drawRoundRect(rectF,roundPx,roundPx, paint);
|
||||||
|
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
|
||||||
|
canvas.drawBitmap(bitmap, rect, rect, paint);
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the profile picture at the place of hamburger icon
|
* Load the profile picture at the place of hamburger icon
|
||||||
* @param activity Activity The current activity
|
* @param activity Activity The current activity
|
||||||
* @param url String the url of the profile picture
|
* @param url String the url of the profile picture
|
||||||
*/
|
*/
|
||||||
public static void changeHamburgerIcon(final Activity activity, String url, ActionBarDrawerToggle toggle){
|
public static void changeHamburgerIcon(final Activity activity, String url){
|
||||||
ImageLoader imageLoader;
|
ImageLoader imageLoader;
|
||||||
DisplayImageOptions options = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false)
|
DisplayImageOptions options = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false)
|
||||||
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
|
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
|
||||||
|
@ -977,8 +993,8 @@ public class Helper {
|
||||||
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
|
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
|
||||||
super.onLoadingComplete(imageUri, view, loadedImage);
|
super.onLoadingComplete(imageUri, view, loadedImage);
|
||||||
Resources res = activity.getResources();
|
Resources res = activity.getResources();
|
||||||
Bitmap loadedImageResized = Bitmap.createScaledBitmap(loadedImage, (int)convertDpToPixel(30, activity), (int)convertDpToPixel(30, activity), true);
|
Bitmap loadedImageResized = Bitmap.createScaledBitmap(loadedImage, (int)convertDpToPixel(40, activity), (int)convertDpToPixel(40, activity), true);
|
||||||
BitmapDrawable icon = new BitmapDrawable(res, loadedImageResized);
|
BitmapDrawable icon = new BitmapDrawable(res, getRoundedCornerBitmap(loadedImageResized, 90));
|
||||||
if( ((MainActivity)activity).getSupportActionBar() != null)
|
if( ((MainActivity)activity).getSupportActionBar() != null)
|
||||||
((MainActivity)activity).getSupportActionBar().setIcon(icon);
|
((MainActivity)activity).getSupportActionBar().setIcon(icon);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import android.os.Bundle;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
|
|
@ -1,41 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
Copyright 2017 Thomas Schneider
|
|
||||||
|
|
||||||
This file is a part of Mastalab
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under the terms of the
|
|
||||||
GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
|
||||||
License, or (at your option) any later version.
|
|
||||||
|
|
||||||
Mastalab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
|
||||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
||||||
Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License along with Mastalab; if not,
|
|
||||||
see <http://www.gnu.org/licenses>.
|
|
||||||
-->
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="center_vertical">
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/tab_icon"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:layout_width="30dp"
|
|
||||||
android:layout_height="30dp" />
|
|
||||||
<TextView
|
|
||||||
android:layout_marginStart="20dp"
|
|
||||||
android:layout_marginLeft="20dp"
|
|
||||||
android:id="@+id/tab_counter"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:gravity="center"
|
|
||||||
android:textSize="14sp"
|
|
||||||
android:minWidth="30dp"
|
|
||||||
android:minHeight="30dp"
|
|
||||||
android:textColor="@color/mastodonC1"
|
|
||||||
android:background="@drawable/shape_counter"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"/>
|
|
||||||
</LinearLayout>
|
|
|
@ -15,27 +15,30 @@
|
||||||
You should have received a copy of the GNU General Public License along with Mastalab; if not,
|
You should have received a copy of the GNU General Public License along with Mastalab; if not,
|
||||||
see <http://www.gnu.org/licenses>.
|
see <http://www.gnu.org/licenses>.
|
||||||
-->
|
-->
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
android:gravity="center_vertical">
|
android:gravity="center_vertical">
|
||||||
<ImageView
|
|
||||||
android:id="@+id/tab_icon"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_marginStart="10dp"
|
|
||||||
android:layout_marginLeft="10dp"
|
|
||||||
android:id="@+id/tab_counter"
|
android:id="@+id/tab_counter"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
|
android:paddingLeft="2dp"
|
||||||
|
android:paddingRight="2dp"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:textSize="10sp"
|
android:textSize="12sp"
|
||||||
android:minWidth="20dp"
|
|
||||||
android:minHeight="20dp"
|
|
||||||
android:textColor="@color/mastodonC1"
|
android:textColor="@color/mastodonC1"
|
||||||
android:background="@drawable/shape_counter"
|
android:background="@drawable/shape_counter"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"/>
|
||||||
</LinearLayout>
|
<ImageView
|
||||||
|
android:id="@+id/tab_icon"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
</RelativeLayout>
|
|
@ -111,7 +111,6 @@ import static fr.gouv.etalab.mastodon.helper.Helper.PREF_KEY_ID;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
|
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.changeHamburgerIcon;
|
import static fr.gouv.etalab.mastodon.helper.Helper.changeHamburgerIcon;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.changeUser;
|
import static fr.gouv.etalab.mastodon.helper.Helper.changeUser;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.loadPPInActionBar;
|
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.menuAccounts;
|
import static fr.gouv.etalab.mastodon.helper.Helper.menuAccounts;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.unCheckAllMenuItems;
|
import static fr.gouv.etalab.mastodon.helper.Helper.unCheckAllMenuItems;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.updateHeaderAccountInfo;
|
import static fr.gouv.etalab.mastodon.helper.Helper.updateHeaderAccountInfo;
|
||||||
|
@ -410,8 +409,17 @@ public class MainActivity extends AppCompatActivity
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
toolbar_search.setQuery("", false);
|
toolbar_search.setQuery("", false);
|
||||||
toolbar_search.setIconified(true);
|
toolbar_search.setIconified(true);
|
||||||
toolbarTitle.setVisibility(View.VISIBLE);
|
if( main_app_container.getVisibility() == View.VISIBLE){
|
||||||
tabLayout.setVisibility(View.VISIBLE);
|
main_app_container.setVisibility(View.VISIBLE);
|
||||||
|
viewPager.setVisibility(View.GONE);
|
||||||
|
tabLayout.setVisibility(View.GONE);
|
||||||
|
toolbarTitle.setVisibility(View.VISIBLE);
|
||||||
|
}else {
|
||||||
|
main_app_container.setVisibility(View.GONE);
|
||||||
|
viewPager.setVisibility(View.VISIBLE);
|
||||||
|
tabLayout.setVisibility(View.VISIBLE);
|
||||||
|
toolbarTitle.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
@ -500,15 +508,12 @@ public class MainActivity extends AppCompatActivity
|
||||||
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
||||||
drawer.addDrawerListener(toggle);
|
drawer.addDrawerListener(toggle);
|
||||||
toggle.setDrawerIndicatorEnabled(false);
|
toggle.setDrawerIndicatorEnabled(false);
|
||||||
changeHamburgerIcon(MainActivity.this, account.getAvatar(), toggle);
|
changeHamburgerIcon(MainActivity.this, account.getAvatar());
|
||||||
toggle.syncState();
|
toggle.syncState();
|
||||||
|
|
||||||
|
|
||||||
headerLayout = navigationView.getHeaderView(0);
|
headerLayout = navigationView.getHeaderView(0);
|
||||||
|
|
||||||
|
|
||||||
updateHeaderAccountInfo(MainActivity.this, account, headerLayout, imageLoader, options);
|
updateHeaderAccountInfo(MainActivity.this, account, headerLayout, imageLoader, options);
|
||||||
loadPPInActionBar(MainActivity.this, account.getAvatar());
|
|
||||||
//Locked account can see follow request
|
//Locked account can see follow request
|
||||||
if (account.isLocked()) {
|
if (account.isLocked()) {
|
||||||
navigationView.getMenu().findItem(R.id.nav_follow_request).setVisible(true);
|
navigationView.getMenu().findItem(R.id.nav_follow_request).setVisible(true);
|
||||||
|
|
Loading…
Reference in New Issue