├── .gitignore
├── LICENSE.txt
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── github
│ │ └── heyalex
│ │ └── bottomdrawerexample
│ │ ├── GoogleTaskExampleDialog.kt
│ │ ├── GoogleTaskJavaSampleDialog.java
│ │ ├── MainActivity.kt
│ │ ├── PullExampleDialog.kt
│ │ ├── RotateExampleDialog.kt
│ │ └── handle
│ │ └── RotateHandleView.kt
│ └── res
│ ├── drawable-v24
│ └── ic_launcher_foreground.xml
│ ├── drawable
│ ├── circular_background.xml
│ ├── ic_close_black_24dp.xml
│ ├── ic_expand_less_black_24dp.xml
│ ├── ic_launcher_background.xml
│ ├── ic_person_add_black_24dp.xml
│ └── ic_settings_black_24dp.xml
│ ├── layout
│ ├── activity_main.xml
│ ├── compact_profile_header.xml
│ ├── content_view.xml
│ ├── example_layout.xml
│ ├── google_task_example_layout.xml
│ ├── profile_content.xml
│ ├── profile_header.xml
│ └── rotate_task_example_layout.xml
│ ├── mipmap-anydpi-v26
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── values-v21
│ └── styles.xml
│ ├── values-v23
│ └── styles.xml
│ ├── values-v29
│ └── styles.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── bottomdrawer
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── github
│ │ └── heyalex
│ │ ├── bottomdrawer
│ │ ├── BottomDrawer.kt
│ │ ├── BottomDrawerDialog.kt
│ │ ├── BottomDrawerFragment.kt
│ │ └── TranslationUpdater.kt
│ │ ├── handle
│ │ ├── PlainHandleView.kt
│ │ └── PullHandleView.kt
│ │ └── utils
│ │ ├── BottomDrawerDelegate.kt
│ │ └── DialogFragmentExtension.kt
│ └── res
│ ├── layout
│ └── bottom_drawer_layout.xml
│ ├── values-v21
│ └── styles.xml
│ ├── values-v23
│ └── styles.xml
│ ├── values-v27
│ └── styles.xml
│ └── values
│ ├── attrs.xml
│ ├── colors.xml
│ ├── dimens.xml
│ ├── ids.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── raw
├── ceramic mug.jpg
├── dinner_set.jpg
├── linen napkins.jpeg
├── sample_custom_arrow.gif
├── sample_custom_pull.gif
├── sample_google_task.gif
└── wine_glass.webp
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2019 Alex Fialko
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
Bottom Drawer
2 | Easy way to make Bottom Sheet with animation
3 | 
4 |
5 | ## Usage
6 | To customize Bottom Drawer you need to define a new style with extending BottomDialogTheme
7 |
8 | You can use the following properties in your BottomDrawer Theme.
9 |
10 | | Properties | Type | Default |
11 | | ------------------------ | --------------------------------- | ------- |
12 | | `should_draw_under_status_bar` | boolean | false |
13 | | `should_draw_content_under_handle_view` | boolean | false |
14 | | `bottom_sheet_corner_radius` | dimension | 10dp |
15 | | `bottom_sheet_extra_padding` | dimension | 4dp |
16 | | `bottom_drawer_background` | color | WHITE |
17 |
18 |
19 | It will be something like:
20 | ```xml
21 |
25 | ```
26 | You can make your own HandleView and implement TranslationUpdater interface for getting callbacks.
27 | Or you can use defined handle views by library like PlainHandleView or PullHandleView (check sample app).
28 |
29 | After customizing theme and choosing handle view, you need to override configureBottomDrawer method and pass theme, handle view to BottomDrawerFragment.
30 |
31 | So the following example will make Google Tasks fragment like on main preview:
32 | ```kotlin
33 | class GoogleTaskExampleDialog : BottomDrawerFragment() {
34 |
35 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
36 | super.onCreateView(inflater, container, savedInstanceState)
37 | return inflater.inflate(R.layout.your_layout, container, false)
38 | }
39 |
40 | override fun configureBottomDrawer(): BottomDrawerDialog {
41 | return BottomDrawerDialog.build(context!!) {
42 | theme = R.style.Plain
43 | //configure handle view
44 | handleView = PlainHandleView(context).apply {
45 | val widthHandle =
46 | resources.getDimensionPixelSize(R.dimen.bottom_sheet_handle_width)
47 | val heightHandle =
48 | resources.getDimensionPixelSize(R.dimen.bottom_sheet_handle_height)
49 | val params =
50 | FrameLayout.LayoutParams(widthHandle, heightHandle, Gravity.CENTER_HORIZONTAL)
51 |
52 | params.topMargin =
53 | resources.getDimensionPixelSize(R.dimen.bottom_sheet_handle_top_margin)
54 |
55 | layoutParams = params
56 | }
57 | }
58 | }
59 | }
60 | ```
61 |
62 |
63 | You also can change color and corner by code in BottomDrawerFragment:
64 | ```kotlin
65 | changeCornerRadius(radius: Float)
66 | changeBackgroundColor(color: Int)
67 | ```
68 |
69 | ## Integration
70 |
71 | This library is available on **jitpack**, so you need to add this repository to your root build.gradle:
72 |
73 | ```groovy
74 | allprojects {
75 | repositories {
76 | ...
77 | maven { url 'https://jitpack.io' }
78 | }
79 | }
80 | ```
81 |
82 | Add the dependency:
83 |
84 | ```groovy
85 | dependencies {
86 | implementation 'com.github.HeyAlex:BottomDrawer:v1.0.0'
87 | }
88 | ```
89 |
90 | ## Samples
91 | You can find more samples in app module, to understand functionality of library.
92 |
93 | 
94 | 
95 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | apply plugin: 'kotlin-android'
4 |
5 | apply plugin: 'kotlin-android-extensions'
6 |
7 | android {
8 | compileSdk 31
9 | defaultConfig {
10 | applicationId "com.github.heyalex.bottomdrawerexample"
11 | minSdkVersion 16
12 | targetSdkVersion 31
13 | versionCode 1
14 | versionName "1.0"
15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 |
24 | repositories {
25 | maven { url "https://jitpack.io" }
26 | }
27 |
28 | compileOptions {
29 | sourceCompatibility JavaVersion.VERSION_1_8
30 | targetCompatibility JavaVersion.VERSION_1_8
31 | }
32 |
33 | kotlinOptions {
34 | jvmTarget = "1.8"
35 | }
36 | }
37 |
38 | allprojects {
39 | repositories {
40 | maven { url 'https://jitpack.io' }
41 | }
42 | }
43 |
44 | dependencies {
45 | implementation fileTree(dir: 'libs', include: ['*.jar'])
46 | implementation project(':bottomdrawer')
47 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
48 | implementation 'com.github.HeyAlex:ExapandableCardView:-SNAPSHOT'
49 | implementation 'androidx.appcompat:appcompat:1.4.1'
50 | implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
51 | implementation 'com.google.android.material:material:1.5.0'
52 | testImplementation 'junit:junit:4.13.2'
53 | androidTestImplementation 'androidx.test:runner:1.4.0'
54 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
55 | implementation 'com.github.rtugeek:colorseekbar:1.7.5'
56 | }
57 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/heyalex/bottomdrawerexample/GoogleTaskExampleDialog.kt:
--------------------------------------------------------------------------------
1 | package com.github.heyalex.bottomdrawerexample
2 |
3 | import android.os.Bundle
4 | import android.view.Gravity
5 | import android.view.LayoutInflater
6 | import android.view.View
7 | import android.view.ViewGroup
8 | import android.widget.FrameLayout
9 | import android.widget.ImageView
10 | import android.widget.SeekBar
11 | import androidx.appcompat.widget.AppCompatCheckBox
12 | import androidx.appcompat.widget.AppCompatSeekBar
13 | import com.github.heyalex.bottomdrawer.BottomDrawerDialog
14 | import com.github.heyalex.bottomdrawer.BottomDrawerFragment
15 | import com.github.heyalex.handle.PlainHandleView
16 | import com.github.heyalex.utils.changeNavigationIconColor
17 | import com.github.heyalex.utils.changeStatusBarIconColor
18 | import com.rtugeek.android.colorseekbar.ColorSeekBar
19 |
20 | class GoogleTaskExampleDialog : BottomDrawerFragment() {
21 |
22 | private var alphaCancelButton = 0f
23 | private lateinit var cancelButton: ImageView
24 |
25 | private lateinit var cornerRadiusSeekBar: AppCompatSeekBar
26 |
27 | private lateinit var navigation: AppCompatCheckBox
28 | private lateinit var statusBar: AppCompatCheckBox
29 | private lateinit var colorSeekBar: ColorSeekBar
30 |
31 | override fun onCreateView(
32 | inflater: LayoutInflater,
33 | container: ViewGroup?,
34 | savedInstanceState: Bundle?
35 | ): View {
36 | val view = inflater.inflate(R.layout.google_task_example_layout, container, false)
37 | cancelButton = view.findViewById(R.id.cancel)
38 | val percent = 0.65f
39 | addBottomSheetCallback {
40 | onSlide { _, slideOffset ->
41 | val alphaTemp = (slideOffset - percent) * (1f / (1f - percent))
42 | alphaCancelButton = if (alphaTemp >= 0) {
43 | alphaTemp
44 | } else {
45 | 0f
46 | }
47 | cancelButton.alpha = alphaCancelButton
48 | cancelButton.isEnabled = alphaCancelButton > 0
49 | }
50 | }
51 | cancelButton.setOnClickListener { dismissWithBehavior() }
52 |
53 | cornerRadiusSeekBar = view.findViewById(R.id.corner_radius_seek_bar)
54 | cornerRadiusSeekBar.max = 200
55 | cornerRadiusSeekBar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
56 | override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
57 | changeCornerRadius(progress.toFloat())
58 | }
59 |
60 | override fun onStartTrackingTouch(seekBar: SeekBar?) {
61 | }
62 |
63 | override fun onStopTrackingTouch(seekBar: SeekBar?) {
64 | }
65 |
66 | })
67 |
68 | navigation = view.findViewById(R.id.navigation_bar_accent)
69 | navigation.setOnCheckedChangeListener { _, isChecked ->
70 | changeNavigationIconColor(isChecked)
71 | }
72 | statusBar = view.findViewById(R.id.status_bar_accent)
73 | statusBar.setOnCheckedChangeListener { _, isChecked ->
74 | changeStatusBarIconColor(isChecked)
75 | }
76 |
77 | colorSeekBar = view.findViewById(R.id.colorSlider)
78 | colorSeekBar.setOnColorChangeListener { _, _, color ->
79 | if (!colorSeekBar.isFirstDraw) {
80 | changeBackgroundColor(color)
81 | }
82 | }
83 |
84 | return view
85 | }
86 |
87 | override fun configureBottomDrawer(): BottomDrawerDialog {
88 | return BottomDrawerDialog.build(context!!) {
89 | theme = R.style.Plain
90 | handleView = PlainHandleView(context).apply {
91 | val widthHandle =
92 | resources.getDimensionPixelSize(R.dimen.bottom_sheet_handle_width)
93 | val heightHandle =
94 | resources.getDimensionPixelSize(R.dimen.bottom_sheet_handle_height)
95 | val params =
96 | FrameLayout.LayoutParams(widthHandle, heightHandle, Gravity.CENTER_HORIZONTAL)
97 |
98 | params.topMargin =
99 | resources.getDimensionPixelSize(R.dimen.bottom_sheet_handle_top_margin)
100 |
101 | layoutParams = params
102 | }
103 | }
104 | }
105 |
106 | override fun onSaveInstanceState(outState: Bundle) {
107 | super.onSaveInstanceState(outState)
108 | outState.putFloat("alphaCancelButton", alphaCancelButton)
109 | }
110 |
111 | override fun onViewStateRestored(savedInstanceState: Bundle?) {
112 | super.onViewStateRestored(savedInstanceState)
113 | alphaCancelButton = savedInstanceState?.getFloat("alphaCancelButton") ?: 0f
114 | cancelButton.alpha = alphaCancelButton
115 | cancelButton.isEnabled = alphaCancelButton > 0
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/heyalex/bottomdrawerexample/GoogleTaskJavaSampleDialog.java:
--------------------------------------------------------------------------------
1 | package com.github.heyalex.bottomdrawerexample;
2 |
3 | import android.os.Bundle;
4 | import android.view.Gravity;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.CompoundButton;
9 | import android.widget.FrameLayout;
10 | import android.widget.ImageView;
11 | import android.widget.SeekBar;
12 |
13 | import com.github.heyalex.bottomdrawer.BottomDrawerDialog;
14 | import com.github.heyalex.bottomdrawer.BottomDrawerFragment;
15 | import com.github.heyalex.handle.PlainHandleView;
16 | import com.github.heyalex.utils.BottomDrawerDelegate;
17 | import com.github.heyalex.utils.DialogFragmentExtensionKt;
18 | import com.rtugeek.android.colorseekbar.ColorSeekBar;
19 |
20 | import org.jetbrains.annotations.NotNull;
21 |
22 | import androidx.annotation.NonNull;
23 | import androidx.annotation.Nullable;
24 | import androidx.appcompat.widget.AppCompatCheckBox;
25 | import androidx.appcompat.widget.AppCompatSeekBar;
26 | import kotlin.Unit;
27 | import kotlin.jvm.functions.Function1;
28 | import kotlin.jvm.functions.Function2;
29 |
30 | public class GoogleTaskJavaSampleDialog extends BottomDrawerFragment {
31 |
32 | float alphaCancelButton = 0f;
33 | ImageView cancelButton;
34 | AppCompatSeekBar cornerRadiusSeekBar;
35 | AppCompatCheckBox navigation;
36 | AppCompatCheckBox statusBar;
37 | ColorSeekBar colorSeekBar;
38 |
39 | @Nullable
40 | @Override
41 | public View onCreateView(@NonNull LayoutInflater inflater,
42 | @Nullable ViewGroup container,
43 | @Nullable Bundle savedInstanceState) {
44 |
45 | View view = inflater.inflate(R.layout.google_task_example_layout, container, false);
46 | cancelButton = view.findViewById(R.id.cancel);
47 | final float percent = 0.65f;
48 |
49 | addBottomSheetCallback(new Function1() {
50 | @Override
51 | public Unit invoke(BottomDrawerDelegate.BottomSheetCallback bottomSheetCallback) {
52 | bottomSheetCallback.onSlide(new Function2() {
53 | @Override
54 | public Unit invoke(View view, Float slideOffset) {
55 | float alphaTemp = (slideOffset - percent) * (1.0F / (1.0F - percent));
56 | GoogleTaskJavaSampleDialog.this.alphaCancelButton = alphaTemp >= (float) 0 ? alphaTemp : 0.0F;
57 | GoogleTaskJavaSampleDialog.this.cancelButton.setAlpha(GoogleTaskJavaSampleDialog.this.alphaCancelButton);
58 | GoogleTaskJavaSampleDialog.this.cancelButton.setEnabled(GoogleTaskJavaSampleDialog.this.alphaCancelButton > 0);
59 | return Unit.INSTANCE;
60 | }
61 | });
62 | return Unit.INSTANCE;
63 | }
64 | });
65 | cancelButton.setOnClickListener(new View.OnClickListener() {
66 | @Override
67 | public void onClick(View v) {
68 | dismissWithBehavior();
69 | }
70 | });
71 |
72 | cornerRadiusSeekBar = view.findViewById(R.id.corner_radius_seek_bar);
73 | cornerRadiusSeekBar.setMax(200);
74 | cornerRadiusSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
75 |
76 | @Override
77 | public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
78 | changeCornerRadius(progress);
79 | }
80 |
81 | @Override
82 | public void onStartTrackingTouch(SeekBar seekBar) {
83 |
84 | }
85 |
86 | @Override
87 | public void onStopTrackingTouch(SeekBar seekBar) {
88 |
89 | }
90 | });
91 |
92 | navigation = view.findViewById(R.id.navigation_bar_accent);
93 | navigation.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
94 | @Override
95 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
96 | DialogFragmentExtensionKt.changeNavigationIconColor(GoogleTaskJavaSampleDialog.this, isChecked);
97 | }
98 | });
99 | statusBar = view.findViewById(R.id.status_bar_accent);
100 | statusBar.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
101 | @Override
102 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
103 | DialogFragmentExtensionKt.changeStatusBarIconColor(GoogleTaskJavaSampleDialog.this, isChecked);
104 | }
105 | });
106 |
107 | colorSeekBar = view.findViewById(R.id.colorSlider);
108 | colorSeekBar.setOnColorChangeListener(new ColorSeekBar.OnColorChangeListener() {
109 | @Override
110 | public void onColorChangeListener(int colorBarPosition,
111 | int alphaBarPosition,
112 | int color) {
113 | if (!colorSeekBar.isFirstDraw()) {
114 | changeBackgroundColor(color);
115 | }
116 | }
117 | });
118 |
119 | return view;
120 | }
121 |
122 | @NotNull
123 | @Override
124 | public BottomDrawerDialog configureBottomDrawer() {
125 | BottomDrawerDialog.Builder builder = new BottomDrawerDialog.Builder(requireContext());
126 |
127 | View handleView = new PlainHandleView(requireContext());
128 | int widthHandle = getResources().getDimensionPixelSize(R.dimen.bottom_sheet_handle_width);
129 | int heightHandle =
130 | getResources().getDimensionPixelSize(R.dimen.bottom_sheet_handle_height);
131 | FrameLayout.LayoutParams params =
132 | new FrameLayout.LayoutParams(widthHandle, heightHandle, Gravity.CENTER_HORIZONTAL);
133 |
134 | params.topMargin =
135 | getResources().getDimensionPixelSize(R.dimen.bottom_sheet_handle_top_margin);
136 | handleView.setLayoutParams(params);
137 |
138 | builder.setHandleView(handleView);
139 |
140 | return builder.build();
141 | }
142 |
143 | @Override
144 | public void onSaveInstanceState(@NonNull @NotNull Bundle outState) {
145 | super.onSaveInstanceState(outState);
146 | outState.putFloat("alphaCancelButton", alphaCancelButton);
147 | }
148 |
149 | @Override
150 | public void onViewStateRestored(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
151 | super.onViewStateRestored(savedInstanceState);
152 | this.alphaCancelButton = savedInstanceState != null ? savedInstanceState.getFloat("alphaCancelButton") : 0.0F;
153 | cancelButton.setAlpha(this.alphaCancelButton);
154 | cancelButton.setEnabled(this.alphaCancelButton > 0);
155 | }
156 | }
157 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/heyalex/bottomdrawerexample/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.github.heyalex.bottomdrawerexample
2 |
3 | import android.graphics.Color
4 | import android.os.Build
5 | import android.os.Bundle
6 | import android.view.View
7 | import android.view.WindowManager
8 | import androidx.appcompat.app.AppCompatActivity
9 | import kotlinx.android.synthetic.main.activity_main.*
10 |
11 |
12 | class MainActivity : AppCompatActivity() {
13 |
14 | override fun onCreate(savedInstanceState: Bundle?) {
15 | super.onCreate(savedInstanceState)
16 | setContentView(R.layout.activity_main)
17 |
18 | window.let {
19 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
20 | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
21 | }
22 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
23 | // for drawing behind status bar
24 | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
25 | }
26 |
27 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
28 | //make system bar to be translucent
29 | window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
30 | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
31 |
32 | //make status bar color transparent
33 | window.statusBarColor = Color.TRANSPARENT
34 |
35 | var flags = it.decorView.systemUiVisibility
36 | // make dark status bar icons
37 | flags =
38 | flags xor View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
39 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
40 | // make dark navigation bar icons
41 | flags =
42 | flags xor View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
43 | }
44 | window.decorView.systemUiVisibility = flags
45 | }
46 | }
47 |
48 | show_button.setOnClickListener {
49 | supportFragmentManager.beginTransaction().add(GoogleTaskExampleDialog(), "test")
50 | .commit()
51 | }
52 |
53 | show_button_sample.setOnClickListener {
54 | supportFragmentManager.beginTransaction().add(PullExampleDialog(), "test1")
55 | .commit()
56 | }
57 |
58 | show_button_second_sample.setOnClickListener {
59 | supportFragmentManager.beginTransaction().add(RotateExampleDialog(), "test1")
60 | .commit()
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/heyalex/bottomdrawerexample/PullExampleDialog.kt:
--------------------------------------------------------------------------------
1 | package com.github.heyalex.bottomdrawerexample
2 |
3 | import android.os.Bundle
4 | import android.view.Gravity
5 | import android.view.LayoutInflater
6 | import android.view.View
7 | import android.view.ViewGroup
8 | import android.widget.FrameLayout
9 | import android.widget.ImageView
10 | import android.widget.SeekBar
11 | import androidx.appcompat.widget.AppCompatCheckBox
12 | import androidx.appcompat.widget.AppCompatSeekBar
13 | import com.github.heyalex.bottomdrawer.BottomDrawerDialog
14 | import com.github.heyalex.bottomdrawer.BottomDrawerFragment
15 | import com.github.heyalex.handle.PullHandleView
16 | import com.github.heyalex.utils.changeNavigationIconColor
17 | import com.github.heyalex.utils.changeStatusBarIconColor
18 | import com.rtugeek.android.colorseekbar.ColorSeekBar
19 |
20 | class PullExampleDialog : BottomDrawerFragment() {
21 |
22 | private var alphaCancelButton = 0f
23 | private lateinit var cancelButton: ImageView
24 |
25 | private lateinit var cornerRadiusSeekBar: AppCompatSeekBar
26 |
27 | private lateinit var navigation: AppCompatCheckBox
28 | private lateinit var statusBar: AppCompatCheckBox
29 | private lateinit var colorSeekBar: ColorSeekBar
30 |
31 | override fun onCreateView(
32 | inflater: LayoutInflater,
33 | container: ViewGroup?,
34 | savedInstanceState: Bundle?
35 | ): View {
36 | val view = inflater.inflate(R.layout.google_task_example_layout, container, false)
37 | cancelButton = view.findViewById(R.id.cancel)
38 | addBottomSheetCallback {
39 | onSlide { _, slideOffset ->
40 | alphaCancelButton = (slideOffset - PERCENT) * (1f / (1f - PERCENT))
41 | cancelButton.alpha = alphaCancelButton
42 | cancelButton.isEnabled = alphaCancelButton > 0
43 | }
44 | }
45 | cancelButton.setOnClickListener { dismissWithBehavior() }
46 |
47 | cornerRadiusSeekBar = view.findViewById(R.id.corner_radius_seek_bar)
48 | cornerRadiusSeekBar.max = 80
49 | cornerRadiusSeekBar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
50 | override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
51 | changeCornerRadius(progress.toFloat())
52 | }
53 |
54 | override fun onStartTrackingTouch(seekBar: SeekBar?) {
55 | }
56 |
57 | override fun onStopTrackingTouch(seekBar: SeekBar?) {
58 | }
59 |
60 | })
61 |
62 | navigation = view.findViewById(R.id.navigation_bar_accent)
63 | navigation.setOnCheckedChangeListener { _, isChecked ->
64 | changeNavigationIconColor(isChecked)
65 | }
66 | statusBar = view.findViewById(R.id.status_bar_accent)
67 | statusBar.setOnCheckedChangeListener { _, isChecked ->
68 | changeStatusBarIconColor(isChecked)
69 | }
70 |
71 | colorSeekBar = view.findViewById(R.id.colorSlider)
72 | colorSeekBar.setOnColorChangeListener { _, _, color ->
73 | if (!colorSeekBar.isFirstDraw) {
74 | changeBackgroundColor(color)
75 | }
76 | }
77 |
78 | return view
79 | }
80 |
81 | override fun configureBottomDrawer(): BottomDrawerDialog {
82 | return BottomDrawerDialog.build(context!!) {
83 | theme = R.style.Pull
84 | handleView = PullHandleView(context).apply {
85 | val widthHandle =
86 | resources.getDimensionPixelSize(R.dimen.sample_bottom_sheet_handle_width)
87 | val heightHandle =
88 | resources.getDimensionPixelSize(R.dimen.sample_bottom_sheet_handle_height)
89 | val params =
90 | FrameLayout.LayoutParams(widthHandle, heightHandle, Gravity.CENTER_HORIZONTAL)
91 |
92 | params.topMargin =
93 | resources.getDimensionPixelSize(R.dimen.sample_bottom_sheet_handle_top_margin)
94 |
95 | layoutParams = params
96 | }
97 | }
98 | }
99 |
100 | override fun onSaveInstanceState(outState: Bundle) {
101 | super.onSaveInstanceState(outState)
102 | outState.putFloat("alphaCancelButton", alphaCancelButton)
103 | }
104 |
105 | override fun onViewStateRestored(savedInstanceState: Bundle?) {
106 | super.onViewStateRestored(savedInstanceState)
107 | alphaCancelButton = savedInstanceState?.getFloat("alphaCancelButton") ?: 0f
108 | }
109 |
110 | companion object {
111 | const val PERCENT = 0.65f
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/heyalex/bottomdrawerexample/RotateExampleDialog.kt:
--------------------------------------------------------------------------------
1 | package com.github.heyalex.bottomdrawerexample
2 |
3 | import android.os.Bundle
4 | import android.view.Gravity
5 | import android.view.LayoutInflater
6 | import android.view.View
7 | import android.view.ViewGroup
8 | import android.widget.FrameLayout
9 | import android.widget.SeekBar
10 | import androidx.appcompat.widget.AppCompatCheckBox
11 | import androidx.appcompat.widget.AppCompatSeekBar
12 | import androidx.core.content.ContextCompat
13 | import com.github.heyalex.bottomdrawer.BottomDrawerDialog
14 | import com.github.heyalex.bottomdrawer.BottomDrawerFragment
15 | import com.github.heyalex.bottomdrawerexample.handle.RotateHandleView
16 | import com.github.heyalex.utils.changeNavigationIconColor
17 | import com.github.heyalex.utils.changeStatusBarIconColor
18 | import com.google.android.material.bottomsheet.BottomSheetBehavior
19 | import com.rtugeek.android.colorseekbar.ColorSeekBar
20 |
21 | class RotateExampleDialog : BottomDrawerFragment() {
22 |
23 | private lateinit var cornerRadiusSeekBar: AppCompatSeekBar
24 |
25 | private lateinit var navigation: AppCompatCheckBox
26 | private lateinit var statusBar: AppCompatCheckBox
27 | private lateinit var colorSeekBar: ColorSeekBar
28 |
29 | override fun onCreateView(
30 | inflater: LayoutInflater,
31 | container: ViewGroup?,
32 | savedInstanceState: Bundle?
33 | ): View {
34 |
35 | val view = inflater.inflate(R.layout.rotate_task_example_layout, container, false)
36 | cornerRadiusSeekBar = view.findViewById(R.id.corner_radius_seek_bar)
37 | cornerRadiusSeekBar.max = 80
38 | cornerRadiusSeekBar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
39 | override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
40 | changeCornerRadius(progress.toFloat())
41 | }
42 |
43 | override fun onStartTrackingTouch(seekBar: SeekBar?) {
44 | }
45 |
46 | override fun onStopTrackingTouch(seekBar: SeekBar?) {
47 | }
48 |
49 | })
50 |
51 | navigation = view.findViewById(R.id.navigation_bar_accent)
52 | navigation.setOnCheckedChangeListener { _, isChecked ->
53 | changeNavigationIconColor(isChecked)
54 | }
55 | statusBar = view.findViewById(R.id.status_bar_accent)
56 | statusBar.setOnCheckedChangeListener { _, isChecked ->
57 | changeStatusBarIconColor(isChecked)
58 | }
59 |
60 | colorSeekBar = view.findViewById(R.id.colorSlider)
61 | colorSeekBar.setOnColorChangeListener { _, _, color ->
62 | if (!colorSeekBar.isFirstDraw) {
63 | changeBackgroundColor(color)
64 | }
65 | }
66 |
67 | return view
68 | }
69 |
70 | override fun configureBottomDrawer(): BottomDrawerDialog {
71 | return BottomDrawerDialog.build(context!!) {
72 | theme = R.style.Rotate
73 | handleView = RotateHandleView(context).apply {
74 | val widthHandle =
75 | resources.getDimensionPixelSize(R.dimen.rotate_sample_bottom_sheet_handle_width)
76 | val heightHandle =
77 | resources.getDimensionPixelSize(R.dimen.rotate_sample_bottom_sheet_handle_height)
78 | val params =
79 | FrameLayout.LayoutParams(widthHandle, heightHandle, Gravity.END)
80 |
81 | params.topMargin =
82 | resources.getDimensionPixelSize(R.dimen.rotate_sample_bottom_sheet_handle_margin)
83 |
84 | params.rightMargin =
85 | resources.getDimensionPixelSize(R.dimen.rotate_sample_bottom_sheet_handle_margin)
86 |
87 | layoutParams = params
88 | background =
89 | ContextCompat.getDrawable(context, R.drawable.ic_expand_less_black_24dp)
90 |
91 | setOnClickListener {
92 | when (getCurrentState()) {
93 | BottomSheetBehavior.STATE_EXPANDED -> dismissWithBehavior()
94 | BottomSheetBehavior.STATE_COLLAPSED,
95 | BottomSheetBehavior.STATE_HALF_EXPANDED -> expandWithBehaivor()
96 |
97 | }
98 | }
99 | }
100 | }
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/heyalex/bottomdrawerexample/handle/RotateHandleView.kt:
--------------------------------------------------------------------------------
1 | package com.github.heyalex.bottomdrawerexample.handle
2 |
3 | import android.content.Context
4 | import androidx.appcompat.widget.AppCompatImageView
5 | import com.github.heyalex.bottomdrawer.TranslationUpdater
6 |
7 | class RotateHandleView(context: Context) : AppCompatImageView(context), TranslationUpdater {
8 | override fun updateTranslation(value: Float) {
9 | this.rotation = -180 * value
10 | }
11 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/circular_background.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
7 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_close_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_expand_less_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_person_add_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_settings_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
20 |
21 |
27 |
28 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/compact_profile_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
22 |
23 |
32 |
33 |
38 |
39 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
30 |
31 |
32 |
33 |
34 |
39 |
40 |
44 |
45 |
51 |
52 |
58 |
59 |
65 |
66 |
72 |
73 |
79 |
80 |
86 |
87 |
93 |
94 |
100 |
101 |
107 |
108 |
114 |
115 |
121 |
122 |
128 |
129 |
135 |
136 |
142 |
143 |
149 |
150 |
156 |
157 |
163 |
164 |
165 |
171 |
172 |
178 |
179 |
185 |
186 |
192 |
193 |
194 |
195 |
196 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/example_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
18 |
19 |
23 |
24 |
28 |
29 |
35 |
36 |
42 |
43 |
49 |
50 |
56 |
57 |
58 |
63 |
64 |
69 |
70 |
74 |
75 |
76 |
77 |
78 |
84 |
85 |
91 |
92 |
98 |
99 |
105 |
106 |
112 |
113 |
119 |
120 |
126 |
127 |
133 |
134 |
140 |
141 |
147 |
148 |
154 |
155 |
161 |
162 |
168 |
169 |
175 |
176 |
182 |
183 |
189 |
190 |
196 |
197 |
198 |
204 |
205 |
211 |
212 |
218 |
219 |
225 |
226 |
227 |
228 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/google_task_example_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
31 |
32 |
33 |
34 |
35 |
40 |
41 |
45 |
46 |
52 |
53 |
59 |
60 |
66 |
67 |
73 |
74 |
80 |
81 |
87 |
88 |
94 |
95 |
101 |
102 |
108 |
109 |
115 |
116 |
122 |
123 |
129 |
130 |
136 |
137 |
143 |
144 |
150 |
151 |
157 |
158 |
164 |
165 |
166 |
172 |
173 |
179 |
180 |
186 |
187 |
193 |
194 |
195 |
196 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/profile_content.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
19 |
20 |
25 |
26 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/profile_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
21 |
22 |
31 |
32 |
37 |
38 |
42 |
43 |
44 |
45 |
57 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/rotate_task_example_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
31 |
32 |
33 |
34 |
35 |
40 |
41 |
45 |
46 |
52 |
53 |
59 |
60 |
66 |
67 |
73 |
74 |
80 |
81 |
87 |
88 |
94 |
95 |
101 |
102 |
108 |
109 |
115 |
116 |
122 |
123 |
129 |
130 |
136 |
137 |
143 |
144 |
150 |
151 |
157 |
158 |
164 |
165 |
166 |
172 |
173 |
179 |
180 |
186 |
187 |
193 |
194 |
195 |
196 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HeyAlex/BottomDrawer/c4c24227e03d6f9eb00b6c4d4e8882306e2da68c/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HeyAlex/BottomDrawer/c4c24227e03d6f9eb00b6c4d4e8882306e2da68c/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HeyAlex/BottomDrawer/c4c24227e03d6f9eb00b6c4d4e8882306e2da68c/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HeyAlex/BottomDrawer/c4c24227e03d6f9eb00b6c4d4e8882306e2da68c/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HeyAlex/BottomDrawer/c4c24227e03d6f9eb00b6c4d4e8882306e2da68c/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HeyAlex/BottomDrawer/c4c24227e03d6f9eb00b6c4d4e8882306e2da68c/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HeyAlex/BottomDrawer/c4c24227e03d6f9eb00b6c4d4e8882306e2da68c/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HeyAlex/BottomDrawer/c4c24227e03d6f9eb00b6c4d4e8882306e2da68c/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HeyAlex/BottomDrawer/c4c24227e03d6f9eb00b6c4d4e8882306e2da68c/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HeyAlex/BottomDrawer/c4c24227e03d6f9eb00b6c4d4e8882306e2da68c/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v23/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v29/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #008577
4 | #00574B
5 | #D81B60
6 | #E0E0E0
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 30dp
4 | 5dp
5 | 8dp
6 |
7 | 36dp
8 | 12dp
9 | 8dp
10 |
11 | 35dp
12 | 35dp
13 | 14dp
14 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | BottomDrawerExample
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
11 |
12 |
16 |
17 |
23 |
24 | 20dp
25 |
26 |
29 |
30 |
34 |
35 |
39 |
40 |
45 |
46 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/bottomdrawer/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/bottomdrawer/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android-extensions'
3 | apply plugin: 'kotlin-android'
4 |
5 | android {
6 | compileSdkVersion 31
7 |
8 | defaultConfig {
9 | minSdkVersion 14
10 | targetSdkVersion 31
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15 |
16 | }
17 |
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 | }
25 |
26 | dependencies {
27 | implementation fileTree(dir: 'libs', include: ['*.jar'])
28 |
29 | implementation 'com.google.android.material:material:1.5.0'
30 | testImplementation 'junit:junit:4.13.2'
31 | androidTestImplementation 'androidx.test:runner:1.4.0'
32 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
33 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
34 | }
35 | repositories {
36 | mavenCentral()
37 | }
38 |
--------------------------------------------------------------------------------
/bottomdrawer/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/bottomdrawer/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/bottomdrawer/src/main/java/com/github/heyalex/bottomdrawer/BottomDrawer.kt:
--------------------------------------------------------------------------------
1 | package com.github.heyalex.bottomdrawer
2 |
3 | import android.content.Context
4 | import android.content.res.ColorStateList
5 | import android.content.res.TypedArray
6 | import android.graphics.Canvas
7 | import android.graphics.Point
8 | import android.graphics.Rect
9 | import android.os.Build
10 | import android.util.AttributeSet
11 | import android.view.LayoutInflater
12 | import android.view.View
13 | import android.view.ViewGroup
14 | import android.view.WindowManager
15 | import android.widget.FrameLayout
16 | import androidx.annotation.LayoutRes
17 | import androidx.core.content.ContextCompat
18 | import androidx.core.view.ViewCompat
19 | import com.google.android.material.shape.CornerFamily
20 | import com.google.android.material.shape.MaterialShapeDrawable
21 | import com.google.android.material.shape.ShapeAppearanceModel
22 |
23 | class BottomDrawer : FrameLayout {
24 |
25 | @LayoutRes
26 | private var contentViewRes: Int = View.NO_ID
27 |
28 | private lateinit var content: View
29 |
30 | private var container: ViewGroup
31 | private val rect: Rect = Rect()
32 |
33 | private val backgroundDrawable: MaterialShapeDrawable
34 | private var drawerBackground: Int = 0
35 | private var cornerRadius: Float = 0f
36 | private var extraPadding: Int = 0
37 | private var diffWithStatusBar: Int = 0
38 | private var translationView: Float = 0f
39 |
40 | private var translationUpdater: TranslationUpdater? = null
41 | private var handleView: View? = null
42 |
43 | private var isEnoughToFullExpand: Boolean = false
44 | private var isEnoughToCollapseExpand: Boolean = false
45 |
46 | private var heightPixels: Int
47 | private var fullHeight: Int
48 | private var collapseHeight: Int
49 |
50 | private var shouldDrawUnderStatus: Boolean = false
51 | private var shouldDrawUnderHandle: Boolean = false
52 |
53 | constructor(context: Context) : this(context, null)
54 | constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
55 |
56 | constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int)
57 | : super(context, attrs, defStyleAttr) {
58 |
59 | setWillNotDraw(false)
60 | initAttributes(context, attrs)
61 |
62 | if (contentViewRes != View.NO_ID) {
63 | content = LayoutInflater.from(context).inflate(contentViewRes, null).apply {
64 | layoutParams =
65 | LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
66 | }
67 | }
68 |
69 | backgroundDrawable = MaterialShapeDrawable(
70 | ShapeAppearanceModel.builder(
71 | context,
72 | attrs,
73 | R.attr.bottomSheetStyle,
74 | 0
75 | ).build()
76 | ).apply {
77 | fillColor = ColorStateList.valueOf(drawerBackground)
78 | }
79 |
80 | calculateDiffStatusBar(0)
81 |
82 | val wm = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
83 | val display = wm.defaultDisplay
84 | val smallest = Point()
85 | val tallest = Point()
86 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
87 | display.getCurrentSizeRange(smallest, tallest)
88 | }
89 |
90 | heightPixels = tallest.y
91 | fullHeight = heightPixels
92 | collapseHeight = heightPixels / 2
93 |
94 | ViewCompat.setOnApplyWindowInsetsListener(this) { v, insets ->
95 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
96 | heightPixels = context.resources.displayMetrics.heightPixels
97 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
98 | heightPixels -= insets.systemWindowInsetTop
99 | }
100 |
101 | fullHeight = heightPixels
102 | collapseHeight = heightPixels / 2
103 |
104 | calculateDiffStatusBar(insets.systemWindowInsetTop)
105 | }
106 | insets.consumeSystemWindowInsets()
107 | }
108 |
109 | container = FrameLayout(context).apply {
110 | val params =
111 | LayoutParams(
112 | ViewGroup.LayoutParams.MATCH_PARENT,
113 | ViewGroup.LayoutParams.WRAP_CONTENT
114 | )
115 |
116 | layoutParams = params
117 | }
118 | super.addView(container)
119 | if (contentViewRes != View.NO_ID) {
120 | addView(content)
121 | }
122 | onSlide(0f)
123 | }
124 |
125 | private fun initAttributes(context: Context, attrs: AttributeSet?) {
126 | var attr: TypedArray? = null
127 | try {
128 | attr = context.obtainStyledAttributes(attrs, R.styleable.BottomDrawer, 0, 0)
129 | extraPadding = attr!!.getDimensionPixelSize(
130 | R.styleable.BottomDrawer_bottom_sheet_extra_padding,
131 | resources.getDimensionPixelSize(R.dimen.bottom_sheet_extra_padding)
132 | )
133 |
134 | cornerRadius = attr.getDimensionPixelSize(
135 | R.styleable.BottomDrawer_bottom_sheet_corner_radius,
136 | resources.getDimensionPixelSize(R.dimen.bottom_sheet_corner_radius)
137 | ).toFloat()
138 |
139 | shouldDrawUnderStatus = attr.getBoolean(
140 | R.styleable.BottomDrawer_should_draw_under_status_bar,
141 | false
142 | )
143 |
144 | shouldDrawUnderHandle = attr.getBoolean(
145 | R.styleable.BottomDrawer_should_draw_content_under_handle_view,
146 | false
147 | )
148 |
149 | drawerBackground = attr.getColor(
150 | R.styleable.BottomDrawer_bottom_drawer_background,
151 | ContextCompat.getColor(context, R.color.bottom_drawer_background)
152 | )
153 |
154 | contentViewRes =
155 | attr.getResourceId(R.styleable.BottomDrawer_content_view, View.NO_ID)
156 |
157 |
158 | } finally {
159 | attr?.recycle()
160 | }
161 | }
162 |
163 | override fun addView(child: View?) {
164 | container.addView(child)
165 | }
166 |
167 | override fun onDraw(canvas: Canvas) {
168 | if (!rect.isEmpty) {
169 | backgroundDrawable.bounds = rect
170 | backgroundDrawable.draw(canvas)
171 | }
172 | }
173 |
174 | override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
175 | super.onLayout(changed, left, top, right, bottom)
176 | rect.set(left, top, right - left, bottom - top)
177 |
178 | val measuredHeight = (container.parent as ViewGroup).measuredHeight
179 | isEnoughToFullExpand =
180 | measuredHeight >= fullHeight
181 | isEnoughToCollapseExpand = measuredHeight >= collapseHeight
182 |
183 | backgroundDrawable.interpolation = if (!isEnoughToFullExpand) 1f else 0f
184 | }
185 |
186 | fun onSlide(value: Float) {
187 | if (handleNonExpandableViews()) {
188 | return
189 | }
190 |
191 | if (value <= offsetTrigger) {
192 | backgroundDrawable.interpolation = 1f
193 | container.translationY = 0f
194 | if (!shouldDrawUnderStatus) {
195 | handleView?.translationY = 0f
196 | }
197 | translationUpdater?.updateTranslation(0f)
198 | return
199 | }
200 | val offset = ((value - offsetTrigger) * (1f / (1f - offsetTrigger)))
201 | translateViews(offset)
202 | translationUpdater?.updateTranslation(offset)
203 | val invert = 1.0f - offset
204 | backgroundDrawable.interpolation = invert
205 | invalidate()
206 | }
207 |
208 | private fun handleNonExpandableViews(): Boolean {
209 | if (!isEnoughToFullExpand) {
210 | backgroundDrawable.interpolation = 1f
211 | translationUpdater?.updateTranslation(0f)
212 | translateViews(0f)
213 | return true
214 | }
215 | return false
216 | }
217 |
218 | private fun translateViews(value: Float) {
219 | translateViews(value, diffWithStatusBar)
220 | }
221 |
222 | internal fun globalTranslationViews() {
223 | if (isEnoughToFullExpand && top < fullHeight - collapseHeight) {
224 | updateTranslationOnGlobalLayoutChanges()
225 | } else {
226 | if (container.paddingBottom != 0) {
227 | container.setPadding(0, 0, 0, 0)
228 | }
229 | translationUpdater?.updateTranslation(0f)
230 | if (top == fullHeight - collapseHeight || !rect.isEmpty) {
231 | backgroundDrawable.interpolation = 1f
232 | translateViews(0f)
233 | }
234 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isEnoughToFullExpand) {
235 | updateTranslationOnGlobalLayoutChanges()
236 | }
237 | }
238 | }
239 |
240 | private fun updateTranslationOnGlobalLayoutChanges() {
241 | //if view is expanded, we need to make a correct translation depends on change orientation
242 | val diff = diffWithStatusBar - top
243 | val translationView = if (diff in 0..diffWithStatusBar) {
244 | diff.toFloat()
245 | } else {
246 | 0f
247 | }
248 | translateViews(1f, translationView.toInt())
249 | if (translationView == 0f && Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) {
250 | translationUpdater?.updateTranslation(0f)
251 | backgroundDrawable.interpolation = 1f
252 | } else if (top == 0) {
253 | translationUpdater?.updateTranslation(1f)
254 | backgroundDrawable.interpolation = 0f
255 | }
256 | }
257 |
258 | private fun translateViews(offset: Float, height: Int) {
259 | translationView = height * offset
260 | container.translationY = translationView
261 | if (!shouldDrawUnderStatus) {
262 | handleView?.translationY = translationView
263 | }
264 |
265 | val paddingBottom = translationView.toInt()
266 | if (top == 0 && translationView != 0f && container.paddingBottom != paddingBottom) {
267 | container.setPadding(0, 0, 0, paddingBottom)
268 | }
269 | }
270 |
271 | private fun calculateDiffStatusBar(topInset: Int) {
272 | diffWithStatusBar =
273 | when {
274 | Build.VERSION.SDK_INT < Build.VERSION_CODES.M -> 0
275 | else -> topInset
276 | }
277 |
278 | diffWithStatusBar += extraPadding
279 | }
280 |
281 | fun addHandleView(newHandleView: View?) {
282 | handleView = newHandleView
283 | handleView?.let { view ->
284 | super.addView(view)
285 | handleView = view
286 | val marginLayoutParams = handleView?.layoutParams as MarginLayoutParams
287 | val height = marginLayoutParams.height + marginLayoutParams.topMargin
288 |
289 | if (!shouldDrawUnderHandle) {
290 | container.setMarginExtensionFunction(0, height, 0, 0)
291 | } else {
292 | container.setMarginExtensionFunction(0, 0, 0, 0)
293 | }
294 |
295 | translationUpdater = view as TranslationUpdater
296 | }
297 | }
298 |
299 | private fun View.setMarginExtensionFunction(left: Int, top: Int, right: Int, bottom: Int) {
300 | val params = layoutParams as MarginLayoutParams
301 | params.setMargins(left, top, right, bottom)
302 | layoutParams = params
303 | }
304 |
305 | fun changeCornerRadius(radius: Float) {
306 | // cornerRadius = radius
307 | // appearanceModel.toBuilder().apply {
308 | // setTopLeftCorner(CornerFamily.ROUNDED, cornerRadius)
309 | // setTopRightCorner(CornerFamily.ROUNDED, cornerRadius)
310 | // }
311 | //
312 | // backgroundDrawable.shapeAppearanceModel = appearanceModel
313 | // backgroundDrawable.interpolation = if (!isEnoughToFullExpand) 1f else 0f
314 | //
315 | // invalidate()
316 | }
317 |
318 | fun changeCornerTreatment(@CornerFamily cornerFamily: Int) {
319 | val shapeAppearanceModel = ShapeAppearanceModel().toBuilder().apply {
320 | setTopLeftCorner(cornerFamily, cornerRadius)
321 | setTopRightCorner(cornerFamily, cornerRadius)
322 | }
323 |
324 | backgroundDrawable.shapeAppearanceModel = shapeAppearanceModel.build()
325 | backgroundDrawable.interpolation = 1f
326 |
327 | invalidate()
328 | }
329 |
330 | fun changeBackgroundColor(color: Int) {
331 | drawerBackground = color
332 | backgroundDrawable.setTint(drawerBackground)
333 | invalidate()
334 | }
335 |
336 | fun changeExtraPadding(extraPadding: Int) {
337 | this.extraPadding = extraPadding
338 | invalidate()
339 | }
340 |
341 | fun shouldDrawUnderHandleView(shouldDrawUnderHandleView: Boolean) {
342 | shouldDrawUnderHandle = shouldDrawUnderHandleView
343 | super.removeView(handleView)
344 | addHandleView(handleView)
345 | invalidate()
346 | }
347 |
348 | fun shouldDrawUnderStatusBar(shouldDrawerUnderStatus: Boolean) {
349 | shouldDrawUnderStatus = shouldDrawerUnderStatus
350 | invalidate()
351 | }
352 |
353 | companion object {
354 | const val offsetTrigger: Float = 0.75f
355 | }
356 | }
--------------------------------------------------------------------------------
/bottomdrawer/src/main/java/com/github/heyalex/bottomdrawer/BottomDrawerDialog.kt:
--------------------------------------------------------------------------------
1 | package com.github.heyalex.bottomdrawer
2 |
3 | import android.content.Context
4 | import android.graphics.Color
5 | import android.os.Build
6 | import android.os.Bundle
7 | import android.view.View
8 | import android.view.ViewGroup
9 | import android.view.Window
10 | import android.view.WindowManager
11 | import androidx.annotation.LayoutRes
12 | import androidx.annotation.StyleRes
13 | import androidx.appcompat.app.AppCompatDialog
14 | import com.github.heyalex.utils.BottomDialog
15 | import com.github.heyalex.utils.BottomDrawerDelegate
16 | import com.google.android.material.bottomsheet.BottomSheetBehavior
17 |
18 | open class BottomDrawerDialog(context: Context, @StyleRes theme: Int = R.style.BottomDialogTheme) :
19 | AppCompatDialog(context, theme), BottomDialog {
20 |
21 | internal var bottomDrawerDelegate = BottomDrawerDelegate(this.context, this)
22 | internal val drawer: BottomDrawer?
23 | get() = bottomDrawerDelegate.drawer
24 |
25 | internal val behavior: BottomSheetBehavior?
26 | get() = bottomDrawerDelegate.behavior
27 |
28 | init {
29 | supportRequestWindowFeature(Window.FEATURE_NO_TITLE)
30 | }
31 |
32 | override fun onCreate(savedInstanceState: Bundle?) {
33 | super.onCreate(savedInstanceState)
34 | window?.let {
35 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
36 | it.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
37 | }
38 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
39 | it.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
40 | }
41 |
42 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
43 | it.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
44 | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
45 | it.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)
46 | it.statusBarColor = Color.TRANSPARENT
47 |
48 | var flags = it.decorView.systemUiVisibility
49 | flags =
50 | flags xor View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
51 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
52 | flags =
53 | flags xor View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
54 | }
55 | it.decorView.systemUiVisibility = flags
56 | }
57 | }
58 | }
59 |
60 | override fun setContentView(@LayoutRes layoutResId: Int) {
61 | super.setContentView(bottomDrawerDelegate.wrapInBottomSheet(layoutResId, null, null))
62 | }
63 |
64 | override fun setContentView(view: View) {
65 | super.setContentView(bottomDrawerDelegate.wrapInBottomSheet(0, view, null))
66 | }
67 |
68 | override fun setContentView(view: View, params: ViewGroup.LayoutParams?) {
69 | super.setContentView(bottomDrawerDelegate.wrapInBottomSheet(0, view, params))
70 | }
71 |
72 |
73 | override fun onStart() {
74 | super.onStart()
75 | bottomDrawerDelegate.open()
76 | }
77 |
78 | override fun onBackPressed() {
79 | bottomDrawerDelegate.onBackPressed()
80 | }
81 |
82 | override fun onSaveInstanceState(): Bundle {
83 | val superState = super.onSaveInstanceState()
84 | bottomDrawerDelegate.onSaveInstanceState(superState)
85 | return superState
86 | }
87 |
88 | override fun onRestoreInstanceState(savedInstanceState: Bundle) {
89 | super.onRestoreInstanceState(savedInstanceState)
90 | bottomDrawerDelegate.onRestoreInstanceState(savedInstanceState)
91 | }
92 |
93 | override fun onDismiss() {
94 | dismiss()
95 | }
96 |
97 | override fun onCancel() {
98 | cancel()
99 | }
100 |
101 | companion object {
102 | inline fun build(context: Context, block: Builder.() -> Unit) =
103 | Builder(context).apply(block).build()
104 | }
105 |
106 | class Builder(
107 | val context: Context
108 | ) {
109 | var theme: Int = R.style.BottomDialogTheme
110 | var handleView: View? = null
111 | var isCancelableOnTouchOutside: Boolean? = null
112 |
113 | fun build() = BottomDrawerDialog(context, theme).apply {
114 | whenNotNull(this@Builder.isCancelableOnTouchOutside) {
115 | bottomDrawerDelegate.isCancelableOnTouchOutside = it
116 | }
117 |
118 | whenNotNull(this@Builder.handleView) {
119 | bottomDrawerDelegate.handleView = it
120 | }
121 | }
122 |
123 | private inline fun whenNotNull(input: T?, callback: (T) -> R): R? {
124 | return input?.let(callback)
125 | }
126 | }
127 | }
--------------------------------------------------------------------------------
/bottomdrawer/src/main/java/com/github/heyalex/bottomdrawer/BottomDrawerFragment.kt:
--------------------------------------------------------------------------------
1 | package com.github.heyalex.bottomdrawer
2 |
3 | import android.app.Dialog
4 | import android.os.Bundle
5 | import android.view.ViewTreeObserver
6 | import com.github.heyalex.utils.BottomDrawerDelegate
7 | import com.google.android.material.bottomsheet.BottomSheetBehavior
8 | import com.google.android.material.shape.CornerFamily
9 |
10 | abstract class BottomDrawerFragment : androidx.fragment.app.DialogFragment(),
11 | ViewTreeObserver.OnGlobalLayoutListener {
12 |
13 | private var bottomDrawerDialog: BottomDrawerDialog? = null
14 |
15 | override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
16 | val dialog = configureBottomDrawer()
17 | bottomDrawerDialog = dialog
18 | return dialog
19 | }
20 |
21 | open fun configureBottomDrawer(): BottomDrawerDialog {
22 | return BottomDrawerDialog(context!!)
23 | }
24 |
25 | override fun onStart() {
26 | super.onStart()
27 | bottomDrawerDialog?.drawer?.viewTreeObserver?.addOnGlobalLayoutListener(this)
28 | dialog!!.setOnDismissListener {
29 | if (isAdded) {
30 | dismissAllowingStateLoss()
31 | }
32 | }
33 | }
34 |
35 | fun dismissWithBehavior() {
36 | bottomDrawerDialog?.behavior?.state = BottomSheetBehavior.STATE_HIDDEN
37 | }
38 |
39 | fun expandWithBehaivor() {
40 | bottomDrawerDialog?.behavior?.state = BottomSheetBehavior.STATE_EXPANDED
41 | }
42 |
43 | fun getCurrentState(): Int? {
44 | return bottomDrawerDialog?.behavior?.state
45 | }
46 |
47 | override fun onGlobalLayout() {
48 | bottomDrawerDialog?.drawer?.globalTranslationViews()
49 | }
50 |
51 | fun addBottomSheetCallback(func: BottomDrawerDelegate.BottomSheetCallback.() -> Unit): BottomSheetBehavior.BottomSheetCallback? {
52 | return bottomDrawerDialog?.bottomDrawerDelegate?.addBottomSheetCallback(func)
53 | }
54 |
55 | fun removeBottomSheetCallback(callback: BottomSheetBehavior.BottomSheetCallback) {
56 | bottomDrawerDialog?.bottomDrawerDelegate?.removeBottomSheetCallback(callback)
57 | }
58 |
59 | fun changeCornerRadius(radius: Float) {
60 | bottomDrawerDialog?.drawer?.changeCornerRadius(radius)
61 | }
62 |
63 | fun changeTopCornerTreatment(@CornerFamily cornerFamily: Int) {
64 | bottomDrawerDialog?.drawer?.changeCornerTreatment(cornerFamily)
65 | }
66 |
67 | fun changeBackgroundColor(color: Int) {
68 | bottomDrawerDialog?.drawer?.changeBackgroundColor(color)
69 | }
70 |
71 | fun changeExtraPadding(extraPadding: Int) {
72 | bottomDrawerDialog?.drawer?.changeExtraPadding(extraPadding)
73 | }
74 | }
--------------------------------------------------------------------------------
/bottomdrawer/src/main/java/com/github/heyalex/bottomdrawer/TranslationUpdater.kt:
--------------------------------------------------------------------------------
1 | package com.github.heyalex.bottomdrawer
2 |
3 | interface TranslationUpdater {
4 | fun updateTranslation(value: Float)
5 | }
--------------------------------------------------------------------------------
/bottomdrawer/src/main/java/com/github/heyalex/handle/PlainHandleView.kt:
--------------------------------------------------------------------------------
1 | package com.github.heyalex.handle
2 |
3 | import android.content.Context
4 | import android.graphics.Canvas
5 | import android.graphics.Paint
6 | import android.graphics.RectF
7 | import android.os.Parcel
8 | import android.os.Parcelable
9 | import android.util.AttributeSet
10 | import android.util.Log
11 | import android.view.View
12 | import androidx.annotation.FloatRange
13 | import androidx.core.content.ContextCompat
14 | import com.github.heyalex.bottomdrawer.R
15 | import com.github.heyalex.bottomdrawer.TranslationUpdater
16 |
17 | class PlainHandleView : View, TranslationUpdater {
18 |
19 | @FloatRange(from = 0.0, to = 1.0)
20 | private var currentOffset = 0f
21 | private var rect = RectF()
22 | private var tempRect: RectF = RectF()
23 |
24 | private var paint = Paint()
25 | private var thickness =
26 | resources.getDimensionPixelSize(R.dimen.bottom_sheet_handle_thickness).toFloat()
27 |
28 | constructor(context: Context) : this(context, null)
29 |
30 | constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
31 |
32 | constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int)
33 | : super(context, attrs, defStyleAttr) {
34 | paint.apply {
35 | color = ContextCompat.getColor(context, R.color.bottom_drawer_handle_view_color)
36 | strokeWidth = thickness
37 | flags = Paint.ANTI_ALIAS_FLAG
38 | }
39 | isSaveEnabled = true
40 | }
41 |
42 | override fun onDraw(canvas: Canvas) {
43 | canvas.drawRoundRect(tempRect, thickness, thickness, paint)
44 | }
45 |
46 | override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
47 | super.onLayout(changed, left, top, right, bottom)
48 | rect.set(left.toFloat(), top.toFloat(), right.toFloat(), bottom.toFloat())
49 | }
50 |
51 | override fun updateTranslation(@FloatRange(from = 0.0, to = 1.0) value: Float) {
52 | currentOffset = value
53 | val offset = (width.toFloat() * currentOffset) / 2
54 | tempRect.set(0 + offset, 0f, width - offset, height.toFloat())
55 | invalidate()
56 | }
57 |
58 | override fun onSaveInstanceState(): Parcelable? {
59 | val superState = super.onSaveInstanceState()
60 | superState?.let {
61 | val customViewSavedState = PlainHandleViewSavedState(superState)
62 | customViewSavedState.offset = currentOffset
63 | return customViewSavedState
64 | }
65 | return superState
66 | }
67 |
68 | override fun onRestoreInstanceState(state: Parcelable) {
69 | Log.d("show_handle", "restore")
70 | val customViewSavedState = state as PlainHandleViewSavedState
71 | currentOffset = customViewSavedState.offset
72 | val offset = (width.toFloat() * currentOffset) / 2
73 | tempRect.set(0 + offset, 0f, width - offset, height.toFloat())
74 | super.onRestoreInstanceState(customViewSavedState.superState)
75 | }
76 |
77 | private class PlainHandleViewSavedState : BaseSavedState {
78 |
79 | internal var offset: Float = 0f
80 |
81 | constructor(superState: Parcelable) : super(superState)
82 |
83 | private constructor(source: Parcel) : super(source) {
84 | offset = source.readFloat()
85 | }
86 |
87 | override fun writeToParcel(out: Parcel, flags: Int) {
88 | super.writeToParcel(out, flags)
89 | out.writeFloat(offset)
90 | }
91 |
92 | companion object CREATOR : Parcelable.Creator {
93 | override fun createFromParcel(source: Parcel): PlainHandleViewSavedState {
94 | return PlainHandleViewSavedState(source)
95 | }
96 |
97 | override fun newArray(size: Int): Array {
98 | return arrayOfNulls(size)
99 | }
100 | }
101 |
102 | override fun describeContents(): Int {
103 | return 0
104 | }
105 | }
106 | }
--------------------------------------------------------------------------------
/bottomdrawer/src/main/java/com/github/heyalex/handle/PullHandleView.kt:
--------------------------------------------------------------------------------
1 | package com.github.heyalex.handle
2 |
3 | import android.content.Context
4 | import android.graphics.Canvas
5 | import android.graphics.Paint
6 | import android.os.Parcel
7 | import android.os.Parcelable
8 | import androidx.annotation.FloatRange
9 | import androidx.core.content.ContextCompat
10 | import android.util.AttributeSet
11 | import android.view.View
12 | import com.github.heyalex.bottomdrawer.R
13 | import com.github.heyalex.bottomdrawer.TranslationUpdater
14 |
15 | class PullHandleView : View, TranslationUpdater {
16 |
17 | @FloatRange(from = 0.0, to = 1.0)
18 | private var currentOffset = 0f
19 |
20 | private var paint = Paint()
21 | private var thickness =
22 | resources.getDimensionPixelSize(R.dimen.bottom_sheet_handle_thickness).toFloat()
23 |
24 | constructor(context: Context) : this(context, null)
25 | constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
26 |
27 | constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int)
28 | : super(context, attrs, defStyleAttr) {
29 | paint.apply {
30 | color = ContextCompat.getColor(context, R.color.bottom_drawer_handle_view_color)
31 | strokeWidth = thickness
32 | flags = Paint.ANTI_ALIAS_FLAG
33 | }
34 | }
35 |
36 | override fun onDraw(canvas: Canvas) {
37 | val radius = thickness / 2
38 |
39 | val halfWidth = width / 2
40 | val halfHeight = height / 2
41 |
42 | val leftX = radius
43 | val rightX = width - radius
44 | val leftRightY = halfHeight - ((halfHeight - radius) * currentOffset)
45 |
46 | val centerX = halfWidth.toFloat()
47 | val centerY = halfHeight + ((halfHeight - radius) * currentOffset)
48 |
49 | canvas.drawCircle(leftX, leftRightY, radius, paint)
50 | canvas.drawLine(leftX, leftRightY, centerX, centerY, paint)
51 |
52 | canvas.drawCircle(centerX, centerY, radius, paint)
53 |
54 | canvas.drawLine(centerX, centerY, rightX, leftRightY, paint)
55 | canvas.drawCircle(rightX, leftRightY, radius, paint)
56 | }
57 |
58 |
59 | override fun updateTranslation(value: Float) {
60 | if (value != currentOffset) {
61 | currentOffset = value
62 | invalidate()
63 | }
64 | }
65 |
66 | override fun onSaveInstanceState(): Parcelable? {
67 | val superState = super.onSaveInstanceState()
68 | superState?.let {
69 | val customViewSavedState = HandleViewSavedState(superState)
70 | customViewSavedState.offset = currentOffset
71 | return customViewSavedState
72 | }
73 | return superState
74 | }
75 |
76 | override fun onRestoreInstanceState(state: Parcelable) {
77 | val customViewSavedState = state as HandleViewSavedState
78 | currentOffset = customViewSavedState.offset
79 | super.onRestoreInstanceState(customViewSavedState.superState)
80 | }
81 |
82 | private class HandleViewSavedState : BaseSavedState {
83 |
84 | internal var offset: Float = 0f
85 |
86 | constructor(superState: Parcelable) : super(superState)
87 |
88 | private constructor(source: Parcel) : super(source) {
89 | offset = source.readFloat()
90 | }
91 |
92 | override fun writeToParcel(out: Parcel, flags: Int) {
93 | super.writeToParcel(out, flags)
94 | out.writeFloat(offset)
95 | }
96 |
97 | companion object CREATOR : Parcelable.Creator {
98 | override fun createFromParcel(source: Parcel): HandleViewSavedState {
99 | return HandleViewSavedState(source)
100 | }
101 |
102 | override fun newArray(size: Int): Array {
103 | return arrayOfNulls(size)
104 | }
105 | }
106 |
107 | override fun describeContents(): Int {
108 | return 0
109 | }
110 | }
111 | }
--------------------------------------------------------------------------------
/bottomdrawer/src/main/java/com/github/heyalex/utils/BottomDrawerDelegate.kt:
--------------------------------------------------------------------------------
1 | package com.github.heyalex.utils
2 |
3 | import android.annotation.SuppressLint
4 | import android.content.Context
5 | import android.os.Bundle
6 | import android.os.Handler
7 | import android.os.Looper
8 | import android.view.LayoutInflater
9 | import android.view.View
10 | import android.view.ViewGroup
11 | import android.widget.FrameLayout
12 | import androidx.coordinatorlayout.widget.CoordinatorLayout
13 | import androidx.core.view.AccessibilityDelegateCompat
14 | import androidx.core.view.ViewCompat
15 | import androidx.core.view.accessibility.AccessibilityNodeInfoCompat
16 | import com.github.heyalex.bottomdrawer.BottomDrawer
17 | import com.github.heyalex.bottomdrawer.R
18 | import com.google.android.material.bottomsheet.BottomSheetBehavior
19 | import java.util.concurrent.CopyOnWriteArrayList
20 |
21 | class BottomDrawerDelegate(
22 | private val context: Context,
23 | private val dialog: BottomDialog
24 | ) {
25 |
26 | internal var behavior: BottomSheetBehavior? = null
27 | internal lateinit var drawer: BottomDrawer
28 | private lateinit var coordinator: CoordinatorLayout
29 | private val callbacks: CopyOnWriteArrayList =
30 | CopyOnWriteArrayList()
31 |
32 | private var offset = 0f
33 | internal var isCancelableOnTouchOutside = true
34 | internal var handleView: View? = null
35 |
36 | @SuppressLint("ClickableViewAccessibility")
37 | fun wrapInBottomSheet(
38 | layoutResId: Int,
39 | view: View?,
40 | params: ViewGroup.LayoutParams?
41 | ): View {
42 | var wrappedView = view
43 | val container = View.inflate(context, R.layout.bottom_drawer_layout, null) as FrameLayout
44 | coordinator = container.findViewById(R.id.bottom_sheet_coordinator)
45 | if (layoutResId != 0 && wrappedView == null) {
46 | wrappedView = LayoutInflater.from(context).inflate(layoutResId, coordinator, false)
47 | }
48 | drawer = coordinator.findViewById(R.id.bottom_sheet_drawer) as BottomDrawer
49 | behavior = BottomSheetBehavior.from(drawer)
50 | behavior?.state = BottomSheetBehavior.STATE_HIDDEN
51 | val metrics = context.resources.displayMetrics
52 | behavior?.peekHeight = metrics.heightPixels / 2
53 | behavior?.isHideable = true
54 |
55 | if (params == null) {
56 | drawer.addView(wrappedView)
57 | } else {
58 | drawer.addView(wrappedView, params)
59 | }
60 | drawer.addHandleView(handleView)
61 |
62 | coordinator.background.alpha = offset.toInt()
63 |
64 | behavior?.setBottomSheetCallback(object :
65 | BottomSheetBehavior.BottomSheetCallback() {
66 | override fun onStateChanged(sheet: View, state: Int) {
67 | callbacks.forEach { callback ->
68 | callback.onStateChanged(sheet, state)
69 | }
70 | }
71 |
72 | override fun onSlide(bottomSheet: View, slideOffset: Float) {
73 | callbacks.forEach { callback ->
74 | callback.onSlide(bottomSheet, slideOffset)
75 | }
76 | }
77 | })
78 |
79 | addBottomSheetCallback {
80 | onSlide { _: View, slideOffset: Float ->
81 | offset = if (slideOffset != slideOffset) {
82 | 0f
83 | } else {
84 | slideOffset
85 | }
86 |
87 | offset++
88 | updateBackgroundOffset()
89 | drawer.onSlide(offset / 2f)
90 | }
91 |
92 | onStateChanged { _: View, newState: Int ->
93 | when (newState) {
94 | BottomSheetBehavior.STATE_HIDDEN -> {
95 | dialog.onDismiss()
96 | }
97 | else -> {
98 |
99 | }
100 | }
101 | }
102 | }
103 |
104 | coordinator.findViewById(R.id.touch_outside)
105 | .setOnClickListener {
106 | if (isCancelableOnTouchOutside) {
107 | behavior?.state = BottomSheetBehavior.STATE_HIDDEN
108 | }
109 | }
110 |
111 | // Handle accessibility events
112 | ViewCompat.setAccessibilityDelegate(
113 | drawer,
114 | object : AccessibilityDelegateCompat() {
115 | override fun onInitializeAccessibilityNodeInfo(
116 | host: View, info: AccessibilityNodeInfoCompat
117 | ) {
118 | super.onInitializeAccessibilityNodeInfo(host, info)
119 | info.isDismissable = true
120 | }
121 |
122 | override fun performAccessibilityAction(
123 | host: View,
124 | action: Int,
125 | args: Bundle
126 | ): Boolean {
127 | if (action == AccessibilityNodeInfoCompat.ACTION_DISMISS) {
128 | dialog.onCancel()
129 | return true
130 | }
131 | return super.performAccessibilityAction(host, action, args)
132 | }
133 | })
134 | drawer.setOnTouchListener { view, event ->
135 | // Consume the event and prevent it from falling through
136 | true
137 | }
138 | return container
139 | }
140 |
141 | fun addBottomSheetCallback(func: BottomSheetCallback.() -> Unit): BottomSheetBehavior.BottomSheetCallback {
142 | val listener = BottomSheetCallback()
143 | listener.func()
144 | callbacks.add(listener)
145 | return listener
146 | }
147 |
148 | fun removeBottomSheetCallback(callback: BottomSheetBehavior.BottomSheetCallback) {
149 | callbacks.remove(callback)
150 | }
151 |
152 | private fun updateBackgroundOffset() {
153 | if (offset <= 1) {
154 | coordinator.background?.alpha = (255 * offset).toInt()
155 | } else {
156 | coordinator.background?.alpha = 255
157 | }
158 | }
159 |
160 | fun open() {
161 | Handler(Looper.getMainLooper()).postDelayed({
162 | behavior?.let {
163 | if (it.state == BottomSheetBehavior.STATE_HIDDEN) {
164 | it.state = BottomSheetBehavior.STATE_HALF_EXPANDED
165 | }
166 | }
167 | }, 50)
168 | }
169 |
170 | fun onBackPressed() {
171 | behavior?.state = BottomSheetBehavior.STATE_HIDDEN
172 | }
173 |
174 | fun onSaveInstanceState(superState: Bundle) {
175 | superState.putFloat("offset", offset)
176 | }
177 |
178 | fun onRestoreInstanceState(savedInstanceState: Bundle) {
179 | offset = savedInstanceState.getFloat("offset")
180 | updateBackgroundOffset()
181 | }
182 |
183 | class BottomSheetCallback : BottomSheetBehavior.BottomSheetCallback() {
184 | private var _onSlide: ((view: View, slideOffset: Float) -> Unit)? = null
185 | private var _onStateChanged: ((view: View, state: Int) -> Unit)? = null
186 |
187 | override fun onSlide(view: View, slideOffset: Float) {
188 | _onSlide?.invoke(view, slideOffset)
189 | }
190 |
191 | fun onSlide(func: (view: View, slideOffset: Float) -> Unit) {
192 | _onSlide = func
193 | }
194 |
195 | override fun onStateChanged(view: View, state: Int) {
196 | _onStateChanged?.invoke(view, state)
197 | }
198 |
199 | fun onStateChanged(func: (view: View, state: Int) -> Unit) {
200 | _onStateChanged = func
201 | }
202 | }
203 | }
204 |
205 | interface BottomDialog {
206 | fun onDismiss()
207 | fun onCancel()
208 | }
--------------------------------------------------------------------------------
/bottomdrawer/src/main/java/com/github/heyalex/utils/DialogFragmentExtension.kt:
--------------------------------------------------------------------------------
1 | package com.github.heyalex.utils
2 |
3 | import android.os.Build
4 | import android.view.View
5 | import android.view.WindowManager
6 | import androidx.core.graphics.ColorUtils
7 | import androidx.fragment.app.DialogFragment
8 |
9 |
10 | fun DialogFragment.changeNavigationIconColor(isLight: Boolean) {
11 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
12 | dialog?.window?.let {
13 | var flags = it.decorView.systemUiVisibility
14 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
15 | flags = if (isLight) {
16 | flags xor View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
17 | } else {
18 | flags or View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
19 | }
20 | }
21 | it.decorView.systemUiVisibility = flags
22 | }
23 | }
24 | }
25 |
26 | fun DialogFragment.changeStatusBarIconColor(isLight: Boolean) {
27 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
28 | dialog?.window?.let {
29 | var flags = it.decorView.systemUiVisibility
30 | flags = if (isLight) {
31 | flags xor View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
32 | } else {
33 | flags or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
34 | }
35 | it.decorView.systemUiVisibility = flags
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/bottomdrawer/src/main/res/layout/bottom_drawer_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
22 |
23 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/bottomdrawer/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
--------------------------------------------------------------------------------
/bottomdrawer/src/main/res/values-v23/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
13 |
--------------------------------------------------------------------------------
/bottomdrawer/src/main/res/values-v27/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
14 |
--------------------------------------------------------------------------------
/bottomdrawer/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/bottomdrawer/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #80000000
4 | #FFFFFF
5 | #E0E0E0
6 |
--------------------------------------------------------------------------------
/bottomdrawer/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 6dp
3 | 10dp
4 | 4dp
5 |
6 |
--------------------------------------------------------------------------------
/bottomdrawer/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/bottomdrawer/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | BottomDrawer
3 |
4 |
--------------------------------------------------------------------------------
/bottomdrawer/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext.kotlin_version = '1.6.20'
5 | repositories {
6 | google()
7 | mavenCentral()
8 |
9 | }
10 | dependencies {
11 | classpath 'com.android.tools.build:gradle:7.1.3'
12 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | google()
21 | mavenCentral()
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # Kotlin code style for this project: "official" or "obsolete":
15 | kotlin.code.style=official
16 | android.useAndroidX=true
17 | android.enableJetifier=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HeyAlex/BottomDrawer/c4c24227e03d6f9eb00b6c4d4e8882306e2da68c/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Apr 23 13:15:53 MSK 2022
2 | distributionBase=GRADLE_USER_HOME
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
4 | distributionPath=wrapper/dists
5 | zipStorePath=wrapper/dists
6 | zipStoreBase=GRADLE_USER_HOME
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/raw/ceramic mug.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HeyAlex/BottomDrawer/c4c24227e03d6f9eb00b6c4d4e8882306e2da68c/raw/ceramic mug.jpg
--------------------------------------------------------------------------------
/raw/dinner_set.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HeyAlex/BottomDrawer/c4c24227e03d6f9eb00b6c4d4e8882306e2da68c/raw/dinner_set.jpg
--------------------------------------------------------------------------------
/raw/linen napkins.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HeyAlex/BottomDrawer/c4c24227e03d6f9eb00b6c4d4e8882306e2da68c/raw/linen napkins.jpeg
--------------------------------------------------------------------------------
/raw/sample_custom_arrow.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HeyAlex/BottomDrawer/c4c24227e03d6f9eb00b6c4d4e8882306e2da68c/raw/sample_custom_arrow.gif
--------------------------------------------------------------------------------
/raw/sample_custom_pull.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HeyAlex/BottomDrawer/c4c24227e03d6f9eb00b6c4d4e8882306e2da68c/raw/sample_custom_pull.gif
--------------------------------------------------------------------------------
/raw/sample_google_task.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HeyAlex/BottomDrawer/c4c24227e03d6f9eb00b6c4d4e8882306e2da68c/raw/sample_google_task.gif
--------------------------------------------------------------------------------
/raw/wine_glass.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HeyAlex/BottomDrawer/c4c24227e03d6f9eb00b6c4d4e8882306e2da68c/raw/wine_glass.webp
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':bottomdrawer'
2 |
--------------------------------------------------------------------------------