From a9a9ec6d75bb3689d368a3dbb4d2cd7df2065252 Mon Sep 17 00:00:00 2001 From: Filip Gruszczynski Date: Thu, 7 May 2015 17:39:28 -0700 Subject: [PATCH] Sample for percent support library. Change-Id: Id16bda966b0e2e920385486e8ee956c8beea2268 --- build/Android.mk | 3 +- build/sdk.atree | 5 ++ samples/SupportPercentDemos/Android.mk | 35 ++++++++ .../SupportPercentDemos/AndroidManifest.xml | 40 +++++++++ .../res/drawable-hdpi/app_sample_code.png | Bin 0 -> 3608 bytes .../res/drawable-mdpi/app_sample_code.png | Bin 0 -> 5198 bytes .../SupportPercentDemos/res/layout/demo_1.xml | 38 ++++++++ .../SupportPercentDemos/res/layout/demo_2.xml | 38 ++++++++ .../res/layout/support_percent_demos.xml | 21 +++++ .../res/values/strings.xml | 19 ++++ .../support/percent/SupportPercentDemos.java | 82 ++++++++++++++++++ 11 files changed, 280 insertions(+), 1 deletion(-) create mode 100644 samples/SupportPercentDemos/Android.mk create mode 100644 samples/SupportPercentDemos/AndroidManifest.xml create mode 100755 samples/SupportPercentDemos/res/drawable-hdpi/app_sample_code.png create mode 100644 samples/SupportPercentDemos/res/drawable-mdpi/app_sample_code.png create mode 100644 samples/SupportPercentDemos/res/layout/demo_1.xml create mode 100644 samples/SupportPercentDemos/res/layout/demo_2.xml create mode 100644 samples/SupportPercentDemos/res/layout/support_percent_demos.xml create mode 100644 samples/SupportPercentDemos/res/values/strings.xml create mode 100644 samples/SupportPercentDemos/src/com/example/android/support/percent/SupportPercentDemos.java diff --git a/build/Android.mk b/build/Android.mk index 5d36d14df..9a27edc9f 100644 --- a/build/Android.mk +++ b/build/Android.mk @@ -113,7 +113,8 @@ ANDROID_SUPPORT_LIBRARIES := \ android-support-v17-leanback \ android-support-multidex \ android-support-multidex-instrumentation \ - android-support-design + android-support-design \ + android-support-percent $(foreach lib, $(ANDROID_SUPPORT_LIBRARIES), $(eval $(call _package_sdk_library,$(lib)))) diff --git a/build/sdk.atree b/build/sdk.atree index 41094a870..c7cb28a89 100644 --- a/build/sdk.atree +++ b/build/sdk.atree @@ -498,6 +498,11 @@ frameworks/support/design/res frameworks/support/design/src/.readme extras/android/support/design/src/.readme ${OUT_DIR}/target/common/obj/PACKAGING/android-support-design_intermediates/android-support-design.jar extras/android/support/design/libs/android-support-design.jar +frameworks/support/percent/AndroidManifest.xml extras/android/support/percent/AndroidManifest.xml +frameworks/support/percent/res extras/android/support/percent/res +frameworks/support/percent/src/.readme extras/android/support/percent/src/.readme +${OUT_DIR}/target/common/obj/PACKAGING/android-support-percent_intermediates/android-support-percent.jar extras/android/support/percent/libs/android-support-percent.jar + ############################################################################## # Tests Component ############################################################################## diff --git a/samples/SupportPercentDemos/Android.mk b/samples/SupportPercentDemos/Android.mk new file mode 100644 index 000000000..6395a84b2 --- /dev/null +++ b/samples/SupportPercentDemos/Android.mk @@ -0,0 +1,35 @@ +# Copyright (C) 2015 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. + +LOCAL_PATH:= $(call my-dir) + +# Build the samples. +# We need to add some special AAPT flags to generate R classes +# for resources that are included from the libraries. +include $(CLEAR_VARS) +LOCAL_PACKAGE_NAME := SupportPercentDemos +LOCAL_MODULE_TAGS := samples +LOCAL_SDK_VERSION := current +LOCAL_SRC_FILES := $(call all-java-files-under, src) +LOCAL_STATIC_JAVA_LIBRARIES := \ + android-support-percent \ + android-support-v4 \ + android-support-v13 +LOCAL_RESOURCE_DIR = \ + $(LOCAL_PATH)/res \ + frameworks/support/percent/res +LOCAL_AAPT_FLAGS := \ + --auto-add-overlay \ + --extra-packages android.support.percent +include $(BUILD_PACKAGE) diff --git a/samples/SupportPercentDemos/AndroidManifest.xml b/samples/SupportPercentDemos/AndroidManifest.xml new file mode 100644 index 000000000..4a7b22b80 --- /dev/null +++ b/samples/SupportPercentDemos/AndroidManifest.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/samples/SupportPercentDemos/res/drawable-hdpi/app_sample_code.png b/samples/SupportPercentDemos/res/drawable-hdpi/app_sample_code.png new file mode 100755 index 0000000000000000000000000000000000000000..66a198496cfb3e77bffb2ca97007e30b2837106a GIT binary patch literal 3608 zcmV+z4(IWSP)>Yjs+!VGP=X>Hec-`Em6es-s;jFtd9cIbfR>gP zFdB^q@$jX-zVr9g)^3~Cop40VIQk#ix^=7O4QOs|hK7cQj_T@~7f_u|Isg&LF_}z_ z>({T(N+b5{*#q_U_4hvd*tdUzAQ*3S6U4Q(cT_u_&N6hsS!+mBQxkoB&t!U{gXj6+ zD(x@MU@+9<=OnhV7t8DI9s7U!`fIQH)dawRjHkZ1xEQiIUvD;BVDH`*sI9HNmFHJ4 zGc7GG1!QmeV`F2jmoE>rA|OXQ@4f%P%P;+DSS;z=cC$ ze<&2vdv`ep->oB z%c41SdT{0P08C7b!)nybd`BKq>E<8p+t3xOi~vBHM-W!t-QfuE`8;s` z{3lSieLLFQ2FS_DS(REaK0dzJ=kx9D>FN3Y(@#Hr3`;kj=9K_IBW^qp2&@PTiV2y( zk&$a~vA-YM+uMLrBFU^`H3{XnNXp8}^18db|BL`Uisg?uhw`}(_QRn=UxSK@3U+QSEF`A39zJ~7+|||f{8LXoHI1F$B{!1AoUnkNeMLR+ z?CdP`UpNn~t*ywlT}&I+Qb8?%0|yS6olfU-Pd@qNCOPM9N)>cuTTuJp0(O2~eI0Ds zQVpv)DwY$MYXdYkHWdZt=YN5R_h1Pwn}#l!g6x)Xn1`!_gHT*l2z7OJzzaO`;qaO) z)b?9%yA>>E^TFfCk8hUJ0+W2_3(K^nkGn|r3?=b!IdkQ!Dh3 zWHxWd0}B>^8URSM4(j|1eV>5cVTZeLv=&Dxm|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3I(++Pf$sxQ&oMp7IRC0 zVjBP-?kvkO{9F9CGfPR9 zkQLd928cxr5Dpoj>pGgIV;BY-Wu{@;UY9J%D6$g`D7kovdm*b`6C6l$`)E?JiByFhVFQPNLEk=NAJ_WS+p+O>;o*RNG?N-8ee+S;gZs4tey zd6mh@dn8k-s^4kb(MEG~v!gZ1vTR=jmli{cqLif$&MZBbMz11zfk2S`pWBbiRkn%HmrV$L)66UWeoa0Nv0_sjAE6A`sYu6AHX{{ye!{mRz=a^%se><954O948u! zGJf}N#cTf<7{KLrv2|-b?d|PE+S_Z#08P_MrK`u|L6RhN-9T|ENUPv59iL`$a&lFW zwzssbis{z+dbAY;RMT~Gxjc>C>lC3k7Bp3C^ECPa=_6_C&8x_(e}zye zL@*d|6bWnsU{Fw1iw$~32CSL`_3@4t7RFFp5M#qSRf5A)&m z>lLpBgF#{r!=Q5jEC%Shwk7~d8CxvIrHdD<-sJT3GzSkIA{L7kn<4QySFc=QczC$# zm|fB6n${#s4ggr7o?#djk+Wl}s&ek^*%jY0#N%<^dh<<3;||@p!IMuuiQSDGinY?AfD7Q40mU9uEf&9>C-A(%ak1*>mR@yM5c%7+$ZJ zlP|tVcXzkd7#ZWz#fyCT`R5(4%QgVzug8TDYX+bgua7S}54X0`+0kJefR>gPdU|?F z=bfFMbar;Gu`#@621qsa-_(*?zoWB*W5TM@R9ghQqB44h}AQags`O97B6ZjTQE+bM1)@cy3wkOyWcZjwp>c_DvpyR_h{Z1OINIiKhBg7%1Yi?@$J+io0NzSjgnf4iF8}}l07*qo IM6N<$f@LhcdjJ3c literal 0 HcmV?d00001 diff --git a/samples/SupportPercentDemos/res/layout/demo_1.xml b/samples/SupportPercentDemos/res/layout/demo_1.xml new file mode 100644 index 000000000..0502e0dc0 --- /dev/null +++ b/samples/SupportPercentDemos/res/layout/demo_1.xml @@ -0,0 +1,38 @@ + + + + + + diff --git a/samples/SupportPercentDemos/res/layout/demo_2.xml b/samples/SupportPercentDemos/res/layout/demo_2.xml new file mode 100644 index 000000000..9fae5ffdf --- /dev/null +++ b/samples/SupportPercentDemos/res/layout/demo_2.xml @@ -0,0 +1,38 @@ + + + + + + diff --git a/samples/SupportPercentDemos/res/layout/support_percent_demos.xml b/samples/SupportPercentDemos/res/layout/support_percent_demos.xml new file mode 100644 index 000000000..80e1bf31b --- /dev/null +++ b/samples/SupportPercentDemos/res/layout/support_percent_demos.xml @@ -0,0 +1,21 @@ + + + diff --git a/samples/SupportPercentDemos/res/values/strings.xml b/samples/SupportPercentDemos/res/values/strings.xml new file mode 100644 index 000000000..cd864c85c --- /dev/null +++ b/samples/SupportPercentDemos/res/values/strings.xml @@ -0,0 +1,19 @@ + + + + + Support Percent Demos + diff --git a/samples/SupportPercentDemos/src/com/example/android/support/percent/SupportPercentDemos.java b/samples/SupportPercentDemos/src/com/example/android/support/percent/SupportPercentDemos.java new file mode 100644 index 000000000..0290eb384 --- /dev/null +++ b/samples/SupportPercentDemos/src/com/example/android/support/percent/SupportPercentDemos.java @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2015 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.example.android.support.percent; + +import android.app.Activity; +import android.app.Fragment; +import android.os.Bundle; +import android.app.FragmentManager; +import android.support.v13.app.FragmentStatePagerAdapter; +import android.support.v4.view.ViewPager; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +public class SupportPercentDemos extends Activity { + private static final String LAYOUT_RESOURCE_ID = "layout_resource_id"; + + private ViewPager mPager; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.support_percent_demos); + mPager = (ViewPager) findViewById(R.id.pager); + mPager.setAdapter(new Adapter(getFragmentManager())); + } + + public static class Adapter extends FragmentStatePagerAdapter { + public Adapter(FragmentManager fm) { + super(fm); + } + + @Override + public Fragment getItem(int position) { + PercentFragment fragment = new PercentFragment(); + Bundle args = new Bundle(); + switch (position) { + case 0: + args.putInt(LAYOUT_RESOURCE_ID, R.layout.demo_1); + break; + case 1: + args.putInt(LAYOUT_RESOURCE_ID, R.layout.demo_2); + default: + break; + } + fragment.setArguments(args); + return fragment; + } + + @Override + public int getCount() { + return 2; + } + } + + public static class PercentFragment extends Fragment { + public PercentFragment() { + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + Bundle args = getArguments(); + int layout = args.getInt(LAYOUT_RESOURCE_ID); + return inflater.inflate(layout, container, false); + } + } +}