Skip to content

Commit

Permalink
- fixed theme not saving
Browse files Browse the repository at this point in the history
- fixed the battery icon color on manga and novel for white theme
- fixed color for light theme on all fragment for the search
  • Loading branch information
jakepurple13 committed May 14, 2021
1 parent 5a8479b commit 8823954
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,13 @@ class SettingsFragment : PreferenceFragmentCompat() {
}?.let(AppCompatDelegate::setDefaultNightMode)
true
}

when (p.value) {
"system" -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
"light" -> AppCompatDelegate.MODE_NIGHT_NO
"dark" -> AppCompatDelegate.MODE_NIGHT_YES
else -> null
}?.let(AppCompatDelegate::setDefaultNightMode)
}

findPreference<SeekBarPreference>("battery_alert")?.let { s ->
Expand Down
35 changes: 18 additions & 17 deletions UIViews/src/main/res/layout/fragment_all.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?colorOnPrimary"
app:layout_collapseMode="pin">

<com.google.android.material.textfield.TextInputLayout
Expand Down Expand Up @@ -77,40 +78,40 @@

<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/scrollToTop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="15dp"
app:backgroundTint="@color/colorAccent"
android:src="@drawable/ic_baseline_vertical_align_top_24"
app:layout_behavior="@string/hide_bottom_view_on_scroll_behavior"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
app:backgroundTint="@color/colorAccent"
app:layout_behavior="@string/hide_bottom_view_on_scroll_behavior" />

<RelativeLayout
android:id="@+id/offline_view"
android:visibility="gone"
tools:visibility="visible"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:visibility="gone"
tools:visibility="visible">

<ImageView
android:id="@+id/offline_icon"
android:layout_alignParentTop="true"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:src="@drawable/ic_baseline_cloud_off_24"
android:layout_width="0dp"
android:layout_height="50dp" />
android:src="@drawable/ic_baseline_cloud_off_24" />

<TextView
style="@style/TextAppearance.MaterialComponents.Headline5"
android:text="@string/you_re_offline"
android:gravity="center"
android:layout_centerHorizontal="true"
android:layout_below="@id/offline_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:layout_below="@id/offline_icon"
android:layout_centerHorizontal="true"
android:gravity="center"
android:text="@string/you_re_offline" />

</RelativeLayout>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,18 @@ class ReadActivity : AppCompatActivity() {
@SuppressLint("SetTextI18n")
private fun batterySetup() {
val batteryInformation = findViewById<TextView>(R.id.batteryInformation)

val normalBatteryColor = colorFromTheme(R.attr.colorOnBackground, Color.WHITE)

batteryInformation.startDrawable = IconicsDrawable(this, GoogleMaterial.Icon.gmd_battery_std).apply {
colorInt = Color.WHITE
colorInt = normalBatteryColor
sizePx = batteryInformation.textSize.roundToInt()
}

Flowables.combineLatest(
batteryLevelAlert
.map { it <= batteryAlertPercent }
.map { if (it) Color.RED else Color.WHITE }
.map { if (it) Color.RED else normalBatteryColor }
.toLatestFlowable(),
batteryInfoItem
.map {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ import io.reactivex.Single

object WuxiaWorld : ApiService {

//TODO: Add search

override val baseUrl: String get() = "https://wuxiaworld.online"

override val canScroll: Boolean get() = true

override fun getRecent(page: Int): Single<List<ItemModel>> = Single.create {
val pop = "/wuxia-list?view=list&page=$page"
"$baseUrl$pop".toJsoup()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import org.junit.Test
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {

@Test
fun novelTest2() {

val f = WuxiaWorld.getList().blockingGet().first()
.toInfoModel().blockingGet()
val f = WuxiaWorld.getList(2).blockingGet()

println(f)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,18 @@ class ReadingActivity : AppCompatActivity() {
@SuppressLint("SetTextI18n")
private fun batterySetup() {
val batteryInformation = binding.batteryInformation

val normalBatteryColor = colorFromTheme(R.attr.colorOnBackground, Color.WHITE)

batteryInformation.startDrawable = IconicsDrawable(this, GoogleMaterial.Icon.gmd_battery_std).apply {
colorInt = Color.WHITE
colorInt = normalBatteryColor
sizePx = batteryInformation.textSize.roundToInt()
}

Flowables.combineLatest(
batteryLevelAlert
.map { it <= batteryAlertPercent }
.map { if (it) Color.RED else Color.WHITE }
.map { if (it) Color.RED else normalBatteryColor }
.toLatestFlowable(),
batteryInfoItem
.map {
Expand Down

0 comments on commit 8823954

Please sign in to comment.