From 584d4e815b34f7e51c348de33e89f154a4ff1556 Mon Sep 17 00:00:00 2001 From: NanYuanZhiGe Date: Mon, 23 Feb 2026 20:29:56 +0800 Subject: [PATCH] Swich gradle version to 8.3 which make new project easy to build, and add RoundedSlidingPanel to make SlidingPanel supports top radius --- build.gradle | 31 ----- demo/build.gradle | 21 ---- demo/build.gradle.kts | 20 +++ demo/settings.gradle | 5 - demo/src/main/AndroidManifest.xml | 2 - .../slidinguppanel/demo/DemoActivity.java | 45 ++++--- demo/src/main/res/drawable/radius.xml | 9 ++ demo/src/main/res/layout/activity_demo.xml | 7 +- gradle/wrapper/gradle-wrapper.properties | 6 +- library/build.gradle | 21 ---- library/build.gradle.kts | 20 +++ library/src/main/AndroidManifest.xml | 1 - .../RoundedSlidingUpPanelLayout.java | 28 +++++ .../slidinguppanel/SlidingUpPanelLayout.java | 18 ++- .../src/main/res/drawable/above_shadow.xml | 2 +- .../src/main/res/drawable/below_shadow.xml | 3 +- .../res/drawable/rounded_above_shadow.xml | 3 + .../res/drawable/rounded_below_shadow.xml | 4 + maven_push.gradle | 114 ------------------ settings.gradle | 2 - settings.gradle.kts | 23 ++++ 21 files changed, 150 insertions(+), 235 deletions(-) delete mode 100644 build.gradle delete mode 100644 demo/build.gradle create mode 100644 demo/build.gradle.kts delete mode 100644 demo/settings.gradle create mode 100644 demo/src/main/res/drawable/radius.xml delete mode 100644 library/build.gradle create mode 100644 library/build.gradle.kts create mode 100644 library/src/main/java/com/sothree/slidinguppanel/RoundedSlidingUpPanelLayout.java create mode 100644 library/src/main/res/drawable/rounded_above_shadow.xml create mode 100644 library/src/main/res/drawable/rounded_below_shadow.xml delete mode 100644 maven_push.gradle delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 53d5638f..00000000 --- a/build.gradle +++ /dev/null @@ -1,31 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. -buildscript { - repositories { - jcenter() - } - - dependencies { - classpath 'com.android.tools.build:gradle:2.3.2' - } -} - -def isReleaseBuild() { - return version.contains("SNAPSHOT") == false -} - -allprojects { - version = VERSION_NAME - group = GROUP - - repositories { - jcenter() - maven { - url "https://maven.google.com" - } - } -} - -task wrapper(type: Wrapper) { - gradleVersion = '3.3' - distributionUrl = "https://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip" -} diff --git a/demo/build.gradle b/demo/build.gradle deleted file mode 100644 index 02b6f063..00000000 --- a/demo/build.gradle +++ /dev/null @@ -1,21 +0,0 @@ -apply plugin: 'com.android.application' - -android { - compileSdkVersion 26 - buildToolsVersion "26.0.1" - - lintOptions { - abortOnError false - } - - defaultConfig { - minSdkVersion 14 - targetSdkVersion 26 - } -} - -dependencies { - compile 'com.android.support:support-v4:26.0.2' - compile 'com.android.support:appcompat-v7:26.0.2' - compile project(':library') -} diff --git a/demo/build.gradle.kts b/demo/build.gradle.kts new file mode 100644 index 00000000..f7fb9419 --- /dev/null +++ b/demo/build.gradle.kts @@ -0,0 +1,20 @@ +plugins { + id("com.android.application") +} + +android { + namespace = "com.sothree.slidinguppanel.demo" + compileSdk= 26 + buildToolsVersion = "26.0.1" + + defaultConfig { + minSdk= 14 + compileSdk= 26 + } +} + +dependencies { + implementation("com.android.support:support-v4:26.0.2") + implementation("com.android.support:appcompat-v7:26.0.2") + implementation(project(":library")) +} diff --git a/demo/settings.gradle b/demo/settings.gradle deleted file mode 100644 index 94a4bfd5..00000000 --- a/demo/settings.gradle +++ /dev/null @@ -1,5 +0,0 @@ -include ':Tnt2' - -include 'androidslidingup' - -project(':androidslidingup').projectDir = new File(settingsDir, '../library/') diff --git a/demo/src/main/AndroidManifest.xml b/demo/src/main/AndroidManifest.xml index a37bd78c..e332b6b2 100644 --- a/demo/src/main/AndroidManifest.xml +++ b/demo/src/main/AndroidManifest.xml @@ -1,13 +1,11 @@ diff --git a/demo/src/main/java/com/sothree/slidinguppanel/demo/DemoActivity.java b/demo/src/main/java/com/sothree/slidinguppanel/demo/DemoActivity.java index 2f95fe8f..66e503b8 100644 --- a/demo/src/main/java/com/sothree/slidinguppanel/demo/DemoActivity.java +++ b/demo/src/main/java/com/sothree/slidinguppanel/demo/DemoActivity.java @@ -83,7 +83,7 @@ public void onItemClick(AdapterView parent, View view, int position, long id) lv.setAdapter(arrayAdapter); - mLayout = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout); + mLayout = findViewById(R.id.sliding_layout); mLayout.addPanelSlideListener(new PanelSlideListener() { @Override public void onPanelSlide(View panel, float slideOffset) { @@ -139,33 +139,30 @@ public boolean onPrepareOptionsMenu(Menu menu) { @Override public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()){ - case R.id.action_toggle: { - if (mLayout != null) { - if (mLayout.getPanelState() != PanelState.HIDDEN) { - mLayout.setPanelState(PanelState.HIDDEN); - item.setTitle(R.string.action_show); - } else { - mLayout.setPanelState(PanelState.COLLAPSED); - item.setTitle(R.string.action_hide); - } + if (item.getItemId()==R.id.action_toggle){ + if (mLayout != null) { + if (mLayout.getPanelState() != PanelState.HIDDEN) { + mLayout.setPanelState(PanelState.HIDDEN); + item.setTitle(R.string.action_show); + } else { + mLayout.setPanelState(PanelState.COLLAPSED); + item.setTitle(R.string.action_hide); } - return true; } - case R.id.action_anchor: { - if (mLayout != null) { - if (mLayout.getAnchorPoint() == 1.0f) { - mLayout.setAnchorPoint(0.7f); - mLayout.setPanelState(PanelState.ANCHORED); - item.setTitle(R.string.action_anchor_disable); - } else { - mLayout.setAnchorPoint(1.0f); - mLayout.setPanelState(PanelState.COLLAPSED); - item.setTitle(R.string.action_anchor_enable); - } + return true; + }else if (item.getItemId()==R.id.action_anchor){ + if (mLayout != null) { + if (mLayout.getAnchorPoint() == 1.0f) { + mLayout.setAnchorPoint(0.7f); + mLayout.setPanelState(PanelState.ANCHORED); + item.setTitle(R.string.action_anchor_disable); + } else { + mLayout.setAnchorPoint(1.0f); + mLayout.setPanelState(PanelState.COLLAPSED); + item.setTitle(R.string.action_anchor_enable); } - return true; } + return true; } return super.onOptionsItemSelected(item); } diff --git a/demo/src/main/res/drawable/radius.xml b/demo/src/main/res/drawable/radius.xml new file mode 100644 index 00000000..6cef66ec --- /dev/null +++ b/demo/src/main/res/drawable/radius.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/demo/src/main/res/layout/activity_demo.xml b/demo/src/main/res/layout/activity_demo.xml index b4d5a374..e214af09 100644 --- a/demo/src/main/res/layout/activity_demo.xml +++ b/demo/src/main/res/layout/activity_demo.xml @@ -1,4 +1,4 @@ - --> - + diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a390e815..29f24232 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Aug 23 22:44:32 CEST 2016 +#Mon Feb 23 19:18:50 CST 2026 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip +zipStorePath=wrapper/dists \ No newline at end of file diff --git a/library/build.gradle b/library/build.gradle deleted file mode 100644 index d6a4eef5..00000000 --- a/library/build.gradle +++ /dev/null @@ -1,21 +0,0 @@ -apply plugin: 'com.android.library' - -repositories { - jcenter() -} - -dependencies { - compile 'com.android.support:support-v4:26.0.2' - compile 'com.android.support:support-annotations:26.0.2' - compile 'com.android.support:recyclerview-v7:26.0.2' -} - -android { - compileSdkVersion 26 - buildToolsVersion "26.0.1" - lintOptions { - abortOnError false - } -} - -apply from: '../maven_push.gradle' diff --git a/library/build.gradle.kts b/library/build.gradle.kts new file mode 100644 index 00000000..0fb6c483 --- /dev/null +++ b/library/build.gradle.kts @@ -0,0 +1,20 @@ +plugins { + id("com.android.library") +} + +android { + namespace = "com.sothree.slidinguppanel" + compileSdk= 26 + buildToolsVersion = "26.0.1" + + defaultConfig { + minSdk= 14 + compileSdk= 26 + } +} + +dependencies { + implementation("com.android.support:support-v4:26.0.2") + implementation("com.android.support:support-annotations:26.0.2") + implementation("com.android.support:recyclerview-v7:26.0.2") +} diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml index ab3dbf77..cc84ddc2 100644 --- a/library/src/main/AndroidManifest.xml +++ b/library/src/main/AndroidManifest.xml @@ -1,6 +1,5 @@ diff --git a/library/src/main/java/com/sothree/slidinguppanel/RoundedSlidingUpPanelLayout.java b/library/src/main/java/com/sothree/slidinguppanel/RoundedSlidingUpPanelLayout.java new file mode 100644 index 00000000..65d9b8f7 --- /dev/null +++ b/library/src/main/java/com/sothree/slidinguppanel/RoundedSlidingUpPanelLayout.java @@ -0,0 +1,28 @@ +package com.sothree.slidinguppanel; + +import android.content.Context; +import android.graphics.drawable.Drawable; +import android.util.AttributeSet; + +public class RoundedSlidingUpPanelLayout extends SlidingUpPanelLayout{ + public RoundedSlidingUpPanelLayout(Context context) { + super(context); + } + + public RoundedSlidingUpPanelLayout(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public RoundedSlidingUpPanelLayout(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + } + + @Override + protected Drawable getShadowDrawable() { + if (mIsSlidingUp) { + return getResources().getDrawable(R.drawable.rounded_above_shadow); + } else { + return getResources().getDrawable(R.drawable.rounded_below_shadow); + } + } +} diff --git a/library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java b/library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java index 424a008c..47e4a2f2 100644 --- a/library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java +++ b/library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java @@ -22,8 +22,6 @@ import android.view.animation.AnimationUtils; import android.view.animation.Interpolator; -import com.sothree.slidinguppanel.library.R; - import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; @@ -122,7 +120,7 @@ public class SlidingUpPanelLayout extends ViewGroup { /** * True if the collapsed panel should be dragged up. */ - private boolean mIsSlidingUp; + protected boolean mIsSlidingUp; /** * Panel overlays the windows instead of putting it underneath it. @@ -331,9 +329,9 @@ public SlidingUpPanelLayout(Context context, AttributeSet attrs, int defStyle) { // If the shadow height is zero, don't show the shadow if (mShadowHeight > 0) { if (mIsSlidingUp) { - mShadowDrawable = getResources().getDrawable(R.drawable.above_shadow); + mShadowDrawable = getShadowDrawable(); } else { - mShadowDrawable = getResources().getDrawable(R.drawable.below_shadow); + mShadowDrawable = getShadowDrawable(); } } else { mShadowDrawable = null; @@ -347,6 +345,14 @@ public SlidingUpPanelLayout(Context context, AttributeSet attrs, int defStyle) { mIsTouchEnabled = true; } + protected Drawable getShadowDrawable() { + if (mIsSlidingUp) { + return getResources().getDrawable(R.drawable.above_shadow); + } else { + return getResources().getDrawable(R.drawable.below_shadow); + } + } + /** * Set the Drag View after the view is inflated */ @@ -1099,7 +1105,7 @@ public PanelState getPanelState() { public void setPanelState(PanelState state) { // Abort any running animation, to allow state change - if(mDragHelper.getViewDragState() == ViewDragHelper.STATE_SETTLING){ + if (mDragHelper.getViewDragState() == ViewDragHelper.STATE_SETTLING) { Log.d(TAG, "View is settling. Aborting animation."); mDragHelper.abort(); } diff --git a/library/src/main/res/drawable/above_shadow.xml b/library/src/main/res/drawable/above_shadow.xml index cf890b9b..5965c971 100644 --- a/library/src/main/res/drawable/above_shadow.xml +++ b/library/src/main/res/drawable/above_shadow.xml @@ -1,5 +1,5 @@ - + - + + + + \ No newline at end of file diff --git a/library/src/main/res/drawable/rounded_below_shadow.xml b/library/src/main/res/drawable/rounded_below_shadow.xml new file mode 100644 index 00000000..a8b409b1 --- /dev/null +++ b/library/src/main/res/drawable/rounded_below_shadow.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/maven_push.gradle b/maven_push.gradle deleted file mode 100644 index f5f4129c..00000000 --- a/maven_push.gradle +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2013 Chris Banes - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -apply plugin: 'maven' -apply plugin: 'signing' - -def isReleaseBuild() { - return VERSION_NAME.contains("SNAPSHOT") == false -} - -def getReleaseRepositoryUrl() { - return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL - : "https://oss.sonatype.org/service/local/staging/deploy/maven2/" -} - -def getSnapshotRepositoryUrl() { - return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL - : "https://oss.sonatype.org/content/repositories/snapshots/" -} - -def getRepositoryUsername() { - return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : "" -} - -def getRepositoryPassword() { - return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : "" -} - -afterEvaluate { project -> - uploadArchives { - repositories { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - - pom.groupId = GROUP - pom.artifactId = POM_ARTIFACT_ID - pom.version = VERSION_NAME - - repository(url: getReleaseRepositoryUrl()) { - authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) - } - snapshotRepository(url: getSnapshotRepositoryUrl()) { - authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) - } - - pom.project { - name POM_NAME - packaging POM_PACKAGING - description POM_DESCRIPTION - url POM_URL - - scm { - url POM_SCM_URL - connection POM_SCM_CONNECTION - developerConnection POM_SCM_DEV_CONNECTION - } - - licenses { - license { - name POM_LICENCE_NAME - url POM_LICENCE_URL - distribution POM_LICENCE_DIST - } - } - - developers { - developer { - id POM_DEVELOPER_ID - name POM_DEVELOPER_NAME - } - } - } - } - } - } - - signing { - required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") } - sign configurations.archives - } - - task androidJavadocs(type: Javadoc) { - source = android.sourceSets.main.java.srcDirs - classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) - } - - task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) { - classifier = 'javadoc' - from androidJavadocs.destinationDir - } - - task androidSourcesJar(type: Jar) { - classifier = 'sources' - from android.sourceSets.main.java.sourceFiles - } - - artifacts { - archives androidSourcesJar - archives androidJavadocsJar - } -} diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 10125648..00000000 --- a/settings.gradle +++ /dev/null @@ -1,2 +0,0 @@ -include ':library' -include ':demo' diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 00000000..08d803e7 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,23 @@ +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0" + id("com.android.application") version "8.3.0" apply false +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + maven (url="https://jitpack.io") + } +} + +rootProject.name = "AndroidSlidingUpPanel" +include(":demo") +include(":library")