Make things run on API 17

This commit is contained in:
topjohnwu 2020-01-15 00:05:44 +08:00
parent de853a2651
commit 433ae89e53
18 changed files with 130 additions and 21 deletions

View File

@ -102,7 +102,9 @@ dependencies {
implementation "com.squareup.retrofit2:adapter-rxjava2:${vRetrofit}" implementation "com.squareup.retrofit2:adapter-rxjava2:${vRetrofit}"
def vOkHttp = '3.12.7' def vOkHttp = '3.12.7'
implementation "com.squareup.okhttp3:okhttp:${vOkHttp}" implementation("com.squareup.okhttp3:okhttp:${vOkHttp}") {
force = true
}
implementation "com.squareup.okhttp3:logging-interceptor:${vOkHttp}" implementation "com.squareup.okhttp3:logging-interceptor:${vOkHttp}"
def vMoshi = '1.9.2' def vMoshi = '1.9.2'

View File

@ -15,7 +15,7 @@ abstract class BaseUIActivity<ViewModel : BaseViewModel, Binding : ViewDataBindi
protected lateinit var binding: Binding protected lateinit var binding: Binding
protected abstract val layoutRes: Int protected abstract val layoutRes: Int
protected abstract val viewModel: ViewModel abstract val viewModel: ViewModel
protected open val themeRes: Int = R.style.MagiskTheme protected open val themeRes: Int = R.style.MagiskTheme
open val snackbarView get() = binding.root open val snackbarView get() = binding.root

View File

@ -17,7 +17,7 @@ abstract class BaseUIFragment<ViewModel : BaseViewModel, Binding : ViewDataBindi
protected val activity get() = requireActivity() as BaseUIActivity<*, *> protected val activity get() = requireActivity() as BaseUIActivity<*, *>
protected lateinit var binding: Binding protected lateinit var binding: Binding
protected abstract val layoutRes: Int protected abstract val layoutRes: Int
protected abstract val viewModel: ViewModel abstract val viewModel: ViewModel
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="?colorSurfaceVariant" />
</shape>
</item>
<item android:bottom="2dp">
<shape android:shape="rectangle">
<solid android:color="?colorSurface" />
</shape>
</item>
</layer-list>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="45"
android:endColor="?colorSurface"
android:startColor="?colorSurfaceVariant" />
</shape>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<size android:height="4dp" />
<corners android:radius="2dp" />
<solid android:color="?colorOnPrimary" />
</shape>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="270"
android:endColor="?colorSurfaceVariant"
android:startColor="@android:color/transparent" />
</shape>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<corners android:radius="@dimen/r1" />
<solid android:color="?colorOnSurfaceVariant" />
<size android:width="5dp" android:height="5dp" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<corners android:radius="@dimen/r1" />
<solid android:color="?colorOnSurfaceVariant" />
<size android:width="5dp" android:height="5dp" />
</shape>
</item>
</selector>

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<solid android:color="@android:color/transparent" />
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<solid android:color="?colorSecondary" />
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<solid android:color="?colorPrimary" />
</shape>
</clip>
</item>
</layer-list>

View File

@ -2,13 +2,13 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item> <item>
<shape android:shape="rectangle"> <shape android:shape="rectangle">
<solid android:color="?colorSurfaceVariant" /> <solid android:color="@color/defColorSurfaceVariant" />
</shape> </shape>
</item> </item>
<item android:bottom="2dp"> <item android:bottom="2dp">
<shape android:shape="rectangle"> <shape android:shape="rectangle">
<solid android:color="?colorSurface" /> <solid android:color="@color/defColorSurface" />
</shape> </shape>
</item> </item>

View File

@ -3,6 +3,6 @@
android:shape="rectangle"> android:shape="rectangle">
<gradient <gradient
android:angle="45" android:angle="45"
android:endColor="?colorSurface" android:endColor="@color/defColorSurface"
android:startColor="?colorSurfaceVariant" /> android:startColor="@color/defColorSurfaceVariant" />
</shape> </shape>

View File

@ -3,5 +3,5 @@
android:shape="rectangle"> android:shape="rectangle">
<size android:height="4dp" /> <size android:height="4dp" />
<corners android:radius="2dp" /> <corners android:radius="2dp" />
<solid android:color="?colorOnPrimary" /> <solid android:color="@color/defColorOnPrimary" />
</shape> </shape>

View File

@ -3,7 +3,7 @@
<item android:state_pressed="true"> <item android:state_pressed="true">
<shape android:shape="rectangle"> <shape android:shape="rectangle">
<corners android:radius="@dimen/r1" /> <corners android:radius="@dimen/r1" />
<solid android:color="?colorPrimaryVariant" /> <solid android:color="@color/defColorPrimaryVariant" />
</shape> </shape>
</item> </item>
<item> <item>
@ -11,4 +11,4 @@
<solid android:color="@android:color/transparent" /> <solid android:color="@android:color/transparent" />
</shape> </shape>
</item> </item>
</selector> </selector>

View File

@ -3,7 +3,7 @@
<item android:state_pressed="true"> <item android:state_pressed="true">
<shape android:shape="rectangle"> <shape android:shape="rectangle">
<corners android:radius="@dimen/r1" /> <corners android:radius="@dimen/r1" />
<solid android:color="?colorPrimaryVariant" /> <solid android:color="@color/defColorPrimaryVariant" />
</shape> </shape>
</item> </item>
<item> <item>
@ -11,4 +11,4 @@
<solid android:color="@android:color/transparent" /> <solid android:color="@android:color/transparent" />
</shape> </shape>
</item> </item>
</selector> </selector>

View File

@ -3,6 +3,6 @@
android:shape="rectangle"> android:shape="rectangle">
<gradient <gradient
android:angle="270" android:angle="270"
android:endColor="?colorSurfaceVariant" android:endColor="@color/defColorSurfaceVariant"
android:startColor="@android:color/transparent" /> android:startColor="@android:color/transparent" />
</shape> </shape>

View File

@ -4,14 +4,14 @@
<item android:state_pressed="true"> <item android:state_pressed="true">
<shape android:shape="rectangle"> <shape android:shape="rectangle">
<corners android:radius="@dimen/r1" /> <corners android:radius="@dimen/r1" />
<solid android:color="?colorOnSurfaceVariant" /> <solid android:color="@color/defColorOnSurfaceVariant" />
<size android:width="5dp" android:height="5dp" /> <size android:width="5dp" android:height="5dp" />
</shape> </shape>
</item> </item>
<item> <item>
<shape android:shape="rectangle"> <shape android:shape="rectangle">
<corners android:radius="@dimen/r1" /> <corners android:radius="@dimen/r1" />
<solid android:color="?colorOnSurfaceVariant" /> <solid android:color="@color/defColorOnSurfaceVariant" />
<size android:width="5dp" android:height="5dp" /> <size android:width="5dp" android:height="5dp" />
</shape> </shape>
</item> </item>

View File

@ -10,7 +10,7 @@
<item android:id="@android:id/secondaryProgress"> <item android:id="@android:id/secondaryProgress">
<clip> <clip>
<shape> <shape>
<solid android:color="?colorSecondary" /> <solid android:color="@color/defColorSecondary" />
</shape> </shape>
</clip> </clip>
</item> </item>
@ -18,9 +18,9 @@
<item android:id="@android:id/progress"> <item android:id="@android:id/progress">
<clip> <clip>
<shape> <shape>
<solid android:color="?colorPrimary" /> <solid android:color="@color/defColorPrimary" />
</shape> </shape>
</clip> </clip>
</item> </item>
</layer-list> </layer-list>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Pre Android 5.0 does not support accessing colors from attributes in drawables
These values are from the default theme (Piplup light)
-->
<resources>
<color name="defColorPrimary">#4EAFF5</color>
<color name="defColorPrimaryVariant">#804EAFF5</color>
<color name="defColorSecondary">#3E78AF</color>
<color name="defColorSecondaryVariant">#803E78AF</color>
<color name="defColorSurface">#F9F9F9</color>
<color name="defColorSurfaceVariant">#E8E8E8</color>
<color name="defColorSurfaceSurfaceVariant">@color/defColorOnSurface</color>
<color name="defColorOnPrimary">#F9F9F9</color>
<color name="defColorOnPrimaryVariant">#D9E6E6E6</color>
<color name="defColorOnSecondary">#F9F9F9</color>
<color name="defColorOnBackground">@color/defColorOnSurface</color>
<color name="defColorError">#CC0047</color>
<color name="defColorOnError">#F9F9F9</color>
<color name="defColorOnSurface">#444444</color>
<color name="defColorOnSurfaceVariant">#80444444</color>
<color name="defColorDisabled">#808080</color>
<color name="defColorDisabledVariant">#66808080</color>
</resources>