├── .classpath
├── .project
├── AndroidManifest.xml
├── README.md
├── bin
├── AndroidManifest.xml
├── SlidingMenu2.apk
├── classes.dex
├── classes
│ └── com
│ │ └── entropy
│ │ └── slidingmenu2
│ │ ├── BuildConfig.class
│ │ ├── MainActivity$1.class
│ │ ├── MainActivity$2.class
│ │ ├── MainActivity.class
│ │ ├── R$array.class
│ │ ├── R$attr.class
│ │ ├── R$dimen.class
│ │ ├── R$drawable.class
│ │ ├── R$id.class
│ │ ├── R$layout.class
│ │ ├── R$menu.class
│ │ ├── R$string.class
│ │ ├── R$style.class
│ │ ├── R.class
│ │ ├── fragment
│ │ ├── FragmentButton.class
│ │ ├── FragmentCheckBox.class
│ │ ├── FragmentEditText.class
│ │ ├── FragmentImageView.class
│ │ ├── FragmentListView.class
│ │ ├── FragmentMain.class
│ │ ├── FragmentRadioButton.class
│ │ ├── FragmentTextView.class
│ │ ├── FragmentToggleButton.class
│ │ └── FragmentWebView.class
│ │ └── layout
│ │ ├── MainLayout$1.class
│ │ ├── MainLayout$EaseInInterpolator.class
│ │ ├── MainLayout$MenuRunnable.class
│ │ ├── MainLayout$MenuState.class
│ │ └── MainLayout.class
├── dexedLibs
│ ├── android-support-v4-4e83ea313a840fd50e6dcee3db5a18b4.jar
│ └── annotations-ecc9911f5c43152223301645083a16df.jar
├── jarlist.cache
├── res
│ ├── drawable-hdpi
│ │ └── ic_launcher.png
│ ├── drawable-mdpi
│ │ └── ic_launcher.png
│ ├── drawable-xhdpi
│ │ └── ic_launcher.png
│ └── drawable-xxhdpi
│ │ └── ic_launcher.png
└── resources.ap_
├── gen
└── com
│ └── entropy
│ └── slidingmenu2
│ ├── BuildConfig.java
│ └── R.java
├── ic_launcher-web.png
├── libs
└── android-support-v4.jar
├── proguard-project.txt
├── project.properties
├── res
├── drawable-hdpi
│ └── ic_launcher.png
├── drawable-mdpi
│ └── ic_launcher.png
├── drawable-xhdpi
│ └── ic_launcher.png
├── drawable-xxhdpi
│ └── ic_launcher.png
├── drawable
│ └── android.jpg
├── layout
│ ├── activity_main.xml
│ ├── fragment_button.xml
│ ├── fragment_checkbox.xml
│ ├── fragment_edittext.xml
│ ├── fragment_imageview.xml
│ ├── fragment_listview.xml
│ ├── fragment_main.xml
│ ├── fragment_radiobutton.xml
│ ├── fragment_textview.xml
│ ├── fragment_togglebutton.xml
│ └── fragment_webview.xml
├── menu
│ └── main.xml
├── values-sw600dp
│ └── dimens.xml
├── values-sw720dp-land
│ └── dimens.xml
└── values
│ ├── dimens.xml
│ ├── menu_items.xml
│ ├── strings.xml
│ └── styles.xml
└── src
└── com
└── entropy
└── slidingmenu2
├── MainActivity.java
├── fragment
├── FragmentButton.java
├── FragmentCheckBox.java
├── FragmentEditText.java
├── FragmentImageView.java
├── FragmentListView.java
├── FragmentMain.java
├── FragmentRadioButton.java
├── FragmentTextView.java
├── FragmentToggleButton.java
└── FragmentWebView.java
└── layout
└── MainLayout.java
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | SlidingMenu2
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
16 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SlidingMenu
2 |
3 | ❤️ Support my app ❤️
4 |
5 | - [Push Hero - pure Swift native macOS application to test push notifications](https://www.producthunt.com/posts/push-hero-2)
6 | - [PastePal - Pasteboard, note and shortcut manager](https://www.producthunt.com/posts/pastepal)
7 | - [Frame recorder - Recorder gif and video with frame](https://www.producthunt.com/posts/frame-recorder)
8 | - [Alias - App and file shortcut manager](https://www.producthunt.com/posts/alias-shortcut-manager)
9 | - [Other apps](https://onmyway133.github.io/projects/)
10 |
11 | ❤️❤️😇😍🤘❤️❤️
12 |
13 | Tutorial on how to create sliding menu on Android
14 | For more information, visit
15 |
16 | https://github.com/onmyway133/blog/issues/151
17 | https://github.com/onmyway133/blog/issues/152
18 |
--------------------------------------------------------------------------------
/bin/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
16 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/bin/SlidingMenu2.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/SlidingMenu2.apk
--------------------------------------------------------------------------------
/bin/classes.dex:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/classes.dex
--------------------------------------------------------------------------------
/bin/classes/com/entropy/slidingmenu2/BuildConfig.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/classes/com/entropy/slidingmenu2/BuildConfig.class
--------------------------------------------------------------------------------
/bin/classes/com/entropy/slidingmenu2/MainActivity$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/classes/com/entropy/slidingmenu2/MainActivity$1.class
--------------------------------------------------------------------------------
/bin/classes/com/entropy/slidingmenu2/MainActivity$2.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/classes/com/entropy/slidingmenu2/MainActivity$2.class
--------------------------------------------------------------------------------
/bin/classes/com/entropy/slidingmenu2/MainActivity.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/classes/com/entropy/slidingmenu2/MainActivity.class
--------------------------------------------------------------------------------
/bin/classes/com/entropy/slidingmenu2/R$array.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/classes/com/entropy/slidingmenu2/R$array.class
--------------------------------------------------------------------------------
/bin/classes/com/entropy/slidingmenu2/R$attr.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/classes/com/entropy/slidingmenu2/R$attr.class
--------------------------------------------------------------------------------
/bin/classes/com/entropy/slidingmenu2/R$dimen.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/classes/com/entropy/slidingmenu2/R$dimen.class
--------------------------------------------------------------------------------
/bin/classes/com/entropy/slidingmenu2/R$drawable.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/classes/com/entropy/slidingmenu2/R$drawable.class
--------------------------------------------------------------------------------
/bin/classes/com/entropy/slidingmenu2/R$id.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/classes/com/entropy/slidingmenu2/R$id.class
--------------------------------------------------------------------------------
/bin/classes/com/entropy/slidingmenu2/R$layout.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/classes/com/entropy/slidingmenu2/R$layout.class
--------------------------------------------------------------------------------
/bin/classes/com/entropy/slidingmenu2/R$menu.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/classes/com/entropy/slidingmenu2/R$menu.class
--------------------------------------------------------------------------------
/bin/classes/com/entropy/slidingmenu2/R$string.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/classes/com/entropy/slidingmenu2/R$string.class
--------------------------------------------------------------------------------
/bin/classes/com/entropy/slidingmenu2/R$style.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/classes/com/entropy/slidingmenu2/R$style.class
--------------------------------------------------------------------------------
/bin/classes/com/entropy/slidingmenu2/R.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/classes/com/entropy/slidingmenu2/R.class
--------------------------------------------------------------------------------
/bin/classes/com/entropy/slidingmenu2/fragment/FragmentButton.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/classes/com/entropy/slidingmenu2/fragment/FragmentButton.class
--------------------------------------------------------------------------------
/bin/classes/com/entropy/slidingmenu2/fragment/FragmentCheckBox.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/classes/com/entropy/slidingmenu2/fragment/FragmentCheckBox.class
--------------------------------------------------------------------------------
/bin/classes/com/entropy/slidingmenu2/fragment/FragmentEditText.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/classes/com/entropy/slidingmenu2/fragment/FragmentEditText.class
--------------------------------------------------------------------------------
/bin/classes/com/entropy/slidingmenu2/fragment/FragmentImageView.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/classes/com/entropy/slidingmenu2/fragment/FragmentImageView.class
--------------------------------------------------------------------------------
/bin/classes/com/entropy/slidingmenu2/fragment/FragmentListView.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/classes/com/entropy/slidingmenu2/fragment/FragmentListView.class
--------------------------------------------------------------------------------
/bin/classes/com/entropy/slidingmenu2/fragment/FragmentMain.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/classes/com/entropy/slidingmenu2/fragment/FragmentMain.class
--------------------------------------------------------------------------------
/bin/classes/com/entropy/slidingmenu2/fragment/FragmentRadioButton.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/classes/com/entropy/slidingmenu2/fragment/FragmentRadioButton.class
--------------------------------------------------------------------------------
/bin/classes/com/entropy/slidingmenu2/fragment/FragmentTextView.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/classes/com/entropy/slidingmenu2/fragment/FragmentTextView.class
--------------------------------------------------------------------------------
/bin/classes/com/entropy/slidingmenu2/fragment/FragmentToggleButton.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/classes/com/entropy/slidingmenu2/fragment/FragmentToggleButton.class
--------------------------------------------------------------------------------
/bin/classes/com/entropy/slidingmenu2/fragment/FragmentWebView.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/classes/com/entropy/slidingmenu2/fragment/FragmentWebView.class
--------------------------------------------------------------------------------
/bin/classes/com/entropy/slidingmenu2/layout/MainLayout$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/classes/com/entropy/slidingmenu2/layout/MainLayout$1.class
--------------------------------------------------------------------------------
/bin/classes/com/entropy/slidingmenu2/layout/MainLayout$EaseInInterpolator.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/classes/com/entropy/slidingmenu2/layout/MainLayout$EaseInInterpolator.class
--------------------------------------------------------------------------------
/bin/classes/com/entropy/slidingmenu2/layout/MainLayout$MenuRunnable.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/classes/com/entropy/slidingmenu2/layout/MainLayout$MenuRunnable.class
--------------------------------------------------------------------------------
/bin/classes/com/entropy/slidingmenu2/layout/MainLayout$MenuState.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/classes/com/entropy/slidingmenu2/layout/MainLayout$MenuState.class
--------------------------------------------------------------------------------
/bin/classes/com/entropy/slidingmenu2/layout/MainLayout.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/classes/com/entropy/slidingmenu2/layout/MainLayout.class
--------------------------------------------------------------------------------
/bin/dexedLibs/android-support-v4-4e83ea313a840fd50e6dcee3db5a18b4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/dexedLibs/android-support-v4-4e83ea313a840fd50e6dcee3db5a18b4.jar
--------------------------------------------------------------------------------
/bin/dexedLibs/annotations-ecc9911f5c43152223301645083a16df.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/dexedLibs/annotations-ecc9911f5c43152223301645083a16df.jar
--------------------------------------------------------------------------------
/bin/jarlist.cache:
--------------------------------------------------------------------------------
1 | # cache for current jar dependency. DO NOT EDIT.
2 | # format is
3 | # Encoding is UTF-8
4 |
--------------------------------------------------------------------------------
/bin/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/bin/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/bin/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/bin/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/bin/resources.ap_:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/bin/resources.ap_
--------------------------------------------------------------------------------
/gen/com/entropy/slidingmenu2/BuildConfig.java:
--------------------------------------------------------------------------------
1 | /** Automatically generated file. DO NOT MODIFY */
2 | package com.entropy.slidingmenu2;
3 |
4 | public final class BuildConfig {
5 | public final static boolean DEBUG = true;
6 | }
--------------------------------------------------------------------------------
/gen/com/entropy/slidingmenu2/R.java:
--------------------------------------------------------------------------------
1 | /* AUTO-GENERATED FILE. DO NOT MODIFY.
2 | *
3 | * This class was automatically generated by the
4 | * aapt tool from the resource data it found. It
5 | * should not be modified by hand.
6 | */
7 |
8 | package com.entropy.slidingmenu2;
9 |
10 | public final class R {
11 | public static final class array {
12 | public static final int menu_items=0x7f050000;
13 | }
14 | public static final class attr {
15 | }
16 | public static final class dimen {
17 | /** Default screen margins, per the Android Design guidelines.
18 |
19 | Customize dimensions originally defined in res/values/dimens.xml (such as
20 | screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
21 |
22 | */
23 | public static final int activity_horizontal_margin=0x7f040000;
24 | public static final int activity_vertical_margin=0x7f040001;
25 | }
26 | public static final class drawable {
27 | public static final int android=0x7f020000;
28 | public static final int ic_launcher=0x7f020001;
29 | }
30 | public static final class id {
31 | public static final int action_settings=0x7f090010;
32 | public static final int activity_main_content_button_menu=0x7f090001;
33 | public static final int activity_main_content_fragment=0x7f090003;
34 | public static final int activity_main_content_title=0x7f090002;
35 | public static final int activity_main_menu_listview=0x7f090000;
36 | public static final int fragment_button_button=0x7f090004;
37 | public static final int fragment_checkbox_checkbox1=0x7f090005;
38 | public static final int fragment_checkbox_checkbox2=0x7f090006;
39 | public static final int fragment_edittext_edittext=0x7f090007;
40 | public static final int fragment_imageview_imageview=0x7f090008;
41 | public static final int fragment_listview_listview=0x7f090009;
42 | public static final int fragment_main_textview=0x7f09000a;
43 | public static final int fragment_radiobutton_radiobutton1=0x7f09000b;
44 | public static final int fragment_radiobutton_radiobutton2=0x7f09000c;
45 | public static final int fragment_textview_textview=0x7f09000d;
46 | public static final int fragment_togglebutton_togglebutton=0x7f09000e;
47 | public static final int fragment_webview_webview=0x7f09000f;
48 | }
49 | public static final class layout {
50 | public static final int activity_main=0x7f030000;
51 | public static final int fragment_button=0x7f030001;
52 | public static final int fragment_checkbox=0x7f030002;
53 | public static final int fragment_edittext=0x7f030003;
54 | public static final int fragment_imageview=0x7f030004;
55 | public static final int fragment_listview=0x7f030005;
56 | public static final int fragment_main=0x7f030006;
57 | public static final int fragment_radiobutton=0x7f030007;
58 | public static final int fragment_textview=0x7f030008;
59 | public static final int fragment_togglebutton=0x7f030009;
60 | public static final int fragment_webview=0x7f03000a;
61 | }
62 | public static final class menu {
63 | public static final int main=0x7f080000;
64 | }
65 | public static final class string {
66 | public static final int action_settings=0x7f060001;
67 | public static final int app_name=0x7f060000;
68 | public static final int hello_world=0x7f060002;
69 | public static final int lorem_ipsum=0x7f060003;
70 | }
71 | public static final class style {
72 | /**
73 | Base application theme, dependent on API level. This theme is replaced
74 | by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
75 |
76 |
77 | Theme customizations available in newer API levels can go in
78 | res/values-vXX/styles.xml, while customizations related to
79 | backward-compatibility can go here.
80 |
81 | */
82 | public static final int AppBaseTheme=0x7f070000;
83 | /** Application theme.
84 | All customizations that are NOT specific to a particular API-level can go here.
85 | */
86 | public static final int AppTheme=0x7f070001;
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/ic_launcher-web.png
--------------------------------------------------------------------------------
/libs/android-support-v4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/libs/android-support-v4.jar
--------------------------------------------------------------------------------
/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-10
15 |
--------------------------------------------------------------------------------
/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable/android.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onmyway133/SlidingMenu/f4998507defb234e91cda674e0f06c65141b13cc/res/drawable/android.jpg
--------------------------------------------------------------------------------
/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
11 |
12 |
18 |
19 |
20 |
21 |
22 |
27 |
28 |
29 |
34 |
35 |
41 |
42 |
49 |
50 |
51 |
52 |
53 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/res/layout/fragment_button.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/res/layout/fragment_checkbox.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/res/layout/fragment_edittext.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/res/layout/fragment_imageview.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/res/layout/fragment_listview.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/res/layout/fragment_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/res/layout/fragment_radiobutton.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
19 |
20 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/res/layout/fragment_textview.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/res/layout/fragment_togglebutton.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/res/layout/fragment_webview.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/res/menu/main.xml:
--------------------------------------------------------------------------------
1 |
9 |
--------------------------------------------------------------------------------
/res/values-sw600dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/res/values-sw720dp-land/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 | 128dp
8 |
9 |
10 |
--------------------------------------------------------------------------------
/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 16dp
5 | 16dp
6 |
7 |
8 |
--------------------------------------------------------------------------------
/res/values/menu_items.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | - Main
5 | - Button
6 | - CheckBox
7 | - EditText
8 | - ImageView
9 | - ListView
10 | - RadioButton
11 | - TextView
12 | - ToggleButton
13 | - WebView
14 | - Dummy 1
15 | - Dummy 2
16 | - Dummy 3
17 | - Dummy 4
18 | - Dummy 5
19 | - Dummy 6
20 |
21 |
22 |
--------------------------------------------------------------------------------
/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | SlidingMenu2
5 | Settings
6 | Hello world!
7 | Lorem ipsum dolor sit amet, modo. Fusce mauris purus, aliquet spor det.
8 |
9 |
10 |
--------------------------------------------------------------------------------
/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
14 |
15 |
16 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/com/entropy/slidingmenu2/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.entropy.slidingmenu2;
2 |
3 |
4 | import com.entropy.slidingmenu2.fragment.FragmentButton;
5 | import com.entropy.slidingmenu2.fragment.FragmentCheckBox;
6 | import com.entropy.slidingmenu2.fragment.FragmentEditText;
7 | import com.entropy.slidingmenu2.fragment.FragmentImageView;
8 | import com.entropy.slidingmenu2.fragment.FragmentListView;
9 | import com.entropy.slidingmenu2.fragment.FragmentMain;
10 | import com.entropy.slidingmenu2.fragment.FragmentRadioButton;
11 | import com.entropy.slidingmenu2.fragment.FragmentTextView;
12 | import com.entropy.slidingmenu2.fragment.FragmentToggleButton;
13 | import com.entropy.slidingmenu2.fragment.FragmentWebView;
14 | import com.entropy.slidingmenu2.layout.MainLayout;
15 |
16 | import android.os.Bundle;
17 | import android.support.v4.app.Fragment;
18 | import android.support.v4.app.FragmentActivity;
19 | import android.support.v4.app.FragmentManager;
20 | import android.support.v4.app.FragmentTransaction;
21 | import android.view.Menu;
22 | import android.view.View;
23 | import android.view.View.OnClickListener;
24 | import android.widget.AdapterView;
25 | import android.widget.ArrayAdapter;
26 | import android.widget.Button;
27 | import android.widget.ListView;
28 | import android.widget.AdapterView.OnItemClickListener;
29 | import android.widget.TextView;
30 |
31 | // DK
32 | // This is my studying about Sliding Menu following Youtube video
33 | public class MainActivity extends FragmentActivity {
34 |
35 | // The MainLayout which will hold both the sliding menu and our main content
36 | // Main content will holds our Fragment respectively
37 | MainLayout mainLayout;
38 |
39 | // ListView menu
40 | private ListView lvMenu;
41 | private String[] lvMenuItems;
42 |
43 | // Menu button
44 | Button btMenu;
45 |
46 | // Title according to fragment
47 | TextView tvTitle;
48 |
49 | @Override
50 | protected void onCreate(Bundle savedInstanceState) {
51 | super.onCreate(savedInstanceState);
52 |
53 | // Inflate the mainLayout
54 | mainLayout = (MainLayout)this.getLayoutInflater().inflate(R.layout.activity_main, null);
55 | setContentView(mainLayout);
56 |
57 | // Init menu
58 |
59 | lvMenuItems = getResources().getStringArray(R.array.menu_items);
60 | lvMenu = (ListView) findViewById(R.id.activity_main_menu_listview);
61 | lvMenu.setAdapter(new ArrayAdapter(this,
62 | android.R.layout.simple_list_item_1, lvMenuItems));
63 | lvMenu.setOnItemClickListener(new OnItemClickListener() {
64 | @Override
65 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
66 | onMenuItemClick(parent, view, position, id);
67 | }
68 |
69 | });
70 |
71 |
72 | // Get menu button
73 | btMenu = (Button) findViewById(R.id.activity_main_content_button_menu);
74 | btMenu.setOnClickListener(new OnClickListener() {
75 | @Override
76 | public void onClick(View v) {
77 | // Show/hide the menu
78 | toggleMenu(v);
79 | }
80 | });
81 |
82 | // Get title textview
83 | tvTitle = (TextView) findViewById(R.id.activity_main_content_title);
84 |
85 |
86 | // Add FragmentMain as the initial fragment
87 | FragmentManager fm = MainActivity.this.getSupportFragmentManager();
88 | FragmentTransaction ft = fm.beginTransaction();
89 |
90 | FragmentMain fragment = new FragmentMain();
91 | ft.add(R.id.activity_main_content_fragment, fragment);
92 | ft.commit();
93 |
94 | }
95 |
96 | @Override
97 | public boolean onCreateOptionsMenu(Menu menu) {
98 | // Inflate the menu; this adds items to the action bar if it is present.
99 | getMenuInflater().inflate(R.menu.main, menu);
100 | return true;
101 | }
102 |
103 | public void toggleMenu(View v){
104 | mainLayout.toggleMenu();
105 | }
106 |
107 | // Perform action when a menu item is clicked
108 | private void onMenuItemClick(AdapterView> parent, View view, int position, long id) {
109 | String selectedItem = lvMenuItems[position];
110 | String currentItem = tvTitle.getText().toString();
111 |
112 | // Do nothing if selectedItem is currentItem
113 | if(selectedItem.compareTo(currentItem) == 0) {
114 | mainLayout.toggleMenu();
115 | return;
116 | }
117 |
118 | FragmentManager fm = MainActivity.this.getSupportFragmentManager();
119 | FragmentTransaction ft = fm.beginTransaction();
120 | Fragment fragment = null;
121 |
122 |
123 | if(selectedItem.compareTo("Main") == 0) {
124 | fragment = new FragmentMain();
125 | } else if(selectedItem.compareTo("Button") == 0) {
126 | fragment = new FragmentButton();
127 | } else if(selectedItem.compareTo("CheckBox") == 0) {
128 | fragment = new FragmentCheckBox();
129 | } else if(selectedItem.compareTo("EditText") == 0) {
130 | fragment = new FragmentEditText();
131 | } else if(selectedItem.compareTo("ImageView") == 0) {
132 | fragment = new FragmentImageView();
133 | } else if(selectedItem.compareTo("ListView") == 0) {
134 | fragment = new FragmentListView();
135 | } else if(selectedItem.compareTo("RadioButton") == 0) {
136 | fragment = new FragmentRadioButton();
137 | } else if(selectedItem.compareTo("TextView") == 0) {
138 | fragment = new FragmentTextView();
139 | Bundle b = new Bundle();
140 | b.putString("KEY_STRING", "Please display this text");
141 | fragment.setArguments(b);
142 | } else if(selectedItem.compareTo("ToggleButton") == 0) {
143 | fragment = new FragmentToggleButton();
144 | } else if(selectedItem.compareTo("WebView") == 0) {
145 | fragment = new FragmentWebView();
146 | }
147 |
148 | if(fragment != null) {
149 | // Replace current fragment by this new one
150 | ft.replace(R.id.activity_main_content_fragment, fragment);
151 | ft.commit();
152 |
153 | // Set title accordingly
154 | tvTitle.setText(selectedItem);
155 | }
156 |
157 | // Hide menu anyway
158 | mainLayout.toggleMenu();
159 | }
160 |
161 | @Override
162 | public void onBackPressed() {
163 | if (mainLayout.isMenuShown()) {
164 | mainLayout.toggleMenu();
165 | }
166 | else {
167 | super.onBackPressed();
168 | }
169 | }
170 | }
171 |
--------------------------------------------------------------------------------
/src/com/entropy/slidingmenu2/fragment/FragmentButton.java:
--------------------------------------------------------------------------------
1 | package com.entropy.slidingmenu2.fragment;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.Button;
9 |
10 | import com.entropy.slidingmenu2.R;
11 |
12 | public class FragmentButton extends Fragment {
13 | Button button;
14 |
15 | public FragmentButton() {
16 | }
17 |
18 | @Override
19 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
20 | Bundle savedInstanceState) {
21 | View view = inflater.inflate(R.layout.fragment_button, null);
22 |
23 | button = (Button) view.findViewById(R.id.fragment_button_button);
24 | button.setText("Button after clicked");
25 |
26 | return view;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/com/entropy/slidingmenu2/fragment/FragmentCheckBox.java:
--------------------------------------------------------------------------------
1 | package com.entropy.slidingmenu2.fragment;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.CheckBox;
9 |
10 | import com.entropy.slidingmenu2.R;
11 |
12 | public class FragmentCheckBox extends Fragment {
13 | CheckBox checkBox1;
14 | CheckBox checkBox2;
15 |
16 | public FragmentCheckBox() {
17 | }
18 |
19 | @Override
20 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
21 | Bundle savedInstanceState) {
22 | View view = inflater.inflate(R.layout.fragment_checkbox, null);
23 |
24 | checkBox1 = (CheckBox) view.findViewById(R.id.fragment_checkbox_checkbox1);
25 | checkBox2 = (CheckBox) view.findViewById(R.id.fragment_checkbox_checkbox2);
26 |
27 | return view;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/com/entropy/slidingmenu2/fragment/FragmentEditText.java:
--------------------------------------------------------------------------------
1 | package com.entropy.slidingmenu2.fragment;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.EditText;
9 |
10 | import com.entropy.slidingmenu2.R;
11 |
12 | public class FragmentEditText extends Fragment {
13 | EditText editText;
14 |
15 | public FragmentEditText() {
16 | }
17 |
18 | @Override
19 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
20 | Bundle savedInstanceState) {
21 | View view = inflater.inflate(R.layout.fragment_edittext, null);
22 |
23 | editText = (EditText) view.findViewById(R.id.fragment_edittext_edittext);
24 |
25 | return view;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/com/entropy/slidingmenu2/fragment/FragmentImageView.java:
--------------------------------------------------------------------------------
1 | package com.entropy.slidingmenu2.fragment;
2 |
3 | import com.entropy.slidingmenu2.R;
4 |
5 | import android.os.Bundle;
6 | import android.support.v4.app.Fragment;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.ImageView;
11 |
12 | public class FragmentImageView extends Fragment {
13 | ImageView imageView;
14 |
15 | public FragmentImageView() {
16 | }
17 |
18 | @Override
19 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
20 | Bundle savedInstanceState) {
21 | View view = inflater.inflate(R.layout.fragment_imageview, null);
22 |
23 | imageView = (ImageView) view.findViewById(R.id.fragment_imageview_imageview);
24 |
25 | imageView.setImageResource(R.drawable.android);
26 |
27 | return view;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/com/entropy/slidingmenu2/fragment/FragmentListView.java:
--------------------------------------------------------------------------------
1 | package com.entropy.slidingmenu2.fragment;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.ArrayAdapter;
9 | import android.widget.ListView;
10 |
11 | import com.entropy.slidingmenu2.R;
12 |
13 | public class FragmentListView extends Fragment {
14 | ListView listView;
15 |
16 | public FragmentListView() {
17 | }
18 |
19 | @Override
20 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
21 | Bundle savedInstanceState) {
22 | View view = inflater.inflate(R.layout.fragment_listview, null);
23 |
24 | String[] listViewItems = new String[] {"Android", "iOS", "Windows Phone", "Blackberry", "Meego", "Symbian"};
25 | listView = (ListView) view.findViewById(R.id.fragment_listview_listview);
26 | listView.setAdapter(new ArrayAdapter(getActivity(),
27 | android.R.layout.simple_list_item_1, listViewItems));
28 |
29 | return view;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/com/entropy/slidingmenu2/fragment/FragmentMain.java:
--------------------------------------------------------------------------------
1 | package com.entropy.slidingmenu2.fragment;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.TextView;
9 |
10 | import com.entropy.slidingmenu2.R;
11 |
12 | public class FragmentMain extends Fragment {
13 | TextView textView;
14 |
15 | public FragmentMain() {
16 | }
17 |
18 | @Override
19 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
20 | Bundle savedInstanceState) {
21 | View view = inflater.inflate(R.layout.fragment_main, null);
22 |
23 | textView = (TextView) view.findViewById(R.id.fragment_main_textview);
24 |
25 | return view;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/com/entropy/slidingmenu2/fragment/FragmentRadioButton.java:
--------------------------------------------------------------------------------
1 | package com.entropy.slidingmenu2.fragment;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.RadioButton;
9 |
10 | import com.entropy.slidingmenu2.R;
11 |
12 | public class FragmentRadioButton extends Fragment {
13 | RadioButton radioButton1;
14 | RadioButton radioButton2;
15 |
16 | public FragmentRadioButton() {
17 | }
18 |
19 | @Override
20 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
21 | Bundle savedInstanceState) {
22 | View view = inflater.inflate(R.layout.fragment_radiobutton, null);
23 |
24 | radioButton1 = (RadioButton) view.findViewById(R.id.fragment_radiobutton_radiobutton1);
25 | radioButton2 = (RadioButton) view.findViewById(R.id.fragment_radiobutton_radiobutton2);
26 |
27 | return view;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/com/entropy/slidingmenu2/fragment/FragmentTextView.java:
--------------------------------------------------------------------------------
1 | package com.entropy.slidingmenu2.fragment;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.TextView;
9 |
10 | import com.entropy.slidingmenu2.R;
11 |
12 | public class FragmentTextView extends Fragment {
13 | public static final String KEY_STRING = "KEY_STRING";
14 | TextView textView;
15 |
16 | public FragmentTextView() {
17 | }
18 |
19 | @Override
20 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
21 | Bundle savedInstanceState) {
22 | View view = inflater.inflate(R.layout.fragment_textview, null);
23 |
24 | Bundle b = getArguments();
25 | String text = b.getString(KEY_STRING);
26 |
27 | textView = (TextView) view.findViewById(R.id.fragment_textview_textview);
28 | textView.setText(text);
29 |
30 | return view;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/com/entropy/slidingmenu2/fragment/FragmentToggleButton.java:
--------------------------------------------------------------------------------
1 | package com.entropy.slidingmenu2.fragment;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.ToggleButton;
9 |
10 | import com.entropy.slidingmenu2.R;
11 |
12 | public class FragmentToggleButton extends Fragment {
13 | ToggleButton toggleButton;
14 |
15 | public FragmentToggleButton() {
16 | }
17 |
18 | @Override
19 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
20 | Bundle savedInstanceState) {
21 | View view = inflater.inflate(R.layout.fragment_togglebutton, null);
22 |
23 | toggleButton = (ToggleButton) view.findViewById(R.id.fragment_togglebutton_togglebutton);
24 |
25 | return view;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/com/entropy/slidingmenu2/fragment/FragmentWebView.java:
--------------------------------------------------------------------------------
1 | package com.entropy.slidingmenu2.fragment;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.webkit.WebView;
9 |
10 | import com.entropy.slidingmenu2.R;
11 |
12 | public class FragmentWebView extends Fragment {
13 | WebView webView;
14 |
15 | public FragmentWebView() {
16 | }
17 |
18 | @Override
19 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
20 | Bundle savedInstanceState) {
21 | View view = inflater.inflate(R.layout.fragment_webview, null);
22 |
23 | webView = (WebView) view.findViewById(R.id.fragment_webview_webview);
24 | String data = "Welcome to WebView
";
25 | webView.loadDataWithBaseURL("", data, "text/html", "UTF-8", "");
26 |
27 | return view;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/com/entropy/slidingmenu2/layout/MainLayout.java:
--------------------------------------------------------------------------------
1 | package com.entropy.slidingmenu2.layout;
2 |
3 | import android.content.Context;
4 | import android.os.Handler;
5 | import android.util.AttributeSet;
6 | import android.util.Log;
7 | import android.view.MotionEvent;
8 | import android.view.View;
9 | import android.view.animation.Interpolator;
10 | import android.widget.LinearLayout;
11 | import android.widget.Scroller;
12 |
13 | // DK Trick
14 | // Only the content is moving. Attach an View.OnTouchListener to it to support fling and drag & drop gesture
15 | // The menu stays still
16 | public class MainLayout extends LinearLayout {
17 |
18 | // Duration of sliding animation, in miliseconds
19 | private static final int SLIDING_DURATION = 500;
20 |
21 | // Query Scroller every 16 miliseconds
22 | private static final int QUERY_INTERVAL = 16;
23 |
24 | // MainLayout width
25 | int mainLayoutWidth;
26 |
27 | // Sliding menu
28 | private View menu;
29 |
30 | // Main content
31 | private View content;
32 |
33 | // menu does not occupy some right space
34 | // This should be updated correctly later in onMeasure
35 | private static int menuRightMargin = 150;
36 |
37 | // The state of menu
38 | private enum MenuState {
39 | HIDING,
40 | HIDDEN,
41 | SHOWING,
42 | SHOWN,
43 | };
44 |
45 | // content will be layouted based on this X offset
46 | // Normally, contentXOffset = menu.getLayoutParams().width = this.getWidth - menuRightMargin
47 | private int contentXOffset;
48 |
49 | // menu is hidden initially
50 | private MenuState currentMenuState = MenuState.HIDDEN;
51 |
52 | // Scroller is used to facilitate animation
53 | private Scroller menuScroller = new Scroller(this.getContext(),
54 | new EaseInInterpolator());
55 |
56 | // Used to query Scroller about scrolling position
57 | // Note: The 3rd paramter to startScroll is the distance
58 | private Runnable menuRunnable = new MenuRunnable();
59 | private Handler menuHandler = new Handler();
60 |
61 | // Previous touch position
62 | int prevX = 0;
63 |
64 | // Is user dragging the content
65 | boolean isDragging = false;
66 |
67 | // Used to facilitate ACTION_UP
68 | int lastDiffX = 0;
69 |
70 | // Constructor
71 |
72 | // 3 parameters constructor seems to be unavailable in 2.3
73 | /*
74 | public MainLayout(Context context, AttributeSet attrs, int defStyle) {
75 | super(context, attrs, defStyle);
76 | }
77 | */
78 |
79 | public MainLayout(Context context, AttributeSet attrs) {
80 | super(context, attrs);
81 | }
82 |
83 | public MainLayout(Context context) {
84 | super(context);
85 | }
86 |
87 | // Overriding LinearLayout core methods
88 |
89 | // Ask all children to measure themselves and compute the measurement of this
90 | // layout based on the children
91 | @Override
92 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
93 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
94 |
95 | mainLayoutWidth = MeasureSpec.getSize(widthMeasureSpec);
96 | menuRightMargin = mainLayoutWidth * 10 / 100;
97 | // Nothing to do, since we only care about how to layout
98 | }
99 |
100 | // This is called when MainLayout is attached to window
101 | // At this point it has a Surface and will start drawing.
102 | // Note that this function is guaranteed to be called before onDraw
103 | @Override
104 | protected void onAttachedToWindow() {
105 | super.onAttachedToWindow();
106 |
107 | // Get our 2 child View
108 | menu = this.getChildAt(0);
109 | content = this.getChildAt(1);
110 |
111 | // Attach View.OnTouchListener
112 | content.setOnTouchListener(new OnTouchListener() {
113 | @Override
114 | public boolean onTouch(View v, MotionEvent event) {
115 | return MainLayout.this.onContentTouch(v, event);
116 | }
117 | });
118 |
119 | // Initially hide the menu
120 | menu.setVisibility(View.GONE);
121 | }
122 |
123 | // Called from layout when this view should assign a size and position to each of its children
124 | @Override
125 | protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
126 | //Log.d("MainLayout.java onLayout()", "left " + left + " top " + top + " right " + right + " bottom " + bottom);
127 | //Log.d("MainLayout.java onLayout()", "getHeight " + this.getHeight() + " getWidth " + this.getWidth());
128 |
129 | // True if MainLayout 's size and position has changed
130 | // If true, calculate child views size
131 | if(changed) {
132 | // Note: LayoutParams are used by views to tell their parents how they want to be laid out
133 |
134 | //Log.d("MainLayout.java onLayout()", "changed " + changed);
135 |
136 | // content View occupies the full height and width
137 | LayoutParams contentLayoutParams = (LayoutParams)content.getLayoutParams();
138 | contentLayoutParams.height = this.getHeight();
139 | contentLayoutParams.width = this.getWidth();
140 |
141 | // menu View occupies the full height, but certain width
142 | LayoutParams menuLayoutParams = (LayoutParams)menu.getLayoutParams();
143 | menuLayoutParams.height = this.getHeight();
144 | menuLayoutParams.width = this.getWidth() - menuRightMargin;
145 | }
146 |
147 | // Layout the child views
148 | menu.layout(left, top, right - menuRightMargin, bottom);
149 | content.layout(left + contentXOffset, top, right + contentXOffset, bottom);
150 |
151 | }
152 |
153 | // Custom methods for MainLayout
154 |
155 | // Used to show/hide menu accordingly
156 | public void toggleMenu() {
157 | // Do nothing if sliding is in progress
158 | if(currentMenuState == MenuState.HIDING || currentMenuState == MenuState.SHOWING)
159 | return;
160 |
161 | switch(currentMenuState) {
162 | case HIDDEN:
163 | currentMenuState = MenuState.SHOWING;
164 | menu.setVisibility(View.VISIBLE);
165 | menuScroller.startScroll(0, 0, menu.getLayoutParams().width,
166 | 0, SLIDING_DURATION);
167 | break;
168 | case SHOWN:
169 | currentMenuState = MenuState.HIDING;
170 | menuScroller.startScroll(contentXOffset, 0, -contentXOffset,
171 | 0, SLIDING_DURATION);
172 | break;
173 | default:
174 | break;
175 | }
176 |
177 | // Begin querying
178 | menuHandler.postDelayed(menuRunnable, QUERY_INTERVAL);
179 |
180 | // Invalite this whole MainLayout, causing onLayout() to be called
181 | this.invalidate();
182 | }
183 |
184 | // Query Scroller
185 | protected class MenuRunnable implements Runnable {
186 | @Override
187 | public void run() {
188 | boolean isScrolling = menuScroller.computeScrollOffset();
189 | adjustContentPosition(isScrolling);
190 | }
191 | }
192 |
193 | // Adjust content View position to match sliding animation
194 | private void adjustContentPosition(boolean isScrolling) {
195 | int scrollerXOffset = menuScroller.getCurrX();
196 |
197 | //Log.d("MainLayout.java adjustContentPosition()", "scrollerOffset " + scrollerOffset);
198 |
199 | // Translate content View accordingly
200 | content.offsetLeftAndRight(scrollerXOffset - contentXOffset);
201 |
202 | contentXOffset = scrollerXOffset;
203 |
204 | // Invalite this whole MainLayout, causing onLayout() to be called
205 | this.invalidate();
206 |
207 | // Check if animation is in progress
208 | if (isScrolling)
209 | menuHandler.postDelayed(menuRunnable, QUERY_INTERVAL);
210 | else
211 | this.onMenuSlidingComplete();
212 | }
213 |
214 | // Called when sliding is complete
215 | private void onMenuSlidingComplete() {
216 | switch (currentMenuState) {
217 | case SHOWING:
218 | currentMenuState = MenuState.SHOWN;
219 | break;
220 | case HIDING:
221 | currentMenuState = MenuState.HIDDEN;
222 | menu.setVisibility(View.GONE);
223 | break;
224 | default:
225 | return;
226 | }
227 | }
228 |
229 | // Make scrolling more natural. Move more quickly at the end
230 | // See the formula here http://cyrilmottier.com/2012/05/22/the-making-of-prixing-fly-in-app-menu-part-1/
231 | protected class EaseInInterpolator implements Interpolator {
232 | @Override
233 | public float getInterpolation(float t) {
234 | return (float)Math.pow(t-1, 5) + 1;
235 | }
236 |
237 | }
238 |
239 | // Is menu completely shown
240 | public boolean isMenuShown() {
241 | return currentMenuState == MenuState.SHOWN;
242 | }
243 |
244 | // Handle touch event on content View
245 | public boolean onContentTouch(View v, MotionEvent event) {
246 | // Do nothing if sliding is in progress
247 | if(currentMenuState == MenuState.HIDING || currentMenuState == MenuState.SHOWING)
248 | return false;
249 |
250 | // getRawX returns X touch point corresponding to screen
251 | // getX sometimes returns screen X, sometimes returns content View X
252 | int curX = (int)event.getRawX();
253 | int diffX = 0;
254 |
255 | switch(event.getAction()) {
256 | case MotionEvent.ACTION_DOWN:
257 | //Log.d("MainLayout.java onContentTouch()", "Down x " + curX);
258 |
259 | prevX = curX;
260 | return true;
261 |
262 | case MotionEvent.ACTION_MOVE:
263 | //Log.d("MainLayout.java onContentTouch()", "Move x " + curX);
264 |
265 | // Set menu to Visible when user start dragging the content View
266 | if(!isDragging) {
267 | isDragging = true;
268 | menu.setVisibility(View.VISIBLE);
269 | }
270 |
271 | // How far we have moved since the last position
272 | diffX = curX - prevX;
273 |
274 | // Prevent user from dragging beyond border
275 | if(contentXOffset + diffX <= 0) {
276 | // Don't allow dragging beyond left border
277 | // Use diffX will make content cross the border, so only translate by -contentXOffset
278 | diffX = -contentXOffset;
279 | } else if(contentXOffset + diffX > mainLayoutWidth - menuRightMargin) {
280 | // Don't allow dragging beyond menu width
281 | diffX = mainLayoutWidth - menuRightMargin - contentXOffset;
282 | }
283 |
284 | // Translate content View accordingly
285 | content.offsetLeftAndRight(diffX);
286 |
287 | contentXOffset += diffX;
288 |
289 | // Invalite this whole MainLayout, causing onLayout() to be called
290 | this.invalidate();
291 |
292 | prevX = curX;
293 | lastDiffX = diffX;
294 | return true;
295 |
296 | case MotionEvent.ACTION_UP:
297 | //Log.d("MainLayout.java onContentTouch()", "Up x " + curX);
298 |
299 | Log.d("MainLayout.java onContentTouch()", "Up lastDiffX " + lastDiffX);
300 |
301 | // Start scrolling
302 | // Remember that when content has a chance to cross left border, lastDiffX is set to 0
303 | if(lastDiffX > 0) {
304 | // User wants to show menu
305 | currentMenuState = MenuState.SHOWING;
306 |
307 | // No need to set to Visible, because we have set to Visible in ACTION_MOVE
308 | //menu.setVisibility(View.VISIBLE);
309 |
310 | //Log.d("MainLayout.java onContentTouch()", "Up contentXOffset " + contentXOffset);
311 |
312 | // Start scrolling from contentXOffset
313 | menuScroller.startScroll(contentXOffset, 0, menu.getLayoutParams().width - contentXOffset,
314 | 0, SLIDING_DURATION);
315 | } else if(lastDiffX < 0) {
316 | // User wants to hide menu
317 | currentMenuState = MenuState.HIDING;
318 | menuScroller.startScroll(contentXOffset, 0, -contentXOffset,
319 | 0, SLIDING_DURATION);
320 | }
321 |
322 | // Begin querying
323 | menuHandler.postDelayed(menuRunnable, QUERY_INTERVAL);
324 |
325 | // Invalite this whole MainLayout, causing onLayout() to be called
326 | this.invalidate();
327 |
328 | // Done dragging
329 | isDragging = false;
330 | prevX = 0;
331 | lastDiffX = 0;
332 | return true;
333 |
334 | default:
335 | break;
336 | }
337 |
338 | return false;
339 | }
340 | }
341 |
--------------------------------------------------------------------------------