Repository: avenwu/support Branch: master Commit: b566821c29f8 Files: 170 Total size: 339.0 KB Directory structure: gitextract_cenee9ug/ ├── .gitignore ├── LICENSE ├── README.md ├── build.gradle ├── gradle/ │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew ├── gradlew.bat ├── sample/ │ ├── .gitignore │ ├── build.gradle │ ├── libs/ │ │ ├── AnnotationProcessorTest.jar │ │ └── markdown4j-2.2.jar │ ├── proguard-rules.pro │ └── src/ │ ├── androidTest/ │ │ └── java/ │ │ └── com/ │ │ └── avenwu/ │ │ └── deepinandroid/ │ │ └── ApplicationTest.java │ └── main/ │ ├── AndroidManifest.xml │ ├── assets/ │ │ └── github-markdown.css │ ├── java/ │ │ └── com/ │ │ └── avenwu/ │ │ └── deepinandroid/ │ │ ├── AnimatedSubActivity.java │ │ ├── BitmapShaderFragment.java │ │ ├── BreathLightViewDemo.java │ │ ├── BusEventDemo.java │ │ ├── CameraMatrixFragmentDemo.java │ │ ├── ColorFilterDemo.java │ │ ├── Content.java │ │ ├── CurtainLayoutFragment.java │ │ ├── CustomDrawableDemo.java │ │ ├── CustomProgressActivity.java │ │ ├── CustomTabActivity.java │ │ ├── CustomTextViewActivity.java │ │ ├── DrawerDemoFragment.java │ │ ├── ExifViewerFragment.java │ │ ├── FeatureActivity.java │ │ ├── FlipFragmentDemo.java │ │ ├── GradientColorFragment.java │ │ ├── LargeHeightImageDisplayFragment.java │ │ ├── LinearGradientView.java │ │ ├── MainActivity.java │ │ ├── MarkdownDemo.java │ │ ├── QQDraggingCircleDemo.java │ │ ├── RefreshDemoFragment.java │ │ ├── RefreshWidgetActivity.java │ │ ├── ScaleSubActivity.java │ │ ├── ShortcutDemo.java │ │ ├── SlideMenuFragment.java │ │ ├── SlidePanelDemo.java │ │ ├── StackZFragment.java │ │ ├── StyledRadioButtonDemo.java │ │ ├── TagInputDemo.java │ │ ├── TypefaceActivity.java │ │ ├── WindowAnimationFragment.java │ │ ├── eventbus/ │ │ │ ├── Bus.java │ │ │ ├── Finder.java │ │ │ ├── NameBasedFinder.java │ │ │ ├── PostHandler.java │ │ │ └── Subscriber.java │ │ └── util/ │ │ ├── SystemUiHider.java │ │ ├── SystemUiHiderBase.java │ │ └── SystemUiHiderHoneycomb.java │ └── res/ │ ├── anim/ │ │ ├── scale_up_left.xml │ │ ├── scale_up_rightt.xml │ │ ├── slide_in_left.xml │ │ ├── slide_in_right.xml │ │ ├── slide_out_left.xml │ │ └── slide_out_right.xml │ ├── color/ │ │ ├── radio_button_color.xml │ │ ├── radio_button_color_blue.xml │ │ ├── radio_button_color_green.xml │ │ ├── radio_button_color_light_blue.xml │ │ ├── radio_button_color_orange.xml │ │ └── radio_button_color_purple.xml │ ├── drawable/ │ │ ├── animate_drawable.xml │ │ ├── flat_round_shape_left.xml │ │ ├── flat_round_shape_middle.xml │ │ └── flat_round_shape_right.xml │ ├── layout/ │ │ ├── activity_main.xml │ │ ├── activity_markdown_demo.xml │ │ ├── activity_my.xml │ │ ├── activity_progress_layout.xml │ │ ├── activity_refresh_widget.xml │ │ ├── activity_typeface.xml │ │ ├── activity_window_anim_sub.xml │ │ ├── activity_window_scale_sub.xml │ │ ├── animation_layout.xml │ │ ├── bitmap_shader_layout.xml │ │ ├── breath_light_layout.xml │ │ ├── camera_matrix_layout.xml │ │ ├── chat_layout.xml │ │ ├── curtain_demo.xml │ │ ├── custom_drawable_layout.xml │ │ ├── custom_tab_activity.xml │ │ ├── eventbus_layout.xml │ │ ├── exif_layout.xml │ │ ├── feature_item_layout.xml │ │ ├── feature_layout.xml │ │ ├── filter_layout.xml │ │ ├── flip_layout.xml │ │ ├── fragment_stack_z.xml │ │ ├── fragment_tab_host.xml │ │ ├── fragment_tab_item.xml │ │ ├── gradient_layout.xml │ │ ├── markdown_edit.xml │ │ ├── qq_dragging_circle_layout.xml │ │ ├── ripple_layout.xml │ │ ├── shorcut_layout.xml │ │ ├── slide_layout.xml │ │ ├── slidepanel_layout.xml │ │ ├── styled_radio_button.xml │ │ ├── tag_item.xml │ │ ├── test_tag_input_layout.xml │ │ └── textview_layout.xml │ ├── menu/ │ │ ├── markdown_menu.xml │ │ ├── menu_main.xml │ │ └── menu_typeface.xml │ ├── values/ │ │ ├── arrays.xml │ │ ├── attrs.xml │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ ├── values-v11/ │ │ └── styles.xml │ ├── values-w820dp/ │ │ └── dimens.xml │ └── values-zh/ │ └── strings.xml ├── settings.gradle └── support/ ├── .gitignore ├── build.gradle ├── custom_mvn_push.gradle ├── proguard-rules.pro └── src/ ├── androidTest/ │ └── java/ │ └── net/ │ └── avenwu/ │ └── support/ │ └── ApplicationTest.java └── main/ ├── AndroidManifest.xml ├── java/ │ └── net/ │ └── avenwu/ │ └── support/ │ ├── presenter/ │ │ ├── Presenter.java │ │ ├── PresenterActivity.java │ │ └── PresenterFragment.java │ ├── protocol/ │ │ ├── RenderAction.java │ │ └── UIAction.java │ ├── util/ │ │ ├── BitmapUtil.java │ │ ├── ChartSet.java │ │ ├── Device.java │ │ ├── ReflectionUtils.java │ │ ├── TypefaceContextWrapper.java │ │ ├── TypefaceLayoutInflator.java │ │ ├── TypefaceUtils.java │ │ └── ViewCompat.java │ └── widget/ │ ├── BreathingDelegate.java │ ├── BreathingLayout.java │ ├── CurtainLayout.java │ ├── CustomSlidePanelLayout.java │ ├── DimImageView.java │ ├── DrawerFrame.java │ ├── DrawerFrameV2.java │ ├── ExProgressView.java │ ├── ExTextView.java │ ├── FlatTabGroup.java │ ├── FlipLayout.java │ ├── MatrixFrameLayout.java │ ├── PolygonWithQuadraticBezirView.java │ ├── RefreshLayout.java │ ├── SegmentDrawable.java │ ├── ShaderImageView.java │ ├── SimpleTab.java │ ├── SimpleTabLayout.java │ └── TagFlowLayout.java └── res/ ├── drawable/ │ └── toast_shape.xml ├── layout/ │ └── custom_toast.xml └── values/ ├── attr_breath_light.xml ├── attr_dim_imagview.xml ├── attr_ex_textview.xml ├── attr_flat_tab_group.xml ├── attrs_drawer_frame.xml ├── ids.xml └── strings.xml ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ .gradle /local.properties /.idea/workspace.xml /.idea/libraries .DS_Store /build **/*.iml .idea ================================================ FILE: LICENSE ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright 2014 Chaobin WU 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. ================================================ FILE: README.md ================================================ Support ======== Custom Android support library, include some useful utils and widget. support内是自定义的一些东西,sammple中包含support的实现demo样例, Download ------- Download the latest repo or grab the stable released version via Maven: Clone the master branch: ``` git clone https://github.com/avenwu/support.git ``` or Gradle: ```Groovy compile 'com.github.avenwu:support:0.1.1' ``` License ======= Copyright 2014 Chaobin Wu. 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. --- 实战案例 ------- ### 卡片翻转优化 ![device-2016-01-19-162559.mp4.gif](images/device-2016-01-19-162559.mp4.gif) ### TextView缩略 通过控制文本展示实现单击展开和收缩文本,并在收缩状态显示提示图标 ![TextView](http://7u2jir.com1.z0.glb.clouddn.com/expand_text.gif) ### 字体设置汇总 通过不同方式实现自定义字体的设置,主要区别在于调用层 ![字体设置汇总](http://7u2jir.com1.z0.glb.clouddn.com/device-2015-10-08-173228.png) ### 巧用BitmapShader 通过为Paint画笔设置Shader,可以再画布上绘制许多有意思的东西 ![BitmapShader](http://7u2jir.com1.z0.glb.clouddn.com/bitmapshader_imageview.gif) ### Property自定义属性动画 基于Property的自定义属性动画 ![Property动画](http://7u2jir.com1.z0.glb.clouddn.com/property_animation.gif) ### 自定义ResideMenu residemenu是是侧滑菜单的一种,但是视觉效果更特别,此次实现是基于android v4中SlidePanelLayout扩展而来,主要是为了减少非核心代码的开发工作。 详细实现请看:[基于SlidePanelLayout实现ResideMenu](http://avenwu.net/2015/02/24/custom_slide_panel_layout_as_reside_style_on_dribble_and_qq) 对于普通侧滑菜单的实现也可以参照我之前的一片文章[自定义侧滑菜单](http://avenwu.net/customlayout/2014/12/16/sliding_menu/) ![自定义ResideMenu](http://7u2jir.com1.z0.glb.clouddn.com/custom_residemenu.gif) ### RadioGroup仿iOS Segmented Control 这个没什么好说的用的实际上是RadioGroup,但是加强了封装和配置,所以使用会方便一些,否则每次需要类似UI效果都从新写是很累的事情。 ![RadioGroup仿iOS Segmented Control ](http://7u2jir.com1.z0.glb.clouddn.com/styled_radiogroup.png) ### 流式标签生成控件 这个东西还是比较有意思的,看图说话,通过EditText和TextView以及ViewGroup的有机结合,就可以做出这个效果不一般的输入交互控件。 详细技术实现请看:[流式标签生成控件](http://avenwu.net/customlayout/2015/01/18/tag_layout) ![流式标签生成控件](http://7u2jir.com1.z0.glb.clouddn.com/tag_input_layout_demo.gif) ### qq消息气泡【二次贝塞尔曲线多边形】 这个实际上是做为分析QQ红点气泡的一部分,及气泡拖拽的原理。 ![多边形气泡](http://7u2jir.com1.z0.glb.clouddn.com/polygon_bezier.gif) ### 侧滑菜单 简单的侧滑效果实现并不难,需要处理两块view容器的相对关系,但是有效果并不代表能使用,可实用的组件还需要考虑很多,下面的demo实际上主要目的在于处理菜单和内容区的位置关系,用的是scroll移动的方法,结合Scroller,所以导致变化的实际上是菜单容器的内容而不是菜单,所以support里还有另外一个自定义侧滑菜单解决这个问题。更多技术实现参考对应的文章:[自定义侧滑菜单](http://avenwu.net/customlayout/2014/12/16/sliding_menu/) ![侧滑菜单](http://7u2jir.com1.z0.glb.clouddn.com/drawermenu.gif) ### 下拉刷新列表 下拉刷新的本质上是LinearLayout嵌套ListView+View(刷新的头部视图),通过TouchEvent的分发控制,动态改变视图的Top位置。 ![下拉刷新列表](http://7u2jir.com1.z0.glb.clouddn.com/pulltorefresh.gif) ### 圆形排行View 这个实际上最开是的时候已经作为一个单独的项目开发,并且已经上传值maven,所以也可用gradle导入。 [IndexImageView项目首页](http://avenwu.net/IndexImageView/) 这个项目源灵感来自搜狐视屏客户端,看好声音的时候看到人气选手的头像是一个圆形带排行数的视图,感觉有点意思,索性花了点时间自己写了一个,同时学习如何将开源项目发布到Maven Central,这样就可以通过gradle方便的获取maven依赖库。 ![Screenshot](https://github.com/avenwu/IndexImageView/raw/master/device-2014-10-21-164818.png) ================================================ FILE: build.gradle ================================================ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.3.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() } } ================================================ FILE: gradle/wrapper/gradle-wrapper.properties ================================================ #Wed Apr 10 15:27:10 PDT 2013 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip ================================================ FILE: gradle.properties ================================================ # Project-wide Gradle settings. # IDE (e.g. Android Studio) users: # Gradle settings configured through the IDE *will override* # any settings specified in this file. # For more details on how to configure your build environment visit # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. # Default value: -Xmx10248m -XX:MaxPermSize=256m # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true ================================================ FILE: gradlew ================================================ #!/usr/bin/env bash ############################################################################## ## ## Gradle start up script for UN*X ## ############################################################################## # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS="" APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # 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 case "`uname`" in CYGWIN* ) cygwin=true ;; Darwin* ) darwin=true ;; MINGW* ) msys=true ;; esac # For Cygwin, ensure paths are in UNIX format before anything is touched. if $cygwin ; then [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` fi # 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\"`/" >&- APP_HOME="`pwd -P`" cd "$SAVED" >&- 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" ] ; 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"` # 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 # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules function splitJvmOpts() { JVM_OPTS=("$@") } eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" ================================================ FILE: gradlew.bat ================================================ @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 @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= set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @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 Windowz variants if not "%OS%" == "Windows_NT" goto win9xME_args if "%@eval[2+2]" == "4" goto 4NT_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=%* goto execute :4NT_args @rem Get arguments from the 4NT Shell from JP Software 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 ================================================ FILE: sample/.gitignore ================================================ /build ================================================ FILE: sample/build.gradle ================================================ apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.1" defaultConfig { applicationId "com.avenwu.deepinandroid" minSdkVersion 8 targetSdkVersion 23 versionCode 1 versionName "1.0" } lintOptions { abortOnError false } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } packagingOptions { exclude 'META-INF/services/javax.annotation.processing.Processor' } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile project(':support') compile 'com.jakewharton:butterknife:6.0.0' compile 'com.github.avenwu:IndexImageView:1.0.1' compile 'com.drewnoakes:metadata-extractor:2.7.2' compile 'com.android.support:support-v4:23.1.0' compile 'com.android.support:appcompat-v7:23.1.0' compile 'com.android.support:percent:23.1.0' compile 'com.squareup.retrofit:retrofit:1.6.0' } ================================================ FILE: sample/proguard-rules.pro ================================================ # Add project specific ProGuard rules here. # By default, the flags in this file are appended to flags specified # in F:\Android\sdk/tools/proguard/proguard-android.txt # You can edit the include path and order by changing the proguardFiles # directive in build.gradle. # # 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 *; #} ================================================ FILE: sample/src/androidTest/java/com/avenwu/deepinandroid/ApplicationTest.java ================================================ package com.avenwu.deepinandroid; import android.app.Application; import android.test.ApplicationTestCase; import android.util.Log; /** * Testing Fundamentals */ public class ApplicationTest extends ApplicationTestCase { public ApplicationTest() { super(Application.class); } final static char ASSIC_START = '!'; final static char ASSIC_END = '~'; final static char UNICODE_START = '!'; final static char UNICODE_END = '~'; final static long DIFF = UNICODE_START - ASSIC_START; public void testEncodeFormat() { String res = ",!@#%&*()?;"; String des = ",!@#%&*()?;"; StringBuilder builder = new StringBuilder(); for (int i = 0; i < res.length(); i++) { char c = res.charAt(i); Log.e("TEST_UNICODE", "" + c); if (isEXPANDUNICODE(c)) { c = unicode2Assic(c); Log.e("TEST_UNICODE", "translated:" + c); } builder.append(c); } assertEquals(des, builder.toString()); } boolean isBasicASSIC(char c) { return c >= ASSIC_START && c <= ASSIC_END; } boolean isEXPANDUNICODE(char c) { return c >= UNICODE_START && c <= UNICODE_END; } char unicode2Assic(char c) { return (char) (c - DIFF); } } ================================================ FILE: sample/src/main/AndroidManifest.xml ================================================ ================================================ FILE: sample/src/main/assets/github-markdown.css ================================================ @font-face { font-family: octicons-anchor; src: url(data:font/woff;charset=utf-8;base64,d09GRgABAAAAAAYcAA0AAAAACjQAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAABMAAAABwAAAAca8vGTk9TLzIAAAFMAAAARAAAAFZG1VHVY21hcAAAAZAAAAA+AAABQgAP9AdjdnQgAAAB0AAAAAQAAAAEACICiGdhc3AAAAHUAAAACAAAAAj//wADZ2x5ZgAAAdwAAADRAAABEKyikaNoZWFkAAACsAAAAC0AAAA2AtXoA2hoZWEAAALgAAAAHAAAACQHngNFaG10eAAAAvwAAAAQAAAAEAwAACJsb2NhAAADDAAAAAoAAAAKALIAVG1heHAAAAMYAAAAHwAAACABEAB2bmFtZQAAAzgAAALBAAAFu3I9x/Nwb3N0AAAF/AAAAB0AAAAvaoFvbwAAAAEAAAAAzBdyYwAAAADP2IQvAAAAAM/bz7t4nGNgZGFgnMDAysDB1Ml0hoGBoR9CM75mMGLkYGBgYmBlZsAKAtJcUxgcPsR8iGF2+O/AEMPsznAYKMwIkgMA5REMOXicY2BgYGaAYBkGRgYQsAHyGMF8FgYFIM0ChED+h5j//yEk/3KoSgZGNgYYk4GRCUgwMaACRoZhDwCs7QgGAAAAIgKIAAAAAf//AAJ4nHWMMQrCQBBF/0zWrCCIKUQsTDCL2EXMohYGSSmorScInsRGL2DOYJe0Ntp7BK+gJ1BxF1stZvjz/v8DRghQzEc4kIgKwiAppcA9LtzKLSkdNhKFY3HF4lK69ExKslx7Xa+vPRVS43G98vG1DnkDMIBUgFN0MDXflU8tbaZOUkXUH0+U27RoRpOIyCKjbMCVejwypzJJG4jIwb43rfl6wbwanocrJm9XFYfskuVC5K/TPyczNU7b84CXcbxks1Un6H6tLH9vf2LRnn8Ax7A5WQAAAHicY2BkYGAA4teL1+yI57f5ysDNwgAC529f0kOmWRiYVgEpDgYmEA8AUzEKsQAAAHicY2BkYGB2+O/AEMPCAAJAkpEBFbAAADgKAe0EAAAiAAAAAAQAAAAEAAAAAAAAKgAqACoAiAAAeJxjYGRgYGBhsGFgYgABEMkFhAwM/xn0QAIAD6YBhwB4nI1Ty07cMBS9QwKlQapQW3VXySvEqDCZGbGaHULiIQ1FKgjWMxknMfLEke2A+IJu+wntrt/QbVf9gG75jK577Lg8K1qQPCfnnnt8fX1NRC/pmjrk/zprC+8D7tBy9DHgBXoWfQ44Av8t4Bj4Z8CLtBL9CniJluPXASf0Lm4CXqFX8Q84dOLnMB17N4c7tBo1AS/Qi+hTwBH4rwHHwN8DXqQ30XXAS7QaLwSc0Gn8NuAVWou/gFmnjLrEaEh9GmDdDGgL3B4JsrRPDU2hTOiMSuJUIdKQQayiAth69r6akSSFqIJuA19TrzCIaY8sIoxyrNIrL//pw7A2iMygkX5vDj+G+kuoLdX4GlGK/8Lnlz6/h9MpmoO9rafrz7ILXEHHaAx95s9lsI7AHNMBWEZHULnfAXwG9/ZqdzLI08iuwRloXE8kfhXYAvE23+23DU3t626rbs8/8adv+9DWknsHp3E17oCf+Z48rvEQNZ78paYM38qfk3v/u3l3u3GXN2Dmvmvpf1Srwk3pB/VSsp512bA/GG5i2WJ7wu430yQ5K3nFGiOqgtmSB5pJVSizwaacmUZzZhXLlZTq8qGGFY2YcSkqbth6aW1tRmlaCFs2016m5qn36SbJrqosG4uMV4aP2PHBmB3tjtmgN2izkGQyLWprekbIntJFing32a5rKWCN/SdSoga45EJykyQ7asZvHQ8PTm6cslIpwyeyjbVltNikc2HTR7YKh9LBl9DADC0U/jLcBZDKrMhUBfQBvXRzLtFtjU9eNHKin0x5InTqb8lNpfKv1s1xHzTXRqgKzek/mb7nB8RZTCDhGEX3kK/8Q75AmUM/eLkfA+0Hi908Kx4eNsMgudg5GLdRD7a84npi+YxNr5i5KIbW5izXas7cHXIMAau1OueZhfj+cOcP3P8MNIWLyYOBuxL6DRylJ4cAAAB4nGNgYoAALjDJyIAOWMCiTIxMLDmZedkABtIBygAAAA==) format('woff'); } .markdown-body { -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; color: #333; overflow: hidden; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif; font-size: 16px; line-height: 1.6; word-wrap: break-word; } .markdown-body a { background: transparent; } .markdown-body a:active, .markdown-body a:hover { outline: 0; } .markdown-body strong { font-weight: bold; } .markdown-body h1 { font-size: 2em; margin: 0.67em 0; } .markdown-body img { border: 0; } .markdown-body hr { -moz-box-sizing: content-box; box-sizing: content-box; height: 0; } .markdown-body pre { overflow: auto; } .markdown-body code, .markdown-body kbd, .markdown-body pre { font-family: monospace, monospace; font-size: 1em; } .markdown-body input { color: inherit; font: inherit; margin: 0; } .markdown-body html input[disabled] { cursor: default; } .markdown-body input { line-height: normal; } .markdown-body input[type="checkbox"] { -moz-box-sizing: border-box; box-sizing: border-box; padding: 0; } .markdown-body table { border-collapse: collapse; border-spacing: 0; } .markdown-body td, .markdown-body th { padding: 0; } .markdown-body * { -moz-box-sizing: border-box; box-sizing: border-box; } .markdown-body input { font: 13px/1.4 Helvetica, arial, freesans, clean, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol"; } .markdown-body a { color: #4183c4; text-decoration: none; } .markdown-body a:hover, .markdown-body a:focus, .markdown-body a:active { text-decoration: underline; } .markdown-body hr { height: 0; margin: 15px 0; overflow: hidden; background: transparent; border: 0; border-bottom: 1px solid #ddd; } .markdown-body hr:before { display: table; content: ""; } .markdown-body hr:after { display: table; clear: both; content: ""; } .markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6 { margin-top: 15px; margin-bottom: 15px; line-height: 1.1; } .markdown-body h1 { font-size: 30px; } .markdown-body h2 { font-size: 21px; } .markdown-body h3 { font-size: 16px; } .markdown-body h4 { font-size: 14px; } .markdown-body h5 { font-size: 12px; } .markdown-body h6 { font-size: 11px; } .markdown-body blockquote { margin: 0; } .markdown-body ul, .markdown-body ol { padding: 0; margin-top: 0; margin-bottom: 0; } .markdown-body ol ol, .markdown-body ul ol { list-style-type: lower-roman; } .markdown-body ul ul ol, .markdown-body ul ol ol, .markdown-body ol ul ol, .markdown-body ol ol ol { list-style-type: lower-alpha; } .markdown-body dd { margin-left: 0; } .markdown-body code { font: 12px Consolas, "Liberation Mono", Menlo, Courier, monospace; } .markdown-body pre { margin-top: 0; margin-bottom: 0; font: 12px Consolas, "Liberation Mono", Menlo, Courier, monospace; } .markdown-body kbd { background-color: #e7e7e7; background-image: -webkit-linear-gradient(#fefefe, #e7e7e7); background-image: linear-gradient(#fefefe, #e7e7e7); background-repeat: repeat-x; border-radius: 2px; border: 1px solid #cfcfcf; color: #000; padding: 3px 5px; line-height: 10px; font: 11px Consolas, "Liberation Mono", Menlo, Courier, monospace; display: inline-block; } .markdown-body>*:first-child { margin-top: 0 !important; } .markdown-body>*:last-child { margin-bottom: 0 !important; } .markdown-body .anchor { position: absolute; top: 0; bottom: 0; left: 0; display: block; padding-right: 6px; padding-left: 30px; margin-left: -30px; } .markdown-body .anchor:focus { outline: none; } .markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6 { position: relative; margin-top: 1em; margin-bottom: 16px; font-weight: bold; line-height: 1.4; } .markdown-body h1 .octicon-link, .markdown-body h2 .octicon-link, .markdown-body h3 .octicon-link, .markdown-body h4 .octicon-link, .markdown-body h5 .octicon-link, .markdown-body h6 .octicon-link { display: none; color: #000; vertical-align: middle; } .markdown-body h1:hover .anchor, .markdown-body h2:hover .anchor, .markdown-body h3:hover .anchor, .markdown-body h4:hover .anchor, .markdown-body h5:hover .anchor, .markdown-body h6:hover .anchor { height: 1em; padding-left: 8px; margin-left: -30px; line-height: 1; text-decoration: none; } .markdown-body h1:hover .anchor .octicon-link, .markdown-body h2:hover .anchor .octicon-link, .markdown-body h3:hover .anchor .octicon-link, .markdown-body h4:hover .anchor .octicon-link, .markdown-body h5:hover .anchor .octicon-link, .markdown-body h6:hover .anchor .octicon-link { display: inline-block; } .markdown-body h1 { padding-bottom: 0.3em; font-size: 2.25em; line-height: 1.2; border-bottom: 1px solid #eee; } .markdown-body h2 { padding-bottom: 0.3em; font-size: 1.75em; line-height: 1.225; border-bottom: 1px solid #eee; } .markdown-body h3 { font-size: 1.5em; line-height: 1.43; } .markdown-body h4 { font-size: 1.25em; } .markdown-body h5 { font-size: 1em; } .markdown-body h6 { font-size: 1em; color: #777; } .markdown-body p, .markdown-body blockquote, .markdown-body ul, .markdown-body ol, .markdown-body dl, .markdown-body table, .markdown-body pre { margin-top: 0; margin-bottom: 16px; } .markdown-body hr { height: 4px; padding: 0; margin: 16px 0; background-color: #e7e7e7; border: 0 none; } .markdown-body ul, .markdown-body ol { padding-left: 2em; } .markdown-body ul ul, .markdown-body ul ol, .markdown-body ol ol, .markdown-body ol ul { margin-top: 0; margin-bottom: 0; } .markdown-body li>p { margin-top: 16px; } .markdown-body dl { padding: 0; } .markdown-body dl dt { padding: 0; margin-top: 16px; font-size: 1em; font-style: italic; font-weight: bold; } .markdown-body dl dd { padding: 0 16px; margin-bottom: 16px; } .markdown-body blockquote { padding: 0 15px; color: #777; border-left: 4px solid #ddd; } .markdown-body blockquote>:first-child { margin-top: 0; } .markdown-body blockquote>:last-child { margin-bottom: 0; } .markdown-body table { display: block; width: 100%; overflow: auto; word-break: normal; word-break: keep-all; } .markdown-body table th { font-weight: bold; } .markdown-body table th, .markdown-body table td { padding: 6px 13px; border: 1px solid #ddd; } .markdown-body table tr { background-color: #fff; border-top: 1px solid #ccc; } .markdown-body table tr:nth-child(2n) { background-color: #f8f8f8; } .markdown-body img { max-width: 100%; -moz-box-sizing: border-box; box-sizing: border-box; } .markdown-body code { padding: 0; padding-top: 0.2em; padding-bottom: 0.2em; margin: 0; font-size: 85%; background-color: rgba(0,0,0,0.04); border-radius: 3px; } .markdown-body code:before, .markdown-body code:after { letter-spacing: -0.2em; content: "\00a0"; } .markdown-body pre>code { padding: 0; margin: 0; font-size: 100%; word-break: normal; white-space: pre; background: transparent; border: 0; } .markdown-body .highlight { margin-bottom: 16px; } .markdown-body .highlight pre, .markdown-body pre { padding: 16px; overflow: auto; font-size: 85%; line-height: 1.45; background-color: #f7f7f7; border-radius: 3px; } .markdown-body .highlight pre { margin-bottom: 0; word-break: normal; } .markdown-body pre { word-wrap: normal; } .markdown-body pre code { display: inline; max-width: initial; padding: 0; margin: 0; overflow: initial; line-height: inherit; word-wrap: normal; background-color: transparent; border: 0; } .markdown-body pre code:before, .markdown-body pre code:after { content: normal; } .markdown-body .highlight { background: #fff; } .markdown-body .highlight .mf, .markdown-body .highlight .mh, .markdown-body .highlight .mi, .markdown-body .highlight .mo, .markdown-body .highlight .il, .markdown-body .highlight .m { color: #945277; } .markdown-body .highlight .s, .markdown-body .highlight .sb, .markdown-body .highlight .sc, .markdown-body .highlight .sd, .markdown-body .highlight .s2, .markdown-body .highlight .se, .markdown-body .highlight .sh, .markdown-body .highlight .si, .markdown-body .highlight .sx, .markdown-body .highlight .s1 { color: #df5000; } .markdown-body .highlight .kc, .markdown-body .highlight .kd, .markdown-body .highlight .kn, .markdown-body .highlight .kp, .markdown-body .highlight .kr, .markdown-body .highlight .kt, .markdown-body .highlight .k, .markdown-body .highlight .o { font-weight: bold; } .markdown-body .highlight .kt { color: #458; } .markdown-body .highlight .c, .markdown-body .highlight .cm, .markdown-body .highlight .c1 { color: #998; font-style: italic; } .markdown-body .highlight .cp, .markdown-body .highlight .cs { color: #999; font-weight: bold; } .markdown-body .highlight .cs { font-style: italic; } .markdown-body .highlight .n { color: #333; } .markdown-body .highlight .na, .markdown-body .highlight .nv, .markdown-body .highlight .vc, .markdown-body .highlight .vg, .markdown-body .highlight .vi { color: #008080; } .markdown-body .highlight .nb { color: #0086B3; } .markdown-body .highlight .nc { color: #458; font-weight: bold; } .markdown-body .highlight .no { color: #094e99; } .markdown-body .highlight .ni { color: #800080; } .markdown-body .highlight .ne { color: #990000; font-weight: bold; } .markdown-body .highlight .nf { color: #945277; font-weight: bold; } .markdown-body .highlight .nn { color: #555; } .markdown-body .highlight .nt { color: #000080; } .markdown-body .highlight .err { color: #a61717; background-color: #e3d2d2; } .markdown-body .highlight .gd { color: #000; background-color: #fdd; } .markdown-body .highlight .gd .x { color: #000; background-color: #faa; } .markdown-body .highlight .ge { font-style: italic; } .markdown-body .highlight .gr { color: #aa0000; } .markdown-body .highlight .gh { color: #999; } .markdown-body .highlight .gi { color: #000; background-color: #dfd; } .markdown-body .highlight .gi .x { color: #000; background-color: #afa; } .markdown-body .highlight .go { color: #888; } .markdown-body .highlight .gp { color: #555; } .markdown-body .highlight .gs { font-weight: bold; } .markdown-body .highlight .gu { color: #800080; font-weight: bold; } .markdown-body .highlight .gt { color: #aa0000; } .markdown-body .highlight .ow { font-weight: bold; } .markdown-body .highlight .w { color: #bbb; } .markdown-body .highlight .sr { color: #017936; } .markdown-body .highlight .ss { color: #8b467f; } .markdown-body .highlight .bp { color: #999; } .markdown-body .highlight .gc { color: #999; background-color: #EAF2F5; } .markdown-body .octicon { font: normal normal 16px octicons-anchor; line-height: 1; display: inline-block; text-decoration: none; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } .markdown-body .octicon-link:before { content: '\f05c'; } .markdown-body .task-list-item { list-style-type: none; } .markdown-body .task-list-item+.task-list-item { margin-top: 3px; } .markdown-body .task-list-item input { float: left; margin: 0.3em 0 0.25em -1.6em; vertical-align: middle; } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/AnimatedSubActivity.java ================================================ /* * Copyright (C) 2013 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 com.avenwu.deepinandroid; import android.app.Activity; import android.os.Bundle; /** * See WindowAnimations.java for comments on the overall application. * * This is a sub-activity which provides custom animation behavior. When this activity * is exited, the user will see the behavior specified in the overridePendingTransition() call. */ public class AnimatedSubActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_window_anim_sub); } @Override public void finish() { super.finish(); overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_right); } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/BitmapShaderFragment.java ================================================ package com.avenwu.deepinandroid; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; /** * Created by chaobin on 4/6/15. */ public class BitmapShaderFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.bitmap_shader_layout, null); view.setOnClickListener(null); return view; } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/BreathLightViewDemo.java ================================================ package com.avenwu.deepinandroid; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; /** * Created by chaobin on 3/3/15. */ public class BreathLightViewDemo extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.ripple_layout, null); view.setOnClickListener(null); return view; } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/BusEventDemo.java ================================================ package com.avenwu.deepinandroid; import com.avenwu.deepinandroid.eventbus.Bus; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.util.Log; import android.view.View; import android.widget.Toast; /** * Created by chaobin on 1/29/15. */ public class BusEventDemo extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.eventbus_layout); } @Override protected void onStart() { super.onStart(); Bus.getDefault().register(this); } public void onSendClick(View view) { Bus.getDefault().post("Hello world"); } public void onEvent(String event) { Log.d("BusEventDemo", "onEvent hit"); Toast.makeText(this, "onEvent hit:" + event, Toast.LENGTH_SHORT).show(); } @Override protected void onStop() { super.onStop(); Bus.getDefault().unregister(this); } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/CameraMatrixFragmentDemo.java ================================================ package com.avenwu.deepinandroid; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; /** * Created by aven on 1/20/16. */ public class CameraMatrixFragmentDemo extends Fragment { @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.camera_matrix_layout, null); } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/ColorFilterDemo.java ================================================ package com.avenwu.deepinandroid; import android.graphics.Color; import android.graphics.PorterDuff; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.Spinner; import android.widget.Toast; import java.lang.reflect.Field; import butterknife.ButterKnife; import butterknife.InjectView; /** * Created by chaobin on 2/3/15. */ public class ColorFilterDemo extends ActionBarActivity implements AdapterView.OnItemSelectedListener { @InjectView(R.id.spinner) Spinner mPorterDuffSpinner; @InjectView(R.id.iv_preview) ImageView mPreviewView; @InjectView(R.id.iv_image) ImageView mImage; static final int MASK_HINT_COLOR = 0x99000000; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.filter_layout); ButterKnife.inject(this); ArrayAdapter adapter = ArrayAdapter.createFromResource(this, R.array.porter_duff_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line); mPorterDuffSpinner.setPrompt("Select the PorterDuff"); mPorterDuffSpinner.setAdapter(adapter); mPorterDuffSpinner.setOnItemSelectedListener(this); int defaultSelection = 0; try { Field field = PorterDuff.Mode.class.getDeclaredField("nativeInt"); field.setAccessible(true); defaultSelection = field.getInt(PorterDuff.Mode.DARKEN); } catch (NoSuchFieldException | IllegalAccessException e) { e.printStackTrace(); } mPorterDuffSpinner.setSelection(defaultSelection); } @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { PorterDuff.Mode mode = PorterDuff.Mode.class.getEnumConstants()[position]; mPreviewView.setColorFilter(Color.GREEN, mode); mImage.setColorFilter(MASK_HINT_COLOR, mode); Toast.makeText(this, "Select " + mode, Toast.LENGTH_SHORT).show(); } @Override public void onNothingSelected(AdapterView parent) { } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/Content.java ================================================ package com.avenwu.deepinandroid; public interface Content { public String getContent(); } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/CurtainLayoutFragment.java ================================================ package com.avenwu.deepinandroid; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; /** * Created by aven on 12/25/15. */ public class CurtainLayoutFragment extends Fragment { @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return View.inflate(getActivity(), R.layout.curtain_demo, null); } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/CustomDrawableDemo.java ================================================ package com.avenwu.deepinandroid; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.util.TypedValue; import android.widget.RadioButton; import android.widget.RadioGroup; import net.avenwu.support.widget.SegmentDrawable; public class CustomDrawableDemo extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.custom_drawable_layout); final int color = 0xff35b558; int strokeWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2f, getResources().getDisplayMetrics()); int corner = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5f, getResources().getDisplayMetrics()); SegmentDrawable drawable1 = new SegmentDrawable(SegmentDrawable.Style.LEFT_EDGE); drawable1.setStrokeWidth(strokeWidth); drawable1.setColor(color); drawable1.setCornerRadius(corner); findViewById(R.id.label).setBackgroundDrawable(drawable1); SegmentDrawable drawable2 = new SegmentDrawable(SegmentDrawable.Style.MIDDLE); drawable2.setStrokeWidth(strokeWidth); drawable2.setColor(color); drawable2.setCornerRadius(corner); findViewById(R.id.label2).setBackgroundDrawable(drawable2); SegmentDrawable drawable3 = new SegmentDrawable(SegmentDrawable.Style.RIGHT_EDGE); drawable3.setStrokeWidth(strokeWidth); drawable3.setColor(color); drawable3.setCornerRadius(corner); findViewById(R.id.label3).setBackgroundDrawable(drawable3); RadioGroup group = (RadioGroup) findViewById(R.id.container); int count = group.getChildCount(); for (int i = 0; i < count; i++) { RadioButton child = (RadioButton) group.getChildAt(i); SegmentDrawable drawable; if (i == 0) { drawable = new SegmentDrawable(SegmentDrawable.Style.LEFT_EDGE); child.setChecked(true); } else if (i == count - 1) { drawable = new SegmentDrawable(SegmentDrawable.Style.RIGHT_EDGE); } else { drawable = new SegmentDrawable(SegmentDrawable.Style.MIDDLE); } drawable.setColor(color); drawable.setStrokeWidth(strokeWidth); drawable.setCornerRadius(corner); child.setButtonDrawable(null); child.setBackgroundDrawable(drawable.newStateListDrawable()); } } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/CustomProgressActivity.java ================================================ package com.avenwu.deepinandroid; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; /** * Created by aven on 10/20/15. */ public class CustomProgressActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_progress_layout); } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/CustomTabActivity.java ================================================ package com.avenwu.deepinandroid; import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentTabHost; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TabWidget; import android.widget.TextView; import android.widget.Toast; import net.avenwu.support.widget.SimpleTab; /** * Created by aven on 5/3/15. */ public class CustomTabActivity extends FragmentActivity { SimpleTab mSimpleTab; FragmentTabHost mTabHost; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.custom_tab_activity); ViewGroup viewGroup = (ViewGroup) findViewById(R.id.container); mSimpleTab = new SimpleTab.Builder(this) .newItem(new SimpleTab.Item().setLabelWithIcon(R.string.tab_1, R.drawable.ic_launcher)) .newItem(new SimpleTab.Item().setLabelWithIcon(R.string.tab_2, R.drawable.ic_launcher)) .newItem(new SimpleTab.Item().setLabelWithIcon(R.string.tab_3, R.drawable.ic_launcher)) .newItem(new SimpleTab.Item().setLabelWithIcon(R.string.tab_4, R.drawable.ic_launcher)) .setOnTabClickListener(new SimpleTab.OnTabClickListener() { @Override public void onItemClick(View view, SimpleTab.Item item, int position) { Toast.makeText(CustomTabActivity.this, "position=" + position, Toast .LENGTH_SHORT).show(); } }) .create(); mSimpleTab.injectInto(viewGroup); // TabWidget mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost); mTabHost.setup(this, getSupportFragmentManager(), android.R.id.tabcontent); mTabHost.addTab( mTabHost.newTabSpec("tab1").setIndicator("Tab 1", null).setIndicator(getTabIndicator(this, R.string.tab_1, R.drawable.ic_launcher)), FragmentTab.class, null); mTabHost.addTab( mTabHost.newTabSpec("tab2").setIndicator("Tab 2", null).setIndicator (getTabIndicator(this, R.string.tab_2, R.drawable.ic_launcher)), FragmentTab.class, null); mTabHost.addTab( mTabHost.newTabSpec("tab3").setIndicator("Tab 3", null).setIndicator (getTabIndicator(this, R.string.tab_3, R.drawable.ic_launcher)), FragmentTab.class, null); mTabHost.addTab( mTabHost.newTabSpec("tab4").setIndicator("Tab 3", null).setIndicator (getTabIndicator(this, R.string.tab_4, R.drawable.ic_launcher)), FragmentTab.class, null); } private View getTabIndicator(Context context, int title, int icon) { View view = LayoutInflater.from(context).inflate(R.layout.fragment_tab_item, null); ImageView iv = (ImageView) view.findViewById(R.id.imageView); iv.setImageResource(icon); TextView tv = (TextView) view.findViewById(R.id.textView); tv.setText(title); return view; } public static class FragmentTab extends Fragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_tab_host, container, false); TextView tv = (TextView) v.findViewById(R.id.text); tv.setText(this.getTag() + " Content"); return v; } } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/CustomTextViewActivity.java ================================================ package com.avenwu.deepinandroid; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.text.Html; import android.text.Spanned; import android.widget.TextView; /** * Created by chaobin on 11/18/15. */ public class CustomTextViewActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.textview_layout); } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/DrawerDemoFragment.java ================================================ package com.avenwu.deepinandroid; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.CompoundButton; import android.widget.FrameLayout; import android.widget.Switch; import android.widget.TextView; import android.widget.Toast; import com.github.avenwu.imageview.IndexImageView; import net.avenwu.support.widget.DrawerFrame; /** * Created by Chaobin Wu on 2014/10/10. */ public class DrawerDemoFragment extends Fragment { DrawerFrame drawerFrame; public DrawerDemoFragment() { } @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.activity_my, container); drawerFrame = (DrawerFrame) view.findViewById(R.id.view); Switch s = (Switch) view.findViewById(R.id.switch1); s.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { drawerFrame.showMenuSmoothly(); } else { drawerFrame.dismissSmoothly(); } } }); TextView menu = new TextView(getActivity()); menu.setText("Menu Layout"); menu.setBackgroundColor(getResources().getColor(android.R.color.holo_red_dark)); menu.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(getActivity(), "Menu clicked", Toast.LENGTH_SHORT).show(); } }); FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); menu.setLayoutParams(layoutParams); menu.setGravity(Gravity.CENTER | Gravity.CENTER_VERTICAL); drawerFrame.setMenuView(menu); IndexImageView imageView = new IndexImageView(getActivity()); imageView.setImageResource(R.drawable.ic_launcher); imageView.setIndexEnable(true); imageView.setText("121"); imageView.setTextDimension(40); FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(200, 200); layoutParams2.gravity = Gravity.CENTER; imageView.setLayoutParams(layoutParams2); drawerFrame.setContentView(imageView); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(getActivity(), "Image cliked", Toast.LENGTH_SHORT).show(); } }); return view; } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/ExifViewerFragment.java ================================================ package com.avenwu.deepinandroid; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.media.ExifInterface; import android.os.AsyncTask; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v4.os.AsyncTaskCompat; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.drew.imaging.ImageMetadataReader; import com.drew.imaging.ImageProcessingException; import com.drew.metadata.Directory; import com.drew.metadata.Metadata; import com.drew.metadata.Tag; import net.avenwu.support.widget.FlatTabGroup; import java.io.IOException; import java.lang.reflect.Field; import java.util.HashMap; import java.util.Iterator; import java.util.Map; /** * Created by chaobin on 3/4/15. */ public class ExifViewerFragment extends Fragment { ImageView mImageView; TextView mTextView; @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.exif_layout, null); mImageView = (ImageView) view.findViewById(R.id.image); mTextView = (TextView) view.findViewById(R.id.text); FlatTabGroup tabs = (FlatTabGroup) view.findViewById(R.id.tabs); tabs.setSelection(0); tabs.setOnTabCheckedListener(new FlatTabGroup.OnTabCheckedListener() { @Override public void onChecked(FlatTabGroup group, int position) { switch (position) { case 0: decodeWith(new AssetsImageExifDecoder()); break; case 1: decodeWith(new ExternalImageExifDecoder()); break; } } }); return view; } private void decodeWith(ExifDecoder decoder) { AsyncTaskCompat.executeParallel(new AsyncTask() { @Override protected ExifBean doInBackground(ExifDecoder... params) { return new ExifBean(params[0].decodeBitmap(), params[0].extractExif()); } @Override protected void onPostExecute(ExifBean exifBean) { if (exifBean.bitmap != null) { mImageView.setImageBitmap(exifBean.bitmap); } if (exifBean.value != null) { mTextView.setText(exifBean.value); } } }, decoder); } interface ExifDecoder { Bitmap decodeBitmap(); String extractExif(); } /** * ExifInterface seems not support image in assets */ class AssetsImageExifDecoder implements ExifDecoder { final String ASSETS_IMAGE_PATH = "image2.jpg"; @Override public Bitmap decodeBitmap() { try { return BitmapFactory.decodeStream(getResources().getAssets().open(ASSETS_IMAGE_PATH)); } catch (IOException e) { Log.d("ExifViewerFragment", "AssetsImageExifDecoder decodeBitmap failed"); e.printStackTrace(); } return null; } @Override public String extractExif() { try { Metadata metadata = ImageMetadataReader.readMetadata(getResources().getAssets().open(ASSETS_IMAGE_PATH)); Iterator iterator = metadata.getDirectories().iterator(); final String output = "%s=%s"; StringBuilder builder = new StringBuilder(); while (iterator.hasNext()) { Directory d = iterator.next(); for (Tag tag : d.getTags()) { builder.append(String.format(output, tag.getTagName(), tag.getDescription())) .append("\n"); } } return builder.toString(); } catch (ImageProcessingException e) { e.printStackTrace(); Log.d("ExifViewerFragment", "get attributes failed"); } catch (IOException e) { e.printStackTrace(); Log.d("ExifViewerFragment", "get attributes failed"); } return null; } } class ExternalImageExifDecoder implements ExifDecoder { //TODO replace with your own image path final String EXTRANAL_IMAGE_PATH = "/storage/sdcard1/DCIM/Camera/IMG_20150304_162932.jpg"; @Override public Bitmap decodeBitmap() { return BitmapFactory.decodeFile(EXTRANAL_IMAGE_PATH); } @Override public String extractExif() { try { ExifInterface exifInterface = new ExifInterface(EXTRANAL_IMAGE_PATH); StringBuilder builder = new StringBuilder(); final String output = "%s=%s"; try { Field field = exifInterface.getClass().getDeclaredField("mAttributes"); field.setAccessible(true); HashMap attrs = (HashMap) field.get(exifInterface); for (Map.Entry entry : attrs.entrySet()) { builder.append(String.format(output, entry.getKey(), entry.getValue())).append("\n"); } } catch (NoSuchFieldException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } return builder.toString(); } catch (IOException e) { Log.d("ExifViewerFragment", "get attributes failed"); e.printStackTrace(); } return null; } } class ExifBean { Bitmap bitmap; String value; public ExifBean(Bitmap bitmap, String value) { this.bitmap = bitmap; this.value = value; } } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/FeatureActivity.java ================================================ package com.avenwu.deepinandroid; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.ViewPager; import android.support.v7.app.AppCompatActivity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; public class FeatureActivity extends AppCompatActivity { View mLeft, mRight; ViewPager viewPager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.feature_layout); viewPager = (ViewPager) findViewById(R.id.viewpager); viewPager.setAdapter(new Adapter(getSupportFragmentManager())); mLeft = findViewById(R.id.iv_left); mRight = findViewById(R.id.iv_right); mLeft.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { viewPager.setCurrentItem(viewPager.getCurrentItem() + 1); } }); mRight.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { viewPager.setCurrentItem(viewPager.getCurrentItem() - 1); } }); viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int i, float v, int i1) { } @Override public void onPageSelected(int i) { mLeft.setVisibility(i == 0 ? View.GONE : View.VISIBLE); mRight.setVisibility(i == 2 ? View.GONE : View.VISIBLE); } @Override public void onPageScrollStateChanged(int i) { } }); } class Adapter extends FragmentPagerAdapter { public Adapter(FragmentManager fm) { super(fm); } @Override public Fragment getItem(int i) { Fragment fragment = new FragmentItem(); Bundle bundle = new Bundle(); switch (i) { case 0: bundle.putString(KEY_LABEL, getString(R.string.page_1_text)); bundle.putInt(KEY_IMAGE_ID, R.drawable.page_1_image); bundle.putInt(KEY_COLOR_ABOVE, getResources().getColor(R.color.page_1_dark)); bundle.putInt(KEY_COLOR_BELOW, getResources().getColor(R.color.page_1)); break; case 1: bundle.putString(KEY_LABEL, getString(R.string.page_2_text)); bundle.putInt(KEY_IMAGE_ID, R.drawable.page_2_image); bundle.putInt(KEY_COLOR_ABOVE, getResources().getColor(R.color.page_2_dark)); bundle.putInt(KEY_COLOR_BELOW, getResources().getColor(R.color.page_2)); break; case 2: bundle.putString(KEY_LABEL, getString(R.string.page_3_text)); bundle.putInt(KEY_IMAGE_ID, R.drawable.page_3_image); bundle.putInt(KEY_COLOR_ABOVE, getResources().getColor(R.color.page_3_dark)); bundle.putInt(KEY_COLOR_BELOW, getResources().getColor(R.color.page_3)); break; } fragment.setArguments(bundle); return fragment; } @Override public int getCount() { return 3; } } public static final String KEY_LABEL = "key_label"; public static final String KEY_IMAGE_ID = "key_image_id"; public static final String KEY_COLOR_ABOVE = "key_color_above"; public static final String KEY_COLOR_BELOW = "key_color_below"; public static class FragmentItem extends Fragment { public FragmentItem() { } @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.feature_item_layout, null); String label = getArguments().getString(KEY_LABEL); ((TextView) view.findViewById(R.id.tv_label)).setText(label); int color1 = getArguments().getInt(KEY_COLOR_ABOVE); view.findViewById(R.id.ll_above).setBackgroundColor(color1); int color2 = getArguments().getInt(KEY_COLOR_BELOW); view.findViewById(R.id.ll_below).setBackgroundColor(color2); int image = getArguments().getInt(KEY_IMAGE_ID); ((ImageView) view.findViewById(R.id.iv_image)).setImageResource(image); return view; } } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/FlipFragmentDemo.java ================================================ package com.avenwu.deepinandroid; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import net.avenwu.support.widget.FlipLayout; /** * Created by aven on 1/19/16. */ public class FlipFragmentDemo extends Fragment { FlipLayout mFlipLayout; @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.flip_layout, null); } @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mFlipLayout = (FlipLayout) view.findViewById(R.id.flip_layout); mFlipLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mFlipLayout.flip(); } }); mFlipLayout.setViewOrder(view.findViewById(R.id.iv_image1), view.findViewById(R.id.iv_image2)); } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/GradientColorFragment.java ================================================ package com.avenwu.deepinandroid; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; /** * Created by chaobin on 3/6/15. */ public class GradientColorFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { return inflater.inflate(R.layout.gradient_layout, null); } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/LargeHeightImageDisplayFragment.java ================================================ package com.avenwu.deepinandroid; import android.content.Context; import android.content.res.AssetManager; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.BitmapRegionDecoder; import android.graphics.Color; import android.graphics.Rect; import android.os.AsyncTask; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v4.os.AsyncTaskCompat; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ScrollView; import java.io.IOException; /** * Created by chaobin on 3/2/15. */ public class LargeHeightImageDisplayFragment extends Fragment { private static final String TAG = LargeHeightImageDisplayFragment.class.getSimpleName(); private ViewGroup mContainer; @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { ScrollView scrollView = new ScrollView(getActivity()); scrollView.setBackgroundColor(Color.WHITE); scrollView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); LinearLayout linearLayout = new LinearLayout(getActivity()); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setLayoutParams(new ScrollView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); mContainer = linearLayout; scrollView.addView(linearLayout); return scrollView; } AsyncTask mDecodeTask; @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { mDecodeTask = new AsyncTask() { @Override protected Object doInBackground(Context... params) { Log.d(TAG, "Start decode image..."); BitmapRegionDecoder decoder = null; try { //TODO According to api document both jpeg and png are supported, however jpeg image just failed to be decoded on this case decoder = BitmapRegionDecoder.newInstance(params[0].getAssets().open("image.png", AssetManager.ACCESS_RANDOM), false); final int screenWidth = params[0].getResources().getDisplayMetrics().widthPixels; final int imageWidth = decoder.getWidth(); final int imageHeight = decoder.getHeight(); final int eachHeight = (int) (screenWidth * ((imageWidth + 0.5f) / screenWidth)); int heightRemained = imageHeight; Rect corpRect = new Rect(0, 0, imageWidth, 0); //TODO the while case is only for test, should only load specific bitmap data when scrolled to be visible while (heightRemained > 0 && !isCancelled()) { Log.d(TAG, "clip image"); if (heightRemained >= eachHeight) { corpRect.set(corpRect.left, corpRect.bottom, corpRect.right, corpRect.bottom + eachHeight); heightRemained -= eachHeight; } else { corpRect.set(corpRect.left, corpRect.bottom, corpRect.right, corpRect.bottom + heightRemained); heightRemained = 0; } Log.d(TAG, "corptBitmap, " + corpRect.toString()); Bitmap corptBitmap = decoder.decodeRegion(corpRect, null); publishProgress(corptBitmap); } Log.d(TAG, "Image decode finished"); } catch (IOException e) { Log.d(TAG, "Image decode failed"); e.printStackTrace(); } finally { if (decoder != null) { decoder.recycle(); } } return null; } @Override protected void onProgressUpdate(Bitmap... values) { if (getActivity() != null && !isRemoving() && values[0] != null) { ImageView imageView = new ImageView(getActivity()); imageView.setScaleType(ImageView.ScaleType.FIT_CENTER); imageView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); imageView.setImageBitmap(values[0]); mContainer.addView(imageView); } } }; AsyncTaskCompat.executeParallel(mDecodeTask, getActivity()); } @Override public void onDestroyView() { if (mContainer != null) { mContainer.removeAllViews(); } if (mDecodeTask != null) { mDecodeTask.cancel(true); } super.onDestroyView(); } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/LinearGradientView.java ================================================ package com.avenwu.deepinandroid; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.LinearGradient; import android.graphics.Paint; import android.graphics.Shader; import android.util.AttributeSet; import android.view.View; /** * Created by chaobin on 3/6/15. */ public class LinearGradientView extends View { Paint mPaint; LinearGradient mGradient; public LinearGradientView(Context context) { this(context, null); } public LinearGradientView(Context context, AttributeSet attrs) { this(context, attrs, 0); } public LinearGradientView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mGradient = new LinearGradient(0, 0, 500, 0, new int[]{ Color.RED, Color.YELLOW, Color.GREEN }, null, Shader.TileMode.CLAMP); mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint.setShader(mGradient); } @Override protected void onDraw(Canvas canvas) { canvas.drawRect(0, 0, 500, 500, mPaint); } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/MainActivity.java ================================================ package com.avenwu.deepinandroid; import android.content.Intent; import android.graphics.drawable.RippleDrawable; import android.os.Bundle; import android.support.v4.app.DialogFragment; import android.support.v4.app.Fragment; import android.support.v7.app.ActionBarActivity; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Toast; import com.avenwu.annotation.PrintMe; @PrintMe public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void showShortcut(View view) { startActivity(new Intent(this, ShortcutDemo.class)); } @PrintMe public void showDrawerFrame(View view) { // Intent intent = new Intent(this, RefreshWidgetActivity.class); // intent.putExtra("fragment", DrawerDemoFragment.class); // startActivity(intent); } @PrintMe public void showRefreshLayout(View view) { // Intent intent = new Intent(this, RefreshWidgetActivity.class); // intent.putExtra("fragment", RefreshDemoFragment.class); // startActivity(intent); } public void openActivity(View view) { try { startActivity(new Intent(this, Class.forName((String) view.getTag()))); } catch (ClassNotFoundException e) { error(e); } } public void openFragment(View view) { try { getSupportFragmentManager().beginTransaction() .add(R.id.container, (Fragment) Class.forName((String) view.getTag()).newInstance(), "fragment") .addToBackStack(null) .commitAllowingStateLoss(); } catch (InstantiationException e) { error(e); } catch (IllegalAccessException e) { error(e); } catch (ClassNotFoundException e) { error(e); } } private void error(Exception e) { e.printStackTrace(); Toast.makeText(this, e.getLocalizedMessage(), Toast.LENGTH_SHORT).show(); } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/MarkdownDemo.java ================================================ package com.avenwu.deepinandroid; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentTransaction; import android.support.v4.view.ViewPager; import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarActivity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.webkit.WebView; import android.widget.EditText; import org.markdown4j.Markdown4jProcessor; import java.io.IOException; import java.util.Locale; import butterknife.ButterKnife; import butterknife.InjectView; public class MarkdownDemo extends ActionBarActivity implements ActionBar.TabListener, Content { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_markdown_demo); // Set up the action bar. final ActionBar actionBar = getSupportActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primary sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBar.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { actionBar.addTab( actionBar.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Override public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { mViewPager.setCurrentItem(tab.getPosition()); } @Override public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { } @Override public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { } private static String makeFragmentName(int viewId, long id) { return "android:switcher:" + viewId + ":" + id; } @Override public String getContent() { Fragment fragment = getSupportFragmentManager().findFragmentByTag(makeFragmentName(mViewPager.getId(), 0)); if (fragment instanceof Content) { return ((Content) fragment).getContent(); } return ""; } /** * A {@link FragmentPagerAdapter} that returns a fragment corresponding to * one of the sections/tabs/pages. */ public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Override public Fragment getItem(int position) { switch (position) { case 0: return new EditFragment(); default: return new PreviewFragment(); } } @Override public int getCount() { return 2; } @Override public CharSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class EditFragment extends Fragment implements Content { @InjectView(R.id.edt_input) EditText mInputView; // String TEMPLATE_DATA = "#Hello\nThis is simple text in format of markdown.\n- li\n- li"; String TEMPLATE_DATA = "# Mou\n" + "\n" + "![Mou icon](http://25.io/mou/Mou_128.png)\n" + "\n" + "## Overview\n" + "\n" + "**Mou**, the missing Markdown editor for *web developers*.\n" + "\n" + "### Syntax\n" + "\n" + "#### Strong and Emphasize \n" + "\n" + "**strong** or __strong__ ( Cmd + B )\n" + "\n" + "*emphasize* or _emphasize_ ( Cmd + I )\n" + "\n" + "**Sometimes I want a lot of text to be bold.\n" + "Like, seriously, a _LOT_ of text**\n" + "\n" + "#### Blockquotes\n" + "\n" + "> Right angle brackets > are used for block quotes.\n" + "\n" + "#### Links and Email\n" + "\n" + "An email link.\n" + "\n" + "Simple inline link , another inline link [Smaller](http://25.io/smaller/), one more inline link with title [Resize](http://resizesafari.com \"a Safari extension\").\n" + "\n" + "A [reference style][id] link. Input id, then anywhere in the doc, define the link with corresponding id:\n" + "\n" + "[id]: http://25.io/mou/ \"Markdown editor on Mac OS X\"\n" + "\n" + "Titles ( or called tool tips ) in the links are optional.\n" + "\n" + "#### Images\n" + "\n" + "An inline image ![Smaller icon](http://25.io/smaller/favicon.ico \"Title here\"), title is optional.\n" + "\n" + "A ![Resize icon][2] reference style image.\n" + "\n" + "[2]: http://resizesafari.com/favicon.ico \"Title\"\n" + "\n" + "#### Inline code and Block code\n" + "\n" + "Inline code are surround by `backtick` key. To create a block code:\n" + "\n" + "\tIndent each line by at least 1 tab, or 4 spaces.\n" + " var Mou = exactlyTheAppIwant; \n" + "\n" + "#### Ordered Lists\n" + "\n" + "Ordered lists are created using \"1.\" + Space:\n" + "\n" + "1. Ordered list item\n" + "2. Ordered list item\n" + "3. Ordered list item\n" + "\n" + "#### Unordered Lists\n" + "\n" + "Unordered list are created using \"*\" + Space:\n" + "\n" + "* Unordered list item\n" + "* Unordered list item\n" + "* Unordered list item \n" + "\n" + "Or using \"-\" + Space:\n" + "\n" + "- Unordered list item\n" + "- Unordered list item\n" + "- Unordered list item\n" + "\n" + "#### Hard Linebreak\n" + "\n" + "End a line with two or more spaces will create a hard linebreak, called `
` in HTML. ( Control + Return ) \n" + "Above line ended with 2 spaces.\n" + "\n" + "#### Horizontal Rules\n" + "\n" + "Three or more asterisks or dashes:\n" + "\n" + "***\n" + "\n" + "---\n" + "\n" + "- - - -\n" + "\n" + "#### Headers\n" + "\n" + "Setext-style:\n" + "\n" + "This is H1\n" + "==========\n" + "\n" + "This is H2\n" + "----------\n" + "\n" + "atx-style:\n" + "\n" + "# This is H1\n" + "## This is H2\n" + "### This is H3\n" + "#### This is H4\n" + "##### This is H5\n" + "###### This is H6\n" + "\n" + "\n" + "### Extra Syntax\n" + "\n" + "#### Footnotes\n" + "\n" + "Footnotes work mostly like reference-style links. A footnote is made of two things: a marker in the text that will become a superscript number; a footnote definition that will be placed in a list of footnotes at the end of the document. A footnote looks like this:\n" + "\n" + "That's some text with a footnote.[^1]\n" + "\n" + "[^1]: And that's the footnote.\n" + "\n" + "\n" + "#### Strikethrough\n" + "\n" + "Wrap with 2 tilde characters:\n" + "\n" + "~~Strikethrough~~\n" + "\n" + "\n" + "#### Fenced Code Blocks\n" + "\n" + "Start with a line containing 3 or more backticks, and ends with the first line with the same number of backticks:\n" + "\n" + "```\n" + "Fenced code blocks are like Stardard Markdown’s regular code\n" + "blocks, except that they’re not indented and instead rely on\n" + "a start and end fence lines to delimit the code block.\n" + "```\n" + "\n" + "\n" + "### Shortcuts\n" + "\n" + "#### View\n" + "\n" + "* Toggle live preview: Shift + Cmd + I\n" + "* Toggle Words Counter: Shift + Cmd + W\n" + "* Toggle Transparent: Shift + Cmd + T\n" + "* Toggle Floating: Shift + Cmd + F\n" + "* Left/Right = 1/1: Cmd + 0\n" + "* Left/Right = 3/1: Cmd + +\n" + "* Left/Right = 1/3: Cmd + -\n" + "* Toggle Writing orientation: Cmd + L\n" + "* Toggle fullscreen: Control + Cmd + F\n" + "\n" + "#### Actions\n" + "\n" + "* Copy HTML: Option + Cmd + C\n" + "* Strong: Select text, Cmd + B\n" + "* Emphasize: Select text, Cmd + I\n" + "* Inline Code: Select text, Cmd + K\n" + "* Strikethrough: Select text, Cmd + U\n" + "* Link: Select text, Control + Shift + L\n" + "* Image: Select text, Control + Shift + I\n" + "* Select Word: Control + Option + W\n" + "* Select Line: Shift + Cmd + L\n" + "* Select All: Cmd + A\n" + "* Deselect All: Cmd + D\n" + "* Convert to Uppercase: Select text, Control + U\n" + "* Convert to Lowercase: Select text, Control + Shift + U\n" + "* Convert to Titlecase: Select text, Control + Option + U\n" + "* Convert to List: Select lines, Control + L\n" + "* Convert to Blockquote: Select lines, Control + Q\n" + "* Convert to H1: Cmd + 1\n" + "* Convert to H2: Cmd + 2\n" + "* Convert to H3: Cmd + 3\n" + "* Convert to H4: Cmd + 4\n" + "* Convert to H5: Cmd + 5\n" + "* Convert to H6: Cmd + 6\n" + "* Convert Spaces to Tabs: Control + [\n" + "* Convert Tabs to Spaces: Control + ]\n" + "* Insert Current Date: Control + Shift + 1\n" + "* Insert Current Time: Control + Shift + 2\n" + "* Insert entity <: Control + Shift + ,\n" + "* Insert entity >: Control + Shift + .\n" + "* Insert entity &: Control + Shift + 7\n" + "* Insert entity Space: Control + Shift + Space\n" + "* Insert Scriptogr.am Header: Control + Shift + G\n" + "* Shift Line Left: Select lines, Cmd + [\n" + "* Shift Line Right: Select lines, Cmd + ]\n" + "* New Line: Cmd + Return\n" + "* Comment: Cmd + /\n" + "* Hard Linebreak: Control + Return\n" + "\n" + "#### Edit\n" + "\n" + "* Auto complete current word: Esc\n" + "* Find: Cmd + F\n" + "* Close find bar: Esc\n" + "\n" + "#### Post\n" + "\n" + "* Post on Scriptogr.am: Control + Shift + S\n" + "* Post on Tumblr: Control + Shift + T\n" + "\n" + "#### Export\n" + "\n" + "* Export HTML: Option + Cmd + E\n" + "* Export PDF: Option + Cmd + P\n" + "\n" + "\n" + "### And more?\n" + "\n" + "Don't forget to check Preferences, lots of useful options are there.\n" + "\n" + "Follow [@Mou](https://twitter.com/mou) on Twitter for the latest news.\n" + "\n" + "For feedback, use the menu `Help` - `Send Feedback`"; public EditFragment() { } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.markdown_edit, container, false); ButterKnife.inject(this, rootView); mInputView.setText(TEMPLATE_DATA); return rootView; } @Override public String getContent() { return mInputView.getText().toString(); } } public static class PreviewFragment extends Fragment { private WebView mWebView; private boolean mIsWebViewAvailable; private Markdown4jProcessor mProcessor; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (mWebView != null) { mWebView.destroy(); } mWebView = new WebView(getActivity()); mIsWebViewAvailable = true; mProcessor = new Markdown4jProcessor(); return mWebView; } @Override public void onPause() { super.onPause(); mWebView.onPause(); } @Override public void onResume() { mWebView.onResume(); super.onResume(); } @Override public void setUserVisibleHint(boolean isVisibleToUser) { super.setUserVisibleHint(isVisibleToUser); if (isVisibleToUser) { String data = ((Content) getActivity()).getContent(); mWebView.loadData(renderMarkdownString(data), "text/html", "UTF-8"); } } String mTemplate = "
%s
"; String renderMarkdownString(String raw) { try { return String.format(mTemplate, mProcessor.process(raw)); } catch (IOException e) { e.printStackTrace(); return String.format(mTemplate, raw); } } @Override public void onDestroyView() { mIsWebViewAvailable = false; super.onDestroyView(); } @Override public void onDestroy() { if (mWebView != null) { mWebView.destroy(); mWebView = null; } super.onDestroy(); } } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/QQDraggingCircleDemo.java ================================================ package com.avenwu.deepinandroid; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.widget.SeekBar; import net.avenwu.support.widget.PolygonWithQuadraticBezirView; import butterknife.ButterKnife; import butterknife.InjectView; /** * Created by chaobin on 12/25/14. */ public class QQDraggingCircleDemo extends ActionBarActivity { @InjectView(R.id.shape2) PolygonWithQuadraticBezirView mShape2; @InjectView(R.id.shape1) PolygonWithQuadraticBezirView mShape1; @InjectView(R.id.seekBarX) SeekBar mSeekX; @InjectView(R.id.seekBarY) SeekBar mSeekY; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.qq_dragging_circle_layout); ButterKnife.inject(this); mShape2.setFilled(true); mSeekX.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mShape1.moveHorizontal(progress / 100.0f); mShape2.moveHorizontal(progress / 100.0f); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mSeekY.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mShape1.moveVertical(progress / 100.0f); mShape2.moveVertical(progress / 100.0f); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/RefreshDemoFragment.java ================================================ package com.avenwu.deepinandroid; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.SimpleAdapter; import net.avenwu.support.widget.RefreshLayout; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * Created by Chaobin Wu on 2014/10/10. */ public class RefreshDemoFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { RefreshLayout view = new RefreshLayout(getActivity()); view.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); view.setBackgroundColor(getResources().getColor(android.R.color.holo_purple)); List> data = new ArrayList>(30); for (int i = 0; i < 20; i++) { Map item = new HashMap(2); item.put("index", i + ""); item.put("text", "This is content " + i); data.add(item); } view.setAdapter(new SimpleAdapter(getActivity(), data, android.R.layout.simple_list_item_2, new String[]{"index", "text"}, new int[]{android.R.id.text1, android.R.id.text2})); return view; } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/RefreshWidgetActivity.java ================================================ package com.avenwu.deepinandroid; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v7.app.ActionBarActivity; public class RefreshWidgetActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_refresh_widget); try { getSupportFragmentManager().beginTransaction() .replace(R.id.container, (Fragment) (((Class) getIntent().getSerializableExtra("fragment")).newInstance())) .commitAllowingStateLoss(); } catch (Exception e) { e.printStackTrace(); } } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/ScaleSubActivity.java ================================================ /* * Copyright (C) 2013 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 com.avenwu.deepinandroid; import android.app.Activity; import android.os.Bundle; import android.view.ViewTreeObserver; import android.view.animation.DecelerateInterpolator; import android.widget.ImageView; /** * See WindowAnimations.java for comments on the overall application. *

* This is a sub-activity which provides custom animation behavior. When this activity * is exited, the user will see the behavior specified in the overridePendingTransition() call. */ public class ScaleSubActivity extends Activity { int leftDeta, topDeta; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_window_scale_sub); final int left = getIntent().getIntExtra("left", 0); final int top = getIntent().getIntExtra("top", 0); final int width = getIntent().getIntExtra("width", 0); final int height = getIntent().getIntExtra("height", 0); final ImageView imageView = (ImageView) findViewById(R.id.image); ViewTreeObserver observer = imageView.getViewTreeObserver(); observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { int[] position = new int[2]; imageView.getLocationOnScreen(position); imageView.getViewTreeObserver().removeOnPreDrawListener(this); leftDeta = left - position[0]; topDeta = top - position[1]; float widthScale = (float) width / imageView.getWidth(); float heightScale = (float) height / imageView.getHeight(); imageView.setPivotX(0); imageView.setPivotY(0); imageView.setTranslationX(leftDeta); imageView.setTranslationY(topDeta); imageView.setScaleX(widthScale); imageView.setScaleY(heightScale); imageView.animate().setDuration(5000).setInterpolator(new DecelerateInterpolator()) .translationX(0).translationX(0).scaleX(1).scaleY(1).start(); return true; } }); } @Override public void finish() { super.finish(); overridePendingTransition(0, 0); } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/ShortcutDemo.java ================================================ package com.avenwu.deepinandroid; import android.app.Activity; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.drawable.AnimationDrawable; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.ImageView; public class ShortcutDemo extends ActionBarActivity { public static String INSTALL_SHORTCUT = "com.android.launcher.action.INSTALL_SHORTCUT"; public static String UNINSTALL_SHORTCUT = "com.android.launcher.action.UNINSTALL_SHORTCUT"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.shorcut_layout); findViewById(R.id.imageView).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AnimationDrawable animationDrawable = (AnimationDrawable) ((ImageView) v).getDrawable(); animationDrawable.start(); } }); findViewById(R.id.btn_install).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { shortcutAdd("测试", count++, ShortcutDemo.class); } }); findViewById(R.id.btn_uninstall).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { shortcutDel("测试", ShortcutDemo.class); } }); } public static int count = 0; private void shortcutAdd(String name, int number, Class cls) { // Intent to be send, when shortcut is pressed by user ("launched") Intent shortcutIntent = new Intent(getApplicationContext(), cls); shortcutIntent.setAction(Intent.ACTION_MAIN); shortcutIntent.addCategory(Intent.CATEGORY_LAUNCHER); // Create bitmap with number in it -> very default. You probably want to give it a more stylish look Bitmap bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888); Paint paint = new Paint(); paint.setColor(0xFF808080); // gray paint.setTextAlign(Paint.Align.CENTER); paint.setTextSize(50); new Canvas(bitmap).drawText("" + number, 50, 50, paint); // Decorate the shortcut Intent addIntent = new Intent(); addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, name); addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON, bitmap); // Inform launcher to create shortcut addIntent.setAction(INSTALL_SHORTCUT); getApplicationContext().sendBroadcast(addIntent); } private void shortcutDel(String name, Class cls) { // Intent to be send, when shortcut is pressed by user ("launched") Intent shortcutIntent = new Intent(getApplicationContext(), cls); shortcutIntent.setAction(Intent.ACTION_MAIN); shortcutIntent.addCategory(Intent.CATEGORY_LAUNCHER); // Decorate the shortcut Intent delIntent = new Intent(); delIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); delIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, name); // Inform launcher to remove shortcut delIntent.setAction(UNINSTALL_SHORTCUT); getApplicationContext().sendBroadcast(delIntent); } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/SlideMenuFragment.java ================================================ package com.avenwu.deepinandroid; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v4.widget.DrawerLayout; import android.support.v4.widget.SlidingPaneLayout; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import net.avenwu.support.widget.DrawerFrameV2; /** * Created by chaobin on 2/16/15. */ public class SlideMenuFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { DrawerFrameV2 view = (DrawerFrameV2) inflater.inflate(R.layout.slide_layout, null); return view; // DrawerLayout // SlidingPaneLayout } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/SlidePanelDemo.java ================================================ package com.avenwu.deepinandroid; import android.graphics.Color; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; /** * Created by chaobin on 2/18/15. */ public class SlidePanelDemo extends ActionBarActivity { int[] mColors = {Color.RED, Color.BLUE, Color.CYAN, Color.GREEN, Color.YELLOW}; ViewGroup mContentView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.slidepanel_layout); mContentView = (ViewGroup) findViewById(R.id.fl_container); // ListView menuList = (ListView) findViewById(R.id.lv_memu_list); // menuList.setAdapter(new ArrayAdapter( // this, // android.R.layout.simple_list_item_1, // android.R.id.text1, // new String[]{"RED", "BLUE", "CYAN", "GREEN", "YELLOW"} // )); // menuList.setOnItemClickListener(new AdapterView.OnItemClickListener() { // @Override // public void onItemClick(AdapterView parent, View view, int position, long id) { // mContentView.setBackgroundColor(mColors[position]); // } // }); mContentView.setBackgroundColor(0xff03a9f4); } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/StackZFragment.java ================================================ package com.avenwu.deepinandroid; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v4.view.ViewCompat; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; /** * Created by aven on 1/27/16. */ public class StackZFragment extends Fragment { @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.fragment_stack_z, null); } @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); int count = ((ViewGroup) view).getChildCount(); for (int i = 0; i < count; i++) { View card = ((ViewGroup) view).getChildAt(i); ViewCompat.setTranslationZ(card, (i + 1) * 8 * getResources().getDisplayMetrics().density); } } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/StyledRadioButtonDemo.java ================================================ package com.avenwu.deepinandroid; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.widget.LinearLayout; import net.avenwu.support.widget.FlatTabGroup; import butterknife.InjectView; /** * Created by chaobin on 2/4/15. */ public class StyledRadioButtonDemo extends ActionBarActivity { @InjectView(R.id.ll_container) LinearLayout mContainer; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.styled_radio_button); } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/TagInputDemo.java ================================================ package com.avenwu.deepinandroid; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.view.View; import android.widget.TextView; import net.avenwu.support.widget.TagFlowLayout; /** * Created by chaobin on 1/14/15. */ public class TagInputDemo extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // setContentView(new TagInputLayout(this)); setContentView(R.layout.test_tag_input_layout); // ((TagInputLayout) findViewById(R.id.tags)).setDecorator(new TagInputLayout.SimpleDecorator(this) { // Drawable[] mDrawable = new Drawable[]{ // getResources().getDrawable(R.drawable.b1), // getResources().getDrawable(R.drawable.b2) // }; // // @Override // public Drawable[] getBackgroundDrawable() { // return mDrawable; // } // }); } public void onGetTags(View view) { TextView tv = (TextView) findViewById(R.id.tv_tags); tv.setText("All tags:\n"); for (CharSequence tag : ((TagFlowLayout) findViewById(R.id.tags)).getTagArray()) { tv.append(tag); tv.append(" "); } } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/TypefaceActivity.java ================================================ package com.avenwu.deepinandroid; import android.content.Context; import android.graphics.Typeface; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.widget.TextView; import net.avenwu.support.util.TypefaceContextWrapper; import net.avenwu.support.util.TypefaceUtils; public class TypefaceActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_typeface); //1. 直接设置TextView setTypeface final Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/Oswald-Stencbab" + ".ttf"); TextView textView = (TextView) findViewById(R.id.tv_label_font); textView.setTypeface(typeface); //2. 缓存/复用Typeface,避免内存浪费 TypefaceUtils.setTypeface(this, (TextView) findViewById(R.id.tv_label_font_2), "fonts/Roboto-Bold.ttf"); //3. 自定义LayoutInflator } @Override protected void attachBaseContext(Context newBase) { super.attachBaseContext(TypefaceContextWrapper.wrap(newBase)); } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/WindowAnimationFragment.java ================================================ package com.avenwu.deepinandroid; import android.app.ActivityOptions; import android.content.Intent; import android.graphics.BitmapFactory; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.TransitionDrawable; import android.os.Build; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; /** * Created by aven on 4/26/15. */ public class WindowAnimationFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.animation_layout, null); view.findViewById(R.id.button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { // Using the AnimatedSubActivity also allows us to animate exiting that // activity - see that activity for details Intent subActivity = new Intent(v.getContext(), AnimatedSubActivity.class); // The enter/exit animations for the two activities are specified by xml resources Bundle translateBundle = ActivityOptions.makeCustomAnimation(v.getContext(), R.anim.slide_in_left, R.anim.slide_out_left).toBundle(); getActivity().startActivity(subActivity, translateBundle); } else { getActivity().overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_left); getActivity().startActivity(new Intent(v.getContext(), AnimatedSubActivity.class)); } } }); view.findViewById(R.id.image).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent subActivity = new Intent(v.getContext(), AnimatedSubActivity.class); // Bundle scaleBundle = ActivityOptions.makeScaleUpAnimation( // v, 0, 0, v.getWidth(), v.getHeight()).toBundle(); // getActivity().startActivity(subActivity, scaleBundle); v.setDrawingCacheEnabled(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { getActivity().startActivity(subActivity, ActivityOptions.makeThumbnailScaleUpAnimation(v, v.getDrawingCache(), 0, 0).toBundle()); } else { getActivity().overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_left); getActivity().startActivity(new Intent(v.getContext(), AnimatedSubActivity.class)); } } }); return view; } @Override public void onViewCreated(View view, Bundle savedInstanceState) { ImageView imageView = (ImageView) view.findViewById(R.id.image2); BitmapDrawable[] bitmapDrawable = new BitmapDrawable[2]; bitmapDrawable[0] = new BitmapDrawable(getResources(), BitmapFactory.decodeResource(getResources(), R.drawable.image1)); bitmapDrawable[1] = new BitmapDrawable(getResources(), BitmapFactory.decodeResource(getResources(), R.drawable.image2)); final TransitionDrawable drawable = new TransitionDrawable(bitmapDrawable); imageView.setImageDrawable(drawable); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (currentDrawable == 0) { drawable.startTransition(500); currentDrawable = 1; } else { drawable.reverseTransition(500); currentDrawable = 0; } } }); view.findViewById(R.id.image3).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int[] position = new int[2]; v.getLocationOnScreen(position); startActivity(new Intent(getActivity(), ScaleSubActivity.class) .putExtra("left", position[0]).putExtra("top", position[1]) .putExtra("width", v.getWidth()).putExtra("height", v.getHeight())); } }); } int currentDrawable = 0; } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/eventbus/Bus.java ================================================ package com.avenwu.deepinandroid.eventbus; import android.os.Looper; import java.lang.reflect.Method; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.CopyOnWriteArrayList; /** * Created by chaobin on 1/29/15. */ public class Bus { static volatile Bus sInstance; Finder mFinder; Map, CopyOnWriteArrayList> mSubscriberMap; PostHandler mPostHandler; private Bus() { mFinder = new NameBasedFinder(); mSubscriberMap = new HashMap<>(); mPostHandler = new PostHandler(Looper.getMainLooper(), this); } public static Bus getDefault() { if (sInstance == null) { synchronized (Bus.class) { if (sInstance == null) { sInstance = new Bus(); } } } return sInstance; } public void register(Object subscriber) { List methods = mFinder.findSubscriber(subscriber.getClass()); if (methods == null || methods.size() < 1) { return; } CopyOnWriteArrayList subscribers = mSubscriberMap.get(subscriber.getClass()); if (subscribers == null) { subscribers = new CopyOnWriteArrayList<>(); mSubscriberMap.put(methods.get(0).getParameterTypes()[0], subscribers); } for (Method method : methods) { Subscriber newSubscriber = new Subscriber(subscriber, method); subscribers.add(newSubscriber); } } public void unregister(Object subscriber) { CopyOnWriteArrayList subscribers = mSubscriberMap.remove(subscriber.getClass()); if (subscribers != null) { for (Subscriber s : subscribers) { s.mMethod = null; s.mSubscriber = null; } } } public void post(Object event) { //TODO post with handler mPostHandler.enqueue(event); } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/eventbus/Finder.java ================================================ package com.avenwu.deepinandroid.eventbus; import java.lang.reflect.Method; import java.util.List; /** * Created by chaobin on 1/29/15. */ public interface Finder { List findSubscriber(Class subscriber); } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/eventbus/NameBasedFinder.java ================================================ package com.avenwu.deepinandroid.eventbus; import android.util.Log; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; /** * Created by chaobin on 1/29/15. */ public class NameBasedFinder implements Finder { @Override public List findSubscriber(Class subscriber) { List methods = new ArrayList<>(); for (Method method : subscriber.getDeclaredMethods()) { if (method.getName().startsWith("onEvent") && method.getParameterTypes().length == 1) { methods.add(method); Log.d("findSubscriber", "add method:" + method.getName()); } } return methods; } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/eventbus/PostHandler.java ================================================ package com.avenwu.deepinandroid.eventbus; import android.os.Handler; import android.os.Looper; import android.os.Message; import java.util.concurrent.CopyOnWriteArrayList; /** * Created by chaobin on 1/29/15. */ public class PostHandler extends Handler { final Bus mBus; public PostHandler(Looper looper, Bus bus) { super(looper); mBus = bus; } @Override public void handleMessage(Message msg) { CopyOnWriteArrayList subscribers = mBus.mSubscriberMap.get(msg.obj.getClass()); for (Subscriber subscriber : subscribers) { subscriber.mMethod.setAccessible(true); try { subscriber.mMethod.invoke(subscriber.mSubscriber, msg.obj); } catch (Exception e) { e.printStackTrace(); } } } void enqueue(Object event) { Message message = obtainMessage(); message.obj = event; sendMessage(message); } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/eventbus/Subscriber.java ================================================ package com.avenwu.deepinandroid.eventbus; import java.lang.reflect.Method; /** * Created by chaobin on 1/29/15. */ public class Subscriber { Object mSubscriber; Method mMethod; Class mEventType; public Subscriber(Object subscriber, Method method) { mSubscriber = subscriber; mMethod = method; mEventType = method.getParameterTypes()[0]; } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/util/SystemUiHider.java ================================================ package com.avenwu.deepinandroid.util; import android.app.Activity; import android.os.Build; import android.view.View; /** * A utility class that helps with showing and hiding system UI such as the * status bar and navigation/system bar. This class uses backward-compatibility * techniques described in * Creating Backward-Compatible UIs to ensure that devices running any * version of Android OS are supported. More specifically, there are separate * implementations of this abstract class: for newer devices, * {@link #getInstance} will return a {@link SystemUiHiderHoneycomb} instance, * while on older devices {@link #getInstance} will return a * {@link SystemUiHiderBase} instance. *

* For more on system bars, see System Bars. * * @see android.view.View#setSystemUiVisibility(int) * @see android.view.WindowManager.LayoutParams#FLAG_FULLSCREEN */ public abstract class SystemUiHider { /** * When this flag is set, the * {@link android.view.WindowManager.LayoutParams#FLAG_LAYOUT_IN_SCREEN} * flag will be set on older devices, making the status bar "float" on top * of the activity layout. This is most useful when there are no controls at * the top of the activity layout. *

* This flag isn't used on newer devices because the action * bar, the most important structural element of an Android app, should * be visible and not obscured by the system UI. */ public static final int FLAG_LAYOUT_IN_SCREEN_OLDER_DEVICES = 0x1; /** * When this flag is set, {@link #show()} and {@link #hide()} will toggle * the visibility of the status bar. If there is a navigation bar, show and * hide will toggle low profile mode. */ public static final int FLAG_FULLSCREEN = 0x2; /** * When this flag is set, {@link #show()} and {@link #hide()} will toggle * the visibility of the navigation bar, if it's present on the device and * the device allows hiding it. In cases where the navigation bar is present * but cannot be hidden, show and hide will toggle low profile mode. */ public static final int FLAG_HIDE_NAVIGATION = FLAG_FULLSCREEN | 0x4; /** * The activity associated with this UI hider object. */ protected Activity mActivity; /** * The view on which {@link View#setSystemUiVisibility(int)} will be called. */ protected View mAnchorView; /** * The current UI hider flags. * * @see #FLAG_FULLSCREEN * @see #FLAG_HIDE_NAVIGATION * @see #FLAG_LAYOUT_IN_SCREEN_OLDER_DEVICES */ protected int mFlags; /** * The current visibility callback. */ protected OnVisibilityChangeListener mOnVisibilityChangeListener = sDummyListener; /** * Creates and returns an instance of {@link SystemUiHider} that is * appropriate for this device. The object will be either a * {@link SystemUiHiderBase} or {@link SystemUiHiderHoneycomb} depending on * the device. * * @param activity The activity whose window's system UI should be * controlled by this class. * @param anchorView The view on which * {@link View#setSystemUiVisibility(int)} will be called. * @param flags Either 0 or any combination of {@link #FLAG_FULLSCREEN}, * {@link #FLAG_HIDE_NAVIGATION}, and * {@link #FLAG_LAYOUT_IN_SCREEN_OLDER_DEVICES}. */ public static SystemUiHider getInstance(Activity activity, View anchorView, int flags) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { return new SystemUiHiderHoneycomb(activity, anchorView, flags); } else { return new SystemUiHiderBase(activity, anchorView, flags); } } protected SystemUiHider(Activity activity, View anchorView, int flags) { mActivity = activity; mAnchorView = anchorView; mFlags = flags; } /** * Sets up the system UI hider. Should be called from * {@link Activity#onCreate}. */ public abstract void setup(); /** * Returns whether or not the system UI is visible. */ public abstract boolean isVisible(); /** * Hide the system UI. */ public abstract void hide(); /** * Show the system UI. */ public abstract void show(); /** * Toggle the visibility of the system UI. */ public void toggle() { if (isVisible()) { hide(); } else { show(); } } /** * Registers a callback, to be triggered when the system UI visibility * changes. */ public void setOnVisibilityChangeListener(OnVisibilityChangeListener listener) { if (listener == null) { listener = sDummyListener; } mOnVisibilityChangeListener = listener; } /** * A dummy no-op callback for use when there is no other listener set. */ private static OnVisibilityChangeListener sDummyListener = new OnVisibilityChangeListener() { @Override public void onVisibilityChange(boolean visible) { } }; /** * A callback interface used to listen for system UI visibility changes. */ public interface OnVisibilityChangeListener { /** * Called when the system UI visibility has changed. * * @param visible True if the system UI is visible. */ public void onVisibilityChange(boolean visible); } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/util/SystemUiHiderBase.java ================================================ package com.avenwu.deepinandroid.util; import android.app.Activity; import android.view.View; import android.view.WindowManager; /** * A base implementation of {@link SystemUiHider}. Uses APIs available in all * API levels to show and hide the status bar. */ public class SystemUiHiderBase extends SystemUiHider { /** * Whether or not the system UI is currently visible. This is a cached value * from calls to {@link #hide()} and {@link #show()}. */ private boolean mVisible = true; /** * Constructor not intended to be called by clients. Use * {@link SystemUiHider#getInstance} to obtain an instance. */ protected SystemUiHiderBase(Activity activity, View anchorView, int flags) { super(activity, anchorView, flags); } @Override public void setup() { if ((mFlags & FLAG_LAYOUT_IN_SCREEN_OLDER_DEVICES) == 0) { mActivity.getWindow().setFlags( WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); } } @Override public boolean isVisible() { return mVisible; } @Override public void hide() { if ((mFlags & FLAG_FULLSCREEN) != 0) { mActivity.getWindow().setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } mOnVisibilityChangeListener.onVisibilityChange(false); mVisible = false; } @Override public void show() { if ((mFlags & FLAG_FULLSCREEN) != 0) { mActivity.getWindow().setFlags( 0, WindowManager.LayoutParams.FLAG_FULLSCREEN); } mOnVisibilityChangeListener.onVisibilityChange(true); mVisible = true; } } ================================================ FILE: sample/src/main/java/com/avenwu/deepinandroid/util/SystemUiHiderHoneycomb.java ================================================ package com.avenwu.deepinandroid.util; import android.annotation.TargetApi; import android.app.Activity; import android.os.Build; import android.view.View; import android.view.WindowManager; /** * An API 11+ implementation of {@link SystemUiHider}. Uses APIs available in * Honeycomb and later (specifically {@link View#setSystemUiVisibility(int)}) to * show and hide the system UI. */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) public class SystemUiHiderHoneycomb extends SystemUiHiderBase { /** * Flags for {@link View#setSystemUiVisibility(int)} to use when showing the * system UI. */ private int mShowFlags; /** * Flags for {@link View#setSystemUiVisibility(int)} to use when hiding the * system UI. */ private int mHideFlags; /** * Flags to test against the first parameter in * {@link android.view.View.OnSystemUiVisibilityChangeListener#onSystemUiVisibilityChange(int)} * to determine the system UI visibility state. */ private int mTestFlags; /** * Whether or not the system UI is currently visible. This is cached from * {@link android.view.View.OnSystemUiVisibilityChangeListener}. */ private boolean mVisible = true; /** * Constructor not intended to be called by clients. Use * {@link SystemUiHider#getInstance} to obtain an instance. */ protected SystemUiHiderHoneycomb(Activity activity, View anchorView, int flags) { super(activity, anchorView, flags); mShowFlags = View.SYSTEM_UI_FLAG_VISIBLE; mHideFlags = View.SYSTEM_UI_FLAG_LOW_PROFILE; mTestFlags = View.SYSTEM_UI_FLAG_LOW_PROFILE; if ((mFlags & FLAG_FULLSCREEN) != 0) { // If the client requested fullscreen, add flags relevant to hiding // the status bar. Note that some of these constants are new as of // API 16 (Jelly Bean). It is safe to use them, as they are inlined // at compile-time and do nothing on pre-Jelly Bean devices. mShowFlags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; mHideFlags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_FULLSCREEN; } if ((mFlags & FLAG_HIDE_NAVIGATION) != 0) { // If the client requested hiding navigation, add relevant flags. mShowFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; mHideFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; mTestFlags |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; } } /** * {@inheritDoc} */ @Override public void setup() { mAnchorView.setOnSystemUiVisibilityChangeListener(mSystemUiVisibilityChangeListener); } /** * {@inheritDoc} */ @Override public void hide() { mAnchorView.setSystemUiVisibility(mHideFlags); } /** * {@inheritDoc} */ @Override public void show() { mAnchorView.setSystemUiVisibility(mShowFlags); } /** * {@inheritDoc} */ @Override public boolean isVisible() { return mVisible; } private View.OnSystemUiVisibilityChangeListener mSystemUiVisibilityChangeListener = new View.OnSystemUiVisibilityChangeListener() { @Override public void onSystemUiVisibilityChange(int vis) { // Test against mTestFlags to see if the system UI is visible. if ((vis & mTestFlags) != 0) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { // Pre-Jelly Bean, we must manually hide the action bar // and use the old window flags API. mActivity.getActionBar().hide(); mActivity.getWindow().setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } // Trigger the registered listener and cache the visibility // state. mOnVisibilityChangeListener.onVisibilityChange(false); mVisible = false; } else { mAnchorView.setSystemUiVisibility(mShowFlags); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { // Pre-Jelly Bean, we must manually show the action bar // and use the old window flags API. mActivity.getActionBar().show(); mActivity.getWindow().setFlags( 0, WindowManager.LayoutParams.FLAG_FULLSCREEN); } // Trigger the registered listener and cache the visibility // state. mOnVisibilityChangeListener.onVisibilityChange(true); mVisible = true; } } }; } ================================================ FILE: sample/src/main/res/anim/scale_up_left.xml ================================================ ================================================ FILE: sample/src/main/res/anim/scale_up_rightt.xml ================================================ ================================================ FILE: sample/src/main/res/anim/slide_in_left.xml ================================================ ================================================ FILE: sample/src/main/res/anim/slide_in_right.xml ================================================ ================================================ FILE: sample/src/main/res/anim/slide_out_left.xml ================================================ ================================================ FILE: sample/src/main/res/anim/slide_out_right.xml ================================================ ================================================ FILE: sample/src/main/res/color/radio_button_color.xml ================================================ ================================================ FILE: sample/src/main/res/color/radio_button_color_blue.xml ================================================ ================================================ FILE: sample/src/main/res/color/radio_button_color_green.xml ================================================ ================================================ FILE: sample/src/main/res/color/radio_button_color_light_blue.xml ================================================ ================================================ FILE: sample/src/main/res/color/radio_button_color_orange.xml ================================================ ================================================ FILE: sample/src/main/res/color/radio_button_color_purple.xml ================================================ ================================================ FILE: sample/src/main/res/drawable/animate_drawable.xml ================================================ ================================================ FILE: sample/src/main/res/drawable/flat_round_shape_left.xml ================================================ ================================================ FILE: sample/src/main/res/drawable/flat_round_shape_middle.xml ================================================ ================================================ FILE: sample/src/main/res/drawable/flat_round_shape_right.xml ================================================ ================================================ FILE: sample/src/main/res/layout/activity_main.xml ================================================