Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
ee06aed9
Commit
ee06aed9
authored
Oct 10, 2019
by
Viktor De Pasquale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated toolbar and bottom bar design implementation
TBD: Both toolbars should move away from the screen when scrolling
parent
af1f5d5a
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
45 additions
and
27 deletions
+45
-27
MainActivity.kt
...c/main/java/com/topjohnwu/magisk/redesign/MainActivity.kt
+17
-0
activity_main_md2.xml
app/src/main/res/layout/activity_main_md2.xml
+14
-23
fragment_home_md2.xml
app/src/main/res/layout/fragment_home_md2.xml
+1
-1
menu_bottom_nav.xml
app/src/main/res/menu/menu_bottom_nav.xml
+3
-3
attrs.xml
app/src/main/res/values/attrs.xml
+1
-0
styles_md2.xml
app/src/main/res/values/styles_md2.xml
+1
-0
styles_md2_impl.xml
app/src/main/res/values/styles_md2_impl.xml
+8
-0
No files found.
app/src/main/java/com/topjohnwu/magisk/redesign/MainActivity.kt
View file @
ee06aed9
...
...
@@ -2,6 +2,8 @@ package com.topjohnwu.magisk.redesign
import
android.graphics.Insets
import
android.os.Bundle
import
android.view.ViewTreeObserver
import
androidx.core.view.setPadding
import
androidx.fragment.app.Fragment
import
com.ncapdevi.fragnav.FragNavController
import
com.topjohnwu.magisk.Const
...
...
@@ -32,6 +34,14 @@ open class MainActivity : CompatActivity<MainViewModel, ActivityMainMd2Binding>(
SettingsFragment
::
class
)
//
This
temporarily
fixes
unwanted
feature
of
BottomNavigationView
-
where
the
view
applies
//padding on itself given insets are not consumed beforehand. Unfortunately the listener
//implementation doesn't favor us against the design library, so on re-create it's often given
//upper hand.
private
val
navObserver
=
ViewTreeObserver
.
OnGlobalLayoutListener
{
binding
.
mainNavigation
.
setPadding
(
0
)
}
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
...
...
@@ -49,11 +59,18 @@ open class MainActivity : CompatActivity<MainViewModel, ActivityMainMd2Binding>(
true
}
binding
.
mainNavigation
.
viewTreeObserver
.
addOnGlobalLayoutListener
(
navObserver
)
if
(
intent
.
getBooleanExtra
(
Const
.
Key
.
OPEN_SETTINGS
,
false
))
{
binding
.
mainNavigation
.
selectedItemId
=
R
.
id
.
settingsFragment
}
}
override
fun
onDestroy
()
{
binding
.
mainNavigation
.
viewTreeObserver
.
removeOnGlobalLayoutListener
(
navObserver
)
super
.
onDestroy
()
}
override
fun
onTabTransaction
(
fragment
:
Fragment
?,
index
:
Int
)
{
super
.
onTabTransaction
(
fragment
,
index
)
...
...
app/src/main/res/layout/activity_main_md2.xml
View file @
ee06aed9
...
...
@@ -24,12 +24,14 @@
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
<com.google.android.material.
appbar.AppBarLayout
style=
"?style
Appbar
"
<com.google.android.material.
card.MaterialCardView
style=
"?style
CardElevated
"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:paddingTop=
"@{viewModel.insets.top}"
tools:paddingTop=
"24dp"
>
android:layout_marginStart=
"@dimen/l1"
android:layout_marginTop=
"@{(int) @dimen/l1 + viewModel.insets.top}"
android:layout_marginEnd=
"@dimen/l1"
tools:layout_marginTop=
"40dp"
>
<com.google.android.material.appbar.MaterialToolbar
android:id=
"@+id/main_toolbar"
...
...
@@ -45,21 +47,18 @@
android:layout_gravity=
"start|bottom"
android:background=
"@drawable/bg_accent"
/>
</com.google.android.material.
appbar.AppBarLayout
>
</com.google.android.material.
card.MaterialCardView
>
<com.google.android.material.
bottomappbar.BottomAppBar
<com.google.android.material.
card.MaterialCardView
android:id=
"@+id/main_bottom_bar"
style=
"?styleCardElevated"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"bottom"
android:background=
"?colorSurface"
android:paddingBottom=
"@{viewModel.insets.bottom}"
app:backgroundTint=
"?colorSurface"
app:contentInsetEnd=
"0dp"
app:contentInsetStart=
"0dp"
app:fabCradleMargin=
"@dimen/l_50"
app:hideOnScroll=
"true"
tools:paddingBottom=
"48dp"
>
android:layout_marginStart=
"@dimen/l1"
android:layout_marginEnd=
"@dimen/l1"
android:layout_marginBottom=
"@{(int) @dimen/l1 + viewModel.insets.bottom}"
tools:layout_marginBottom=
"64dp"
>
<LinearLayout
android:layout_width=
"match_parent"
...
...
@@ -94,15 +93,7 @@
</LinearLayout>
</com.google.android.material.bottomappbar.BottomAppBar>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"@{viewModel.insets.bottom + (int) @dimen/l1}"
app:fabSize=
"normal"
app:layout_anchor=
"@+id/main_bottom_bar"
app:srcCompat=
"@drawable/ic_superuser_md2"
/>
</com.google.android.material.card.MaterialCardView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
...
...
app/src/main/res/layout/fragment_home_md2.xml
View file @
ee06aed9
...
...
@@ -21,7 +21,7 @@
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:clipToPadding=
"false"
android:paddingTop=
"@{viewModel.insets.top + (int) @dimen/internal_action_bar_size + (int) @dimen/l
1
}"
android:paddingTop=
"@{viewModel.insets.top + (int) @dimen/internal_action_bar_size + (int) @dimen/l
2
}"
android:paddingBottom=
"@{viewModel.insets.bottom + (int) @dimen/margin_fab + (int) @dimen/l1}"
tools:layout_marginTop=
"24dp"
>
...
...
app/src/main/res/menu/menu_bottom_nav.xml
View file @
ee06aed9
...
...
@@ -15,9 +15,9 @@
tools:showAsAction=
"always"
/>
<item
android:id=
"@+id/
fake
"
android:
enabled=
"false
"
android:title=
""
android:id=
"@+id/
superuserFragment
"
android:
icon=
"@drawable/ic_superuser_md2
"
android:title=
"
@string/section_superuser
"
tools:showAsAction=
"always"
/>
<item
...
...
app/src/main/res/values/attrs.xml
View file @
ee06aed9
...
...
@@ -17,6 +17,7 @@
<!--Card-->
<attr
name=
"styleCardNormal"
format=
"reference"
/>
<attr
name=
"styleCardElevated"
format=
"reference"
/>
<attr
name=
"styleCardOnPrimary"
format=
"reference"
/>
<!--Button-->
...
...
app/src/main/res/values/styles_md2.xml
View file @
ee06aed9
...
...
@@ -30,6 +30,7 @@
<item
name=
"styleToolbar"
>
@style/WidgetFoundation.Toolbar
</item>
<item
name=
"styleCardNormal"
>
@style/WidgetFoundation.Card
</item>
<item
name=
"styleCardElevated"
>
@style/WidgetFoundation.Card.Elevated
</item>
<item
name=
"styleCardOnPrimary"
>
@style/WidgetFoundation.Card.OnPrimary
</item>
<item
name=
"styleButtonDefault"
>
@style/WidgetFoundation.Button
</item>
...
...
app/src/main/res/values/styles_md2_impl.xml
View file @
ee06aed9
...
...
@@ -27,6 +27,13 @@ variant. Make sure to use style referenced by attribute defined it attrs.xml.
<item
name=
"cardBackgroundColor"
>
?colorSurfaceVariant
</item>
<item
name=
"cardCornerRadius"
>
@dimen/l_50
</item>
<item
name=
"cardElevation"
>
0dp
</item>
<item
name=
"cardPreventCornerOverlap"
>
true
</item>
</style>
<style
name=
"WidgetFoundation.Card.Elevated"
parent=
"Widget.MaterialComponents.CardView"
>
<item
name=
"cardBackgroundColor"
>
?colorSurface
</item>
<item
name=
"cardElevation"
>
@dimen/l_25
</item>
</style>
<style
name=
"WidgetFoundation.Card.OnPrimary"
parent=
"Widget.MaterialComponents.CardView"
>
...
...
@@ -35,6 +42,7 @@ variant. Make sure to use style referenced by attribute defined it attrs.xml.
<item
name=
"strokeColor"
>
?colorOnPrimaryVariant
</item>
<item
name=
"strokeWidth"
>
1dp
</item>
<item
name=
"cardBackgroundColor"
>
?colorPrimary
</item>
<item
name=
"cardPreventCornerOverlap"
>
true
</item>
</style>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment