From 10e5761cc3c351c9cd583033742ecd30c0284017 Mon Sep 17 00:00:00 2001 From: Spoetnic Date: Thu, 8 Dec 2016 22:34:17 +0100 Subject: [PATCH 1/5] Implement more robust NavigationarHeight computation. --- .../cocosw/bottomsheet/TranslucentHelper.java | 54 +++++++++---------- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/library/src/main/java/com/cocosw/bottomsheet/TranslucentHelper.java b/library/src/main/java/com/cocosw/bottomsheet/TranslucentHelper.java index 7ab4872..e853537 100644 --- a/library/src/main/java/com/cocosw/bottomsheet/TranslucentHelper.java +++ b/library/src/main/java/com/cocosw/bottomsheet/TranslucentHelper.java @@ -9,6 +9,8 @@ import android.content.res.TypedArray; import android.os.Build; import android.util.DisplayMetrics; +import android.view.KeyCharacterMap; +import android.view.KeyEvent; import android.view.ViewConfiguration; import android.view.Window; import android.view.WindowManager; @@ -101,40 +103,34 @@ private float getSmallestWidthDp(WindowManager wm) { return Math.min(widthDp, heightDp); } - int getNavigationBarHeight(Context context) { - Resources res = context.getResources(); - int result = 0; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { - if (hasNavBar(context)) { - String key; - if (mInPortrait) { - key = NAV_BAR_HEIGHT_RES_NAME; - } else { - if (!isNavigationAtBottom()) - return 0; - key = NAV_BAR_HEIGHT_LANDSCAPE_RES_NAME; - } - return getInternalDimensionSize(res, key); - } + public int getNavigationBarHeight(Context context) { + return getNavigationBarHeight(context, false); + } + + public int getNavigationBarHeight(Context context, boolean skipRequirement) { + int resourceId = context.getResources().getIdentifier(NAV_BAR_HEIGHT_RES_NAME, "dimen", "android"); + if (resourceId > 0 && (skipRequirement || hasNavBar(context))) { + return context.getResources().getDimensionPixelSize(resourceId); } - return result; + return 0; } private boolean hasNavBar(Context context) { - Resources res = context.getResources(); - int resourceId = res.getIdentifier(SHOW_NAV_BAR_RES_NAME, "bool", "android"); - if (resourceId != 0) { - boolean hasNav = res.getBoolean(resourceId); - // check override flag (see static block) - if ("1".equals(sNavBarOverride)) { - hasNav = false; - } else if ("0".equals(sNavBarOverride)) { - hasNav = true; - } - return hasNav; - } else { // fallback - return !ViewConfiguration.get(context).hasPermanentMenuKey(); + // Kitkat and less shows container above nav bar + if (android.os.Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) { + return false; + } + // Emulator + if (Build.FINGERPRINT.startsWith("generic")) { + return true; } + boolean hasMenuKey = ViewConfiguration.get(context).hasPermanentMenuKey(); + boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK); + boolean hasNoCapacitiveKeys = !hasMenuKey && !hasBackKey; + Resources resources = context.getResources(); + int id = resources.getIdentifier(SHOW_NAV_BAR_RES_NAME, "bool", "android"); + boolean hasOnScreenNavBar = id > 0 && resources.getBoolean(id); + return hasOnScreenNavBar || hasNoCapacitiveKeys || getNavigationBarHeight(context, true) > 0; } private int getInternalDimensionSize(Resources res, String key) { From 80985673bc287845a890673e0e32fac8772a5c5f Mon Sep 17 00:00:00 2001 From: Spoetnic Date: Thu, 8 Dec 2016 22:34:33 +0100 Subject: [PATCH 2/5] Update dependencies --- .travis.yml | 4 ++-- build.gradle | 2 +- example/build.gradle | 2 +- gradle.properties | 8 ++++---- gradle/wrapper/gradle-wrapper.properties | 2 +- library/build.gradle | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5984037..253e848 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,8 +21,8 @@ branches: android: components: - - build-tools-23.0.1 - - android-23 + - build-tools-25.0.1 + - android-25 - extra-android-m2repository script: ./gradlew assembleDebug diff --git a/build.gradle b/build.gradle index a139ad6..209c42f 100644 --- a/build.gradle +++ b/build.gradle @@ -20,7 +20,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:1.3.1' + classpath 'com.android.tools.build:gradle:2.2.3' } } diff --git a/example/build.gradle b/example/build.gradle index 64e34e7..b61e702 100644 --- a/example/build.gradle +++ b/example/build.gradle @@ -3,7 +3,7 @@ apply from: 'https://raw.githubusercontent.com/soarcn/gradle/master/android.grad dependencies { compile project(':library') compile 'com.cocosw:query:0.2.2' - compile 'com.android.support:appcompat-v7:22.1.1' + compile 'com.android.support:appcompat-v7:25.0.1' // androidTestCompile ('com.android.support.test.espresso:espresso-core:+') { // exclude module: 'support-annotations' diff --git a/gradle.properties b/gradle.properties index f7edd46..2165f30 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,10 +18,10 @@ VERSION_NAME=0.0.1 VERSION_CODE=1 -MIN_SDK_VERSION=8 -TARGET_SDK_VERSION=22 -COMPILE_SDK_VERSION=23 -BUILD_TOOLS_VERSION=23.0.1 +MIN_SDK_VERSION=9 +TARGET_SDK_VERSION=25 +COMPILE_SDK_VERSION=25 +BUILD_TOOLS_VERSION=25.0.1 POM_GROUP_ID=com.cocosw POM_ARTIFACT_ID=bottomsheet diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8a7d488..71385bf 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip diff --git a/library/build.gradle b/library/build.gradle index f770c4a..28d2a06 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -2,6 +2,6 @@ apply from: 'https://raw.githubusercontent.com/soarcn/gradle/master/android-libr apply from: 'https://raw.githubusercontent.com/soarcn/gradle/master/maven_push.gradle' dependencies { - compile 'com.android.support:support-v4:22.2.0' + compile 'com.android.support:support-v4:25.0.1' } From cebabe84342da28115f4ed9f26e5a2dae44fd6bc Mon Sep 17 00:00:00 2001 From: Spoetnic Date: Thu, 8 Dec 2016 22:36:28 +0100 Subject: [PATCH 3/5] Revert "Update dependencies" This reverts commit 80985673bc287845a890673e0e32fac8772a5c5f. --- .travis.yml | 4 ++-- build.gradle | 2 +- example/build.gradle | 2 +- gradle.properties | 8 ++++---- gradle/wrapper/gradle-wrapper.properties | 2 +- library/build.gradle | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 253e848..5984037 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,8 +21,8 @@ branches: android: components: - - build-tools-25.0.1 - - android-25 + - build-tools-23.0.1 + - android-23 - extra-android-m2repository script: ./gradlew assembleDebug diff --git a/build.gradle b/build.gradle index 209c42f..a139ad6 100644 --- a/build.gradle +++ b/build.gradle @@ -20,7 +20,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:2.2.3' + classpath 'com.android.tools.build:gradle:1.3.1' } } diff --git a/example/build.gradle b/example/build.gradle index b61e702..64e34e7 100644 --- a/example/build.gradle +++ b/example/build.gradle @@ -3,7 +3,7 @@ apply from: 'https://raw.githubusercontent.com/soarcn/gradle/master/android.grad dependencies { compile project(':library') compile 'com.cocosw:query:0.2.2' - compile 'com.android.support:appcompat-v7:25.0.1' + compile 'com.android.support:appcompat-v7:22.1.1' // androidTestCompile ('com.android.support.test.espresso:espresso-core:+') { // exclude module: 'support-annotations' diff --git a/gradle.properties b/gradle.properties index 2165f30..f7edd46 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,10 +18,10 @@ VERSION_NAME=0.0.1 VERSION_CODE=1 -MIN_SDK_VERSION=9 -TARGET_SDK_VERSION=25 -COMPILE_SDK_VERSION=25 -BUILD_TOOLS_VERSION=25.0.1 +MIN_SDK_VERSION=8 +TARGET_SDK_VERSION=22 +COMPILE_SDK_VERSION=23 +BUILD_TOOLS_VERSION=23.0.1 POM_GROUP_ID=com.cocosw POM_ARTIFACT_ID=bottomsheet diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 71385bf..8a7d488 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip diff --git a/library/build.gradle b/library/build.gradle index 28d2a06..f770c4a 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -2,6 +2,6 @@ apply from: 'https://raw.githubusercontent.com/soarcn/gradle/master/android-libr apply from: 'https://raw.githubusercontent.com/soarcn/gradle/master/maven_push.gradle' dependencies { - compile 'com.android.support:support-v4:25.0.1' + compile 'com.android.support:support-v4:22.2.0' } From 9e60c62fcad7a9ae834e1d30a625b0b0f9dc70eb Mon Sep 17 00:00:00 2001 From: Spoetnic Date: Thu, 8 Dec 2016 22:43:16 +0100 Subject: [PATCH 4/5] Update all dependencies to 25.0.1, needed minSKD to 9 (2.3+, which I think is fair: https://developer.android.com/about/dashboards/index.html) --- .travis.yml | 4 ++-- build.gradle | 2 +- example/build.gradle | 2 +- gradle.properties | 10 +++++----- gradle/wrapper/gradle-wrapper.properties | 2 +- library/build.gradle | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5984037..253e848 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,8 +21,8 @@ branches: android: components: - - build-tools-23.0.1 - - android-23 + - build-tools-25.0.1 + - android-25 - extra-android-m2repository script: ./gradlew assembleDebug diff --git a/build.gradle b/build.gradle index a139ad6..209c42f 100644 --- a/build.gradle +++ b/build.gradle @@ -20,7 +20,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:1.3.1' + classpath 'com.android.tools.build:gradle:2.2.3' } } diff --git a/example/build.gradle b/example/build.gradle index 64e34e7..b61e702 100644 --- a/example/build.gradle +++ b/example/build.gradle @@ -3,7 +3,7 @@ apply from: 'https://raw.githubusercontent.com/soarcn/gradle/master/android.grad dependencies { compile project(':library') compile 'com.cocosw:query:0.2.2' - compile 'com.android.support:appcompat-v7:22.1.1' + compile 'com.android.support:appcompat-v7:25.0.1' // androidTestCompile ('com.android.support.test.espresso:espresso-core:+') { // exclude module: 'support-annotations' diff --git a/gradle.properties b/gradle.properties index f7edd46..9f98a4b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,14 +18,14 @@ VERSION_NAME=0.0.1 VERSION_CODE=1 -MIN_SDK_VERSION=8 -TARGET_SDK_VERSION=22 -COMPILE_SDK_VERSION=23 -BUILD_TOOLS_VERSION=23.0.1 +MIN_SDK_VERSION=9 +TARGET_SDK_VERSION=25 +COMPILE_SDK_VERSION=25 +BUILD_TOOLS_VERSION=25.0.1 POM_GROUP_ID=com.cocosw POM_ARTIFACT_ID=bottomsheet -POM_VERSION=1.2.0 +POM_VERSION=1.2.1 POM_NAME=bottomsheet POM_PACKAGING=pom POM_DESCRIPTION=One way to present a set of actions to a user is with bottom sheets, a sheet of paper that slides up from the bottom edge of the screen. Bottom sheets offer flexibility in the display of clear and simple actions that do not need explanation. diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8a7d488..71385bf 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip diff --git a/library/build.gradle b/library/build.gradle index f770c4a..28d2a06 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -2,6 +2,6 @@ apply from: 'https://raw.githubusercontent.com/soarcn/gradle/master/android-libr apply from: 'https://raw.githubusercontent.com/soarcn/gradle/master/maven_push.gradle' dependencies { - compile 'com.android.support:support-v4:22.2.0' + compile 'com.android.support:support-v4:25.0.1' } From bd1d2c5ef1741b238fe3a9ae15b384dfca2e2b4b Mon Sep 17 00:00:00 2001 From: Spoetnic Date: Thu, 8 Dec 2016 22:47:21 +0100 Subject: [PATCH 5/5] Revert "Update all dependencies to 25.0.1, needed minSKD to 9 (2.3+, which I think is fair: https://developer.android.com/about/dashboards/index.html)" This reverts commit 9e60c62fcad7a9ae834e1d30a625b0b0f9dc70eb. --- .travis.yml | 4 ++-- build.gradle | 2 +- example/build.gradle | 2 +- gradle.properties | 10 +++++----- gradle/wrapper/gradle-wrapper.properties | 2 +- library/build.gradle | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 253e848..5984037 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,8 +21,8 @@ branches: android: components: - - build-tools-25.0.1 - - android-25 + - build-tools-23.0.1 + - android-23 - extra-android-m2repository script: ./gradlew assembleDebug diff --git a/build.gradle b/build.gradle index 209c42f..a139ad6 100644 --- a/build.gradle +++ b/build.gradle @@ -20,7 +20,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:2.2.3' + classpath 'com.android.tools.build:gradle:1.3.1' } } diff --git a/example/build.gradle b/example/build.gradle index b61e702..64e34e7 100644 --- a/example/build.gradle +++ b/example/build.gradle @@ -3,7 +3,7 @@ apply from: 'https://raw.githubusercontent.com/soarcn/gradle/master/android.grad dependencies { compile project(':library') compile 'com.cocosw:query:0.2.2' - compile 'com.android.support:appcompat-v7:25.0.1' + compile 'com.android.support:appcompat-v7:22.1.1' // androidTestCompile ('com.android.support.test.espresso:espresso-core:+') { // exclude module: 'support-annotations' diff --git a/gradle.properties b/gradle.properties index 9f98a4b..f7edd46 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,14 +18,14 @@ VERSION_NAME=0.0.1 VERSION_CODE=1 -MIN_SDK_VERSION=9 -TARGET_SDK_VERSION=25 -COMPILE_SDK_VERSION=25 -BUILD_TOOLS_VERSION=25.0.1 +MIN_SDK_VERSION=8 +TARGET_SDK_VERSION=22 +COMPILE_SDK_VERSION=23 +BUILD_TOOLS_VERSION=23.0.1 POM_GROUP_ID=com.cocosw POM_ARTIFACT_ID=bottomsheet -POM_VERSION=1.2.1 +POM_VERSION=1.2.0 POM_NAME=bottomsheet POM_PACKAGING=pom POM_DESCRIPTION=One way to present a set of actions to a user is with bottom sheets, a sheet of paper that slides up from the bottom edge of the screen. Bottom sheets offer flexibility in the display of clear and simple actions that do not need explanation. diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 71385bf..8a7d488 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip diff --git a/library/build.gradle b/library/build.gradle index 28d2a06..f770c4a 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -2,6 +2,6 @@ apply from: 'https://raw.githubusercontent.com/soarcn/gradle/master/android-libr apply from: 'https://raw.githubusercontent.com/soarcn/gradle/master/maven_push.gradle' dependencies { - compile 'com.android.support:support-v4:25.0.1' + compile 'com.android.support:support-v4:22.2.0' }