Merge pull request #826 from Nethermane/master

Adding username to Drawer
This commit is contained in:
neslihanturan 2017-08-09 10:43:45 +03:00 committed by GitHub
commit 9ea805f9f5
3 changed files with 34 additions and 6 deletions

View file

@ -58,7 +58,6 @@ class LoginTask extends AsyncTask<String, String, String> {
protected void onPostExecute(String result) {
super.onPostExecute(result);
Timber.d("Login done!");
EventLog.schema(CommonsApplication.EVENT_LOGIN_ATTEMPT)
.param("username", username)
.param("result", result)

View file

@ -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.DialogInterface;
import android.content.Intent;
@ -10,9 +12,11 @@ import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
import butterknife.BindView;
@ -39,9 +43,15 @@ public class NavigationBaseActivity extends BaseActivity
DrawerLayout drawerLayout;
private ActionBarDrawerToggle toggle;
private String username;
private TextView usernameTextView;
public void initDrawer() {
navigationView.setNavigationItemSelectedListener(this);
username = CommonsApplication.getInstance().getCurrentAccount().name;
usernameTextView = ((TextView) navigationView.getHeaderView(0)
.findViewById(R.id.userNameText));
usernameTextView.setText(username != null ? username : "");
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);