mirror of https://github.com/readrops/Readrops.git
Add drawer account header
This commit is contained in:
parent
4985604289
commit
2ecc707d0e
|
@ -9,6 +9,7 @@ import android.view.ActionMode;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -38,6 +39,7 @@ import com.mikepenz.materialdrawer.Drawer;
|
||||||
import com.mikepenz.materialdrawer.DrawerBuilder;
|
import com.mikepenz.materialdrawer.DrawerBuilder;
|
||||||
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem;
|
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem;
|
||||||
import com.mikepenz.materialdrawer.model.ProfileDrawerItem;
|
import com.mikepenz.materialdrawer.model.ProfileDrawerItem;
|
||||||
|
import com.mikepenz.materialdrawer.model.ProfileSettingDrawerItem;
|
||||||
import com.mikepenz.materialdrawer.model.SecondaryDrawerItem;
|
import com.mikepenz.materialdrawer.model.SecondaryDrawerItem;
|
||||||
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
|
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
|
||||||
import com.readrops.app.R;
|
import com.readrops.app.R;
|
||||||
|
@ -64,9 +66,11 @@ import io.reactivex.schedulers.Schedulers;
|
||||||
public class MainActivity extends AppCompatActivity implements SwipeRefreshLayout.OnRefreshListener {
|
public class MainActivity extends AppCompatActivity implements SwipeRefreshLayout.OnRefreshListener {
|
||||||
|
|
||||||
public static final String TAG = MainActivity.class.getSimpleName();
|
public static final String TAG = MainActivity.class.getSimpleName();
|
||||||
|
|
||||||
public static final int ADD_FEED_REQUEST = 1;
|
public static final int ADD_FEED_REQUEST = 1;
|
||||||
public static final int MANAGE_FEEDS_REQUEST = 2;
|
public static final int MANAGE_FEEDS_REQUEST = 2;
|
||||||
public static final int ITEM_REQUEST = 3;
|
public static final int ITEM_REQUEST = 3;
|
||||||
|
public static final int ADD_ACCOUNT_REQUEST = 4;
|
||||||
|
|
||||||
private RecyclerView recyclerView;
|
private RecyclerView recyclerView;
|
||||||
private MainItemListAdapter adapter;
|
private MainItemListAdapter adapter;
|
||||||
|
@ -143,20 +147,40 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
|
||||||
|
|
||||||
private void buildDrawer() {
|
private void buildDrawer() {
|
||||||
ProfileDrawerItem profileItem = new ProfileDrawerItem()
|
ProfileDrawerItem profileItem = new ProfileDrawerItem()
|
||||||
|
.withIcon(R.drawable.ic_nextcloud_news)
|
||||||
.withName(account.getDisplayedName())
|
.withName(account.getDisplayedName())
|
||||||
.withEmail(account.getAccountName());
|
.withEmail(account.getAccountName());
|
||||||
|
|
||||||
|
ProfileSettingDrawerItem profileSettingsItem = new ProfileSettingDrawerItem()
|
||||||
|
.withName(getString(R.string.account_settings))
|
||||||
|
.withIcon(R.drawable.ic_account);
|
||||||
|
|
||||||
|
ProfileSettingDrawerItem addAccountSettingsItem = new ProfileSettingDrawerItem()
|
||||||
|
.withName(getString(R.string.add_account))
|
||||||
|
.withIcon(R.drawable.ic_add_account_grey)
|
||||||
|
.withOnDrawerItemClickListener((view, position, drawerItem) -> {
|
||||||
|
Intent intent = new Intent(this, AddAccountActivity.class);
|
||||||
|
startActivityForResult(intent, ADD_ACCOUNT_REQUEST);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
AccountHeader header = new AccountHeaderBuilder()
|
AccountHeader header = new AccountHeaderBuilder()
|
||||||
.withActivity(this)
|
.withActivity(this)
|
||||||
.addProfiles(profileItem)
|
.addProfiles(profileItem, profileSettingsItem, addAccountSettingsItem)
|
||||||
|
.withDividerBelowHeader(false)
|
||||||
|
.withAlternativeProfileHeaderSwitching(true)
|
||||||
.withCurrentProfileHiddenInList(true)
|
.withCurrentProfileHiddenInList(true)
|
||||||
.withTextColorRes(R.color.colorPrimary)
|
.withTextColorRes(R.color.colorBackground)
|
||||||
|
.withHeaderBackground(R.drawable.header_background)
|
||||||
|
.withHeaderBackgroundScaleType(ImageView.ScaleType.CENTER_CROP)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
drawer = new DrawerBuilder()
|
drawer = new DrawerBuilder()
|
||||||
.withActivity(this)
|
.withActivity(this)
|
||||||
.withToolbar(toolbar)
|
.withToolbar(toolbar)
|
||||||
.withAccountHeader(header)
|
.withAccountHeader(header)
|
||||||
|
.withSelectedItem(DrawerManager.ARTICLES_ITEM_ID)
|
||||||
.withOnDrawerItemClickListener((view, position, drawerItem) -> {
|
.withOnDrawerItemClickListener((view, position, drawerItem) -> {
|
||||||
handleDrawerClick(drawerItem);
|
handleDrawerClick(drawerItem);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -2,8 +2,6 @@ package com.readrops.app.utils;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import androidx.annotation.ColorInt;
|
|
||||||
|
|
||||||
import com.mikepenz.materialdrawer.Drawer;
|
import com.mikepenz.materialdrawer.Drawer;
|
||||||
import com.mikepenz.materialdrawer.model.DividerDrawerItem;
|
import com.mikepenz.materialdrawer.model.DividerDrawerItem;
|
||||||
import com.mikepenz.materialdrawer.model.ExpandableBadgeDrawerItem;
|
import com.mikepenz.materialdrawer.model.ExpandableBadgeDrawerItem;
|
||||||
|
@ -90,11 +88,13 @@ public class DrawerManager {
|
||||||
PrimaryDrawerItem articles = new PrimaryDrawerItem()
|
PrimaryDrawerItem articles = new PrimaryDrawerItem()
|
||||||
.withName(context.getString(R.string.articles))
|
.withName(context.getString(R.string.articles))
|
||||||
.withIcon(context.getDrawable(R.drawable.ic_rss_feed_grey))
|
.withIcon(context.getDrawable(R.drawable.ic_rss_feed_grey))
|
||||||
|
.withSelectable(true)
|
||||||
.withIdentifier(ARTICLES_ITEM_ID);
|
.withIdentifier(ARTICLES_ITEM_ID);
|
||||||
|
|
||||||
PrimaryDrawerItem toReadLater = new PrimaryDrawerItem()
|
PrimaryDrawerItem toReadLater = new PrimaryDrawerItem()
|
||||||
.withName(context.getString(R.string.read_later))
|
.withName(context.getString(R.string.read_later))
|
||||||
.withIcon(context.getDrawable(R.drawable.ic_read_later_grey))
|
.withIcon(context.getDrawable(R.drawable.ic_read_later_grey))
|
||||||
|
.withSelectable(true)
|
||||||
.withIdentifier(READ_LATER_ID);
|
.withIdentifier(READ_LATER_ID);
|
||||||
|
|
||||||
drawer.addItem(articles);
|
drawer.addItem(articles);
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 151 KiB |
|
@ -0,0 +1,5 @@
|
||||||
|
<vector android:height="24dp" android:tint="#727272"
|
||||||
|
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="#FF000000" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,5c1.66,0 3,1.34 3,3s-1.34,3 -3,3 -3,-1.34 -3,-3 1.34,-3 3,-3zM12,19.2c-2.5,0 -4.71,-1.28 -6,-3.22 0.03,-1.99 4,-3.08 6,-3.08 1.99,0 5.97,1.09 6,3.08 -1.29,1.94 -3.5,3.22 -6,3.22z"/>
|
||||||
|
</vector>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<vector android:height="24dp" android:tint="#727272"
|
||||||
|
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="#FF000000" android:pathData="M15,12c2.21,0 4,-1.79 4,-4s-1.79,-4 -4,-4 -4,1.79 -4,4 1.79,4 4,4zM6,10L6,7L4,7v3L1,10v2h3v3h2v-3h3v-2L6,10zM15,14c-2.67,0 -8,1.34 -8,4v2h16v-2c0,-2.66 -5.33,-4 -8,-4z"/>
|
||||||
|
</vector>
|
|
@ -54,5 +54,7 @@
|
||||||
<string name="account_name">Nom du compte</string>
|
<string name="account_name">Nom du compte</string>
|
||||||
<string name="login">Identifiant</string>
|
<string name="login">Identifiant</string>
|
||||||
<string name="password">Mot de passe</string>
|
<string name="password">Mot de passe</string>
|
||||||
|
<string name="account_settings">Paramètres du compte</string>
|
||||||
|
<string name="add_account">Ajouter un compte</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
|
@ -57,4 +57,6 @@
|
||||||
<string name="login">Login</string>
|
<string name="login">Login</string>
|
||||||
<string name="password">Password</string>
|
<string name="password">Password</string>
|
||||||
<string name="nextcloud_news" translatable="false">Nextcloud News</string>
|
<string name="nextcloud_news" translatable="false">Nextcloud News</string>
|
||||||
|
<string name="account_settings">Account settings</string>
|
||||||
|
<string name="add_account">Add account</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in New Issue