diff --git a/.gitignore b/.gitignore index b518b3c..2f49c1e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,14 @@ + +# Created by https://www.gitignore.io/api/androidstudio + +### AndroidStudio ### +# Covers files to be ignored for android development using Android Studio. + # Built application files *.apk *.ap_ -# Files for the Dalvik VM +# Files for the ART/Dalvik VM *.dex # Java class files @@ -11,11 +17,16 @@ # Generated files bin/ gen/ +out/ # Gradle files +.gradle .gradle/ build/ +# Signing files +.signing/ + # Local configuration file (sdk path, etc) local.properties @@ -25,49 +36,101 @@ proguard/ # Log Files *.log -# ========================= -# Operating System Files -# ========================= - -# OSX -# ========================= - +# Android Studio +/*/build/ +/*/local.properties +/*/out +/*/*/build +/*/*/production +captures/ +.navigation/ +*.ipr +*~ +*.swp + +# Android Patch +gen-external-apklibs + +# External native build folder generated in Android Studio 2.2 and later +.externalNativeBuild + +# NDK +obj/ + +# IntelliJ IDEA +*.iml +*.iws +/out/ + +# User-specific configurations +.idea/caches/ +.idea/libraries/ +.idea/shelf/ +.idea/workspace.xml +.idea/tasks.xml +.idea/.name +.idea/compiler.xml +.idea/copyright/profiles_settings.xml +.idea/encodings.xml +.idea/misc.xml +.idea/modules.xml +.idea/scopes/scope_settings.xml +.idea/dictionaries +.idea/vcs.xml +.idea/jsLibraryMappings.xml +.idea/datasources.xml +.idea/dataSources.ids +.idea/sqlDataSources.xml +.idea/dynamic.xml +.idea/uiDesigner.xml +.idea/** + +# OS-specific files .DS_Store -.AppleDouble -.LSOverride - -# Thumbnails +.DS_Store? ._* - -# Files that might appear on external disk .Spotlight-V100 .Trashes +ehthumbs.db +Thumbs.db -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk +# Legacy Eclipse project files +.classpath +.project +.cproject +.settings/ -# Windows -# ========================= +# Mobile Tools for Java (J2ME) +.mtj.tmp/ -# Windows image file caches -Thumbs.db -ehthumbs.db +# Package Files # +*.war +*.ear + +# virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml) +hs_err_pid* + +## Plugin-specific files: + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Mongo Explorer plugin +.idea/mongoSettings.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +### AndroidStudio Patch ### -# Folder config file -Desktop.ini +!/gradle/wrapper/gradle-wrapper.jar -# Recycle Bin used on file shares -$RECYCLE.BIN/ -# Windows Installer files -*.cab -*.msi -*.msm -*.msp +# End of https://www.gitignore.io/api/androidstudio -# Windows shortcuts -*.lnk diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..9b3fa3e --- /dev/null +++ b/build.gradle @@ -0,0 +1,17 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + repositories { + jcenter() + google() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.1.4' + } +} + +allprojects { + repositories { + jcenter() + google() + } +} diff --git a/eclipse/v1-AospImpl/.classpath b/eclipse/v1-AospImpl/.classpath deleted file mode 100644 index 5176974..0000000 --- a/eclipse/v1-AospImpl/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/eclipse/v1-AospImpl/.project b/eclipse/v1-AospImpl/.project deleted file mode 100644 index 8729ee3..0000000 --- a/eclipse/v1-AospImpl/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - SlidingDrawerDemo - - - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - diff --git a/eclipse/v1-AospImpl/AndroidManifest.xml b/eclipse/v1-AospImpl/AndroidManifest.xml deleted file mode 100644 index df5fbab..0000000 --- a/eclipse/v1-AospImpl/AndroidManifest.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/eclipse/v1-AospImpl/gen/me/wtao/widget/BuildConfig.java b/eclipse/v1-AospImpl/gen/me/wtao/widget/BuildConfig.java deleted file mode 100644 index 9925c5d..0000000 --- a/eclipse/v1-AospImpl/gen/me/wtao/widget/BuildConfig.java +++ /dev/null @@ -1,6 +0,0 @@ -/** Automatically generated file. DO NOT MODIFY */ -package me.wtao.widget; - -public final class BuildConfig { - public final static boolean DEBUG = true; -} \ No newline at end of file diff --git a/eclipse/v1-AospImpl/gen/me/wtao/widget/R.java b/eclipse/v1-AospImpl/gen/me/wtao/widget/R.java deleted file mode 100644 index 97c4786..0000000 --- a/eclipse/v1-AospImpl/gen/me/wtao/widget/R.java +++ /dev/null @@ -1,353 +0,0 @@ -/* AUTO-GENERATED FILE. DO NOT MODIFY. - * - * This class was automatically generated by the - * aapt tool from the resource data it found. It - * should not be modified by hand. - */ - -package me.wtao.widget; - -public final class R { - public static final class attr { - /**

Must be a boolean value, either "true" or "false". -

This may also be a reference to a resource (in the form -"@[package:]type:name") or -theme attribute (in the form -"?[package:][type:]name") -containing a value of this type. - */ - public static final int allowSingleTap=0x7f010005; - /** - Indicates whether the drawer should be opened/closed with an animation - when the user clicks the handle. Default is true. - -

Must be a boolean value, either "true" or "false". -

This may also be a reference to a resource (in the form -"@[package:]type:name") or -theme attribute (in the form -"?[package:][type:]name") -containing a value of this type. - */ - public static final int animateOnClick=0x7f010006; - /** - Indicates whether the drawer can be opened/closed by a single tap - on the handle. (If false, the user must drag or fling, or click - using the trackball, to open/close the drawer.) Default is true. - -

Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp". -Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), -in (inches), mm (millimeters). -

This may also be a reference to a resource (in the form -"@[package:]type:name") or -theme attribute (in the form -"?[package:][type:]name") -containing a value of this type. - */ - public static final int collapsedOffset=0x7f010003; - /** Identifier for the child that represents the drawer's content. -

Must be a reference to another resource, in the form "@[+][package:]type:name" -or to a theme attribute in the form "?[package:][type:]name". - */ - public static final int content=0x7f010001; - /**

Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp". -Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), -in (inches), mm (millimeters). -

This may also be a reference to a resource (in the form -"@[package:]type:name") or -theme attribute (in the form -"?[package:][type:]name") -containing a value of this type. - */ - public static final int expandedOffset=0x7f010004; - /** Identifier for the child that represents the drawer's handle. -

Must be a reference to another resource, in the form "@[+][package:]type:name" -or to a theme attribute in the form "?[package:][type:]name". - */ - public static final int handle=0x7f010000; - /** Orientation of the SlidingDrawer. -

Must be one of the following constant values.

- ---- - - - - -
ConstantValueDescription
topDown1
bottomUp2
leftToRight4
rightToLeft8
- */ - public static final int orientation=0x7f010002; - } - public static final class color { - /** A really bright Holo shade of blue - */ - public static final int holo_blue_bright=0x7f05000d; - /** A dark Holo shade of blue - */ - public static final int holo_blue_dark=0x7f050006; - /** A light Holo shade of blue - */ - public static final int holo_blue_light=0x7f050000; - /** A dark Holo shade of green - */ - public static final int holo_green_dark=0x7f050007; - /** A light Holo shade of green - */ - public static final int holo_green_light=0x7f050002; - /** A dark Holo shade of orange - */ - public static final int holo_orange_dark=0x7f05000c; - /** A light Holo shade of orange - */ - public static final int holo_orange_light=0x7f05000a; - /** A Holo shade of purple - */ - public static final int holo_purple=0x7f050009; - /** A dark Holo shade of red - */ - public static final int holo_red_dark=0x7f050008; - /** A light Holo shade of red - */ - public static final int holo_red_light=0x7f050004; - public static final int theme_color=0x7f05000e; - public static final int transparent_blue_light=0x7f050001; - public static final int transparent_green_light=0x7f050003; - public static final int transparent_orange_light=0x7f05000b; - public static final int transparent_red_light=0x7f050005; - } - public static final class dimen { - /** Default screen margins, per the Android Design guidelines. - - Customize dimensions originally defined in res/values/dimens.xml (such as - screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here. - - */ - public static final int activity_horizontal_margin=0x7f060000; - public static final int activity_vertical_margin=0x7f060001; - public static final int collapsed_offset=0x7f06000c; - public static final int expanded_offset=0x7f06000b; - public static final int horizontal_handle_height=0x7f060008; - public static final int horizontal_handle_width=0x7f060007; - public static final int shape_corner_radius=0x7f060002; - public static final int shape_stroke_width=0x7f060003; - public static final int sliding_drawer_outter_height=0x7f060005; - public static final int sliding_drawer_outter_width=0x7f060006; - public static final int vertical_handle_height=0x7f06000a; - public static final int vertical_handle_width=0x7f060009; - public static final int view_margin=0x7f060004; - } - public static final class drawable { - public static final int bk_holo_blue_light=0x7f020000; - public static final int bk_holo_red_light=0x7f020001; - public static final int ic_launcher=0x7f020002; - } - public static final class id { - public static final int action_settings=0x7f04000c; - public static final int bottomUp=0x7f040001; - public static final int content=0x7f040006; - public static final int drawer=0x7f04000b; - public static final int drawer_bottom_up=0x7f040008; - public static final int drawer_left_to_right=0x7f040009; - public static final int drawer_outter_layout=0x7f040004; - public static final int drawer_right_to_left=0x7f04000a; - public static final int drawer_top_down=0x7f040005; - public static final int handle=0x7f040007; - public static final int leftToRight=0x7f040002; - public static final int rightToLeft=0x7f040003; - public static final int topDown=0x7f040000; - } - public static final class layout { - public static final int activity_demo_1=0x7f030000; - public static final int activity_demo_2=0x7f030001; - public static final int layout_sliding_drawer=0x7f030002; - } - public static final class menu { - public static final int demo=0x7f090000; - } - public static final class string { - public static final int action_settings=0x7f070001; - public static final int app_name=0x7f070000; - public static final int content_prompt=0x7f070002; - public static final int handle_prompt=0x7f070003; - } - public static final class style { - /** - Base application theme, dependent on API level. This theme is replaced - by AppBaseTheme from res/values-vXX/styles.xml on newer devices. - - - Theme customizations available in newer API levels can go in - res/values-vXX/styles.xml, while customizations related to - backward-compatibility can go here. - - - Base application theme for API 11+. This theme completely replaces - AppBaseTheme from res/values/styles.xml on API 11+ devices. - - API 11 theme customizations can go here. - - Base application theme for API 14+. This theme completely replaces - AppBaseTheme from BOTH res/values/styles.xml and - res/values-v11/styles.xml on API 14+ devices. - - API 14 theme customizations can go here. - */ - public static final int AppBaseTheme=0x7f080000; - /** Application theme. - All customizations that are NOT specific to a particular API-level can go here. - */ - public static final int AppTheme=0x7f080001; - } - public static final class styleable { - /** - SlidingDrawer specific attributes. These attributes are used to configure - a SlidingDrawer from XML. - -

Includes the following attributes:

- - - - - - - - - - - -
AttributeDescription
{@link #SlidingDrawer_allowSingleTap me.wtao.widget:allowSingleTap}
{@link #SlidingDrawer_animateOnClick me.wtao.widget:animateOnClick} - Indicates whether the drawer should be opened/closed with an animation - when the user clicks the handle.
{@link #SlidingDrawer_collapsedOffset me.wtao.widget:collapsedOffset} - Indicates whether the drawer can be opened/closed by a single tap - on the handle.
{@link #SlidingDrawer_content me.wtao.widget:content} Identifier for the child that represents the drawer's content.
{@link #SlidingDrawer_expandedOffset me.wtao.widget:expandedOffset}
{@link #SlidingDrawer_handle me.wtao.widget:handle} Identifier for the child that represents the drawer's handle.
{@link #SlidingDrawer_orientation me.wtao.widget:orientation} Orientation of the SlidingDrawer.
- @see #SlidingDrawer_allowSingleTap - @see #SlidingDrawer_animateOnClick - @see #SlidingDrawer_collapsedOffset - @see #SlidingDrawer_content - @see #SlidingDrawer_expandedOffset - @see #SlidingDrawer_handle - @see #SlidingDrawer_orientation - */ - public static final int[] SlidingDrawer = { - 0x7f010000, 0x7f010001, 0x7f010002, 0x7f010003, - 0x7f010004, 0x7f010005, 0x7f010006 - }; - /** -

This symbol is the offset where the {@link me.wtao.widget.R.attr#allowSingleTap} - attribute's value can be found in the {@link #SlidingDrawer} array. - - -

Must be a boolean value, either "true" or "false". -

This may also be a reference to a resource (in the form -"@[package:]type:name") or -theme attribute (in the form -"?[package:][type:]name") -containing a value of this type. - @attr name me.wtao.widget:allowSingleTap - */ - public static final int SlidingDrawer_allowSingleTap = 5; - /** -

- @attr description - - Indicates whether the drawer should be opened/closed with an animation - when the user clicks the handle. Default is true. - - - -

Must be a boolean value, either "true" or "false". -

This may also be a reference to a resource (in the form -"@[package:]type:name") or -theme attribute (in the form -"?[package:][type:]name") -containing a value of this type. -

This is a private symbol. - @attr name me.wtao.widget:animateOnClick - */ - public static final int SlidingDrawer_animateOnClick = 6; - /** -

- @attr description - - Indicates whether the drawer can be opened/closed by a single tap - on the handle. (If false, the user must drag or fling, or click - using the trackball, to open/close the drawer.) Default is true. - - - -

Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp". -Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), -in (inches), mm (millimeters). -

This may also be a reference to a resource (in the form -"@[package:]type:name") or -theme attribute (in the form -"?[package:][type:]name") -containing a value of this type. -

This is a private symbol. - @attr name me.wtao.widget:collapsedOffset - */ - public static final int SlidingDrawer_collapsedOffset = 3; - /** -

- @attr description - Identifier for the child that represents the drawer's content. - - -

Must be a reference to another resource, in the form "@[+][package:]type:name" -or to a theme attribute in the form "?[package:][type:]name". -

This is a private symbol. - @attr name me.wtao.widget:content - */ - public static final int SlidingDrawer_content = 1; - /** -

This symbol is the offset where the {@link me.wtao.widget.R.attr#expandedOffset} - attribute's value can be found in the {@link #SlidingDrawer} array. - - -

Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp". -Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), -in (inches), mm (millimeters). -

This may also be a reference to a resource (in the form -"@[package:]type:name") or -theme attribute (in the form -"?[package:][type:]name") -containing a value of this type. - @attr name me.wtao.widget:expandedOffset - */ - public static final int SlidingDrawer_expandedOffset = 4; - /** -

- @attr description - Identifier for the child that represents the drawer's handle. - - -

Must be a reference to another resource, in the form "@[+][package:]type:name" -or to a theme attribute in the form "?[package:][type:]name". -

This is a private symbol. - @attr name me.wtao.widget:handle - */ - public static final int SlidingDrawer_handle = 0; - /** -

- @attr description - Orientation of the SlidingDrawer. - - -

Must be one of the following constant values.

- ---- - - - - -
ConstantValueDescription
topDown1
bottomUp2
leftToRight4
rightToLeft8
-

This is a private symbol. - @attr name me.wtao.widget:orientation - */ - public static final int SlidingDrawer_orientation = 2; - }; -} diff --git a/eclipse/v1-AospImpl/ic_launcher-web.png b/eclipse/v1-AospImpl/ic_launcher-web.png deleted file mode 100644 index cfc0eb6..0000000 Binary files a/eclipse/v1-AospImpl/ic_launcher-web.png and /dev/null differ diff --git a/eclipse/v1-AospImpl/proguard-project.txt b/eclipse/v1-AospImpl/proguard-project.txt deleted file mode 100644 index f2fe155..0000000 --- a/eclipse/v1-AospImpl/proguard-project.txt +++ /dev/null @@ -1,20 +0,0 @@ -# To enable ProGuard in your project, edit project.properties -# to define the proguard.config property as described in that file. -# -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in ${sdk.dir}/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the ProGuard -# include property in project.properties. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} diff --git a/eclipse/v1-AospImpl/project.properties b/eclipse/v1-AospImpl/project.properties deleted file mode 100644 index 0840b4a..0000000 --- a/eclipse/v1-AospImpl/project.properties +++ /dev/null @@ -1,14 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): -#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt - -# Project target. -target=android-15 diff --git a/eclipse/v1-AospImpl/res/drawable-hdpi/ic_launcher.png b/eclipse/v1-AospImpl/res/drawable-hdpi/ic_launcher.png deleted file mode 100644 index 7ae669e..0000000 Binary files a/eclipse/v1-AospImpl/res/drawable-hdpi/ic_launcher.png and /dev/null differ diff --git a/eclipse/v1-AospImpl/res/drawable-mdpi/ic_launcher.png b/eclipse/v1-AospImpl/res/drawable-mdpi/ic_launcher.png deleted file mode 100644 index 9ab91bc..0000000 Binary files a/eclipse/v1-AospImpl/res/drawable-mdpi/ic_launcher.png and /dev/null differ diff --git a/eclipse/v1-AospImpl/res/drawable-xhdpi/ic_launcher.png b/eclipse/v1-AospImpl/res/drawable-xhdpi/ic_launcher.png deleted file mode 100644 index 288bb4e..0000000 Binary files a/eclipse/v1-AospImpl/res/drawable-xhdpi/ic_launcher.png and /dev/null differ diff --git a/eclipse/v1-AospImpl/res/drawable-xxhdpi/ic_launcher.png b/eclipse/v1-AospImpl/res/drawable-xxhdpi/ic_launcher.png deleted file mode 100644 index 4cbbf0c..0000000 Binary files a/eclipse/v1-AospImpl/res/drawable-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/eclipse/v1-AospImpl/res/drawable/bk_holo_blue_light.xml b/eclipse/v1-AospImpl/res/drawable/bk_holo_blue_light.xml deleted file mode 100644 index 4e1a6f9..0000000 --- a/eclipse/v1-AospImpl/res/drawable/bk_holo_blue_light.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/eclipse/v1-AospImpl/res/drawable/bk_holo_red_light.xml b/eclipse/v1-AospImpl/res/drawable/bk_holo_red_light.xml deleted file mode 100644 index e894ff6..0000000 --- a/eclipse/v1-AospImpl/res/drawable/bk_holo_red_light.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/eclipse/v1-AospImpl/res/layout/activity_demo_1.xml b/eclipse/v1-AospImpl/res/layout/activity_demo_1.xml deleted file mode 100644 index d472539..0000000 --- a/eclipse/v1-AospImpl/res/layout/activity_demo_1.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/eclipse/v1-AospImpl/res/layout/activity_demo_2.xml b/eclipse/v1-AospImpl/res/layout/activity_demo_2.xml deleted file mode 100644 index f8d3b14..0000000 --- a/eclipse/v1-AospImpl/res/layout/activity_demo_2.xml +++ /dev/null @@ -1,183 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/eclipse/v1-AospImpl/res/layout/layout_sliding_drawer.xml b/eclipse/v1-AospImpl/res/layout/layout_sliding_drawer.xml deleted file mode 100644 index 7cb6552..0000000 --- a/eclipse/v1-AospImpl/res/layout/layout_sliding_drawer.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/eclipse/v1-AospImpl/res/menu/demo.xml b/eclipse/v1-AospImpl/res/menu/demo.xml deleted file mode 100644 index c002028..0000000 --- a/eclipse/v1-AospImpl/res/menu/demo.xml +++ /dev/null @@ -1,9 +0,0 @@ -

- - - - diff --git a/eclipse/v1-AospImpl/res/values-sw600dp/dimens.xml b/eclipse/v1-AospImpl/res/values-sw600dp/dimens.xml deleted file mode 100644 index 44f01db..0000000 --- a/eclipse/v1-AospImpl/res/values-sw600dp/dimens.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - diff --git a/eclipse/v1-AospImpl/res/values-sw720dp-land/dimens.xml b/eclipse/v1-AospImpl/res/values-sw720dp-land/dimens.xml deleted file mode 100644 index 61e3fa8..0000000 --- a/eclipse/v1-AospImpl/res/values-sw720dp-land/dimens.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - 128dp - - diff --git a/eclipse/v1-AospImpl/res/values/attrs.xml b/eclipse/v1-AospImpl/res/values/attrs.xml deleted file mode 100644 index ea91a16..0000000 --- a/eclipse/v1-AospImpl/res/values/attrs.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/eclipse/v1-AospImpl/res/values/colors.xml b/eclipse/v1-AospImpl/res/values/colors.xml deleted file mode 100644 index 8191e68..0000000 --- a/eclipse/v1-AospImpl/res/values/colors.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - #ff33b5e5 - #3e33b5e5 - - #ff99cc00 - #3e99cc00 - - #ffff4444 - #3eff4444 - - #ff0099cc - - #ff669900 - - #ffcc0000 - - #ffaa66cc - - #ffffbb33 - #3effbb33 - - #ffff8800 - - #ff00ddff - @color/holo_blue_light - - \ No newline at end of file diff --git a/eclipse/v1-AospImpl/res/values/dimens.xml b/eclipse/v1-AospImpl/res/values/dimens.xml deleted file mode 100644 index 6794b4a..0000000 --- a/eclipse/v1-AospImpl/res/values/dimens.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - 16dp - 16dp - 0dp - 1dp - 2dp - 768dp - 512dp - 128dp - 64dp - @dimen/horizontal_handle_height - @dimen/horizontal_handle_width - 64dp - 32dp - - \ No newline at end of file diff --git a/eclipse/v1-AospImpl/res/values/strings.xml b/eclipse/v1-AospImpl/res/values/strings.xml deleted file mode 100644 index f37fc41..0000000 --- a/eclipse/v1-AospImpl/res/values/strings.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - SlidingDrawer Demo - Settings - \@id/content - \@id/handle - - \ No newline at end of file diff --git a/eclipse/v1-AospImpl/src/me/wtao/utils/Logcat.java b/eclipse/v1-AospImpl/src/me/wtao/utils/Logcat.java deleted file mode 100644 index 25baad9..0000000 --- a/eclipse/v1-AospImpl/src/me/wtao/utils/Logcat.java +++ /dev/null @@ -1,189 +0,0 @@ -package me.wtao.utils; - -import android.app.Activity; -import android.app.AlertDialog; -import android.content.Context; -import android.util.Log; -import android.widget.Toast; - -/** - * Generally, use the Log.v() Log.d() Log.i() Log.w() and Log.e() methods.
- *
- * The order in terms of verbosity, from least to most is ERROR, WARN, INFO, - * DEBUG, VERBOSE. Verbose should never be compiled into an application except - * during development. Debug logs are compiled in but stripped at runtime. - * Error, warning and info logs are always kept.
- *
- * Tip: A good convention is to declare a TAG constant in your class:
- *
- * private static final String TAG = "<ClassName>";
- *
- * and use that in subsequent calls to the log methods. In other way, using - * {@link #Logcat()} to construct, it'll auto declare the TAG for you; Of course - * you can specify any TAG as you lick using {@link #Logcat(String)}. that's - * nice :)
- *
- * If you need {@link Toast} a light-weight notice when WARN and INFO, or a - * ERROR dialog, you can use the {@link #Logcat(Context)}. And if you don't want - * log no more, just {@link #setOff()}; {@link #setOn()} to re-enable the - * Logcat.
- *
- * At last, Logcat println the message you set in the format as following:
- *
- * <CallerClassName#CallerClassMethod:__LINE__> <your-message>
- *
- * f.m.
- *
- * <me.wtao.widget.SlidingDrawer#onLayout:359> entry
- *
- * which TAG is SlidingDrawer.
- * - * @author tagorewang <wtao901231@gmail.com> - * - * @see android.util.Log - */ -public class Logcat { - private static int STACK_TRACE_CALLER = 3; - - private Context mContext; - private String mTag; - private boolean mOn; - - public Logcat() { - mContext = null; - mTag = getCallerTag(); - mOn = true; - } - - public Logcat(Context context) { - mContext = context; - mTag = getCallerTag(); - mOn = true; - } - - public Logcat(String tag) { - this(null, tag); - } - - public Logcat(Context context, String tag) { - this(context, tag, true); - } - - public Logcat(Context context, String tag, boolean isLoggable) { - mContext = context; - mTag = tag; - mOn = isLoggable; - } - - public void setOn() { - mOn = true; - } - - public void setOff() { - mOn = false; - } - - public void v(Object... msg_segs) { - if (mOn) { - String msg = messageBuilder(msg_segs); - Log.v(mTag, msg); - } - } - - public void d(Object... msg_segs) { - if (mOn) { - String msg = messageBuilder(msg_segs); - Log.d(mTag, msg); - } - } - - public void i(Object... msg_segs) { - if (mOn) { - String msg = messageBuilder(msg_segs); - Log.i(mTag, msg); - - if (mContext != null) { - Toast.makeText(mContext, msg, Toast.LENGTH_SHORT).show(); - } - } - } - - public void w(Object... msg_segs) { - if (mOn) { - String msg = messageBuilder(msg_segs); - Log.w(mTag, msg); - - if (mContext != null) { - Toast.makeText(mContext, msg, Toast.LENGTH_SHORT).show(); - } - } - } - - public void e(Object... msg_segs) { - if (mOn) { - String msg = messageBuilder(msg_segs); - Log.e(mTag, msg); - - if (mContext != null) { - if (mContext instanceof Activity) { - Activity activity = (Activity) mContext; - AlertDialog.Builder builder = new AlertDialog.Builder( - activity); - builder.setTitle(mTag); - builder.setMessage(msg); - AlertDialog dialog = builder.create(); - dialog.show(); - } else { - Toast.makeText(mContext, msg, Toast.LENGTH_SHORT).show(); - } - } - - Exception e = new Exception(); - e.printStackTrace(); - } - } - - private String messageBuilder(Object... msg_segs) { - StringBuilder sb = new StringBuilder(); - - sb.append('<'); - sb.append(getCallerClassName()); - sb.append('#'); - sb.append(getCallerClassMethod()); - sb.append(':'); - sb.append(getCallerLogLine()); - sb.append("> "); - - for (Object seg : msg_segs) { - sb.append(seg); - } - - return sb.toString(); - } - - private String getCallerTag() { - final int caller = STACK_TRACE_CALLER - 1; - String callerName = new Exception().getStackTrace()[caller] - .getClassName(); - final String regEx = "[.]"; - String[] callNameSegs = callerName.split(regEx); - final int lastIndex = callNameSegs.length - 1; - - return callNameSegs[lastIndex]; - } - - private String getCallerClassName() { - return new Exception().getStackTrace()[STACK_TRACE_CALLER] - .getClassName(); - } - - private String getCallerClassMethod() { - return new Exception().getStackTrace()[STACK_TRACE_CALLER] - .getMethodName(); - } - - private int getCallerLogLine() { - return new Exception().getStackTrace()[STACK_TRACE_CALLER] - .getLineNumber(); - } -} diff --git a/eclipse/v1-AospImpl/src/me/wtao/widget/DemoActivity.java b/eclipse/v1-AospImpl/src/me/wtao/widget/DemoActivity.java deleted file mode 100644 index 9c6560e..0000000 --- a/eclipse/v1-AospImpl/src/me/wtao/widget/DemoActivity.java +++ /dev/null @@ -1,71 +0,0 @@ -package me.wtao.widget; - -import me.wtao.utils.Logcat; -import android.app.Activity; -import android.os.Bundle; -import android.view.Menu; - -public class DemoActivity extends Activity { - private Logcat mlogcat; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - mlogcat = new Logcat(); - - // requestWindowFeature(Window.FEATURE_NO_TITLE); - // getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, - // WindowManager.LayoutParams.FLAG_FULLSCREEN); - - // setContentView(R.layout.activity_demo_1); - // setContentView(R.layout.layout_sliding_drawer); - - setContentView(R.layout.activity_demo_2); - - SlidingDrawer t2b = (SlidingDrawer) findViewById(R.id.drawer_top_down); - // SlidingDrawer b2t = (SlidingDrawer) - // findViewById(R.id.drawer_bottom_up); - // SlidingDrawer l2r = (SlidingDrawer) - // findViewById(R.id.drawer_left_to_right); - // SlidingDrawer r2l = (SlidingDrawer) - // findViewById(R.id.drawer_right_to_left); - - OnDrawerScrollListener onDrawerScrollListener = new OnDrawerScrollListener(); - t2b.setOnDrawerScrollListener(onDrawerScrollListener); - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - // Inflate the menu; this adds items to the action bar if it is present. - getMenuInflater().inflate(R.menu.demo, menu); - return true; - } - - private class OnDrawerScrollListener implements - SlidingDrawer.OnDrawerScrollListener { - - @Override - public void onPreScrollStarted() { - mlogcat.d("entry"); - } - - @Override - public void onScrollStarted() { - mlogcat.d("entry"); - } - - @Override - public void onScroll(boolean willBackward) { - if (willBackward) { - mlogcat.w("willBackward ? ", true); - } - } - - @Override - public void onScrollEnded() { - mlogcat.d("entry"); - } - - } - -} diff --git a/eclipse/v1-AospImpl/src/me/wtao/widget/SlidingDrawer.java b/eclipse/v1-AospImpl/src/me/wtao/widget/SlidingDrawer.java deleted file mode 100644 index 5309f0b..0000000 --- a/eclipse/v1-AospImpl/src/me/wtao/widget/SlidingDrawer.java +++ /dev/null @@ -1,1639 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package me.wtao.widget; - -import java.util.ArrayList; - -import me.wtao.utils.Logcat; -import android.content.Context; -import android.content.res.TypedArray; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.Rect; -import android.os.Handler; -import android.os.Message; -import android.os.SystemClock; -import android.util.AttributeSet; -import android.view.MotionEvent; -import android.view.SoundEffectConstants; -import android.view.VelocityTracker; -import android.view.View; -import android.view.ViewGroup; -import android.view.accessibility.AccessibilityEvent; - -/** - * SlidingDrawer hides content out of the screen and allows the user to drag a - * handle to bring the content on screen. SlidingDrawer can be used vertically - * or horizontally.
- * - * A special widget composed of two children views: the handle, that the users - * drags, and the content, attached to the handle and dragged with it.
- * - * SlidingDrawer should be used as an overlay inside layouts. This means - * SlidingDrawer should only be used inside of a FrameLayout or a RelativeLayout - * for instance. The size of the SlidingDrawer defines how much space the - * content will occupy once slid out so SlidingDrawer should usually use - * match_parent for both its dimensions.
- * - * Inside an XML layout, SlidingDrawer must define the id of the handle and of - * the content:
- * - *
- * <SlidingDrawer
- *     android:id="@+id/drawer"
- *     android:layout_width="match_parent"
- *     android:layout_height="match_parent"
- * 
- *     android:handle="@+id/handle"
- *     android:content="@+id/content">
- * 
- *     <ImageView
- *         android:id="@id/handle"
- *         android:layout_width="88dip"
- *         android:layout_height="44dip" />
- * 
- *     <GridView
- *         android:id="@id/content"
- *         android:layout_width="match_parent"
- *         android:layout_height="match_parent" />
- * 
- * </SlidingDrawer>
- * 
- * - * @see R.styleable#SlidingDrawer_content
- * @see R.styleable#SlidingDrawer_handle
- * @see R.styleable#SlidingDrawer_topOffset
- * @see R.styleable#SlidingDrawer_bottomOffset
- * @see R.styleable#SlidingDrawer_orientation
- * @see R.styleable#SlidingDrawer_allowSingleTap
- * @see R.styleable#SlidingDrawer_animateOnClick
- * - */ - -public class SlidingDrawer extends ViewGroup { - public static final int ORIENTATION_TOP_DOWN = 0x01; - public static final int ORIENTATION_BOTTOM_UP = 0x02; - public static final int ORIENTATION_LEFT_TO_RIGHT = 0x04; - public static final int ORIENTATION_RIGHT_TO_LEFT = 0x08; - - private static Logcat sLogcat = new Logcat(); - - /** - * when moving at the end of {@link SlidingDrawer}, weather - * {@link #EXPANDED_FULL_OPEN} or {@link #COLLAPSED_FULL_CLOSED}, if the - * offset is less than the TAP_THRESHOLD ({@value #TAP_THRESHOLD} dp), the - * moving will be treat as a single tap. - * - * @see #isSingleTap() - */ - private static final int TAP_THRESHOLD = 6; - /** - * max velocity ({@value #MAXIMUM_TAP_VELOCITY}) of tap, as a comparative - * critical point in {@link #performFling(int, float, boolean)}
- * Velocity unit is one pixel per second. - * - * @see #VELOCITY_UNITS - */ - private static final float MAXIMUM_TAP_VELOCITY = 100.0f; - /** - * max value ({@value #MAXIMUM_MINOR_VELOCITY} px/s) of secondary subvector. - * in the horizontal direction it's subvector Y, while in the vertical - * direction subvector X.
- * Velocity unit is one pixel per second. - * - * @see #VELOCITY_UNITS - */ - private static final float MAXIMUM_MINOR_VELOCITY = 150.0f; - /** - * max value ({@value #MAXIMUM_MAJOR_VELOCITY} px/s) of main subvector. in - * the horizontal direction it's subvector X, while in the vertical - * direction subvector Y.
- * Velocity unit is one pixel per second. - * - * @see #VELOCITY_UNITS - */ - private static final float MAXIMUM_MAJOR_VELOCITY = 200.0f; - /** - * max value ({@value #MAXIMUM_ACCELERATION} px/s/s) of acceleration. - * Acceleration unit is one pixel per square second. - * - * @see #VELOCITY_UNITS - */ - private static final float MAXIMUM_ACCELERATION = 2000.0f; - /** - * The units you would like the velocity in. A value of 1 provides pixels - * per millisecond, 1000 provides pixels per second, etc.
- * We set VELOCITY_UNITS as {@value #VELOCITY_UNITS}, that is one pixel per - * second. - * - * @see #incrementAnimation() - * @see android.view.VelocityTracker#computeCurrentVelocity(int, float) - */ - private static final int VELOCITY_UNITS = 1000; - private static final int MSG_ANIMATE = 1000; - /** - * animation update rate is {@value #ANIMATION_FRAME_DURATION} fps - */ - private static final int ANIMATION_FRAME_DURATION = 1000 / 60; - - private static final int EXPANDED_FULL_OPEN = -10001; - private static final int COLLAPSED_FULL_CLOSED = -10002; - - private final int mHandleId; - private final int mContentId; - - private View mHandle; - private View mContent; - - private final Rect mFrame = new Rect(); - private final Rect mInvalidate = new Rect(); - private boolean mTracking; - private boolean mLocked; - - private VelocityTracker mVelocityTracker; - - private boolean mVertical; - private boolean mExpanded; - private int mCollapsedOffset; - private int mExpandedOffset; - private int mHandleHeight; - private int mHandleWidth; - - private int mOrientation; - - private OnDrawerOpenListener mOnDrawerOpenListener; - private OnDrawerCloseListener mOnDrawerCloseListener; - private OnDrawerScrollListener mOnDrawerScrollListener; - - private final Handler mHandler = new SlidingHandler(); - private float mAnimatedAcceleration; - private float mAnimatedVelocity; - private float mAnimationPosition; - private long mAnimationLastTime; - private long mCurrentAnimationTime; - private int mTouchDelta; - private int mTouchOffset; - private boolean mAnimating; - private boolean mAllowSingleTap; - private boolean mAnimateOnClick; - - /** - * ceiling of {@link android.util.DisplayMetrics.density} * - * {@link #TAP_THRESHOLD} - * - * @see #SlidingDrawer(Context, AttributeSet, int) - */ - private final int mTapThreshold; - /** - * ceiling of {@link android.util.DisplayMetrics.density} * - * {@link #MAXIMUM_TAP_VELOCITY} - * - * @see #SlidingDrawer(Context, AttributeSet, int) - */ - private final int mMaximumTapVelocity; - /** - * ceiling of {@link android.util.DisplayMetrics.density} * - * {@link #MAXIMUM_MINOR_VELOCITY} - * - * @see #SlidingDrawer(Context, AttributeSet, int) - */ - private final int mMaximumMinorVelocity; - /** - * ceiling of {@link android.util.DisplayMetrics.density} * - * {@link #MAXIMUM_MAJOR_VELOCITY} - * - * @see #SlidingDrawer(Context, AttributeSet, int) - */ - private final int mMaximumMajorVelocity; - /** - * ceiling of {@link android.util.DisplayMetrics.density} * - * {@link #MAXIMUM_ACCELERATION} - * - * @see #SlidingDrawer(Context, AttributeSet, int) - */ - private final int mMaximumAcceleration; - /** - * ceiling of {@link android.util.DisplayMetrics.density} * - * {@link #VELOCITY_UNITS} - * - * @see #SlidingDrawer(Context, AttributeSet, int) - */ - private final int mVelocityUnits; - - /** - * Callback invoked when the drawer is opened. - */ - public static interface OnDrawerOpenListener { - /** - * Invoked when the drawer becomes fully open. - */ - public void onDrawerOpened(); - } - - /** - * Callback invoked when the drawer is closed. - */ - public static interface OnDrawerCloseListener { - /** - * Invoked when the drawer becomes fully closed. - */ - public void onDrawerClosed(); - } - - /** - * Callback invoked when the drawer is scrolled. - */ - public static interface OnDrawerScrollListener { - /** - * Invoked before the user starts dragging/flinging the drawer's handle. - */ - public void onPreScrollStarted(); - - /** - * Invoked when the user starts dragging/flinging the drawer's handle. - */ - public void onScrollStarted(); - - /** - * Invoked when the user is dragging/flinging the drawer's handle. - * - * @param willBackward - * true if the user reverse dragging/flinging - */ - public void onScroll(boolean willBackward); - - /** - * Invoked when the user stops dragging/flinging the drawer's handle. - */ - public void onScrollEnded(); - } - - /** - * Creates a new SlidingDrawer from a specified set of attributes defined in - * XML. - * - * @param context - * The application's environment. - * @param attrs - * The attributes defined in XML. - */ - public SlidingDrawer(Context context, AttributeSet attrs) { - this(context, attrs, 0); - } - - /** - * Creates a new SlidingDrawer from a specified set of attributes defined in - * XML. - * - * @param context - * The application's environment. - * @param attrs - * The attributes defined in XML. - * @param defStyle - * The style to apply to this widget. - */ - public SlidingDrawer(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - - TypedArray a = context.obtainStyledAttributes(attrs, - R.styleable.SlidingDrawer, defStyle, 0); - - mOrientation = a.getInt(R.styleable.SlidingDrawer_orientation, - ORIENTATION_LEFT_TO_RIGHT); - checkOrientation(); - mVertical = (mOrientation == ORIENTATION_TOP_DOWN || mOrientation == ORIENTATION_BOTTOM_UP); - - mCollapsedOffset = (int) a.getDimension( - R.styleable.SlidingDrawer_collapsedOffset, 0.0f); - if (mCollapsedOffset < 0) { - throw new IllegalArgumentException( - "The collapsedOffset attribute should not be negative."); - } - - mExpandedOffset = (int) a.getDimension( - R.styleable.SlidingDrawer_expandedOffset, 0.0f); - if (mExpandedOffset < 0) { - throw new IllegalArgumentException( - "The expandedOffset attribute should not be negative."); - } - - mAllowSingleTap = a.getBoolean( - R.styleable.SlidingDrawer_allowSingleTap, false); - mAnimateOnClick = a.getBoolean( - R.styleable.SlidingDrawer_animateOnClick, false); - - int handleId = a.getResourceId(R.styleable.SlidingDrawer_handle, 0); - if (handleId == 0) { - throw new IllegalArgumentException( - "The handle attribute is required and must refer " - + "to a valid child."); - } - - int contentId = a.getResourceId(R.styleable.SlidingDrawer_content, 0); - if (contentId == 0) { - throw new IllegalArgumentException( - "The content attribute is required and must refer " - + "to a valid child."); - } - - if (handleId == contentId) { - throw new IllegalArgumentException( - "The content and handle attributes must refer " - + "to different children."); - } - - mHandleId = handleId; - mContentId = contentId; - - final float density = getResources().getDisplayMetrics().density; - mTapThreshold = (int) (TAP_THRESHOLD * density + 0.5f); - mMaximumTapVelocity = (int) (MAXIMUM_TAP_VELOCITY * density + 0.5f); - mMaximumMinorVelocity = (int) (MAXIMUM_MINOR_VELOCITY * density + 0.5f); - mMaximumMajorVelocity = (int) (MAXIMUM_MAJOR_VELOCITY * density + 0.5f); - mMaximumAcceleration = (int) (MAXIMUM_ACCELERATION * density + 0.5f); - mVelocityUnits = (int) (VELOCITY_UNITS * density + 0.5f); - - a.recycle(); - - setAlwaysDrawnWithCacheEnabled(false); - - sLogcat.setOn(); // TODO log switch - } - - /** - * Toggles the drawer open and close. Takes effect immediately. - * - * @see #open() - * @see #close() - * @see #animateClose() - * @see #animateOpen() - * @see #animateToggle() - */ - public void toggle() { - if (!mExpanded) { - openDrawer(); - } else { - closeDrawer(); - } - - refresh(); - } - - /** - * Toggles the drawer open and close with an animation. - * - * @see #open() - * @see #close() - * @see #animateClose() - * @see #animateOpen() - * @see #toggle() - */ - public void animateToggle() { - if (!mExpanded) { - animateOpen(); - } else { - animateClose(); - } - } - - /** - * Opens the drawer immediately. - * - * @see #toggle() - * @see #close() - * @see #animateOpen() - */ - public void open() { - openDrawer(); - - refresh(); - - sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); - } - - /** - * Closes the drawer immediately. - * - * @see #toggle() - * @see #open() - * @see #animateClose() - */ - public void close() { - closeDrawer(); - - refresh(); - } - - /** - * Closes the drawer with an animation. - * - * @see #close() - * @see #open() - * @see #animateOpen() - * @see #animateToggle() - * @see #toggle() - */ - public void animateClose() { - prepareContent(); - final OnDrawerScrollListener scrollListener = mOnDrawerScrollListener; - if (scrollListener != null) { - scrollListener.onScrollStarted(); - } - - animateClose(isVertical() ? mHandle.getTop() : mHandle.getLeft()); - - if (scrollListener != null) { - scrollListener.onScrollEnded(); - } - } - - /** - * Opens the drawer with an animation. - * - * @see #close() - * @see #open() - * @see #animateClose() - * @see #animateToggle() - * @see #toggle() - */ - public void animateOpen() { - prepareContent(); - final OnDrawerScrollListener scrollListener = mOnDrawerScrollListener; - if (scrollListener != null) { - scrollListener.onScrollStarted(); - } - - animateOpen(isVertical() ? mHandle.getTop() : mHandle.getLeft()); - - sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); - - if (scrollListener != null) { - scrollListener.onScrollEnded(); - } - } - - // /** - // * The reason for commenting out: backwards compatibility.
- // * These methods are added in API level 14. - // * - // * @author tagorewang - 2013/7/24 commented out - // */ - // @Override - // public void onInitializeAccessibilityEvent(AccessibilityEvent event) { - // super.onInitializeAccessibilityEvent(event); - // event.setClassName(SlidingDrawer.class.getName()); - // } - // - // @Override - // public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) - // { - // super.onInitializeAccessibilityNodeInfo(info); - // info.setClassName(SlidingDrawer.class.getName()); - // } - - /** - * Sets the listener that receives a notification when the drawer becomes - * open. - * - * @param onDrawerOpenListener - * The listener to be notified when the drawer is opened. - */ - public void setOnDrawerOpenListener( - OnDrawerOpenListener onDrawerOpenListener) { - mOnDrawerOpenListener = onDrawerOpenListener; - } - - /** - * Sets the listener that receives a notification when the drawer becomes - * close. - * - * @param onDrawerCloseListener - * The listener to be notified when the drawer is closed. - */ - public void setOnDrawerCloseListener( - OnDrawerCloseListener onDrawerCloseListener) { - mOnDrawerCloseListener = onDrawerCloseListener; - } - - /** - * Sets the listener that receives a notification when the drawer starts or - * ends a scroll. A fling is considered as a scroll. A fling will also - * trigger a drawer opened or drawer closed event. - * - * @param onDrawerScrollListener - * The listener to be notified when scrolling starts or stops. - */ - public void setOnDrawerScrollListener( - OnDrawerScrollListener onDrawerScrollListener) { - mOnDrawerScrollListener = onDrawerScrollListener; - } - - /** - * Returns the handle of the drawer. - * - * @return The View reprenseting the handle of the drawer, identified by the - * "handle" id in XML. - */ - public View getHandle() { - return mHandle; - } - - /** - * Returns the content of the drawer. - * - * @return The View reprenseting the content of the drawer, identified by - * the "content" id in XML. - */ - public View getContent() { - return mContent; - } - - /** - * Unlocks the SlidingDrawer so that touch events are processed. - * - * @see #lock() - */ - public void unlock() { - mLocked = false; - } - - /** - * Locks the SlidingDrawer so that touch events are ignores. - * - * @see #unlock() - */ - public void lock() { - mLocked = true; - } - - /** - * Indicates whether the drawer is currently fully opened. - * - * @return True if the drawer is opened, false otherwise. - */ - public boolean isOpened() { - return mExpanded; - } - - /** - * Indicates whether the drawer is scrolling or flinging. - * - * @return True if the drawer is scroller or flinging, false otherwise. - */ - public boolean isMoving() { - return mTracking || mAnimating; - } - - @Override - public boolean onInterceptTouchEvent(MotionEvent event) { - sLogcat.v("entry"); - - if (mLocked) { - sLogcat.v("exit: ", false, " locked"); - return false; - } - - final int action = event.getAction(); - - float x = event.getX(); - float y = event.getY(); - - final Rect frame = mFrame; - final View handle = mHandle; - - handle.getHitRect(frame); - final boolean hit = frame.contains((int) x, (int) y); - if (!mTracking && !hit) { - sLogcat.v("exit: ", false, " tracking ? ", mTracking, ", hit ? ", - hit); - return false; - } - - if (action == MotionEvent.ACTION_DOWN) { - mTracking = true; - - handle.setPressed(true); - // Must be called before prepareTracking() - prepareContent(); - - // Must be called after prepareContent() - if (mOnDrawerScrollListener != null) { - mOnDrawerScrollListener.onScrollStarted(); - } - - mTouchDelta = 0; - if (mVertical) { - final int top = mHandle.getTop(); - mTouchOffset = (int) y - top; - prepareTracking(top); - } else { - final int left = mHandle.getLeft(); - mTouchOffset = (int) x - left; - prepareTracking(left); - } - mVelocityTracker.addMovement(event); - } - - sLogcat.v("exit: ", true); - return true; - } - - private String shortFor(MotionEvent event, String... keys) { - String eventDesc = event.toString(); - String[] eventDescItems = eventDesc.substring( - eventDesc.indexOf('{') + 1, eventDesc.indexOf('}')).split( - "[, ]"); - ArrayList eventDescItemsSet = new ArrayList(); - for (String item : eventDescItems) { - eventDescItemsSet.add(item.split("[\\[=]")[0]); - } - - StringBuilder shortDesc = new StringBuilder(); - - if (keys.length == 0) { - String[] defaultInit = { "action" }; - keys = defaultInit; - } - for (int i = 0; i != keys.length; ++i) { - int idx = eventDescItemsSet.indexOf(keys[i]); - if (idx != -1) { - shortDesc.append(eventDescItems[idx]); - shortDesc.append(" "); - } - } - - return shortDesc.toString().trim(); - } - - @Override - public boolean onTouchEvent(MotionEvent event) { - sLogcat.d("entry: ", shortFor(event)); - - if (mLocked) { - sLogcat.v("exit: ", true, " locked"); - return true; - } - - sLogcat.v("tracking ? ", mTracking, ", animating ? ", mAnimating); - - if (mTracking) { - mVelocityTracker.addMovement(event); - - switch (event.getAction()) { - case MotionEvent.ACTION_MOVE: - boolean willBackward = moveHandle((int) (isVertical() ? event - .getY() : event.getX()) - mTouchOffset); - if (mOnDrawerScrollListener != null) { - mOnDrawerScrollListener.onScroll(willBackward); - } - break; // MotionEvent.ACTION_MOVE - - case MotionEvent.ACTION_UP: - case MotionEvent.ACTION_CANCEL: - // get the tap velocity, must after VelocityTracker, if don't - // want to lose some velocity tracks - final float velocity = computeVelocity(); - - // target position - int position = (isVertical() ? mHandle.getTop() : mHandle - .getLeft()); - - sLogcat.v("allowSingleTap ? ", mAllowSingleTap); - - if (Math.abs(velocity) < mMaximumTapVelocity && isSingleTap() - && mAllowSingleTap) { - sLogcat.d("single tap to fling"); - - playSoundEffect(SoundEffectConstants.CLICK); - - if (mExpanded) { - animateClose(position); - } else { - animateOpen(position); - } - } else { - sLogcat.d("drag to fling"); - - performFling(position, velocity, false); - } - break; // MotionEvent.ACTION_UP || MotionEvent.ACTION_CANCEL - } - } - - sLogcat.v("exit: didOnTouchEvent"); - return mTracking || mAnimating || super.onTouchEvent(event); - } - - @Override - protected void onFinishInflate() { - mHandle = findViewById(mHandleId); - if (mHandle == null) { - throw new IllegalArgumentException( - "The handle attribute is must refer to an" - + " existing child."); - } - if (mAnimateOnClick) { - sLogcat.v("animateOnClick ? ", true); - - mHandle.setOnClickListener(new DrawerToggler()); - } - - mContent = findViewById(mContentId); - if (mContent == null) { - throw new IllegalArgumentException( - "The content attribute is must refer to an" - + " existing child."); - } - mContent.setVisibility(View.GONE); - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - int widthSpecMode = MeasureSpec.getMode(widthMeasureSpec); - int widthSpecSize = MeasureSpec.getSize(widthMeasureSpec); - - int heightSpecMode = MeasureSpec.getMode(heightMeasureSpec); - int heightSpecSize = MeasureSpec.getSize(heightMeasureSpec); - - if (widthSpecMode == MeasureSpec.UNSPECIFIED - || heightSpecMode == MeasureSpec.UNSPECIFIED) { - throw new RuntimeException( - "SlidingDrawer cannot have UNSPECIFIED dimensions"); - } - - final View handle = mHandle; - measureChild(handle, widthMeasureSpec, heightMeasureSpec); - - if (isVertical()) { - int height = heightSpecSize - handle.getMeasuredHeight() - - mExpandedOffset; - mContent.measure(MeasureSpec.makeMeasureSpec(widthSpecSize, - MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, - MeasureSpec.EXACTLY)); - } else { - int width = widthSpecSize - handle.getMeasuredWidth() - - mExpandedOffset; - mContent.measure(MeasureSpec.makeMeasureSpec(width, - MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec( - heightSpecSize, MeasureSpec.EXACTLY)); - } - - setMeasuredDimension(widthSpecSize, heightSpecSize); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - sLogcat.v("entry"); - - final long drawingTime = getDrawingTime(); - final View handle = mHandle; - - sLogcat.v("handle visible ? ", mHandle.getVisibility() == View.VISIBLE); - - if (mHandle.getVisibility() == View.VISIBLE) { - drawChild(canvas, handle, drawingTime); - } - - sLogcat.v("tracking ? ", mTracking, ", animatin ? ", mAnimating, - ", expanded ? ", mExpanded); - - if (mTracking || mAnimating) { - final Bitmap cache = mContent.getDrawingCache(); - - sLogcat.v("cache ? ", (cache != null)); - - if (cache != null) { - switch (mOrientation) { - case ORIENTATION_TOP_DOWN: - canvas.drawBitmap(cache, 0, -mContent.getMeasuredHeight() - + handle.getTop(), null); - break; - - case ORIENTATION_BOTTOM_UP: - canvas.drawBitmap(cache, 0, handle.getBottom(), null); - break; - - case ORIENTATION_LEFT_TO_RIGHT: - canvas.drawBitmap(cache, -mContent.getMeasuredWidth() - + handle.getLeft(), 0, null); - break; - - case ORIENTATION_RIGHT_TO_LEFT: - canvas.drawBitmap(cache, handle.getRight(), 0, null); - break; - - } - } else { - canvas.save(); - - // canvas.translate (dx, dy) -> original point (x0+dx, y0+dy); - // that is, prepare for drawing in {(x0+dx, y0+dy) -> - // (x0+dx+w, y0+dy+h)} matix, where w and h may be dynamic - switch (mOrientation) { - case ORIENTATION_TOP_DOWN: - canvas.translate(0, - -mContent.getMeasuredHeight() + handle.getTop()); - break; - - case ORIENTATION_BOTTOM_UP: - canvas.translate(0, handle.getTop() - mExpandedOffset); - break; - - case ORIENTATION_LEFT_TO_RIGHT: - canvas.translate( - -mContent.getMeasuredWidth() + handle.getLeft(), 0); - break; - - case ORIENTATION_RIGHT_TO_LEFT: - canvas.translate(handle.getLeft() - mExpandedOffset, 0); - break; - - } - - drawChild(canvas, mContent, drawingTime); - - canvas.restore(); - } - } else if (mExpanded) { - drawChild(canvas, mContent, drawingTime); - } - - sLogcat.v("exit: didDispatchDraw"); - } - - @Override - protected void onLayout(boolean changed, int l, int t, int r, int b) { - sLogcat.v("entry"); - - if (mTracking) { - sLogcat.v("exit: tracking ? ", mTracking); - return; - } - - final int width = r - l; - final int height = b - t; - - final View handle = mHandle; - - int childWidth = handle.getMeasuredWidth(); - int childHeight = handle.getMeasuredHeight(); - - int childLeft = 0; - int childTop = 0; - - final View content = mContent; - - switch (mOrientation) { - case ORIENTATION_TOP_DOWN: - childLeft = (width - childWidth) / 2; - childTop = mExpanded ? height - childHeight - mExpandedOffset - : -mCollapsedOffset; - - content.layout(0, 0, content.getMeasuredWidth(), - content.getMeasuredHeight()); - break; - - case ORIENTATION_BOTTOM_UP: - childLeft = (width - childWidth) / 2; - childTop = mExpanded ? mExpandedOffset : height - childHeight - + mCollapsedOffset; - - content.layout(0, mExpandedOffset + childHeight, - content.getMeasuredWidth(), mExpandedOffset + childHeight - + content.getMeasuredHeight()); - break; - - case ORIENTATION_LEFT_TO_RIGHT: - childLeft = mExpanded ? width - childWidth - mExpandedOffset - : -mCollapsedOffset; - childTop = (height - childHeight) / 2; - - content.layout(0, 0, content.getMeasuredWidth(), - content.getMeasuredHeight()); - break; - - case ORIENTATION_RIGHT_TO_LEFT: - childLeft = mExpanded ? mExpandedOffset : width - childWidth - + mCollapsedOffset; - childTop = (height - childHeight) / 2; - - content.layout(mExpandedOffset + childWidth, 0, mExpandedOffset - + childWidth + content.getMeasuredWidth(), - content.getMeasuredHeight()); - break; - - } - - handle.layout(childLeft, childTop, childLeft + childWidth, childTop - + childHeight); - mHandleHeight = handle.getHeight(); - mHandleWidth = handle.getWidth(); - - sLogcat.v("exit: didOnLayout"); - } - - private float computeVelocity() { - final VelocityTracker velocityTracker = mVelocityTracker; - velocityTracker.computeCurrentVelocity(mVelocityUnits); - - float yVelocity = velocityTracker.getYVelocity(); - float xVelocity = velocityTracker.getXVelocity(); - boolean negative; - - final boolean vertical = isVertical(); - if (vertical) { - // in the vertical direction, the direction of the vector as - // same as subvector Y - negative = yVelocity < 0; - if (xVelocity < 0) { - xVelocity = -xVelocity; - } - if (xVelocity > mMaximumMinorVelocity) { - xVelocity = mMaximumMinorVelocity; - } - } else { - // in the horizontal direction, the direction of the vector - // as same as subvector X - negative = xVelocity < 0; - if (yVelocity < 0) { - yVelocity = -yVelocity; - } - if (yVelocity > mMaximumMinorVelocity) { - yVelocity = mMaximumMinorVelocity; - } - } - - // Vector VELOCITY has length SQRT(x^2+ y^2) - float velocity = (float) Math.hypot(xVelocity, yVelocity); - if (negative) { - velocity = -velocity; - } - - return velocity; - } - - private boolean isSingleTap() { - sLogcat.v("entry"); - - boolean ret = false; - - switch (mOrientation) { - case ORIENTATION_TOP_DOWN: - ret = (mExpanded && mHandle.getBottom() >= getTop() - getBottom() - - mExpandedOffset - mTapThreshold) - || (!mExpanded && mHandle.getTop() + mCollapsedOffset <= mTapThreshold); - break; - - case ORIENTATION_BOTTOM_UP: - ret = (mExpanded && mHandle.getTop() <= mTapThreshold - + mExpandedOffset) - || (!mExpanded && mHandle.getBottom() - mCollapsedOffset >= getBottom() - - getTop() - mTapThreshold); - break; - - case ORIENTATION_LEFT_TO_RIGHT: - ret = ((mExpanded && mHandle.getRight() >= getRight() - getLeft() - - mExpandedOffset - mTapThreshold) || (!mExpanded && mHandle - .getLeft() + mCollapsedOffset <= mTapThreshold)); - break; - - case ORIENTATION_RIGHT_TO_LEFT: - ret = ((mExpanded && mHandle.getLeft() <= mTapThreshold - + mExpandedOffset) || (!mExpanded && mHandle.getRight() - - mCollapsedOffset >= getRight() - getLeft() - - mTapThreshold)); - break; - - } - - sLogcat.v("exit: ", ret); - - return ret; - } - - private void refresh() { - invalidate(); - requestLayout(); - } - - private void animateClose(int position) { - prepareTracking(position); - switch (mOrientation) { - case ORIENTATION_TOP_DOWN: - performFling(position, -mMaximumAcceleration, true); - break; - - case ORIENTATION_BOTTOM_UP: - performFling(position, mMaximumAcceleration, true); - break; - - case ORIENTATION_LEFT_TO_RIGHT: - performFling(position, -mMaximumAcceleration, true); - break; - - case ORIENTATION_RIGHT_TO_LEFT: - performFling(position, mMaximumAcceleration, true); - break; - - } - } - - private void animateOpen(int position) { - prepareTracking(position); - switch (mOrientation) { - case ORIENTATION_TOP_DOWN: - performFling(position, mMaximumAcceleration, true); - break; - - case ORIENTATION_BOTTOM_UP: - performFling(position, -mMaximumAcceleration, true); - break; - - case ORIENTATION_LEFT_TO_RIGHT: - performFling(position, mMaximumAcceleration, true); - break; - - case ORIENTATION_RIGHT_TO_LEFT: - performFling(position, -mMaximumAcceleration, true); - break; - - } - } - - /** - * @param position - * start position - * @param velocity - * initialized velocity - * @param autoAnimated - * {@link #animateOpen()} and {@link #animateClose()} - */ - private void performFling(int position, float velocity, boolean autoAnimated) { - mAnimationPosition = position; - mAnimatedVelocity = velocity; - - final boolean invertedCoord = (mOrientation == ORIENTATION_LEFT_TO_RIGHT || mOrientation == ORIENTATION_TOP_DOWN); - final int ROLLBACK_OFFSET_THRESHOLD = (mVertical ? getHeight() - : getWidth()) / 4; - - boolean willOnFling; - boolean willRollback; - - if (mExpanded) { - // we're EXPANDED - int ROLLBACE_CRITICAL_POINT = 0; - switch (mOrientation) { - case ORIENTATION_TOP_DOWN: - ROLLBACE_CRITICAL_POINT = getBottom() - mExpandedOffset - - ROLLBACK_OFFSET_THRESHOLD; - break; - - case ORIENTATION_BOTTOM_UP: - ROLLBACE_CRITICAL_POINT = getTop() + mExpandedOffset - + ROLLBACK_OFFSET_THRESHOLD; - break; - - case ORIENTATION_LEFT_TO_RIGHT: - ROLLBACE_CRITICAL_POINT = getRight() - mExpandedOffset - - ROLLBACK_OFFSET_THRESHOLD; - break; - - case ORIENTATION_RIGHT_TO_LEFT: - ROLLBACE_CRITICAL_POINT = getLeft() + mExpandedOffset - + ROLLBACK_OFFSET_THRESHOLD; - break; - } - - if (invertedCoord) { - willOnFling = velocity < -mMaximumMajorVelocity; - willRollback = position > ROLLBACE_CRITICAL_POINT; - } else { - willOnFling = velocity > mMaximumMajorVelocity; - willRollback = position < ROLLBACE_CRITICAL_POINT; - } - - if (autoAnimated || willOnFling || !willRollback) { - // We are expanded and are now going to animate CLOSE. - if (invertedCoord) { - mAnimatedAcceleration = -mMaximumAcceleration; - if (velocity > 0) { - mAnimatedVelocity = 0; - } - } else { - mAnimatedAcceleration = mMaximumAcceleration; - if (velocity < 0) { - mAnimatedVelocity = 0; - } - } - } else { - // We are expanded, but they didn't move sufficiently to cause - // us to retract. Animate back to the expanded position. so - // animate BACK to expanded! - if (invertedCoord) { - mAnimatedAcceleration = mMaximumAcceleration; - if (velocity < 0) { - mAnimatedVelocity = 0; - } - } else { - mAnimatedAcceleration = -mMaximumAcceleration; - if (velocity > 0) { - mAnimatedVelocity = 0; - } - } - } - } else { - // we're COLLAPSED - int ROLLBACE_CRITICAL_POINT = 0; - switch (mOrientation) { - case ORIENTATION_TOP_DOWN: - ROLLBACE_CRITICAL_POINT = getTop() + ROLLBACK_OFFSET_THRESHOLD; - break; - - case ORIENTATION_BOTTOM_UP: - ROLLBACE_CRITICAL_POINT = getBottom() - - ROLLBACK_OFFSET_THRESHOLD; - break; - - case ORIENTATION_LEFT_TO_RIGHT: - ROLLBACE_CRITICAL_POINT = getLeft() + ROLLBACK_OFFSET_THRESHOLD; - break; - - case ORIENTATION_RIGHT_TO_LEFT: - ROLLBACE_CRITICAL_POINT = getRight() - - ROLLBACK_OFFSET_THRESHOLD; - break; - } - - if (!invertedCoord) { - willOnFling = velocity < -mMaximumMajorVelocity; - willRollback = position > ROLLBACE_CRITICAL_POINT; - } else { - willOnFling = velocity > mMaximumMajorVelocity; - willRollback = position < ROLLBACE_CRITICAL_POINT; - } - - if (autoAnimated || willOnFling || !willRollback) { - // We are expanded and are now going to animate OPEN. - if (!invertedCoord) { - mAnimatedAcceleration = -mMaximumAcceleration; - if (velocity > 0) { - mAnimatedVelocity = 0; - } - } else { - mAnimatedAcceleration = mMaximumAcceleration; - if (velocity < 0) { - mAnimatedVelocity = 0; - } - } - } else { - // We are expanded, but they didn't move sufficiently to cause - // us to retract. Animate back to the expanded position. so - // animate BACK to collapsed! - - if (!invertedCoord) { - mAnimatedAcceleration = mMaximumAcceleration; - if (velocity < 0) { - mAnimatedVelocity = 0; - } - } else { - - mAnimatedAcceleration = -mMaximumAcceleration; - if (velocity > 0) { - mAnimatedVelocity = 0; - } - } - } - } - - long now = SystemClock.uptimeMillis(); - mAnimationLastTime = now; - mCurrentAnimationTime = now + ANIMATION_FRAME_DURATION; - mAnimating = true; - mHandler.removeMessages(MSG_ANIMATE); - mHandler.sendMessageAtTime(mHandler.obtainMessage(MSG_ANIMATE), - mCurrentAnimationTime); - stopTracking(); - } - - private void prepareTracking(int position) { - mVelocityTracker = VelocityTracker.obtain(); - boolean opening = !mExpanded; - if (opening) { - // tap to expanded very quickly, if allow - mAnimatedAcceleration = mMaximumAcceleration; - mAnimatedVelocity = mMaximumMajorVelocity; - - // put it in its place, ready to go if given more action, f.e. - // dragging, animating or others - switch (mOrientation) { - case ORIENTATION_TOP_DOWN: - mAnimatedAcceleration = -mCollapsedOffset; - break; - - case ORIENTATION_BOTTOM_UP: - mAnimationPosition = getHeight() - mHandleHeight - + mCollapsedOffset; - break; - - case ORIENTATION_LEFT_TO_RIGHT: - mAnimationPosition = -mCollapsedOffset; - break; - - case ORIENTATION_RIGHT_TO_LEFT: - mAnimationPosition = getWidth() - mHandleWidth - + mCollapsedOffset; - break; - - } - moveHandle((int) mAnimationPosition); - - // reset animator frame time - mHandler.removeMessages(MSG_ANIMATE); - long now = SystemClock.uptimeMillis(); - mAnimationLastTime = now; - mCurrentAnimationTime = now + ANIMATION_FRAME_DURATION; - mAnimating = true; - } else { - if (mAnimating) { - mAnimating = false; - mHandler.removeMessages(MSG_ANIMATE); - } - moveHandle(position); - } - - // MUST did prepareTracking, then set true - mTracking = true; - // reset before moving, NEVER delete unless you don't moveHandle() above - mTouchDelta = 0; - } - - private boolean moveHandle(int position) { - boolean willBackward = false; - final View handle = mHandle; - - if (isVertical()) { - final int upperHalfOffset = (mOrientation == ORIENTATION_TOP_DOWN ? -mCollapsedOffset - : mExpandedOffset) - - handle.getTop(); - final int lowerHalfOffset = (mOrientation == ORIENTATION_TOP_DOWN ? -mExpandedOffset - : mCollapsedOffset) - + getBottom() - getTop() - mHandleHeight - handle.getTop(); - - if (position == EXPANDED_FULL_OPEN) { - if (mOrientation == ORIENTATION_TOP_DOWN) { - handle.offsetTopAndBottom(lowerHalfOffset); - } else { - handle.offsetTopAndBottom(upperHalfOffset); - } - invalidate(); - } else if (position == COLLAPSED_FULL_CLOSED) { - if (mOrientation == ORIENTATION_TOP_DOWN) { - handle.offsetTopAndBottom(upperHalfOffset); - } else { - handle.offsetTopAndBottom(lowerHalfOffset); - } - invalidate(); - } else { - final int top = handle.getTop(); - int deltaY = position - top; - - willBackward = (mTouchDelta * deltaY) < 0; - if (deltaY != 0) { - mTouchDelta = deltaY; - } - - // make it within the range - if (position < 0) { - // upper half offset top-and-bottom - deltaY = upperHalfOffset; - } else if (deltaY > lowerHalfOffset) { - // lower half offset top-and-bottom - deltaY = lowerHalfOffset; - } - handle.offsetTopAndBottom(deltaY); - - final Rect frame = mFrame; - final Rect region = mInvalidate; - - // invalidate handle - handle.getHitRect(frame); - region.set(frame); - region.union(frame.left, frame.top - deltaY, frame.right, - frame.bottom - deltaY); - - // invalidate content - if (mOrientation == ORIENTATION_TOP_DOWN) { - region.union(0, 0, getWidth(), frame.top - deltaY); - } else { - region.union(0, frame.bottom - deltaY, getWidth(), - frame.bottom - deltaY + mContent.getHeight()); - } - - invalidate(region); - } - } else { - final int leftHalfOffset = (mOrientation == ORIENTATION_LEFT_TO_RIGHT ? -mCollapsedOffset - : mExpandedOffset) - - handle.getLeft(); - final int rightHalfOffset = (mOrientation == ORIENTATION_LEFT_TO_RIGHT ? -mExpandedOffset - : mCollapsedOffset) - + getRight() - getLeft() - mHandleWidth - handle.getLeft(); - - if (position == EXPANDED_FULL_OPEN) { - if (mOrientation == ORIENTATION_LEFT_TO_RIGHT) { - handle.offsetLeftAndRight(rightHalfOffset); - } else { - handle.offsetLeftAndRight(leftHalfOffset); - } - invalidate(); - } else if (position == COLLAPSED_FULL_CLOSED) { - if (mOrientation == ORIENTATION_LEFT_TO_RIGHT) { - handle.offsetLeftAndRight(leftHalfOffset); - } else { - handle.offsetLeftAndRight(rightHalfOffset); - } - invalidate(); - } else { - final int left = handle.getLeft(); - int deltaX = position - left; - - willBackward = (mTouchDelta * deltaX) < 0; - if (deltaX != 0) { - mTouchDelta = deltaX; - } - - // make it within the range - if (position < 0) { - // left half offset left-and-right - deltaX = leftHalfOffset; - } else if (deltaX > rightHalfOffset) { - // right half offset left-and-right - deltaX = rightHalfOffset; - } - handle.offsetLeftAndRight(deltaX); - - final Rect frame = mFrame; - final Rect region = mInvalidate; - - // invalidate handle - handle.getHitRect(frame); - region.set(frame); - region.union(frame.left - deltaX, frame.top, frame.right - - deltaX, frame.bottom); - - // invalidate content - if (mOrientation == ORIENTATION_LEFT_TO_RIGHT) { - region.union(0, 0, frame.left - deltaX, getHeight()); - } else { - region.union(frame.right - deltaX, 0, frame.right - deltaX - + mContent.getWidth(), getHeight()); - } - - invalidate(region); - } - } - - if (willBackward) { - sLogcat.w("exit: willBackward ? ", true); - } - return willBackward; - } - - private void prepareContent() { - sLogcat.v("entry"); - - if (mAnimating) { - sLogcat.v("exit: animating ? ", false); - return; - } - - if (mOnDrawerScrollListener != null) { - mOnDrawerScrollListener.onPreScrollStarted(); - } - - // Something changed in the content, we need to honor the layout request - // before creating the cached bitmap - final View content = mContent; - if (content.isLayoutRequested()) { - if (isVertical()) { - final int childHeight = mHandleHeight; - int height = getBottom() - getTop() - childHeight - - mExpandedOffset; - content.measure(MeasureSpec.makeMeasureSpec(getRight() - - getLeft(), MeasureSpec.EXACTLY), MeasureSpec - .makeMeasureSpec(height, MeasureSpec.EXACTLY)); - if (mOrientation == ORIENTATION_TOP_DOWN) { - content.layout(0, 0, content.getMeasuredWidth(), - content.getMeasuredHeight()); - } else { - content.layout(0, mExpandedOffset + childHeight, - content.getMeasuredWidth(), mExpandedOffset - + childHeight + content.getMeasuredHeight()); - } - } else { - final int childWidth = mHandle.getWidth(); - int width = getRight() - getLeft() - childWidth - - mExpandedOffset; - content.measure(MeasureSpec.makeMeasureSpec(width, - MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec( - getBottom() - getTop(), MeasureSpec.EXACTLY)); - if (mOrientation == ORIENTATION_LEFT_TO_RIGHT) { - content.layout(0, 0, content.getMeasuredWidth(), - content.getMeasuredHeight()); - } else { - content.layout( - childWidth + mExpandedOffset, - 0, - mExpandedOffset + childWidth - + content.getMeasuredWidth(), - content.getMeasuredHeight()); - } - } - } - // Try only once... we should really loop but it's not a big deal - // if the draw was cancelled, it will only be temporary anyway - content.getViewTreeObserver().dispatchOnPreDraw(); - - // Creating the cached bitmap - if (!content.isHardwareAccelerated()) { - content.buildDrawingCache(); - } - - content.setVisibility(View.GONE); - - sLogcat.v("exit: didPrepareContent"); - } - - private void stopTracking() { - mHandle.setPressed(false); - mTracking = false; - - if (mOnDrawerScrollListener != null) { - mOnDrawerScrollListener.onScrollEnded(); - } - - if (mVelocityTracker != null) { - mVelocityTracker.recycle(); - mVelocityTracker = null; - } - } - - private void doAnimation() { - boolean willOpen = false; - boolean willClose = false; - - if (mAnimating) { - incrementAnimation(); - - switch (mOrientation) { - case ORIENTATION_TOP_DOWN: - willOpen = (mAnimationPosition >= (getHeight() - - mExpandedOffset - 1)); - willClose = (mAnimationPosition < -mCollapsedOffset); - break; - - case ORIENTATION_BOTTOM_UP: - willOpen = (mAnimationPosition < mExpandedOffset); - willClose = (mAnimationPosition >= (getHeight() - + mCollapsedOffset - 1)); - break; - - case ORIENTATION_LEFT_TO_RIGHT: - willOpen = (mAnimationPosition >= (getWidth() - mExpandedOffset - 1)); - willClose = (mAnimationPosition < -mCollapsedOffset); - break; - - case ORIENTATION_RIGHT_TO_LEFT: - willOpen = (mAnimationPosition < mExpandedOffset); - willClose = (mAnimationPosition >= (getWidth() - + mCollapsedOffset - 1)); - break; - - } - - if (willOpen) { - mAnimating = false; - openDrawer(); - } else if (willClose) { - mAnimating = false; - closeDrawer(); - } else { - moveHandle((int) mAnimationPosition); - mCurrentAnimationTime += ANIMATION_FRAME_DURATION; - mHandler.sendMessageAtTime(mHandler.obtainMessage(MSG_ANIMATE), - mCurrentAnimationTime); - } - } - } - - private void incrementAnimation() { - long now = SystemClock.uptimeMillis(); - float t = (now - mAnimationLastTime) / 1000.0f; // ms -> s - final float position = mAnimationPosition; - final float v = mAnimatedVelocity; // px/s - final float a = mAnimatedAcceleration; // px/s/s - mAnimationPosition = position + (v * t) + (0.5f * a * t * t); // px - mAnimatedVelocity = v + (a * t); // px/s - mAnimationLastTime = now; // ms - } - - private void closeDrawer() { - moveHandle(COLLAPSED_FULL_CLOSED); - mContent.setVisibility(View.GONE); - mContent.destroyDrawingCache(); - - if (!mExpanded) { - return; - } - - mExpanded = false; - if (mOnDrawerCloseListener != null) { - mOnDrawerCloseListener.onDrawerClosed(); - } - } - - private void openDrawer() { - moveHandle(EXPANDED_FULL_OPEN); - mContent.setVisibility(View.VISIBLE); - - if (mExpanded) { - return; - } - - mExpanded = true; - - if (mOnDrawerOpenListener != null) { - mOnDrawerOpenListener.onDrawerOpened(); - } - } - - private boolean isVertical() { - return mVertical; - } - - // private boolean isHorizontal() { - // return !isVertical(); - // } - - private void checkOrientation() { - String bits = Integer.toBinaryString(mOrientation); - boolean isValidLen = (bits.length() <= 4); - boolean isValidFlagBit = false; - if (isValidLen) { - final String rgEx = "0"; - isValidFlagBit = (bits.split(rgEx).length == 1); - } - if (!(isValidLen && isValidFlagBit)) { - throw new IllegalArgumentException( - "The orientation attribute is required, or the assigned orientation is undefined."); - } - - } - - private class DrawerToggler implements OnClickListener { - public void onClick(View v) { - sLogcat.d("entry"); - - if (mLocked) { - sLogcat.v("exit: locked ? ", true); - return; - } - // mAllowSingleTap isn't relevant here; you're *always* - // allowed to open/close the drawer by clicking with the - // trackball. - - if (mAnimateOnClick) { - animateToggle(); - } else { - toggle(); - } - - sLogcat.v("exit: didOnClick"); - } - } - - private class SlidingHandler extends Handler { - public void handleMessage(Message m) { - switch (m.what) { - case MSG_ANIMATE: - doAnimation(); - break; - } - } - } - -} diff --git a/eclipse/v2-AnimatorImpl/.classpath b/eclipse/v2-AnimatorImpl/.classpath deleted file mode 100644 index 7bc01d9..0000000 --- a/eclipse/v2-AnimatorImpl/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/eclipse/v2-AnimatorImpl/.project b/eclipse/v2-AnimatorImpl/.project deleted file mode 100644 index 5890b77..0000000 --- a/eclipse/v2-AnimatorImpl/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - SlidingDrawerWidget - - - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - diff --git a/eclipse/v2-AnimatorImpl/gen/android/support/widget/BuildConfig.java b/eclipse/v2-AnimatorImpl/gen/android/support/widget/BuildConfig.java deleted file mode 100644 index ce5644e..0000000 --- a/eclipse/v2-AnimatorImpl/gen/android/support/widget/BuildConfig.java +++ /dev/null @@ -1,6 +0,0 @@ -/** Automatically generated file. DO NOT MODIFY */ -package android.support.widget; - -public final class BuildConfig { - public final static boolean DEBUG = true; -} \ No newline at end of file diff --git a/eclipse/v2-AnimatorImpl/gen/android/support/widget/R.java b/eclipse/v2-AnimatorImpl/gen/android/support/widget/R.java deleted file mode 100644 index a5e196f..0000000 --- a/eclipse/v2-AnimatorImpl/gen/android/support/widget/R.java +++ /dev/null @@ -1,250 +0,0 @@ -/* AUTO-GENERATED FILE. DO NOT MODIFY. - * - * This class was automatically generated by the - * aapt tool from the resource data it found. It - * should not be modified by hand. - */ - -package android.support.widget; - -public final class R { - public static final class attr { - /** - Indicates whether the drawer can be opened/closed by a single tap - on the handle. (If false, the user must drag or fling, or click - using the trackball, to open/close the drawer.) Default is true. - - -

Must be a boolean value, either "true" or "false". -

This may also be a reference to a resource (in the form -"@[package:]type:name") or -theme attribute (in the form -"?[package:][type:]name") -containing a value of this type. - */ - public static final int allowSingleTap=0x7f010003; - /** - Indicates whether the drawer should be opened/closed with an animation - when the user clicks the handle. Default is true. - -

Must be a boolean value, either "true" or "false". -

This may also be a reference to a resource (in the form -"@[package:]type:name") or -theme attribute (in the form -"?[package:][type:]name") -containing a value of this type. - */ - public static final int animateOnClick=0x7f010004; - /** Identifier for the child that represents the drawer's content. -

Must be a reference to another resource, in the form "@[+][package:]type:name" -or to a theme attribute in the form "?[package:][type:]name". - */ - public static final int content=0x7f010001; - /** Identifier for the child that represents the drawer's handle. -

Must be a reference to another resource, in the form "@[+][package:]type:name" -or to a theme attribute in the form "?[package:][type:]name". - */ - public static final int handle=0x7f010000; - /** Orientation of the SlidingDrawer. -

Must be one of the following constant values.

- ---- - - - - -
ConstantValueDescription
topDown1
bottomUp2
leftToRight4
rightToLeft8
- */ - public static final int orientation=0x7f010002; - /**

May be a reference to another resource, in the form "@[+][package:]type:name" -or to a theme attribute in the form "?[package:][type:]name". -

May be a color value, in the form of "#rgb", "#argb", -"#rrggbb", or "#aarrggbb". - */ - public static final int tensionTween=0x7f010005; - } - public static final class drawable { - public static final int ic_launcher=0x7f020000; - } - public static final class id { - public static final int bottomUp=0x7f060000; - public static final int content1=0x7f060004; - public static final int content2=0x7f060006; - public static final int content3=0x7f060008; - public static final int content4=0x7f06000a; - public static final int handle1=0x7f060005; - public static final int handle2=0x7f060007; - public static final int handle3=0x7f060009; - public static final int handle4=0x7f06000b; - public static final int leftToRight=0x7f060001; - public static final int rightToLeft=0x7f060002; - public static final int topDown=0x7f060003; - } - public static final class layout { - public static final int sliding_drawer_activity_layout=0x7f030000; - } - public static final class string { - public static final int app_name=0x7f040000; - } - public static final class style { - /** - Base application theme, dependent on API level. This theme is replaced - by AppBaseTheme from res/values-vXX/styles.xml on newer devices. - - - Theme customizations available in newer API levels can go in - res/values-vXX/styles.xml, while customizations related to - backward-compatibility can go here. - - - Base application theme for API 11+. This theme completely replaces - AppBaseTheme from res/values/styles.xml on API 11+ devices. - - API 11 theme customizations can go here. - - Base application theme for API 14+. This theme completely replaces - AppBaseTheme from BOTH res/values/styles.xml and - res/values-v11/styles.xml on API 14+ devices. - - API 14 theme customizations can go here. - */ - public static final int AppBaseTheme=0x7f050000; - /** Application theme. - All customizations that are NOT specific to a particular API-level can go here. - */ - public static final int AppTheme=0x7f050001; - } - public static final class styleable { - /** - SlidingDrawer specific attributes. These attributes are used to configure - a SlidingDrawer from XML. - -

Includes the following attributes:

- - - - - - - - - - -
AttributeDescription
{@link #SlidingDrawer_allowSingleTap android.support.widget:allowSingleTap} - Indicates whether the drawer can be opened/closed by a single tap - on the handle.
{@link #SlidingDrawer_animateOnClick android.support.widget:animateOnClick} - Indicates whether the drawer should be opened/closed with an animation - when the user clicks the handle.
{@link #SlidingDrawer_content android.support.widget:content} Identifier for the child that represents the drawer's content.
{@link #SlidingDrawer_handle android.support.widget:handle} Identifier for the child that represents the drawer's handle.
{@link #SlidingDrawer_orientation android.support.widget:orientation} Orientation of the SlidingDrawer.
{@link #SlidingDrawer_tensionTween android.support.widget:tensionTween}
- @see #SlidingDrawer_allowSingleTap - @see #SlidingDrawer_animateOnClick - @see #SlidingDrawer_content - @see #SlidingDrawer_handle - @see #SlidingDrawer_orientation - @see #SlidingDrawer_tensionTween - */ - public static final int[] SlidingDrawer = { - 0x7f010000, 0x7f010001, 0x7f010002, 0x7f010003, - 0x7f010004, 0x7f010005 - }; - /** -

- @attr description - - Indicates whether the drawer can be opened/closed by a single tap - on the handle. (If false, the user must drag or fling, or click - using the trackball, to open/close the drawer.) Default is true. - - - - -

Must be a boolean value, either "true" or "false". -

This may also be a reference to a resource (in the form -"@[package:]type:name") or -theme attribute (in the form -"?[package:][type:]name") -containing a value of this type. -

This is a private symbol. - @attr name android.support.widget:allowSingleTap - */ - public static final int SlidingDrawer_allowSingleTap = 3; - /** -

- @attr description - - Indicates whether the drawer should be opened/closed with an animation - when the user clicks the handle. Default is true. - - - -

Must be a boolean value, either "true" or "false". -

This may also be a reference to a resource (in the form -"@[package:]type:name") or -theme attribute (in the form -"?[package:][type:]name") -containing a value of this type. -

This is a private symbol. - @attr name android.support.widget:animateOnClick - */ - public static final int SlidingDrawer_animateOnClick = 4; - /** -

- @attr description - Identifier for the child that represents the drawer's content. - - -

Must be a reference to another resource, in the form "@[+][package:]type:name" -or to a theme attribute in the form "?[package:][type:]name". -

This is a private symbol. - @attr name android.support.widget:content - */ - public static final int SlidingDrawer_content = 1; - /** -

- @attr description - Identifier for the child that represents the drawer's handle. - - -

Must be a reference to another resource, in the form "@[+][package:]type:name" -or to a theme attribute in the form "?[package:][type:]name". -

This is a private symbol. - @attr name android.support.widget:handle - */ - public static final int SlidingDrawer_handle = 0; - /** -

- @attr description - Orientation of the SlidingDrawer. - - -

Must be one of the following constant values.

- ---- - - - - -
ConstantValueDescription
topDown1
bottomUp2
leftToRight4
rightToLeft8
-

This is a private symbol. - @attr name android.support.widget:orientation - */ - public static final int SlidingDrawer_orientation = 2; - /** -

This symbol is the offset where the {@link android.support.widget.R.attr#tensionTween} - attribute's value can be found in the {@link #SlidingDrawer} array. - - -

May be a reference to another resource, in the form "@[+][package:]type:name" -or to a theme attribute in the form "?[package:][type:]name". -

May be a color value, in the form of "#rgb", "#argb", -"#rrggbb", or "#aarrggbb". - @attr name android.support.widget:tensionTween - */ - public static final int SlidingDrawer_tensionTween = 5; - }; -} diff --git a/eclipse/v2-AnimatorImpl/libs/android-support-v4.jar b/eclipse/v2-AnimatorImpl/libs/android-support-v4.jar deleted file mode 100644 index bd450c7..0000000 Binary files a/eclipse/v2-AnimatorImpl/libs/android-support-v4.jar and /dev/null differ diff --git a/eclipse/v2-AnimatorImpl/libs/framework.jar b/eclipse/v2-AnimatorImpl/libs/framework.jar deleted file mode 100644 index 7242f27..0000000 Binary files a/eclipse/v2-AnimatorImpl/libs/framework.jar and /dev/null differ diff --git a/eclipse/v2-AnimatorImpl/libs/nineoldandroids.jar b/eclipse/v2-AnimatorImpl/libs/nineoldandroids.jar deleted file mode 100644 index 4d8d4a9..0000000 Binary files a/eclipse/v2-AnimatorImpl/libs/nineoldandroids.jar and /dev/null differ diff --git a/eclipse/v2-AnimatorImpl/proguard-project.txt b/eclipse/v2-AnimatorImpl/proguard-project.txt deleted file mode 100644 index f2fe155..0000000 --- a/eclipse/v2-AnimatorImpl/proguard-project.txt +++ /dev/null @@ -1,20 +0,0 @@ -# To enable ProGuard in your project, edit project.properties -# to define the proguard.config property as described in that file. -# -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in ${sdk.dir}/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the ProGuard -# include property in project.properties. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} diff --git a/eclipse/v2-AnimatorImpl/project.properties b/eclipse/v2-AnimatorImpl/project.properties deleted file mode 100644 index 4ab1256..0000000 --- a/eclipse/v2-AnimatorImpl/project.properties +++ /dev/null @@ -1,14 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): -#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt - -# Project target. -target=android-19 diff --git a/eclipse/v2-AnimatorImpl/res/layout/sliding_drawer_activity_layout.xml b/eclipse/v2-AnimatorImpl/res/layout/sliding_drawer_activity_layout.xml deleted file mode 100644 index 4afb3c4..0000000 --- a/eclipse/v2-AnimatorImpl/res/layout/sliding_drawer_activity_layout.xml +++ /dev/null @@ -1,135 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/eclipse/v2-AnimatorImpl/res/values-v11/styles.xml b/eclipse/v2-AnimatorImpl/res/values-v11/styles.xml deleted file mode 100644 index 3c02242..0000000 --- a/eclipse/v2-AnimatorImpl/res/values-v11/styles.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - diff --git a/eclipse/v2-AnimatorImpl/res/values-v14/styles.xml b/eclipse/v2-AnimatorImpl/res/values-v14/styles.xml deleted file mode 100644 index a91fd03..0000000 --- a/eclipse/v2-AnimatorImpl/res/values-v14/styles.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - diff --git a/eclipse/v2-AnimatorImpl/res/values/strings.xml b/eclipse/v2-AnimatorImpl/res/values/strings.xml deleted file mode 100644 index e307827..0000000 --- a/eclipse/v2-AnimatorImpl/res/values/strings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - SlidingDrawerWidget - - diff --git a/eclipse/v2-AnimatorImpl/res/values/styles.xml b/eclipse/v2-AnimatorImpl/res/values/styles.xml deleted file mode 100644 index 6ce89c7..0000000 --- a/eclipse/v2-AnimatorImpl/res/values/styles.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..7a3265e Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..efc27cb --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Sat Jan 13 09:12:34 PST 2018 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-all.zip diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..cccdd3d --- /dev/null +++ b/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..f955316 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/library/.gitignore b/library/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/library/.gitignore @@ -0,0 +1 @@ +/build diff --git a/library/build.gradle b/library/build.gradle new file mode 100644 index 0000000..c3f98a4 --- /dev/null +++ b/library/build.gradle @@ -0,0 +1,16 @@ +apply plugin: 'com.android.library' + +android { + compileSdkVersion 27 + + defaultConfig { + minSdkVersion 14 + targetSdkVersion 27 + versionCode 1 + versionName "1.0" + } +} + +dependencies { + implementation 'com.nineoldandroids:library:2.4.0' +} diff --git a/library/proguard-rules.pro b/library/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/library/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml new file mode 100644 index 0000000..0533332 --- /dev/null +++ b/library/src/main/AndroidManifest.xml @@ -0,0 +1 @@ + diff --git a/eclipse/v2-AnimatorImpl/src/android/support/widget/SlidingDrawer.java b/library/src/main/java/android/support/widget/SlidingDrawer.java similarity index 98% rename from eclipse/v2-AnimatorImpl/src/android/support/widget/SlidingDrawer.java rename to library/src/main/java/android/support/widget/SlidingDrawer.java index 3a54d2a..5c0fa31 100644 --- a/eclipse/v2-AnimatorImpl/src/android/support/widget/SlidingDrawer.java +++ b/library/src/main/java/android/support/widget/SlidingDrawer.java @@ -1,7 +1,5 @@ package android.support.widget; -import java.lang.ref.WeakReference; - import android.annotation.SuppressLint; import android.content.Context; import android.content.res.TypedArray; @@ -20,6 +18,8 @@ import com.nineoldandroids.animation.ObjectAnimator; import com.nineoldandroids.view.ViewHelper; +import java.lang.ref.WeakReference; + @SuppressLint("NewApi") public class SlidingDrawer extends RelativeLayout implements OnTouchListener, AnimatorListener { @@ -132,7 +132,7 @@ public SlidingDrawer(Context context, AttributeSet attrs, int defStyleAttr) { * defaults. */ public SlidingDrawer(Context context, AttributeSet attrs, int defStyleAttr, - int defStyleRes) { + int defStyleRes) { super(context, attrs); final TypedArray a = context.obtainStyledAttributes(attrs, @@ -172,6 +172,7 @@ public SlidingDrawer(Context context, AttributeSet attrs, int defStyleAttr, @Override protected void onFinishInflate() { + super.onFinishInflate(); mHandle = findViewById(mHandleId); if (mHandle == null) { throw new IllegalArgumentException( @@ -193,8 +194,8 @@ public void onClick(View v) { throw new IllegalArgumentException( "The content attribute is must refer to an existing child."); } - - + + } @Override @@ -285,11 +286,11 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) { private void adjustLayoutMargin() { ViewGroup.LayoutParams lp = getLayoutParams(); - if(null == lp || !(lp instanceof ViewGroup.MarginLayoutParams)) { + if(null == lp || !(lp instanceof MarginLayoutParams)) { return; } - - ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) lp; + + MarginLayoutParams mlp = (MarginLayoutParams) lp; if(isHorizontal()) { if(ORIENTATION_RIGHT_TO_LEFT == mOrientation) { mlp.rightMargin = 0; diff --git a/eclipse/v2-AnimatorImpl/res/values/attrs_SlidingDrawer.xml b/library/src/main/res/values/attrs.xml similarity index 100% rename from eclipse/v2-AnimatorImpl/res/values/attrs_SlidingDrawer.xml rename to library/src/main/res/values/attrs.xml diff --git a/sample-app/build.gradle b/sample-app/build.gradle new file mode 100644 index 0000000..569a939 --- /dev/null +++ b/sample-app/build.gradle @@ -0,0 +1,17 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 27 + buildToolsVersion "27.0.3" + + defaultConfig { + applicationId "android.support.widget" + minSdkVersion 14 + targetSdkVersion 27 + } +} + +dependencies { + implementation project(':library') + implementation 'com.android.support:support-v4:27.1.1' +} diff --git a/eclipse/v2-AnimatorImpl/AndroidManifest.xml b/sample-app/src/main/AndroidManifest.xml similarity index 64% rename from eclipse/v2-AnimatorImpl/AndroidManifest.xml rename to sample-app/src/main/AndroidManifest.xml index e9b10fd..79be7c6 100644 --- a/eclipse/v2-AnimatorImpl/AndroidManifest.xml +++ b/sample-app/src/main/AndroidManifest.xml @@ -1,18 +1,12 @@ - - + package="android.support.widget"> - + android:theme="@style/AppTheme"> + diff --git a/eclipse/v2-AnimatorImpl/src/android/demo/SlidingDrawerActivity.java b/sample-app/src/main/java/android/support/widget/MainActivity.java similarity index 50% rename from eclipse/v2-AnimatorImpl/src/android/demo/SlidingDrawerActivity.java rename to sample-app/src/main/java/android/support/widget/MainActivity.java index 353c40f..d8db4ee 100644 --- a/eclipse/v2-AnimatorImpl/src/android/demo/SlidingDrawerActivity.java +++ b/sample-app/src/main/java/android/support/widget/MainActivity.java @@ -1,15 +1,14 @@ -package android.demo; +package android.support.widget; import android.app.Activity; import android.os.Bundle; -import android.support.widget.R; -public class SlidingDrawerActivity extends Activity { +public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.sliding_drawer_activity_layout); + setContentView(R.layout.main_activity); } } diff --git a/eclipse/v2-AnimatorImpl/res/drawable-hdpi/ic_launcher.png b/sample-app/src/main/res/drawable-hdpi/ic_launcher.png similarity index 100% rename from eclipse/v2-AnimatorImpl/res/drawable-hdpi/ic_launcher.png rename to sample-app/src/main/res/drawable-hdpi/ic_launcher.png diff --git a/eclipse/v2-AnimatorImpl/res/drawable-mdpi/ic_launcher.png b/sample-app/src/main/res/drawable-mdpi/ic_launcher.png similarity index 100% rename from eclipse/v2-AnimatorImpl/res/drawable-mdpi/ic_launcher.png rename to sample-app/src/main/res/drawable-mdpi/ic_launcher.png diff --git a/eclipse/v2-AnimatorImpl/res/drawable-xhdpi/ic_launcher.png b/sample-app/src/main/res/drawable-xhdpi/ic_launcher.png similarity index 100% rename from eclipse/v2-AnimatorImpl/res/drawable-xhdpi/ic_launcher.png rename to sample-app/src/main/res/drawable-xhdpi/ic_launcher.png diff --git a/sample-app/src/main/res/layout/main_activity.xml b/sample-app/src/main/res/layout/main_activity.xml new file mode 100644 index 0000000..6958b13 --- /dev/null +++ b/sample-app/src/main/res/layout/main_activity.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/eclipse/v1-AospImpl/res/values-v11/styles.xml b/sample-app/src/main/res/values-v11/styles.xml similarity index 100% rename from eclipse/v1-AospImpl/res/values-v11/styles.xml rename to sample-app/src/main/res/values-v11/styles.xml diff --git a/eclipse/v1-AospImpl/res/values-v14/styles.xml b/sample-app/src/main/res/values-v14/styles.xml similarity index 100% rename from eclipse/v1-AospImpl/res/values-v14/styles.xml rename to sample-app/src/main/res/values-v14/styles.xml diff --git a/sample-app/src/main/res/values/strings.xml b/sample-app/src/main/res/values/strings.xml new file mode 100644 index 0000000..a59ac25 --- /dev/null +++ b/sample-app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + Sliding Drawer + diff --git a/eclipse/v1-AospImpl/res/values/styles.xml b/sample-app/src/main/res/values/styles.xml similarity index 100% rename from eclipse/v1-AospImpl/res/values/styles.xml rename to sample-app/src/main/res/values/styles.xml diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..41a59c8 --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +include ':sample-app', ':library'