Skip to content

Commit

Permalink
Merge pull request #23 from odaridavid/fix-errors-api21/22
Browse files Browse the repository at this point in the history
fix api 21/22 details crash
  • Loading branch information
odaridavid authored Jun 26, 2020
2 parents d0d4f68 + b34101c commit 782fdbc
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
defaultConfig {

def versionMajor = 1
def versionMinor = 2
def versionPatch = 1
def versionMinor = 3
def versionPatch = 0

applicationId "com.github.odaridavid.designpatterns"
minSdkVersion 21
Expand Down Expand Up @@ -55,8 +55,8 @@ dependencies {
def about_libraries_version = "8.1.2"

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.2.0-rc01'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.os.PowerManager
import android.view.View
import androidx.annotation.RequiresApi
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.preference.PreferenceManager
import com.github.odaridavid.designpatterns.R
import com.github.odaridavid.designpatterns.helpers.InjectorUtils
Expand All @@ -28,9 +29,16 @@ internal abstract class BaseActivity : AppCompatActivity(), ISystemThemeChangeLi
override fun onResume() {
if (versionFrom(Build.VERSION_CODES.M))
matchSystemBarsWithBackground()
else
initSystemBarsWithDefaultColors()
super.onResume()
}

private fun initSystemBarsWithDefaultColors() {
window.statusBarColor = ContextCompat.getColor(this, android.R.color.background_dark)
window.navigationBarColor = ContextCompat.getColor(this, android.R.color.background_dark)
}

@RequiresApi(Build.VERSION_CODES.M)
private fun matchSystemBarsWithBackground() {
val sp = PreferenceManager.getDefaultSharedPreferences(baseContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.github.odaridavid.designpatterns.databinding.ActivityDesignPatternDet
import com.github.odaridavid.designpatterns.helpers.DARK_KOTLIN_CSS_PATH
import com.github.odaridavid.designpatterns.helpers.LIGHT_KOTLIN_CSS_PATH
import com.github.odaridavid.designpatterns.helpers.NavigationUtils
import com.github.odaridavid.designpatterns.helpers.SdkUtils.versionFrom
import com.github.odaridavid.designpatterns.helpers.loadWithKotlinCss
import com.github.odaridavid.designpatterns.models.DesignPattern

Expand All @@ -35,9 +36,9 @@ internal class DesignPatternDetailActivity : BaseActivity() {
)
}

@RequiresApi(Build.VERSION_CODES.M)
override fun onPowerSaverModeChange(powerManager: PowerManager): String {
super.onPowerSaverModeChange(powerManager)
if (versionFrom(Build.VERSION_CODES.M))
super.onPowerSaverModeChange(powerManager) //Changes system bars
return if (powerManager.isPowerSaveMode) DARK_KOTLIN_CSS_PATH else LIGHT_KOTLIN_CSS_PATH
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ internal class MainActivity : BaseActivity() {
InAppUpdateManager(baseContext, this).checkForUpdate()

with(RatingManager(sharedPref)) {
if (!hasGivenRating()) {
updatePromptForRatingCounter()
if (shouldPromptForRating()) {
showRatingAlertDialog(this)
}
if (hasGivenRating()) return@with
updatePromptForRatingCounter()
if (shouldPromptForRating()) {
showRatingAlertDialog(this)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion whatsnew/whatsnew-en-GB
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- Reduce app size
- Fix Lollipop and Marshmallow Crashing

0 comments on commit 782fdbc

Please sign in to comment.