This commit is contained in:
Amine 2017-09-02 17:55:02 +02:00
parent 043b184065
commit 9fa178d513
3 changed files with 57 additions and 21 deletions

View File

@ -64,6 +64,10 @@ import com.ashokvarma.bottomnavigation.BottomNavigationBar
import com.ashokvarma.bottomnavigation.BottomNavigationItem import com.ashokvarma.bottomnavigation.BottomNavigationItem
import com.ashokvarma.bottomnavigation.TextBadgeItem import com.ashokvarma.bottomnavigation.TextBadgeItem
import com.ftinc.scoop.Scoop 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 { class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
@ -150,7 +154,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
handleBottomBar() handleBottomBar()
handleDrawer() handleDrawer(dirtyPref)
coordinatorLayout = findViewById(R.id.coordLayout) coordinatorLayout = findViewById(R.id.coordLayout)
swipeRefreshLayout = findViewById(R.id.swipeRefreshLayout) swipeRefreshLayout = findViewById(R.id.swipeRefreshLayout)
@ -291,10 +295,25 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
userIdentifier = sharedPref.getString("unique_id", "") 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() drawer = DrawerBuilder()
.withActivity(this) .withActivity(this)
.withAccountHeader(headerResult)
.withHeaderHeight(DimenHolder.fromDp(140))
.withRootView(R.id.drawer_layout) .withRootView(R.id.drawer_layout)
.withToolbar(toolbar) .withToolbar(toolbar)
.withActionBarDrawerToggle(true) .withActionBarDrawerToggle(true)
@ -316,25 +335,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
}) })
.build() .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( drawer.addStickyFooterItem(
PrimaryDrawerItem() PrimaryDrawerItem()
.withName(R.string.title_activity_settings) .withName(R.string.title_activity_settings)
@ -438,6 +438,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
.withIdentifier(DRAWER_ID_TAGS) .withIdentifier(DRAWER_ID_TAGS)
.withSelectable(false)) .withSelectable(false))
handleTags(maybeDrawerData.tags) handleTags(maybeDrawerData.tags)
drawer.addItem(DividerDrawerItem())
drawer.addItem( drawer.addItem(
SecondaryDrawerItem() SecondaryDrawerItem()
.withName(getString(R.string.drawer_item_sources)) .withName(getString(R.string.drawer_item_sources))
@ -450,6 +451,26 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
} }
) )
handleSources(maybeDrawerData.sources) 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) if (!loadedFromCache)

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

View File

@ -13,6 +13,7 @@
<item name="android:colorBackground">@color/md_grey_50</item> <item name="android:colorBackground">@color/md_grey_50</item>
<item name="android:textColorPrimary">@color/md_grey_900</item> <item name="android:textColorPrimary">@color/md_grey_900</item>
<item name="android:textColorSecondary">@color/md_grey_400</item> <item name="android:textColorSecondary">@color/md_grey_400</item>
<item name="material_drawer_header_selection_text">@color/md_grey_900</item>
</style> </style>
<style name="NoBarDark" parent="MaterialDrawerTheme"> <style name="NoBarDark" parent="MaterialDrawerTheme">
@ -25,12 +26,14 @@
<item name="bnbBackgroundColor">@color/md_grey_900</item> <item name="bnbBackgroundColor">@color/md_grey_900</item>
<item name="android:textColorPrimary">@color/md_white_1000</item> <item name="android:textColorPrimary">@color/md_white_1000</item>
<item name="android:textColorSecondary">@color/md_grey_600</item> <item name="android:textColorSecondary">@color/md_grey_600</item>
<item name="material_drawer_header_selection_text">@color/md_grey_900</item>
</style> </style>
<!-- ToolBar --> <!-- ToolBar -->
<style name="ToolBarStyle" parent="Theme.AppCompat"> <style name="ToolBarStyle" parent="Theme.AppCompat">
<item name="android:textColorPrimary">@color/white</item> <item name="android:textColorPrimary">@color/white</item>
<item name="android:textColorSecondary">@color/white</item> <item name="android:textColorSecondary">@color/white</item>
<item name="material_drawer_header_selection_text">@color/md_grey_900</item>
<item name="actionMenuTextColor">@color/white</item> <item name="actionMenuTextColor">@color/white</item>
<!--<item name="actionOverflowButtonStyle">@style/ActionButtonOverflowStyle</item> <!--<item name="actionOverflowButtonStyle">@style/ActionButtonOverflowStyle</item>
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>--> <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>-->
@ -46,6 +49,7 @@
<item name="android:colorBackground">@color/md_grey_50</item> <item name="android:colorBackground">@color/md_grey_50</item>
<item name="android:textColorPrimary">@color/md_grey_900</item> <item name="android:textColorPrimary">@color/md_grey_900</item>
<item name="android:textColorSecondary">@color/md_grey_400</item> <item name="android:textColorSecondary">@color/md_grey_400</item>
<item name="material_drawer_header_selection_text">@color/md_grey_900</item>
</style> </style>
<style name="NoBarBlueAmberDark" parent="MaterialDrawerTheme"> <style name="NoBarBlueAmberDark" parent="MaterialDrawerTheme">
@ -58,6 +62,7 @@
<item name="bnbBackgroundColor">@color/md_grey_900</item> <item name="bnbBackgroundColor">@color/md_grey_900</item>
<item name="android:textColorPrimary">@color/md_white_1000</item> <item name="android:textColorPrimary">@color/md_white_1000</item>
<item name="android:textColorSecondary">@color/md_grey_600</item> <item name="android:textColorSecondary">@color/md_grey_600</item>
<item name="material_drawer_header_selection_text">@color/md_grey_900</item>
</style> </style>
<style name="NoBarGreyOrange" parent="MaterialDrawerTheme.Light"> <style name="NoBarGreyOrange" parent="MaterialDrawerTheme.Light">
@ -69,6 +74,7 @@
<item name="android:colorBackground">@color/md_grey_50</item> <item name="android:colorBackground">@color/md_grey_50</item>
<item name="android:textColorPrimary">@color/md_grey_900</item> <item name="android:textColorPrimary">@color/md_grey_900</item>
<item name="android:textColorSecondary">@color/md_grey_400</item> <item name="android:textColorSecondary">@color/md_grey_400</item>
<item name="material_drawer_header_selection_text">@color/md_grey_900</item>
</style> </style>
<style name="NoBarGreyOrangeDark" parent="MaterialDrawerTheme"> <style name="NoBarGreyOrangeDark" parent="MaterialDrawerTheme">
@ -81,6 +87,7 @@
<item name="bnbBackgroundColor">@color/md_grey_900</item> <item name="bnbBackgroundColor">@color/md_grey_900</item>
<item name="android:textColorPrimary">@color/md_white_1000</item> <item name="android:textColorPrimary">@color/md_white_1000</item>
<item name="android:textColorSecondary">@color/md_grey_600</item> <item name="android:textColorSecondary">@color/md_grey_600</item>
<item name="material_drawer_header_selection_text">@color/md_grey_900</item>
</style> </style>
<style name="NoBarIndigoPink" parent="MaterialDrawerTheme.Light"> <style name="NoBarIndigoPink" parent="MaterialDrawerTheme.Light">
@ -92,6 +99,7 @@
<item name="android:colorBackground">@color/md_grey_50</item> <item name="android:colorBackground">@color/md_grey_50</item>
<item name="android:textColorPrimary">@color/md_grey_900</item> <item name="android:textColorPrimary">@color/md_grey_900</item>
<item name="android:textColorSecondary">@color/md_grey_400</item> <item name="android:textColorSecondary">@color/md_grey_400</item>
<item name="material_drawer_header_selection_text">@color/md_grey_900</item>
</style> </style>
<style name="NoBarIndigoPinkDark" parent="MaterialDrawerTheme"> <style name="NoBarIndigoPinkDark" parent="MaterialDrawerTheme">
@ -104,6 +112,7 @@
<item name="bnbBackgroundColor">@color/md_grey_900</item> <item name="bnbBackgroundColor">@color/md_grey_900</item>
<item name="android:textColorPrimary">@color/md_white_1000</item> <item name="android:textColorPrimary">@color/md_white_1000</item>
<item name="android:textColorSecondary">@color/md_grey_600</item> <item name="android:textColorSecondary">@color/md_grey_600</item>
<item name="material_drawer_header_selection_text">@color/md_grey_900</item>
</style> </style>
<style name="NoBarRedTeal" parent="MaterialDrawerTheme.Light"> <style name="NoBarRedTeal" parent="MaterialDrawerTheme.Light">
@ -115,6 +124,7 @@
<item name="android:colorBackground">@color/md_grey_50</item> <item name="android:colorBackground">@color/md_grey_50</item>
<item name="android:textColorPrimary">@color/md_grey_900</item> <item name="android:textColorPrimary">@color/md_grey_900</item>
<item name="android:textColorSecondary">@color/md_grey_400</item> <item name="android:textColorSecondary">@color/md_grey_400</item>
<item name="material_drawer_header_selection_text">@color/md_grey_900</item>
</style> </style>
<style name="NoBarRedTealDark" parent="MaterialDrawerTheme"> <style name="NoBarRedTealDark" parent="MaterialDrawerTheme">
@ -127,6 +137,7 @@
<item name="bnbBackgroundColor">@color/md_grey_900</item> <item name="bnbBackgroundColor">@color/md_grey_900</item>
<item name="android:textColorPrimary">@color/md_white_1000</item> <item name="android:textColorPrimary">@color/md_white_1000</item>
<item name="android:textColorSecondary">@color/md_grey_600</item> <item name="android:textColorSecondary">@color/md_grey_600</item>
<item name="material_drawer_header_selection_text">@color/md_grey_900</item>
</style> </style>
<style name="NoBarCyanPink" parent="MaterialDrawerTheme.Light"> <style name="NoBarCyanPink" parent="MaterialDrawerTheme.Light">
@ -138,6 +149,7 @@
<item name="android:colorBackground">@color/md_grey_50</item> <item name="android:colorBackground">@color/md_grey_50</item>
<item name="android:textColorPrimary">@color/md_grey_900</item> <item name="android:textColorPrimary">@color/md_grey_900</item>
<item name="android:textColorSecondary">@color/md_grey_400</item> <item name="android:textColorSecondary">@color/md_grey_400</item>
<item name="material_drawer_header_selection_text">@color/md_grey_900</item>
</style> </style>
<style name="NoBarCyanPinkDark" parent="MaterialDrawerTheme"> <style name="NoBarCyanPinkDark" parent="MaterialDrawerTheme">
@ -150,6 +162,7 @@
<item name="bnbBackgroundColor">@color/md_grey_900</item> <item name="bnbBackgroundColor">@color/md_grey_900</item>
<item name="android:textColorPrimary">@color/md_white_1000</item> <item name="android:textColorPrimary">@color/md_white_1000</item>
<item name="android:textColorSecondary">@color/md_grey_600</item> <item name="android:textColorSecondary">@color/md_grey_600</item>
<item name="material_drawer_header_selection_text">@color/md_grey_900</item>
</style> </style>
@ -162,6 +175,7 @@
<item name="android:colorBackground">@color/md_grey_50</item> <item name="android:colorBackground">@color/md_grey_50</item>
<item name="android:textColorPrimary">@color/md_grey_900</item> <item name="android:textColorPrimary">@color/md_grey_900</item>
<item name="android:textColorSecondary">@color/md_grey_400</item> <item name="android:textColorSecondary">@color/md_grey_400</item>
<item name="material_drawer_header_selection_text">@color/md_grey_900</item>
</style> </style>
<style name="NoBarTealOrangeDark" parent="MaterialDrawerTheme"> <style name="NoBarTealOrangeDark" parent="MaterialDrawerTheme">
@ -174,6 +188,7 @@
<item name="bnbBackgroundColor">@color/md_grey_900</item> <item name="bnbBackgroundColor">@color/md_grey_900</item>
<item name="android:textColorPrimary">@color/md_white_1000</item> <item name="android:textColorPrimary">@color/md_white_1000</item>
<item name="android:textColorSecondary">@color/md_grey_600</item> <item name="android:textColorSecondary">@color/md_grey_600</item>
<item name="material_drawer_header_selection_text">@color/md_grey_900</item>
</style> </style>
</resources> </resources>