From cf7976481f65c73f6b960f5086d04391cd575ee5 Mon Sep 17 00:00:00 2001 From: kubasz Date: Sun, 11 Aug 2019 15:58:02 +0200 Subject: [PATCH] Added more bugs --- .idea/render.experimental.xml | 6 ++ .idea/vcs.xml | 6 ++ app/src/main/AndroidManifest.xml | 2 +- app/src/main/res/layout/sample_nav_view.xml | 45 ++++++++- app/src/main/res/values/colors.xml | 3 + app/src/main/res/values/styles.xml | 51 ++++++++-- navlib/build.gradle | 4 +- .../java/pl/szczodrzynski/navlib/NavView.kt | 25 +++-- .../res/drawable/bottom_sheet_background.xml | 8 ++ .../bottom_sheet_fragment_theme_info.xml | 90 ++++++++++++------ navlib/src/main/res/layout/nav_view.xml | 92 ++++++++----------- navlib/src/main/res/values/attrs.xml | 4 + navlib/src/main/res/values/styles.xml | 7 +- 13 files changed, 242 insertions(+), 101 deletions(-) create mode 100644 .idea/render.experimental.xml create mode 100644 .idea/vcs.xml create mode 100644 navlib/src/main/res/drawable/bottom_sheet_background.xml create mode 100644 navlib/src/main/res/values/attrs.xml diff --git a/.idea/render.experimental.xml b/.idea/render.experimental.xml new file mode 100644 index 0000000..8ec256a --- /dev/null +++ b/.idea/render.experimental.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 9715f8e..2864e26 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -8,7 +8,7 @@ android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" - android:theme="@style/AppTheme"> + android:theme="@style/AppTheme.Light"> diff --git a/app/src/main/res/layout/sample_nav_view.xml b/app/src/main/res/layout/sample_nav_view.xml index 0f7ee4c..c79617c 100644 --- a/app/src/main/res/layout/sample_nav_view.xml +++ b/app/src/main/res/layout/sample_nav_view.xml @@ -1,7 +1,8 @@ + android:layout_height="match_parent" + xmlns:tools="http://schemas.android.com/tools"> + + + + + + + + + + + + + - - diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index ce71d26..9dafdc7 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -5,4 +5,7 @@ #6EC6FF #4caf50 #4CAF50 + + #ffffff + #121212 diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index ab3813f..50401e0 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,18 +1,55 @@ - + diff --git a/navlib/build.gradle b/navlib/build.gradle index 64ed7d1..941182a 100644 --- a/navlib/build.gradle +++ b/navlib/build.gradle @@ -12,6 +12,8 @@ android { versionName "1.0" consumerProguardFiles 'consumer-rules.pro' + + vectorDrawables.useSupportLibrary = true } buildTypes { @@ -28,6 +30,6 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'androidx.appcompat:appcompat:1.0.2' implementation 'androidx.core:core-ktx:1.0.2' - implementation 'com.google.android.material:material:1.0.0' + implementation 'com.google.android.material:material:1.1.0-alpha09' implementation "androidx.legacy:legacy-support-v4:1.0.0" } diff --git a/navlib/src/main/java/pl/szczodrzynski/navlib/NavView.kt b/navlib/src/main/java/pl/szczodrzynski/navlib/NavView.kt index 1f85c25..e42c3f9 100644 --- a/navlib/src/main/java/pl/szczodrzynski/navlib/NavView.kt +++ b/navlib/src/main/java/pl/szczodrzynski/navlib/NavView.kt @@ -4,23 +4,28 @@ import android.content.Context import android.util.AttributeSet import android.view.LayoutInflater import android.view.MotionEvent +import android.view.MotionEvent.INVALID_POINTER_ID import android.view.View import android.view.ViewGroup +import android.widget.FrameLayout import android.widget.LinearLayout import android.widget.TextView +import androidx.core.view.MotionEventCompat +import androidx.core.widget.NestedScrollView +import androidx.customview.widget.ViewDragHelper import com.google.android.material.bottomappbar.BottomAppBar import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_COLLAPSED import com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_HIDDEN import com.google.android.material.floatingactionbutton.FloatingActionButton -class NavView : LinearLayout { +class NavView : FrameLayout { private var contentView: LinearLayout? = null private lateinit var bottomAppBar: BottomAppBar private lateinit var floatingActionButton: FloatingActionButton private lateinit var scrimView: View - private lateinit var bottomSheet: View + private lateinit var bottomSheet: NestedScrollView private lateinit var bottomSheetBehavior: BottomSheetBehavior private var bottomSheetVisible = false @@ -56,7 +61,7 @@ class NavView : LinearLayout { contentView = findViewById(R.id.nv_content) - findViewById(R.id.textView).text = "${displayWidth}dp x ${displayHeight}dp" + //findViewById(R.id.textView).text = "${displayWidth}dp x ${displayHeight}dp" bottomAppBar = findViewById(R.id.nv_bottomAppBar) floatingActionButton = findViewById(R.id.nv_floatingActionButton) @@ -64,16 +69,18 @@ class NavView : LinearLayout { bottomSheet = findViewById(R.id.nv_bottomSheet) bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet) + bottomSheetBehavior.state = STATE_HIDDEN + bottomAppBar.setOnTouchListener { v, event -> bottomSheet.dispatchTouchEvent(event) false } scrimView.setOnTouchListener { v, event -> - if (event.action == MotionEvent.ACTION_UP && bottomSheetVisible) { + if (event.action == MotionEvent.ACTION_UP && bottomSheetBehavior.state != STATE_HIDDEN) { bottomSheetBehavior.state = STATE_HIDDEN } - false + true } bottomSheetBehavior.setBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() { @@ -90,7 +97,6 @@ class NavView : LinearLayout { } }) - floatingActionButton.setOnClickListener { if (bottomSheetBehavior.state == STATE_HIDDEN) { bottomSheetBehavior.state = STATE_COLLAPSED @@ -100,8 +106,15 @@ class NavView : LinearLayout { } } + + } + + + + + override fun addView(child: View?, index: Int, params: ViewGroup.LayoutParams?) { if (contentView == null) { super.addView(child, index, params) diff --git a/navlib/src/main/res/drawable/bottom_sheet_background.xml b/navlib/src/main/res/drawable/bottom_sheet_background.xml new file mode 100644 index 0000000..dfb58df --- /dev/null +++ b/navlib/src/main/res/drawable/bottom_sheet_background.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/navlib/src/main/res/layout/bottom_sheet_fragment_theme_info.xml b/navlib/src/main/res/layout/bottom_sheet_fragment_theme_info.xml index 9d8a923..739b0d4 100644 --- a/navlib/src/main/res/layout/bottom_sheet_fragment_theme_info.xml +++ b/navlib/src/main/res/layout/bottom_sheet_fragment_theme_info.xml @@ -12,41 +12,79 @@ android:layout_marginTop="8dp" android:background="@drawable/bottom_sheet_controll_bar" /> - + android:orientation="vertical"> - + android:text="Button" /> -