├── .idea
├── .name
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── vcs.xml
├── modules.xml
├── runConfigurations.xml
├── gradle.xml
├── compiler.xml
└── misc.xml
├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable
│ │ │ │ ├── bottom_panel_menu_bg.xml
│ │ │ │ └── quick_settings_menu_bg.xml
│ │ │ ├── anim
│ │ │ │ ├── bottom_panel_slide_down.xml
│ │ │ │ └── bottom_panel_slide_up.xml
│ │ │ └── layout
│ │ │ │ ├── activity_quick_settings.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ └── activity_bottom_panel.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── imangazaliev
│ │ │ └── quickmenusample
│ │ │ ├── MainActivity.java
│ │ │ ├── QuickSettingsActivity.java
│ │ │ └── BottomPanelActivity.java
│ └── test
│ │ └── java
│ │ └── imangazaliev
│ │ └── quickmenusample
│ │ ├── QuickMenuTest.java
│ │ └── QuickMenuPropertiesTest.java
├── proguard-rules.pro
├── build.gradle
└── app.iml
├── library
├── .gitignore
├── src
│ └── main
│ │ ├── res
│ │ ├── values
│ │ │ ├── strings.xml
│ │ │ ├── ids.xml
│ │ │ ├── dimens.xml
│ │ │ └── colors.xml
│ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ │ └── ic_launcher.png
│ │ ├── layout
│ │ │ ├── spinner_menu_item.xml
│ │ │ ├── text_menu_item.xml
│ │ │ └── quick_menu_layout.xml
│ │ └── drawable
│ │ │ └── quick_menu_bg.xml
│ │ ├── java
│ │ └── imangazaliev
│ │ │ └── quickmenu
│ │ │ ├── QuickMenuListener.java
│ │ │ ├── interfaces
│ │ │ └── QuickMenuItem.java
│ │ │ ├── model
│ │ │ ├── DividerMenuItem.java
│ │ │ ├── SpinnerMenuItem.java
│ │ │ └── TextMenuItem.java
│ │ │ ├── QuickMenu.java
│ │ │ ├── QuickMenuHelper.java
│ │ │ └── QuickMenuProperties.java
│ │ └── AndroidManifest.xml
├── proguard-rules.pro
├── build.gradle
└── library.iml
├── settings.gradle
├── screenshots
├── 1.jpg
├── 2.jpg
└── 3.png
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── QuickMenuLibrary.iml
├── LICENSE
├── gradlew.bat
├── gradlew
├── README-RU.md
└── README.md
/.idea/.name:
--------------------------------------------------------------------------------
1 | QuickMenu
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':library', ':app'
2 |
--------------------------------------------------------------------------------
/screenshots/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ImangazalievM/QuickMenu/HEAD/screenshots/1.jpg
--------------------------------------------------------------------------------
/screenshots/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ImangazalievM/QuickMenu/HEAD/screenshots/2.jpg
--------------------------------------------------------------------------------
/screenshots/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ImangazalievM/QuickMenu/HEAD/screenshots/3.png
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | QuickMenuSample
3 |
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ImangazalievM/QuickMenu/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | QuickMenuLibrary
3 |
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 | /captures
8 | /bintrayup.bat
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ImangazalievM/QuickMenu/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ImangazalievM/QuickMenu/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ImangazalievM/QuickMenu/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ImangazalievM/QuickMenu/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ImangazalievM/QuickMenu/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/library/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ImangazalievM/QuickMenu/HEAD/library/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/library/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ImangazalievM/QuickMenu/HEAD/library/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/library/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ImangazalievM/QuickMenu/HEAD/library/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/library/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ImangazalievM/QuickMenu/HEAD/library/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/library/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ImangazalievM/QuickMenu/HEAD/library/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/library/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/library/src/main/java/imangazaliev/quickmenu/QuickMenuListener.java:
--------------------------------------------------------------------------------
1 | package imangazaliev.quickmenu;
2 |
3 | public interface QuickMenuListener {
4 |
5 | void onMenuShowed();
6 | void onMenuHided();
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/library/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 270dp
3 | 15dp
4 | 10dp
5 |
6 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/spinner_menu_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #03A9F4
4 | #0277BD
5 | #03A9F4
6 |
7 |
--------------------------------------------------------------------------------
/library/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/text_menu_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Jul 11 13:24:17 MSK 2016
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bottom_panel_menu_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | -
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/library/src/main/java/imangazaliev/quickmenu/interfaces/QuickMenuItem.java:
--------------------------------------------------------------------------------
1 | package imangazaliev.quickmenu.interfaces;
2 |
3 | import android.content.Context;
4 | import android.view.View;
5 | import android.view.ViewGroup;
6 |
7 | public interface QuickMenuItem {
8 |
9 | View getView(Context context, ViewGroup parent);
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/library/src/main/res/drawable/quick_menu_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/quick_settings_menu_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/bottom_panel_slide_down.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/bottom_panel_slide_up.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\Mahach\AndroidDeveloment\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/library/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\Mahach\AndroidDeveloment\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_quick_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
17 |
18 |
19 |
20 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
13 |
14 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_bottom_panel.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
18 |
19 |
20 |
21 |
25 |
26 |
--------------------------------------------------------------------------------
/QuickMenuLibrary.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.novoda.bintray-release'
3 |
4 | android {
5 |
6 | compileSdkVersion 23
7 | buildToolsVersion "23.0.1"
8 |
9 | defaultConfig {
10 | minSdkVersion 14
11 | targetSdkVersion 23
12 | versionCode 2
13 | versionName "1.1.0"
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | }
22 |
23 | dependencies {
24 | compile fileTree(dir: 'libs', include: ['*.jar'])
25 | compile 'com.android.support:appcompat-v7:23.1.0'
26 | }
27 |
28 | // это блок будет обработан плагином bintray-release
29 | publish {
30 | groupId = 'com.github.imangazalievm'
31 | artifactId = 'quickmenu'
32 | publishVersion = '1.1.0'
33 | desc = 'Небольшая библиотека для создания меню с быстрыми настройками'
34 | licences = ['MIT']
35 | website = 'https://github.com/ImangazalievM/QuickMenu'
36 | }
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 |
5 | compileSdkVersion 23
6 | buildToolsVersion "23.0.1"
7 |
8 | defaultConfig {
9 | applicationId "imangazaliev.quickmenusample"
10 | minSdkVersion 14
11 | targetSdkVersion 23
12 | versionCode 1
13 | versionName "1.0"
14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15 | }
16 |
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 |
24 | }
25 |
26 | dependencies {
27 | compile project(':library')
28 |
29 | // Robolectric
30 | testCompile 'junit:junit:4.12'
31 | testCompile 'org.hamcrest:hamcrest-core:1.1'
32 | testCompile 'org.hamcrest:hamcrest-library:1.1'
33 | testCompile 'org.hamcrest:hamcrest-integration:1.1'
34 | testCompile "org.robolectric:robolectric:3.0"
35 |
36 | compile 'com.android.support:appcompat-v7:23.1.0'
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | >
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c) 2016 Mahach Imangazaliev
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
--------------------------------------------------------------------------------
/app/src/main/java/imangazaliev/quickmenusample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package imangazaliev.quickmenusample;
2 |
3 | import android.content.Intent;
4 | import android.graphics.Color;
5 | import android.graphics.drawable.ColorDrawable;
6 | import android.graphics.drawable.Drawable;
7 | import android.os.Bundle;
8 | import android.support.v7.app.AppCompatActivity;
9 | import android.view.View;
10 |
11 | import imangazaliev.quickmenu.QuickMenu;
12 | import imangazaliev.quickmenu.QuickMenuProperties;
13 | import imangazaliev.quickmenu.model.DividerMenuItem;
14 | import imangazaliev.quickmenu.model.SpinnerMenuItem;
15 |
16 | public class MainActivity extends AppCompatActivity {
17 |
18 |
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.activity_main);
23 |
24 | }
25 |
26 | public void openQuickSettingsActivity(View view) {
27 | Intent intent = new Intent(this, QuickSettingsActivity.class);
28 | startActivity(intent);
29 | }
30 |
31 | public void openBottomPanelActivity(View view) {
32 | Intent intent = new Intent(this, BottomPanelActivity.class);
33 | startActivity(intent);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/quick_menu_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
18 |
19 |
24 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/java/imangazaliev/quickmenusample/QuickSettingsActivity.java:
--------------------------------------------------------------------------------
1 | package imangazaliev.quickmenusample;
2 |
3 | import android.graphics.Color;
4 | import android.graphics.drawable.ColorDrawable;
5 | import android.graphics.drawable.Drawable;
6 | import android.os.Bundle;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.view.Gravity;
9 | import android.view.View;
10 |
11 | import imangazaliev.quickmenu.QuickMenu;
12 | import imangazaliev.quickmenu.QuickMenuProperties;
13 | import imangazaliev.quickmenu.model.DividerMenuItem;
14 | import imangazaliev.quickmenu.model.SpinnerMenuItem;
15 |
16 | public class QuickSettingsActivity extends AppCompatActivity {
17 |
18 | QuickMenu menu;
19 |
20 | @Override
21 | protected void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.activity_quick_settings);
24 |
25 | String[] spinnerItems = {"Cat", "Dog", "Cow"};
26 |
27 | Drawable menuBackground = getResources().getDrawable(R.drawable.quick_settings_menu_bg);
28 | Drawable layoutBackground = new ColorDrawable(Color.parseColor("#80000000"));
29 |
30 | QuickMenuProperties properties = new QuickMenuProperties.Builder(this)
31 | .withWidthInPercentages(60)
32 | .withBackground(menuBackground)
33 | .withMargins(50, 50, 50, 50)
34 | .withLayoutBackground(layoutBackground)
35 | .withCancelOnTouchOutside(true)
36 | .build();
37 |
38 | menu = new QuickMenu.Builder(this)
39 | .withItems(new SpinnerMenuItem(spinnerItems),
40 | new DividerMenuItem(this).withColor(Color.parseColor("#EEEEEE")),
41 | new SpinnerMenuItem(spinnerItems))
42 | .withProperties(properties)
43 | .build();
44 |
45 |
46 | }
47 |
48 | public void showMenu(View view) {
49 | menu.show();
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/library/src/main/java/imangazaliev/quickmenu/model/DividerMenuItem.java:
--------------------------------------------------------------------------------
1 | package imangazaliev.quickmenu.model;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.graphics.drawable.ColorDrawable;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.LinearLayout;
9 |
10 | import imangazaliev.quickmenu.interfaces.QuickMenuItem;
11 |
12 | public class DividerMenuItem implements QuickMenuItem {
13 |
14 | private int mDividerColor;
15 | private int mDividerWidth;
16 | private int mMarginLeft, mMarginTop, mMarginRight, mMarginBottom;
17 |
18 | public DividerMenuItem(Context context) {
19 | mDividerColor = Color.LTGRAY;
20 | mDividerWidth = (int) context.getResources().getDisplayMetrics().density;
21 | mMarginLeft = mMarginTop = mMarginRight = mMarginBottom = 0;
22 |
23 | }
24 |
25 | public DividerMenuItem withColor(int color) {
26 | this.mDividerColor = color;
27 | return this;
28 | }
29 |
30 | public DividerMenuItem withMargins(int left, int top, int right, int bottom) {
31 | this.mMarginLeft = left;
32 | this.mMarginTop = top;
33 | this.mMarginRight = right;
34 | this.mMarginBottom = bottom;
35 | return this;
36 | }
37 |
38 | public DividerMenuItem withWidth(int width) {
39 | this.mDividerWidth = width;
40 | return this;
41 | }
42 |
43 | @Override
44 | public View getView(Context context, ViewGroup parent) {
45 | View divider = new View(context);
46 | LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mDividerWidth);
47 | layoutParams.setMargins(mMarginLeft, mMarginTop, mMarginRight, mMarginBottom);
48 | divider.setLayoutParams(layoutParams);
49 | divider.setBackgroundDrawable(new ColorDrawable(mDividerColor));
50 | divider.setEnabled(false);
51 | return divider;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/library/src/main/java/imangazaliev/quickmenu/model/SpinnerMenuItem.java:
--------------------------------------------------------------------------------
1 | package imangazaliev.quickmenu.model;
2 |
3 | import android.content.Context;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.AdapterView;
8 | import android.widget.ArrayAdapter;
9 | import android.widget.Spinner;
10 |
11 | import imangazaliev.quickmenulibrary.R;
12 | import imangazaliev.quickmenu.interfaces.QuickMenuItem;
13 |
14 | public class SpinnerMenuItem implements QuickMenuItem {
15 |
16 | public interface OnItemClickListener {
17 |
18 | void onItemClick(View view, int position, long id);
19 |
20 | }
21 |
22 | private String[] mItems;
23 | private OnItemClickListener mItemClickListener;
24 |
25 | public SpinnerMenuItem(String[] items) {
26 | this.mItems = items;
27 | }
28 |
29 | public SpinnerMenuItem withListener(OnItemClickListener itemClickListener) {
30 | this.mItemClickListener = itemClickListener;
31 | return this;
32 | }
33 |
34 | @Override
35 | public View getView(Context context, ViewGroup parent) {
36 | LayoutInflater inflater = LayoutInflater.from(context);
37 | Spinner spinner = (Spinner) inflater.inflate(R.layout.spinner_menu_item, parent, false);
38 | ArrayAdapter spinnerArrayAdapter = new ArrayAdapter<>(context, android.R.layout.simple_spinner_item, mItems);
39 | spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
40 | spinner.setAdapter(spinnerArrayAdapter);
41 | spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
42 | @Override
43 | public void onItemSelected(AdapterView> parentView, View selectedItemView, int position, long id) {
44 | if (mItemClickListener != null) {
45 | mItemClickListener.onItemClick(selectedItemView, position, id);
46 | }
47 | }
48 |
49 | @Override
50 | public void onNothingSelected(AdapterView> parentView) {
51 | }
52 | });
53 | return spinner;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/library/src/main/java/imangazaliev/quickmenu/model/TextMenuItem.java:
--------------------------------------------------------------------------------
1 | package imangazaliev.quickmenu.model;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.graphics.drawable.Drawable;
6 | import android.view.Gravity;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.LinearLayout;
11 | import android.widget.TextView;
12 |
13 | import imangazaliev.quickmenu.interfaces.QuickMenuItem;
14 | import imangazaliev.quickmenulibrary.R;
15 |
16 | /**
17 | * Created by Mahach Imangazaliev on 18.01.2016
18 | */
19 | public class TextMenuItem implements QuickMenuItem {
20 |
21 | private String mText;
22 | private int mTextColor;
23 | private Drawable mBackground;
24 | private int mGravity;
25 | private int mMarginLeft, mMarginTop, mMarginRight, mMarginBottom;
26 |
27 | public TextMenuItem(String text) {
28 | this.mText = text;
29 | mTextColor = Color.BLACK;
30 | mBackground = null;
31 | mGravity = Gravity.CENTER;
32 | }
33 |
34 | public TextMenuItem withTextColor(int textColor) {
35 | this.mTextColor = textColor;
36 | return this;
37 | }
38 |
39 | public TextMenuItem withTextBackground(Drawable background) {
40 | this.mBackground = background;
41 | return this;
42 | }
43 |
44 | public TextMenuItem withGravity(int gravity) {
45 | this.mGravity = gravity;
46 | return this;
47 | }
48 |
49 | public TextMenuItem withMargins(int left, int top, int right, int bottom) {
50 | this.mMarginLeft = left;
51 | this.mMarginTop = top;
52 | this.mMarginRight = right;
53 | this.mMarginBottom = bottom;
54 | return this;
55 | }
56 |
57 | @Override
58 | public View getView(Context context, ViewGroup parent) {
59 | LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
60 | layoutParams.setMargins(mMarginLeft, mMarginTop, mMarginRight, mMarginBottom);
61 |
62 | LayoutInflater inflater = LayoutInflater.from(context);
63 | TextView textView = (TextView) inflater.inflate(R.layout.text_menu_item, parent, false);
64 | textView.setText(mText);
65 | textView.setTextColor(mTextColor);
66 | textView.setBackgroundDrawable(mBackground);
67 | textView.setGravity(mGravity);
68 | textView.setLayoutParams(layoutParams);
69 | return textView;
70 | }
71 | }
--------------------------------------------------------------------------------
/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 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
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 Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/src/test/java/imangazaliev/quickmenusample/QuickMenuTest.java:
--------------------------------------------------------------------------------
1 | package imangazaliev.quickmenusample;
2 |
3 | import android.app.Activity;
4 |
5 | import org.junit.Assert;
6 | import org.junit.Before;
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 | import org.robolectric.Robolectric;
10 | import org.robolectric.RobolectricGradleTestRunner;
11 | import org.robolectric.annotation.Config;
12 |
13 | import imangazaliev.quickmenu.QuickMenu;
14 | import imangazaliev.quickmenu.model.SpinnerMenuItem;
15 |
16 | /**
17 | * Created by Mahach Imangazaliev on 14.01.2016
18 | */
19 |
20 |
21 | @RunWith(RobolectricGradleTestRunner.class)
22 | @Config(constants = BuildConfig.class, sdk = 19, manifest = "src/main/AndroidManifest.xml")
23 | public class QuickMenuTest {
24 |
25 | private Activity activity;
26 | private final String[] spinnerItems = {"Ражик", "Мурзик", "Барсик"};
27 |
28 | @Before
29 | public void init() {
30 | activity = Robolectric.setupActivity(QuickSettingsActivity.class);
31 | }
32 |
33 | @Test(expected = RuntimeException.class)
34 | public void testActivityNull() {
35 | new QuickMenu.Builder(null)
36 | .withItems(new SpinnerMenuItem(spinnerItems))
37 | .build();
38 |
39 | }
40 |
41 | @Test(expected = RuntimeException.class)
42 | public void testOneOfItemsNull() {
43 | new QuickMenu.Builder(activity)
44 | .withItems(null)
45 | .build();
46 | }
47 |
48 | @Test()
49 | public void testCorrectLayoutId() {
50 | new QuickMenu.Builder(activity)
51 | .withLayoutId(R.id.quickMenuContainer)
52 | .withItems(new SpinnerMenuItem(spinnerItems))
53 | .build();
54 | }
55 |
56 | @Test(expected = RuntimeException.class)
57 | public void testIncorrectLayoutId() {
58 | new QuickMenu.Builder(activity)
59 | .withLayoutId(-1)
60 | .withItems(new SpinnerMenuItem(spinnerItems))
61 | .build();
62 | }
63 |
64 | @Test()
65 | public void testMenu() {
66 | new QuickMenu.Builder(activity)
67 | .withItems(new SpinnerMenuItem(spinnerItems))
68 | .build();
69 | }
70 |
71 | @Test()
72 | public void testMenuVisibility() {
73 | QuickMenu menu = new QuickMenu.Builder(activity)
74 | .withItems(new SpinnerMenuItem(spinnerItems))
75 | .build();
76 |
77 | //меню не показывается
78 | Assert.assertTrue(!menu.isShowing());
79 |
80 | //меню показывается
81 | menu.show();
82 | Assert.assertTrue(menu.isShowing());
83 | }
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/app/src/main/java/imangazaliev/quickmenusample/BottomPanelActivity.java:
--------------------------------------------------------------------------------
1 | package imangazaliev.quickmenusample;
2 |
3 | import android.graphics.Color;
4 | import android.graphics.drawable.ColorDrawable;
5 | import android.graphics.drawable.Drawable;
6 | import android.os.Bundle;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.view.Gravity;
9 | import android.view.View;
10 | import android.view.animation.AnimationUtils;
11 | import android.widget.Toast;
12 |
13 | import imangazaliev.quickmenu.QuickMenu;
14 | import imangazaliev.quickmenu.QuickMenuListener;
15 | import imangazaliev.quickmenu.QuickMenuProperties;
16 | import imangazaliev.quickmenu.model.DividerMenuItem;
17 | import imangazaliev.quickmenu.model.SpinnerMenuItem;
18 |
19 | public class BottomPanelActivity extends AppCompatActivity {
20 |
21 | QuickMenu menu;
22 |
23 |
24 | @Override
25 | protected void onCreate(Bundle savedInstanceState) {
26 | super.onCreate(savedInstanceState);
27 | setContentView(R.layout.activity_bottom_panel);
28 | String[] spinnerItems = {"Cat", "Dog", "Cow"};
29 |
30 | Drawable menuBackground = getResources().getDrawable(R.drawable.bottom_panel_menu_bg);
31 | Drawable layoutBackground = new ColorDrawable(Color.parseColor("#80000000"));
32 |
33 | QuickMenuProperties properties = new QuickMenuProperties.Builder(this)
34 | .withWidthInPercentages(100)
35 | .withGravity(Gravity.BOTTOM)
36 | .withBackground(menuBackground)
37 | .withLayoutBackground(layoutBackground)
38 | .withCancelOnTouchOutside(true)
39 | .withMargins(0, 0, 0, 0)
40 | .withOnShowAnimation(AnimationUtils.loadAnimation(this, R.anim.bottom_panel_slide_up))
41 | .withOnHideAnimation(AnimationUtils.loadAnimation(this, R.anim.bottom_panel_slide_down))
42 | .build();
43 |
44 | menu = new QuickMenu.Builder(this)
45 | .withItems(new SpinnerMenuItem(spinnerItems),
46 | new DividerMenuItem(this).withColor(Color.parseColor("#EEEEEE")),
47 | new SpinnerMenuItem(spinnerItems))
48 | .withProperties(properties)
49 | .build();
50 |
51 | menu.setQuickMenuListener(new QuickMenuListener() {
52 | @Override
53 | public void onMenuShowed() {
54 | Toast.makeText(BottomPanelActivity.this, "Menu showed", Toast.LENGTH_SHORT).show();
55 | }
56 |
57 | @Override
58 | public void onMenuHided() {
59 | Toast.makeText(BottomPanelActivity.this, "Menu hided", Toast.LENGTH_SHORT).show();
60 | }
61 | });
62 |
63 | }
64 |
65 | public void showMenu(View view) {
66 | menu.show();
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/library/src/main/java/imangazaliev/quickmenu/QuickMenu.java:
--------------------------------------------------------------------------------
1 | package imangazaliev.quickmenu;
2 |
3 | import android.app.Activity;
4 | import android.view.animation.Animation;
5 |
6 | import java.util.Arrays;
7 | import java.util.Collections;
8 | import java.util.List;
9 |
10 | import imangazaliev.quickmenulibrary.R;
11 | import imangazaliev.quickmenu.interfaces.QuickMenuItem;
12 |
13 | /**
14 | * Меню быстрых настроек
15 | */
16 | public class QuickMenu {
17 |
18 | private final List mItems;
19 | private final QuickMenuHelper mHelper;
20 |
21 | private QuickMenu(Builder builder) {
22 | this.mItems = builder.mItems;
23 | this.mHelper = new QuickMenuHelper(builder.mActivity, mItems, builder.mLayoutId, builder.mMenuProperties);
24 | }
25 |
26 | public List getItems() {
27 | return mItems;
28 | }
29 |
30 | public void setQuickMenuListener(QuickMenuListener quickMenuListener) {
31 | mHelper.setQuickMenuListener(quickMenuListener);
32 | }
33 |
34 | public boolean isShowing() {
35 | return mHelper.isShowing();
36 | }
37 |
38 | public void show() {
39 | mHelper.showMenu();
40 | }
41 |
42 | public void hide() {
43 | mHelper.hideMenu();
44 | }
45 |
46 | public static class Builder {
47 |
48 | private Activity mActivity;
49 | private int mLayoutId;
50 | /* Пункты меню */
51 | private List mItems;
52 | /* Настройки меню */
53 | private QuickMenuProperties mMenuProperties;
54 |
55 |
56 | public Builder(Activity activity) {
57 | mActivity = activity;
58 | //устанавливаем стандартный id лейаута
59 | mLayoutId = R.id.quickMenuContainer;
60 | mItems = Collections.emptyList();
61 | }
62 |
63 | public Builder withLayoutId(int layoutId) {
64 | this.mLayoutId = layoutId;
65 | return this;
66 | }
67 |
68 | public Builder withItems(QuickMenuItem... items) {
69 | this.mItems = Arrays.asList(items);
70 | return this;
71 | }
72 |
73 | public Builder withProperties(QuickMenuProperties mMenuProperties) {
74 | this.mMenuProperties = mMenuProperties;
75 | return this;
76 | }
77 |
78 | public QuickMenu build() {
79 | //проверяем, была ли передана активити
80 | if (mActivity == null) {
81 | throw new RuntimeException("Activity value cannot be null");
82 | }
83 |
84 | //проверяем, чтобы ни один из элеиентов не равнялся null
85 | for (int i = 0; i < mItems.size(); i++) {
86 | if (mItems.get(i) == null) {
87 | throw new RuntimeException("Item with index " + i + " is null");
88 | }
89 | }
90 |
91 | if (mMenuProperties == null) {
92 | this.mMenuProperties = new QuickMenuProperties.Builder(mActivity).build();
93 | }
94 |
95 | return new QuickMenu(this);
96 | }
97 | }
98 |
99 | }
100 |
--------------------------------------------------------------------------------
/app/src/test/java/imangazaliev/quickmenusample/QuickMenuPropertiesTest.java:
--------------------------------------------------------------------------------
1 | package imangazaliev.quickmenusample;
2 |
3 | import android.app.Activity;
4 | import android.graphics.Color;
5 | import android.graphics.drawable.ColorDrawable;
6 | import android.graphics.drawable.Drawable;
7 |
8 | import org.junit.Before;
9 | import org.junit.Test;
10 | import org.junit.runner.RunWith;
11 | import org.robolectric.Robolectric;
12 | import org.robolectric.RobolectricGradleTestRunner;
13 | import org.robolectric.annotation.Config;
14 |
15 | import imangazaliev.quickmenu.QuickMenuProperties;
16 |
17 | import static junit.framework.Assert.assertEquals;
18 |
19 | /**
20 | * Created by Mahach Imangazaliev on 15.01.2016
21 | */
22 | @RunWith(RobolectricGradleTestRunner.class)
23 | @Config(constants = BuildConfig.class, sdk = 19, manifest = "src/main/AndroidManifest.xml")
24 | public class QuickMenuPropertiesTest {
25 |
26 | private Activity activity;
27 |
28 | @Before
29 | public void init() {
30 | activity = Robolectric.setupActivity(QuickSettingsActivity.class);
31 | }
32 |
33 | @Test
34 | public void testWidthInPercentages() {
35 | new QuickMenuProperties.Builder(activity)
36 | .withWidthInPercentages(50)
37 | .build();
38 | }
39 |
40 | @Test(expected = RuntimeException.class)
41 | public void testWidthMoreThan100Percent() {
42 | new QuickMenuProperties.Builder(activity)
43 | .withWidthInPercentages(101)
44 | .build();
45 | }
46 |
47 | @Test
48 | public void testWidthInPixels() {
49 | new QuickMenuProperties.Builder(activity)
50 | .withWidth(300)
51 | .build();
52 | }
53 |
54 | @Test(expected = RuntimeException.class)
55 | public void testWidthLessThanZeroPixels() {
56 | new QuickMenuProperties.Builder(activity)
57 | .withWidth(-2)
58 | .build();
59 | }
60 |
61 | @Test()
62 | public void testMenuPropertiesMargins() {
63 | QuickMenuProperties properties = new QuickMenuProperties.Builder(activity)
64 | .withMargins(10, 20, 30, 40)
65 | .build();
66 |
67 | assertEquals(10, properties.getMarginLeft());
68 | assertEquals(20, properties.getMarginTop());
69 | assertEquals(30, properties.getMarginRight());
70 | assertEquals(40, properties.getMarginBottom());
71 | }
72 |
73 | @Test()
74 | public void testMenuPropertiesPaddings() {
75 | QuickMenuProperties properties = new QuickMenuProperties.Builder(activity)
76 | .withPaddings(10, 20, 30, 40)
77 | .build();
78 |
79 | assertEquals(10, properties.getPaddingLeft());
80 | assertEquals(20, properties.getPaddingTop());
81 | assertEquals(30, properties.getPaddingRight());
82 | assertEquals(40, properties.getPaddingBottom());
83 | }
84 |
85 | @Test
86 | public void testQuickMenuProperties() {
87 | Drawable menuBackground = activity.getResources().getDrawable(R.drawable.quick_menu_bg);
88 | Drawable layoutBackground = new ColorDrawable(Color.parseColor("#99000000"));
89 |
90 | new QuickMenuProperties.Builder(activity)
91 | .withWidth(1200)
92 | .withWidthInPercentages(99)
93 | .withBackground(menuBackground)
94 | .withMargins(0, 0, 10, 10)
95 | .withLayoutBackground(layoutBackground)
96 | .build();
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
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 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/README-RU.md:
--------------------------------------------------------------------------------
1 | # QuickMenu
2 | [  ](https://bintray.com/imangazaliev/maven/quickmenu/_latestVersion)
3 | [](http://android-arsenal.com/details/1/3824)
4 |
5 | Небольшая библиотека для создания меню с быстрыми настройками
6 |
7 | ##Скриншоты
8 |
9 |
10 |
11 |
12 |
13 | ## Подключение библиотеки
14 |
15 | ```gradle
16 | compile 'com.github.imangazalievm:quickmenu:1.1.0'
17 | ```
18 |
19 | ##Показываем меню:
20 |
21 | Файл **main.xml**:
22 |
23 | ```java
24 |
25 |
29 |
30 |
37 |
38 |
42 |
43 |
44 | ```
45 |
46 | Во FrameLayout'е с идентификатором `quickMenuContainer` будет показано наше меню.
47 |
48 | ```java
49 | QuickMenu menu = new QuickMenu.Builder(this).build();
50 | menu.show();
51 | ```
52 |
53 | ##Добавление элементов
54 |
55 | ```java
56 | QuickMenu menu = new QuickMenu.Builder(this)
57 | .withItems(new SpinnerMenuItem(spinnerItems),
58 | new DividerMenuItem(this)),
59 | new SpinnerMenuItem(spinnerItems))
60 | .withProperties(properties)
61 | .build();
62 | ```
63 |
64 | В библиотеке есть только 3 типа элементов:
65 |
66 | - **SpinnerMenuItem** - настраиваемый Spinner
67 | - **TextMenuItem** - текст
68 | - **DividerMenuItem** - разделительная линия
69 |
70 | Также можно добавить свои элементы реализовав интерфейс QuickMenuItem:
71 |
72 | ```java
73 | public class CustomMenuItem implements QuickMenuItem {
74 |
75 | public CustomItem() {
76 | }
77 |
78 | @Override
79 | public View getView(Context context, ViewGroup parent) {
80 |
81 | MyCustomView view = ...
82 |
83 | //создаем View
84 |
85 | return view;
86 | }
87 | }
88 | ```
89 |
90 | ##Настройка внешнего вида
91 |
92 | Внешний вид меню можно настроить с помощью QuickMenuProperties:
93 |
94 | ```java
95 | QuickMenuProperties properties = new QuickMenuProperties.Builder(this)
96 | .withWidthInPercentages(menuWidthInPercentages)
97 | .withGravity(Gravity.BOTTOM)
98 | .withBackground(drawable)
99 | .withMargins(left, top, right, bottom)
100 | .withLayoutBackground(drawable)
101 | .withCancelOnTouchOutside(true)
102 | .build();
103 |
104 | QuickMenu menu = new QuickMenu.Builder(this)
105 | .withItems(new SpinnerMenuItem(spinnerItems),
106 | new DividerMenuItem(this).withColor(Color.parseColor("#FFA19348")),
107 | new SpinnerMenuItem(spinnerItems))
108 | .withProperties(properties)
109 | .build();
110 |
111 | menu.show();
112 | ```
113 |
114 | - **withWidth(int)** - ширина меню в пикселях
115 | - **withWidthInPercentages()** - ширина меню в процентах
116 | - **withGravity()** - позиция меню
117 | - **withMargins(int, int, int, int)** - внешние отступы меню
118 | - **withPaddings(int, int, int, int)** - внутренние отступы меню
119 | - **withBackground(Drawable)** - фон меню
120 | - **withLayoutBackground(Drawable)** - фон области вокруг меню
121 | - **withCancelOnTouchOutside(boolean)** - закрытие при нажатии на область за границей меню
122 |
123 | ##Установка слушателей
124 |
125 | Также вы можете добавить слушатель показа/скрытия меню:
126 |
127 | ```java
128 | menu.setQuickMenuListener(new QuickMenuListener() {
129 | @Override
130 | public void onMenuShowed() {
131 | Toast.makeText(BottomPanelActivity.this, "Menu showed", Toast.LENGTH_SHORT).show();
132 | }
133 |
134 | @Override
135 | public void onMenuHided() {
136 | Toast.makeText(BottomPanelActivity.this, "Menu hided", Toast.LENGTH_SHORT).show();
137 | }
138 | });
139 | ```
140 |
141 | ##Лицензия
142 |
143 | The MIT License
144 |
145 | Copyright (c) 2016 Mahach Imangazaliev
146 |
147 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
148 |
149 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
150 |
151 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
152 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # QuickMenu
2 | [  ](https://bintray.com/imangazaliev/maven/quickmenu/_latestVersion)
3 | [](http://android-arsenal.com/details/1/3824)
4 |
5 | [Русская версия (Russian version)](README-RU.md)
6 |
7 | Small library for creating menus with fast settings
8 |
9 | ## Screenshots
10 |
11 |
12 |
13 |
14 |
15 | ## Connecting library to project
16 |
17 | ```gradle
18 | compile 'com.github.imangazalievm:quickmenu:1.1.0'
19 | ```
20 |
21 | ## How to show menu:
22 |
23 | File **main.xml**:
24 |
25 | ```java
26 |
27 |
31 |
32 |
39 |
40 |
44 |
45 |
46 | ```
47 |
48 | Our menu will be shown in FrameLayout with ID `quickMenuContainer`
49 |
50 | ```java
51 | QuickMenu menu = new QuickMenu.Builder(this).build();
52 | menu.show();
53 | ```
54 |
55 | ## Adding new elements to menu
56 |
57 | ```java
58 | QuickMenu menu = new QuickMenu.Builder(this)
59 | .withItems(new SpinnerMenuItem(spinnerItems),
60 | new DividerMenuItem(this),
61 | new SpinnerMenuItem(spinnerItems))
62 | .withProperties(properties)
63 | .build();
64 | ```
65 |
66 | There are only 3 types of elements:
67 |
68 | - **SpinnerMenuItem** - customizable Spinner
69 | - **TextMenuItem** - text
70 | - **DividerMenuItem** - divider line
71 |
72 | We also can create custom elements, implementing QuickMenuItem interface:
73 |
74 | ```java
75 | public class CustomMenuItem implements QuickMenuItem {
76 |
77 | public CustomItem() {
78 | }
79 |
80 | @Override
81 | public View getView(Context context, ViewGroup parent) {
82 |
83 | MyCustomView view = ...
84 |
85 | //создаем View
86 |
87 | return view;
88 | }
89 | }
90 | ```
91 |
92 | ## Changing user-interface
93 |
94 | Menu's appearance can be changed using QuickMenuProporeties.
95 |
96 | ```java
97 | QuickMenuProperties properties = new QuickMenuProperties.Builder(this)
98 | .withWidthInPercentages(menuWidthInPercentages)
99 | .withGravity(Gravity.BOTTOM)
100 | .withBackground(drawable)
101 | .withMargins(left, top, right, bottom)
102 | .withLayoutBackground(drawable)
103 | .withCancelOnTouchOutside(true)
104 | .build();
105 |
106 | QuickMenu menu = new QuickMenu.Builder(this)
107 | .withItems(new SpinnerMenuItem(spinnerItems),
108 | new DividerMenuItem(this).withColor(Color.parseColor("#FFA19348")),
109 | new SpinnerMenuItem(spinnerItems))
110 | .withProperties(properties)
111 | .build();
112 |
113 | menu.show();
114 | ```
115 |
116 | - **withWidth(int)** - menu width in pixels
117 | - **withWidthInPercentages()** - menu width in percents
118 | - **withGravity()** - menu position
119 | - **withMargins(int, int, int, int)** - outer menu indent
120 | - **withMargins(int, int, int, int)** - inner menu indent
121 | - **withBackground(Drawable)** - menu background
122 | - **withLayoutBackground(Drawable)** - background of area around menu
123 | - **withCancelOnTouchOutside(boolean)** - close menu when touched outside
124 |
125 | ##Setup listener
126 |
127 | You can also setup show/hide listener:
128 |
129 | ```java
130 | menu.setQuickMenuListener(new QuickMenuListener() {
131 | @Override
132 | public void onMenuShowed() {
133 | Toast.makeText(BottomPanelActivity.this, "Menu showed", Toast.LENGTH_SHORT).show();
134 | }
135 |
136 | @Override
137 | public void onMenuHided() {
138 | Toast.makeText(BottomPanelActivity.this, "Menu hided", Toast.LENGTH_SHORT).show();
139 | }
140 | });
141 | ```
142 |
143 | ## License
144 |
145 | The MIT License
146 |
147 | Copyright (c) 2016 Mahach Imangazaliev
148 |
149 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
150 |
151 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
152 |
153 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
154 |
--------------------------------------------------------------------------------
/library/src/main/java/imangazaliev/quickmenu/QuickMenuHelper.java:
--------------------------------------------------------------------------------
1 | package imangazaliev.quickmenu;
2 |
3 | import android.app.Activity;
4 | import android.view.Gravity;
5 | import android.view.LayoutInflater;
6 | import android.view.MotionEvent;
7 | import android.view.View;
8 | import android.view.ViewTreeObserver;
9 | import android.view.animation.Animation;
10 | import android.widget.FrameLayout;
11 | import android.widget.LinearLayout;
12 | import android.widget.RelativeLayout;
13 | import android.widget.ScrollView;
14 | import android.widget.Toast;
15 |
16 | import java.util.List;
17 |
18 | import imangazaliev.quickmenulibrary.R;
19 | import imangazaliev.quickmenu.interfaces.QuickMenuItem;
20 |
21 | /**
22 | * Этот класс устанавливает меню в лейаут и заполняет меню пунктами
23 | */
24 | public class QuickMenuHelper {
25 |
26 | private Activity mActivity;
27 | private List mItems;
28 | /* Лейаут, в который будет устанавливаться родительский лейаут меню */
29 | private FrameLayout mMenuContainerLayout;
30 | /* Родительский лейаут меню */
31 | private LinearLayout mParentLayout;
32 | /* Лейаут меню */
33 | private LinearLayout mMenuLayout;
34 | /* Лейаут пунктов меню */
35 | private LinearLayout mMenuItemsContainer;
36 | private Animation mShowAnimation;
37 | private Animation mHideAnimation;
38 | private QuickMenuListener mQuickMenuListener;
39 | private boolean isAnimationActive;
40 |
41 | public QuickMenuHelper(Activity activity, List items, int layoutId, QuickMenuProperties properties) {
42 | this.mActivity = activity;
43 | this.mItems = items;
44 |
45 | this.isAnimationActive = false;
46 |
47 | initContainerLayout(layoutId);
48 | setupMenuLayout(properties);
49 | initAnimations(properties);
50 | addItemsToMenu();
51 | }
52 |
53 | public void setQuickMenuListener(QuickMenuListener quickMenuListener) {
54 | mQuickMenuListener = quickMenuListener;
55 | }
56 |
57 | /**
58 | * Устанавливаем меню в лейаут
59 | */
60 | private void initContainerLayout(int layoutId) {
61 | try {
62 | mMenuContainerLayout = (FrameLayout) mActivity.findViewById(layoutId);
63 | if (mMenuContainerLayout == null) {
64 | throw new RuntimeException("Menu's container layout not found");
65 | }
66 | } catch (ClassCastException e) {
67 | throw new RuntimeException("Menu's container layout must be FrameLayout");
68 | }
69 | }
70 |
71 | /**
72 | * Устанавливаем меню в лейаут
73 | */
74 | private boolean childIsTouched;
75 | private void setupMenuLayout(final QuickMenuProperties properties) {
76 | LayoutInflater inflater = mActivity.getLayoutInflater();
77 | inflater.inflate(R.layout.quick_menu_layout, mMenuContainerLayout, true);
78 | mParentLayout = (LinearLayout) mMenuContainerLayout.findViewById(R.id.menuParentLayout);
79 | mMenuLayout = (LinearLayout) mParentLayout.findViewById(R.id.menuLayout);
80 | mMenuItemsContainer = (LinearLayout) mParentLayout.findViewById(R.id.menuItemsContainer);
81 |
82 | mParentLayout.setVisibility(View.GONE);
83 | mParentLayout.setBackgroundDrawable(properties.getLayoutBackground());
84 | mMenuLayout.setBackgroundDrawable(properties.getMenuBackground());
85 | mParentLayout.setGravity(properties.getGravity());
86 |
87 | mParentLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
88 | @Override
89 | public void onGlobalLayout() {
90 | int menuWidth;
91 | if (properties.getWidthMode() == QuickMenuProperties.WidthMode.PIXELS) {
92 | menuWidth = properties.getMenuWidth();
93 | } else {
94 | //устанавливаем ширину в процентах от ширины родителя
95 | float widthInPercentages = properties.getMenuWidthInPercentages() * 0.01f;
96 | menuWidth = (int) (mParentLayout.getWidth() * widthInPercentages);
97 | }
98 |
99 | LinearLayout.LayoutParams menuLayoutParams = (LinearLayout.LayoutParams) mMenuLayout.getLayoutParams();
100 | menuLayoutParams.setMargins(properties.getMarginLeft(), properties.getMarginTop(), properties.getMarginRight(), properties.getMarginBottom());
101 | menuLayoutParams.width = menuWidth;
102 |
103 | mMenuLayout.setLayoutParams(menuLayoutParams);
104 | mMenuLayout.setPadding(properties.getPaddingLeft(), properties.getPaddingTop(), properties.getPaddingRight(), properties.getPaddingBottom());
105 |
106 | }
107 | });
108 |
109 | if (properties.getCanceledOnTouchOutside()) {
110 | mParentLayout.setOnTouchListener(new View.OnTouchListener() {
111 | @Override
112 | public boolean onTouch(View v, MotionEvent event) {
113 | if (childIsTouched) {
114 | childIsTouched = false;
115 | return true;
116 | }
117 | hideMenu();
118 | return true;
119 | }
120 | });
121 |
122 | mMenuLayout.setOnTouchListener(new View.OnTouchListener() {
123 | @Override
124 | public boolean onTouch(View v, MotionEvent event) {
125 | childIsTouched = true;
126 | return true;
127 | }
128 | });
129 | }
130 |
131 | }
132 |
133 | private void initAnimations(QuickMenuProperties properties) {
134 | this.mShowAnimation = properties.getOnShowAnimation();
135 | this.mHideAnimation = properties.getOnHideAnimation();
136 |
137 | if (mShowAnimation != null) {
138 | mShowAnimation.setAnimationListener(new Animation.AnimationListener() {
139 | @Override
140 | public void onAnimationStart(Animation animation) {
141 | isAnimationActive = true;
142 | }
143 |
144 | @Override
145 | public void onAnimationEnd(Animation animation) {
146 | isAnimationActive = false;
147 | if (mQuickMenuListener != null) {
148 | mQuickMenuListener.onMenuShowed();
149 | }
150 | }
151 |
152 | @Override
153 | public void onAnimationRepeat(Animation animation) {}
154 | });
155 | }
156 |
157 | if (mHideAnimation != null) {
158 | mHideAnimation.setAnimationListener(new Animation.AnimationListener() {
159 | @Override
160 | public void onAnimationStart(Animation animation) {
161 | isAnimationActive = true;
162 | }
163 |
164 | @Override
165 | public void onAnimationEnd(Animation animation) {
166 | isAnimationActive = false;
167 | mParentLayout.setVisibility(View.GONE);
168 | if (mQuickMenuListener != null) {
169 | mQuickMenuListener.onMenuHided();
170 | }
171 | }
172 |
173 | @Override
174 | public void onAnimationRepeat(Animation animation) {}
175 | });
176 | }
177 | }
178 |
179 | /**
180 | * Добавляем элементы меню в лейаут
181 | */
182 | private void addItemsToMenu() {
183 | for (QuickMenuItem item : mItems) {
184 | mMenuItemsContainer.addView(item.getView(mActivity, mMenuLayout));
185 | }
186 | }
187 |
188 | public boolean isShowing() {
189 | return mParentLayout.getVisibility() == View.VISIBLE;
190 | }
191 |
192 | public void showMenu() {
193 | if (isAnimationActive) {
194 | return;
195 | }
196 |
197 | mParentLayout.setVisibility(View.VISIBLE);
198 |
199 | if (mShowAnimation != null) {
200 | mMenuLayout.startAnimation(mShowAnimation);
201 | }
202 | }
203 |
204 | public void hideMenu() {
205 | if (isAnimationActive) {
206 | return;
207 | }
208 |
209 | if (mHideAnimation != null) {
210 | mMenuLayout.startAnimation(mHideAnimation);
211 | } else {
212 | mParentLayout.setVisibility(View.GONE);
213 | }
214 | }
215 |
216 |
217 | }
218 |
--------------------------------------------------------------------------------
/library/src/main/java/imangazaliev/quickmenu/QuickMenuProperties.java:
--------------------------------------------------------------------------------
1 | package imangazaliev.quickmenu;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.graphics.drawable.ColorDrawable;
6 | import android.graphics.drawable.Drawable;
7 | import android.view.Gravity;
8 | import android.view.animation.Animation;
9 |
10 | import imangazaliev.quickmenulibrary.R;
11 |
12 | /**
13 | * Created by Mahach Imangazaliev on 15.01.2016
14 | */
15 | public class QuickMenuProperties {
16 |
17 | public enum WidthMode {PIXELS, PERCENTAGES}
18 |
19 | private final WidthMode mWidthMode;
20 | private final int mMenuWidth;
21 | private int mGravity;
22 | private final int mMenuWidthInPercentages;
23 | private final int mMarginLeft, mMarginTop, mMarginRight, mMarginBottom;
24 | private final int mPaddingLeft, mPaddingTop, mPaddingRight, mPaddingBottom;
25 | private final Drawable mMenuBackground;
26 | private final Drawable mLayoutBackground;
27 | private final boolean mCanceledOnTouchOutside;
28 | private final Animation mShowAnimation;
29 | private final Animation mHideAnimation;
30 |
31 | private QuickMenuProperties(Builder builder) {
32 | this.mWidthMode = builder.mWidthMode;
33 | this.mMenuWidth = builder.mMenuWidth;
34 | this.mGravity = builder.mGravity;
35 | this.mMenuWidthInPercentages = builder.mMenuWidthInPercentages;
36 | this.mMarginLeft = builder.mMarginLeft;
37 | this.mMarginTop = builder.mMarginTop;
38 | this.mMarginRight = builder.mMarginRight;
39 | this.mMarginBottom = builder.mMarginBottom;
40 | this.mPaddingLeft = builder.mPaddingLeft;
41 | this.mPaddingTop = builder.mPaddingTop;
42 | this.mPaddingRight = builder.mPaddingRight;
43 | this.mPaddingBottom = builder.mPaddingBottom;
44 | this.mMenuBackground = builder.mMenuBackground;
45 | this.mLayoutBackground = builder.mLayoutBackground;
46 | this.mCanceledOnTouchOutside = builder.mCanceledOnTouchOutside;
47 | this.mShowAnimation = builder.mShowAnimation;
48 | this.mHideAnimation = builder.mHideAnimation;
49 | }
50 |
51 | public WidthMode getWidthMode() {
52 | return mWidthMode;
53 | }
54 |
55 | public int getMenuWidth() {
56 | return mMenuWidth;
57 | }
58 |
59 | public int getGravity() {
60 | return mGravity;
61 | }
62 |
63 | public int getMenuWidthInPercentages() {
64 | return mMenuWidthInPercentages;
65 | }
66 |
67 | public int getMarginTop() {
68 | return mMarginTop;
69 | }
70 |
71 | public int getMarginBottom() {
72 | return mMarginBottom;
73 | }
74 |
75 | public int getMarginLeft() {
76 | return mMarginLeft;
77 | }
78 |
79 | public int getMarginRight() {
80 | return mMarginRight;
81 | }
82 |
83 | public int getPaddingTop() {
84 | return mPaddingTop;
85 | }
86 |
87 | public int getPaddingBottom() {
88 | return mPaddingBottom;
89 | }
90 |
91 | public int getPaddingLeft() {
92 | return mPaddingLeft;
93 | }
94 |
95 | public int getPaddingRight() {
96 | return mPaddingRight;
97 | }
98 |
99 | public Drawable getMenuBackground() {
100 | return mMenuBackground;
101 | }
102 |
103 | public Drawable getLayoutBackground() {
104 | return mLayoutBackground;
105 | }
106 |
107 | public boolean getCanceledOnTouchOutside() {
108 | return mCanceledOnTouchOutside;
109 | }
110 |
111 | public Animation getOnShowAnimation() {
112 | return mShowAnimation;
113 | }
114 |
115 | public Animation getOnHideAnimation() {
116 | return mHideAnimation;
117 | }
118 |
119 | public static class Builder {
120 |
121 | /** */
122 | private WidthMode mWidthMode;
123 | /**
124 | * Ширина меню в пикселях
125 | */
126 | private int mMenuWidth;
127 | /**
128 | * Позиция на экране
129 | */
130 | private int mGravity;
131 | /**
132 | * Ширина меню в процентах
133 | */
134 | private int mMenuWidthInPercentages;
135 | /**
136 | * Внешние отступы меню
137 | */
138 | private int mMarginTop, mMarginLeft, mMarginBottom, mMarginRight;
139 | /**
140 | * Внутренние отступы меню
141 | */
142 | private int mPaddingTop, mPaddingLeft, mPaddingBottom, mPaddingRight;
143 | /**
144 | * Фон меню
145 | */
146 | private Drawable mMenuBackground;
147 | /**
148 | * Фон лейаута, в котором находится меню
149 | */
150 | private Drawable mLayoutBackground;
151 | /**
152 | * Меню закрывается при нажатии за зону самого меню
153 | */
154 | private boolean mCanceledOnTouchOutside;
155 | /**
156 | * Анимация при появлении меню
157 | */
158 | private Animation mShowAnimation;
159 | /**
160 | * Анимация при скрытии меню
161 | */
162 | private Animation mHideAnimation;
163 |
164 | public Builder(Context context) {
165 | this.mWidthMode = WidthMode.PIXELS;
166 | this.mMenuWidth = context.getResources().getDimensionPixelSize(R.dimen.quick_menu_width);
167 | this.mGravity = Gravity.TOP | Gravity.RIGHT;
168 | this.mMarginTop = mMarginLeft = mMarginBottom = mMarginRight = context.getResources().getDimensionPixelSize(R.dimen.quick_menu_margin);
169 | this.mPaddingTop = mPaddingLeft = mPaddingBottom = mPaddingRight = context.getResources().getDimensionPixelSize(R.dimen.quick_menu_padding);
170 | this.mMenuBackground = context.getResources().getDrawable(R.drawable.quick_menu_bg);
171 | this.mLayoutBackground = new ColorDrawable(Color.parseColor("#99000000"));
172 | this.mCanceledOnTouchOutside = false;
173 | }
174 |
175 | public Builder withWidth(int width) {
176 | if (width < 0) {
177 | throw new RuntimeException("Number must be greater than or equal to zero");
178 | }
179 | this.mMenuWidth = width;
180 | this.mWidthMode = WidthMode.PIXELS;
181 | return this;
182 | }
183 |
184 | public Builder withWidthInPercentages(int widthInPercentages) {
185 | if (widthInPercentages < 0 || widthInPercentages > 100) {
186 | throw new RuntimeException("Number must be between 0 and 100");
187 | }
188 | this.mMenuWidthInPercentages = widthInPercentages;
189 | this.mWidthMode = WidthMode.PERCENTAGES;
190 | return this;
191 | }
192 |
193 | public Builder withGravity(int gravity) {
194 | this.mGravity = gravity;
195 | return this;
196 | }
197 |
198 | public Builder withMargins(int left, int top, int right, int bottom) {
199 | this.mMarginLeft = left;
200 | this.mMarginTop = top;
201 | this.mMarginRight = right;
202 | this.mMarginBottom = bottom;
203 | return this;
204 | }
205 |
206 | public Builder withPaddings(int left, int top, int right, int bottom) {
207 | this.mPaddingLeft = left;
208 | this.mPaddingTop = top;
209 | this.mPaddingRight = right;
210 | this.mPaddingBottom = bottom;
211 | return this;
212 | }
213 |
214 | public Builder withBackground(Drawable background) {
215 | this.mMenuBackground = background;
216 | return this;
217 | }
218 |
219 | public Builder withLayoutBackground(Drawable background) {
220 | this.mLayoutBackground = background;
221 | return this;
222 | }
223 |
224 | public Builder withCancelOnTouchOutside(boolean cancelOnTouchOutside) {
225 | this.mCanceledOnTouchOutside = cancelOnTouchOutside;
226 | return this;
227 | }
228 |
229 | public Builder withOnShowAnimation(Animation showAnimation) {
230 | this.mShowAnimation = showAnimation;
231 | return this;
232 | }
233 |
234 | public Builder withOnHideAnimation(Animation hideAnimation) {
235 | this.mHideAnimation = hideAnimation;
236 | return this;
237 | }
238 |
239 | public QuickMenuProperties build() {
240 | return new QuickMenuProperties(this);
241 | }
242 |
243 | }
244 |
245 | }
246 |
--------------------------------------------------------------------------------
/library/library.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | generateDebugSources
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
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 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | generateDebugSources
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
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 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
--------------------------------------------------------------------------------