From 9fa178d513f5f008166ba7053fe9aa02cbb1d17a Mon Sep 17 00:00:00 2001 From: Amine Date: Sat, 2 Sep 2017 17:55:02 +0200 Subject: [PATCH] Closes #71 --- .../bou/readerforselfoss/HomeActivity.kt | 63 ++++++++++++------ app/src/main/res/drawable/bg.png | Bin 0 -> 406 bytes app/src/main/res/values/styles.xml | 15 +++++ 3 files changed, 57 insertions(+), 21 deletions(-) create mode 100644 app/src/main/res/drawable/bg.png diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt index 3e11402..d5bff16 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt @@ -64,6 +64,10 @@ import com.ashokvarma.bottomnavigation.BottomNavigationBar import com.ashokvarma.bottomnavigation.BottomNavigationItem import com.ashokvarma.bottomnavigation.TextBadgeItem import com.ftinc.scoop.Scoop +import com.mikepenz.materialdrawer.AccountHeader +import com.mikepenz.materialdrawer.AccountHeaderBuilder +import com.mikepenz.materialdrawer.holder.DimenHolder +import com.mikepenz.materialdrawer.model.ProfileDrawerItem class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener { @@ -150,7 +154,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener { handleBottomBar() - handleDrawer() + handleDrawer(dirtyPref) coordinatorLayout = findViewById(R.id.coordLayout) swipeRefreshLayout = findViewById(R.id.swipeRefreshLayout) @@ -291,10 +295,25 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener { userIdentifier = sharedPref.getString("unique_id", "") } - private fun handleDrawer() { + private fun handleDrawer(dirtyPref: SharedPreferences) { + + val headerResult: AccountHeader = AccountHeaderBuilder() + .withActivity(this) + .withHeaderBackground(R.drawable.bg) + .addProfiles( + ProfileDrawerItem() + .withName( + dirtyPref.getString("url", "") + ) + .withIcon(resources.getDrawable(R.mipmap.ic_launcher)) + ) + .withSelectionListEnabledForSingleProfile(false) + .build() drawer = DrawerBuilder() .withActivity(this) + .withAccountHeader(headerResult) + .withHeaderHeight(DimenHolder.fromDp(140)) .withRootView(R.id.drawer_layout) .withToolbar(toolbar) .withActionBarDrawerToggle(true) @@ -316,25 +335,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener { }) .build() - drawer.addStickyFooterItem( - PrimaryDrawerItem() - .withName(R.string.action_about) - .withSelectable(false) - .withIcon(R.drawable.ic_info_outline) - .withIconTintingEnabled(true) - .withOnDrawerItemClickListener { _, _, _ -> - LibsBuilder() - .withActivityStyle( - if (appColors.isDarkTheme) - Libs.ActivityStyle.LIGHT_DARK_TOOLBAR - else - Libs.ActivityStyle.DARK - ) - .withAboutIconShown(true) - .withAboutVersionShown(true) - .start(this@HomeActivity) - false - }) drawer.addStickyFooterItem( PrimaryDrawerItem() .withName(R.string.title_activity_settings) @@ -438,6 +438,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener { .withIdentifier(DRAWER_ID_TAGS) .withSelectable(false)) handleTags(maybeDrawerData.tags) + drawer.addItem(DividerDrawerItem()) drawer.addItem( SecondaryDrawerItem() .withName(getString(R.string.drawer_item_sources)) @@ -450,6 +451,26 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener { } ) handleSources(maybeDrawerData.sources) + drawer.addItem(DividerDrawerItem()) + drawer.addItem( + PrimaryDrawerItem() + .withName(R.string.action_about) + .withSelectable(false) + .withIcon(R.drawable.ic_info_outline) + .withIconTintingEnabled(true) + .withOnDrawerItemClickListener { _, _, _ -> + LibsBuilder() + .withActivityStyle( + if (appColors.isDarkTheme) + Libs.ActivityStyle.LIGHT_DARK_TOOLBAR + else + Libs.ActivityStyle.DARK + ) + .withAboutIconShown(true) + .withAboutVersionShown(true) + .start(this@HomeActivity) + false + }) if (!loadedFromCache) diff --git a/app/src/main/res/drawable/bg.png b/app/src/main/res/drawable/bg.png new file mode 100644 index 0000000000000000000000000000000000000000..d93c122cdd5100cff036e92571da62d6e62661bf GIT binary patch literal 406 zcmeAS@N?(olHy`uVBq!ia0vp^D}XqRg9%7p+33{;q?n7HJVQ7*IBq}me*okPl(fHZESiJly2F>Bjwjck5h>}pxP|$%EZ^#at>Wvd$VP2^k&ZJ?P-@M<_2!sn%}*yDth|W+q>4> zlS}*h&0zKQ4OPcqnXZXD3?uGstl|ZULWy!Dskr2;o58vdgLO-Vtxx>gcQrd=ZyTIQ z{t6a_67P|uY*&}BxpyrUWaswwNQf5Ps)6#>AmgD1oqr_@)TM30e@E7C!cQ*woxqS~ N@O1TaS?83{1ONr4zZC!g literal 0 HcmV?d00001 diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 4f95805..b9c1081 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -13,6 +13,7 @@ @color/md_grey_50 @color/md_grey_900 @color/md_grey_400 + @color/md_grey_900 @@ -162,6 +175,7 @@ @color/md_grey_50 @color/md_grey_900 @color/md_grey_400 + @color/md_grey_900