Skip to content

Commit 7549638

Browse files
Merge pull request commons-app#929 from JohnKal/master
fix for issue commons-app#719
2 parents 647d7bc + aab792f commit 7549638

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

app/src/main/java/fr/free/nrw/commons/theme/NavigationBaseActivity.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package fr.free.nrw.commons.theme;
22

3+
import android.accounts.Account;
4+
import android.accounts.AccountManager;
35
import android.content.ActivityNotFoundException;
46
import android.content.Intent;
57
import android.support.annotation.NonNull;
@@ -9,7 +11,9 @@
911
import android.support.v7.app.AlertDialog;
1012
import android.support.v7.widget.Toolbar;
1113
import android.view.MenuItem;
14+
import android.view.View;
1215
import android.view.ViewGroup;
16+
import android.widget.TextView;
1317
import android.widget.Toast;
1418

1519
import butterknife.BindView;
@@ -18,6 +22,7 @@
1822
import fr.free.nrw.commons.CommonsApplication;
1923
import fr.free.nrw.commons.R;
2024
import fr.free.nrw.commons.WelcomeActivity;
25+
import fr.free.nrw.commons.auth.AccountUtil;
2126
import fr.free.nrw.commons.auth.LoginActivity;
2227
import fr.free.nrw.commons.contributions.ContributionsActivity;
2328
import fr.free.nrw.commons.nearby.NearbyActivity;
@@ -47,6 +52,22 @@ public void initDrawer() {
4752
toggle.setDrawerIndicatorEnabled(true);
4853
toggle.syncState();
4954
setDrawerPaneWidth();
55+
setUserName();
56+
}
57+
58+
/**
59+
* Set the username in navigationHeader.
60+
*/
61+
private void setUserName() {
62+
63+
View navHeaderView = navigationView.getHeaderView(0);
64+
TextView username = (TextView) navHeaderView.findViewById(R.id.username);
65+
66+
AccountManager accountManager = AccountManager.get(this);
67+
Account[] allAccounts = accountManager.getAccountsByType(AccountUtil.accountType());
68+
if (allAccounts.length != 0) {
69+
username.setText(allAccounts[0].name);
70+
}
5071
}
5172

5273
public void initBackButton() {
Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,28 @@
11
<?xml version="1.0" encoding="utf-8"?>
2+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_height="match_parent"
4+
android:layout_width="match_parent"
5+
android:background="@android:color/darker_gray">
26
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
37
android:id="@+id/pictureOfTheDay"
48
android:layout_width="match_parent"
59
android:layout_height="172dp"
610
android:background="@android:color/darker_gray"
7-
android:padding="16dp"
11+
android:paddingLeft="16dp"
12+
android:paddingTop="16dp"
13+
android:paddingRight="16dp"
14+
android:paddingBottom="5dp"
815
android:src="@drawable/commons_logo_large"/>
16+
17+
<TextView
18+
android:id="@+id/username"
19+
android:layout_width="wrap_content"
20+
android:layout_height="wrap_content"
21+
android:text="TextView"
22+
android:textColor="@color/item_white_background"
23+
android:textSize="22sp"
24+
android:layout_below="@+id/pictureOfTheDay"
25+
android:layout_centerHorizontal="true"
26+
android:paddingBottom="5dp"/>
27+
28+
</RelativeLayout>

0 commit comments

Comments
 (0)