Add night mode support

This commit is contained in:
Mygod
2018-08-16 11:12:18 +08:00
parent 4d8891c0dc
commit 14ccd9e9eb
8 changed files with 23 additions and 10 deletions

View File

@@ -46,7 +46,7 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
if (savedInstanceState == null) displayFragment(TetheringFragment()) if (savedInstanceState == null) displayFragment(TetheringFragment())
badge = QBadgeView(this) badge = QBadgeView(this)
badge.bindTarget((binding.navigation.getChildAt(0) as BottomNavigationMenuView).getChildAt(1)) badge.bindTarget((binding.navigation.getChildAt(0) as BottomNavigationMenuView).getChildAt(1))
badge.badgeBackgroundColor = ContextCompat.getColor(this, R.color.colorAccent) badge.badgeBackgroundColor = ContextCompat.getColor(this, R.color.colorSecondary)
badge.badgeTextColor = ContextCompat.getColor(this, R.color.primary_text_default_material_light) badge.badgeTextColor = ContextCompat.getColor(this, R.color.primary_text_default_material_light)
badge.badgeGravity = Gravity.TOP or Gravity.CENTER_HORIZONTAL badge.badgeGravity = Gravity.TOP or Gravity.CENTER_HORIZONTAL
badge.setGravityOffset(16f, 0f, true) badge.setGravityOffset(16f, 0f, true)

View File

@@ -45,7 +45,7 @@ class ClientsFragment : Fragment(), ServiceConnection {
binding.clients.layoutManager = LinearLayoutManager(context, RecyclerView.VERTICAL, false) binding.clients.layoutManager = LinearLayoutManager(context, RecyclerView.VERTICAL, false)
binding.clients.itemAnimator = DefaultItemAnimator() binding.clients.itemAnimator = DefaultItemAnimator()
binding.clients.adapter = adapter binding.clients.adapter = adapter
binding.swipeRefresher.setColorSchemeResources(R.color.colorAccent) binding.swipeRefresher.setColorSchemeResources(R.color.colorSecondary)
binding.swipeRefresher.setOnRefreshListener { binding.swipeRefresher.setOnRefreshListener {
IpNeighbourMonitor.instance?.flush() IpNeighbourMonitor.instance?.flush()
} }

View File

@@ -45,7 +45,7 @@
android:id="@+id/line" android:id="@+id/line"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0.1px" android:layout_height="0.1px"
android:background="@color/navigationBarColor" android:background="?android:attr/navigationBarColor"
android:elevation="9dp" android:elevation="9dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"

View File

@@ -12,7 +12,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:src="@drawable/ic_content_add" android:src="@drawable/ic_content_add"
android:tint="@color/colorAccent"/> android:tint="@color/colorSecondary"/>
<Space <Space
android:layout_width="16dp" android:layout_width="16dp"

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#2e7d32</color>
<color name="colorPrimaryDark">#005005</color>
<color name="colorSecondary">#AEEA00</color>
</resources>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.MaterialComponents.DayNight.NoActionBar" parent="Theme.MaterialComponents.NoActionBar"/>
</resources>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<color name="colorPrimary">#4CAF50</color> <color name="colorPrimary">#4CAF50</color>
<color name="colorPrimaryDark">#388E3C</color> <color name="colorPrimaryDark">#087f23</color>
<color name="colorAccent">#AEEA00</color> <color name="colorSecondary">#AEEA00</color>
<color name="navigationBarColor">@android:color/black</color> <color name="navigationBarColor">@android:color/black</color>
</resources> </resources>

View File

@@ -1,13 +1,16 @@
<resources xmlns:tools="http://schemas.android.com/tools"> <resources xmlns:tools="http://schemas.android.com/tools">
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar"> <style name="Theme.MaterialComponents.DayNight.NoActionBar" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:navigationBarColor">@color/navigationBarColor</item> <item name="android:navigationBarColor">@color/navigationBarColor</item>
<item name="android:windowLightNavigationBar" tools:ignore="NewApi">true</item> <item name="android:windowLightNavigationBar" tools:ignore="NewApi">true</item>
</style> </style>
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorSecondary">@color/colorSecondary</item>
</style>
<!-- https://android.googlesource.com/platform/packages/apps/Settings/+/7efcc35/res/values/styles.xml --> <!-- https://android.googlesource.com/platform/packages/apps/Settings/+/7efcc35/res/values/styles.xml -->
<style name="wifi_item"> <style name="wifi_item">
<item name="android:layout_marginTop">8dip</item> <item name="android:layout_marginTop">8dip</item>