mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
fix for issue #719
This commit is contained in:
parent
4154a7c9d2
commit
99f4f376bd
2 changed files with 40 additions and 1 deletions
|
|
@ -1,5 +1,7 @@
|
|||
package fr.free.nrw.commons.theme;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.support.annotation.NonNull;
|
||||
|
|
@ -9,7 +11,9 @@ import android.support.v7.app.ActionBarDrawerToggle;
|
|||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import butterknife.BindView;
|
||||
|
|
@ -18,6 +22,7 @@ import fr.free.nrw.commons.BuildConfig;
|
|||
import fr.free.nrw.commons.CommonsApplication;
|
||||
import fr.free.nrw.commons.R;
|
||||
import fr.free.nrw.commons.WelcomeActivity;
|
||||
import fr.free.nrw.commons.auth.AccountUtil;
|
||||
import fr.free.nrw.commons.auth.LoginActivity;
|
||||
import fr.free.nrw.commons.contributions.ContributionsActivity;
|
||||
import fr.free.nrw.commons.nearby.NearbyActivity;
|
||||
|
|
@ -34,6 +39,8 @@ public abstract class NavigationBaseActivity extends BaseActivity
|
|||
@BindView(R.id.drawer_layout)
|
||||
DrawerLayout drawerLayout;
|
||||
|
||||
TextView username;
|
||||
|
||||
private ActionBarDrawerToggle toggle;
|
||||
|
||||
public void initDrawer() {
|
||||
|
|
@ -47,6 +54,18 @@ public abstract class NavigationBaseActivity extends BaseActivity
|
|||
toggle.setDrawerIndicatorEnabled(true);
|
||||
toggle.syncState();
|
||||
setDrawerPaneWidth();
|
||||
|
||||
View navHeaderView= navigationView.getHeaderView(0);
|
||||
username = (TextView) navHeaderView.findViewById(R.id.username);
|
||||
setUserName();
|
||||
}
|
||||
|
||||
public void setUserName() {
|
||||
AccountManager accountManager = AccountManager.get(this);
|
||||
Account[] allAccounts = accountManager.getAccountsByType(AccountUtil.accountType());
|
||||
if (allAccounts.length != 0) {
|
||||
username.setText(allAccounts[0].name);
|
||||
}
|
||||
}
|
||||
|
||||
public void initBackButton() {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,28 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent"
|
||||
android:background="@android:color/darker_gray">
|
||||
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/pictureOfTheDay"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="172dp"
|
||||
android:background="@android:color/darker_gray"
|
||||
android:padding="16dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:src="@drawable/commons_logo_large"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/username"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="TextView"
|
||||
android:textColor="@color/item_white_background"
|
||||
android:textSize="22sp"
|
||||
android:layout_below="@+id/pictureOfTheDay"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:paddingBottom="5dp"/>
|
||||
|
||||
</RelativeLayout>
|
||||
Loading…
Add table
Add a link
Reference in a new issue