Skip to content

Commit

Permalink
upgrade night theme.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethosa committed Mar 28, 2022
1 parent e86ed8d commit 48bcbed
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 4 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "com.ethosa.ktc"
minSdk 21
targetSdk 32
versionCode 7
versionName "0.5.0"
versionCode 8
versionName "0.5.1"
ndk {
abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64'
}
Expand Down Expand Up @@ -53,6 +53,7 @@ dependencies {
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.preference:preference:1.2.0'
implementation 'androidx.webkit:webkit:1.4.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/ethosa/ktc/college/ProCollege.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import android.content.Context
import android.webkit.WebView
import android.webkit.WebViewClient
import android.widget.ProgressBar

/**
* Provides work with pro college.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@ package com.ethosa.ktc.ui.fragments

import android.content.Context
import android.content.SharedPreferences
import android.content.res.Configuration
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.webkit.WebChromeClient
import android.webkit.WebView
import androidx.webkit.WebSettingsCompat
import androidx.webkit.WebSettingsCompat.FORCE_DARK_OFF
import androidx.webkit.WebSettingsCompat.FORCE_DARK_ON
import androidx.webkit.WebViewFeature
import com.ethosa.ktc.college.ProCollege
import com.ethosa.ktc.databinding.FragmentProCollegeBinding

Expand Down Expand Up @@ -38,6 +45,30 @@ class ProCollegeFragment : Fragment() {
binding.username.editText?.setText(preferences.getString(USERNAME, ""))
binding.password.editText?.setText(preferences.getString(PASSWORD, ""))

// Auto dark mode ...
if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
when (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) {
Configuration.UI_MODE_NIGHT_YES -> {
WebSettingsCompat.setForceDark(binding.content.settings, FORCE_DARK_ON)
}
Configuration.UI_MODE_NIGHT_NO, Configuration.UI_MODE_NIGHT_UNDEFINED -> {
WebSettingsCompat.setForceDark(binding.content.settings, FORCE_DARK_OFF)
}
}
}

// Page load progress
binding.content.webChromeClient = object : WebChromeClient() {
override fun onProgressChanged(view: WebView?, newProgress: Int) {
super.onProgressChanged(view, newProgress)
binding.contentProgress.progress = newProgress
if (newProgress >= 100)
binding.contentProgress.visibility = View.GONE
else
binding.contentProgress.visibility = View.VISIBLE
}
}

binding.auth.setOnClickListener {
// Auth in ProCollege
binding.login.visibility = View.GONE
Expand Down
14 changes: 13 additions & 1 deletion app/src/main/res/layout/fragment_pro_college.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent">

</WebView>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/login"
Expand Down Expand Up @@ -92,4 +94,14 @@
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

<ProgressBar
android:id="@+id/content_progress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 0 additions & 1 deletion app/src/main/res/values-night/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@
<item name="android:textColorLink">@color/primary_variant</item>

<item name="fontFamily">@font/nuritom</item>
<item name="android:buttonStyle">@style/Widget.MaterialComponents.Button</item>
</style>
</resources>

0 comments on commit 48bcbed

Please sign in to comment.