Add user display name support

This commit is contained in:
Mario Danic 2017-01-26 05:07:34 +01:00 committed by AndyScherzinger
parent e260609e31
commit 28d6ccb7d6
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
2 changed files with 30 additions and 11 deletions

View file

@ -5,6 +5,7 @@ import android.os.Bundle;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
@ -37,9 +38,9 @@ import butterknife.Unbinder;
public class UserInfoActivity extends FileActivity {
private static final String TAG = UserInfoActivity.class.getSimpleName();
protected static final String KEY_USER_DATA = "USER_DATA";
protected static final String KEY_NEXTCLOUD_ACCOUNT = "NEXTCLOUD_ACCOUNT";
private static final String KEY_USER_DATA = "USER_DATA";
private static final String KEY_ACCOUNT = "ACCOUNT";
private static final String KEY_DISPLAY_NAME = "DISPLAY_NAME";
@BindView(R.id.generic_rv)
RecyclerView genericRecyclerView;
@ -71,6 +72,8 @@ public class UserInfoActivity extends FileActivity {
private UserInfo userInfo;
private Account account;
private String displayName;
@Override
public void onCreate(Bundle savedInstanceState) {
Log_OC.v(TAG, "onCreate() start");
@ -78,15 +81,27 @@ public class UserInfoActivity extends FileActivity {
Bundle bundle = getIntent().getExtras();
if (bundle.containsKey(KEY_NEXTCLOUD_ACCOUNT)) {
account = Parcels.unwrap(bundle.getParcelable(KEY_NEXTCLOUD_ACCOUNT));
account = Parcels.unwrap(bundle.getParcelable(KEY_ACCOUNT));
if (savedInstanceState != null && savedInstanceState.containsKey(KEY_USER_DATA)) {
userInfo = Parcels.unwrap(savedInstanceState.getParcelable(KEY_USER_DATA));
}
if (bundle.containsKey(KEY_DISPLAY_NAME)) {
displayName = bundle.getString(KEY_DISPLAY_NAME);
} else if (userInfo != null && !TextUtils.isEmpty(userInfo.getDisplayName())) {
displayName = userInfo.getDisplayName();
}
setContentView(R.layout.user_info_layout);
unbinder = ButterKnife.bind(this);
setupToolbar();
updateActionBarTitleAndHomeButtonByString(getResources().getString(R.string.user_information_description));
if (!TextUtils.isEmpty(displayName)) {
updateActionBarTitleAndHomeButtonByString(displayName);
} else {
updateActionBarTitleAndHomeButtonByString(getResources().getString(R.string.user_information_description));
}
layoutManager = new LinearLayoutManager(this);
genericRecyclerView.setLayoutManager(layoutManager);
@ -95,8 +110,7 @@ public class UserInfoActivity extends FileActivity {
((LinearLayoutManager)layoutManager).getOrientation());
genericRecyclerView.addItemDecoration(dividerItemDecoration);
if (savedInstanceState != null && savedInstanceState.containsKey(KEY_USER_DATA)) {
userInfo = Parcels.unwrap(savedInstanceState.getParcelable(KEY_USER_DATA));
if (userInfo != null) {
adapter = new UserInfoAdapter(userInfo, UserInfoActivity.this);
multiView.setVisibility(View.VISIBLE);
genericRecyclerView.setVisibility(View.GONE);

View file

@ -72,8 +72,6 @@ public class ManageAccountsActivity extends FileActivity
private static final String KEY_ACCOUNT = "ACCOUNT";
private static final String KEY_DISPLAY_NAME = "DISPLAY_NAME";
private static final int KEY_USER_INFO_REQUEST_CODE = 13;
private static final int KEY_DELETE_CODE = 101;
private ListView mListView;
private final Handler mHandler = new Handler();
@ -118,7 +116,14 @@ public class ManageAccountsActivity extends FileActivity
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Account account = mAccountListAdapter.getItem(position).getAccount();
intent.putExtra("NEXTCLOUD_ACCOUNT", Parcels.wrap(account));
intent.putExtra(KEY_ACCOUNT, Parcels.wrap(account));
try {
OwnCloudAccount oca = new OwnCloudAccount(account, MainApp.getAppContext());
intent.putExtra(KEY_DISPLAY_NAME, oca.getDisplayName());
} catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) {
Log_OC.d(TAG, "Failed to find NC account");
}
startActivity(intent);
}
});