-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from invissvenska/develop
Develop
- Loading branch information
Showing
67 changed files
with
1,781 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# Built application files | ||
*.apk | ||
*.ap_ | ||
*.aab | ||
*.aar | ||
|
||
# Files for the ART/Dalvik VM | ||
*.dex | ||
|
||
# Java class files | ||
*.class | ||
|
||
# Generated files | ||
bin/ | ||
gen/ | ||
out/ | ||
release/ | ||
|
||
# Gradle files | ||
.gradle | ||
.gradle/ | ||
build/ | ||
/build | ||
|
||
# Local configuration file (sdk path, etc) | ||
local.properties | ||
/local.properties | ||
|
||
# Proguard folder generated by Eclipse | ||
proguard/ | ||
|
||
# Log Files | ||
*.log | ||
|
||
# Android Studio Navigation editor temp files | ||
.navigation/ | ||
|
||
# Android Studio captures folder | ||
captures/ | ||
/captures | ||
|
||
# IntelliJ | ||
*.iml | ||
.idea/** | ||
/.idea/* | ||
|
||
# Keystore files | ||
# Uncomment the following lines if you do not want to check your keystore files in. | ||
#*.jks | ||
#*.keystore | ||
|
||
# External native build folder generated in Android Studio 2.2 and later | ||
.externalNativeBuild | ||
|
||
# Google Services (e.g. APIs or Firebase) | ||
# google-services.json | ||
|
||
# Freeline | ||
freeline.py | ||
freeline/ | ||
freeline_project_description.json | ||
|
||
# fastlane | ||
fastlane/report.xml | ||
fastlane/Preview.html | ||
fastlane/screenshots | ||
fastlane/test_output | ||
fastlane/readme.md | ||
|
||
# Version control | ||
vcs.xml | ||
|
||
# lint | ||
lint/intermediates/ | ||
lint/generated/ | ||
lint/outputs/ | ||
lint/tmp/ | ||
# lint/reports/ | ||
/app/debug/output.json | ||
|
||
.DS_Store | ||
.cxx | ||
.cxx/ | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,123 @@ | ||
# -ModalBottomSheetDialog | ||
# ModalBottomSheetDialog | ||
[![API](https://img.shields.io/badge/API-16%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=16) [![](https://jitpack.io/v/invissvenska/ModalBottomSheetDialog.svg)](https://jitpack.io/#invissvenska/ModalBottomSheetDialog) | ||
|
||
## Prerequisites | ||
|
||
Add this in your root `build.gradle` file (**not** your module `build.gradle` file): | ||
|
||
```gradle | ||
allprojects { | ||
repositories { | ||
... | ||
maven { url "https://jitpack.io" } | ||
} | ||
} | ||
``` | ||
|
||
## Dependency | ||
|
||
Add this to your module's `build.gradle` file (make sure the version matches the JitPack badge above): | ||
|
||
```gradle | ||
dependencies { | ||
... | ||
implementation 'com.github.invissvenska:ModalBottomSheetDialog:VERSION' | ||
} | ||
``` | ||
|
||
## Configuration | ||
|
||
Implement the ModalBottomSheetDialog Listener interface on your Activity or Fragment: | ||
|
||
```java | ||
public class MainActivity extends AppCompatActivity implements ModalBottomSheetDialog.Listener { | ||
|
||
// some other code | ||
|
||
@Override | ||
public void onItemSelected(String tag, Item item) { | ||
Toast.makeText(getApplicationContext(), "Tag: " + tag + ", clicked on: " + item.getTitle(), | ||
Toast.LENGTH_SHORT).show(); | ||
} | ||
} | ||
``` | ||
|
||
```java | ||
new ModalBottomSheetDialog.Builder() | ||
.setHeader(String title) // optional | ||
.setHeaderLayout(@LayoutRes int layoutResource) // optional (TextView must have id 'header' in layout) | ||
.add(@MenuRes int menuResource) // can be used more then once | ||
.setItemLayout(@LayoutRes int layoutResource) // optional (TextView with id 'title' or ImageView with id 'icon' must be defined in layout) | ||
.setColumns(int columns) // optional (default is 1) | ||
.show(FragmentManager fragmentManager, String tag); | ||
``` | ||
|
||
Extend you theme with on of the DayNight variants to support a dark styled ModalBottomSheetDialog. For example `styles.xml`: | ||
```xml | ||
<resources> | ||
<!-- Base application theme. --> | ||
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar"> | ||
<!-- Customize your theme here. --> | ||
<item name="colorPrimary">@color/colorPrimary</item> | ||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> | ||
<item name="colorAccent">@color/colorAccent</item> | ||
</style> | ||
|
||
<!-- other style declarations --> | ||
|
||
</resources> | ||
``` | ||
|
||
## Usage | ||
|
||
To create a ModalBottomSheetDialog and display it later in code: | ||
``` java | ||
ModalBottomSheetDialog dialog = new ModalBottomSheetDialog.Builder() | ||
.setHeader("Title of modal") | ||
.add(R.menu.options) | ||
.build(); | ||
// some other code in between | ||
dialog.show(getSupportFragmentManager(), "WithHeader"); | ||
``` | ||
|
||
To display a ModalBottomSheetDialog directly: | ||
``` java | ||
new ModalBottomSheetDialog.Builder() | ||
.setHeader("Title of modal") | ||
.add(R.menu.options) | ||
.show(getSupportFragmentManager(), "WithHeader"); | ||
``` | ||
|
||
To display a ModalBottomSheetDialog with items from multiple menu resources: | ||
``` java | ||
new ModalBottomSheetDialog.Builder() | ||
.add(R.menu.options) | ||
.add(R.menu.options) | ||
.show(getSupportFragmentManager(), "WithoutHeader"); | ||
``` | ||
|
||
To display a ModalBottomSheetDialog in a grid layout: | ||
``` java | ||
new ModalBottomSheetDialog.Builder() | ||
.setHeader("Grid bottom layout") | ||
.add(R.menu.lot_of_options) | ||
.setColumns(3) | ||
.show(getSupportFragmentManager(), "Grid Layout"); | ||
``` | ||
|
||
To display a ModalBottomSheetDialog with custom layout: | ||
``` java | ||
new ModalBottomSheetDialog.Builder() | ||
.setHeader("Custom title and item layouts") | ||
.setHeaderLayout(R.layout.alternate_bottom_sheet_fragment_header) | ||
.add(R.menu.lot_of_options) | ||
.setItemLayout(R.layout.alternate_bottom_sheet_fragment_item) | ||
.setColumns(3) | ||
.show(getSupportFragmentManager(), "Custom Layout"); | ||
``` | ||
|
||
## Screenshots | ||
|
||
**Please click the image below to enlarge.** | ||
|
||
<img src="https://raw.githubusercontent.com/invissvenska/ModalBottomSheetDialog/master/media/collage.png"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion rootProject.ext.compileSdkVersion | ||
buildToolsVersion rootProject.ext.buildToolsVersion | ||
|
||
defaultConfig { | ||
applicationId "nl.invissvenska.modalbottomsheetdialog" | ||
minSdkVersion rootProject.ext.minSdkVersion | ||
targetSdkVersion rootProject.ext.targetSdkVersion | ||
versionCode rootProject.ext.versionCode | ||
versionName rootProject.ext.versionName | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation "androidx.appcompat:appcompat:$androidXVersion" | ||
implementation "com.google.android.material:material:$androidXVersion" | ||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' | ||
testImplementation 'junit:junit:4.12' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.1' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' | ||
|
||
implementation project(':modalbottomsheetdialog') | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
26 changes: 26 additions & 0 deletions
26
...droidTest/java/nl/invissvenska/modalbottomsheetdialog/sample/ExampleInstrumentedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package nl.invissvenska.modalbottomsheetdialog.sample; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry; | ||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
@Test | ||
public void useAppContext() { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); | ||
assertEquals("nl.invissvenska.modalbottomsheetdialog", appContext.getPackageName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="nl.invissvenska.modalbottomsheetdialog.sample"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme.NoActionBar"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
Oops, something went wrong.