From 833e5635702b23fb7fad28377d6cb318b27510d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Lund=C3=A9n?= Date: Sun, 22 Apr 2012 17:44:16 +0200 Subject: [PATCH 001/763] Add missing xhdpi icon to Gallery2 Change-Id: Ie20b8c71e9082f229f66253c0a0a5d7acf6a532c --- res/mipmap-xhdpi/ic_launcher_gallery.png | Bin 0 -> 10650 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 res/mipmap-xhdpi/ic_launcher_gallery.png diff --git a/res/mipmap-xhdpi/ic_launcher_gallery.png b/res/mipmap-xhdpi/ic_launcher_gallery.png new file mode 100644 index 0000000000000000000000000000000000000000..0c3c2ef61843a12ab13f15b0ee0875c93766d7cb GIT binary patch literal 10650 zcmV;LDP`7)P)H_}YwvUJy>F;jQ&$gclFe>4#WpEYlr5QqBiRB12QdPEkYP&!Z1{s^D6s-~ zfMhs|Wee5^83yDJG9b~3jRXo}i$>r$fMS@5C8cF1kSInY)nZE=LN-}F)%@PO!`XW+ zf7tund+thr%E=X%iZAM`oy&WAqqAzpgvC4T9beu?k; zuJ2mC7vPy^o*{(5i!Z*&+u#0nKJ}?j@$$>pnNH6U34{P<%a?C_IK&9Q09{J;q@pWrus<2O)MKK$Vi^O2AIjK2Q^ z@8kUJ91%qo%%q-hB?#5B0IK~0$lxOT-QR!jxErd<$;kyyPtRE_Iz$9_5OGvx`914< zWVzU70TdCzESGa@{TLr=o+F~mbMM)^sFwRG_old)YcAJO{*5uzb9lX;)mM?n{skD1 zM||;%Uy@IJ;#cfvfA)X#Z~ylHh=2M|{~3=z{y0DLGe1K-JUryZ7eB?-t5=sF`mvAw zpZ4UN-ohJsT)M;`nB#44i#+$-b9~SDd=J0=>%YeJ>(`eW5CMMWS3behPe09*Pd=$4 z;{V_u{P}Nm!9qv9C5iPrDd!>iku+KKC%9aU9sgn>wR#gL}fB)udH#MN1q3&E= ze~Gj6+E%-C{Thlk`BDq^e_nrGvT+To*Y4K>H&q?E`zJs5x!?YKKk_4gKaEBs|DhlH zTmBdR!k=F)zz06?L0*6TH3jUw?|tt(LTG;U;>9Z`UDxffZ>t*`-sG-D*}SmbwsP0` zxUWEpiRnK_*ylFZ1Bl&=v+uLk7jU=lTfJWPUVkx_#z#K#v(0yZ_jmvB(@#GW-tmsN z=WqSiZ{y=1|7Bz{nQ-OGBYfv~ey2Y1#AEi+kACz|e#1BXq5pY2J{sqoefQGJ+HSo6 z;d=$S|FsWyxc~c^grT6m{B!u$b-Gna?6wG5MB?@9pZ~RA_=S)D@t0rr(|5k}Dj_uf z>Z>mkbIyd&kaOn8e(cBirgwjn=IqjSIk=lYq~yLzhrQv#|Egc7gZTr)VV%up9Wee^ z|LR|!x#QF6`N{;HoLnTOuI^Kp5BU7-lnQM^0h4duc_;?hc=uJFdmPq^Dpm;X3l8TkhAr%>+j<&%6>oa5UTzkTnpUs zwd>uVZ@61U0Thvy35y~^&Uq~oDT&Fx?6#gv-U#R5)xK^o#J=nK{XcAwY(D5U;6AIU z0=*CDGr;}@_(~AlPBA5L4$C5VwQrl^8Z6F!q4@*D&5b>@XMf4Yg2`^3s{fIl@uKXx zuH9j5Z}?ZnLNJ@6I=kO}c#)s1MN$!@Vk(=T>N{|gz|EVlkn@yFm)?T8k+ZEq6mO4I!Tw)V?e zfG_9uz9VDb_5H&~WBuZ}L(YjymoD+tQ%~`+kNw*n$iR+!_tlA#88>g;UTHuG&F~Gr za#!09X=U#PFuJZ|Hk*@DLbW*a64JhrN%X@yaDObTyA6`t>c_`ag0-PD!EV!?bquk{11_r3nvX8Xc-r%!J0+`Ywn-~3j2|9igKfBO07 ziv~2!FcG8r09&p;OUJ4kq2CadblNuZna_NV-~GK$bM?w4%>3VT*WG6~?$LmuzyguZ z7qz5HEwc2x>p=!?UGs&4W?s2^nWvwAYHb4!WwSqjT@T2Q+aTB8@>X6Mk9>&*^%uI! zfo+F@#X>Ek*{T_CPHZCQ_s;mi@BN#wfF?BC(fS&W(`S+c!S*K>uR@WUbt*zcX%Iqh z5Lc!ZBa?_R@Ot_pZ##a5Ye&~emH;D*K`>klLP?I?Ye}?TkPXA;Vgt|^xN++S-~WUE z1@C^(ySQ`v&RQJ53MlOU8e1BZ;J+T0xl_3N5uf{!n7cQ)^xa7nOinIHRVS8wG3z6TTcB`y*qa1yR?S+CM+ zSpXGK1aSij?BPq{_qXl1dj0ue)d;AM5I-jRMH)Y(c&H3TR3s9UaL8x;6Fm3GH}Y4% zRMf8V4C6~4k2Ny<+naCjx5y1)WsK^rD(E6{D`~6n5 z0INGza4`%g&>)NvIVAc4!6(&RB)~~@T+u6h+J2Rj29OEs)N3lfP00ty(hB8SrdaUl!UlIzk8_2s{!141Y^1VmA< z3t5*;5VCh%2q)a;I*d;F8}Io$93G9C`Y9oXvfyfXV`wxaYT4}==7tea1V@T_L@=q2 zFn~0Uw@y212F_fT;Mx$hyuTw}i8P3EaQCi1dVIVp$P86Sq=cb;NX5|2trf^*se+r9 zPF?B$1f-HwGU`>}VklCz!Yg#s3*S&tT)^t0DA0%yrC`!dAbI9uxW)}$;&b+E{K&h0 zlxvqSaprdm;Y*6}i3ZV;Sokx7gBKs7QllKe`-K-rqC)FP>v%Mp5No390~5WzDTf&U z{f>!cKby}9XQ!(usFWmaCziHDjRu+V>Vt>Kcq9-BG=w5}Kne8Zrn2LtMmS{$BH-dg zQB;I1hF9kpfq)S_6Vwrhi{S}gwJ-5&=Re2adGC+%^kYwQM{g2>7Qu@l!67;t6-3v7 zL6=o*rXqNa=`9x1BTCU8&9t$pZ{I-w-RZ;ihcMU036IBI7(dG4WW3UVo|LpMXd7Vj zD+P)s)-3TWY87pTd0h6nPrfpsA@%9S;p^(5Hx}) zL7kI0LgbvE{=$FHUw+4b$$$3Df6A-8OdK^Ox)DRgD=krq7xEg?h?d>&u_lBHS{7Wi zI9+rE5mKcy_)DLkp6rgN(P=0@k30 z%`ml(g*RioB#{~!2s z&;D7y=ea-4E9pzb;}OJ+s3X(`sDHHI@g6}!&7>=rG-wgL)*XRkDH9|>qe$a~7HBdd zYPr6ptzFlEJ~CV-n7d3+`K3&a3yU)@UpyITK-6`-bZAw4)820<9K)zU#EAlpI8Al2 zszWPpH3|Z>yuP>l%iODMR-#5!1LJVOL7ec9zwpob(A)kLfAO7vo>!(X5f2YbtS(jf zTFgL@{`0Evi6{~A04~KR)YVr9Pc;WI#nn-Dv;i4A5)vU+G=w2Bzz50eFw~TtmZP^S zx7&uXPyF(*D4)7C6n_m%wmthkzR;#}s93exf|^$!keBgusPInN`CiPkmj5FV6oLj+ z18r!y*dFqazwj^kjwimI?|=7S;??u(gg8P%sxI6S65>V>E$2ZYM^r+|rX_$VqOmx5 zm9p?u(}|!_kVcB&4?ups3y98%@ePjBCmNGfN{fEsoL^g zuxj!4vcm?h$Hqa7Ac=^eWLz>@&4X4Pskhf?jlKIXt>#OG7?i8y6aLvtALU(F-^pKj z@AvWg>=l9v8VpD^j_M;VseUy;-SJ8QEhb1cqDpc02%e2xL3|NMW6?Z4j7VG%BtcBX z#>hSNECqP%ec;MG+kH!|{qMeX!~F?4=ef%l_=o)hh-`&VgOa2S)o3m5HCx9(dfOf) z(MU&h0m&#%tO8zYfjS};oz$`rD#a|t5Q!>W8(-jGT>k|gz3>?S%^&@1+?n4b2xwHa zNj2V=;__XKofk#C{!2hKfNFV9P&8Kb5pXRTFj0{PbmHiRh#nZy3VPf?n~_n0Muyq0 znJsgtRqf=#MW}9kPG>GJoK+3z3o@&aQkDgoZ8KyWq17-Q_hl{+C6z@`0ZRmN6zhTI zVq@!qnD*dXF>g^7(ag2UC4TO;k8?0S;%~q2uXEbn2Fb(_k*37!5^PBmT*4eR;t`4o zlUghal~FBLL9`|yDHk6V>-9|nIuY#j3>nXHn~~xviyPO;N7o8iXDeuJvjDRhw(rOT zWEzy0Ubx|p{_(3`+@L!##zBH*-kY}dFJCKc>|#6gzfkFj(h+4rqvhXFf7WWMUmY>$hIuOfrA#1AmpdpW)1D8qg*op+nma2?-$=)3wa5i`j`9&``Ml zO{2wZ^*gmuG-ovBVlIQD!O%2=v%5$;gUJjzSP%}3(6aOw$k6_-EWv{bg~eIS#re`p zFZu`m-}kL}L1t;irE!t+jqS+;Hj@z6wE!pTf}nGP2w1tv2!tAP23u?@B0QCzi{Lzf^M z8h|#V2aX;adXSN^A!ETq3CWT>nr)TsuQ}j#8K~TkJXU`7*wsh<-^_3OZ~olhT`}Vz ztQ^YHm~8fhtqU1!&}C99OqHz~CDDYAMg-ABa3|DV8v1AlUnW6PJ5(-?CcHd&0rL2KMjXXW-((2=4OAsh%{1dJWVjx-50BP859 zTo$-@I0?@kKJOscqLJ^yeIBYV-~fwmN}Hp^<4b;a=hdPCIm#v^|I)z9!Bzw_JqBTv4C*UqlfwqrbasR>7` z_FhZitXhSpHIw#g`(r^ZlS3*!#Gw`RKnVwej--T}BZtt_G@0;Qx4y^|PrQ}yeD)i;Ila#KU<|P<=wyjoOT|o^5=Tlx zv_%3)P$V`b(@l=e6J$Z#NSH+QFc8LpFal|T#!GCkr9O=%+!Evt%X4x!Bj+i(n__87 zm(NM(Gd$bcy|4SjA@#+#*d_I~vf@##CIrM1hBmn8r30vl=w5OzOFZ3|Sh)0dP)Zo8 z+7*Xuxd^|0#UQjA2nq+I5x3@dnH`P!&%fo5aGGy0x-descKpR{OeC#HORft-p zlxjjO7|zu3&XAylqlS3c5Dp?b7NiAf9a{MQc*-(;riqy* zcC;!4w_>hwf|fc#+Xzim+K~9%={^3FZ~Xw?oT0~K!tn&Ta0ufO5*pB0B8yaF1#$on zc-KIVFa@6#AT1t^iHBptK}$G@$V6aN3hPVIB^%@-d{V-?j=Y$Y(}KKMU|kh{HzTJR z+2-Wgf;w|y4FlR$oZ9Nj7q4Wn-UL+ypvtgvL*tSiz4Y-rpoq=l{B|BtUOpKKlaUdv z6w-q_0m=ddCkD7MX?WrG>%8+F&+zEg5vPqYx^|3QzJ!b?(2mOP_Q7a?1ik>~f}IO? zr=URL=zw@|L^wJiOj_hn;ZTaXiG3Zt_=U244N}Itgf9}dNaRJr77OyC!xkO3n3K~S z^Nu`QEOUWfwcvGVdM_`o7;4Ly`A`EK)wt#d)(gzrg5IQouZ65`v`yw{tf(25Dik5b z`8L5h7zIxA8FFdDd%oduW|P49(QC*fSJC4W^zlcKlM99HI$hv*r}*6|EF2#RMuwRa zCL{Flm@qyf98S=q296ZQ0!_VrbI1;z7dMq1<_4W(bHnCk0c=(@AkXLI`J65aL4%G--Hke#+6cL!Nx%i0R>k=CP~D$uauG74(Tmz`ONmD>!=P0KM`I;n_#APv1uF zM3jrj(Fn!?qAqosP|OtqWChEGkkJ8i$7fDHPjs_Hnss#31!=J;|6k1MQV~An5`CFM z?|4}k;2J;HcQ$6Mai~f^_MlI==l2ZwKH~1OyC}b2tnXKRy@c$j0~WsSihehz02|j`#Iq%XWOb*)g)7nim$DMk9uz0U;EOW^&MS^WGV6 zdg_=bQVJkOsT{65TKV2I;e};deW*F=9vL7iYA8;wIru zPe6A9sRIviYLLe;Z(s_f01L>|Or9muG?Aut=TAGj*@DG9k#k43yz2hcP{;xjmeAy? zVC92kYuFXDuf3_rH^$&Y{}DHx>$+pv?}Uel1?Iwv%Xfh#`CWa7%*no}_`Ml$) zcRYrT65%+)K}3QeBVCyh4&b?_tW5u>1??aG674t5 zpt}NR3Z1}o1`C5TgGC_EgmgY9pC!84g6@1#HDEzE??^dUQ=wJxPK-6D}3RGHkmLov?;<@g*buPY{Ai6E~AGA6G0DS z!DPA_M8hp1dKK>$bpQIFkbnEPkY-T5r(7k(N({V8NJ!sk=G4iXVr;AxJ}19*#sP>5Ga3qm?QB>(y)E2E@CupCF|s+hVlJ468U?LG&qV`Pb@Kfhu=1W} z>o15sK-6o&YJ>0AfX$xSwF+5X2yLBkP}s#1oH!9oI>wK+v{wVJh4vwB#+d>g(;Gj} zy%+uo;kQ1)1-pz*6rU&1%1m~{x&?VLMQmJ{YZ^-lQX=9_dL?d|ZT3HyjSd<7Qw1r|q5xi)N6LAl<@1`T4p48C)lr#@z0TxE?GL|Wh zHfSYtCB#dYS+3L@ypVUTlobkoS9>6QfFKV|@;WkO9M2RhtgGpUDej3^TKy^SO!pY_p?xIOa;z(1{U_jnFD#0y4_T zNReYjqE|?GhUC{FByOF(#3W95^sytl`4o*c@o~YEP}->!(J}ZK_ab<#!8C%zYAPUQ zBXveHBd0`4kn^YlYmSD7sOyNNTPEc?cqAK^GuaH!;8Og6Y*hodi}Ksy`DVlRwl9sV zBw@KyvVx;`cgh1hBO?IIMmTWdMGDnpTztW7?i`G)Y^9z8ZjOYG+qdrV#K{SASUCJr z+fsc2c~M9MXahbe*{(O3HxL?JBbFSuM9z@2l2u6NYYZp+hMJ#gwUxI06bf&ZFCR*{7_KiK*bkeb(L_07+R)_Vijh^gx|H{T~ zcZiqzvXiG%7`5oZh%i=kjG?+L9=Fx7zKN3j3ip>bVpfpB>x;%e8%} z^3*oN@O22s_e|;awJym%57^3t`;}2GbpGwWVc*%Lv06AQPS_kqi4@OK$;5U4 zl~l-4IYVcN8#%${ixZBIMp#lvf!sL-vubc@aF2+O!6#UXq|#qG)V@O!kahO}Z*Wpf~4M=STMqh-O|LZqb51$63bvgZ?W&G?wi>n+1uwIHMDxIT5T|&{-yi1JcY`oG*xn0aAvP(I#^9<&HLt z(McemX>pdF;?jV&h_)aH>RhV4@HrIvRnEamLK=HFP(DMWDI* zEY0ON!{M9BdWrPvYh;~Z3oATn2kUD0zWZ|Wd$D)mrnsl_I&*T3>atm>+Zg2RkhN%Z zuIJ3_Nm&2KmeG*xg(5bEx2il27NCrIO|}BZ000S9Nkl4Y5*nOLJg9VW5~F3ck}jTk|4#b1YGIz6m*( zI`q;st$}g7dc^zziC8bgyk<>enQ}52#G(EvQTly z&hHY(N6c?cx%KLltIxa%i7l=Xrzy^L5t+RX=`=7tJVC=HXiwvXpvPjts+4}(rw$g(7WyzOx*pwa172!n-7-xgN3D}8+txApes|&CV z#?59^Cbe(16l9S7w3HPNJ{-=}*NTdY$&&fjUt~8=Faw*-O4$!ZE**0G=q1eC63IwI zo+{HuSkvy$do9Bk7t7v=JsuF)J^Ae{#^j5wbPcfYtGF2-1zkY|T<^GNCfM_nK+ z97|eEx~)Bdm_t zsc=J$WU`e7&GrA7;#n%wS!;MYY~9*!(0llS!?x}NR;%J$C)`&N8-`SCtO$l6RX<@@ zYCm`bp~WOZj2s;tFuQR^nk8<(9GTr%kZzASd%flCZbM2(2q(mFfglsiT09FmNv)U# z+;rJVUxaM^u$zM2_l1+{IP;)*l&$0}W>R*(F#zH!>S?82cA10@9B|K$8^RC!it<%P z-dm9^4Tw?Ju!{ZjBDULZ`jD?+K`WL-IfEAAdjwh}jF2{RJQ<@hVm?!R)^PV`!`W*M zi+e5IVuHsDAQurXlH?H6F-CQ`ouSR7Fy*S#?1$eNy?~3oFWOifZ??R=-kfc@2*o+~ z$ycGWER!%_0es7Xla=8jL-=NU+T7;cRM`vPxRzlZ(nFAahgv9&9p=?qIRWs-)OUk&GSg{DPVqCaQq(nH`%5L{c`8LBWPfg=SCGz>$zA=vE7bIyy2Ag=hUJ9iT+T)2=IuL-?vBVQ4*;T>)jWQ-h^5mp_|XR_~g^1?nn6aG+;adDxAu7BsRnl2pUT#qX$d_ zd8EuASL~7?DWEA9>?IfHmrR(^aku$A$d?L3&DY1IvC+Z5oNP5LqMI*S8(u3btKfl( zH-&o6b{TdeaAh{;(ld{c7d3YtM2Twy2)8EZu08z6cjf`BDvj)zn6++xwx6ZN+RdlM zg3FISip!tjUPqy#3B+-;vc;@!jK+}`Mi-oMKdzwfMBJF7IGoe4H9Oxoa`Sx;>Dipb zEt^q1?0aaCEeeZbMZ@u}+Q52vzQHIT^iym_LA6{w7*}IE^MFlew7b)#M9!I<5~5lc z^L(I+LR#V+J8sYiH-2B&U;Dv)_e9_O)nOm}Bi}PBZ$RjgRZ?YUq@4FK;e2Nlgzqsy z!?BBlikRFVhUllA2$S)c$#^n&X4uA~owj83LxyfSDQm4|t@f$X5+mjxJ) z$4l5@MNZh)9Xx2}$~&T<9@7~R6Mb*DYwh}oR_}%dFJ!Q&WE<`K9xMw zd^PticG-QaO%E43e`Raf*TUO&#I0L52q7-B{}nymw>5XI0c^tr4NGOx&+{7gfvrtT zDH$Wco8SB-AOHCOy>}N4v7_E$?V7^1$+*~$zOrY5eXBCH|FsXPEIauc5BKD5 z-+>v`M(vzs$cm8lS(v*&@N4s#USE698tYq>_FY#5HlLue{mkzDPUY*zLu`mT7d8MA zW3%>qEzd{M)uZ-&MZS1rA4Bp7?ht_U^RqRx7oj}FXGs`ZKEz7?|15|95PN^;4>r5& z!#%^(EyoFr@sjJ zYp=bwRvX@oz7_lu@D|`v?*EL|uOAP8%z)1U*D0OL>)S?E_}=gRem?x+pI|f^Mb&VS zvqky3>G>*!q2l24`Fu8GS$Nq%a{J7-_XQ&V-?RMkHE4}Q)~{$ho~&ihvdV1hLuP_9 znH<&Z&Az^czY0ePfv#IHpHIIojISSGKh} Date: Wed, 25 Apr 2012 10:35:16 -0700 Subject: [PATCH 002/763] Import translations. DO NOT MERGE Change-Id: Ic2b00aaa84a720899ed02dae660b11e26dae5050 --- res/values-ca/strings.xml | 6 ++---- res/values-en-rGB/strings.xml | 6 ++---- res/values-iw/strings.xml | 6 ++---- res/values-nb/strings.xml | 6 ++---- res/values-sv/strings.xml | 6 ++---- 5 files changed, 10 insertions(+), 20 deletions(-) diff --git a/res/values-ca/strings.xml b/res/values-ca/strings.xml index c385221b1..85c3f6a31 100644 --- a/res/values-ca/strings.xml +++ b/res/values-ca/strings.xml @@ -46,10 +46,8 @@ "S\'està establint el fons de pantalla..." "Fons de pantalla" "Suprimeix" - - - - + "Vols confirmar la supressió?" + "Confirma" "Cancel·la" "Comparteix" "Selecciona-ho tot" diff --git a/res/values-en-rGB/strings.xml b/res/values-en-rGB/strings.xml index 0bdceb4aa..5447e8b13 100644 --- a/res/values-en-rGB/strings.xml +++ b/res/values-en-rGB/strings.xml @@ -46,10 +46,8 @@ "Setting wallpaper..." "Wallpaper" "Delete" - - - - + "Confirm deletion?" + "Confirm" "Cancel" "Share" "Select all" diff --git a/res/values-iw/strings.xml b/res/values-iw/strings.xml index 41bd60a6e..fd9ab85bc 100644 --- a/res/values-iw/strings.xml +++ b/res/values-iw/strings.xml @@ -46,10 +46,8 @@ "מגדיר טפט..." "טפט" "מחק" - - - - + "האם לאשר מחיקה?" + "אשר" "ביטול" "שיתוף" "בחר הכול" diff --git a/res/values-nb/strings.xml b/res/values-nb/strings.xml index 20ec589c5..d868e08c8 100644 --- a/res/values-nb/strings.xml +++ b/res/values-nb/strings.xml @@ -46,10 +46,8 @@ "Angir bakgrunn …" "Bakgrunnsbilde" "Slett" - - - - + "Bekrefte slettingen?" + "Bekreft" "Avbryt" "Del" "Velg alle" diff --git a/res/values-sv/strings.xml b/res/values-sv/strings.xml index f61cbaa48..71cec0651 100644 --- a/res/values-sv/strings.xml +++ b/res/values-sv/strings.xml @@ -46,10 +46,8 @@ "Bakgrund ställs in ..." "Bakgrund" "Ta bort" - - - - + "Bekräfta borttagning?" + "Bekräfta" "Avbryt" "Dela" "Markera alla" -- GitLab From 54d626f5b529508637c3117a28874bee35bb0fc8 Mon Sep 17 00:00:00 2001 From: Yuli Huang Date: Wed, 25 Apr 2012 23:51:52 +0800 Subject: [PATCH 003/763] Make 'Edit' behave more consistent with 'Crop'. 1. Save edited PWA photo in 'dowload', same as cropped images. 2. Fix Crop-image toast may show strings without i18n. bug:6168430 Change-Id: Ie1ea8e5774f6dee632477a6f887aa766a295a120 --- res/values/photoeditor_strings.xml | 13 ++++----- res/values/strings.xml | 5 ++-- src/com/android/gallery3d/app/CropImage.java | 4 +-- src/com/android/gallery3d/app/PhotoPage.java | 11 ++++---- .../android/gallery3d/data/MtpContext.java | 5 ++-- .../gallery3d/photoeditor/SaveCopyTask.java | 27 ++++++++++++------- .../android/gallery3d/util/BucketNames.java | 26 ++++++++++++++++++ .../android/gallery3d/util/MediaSetUtils.java | 6 ++--- 8 files changed, 64 insertions(+), 33 deletions(-) create mode 100644 src/com/android/gallery3d/util/BucketNames.java diff --git a/res/values/photoeditor_strings.xml b/res/values/photoeditor_strings.xml index b282a45b7..2305e0b3d 100644 --- a/res/values/photoeditor_strings.xml +++ b/res/values/photoeditor_strings.xml @@ -19,16 +19,13 @@ Photo Studio - Photo cannot be loaded + Couldn\'t load the photo - Photo cannot be saved + Couldn\'t save edited photo - - Photo saved to %s album - - - Edited + + Edited photo saved to %s Save edited photo? @@ -133,7 +130,7 @@ Drag photo to flip it - Tap to remove red eyes + Tap on red eyes to remove them Drag photo to rotate it diff --git a/res/values/strings.xml b/res/values/strings.xml index e8bf0f49a..3bff3ba5f 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -230,8 +230,9 @@ No photos. - Cropped image saved to Downloads. + %s folder (string: folder_download) [CHAR LIMIT=50]--> + + Cropped image saved to %s. diff --git a/src/com/android/gallery3d/app/CropImage.java b/src/com/android/gallery3d/app/CropImage.java index 40b357d72..4fec95b36 100644 --- a/src/com/android/gallery3d/app/CropImage.java +++ b/src/com/android/gallery3d/app/CropImage.java @@ -58,6 +58,7 @@ import com.android.gallery3d.ui.CropView; import com.android.gallery3d.ui.GLRoot; import com.android.gallery3d.ui.SynchronizedHandler; import com.android.gallery3d.ui.TileImageViewAdapter; +import com.android.gallery3d.util.BucketNames; import com.android.gallery3d.util.Future; import com.android.gallery3d.util.FutureListener; import com.android.gallery3d.util.GalleryUtils; @@ -120,9 +121,8 @@ public class CropImage extends AbstractGalleryActivity { private static final int STATE_LOADED = 1; private static final int STATE_SAVING = 2; - public static final String DOWNLOAD_STRING = "download"; public static final File DOWNLOAD_BUCKET = new File( - Environment.getExternalStorageDirectory(), DOWNLOAD_STRING); + Environment.getExternalStorageDirectory(), BucketNames.DOWNLOAD); public static final String CROP_ACTION = "com.android.camera.action.CROP"; diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index fadcbf1ce..8794cb976 100644 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -584,11 +584,12 @@ public class PhotoPage extends ActivityState } break; case REQUEST_CROP_PICASA: { - int message = resultCode == Activity.RESULT_OK - ? R.string.crop_saved - : R.string.crop_not_saved; - Toast.makeText(mActivity.getAndroidContext(), - message, Toast.LENGTH_SHORT).show(); + Context context = mActivity.getAndroidContext(); + // TODO: Use crop_saved instead of photo_saved after its new translation is done. + String message = resultCode == Activity.RESULT_OK ? context.getString( + R.string.photo_saved, context.getString(R.string.folder_download)) + : context.getString(R.string.crop_not_saved); + Toast.makeText(context, message, Toast.LENGTH_SHORT).show(); break; } case REQUEST_SLIDESHOW: { diff --git a/src/com/android/gallery3d/data/MtpContext.java b/src/com/android/gallery3d/data/MtpContext.java index ee5cf7e6a..074902025 100644 --- a/src/com/android/gallery3d/data/MtpContext.java +++ b/src/com/android/gallery3d/data/MtpContext.java @@ -10,6 +10,7 @@ import android.util.Log; import android.widget.Toast; import com.android.gallery3d.R; +import com.android.gallery3d.util.BucketNames; import com.android.gallery3d.util.GalleryUtils; import java.io.File; @@ -19,8 +20,6 @@ import java.util.List; public class MtpContext implements MtpClient.Listener { private static final String TAG = "MtpContext"; - public static final String NAME_IMPORTED_FOLDER = "Imported"; - private ScannerClient mScannerClient; private Context mContext; private MtpClient mClient; @@ -104,7 +103,7 @@ public class MtpContext implements MtpClient.Listener { public boolean copyFile(String deviceName, MtpObjectInfo objInfo) { if (GalleryUtils.hasSpaceForSize(objInfo.getCompressedSize())) { File dest = Environment.getExternalStorageDirectory(); - dest = new File(dest, NAME_IMPORTED_FOLDER); + dest = new File(dest, BucketNames.IMPORTED); dest.mkdirs(); String destPath = new File(dest, objInfo.getName()).getAbsolutePath(); int objectId = objInfo.getObjectHandle(); diff --git a/src/com/android/gallery3d/photoeditor/SaveCopyTask.java b/src/com/android/gallery3d/photoeditor/SaveCopyTask.java index 6b7b7c38f..1b5929245 100644 --- a/src/com/android/gallery3d/photoeditor/SaveCopyTask.java +++ b/src/com/android/gallery3d/photoeditor/SaveCopyTask.java @@ -30,6 +30,7 @@ import android.view.Gravity; import android.widget.Toast; import com.android.gallery3d.R; +import com.android.gallery3d.util.BucketNames; import java.io.File; import java.sql.Date; @@ -59,7 +60,7 @@ public class SaveCopyTask extends AsyncTask { private final Uri sourceUri; private final Callback callback; private final String saveFileName; - private File saveDirectory; + private String saveFolderName; public SaveCopyTask(Context context, Uri sourceUri, Callback callback) { this.context = context; @@ -79,8 +80,17 @@ public class SaveCopyTask extends AsyncTask { if (params[0] == null) { return null; } + // Use the default save directory if the source directory cannot be saved. + File saveDirectory = getSaveDirectory(); + if ((saveDirectory == null) || !saveDirectory.canWrite()) { + saveDirectory = new File(Environment.getExternalStorageDirectory(), + BucketNames.DOWNLOAD); + saveFolderName = context.getString(R.string.folder_download); + } else { + saveFolderName = saveDirectory.getName(); + } + Bitmap bitmap = params[0]; - getSaveDirectory(); File file = new BitmapUtils(context).saveBitmap( bitmap, saveDirectory, saveFileName, Bitmap.CompressFormat.JPEG); Uri uri = (file != null) ? insertContent(file) : null; @@ -91,7 +101,7 @@ public class SaveCopyTask extends AsyncTask { @Override protected void onPostExecute(Uri result) { String message = (result == null) ? context.getString(R.string.saving_failure) - : context.getString(R.string.photo_saved, saveDirectory.getName()); + : context.getString(R.string.photo_saved, saveFolderName); Toast toast = Toast.makeText(context, message, Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); @@ -116,19 +126,16 @@ public class SaveCopyTask extends AsyncTask { } } - private void getSaveDirectory() { + private File getSaveDirectory() { + final File[] dir = new File[1]; querySource(new String[] { ImageColumns.DATA }, new ContentResolverQueryCallback () { @Override public void onCursorResult(Cursor cursor) { - saveDirectory = new File(cursor.getString(0)).getParentFile(); + dir[0] = new File(cursor.getString(0)).getParentFile(); } }); - // Use the default save directory if the source directory cannot be saved. - if ((saveDirectory == null) || !saveDirectory.canWrite()) { - saveDirectory = new File(Environment.getExternalStorageDirectory(), - context.getString(R.string.edited_photo_bucket_name)); - } + return dir[0]; } /** diff --git a/src/com/android/gallery3d/util/BucketNames.java b/src/com/android/gallery3d/util/BucketNames.java new file mode 100644 index 000000000..043dd3d10 --- /dev/null +++ b/src/com/android/gallery3d/util/BucketNames.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2012 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.android.gallery3d.util; + +/** + * Bucket names for buckets that are created and used in the Gallery. + */ +public class BucketNames { + + public static final String IMPORTED = "Imported"; + public static final String DOWNLOAD = "download"; +} diff --git a/src/com/android/gallery3d/util/MediaSetUtils.java b/src/com/android/gallery3d/util/MediaSetUtils.java index 8e60f5955..3bb3f8bd1 100644 --- a/src/com/android/gallery3d/util/MediaSetUtils.java +++ b/src/com/android/gallery3d/util/MediaSetUtils.java @@ -19,7 +19,6 @@ package com.android.gallery3d.util; import android.os.Environment; import com.android.gallery3d.data.MediaSet; -import com.android.gallery3d.data.MtpContext; import com.android.gallery3d.data.Path; import java.util.Comparator; @@ -30,10 +29,11 @@ public class MediaSetUtils { public static final int CAMERA_BUCKET_ID = GalleryUtils.getBucketId( Environment.getExternalStorageDirectory().toString() + "/DCIM/Camera"); public static final int DOWNLOAD_BUCKET_ID = GalleryUtils.getBucketId( - Environment.getExternalStorageDirectory().toString() + "/download"); + Environment.getExternalStorageDirectory().toString() + "/" + + BucketNames.DOWNLOAD); public static final int IMPORTED_BUCKET_ID = GalleryUtils.getBucketId( Environment.getExternalStorageDirectory().toString() + "/" - + MtpContext.NAME_IMPORTED_FOLDER); + + BucketNames.IMPORTED); public static final int SNAPSHOT_BUCKET_ID = GalleryUtils.getBucketId( Environment.getExternalStorageDirectory().toString() + "/Pictures/Screenshots"); -- GitLab From 3fea3f6f48ebf56b8e892d35da979a5e4956902b Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Thu, 26 Apr 2012 11:23:07 -0700 Subject: [PATCH 004/763] Import translations. DO NOT MERGE Change-Id: Id21a966b0d23972c9f48250eecd5f2f3a39ce724 --- res/values-af/strings.xml | 9 ++++----- res/values-am/strings.xml | 9 ++++----- res/values-ar/strings.xml | 9 ++++----- res/values-be/strings.xml | 9 ++++----- res/values-bg/strings.xml | 3 ++- res/values-ca/strings.xml | 3 ++- res/values-cs/strings.xml | 3 ++- res/values-da/strings.xml | 9 ++++----- res/values-de/strings.xml | 9 ++++----- res/values-el/strings.xml | 9 ++++----- res/values-en-rGB/strings.xml | 3 ++- res/values-es-rUS/strings.xml | 3 ++- res/values-es/strings.xml | 9 ++++----- res/values-et/strings.xml | 9 ++++----- res/values-fa/strings.xml | 3 ++- res/values-fi/strings.xml | 9 ++++----- res/values-fr/strings.xml | 9 ++++----- res/values-hi/strings.xml | 3 ++- res/values-hr/strings.xml | 3 ++- res/values-hu/strings.xml | 3 ++- res/values-in/strings.xml | 3 ++- res/values-it/strings.xml | 9 ++++----- res/values-iw/strings.xml | 3 ++- res/values-ja/strings.xml | 3 ++- res/values-ko/strings.xml | 3 ++- res/values-lt/strings.xml | 3 ++- res/values-lv/strings.xml | 9 ++++----- res/values-ms/strings.xml | 3 ++- res/values-nb/strings.xml | 3 ++- res/values-nl/strings.xml | 9 ++++----- res/values-pl/strings.xml | 3 ++- res/values-pt-rPT/strings.xml | 3 ++- res/values-pt/strings.xml | 9 ++++----- res/values-rm/strings.xml | 2 +- res/values-ro/strings.xml | 3 ++- res/values-ru/strings.xml | 3 ++- res/values-sk/strings.xml | 3 ++- res/values-sl/strings.xml | 9 ++++----- res/values-sr/strings.xml | 3 ++- res/values-sv/strings.xml | 3 ++- res/values-sw/strings.xml | 9 ++++----- res/values-th/strings.xml | 3 ++- res/values-tl/strings.xml | 3 ++- res/values-tr/strings.xml | 3 ++- res/values-uk/strings.xml | 3 ++- res/values-vi/strings.xml | 3 ++- res/values-zh-rCN/strings.xml | 3 ++- res/values-zh-rTW/strings.xml | 3 ++- res/values-zu/strings.xml | 9 ++++----- 49 files changed, 133 insertions(+), 121 deletions(-) diff --git a/res/values-af/strings.xml b/res/values-af/strings.xml index af3e90c0e..6c4c376a6 100644 --- a/res/values-af/strings.xml +++ b/res/values-af/strings.xml @@ -46,10 +46,8 @@ "Stel tans muurpapier in..." "Muurpapier" "Vee uit" - - - - + "Bevestig uitvee?" + "Bevestig" "Kanselleer" "Deling" "Kies almal" @@ -101,7 +99,8 @@ "Prente en video\'s" "Fotogalery" "Geen foto\'s nie." - "Gesnoeide prent gestoor in Aflaaisels." + + "Gesnoeide prent is nie gestoor nie." "Geen albums beskikbaar nie." "O prente/video\'s beskikbaar." diff --git a/res/values-am/strings.xml b/res/values-am/strings.xml index ace549765..ea664ea68 100644 --- a/res/values-am/strings.xml +++ b/res/values-am/strings.xml @@ -46,10 +46,8 @@ "ልጣፍ በማቀናበር ላይ...." "ልጣፍ" "ሰርዝ" - - - - + "ስረዛ ይረጋገጥ?" + "አረጋግጥ" "ይቅር" "አጋራ" "ሁሉንም ምረጥ" @@ -101,7 +99,8 @@ "ምስሎች & ቪዲዮዎች" "የፎቶ ሥነ ጥበብ ማዕከል" "ምንም ፎቶዎች የሉም፡፡" - "የተከረከመ ምስል ወደ አውርዶች ተቀምጧል::" + + "የተከረከመው ምስል አልተቀመጠም::" "ምንም አልበሞች አልተገኙም::" "O ምስሎች/ ቪዲዮዎች ማግኘት ይቻላል::" diff --git a/res/values-ar/strings.xml b/res/values-ar/strings.xml index 6bdeecc24..bed39aa83 100644 --- a/res/values-ar/strings.xml +++ b/res/values-ar/strings.xml @@ -46,10 +46,8 @@ "جارٍ تعيين الخلفية..." "الخلفية" "حذف" - - - - + "هل تريد تأكيد الحذف؟" + "تأكيد" "إلغاء" "مشاركة" "تحديد الكل" @@ -101,7 +99,8 @@ "الصور ومقاطع الفيديو" "معرض الصور" "ليست هناك أية صور." - "تم حفظ الصورة التي تم اقتصاصها إلى التنزيلات." + + "لم يتم حفظ الصورة التي تم اقتصاصها." "ليست هناك أية ألبومات متاحة." "لا تتوفر أية صور/مقاطع فيديو." diff --git a/res/values-be/strings.xml b/res/values-be/strings.xml index b2b322cf4..b6924b173 100644 --- a/res/values-be/strings.xml +++ b/res/values-be/strings.xml @@ -46,10 +46,8 @@ "Усталяванне шпалер..." "Шпалеры" "Выдаліць" - - - - + "Пацвердзіць выдаленне?" + "Пацвердзіць" "Адмяніць" "Апублікаваць" "Выбраць усё" @@ -101,7 +99,8 @@ "Выявы і відэа" "Фотагалерэя" "Фатаграфій няма" - "Абрэзаная выява захоўваецца ў тэчцы спампаванняў." + + "Абрэзаная выява не захавана." "Няма альбомаў." "Выяў/вiдэа: 0." diff --git a/res/values-bg/strings.xml b/res/values-bg/strings.xml index e3619f7ad..44ba42e46 100644 --- a/res/values-bg/strings.xml +++ b/res/values-bg/strings.xml @@ -101,7 +101,8 @@ "Изображения и видеоклипове" "Фотогалерия" "Няма снимки." - "Подрязаното изображение е запазено в „Изтегляния“." + + "Подрязаното изображение не бе запазено." "Няма налични албуми." "0 изображения/видеоклипове са налице." diff --git a/res/values-ca/strings.xml b/res/values-ca/strings.xml index 85c3f6a31..e8fa4e910 100644 --- a/res/values-ca/strings.xml +++ b/res/values-ca/strings.xml @@ -99,7 +99,8 @@ "Imatges i vídeos" "Galeria de fotos" "Sense fotos." - "S\'ha desat la imatge retallada a Baixades." + + "La imatge retallada no s\'ha desat." "No hi ha àlbums disponibles." "O imatges/vídeos disponibles." diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml index 046830cc1..600b4efbd 100644 --- a/res/values-cs/strings.xml +++ b/res/values-cs/strings.xml @@ -101,7 +101,8 @@ "Obrázky a videa" "Galerie fotografií" "Žádné fotky." - "Ořezaný snímek uložen do složky stažených souborů." + + "Ořezaný snímek není uložen." "Žádné album není k dispozici." "Žádné obrázky ani videa nejsou k dispozici." diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml index 0c11da476..abd3284d9 100644 --- a/res/values-da/strings.xml +++ b/res/values-da/strings.xml @@ -46,10 +46,8 @@ "Angiver baggrund..." "Tapet" "Slet" - - - - + "Vil du bekræfte sletningen?" + "Bekræft" "Annuller" "Del" "Markér alle" @@ -101,7 +99,8 @@ "Billeder og videoer" "Billedgalleri" "Ingen billeder." - "Beskåret billede gemmes i Downloads." + + "Det beskårne billede blev ikke gemt." "Ingen tilgængelige albummer." "O tilgængelige billeder/videoer." diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index 05b4170f0..f2dc98ec5 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -46,10 +46,8 @@ "Hintergrund wird festgelegt..." "Hintergrund" "Löschen" - - - - + "Löschvorgang bestätigen?" + "Bestätigen" "Abbrechen" "Teilen" "Alle auswählen" @@ -101,7 +99,8 @@ "Bilder und Videos" "Fotogalerie" "Keine Fotos vorhanden" - "Zugeschnittenes Bild unter Downloads gespeichert" + + "Zugeschnittenes Bild wurde nicht gespeichert." "Keine Alben verfügbar" "Keine Bilder oder Videos vorhanden" diff --git a/res/values-el/strings.xml b/res/values-el/strings.xml index 4b5b3c3d7..4ecd5c3e2 100644 --- a/res/values-el/strings.xml +++ b/res/values-el/strings.xml @@ -46,10 +46,8 @@ "Ορισμός ταπετσαρίας..." "Ταπετσαρία" "Διαγραφή" - - - - + "Επιβεβαίωση διαγραφής" + "Επιβεβαίωση" "Ακύρωση" "Κοινή χρήση" "Επιλογή όλων" @@ -101,7 +99,8 @@ "Εικόνες και βίντεο" "Συλλογή φωτογραφιών" "Δεν υπάρχουν φωτογραφίες." - "Η αποκομμένη εικόνα αποθηκεύτηκε στις \"Λήψεις\"." + + "Δεν αποθηκεύτηκε η αποκομένη εικόνα." "Δεν υπάρχουν διαθέσιμα λευκώματα." "Δεν υπάρχουν διαθέσιμες εικόνες/βίντεο." diff --git a/res/values-en-rGB/strings.xml b/res/values-en-rGB/strings.xml index 5447e8b13..fe65c3bba 100644 --- a/res/values-en-rGB/strings.xml +++ b/res/values-en-rGB/strings.xml @@ -99,7 +99,8 @@ "Images & videos" "Photo Gallery" "No photos." - "Cropped image saved to Downloads." + + "Cropped image wasn\'t saved." "No albums available." "O images/videos available." diff --git a/res/values-es-rUS/strings.xml b/res/values-es-rUS/strings.xml index 9a13cdfb5..78032d336 100644 --- a/res/values-es-rUS/strings.xml +++ b/res/values-es-rUS/strings.xml @@ -101,7 +101,8 @@ "Imágenes y videos" "Galería de fotos" "No hay fotos." - "La imagen recortada se guardó en Descargas." + + "No se ha guardado la imagen recortada." "No hay álbumes disponibles." "No hay imágenes/videos disponibles." diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index dcca6e6a8..0523bf4c0 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -46,10 +46,8 @@ "Estableciendo fondo de pantalla..." "Fondo de pantalla" "Borrar" - - - - + "¿Confirmar eliminación?" + "Confirmar" "Cancelar" "Compartir" "Seleccionar todo" @@ -101,7 +99,8 @@ "Imágenes y vídeos" "Galería de fotos" "No hay fotos." - "La imagen recortada se ha guardado en Descargas." + + "No se ha guardado la imagen recortada." "No hay álbumes disponibles." "No hay imágenes ni vídeos disponibles." diff --git a/res/values-et/strings.xml b/res/values-et/strings.xml index a7bc4eda5..3d431467e 100644 --- a/res/values-et/strings.xml +++ b/res/values-et/strings.xml @@ -46,10 +46,8 @@ "Taustapildi määramine ..." "Taustapilt" "Kustuta" - - - - + "Kas kinnitada kustutamine?" + "Kinnitamine" "Tühista" "Jaga" "Vali kõik" @@ -101,7 +99,8 @@ "Kujutised ja videod" "Fotogalerii" "Fotod puuduvad." - "Kärbitud kujutis salvestati allalaadimiste kausta." + + "Kärbitud kujutist ei salvestatud." "Ühtegi albumit pole saadaval." "O kujutist/videot on saadaval." diff --git a/res/values-fa/strings.xml b/res/values-fa/strings.xml index cecd272cc..753d64b90 100644 --- a/res/values-fa/strings.xml +++ b/res/values-fa/strings.xml @@ -101,7 +101,8 @@ "تصاویر و ویدیوها" "گالری عکس" "عکسی موجود نیست." - "تصویر بریده شده در \"دانلودها\" ذخیره شد." + + "تصویر برش‌خورده ذخیره نشد." "آلبومی موجود نیست." "O تصویر/ویدیو موجود است." diff --git a/res/values-fi/strings.xml b/res/values-fi/strings.xml index 9f370ea58..16075c4e8 100644 --- a/res/values-fi/strings.xml +++ b/res/values-fi/strings.xml @@ -46,10 +46,8 @@ "Asetetaan taustakuvaa..." "taustakuvaksi" "Poista" - - - - + "Vahvista poistaminen?" + "Vahvista" "Peruuta" "Jaa" "Valitse kaikki" @@ -101,7 +99,8 @@ "Kuvat ja videot" "Kuvagalleria" "Ei valokuvia." - "Rajattu kuva tallennetaan Lataukset-kansioon." + + "Rajattua kuvaa ei tallennettu." "Ei albumeja käytettävissä." "0 kuvaa/videota saatavilla." diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index 36c04f6af..0e054b65c 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -46,10 +46,8 @@ "Définition du fond d\'écran…" "Fond d\'écran" "Supprimer" - - - - + "Confirmer la suppression ?" + "Confirmer" "Annuler" "Partager" "Tout sélectionner" @@ -101,7 +99,8 @@ "Images et vidéos" "Galerie photos" "Aucune photo" - "Image rognée enregistrée dans \"Téléchargements\"." + + "L\'image rognée n\'a pas été enregistrée." "Aucun album disponible." "Aucune image/vidéo disponible." diff --git a/res/values-hi/strings.xml b/res/values-hi/strings.xml index 93d95faaa..df31be80b 100644 --- a/res/values-hi/strings.xml +++ b/res/values-hi/strings.xml @@ -101,7 +101,8 @@ "छवियां और वीडियो" "फ़ोटो गैलरी" "कोई फ़ोटो नहीं." - "काट-छांट की गई छवि को डाउनलोड में सहेजा गया." + + "काट-छांट की गई छवि को नहीं सहेजा गया." "कोई एल्‍बम उपलब्‍ध नहीं." "O छवियां/वीडियो उपलब्‍ध." diff --git a/res/values-hr/strings.xml b/res/values-hr/strings.xml index f2c755bf8..fb3d2ed85 100644 --- a/res/values-hr/strings.xml +++ b/res/values-hr/strings.xml @@ -101,7 +101,8 @@ "Slike i videozapisi" "Galerija fotografija" "Nema fotografija." - "Obrezana slika spremljena u Preuzimanja." + + "Obrezana slika nije spremljena." "Nema dostupnih albuma." "Dostupno je 0 slika/videozapisa." diff --git a/res/values-hu/strings.xml b/res/values-hu/strings.xml index f07ab56f4..583782480 100644 --- a/res/values-hu/strings.xml +++ b/res/values-hu/strings.xml @@ -101,7 +101,8 @@ "Képek és videók" "Fotógaléria" "Nincsenek fényképek." - "A vágott kép a Letöltések közé került." + + "A vágott kép nincs elmentve." "Nincs elérhető album." "Nincs elérhető kép/videó." diff --git a/res/values-in/strings.xml b/res/values-in/strings.xml index 48d03edd3..532a98ae9 100644 --- a/res/values-in/strings.xml +++ b/res/values-in/strings.xml @@ -101,7 +101,8 @@ "Gambar & video" "Galeri Foto" "Tidak ada foto." - "Gambar yang dipangkas disimpan ke Unduhan." + + "Gambar yang dipangkas tidak disimpan." "Tidak ada album yang tersedia." "O gambar/video tersedia." diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index e1975ac99..b8f992ee8 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -46,10 +46,8 @@ "Impostazione sfondo..." "Sfondo" "Elimina" - - - - + "Confermi l\'eliminazione?" + "Conferma" "Annulla" "Condividi" "Seleziona tutti" @@ -101,7 +99,8 @@ "Immagini e video" "Galleria fotografica" "Nessuna foto." - "Immagine ritagliata salvata in Download." + + "L\'immagine ritagliata non è stata salvata." "Nessun album disponibile." "Nessun video/immagine disponibile." diff --git a/res/values-iw/strings.xml b/res/values-iw/strings.xml index fd9ab85bc..c4f34dab9 100644 --- a/res/values-iw/strings.xml +++ b/res/values-iw/strings.xml @@ -99,7 +99,8 @@ "תמונות וסרטונים" "גלריית תמונות" "אין תמונות." - "התמונה החתוכה נשמרה ב\'הורדות\'." + + "התמונה החתוכה לא נשמרה." "אין אלבומים זמינים." "O תמונות/סרטוני וידאו זמינים." diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml index 6ad2735cf..ed587cf7b 100644 --- a/res/values-ja/strings.xml +++ b/res/values-ja/strings.xml @@ -101,7 +101,8 @@ "画像と動画" "フォトギャラリー" "画像がありません。" - "トリミングした画像を[ダウンロード]に保存しました。" + + "トリミングした画像は保存されていません。" "使用できるアルバムはありません。" "使用できる画像/動画: 0件" diff --git a/res/values-ko/strings.xml b/res/values-ko/strings.xml index e285dceaa..f59af3c1a 100644 --- a/res/values-ko/strings.xml +++ b/res/values-ko/strings.xml @@ -101,7 +101,8 @@ "이미지 및 동영상" "사진 갤러리" "사진이 없습니다." - "잘린 이미지가 다운로드에 저장되었습니다." + + "잘린 이미지가 저장되지 않았습니다." "사용할 수 있는 앨범이 없습니다." "사용할 수 있는 이미지/동영상이 없습니다." diff --git a/res/values-lt/strings.xml b/res/values-lt/strings.xml index 677cc5b6c..0605ef832 100644 --- a/res/values-lt/strings.xml +++ b/res/values-lt/strings.xml @@ -101,7 +101,8 @@ "Vaizdai ir vaizdo įrašai" "Nuotraukų galerija" "Nėra nuotraukų." - "Apkarpytas vaizdas išsaug. skilt. „Atsisiuntimai“." + + "Apkarpytas vaizdas neišsaugotas." "Nėra pasiekiamų albumų." "Nepasiekiami jokie vaizdai / vaizdo įrašai." diff --git a/res/values-lv/strings.xml b/res/values-lv/strings.xml index c66b0cc37..0dce0a5da 100644 --- a/res/values-lv/strings.xml +++ b/res/values-lv/strings.xml @@ -46,10 +46,8 @@ "Notiek fona tapetes iestatīšana..." "Fona tapete" "Dzēst" - - - - + "Vai apstiprināt dzēšanu?" + "Apstiprināt" "Atcelt" "Dalies" "Atlasīt visu" @@ -101,7 +99,8 @@ "Attēli un videoklipi" "Fotogalerija" "Nav fotoattēlu." - "Izgrieztais attēls ir saglabāts mapē Lejupielādes." + + "Izgrieztais attēls netika saglabāts." "Nav pieejams neviens albums." "Nav pieejams neviens attēls/videoklips." diff --git a/res/values-ms/strings.xml b/res/values-ms/strings.xml index 0a0c4dccd..127667e6a 100644 --- a/res/values-ms/strings.xml +++ b/res/values-ms/strings.xml @@ -101,7 +101,8 @@ "Imej & video" "Galeri Foto" "Tiada foto." - "Imej yang dipangkas disimpan ke Muat Turun." + + "Imej yang dipangkas tidak disimpan." "Tiada album tersedia." "O imej/video yang tersedia." diff --git a/res/values-nb/strings.xml b/res/values-nb/strings.xml index d868e08c8..c1b30d21a 100644 --- a/res/values-nb/strings.xml +++ b/res/values-nb/strings.xml @@ -99,7 +99,8 @@ "Bilder og videoer" "Fotogalleri" "Ingen bilder." - "Beskåret bilde lagret i Nedlastinger." + + "Beskåret bilde ble ikke lagret." "Ingen album tilgjengelig." "0 bilder/videoer tilgjengelig." diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml index ec93df3c7..bf000c05e 100644 --- a/res/values-nl/strings.xml +++ b/res/values-nl/strings.xml @@ -46,10 +46,8 @@ "Achtergrond instellen..." "Achtergrond" "Verwijderen" - - - - + "Verwijdering bevestigen?" + "Bevestigen" "Annuleren" "Delen" "Alles selecteren" @@ -101,7 +99,8 @@ "Afbeeldingen en video\'s" "Fotogalerij" "Geen foto\'s." - "Bijgesneden afbeelding opgeslagen in Downloads." + + "Bijgesneden afbeelding is niet opgeslagen." "Geen albums beschikbaar." "0 afbeeldingen/video\'s beschikbaar." diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml index ead785957..ee9dbcbc6 100644 --- a/res/values-pl/strings.xml +++ b/res/values-pl/strings.xml @@ -101,7 +101,8 @@ "Obrazy i filmy" "Galeria zdjęć" "Brak zdjęć" - "Przycięty obraz zapisano w Pobranych plikach." + + "Przycięty obraz nie został zapisany." "Brak dostępnych albumów" "O dostępnych obrazów/filmów" diff --git a/res/values-pt-rPT/strings.xml b/res/values-pt-rPT/strings.xml index d96049b78..d49a067ab 100644 --- a/res/values-pt-rPT/strings.xml +++ b/res/values-pt-rPT/strings.xml @@ -101,7 +101,8 @@ "Imagens e vídeos" "Galeria de fotografias" "Não existem fotografias." - "Imagem recortada guardada em Transferências." + + "A imagem recortada não foi guardada." "Nenhum álbum disponível." "0 imagens/vídeos disponíveis." diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml index 9b516dfcc..072312e91 100644 --- a/res/values-pt/strings.xml +++ b/res/values-pt/strings.xml @@ -46,10 +46,8 @@ "Definindo plano de fundo..." "Plano de fundo" "Excluir" - - - - + "Confirmar exclusão?" + "Confirmar" "Cancelar" "Compartilhar" "Selecionar tudo" @@ -101,7 +99,8 @@ "Imagens e vídeos" "Galeria de fotos" "Nenhuma foto." - "A imagem cortada foi salva em Downloads." + + "A imagem cortada não foi salva." "Nenhum álbum disponível." "0 imagens/vídeos disponíveis." diff --git a/res/values-rm/strings.xml b/res/values-rm/strings.xml index 6cfa1d0b8..a00f88b5c 100644 --- a/res/values-rm/strings.xml +++ b/res/values-rm/strings.xml @@ -139,7 +139,7 @@ - + diff --git a/res/values-ro/strings.xml b/res/values-ro/strings.xml index 0b531fb31..d9f84c6a4 100644 --- a/res/values-ro/strings.xml +++ b/res/values-ro/strings.xml @@ -101,7 +101,8 @@ "Imagini şi videoclipuri" "Galerie foto" "Nicio fotografie." - "Imaginea decupată a fost salvată la Descărcări." + + "Imaginea decupată nu a fost salvată." "Nu există albume disponibile." "Nu există imagini/videoclipuri disponibile." diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index 1d62e9264..e8f6892e7 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -101,7 +101,8 @@ "Изображения и видео" "Фотогалерея" "Нет фотографий" - "Изображение сохранено в папке \"Загрузки\"." + + "Изображение не сохранено." "Нет доступных альбомов." "Нет фото/видео" diff --git a/res/values-sk/strings.xml b/res/values-sk/strings.xml index b107b9171..25b29b198 100644 --- a/res/values-sk/strings.xml +++ b/res/values-sk/strings.xml @@ -101,7 +101,8 @@ "Obrázky a videá" "Fotogaléria" "Žiadne fotografie." - "Orez. obrázok bol uložený do Prevzatých súborov." + + "Orezaný obrázok nebol uložený." "Nie sú k dispozícii žiadne albumy." "Počet obrázkov / videí k dispozícii: 0" diff --git a/res/values-sl/strings.xml b/res/values-sl/strings.xml index 40c878708..b4913ff5a 100644 --- a/res/values-sl/strings.xml +++ b/res/values-sl/strings.xml @@ -46,10 +46,8 @@ "Nastavljanje slike za ozadje ..." "Slika za ozadje" "Izbriši" - - - - + "Potrjujete brisanje?" + "Potrdi" "Prekliči" "Skupna raba" "Izberi vse" @@ -101,7 +99,8 @@ "Slike in videoposnetki" "Fotogalerija" "Ni fotografij." - "Obrezana slika je shranjena v prenose." + + "Obrezana slika ni bila shranjena." "Ni albumov." "Na voljo 0 slik oz. videoposnetkov." diff --git a/res/values-sr/strings.xml b/res/values-sr/strings.xml index c200f2c69..b684ee942 100644 --- a/res/values-sr/strings.xml +++ b/res/values-sr/strings.xml @@ -101,7 +101,8 @@ "Слике и видео снимци" "Фото-галерија" "Нема фотографија." - "Опсечена слика је сачувана у Преузимањима." + + "Опсечена слика није сачувана." "Ниједан албум није доступан." "Доступно је 0 слика/видео снимака." diff --git a/res/values-sv/strings.xml b/res/values-sv/strings.xml index 71cec0651..2f4c152d7 100644 --- a/res/values-sv/strings.xml +++ b/res/values-sv/strings.xml @@ -99,7 +99,8 @@ "Bilder och videor" "Fotogalleri" "Inga foton." - "Den beskurna bilden sparades i Hämtningar." + + "Den beskurna bilden sparades inte." "Det finns inga album." "Det finns inga bilder/videor." diff --git a/res/values-sw/strings.xml b/res/values-sw/strings.xml index 634eb25ca..108408b8b 100644 --- a/res/values-sw/strings.xml +++ b/res/values-sw/strings.xml @@ -46,10 +46,8 @@ "Inaweka karatasi ya ukuta..." "Mandhari" "Futa" - - - - + "Thibitisha ufutaji?" + "Thibitisha" "Ghairi" "Shiriki" "Chagua zote" @@ -104,7 +102,8 @@ "Picha & video" "Matunzio ya picha" "Hakuna picha." - "Picha iliyopunguzwa imehifadhiwa kwa Vipakuzi." + + "Picha iliyopunguzwa haijahifadhiwa" "Hakuna albamu zinazopatikana." "picha / video zilizopo 0." diff --git a/res/values-th/strings.xml b/res/values-th/strings.xml index 53024eaa4..e94387b4f 100644 --- a/res/values-th/strings.xml +++ b/res/values-th/strings.xml @@ -101,7 +101,8 @@ "ภาพและวิดีโอ" "แกลเลอรีรูปภาพ" "ไม่มีรูปภาพ" - "ภาพที่ตัดจะได้รับการบันทึกไว้ในโฟลเดอร์ดาวน์โหลด" + + "ภาพที่ตัดไม่ได้รับการบันทึก" "ไม่มีอัลบั้ม" "O ภาพ/วิดีโอ" diff --git a/res/values-tl/strings.xml b/res/values-tl/strings.xml index 46a1a9863..008fcb9f6 100644 --- a/res/values-tl/strings.xml +++ b/res/values-tl/strings.xml @@ -101,7 +101,8 @@ "Mga larawan & video" "Photo Gallery" "Walang mga larawan." - "Nai-save ang na-crop na larawan sa Mga Download." + + "Hindi nai-save ang na-crop na larawan." "Walang available na mga album." "O na larawan/video ang available." diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml index dab142344..c3dd3a661 100644 --- a/res/values-tr/strings.xml +++ b/res/values-tr/strings.xml @@ -101,7 +101,8 @@ "Resimler ve videolar" "Fotoğraf Galerisi" "Fotoğraf yok." - "Kırpılmış resim İndirilenler klasörüne kaydedildi." + + "Kırpılmış resim kaydedilmedi." "Kullanılabilir albüm yok." "Kullanılabilir resim/video yok." diff --git a/res/values-uk/strings.xml b/res/values-uk/strings.xml index 27aae30f5..9d4f14d84 100644 --- a/res/values-uk/strings.xml +++ b/res/values-uk/strings.xml @@ -101,7 +101,8 @@ "Зображення й відео" "Фотогалерея" "Фотографій немає." - "Обрізане зображення збережено в папці завантажень." + + "Обрізане зображення не збережено." "Немає доступних альбомів." "Немає доступних зображень або відео." diff --git a/res/values-vi/strings.xml b/res/values-vi/strings.xml index 325b0a858..4023a5a08 100644 --- a/res/values-vi/strings.xml +++ b/res/values-vi/strings.xml @@ -101,7 +101,8 @@ "Hình ảnh & video" "Thư viện ảnh" "Không có ảnh." - "Đã lưu hình ảnh được cắt vào Tải xuống." + + "Hình ảnh được cắt chưa được lưu." "Không có album nào." "O có hình ảnh/video nào." diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index 311578416..76f17f27a 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -101,7 +101,8 @@ "图片和视频" "照片库" "无照片。" - "经过裁剪的图片已保存至“下载内容”文件夹。" + + "经过裁剪的图片尚未保存。" "没有可用的相册。" "没有可用的图片/视频。" diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml index 10d439222..2affe7e07 100644 --- a/res/values-zh-rTW/strings.xml +++ b/res/values-zh-rTW/strings.xml @@ -101,7 +101,8 @@ "圖片和影片" "相片庫" "沒有任何相片。" - "裁剪的圖片已儲存至「下載」資料夾。" + + "未儲存裁剪的圖片。" "沒有相簿。" "O 個可用的圖片/影片。" diff --git a/res/values-zu/strings.xml b/res/values-zu/strings.xml index 58cc4af24..fe465b155 100644 --- a/res/values-zu/strings.xml +++ b/res/values-zu/strings.xml @@ -46,10 +46,8 @@ "Isetha iphephadonga..." "Iphephadonga" "Susa" - - - - + "Qinisekisa ukususa?" + "Qinisekisa" "Khansela" "Yabelana" "Khetha konke" @@ -101,7 +99,8 @@ "Izithombe namavidiyo" "Igalari Yesithombe" "Azikho izithombe" - "Isithombe esincishisiwe silondolozwe kokulayishwe ngokungenisa." + + "Umfanekiso onqampuliwe awulondoloziwe" "Awekho ama-albhamu atholalakalayo." "O izithombe/amavidiyo okutholakalayo." -- GitLab From 158d6a42741a7d0b03ece11071a142691217592e Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Thu, 26 Apr 2012 12:52:11 -0700 Subject: [PATCH 005/763] Import translations. DO NOT MERGE Change-Id: Ibe4ad2e00e95790e7891fc0d9e035fcb744629b9 --- res/values-af/photoeditor_strings.xml | 13 ++++++++----- res/values-am/photoeditor_strings.xml | 13 ++++++++----- res/values-ar/photoeditor_strings.xml | 13 ++++++++----- res/values-be/photoeditor_strings.xml | 13 ++++++++----- res/values-bg/photoeditor_strings.xml | 13 ++++++++----- res/values-ca/photoeditor_strings.xml | 13 ++++++++----- res/values-cs/photoeditor_strings.xml | 13 ++++++++----- res/values-da/photoeditor_strings.xml | 13 ++++++++----- res/values-de/photoeditor_strings.xml | 13 ++++++++----- res/values-el/photoeditor_strings.xml | 13 ++++++++----- res/values-en-rGB/photoeditor_strings.xml | 13 ++++++++----- res/values-es-rUS/photoeditor_strings.xml | 13 ++++++++----- res/values-es/photoeditor_strings.xml | 13 ++++++++----- res/values-et/photoeditor_strings.xml | 13 ++++++++----- res/values-fa/photoeditor_strings.xml | 13 ++++++++----- res/values-fi/photoeditor_strings.xml | 13 ++++++++----- res/values-fr/photoeditor_strings.xml | 13 ++++++++----- res/values-hi/photoeditor_strings.xml | 13 ++++++++----- res/values-hr/photoeditor_strings.xml | 13 ++++++++----- res/values-hu/photoeditor_strings.xml | 13 ++++++++----- res/values-in/photoeditor_strings.xml | 13 ++++++++----- res/values-it/photoeditor_strings.xml | 13 ++++++++----- res/values-iw/photoeditor_strings.xml | 13 ++++++++----- res/values-ja/photoeditor_strings.xml | 13 ++++++++----- res/values-ko/photoeditor_strings.xml | 13 ++++++++----- res/values-lt/photoeditor_strings.xml | 13 ++++++++----- res/values-lv/photoeditor_strings.xml | 13 ++++++++----- res/values-ms/photoeditor_strings.xml | 13 ++++++++----- res/values-nb/photoeditor_strings.xml | 13 ++++++++----- res/values-nl/photoeditor_strings.xml | 13 ++++++++----- res/values-pl/photoeditor_strings.xml | 13 ++++++++----- res/values-pt-rPT/photoeditor_strings.xml | 13 ++++++++----- res/values-pt/photoeditor_strings.xml | 13 ++++++++----- res/values-ro/photoeditor_strings.xml | 13 ++++++++----- res/values-ru/photoeditor_strings.xml | 13 ++++++++----- res/values-sk/photoeditor_strings.xml | 13 ++++++++----- res/values-sl/photoeditor_strings.xml | 13 ++++++++----- res/values-sr/photoeditor_strings.xml | 13 ++++++++----- res/values-sv/photoeditor_strings.xml | 13 ++++++++----- res/values-sw/photoeditor_strings.xml | 13 ++++++++----- res/values-th/photoeditor_strings.xml | 13 ++++++++----- res/values-tl/photoeditor_strings.xml | 13 ++++++++----- res/values-tr/photoeditor_strings.xml | 13 ++++++++----- res/values-uk/photoeditor_strings.xml | 13 ++++++++----- res/values-vi/photoeditor_strings.xml | 13 ++++++++----- res/values-zh-rCN/photoeditor_strings.xml | 13 ++++++++----- res/values-zh-rTW/photoeditor_strings.xml | 13 ++++++++----- res/values-zu/photoeditor_strings.xml | 13 ++++++++----- 48 files changed, 384 insertions(+), 240 deletions(-) diff --git a/res/values-af/photoeditor_strings.xml b/res/values-af/photoeditor_strings.xml index f9e87d8db..5cff1185a 100644 --- a/res/values-af/photoeditor_strings.xml +++ b/res/values-af/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Fotoateljee" - "Foto kan nie gelaai word nie" - "Foto kan nie gestoor word nie" - "Foto gestoor in %s album" - "Geredigeer" + + + + + + "Stoor geredigeerde foto?" "Ja" "Nee" @@ -55,7 +57,8 @@ "Trek merkers om foto te sny" "Teken op foto om te krabbel" "Trek foto om dit om te keer" - "Tik om rooi oë te verwyder" + + "Trek foto om dit te draai" "Trek foto om dit reguit te trek" diff --git a/res/values-am/photoeditor_strings.xml b/res/values-am/photoeditor_strings.xml index 83971d638..7f0fbd494 100644 --- a/res/values-am/photoeditor_strings.xml +++ b/res/values-am/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Photo Studio" - "ፎቶ ሊሰቀል አይችልም" - "ፎቶ ሊሰቀል አልተቻለም" - "ፎቶ ወደ %s አልበም ተቀምጧል" - "አርትእ ተደርጓል" + + + + + + "ማስተካከያ የተደረገበት ፎቶ ይቀመጥ?" "አዎ" "አይ" @@ -55,7 +57,8 @@ "ፎቶ ለመከርከም አመልካቾችን ጎትት" "ፎቶውን doodle ለማድረግ ሳል" "ፎቶውን በፍጥነት ለመግለጥ ጎትት" - "ቀይነጥብ ለማስወገድ ሁለቴ ንካ" + + "ፎቶውንለማሽከርከር ጎትት" "ፎቶውንቀጥ ለማደረግ ጎትት" diff --git a/res/values-ar/photoeditor_strings.xml b/res/values-ar/photoeditor_strings.xml index 301481c5e..a4c2e699a 100644 --- a/res/values-ar/photoeditor_strings.xml +++ b/res/values-ar/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Photo Studio" - "لا يمكن تحميل الصورة" - "لا يمكن حفظ الصورة" - "تم حفظ الصورة إلى الألبوم %s" - "صور معدلة" + + + + + + "هل تريد حفظ الصورة التي تم تعديلها؟" "نعم" "لا" @@ -55,7 +57,8 @@ "اسحب العلامات لاقتصاص الصورة" "اسحب الصورة لإنشاء رسومات مبتكرة" "اسحب الصورة لقلبها" - "انقر لإزالة الأعين الحمراء" + + "اسحب الصورة لتدويرها" "اسحب الصورة لتسويتها" diff --git a/res/values-be/photoeditor_strings.xml b/res/values-be/photoeditor_strings.xml index 8984b1466..fac393ea7 100644 --- a/res/values-be/photoeditor_strings.xml +++ b/res/values-be/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Фотастудыя" - "Немагчыма загрузіць фатаграфію" - "Немагчыма захаваць фатаграфію" - "Фатаграфія захаваная ў альбом %s" - "Рэдагаванае" + + + + + + "Захаваць адрэдагаванае фота?" "Так" "Не" @@ -55,7 +57,8 @@ "Перацягнуць маркеры, каб абрэзаць фота" "Перац. фота, каб пераўтв. яго ў святоч. лагатып" "Перацягніце фатаграфію, каб перавярнуць яе" - "Націсніце, каб лiквiдаваць эфект чырвоных вачэй" + + "Перацягніце фатаграфію, каб павярнуць яе" "Перацягніце фатаграфію, каб выпраміць яе" diff --git a/res/values-bg/photoeditor_strings.xml b/res/values-bg/photoeditor_strings.xml index facb0d1e3..bac5c04a6 100644 --- a/res/values-bg/photoeditor_strings.xml +++ b/res/values-bg/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Photo Studio" - "Снимката не може да бъде заредена" - "Снимката не може да бъде запазена" - "Снимката е запазена в албума „%s“" - "Редактирани" + + + + + + "Да се запази ли редактираната снимка?" "Да" "Нe" @@ -55,7 +57,8 @@ "Плъзнете маркерите, за да подрежете снимката" "Рисувайте директно върху снимката" "Плъзнете с пръст върху снимката, за да я обърнете" - "Докоснете, за да премахнете „червени очи“" + + "Плъзнете с пръст върху снимката, за да я завъртите" "Плъзнете с пръст върху снимката, за да я изправите" diff --git a/res/values-ca/photoeditor_strings.xml b/res/values-ca/photoeditor_strings.xml index 9c2d31dc9..3dc22a393 100644 --- a/res/values-ca/photoeditor_strings.xml +++ b/res/values-ca/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Estudi de fotografia" - "La foto no es pot carregar" - "La foto no es pot desar" - "S\'ha desat la foto a l\'àlbum %s" - "Editades" + + + + + + "Vols desar la foto editada?" "Sí" "No" @@ -55,7 +57,8 @@ "Arrossega els marcadors per retallar la foto" "Arrossega el cursor sobre la foto per dibuixar" "Arrossega la foto per invertir-la" - "Toca per eliminar els ulls vermells" + + "Arrossega la foto per girar-la" "Arrossega la foto per redreçar-la" diff --git a/res/values-cs/photoeditor_strings.xml b/res/values-cs/photoeditor_strings.xml index 48ef93247..f59c2fa38 100644 --- a/res/values-cs/photoeditor_strings.xml +++ b/res/values-cs/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Photo Studio" - "Fotku nelze nahrát." - "Fotku nelze uložit." - "Fotka uložena do alba %s" - "Upraveno" + + + + + + "Chcete upravenou fotografii uložit?" "Ano" "Ne" @@ -55,7 +57,8 @@ "Táhnutím značek fotografii oříznete" "Na fotografii můžete kreslit prstem" "Táhnutím prstem fotografii převrátíte" - "Klepnutím odstraníte červené oči" + + "Táhnutím prstem fotografii otočíte" "Táhnutím prstem fotografii narovnáte" diff --git a/res/values-da/photoeditor_strings.xml b/res/values-da/photoeditor_strings.xml index 447fabf25..2331cb318 100644 --- a/res/values-da/photoeditor_strings.xml +++ b/res/values-da/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Fotostudie" - "Billedet kan ikke indlæses" - "Billedet kan ikke gemmes" - "Billedet gemmes i albummet %s" - "Redigeret" + + + + + + "Vil du gemme det redigerede billede?" "Ja" "Nej" @@ -55,7 +57,8 @@ "Træk markører for at beskære billedet" "Tegn på billedet for at lave kruseduller" "Træk billedet for at vende det" - "Tryk for at fjerne røde øjne" + + "Træk billedet for at rotere det" "Træk i billedet for at rette det op" diff --git a/res/values-de/photoeditor_strings.xml b/res/values-de/photoeditor_strings.xml index b57502cd3..36ccfe0ae 100644 --- a/res/values-de/photoeditor_strings.xml +++ b/res/values-de/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Photo Studio" - "Foto kann nicht geladen werden." - "Foto kann nicht gespeichert werden." - "Foto in Album %s gespeichert" - "Bearbeitet" + + + + + + "Bearbeitetes Foto speichern?" "Ja" "Nein" @@ -55,7 +57,8 @@ "Zum Zuschneiden des Fotos Markierungen ziehen" "Zum Malen auf dem Foto malen" "Foto ziehen, um es umzudrehen" - "Zum Entfernen roter Augen tippen" + + "Foto ziehen, um es zu drehen" "Foto ziehen, um es zu strecken" diff --git a/res/values-el/photoeditor_strings.xml b/res/values-el/photoeditor_strings.xml index 88ece2602..2df08fdd7 100644 --- a/res/values-el/photoeditor_strings.xml +++ b/res/values-el/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Photo Studio" - "Αδύν.φόρτ.φωτογραφ." - "Αδύν.αποθ.φωτογρ." - "Η φωτ. αποθηκεύτηκε στο λεύκωμα %s" - "Επεξεργασμ." + + + + + + "Αποθήκευση επεξεργασμένης φωτογραφίας;" "Ναι" "Όχι" @@ -55,7 +57,8 @@ "Σύρετε τους δείκτες για την περικοπή της φωτογραφίας" "Σχεδιάστε στη φωτογραφία για να δημιουργήσετε ένα σκετσάκι" "Σύρετε τη φωτογραφία για να την αναστρέψετε" - "Πατήστε για να αφαιρέσετε τα κόκκινα μάτια" + + "Σύρετε τη φωτογραφία για να την περιστρέψετε" "Σύρετε τη φωτογραφία για να την ευθυγραμμίσετε" diff --git a/res/values-en-rGB/photoeditor_strings.xml b/res/values-en-rGB/photoeditor_strings.xml index 04660ae93..7bd35a38f 100644 --- a/res/values-en-rGB/photoeditor_strings.xml +++ b/res/values-en-rGB/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Photo Studio" - "Photo cannot be loaded." - "Photo cannot be saved" - "Photo saved to %s album" - "Edited" + + + + + + "Save edited photo?" "Yes" "No" @@ -55,7 +57,8 @@ "Drag markers to crop photo" "Draw on photo to doodle" "Drag photo to flip it" - "Tap to remove red eyes" + + "Drag photo to rotate it" "Drag photo to straighten it" diff --git a/res/values-es-rUS/photoeditor_strings.xml b/res/values-es-rUS/photoeditor_strings.xml index d6bd2b895..ab34bcc7b 100644 --- a/res/values-es-rUS/photoeditor_strings.xml +++ b/res/values-es-rUS/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Estudio de fotografía" - "No se puede cargar la foto." - "No se puede guardar la foto." - "La foto se guardó en el álbum %s." - "Editadas" + + + + + + "¿Guardar foto editada?" "Sí" "No" @@ -55,7 +57,8 @@ "Arrastrar los marcadores para recortar la foto" "Dibuja en la foto para hacer garabatos" "Arrastra la foto para darla vuelta" - "Toca para eliminar los ojos rojos" + + "Arrastra la foto para hacerla girar" "Arrastra la foto para enderezarla" diff --git a/res/values-es/photoeditor_strings.xml b/res/values-es/photoeditor_strings.xml index e86d69f51..906453446 100644 --- a/res/values-es/photoeditor_strings.xml +++ b/res/values-es/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Photo Studio" - "No se puede cargar la foto." - "No se puede guardar la foto." - "Foto guardada en el álbum %s" - "Editadas" + + + + + + "¿Quieres guardar la foto editada?" "Sí" "No" @@ -55,7 +57,8 @@ "Arrastra los marcadores para recortar la foto" "Dibuja en la foto para hacer garabatos" "Arrastra la foto para darle la vuelta" - "Toca para eliminar los ojos rojos" + + "Arrastra la foto para girarla" "Arrastra la foto para enderezarla" diff --git a/res/values-et/photoeditor_strings.xml b/res/values-et/photoeditor_strings.xml index eea16a28c..1c25bbbdb 100644 --- a/res/values-et/photoeditor_strings.xml +++ b/res/values-et/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Fotostuudio" - "Fotot ei saa laadida" - "Fotot ei saa salvestada" - "Foto salvestati albumisse %s" - "Muudetud" + + + + + + "Kas salvestada muudetud foto?" "Jah" "Ei" @@ -55,7 +57,8 @@ "Foto kärpimiseks lohistage markereid" "Kritseldamiseks joonistage fotol" "Ümberpööramiseks lohistage fotot" - "Puudutage punasilmsuse eemaldamiseks" + + "Pööramiseks lohistage fotot" "Rihtimiseks lohistage fotot" diff --git a/res/values-fa/photoeditor_strings.xml b/res/values-fa/photoeditor_strings.xml index 16b15465d..19983700a 100644 --- a/res/values-fa/photoeditor_strings.xml +++ b/res/values-fa/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Photo Studio" - "عکس بارگیری نمی‌شود" - "عکس ذخیره نمی‌شود" - "عکس در آلبوم %s ذخیره شد" - "ویرایش شده" + + + + + + "عکس ویرایش شده ذخیره شود؟" "بله" "خیر" @@ -55,7 +57,8 @@ "برای بریدن عکس نشانگرها را بکشید" "برای doodle کردن روی عکس رسم کنید" "برای وارونه کردن عکس آن را بکشید" - "برای حذف قرمزی چشم ضربه بزنید" + + "برای چرخاندن عکس آن را بکشید" "برای صاف کردن عکس آن را بکشید" diff --git a/res/values-fi/photoeditor_strings.xml b/res/values-fi/photoeditor_strings.xml index 2bb64856a..2caa636ae 100644 --- a/res/values-fi/photoeditor_strings.xml +++ b/res/values-fi/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Valokuvastudio" - "Kuvaa ei voi ladata." - "Kuvaa ei voi tallentaa." - "Kuva tallennettu albumiin %s." - "Muokattu" + + + + + + "Tallennetaanko muokattu valokuva?" "Kyllä" "Ei" @@ -55,7 +57,8 @@ "Leikkaa kuvaa vetämällä merkkejä" "Piirrä valokuvaan siirtämällä osoitin sen päälle" "Käännä kuva vetämällä" - "Poista punaiset silmät napauttamalla" + + "Käännä valokuvaa vetämällä" "Suorista valokuva vetämällä" diff --git a/res/values-fr/photoeditor_strings.xml b/res/values-fr/photoeditor_strings.xml index a4d59eab9..cbb3f3cff 100644 --- a/res/values-fr/photoeditor_strings.xml +++ b/res/values-fr/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Photo Studio" - "Impossible de charger la photo." - "Impossible d\'enregistrer la photo." - "Photo enregistrée dans l\'album \"%s\"." - "Retouchées" + + + + + + "Enregistrer photo retouchée ?" "Oui" "Non" @@ -55,7 +57,8 @@ "Faire glisser les marqueurs pour rogner la photo" "Dessiner sur la photo pour gribouiller" "Faire glisser la photo pour la retourner" - "Appuyer pour supprimer les yeux rouges" + + "Faire glisser la photo pour la faire pivoter" "Faire glisser la photo pour la redresser" diff --git a/res/values-hi/photoeditor_strings.xml b/res/values-hi/photoeditor_strings.xml index 1f6ea0629..2f51b5589 100644 --- a/res/values-hi/photoeditor_strings.xml +++ b/res/values-hi/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Photo Studio" - "फ़ोटो लोड नहीं हो सकता" - "फ़ोटो सहेजा नहीं जा सकता" - "फ़ोटो %s एल्‍बम में सहेजा गया" - "संपादित" + + + + + + "संपादित फ़ोटो सहेजें?" "हां" "नहीं" @@ -55,7 +57,8 @@ "फ़ोटो की काट-छांट करने के लि‍ए मार्कर को खींचें" "doodle के लिए फ़ोटो पर आरेखित करें" "फ़ोटो को फ़्लिप करने के लिए उसे खींचें" - "रेड आई निकालने के लिए टैप करें" + + "घुमाने के लिए फ़ोटो को खींचें" "सीधा करने के लिए फ़ोटो को खींचें" diff --git a/res/values-hr/photoeditor_strings.xml b/res/values-hr/photoeditor_strings.xml index 077c19433..8e2c19a58 100644 --- a/res/values-hr/photoeditor_strings.xml +++ b/res/values-hr/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Fotostudio" - "Fotografiju nije moguće učitati" - "Fotografiju nije moguće spremiti" - "Fotografija spremljena u album %s" - "Uređeno" + + + + + + "Spremiti uređenu fotografiju?" "Da" "Ne" @@ -55,7 +57,8 @@ "Povucite oznake da biste obrezali sliku" "Crtanje na fotografiju za doodle logotip" "Povucite sliku da biste je preokrenuli" - "Dotaknite za uklanjanje crvenih očiju" + + "Povucite fotografiju da biste je rotirali" "Povucite fotografiju da biste je izravnali" diff --git a/res/values-hu/photoeditor_strings.xml b/res/values-hu/photoeditor_strings.xml index 0b60f1cdb..5c6c09ff2 100644 --- a/res/values-hu/photoeditor_strings.xml +++ b/res/values-hu/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Photo Studio" - "A fotót nem lehet betölteni" - "A fotót nem lehet menteni" - "Fotó mentve a(z) %s albumba" - "Szerkesztve" + + + + + + "A szerkesztett kép mentése?" "Igen" "Nem" @@ -55,7 +57,8 @@ "Húzza a jelölőket a fotó vágásához" "Rajzoljon a fotóra embléma létrehozásához" "Húzza a fotót annak tükrözéséhez" - "Érintse meg a vörös szem hatás eltávolításához" + + "Húzza a fényképet annak forgatásához" "Húzza a fényképet annak kiegyenesítéséhez" diff --git a/res/values-in/photoeditor_strings.xml b/res/values-in/photoeditor_strings.xml index f29c0ab41..ef33857ff 100644 --- a/res/values-in/photoeditor_strings.xml +++ b/res/values-in/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Photo Studio" - "Foto tidak dapat dimuat" - "Foto tidak dapat disimpan" - "Foto disimpan ke album %s" - "Hasil edit" + + + + + + "Simpan foto yang diedit?" "Ya" "Tidak" @@ -55,7 +57,8 @@ "Seret penanda untuk memangkas foto" "Menggambar pada foto untuk membuat orat-oret" "Seret foto untuk membaliknya" - "Ketuk untuk menghapus mata merah" + + "Seret foto untuk memutarnya" "Seret foto untuk meluruskannya" diff --git a/res/values-it/photoeditor_strings.xml b/res/values-it/photoeditor_strings.xml index 49044efec..f48f3bd63 100644 --- a/res/values-it/photoeditor_strings.xml +++ b/res/values-it/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Photo Studio" - "Impossibile caricare la foto" - "Impossibile salvare la foto" - "Foto salvate nell\'album %s" - "Modificata" + + + + + + "Salvare la foto modificata?" "Sì" "No" @@ -55,7 +57,8 @@ "Trascina gli indicatori per ritagliare la foto" "Disegna sulla foto per scarabocchiarla" "Trascina la foto per girarla" - "Tocca per rimuovere gli occhi rossi" + + "Trascina la foto per ruotarla" "Trascina la foto per raddrizzarla" diff --git a/res/values-iw/photoeditor_strings.xml b/res/values-iw/photoeditor_strings.xml index 1cc55b3be..37e01120b 100644 --- a/res/values-iw/photoeditor_strings.xml +++ b/res/values-iw/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Photo Studio" - "לא ניתן לטעון את התמונה" - "לא ניתן לשמור את התמונה" - "התמונה נשמרה באלבום %s" - "תמונות ערוכות" + + + + + + "לשמור את התמונה הערוכה?" "כן" "לא" @@ -55,7 +57,8 @@ "גרור סמנים כדי לחתוך תמונה" "גרור על גבי התמונה כדי לצייר עליה" "גרור את התמונה כדי להפוך אותה" - "הקש כדי להסיר עיניים אדומות" + + "גרור את התמונה כדי לסובב אותה" "גרור את התמונה כדי ליישר אותה" diff --git a/res/values-ja/photoeditor_strings.xml b/res/values-ja/photoeditor_strings.xml index 7686611e9..3d080d956 100644 --- a/res/values-ja/photoeditor_strings.xml +++ b/res/values-ja/photoeditor_strings.xml @@ -17,10 +17,12 @@ "フォトスタジオ" - "画像を読み込めません" - "画像を保存できません" - "写真をアルバム「%s」に保存しました" - "編集済み" + + + + + + "編集した写真を保存しますか?" "はい" "いいえ" @@ -55,7 +57,8 @@ "写真をトリミングするにはマーカーをドラッグ" "画像の上に書き込みます" "画像をめくるにはドラッグします" - "赤目を補正するにはタップします" + + "画像を回転させるにはドラッグします" "画像をまっすぐにするにはドラッグします" diff --git a/res/values-ko/photoeditor_strings.xml b/res/values-ko/photoeditor_strings.xml index cede76b73..a255f2d2a 100644 --- a/res/values-ko/photoeditor_strings.xml +++ b/res/values-ko/photoeditor_strings.xml @@ -17,10 +17,12 @@ "사진 스튜디오" - "사진을 로드할 수 없습니다." - "사진을 저장할 수 없습니다." - "%s 앨범에 사진을 저장했습니다." - "수정된 사진" + + + + + + "수정한 사진을 저장하시겠습니까?" "예" "아니요" @@ -55,7 +57,8 @@ "아이콘을 드래그하여 사진 자르기" "사진에 그림을 그려 낙서하기" "사진을 드래그하여 방향 바꾸기" - "터치하여 적목 현상 제거" + + "드래그하여 사진 회전" "사진을 드래그하여 반듯하게 하기" diff --git a/res/values-lt/photoeditor_strings.xml b/res/values-lt/photoeditor_strings.xml index a2b5fedf2..cc9d511be 100644 --- a/res/values-lt/photoeditor_strings.xml +++ b/res/values-lt/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Photo Studio" - "Negalima įkelti nuotraukos" - "Negalima išsaugoti nuotraukos" - "Nuotrauka išsaugota albume „%s“" - "Redaguota" + + + + + + "Išsaugoti redaguotą nuotrauką?" "Taip" "Ne" @@ -55,7 +57,8 @@ "Jei norite apkarpyti nuotr., vilkite žymeklius" "Pieškite ant nuotraukos, jei norite taikyti logotipų puošybą" "Vilkite nuotrauką, kad ją apverstumėte" - "Palieskite, kad pašalintumėte raudonas akis" + + "Vilkite nuotrauką, kad ją apsuktumėte" "Vilkite nuotrauką, kad ją ištiesintumėte" diff --git a/res/values-lv/photoeditor_strings.xml b/res/values-lv/photoeditor_strings.xml index f1af66e92..322a4178d 100644 --- a/res/values-lv/photoeditor_strings.xml +++ b/res/values-lv/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Fotostudija" - "Fotoattēlu nevar ielādēt." - "Fotoattēlu nevar saglabāt." - "Fotoattēls ir saglabāts albumā %s." - "Rediģēti" + + + + + + "Vai saglabāt rediģēto fotoattēlu?" "Jā" "Nē" @@ -55,7 +57,8 @@ "Velciet marķierus, lai apgrieztu fotoattēlu." "Velciet uz fotoattēla, lai kricelētu." "Velciet fotoattēlu, lai to apgrieztu." - "Pieskarieties, lai noņemtu sarkano acu efektu." + + "Velciet fotoattēlu, lai to pagrieztu." "Velciet fotoattēlu, lai to iztaisnotu." diff --git a/res/values-ms/photoeditor_strings.xml b/res/values-ms/photoeditor_strings.xml index ac4a130c8..a4e37283d 100644 --- a/res/values-ms/photoeditor_strings.xml +++ b/res/values-ms/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Studio Foto" - "Foto tidak boleh dimuatkan" - "Foto tidak boleh disimpan" - "Foto disimpan ke album %s" - "Diedit" + + + + + + "Simpan foto yang diedit?" "Ya" "Tidak" @@ -55,7 +57,8 @@ "Seret penanda untuk memangkas foto" "Lukis pada foto untuk mencoret" "Seret foto untuk menterbalikkannya" - "Ketik untuk mengalih keluar mata merah" + + "Seret foto untuk memutarnya" "Seret foto untuk meluruskannya" diff --git a/res/values-nb/photoeditor_strings.xml b/res/values-nb/photoeditor_strings.xml index 03f7c1216..589ae43d7 100644 --- a/res/values-nb/photoeditor_strings.xml +++ b/res/values-nb/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Photo Studio" - "Bildet kan ikke lastes inn" - "Bildet kan ikke lagres" - "Foto lagret i albumet %s" - "Redigert" + + + + + + "Vil du lagre det redigerte bildet?" "Ja" "Nei" @@ -55,7 +57,8 @@ "Dra markører for å beskjære bildet" "Tegn på bildet for å drodle" "Dra bildet for å snu det" - "Trykk for å fjerne røde øyne" + + "Dra bildet for å rotere det" "Dra bildet for å rette på det" diff --git a/res/values-nl/photoeditor_strings.xml b/res/values-nl/photoeditor_strings.xml index 7a0f37496..96b4242f0 100644 --- a/res/values-nl/photoeditor_strings.xml +++ b/res/values-nl/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Photo Studio" - "Foto kan niet worden geladen" - "Foto kan niet worden opgeslagen" - "Foto opgeslagen in album %s" - "Bewerkt" + + + + + + "Bewerkte foto opslaan?" "Ja" "Nee" @@ -55,7 +57,8 @@ "Sleep de markeringen om de foto bij te snijden" "Teken op de foto om hierop te krabbelen" "Sleep de foto om deze te spiegelen" - "Tik om rode ogen te verwijderen" + + "Sleep de foto om deze te draaien" "Sleep de foto om deze recht te zetten" diff --git a/res/values-pl/photoeditor_strings.xml b/res/values-pl/photoeditor_strings.xml index e48c333a5..a3ade7658 100644 --- a/res/values-pl/photoeditor_strings.xml +++ b/res/values-pl/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Studio fotograficzne" - "Nie można wczytać zdjęcia" - "Nie można zapisać zdjęcia" - "Zdjęcie zapisano w albumie %s" - "Edytowane" + + + + + + "Czy zapisać edytowane zdjęcie?" "Tak" "Nie" @@ -55,7 +57,8 @@ "Przeciągnij znaczniki, aby przyciąć zdjęcie" "Rysuj po zdjęciu, aby dodać bazgroły." "Przeciągnij zdjęcie, aby je odwrócić." - "Dotknij, aby usunąć efekt czerwonych oczu." + + "Przeciągnij zdjęcie, aby je obrócić." "Przeciągnij zdjęcie, aby je wyprostować." diff --git a/res/values-pt-rPT/photoeditor_strings.xml b/res/values-pt-rPT/photoeditor_strings.xml index f0f6e004c..bc240d64d 100644 --- a/res/values-pt-rPT/photoeditor_strings.xml +++ b/res/values-pt-rPT/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Photo Studio" - "Não é possível carregar a fotografia" - "Não é possível guardar a fotografia" - "Fotografia guardada no álbum %s" - "Editado" + + + + + + "Guardar a fotografia editada?" "Sim" "Não" @@ -55,7 +57,8 @@ "Arraste os marcadores para recortar a fotografia" "Desenhe na fotografia para rabiscar" "Arraste a fotografia para virá-la" - "Toque para remover o efeito de olhos vermelhos" + + "Arraste a fotografia para rodá-la" "Arraste a fotografia para endireitá-la" diff --git a/res/values-pt/photoeditor_strings.xml b/res/values-pt/photoeditor_strings.xml index 664c9a5d5..6fe6d5758 100644 --- a/res/values-pt/photoeditor_strings.xml +++ b/res/values-pt/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Photo Studio" - "Não foi possível carregar a foto" - "Não é possível salvar a foto" - "Foto salva no álbum %s" - "Editado" + + + + + + "Salvar foto editada?" "Sim" "Não" @@ -55,7 +57,8 @@ "Arraste os marcadores para cortar a foto" "Desenhe na foto para rabiscar" "Arraste a foto para invertê-la" - "Toque para remover olhos vermelhos" + + "Arraste a foto para girá-la" "Arraste a foto para endireitá-la" diff --git a/res/values-ro/photoeditor_strings.xml b/res/values-ro/photoeditor_strings.xml index f4c23ec45..16037f826 100644 --- a/res/values-ro/photoeditor_strings.xml +++ b/res/values-ro/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Studio foto" - "Fotografia nu poate fi încărcată" - "Fotografia nu poate fi salvată" - "Fotografie salvată în albumul %s" - "Editate" + + + + + + "Salvaţi fotografia editată?" "Da" "Nu" @@ -55,7 +57,8 @@ "Trageţi marcatorii pentru a decupa fotografia" "Desenaţi pe fotografie pentru a crea doodle" "Trageţi o fotografie pentru a o răsturna" - "Apăsaţi pentru a elimina ochii roşii" + + "Trageţi fotografia pentru a o roti" "Trageţi de fotografie pentru a o îndrepta" diff --git a/res/values-ru/photoeditor_strings.xml b/res/values-ru/photoeditor_strings.xml index 312ae4308..f6cb79b65 100644 --- a/res/values-ru/photoeditor_strings.xml +++ b/res/values-ru/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Фотостудия" - "Не удалось загрузить фото" - "Не удалось сохранить фото" - "Фотография сохранена в альбоме \"%s\"" - "Измененные" + + + + + + "Сохранить изменения?" "Да" "Нет" @@ -55,7 +57,8 @@ "Чтобы кадрировать фото, перетащите маркеры" "Рисуйте на фото пальцем" "Чтобы отразить фото, перетащите его край" - "Нажмите для устранения эффекта красных глаз" + + "Чтобы повернуть фото, перетащите его край" "Чтобы выровнять фото, перетащите его" diff --git a/res/values-sk/photoeditor_strings.xml b/res/values-sk/photoeditor_strings.xml index c5c268466..239cb4c9b 100644 --- a/res/values-sk/photoeditor_strings.xml +++ b/res/values-sk/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Photo Studio" - "Fotografiu sa nepodarilo načítať" - "Fotografiu sa nepodarilo uložiť" - "Fotografia bola uložená do albumu %s" - "Upravené" + + + + + + "Chcete upravenú fotografiu uložiť?" "Áno" "Nie" @@ -55,7 +57,8 @@ "Potiahnutím značiek orežete fotografiu" "Na fotografii môžete kresliť prstom" "Potiahnutím prstom fotografiu prevrátite" - "Klepnutím odstráňte efekt červených očí" + + "Potiahnutím prstom fotografiu otočíte" "Potiahnutím prstom fotografiu vyrovnáte" diff --git a/res/values-sl/photoeditor_strings.xml b/res/values-sl/photoeditor_strings.xml index 802cb0792..92309a024 100644 --- a/res/values-sl/photoeditor_strings.xml +++ b/res/values-sl/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Photo Studio" - "Slike ni mogoče prenesti" - "Fotografije ni mogoče shraniti" - "Fotografija je bila shranjena v album %s" - "Urejeno" + + + + + + "Želite shraniti urejene fotografije?" "Da" "Ne" @@ -55,7 +57,8 @@ "Povlecite oznake, da obrežete fotografijo" "Povlecite po fotografiji za prostoročno risanje" "Povlecite fotografijo, da jo obrnete" - "Tapnite, da odstranite rdeče oči" + + "Povlecite fotografijo, da jo zavrtite" "Povlecite fotografijo, da jo poravnate" diff --git a/res/values-sr/photoeditor_strings.xml b/res/values-sr/photoeditor_strings.xml index a4a9ab5aa..d39a1c720 100644 --- a/res/values-sr/photoeditor_strings.xml +++ b/res/values-sr/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Фото-студио" - "Фотографија не може да се учита" - "Фотографија не може да се сачува" - "Фотографија је сачувана у албум %s" - "Измењено" + + + + + + "Желите ли да сачувате измењену фотографију?" "Да" "Не" @@ -55,7 +57,8 @@ "Превуците означиваче да бисте опсекли фотографију" "Превуците слику на дудл логотип" "Превуците фотографију да бисте је окренули" - "Додирните да бисте уклонили ефекат црвених очију" + + "Превуците фотографију да бисте је ротирали" "Превуците фотографију да бисте је исправили" diff --git a/res/values-sv/photoeditor_strings.xml b/res/values-sv/photoeditor_strings.xml index bf82cf549..e7a7e500c 100644 --- a/res/values-sv/photoeditor_strings.xml +++ b/res/values-sv/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Fotostudio" - "Fotot kan inte läsas in" - "Fotot kan inte sparas" - "Fotot sparades i albumet %s" - "Redigerade" + + + + + + "Spara redigerat foto?" "Ja" "Nej" @@ -55,7 +57,8 @@ "Dra markörerna om du vill beskära bilden" "Rita på bilden om du vill" "Tryck och dra bilden om du vill vända den" - "Knacka lätt om du vill ta bort röda ögon" + + "Tryck och dra bilden om du vill rotera den" "Tryck och dra bilden om du vill räta upp den" diff --git a/res/values-sw/photoeditor_strings.xml b/res/values-sw/photoeditor_strings.xml index c48e0d6d9..34fc8acb6 100644 --- a/res/values-sw/photoeditor_strings.xml +++ b/res/values-sw/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Studio ya Picha" - "Picha haiwezi kkupakizwa" - "Picha haiwezi kuhifadhiwa" - "Picha imehifadhiwa kwenye albamu %s" - "Imehaririwa" + + + + + + "Hifadhi picha zilizohaririwa" "Ndio" "Hakuna" @@ -55,7 +57,8 @@ "Kokota viweka alama ili kupuna picha" "Chora kwenye picha ku doodle" "Kokota picha ili kuiflipu" - "Gonja ili kuondoa macho mekundu" + + "kokota picha ili kuizungusha" "Kokota picha ili kuizungusha" diff --git a/res/values-th/photoeditor_strings.xml b/res/values-th/photoeditor_strings.xml index d39658a9f..fba2a656f 100644 --- a/res/values-th/photoeditor_strings.xml +++ b/res/values-th/photoeditor_strings.xml @@ -17,10 +17,12 @@ "สตูดิโอถ่ายภาพ" - "ไม่สามารถโหลดภาพถ่าย" - "ไม่สามารถบันทึกภาพถ่าย" - "ภาพได้ัรับการบันทึกในอัลบั้ม %s แล้ว" - "แก้ไขแล้ว" + + + + + + "บันทึกภาพที่แก้ไขหรือไม่" "ใช่" "ไม่" @@ -55,7 +57,8 @@ "ลากเครื่องหมายเพื่อครอบตัดภาพ" "วาดบนภาพเพื่อ doodle" "ลากภาพเพื่อพลิก" - "แตะเพื่อลบตาแดง" + + "ลากภาพเพื่อหมุน" "ลากภาพเพื่อยืดให้ตรง" diff --git a/res/values-tl/photoeditor_strings.xml b/res/values-tl/photoeditor_strings.xml index fa547b51a..fb0957a1e 100644 --- a/res/values-tl/photoeditor_strings.xml +++ b/res/values-tl/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Photo Studio" - "Hindi ma-load ang larawan" - "Hindi ma-save ang larawan" - "Na-save ang larawan sa album na %s" - "Na-edit" + + + + + + "I-save ang na-edit na larawan?" "Oo" "Hindi" @@ -55,7 +57,8 @@ "I-drag ang mga marker upang i-crop ang larawan" "Gumuhit sa larawan upang mag-doodle" "I-drag ang larawan upang i-flip ito" - "Tapikin upang alisin ang mga pulang mata" + + "I-drag ang larawan upang i-rotate ito" "I-drag ang larawan upang iunat ito" diff --git a/res/values-tr/photoeditor_strings.xml b/res/values-tr/photoeditor_strings.xml index 5321e4d6b..bc473c2a8 100644 --- a/res/values-tr/photoeditor_strings.xml +++ b/res/values-tr/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Fotoğraf Stüdyosu" - "Fotoğraf yüklenemiyor" - "Fotoğraf kaydedilemiyor" - "Fotoğraf %s albümüne kaydedildi" - "Düzenlendi" + + + + + + "Düzenlenmiş fotoğraf kaydedilsin mi?" "Evet" "Hayır" @@ -55,7 +57,8 @@ "Fotoğrafı kırpmak içni işaretçileri sürükleyin" "Doodle için fotoğrafın üzerinde çizin" "Çevirmek için fotoğrafı sürükleyin" - "Kırmızı gözleri kaldırmak için hafifçe vurun" + + "Döndürmek için fotoğrafı sürükleyin" "Düzleştirmek için fotoğrafı sürükleyin" diff --git a/res/values-uk/photoeditor_strings.xml b/res/values-uk/photoeditor_strings.xml index 76bb7ce19..0527780b8 100644 --- a/res/values-uk/photoeditor_strings.xml +++ b/res/values-uk/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Photo Studio" - "Фото неможливо завантажити" - "Фото неможливо зберегти" - "Фото збережено в альбом \"%s\"" - "Редаговано" + + + + + + "Зберегти відредаговану фотографію?" "Так" "Ні" @@ -55,7 +57,8 @@ "Перетягніть маркери, щоб обрізати фото" "Малюйте на фото, щоб створити doodle" "Потягніть за фото, щоб перевернути його" - "Натисніть, щоб усунути ефект червоних очей" + + "Потягніть за фото, щоб обертати його" "Перетягніть фото, щоб вирівняти його" diff --git a/res/values-vi/photoeditor_strings.xml b/res/values-vi/photoeditor_strings.xml index c3f8281f2..349c25a03 100644 --- a/res/values-vi/photoeditor_strings.xml +++ b/res/values-vi/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Studio ảnh" - "Không thể tải ảnh" - "Không thể lưu ảnh" - "Ảnh đã được lưu vào album %s" - "Đã chỉnh sửa" + + + + + + "Lưu ảnh đã chỉnh sửa?" "Có" "Không" @@ -55,7 +57,8 @@ "Kéo các điểm đánh dấu để cắt ảnh" "Kéo trên ảnh để vẽ ngoạch ngoạc" "Kéo ảnh để lật" - "Chạm để loại bỏ mắt đỏ" + + "Kéo ảnh để xoay" "Kéo ảnh để sắp thẳng" diff --git a/res/values-zh-rCN/photoeditor_strings.xml b/res/values-zh-rCN/photoeditor_strings.xml index 09ab11a17..9cd3073f1 100644 --- a/res/values-zh-rCN/photoeditor_strings.xml +++ b/res/values-zh-rCN/photoeditor_strings.xml @@ -17,10 +17,12 @@ "照相馆" - "无法加载照片" - "无法保存照片" - "照片已保存到“%s”相册" - "已修改" + + + + + + "要保存已修改的照片吗?" "是" "否" @@ -55,7 +57,8 @@ "拖动标记以裁剪照片" "在照片上绘制即可涂鸦" "拖动照片可将其翻转" - "点按可消除红眼" + + "拖动照片可将其旋转" "拖动照片可将其拉直" diff --git a/res/values-zh-rTW/photoeditor_strings.xml b/res/values-zh-rTW/photoeditor_strings.xml index b2e8fc6b9..9feeda49a 100644 --- a/res/values-zh-rTW/photoeditor_strings.xml +++ b/res/values-zh-rTW/photoeditor_strings.xml @@ -17,10 +17,12 @@ "相片工作室" - "無法載入相片" - "無法儲存相片" - "相片已儲存至 %s 相簿中" - "已編輯" + + + + + + "要儲存已編輯的相片嗎?" "是" "否" @@ -55,7 +57,8 @@ "拖曳標記即可裁剪相片" "在相片上畫圖即可塗鴉" "拖曳照片即可翻轉" - "輕按即可消除紅眼" + + "拖曳照片即可旋轉" "拖曳照片即可拉正" diff --git a/res/values-zu/photoeditor_strings.xml b/res/values-zu/photoeditor_strings.xml index 98f599f3d..285a31d7d 100644 --- a/res/values-zu/photoeditor_strings.xml +++ b/res/values-zu/photoeditor_strings.xml @@ -17,10 +17,12 @@ "Endawo Yezithombe" - "Isithombe asikwazi ukulayishwa" - "Isithombe asikwazi ukulondolozwa" - "Isithombe silondolozwe kwi %s albhamu" - "Kuhleliwe" + + + + + + "Londoloza isithombe esihleliwe" "Yebo" "Cha" @@ -55,7 +57,8 @@ "Hudula insiza yokubeka uphawu ukuze usike ongakudingi esithombeni" "Dweba esithombeni ukuze kube nemidwebo eshintshayo" "Hudula isithombe ukuze usiphendule" - "Thepha ukuze ususu iso elibomvu" + + "Hudula isithombe ukuze usijikeleze" "Hudula isithombe ukuze usiqondise" -- GitLab From 3e54da49e97a681ecf9f27893659da58c2c538c0 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Fri, 27 Apr 2012 10:38:50 -0700 Subject: [PATCH 006/763] Import translations. DO NOT MERGE Change-Id: I6ce4eb808519167358f7ff63a7893f3faa482b62 --- res/values-bg/strings.xml | 6 ++---- res/values-cs/strings.xml | 6 ++---- res/values-es-rUS/strings.xml | 6 ++---- res/values-fa/strings.xml | 6 ++---- res/values-hi/strings.xml | 6 ++---- res/values-hr/strings.xml | 6 ++---- res/values-hu/strings.xml | 6 ++---- res/values-in/strings.xml | 6 ++---- res/values-ja/strings.xml | 6 ++---- res/values-ko/strings.xml | 6 ++---- res/values-lt/strings.xml | 6 ++---- res/values-ms/strings.xml | 6 ++---- res/values-pt-rPT/strings.xml | 6 ++---- res/values-ro/strings.xml | 6 ++---- res/values-ru/strings.xml | 6 ++---- res/values-sk/strings.xml | 6 ++---- res/values-sr/strings.xml | 6 ++---- res/values-th/strings.xml | 6 ++---- res/values-tr/strings.xml | 6 ++---- res/values-uk/strings.xml | 6 ++---- res/values-vi/strings.xml | 6 ++---- res/values-zh-rCN/strings.xml | 6 ++---- res/values-zh-rTW/strings.xml | 6 ++---- 23 files changed, 46 insertions(+), 92 deletions(-) diff --git a/res/values-bg/strings.xml b/res/values-bg/strings.xml index 44ba42e46..5f7b7b005 100644 --- a/res/values-bg/strings.xml +++ b/res/values-bg/strings.xml @@ -46,10 +46,8 @@ "Тапетът се задава..." "Тапет" "Изтриване" - - - - + "Да се потвърди ли изтриването?" + "Потвърждаване" "Отказ" "Споделяне" "Избиране на всички" diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml index 600b4efbd..732f2e2e6 100644 --- a/res/values-cs/strings.xml +++ b/res/values-cs/strings.xml @@ -46,10 +46,8 @@ "Nastavování tapety..." "Tapeta" "Smazat" - - - - + "Potvrdit smazání?" + "Potvrdit" "Zrušit" "Sdílet" "Vybrat vše" diff --git a/res/values-es-rUS/strings.xml b/res/values-es-rUS/strings.xml index 78032d336..60da854c5 100644 --- a/res/values-es-rUS/strings.xml +++ b/res/values-es-rUS/strings.xml @@ -46,10 +46,8 @@ "Estableciendo fondo de pantalla..." "Papel tapiz" "Eliminar" - - - - + "¿Quieres confirmar la eliminación?" + "Confirmar" "Cancelar" "Compartir" "Seleccionar todo" diff --git a/res/values-fa/strings.xml b/res/values-fa/strings.xml index 753d64b90..be3056a3b 100644 --- a/res/values-fa/strings.xml +++ b/res/values-fa/strings.xml @@ -46,10 +46,8 @@ "تنظیم تصویر زمینه..." "تصویر زمینه" "حذف" - - - - + "حذف را تایید می‌کنید؟" + "تأیید" "لغو" "اشتراک گذاری" "انتخاب همه" diff --git a/res/values-hi/strings.xml b/res/values-hi/strings.xml index df31be80b..675aebd86 100644 --- a/res/values-hi/strings.xml +++ b/res/values-hi/strings.xml @@ -46,10 +46,8 @@ "वॉलपेपर सेट कर रहा है..." "वॉलपेपर" "हटाएं" - - - - + "हटाने की पुष्‍टि करें?" + "पुष्टि करें" "रद्द करें" "शेयर करें" "सभी का चयन करें" diff --git a/res/values-hr/strings.xml b/res/values-hr/strings.xml index fb3d2ed85..df1061dd7 100644 --- a/res/values-hr/strings.xml +++ b/res/values-hr/strings.xml @@ -46,10 +46,8 @@ "Postavljanje pozadinske slike…" "Pozadinska slika" "Izbriši" - - - - + "Potvrdi brisanje?" + "Potvrdi" "Odustani" "Podijeli" "Odaberi sve" diff --git a/res/values-hu/strings.xml b/res/values-hu/strings.xml index 583782480..c2649c4b1 100644 --- a/res/values-hu/strings.xml +++ b/res/values-hu/strings.xml @@ -46,10 +46,8 @@ "Háttérkép beállítása..." "Háttérkép" "Törlés" - - - - + "Megerősíti a törlést?" + "Megerősítés" "Mégse" "Megosztás" "Az összes kijelölése" diff --git a/res/values-in/strings.xml b/res/values-in/strings.xml index 532a98ae9..161f3e6dd 100644 --- a/res/values-in/strings.xml +++ b/res/values-in/strings.xml @@ -46,10 +46,8 @@ "Menyetel wallpaper..." "Wallpaper" "Hapus" - - - - + "Konfirmasi penghapusan?" + "Konfirmasi" "Batal" "Bagikan" "Pilih semua" diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml index ed587cf7b..33058e041 100644 --- a/res/values-ja/strings.xml +++ b/res/values-ja/strings.xml @@ -46,10 +46,8 @@ "壁紙を設定しています..." "壁紙" "削除" - - - - + "削除してもよろしいですか?" + "確認" "キャンセル" "共有" "すべて選択" diff --git a/res/values-ko/strings.xml b/res/values-ko/strings.xml index f59af3c1a..e03d12e84 100644 --- a/res/values-ko/strings.xml +++ b/res/values-ko/strings.xml @@ -46,10 +46,8 @@ "배경화면을 설정하는 중..." "배경화면" "삭제" - - - - + "삭제하시겠습니까?" + "확인" "취소" "공유" "모두 선택" diff --git a/res/values-lt/strings.xml b/res/values-lt/strings.xml index 0605ef832..da8f10bce 100644 --- a/res/values-lt/strings.xml +++ b/res/values-lt/strings.xml @@ -46,10 +46,8 @@ "Nustatomas darbalaukio fonas…" "Darbalaukio fonas" "Ištrinti" - - - - + "Patvirtinti ištrynimą?" + "Patvirtinti" "Atšaukti" "Bendrinti" "Pasirinkti viską" diff --git a/res/values-ms/strings.xml b/res/values-ms/strings.xml index 127667e6a..ca0efe043 100644 --- a/res/values-ms/strings.xml +++ b/res/values-ms/strings.xml @@ -46,10 +46,8 @@ "Menetapkan kertas dinding…" "Kertas dinding" "Padam" - - - - + "Sahkan pemadaman?" + "Sahkan" "Batal" "Kongsi" "Pilih semua" diff --git a/res/values-pt-rPT/strings.xml b/res/values-pt-rPT/strings.xml index d49a067ab..93d21238a 100644 --- a/res/values-pt-rPT/strings.xml +++ b/res/values-pt-rPT/strings.xml @@ -46,10 +46,8 @@ "A definir imagem de fundo…" "Imagem de fundo" "Eliminar" - - - - + "Confirmar eliminação?" + "Confirmar" "Cancelar" "Partilhar" "Selecionar tudo" diff --git a/res/values-ro/strings.xml b/res/values-ro/strings.xml index d9f84c6a4..d1e766e5a 100644 --- a/res/values-ro/strings.xml +++ b/res/values-ro/strings.xml @@ -46,10 +46,8 @@ "Se setează imaginea de fundal..." "Imagine de fundal" "Ştergeţi" - - - - + "Confirmaţi ştergerea?" + "Confirmaţi" "Anulaţi" "Distribuiţi" "Selectaţi-le pe toate" diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index e8f6892e7..ce167185b 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -46,10 +46,8 @@ "Установка обоев..." "Обои" "Удалить" - - - - + "Удалить?" + "Подтвердить" "Отмена" "Отправить" "Выбрать все" diff --git a/res/values-sk/strings.xml b/res/values-sk/strings.xml index 25b29b198..2a0b000ba 100644 --- a/res/values-sk/strings.xml +++ b/res/values-sk/strings.xml @@ -46,10 +46,8 @@ "Prebieha nastavenie tapety..." "Tapeta" "Odstrániť" - - - - + "Potvrdiť odstránenie?" + "Potvrdiť" "Zrušiť" "Zdieľať" "Vybrať všetko" diff --git a/res/values-sr/strings.xml b/res/values-sr/strings.xml index b684ee942..9fced330e 100644 --- a/res/values-sr/strings.xml +++ b/res/values-sr/strings.xml @@ -46,10 +46,8 @@ "Подешавање позадине..." "Позадина" "Избриши" - - - - + "Желите ли да потврдите брисање?" + "Потврди" "Откажи" "Дели" "Изабери све" diff --git a/res/values-th/strings.xml b/res/values-th/strings.xml index e94387b4f..6dfa5b3d5 100644 --- a/res/values-th/strings.xml +++ b/res/values-th/strings.xml @@ -46,10 +46,8 @@ "กำลังตั้งค่าวอลเปเปอร์..." "วอลเปเปอร์" "ลบ" - - - - + "ยืนยันการลบหรือไม่" + "ยืนยัน" "ยกเลิก" "แบ่งปัน" "เลือกทั้งหมด" diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml index c3dd3a661..0f10199cc 100644 --- a/res/values-tr/strings.xml +++ b/res/values-tr/strings.xml @@ -46,10 +46,8 @@ "Duvar kağıdı ayarlanıyor..." "Duvar Kağıdı" "Sil" - - - - + "Silme işlemini onaylıyor musunuz?" + "Onayla" "İptal" "Paylaş" "Tümünü seç" diff --git a/res/values-uk/strings.xml b/res/values-uk/strings.xml index 9d4f14d84..15ca26c3a 100644 --- a/res/values-uk/strings.xml +++ b/res/values-uk/strings.xml @@ -46,10 +46,8 @@ "Встановлення фонового малюнка..." "Фоновий мал." "Видалити" - - - - + "Підтвердити видалення?" + "Підтвердити" "Скасувати" "Надісл." "Вибрати всі" diff --git a/res/values-vi/strings.xml b/res/values-vi/strings.xml index 4023a5a08..07d88c9da 100644 --- a/res/values-vi/strings.xml +++ b/res/values-vi/strings.xml @@ -46,10 +46,8 @@ "Đang đặt hình nền..." "Hình nền" "Xóa" - - - - + "Xác nhận xóa?" + "Xác nhận" "Hủy" "Chia sẻ" "Chọn tất cả" diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index 76f17f27a..4aa92ced2 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -46,10 +46,8 @@ "正在设置壁纸..." "壁纸" "删除" - - - - + "确认删除?" + "确认" "取消" "分享" "全选" diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml index 2affe7e07..59751a525 100644 --- a/res/values-zh-rTW/strings.xml +++ b/res/values-zh-rTW/strings.xml @@ -46,10 +46,8 @@ "正在設定桌布..." "桌布" "刪除" - - - - + "確認刪除?" + "確認" "取消" "分享" "全選" -- GitLab From 19fb58b4bc086028a184a5f8f873f43e0cc178f9 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Mon, 30 Apr 2012 10:45:24 -0700 Subject: [PATCH 007/763] Import translations. DO NOT MERGE Change-Id: Ie9afe62f6e6189c1053bf72da89eaab4e902bb64 --- res/values-af/strings.xml | 3 +-- res/values-am/strings.xml | 3 +-- res/values-ar/strings.xml | 3 +-- res/values-be/strings.xml | 3 +-- res/values-bg/strings.xml | 3 +-- res/values-ca/strings.xml | 3 +-- res/values-cs/strings.xml | 3 +-- res/values-da/strings.xml | 3 +-- res/values-de/strings.xml | 3 +-- res/values-el/strings.xml | 3 +-- res/values-en-rGB/strings.xml | 3 +-- res/values-es/strings.xml | 3 +-- res/values-et/strings.xml | 3 +-- res/values-fa/strings.xml | 3 +-- res/values-fi/strings.xml | 3 +-- res/values-fr/strings.xml | 3 +-- res/values-hi/strings.xml | 3 +-- res/values-hr/strings.xml | 5 ++--- res/values-hu/strings.xml | 3 +-- res/values-in/strings.xml | 5 ++--- res/values-it/strings.xml | 3 +-- res/values-iw/strings.xml | 3 +-- res/values-ja/strings.xml | 3 +-- res/values-ko/strings.xml | 3 +-- res/values-lt/strings.xml | 3 +-- res/values-lv/strings.xml | 3 +-- res/values-nb/strings.xml | 3 +-- res/values-nl/strings.xml | 3 +-- res/values-pl/strings.xml | 9 +++------ res/values-pt-rPT/strings.xml | 3 +-- res/values-pt/strings.xml | 3 +-- res/values-ro/strings.xml | 3 +-- res/values-ru/strings.xml | 3 +-- res/values-sk/strings.xml | 3 +-- res/values-sl/strings.xml | 3 +-- res/values-sr/strings.xml | 3 +-- res/values-sv/strings.xml | 3 +-- res/values-th/strings.xml | 3 +-- res/values-tl/strings.xml | 9 +++------ res/values-tr/strings.xml | 3 +-- res/values-uk/strings.xml | 3 +-- res/values-vi/strings.xml | 3 +-- res/values-zh-rCN/strings.xml | 3 +-- res/values-zh-rTW/strings.xml | 3 +-- res/values-zu/strings.xml | 3 +-- 45 files changed, 51 insertions(+), 100 deletions(-) diff --git a/res/values-af/strings.xml b/res/values-af/strings.xml index 6c4c376a6..88ddb9f44 100644 --- a/res/values-af/strings.xml +++ b/res/values-af/strings.xml @@ -99,8 +99,7 @@ "Prente en video\'s" "Fotogalery" "Geen foto\'s nie." - - + "Gesnoeide prent gestoor in %s." "Gesnoeide prent is nie gestoor nie." "Geen albums beskikbaar nie." "O prente/video\'s beskikbaar." diff --git a/res/values-am/strings.xml b/res/values-am/strings.xml index ea664ea68..6f8a39e41 100644 --- a/res/values-am/strings.xml +++ b/res/values-am/strings.xml @@ -99,8 +99,7 @@ "ምስሎች & ቪዲዮዎች" "የፎቶ ሥነ ጥበብ ማዕከል" "ምንም ፎቶዎች የሉም፡፡" - - + "የተከረከመ ምስል %s ላይ ተቀምጧል።" "የተከረከመው ምስል አልተቀመጠም::" "ምንም አልበሞች አልተገኙም::" "O ምስሎች/ ቪዲዮዎች ማግኘት ይቻላል::" diff --git a/res/values-ar/strings.xml b/res/values-ar/strings.xml index bed39aa83..bb9fed140 100644 --- a/res/values-ar/strings.xml +++ b/res/values-ar/strings.xml @@ -99,8 +99,7 @@ "الصور ومقاطع الفيديو" "معرض الصور" "ليست هناك أية صور." - - + "تم حفظ الصورة التي تم اقتصاصها في %s." "لم يتم حفظ الصورة التي تم اقتصاصها." "ليست هناك أية ألبومات متاحة." "لا تتوفر أية صور/مقاطع فيديو." diff --git a/res/values-be/strings.xml b/res/values-be/strings.xml index b6924b173..d2b64d3dc 100644 --- a/res/values-be/strings.xml +++ b/res/values-be/strings.xml @@ -99,8 +99,7 @@ "Выявы і відэа" "Фотагалерэя" "Фатаграфій няма" - - + "Абрэзаная выява захавана ў тэчцы %s." "Абрэзаная выява не захавана." "Няма альбомаў." "Выяў/вiдэа: 0." diff --git a/res/values-bg/strings.xml b/res/values-bg/strings.xml index 5f7b7b005..bc908a3ef 100644 --- a/res/values-bg/strings.xml +++ b/res/values-bg/strings.xml @@ -99,8 +99,7 @@ "Изображения и видеоклипове" "Фотогалерия" "Няма снимки." - - + "Подрязаното изображение е запазено в/ъв „%s“." "Подрязаното изображение не бе запазено." "Няма налични албуми." "0 изображения/видеоклипове са налице." diff --git a/res/values-ca/strings.xml b/res/values-ca/strings.xml index e8fa4e910..9f36f5310 100644 --- a/res/values-ca/strings.xml +++ b/res/values-ca/strings.xml @@ -99,8 +99,7 @@ "Imatges i vídeos" "Galeria de fotos" "Sense fotos." - - + "S\'ha desat la imatge retallada a %s." "La imatge retallada no s\'ha desat." "No hi ha àlbums disponibles." "O imatges/vídeos disponibles." diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml index 732f2e2e6..dc7efa4ee 100644 --- a/res/values-cs/strings.xml +++ b/res/values-cs/strings.xml @@ -99,8 +99,7 @@ "Obrázky a videa" "Galerie fotografií" "Žádné fotky." - - + "Ořezaný snímek byl uložen do složky %s." "Ořezaný snímek není uložen." "Žádné album není k dispozici." "Žádné obrázky ani videa nejsou k dispozici." diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml index abd3284d9..52ab8eb60 100644 --- a/res/values-da/strings.xml +++ b/res/values-da/strings.xml @@ -99,8 +99,7 @@ "Billeder og videoer" "Billedgalleri" "Ingen billeder." - - + "Det beskårne billede er gemt i %s." "Det beskårne billede blev ikke gemt." "Ingen tilgængelige albummer." "O tilgængelige billeder/videoer." diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index f2dc98ec5..ed7231cff 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -99,8 +99,7 @@ "Bilder und Videos" "Fotogalerie" "Keine Fotos vorhanden" - - + "Zugeschnittenes Bild gespeichert in %s" "Zugeschnittenes Bild wurde nicht gespeichert." "Keine Alben verfügbar" "Keine Bilder oder Videos vorhanden" diff --git a/res/values-el/strings.xml b/res/values-el/strings.xml index 4ecd5c3e2..baf9334c4 100644 --- a/res/values-el/strings.xml +++ b/res/values-el/strings.xml @@ -99,8 +99,7 @@ "Εικόνες και βίντεο" "Συλλογή φωτογραφιών" "Δεν υπάρχουν φωτογραφίες." - - + "Η αποκομμένη εικόνα αποθηκεύτηκε στον φάκελο %s." "Δεν αποθηκεύτηκε η αποκομένη εικόνα." "Δεν υπάρχουν διαθέσιμα λευκώματα." "Δεν υπάρχουν διαθέσιμες εικόνες/βίντεο." diff --git a/res/values-en-rGB/strings.xml b/res/values-en-rGB/strings.xml index fe65c3bba..df12bddc3 100644 --- a/res/values-en-rGB/strings.xml +++ b/res/values-en-rGB/strings.xml @@ -99,8 +99,7 @@ "Images & videos" "Photo Gallery" "No photos." - - + "Cropped image saved to %s." "Cropped image wasn\'t saved." "No albums available." "O images/videos available." diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index 0523bf4c0..c02ff8f21 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -99,8 +99,7 @@ "Imágenes y vídeos" "Galería de fotos" "No hay fotos." - - + "La imagen recortada se ha guardado en %s." "No se ha guardado la imagen recortada." "No hay álbumes disponibles." "No hay imágenes ni vídeos disponibles." diff --git a/res/values-et/strings.xml b/res/values-et/strings.xml index 3d431467e..d48fffab6 100644 --- a/res/values-et/strings.xml +++ b/res/values-et/strings.xml @@ -99,8 +99,7 @@ "Kujutised ja videod" "Fotogalerii" "Fotod puuduvad." - - + "Kärbitud kujutis salvestati kausta %s." "Kärbitud kujutist ei salvestatud." "Ühtegi albumit pole saadaval." "O kujutist/videot on saadaval." diff --git a/res/values-fa/strings.xml b/res/values-fa/strings.xml index be3056a3b..25489d232 100644 --- a/res/values-fa/strings.xml +++ b/res/values-fa/strings.xml @@ -99,8 +99,7 @@ "تصاویر و ویدیوها" "گالری عکس" "عکسی موجود نیست." - - + "تصویر بریده شده در %s ذخیره شد." "تصویر برش‌خورده ذخیره نشد." "آلبومی موجود نیست." "O تصویر/ویدیو موجود است." diff --git a/res/values-fi/strings.xml b/res/values-fi/strings.xml index 16075c4e8..34554c4a4 100644 --- a/res/values-fi/strings.xml +++ b/res/values-fi/strings.xml @@ -99,8 +99,7 @@ "Kuvat ja videot" "Kuvagalleria" "Ei valokuvia." - - + "Rajattu kuva tallennettu kansioon %s." "Rajattua kuvaa ei tallennettu." "Ei albumeja käytettävissä." "0 kuvaa/videota saatavilla." diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index 0e054b65c..427038a23 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -99,8 +99,7 @@ "Images et vidéos" "Galerie photos" "Aucune photo" - - + "Image rognée enregistrée dans %s." "L\'image rognée n\'a pas été enregistrée." "Aucun album disponible." "Aucune image/vidéo disponible." diff --git a/res/values-hi/strings.xml b/res/values-hi/strings.xml index 675aebd86..4156ddd2d 100644 --- a/res/values-hi/strings.xml +++ b/res/values-hi/strings.xml @@ -99,8 +99,7 @@ "छवियां और वीडियो" "फ़ोटो गैलरी" "कोई फ़ोटो नहीं." - - + "काट-छांट की गई छवि को %s में सहेजा गया." "काट-छांट की गई छवि को नहीं सहेजा गया." "कोई एल्‍बम उपलब्‍ध नहीं." "O छवियां/वीडियो उपलब्‍ध." diff --git a/res/values-hr/strings.xml b/res/values-hr/strings.xml index df1061dd7..73e4a7591 100644 --- a/res/values-hr/strings.xml +++ b/res/values-hr/strings.xml @@ -46,7 +46,7 @@ "Postavljanje pozadinske slike…" "Pozadinska slika" "Izbriši" - "Potvrdi brisanje?" + "Potvrditi brisanje?" "Potvrdi" "Odustani" "Podijeli" @@ -99,8 +99,7 @@ "Slike i videozapisi" "Galerija fotografija" "Nema fotografija." - - + "Obrezana slika spremljena u mapu %s." "Obrezana slika nije spremljena." "Nema dostupnih albuma." "Dostupno je 0 slika/videozapisa." diff --git a/res/values-hu/strings.xml b/res/values-hu/strings.xml index c2649c4b1..1fdc39c40 100644 --- a/res/values-hu/strings.xml +++ b/res/values-hu/strings.xml @@ -99,8 +99,7 @@ "Képek és videók" "Fotógaléria" "Nincsenek fényképek." - - + "A vágott képet a(z) %s mappába mentettük." "A vágott kép nincs elmentve." "Nincs elérhető album." "Nincs elérhető kép/videó." diff --git a/res/values-in/strings.xml b/res/values-in/strings.xml index 161f3e6dd..b72fb0b33 100644 --- a/res/values-in/strings.xml +++ b/res/values-in/strings.xml @@ -78,7 +78,7 @@ "Tidak dapat menemukan item." "Edit" "Tak ada apl tersedia untuk menyelesaikan tindakan." - "Memproses permintaan menyimpan ke tembolok" + "Memproses permintaan menyimpan ke cache" "Smpn ke tmbolok" "Pangkas" "Setel sebagai" @@ -99,8 +99,7 @@ "Gambar & video" "Galeri Foto" "Tidak ada foto." - - + "Gambar yang dipotong disimpan ke %s." "Gambar yang dipangkas tidak disimpan." "Tidak ada album yang tersedia." "O gambar/video tersedia." diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index b8f992ee8..3437b114c 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -99,8 +99,7 @@ "Immagini e video" "Galleria fotografica" "Nessuna foto." - - + "Immagine ritagliata salvata in %s." "L\'immagine ritagliata non è stata salvata." "Nessun album disponibile." "Nessun video/immagine disponibile." diff --git a/res/values-iw/strings.xml b/res/values-iw/strings.xml index c4f34dab9..1462f420a 100644 --- a/res/values-iw/strings.xml +++ b/res/values-iw/strings.xml @@ -99,8 +99,7 @@ "תמונות וסרטונים" "גלריית תמונות" "אין תמונות." - - + "התמונה שנחתכה נשמרה ב-%s." "התמונה החתוכה לא נשמרה." "אין אלבומים זמינים." "O תמונות/סרטוני וידאו זמינים." diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml index 33058e041..8b695d632 100644 --- a/res/values-ja/strings.xml +++ b/res/values-ja/strings.xml @@ -99,8 +99,7 @@ "画像と動画" "フォトギャラリー" "画像がありません。" - - + "トリミングした画像を%sに保存しました。" "トリミングした画像は保存されていません。" "使用できるアルバムはありません。" "使用できる画像/動画: 0件" diff --git a/res/values-ko/strings.xml b/res/values-ko/strings.xml index e03d12e84..698a4e4f7 100644 --- a/res/values-ko/strings.xml +++ b/res/values-ko/strings.xml @@ -99,8 +99,7 @@ "이미지 및 동영상" "사진 갤러리" "사진이 없습니다." - - + "잘린 이미지가 %s에 저장되었습니다." "잘린 이미지가 저장되지 않았습니다." "사용할 수 있는 앨범이 없습니다." "사용할 수 있는 이미지/동영상이 없습니다." diff --git a/res/values-lt/strings.xml b/res/values-lt/strings.xml index da8f10bce..343044a5b 100644 --- a/res/values-lt/strings.xml +++ b/res/values-lt/strings.xml @@ -99,8 +99,7 @@ "Vaizdai ir vaizdo įrašai" "Nuotraukų galerija" "Nėra nuotraukų." - - + "Apkarpytas vaizdas išsaugotas aplanke %s." "Apkarpytas vaizdas neišsaugotas." "Nėra pasiekiamų albumų." "Nepasiekiami jokie vaizdai / vaizdo įrašai." diff --git a/res/values-lv/strings.xml b/res/values-lv/strings.xml index 0dce0a5da..f3254dd86 100644 --- a/res/values-lv/strings.xml +++ b/res/values-lv/strings.xml @@ -99,8 +99,7 @@ "Attēli un videoklipi" "Fotogalerija" "Nav fotoattēlu." - - + "Apgrieztais attēls ir saglabāts mapē %s." "Izgrieztais attēls netika saglabāts." "Nav pieejams neviens albums." "Nav pieejams neviens attēls/videoklips." diff --git a/res/values-nb/strings.xml b/res/values-nb/strings.xml index c1b30d21a..559ba4c8f 100644 --- a/res/values-nb/strings.xml +++ b/res/values-nb/strings.xml @@ -99,8 +99,7 @@ "Bilder og videoer" "Fotogalleri" "Ingen bilder." - - + "Det beskårede bildet er lagret i %s." "Beskåret bilde ble ikke lagret." "Ingen album tilgjengelig." "0 bilder/videoer tilgjengelig." diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml index bf000c05e..d899138c7 100644 --- a/res/values-nl/strings.xml +++ b/res/values-nl/strings.xml @@ -99,8 +99,7 @@ "Afbeeldingen en video\'s" "Fotogalerij" "Geen foto\'s." - - + "Bijgesneden afbeelding is opgeslagen in %s." "Bijgesneden afbeelding is niet opgeslagen." "Geen albums beschikbaar." "0 afbeeldingen/video\'s beschikbaar." diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml index ee9dbcbc6..f2cf2a732 100644 --- a/res/values-pl/strings.xml +++ b/res/values-pl/strings.xml @@ -46,10 +46,8 @@ "Ustawianie tapety…" "Tapeta" "Usuń" - - - - + "Potwierdzasz usunięcie?" + "Potwierdź" "Anuluj" "Udostępnij" "Zaznacz wszystkie" @@ -101,8 +99,7 @@ "Obrazy i filmy" "Galeria zdjęć" "Brak zdjęć" - - + "Przycięty obraz zapisano w %s." "Przycięty obraz nie został zapisany." "Brak dostępnych albumów" "O dostępnych obrazów/filmów" diff --git a/res/values-pt-rPT/strings.xml b/res/values-pt-rPT/strings.xml index 93d21238a..54761d79c 100644 --- a/res/values-pt-rPT/strings.xml +++ b/res/values-pt-rPT/strings.xml @@ -99,8 +99,7 @@ "Imagens e vídeos" "Galeria de fotografias" "Não existem fotografias." - - + "Imagem recortada guardada em %s." "A imagem recortada não foi guardada." "Nenhum álbum disponível." "0 imagens/vídeos disponíveis." diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml index 072312e91..f294f9f62 100644 --- a/res/values-pt/strings.xml +++ b/res/values-pt/strings.xml @@ -99,8 +99,7 @@ "Imagens e vídeos" "Galeria de fotos" "Nenhuma foto." - - + "A imagem cortada foi salva em %s." "A imagem cortada não foi salva." "Nenhum álbum disponível." "0 imagens/vídeos disponíveis." diff --git a/res/values-ro/strings.xml b/res/values-ro/strings.xml index d1e766e5a..7ec1cf52f 100644 --- a/res/values-ro/strings.xml +++ b/res/values-ro/strings.xml @@ -99,8 +99,7 @@ "Imagini şi videoclipuri" "Galerie foto" "Nicio fotografie." - - + "Imaginea decupată a fost salvată în %s." "Imaginea decupată nu a fost salvată." "Nu există albume disponibile." "Nu există imagini/videoclipuri disponibile." diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index ce167185b..47d3ef10f 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -99,8 +99,7 @@ "Изображения и видео" "Фотогалерея" "Нет фотографий" - - + "Обрезанное изображение сохранено в папке %s." "Изображение не сохранено." "Нет доступных альбомов." "Нет фото/видео" diff --git a/res/values-sk/strings.xml b/res/values-sk/strings.xml index 2a0b000ba..f18eae272 100644 --- a/res/values-sk/strings.xml +++ b/res/values-sk/strings.xml @@ -99,8 +99,7 @@ "Obrázky a videá" "Fotogaléria" "Žiadne fotografie." - - + "Orezaný obrázok bol uložený do priečinka %s." "Orezaný obrázok nebol uložený." "Nie sú k dispozícii žiadne albumy." "Počet obrázkov / videí k dispozícii: 0" diff --git a/res/values-sl/strings.xml b/res/values-sl/strings.xml index b4913ff5a..b11bf07ec 100644 --- a/res/values-sl/strings.xml +++ b/res/values-sl/strings.xml @@ -99,8 +99,7 @@ "Slike in videoposnetki" "Fotogalerija" "Ni fotografij." - - + "Obrezana slika je shranjena v mapi %s." "Obrezana slika ni bila shranjena." "Ni albumov." "Na voljo 0 slik oz. videoposnetkov." diff --git a/res/values-sr/strings.xml b/res/values-sr/strings.xml index 9fced330e..b83881821 100644 --- a/res/values-sr/strings.xml +++ b/res/values-sr/strings.xml @@ -99,8 +99,7 @@ "Слике и видео снимци" "Фото-галерија" "Нема фотографија." - - + "Опсечена слика је сачувана у директоријуму %s." "Опсечена слика није сачувана." "Ниједан албум није доступан." "Доступно је 0 слика/видео снимака." diff --git a/res/values-sv/strings.xml b/res/values-sv/strings.xml index 2f4c152d7..f89db3c37 100644 --- a/res/values-sv/strings.xml +++ b/res/values-sv/strings.xml @@ -99,8 +99,7 @@ "Bilder och videor" "Fotogalleri" "Inga foton." - - + "Den beskurna bilden har sparats i %s." "Den beskurna bilden sparades inte." "Det finns inga album." "Det finns inga bilder/videor." diff --git a/res/values-th/strings.xml b/res/values-th/strings.xml index 6dfa5b3d5..ab6bf6910 100644 --- a/res/values-th/strings.xml +++ b/res/values-th/strings.xml @@ -99,8 +99,7 @@ "ภาพและวิดีโอ" "แกลเลอรีรูปภาพ" "ไม่มีรูปภาพ" - - + "บันทึกภาพที่ครอบตัดไว้ที่ %s" "ภาพที่ตัดไม่ได้รับการบันทึก" "ไม่มีอัลบั้ม" "O ภาพ/วิดีโอ" diff --git a/res/values-tl/strings.xml b/res/values-tl/strings.xml index 008fcb9f6..90f126a56 100644 --- a/res/values-tl/strings.xml +++ b/res/values-tl/strings.xml @@ -46,10 +46,8 @@ "Itinatakda ang wallpaper…" "Wallpaper" "Tanggalin" - - - - + "Kumpirmahin ang pagtanggal?" + "Kumpirmahin" "Kanselahin" "Ibahagi" "Piliin lahat" @@ -101,8 +99,7 @@ "Mga larawan & video" "Photo Gallery" "Walang mga larawan." - - + "Nai-save ang na-crop na larawan sa %s." "Hindi nai-save ang na-crop na larawan." "Walang available na mga album." "O na larawan/video ang available." diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml index 0f10199cc..e1b734db7 100644 --- a/res/values-tr/strings.xml +++ b/res/values-tr/strings.xml @@ -99,8 +99,7 @@ "Resimler ve videolar" "Fotoğraf Galerisi" "Fotoğraf yok." - - + "Kırpılan resim %s klasörüne kaydedildi." "Kırpılmış resim kaydedilmedi." "Kullanılabilir albüm yok." "Kullanılabilir resim/video yok." diff --git a/res/values-uk/strings.xml b/res/values-uk/strings.xml index 15ca26c3a..75805d78c 100644 --- a/res/values-uk/strings.xml +++ b/res/values-uk/strings.xml @@ -99,8 +99,7 @@ "Зображення й відео" "Фотогалерея" "Фотографій немає." - - + "Обрізане зображення збережено в папці %s." "Обрізане зображення не збережено." "Немає доступних альбомів." "Немає доступних зображень або відео." diff --git a/res/values-vi/strings.xml b/res/values-vi/strings.xml index 07d88c9da..0454ea9a1 100644 --- a/res/values-vi/strings.xml +++ b/res/values-vi/strings.xml @@ -99,8 +99,7 @@ "Hình ảnh & video" "Thư viện ảnh" "Không có ảnh." - - + "Đã lưu hình ảnh được cắt vào %s." "Hình ảnh được cắt chưa được lưu." "Không có album nào." "O có hình ảnh/video nào." diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index 4aa92ced2..c670b6558 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -99,8 +99,7 @@ "图片和视频" "照片库" "无照片。" - - + "经过裁剪的图片已保存至“%s”。" "经过裁剪的图片尚未保存。" "没有可用的相册。" "没有可用的图片/视频。" diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml index 59751a525..91891ea33 100644 --- a/res/values-zh-rTW/strings.xml +++ b/res/values-zh-rTW/strings.xml @@ -99,8 +99,7 @@ "圖片和影片" "相片庫" "沒有任何相片。" - - + "裁剪的圖片已儲存至「%s」。" "未儲存裁剪的圖片。" "沒有相簿。" "O 個可用的圖片/影片。" diff --git a/res/values-zu/strings.xml b/res/values-zu/strings.xml index fe465b155..bc6977dc4 100644 --- a/res/values-zu/strings.xml +++ b/res/values-zu/strings.xml @@ -99,8 +99,7 @@ "Izithombe namavidiyo" "Igalari Yesithombe" "Azikho izithombe" - - + "Umfanekiso onqampuniwe ulondolozelwe e %s." "Umfanekiso onqampuliwe awulondoloziwe" "Awekho ama-albhamu atholalakalayo." "O izithombe/amavidiyo okutholakalayo." -- GitLab From fbdc19049e22b8b98af04e0a378c7a67810f0da7 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Mon, 30 Apr 2012 11:50:37 -0700 Subject: [PATCH 008/763] Import translations. DO NOT MERGE Change-Id: I81d0c999c8cc273044a4b8fbab92f6223ddd4654 --- res/values-af/photoeditor_strings.xml | 12 ++++-------- res/values-am/photoeditor_strings.xml | 12 ++++-------- res/values-ar/photoeditor_strings.xml | 12 ++++-------- res/values-be/photoeditor_strings.xml | 12 ++++-------- res/values-bg/photoeditor_strings.xml | 12 ++++-------- res/values-ca/photoeditor_strings.xml | 12 ++++-------- res/values-cs/photoeditor_strings.xml | 12 ++++-------- res/values-da/photoeditor_strings.xml | 12 ++++-------- res/values-de/photoeditor_strings.xml | 12 ++++-------- res/values-el/photoeditor_strings.xml | 12 ++++-------- res/values-en-rGB/photoeditor_strings.xml | 12 ++++-------- res/values-es/photoeditor_strings.xml | 12 ++++-------- res/values-et/photoeditor_strings.xml | 12 ++++-------- res/values-fa/photoeditor_strings.xml | 12 ++++-------- res/values-fi/photoeditor_strings.xml | 12 ++++-------- res/values-fr/photoeditor_strings.xml | 12 ++++-------- res/values-hi/photoeditor_strings.xml | 12 ++++-------- res/values-hr/photoeditor_strings.xml | 12 ++++-------- res/values-hu/photoeditor_strings.xml | 12 ++++-------- res/values-in/photoeditor_strings.xml | 12 ++++-------- res/values-it/photoeditor_strings.xml | 12 ++++-------- res/values-iw/photoeditor_strings.xml | 12 ++++-------- res/values-ja/photoeditor_strings.xml | 12 ++++-------- res/values-ko/photoeditor_strings.xml | 12 ++++-------- res/values-lt/photoeditor_strings.xml | 12 ++++-------- res/values-lv/photoeditor_strings.xml | 12 ++++-------- res/values-nb/photoeditor_strings.xml | 12 ++++-------- res/values-nl/photoeditor_strings.xml | 12 ++++-------- res/values-pl/photoeditor_strings.xml | 12 ++++-------- res/values-pt-rPT/photoeditor_strings.xml | 12 ++++-------- res/values-pt/photoeditor_strings.xml | 12 ++++-------- res/values-ro/photoeditor_strings.xml | 12 ++++-------- res/values-ru/photoeditor_strings.xml | 12 ++++-------- res/values-sk/photoeditor_strings.xml | 12 ++++-------- res/values-sl/photoeditor_strings.xml | 12 ++++-------- res/values-sr/photoeditor_strings.xml | 12 ++++-------- res/values-sv/photoeditor_strings.xml | 12 ++++-------- res/values-th/photoeditor_strings.xml | 12 ++++-------- res/values-tl/photoeditor_strings.xml | 12 ++++-------- res/values-tr/photoeditor_strings.xml | 12 ++++-------- res/values-uk/photoeditor_strings.xml | 12 ++++-------- res/values-vi/photoeditor_strings.xml | 12 ++++-------- res/values-zh-rCN/photoeditor_strings.xml | 12 ++++-------- res/values-zh-rTW/photoeditor_strings.xml | 12 ++++-------- res/values-zu/photoeditor_strings.xml | 12 ++++-------- 45 files changed, 180 insertions(+), 360 deletions(-) diff --git a/res/values-af/photoeditor_strings.xml b/res/values-af/photoeditor_strings.xml index 5cff1185a..e6fc868dd 100644 --- a/res/values-af/photoeditor_strings.xml +++ b/res/values-af/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Fotoateljee" - - - - - - + "Kon nie die foto laai nie" + "Kon nie geredigeerde foto stoor nie" + "Geredigeerde foto gestoor in %s" "Stoor geredigeerde foto?" "Ja" "Nee" @@ -57,8 +54,7 @@ "Trek merkers om foto te sny" "Teken op foto om te krabbel" "Trek foto om dit om te keer" - - + "Tik op rooi oë om hulle te verwyder" "Trek foto om dit te draai" "Trek foto om dit reguit te trek" diff --git a/res/values-am/photoeditor_strings.xml b/res/values-am/photoeditor_strings.xml index 7f0fbd494..2884d90a7 100644 --- a/res/values-am/photoeditor_strings.xml +++ b/res/values-am/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Photo Studio" - - - - - - + "ፎቶውን መጫን አልተቻለም" + "አርትዖት የተደረገበት ፎቶ ማስቀመጥ አልተቻለም" + "አርትዖት የተደረገበት ፎቶ %s ላይ ተቀምጧል" "ማስተካከያ የተደረገበት ፎቶ ይቀመጥ?" "አዎ" "አይ" @@ -57,8 +54,7 @@ "ፎቶ ለመከርከም አመልካቾችን ጎትት" "ፎቶውን doodle ለማድረግ ሳል" "ፎቶውን በፍጥነት ለመግለጥ ጎትት" - - + "ቀይ አይኖችን ለማስወገድ እነሱ ላይ መታ አድርግ" "ፎቶውንለማሽከርከር ጎትት" "ፎቶውንቀጥ ለማደረግ ጎትት" diff --git a/res/values-ar/photoeditor_strings.xml b/res/values-ar/photoeditor_strings.xml index a4c2e699a..69cf2156a 100644 --- a/res/values-ar/photoeditor_strings.xml +++ b/res/values-ar/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Photo Studio" - - - - - - + "تعذر تحميل الصورة" + "تعذر حفظ الصورة المعدلة" + "تم حفظ الصورة المعدلة في %s" "هل تريد حفظ الصورة التي تم تعديلها؟" "نعم" "لا" @@ -57,8 +54,7 @@ "اسحب العلامات لاقتصاص الصورة" "اسحب الصورة لإنشاء رسومات مبتكرة" "اسحب الصورة لقلبها" - - + "انقر على العيون الحمراء لإزالتها" "اسحب الصورة لتدويرها" "اسحب الصورة لتسويتها" diff --git a/res/values-be/photoeditor_strings.xml b/res/values-be/photoeditor_strings.xml index fac393ea7..3f96ea908 100644 --- a/res/values-be/photoeditor_strings.xml +++ b/res/values-be/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Фотастудыя" - - - - - - + "Немагчыма загрузіць фота" + "Немагчыма захаваць адрэдагаванае фота" + "Адрэдагаванае фота захавана ў тэчцы %s" "Захаваць адрэдагаванае фота?" "Так" "Не" @@ -57,8 +54,7 @@ "Перацягнуць маркеры, каб абрэзаць фота" "Перац. фота, каб пераўтв. яго ў святоч. лагатып" "Перацягніце фатаграфію, каб перавярнуць яе" - - + "Нац. на \"чырвоныя вочы\", каб выдаліць іх" "Перацягніце фатаграфію, каб павярнуць яе" "Перацягніце фатаграфію, каб выпраміць яе" diff --git a/res/values-bg/photoeditor_strings.xml b/res/values-bg/photoeditor_strings.xml index bac5c04a6..849e39d09 100644 --- a/res/values-bg/photoeditor_strings.xml +++ b/res/values-bg/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Photo Studio" - - - - - - + "Снимката не можа да бъде заредена" + "Редакт. снимка не можа да бъде запазена" + "Редактираната снимка е запазена в/ъв „%s“" "Да се запази ли редактираната снимка?" "Да" "Нe" @@ -57,8 +54,7 @@ "Плъзнете маркерите, за да подрежете снимката" "Рисувайте директно върху снимката" "Плъзнете с пръст върху снимката, за да я обърнете" - - + "Докоснете „черв. очи“ за премахването им" "Плъзнете с пръст върху снимката, за да я завъртите" "Плъзнете с пръст върху снимката, за да я изправите" diff --git a/res/values-ca/photoeditor_strings.xml b/res/values-ca/photoeditor_strings.xml index 3dc22a393..4e3ef7152 100644 --- a/res/values-ca/photoeditor_strings.xml +++ b/res/values-ca/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Estudi de fotografia" - - - - - - + "No s\'ha pogut carregar la foto" + "No s\'ha pogut desar la foto editada" + "S\'ha desat la foto editada a %s" "Vols desar la foto editada?" "Sí" "No" @@ -57,8 +54,7 @@ "Arrossega els marcadors per retallar la foto" "Arrossega el cursor sobre la foto per dibuixar" "Arrossega la foto per invertir-la" - - + "Toca els ulls vermells per eliminar-los" "Arrossega la foto per girar-la" "Arrossega la foto per redreçar-la" diff --git a/res/values-cs/photoeditor_strings.xml b/res/values-cs/photoeditor_strings.xml index f59c2fa38..9c62692f6 100644 --- a/res/values-cs/photoeditor_strings.xml +++ b/res/values-cs/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Photo Studio" - - - - - - + "Fotografii nelze načíst" + "Upravená fotografie nelze uložit" + "Upravená fotografie uložena do složky %s." "Chcete upravenou fotografii uložit?" "Ano" "Ne" @@ -57,8 +54,7 @@ "Táhnutím značek fotografii oříznete" "Na fotografii můžete kreslit prstem" "Táhnutím prstem fotografii převrátíte" - - + "Červené oči odstraníte klepnutím na oči" "Táhnutím prstem fotografii otočíte" "Táhnutím prstem fotografii narovnáte" diff --git a/res/values-da/photoeditor_strings.xml b/res/values-da/photoeditor_strings.xml index 2331cb318..c16fa6258 100644 --- a/res/values-da/photoeditor_strings.xml +++ b/res/values-da/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Fotostudie" - - - - - - + "Fotoet kunne ikke indlæses" + "Det redigerede foto kunne ikke gemmes" + "Det redigerede foto er gemt i %s" "Vil du gemme det redigerede billede?" "Ja" "Nej" @@ -57,8 +54,7 @@ "Træk markører for at beskære billedet" "Tegn på billedet for at lave kruseduller" "Træk billedet for at vende det" - - + "Tryk på røde øjne for at fjerne dem" "Træk billedet for at rotere det" "Træk i billedet for at rette det op" diff --git a/res/values-de/photoeditor_strings.xml b/res/values-de/photoeditor_strings.xml index 36ccfe0ae..edd1e175d 100644 --- a/res/values-de/photoeditor_strings.xml +++ b/res/values-de/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Photo Studio" - - - - - - + "Foto konnte nicht geladen werden." + "Speichern des bearbeiteten Fotos nicht möglich" + "Das bearbeitete Foto wurde in %s gespeichert." "Bearbeitetes Foto speichern?" "Ja" "Nein" @@ -57,8 +54,7 @@ "Zum Zuschneiden des Fotos Markierungen ziehen" "Zum Malen auf dem Foto malen" "Foto ziehen, um es umzudrehen" - - + "Zur Korrektur auf rote Augen tippen" "Foto ziehen, um es zu drehen" "Foto ziehen, um es zu strecken" diff --git a/res/values-el/photoeditor_strings.xml b/res/values-el/photoeditor_strings.xml index 2df08fdd7..d4b4d4a84 100644 --- a/res/values-el/photoeditor_strings.xml +++ b/res/values-el/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Photo Studio" - - - - - - + "Αδύνατη η φόρτωση της φωτογραφίας" + "Αδύνατη η αποθήκευση της επεξ. φωτογρ." + "Η επεξ. φωτογραφία αποθηκ. στον φάκελο %s" "Αποθήκευση επεξεργασμένης φωτογραφίας;" "Ναι" "Όχι" @@ -57,8 +54,7 @@ "Σύρετε τους δείκτες για την περικοπή της φωτογραφίας" "Σχεδιάστε στη φωτογραφία για να δημιουργήσετε ένα σκετσάκι" "Σύρετε τη φωτογραφία για να την αναστρέψετε" - - + "Πατήστε στα κόκκινα μάτια για διόρθωση" "Σύρετε τη φωτογραφία για να την περιστρέψετε" "Σύρετε τη φωτογραφία για να την ευθυγραμμίσετε" diff --git a/res/values-en-rGB/photoeditor_strings.xml b/res/values-en-rGB/photoeditor_strings.xml index 7bd35a38f..5ad7cd36e 100644 --- a/res/values-en-rGB/photoeditor_strings.xml +++ b/res/values-en-rGB/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Photo Studio" - - - - - - + "Couldn\'t load the photo" + "Couldn\'t save edited photo" + "Edited photo saved to %s" "Save edited photo?" "Yes" "No" @@ -57,8 +54,7 @@ "Drag markers to crop photo" "Draw on photo to doodle" "Drag photo to flip it" - - + "Tap on red eyes to remove them" "Drag photo to rotate it" "Drag photo to straighten it" diff --git a/res/values-es/photoeditor_strings.xml b/res/values-es/photoeditor_strings.xml index 906453446..ac10fae92 100644 --- a/res/values-es/photoeditor_strings.xml +++ b/res/values-es/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Photo Studio" - - - - - - + "No se puede cargar la foto." + "No se ha podido guardar la foto editada." + "La foto editada se ha guardado en %s." "¿Quieres guardar la foto editada?" "Sí" "No" @@ -57,8 +54,7 @@ "Arrastra los marcadores para recortar la foto" "Dibuja en la foto para hacer garabatos" "Arrastra la foto para darle la vuelta" - - + "Elimina los ojos rojos tocando el icono" "Arrastra la foto para girarla" "Arrastra la foto para enderezarla" diff --git a/res/values-et/photoeditor_strings.xml b/res/values-et/photoeditor_strings.xml index 1c25bbbdb..0ebdbd262 100644 --- a/res/values-et/photoeditor_strings.xml +++ b/res/values-et/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Fotostuudio" - - - - - - + "Fotot ei õnnestunud laadida" + "Muudetud fotot ei õnnestunud salvestada" + "Muudetud foto salvestati kausta %s" "Kas salvestada muudetud foto?" "Jah" "Ei" @@ -57,8 +54,7 @@ "Foto kärpimiseks lohistage markereid" "Kritseldamiseks joonistage fotol" "Ümberpööramiseks lohistage fotot" - - + "Punasilmsuse eemaldam. puudutage silma" "Pööramiseks lohistage fotot" "Rihtimiseks lohistage fotot" diff --git a/res/values-fa/photoeditor_strings.xml b/res/values-fa/photoeditor_strings.xml index 19983700a..78bf4a4d3 100644 --- a/res/values-fa/photoeditor_strings.xml +++ b/res/values-fa/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Photo Studio" - - - - - - + "بارگیری عکس انجام نشد" + "عکس ویرایش شده ذخیره نشد" + "عکس ویرایش شده در %s ذخیره شد" "عکس ویرایش شده ذخیره شود؟" "بله" "خیر" @@ -57,8 +54,7 @@ "برای بریدن عکس نشانگرها را بکشید" "برای doodle کردن روی عکس رسم کنید" "برای وارونه کردن عکس آن را بکشید" - - + "روی قرمزی چشم برای رفع آن ضربه بزنید" "برای چرخاندن عکس آن را بکشید" "برای صاف کردن عکس آن را بکشید" diff --git a/res/values-fi/photoeditor_strings.xml b/res/values-fi/photoeditor_strings.xml index 2caa636ae..9850a032e 100644 --- a/res/values-fi/photoeditor_strings.xml +++ b/res/values-fi/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Valokuvastudio" - - - - - - + "Kuvaa ei voi ladata" + "Muokatun kuvan tallentaminen epäonnistui" + "Muokattu kuva tallennettu kansioon %s" "Tallennetaanko muokattu valokuva?" "Kyllä" "Ei" @@ -57,8 +54,7 @@ "Leikkaa kuvaa vetämällä merkkejä" "Piirrä valokuvaan siirtämällä osoitin sen päälle" "Käännä kuva vetämällä" - - + "Poista punasilmäisyys napautt. silmiä" "Käännä valokuvaa vetämällä" "Suorista valokuva vetämällä" diff --git a/res/values-fr/photoeditor_strings.xml b/res/values-fr/photoeditor_strings.xml index cbb3f3cff..e3f6636bd 100644 --- a/res/values-fr/photoeditor_strings.xml +++ b/res/values-fr/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Photo Studio" - - - - - - + "Impossible de charger la photo." + "Imposs. enregistrer photo retouchée." + "Photo retouchée enregistrée dans %s." "Enregistrer photo retouchée ?" "Oui" "Non" @@ -57,8 +54,7 @@ "Faire glisser les marqueurs pour rogner la photo" "Dessiner sur la photo pour gribouiller" "Faire glisser la photo pour la retourner" - - + "Appuyer sur yeux rouges pour les effacer" "Faire glisser la photo pour la faire pivoter" "Faire glisser la photo pour la redresser" diff --git a/res/values-hi/photoeditor_strings.xml b/res/values-hi/photoeditor_strings.xml index 2f51b5589..50e081b61 100644 --- a/res/values-hi/photoeditor_strings.xml +++ b/res/values-hi/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Photo Studio" - - - - - - + "फ़ोटो लोड नहीं किया जा सका" + "संपादित फ़ोटो को सहेजा नहीं जा सका" + "संपादित फ़ोटो को %s में सहेजा गया" "संपादित फ़ोटो सहेजें?" "हां" "नहीं" @@ -57,8 +54,7 @@ "फ़ोटो की काट-छांट करने के लि‍ए मार्कर को खींचें" "doodle के लिए फ़ोटो पर आरेखित करें" "फ़ोटो को फ़्लिप करने के लिए उसे खींचें" - - + "रेड आई निकालने के लिए उन पर टैप करें" "घुमाने के लिए फ़ोटो को खींचें" "सीधा करने के लिए फ़ोटो को खींचें" diff --git a/res/values-hr/photoeditor_strings.xml b/res/values-hr/photoeditor_strings.xml index 8e2c19a58..6cff5dc75 100644 --- a/res/values-hr/photoeditor_strings.xml +++ b/res/values-hr/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Fotostudio" - - - - - - + "Nije moguće učitati fotografiju" + "Nije moguće spremiti uređenu fotografiju" + "Uređena fotografija spremljena u mapu %s" "Spremiti uređenu fotografiju?" "Da" "Ne" @@ -57,8 +54,7 @@ "Povucite oznake da biste obrezali sliku" "Crtanje na fotografiju za doodle logotip" "Povucite sliku da biste je preokrenuli" - - + "Dotaknite oči da biste uklonili crvenilo" "Povucite fotografiju da biste je rotirali" "Povucite fotografiju da biste je izravnali" diff --git a/res/values-hu/photoeditor_strings.xml b/res/values-hu/photoeditor_strings.xml index 5c6c09ff2..4c26cdc9c 100644 --- a/res/values-hu/photoeditor_strings.xml +++ b/res/values-hu/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Photo Studio" - - - - - - + "Nem sikerült betölteni a fotót" + "A szerkesztett fotót nem tudtuk menteni" + "A Szerkesztett fotót %s mappába mentettük" "A szerkesztett kép mentése?" "Igen" "Nem" @@ -57,8 +54,7 @@ "Húzza a jelölőket a fotó vágásához" "Rajzoljon a fotóra embléma létrehozásához" "Húzza a fotót annak tükrözéséhez" - - + "Vörös szemek eltávolítása megérintéssel" "Húzza a fényképet annak forgatásához" "Húzza a fényképet annak kiegyenesítéséhez" diff --git a/res/values-in/photoeditor_strings.xml b/res/values-in/photoeditor_strings.xml index ef33857ff..49e43e1b0 100644 --- a/res/values-in/photoeditor_strings.xml +++ b/res/values-in/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Photo Studio" - - - - - - + "Tidak dapat memuat foto" + "Tidak dapat menyimpan foto yang diedit" + "Foto yang diedit disimpan di %s" "Simpan foto yang diedit?" "Ya" "Tidak" @@ -57,8 +54,7 @@ "Seret penanda untuk memangkas foto" "Menggambar pada foto untuk membuat orat-oret" "Seret foto untuk membaliknya" - - + "Ketuk mata merah untuk menghapusnya" "Seret foto untuk memutarnya" "Seret foto untuk meluruskannya" diff --git a/res/values-it/photoeditor_strings.xml b/res/values-it/photoeditor_strings.xml index f48f3bd63..a28897804 100644 --- a/res/values-it/photoeditor_strings.xml +++ b/res/values-it/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Photo Studio" - - - - - - + "Impossibile caricare la foto" + "Impossibile salvare la foto modificata" + "Foto modificata salvata in %s" "Salvare la foto modificata?" "Sì" "No" @@ -57,8 +54,7 @@ "Trascina gli indicatori per ritagliare la foto" "Disegna sulla foto per scarabocchiarla" "Trascina la foto per girarla" - - + "Tocca gli occhi rossi per rimuoverli" "Trascina la foto per ruotarla" "Trascina la foto per raddrizzarla" diff --git a/res/values-iw/photoeditor_strings.xml b/res/values-iw/photoeditor_strings.xml index 37e01120b..488cf958a 100644 --- a/res/values-iw/photoeditor_strings.xml +++ b/res/values-iw/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Photo Studio" - - - - - - + "לא ניתן היה לטעון את התמונה" + "לא ניתן היה לשמור את התמונה שנערכה" + "התמונה שנערכה נשמרה ב-%s" "לשמור את התמונה הערוכה?" "כן" "לא" @@ -57,8 +54,7 @@ "גרור סמנים כדי לחתוך תמונה" "גרור על גבי התמונה כדי לצייר עליה" "גרור את התמונה כדי להפוך אותה" - - + "הקש על עיניים אדומות כדי להסיר אותן" "גרור את התמונה כדי לסובב אותה" "גרור את התמונה כדי ליישר אותה" diff --git a/res/values-ja/photoeditor_strings.xml b/res/values-ja/photoeditor_strings.xml index 3d080d956..4533ea45c 100644 --- a/res/values-ja/photoeditor_strings.xml +++ b/res/values-ja/photoeditor_strings.xml @@ -17,12 +17,9 @@ "フォトスタジオ" - - - - - - + "画像を読み込めませんでした" + "編集した画像を保存できませんでした" + "編集した画像を%sに保存しました" "編集した写真を保存しますか?" "はい" "いいえ" @@ -57,8 +54,7 @@ "写真をトリミングするにはマーカーをドラッグ" "画像の上に書き込みます" "画像をめくるにはドラッグします" - - + "赤目を補正するには赤目部分をタップします" "画像を回転させるにはドラッグします" "画像をまっすぐにするにはドラッグします" diff --git a/res/values-ko/photoeditor_strings.xml b/res/values-ko/photoeditor_strings.xml index a255f2d2a..afaa20987 100644 --- a/res/values-ko/photoeditor_strings.xml +++ b/res/values-ko/photoeditor_strings.xml @@ -17,12 +17,9 @@ "사진 스튜디오" - - - - - - + "사진을 로드할 수 없습니다." + "수정한 사진을 저장할 수 없습니다." + "수정한 사진이 %s에 저장되었습니다." "수정한 사진을 저장하시겠습니까?" "예" "아니요" @@ -57,8 +54,7 @@ "아이콘을 드래그하여 사진 자르기" "사진에 그림을 그려 낙서하기" "사진을 드래그하여 방향 바꾸기" - - + "적목현상을 없애려면 눈을 탭하세요." "드래그하여 사진 회전" "사진을 드래그하여 반듯하게 하기" diff --git a/res/values-lt/photoeditor_strings.xml b/res/values-lt/photoeditor_strings.xml index cc9d511be..ffa2f1526 100644 --- a/res/values-lt/photoeditor_strings.xml +++ b/res/values-lt/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Photo Studio" - - - - - - + "Nepavyko įkelti nuotraukos" + "Nepavyko išsaugoti redaguotos nuotraukos" + "Redaguota nuotrauka išsaugota aplanke %s" "Išsaugoti redaguotą nuotrauką?" "Taip" "Ne" @@ -57,8 +54,7 @@ "Jei norite apkarpyti nuotr., vilkite žymeklius" "Pieškite ant nuotraukos, jei norite taikyti logotipų puošybą" "Vilkite nuotrauką, kad ją apverstumėte" - - + "Palieskite raudonas akis, jei norite pašalinti raudonų akių efektą" "Vilkite nuotrauką, kad ją apsuktumėte" "Vilkite nuotrauką, kad ją ištiesintumėte" diff --git a/res/values-lv/photoeditor_strings.xml b/res/values-lv/photoeditor_strings.xml index 322a4178d..e5ddbef06 100644 --- a/res/values-lv/photoeditor_strings.xml +++ b/res/values-lv/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Fotostudija" - - - - - - + "Fotoattēlu nevarēja ielādēt." + "Rediģēto fotoattēlu nevarēja saglabāt." + "Rediģētais attēls ir saglabāts mapē %s." "Vai saglabāt rediģēto fotoattēlu?" "Jā" "Nē" @@ -57,8 +54,7 @@ "Velciet marķierus, lai apgrieztu fotoattēlu." "Velciet uz fotoattēla, lai kricelētu." "Velciet fotoattēlu, lai to apgrieztu." - - + "Piesk. sark. acīm, lai noņ. šo efektu." "Velciet fotoattēlu, lai to pagrieztu." "Velciet fotoattēlu, lai to iztaisnotu." diff --git a/res/values-nb/photoeditor_strings.xml b/res/values-nb/photoeditor_strings.xml index 589ae43d7..ea1a1b2b9 100644 --- a/res/values-nb/photoeditor_strings.xml +++ b/res/values-nb/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Photo Studio" - - - - - - + "Kunne ikke laste inn bildet" + "Kunne ikke lagre det redigerte bildet" + "Det redigerte bildet ble lagret i %s" "Vil du lagre det redigerte bildet?" "Ja" "Nei" @@ -57,8 +54,7 @@ "Dra markører for å beskjære bildet" "Tegn på bildet for å drodle" "Dra bildet for å snu det" - - + "Trykk på røde øyne for å fjerne dem" "Dra bildet for å rotere det" "Dra bildet for å rette på det" diff --git a/res/values-nl/photoeditor_strings.xml b/res/values-nl/photoeditor_strings.xml index 96b4242f0..97a37fb7c 100644 --- a/res/values-nl/photoeditor_strings.xml +++ b/res/values-nl/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Photo Studio" - - - - - - + "Kan de foto niet laden" + "Kan de bewerkte foto niet opslaan" + "Bewerkte foto is opgeslagen in %s" "Bewerkte foto opslaan?" "Ja" "Nee" @@ -57,8 +54,7 @@ "Sleep de markeringen om de foto bij te snijden" "Teken op de foto om hierop te krabbelen" "Sleep de foto om deze te spiegelen" - - + "Tik op rode ogen om ze te verwijderen" "Sleep de foto om deze te draaien" "Sleep de foto om deze recht te zetten" diff --git a/res/values-pl/photoeditor_strings.xml b/res/values-pl/photoeditor_strings.xml index a3ade7658..8b52375d3 100644 --- a/res/values-pl/photoeditor_strings.xml +++ b/res/values-pl/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Studio fotograficzne" - - - - - - + "Nie można wczytać zdjęcia" + "Nie można zapisać edytowanego zdjęcia" + "Edytowane zdjęcie zapisano w %s" "Czy zapisać edytowane zdjęcie?" "Tak" "Nie" @@ -57,8 +54,7 @@ "Przeciągnij znaczniki, aby przyciąć zdjęcie" "Rysuj po zdjęciu, aby dodać bazgroły." "Przeciągnij zdjęcie, aby je odwrócić." - - + "Dotknij czerwonych oczu, aby je usunąć" "Przeciągnij zdjęcie, aby je obrócić." "Przeciągnij zdjęcie, aby je wyprostować." diff --git a/res/values-pt-rPT/photoeditor_strings.xml b/res/values-pt-rPT/photoeditor_strings.xml index bc240d64d..c91028cca 100644 --- a/res/values-pt-rPT/photoeditor_strings.xml +++ b/res/values-pt-rPT/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Photo Studio" - - - - - - + "Não foi possível carregar a fotografia" + "Não foi possível guardar a fot. editada." + "Fotografia editada guardada em %s" "Guardar a fotografia editada?" "Sim" "Não" @@ -57,8 +54,7 @@ "Arraste os marcadores para recortar a fotografia" "Desenhe na fotografia para rabiscar" "Arraste a fotografia para virá-la" - - + "Toque nos olhos vermelhos para remover" "Arraste a fotografia para rodá-la" "Arraste a fotografia para endireitá-la" diff --git a/res/values-pt/photoeditor_strings.xml b/res/values-pt/photoeditor_strings.xml index 6fe6d5758..5025e4c2b 100644 --- a/res/values-pt/photoeditor_strings.xml +++ b/res/values-pt/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Photo Studio" - - - - - - + "Não foi possível carregar a foto" + "Não foi possível salvar a foto editada" + "A foto editada foi salva em %s" "Salvar foto editada?" "Sim" "Não" @@ -57,8 +54,7 @@ "Arraste os marcadores para cortar a foto" "Desenhe na foto para rabiscar" "Arraste a foto para invertê-la" - - + "Toque nos olhos vermelhos para removê-los" "Arraste a foto para girá-la" "Arraste a foto para endireitá-la" diff --git a/res/values-ro/photoeditor_strings.xml b/res/values-ro/photoeditor_strings.xml index 16037f826..6a45a8795 100644 --- a/res/values-ro/photoeditor_strings.xml +++ b/res/values-ro/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Studio foto" - - - - - - + "Fotografia nu a putut fi încărcată" + "Fotografia editată nu a putut fi salvată" + "Fotografia editată a fost salvată în %s" "Salvaţi fotografia editată?" "Da" "Nu" @@ -57,8 +54,7 @@ "Trageţi marcatorii pentru a decupa fotografia" "Desenaţi pe fotografie pentru a crea doodle" "Trageţi o fotografie pentru a o răsturna" - - + "Apăsaţi pe ochii roşii pentru eliminare" "Trageţi fotografia pentru a o roti" "Trageţi de fotografie pentru a o îndrepta" diff --git a/res/values-ru/photoeditor_strings.xml b/res/values-ru/photoeditor_strings.xml index f6cb79b65..3b10e8365 100644 --- a/res/values-ru/photoeditor_strings.xml +++ b/res/values-ru/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Фотостудия" - - - - - - + "Не удалось загрузить фотографию" + "Не удалось сохранить изменения" + "Измененная фотография сохранена в папке %s" "Сохранить изменения?" "Да" "Нет" @@ -57,8 +54,7 @@ "Чтобы кадрировать фото, перетащите маркеры" "Рисуйте на фото пальцем" "Чтобы отразить фото, перетащите его край" - - + "Нажмите на красные глаза, чтобы убрать их" "Чтобы повернуть фото, перетащите его край" "Чтобы выровнять фото, перетащите его" diff --git a/res/values-sk/photoeditor_strings.xml b/res/values-sk/photoeditor_strings.xml index 239cb4c9b..c589073cb 100644 --- a/res/values-sk/photoeditor_strings.xml +++ b/res/values-sk/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Photo Studio" - - - - - - + "Fotografiu sa nepodarilo načítať" + "Upravenú fotografiu sa nepodarilo uložiť" + "Uprav. fotografia bola ulož. do prieč. %s" "Chcete upravenú fotografiu uložiť?" "Áno" "Nie" @@ -57,8 +54,7 @@ "Potiahnutím značiek orežete fotografiu" "Na fotografii môžete kresliť prstom" "Potiahnutím prstom fotografiu prevrátite" - - + "Červené oči odstránite klepnutím na ne" "Potiahnutím prstom fotografiu otočíte" "Potiahnutím prstom fotografiu vyrovnáte" diff --git a/res/values-sl/photoeditor_strings.xml b/res/values-sl/photoeditor_strings.xml index 92309a024..7a73549c5 100644 --- a/res/values-sl/photoeditor_strings.xml +++ b/res/values-sl/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Photo Studio" - - - - - - + "Fotografije ni mogoče naložiti" + "Urejene fotografije ni mogoče shraniti" + "Urejena fotografija je shranjena v mapi %s" "Želite shraniti urejene fotografije?" "Da" "Ne" @@ -57,8 +54,7 @@ "Povlecite oznake, da obrežete fotografijo" "Povlecite po fotografiji za prostoročno risanje" "Povlecite fotografijo, da jo obrnete" - - + "Rdeče oči odstranite z dotikom" "Povlecite fotografijo, da jo zavrtite" "Povlecite fotografijo, da jo poravnate" diff --git a/res/values-sr/photoeditor_strings.xml b/res/values-sr/photoeditor_strings.xml index d39a1c720..595ee4ab8 100644 --- a/res/values-sr/photoeditor_strings.xml +++ b/res/values-sr/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Фото-студио" - - - - - - + "Није могуће учитати слику" + "Није могуће сачувати измењену слику" + "Измењена слика је сачувана у %s" "Желите ли да сачувате измењену фотографију?" "Да" "Не" @@ -57,8 +54,7 @@ "Превуците означиваче да бисте опсекли фотографију" "Превуците слику на дудл логотип" "Превуците фотографију да бисте је окренули" - - + "Додирните црвене очи да бисте их уклонили" "Превуците фотографију да бисте је ротирали" "Превуците фотографију да бисте је исправили" diff --git a/res/values-sv/photoeditor_strings.xml b/res/values-sv/photoeditor_strings.xml index e7a7e500c..2ec932018 100644 --- a/res/values-sv/photoeditor_strings.xml +++ b/res/values-sv/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Fotostudio" - - - - - - + "Det gick inte att läsa in bilden" + "Det gick inte att spara redigerad bild" + "Den redigerade bilden sparas i %s" "Spara redigerat foto?" "Ja" "Nej" @@ -57,8 +54,7 @@ "Dra markörerna om du vill beskära bilden" "Rita på bilden om du vill" "Tryck och dra bilden om du vill vända den" - - + "Knacka lätt på röda ögon för att ta bort" "Tryck och dra bilden om du vill rotera den" "Tryck och dra bilden om du vill räta upp den" diff --git a/res/values-th/photoeditor_strings.xml b/res/values-th/photoeditor_strings.xml index fba2a656f..773b0a962 100644 --- a/res/values-th/photoeditor_strings.xml +++ b/res/values-th/photoeditor_strings.xml @@ -17,12 +17,9 @@ "สตูดิโอถ่ายภาพ" - - - - - - + "ไม่สามารถโหลดรูปภาพ" + "ไม่สามารถบันทึกรูปภาพที่แก้ไข" + "บันทึกภาพที่แก้ไขไว้ที่ %s" "บันทึกภาพที่แก้ไขหรือไม่" "ใช่" "ไม่" @@ -57,8 +54,7 @@ "ลากเครื่องหมายเพื่อครอบตัดภาพ" "วาดบนภาพเพื่อ doodle" "ลากภาพเพื่อพลิก" - - + "แตะที่ตาแดงเพื่อนำออก" "ลากภาพเพื่อหมุน" "ลากภาพเพื่อยืดให้ตรง" diff --git a/res/values-tl/photoeditor_strings.xml b/res/values-tl/photoeditor_strings.xml index fb0957a1e..8d6a2377e 100644 --- a/res/values-tl/photoeditor_strings.xml +++ b/res/values-tl/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Photo Studio" - - - - - - + "Hindi mai-load ang larawan" + "Hindi mai-save ang na-edit na larawan" + "Nai-save ang na-edit na larawan sa %s" "I-save ang na-edit na larawan?" "Oo" "Hindi" @@ -57,8 +54,7 @@ "I-drag ang mga marker upang i-crop ang larawan" "Gumuhit sa larawan upang mag-doodle" "I-drag ang larawan upang i-flip ito" - - + "Pindutin ang mga red eye upang alisin ang mga ito" "I-drag ang larawan upang i-rotate ito" "I-drag ang larawan upang iunat ito" diff --git a/res/values-tr/photoeditor_strings.xml b/res/values-tr/photoeditor_strings.xml index bc473c2a8..da64ee0a1 100644 --- a/res/values-tr/photoeditor_strings.xml +++ b/res/values-tr/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Fotoğraf Stüdyosu" - - - - - - + "Fotoğraf yüklenemedi" + "Düzenlenen fotoğraf kaydedilemedi" + "Düzenlenen fotoğraf %s içine kaydedildi" "Düzenlenmiş fotoğraf kaydedilsin mi?" "Evet" "Hayır" @@ -57,8 +54,7 @@ "Fotoğrafı kırpmak içni işaretçileri sürükleyin" "Doodle için fotoğrafın üzerinde çizin" "Çevirmek için fotoğrafı sürükleyin" - - + "Kaldırmak için kırmızı gözlere dokunun" "Döndürmek için fotoğrafı sürükleyin" "Düzleştirmek için fotoğrafı sürükleyin" diff --git a/res/values-uk/photoeditor_strings.xml b/res/values-uk/photoeditor_strings.xml index 0527780b8..f7a27349b 100644 --- a/res/values-uk/photoeditor_strings.xml +++ b/res/values-uk/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Photo Studio" - - - - - - + "Не вдалося завантажити фотографію" + "Не вдалося зберегти відредаговане фото" + "Відредаговане фото збережено в папці %s" "Зберегти відредаговану фотографію?" "Так" "Ні" @@ -57,8 +54,7 @@ "Перетягніть маркери, щоб обрізати фото" "Малюйте на фото, щоб створити doodle" "Потягніть за фото, щоб перевернути його" - - + "Швидко торкн. черв.очей, щоб усун. ефект" "Потягніть за фото, щоб обертати його" "Перетягніть фото, щоб вирівняти його" diff --git a/res/values-vi/photoeditor_strings.xml b/res/values-vi/photoeditor_strings.xml index 349c25a03..a91ac7e82 100644 --- a/res/values-vi/photoeditor_strings.xml +++ b/res/values-vi/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Studio ảnh" - - - - - - + "Không thể tải ảnh" + "Không thể lưu ảnh đã chỉnh sửa" + "Đã lưu ảnh chỉnh sửa vào %s" "Lưu ảnh đã chỉnh sửa?" "Có" "Không" @@ -57,8 +54,7 @@ "Kéo các điểm đánh dấu để cắt ảnh" "Kéo trên ảnh để vẽ ngoạch ngoạc" "Kéo ảnh để lật" - - + "Chạm vào mắt đỏ để xóa hiệu ứng mắt đỏ" "Kéo ảnh để xoay" "Kéo ảnh để sắp thẳng" diff --git a/res/values-zh-rCN/photoeditor_strings.xml b/res/values-zh-rCN/photoeditor_strings.xml index 9cd3073f1..f3cfd2765 100644 --- a/res/values-zh-rCN/photoeditor_strings.xml +++ b/res/values-zh-rCN/photoeditor_strings.xml @@ -17,12 +17,9 @@ "照相馆" - - - - - - + "无法加载该照片" + "无法保存经过编辑的照片" + "经过编辑的照片已保存至“%s”" "要保存已修改的照片吗?" "是" "否" @@ -57,8 +54,7 @@ "拖动标记以裁剪照片" "在照片上绘制即可涂鸦" "拖动照片可将其翻转" - - + "点按即可消除红眼" "拖动照片可将其旋转" "拖动照片可将其拉直" diff --git a/res/values-zh-rTW/photoeditor_strings.xml b/res/values-zh-rTW/photoeditor_strings.xml index 9feeda49a..b16aed081 100644 --- a/res/values-zh-rTW/photoeditor_strings.xml +++ b/res/values-zh-rTW/photoeditor_strings.xml @@ -17,12 +17,9 @@ "相片工作室" - - - - - - + "無法載入相片" + "無法儲存編輯的相片" + "編輯的相片已儲存至「%s」" "要儲存已編輯的相片嗎?" "是" "否" @@ -57,8 +54,7 @@ "拖曳標記即可裁剪相片" "在相片上畫圖即可塗鴉" "拖曳照片即可翻轉" - - + "輕按紅眼即可予以移除" "拖曳照片即可旋轉" "拖曳照片即可拉正" diff --git a/res/values-zu/photoeditor_strings.xml b/res/values-zu/photoeditor_strings.xml index 285a31d7d..44b80e3db 100644 --- a/res/values-zu/photoeditor_strings.xml +++ b/res/values-zu/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Endawo Yezithombe" - - - - - - + "Ayikwazanga ukulayisha isithombe" + "Ayikwazanga ukulondoloza isithombe esilungisiwe" + "Isithombe esilungisiwe silondolozwe e %s" "Londoloza isithombe esihleliwe" "Yebo" "Cha" @@ -57,8 +54,7 @@ "Hudula insiza yokubeka uphawu ukuze usike ongakudingi esithombeni" "Dweba esithombeni ukuze kube nemidwebo eshintshayo" "Hudula isithombe ukuze usiphendule" - - + "Thinta emehlweni abomvu ukuze uwasuse" "Hudula isithombe ukuze usijikeleze" "Hudula isithombe ukuze usiqondise" -- GitLab From a2799d4973e11c5f7c9b00d1bc61f31de463ce57 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Tue, 1 May 2012 10:28:25 -0700 Subject: [PATCH 009/763] Import translations. DO NOT MERGE Change-Id: I166d8c1f6827bc0fac7b4f0436f59aac67394633 --- res/values-es-rUS/strings.xml | 3 +-- res/values-ms/strings.xml | 3 +-- res/values-sw/strings.xml | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/res/values-es-rUS/strings.xml b/res/values-es-rUS/strings.xml index 60da854c5..74b9f586a 100644 --- a/res/values-es-rUS/strings.xml +++ b/res/values-es-rUS/strings.xml @@ -99,8 +99,7 @@ "Imágenes y videos" "Galería de fotos" "No hay fotos." - - + "La imagen recortada se ha guardado en %s." "No se ha guardado la imagen recortada." "No hay álbumes disponibles." "No hay imágenes/videos disponibles." diff --git a/res/values-ms/strings.xml b/res/values-ms/strings.xml index ca0efe043..440927b2a 100644 --- a/res/values-ms/strings.xml +++ b/res/values-ms/strings.xml @@ -99,8 +99,7 @@ "Imej & video" "Galeri Foto" "Tiada foto." - - + "Imej yang dipangkas disimpan ke %s." "Imej yang dipangkas tidak disimpan." "Tiada album tersedia." "O imej/video yang tersedia." diff --git a/res/values-sw/strings.xml b/res/values-sw/strings.xml index 108408b8b..df169890e 100644 --- a/res/values-sw/strings.xml +++ b/res/values-sw/strings.xml @@ -102,8 +102,7 @@ "Picha & video" "Matunzio ya picha" "Hakuna picha." - - + "Picha iliyopunguzwa imehifadhiwa kwa %s." "Picha iliyopunguzwa haijahifadhiwa" "Hakuna albamu zinazopatikana." "picha / video zilizopo 0." -- GitLab From fa71442fa3bd56875ab30a6191114ab9600b53da Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Tue, 1 May 2012 11:36:20 -0700 Subject: [PATCH 010/763] Import translations. DO NOT MERGE Change-Id: I40d1d3dafb1bb71b6478dbfd56afc630b962113d --- res/values-es-rUS/photoeditor_strings.xml | 12 ++++-------- res/values-ms/photoeditor_strings.xml | 12 ++++-------- res/values-sw/photoeditor_strings.xml | 12 ++++-------- 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/res/values-es-rUS/photoeditor_strings.xml b/res/values-es-rUS/photoeditor_strings.xml index ab34bcc7b..1353e650f 100644 --- a/res/values-es-rUS/photoeditor_strings.xml +++ b/res/values-es-rUS/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Estudio de fotografía" - - - - - - + "No se puede cargar la foto" + "No se pudo guardar la foto editada" + "La foto editada se ha guardado en %s." "¿Guardar foto editada?" "Sí" "No" @@ -57,8 +54,7 @@ "Arrastrar los marcadores para recortar la foto" "Dibuja en la foto para hacer garabatos" "Arrastra la foto para darla vuelta" - - + "Pulsa sobre los ojos rojos para eliminarlos" "Arrastra la foto para hacerla girar" "Arrastra la foto para enderezarla" diff --git a/res/values-ms/photoeditor_strings.xml b/res/values-ms/photoeditor_strings.xml index a4e37283d..1ab16ed5a 100644 --- a/res/values-ms/photoeditor_strings.xml +++ b/res/values-ms/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Studio Foto" - - - - - - + "Tidak dapat memuatkan foto" + "Tidak dapat menyimpan foto yang diedit" + "Foto diedit disimpan ke %s" "Simpan foto yang diedit?" "Ya" "Tidak" @@ -57,8 +54,7 @@ "Seret penanda untuk memangkas foto" "Lukis pada foto untuk mencoret" "Seret foto untuk menterbalikkannya" - - + "Ketik pada mata merah untuk mengalih keluar" "Seret foto untuk memutarnya" "Seret foto untuk meluruskannya" diff --git a/res/values-sw/photoeditor_strings.xml b/res/values-sw/photoeditor_strings.xml index 34fc8acb6..8061c3ca2 100644 --- a/res/values-sw/photoeditor_strings.xml +++ b/res/values-sw/photoeditor_strings.xml @@ -17,12 +17,9 @@ "Studio ya Picha" - - - - - - + "Haikuweza kupakia picha" + "Haikuweza kuhifadhi picha iliyohaririwa" + "Picha iliyohaririwa imehifadhiwa kwa %s" "Hifadhi picha zilizohaririwa" "Ndio" "Hakuna" @@ -57,8 +54,7 @@ "Kokota viweka alama ili kupuna picha" "Chora kwenye picha ku doodle" "Kokota picha ili kuiflipu" - - + "Gonga kwenye macho mekundu ili kuondoa" "kokota picha ili kuizungusha" "Kokota picha ili kuizungusha" -- GitLab From b1bedd6150c2428f5cdc2bb39158b8cb42a64512 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Wed, 2 May 2012 11:06:33 -0700 Subject: [PATCH 011/763] Import translations. DO NOT MERGE Change-Id: I173ebbf3160eb55506dc6695b18d6267d3fca885 --- res/values-af/strings.xml | 2 -- res/values-am/strings.xml | 2 -- res/values-ar/strings.xml | 2 -- res/values-be/strings.xml | 2 -- res/values-bg/strings.xml | 2 -- res/values-ca/strings.xml | 2 -- res/values-cs/strings.xml | 2 -- res/values-da/strings.xml | 2 -- res/values-de/strings.xml | 2 -- res/values-el/strings.xml | 2 -- res/values-en-rGB/strings.xml | 2 -- res/values-es-rUS/strings.xml | 2 -- res/values-es/strings.xml | 2 -- res/values-et/strings.xml | 2 -- res/values-fa/strings.xml | 2 -- res/values-fi/strings.xml | 2 -- res/values-fr/strings.xml | 2 -- res/values-hi/strings.xml | 2 -- res/values-hr/strings.xml | 2 -- res/values-hu/strings.xml | 2 -- res/values-in/strings.xml | 2 -- res/values-it/strings.xml | 2 -- res/values-iw/strings.xml | 2 -- res/values-ja/strings.xml | 2 -- res/values-ko/strings.xml | 2 -- res/values-lt/strings.xml | 2 -- res/values-lv/strings.xml | 2 -- res/values-ms/strings.xml | 2 -- res/values-nb/strings.xml | 2 -- res/values-nl/strings.xml | 2 -- res/values-pl/strings.xml | 2 -- res/values-pt-rPT/strings.xml | 2 -- res/values-pt/strings.xml | 2 -- res/values-rm/strings.xml | 4 ---- res/values-ro/strings.xml | 2 -- res/values-ru/strings.xml | 2 -- res/values-sk/strings.xml | 2 -- res/values-sl/strings.xml | 2 -- res/values-sr/strings.xml | 2 -- res/values-sv/strings.xml | 2 -- res/values-sw/strings.xml | 2 -- res/values-th/strings.xml | 2 -- res/values-tl/strings.xml | 2 -- res/values-tr/strings.xml | 2 -- res/values-uk/strings.xml | 2 -- res/values-vi/strings.xml | 2 -- res/values-zh-rCN/strings.xml | 2 -- res/values-zh-rTW/strings.xml | 2 -- res/values-zu/strings.xml | 2 -- 49 files changed, 100 deletions(-) diff --git a/res/values-af/strings.xml b/res/values-af/strings.xml index 88ddb9f44..bf8a81ad4 100644 --- a/res/values-af/strings.xml +++ b/res/values-af/strings.xml @@ -77,7 +77,6 @@ "Draai na regs" "Kon nie die item vind nie." "Redigeer" - "Geen program is beskikbaar om die handeling te voltooi nie." "Verwerk kasversoeke" "Kas tans..." "Snoei" @@ -100,7 +99,6 @@ "Fotogalery" "Geen foto\'s nie." "Gesnoeide prent gestoor in %s." - "Gesnoeide prent is nie gestoor nie." "Geen albums beskikbaar nie." "O prente/video\'s beskikbaar." "Plasings" diff --git a/res/values-am/strings.xml b/res/values-am/strings.xml index 6f8a39e41..1bae5884d 100644 --- a/res/values-am/strings.xml +++ b/res/values-am/strings.xml @@ -77,7 +77,6 @@ "ወደ ቀኝ አሽከርክር" "ሊገኙ አልተቻለም::" "አርትዕ" - "ይህን እርምጃ ለማጠናቀቅ ምንም መተግበሪያ አልተገኘም::" "መሸጎጫ ጥየቃዎች ሂደት" "በመሸጎጥ ላይ..." "ከርክም" @@ -100,7 +99,6 @@ "የፎቶ ሥነ ጥበብ ማዕከል" "ምንም ፎቶዎች የሉም፡፡" "የተከረከመ ምስል %s ላይ ተቀምጧል።" - "የተከረከመው ምስል አልተቀመጠም::" "ምንም አልበሞች አልተገኙም::" "O ምስሎች/ ቪዲዮዎች ማግኘት ይቻላል::" "ልኡክ ጽሁፎች" diff --git a/res/values-ar/strings.xml b/res/values-ar/strings.xml index bb9fed140..17609f7d2 100644 --- a/res/values-ar/strings.xml +++ b/res/values-ar/strings.xml @@ -77,7 +77,6 @@ "تدوير لليمين" "تعذر العثور على العنصر." "تعديل" - "ليس هناك تطبيق متاح لإكمال الإجراء." "معالجة طلبات التخزين المؤقت" "تخزين مؤقت..." "اقتصاص" @@ -100,7 +99,6 @@ "معرض الصور" "ليست هناك أية صور." "تم حفظ الصورة التي تم اقتصاصها في %s." - "لم يتم حفظ الصورة التي تم اقتصاصها." "ليست هناك أية ألبومات متاحة." "لا تتوفر أية صور/مقاطع فيديو." "المشاركات" diff --git a/res/values-be/strings.xml b/res/values-be/strings.xml index d2b64d3dc..9c636fb73 100644 --- a/res/values-be/strings.xml +++ b/res/values-be/strings.xml @@ -77,7 +77,6 @@ "Павярнуць направа" "Элемент не знойдзены." "Рэдагаваць" - "Няма даступных прыкладанняў, каб завершыць гэта дзеянне." "Запыты на кэшаванне працэсу" "Кэшаванне..." "Абрэзаць" @@ -100,7 +99,6 @@ "Фотагалерэя" "Фатаграфій няма" "Абрэзаная выява захавана ў тэчцы %s." - "Абрэзаная выява не захавана." "Няма альбомаў." "Выяў/вiдэа: 0." "Паведамленнi" diff --git a/res/values-bg/strings.xml b/res/values-bg/strings.xml index bc908a3ef..10e7ca0f8 100644 --- a/res/values-bg/strings.xml +++ b/res/values-bg/strings.xml @@ -77,7 +77,6 @@ "Завъртане надясно" "Елементът не можа да бъде намерен." "Редактиране" - "Няма налични прилож. за завършване на действието." "Заявките за кеширане се обработват" "Кешира се..." "Подрязване" @@ -100,7 +99,6 @@ "Фотогалерия" "Няма снимки." "Подрязаното изображение е запазено в/ъв „%s“." - "Подрязаното изображение не бе запазено." "Няма налични албуми." "0 изображения/видеоклипове са налице." "Публикации" diff --git a/res/values-ca/strings.xml b/res/values-ca/strings.xml index 9f36f5310..e8a98683c 100644 --- a/res/values-ca/strings.xml +++ b/res/values-ca/strings.xml @@ -77,7 +77,6 @@ "Gira a la dreta" "No s\'ha trobat l\'element." "Edita" - "No hi ha cap aplicació disponible per completar l\'acció." "S\'estan processant les sol·licituds de memòria cau" "S\'està desant a la memòria cau..." "Retalla" @@ -100,7 +99,6 @@ "Galeria de fotos" "Sense fotos." "S\'ha desat la imatge retallada a %s." - "La imatge retallada no s\'ha desat." "No hi ha àlbums disponibles." "O imatges/vídeos disponibles." "Publicacions" diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml index dc7efa4ee..e5394e5de 100644 --- a/res/values-cs/strings.xml +++ b/res/values-cs/strings.xml @@ -77,7 +77,6 @@ "Otočit doprava" "Položku nelze najít." "Upravit" - "Není k dispozici žádná aplikace k dokončení akce." "Zpracování požadavků na uložení do mezipaměti" "Ukládání do mezipaměti..." "Oříznout" @@ -100,7 +99,6 @@ "Galerie fotografií" "Žádné fotky." "Ořezaný snímek byl uložen do složky %s." - "Ořezaný snímek není uložen." "Žádné album není k dispozici." "Žádné obrázky ani videa nejsou k dispozici." "Příspěvky" diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml index 52ab8eb60..d3efc0dd9 100644 --- a/res/values-da/strings.xml +++ b/res/values-da/strings.xml @@ -77,7 +77,6 @@ "Roter til højre" "Elementet blev ikke fundet." "Rediger" - "Der er ingen apps, der kan gennemføre handlingen." "Håndterer anmodninger om cachelagring" "Cachelagrer..." "Beskær" @@ -100,7 +99,6 @@ "Billedgalleri" "Ingen billeder." "Det beskårne billede er gemt i %s." - "Det beskårne billede blev ikke gemt." "Ingen tilgængelige albummer." "O tilgængelige billeder/videoer." "Indlæg" diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index ed7231cff..b0eb2135d 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -77,7 +77,6 @@ "Nach rechts drehen" "Bild wurde nicht gefunden." "Bearbeiten" - "Für diese Aktion ist keine App verfügbar." "Caching-Anfragen werden verarbeitet." "Caching läuft..." "Zuschneiden" @@ -100,7 +99,6 @@ "Fotogalerie" "Keine Fotos vorhanden" "Zugeschnittenes Bild gespeichert in %s" - "Zugeschnittenes Bild wurde nicht gespeichert." "Keine Alben verfügbar" "Keine Bilder oder Videos vorhanden" "Posts" diff --git a/res/values-el/strings.xml b/res/values-el/strings.xml index baf9334c4..951d98606 100644 --- a/res/values-el/strings.xml +++ b/res/values-el/strings.xml @@ -77,7 +77,6 @@ "Δεξιά περιστροφή" "Δεν ήταν δυνατή η εύρεση." "Επεξεργασία" - "Δεν υπάρχουν διαθέσιμες εφαρμογές για την ολοκλήρωση της ενέργειας." "Επεξεργασία αιτημάτων προσωρινής αποθήκευσης" "Προσωρ. αποθ..." "Περικοπή" @@ -100,7 +99,6 @@ "Συλλογή φωτογραφιών" "Δεν υπάρχουν φωτογραφίες." "Η αποκομμένη εικόνα αποθηκεύτηκε στον φάκελο %s." - "Δεν αποθηκεύτηκε η αποκομένη εικόνα." "Δεν υπάρχουν διαθέσιμα λευκώματα." "Δεν υπάρχουν διαθέσιμες εικόνες/βίντεο." "Αναρτήσεις" diff --git a/res/values-en-rGB/strings.xml b/res/values-en-rGB/strings.xml index df12bddc3..fad74c10e 100644 --- a/res/values-en-rGB/strings.xml +++ b/res/values-en-rGB/strings.xml @@ -77,7 +77,6 @@ "Rotate right" "Couldn\'t find item." "Edit" - "No app is available to complete the action." "Process Caching Requests" "Caching..." "Crop" @@ -100,7 +99,6 @@ "Photo Gallery" "No photos." "Cropped image saved to %s." - "Cropped image wasn\'t saved." "No albums available." "O images/videos available." "Posts" diff --git a/res/values-es-rUS/strings.xml b/res/values-es-rUS/strings.xml index 74b9f586a..2edd2021b 100644 --- a/res/values-es-rUS/strings.xml +++ b/res/values-es-rUS/strings.xml @@ -77,7 +77,6 @@ "Rotar hacia la derecha" "No se pudo encontrar el elemento." "Editar" - "No hay aplicaciones para completar la acción." "Procesando solicitudes de almacenamiento en caché" "Alm en caché..." "Recortar" @@ -100,7 +99,6 @@ "Galería de fotos" "No hay fotos." "La imagen recortada se ha guardado en %s." - "No se ha guardado la imagen recortada." "No hay álbumes disponibles." "No hay imágenes/videos disponibles." "Publicaciones" diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index c02ff8f21..68e50c117 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -77,7 +77,6 @@ "Girar a la derecha" "No se ha podido encontrar el elemento." "Editar" - "No hay aplicaciones para completar la acción." "Procesando solicitudes de almacenamiento en caché" "Almacenando en caché..." "Recortar" @@ -100,7 +99,6 @@ "Galería de fotos" "No hay fotos." "La imagen recortada se ha guardado en %s." - "No se ha guardado la imagen recortada." "No hay álbumes disponibles." "No hay imágenes ni vídeos disponibles." "Publicaciones" diff --git a/res/values-et/strings.xml b/res/values-et/strings.xml index d48fffab6..bcb030704 100644 --- a/res/values-et/strings.xml +++ b/res/values-et/strings.xml @@ -77,7 +77,6 @@ "Pööra paremale" "Üksust ei leitud." "Muuda" - "Toimingu lõpetamiseks pole sobivat rakendust saadaval." "Vahemällu lisamise taotluste töötlemine" "Vahemällu ..." "Kärbi" @@ -100,7 +99,6 @@ "Fotogalerii" "Fotod puuduvad." "Kärbitud kujutis salvestati kausta %s." - "Kärbitud kujutist ei salvestatud." "Ühtegi albumit pole saadaval." "O kujutist/videot on saadaval." "Postitused" diff --git a/res/values-fa/strings.xml b/res/values-fa/strings.xml index 25489d232..8b74110bb 100644 --- a/res/values-fa/strings.xml +++ b/res/values-fa/strings.xml @@ -77,7 +77,6 @@ "چرخش به راست" "مورد یافت نشد." "ویرایش" - "هیچ برنامه‌ای برای انجام این عملکرد موجود نیست." "پردازش درخواست‌های ذخیره در حافظه پنهان" "در حال ذخیره در حافظه پنهان..." "برش" @@ -100,7 +99,6 @@ "گالری عکس" "عکسی موجود نیست." "تصویر بریده شده در %s ذخیره شد." - "تصویر برش‌خورده ذخیره نشد." "آلبومی موجود نیست." "O تصویر/ویدیو موجود است." "پست‌ها" diff --git a/res/values-fi/strings.xml b/res/values-fi/strings.xml index 34554c4a4..febd5d19d 100644 --- a/res/values-fi/strings.xml +++ b/res/values-fi/strings.xml @@ -77,7 +77,6 @@ "Kierrä myötäpäivään" "Kohdetta ei löytynyt." "Muokkaa" - "Toiminnon suorittam. vaad. sov. ei ole saatavilla." "Käsitellään välimuistipyyntöjä" "Vie välimuist." "Rajaa" @@ -100,7 +99,6 @@ "Kuvagalleria" "Ei valokuvia." "Rajattu kuva tallennettu kansioon %s." - "Rajattua kuvaa ei tallennettu." "Ei albumeja käytettävissä." "0 kuvaa/videota saatavilla." "Julkaisut" diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index 427038a23..431683006 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -77,7 +77,6 @@ "Faire pivoter à droite" "Impossible de trouver l\'élément." "Retoucher" - "Aucune appli disponible pour effectuer l\'action." "Demandes de mise en cache en cours de traitement" "Mise en cache…" "Rogner" @@ -100,7 +99,6 @@ "Galerie photos" "Aucune photo" "Image rognée enregistrée dans %s." - "L\'image rognée n\'a pas été enregistrée." "Aucun album disponible." "Aucune image/vidéo disponible." "Posts" diff --git a/res/values-hi/strings.xml b/res/values-hi/strings.xml index 4156ddd2d..baf920653 100644 --- a/res/values-hi/strings.xml +++ b/res/values-hi/strings.xml @@ -77,7 +77,6 @@ "दाएं घुमाएं" "आइटम नहीं ढूंढा जा सका." "संपादित करें" - "क्रिया पूर्ण करने हेतु कोई एप्‍लि. उपलब्‍ध नहीं." "संचय अनुरोध संसाधित कर रहा है" "संचय कर रहा है..." "काट-छांट करें" @@ -100,7 +99,6 @@ "फ़ोटो गैलरी" "कोई फ़ोटो नहीं." "काट-छांट की गई छवि को %s में सहेजा गया." - "काट-छांट की गई छवि को नहीं सहेजा गया." "कोई एल्‍बम उपलब्‍ध नहीं." "O छवियां/वीडियो उपलब्‍ध." "पोस्ट" diff --git a/res/values-hr/strings.xml b/res/values-hr/strings.xml index 73e4a7591..eae3b03ad 100644 --- a/res/values-hr/strings.xml +++ b/res/values-hr/strings.xml @@ -77,7 +77,6 @@ "Rotiraj udesno" "Nije moguće pronaći stavku." "Uredi" - "Nema dostupnih aplikacija za dovršavanje radnje." "Obrada zahtjeva za predmemoriju" "U predmemoriju…" "Obreži" @@ -100,7 +99,6 @@ "Galerija fotografija" "Nema fotografija." "Obrezana slika spremljena u mapu %s." - "Obrezana slika nije spremljena." "Nema dostupnih albuma." "Dostupno je 0 slika/videozapisa." "Postovi" diff --git a/res/values-hu/strings.xml b/res/values-hu/strings.xml index 1fdc39c40..273c1b7d2 100644 --- a/res/values-hu/strings.xml +++ b/res/values-hu/strings.xml @@ -77,7 +77,6 @@ "Forgatás jobbra" "Nem található az elem." "Szerkesztés" - "Nincs elérhető alkalmazás a művelet befejezéséhez." "Tárolási kérelmek feldolgozása" "Gyorsítótárazás..." "Körbevágás" @@ -100,7 +99,6 @@ "Fotógaléria" "Nincsenek fényképek." "A vágott képet a(z) %s mappába mentettük." - "A vágott kép nincs elmentve." "Nincs elérhető album." "Nincs elérhető kép/videó." "Bejegyzések" diff --git a/res/values-in/strings.xml b/res/values-in/strings.xml index b72fb0b33..136cdc5fd 100644 --- a/res/values-in/strings.xml +++ b/res/values-in/strings.xml @@ -77,7 +77,6 @@ "Putar ke kanan" "Tidak dapat menemukan item." "Edit" - "Tak ada apl tersedia untuk menyelesaikan tindakan." "Memproses permintaan menyimpan ke cache" "Smpn ke tmbolok" "Pangkas" @@ -100,7 +99,6 @@ "Galeri Foto" "Tidak ada foto." "Gambar yang dipotong disimpan ke %s." - "Gambar yang dipangkas tidak disimpan." "Tidak ada album yang tersedia." "O gambar/video tersedia." "Pos" diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index 3437b114c..c19b059ae 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -77,7 +77,6 @@ "Ruota a destra" "Impossibile trovare l\'elemento." "Modifica" - "Nessuna appl. disponibile per completare azione." "Elaborazione richieste memorizzazione cache" "Memorizzazione..." "Ritaglia" @@ -100,7 +99,6 @@ "Galleria fotografica" "Nessuna foto." "Immagine ritagliata salvata in %s." - "L\'immagine ritagliata non è stata salvata." "Nessun album disponibile." "Nessun video/immagine disponibile." "Post" diff --git a/res/values-iw/strings.xml b/res/values-iw/strings.xml index 1462f420a..ae545511b 100644 --- a/res/values-iw/strings.xml +++ b/res/values-iw/strings.xml @@ -77,7 +77,6 @@ "סובב ימינה" "הפריט לא נמצא." "ערוך" - "אין יישומים זמינים להשלמת הפעולה." "מעבד בקשות העברה למטמון" "מעביר למטמון..." "חתוך" @@ -100,7 +99,6 @@ "גלריית תמונות" "אין תמונות." "התמונה שנחתכה נשמרה ב-%s." - "התמונה החתוכה לא נשמרה." "אין אלבומים זמינים." "O תמונות/סרטוני וידאו זמינים." "פוסטים" diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml index 8b695d632..832d31cf1 100644 --- a/res/values-ja/strings.xml +++ b/res/values-ja/strings.xml @@ -77,7 +77,6 @@ "右に回転" "アイテムが見つかりませんでした。" "編集" - "この操作に使用できるアプリがありません。" "キャッシュリクエストを処理しています" "キャッシュ中..." "トリミング" @@ -100,7 +99,6 @@ "フォトギャラリー" "画像がありません。" "トリミングした画像を%sに保存しました。" - "トリミングした画像は保存されていません。" "使用できるアルバムはありません。" "使用できる画像/動画: 0件" "投稿" diff --git a/res/values-ko/strings.xml b/res/values-ko/strings.xml index 698a4e4f7..bfff577d6 100644 --- a/res/values-ko/strings.xml +++ b/res/values-ko/strings.xml @@ -77,7 +77,6 @@ "오른쪽으로 회전" "항목을 찾을 수 없습니다." "수정" - "작업을 완료할 수 있는 앱이 없습니다." "캐시 요청을 처리하는 중" "캐시하는 중..." "자르기" @@ -100,7 +99,6 @@ "사진 갤러리" "사진이 없습니다." "잘린 이미지가 %s에 저장되었습니다." - "잘린 이미지가 저장되지 않았습니다." "사용할 수 있는 앨범이 없습니다." "사용할 수 있는 이미지/동영상이 없습니다." "소식" diff --git a/res/values-lt/strings.xml b/res/values-lt/strings.xml index 343044a5b..b7323f19f 100644 --- a/res/values-lt/strings.xml +++ b/res/values-lt/strings.xml @@ -77,7 +77,6 @@ "Sukti į dešinę" "Nepavyko surasti elemento." "Redaguoti" - "Nėra pasiekiamos programos veiksmui užbaigti." "Talpinimo užklausų apdorojimas" "Talpinama…" "Apkarpyti" @@ -100,7 +99,6 @@ "Nuotraukų galerija" "Nėra nuotraukų." "Apkarpytas vaizdas išsaugotas aplanke %s." - "Apkarpytas vaizdas neišsaugotas." "Nėra pasiekiamų albumų." "Nepasiekiami jokie vaizdai / vaizdo įrašai." "Įrašai" diff --git a/res/values-lv/strings.xml b/res/values-lv/strings.xml index f3254dd86..bbfc72d7d 100644 --- a/res/values-lv/strings.xml +++ b/res/values-lv/strings.xml @@ -77,7 +77,6 @@ "Pagriezt pa labi" "Nevarēja atrast vienumu." "Rediģēt" - "Nav nevienas lietotnes šīs darbības veikšanai." "Tiek apstrādāti pieprasījumi rakstīšanai kešatmiņā" "Glabā kešatm..." "Apgriezt" @@ -100,7 +99,6 @@ "Fotogalerija" "Nav fotoattēlu." "Apgrieztais attēls ir saglabāts mapē %s." - "Izgrieztais attēls netika saglabāts." "Nav pieejams neviens albums." "Nav pieejams neviens attēls/videoklips." "Ziņas" diff --git a/res/values-ms/strings.xml b/res/values-ms/strings.xml index 440927b2a..0ee0ffb76 100644 --- a/res/values-ms/strings.xml +++ b/res/values-ms/strings.xml @@ -77,7 +77,6 @@ "Putar ke kanan" "Tidak dapat mencari item." "Edit" - "Tiada aplikasi tersedia untuk melengkapkan tindakan." "Memproses permintaan cache" "Mengcache..." "Pangkas" @@ -100,7 +99,6 @@ "Galeri Foto" "Tiada foto." "Imej yang dipangkas disimpan ke %s." - "Imej yang dipangkas tidak disimpan." "Tiada album tersedia." "O imej/video yang tersedia." "Siaran" diff --git a/res/values-nb/strings.xml b/res/values-nb/strings.xml index 559ba4c8f..14ebe01d3 100644 --- a/res/values-nb/strings.xml +++ b/res/values-nb/strings.xml @@ -77,7 +77,6 @@ "Roter mot høyre" "Finner ikke elementet." "Rediger" - "Ingen app er tilgjengelig for å fullføre handlingen." "Behandler forespørsler om bufring" "Henter …" "Beskjær" @@ -100,7 +99,6 @@ "Fotogalleri" "Ingen bilder." "Det beskårede bildet er lagret i %s." - "Beskåret bilde ble ikke lagret." "Ingen album tilgjengelig." "0 bilder/videoer tilgjengelig." "Innlegg" diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml index d899138c7..576fdf4dc 100644 --- a/res/values-nl/strings.xml +++ b/res/values-nl/strings.xml @@ -77,7 +77,6 @@ "Rechtsom draaien" "Kan item niet vinden." "Bewerken" - "Geen app beschikbaar om de actie te voltooien." "Cacheverzoeken verwerken" "In cache opslaan..." "Bijsnijden" @@ -100,7 +99,6 @@ "Fotogalerij" "Geen foto\'s." "Bijgesneden afbeelding is opgeslagen in %s." - "Bijgesneden afbeelding is niet opgeslagen." "Geen albums beschikbaar." "0 afbeeldingen/video\'s beschikbaar." "Berichten" diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml index f2cf2a732..a4d637bcf 100644 --- a/res/values-pl/strings.xml +++ b/res/values-pl/strings.xml @@ -77,7 +77,6 @@ "Obróć w prawo" "Nie można znaleźć elementu." "Edytuj" - "Brak dostępnej aplikacji do ukończenia operacji" "Przetwarzanie żądań dotyczących buforowania" "Buforowanie…" "Przytnij" @@ -100,7 +99,6 @@ "Galeria zdjęć" "Brak zdjęć" "Przycięty obraz zapisano w %s." - "Przycięty obraz nie został zapisany." "Brak dostępnych albumów" "O dostępnych obrazów/filmów" "Posty" diff --git a/res/values-pt-rPT/strings.xml b/res/values-pt-rPT/strings.xml index 54761d79c..a3d4eeee7 100644 --- a/res/values-pt-rPT/strings.xml +++ b/res/values-pt-rPT/strings.xml @@ -77,7 +77,6 @@ "Rodar para a direita" "Não foi possível encontrar item." "Editar" - "Nenhuma aplicação disponível para concluir a ação." "A processar pedidos de colocação em cache" "A col. cache..." "Recortar" @@ -100,7 +99,6 @@ "Galeria de fotografias" "Não existem fotografias." "Imagem recortada guardada em %s." - "A imagem recortada não foi guardada." "Nenhum álbum disponível." "0 imagens/vídeos disponíveis." "Mensagens" diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml index f294f9f62..6fc6378ec 100644 --- a/res/values-pt/strings.xml +++ b/res/values-pt/strings.xml @@ -77,7 +77,6 @@ "Girar para a direita" "Não foi possível encontrar o item." "Editar" - "Não há aplicativo disponível para concluir a ação." "Processando solicitações de armazenamento em cache" "Cache..." "Cortar" @@ -100,7 +99,6 @@ "Galeria de fotos" "Nenhuma foto." "A imagem cortada foi salva em %s." - "A imagem cortada não foi salva." "Nenhum álbum disponível." "0 imagens/vídeos disponíveis." "Postagens" diff --git a/res/values-rm/strings.xml b/res/values-rm/strings.xml index a00f88b5c..d5dda4a84 100644 --- a/res/values-rm/strings.xml +++ b/res/values-rm/strings.xml @@ -96,8 +96,6 @@ - - @@ -141,8 +139,6 @@ - - diff --git a/res/values-ro/strings.xml b/res/values-ro/strings.xml index 7ec1cf52f..aa3d15154 100644 --- a/res/values-ro/strings.xml +++ b/res/values-ro/strings.xml @@ -77,7 +77,6 @@ "Rotiţi spre dreapta" "Elementul nu a putut fi găsit." "Editaţi" - "Nu există aplic. dispon. pt. a finaliza acţiunea." "Se proces. solicit. de stocare în memoria cache" "Mem. cache..." "Decupaţi" @@ -100,7 +99,6 @@ "Galerie foto" "Nicio fotografie." "Imaginea decupată a fost salvată în %s." - "Imaginea decupată nu a fost salvată." "Nu există albume disponibile." "Nu există imagini/videoclipuri disponibile." "Postări" diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index 47d3ef10f..e6148cf83 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -77,7 +77,6 @@ "Повернуть вправо" "Элемент не найден." "Изменить" - "Действие не поддерживается ни в одном приложении." "Обработка запросов на кэширование" "Кэширование..." "Кадрировать" @@ -100,7 +99,6 @@ "Фотогалерея" "Нет фотографий" "Обрезанное изображение сохранено в папке %s." - "Изображение не сохранено." "Нет доступных альбомов." "Нет фото/видео" "Записи" diff --git a/res/values-sk/strings.xml b/res/values-sk/strings.xml index f18eae272..9bc625ff5 100644 --- a/res/values-sk/strings.xml +++ b/res/values-sk/strings.xml @@ -77,7 +77,6 @@ "Otočiť doprava" "Položku sa nepodarilo nájsť." "Upraviť" - "Na dokončenie akcie chýba aplikácia." "Spracovávanie žiadostí o ulož. do vyrovnáv. pamäte" "Do pamäte..." "Orezať" @@ -100,7 +99,6 @@ "Fotogaléria" "Žiadne fotografie." "Orezaný obrázok bol uložený do priečinka %s." - "Orezaný obrázok nebol uložený." "Nie sú k dispozícii žiadne albumy." "Počet obrázkov / videí k dispozícii: 0" "Príspevky" diff --git a/res/values-sl/strings.xml b/res/values-sl/strings.xml index b11bf07ec..4557a4146 100644 --- a/res/values-sl/strings.xml +++ b/res/values-sl/strings.xml @@ -77,7 +77,6 @@ "Zasukaj desno" "Ni mogoče najti elementa." "Urejanje" - "Ni programa, ki bi dokončal dejanje." "Obdelava zahtev za predpomnjenje" "Predpomnjenje ..." "Obrezovanje" @@ -100,7 +99,6 @@ "Fotogalerija" "Ni fotografij." "Obrezana slika je shranjena v mapi %s." - "Obrezana slika ni bila shranjena." "Ni albumov." "Na voljo 0 slik oz. videoposnetkov." "Objave" diff --git a/res/values-sr/strings.xml b/res/values-sr/strings.xml index b83881821..aadbf7a86 100644 --- a/res/values-sr/strings.xml +++ b/res/values-sr/strings.xml @@ -77,7 +77,6 @@ "Ротирај удесно" "Није могуће пронаћи ставку." "Измени" - "Нема доступних апликација за довршавање радње." "Обрада захтева за кеширање" "Кеширање..." "Опсеци" @@ -100,7 +99,6 @@ "Фото-галерија" "Нема фотографија." "Опсечена слика је сачувана у директоријуму %s." - "Опсечена слика није сачувана." "Ниједан албум није доступан." "Доступно је 0 слика/видео снимака." "Постови" diff --git a/res/values-sv/strings.xml b/res/values-sv/strings.xml index f89db3c37..742ac58d3 100644 --- a/res/values-sv/strings.xml +++ b/res/values-sv/strings.xml @@ -77,7 +77,6 @@ "Rotera åt höger" "Det gick inte att hitta objektet." "Redigera" - "Det finns ingen app för att slutföra åtgärden." "Begäran om cachelagring bearbetas" "Cachelagrar ..." "Beskär" @@ -100,7 +99,6 @@ "Fotogalleri" "Inga foton." "Den beskurna bilden har sparats i %s." - "Den beskurna bilden sparades inte." "Det finns inga album." "Det finns inga bilder/videor." "Inlägg" diff --git a/res/values-sw/strings.xml b/res/values-sw/strings.xml index df169890e..ed8117e04 100644 --- a/res/values-sw/strings.xml +++ b/res/values-sw/strings.xml @@ -80,7 +80,6 @@ "Zungusha kulia" "Hakuweza kupata kipengee." "Hariri" - "Hakuna prog inayopatikana ili kukamilisha tendo hilo." "Maombi ya kuakibisha michakato" "Inaakibisha..." "Punguza" @@ -103,7 +102,6 @@ "Matunzio ya picha" "Hakuna picha." "Picha iliyopunguzwa imehifadhiwa kwa %s." - "Picha iliyopunguzwa haijahifadhiwa" "Hakuna albamu zinazopatikana." "picha / video zilizopo 0." "Zilizowekwa" diff --git a/res/values-th/strings.xml b/res/values-th/strings.xml index ab6bf6910..7ed0836b5 100644 --- a/res/values-th/strings.xml +++ b/res/values-th/strings.xml @@ -77,7 +77,6 @@ "หมุนไปทางขวา" "ไม่พบรายการ" "แก้ไข" - "ไม่มีแอปพลิเคชันสำหรับดำเนินการให้เสร็จสิ้น" "กำลังประมวลผลคำขอให้แคช" "กำลังแคช..." "ตัด" @@ -100,7 +99,6 @@ "แกลเลอรีรูปภาพ" "ไม่มีรูปภาพ" "บันทึกภาพที่ครอบตัดไว้ที่ %s" - "ภาพที่ตัดไม่ได้รับการบันทึก" "ไม่มีอัลบั้ม" "O ภาพ/วิดีโอ" "โพสต์" diff --git a/res/values-tl/strings.xml b/res/values-tl/strings.xml index 90f126a56..66de41bd1 100644 --- a/res/values-tl/strings.xml +++ b/res/values-tl/strings.xml @@ -77,7 +77,6 @@ "I-rotate pakanan" "Hindi mahanap ang item." "I-edit" - "Walang app available para makumpleto ang pagkilos." "Pinoproseso ang mga kahilingan sa pag-cache" "Nagka-cache…" "I-crop" @@ -100,7 +99,6 @@ "Photo Gallery" "Walang mga larawan." "Nai-save ang na-crop na larawan sa %s." - "Hindi nai-save ang na-crop na larawan." "Walang available na mga album." "O na larawan/video ang available." "Mga Post" diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml index e1b734db7..8b4eb5ea2 100644 --- a/res/values-tr/strings.xml +++ b/res/values-tr/strings.xml @@ -77,7 +77,6 @@ "Sağa döndür" "Öğe bulunamadı." "Düzenle" - "İşlemi tamamlayacak hiç uygulama yok." "Önbelleğe alma istekleri işleniyor" "Önbelleğe alınıyor..." "Kırp" @@ -100,7 +99,6 @@ "Fotoğraf Galerisi" "Fotoğraf yok." "Kırpılan resim %s klasörüne kaydedildi." - "Kırpılmış resim kaydedilmedi." "Kullanılabilir albüm yok." "Kullanılabilir resim/video yok." "Yayınlar" diff --git a/res/values-uk/strings.xml b/res/values-uk/strings.xml index 75805d78c..6846c9ed8 100644 --- a/res/values-uk/strings.xml +++ b/res/values-uk/strings.xml @@ -77,7 +77,6 @@ "Поверн. вправо" "Не вдалося знайти елемент." "Редагувати" - "Немає доступної програми, щоб виконати цю дію." "Виконується обробка запитів кешування" "Кешування..." "Обрізати" @@ -100,7 +99,6 @@ "Фотогалерея" "Фотографій немає." "Обрізане зображення збережено в папці %s." - "Обрізане зображення не збережено." "Немає доступних альбомів." "Немає доступних зображень або відео." "Публікації" diff --git a/res/values-vi/strings.xml b/res/values-vi/strings.xml index 0454ea9a1..bbcc6ac7e 100644 --- a/res/values-vi/strings.xml +++ b/res/values-vi/strings.xml @@ -77,7 +77,6 @@ "Xoay phải" "Không thể tìm thấy mục." "Chỉnh sửa" - "Không có ứng dụng nào để hoàn tất tác vụ." "Đang xử lý yêu cầu lưu vào bộ nhớ cache" "Lưu cache..." "Cắt" @@ -100,7 +99,6 @@ "Thư viện ảnh" "Không có ảnh." "Đã lưu hình ảnh được cắt vào %s." - "Hình ảnh được cắt chưa được lưu." "Không có album nào." "O có hình ảnh/video nào." "Bài đăng" diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index c670b6558..63b9b99d7 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -77,7 +77,6 @@ "向右旋转" "找不到指定的项。" "编辑" - "没有可完成该操作的应用。" "正在处理缓存请求" "正在缓存..." "修剪" @@ -100,7 +99,6 @@ "照片库" "无照片。" "经过裁剪的图片已保存至“%s”。" - "经过裁剪的图片尚未保存。" "没有可用的相册。" "没有可用的图片/视频。" "帖子" diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml index 91891ea33..fcb1be02d 100644 --- a/res/values-zh-rTW/strings.xml +++ b/res/values-zh-rTW/strings.xml @@ -77,7 +77,6 @@ "向右旋轉" "找不到項目。" "編輯" - "沒有可完成這個動作的應用程式。" "正在處理快取要求" "快取中…" "裁剪" @@ -100,7 +99,6 @@ "相片庫" "沒有任何相片。" "裁剪的圖片已儲存至「%s」。" - "未儲存裁剪的圖片。" "沒有相簿。" "O 個可用的圖片/影片。" "訊息中的相片" diff --git a/res/values-zu/strings.xml b/res/values-zu/strings.xml index bc6977dc4..641100c8c 100644 --- a/res/values-zu/strings.xml +++ b/res/values-zu/strings.xml @@ -77,7 +77,6 @@ "Phendukisela kwesokudla" "Yehlulekile ukuthola into yakho." "Hlela" - "Azikho izinhlelo zokusebenza ezitholakalayo ukuze kuqedelwe okwenziwayo." "Ilungisa izicelo zokufaka kwinqolobane" "Ukulondoloza isikhashana..." "Khropha" @@ -100,7 +99,6 @@ "Igalari Yesithombe" "Azikho izithombe" "Umfanekiso onqampuniwe ulondolozelwe e %s." - "Umfanekiso onqampuliwe awulondoloziwe" "Awekho ama-albhamu atholalakalayo." "O izithombe/amavidiyo okutholakalayo." "Okuposiwe" -- GitLab From b43d45df4951e887f4012f04067092688fc447ef Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Thu, 3 May 2012 12:48:38 -0700 Subject: [PATCH 012/763] Import translations. DO NOT MERGE Change-Id: I6f229f2f85af67c76d057e23c22c6ccba7795f85 --- res/values-es-rUS/strings.xml | 2 +- res/values-nb/strings.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/res/values-es-rUS/strings.xml b/res/values-es-rUS/strings.xml index 2edd2021b..61cf8fd2b 100644 --- a/res/values-es-rUS/strings.xml +++ b/res/values-es-rUS/strings.xml @@ -98,7 +98,7 @@ "Imágenes y videos" "Galería de fotos" "No hay fotos." - "La imagen recortada se ha guardado en %s." + "La imagen recortada se guardó en %s." "No hay álbumes disponibles." "No hay imágenes/videos disponibles." "Publicaciones" diff --git a/res/values-nb/strings.xml b/res/values-nb/strings.xml index 14ebe01d3..d7368ac1e 100644 --- a/res/values-nb/strings.xml +++ b/res/values-nb/strings.xml @@ -46,7 +46,7 @@ "Angir bakgrunn …" "Bakgrunnsbilde" "Slett" - "Bekrefte slettingen?" + "Bekrefter du slettingen?" "Bekreft" "Avbryt" "Del" -- GitLab From 56df09a404a9b23070022e070128211bbe6ad74f Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Thu, 3 May 2012 13:53:19 -0700 Subject: [PATCH 013/763] Import translations. DO NOT MERGE Change-Id: Iba1e4fc3cb7158b32e25db047fc0793e21d52c48 --- res/values-af/photoeditor_strings.xml | 4 ++-- res/values-am/photoeditor_strings.xml | 4 ++-- res/values-ar/photoeditor_strings.xml | 4 ++-- res/values-be/photoeditor_strings.xml | 4 ++-- res/values-bg/photoeditor_strings.xml | 4 ++-- res/values-ca/photoeditor_strings.xml | 4 ++-- res/values-cs/photoeditor_strings.xml | 4 ++-- res/values-da/photoeditor_strings.xml | 4 ++-- res/values-de/photoeditor_strings.xml | 4 ++-- res/values-el/photoeditor_strings.xml | 4 ++-- res/values-en-rGB/photoeditor_strings.xml | 4 ++-- res/values-es-rUS/photoeditor_strings.xml | 8 ++++---- res/values-es/photoeditor_strings.xml | 4 ++-- res/values-et/photoeditor_strings.xml | 4 ++-- res/values-fa/photoeditor_strings.xml | 4 ++-- res/values-fi/photoeditor_strings.xml | 4 ++-- res/values-fr/photoeditor_strings.xml | 4 ++-- res/values-hi/photoeditor_strings.xml | 4 ++-- res/values-hr/photoeditor_strings.xml | 4 ++-- res/values-hu/photoeditor_strings.xml | 4 ++-- res/values-in/photoeditor_strings.xml | 4 ++-- res/values-it/photoeditor_strings.xml | 4 ++-- res/values-iw/photoeditor_strings.xml | 4 ++-- res/values-ja/photoeditor_strings.xml | 4 ++-- res/values-ko/photoeditor_strings.xml | 4 ++-- res/values-lt/photoeditor_strings.xml | 6 +++--- res/values-lv/photoeditor_strings.xml | 4 ++-- res/values-ms/photoeditor_strings.xml | 4 ++-- res/values-nb/photoeditor_strings.xml | 4 ++-- res/values-nl/photoeditor_strings.xml | 4 ++-- res/values-pl/photoeditor_strings.xml | 4 ++-- res/values-pt-rPT/photoeditor_strings.xml | 8 ++++---- res/values-pt/photoeditor_strings.xml | 4 ++-- res/values-ro/photoeditor_strings.xml | 4 ++-- res/values-ru/photoeditor_strings.xml | 4 ++-- res/values-sk/photoeditor_strings.xml | 4 ++-- res/values-sl/photoeditor_strings.xml | 4 ++-- res/values-sr/photoeditor_strings.xml | 4 ++-- res/values-sv/photoeditor_strings.xml | 4 ++-- res/values-sw/photoeditor_strings.xml | 6 +++--- res/values-th/photoeditor_strings.xml | 4 ++-- res/values-tl/photoeditor_strings.xml | 4 ++-- res/values-tr/photoeditor_strings.xml | 4 ++-- res/values-uk/photoeditor_strings.xml | 6 +++--- res/values-vi/photoeditor_strings.xml | 4 ++-- res/values-zh-rCN/photoeditor_strings.xml | 4 ++-- res/values-zh-rTW/photoeditor_strings.xml | 4 ++-- res/values-zu/photoeditor_strings.xml | 4 ++-- 48 files changed, 103 insertions(+), 103 deletions(-) diff --git a/res/values-af/photoeditor_strings.xml b/res/values-af/photoeditor_strings.xml index e6fc868dd..63a104f76 100644 --- a/res/values-af/photoeditor_strings.xml +++ b/res/values-af/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Kon nie die foto laai nie" "Kon nie geredigeerde foto stoor nie" "Geredigeerde foto gestoor in %s" - "Stoor geredigeerde foto?" + + "Ja" - "Nee" "Stoor" "Outokorrigeer" "Snoei" diff --git a/res/values-am/photoeditor_strings.xml b/res/values-am/photoeditor_strings.xml index 2884d90a7..61002be4a 100644 --- a/res/values-am/photoeditor_strings.xml +++ b/res/values-am/photoeditor_strings.xml @@ -20,9 +20,9 @@ "ፎቶውን መጫን አልተቻለም" "አርትዖት የተደረገበት ፎቶ ማስቀመጥ አልተቻለም" "አርትዖት የተደረገበት ፎቶ %s ላይ ተቀምጧል" - "ማስተካከያ የተደረገበት ፎቶ ይቀመጥ?" + + "አዎ" - "አይ" "አስቀምጥ" "በራስ-ጠግን" "ክፈፍ" diff --git a/res/values-ar/photoeditor_strings.xml b/res/values-ar/photoeditor_strings.xml index 69cf2156a..c0adc7f71 100644 --- a/res/values-ar/photoeditor_strings.xml +++ b/res/values-ar/photoeditor_strings.xml @@ -20,9 +20,9 @@ "تعذر تحميل الصورة" "تعذر حفظ الصورة المعدلة" "تم حفظ الصورة المعدلة في %s" - "هل تريد حفظ الصورة التي تم تعديلها؟" + + "نعم" - "لا" "حفظ" "إصلاح تلقائي" "اقتصاص" diff --git a/res/values-be/photoeditor_strings.xml b/res/values-be/photoeditor_strings.xml index 3f96ea908..d21831335 100644 --- a/res/values-be/photoeditor_strings.xml +++ b/res/values-be/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Немагчыма загрузіць фота" "Немагчыма захаваць адрэдагаванае фота" "Адрэдагаванае фота захавана ў тэчцы %s" - "Захаваць адрэдагаванае фота?" + + "Так" - "Не" "ЗАХАВАЦЬ" "Аўтафікс." "Абрэзаць" diff --git a/res/values-bg/photoeditor_strings.xml b/res/values-bg/photoeditor_strings.xml index 849e39d09..0539a401e 100644 --- a/res/values-bg/photoeditor_strings.xml +++ b/res/values-bg/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Снимката не можа да бъде заредена" "Редакт. снимка не можа да бъде запазена" "Редактираната снимка е запазена в/ъв „%s“" - "Да се запази ли редактираната снимка?" + + "Да" - "Нe" "ЗАПАЗВ." "Автокоригиране" "Подрязване" diff --git a/res/values-ca/photoeditor_strings.xml b/res/values-ca/photoeditor_strings.xml index 4e3ef7152..760c56964 100644 --- a/res/values-ca/photoeditor_strings.xml +++ b/res/values-ca/photoeditor_strings.xml @@ -20,9 +20,9 @@ "No s\'ha pogut carregar la foto" "No s\'ha pogut desar la foto editada" "S\'ha desat la foto editada a %s" - "Vols desar la foto editada?" + + "Sí" - "No" "DESA" "Correcció automàtica" "Retalla" diff --git a/res/values-cs/photoeditor_strings.xml b/res/values-cs/photoeditor_strings.xml index 9c62692f6..b3ec484d7 100644 --- a/res/values-cs/photoeditor_strings.xml +++ b/res/values-cs/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Fotografii nelze načíst" "Upravená fotografie nelze uložit" "Upravená fotografie uložena do složky %s." - "Chcete upravenou fotografii uložit?" + + "Ano" - "Ne" "ULOŽIT" "Automat. oprava" "Oříznout" diff --git a/res/values-da/photoeditor_strings.xml b/res/values-da/photoeditor_strings.xml index c16fa6258..983c4dd0b 100644 --- a/res/values-da/photoeditor_strings.xml +++ b/res/values-da/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Fotoet kunne ikke indlæses" "Det redigerede foto kunne ikke gemmes" "Det redigerede foto er gemt i %s" - "Vil du gemme det redigerede billede?" + + "Ja" - "Nej" "GEM" "Autojustering" "Beskær" diff --git a/res/values-de/photoeditor_strings.xml b/res/values-de/photoeditor_strings.xml index edd1e175d..873746a47 100644 --- a/res/values-de/photoeditor_strings.xml +++ b/res/values-de/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Foto konnte nicht geladen werden." "Speichern des bearbeiteten Fotos nicht möglich" "Das bearbeitete Foto wurde in %s gespeichert." - "Bearbeitetes Foto speichern?" + + "Ja" - "Nein" "Speichern" "Auto-Fix" "Zuschneiden" diff --git a/res/values-el/photoeditor_strings.xml b/res/values-el/photoeditor_strings.xml index d4b4d4a84..da614ca04 100644 --- a/res/values-el/photoeditor_strings.xml +++ b/res/values-el/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Αδύνατη η φόρτωση της φωτογραφίας" "Αδύνατη η αποθήκευση της επεξ. φωτογρ." "Η επεξ. φωτογραφία αποθηκ. στον φάκελο %s" - "Αποθήκευση επεξεργασμένης φωτογραφίας;" + + "Ναι" - "Όχι" "ΑΠΟΘΗΚΕΥΣΗ" "Αυτ.επιδ." "Περικοπή" diff --git a/res/values-en-rGB/photoeditor_strings.xml b/res/values-en-rGB/photoeditor_strings.xml index 5ad7cd36e..2f2866482 100644 --- a/res/values-en-rGB/photoeditor_strings.xml +++ b/res/values-en-rGB/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Couldn\'t load the photo" "Couldn\'t save edited photo" "Edited photo saved to %s" - "Save edited photo?" + + "Yes" - "No" "SAVE" "Auto-fix" "Crop" diff --git a/res/values-es-rUS/photoeditor_strings.xml b/res/values-es-rUS/photoeditor_strings.xml index 1353e650f..0dc1a00a8 100644 --- a/res/values-es-rUS/photoeditor_strings.xml +++ b/res/values-es-rUS/photoeditor_strings.xml @@ -19,10 +19,10 @@ "Estudio de fotografía" "No se puede cargar la foto" "No se pudo guardar la foto editada" - "La foto editada se ha guardado en %s." - "¿Guardar foto editada?" + "La foto editada se guardó en %s." + + "Sí" - "No" "GUARDAR" "Autocorrección" "Recortar" @@ -54,7 +54,7 @@ "Arrastrar los marcadores para recortar la foto" "Dibuja en la foto para hacer garabatos" "Arrastra la foto para darla vuelta" - "Pulsa sobre los ojos rojos para eliminarlos" + "Elimina los ojos rojos tocando el icono" "Arrastra la foto para hacerla girar" "Arrastra la foto para enderezarla" diff --git a/res/values-es/photoeditor_strings.xml b/res/values-es/photoeditor_strings.xml index ac10fae92..462627254 100644 --- a/res/values-es/photoeditor_strings.xml +++ b/res/values-es/photoeditor_strings.xml @@ -20,9 +20,9 @@ "No se puede cargar la foto." "No se ha podido guardar la foto editada." "La foto editada se ha guardado en %s." - "¿Quieres guardar la foto editada?" + + "Sí" - "No" "GUARDAR" "Ajuste automático" "Recortar" diff --git a/res/values-et/photoeditor_strings.xml b/res/values-et/photoeditor_strings.xml index 0ebdbd262..d92fa6b8c 100644 --- a/res/values-et/photoeditor_strings.xml +++ b/res/values-et/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Fotot ei õnnestunud laadida" "Muudetud fotot ei õnnestunud salvestada" "Muudetud foto salvestati kausta %s" - "Kas salvestada muudetud foto?" + + "Jah" - "Ei" "SALVESTA" "Automaatparandus" "Kärpimine" diff --git a/res/values-fa/photoeditor_strings.xml b/res/values-fa/photoeditor_strings.xml index 78bf4a4d3..b5901749d 100644 --- a/res/values-fa/photoeditor_strings.xml +++ b/res/values-fa/photoeditor_strings.xml @@ -20,9 +20,9 @@ "بارگیری عکس انجام نشد" "عکس ویرایش شده ذخیره نشد" "عکس ویرایش شده در %s ذخیره شد" - "عکس ویرایش شده ذخیره شود؟" + + "بله" - "خیر" "ذخیره" "تصحیح خودکار" "برش" diff --git a/res/values-fi/photoeditor_strings.xml b/res/values-fi/photoeditor_strings.xml index 9850a032e..baeb101e7 100644 --- a/res/values-fi/photoeditor_strings.xml +++ b/res/values-fi/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Kuvaa ei voi ladata" "Muokatun kuvan tallentaminen epäonnistui" "Muokattu kuva tallennettu kansioon %s" - "Tallennetaanko muokattu valokuva?" + + "Kyllä" - "Ei" "Tallenna" "Autom. korjaus" "Rajaa" diff --git a/res/values-fr/photoeditor_strings.xml b/res/values-fr/photoeditor_strings.xml index e3f6636bd..6a564430c 100644 --- a/res/values-fr/photoeditor_strings.xml +++ b/res/values-fr/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Impossible de charger la photo." "Imposs. enregistrer photo retouchée." "Photo retouchée enregistrée dans %s." - "Enregistrer photo retouchée ?" + + "Oui" - "Non" "ENREG." "Correction auto" "Rogner" diff --git a/res/values-hi/photoeditor_strings.xml b/res/values-hi/photoeditor_strings.xml index 50e081b61..1534f7e71 100644 --- a/res/values-hi/photoeditor_strings.xml +++ b/res/values-hi/photoeditor_strings.xml @@ -20,9 +20,9 @@ "फ़ोटो लोड नहीं किया जा सका" "संपादित फ़ोटो को सहेजा नहीं जा सका" "संपादित फ़ोटो को %s में सहेजा गया" - "संपादित फ़ोटो सहेजें?" + + "हां" - "नहीं" "सहेजें" "स्‍वत: समायोजन" "काट-छांट करें" diff --git a/res/values-hr/photoeditor_strings.xml b/res/values-hr/photoeditor_strings.xml index 6cff5dc75..a77d60410 100644 --- a/res/values-hr/photoeditor_strings.xml +++ b/res/values-hr/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Nije moguće učitati fotografiju" "Nije moguće spremiti uređenu fotografiju" "Uređena fotografija spremljena u mapu %s" - "Spremiti uređenu fotografiju?" + + "Da" - "Ne" "SPREMI" "Aut. popravak" "Obreži" diff --git a/res/values-hu/photoeditor_strings.xml b/res/values-hu/photoeditor_strings.xml index 4c26cdc9c..47c805f97 100644 --- a/res/values-hu/photoeditor_strings.xml +++ b/res/values-hu/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Nem sikerült betölteni a fotót" "A szerkesztett fotót nem tudtuk menteni" "A Szerkesztett fotót %s mappába mentettük" - "A szerkesztett kép mentése?" + + "Igen" - "Nem" "MENTÉS" "Autom. javítás" "Körbevágás" diff --git a/res/values-in/photoeditor_strings.xml b/res/values-in/photoeditor_strings.xml index 49e43e1b0..ff024770d 100644 --- a/res/values-in/photoeditor_strings.xml +++ b/res/values-in/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Tidak dapat memuat foto" "Tidak dapat menyimpan foto yang diedit" "Foto yang diedit disimpan di %s" - "Simpan foto yang diedit?" + + "Ya" - "Tidak" "SIMPAN" "Prbaikan Otomts" "Pangkas" diff --git a/res/values-it/photoeditor_strings.xml b/res/values-it/photoeditor_strings.xml index a28897804..07b163911 100644 --- a/res/values-it/photoeditor_strings.xml +++ b/res/values-it/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Impossibile caricare la foto" "Impossibile salvare la foto modificata" "Foto modificata salvata in %s" - "Salvare la foto modificata?" + + "Sì" - "No" "SALVA" "Correzione autom." "Ritaglia" diff --git a/res/values-iw/photoeditor_strings.xml b/res/values-iw/photoeditor_strings.xml index 488cf958a..92b472218 100644 --- a/res/values-iw/photoeditor_strings.xml +++ b/res/values-iw/photoeditor_strings.xml @@ -20,9 +20,9 @@ "לא ניתן היה לטעון את התמונה" "לא ניתן היה לשמור את התמונה שנערכה" "התמונה שנערכה נשמרה ב-%s" - "לשמור את התמונה הערוכה?" + + "כן" - "לא" "שמור" "תיקון אוטומטי" "חתוך" diff --git a/res/values-ja/photoeditor_strings.xml b/res/values-ja/photoeditor_strings.xml index 4533ea45c..493b8d166 100644 --- a/res/values-ja/photoeditor_strings.xml +++ b/res/values-ja/photoeditor_strings.xml @@ -20,9 +20,9 @@ "画像を読み込めませんでした" "編集した画像を保存できませんでした" "編集した画像を%sに保存しました" - "編集した写真を保存しますか?" + + "はい" - "いいえ" "保存" "自動修正" "トリミング" diff --git a/res/values-ko/photoeditor_strings.xml b/res/values-ko/photoeditor_strings.xml index afaa20987..83907f5b9 100644 --- a/res/values-ko/photoeditor_strings.xml +++ b/res/values-ko/photoeditor_strings.xml @@ -20,9 +20,9 @@ "사진을 로드할 수 없습니다." "수정한 사진을 저장할 수 없습니다." "수정한 사진이 %s에 저장되었습니다." - "수정한 사진을 저장하시겠습니까?" + + "예" - "아니요" "저장" "자동 보정" "자르기" diff --git a/res/values-lt/photoeditor_strings.xml b/res/values-lt/photoeditor_strings.xml index ffa2f1526..68425fabb 100644 --- a/res/values-lt/photoeditor_strings.xml +++ b/res/values-lt/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Nepavyko įkelti nuotraukos" "Nepavyko išsaugoti redaguotos nuotraukos" "Redaguota nuotrauka išsaugota aplanke %s" - "Išsaugoti redaguotą nuotrauką?" + + "Taip" - "Ne" "IŠSAUGOT" "Automat. nustat." "Apkarpyti" @@ -54,7 +54,7 @@ "Jei norite apkarpyti nuotr., vilkite žymeklius" "Pieškite ant nuotraukos, jei norite taikyti logotipų puošybą" "Vilkite nuotrauką, kad ją apverstumėte" - "Palieskite raudonas akis, jei norite pašalinti raudonų akių efektą" + "Paliesk. raud. akis, kad pašal. jų efek." "Vilkite nuotrauką, kad ją apsuktumėte" "Vilkite nuotrauką, kad ją ištiesintumėte" diff --git a/res/values-lv/photoeditor_strings.xml b/res/values-lv/photoeditor_strings.xml index e5ddbef06..1b8f3c9a5 100644 --- a/res/values-lv/photoeditor_strings.xml +++ b/res/values-lv/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Fotoattēlu nevarēja ielādēt." "Rediģēto fotoattēlu nevarēja saglabāt." "Rediģētais attēls ir saglabāts mapē %s." - "Vai saglabāt rediģēto fotoattēlu?" + + "Jā" - "Nē" "SAGLABĀT" "Automātiska labošana" "Apgriešana" diff --git a/res/values-ms/photoeditor_strings.xml b/res/values-ms/photoeditor_strings.xml index 1ab16ed5a..6547885ca 100644 --- a/res/values-ms/photoeditor_strings.xml +++ b/res/values-ms/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Tidak dapat memuatkan foto" "Tidak dapat menyimpan foto yang diedit" "Foto diedit disimpan ke %s" - "Simpan foto yang diedit?" + + "Ya" - "Tidak" "SIMPAN" "Auto-baiki" "Pangkas" diff --git a/res/values-nb/photoeditor_strings.xml b/res/values-nb/photoeditor_strings.xml index ea1a1b2b9..21a988610 100644 --- a/res/values-nb/photoeditor_strings.xml +++ b/res/values-nb/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Kunne ikke laste inn bildet" "Kunne ikke lagre det redigerte bildet" "Det redigerte bildet ble lagret i %s" - "Vil du lagre det redigerte bildet?" + + "Ja" - "Nei" "LAGRE" "Autokorrektur" "Beskjær" diff --git a/res/values-nl/photoeditor_strings.xml b/res/values-nl/photoeditor_strings.xml index 97a37fb7c..37399624f 100644 --- a/res/values-nl/photoeditor_strings.xml +++ b/res/values-nl/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Kan de foto niet laden" "Kan de bewerkte foto niet opslaan" "Bewerkte foto is opgeslagen in %s" - "Bewerkte foto opslaan?" + + "Ja" - "Nee" "OPSLAAN" "Auto-fix" "Bijsnijden" diff --git a/res/values-pl/photoeditor_strings.xml b/res/values-pl/photoeditor_strings.xml index 8b52375d3..4526bc578 100644 --- a/res/values-pl/photoeditor_strings.xml +++ b/res/values-pl/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Nie można wczytać zdjęcia" "Nie można zapisać edytowanego zdjęcia" "Edytowane zdjęcie zapisano w %s" - "Czy zapisać edytowane zdjęcie?" + + "Tak" - "Nie" "ZAPISZ" "Autopoprawka" "Przytnij" diff --git a/res/values-pt-rPT/photoeditor_strings.xml b/res/values-pt-rPT/photoeditor_strings.xml index c91028cca..aec27e093 100644 --- a/res/values-pt-rPT/photoeditor_strings.xml +++ b/res/values-pt-rPT/photoeditor_strings.xml @@ -18,11 +18,11 @@ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> "Photo Studio" "Não foi possível carregar a fotografia" - "Não foi possível guardar a fot. editada." + "Não foi possível guardar a foto editada." "Fotografia editada guardada em %s" - "Guardar a fotografia editada?" + + "Sim" - "Não" "GUARDAR" "Correção Autom." "Recortar" @@ -54,7 +54,7 @@ "Arraste os marcadores para recortar a fotografia" "Desenhe na fotografia para rabiscar" "Arraste a fotografia para virá-la" - "Toque nos olhos vermelhos para remover" + "Toque nos olhos vermelhos p/ os remover" "Arraste a fotografia para rodá-la" "Arraste a fotografia para endireitá-la" diff --git a/res/values-pt/photoeditor_strings.xml b/res/values-pt/photoeditor_strings.xml index 5025e4c2b..08aa3c57c 100644 --- a/res/values-pt/photoeditor_strings.xml +++ b/res/values-pt/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Não foi possível carregar a foto" "Não foi possível salvar a foto editada" "A foto editada foi salva em %s" - "Salvar foto editada?" + + "Sim" - "Não" "SALVAR" "Correção autom." "Cortar" diff --git a/res/values-ro/photoeditor_strings.xml b/res/values-ro/photoeditor_strings.xml index 6a45a8795..ca664d59f 100644 --- a/res/values-ro/photoeditor_strings.xml +++ b/res/values-ro/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Fotografia nu a putut fi încărcată" "Fotografia editată nu a putut fi salvată" "Fotografia editată a fost salvată în %s" - "Salvaţi fotografia editată?" + + "Da" - "Nu" "SALVAŢI" "Remediere auto." "Decupaţi" diff --git a/res/values-ru/photoeditor_strings.xml b/res/values-ru/photoeditor_strings.xml index 3b10e8365..7eeb0dffb 100644 --- a/res/values-ru/photoeditor_strings.xml +++ b/res/values-ru/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Не удалось загрузить фотографию" "Не удалось сохранить изменения" "Измененная фотография сохранена в папке %s" - "Сохранить изменения?" + + "Да" - "Нет" "ГОТОВО" "Авто" "Кадрировать" diff --git a/res/values-sk/photoeditor_strings.xml b/res/values-sk/photoeditor_strings.xml index c589073cb..70d67da6f 100644 --- a/res/values-sk/photoeditor_strings.xml +++ b/res/values-sk/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Fotografiu sa nepodarilo načítať" "Upravenú fotografiu sa nepodarilo uložiť" "Uprav. fotografia bola ulož. do prieč. %s" - "Chcete upravenú fotografiu uložiť?" + + "Áno" - "Nie" "ULOŽIŤ" "Automat. oprava" "Orezať" diff --git a/res/values-sl/photoeditor_strings.xml b/res/values-sl/photoeditor_strings.xml index 7a73549c5..bf854d64c 100644 --- a/res/values-sl/photoeditor_strings.xml +++ b/res/values-sl/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Fotografije ni mogoče naložiti" "Urejene fotografije ni mogoče shraniti" "Urejena fotografija je shranjena v mapi %s" - "Želite shraniti urejene fotografije?" + + "Da" - "Ne" "SHRANI" "Samod. poprav." "Obrezovanje" diff --git a/res/values-sr/photoeditor_strings.xml b/res/values-sr/photoeditor_strings.xml index 595ee4ab8..e08530c64 100644 --- a/res/values-sr/photoeditor_strings.xml +++ b/res/values-sr/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Није могуће учитати слику" "Није могуће сачувати измењену слику" "Измењена слика је сачувана у %s" - "Желите ли да сачувате измењену фотографију?" + + "Да" - "Не" "САЧУВАЈ" "Аутоподешавање" "Опсецање" diff --git a/res/values-sv/photoeditor_strings.xml b/res/values-sv/photoeditor_strings.xml index 2ec932018..940188556 100644 --- a/res/values-sv/photoeditor_strings.xml +++ b/res/values-sv/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Det gick inte att läsa in bilden" "Det gick inte att spara redigerad bild" "Den redigerade bilden sparas i %s" - "Spara redigerat foto?" + + "Ja" - "Nej" "SPARA" "Åtgärda automatiskt" "Beskär" diff --git a/res/values-sw/photoeditor_strings.xml b/res/values-sw/photoeditor_strings.xml index 8061c3ca2..db7274ea9 100644 --- a/res/values-sw/photoeditor_strings.xml +++ b/res/values-sw/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Haikuweza kupakia picha" "Haikuweza kuhifadhi picha iliyohaririwa" "Picha iliyohaririwa imehifadhiwa kwa %s" - "Hifadhi picha zilizohaririwa" + + "Ndio" - "Hakuna" "HIFADHI" "Weka kiotomatiki" "Kata" @@ -54,7 +54,7 @@ "Kokota viweka alama ili kupuna picha" "Chora kwenye picha ku doodle" "Kokota picha ili kuiflipu" - "Gonga kwenye macho mekundu ili kuondoa" + "Gonga kwenye macho mekundu ili kuyaondoa" "kokota picha ili kuizungusha" "Kokota picha ili kuizungusha" diff --git a/res/values-th/photoeditor_strings.xml b/res/values-th/photoeditor_strings.xml index 773b0a962..86ed23a97 100644 --- a/res/values-th/photoeditor_strings.xml +++ b/res/values-th/photoeditor_strings.xml @@ -20,9 +20,9 @@ "ไม่สามารถโหลดรูปภาพ" "ไม่สามารถบันทึกรูปภาพที่แก้ไข" "บันทึกภาพที่แก้ไขไว้ที่ %s" - "บันทึกภาพที่แก้ไขหรือไม่" + + "ใช่" - "ไม่" "บันทึก" "แก้ไขอัตโนมัติ" "ตัด" diff --git a/res/values-tl/photoeditor_strings.xml b/res/values-tl/photoeditor_strings.xml index 8d6a2377e..6bc698c55 100644 --- a/res/values-tl/photoeditor_strings.xml +++ b/res/values-tl/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Hindi mai-load ang larawan" "Hindi mai-save ang na-edit na larawan" "Nai-save ang na-edit na larawan sa %s" - "I-save ang na-edit na larawan?" + + "Oo" - "Hindi" "I-SAVE" "Auto-fix" "Pag-crop" diff --git a/res/values-tr/photoeditor_strings.xml b/res/values-tr/photoeditor_strings.xml index da64ee0a1..233ba1ec3 100644 --- a/res/values-tr/photoeditor_strings.xml +++ b/res/values-tr/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Fotoğraf yüklenemedi" "Düzenlenen fotoğraf kaydedilemedi" "Düzenlenen fotoğraf %s içine kaydedildi" - "Düzenlenmiş fotoğraf kaydedilsin mi?" + + "Evet" - "Hayır" "KAYDET" "Otomatik düzelt" "Kırp" diff --git a/res/values-uk/photoeditor_strings.xml b/res/values-uk/photoeditor_strings.xml index f7a27349b..c3becec2f 100644 --- a/res/values-uk/photoeditor_strings.xml +++ b/res/values-uk/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Не вдалося завантажити фотографію" "Не вдалося зберегти відредаговане фото" "Відредаговане фото збережено в папці %s" - "Зберегти відредаговану фотографію?" + + "Так" - "Ні" "ЗБЕРЕГТИ" "Автовиправлення" "Обрізка" @@ -54,7 +54,7 @@ "Перетягніть маркери, щоб обрізати фото" "Малюйте на фото, щоб створити doodle" "Потягніть за фото, щоб перевернути його" - "Швидко торкн. черв.очей, щоб усун. ефект" + "Торкн. червоних очей, щоб усунути ефект" "Потягніть за фото, щоб обертати його" "Перетягніть фото, щоб вирівняти його" diff --git a/res/values-vi/photoeditor_strings.xml b/res/values-vi/photoeditor_strings.xml index a91ac7e82..d32d2b299 100644 --- a/res/values-vi/photoeditor_strings.xml +++ b/res/values-vi/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Không thể tải ảnh" "Không thể lưu ảnh đã chỉnh sửa" "Đã lưu ảnh chỉnh sửa vào %s" - "Lưu ảnh đã chỉnh sửa?" + + "Có" - "Không" "LƯU" "T.động sửa" "Cắt" diff --git a/res/values-zh-rCN/photoeditor_strings.xml b/res/values-zh-rCN/photoeditor_strings.xml index f3cfd2765..876e006ff 100644 --- a/res/values-zh-rCN/photoeditor_strings.xml +++ b/res/values-zh-rCN/photoeditor_strings.xml @@ -20,9 +20,9 @@ "无法加载该照片" "无法保存经过编辑的照片" "经过编辑的照片已保存至“%s”" - "要保存已修改的照片吗?" + + "是" - "否" "保存" "自动修正" "修剪" diff --git a/res/values-zh-rTW/photoeditor_strings.xml b/res/values-zh-rTW/photoeditor_strings.xml index b16aed081..2ad36c367 100644 --- a/res/values-zh-rTW/photoeditor_strings.xml +++ b/res/values-zh-rTW/photoeditor_strings.xml @@ -20,9 +20,9 @@ "無法載入相片" "無法儲存編輯的相片" "編輯的相片已儲存至「%s」" - "要儲存已編輯的相片嗎?" + + "是" - "否" "儲存" "自動修正" "裁剪" diff --git a/res/values-zu/photoeditor_strings.xml b/res/values-zu/photoeditor_strings.xml index 44b80e3db..fc234f56a 100644 --- a/res/values-zu/photoeditor_strings.xml +++ b/res/values-zu/photoeditor_strings.xml @@ -20,9 +20,9 @@ "Ayikwazanga ukulayisha isithombe" "Ayikwazanga ukulondoloza isithombe esilungisiwe" "Isithombe esilungisiwe silondolozwe e %s" - "Londoloza isithombe esihleliwe" + + "Yebo" - "Cha" "Londoloza" "Insiza Yokulungisa Okuzenzekelayo" "Nqampuna" -- GitLab From 5eeb896fd725652fb1d93031b9878f33e904cd19 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Fri, 4 May 2012 12:05:17 -0700 Subject: [PATCH 014/763] Import translations. DO NOT MERGE Change-Id: I7f9521775fb29c3d2fb4b65165600167c9ee9706 --- res/values-ca/photoeditor_strings.xml | 3 +-- res/values-da/photoeditor_strings.xml | 3 +-- res/values-el/photoeditor_strings.xml | 3 +-- res/values-en-rGB/photoeditor_strings.xml | 3 +-- res/values-nl/photoeditor_strings.xml | 3 +-- res/values-sr/photoeditor_strings.xml | 2 +- res/values-tr/photoeditor_strings.xml | 2 +- res/values-zh-rTW/photoeditor_strings.xml | 4 ++-- 8 files changed, 9 insertions(+), 14 deletions(-) diff --git a/res/values-ca/photoeditor_strings.xml b/res/values-ca/photoeditor_strings.xml index 760c56964..83139654a 100644 --- a/res/values-ca/photoeditor_strings.xml +++ b/res/values-ca/photoeditor_strings.xml @@ -20,8 +20,7 @@ "No s\'ha pogut carregar la foto" "No s\'ha pogut desar la foto editada" "S\'ha desat la foto editada a %s" - - + "Vols descartar els canvis no desats?" "Sí" "DESA" "Correcció automàtica" diff --git a/res/values-da/photoeditor_strings.xml b/res/values-da/photoeditor_strings.xml index 983c4dd0b..0d96d434d 100644 --- a/res/values-da/photoeditor_strings.xml +++ b/res/values-da/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Fotoet kunne ikke indlæses" "Det redigerede foto kunne ikke gemmes" "Det redigerede foto er gemt i %s" - - + "Kassér ændringer, som ikke er gemt?" "Ja" "GEM" "Autojustering" diff --git a/res/values-el/photoeditor_strings.xml b/res/values-el/photoeditor_strings.xml index da614ca04..8ec8c5af4 100644 --- a/res/values-el/photoeditor_strings.xml +++ b/res/values-el/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Αδύνατη η φόρτωση της φωτογραφίας" "Αδύνατη η αποθήκευση της επεξ. φωτογρ." "Η επεξ. φωτογραφία αποθηκ. στον φάκελο %s" - - + "Απόρριψη μη αποθηκευμένων αλλαγών;" "Ναι" "ΑΠΟΘΗΚΕΥΣΗ" "Αυτ.επιδ." diff --git a/res/values-en-rGB/photoeditor_strings.xml b/res/values-en-rGB/photoeditor_strings.xml index 2f2866482..6dde2f8c0 100644 --- a/res/values-en-rGB/photoeditor_strings.xml +++ b/res/values-en-rGB/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Couldn\'t load the photo" "Couldn\'t save edited photo" "Edited photo saved to %s" - - + "Discard unsaved changes?" "Yes" "SAVE" "Auto-fix" diff --git a/res/values-nl/photoeditor_strings.xml b/res/values-nl/photoeditor_strings.xml index 37399624f..e4418fcec 100644 --- a/res/values-nl/photoeditor_strings.xml +++ b/res/values-nl/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Kan de foto niet laden" "Kan de bewerkte foto niet opslaan" "Bewerkte foto is opgeslagen in %s" - - + "Niet-opgeslagen wijzigingen annuleren?" "Ja" "OPSLAAN" "Auto-fix" diff --git a/res/values-sr/photoeditor_strings.xml b/res/values-sr/photoeditor_strings.xml index e08530c64..436faf944 100644 --- a/res/values-sr/photoeditor_strings.xml +++ b/res/values-sr/photoeditor_strings.xml @@ -54,7 +54,7 @@ "Превуците означиваче да бисте опсекли фотографију" "Превуците слику на дудл логотип" "Превуците фотографију да бисте је окренули" - "Додирните црвене очи да бисте их уклонили" + "Додирните црвене очи да бисте их поправили" "Превуците фотографију да бисте је ротирали" "Превуците фотографију да бисте је исправили" diff --git a/res/values-tr/photoeditor_strings.xml b/res/values-tr/photoeditor_strings.xml index 233ba1ec3..44ff25409 100644 --- a/res/values-tr/photoeditor_strings.xml +++ b/res/values-tr/photoeditor_strings.xml @@ -54,7 +54,7 @@ "Fotoğrafı kırpmak içni işaretçileri sürükleyin" "Doodle için fotoğrafın üzerinde çizin" "Çevirmek için fotoğrafı sürükleyin" - "Kaldırmak için kırmızı gözlere dokunun" + "Kırmızı gözleri hafifçe vurarak düzeltin" "Döndürmek için fotoğrafı sürükleyin" "Düzleştirmek için fotoğrafı sürükleyin" diff --git a/res/values-zh-rTW/photoeditor_strings.xml b/res/values-zh-rTW/photoeditor_strings.xml index 2ad36c367..3112a0ad1 100644 --- a/res/values-zh-rTW/photoeditor_strings.xml +++ b/res/values-zh-rTW/photoeditor_strings.xml @@ -18,8 +18,8 @@ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> "相片工作室" "無法載入相片" - "無法儲存編輯的相片" - "編輯的相片已儲存至「%s」" + "無法儲存編輯完成的相片" + "編輯完成的相片已儲存至「%s」" "是" -- GitLab From 81c2f0115a81446ed51a5ed86b4eaaa2e1de2050 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Mon, 7 May 2012 12:09:40 -0700 Subject: [PATCH 015/763] Import translations. DO NOT MERGE Change-Id: Ia266db1c3715c642e2035b8d0b7b269d07a0a0f6 --- res/values-am/photoeditor_strings.xml | 3 +-- res/values-ar/photoeditor_strings.xml | 3 +-- res/values-be/photoeditor_strings.xml | 3 +-- res/values-bg/photoeditor_strings.xml | 3 +-- res/values-cs/photoeditor_strings.xml | 3 +-- res/values-de/photoeditor_strings.xml | 3 +-- res/values-es-rUS/photoeditor_strings.xml | 3 +-- res/values-es/photoeditor_strings.xml | 3 +-- res/values-et/photoeditor_strings.xml | 3 +-- res/values-fi/photoeditor_strings.xml | 3 +-- res/values-fr/photoeditor_strings.xml | 3 +-- res/values-hi/photoeditor_strings.xml | 3 +-- res/values-hr/photoeditor_strings.xml | 3 +-- res/values-hu/photoeditor_strings.xml | 3 +-- res/values-it/photoeditor_strings.xml | 3 +-- res/values-iw/photoeditor_strings.xml | 3 +-- res/values-ja/photoeditor_strings.xml | 3 +-- res/values-ko/photoeditor_strings.xml | 3 +-- res/values-lt/photoeditor_strings.xml | 3 +-- res/values-lv/photoeditor_strings.xml | 3 +-- res/values-nb/photoeditor_strings.xml | 3 +-- res/values-pt-rPT/photoeditor_strings.xml | 3 +-- res/values-pt/photoeditor_strings.xml | 3 +-- res/values-ro/photoeditor_strings.xml | 3 +-- res/values-ru/photoeditor_strings.xml | 3 +-- res/values-sk/photoeditor_strings.xml | 3 +-- res/values-sl/photoeditor_strings.xml | 3 +-- res/values-sr/photoeditor_strings.xml | 3 +-- res/values-sv/photoeditor_strings.xml | 3 +-- res/values-sw/photoeditor_strings.xml | 3 +-- res/values-th/photoeditor_strings.xml | 3 +-- res/values-tl/photoeditor_strings.xml | 3 +-- res/values-tr/photoeditor_strings.xml | 3 +-- res/values-uk/photoeditor_strings.xml | 3 +-- res/values-vi/photoeditor_strings.xml | 3 +-- res/values-zh-rTW/photoeditor_strings.xml | 3 +-- res/values-zu/photoeditor_strings.xml | 3 +-- 37 files changed, 37 insertions(+), 74 deletions(-) diff --git a/res/values-am/photoeditor_strings.xml b/res/values-am/photoeditor_strings.xml index 61002be4a..75759300b 100644 --- a/res/values-am/photoeditor_strings.xml +++ b/res/values-am/photoeditor_strings.xml @@ -20,8 +20,7 @@ "ፎቶውን መጫን አልተቻለም" "አርትዖት የተደረገበት ፎቶ ማስቀመጥ አልተቻለም" "አርትዖት የተደረገበት ፎቶ %s ላይ ተቀምጧል" - - + "ያልተቀመጡ ለውጦች ይወገዱ?" "አዎ" "አስቀምጥ" "በራስ-ጠግን" diff --git a/res/values-ar/photoeditor_strings.xml b/res/values-ar/photoeditor_strings.xml index c0adc7f71..7f75cc70c 100644 --- a/res/values-ar/photoeditor_strings.xml +++ b/res/values-ar/photoeditor_strings.xml @@ -20,8 +20,7 @@ "تعذر تحميل الصورة" "تعذر حفظ الصورة المعدلة" "تم حفظ الصورة المعدلة في %s" - - + "هل تريد إلغاء أي تغييرات غير محفوظة؟" "نعم" "حفظ" "إصلاح تلقائي" diff --git a/res/values-be/photoeditor_strings.xml b/res/values-be/photoeditor_strings.xml index d21831335..6fa477b83 100644 --- a/res/values-be/photoeditor_strings.xml +++ b/res/values-be/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Немагчыма загрузіць фота" "Немагчыма захаваць адрэдагаванае фота" "Адрэдагаванае фота захавана ў тэчцы %s" - - + "Скасаваць незахаваныя змены?" "Так" "ЗАХАВАЦЬ" "Аўтафікс." diff --git a/res/values-bg/photoeditor_strings.xml b/res/values-bg/photoeditor_strings.xml index 0539a401e..b31bf211b 100644 --- a/res/values-bg/photoeditor_strings.xml +++ b/res/values-bg/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Снимката не можа да бъде заредена" "Редакт. снимка не можа да бъде запазена" "Редактираната снимка е запазена в/ъв „%s“" - - + "Да се отхвърлят ли незапазените промени?" "Да" "ЗАПАЗВ." "Автокоригиране" diff --git a/res/values-cs/photoeditor_strings.xml b/res/values-cs/photoeditor_strings.xml index b3ec484d7..0349bd25b 100644 --- a/res/values-cs/photoeditor_strings.xml +++ b/res/values-cs/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Fotografii nelze načíst" "Upravená fotografie nelze uložit" "Upravená fotografie uložena do složky %s." - - + "Zrušit neuložené změny?" "Ano" "ULOŽIT" "Automat. oprava" diff --git a/res/values-de/photoeditor_strings.xml b/res/values-de/photoeditor_strings.xml index 873746a47..a00fa53f7 100644 --- a/res/values-de/photoeditor_strings.xml +++ b/res/values-de/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Foto konnte nicht geladen werden." "Speichern des bearbeiteten Fotos nicht möglich" "Das bearbeitete Foto wurde in %s gespeichert." - - + "Nicht gespeicherte Änderungen verwerfen?" "Ja" "Speichern" "Auto-Fix" diff --git a/res/values-es-rUS/photoeditor_strings.xml b/res/values-es-rUS/photoeditor_strings.xml index 0dc1a00a8..f0a38ed9e 100644 --- a/res/values-es-rUS/photoeditor_strings.xml +++ b/res/values-es-rUS/photoeditor_strings.xml @@ -20,8 +20,7 @@ "No se puede cargar la foto" "No se pudo guardar la foto editada" "La foto editada se guardó en %s." - - + "¿Descartar cambios sin guardar?" "Sí" "GUARDAR" "Autocorrección" diff --git a/res/values-es/photoeditor_strings.xml b/res/values-es/photoeditor_strings.xml index 462627254..4b4f7eb3a 100644 --- a/res/values-es/photoeditor_strings.xml +++ b/res/values-es/photoeditor_strings.xml @@ -20,8 +20,7 @@ "No se puede cargar la foto." "No se ha podido guardar la foto editada." "La foto editada se ha guardado en %s." - - + "¿Descartar los cambios no guardados?" "Sí" "GUARDAR" "Ajuste automático" diff --git a/res/values-et/photoeditor_strings.xml b/res/values-et/photoeditor_strings.xml index d92fa6b8c..c9244868d 100644 --- a/res/values-et/photoeditor_strings.xml +++ b/res/values-et/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Fotot ei õnnestunud laadida" "Muudetud fotot ei õnnestunud salvestada" "Muudetud foto salvestati kausta %s" - - + "Kas loobute salvestamata muudatustest?" "Jah" "SALVESTA" "Automaatparandus" diff --git a/res/values-fi/photoeditor_strings.xml b/res/values-fi/photoeditor_strings.xml index baeb101e7..ce60dc7c1 100644 --- a/res/values-fi/photoeditor_strings.xml +++ b/res/values-fi/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Kuvaa ei voi ladata" "Muokatun kuvan tallentaminen epäonnistui" "Muokattu kuva tallennettu kansioon %s" - - + "Hylätäänkö tallentamattomat muutokset?" "Kyllä" "Tallenna" "Autom. korjaus" diff --git a/res/values-fr/photoeditor_strings.xml b/res/values-fr/photoeditor_strings.xml index 6a564430c..193e3f0fe 100644 --- a/res/values-fr/photoeditor_strings.xml +++ b/res/values-fr/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Impossible de charger la photo." "Imposs. enregistrer photo retouchée." "Photo retouchée enregistrée dans %s." - - + "Annuler modifications non enregistrées ?" "Oui" "ENREG." "Correction auto" diff --git a/res/values-hi/photoeditor_strings.xml b/res/values-hi/photoeditor_strings.xml index 1534f7e71..f5286ec7b 100644 --- a/res/values-hi/photoeditor_strings.xml +++ b/res/values-hi/photoeditor_strings.xml @@ -20,8 +20,7 @@ "फ़ोटो लोड नहीं किया जा सका" "संपादित फ़ोटो को सहेजा नहीं जा सका" "संपादित फ़ोटो को %s में सहेजा गया" - - + "न सहेजे गए परिवर्तनों को छोड़ें?" "हां" "सहेजें" "स्‍वत: समायोजन" diff --git a/res/values-hr/photoeditor_strings.xml b/res/values-hr/photoeditor_strings.xml index a77d60410..6ba85f333 100644 --- a/res/values-hr/photoeditor_strings.xml +++ b/res/values-hr/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Nije moguće učitati fotografiju" "Nije moguće spremiti uređenu fotografiju" "Uređena fotografija spremljena u mapu %s" - - + "Odbaciti nespremljene promjene?" "Da" "SPREMI" "Aut. popravak" diff --git a/res/values-hu/photoeditor_strings.xml b/res/values-hu/photoeditor_strings.xml index 47c805f97..4136478fa 100644 --- a/res/values-hu/photoeditor_strings.xml +++ b/res/values-hu/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Nem sikerült betölteni a fotót" "A szerkesztett fotót nem tudtuk menteni" "A Szerkesztett fotót %s mappába mentettük" - - + "Elveti a nem mentett módosításokat?" "Igen" "MENTÉS" "Autom. javítás" diff --git a/res/values-it/photoeditor_strings.xml b/res/values-it/photoeditor_strings.xml index 07b163911..1e42e79a3 100644 --- a/res/values-it/photoeditor_strings.xml +++ b/res/values-it/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Impossibile caricare la foto" "Impossibile salvare la foto modificata" "Foto modificata salvata in %s" - - + "Ignorare le modifiche non salvate?" "Sì" "SALVA" "Correzione autom." diff --git a/res/values-iw/photoeditor_strings.xml b/res/values-iw/photoeditor_strings.xml index 92b472218..bde3689bf 100644 --- a/res/values-iw/photoeditor_strings.xml +++ b/res/values-iw/photoeditor_strings.xml @@ -20,8 +20,7 @@ "לא ניתן היה לטעון את התמונה" "לא ניתן היה לשמור את התמונה שנערכה" "התמונה שנערכה נשמרה ב-%s" - - + "למחוק שינויים שלא נשמרו?" "כן" "שמור" "תיקון אוטומטי" diff --git a/res/values-ja/photoeditor_strings.xml b/res/values-ja/photoeditor_strings.xml index 493b8d166..5fab60338 100644 --- a/res/values-ja/photoeditor_strings.xml +++ b/res/values-ja/photoeditor_strings.xml @@ -20,8 +20,7 @@ "画像を読み込めませんでした" "編集した画像を保存できませんでした" "編集した画像を%sに保存しました" - - + "保存されていない変更を破棄しますか?" "はい" "保存" "自動修正" diff --git a/res/values-ko/photoeditor_strings.xml b/res/values-ko/photoeditor_strings.xml index 83907f5b9..3f89a37da 100644 --- a/res/values-ko/photoeditor_strings.xml +++ b/res/values-ko/photoeditor_strings.xml @@ -20,8 +20,7 @@ "사진을 로드할 수 없습니다." "수정한 사진을 저장할 수 없습니다." "수정한 사진이 %s에 저장되었습니다." - - + "저장되지 않은 변경사항을 삭제하시겠습니까?" "예" "저장" "자동 보정" diff --git a/res/values-lt/photoeditor_strings.xml b/res/values-lt/photoeditor_strings.xml index 68425fabb..c9f76c4e4 100644 --- a/res/values-lt/photoeditor_strings.xml +++ b/res/values-lt/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Nepavyko įkelti nuotraukos" "Nepavyko išsaugoti redaguotos nuotraukos" "Redaguota nuotrauka išsaugota aplanke %s" - - + "Atmesti neišsaugotus pakeitimus?" "Taip" "IŠSAUGOT" "Automat. nustat." diff --git a/res/values-lv/photoeditor_strings.xml b/res/values-lv/photoeditor_strings.xml index 1b8f3c9a5..444f2c98b 100644 --- a/res/values-lv/photoeditor_strings.xml +++ b/res/values-lv/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Fotoattēlu nevarēja ielādēt." "Rediģēto fotoattēlu nevarēja saglabāt." "Rediģētais attēls ir saglabāts mapē %s." - - + "Vai atmest nesaglabātās izmaiņas?" "Jā" "SAGLABĀT" "Automātiska labošana" diff --git a/res/values-nb/photoeditor_strings.xml b/res/values-nb/photoeditor_strings.xml index 21a988610..425cd7780 100644 --- a/res/values-nb/photoeditor_strings.xml +++ b/res/values-nb/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Kunne ikke laste inn bildet" "Kunne ikke lagre det redigerte bildet" "Det redigerte bildet ble lagret i %s" - - + "Vil du forkaste endringer som ikke er lagret?" "Ja" "LAGRE" "Autokorrektur" diff --git a/res/values-pt-rPT/photoeditor_strings.xml b/res/values-pt-rPT/photoeditor_strings.xml index aec27e093..13575a887 100644 --- a/res/values-pt-rPT/photoeditor_strings.xml +++ b/res/values-pt-rPT/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Não foi possível carregar a fotografia" "Não foi possível guardar a foto editada." "Fotografia editada guardada em %s" - - + "Rejeitar alterações não guardadas?" "Sim" "GUARDAR" "Correção Autom." diff --git a/res/values-pt/photoeditor_strings.xml b/res/values-pt/photoeditor_strings.xml index 08aa3c57c..8c8a28bd5 100644 --- a/res/values-pt/photoeditor_strings.xml +++ b/res/values-pt/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Não foi possível carregar a foto" "Não foi possível salvar a foto editada" "A foto editada foi salva em %s" - - + "Descartar as alterações não salvas?" "Sim" "SALVAR" "Correção autom." diff --git a/res/values-ro/photoeditor_strings.xml b/res/values-ro/photoeditor_strings.xml index ca664d59f..3967449af 100644 --- a/res/values-ro/photoeditor_strings.xml +++ b/res/values-ro/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Fotografia nu a putut fi încărcată" "Fotografia editată nu a putut fi salvată" "Fotografia editată a fost salvată în %s" - - + "Renunţaţi la modificările nesalvate?" "Da" "SALVAŢI" "Remediere auto." diff --git a/res/values-ru/photoeditor_strings.xml b/res/values-ru/photoeditor_strings.xml index 7eeb0dffb..af7f91f27 100644 --- a/res/values-ru/photoeditor_strings.xml +++ b/res/values-ru/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Не удалось загрузить фотографию" "Не удалось сохранить изменения" "Измененная фотография сохранена в папке %s" - - + "Отменить несохраненные изменения?" "Да" "ГОТОВО" "Авто" diff --git a/res/values-sk/photoeditor_strings.xml b/res/values-sk/photoeditor_strings.xml index 70d67da6f..2b563f457 100644 --- a/res/values-sk/photoeditor_strings.xml +++ b/res/values-sk/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Fotografiu sa nepodarilo načítať" "Upravenú fotografiu sa nepodarilo uložiť" "Uprav. fotografia bola ulož. do prieč. %s" - - + "Zahodiť neuložené zmeny?" "Áno" "ULOŽIŤ" "Automat. oprava" diff --git a/res/values-sl/photoeditor_strings.xml b/res/values-sl/photoeditor_strings.xml index bf854d64c..10a6e82a7 100644 --- a/res/values-sl/photoeditor_strings.xml +++ b/res/values-sl/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Fotografije ni mogoče naložiti" "Urejene fotografije ni mogoče shraniti" "Urejena fotografija je shranjena v mapi %s" - - + "Želite zavreči neshranjene spremembe?" "Da" "SHRANI" "Samod. poprav." diff --git a/res/values-sr/photoeditor_strings.xml b/res/values-sr/photoeditor_strings.xml index 436faf944..6ac3576bb 100644 --- a/res/values-sr/photoeditor_strings.xml +++ b/res/values-sr/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Није могуће учитати слику" "Није могуће сачувати измењену слику" "Измењена слика је сачувана у %s" - - + "Желите да одбаците несачуване промене?" "Да" "САЧУВАЈ" "Аутоподешавање" diff --git a/res/values-sv/photoeditor_strings.xml b/res/values-sv/photoeditor_strings.xml index 940188556..e1d9a002d 100644 --- a/res/values-sv/photoeditor_strings.xml +++ b/res/values-sv/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Det gick inte att läsa in bilden" "Det gick inte att spara redigerad bild" "Den redigerade bilden sparas i %s" - - + "Vill du ignorera ändringar som inte har sparats?" "Ja" "SPARA" "Åtgärda automatiskt" diff --git a/res/values-sw/photoeditor_strings.xml b/res/values-sw/photoeditor_strings.xml index db7274ea9..d8d1b82c3 100644 --- a/res/values-sw/photoeditor_strings.xml +++ b/res/values-sw/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Haikuweza kupakia picha" "Haikuweza kuhifadhi picha iliyohaririwa" "Picha iliyohaririwa imehifadhiwa kwa %s" - - + "Tupa mabadiliko yasiyohifadhiwa?" "Ndio" "HIFADHI" "Weka kiotomatiki" diff --git a/res/values-th/photoeditor_strings.xml b/res/values-th/photoeditor_strings.xml index 86ed23a97..7f819e826 100644 --- a/res/values-th/photoeditor_strings.xml +++ b/res/values-th/photoeditor_strings.xml @@ -20,8 +20,7 @@ "ไม่สามารถโหลดรูปภาพ" "ไม่สามารถบันทึกรูปภาพที่แก้ไข" "บันทึกภาพที่แก้ไขไว้ที่ %s" - - + "ยกเลิกการเปลี่ยนแปลงที่ยังไม่ได้บันทึก" "ใช่" "บันทึก" "แก้ไขอัตโนมัติ" diff --git a/res/values-tl/photoeditor_strings.xml b/res/values-tl/photoeditor_strings.xml index 6bc698c55..467568566 100644 --- a/res/values-tl/photoeditor_strings.xml +++ b/res/values-tl/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Hindi mai-load ang larawan" "Hindi mai-save ang na-edit na larawan" "Nai-save ang na-edit na larawan sa %s" - - + "I-discard ang di naka-save na pagbabago?" "Oo" "I-SAVE" "Auto-fix" diff --git a/res/values-tr/photoeditor_strings.xml b/res/values-tr/photoeditor_strings.xml index 44ff25409..e3dac6620 100644 --- a/res/values-tr/photoeditor_strings.xml +++ b/res/values-tr/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Fotoğraf yüklenemedi" "Düzenlenen fotoğraf kaydedilemedi" "Düzenlenen fotoğraf %s içine kaydedildi" - - + "Kaydedilmeyen değişiklikler silinsin mi?" "Evet" "KAYDET" "Otomatik düzelt" diff --git a/res/values-uk/photoeditor_strings.xml b/res/values-uk/photoeditor_strings.xml index c3becec2f..67707d527 100644 --- a/res/values-uk/photoeditor_strings.xml +++ b/res/values-uk/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Не вдалося завантажити фотографію" "Не вдалося зберегти відредаговане фото" "Відредаговане фото збережено в папці %s" - - + "Відхилити незбережені зміни?" "Так" "ЗБЕРЕГТИ" "Автовиправлення" diff --git a/res/values-vi/photoeditor_strings.xml b/res/values-vi/photoeditor_strings.xml index d32d2b299..82779c33e 100644 --- a/res/values-vi/photoeditor_strings.xml +++ b/res/values-vi/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Không thể tải ảnh" "Không thể lưu ảnh đã chỉnh sửa" "Đã lưu ảnh chỉnh sửa vào %s" - - + "Hủy các thay đổi chưa lưu?" "Có" "LƯU" "T.động sửa" diff --git a/res/values-zh-rTW/photoeditor_strings.xml b/res/values-zh-rTW/photoeditor_strings.xml index 3112a0ad1..21b724689 100644 --- a/res/values-zh-rTW/photoeditor_strings.xml +++ b/res/values-zh-rTW/photoeditor_strings.xml @@ -20,8 +20,7 @@ "無法載入相片" "無法儲存編輯完成的相片" "編輯完成的相片已儲存至「%s」" - - + "要捨棄尚未儲存的變更?" "是" "儲存" "自動修正" diff --git a/res/values-zu/photoeditor_strings.xml b/res/values-zu/photoeditor_strings.xml index fc234f56a..fad43bf94 100644 --- a/res/values-zu/photoeditor_strings.xml +++ b/res/values-zu/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Ayikwazanga ukulayisha isithombe" "Ayikwazanga ukulondoloza isithombe esilungisiwe" "Isithombe esilungisiwe silondolozwe e %s" - - + "Lahla izinguquko ezingagciniwe?" "Yebo" "Londoloza" "Insiza Yokulungisa Okuzenzekelayo" -- GitLab From f87bb236af2275180df1b378e00e3b20d6bfdd2c Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Wed, 9 May 2012 11:39:34 -0700 Subject: [PATCH 016/763] Import translations. DO NOT MERGE Change-Id: I649abc52094a6ce50c33f8b83bdb5bee4331f31d --- res/values-af/photoeditor_strings.xml | 3 +-- res/values-fa/photoeditor_strings.xml | 3 +-- res/values-in/photoeditor_strings.xml | 3 +-- res/values-ms/photoeditor_strings.xml | 3 +-- res/values-pl/photoeditor_strings.xml | 3 +-- res/values-zh-rCN/photoeditor_strings.xml | 3 +-- 6 files changed, 6 insertions(+), 12 deletions(-) diff --git a/res/values-af/photoeditor_strings.xml b/res/values-af/photoeditor_strings.xml index 63a104f76..c18011022 100644 --- a/res/values-af/photoeditor_strings.xml +++ b/res/values-af/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Kon nie die foto laai nie" "Kon nie geredigeerde foto stoor nie" "Geredigeerde foto gestoor in %s" - - + "Raak ontslae van ongestoorde veranderinge?" "Ja" "Stoor" "Outokorrigeer" diff --git a/res/values-fa/photoeditor_strings.xml b/res/values-fa/photoeditor_strings.xml index b5901749d..177c6465b 100644 --- a/res/values-fa/photoeditor_strings.xml +++ b/res/values-fa/photoeditor_strings.xml @@ -20,8 +20,7 @@ "بارگیری عکس انجام نشد" "عکس ویرایش شده ذخیره نشد" "عکس ویرایش شده در %s ذخیره شد" - - + "از تغییرات ذخیره نشده صرفنظر شود؟" "بله" "ذخیره" "تصحیح خودکار" diff --git a/res/values-in/photoeditor_strings.xml b/res/values-in/photoeditor_strings.xml index ff024770d..3aea62988 100644 --- a/res/values-in/photoeditor_strings.xml +++ b/res/values-in/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Tidak dapat memuat foto" "Tidak dapat menyimpan foto yang diedit" "Foto yang diedit disimpan di %s" - - + "Buang perubahan yang tidak tersimpan?" "Ya" "SIMPAN" "Prbaikan Otomts" diff --git a/res/values-ms/photoeditor_strings.xml b/res/values-ms/photoeditor_strings.xml index 6547885ca..c7be0f873 100644 --- a/res/values-ms/photoeditor_strings.xml +++ b/res/values-ms/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Tidak dapat memuatkan foto" "Tidak dapat menyimpan foto yang diedit" "Foto diedit disimpan ke %s" - - + "Buang perubahan yang belum disimpan?" "Ya" "SIMPAN" "Auto-baiki" diff --git a/res/values-pl/photoeditor_strings.xml b/res/values-pl/photoeditor_strings.xml index 4526bc578..628cccbab 100644 --- a/res/values-pl/photoeditor_strings.xml +++ b/res/values-pl/photoeditor_strings.xml @@ -20,8 +20,7 @@ "Nie można wczytać zdjęcia" "Nie można zapisać edytowanego zdjęcia" "Edytowane zdjęcie zapisano w %s" - - + "Odrzucić niezapisane zmiany?" "Tak" "ZAPISZ" "Autopoprawka" diff --git a/res/values-zh-rCN/photoeditor_strings.xml b/res/values-zh-rCN/photoeditor_strings.xml index 876e006ff..123e390bd 100644 --- a/res/values-zh-rCN/photoeditor_strings.xml +++ b/res/values-zh-rCN/photoeditor_strings.xml @@ -20,8 +20,7 @@ "无法加载该照片" "无法保存经过编辑的照片" "经过编辑的照片已保存至“%s”" - - + "要舍弃未保存的更改吗?" "是" "保存" "自动修正" -- GitLab From 5ac531134bf4e23ac136282ba36b2a88d485af02 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Mon, 14 May 2012 11:24:44 -0700 Subject: [PATCH 017/763] Import translations. DO NOT MERGE Change-Id: I0a3057ba775776b9148af3e9ab7fd302f21cb8c0 --- res/values-cs/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml index e5394e5de..1d2c68885 100644 --- a/res/values-cs/strings.xml +++ b/res/values-cs/strings.xml @@ -103,7 +103,7 @@ "Žádné obrázky ani videa nejsou k dispozici." "Příspěvky" "Zpřístupnit offline" - "Obnovit" + "Aktualizovat" "Hotovo" "%1$d z %2$d položek:" "Název" -- GitLab From c46beb501f519fab926141902a5b8e49cdb7f62f Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Tue, 15 May 2012 15:29:36 -0700 Subject: [PATCH 018/763] Import translations. DO NOT MERGE Change-Id: Ie14d3f0aef0ada917b7de6b4176d442565ae9b3a --- res/values-ko/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values-ko/strings.xml b/res/values-ko/strings.xml index bfff577d6..b15bb4e4f 100644 --- a/res/values-ko/strings.xml +++ b/res/values-ko/strings.xml @@ -155,7 +155,7 @@ "이미지 선택" "슬라이드쇼" "앨범" - "횟수" + "시간" "위치" "사용자" "태그" -- GitLab From 9d0a432133dce593a9edf38a04077559c93583e4 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Wed, 16 May 2012 10:41:21 -0700 Subject: [PATCH 019/763] Import translations. DO NOT MERGE Change-Id: I7ce56d9778b2e489bc152e60d5ea9b526701de76 --- res/values-af/strings.xml | 6 ++++-- res/values-am/strings.xml | 6 ++++-- res/values-ar/strings.xml | 6 ++++-- res/values-be/strings.xml | 6 ++++-- res/values-bg/strings.xml | 6 ++++-- res/values-ca/strings.xml | 6 ++++-- res/values-cs/strings.xml | 6 ++++-- res/values-da/strings.xml | 6 ++++-- res/values-de/strings.xml | 6 ++++-- res/values-el/strings.xml | 6 ++++-- res/values-en-rGB/strings.xml | 6 ++++-- res/values-es-rUS/strings.xml | 6 ++++-- res/values-es/strings.xml | 6 ++++-- res/values-et/strings.xml | 6 ++++-- res/values-fa/strings.xml | 6 ++++-- res/values-fi/strings.xml | 6 ++++-- res/values-fr/strings.xml | 6 ++++-- res/values-hi/strings.xml | 6 ++++-- res/values-hr/strings.xml | 6 ++++-- res/values-hu/strings.xml | 6 ++++-- res/values-in/strings.xml | 6 ++++-- res/values-it/strings.xml | 6 ++++-- res/values-iw/strings.xml | 6 ++++-- res/values-ja/strings.xml | 6 ++++-- res/values-ko/strings.xml | 6 ++++-- res/values-lt/strings.xml | 6 ++++-- res/values-lv/strings.xml | 6 ++++-- res/values-ms/strings.xml | 6 ++++-- res/values-nb/strings.xml | 6 ++++-- res/values-nl/strings.xml | 6 ++++-- res/values-pl/strings.xml | 6 ++++-- res/values-pt-rPT/strings.xml | 6 ++++-- res/values-pt/strings.xml | 6 ++++-- res/values-rm/strings.xml | 6 +++--- res/values-ro/strings.xml | 6 ++++-- res/values-ru/strings.xml | 6 ++++-- res/values-sk/strings.xml | 6 ++++-- res/values-sl/strings.xml | 6 ++++-- res/values-sr/strings.xml | 6 ++++-- res/values-sv/strings.xml | 6 ++++-- res/values-sw/strings.xml | 6 ++++-- res/values-th/strings.xml | 6 ++++-- res/values-tl/strings.xml | 6 ++++-- res/values-tr/strings.xml | 6 ++++-- res/values-uk/strings.xml | 6 ++++-- res/values-vi/strings.xml | 6 ++++-- res/values-zh-rCN/strings.xml | 6 ++++-- res/values-zh-rTW/strings.xml | 6 ++++-- res/values-zu/strings.xml | 6 ++++-- 49 files changed, 195 insertions(+), 99 deletions(-) diff --git a/res/values-af/strings.xml b/res/values-af/strings.xml index bf8a81ad4..801c87ea4 100644 --- a/res/values-af/strings.xml +++ b/res/values-af/strings.xml @@ -32,7 +32,8 @@ "Kon nie die prent laai nie" "Geen kleinkiekie nie" "Begin van voor af" - "OK" + + "Raak aan \'n gesig om te begin." "Stoor tans prent…" "Kon nie gesnoeide prent stoor nie." @@ -46,7 +47,8 @@ "Stel tans muurpapier in..." "Muurpapier" "Vee uit" - "Bevestig uitvee?" + + "Bevestig" "Kanselleer" "Deling" diff --git a/res/values-am/strings.xml b/res/values-am/strings.xml index 1bae5884d..f1be67aee 100644 --- a/res/values-am/strings.xml +++ b/res/values-am/strings.xml @@ -32,7 +32,8 @@ "ምስሉን መጫን አልተቻለም" "ምንም ጥፍርአከል የለም" "እንደገና ጀምር" - "እሺ" + + "ለመጀመር ፊት ንካ::" "ምስል በማስቀመጥ ላይ..." "የተቀመቀመውን ምስል ማስቀመጥ አልተቻለም::" @@ -46,7 +47,8 @@ "ልጣፍ በማቀናበር ላይ...." "ልጣፍ" "ሰርዝ" - "ስረዛ ይረጋገጥ?" + + "አረጋግጥ" "ይቅር" "አጋራ" diff --git a/res/values-ar/strings.xml b/res/values-ar/strings.xml index 17609f7d2..c0080a621 100644 --- a/res/values-ar/strings.xml +++ b/res/values-ar/strings.xml @@ -32,7 +32,8 @@ "تعذر تحميل الصورة" "بلا صورة مصغرة" "البدء من جديد" - "موافق" + + "المس وجهًا للبدء." "جارٍ حفظ الصورة..." "تعذر حفظ الصورة التي تم اقتصاصها." @@ -46,7 +47,8 @@ "جارٍ تعيين الخلفية..." "الخلفية" "حذف" - "هل تريد تأكيد الحذف؟" + + "تأكيد" "إلغاء" "مشاركة" diff --git a/res/values-be/strings.xml b/res/values-be/strings.xml index 9c636fb73..e42d884b5 100644 --- a/res/values-be/strings.xml +++ b/res/values-be/strings.xml @@ -32,7 +32,8 @@ "Не атрымалася загрузіць малюнак" "Няма паменшанай выявы" "Пачаць зноў" - "ОК" + + "Дакранiцеся да твару, каб пачаць." "Захаванне выявы..." "Немагчыма захаваць абрэзаную выяву." @@ -46,7 +47,8 @@ "Усталяванне шпалер..." "Шпалеры" "Выдаліць" - "Пацвердзіць выдаленне?" + + "Пацвердзіць" "Адмяніць" "Апублікаваць" diff --git a/res/values-bg/strings.xml b/res/values-bg/strings.xml index 10e7ca0f8..8f4600074 100644 --- a/res/values-bg/strings.xml +++ b/res/values-bg/strings.xml @@ -32,7 +32,8 @@ "Изображението не можа да бъде заредено" "Няма миниизображение" "Стартиране отначало" - "OK" + + "Докоснете лице за начало." "Снимката се запазва..." "Подрязаното изобр. не можа да се запази." @@ -46,7 +47,8 @@ "Тапетът се задава..." "Тапет" "Изтриване" - "Да се потвърди ли изтриването?" + + "Потвърждаване" "Отказ" "Споделяне" diff --git a/res/values-ca/strings.xml b/res/values-ca/strings.xml index e8a98683c..d43638d1e 100644 --- a/res/values-ca/strings.xml +++ b/res/values-ca/strings.xml @@ -32,7 +32,8 @@ "No s\'ha pogut carregar la imatge" "No hi ha cap miniatura" "Torna a començar" - "D\'acord" + + "Toca una cara per començar." "S\'està desant la imatge..." "No s\'ha pogut desar la imatge retallada." @@ -46,7 +47,8 @@ "S\'està establint el fons de pantalla..." "Fons de pantalla" "Suprimeix" - "Vols confirmar la supressió?" + + "Confirma" "Cancel·la" "Comparteix" diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml index 1d2c68885..426cddb8a 100644 --- a/res/values-cs/strings.xml +++ b/res/values-cs/strings.xml @@ -32,7 +32,8 @@ "Obrázek nelze načíst" "Miniatura není dostupná" "Začít znovu" - "OK" + + "Začněte klepnutím na obličej." "Ukládání fotografie..." "Oříznutý obrázek nelze uložit." @@ -46,7 +47,8 @@ "Nastavování tapety..." "Tapeta" "Smazat" - "Potvrdit smazání?" + + "Potvrdit" "Zrušit" "Sdílet" diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml index d3efc0dd9..93d2464f7 100644 --- a/res/values-da/strings.xml +++ b/res/values-da/strings.xml @@ -32,7 +32,8 @@ "Billedet kunne ikke indlæses" "Ingen miniature" "Start igen" - "OK" + + "Tryk på et ansigt for at begynde." "Gemmer billede..." "Det beskårne billede kunne ikke gemmes." @@ -46,7 +47,8 @@ "Angiver baggrund..." "Tapet" "Slet" - "Vil du bekræfte sletningen?" + + "Bekræft" "Annuller" "Del" diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index b0eb2135d..096b995f0 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -32,7 +32,8 @@ "Bild konnte nicht geladen werden." "Keine Miniaturansicht" "Starten" - "OK" + + "Zum Beginnen auf ein Gesicht tippen" "Bild wird gespeichert..." "Zugeschnittenes Bild nicht gespeichert" @@ -46,7 +47,8 @@ "Hintergrund wird festgelegt..." "Hintergrund" "Löschen" - "Löschvorgang bestätigen?" + + "Bestätigen" "Abbrechen" "Teilen" diff --git a/res/values-el/strings.xml b/res/values-el/strings.xml index 951d98606..72eb17097 100644 --- a/res/values-el/strings.xml +++ b/res/values-el/strings.xml @@ -32,7 +32,8 @@ "Δεν ήταν δυνατή η φόρτωση της εικόνας" "Δεν υπάρχει μικρογραφία" "Έναρξη από την αρχή" - "OK" + + "Αγγίξτε κάποιο πρόσωπο για να ξεκινήσετε." "Αποθήκευση εικόνας..." "Αδυναμία αποθήκευσης αποκομμένης εικόνας" @@ -46,7 +47,8 @@ "Ορισμός ταπετσαρίας..." "Ταπετσαρία" "Διαγραφή" - "Επιβεβαίωση διαγραφής" + + "Επιβεβαίωση" "Ακύρωση" "Κοινή χρήση" diff --git a/res/values-en-rGB/strings.xml b/res/values-en-rGB/strings.xml index fad74c10e..7792b3a54 100644 --- a/res/values-en-rGB/strings.xml +++ b/res/values-en-rGB/strings.xml @@ -32,7 +32,8 @@ "Couldn\'t load the image" "No thumbnail" "Start again" - "OK" + + "Touch a face to begin." "Saving picture…" "Couldn\'t save cropped image." @@ -46,7 +47,8 @@ "Setting wallpaper..." "Wallpaper" "Delete" - "Confirm deletion?" + + "Confirm" "Cancel" "Share" diff --git a/res/values-es-rUS/strings.xml b/res/values-es-rUS/strings.xml index 61cf8fd2b..48f7fc20a 100644 --- a/res/values-es-rUS/strings.xml +++ b/res/values-es-rUS/strings.xml @@ -32,7 +32,8 @@ "No se pudo cargar la imagen." "Sin miniatura" "Empezar de nuevo" - "Aceptar" + + "Toca una cara para comenzar." "Guardando imagen..." "No se pudo guardar la imagen recortada." @@ -46,7 +47,8 @@ "Estableciendo fondo de pantalla..." "Papel tapiz" "Eliminar" - "¿Quieres confirmar la eliminación?" + + "Confirmar" "Cancelar" "Compartir" diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index 68e50c117..dc03d5245 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -32,7 +32,8 @@ "No se puede cargar la imagen." "No hay miniaturas." "Volver a reproducir" - "Aceptar" + + "Toca una cara para comenzar." "Guardando imagen..." "Error al guardar la imagen recortada" @@ -46,7 +47,8 @@ "Estableciendo fondo de pantalla..." "Fondo de pantalla" "Borrar" - "¿Confirmar eliminación?" + + "Confirmar" "Cancelar" "Compartir" diff --git a/res/values-et/strings.xml b/res/values-et/strings.xml index bcb030704..6e12144b0 100644 --- a/res/values-et/strings.xml +++ b/res/values-et/strings.xml @@ -32,7 +32,8 @@ "Kujutist ei õnnestunud laadida" "Pisipilti pole" "Alusta uuesti" - "OK" + + "Alustamiseks näo puudutamine." "Pildi salvestamine ..." "Kärbitud kujutist ei saanud salvestada." @@ -46,7 +47,8 @@ "Taustapildi määramine ..." "Taustapilt" "Kustuta" - "Kas kinnitada kustutamine?" + + "Kinnitamine" "Tühista" "Jaga" diff --git a/res/values-fa/strings.xml b/res/values-fa/strings.xml index 8b74110bb..d44b6606a 100644 --- a/res/values-fa/strings.xml +++ b/res/values-fa/strings.xml @@ -32,7 +32,8 @@ "تصویر بارگیری نمی‌شود" "تصویر کوچکی وجود ندارد" "شروع مجدد" - "تائید" + + "برای شروع یک چهره را لمس کنید." "در حال ذخیره عکس..." "ذخیره تصویر برش‌خورده امکان‌پذیر نیست." @@ -46,7 +47,8 @@ "تنظیم تصویر زمینه..." "تصویر زمینه" "حذف" - "حذف را تایید می‌کنید؟" + + "تأیید" "لغو" "اشتراک گذاری" diff --git a/res/values-fi/strings.xml b/res/values-fi/strings.xml index febd5d19d..ff0fab83b 100644 --- a/res/values-fi/strings.xml +++ b/res/values-fi/strings.xml @@ -32,7 +32,8 @@ "Kuvaa ei voi ladata" "Ei pikkukuvaa" "Aloita alusta" - "OK" + + "Aloita koskettamalla kasvoja." "Tallennetaan kuvaa…" "Rajattua kuvaa ei voitu tallentaa." @@ -46,7 +47,8 @@ "Asetetaan taustakuvaa..." "taustakuvaksi" "Poista" - "Vahvista poistaminen?" + + "Vahvista" "Peruuta" "Jaa" diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index 431683006..6dd35f7ae 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -32,7 +32,8 @@ "Impossible de charger l\'image." "Aucune vignette" "Démarrer" - "OK" + + "Appuyer sur un visage pour commencer" "Enregistrement de l\'image" "Impossible d\'enregistrer l\'image rognée." @@ -46,7 +47,8 @@ "Définition du fond d\'écran…" "Fond d\'écran" "Supprimer" - "Confirmer la suppression ?" + + "Confirmer" "Annuler" "Partager" diff --git a/res/values-hi/strings.xml b/res/values-hi/strings.xml index baf920653..2711cf4b4 100644 --- a/res/values-hi/strings.xml +++ b/res/values-hi/strings.xml @@ -32,7 +32,8 @@ "छवि लोड नहीं हो सकी" "कोई थंबनेल नहीं" "पुन: प्रारंभ करें" - "ठीक" + + "शुरू करने के लिए कोई चेहरा स्‍पर्श करें." "चित्र सहेज रहा है…" "काट-छांट की गई छवि को नहीं सहेज सका." @@ -46,7 +47,8 @@ "वॉलपेपर सेट कर रहा है..." "वॉलपेपर" "हटाएं" - "हटाने की पुष्‍टि करें?" + + "पुष्टि करें" "रद्द करें" "शेयर करें" diff --git a/res/values-hr/strings.xml b/res/values-hr/strings.xml index eae3b03ad..e42998b6c 100644 --- a/res/values-hr/strings.xml +++ b/res/values-hr/strings.xml @@ -32,7 +32,8 @@ "Nije moguće učitati sliku" "Nema minijatura" "Počni ispočetka" - "U redu" + + "Dodirnite lice za početak." "Spremanje slike..." "Nije moguće spremiti obrezanu sliku." @@ -46,7 +47,8 @@ "Postavljanje pozadinske slike…" "Pozadinska slika" "Izbriši" - "Potvrditi brisanje?" + + "Potvrdi" "Odustani" "Podijeli" diff --git a/res/values-hu/strings.xml b/res/values-hu/strings.xml index 273c1b7d2..031be83d8 100644 --- a/res/values-hu/strings.xml +++ b/res/values-hu/strings.xml @@ -32,7 +32,8 @@ "Nem sikerült betölteni a képet" "Nincs indexkép" "Újrakezdés" - "OK" + + "Érintsen meg egy arcot a kezdéshez." "Kép mentése..." "Nem lehet menteni a vágott képet." @@ -46,7 +47,8 @@ "Háttérkép beállítása..." "Háttérkép" "Törlés" - "Megerősíti a törlést?" + + "Megerősítés" "Mégse" "Megosztás" diff --git a/res/values-in/strings.xml b/res/values-in/strings.xml index 136cdc5fd..882861c1c 100644 --- a/res/values-in/strings.xml +++ b/res/values-in/strings.xml @@ -32,7 +32,8 @@ "Tidak dapat memuat gambar" "Tidak ada gambar mini" "Memulai" - "Oke" + + "Sentuh wajah untuk memulai." "Menyimpan gambar…" "Tak dapat menyimpan gambar yg dipangkas." @@ -46,7 +47,8 @@ "Menyetel wallpaper..." "Wallpaper" "Hapus" - "Konfirmasi penghapusan?" + + "Konfirmasi" "Batal" "Bagikan" diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index c19b059ae..33fd37cb2 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -32,7 +32,8 @@ "Impossibile caricare l\'immagine" "Nessuna miniatura" "Ricomincia" - "OK" + + "Tocca un viso per iniziare." "Salvataggio foto..." "Impossibile salvare immagine ritagliata." @@ -46,7 +47,8 @@ "Impostazione sfondo..." "Sfondo" "Elimina" - "Confermi l\'eliminazione?" + + "Conferma" "Annulla" "Condividi" diff --git a/res/values-iw/strings.xml b/res/values-iw/strings.xml index ae545511b..05811a60b 100644 --- a/res/values-iw/strings.xml +++ b/res/values-iw/strings.xml @@ -32,7 +32,8 @@ "לא היתה אפשרות לטעון את התמונה" "ללא תמונה ממוזערת" "התחל מחדש" - "אישור" + + "גע בפנים כלשהם כדי להתחיל." "שומר תמונה..." "לא ניתן לשמור את התמונה החתוכה." @@ -46,7 +47,8 @@ "מגדיר טפט..." "טפט" "מחק" - "האם לאשר מחיקה?" + + "אשר" "ביטול" "שיתוף" diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml index 832d31cf1..01d5ca2a9 100644 --- a/res/values-ja/strings.xml +++ b/res/values-ja/strings.xml @@ -32,7 +32,8 @@ "画像を読み込めませんでした" "サムネイルなし" "最初から再生" - "OK" + + "始めるには顔をタップします。" "写真を保存中…" "トリミングした画像を保存できません。" @@ -46,7 +47,8 @@ "壁紙を設定しています..." "壁紙" "削除" - "削除してもよろしいですか?" + + "確認" "キャンセル" "共有" diff --git a/res/values-ko/strings.xml b/res/values-ko/strings.xml index b15bb4e4f..c6d9bd6cd 100644 --- a/res/values-ko/strings.xml +++ b/res/values-ko/strings.xml @@ -32,7 +32,8 @@ "이미지를 로드할 수 없습니다." "미리보기 이미지 없음" "처음부터 보기" - "확인" + + "시작하려면 얼굴을 터치하세요." "사진 저장 중..." "잘린 이미지를 저장하지 못했습니다." @@ -46,7 +47,8 @@ "배경화면을 설정하는 중..." "배경화면" "삭제" - "삭제하시겠습니까?" + + "확인" "취소" "공유" diff --git a/res/values-lt/strings.xml b/res/values-lt/strings.xml index b7323f19f..01ca1d30d 100644 --- a/res/values-lt/strings.xml +++ b/res/values-lt/strings.xml @@ -32,7 +32,8 @@ "Nepavyko įkelti vaizdo" "Nėra miniatiūros" "Pradėti iš naujo" - "Gerai" + + "Jei norite pradėti, palieskite veidą." "Išsaugomas paveikslėlis..." "Nepavyko išsaugoti apkarpyto vaizdo." @@ -46,7 +47,8 @@ "Nustatomas darbalaukio fonas…" "Darbalaukio fonas" "Ištrinti" - "Patvirtinti ištrynimą?" + + "Patvirtinti" "Atšaukti" "Bendrinti" diff --git a/res/values-lv/strings.xml b/res/values-lv/strings.xml index bbfc72d7d..68332b485 100644 --- a/res/values-lv/strings.xml +++ b/res/values-lv/strings.xml @@ -32,7 +32,8 @@ "Nevarēja ielādēt attēlu." "Nav sīktēla." "Sākt vēlreiz" - "Labi" + + "Pieskarieties sejai, lai sāktu." "Notiek attēla saglabāšana..." "Nevarēja saglabāt izgriezto attēlu." @@ -46,7 +47,8 @@ "Notiek fona tapetes iestatīšana..." "Fona tapete" "Dzēst" - "Vai apstiprināt dzēšanu?" + + "Apstiprināt" "Atcelt" "Dalies" diff --git a/res/values-ms/strings.xml b/res/values-ms/strings.xml index 0ee0ffb76..76e31c180 100644 --- a/res/values-ms/strings.xml +++ b/res/values-ms/strings.xml @@ -32,7 +32,8 @@ "Tidak dapat memuatkan imej" "Tiada lakaran kenit" "Mainkan semula dari mula" - "OK" + + "Sentuh muka untuk bermula." "Menyimpan gambar..." "Tidak dapat menyimpan imej yang dipangkas." @@ -46,7 +47,8 @@ "Menetapkan kertas dinding…" "Kertas dinding" "Padam" - "Sahkan pemadaman?" + + "Sahkan" "Batal" "Kongsi" diff --git a/res/values-nb/strings.xml b/res/values-nb/strings.xml index d7368ac1e..4b2bee739 100644 --- a/res/values-nb/strings.xml +++ b/res/values-nb/strings.xml @@ -32,7 +32,8 @@ "Kunne ikke laste inn bildet" "Ingen miniatyrbilder" "Begynn på nytt" - "OK" + + "Berør et ansikt for å begynne." "Lagrer bilde ..." "Kan ikke lagre det beskårede bildet." @@ -46,7 +47,8 @@ "Angir bakgrunn …" "Bakgrunnsbilde" "Slett" - "Bekrefter du slettingen?" + + "Bekreft" "Avbryt" "Del" diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml index 576fdf4dc..40e0e2e3b 100644 --- a/res/values-nl/strings.xml +++ b/res/values-nl/strings.xml @@ -32,7 +32,8 @@ "Kan de afbeelding niet laden" "Geen miniatuur" "Opnieuw starten" - "OK" + + "Raak een gezicht aan om te beginnen." "Foto opslaan..." "Kan bijgesneden afbeelding niet opslaan." @@ -46,7 +47,8 @@ "Achtergrond instellen..." "Achtergrond" "Verwijderen" - "Verwijdering bevestigen?" + + "Bevestigen" "Annuleren" "Delen" diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml index a4d637bcf..c9040b15e 100644 --- a/res/values-pl/strings.xml +++ b/res/values-pl/strings.xml @@ -32,7 +32,8 @@ "Nie można wczytać zdjęcia" "Brak miniatury" "Rozpocznij" - "OK" + + "Dotknij twarzy, aby rozpocząć." "Zapisywanie zdjęcia…" "Nie można zapisać przyciętego obrazu." @@ -46,7 +47,8 @@ "Ustawianie tapety…" "Tapeta" "Usuń" - "Potwierdzasz usunięcie?" + + "Potwierdź" "Anuluj" "Udostępnij" diff --git a/res/values-pt-rPT/strings.xml b/res/values-pt-rPT/strings.xml index a3d4eeee7..c3a377aef 100644 --- a/res/values-pt-rPT/strings.xml +++ b/res/values-pt-rPT/strings.xml @@ -32,7 +32,8 @@ "Não foi possível carregar a imagem" "Sem miniatura" "Recomeçar" - "OK" + + "Toque num rosto para começar." "A guardar imagem..." "Impossível guardar imagem recortada." @@ -46,7 +47,8 @@ "A definir imagem de fundo…" "Imagem de fundo" "Eliminar" - "Confirmar eliminação?" + + "Confirmar" "Cancelar" "Partilhar" diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml index 6fc6378ec..e02dfac51 100644 --- a/res/values-pt/strings.xml +++ b/res/values-pt/strings.xml @@ -32,7 +32,8 @@ "Não foi possível carregar a imagem" "Sem miniatura" "Reiniciar" - "OK" + + "Toque em um rosto para começar." "Salvando imagem…" "Não é possível salvar a imagem cortada." @@ -46,7 +47,8 @@ "Definindo plano de fundo..." "Plano de fundo" "Excluir" - "Confirmar exclusão?" + + "Confirmar" "Cancelar" "Compartilhar" diff --git a/res/values-rm/strings.xml b/res/values-rm/strings.xml index d5dda4a84..5ee7c7649 100644 --- a/res/values-rm/strings.xml +++ b/res/values-rm/strings.xml @@ -39,7 +39,7 @@ "Cumenzar" - + @@ -62,8 +62,8 @@ "Culissa" "Stizzar" - - + + "Interrumper" diff --git a/res/values-ro/strings.xml b/res/values-ro/strings.xml index aa3d15154..16d8721e0 100644 --- a/res/values-ro/strings.xml +++ b/res/values-ro/strings.xml @@ -32,7 +32,8 @@ "Nu s-a putut încărca imaginea" "Nu există o miniatură" "Începeţi din nou" - "OK" + + "Atingeţi o faţă pentru a începe." "Se salvează fotografia..." "Imaginea decupată nu s-a putut salva." @@ -46,7 +47,8 @@ "Se setează imaginea de fundal..." "Imagine de fundal" "Ştergeţi" - "Confirmaţi ştergerea?" + + "Confirmaţi" "Anulaţi" "Distribuiţi" diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index e6148cf83..142567764 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -32,7 +32,8 @@ "Не удалось загрузить изображение" "Нет уменьшенного изображения" "Начать с начала" - "ОК" + + "Нажмите на лицо, чтобы начать." "Сохранение картинки..." "Изображение не сохранено." @@ -46,7 +47,8 @@ "Установка обоев..." "Обои" "Удалить" - "Удалить?" + + "Подтвердить" "Отмена" "Отправить" diff --git a/res/values-sk/strings.xml b/res/values-sk/strings.xml index 9bc625ff5..3322b911d 100644 --- a/res/values-sk/strings.xml +++ b/res/values-sk/strings.xml @@ -32,7 +32,8 @@ "Obrázok sa nepodarilo načítať" "Žiadne miniatúry" "Začať odznova" - "OK" + + "Začnite dotknutím sa tváre." "Prebieha ukladanie fotografie..." "Orezaný obrázok sa nepodarilo uložiť." @@ -46,7 +47,8 @@ "Prebieha nastavenie tapety..." "Tapeta" "Odstrániť" - "Potvrdiť odstránenie?" + + "Potvrdiť" "Zrušiť" "Zdieľať" diff --git a/res/values-sl/strings.xml b/res/values-sl/strings.xml index 4557a4146..a04146077 100644 --- a/res/values-sl/strings.xml +++ b/res/values-sl/strings.xml @@ -32,7 +32,8 @@ "Slike ni bilo mogoče naložiti" "Ni sličice" "Začni znova" - "V redu" + + "Dotaknite se obraza, če želite začeti." "Shranjevanje slike ..." "Obrezane slike ni bilo mogoče shraniti." @@ -46,7 +47,8 @@ "Nastavljanje slike za ozadje ..." "Slika za ozadje" "Izbriši" - "Potrjujete brisanje?" + + "Potrdi" "Prekliči" "Skupna raba" diff --git a/res/values-sr/strings.xml b/res/values-sr/strings.xml index aadbf7a86..7e69a7c1e 100644 --- a/res/values-sr/strings.xml +++ b/res/values-sr/strings.xml @@ -32,7 +32,8 @@ "Није могуће учитати слику" "Нема сличице" "Започни поново" - "Потврди" + + "Додирните неко лице за почетак." "Чување слике…" "Није могуће сачувати опсечену слику." @@ -46,7 +47,8 @@ "Подешавање позадине..." "Позадина" "Избриши" - "Желите ли да потврдите брисање?" + + "Потврди" "Откажи" "Дели" diff --git a/res/values-sv/strings.xml b/res/values-sv/strings.xml index 742ac58d3..33c1ae4ac 100644 --- a/res/values-sv/strings.xml +++ b/res/values-sv/strings.xml @@ -32,7 +32,8 @@ "Det gick inte att läsa in bilden" "Ingen miniatyrbild" "Börja om" - "OK" + + "Tryck på ett ansikte när du vill börja." "Sparar bild…" "Det gick inte att spara den beskurna bilden." @@ -46,7 +47,8 @@ "Bakgrund ställs in ..." "Bakgrund" "Ta bort" - "Bekräfta borttagning?" + + "Bekräfta" "Avbryt" "Dela" diff --git a/res/values-sw/strings.xml b/res/values-sw/strings.xml index ed8117e04..d8b90fdf8 100644 --- a/res/values-sw/strings.xml +++ b/res/values-sw/strings.xml @@ -32,7 +32,8 @@ "Haikuweza kupakia picha" "Hakuna kijipicha" "Anza tena" - "Sawa" + + "Gusa sura ili kuanza." "Inahifadhi picha…" "Haiwezi kuhifadhi picha iliyopogolewa." @@ -46,7 +47,8 @@ "Inaweka karatasi ya ukuta..." "Mandhari" "Futa" - "Thibitisha ufutaji?" + + "Thibitisha" "Ghairi" "Shiriki" diff --git a/res/values-th/strings.xml b/res/values-th/strings.xml index 7ed0836b5..ad7079ec6 100644 --- a/res/values-th/strings.xml +++ b/res/values-th/strings.xml @@ -32,7 +32,8 @@ "ไม่สามารถโหลดภาพ" "ไม่มีภาพขนาดย่อ" "เริ่มต้นใหม่" - "ตกลง" + + "แตะใบหน้าเพื่อเริ่มต้น" "กำลังบันทึกภาพ..." "ไม่สามารถบันทึกภาพที่ตัดได้" @@ -46,7 +47,8 @@ "กำลังตั้งค่าวอลเปเปอร์..." "วอลเปเปอร์" "ลบ" - "ยืนยันการลบหรือไม่" + + "ยืนยัน" "ยกเลิก" "แบ่งปัน" diff --git a/res/values-tl/strings.xml b/res/values-tl/strings.xml index 66de41bd1..f8be4ba58 100644 --- a/res/values-tl/strings.xml +++ b/res/values-tl/strings.xml @@ -32,7 +32,8 @@ "Hindi ma-load ang larawan" "Walang thumbnail" "Magsimula na" - "OK" + + "Pumindot ng mukha upang magsimula." "Nagse-save ng larawan..." "Hindi mai-save ang na-crop na larawan." @@ -46,7 +47,8 @@ "Itinatakda ang wallpaper…" "Wallpaper" "Tanggalin" - "Kumpirmahin ang pagtanggal?" + + "Kumpirmahin" "Kanselahin" "Ibahagi" diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml index 8b4eb5ea2..810ed8968 100644 --- a/res/values-tr/strings.xml +++ b/res/values-tr/strings.xml @@ -32,7 +32,8 @@ "Resim yüklenemedi" "Küçük resim yok" "Başlat" - "Tamam" + + "Başlamak için bir yüze dokunun." "Resim kaydediliyor..." "Kırpılmış resim kaydedilemedi." @@ -46,7 +47,8 @@ "Duvar kağıdı ayarlanıyor..." "Duvar Kağıdı" "Sil" - "Silme işlemini onaylıyor musunuz?" + + "Onayla" "İptal" "Paylaş" diff --git a/res/values-uk/strings.xml b/res/values-uk/strings.xml index 6846c9ed8..3c905cf2c 100644 --- a/res/values-uk/strings.xml +++ b/res/values-uk/strings.xml @@ -32,7 +32,8 @@ "Не вдалося завантажити зображення" "Немає ескізу" "Почати знову" - "OK" + + "Торкніться обличчя, щоб почати." "Зберіг-ня фото…" "Не вдалося зберегти обрізане зображення." @@ -46,7 +47,8 @@ "Встановлення фонового малюнка..." "Фоновий мал." "Видалити" - "Підтвердити видалення?" + + "Підтвердити" "Скасувати" "Надісл." diff --git a/res/values-vi/strings.xml b/res/values-vi/strings.xml index bbcc6ac7e..941ae20c1 100644 --- a/res/values-vi/strings.xml +++ b/res/values-vi/strings.xml @@ -32,7 +32,8 @@ "Không thể tải hình ảnh" "Không có hình thu nhỏ" "Bắt đầu lại" - "OK" + + "Chạm vào một khuôn mặt để bắt đầu." "Đang lưu ảnh…" "Không thể lưu hình ảnh được cắt." @@ -46,7 +47,8 @@ "Đang đặt hình nền..." "Hình nền" "Xóa" - "Xác nhận xóa?" + + "Xác nhận" "Hủy" "Chia sẻ" diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index 63b9b99d7..af34d2849 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -32,7 +32,8 @@ "无法加载此图片" "无缩略图" "重新开始" - "确定" + + "触摸一张脸开始裁剪。" "正在保存照片..." "无法保存经过裁剪的图片。" @@ -46,7 +47,8 @@ "正在设置壁纸..." "壁纸" "删除" - "确认删除?" + + "确认" "取消" "分享" diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml index fcb1be02d..97b6b3550 100644 --- a/res/values-zh-rTW/strings.xml +++ b/res/values-zh-rTW/strings.xml @@ -32,7 +32,8 @@ "無法載入圖片" "無縮圖" "重新開始" - "確定" + + "輕觸臉孔即可開始。" "正在儲存相片..." "無法儲存裁剪的圖片。" @@ -46,7 +47,8 @@ "正在設定桌布..." "桌布" "刪除" - "確認刪除?" + + "確認" "取消" "分享" diff --git a/res/values-zu/strings.xml b/res/values-zu/strings.xml index 641100c8c..c59cfa8c0 100644 --- a/res/values-zu/strings.xml +++ b/res/values-zu/strings.xml @@ -32,7 +32,8 @@ "Ayikwazanga ukulayisha umfanekiso" "Asikho isithoombe esincane" "Qala phansi" - "Kulungile" + + "Cindezela ubuso ukuze uqale." "Ilondoloza isithombe..." "Yehlulekile ukulondoloza umfanekiso onqampuniwe." @@ -46,7 +47,8 @@ "Isetha iphephadonga..." "Iphephadonga" "Susa" - "Qinisekisa ukususa?" + + "Qinisekisa" "Khansela" "Yabelana" -- GitLab From 16767eb1e6b1f42338efdd7fa49c28691a380bee Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Fri, 25 May 2012 11:26:21 -0700 Subject: [PATCH 020/763] Import translations. DO NOT MERGE Change-Id: Ie3efea4133d63aac5b1df887925b914b7107859d --- res/values-af/strings.xml | 13 ++++++++----- res/values-am/strings.xml | 13 ++++++++----- res/values-ar/strings.xml | 13 ++++++++----- res/values-be/strings.xml | 13 ++++++++----- res/values-bg/strings.xml | 13 ++++++++----- res/values-ca/strings.xml | 13 ++++++++----- res/values-cs/strings.xml | 31 +++++++++++++++++-------------- res/values-da/strings.xml | 13 ++++++++----- res/values-de/strings.xml | 13 ++++++++----- res/values-el/strings.xml | 13 ++++++++----- res/values-en-rGB/strings.xml | 13 ++++++++----- res/values-es-rUS/strings.xml | 13 ++++++++----- res/values-es/strings.xml | 13 ++++++++----- res/values-et/strings.xml | 13 ++++++++----- res/values-fa/strings.xml | 13 ++++++++----- res/values-fi/strings.xml | 13 ++++++++----- res/values-fr/strings.xml | 13 ++++++++----- res/values-hi/strings.xml | 13 ++++++++----- res/values-hr/strings.xml | 13 ++++++++----- res/values-hu/strings.xml | 13 ++++++++----- res/values-in/strings.xml | 13 ++++++++----- res/values-it/strings.xml | 13 ++++++++----- res/values-iw/strings.xml | 13 ++++++++----- res/values-ja/strings.xml | 13 ++++++++----- res/values-ko/strings.xml | 13 ++++++++----- res/values-lt/strings.xml | 13 ++++++++----- res/values-lv/strings.xml | 13 ++++++++----- res/values-ms/strings.xml | 13 ++++++++----- res/values-nb/strings.xml | 15 +++++++++------ res/values-nl/strings.xml | 13 ++++++++----- res/values-pl/strings.xml | 15 +++++++++------ res/values-pt-rPT/strings.xml | 13 ++++++++----- res/values-pt/strings.xml | 15 +++++++++------ res/values-rm/strings.xml | 6 ++++-- res/values-ro/strings.xml | 13 ++++++++----- res/values-ru/strings.xml | 13 ++++++++----- res/values-sk/strings.xml | 13 ++++++++----- res/values-sl/strings.xml | 13 ++++++++----- res/values-sr/strings.xml | 13 ++++++++----- res/values-sv/strings.xml | 13 ++++++++----- res/values-sw/strings.xml | 13 ++++++++----- res/values-th/strings.xml | 13 ++++++++----- res/values-tl/strings.xml | 13 ++++++++----- res/values-tr/strings.xml | 13 ++++++++----- res/values-uk/strings.xml | 13 ++++++++----- res/values-vi/strings.xml | 13 ++++++++----- res/values-zh-rCN/strings.xml | 19 +++++++++++-------- res/values-zh-rTW/strings.xml | 13 ++++++++----- res/values-zu/strings.xml | 13 ++++++++----- 49 files changed, 403 insertions(+), 257 deletions(-) diff --git a/res/values-af/strings.xml b/res/values-af/strings.xml index 801c87ea4..315bdcc01 100644 --- a/res/values-af/strings.xml +++ b/res/values-af/strings.xml @@ -32,8 +32,8 @@ "Kon nie die prent laai nie" "Geen kleinkiekie nie" "Begin van voor af" - - + "OK" + "OK" "Raak aan \'n gesig om te begin." "Stoor tans prent…" "Kon nie gesnoeide prent stoor nie." @@ -44,11 +44,15 @@ "Kies album" "Kies groep" "Stel prent as" + + "Stel tans muurpapier in..." "Muurpapier" "Vee uit" - - + + "Vee gekose item uit?" + "Vee gekose items uit?" + "Bevestig" "Kanselleer" "Deling" @@ -94,7 +98,6 @@ "Geen ligging nie" "Sommige liggings kon nie geïdentifiseer word nie weens netwerkprobleme." "Kon nie die foto\'s in hierdie album aflaai nie. Probeer later weer." - "Kon nie die lys van albums aflaai nie. Probeer later weer." "Net prente" "Net video\'s" "Prente en video\'s" diff --git a/res/values-am/strings.xml b/res/values-am/strings.xml index f1be67aee..e62624c68 100644 --- a/res/values-am/strings.xml +++ b/res/values-am/strings.xml @@ -32,8 +32,8 @@ "ምስሉን መጫን አልተቻለም" "ምንም ጥፍርአከል የለም" "እንደገና ጀምር" - - + "እሺ" + "እሺ" "ለመጀመር ፊት ንካ::" "ምስል በማስቀመጥ ላይ..." "የተቀመቀመውን ምስል ማስቀመጥ አልተቻለም::" @@ -44,11 +44,15 @@ "አልበም ምረጥ" "ቡድን ምረጥ" "ምስል እንደ አዘጋጅ" + + "ልጣፍ በማቀናበር ላይ...." "ልጣፍ" "ሰርዝ" - - + + "የተመረጠው ንጥል ይሰረዝ?" + "የተመረጡት ንጥሎች ይሰረዙ?" + "አረጋግጥ" "ይቅር" "አጋራ" @@ -94,7 +98,6 @@ "ምንም ስፍራ የለም" "አንዳንድ ስፍራዎች በአውታረ መረብ ችግር ምክንያት ለየቶ ማወቅ አልተቻለም::" "በዚህ አልበም ላይ ያሉ ፎቶዎችን ለማውረድ አልተቻለም፡፡ በኋላ ደግመህ ሞክር፡፡" - "የአልበሞችን ዝርዝር ለማውረድ አልተቻለም፡፡ በኋላ ደግመህ ሞክር፡፡" "ምስሎች ብቻ" "ቪዲዮዎች ብቻ" "ምስሎች & ቪዲዮዎች" diff --git a/res/values-ar/strings.xml b/res/values-ar/strings.xml index c0080a621..4417bc2f6 100644 --- a/res/values-ar/strings.xml +++ b/res/values-ar/strings.xml @@ -32,8 +32,8 @@ "تعذر تحميل الصورة" "بلا صورة مصغرة" "البدء من جديد" - - + "موافق" + "موافق" "المس وجهًا للبدء." "جارٍ حفظ الصورة..." "تعذر حفظ الصورة التي تم اقتصاصها." @@ -44,11 +44,15 @@ "تحديد ألبوم" "تحديد مجموعة" "تعيين الصورة كـ" + + "جارٍ تعيين الخلفية..." "الخلفية" "حذف" - - + + "هل تريد حذف العنصر المحدد؟" + "هل تريد حذف العناصر المحددة؟" + "تأكيد" "إلغاء" "مشاركة" @@ -94,7 +98,6 @@ "لا موقع" "تعذر تحديد بعض المواقع بسبب مشاكل في الشبكة." "تعذر تحميل الصور في هذا الألبوم. أعد المحاولة لاحقًا." - "تعذر تحميل قائمة الألبومات. أعد المحاولة لاحقًا." "الصور فقط" "مقاطع الفيديو فقط" "الصور ومقاطع الفيديو" diff --git a/res/values-be/strings.xml b/res/values-be/strings.xml index e42d884b5..61c6a2cc4 100644 --- a/res/values-be/strings.xml +++ b/res/values-be/strings.xml @@ -32,8 +32,8 @@ "Не атрымалася загрузіць малюнак" "Няма паменшанай выявы" "Пачаць зноў" - - + "ОК" + "ОК" "Дакранiцеся да твару, каб пачаць." "Захаванне выявы..." "Немагчыма захаваць абрэзаную выяву." @@ -44,11 +44,15 @@ "Выбраць альбом" "Выбар групы" "Усталяваць малюнак як" + + "Усталяванне шпалер..." "Шпалеры" "Выдаліць" - - + + "Выдаліць выбраны элемент?" + "Выдаліць выбраныя элементы?" + "Пацвердзіць" "Адмяніць" "Апублікаваць" @@ -94,7 +98,6 @@ "Няма месцазнаходж." "Некаторыя месцы не могуць быць вызначаны з-за праблем сеткі." "Немагчыма спампаваць фатаграфіі ў гэтым альбоме. Паўтарыце спробу пазней." - "Немагчыма спампаваць спіс альбомаў. Паўтарыце спробу пазней." "Толькі малюнкі" "Толькі відэа" "Выявы і відэа" diff --git a/res/values-bg/strings.xml b/res/values-bg/strings.xml index 8f4600074..4e549f8ca 100644 --- a/res/values-bg/strings.xml +++ b/res/values-bg/strings.xml @@ -32,8 +32,8 @@ "Изображението не можа да бъде заредено" "Няма миниизображение" "Стартиране отначало" - - + "OK" + "OK" "Докоснете лице за начало." "Снимката се запазва..." "Подрязаното изобр. не можа да се запази." @@ -44,11 +44,15 @@ "Изберете албум" "Изберете група" "Задаване на снимката като" + + "Тапетът се задава..." "Тапет" "Изтриване" - - + + "Да се изтрие ли избраното?" + "Да се изтрият ли избраните?" + "Потвърждаване" "Отказ" "Споделяне" @@ -94,7 +98,6 @@ "Няма местоположение" "Някои местоположения не можаха да бъдат идентифицирани поради проблеми с мрежата." "Снимките в този албум не можаха да се изтеглят. Опитайте отново по-късно." - "Списъкът с албуми не можа да се изтегли. Опитайте отново по-късно." "Само изображения" "Само видеоклипове" "Изображения и видеоклипове" diff --git a/res/values-ca/strings.xml b/res/values-ca/strings.xml index d43638d1e..a566c2408 100644 --- a/res/values-ca/strings.xml +++ b/res/values-ca/strings.xml @@ -32,8 +32,8 @@ "No s\'ha pogut carregar la imatge" "No hi ha cap miniatura" "Torna a començar" - - + "D\'acord" + "Accepta" "Toca una cara per començar." "S\'està desant la imatge..." "No s\'ha pogut desar la imatge retallada." @@ -44,11 +44,15 @@ "Selecciona un àlbum" "Selecciona un grup" "Defineix la imatge com a" + + "S\'està establint el fons de pantalla..." "Fons de pantalla" "Suprimeix" - - + + "Vols supr. l\'element selecc.?" + "Vols supr. l\'element selecc.?" + "Confirma" "Cancel·la" "Comparteix" @@ -94,7 +98,6 @@ "Sense ubicació" "Hi ha ubicacions que no s\'han pogut identificar a causa de problemes amb la xarxa." "No s\'han pogut baixar les fotos en aquest àlbum. Torna-ho a provar més tard." - "No s\'ha pogut baixar la llista d\'àlbums. Torna-ho a provar més tard." "Només imatges" "Només vídeos" "Imatges i vídeos" diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml index 426cddb8a..42b652b52 100644 --- a/res/values-cs/strings.xml +++ b/res/values-cs/strings.xml @@ -32,23 +32,27 @@ "Obrázek nelze načíst" "Miniatura není dostupná" "Začít znovu" - - + "OK" + "OK" "Začněte klepnutím na obličej." "Ukládání fotografie..." "Oříznutý obrázek nelze uložit." "Oříznout fotografii" - "Vyberte fotografii" - "Vyberte video" - "Vyberte položku" - "Vyberte album" - "Vyberte skupinu" - "Fotografie bude použita jako" + "Vybrat fotografii" + "Vybrat video" + "Vybrat položku" + "Vybrat album" + "Vybrat skupinu" + "Nastavit fotografii jako" + + "Nastavování tapety..." "Tapeta" "Smazat" - - + + "Smazat vybranou položku?" + "Smazat vybrané položky?" + "Potvrdit" "Zrušit" "Sdílet" @@ -87,14 +91,13 @@ "Podle místa" "Podle času" "Podle tagů" - "Podle osob" + "Podle lidí" "Podle alba" "Podle velikosti" "Neoznačeno" "Neznámá poloha" "Některá umístění se nepodařilo identifikovat kvůli problémům se sítí." "Fotografie v tomto albu nelze stáhnout. Zkuste to znovu později." - "Seznam alb nelze stáhnout. Zkuste to znovu později." "Pouze obrázky" "Pouze videa" "Obrázky a videa" @@ -161,12 +164,12 @@ "Lokality" "Lidé" "Tagy" - "Seskupit podle" + "Seskupit podle..." "Nastavení" "Přidat účet" "Fotoaparát" "Stahování" "Importováno" - "Snímek obrazovky" + "Snímky obrazovky" "Nápověda" diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml index 93d2464f7..6675637f0 100644 --- a/res/values-da/strings.xml +++ b/res/values-da/strings.xml @@ -32,8 +32,8 @@ "Billedet kunne ikke indlæses" "Ingen miniature" "Start igen" - - + "OK" + "OK" "Tryk på et ansigt for at begynde." "Gemmer billede..." "Det beskårne billede kunne ikke gemmes." @@ -44,11 +44,15 @@ "Vælg album" "Vælg gruppe" "Angiv billedet som" + + "Angiver baggrund..." "Tapet" "Slet" - - + + "Vil du slette valgte element?" + "Vil du slette valgte elementer?" + "Bekræft" "Annuller" "Del" @@ -94,7 +98,6 @@ "Ingen placering" "Nogle placeringer kunne ikke identificeres på grund af netværksproblemer." "Billederne i dette album kunne ikke hentes. Prøv igen senere." - "Listen over albummer kunne ikke downloades. Prøv igen senere." "Kun billeder" "Kun videoer" "Billeder og videoer" diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index 096b995f0..e7c6efbd3 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -32,8 +32,8 @@ "Bild konnte nicht geladen werden." "Keine Miniaturansicht" "Starten" - - + "OK" + "OK" "Zum Beginnen auf ein Gesicht tippen" "Bild wird gespeichert..." "Zugeschnittenes Bild nicht gespeichert" @@ -44,11 +44,15 @@ "Album auswählen" "Gruppe auswählen" "Bild festlegen als" + + "Hintergrund wird festgelegt..." "Hintergrund" "Löschen" - - + + "Ausgewähltes Element löschen?" + "Ausgewählte Elemente löschen?" + "Bestätigen" "Abbrechen" "Teilen" @@ -94,7 +98,6 @@ "Kein Aufnahmeort" "Einige Standorte konnten aufgrund von Netzwerkproblemen nicht identifiziert werden." "Die Fotos aus diesem Album konnten nicht heruntergeladen werden. Bitte versuchen Sie es später erneut." - "Die Albenliste konnte nicht heruntergeladen werden. Bitte versuchen Sie es später erneut." "Nur Bilder" "Nur Videos" "Bilder und Videos" diff --git a/res/values-el/strings.xml b/res/values-el/strings.xml index 72eb17097..f63e0a8d0 100644 --- a/res/values-el/strings.xml +++ b/res/values-el/strings.xml @@ -32,8 +32,8 @@ "Δεν ήταν δυνατή η φόρτωση της εικόνας" "Δεν υπάρχει μικρογραφία" "Έναρξη από την αρχή" - - + "OK" + "ΟΚ" "Αγγίξτε κάποιο πρόσωπο για να ξεκινήσετε." "Αποθήκευση εικόνας..." "Αδυναμία αποθήκευσης αποκομμένης εικόνας" @@ -44,11 +44,15 @@ "Επιλογή λευκώματος" "Επιλογή ομάδας" "Ορισμός εικόνας ως" + + "Ορισμός ταπετσαρίας..." "Ταπετσαρία" "Διαγραφή" - - + + "Διαγραφή επιλεγμέν. στοιχείου;" + "Διαγραφή επιλεγμέν. στοιχείων;" + "Επιβεβαίωση" "Ακύρωση" "Κοινή χρήση" @@ -94,7 +98,6 @@ "Καμία τοποθεσία" "Δεν ήταν δυνατός ο προσδιορισμός ορισμένων τοποθεσιών λόγω προβλημάτων δικτύου." "Δεν ήταν δυνατή η λήψη των φωτογραφιών σε αυτό το λεύκωμα. Δοκιμάστε ξανά αργότερα." - "Δεν ήταν δυνατή η λήψη της λίστας λευκωμάτων. Δοκιμάστε ξανά αργότερα." "Μόνο εικόνες" "Μόνο βίντεο" "Εικόνες και βίντεο" diff --git a/res/values-en-rGB/strings.xml b/res/values-en-rGB/strings.xml index 7792b3a54..02e3d20c3 100644 --- a/res/values-en-rGB/strings.xml +++ b/res/values-en-rGB/strings.xml @@ -32,8 +32,8 @@ "Couldn\'t load the image" "No thumbnail" "Start again" - - + "OK" + "OK" "Touch a face to begin." "Saving picture…" "Couldn\'t save cropped image." @@ -44,11 +44,15 @@ "Select album" "Select group" "Set picture as" + + "Setting wallpaper..." "Wallpaper" "Delete" - - + + "Delete selected item?" + "Delete selected items?" + "Confirm" "Cancel" "Share" @@ -94,7 +98,6 @@ "No location" "Some locations couldn\'t be identified due to network problems." "Couldn\'t download the photos in this album. Retry later." - "Couldn\'t download the list of albums. Retry later." "Images only" "Videos only" "Images & videos" diff --git a/res/values-es-rUS/strings.xml b/res/values-es-rUS/strings.xml index 48f7fc20a..35fb8e121 100644 --- a/res/values-es-rUS/strings.xml +++ b/res/values-es-rUS/strings.xml @@ -32,8 +32,8 @@ "No se pudo cargar la imagen." "Sin miniatura" "Empezar de nuevo" - - + "Aceptar" + "Aceptar" "Toca una cara para comenzar." "Guardando imagen..." "No se pudo guardar la imagen recortada." @@ -44,11 +44,15 @@ "Seleccionar álbum" "Seleccionar un grupo" "Establecer imagen como" + + "Estableciendo fondo de pantalla..." "Papel tapiz" "Eliminar" - - + + "¿Eliminar elemento selec.?" + "¿Eliminar elementos selecs.?" + "Confirmar" "Cancelar" "Compartir" @@ -94,7 +98,6 @@ "No hay ubicación" "No se pudieron identificar algunas ubicaciones debido a problemas de la red." "No se pudieron descargar las fotos de este álbum. Vuelve a intentarlo más adelante." - "No se pudo descargar la lista de álbumes. Vuelve a intentarlo más adelante." "Sólo imágenes" "Sólo videos" "Imágenes y videos" diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index dc03d5245..cc8e57fc2 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -32,8 +32,8 @@ "No se puede cargar la imagen." "No hay miniaturas." "Volver a reproducir" - - + "Aceptar" + "Aceptar" "Toca una cara para comenzar." "Guardando imagen..." "Error al guardar la imagen recortada" @@ -44,11 +44,15 @@ "Seleccionar álbum" "Seleccionar grupo" "Establecer imagen como" + + "Estableciendo fondo de pantalla..." "Fondo de pantalla" "Borrar" - - + + "¿Eliminar elemento seleccionado?" + "¿Eliminar elementos seleccionados?" + "Confirmar" "Cancelar" "Compartir" @@ -94,7 +98,6 @@ "Sin ubicación" "No se ha podido identificar algunas ubicaciones debido a errores en la red." "No se ha podido descargar las fotos del álbum. Inténtalo de nuevo más tarde." - "No se ha podido descargar la lista de álbumes. Inténtalo de nuevo más tarde." "Solo imágenes" "Solo vídeos" "Imágenes y vídeos" diff --git a/res/values-et/strings.xml b/res/values-et/strings.xml index 6e12144b0..3f669f090 100644 --- a/res/values-et/strings.xml +++ b/res/values-et/strings.xml @@ -32,8 +32,8 @@ "Kujutist ei õnnestunud laadida" "Pisipilti pole" "Alusta uuesti" - - + "OK" + "OK" "Alustamiseks näo puudutamine." "Pildi salvestamine ..." "Kärbitud kujutist ei saanud salvestada." @@ -44,11 +44,15 @@ "Albumi valimine" "Rühma valimine" "Seadke pilt kui" + + "Taustapildi määramine ..." "Taustapilt" "Kustuta" - - + + "Kas kustutada valitud üksus?" + "Kas kustutada valitud üksused?" + "Kinnitamine" "Tühista" "Jaga" @@ -94,7 +98,6 @@ "Asukoht puudub" "Mõnda asukohta ei suudetud võrguprobleemide tõttu tuvastada." "Fotosid ei saa sellesse albumisse alla laadida. Proovige hiljem uuesti." - "Albumite loendit ei saa alla laadida. Proovige hiljem uuesti." "Ainult kujutised" "Ainult videod" "Kujutised ja videod" diff --git a/res/values-fa/strings.xml b/res/values-fa/strings.xml index d44b6606a..0622954a9 100644 --- a/res/values-fa/strings.xml +++ b/res/values-fa/strings.xml @@ -32,8 +32,8 @@ "تصویر بارگیری نمی‌شود" "تصویر کوچکی وجود ندارد" "شروع مجدد" - - + "تائید" + "تأیید" "برای شروع یک چهره را لمس کنید." "در حال ذخیره عکس..." "ذخیره تصویر برش‌خورده امکان‌پذیر نیست." @@ -44,11 +44,15 @@ "آلبوم را انتخاب کنید" "انتخاب گروه" "تنظیم تصویر بعنوان" + + "تنظیم تصویر زمینه..." "تصویر زمینه" "حذف" - - + + "مورد انتخابی حذف شود؟" + "موارد انتخابی حذف شوند؟" + "تأیید" "لغو" "اشتراک گذاری" @@ -94,7 +98,6 @@ "مکانی موجود نیست" "شناسایی برخی از مکان‌ها به دلیل مشکلات شبکه امکان‌پذیر نیست." "عکس‌های این آلبوم را نمی‌توان دانلود کرد. بعداً دوباره امتحان کنید." - "لیست آلبوم‌ها را نمی‌توان دانلود کرد. بعداً دوباره امتحان کنید." "فقط تصاویر" "فقط ویدیوها" "تصاویر و ویدیوها" diff --git a/res/values-fi/strings.xml b/res/values-fi/strings.xml index ff0fab83b..4b91ad448 100644 --- a/res/values-fi/strings.xml +++ b/res/values-fi/strings.xml @@ -32,8 +32,8 @@ "Kuvaa ei voi ladata" "Ei pikkukuvaa" "Aloita alusta" - - + "OK" + "OK" "Aloita koskettamalla kasvoja." "Tallennetaan kuvaa…" "Rajattua kuvaa ei voitu tallentaa." @@ -44,11 +44,15 @@ "Valitse albumi" "Valitse ryhmä" "Aseta kuva" + + "Asetetaan taustakuvaa..." "taustakuvaksi" "Poista" - - + + "Poistetaanko valittu kohde?" + "Poistetaanko valitut kohteet?" + "Vahvista" "Peruuta" "Jaa" @@ -94,7 +98,6 @@ "Ei sijaintia" "Verkkoyhteysongelma – joitakin paikkoja ei voi tunnistaa." "Albumin valokuvia ei voi ladata. Yritä myöhemmin uudelleen." - "Albumiluetteloa ei voi ladata. Yritä myöhemmin uudelleen." "Vain kuvat" "Vain videot" "Kuvat ja videot" diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index 6dd35f7ae..85af46ddf 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -32,8 +32,8 @@ "Impossible de charger l\'image." "Aucune vignette" "Démarrer" - - + "OK" + "OK" "Appuyer sur un visage pour commencer" "Enregistrement de l\'image" "Impossible d\'enregistrer l\'image rognée." @@ -44,11 +44,15 @@ "Sélectionner album" "Sélectionnez groupe" "Utiliser l\'image comme" + + "Définition du fond d\'écran…" "Fond d\'écran" "Supprimer" - - + + "Supprimer élément sélectionné ?" + "Supprimer éléments sélectionnés ?" + "Confirmer" "Annuler" "Partager" @@ -94,7 +98,6 @@ "Aucun lieu" "Certains lieux n\'ont pas pu être identifiés en raison de problèmes réseau." "Impossible de télécharger les photos de cet album. Veuillez réessayer ultérieurement." - "Impossible de télécharger la liste des albums. Veuillez réessayer ultérieurement." "Images uniquement" "Vidéos uniquement" "Images et vidéos" diff --git a/res/values-hi/strings.xml b/res/values-hi/strings.xml index 2711cf4b4..b8329ae71 100644 --- a/res/values-hi/strings.xml +++ b/res/values-hi/strings.xml @@ -32,8 +32,8 @@ "छवि लोड नहीं हो सकी" "कोई थंबनेल नहीं" "पुन: प्रारंभ करें" - - + "ठीक" + "ठीक" "शुरू करने के लिए कोई चेहरा स्‍पर्श करें." "चित्र सहेज रहा है…" "काट-छांट की गई छवि को नहीं सहेज सका." @@ -44,11 +44,15 @@ "एल्बम का चयन करें" "समूह का चयन करें" "चित्र इस रूप में सेट करें" + + "वॉलपेपर सेट कर रहा है..." "वॉलपेपर" "हटाएं" - - + + "चयनित आइटम हटाएं?" + "चयनित आइटम हटाएं?" + "पुष्टि करें" "रद्द करें" "शेयर करें" @@ -94,7 +98,6 @@ "कोई स्थान नहीं" "नेटवर्क समस्‍याओं के कारण कुछ स्‍थानों को पहचाना नहीं जा सका." "इस एल्बम के फ़ोटो डाउनलोड नहीं किए जा सके. बाद में पुन: प्रयास करें." - "एल्बम की सूची डाउनलोड नहीं की जा सकी. बाद में पुन: प्रयास करें." "केवल छवियां" "केवल वीडियो" "छवियां और वीडियो" diff --git a/res/values-hr/strings.xml b/res/values-hr/strings.xml index e42998b6c..4a4c4abef 100644 --- a/res/values-hr/strings.xml +++ b/res/values-hr/strings.xml @@ -32,8 +32,8 @@ "Nije moguće učitati sliku" "Nema minijatura" "Počni ispočetka" - - + "U redu" + "U redu" "Dodirnite lice za početak." "Spremanje slike..." "Nije moguće spremiti obrezanu sliku." @@ -44,11 +44,15 @@ "Odaberi album" "Odabir grupe" "Postavi sliku kao" + + "Postavljanje pozadinske slike…" "Pozadinska slika" "Izbriši" - - + + "Izbrisati odabranu stavku?" + "Izbrisati odabrane stavke?" + "Potvrdi" "Odustani" "Podijeli" @@ -94,7 +98,6 @@ "Nema lokacije" "Neke lokacije nisu se mogle identificirati zbog poteškoća s mrežnom." "Preuzimanje fotografija iz ovog albuma nije uspjelo. Pokušajte ponovo kasnije." - "Preuzimanje popisa albuma nije uspjelo. Pokušajte ponovo kasnije." "Samo slike" "Samo videozapisi" "Slike i videozapisi" diff --git a/res/values-hu/strings.xml b/res/values-hu/strings.xml index 031be83d8..1cc970370 100644 --- a/res/values-hu/strings.xml +++ b/res/values-hu/strings.xml @@ -32,8 +32,8 @@ "Nem sikerült betölteni a képet" "Nincs indexkép" "Újrakezdés" - - + "OK" + "OK" "Érintsen meg egy arcot a kezdéshez." "Kép mentése..." "Nem lehet menteni a vágott képet." @@ -44,11 +44,15 @@ "Album kiválasztása" "Csoport kiválasztása" "Kép beállítása, mint" + + "Háttérkép beállítása..." "Háttérkép" "Törlés" - - + + "Törli a kiválasztott elemet?" + "Törli a kiválasztott elemeket?" + "Megerősítés" "Mégse" "Megosztás" @@ -94,7 +98,6 @@ "Nincs helyadat" "Néhány helyet nem lehetett azonosítani hálózati problémák miatt." "Nem sikerült letölteni ennek az albumnak a képeit. Próbálja újra később." - "Nem sikerült letölteni az albumok listáját. Próbálja újra később." "Csak képek" "Csak videók" "Képek és videók" diff --git a/res/values-in/strings.xml b/res/values-in/strings.xml index 882861c1c..a62697ca7 100644 --- a/res/values-in/strings.xml +++ b/res/values-in/strings.xml @@ -32,8 +32,8 @@ "Tidak dapat memuat gambar" "Tidak ada gambar mini" "Memulai" - - + "Oke" + "Oke" "Sentuh wajah untuk memulai." "Menyimpan gambar…" "Tak dapat menyimpan gambar yg dipangkas." @@ -44,11 +44,15 @@ "Pilih album" "Pilih grup" "Setel gambar sebagai" + + "Menyetel wallpaper..." "Wallpaper" "Hapus" - - + + "Hapus item yang dipilih?" + "Hapus item yang dipilih?" + "Konfirmasi" "Batal" "Bagikan" @@ -94,7 +98,6 @@ "Tidak ada lokasi" "Beberapa lokasi tidak dapat diidentifikasi karena masalah jaringan." "Tidak dapat mengunduh foto di album ini. Coba lagi nanti." - "Tidak dapat mengunduh daftar album. Coba lagi nanti." "Hanya gambar" "Hanya video" "Gambar & video" diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index 33fd37cb2..ceabf3fa6 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -32,8 +32,8 @@ "Impossibile caricare l\'immagine" "Nessuna miniatura" "Ricomincia" - - + "OK" + "OK" "Tocca un viso per iniziare." "Salvataggio foto..." "Impossibile salvare immagine ritagliata." @@ -44,11 +44,15 @@ "Seleziona album" "Seleziona gruppo" "Imposta foto come" + + "Impostazione sfondo..." "Sfondo" "Elimina" - - + + "Eliminare elemento selezionato?" + "Eliminare elementi selezionati?" + "Conferma" "Annulla" "Condividi" @@ -94,7 +98,6 @@ "Nessun luogo" "Impossibile identificare alcune località a causa di problemi di rete." "Download delle foto in questo album non riuscito. Riprova più tardi." - "Download dell\'elenco di album non riuscito. Riprova più tardi." "Solo immagini" "Solo video" "Immagini e video" diff --git a/res/values-iw/strings.xml b/res/values-iw/strings.xml index 05811a60b..8a68468b2 100644 --- a/res/values-iw/strings.xml +++ b/res/values-iw/strings.xml @@ -32,8 +32,8 @@ "לא היתה אפשרות לטעון את התמונה" "ללא תמונה ממוזערת" "התחל מחדש" - - + "אישור" + "אישור" "גע בפנים כלשהם כדי להתחיל." "שומר תמונה..." "לא ניתן לשמור את התמונה החתוכה." @@ -44,11 +44,15 @@ "בחר אלבום" "בחר קבוצה" "הגדר תמונה בתור" + + "מגדיר טפט..." "טפט" "מחק" - - + + "האם למחוק את הפריט שנבחר?" + "האם למחוק את הפריטים שנבחרו?" + "אשר" "ביטול" "שיתוף" @@ -94,7 +98,6 @@ "ללא מיקום" "לא ניתן לזהות מיקומים מסוימים בשל בעיות ברשת." "לא ניתן להוריד את התמונות באלבום זה. נסה שוב מאוחר יותר." - "לא ניתן להוריד את רשימת האלבומים. נסה שוב מאוחר יותר." "תמונות בלבד" "סרטונים בלבד" "תמונות וסרטונים" diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml index 01d5ca2a9..a1d8c8006 100644 --- a/res/values-ja/strings.xml +++ b/res/values-ja/strings.xml @@ -32,8 +32,8 @@ "画像を読み込めませんでした" "サムネイルなし" "最初から再生" - - + "OK" + "OK" "始めるには顔をタップします。" "写真を保存中…" "トリミングした画像を保存できません。" @@ -44,11 +44,15 @@ "アルバムを選択" "グループの選択" "登録" + + "壁紙を設定しています..." "壁紙" "削除" - - + + "アイテムを削除しますか?" + "アイテムを削除しますか?" + "確認" "キャンセル" "共有" @@ -94,7 +98,6 @@ "位置情報なし" "ネットワークの問題により一部の位置情報を特定できませんでした。" "このアルバムの画像をダウンロードできませんでした。しばらくしてからもう一度お試しください。" - "アルバムのリストをダウンロードできませんでした。しばらくしてからもう一度お試しください。" "画像のみ" "動画のみ" "画像と動画" diff --git a/res/values-ko/strings.xml b/res/values-ko/strings.xml index c6d9bd6cd..dd6967323 100644 --- a/res/values-ko/strings.xml +++ b/res/values-ko/strings.xml @@ -32,8 +32,8 @@ "이미지를 로드할 수 없습니다." "미리보기 이미지 없음" "처음부터 보기" - - + "확인" + "확인" "시작하려면 얼굴을 터치하세요." "사진 저장 중..." "잘린 이미지를 저장하지 못했습니다." @@ -44,11 +44,15 @@ "앨범 선택" "그룹 선택" "사진을 다음으로 설정" + + "배경화면을 설정하는 중..." "배경화면" "삭제" - - + + "선택한 항목을 삭제할까요?" + "선택한 항목을 삭제할까요?" + "확인" "취소" "공유" @@ -94,7 +98,6 @@ "위치 없음" "네트워크 문제로 인해 일부 위치를 식별하지 못했습니다." "앨범 사진을 다운로드하지 못했습니다. 나중에 다시 시도해 주세요." - "앨범 목록을 다운로드하지 못했습니다. 나중에 다시 시도해 주세요." "이미지" "동영상" "이미지 및 동영상" diff --git a/res/values-lt/strings.xml b/res/values-lt/strings.xml index 01ca1d30d..57d615a0f 100644 --- a/res/values-lt/strings.xml +++ b/res/values-lt/strings.xml @@ -32,8 +32,8 @@ "Nepavyko įkelti vaizdo" "Nėra miniatiūros" "Pradėti iš naujo" - - + "Gerai" + "Gerai" "Jei norite pradėti, palieskite veidą." "Išsaugomas paveikslėlis..." "Nepavyko išsaugoti apkarpyto vaizdo." @@ -44,11 +44,15 @@ "Pasirinkti albumą" "Pasirinkti grupę" "Nustatyti paveikslėlį kaip" + + "Nustatomas darbalaukio fonas…" "Darbalaukio fonas" "Ištrinti" - - + + "Ištrinti pasirinktą elementą?" + "Ištrinti pasirink. elementus?" + "Patvirtinti" "Atšaukti" "Bendrinti" @@ -94,7 +98,6 @@ "Nėra vietos" "Kai kurių vietų nepavyko nustatyti dėl tinklo problemų." "Šio albumo nuotraukų atsisiųsti nepavyko. Bandykite dar kartą vėliau." - "Albumų sąrašo atsisiųsti nepavyko. Bandykite dar kartą vėliau." "Tik vaizdai" "Tik vaizdo įrašai" "Vaizdai ir vaizdo įrašai" diff --git a/res/values-lv/strings.xml b/res/values-lv/strings.xml index 68332b485..cb17e5e43 100644 --- a/res/values-lv/strings.xml +++ b/res/values-lv/strings.xml @@ -32,8 +32,8 @@ "Nevarēja ielādēt attēlu." "Nav sīktēla." "Sākt vēlreiz" - - + "Labi" + "Labi" "Pieskarieties sejai, lai sāktu." "Notiek attēla saglabāšana..." "Nevarēja saglabāt izgriezto attēlu." @@ -44,11 +44,15 @@ "Albuma atlase" "Atlasiet grupu" "Iestatīt attēlu kā:" + + "Notiek fona tapetes iestatīšana..." "Fona tapete" "Dzēst" - - + + "Vai dzēst atlasīto vienumu?" + "Vai dzēst atlasītos vienumus?" + "Apstiprināt" "Atcelt" "Dalies" @@ -94,7 +98,6 @@ "Nav vietas inform." "Tīkla problēmu dēļ nevarēja noteikt dažas atrašanās vietas." "Nevarēja lejupielādēt šī albuma fotoattēlus. Vēlāk mēģiniet vēlreiz." - "Nevarēja lejupielādēt albumu sarakstu. Vēlāk mēģiniet vēlreiz." "Tikai attēli" "Tikai videoklipi" "Attēli un videoklipi" diff --git a/res/values-ms/strings.xml b/res/values-ms/strings.xml index 76e31c180..ee758ed86 100644 --- a/res/values-ms/strings.xml +++ b/res/values-ms/strings.xml @@ -32,8 +32,8 @@ "Tidak dapat memuatkan imej" "Tiada lakaran kenit" "Mainkan semula dari mula" - - + "OK" + "OK" "Sentuh muka untuk bermula." "Menyimpan gambar..." "Tidak dapat menyimpan imej yang dipangkas." @@ -44,11 +44,15 @@ "Pilih album" "Pilih kumpulan" "Tetapkan gambar sebagai" + + "Menetapkan kertas dinding…" "Kertas dinding" "Padam" - - + + "Padam item yang dipilih?" + "Padam item yang dipilih?" + "Sahkan" "Batal" "Kongsi" @@ -94,7 +98,6 @@ "Tiada lokasi" "Beberapa lokasi tidak dapat dikenal pasti kerana masalah rangkaian." "Tidak dapat memuat turun foto dalam album ini. Cuba lagi nanti." - "Tidak dapat memuat turun senarai album. Cuba lagi nanti." "Imej sahaja" "Video sahaja" "Imej & video" diff --git a/res/values-nb/strings.xml b/res/values-nb/strings.xml index 4b2bee739..9dd8e27ff 100644 --- a/res/values-nb/strings.xml +++ b/res/values-nb/strings.xml @@ -32,8 +32,8 @@ "Kunne ikke laste inn bildet" "Ingen miniatyrbilder" "Begynn på nytt" - - + "OK" + "OK" "Berør et ansikt for å begynne." "Lagrer bilde ..." "Kan ikke lagre det beskårede bildet." @@ -44,11 +44,15 @@ "Velg album" "Valg av gruppe" "Angi bilde som" + + "Angir bakgrunn …" "Bakgrunnsbilde" "Slett" - - + + "Vil du slette det valgte medieelementet?" + "Vil du slette de valgte medieelementene?" + "Bekreft" "Avbryt" "Del" @@ -94,7 +98,6 @@ "Ingen posisjon" "Noen steder kunne ikke identifiseres på grunn av nettverksproblemer." "Kunne ikke laste ned bildene i dette albumet. Prøv på nytt senere." - "Kunne ikke laste ned albumlisten. Prøv på nytt senere." "Kun bilder" "Kun videoer" "Bilder og videoer" @@ -157,7 +160,7 @@ "Valg av bilder" "Lysbildefremvisning" "Album" - "Ganger" + "Tidspunkt" "Steder" "Folk" "Etiketter" diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml index 40e0e2e3b..cad39569a 100644 --- a/res/values-nl/strings.xml +++ b/res/values-nl/strings.xml @@ -32,8 +32,8 @@ "Kan de afbeelding niet laden" "Geen miniatuur" "Opnieuw starten" - - + "OK" + "OK" "Raak een gezicht aan om te beginnen." "Foto opslaan..." "Kan bijgesneden afbeelding niet opslaan." @@ -44,11 +44,15 @@ "Album selecteren" "Groep selecteren" "Foto instellen als" + + "Achtergrond instellen..." "Achtergrond" "Verwijderen" - - + + "Geselecteerd item verwijderen?" + "Geselect. items verwijderen?" + "Bevestigen" "Annuleren" "Delen" @@ -94,7 +98,6 @@ "Geen locatie" "Sommige locaties kunnen wegens problemen met het netwerk niet worden geïdentificeerd." "Kan de foto\'s in dit album niet downloaden. Probeer het later opnieuw." - "Kan de lijst met albums niet downloaden. Probeer het later opnieuw." "Alleen afbeeldingen" "Alleen video\'s" "Afbeeldingen en video\'s" diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml index c9040b15e..691bbd04e 100644 --- a/res/values-pl/strings.xml +++ b/res/values-pl/strings.xml @@ -32,8 +32,8 @@ "Nie można wczytać zdjęcia" "Brak miniatury" "Rozpocznij" - - + "OK" + "OK" "Dotknij twarzy, aby rozpocząć." "Zapisywanie zdjęcia…" "Nie można zapisać przyciętego obrazu." @@ -44,11 +44,15 @@ "Wybierz album" "Wybierz grupę" "Ustaw zdjęcie jako" + + "Ustawianie tapety…" "Tapeta" "Usuń" - - + + "Usunąć wybrany element?" + "Usunąć wybrane elementy?" + "Potwierdź" "Anuluj" "Udostępnij" @@ -94,7 +98,6 @@ "Brak lokalizacji" "Niektórych lokalizacji nie można zidentyfikować z powodu problemów z siecią." "Nie można pobrać zdjęć z tego albumu. Spróbuj ponownie później." - "Nie można pobrać listy albumów. Spróbuj ponownie później." "Tylko obrazy" "Tylko filmy" "Obrazy i filmy" @@ -141,7 +144,7 @@ "Albumy lokalne" "Urządzenia MTP" "Albumy Picasa" - "Wolne: %s" + "%s wolne" "%1$s lub mniej" "%1$s lub więcej" "%1$s do %2$s" diff --git a/res/values-pt-rPT/strings.xml b/res/values-pt-rPT/strings.xml index c3a377aef..50c94292b 100644 --- a/res/values-pt-rPT/strings.xml +++ b/res/values-pt-rPT/strings.xml @@ -32,8 +32,8 @@ "Não foi possível carregar a imagem" "Sem miniatura" "Recomeçar" - - + "OK" + "OK" "Toque num rosto para começar." "A guardar imagem..." "Impossível guardar imagem recortada." @@ -44,11 +44,15 @@ "Selecionar álbum" "Selecionar grupo" "Definir imagem como" + + "A definir imagem de fundo…" "Imagem de fundo" "Eliminar" - - + + "Eliminar item selecionado?" + "Eliminar itens selecionados?" + "Confirmar" "Cancelar" "Partilhar" @@ -94,7 +98,6 @@ "Sem localização" "Não foi possível identificar algumas localizações devido a problemas de rede." "Não foi possível transferir as fotografias deste álbum. Tente novamente mais tarde." - "Não foi possível transferir a lista de álbuns. Tente novamente mais tarde." "Apenas imagens" "Apenas vídeos" "Imagens e vídeos" diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml index e02dfac51..a0485ee99 100644 --- a/res/values-pt/strings.xml +++ b/res/values-pt/strings.xml @@ -32,8 +32,8 @@ "Não foi possível carregar a imagem" "Sem miniatura" "Reiniciar" - - + "OK" + "OK" "Toque em um rosto para começar." "Salvando imagem…" "Não é possível salvar a imagem cortada." @@ -44,11 +44,15 @@ "Selecionar álbum" "Selecionar grupo" "Definir imagem como" + + "Definindo plano de fundo..." "Plano de fundo" "Excluir" - - + + "Excluir o item selecionado?" + "Excluir os itens selecionados?" + "Confirmar" "Cancelar" "Compartilhar" @@ -94,7 +98,6 @@ "Nenhum local" "Alguns locais não foram identificados por problemas na rede." "Não foi possível fazer download das fotos neste álbum. Tente novamente mais tarde." - "Não foi possível fazer download da lista de álbuns. Tente novamente mais tarde." "Apenas imagens" "Somente vídeos" "Imagens e vídeos" @@ -157,7 +160,7 @@ "Escolher imagens" "Apresent. de slides" "Álbuns" - "Vezes" + "Data e hora" "Locais" "Pessoas" "Etiquetas" diff --git a/res/values-rm/strings.xml b/res/values-rm/strings.xml index 5ee7c7649..ffb6ef799 100644 --- a/res/values-rm/strings.xml +++ b/res/values-rm/strings.xml @@ -39,6 +39,8 @@ "Cumenzar" + + @@ -58,6 +60,8 @@ "Definir il maletg sco" + + "Culissa" @@ -125,8 +129,6 @@ - - diff --git a/res/values-ro/strings.xml b/res/values-ro/strings.xml index 16d8721e0..efcf779f8 100644 --- a/res/values-ro/strings.xml +++ b/res/values-ro/strings.xml @@ -32,8 +32,8 @@ "Nu s-a putut încărca imaginea" "Nu există o miniatură" "Începeţi din nou" - - + "OK" + "OK" "Atingeţi o faţă pentru a începe." "Se salvează fotografia..." "Imaginea decupată nu s-a putut salva." @@ -44,11 +44,15 @@ "Selectaţi un album" "Selectaţi un grup" "Setaţi fotografia ca" + + "Se setează imaginea de fundal..." "Imagine de fundal" "Ştergeţi" - - + + "Ştergeţi articolul selectat?" + "Ştergeţi articolele selectate?" + "Confirmaţi" "Anulaţi" "Distribuiţi" @@ -94,7 +98,6 @@ "Fără locaţie" "Unele locaţii nu au putut fi identificate din cauza unor probleme de reţea." "Descărcarea fotografiilor din acest album a eşuat. Încercaţi din nou mai târziu." - "Descărcarea listei de albume a eşuat. Încercaţi din nou mai târziu." "Numai imagini" "Numai videoclipuri" "Imagini şi videoclipuri" diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index 142567764..d7aff4f84 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -32,8 +32,8 @@ "Не удалось загрузить изображение" "Нет уменьшенного изображения" "Начать с начала" - - + "ОК" + "ОК" "Нажмите на лицо, чтобы начать." "Сохранение картинки..." "Изображение не сохранено." @@ -44,11 +44,15 @@ "Выбрать альбомы" "Выбрать группы" "Установить картинку как" + + "Установка обоев..." "Обои" "Удалить" - - + + "Удалить выбранный файл?" + "Удалить выбранные файлы?" + "Подтвердить" "Отмена" "Отправить" @@ -94,7 +98,6 @@ "Место не указано" "Не удалось найти все места из-за проблем с подключением." "Не удалось загрузить фото. Повторите попытку позже." - "Не удалось загрузить список альбомов. Повторите попытку позже." "Только изображения" "Только видео" "Изображения и видео" diff --git a/res/values-sk/strings.xml b/res/values-sk/strings.xml index 3322b911d..e87387001 100644 --- a/res/values-sk/strings.xml +++ b/res/values-sk/strings.xml @@ -32,8 +32,8 @@ "Obrázok sa nepodarilo načítať" "Žiadne miniatúry" "Začať odznova" - - + "OK" + "OK" "Začnite dotknutím sa tváre." "Prebieha ukladanie fotografie..." "Orezaný obrázok sa nepodarilo uložiť." @@ -44,11 +44,15 @@ "Vybrať album" "Vybrať skupinu" "Fotografia bude použitá ako" + + "Prebieha nastavenie tapety..." "Tapeta" "Odstrániť" - - + + "Odstrániť vybratú položku?" + "Odstrániť vybraté položky?" + "Potvrdiť" "Zrušiť" "Zdieľať" @@ -94,7 +98,6 @@ "Bez údajov o polohe" "Niektoré umiestnenia nebolo možné identifikovať kvôli problémom so sieťou." "Fotografie z tohto albumu sa nepodarilo prevziať. Skúste to znova neskôr." - "Zoznam albumov sa nepodarilo prevziať. Skúste to znova neskôr." "Iba obrázky" "Iba videá" "Obrázky a videá" diff --git a/res/values-sl/strings.xml b/res/values-sl/strings.xml index a04146077..8446a6c6f 100644 --- a/res/values-sl/strings.xml +++ b/res/values-sl/strings.xml @@ -32,8 +32,8 @@ "Slike ni bilo mogoče naložiti" "Ni sličice" "Začni znova" - - + "V redu" + "V redu" "Dotaknite se obraza, če želite začeti." "Shranjevanje slike ..." "Obrezane slike ni bilo mogoče shraniti." @@ -44,11 +44,15 @@ "Izberite album" "Izberite skupino" "Nastavi sliko kot" + + "Nastavljanje slike za ozadje ..." "Slika za ozadje" "Izbriši" - - + + "Želite izbrisati ta element?" + "Želite izbrisati te elemente?" + "Potrdi" "Prekliči" "Skupna raba" @@ -94,7 +98,6 @@ "Ni lokacije" "Nekaterih ​​lokacij ni bilo mogoče določiti zaradi težav v omrežju." "Slik v tem albumu ni mogoče prenesti. Poskusite znova pozneje." - "Seznama albumov ni mogoče prenesti. Poskusite znova pozneje." "Samo slike" "Samo videoposnetki" "Slike in videoposnetki" diff --git a/res/values-sr/strings.xml b/res/values-sr/strings.xml index 7e69a7c1e..317ddc70f 100644 --- a/res/values-sr/strings.xml +++ b/res/values-sr/strings.xml @@ -32,8 +32,8 @@ "Није могуће учитати слику" "Нема сличице" "Започни поново" - - + "Потврди" + "Потврди" "Додирните неко лице за почетак." "Чување слике…" "Није могуће сачувати опсечену слику." @@ -44,11 +44,15 @@ "Избор албума" "Избор групе" "Постављање слике као" + + "Подешавање позадине..." "Позадина" "Избриши" - - + + "Бришете изабрану ставку?" + "Бришете изабране ставке?" + "Потврди" "Откажи" "Дели" @@ -94,7 +98,6 @@ "Без локације" "Није могуће идентификовати неке локације због проблема са мрежом." "Није могуће преузети фотографије у овом албуму. Покушајте поново касније." - "Није могуће преузети листу албума. Покушајте поново касније." "Само слике" "Само видео снимци" "Слике и видео снимци" diff --git a/res/values-sv/strings.xml b/res/values-sv/strings.xml index 33c1ae4ac..895ffee1e 100644 --- a/res/values-sv/strings.xml +++ b/res/values-sv/strings.xml @@ -32,8 +32,8 @@ "Det gick inte att läsa in bilden" "Ingen miniatyrbild" "Börja om" - - + "OK" + "OK" "Tryck på ett ansikte när du vill börja." "Sparar bild…" "Det gick inte att spara den beskurna bilden." @@ -44,11 +44,15 @@ "Välj ett album" "Välj en grupp" "Använd bild som" + + "Bakgrund ställs in ..." "Bakgrund" "Ta bort" - - + + "Ta bort markerat objekt?" + "Radera markerade objekt?" + "Bekräfta" "Avbryt" "Dela" @@ -94,7 +98,6 @@ "Ingen plats" "Det gick inte att identifiera vissa platser på grund av nätverksproblem." "Det gick inte att hämta bilderna i albumet. Försök igen senare." - "Det gick inte att hämta albumlistan. Försök igen senare." "Endast bilder" "Endast video" "Bilder och videor" diff --git a/res/values-sw/strings.xml b/res/values-sw/strings.xml index d8b90fdf8..9acfa0885 100644 --- a/res/values-sw/strings.xml +++ b/res/values-sw/strings.xml @@ -32,8 +32,8 @@ "Haikuweza kupakia picha" "Hakuna kijipicha" "Anza tena" - - + "Sawa" + "Sawa" "Gusa sura ili kuanza." "Inahifadhi picha…" "Haiwezi kuhifadhi picha iliyopogolewa." @@ -44,11 +44,15 @@ "Chagua albamu" "Chagua kikundi" "Weka picha kama" + + "Inaweka karatasi ya ukuta..." "Mandhari" "Futa" - - + + "Futa kipengee kilichoteuliwa?" + "Futa vipengee vilivyoteuliwa?" + "Thibitisha" "Ghairi" "Shiriki" @@ -97,7 +101,6 @@ "Hakuna Mahali" "Baadhi ya maeneo haikuweza kutambuliwa kutokana na matatizo ya mtandao." "Haikuwezi kupakua picha zilizo kwenye albamu hii. Jaribu tena baadaye." - "Haikuweza kupakua orodha ya albamu. Jaribu tena baadaye." "Picha tu" "Video tu" "Picha & video" diff --git a/res/values-th/strings.xml b/res/values-th/strings.xml index ad7079ec6..b163d1972 100644 --- a/res/values-th/strings.xml +++ b/res/values-th/strings.xml @@ -32,8 +32,8 @@ "ไม่สามารถโหลดภาพ" "ไม่มีภาพขนาดย่อ" "เริ่มต้นใหม่" - - + "ตกลง" + "ตกลง" "แตะใบหน้าเพื่อเริ่มต้น" "กำลังบันทึกภาพ..." "ไม่สามารถบันทึกภาพที่ตัดได้" @@ -44,11 +44,15 @@ "เลือกอัลบั้ม" "เลือกกลุ่ม" "ตั้งค่าภาพเป็น" + + "กำลังตั้งค่าวอลเปเปอร์..." "วอลเปเปอร์" "ลบ" - - + + "ลบรายการที่เลือกหรือไม่" + "ลบรายการที่เลือกหรือไม่" + "ยืนยัน" "ยกเลิก" "แบ่งปัน" @@ -94,7 +98,6 @@ "ไม่มีสถานที่" "ไม่สามารถระบุบางตำแหน่งได้เนื่องจากปัญหาเกี่ยวกับเครือข่าย" "ไม่สามารถดาวน์โหลดรูปภาพในอัลบั้มนี้ โปรดลองอีกครั้งในภายหลัง" - "ไม่สามารถดาวน์โหลดรายการอัลบั้ม โปรดลองอีกครั้งในภายหลัง" "เฉพาะภาพ" "เฉพาะวิดีโอ" "ภาพและวิดีโอ" diff --git a/res/values-tl/strings.xml b/res/values-tl/strings.xml index f8be4ba58..77babe8b8 100644 --- a/res/values-tl/strings.xml +++ b/res/values-tl/strings.xml @@ -32,8 +32,8 @@ "Hindi ma-load ang larawan" "Walang thumbnail" "Magsimula na" - - + "OK" + "OK" "Pumindot ng mukha upang magsimula." "Nagse-save ng larawan..." "Hindi mai-save ang na-crop na larawan." @@ -44,11 +44,15 @@ "Pumili ng album" "Pumili ng pangkat" "Itakda ang larawan bilang" + + "Itinatakda ang wallpaper…" "Wallpaper" "Tanggalin" - - + + "Tanggalin ang napiling item?" + "Tanggalin mga napiling item?" + "Kumpirmahin" "Kanselahin" "Ibahagi" @@ -94,7 +98,6 @@ "Walang lokasyon" "Hindi matukoy ang ilang mga lokasyon dahil sa mga problema sa network." "Hindi ma-download ang mga larawan sa album na ito. Pakisubukang muli sa ibang pagkakataon." - "Hindi ma-download ang listahan ng mga album. Pakisubukang muli sa ibang pagkakataon." "Mga larawan lamang" "Mga video lamang" "Mga larawan & video" diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml index 810ed8968..2a6ac2d87 100644 --- a/res/values-tr/strings.xml +++ b/res/values-tr/strings.xml @@ -32,8 +32,8 @@ "Resim yüklenemedi" "Küçük resim yok" "Başlat" - - + "Tamam" + "Tamam" "Başlamak için bir yüze dokunun." "Resim kaydediliyor..." "Kırpılmış resim kaydedilemedi." @@ -44,11 +44,15 @@ "Albüm seçin" "Grup seçin" "Resmi şu şekilde ayarla:" + + "Duvar kağıdı ayarlanıyor..." "Duvar Kağıdı" "Sil" - - + + "Seçilen öğe silinsin mi?" + "Seçilen öğeler silinsin mi?" + "Onayla" "İptal" "Paylaş" @@ -94,7 +98,6 @@ "Konum bilgisi yok" "Ağ sorunları nedeniyle bazı konumlar tanımlanamadı." "Bu albümdeki fotoğraflar indirilemedi. Daha sonra tekrar deneyin." - "Albüm listesi indirilemedi. Daha sonra tekrar deneyin." "Yalnızca resimler" "Yalnızca videolar" "Resimler ve videolar" diff --git a/res/values-uk/strings.xml b/res/values-uk/strings.xml index 3c905cf2c..e04db9312 100644 --- a/res/values-uk/strings.xml +++ b/res/values-uk/strings.xml @@ -32,8 +32,8 @@ "Не вдалося завантажити зображення" "Немає ескізу" "Почати знову" - - + "OK" + "ОК" "Торкніться обличчя, щоб почати." "Зберіг-ня фото…" "Не вдалося зберегти обрізане зображення." @@ -44,11 +44,15 @@ "Виберіть альбом" "Виберіть групу" "Устан. фото як" + + "Встановлення фонового малюнка..." "Фоновий мал." "Видалити" - - + + "Видалити вибраний елемент?" + "Видалити вибрані елементи?" + "Підтвердити" "Скасувати" "Надісл." @@ -94,7 +98,6 @@ "Без місцезнаходження" "Не вдалося визначити деякі місцезнаходження через проблеми з мережею." "Не вдалося завантажити фото цього альбому. Повторіть спробу пізніше." - "Не вдалося завантажити список альбомів. Повторіть спробу пізніше." "Лише зображення" "Лише відео" "Зображення й відео" diff --git a/res/values-vi/strings.xml b/res/values-vi/strings.xml index 941ae20c1..c9e1117e8 100644 --- a/res/values-vi/strings.xml +++ b/res/values-vi/strings.xml @@ -32,8 +32,8 @@ "Không thể tải hình ảnh" "Không có hình thu nhỏ" "Bắt đầu lại" - - + "OK" + "OK" "Chạm vào một khuôn mặt để bắt đầu." "Đang lưu ảnh…" "Không thể lưu hình ảnh được cắt." @@ -44,11 +44,15 @@ "Chọn album" "Chọn nhóm" "Đặt ảnh làm" + + "Đang đặt hình nền..." "Hình nền" "Xóa" - - + + "Xóa mục đã chọn?" + "Xóa các mục đã chọn?" + "Xác nhận" "Hủy" "Chia sẻ" @@ -94,7 +98,6 @@ "Không có vị trí nào" "Không thể xác định một số vị trí do sự cố mạng." "Không thể tải xuống ảnh trong album này. Hãy thử lại sau." - "Không thể tải xuống danh sách album. Hãy thử lại sau." "Chỉ hình ảnh" "Chỉ video" "Hình ảnh & video" diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index af34d2849..62e9920f8 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -32,8 +32,8 @@ "无法加载此图片" "无缩略图" "重新开始" - - + "确定" + "确定" "触摸一张脸开始裁剪。" "正在保存照片..." "无法保存经过裁剪的图片。" @@ -44,11 +44,15 @@ "选择相册" "选择群组" "将照片设置为" + + "正在设置壁纸..." "壁纸" "删除" - - + + "要删除所选项吗?" + "要删除所选项吗?" + "确认" "取消" "分享" @@ -94,15 +98,14 @@ "无位置信息" "出现网络问题,系统无法识别某些位置。" "无法下载此相册中的照片,请稍后重试。" - "无法下载相册列表,请稍后重试。" "仅限图片" "仅限视频" "图片和视频" - "照片库" - "无照片。" + "照片" + "没有照片。" "经过裁剪的图片已保存至“%s”。" "没有可用的相册。" - "没有可用的图片/视频。" + "没有图片/视频。" "帖子" "允许离线状态下使用" "刷新" diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml index 97b6b3550..6786c2ed5 100644 --- a/res/values-zh-rTW/strings.xml +++ b/res/values-zh-rTW/strings.xml @@ -32,8 +32,8 @@ "無法載入圖片" "無縮圖" "重新開始" - - + "確定" + "確定" "輕觸臉孔即可開始。" "正在儲存相片..." "無法儲存裁剪的圖片。" @@ -44,11 +44,15 @@ "選取相簿" "選取群組" "將相片設為" + + "正在設定桌布..." "桌布" "刪除" - - + + "刪除選取的項目?" + "刪除選取的項目?" + "確認" "取消" "分享" @@ -94,7 +98,6 @@ "無位置資訊" "網路發生問題,因此無法辨識部分位置。" "無法下載這個相簿中的相片,請稍後再試。" - "無法下載相簿清單,請稍後再試。" "僅顯示圖片" "僅顯示影片" "圖片和影片" diff --git a/res/values-zu/strings.xml b/res/values-zu/strings.xml index c59cfa8c0..c23c75796 100644 --- a/res/values-zu/strings.xml +++ b/res/values-zu/strings.xml @@ -32,8 +32,8 @@ "Ayikwazanga ukulayisha umfanekiso" "Asikho isithoombe esincane" "Qala phansi" - - + "Kulungile" + "KULUNGILE" "Cindezela ubuso ukuze uqale." "Ilondoloza isithombe..." "Yehlulekile ukulondoloza umfanekiso onqampuniwe." @@ -44,11 +44,15 @@ "Khetha i-albhamu" "Khetha iqembu" "Hlela isithombe njenge" + + "Isetha iphephadonga..." "Iphephadonga" "Susa" - - + + "Sula into ekhethiwe?" + "Sula izinto ezikhethiwe?" + "Qinisekisa" "Khansela" "Yabelana" @@ -94,7 +98,6 @@ "Ayikho indawo" "Ezinye izindawo azikwazanga ukubonakala ngenxa yezinkinga zokuxhumeka kuhleloxhumano" "Ayikwazanga ukulanda izithombe kule albhamu. Zama ngemva kwesikhashana." - "Ayikwazanga ukulanda uhlu lwama-albhamu. Zama futhi ngemva kwesikhashana." "Izithombe kuphela" "Amavidiyo kuphela" "Izithombe namavidiyo" -- GitLab From d19f7d5806e4f23a76657146db612153eab30a66 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Tue, 29 May 2012 10:58:13 -0700 Subject: [PATCH 021/763] Import translations. DO NOT MERGE Change-Id: Ib9ae85b5013a12c2d2ea10ea7b48d0636797cefd --- res/values-am/strings.xml | 3 +-- res/values-ca/strings.xml | 5 ++--- res/values-da/strings.xml | 2 +- res/values-el/strings.xml | 3 +-- res/values-en-rGB/strings.xml | 3 +-- res/values-es-rUS/strings.xml | 4 ++-- res/values-es/strings.xml | 3 +-- res/values-fr/strings.xml | 2 +- res/values-iw/strings.xml | 3 +-- res/values-sw/strings.xml | 3 +-- res/values-th/strings.xml | 3 +-- 11 files changed, 13 insertions(+), 21 deletions(-) diff --git a/res/values-am/strings.xml b/res/values-am/strings.xml index e62624c68..b88187f69 100644 --- a/res/values-am/strings.xml +++ b/res/values-am/strings.xml @@ -44,8 +44,7 @@ "አልበም ምረጥ" "ቡድን ምረጥ" "ምስል እንደ አዘጋጅ" - - + "ልጣፍ አዘጋጅ" "ልጣፍ በማቀናበር ላይ...." "ልጣፍ" "ሰርዝ" diff --git a/res/values-ca/strings.xml b/res/values-ca/strings.xml index a566c2408..ea13a589e 100644 --- a/res/values-ca/strings.xml +++ b/res/values-ca/strings.xml @@ -44,14 +44,13 @@ "Selecciona un àlbum" "Selecciona un grup" "Defineix la imatge com a" - - + "Defineix el fons de pantalla" "S\'està establint el fons de pantalla..." "Fons de pantalla" "Suprimeix" "Vols supr. l\'element selecc.?" - "Vols supr. l\'element selecc.?" + "Vols supr. els elements sel.?" "Confirma" "Cancel·la" diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml index 6675637f0..feab24d03 100644 --- a/res/values-da/strings.xml +++ b/res/values-da/strings.xml @@ -50,7 +50,7 @@ "Tapet" "Slet" - "Vil du slette valgte element?" + "Vil du slette det valgte element?" "Vil du slette valgte elementer?" "Bekræft" diff --git a/res/values-el/strings.xml b/res/values-el/strings.xml index f63e0a8d0..7435abe9a 100644 --- a/res/values-el/strings.xml +++ b/res/values-el/strings.xml @@ -44,8 +44,7 @@ "Επιλογή λευκώματος" "Επιλογή ομάδας" "Ορισμός εικόνας ως" - - + "Ορισμός ταπετσαρίας" "Ορισμός ταπετσαρίας..." "Ταπετσαρία" "Διαγραφή" diff --git a/res/values-en-rGB/strings.xml b/res/values-en-rGB/strings.xml index 02e3d20c3..02b496763 100644 --- a/res/values-en-rGB/strings.xml +++ b/res/values-en-rGB/strings.xml @@ -44,8 +44,7 @@ "Select album" "Select group" "Set picture as" - - + "Set wallpaper" "Setting wallpaper..." "Wallpaper" "Delete" diff --git a/res/values-es-rUS/strings.xml b/res/values-es-rUS/strings.xml index 35fb8e121..8f792c86f 100644 --- a/res/values-es-rUS/strings.xml +++ b/res/values-es-rUS/strings.xml @@ -50,8 +50,8 @@ "Papel tapiz" "Eliminar" - "¿Eliminar elemento selec.?" - "¿Eliminar elementos selecs.?" + "¿Eliminar elemento?" + "¿Eliminar elementos?" "Confirmar" "Cancelar" diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index cc8e57fc2..eb473ab13 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -44,8 +44,7 @@ "Seleccionar álbum" "Seleccionar grupo" "Establecer imagen como" - - + "Establecer fondo de pantalla" "Estableciendo fondo de pantalla..." "Fondo de pantalla" "Borrar" diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index 85af46ddf..e674a9b63 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -51,7 +51,7 @@ "Supprimer" "Supprimer élément sélectionné ?" - "Supprimer éléments sélectionnés ?" + "Suppr. éléments sélectionnés ?" "Confirmer" "Annuler" diff --git a/res/values-iw/strings.xml b/res/values-iw/strings.xml index 8a68468b2..c62aad437 100644 --- a/res/values-iw/strings.xml +++ b/res/values-iw/strings.xml @@ -44,8 +44,7 @@ "בחר אלבום" "בחר קבוצה" "הגדר תמונה בתור" - - + "הגדר טפט" "מגדיר טפט..." "טפט" "מחק" diff --git a/res/values-sw/strings.xml b/res/values-sw/strings.xml index 9acfa0885..772ce6320 100644 --- a/res/values-sw/strings.xml +++ b/res/values-sw/strings.xml @@ -44,8 +44,7 @@ "Chagua albamu" "Chagua kikundi" "Weka picha kama" - - + "Weka mandhari" "Inaweka karatasi ya ukuta..." "Mandhari" "Futa" diff --git a/res/values-th/strings.xml b/res/values-th/strings.xml index b163d1972..2095b9b4b 100644 --- a/res/values-th/strings.xml +++ b/res/values-th/strings.xml @@ -44,8 +44,7 @@ "เลือกอัลบั้ม" "เลือกกลุ่ม" "ตั้งค่าภาพเป็น" - - + "ตั้งค่าวอลเปเปอร์" "กำลังตั้งค่าวอลเปเปอร์..." "วอลเปเปอร์" "ลบ" -- GitLab From b4a2ff68cd17b8778e5bcd54f4f9f5e8b9da1de4 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Tue, 29 May 2012 11:56:33 -0700 Subject: [PATCH 022/763] Import translations. DO NOT MERGE Change-Id: Ifff95b969b5388df20cd834f81cab4a11ed655bf --- res/values-cs/photoeditor_strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values-cs/photoeditor_strings.xml b/res/values-cs/photoeditor_strings.xml index 0349bd25b..187c236e5 100644 --- a/res/values-cs/photoeditor_strings.xml +++ b/res/values-cs/photoeditor_strings.xml @@ -20,7 +20,7 @@ "Fotografii nelze načíst" "Upravená fotografie nelze uložit" "Upravená fotografie uložena do složky %s." - "Zrušit neuložené změny?" + "Zahodit neuložené změny?" "Ano" "ULOŽIT" "Automat. oprava" -- GitLab From 9dbf1623388bd5c3d7e85d3607b424b9c9744a23 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Wed, 30 May 2012 10:10:30 -0700 Subject: [PATCH 023/763] Import translations. DO NOT MERGE Change-Id: I57a2c1fcaa457e650abd4546cf49b764d05036be --- res/values-ar/strings.xml | 3 +-- res/values-es-rUS/strings.xml | 3 +-- res/values-et/strings.xml | 3 +-- res/values-fa/strings.xml | 3 +-- res/values-in/strings.xml | 3 +-- res/values-ko/strings.xml | 3 +-- res/values-lt/strings.xml | 3 +-- res/values-lv/strings.xml | 3 +-- res/values-ms/strings.xml | 3 +-- res/values-pl/strings.xml | 3 +-- res/values-pt/strings.xml | 3 +-- res/values-tl/strings.xml | 3 +-- res/values-uk/strings.xml | 3 +-- res/values-vi/strings.xml | 3 +-- res/values-zu/strings.xml | 3 +-- 15 files changed, 15 insertions(+), 30 deletions(-) diff --git a/res/values-ar/strings.xml b/res/values-ar/strings.xml index 4417bc2f6..fe3a2111a 100644 --- a/res/values-ar/strings.xml +++ b/res/values-ar/strings.xml @@ -44,8 +44,7 @@ "تحديد ألبوم" "تحديد مجموعة" "تعيين الصورة كـ" - - + "تعيين خلفية" "جارٍ تعيين الخلفية..." "الخلفية" "حذف" diff --git a/res/values-es-rUS/strings.xml b/res/values-es-rUS/strings.xml index 8f792c86f..cf800b72f 100644 --- a/res/values-es-rUS/strings.xml +++ b/res/values-es-rUS/strings.xml @@ -44,8 +44,7 @@ "Seleccionar álbum" "Seleccionar un grupo" "Establecer imagen como" - - + "Establecer como fondo de pantalla" "Estableciendo fondo de pantalla..." "Papel tapiz" "Eliminar" diff --git a/res/values-et/strings.xml b/res/values-et/strings.xml index 3f669f090..6ae9bba74 100644 --- a/res/values-et/strings.xml +++ b/res/values-et/strings.xml @@ -44,8 +44,7 @@ "Albumi valimine" "Rühma valimine" "Seadke pilt kui" - - + "Taustapildiks määr." "Taustapildi määramine ..." "Taustapilt" "Kustuta" diff --git a/res/values-fa/strings.xml b/res/values-fa/strings.xml index 0622954a9..c51d8c42f 100644 --- a/res/values-fa/strings.xml +++ b/res/values-fa/strings.xml @@ -44,8 +44,7 @@ "آلبوم را انتخاب کنید" "انتخاب گروه" "تنظیم تصویر بعنوان" - - + "تنظیم تصویر زمینه" "تنظیم تصویر زمینه..." "تصویر زمینه" "حذف" diff --git a/res/values-in/strings.xml b/res/values-in/strings.xml index a62697ca7..d79aa3320 100644 --- a/res/values-in/strings.xml +++ b/res/values-in/strings.xml @@ -44,8 +44,7 @@ "Pilih album" "Pilih grup" "Setel gambar sebagai" - - + "Setel wallpaper" "Menyetel wallpaper..." "Wallpaper" "Hapus" diff --git a/res/values-ko/strings.xml b/res/values-ko/strings.xml index dd6967323..4ac2b3713 100644 --- a/res/values-ko/strings.xml +++ b/res/values-ko/strings.xml @@ -44,8 +44,7 @@ "앨범 선택" "그룹 선택" "사진을 다음으로 설정" - - + "배경화면 설정" "배경화면을 설정하는 중..." "배경화면" "삭제" diff --git a/res/values-lt/strings.xml b/res/values-lt/strings.xml index 57d615a0f..95f1a8ff9 100644 --- a/res/values-lt/strings.xml +++ b/res/values-lt/strings.xml @@ -44,8 +44,7 @@ "Pasirinkti albumą" "Pasirinkti grupę" "Nustatyti paveikslėlį kaip" - - + "Nustat. darbal. foną" "Nustatomas darbalaukio fonas…" "Darbalaukio fonas" "Ištrinti" diff --git a/res/values-lv/strings.xml b/res/values-lv/strings.xml index cb17e5e43..c3e47b41d 100644 --- a/res/values-lv/strings.xml +++ b/res/values-lv/strings.xml @@ -44,8 +44,7 @@ "Albuma atlase" "Atlasiet grupu" "Iestatīt attēlu kā:" - - + "Iestatīt fona tapeti" "Notiek fona tapetes iestatīšana..." "Fona tapete" "Dzēst" diff --git a/res/values-ms/strings.xml b/res/values-ms/strings.xml index ee758ed86..8349896d1 100644 --- a/res/values-ms/strings.xml +++ b/res/values-ms/strings.xml @@ -44,8 +44,7 @@ "Pilih album" "Pilih kumpulan" "Tetapkan gambar sebagai" - - + "Tetapkan kertas dinding" "Menetapkan kertas dinding…" "Kertas dinding" "Padam" diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml index 691bbd04e..5b6ca5310 100644 --- a/res/values-pl/strings.xml +++ b/res/values-pl/strings.xml @@ -44,8 +44,7 @@ "Wybierz album" "Wybierz grupę" "Ustaw zdjęcie jako" - - + "Ustaw tapetę" "Ustawianie tapety…" "Tapeta" "Usuń" diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml index a0485ee99..b7a0140ef 100644 --- a/res/values-pt/strings.xml +++ b/res/values-pt/strings.xml @@ -44,8 +44,7 @@ "Selecionar álbum" "Selecionar grupo" "Definir imagem como" - - + "Definir plano de fundo" "Definindo plano de fundo..." "Plano de fundo" "Excluir" diff --git a/res/values-tl/strings.xml b/res/values-tl/strings.xml index 77babe8b8..d376a02ff 100644 --- a/res/values-tl/strings.xml +++ b/res/values-tl/strings.xml @@ -44,8 +44,7 @@ "Pumili ng album" "Pumili ng pangkat" "Itakda ang larawan bilang" - - + "Itakda ang wallpaper" "Itinatakda ang wallpaper…" "Wallpaper" "Tanggalin" diff --git a/res/values-uk/strings.xml b/res/values-uk/strings.xml index e04db9312..23f67321c 100644 --- a/res/values-uk/strings.xml +++ b/res/values-uk/strings.xml @@ -44,8 +44,7 @@ "Виберіть альбом" "Виберіть групу" "Устан. фото як" - - + "Устан. фон. зображ." "Встановлення фонового малюнка..." "Фоновий мал." "Видалити" diff --git a/res/values-vi/strings.xml b/res/values-vi/strings.xml index c9e1117e8..335646ae9 100644 --- a/res/values-vi/strings.xml +++ b/res/values-vi/strings.xml @@ -44,8 +44,7 @@ "Chọn album" "Chọn nhóm" "Đặt ảnh làm" - - + "Đặt hình nền" "Đang đặt hình nền..." "Hình nền" "Xóa" diff --git a/res/values-zu/strings.xml b/res/values-zu/strings.xml index c23c75796..7ebfa3a09 100644 --- a/res/values-zu/strings.xml +++ b/res/values-zu/strings.xml @@ -44,8 +44,7 @@ "Khetha i-albhamu" "Khetha iqembu" "Hlela isithombe njenge" - - + "Setha isithombe sangemuva" "Isetha iphephadonga..." "Iphephadonga" "Susa" -- GitLab From b03186a84d5f13e5d3541264632b2d1f176dc40e Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Thu, 31 May 2012 10:59:13 -0700 Subject: [PATCH 024/763] Import translations. DO NOT MERGE Change-Id: I2bcbcd25d41212cb4e81b1e2f621f635cb1d9c8a --- res/values-af/strings.xml | 3 +-- res/values-cs/strings.xml | 7 +++---- res/values-da/strings.xml | 3 +-- res/values-it/strings.xml | 3 +-- res/values-ru/strings.xml | 3 +-- res/values-sv/strings.xml | 3 +-- res/values-zh-rCN/strings.xml | 7 +++---- 7 files changed, 11 insertions(+), 18 deletions(-) diff --git a/res/values-af/strings.xml b/res/values-af/strings.xml index 315bdcc01..e3c1e8c5a 100644 --- a/res/values-af/strings.xml +++ b/res/values-af/strings.xml @@ -44,8 +44,7 @@ "Kies album" "Kies groep" "Stel prent as" - - + "Stel muurpapier" "Stel tans muurpapier in..." "Muurpapier" "Vee uit" diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml index 42b652b52..16c0e82d7 100644 --- a/res/values-cs/strings.xml +++ b/res/values-cs/strings.xml @@ -44,8 +44,7 @@ "Vybrat album" "Vybrat skupinu" "Nastavit fotografii jako" - - + "Nastavit tapetu" "Nastavování tapety..." "Tapeta" "Smazat" @@ -126,9 +125,9 @@ "Model" "Blesk" "Clona" - "Ohnisk. vzdál." + "Ohnisk. vzdálenost" "Vyvážení bílé" - "Doba expozice" + "Expoziční čas" "ISO" "mm" "Ručně" diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml index feab24d03..2fcb2fcef 100644 --- a/res/values-da/strings.xml +++ b/res/values-da/strings.xml @@ -44,8 +44,7 @@ "Vælg album" "Vælg gruppe" "Angiv billedet som" - - + "Angiv baggrund" "Angiver baggrund..." "Tapet" "Slet" diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index ceabf3fa6..88d57ab16 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -44,8 +44,7 @@ "Seleziona album" "Seleziona gruppo" "Imposta foto come" - - + "Imposta sfondo" "Impostazione sfondo..." "Sfondo" "Elimina" diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index d7aff4f84..a9a780075 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -44,8 +44,7 @@ "Выбрать альбомы" "Выбрать группы" "Установить картинку как" - - + "Установить обои" "Установка обоев..." "Обои" "Удалить" diff --git a/res/values-sv/strings.xml b/res/values-sv/strings.xml index 895ffee1e..c3a0efae5 100644 --- a/res/values-sv/strings.xml +++ b/res/values-sv/strings.xml @@ -44,8 +44,7 @@ "Välj ett album" "Välj en grupp" "Använd bild som" - - + "Välj bakgrund" "Bakgrund ställs in ..." "Bakgrund" "Ta bort" diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index 62e9920f8..917e990dc 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -44,14 +44,13 @@ "选择相册" "选择群组" "将照片设置为" - - + "设为壁纸" "正在设置壁纸..." "壁纸" "删除" - "要删除所选项吗?" - "要删除所选项吗?" + "要删除所选内容吗?" + "要删除所选内容吗?" "确认" "取消" -- GitLab From 23b602e709f1551acdb7cf2caaf5b7838b567d15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Lund=C3=A9n?= Date: Thu, 31 May 2012 23:51:07 +0200 Subject: [PATCH 025/763] Gallery2: Use ICS alert drawable Same bug here. It's using the old compability drawable instead of the Holo theme one. Change-Id: Ia84ce1d305ee63fc6bc1fdb407a91b3421842eb1 --- src/com/android/gallery3d/app/AbstractGalleryActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/android/gallery3d/app/AbstractGalleryActivity.java b/src/com/android/gallery3d/app/AbstractGalleryActivity.java index d25f60ebe..9500fff7a 100644 --- a/src/com/android/gallery3d/app/AbstractGalleryActivity.java +++ b/src/com/android/gallery3d/app/AbstractGalleryActivity.java @@ -142,7 +142,7 @@ public class AbstractGalleryActivity extends Activity implements GalleryActivity } }; mAlertDialog = new AlertDialog.Builder(this) - .setIcon(android.R.drawable.ic_dialog_alert) + .setIconAttribute(android.R.attr.alertDialogIcon) .setTitle("No Storage") .setMessage("No external storage available.") .setNegativeButton(android.R.string.cancel, onClick) -- GitLab From 9ab4ff1c34a5a825c1e203de12c6dc9e10a048cf Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Fri, 1 Jun 2012 10:19:20 -0700 Subject: [PATCH 026/763] Import translations. DO NOT MERGE Change-Id: Ia4cc33ee514ce169636fda6e8007389ac60c8e17 --- res/values-be/strings.xml | 3 +-- res/values-de/strings.xml | 3 +-- res/values-fi/strings.xml | 3 +-- res/values-fr/strings.xml | 3 +-- res/values-hi/strings.xml | 3 +-- res/values-hr/strings.xml | 3 +-- res/values-hu/strings.xml | 3 +-- res/values-ja/strings.xml | 3 +-- res/values-nb/strings.xml | 3 +-- res/values-nl/strings.xml | 3 +-- res/values-ro/strings.xml | 3 +-- res/values-sk/strings.xml | 3 +-- res/values-sl/strings.xml | 3 +-- res/values-sr/strings.xml | 3 +-- res/values-tr/strings.xml | 3 +-- res/values-zh-rTW/strings.xml | 3 +-- 16 files changed, 16 insertions(+), 32 deletions(-) diff --git a/res/values-be/strings.xml b/res/values-be/strings.xml index 61c6a2cc4..14547042f 100644 --- a/res/values-be/strings.xml +++ b/res/values-be/strings.xml @@ -44,8 +44,7 @@ "Выбраць альбом" "Выбар групы" "Усталяваць малюнак як" - - + "Усталяваць шпалеры" "Усталяванне шпалер..." "Шпалеры" "Выдаліць" diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index e7c6efbd3..cce0dd709 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -44,8 +44,7 @@ "Album auswählen" "Gruppe auswählen" "Bild festlegen als" - - + "Hintergrund wählen" "Hintergrund wird festgelegt..." "Hintergrund" "Löschen" diff --git a/res/values-fi/strings.xml b/res/values-fi/strings.xml index 4b91ad448..c1e796907 100644 --- a/res/values-fi/strings.xml +++ b/res/values-fi/strings.xml @@ -44,8 +44,7 @@ "Valitse albumi" "Valitse ryhmä" "Aseta kuva" - - + "Aseta taustakuva" "Asetetaan taustakuvaa..." "taustakuvaksi" "Poista" diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index e674a9b63..5a5d4ca8e 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -44,8 +44,7 @@ "Sélectionner album" "Sélectionnez groupe" "Utiliser l\'image comme" - - + "Définir fond d\'écran" "Définition du fond d\'écran…" "Fond d\'écran" "Supprimer" diff --git a/res/values-hi/strings.xml b/res/values-hi/strings.xml index b8329ae71..0db281dd9 100644 --- a/res/values-hi/strings.xml +++ b/res/values-hi/strings.xml @@ -44,8 +44,7 @@ "एल्बम का चयन करें" "समूह का चयन करें" "चित्र इस रूप में सेट करें" - - + "वॉलपेपर सेट करें" "वॉलपेपर सेट कर रहा है..." "वॉलपेपर" "हटाएं" diff --git a/res/values-hr/strings.xml b/res/values-hr/strings.xml index 4a4c4abef..ccc385692 100644 --- a/res/values-hr/strings.xml +++ b/res/values-hr/strings.xml @@ -44,8 +44,7 @@ "Odaberi album" "Odabir grupe" "Postavi sliku kao" - - + "Postavljanje pozadine" "Postavljanje pozadinske slike…" "Pozadinska slika" "Izbriši" diff --git a/res/values-hu/strings.xml b/res/values-hu/strings.xml index 1cc970370..e0d360bb6 100644 --- a/res/values-hu/strings.xml +++ b/res/values-hu/strings.xml @@ -44,8 +44,7 @@ "Album kiválasztása" "Csoport kiválasztása" "Kép beállítása, mint" - - + "Háttérkép beállítása" "Háttérkép beállítása..." "Háttérkép" "Törlés" diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml index a1d8c8006..8cef890a8 100644 --- a/res/values-ja/strings.xml +++ b/res/values-ja/strings.xml @@ -44,8 +44,7 @@ "アルバムを選択" "グループの選択" "登録" - - + "壁紙を設定" "壁紙を設定しています..." "壁紙" "削除" diff --git a/res/values-nb/strings.xml b/res/values-nb/strings.xml index 9dd8e27ff..37874fea9 100644 --- a/res/values-nb/strings.xml +++ b/res/values-nb/strings.xml @@ -44,8 +44,7 @@ "Velg album" "Valg av gruppe" "Angi bilde som" - - + "Angi bakgrunnsbilde" "Angir bakgrunn …" "Bakgrunnsbilde" "Slett" diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml index cad39569a..f28c90d26 100644 --- a/res/values-nl/strings.xml +++ b/res/values-nl/strings.xml @@ -44,8 +44,7 @@ "Album selecteren" "Groep selecteren" "Foto instellen als" - - + "Achtergrond inst." "Achtergrond instellen..." "Achtergrond" "Verwijderen" diff --git a/res/values-ro/strings.xml b/res/values-ro/strings.xml index efcf779f8..d10bf6fea 100644 --- a/res/values-ro/strings.xml +++ b/res/values-ro/strings.xml @@ -44,8 +44,7 @@ "Selectaţi un album" "Selectaţi un grup" "Setaţi fotografia ca" - - + "Setaţi imag. fundal" "Se setează imaginea de fundal..." "Imagine de fundal" "Ştergeţi" diff --git a/res/values-sk/strings.xml b/res/values-sk/strings.xml index e87387001..bd914b985 100644 --- a/res/values-sk/strings.xml +++ b/res/values-sk/strings.xml @@ -44,8 +44,7 @@ "Vybrať album" "Vybrať skupinu" "Fotografia bude použitá ako" - - + "Nastaviť tapetu" "Prebieha nastavenie tapety..." "Tapeta" "Odstrániť" diff --git a/res/values-sl/strings.xml b/res/values-sl/strings.xml index 8446a6c6f..fb2012033 100644 --- a/res/values-sl/strings.xml +++ b/res/values-sl/strings.xml @@ -44,8 +44,7 @@ "Izberite album" "Izberite skupino" "Nastavi sliko kot" - - + "Nastavi ozadje" "Nastavljanje slike za ozadje ..." "Slika za ozadje" "Izbriši" diff --git a/res/values-sr/strings.xml b/res/values-sr/strings.xml index 317ddc70f..ad14c081f 100644 --- a/res/values-sr/strings.xml +++ b/res/values-sr/strings.xml @@ -44,8 +44,7 @@ "Избор албума" "Избор групе" "Постављање слике као" - - + "Подешавање позадине" "Подешавање позадине..." "Позадина" "Избриши" diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml index 2a6ac2d87..190dc46ec 100644 --- a/res/values-tr/strings.xml +++ b/res/values-tr/strings.xml @@ -44,8 +44,7 @@ "Albüm seçin" "Grup seçin" "Resmi şu şekilde ayarla:" - - + "Duvar kağıdını ayarla" "Duvar kağıdı ayarlanıyor..." "Duvar Kağıdı" "Sil" diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml index 6786c2ed5..ac7de4f4a 100644 --- a/res/values-zh-rTW/strings.xml +++ b/res/values-zh-rTW/strings.xml @@ -44,8 +44,7 @@ "選取相簿" "選取群組" "將相片設為" - - + "設定桌布" "正在設定桌布..." "桌布" "刪除" -- GitLab From 1e8204e717b02f7b40933ea6b67ab221ee440cf5 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Mon, 4 Jun 2012 14:45:24 -0700 Subject: [PATCH 027/763] Import translations. DO NOT MERGE Change-Id: I630c967050e27c228f1f05333cc2a3590b3eadcb --- res/values-bg/strings.xml | 3 +-- res/values-cs/strings.xml | 2 +- res/values-pt-rPT/strings.xml | 3 +-- res/values-rm/strings.xml | 21 +++++++-------------- 4 files changed, 10 insertions(+), 19 deletions(-) diff --git a/res/values-bg/strings.xml b/res/values-bg/strings.xml index 4e549f8ca..da21938b5 100644 --- a/res/values-bg/strings.xml +++ b/res/values-bg/strings.xml @@ -44,8 +44,7 @@ "Изберете албум" "Изберете група" "Задаване на снимката като" - - + "Задаване на тапет" "Тапетът се задава..." "Тапет" "Изтриване" diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml index 16c0e82d7..9cb883554 100644 --- a/res/values-cs/strings.xml +++ b/res/values-cs/strings.xml @@ -135,7 +135,7 @@ "S bleskem" "Bez blesku" - "Zpřístupnění alba offline." + "Zpřístupňování alba offline" "Zpřístupnění alb offline" "Tato položka je uložena v místním úložišti a je k dispozici offline." diff --git a/res/values-pt-rPT/strings.xml b/res/values-pt-rPT/strings.xml index 50c94292b..fa0288a4b 100644 --- a/res/values-pt-rPT/strings.xml +++ b/res/values-pt-rPT/strings.xml @@ -44,8 +44,7 @@ "Selecionar álbum" "Selecionar grupo" "Definir imagem como" - - + "Definir imagem fundo" "A definir imagem de fundo…" "Imagem de fundo" "Eliminar" diff --git a/res/values-rm/strings.xml b/res/values-rm/strings.xml index ffb6ef799..c85a7de64 100644 --- a/res/values-rm/strings.xml +++ b/res/values-rm/strings.xml @@ -20,8 +20,7 @@ "Rom da maletgs" "%1$02d:%2$02d" "%1$d:%2$02d:%3$02d" - - + "Films" "Chargiar il video…" @@ -39,12 +38,10 @@ "Cumenzar" - - + "Memorisar" - - + "Smatgai sin ina fatscha per cumenzar." "Memorisar il maletg..." @@ -62,8 +59,7 @@ "Definir il maletg sco" - - + "La culissa vegn configurada. Spetgai per plaschair..." "Culissa" "Stizzar" @@ -72,10 +68,8 @@ "Interrumper" "Cundivider" - - - - + "Selecziunar tut" + "Deselecziunar tut" "Preschentaziun da dia" "Detagls" @@ -107,8 +101,7 @@ "Definir sco" - - + "Impussibel da reproducir il video" -- GitLab From 3c61e37e7cd6118bc8835ea16597162c2a8a00e9 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Tue, 5 Jun 2012 09:39:40 -0700 Subject: [PATCH 028/763] Import translations. DO NOT MERGE Change-Id: I7ad1b46db67adde3e45c2dc24b77622a29af3150 --- res/values-rm/strings.xml | 21 ++++++++++++++------- res/values-vi/strings.xml | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/res/values-rm/strings.xml b/res/values-rm/strings.xml index c85a7de64..ffb6ef799 100644 --- a/res/values-rm/strings.xml +++ b/res/values-rm/strings.xml @@ -20,7 +20,8 @@ "Rom da maletgs" "%1$02d:%2$02d" "%1$d:%2$02d:%3$02d" - "Films" + + "Chargiar il video…" @@ -38,10 +39,12 @@ "Cumenzar" - "Memorisar" + + - "Smatgai sin ina fatscha per cumenzar." + + "Memorisar il maletg..." @@ -59,7 +62,8 @@ "Definir il maletg sco" - "La culissa vegn configurada. Spetgai per plaschair..." + + "Culissa" "Stizzar" @@ -68,8 +72,10 @@ "Interrumper" "Cundivider" - "Selecziunar tut" - "Deselecziunar tut" + + + + "Preschentaziun da dia" "Detagls" @@ -101,7 +107,8 @@ "Definir sco" - "Impussibel da reproducir il video" + + diff --git a/res/values-vi/strings.xml b/res/values-vi/strings.xml index 335646ae9..72457c64b 100644 --- a/res/values-vi/strings.xml +++ b/res/values-vi/strings.xml @@ -106,7 +106,7 @@ "Không có album nào." "O có hình ảnh/video nào." "Bài đăng" - "Làm cho sẵn có khi ngoại tuyến" + "Cho phép ngoại tuyến" "Làm mới" "Xong" "%1$d/%2$d mục:" -- GitLab From 8be70c9176a9dc70d77b259e857d3beb13cff524 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Wed, 6 Jun 2012 10:56:34 -0700 Subject: [PATCH 029/763] Import translations. DO NOT MERGE Change-Id: I5847ab732e86841a916b6d641766c329c4e367be --- res/values-ca/strings.xml | 2 +- res/values-uk/strings.xml | 2 +- res/values-zh-rCN/strings.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/res/values-ca/strings.xml b/res/values-ca/strings.xml index ea13a589e..e2a83595f 100644 --- a/res/values-ca/strings.xml +++ b/res/values-ca/strings.xml @@ -159,7 +159,7 @@ "Selecció d\'imatges" "Pres. diapositives" "Àlbums" - "Vegades" + "Dates" "Ubicacions" "Persones" "Etiquetes" diff --git a/res/values-uk/strings.xml b/res/values-uk/strings.xml index 23f67321c..1626d4676 100644 --- a/res/values-uk/strings.xml +++ b/res/values-uk/strings.xml @@ -44,7 +44,7 @@ "Виберіть альбом" "Виберіть групу" "Устан. фото як" - "Устан. фон. зображ." + "Фонове зображення" "Встановлення фонового малюнка..." "Фоновий мал." "Видалити" diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index 917e990dc..ba3e913b6 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -44,7 +44,7 @@ "选择相册" "选择群组" "将照片设置为" - "设为壁纸" + "设置壁纸" "正在设置壁纸..." "壁纸" "删除" -- GitLab From e791e1c5bb5441528442dbb1e203c493a802d788 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Mon, 11 Jun 2012 10:24:33 -0700 Subject: [PATCH 030/763] Import translations. DO NOT MERGE Change-Id: I1eb9710c0fdf95d4d39a3b36ecb2606a64723177 --- res/values-en-rGB/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values-en-rGB/strings.xml b/res/values-en-rGB/strings.xml index 02b496763..c7bbcea13 100644 --- a/res/values-en-rGB/strings.xml +++ b/res/values-en-rGB/strings.xml @@ -170,5 +170,5 @@ "Download" "Imported" "Screenshot" - "Was this helpful?" + "Help" -- GitLab From 5bced1b7da3a1d3e8ad7e93e641467f30db40874 Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Tue, 12 Jun 2012 11:51:32 -0700 Subject: [PATCH 031/763] Import translations. DO NOT MERGE Change-Id: Idb929a3d9027bfc52a8fe9fd49d06a8ee22b268f --- res/values-am/strings.xml | 2 +- res/values-fa/strings.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/res/values-am/strings.xml b/res/values-am/strings.xml index b88187f69..7a7f2dace 100644 --- a/res/values-am/strings.xml +++ b/res/values-am/strings.xml @@ -105,7 +105,7 @@ "የተከረከመ ምስል %s ላይ ተቀምጧል።" "ምንም አልበሞች አልተገኙም::" "O ምስሎች/ ቪዲዮዎች ማግኘት ይቻላል::" - "ልኡክ ጽሁፎች" + "ልጥፎች" "ከመስመር ውጪ እንዲገኝአድርግ" "አድስ" "ተከናውኗል" diff --git a/res/values-fa/strings.xml b/res/values-fa/strings.xml index c51d8c42f..12395e244 100644 --- a/res/values-fa/strings.xml +++ b/res/values-fa/strings.xml @@ -159,7 +159,7 @@ "انتخاب تصاویر" "نمایش اسلاید" "آلبوم‌ها" - "دفعات" + "دوره" "مکان‌ها" "افراد" "نشان‌ها" -- GitLab From a901f8861f9b62386ad9729d533db744964a8690 Mon Sep 17 00:00:00 2001 From: Jorge Ruesga Date: Tue, 12 Jun 2012 23:28:58 +0200 Subject: [PATCH 032/763] Gallery2: Check privative effects Gallery2 has 2 effects (FaceTan and Facelift) from the privative gapps. If gapps is not present, Gallery2 gets into a FC when click on this effects. This patch checks if the permission "com.google.android.media.effects" exists and hide this 2 effects if permission not exists Patch 2: Use EffectFactory.isEffectSupported to detect if filters exists Patch 3: Make isPresent method from effect classes a static method Patch 4: Change actions classes for static calling to effects classes Change-Id: I8f6b59e57e504114835ab3283f65a72b4f6774a8 --- .../android/gallery3d/photoeditor/EffectsBar.java | 9 +++++++-- .../photoeditor/actions/EffectAction.java | 9 +++++++++ .../photoeditor/actions/FaceTanAction.java | 6 +++++- .../photoeditor/actions/FaceliftAction.java | 6 +++++- .../photoeditor/filters/FaceTanFilter.java | 15 ++++++++++++++- .../photoeditor/filters/FaceliftFilter.java | 14 +++++++++++++- 6 files changed, 53 insertions(+), 6 deletions(-) diff --git a/src/com/android/gallery3d/photoeditor/EffectsBar.java b/src/com/android/gallery3d/photoeditor/EffectsBar.java index 40754040c..1510c2f01 100644 --- a/src/com/android/gallery3d/photoeditor/EffectsBar.java +++ b/src/com/android/gallery3d/photoeditor/EffectsBar.java @@ -74,8 +74,13 @@ public class EffectsBar extends LinearLayout { effectsGallery = inflater.inflate(R.layout.photoeditor_effects_gallery, this, false); ViewGroup scrollView = (ViewGroup) effectsGallery.findViewById(R.id.scroll_view); ViewGroup effects = (ViewGroup) inflater.inflate(effectsId, scrollView, false); - for (int i = 0; i < effects.getChildCount(); i++) { - setupEffectListener((EffectAction) effects.getChildAt(i)); + for (int i = effects.getChildCount()-1; i >= 0; i--) { + EffectAction effect = (EffectAction) effects.getChildAt(i); + if( !effect.isPresent() ){ + effects.removeViewAt(i); + continue; + } + setupEffectListener(effect); } scrollView.addView(effects); scrollView.scrollTo(0, 0); diff --git a/src/com/android/gallery3d/photoeditor/actions/EffectAction.java b/src/com/android/gallery3d/photoeditor/actions/EffectAction.java index 6c6a893e3..c8e5d7d59 100644 --- a/src/com/android/gallery3d/photoeditor/actions/EffectAction.java +++ b/src/com/android/gallery3d/photoeditor/actions/EffectAction.java @@ -148,6 +148,15 @@ public abstract class EffectAction extends LinearLayout { */ protected abstract void doEnd(); + /** + * Checks if the action effect is present in the system. + * + * @return boolean true if an action effect is present in the system and can be loaded + */ + public boolean isPresent() { + return true; + } + /** * Done callback for executing top filter changes. */ diff --git a/src/com/android/gallery3d/photoeditor/actions/FaceTanAction.java b/src/com/android/gallery3d/photoeditor/actions/FaceTanAction.java index a82f33079..dd7df1899 100644 --- a/src/com/android/gallery3d/photoeditor/actions/FaceTanAction.java +++ b/src/com/android/gallery3d/photoeditor/actions/FaceTanAction.java @@ -37,7 +37,6 @@ public class FaceTanAction extends EffectAction { @Override public void doBegin() { final FaceTanFilter filter = new FaceTanFilter(); - scalePicker = factory.createScalePicker(EffectToolFactory.ScalePickerType.GENERIC); scalePicker.setOnScaleChangeListener(new ScaleSeekBar.OnScaleChangeListener() { @@ -59,4 +58,9 @@ public class FaceTanAction extends EffectAction { public void doEnd() { scalePicker.setOnScaleChangeListener(null); } + + @Override + public boolean isPresent() { + return FaceTanFilter.isPresent(); + } } diff --git a/src/com/android/gallery3d/photoeditor/actions/FaceliftAction.java b/src/com/android/gallery3d/photoeditor/actions/FaceliftAction.java index 90d4e0c72..2cf71c0b0 100644 --- a/src/com/android/gallery3d/photoeditor/actions/FaceliftAction.java +++ b/src/com/android/gallery3d/photoeditor/actions/FaceliftAction.java @@ -37,7 +37,6 @@ public class FaceliftAction extends EffectAction { @Override public void doBegin() { final FaceliftFilter filter = new FaceliftFilter(); - scalePicker = factory.createScalePicker(EffectToolFactory.ScalePickerType.GENERIC); scalePicker.setOnScaleChangeListener(new ScaleSeekBar.OnScaleChangeListener() { @@ -59,4 +58,9 @@ public class FaceliftAction extends EffectAction { public void doEnd() { scalePicker.setOnScaleChangeListener(null); } + + @Override + public boolean isPresent() { + return FaceliftFilter.isPresent(); + } } diff --git a/src/com/android/gallery3d/photoeditor/filters/FaceTanFilter.java b/src/com/android/gallery3d/photoeditor/filters/FaceTanFilter.java index c52bb8848..b7a1cf1c7 100644 --- a/src/com/android/gallery3d/photoeditor/filters/FaceTanFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/FaceTanFilter.java @@ -17,6 +17,7 @@ package com.android.gallery3d.photoeditor.filters; import android.media.effect.Effect; +import android.media.effect.EffectFactory; import com.android.gallery3d.photoeditor.Photo; @@ -27,10 +28,22 @@ public class FaceTanFilter extends AbstractScaleFilter { public static final Creator CREATOR = creatorOf(FaceTanFilter.class); + private static final String EFFECT_FACE_TANNING = "com.google.android.media.effect.effects.FaceTanningEffect"; + @Override public void process(Photo src, Photo dst) { - Effect effect = getEffect("com.google.android.media.effect.effects.FaceTanningEffect"); + Effect effect = getEffect(EFFECT_FACE_TANNING); effect.setParameter("blend", scale); effect.apply(src.texture(), src.width(), src.height(), dst.texture()); } + + /** + * Checks if the effect is present in the system. + * + * @return boolean true if an effect is present in the system and can be loaded + */ + public static boolean isPresent() { + return EffectFactory.isEffectSupported(EFFECT_FACE_TANNING); + } + } diff --git a/src/com/android/gallery3d/photoeditor/filters/FaceliftFilter.java b/src/com/android/gallery3d/photoeditor/filters/FaceliftFilter.java index c6ad84b80..3e4fad206 100644 --- a/src/com/android/gallery3d/photoeditor/filters/FaceliftFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/FaceliftFilter.java @@ -17,6 +17,7 @@ package com.android.gallery3d.photoeditor.filters; import android.media.effect.Effect; +import android.media.effect.EffectFactory; import com.android.gallery3d.photoeditor.Photo; @@ -27,10 +28,21 @@ public class FaceliftFilter extends AbstractScaleFilter { public static final Creator CREATOR = creatorOf(FaceliftFilter.class); + private static final String EFFECT_FACELIFT = "com.google.android.media.effect.effects.FaceliftEffect"; + @Override public void process(Photo src, Photo dst) { - Effect effect = getEffect("com.google.android.media.effect.effects.FaceliftEffect"); + Effect effect = getEffect(EFFECT_FACELIFT); effect.setParameter("blend", scale); effect.apply(src.texture(), src.width(), src.height(), dst.texture()); } + + /** + * Checks if the effect is present in the system. + * + * @return boolean true if an effect is present in the system and can be loaded + */ + public static boolean isPresent() { + return EffectFactory.isEffectSupported(EFFECT_FACELIFT); + } } -- GitLab From d6e23b6ff938f176f19f9cb2728f607b68cc1510 Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Mon, 18 Jun 2012 10:22:38 -0700 Subject: [PATCH 033/763] Import translations. DO NOT MERGE Change-Id: Ib1876c5daebce55dc45ee46d493a8f6494bce54a --- res/values-sw/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/res/values-sw/strings.xml b/res/values-sw/strings.xml index 772ce6320..455cd4cad 100644 --- a/res/values-sw/strings.xml +++ b/res/values-sw/strings.xml @@ -49,8 +49,8 @@ "Mandhari" "Futa" - "Futa kipengee kilichoteuliwa?" - "Futa vipengee vilivyoteuliwa?" + "Kipengee kilichoteuliwa kifutwe?" + "Vipengee vilivyoteuliwa vifutwe?" "Thibitisha" "Ghairi" -- GitLab From 0f2a9b8cd38dab7212234eb0e0d5f66d6f485ba6 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Tue, 19 Jun 2012 13:23:58 -0700 Subject: [PATCH 034/763] Import translations. DO NOT MERGE Change-Id: If311f3cbb087651e37b00789c69cd4035ec03e02 --- res/values-af/strings.xml | 4 ++++ res/values-am/strings.xml | 4 ++++ res/values-ar/strings.xml | 4 ++++ res/values-be/strings.xml | 4 ++++ res/values-bg/strings.xml | 4 ++++ res/values-ca/strings.xml | 4 ++++ res/values-cs/strings.xml | 4 ++++ res/values-da/strings.xml | 4 ++++ res/values-de/strings.xml | 4 ++++ res/values-el/strings.xml | 4 ++++ res/values-en-rGB/strings.xml | 2 ++ res/values-es-rUS/strings.xml | 4 ++++ res/values-es/strings.xml | 4 ++++ res/values-et/strings.xml | 4 ++++ res/values-fa/strings.xml | 4 ++++ res/values-fi/strings.xml | 2 ++ res/values-fr/strings.xml | 4 ++++ res/values-hi/strings.xml | 4 ++++ res/values-hr/strings.xml | 4 ++++ res/values-hu/strings.xml | 4 ++++ res/values-in/strings.xml | 4 ++++ res/values-it/strings.xml | 4 ++++ res/values-iw/strings.xml | 4 ++++ res/values-ja/strings.xml | 4 ++++ res/values-ko/strings.xml | 4 ++++ res/values-lt/strings.xml | 4 ++++ res/values-lv/strings.xml | 4 ++++ res/values-ms/strings.xml | 4 ++++ res/values-nb/strings.xml | 4 ++++ res/values-nl/strings.xml | 4 ++++ res/values-pl/strings.xml | 4 ++++ res/values-pt-rPT/strings.xml | 4 ++++ res/values-pt/strings.xml | 4 ++++ res/values-rm/strings.xml | 4 ++++ res/values-ro/strings.xml | 4 ++++ res/values-ru/strings.xml | 4 ++++ res/values-sk/strings.xml | 4 ++++ res/values-sl/strings.xml | 4 ++++ res/values-sr/strings.xml | 4 ++++ res/values-sv/strings.xml | 4 ++++ res/values-sw/strings.xml | 4 ++++ res/values-th/strings.xml | 4 ++++ res/values-tl/strings.xml | 4 ++++ res/values-tr/strings.xml | 4 ++++ res/values-uk/strings.xml | 4 ++++ res/values-vi/strings.xml | 4 ++++ res/values-zh-rCN/strings.xml | 4 ++++ res/values-zh-rTW/strings.xml | 4 ++++ res/values-zu/strings.xml | 4 ++++ 49 files changed, 192 insertions(+) diff --git a/res/values-af/strings.xml b/res/values-af/strings.xml index e3c1e8c5a..3092e4df4 100644 --- a/res/values-af/strings.xml +++ b/res/values-af/strings.xml @@ -55,6 +55,10 @@ "Bevestig" "Kanselleer" "Deling" + + + + "Kies almal" "Ontkies almal" "Skyfievertoning" diff --git a/res/values-am/strings.xml b/res/values-am/strings.xml index 7a7f2dace..656054649 100644 --- a/res/values-am/strings.xml +++ b/res/values-am/strings.xml @@ -55,6 +55,10 @@ "አረጋግጥ" "ይቅር" "አጋራ" + + + + "ሁሉንም ምረጥ" "ሁሉንም አትምረጥ" "ስላይድ አሳይ" diff --git a/res/values-ar/strings.xml b/res/values-ar/strings.xml index fe3a2111a..c0d91cb3d 100644 --- a/res/values-ar/strings.xml +++ b/res/values-ar/strings.xml @@ -55,6 +55,10 @@ "تأكيد" "إلغاء" "مشاركة" + + + + "تحديد الكل" "إلغاء تحديد الكل" "عرض الشرائح" diff --git a/res/values-be/strings.xml b/res/values-be/strings.xml index 14547042f..6fb8b5ce8 100644 --- a/res/values-be/strings.xml +++ b/res/values-be/strings.xml @@ -55,6 +55,10 @@ "Пацвердзіць" "Адмяніць" "Апублікаваць" + + + + "Выбраць усё" "Адмяніць выбар усяго" "Слайд-шоу" diff --git a/res/values-bg/strings.xml b/res/values-bg/strings.xml index da21938b5..5b24bc2aa 100644 --- a/res/values-bg/strings.xml +++ b/res/values-bg/strings.xml @@ -55,6 +55,10 @@ "Потвърждаване" "Отказ" "Споделяне" + + + + "Избиране на всички" "Премахване на избора" "Слайдшоу" diff --git a/res/values-ca/strings.xml b/res/values-ca/strings.xml index e2a83595f..b60ab1615 100644 --- a/res/values-ca/strings.xml +++ b/res/values-ca/strings.xml @@ -55,6 +55,10 @@ "Confirma" "Cancel·la" "Comparteix" + + + + "Selecciona-ho tot" "Anul·la la selecció de tot" "Presentació de diapositives" diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml index 9cb883554..e6e592aa3 100644 --- a/res/values-cs/strings.xml +++ b/res/values-cs/strings.xml @@ -55,6 +55,10 @@ "Potvrdit" "Zrušit" "Sdílet" + + + + "Vybrat vše" "Zrušit výběr všech položek" "Prezentace" diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml index 2fcb2fcef..5ce86311d 100644 --- a/res/values-da/strings.xml +++ b/res/values-da/strings.xml @@ -55,6 +55,10 @@ "Bekræft" "Annuller" "Del" + + + + "Markér alle" "Fjern markering af alle" "Diasshow" diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index cce0dd709..b151a68eb 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -55,6 +55,10 @@ "Bestätigen" "Abbrechen" "Teilen" + + + + "Alle auswählen" "Auswahl für alle aufheben" "Diashow" diff --git a/res/values-el/strings.xml b/res/values-el/strings.xml index 7435abe9a..af9080c9d 100644 --- a/res/values-el/strings.xml +++ b/res/values-el/strings.xml @@ -55,6 +55,10 @@ "Επιβεβαίωση" "Ακύρωση" "Κοινή χρήση" + + + + "Επιλογή όλων" "Αποεπιλογή όλων" "Προβολή διαφανειών" diff --git a/res/values-en-rGB/strings.xml b/res/values-en-rGB/strings.xml index c7bbcea13..b08ee8daa 100644 --- a/res/values-en-rGB/strings.xml +++ b/res/values-en-rGB/strings.xml @@ -55,6 +55,8 @@ "Confirm" "Cancel" "Share" + "Deleted" + "UNDO" "Select all" "Deselect all" "Slideshow" diff --git a/res/values-es-rUS/strings.xml b/res/values-es-rUS/strings.xml index cf800b72f..f38417996 100644 --- a/res/values-es-rUS/strings.xml +++ b/res/values-es-rUS/strings.xml @@ -55,6 +55,10 @@ "Confirmar" "Cancelar" "Compartir" + + + + "Seleccionar todo" "Desmarcar todo" "Presentación de diapositivas" diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index eb473ab13..d7f288ad1 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -55,6 +55,10 @@ "Confirmar" "Cancelar" "Compartir" + + + + "Seleccionar todo" "Desmarcar todo" "Presentación" diff --git a/res/values-et/strings.xml b/res/values-et/strings.xml index 6ae9bba74..caffb106b 100644 --- a/res/values-et/strings.xml +++ b/res/values-et/strings.xml @@ -55,6 +55,10 @@ "Kinnitamine" "Tühista" "Jaga" + + + + "Vali kõik" "Tühista kõik valikud" "Slaidiseanss" diff --git a/res/values-fa/strings.xml b/res/values-fa/strings.xml index 12395e244..ee1c89f9d 100644 --- a/res/values-fa/strings.xml +++ b/res/values-fa/strings.xml @@ -55,6 +55,10 @@ "تأیید" "لغو" "اشتراک گذاری" + + + + "انتخاب همه" "لغو انتخاب همه" "نمایش اسلاید" diff --git a/res/values-fi/strings.xml b/res/values-fi/strings.xml index c1e796907..508eb8f61 100644 --- a/res/values-fi/strings.xml +++ b/res/values-fi/strings.xml @@ -55,6 +55,8 @@ "Vahvista" "Peruuta" "Jaa" + "Poistettu" + "KUMOA" "Valitse kaikki" "Poista kaikki valinnat" "Diaesitys" diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index 5a5d4ca8e..efe7a4394 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -55,6 +55,10 @@ "Confirmer" "Annuler" "Partager" + + + + "Tout sélectionner" "Tout désélectionner" "Diaporama" diff --git a/res/values-hi/strings.xml b/res/values-hi/strings.xml index 0db281dd9..1d74e619c 100644 --- a/res/values-hi/strings.xml +++ b/res/values-hi/strings.xml @@ -55,6 +55,10 @@ "पुष्टि करें" "रद्द करें" "शेयर करें" + + + + "सभी का चयन करें" "सभी का चयन रद्द करें" "स्लाइडशो" diff --git a/res/values-hr/strings.xml b/res/values-hr/strings.xml index ccc385692..aae1e4b91 100644 --- a/res/values-hr/strings.xml +++ b/res/values-hr/strings.xml @@ -55,6 +55,10 @@ "Potvrdi" "Odustani" "Podijeli" + + + + "Odaberi sve" "Poništi odabir za sve" "Dijaprojekcija" diff --git a/res/values-hu/strings.xml b/res/values-hu/strings.xml index e0d360bb6..c4aec1f51 100644 --- a/res/values-hu/strings.xml +++ b/res/values-hu/strings.xml @@ -55,6 +55,10 @@ "Megerősítés" "Mégse" "Megosztás" + + + + "Az összes kijelölése" "Az összes kijelölés törlése" "Diavetítés" diff --git a/res/values-in/strings.xml b/res/values-in/strings.xml index d79aa3320..a3622e1a6 100644 --- a/res/values-in/strings.xml +++ b/res/values-in/strings.xml @@ -55,6 +55,10 @@ "Konfirmasi" "Batal" "Bagikan" + + + + "Pilih semua" "Batalkan semua pilihan" "Rangkai slide" diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index 88d57ab16..7f133b3e5 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -55,6 +55,10 @@ "Conferma" "Annulla" "Condividi" + + + + "Seleziona tutti" "Deseleziona tutto" "Presentazione" diff --git a/res/values-iw/strings.xml b/res/values-iw/strings.xml index c62aad437..0f7972923 100644 --- a/res/values-iw/strings.xml +++ b/res/values-iw/strings.xml @@ -55,6 +55,10 @@ "אשר" "ביטול" "שיתוף" + + + + "בחר הכול" "בטל בחירה של הכל" "מצגת" diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml index 8cef890a8..e3170cd4a 100644 --- a/res/values-ja/strings.xml +++ b/res/values-ja/strings.xml @@ -55,6 +55,10 @@ "確認" "キャンセル" "共有" + + + + "すべて選択" "選択をすべて解除" "スライドショー" diff --git a/res/values-ko/strings.xml b/res/values-ko/strings.xml index 4ac2b3713..ecf43915f 100644 --- a/res/values-ko/strings.xml +++ b/res/values-ko/strings.xml @@ -55,6 +55,10 @@ "확인" "취소" "공유" + + + + "모두 선택" "모두 선택취소" "슬라이드쇼" diff --git a/res/values-lt/strings.xml b/res/values-lt/strings.xml index 95f1a8ff9..e79e22075 100644 --- a/res/values-lt/strings.xml +++ b/res/values-lt/strings.xml @@ -55,6 +55,10 @@ "Patvirtinti" "Atšaukti" "Bendrinti" + + + + "Pasirinkti viską" "Panaikinti visus žymėjimus" "Skaidrių demonstracija" diff --git a/res/values-lv/strings.xml b/res/values-lv/strings.xml index c3e47b41d..a0a881f3c 100644 --- a/res/values-lv/strings.xml +++ b/res/values-lv/strings.xml @@ -55,6 +55,10 @@ "Apstiprināt" "Atcelt" "Dalies" + + + + "Atlasīt visu" "Atcelt visu atlasi" "Slaidrāde" diff --git a/res/values-ms/strings.xml b/res/values-ms/strings.xml index 8349896d1..065a66092 100644 --- a/res/values-ms/strings.xml +++ b/res/values-ms/strings.xml @@ -55,6 +55,10 @@ "Sahkan" "Batal" "Kongsi" + + + + "Pilih semua" "Nyahpilih semua" "Tayangan slaid" diff --git a/res/values-nb/strings.xml b/res/values-nb/strings.xml index 37874fea9..5f18b07df 100644 --- a/res/values-nb/strings.xml +++ b/res/values-nb/strings.xml @@ -55,6 +55,10 @@ "Bekreft" "Avbryt" "Del" + + + + "Velg alle" "Opphev alle valg" "Lysbildevisning" diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml index f28c90d26..cadb241f3 100644 --- a/res/values-nl/strings.xml +++ b/res/values-nl/strings.xml @@ -55,6 +55,10 @@ "Bevestigen" "Annuleren" "Delen" + + + + "Alles selecteren" "Alle selecties opheffen" "Diavoorstelling" diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml index 5b6ca5310..498c34a1b 100644 --- a/res/values-pl/strings.xml +++ b/res/values-pl/strings.xml @@ -55,6 +55,10 @@ "Potwierdź" "Anuluj" "Udostępnij" + + + + "Zaznacz wszystkie" "Usuń zaznaczenie wszystkich" "Pokaz slajdów" diff --git a/res/values-pt-rPT/strings.xml b/res/values-pt-rPT/strings.xml index fa0288a4b..a7e8736aa 100644 --- a/res/values-pt-rPT/strings.xml +++ b/res/values-pt-rPT/strings.xml @@ -55,6 +55,10 @@ "Confirmar" "Cancelar" "Partilhar" + + + + "Selecionar tudo" "Desmarcar tudo" "Apresentação de diapositivos" diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml index b7a0140ef..c47d766d1 100644 --- a/res/values-pt/strings.xml +++ b/res/values-pt/strings.xml @@ -55,6 +55,10 @@ "Confirmar" "Cancelar" "Compartilhar" + + + + "Selecionar tudo" "Desmarcar tudo" "Apresentação de slides" diff --git a/res/values-rm/strings.xml b/res/values-rm/strings.xml index ffb6ef799..ec361e8ad 100644 --- a/res/values-rm/strings.xml +++ b/res/values-rm/strings.xml @@ -72,6 +72,10 @@ "Interrumper" "Cundivider" + + + + diff --git a/res/values-ro/strings.xml b/res/values-ro/strings.xml index d10bf6fea..53934306e 100644 --- a/res/values-ro/strings.xml +++ b/res/values-ro/strings.xml @@ -55,6 +55,10 @@ "Confirmaţi" "Anulaţi" "Distribuiţi" + + + + "Selectaţi-le pe toate" "Deselectaţi-le pe toate" "Prezentare" diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index a9a780075..7903d88b1 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -55,6 +55,10 @@ "Подтвердить" "Отмена" "Отправить" + + + + "Выбрать все" "Отменить все" "Слайд-шоу" diff --git a/res/values-sk/strings.xml b/res/values-sk/strings.xml index bd914b985..1672f3d02 100644 --- a/res/values-sk/strings.xml +++ b/res/values-sk/strings.xml @@ -55,6 +55,10 @@ "Potvrdiť" "Zrušiť" "Zdieľať" + + + + "Vybrať všetko" "Zrušiť výber všetkých položiek" "Prezentácia" diff --git a/res/values-sl/strings.xml b/res/values-sl/strings.xml index fb2012033..71b32fc8a 100644 --- a/res/values-sl/strings.xml +++ b/res/values-sl/strings.xml @@ -55,6 +55,10 @@ "Potrdi" "Prekliči" "Skupna raba" + + + + "Izberi vse" "Prekliči celoten izbor" "Diaprojekcija" diff --git a/res/values-sr/strings.xml b/res/values-sr/strings.xml index ad14c081f..e80906bf4 100644 --- a/res/values-sr/strings.xml +++ b/res/values-sr/strings.xml @@ -55,6 +55,10 @@ "Потврди" "Откажи" "Дели" + + + + "Изабери све" "Опозови све изборе" "Пројекција слајдова" diff --git a/res/values-sv/strings.xml b/res/values-sv/strings.xml index c3a0efae5..16c173202 100644 --- a/res/values-sv/strings.xml +++ b/res/values-sv/strings.xml @@ -55,6 +55,10 @@ "Bekräfta" "Avbryt" "Dela" + + + + "Markera alla" "Avmarkera alla" "Bildspel" diff --git a/res/values-sw/strings.xml b/res/values-sw/strings.xml index 455cd4cad..9cc6cd4b0 100644 --- a/res/values-sw/strings.xml +++ b/res/values-sw/strings.xml @@ -55,6 +55,10 @@ "Thibitisha" "Ghairi" "Shiriki" + + + + "Chagua zote" "Ghairi uteuzi kwa zote" "Onyesho la slaidi" diff --git a/res/values-th/strings.xml b/res/values-th/strings.xml index 2095b9b4b..3966569e7 100644 --- a/res/values-th/strings.xml +++ b/res/values-th/strings.xml @@ -55,6 +55,10 @@ "ยืนยัน" "ยกเลิก" "แบ่งปัน" + + + + "เลือกทั้งหมด" "ยกเลิกการเลือกทั้งหมด" "การนำเสนอภาพนิ่ง" diff --git a/res/values-tl/strings.xml b/res/values-tl/strings.xml index d376a02ff..a396ec881 100644 --- a/res/values-tl/strings.xml +++ b/res/values-tl/strings.xml @@ -55,6 +55,10 @@ "Kumpirmahin" "Kanselahin" "Ibahagi" + + + + "Piliin lahat" "Alisin sa pagkakapili ang lahat" "Slideshow" diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml index 190dc46ec..b743a1fcc 100644 --- a/res/values-tr/strings.xml +++ b/res/values-tr/strings.xml @@ -55,6 +55,10 @@ "Onayla" "İptal" "Paylaş" + + + + "Tümünü seç" "Tümünün seçimini kaldır" "Slayt Gösterisi" diff --git a/res/values-uk/strings.xml b/res/values-uk/strings.xml index 1626d4676..442ae9a48 100644 --- a/res/values-uk/strings.xml +++ b/res/values-uk/strings.xml @@ -55,6 +55,10 @@ "Підтвердити" "Скасувати" "Надісл." + + + + "Вибрати всі" "Відмінити всі" "Слайд-шоу" diff --git a/res/values-vi/strings.xml b/res/values-vi/strings.xml index 72457c64b..6099f08bb 100644 --- a/res/values-vi/strings.xml +++ b/res/values-vi/strings.xml @@ -55,6 +55,10 @@ "Xác nhận" "Hủy" "Chia sẻ" + + + + "Chọn tất cả" "Bỏ chọn tất cả" "Trình chiếu" diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index ba3e913b6..ca9dfe533 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -55,6 +55,10 @@ "确认" "取消" "分享" + + + + "全选" "取消全选" "播放幻灯片" diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml index ac7de4f4a..a1b95df8d 100644 --- a/res/values-zh-rTW/strings.xml +++ b/res/values-zh-rTW/strings.xml @@ -55,6 +55,10 @@ "確認" "取消" "分享" + + + + "全選" "取消全選" "投影播放" diff --git a/res/values-zu/strings.xml b/res/values-zu/strings.xml index 7ebfa3a09..a6c983060 100644 --- a/res/values-zu/strings.xml +++ b/res/values-zu/strings.xml @@ -55,6 +55,10 @@ "Qinisekisa" "Khansela" "Yabelana" + + + + "Khetha konke" "Ungakhethi konke" "Umbukiso weslaydi" -- GitLab From d0f79f64c0a7ec68ffcaa98992aae0af22a9cee1 Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Wed, 20 Jun 2012 13:55:16 +0800 Subject: [PATCH 035/763] Move LongSparseArray into Gallery for unbundling. Change-Id: Ifa0d06818a2d21bd8ddeabe808d792f39c31322f --- .../gallery3d/common/LongSparseArray.java | 368 ++++++++++++++++++ .../android/gallery3d/ui/TileImageView.java | 2 +- 2 files changed, 369 insertions(+), 1 deletion(-) create mode 100644 gallerycommon/src/com/android/gallery3d/common/LongSparseArray.java diff --git a/gallerycommon/src/com/android/gallery3d/common/LongSparseArray.java b/gallerycommon/src/com/android/gallery3d/common/LongSparseArray.java new file mode 100644 index 000000000..b3298e672 --- /dev/null +++ b/gallerycommon/src/com/android/gallery3d/common/LongSparseArray.java @@ -0,0 +1,368 @@ +/* + * Copyright (C) 2009 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.android.gallery3d.common; + + +// Copied from android.util.LongSparseArray for unbundling + +/** + * SparseArray mapping longs to Objects. Unlike a normal array of Objects, + * there can be gaps in the indices. It is intended to be more efficient + * than using a HashMap to map Longs to Objects. + */ +public class LongSparseArray implements Cloneable { + private static final Object DELETED = new Object(); + private boolean mGarbage = false; + + private long[] mKeys; + private Object[] mValues; + private int mSize; + + /** + * Creates a new LongSparseArray containing no mappings. + */ + public LongSparseArray() { + this(10); + } + + /** + * Creates a new LongSparseArray containing no mappings that will not + * require any additional memory allocation to store the specified + * number of mappings. + */ + public LongSparseArray(int initialCapacity) { + initialCapacity = idealLongArraySize(initialCapacity); + + mKeys = new long[initialCapacity]; + mValues = new Object[initialCapacity]; + mSize = 0; + } + + @Override + @SuppressWarnings("unchecked") + public LongSparseArray clone() { + LongSparseArray clone = null; + try { + clone = (LongSparseArray) super.clone(); + clone.mKeys = mKeys.clone(); + clone.mValues = mValues.clone(); + } catch (CloneNotSupportedException cnse) { + /* ignore */ + } + return clone; + } + + /** + * Gets the Object mapped from the specified key, or null + * if no such mapping has been made. + */ + public E get(long key) { + return get(key, null); + } + + /** + * Gets the Object mapped from the specified key, or the specified Object + * if no such mapping has been made. + */ + @SuppressWarnings("unchecked") + public E get(long key, E valueIfKeyNotFound) { + int i = binarySearch(mKeys, 0, mSize, key); + + if (i < 0 || mValues[i] == DELETED) { + return valueIfKeyNotFound; + } else { + return (E) mValues[i]; + } + } + + /** + * Removes the mapping from the specified key, if there was any. + */ + public void delete(long key) { + int i = binarySearch(mKeys, 0, mSize, key); + + if (i >= 0) { + if (mValues[i] != DELETED) { + mValues[i] = DELETED; + mGarbage = true; + } + } + } + + /** + * Alias for {@link #delete(long)}. + */ + public void remove(long key) { + delete(key); + } + + /** + * Removes the mapping at the specified index. + */ + public void removeAt(int index) { + if (mValues[index] != DELETED) { + mValues[index] = DELETED; + mGarbage = true; + } + } + + private void gc() { + // Log.e("SparseArray", "gc start with " + mSize); + + int n = mSize; + int o = 0; + long[] keys = mKeys; + Object[] values = mValues; + + for (int i = 0; i < n; i++) { + Object val = values[i]; + + if (val != DELETED) { + if (i != o) { + keys[o] = keys[i]; + values[o] = val; + values[i] = null; + } + + o++; + } + } + + mGarbage = false; + mSize = o; + + // Log.e("SparseArray", "gc end with " + mSize); + } + + /** + * Adds a mapping from the specified key to the specified value, + * replacing the previous mapping from the specified key if there + * was one. + */ + public void put(long key, E value) { + int i = binarySearch(mKeys, 0, mSize, key); + + if (i >= 0) { + mValues[i] = value; + } else { + i = ~i; + + if (i < mSize && mValues[i] == DELETED) { + mKeys[i] = key; + mValues[i] = value; + return; + } + + if (mGarbage && mSize >= mKeys.length) { + gc(); + + // Search again because indices may have changed. + i = ~binarySearch(mKeys, 0, mSize, key); + } + + if (mSize >= mKeys.length) { + int n = idealLongArraySize(mSize + 1); + + long[] nkeys = new long[n]; + Object[] nvalues = new Object[n]; + + // Log.e("SparseArray", "grow " + mKeys.length + " to " + n); + System.arraycopy(mKeys, 0, nkeys, 0, mKeys.length); + System.arraycopy(mValues, 0, nvalues, 0, mValues.length); + + mKeys = nkeys; + mValues = nvalues; + } + + if (mSize - i != 0) { + // Log.e("SparseArray", "move " + (mSize - i)); + System.arraycopy(mKeys, i, mKeys, i + 1, mSize - i); + System.arraycopy(mValues, i, mValues, i + 1, mSize - i); + } + + mKeys[i] = key; + mValues[i] = value; + mSize++; + } + } + + /** + * Returns the number of key-value mappings that this LongSparseArray + * currently stores. + */ + public int size() { + if (mGarbage) { + gc(); + } + + return mSize; + } + + /** + * Given an index in the range 0...size()-1, returns + * the key from the indexth key-value mapping that this + * LongSparseArray stores. + */ + public long keyAt(int index) { + if (mGarbage) { + gc(); + } + + return mKeys[index]; + } + + /** + * Given an index in the range 0...size()-1, returns + * the value from the indexth key-value mapping that this + * LongSparseArray stores. + */ + @SuppressWarnings("unchecked") + public E valueAt(int index) { + if (mGarbage) { + gc(); + } + + return (E) mValues[index]; + } + + /** + * Given an index in the range 0...size()-1, sets a new + * value for the indexth key-value mapping that this + * LongSparseArray stores. + */ + public void setValueAt(int index, E value) { + if (mGarbage) { + gc(); + } + + mValues[index] = value; + } + + /** + * Returns the index for which {@link #keyAt} would return the + * specified key, or a negative number if the specified + * key is not mapped. + */ + public int indexOfKey(long key) { + if (mGarbage) { + gc(); + } + + return binarySearch(mKeys, 0, mSize, key); + } + + /** + * Returns an index for which {@link #valueAt} would return the + * specified key, or a negative number if no keys map to the + * specified value. + * Beware that this is a linear search, unlike lookups by key, + * and that multiple keys can map to the same value and this will + * find only one of them. + */ + public int indexOfValue(E value) { + if (mGarbage) { + gc(); + } + + for (int i = 0; i < mSize; i++) + if (mValues[i] == value) + return i; + + return -1; + } + + /** + * Removes all key-value mappings from this LongSparseArray. + */ + public void clear() { + int n = mSize; + Object[] values = mValues; + + for (int i = 0; i < n; i++) { + values[i] = null; + } + + mSize = 0; + mGarbage = false; + } + + /** + * Puts a key/value pair into the array, optimizing for the case where + * the key is greater than all existing keys in the array. + */ + public void append(long key, E value) { + if (mSize != 0 && key <= mKeys[mSize - 1]) { + put(key, value); + return; + } + + if (mGarbage && mSize >= mKeys.length) { + gc(); + } + + int pos = mSize; + if (pos >= mKeys.length) { + int n = idealLongArraySize(pos + 1); + + long[] nkeys = new long[n]; + Object[] nvalues = new Object[n]; + + // Log.e("SparseArray", "grow " + mKeys.length + " to " + n); + System.arraycopy(mKeys, 0, nkeys, 0, mKeys.length); + System.arraycopy(mValues, 0, nvalues, 0, mValues.length); + + mKeys = nkeys; + mValues = nvalues; + } + + mKeys[pos] = key; + mValues[pos] = value; + mSize = pos + 1; + } + + private static int binarySearch(long[] a, int start, int len, long key) { + int high = start + len, low = start - 1, guess; + + while (high - low > 1) { + guess = (high + low) / 2; + + if (a[guess] < key) + low = guess; + else + high = guess; + } + + if (high == start + len) + return ~(start + len); + else if (a[high] == key) + return high; + else + return ~high; + } + + private static int idealByteArraySize(int need) { + for (int i = 4; i < 32; i++) + if (need <= (1 << i) - 12) + return (1 << i) - 12; + + return need; + } + + public static int idealLongArraySize(int need) { + return idealByteArraySize(need * 8) / 8; + } +} diff --git a/src/com/android/gallery3d/ui/TileImageView.java b/src/com/android/gallery3d/ui/TileImageView.java index 0c6086d1c..adbf850c1 100644 --- a/src/com/android/gallery3d/ui/TileImageView.java +++ b/src/com/android/gallery3d/ui/TileImageView.java @@ -21,9 +21,9 @@ import android.graphics.Point; import android.graphics.Rect; import android.graphics.RectF; import android.util.FloatMath; -import android.util.LongSparseArray; import com.android.gallery3d.app.GalleryContext; +import com.android.gallery3d.common.LongSparseArray; import com.android.gallery3d.common.Utils; import com.android.gallery3d.data.BitmapPool; import com.android.gallery3d.data.DecodeUtils; -- GitLab From 86ac54b10762baec444c28eb22d1ebd22ef4ee3a Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Wed, 20 Jun 2012 09:43:37 -0700 Subject: [PATCH 036/763] Import translations. DO NOT MERGE Change-Id: Ie875f22d881a5f35fce1484e0cfe6237b15699f7 --- res/values-es-rUS/strings.xml | 6 ++---- res/values-iw/strings.xml | 6 ++---- res/values-nl/strings.xml | 6 ++---- res/values-sw/strings.xml | 6 ++---- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/res/values-es-rUS/strings.xml b/res/values-es-rUS/strings.xml index f38417996..7aff521a2 100644 --- a/res/values-es-rUS/strings.xml +++ b/res/values-es-rUS/strings.xml @@ -55,10 +55,8 @@ "Confirmar" "Cancelar" "Compartir" - - - - + "Eliminada" + "DESHACER" "Seleccionar todo" "Desmarcar todo" "Presentación de diapositivas" diff --git a/res/values-iw/strings.xml b/res/values-iw/strings.xml index 0f7972923..3e1d8439f 100644 --- a/res/values-iw/strings.xml +++ b/res/values-iw/strings.xml @@ -55,10 +55,8 @@ "אשר" "ביטול" "שיתוף" - - - - + "נמחק" + "בטל" "בחר הכול" "בטל בחירה של הכל" "מצגת" diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml index cadb241f3..a535d4656 100644 --- a/res/values-nl/strings.xml +++ b/res/values-nl/strings.xml @@ -55,10 +55,8 @@ "Bevestigen" "Annuleren" "Delen" - - - - + "Verwijderd" + "ONGEDAAN MAKEN" "Alles selecteren" "Alle selecties opheffen" "Diavoorstelling" diff --git a/res/values-sw/strings.xml b/res/values-sw/strings.xml index 9cc6cd4b0..4cd15aafc 100644 --- a/res/values-sw/strings.xml +++ b/res/values-sw/strings.xml @@ -55,10 +55,8 @@ "Thibitisha" "Ghairi" "Shiriki" - - - - + "Imefutwa" + "UNDO" "Chagua zote" "Ghairi uteuzi kwa zote" "Onyesho la slaidi" -- GitLab From ff08772a422a8f93792cf49f0f804ee4f42a909f Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Wed, 20 Jun 2012 18:45:30 -0700 Subject: [PATCH 037/763] Import translations. DO NOT MERGE Change-Id: If82aede2b76dc81e117d9b6e62bb21c96aaf8914 --- res/values-am/strings.xml | 6 ++---- res/values-el/strings.xml | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/res/values-am/strings.xml b/res/values-am/strings.xml index 656054649..3a29f4fa3 100644 --- a/res/values-am/strings.xml +++ b/res/values-am/strings.xml @@ -55,10 +55,8 @@ "አረጋግጥ" "ይቅር" "አጋራ" - - - - + "ጠፍቷል" + "ቀልብስ" "ሁሉንም ምረጥ" "ሁሉንም አትምረጥ" "ስላይድ አሳይ" diff --git a/res/values-el/strings.xml b/res/values-el/strings.xml index af9080c9d..c2ca79319 100644 --- a/res/values-el/strings.xml +++ b/res/values-el/strings.xml @@ -55,10 +55,8 @@ "Επιβεβαίωση" "Ακύρωση" "Κοινή χρήση" - - - - + "Διαγράφηκε" + "ΑΝΑΙΡΕΣΗ" "Επιλογή όλων" "Αποεπιλογή όλων" "Προβολή διαφανειών" -- GitLab From 22a3633a5b84449a419ecb92479703725bdd6723 Mon Sep 17 00:00:00 2001 From: Wu-cheng Li Date: Thu, 21 Jun 2012 16:45:55 +0800 Subject: [PATCH 038/763] Use View.setBackgroundDrawable instead of setBackground. View.setBackground was added in API 16. Use setBackgroundDrawable instead. bug:6698428 Change-Id: I1346ba4c640ae98d76e333779b4620cdc48b6a3a --- src/com/android/gallery3d/app/MoviePlayer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/com/android/gallery3d/app/MoviePlayer.java b/src/com/android/gallery3d/app/MoviePlayer.java index 11b40bdf8..ea12e4b7e 100644 --- a/src/com/android/gallery3d/app/MoviePlayer.java +++ b/src/com/android/gallery3d/app/MoviePlayer.java @@ -98,9 +98,10 @@ public class MoviePlayer implements }; private final Runnable mRemoveBackground = new Runnable() { + @SuppressWarnings("deprecation") @Override public void run() { - mRootView.setBackground(null); + mRootView.setBackgroundDrawable(null); } }; -- GitLab From 2122358459ff38f4cb9f21d086f4ef3000b0e172 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Thu, 21 Jun 2012 11:02:05 -0700 Subject: [PATCH 039/763] Import translations. DO NOT MERGE Change-Id: Ib58116d9f2da412110e7a45fe8c41eea73f771b1 --- res/values-af/strings.xml | 6 ++---- res/values-ar/strings.xml | 6 ++---- res/values-be/strings.xml | 6 ++---- res/values-ca/strings.xml | 6 ++---- res/values-cs/strings.xml | 6 ++---- res/values-da/strings.xml | 6 ++---- res/values-de/strings.xml | 6 ++---- res/values-es/strings.xml | 6 ++---- res/values-et/strings.xml | 6 ++---- res/values-fa/strings.xml | 6 ++---- res/values-fr/strings.xml | 6 ++---- res/values-hi/strings.xml | 6 ++---- res/values-hr/strings.xml | 6 ++---- res/values-hu/strings.xml | 6 ++---- res/values-in/strings.xml | 6 ++---- res/values-it/strings.xml | 6 ++---- res/values-ja/strings.xml | 6 ++---- res/values-ko/strings.xml | 6 ++---- res/values-lt/strings.xml | 6 ++---- res/values-lv/strings.xml | 6 ++---- res/values-ms/strings.xml | 6 ++---- res/values-nb/strings.xml | 6 ++---- res/values-pl/strings.xml | 6 ++---- res/values-pt-rPT/strings.xml | 6 ++---- res/values-pt/strings.xml | 6 ++---- res/values-ro/strings.xml | 6 ++---- res/values-ru/strings.xml | 6 ++---- res/values-sk/strings.xml | 6 ++---- res/values-sl/strings.xml | 6 ++---- res/values-sr/strings.xml | 6 ++---- res/values-sv/strings.xml | 6 ++---- res/values-th/strings.xml | 6 ++---- res/values-tl/strings.xml | 6 ++---- res/values-tr/strings.xml | 6 ++---- res/values-uk/strings.xml | 6 ++---- res/values-vi/strings.xml | 6 ++---- res/values-zh-rCN/strings.xml | 6 ++---- res/values-zh-rTW/strings.xml | 6 ++---- 38 files changed, 76 insertions(+), 152 deletions(-) diff --git a/res/values-af/strings.xml b/res/values-af/strings.xml index 3092e4df4..829d5a14f 100644 --- a/res/values-af/strings.xml +++ b/res/values-af/strings.xml @@ -55,10 +55,8 @@ "Bevestig" "Kanselleer" "Deling" - - - - + "geskrap" + "ONTDOEN" "Kies almal" "Ontkies almal" "Skyfievertoning" diff --git a/res/values-ar/strings.xml b/res/values-ar/strings.xml index c0d91cb3d..0403cf538 100644 --- a/res/values-ar/strings.xml +++ b/res/values-ar/strings.xml @@ -55,10 +55,8 @@ "تأكيد" "إلغاء" "مشاركة" - - - - + "تم حذفها" + "تراجع" "تحديد الكل" "إلغاء تحديد الكل" "عرض الشرائح" diff --git a/res/values-be/strings.xml b/res/values-be/strings.xml index 6fb8b5ce8..37a0872b2 100644 --- a/res/values-be/strings.xml +++ b/res/values-be/strings.xml @@ -55,10 +55,8 @@ "Пацвердзіць" "Адмяніць" "Апублікаваць" - - - - + "Выдаленая" + "ВЯРНУЦЬ" "Выбраць усё" "Адмяніць выбар усяго" "Слайд-шоу" diff --git a/res/values-ca/strings.xml b/res/values-ca/strings.xml index b60ab1615..fcfdda602 100644 --- a/res/values-ca/strings.xml +++ b/res/values-ca/strings.xml @@ -55,10 +55,8 @@ "Confirma" "Cancel·la" "Comparteix" - - - - + "Suprimida" + "DESFÉS" "Selecciona-ho tot" "Anul·la la selecció de tot" "Presentació de diapositives" diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml index e6e592aa3..0aa06dbe7 100644 --- a/res/values-cs/strings.xml +++ b/res/values-cs/strings.xml @@ -55,10 +55,8 @@ "Potvrdit" "Zrušit" "Sdílet" - - - - + "Smazáno" + "VRÁTIT ZPĚT" "Vybrat vše" "Zrušit výběr všech položek" "Prezentace" diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml index 5ce86311d..1bb78897a 100644 --- a/res/values-da/strings.xml +++ b/res/values-da/strings.xml @@ -55,10 +55,8 @@ "Bekræft" "Annuller" "Del" - - - - + "Slettet" + "FORTRYD" "Markér alle" "Fjern markering af alle" "Diasshow" diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index b151a68eb..13b507ee8 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -55,10 +55,8 @@ "Bestätigen" "Abbrechen" "Teilen" - - - - + "Gelöscht" + "Rückgängig" "Alle auswählen" "Auswahl für alle aufheben" "Diashow" diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index d7f288ad1..2edbdf5cf 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -55,10 +55,8 @@ "Confirmar" "Cancelar" "Compartir" - - - - + "Eliminada" + "DESHACER" "Seleccionar todo" "Desmarcar todo" "Presentación" diff --git a/res/values-et/strings.xml b/res/values-et/strings.xml index caffb106b..96d05cddd 100644 --- a/res/values-et/strings.xml +++ b/res/values-et/strings.xml @@ -55,10 +55,8 @@ "Kinnitamine" "Tühista" "Jaga" - - - - + "Kustutatud" + "VÕTA TAGASI" "Vali kõik" "Tühista kõik valikud" "Slaidiseanss" diff --git a/res/values-fa/strings.xml b/res/values-fa/strings.xml index ee1c89f9d..781909067 100644 --- a/res/values-fa/strings.xml +++ b/res/values-fa/strings.xml @@ -55,10 +55,8 @@ "تأیید" "لغو" "اشتراک گذاری" - - - - + "پاک شد" + "واگرد" "انتخاب همه" "لغو انتخاب همه" "نمایش اسلاید" diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index efe7a4394..611ab1dee 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -55,10 +55,8 @@ "Confirmer" "Annuler" "Partager" - - - - + "Supprimée" + "ANNULER" "Tout sélectionner" "Tout désélectionner" "Diaporama" diff --git a/res/values-hi/strings.xml b/res/values-hi/strings.xml index 1d74e619c..4aa4d357d 100644 --- a/res/values-hi/strings.xml +++ b/res/values-hi/strings.xml @@ -55,10 +55,8 @@ "पुष्टि करें" "रद्द करें" "शेयर करें" - - - - + "हटाई गई" + "पूर्ववत करें" "सभी का चयन करें" "सभी का चयन रद्द करें" "स्लाइडशो" diff --git a/res/values-hr/strings.xml b/res/values-hr/strings.xml index aae1e4b91..7cb659bb3 100644 --- a/res/values-hr/strings.xml +++ b/res/values-hr/strings.xml @@ -55,10 +55,8 @@ "Potvrdi" "Odustani" "Podijeli" - - - - + "Izbrisano" + "PONIŠTI" "Odaberi sve" "Poništi odabir za sve" "Dijaprojekcija" diff --git a/res/values-hu/strings.xml b/res/values-hu/strings.xml index c4aec1f51..f933833b4 100644 --- a/res/values-hu/strings.xml +++ b/res/values-hu/strings.xml @@ -55,10 +55,8 @@ "Megerősítés" "Mégse" "Megosztás" - - - - + "Törölve" + "VISSZAVONÁS" "Az összes kijelölése" "Az összes kijelölés törlése" "Diavetítés" diff --git a/res/values-in/strings.xml b/res/values-in/strings.xml index a3622e1a6..b1c2ddf38 100644 --- a/res/values-in/strings.xml +++ b/res/values-in/strings.xml @@ -55,10 +55,8 @@ "Konfirmasi" "Batal" "Bagikan" - - - - + "Dihapus" + "URUNGKAN" "Pilih semua" "Batalkan semua pilihan" "Rangkai slide" diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index 7f133b3e5..4cd7c868f 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -55,10 +55,8 @@ "Conferma" "Annulla" "Condividi" - - - - + "Eliminata" + "ANNULLA" "Seleziona tutti" "Deseleziona tutto" "Presentazione" diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml index e3170cd4a..10588e11c 100644 --- a/res/values-ja/strings.xml +++ b/res/values-ja/strings.xml @@ -55,10 +55,8 @@ "確認" "キャンセル" "共有" - - - - + "削除済み" + "元に戻す" "すべて選択" "選択をすべて解除" "スライドショー" diff --git a/res/values-ko/strings.xml b/res/values-ko/strings.xml index ecf43915f..b12d9f96b 100644 --- a/res/values-ko/strings.xml +++ b/res/values-ko/strings.xml @@ -55,10 +55,8 @@ "확인" "취소" "공유" - - - - + "삭제됨" + "실행취소" "모두 선택" "모두 선택취소" "슬라이드쇼" diff --git a/res/values-lt/strings.xml b/res/values-lt/strings.xml index e79e22075..da768e9be 100644 --- a/res/values-lt/strings.xml +++ b/res/values-lt/strings.xml @@ -55,10 +55,8 @@ "Patvirtinti" "Atšaukti" "Bendrinti" - - - - + "Ištrinta" + "ANULIUOTI" "Pasirinkti viską" "Panaikinti visus žymėjimus" "Skaidrių demonstracija" diff --git a/res/values-lv/strings.xml b/res/values-lv/strings.xml index a0a881f3c..d73516702 100644 --- a/res/values-lv/strings.xml +++ b/res/values-lv/strings.xml @@ -55,10 +55,8 @@ "Apstiprināt" "Atcelt" "Dalies" - - - - + "Dzēsts" + "ATSAUKT" "Atlasīt visu" "Atcelt visu atlasi" "Slaidrāde" diff --git a/res/values-ms/strings.xml b/res/values-ms/strings.xml index 065a66092..04988bc0d 100644 --- a/res/values-ms/strings.xml +++ b/res/values-ms/strings.xml @@ -55,10 +55,8 @@ "Sahkan" "Batal" "Kongsi" - - - - + "Dipadamkan" + "BUAT ASAL" "Pilih semua" "Nyahpilih semua" "Tayangan slaid" diff --git a/res/values-nb/strings.xml b/res/values-nb/strings.xml index 5f18b07df..6a34ab251 100644 --- a/res/values-nb/strings.xml +++ b/res/values-nb/strings.xml @@ -55,10 +55,8 @@ "Bekreft" "Avbryt" "Del" - - - - + "Slettet" + "ANGRE" "Velg alle" "Opphev alle valg" "Lysbildevisning" diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml index 498c34a1b..bddda6a1f 100644 --- a/res/values-pl/strings.xml +++ b/res/values-pl/strings.xml @@ -55,10 +55,8 @@ "Potwierdź" "Anuluj" "Udostępnij" - - - - + "Usunięty" + "COFNIJ" "Zaznacz wszystkie" "Usuń zaznaczenie wszystkich" "Pokaz slajdów" diff --git a/res/values-pt-rPT/strings.xml b/res/values-pt-rPT/strings.xml index a7e8736aa..de3a7ea95 100644 --- a/res/values-pt-rPT/strings.xml +++ b/res/values-pt-rPT/strings.xml @@ -55,10 +55,8 @@ "Confirmar" "Cancelar" "Partilhar" - - - - + "Eliminada" + "ANULAR" "Selecionar tudo" "Desmarcar tudo" "Apresentação de diapositivos" diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml index c47d766d1..bf54c2806 100644 --- a/res/values-pt/strings.xml +++ b/res/values-pt/strings.xml @@ -55,10 +55,8 @@ "Confirmar" "Cancelar" "Compartilhar" - - - - + "Excluída" + "DESFAZER" "Selecionar tudo" "Desmarcar tudo" "Apresentação de slides" diff --git a/res/values-ro/strings.xml b/res/values-ro/strings.xml index 53934306e..b84bbd068 100644 --- a/res/values-ro/strings.xml +++ b/res/values-ro/strings.xml @@ -55,10 +55,8 @@ "Confirmaţi" "Anulaţi" "Distribuiţi" - - - - + "Ştearsă" + "ANULAŢI" "Selectaţi-le pe toate" "Deselectaţi-le pe toate" "Prezentare" diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index 7903d88b1..85610587b 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -55,10 +55,8 @@ "Подтвердить" "Отмена" "Отправить" - - - - + "Удалено" + "ОТМЕНИТЬ" "Выбрать все" "Отменить все" "Слайд-шоу" diff --git a/res/values-sk/strings.xml b/res/values-sk/strings.xml index 1672f3d02..68840687d 100644 --- a/res/values-sk/strings.xml +++ b/res/values-sk/strings.xml @@ -55,10 +55,8 @@ "Potvrdiť" "Zrušiť" "Zdieľať" - - - - + "Odstránený" + "SPÄŤ" "Vybrať všetko" "Zrušiť výber všetkých položiek" "Prezentácia" diff --git a/res/values-sl/strings.xml b/res/values-sl/strings.xml index 71b32fc8a..8f2fdf2fe 100644 --- a/res/values-sl/strings.xml +++ b/res/values-sl/strings.xml @@ -55,10 +55,8 @@ "Potrdi" "Prekliči" "Skupna raba" - - - - + "Izbrisano" + "RAZVELJAVI" "Izberi vse" "Prekliči celoten izbor" "Diaprojekcija" diff --git a/res/values-sr/strings.xml b/res/values-sr/strings.xml index e80906bf4..dedc12fee 100644 --- a/res/values-sr/strings.xml +++ b/res/values-sr/strings.xml @@ -55,10 +55,8 @@ "Потврди" "Откажи" "Дели" - - - - + "Избрисана" + "ОПОЗОВИ" "Изабери све" "Опозови све изборе" "Пројекција слајдова" diff --git a/res/values-sv/strings.xml b/res/values-sv/strings.xml index 16c173202..a673a0119 100644 --- a/res/values-sv/strings.xml +++ b/res/values-sv/strings.xml @@ -55,10 +55,8 @@ "Bekräfta" "Avbryt" "Dela" - - - - + "Borttagen" + "ÅNGRA" "Markera alla" "Avmarkera alla" "Bildspel" diff --git a/res/values-th/strings.xml b/res/values-th/strings.xml index 3966569e7..24d2acf61 100644 --- a/res/values-th/strings.xml +++ b/res/values-th/strings.xml @@ -55,10 +55,8 @@ "ยืนยัน" "ยกเลิก" "แบ่งปัน" - - - - + "ลบแล้ว" + "เลิกทำ" "เลือกทั้งหมด" "ยกเลิกการเลือกทั้งหมด" "การนำเสนอภาพนิ่ง" diff --git a/res/values-tl/strings.xml b/res/values-tl/strings.xml index a396ec881..36ee4dc6c 100644 --- a/res/values-tl/strings.xml +++ b/res/values-tl/strings.xml @@ -55,10 +55,8 @@ "Kumpirmahin" "Kanselahin" "Ibahagi" - - - - + "Tinanggal" + "I-UNDO" "Piliin lahat" "Alisin sa pagkakapili ang lahat" "Slideshow" diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml index b743a1fcc..1e3c34159 100644 --- a/res/values-tr/strings.xml +++ b/res/values-tr/strings.xml @@ -55,10 +55,8 @@ "Onayla" "İptal" "Paylaş" - - - - + "Silindi" + "GERİ AL" "Tümünü seç" "Tümünün seçimini kaldır" "Slayt Gösterisi" diff --git a/res/values-uk/strings.xml b/res/values-uk/strings.xml index 442ae9a48..4700e294c 100644 --- a/res/values-uk/strings.xml +++ b/res/values-uk/strings.xml @@ -55,10 +55,8 @@ "Підтвердити" "Скасувати" "Надісл." - - - - + "Видалено" + "ВІДМІНИТИ" "Вибрати всі" "Відмінити всі" "Слайд-шоу" diff --git a/res/values-vi/strings.xml b/res/values-vi/strings.xml index 6099f08bb..02784073d 100644 --- a/res/values-vi/strings.xml +++ b/res/values-vi/strings.xml @@ -55,10 +55,8 @@ "Xác nhận" "Hủy" "Chia sẻ" - - - - + "Đã xóa" + "HOÀN TÁC" "Chọn tất cả" "Bỏ chọn tất cả" "Trình chiếu" diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index ca9dfe533..9bd5195a8 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -55,10 +55,8 @@ "确认" "取消" "分享" - - - - + "已删除" + "撤消" "全选" "取消全选" "播放幻灯片" diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml index a1b95df8d..722e0babc 100644 --- a/res/values-zh-rTW/strings.xml +++ b/res/values-zh-rTW/strings.xml @@ -55,10 +55,8 @@ "確認" "取消" "分享" - - - - + "已刪除" + "復原" "全選" "取消全選" "投影播放" -- GitLab From 7a5e1e771ae58241f3a2be36f23025f282032261 Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Wed, 20 Jun 2012 16:54:24 +0800 Subject: [PATCH 040/763] Guard the use of SYSTEM_UI_FLAG_XXXX with TargetApi bug: 6698718 Change-Id: I6962f0128ce2bd57658b7f3b77d2bc150eff1f60 --- .../android/gallery3d/common/ApiHelper.java | 37 +++++++++++ .../android/gallery3d/app/MovieActivity.java | 18 ++++- .../android/gallery3d/app/MoviePlayer.java | 66 +++++++++++-------- src/com/android/gallery3d/ui/GLRootView.java | 16 +++-- 4 files changed, 102 insertions(+), 35 deletions(-) create mode 100644 gallerycommon/src/com/android/gallery3d/common/ApiHelper.java diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java new file mode 100644 index 000000000..2fa93b9e9 --- /dev/null +++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2012 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.android.gallery3d.common; + +import android.view.View; + +public class ApiHelper { + + public static final boolean HAS_VIEW_SYSTEM_UI_FLAG_LAYOUT_STABLE = + hasField(View.class, "SYSTEM_UI_FLAG_LAYOUT_STABLE"); + + public static final boolean HAS_VIEW_SYSTEM_UI_FLAG_HIDE_NAVIGATION = + hasField(View.class, "SYSTEM_UI_FLAG_HIDE_NAVIGATION"); + + private static boolean hasField(Class klass, String fieldName) { + try { + klass.getDeclaredField(fieldName); + return true; + } catch (NoSuchFieldException e) { + return false; + } + } +} diff --git a/src/com/android/gallery3d/app/MovieActivity.java b/src/com/android/gallery3d/app/MovieActivity.java index 78fe1ee78..5f4db1d13 100644 --- a/src/com/android/gallery3d/app/MovieActivity.java +++ b/src/com/android/gallery3d/app/MovieActivity.java @@ -16,6 +16,7 @@ package com.android.gallery3d.app; +import android.annotation.TargetApi; import android.app.ActionBar; import android.app.Activity; import android.content.AsyncQueryHandler; @@ -27,6 +28,7 @@ import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.media.AudioManager; import android.net.Uri; +import android.os.Build; import android.os.Bundle; import android.provider.MediaStore; import android.provider.OpenableColumns; @@ -39,6 +41,7 @@ import android.view.WindowManager; import android.widget.ShareActionProvider; import com.android.gallery3d.R; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.common.Utils; /** @@ -59,6 +62,15 @@ public class MovieActivity extends Activity { private Uri mUri; private boolean mTreatUpAsBack; + @TargetApi(Build.VERSION_CODES.JELLY_BEAN) + private void setSystemUiVisibility(View rootView) { + if (ApiHelper.HAS_VIEW_SYSTEM_UI_FLAG_LAYOUT_STABLE) { + rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); + } + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -68,9 +80,9 @@ public class MovieActivity extends Activity { setContentView(R.layout.movie_view); View rootView = findViewById(R.id.movie_view_root); - rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE - | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN - | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); + + setSystemUiVisibility(rootView); + Intent intent = getIntent(); initializeActionBar(intent); mFinishOnCompletion = intent.getBooleanExtra( diff --git a/src/com/android/gallery3d/app/MoviePlayer.java b/src/com/android/gallery3d/app/MoviePlayer.java index ea12e4b7e..c0f0ce739 100644 --- a/src/com/android/gallery3d/app/MoviePlayer.java +++ b/src/com/android/gallery3d/app/MoviePlayer.java @@ -16,6 +16,7 @@ package com.android.gallery3d.app; +import android.annotation.TargetApi; import android.app.AlertDialog; import android.content.BroadcastReceiver; import android.content.Context; @@ -28,6 +29,7 @@ import android.graphics.Color; import android.media.AudioManager; import android.media.MediaPlayer; import android.net.Uri; +import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.view.KeyEvent; @@ -37,6 +39,7 @@ import android.view.ViewGroup; import android.widget.VideoView; import com.android.gallery3d.R; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.common.BlobCache; import com.android.gallery3d.util.CacheManager; import com.android.gallery3d.util.GalleryUtils; @@ -149,6 +152,37 @@ public class MoviePlayer implements } }, BLACK_TIMEOUT); + setOnSystemUiVisibilityChangeListener(); + // Hide system UI by default + showSystemUi(false); + + mAudioBecomingNoisyReceiver = new AudioBecomingNoisyReceiver(); + mAudioBecomingNoisyReceiver.register(); + + Intent i = new Intent(SERVICECMD); + i.putExtra(CMDNAME, CMDPAUSE); + movieActivity.sendBroadcast(i); + + if (savedInstance != null) { // this is a resumed activity + mVideoPosition = savedInstance.getInt(KEY_VIDEO_POSITION, 0); + mResumeableTime = savedInstance.getLong(KEY_RESUMEABLE_TIME, Long.MAX_VALUE); + mVideoView.start(); + mVideoView.suspend(); + mHasPaused = true; + } else { + final Integer bookmark = mBookmarker.getBookmark(mUri); + if (bookmark != null) { + showResumeDialog(movieActivity, bookmark); + } else { + startVideo(); + } + } + } + + @TargetApi(Build.VERSION_CODES.JELLY_BEAN) + private void setOnSystemUiVisibilityChangeListener() { + if (!ApiHelper.HAS_VIEW_SYSTEM_UI_FLAG_HIDE_NAVIGATION) return; + // When the user touches the screen or uses some hard key, the framework // will change system ui visibility from invisible to visible. We show // the media control and enable system UI (e.g. ActionBar) to be visible at this point @@ -177,37 +211,15 @@ public class MoviePlayer implements } } }); - - // Hide system UI by default - showSystemUi(false); - - mAudioBecomingNoisyReceiver = new AudioBecomingNoisyReceiver(); - mAudioBecomingNoisyReceiver.register(); - - Intent i = new Intent(SERVICECMD); - i.putExtra(CMDNAME, CMDPAUSE); - movieActivity.sendBroadcast(i); - - if (savedInstance != null) { // this is a resumed activity - mVideoPosition = savedInstance.getInt(KEY_VIDEO_POSITION, 0); - mResumeableTime = savedInstance.getLong(KEY_RESUMEABLE_TIME, Long.MAX_VALUE); - mVideoView.start(); - mVideoView.suspend(); - mHasPaused = true; - } else { - final Integer bookmark = mBookmarker.getBookmark(mUri); - if (bookmark != null) { - showResumeDialog(movieActivity, bookmark); - } else { - startVideo(); - } - } } + @TargetApi(Build.VERSION_CODES.JELLY_BEAN) private void showSystemUi(boolean visible) { + if (!ApiHelper.HAS_VIEW_SYSTEM_UI_FLAG_LAYOUT_STABLE) return; + int flag = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_LAYOUT_STABLE; + | View.SYSTEM_UI_FLAG_LAYOUT_STABLE; if (!visible) { flag |= View.SYSTEM_UI_FLAG_LOW_PROFILE | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; @@ -497,7 +509,7 @@ class Bookmarker { DataInputStream dis = new DataInputStream( new ByteArrayInputStream(data)); - String uriString = dis.readUTF(dis); + String uriString = DataInputStream.readUTF(dis); int bookmark = dis.readInt(); int duration = dis.readInt(); diff --git a/src/com/android/gallery3d/ui/GLRootView.java b/src/com/android/gallery3d/ui/GLRootView.java index 99ed8cb42..2068520aa 100644 --- a/src/com/android/gallery3d/ui/GLRootView.java +++ b/src/com/android/gallery3d/ui/GLRootView.java @@ -16,10 +16,12 @@ package com.android.gallery3d.ui; +import android.annotation.TargetApi; import android.content.Context; import android.graphics.Matrix; import android.graphics.PixelFormat; import android.opengl.GLSurfaceView; +import android.os.Build; import android.os.Process; import android.os.SystemClock; import android.util.AttributeSet; @@ -29,6 +31,7 @@ import android.view.View; import com.android.gallery3d.R; import com.android.gallery3d.anim.CanvasAnimation; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.common.Utils; import com.android.gallery3d.util.GalleryUtils; import com.android.gallery3d.util.Profile; @@ -536,12 +539,15 @@ public class GLRootView extends GLSurfaceView } @Override + @TargetApi(Build.VERSION_CODES.JELLY_BEAN) public void setLightsOutMode(boolean enabled) { - int flags = enabled - ? SYSTEM_UI_FLAG_LOW_PROFILE - | SYSTEM_UI_FLAG_FULLSCREEN - | SYSTEM_UI_FLAG_LAYOUT_STABLE - : 0; + int flags = 0; + if (enabled) { + flags = SYSTEM_UI_FLAG_LOW_PROFILE; + if (ApiHelper.HAS_VIEW_SYSTEM_UI_FLAG_LAYOUT_STABLE) { + flags |= (SYSTEM_UI_FLAG_FULLSCREEN | SYSTEM_UI_FLAG_LAYOUT_STABLE); + } + } setSystemUiVisibility(flags); } -- GitLab From fd3071dfc28b4caad583c77d7a4d9dad8fb86a3a Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Thu, 21 Jun 2012 17:05:10 +0800 Subject: [PATCH 041/763] Remove hardwired strings for no external storage. bug: 6682495 Change-Id: I68652d6b01842a42907b953574d563cf98e65219 --- res/values/strings.xml | 6 ++++++ src/com/android/gallery3d/app/AbstractGalleryActivity.java | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 899c1e697..0000c61e4 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -445,4 +445,10 @@ + + + No Storage + + + No external storage available diff --git a/src/com/android/gallery3d/app/AbstractGalleryActivity.java b/src/com/android/gallery3d/app/AbstractGalleryActivity.java index 144485df8..0987ac39f 100644 --- a/src/com/android/gallery3d/app/AbstractGalleryActivity.java +++ b/src/com/android/gallery3d/app/AbstractGalleryActivity.java @@ -143,8 +143,8 @@ public class AbstractGalleryActivity extends Activity implements GalleryActivity }; mAlertDialog = new AlertDialog.Builder(this) .setIconAttribute(android.R.attr.alertDialogIcon) - .setTitle("No Storage") - .setMessage("No external storage available.") + .setTitle(R.string.no_external_storage_title) + .setMessage(R.string.no_external_storage) .setNegativeButton(android.R.string.cancel, onClick) .setOnCancelListener(onCancel) .show(); -- GitLab From b47927b7b43679e7315e6099e0a610760320d18d Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Fri, 22 Jun 2012 12:31:33 +0800 Subject: [PATCH 042/763] Use MediaColumns.WIDTH and MediaColumns.HEIGHT only when they are available. bug:6698720 Change-Id: Iaabfd1d5fe16b5d89f564d688a78e773ad36c8bd --- .../android/gallery3d/common/ApiHelper.java | 4 +++ src/com/android/gallery3d/app/CropImage.java | 27 ++++++++++++------- .../android/gallery3d/data/LocalImage.java | 20 ++++++++++++-- 3 files changed, 39 insertions(+), 12 deletions(-) diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java index 2fa93b9e9..15026bbf3 100644 --- a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java +++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java @@ -16,6 +16,7 @@ package com.android.gallery3d.common; +import android.provider.MediaStore.MediaColumns; import android.view.View; public class ApiHelper { @@ -26,6 +27,9 @@ public class ApiHelper { public static final boolean HAS_VIEW_SYSTEM_UI_FLAG_HIDE_NAVIGATION = hasField(View.class, "SYSTEM_UI_FLAG_HIDE_NAVIGATION"); + public static final boolean HAS_MEDIA_COLUMNS_WIDTH_AND_HEIGHT = + hasField(MediaColumns.class, "WIDTH"); + private static boolean hasField(Class klass, String fieldName) { try { klass.getDeclaredField(fieldName); diff --git a/src/com/android/gallery3d/app/CropImage.java b/src/com/android/gallery3d/app/CropImage.java index 4f450d85e..294e285ea 100644 --- a/src/com/android/gallery3d/app/CropImage.java +++ b/src/com/android/gallery3d/app/CropImage.java @@ -16,6 +16,7 @@ package com.android.gallery3d.app; +import android.annotation.TargetApi; import android.app.ActionBar; import android.app.ProgressDialog; import android.app.WallpaperManager; @@ -32,6 +33,7 @@ import android.graphics.Rect; import android.graphics.RectF; import android.media.ExifInterface; import android.net.Uri; +import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.os.Handler; @@ -45,6 +47,7 @@ import android.view.Window; import android.widget.Toast; import com.android.gallery3d.R; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.common.BitmapUtils; import com.android.gallery3d.common.Utils; import com.android.gallery3d.data.DataManager; @@ -96,10 +99,6 @@ public class CropImage extends AbstractGalleryActivity { private static final int DEFAULT_COMPRESS_QUALITY = 90; private static final String TIME_STAMP_NAME = "'IMG'_yyyyMMdd_HHmmss"; - // Change these to Images.Media.WIDTH/HEIGHT after they are unhidden. - private static final String WIDTH = "width"; - private static final String HEIGHT = "height"; - public static final String KEY_RETURN_DATA = "return-data"; public static final String KEY_CROPPED_RECT = "cropped-rect"; public static final String KEY_ASPECT_X = "aspectX"; @@ -371,6 +370,15 @@ public class CropImage extends AbstractGalleryActivity { } } + @TargetApi(Build.VERSION_CODES.JELLY_BEAN) + private static void setImageSize(ContentValues values, int width, int height) { + // The two fields are available since ICS but got published in JB + if (ApiHelper.HAS_MEDIA_COLUMNS_WIDTH_AND_HEIGHT) { + values.put(Images.Media.WIDTH, width); + values.put(Images.Media.HEIGHT, height); + } + } + private Uri savePicasaImage(JobContext jc, Bitmap cropped) { if (!DOWNLOAD_BUCKET.isDirectory() && !DOWNLOAD_BUCKET.mkdirs()) { throw new RuntimeException("cannot create download folder"); @@ -395,8 +403,7 @@ public class CropImage extends AbstractGalleryActivity { values.put(Images.Media.ORIENTATION, 0); values.put(Images.Media.DATA, output.getAbsolutePath()); values.put(Images.Media.SIZE, output.length()); - values.put(WIDTH, cropped.getWidth()); - values.put(HEIGHT, cropped.getHeight()); + setImageSize(values, cropped.getWidth(), cropped.getHeight()); double latitude = PicasaSource.getLatitude(mMediaItem); double longitude = PicasaSource.getLongitude(mMediaItem); @@ -434,8 +441,8 @@ public class CropImage extends AbstractGalleryActivity { values.put(Images.Media.ORIENTATION, 0); values.put(Images.Media.DATA, output.getAbsolutePath()); values.put(Images.Media.SIZE, output.length()); - values.put(WIDTH, cropped.getWidth()); - values.put(HEIGHT, cropped.getHeight()); + + setImageSize(values, cropped.getWidth(), cropped.getHeight()); if (GalleryUtils.isValidLocation(localImage.latitude, localImage.longitude)) { values.put(Images.Media.LATITUDE, localImage.latitude); @@ -467,8 +474,8 @@ public class CropImage extends AbstractGalleryActivity { values.put(Images.Media.ORIENTATION, 0); values.put(Images.Media.DATA, output.getAbsolutePath()); values.put(Images.Media.SIZE, output.length()); - values.put(WIDTH, cropped.getWidth()); - values.put(HEIGHT, cropped.getHeight()); + + setImageSize(values, cropped.getWidth(), cropped.getHeight()); return getContentResolver().insert( Images.Media.EXTERNAL_CONTENT_URI, values); diff --git a/src/com/android/gallery3d/data/LocalImage.java b/src/com/android/gallery3d/data/LocalImage.java index aa27c6f42..b64b2c3f0 100644 --- a/src/com/android/gallery3d/data/LocalImage.java +++ b/src/com/android/gallery3d/data/LocalImage.java @@ -16,6 +16,7 @@ package com.android.gallery3d.data; +import android.annotation.TargetApi; import android.content.ContentResolver; import android.content.ContentValues; import android.database.Cursor; @@ -24,11 +25,14 @@ import android.graphics.BitmapFactory; import android.graphics.BitmapRegionDecoder; import android.media.ExifInterface; import android.net.Uri; +import android.os.Build; import android.provider.MediaStore.Images; import android.provider.MediaStore.Images.ImageColumns; +import android.provider.MediaStore.MediaColumns; import android.util.Log; import com.android.gallery3d.app.GalleryApp; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.common.BitmapUtils; import com.android.gallery3d.util.GalleryUtils; import com.android.gallery3d.util.ThreadPool.Job; @@ -74,10 +78,22 @@ public class LocalImage extends LocalMediaItem { ImageColumns.ORIENTATION, // 9 ImageColumns.BUCKET_ID, // 10 ImageColumns.SIZE, // 11 - ImageColumns.WIDTH, // 12 - ImageColumns.HEIGHT // 13 + "0", // 12 + "0" // 13 }; + static { + updateWidthAndHeightProjection(); + } + + @TargetApi(Build.VERSION_CODES.JELLY_BEAN) + private static void updateWidthAndHeightProjection() { + if (ApiHelper.HAS_MEDIA_COLUMNS_WIDTH_AND_HEIGHT) { + PROJECTION[INDEX_WIDTH] = MediaColumns.WIDTH; + PROJECTION[INDEX_HEIGHT] = MediaColumns.HEIGHT; + } + } + private final GalleryApp mApplication; public int rotation; -- GitLab From 369d0e6b4ee4f034a418177516ea8a76a16953df Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Fri, 22 Jun 2012 15:33:53 +0800 Subject: [PATCH 043/763] Use another version of setRemoteViews for backward compatibility. bug: 6706684 Change-Id: I6fd77845d64cfb9e6830c1eabdcb5c2e9a7df854 --- .../android/gallery3d/gadget/PhotoAppWidgetProvider.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/com/android/gallery3d/gadget/PhotoAppWidgetProvider.java b/src/com/android/gallery3d/gadget/PhotoAppWidgetProvider.java index c18652d5b..343b15a5b 100644 --- a/src/com/android/gallery3d/gadget/PhotoAppWidgetProvider.java +++ b/src/com/android/gallery3d/gadget/PhotoAppWidgetProvider.java @@ -66,6 +66,7 @@ public class PhotoAppWidgetProvider extends AppWidgetProvider { super.onUpdate(context, appWidgetManager, appWidgetIds); } + @SuppressWarnings("deprecation") private static RemoteViews buildStackWidget(Context context, int widgetId, Entry entry) { RemoteViews views = new RemoteViews( context.getPackageName(), R.layout.appwidget_main); @@ -76,7 +77,10 @@ public class PhotoAppWidgetProvider extends AppWidgetProvider { intent.putExtra(WidgetService.EXTRA_ALBUM_PATH, entry.albumPath); intent.setData(Uri.parse("widget://gallery/" + widgetId)); - views.setRemoteAdapter(R.id.appwidget_stack_view, intent); + // We use the deprecated API for backward compatibility + // The new API is available in ICE_CREAM_SANDWICH (15) + views.setRemoteAdapter(widgetId, R.id.appwidget_stack_view, intent); + views.setEmptyView(R.id.appwidget_stack_view, R.id.appwidget_empty_view); Intent clickIntent = new Intent(context, WidgetClickHandler.class); -- GitLab From 89b83408acebc3ebf9bf6a19bb064473497dc920 Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Fri, 22 Jun 2012 10:55:29 -0700 Subject: [PATCH 044/763] Import translations. DO NOT MERGE Change-Id: If644f38aa01a00a9eb6906f487ec46c0f1a0d532 --- res/values-bg/strings.xml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/res/values-bg/strings.xml b/res/values-bg/strings.xml index 5b24bc2aa..80407dc6e 100644 --- a/res/values-bg/strings.xml +++ b/res/values-bg/strings.xml @@ -55,10 +55,8 @@ "Потвърждаване" "Отказ" "Споделяне" - - - - + "Изтрито" + "ОТМЯНА" "Избиране на всички" "Премахване на избора" "Слайдшоу" -- GitLab From 8b930828c7a33d668876972c22a515e9163592f7 Mon Sep 17 00:00:00 2001 From: Pin Ting Date: Wed, 20 Jun 2012 18:39:57 +0800 Subject: [PATCH 045/763] Use public OverScroller() instead of a hidden one.. Bug:6698374 Change-Id: I3a97d0b4bbfb5e2a1e9f4a656d39db636defcdbd --- .../android/gallery3d/ui/PositionController.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/com/android/gallery3d/ui/PositionController.java b/src/com/android/gallery3d/ui/PositionController.java index d556cafdc..6d334709d 100644 --- a/src/com/android/gallery3d/ui/PositionController.java +++ b/src/com/android/gallery3d/ui/PositionController.java @@ -110,11 +110,11 @@ class PositionController { private Listener mListener; private volatile Rect mOpenAnimationRect; - // Use a large enough value, so we won't see the gray shadown in the beginning. + // Use a large enough value, so we won't see the gray shadow in the beginning. private int mViewW = 1200; private int mViewH = 1200; - // A scaling guesture is in progress. + // A scaling gesture is in progress. private boolean mInScale; // The focus point of the scaling gesture, relative to the center of the // picture in bitmap pixels. @@ -178,7 +178,7 @@ class PositionController { private RangeArray mTempGaps = new RangeArray(-BOX_MAX, BOX_MAX - 1); - // The output of the PositionController. Available throught getPosition(). + // The output of the PositionController. Available through getPosition(). private RangeArray mRects = new RangeArray(-BOX_MAX, BOX_MAX); // The direction of a new picture should appear. New pictures pop from top @@ -211,7 +211,7 @@ class PositionController { mListener = listener; mPageScroller = new FlingScroller(); mFilmScroller = new OverScroller(context, - null /* default interpolator */, false /* no flywheel */); + null /* default interpolator */, 0, 0, false /* no flywheel */); // Initialize the areas. initPlatform(); @@ -519,7 +519,7 @@ class PositionController { Platform p = mPlatform; // We want to keep the focus point (on the bitmap) the same as when we - // begin the scale guesture, that is, + // begin the scale gesture, that is, // // (focusX' - currentX') / scale' = (focusX - currentX) / scale // @@ -1005,7 +1005,7 @@ class PositionController { // N N N N N N N -- all new boxes // -3 -2 -1 0 1 2 3 -- nothing changed // -2 -1 0 1 2 3 N -- focus goes to the next box - // N -3 -2 -1 0 1 2 -- focuse goes to the previous box + // N -3 -2 -1 0 1 2 -- focus goes to the previous box // -3 -2 -1 1 2 3 N -- the focused box was deleted. // // hasPrev/hasNext indicates if there are previous/next boxes for the @@ -1019,7 +1019,7 @@ class PositionController { RangeIntArray from = new RangeIntArray(fromIndex, -BOX_MAX, BOX_MAX); - // 1. Get the absolute X coordiates for the boxes. + // 1. Get the absolute X coordinates for the boxes. layoutAndSetPosition(); for (int i = -BOX_MAX; i <= BOX_MAX; i++) { Box b = mBoxes.get(i); @@ -1366,7 +1366,7 @@ class PositionController { public int mAnimationKind; public int mAnimationDuration; - // This should be overidden in subclass to change the animation values + // This should be overridden in subclass to change the animation values // give the progress value in [0, 1]. protected abstract boolean interpolate(float progress); public abstract boolean startSnapback(); -- GitLab From cccb63219fc92b7f6a6e322746f276e6f07c7dd0 Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Wed, 27 Jun 2012 15:28:07 +0800 Subject: [PATCH 046/763] Don't use Display.getSize(). Change-Id: I9b5c9021bae2b58d2815a909c97104f215d4d2e8 --- src/com/android/gallery3d/app/Wallpaper.java | 18 ++++++++++++++++-- .../android/gallery3d/util/GalleryUtils.java | 2 -- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/com/android/gallery3d/app/Wallpaper.java b/src/com/android/gallery3d/app/Wallpaper.java index c08c1d705..d64eecdcf 100644 --- a/src/com/android/gallery3d/app/Wallpaper.java +++ b/src/com/android/gallery3d/app/Wallpaper.java @@ -16,11 +16,14 @@ package com.android.gallery3d.app; +import android.annotation.TargetApi; import android.app.Activity; import android.content.Intent; import android.graphics.Point; import android.net.Uri; +import android.os.Build; import android.os.Bundle; +import android.view.Display; /** * Wallpaper picker for the gallery application. This just redirects to the @@ -57,6 +60,18 @@ public class Wallpaper extends Activity { } } + @SuppressWarnings("deprecation") + @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) + private Point getDefaultDisplaySize(Point size) { + Display d = getWindowManager().getDefaultDisplay(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { + d.getSize(size); + } else { + size.set(d.getWidth(), d.getHeight()); + } + return size; + } + @SuppressWarnings("fallthrough") @Override protected void onResume() { @@ -78,8 +93,7 @@ public class Wallpaper extends Activity { case STATE_PHOTO_PICKED: { int width = getWallpaperDesiredMinimumWidth(); int height = getWallpaperDesiredMinimumHeight(); - Point size = new Point(); - getWindowManager().getDefaultDisplay().getSize(size); + Point size = getDefaultDisplaySize(new Point()); float spotlightX = (float) size.x / width; float spotlightY = (float) size.y / height; Intent request = new Intent(CropImage.ACTION_CROP) diff --git a/src/com/android/gallery3d/util/GalleryUtils.java b/src/com/android/gallery3d/util/GalleryUtils.java index 1d70914ce..1291ee9f7 100644 --- a/src/com/android/gallery3d/util/GalleryUtils.java +++ b/src/com/android/gallery3d/util/GalleryUtils.java @@ -16,7 +16,6 @@ package com.android.gallery3d.util; -import android.app.Activity; import android.content.ActivityNotFoundException; import android.content.ComponentName; import android.content.Context; @@ -24,7 +23,6 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; -import android.content.res.Resources; import android.net.Uri; import android.os.ConditionVariable; import android.os.Environment; -- GitLab From a56270e9d7072be946569815712dea09b2544718 Mon Sep 17 00:00:00 2001 From: Hung-ying Tyan Date: Wed, 27 Jun 2012 18:25:47 +0800 Subject: [PATCH 047/763] Replace BroadcastReceiver.goAsync() with IntentService to make Gallery run on older API. Change-Id: I30dacb38eb4e70ed3f89135544d6c514d0379add --- AndroidManifest.xml | 1 + .../gallery3d/app/PackagesMonitor.java | 28 +++++++++---------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 2a69ce1e3..5fc501506 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -322,6 +322,7 @@ + diff --git a/src/com/android/gallery3d/app/PackagesMonitor.java b/src/com/android/gallery3d/app/PackagesMonitor.java index e4bb8eedb..c849df6d4 100644 --- a/src/com/android/gallery3d/app/PackagesMonitor.java +++ b/src/com/android/gallery3d/app/PackagesMonitor.java @@ -16,6 +16,7 @@ package com.android.gallery3d.app; +import android.app.IntentService; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -34,23 +35,22 @@ public class PackagesMonitor extends BroadcastReceiver { @Override public void onReceive(final Context context, final Intent intent) { - final PendingResult result = goAsync(); - new Thread("GalleryPackagesMonitorAsync") { - @Override - public void run() { - try { - onReceiveAsync(context, intent); - } catch (Throwable t) { - Log.e("PackagesMonitor", "onReceiveAsync", t); - } finally { - result.finish(); - } - } - }.start(); + context.startService(new Intent(context, AsyncService.class)); + } + + public static class AsyncService extends IntentService { + public AsyncService() { + super("GalleryPackagesMonitorAsync"); + } + + @Override + protected void onHandleIntent(Intent intent) { + onReceiveAsync(this, intent); + } } // Runs in a background thread. - private void onReceiveAsync(Context context, Intent intent) { + private static void onReceiveAsync(Context context, Intent intent) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); int version = prefs.getInt(KEY_PACKAGES_VERSION, 1); -- GitLab From 936663cb1be5d9fb498fc3a4000eb40dd60fcf30 Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Wed, 27 Jun 2012 11:23:44 -0700 Subject: [PATCH 048/763] Import translations. DO NOT MERGE Change-Id: Id2dc6d5f32fc724c03e0f3a628590f6f07f87357 --- res/values-af/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values-af/strings.xml b/res/values-af/strings.xml index 829d5a14f..1226ec145 100644 --- a/res/values-af/strings.xml +++ b/res/values-af/strings.xml @@ -55,7 +55,7 @@ "Bevestig" "Kanselleer" "Deling" - "geskrap" + "Uitgevee" "ONTDOEN" "Kies almal" "Ontkies almal" -- GitLab From 47006127731a472804002876a6d03da41a859d5d Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Wed, 27 Jun 2012 11:48:17 -0700 Subject: [PATCH 049/763] Import translations. DO NOT MERGE Change-Id: If975fd0d8a50a650b05756ba1a3202ac49df4748 --- res/values-af/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values-af/strings.xml b/res/values-af/strings.xml index 829d5a14f..1226ec145 100644 --- a/res/values-af/strings.xml +++ b/res/values-af/strings.xml @@ -55,7 +55,7 @@ "Bevestig" "Kanselleer" "Deling" - "geskrap" + "Uitgevee" "ONTDOEN" "Kies almal" "Ontkies almal" -- GitLab From 30aa92093126f00b46543ae3b5d1035a3270f240 Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Wed, 27 Jun 2012 19:01:21 +0800 Subject: [PATCH 050/763] Don't reuse bitmaps in BitmapRegionDecoder before JB. Change-Id: I8a2f520f98116af6861fa2cd1460e6f848bbb4e4 --- gallerycommon/Android.mk | 2 +- .../android/gallery3d/common/ApiHelper.java | 6 +++ .../android/gallery3d/ui/TileImageView.java | 13 +++-- .../gallery3d/ui/TileImageViewAdapter.java | 50 +++++++++++++++++++ 4 files changed, 65 insertions(+), 6 deletions(-) diff --git a/gallerycommon/Android.mk b/gallerycommon/Android.mk index a942de289..fb81dd950 100644 --- a/gallerycommon/Android.mk +++ b/gallerycommon/Android.mk @@ -22,6 +22,6 @@ include $(CLEAR_VARS) LOCAL_MODULE := com.android.gallery3d.common2 LOCAL_SRC_FILES := $(call all-java-files-under, src) -LOCAL_SDK_VERSION := 8 +LOCAL_SDK_VERSION := current include $(BUILD_STATIC_JAVA_LIBRARY) diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java index 15026bbf3..c42c5fed6 100644 --- a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java +++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java @@ -16,9 +16,12 @@ package com.android.gallery3d.common; +import android.annotation.TargetApi; +import android.os.Build; import android.provider.MediaStore.MediaColumns; import android.view.View; +@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public class ApiHelper { public static final boolean HAS_VIEW_SYSTEM_UI_FLAG_LAYOUT_STABLE = @@ -30,6 +33,9 @@ public class ApiHelper { public static final boolean HAS_MEDIA_COLUMNS_WIDTH_AND_HEIGHT = hasField(MediaColumns.class, "WIDTH"); + public static final boolean HAS_REUSING_BITMAP_IN_BITMAP_REGION_DECODER = + Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; + private static boolean hasField(Class klass, String fieldName) { try { klass.getDeclaredField(fieldName); diff --git a/src/com/android/gallery3d/ui/TileImageView.java b/src/com/android/gallery3d/ui/TileImageView.java index adbf850c1..fc61efd64 100644 --- a/src/com/android/gallery3d/ui/TileImageView.java +++ b/src/com/android/gallery3d/ui/TileImageView.java @@ -23,6 +23,7 @@ import android.graphics.RectF; import android.util.FloatMath; import com.android.gallery3d.app.GalleryContext; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.common.LongSparseArray; import com.android.gallery3d.common.Utils; import com.android.gallery3d.data.BitmapPool; @@ -48,7 +49,9 @@ public class TileImageView extends GLView { private static final int UPLOAD_LIMIT = 1; private static final BitmapPool sTilePool = - new BitmapPool(BITMAP_SIZE, BITMAP_SIZE, 128); + ApiHelper.HAS_REUSING_BITMAP_IN_BITMAP_REGION_DECODER + ? new BitmapPool(BITMAP_SIZE, BITMAP_SIZE, 128) + : null; /* * This is the tile state in the CPU side. @@ -378,7 +381,7 @@ public class TileImageView extends GLView { } } setScreenNail(null); - sTilePool.clear(); + if (sTilePool != null) sTilePool.clear(); } public void prepareTextures() { @@ -487,7 +490,7 @@ public class TileImageView extends GLView { if (tile.mTileState == STATE_RECYCLING) { tile.mTileState = STATE_RECYCLED; if (tile.mDecodedTile != null) { - sTilePool.recycle(tile.mDecodedTile); + if (sTilePool != null) sTilePool.recycle(tile.mDecodedTile); tile.mDecodedTile = null; } mRecycledQueue.push(tile); @@ -515,7 +518,7 @@ public class TileImageView extends GLView { } tile.mTileState = STATE_RECYCLED; if (tile.mDecodedTile != null) { - sTilePool.recycle(tile.mDecodedTile); + if (sTilePool != null) sTilePool.recycle(tile.mDecodedTile); tile.mDecodedTile = null; } mRecycledQueue.push(tile); @@ -653,7 +656,7 @@ public class TileImageView extends GLView { @Override protected void onFreeBitmap(Bitmap bitmap) { - sTilePool.recycle(bitmap); + if (sTilePool != null) sTilePool.recycle(bitmap); } boolean decode() { diff --git a/src/com/android/gallery3d/ui/TileImageViewAdapter.java b/src/com/android/gallery3d/ui/TileImageViewAdapter.java index 0b4ac0375..4865e5c67 100644 --- a/src/com/android/gallery3d/ui/TileImageViewAdapter.java +++ b/src/com/android/gallery3d/ui/TileImageViewAdapter.java @@ -20,8 +20,10 @@ import android.graphics.Bitmap; import android.graphics.Bitmap.Config; import android.graphics.BitmapFactory; import android.graphics.BitmapRegionDecoder; +import android.graphics.Canvas; import android.graphics.Rect; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.common.Utils; import com.android.gallery3d.data.BitmapPool; @@ -108,6 +110,11 @@ public class TileImageViewAdapter implements TileImageView.Model { @Override public Bitmap getTile(int level, int x, int y, int tileSize, int borderSize, BitmapPool pool) { + + if (!ApiHelper.HAS_REUSING_BITMAP_IN_BITMAP_REGION_DECODER) { + return getTileWithoutReusingBitmap(level, x, y, tileSize, borderSize); + } + int b = borderSize << level; int t = tileSize << level; @@ -158,6 +165,49 @@ public class TileImageViewAdapter implements TileImageView.Model { return bitmap; } + private Bitmap getTileWithoutReusingBitmap( + int level, int x, int y, int tileSize, int borderSize) { + int b = borderSize << level; + int t = tileSize << level; + Rect wantRegion = new Rect(x - b, y - b, x + t + b, y + t + b); + + BitmapRegionDecoder regionDecoder; + Rect overlapRegion; + + synchronized (this) { + regionDecoder = mRegionDecoder; + if (regionDecoder == null) return null; + overlapRegion = new Rect(0, 0, mImageWidth, mImageHeight); + Utils.assertTrue(overlapRegion.intersect(wantRegion)); + } + + BitmapFactory.Options options = new BitmapFactory.Options(); + options.inPreferredConfig = Config.ARGB_8888; + options.inPreferQualityOverSpeed = true; + options.inSampleSize = (1 << level); + Bitmap bitmap = null; + + // In CropImage, we may call the decodeRegion() concurrently. + synchronized (regionDecoder) { + bitmap = regionDecoder.decodeRegion(overlapRegion, options); + } + + if (bitmap == null) { + Log.w(TAG, "fail in decoding region"); + } + + if (wantRegion.equals(overlapRegion)) return bitmap; + + int s = tileSize + 2 * borderSize; + Bitmap result = Bitmap.createBitmap(s, s, Config.ARGB_8888); + Canvas canvas = new Canvas(result); + canvas.drawBitmap(bitmap, + (overlapRegion.left - wantRegion.left) >> level, + (overlapRegion.top - wantRegion.top) >> level, null); + return result; + } + + @Override public ScreenNail getScreenNail() { return mScreenNail; -- GitLab From 3a45725ad42324cd2db172fb082fe80772d94d3f Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Thu, 28 Jun 2012 11:10:02 +0800 Subject: [PATCH 051/763] Don't use Build.VERSION_CODES. Since they won't be available on old platform. bug: 6752318 Change-Id: I55a9e83dbf05b93c83c68cb31f6edcbc29793283 --- .../com/android/gallery3d/common/ApiHelper.java | 14 +++++++++++--- src/com/android/gallery3d/app/CropImage.java | 3 +-- src/com/android/gallery3d/app/MoviePlayer.java | 5 ++--- src/com/android/gallery3d/app/Wallpaper.java | 6 ++++-- src/com/android/gallery3d/data/LocalImage.java | 3 +-- src/com/android/gallery3d/ui/GLRootView.java | 3 +-- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java index c42c5fed6..85b092576 100644 --- a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java +++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java @@ -16,13 +16,21 @@ package com.android.gallery3d.common; -import android.annotation.TargetApi; import android.os.Build; import android.provider.MediaStore.MediaColumns; import android.view.View; -@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public class ApiHelper { + public static interface VERSION_CODES { + // These value are copied from Build.VERSION_CODES + public static final int GINGERBREAD_MR1 = 10; + public static final int HONEYCOMB = 11; + public static final int HONEYCOMB_MR1 = 12; + public static final int HONEYCOMB_MR2 = 13; + public static final int ICE_CREAM_SANDWICH = 14; + public static final int ICE_CREAM_SANDWICH_MR1 = 15; + public static final int JELLY_BEAN = 16; + } public static final boolean HAS_VIEW_SYSTEM_UI_FLAG_LAYOUT_STABLE = hasField(View.class, "SYSTEM_UI_FLAG_LAYOUT_STABLE"); @@ -34,7 +42,7 @@ public class ApiHelper { hasField(MediaColumns.class, "WIDTH"); public static final boolean HAS_REUSING_BITMAP_IN_BITMAP_REGION_DECODER = - Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; + Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN; private static boolean hasField(Class klass, String fieldName) { try { diff --git a/src/com/android/gallery3d/app/CropImage.java b/src/com/android/gallery3d/app/CropImage.java index 294e285ea..f2646978a 100644 --- a/src/com/android/gallery3d/app/CropImage.java +++ b/src/com/android/gallery3d/app/CropImage.java @@ -33,7 +33,6 @@ import android.graphics.Rect; import android.graphics.RectF; import android.media.ExifInterface; import android.net.Uri; -import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.os.Handler; @@ -370,7 +369,7 @@ public class CropImage extends AbstractGalleryActivity { } } - @TargetApi(Build.VERSION_CODES.JELLY_BEAN) + @TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN) private static void setImageSize(ContentValues values, int width, int height) { // The two fields are available since ICS but got published in JB if (ApiHelper.HAS_MEDIA_COLUMNS_WIDTH_AND_HEIGHT) { diff --git a/src/com/android/gallery3d/app/MoviePlayer.java b/src/com/android/gallery3d/app/MoviePlayer.java index c0f0ce739..98d7a6434 100644 --- a/src/com/android/gallery3d/app/MoviePlayer.java +++ b/src/com/android/gallery3d/app/MoviePlayer.java @@ -29,7 +29,6 @@ import android.graphics.Color; import android.media.AudioManager; import android.media.MediaPlayer; import android.net.Uri; -import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.view.KeyEvent; @@ -179,7 +178,7 @@ public class MoviePlayer implements } } - @TargetApi(Build.VERSION_CODES.JELLY_BEAN) + @TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN) private void setOnSystemUiVisibilityChangeListener() { if (!ApiHelper.HAS_VIEW_SYSTEM_UI_FLAG_HIDE_NAVIGATION) return; @@ -213,7 +212,7 @@ public class MoviePlayer implements }); } - @TargetApi(Build.VERSION_CODES.JELLY_BEAN) + @TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN) private void showSystemUi(boolean visible) { if (!ApiHelper.HAS_VIEW_SYSTEM_UI_FLAG_LAYOUT_STABLE) return; diff --git a/src/com/android/gallery3d/app/Wallpaper.java b/src/com/android/gallery3d/app/Wallpaper.java index d64eecdcf..1ece66c49 100644 --- a/src/com/android/gallery3d/app/Wallpaper.java +++ b/src/com/android/gallery3d/app/Wallpaper.java @@ -25,6 +25,8 @@ import android.os.Build; import android.os.Bundle; import android.view.Display; +import com.android.gallery3d.common.ApiHelper; + /** * Wallpaper picker for the gallery application. This just redirects to the * standard pick action. @@ -61,10 +63,10 @@ public class Wallpaper extends Activity { } @SuppressWarnings("deprecation") - @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) + @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB_MR2) private Point getDefaultDisplaySize(Point size) { Display d = getWindowManager().getDefaultDisplay(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { + if (Build.VERSION.SDK_INT >= ApiHelper.VERSION_CODES.HONEYCOMB_MR2) { d.getSize(size); } else { size.set(d.getWidth(), d.getHeight()); diff --git a/src/com/android/gallery3d/data/LocalImage.java b/src/com/android/gallery3d/data/LocalImage.java index c432ab44d..316e32469 100644 --- a/src/com/android/gallery3d/data/LocalImage.java +++ b/src/com/android/gallery3d/data/LocalImage.java @@ -25,7 +25,6 @@ import android.graphics.BitmapFactory; import android.graphics.BitmapRegionDecoder; import android.media.ExifInterface; import android.net.Uri; -import android.os.Build; import android.provider.MediaStore.Images; import android.provider.MediaStore.Images.ImageColumns; import android.provider.MediaStore.MediaColumns; @@ -86,7 +85,7 @@ public class LocalImage extends LocalMediaItem { updateWidthAndHeightProjection(); } - @TargetApi(Build.VERSION_CODES.JELLY_BEAN) + @TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN) private static void updateWidthAndHeightProjection() { if (ApiHelper.HAS_MEDIA_COLUMNS_WIDTH_AND_HEIGHT) { PROJECTION[INDEX_WIDTH] = MediaColumns.WIDTH; diff --git a/src/com/android/gallery3d/ui/GLRootView.java b/src/com/android/gallery3d/ui/GLRootView.java index 2068520aa..478cb4f87 100644 --- a/src/com/android/gallery3d/ui/GLRootView.java +++ b/src/com/android/gallery3d/ui/GLRootView.java @@ -21,7 +21,6 @@ import android.content.Context; import android.graphics.Matrix; import android.graphics.PixelFormat; import android.opengl.GLSurfaceView; -import android.os.Build; import android.os.Process; import android.os.SystemClock; import android.util.AttributeSet; @@ -539,7 +538,7 @@ public class GLRootView extends GLSurfaceView } @Override - @TargetApi(Build.VERSION_CODES.JELLY_BEAN) + @TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN) public void setLightsOutMode(boolean enabled) { int flags = 0; if (enabled) { -- GitLab From 9d272d79cccd5c74c1bf1996d7d7beb353d50b6a Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Thu, 28 Jun 2012 10:12:25 -0700 Subject: [PATCH 052/763] Import translations. DO NOT MERGE Change-Id: I4ea9a929181ee1b09cdd4628af095ffaa86646e3 Auto-generated-cl: translation import --- res/values-sw/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values-sw/strings.xml b/res/values-sw/strings.xml index 4cd15aafc..c69fed2ed 100644 --- a/res/values-sw/strings.xml +++ b/res/values-sw/strings.xml @@ -56,7 +56,7 @@ "Ghairi" "Shiriki" "Imefutwa" - "UNDO" + "TENDUA" "Chagua zote" "Ghairi uteuzi kwa zote" "Onyesho la slaidi" -- GitLab From 59a38959ba90a0760e7850e72e03d69900d5ac63 Mon Sep 17 00:00:00 2001 From: Hung-ying Tyan Date: Fri, 29 Jun 2012 12:11:54 +0800 Subject: [PATCH 053/763] Pass correct intent to IntentService in PackagesMonitor Bug: 6755040 Change-Id: I073f4acd026cfcae3e2f4759657324f48b7238c4 --- src/com/android/gallery3d/app/PackagesMonitor.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/com/android/gallery3d/app/PackagesMonitor.java b/src/com/android/gallery3d/app/PackagesMonitor.java index c849df6d4..d8aa8c914 100644 --- a/src/com/android/gallery3d/app/PackagesMonitor.java +++ b/src/com/android/gallery3d/app/PackagesMonitor.java @@ -35,7 +35,8 @@ public class PackagesMonitor extends BroadcastReceiver { @Override public void onReceive(final Context context, final Intent intent) { - context.startService(new Intent(context, AsyncService.class)); + intent.setClass(context, AsyncService.class); + context.startService(intent); } public static class AsyncService extends IntentService { -- GitLab From f8e36b36cecf6c7330041356425756dd8d76e949 Mon Sep 17 00:00:00 2001 From: Wu-cheng Li Date: Fri, 29 Jun 2012 18:21:15 +0800 Subject: [PATCH 054/763] Make gallery/camera build in JB API level. Bug:4965992 Change-Id: I91e56aacb5447c811aafce756292ab5ee0636cee --- Android.mk | 2 +- AndroidManifest.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Android.mk b/Android.mk index ea71b3958..b0ebf899a 100644 --- a/Android.mk +++ b/Android.mk @@ -18,7 +18,7 @@ LOCAL_PACKAGE_NAME := Gallery2 LOCAL_OVERRIDES_PACKAGES := Gallery Gallery3D GalleryNew3D -#LOCAL_SDK_VERSION := current +LOCAL_SDK_VERSION := current LOCAL_JNI_SHARED_LIBRARIES := libjni_mosaic libjni_eglfence diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 5fc501506..c7a693b43 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -7,7 +7,7 @@ - + -- GitLab From fc86994f86f8cfb31e151c9e730dc1e9dc7b3349 Mon Sep 17 00:00:00 2001 From: Yuli Huang Date: Fri, 29 Jun 2012 18:59:17 +0800 Subject: [PATCH 055/763] Do not use NfcAdapter API in old platforms. bug:6698904 Change-Id: I8cab312a212e4cba43187a73bc76d3f2164527a9 --- src/com/android/gallery3d/app/PhotoPage.java | 19 +++++++++++---- .../gallery3d/ui/ActionModeHandler.java | 24 +++++++++++-------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index 17f57c204..22b01637e 100644 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -16,6 +16,7 @@ package com.android.gallery3d.app; +import android.annotation.TargetApi; import android.app.ActionBar.OnMenuVisibilityListener; import android.app.Activity; import android.content.ActivityNotFoundException; @@ -25,6 +26,7 @@ import android.content.Intent; import android.graphics.Rect; import android.net.Uri; import android.nfc.NfcAdapter; +import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Message; @@ -37,6 +39,7 @@ import android.widget.ShareActionProvider; import android.widget.Toast; import com.android.gallery3d.R; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.common.Utils; import com.android.gallery3d.data.DataManager; import com.android.gallery3d.data.FilterDeleteSet; @@ -318,18 +321,24 @@ public class PhotoPage extends ActivityState implements } } + @TargetApi(Build.VERSION_CODES.JELLY_BEAN) + private void setNfcBeamPushUris(Uri[] uris) { + if (mNfcAdapter != null && + Build.VERSION.SDK_INT >= ApiHelper.VERSION_CODES.JELLY_BEAN) { + mNfcAdapter.setBeamPushUris(uris, (Activity)mActivity); + } + } + private void updateShareURI(Path path) { if (mShareActionProvider != null) { DataManager manager = mActivity.getDataManager(); int type = manager.getMediaType(path); Intent intent = new Intent(Intent.ACTION_SEND); intent.setType(MenuExecutor.getMimeType(type)); - intent.putExtra(Intent.EXTRA_STREAM, manager.getContentUri(path)); + Uri uri = manager.getContentUri(path); + intent.putExtra(Intent.EXTRA_STREAM, uri); mShareActionProvider.setShareIntent(intent); - if (mNfcAdapter != null) { - mNfcAdapter.setBeamPushUris(new Uri[]{manager.getContentUri(path)}, - (Activity)mActivity); - } + setNfcBeamPushUris(new Uri[]{uri}); mPendingSharePath = null; } else { // This happens when ActionBar is not created yet. diff --git a/src/com/android/gallery3d/ui/ActionModeHandler.java b/src/com/android/gallery3d/ui/ActionModeHandler.java index 746d41d4b..2a0157a4b 100644 --- a/src/com/android/gallery3d/ui/ActionModeHandler.java +++ b/src/com/android/gallery3d/ui/ActionModeHandler.java @@ -16,11 +16,13 @@ package com.android.gallery3d.ui; +import android.annotation.TargetApi; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.nfc.NfcAdapter; +import android.os.Build; import android.os.Handler; import android.view.ActionMode; import android.view.LayoutInflater; @@ -36,6 +38,7 @@ import android.widget.ShareActionProvider.OnShareTargetSelectedListener; import com.android.gallery3d.R; import com.android.gallery3d.app.GalleryActionBar; import com.android.gallery3d.app.GalleryActivity; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.common.Utils; import com.android.gallery3d.data.DataManager; import com.android.gallery3d.data.MediaObject; @@ -224,14 +227,20 @@ public class ActionModeHandler implements ActionMode.Callback { return operation; } + @TargetApi(Build.VERSION_CODES.JELLY_BEAN) + private void setNfcBeamPushUris(Uri[] uris) { + if (mNfcAdapter != null && + Build.VERSION.SDK_INT >= ApiHelper.VERSION_CODES.JELLY_BEAN) { + mNfcAdapter.setBeamPushUris(uris, (Activity)mActivity); + } + } + // Share intent needs to expand the selection set so we can get URI of // each media item private Intent computeSharingIntent(JobContext jc) { ArrayList expandedPaths = mSelectionManager.getSelected(true); if (expandedPaths.size() == 0) { - if (mNfcAdapter != null) { - mNfcAdapter.setBeamPushUris(null, (Activity)mActivity); - } + setNfcBeamPushUris(null); return null; } final ArrayList uris = new ArrayList(); @@ -259,14 +268,9 @@ public class ActionModeHandler implements ActionMode.Callback { intent.putExtra(Intent.EXTRA_STREAM, uris.get(0)); } intent.setType(mimeType); - if (mNfcAdapter != null) { - mNfcAdapter.setBeamPushUris(uris.toArray(new Uri[uris.size()]), - (Activity)mActivity); - } + setNfcBeamPushUris(uris.toArray(new Uri[uris.size()])); } else { - if (mNfcAdapter != null) { - mNfcAdapter.setBeamPushUris(null, (Activity)mActivity); - } + setNfcBeamPushUris(null); } return intent; -- GitLab From e18dd7c80a69a8139a3397d2e6f97a1dce9f608c Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Fri, 29 Jun 2012 10:13:45 -0700 Subject: [PATCH 056/763] Import translations. DO NOT MERGE Change-Id: I7eac634e7f838f0eea492ec6b01fec518a7a3b39 Auto-generated-cl: translation import --- res/values-af/strings.xml | 4 ++++ res/values-am/strings.xml | 4 ++++ res/values-ar/strings.xml | 4 ++++ res/values-be/strings.xml | 4 ++++ res/values-bg/strings.xml | 4 ++++ res/values-ca/strings.xml | 4 ++++ res/values-cs/strings.xml | 4 ++++ res/values-da/strings.xml | 4 ++++ res/values-de/strings.xml | 4 ++++ res/values-el/strings.xml | 4 ++++ res/values-en-rGB/strings.xml | 4 ++++ res/values-es-rUS/strings.xml | 4 ++++ res/values-es/strings.xml | 4 ++++ res/values-et/strings.xml | 4 ++++ res/values-fa/strings.xml | 4 ++++ res/values-fi/strings.xml | 4 ++++ res/values-fr/strings.xml | 4 ++++ res/values-hi/strings.xml | 4 ++++ res/values-hr/strings.xml | 4 ++++ res/values-hu/strings.xml | 4 ++++ res/values-in/strings.xml | 4 ++++ res/values-it/strings.xml | 4 ++++ res/values-iw/strings.xml | 4 ++++ res/values-ja/strings.xml | 4 ++++ res/values-ko/strings.xml | 4 ++++ res/values-lt/strings.xml | 4 ++++ res/values-lv/strings.xml | 4 ++++ res/values-ms/strings.xml | 4 ++++ res/values-nb/strings.xml | 4 ++++ res/values-nl/strings.xml | 4 ++++ res/values-pl/strings.xml | 4 ++++ res/values-pt-rPT/strings.xml | 4 ++++ res/values-pt/strings.xml | 4 ++++ res/values-rm/strings.xml | 4 ++++ res/values-ro/strings.xml | 4 ++++ res/values-ru/strings.xml | 4 ++++ res/values-sk/strings.xml | 4 ++++ res/values-sl/strings.xml | 4 ++++ res/values-sr/strings.xml | 4 ++++ res/values-sv/strings.xml | 4 ++++ res/values-sw/strings.xml | 4 ++++ res/values-th/strings.xml | 4 ++++ res/values-tl/strings.xml | 4 ++++ res/values-tr/strings.xml | 4 ++++ res/values-uk/strings.xml | 4 ++++ res/values-vi/strings.xml | 4 ++++ res/values-zh-rCN/strings.xml | 4 ++++ res/values-zh-rTW/strings.xml | 4 ++++ res/values-zu/strings.xml | 4 ++++ 49 files changed, 196 insertions(+) diff --git a/res/values-af/strings.xml b/res/values-af/strings.xml index 1226ec145..2e4fd27c0 100644 --- a/res/values-af/strings.xml +++ b/res/values-af/strings.xml @@ -173,4 +173,8 @@ "Ingevoer" "Skermkiekie" "Hulp" + + + + diff --git a/res/values-am/strings.xml b/res/values-am/strings.xml index 3a29f4fa3..8fc98ec36 100644 --- a/res/values-am/strings.xml +++ b/res/values-am/strings.xml @@ -173,4 +173,8 @@ "ከውጭ የገባ" "ቅጽበታዊ ገጽ እይታ" "እገዛ" + + + + diff --git a/res/values-ar/strings.xml b/res/values-ar/strings.xml index 0403cf538..8549b003b 100644 --- a/res/values-ar/strings.xml +++ b/res/values-ar/strings.xml @@ -173,4 +173,8 @@ "المستوردة" "لقطة شاشة" "المساعدة" + + + + diff --git a/res/values-be/strings.xml b/res/values-be/strings.xml index 37a0872b2..74b23628e 100644 --- a/res/values-be/strings.xml +++ b/res/values-be/strings.xml @@ -173,4 +173,8 @@ "Імпартаваныя" "Скрыншот" "Даведка" + + + + diff --git a/res/values-bg/strings.xml b/res/values-bg/strings.xml index 80407dc6e..321ab260c 100644 --- a/res/values-bg/strings.xml +++ b/res/values-bg/strings.xml @@ -173,4 +173,8 @@ "Импортирани" "Екранна снимка" "Помощ" + + + + diff --git a/res/values-ca/strings.xml b/res/values-ca/strings.xml index fcfdda602..56697efb4 100644 --- a/res/values-ca/strings.xml +++ b/res/values-ca/strings.xml @@ -173,4 +173,8 @@ "Importades" "Captura de pantalla" "Ajuda" + + + + diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml index 0aa06dbe7..04e60859a 100644 --- a/res/values-cs/strings.xml +++ b/res/values-cs/strings.xml @@ -173,4 +173,8 @@ "Importováno" "Snímky obrazovky" "Nápověda" + + + + diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml index 1bb78897a..76c3e3168 100644 --- a/res/values-da/strings.xml +++ b/res/values-da/strings.xml @@ -173,4 +173,8 @@ "Importeret" "Skærmbillede" "Hjælp" + + + + diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index 13b507ee8..1a97bc9db 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -173,4 +173,8 @@ "Importiert" "Screenshots" "Hilfe" + + + + diff --git a/res/values-el/strings.xml b/res/values-el/strings.xml index c2ca79319..691a3020f 100644 --- a/res/values-el/strings.xml +++ b/res/values-el/strings.xml @@ -173,4 +173,8 @@ "Έγινε εισαγωγή" "Στιγμιότυπο οθόνης" "Βοήθεια" + + + + diff --git a/res/values-en-rGB/strings.xml b/res/values-en-rGB/strings.xml index b08ee8daa..a2f68d8f9 100644 --- a/res/values-en-rGB/strings.xml +++ b/res/values-en-rGB/strings.xml @@ -173,4 +173,8 @@ "Imported" "Screenshot" "Help" + + + + diff --git a/res/values-es-rUS/strings.xml b/res/values-es-rUS/strings.xml index 7aff521a2..86b8f4d41 100644 --- a/res/values-es-rUS/strings.xml +++ b/res/values-es-rUS/strings.xml @@ -173,4 +173,8 @@ "Importadas" "Capturas de pantalla" "Ayuda" + + + + diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index 2edbdf5cf..7d1071b6c 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -173,4 +173,8 @@ "Importadas" "Capturas de pantalla" "Ayuda" + + + + diff --git a/res/values-et/strings.xml b/res/values-et/strings.xml index 96d05cddd..e0b4c5883 100644 --- a/res/values-et/strings.xml +++ b/res/values-et/strings.xml @@ -173,4 +173,8 @@ "Imporditud" "Ekraanipilt" "Abi" + + + + diff --git a/res/values-fa/strings.xml b/res/values-fa/strings.xml index 781909067..2055299bd 100644 --- a/res/values-fa/strings.xml +++ b/res/values-fa/strings.xml @@ -173,4 +173,8 @@ "وارد شده" "عکس صفحه" "راهنما" + + + + diff --git a/res/values-fi/strings.xml b/res/values-fi/strings.xml index 508eb8f61..b46601df7 100644 --- a/res/values-fi/strings.xml +++ b/res/values-fi/strings.xml @@ -173,4 +173,8 @@ "Tuonti" "Kuvakaappaus" "Ohje" + + + + diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index 611ab1dee..96c1dc923 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -173,4 +173,8 @@ "Importations" "Captures d\'écran" "Aide" + + + + diff --git a/res/values-hi/strings.xml b/res/values-hi/strings.xml index 4aa4d357d..813a4f069 100644 --- a/res/values-hi/strings.xml +++ b/res/values-hi/strings.xml @@ -173,4 +173,8 @@ "आयातित" "स्क्रीनशॉट" "सहायता" + + + + diff --git a/res/values-hr/strings.xml b/res/values-hr/strings.xml index 7cb659bb3..14eee83c9 100644 --- a/res/values-hr/strings.xml +++ b/res/values-hr/strings.xml @@ -173,4 +173,8 @@ "Uvezeno" "Snimak zaslona" "Pomoć" + + + + diff --git a/res/values-hu/strings.xml b/res/values-hu/strings.xml index f933833b4..4afaaf9d3 100644 --- a/res/values-hu/strings.xml +++ b/res/values-hu/strings.xml @@ -173,4 +173,8 @@ "Importált" "Képernyőkép" "Súgó" + + + + diff --git a/res/values-in/strings.xml b/res/values-in/strings.xml index b1c2ddf38..c1c4ae664 100644 --- a/res/values-in/strings.xml +++ b/res/values-in/strings.xml @@ -173,4 +173,8 @@ "Diimpor" "Tangkapan Layar" "Bantuan" + + + + diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index 4cd7c868f..7484105dc 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -173,4 +173,8 @@ "Importate" "Screenshot" "Guida" + + + + diff --git a/res/values-iw/strings.xml b/res/values-iw/strings.xml index 3e1d8439f..a14f1b779 100644 --- a/res/values-iw/strings.xml +++ b/res/values-iw/strings.xml @@ -173,4 +173,8 @@ "מיובאות" "צילום מסך" "עזרה" + + + + diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml index 10588e11c..7067372b2 100644 --- a/res/values-ja/strings.xml +++ b/res/values-ja/strings.xml @@ -173,4 +173,8 @@ "インポート済み" "スクリーンショット" "ヘルプ" + + + + diff --git a/res/values-ko/strings.xml b/res/values-ko/strings.xml index b12d9f96b..016a8bcb5 100644 --- a/res/values-ko/strings.xml +++ b/res/values-ko/strings.xml @@ -173,4 +173,8 @@ "가져옴" "스크린샷" "도움말" + + + + diff --git a/res/values-lt/strings.xml b/res/values-lt/strings.xml index da768e9be..8bc098b0e 100644 --- a/res/values-lt/strings.xml +++ b/res/values-lt/strings.xml @@ -173,4 +173,8 @@ "Importuota" "Ekrano kopija" "Pagalba" + + + + diff --git a/res/values-lv/strings.xml b/res/values-lv/strings.xml index d73516702..1a14aa9f5 100644 --- a/res/values-lv/strings.xml +++ b/res/values-lv/strings.xml @@ -173,4 +173,8 @@ "Importētie" "Ekrānuzņēmums" "Palīdzība" + + + + diff --git a/res/values-ms/strings.xml b/res/values-ms/strings.xml index 04988bc0d..df48fd8f5 100644 --- a/res/values-ms/strings.xml +++ b/res/values-ms/strings.xml @@ -173,4 +173,8 @@ "Diimport" "Tangkapan skrin" "Bantuan" + + + + diff --git a/res/values-nb/strings.xml b/res/values-nb/strings.xml index 6a34ab251..25422eda2 100644 --- a/res/values-nb/strings.xml +++ b/res/values-nb/strings.xml @@ -173,4 +173,8 @@ "Importert" "Skjermdump" "Brukerstøtte" + + + + diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml index a535d4656..45065802b 100644 --- a/res/values-nl/strings.xml +++ b/res/values-nl/strings.xml @@ -173,4 +173,8 @@ "Geïmporteerd" "Schermafbeelding" "Help" + + + + diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml index bddda6a1f..cd1fa91ce 100644 --- a/res/values-pl/strings.xml +++ b/res/values-pl/strings.xml @@ -173,4 +173,8 @@ "Zaimportowane" "Zrzuty ekranu" "Pomoc" + + + + diff --git a/res/values-pt-rPT/strings.xml b/res/values-pt-rPT/strings.xml index de3a7ea95..1c6b15018 100644 --- a/res/values-pt-rPT/strings.xml +++ b/res/values-pt-rPT/strings.xml @@ -173,4 +173,8 @@ "Importada" "Captura de ecrã" "Ajuda" + + + + diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml index bf54c2806..cce8e775a 100644 --- a/res/values-pt/strings.xml +++ b/res/values-pt/strings.xml @@ -173,4 +173,8 @@ "Importado" "Capturas de tela" "Ajuda" + + + + diff --git a/res/values-rm/strings.xml b/res/values-rm/strings.xml index ec361e8ad..1422012c8 100644 --- a/res/values-rm/strings.xml +++ b/res/values-rm/strings.xml @@ -272,4 +272,8 @@ + + + + diff --git a/res/values-ro/strings.xml b/res/values-ro/strings.xml index b84bbd068..423ec82b2 100644 --- a/res/values-ro/strings.xml +++ b/res/values-ro/strings.xml @@ -173,4 +173,8 @@ "Importate" "Captură de ecran" "Ajutor" + + + + diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index 85610587b..027afdbf4 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -173,4 +173,8 @@ "Импортированные" "Скриншоты" "Справка" + + + + diff --git a/res/values-sk/strings.xml b/res/values-sk/strings.xml index 68840687d..8bf48b042 100644 --- a/res/values-sk/strings.xml +++ b/res/values-sk/strings.xml @@ -173,4 +173,8 @@ "Importované" "Snímka obrazovky" "Pomocník" + + + + diff --git a/res/values-sl/strings.xml b/res/values-sl/strings.xml index 8f2fdf2fe..3917d2cf1 100644 --- a/res/values-sl/strings.xml +++ b/res/values-sl/strings.xml @@ -173,4 +173,8 @@ "Uvoženo" "Posnetek zaslona" "Pomoč" + + + + diff --git a/res/values-sr/strings.xml b/res/values-sr/strings.xml index dedc12fee..b5bb5f2ba 100644 --- a/res/values-sr/strings.xml +++ b/res/values-sr/strings.xml @@ -173,4 +173,8 @@ "Увезено" "Снимак екрана" "Помоћ" + + + + diff --git a/res/values-sv/strings.xml b/res/values-sv/strings.xml index a673a0119..78822b232 100644 --- a/res/values-sv/strings.xml +++ b/res/values-sv/strings.xml @@ -173,4 +173,8 @@ "Importerat" "Skärmbild" "Hjälp" + + + + diff --git a/res/values-sw/strings.xml b/res/values-sw/strings.xml index c69fed2ed..85d6c8e4c 100644 --- a/res/values-sw/strings.xml +++ b/res/values-sw/strings.xml @@ -176,4 +176,8 @@ "Zilizoletwa" "Picha kiwamba" "Msaada" + + + + diff --git a/res/values-th/strings.xml b/res/values-th/strings.xml index 24d2acf61..7276dca2e 100644 --- a/res/values-th/strings.xml +++ b/res/values-th/strings.xml @@ -173,4 +173,8 @@ "นำเข้าแล้ว" "ภาพหน้าจอ" "ความช่วยเหลือ" + + + + diff --git a/res/values-tl/strings.xml b/res/values-tl/strings.xml index 36ee4dc6c..239d26a46 100644 --- a/res/values-tl/strings.xml +++ b/res/values-tl/strings.xml @@ -173,4 +173,8 @@ "Na-import" "Screenshot" "Tulong" + + + + diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml index 1e3c34159..113da0eb6 100644 --- a/res/values-tr/strings.xml +++ b/res/values-tr/strings.xml @@ -173,4 +173,8 @@ "İçe aktarıldı" "Ekran görüntüsü" "Yardım" + + + + diff --git a/res/values-uk/strings.xml b/res/values-uk/strings.xml index 4700e294c..49bea9c17 100644 --- a/res/values-uk/strings.xml +++ b/res/values-uk/strings.xml @@ -173,4 +173,8 @@ "Імпортовані" "Знімки екрана" "Довідка" + + + + diff --git a/res/values-vi/strings.xml b/res/values-vi/strings.xml index 02784073d..eb454a031 100644 --- a/res/values-vi/strings.xml +++ b/res/values-vi/strings.xml @@ -173,4 +173,8 @@ "Đã nhập" "Ảnh chụp màn hình" "Trợ giúp" + + + + diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index 9bd5195a8..5ebb05197 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -173,4 +173,8 @@ "已导入" "屏幕截图" "帮助" + + + + diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml index 722e0babc..2628b6c1c 100644 --- a/res/values-zh-rTW/strings.xml +++ b/res/values-zh-rTW/strings.xml @@ -173,4 +173,8 @@ "匯入" "螢幕擷取畫面" "說明" + + + + diff --git a/res/values-zu/strings.xml b/res/values-zu/strings.xml index a6c983060..009cae796 100644 --- a/res/values-zu/strings.xml +++ b/res/values-zu/strings.xml @@ -175,4 +175,8 @@ "Okulandiwe" "Isithombe-skrini" "Usizo" + + + + -- GitLab From b86930228a01c783078005627fbe2bc79f3a88fb Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Mon, 2 Jul 2012 11:11:42 -0700 Subject: [PATCH 057/763] Import translations. DO NOT MERGE Change-Id: I5d153253458dc03fab2e24a08c9208eec6552bdd Auto-generated-cl: translation import --- res/values-be/strings.xml | 6 ++---- res/values-ca/strings.xml | 6 ++---- res/values-en-rGB/strings.xml | 6 ++---- res/values-fa/strings.xml | 6 ++---- res/values-it/strings.xml | 6 ++---- res/values-iw/strings.xml | 6 ++---- res/values-ru/strings.xml | 6 ++---- res/values-sv/strings.xml | 6 ++---- res/values-sw/strings.xml | 6 ++---- res/values-th/strings.xml | 6 ++---- res/values-zu/strings.xml | 6 ++---- 11 files changed, 22 insertions(+), 44 deletions(-) diff --git a/res/values-be/strings.xml b/res/values-be/strings.xml index 74b23628e..d6f9dd5f3 100644 --- a/res/values-be/strings.xml +++ b/res/values-be/strings.xml @@ -173,8 +173,6 @@ "Імпартаваныя" "Скрыншот" "Даведка" - - - - + "Няма захавальнiкаў" + "Няма даступных знешнiх захавальнiкаў" diff --git a/res/values-ca/strings.xml b/res/values-ca/strings.xml index 56697efb4..b461bf51c 100644 --- a/res/values-ca/strings.xml +++ b/res/values-ca/strings.xml @@ -173,8 +173,6 @@ "Importades" "Captura de pantalla" "Ajuda" - - - - + "No hi ha emmagatzem." + "No hi ha emmagatzematge extern disponible" diff --git a/res/values-en-rGB/strings.xml b/res/values-en-rGB/strings.xml index a2f68d8f9..f94b04197 100644 --- a/res/values-en-rGB/strings.xml +++ b/res/values-en-rGB/strings.xml @@ -173,8 +173,6 @@ "Imported" "Screenshot" "Help" - - - - + "No Storage" + "No external storage available" diff --git a/res/values-fa/strings.xml b/res/values-fa/strings.xml index 2055299bd..4ed530228 100644 --- a/res/values-fa/strings.xml +++ b/res/values-fa/strings.xml @@ -173,8 +173,6 @@ "وارد شده" "عکس صفحه" "راهنما" - - - - + "فاقد دستگاه ذخیره‌‌‌سازی" + "هیچ دستگاه ذخیره خارجی دردسترس نیست" diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index 7484105dc..d27ceb2cb 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -173,8 +173,6 @@ "Importate" "Screenshot" "Guida" - - - - + "Nessun archivio" + "Nessun archivio esterno disponibile" diff --git a/res/values-iw/strings.xml b/res/values-iw/strings.xml index a14f1b779..7ff250377 100644 --- a/res/values-iw/strings.xml +++ b/res/values-iw/strings.xml @@ -173,8 +173,6 @@ "מיובאות" "צילום מסך" "עזרה" - - - - + "אין אחסון" + "אחסון חיצוני לא זמין" diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index 027afdbf4..0aaab06b1 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -173,8 +173,6 @@ "Импортированные" "Скриншоты" "Справка" - - - - + "Накопитель не найден" + "Нет внешних накопителей" diff --git a/res/values-sv/strings.xml b/res/values-sv/strings.xml index 78822b232..3e3043b6d 100644 --- a/res/values-sv/strings.xml +++ b/res/values-sv/strings.xml @@ -173,8 +173,6 @@ "Importerat" "Skärmbild" "Hjälp" - - - - + "Ingen lagringsenhet" + "Inget externt lagringsutrymme är tillgängligt" diff --git a/res/values-sw/strings.xml b/res/values-sw/strings.xml index 85d6c8e4c..45438f492 100644 --- a/res/values-sw/strings.xml +++ b/res/values-sw/strings.xml @@ -176,8 +176,6 @@ "Zilizoletwa" "Picha kiwamba" "Msaada" - - - - + "Hakuna Hifadhi" + "Hakuna hifadhi ya nje inayopatikana" diff --git a/res/values-th/strings.xml b/res/values-th/strings.xml index 7276dca2e..24fcd247e 100644 --- a/res/values-th/strings.xml +++ b/res/values-th/strings.xml @@ -173,8 +173,6 @@ "นำเข้าแล้ว" "ภาพหน้าจอ" "ความช่วยเหลือ" - - - - + "ไม่มีที่เก็บข้อมูล" + "ไม่มีที่จัดเก็บข้อมูลภายนอกที่สามารถใช้ได้" diff --git a/res/values-zu/strings.xml b/res/values-zu/strings.xml index 009cae796..8bf89d8d6 100644 --- a/res/values-zu/strings.xml +++ b/res/values-zu/strings.xml @@ -175,8 +175,6 @@ "Okulandiwe" "Isithombe-skrini" "Usizo" - - - - + "Asikho isilondolozi" + "Asikho isilondolozi sangaphandle esikhona" -- GitLab From ca7d9bfb42c1d5037bcecdde30eb836755140b03 Mon Sep 17 00:00:00 2001 From: The Android Open Source Project Date: Fri, 29 Jun 2012 08:19:39 -0700 Subject: [PATCH 058/763] Avoid using View.SYSTEM_UI_FLAG_LOW_PROFILE. Use View.STATUS_BAR_HIDDEN instead. Bug:6706727 Change-Id: I0324a251b10eba11350f1813ee975d493bbcfafa --- src/com/android/gallery3d/app/MoviePlayer.java | 2 +- src/com/android/gallery3d/ui/GLRootView.java | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/com/android/gallery3d/app/MoviePlayer.java b/src/com/android/gallery3d/app/MoviePlayer.java index 98d7a6434..4f72c13ba 100644 --- a/src/com/android/gallery3d/app/MoviePlayer.java +++ b/src/com/android/gallery3d/app/MoviePlayer.java @@ -220,7 +220,7 @@ public class MoviePlayer implements | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE; if (!visible) { - flag |= View.SYSTEM_UI_FLAG_LOW_PROFILE | View.SYSTEM_UI_FLAG_FULLSCREEN + flag |= View.STATUS_BAR_HIDDEN | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; } mVideoView.setSystemUiVisibility(flag); diff --git a/src/com/android/gallery3d/ui/GLRootView.java b/src/com/android/gallery3d/ui/GLRootView.java index 478cb4f87..401ca59eb 100644 --- a/src/com/android/gallery3d/ui/GLRootView.java +++ b/src/com/android/gallery3d/ui/GLRootView.java @@ -84,9 +84,6 @@ public class GLRootView extends GLSurfaceView private Matrix mCompensationMatrix = new Matrix(); private int mDisplayRotation; - // The value which will become mCompensation in next layout. - private int mPendingCompensation; - private int mFlags = FLAG_NEED_LAYOUT; private volatile boolean mRenderRequested = false; @@ -333,6 +330,7 @@ public class GLRootView extends GLSurfaceView if (mFirstDraw) { mFirstDraw = false; post(new Runnable() { + @Override public void run() { View root = getRootView(); View cover = root.findViewById(R.id.gl_root_cover); @@ -542,7 +540,7 @@ public class GLRootView extends GLSurfaceView public void setLightsOutMode(boolean enabled) { int flags = 0; if (enabled) { - flags = SYSTEM_UI_FLAG_LOW_PROFILE; + flags = STATUS_BAR_HIDDEN; if (ApiHelper.HAS_VIEW_SYSTEM_UI_FLAG_LAYOUT_STABLE) { flags |= (SYSTEM_UI_FLAG_FULLSCREEN | SYSTEM_UI_FLAG_LAYOUT_STABLE); } -- GitLab From df4763cf8752fb1babc7244fc2be33ed87d3b072 Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Thu, 28 Jun 2012 17:12:20 +0800 Subject: [PATCH 059/763] Don't reuse bitmap before HoneyComb. Change-Id: I0df9bf0a8f43e28ed25b436d4c584dc3ceb43c1d --- .../android/gallery3d/common/ApiHelper.java | 3 + .../app/AbstractGalleryActivity.java | 10 ++- src/com/android/gallery3d/app/CropImage.java | 3 +- .../android/gallery3d/app/MoviePlayer.java | 5 +- src/com/android/gallery3d/app/Wallpaper.java | 2 +- .../android/gallery3d/data/BitmapPool.java | 69 +--------------- .../android/gallery3d/data/DecodeUtils.java | 79 ++++++++++++++++++- .../gallery3d/data/ImageCacheRequest.java | 10 ++- .../android/gallery3d/data/LocalImage.java | 3 +- src/com/android/gallery3d/data/MediaItem.java | 14 +++- .../gallery3d/ui/AlbumSetSlidingWindow.java | 4 +- .../gallery3d/ui/AlbumSlidingWindow.java | 4 +- .../gallery3d/ui/BitmapScreenNail.java | 16 ++-- src/com/android/gallery3d/ui/GLRootView.java | 3 +- 14 files changed, 133 insertions(+), 92 deletions(-) diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java index 85b092576..32c3a9c98 100644 --- a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java +++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java @@ -44,6 +44,9 @@ public class ApiHelper { public static final boolean HAS_REUSING_BITMAP_IN_BITMAP_REGION_DECODER = Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN; + public static final boolean HAS_REUSING_BITMAP_IN_BITMAP_FACTORY = + Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB; + private static boolean hasField(Class klass, String fieldName) { try { klass.getDeclaredField(fieldName); diff --git a/src/com/android/gallery3d/app/AbstractGalleryActivity.java b/src/com/android/gallery3d/app/AbstractGalleryActivity.java index 0987ac39f..9b2a85ed4 100644 --- a/src/com/android/gallery3d/app/AbstractGalleryActivity.java +++ b/src/com/android/gallery3d/app/AbstractGalleryActivity.java @@ -32,6 +32,7 @@ import android.view.Window; import android.view.WindowManager; import com.android.gallery3d.R; +import com.android.gallery3d.data.BitmapPool; import com.android.gallery3d.data.DataManager; import com.android.gallery3d.data.MediaItem; import com.android.gallery3d.ui.GLRoot; @@ -188,11 +189,16 @@ public class AbstractGalleryActivity extends Activity implements GalleryActivity } finally { mGLRootView.unlockRenderThread(); } - MediaItem.getMicroThumbPool().clear(); - MediaItem.getThumbPool().clear(); + clearBitmapPool(MediaItem.getMicroThumbPool()); + clearBitmapPool(MediaItem.getThumbPool()); + MediaItem.getBytesBufferPool().clear(); } + private static void clearBitmapPool(BitmapPool pool) { + if (pool != null) pool.clear(); + } + @Override protected void onDestroy() { super.onDestroy(); diff --git a/src/com/android/gallery3d/app/CropImage.java b/src/com/android/gallery3d/app/CropImage.java index f2646978a..294e285ea 100644 --- a/src/com/android/gallery3d/app/CropImage.java +++ b/src/com/android/gallery3d/app/CropImage.java @@ -33,6 +33,7 @@ import android.graphics.Rect; import android.graphics.RectF; import android.media.ExifInterface; import android.net.Uri; +import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.os.Handler; @@ -369,7 +370,7 @@ public class CropImage extends AbstractGalleryActivity { } } - @TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN) + @TargetApi(Build.VERSION_CODES.JELLY_BEAN) private static void setImageSize(ContentValues values, int width, int height) { // The two fields are available since ICS but got published in JB if (ApiHelper.HAS_MEDIA_COLUMNS_WIDTH_AND_HEIGHT) { diff --git a/src/com/android/gallery3d/app/MoviePlayer.java b/src/com/android/gallery3d/app/MoviePlayer.java index 4f72c13ba..660c4d953 100644 --- a/src/com/android/gallery3d/app/MoviePlayer.java +++ b/src/com/android/gallery3d/app/MoviePlayer.java @@ -29,6 +29,7 @@ import android.graphics.Color; import android.media.AudioManager; import android.media.MediaPlayer; import android.net.Uri; +import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.view.KeyEvent; @@ -178,7 +179,7 @@ public class MoviePlayer implements } } - @TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN) + @TargetApi(Build.VERSION_CODES.JELLY_BEAN) private void setOnSystemUiVisibilityChangeListener() { if (!ApiHelper.HAS_VIEW_SYSTEM_UI_FLAG_HIDE_NAVIGATION) return; @@ -212,7 +213,7 @@ public class MoviePlayer implements }); } - @TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN) + @TargetApi(Build.VERSION_CODES.JELLY_BEAN) private void showSystemUi(boolean visible) { if (!ApiHelper.HAS_VIEW_SYSTEM_UI_FLAG_LAYOUT_STABLE) return; diff --git a/src/com/android/gallery3d/app/Wallpaper.java b/src/com/android/gallery3d/app/Wallpaper.java index 1ece66c49..996d3f080 100644 --- a/src/com/android/gallery3d/app/Wallpaper.java +++ b/src/com/android/gallery3d/app/Wallpaper.java @@ -63,7 +63,7 @@ public class Wallpaper extends Activity { } @SuppressWarnings("deprecation") - @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB_MR2) + @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) private Point getDefaultDisplaySize(Point size) { Display d = getWindowManager().getDefaultDisplay(); if (Build.VERSION.SDK_INT >= ApiHelper.VERSION_CODES.HONEYCOMB_MR2) { diff --git a/src/com/android/gallery3d/data/BitmapPool.java b/src/com/android/gallery3d/data/BitmapPool.java index 0fbd84ef5..1151dded7 100644 --- a/src/com/android/gallery3d/data/BitmapPool.java +++ b/src/com/android/gallery3d/data/BitmapPool.java @@ -17,14 +17,9 @@ package com.android.gallery3d.data; import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.BitmapFactory.Options; import com.android.gallery3d.common.Utils; -import com.android.gallery3d.ui.Log; -import com.android.gallery3d.util.ThreadPool.JobContext; -import java.io.FileDescriptor; import java.util.ArrayList; public class BitmapPool { @@ -94,67 +89,7 @@ public class BitmapPool { mPool.clear(); } - private Bitmap findCachedBitmap(JobContext jc, - byte[] data, int offset, int length, Options options) { - if (mOneSize) return getBitmap(); - DecodeUtils.decodeBounds(jc, data, offset, length, options); - return getBitmap(options.outWidth, options.outHeight); - } - - private Bitmap findCachedBitmap(JobContext jc, - FileDescriptor fileDescriptor, Options options) { - if (mOneSize) return getBitmap(); - DecodeUtils.decodeBounds(jc, fileDescriptor, options); - return getBitmap(options.outWidth, options.outHeight); - } - - public Bitmap decode(JobContext jc, - byte[] data, int offset, int length, BitmapFactory.Options options) { - if (options == null) options = new BitmapFactory.Options(); - if (options.inSampleSize < 1) options.inSampleSize = 1; - options.inPreferredConfig = Bitmap.Config.ARGB_8888; - options.inBitmap = (options.inSampleSize == 1) - ? findCachedBitmap(jc, data, offset, length, options) : null; - try { - Bitmap bitmap = DecodeUtils.decode(jc, data, offset, length, options); - if (options.inBitmap != null && options.inBitmap != bitmap) { - recycle(options.inBitmap); - options.inBitmap = null; - } - return bitmap; - } catch (IllegalArgumentException e) { - if (options.inBitmap == null) throw e; - - Log.w(TAG, "decode fail with a given bitmap, try decode to a new bitmap"); - recycle(options.inBitmap); - options.inBitmap = null; - return DecodeUtils.decode(jc, data, offset, length, options); - } - } - - // This is the same as the method above except the source data comes - // from a file descriptor instead of a byte array. - public Bitmap decode(JobContext jc, - FileDescriptor fileDescriptor, Options options) { - if (options == null) options = new BitmapFactory.Options(); - if (options.inSampleSize < 1) options.inSampleSize = 1; - options.inPreferredConfig = Bitmap.Config.ARGB_8888; - options.inBitmap = (options.inSampleSize == 1) - ? findCachedBitmap(jc, fileDescriptor, options) : null; - try { - Bitmap bitmap = DecodeUtils.decode(jc, fileDescriptor, options); - if (options.inBitmap != null&& options.inBitmap != bitmap) { - recycle(options.inBitmap); - options.inBitmap = null; - } - return bitmap; - } catch (IllegalArgumentException e) { - if (options.inBitmap == null) throw e; - - Log.w(TAG, "decode fail with a given bitmap, try decode to a new bitmap"); - recycle(options.inBitmap); - options.inBitmap = null; - return DecodeUtils.decode(jc, fileDescriptor, options); - } + public boolean isOneSize() { + return mOneSize; } } diff --git a/src/com/android/gallery3d/data/DecodeUtils.java b/src/com/android/gallery3d/data/DecodeUtils.java index e51dc3fa9..773af74bb 100644 --- a/src/com/android/gallery3d/data/DecodeUtils.java +++ b/src/com/android/gallery3d/data/DecodeUtils.java @@ -16,15 +16,18 @@ package com.android.gallery3d.data; +import android.annotation.TargetApi; import android.graphics.Bitmap; import android.graphics.Bitmap.Config; import android.graphics.BitmapFactory; import android.graphics.BitmapFactory.Options; import android.graphics.BitmapRegionDecoder; +import android.os.Build; import android.util.FloatMath; import com.android.gallery3d.common.BitmapUtils; import com.android.gallery3d.common.Utils; +import com.android.gallery3d.ui.Log; import com.android.gallery3d.util.ThreadPool.CancelListener; import com.android.gallery3d.util.ThreadPool.JobContext; @@ -33,7 +36,7 @@ import java.io.FileInputStream; import java.io.InputStream; public class DecodeUtils { - private static final String TAG = "DecodeService"; + private static final String TAG = "DecodeUtils"; private static class DecodeCanceller implements CancelListener { Options mOptions; @@ -230,4 +233,78 @@ public class DecodeUtils { return null; } } + + @TargetApi(Build.VERSION_CODES.HONEYCOMB) + public static Bitmap decode(JobContext jc, byte[] data, int offset, + int length, BitmapFactory.Options options, BitmapPool pool) { + if (pool == null) { + return decode(jc, data, offset, length, options); + } + + if (options == null) options = new BitmapFactory.Options(); + if (options.inSampleSize < 1) options.inSampleSize = 1; + options.inPreferredConfig = Bitmap.Config.ARGB_8888; + options.inBitmap = (options.inSampleSize == 1) + ? findCachedBitmap(pool, jc, data, offset, length, options) : null; + try { + Bitmap bitmap = decode(jc, data, offset, length, options); + if (options.inBitmap != null && options.inBitmap != bitmap) { + pool.recycle(options.inBitmap); + options.inBitmap = null; + } + return bitmap; + } catch (IllegalArgumentException e) { + if (options.inBitmap == null) throw e; + + Log.w(TAG, "decode fail with a given bitmap, try decode to a new bitmap"); + pool.recycle(options.inBitmap); + options.inBitmap = null; + return decode(jc, data, offset, length, options); + } + } + + // This is the same as the method above except the source data comes + // from a file descriptor instead of a byte array. + @TargetApi(Build.VERSION_CODES.HONEYCOMB) + public static Bitmap decode(JobContext jc, + FileDescriptor fileDescriptor, Options options, BitmapPool pool) { + if (pool == null) { + return decode(jc, fileDescriptor, options); + } + + if (options == null) options = new BitmapFactory.Options(); + if (options.inSampleSize < 1) options.inSampleSize = 1; + options.inPreferredConfig = Bitmap.Config.ARGB_8888; + options.inBitmap = (options.inSampleSize == 1) + ? findCachedBitmap(pool, jc, fileDescriptor, options) : null; + try { + Bitmap bitmap = DecodeUtils.decode(jc, fileDescriptor, options); + if (options.inBitmap != null && options.inBitmap != bitmap) { + pool.recycle(options.inBitmap); + options.inBitmap = null; + } + return bitmap; + } catch (IllegalArgumentException e) { + if (options.inBitmap == null) throw e; + + Log.w(TAG, "decode fail with a given bitmap, try decode to a new bitmap"); + pool.recycle(options.inBitmap); + options.inBitmap = null; + return decode(jc, fileDescriptor, options); + } + } + + private static Bitmap findCachedBitmap(BitmapPool pool, JobContext jc, + byte[] data, int offset, int length, Options options) { + if (pool.isOneSize()) return pool.getBitmap(); + decodeBounds(jc, data, offset, length, options); + return pool.getBitmap(options.outWidth, options.outHeight); + } + + private static Bitmap findCachedBitmap(BitmapPool pool, JobContext jc, + FileDescriptor fileDescriptor, Options options) { + if (pool.isOneSize()) return pool.getBitmap(); + decodeBounds(jc, fileDescriptor, options); + return pool.getBitmap(options.outWidth, options.outHeight); + } } diff --git a/src/com/android/gallery3d/data/ImageCacheRequest.java b/src/com/android/gallery3d/data/ImageCacheRequest.java index 81660c915..b977b1016 100644 --- a/src/com/android/gallery3d/data/ImageCacheRequest.java +++ b/src/com/android/gallery3d/data/ImageCacheRequest.java @@ -57,11 +57,13 @@ abstract class ImageCacheRequest implements Job { options.inPreferredConfig = Bitmap.Config.ARGB_8888; Bitmap bitmap; if (mType == MediaItem.TYPE_MICROTHUMBNAIL) { - bitmap = MediaItem.getMicroThumbPool().decode(jc, - buffer.data, buffer.offset, buffer.length, options); + bitmap = DecodeUtils.decode(jc, + buffer.data, buffer.offset, buffer.length, options, + MediaItem.getMicroThumbPool()); } else { - bitmap = MediaItem.getThumbPool().decode(jc, - buffer.data, buffer.offset, buffer.length, options); + bitmap = DecodeUtils.decode(jc, + buffer.data, buffer.offset, buffer.length, options, + MediaItem.getThumbPool()); } if (bitmap == null && !jc.isCancelled()) { Log.w(TAG, "decode cached failed " + debugTag); diff --git a/src/com/android/gallery3d/data/LocalImage.java b/src/com/android/gallery3d/data/LocalImage.java index 316e32469..c432ab44d 100644 --- a/src/com/android/gallery3d/data/LocalImage.java +++ b/src/com/android/gallery3d/data/LocalImage.java @@ -25,6 +25,7 @@ import android.graphics.BitmapFactory; import android.graphics.BitmapRegionDecoder; import android.media.ExifInterface; import android.net.Uri; +import android.os.Build; import android.provider.MediaStore.Images; import android.provider.MediaStore.Images.ImageColumns; import android.provider.MediaStore.MediaColumns; @@ -85,7 +86,7 @@ public class LocalImage extends LocalMediaItem { updateWidthAndHeightProjection(); } - @TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN) + @TargetApi(Build.VERSION_CODES.JELLY_BEAN) private static void updateWidthAndHeightProjection() { if (ApiHelper.HAS_MEDIA_COLUMNS_WIDTH_AND_HEIGHT) { PROJECTION[INDEX_WIDTH] = MediaColumns.WIDTH; diff --git a/src/com/android/gallery3d/data/MediaItem.java b/src/com/android/gallery3d/data/MediaItem.java index f0f1af434..15bb17623 100644 --- a/src/com/android/gallery3d/data/MediaItem.java +++ b/src/com/android/gallery3d/data/MediaItem.java @@ -19,6 +19,7 @@ package com.android.gallery3d.data; import android.graphics.Bitmap; import android.graphics.BitmapRegionDecoder; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.ui.ScreenNail; import com.android.gallery3d.util.ThreadPool.Job; @@ -42,9 +43,16 @@ public abstract class MediaItem extends MediaObject { private static final int BYTESBUFFE_POOL_SIZE = 4; private static final int BYTESBUFFER_SIZE = 200 * 1024; - private static final BitmapPool sMicroThumbPool = new BitmapPool( - MICROTHUMBNAIL_TARGET_SIZE, MICROTHUMBNAIL_TARGET_SIZE, 16); - private static final BitmapPool sThumbPool = new BitmapPool(4); + private static final BitmapPool sMicroThumbPool = + ApiHelper.HAS_REUSING_BITMAP_IN_BITMAP_FACTORY + ? new BitmapPool(MICROTHUMBNAIL_TARGET_SIZE, MICROTHUMBNAIL_TARGET_SIZE, 16) + : null; + + private static final BitmapPool sThumbPool = + ApiHelper.HAS_REUSING_BITMAP_IN_BITMAP_FACTORY + ? new BitmapPool(4) + : null; + private static final BytesBufferPool sMicroThumbBufferPool = new BytesBufferPool(BYTESBUFFE_POOL_SIZE, BYTESBUFFER_SIZE); diff --git a/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java b/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java index 6561a23f3..449c6f9d3 100644 --- a/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java +++ b/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java @@ -23,6 +23,7 @@ import com.android.gallery3d.R; import com.android.gallery3d.app.AlbumSetDataLoader; import com.android.gallery3d.app.GalleryActivity; import com.android.gallery3d.common.Utils; +import com.android.gallery3d.data.BitmapPool; import com.android.gallery3d.data.DataSourceType; import com.android.gallery3d.data.MediaItem; import com.android.gallery3d.data.MediaObject; @@ -423,7 +424,8 @@ public class AlbumSetSlidingWindow implements AlbumSetDataLoader.DataListener { @Override protected void recycleBitmap(Bitmap bitmap) { - MediaItem.getMicroThumbPool().recycle(bitmap); + BitmapPool pool = MediaItem.getMicroThumbPool(); + if (pool != null) pool.recycle(bitmap); } @Override diff --git a/src/com/android/gallery3d/ui/AlbumSlidingWindow.java b/src/com/android/gallery3d/ui/AlbumSlidingWindow.java index deec1712d..d5d90a9ea 100644 --- a/src/com/android/gallery3d/ui/AlbumSlidingWindow.java +++ b/src/com/android/gallery3d/ui/AlbumSlidingWindow.java @@ -22,6 +22,7 @@ import android.os.Message; import com.android.gallery3d.app.AlbumDataLoader; import com.android.gallery3d.app.GalleryActivity; import com.android.gallery3d.common.Utils; +import com.android.gallery3d.data.BitmapPool; import com.android.gallery3d.data.MediaItem; import com.android.gallery3d.data.Path; import com.android.gallery3d.util.Future; @@ -277,7 +278,8 @@ public class AlbumSlidingWindow implements AlbumDataLoader.DataListener { @Override protected void recycleBitmap(Bitmap bitmap) { - MediaItem.getMicroThumbPool().recycle(bitmap); + BitmapPool pool = MediaItem.getMicroThumbPool(); + if (pool != null) pool.recycle(bitmap); } @Override diff --git a/src/com/android/gallery3d/ui/BitmapScreenNail.java b/src/com/android/gallery3d/ui/BitmapScreenNail.java index 5c917570d..0043e0cbe 100644 --- a/src/com/android/gallery3d/ui/BitmapScreenNail.java +++ b/src/com/android/gallery3d/ui/BitmapScreenNail.java @@ -20,6 +20,7 @@ import android.graphics.Bitmap; import android.graphics.RectF; import com.android.gallery3d.common.Utils; +import com.android.gallery3d.data.BitmapPool; import com.android.gallery3d.data.MediaItem; // This is a ScreenNail wraps a Bitmap. There are some extra functions: @@ -70,6 +71,11 @@ public class BitmapScreenNail implements ScreenNail { mHeight = Math.round(scale * height); } + private static void recycleBitmap(BitmapPool pool, Bitmap bitmap) { + if (pool == null || bitmap == null) return; + pool.recycle(bitmap); + } + // Combines the two ScreenNails. // Returns the used one and recycle the unused one. public ScreenNail combine(ScreenNail other) { @@ -88,9 +94,7 @@ public class BitmapScreenNail implements ScreenNail { mWidth = newer.mWidth; mHeight = newer.mHeight; if (newer.mBitmap != null) { - if (mBitmap != null) { - MediaItem.getThumbPool().recycle(mBitmap); - } + recycleBitmap(MediaItem.getThumbPool(), mBitmap); mBitmap = newer.mBitmap; newer.mBitmap = null; @@ -130,10 +134,8 @@ public class BitmapScreenNail implements ScreenNail { mTexture.recycle(); mTexture = null; } - if (mBitmap != null) { - MediaItem.getThumbPool().recycle(mBitmap); - mBitmap = null; - } + recycleBitmap(MediaItem.getThumbPool(), mBitmap); + mBitmap = null; } @Override diff --git a/src/com/android/gallery3d/ui/GLRootView.java b/src/com/android/gallery3d/ui/GLRootView.java index 401ca59eb..fe4e19d7b 100644 --- a/src/com/android/gallery3d/ui/GLRootView.java +++ b/src/com/android/gallery3d/ui/GLRootView.java @@ -21,6 +21,7 @@ import android.content.Context; import android.graphics.Matrix; import android.graphics.PixelFormat; import android.opengl.GLSurfaceView; +import android.os.Build; import android.os.Process; import android.os.SystemClock; import android.util.AttributeSet; @@ -536,7 +537,7 @@ public class GLRootView extends GLSurfaceView } @Override - @TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN) + @TargetApi(Build.VERSION_CODES.JELLY_BEAN) public void setLightsOutMode(boolean enabled) { int flags = 0; if (enabled) { -- GitLab From 6772173d2a49b87a1d209f42fe52b5f830596f99 Mon Sep 17 00:00:00 2001 From: Chih-Chung Chang Date: Tue, 3 Jul 2012 12:49:45 +0800 Subject: [PATCH 060/763] Remove dependencies on APIs only exist on newer platforms. Change-Id: I606a23863247454051dd183ddf6b77f6bc882685 --- .../android/gallery3d/common/ApiHelper.java | 18 + .../gallery3d/common/OverScroller.java | 958 ++++++++++++++++++ .../android/gallery3d/common/Scroller.java | 507 +++++++++ .../android/gallery3d/app/MoviePlayer.java | 8 +- src/com/android/gallery3d/app/PhotoPage.java | 5 +- .../gallery3d/ui/ActionModeHandler.java | 5 +- .../gallery3d/ui/PositionController.java | 2 +- .../ui/SurfaceTextureScreenNail.java | 18 +- 8 files changed, 1510 insertions(+), 11 deletions(-) create mode 100644 gallerycommon/src/com/android/gallery3d/common/OverScroller.java create mode 100644 gallerycommon/src/com/android/gallery3d/common/Scroller.java diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java index 32c3a9c98..a908e1591 100644 --- a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java +++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java @@ -47,6 +47,13 @@ public class ApiHelper { public static final boolean HAS_REUSING_BITMAP_IN_BITMAP_FACTORY = Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB; + public static final boolean HAS_SET_BEAM_PUSH_URIS = + Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN; + + public static final boolean HAS_SET_DEFALT_BUFFER_SIZE = hasMethod( + "android.graphics.SurfaceTexture", "setDefaultBufferSize", + int.class, int.class); + private static boolean hasField(Class klass, String fieldName) { try { klass.getDeclaredField(fieldName); @@ -55,4 +62,15 @@ public class ApiHelper { return false; } } + + private static boolean hasMethod(String className, String methodName, + Class... parameterTypes) { + try { + Class klass = Class.forName(className); + klass.getDeclaredMethod(methodName, parameterTypes); + return true; + } catch (Throwable th) { + return false; + } + } } diff --git a/gallerycommon/src/com/android/gallery3d/common/OverScroller.java b/gallerycommon/src/com/android/gallery3d/common/OverScroller.java new file mode 100644 index 000000000..1ab7953d2 --- /dev/null +++ b/gallerycommon/src/com/android/gallery3d/common/OverScroller.java @@ -0,0 +1,958 @@ +/* + * Copyright (C) 2010 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.android.gallery3d.common; + +import android.content.Context; +import android.hardware.SensorManager; +import android.util.FloatMath; +import android.util.Log; +import android.view.ViewConfiguration; +import android.view.animation.AnimationUtils; +import android.view.animation.Interpolator; + +/** + * This class encapsulates scrolling with the ability to overshoot the bounds + * of a scrolling operation. This class is a drop-in replacement for + * {@link android.widget.Scroller} in most cases. + */ +public class OverScroller { + private int mMode; + + private final SplineOverScroller mScrollerX; + private final SplineOverScroller mScrollerY; + + private Interpolator mInterpolator; + + private final boolean mFlywheel; + + private static final int DEFAULT_DURATION = 250; + private static final int SCROLL_MODE = 0; + private static final int FLING_MODE = 1; + + /** + * Creates an OverScroller with a viscous fluid scroll interpolator and flywheel. + * @param context + */ + public OverScroller(Context context) { + this(context, null); + } + + /** + * Creates an OverScroller with flywheel enabled. + * @param context The context of this application. + * @param interpolator The scroll interpolator. If null, a default (viscous) interpolator will + * be used. + */ + public OverScroller(Context context, Interpolator interpolator) { + this(context, interpolator, true); + } + + /** + * Creates an OverScroller. + * @param context The context of this application. + * @param interpolator The scroll interpolator. If null, a default (viscous) interpolator will + * be used. + * @param flywheel If true, successive fling motions will keep on increasing scroll speed. + * @hide + */ + public OverScroller(Context context, Interpolator interpolator, boolean flywheel) { + mInterpolator = interpolator; + mFlywheel = flywheel; + mScrollerX = new SplineOverScroller(); + mScrollerY = new SplineOverScroller(); + + SplineOverScroller.initFromContext(context); + } + + /** + * Creates an OverScroller with flywheel enabled. + * @param context The context of this application. + * @param interpolator The scroll interpolator. If null, a default (viscous) interpolator will + * be used. + * @param bounceCoefficientX A value between 0 and 1 that will determine the proportion of the + * velocity which is preserved in the bounce when the horizontal edge is reached. A null value + * means no bounce. This behavior is no longer supported and this coefficient has no effect. + * @param bounceCoefficientY Same as bounceCoefficientX but for the vertical direction. This + * behavior is no longer supported and this coefficient has no effect. + * !deprecated Use {!link #OverScroller(Context, Interpolator, boolean)} instead. + */ + public OverScroller(Context context, Interpolator interpolator, + float bounceCoefficientX, float bounceCoefficientY) { + this(context, interpolator, true); + } + + /** + * Creates an OverScroller. + * @param context The context of this application. + * @param interpolator The scroll interpolator. If null, a default (viscous) interpolator will + * be used. + * @param bounceCoefficientX A value between 0 and 1 that will determine the proportion of the + * velocity which is preserved in the bounce when the horizontal edge is reached. A null value + * means no bounce. This behavior is no longer supported and this coefficient has no effect. + * @param bounceCoefficientY Same as bounceCoefficientX but for the vertical direction. This + * behavior is no longer supported and this coefficient has no effect. + * @param flywheel If true, successive fling motions will keep on increasing scroll speed. + * !deprecated Use {!link OverScroller(Context, Interpolator, boolean)} instead. + */ + public OverScroller(Context context, Interpolator interpolator, + float bounceCoefficientX, float bounceCoefficientY, boolean flywheel) { + this(context, interpolator, flywheel); + } + + void setInterpolator(Interpolator interpolator) { + mInterpolator = interpolator; + } + + /** + * The amount of friction applied to flings. The default value + * is {@link ViewConfiguration#getScrollFriction}. + * + * @param friction A scalar dimension-less value representing the coefficient of + * friction. + */ + public final void setFriction(float friction) { + mScrollerX.setFriction(friction); + mScrollerY.setFriction(friction); + } + + /** + * + * Returns whether the scroller has finished scrolling. + * + * @return True if the scroller has finished scrolling, false otherwise. + */ + public final boolean isFinished() { + return mScrollerX.mFinished && mScrollerY.mFinished; + } + + /** + * Force the finished field to a particular value. Contrary to + * {@link #abortAnimation()}, forcing the animation to finished + * does NOT cause the scroller to move to the final x and y + * position. + * + * @param finished The new finished value. + */ + public final void forceFinished(boolean finished) { + mScrollerX.mFinished = mScrollerY.mFinished = finished; + } + + /** + * Returns the current X offset in the scroll. + * + * @return The new X offset as an absolute distance from the origin. + */ + public final int getCurrX() { + return mScrollerX.mCurrentPosition; + } + + /** + * Returns the current Y offset in the scroll. + * + * @return The new Y offset as an absolute distance from the origin. + */ + public final int getCurrY() { + return mScrollerY.mCurrentPosition; + } + + /** + * Returns the absolute value of the current velocity. + * + * @return The original velocity less the deceleration, norm of the X and Y velocity vector. + */ + public float getCurrVelocity() { + float squaredNorm = mScrollerX.mCurrVelocity * mScrollerX.mCurrVelocity; + squaredNorm += mScrollerY.mCurrVelocity * mScrollerY.mCurrVelocity; + return FloatMath.sqrt(squaredNorm); + } + + /** + * Returns the start X offset in the scroll. + * + * @return The start X offset as an absolute distance from the origin. + */ + public final int getStartX() { + return mScrollerX.mStart; + } + + /** + * Returns the start Y offset in the scroll. + * + * @return The start Y offset as an absolute distance from the origin. + */ + public final int getStartY() { + return mScrollerY.mStart; + } + + /** + * Returns where the scroll will end. Valid only for "fling" scrolls. + * + * @return The final X offset as an absolute distance from the origin. + */ + public final int getFinalX() { + return mScrollerX.mFinal; + } + + /** + * Returns where the scroll will end. Valid only for "fling" scrolls. + * + * @return The final Y offset as an absolute distance from the origin. + */ + public final int getFinalY() { + return mScrollerY.mFinal; + } + + /** + * Returns how long the scroll event will take, in milliseconds. + * + * @return The duration of the scroll in milliseconds. + * + * @hide Pending removal once nothing depends on it + * @deprecated OverScrollers don't necessarily have a fixed duration. + * This function will lie to the best of its ability. + */ + @Deprecated + public final int getDuration() { + return Math.max(mScrollerX.mDuration, mScrollerY.mDuration); + } + + /** + * Extend the scroll animation. This allows a running animation to scroll + * further and longer, when used with {@link #setFinalX(int)} or {@link #setFinalY(int)}. + * + * @param extend Additional time to scroll in milliseconds. + * @see #setFinalX(int) + * @see #setFinalY(int) + * + * @hide Pending removal once nothing depends on it + * @deprecated OverScrollers don't necessarily have a fixed duration. + * Instead of setting a new final position and extending + * the duration of an existing scroll, use startScroll + * to begin a new animation. + */ + @Deprecated + public void extendDuration(int extend) { + mScrollerX.extendDuration(extend); + mScrollerY.extendDuration(extend); + } + + /** + * Sets the final position (X) for this scroller. + * + * @param newX The new X offset as an absolute distance from the origin. + * @see #extendDuration(int) + * @see #setFinalY(int) + * + * @hide Pending removal once nothing depends on it + * @deprecated OverScroller's final position may change during an animation. + * Instead of setting a new final position and extending + * the duration of an existing scroll, use startScroll + * to begin a new animation. + */ + @Deprecated + public void setFinalX(int newX) { + mScrollerX.setFinalPosition(newX); + } + + /** + * Sets the final position (Y) for this scroller. + * + * @param newY The new Y offset as an absolute distance from the origin. + * @see #extendDuration(int) + * @see #setFinalX(int) + * + * @hide Pending removal once nothing depends on it + * @deprecated OverScroller's final position may change during an animation. + * Instead of setting a new final position and extending + * the duration of an existing scroll, use startScroll + * to begin a new animation. + */ + @Deprecated + public void setFinalY(int newY) { + mScrollerY.setFinalPosition(newY); + } + + /** + * Call this when you want to know the new location. If it returns true, the + * animation is not yet finished. + */ + public boolean computeScrollOffset() { + if (isFinished()) { + return false; + } + + switch (mMode) { + case SCROLL_MODE: + long time = AnimationUtils.currentAnimationTimeMillis(); + // Any scroller can be used for time, since they were started + // together in scroll mode. We use X here. + final long elapsedTime = time - mScrollerX.mStartTime; + + final int duration = mScrollerX.mDuration; + if (elapsedTime < duration) { + float q = (float) (elapsedTime) / duration; + + if (mInterpolator == null) { + q = Scroller.viscousFluid(q); + } else { + q = mInterpolator.getInterpolation(q); + } + + mScrollerX.updateScroll(q); + mScrollerY.updateScroll(q); + } else { + abortAnimation(); + } + break; + + case FLING_MODE: + if (!mScrollerX.mFinished) { + if (!mScrollerX.update()) { + if (!mScrollerX.continueWhenFinished()) { + mScrollerX.finish(); + } + } + } + + if (!mScrollerY.mFinished) { + if (!mScrollerY.update()) { + if (!mScrollerY.continueWhenFinished()) { + mScrollerY.finish(); + } + } + } + + break; + } + + return true; + } + + /** + * Start scrolling by providing a starting point and the distance to travel. + * The scroll will use the default value of 250 milliseconds for the + * duration. + * + * @param startX Starting horizontal scroll offset in pixels. Positive + * numbers will scroll the content to the left. + * @param startY Starting vertical scroll offset in pixels. Positive numbers + * will scroll the content up. + * @param dx Horizontal distance to travel. Positive numbers will scroll the + * content to the left. + * @param dy Vertical distance to travel. Positive numbers will scroll the + * content up. + */ + public void startScroll(int startX, int startY, int dx, int dy) { + startScroll(startX, startY, dx, dy, DEFAULT_DURATION); + } + + /** + * Start scrolling by providing a starting point and the distance to travel. + * + * @param startX Starting horizontal scroll offset in pixels. Positive + * numbers will scroll the content to the left. + * @param startY Starting vertical scroll offset in pixels. Positive numbers + * will scroll the content up. + * @param dx Horizontal distance to travel. Positive numbers will scroll the + * content to the left. + * @param dy Vertical distance to travel. Positive numbers will scroll the + * content up. + * @param duration Duration of the scroll in milliseconds. + */ + public void startScroll(int startX, int startY, int dx, int dy, int duration) { + mMode = SCROLL_MODE; + mScrollerX.startScroll(startX, dx, duration); + mScrollerY.startScroll(startY, dy, duration); + } + + /** + * Call this when you want to 'spring back' into a valid coordinate range. + * + * @param startX Starting X coordinate + * @param startY Starting Y coordinate + * @param minX Minimum valid X value + * @param maxX Maximum valid X value + * @param minY Minimum valid Y value + * @param maxY Minimum valid Y value + * @return true if a springback was initiated, false if startX and startY were + * already within the valid range. + */ + public boolean springBack(int startX, int startY, int minX, int maxX, int minY, int maxY) { + mMode = FLING_MODE; + + // Make sure both methods are called. + final boolean spingbackX = mScrollerX.springback(startX, minX, maxX); + final boolean spingbackY = mScrollerY.springback(startY, minY, maxY); + return spingbackX || spingbackY; + } + + public void fling(int startX, int startY, int velocityX, int velocityY, + int minX, int maxX, int minY, int maxY) { + fling(startX, startY, velocityX, velocityY, minX, maxX, minY, maxY, 0, 0); + } + + /** + * Start scrolling based on a fling gesture. The distance traveled will + * depend on the initial velocity of the fling. + * + * @param startX Starting point of the scroll (X) + * @param startY Starting point of the scroll (Y) + * @param velocityX Initial velocity of the fling (X) measured in pixels per + * second. + * @param velocityY Initial velocity of the fling (Y) measured in pixels per + * second + * @param minX Minimum X value. The scroller will not scroll past this point + * unless overX > 0. If overfling is allowed, it will use minX as + * a springback boundary. + * @param maxX Maximum X value. The scroller will not scroll past this point + * unless overX > 0. If overfling is allowed, it will use maxX as + * a springback boundary. + * @param minY Minimum Y value. The scroller will not scroll past this point + * unless overY > 0. If overfling is allowed, it will use minY as + * a springback boundary. + * @param maxY Maximum Y value. The scroller will not scroll past this point + * unless overY > 0. If overfling is allowed, it will use maxY as + * a springback boundary. + * @param overX Overfling range. If > 0, horizontal overfling in either + * direction will be possible. + * @param overY Overfling range. If > 0, vertical overfling in either + * direction will be possible. + */ + public void fling(int startX, int startY, int velocityX, int velocityY, + int minX, int maxX, int minY, int maxY, int overX, int overY) { + // Continue a scroll or fling in progress + if (mFlywheel && !isFinished()) { + float oldVelocityX = mScrollerX.mCurrVelocity; + float oldVelocityY = mScrollerY.mCurrVelocity; + if (Math.signum(velocityX) == Math.signum(oldVelocityX) && + Math.signum(velocityY) == Math.signum(oldVelocityY)) { + velocityX += oldVelocityX; + velocityY += oldVelocityY; + } + } + + mMode = FLING_MODE; + mScrollerX.fling(startX, velocityX, minX, maxX, overX); + mScrollerY.fling(startY, velocityY, minY, maxY, overY); + } + + /** + * Notify the scroller that we've reached a horizontal boundary. + * Normally the information to handle this will already be known + * when the animation is started, such as in a call to one of the + * fling functions. However there are cases where this cannot be known + * in advance. This function will transition the current motion and + * animate from startX to finalX as appropriate. + * + * @param startX Starting/current X position + * @param finalX Desired final X position + * @param overX Magnitude of overscroll allowed. This should be the maximum + * desired distance from finalX. Absolute value - must be positive. + */ + public void notifyHorizontalEdgeReached(int startX, int finalX, int overX) { + mScrollerX.notifyEdgeReached(startX, finalX, overX); + } + + /** + * Notify the scroller that we've reached a vertical boundary. + * Normally the information to handle this will already be known + * when the animation is started, such as in a call to one of the + * fling functions. However there are cases where this cannot be known + * in advance. This function will animate a parabolic motion from + * startY to finalY. + * + * @param startY Starting/current Y position + * @param finalY Desired final Y position + * @param overY Magnitude of overscroll allowed. This should be the maximum + * desired distance from finalY. Absolute value - must be positive. + */ + public void notifyVerticalEdgeReached(int startY, int finalY, int overY) { + mScrollerY.notifyEdgeReached(startY, finalY, overY); + } + + /** + * Returns whether the current Scroller is currently returning to a valid position. + * Valid bounds were provided by the + * {@link #fling(int, int, int, int, int, int, int, int, int, int)} method. + * + * One should check this value before calling + * {@link #startScroll(int, int, int, int)} as the interpolation currently in progress + * to restore a valid position will then be stopped. The caller has to take into account + * the fact that the started scroll will start from an overscrolled position. + * + * @return true when the current position is overscrolled and in the process of + * interpolating back to a valid value. + */ + public boolean isOverScrolled() { + return ((!mScrollerX.mFinished && + mScrollerX.mState != SplineOverScroller.SPLINE) || + (!mScrollerY.mFinished && + mScrollerY.mState != SplineOverScroller.SPLINE)); + } + + /** + * Stops the animation. Contrary to {@link #forceFinished(boolean)}, + * aborting the animating causes the scroller to move to the final x and y + * positions. + * + * @see #forceFinished(boolean) + */ + public void abortAnimation() { + mScrollerX.finish(); + mScrollerY.finish(); + } + + /** + * Returns the time elapsed since the beginning of the scrolling. + * + * @return The elapsed time in milliseconds. + * + * @hide + */ + public int timePassed() { + final long time = AnimationUtils.currentAnimationTimeMillis(); + final long startTime = Math.min(mScrollerX.mStartTime, mScrollerY.mStartTime); + return (int) (time - startTime); + } + + /** + * @hide + */ + public boolean isScrollingInDirection(float xvel, float yvel) { + final int dx = mScrollerX.mFinal - mScrollerX.mStart; + final int dy = mScrollerY.mFinal - mScrollerY.mStart; + return !isFinished() && Math.signum(xvel) == Math.signum(dx) && + Math.signum(yvel) == Math.signum(dy); + } + + static class SplineOverScroller { + // Initial position + private int mStart; + + // Current position + private int mCurrentPosition; + + // Final position + private int mFinal; + + // Initial velocity + private int mVelocity; + + // Current velocity + private float mCurrVelocity; + + // Constant current deceleration + private float mDeceleration; + + // Animation starting time, in system milliseconds + private long mStartTime; + + // Animation duration, in milliseconds + private int mDuration; + + // Duration to complete spline component of animation + private int mSplineDuration; + + // Distance to travel along spline animation + private int mSplineDistance; + + // Whether the animation is currently in progress + private boolean mFinished; + + // The allowed overshot distance before boundary is reached. + private int mOver; + + // Fling friction + private float mFlingFriction = ViewConfiguration.getScrollFriction(); + + // Current state of the animation. + private int mState = SPLINE; + + // Constant gravity value, used in the deceleration phase. + private static final float GRAVITY = 2000.0f; + + // A device specific coefficient adjusted to physical values. + private static float PHYSICAL_COEF; + + private static float DECELERATION_RATE = (float) (Math.log(0.78) / Math.log(0.9)); + private static final float INFLEXION = 0.35f; // Tension lines cross at (INFLEXION, 1) + private static final float START_TENSION = 0.5f; + private static final float END_TENSION = 1.0f; + private static final float P1 = START_TENSION * INFLEXION; + private static final float P2 = 1.0f - END_TENSION * (1.0f - INFLEXION); + + private static final int NB_SAMPLES = 100; + private static final float[] SPLINE_POSITION = new float[NB_SAMPLES + 1]; + private static final float[] SPLINE_TIME = new float[NB_SAMPLES + 1]; + + private static final int SPLINE = 0; + private static final int CUBIC = 1; + private static final int BALLISTIC = 2; + + static { + float x_min = 0.0f; + float y_min = 0.0f; + for (int i = 0; i < NB_SAMPLES; i++) { + final float alpha = (float) i / NB_SAMPLES; + + float x_max = 1.0f; + float x, tx, coef; + while (true) { + x = x_min + (x_max - x_min) / 2.0f; + coef = 3.0f * x * (1.0f - x); + tx = coef * ((1.0f - x) * P1 + x * P2) + x * x * x; + if (Math.abs(tx - alpha) < 1E-5) break; + if (tx > alpha) x_max = x; + else x_min = x; + } + SPLINE_POSITION[i] = coef * ((1.0f - x) * START_TENSION + x) + x * x * x; + + float y_max = 1.0f; + float y, dy; + while (true) { + y = y_min + (y_max - y_min) / 2.0f; + coef = 3.0f * y * (1.0f - y); + dy = coef * ((1.0f - y) * START_TENSION + y) + y * y * y; + if (Math.abs(dy - alpha) < 1E-5) break; + if (dy > alpha) y_max = y; + else y_min = y; + } + SPLINE_TIME[i] = coef * ((1.0f - y) * P1 + y * P2) + y * y * y; + } + SPLINE_POSITION[NB_SAMPLES] = SPLINE_TIME[NB_SAMPLES] = 1.0f; + } + + static void initFromContext(Context context) { + final float ppi = context.getResources().getDisplayMetrics().density * 160.0f; + PHYSICAL_COEF = SensorManager.GRAVITY_EARTH // g (m/s^2) + * 39.37f // inch/meter + * ppi + * 0.84f; // look and feel tuning + } + + void setFriction(float friction) { + mFlingFriction = friction; + } + + SplineOverScroller() { + mFinished = true; + } + + void updateScroll(float q) { + mCurrentPosition = mStart + Math.round(q * (mFinal - mStart)); + } + + /* + * Get a signed deceleration that will reduce the velocity. + */ + static private float getDeceleration(int velocity) { + return velocity > 0 ? -GRAVITY : GRAVITY; + } + + /* + * Modifies mDuration to the duration it takes to get from start to newFinal using the + * spline interpolation. The previous duration was needed to get to oldFinal. + */ + private void adjustDuration(int start, int oldFinal, int newFinal) { + final int oldDistance = oldFinal - start; + final int newDistance = newFinal - start; + final float x = Math.abs((float) newDistance / oldDistance); + final int index = (int) (NB_SAMPLES * x); + if (index < NB_SAMPLES) { + final float x_inf = (float) index / NB_SAMPLES; + final float x_sup = (float) (index + 1) / NB_SAMPLES; + final float t_inf = SPLINE_TIME[index]; + final float t_sup = SPLINE_TIME[index + 1]; + final float timeCoef = t_inf + (x - x_inf) / (x_sup - x_inf) * (t_sup - t_inf); + mDuration *= timeCoef; + } + } + + void startScroll(int start, int distance, int duration) { + mFinished = false; + + mStart = start; + mFinal = start + distance; + + mStartTime = AnimationUtils.currentAnimationTimeMillis(); + mDuration = duration; + + // Unused + mDeceleration = 0.0f; + mVelocity = 0; + } + + void finish() { + mCurrentPosition = mFinal; + // Not reset since WebView relies on this value for fast fling. + // TODO: restore when WebView uses the fast fling implemented in this class. + // mCurrVelocity = 0.0f; + mFinished = true; + } + + void setFinalPosition(int position) { + mFinal = position; + mFinished = false; + } + + void extendDuration(int extend) { + final long time = AnimationUtils.currentAnimationTimeMillis(); + final int elapsedTime = (int) (time - mStartTime); + mDuration = elapsedTime + extend; + mFinished = false; + } + + boolean springback(int start, int min, int max) { + mFinished = true; + + mStart = mFinal = start; + mVelocity = 0; + + mStartTime = AnimationUtils.currentAnimationTimeMillis(); + mDuration = 0; + + if (start < min) { + startSpringback(start, min, 0); + } else if (start > max) { + startSpringback(start, max, 0); + } + + return !mFinished; + } + + private void startSpringback(int start, int end, int velocity) { + // mStartTime has been set + mFinished = false; + mState = CUBIC; + mStart = start; + mFinal = end; + final int delta = start - end; + mDeceleration = getDeceleration(delta); + // TODO take velocity into account + mVelocity = -delta; // only sign is used + mOver = Math.abs(delta); + mDuration = (int) (1000.0 * Math.sqrt(-2.0 * delta / mDeceleration)); + } + + void fling(int start, int velocity, int min, int max, int over) { + mOver = over; + mFinished = false; + mCurrVelocity = mVelocity = velocity; + mDuration = mSplineDuration = 0; + mStartTime = AnimationUtils.currentAnimationTimeMillis(); + mCurrentPosition = mStart = start; + + if (start > max || start < min) { + startAfterEdge(start, min, max, velocity); + return; + } + + mState = SPLINE; + double totalDistance = 0.0; + + if (velocity != 0) { + mDuration = mSplineDuration = getSplineFlingDuration(velocity); + totalDistance = getSplineFlingDistance(velocity); + } + + mSplineDistance = (int) (totalDistance * Math.signum(velocity)); + mFinal = start + mSplineDistance; + + // Clamp to a valid final position + if (mFinal < min) { + adjustDuration(mStart, mFinal, min); + mFinal = min; + } + + if (mFinal > max) { + adjustDuration(mStart, mFinal, max); + mFinal = max; + } + } + + private double getSplineDeceleration(int velocity) { + return Math.log(INFLEXION * Math.abs(velocity) / (mFlingFriction * PHYSICAL_COEF)); + } + + private double getSplineFlingDistance(int velocity) { + final double l = getSplineDeceleration(velocity); + final double decelMinusOne = DECELERATION_RATE - 1.0; + return mFlingFriction * PHYSICAL_COEF * Math.exp(DECELERATION_RATE / decelMinusOne * l); + } + + /* Returns the duration, expressed in milliseconds */ + private int getSplineFlingDuration(int velocity) { + final double l = getSplineDeceleration(velocity); + final double decelMinusOne = DECELERATION_RATE - 1.0; + return (int) (1000.0 * Math.exp(l / decelMinusOne)); + } + + private void fitOnBounceCurve(int start, int end, int velocity) { + // Simulate a bounce that started from edge + final float durationToApex = - velocity / mDeceleration; + final float distanceToApex = velocity * velocity / 2.0f / Math.abs(mDeceleration); + final float distanceToEdge = Math.abs(end - start); + final float totalDuration = (float) Math.sqrt( + 2.0 * (distanceToApex + distanceToEdge) / Math.abs(mDeceleration)); + mStartTime -= (int) (1000.0f * (totalDuration - durationToApex)); + mStart = end; + mVelocity = (int) (- mDeceleration * totalDuration); + } + + private void startBounceAfterEdge(int start, int end, int velocity) { + mDeceleration = getDeceleration(velocity == 0 ? start - end : velocity); + fitOnBounceCurve(start, end, velocity); + onEdgeReached(); + } + + private void startAfterEdge(int start, int min, int max, int velocity) { + if (start > min && start < max) { + Log.e("OverScroller", "startAfterEdge called from a valid position"); + mFinished = true; + return; + } + final boolean positive = start > max; + final int edge = positive ? max : min; + final int overDistance = start - edge; + boolean keepIncreasing = overDistance * velocity >= 0; + if (keepIncreasing) { + // Will result in a bounce or a to_boundary depending on velocity. + startBounceAfterEdge(start, edge, velocity); + } else { + final double totalDistance = getSplineFlingDistance(velocity); + if (totalDistance > Math.abs(overDistance)) { + fling(start, velocity, positive ? min : start, positive ? start : max, mOver); + } else { + startSpringback(start, edge, velocity); + } + } + } + + void notifyEdgeReached(int start, int end, int over) { + // mState is used to detect successive notifications + if (mState == SPLINE) { + mOver = over; + mStartTime = AnimationUtils.currentAnimationTimeMillis(); + // We were in fling/scroll mode before: current velocity is such that distance to + // edge is increasing. This ensures that startAfterEdge will not start a new fling. + startAfterEdge(start, end, end, (int) mCurrVelocity); + } + } + + private void onEdgeReached() { + // mStart, mVelocity and mStartTime were adjusted to their values when edge was reached. + float distance = mVelocity * mVelocity / (2.0f * Math.abs(mDeceleration)); + final float sign = Math.signum(mVelocity); + + if (distance > mOver) { + // Default deceleration is not sufficient to slow us down before boundary + mDeceleration = - sign * mVelocity * mVelocity / (2.0f * mOver); + distance = mOver; + } + + mOver = (int) distance; + mState = BALLISTIC; + mFinal = mStart + (int) (mVelocity > 0 ? distance : -distance); + mDuration = - (int) (1000.0f * mVelocity / mDeceleration); + } + + boolean continueWhenFinished() { + switch (mState) { + case SPLINE: + // Duration from start to null velocity + if (mDuration < mSplineDuration) { + // If the animation was clamped, we reached the edge + mStart = mFinal; + // TODO Better compute speed when edge was reached + mVelocity = (int) mCurrVelocity; + mDeceleration = getDeceleration(mVelocity); + mStartTime += mDuration; + onEdgeReached(); + } else { + // Normal stop, no need to continue + return false; + } + break; + case BALLISTIC: + mStartTime += mDuration; + startSpringback(mFinal, mStart, 0); + break; + case CUBIC: + return false; + } + + update(); + return true; + } + + /* + * Update the current position and velocity for current time. Returns + * true if update has been done and false if animation duration has been + * reached. + */ + boolean update() { + final long time = AnimationUtils.currentAnimationTimeMillis(); + final long currentTime = time - mStartTime; + + if (currentTime > mDuration) { + return false; + } + + double distance = 0.0; + switch (mState) { + case SPLINE: { + final float t = (float) currentTime / mSplineDuration; + final int index = (int) (NB_SAMPLES * t); + float distanceCoef = 1.f; + float velocityCoef = 0.f; + if (index < NB_SAMPLES) { + final float t_inf = (float) index / NB_SAMPLES; + final float t_sup = (float) (index + 1) / NB_SAMPLES; + final float d_inf = SPLINE_POSITION[index]; + final float d_sup = SPLINE_POSITION[index + 1]; + velocityCoef = (d_sup - d_inf) / (t_sup - t_inf); + distanceCoef = d_inf + (t - t_inf) * velocityCoef; + } + + distance = distanceCoef * mSplineDistance; + mCurrVelocity = velocityCoef * mSplineDistance / mSplineDuration * 1000.0f; + break; + } + + case BALLISTIC: { + final float t = currentTime / 1000.0f; + mCurrVelocity = mVelocity + mDeceleration * t; + distance = mVelocity * t + mDeceleration * t * t / 2.0f; + break; + } + + case CUBIC: { + final float t = (float) (currentTime) / mDuration; + final float t2 = t * t; + final float sign = Math.signum(mVelocity); + distance = sign * mOver * (3.0f * t2 - 2.0f * t * t2); + mCurrVelocity = sign * mOver * 6.0f * (- t + t2); + break; + } + } + + mCurrentPosition = mStart + (int) Math.round(distance); + + return true; + } + } +} diff --git a/gallerycommon/src/com/android/gallery3d/common/Scroller.java b/gallerycommon/src/com/android/gallery3d/common/Scroller.java new file mode 100644 index 000000000..160f3ca43 --- /dev/null +++ b/gallerycommon/src/com/android/gallery3d/common/Scroller.java @@ -0,0 +1,507 @@ +/* + * Copyright (C) 2006 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.android.gallery3d.common; + +import android.content.Context; +import android.hardware.SensorManager; +import android.os.Build; +import android.util.FloatMath; +import android.view.ViewConfiguration; +import android.view.animation.AnimationUtils; +import android.view.animation.Interpolator; + + +/** + * This class encapsulates scrolling. The duration of the scroll + * can be passed in the constructor and specifies the maximum time that + * the scrolling animation should take. Past this time, the scrolling is + * automatically moved to its final stage and computeScrollOffset() + * will always return false to indicate that scrolling is over. + */ +public class Scroller { + private int mMode; + + private int mStartX; + private int mStartY; + private int mFinalX; + private int mFinalY; + + private int mMinX; + private int mMaxX; + private int mMinY; + private int mMaxY; + + private int mCurrX; + private int mCurrY; + private long mStartTime; + private int mDuration; + private float mDurationReciprocal; + private float mDeltaX; + private float mDeltaY; + private boolean mFinished; + private Interpolator mInterpolator; + private boolean mFlywheel; + + private float mVelocity; + + private static final int DEFAULT_DURATION = 250; + private static final int SCROLL_MODE = 0; + private static final int FLING_MODE = 1; + + private static float DECELERATION_RATE = (float) (Math.log(0.75) / Math.log(0.9)); + private static float ALPHA = 800; // pixels / seconds + private static float START_TENSION = 0.4f; // Tension at start: (0.4 * total T, 1.0 * Distance) + private static float END_TENSION = 1.0f - START_TENSION; + private static final int NB_SAMPLES = 100; + private static final float[] SPLINE = new float[NB_SAMPLES + 1]; + + private float mDeceleration; + private final float mPpi; + + static { + float x_min = 0.0f; + for (int i = 0; i <= NB_SAMPLES; i++) { + final float t = (float) i / NB_SAMPLES; + float x_max = 1.0f; + float x, tx, coef; + while (true) { + x = x_min + (x_max - x_min) / 2.0f; + coef = 3.0f * x * (1.0f - x); + tx = coef * ((1.0f - x) * START_TENSION + x * END_TENSION) + x * x * x; + if (Math.abs(tx - t) < 1E-5) break; + if (tx > t) x_max = x; + else x_min = x; + } + final float d = coef + x * x * x; + SPLINE[i] = d; + } + SPLINE[NB_SAMPLES] = 1.0f; + + // This controls the viscous fluid effect (how much of it) + sViscousFluidScale = 8.0f; + // must be set to 1.0 (used in viscousFluid()) + sViscousFluidNormalize = 1.0f; + sViscousFluidNormalize = 1.0f / viscousFluid(1.0f); + } + + private static float sViscousFluidScale; + private static float sViscousFluidNormalize; + + /** + * Create a Scroller with the default duration and interpolator. + */ + public Scroller(Context context) { + this(context, null); + } + + /** + * Create a Scroller with the specified interpolator. If the interpolator is + * null, the default (viscous) interpolator will be used. "Flywheel" behavior will + * be in effect for apps targeting Honeycomb or newer. + */ + public Scroller(Context context, Interpolator interpolator) { + this(context, interpolator, + context.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.HONEYCOMB); + } + + /** + * Create a Scroller with the specified interpolator. If the interpolator is + * null, the default (viscous) interpolator will be used. Specify whether or + * not to support progressive "flywheel" behavior in flinging. + */ + public Scroller(Context context, Interpolator interpolator, boolean flywheel) { + mFinished = true; + mInterpolator = interpolator; + mPpi = context.getResources().getDisplayMetrics().density * 160.0f; + mDeceleration = computeDeceleration(ViewConfiguration.getScrollFriction()); + mFlywheel = flywheel; + } + + /** + * The amount of friction applied to flings. The default value + * is {@link ViewConfiguration#getScrollFriction}. + * + * @param friction A scalar dimension-less value representing the coefficient of + * friction. + */ + public final void setFriction(float friction) { + mDeceleration = computeDeceleration(friction); + } + + private float computeDeceleration(float friction) { + return SensorManager.GRAVITY_EARTH // g (m/s^2) + * 39.37f // inch/meter + * mPpi // pixels per inch + * friction; + } + + /** + * + * Returns whether the scroller has finished scrolling. + * + * @return True if the scroller has finished scrolling, false otherwise. + */ + public final boolean isFinished() { + return mFinished; + } + + /** + * Force the finished field to a particular value. + * + * @param finished The new finished value. + */ + public final void forceFinished(boolean finished) { + mFinished = finished; + } + + /** + * Returns how long the scroll event will take, in milliseconds. + * + * @return The duration of the scroll in milliseconds. + */ + public final int getDuration() { + return mDuration; + } + + /** + * Returns the current X offset in the scroll. + * + * @return The new X offset as an absolute distance from the origin. + */ + public final int getCurrX() { + return mCurrX; + } + + /** + * Returns the current Y offset in the scroll. + * + * @return The new Y offset as an absolute distance from the origin. + */ + public final int getCurrY() { + return mCurrY; + } + + /** + * Returns the current velocity. + * + * @return The original velocity less the deceleration. Result may be + * negative. + */ + public float getCurrVelocity() { + return mVelocity - mDeceleration * timePassed() / 2000.0f; + } + + /** + * Returns the start X offset in the scroll. + * + * @return The start X offset as an absolute distance from the origin. + */ + public final int getStartX() { + return mStartX; + } + + /** + * Returns the start Y offset in the scroll. + * + * @return The start Y offset as an absolute distance from the origin. + */ + public final int getStartY() { + return mStartY; + } + + /** + * Returns where the scroll will end. Valid only for "fling" scrolls. + * + * @return The final X offset as an absolute distance from the origin. + */ + public final int getFinalX() { + return mFinalX; + } + + /** + * Returns where the scroll will end. Valid only for "fling" scrolls. + * + * @return The final Y offset as an absolute distance from the origin. + */ + public final int getFinalY() { + return mFinalY; + } + + /** + * Call this when you want to know the new location. If it returns true, + * the animation is not yet finished. loc will be altered to provide the + * new location. + */ + public boolean computeScrollOffset() { + if (mFinished) { + return false; + } + + int timePassed = (int)(AnimationUtils.currentAnimationTimeMillis() - mStartTime); + + if (timePassed < mDuration) { + switch (mMode) { + case SCROLL_MODE: + float x = timePassed * mDurationReciprocal; + + if (mInterpolator == null) + x = viscousFluid(x); + else + x = mInterpolator.getInterpolation(x); + + mCurrX = mStartX + Math.round(x * mDeltaX); + mCurrY = mStartY + Math.round(x * mDeltaY); + break; + case FLING_MODE: + final float t = (float) timePassed / mDuration; + final int index = (int) (NB_SAMPLES * t); + final float t_inf = (float) index / NB_SAMPLES; + final float t_sup = (float) (index + 1) / NB_SAMPLES; + final float d_inf = SPLINE[index]; + final float d_sup = SPLINE[index + 1]; + final float distanceCoef = d_inf + (t - t_inf) / (t_sup - t_inf) * (d_sup - d_inf); + + mCurrX = mStartX + Math.round(distanceCoef * (mFinalX - mStartX)); + // Pin to mMinX <= mCurrX <= mMaxX + mCurrX = Math.min(mCurrX, mMaxX); + mCurrX = Math.max(mCurrX, mMinX); + + mCurrY = mStartY + Math.round(distanceCoef * (mFinalY - mStartY)); + // Pin to mMinY <= mCurrY <= mMaxY + mCurrY = Math.min(mCurrY, mMaxY); + mCurrY = Math.max(mCurrY, mMinY); + + if (mCurrX == mFinalX && mCurrY == mFinalY) { + mFinished = true; + } + + break; + } + } + else { + mCurrX = mFinalX; + mCurrY = mFinalY; + mFinished = true; + } + return true; + } + + /** + * Start scrolling by providing a starting point and the distance to travel. + * The scroll will use the default value of 250 milliseconds for the + * duration. + * + * @param startX Starting horizontal scroll offset in pixels. Positive + * numbers will scroll the content to the left. + * @param startY Starting vertical scroll offset in pixels. Positive numbers + * will scroll the content up. + * @param dx Horizontal distance to travel. Positive numbers will scroll the + * content to the left. + * @param dy Vertical distance to travel. Positive numbers will scroll the + * content up. + */ + public void startScroll(int startX, int startY, int dx, int dy) { + startScroll(startX, startY, dx, dy, DEFAULT_DURATION); + } + + /** + * Start scrolling by providing a starting point and the distance to travel. + * + * @param startX Starting horizontal scroll offset in pixels. Positive + * numbers will scroll the content to the left. + * @param startY Starting vertical scroll offset in pixels. Positive numbers + * will scroll the content up. + * @param dx Horizontal distance to travel. Positive numbers will scroll the + * content to the left. + * @param dy Vertical distance to travel. Positive numbers will scroll the + * content up. + * @param duration Duration of the scroll in milliseconds. + */ + public void startScroll(int startX, int startY, int dx, int dy, int duration) { + mMode = SCROLL_MODE; + mFinished = false; + mDuration = duration; + mStartTime = AnimationUtils.currentAnimationTimeMillis(); + mStartX = startX; + mStartY = startY; + mFinalX = startX + dx; + mFinalY = startY + dy; + mDeltaX = dx; + mDeltaY = dy; + mDurationReciprocal = 1.0f / (float) mDuration; + } + + /** + * Start scrolling based on a fling gesture. The distance travelled will + * depend on the initial velocity of the fling. + * + * @param startX Starting point of the scroll (X) + * @param startY Starting point of the scroll (Y) + * @param velocityX Initial velocity of the fling (X) measured in pixels per + * second. + * @param velocityY Initial velocity of the fling (Y) measured in pixels per + * second + * @param minX Minimum X value. The scroller will not scroll past this + * point. + * @param maxX Maximum X value. The scroller will not scroll past this + * point. + * @param minY Minimum Y value. The scroller will not scroll past this + * point. + * @param maxY Maximum Y value. The scroller will not scroll past this + * point. + */ + public void fling(int startX, int startY, int velocityX, int velocityY, + int minX, int maxX, int minY, int maxY) { + // Continue a scroll or fling in progress + if (mFlywheel && !mFinished) { + float oldVel = getCurrVelocity(); + + float dx = (float) (mFinalX - mStartX); + float dy = (float) (mFinalY - mStartY); + float hyp = FloatMath.sqrt(dx * dx + dy * dy); + + float ndx = dx / hyp; + float ndy = dy / hyp; + + float oldVelocityX = ndx * oldVel; + float oldVelocityY = ndy * oldVel; + if (Math.signum(velocityX) == Math.signum(oldVelocityX) && + Math.signum(velocityY) == Math.signum(oldVelocityY)) { + velocityX += oldVelocityX; + velocityY += oldVelocityY; + } + } + + mMode = FLING_MODE; + mFinished = false; + + float velocity = FloatMath.sqrt(velocityX * velocityX + velocityY * velocityY); + + mVelocity = velocity; + final double l = Math.log(START_TENSION * velocity / ALPHA); + mDuration = (int) (1000.0 * Math.exp(l / (DECELERATION_RATE - 1.0))); + mStartTime = AnimationUtils.currentAnimationTimeMillis(); + mStartX = startX; + mStartY = startY; + + float coeffX = velocity == 0 ? 1.0f : velocityX / velocity; + float coeffY = velocity == 0 ? 1.0f : velocityY / velocity; + + int totalDistance = + (int) (ALPHA * Math.exp(DECELERATION_RATE / (DECELERATION_RATE - 1.0) * l)); + + mMinX = minX; + mMaxX = maxX; + mMinY = minY; + mMaxY = maxY; + + mFinalX = startX + Math.round(totalDistance * coeffX); + // Pin to mMinX <= mFinalX <= mMaxX + mFinalX = Math.min(mFinalX, mMaxX); + mFinalX = Math.max(mFinalX, mMinX); + + mFinalY = startY + Math.round(totalDistance * coeffY); + // Pin to mMinY <= mFinalY <= mMaxY + mFinalY = Math.min(mFinalY, mMaxY); + mFinalY = Math.max(mFinalY, mMinY); + } + + static float viscousFluid(float x) + { + x *= sViscousFluidScale; + if (x < 1.0f) { + x -= (1.0f - (float)Math.exp(-x)); + } else { + float start = 0.36787944117f; // 1/e == exp(-1) + x = 1.0f - (float)Math.exp(1.0f - x); + x = start + x * (1.0f - start); + } + x *= sViscousFluidNormalize; + return x; + } + + /** + * Stops the animation. Contrary to {@link #forceFinished(boolean)}, + * aborting the animating cause the scroller to move to the final x and y + * position + * + * @see #forceFinished(boolean) + */ + public void abortAnimation() { + mCurrX = mFinalX; + mCurrY = mFinalY; + mFinished = true; + } + + /** + * Extend the scroll animation. This allows a running animation to scroll + * further and longer, when used with {@link #setFinalX(int)} or {@link #setFinalY(int)}. + * + * @param extend Additional time to scroll in milliseconds. + * @see #setFinalX(int) + * @see #setFinalY(int) + */ + public void extendDuration(int extend) { + int passed = timePassed(); + mDuration = passed + extend; + mDurationReciprocal = 1.0f / mDuration; + mFinished = false; + } + + /** + * Returns the time elapsed since the beginning of the scrolling. + * + * @return The elapsed time in milliseconds. + */ + public int timePassed() { + return (int)(AnimationUtils.currentAnimationTimeMillis() - mStartTime); + } + + /** + * Sets the final position (X) for this scroller. + * + * @param newX The new X offset as an absolute distance from the origin. + * @see #extendDuration(int) + * @see #setFinalY(int) + */ + public void setFinalX(int newX) { + mFinalX = newX; + mDeltaX = mFinalX - mStartX; + mFinished = false; + } + + /** + * Sets the final position (Y) for this scroller. + * + * @param newY The new Y offset as an absolute distance from the origin. + * @see #extendDuration(int) + * @see #setFinalX(int) + */ + public void setFinalY(int newY) { + mFinalY = newY; + mDeltaY = mFinalY - mStartY; + mFinished = false; + } + + /** + * @hide + */ + public boolean isScrollingInDirection(float xvel, float yvel) { + return !mFinished && Math.signum(xvel) == Math.signum(mFinalX - mStartX) && + Math.signum(yvel) == Math.signum(mFinalY - mStartY); + } +} diff --git a/src/com/android/gallery3d/app/MoviePlayer.java b/src/com/android/gallery3d/app/MoviePlayer.java index 660c4d953..f2dc9ad20 100644 --- a/src/com/android/gallery3d/app/MoviePlayer.java +++ b/src/com/android/gallery3d/app/MoviePlayer.java @@ -58,6 +58,10 @@ public class MoviePlayer implements private static final String KEY_VIDEO_POSITION = "video-position"; private static final String KEY_RESUMEABLE_TIME = "resumeable-timeout"; + // These are constants in KeyEvent, appearing on API level 11. + private static final int KEYCODE_MEDIA_PLAY = 126; + private static final int KEYCODE_MEDIA_PAUSE = 127; + // Copied from MediaPlaybackService in the Music Player app. private static final String SERVICECMD = "com.android.music.musicservicecommand"; private static final String CMDNAME = "command"; @@ -411,12 +415,12 @@ public class MoviePlayer implements playVideo(); } return true; - case KeyEvent.KEYCODE_MEDIA_PAUSE: + case KEYCODE_MEDIA_PAUSE: if (mVideoView.isPlaying()) { pauseVideo(); } return true; - case KeyEvent.KEYCODE_MEDIA_PLAY: + case KEYCODE_MEDIA_PLAY: if (!mVideoView.isPlaying()) { playVideo(); } diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index 22b01637e..3b6a7704b 100644 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -321,10 +321,9 @@ public class PhotoPage extends ActivityState implements } } - @TargetApi(Build.VERSION_CODES.JELLY_BEAN) + @TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN) private void setNfcBeamPushUris(Uri[] uris) { - if (mNfcAdapter != null && - Build.VERSION.SDK_INT >= ApiHelper.VERSION_CODES.JELLY_BEAN) { + if (mNfcAdapter != null && ApiHelper.HAS_SET_BEAM_PUSH_URIS) { mNfcAdapter.setBeamPushUris(uris, (Activity)mActivity); } } diff --git a/src/com/android/gallery3d/ui/ActionModeHandler.java b/src/com/android/gallery3d/ui/ActionModeHandler.java index 2a0157a4b..190b2b8c6 100644 --- a/src/com/android/gallery3d/ui/ActionModeHandler.java +++ b/src/com/android/gallery3d/ui/ActionModeHandler.java @@ -227,10 +227,9 @@ public class ActionModeHandler implements ActionMode.Callback { return operation; } - @TargetApi(Build.VERSION_CODES.JELLY_BEAN) + @TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN) private void setNfcBeamPushUris(Uri[] uris) { - if (mNfcAdapter != null && - Build.VERSION.SDK_INT >= ApiHelper.VERSION_CODES.JELLY_BEAN) { + if (mNfcAdapter != null && ApiHelper.HAS_SET_BEAM_PUSH_URIS) { mNfcAdapter.setBeamPushUris(uris, (Activity)mActivity); } } diff --git a/src/com/android/gallery3d/ui/PositionController.java b/src/com/android/gallery3d/ui/PositionController.java index 6d334709d..9b77d6814 100644 --- a/src/com/android/gallery3d/ui/PositionController.java +++ b/src/com/android/gallery3d/ui/PositionController.java @@ -19,8 +19,8 @@ package com.android.gallery3d.ui; import android.content.Context; import android.graphics.Rect; import android.util.Log; -import android.widget.OverScroller; +import com.android.gallery3d.common.OverScroller; import com.android.gallery3d.common.Utils; import com.android.gallery3d.util.GalleryUtils; import com.android.gallery3d.util.RangeArray; diff --git a/src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java b/src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java index 5f45f1683..a04313b8b 100644 --- a/src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java +++ b/src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java @@ -16,13 +16,20 @@ package com.android.gallery3d.ui; +import android.annotation.TargetApi; import android.graphics.RectF; import android.graphics.SurfaceTexture; import android.opengl.GLES11Ext; +import com.android.gallery3d.common.ApiHelper; + public abstract class SurfaceTextureScreenNail implements ScreenNail, SurfaceTexture.OnFrameAvailableListener { private static final String TAG = "SurfaceTextureScreenNail"; + // This constant is not available in API level before 15, but it was just an + // oversight. + private static final int GL_TEXTURE_EXTERNAL_OES = 0x8D65; + protected ExtTexture mExtTexture; private SurfaceTexture mSurfaceTexture; private int mWidth, mHeight; @@ -33,16 +40,23 @@ public abstract class SurfaceTextureScreenNail implements ScreenNail, } public void acquireSurfaceTexture() { - mExtTexture = new ExtTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES); + mExtTexture = new ExtTexture(GL_TEXTURE_EXTERNAL_OES); mExtTexture.setSize(mWidth, mHeight); mSurfaceTexture = new SurfaceTexture(mExtTexture.getId()); - mSurfaceTexture.setDefaultBufferSize(mWidth, mHeight); + setDefaultBufferSize(mSurfaceTexture, mWidth, mHeight); mSurfaceTexture.setOnFrameAvailableListener(this); synchronized (this) { mHasTexture = true; } } + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) + private static void setDefaultBufferSize(SurfaceTexture st, int width, int height) { + if (ApiHelper.HAS_SET_DEFALT_BUFFER_SIZE) { + st.setDefaultBufferSize(width, height); + } + } + public SurfaceTexture getSurfaceTexture() { return mSurfaceTexture; } -- GitLab From 6b9ff6aa3da883ee4efd682b3c6c331cf49066e1 Mon Sep 17 00:00:00 2001 From: Hung-ying Tyan Date: Tue, 3 Jul 2012 18:55:25 +0800 Subject: [PATCH 061/763] Add ExifTags to hold tag names that are not available in ExifInterface prior to API level 11. Bug: 6775786 Change-Id: Iab564f577d9a0b87c8fb7b91eda6cabc12b5a11a --- .../android/gallery3d/common/ExifTags.java | 27 +++++++++++++++++++ src/com/android/gallery3d/app/CropImage.java | 13 ++++----- .../android/gallery3d/data/MediaDetails.java | 7 ++--- 3 files changed, 38 insertions(+), 9 deletions(-) create mode 100644 gallerycommon/src/com/android/gallery3d/common/ExifTags.java diff --git a/gallerycommon/src/com/android/gallery3d/common/ExifTags.java b/gallerycommon/src/com/android/gallery3d/common/ExifTags.java new file mode 100644 index 000000000..9b11fe416 --- /dev/null +++ b/gallerycommon/src/com/android/gallery3d/common/ExifTags.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2012 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.android.gallery3d.common; + +/** + * The class holds the EXIF tag names that are not available in + * {@link android.media.ExifInterface} prior to API level 11. + */ +public interface ExifTags { + static final String TAG_ISO = "ISOSpeedRatings"; + static final String TAG_EXPOSURE_TIME = "ExposureTime"; + static final String TAG_APERTURE = "FNumber"; +} diff --git a/src/com/android/gallery3d/app/CropImage.java b/src/com/android/gallery3d/app/CropImage.java index 294e285ea..a587624ed 100644 --- a/src/com/android/gallery3d/app/CropImage.java +++ b/src/com/android/gallery3d/app/CropImage.java @@ -49,6 +49,7 @@ import android.widget.Toast; import com.android.gallery3d.R; import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.common.BitmapUtils; +import com.android.gallery3d.common.ExifTags; import com.android.gallery3d.common.Utils; import com.android.gallery3d.data.DataManager; import com.android.gallery3d.data.LocalImage; @@ -989,11 +990,11 @@ public class CropImage extends AbstractGalleryActivity { } // Handle some special values here - String value = oldExif.getAttribute(ExifInterface.TAG_APERTURE); + String value = oldExif.getAttribute(ExifTags.TAG_APERTURE); if (value != null) { try { float aperture = Float.parseFloat(value); - newExif.setAttribute(ExifInterface.TAG_APERTURE, + newExif.setAttribute(ExifTags.TAG_APERTURE, String.valueOf((int) (aperture * 10 + 0.5f)) + "/10"); } catch (NumberFormatException e) { Log.w(TAG, "cannot parse aperture: " + value); @@ -1002,22 +1003,22 @@ public class CropImage extends AbstractGalleryActivity { // TODO: The code is broken, need to fix the JHEAD lib /* - value = oldExif.getAttribute(ExifInterface.TAG_EXPOSURE_TIME); + value = oldExif.getAttribute(ExifTags.TAG_EXPOSURE_TIME); if (value != null) { try { double exposure = Double.parseDouble(value); testToRational("test exposure", exposure); - newExif.setAttribute(ExifInterface.TAG_EXPOSURE_TIME, value); + newExif.setAttribute(ExifTags.TAG_EXPOSURE_TIME, value); } catch (NumberFormatException e) { Log.w(TAG, "cannot parse exposure time: " + value); } } - value = oldExif.getAttribute(ExifInterface.TAG_ISO); + value = oldExif.getAttribute(ExifTags.TAG_ISO); if (value != null) { try { int iso = Integer.parseInt(value); - newExif.setAttribute(ExifInterface.TAG_ISO, String.valueOf(iso) + "/1"); + newExif.setAttribute(ExifTags.TAG_ISO, String.valueOf(iso) + "/1"); } catch (NumberFormatException e) { Log.w(TAG, "cannot parse exposure time: " + value); } diff --git a/src/com/android/gallery3d/data/MediaDetails.java b/src/com/android/gallery3d/data/MediaDetails.java index 9663dd0e6..c18365df0 100644 --- a/src/com/android/gallery3d/data/MediaDetails.java +++ b/src/com/android/gallery3d/data/MediaDetails.java @@ -19,6 +19,7 @@ package com.android.gallery3d.data; import android.media.ExifInterface; import com.android.gallery3d.R; +import com.android.gallery3d.common.ExifTags; import java.io.IOException; import java.util.HashMap; @@ -126,11 +127,11 @@ public class MediaDetails implements Iterable> { MediaDetails.INDEX_HEIGHT); setExifData(details, exif, ExifInterface.TAG_MAKE, MediaDetails.INDEX_MAKE); setExifData(details, exif, ExifInterface.TAG_MODEL, MediaDetails.INDEX_MODEL); - setExifData(details, exif, ExifInterface.TAG_APERTURE, MediaDetails.INDEX_APERTURE); - setExifData(details, exif, ExifInterface.TAG_ISO, MediaDetails.INDEX_ISO); + setExifData(details, exif, ExifTags.TAG_APERTURE, MediaDetails.INDEX_APERTURE); + setExifData(details, exif, ExifTags.TAG_ISO, MediaDetails.INDEX_ISO); setExifData(details, exif, ExifInterface.TAG_WHITE_BALANCE, MediaDetails.INDEX_WHITE_BALANCE); - setExifData(details, exif, ExifInterface.TAG_EXPOSURE_TIME, + setExifData(details, exif, ExifTags.TAG_EXPOSURE_TIME, MediaDetails.INDEX_EXPOSURE_TIME); double data = exif.getAttributeDouble(ExifInterface.TAG_FOCAL_LENGTH, 0); -- GitLab From 9e7992d94d18a1e6f32c9e4b8bc6f72e30f92983 Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Tue, 3 Jul 2012 10:47:44 -0700 Subject: [PATCH 062/763] Import translations. DO NOT MERGE Change-Id: I502e70e7b7acf9821cdefdc92352924c8fa9ba99 Auto-generated-cl: translation import --- res/values-af/strings.xml | 6 ++---- res/values-am/strings.xml | 6 ++---- res/values-ar/strings.xml | 6 ++---- res/values-be/strings.xml | 6 ++---- res/values-ca/strings.xml | 6 ++---- res/values-da/strings.xml | 6 ++---- res/values-el/strings.xml | 6 ++---- res/values-en-rGB/strings.xml | 6 ++---- res/values-fa/strings.xml | 6 ++---- res/values-hu/strings.xml | 6 ++---- res/values-it/strings.xml | 6 ++---- res/values-iw/strings.xml | 6 ++---- res/values-pl/strings.xml | 6 ++---- res/values-pt-rPT/strings.xml | 6 ++---- res/values-pt/strings.xml | 6 ++---- res/values-ru/strings.xml | 6 ++---- res/values-sv/strings.xml | 6 ++---- res/values-sw/strings.xml | 6 ++---- res/values-th/strings.xml | 6 ++---- res/values-tl/strings.xml | 6 ++---- res/values-uk/strings.xml | 6 ++---- res/values-zh-rCN/strings.xml | 6 ++---- res/values-zu/strings.xml | 6 ++---- 23 files changed, 46 insertions(+), 92 deletions(-) diff --git a/res/values-af/strings.xml b/res/values-af/strings.xml index 2e4fd27c0..53067826d 100644 --- a/res/values-af/strings.xml +++ b/res/values-af/strings.xml @@ -173,8 +173,6 @@ "Ingevoer" "Skermkiekie" "Hulp" - - - - + "Geen berging nie" + "Geen eksterne berging beskikbaar nie" diff --git a/res/values-am/strings.xml b/res/values-am/strings.xml index 8fc98ec36..c559d745e 100644 --- a/res/values-am/strings.xml +++ b/res/values-am/strings.xml @@ -173,8 +173,6 @@ "ከውጭ የገባ" "ቅጽበታዊ ገጽ እይታ" "እገዛ" - - - - + "ምንም ማከማቻ የለም" + "ምንም ውጫዊ ማከማቻ የለም" diff --git a/res/values-ar/strings.xml b/res/values-ar/strings.xml index 8549b003b..73d24288a 100644 --- a/res/values-ar/strings.xml +++ b/res/values-ar/strings.xml @@ -173,8 +173,6 @@ "المستوردة" "لقطة شاشة" "المساعدة" - - - - + "لا تتوفر سعة تخزين" + "لا تتوفر سعة تخزين خارجية" diff --git a/res/values-be/strings.xml b/res/values-be/strings.xml index 74b23628e..d6f9dd5f3 100644 --- a/res/values-be/strings.xml +++ b/res/values-be/strings.xml @@ -173,8 +173,6 @@ "Імпартаваныя" "Скрыншот" "Даведка" - - - - + "Няма захавальнiкаў" + "Няма даступных знешнiх захавальнiкаў" diff --git a/res/values-ca/strings.xml b/res/values-ca/strings.xml index 56697efb4..b461bf51c 100644 --- a/res/values-ca/strings.xml +++ b/res/values-ca/strings.xml @@ -173,8 +173,6 @@ "Importades" "Captura de pantalla" "Ajuda" - - - - + "No hi ha emmagatzem." + "No hi ha emmagatzematge extern disponible" diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml index 76c3e3168..63aeca2df 100644 --- a/res/values-da/strings.xml +++ b/res/values-da/strings.xml @@ -173,8 +173,6 @@ "Importeret" "Skærmbillede" "Hjælp" - - - - + "Intet lager" + "Intet tilgængeligt eksternt lager" diff --git a/res/values-el/strings.xml b/res/values-el/strings.xml index 691a3020f..32377af68 100644 --- a/res/values-el/strings.xml +++ b/res/values-el/strings.xml @@ -173,8 +173,6 @@ "Έγινε εισαγωγή" "Στιγμιότυπο οθόνης" "Βοήθεια" - - - - + "Δεν υπάρχ.αποθ.χώρ." + "Δεν υπάρχει διαθέσιμος εξωτερικός χώρος αποθήκευσης" diff --git a/res/values-en-rGB/strings.xml b/res/values-en-rGB/strings.xml index a2f68d8f9..f94b04197 100644 --- a/res/values-en-rGB/strings.xml +++ b/res/values-en-rGB/strings.xml @@ -173,8 +173,6 @@ "Imported" "Screenshot" "Help" - - - - + "No Storage" + "No external storage available" diff --git a/res/values-fa/strings.xml b/res/values-fa/strings.xml index 2055299bd..4ed530228 100644 --- a/res/values-fa/strings.xml +++ b/res/values-fa/strings.xml @@ -173,8 +173,6 @@ "وارد شده" "عکس صفحه" "راهنما" - - - - + "فاقد دستگاه ذخیره‌‌‌سازی" + "هیچ دستگاه ذخیره خارجی دردسترس نیست" diff --git a/res/values-hu/strings.xml b/res/values-hu/strings.xml index 4afaaf9d3..0e1d04aae 100644 --- a/res/values-hu/strings.xml +++ b/res/values-hu/strings.xml @@ -173,8 +173,6 @@ "Importált" "Képernyőkép" "Súgó" - - - - + "Nincs tárhely" + "Nincs elérhető külső tárhely" diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index 7484105dc..d27ceb2cb 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -173,8 +173,6 @@ "Importate" "Screenshot" "Guida" - - - - + "Nessun archivio" + "Nessun archivio esterno disponibile" diff --git a/res/values-iw/strings.xml b/res/values-iw/strings.xml index a14f1b779..7ff250377 100644 --- a/res/values-iw/strings.xml +++ b/res/values-iw/strings.xml @@ -173,8 +173,6 @@ "מיובאות" "צילום מסך" "עזרה" - - - - + "אין אחסון" + "אחסון חיצוני לא זמין" diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml index cd1fa91ce..87bee55cd 100644 --- a/res/values-pl/strings.xml +++ b/res/values-pl/strings.xml @@ -173,8 +173,6 @@ "Zaimportowane" "Zrzuty ekranu" "Pomoc" - - - - + "Brak pamięci" + "Brak pamięci zewnętrznej" diff --git a/res/values-pt-rPT/strings.xml b/res/values-pt-rPT/strings.xml index 1c6b15018..b66ff4b8a 100644 --- a/res/values-pt-rPT/strings.xml +++ b/res/values-pt-rPT/strings.xml @@ -173,8 +173,6 @@ "Importada" "Captura de ecrã" "Ajuda" - - - - + "Nenhum Armazenamento" + "Nenhum armazenamento externo disponível" diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml index cce8e775a..49bc6a2e6 100644 --- a/res/values-pt/strings.xml +++ b/res/values-pt/strings.xml @@ -173,8 +173,6 @@ "Importado" "Capturas de tela" "Ajuda" - - - - + "Nenhum armazenamento" + "Nenhum armazenamento externo disponível" diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index 027afdbf4..0aaab06b1 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -173,8 +173,6 @@ "Импортированные" "Скриншоты" "Справка" - - - - + "Накопитель не найден" + "Нет внешних накопителей" diff --git a/res/values-sv/strings.xml b/res/values-sv/strings.xml index 78822b232..3e3043b6d 100644 --- a/res/values-sv/strings.xml +++ b/res/values-sv/strings.xml @@ -173,8 +173,6 @@ "Importerat" "Skärmbild" "Hjälp" - - - - + "Ingen lagringsenhet" + "Inget externt lagringsutrymme är tillgängligt" diff --git a/res/values-sw/strings.xml b/res/values-sw/strings.xml index 85d6c8e4c..45438f492 100644 --- a/res/values-sw/strings.xml +++ b/res/values-sw/strings.xml @@ -176,8 +176,6 @@ "Zilizoletwa" "Picha kiwamba" "Msaada" - - - - + "Hakuna Hifadhi" + "Hakuna hifadhi ya nje inayopatikana" diff --git a/res/values-th/strings.xml b/res/values-th/strings.xml index 7276dca2e..24fcd247e 100644 --- a/res/values-th/strings.xml +++ b/res/values-th/strings.xml @@ -173,8 +173,6 @@ "นำเข้าแล้ว" "ภาพหน้าจอ" "ความช่วยเหลือ" - - - - + "ไม่มีที่เก็บข้อมูล" + "ไม่มีที่จัดเก็บข้อมูลภายนอกที่สามารถใช้ได้" diff --git a/res/values-tl/strings.xml b/res/values-tl/strings.xml index 239d26a46..1a8562647 100644 --- a/res/values-tl/strings.xml +++ b/res/values-tl/strings.xml @@ -173,8 +173,6 @@ "Na-import" "Screenshot" "Tulong" - - - - + "Walang Storage" + "Walang available na panlabas na storage" diff --git a/res/values-uk/strings.xml b/res/values-uk/strings.xml index 49bea9c17..ee25bb556 100644 --- a/res/values-uk/strings.xml +++ b/res/values-uk/strings.xml @@ -173,8 +173,6 @@ "Імпортовані" "Знімки екрана" "Довідка" - - - - + "Немає пам’яті" + "Доступної зовнішньої пам’яті немає" diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index 5ebb05197..0454147fb 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -173,8 +173,6 @@ "已导入" "屏幕截图" "帮助" - - - - + "没有外部存储设备" + "没有可用的外部存储设备" diff --git a/res/values-zu/strings.xml b/res/values-zu/strings.xml index 009cae796..8bf89d8d6 100644 --- a/res/values-zu/strings.xml +++ b/res/values-zu/strings.xml @@ -175,8 +175,6 @@ "Okulandiwe" "Isithombe-skrini" "Usizo" - - - - + "Asikho isilondolozi" + "Asikho isilondolozi sangaphandle esikhona" -- GitLab From 85c4d54f7d59eea01dfc8c9ea4c51ec59f67cd68 Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Tue, 3 Jul 2012 10:49:16 -0700 Subject: [PATCH 063/763] Import translations. DO NOT MERGE Change-Id: I5ecde362be1d6e55ecc5e6fe5f449a3e435080f8 Auto-generated-cl: translation import --- res/values-af/strings.xml | 6 ++---- res/values-am/strings.xml | 6 ++---- res/values-ar/strings.xml | 6 ++---- res/values-da/strings.xml | 6 ++---- res/values-el/strings.xml | 6 ++---- res/values-hu/strings.xml | 6 ++---- res/values-pl/strings.xml | 6 ++---- res/values-pt-rPT/strings.xml | 6 ++---- res/values-pt/strings.xml | 6 ++---- res/values-tl/strings.xml | 6 ++---- res/values-uk/strings.xml | 6 ++---- res/values-zh-rCN/strings.xml | 6 ++---- 12 files changed, 24 insertions(+), 48 deletions(-) diff --git a/res/values-af/strings.xml b/res/values-af/strings.xml index 2e4fd27c0..53067826d 100644 --- a/res/values-af/strings.xml +++ b/res/values-af/strings.xml @@ -173,8 +173,6 @@ "Ingevoer" "Skermkiekie" "Hulp" - - - - + "Geen berging nie" + "Geen eksterne berging beskikbaar nie" diff --git a/res/values-am/strings.xml b/res/values-am/strings.xml index 8fc98ec36..c559d745e 100644 --- a/res/values-am/strings.xml +++ b/res/values-am/strings.xml @@ -173,8 +173,6 @@ "ከውጭ የገባ" "ቅጽበታዊ ገጽ እይታ" "እገዛ" - - - - + "ምንም ማከማቻ የለም" + "ምንም ውጫዊ ማከማቻ የለም" diff --git a/res/values-ar/strings.xml b/res/values-ar/strings.xml index 8549b003b..73d24288a 100644 --- a/res/values-ar/strings.xml +++ b/res/values-ar/strings.xml @@ -173,8 +173,6 @@ "المستوردة" "لقطة شاشة" "المساعدة" - - - - + "لا تتوفر سعة تخزين" + "لا تتوفر سعة تخزين خارجية" diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml index 76c3e3168..63aeca2df 100644 --- a/res/values-da/strings.xml +++ b/res/values-da/strings.xml @@ -173,8 +173,6 @@ "Importeret" "Skærmbillede" "Hjælp" - - - - + "Intet lager" + "Intet tilgængeligt eksternt lager" diff --git a/res/values-el/strings.xml b/res/values-el/strings.xml index 691a3020f..32377af68 100644 --- a/res/values-el/strings.xml +++ b/res/values-el/strings.xml @@ -173,8 +173,6 @@ "Έγινε εισαγωγή" "Στιγμιότυπο οθόνης" "Βοήθεια" - - - - + "Δεν υπάρχ.αποθ.χώρ." + "Δεν υπάρχει διαθέσιμος εξωτερικός χώρος αποθήκευσης" diff --git a/res/values-hu/strings.xml b/res/values-hu/strings.xml index 4afaaf9d3..0e1d04aae 100644 --- a/res/values-hu/strings.xml +++ b/res/values-hu/strings.xml @@ -173,8 +173,6 @@ "Importált" "Képernyőkép" "Súgó" - - - - + "Nincs tárhely" + "Nincs elérhető külső tárhely" diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml index cd1fa91ce..87bee55cd 100644 --- a/res/values-pl/strings.xml +++ b/res/values-pl/strings.xml @@ -173,8 +173,6 @@ "Zaimportowane" "Zrzuty ekranu" "Pomoc" - - - - + "Brak pamięci" + "Brak pamięci zewnętrznej" diff --git a/res/values-pt-rPT/strings.xml b/res/values-pt-rPT/strings.xml index 1c6b15018..b66ff4b8a 100644 --- a/res/values-pt-rPT/strings.xml +++ b/res/values-pt-rPT/strings.xml @@ -173,8 +173,6 @@ "Importada" "Captura de ecrã" "Ajuda" - - - - + "Nenhum Armazenamento" + "Nenhum armazenamento externo disponível" diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml index cce8e775a..49bc6a2e6 100644 --- a/res/values-pt/strings.xml +++ b/res/values-pt/strings.xml @@ -173,8 +173,6 @@ "Importado" "Capturas de tela" "Ajuda" - - - - + "Nenhum armazenamento" + "Nenhum armazenamento externo disponível" diff --git a/res/values-tl/strings.xml b/res/values-tl/strings.xml index 239d26a46..1a8562647 100644 --- a/res/values-tl/strings.xml +++ b/res/values-tl/strings.xml @@ -173,8 +173,6 @@ "Na-import" "Screenshot" "Tulong" - - - - + "Walang Storage" + "Walang available na panlabas na storage" diff --git a/res/values-uk/strings.xml b/res/values-uk/strings.xml index 49bea9c17..ee25bb556 100644 --- a/res/values-uk/strings.xml +++ b/res/values-uk/strings.xml @@ -173,8 +173,6 @@ "Імпортовані" "Знімки екрана" "Довідка" - - - - + "Немає пам’яті" + "Доступної зовнішньої пам’яті немає" diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index 5ebb05197..0454147fb 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -173,8 +173,6 @@ "已导入" "屏幕截图" "帮助" - - - - + "没有外部存储设备" + "没有可用的外部存储设备" -- GitLab From 04ebde7418493debda790f3eae933b5f6c38e897 Mon Sep 17 00:00:00 2001 From: Chih-Chung Chang Date: Tue, 3 Jul 2012 19:33:46 +0800 Subject: [PATCH 064/763] Use MTP only if the MTP API is available. Change-Id: I5c747d0da2905eb344c56dfab6333034dd5eecc3 --- .../src/com/android/gallery3d/common/ApiHelper.java | 3 +++ src/com/android/gallery3d/data/DataManager.java | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java index a908e1591..c1724a825 100644 --- a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java +++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java @@ -54,6 +54,9 @@ public class ApiHelper { "android.graphics.SurfaceTexture", "setDefaultBufferSize", int.class, int.class); + public static final boolean HAS_MTP = + Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB_MR1; + private static boolean hasField(Class klass, String fieldName) { try { klass.getDeclaredField(fieldName); diff --git a/src/com/android/gallery3d/data/DataManager.java b/src/com/android/gallery3d/data/DataManager.java index 85513279c..9ffdc0b50 100644 --- a/src/com/android/gallery3d/data/DataManager.java +++ b/src/com/android/gallery3d/data/DataManager.java @@ -23,6 +23,7 @@ import android.os.Handler; import android.support.v4.content.LocalBroadcastManager; import com.android.gallery3d.app.GalleryApp; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.common.Utils; import com.android.gallery3d.data.MediaSet.ItemConsumer; import com.android.gallery3d.data.MediaSource.PathId; @@ -115,7 +116,9 @@ public class DataManager { // the order matters, the UriSource must come last addSource(new LocalSource(mApplication)); addSource(new PicasaSource(mApplication)); - addSource(new MtpSource(mApplication)); + if (ApiHelper.HAS_MTP) { + addSource(new MtpSource(mApplication)); + } addSource(new ComboSource(mApplication)); addSource(new ClusterSource(mApplication)); addSource(new FilterSource(mApplication)); -- GitLab From 097518e3dcbf212a78fa1fe3ad1ddea236401eb5 Mon Sep 17 00:00:00 2001 From: Chih-Chung Chang Date: Wed, 4 Jul 2012 16:54:02 +0800 Subject: [PATCH 065/763] Don't use AutoFocusMoveCallback on older platforms. Change-Id: I281888ee88c08b1caf4754e714f0f42c75e26dd9 --- gallerycommon/src/com/android/gallery3d/common/ApiHelper.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java index c1724a825..4545b92f3 100644 --- a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java +++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java @@ -57,6 +57,9 @@ public class ApiHelper { public static final boolean HAS_MTP = Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB_MR1; + public static final boolean HAS_AUTO_FOCUS_MOVE_CALLBACK = + Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN; + private static boolean hasField(Class klass, String fieldName) { try { klass.getDeclaredField(fieldName); -- GitLab From b1eb01cd02d1e75e6b9c3e593f6ff34335e2ca8a Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Wed, 4 Jul 2012 15:48:59 +0800 Subject: [PATCH 066/763] Don't use invalidateOptionsMenu before API level 11. Change-Id: If46d46e44797b2bd4f66235eca0954a55d0008cf --- .../android/gallery3d/common/ApiHelper.java | 16 +++++++++- .../app/AbstractGalleryActivity.java | 29 +++++++++++++++++++ .../android/gallery3d/app/ActivityState.java | 3 +- src/com/android/gallery3d/app/Gallery.java | 8 ----- 4 files changed, 45 insertions(+), 11 deletions(-) diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java index 4545b92f3..305fb2cf3 100644 --- a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java +++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java @@ -16,6 +16,7 @@ package com.android.gallery3d.common; +import android.app.Activity; import android.os.Build; import android.provider.MediaStore.MediaColumns; import android.view.View; @@ -60,6 +61,9 @@ public class ApiHelper { public static final boolean HAS_AUTO_FOCUS_MOVE_CALLBACK = Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN; + public static final boolean HAS_ACTIVITY_INVALIDATE_OPTIONS_MENU = + hasMethod(Activity.class, "invalidateOptionsMenu"); + private static boolean hasField(Class klass, String fieldName) { try { klass.getDeclaredField(fieldName); @@ -72,11 +76,21 @@ public class ApiHelper { private static boolean hasMethod(String className, String methodName, Class... parameterTypes) { try { - Class klass = Class.forName(className); + Class klass = Class.forName(className); klass.getDeclaredMethod(methodName, parameterTypes); return true; } catch (Throwable th) { return false; } } + + private static boolean hasMethod( + Class klass, String methodName, Class ... paramTypes) { + try { + klass.getDeclaredMethod(methodName, paramTypes); + return true; + } catch (NoSuchMethodException e) { + return false; + } + } } diff --git a/src/com/android/gallery3d/app/AbstractGalleryActivity.java b/src/com/android/gallery3d/app/AbstractGalleryActivity.java index 9b2a85ed4..24d5dbcdf 100644 --- a/src/com/android/gallery3d/app/AbstractGalleryActivity.java +++ b/src/com/android/gallery3d/app/AbstractGalleryActivity.java @@ -16,6 +16,7 @@ package com.android.gallery3d.app; +import android.annotation.TargetApi; import android.app.Activity; import android.app.AlertDialog; import android.content.BroadcastReceiver; @@ -27,11 +28,13 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.res.Configuration; import android.os.Bundle; +import android.view.Menu; import android.view.MenuItem; import android.view.Window; import android.view.WindowManager; import com.android.gallery3d.R; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.data.BitmapPool; import com.android.gallery3d.data.DataManager; import com.android.gallery3d.data.MediaItem; @@ -85,18 +88,42 @@ public class AbstractGalleryActivity extends Activity implements GalleryActivity toggleStatusBarByOrientation(); } + private Menu mOptionsMenu; + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + mOptionsMenu = menu; + super.onCreateOptionsMenu(menu); + return getStateManager().createOptionsMenu(menu); + } + + @Override + @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB) + public void invalidateOptionsMenu() { + if (ApiHelper.HAS_ACTIVITY_INVALIDATE_OPTIONS_MENU) { + super.invalidateOptionsMenu(); + } else if (mOptionsMenu != null) { + mOptionsMenu.clear(); + getStateManager().createOptionsMenu(mOptionsMenu); + } + } + + @Override public Context getAndroidContext() { return this; } + @Override public DataManager getDataManager() { return ((GalleryApp) getApplication()).getDataManager(); } + @Override public ThreadPool getThreadPool() { return ((GalleryApp) getApplication()).getThreadPool(); } + @Override public synchronized StateManager getStateManager() { if (mStateManager == null) { mStateManager = new StateManager(this); @@ -104,10 +131,12 @@ public class AbstractGalleryActivity extends Activity implements GalleryActivity return mStateManager; } + @Override public GLRoot getGLRoot() { return mGLRootView; } + @Override public OrientationManager getOrientationManager() { return mOrientationManager; } diff --git a/src/com/android/gallery3d/app/ActivityState.java b/src/com/android/gallery3d/app/ActivityState.java index 867cda3e5..c870855c9 100644 --- a/src/com/android/gallery3d/app/ActivityState.java +++ b/src/com/android/gallery3d/app/ActivityState.java @@ -27,7 +27,6 @@ import android.os.BatteryManager; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; -import android.view.View; import android.view.Window; import android.view.WindowManager; @@ -135,7 +134,7 @@ abstract public class ActivityState { // should only be called by StateManager void resume() { - Activity activity = (Activity) mActivity; + AbstractGalleryActivity activity = (AbstractGalleryActivity) mActivity; ActionBar actionBar = activity.getActionBar(); if (actionBar != null) { if ((mFlags & FLAG_HIDE_ACTION_BAR) != 0) { diff --git a/src/com/android/gallery3d/app/Gallery.java b/src/com/android/gallery3d/app/Gallery.java index 468d202d4..0d5770cd5 100644 --- a/src/com/android/gallery3d/app/Gallery.java +++ b/src/com/android/gallery3d/app/Gallery.java @@ -26,7 +26,6 @@ import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.provider.OpenableColumns; -import android.view.Menu; import android.view.Window; import android.widget.Toast; @@ -37,7 +36,6 @@ import com.android.gallery3d.data.MediaItem; import com.android.gallery3d.data.MediaSet; import com.android.gallery3d.data.Path; import com.android.gallery3d.picasasource.PicasaSource; -import com.android.gallery3d.ui.GLRoot; import com.android.gallery3d.util.GalleryUtils; public final class Gallery extends AbstractGalleryActivity implements OnCancelListener { @@ -231,12 +229,6 @@ public final class Gallery extends AbstractGalleryActivity implements OnCancelLi } } - @Override - public boolean onCreateOptionsMenu(Menu menu) { - super.onCreateOptionsMenu(menu); - return getStateManager().createOptionsMenu(menu); - } - @Override protected void onResume() { Utils.assertTrue(getStateManager().getStateCount() > 0); -- GitLab From a2cb30b688131380cab763a1b4da25f15a9fa45a Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Wed, 4 Jul 2012 18:20:13 +0800 Subject: [PATCH 067/763] Don't show the shuffle and album widget for old platforms Change-Id: Ide7074025aefe289bf6c71d623eac5100ab72932 --- .../android/gallery3d/common/ApiHelper.java | 3 ++ .../gadget/PhotoAppWidgetProvider.java | 10 ++++-- .../gallery3d/gadget/WidgetConfigure.java | 31 +++++++++++++------ .../gallery3d/gadget/WidgetService.java | 3 ++ 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java index 305fb2cf3..06518108b 100644 --- a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java +++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java @@ -64,6 +64,9 @@ public class ApiHelper { public static final boolean HAS_ACTIVITY_INVALIDATE_OPTIONS_MENU = hasMethod(Activity.class, "invalidateOptionsMenu"); + public static final boolean HAS_REMOTE_VIEWS_SERVICE = + Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB; + private static boolean hasField(Class klass, String fieldName) { try { klass.getDeclaredField(fieldName); diff --git a/src/com/android/gallery3d/gadget/PhotoAppWidgetProvider.java b/src/com/android/gallery3d/gadget/PhotoAppWidgetProvider.java index 98139026e..58466bf01 100644 --- a/src/com/android/gallery3d/gadget/PhotoAppWidgetProvider.java +++ b/src/com/android/gallery3d/gadget/PhotoAppWidgetProvider.java @@ -16,6 +16,7 @@ package com.android.gallery3d.gadget; +import android.annotation.TargetApi; import android.app.PendingIntent; import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProvider; @@ -28,6 +29,7 @@ import android.util.Log; import android.widget.RemoteViews; import com.android.gallery3d.R; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.gadget.WidgetDatabaseHelper.Entry; import com.android.gallery3d.onetimeinitializer.GalleryWidgetMigrator; @@ -50,8 +52,11 @@ public class PhotoAppWidgetProvider extends AppWidgetProvider { @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { - // migrate gallery widgets from pre-JB releases to JB due to bucket ID change - GalleryWidgetMigrator.migrateGalleryWidgets(context); + + if (ApiHelper.HAS_REMOTE_VIEWS_SERVICE) { + // migrate gallery widgets from pre-JB releases to JB due to bucket ID change + GalleryWidgetMigrator.migrateGalleryWidgets(context); + } WidgetDatabaseHelper helper = new WidgetDatabaseHelper(context); try { @@ -71,6 +76,7 @@ public class PhotoAppWidgetProvider extends AppWidgetProvider { } @SuppressWarnings("deprecation") + @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB) private static RemoteViews buildStackWidget(Context context, int widgetId, Entry entry) { RemoteViews views = new RemoteViews( context.getPackageName(), R.layout.appwidget_main); diff --git a/src/com/android/gallery3d/gadget/WidgetConfigure.java b/src/com/android/gallery3d/gadget/WidgetConfigure.java index 5717657c2..331e7d2c4 100644 --- a/src/com/android/gallery3d/gadget/WidgetConfigure.java +++ b/src/com/android/gallery3d/gadget/WidgetConfigure.java @@ -29,12 +29,14 @@ import com.android.gallery3d.R; import com.android.gallery3d.app.AlbumPicker; import com.android.gallery3d.app.CropImage; import com.android.gallery3d.app.DialogPicker; +import com.android.gallery3d.common.ApiHelper; public class WidgetConfigure extends Activity { @SuppressWarnings("unused") private static final String TAG = "WidgetConfigure"; public static final String KEY_WIDGET_TYPE = "widget-type"; + private static final String KEY_PICKED_ITEM = "picked-item"; private static final int REQUEST_WIDGET_TYPE = 1; private static final int REQUEST_CHOOSE_ALBUM = 2; @@ -51,12 +53,11 @@ public class WidgetConfigure extends Activity { private static int MAX_WIDGET_SIDE = 360; private int mAppWidgetId = -1; - private int mWidgetType = 0; private Uri mPickedItem; @Override - protected void onCreate(Bundle bundle) { - super.onCreate(bundle); + protected void onCreate(Bundle savedState) { + super.onCreate(savedState); mAppWidgetId = getIntent().getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1); if (mAppWidgetId == -1) { @@ -65,12 +66,24 @@ public class WidgetConfigure extends Activity { return; } - if (mWidgetType == 0) { - Intent intent = new Intent(this, WidgetTypeChooser.class); - startActivityForResult(intent, REQUEST_WIDGET_TYPE); + if (savedState == null) { + if (ApiHelper.HAS_REMOTE_VIEWS_SERVICE) { + Intent intent = new Intent(this, WidgetTypeChooser.class); + startActivityForResult(intent, REQUEST_WIDGET_TYPE); + } else { // Choose the photo type widget + setWidgetType(new Intent() + .putExtra(KEY_WIDGET_TYPE, R.id.widget_type_photo)); + } + } else { + mPickedItem = savedState.getParcelable(KEY_PICKED_ITEM); } } + protected void onSaveInstanceStates(Bundle outState) { + super.onSaveInstanceState(outState); + outState.putParcelable(KEY_PICKED_ITEM, mPickedItem); + } + private void updateWidgetAndFinish(WidgetDatabaseHelper.Entry entry) { AppWidgetManager manager = AppWidgetManager.getInstance(this); RemoteViews views = PhotoAppWidgetProvider.buildWidget(this, mAppWidgetId, entry); @@ -153,11 +166,11 @@ public class WidgetConfigure extends Activity { } private void setWidgetType(Intent data) { - mWidgetType = data.getIntExtra(KEY_WIDGET_TYPE, R.id.widget_type_shuffle); - if (mWidgetType == R.id.widget_type_album) { + int widgetType = data.getIntExtra(KEY_WIDGET_TYPE, R.id.widget_type_shuffle); + if (widgetType == R.id.widget_type_album) { Intent intent = new Intent(this, AlbumPicker.class); startActivityForResult(intent, REQUEST_CHOOSE_ALBUM); - } else if (mWidgetType == R.id.widget_type_shuffle) { + } else if (widgetType == R.id.widget_type_shuffle) { WidgetDatabaseHelper helper = new WidgetDatabaseHelper(this); try { helper.setWidget(mAppWidgetId, WidgetDatabaseHelper.TYPE_SHUFFLE, null); diff --git a/src/com/android/gallery3d/gadget/WidgetService.java b/src/com/android/gallery3d/gadget/WidgetService.java index eba7403c9..83e37a630 100644 --- a/src/com/android/gallery3d/gadget/WidgetService.java +++ b/src/com/android/gallery3d/gadget/WidgetService.java @@ -16,6 +16,7 @@ package com.android.gallery3d.gadget; +import android.annotation.TargetApi; import android.appwidget.AppWidgetManager; import android.content.Intent; import android.graphics.Bitmap; @@ -25,11 +26,13 @@ import android.widget.RemoteViewsService; import com.android.gallery3d.R; import com.android.gallery3d.app.GalleryApp; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.data.ContentListener; import com.android.gallery3d.data.DataManager; import com.android.gallery3d.data.MediaSet; import com.android.gallery3d.data.Path; +@TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB) public class WidgetService extends RemoteViewsService { @SuppressWarnings("unused") -- GitLab From 88097d4175d44c4c08af4e8652df6dff458aeff1 Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Thu, 5 Jul 2012 12:16:40 +0800 Subject: [PATCH 068/763] Use different back algorithm for Gallery's widget after JB. Change-Id: I1c3c6eea4e5794555a36179b295b15d9dba6de74 --- .../gallery3d/gadget/WidgetClickHandler.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/com/android/gallery3d/gadget/WidgetClickHandler.java b/src/com/android/gallery3d/gadget/WidgetClickHandler.java index 35f9bec36..37ee1a651 100644 --- a/src/com/android/gallery3d/gadget/WidgetClickHandler.java +++ b/src/com/android/gallery3d/gadget/WidgetClickHandler.java @@ -16,10 +16,12 @@ package com.android.gallery3d.gadget; +import android.annotation.TargetApi; import android.app.Activity; import android.content.Intent; import android.content.res.AssetFileDescriptor; import android.net.Uri; +import android.os.Build; import android.os.Bundle; import android.util.Log; import android.widget.Toast; @@ -27,6 +29,7 @@ import android.widget.Toast; import com.android.gallery3d.R; import com.android.gallery3d.app.Gallery; import com.android.gallery3d.app.PhotoPage; +import com.android.gallery3d.common.ApiHelper; public class WidgetClickHandler extends Activity { private static final String TAG = "PhotoAppWidgetClickHandler"; @@ -45,20 +48,29 @@ public class WidgetClickHandler extends Activity { } @Override + @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB) protected void onCreate(Bundle savedState) { super.onCreate(savedState); + // The behavior is changed in JB, refer to b/6384492 for more details + boolean tediousBack = Build.VERSION.SDK_INT >= ApiHelper.VERSION_CODES.JELLY_BEAN; Uri uri = getIntent().getData(); Intent intent; if (isValidDataUri(uri)) { intent = new Intent(Intent.ACTION_VIEW, uri); - intent.putExtra(PhotoPage.KEY_TREAT_BACK_AS_UP, true); + if (tediousBack) { + intent.putExtra(PhotoPage.KEY_TREAT_BACK_AS_UP, true); + } } else { Toast.makeText(this, R.string.no_such_item, Toast.LENGTH_LONG).show(); intent = new Intent(this, Gallery.class); } - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | - Intent.FLAG_ACTIVITY_TASK_ON_HOME); + if (tediousBack) { + intent.setFlags( + Intent.FLAG_ACTIVITY_NEW_TASK | + Intent.FLAG_ACTIVITY_CLEAR_TASK | + Intent.FLAG_ACTIVITY_TASK_ON_HOME); + } startActivity(intent); finish(); } -- GitLab From fe9989a9a58d5ef883099ef747625aca0232df35 Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Thu, 5 Jul 2012 17:06:56 +0800 Subject: [PATCH 069/763] Don't test the EXTRA_LOCAL_ONLY before HC. Change-Id: Idebb2aba994e38cf7eead795f1834ff98eaec27d --- .../src/com/android/gallery3d/common/ApiHelper.java | 3 +++ src/com/android/gallery3d/ui/CustomMenu.java | 6 ++---- src/com/android/gallery3d/util/GalleryUtils.java | 9 +++++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java index 06518108b..20098e4b4 100644 --- a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java +++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java @@ -67,6 +67,9 @@ public class ApiHelper { public static final boolean HAS_REMOTE_VIEWS_SERVICE = Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB; + public static final boolean HAS_INTENT_EXTRA_LOCAL_ONLY = + Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB; + private static boolean hasField(Class klass, String fieldName) { try { klass.getDeclaredField(fieldName); diff --git a/src/com/android/gallery3d/ui/CustomMenu.java b/src/com/android/gallery3d/ui/CustomMenu.java index dd8e6abc4..15b3dc2c2 100644 --- a/src/com/android/gallery3d/ui/CustomMenu.java +++ b/src/com/android/gallery3d/ui/CustomMenu.java @@ -25,8 +25,6 @@ import android.widget.Button; import android.widget.PopupMenu; import android.widget.PopupMenu.OnMenuItemClickListener; -import com.android.gallery3d.R; - import java.util.ArrayList; public class CustomMenu implements OnMenuItemClickListener { @@ -46,6 +44,7 @@ public class CustomMenu implements OnMenuItemClickListener { mPopupMenu.getMenuInflater().inflate(menuId, mMenu); mPopupMenu.setOnMenuItemClickListener(listener); mButton.setOnClickListener(new OnClickListener() { + @Override public void onClick(View v) { mPopupMenu.show(); } @@ -61,8 +60,6 @@ public class CustomMenu implements OnMenuItemClickListener { } } - - private Context mContext; private ArrayList mMenus; private OnMenuItemClickListener mListener; @@ -82,6 +79,7 @@ public class CustomMenu implements OnMenuItemClickListener { mListener = listener; } + @Override public boolean onMenuItemClick(MenuItem item) { if (mListener != null) { return mListener.onMenuItemClick(item); diff --git a/src/com/android/gallery3d/util/GalleryUtils.java b/src/com/android/gallery3d/util/GalleryUtils.java index 1291ee9f7..05198f41b 100644 --- a/src/com/android/gallery3d/util/GalleryUtils.java +++ b/src/com/android/gallery3d/util/GalleryUtils.java @@ -16,6 +16,7 @@ package com.android.gallery3d.util; +import android.annotation.TargetApi; import android.content.ActivityNotFoundException; import android.content.ComponentName; import android.content.Context; @@ -35,6 +36,7 @@ import android.view.WindowManager; import com.android.gallery3d.R; import com.android.gallery3d.app.PackagesMonitor; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.data.DataManager; import com.android.gallery3d.data.MediaItem; import com.android.gallery3d.util.ThreadPool.CancelListener; @@ -288,6 +290,7 @@ public class GalleryUtils { return durationValue; } + @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB) public static int determineTypeBits(Context context, Intent intent) { int typeBits = 0; String type = intent.resolveType(context); @@ -304,8 +307,10 @@ public class GalleryUtils { typeBits = DataManager.INCLUDE_ALL; } - if (intent.getBooleanExtra(Intent.EXTRA_LOCAL_ONLY, false)) { - typeBits |= DataManager.INCLUDE_LOCAL_ONLY; + if (ApiHelper.HAS_INTENT_EXTRA_LOCAL_ONLY) { + if (intent.getBooleanExtra(Intent.EXTRA_LOCAL_ONLY, false)) { + typeBits |= DataManager.INCLUDE_LOCAL_ONLY; + } } return typeBits; -- GitLab From b0774a3bfb24d8515fc3ddf152fabf82f0ff67e5 Mon Sep 17 00:00:00 2001 From: Yuli Huang Date: Fri, 6 Jul 2012 15:12:26 +0800 Subject: [PATCH 070/763] Avoid using setSystemUiVisibility in old platforms. bug:6785569 Change-Id: I0a19ab2818b6f34d530c5d65e781d3168533d44f --- gallerycommon/src/com/android/gallery3d/common/ApiHelper.java | 3 +++ src/com/android/gallery3d/ui/GLRootView.java | 2 ++ 2 files changed, 5 insertions(+) diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java index 20098e4b4..b5db3c88e 100644 --- a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java +++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java @@ -70,6 +70,9 @@ public class ApiHelper { public static final boolean HAS_INTENT_EXTRA_LOCAL_ONLY = Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB; + public static final boolean HAS_SET_SYSTEM_UI_VISIBILITY = + hasMethod(View.class, "setSystemUiVisibility", int.class); + private static boolean hasField(Class klass, String fieldName) { try { klass.getDeclaredField(fieldName); diff --git a/src/com/android/gallery3d/ui/GLRootView.java b/src/com/android/gallery3d/ui/GLRootView.java index fe4e19d7b..9fd9473dc 100644 --- a/src/com/android/gallery3d/ui/GLRootView.java +++ b/src/com/android/gallery3d/ui/GLRootView.java @@ -539,6 +539,8 @@ public class GLRootView extends GLSurfaceView @Override @TargetApi(Build.VERSION_CODES.JELLY_BEAN) public void setLightsOutMode(boolean enabled) { + if (!ApiHelper.HAS_SET_SYSTEM_UI_VISIBILITY) return; + int flags = 0; if (enabled) { flags = STATUS_BAR_HIDDEN; -- GitLab From 11c7b82795abf98cad4a041b89e614236cb6254f Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Mon, 9 Jul 2012 10:24:15 -0700 Subject: [PATCH 071/763] Import translations. DO NOT MERGE Change-Id: I1b461a3723c5439fefd54362be20a4a0100be5c8 Auto-generated-cl: translation import --- res/values-bg/strings.xml | 6 ++---- res/values-cs/strings.xml | 6 ++---- res/values-de/strings.xml | 6 ++---- res/values-es-rUS/strings.xml | 6 ++---- res/values-es/strings.xml | 6 ++---- res/values-et/strings.xml | 6 ++---- res/values-fi/strings.xml | 6 ++---- res/values-fr/strings.xml | 6 ++---- res/values-hi/strings.xml | 6 ++---- res/values-hr/strings.xml | 6 ++---- res/values-in/strings.xml | 6 ++---- res/values-ja/strings.xml | 6 ++---- res/values-ko/strings.xml | 6 ++---- res/values-lt/strings.xml | 6 ++---- res/values-lv/strings.xml | 6 ++---- res/values-ms/strings.xml | 6 ++---- res/values-nb/strings.xml | 6 ++---- res/values-nl/strings.xml | 6 ++---- res/values-ro/strings.xml | 6 ++---- res/values-sk/strings.xml | 6 ++---- res/values-sl/strings.xml | 6 ++---- res/values-sr/strings.xml | 6 ++---- res/values-tr/strings.xml | 6 ++---- res/values-vi/strings.xml | 6 ++---- res/values-zh-rCN/strings.xml | 2 +- res/values-zh-rTW/strings.xml | 6 ++---- 26 files changed, 51 insertions(+), 101 deletions(-) diff --git a/res/values-bg/strings.xml b/res/values-bg/strings.xml index 321ab260c..6099834f5 100644 --- a/res/values-bg/strings.xml +++ b/res/values-bg/strings.xml @@ -173,8 +173,6 @@ "Импортирани" "Екранна снимка" "Помощ" - - - - + "Няма хранилище" + "Няма налично външно хранилище" diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml index 04e60859a..83cf1ca9d 100644 --- a/res/values-cs/strings.xml +++ b/res/values-cs/strings.xml @@ -173,8 +173,6 @@ "Importováno" "Snímky obrazovky" "Nápověda" - - - - + "Žádné úložiště" + "Žádné externí úložiště není k dispozici" diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index 1a97bc9db..815bb6ada 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -173,8 +173,6 @@ "Importiert" "Screenshots" "Hilfe" - - - - + "Kein Speicher" + "Kein externer Speicher verfügbar" diff --git a/res/values-es-rUS/strings.xml b/res/values-es-rUS/strings.xml index 86b8f4d41..de0a20d04 100644 --- a/res/values-es-rUS/strings.xml +++ b/res/values-es-rUS/strings.xml @@ -173,8 +173,6 @@ "Importadas" "Capturas de pantalla" "Ayuda" - - - - + "Sin almacenamiento" + "No hay almacenamiento externo disponible." diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index 7d1071b6c..f63112ad0 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -173,8 +173,6 @@ "Importadas" "Capturas de pantalla" "Ayuda" - - - - + "Sin almacenamiento" + "No hay almacenamiento externo disponible." diff --git a/res/values-et/strings.xml b/res/values-et/strings.xml index e0b4c5883..0e917d741 100644 --- a/res/values-et/strings.xml +++ b/res/values-et/strings.xml @@ -173,8 +173,6 @@ "Imporditud" "Ekraanipilt" "Abi" - - - - + "Mäluseade puudub" + "Ükski välismäluseade ei ole saadaval" diff --git a/res/values-fi/strings.xml b/res/values-fi/strings.xml index b46601df7..d1eba0a84 100644 --- a/res/values-fi/strings.xml +++ b/res/values-fi/strings.xml @@ -173,8 +173,6 @@ "Tuonti" "Kuvakaappaus" "Ohje" - - - - + "Ei tallennustilaa" + "Ei ulkoista tallennustilaa" diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index 96c1dc923..686fc0e5d 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -173,8 +173,6 @@ "Importations" "Captures d\'écran" "Aide" - - - - + "Aucune mémoire" + "Aucune mémoire de stockage externe disponible." diff --git a/res/values-hi/strings.xml b/res/values-hi/strings.xml index 813a4f069..ab2505bdf 100644 --- a/res/values-hi/strings.xml +++ b/res/values-hi/strings.xml @@ -173,8 +173,6 @@ "आयातित" "स्क्रीनशॉट" "सहायता" - - - - + "कोई संग्रहण नहीं" + "कोई बाहरी संग्रहण उपलब्ध नहीं है" diff --git a/res/values-hr/strings.xml b/res/values-hr/strings.xml index 14eee83c9..6166a216d 100644 --- a/res/values-hr/strings.xml +++ b/res/values-hr/strings.xml @@ -173,8 +173,6 @@ "Uvezeno" "Snimak zaslona" "Pomoć" - - - - + "Nema pohrane" + "Nema dostupne vanjske pohrane" diff --git a/res/values-in/strings.xml b/res/values-in/strings.xml index c1c4ae664..a0143c540 100644 --- a/res/values-in/strings.xml +++ b/res/values-in/strings.xml @@ -173,8 +173,6 @@ "Diimpor" "Tangkapan Layar" "Bantuan" - - - - + "Tak Ada Penyimpanan" + "Tidak ada penyimpanan eksternal yang tersedia" diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml index 7067372b2..1c68df7f4 100644 --- a/res/values-ja/strings.xml +++ b/res/values-ja/strings.xml @@ -173,8 +173,6 @@ "インポート済み" "スクリーンショット" "ヘルプ" - - - - + "ストレージがありません" + "利用できる外部ストレージがありません" diff --git a/res/values-ko/strings.xml b/res/values-ko/strings.xml index 016a8bcb5..e516726f7 100644 --- a/res/values-ko/strings.xml +++ b/res/values-ko/strings.xml @@ -173,8 +173,6 @@ "가져옴" "스크린샷" "도움말" - - - - + "저장소 없음" + "사용할 수 있는 외부 저장소 없음" diff --git a/res/values-lt/strings.xml b/res/values-lt/strings.xml index 8bc098b0e..1e7b3e3a1 100644 --- a/res/values-lt/strings.xml +++ b/res/values-lt/strings.xml @@ -173,8 +173,6 @@ "Importuota" "Ekrano kopija" "Pagalba" - - - - + "Nėra atmintinės" + "Nepasiekiama jokia išorinė atmintinė" diff --git a/res/values-lv/strings.xml b/res/values-lv/strings.xml index 1a14aa9f5..047b71c08 100644 --- a/res/values-lv/strings.xml +++ b/res/values-lv/strings.xml @@ -173,8 +173,6 @@ "Importētie" "Ekrānuzņēmums" "Palīdzība" - - - - + "Nav atmiņas" + "Nav ārējās atmiņas" diff --git a/res/values-ms/strings.xml b/res/values-ms/strings.xml index df48fd8f5..4dd3f8e35 100644 --- a/res/values-ms/strings.xml +++ b/res/values-ms/strings.xml @@ -173,8 +173,6 @@ "Diimport" "Tangkapan skrin" "Bantuan" - - - - + "Tiada Storan" + "Tiada storan luar tersedia" diff --git a/res/values-nb/strings.xml b/res/values-nb/strings.xml index 25422eda2..adea1f531 100644 --- a/res/values-nb/strings.xml +++ b/res/values-nb/strings.xml @@ -173,8 +173,6 @@ "Importert" "Skjermdump" "Brukerstøtte" - - - - + "Ingen lagring" + "Ekstern lagringsplass ikke tilgjengelig" diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml index 45065802b..0c52e621f 100644 --- a/res/values-nl/strings.xml +++ b/res/values-nl/strings.xml @@ -173,8 +173,6 @@ "Geïmporteerd" "Schermafbeelding" "Help" - - - - + "Geen opslag" + "Geen externe opslag beschikbaar" diff --git a/res/values-ro/strings.xml b/res/values-ro/strings.xml index 423ec82b2..dad99692c 100644 --- a/res/values-ro/strings.xml +++ b/res/values-ro/strings.xml @@ -173,8 +173,6 @@ "Importate" "Captură de ecran" "Ajutor" - - - - + "Nicio stocare" + "Nu este disponibilă nicio stocare externă" diff --git a/res/values-sk/strings.xml b/res/values-sk/strings.xml index 8bf48b042..49efd928c 100644 --- a/res/values-sk/strings.xml +++ b/res/values-sk/strings.xml @@ -173,8 +173,6 @@ "Importované" "Snímka obrazovky" "Pomocník" - - - - + "Žiadny ukladací priestor" + "K dispozícii nie je žiadny externý ukladací priestor" diff --git a/res/values-sl/strings.xml b/res/values-sl/strings.xml index 3917d2cf1..a239e75f5 100644 --- a/res/values-sl/strings.xml +++ b/res/values-sl/strings.xml @@ -173,8 +173,6 @@ "Uvoženo" "Posnetek zaslona" "Pomoč" - - - - + "Ni prostora za shranjevanje" + "Na voljo ni nobena zunanja naprava za shranjevanje" diff --git a/res/values-sr/strings.xml b/res/values-sr/strings.xml index b5bb5f2ba..15198ecd3 100644 --- a/res/values-sr/strings.xml +++ b/res/values-sr/strings.xml @@ -173,8 +173,6 @@ "Увезено" "Снимак екрана" "Помоћ" - - - - + "Нема меморије" + "Спољна меморија није доступна" diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml index 113da0eb6..77039144b 100644 --- a/res/values-tr/strings.xml +++ b/res/values-tr/strings.xml @@ -173,8 +173,6 @@ "İçe aktarıldı" "Ekran görüntüsü" "Yardım" - - - - + "Depolama yok" + "Kullanılabilir harici depolama yok" diff --git a/res/values-vi/strings.xml b/res/values-vi/strings.xml index eb454a031..97d6d26e3 100644 --- a/res/values-vi/strings.xml +++ b/res/values-vi/strings.xml @@ -173,8 +173,6 @@ "Đã nhập" "Ảnh chụp màn hình" "Trợ giúp" - - - - + "Không có bộ nhớ nào" + "Không có bộ nhớ ngoài nào" diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index 0454147fb..b6fd4495c 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -173,6 +173,6 @@ "已导入" "屏幕截图" "帮助" - "没有外部存储设备" + "没有存储设备" "没有可用的外部存储设备" diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml index 2628b6c1c..0161614ff 100644 --- a/res/values-zh-rTW/strings.xml +++ b/res/values-zh-rTW/strings.xml @@ -173,8 +173,6 @@ "匯入" "螢幕擷取畫面" "說明" - - - - + "沒有儲存裝置" + "沒有可用的外部儲存裝置" -- GitLab From e419a8b625761cf153c6bf1e1ca541c93a9a91ed Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Mon, 9 Jul 2012 10:25:49 -0700 Subject: [PATCH 072/763] Import translations. DO NOT MERGE Change-Id: I93d4e9712d9e6dc0fb8035e222982b5fcd0955a5 Auto-generated-cl: translation import --- res/values-bg/strings.xml | 6 ++---- res/values-cs/strings.xml | 6 ++---- res/values-de/strings.xml | 6 ++---- res/values-es-rUS/strings.xml | 6 ++---- res/values-es/strings.xml | 6 ++---- res/values-et/strings.xml | 6 ++---- res/values-fi/strings.xml | 6 ++---- res/values-fr/strings.xml | 6 ++---- res/values-hi/strings.xml | 6 ++---- res/values-hr/strings.xml | 6 ++---- res/values-in/strings.xml | 6 ++---- res/values-ja/strings.xml | 6 ++---- res/values-ko/strings.xml | 6 ++---- res/values-lt/strings.xml | 6 ++---- res/values-lv/strings.xml | 6 ++---- res/values-ms/strings.xml | 6 ++---- res/values-nb/strings.xml | 6 ++---- res/values-nl/strings.xml | 6 ++---- res/values-ro/strings.xml | 6 ++---- res/values-sk/strings.xml | 6 ++---- res/values-sl/strings.xml | 6 ++---- res/values-sr/strings.xml | 6 ++---- res/values-tr/strings.xml | 6 ++---- res/values-vi/strings.xml | 6 ++---- res/values-zh-rCN/strings.xml | 2 +- res/values-zh-rTW/strings.xml | 6 ++---- 26 files changed, 51 insertions(+), 101 deletions(-) diff --git a/res/values-bg/strings.xml b/res/values-bg/strings.xml index 321ab260c..6099834f5 100644 --- a/res/values-bg/strings.xml +++ b/res/values-bg/strings.xml @@ -173,8 +173,6 @@ "Импортирани" "Екранна снимка" "Помощ" - - - - + "Няма хранилище" + "Няма налично външно хранилище" diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml index 04e60859a..83cf1ca9d 100644 --- a/res/values-cs/strings.xml +++ b/res/values-cs/strings.xml @@ -173,8 +173,6 @@ "Importováno" "Snímky obrazovky" "Nápověda" - - - - + "Žádné úložiště" + "Žádné externí úložiště není k dispozici" diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index 1a97bc9db..815bb6ada 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -173,8 +173,6 @@ "Importiert" "Screenshots" "Hilfe" - - - - + "Kein Speicher" + "Kein externer Speicher verfügbar" diff --git a/res/values-es-rUS/strings.xml b/res/values-es-rUS/strings.xml index 86b8f4d41..de0a20d04 100644 --- a/res/values-es-rUS/strings.xml +++ b/res/values-es-rUS/strings.xml @@ -173,8 +173,6 @@ "Importadas" "Capturas de pantalla" "Ayuda" - - - - + "Sin almacenamiento" + "No hay almacenamiento externo disponible." diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index 7d1071b6c..f63112ad0 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -173,8 +173,6 @@ "Importadas" "Capturas de pantalla" "Ayuda" - - - - + "Sin almacenamiento" + "No hay almacenamiento externo disponible." diff --git a/res/values-et/strings.xml b/res/values-et/strings.xml index e0b4c5883..0e917d741 100644 --- a/res/values-et/strings.xml +++ b/res/values-et/strings.xml @@ -173,8 +173,6 @@ "Imporditud" "Ekraanipilt" "Abi" - - - - + "Mäluseade puudub" + "Ükski välismäluseade ei ole saadaval" diff --git a/res/values-fi/strings.xml b/res/values-fi/strings.xml index b46601df7..d1eba0a84 100644 --- a/res/values-fi/strings.xml +++ b/res/values-fi/strings.xml @@ -173,8 +173,6 @@ "Tuonti" "Kuvakaappaus" "Ohje" - - - - + "Ei tallennustilaa" + "Ei ulkoista tallennustilaa" diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index 96c1dc923..686fc0e5d 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -173,8 +173,6 @@ "Importations" "Captures d\'écran" "Aide" - - - - + "Aucune mémoire" + "Aucune mémoire de stockage externe disponible." diff --git a/res/values-hi/strings.xml b/res/values-hi/strings.xml index 813a4f069..ab2505bdf 100644 --- a/res/values-hi/strings.xml +++ b/res/values-hi/strings.xml @@ -173,8 +173,6 @@ "आयातित" "स्क्रीनशॉट" "सहायता" - - - - + "कोई संग्रहण नहीं" + "कोई बाहरी संग्रहण उपलब्ध नहीं है" diff --git a/res/values-hr/strings.xml b/res/values-hr/strings.xml index 14eee83c9..6166a216d 100644 --- a/res/values-hr/strings.xml +++ b/res/values-hr/strings.xml @@ -173,8 +173,6 @@ "Uvezeno" "Snimak zaslona" "Pomoć" - - - - + "Nema pohrane" + "Nema dostupne vanjske pohrane" diff --git a/res/values-in/strings.xml b/res/values-in/strings.xml index c1c4ae664..a0143c540 100644 --- a/res/values-in/strings.xml +++ b/res/values-in/strings.xml @@ -173,8 +173,6 @@ "Diimpor" "Tangkapan Layar" "Bantuan" - - - - + "Tak Ada Penyimpanan" + "Tidak ada penyimpanan eksternal yang tersedia" diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml index 7067372b2..1c68df7f4 100644 --- a/res/values-ja/strings.xml +++ b/res/values-ja/strings.xml @@ -173,8 +173,6 @@ "インポート済み" "スクリーンショット" "ヘルプ" - - - - + "ストレージがありません" + "利用できる外部ストレージがありません" diff --git a/res/values-ko/strings.xml b/res/values-ko/strings.xml index 016a8bcb5..e516726f7 100644 --- a/res/values-ko/strings.xml +++ b/res/values-ko/strings.xml @@ -173,8 +173,6 @@ "가져옴" "스크린샷" "도움말" - - - - + "저장소 없음" + "사용할 수 있는 외부 저장소 없음" diff --git a/res/values-lt/strings.xml b/res/values-lt/strings.xml index 8bc098b0e..1e7b3e3a1 100644 --- a/res/values-lt/strings.xml +++ b/res/values-lt/strings.xml @@ -173,8 +173,6 @@ "Importuota" "Ekrano kopija" "Pagalba" - - - - + "Nėra atmintinės" + "Nepasiekiama jokia išorinė atmintinė" diff --git a/res/values-lv/strings.xml b/res/values-lv/strings.xml index 1a14aa9f5..047b71c08 100644 --- a/res/values-lv/strings.xml +++ b/res/values-lv/strings.xml @@ -173,8 +173,6 @@ "Importētie" "Ekrānuzņēmums" "Palīdzība" - - - - + "Nav atmiņas" + "Nav ārējās atmiņas" diff --git a/res/values-ms/strings.xml b/res/values-ms/strings.xml index df48fd8f5..4dd3f8e35 100644 --- a/res/values-ms/strings.xml +++ b/res/values-ms/strings.xml @@ -173,8 +173,6 @@ "Diimport" "Tangkapan skrin" "Bantuan" - - - - + "Tiada Storan" + "Tiada storan luar tersedia" diff --git a/res/values-nb/strings.xml b/res/values-nb/strings.xml index 25422eda2..adea1f531 100644 --- a/res/values-nb/strings.xml +++ b/res/values-nb/strings.xml @@ -173,8 +173,6 @@ "Importert" "Skjermdump" "Brukerstøtte" - - - - + "Ingen lagring" + "Ekstern lagringsplass ikke tilgjengelig" diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml index 45065802b..0c52e621f 100644 --- a/res/values-nl/strings.xml +++ b/res/values-nl/strings.xml @@ -173,8 +173,6 @@ "Geïmporteerd" "Schermafbeelding" "Help" - - - - + "Geen opslag" + "Geen externe opslag beschikbaar" diff --git a/res/values-ro/strings.xml b/res/values-ro/strings.xml index 423ec82b2..dad99692c 100644 --- a/res/values-ro/strings.xml +++ b/res/values-ro/strings.xml @@ -173,8 +173,6 @@ "Importate" "Captură de ecran" "Ajutor" - - - - + "Nicio stocare" + "Nu este disponibilă nicio stocare externă" diff --git a/res/values-sk/strings.xml b/res/values-sk/strings.xml index 8bf48b042..49efd928c 100644 --- a/res/values-sk/strings.xml +++ b/res/values-sk/strings.xml @@ -173,8 +173,6 @@ "Importované" "Snímka obrazovky" "Pomocník" - - - - + "Žiadny ukladací priestor" + "K dispozícii nie je žiadny externý ukladací priestor" diff --git a/res/values-sl/strings.xml b/res/values-sl/strings.xml index 3917d2cf1..a239e75f5 100644 --- a/res/values-sl/strings.xml +++ b/res/values-sl/strings.xml @@ -173,8 +173,6 @@ "Uvoženo" "Posnetek zaslona" "Pomoč" - - - - + "Ni prostora za shranjevanje" + "Na voljo ni nobena zunanja naprava za shranjevanje" diff --git a/res/values-sr/strings.xml b/res/values-sr/strings.xml index b5bb5f2ba..15198ecd3 100644 --- a/res/values-sr/strings.xml +++ b/res/values-sr/strings.xml @@ -173,8 +173,6 @@ "Увезено" "Снимак екрана" "Помоћ" - - - - + "Нема меморије" + "Спољна меморија није доступна" diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml index 113da0eb6..77039144b 100644 --- a/res/values-tr/strings.xml +++ b/res/values-tr/strings.xml @@ -173,8 +173,6 @@ "İçe aktarıldı" "Ekran görüntüsü" "Yardım" - - - - + "Depolama yok" + "Kullanılabilir harici depolama yok" diff --git a/res/values-vi/strings.xml b/res/values-vi/strings.xml index eb454a031..97d6d26e3 100644 --- a/res/values-vi/strings.xml +++ b/res/values-vi/strings.xml @@ -173,8 +173,6 @@ "Đã nhập" "Ảnh chụp màn hình" "Trợ giúp" - - - - + "Không có bộ nhớ nào" + "Không có bộ nhớ ngoài nào" diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index 0454147fb..b6fd4495c 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -173,6 +173,6 @@ "已导入" "屏幕截图" "帮助" - "没有外部存储设备" + "没有存储设备" "没有可用的外部存储设备" diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml index 2628b6c1c..0161614ff 100644 --- a/res/values-zh-rTW/strings.xml +++ b/res/values-zh-rTW/strings.xml @@ -173,8 +173,6 @@ "匯入" "螢幕擷取畫面" "說明" - - - - + "沒有儲存裝置" + "沒有可用的外部儲存裝置" -- GitLab From 8880e1f41c568ae56326051ff926448c0edaf6f6 Mon Sep 17 00:00:00 2001 From: Hung-ying Tyan Date: Mon, 9 Jul 2012 14:59:51 +0800 Subject: [PATCH 073/763] Add existence check for DevicePolicyManager.getCameraDisabled() Bug: 6706695 Change-Id: Ib8ea8805a4bea862c8407f8c73a6e5ba1e0f49d3 --- .../src/com/android/gallery3d/common/ApiHelper.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java index b5db3c88e..4e61c77c9 100644 --- a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java +++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java @@ -17,6 +17,8 @@ package com.android.gallery3d.common; import android.app.Activity; +import android.app.admin.DevicePolicyManager; +import android.content.ComponentName; import android.os.Build; import android.provider.MediaStore.MediaColumns; import android.view.View; @@ -73,6 +75,9 @@ public class ApiHelper { public static final boolean HAS_SET_SYSTEM_UI_VISIBILITY = hasMethod(View.class, "setSystemUiVisibility", int.class); + public static final boolean HAS_GET_CAMERA_DISABLED = + hasMethod(DevicePolicyManager.class, "getCameraDisabled", ComponentName.class); + private static boolean hasField(Class klass, String fieldName) { try { klass.getDeclaredField(fieldName); -- GitLab From fd0975a26fbbe5b1b8d35b46a6c9b7c5f228fdd2 Mon Sep 17 00:00:00 2001 From: Wu-cheng Li Date: Wed, 4 Jul 2012 16:32:57 +0800 Subject: [PATCH 074/763] Make jni build against NDK. bug:6698708 Change-Id: I913e2f29657abc0af79223ba49148a6080d39ba7 --- jni/Android.mk | 8 ++++++-- jni/jni_egl_fence.cpp | 42 ++++++++++++++++++++++++++++++++++++++---- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/jni/Android.mk b/jni/Android.mk index eedfa0bff..a4fb844bd 100644 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -6,11 +6,15 @@ LOCAL_CFLAGS += -DEGL_EGLEXT_PROTOTYPES LOCAL_SRC_FILES := jni_egl_fence.cpp -LOCAL_SHARED_LIBRARIES := libcutils libEGL +ifeq ($(TARGET_ARCH), arm) + LOCAL_NDK_VERSION := 5 + LOCAL_SDK_VERSION := 9 +endif + +LOCAL_LDFLAGS := -llog -lEGL LOCAL_MODULE_TAGS := optional LOCAL_MODULE := libjni_eglfence include $(BUILD_SHARED_LIBRARY) - diff --git a/jni/jni_egl_fence.cpp b/jni/jni_egl_fence.cpp index 8d557df31..cf15e2f5d 100644 --- a/jni/jni_egl_fence.cpp +++ b/jni/jni_egl_fence.cpp @@ -16,29 +16,63 @@ #include "jni_egl_fence.h" -#include +#include #include #include +#include + +#define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR,"egl_fence",__VA_ARGS__) + +typedef EGLSyncKHR EGLAPIENTRY (*TypeEglCreateSyncKHR)(EGLDisplay dpy, + EGLenum type, const EGLint *attrib_list); +typedef EGLBoolean EGLAPIENTRY (*TypeEglDestroySyncKHR)(EGLDisplay dpy, + EGLSyncKHR sync); +typedef EGLint EGLAPIENTRY (*TypeEglClientWaitSyncKHR)(EGLDisplay dpy, + EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); +static TypeEglCreateSyncKHR FuncEglCreateSyncKHR = NULL; +static TypeEglClientWaitSyncKHR FuncEglClientWaitSyncKHR = NULL; +static TypeEglDestroySyncKHR FuncEglDestroySyncKHR = NULL; +static bool initialized = false; +static bool egl_khr_fence_sync_supported = false; + +bool IsEglKHRFenceSyncSupported() { + if (!initialized) { + EGLDisplay display = eglGetCurrentDisplay(); + const char* eglExtensions = eglQueryString(eglGetCurrentDisplay(), EGL_EXTENSIONS); + if (eglExtensions && strstr(eglExtensions, "EGL_KHR_fence_sync")) { + FuncEglCreateSyncKHR = (TypeEglCreateSyncKHR) eglGetProcAddress("eglCreateSyncKHR"); + FuncEglClientWaitSyncKHR = (TypeEglClientWaitSyncKHR) eglGetProcAddress("eglClientWaitSyncKHR"); + FuncEglDestroySyncKHR = (TypeEglDestroySyncKHR) eglGetProcAddress("eglDestroySyncKHR"); + if (FuncEglCreateSyncKHR != NULL && FuncEglClientWaitSyncKHR != NULL + && FuncEglDestroySyncKHR != NULL) { + egl_khr_fence_sync_supported = true; + } + } + initialized = true; + } + return egl_khr_fence_sync_supported; +} void Java_com_android_gallery3d_photoeditor_FilterStack_nativeEglSetFenceAndWait(JNIEnv* env, jobject thiz) { + if (!IsEglKHRFenceSyncSupported()) return; EGLDisplay display = eglGetCurrentDisplay(); // Create a egl fence and wait for egl to return it. // Additional reference on egl fence sync can be found in: // http://www.khronos.org/registry/vg/extensions/KHR/EGL_KHR_fence_sync.txt - EGLSyncKHR fence = eglCreateSyncKHR(display, EGL_SYNC_FENCE_KHR, NULL); + EGLSyncKHR fence = FuncEglCreateSyncKHR(display, EGL_SYNC_FENCE_KHR, NULL); if (fence == EGL_NO_SYNC_KHR) { return; } - EGLint result = eglClientWaitSyncKHR(display, + EGLint result = FuncEglClientWaitSyncKHR(display, fence, EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, EGL_FOREVER_KHR); if (result == EGL_FALSE) { ALOGE("EGL FENCE: error waiting for fence: %#x", eglGetError()); } - eglDestroySyncKHR(display, fence); + FuncEglDestroySyncKHR(display, fence); } -- GitLab From 4bfc86a3d6ce4df7fa3751ef5e06cf622cae0de2 Mon Sep 17 00:00:00 2001 From: Ahbong Chang Date: Wed, 11 Jul 2012 13:56:46 +0800 Subject: [PATCH 075/763] Add existence check for face detection methods. android.hardware.Camera.setFaceDetectionListener() android.hardware.Camera.startFaceDetection() android.hardware.Camera.stopFaceDetection() android.hardware.Camera.Parameters.getMaxNumDetectedFaces() Bug: 6707152 Change-Id: Ia6b54246273548db44ec28c40f9efe49048ea8d5 --- .../android/gallery3d/common/ApiHelper.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java index 4e61c77c9..fd2488faf 100644 --- a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java +++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java @@ -19,6 +19,8 @@ package com.android.gallery3d.common; import android.app.Activity; import android.app.admin.DevicePolicyManager; import android.content.ComponentName; +import android.hardware.Camera; +import android.hardware.Camera.FaceDetectionListener; import android.os.Build; import android.provider.MediaStore.MediaColumns; import android.view.View; @@ -75,6 +77,13 @@ public class ApiHelper { public static final boolean HAS_SET_SYSTEM_UI_VISIBILITY = hasMethod(View.class, "setSystemUiVisibility", int.class); + public static final boolean HAS_FACE_DETECTION = + hasClass(Camera.class, "android.hardware.Camera$FaceDetectionListener") && + hasMethod(Camera.class, "setFaceDetectionListener", FaceDetectionListener.class) && + hasMethod(Camera.class, "startFaceDetection") && + hasMethod(Camera.class, "stopFaceDetection") && + hasMethod(Camera.Parameters.class, "getMaxNumDetectedFaces"); + public static final boolean HAS_GET_CAMERA_DISABLED = hasMethod(DevicePolicyManager.class, "getCameraDisabled", ComponentName.class); @@ -107,4 +116,15 @@ public class ApiHelper { return false; } } + + private static boolean hasClass(Class klass, String className) { + Class[] klasses = klass.getClasses(); + for (int i = 0; i < klasses.length; ++i) { + if (klasses[i].getName().equals(className)) { + return true; + } + } + return false; + } + } -- GitLab From 1b10bf568327fa6c6c1ddbfd98cb17524bebfd46 Mon Sep 17 00:00:00 2001 From: Angus Kong Date: Fri, 13 Jul 2012 11:54:05 +0800 Subject: [PATCH 076/763] Add the method for hidden fields. bug:6698375 Change-Id: I5feb3fdd680fec0d745bd3176f4676c16484d4ed --- .../com/android/gallery3d/common/ApiHelper.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java index fd2488faf..753cacdf7 100644 --- a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java +++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java @@ -25,6 +25,8 @@ import android.os.Build; import android.provider.MediaStore.MediaColumns; import android.view.View; +import java.lang.reflect.Field; + public class ApiHelper { public static interface VERSION_CODES { // These value are copied from Build.VERSION_CODES @@ -87,6 +89,19 @@ public class ApiHelper { public static final boolean HAS_GET_CAMERA_DISABLED = hasMethod(DevicePolicyManager.class, "getCameraDisabled", ComponentName.class); + public static final boolean HAS_MEDIA_ACTION_SOUND = + Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN; + + public static int getIntFieldIfExists(Class klass, String fieldName, + Class obj, int defaultVal) { + try { + Field f = klass.getDeclaredField(fieldName); + return f.getInt(obj); + } catch (Exception e) { + return defaultVal; + } + } + private static boolean hasField(Class klass, String fieldName) { try { klass.getDeclaredField(fieldName); -- GitLab From 840ae396bac4ff8ff34e88c8d2a1773cb112a4b6 Mon Sep 17 00:00:00 2001 From: Chih-Chung Chang Date: Fri, 13 Jul 2012 14:57:26 +0800 Subject: [PATCH 077/763] Only use SurfaceTexture.release and setIconAttribute on newer platforms. Bug: 6706784 Change-Id: Ic1bb2bb27c3184d791de566d88dbade039fb9d87 --- .../android/gallery3d/common/ApiHelper.java | 6 ++++++ .../gallery3d/app/AbstractGalleryActivity.java | 18 ++++++++++++++---- .../gallery3d/ui/SurfaceTextureScreenNail.java | 9 ++++++++- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java index 753cacdf7..620e1ae7a 100644 --- a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java +++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java @@ -61,6 +61,9 @@ public class ApiHelper { "android.graphics.SurfaceTexture", "setDefaultBufferSize", int.class, int.class); + public static final boolean HAS_RELEASE_SURFACE_TEXTURE = hasMethod( + "android.graphics.SurfaceTexture", "release"); + public static final boolean HAS_MTP = Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB_MR1; @@ -102,6 +105,9 @@ public class ApiHelper { } } + public static final boolean HAS_SET_ICON_ATTRIBUTE = + Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB; + private static boolean hasField(Class klass, String fieldName) { try { klass.getDeclaredField(fieldName); diff --git a/src/com/android/gallery3d/app/AbstractGalleryActivity.java b/src/com/android/gallery3d/app/AbstractGalleryActivity.java index 24d5dbcdf..6b0b106aa 100644 --- a/src/com/android/gallery3d/app/AbstractGalleryActivity.java +++ b/src/com/android/gallery3d/app/AbstractGalleryActivity.java @@ -171,17 +171,27 @@ public class AbstractGalleryActivity extends Activity implements GalleryActivity dialog.cancel(); } }; - mAlertDialog = new AlertDialog.Builder(this) - .setIconAttribute(android.R.attr.alertDialogIcon) + AlertDialog.Builder builder = new AlertDialog.Builder(this) .setTitle(R.string.no_external_storage_title) .setMessage(R.string.no_external_storage) .setNegativeButton(android.R.string.cancel, onClick) - .setOnCancelListener(onCancel) - .show(); + .setOnCancelListener(onCancel); + if (ApiHelper.HAS_SET_ICON_ATTRIBUTE) { + setAlertDialogIconAttribute(builder); + } else { + builder.setIcon(android.R.drawable.ic_dialog_alert); + } + mAlertDialog = builder.show(); registerReceiver(mMountReceiver, mMountFilter); } } + @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB) + private static void setAlertDialogIconAttribute( + AlertDialog.Builder builder) { + builder.setIconAttribute(android.R.attr.alertDialogIcon); + } + @Override protected void onStop() { super.onStop(); diff --git a/src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java b/src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java index a04313b8b..dd9b7ce1f 100644 --- a/src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java +++ b/src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java @@ -57,6 +57,13 @@ public abstract class SurfaceTextureScreenNail implements ScreenNail, } } + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) + private static void releaseSurfaceTexture(SurfaceTexture st) { + if (ApiHelper.HAS_RELEASE_SURFACE_TEXTURE) { + st.release(); + } + } + public SurfaceTexture getSurfaceTexture() { return mSurfaceTexture; } @@ -67,7 +74,7 @@ public abstract class SurfaceTextureScreenNail implements ScreenNail, } mExtTexture.recycle(); mExtTexture = null; - mSurfaceTexture.release(); + releaseSurfaceTexture(mSurfaceTexture); mSurfaceTexture = null; } -- GitLab From 0315c71d905803cc361b5815b6595c37305b6425 Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Fri, 13 Jul 2012 10:19:43 -0700 Subject: [PATCH 078/763] Change "current" sdk version to 16 as it becomes official Change-Id: I09c13b99ff1bc368e1fa335f2efc4cba5410d2f5 --- Android.mk | 2 +- gallerycommon/Android.mk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Android.mk b/Android.mk index b0ebf899a..4854a5c5e 100644 --- a/Android.mk +++ b/Android.mk @@ -18,7 +18,7 @@ LOCAL_PACKAGE_NAME := Gallery2 LOCAL_OVERRIDES_PACKAGES := Gallery Gallery3D GalleryNew3D -LOCAL_SDK_VERSION := current +LOCAL_SDK_VERSION := 16 LOCAL_JNI_SHARED_LIBRARIES := libjni_mosaic libjni_eglfence diff --git a/gallerycommon/Android.mk b/gallerycommon/Android.mk index fb81dd950..1d341472c 100644 --- a/gallerycommon/Android.mk +++ b/gallerycommon/Android.mk @@ -22,6 +22,6 @@ include $(CLEAR_VARS) LOCAL_MODULE := com.android.gallery3d.common2 LOCAL_SRC_FILES := $(call all-java-files-under, src) -LOCAL_SDK_VERSION := current +LOCAL_SDK_VERSION := 16 include $(BUILD_STATIC_JAVA_LIBRARY) -- GitLab From 13b5a263afd446548ef00ea991194892d2c65375 Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Fri, 13 Jul 2012 10:27:25 -0700 Subject: [PATCH 079/763] Import translations. DO NOT MERGE Change-Id: Ic33cc9dc568e0acf7d12f5d743801689647ea916 Auto-generated-cl: translation import --- res/values-fa/strings.xml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/res/values-fa/strings.xml b/res/values-fa/strings.xml index 4ed530228..bb21673ce 100644 --- a/res/values-fa/strings.xml +++ b/res/values-fa/strings.xml @@ -20,11 +20,11 @@ "قاب عکس" "%1$02d:%2$02d" "%1$d:%2$02d:%3$02d" - "پخش کننده ویدیو" - "در حال بارگیری ویدیو..." + "پخش کننده ویدئو" + "در حال بارگیری ویدئو..." "در حال بارگیری تصویر …" "بارگیری حساب؟؟؟" - "از سرگیری ویدیو" + "از سرگیری ویدئو" "ادامه پخش از %s ؟" "از سرگیری پخش" "در حال بارگیری…" @@ -39,11 +39,11 @@ "ذخیره تصویر برش‌خورده امکان‌پذیر نیست." "برش تصویر" "انتخاب عکس" - "انتخاب ویدیو" + "انتخاب ویدئو" "انتخاب مورد" "آلبوم را انتخاب کنید" "انتخاب گروه" - "تنظیم تصویر بعنوان" + "تنظیم تصویر به‌عنوان" "تنظیم تصویر زمینه" "تنظیم تصویر زمینه..." "تصویر زمینه" @@ -87,8 +87,8 @@ "پردازش درخواست‌های ذخیره در حافظه پنهان" "در حال ذخیره در حافظه پنهان..." "برش" - "تنظیم بعنوان" - "ویدیو پخش نمی‌شود." + "تنظیم به‌عنوان" + "ویدئو پخش نمی‌شود." "بر اساس محل" "بر اساس زمان" "بر اساس برچسب ها" @@ -100,13 +100,13 @@ "شناسایی برخی از مکان‌ها به دلیل مشکلات شبکه امکان‌پذیر نیست." "عکس‌های این آلبوم را نمی‌توان دانلود کرد. بعداً دوباره امتحان کنید." "فقط تصاویر" - "فقط ویدیوها" - "تصاویر و ویدیوها" + "فقط ویدئوها" + "تصاویر و ویدئوها" "گالری عکس" "عکسی موجود نیست." "تصویر بریده شده در %s ذخیره شد." "آلبومی موجود نیست." - "O تصویر/ویدیو موجود است." + "O تصویر/ویدئو موجود است." "پست‌ها" "در دسترس بودن در هنگام آفلاین" "بازخوانی" @@ -140,7 +140,7 @@ "آلبوم را به صورت آفلاین در دسترس قرار دهید." "آلبوم‌ها را به صورت آفلاین در دسترس قرار دهید." - "این مورد به صورت محلی ذخیره می شود و به طور آفلاین در دسترس است." + "این مورد به صورت محلی ذخیره می‌شود و به طور آفلاین در دسترس است." "همه آلبوم‌ها" "آلبوم‌های محلی" "دستگاه‌های MTP" -- GitLab From 74dcb88ab640a2a5a5ec263ee5dbbacd93e8962a Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Fri, 13 Jul 2012 10:29:34 -0700 Subject: [PATCH 080/763] Import translations. DO NOT MERGE Change-Id: Ied8634473195dea6df909dd08bdb2da16d99788c Auto-generated-cl: translation import --- res/values-fa/strings.xml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/res/values-fa/strings.xml b/res/values-fa/strings.xml index 4ed530228..bb21673ce 100644 --- a/res/values-fa/strings.xml +++ b/res/values-fa/strings.xml @@ -20,11 +20,11 @@ "قاب عکس" "%1$02d:%2$02d" "%1$d:%2$02d:%3$02d" - "پخش کننده ویدیو" - "در حال بارگیری ویدیو..." + "پخش کننده ویدئو" + "در حال بارگیری ویدئو..." "در حال بارگیری تصویر …" "بارگیری حساب؟؟؟" - "از سرگیری ویدیو" + "از سرگیری ویدئو" "ادامه پخش از %s ؟" "از سرگیری پخش" "در حال بارگیری…" @@ -39,11 +39,11 @@ "ذخیره تصویر برش‌خورده امکان‌پذیر نیست." "برش تصویر" "انتخاب عکس" - "انتخاب ویدیو" + "انتخاب ویدئو" "انتخاب مورد" "آلبوم را انتخاب کنید" "انتخاب گروه" - "تنظیم تصویر بعنوان" + "تنظیم تصویر به‌عنوان" "تنظیم تصویر زمینه" "تنظیم تصویر زمینه..." "تصویر زمینه" @@ -87,8 +87,8 @@ "پردازش درخواست‌های ذخیره در حافظه پنهان" "در حال ذخیره در حافظه پنهان..." "برش" - "تنظیم بعنوان" - "ویدیو پخش نمی‌شود." + "تنظیم به‌عنوان" + "ویدئو پخش نمی‌شود." "بر اساس محل" "بر اساس زمان" "بر اساس برچسب ها" @@ -100,13 +100,13 @@ "شناسایی برخی از مکان‌ها به دلیل مشکلات شبکه امکان‌پذیر نیست." "عکس‌های این آلبوم را نمی‌توان دانلود کرد. بعداً دوباره امتحان کنید." "فقط تصاویر" - "فقط ویدیوها" - "تصاویر و ویدیوها" + "فقط ویدئوها" + "تصاویر و ویدئوها" "گالری عکس" "عکسی موجود نیست." "تصویر بریده شده در %s ذخیره شد." "آلبومی موجود نیست." - "O تصویر/ویدیو موجود است." + "O تصویر/ویدئو موجود است." "پست‌ها" "در دسترس بودن در هنگام آفلاین" "بازخوانی" @@ -140,7 +140,7 @@ "آلبوم را به صورت آفلاین در دسترس قرار دهید." "آلبوم‌ها را به صورت آفلاین در دسترس قرار دهید." - "این مورد به صورت محلی ذخیره می شود و به طور آفلاین در دسترس است." + "این مورد به صورت محلی ذخیره می‌شود و به طور آفلاین در دسترس است." "همه آلبوم‌ها" "آلبوم‌های محلی" "دستگاه‌های MTP" -- GitLab From 602c7321d728f8332d057182b6ac223b2c4b4716 Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Mon, 16 Jul 2012 10:10:33 -0700 Subject: [PATCH 081/763] Import translations. DO NOT MERGE Change-Id: I3252729107c7525ca5d208ba106a10a0e9917661 Auto-generated-cl: translation import --- res/values-fa/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/res/values-fa/strings.xml b/res/values-fa/strings.xml index bb21673ce..e9f0463b1 100644 --- a/res/values-fa/strings.xml +++ b/res/values-fa/strings.xml @@ -32,7 +32,7 @@ "تصویر بارگیری نمی‌شود" "تصویر کوچکی وجود ندارد" "شروع مجدد" - "تائید" + "تأیید" "تأیید" "برای شروع یک چهره را لمس کنید." "در حال ذخیره عکس..." @@ -91,7 +91,7 @@ "ویدئو پخش نمی‌شود." "بر اساس محل" "بر اساس زمان" - "بر اساس برچسب ها" + "بر اساس برچسب‌ها" "براساس افراد" "بر اساس آلبوم" "بر اساس اندازه" -- GitLab From 191a5e933d8c9fb4ea34e635ff7d98281586a216 Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Mon, 16 Jul 2012 10:11:05 -0700 Subject: [PATCH 082/763] Import translations. DO NOT MERGE Change-Id: Ib588a4ce4dc897fbf676781e9a08ac5718b543aa Auto-generated-cl: translation import --- res/values-fa/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/res/values-fa/strings.xml b/res/values-fa/strings.xml index bb21673ce..e9f0463b1 100644 --- a/res/values-fa/strings.xml +++ b/res/values-fa/strings.xml @@ -32,7 +32,7 @@ "تصویر بارگیری نمی‌شود" "تصویر کوچکی وجود ندارد" "شروع مجدد" - "تائید" + "تأیید" "تأیید" "برای شروع یک چهره را لمس کنید." "در حال ذخیره عکس..." @@ -91,7 +91,7 @@ "ویدئو پخش نمی‌شود." "بر اساس محل" "بر اساس زمان" - "بر اساس برچسب ها" + "بر اساس برچسب‌ها" "براساس افراد" "بر اساس آلبوم" "بر اساس اندازه" -- GitLab From b60dec6d1ca85a1287aeb80855fae0c0a9aeaade Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Mon, 16 Jul 2012 11:10:27 -0700 Subject: [PATCH 083/763] Import translations. DO NOT MERGE Change-Id: I9f824e4ef25030fa326c33bf2e29a75a8b588e39 Auto-generated-cl: translation import --- res/values-fa/photoeditor_strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values-fa/photoeditor_strings.xml b/res/values-fa/photoeditor_strings.xml index 177c6465b..2c11145a0 100644 --- a/res/values-fa/photoeditor_strings.xml +++ b/res/values-fa/photoeditor_strings.xml @@ -36,7 +36,7 @@ "وارونه کردن" "بافت فیلم" "سیاه‌ و سفید" - "قسمت های برجسته" + "قسمت‌های برجسته" "Lomo" "نگاتیو" "پوستری کردن" -- GitLab From 80bacf0bb7db15ea21029b6ce645ec093562aa7d Mon Sep 17 00:00:00 2001 From: Ahbong Chang Date: Tue, 17 Jul 2012 16:58:17 +0800 Subject: [PATCH 084/763] Add checker for panorama supporting. Bug: 6816669 Change-Id: I34f80485d46f04f7adc49e2fd49dea1a08a72af9 --- gallerycommon/src/com/android/gallery3d/common/ApiHelper.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java index 620e1ae7a..8ebdc1808 100644 --- a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java +++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java @@ -95,6 +95,9 @@ public class ApiHelper { public static final boolean HAS_MEDIA_ACTION_SOUND = Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN; + public static final boolean HAS_PANORAMA = + Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB; + public static int getIntFieldIfExists(Class klass, String fieldName, Class obj, int defaultVal) { try { -- GitLab From 44ef42f215d68ade8b63d18fede944c244a2a1dd Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Wed, 11 Jul 2012 11:20:00 +0800 Subject: [PATCH 085/763] Make CustomMenu compatible with API level 10. bug: 6802855 Change-Id: I230c91bd9744935a181881131dcd2275ed89d819 --- .../menu_dropdown_panel_holo_dark.9.png | Bin 0 -> 922 bytes .../menu_dropdown_panel_holo_dark.9.png | Bin 0 -> 651 bytes .../menu_dropdown_panel_holo_dark.9.png | Bin 0 -> 1362 bytes .../popup_list_item.xml} | 17 +- res/values/ids.xml | 1 + .../gallery3d/ui/ActionModeHandler.java | 50 ++--- src/com/android/gallery3d/ui/CustomMenu.java | 89 --------- src/com/android/gallery3d/ui/PopupList.java | 188 ++++++++++++++++++ .../android/gallery3d/ui/SelectionMenu.java | 61 ++++++ 9 files changed, 285 insertions(+), 121 deletions(-) create mode 100644 res/drawable-hdpi/menu_dropdown_panel_holo_dark.9.png create mode 100644 res/drawable-mdpi/menu_dropdown_panel_holo_dark.9.png create mode 100644 res/drawable-xhdpi/menu_dropdown_panel_holo_dark.9.png rename res/{menu/selection.xml => layout/popup_list_item.xml} (54%) delete mode 100644 src/com/android/gallery3d/ui/CustomMenu.java create mode 100644 src/com/android/gallery3d/ui/PopupList.java create mode 100644 src/com/android/gallery3d/ui/SelectionMenu.java diff --git a/res/drawable-hdpi/menu_dropdown_panel_holo_dark.9.png b/res/drawable-hdpi/menu_dropdown_panel_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..4d3d208578c61662986fdc16bd15c69759b48d6a GIT binary patch literal 922 zcmV;L17-Y)P)!ytdud6iMT7O&4bD*mP3eKws)UN7D2k#e z%DbYt@4NEYnkjlINEK7=*RV3zwml#Px9r!q%}Y$QM*NqHEZ-wscn^ zf4p9=Kg#ZZAKY%YZvc!aCbL}F6eGxtBSzy=smEUmc6C{?q1YCQrid~5o$!73+BeU$Ee{DI^Yo4#-o87 zao*xiE9Z<+s}ttlWw19HGlEA1nW09+*~|#}a;CkeJh%bU1g9CP5h0^O2}4Hs%y=Lc z5q!OY8j*^uk~rBBK?ljmh#jL84Ev;rDo>_H#K|6e%Mo=CgLzw$rI$Y4Z-kUy6U47Z zMI2w^tmuV~pH%tJq!^(yWY-hbFl2;G2g)+VPqud2Sicc+jL>MvBTKK;HbN#jlrS<8 zl+;FqdPULzJ~Kh_!?j8>!xs^*nQAm$#290~ue;BBnY1w&wMw4#m(pwEDZd_oY1{Ux z>$>N)H(eWD*FCpw`-IsDKF28-6~1bz!JGs-W6Z&R1n>#KR{&q8us99Q}8ID#(NJr3oa@N-D4Rc$qhA--bT2} z_Wpf@Z`4749}#V+fwWJz^oyZKO1~J&exY-1*Kg?D$hu!fixvAiNfpmG;mo&f5BSEA wlE;@gYed_N;JFm#Y)Zw{1W}kQU9GkF3xsHEK4Myn7XSbN07*qoM6N<$g18=|djJ3c literal 0 HcmV?d00001 diff --git a/res/drawable-mdpi/menu_dropdown_panel_holo_dark.9.png b/res/drawable-mdpi/menu_dropdown_panel_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..460ec46eb0786706610e21ac9097de489cedfc33 GIT binary patch literal 651 zcmV;60(AX}P)!1&^00004b3#c}2nYxW zdZ_-Wf*5)VugS&t+23J}V*z%DOHb#W|`Z#l>;cJ*L_P;jGoKD8nX4Z`xH*Q>s zTvTl`b;%gqS1znaOc|u@tz3t7=|UK<9Hr>BJ|D1%4AOYzE>c>YASL1(e+Y^`_iG?7 z1UL~EK(|`0e*W#*UXt~C{TfUweyI5sSBLVgO?u)p&e9+4(C=i^T1GuQJ|j^LdEE0 zfZFjzm@Nd117_`XxKDqSoJXh_wG-}tW_yHE!!B|TSvyio<6k9eTgoG9O0aTdZJ81x zmbul8Z%fpkT#Wc{ND1L@No&VX#iPVF7hx`c0JdkE;3e2%ZBQYi%Oe#dj=&z+_I>|? zOJi$dCv)FoZJG3n&>Qp|;vSo*JOkf=A5uR{`;uV-QwsX>Ho!a31HXV*se5TxFFA=4 zo=3!%#5;D2+DO|6R;c8b^-B2j{s4XhZw!t1m&l3O!HmBwHn=!)kb6yF?kI1MVX*Vu z<6hz)DH{^YBPWDzO$|0isCW3@P>L98oO;C$E5=4jGEPjLS?XZ=13IvJLaC?O;nLn? z=e?6_T^b`&$N3sK+o1N3^-DyB&=+_N>geY)_rHdJwBJ%s{^4(_WBZ5MLQM53U4RfX laXn(LVYMe-Njr@(d;;;gyUim^Wn%yU002ovPDHLkV1m`SB-{W1 literal 0 HcmV?d00001 diff --git a/res/drawable-xhdpi/menu_dropdown_panel_holo_dark.9.png b/res/drawable-xhdpi/menu_dropdown_panel_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..e2aff72f483ce4cc6ccddf17331249fa612d2a83 GIT binary patch literal 1362 zcmV-Y1+DstP)?8OR-p?Vt(<)KXNk*dJ1<_`!jRpab6RMK;Rk47fDU#NEX#7yk4(~&Fr}L7DZp)K} zK)DDZgb+dqA%qY@2q7)3S*px^wsY!a9l?~jW2$HoDfOAoDc4?$q=mJH$Q@HesW|pH zEqI5t5pt#=^`ykNb$bDA+g_!6r>E#0Ebxb)V~E)@66{HSu%o+0#^7QK=<56_<*0g z4?VWXMFRkJB8s~XX6q}?LEeWW=Ef--P!X+fp` zQ#hbt=1@CWv@?Vrj0n$wG-wfB>s2&!$QdDJ0ulZgw-cuRiR{Y>^Hj3K6cvDZyr8vA z8lxp5*y$r9!v6G_XAF7`2PhmT)XW;J_(x39;8bKfgMu`e! zU+jWXwIOOF0-q>8C*JQsY~7_bBCuA z|Ap1-2&vJi9g(t&*dI@qVtrbEm_q)8uxlUymW^N&DQrSTF2REQdw9B(B*Fk-L?96w zfdFVX0=tCgq*<4>5rKwy4p!?>V+1b~mqyqhPm^M8N}pNlWK7Aa(;L|rtB1{dT%;u; z=)dm(?jeLfE6zhUB!2hW01y9MdY)1v=ujhBx3b+Xm&>Pd9KV)clx)K|j$bdA%O^}( zPFj=H`w_B~E-2}`eIdjBd_I2}hT(GvVW{|jkQIawhG7^!pU>wnc#H_%SRreOrJP6k z#f!~#`~_1^!^gPqw^)9R`+vop3DslHn(o!PiI0dTt@|45Za=)m1`%IwEW{fV$LVaF zE9RVsAMaWMjZlg;f(R_4iy{7r`=s=`3SdP<&^M)TPHqgUw5?z25;3$902*NlyMU*S zpa+j$RH$BIEX`7~H`b|A%pl=Pj|o!QHv-L&MvImjnCmfv9y@5Gq|A_|G$L4MNvqdg zg%(@J38}FG4N!(%uhEggMhM*%9HY#I^l zO-Wr$p$z~$ref=30GgqO)XJdORd}!BEq>NeB8p9{v^kJo2|NxCQwf^HCpGf6X;Wp4 zg!hgmb$FtdtQ>ASMriqL^@|$FBEhNWjw@zMktp~+Gzo9nO1w>OhBUKE#}ER(1L)vD UI+1b(O8@`>07*qoM6N<$f~tseq5uE@ literal 0 HcmV?d00001 diff --git a/res/menu/selection.xml b/res/layout/popup_list_item.xml similarity index 54% rename from res/menu/selection.xml rename to res/layout/popup_list_item.xml index 18839e4d2..4dbc610d9 100644 --- a/res/menu/selection.xml +++ b/res/layout/popup_list_item.xml @@ -1,5 +1,5 @@ - - - - + + diff --git a/res/values/ids.xml b/res/values/ids.xml index b6fda4771..7babba067 100644 --- a/res/values/ids.xml +++ b/res/values/ids.xml @@ -18,4 +18,5 @@ --> + diff --git a/src/com/android/gallery3d/ui/ActionModeHandler.java b/src/com/android/gallery3d/ui/ActionModeHandler.java index 190b2b8c6..80d2500d4 100644 --- a/src/com/android/gallery3d/ui/ActionModeHandler.java +++ b/src/com/android/gallery3d/ui/ActionModeHandler.java @@ -22,7 +22,6 @@ import android.content.Context; import android.content.Intent; import android.net.Uri; import android.nfc.NfcAdapter; -import android.os.Build; import android.os.Handler; import android.view.ActionMode; import android.view.LayoutInflater; @@ -31,7 +30,6 @@ import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.widget.Button; -import android.widget.PopupMenu.OnMenuItemClickListener; import android.widget.ShareActionProvider; import android.widget.ShareActionProvider.OnShareTargetSelectedListener; @@ -43,7 +41,6 @@ import com.android.gallery3d.common.Utils; import com.android.gallery3d.data.DataManager; import com.android.gallery3d.data.MediaObject; import com.android.gallery3d.data.Path; -import com.android.gallery3d.ui.CustomMenu.DropDownMenu; import com.android.gallery3d.ui.MenuExecutor.ProgressListener; import com.android.gallery3d.util.Future; import com.android.gallery3d.util.GalleryUtils; @@ -52,7 +49,8 @@ import com.android.gallery3d.util.ThreadPool.JobContext; import java.util.ArrayList; -public class ActionModeHandler implements ActionMode.Callback { +public class ActionModeHandler implements + ActionMode.Callback, PopupList.OnPopupItemClickListener { private static final String TAG = "ActionModeHandler"; private static final int SUPPORT_MULTIPLE_MASK = MediaObject.SUPPORT_DELETE | MediaObject.SUPPORT_ROTATE | MediaObject.SUPPORT_SHARE @@ -67,7 +65,7 @@ public class ActionModeHandler implements ActionMode.Callback { private final SelectionManager mSelectionManager; private final NfcAdapter mNfcAdapter; private Menu mMenu; - private DropDownMenu mSelectionMenu; + private SelectionMenu mSelectionMenu; private ActionModeListener mListener; private Future mMenuTask; private final Handler mMainHandler; @@ -85,20 +83,13 @@ public class ActionModeHandler implements ActionMode.Callback { public ActionMode startActionMode() { Activity a = (Activity) mActivity; final ActionMode actionMode = a.startActionMode(this); - CustomMenu customMenu = new CustomMenu(a); View customView = LayoutInflater.from(a).inflate( R.layout.action_mode, null); actionMode.setCustomView(customView); - mSelectionMenu = customMenu.addDropDownMenu( - (Button) customView.findViewById(R.id.selection_menu), - R.menu.selection); + mSelectionMenu = new SelectionMenu(a, + (Button) customView.findViewById(R.id.selection_menu), this); updateSelectionMenu(); - customMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() { - @Override - public boolean onMenuItemClick(MenuItem item) { - return onActionItemClicked(actionMode, item); - } - }); + return actionMode; } @@ -137,14 +128,25 @@ public class ActionModeHandler implements ActionMode.Callback { R.plurals.delete_selection, mSelectionManager.getSelectedCount()); } mMenuExecutor.onMenuClicked(item, confirmMsg, listener); - if (action == R.id.action_select_all) { + } finally { + root.unlockRenderThread(); + } + return true; + } + + @Override + public boolean onPopupItemClick(int itemId) { + GLRoot root = mActivity.getGLRoot(); + root.lockRenderThread(); + try { + if (itemId == R.id.action_select_all) { updateSupportedOperation(); - updateSelectionMenu(); + mMenuExecutor.onMenuClicked(itemId, null, false, true); } + return true; } finally { root.unlockRenderThread(); } - return true; } private void updateSelectionMenu() { @@ -153,18 +155,10 @@ public class ActionModeHandler implements ActionMode.Callback { String format = mActivity.getResources().getQuantityString( R.plurals.number_of_items_selected, count); setTitle(String.format(format, count)); + // For clients who call SelectionManager.selectAll() directly, we need to ensure the // menu status is consistent with selection manager. - MenuItem item = mSelectionMenu.findItem(R.id.action_select_all); - if (item != null) { - if (mSelectionManager.inSelectAllMode()) { - item.setChecked(true); - item.setTitle(R.string.deselect_all); - } else { - item.setChecked(false); - item.setTitle(R.string.select_all); - } - } + mSelectionMenu.updateSelectAllMode(mSelectionManager.inSelectAllMode()); } public boolean onCreateActionMode(ActionMode mode, Menu menu) { diff --git a/src/com/android/gallery3d/ui/CustomMenu.java b/src/com/android/gallery3d/ui/CustomMenu.java deleted file mode 100644 index 15b3dc2c2..000000000 --- a/src/com/android/gallery3d/ui/CustomMenu.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2010 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.android.gallery3d.ui; - -import android.content.Context; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.view.View.OnClickListener; -import android.widget.Button; -import android.widget.PopupMenu; -import android.widget.PopupMenu.OnMenuItemClickListener; - -import java.util.ArrayList; - -public class CustomMenu implements OnMenuItemClickListener { - @SuppressWarnings("unused") - private static final String TAG = "FilterMenu"; - - public static class DropDownMenu { - private Button mButton; - private PopupMenu mPopupMenu; - private Menu mMenu; - - public DropDownMenu(Context context, Button button, int menuId, - OnMenuItemClickListener listener) { - mButton = button; - mPopupMenu = new PopupMenu(context, mButton); - mMenu = mPopupMenu.getMenu(); - mPopupMenu.getMenuInflater().inflate(menuId, mMenu); - mPopupMenu.setOnMenuItemClickListener(listener); - mButton.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - mPopupMenu.show(); - } - }); - } - - public MenuItem findItem(int id) { - return mMenu.findItem(id); - } - - public void setTitle(CharSequence title) { - mButton.setText(title); - } - } - - private Context mContext; - private ArrayList mMenus; - private OnMenuItemClickListener mListener; - - public CustomMenu(Context context) { - mContext = context; - mMenus = new ArrayList(); - } - - public DropDownMenu addDropDownMenu(Button button, int menuId) { - DropDownMenu menu = new DropDownMenu(mContext, button, menuId, this); - mMenus.add(menu); - return menu; - } - - public void setOnMenuItemClickListener(OnMenuItemClickListener listener) { - mListener = listener; - } - - @Override - public boolean onMenuItemClick(MenuItem item) { - if (mListener != null) { - return mListener.onMenuItemClick(item); - } - return false; - } -} diff --git a/src/com/android/gallery3d/ui/PopupList.java b/src/com/android/gallery3d/ui/PopupList.java new file mode 100644 index 000000000..ee02029c7 --- /dev/null +++ b/src/com/android/gallery3d/ui/PopupList.java @@ -0,0 +1,188 @@ +// Copyright 2012 Google Inc. All Rights Reserved. + +package com.android.gallery3d.ui; + +import android.content.Context; +import android.graphics.Rect; +import android.view.LayoutInflater; +import android.view.View; +import android.view.View.MeasureSpec; +import android.view.ViewGroup; +import android.view.ViewTreeObserver; +import android.view.ViewTreeObserver.OnGlobalLayoutListener; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.BaseAdapter; +import android.widget.ListView; +import android.widget.PopupWindow; +import android.widget.TextView; + +import com.android.gallery3d.R; +import com.android.gallery3d.common.Utils; + +import java.util.ArrayList; + +public class PopupList { + + public static interface OnPopupItemClickListener { + public boolean onPopupItemClick(int itemId); + } + + public static class Item { + public final int id; + public String title; + + public Item(int id, String title) { + this.id = id; + this.title = title; + } + + public void setTitle(String title) { + this.title = title; + } + } + + private final Context mContext; + private final View mAnchorView; + private final ArrayList mItems = new ArrayList(); + private PopupWindow mPopupWindow; + private ListView mContentList; + private OnPopupItemClickListener mOnPopupItemClickListener; + private int mPopupOffsetX; + private int mPopupOffsetY; + private int mPopupWidth; + private int mPopupHeight; + + public PopupList(Context context, View anchorView) { + mContext = context; + mAnchorView = anchorView; + } + + public void setOnPopupItemClickListener(OnPopupItemClickListener listener) { + mOnPopupItemClickListener = listener; + } + + public void addItem(int id, String title) { + mItems.add(new Item(id, title)); + } + + private final PopupWindow.OnDismissListener mOnDismissListener = + new PopupWindow.OnDismissListener() { + @SuppressWarnings("deprecation") + @Override + public void onDismiss() { + if (mPopupWindow == null) return; + mPopupWindow = null; + ViewTreeObserver observer = mAnchorView.getViewTreeObserver(); + if (observer.isAlive()) { + // We used the deprecated function for backward compatibility + // The new "removeOnGlobalLayoutListener" is introduced in API level 16 + observer.removeGlobalOnLayoutListener(mOnGLobalLayoutListener); + } + } + }; + + private final OnItemClickListener mOnItemClickListener = + new OnItemClickListener() { + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + Utils.debug("onItemClick: %s, %s", position, id); + if (mPopupWindow == null) return; + mPopupWindow.dismiss(); + if (mOnPopupItemClickListener != null) { + mOnPopupItemClickListener.onPopupItemClick((int) id); + } + } + }; + + private final OnGlobalLayoutListener mOnGLobalLayoutListener = + new OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + if (mPopupWindow == null) return; + updatePopupLayoutParams(); + // Need to update the position of the popup window + mPopupWindow.update(mAnchorView, + mPopupOffsetX, mPopupOffsetY, mPopupWidth, mPopupHeight); + } + }; + + public void show() { + if (mPopupWindow != null) return; + mAnchorView.getViewTreeObserver() + .addOnGlobalLayoutListener(mOnGLobalLayoutListener); + mPopupWindow = createPopupWindow(); + updatePopupLayoutParams(); + mPopupWindow.setWidth(mPopupWidth); + mPopupWindow.setHeight(mPopupHeight); + mPopupWindow.showAsDropDown(mAnchorView, mPopupOffsetX, mPopupOffsetY); + } + + private void updatePopupLayoutParams() { + ListView content = mContentList; + PopupWindow popup = mPopupWindow; + + Rect p = new Rect(); + popup.getBackground().getPadding(p); + + int maxHeight = mPopupWindow.getMaxAvailableHeight(mAnchorView) - p.top - p.bottom; + mContentList.measure( + MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), + MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST)); + mPopupWidth = content.getMeasuredWidth() + p.top + p.bottom; + mPopupHeight = Math.min(maxHeight, content.getMeasuredHeight() + p.left + p.right); + mPopupOffsetX = -p.left; + mPopupOffsetY = -p.top; + } + + private PopupWindow createPopupWindow() { + PopupWindow popup = new PopupWindow(); + popup.setOnDismissListener(mOnDismissListener); + + popup.setBackgroundDrawable(mContext.getResources().getDrawable( + R.drawable.menu_dropdown_panel_holo_dark)); + mContentList = new ListView(mContext); + mContentList.setAdapter(new ItemDataAdapter()); + mContentList.setOnItemClickListener(mOnItemClickListener); + popup.setContentView(mContentList); + popup.setFocusable(true); + popup.setOutsideTouchable(true); + + return popup; + } + + public Item findItem(int id) { + for (Item item : mItems) { + if (item.id == id) return item; + } + return null; + } + + private class ItemDataAdapter extends BaseAdapter { + @Override + public int getCount() { + return mItems.size(); + } + + @Override + public Object getItem(int position) { + return mItems.get(position); + } + + @Override + public long getItemId(int position) { + return mItems.get(position).id; + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + if (convertView == null) { + convertView = LayoutInflater.from(mContext) + .inflate(R.layout.popup_list_item, null); + } + TextView text = (TextView) convertView.findViewById(android.R.id.text1); + text.setText(mItems.get(position).title); + return convertView; + } + } +} diff --git a/src/com/android/gallery3d/ui/SelectionMenu.java b/src/com/android/gallery3d/ui/SelectionMenu.java new file mode 100644 index 000000000..5b0828328 --- /dev/null +++ b/src/com/android/gallery3d/ui/SelectionMenu.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2010 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.android.gallery3d.ui; + +import android.content.Context; +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.Button; + +import com.android.gallery3d.R; +import com.android.gallery3d.ui.PopupList.OnPopupItemClickListener; + +public class SelectionMenu implements OnClickListener { + @SuppressWarnings("unused") + private static final String TAG = "SelectionMenu"; + + private final Context mContext; + private final Button mButton; + private final PopupList mPopupList; + + public SelectionMenu(Context context, Button button, OnPopupItemClickListener listener) { + mContext = context; + mButton = button; + mPopupList = new PopupList(context, mButton); + mPopupList.addItem(R.id.action_select_all, + context.getString(R.string.select_all)); + mPopupList.setOnPopupItemClickListener(listener); + mButton.setOnClickListener(this); + } + + @Override + public void onClick(View v) { + mPopupList.show(); + } + + public void updateSelectAllMode(boolean inSelectAllMode) { + PopupList.Item item = mPopupList.findItem(R.id.action_select_all); + if (item != null) { + item.setTitle(mContext.getString( + inSelectAllMode ? R.string.deselect_all : R.string.select_all)); + } + } + + public void setTitle(CharSequence title) { + mButton.setText(title); + } +} -- GitLab From d7f6eb1c3ac9c87e1058770586e128290f71d025 Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Tue, 17 Jul 2012 10:22:16 -0700 Subject: [PATCH 086/763] Import translations. DO NOT MERGE Change-Id: I7211ff883bfdf8f5483d4b2f19f7f3572116335a Auto-generated-cl: translation import --- res/values-ru/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index 0aaab06b1..5a30aab77 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -27,7 +27,7 @@ "Продолжение просмотра видео" "Продолжить воспроизведение с %s?" "Продолжить воспроизведение" - "Идет загрузка…" + "Загрузка…" "Не загружено" "Не удалось загрузить изображение" "Нет уменьшенного изображения" -- GitLab From dff1479e600007aaf9f2b2d8c56ab1ce7854e983 Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Tue, 17 Jul 2012 10:22:53 -0700 Subject: [PATCH 087/763] Import translations. DO NOT MERGE Change-Id: I46832a8f8bd16162a91401670eea64278e7806d1 Auto-generated-cl: translation import --- res/values-ru/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index 0aaab06b1..5a30aab77 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -27,7 +27,7 @@ "Продолжение просмотра видео" "Продолжить воспроизведение с %s?" "Продолжить воспроизведение" - "Идет загрузка…" + "Загрузка…" "Не загружено" "Не удалось загрузить изображение" "Нет уменьшенного изображения" -- GitLab From 25fdccffbf475cbd60cad33005878d3f2d0ef7a4 Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Wed, 18 Jul 2012 11:45:10 -0700 Subject: [PATCH 088/763] Import translations. DO NOT MERGE Change-Id: I7c0a46f58b9086734ec66568601cb5efd536bcd6 Auto-generated-cl: translation import --- res/values-fa/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values-fa/strings.xml b/res/values-fa/strings.xml index e9f0463b1..a7a86eb74 100644 --- a/res/values-fa/strings.xml +++ b/res/values-fa/strings.xml @@ -54,7 +54,7 @@ "تأیید" "لغو" - "اشتراک گذاری" + "اشتراک‌گذاری" "پاک شد" "واگرد" "انتخاب همه" -- GitLab From f4e528dceb5381eb81f97e55089436de0364bca3 Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Wed, 18 Jul 2012 11:46:12 -0700 Subject: [PATCH 089/763] Import translations. DO NOT MERGE Change-Id: I2090d15e5bdf9944b8300748da4f8eca4b797709 Auto-generated-cl: translation import --- res/values-fa/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values-fa/strings.xml b/res/values-fa/strings.xml index e9f0463b1..a7a86eb74 100644 --- a/res/values-fa/strings.xml +++ b/res/values-fa/strings.xml @@ -54,7 +54,7 @@ "تأیید" "لغو" - "اشتراک گذاری" + "اشتراک‌گذاری" "پاک شد" "واگرد" "انتخاب همه" -- GitLab From 7ca90116a6f7c81f2a20ff8cb8968d41321acafd Mon Sep 17 00:00:00 2001 From: Wu-cheng Li Date: Thu, 19 Jul 2012 17:31:31 +0800 Subject: [PATCH 090/763] Change minSdkVersion to 13. bug:6706723 Change-Id: I3bb7cfa173f6fdd2ba9df4bda96ea31349b5bd5c --- AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index c7a693b43..57aa797ee 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -7,7 +7,7 @@ - + -- GitLab From 331bb4180d56f7cb1f88e919edd398709568dbfe Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Queru Date: Thu, 19 Jul 2012 10:56:47 -0700 Subject: [PATCH 091/763] Fix non-ARM builds - use the proper way to reference libraries Change-Id: Ibd84af84861d1cbaa8203e4b287cb20f5e9027a0 --- jni/Android.mk | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jni/Android.mk b/jni/Android.mk index a4fb844bd..e86ec8db0 100644 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -9,10 +9,11 @@ LOCAL_SRC_FILES := jni_egl_fence.cpp ifeq ($(TARGET_ARCH), arm) LOCAL_NDK_VERSION := 5 LOCAL_SDK_VERSION := 9 + LOCAL_LDFLAGS := -llog -lEGL +else + LOCAL_SHARED_LIBRARIES := liblog libEGL endif -LOCAL_LDFLAGS := -llog -lEGL - LOCAL_MODULE_TAGS := optional LOCAL_MODULE := libjni_eglfence -- GitLab From a895fae285e0a163faa523c6fe6e05e0f379fe16 Mon Sep 17 00:00:00 2001 From: Chih-Chung Chang Date: Fri, 20 Jul 2012 11:38:48 +0800 Subject: [PATCH 092/763] Only make time lapse recording available on and after Honeycomb. Change-Id: Ia5b2f69a3c0feb9e0219118a7dd372a09cf2da73 --- gallerycommon/src/com/android/gallery3d/common/ApiHelper.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java index 8ebdc1808..229eaedc3 100644 --- a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java +++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java @@ -98,6 +98,9 @@ public class ApiHelper { public static final boolean HAS_PANORAMA = Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB; + public static final boolean HAS_TIME_LAPSE_RECORDING = + Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB; + public static int getIntFieldIfExists(Class klass, String fieldName, Class obj, int defaultVal) { try { -- GitLab From 064c30b6c89c4282487290ea11e7d3fd1ef68c64 Mon Sep 17 00:00:00 2001 From: Angus Kong Date: Fri, 20 Jul 2012 15:59:50 +0800 Subject: [PATCH 093/763] Add check for camcorder zoom. bug:6838676 Change-Id: I9aeda27cf55ded444841ade40ea1eb1b91da01cb --- gallerycommon/src/com/android/gallery3d/common/ApiHelper.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java index 229eaedc3..d586ca47f 100644 --- a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java +++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java @@ -101,6 +101,9 @@ public class ApiHelper { public static final boolean HAS_TIME_LAPSE_RECORDING = Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB; + public static final boolean HAS_CAMCORDER_ZOOM = + Build.VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH; + public static int getIntFieldIfExists(Class klass, String fieldName, Class obj, int defaultVal) { try { -- GitLab From 99c4c15c64fda3ccde5755c51527aa5094f8fda6 Mon Sep 17 00:00:00 2001 From: Wu-cheng Li Date: Thu, 19 Jul 2012 18:35:30 +0800 Subject: [PATCH 094/763] Do not use listPreferredItemHeightSmall before API 14. bug:6706647 Change-Id: I9ebdb299e16bdf467cc46b3d094306d93147ee64 --- res/layout/action_bar_text.xml | 2 +- res/layout/popup_list_item.xml | 2 +- res/values-v14/styles.xml | 21 +++++++++++++++++++++ res/values/attrs.xml | 20 ++++++++++++++++++++ res/values/styles.xml | 5 ++++- 5 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 res/values-v14/styles.xml create mode 100644 res/values/attrs.xml diff --git a/res/layout/action_bar_text.xml b/res/layout/action_bar_text.xml index 2a1f0318c..7fccf0268 100644 --- a/res/layout/action_bar_text.xml +++ b/res/layout/action_bar_text.xml @@ -23,5 +23,5 @@ android:gravity="center_vertical" android:paddingLeft="18dp" android:paddingRight="18dp" - android:minHeight="?android:attr/listPreferredItemHeightSmall" + android:minHeight="?attr/listPreferredItemHeightSmall" /> diff --git a/res/layout/popup_list_item.xml b/res/layout/popup_list_item.xml index 4dbc610d9..3c43e8c1a 100644 --- a/res/layout/popup_list_item.xml +++ b/res/layout/popup_list_item.xml @@ -22,6 +22,6 @@ android:gravity="center_vertical" android:paddingLeft="16dp" android:paddingRight="16dp" - android:minHeight="?android:attr/listPreferredItemHeightSmall" + android:minHeight="?attr/listPreferredItemHeightSmall" android:minWidth="196dp" /> diff --git a/res/values-v14/styles.xml b/res/values-v14/styles.xml new file mode 100644 index 000000000..d14ad0899 --- /dev/null +++ b/res/values-v14/styles.xml @@ -0,0 +1,21 @@ + + + + + + diff --git a/res/values/attrs.xml b/res/values/attrs.xml new file mode 100644 index 000000000..f9c3d2486 --- /dev/null +++ b/res/values/attrs.xml @@ -0,0 +1,20 @@ + + + + + + + diff --git a/res/values/styles.xml b/res/values/styles.xml index 3c32cef6d..7389318ce 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -15,7 +15,10 @@ --> - + diff --git a/res/values/attrs.xml b/res/values/attrs.xml index f9c3d2486..94d5b72de 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -16,5 +16,6 @@ + diff --git a/res/values/styles.xml b/res/values/styles.xml index 7389318ce..3239f681d 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -17,6 +17,7 @@ true diff --git a/res/values/dimensions.xml b/res/values/dimensions.xml index 92e671370..b950f0a90 100644 --- a/res/values/dimensions.xml +++ b/res/values/dimensions.xml @@ -20,22 +20,22 @@ 120dp - 2 - 4 - 1dp - - 40dp - 3dp - 4dp - 14sp + 1 + 2 + 12dp + + 45dp + 10dp + 10dp + 20sp 12sp 6dp - 25dp + 20dp 2 4 - 1dp + 4dp 24dp diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index df648fdfd..c71312dd3 100644 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -156,7 +156,7 @@ public class PhotoPage extends ActivityState implements @Override protected void renderBackground(GLCanvas view) { - view.clearBuffer(); + view.clearBuffer(0f, 0f, 0f, 1f); } @Override diff --git a/src/com/android/gallery3d/app/SlideshowPage.java b/src/com/android/gallery3d/app/SlideshowPage.java index 5ec447f65..c0e35be26 100644 --- a/src/com/android/gallery3d/app/SlideshowPage.java +++ b/src/com/android/gallery3d/app/SlideshowPage.java @@ -99,7 +99,7 @@ public class SlideshowPage extends ActivityState { @Override protected void renderBackground(GLCanvas canvas) { - canvas.clearBuffer(); + canvas.clearBuffer(0f, 0f, 0f, 0f); } }; diff --git a/src/com/android/gallery3d/ui/AlbumLabelMaker.java b/src/com/android/gallery3d/ui/AlbumLabelMaker.java index 93b37ce13..a689e6990 100644 --- a/src/com/android/gallery3d/ui/AlbumLabelMaker.java +++ b/src/com/android/gallery3d/ui/AlbumLabelMaker.java @@ -34,12 +34,11 @@ import com.android.gallery3d.util.ThreadPool; import com.android.gallery3d.util.ThreadPool.JobContext; public class AlbumLabelMaker { - private static final int FONT_COLOR_TITLE = Color.WHITE; - private static final int FONT_COLOR_COUNT = 0x80FFFFFF; // 50% white + private static final int FONT_COLOR_TITLE = Color.BLACK; + private static final int FONT_COLOR_COUNT = 0x80000000; - // We keep a border around the album label to prevent aliasing - private static final int BORDER_SIZE = 1; - private static final int BACKGROUND_COLOR = 0x60000000; // 36% Dark + private static final int BORDER_SIZE = 0; + private static final int BACKGROUND_COLOR = 0xFFFFFFFF; private final AlbumSetSlotRenderer.LabelSpec mSpec; private final TextPaint mTitlePaint; @@ -58,7 +57,7 @@ public class AlbumLabelMaker { mContext = context; mSpec = spec; mTitlePaint = getTextPaint(spec.titleFontSize, FONT_COLOR_TITLE, false); - mCountPaint = getTextPaint(spec.countFontSize, FONT_COLOR_COUNT, true); + mCountPaint = getTextPaint(spec.countFontSize, FONT_COLOR_COUNT, false); mLocalSetIcon = new LazyLoadedBitmap(R.drawable.frame_overlay_gallery_folder); mPicasaIcon = new LazyLoadedBitmap(R.drawable.frame_overlay_gallery_picasa); @@ -89,7 +88,7 @@ public class AlbumLabelMaker { paint.setTextSize(textSize); paint.setAntiAlias(true); paint.setColor(color); - paint.setShadowLayer(2f, 0f, 0f, Color.BLACK); + //paint.setShadowLayer(2f, 0f, 0f, Color.LTGRAY); if (isBold) { paint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); } @@ -181,23 +180,25 @@ public class AlbumLabelMaker { // draw title if (jc.isCancelled()) return null; - int x = s.leftMargin; + int x = s.leftMargin + s.iconSize; int y = s.titleOffset; drawText(canvas, x, y, title, labelWidth - s.leftMargin, mTitlePaint); - // draw the count + // TODO: draw the count once visual designers finalize where + /* if (jc.isCancelled()) return null; if (icon != null) x = s.iconSize; y += s.titleFontSize + s.countOffset; drawText(canvas, x, y, count, labelWidth - s.leftMargin - s.iconSize, mCountPaint); + */ // draw the icon if (icon != null) { if (jc.isCancelled()) return null; float scale = (float) s.iconSize / icon.getWidth(); - canvas.translate(0, bitmap.getHeight() - - Math.round(scale * icon.getHeight())); + canvas.translate(s.leftMargin, (s.labelBackgroundHeight - + Math.round(scale * icon.getHeight()))/2f); canvas.scale(scale, scale); canvas.drawBitmap(icon, 0, 0, null); } diff --git a/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java b/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java index cca8d40a5..f58c033b0 100644 --- a/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java +++ b/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java @@ -28,7 +28,7 @@ public class AlbumSetSlotRenderer extends AbstractSlotRenderer { @SuppressWarnings("unused") private static final String TAG = "AlbumSetView"; private static final int CACHE_SIZE = 96; - private static final int PLACEHOLDER_COLOR = 0xFF222222; + private static final int PLACEHOLDER_COLOR = 0xFFDDDDDD; private final ColorTexture mWaitLoadingTexture; private final GalleryActivity mActivity; diff --git a/src/com/android/gallery3d/ui/AlbumSlotRenderer.java b/src/com/android/gallery3d/ui/AlbumSlotRenderer.java index ab9976621..dee9a0b11 100644 --- a/src/com/android/gallery3d/ui/AlbumSlotRenderer.java +++ b/src/com/android/gallery3d/ui/AlbumSlotRenderer.java @@ -31,7 +31,7 @@ public class AlbumSlotRenderer extends AbstractSlotRenderer { public boolean acceptSlot(int index); } - private static final int PLACEHOLDER_COLOR = 0xFF222222; + private static final int PLACEHOLDER_COLOR = 0xFFDDDDDD; private static final int CACHE_SIZE = 96; private AlbumSlidingWindow mDataWindow; diff --git a/src/com/android/gallery3d/ui/GLCanvas.java b/src/com/android/gallery3d/ui/GLCanvas.java index c12a9f78c..6d9aa4271 100644 --- a/src/com/android/gallery3d/ui/GLCanvas.java +++ b/src/com/android/gallery3d/ui/GLCanvas.java @@ -121,4 +121,6 @@ public interface GLCanvas { public void beginRenderTarget(RawTexture texture); public void endRenderTarget(); + + public void clearBuffer(float r, float g, float b, float a); } diff --git a/src/com/android/gallery3d/ui/GLCanvasImpl.java b/src/com/android/gallery3d/ui/GLCanvasImpl.java index 7b7a31773..a254bcce4 100644 --- a/src/com/android/gallery3d/ui/GLCanvasImpl.java +++ b/src/com/android/gallery3d/ui/GLCanvasImpl.java @@ -649,10 +649,17 @@ public class GLCanvasImpl implements GLCanvas { } @Override - public void clearBuffer() { + public void clearBuffer(float r, float g, float b, float a) { + mGL.glClearColor(r, g, b, a); mGL.glClear(GL10.GL_COLOR_BUFFER_BIT); } + @Override + public void clearBuffer() { + // TODO: Make this grey background color constant + clearBuffer(0.93f, 0.93f, 0.93f, 1); + } + private void setTextureCoords(RectF source) { setTextureCoords(source.left, source.top, source.right, source.bottom); } diff --git a/tests/src/com/android/gallery3d/ui/GLCanvasStub.java b/tests/src/com/android/gallery3d/ui/GLCanvasStub.java index 5f749d8fc..f30b57964 100644 --- a/tests/src/com/android/gallery3d/ui/GLCanvasStub.java +++ b/tests/src/com/android/gallery3d/ui/GLCanvasStub.java @@ -23,6 +23,7 @@ import javax.microedition.khronos.opengles.GL11; public class GLCanvasStub implements GLCanvas { public void setSize(int width, int height) {} public void clearBuffer() {} + public void clearBuffer(float r, float g, float b, float a) {} public void setCurrentAnimationTimeMillis(long time) {} public long currentAnimationTimeMillis() { throw new UnsupportedOperationException(); -- GitLab From 8731f48d35a9039b49e11b5f5ac33f8ae27ec399 Mon Sep 17 00:00:00 2001 From: Wu-cheng Li Date: Fri, 10 Aug 2012 15:46:25 +0800 Subject: [PATCH 160/763] Guard android.media.effect.Effect with TargetApi. bug:6927717 Change-Id: I25f881ab449ea4cb26a41c5219884d93725a1693 --- .../android/gallery3d/photoeditor/filters/AutoFixFilter.java | 3 +++ .../gallery3d/photoeditor/filters/ColorTemperatureFilter.java | 3 +++ src/com/android/gallery3d/photoeditor/filters/CropFilter.java | 3 +++ .../gallery3d/photoeditor/filters/CrossProcessFilter.java | 3 +++ .../gallery3d/photoeditor/filters/DocumentaryFilter.java | 3 +++ .../android/gallery3d/photoeditor/filters/DoodleFilter.java | 3 +++ .../android/gallery3d/photoeditor/filters/DuotoneFilter.java | 3 +++ .../android/gallery3d/photoeditor/filters/FaceTanFilter.java | 4 ++++ .../android/gallery3d/photoeditor/filters/FaceliftFilter.java | 4 ++++ .../gallery3d/photoeditor/filters/FillLightFilter.java | 3 +++ src/com/android/gallery3d/photoeditor/filters/Filter.java | 3 +++ .../android/gallery3d/photoeditor/filters/FisheyeFilter.java | 3 +++ src/com/android/gallery3d/photoeditor/filters/FlipFilter.java | 3 +++ .../android/gallery3d/photoeditor/filters/GrainFilter.java | 3 +++ .../gallery3d/photoeditor/filters/GrayscaleFilter.java | 3 +++ .../gallery3d/photoeditor/filters/HighlightFilter.java | 3 +++ .../android/gallery3d/photoeditor/filters/LomoishFilter.java | 3 +++ .../android/gallery3d/photoeditor/filters/NegativeFilter.java | 3 +++ .../gallery3d/photoeditor/filters/PosterizeFilter.java | 3 +++ .../android/gallery3d/photoeditor/filters/RedEyeFilter.java | 3 +++ .../android/gallery3d/photoeditor/filters/RotateFilter.java | 3 +++ .../gallery3d/photoeditor/filters/SaturationFilter.java | 3 +++ .../android/gallery3d/photoeditor/filters/SepiaFilter.java | 3 +++ .../android/gallery3d/photoeditor/filters/ShadowFilter.java | 3 +++ .../android/gallery3d/photoeditor/filters/SharpenFilter.java | 3 +++ .../gallery3d/photoeditor/filters/StraightenFilter.java | 3 +++ src/com/android/gallery3d/photoeditor/filters/TintFilter.java | 3 +++ .../android/gallery3d/photoeditor/filters/VignetteFilter.java | 3 +++ 28 files changed, 86 insertions(+) diff --git a/src/com/android/gallery3d/photoeditor/filters/AutoFixFilter.java b/src/com/android/gallery3d/photoeditor/filters/AutoFixFilter.java index d168a787f..b71da1920 100644 --- a/src/com/android/gallery3d/photoeditor/filters/AutoFixFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/AutoFixFilter.java @@ -16,9 +16,11 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -29,6 +31,7 @@ public class AutoFixFilter extends AbstractScaleFilter { public static final Creator CREATOR = creatorOf(AutoFixFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_AUTOFIX); effect.setParameter("scale", scale); diff --git a/src/com/android/gallery3d/photoeditor/filters/ColorTemperatureFilter.java b/src/com/android/gallery3d/photoeditor/filters/ColorTemperatureFilter.java index c5a6a35e4..960be416d 100644 --- a/src/com/android/gallery3d/photoeditor/filters/ColorTemperatureFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/ColorTemperatureFilter.java @@ -16,9 +16,11 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -30,6 +32,7 @@ public class ColorTemperatureFilter extends AbstractScaleFilter { ColorTemperatureFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_TEMPERATURE); effect.setParameter("scale", scale); diff --git a/src/com/android/gallery3d/photoeditor/filters/CropFilter.java b/src/com/android/gallery3d/photoeditor/filters/CropFilter.java index 00a6c424a..053998dfb 100644 --- a/src/com/android/gallery3d/photoeditor/filters/CropFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/CropFilter.java @@ -16,11 +16,13 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.graphics.RectF; import android.media.effect.Effect; import android.media.effect.EffectFactory; import android.os.Parcel; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -40,6 +42,7 @@ public class CropFilter extends Filter { } @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { dst.changeDimension(Math.round(bounds.width() * src.width()), Math.round(bounds.height() * src.height())); diff --git a/src/com/android/gallery3d/photoeditor/filters/CrossProcessFilter.java b/src/com/android/gallery3d/photoeditor/filters/CrossProcessFilter.java index bc233daa2..9c3d49ad9 100644 --- a/src/com/android/gallery3d/photoeditor/filters/CrossProcessFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/CrossProcessFilter.java @@ -16,8 +16,10 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -28,6 +30,7 @@ public class CrossProcessFilter extends Filter { public static final Creator CREATOR = creatorOf(CrossProcessFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { getEffect(EffectFactory.EFFECT_CROSSPROCESS).apply( src.texture(), src.width(), src.height(), dst.texture()); diff --git a/src/com/android/gallery3d/photoeditor/filters/DocumentaryFilter.java b/src/com/android/gallery3d/photoeditor/filters/DocumentaryFilter.java index d2e4c7cd0..1270defa3 100644 --- a/src/com/android/gallery3d/photoeditor/filters/DocumentaryFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/DocumentaryFilter.java @@ -16,8 +16,10 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -28,6 +30,7 @@ public class DocumentaryFilter extends Filter { public static final Creator CREATOR = creatorOf(DocumentaryFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { getEffect(EffectFactory.EFFECT_DOCUMENTARY).apply( src.texture(), src.width(), src.height(), dst.texture()); diff --git a/src/com/android/gallery3d/photoeditor/filters/DoodleFilter.java b/src/com/android/gallery3d/photoeditor/filters/DoodleFilter.java index 61920d377..52e606130 100644 --- a/src/com/android/gallery3d/photoeditor/filters/DoodleFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/DoodleFilter.java @@ -16,6 +16,7 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Matrix; @@ -26,6 +27,7 @@ import android.media.effect.Effect; import android.media.effect.EffectFactory; import android.os.Parcel; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; import com.android.gallery3d.photoeditor.actions.Doodle; @@ -45,6 +47,7 @@ public class DoodleFilter extends Filter { } @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Bitmap bitmap = Bitmap.createBitmap(src.width(), src.height(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); diff --git a/src/com/android/gallery3d/photoeditor/filters/DuotoneFilter.java b/src/com/android/gallery3d/photoeditor/filters/DuotoneFilter.java index b2c55252e..9449d0925 100644 --- a/src/com/android/gallery3d/photoeditor/filters/DuotoneFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/DuotoneFilter.java @@ -16,10 +16,12 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; import android.os.Parcel; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -38,6 +40,7 @@ public class DuotoneFilter extends Filter { } @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_DUOTONE); effect.setParameter("first_color", firstColor); diff --git a/src/com/android/gallery3d/photoeditor/filters/FaceTanFilter.java b/src/com/android/gallery3d/photoeditor/filters/FaceTanFilter.java index b7a1cf1c7..0687e7386 100644 --- a/src/com/android/gallery3d/photoeditor/filters/FaceTanFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/FaceTanFilter.java @@ -16,9 +16,11 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -31,6 +33,7 @@ public class FaceTanFilter extends AbstractScaleFilter { private static final String EFFECT_FACE_TANNING = "com.google.android.media.effect.effects.FaceTanningEffect"; @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EFFECT_FACE_TANNING); effect.setParameter("blend", scale); @@ -42,6 +45,7 @@ public class FaceTanFilter extends AbstractScaleFilter { * * @return boolean true if an effect is present in the system and can be loaded */ + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public static boolean isPresent() { return EffectFactory.isEffectSupported(EFFECT_FACE_TANNING); } diff --git a/src/com/android/gallery3d/photoeditor/filters/FaceliftFilter.java b/src/com/android/gallery3d/photoeditor/filters/FaceliftFilter.java index 3e4fad206..c714a544e 100644 --- a/src/com/android/gallery3d/photoeditor/filters/FaceliftFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/FaceliftFilter.java @@ -16,9 +16,11 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -31,6 +33,7 @@ public class FaceliftFilter extends AbstractScaleFilter { private static final String EFFECT_FACELIFT = "com.google.android.media.effect.effects.FaceliftEffect"; @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EFFECT_FACELIFT); effect.setParameter("blend", scale); @@ -42,6 +45,7 @@ public class FaceliftFilter extends AbstractScaleFilter { * * @return boolean true if an effect is present in the system and can be loaded */ + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public static boolean isPresent() { return EffectFactory.isEffectSupported(EFFECT_FACELIFT); } diff --git a/src/com/android/gallery3d/photoeditor/filters/FillLightFilter.java b/src/com/android/gallery3d/photoeditor/filters/FillLightFilter.java index 3aedd745e..3b128c074 100644 --- a/src/com/android/gallery3d/photoeditor/filters/FillLightFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/FillLightFilter.java @@ -16,9 +16,11 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -29,6 +31,7 @@ public class FillLightFilter extends AbstractScaleFilter { public static final Creator CREATOR = creatorOf(FillLightFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_FILLLIGHT); effect.setParameter("strength", scale); diff --git a/src/com/android/gallery3d/photoeditor/filters/Filter.java b/src/com/android/gallery3d/photoeditor/filters/Filter.java index 5d1ac229b..4304caf68 100644 --- a/src/com/android/gallery3d/photoeditor/filters/Filter.java +++ b/src/com/android/gallery3d/photoeditor/filters/Filter.java @@ -16,11 +16,13 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectContext; import android.os.Parcel; import android.os.Parcelable; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; import java.util.HashMap; @@ -28,6 +30,7 @@ import java.util.HashMap; /** * Image filter for photo editing; all of its methods must be called from a single GL thread. */ +@TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public abstract class Filter implements Parcelable { // TODO: This should be set in MFF instead. diff --git a/src/com/android/gallery3d/photoeditor/filters/FisheyeFilter.java b/src/com/android/gallery3d/photoeditor/filters/FisheyeFilter.java index 7fe6108c9..3789b39c9 100644 --- a/src/com/android/gallery3d/photoeditor/filters/FisheyeFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/FisheyeFilter.java @@ -16,9 +16,11 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -29,6 +31,7 @@ public class FisheyeFilter extends AbstractScaleFilter { public static final Creator CREATOR = creatorOf(FisheyeFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_FISHEYE); effect.setParameter("scale", scale); diff --git a/src/com/android/gallery3d/photoeditor/filters/FlipFilter.java b/src/com/android/gallery3d/photoeditor/filters/FlipFilter.java index 9c325c1c9..efbdac50d 100644 --- a/src/com/android/gallery3d/photoeditor/filters/FlipFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/FlipFilter.java @@ -16,10 +16,12 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; import android.os.Parcel; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -37,6 +39,7 @@ public class FlipFilter extends Filter { } @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_FLIP); effect.setParameter("horizontal", flips[0]); diff --git a/src/com/android/gallery3d/photoeditor/filters/GrainFilter.java b/src/com/android/gallery3d/photoeditor/filters/GrainFilter.java index 04867c6ac..596d1b608 100644 --- a/src/com/android/gallery3d/photoeditor/filters/GrainFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/GrainFilter.java @@ -16,9 +16,11 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -29,6 +31,7 @@ public class GrainFilter extends AbstractScaleFilter { public static final Creator CREATOR = creatorOf(GrainFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_GRAIN); effect.setParameter("strength", scale); diff --git a/src/com/android/gallery3d/photoeditor/filters/GrayscaleFilter.java b/src/com/android/gallery3d/photoeditor/filters/GrayscaleFilter.java index b0e94ef7c..bf4f4c713 100644 --- a/src/com/android/gallery3d/photoeditor/filters/GrayscaleFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/GrayscaleFilter.java @@ -16,8 +16,10 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -28,6 +30,7 @@ public class GrayscaleFilter extends Filter { public static final Creator CREATOR = creatorOf(GrayscaleFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { getEffect(EffectFactory.EFFECT_GRAYSCALE).apply( src.texture(), src.width(), src.height(), dst.texture()); diff --git a/src/com/android/gallery3d/photoeditor/filters/HighlightFilter.java b/src/com/android/gallery3d/photoeditor/filters/HighlightFilter.java index e079c2e58..3d451f1dd 100644 --- a/src/com/android/gallery3d/photoeditor/filters/HighlightFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/HighlightFilter.java @@ -16,9 +16,11 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -29,6 +31,7 @@ public class HighlightFilter extends AbstractScaleFilter { public static final Creator CREATOR = creatorOf(HighlightFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_BLACKWHITE); effect.setParameter("black", 0f); diff --git a/src/com/android/gallery3d/photoeditor/filters/LomoishFilter.java b/src/com/android/gallery3d/photoeditor/filters/LomoishFilter.java index 16a1d61e9..594fd11eb 100644 --- a/src/com/android/gallery3d/photoeditor/filters/LomoishFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/LomoishFilter.java @@ -16,8 +16,10 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -28,6 +30,7 @@ public class LomoishFilter extends Filter { public static final Creator CREATOR = creatorOf(LomoishFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { getEffect(EffectFactory.EFFECT_LOMOISH).apply( src.texture(), src.width(), src.height(), dst.texture()); diff --git a/src/com/android/gallery3d/photoeditor/filters/NegativeFilter.java b/src/com/android/gallery3d/photoeditor/filters/NegativeFilter.java index db702d7e3..327941b2f 100644 --- a/src/com/android/gallery3d/photoeditor/filters/NegativeFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/NegativeFilter.java @@ -16,8 +16,10 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -28,6 +30,7 @@ public class NegativeFilter extends Filter { public static final Creator CREATOR = creatorOf(NegativeFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { getEffect(EffectFactory.EFFECT_NEGATIVE).apply( src.texture(), src.width(), src.height(), dst.texture()); diff --git a/src/com/android/gallery3d/photoeditor/filters/PosterizeFilter.java b/src/com/android/gallery3d/photoeditor/filters/PosterizeFilter.java index 23e78bffb..805a87b45 100644 --- a/src/com/android/gallery3d/photoeditor/filters/PosterizeFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/PosterizeFilter.java @@ -16,8 +16,10 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -28,6 +30,7 @@ public class PosterizeFilter extends Filter { public static final Creator CREATOR = creatorOf(PosterizeFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { getEffect(EffectFactory.EFFECT_POSTERIZE).apply( src.texture(), src.width(), src.height(), dst.texture()); diff --git a/src/com/android/gallery3d/photoeditor/filters/RedEyeFilter.java b/src/com/android/gallery3d/photoeditor/filters/RedEyeFilter.java index 32e8f7c30..1bfcde5a7 100644 --- a/src/com/android/gallery3d/photoeditor/filters/RedEyeFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/RedEyeFilter.java @@ -16,11 +16,13 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.graphics.PointF; import android.media.effect.Effect; import android.media.effect.EffectFactory; import android.os.Parcel; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; import java.util.Vector; @@ -42,6 +44,7 @@ public class RedEyeFilter extends Filter { } @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_REDEYE); float[] centers = new float[redeyes.size() * 2]; diff --git a/src/com/android/gallery3d/photoeditor/filters/RotateFilter.java b/src/com/android/gallery3d/photoeditor/filters/RotateFilter.java index d820bdac6..a885e2538 100644 --- a/src/com/android/gallery3d/photoeditor/filters/RotateFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/RotateFilter.java @@ -16,10 +16,12 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; import android.os.Parcel; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -39,6 +41,7 @@ public class RotateFilter extends Filter { } @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { if (degrees % 180 != 0) { dst.changeDimension(src.height(), src.width()); diff --git a/src/com/android/gallery3d/photoeditor/filters/SaturationFilter.java b/src/com/android/gallery3d/photoeditor/filters/SaturationFilter.java index af08a7b9c..dab06e05d 100644 --- a/src/com/android/gallery3d/photoeditor/filters/SaturationFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/SaturationFilter.java @@ -16,9 +16,11 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -29,6 +31,7 @@ public class SaturationFilter extends AbstractScaleFilter { public static final Creator CREATOR = creatorOf(SaturationFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_SATURATE); effect.setParameter("scale", (scale - 0.5f) * 2); diff --git a/src/com/android/gallery3d/photoeditor/filters/SepiaFilter.java b/src/com/android/gallery3d/photoeditor/filters/SepiaFilter.java index d95c0d84c..efd130b37 100644 --- a/src/com/android/gallery3d/photoeditor/filters/SepiaFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/SepiaFilter.java @@ -16,8 +16,10 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -28,6 +30,7 @@ public class SepiaFilter extends Filter { public static final Creator CREATOR = creatorOf(SepiaFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { getEffect(EffectFactory.EFFECT_SEPIA).apply( src.texture(), src.width(), src.height(), dst.texture()); diff --git a/src/com/android/gallery3d/photoeditor/filters/ShadowFilter.java b/src/com/android/gallery3d/photoeditor/filters/ShadowFilter.java index 03960e405..fd214b3a3 100644 --- a/src/com/android/gallery3d/photoeditor/filters/ShadowFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/ShadowFilter.java @@ -16,9 +16,11 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -29,6 +31,7 @@ public class ShadowFilter extends AbstractScaleFilter { public static final Creator CREATOR = creatorOf(ShadowFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_BLACKWHITE); effect.setParameter("black", scale * 0.5f); diff --git a/src/com/android/gallery3d/photoeditor/filters/SharpenFilter.java b/src/com/android/gallery3d/photoeditor/filters/SharpenFilter.java index f066dcf75..90c0ec79b 100644 --- a/src/com/android/gallery3d/photoeditor/filters/SharpenFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/SharpenFilter.java @@ -16,9 +16,11 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -29,6 +31,7 @@ public class SharpenFilter extends AbstractScaleFilter { public static final Creator CREATOR = creatorOf(SharpenFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_SHARPEN); effect.setParameter("scale", scale); diff --git a/src/com/android/gallery3d/photoeditor/filters/StraightenFilter.java b/src/com/android/gallery3d/photoeditor/filters/StraightenFilter.java index bf4ace589..f6e3bf08c 100644 --- a/src/com/android/gallery3d/photoeditor/filters/StraightenFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/StraightenFilter.java @@ -16,10 +16,12 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; import android.os.Parcel; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -37,6 +39,7 @@ public class StraightenFilter extends Filter { } @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_STRAIGHTEN); effect.setParameter("maxAngle", MAX_DEGREES); diff --git a/src/com/android/gallery3d/photoeditor/filters/TintFilter.java b/src/com/android/gallery3d/photoeditor/filters/TintFilter.java index 7a7463e4c..eb3a831eb 100644 --- a/src/com/android/gallery3d/photoeditor/filters/TintFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/TintFilter.java @@ -16,10 +16,12 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; import android.os.Parcel; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -36,6 +38,7 @@ public class TintFilter extends Filter { } @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_TINT); effect.setParameter("tint", color); diff --git a/src/com/android/gallery3d/photoeditor/filters/VignetteFilter.java b/src/com/android/gallery3d/photoeditor/filters/VignetteFilter.java index 59034615f..4f6b6526d 100644 --- a/src/com/android/gallery3d/photoeditor/filters/VignetteFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/VignetteFilter.java @@ -16,9 +16,11 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -29,6 +31,7 @@ public class VignetteFilter extends AbstractScaleFilter { public static final Creator CREATOR = creatorOf(VignetteFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_VIGNETTE); effect.setParameter("scale", scale); -- GitLab From a9fb0f51165bf1ba8287f4abaf5319efaf2cae84 Mon Sep 17 00:00:00 2001 From: Wu-cheng Li Date: Fri, 10 Aug 2012 16:03:23 +0800 Subject: [PATCH 161/763] Guard SurfaceTextureScreenNail with TargetApi. bug:6927809 Change-Id: If03ffbcbf908a960f00bba97be0cdbf317ecabe8 --- src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java b/src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java index fd16b3537..ee5fe3dcb 100644 --- a/src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java +++ b/src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java @@ -22,6 +22,7 @@ import android.graphics.SurfaceTexture; import com.android.gallery3d.common.ApiHelper; +@TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB) public abstract class SurfaceTextureScreenNail implements ScreenNail, SurfaceTexture.OnFrameAvailableListener { @SuppressWarnings("unused") -- GitLab From bc8808a30e524e943b28b484d974b52769694e37 Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Thu, 9 Aug 2012 18:22:40 +0800 Subject: [PATCH 162/763] Extract EXIF info only for JPEG files bug: 6489840 Change-Id: I0ad682bffa5374d0d61ebaa502cc8b90e469b4c8 --- src/com/android/gallery3d/data/LocalImage.java | 6 +++++- src/com/android/gallery3d/data/LocalMediaItem.java | 2 ++ src/com/android/gallery3d/ui/PopupList.java | 2 -- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/com/android/gallery3d/data/LocalImage.java b/src/com/android/gallery3d/data/LocalImage.java index 370ef2686..b10b96289 100644 --- a/src/com/android/gallery3d/data/LocalImage.java +++ b/src/com/android/gallery3d/data/LocalImage.java @@ -309,7 +309,11 @@ public class LocalImage extends LocalMediaItem { public MediaDetails getDetails() { MediaDetails details = super.getDetails(); details.addDetail(MediaDetails.INDEX_ORIENTATION, Integer.valueOf(rotation)); - MediaDetails.extractExifInfo(details, filePath); + if (MIME_TYPE_JPEG.equals(mimeType)) { + // ExifInterface returns incorrect values for photos in other format. + // For example, the width and height of an webp images is always '0'. + MediaDetails.extractExifInfo(details, filePath); + } return details; } diff --git a/src/com/android/gallery3d/data/LocalMediaItem.java b/src/com/android/gallery3d/data/LocalMediaItem.java index fdc973e8d..eb054d03e 100644 --- a/src/com/android/gallery3d/data/LocalMediaItem.java +++ b/src/com/android/gallery3d/data/LocalMediaItem.java @@ -86,6 +86,8 @@ public abstract class LocalMediaItem extends MediaItem { details.addDetail(MediaDetails.INDEX_TITLE, caption); DateFormat formater = DateFormat.getDateTimeInstance(); details.addDetail(MediaDetails.INDEX_DATETIME, formater.format(new Date(dateTakenInMs))); + details.addDetail(MediaDetails.INDEX_WIDTH, width); + details.addDetail(MediaDetails.INDEX_HEIGHT, height); if (GalleryUtils.isValidLocation(latitude, longitude)) { details.addDetail(MediaDetails.INDEX_LOCATION, new double[] {latitude, longitude}); diff --git a/src/com/android/gallery3d/ui/PopupList.java b/src/com/android/gallery3d/ui/PopupList.java index ee02029c7..a5fbb09a8 100644 --- a/src/com/android/gallery3d/ui/PopupList.java +++ b/src/com/android/gallery3d/ui/PopupList.java @@ -18,7 +18,6 @@ import android.widget.PopupWindow; import android.widget.TextView; import com.android.gallery3d.R; -import com.android.gallery3d.common.Utils; import java.util.ArrayList; @@ -86,7 +85,6 @@ public class PopupList { new OnItemClickListener() { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { - Utils.debug("onItemClick: %s, %s", position, id); if (mPopupWindow == null) return; mPopupWindow.dismiss(); if (mOnPopupItemClickListener != null) { -- GitLab From 37ba3d7b5953decbb7cc21f74cd61ceed12b199a Mon Sep 17 00:00:00 2001 From: Wu-cheng Li Date: Mon, 13 Aug 2012 17:31:22 +0800 Subject: [PATCH 163/763] Make a copy of MotionEvent in MotionEventHelper.transform. RotateLayout transforms the event in dispatchTouchEvent. If the event is not handled, the parent of RotateLayout may send the transformed event to other views and the coordinates will be wrong. Make a copy of MotionEvent in transform. This also makes the behavior consistent in different API levels. bug:6974916 Change-Id: Id835767cc9be3f244e5abe2b855e5188045adedc --- src/com/android/gallery3d/util/MotionEventHelper.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/com/android/gallery3d/util/MotionEventHelper.java b/src/com/android/gallery3d/util/MotionEventHelper.java index 1c9d06244..715f7fa69 100644 --- a/src/com/android/gallery3d/util/MotionEventHelper.java +++ b/src/com/android/gallery3d/util/MotionEventHelper.java @@ -38,8 +38,9 @@ public final class MotionEventHelper { @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB) private static MotionEvent transformEventNew(MotionEvent e, Matrix m) { - e.transform(m); - return e; + MotionEvent newEvent = MotionEvent.obtain(e); + newEvent.transform(m); + return newEvent; } // This is copied from Input.cpp in the android framework. -- GitLab From 6601b3a226c9e5c9ac10e2dd8f1ee8a78946cc5c Mon Sep 17 00:00:00 2001 From: Bobby Georgescu Date: Mon, 13 Aug 2012 11:01:10 -0700 Subject: [PATCH 164/763] Fix white viewfinder flash introduced by Gallery UI reskin Bug: 6974088 Change-Id: Id6269fdbe4b5cf0d5befee800ff3c57c3b501448 --- res/layout/gl_root_group.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/layout/gl_root_group.xml b/res/layout/gl_root_group.xml index 796c9cd7b..76ff33b73 100644 --- a/res/layout/gl_root_group.xml +++ b/res/layout/gl_root_group.xml @@ -22,5 +22,5 @@ + android:background="@android:color/black"/> -- GitLab From e24cc7208a6d3760a87dfd4b80a7a6683fe146eb Mon Sep 17 00:00:00 2001 From: Bobby Georgescu Date: Mon, 13 Aug 2012 13:30:02 -0700 Subject: [PATCH 165/763] Show album counts in Gallery & other small reskin fixes Bug: 6975144 Change-Id: I2f12c6482cc009aecbca3e26482ebd8944f01bb8 --- res/values/dimensions.xml | 1 + src/com/android/gallery3d/app/Config.java | 2 ++ .../android/gallery3d/ui/AlbumLabelMaker.java | 17 +++++++++-------- .../gallery3d/ui/AlbumSetSlotRenderer.java | 1 + 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/res/values/dimensions.xml b/res/values/dimensions.xml index b950f0a90..009a2e13e 100644 --- a/res/values/dimensions.xml +++ b/res/values/dimensions.xml @@ -30,6 +30,7 @@ 20sp 12sp 6dp + 30dp 20dp diff --git a/src/com/android/gallery3d/app/Config.java b/src/com/android/gallery3d/app/Config.java index a95427b35..bd4aed1d5 100644 --- a/src/com/android/gallery3d/app/Config.java +++ b/src/com/android/gallery3d/app/Config.java @@ -58,6 +58,8 @@ final class Config { R.dimen.albumset_count_font_size); labelSpec.leftMargin = r.getDimensionPixelSize( R.dimen.albumset_left_margin); + labelSpec.titleRightMargin = r.getDimensionPixelSize( + R.dimen.albumset_title_right_margin); labelSpec.iconSize = r.getDimensionPixelSize( R.dimen.albumset_icon_size); } diff --git a/src/com/android/gallery3d/ui/AlbumLabelMaker.java b/src/com/android/gallery3d/ui/AlbumLabelMaker.java index a689e6990..4a1d545b7 100644 --- a/src/com/android/gallery3d/ui/AlbumLabelMaker.java +++ b/src/com/android/gallery3d/ui/AlbumLabelMaker.java @@ -181,17 +181,18 @@ public class AlbumLabelMaker { // draw title if (jc.isCancelled()) return null; int x = s.leftMargin + s.iconSize; - int y = s.titleOffset; - drawText(canvas, x, y, title, labelWidth - s.leftMargin, mTitlePaint); + // TODO: is the offset relevant in new reskin? + // int y = s.titleOffset; + int y = (s.labelBackgroundHeight - s.titleFontSize) / 2; + drawText(canvas, x, y, title, labelWidth - s.leftMargin - x - + s.titleRightMargin, mTitlePaint); - // TODO: draw the count once visual designers finalize where - /* + // draw count if (jc.isCancelled()) return null; - if (icon != null) x = s.iconSize; - y += s.titleFontSize + s.countOffset; + x = labelWidth - s.titleRightMargin; + y = (s.labelBackgroundHeight - s.countFontSize) / 2; drawText(canvas, x, y, count, - labelWidth - s.leftMargin - s.iconSize, mCountPaint); - */ + labelWidth - x , mCountPaint); // draw the icon if (icon != null) { diff --git a/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java b/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java index f58c033b0..cee36d969 100644 --- a/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java +++ b/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java @@ -51,6 +51,7 @@ public class AlbumSetSlotRenderer extends AbstractSlotRenderer { public int countFontSize; public int leftMargin; public int iconSize; + public int titleRightMargin; } public AlbumSetSlotRenderer(GalleryActivity activity, SelectionManager selectionManager, -- GitLab From 47c247e7c575d712546814b8dc4c737de93c2e61 Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Mon, 13 Aug 2012 15:34:59 +0800 Subject: [PATCH 166/763] Remove the previewImage and staticWallpaperPreview. Change-Id: I804ea494efdcca5fa70944f29e92c5f022f622c1 fix: 6974862 --- res/xml-v11/wallpaper_picker_preview.xml | 19 +++++++++++++++++++ res/xml-v11/widget_info.xml | 22 ++++++++++++++++++++++ res/xml/wallpaper_picker_preview.xml | 4 +--- res/xml/widget_info.xml | 1 - 4 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 res/xml-v11/wallpaper_picker_preview.xml create mode 100644 res/xml-v11/widget_info.xml diff --git a/res/xml-v11/wallpaper_picker_preview.xml b/res/xml-v11/wallpaper_picker_preview.xml new file mode 100644 index 000000000..d1ebf67ec --- /dev/null +++ b/res/xml-v11/wallpaper_picker_preview.xml @@ -0,0 +1,19 @@ + + + + + diff --git a/res/xml-v11/widget_info.xml b/res/xml-v11/widget_info.xml new file mode 100644 index 000000000..2ade4f27e --- /dev/null +++ b/res/xml-v11/widget_info.xml @@ -0,0 +1,22 @@ + + + diff --git a/res/xml/wallpaper_picker_preview.xml b/res/xml/wallpaper_picker_preview.xml index 759ff6fd4..b9570776c 100644 --- a/res/xml/wallpaper_picker_preview.xml +++ b/res/xml/wallpaper_picker_preview.xml @@ -14,6 +14,4 @@ limitations under the License. --> - - + diff --git a/res/xml/widget_info.xml b/res/xml/widget_info.xml index 4aa460f8d..13c947874 100644 --- a/res/xml/widget_info.xml +++ b/res/xml/widget_info.xml @@ -3,6 +3,5 @@ android:minWidth="@dimen/appwidget_width" android:minHeight="@dimen/appwidget_height" android:updatePeriodMillis="86400000" - android:previewImage="@drawable/preview" android:initialLayout="@layout/appwidget_main" android:configure="com.android.gallery3d.gadget.WidgetConfigure"/> -- GitLab From ceb25e968ae6c7360de52c477816995ee3edc340 Mon Sep 17 00:00:00 2001 From: Wu-cheng Li Date: Tue, 14 Aug 2012 16:21:00 +0800 Subject: [PATCH 167/763] Rename ThemeCamera to Theme.Camera to be consistent. bug:6982707 Change-Id: Ic82f542ee8aafdf6c49344887459e75303ca5df8 --- AndroidManifest.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 2e87baee0..2ad38c4ce 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -257,7 +257,7 @@ -- GitLab From 4c47cca7e2beb1fd4109e18f78c4288392a2ca94 Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Tue, 14 Aug 2012 10:33:44 -0700 Subject: [PATCH 168/763] Retire LOCAL_NDK_VERSION. Bug: 6932421 Change-Id: I9e5e8fba22ac235701c002e27012bb3954896140 --- jni/Android.mk | 2 -- 1 file changed, 2 deletions(-) diff --git a/jni/Android.mk b/jni/Android.mk index 593074f6f..cc1174bd2 100644 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -7,12 +7,10 @@ LOCAL_CFLAGS += -DEGL_EGLEXT_PROTOTYPES LOCAL_SRC_FILES := jni_egl_fence.cpp ifeq ($(TARGET_ARCH), arm) - LOCAL_NDK_VERSION := 5 LOCAL_SDK_VERSION := 9 endif ifeq ($(TARGET_ARCH), x86) - LOCAL_NDK_VERSION := 6 LOCAL_SDK_VERSION := 9 endif -- GitLab From f0c89374bfc008fb79ac3cb91cfd6d565d203041 Mon Sep 17 00:00:00 2001 From: Bobby Georgescu Date: Mon, 13 Aug 2012 14:27:08 -0700 Subject: [PATCH 169/763] Gallery reskin: album list spacing, action bar theme Change-Id: Ic556f22bd25c57ddd0b659a7f43a7a1afbdcb8df --- res/values/dimensions.xml | 2 ++ res/values/styles.xml | 4 +--- src/com/android/gallery3d/app/AlbumSetPage.java | 11 ++++++----- src/com/android/gallery3d/app/Config.java | 5 +++++ 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/res/values/dimensions.xml b/res/values/dimensions.xml index 009a2e13e..906dbdb83 100644 --- a/res/values/dimensions.xml +++ b/res/values/dimensions.xml @@ -22,6 +22,8 @@ 1 2 + 15dp + 15dp 12dp 45dp diff --git a/res/values/styles.xml b/res/values/styles.xml index 3239f681d..05bff4611 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -27,10 +27,8 @@ @null @null - - + + + + diff --git a/actionbarsherlock/res/values-v14/abs__styles.xml b/actionbarsherlock/res/values-v14/abs__styles.xml new file mode 100644 index 000000000..f2aa64d2d --- /dev/null +++ b/actionbarsherlock/res/values-v14/abs__styles.xml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/actionbarsherlock/res/values-v14/abs__themes.xml b/actionbarsherlock/res/values-v14/abs__themes.xml new file mode 100644 index 000000000..ceb960737 --- /dev/null +++ b/actionbarsherlock/res/values-v14/abs__themes.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + diff --git a/actionbarsherlock/res/values-w360dp/abs__dimens.xml b/actionbarsherlock/res/values-w360dp/abs__dimens.xml new file mode 100644 index 000000000..6f49d7e47 --- /dev/null +++ b/actionbarsherlock/res/values-w360dp/abs__dimens.xml @@ -0,0 +1,22 @@ + + + + 3 + diff --git a/actionbarsherlock/res/values-w480dp/abs__bools.xml b/actionbarsherlock/res/values-w480dp/abs__bools.xml new file mode 100644 index 000000000..3eaf4aee9 --- /dev/null +++ b/actionbarsherlock/res/values-w480dp/abs__bools.xml @@ -0,0 +1,22 @@ + + + + true + false + diff --git a/actionbarsherlock/res/values-w480dp/abs__config.xml b/actionbarsherlock/res/values-w480dp/abs__config.xml new file mode 100644 index 000000000..88357b0a7 --- /dev/null +++ b/actionbarsherlock/res/values-w480dp/abs__config.xml @@ -0,0 +1,29 @@ + + + + + + + + true + + diff --git a/actionbarsherlock/res/values-w500dp/abs__dimens.xml b/actionbarsherlock/res/values-w500dp/abs__dimens.xml new file mode 100644 index 000000000..2fd4deea2 --- /dev/null +++ b/actionbarsherlock/res/values-w500dp/abs__dimens.xml @@ -0,0 +1,22 @@ + + + + 4 + diff --git a/actionbarsherlock/res/values-w600dp/abs__dimens.xml b/actionbarsherlock/res/values-w600dp/abs__dimens.xml new file mode 100644 index 000000000..b085952d3 --- /dev/null +++ b/actionbarsherlock/res/values-w600dp/abs__dimens.xml @@ -0,0 +1,22 @@ + + + + 5 + diff --git a/actionbarsherlock/res/values-xlarge/abs__dimens.xml b/actionbarsherlock/res/values-xlarge/abs__dimens.xml new file mode 100644 index 000000000..bfc535de1 --- /dev/null +++ b/actionbarsherlock/res/values-xlarge/abs__dimens.xml @@ -0,0 +1,45 @@ + + + + + 56dip + + 4dip + + 18dp + + 14dp + + -3dp + + 9dip + + + 64dip + + + 45% + + 72% + diff --git a/actionbarsherlock/res/values/abs__attrs.xml b/actionbarsherlock/res/values/abs__attrs.xml new file mode 100644 index 000000000..bd5ee4404 --- /dev/null +++ b/actionbarsherlock/res/values/abs__attrs.xml @@ -0,0 +1,380 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/actionbarsherlock/res/values/abs__bools.xml b/actionbarsherlock/res/values/abs__bools.xml new file mode 100644 index 000000000..0b432448d --- /dev/null +++ b/actionbarsherlock/res/values/abs__bools.xml @@ -0,0 +1,22 @@ + + + + + false + true + true + + diff --git a/actionbarsherlock/res/values/abs__colors.xml b/actionbarsherlock/res/values/abs__colors.xml new file mode 100644 index 000000000..625c632ff --- /dev/null +++ b/actionbarsherlock/res/values/abs__colors.xml @@ -0,0 +1,27 @@ + + + + + #ff000000 + #fff3f3f3 + @color/abs__background_holo_light + @color/abs__background_holo_dark + #ff4c4c4c + #ffb2b2b2 + @color/abs__bright_foreground_holo_light + @color/abs__bright_foreground_holo_dark + #ff33b5e5 + diff --git a/actionbarsherlock/res/values/abs__config.xml b/actionbarsherlock/res/values/abs__config.xml new file mode 100644 index 000000000..4c7b5d459 --- /dev/null +++ b/actionbarsherlock/res/values/abs__config.xml @@ -0,0 +1,43 @@ + + + + + + + + 320dp + + + false + + + true + + + false + + diff --git a/actionbarsherlock/res/values/abs__dimens.xml b/actionbarsherlock/res/values/abs__dimens.xml new file mode 100644 index 000000000..0a409756c --- /dev/null +++ b/actionbarsherlock/res/values/abs__dimens.xml @@ -0,0 +1,50 @@ + + + + + 48dip + + 8dip + + 18dp + + 14dp + + -3dp + + 5dip + + 2 + + + 56dip + + + 64dip + + + 65% + + 95% + diff --git a/actionbarsherlock/res/values/abs__ids.xml b/actionbarsherlock/res/values/abs__ids.xml new file mode 100644 index 000000000..f9f56045b --- /dev/null +++ b/actionbarsherlock/res/values/abs__ids.xml @@ -0,0 +1,26 @@ + + + + + + + + + + diff --git a/actionbarsherlock/res/values/abs__strings.xml b/actionbarsherlock/res/values/abs__strings.xml new file mode 100644 index 000000000..1e1c7022c --- /dev/null +++ b/actionbarsherlock/res/values/abs__strings.xml @@ -0,0 +1,42 @@ + + + + + Navigate home + + Navigate up + + More options + + + Done + + + See all... + + Select activity + + Share with... + + Choose an application + + Share with + + Share with %s + diff --git a/actionbarsherlock/res/values/abs__styles.xml b/actionbarsherlock/res/values/abs__styles.xml new file mode 100644 index 000000000..8cbd36484 --- /dev/null +++ b/actionbarsherlock/res/values/abs__styles.xml @@ -0,0 +1,384 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/actionbarsherlock/res/values/abs__themes.xml b/actionbarsherlock/res/values/abs__themes.xml new file mode 100644 index 000000000..5300dedd6 --- /dev/null +++ b/actionbarsherlock/res/values/abs__themes.xml @@ -0,0 +1,226 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/actionbarsherlock/src/android/support/v4/app/_ActionBarSherlockTrojanHorse.java b/actionbarsherlock/src/android/support/v4/app/_ActionBarSherlockTrojanHorse.java new file mode 100644 index 000000000..3e3db62b7 --- /dev/null +++ b/actionbarsherlock/src/android/support/v4/app/_ActionBarSherlockTrojanHorse.java @@ -0,0 +1,144 @@ +package android.support.v4.app; + +import android.util.Log; +import android.view.View; +import android.view.Window; +import com.actionbarsherlock.ActionBarSherlock.OnCreatePanelMenuListener; +import com.actionbarsherlock.ActionBarSherlock.OnMenuItemSelectedListener; +import com.actionbarsherlock.ActionBarSherlock.OnPreparePanelListener; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; + +import java.util.ArrayList; + +/** I'm in ur package. Stealing ur variables. */ +public abstract class _ActionBarSherlockTrojanHorse extends FragmentActivity implements OnCreatePanelMenuListener, OnPreparePanelListener, OnMenuItemSelectedListener { + private static final boolean DEBUG = false; + private static final String TAG = "_ActionBarSherlockTrojanHorse"; + + /** Fragment interface for menu creation callback. */ + public interface OnCreateOptionsMenuListener { + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater); + } + /** Fragment interface for menu preparation callback. */ + public interface OnPrepareOptionsMenuListener { + public void onPrepareOptionsMenu(Menu menu); + } + /** Fragment interface for menu item selection callback. */ + public interface OnOptionsItemSelectedListener { + public boolean onOptionsItemSelected(MenuItem item); + } + + private ArrayList mCreatedMenus; + + + /////////////////////////////////////////////////////////////////////////// + // Sherlock menu handling + /////////////////////////////////////////////////////////////////////////// + + @Override + public boolean onCreatePanelMenu(int featureId, Menu menu) { + if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] featureId: " + featureId + ", menu: " + menu); + + if (featureId == Window.FEATURE_OPTIONS_PANEL) { + boolean result = onCreateOptionsMenu(menu); + if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] activity create result: " + result); + + MenuInflater inflater = getSupportMenuInflater(); + boolean show = false; + ArrayList newMenus = null; + if (mFragments.mActive != null) { + for (int i = 0; i < mFragments.mAdded.size(); i++) { + Fragment f = mFragments.mAdded.get(i); + if (f != null && !f.mHidden && f.mHasMenu && f.mMenuVisible && f instanceof OnCreateOptionsMenuListener) { + show = true; + ((OnCreateOptionsMenuListener)f).onCreateOptionsMenu(menu, inflater); + if (newMenus == null) { + newMenus = new ArrayList(); + } + newMenus.add(f); + } + } + } + + if (mCreatedMenus != null) { + for (int i = 0; i < mCreatedMenus.size(); i++) { + Fragment f = mCreatedMenus.get(i); + if (newMenus == null || !newMenus.contains(f)) { + f.onDestroyOptionsMenu(); + } + } + } + + mCreatedMenus = newMenus; + + if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] fragments create result: " + show); + result |= show; + + if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] returning " + result); + return result; + } + return false; + } + + @Override + public boolean onPreparePanel(int featureId, View view, Menu menu) { + if (DEBUG) Log.d(TAG, "[onPreparePanel] featureId: " + featureId + ", view: " + view + " menu: " + menu); + + if (featureId == Window.FEATURE_OPTIONS_PANEL) { + boolean result = onPrepareOptionsMenu(menu); + if (DEBUG) Log.d(TAG, "[onPreparePanel] activity prepare result: " + result); + + boolean show = false; + if (mFragments.mActive != null) { + for (int i = 0; i < mFragments.mAdded.size(); i++) { + Fragment f = mFragments.mAdded.get(i); + if (f != null && !f.mHidden && f.mHasMenu && f.mMenuVisible && f instanceof OnPrepareOptionsMenuListener) { + show = true; + ((OnPrepareOptionsMenuListener)f).onPrepareOptionsMenu(menu); + } + } + } + + if (DEBUG) Log.d(TAG, "[onPreparePanel] fragments prepare result: " + show); + result |= show; + + result &= menu.hasVisibleItems(); + if (DEBUG) Log.d(TAG, "[onPreparePanel] returning " + result); + return result; + } + return false; + } + + @Override + public boolean onMenuItemSelected(int featureId, MenuItem item) { + if (DEBUG) Log.d(TAG, "[onMenuItemSelected] featureId: " + featureId + ", item: " + item); + + if (featureId == Window.FEATURE_OPTIONS_PANEL) { + if (onOptionsItemSelected(item)) { + return true; + } + + if (mFragments.mActive != null) { + for (int i = 0; i < mFragments.mAdded.size(); i++) { + Fragment f = mFragments.mAdded.get(i); + if (f != null && !f.mHidden && f.mHasMenu && f.mMenuVisible && f instanceof OnOptionsItemSelectedListener) { + if (((OnOptionsItemSelectedListener)f).onOptionsItemSelected(item)) { + return true; + } + } + } + } + } + return false; + } + + public abstract boolean onCreateOptionsMenu(Menu menu); + + public abstract boolean onPrepareOptionsMenu(Menu menu); + + public abstract boolean onOptionsItemSelected(MenuItem item); + + public abstract MenuInflater getSupportMenuInflater(); +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/ActionBarSherlock.java b/actionbarsherlock/src/com/actionbarsherlock/ActionBarSherlock.java new file mode 100644 index 000000000..8340fb591 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/ActionBarSherlock.java @@ -0,0 +1,791 @@ +package com.actionbarsherlock; + +import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; +import java.util.Iterator; +import android.app.Activity; +import android.content.Context; +import android.content.res.Configuration; +import android.os.Build; +import android.os.Bundle; +import android.util.DisplayMetrics; +import android.util.Log; +import android.view.KeyEvent; +import android.view.View; +import android.view.ViewGroup; +import android.view.Window; +import com.actionbarsherlock.app.ActionBar; +import com.actionbarsherlock.internal.ActionBarSherlockCompat; +import com.actionbarsherlock.internal.ActionBarSherlockNative; +import com.actionbarsherlock.view.ActionMode; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; + +/** + *

Helper for implementing the action bar design pattern across all versions + * of Android.

+ * + *

This class will manage interaction with a custom action bar based on the + * Android 4.0 source code. The exposed API mirrors that of its native + * counterpart and you should refer to its documentation for instruction.

+ * + * @author Jake Wharton + */ +public abstract class ActionBarSherlock { + protected static final String TAG = "ActionBarSherlock"; + protected static final boolean DEBUG = false; + + private static final Class[] CONSTRUCTOR_ARGS = new Class[] { Activity.class, int.class }; + private static final HashMap> IMPLEMENTATIONS = + new HashMap>(); + + static { + //Register our two built-in implementations + registerImplementation(ActionBarSherlockCompat.class); + registerImplementation(ActionBarSherlockNative.class); + } + + + /** + *

Denotes an implementation of ActionBarSherlock which provides an + * action bar-enhanced experience.

+ */ + @Target(ElementType.TYPE) + @Retention(RetentionPolicy.RUNTIME) + public @interface Implementation { + static final int DEFAULT_API = -1; + static final int DEFAULT_DPI = -1; + + int api() default DEFAULT_API; + int dpi() default DEFAULT_DPI; + } + + + /** Activity interface for menu creation callback. */ + public interface OnCreatePanelMenuListener { + public boolean onCreatePanelMenu(int featureId, Menu menu); + } + /** Activity interface for menu creation callback. */ + public interface OnCreateOptionsMenuListener { + public boolean onCreateOptionsMenu(Menu menu); + } + /** Activity interface for menu item selection callback. */ + public interface OnMenuItemSelectedListener { + public boolean onMenuItemSelected(int featureId, MenuItem item); + } + /** Activity interface for menu item selection callback. */ + public interface OnOptionsItemSelectedListener { + public boolean onOptionsItemSelected(MenuItem item); + } + /** Activity interface for menu preparation callback. */ + public interface OnPreparePanelListener { + public boolean onPreparePanel(int featureId, View view, Menu menu); + } + /** Activity interface for menu preparation callback. */ + public interface OnPrepareOptionsMenuListener { + public boolean onPrepareOptionsMenu(Menu menu); + } + /** Activity interface for action mode finished callback. */ + public interface OnActionModeFinishedListener { + public void onActionModeFinished(ActionMode mode); + } + /** Activity interface for action mode started callback. */ + public interface OnActionModeStartedListener { + public void onActionModeStarted(ActionMode mode); + } + + + /** + * If set, the logic in these classes will assume that an {@link Activity} + * is dispatching all of the required events to the class. This flag should + * only be used internally or if you are creating your own base activity + * modeled after one of the included types (e.g., {@code SherlockActivity}). + */ + public static final int FLAG_DELEGATE = 1; + + + /** + * Register an ActionBarSherlock implementation. + * + * @param implementationClass Target implementation class which extends + * {@link ActionBarSherlock}. This class must also be annotated with + * {@link Implementation}. + */ + public static void registerImplementation(Class implementationClass) { + if (!implementationClass.isAnnotationPresent(Implementation.class)) { + throw new IllegalArgumentException("Class " + implementationClass.getSimpleName() + " is not annotated with @Implementation"); + } else if (IMPLEMENTATIONS.containsValue(implementationClass)) { + if (DEBUG) Log.w(TAG, "Class " + implementationClass.getSimpleName() + " already registered"); + return; + } + + Implementation impl = implementationClass.getAnnotation(Implementation.class); + if (DEBUG) Log.i(TAG, "Registering " + implementationClass.getSimpleName() + " with qualifier " + impl); + IMPLEMENTATIONS.put(impl, implementationClass); + } + + /** + * Unregister an ActionBarSherlock implementation. This should be + * considered very volatile and you should only use it if you know what + * you are doing. You have been warned. + * + * @param implementationClass Target implementation class. + * @return Boolean indicating whether the class was removed. + */ + public static boolean unregisterImplementation(Class implementationClass) { + return IMPLEMENTATIONS.values().remove(implementationClass); + } + + /** + * Wrap an activity with an action bar abstraction which will enable the + * use of a custom implementation on platforms where a native version does + * not exist. + * + * @param activity Activity to wrap. + * @return Instance to interact with the action bar. + */ + public static ActionBarSherlock wrap(Activity activity) { + return wrap(activity, 0); + } + + /** + * Wrap an activity with an action bar abstraction which will enable the + * use of a custom implementation on platforms where a native version does + * not exist. + * + * @param activity Owning activity. + * @param flags Option flags to control behavior. + * @return Instance to interact with the action bar. + */ + public static ActionBarSherlock wrap(Activity activity, int flags) { + //Create a local implementation map we can modify + HashMap> impls = + new HashMap>(IMPLEMENTATIONS); + boolean hasQualfier; + + /* DPI FILTERING */ + hasQualfier = false; + for (Implementation key : impls.keySet()) { + //Only honor TVDPI as a specific qualifier + if (key.dpi() == DisplayMetrics.DENSITY_TV) { + hasQualfier = true; + break; + } + } + if (hasQualfier) { + final boolean isTvDpi = activity.getResources().getDisplayMetrics().densityDpi == DisplayMetrics.DENSITY_TV; + for (Iterator keys = impls.keySet().iterator(); keys.hasNext(); ) { + int keyDpi = keys.next().dpi(); + if ((isTvDpi && keyDpi != DisplayMetrics.DENSITY_TV) + || (!isTvDpi && keyDpi == DisplayMetrics.DENSITY_TV)) { + keys.remove(); + } + } + } + + /* API FILTERING */ + hasQualfier = false; + for (Implementation key : impls.keySet()) { + if (key.api() != Implementation.DEFAULT_API) { + hasQualfier = true; + break; + } + } + if (hasQualfier) { + final int runtimeApi = Build.VERSION.SDK_INT; + int bestApi = 0; + for (Iterator keys = impls.keySet().iterator(); keys.hasNext(); ) { + int keyApi = keys.next().api(); + if (keyApi > runtimeApi) { + keys.remove(); + } else if (keyApi > bestApi) { + bestApi = keyApi; + } + } + for (Iterator keys = impls.keySet().iterator(); keys.hasNext(); ) { + if (keys.next().api() != bestApi) { + keys.remove(); + } + } + } + + if (impls.size() > 1) { + throw new IllegalStateException("More than one implementation matches configuration."); + } + if (impls.isEmpty()) { + throw new IllegalStateException("No implementations match configuration."); + } + Class impl = impls.values().iterator().next(); + if (DEBUG) Log.i(TAG, "Using implementation: " + impl.getSimpleName()); + + try { + Constructor ctor = impl.getConstructor(CONSTRUCTOR_ARGS); + return ctor.newInstance(activity, flags); + } catch (NoSuchMethodException e) { + throw new RuntimeException(e); + } catch (IllegalArgumentException e) { + throw new RuntimeException(e); + } catch (InstantiationException e) { + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } catch (InvocationTargetException e) { + throw new RuntimeException(e); + } + } + + + /** Activity which is displaying the action bar. Also used for context. */ + protected final Activity mActivity; + /** Whether delegating actions for the activity or managing ourselves. */ + protected final boolean mIsDelegate; + + /** Reference to our custom menu inflater which supports action items. */ + protected MenuInflater mMenuInflater; + + + + protected ActionBarSherlock(Activity activity, int flags) { + if (DEBUG) Log.d(TAG, "[] activity: " + activity + ", flags: " + flags); + + mActivity = activity; + mIsDelegate = (flags & FLAG_DELEGATE) != 0; + } + + + /** + * Get the current action bar instance. + * + * @return Action bar instance. + */ + public abstract ActionBar getActionBar(); + + + /////////////////////////////////////////////////////////////////////////// + // Lifecycle and interaction callbacks when delegating + /////////////////////////////////////////////////////////////////////////// + + /** + * Notify action bar of a configuration change event. Should be dispatched + * after the call to the superclass implementation. + * + *
+     * @Override
+     * public void onConfigurationChanged(Configuration newConfig) {
+     *     super.onConfigurationChanged(newConfig);
+     *     mSherlock.dispatchConfigurationChanged(newConfig);
+     * }
+     * 
+ * + * @param newConfig The new device configuration. + */ + public void dispatchConfigurationChanged(Configuration newConfig) {} + + /** + * Notify the action bar that the activity has finished its resuming. This + * should be dispatched after the call to the superclass implementation. + * + *
+     * @Override
+     * protected void onPostResume() {
+     *     super.onPostResume();
+     *     mSherlock.dispatchPostResume();
+     * }
+     * 
+ */ + public void dispatchPostResume() {} + + /** + * Notify the action bar that the activity is pausing. This should be + * dispatched before the call to the superclass implementation. + * + *
+     * @Override
+     * protected void onPause() {
+     *     mSherlock.dispatchPause();
+     *     super.onPause();
+     * }
+     * 
+ */ + public void dispatchPause() {} + + /** + * Notify the action bar that the activity is stopping. This should be + * called before the superclass implementation. + * + *

+ * @Override + * protected void onStop() { + * mSherlock.dispatchStop(); + * super.onStop(); + * } + *

+ */ + public void dispatchStop() {} + + /** + * Indicate that the menu should be recreated by calling + * {@link OnCreateOptionsMenuListener#onCreateOptionsMenu(com.actionbarsherlock.view.Menu)}. + */ + public abstract void dispatchInvalidateOptionsMenu(); + + /** + * Notify the action bar that it should display its overflow menu if it is + * appropriate for the device. The implementation should conditionally + * call the superclass method only if this method returns {@code false}. + * + *

+ * @Override + * public void openOptionsMenu() { + * if (!mSherlock.dispatchOpenOptionsMenu()) { + * super.openOptionsMenu(); + * } + * } + *

+ * + * @return {@code true} if the opening of the menu was handled internally. + */ + public boolean dispatchOpenOptionsMenu() { + return false; + } + + /** + * Notify the action bar that it should close its overflow menu if it is + * appropriate for the device. This implementation should conditionally + * call the superclass method only if this method returns {@code false}. + * + *
+     * @Override
+     * public void closeOptionsMenu() {
+     *     if (!mSherlock.dispatchCloseOptionsMenu()) {
+     *         super.closeOptionsMenu();
+     *     }
+     * }
+     * 
+ * + * @return {@code true} if the closing of the menu was handled internally. + */ + public boolean dispatchCloseOptionsMenu() { + return false; + } + + /** + * Notify the class that the activity has finished its creation. This + * should be called after the superclass implementation. + * + *
+     * @Override
+     * protected void onPostCreate(Bundle savedInstanceState) {
+     *     mSherlock.dispatchPostCreate(savedInstanceState);
+     *     super.onPostCreate(savedInstanceState);
+     * }
+     * 
+ * + * @param savedInstanceState If the activity is being re-initialized after + * previously being shut down then this Bundle + * contains the data it most recently supplied in + * {@link Activity#}onSaveInstanceState(Bundle)}. + * Note: Otherwise it is null. + */ + public void dispatchPostCreate(Bundle savedInstanceState) {} + + /** + * Notify the action bar that the title has changed and the action bar + * should be updated to reflect the change. This should be called before + * the superclass implementation. + * + *
+     *  @Override
+     *  protected void onTitleChanged(CharSequence title, int color) {
+     *      mSherlock.dispatchTitleChanged(title, color);
+     *      super.onTitleChanged(title, color);
+     *  }
+     * 
+ * + * @param title New activity title. + * @param color New activity color. + */ + public void dispatchTitleChanged(CharSequence title, int color) {} + + /** + * Notify the action bar the user has created a key event. This is used to + * toggle the display of the overflow action item with the menu key and to + * close the action mode or expanded action item with the back key. + * + *
+     * @Override
+     * public boolean dispatchKeyEvent(KeyEvent event) {
+     *     if (mSherlock.dispatchKeyEvent(event)) {
+     *         return true;
+     *     }
+     *     return super.dispatchKeyEvent(event);
+     * }
+     * 
+ * + * @param event Description of the key event. + * @return {@code true} if the event was handled. + */ + public boolean dispatchKeyEvent(KeyEvent event) { + return false; + } + + /** + * Notify the action bar that the Activity has triggered a menu creation + * which should happen on the conclusion of {@link Activity#onCreate}. This + * will be used to gain a reference to the native menu for native and + * overflow binding as well as to indicate when compatibility create should + * occur for the first time. + * + * @param menu Activity native menu. + * @return {@code true} since we always want to say that we have a native + */ + public abstract boolean dispatchCreateOptionsMenu(android.view.Menu menu); + + /** + * Notify the action bar that the Activity has triggered a menu preparation + * which usually means that the user has requested the overflow menu via a + * hardware menu key. You should return the result of this method call and + * not call the superclass implementation. + * + *

+ * @Override + * public final boolean onPrepareOptionsMenu(android.view.Menu menu) { + * return mSherlock.dispatchPrepareOptionsMenu(menu); + * } + *

+ * + * @param menu Activity native menu. + * @return {@code true} if menu display should proceed. + */ + public abstract boolean dispatchPrepareOptionsMenu(android.view.Menu menu); + + /** + * Notify the action bar that a native options menu item has been selected. + * The implementation should return the result of this method call. + * + *

+ * @Override + * public final boolean onOptionsItemSelected(android.view.MenuItem item) { + * return mSherlock.dispatchOptionsItemSelected(item); + * } + *

+ * + * @param item Options menu item. + * @return @{code true} if the selection was handled. + */ + public abstract boolean dispatchOptionsItemSelected(android.view.MenuItem item); + + /** + * Notify the action bar that the overflow menu has been opened. The + * implementation should conditionally return {@code true} if this method + * returns {@code true}, otherwise return the result of the superclass + * method. + * + *

+ * @Override + * public final boolean onMenuOpened(int featureId, android.view.Menu menu) { + * if (mSherlock.dispatchMenuOpened(featureId, menu)) { + * return true; + * } + * return super.onMenuOpened(featureId, menu); + * } + *

+ * + * @param featureId Window feature which triggered the event. + * @param menu Activity native menu. + * @return {@code true} if the event was handled by this method. + */ + public boolean dispatchMenuOpened(int featureId, android.view.Menu menu) { + return false; + } + + /** + * Notify the action bar that the overflow menu has been closed. This + * method should be called before the superclass implementation. + * + *

+ * @Override + * public void onPanelClosed(int featureId, android.view.Menu menu) { + * mSherlock.dispatchPanelClosed(featureId, menu); + * super.onPanelClosed(featureId, menu); + * } + *

+ * + * @param featureId + * @param menu + */ + public void dispatchPanelClosed(int featureId, android.view.Menu menu) {} + + /** + * Notify the action bar that the activity has been destroyed. This method + * should be called before the superclass implementation. + * + *

+ * @Override + * public void onDestroy() { + * mSherlock.dispatchDestroy(); + * super.onDestroy(); + * } + *

+ */ + public void dispatchDestroy() {} + + + /////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// + + + /** + * Internal method to trigger the menu creation process. + * + * @return {@code true} if menu creation should proceed. + */ + protected final boolean callbackCreateOptionsMenu(Menu menu) { + if (DEBUG) Log.d(TAG, "[callbackCreateOptionsMenu] menu: " + menu); + + boolean result = true; + if (mActivity instanceof OnCreatePanelMenuListener) { + OnCreatePanelMenuListener listener = (OnCreatePanelMenuListener)mActivity; + result = listener.onCreatePanelMenu(Window.FEATURE_OPTIONS_PANEL, menu); + } else if (mActivity instanceof OnCreateOptionsMenuListener) { + OnCreateOptionsMenuListener listener = (OnCreateOptionsMenuListener)mActivity; + result = listener.onCreateOptionsMenu(menu); + } + + if (DEBUG) Log.d(TAG, "[callbackCreateOptionsMenu] returning " + result); + return result; + } + + /** + * Internal method to trigger the menu preparation process. + * + * @return {@code true} if menu preparation should proceed. + */ + protected final boolean callbackPrepareOptionsMenu(Menu menu) { + if (DEBUG) Log.d(TAG, "[callbackPrepareOptionsMenu] menu: " + menu); + + boolean result = true; + if (mActivity instanceof OnPreparePanelListener) { + OnPreparePanelListener listener = (OnPreparePanelListener)mActivity; + result = listener.onPreparePanel(Window.FEATURE_OPTIONS_PANEL, null, menu); + } else if (mActivity instanceof OnPrepareOptionsMenuListener) { + OnPrepareOptionsMenuListener listener = (OnPrepareOptionsMenuListener)mActivity; + result = listener.onPrepareOptionsMenu(menu); + } + + if (DEBUG) Log.d(TAG, "[callbackPrepareOptionsMenu] returning " + result); + return result; + } + + /** + * Internal method for dispatching options menu selection to the owning + * activity callback. + * + * @param item Selected options menu item. + * @return {@code true} if the item selection was handled in the callback. + */ + protected final boolean callbackOptionsItemSelected(MenuItem item) { + if (DEBUG) Log.d(TAG, "[callbackOptionsItemSelected] item: " + item.getTitleCondensed()); + + boolean result = false; + if (mActivity instanceof OnMenuItemSelectedListener) { + OnMenuItemSelectedListener listener = (OnMenuItemSelectedListener)mActivity; + result = listener.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, item); + } else if (mActivity instanceof OnOptionsItemSelectedListener) { + OnOptionsItemSelectedListener listener = (OnOptionsItemSelectedListener)mActivity; + result = listener.onOptionsItemSelected(item); + } + + if (DEBUG) Log.d(TAG, "[callbackOptionsItemSelected] returning " + result); + return result; + } + + + /////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// + + + /** + * Query for the availability of a certain feature. + * + * @param featureId The feature ID to check. + * @return {@code true} if feature is enabled, {@code false} otherwise. + */ + public abstract boolean hasFeature(int featureId); + + /** + * Enable extended screen features. This must be called before + * {@code setContentView()}. May be called as many times as desired as long + * as it is before {@code setContentView()}. If not called, no extended + * features will be available. You can not turn off a feature once it is + * requested. + * + * @param featureId The desired features, defined as constants by Window. + * @return Returns true if the requested feature is supported and now + * enabled. + */ + public abstract boolean requestFeature(int featureId); + + /** + * Set extra options that will influence the UI for this window. + * + * @param uiOptions Flags specifying extra options for this window. + */ + public abstract void setUiOptions(int uiOptions); + + /** + * Set extra options that will influence the UI for this window. Only the + * bits filtered by mask will be modified. + * + * @param uiOptions Flags specifying extra options for this window. + * @param mask Flags specifying which options should be modified. Others + * will remain unchanged. + */ + public abstract void setUiOptions(int uiOptions, int mask); + + /** + * Set the content of the activity inside the action bar. + * + * @param layoutResId Layout resource ID. + */ + public abstract void setContentView(int layoutResId); + + /** + * Set the content of the activity inside the action bar. + * + * @param view The desired content to display. + */ + public void setContentView(View view) { + if (DEBUG) Log.d(TAG, "[setContentView] view: " + view); + + setContentView(view, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)); + } + + /** + * Set the content of the activity inside the action bar. + * + * @param view The desired content to display. + * @param params Layout parameters to apply to the view. + */ + public abstract void setContentView(View view, ViewGroup.LayoutParams params); + + /** + * Variation on {@link #setContentView(android.view.View, android.view.ViewGroup.LayoutParams)} + * to add an additional content view to the screen. Added after any + * existing ones on the screen -- existing views are NOT removed. + * + * @param view The desired content to display. + * @param params Layout parameters for the view. + */ + public abstract void addContentView(View view, ViewGroup.LayoutParams params); + + /** + * Change the title associated with this activity. + */ + public abstract void setTitle(CharSequence title); + + /** + * Change the title associated with this activity. + */ + public void setTitle(int resId) { + if (DEBUG) Log.d(TAG, "[setTitle] resId: " + resId); + + setTitle(mActivity.getString(resId)); + } + + /** + * Sets the visibility of the progress bar in the title. + *

+ * In order for the progress bar to be shown, the feature must be requested + * via {@link #requestWindowFeature(int)}. + * + * @param visible Whether to show the progress bars in the title. + */ + public abstract void setProgressBarVisibility(boolean visible); + + /** + * Sets the visibility of the indeterminate progress bar in the title. + *

+ * In order for the progress bar to be shown, the feature must be requested + * via {@link #requestWindowFeature(int)}. + * + * @param visible Whether to show the progress bars in the title. + */ + public abstract void setProgressBarIndeterminateVisibility(boolean visible); + + /** + * Sets whether the horizontal progress bar in the title should be indeterminate (the circular + * is always indeterminate). + *

+ * In order for the progress bar to be shown, the feature must be requested + * via {@link #requestWindowFeature(int)}. + * + * @param indeterminate Whether the horizontal progress bar should be indeterminate. + */ + public abstract void setProgressBarIndeterminate(boolean indeterminate); + + /** + * Sets the progress for the progress bars in the title. + *

+ * In order for the progress bar to be shown, the feature must be requested + * via {@link #requestWindowFeature(int)}. + * + * @param progress The progress for the progress bar. Valid ranges are from + * 0 to 10000 (both inclusive). If 10000 is given, the progress + * bar will be completely filled and will fade out. + */ + public abstract void setProgress(int progress); + + /** + * Sets the secondary progress for the progress bar in the title. This + * progress is drawn between the primary progress (set via + * {@link #setProgress(int)} and the background. It can be ideal for media + * scenarios such as showing the buffering progress while the default + * progress shows the play progress. + *

+ * In order for the progress bar to be shown, the feature must be requested + * via {@link #requestWindowFeature(int)}. + * + * @param secondaryProgress The secondary progress for the progress bar. Valid ranges are from + * 0 to 10000 (both inclusive). + */ + public abstract void setSecondaryProgress(int secondaryProgress); + + /** + * Get a menu inflater instance which supports the newer menu attributes. + * + * @return Menu inflater instance. + */ + public MenuInflater getMenuInflater() { + if (DEBUG) Log.d(TAG, "[getMenuInflater]"); + + // Make sure that action views can get an appropriate theme. + if (mMenuInflater == null) { + if (getActionBar() != null) { + mMenuInflater = new MenuInflater(getThemedContext()); + } else { + mMenuInflater = new MenuInflater(mActivity); + } + } + return mMenuInflater; + } + + protected abstract Context getThemedContext(); + + /** + * Start an action mode. + * + * @param callback Callback that will manage lifecycle events for this + * context mode. + * @return The ContextMode that was started, or null if it was canceled. + * @see ActionMode + */ + public abstract ActionMode startActionMode(ActionMode.Callback callback); +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/app/ActionBar.java b/actionbarsherlock/src/com/actionbarsherlock/app/ActionBar.java new file mode 100644 index 000000000..2497d24ff --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/app/ActionBar.java @@ -0,0 +1,947 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.app; + +import android.content.Context; +import android.graphics.drawable.Drawable; +import android.support.v4.app.FragmentTransaction; +import android.util.AttributeSet; +import android.view.Gravity; +import android.view.View; +import android.view.ViewDebug; +import android.view.ViewGroup; +import android.view.ViewGroup.MarginLayoutParams; +import android.widget.SpinnerAdapter; + +/** + * A window feature at the top of the activity that may display the activity title, navigation + * modes, and other interactive items. + *

Beginning with Android 3.0 (API level 11), the action bar appears at the top of an + * activity's window when the activity uses the system's {@link + * android.R.style#Theme_Holo Holo} theme (or one of its descendant themes), which is the default. + * You may otherwise add the action bar by calling {@link + * android.view.Window#requestFeature requestFeature(FEATURE_ACTION_BAR)} or by declaring it in a + * custom theme with the {@link android.R.styleable#Theme_windowActionBar windowActionBar} property. + *

By default, the action bar shows the application icon on + * the left, followed by the activity title. If your activity has an options menu, you can make + * select items accessible directly from the action bar as "action items". You can also + * modify various characteristics of the action bar or remove it completely.

+ *

From your activity, you can retrieve an instance of {@link ActionBar} by calling {@link + * android.app.Activity#getActionBar getActionBar()}.

+ *

In some cases, the action bar may be overlayed by another bar that enables contextual actions, + * using an {@link android.view.ActionMode}. For example, when the user selects one or more items in + * your activity, you can enable an action mode that offers actions specific to the selected + * items, with a UI that temporarily replaces the action bar. Although the UI may occupy the + * same space, the {@link android.view.ActionMode} APIs are distinct and independent from those for + * {@link ActionBar}. + *

+ *

Developer Guides

+ *

For information about how to use the action bar, including how to add action items, navigation + * modes and more, read the Action + * Bar developer guide.

+ *
+ */ +public abstract class ActionBar { + /** + * Standard navigation mode. Consists of either a logo or icon + * and title text with an optional subtitle. Clicking any of these elements + * will dispatch onOptionsItemSelected to the host Activity with + * a MenuItem with item ID android.R.id.home. + */ + public static final int NAVIGATION_MODE_STANDARD = android.app.ActionBar.NAVIGATION_MODE_STANDARD; + + /** + * List navigation mode. Instead of static title text this mode + * presents a list menu for navigation within the activity. + * e.g. this might be presented to the user as a dropdown list. + */ + public static final int NAVIGATION_MODE_LIST = android.app.ActionBar.NAVIGATION_MODE_LIST; + + /** + * Tab navigation mode. Instead of static title text this mode + * presents a series of tabs for navigation within the activity. + */ + public static final int NAVIGATION_MODE_TABS = android.app.ActionBar.NAVIGATION_MODE_TABS; + + /** + * Use logo instead of icon if available. This flag will cause appropriate + * navigation modes to use a wider logo in place of the standard icon. + * + * @see #setDisplayOptions(int) + * @see #setDisplayOptions(int, int) + */ + public static final int DISPLAY_USE_LOGO = android.app.ActionBar.DISPLAY_USE_LOGO; + + /** + * Show 'home' elements in this action bar, leaving more space for other + * navigation elements. This includes logo and icon. + * + * @see #setDisplayOptions(int) + * @see #setDisplayOptions(int, int) + */ + public static final int DISPLAY_SHOW_HOME = android.app.ActionBar.DISPLAY_SHOW_HOME; + + /** + * Display the 'home' element such that it appears as an 'up' affordance. + * e.g. show an arrow to the left indicating the action that will be taken. + * + * Set this flag if selecting the 'home' button in the action bar to return + * up by a single level in your UI rather than back to the top level or front page. + * + *

Setting this option will implicitly enable interaction with the home/up + * button. See {@link #setHomeButtonEnabled(boolean)}. + * + * @see #setDisplayOptions(int) + * @see #setDisplayOptions(int, int) + */ + public static final int DISPLAY_HOME_AS_UP = android.app.ActionBar.DISPLAY_HOME_AS_UP; + + /** + * Show the activity title and subtitle, if present. + * + * @see #setTitle(CharSequence) + * @see #setTitle(int) + * @see #setSubtitle(CharSequence) + * @see #setSubtitle(int) + * @see #setDisplayOptions(int) + * @see #setDisplayOptions(int, int) + */ + public static final int DISPLAY_SHOW_TITLE = android.app.ActionBar.DISPLAY_SHOW_TITLE; + + /** + * Show the custom view if one has been set. + * @see #setCustomView(View) + * @see #setDisplayOptions(int) + * @see #setDisplayOptions(int, int) + */ + public static final int DISPLAY_SHOW_CUSTOM = android.app.ActionBar.DISPLAY_SHOW_CUSTOM; + + /** + * Set the action bar into custom navigation mode, supplying a view + * for custom navigation. + * + * Custom navigation views appear between the application icon and + * any action buttons and may use any space available there. Common + * use cases for custom navigation views might include an auto-suggesting + * address bar for a browser or other navigation mechanisms that do not + * translate well to provided navigation modes. + * + * @param view Custom navigation view to place in the ActionBar. + */ + public abstract void setCustomView(View view); + + /** + * Set the action bar into custom navigation mode, supplying a view + * for custom navigation. + * + *

Custom navigation views appear between the application icon and + * any action buttons and may use any space available there. Common + * use cases for custom navigation views might include an auto-suggesting + * address bar for a browser or other navigation mechanisms that do not + * translate well to provided navigation modes.

+ * + *

The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for + * the custom view to be displayed.

+ * + * @param view Custom navigation view to place in the ActionBar. + * @param layoutParams How this custom view should layout in the bar. + * + * @see #setDisplayOptions(int, int) + */ + public abstract void setCustomView(View view, LayoutParams layoutParams); + + /** + * Set the action bar into custom navigation mode, supplying a view + * for custom navigation. + * + *

Custom navigation views appear between the application icon and + * any action buttons and may use any space available there. Common + * use cases for custom navigation views might include an auto-suggesting + * address bar for a browser or other navigation mechanisms that do not + * translate well to provided navigation modes.

+ * + *

The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for + * the custom view to be displayed.

+ * + * @param resId Resource ID of a layout to inflate into the ActionBar. + * + * @see #setDisplayOptions(int, int) + */ + public abstract void setCustomView(int resId); + + /** + * Set the icon to display in the 'home' section of the action bar. + * The action bar will use an icon specified by its style or the + * activity icon by default. + * + * Whether the home section shows an icon or logo is controlled + * by the display option {@link #DISPLAY_USE_LOGO}. + * + * @param resId Resource ID of a drawable to show as an icon. + * + * @see #setDisplayUseLogoEnabled(boolean) + * @see #setDisplayShowHomeEnabled(boolean) + */ + public abstract void setIcon(int resId); + + /** + * Set the icon to display in the 'home' section of the action bar. + * The action bar will use an icon specified by its style or the + * activity icon by default. + * + * Whether the home section shows an icon or logo is controlled + * by the display option {@link #DISPLAY_USE_LOGO}. + * + * @param icon Drawable to show as an icon. + * + * @see #setDisplayUseLogoEnabled(boolean) + * @see #setDisplayShowHomeEnabled(boolean) + */ + public abstract void setIcon(Drawable icon); + + /** + * Set the logo to display in the 'home' section of the action bar. + * The action bar will use a logo specified by its style or the + * activity logo by default. + * + * Whether the home section shows an icon or logo is controlled + * by the display option {@link #DISPLAY_USE_LOGO}. + * + * @param resId Resource ID of a drawable to show as a logo. + * + * @see #setDisplayUseLogoEnabled(boolean) + * @see #setDisplayShowHomeEnabled(boolean) + */ + public abstract void setLogo(int resId); + + /** + * Set the logo to display in the 'home' section of the action bar. + * The action bar will use a logo specified by its style or the + * activity logo by default. + * + * Whether the home section shows an icon or logo is controlled + * by the display option {@link #DISPLAY_USE_LOGO}. + * + * @param logo Drawable to show as a logo. + * + * @see #setDisplayUseLogoEnabled(boolean) + * @see #setDisplayShowHomeEnabled(boolean) + */ + public abstract void setLogo(Drawable logo); + + /** + * Set the adapter and navigation callback for list navigation mode. + * + * The supplied adapter will provide views for the expanded list as well as + * the currently selected item. (These may be displayed differently.) + * + * The supplied OnNavigationListener will alert the application when the user + * changes the current list selection. + * + * @param adapter An adapter that will provide views both to display + * the current navigation selection and populate views + * within the dropdown navigation menu. + * @param callback An OnNavigationListener that will receive events when the user + * selects a navigation item. + */ + public abstract void setListNavigationCallbacks(SpinnerAdapter adapter, + OnNavigationListener callback); + + /** + * Set the selected navigation item in list or tabbed navigation modes. + * + * @param position Position of the item to select. + */ + public abstract void setSelectedNavigationItem(int position); + + /** + * Get the position of the selected navigation item in list or tabbed navigation modes. + * + * @return Position of the selected item. + */ + public abstract int getSelectedNavigationIndex(); + + /** + * Get the number of navigation items present in the current navigation mode. + * + * @return Number of navigation items. + */ + public abstract int getNavigationItemCount(); + + /** + * Set the action bar's title. This will only be displayed if + * {@link #DISPLAY_SHOW_TITLE} is set. + * + * @param title Title to set + * + * @see #setTitle(int) + * @see #setDisplayOptions(int, int) + */ + public abstract void setTitle(CharSequence title); + + /** + * Set the action bar's title. This will only be displayed if + * {@link #DISPLAY_SHOW_TITLE} is set. + * + * @param resId Resource ID of title string to set + * + * @see #setTitle(CharSequence) + * @see #setDisplayOptions(int, int) + */ + public abstract void setTitle(int resId); + + /** + * Set the action bar's subtitle. This will only be displayed if + * {@link #DISPLAY_SHOW_TITLE} is set. Set to null to disable the + * subtitle entirely. + * + * @param subtitle Subtitle to set + * + * @see #setSubtitle(int) + * @see #setDisplayOptions(int, int) + */ + public abstract void setSubtitle(CharSequence subtitle); + + /** + * Set the action bar's subtitle. This will only be displayed if + * {@link #DISPLAY_SHOW_TITLE} is set. + * + * @param resId Resource ID of subtitle string to set + * + * @see #setSubtitle(CharSequence) + * @see #setDisplayOptions(int, int) + */ + public abstract void setSubtitle(int resId); + + /** + * Set display options. This changes all display option bits at once. To change + * a limited subset of display options, see {@link #setDisplayOptions(int, int)}. + * + * @param options A combination of the bits defined by the DISPLAY_ constants + * defined in ActionBar. + */ + public abstract void setDisplayOptions(int options); + + /** + * Set selected display options. Only the options specified by mask will be changed. + * To change all display option bits at once, see {@link #setDisplayOptions(int)}. + * + *

Example: setDisplayOptions(0, DISPLAY_SHOW_HOME) will disable the + * {@link #DISPLAY_SHOW_HOME} option. + * setDisplayOptions(DISPLAY_SHOW_HOME, DISPLAY_SHOW_HOME | DISPLAY_USE_LOGO) + * will enable {@link #DISPLAY_SHOW_HOME} and disable {@link #DISPLAY_USE_LOGO}. + * + * @param options A combination of the bits defined by the DISPLAY_ constants + * defined in ActionBar. + * @param mask A bit mask declaring which display options should be changed. + */ + public abstract void setDisplayOptions(int options, int mask); + + /** + * Set whether to display the activity logo rather than the activity icon. + * A logo is often a wider, more detailed image. + * + *

To set several display options at once, see the setDisplayOptions methods. + * + * @param useLogo true to use the activity logo, false to use the activity icon. + * + * @see #setDisplayOptions(int) + * @see #setDisplayOptions(int, int) + */ + public abstract void setDisplayUseLogoEnabled(boolean useLogo); + + /** + * Set whether to include the application home affordance in the action bar. + * Home is presented as either an activity icon or logo. + * + *

To set several display options at once, see the setDisplayOptions methods. + * + * @param showHome true to show home, false otherwise. + * + * @see #setDisplayOptions(int) + * @see #setDisplayOptions(int, int) + */ + public abstract void setDisplayShowHomeEnabled(boolean showHome); + + /** + * Set whether home should be displayed as an "up" affordance. + * Set this to true if selecting "home" returns up by a single level in your UI + * rather than back to the top level or front page. + * + *

To set several display options at once, see the setDisplayOptions methods. + * + * @param showHomeAsUp true to show the user that selecting home will return one + * level up rather than to the top level of the app. + * + * @see #setDisplayOptions(int) + * @see #setDisplayOptions(int, int) + */ + public abstract void setDisplayHomeAsUpEnabled(boolean showHomeAsUp); + + /** + * Set whether an activity title/subtitle should be displayed. + * + *

To set several display options at once, see the setDisplayOptions methods. + * + * @param showTitle true to display a title/subtitle if present. + * + * @see #setDisplayOptions(int) + * @see #setDisplayOptions(int, int) + */ + public abstract void setDisplayShowTitleEnabled(boolean showTitle); + + /** + * Set whether a custom view should be displayed, if set. + * + *

To set several display options at once, see the setDisplayOptions methods. + * + * @param showCustom true if the currently set custom view should be displayed, false otherwise. + * + * @see #setDisplayOptions(int) + * @see #setDisplayOptions(int, int) + */ + public abstract void setDisplayShowCustomEnabled(boolean showCustom); + + /** + * Set the ActionBar's background. This will be used for the primary + * action bar. + * + * @param d Background drawable + * @see #setStackedBackgroundDrawable(Drawable) + * @see #setSplitBackgroundDrawable(Drawable) + */ + public abstract void setBackgroundDrawable(Drawable d); + + /** + * Set the ActionBar's stacked background. This will appear + * in the second row/stacked bar on some devices and configurations. + * + * @param d Background drawable for the stacked row + */ + public void setStackedBackgroundDrawable(Drawable d) { } + + /** + * Set the ActionBar's split background. This will appear in + * the split action bar containing menu-provided action buttons + * on some devices and configurations. + *

You can enable split action bar with {@link android.R.attr#uiOptions} + * + * @param d Background drawable for the split bar + */ + public void setSplitBackgroundDrawable(Drawable d) { } + + /** + * @return The current custom view. + */ + public abstract View getCustomView(); + + /** + * Returns the current ActionBar title in standard mode. + * Returns null if {@link #getNavigationMode()} would not return + * {@link #NAVIGATION_MODE_STANDARD}. + * + * @return The current ActionBar title or null. + */ + public abstract CharSequence getTitle(); + + /** + * Returns the current ActionBar subtitle in standard mode. + * Returns null if {@link #getNavigationMode()} would not return + * {@link #NAVIGATION_MODE_STANDARD}. + * + * @return The current ActionBar subtitle or null. + */ + public abstract CharSequence getSubtitle(); + + /** + * Returns the current navigation mode. The result will be one of: + *

    + *
  • {@link #NAVIGATION_MODE_STANDARD}
  • + *
  • {@link #NAVIGATION_MODE_LIST}
  • + *
  • {@link #NAVIGATION_MODE_TABS}
  • + *
+ * + * @return The current navigation mode. + */ + public abstract int getNavigationMode(); + + /** + * Set the current navigation mode. + * + * @param mode The new mode to set. + * @see #NAVIGATION_MODE_STANDARD + * @see #NAVIGATION_MODE_LIST + * @see #NAVIGATION_MODE_TABS + */ + public abstract void setNavigationMode(int mode); + + /** + * @return The current set of display options. + */ + public abstract int getDisplayOptions(); + + /** + * Create and return a new {@link Tab}. + * This tab will not be included in the action bar until it is added. + * + *

Very often tabs will be used to switch between {@link Fragment} + * objects. Here is a typical implementation of such tabs:

+ * + * {@sample development/samples/ApiDemos/src/com/example/android/apis/app/FragmentTabs.java + * complete} + * + * @return A new Tab + * + * @see #addTab(Tab) + */ + public abstract Tab newTab(); + + /** + * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list. + * If this is the first tab to be added it will become the selected tab. + * + * @param tab Tab to add + */ + public abstract void addTab(Tab tab); + + /** + * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list. + * + * @param tab Tab to add + * @param setSelected True if the added tab should become the selected tab. + */ + public abstract void addTab(Tab tab, boolean setSelected); + + /** + * Add a tab for use in tabbed navigation mode. The tab will be inserted at + * position. If this is the first tab to be added it will become + * the selected tab. + * + * @param tab The tab to add + * @param position The new position of the tab + */ + public abstract void addTab(Tab tab, int position); + + /** + * Add a tab for use in tabbed navigation mode. The tab will be insterted at + * position. + * + * @param tab The tab to add + * @param position The new position of the tab + * @param setSelected True if the added tab should become the selected tab. + */ + public abstract void addTab(Tab tab, int position, boolean setSelected); + + /** + * Remove a tab from the action bar. If the removed tab was selected it will be deselected + * and another tab will be selected if present. + * + * @param tab The tab to remove + */ + public abstract void removeTab(Tab tab); + + /** + * Remove a tab from the action bar. If the removed tab was selected it will be deselected + * and another tab will be selected if present. + * + * @param position Position of the tab to remove + */ + public abstract void removeTabAt(int position); + + /** + * Remove all tabs from the action bar and deselect the current tab. + */ + public abstract void removeAllTabs(); + + /** + * Select the specified tab. If it is not a child of this action bar it will be added. + * + *

Note: If you want to select by index, use {@link #setSelectedNavigationItem(int)}.

+ * + * @param tab Tab to select + */ + public abstract void selectTab(Tab tab); + + /** + * Returns the currently selected tab if in tabbed navigation mode and there is at least + * one tab present. + * + * @return The currently selected tab or null + */ + public abstract Tab getSelectedTab(); + + /** + * Returns the tab at the specified index. + * + * @param index Index value in the range 0-get + * @return + */ + public abstract Tab getTabAt(int index); + + /** + * Returns the number of tabs currently registered with the action bar. + * @return Tab count + */ + public abstract int getTabCount(); + + /** + * Retrieve the current height of the ActionBar. + * + * @return The ActionBar's height + */ + public abstract int getHeight(); + + /** + * Show the ActionBar if it is not currently showing. + * If the window hosting the ActionBar does not have the feature + * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application + * content to fit the new space available. + */ + public abstract void show(); + + /** + * Hide the ActionBar if it is currently showing. + * If the window hosting the ActionBar does not have the feature + * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application + * content to fit the new space available. + */ + public abstract void hide(); + + /** + * @return true if the ActionBar is showing, false otherwise. + */ + public abstract boolean isShowing(); + + /** + * Add a listener that will respond to menu visibility change events. + * + * @param listener The new listener to add + */ + public abstract void addOnMenuVisibilityListener(OnMenuVisibilityListener listener); + + /** + * Remove a menu visibility listener. This listener will no longer receive menu + * visibility change events. + * + * @param listener A listener to remove that was previously added + */ + public abstract void removeOnMenuVisibilityListener(OnMenuVisibilityListener listener); + + /** + * Enable or disable the "home" button in the corner of the action bar. (Note that this + * is the application home/up affordance on the action bar, not the systemwide home + * button.) + * + *

This defaults to true for packages targeting < API 14. For packages targeting + * API 14 or greater, the application should call this method to enable interaction + * with the home/up affordance. + * + *

Setting the {@link #DISPLAY_HOME_AS_UP} display option will automatically enable + * the home button. + * + * @param enabled true to enable the home button, false to disable the home button. + */ + public void setHomeButtonEnabled(boolean enabled) { } + + /** + * Returns a {@link Context} with an appropriate theme for creating views that + * will appear in the action bar. If you are inflating or instantiating custom views + * that will appear in an action bar, you should use the Context returned by this method. + * (This includes adapters used for list navigation mode.) + * This will ensure that views contrast properly against the action bar. + * + * @return A themed Context for creating views + */ + public Context getThemedContext() { return null; } + + /** + * Listener interface for ActionBar navigation events. + */ + public interface OnNavigationListener { + /** + * This method is called whenever a navigation item in your action bar + * is selected. + * + * @param itemPosition Position of the item clicked. + * @param itemId ID of the item clicked. + * @return True if the event was handled, false otherwise. + */ + public boolean onNavigationItemSelected(int itemPosition, long itemId); + } + + /** + * Listener for receiving events when action bar menus are shown or hidden. + */ + public interface OnMenuVisibilityListener { + /** + * Called when an action bar menu is shown or hidden. Applications may want to use + * this to tune auto-hiding behavior for the action bar or pause/resume video playback, + * gameplay, or other activity within the main content area. + * + * @param isVisible True if an action bar menu is now visible, false if no action bar + * menus are visible. + */ + public void onMenuVisibilityChanged(boolean isVisible); + } + + /** + * A tab in the action bar. + * + *

Tabs manage the hiding and showing of {@link Fragment}s. + */ + public static abstract class Tab { + /** + * An invalid position for a tab. + * + * @see #getPosition() + */ + public static final int INVALID_POSITION = -1; + + /** + * Return the current position of this tab in the action bar. + * + * @return Current position, or {@link #INVALID_POSITION} if this tab is not currently in + * the action bar. + */ + public abstract int getPosition(); + + /** + * Return the icon associated with this tab. + * + * @return The tab's icon + */ + public abstract Drawable getIcon(); + + /** + * Return the text of this tab. + * + * @return The tab's text + */ + public abstract CharSequence getText(); + + /** + * Set the icon displayed on this tab. + * + * @param icon The drawable to use as an icon + * @return The current instance for call chaining + */ + public abstract Tab setIcon(Drawable icon); + + /** + * Set the icon displayed on this tab. + * + * @param resId Resource ID referring to the drawable to use as an icon + * @return The current instance for call chaining + */ + public abstract Tab setIcon(int resId); + + /** + * Set the text displayed on this tab. Text may be truncated if there is not + * room to display the entire string. + * + * @param text The text to display + * @return The current instance for call chaining + */ + public abstract Tab setText(CharSequence text); + + /** + * Set the text displayed on this tab. Text may be truncated if there is not + * room to display the entire string. + * + * @param resId A resource ID referring to the text that should be displayed + * @return The current instance for call chaining + */ + public abstract Tab setText(int resId); + + /** + * Set a custom view to be used for this tab. This overrides values set by + * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}. + * + * @param view Custom view to be used as a tab. + * @return The current instance for call chaining + */ + public abstract Tab setCustomView(View view); + + /** + * Set a custom view to be used for this tab. This overrides values set by + * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}. + * + * @param layoutResId A layout resource to inflate and use as a custom tab view + * @return The current instance for call chaining + */ + public abstract Tab setCustomView(int layoutResId); + + /** + * Retrieve a previously set custom view for this tab. + * + * @return The custom view set by {@link #setCustomView(View)}. + */ + public abstract View getCustomView(); + + /** + * Give this Tab an arbitrary object to hold for later use. + * + * @param obj Object to store + * @return The current instance for call chaining + */ + public abstract Tab setTag(Object obj); + + /** + * @return This Tab's tag object. + */ + public abstract Object getTag(); + + /** + * Set the {@link TabListener} that will handle switching to and from this tab. + * All tabs must have a TabListener set before being added to the ActionBar. + * + * @param listener Listener to handle tab selection events + * @return The current instance for call chaining + */ + public abstract Tab setTabListener(TabListener listener); + + /** + * Select this tab. Only valid if the tab has been added to the action bar. + */ + public abstract void select(); + + /** + * Set a description of this tab's content for use in accessibility support. + * If no content description is provided the title will be used. + * + * @param resId A resource ID referring to the description text + * @return The current instance for call chaining + * @see #setContentDescription(CharSequence) + * @see #getContentDescription() + */ + public abstract Tab setContentDescription(int resId); + + /** + * Set a description of this tab's content for use in accessibility support. + * If no content description is provided the title will be used. + * + * @param contentDesc Description of this tab's content + * @return The current instance for call chaining + * @see #setContentDescription(int) + * @see #getContentDescription() + */ + public abstract Tab setContentDescription(CharSequence contentDesc); + + /** + * Gets a brief description of this tab's content for use in accessibility support. + * + * @return Description of this tab's content + * @see #setContentDescription(CharSequence) + * @see #setContentDescription(int) + */ + public abstract CharSequence getContentDescription(); + } + + /** + * Callback interface invoked when a tab is focused, unfocused, added, or removed. + */ + public interface TabListener { + /** + * Called when a tab enters the selected state. + * + * @param tab The tab that was selected + * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute + * during a tab switch. The previous tab's unselect and this tab's select will be + * executed in a single transaction. This FragmentTransaction does not support + * being added to the back stack. + */ + public void onTabSelected(Tab tab, FragmentTransaction ft); + + /** + * Called when a tab exits the selected state. + * + * @param tab The tab that was unselected + * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute + * during a tab switch. This tab's unselect and the newly selected tab's select + * will be executed in a single transaction. This FragmentTransaction does not + * support being added to the back stack. + */ + public void onTabUnselected(Tab tab, FragmentTransaction ft); + + /** + * Called when a tab that is already selected is chosen again by the user. + * Some applications may use this action to return to the top level of a category. + * + * @param tab The tab that was reselected. + * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute + * once this method returns. This FragmentTransaction does not support + * being added to the back stack. + */ + public void onTabReselected(Tab tab, FragmentTransaction ft); + } + + /** + * Per-child layout information associated with action bar custom views. + * + * @attr ref android.R.styleable#ActionBar_LayoutParams_layout_gravity + */ + public static class LayoutParams extends MarginLayoutParams { + /** + * Gravity for the view associated with these LayoutParams. + * + * @see android.view.Gravity + */ + @ViewDebug.ExportedProperty(mapping = { + @ViewDebug.IntToString(from = -1, to = "NONE"), + @ViewDebug.IntToString(from = Gravity.NO_GRAVITY, to = "NONE"), + @ViewDebug.IntToString(from = Gravity.TOP, to = "TOP"), + @ViewDebug.IntToString(from = Gravity.BOTTOM, to = "BOTTOM"), + @ViewDebug.IntToString(from = Gravity.LEFT, to = "LEFT"), + @ViewDebug.IntToString(from = Gravity.RIGHT, to = "RIGHT"), + @ViewDebug.IntToString(from = Gravity.CENTER_VERTICAL, to = "CENTER_VERTICAL"), + @ViewDebug.IntToString(from = Gravity.FILL_VERTICAL, to = "FILL_VERTICAL"), + @ViewDebug.IntToString(from = Gravity.CENTER_HORIZONTAL, to = "CENTER_HORIZONTAL"), + @ViewDebug.IntToString(from = Gravity.FILL_HORIZONTAL, to = "FILL_HORIZONTAL"), + @ViewDebug.IntToString(from = Gravity.CENTER, to = "CENTER"), + @ViewDebug.IntToString(from = Gravity.FILL, to = "FILL") + }) + public int gravity = -1; + + public LayoutParams(Context c, AttributeSet attrs) { + super(c, attrs); + } + + public LayoutParams(int width, int height) { + super(width, height); + this.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT; + } + + public LayoutParams(int width, int height, int gravity) { + super(width, height); + this.gravity = gravity; + } + + public LayoutParams(int gravity) { + this(WRAP_CONTENT, FILL_PARENT, gravity); + } + + public LayoutParams(LayoutParams source) { + super(source); + + this.gravity = source.gravity; + } + + public LayoutParams(ViewGroup.LayoutParams source) { + super(source); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockActivity.java b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockActivity.java new file mode 100644 index 000000000..9cb57e95a --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockActivity.java @@ -0,0 +1,259 @@ +package com.actionbarsherlock.app; + +import android.app.Activity; +import android.content.res.Configuration; +import android.os.Bundle; +import android.view.KeyEvent; +import android.view.View; +import android.view.Window; +import android.view.ViewGroup.LayoutParams; +import com.actionbarsherlock.ActionBarSherlock; +import com.actionbarsherlock.ActionBarSherlock.OnActionModeFinishedListener; +import com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListener; +import com.actionbarsherlock.ActionBarSherlock.OnCreatePanelMenuListener; +import com.actionbarsherlock.ActionBarSherlock.OnMenuItemSelectedListener; +import com.actionbarsherlock.ActionBarSherlock.OnPreparePanelListener; +import com.actionbarsherlock.view.ActionMode; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; + +public abstract class SherlockActivity extends Activity implements OnCreatePanelMenuListener, OnPreparePanelListener, OnMenuItemSelectedListener, OnActionModeStartedListener, OnActionModeFinishedListener { + private ActionBarSherlock mSherlock; + + protected final ActionBarSherlock getSherlock() { + if (mSherlock == null) { + mSherlock = ActionBarSherlock.wrap(this, ActionBarSherlock.FLAG_DELEGATE); + } + return mSherlock; + } + + + /////////////////////////////////////////////////////////////////////////// + // Action bar and mode + /////////////////////////////////////////////////////////////////////////// + + public ActionBar getSupportActionBar() { + return getSherlock().getActionBar(); + } + + public ActionMode startActionMode(ActionMode.Callback callback) { + return getSherlock().startActionMode(callback); + } + + @Override + public void onActionModeStarted(ActionMode mode) {} + + @Override + public void onActionModeFinished(ActionMode mode) {} + + + /////////////////////////////////////////////////////////////////////////// + // General lifecycle/callback dispatching + /////////////////////////////////////////////////////////////////////////// + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + getSherlock().dispatchConfigurationChanged(newConfig); + } + + @Override + protected void onPostResume() { + super.onPostResume(); + getSherlock().dispatchPostResume(); + } + + @Override + protected void onPause() { + getSherlock().dispatchPause(); + super.onPause(); + } + + @Override + protected void onStop() { + getSherlock().dispatchStop(); + super.onStop(); + } + + @Override + protected void onDestroy() { + getSherlock().dispatchDestroy(); + super.onDestroy(); + } + + @Override + protected void onPostCreate(Bundle savedInstanceState) { + getSherlock().dispatchPostCreate(savedInstanceState); + super.onPostCreate(savedInstanceState); + } + + @Override + protected void onTitleChanged(CharSequence title, int color) { + getSherlock().dispatchTitleChanged(title, color); + super.onTitleChanged(title, color); + } + + @Override + public final boolean onMenuOpened(int featureId, android.view.Menu menu) { + if (getSherlock().dispatchMenuOpened(featureId, menu)) { + return true; + } + return super.onMenuOpened(featureId, menu); + } + + @Override + public void onPanelClosed(int featureId, android.view.Menu menu) { + getSherlock().dispatchPanelClosed(featureId, menu); + super.onPanelClosed(featureId, menu); + } + + @Override + public boolean dispatchKeyEvent(KeyEvent event) { + if (getSherlock().dispatchKeyEvent(event)) { + return true; + } + return super.dispatchKeyEvent(event); + } + + + /////////////////////////////////////////////////////////////////////////// + // Native menu handling + /////////////////////////////////////////////////////////////////////////// + + public MenuInflater getSupportMenuInflater() { + return getSherlock().getMenuInflater(); + } + + public void invalidateOptionsMenu() { + getSherlock().dispatchInvalidateOptionsMenu(); + } + + public void supportInvalidateOptionsMenu() { + invalidateOptionsMenu(); + } + + @Override + public final boolean onCreateOptionsMenu(android.view.Menu menu) { + return getSherlock().dispatchCreateOptionsMenu(menu); + } + + @Override + public final boolean onPrepareOptionsMenu(android.view.Menu menu) { + return getSherlock().dispatchPrepareOptionsMenu(menu); + } + + @Override + public final boolean onOptionsItemSelected(android.view.MenuItem item) { + return getSherlock().dispatchOptionsItemSelected(item); + } + + @Override + public void openOptionsMenu() { + if (!getSherlock().dispatchOpenOptionsMenu()) { + super.openOptionsMenu(); + } + } + + @Override + public void closeOptionsMenu() { + if (!getSherlock().dispatchCloseOptionsMenu()) { + super.closeOptionsMenu(); + } + } + + + /////////////////////////////////////////////////////////////////////////// + // Sherlock menu handling + /////////////////////////////////////////////////////////////////////////// + + @Override + public boolean onCreatePanelMenu(int featureId, Menu menu) { + if (featureId == Window.FEATURE_OPTIONS_PANEL) { + return onCreateOptionsMenu(menu); + } + return false; + } + + public boolean onCreateOptionsMenu(Menu menu) { + return true; + } + + @Override + public boolean onPreparePanel(int featureId, View view, Menu menu) { + if (featureId == Window.FEATURE_OPTIONS_PANEL) { + return onPrepareOptionsMenu(menu); + } + return false; + } + + public boolean onPrepareOptionsMenu(Menu menu) { + return true; + } + + @Override + public boolean onMenuItemSelected(int featureId, MenuItem item) { + if (featureId == Window.FEATURE_OPTIONS_PANEL) { + return onOptionsItemSelected(item); + } + return false; + } + + public boolean onOptionsItemSelected(MenuItem item) { + return false; + } + + + /////////////////////////////////////////////////////////////////////////// + // Content + /////////////////////////////////////////////////////////////////////////// + + @Override + public void addContentView(View view, LayoutParams params) { + getSherlock().addContentView(view, params); + } + + @Override + public void setContentView(int layoutResId) { + getSherlock().setContentView(layoutResId); + } + + @Override + public void setContentView(View view, LayoutParams params) { + getSherlock().setContentView(view, params); + } + + @Override + public void setContentView(View view) { + getSherlock().setContentView(view); + } + + public void requestWindowFeature(long featureId) { + getSherlock().requestFeature((int)featureId); + } + + + /////////////////////////////////////////////////////////////////////////// + // Progress Indication + /////////////////////////////////////////////////////////////////////////// + + public void setSupportProgress(int progress) { + getSherlock().setProgress(progress); + } + + public void setSupportProgressBarIndeterminate(boolean indeterminate) { + getSherlock().setProgressBarIndeterminate(indeterminate); + } + + public void setSupportProgressBarIndeterminateVisibility(boolean visible) { + getSherlock().setProgressBarIndeterminateVisibility(visible); + } + + public void setSupportProgressBarVisibility(boolean visible) { + getSherlock().setProgressBarVisibility(visible); + } + + public void setSupportSecondaryProgress(int secondaryProgress) { + getSherlock().setSecondaryProgress(secondaryProgress); + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockDialogFragment.java b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockDialogFragment.java new file mode 100644 index 000000000..a7c856bf0 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockDialogFragment.java @@ -0,0 +1,68 @@ +package com.actionbarsherlock.app; + +import android.app.Activity; +import android.support.v4.app.DialogFragment; +import com.actionbarsherlock.internal.view.menu.MenuItemWrapper; +import com.actionbarsherlock.internal.view.menu.MenuWrapper; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; + +import static com.actionbarsherlock.app.SherlockFragmentActivity.OnCreateOptionsMenuListener; +import static com.actionbarsherlock.app.SherlockFragmentActivity.OnOptionsItemSelectedListener; +import static com.actionbarsherlock.app.SherlockFragmentActivity.OnPrepareOptionsMenuListener; + +public class SherlockDialogFragment extends DialogFragment implements OnCreateOptionsMenuListener, OnPrepareOptionsMenuListener, OnOptionsItemSelectedListener { + private SherlockFragmentActivity mActivity; + + public SherlockFragmentActivity getSherlockActivity() { + return mActivity; + } + + @Override + public void onAttach(Activity activity) { + if (!(activity instanceof SherlockFragmentActivity)) { + throw new IllegalStateException(getClass().getSimpleName() + " must be attached to a SherlockFragmentActivity."); + } + mActivity = (SherlockFragmentActivity)activity; + + super.onAttach(activity); + } + + @Override + public void onDetach() { + mActivity = null; + super.onDetach(); + } + + @Override + public final void onCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater) { + onCreateOptionsMenu(new MenuWrapper(menu), mActivity.getSupportMenuInflater()); + } + + @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + //Nothing to see here. + } + + @Override + public final void onPrepareOptionsMenu(android.view.Menu menu) { + onPrepareOptionsMenu(new MenuWrapper(menu)); + } + + @Override + public void onPrepareOptionsMenu(Menu menu) { + //Nothing to see here. + } + + @Override + public final boolean onOptionsItemSelected(android.view.MenuItem item) { + return onOptionsItemSelected(new MenuItemWrapper(item)); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + //Nothing to see here. + return false; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockExpandableListActivity.java b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockExpandableListActivity.java new file mode 100644 index 000000000..078f9b0ca --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockExpandableListActivity.java @@ -0,0 +1,259 @@ +package com.actionbarsherlock.app; + +import android.app.ExpandableListActivity; +import android.content.res.Configuration; +import android.os.Bundle; +import android.view.KeyEvent; +import android.view.View; +import android.view.ViewGroup.LayoutParams; +import android.view.Window; +import com.actionbarsherlock.ActionBarSherlock; +import com.actionbarsherlock.ActionBarSherlock.OnActionModeFinishedListener; +import com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListener; +import com.actionbarsherlock.ActionBarSherlock.OnCreatePanelMenuListener; +import com.actionbarsherlock.ActionBarSherlock.OnMenuItemSelectedListener; +import com.actionbarsherlock.ActionBarSherlock.OnPreparePanelListener; +import com.actionbarsherlock.view.ActionMode; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; + +public abstract class SherlockExpandableListActivity extends ExpandableListActivity implements OnCreatePanelMenuListener, OnPreparePanelListener, OnMenuItemSelectedListener, OnActionModeStartedListener, OnActionModeFinishedListener { + private ActionBarSherlock mSherlock; + + protected final ActionBarSherlock getSherlock() { + if (mSherlock == null) { + mSherlock = ActionBarSherlock.wrap(this, ActionBarSherlock.FLAG_DELEGATE); + } + return mSherlock; + } + + + /////////////////////////////////////////////////////////////////////////// + // Action bar and mode + /////////////////////////////////////////////////////////////////////////// + + public ActionBar getSupportActionBar() { + return getSherlock().getActionBar(); + } + + public ActionMode startActionMode(ActionMode.Callback callback) { + return getSherlock().startActionMode(callback); + } + + @Override + public void onActionModeStarted(ActionMode mode) {} + + @Override + public void onActionModeFinished(ActionMode mode) {} + + + /////////////////////////////////////////////////////////////////////////// + // General lifecycle/callback dispatching + /////////////////////////////////////////////////////////////////////////// + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + getSherlock().dispatchConfigurationChanged(newConfig); + } + + @Override + protected void onPostResume() { + super.onPostResume(); + getSherlock().dispatchPostResume(); + } + + @Override + protected void onPause() { + getSherlock().dispatchPause(); + super.onPause(); + } + + @Override + protected void onStop() { + getSherlock().dispatchStop(); + super.onStop(); + } + + @Override + protected void onDestroy() { + getSherlock().dispatchDestroy(); + super.onDestroy(); + } + + @Override + protected void onPostCreate(Bundle savedInstanceState) { + getSherlock().dispatchPostCreate(savedInstanceState); + super.onPostCreate(savedInstanceState); + } + + @Override + protected void onTitleChanged(CharSequence title, int color) { + getSherlock().dispatchTitleChanged(title, color); + super.onTitleChanged(title, color); + } + + @Override + public final boolean onMenuOpened(int featureId, android.view.Menu menu) { + if (getSherlock().dispatchMenuOpened(featureId, menu)) { + return true; + } + return super.onMenuOpened(featureId, menu); + } + + @Override + public void onPanelClosed(int featureId, android.view.Menu menu) { + getSherlock().dispatchPanelClosed(featureId, menu); + super.onPanelClosed(featureId, menu); + } + + @Override + public boolean dispatchKeyEvent(KeyEvent event) { + if (getSherlock().dispatchKeyEvent(event)) { + return true; + } + return super.dispatchKeyEvent(event); + } + + + /////////////////////////////////////////////////////////////////////////// + // Native menu handling + /////////////////////////////////////////////////////////////////////////// + + public MenuInflater getSupportMenuInflater() { + return getSherlock().getMenuInflater(); + } + + public void invalidateOptionsMenu() { + getSherlock().dispatchInvalidateOptionsMenu(); + } + + public void supportInvalidateOptionsMenu() { + invalidateOptionsMenu(); + } + + @Override + public final boolean onCreateOptionsMenu(android.view.Menu menu) { + return getSherlock().dispatchCreateOptionsMenu(menu); + } + + @Override + public final boolean onPrepareOptionsMenu(android.view.Menu menu) { + return getSherlock().dispatchPrepareOptionsMenu(menu); + } + + @Override + public final boolean onOptionsItemSelected(android.view.MenuItem item) { + return getSherlock().dispatchOptionsItemSelected(item); + } + + @Override + public void openOptionsMenu() { + if (!getSherlock().dispatchOpenOptionsMenu()) { + super.openOptionsMenu(); + } + } + + @Override + public void closeOptionsMenu() { + if (!getSherlock().dispatchCloseOptionsMenu()) { + super.closeOptionsMenu(); + } + } + + + /////////////////////////////////////////////////////////////////////////// + // Sherlock menu handling + /////////////////////////////////////////////////////////////////////////// + + @Override + public boolean onCreatePanelMenu(int featureId, Menu menu) { + if (featureId == Window.FEATURE_OPTIONS_PANEL) { + return onCreateOptionsMenu(menu); + } + return false; + } + + public boolean onCreateOptionsMenu(Menu menu) { + return true; + } + + @Override + public boolean onPreparePanel(int featureId, View view, Menu menu) { + if (featureId == Window.FEATURE_OPTIONS_PANEL) { + return onPrepareOptionsMenu(menu); + } + return false; + } + + public boolean onPrepareOptionsMenu(Menu menu) { + return true; + } + + @Override + public boolean onMenuItemSelected(int featureId, MenuItem item) { + if (featureId == Window.FEATURE_OPTIONS_PANEL) { + return onOptionsItemSelected(item); + } + return false; + } + + public boolean onOptionsItemSelected(MenuItem item) { + return false; + } + + + /////////////////////////////////////////////////////////////////////////// + // Content + /////////////////////////////////////////////////////////////////////////// + + @Override + public void addContentView(View view, LayoutParams params) { + getSherlock().addContentView(view, params); + } + + @Override + public void setContentView(int layoutResId) { + getSherlock().setContentView(layoutResId); + } + + @Override + public void setContentView(View view, LayoutParams params) { + getSherlock().setContentView(view, params); + } + + @Override + public void setContentView(View view) { + getSherlock().setContentView(view); + } + + public void requestWindowFeature(long featureId) { + getSherlock().requestFeature((int)featureId); + } + + + /////////////////////////////////////////////////////////////////////////// + // Progress Indication + /////////////////////////////////////////////////////////////////////////// + + public void setSupportProgress(int progress) { + getSherlock().setProgress(progress); + } + + public void setSupportProgressBarIndeterminate(boolean indeterminate) { + getSherlock().setProgressBarIndeterminate(indeterminate); + } + + public void setSupportProgressBarIndeterminateVisibility(boolean visible) { + getSherlock().setProgressBarIndeterminateVisibility(visible); + } + + public void setSupportProgressBarVisibility(boolean visible) { + getSherlock().setProgressBarVisibility(visible); + } + + public void setSupportSecondaryProgress(int secondaryProgress) { + getSherlock().setSecondaryProgress(secondaryProgress); + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockFragment.java b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockFragment.java new file mode 100644 index 000000000..0f24e9c85 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockFragment.java @@ -0,0 +1,68 @@ +package com.actionbarsherlock.app; + +import android.app.Activity; +import android.support.v4.app.Fragment; +import com.actionbarsherlock.internal.view.menu.MenuItemWrapper; +import com.actionbarsherlock.internal.view.menu.MenuWrapper; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; + +import static com.actionbarsherlock.app.SherlockFragmentActivity.OnCreateOptionsMenuListener; +import static com.actionbarsherlock.app.SherlockFragmentActivity.OnOptionsItemSelectedListener; +import static com.actionbarsherlock.app.SherlockFragmentActivity.OnPrepareOptionsMenuListener; + +public class SherlockFragment extends Fragment implements OnCreateOptionsMenuListener, OnPrepareOptionsMenuListener, OnOptionsItemSelectedListener { + private SherlockFragmentActivity mActivity; + + public SherlockFragmentActivity getSherlockActivity() { + return mActivity; + } + + @Override + public void onAttach(Activity activity) { + if (!(activity instanceof SherlockFragmentActivity)) { + throw new IllegalStateException(getClass().getSimpleName() + " must be attached to a SherlockFragmentActivity."); + } + mActivity = (SherlockFragmentActivity)activity; + + super.onAttach(activity); + } + + @Override + public void onDetach() { + mActivity = null; + super.onDetach(); + } + + @Override + public final void onCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater) { + onCreateOptionsMenu(new MenuWrapper(menu), mActivity.getSupportMenuInflater()); + } + + @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + //Nothing to see here. + } + + @Override + public final void onPrepareOptionsMenu(android.view.Menu menu) { + onPrepareOptionsMenu(new MenuWrapper(menu)); + } + + @Override + public void onPrepareOptionsMenu(Menu menu) { + //Nothing to see here. + } + + @Override + public final boolean onOptionsItemSelected(android.view.MenuItem item) { + return onOptionsItemSelected(new MenuItemWrapper(item)); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + //Nothing to see here. + return false; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockFragmentActivity.java b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockFragmentActivity.java new file mode 100644 index 000000000..5cd13ba7c --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockFragmentActivity.java @@ -0,0 +1,292 @@ +package com.actionbarsherlock.app; + +import android.content.res.Configuration; +import android.os.Bundle; +import android.support.v4.app._ActionBarSherlockTrojanHorse; +import android.util.Log; +import android.view.KeyEvent; +import android.view.View; +import android.view.ViewGroup.LayoutParams; +import android.view.Window; +import com.actionbarsherlock.ActionBarSherlock; +import com.actionbarsherlock.view.ActionMode; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; + +import static com.actionbarsherlock.ActionBarSherlock.OnActionModeFinishedListener; +import static com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListener; + +/** @see {@link _ActionBarSherlockTrojanHorse} */ +public class SherlockFragmentActivity extends _ActionBarSherlockTrojanHorse implements OnActionModeStartedListener, OnActionModeFinishedListener { + private static final boolean DEBUG = false; + private static final String TAG = "SherlockFragmentActivity"; + + private ActionBarSherlock mSherlock; + private boolean mIgnoreNativeCreate = false; + private boolean mIgnoreNativePrepare = false; + private boolean mIgnoreNativeSelected = false; + + protected final ActionBarSherlock getSherlock() { + if (mSherlock == null) { + mSherlock = ActionBarSherlock.wrap(this, ActionBarSherlock.FLAG_DELEGATE); + } + return mSherlock; + } + + + /////////////////////////////////////////////////////////////////////////// + // Action bar and mode + /////////////////////////////////////////////////////////////////////////// + + public ActionBar getSupportActionBar() { + return getSherlock().getActionBar(); + } + + public ActionMode startActionMode(ActionMode.Callback callback) { + return getSherlock().startActionMode(callback); + } + + @Override + public void onActionModeStarted(ActionMode mode) {} + + @Override + public void onActionModeFinished(ActionMode mode) {} + + + /////////////////////////////////////////////////////////////////////////// + // General lifecycle/callback dispatching + /////////////////////////////////////////////////////////////////////////// + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + getSherlock().dispatchConfigurationChanged(newConfig); + } + + @Override + protected void onPostResume() { + super.onPostResume(); + getSherlock().dispatchPostResume(); + } + + @Override + protected void onPause() { + getSherlock().dispatchPause(); + super.onPause(); + } + + @Override + protected void onStop() { + getSherlock().dispatchStop(); + super.onStop(); + } + + @Override + protected void onDestroy() { + getSherlock().dispatchDestroy(); + super.onDestroy(); + } + + @Override + protected void onPostCreate(Bundle savedInstanceState) { + getSherlock().dispatchPostCreate(savedInstanceState); + super.onPostCreate(savedInstanceState); + } + + @Override + protected void onTitleChanged(CharSequence title, int color) { + getSherlock().dispatchTitleChanged(title, color); + super.onTitleChanged(title, color); + } + + @Override + public final boolean onMenuOpened(int featureId, android.view.Menu menu) { + if (getSherlock().dispatchMenuOpened(featureId, menu)) { + return true; + } + return super.onMenuOpened(featureId, menu); + } + + @Override + public void onPanelClosed(int featureId, android.view.Menu menu) { + getSherlock().dispatchPanelClosed(featureId, menu); + super.onPanelClosed(featureId, menu); + } + + @Override + public boolean dispatchKeyEvent(KeyEvent event) { + if (getSherlock().dispatchKeyEvent(event)) { + return true; + } + return super.dispatchKeyEvent(event); + } + + + /////////////////////////////////////////////////////////////////////////// + // Native menu handling + /////////////////////////////////////////////////////////////////////////// + + public MenuInflater getSupportMenuInflater() { + if (DEBUG) Log.d(TAG, "[getSupportMenuInflater]"); + + return getSherlock().getMenuInflater(); + } + + public void invalidateOptionsMenu() { + if (DEBUG) Log.d(TAG, "[invalidateOptionsMenu]"); + + getSherlock().dispatchInvalidateOptionsMenu(); + } + + public void supportInvalidateOptionsMenu() { + if (DEBUG) Log.d(TAG, "[supportInvalidateOptionsMenu]"); + + invalidateOptionsMenu(); + } + + @Override + public final boolean onCreatePanelMenu(int featureId, android.view.Menu menu) { + if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] featureId: " + featureId + ", menu: " + menu); + + if (featureId == Window.FEATURE_OPTIONS_PANEL && !mIgnoreNativeCreate) { + mIgnoreNativeCreate = true; + boolean result = getSherlock().dispatchCreateOptionsMenu(menu); + mIgnoreNativeCreate = false; + + if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] returning " + result); + return result; + } + return super.onCreatePanelMenu(featureId, menu); + } + + @Override + public final boolean onCreateOptionsMenu(android.view.Menu menu) { + return true; + } + + @Override + public final boolean onPreparePanel(int featureId, View view, android.view.Menu menu) { + if (DEBUG) Log.d(TAG, "[onPreparePanel] featureId: " + featureId + ", view: " + view + ", menu: " + menu); + + if (featureId == Window.FEATURE_OPTIONS_PANEL && !mIgnoreNativePrepare) { + mIgnoreNativePrepare = true; + boolean result = getSherlock().dispatchPrepareOptionsMenu(menu); + mIgnoreNativePrepare = false; + + if (DEBUG) Log.d(TAG, "[onPreparePanel] returning " + result); + return result; + } + return super.onPreparePanel(featureId, view, menu); + } + + @Override + public final boolean onPrepareOptionsMenu(android.view.Menu menu) { + return true; + } + + @Override + public final boolean onMenuItemSelected(int featureId, android.view.MenuItem item) { + if (DEBUG) Log.d(TAG, "[onMenuItemSelected] featureId: " + featureId + ", item: " + item); + + if (featureId == Window.FEATURE_OPTIONS_PANEL && !mIgnoreNativeSelected) { + mIgnoreNativeSelected = true; + boolean result = getSherlock().dispatchOptionsItemSelected(item); + mIgnoreNativeSelected = false; + + if (DEBUG) Log.d(TAG, "[onMenuItemSelected] returning " + result); + return result; + } + return super.onMenuItemSelected(featureId, item); + } + + @Override + public final boolean onOptionsItemSelected(android.view.MenuItem item) { + return false; + } + + @Override + public void openOptionsMenu() { + if (!getSherlock().dispatchOpenOptionsMenu()) { + super.openOptionsMenu(); + } + } + + @Override + public void closeOptionsMenu() { + if (!getSherlock().dispatchCloseOptionsMenu()) { + super.closeOptionsMenu(); + } + } + + + /////////////////////////////////////////////////////////////////////////// + // Sherlock menu handling + /////////////////////////////////////////////////////////////////////////// + + public boolean onCreateOptionsMenu(Menu menu) { + return true; + } + + public boolean onPrepareOptionsMenu(Menu menu) { + return true; + } + + public boolean onOptionsItemSelected(MenuItem item) { + return false; + } + + + /////////////////////////////////////////////////////////////////////////// + // Content + /////////////////////////////////////////////////////////////////////////// + + @Override + public void addContentView(View view, LayoutParams params) { + getSherlock().addContentView(view, params); + } + + @Override + public void setContentView(int layoutResId) { + getSherlock().setContentView(layoutResId); + } + + @Override + public void setContentView(View view, LayoutParams params) { + getSherlock().setContentView(view, params); + } + + @Override + public void setContentView(View view) { + getSherlock().setContentView(view); + } + + public void requestWindowFeature(long featureId) { + getSherlock().requestFeature((int)featureId); + } + + + /////////////////////////////////////////////////////////////////////////// + // Progress Indication + /////////////////////////////////////////////////////////////////////////// + + public void setSupportProgress(int progress) { + getSherlock().setProgress(progress); + } + + public void setSupportProgressBarIndeterminate(boolean indeterminate) { + getSherlock().setProgressBarIndeterminate(indeterminate); + } + + public void setSupportProgressBarIndeterminateVisibility(boolean visible) { + getSherlock().setProgressBarIndeterminateVisibility(visible); + } + + public void setSupportProgressBarVisibility(boolean visible) { + getSherlock().setProgressBarVisibility(visible); + } + + public void setSupportSecondaryProgress(int secondaryProgress) { + getSherlock().setSecondaryProgress(secondaryProgress); + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockListActivity.java b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockListActivity.java new file mode 100644 index 000000000..00c00fee5 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockListActivity.java @@ -0,0 +1,259 @@ +package com.actionbarsherlock.app; + +import android.app.ListActivity; +import android.content.res.Configuration; +import android.os.Bundle; +import android.view.KeyEvent; +import android.view.View; +import android.view.Window; +import android.view.ViewGroup.LayoutParams; +import com.actionbarsherlock.ActionBarSherlock; +import com.actionbarsherlock.ActionBarSherlock.OnActionModeFinishedListener; +import com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListener; +import com.actionbarsherlock.ActionBarSherlock.OnCreatePanelMenuListener; +import com.actionbarsherlock.ActionBarSherlock.OnMenuItemSelectedListener; +import com.actionbarsherlock.ActionBarSherlock.OnPreparePanelListener; +import com.actionbarsherlock.view.ActionMode; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; + +public abstract class SherlockListActivity extends ListActivity implements OnCreatePanelMenuListener, OnPreparePanelListener, OnMenuItemSelectedListener, OnActionModeStartedListener, OnActionModeFinishedListener { + private ActionBarSherlock mSherlock; + + protected final ActionBarSherlock getSherlock() { + if (mSherlock == null) { + mSherlock = ActionBarSherlock.wrap(this, ActionBarSherlock.FLAG_DELEGATE); + } + return mSherlock; + } + + + /////////////////////////////////////////////////////////////////////////// + // Action bar and mode + /////////////////////////////////////////////////////////////////////////// + + public ActionBar getSupportActionBar() { + return getSherlock().getActionBar(); + } + + public ActionMode startActionMode(ActionMode.Callback callback) { + return getSherlock().startActionMode(callback); + } + + @Override + public void onActionModeStarted(ActionMode mode) {} + + @Override + public void onActionModeFinished(ActionMode mode) {} + + + /////////////////////////////////////////////////////////////////////////// + // General lifecycle/callback dispatching + /////////////////////////////////////////////////////////////////////////// + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + getSherlock().dispatchConfigurationChanged(newConfig); + } + + @Override + protected void onPostResume() { + super.onPostResume(); + getSherlock().dispatchPostResume(); + } + + @Override + protected void onPause() { + getSherlock().dispatchPause(); + super.onPause(); + } + + @Override + protected void onStop() { + getSherlock().dispatchStop(); + super.onStop(); + } + + @Override + protected void onDestroy() { + getSherlock().dispatchDestroy(); + super.onDestroy(); + } + + @Override + protected void onPostCreate(Bundle savedInstanceState) { + getSherlock().dispatchPostCreate(savedInstanceState); + super.onPostCreate(savedInstanceState); + } + + @Override + protected void onTitleChanged(CharSequence title, int color) { + getSherlock().dispatchTitleChanged(title, color); + super.onTitleChanged(title, color); + } + + @Override + public final boolean onMenuOpened(int featureId, android.view.Menu menu) { + if (getSherlock().dispatchMenuOpened(featureId, menu)) { + return true; + } + return super.onMenuOpened(featureId, menu); + } + + @Override + public void onPanelClosed(int featureId, android.view.Menu menu) { + getSherlock().dispatchPanelClosed(featureId, menu); + super.onPanelClosed(featureId, menu); + } + + @Override + public boolean dispatchKeyEvent(KeyEvent event) { + if (getSherlock().dispatchKeyEvent(event)) { + return true; + } + return super.dispatchKeyEvent(event); + } + + + /////////////////////////////////////////////////////////////////////////// + // Native menu handling + /////////////////////////////////////////////////////////////////////////// + + public MenuInflater getSupportMenuInflater() { + return getSherlock().getMenuInflater(); + } + + public void invalidateOptionsMenu() { + getSherlock().dispatchInvalidateOptionsMenu(); + } + + public void supportInvalidateOptionsMenu() { + invalidateOptionsMenu(); + } + + @Override + public final boolean onCreateOptionsMenu(android.view.Menu menu) { + return getSherlock().dispatchCreateOptionsMenu(menu); + } + + @Override + public final boolean onPrepareOptionsMenu(android.view.Menu menu) { + return getSherlock().dispatchPrepareOptionsMenu(menu); + } + + @Override + public final boolean onOptionsItemSelected(android.view.MenuItem item) { + return getSherlock().dispatchOptionsItemSelected(item); + } + + @Override + public void openOptionsMenu() { + if (!getSherlock().dispatchOpenOptionsMenu()) { + super.openOptionsMenu(); + } + } + + @Override + public void closeOptionsMenu() { + if (!getSherlock().dispatchCloseOptionsMenu()) { + super.closeOptionsMenu(); + } + } + + + /////////////////////////////////////////////////////////////////////////// + // Sherlock menu handling + /////////////////////////////////////////////////////////////////////////// + + @Override + public boolean onCreatePanelMenu(int featureId, Menu menu) { + if (featureId == Window.FEATURE_OPTIONS_PANEL) { + return onCreateOptionsMenu(menu); + } + return false; + } + + public boolean onCreateOptionsMenu(Menu menu) { + return true; + } + + @Override + public boolean onPreparePanel(int featureId, View view, Menu menu) { + if (featureId == Window.FEATURE_OPTIONS_PANEL) { + return onPrepareOptionsMenu(menu); + } + return false; + } + + public boolean onPrepareOptionsMenu(Menu menu) { + return true; + } + + @Override + public boolean onMenuItemSelected(int featureId, MenuItem item) { + if (featureId == Window.FEATURE_OPTIONS_PANEL) { + return onOptionsItemSelected(item); + } + return false; + } + + public boolean onOptionsItemSelected(MenuItem item) { + return false; + } + + + /////////////////////////////////////////////////////////////////////////// + // Content + /////////////////////////////////////////////////////////////////////////// + + @Override + public void addContentView(View view, LayoutParams params) { + getSherlock().addContentView(view, params); + } + + @Override + public void setContentView(int layoutResId) { + getSherlock().setContentView(layoutResId); + } + + @Override + public void setContentView(View view, LayoutParams params) { + getSherlock().setContentView(view, params); + } + + @Override + public void setContentView(View view) { + getSherlock().setContentView(view); + } + + public void requestWindowFeature(long featureId) { + getSherlock().requestFeature((int)featureId); + } + + + /////////////////////////////////////////////////////////////////////////// + // Progress Indication + /////////////////////////////////////////////////////////////////////////// + + public void setSupportProgress(int progress) { + getSherlock().setProgress(progress); + } + + public void setSupportProgressBarIndeterminate(boolean indeterminate) { + getSherlock().setProgressBarIndeterminate(indeterminate); + } + + public void setSupportProgressBarIndeterminateVisibility(boolean visible) { + getSherlock().setProgressBarIndeterminateVisibility(visible); + } + + public void setSupportProgressBarVisibility(boolean visible) { + getSherlock().setProgressBarVisibility(visible); + } + + public void setSupportSecondaryProgress(int secondaryProgress) { + getSherlock().setSecondaryProgress(secondaryProgress); + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockListFragment.java b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockListFragment.java new file mode 100644 index 000000000..13ca3c49f --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockListFragment.java @@ -0,0 +1,68 @@ +package com.actionbarsherlock.app; + +import android.app.Activity; +import android.support.v4.app.ListFragment; +import com.actionbarsherlock.internal.view.menu.MenuItemWrapper; +import com.actionbarsherlock.internal.view.menu.MenuWrapper; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; + +import static com.actionbarsherlock.app.SherlockFragmentActivity.OnCreateOptionsMenuListener; +import static com.actionbarsherlock.app.SherlockFragmentActivity.OnOptionsItemSelectedListener; +import static com.actionbarsherlock.app.SherlockFragmentActivity.OnPrepareOptionsMenuListener; + +public class SherlockListFragment extends ListFragment implements OnCreateOptionsMenuListener, OnPrepareOptionsMenuListener, OnOptionsItemSelectedListener { + private SherlockFragmentActivity mActivity; + + public SherlockFragmentActivity getSherlockActivity() { + return mActivity; + } + + @Override + public void onAttach(Activity activity) { + if (!(activity instanceof SherlockFragmentActivity)) { + throw new IllegalStateException(getClass().getSimpleName() + " must be attached to a SherlockFragmentActivity."); + } + mActivity = (SherlockFragmentActivity)activity; + + super.onAttach(activity); + } + + @Override + public void onDetach() { + mActivity = null; + super.onDetach(); + } + + @Override + public final void onCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater) { + onCreateOptionsMenu(new MenuWrapper(menu), mActivity.getSupportMenuInflater()); + } + + @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + //Nothing to see here. + } + + @Override + public final void onPrepareOptionsMenu(android.view.Menu menu) { + onPrepareOptionsMenu(new MenuWrapper(menu)); + } + + @Override + public void onPrepareOptionsMenu(Menu menu) { + //Nothing to see here. + } + + @Override + public final boolean onOptionsItemSelected(android.view.MenuItem item) { + return onOptionsItemSelected(new MenuItemWrapper(item)); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + //Nothing to see here. + return false; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockPreferenceActivity.java b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockPreferenceActivity.java new file mode 100644 index 000000000..4f80be515 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockPreferenceActivity.java @@ -0,0 +1,259 @@ +package com.actionbarsherlock.app; + +import android.content.res.Configuration; +import android.os.Bundle; +import android.preference.PreferenceActivity; +import android.view.KeyEvent; +import android.view.View; +import android.view.ViewGroup.LayoutParams; +import android.view.Window; +import com.actionbarsherlock.ActionBarSherlock; +import com.actionbarsherlock.ActionBarSherlock.OnActionModeFinishedListener; +import com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListener; +import com.actionbarsherlock.ActionBarSherlock.OnCreatePanelMenuListener; +import com.actionbarsherlock.ActionBarSherlock.OnMenuItemSelectedListener; +import com.actionbarsherlock.ActionBarSherlock.OnPreparePanelListener; +import com.actionbarsherlock.view.ActionMode; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; + +public abstract class SherlockPreferenceActivity extends PreferenceActivity implements OnCreatePanelMenuListener, OnPreparePanelListener, OnMenuItemSelectedListener, OnActionModeStartedListener, OnActionModeFinishedListener { + private ActionBarSherlock mSherlock; + + protected final ActionBarSherlock getSherlock() { + if (mSherlock == null) { + mSherlock = ActionBarSherlock.wrap(this, ActionBarSherlock.FLAG_DELEGATE); + } + return mSherlock; + } + + + /////////////////////////////////////////////////////////////////////////// + // Action bar and mode + /////////////////////////////////////////////////////////////////////////// + + public ActionBar getSupportActionBar() { + return getSherlock().getActionBar(); + } + + public ActionMode startActionMode(ActionMode.Callback callback) { + return getSherlock().startActionMode(callback); + } + + @Override + public void onActionModeStarted(ActionMode mode) {} + + @Override + public void onActionModeFinished(ActionMode mode) {} + + + /////////////////////////////////////////////////////////////////////////// + // General lifecycle/callback dispatching + /////////////////////////////////////////////////////////////////////////// + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + getSherlock().dispatchConfigurationChanged(newConfig); + } + + @Override + protected void onPostResume() { + super.onPostResume(); + getSherlock().dispatchPostResume(); + } + + @Override + protected void onPause() { + getSherlock().dispatchPause(); + super.onPause(); + } + + @Override + protected void onStop() { + getSherlock().dispatchStop(); + super.onStop(); + } + + @Override + protected void onDestroy() { + getSherlock().dispatchDestroy(); + super.onDestroy(); + } + + @Override + protected void onPostCreate(Bundle savedInstanceState) { + getSherlock().dispatchPostCreate(savedInstanceState); + super.onPostCreate(savedInstanceState); + } + + @Override + protected void onTitleChanged(CharSequence title, int color) { + getSherlock().dispatchTitleChanged(title, color); + super.onTitleChanged(title, color); + } + + @Override + public final boolean onMenuOpened(int featureId, android.view.Menu menu) { + if (getSherlock().dispatchMenuOpened(featureId, menu)) { + return true; + } + return super.onMenuOpened(featureId, menu); + } + + @Override + public void onPanelClosed(int featureId, android.view.Menu menu) { + getSherlock().dispatchPanelClosed(featureId, menu); + super.onPanelClosed(featureId, menu); + } + + @Override + public boolean dispatchKeyEvent(KeyEvent event) { + if (getSherlock().dispatchKeyEvent(event)) { + return true; + } + return super.dispatchKeyEvent(event); + } + + + /////////////////////////////////////////////////////////////////////////// + // Native menu handling + /////////////////////////////////////////////////////////////////////////// + + public MenuInflater getSupportMenuInflater() { + return getSherlock().getMenuInflater(); + } + + public void invalidateOptionsMenu() { + getSherlock().dispatchInvalidateOptionsMenu(); + } + + public void supportInvalidateOptionsMenu() { + invalidateOptionsMenu(); + } + + @Override + public final boolean onCreateOptionsMenu(android.view.Menu menu) { + return getSherlock().dispatchCreateOptionsMenu(menu); + } + + @Override + public final boolean onPrepareOptionsMenu(android.view.Menu menu) { + return getSherlock().dispatchPrepareOptionsMenu(menu); + } + + @Override + public final boolean onOptionsItemSelected(android.view.MenuItem item) { + return getSherlock().dispatchOptionsItemSelected(item); + } + + @Override + public void openOptionsMenu() { + if (!getSherlock().dispatchOpenOptionsMenu()) { + super.openOptionsMenu(); + } + } + + @Override + public void closeOptionsMenu() { + if (!getSherlock().dispatchCloseOptionsMenu()) { + super.closeOptionsMenu(); + } + } + + + /////////////////////////////////////////////////////////////////////////// + // Sherlock menu handling + /////////////////////////////////////////////////////////////////////////// + + @Override + public boolean onCreatePanelMenu(int featureId, Menu menu) { + if (featureId == Window.FEATURE_OPTIONS_PANEL) { + return onCreateOptionsMenu(menu); + } + return false; + } + + public boolean onCreateOptionsMenu(Menu menu) { + return true; + } + + @Override + public boolean onPreparePanel(int featureId, View view, Menu menu) { + if (featureId == Window.FEATURE_OPTIONS_PANEL) { + return onPrepareOptionsMenu(menu); + } + return false; + } + + public boolean onPrepareOptionsMenu(Menu menu) { + return true; + } + + @Override + public boolean onMenuItemSelected(int featureId, MenuItem item) { + if (featureId == Window.FEATURE_OPTIONS_PANEL) { + return onOptionsItemSelected(item); + } + return false; + } + + public boolean onOptionsItemSelected(MenuItem item) { + return false; + } + + + /////////////////////////////////////////////////////////////////////////// + // Content + /////////////////////////////////////////////////////////////////////////// + + @Override + public void addContentView(View view, LayoutParams params) { + getSherlock().addContentView(view, params); + } + + @Override + public void setContentView(int layoutResId) { + getSherlock().setContentView(layoutResId); + } + + @Override + public void setContentView(View view, LayoutParams params) { + getSherlock().setContentView(view, params); + } + + @Override + public void setContentView(View view) { + getSherlock().setContentView(view); + } + + public void requestWindowFeature(long featureId) { + getSherlock().requestFeature((int)featureId); + } + + + /////////////////////////////////////////////////////////////////////////// + // Progress Indication + /////////////////////////////////////////////////////////////////////////// + + public void setSupportProgress(int progress) { + getSherlock().setProgress(progress); + } + + public void setSupportProgressBarIndeterminate(boolean indeterminate) { + getSherlock().setProgressBarIndeterminate(indeterminate); + } + + public void setSupportProgressBarIndeterminateVisibility(boolean visible) { + getSherlock().setProgressBarIndeterminateVisibility(visible); + } + + public void setSupportProgressBarVisibility(boolean visible) { + getSherlock().setProgressBarVisibility(visible); + } + + public void setSupportSecondaryProgress(int secondaryProgress) { + getSherlock().setSecondaryProgress(secondaryProgress); + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockCompat.java b/actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockCompat.java new file mode 100644 index 000000000..05353d28c --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockCompat.java @@ -0,0 +1,1207 @@ +package com.actionbarsherlock.internal; + +import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; +import static com.actionbarsherlock.internal.ResourcesCompat.getResources_getBoolean; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import org.xmlpull.v1.XmlPullParser; +import android.app.Activity; +import android.content.Context; +import android.content.pm.ActivityInfo; +import android.content.res.AssetManager; +import android.content.res.Configuration; +import android.content.res.Resources; +import android.content.res.TypedArray; +import android.content.res.XmlResourceParser; +import android.os.Bundle; +import android.util.AndroidRuntimeException; +import android.util.Log; +import android.util.TypedValue; +import android.view.ContextThemeWrapper; +import android.view.KeyCharacterMap; +import android.view.KeyEvent; +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewStub; +import android.view.Window; +import android.view.accessibility.AccessibilityEvent; +import android.view.animation.Animation; +import android.view.animation.AnimationUtils; +import android.widget.FrameLayout; +import android.widget.TextView; +import com.actionbarsherlock.ActionBarSherlock; +import com.actionbarsherlock.R; +import com.actionbarsherlock.app.ActionBar; +import com.actionbarsherlock.internal.app.ActionBarImpl; +import com.actionbarsherlock.internal.view.StandaloneActionMode; +import com.actionbarsherlock.internal.view.menu.ActionMenuPresenter; +import com.actionbarsherlock.internal.view.menu.MenuBuilder; +import com.actionbarsherlock.internal.view.menu.MenuItemImpl; +import com.actionbarsherlock.internal.view.menu.MenuPresenter; +import com.actionbarsherlock.internal.widget.ActionBarContainer; +import com.actionbarsherlock.internal.widget.ActionBarContextView; +import com.actionbarsherlock.internal.widget.ActionBarView; +import com.actionbarsherlock.internal.widget.IcsProgressBar; +import com.actionbarsherlock.view.ActionMode; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuItem; + +@ActionBarSherlock.Implementation(api = 7) +public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBuilder.Callback, com.actionbarsherlock.view.Window.Callback, MenuPresenter.Callback, android.view.MenuItem.OnMenuItemClickListener { + /** Window features which are enabled by default. */ + protected static final int DEFAULT_FEATURES = 0; + + + public ActionBarSherlockCompat(Activity activity, int flags) { + super(activity, flags); + } + + + /////////////////////////////////////////////////////////////////////////// + // Properties + /////////////////////////////////////////////////////////////////////////// + + /** Whether or not the device has a dedicated menu key button. */ + private boolean mReserveOverflow; + /** Lazy-load indicator for {@link #mReserveOverflow}. */ + private boolean mReserveOverflowSet = false; + + /** Current menu instance for managing action items. */ + private MenuBuilder mMenu; + /** Map between native options items and sherlock items. */ + protected HashMap mNativeItemMap; + /** Indication of a long-press on the hardware menu key. */ + private boolean mMenuKeyIsLongPress = false; + + /** Parent view of the window decoration (action bar, mode, etc.). */ + private ViewGroup mDecor; + /** Parent view of the activity content. */ + private ViewGroup mContentParent; + + /** Whether or not the title is stable and can be displayed. */ + private boolean mIsTitleReady = false; + /** Whether or not the parent activity has been destroyed. */ + private boolean mIsDestroyed = false; + + /* Emulate PanelFeatureState */ + private boolean mClosingActionMenu; + private boolean mMenuIsPrepared; + private boolean mMenuRefreshContent; + private Bundle mMenuFrozenActionViewState; + + /** Implementation which backs the action bar interface API. */ + private ActionBarImpl aActionBar; + /** Main action bar view which displays the core content. */ + private ActionBarView wActionBar; + /** Relevant window and action bar features flags. */ + private int mFeatures = DEFAULT_FEATURES; + /** Relevant user interface option flags. */ + private int mUiOptions = 0; + + /** Decor indeterminate progress indicator. */ + private IcsProgressBar mCircularProgressBar; + /** Decor progress indicator. */ + private IcsProgressBar mHorizontalProgressBar; + + /** Current displayed context action bar, if any. */ + private ActionMode mActionMode; + /** Parent view in which the context action bar is displayed. */ + private ActionBarContextView mActionModeView; + + /** Title view used with dialogs. */ + private TextView mTitleView; + /** Current activity title. */ + private CharSequence mTitle = null; + /** Whether or not this "activity" is floating (i.e., a dialog) */ + private boolean mIsFloating; + + + + /////////////////////////////////////////////////////////////////////////// + // Instance methods + /////////////////////////////////////////////////////////////////////////// + + @Override + public ActionBar getActionBar() { + if (DEBUG) Log.d(TAG, "[getActionBar]"); + + initActionBar(); + return aActionBar; + } + + private void initActionBar() { + if (DEBUG) Log.d(TAG, "[initActionBar]"); + + // Initializing the window decor can change window feature flags. + // Make sure that we have the correct set before performing the test below. + if (mDecor == null) { + installDecor(); + } + + if ((aActionBar != null) || !hasFeature(Window.FEATURE_ACTION_BAR) || hasFeature(Window.FEATURE_NO_TITLE) || mActivity.isChild()) { + return; + } + + aActionBar = new ActionBarImpl(mActivity, mFeatures); + + if (!mIsDelegate) { + //We may never get another chance to set the title + wActionBar.setWindowTitle(mActivity.getTitle()); + } + } + + @Override + protected Context getThemedContext() { + return aActionBar.getThemedContext(); + } + + @Override + public void setTitle(CharSequence title) { + if (DEBUG) Log.d(TAG, "[setTitle] title: " + title); + + dispatchTitleChanged(title, 0); + } + + @Override + public ActionMode startActionMode(ActionMode.Callback callback) { + if (DEBUG) Log.d(TAG, "[startActionMode] callback: " + callback); + + if (mActionMode != null) { + mActionMode.finish(); + } + + final ActionMode.Callback wrappedCallback = new ActionModeCallbackWrapper(callback); + ActionMode mode = null; + + //Emulate Activity's onWindowStartingActionMode: + initActionBar(); + if (aActionBar != null) { + mode = aActionBar.startActionMode(wrappedCallback); + } + + if (mode != null) { + mActionMode = mode; + } else { + if (mActionModeView == null) { + ViewStub stub = (ViewStub)mDecor.findViewById(R.id.abs__action_mode_bar_stub); + if (stub != null) { + mActionModeView = (ActionBarContextView)stub.inflate(); + } + } + if (mActionModeView != null) { + mActionModeView.killMode(); + mode = new StandaloneActionMode(mActivity, mActionModeView, wrappedCallback, true); + if (callback.onCreateActionMode(mode, mode.getMenu())) { + mode.invalidate(); + mActionModeView.initForMode(mode); + mActionModeView.setVisibility(View.VISIBLE); + mActionMode = mode; + mActionModeView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); + } else { + mActionMode = null; + } + } + } + if (mActionMode != null && mActivity instanceof OnActionModeStartedListener) { + ((OnActionModeStartedListener)mActivity).onActionModeStarted(mActionMode); + } + return mActionMode; + } + + + /////////////////////////////////////////////////////////////////////////// + // Lifecycle and interaction callbacks for delegation + /////////////////////////////////////////////////////////////////////////// + + @Override + public void dispatchConfigurationChanged(Configuration newConfig) { + if (DEBUG) Log.d(TAG, "[dispatchConfigurationChanged] newConfig: " + newConfig); + + if (aActionBar != null) { + aActionBar.onConfigurationChanged(newConfig); + } + } + + @Override + public void dispatchPostResume() { + if (DEBUG) Log.d(TAG, "[dispatchPostResume]"); + + if (aActionBar != null) { + aActionBar.setShowHideAnimationEnabled(true); + } + } + + @Override + public void dispatchPause() { + if (DEBUG) Log.d(TAG, "[dispatchPause]"); + + if (wActionBar != null && wActionBar.isOverflowMenuShowing()) { + wActionBar.hideOverflowMenu(); + } + } + + @Override + public void dispatchStop() { + if (DEBUG) Log.d(TAG, "[dispatchStop]"); + + if (aActionBar != null) { + aActionBar.setShowHideAnimationEnabled(false); + } + } + + @Override + public void dispatchInvalidateOptionsMenu() { + if (DEBUG) Log.d(TAG, "[dispatchInvalidateOptionsMenu]"); + + Bundle savedActionViewStates = null; + if (mMenu != null) { + savedActionViewStates = new Bundle(); + mMenu.saveActionViewStates(savedActionViewStates); + if (savedActionViewStates.size() > 0) { + mMenuFrozenActionViewState = savedActionViewStates; + } + // This will be started again when the panel is prepared. + mMenu.stopDispatchingItemsChanged(); + mMenu.clear(); + } + mMenuRefreshContent = true; + + // Prepare the options panel if we have an action bar + if (wActionBar != null) { + mMenuIsPrepared = false; + preparePanel(); + } + } + + @Override + public boolean dispatchOpenOptionsMenu() { + if (DEBUG) Log.d(TAG, "[dispatchOpenOptionsMenu]"); + + if (!isReservingOverflow()) { + return false; + } + + return wActionBar.showOverflowMenu(); + } + + @Override + public boolean dispatchCloseOptionsMenu() { + if (DEBUG) Log.d(TAG, "[dispatchCloseOptionsMenu]"); + + if (!isReservingOverflow()) { + return false; + } + + return wActionBar.hideOverflowMenu(); + } + + @Override + public void dispatchPostCreate(Bundle savedInstanceState) { + if (DEBUG) Log.d(TAG, "[dispatchOnPostCreate]"); + + if (mIsDelegate) { + mIsTitleReady = true; + } + + if (mDecor == null) { + initActionBar(); + } + } + + @Override + public boolean dispatchCreateOptionsMenu(android.view.Menu menu) { + if (DEBUG) { + Log.d(TAG, "[dispatchCreateOptionsMenu] android.view.Menu: " + menu); + Log.d(TAG, "[dispatchCreateOptionsMenu] returning true"); + } + return true; + } + + @Override + public boolean dispatchPrepareOptionsMenu(android.view.Menu menu) { + if (DEBUG) Log.d(TAG, "[dispatchPrepareOptionsMenu] android.view.Menu: " + menu); + + if (mActionMode != null) { + return false; + } + + mMenuIsPrepared = false; + if (!preparePanel()) { + return false; + } + + if (isReservingOverflow()) { + return false; + } + + if (mNativeItemMap == null) { + mNativeItemMap = new HashMap(); + } else { + mNativeItemMap.clear(); + } + + if (mMenu == null) { + return false; + } + + boolean result = mMenu.bindNativeOverflow(menu, this, mNativeItemMap); + if (DEBUG) Log.d(TAG, "[dispatchPrepareOptionsMenu] returning " + result); + return result; + } + + @Override + public boolean dispatchOptionsItemSelected(android.view.MenuItem item) { + throw new IllegalStateException("Native callback invoked. Create a test case and report!"); + } + + @Override + public boolean dispatchMenuOpened(int featureId, android.view.Menu menu) { + if (DEBUG) Log.d(TAG, "[dispatchMenuOpened] featureId: " + featureId + ", menu: " + menu); + + if (featureId == Window.FEATURE_ACTION_BAR || featureId == Window.FEATURE_OPTIONS_PANEL) { + if (aActionBar != null) { + aActionBar.dispatchMenuVisibilityChanged(true); + } + return true; + } + + return false; + } + + @Override + public void dispatchPanelClosed(int featureId, android.view.Menu menu){ + if (DEBUG) Log.d(TAG, "[dispatchPanelClosed] featureId: " + featureId + ", menu: " + menu); + + if (featureId == Window.FEATURE_ACTION_BAR || featureId == Window.FEATURE_OPTIONS_PANEL) { + if (aActionBar != null) { + aActionBar.dispatchMenuVisibilityChanged(false); + } + } + } + + @Override + public void dispatchTitleChanged(CharSequence title, int color) { + if (DEBUG) Log.d(TAG, "[dispatchTitleChanged] title: " + title + ", color: " + color); + + if (!mIsDelegate || mIsTitleReady) { + if (mTitleView != null) { + mTitleView.setText(title); + } else if (wActionBar != null) { + wActionBar.setWindowTitle(title); + } + } + + mTitle = title; + } + + @Override + public boolean dispatchKeyEvent(KeyEvent event) { + if (DEBUG) Log.d(TAG, "[dispatchKeyEvent] event: " + event); + + final int keyCode = event.getKeyCode(); + + // Not handled by the view hierarchy, does the action bar want it + // to cancel out of something special? + if (keyCode == KeyEvent.KEYCODE_BACK) { + final int action = event.getAction(); + // Back cancels action modes first. + if (mActionMode != null) { + if (action == KeyEvent.ACTION_UP) { + mActionMode.finish(); + } + if (DEBUG) Log.d(TAG, "[dispatchKeyEvent] returning true"); + return true; + } + + // Next collapse any expanded action views. + if (wActionBar != null && wActionBar.hasExpandedActionView()) { + if (action == KeyEvent.ACTION_UP) { + wActionBar.collapseActionView(); + } + if (DEBUG) Log.d(TAG, "[dispatchKeyEvent] returning true"); + return true; + } + } + + boolean result = false; + if (keyCode == KeyEvent.KEYCODE_MENU && isReservingOverflow()) { + if (event.getAction() == KeyEvent.ACTION_DOWN && event.isLongPress()) { + mMenuKeyIsLongPress = true; + } else if (event.getAction() == KeyEvent.ACTION_UP) { + if (!mMenuKeyIsLongPress) { + if (mActionMode == null && wActionBar != null) { + if (wActionBar.isOverflowMenuShowing()) { + wActionBar.hideOverflowMenu(); + } else { + wActionBar.showOverflowMenu(); + } + } + result = true; + } + mMenuKeyIsLongPress = false; + } + } + + if (DEBUG) Log.d(TAG, "[dispatchKeyEvent] returning " + result); + return result; + } + + @Override + public void dispatchDestroy() { + mIsDestroyed = true; + } + + + /////////////////////////////////////////////////////////////////////////// + // Menu callback lifecycle and creation + /////////////////////////////////////////////////////////////////////////// + + private boolean preparePanel() { + // Already prepared (isPrepared will be reset to false later) + if (mMenuIsPrepared) { + return true; + } + + // Init the panel state's menu--return false if init failed + if (mMenu == null || mMenuRefreshContent) { + if (mMenu == null) { + if (!initializePanelMenu() || (mMenu == null)) { + return false; + } + } + + if (wActionBar != null) { + wActionBar.setMenu(mMenu, this); + } + + // Call callback, and return if it doesn't want to display menu. + + // Creating the panel menu will involve a lot of manipulation; + // don't dispatch change events to presenters until we're done. + mMenu.stopDispatchingItemsChanged(); + if (!callbackCreateOptionsMenu(mMenu)) { + // Ditch the menu created above + mMenu = null; + + if (wActionBar != null) { + // Don't show it in the action bar either + wActionBar.setMenu(null, this); + } + + return false; + } + + mMenuRefreshContent = false; + } + + // Callback and return if the callback does not want to show the menu + + // Preparing the panel menu can involve a lot of manipulation; + // don't dispatch change events to presenters until we're done. + mMenu.stopDispatchingItemsChanged(); + + // Restore action view state before we prepare. This gives apps + // an opportunity to override frozen/restored state in onPrepare. + if (mMenuFrozenActionViewState != null) { + mMenu.restoreActionViewStates(mMenuFrozenActionViewState); + mMenuFrozenActionViewState = null; + } + + if (!callbackPrepareOptionsMenu(mMenu)) { + if (wActionBar != null) { + // The app didn't want to show the menu for now but it still exists. + // Clear it out of the action bar. + wActionBar.setMenu(null, this); + } + mMenu.startDispatchingItemsChanged(); + return false; + } + + // Set the proper keymap + KeyCharacterMap kmap = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD); + mMenu.setQwertyMode(kmap.getKeyboardType() != KeyCharacterMap.NUMERIC); + mMenu.startDispatchingItemsChanged(); + + // Set other state + mMenuIsPrepared = true; + + return true; + } + + public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) { + return callbackOptionsItemSelected(item); + } + + public void onMenuModeChange(MenuBuilder menu) { + reopenMenu(true); + } + + private void reopenMenu(boolean toggleMenuMode) { + if (wActionBar != null && wActionBar.isOverflowReserved()) { + if (!wActionBar.isOverflowMenuShowing() || !toggleMenuMode) { + if (wActionBar.getVisibility() == View.VISIBLE) { + if (callbackPrepareOptionsMenu(mMenu)) { + wActionBar.showOverflowMenu(); + } + } + } else { + wActionBar.hideOverflowMenu(); + } + return; + } + } + + private boolean initializePanelMenu() { + Context context = mActivity;//getContext(); + + // If we have an action bar, initialize the menu with a context themed for it. + if (wActionBar != null) { + TypedValue outValue = new TypedValue(); + Resources.Theme currentTheme = context.getTheme(); + currentTheme.resolveAttribute(R.attr.actionBarWidgetTheme, + outValue, true); + final int targetThemeRes = outValue.resourceId; + + if (targetThemeRes != 0 /*&& context.getThemeResId() != targetThemeRes*/) { + context = new ContextThemeWrapper(context, targetThemeRes); + } + } + + mMenu = new MenuBuilder(context); + mMenu.setCallback(this); + + return true; + } + + void checkCloseActionMenu(Menu menu) { + if (mClosingActionMenu) { + return; + } + + mClosingActionMenu = true; + wActionBar.dismissPopupMenus(); + //Callback cb = getCallback(); + //if (cb != null && !isDestroyed()) { + // cb.onPanelClosed(FEATURE_ACTION_BAR, menu); + //} + mClosingActionMenu = false; + } + + @Override + public boolean onOpenSubMenu(MenuBuilder subMenu) { + return true; + } + + @Override + public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) { + checkCloseActionMenu(menu); + } + + @Override + public boolean onMenuItemClick(android.view.MenuItem item) { + if (DEBUG) Log.d(TAG, "[mNativeItemListener.onMenuItemClick] item: " + item); + + final MenuItemImpl sherlockItem = mNativeItemMap.get(item); + if (sherlockItem != null) { + sherlockItem.invoke(); + } else { + Log.e(TAG, "Options item \"" + item + "\" not found in mapping"); + } + + return true; //Do not allow continuation of native handling + } + + @Override + public boolean onMenuItemSelected(int featureId, MenuItem item) { + return callbackOptionsItemSelected(item); + } + + + /////////////////////////////////////////////////////////////////////////// + // Progress bar interaction and internal handling + /////////////////////////////////////////////////////////////////////////// + + @Override + public void setProgressBarVisibility(boolean visible) { + if (DEBUG) Log.d(TAG, "[setProgressBarVisibility] visible: " + visible); + + setFeatureInt(Window.FEATURE_PROGRESS, visible ? Window.PROGRESS_VISIBILITY_ON : + Window.PROGRESS_VISIBILITY_OFF); + } + + @Override + public void setProgressBarIndeterminateVisibility(boolean visible) { + if (DEBUG) Log.d(TAG, "[setProgressBarIndeterminateVisibility] visible: " + visible); + + setFeatureInt(Window.FEATURE_INDETERMINATE_PROGRESS, + visible ? Window.PROGRESS_VISIBILITY_ON : Window.PROGRESS_VISIBILITY_OFF); + } + + @Override + public void setProgressBarIndeterminate(boolean indeterminate) { + if (DEBUG) Log.d(TAG, "[setProgressBarIndeterminate] indeterminate: " + indeterminate); + + setFeatureInt(Window.FEATURE_PROGRESS, + indeterminate ? Window.PROGRESS_INDETERMINATE_ON : Window.PROGRESS_INDETERMINATE_OFF); + } + + @Override + public void setProgress(int progress) { + if (DEBUG) Log.d(TAG, "[setProgress] progress: " + progress); + + setFeatureInt(Window.FEATURE_PROGRESS, progress + Window.PROGRESS_START); + } + + @Override + public void setSecondaryProgress(int secondaryProgress) { + if (DEBUG) Log.d(TAG, "[setSecondaryProgress] secondaryProgress: " + secondaryProgress); + + setFeatureInt(Window.FEATURE_PROGRESS, + secondaryProgress + Window.PROGRESS_SECONDARY_START); + } + + private void setFeatureInt(int featureId, int value) { + updateInt(featureId, value, false); + } + + private void updateInt(int featureId, int value, boolean fromResume) { + // Do nothing if the decor is not yet installed... an update will + // need to be forced when we eventually become active. + if (mContentParent == null) { + return; + } + + final int featureMask = 1 << featureId; + + if ((getFeatures() & featureMask) == 0 && !fromResume) { + return; + } + + onIntChanged(featureId, value); + } + + private void onIntChanged(int featureId, int value) { + if (featureId == Window.FEATURE_PROGRESS || featureId == Window.FEATURE_INDETERMINATE_PROGRESS) { + updateProgressBars(value); + } + } + + private void updateProgressBars(int value) { + IcsProgressBar circularProgressBar = getCircularProgressBar(true); + IcsProgressBar horizontalProgressBar = getHorizontalProgressBar(true); + + final int features = mFeatures;//getLocalFeatures(); + if (value == Window.PROGRESS_VISIBILITY_ON) { + if ((features & (1 << Window.FEATURE_PROGRESS)) != 0) { + int level = horizontalProgressBar.getProgress(); + int visibility = (horizontalProgressBar.isIndeterminate() || level < 10000) ? + View.VISIBLE : View.INVISIBLE; + horizontalProgressBar.setVisibility(visibility); + } + if ((features & (1 << Window.FEATURE_INDETERMINATE_PROGRESS)) != 0) { + circularProgressBar.setVisibility(View.VISIBLE); + } + } else if (value == Window.PROGRESS_VISIBILITY_OFF) { + if ((features & (1 << Window.FEATURE_PROGRESS)) != 0) { + horizontalProgressBar.setVisibility(View.GONE); + } + if ((features & (1 << Window.FEATURE_INDETERMINATE_PROGRESS)) != 0) { + circularProgressBar.setVisibility(View.GONE); + } + } else if (value == Window.PROGRESS_INDETERMINATE_ON) { + horizontalProgressBar.setIndeterminate(true); + } else if (value == Window.PROGRESS_INDETERMINATE_OFF) { + horizontalProgressBar.setIndeterminate(false); + } else if (Window.PROGRESS_START <= value && value <= Window.PROGRESS_END) { + // We want to set the progress value before testing for visibility + // so that when the progress bar becomes visible again, it has the + // correct level. + horizontalProgressBar.setProgress(value - Window.PROGRESS_START); + + if (value < Window.PROGRESS_END) { + showProgressBars(horizontalProgressBar, circularProgressBar); + } else { + hideProgressBars(horizontalProgressBar, circularProgressBar); + } + } else if (Window.PROGRESS_SECONDARY_START <= value && value <= Window.PROGRESS_SECONDARY_END) { + horizontalProgressBar.setSecondaryProgress(value - Window.PROGRESS_SECONDARY_START); + + showProgressBars(horizontalProgressBar, circularProgressBar); + } + } + + private void showProgressBars(IcsProgressBar horizontalProgressBar, IcsProgressBar spinnyProgressBar) { + final int features = mFeatures;//getLocalFeatures(); + if ((features & (1 << Window.FEATURE_INDETERMINATE_PROGRESS)) != 0 && + spinnyProgressBar.getVisibility() == View.INVISIBLE) { + spinnyProgressBar.setVisibility(View.VISIBLE); + } + // Only show the progress bars if the primary progress is not complete + if ((features & (1 << Window.FEATURE_PROGRESS)) != 0 && + horizontalProgressBar.getProgress() < 10000) { + horizontalProgressBar.setVisibility(View.VISIBLE); + } + } + + private void hideProgressBars(IcsProgressBar horizontalProgressBar, IcsProgressBar spinnyProgressBar) { + final int features = mFeatures;//getLocalFeatures(); + Animation anim = AnimationUtils.loadAnimation(mActivity, android.R.anim.fade_out); + anim.setDuration(1000); + if ((features & (1 << Window.FEATURE_INDETERMINATE_PROGRESS)) != 0 && + spinnyProgressBar.getVisibility() == View.VISIBLE) { + spinnyProgressBar.startAnimation(anim); + spinnyProgressBar.setVisibility(View.INVISIBLE); + } + if ((features & (1 << Window.FEATURE_PROGRESS)) != 0 && + horizontalProgressBar.getVisibility() == View.VISIBLE) { + horizontalProgressBar.startAnimation(anim); + horizontalProgressBar.setVisibility(View.INVISIBLE); + } + } + + private IcsProgressBar getCircularProgressBar(boolean shouldInstallDecor) { + if (mCircularProgressBar != null) { + return mCircularProgressBar; + } + if (mContentParent == null && shouldInstallDecor) { + installDecor(); + } + mCircularProgressBar = (IcsProgressBar)mDecor.findViewById(R.id.abs__progress_circular); + if (mCircularProgressBar != null) { + mCircularProgressBar.setVisibility(View.INVISIBLE); + } + return mCircularProgressBar; + } + + private IcsProgressBar getHorizontalProgressBar(boolean shouldInstallDecor) { + if (mHorizontalProgressBar != null) { + return mHorizontalProgressBar; + } + if (mContentParent == null && shouldInstallDecor) { + installDecor(); + } + mHorizontalProgressBar = (IcsProgressBar)mDecor.findViewById(R.id.abs__progress_horizontal); + if (mHorizontalProgressBar != null) { + mHorizontalProgressBar.setVisibility(View.INVISIBLE); + } + return mHorizontalProgressBar; + } + + + /////////////////////////////////////////////////////////////////////////// + // Feature management and content interaction and creation + /////////////////////////////////////////////////////////////////////////// + + private int getFeatures() { + if (DEBUG) Log.d(TAG, "[getFeatures] returning " + mFeatures); + + return mFeatures; + } + + @Override + public boolean hasFeature(int featureId) { + if (DEBUG) Log.d(TAG, "[hasFeature] featureId: " + featureId); + + boolean result = (mFeatures & (1 << featureId)) != 0; + if (DEBUG) Log.d(TAG, "[hasFeature] returning " + result); + return result; + } + + @Override + public boolean requestFeature(int featureId) { + if (DEBUG) Log.d(TAG, "[requestFeature] featureId: " + featureId); + + if (mContentParent != null) { + throw new AndroidRuntimeException("requestFeature() must be called before adding content"); + } + + switch (featureId) { + case Window.FEATURE_ACTION_BAR: + case Window.FEATURE_ACTION_BAR_OVERLAY: + case Window.FEATURE_ACTION_MODE_OVERLAY: + case Window.FEATURE_INDETERMINATE_PROGRESS: + case Window.FEATURE_NO_TITLE: + case Window.FEATURE_PROGRESS: + mFeatures |= (1 << featureId); + return true; + + default: + return false; + } + } + + @Override + public void setUiOptions(int uiOptions) { + if (DEBUG) Log.d(TAG, "[setUiOptions] uiOptions: " + uiOptions); + + mUiOptions = uiOptions; + } + + @Override + public void setUiOptions(int uiOptions, int mask) { + if (DEBUG) Log.d(TAG, "[setUiOptions] uiOptions: " + uiOptions + ", mask: " + mask); + + mUiOptions = (mUiOptions & ~mask) | (uiOptions & mask); + } + + @Override + public void setContentView(int layoutResId) { + if (DEBUG) Log.d(TAG, "[setContentView] layoutResId: " + layoutResId); + + if (mContentParent == null) { + installDecor(); + } else { + mContentParent.removeAllViews(); + } + mActivity.getLayoutInflater().inflate(layoutResId, mContentParent); + + android.view.Window.Callback callback = mActivity.getWindow().getCallback(); + if (callback != null) { + callback.onContentChanged(); + } + + initActionBar(); + } + + @Override + public void setContentView(View view, ViewGroup.LayoutParams params) { + if (DEBUG) Log.d(TAG, "[setContentView] view: " + view + ", params: " + params); + + if (mContentParent == null) { + installDecor(); + } else { + mContentParent.removeAllViews(); + } + mContentParent.addView(view, params); + + android.view.Window.Callback callback = mActivity.getWindow().getCallback(); + if (callback != null) { + callback.onContentChanged(); + } + + initActionBar(); + } + + @Override + public void addContentView(View view, ViewGroup.LayoutParams params) { + if (DEBUG) Log.d(TAG, "[addContentView] view: " + view + ", params: " + params); + + if (mContentParent == null) { + installDecor(); + } + mContentParent.addView(view, params); + + initActionBar(); + } + + private void installDecor() { + if (DEBUG) Log.d(TAG, "[installDecor]"); + + if (mDecor == null) { + mDecor = (ViewGroup)mActivity.getWindow().getDecorView().findViewById(android.R.id.content); + } + if (mContentParent == null) { + //Since we are not operating at the window level we need to take + //into account the fact that the true decor may have already been + //initialized and had content attached to it. If that is the case, + //copy over its children to our new content container. + List views = null; + if (mDecor.getChildCount() > 0) { + views = new ArrayList(1); //Usually there's only one child + for (int i = 0, children = mDecor.getChildCount(); i < children; i++) { + View child = mDecor.getChildAt(0); + mDecor.removeView(child); + views.add(child); + } + } + + mContentParent = generateLayout(); + + //Copy over the old children. See above for explanation. + if (views != null) { + for (View child : views) { + mContentParent.addView(child); + } + } + + mTitleView = (TextView)mDecor.findViewById(android.R.id.title); + if (mTitleView != null) { + if (hasFeature(Window.FEATURE_NO_TITLE)) { + mTitleView.setVisibility(View.GONE); + if (mContentParent instanceof FrameLayout) { + ((FrameLayout)mContentParent).setForeground(null); + } + } else { + mTitleView.setText(mTitle); + } + } else { + wActionBar = (ActionBarView)mDecor.findViewById(R.id.abs__action_bar); + if (wActionBar != null) { + wActionBar.setWindowCallback(this); + if (wActionBar.getTitle() == null) { + wActionBar.setWindowTitle(mActivity.getTitle()); + } + if (hasFeature(Window.FEATURE_PROGRESS)) { + wActionBar.initProgress(); + } + if (hasFeature(Window.FEATURE_INDETERMINATE_PROGRESS)) { + wActionBar.initIndeterminateProgress(); + } + + //Since we don't require onCreate dispatching, parse for uiOptions here + int uiOptions = loadUiOptionsFromManifest(mActivity); + if (uiOptions != 0) { + mUiOptions = uiOptions; + } + + boolean splitActionBar = false; + final boolean splitWhenNarrow = (mUiOptions & ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW) != 0; + if (splitWhenNarrow) { + splitActionBar = getResources_getBoolean(mActivity, R.bool.abs__split_action_bar_is_narrow); + } else { + splitActionBar = mActivity.getTheme() + .obtainStyledAttributes(R.styleable.SherlockTheme) + .getBoolean(R.styleable.SherlockTheme_windowSplitActionBar, false); + } + final ActionBarContainer splitView = (ActionBarContainer)mDecor.findViewById(R.id.abs__split_action_bar); + if (splitView != null) { + wActionBar.setSplitView(splitView); + wActionBar.setSplitActionBar(splitActionBar); + wActionBar.setSplitWhenNarrow(splitWhenNarrow); + + mActionModeView = (ActionBarContextView)mDecor.findViewById(R.id.abs__action_context_bar); + mActionModeView.setSplitView(splitView); + mActionModeView.setSplitActionBar(splitActionBar); + mActionModeView.setSplitWhenNarrow(splitWhenNarrow); + } else if (splitActionBar) { + Log.e(TAG, "Requested split action bar with incompatible window decor! Ignoring request."); + } + + // Post the panel invalidate for later; avoid application onCreateOptionsMenu + // being called in the middle of onCreate or similar. + mDecor.post(new Runnable() { + @Override + public void run() { + //Invalidate if the panel menu hasn't been created before this. + if (!mIsDestroyed && !mActivity.isFinishing() && mMenu == null) { + dispatchInvalidateOptionsMenu(); + } + } + }); + } + } + } + } + + private ViewGroup generateLayout() { + if (DEBUG) Log.d(TAG, "[generateLayout]"); + + // Apply data from current theme. + + TypedArray a = mActivity.getTheme().obtainStyledAttributes(R.styleable.SherlockTheme); + + mIsFloating = a.getBoolean(R.styleable.SherlockTheme_android_windowIsFloating, false); + + if (!a.hasValue(R.styleable.SherlockTheme_windowActionBar)) { + throw new IllegalStateException("You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative."); + } + + if (a.getBoolean(R.styleable.SherlockTheme_windowNoTitle, false)) { + requestFeature(Window.FEATURE_NO_TITLE); + } else if (a.getBoolean(R.styleable.SherlockTheme_windowActionBar, false)) { + // Don't allow an action bar if there is no title. + requestFeature(Window.FEATURE_ACTION_BAR); + } + + if (a.getBoolean(R.styleable.SherlockTheme_windowActionBarOverlay, false)) { + requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); + } + + if (a.getBoolean(R.styleable.SherlockTheme_windowActionModeOverlay, false)) { + requestFeature(Window.FEATURE_ACTION_MODE_OVERLAY); + } + + a.recycle(); + + int layoutResource; + if (!hasFeature(Window.FEATURE_NO_TITLE)) { + if (mIsFloating) { + //Trash original dialog LinearLayout + mDecor = (ViewGroup)mDecor.getParent(); + mDecor.removeAllViews(); + + layoutResource = R.layout.abs__dialog_title_holo; + } else { + if (hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY)) { + layoutResource = R.layout.abs__screen_action_bar_overlay; + } else { + layoutResource = R.layout.abs__screen_action_bar; + } + } + } else if (hasFeature(Window.FEATURE_ACTION_MODE_OVERLAY) && !hasFeature(Window.FEATURE_NO_TITLE)) { + layoutResource = R.layout.abs__screen_simple_overlay_action_mode; + } else { + layoutResource = R.layout.abs__screen_simple; + } + + if (DEBUG) Log.d(TAG, "[generateLayout] using screen XML " + mActivity.getResources().getString(layoutResource)); + View in = mActivity.getLayoutInflater().inflate(layoutResource, null); + mDecor.addView(in, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)); + + ViewGroup contentParent = (ViewGroup)mDecor.findViewById(R.id.abs__content); + if (contentParent == null) { + throw new RuntimeException("Couldn't find content container view"); + } + + //Make our new child the true content view (for fragments). VERY VOLATILE! + mDecor.setId(View.NO_ID); + contentParent.setId(android.R.id.content); + + if (hasFeature(Window.FEATURE_INDETERMINATE_PROGRESS)) { + IcsProgressBar progress = getCircularProgressBar(false); + if (progress != null) { + progress.setIndeterminate(true); + } + } + + return contentParent; + } + + + /////////////////////////////////////////////////////////////////////////// + // Miscellaneous + /////////////////////////////////////////////////////////////////////////// + + /** + * Determine whether or not the device has a dedicated menu key. + * + * @return {@code true} if native menu key is present. + */ + private boolean isReservingOverflow() { + if (!mReserveOverflowSet) { + mReserveOverflow = ActionMenuPresenter.reserveOverflow(mActivity); + mReserveOverflowSet = true; + } + return mReserveOverflow; + } + + private static int loadUiOptionsFromManifest(Activity activity) { + int uiOptions = 0; + try { + final String thisPackage = activity.getClass().getName(); + if (DEBUG) Log.i(TAG, "Parsing AndroidManifest.xml for " + thisPackage); + + final String packageName = activity.getApplicationInfo().packageName; + final AssetManager am = activity.createPackageContext(packageName, 0).getAssets(); + final XmlResourceParser xml = am.openXmlResourceParser("AndroidManifest.xml"); + + int eventType = xml.getEventType(); + while (eventType != XmlPullParser.END_DOCUMENT) { + if (eventType == XmlPullParser.START_TAG) { + String name = xml.getName(); + + if ("application".equals(name)) { + //Check if the has the attribute + if (DEBUG) Log.d(TAG, "Got "); + + for (int i = xml.getAttributeCount() - 1; i >= 0; i--) { + if (DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i)); + + if ("uiOptions".equals(xml.getAttributeName(i))) { + uiOptions = xml.getAttributeIntValue(i, 0); + break; //out of for loop + } + } + } else if ("activity".equals(name)) { + //Check if the is us and has the attribute + if (DEBUG) Log.d(TAG, "Got "); + Integer activityUiOptions = null; + String activityPackage = null; + boolean isOurActivity = false; + + for (int i = xml.getAttributeCount() - 1; i >= 0; i--) { + if (DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i)); + + //We need both uiOptions and name attributes + String attrName = xml.getAttributeName(i); + if ("uiOptions".equals(attrName)) { + activityUiOptions = xml.getAttributeIntValue(i, 0); + } else if ("name".equals(attrName)) { + activityPackage = cleanActivityName(packageName, xml.getAttributeValue(i)); + if (!thisPackage.equals(activityPackage)) { + break; //out of for loop + } + isOurActivity = true; + } + + //Make sure we have both attributes before processing + if ((activityUiOptions != null) && (activityPackage != null)) { + //Our activity, uiOptions specified, override with our value + uiOptions = activityUiOptions.intValue(); + } + } + if (isOurActivity) { + //If we matched our activity but it had no logo don't + //do any more processing of the manifest + break; + } + } + } + eventType = xml.nextToken(); + } + } catch (Exception e) { + e.printStackTrace(); + } + if (DEBUG) Log.i(TAG, "Returning " + Integer.toHexString(uiOptions)); + return uiOptions; + } + + public static String cleanActivityName(String manifestPackage, String activityName) { + if (activityName.charAt(0) == '.') { + //Relative activity name (e.g., android:name=".ui.SomeClass") + return manifestPackage + activityName; + } + if (activityName.indexOf('.', 1) == -1) { + //Unqualified activity name (e.g., android:name="SomeClass") + return manifestPackage + "." + activityName; + } + //Fully-qualified activity name (e.g., "com.my.package.SomeClass") + return activityName; + } + + /** + * Clears out internal reference when the action mode is destroyed. + */ + private class ActionModeCallbackWrapper implements ActionMode.Callback { + private final ActionMode.Callback mWrapped; + + public ActionModeCallbackWrapper(ActionMode.Callback wrapped) { + mWrapped = wrapped; + } + + public boolean onCreateActionMode(ActionMode mode, Menu menu) { + return mWrapped.onCreateActionMode(mode, menu); + } + + public boolean onPrepareActionMode(ActionMode mode, Menu menu) { + return mWrapped.onPrepareActionMode(mode, menu); + } + + public boolean onActionItemClicked(ActionMode mode, MenuItem item) { + return mWrapped.onActionItemClicked(mode, item); + } + + public void onDestroyActionMode(ActionMode mode) { + mWrapped.onDestroyActionMode(mode); + if (mActionModeView != null) { + mActionModeView.setVisibility(View.GONE); + mActionModeView.removeAllViews(); + } + if (mActivity instanceof OnActionModeFinishedListener) { + ((OnActionModeFinishedListener)mActivity).onActionModeFinished(mActionMode); + } + mActionMode = null; + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockNative.java b/actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockNative.java new file mode 100644 index 000000000..9afca185a --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockNative.java @@ -0,0 +1,328 @@ +package com.actionbarsherlock.internal; + +import com.actionbarsherlock.ActionBarSherlock; +import com.actionbarsherlock.app.ActionBar; +import com.actionbarsherlock.internal.app.ActionBarWrapper; +import com.actionbarsherlock.internal.view.menu.MenuWrapper; +import com.actionbarsherlock.view.ActionMode; +import com.actionbarsherlock.view.MenuInflater; +import android.app.Activity; +import android.content.Context; +import android.util.Log; +import android.util.TypedValue; +import android.view.ContextThemeWrapper; +import android.view.View; +import android.view.Window; +import android.view.ViewGroup.LayoutParams; + +@ActionBarSherlock.Implementation(api = 14) +public class ActionBarSherlockNative extends ActionBarSherlock { + private ActionBarWrapper mActionBar; + private ActionModeWrapper mActionMode; + private MenuWrapper mMenu; + + public ActionBarSherlockNative(Activity activity, int flags) { + super(activity, flags); + } + + + @Override + public ActionBar getActionBar() { + if (DEBUG) Log.d(TAG, "[getActionBar]"); + + initActionBar(); + return mActionBar; + } + + private void initActionBar() { + if (mActionBar != null || mActivity.getActionBar() == null) { + return; + } + + mActionBar = new ActionBarWrapper(mActivity); + } + + @Override + public void dispatchInvalidateOptionsMenu() { + if (DEBUG) Log.d(TAG, "[dispatchInvalidateOptionsMenu]"); + + mActivity.getWindow().invalidatePanelMenu(Window.FEATURE_OPTIONS_PANEL); + } + + @Override + public boolean dispatchCreateOptionsMenu(android.view.Menu menu) { + if (DEBUG) Log.d(TAG, "[dispatchCreateOptionsMenu] menu: " + menu); + + if (mMenu == null || menu != mMenu.unwrap()) { + mMenu = new MenuWrapper(menu); + } + + final boolean result = callbackCreateOptionsMenu(mMenu); + if (DEBUG) Log.d(TAG, "[dispatchCreateOptionsMenu] returning " + result); + return result; + } + + @Override + public boolean dispatchPrepareOptionsMenu(android.view.Menu menu) { + if (DEBUG) Log.d(TAG, "[dispatchPrepareOptionsMenu] menu: " + menu); + + final boolean result = callbackPrepareOptionsMenu(mMenu); + if (DEBUG) Log.d(TAG, "[dispatchPrepareOptionsMenu] returning " + result); + return result; + } + + @Override + public boolean dispatchOptionsItemSelected(android.view.MenuItem item) { + if (DEBUG) Log.d(TAG, "[dispatchOptionsItemSelected] item: " + item.getTitleCondensed()); + + final boolean result = callbackOptionsItemSelected(mMenu.findItem(item)); + if (DEBUG) Log.d(TAG, "[dispatchOptionsItemSelected] returning " + result); + return result; + } + + @Override + public boolean hasFeature(int feature) { + if (DEBUG) Log.d(TAG, "[hasFeature] feature: " + feature); + + final boolean result = mActivity.getWindow().hasFeature(feature); + if (DEBUG) Log.d(TAG, "[hasFeature] returning " + result); + return result; + } + + @Override + public boolean requestFeature(int featureId) { + if (DEBUG) Log.d(TAG, "[requestFeature] featureId: " + featureId); + + final boolean result = mActivity.getWindow().requestFeature(featureId); + if (DEBUG) Log.d(TAG, "[requestFeature] returning " + result); + return result; + } + + @Override + public void setUiOptions(int uiOptions) { + if (DEBUG) Log.d(TAG, "[setUiOptions] uiOptions: " + uiOptions); + + mActivity.getWindow().setUiOptions(uiOptions); + } + + @Override + public void setUiOptions(int uiOptions, int mask) { + if (DEBUG) Log.d(TAG, "[setUiOptions] uiOptions: " + uiOptions + ", mask: " + mask); + + mActivity.getWindow().setUiOptions(uiOptions, mask); + } + + @Override + public void setContentView(int layoutResId) { + if (DEBUG) Log.d(TAG, "[setContentView] layoutResId: " + layoutResId); + + mActivity.getWindow().setContentView(layoutResId); + initActionBar(); + } + + @Override + public void setContentView(View view, LayoutParams params) { + if (DEBUG) Log.d(TAG, "[setContentView] view: " + view + ", params: " + params); + + mActivity.getWindow().setContentView(view, params); + initActionBar(); + } + + @Override + public void addContentView(View view, LayoutParams params) { + if (DEBUG) Log.d(TAG, "[addContentView] view: " + view + ", params: " + params); + + mActivity.getWindow().addContentView(view, params); + initActionBar(); + } + + @Override + public void setTitle(CharSequence title) { + if (DEBUG) Log.d(TAG, "[setTitle] title: " + title); + + mActivity.getWindow().setTitle(title); + } + + @Override + public void setProgressBarVisibility(boolean visible) { + if (DEBUG) Log.d(TAG, "[setProgressBarVisibility] visible: " + visible); + + mActivity.setProgressBarVisibility(visible); + } + + @Override + public void setProgressBarIndeterminateVisibility(boolean visible) { + if (DEBUG) Log.d(TAG, "[setProgressBarIndeterminateVisibility] visible: " + visible); + + mActivity.setProgressBarIndeterminateVisibility(visible); + } + + @Override + public void setProgressBarIndeterminate(boolean indeterminate) { + if (DEBUG) Log.d(TAG, "[setProgressBarIndeterminate] indeterminate: " + indeterminate); + + mActivity.setProgressBarIndeterminate(indeterminate); + } + + @Override + public void setProgress(int progress) { + if (DEBUG) Log.d(TAG, "[setProgress] progress: " + progress); + + mActivity.setProgress(progress); + } + + @Override + public void setSecondaryProgress(int secondaryProgress) { + if (DEBUG) Log.d(TAG, "[setSecondaryProgress] secondaryProgress: " + secondaryProgress); + + mActivity.setSecondaryProgress(secondaryProgress); + } + + @Override + protected Context getThemedContext() { + Context context = mActivity; + TypedValue outValue = new TypedValue(); + mActivity.getTheme().resolveAttribute(android.R.attr.actionBarWidgetTheme, outValue, true); + if (outValue.resourceId != 0) { + //We are unable to test if this is the same as our current theme + //so we just wrap it and hope that if the attribute was specified + //then the user is intentionally specifying an alternate theme. + context = new ContextThemeWrapper(context, outValue.resourceId); + } + return context; + } + + @Override + public ActionMode startActionMode(com.actionbarsherlock.view.ActionMode.Callback callback) { + if (DEBUG) Log.d(TAG, "[startActionMode] callback: " + callback); + + if (mActionMode != null) { + mActionMode.finish(); + } + ActionModeCallbackWrapper wrapped = null; + if (callback != null) { + wrapped = new ActionModeCallbackWrapper(callback); + } + + //Calling this will trigger the callback wrapper's onCreate which + //is where we will set the new instance to mActionMode since we need + //to pass it through to the sherlock callbacks and the call below + //will not have returned yet to store its value. + mActivity.startActionMode(wrapped); + + return mActionMode; + } + + private class ActionModeCallbackWrapper implements android.view.ActionMode.Callback { + private final ActionMode.Callback mCallback; + + public ActionModeCallbackWrapper(ActionMode.Callback callback) { + mCallback = callback; + } + + @Override + public boolean onCreateActionMode(android.view.ActionMode mode, android.view.Menu menu) { + //See ActionBarSherlockNative#startActionMode + mActionMode = new ActionModeWrapper(mode); + + return mCallback.onCreateActionMode(mActionMode, mActionMode.getMenu()); + } + + @Override + public boolean onPrepareActionMode(android.view.ActionMode mode, android.view.Menu menu) { + return mCallback.onPrepareActionMode(mActionMode, mActionMode.getMenu()); + } + + @Override + public boolean onActionItemClicked(android.view.ActionMode mode, android.view.MenuItem item) { + return mCallback.onActionItemClicked(mActionMode, mActionMode.getMenu().findItem(item)); + } + + @Override + public void onDestroyActionMode(android.view.ActionMode mode) { + mCallback.onDestroyActionMode(mActionMode); + } + } + + private class ActionModeWrapper extends ActionMode { + private final android.view.ActionMode mActionMode; + private MenuWrapper mMenu = null; + + ActionModeWrapper(android.view.ActionMode actionMode) { + mActionMode = actionMode; + } + + @Override + public void setTitle(CharSequence title) { + mActionMode.setTitle(title); + } + + @Override + public void setTitle(int resId) { + mActionMode.setTitle(resId); + } + + @Override + public void setSubtitle(CharSequence subtitle) { + mActionMode.setSubtitle(subtitle); + } + + @Override + public void setSubtitle(int resId) { + mActionMode.setSubtitle(resId); + } + + @Override + public void setCustomView(View view) { + mActionMode.setCustomView(view); + } + + @Override + public void invalidate() { + mActionMode.invalidate(); + } + + @Override + public void finish() { + mActionMode.finish(); + } + + @Override + public MenuWrapper getMenu() { + if (mMenu == null) { + mMenu = new MenuWrapper(mActionMode.getMenu()); + } + return mMenu; + } + + @Override + public CharSequence getTitle() { + return mActionMode.getTitle(); + } + + @Override + public CharSequence getSubtitle() { + return mActionMode.getSubtitle(); + } + + @Override + public View getCustomView() { + return mActionMode.getCustomView(); + } + + @Override + public MenuInflater getMenuInflater() { + return ActionBarSherlockNative.this.getMenuInflater(); + } + + @Override + public void setTag(Object tag) { + mActionMode.setTag(tag); + } + + @Override + public Object getTag() { + return mActionMode.getTag(); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/ResourcesCompat.java b/actionbarsherlock/src/com/actionbarsherlock/internal/ResourcesCompat.java new file mode 100644 index 000000000..8e1efe8c5 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/ResourcesCompat.java @@ -0,0 +1,95 @@ +package com.actionbarsherlock.internal; + +import android.content.Context; +import android.os.Build; +import android.util.DisplayMetrics; +import com.actionbarsherlock.R; + +public final class ResourcesCompat { + //No instances + private ResourcesCompat() {} + + + /** + * Support implementation of {@code getResources().getBoolean()} that we + * can use to simulate filtering based on width and smallest width + * qualifiers on pre-3.2. + * + * @param context Context to load booleans from on 3.2+ and to fetch the + * display metrics. + * @param id Id of boolean to load. + * @return Associated boolean value as reflected by the current display + * metrics. + */ + public static boolean getResources_getBoolean(Context context, int id) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { + return context.getResources().getBoolean(id); + } + + DisplayMetrics metrics = context.getResources().getDisplayMetrics(); + float widthDp = metrics.widthPixels / metrics.density; + float heightDp = metrics.heightPixels / metrics.density; + float smallestWidthDp = (widthDp < heightDp) ? widthDp : heightDp; + + if (id == R.bool.abs__action_bar_embed_tabs) { + if (widthDp >= 480) { + return true; //values-w480dp + } + return false; //values + } + if (id == R.bool.abs__split_action_bar_is_narrow) { + if (widthDp >= 480) { + return false; //values-w480dp + } + return true; //values + } + if (id == R.bool.abs__action_bar_expanded_action_views_exclusive) { + if (smallestWidthDp >= 600) { + return false; //values-sw600dp + } + return true; //values + } + if (id == R.bool.abs__config_allowActionMenuItemTextWithIcon) { + if (widthDp >= 480) { + return true; //values-w480dp + } + return false; //values + } + + throw new IllegalArgumentException("Unknown boolean resource ID " + id); + } + + /** + * Support implementation of {@code getResources().getInteger()} that we + * can use to simulate filtering based on width qualifiers on pre-3.2. + * + * @param context Context to load integers from on 3.2+ and to fetch the + * display metrics. + * @param id Id of integer to load. + * @return Associated integer value as reflected by the current display + * metrics. + */ + public static int getResources_getInteger(Context context, int id) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { + return context.getResources().getInteger(id); + } + + DisplayMetrics metrics = context.getResources().getDisplayMetrics(); + float widthDp = metrics.widthPixels / metrics.density; + + if (id == R.integer.abs__max_action_buttons) { + if (widthDp >= 600) { + return 5; //values-w600dp + } + if (widthDp >= 500) { + return 4; //values-w500dp + } + if (widthDp >= 360) { + return 3; //values-w360dp + } + return 2; //values + } + + throw new IllegalArgumentException("Unknown integer resource ID " + id); + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/app/ActionBarImpl.java b/actionbarsherlock/src/com/actionbarsherlock/internal/app/ActionBarImpl.java new file mode 100644 index 000000000..6ae0402c0 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/app/ActionBarImpl.java @@ -0,0 +1,1026 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.app; + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import android.app.Activity; +import android.app.Dialog; +import android.content.Context; +import android.content.res.Configuration; +import android.content.res.Resources; +import android.graphics.drawable.Drawable; +import android.os.Build; +import android.os.Handler; +import android.support.v4.app.FragmentTransaction; +import android.util.TypedValue; +import android.view.ContextThemeWrapper; +import android.view.LayoutInflater; +import android.view.View; +import android.view.Window; +import android.view.accessibility.AccessibilityEvent; +import android.widget.SpinnerAdapter; +import com.actionbarsherlock.R; +import com.actionbarsherlock.app.ActionBar; +import com.actionbarsherlock.app.SherlockFragmentActivity; +import com.actionbarsherlock.internal.nineoldandroids.animation.Animator; +import com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorListenerAdapter; +import com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet; +import com.actionbarsherlock.internal.nineoldandroids.animation.ObjectAnimator; +import com.actionbarsherlock.internal.nineoldandroids.animation.Animator.AnimatorListener; +import com.actionbarsherlock.internal.nineoldandroids.widget.NineFrameLayout; +import com.actionbarsherlock.internal.view.menu.MenuBuilder; +import com.actionbarsherlock.internal.view.menu.MenuPopupHelper; +import com.actionbarsherlock.internal.view.menu.SubMenuBuilder; +import com.actionbarsherlock.internal.widget.ActionBarContainer; +import com.actionbarsherlock.internal.widget.ActionBarContextView; +import com.actionbarsherlock.internal.widget.ActionBarView; +import com.actionbarsherlock.internal.widget.ScrollingTabContainerView; +import com.actionbarsherlock.view.ActionMode; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; +import static com.actionbarsherlock.internal.ResourcesCompat.getResources_getBoolean; + +/** + * ActionBarImpl is the ActionBar implementation used + * by devices of all screen sizes. If it detects a compatible decor, + * it will split contextual modes across both the ActionBarView at + * the top of the screen and a horizontal LinearLayout at the bottom + * which is normally hidden. + */ +public class ActionBarImpl extends ActionBar { + //UNUSED private static final String TAG = "ActionBarImpl"; + + private Context mContext; + private Context mThemedContext; + private Activity mActivity; + //UNUSED private Dialog mDialog; + + private ActionBarContainer mContainerView; + private ActionBarView mActionView; + private ActionBarContextView mContextView; + private ActionBarContainer mSplitView; + private NineFrameLayout mContentView; + private ScrollingTabContainerView mTabScrollView; + + private ArrayList mTabs = new ArrayList(); + + private TabImpl mSelectedTab; + private int mSavedTabPosition = INVALID_POSITION; + + ActionModeImpl mActionMode; + ActionMode mDeferredDestroyActionMode; + ActionMode.Callback mDeferredModeDestroyCallback; + + private boolean mLastMenuVisibility; + private ArrayList mMenuVisibilityListeners = + new ArrayList(); + + private static final int CONTEXT_DISPLAY_NORMAL = 0; + private static final int CONTEXT_DISPLAY_SPLIT = 1; + + private static final int INVALID_POSITION = -1; + + private int mContextDisplayMode; + private boolean mHasEmbeddedTabs; + + final Handler mHandler = new Handler(); + Runnable mTabSelector; + + private Animator mCurrentShowAnim; + private Animator mCurrentModeAnim; + private boolean mShowHideAnimationEnabled; + boolean mWasHiddenBeforeMode; + + final AnimatorListener mHideListener = new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + if (mContentView != null) { + mContentView.setTranslationY(0); + mContainerView.setTranslationY(0); + } + if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) { + mSplitView.setVisibility(View.GONE); + } + mContainerView.setVisibility(View.GONE); + mContainerView.setTransitioning(false); + mCurrentShowAnim = null; + completeDeferredDestroyActionMode(); + } + }; + + final AnimatorListener mShowListener = new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + mCurrentShowAnim = null; + mContainerView.requestLayout(); + } + }; + + public ActionBarImpl(Activity activity, int features) { + mActivity = activity; + Window window = activity.getWindow(); + View decor = window.getDecorView(); + init(decor); + + //window.hasFeature() workaround for pre-3.0 + if ((features & (1 << Window.FEATURE_ACTION_BAR_OVERLAY)) == 0) { + mContentView = (NineFrameLayout)decor.findViewById(android.R.id.content); + } + } + + public ActionBarImpl(Dialog dialog) { + //UNUSED mDialog = dialog; + init(dialog.getWindow().getDecorView()); + } + + private void init(View decor) { + mContext = decor.getContext(); + mActionView = (ActionBarView) decor.findViewById(R.id.abs__action_bar); + mContextView = (ActionBarContextView) decor.findViewById( + R.id.abs__action_context_bar); + mContainerView = (ActionBarContainer) decor.findViewById( + R.id.abs__action_bar_container); + mSplitView = (ActionBarContainer) decor.findViewById( + R.id.abs__split_action_bar); + + if (mActionView == null || mContextView == null || mContainerView == null) { + throw new IllegalStateException(getClass().getSimpleName() + " can only be used " + + "with a compatible window decor layout"); + } + + mActionView.setContextView(mContextView); + mContextDisplayMode = mActionView.isSplitActionBar() ? + CONTEXT_DISPLAY_SPLIT : CONTEXT_DISPLAY_NORMAL; + + // Older apps get the home button interaction enabled by default. + // Newer apps need to enable it explicitly. + setHomeButtonEnabled(mContext.getApplicationInfo().targetSdkVersion < 14); + + setHasEmbeddedTabs(getResources_getBoolean(mContext, + R.bool.abs__action_bar_embed_tabs)); + } + + public void onConfigurationChanged(Configuration newConfig) { + setHasEmbeddedTabs(getResources_getBoolean(mContext, + R.bool.abs__action_bar_embed_tabs)); + + //Manually dispatch a configuration change to the action bar view on pre-2.2 + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) { + mActionView.onConfigurationChanged(newConfig); + if (mContextView != null) { + mContextView.onConfigurationChanged(newConfig); + } + } + } + + private void setHasEmbeddedTabs(boolean hasEmbeddedTabs) { + mHasEmbeddedTabs = hasEmbeddedTabs; + // Switch tab layout configuration if needed + if (!mHasEmbeddedTabs) { + mActionView.setEmbeddedTabView(null); + mContainerView.setTabContainer(mTabScrollView); + } else { + mContainerView.setTabContainer(null); + mActionView.setEmbeddedTabView(mTabScrollView); + } + final boolean isInTabMode = getNavigationMode() == NAVIGATION_MODE_TABS; + if (mTabScrollView != null) { + mTabScrollView.setVisibility(isInTabMode ? View.VISIBLE : View.GONE); + } + mActionView.setCollapsable(!mHasEmbeddedTabs && isInTabMode); + } + + private void ensureTabsExist() { + if (mTabScrollView != null) { + return; + } + + ScrollingTabContainerView tabScroller = new ScrollingTabContainerView(mContext); + + if (mHasEmbeddedTabs) { + tabScroller.setVisibility(View.VISIBLE); + mActionView.setEmbeddedTabView(tabScroller); + } else { + tabScroller.setVisibility(getNavigationMode() == NAVIGATION_MODE_TABS ? + View.VISIBLE : View.GONE); + mContainerView.setTabContainer(tabScroller); + } + mTabScrollView = tabScroller; + } + + void completeDeferredDestroyActionMode() { + if (mDeferredModeDestroyCallback != null) { + mDeferredModeDestroyCallback.onDestroyActionMode(mDeferredDestroyActionMode); + mDeferredDestroyActionMode = null; + mDeferredModeDestroyCallback = null; + } + } + + /** + * Enables or disables animation between show/hide states. + * If animation is disabled using this method, animations in progress + * will be finished. + * + * @param enabled true to animate, false to not animate. + */ + public void setShowHideAnimationEnabled(boolean enabled) { + mShowHideAnimationEnabled = enabled; + if (!enabled && mCurrentShowAnim != null) { + mCurrentShowAnim.end(); + } + } + + public void addOnMenuVisibilityListener(OnMenuVisibilityListener listener) { + mMenuVisibilityListeners.add(listener); + } + + public void removeOnMenuVisibilityListener(OnMenuVisibilityListener listener) { + mMenuVisibilityListeners.remove(listener); + } + + public void dispatchMenuVisibilityChanged(boolean isVisible) { + if (isVisible == mLastMenuVisibility) { + return; + } + mLastMenuVisibility = isVisible; + + final int count = mMenuVisibilityListeners.size(); + for (int i = 0; i < count; i++) { + mMenuVisibilityListeners.get(i).onMenuVisibilityChanged(isVisible); + } + } + + @Override + public void setCustomView(int resId) { + setCustomView(LayoutInflater.from(getThemedContext()).inflate(resId, mActionView, false)); + } + + @Override + public void setDisplayUseLogoEnabled(boolean useLogo) { + setDisplayOptions(useLogo ? DISPLAY_USE_LOGO : 0, DISPLAY_USE_LOGO); + } + + @Override + public void setDisplayShowHomeEnabled(boolean showHome) { + setDisplayOptions(showHome ? DISPLAY_SHOW_HOME : 0, DISPLAY_SHOW_HOME); + } + + @Override + public void setDisplayHomeAsUpEnabled(boolean showHomeAsUp) { + setDisplayOptions(showHomeAsUp ? DISPLAY_HOME_AS_UP : 0, DISPLAY_HOME_AS_UP); + } + + @Override + public void setDisplayShowTitleEnabled(boolean showTitle) { + setDisplayOptions(showTitle ? DISPLAY_SHOW_TITLE : 0, DISPLAY_SHOW_TITLE); + } + + @Override + public void setDisplayShowCustomEnabled(boolean showCustom) { + setDisplayOptions(showCustom ? DISPLAY_SHOW_CUSTOM : 0, DISPLAY_SHOW_CUSTOM); + } + + @Override + public void setHomeButtonEnabled(boolean enable) { + mActionView.setHomeButtonEnabled(enable); + } + + @Override + public void setTitle(int resId) { + setTitle(mContext.getString(resId)); + } + + @Override + public void setSubtitle(int resId) { + setSubtitle(mContext.getString(resId)); + } + + public void setSelectedNavigationItem(int position) { + switch (mActionView.getNavigationMode()) { + case NAVIGATION_MODE_TABS: + selectTab(mTabs.get(position)); + break; + case NAVIGATION_MODE_LIST: + mActionView.setDropdownSelectedPosition(position); + break; + default: + throw new IllegalStateException( + "setSelectedNavigationIndex not valid for current navigation mode"); + } + } + + public void removeAllTabs() { + cleanupTabs(); + } + + private void cleanupTabs() { + if (mSelectedTab != null) { + selectTab(null); + } + mTabs.clear(); + if (mTabScrollView != null) { + mTabScrollView.removeAllTabs(); + } + mSavedTabPosition = INVALID_POSITION; + } + + public void setTitle(CharSequence title) { + mActionView.setTitle(title); + } + + public void setSubtitle(CharSequence subtitle) { + mActionView.setSubtitle(subtitle); + } + + public void setDisplayOptions(int options) { + mActionView.setDisplayOptions(options); + } + + public void setDisplayOptions(int options, int mask) { + final int current = mActionView.getDisplayOptions(); + mActionView.setDisplayOptions((options & mask) | (current & ~mask)); + } + + public void setBackgroundDrawable(Drawable d) { + mContainerView.setPrimaryBackground(d); + } + + public void setStackedBackgroundDrawable(Drawable d) { + mContainerView.setStackedBackground(d); + } + + public void setSplitBackgroundDrawable(Drawable d) { + if (mSplitView != null) { + mSplitView.setSplitBackground(d); + } + } + + public View getCustomView() { + return mActionView.getCustomNavigationView(); + } + + public CharSequence getTitle() { + return mActionView.getTitle(); + } + + public CharSequence getSubtitle() { + return mActionView.getSubtitle(); + } + + public int getNavigationMode() { + return mActionView.getNavigationMode(); + } + + public int getDisplayOptions() { + return mActionView.getDisplayOptions(); + } + + public ActionMode startActionMode(ActionMode.Callback callback) { + boolean wasHidden = false; + if (mActionMode != null) { + wasHidden = mWasHiddenBeforeMode; + mActionMode.finish(); + } + + mContextView.killMode(); + ActionModeImpl mode = new ActionModeImpl(callback); + if (mode.dispatchOnCreate()) { + mWasHiddenBeforeMode = !isShowing() || wasHidden; + mode.invalidate(); + mContextView.initForMode(mode); + animateToMode(true); + if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) { + // TODO animate this + mSplitView.setVisibility(View.VISIBLE); + } + mContextView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); + mActionMode = mode; + return mode; + } + return null; + } + + private void configureTab(Tab tab, int position) { + final TabImpl tabi = (TabImpl) tab; + final ActionBar.TabListener callback = tabi.getCallback(); + + if (callback == null) { + throw new IllegalStateException("Action Bar Tab must have a Callback"); + } + + tabi.setPosition(position); + mTabs.add(position, tabi); + + final int count = mTabs.size(); + for (int i = position + 1; i < count; i++) { + mTabs.get(i).setPosition(i); + } + } + + @Override + public void addTab(Tab tab) { + addTab(tab, mTabs.isEmpty()); + } + + @Override + public void addTab(Tab tab, int position) { + addTab(tab, position, mTabs.isEmpty()); + } + + @Override + public void addTab(Tab tab, boolean setSelected) { + ensureTabsExist(); + mTabScrollView.addTab(tab, setSelected); + configureTab(tab, mTabs.size()); + if (setSelected) { + selectTab(tab); + } + } + + @Override + public void addTab(Tab tab, int position, boolean setSelected) { + ensureTabsExist(); + mTabScrollView.addTab(tab, position, setSelected); + configureTab(tab, position); + if (setSelected) { + selectTab(tab); + } + } + + @Override + public Tab newTab() { + return new TabImpl(); + } + + @Override + public void removeTab(Tab tab) { + removeTabAt(tab.getPosition()); + } + + @Override + public void removeTabAt(int position) { + if (mTabScrollView == null) { + // No tabs around to remove + return; + } + + int selectedTabPosition = mSelectedTab != null + ? mSelectedTab.getPosition() : mSavedTabPosition; + mTabScrollView.removeTabAt(position); + TabImpl removedTab = mTabs.remove(position); + if (removedTab != null) { + removedTab.setPosition(-1); + } + + final int newTabCount = mTabs.size(); + for (int i = position; i < newTabCount; i++) { + mTabs.get(i).setPosition(i); + } + + if (selectedTabPosition == position) { + selectTab(mTabs.isEmpty() ? null : mTabs.get(Math.max(0, position - 1))); + } + } + + @Override + public void selectTab(Tab tab) { + if (getNavigationMode() != NAVIGATION_MODE_TABS) { + mSavedTabPosition = tab != null ? tab.getPosition() : INVALID_POSITION; + return; + } + + FragmentTransaction trans = null; + if (mActivity instanceof SherlockFragmentActivity) { + trans = ((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction() + .disallowAddToBackStack(); + } + + if (mSelectedTab == tab) { + if (mSelectedTab != null) { + mSelectedTab.getCallback().onTabReselected(mSelectedTab, trans); + mTabScrollView.animateToTab(tab.getPosition()); + } + } else { + mTabScrollView.setTabSelected(tab != null ? tab.getPosition() : Tab.INVALID_POSITION); + if (mSelectedTab != null) { + mSelectedTab.getCallback().onTabUnselected(mSelectedTab, trans); + } + mSelectedTab = (TabImpl) tab; + if (mSelectedTab != null) { + mSelectedTab.getCallback().onTabSelected(mSelectedTab, trans); + } + } + + if (trans != null && !trans.isEmpty()) { + trans.commit(); + } + } + + @Override + public Tab getSelectedTab() { + return mSelectedTab; + } + + @Override + public int getHeight() { + return mContainerView.getHeight(); + } + + @Override + public void show() { + show(true); + } + + void show(boolean markHiddenBeforeMode) { + if (mCurrentShowAnim != null) { + mCurrentShowAnim.end(); + } + if (mContainerView.getVisibility() == View.VISIBLE) { + if (markHiddenBeforeMode) mWasHiddenBeforeMode = false; + return; + } + mContainerView.setVisibility(View.VISIBLE); + + if (mShowHideAnimationEnabled) { + mContainerView.setAlpha(0); + AnimatorSet anim = new AnimatorSet(); + AnimatorSet.Builder b = anim.play(ObjectAnimator.ofFloat(mContainerView, "alpha", 1)); + if (mContentView != null) { + b.with(ObjectAnimator.ofFloat(mContentView, "translationY", + -mContainerView.getHeight(), 0)); + mContainerView.setTranslationY(-mContainerView.getHeight()); + b.with(ObjectAnimator.ofFloat(mContainerView, "translationY", 0)); + } + if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) { + mSplitView.setAlpha(0); + mSplitView.setVisibility(View.VISIBLE); + b.with(ObjectAnimator.ofFloat(mSplitView, "alpha", 1)); + } + anim.addListener(mShowListener); + mCurrentShowAnim = anim; + anim.start(); + } else { + mContainerView.setAlpha(1); + mContainerView.setTranslationY(0); + mShowListener.onAnimationEnd(null); + } + } + + @Override + public void hide() { + if (mCurrentShowAnim != null) { + mCurrentShowAnim.end(); + } + if (mContainerView.getVisibility() == View.GONE) { + return; + } + + if (mShowHideAnimationEnabled) { + mContainerView.setAlpha(1); + mContainerView.setTransitioning(true); + AnimatorSet anim = new AnimatorSet(); + AnimatorSet.Builder b = anim.play(ObjectAnimator.ofFloat(mContainerView, "alpha", 0)); + if (mContentView != null) { + b.with(ObjectAnimator.ofFloat(mContentView, "translationY", + 0, -mContainerView.getHeight())); + b.with(ObjectAnimator.ofFloat(mContainerView, "translationY", + -mContainerView.getHeight())); + } + if (mSplitView != null && mSplitView.getVisibility() == View.VISIBLE) { + mSplitView.setAlpha(1); + b.with(ObjectAnimator.ofFloat(mSplitView, "alpha", 0)); + } + anim.addListener(mHideListener); + mCurrentShowAnim = anim; + anim.start(); + } else { + mHideListener.onAnimationEnd(null); + } + } + + public boolean isShowing() { + return mContainerView.getVisibility() == View.VISIBLE; + } + + void animateToMode(boolean toActionMode) { + if (toActionMode) { + show(false); + } + if (mCurrentModeAnim != null) { + mCurrentModeAnim.end(); + } + + mActionView.animateToVisibility(toActionMode ? View.GONE : View.VISIBLE); + mContextView.animateToVisibility(toActionMode ? View.VISIBLE : View.GONE); + if (mTabScrollView != null && !mActionView.hasEmbeddedTabs() && mActionView.isCollapsed()) { + mTabScrollView.animateToVisibility(toActionMode ? View.GONE : View.VISIBLE); + } + } + + public Context getThemedContext() { + if (mThemedContext == null) { + TypedValue outValue = new TypedValue(); + Resources.Theme currentTheme = mContext.getTheme(); + currentTheme.resolveAttribute(R.attr.actionBarWidgetTheme, + outValue, true); + final int targetThemeRes = outValue.resourceId; + + if (targetThemeRes != 0) { //XXX && mContext.getThemeResId() != targetThemeRes) { + mThemedContext = new ContextThemeWrapper(mContext, targetThemeRes); + } else { + mThemedContext = mContext; + } + } + return mThemedContext; + } + + /** + * @hide + */ + public class ActionModeImpl extends ActionMode implements MenuBuilder.Callback { + private ActionMode.Callback mCallback; + private MenuBuilder mMenu; + private WeakReference mCustomView; + + public ActionModeImpl(ActionMode.Callback callback) { + mCallback = callback; + mMenu = new MenuBuilder(getThemedContext()) + .setDefaultShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); + mMenu.setCallback(this); + } + + @Override + public MenuInflater getMenuInflater() { + return new MenuInflater(getThemedContext()); + } + + @Override + public Menu getMenu() { + return mMenu; + } + + @Override + public void finish() { + if (mActionMode != this) { + // Not the active action mode - no-op + return; + } + + // If we were hidden before the mode was shown, defer the onDestroy + // callback until the animation is finished and associated relayout + // is about to happen. This lets apps better anticipate visibility + // and layout behavior. + if (mWasHiddenBeforeMode) { + mDeferredDestroyActionMode = this; + mDeferredModeDestroyCallback = mCallback; + } else { + mCallback.onDestroyActionMode(this); + } + mCallback = null; + animateToMode(false); + + // Clear out the context mode views after the animation finishes + mContextView.closeMode(); + mActionView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); + + mActionMode = null; + + if (mWasHiddenBeforeMode) { + hide(); + } + } + + @Override + public void invalidate() { + mMenu.stopDispatchingItemsChanged(); + try { + mCallback.onPrepareActionMode(this, mMenu); + } finally { + mMenu.startDispatchingItemsChanged(); + } + } + + public boolean dispatchOnCreate() { + mMenu.stopDispatchingItemsChanged(); + try { + return mCallback.onCreateActionMode(this, mMenu); + } finally { + mMenu.startDispatchingItemsChanged(); + } + } + + @Override + public void setCustomView(View view) { + mContextView.setCustomView(view); + mCustomView = new WeakReference(view); + } + + @Override + public void setSubtitle(CharSequence subtitle) { + mContextView.setSubtitle(subtitle); + } + + @Override + public void setTitle(CharSequence title) { + mContextView.setTitle(title); + } + + @Override + public void setTitle(int resId) { + setTitle(mContext.getResources().getString(resId)); + } + + @Override + public void setSubtitle(int resId) { + setSubtitle(mContext.getResources().getString(resId)); + } + + @Override + public CharSequence getTitle() { + return mContextView.getTitle(); + } + + @Override + public CharSequence getSubtitle() { + return mContextView.getSubtitle(); + } + + @Override + public View getCustomView() { + return mCustomView != null ? mCustomView.get() : null; + } + + public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) { + if (mCallback != null) { + return mCallback.onActionItemClicked(this, item); + } else { + return false; + } + } + + public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) { + } + + public boolean onSubMenuSelected(SubMenuBuilder subMenu) { + if (mCallback == null) { + return false; + } + + if (!subMenu.hasVisibleItems()) { + return true; + } + + new MenuPopupHelper(getThemedContext(), subMenu).show(); + return true; + } + + public void onCloseSubMenu(SubMenuBuilder menu) { + } + + public void onMenuModeChange(MenuBuilder menu) { + if (mCallback == null) { + return; + } + invalidate(); + mContextView.showOverflowMenu(); + } + } + + /** + * @hide + */ + public class TabImpl extends ActionBar.Tab { + private ActionBar.TabListener mCallback; + private Object mTag; + private Drawable mIcon; + private CharSequence mText; + private CharSequence mContentDesc; + private int mPosition = -1; + private View mCustomView; + + @Override + public Object getTag() { + return mTag; + } + + @Override + public Tab setTag(Object tag) { + mTag = tag; + return this; + } + + public ActionBar.TabListener getCallback() { + return mCallback; + } + + @Override + public Tab setTabListener(ActionBar.TabListener callback) { + mCallback = callback; + return this; + } + + @Override + public View getCustomView() { + return mCustomView; + } + + @Override + public Tab setCustomView(View view) { + mCustomView = view; + if (mPosition >= 0) { + mTabScrollView.updateTab(mPosition); + } + return this; + } + + @Override + public Tab setCustomView(int layoutResId) { + return setCustomView(LayoutInflater.from(getThemedContext()) + .inflate(layoutResId, null)); + } + + @Override + public Drawable getIcon() { + return mIcon; + } + + @Override + public int getPosition() { + return mPosition; + } + + public void setPosition(int position) { + mPosition = position; + } + + @Override + public CharSequence getText() { + return mText; + } + + @Override + public Tab setIcon(Drawable icon) { + mIcon = icon; + if (mPosition >= 0) { + mTabScrollView.updateTab(mPosition); + } + return this; + } + + @Override + public Tab setIcon(int resId) { + return setIcon(mContext.getResources().getDrawable(resId)); + } + + @Override + public Tab setText(CharSequence text) { + mText = text; + if (mPosition >= 0) { + mTabScrollView.updateTab(mPosition); + } + return this; + } + + @Override + public Tab setText(int resId) { + return setText(mContext.getResources().getText(resId)); + } + + @Override + public void select() { + selectTab(this); + } + + @Override + public Tab setContentDescription(int resId) { + return setContentDescription(mContext.getResources().getText(resId)); + } + + @Override + public Tab setContentDescription(CharSequence contentDesc) { + mContentDesc = contentDesc; + if (mPosition >= 0) { + mTabScrollView.updateTab(mPosition); + } + return this; + } + + @Override + public CharSequence getContentDescription() { + return mContentDesc; + } + } + + @Override + public void setCustomView(View view) { + mActionView.setCustomNavigationView(view); + } + + @Override + public void setCustomView(View view, LayoutParams layoutParams) { + view.setLayoutParams(layoutParams); + mActionView.setCustomNavigationView(view); + } + + @Override + public void setListNavigationCallbacks(SpinnerAdapter adapter, OnNavigationListener callback) { + mActionView.setDropdownAdapter(adapter); + mActionView.setCallback(callback); + } + + @Override + public int getSelectedNavigationIndex() { + switch (mActionView.getNavigationMode()) { + case NAVIGATION_MODE_TABS: + return mSelectedTab != null ? mSelectedTab.getPosition() : -1; + case NAVIGATION_MODE_LIST: + return mActionView.getDropdownSelectedPosition(); + default: + return -1; + } + } + + @Override + public int getNavigationItemCount() { + switch (mActionView.getNavigationMode()) { + case NAVIGATION_MODE_TABS: + return mTabs.size(); + case NAVIGATION_MODE_LIST: + SpinnerAdapter adapter = mActionView.getDropdownAdapter(); + return adapter != null ? adapter.getCount() : 0; + default: + return 0; + } + } + + @Override + public int getTabCount() { + return mTabs.size(); + } + + @Override + public void setNavigationMode(int mode) { + final int oldMode = mActionView.getNavigationMode(); + switch (oldMode) { + case NAVIGATION_MODE_TABS: + mSavedTabPosition = getSelectedNavigationIndex(); + selectTab(null); + mTabScrollView.setVisibility(View.GONE); + break; + } + mActionView.setNavigationMode(mode); + switch (mode) { + case NAVIGATION_MODE_TABS: + ensureTabsExist(); + mTabScrollView.setVisibility(View.VISIBLE); + if (mSavedTabPosition != INVALID_POSITION) { + setSelectedNavigationItem(mSavedTabPosition); + mSavedTabPosition = INVALID_POSITION; + } + break; + } + mActionView.setCollapsable(mode == NAVIGATION_MODE_TABS && !mHasEmbeddedTabs); + } + + @Override + public Tab getTabAt(int index) { + return mTabs.get(index); + } + + + @Override + public void setIcon(int resId) { + mActionView.setIcon(resId); + } + + @Override + public void setIcon(Drawable icon) { + mActionView.setIcon(icon); + } + + @Override + public void setLogo(int resId) { + mActionView.setLogo(resId); + } + + @Override + public void setLogo(Drawable logo) { + mActionView.setLogo(logo); + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/app/ActionBarWrapper.java b/actionbarsherlock/src/com/actionbarsherlock/internal/app/ActionBarWrapper.java new file mode 100644 index 000000000..e390ea428 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/app/ActionBarWrapper.java @@ -0,0 +1,468 @@ +package com.actionbarsherlock.internal.app; + +import java.util.HashSet; +import java.util.Set; + +import android.app.Activity; +import android.content.Context; +import android.graphics.drawable.Drawable; +import android.support.v4.app.FragmentTransaction; +import android.view.View; +import android.widget.SpinnerAdapter; + +import com.actionbarsherlock.app.ActionBar; +import com.actionbarsherlock.app.SherlockFragmentActivity; + +public class ActionBarWrapper extends ActionBar implements android.app.ActionBar.OnNavigationListener, android.app.ActionBar.OnMenuVisibilityListener { + private final Activity mActivity; + private final android.app.ActionBar mActionBar; + private ActionBar.OnNavigationListener mNavigationListener; + private Set mMenuVisibilityListeners = new HashSet(1); + private FragmentTransaction mFragmentTransaction; + + + public ActionBarWrapper(Activity activity) { + mActivity = activity; + mActionBar = activity.getActionBar(); + if (mActionBar != null) { + mActionBar.addOnMenuVisibilityListener(this); + } + } + + + @Override + public void setHomeButtonEnabled(boolean enabled) { + mActionBar.setHomeButtonEnabled(enabled); + } + + @Override + public Context getThemedContext() { + return mActionBar.getThemedContext(); + } + + @Override + public void setCustomView(View view) { + mActionBar.setCustomView(view); + } + + @Override + public void setCustomView(View view, LayoutParams layoutParams) { + android.app.ActionBar.LayoutParams lp = new android.app.ActionBar.LayoutParams(layoutParams); + lp.gravity = layoutParams.gravity; + lp.bottomMargin = layoutParams.bottomMargin; + lp.topMargin = layoutParams.topMargin; + lp.leftMargin = layoutParams.leftMargin; + lp.rightMargin = layoutParams.rightMargin; + mActionBar.setCustomView(view, lp); + } + + @Override + public void setCustomView(int resId) { + mActionBar.setCustomView(resId); + } + + @Override + public void setIcon(int resId) { + mActionBar.setIcon(resId); + } + + @Override + public void setIcon(Drawable icon) { + mActionBar.setIcon(icon); + } + + @Override + public void setLogo(int resId) { + mActionBar.setLogo(resId); + } + + @Override + public void setLogo(Drawable logo) { + mActionBar.setLogo(logo); + } + + @Override + public void setListNavigationCallbacks(SpinnerAdapter adapter, OnNavigationListener callback) { + mNavigationListener = callback; + mActionBar.setListNavigationCallbacks(adapter, (callback != null) ? this : null); + } + + @Override + public boolean onNavigationItemSelected(int itemPosition, long itemId) { + //This should never be a NullPointerException since we only set + //ourselves as the listener when the callback is not null. + return mNavigationListener.onNavigationItemSelected(itemPosition, itemId); + } + + @Override + public void setSelectedNavigationItem(int position) { + mActionBar.setSelectedNavigationItem(position); + } + + @Override + public int getSelectedNavigationIndex() { + return mActionBar.getSelectedNavigationIndex(); + } + + @Override + public int getNavigationItemCount() { + return mActionBar.getNavigationItemCount(); + } + + @Override + public void setTitle(CharSequence title) { + mActionBar.setTitle(title); + } + + @Override + public void setTitle(int resId) { + mActionBar.setTitle(resId); + } + + @Override + public void setSubtitle(CharSequence subtitle) { + mActionBar.setSubtitle(subtitle); + } + + @Override + public void setSubtitle(int resId) { + mActionBar.setSubtitle(resId); + } + + @Override + public void setDisplayOptions(int options) { + mActionBar.setDisplayOptions(options); + } + + @Override + public void setDisplayOptions(int options, int mask) { + mActionBar.setDisplayOptions(options, mask); + } + + @Override + public void setDisplayUseLogoEnabled(boolean useLogo) { + mActionBar.setDisplayUseLogoEnabled(useLogo); + } + + @Override + public void setDisplayShowHomeEnabled(boolean showHome) { + mActionBar.setDisplayShowHomeEnabled(showHome); + } + + @Override + public void setDisplayHomeAsUpEnabled(boolean showHomeAsUp) { + mActionBar.setDisplayHomeAsUpEnabled(showHomeAsUp); + } + + @Override + public void setDisplayShowTitleEnabled(boolean showTitle) { + mActionBar.setDisplayShowTitleEnabled(showTitle); + } + + @Override + public void setDisplayShowCustomEnabled(boolean showCustom) { + mActionBar.setDisplayShowCustomEnabled(showCustom); + } + + @Override + public void setBackgroundDrawable(Drawable d) { + mActionBar.setBackgroundDrawable(d); + } + + @Override + public void setStackedBackgroundDrawable(Drawable d) { + mActionBar.setStackedBackgroundDrawable(d); + } + + @Override + public void setSplitBackgroundDrawable(Drawable d) { + mActionBar.setSplitBackgroundDrawable(d); + } + + @Override + public View getCustomView() { + return mActionBar.getCustomView(); + } + + @Override + public CharSequence getTitle() { + return mActionBar.getTitle(); + } + + @Override + public CharSequence getSubtitle() { + return mActionBar.getSubtitle(); + } + + @Override + public int getNavigationMode() { + return mActionBar.getNavigationMode(); + } + + @Override + public void setNavigationMode(int mode) { + mActionBar.setNavigationMode(mode); + } + + @Override + public int getDisplayOptions() { + return mActionBar.getDisplayOptions(); + } + + public class TabWrapper extends ActionBar.Tab implements android.app.ActionBar.TabListener { + final android.app.ActionBar.Tab mNativeTab; + private Object mTag; + private TabListener mListener; + + public TabWrapper(android.app.ActionBar.Tab nativeTab) { + mNativeTab = nativeTab; + mNativeTab.setTag(this); + } + + @Override + public int getPosition() { + return mNativeTab.getPosition(); + } + + @Override + public Drawable getIcon() { + return mNativeTab.getIcon(); + } + + @Override + public CharSequence getText() { + return mNativeTab.getText(); + } + + @Override + public Tab setIcon(Drawable icon) { + mNativeTab.setIcon(icon); + return this; + } + + @Override + public Tab setIcon(int resId) { + mNativeTab.setIcon(resId); + return this; + } + + @Override + public Tab setText(CharSequence text) { + mNativeTab.setText(text); + return this; + } + + @Override + public Tab setText(int resId) { + mNativeTab.setText(resId); + return this; + } + + @Override + public Tab setCustomView(View view) { + mNativeTab.setCustomView(view); + return this; + } + + @Override + public Tab setCustomView(int layoutResId) { + mNativeTab.setCustomView(layoutResId); + return this; + } + + @Override + public View getCustomView() { + return mNativeTab.getCustomView(); + } + + @Override + public Tab setTag(Object obj) { + mTag = obj; + return this; + } + + @Override + public Object getTag() { + return mTag; + } + + @Override + public Tab setTabListener(TabListener listener) { + mNativeTab.setTabListener(listener != null ? this : null); + mListener = listener; + return this; + } + + @Override + public void select() { + mNativeTab.select(); + } + + @Override + public Tab setContentDescription(int resId) { + mNativeTab.setContentDescription(resId); + return this; + } + + @Override + public Tab setContentDescription(CharSequence contentDesc) { + mNativeTab.setContentDescription(contentDesc); + return this; + } + + @Override + public CharSequence getContentDescription() { + return mNativeTab.getContentDescription(); + } + + @Override + public void onTabReselected(android.app.ActionBar.Tab tab, android.app.FragmentTransaction ft) { + if (mListener != null) { + FragmentTransaction trans = null; + if (mActivity instanceof SherlockFragmentActivity) { + trans = ((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction() + .disallowAddToBackStack(); + } + + mListener.onTabReselected(this, trans); + + if (trans != null && !trans.isEmpty()) { + trans.commit(); + } + } + } + + @Override + public void onTabSelected(android.app.ActionBar.Tab tab, android.app.FragmentTransaction ft) { + if (mListener != null) { + + if (mFragmentTransaction == null && mActivity instanceof SherlockFragmentActivity) { + mFragmentTransaction = ((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction() + .disallowAddToBackStack(); + } + + mListener.onTabSelected(this, mFragmentTransaction); + + if (mFragmentTransaction != null) { + if (!mFragmentTransaction.isEmpty()) { + mFragmentTransaction.commit(); + } + mFragmentTransaction = null; + } + } + } + + @Override + public void onTabUnselected(android.app.ActionBar.Tab tab, android.app.FragmentTransaction ft) { + if (mListener != null) { + FragmentTransaction trans = null; + if (mActivity instanceof SherlockFragmentActivity) { + trans = ((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction() + .disallowAddToBackStack(); + mFragmentTransaction = trans; + } + + mListener.onTabUnselected(this, trans); + } + } + } + + @Override + public Tab newTab() { + return new TabWrapper(mActionBar.newTab()); + } + + @Override + public void addTab(Tab tab) { + mActionBar.addTab(((TabWrapper)tab).mNativeTab); + } + + @Override + public void addTab(Tab tab, boolean setSelected) { + mActionBar.addTab(((TabWrapper)tab).mNativeTab, setSelected); + } + + @Override + public void addTab(Tab tab, int position) { + mActionBar.addTab(((TabWrapper)tab).mNativeTab, position); + } + + @Override + public void addTab(Tab tab, int position, boolean setSelected) { + mActionBar.addTab(((TabWrapper)tab).mNativeTab, position, setSelected); + } + + @Override + public void removeTab(Tab tab) { + mActionBar.removeTab(((TabWrapper)tab).mNativeTab); + } + + @Override + public void removeTabAt(int position) { + mActionBar.removeTabAt(position); + } + + @Override + public void removeAllTabs() { + mActionBar.removeAllTabs(); + } + + @Override + public void selectTab(Tab tab) { + mActionBar.selectTab(((TabWrapper)tab).mNativeTab); + } + + @Override + public Tab getSelectedTab() { + android.app.ActionBar.Tab selected = mActionBar.getSelectedTab(); + return (selected != null) ? (Tab)selected.getTag() : null; + } + + @Override + public Tab getTabAt(int index) { + android.app.ActionBar.Tab selected = mActionBar.getTabAt(index); + return (selected != null) ? (Tab)selected.getTag() : null; + } + + @Override + public int getTabCount() { + return mActionBar.getTabCount(); + } + + @Override + public int getHeight() { + return mActionBar.getHeight(); + } + + @Override + public void show() { + mActionBar.show(); + } + + @Override + public void hide() { + mActionBar.hide(); + } + + @Override + public boolean isShowing() { + return mActionBar.isShowing(); + } + + @Override + public void addOnMenuVisibilityListener(OnMenuVisibilityListener listener) { + mMenuVisibilityListeners.add(listener); + } + + @Override + public void removeOnMenuVisibilityListener(OnMenuVisibilityListener listener) { + mMenuVisibilityListeners.remove(listener); + } + + @Override + public void onMenuVisibilityChanged(boolean isVisible) { + for (OnMenuVisibilityListener listener : mMenuVisibilityListeners) { + listener.onMenuVisibilityChanged(isVisible); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/Animator.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/Animator.java new file mode 100644 index 000000000..2caf5b4a9 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/Animator.java @@ -0,0 +1,278 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; + +import java.util.ArrayList; + +import android.view.animation.Interpolator; + +/** + * This is the superclass for classes which provide basic support for animations which can be + * started, ended, and have AnimatorListeners added to them. + */ +public abstract class Animator implements Cloneable { + + + /** + * The set of listeners to be sent events through the life of an animation. + */ + ArrayList mListeners = null; + + /** + * Starts this animation. If the animation has a nonzero startDelay, the animation will start + * running after that delay elapses. A non-delayed animation will have its initial + * value(s) set immediately, followed by calls to + * {@link AnimatorListener#onAnimationStart(Animator)} for any listeners of this animator. + * + *

The animation started by calling this method will be run on the thread that called + * this method. This thread should have a Looper on it (a runtime exception will be thrown if + * this is not the case). Also, if the animation will animate + * properties of objects in the view hierarchy, then the calling thread should be the UI + * thread for that view hierarchy.

+ * + */ + public void start() { + } + + /** + * Cancels the animation. Unlike {@link #end()}, cancel() causes the animation to + * stop in its tracks, sending an + * {@link android.animation.Animator.AnimatorListener#onAnimationCancel(Animator)} to + * its listeners, followed by an + * {@link android.animation.Animator.AnimatorListener#onAnimationEnd(Animator)} message. + * + *

This method must be called on the thread that is running the animation.

+ */ + public void cancel() { + } + + /** + * Ends the animation. This causes the animation to assign the end value of the property being + * animated, then calling the + * {@link android.animation.Animator.AnimatorListener#onAnimationEnd(Animator)} method on + * its listeners. + * + *

This method must be called on the thread that is running the animation.

+ */ + public void end() { + } + + /** + * The amount of time, in milliseconds, to delay starting the animation after + * {@link #start()} is called. + * + * @return the number of milliseconds to delay running the animation + */ + public abstract long getStartDelay(); + + /** + * The amount of time, in milliseconds, to delay starting the animation after + * {@link #start()} is called. + + * @param startDelay The amount of the delay, in milliseconds + */ + public abstract void setStartDelay(long startDelay); + + + /** + * Sets the length of the animation. + * + * @param duration The length of the animation, in milliseconds. + */ + public abstract Animator setDuration(long duration); + + /** + * Gets the length of the animation. + * + * @return The length of the animation, in milliseconds. + */ + public abstract long getDuration(); + + /** + * The time interpolator used in calculating the elapsed fraction of this animation. The + * interpolator determines whether the animation runs with linear or non-linear motion, + * such as acceleration and deceleration. The default value is + * {@link android.view.animation.AccelerateDecelerateInterpolator} + * + * @param value the interpolator to be used by this animation + */ + public abstract void setInterpolator(/*Time*/Interpolator value); + + /** + * Returns whether this Animator is currently running (having been started and gone past any + * initial startDelay period and not yet ended). + * + * @return Whether the Animator is running. + */ + public abstract boolean isRunning(); + + /** + * Returns whether this Animator has been started and not yet ended. This state is a superset + * of the state of {@link #isRunning()}, because an Animator with a nonzero + * {@link #getStartDelay() startDelay} will return true for {@link #isStarted()} during the + * delay phase, whereas {@link #isRunning()} will return true only after the delay phase + * is complete. + * + * @return Whether the Animator has been started and not yet ended. + */ + public boolean isStarted() { + // Default method returns value for isRunning(). Subclasses should override to return a + // real value. + return isRunning(); + } + + /** + * Adds a listener to the set of listeners that are sent events through the life of an + * animation, such as start, repeat, and end. + * + * @param listener the listener to be added to the current set of listeners for this animation. + */ + public void addListener(AnimatorListener listener) { + if (mListeners == null) { + mListeners = new ArrayList(); + } + mListeners.add(listener); + } + + /** + * Removes a listener from the set listening to this animation. + * + * @param listener the listener to be removed from the current set of listeners for this + * animation. + */ + public void removeListener(AnimatorListener listener) { + if (mListeners == null) { + return; + } + mListeners.remove(listener); + if (mListeners.size() == 0) { + mListeners = null; + } + } + + /** + * Gets the set of {@link android.animation.Animator.AnimatorListener} objects that are currently + * listening for events on this Animator object. + * + * @return ArrayList The set of listeners. + */ + public ArrayList getListeners() { + return mListeners; + } + + /** + * Removes all listeners from this object. This is equivalent to calling + * getListeners() followed by calling clear() on the + * returned list of listeners. + */ + public void removeAllListeners() { + if (mListeners != null) { + mListeners.clear(); + mListeners = null; + } + } + + @Override + public Animator clone() { + try { + final Animator anim = (Animator) super.clone(); + if (mListeners != null) { + ArrayList oldListeners = mListeners; + anim.mListeners = new ArrayList(); + int numListeners = oldListeners.size(); + for (int i = 0; i < numListeners; ++i) { + anim.mListeners.add(oldListeners.get(i)); + } + } + return anim; + } catch (CloneNotSupportedException e) { + throw new AssertionError(); + } + } + + /** + * This method tells the object to use appropriate information to extract + * starting values for the animation. For example, a AnimatorSet object will pass + * this call to its child objects to tell them to set up the values. A + * ObjectAnimator object will use the information it has about its target object + * and PropertyValuesHolder objects to get the start values for its properties. + * An ValueAnimator object will ignore the request since it does not have enough + * information (such as a target object) to gather these values. + */ + public void setupStartValues() { + } + + /** + * This method tells the object to use appropriate information to extract + * ending values for the animation. For example, a AnimatorSet object will pass + * this call to its child objects to tell them to set up the values. A + * ObjectAnimator object will use the information it has about its target object + * and PropertyValuesHolder objects to get the start values for its properties. + * An ValueAnimator object will ignore the request since it does not have enough + * information (such as a target object) to gather these values. + */ + public void setupEndValues() { + } + + /** + * Sets the target object whose property will be animated by this animation. Not all subclasses + * operate on target objects (for example, {@link ValueAnimator}, but this method + * is on the superclass for the convenience of dealing generically with those subclasses + * that do handle targets. + * + * @param target The object being animated + */ + public void setTarget(Object target) { + } + + /** + *

An animation listener receives notifications from an animation. + * Notifications indicate animation related events, such as the end or the + * repetition of the animation.

+ */ + public static interface AnimatorListener { + /** + *

Notifies the start of the animation.

+ * + * @param animation The started animation. + */ + void onAnimationStart(Animator animation); + + /** + *

Notifies the end of the animation. This callback is not invoked + * for animations with repeat count set to INFINITE.

+ * + * @param animation The animation which reached its end. + */ + void onAnimationEnd(Animator animation); + + /** + *

Notifies the cancellation of the animation. This callback is not invoked + * for animations with repeat count set to INFINITE.

+ * + * @param animation The animation which was canceled. + */ + void onAnimationCancel(Animator animation); + + /** + *

Notifies the repetition of the animation.

+ * + * @param animation The animation which was repeated. + */ + void onAnimationRepeat(Animator animation); + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorListenerAdapter.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorListenerAdapter.java new file mode 100644 index 000000000..02ddff48d --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorListenerAdapter.java @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; + +/** + * This adapter class provides empty implementations of the methods from {@link android.animation.Animator.AnimatorListener}. + * Any custom listener that cares only about a subset of the methods of this listener can + * simply subclass this adapter class instead of implementing the interface directly. + */ +public abstract class AnimatorListenerAdapter implements Animator.AnimatorListener { + + /** + * {@inheritDoc} + */ + @Override + public void onAnimationCancel(Animator animation) { + } + + /** + * {@inheritDoc} + */ + @Override + public void onAnimationEnd(Animator animation) { + } + + /** + * {@inheritDoc} + */ + @Override + public void onAnimationRepeat(Animator animation) { + } + + /** + * {@inheritDoc} + */ + @Override + public void onAnimationStart(Animator animation) { + } + +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorSet.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorSet.java new file mode 100644 index 000000000..3231080c4 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorSet.java @@ -0,0 +1,1111 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; + +import android.view.animation.Interpolator; + +/** + * This class plays a set of {@link Animator} objects in the specified order. Animations + * can be set up to play together, in sequence, or after a specified delay. + * + *

There are two different approaches to adding animations to a AnimatorSet: + * either the {@link AnimatorSet#playTogether(Animator[]) playTogether()} or + * {@link AnimatorSet#playSequentially(Animator[]) playSequentially()} methods can be called to add + * a set of animations all at once, or the {@link AnimatorSet#play(Animator)} can be + * used in conjunction with methods in the {@link AnimatorSet.Builder Builder} + * class to add animations + * one by one.

+ * + *

It is possible to set up a AnimatorSet with circular dependencies between + * its animations. For example, an animation a1 could be set up to start before animation a2, a2 + * before a3, and a3 before a1. The results of this configuration are undefined, but will typically + * result in none of the affected animations being played. Because of this (and because + * circular dependencies do not make logical sense anyway), circular dependencies + * should be avoided, and the dependency flow of animations should only be in one direction. + */ +@SuppressWarnings("unchecked") +public final class AnimatorSet extends Animator { + + /** + * Internal variables + * NOTE: This object implements the clone() method, making a deep copy of any referenced + * objects. As other non-trivial fields are added to this class, make sure to add logic + * to clone() to make deep copies of them. + */ + + /** + * Tracks animations currently being played, so that we know what to + * cancel or end when cancel() or end() is called on this AnimatorSet + */ + private ArrayList mPlayingSet = new ArrayList(); + + /** + * Contains all nodes, mapped to their respective Animators. When new + * dependency information is added for an Animator, we want to add it + * to a single node representing that Animator, not create a new Node + * if one already exists. + */ + private HashMap mNodeMap = new HashMap(); + + /** + * Set of all nodes created for this AnimatorSet. This list is used upon + * starting the set, and the nodes are placed in sorted order into the + * sortedNodes collection. + */ + private ArrayList mNodes = new ArrayList(); + + /** + * The sorted list of nodes. This is the order in which the animations will + * be played. The details about when exactly they will be played depend + * on the dependency relationships of the nodes. + */ + private ArrayList mSortedNodes = new ArrayList(); + + /** + * Flag indicating whether the nodes should be sorted prior to playing. This + * flag allows us to cache the previous sorted nodes so that if the sequence + * is replayed with no changes, it does not have to re-sort the nodes again. + */ + private boolean mNeedsSort = true; + + private AnimatorSetListener mSetListener = null; + + /** + * Flag indicating that the AnimatorSet has been manually + * terminated (by calling cancel() or end()). + * This flag is used to avoid starting other animations when currently-playing + * child animations of this AnimatorSet end. It also determines whether cancel/end + * notifications are sent out via the normal AnimatorSetListener mechanism. + */ + boolean mTerminated = false; + + /** + * Indicates whether an AnimatorSet has been start()'d, whether or + * not there is a nonzero startDelay. + */ + private boolean mStarted = false; + + // The amount of time in ms to delay starting the animation after start() is called + private long mStartDelay = 0; + + // Animator used for a nonzero startDelay + private ValueAnimator mDelayAnim = null; + + + // How long the child animations should last in ms. The default value is negative, which + // simply means that there is no duration set on the AnimatorSet. When a real duration is + // set, it is passed along to the child animations. + private long mDuration = -1; + + + /** + * Sets up this AnimatorSet to play all of the supplied animations at the same time. + * + * @param items The animations that will be started simultaneously. + */ + public void playTogether(Animator... items) { + if (items != null) { + mNeedsSort = true; + Builder builder = play(items[0]); + for (int i = 1; i < items.length; ++i) { + builder.with(items[i]); + } + } + } + + /** + * Sets up this AnimatorSet to play all of the supplied animations at the same time. + * + * @param items The animations that will be started simultaneously. + */ + public void playTogether(Collection items) { + if (items != null && items.size() > 0) { + mNeedsSort = true; + Builder builder = null; + for (Animator anim : items) { + if (builder == null) { + builder = play(anim); + } else { + builder.with(anim); + } + } + } + } + + /** + * Sets up this AnimatorSet to play each of the supplied animations when the + * previous animation ends. + * + * @param items The animations that will be started one after another. + */ + public void playSequentially(Animator... items) { + if (items != null) { + mNeedsSort = true; + if (items.length == 1) { + play(items[0]); + } else { + for (int i = 0; i < items.length - 1; ++i) { + play(items[i]).before(items[i+1]); + } + } + } + } + + /** + * Sets up this AnimatorSet to play each of the supplied animations when the + * previous animation ends. + * + * @param items The animations that will be started one after another. + */ + public void playSequentially(List items) { + if (items != null && items.size() > 0) { + mNeedsSort = true; + if (items.size() == 1) { + play(items.get(0)); + } else { + for (int i = 0; i < items.size() - 1; ++i) { + play(items.get(i)).before(items.get(i+1)); + } + } + } + } + + /** + * Returns the current list of child Animator objects controlled by this + * AnimatorSet. This is a copy of the internal list; modifications to the returned list + * will not affect the AnimatorSet, although changes to the underlying Animator objects + * will affect those objects being managed by the AnimatorSet. + * + * @return ArrayList The list of child animations of this AnimatorSet. + */ + public ArrayList getChildAnimations() { + ArrayList childList = new ArrayList(); + for (Node node : mNodes) { + childList.add(node.animation); + } + return childList; + } + + /** + * Sets the target object for all current {@link #getChildAnimations() child animations} + * of this AnimatorSet that take targets ({@link ObjectAnimator} and + * AnimatorSet). + * + * @param target The object being animated + */ + @Override + public void setTarget(Object target) { + for (Node node : mNodes) { + Animator animation = node.animation; + if (animation instanceof AnimatorSet) { + ((AnimatorSet)animation).setTarget(target); + } else if (animation instanceof ObjectAnimator) { + ((ObjectAnimator)animation).setTarget(target); + } + } + } + + /** + * Sets the TimeInterpolator for all current {@link #getChildAnimations() child animations} + * of this AnimatorSet. + * + * @param interpolator the interpolator to be used by each child animation of this AnimatorSet + */ + @Override + public void setInterpolator(/*Time*/Interpolator interpolator) { + for (Node node : mNodes) { + node.animation.setInterpolator(interpolator); + } + } + + /** + * This method creates a Builder object, which is used to + * set up playing constraints. This initial play() method + * tells the Builder the animation that is the dependency for + * the succeeding commands to the Builder. For example, + * calling play(a1).with(a2) sets up the AnimatorSet to play + * a1 and a2 at the same time, + * play(a1).before(a2) sets up the AnimatorSet to play + * a1 first, followed by a2, and + * play(a1).after(a2) sets up the AnimatorSet to play + * a2 first, followed by a1. + * + *

Note that play() is the only way to tell the + * Builder the animation upon which the dependency is created, + * so successive calls to the various functions in Builder + * will all refer to the initial parameter supplied in play() + * as the dependency of the other animations. For example, calling + * play(a1).before(a2).before(a3) will play both a2 + * and a3 when a1 ends; it does not set up a dependency between + * a2 and a3.

+ * + * @param anim The animation that is the dependency used in later calls to the + * methods in the returned Builder object. A null parameter will result + * in a null Builder return value. + * @return Builder The object that constructs the AnimatorSet based on the dependencies + * outlined in the calls to play and the other methods in the + * BuilderNote that canceling a AnimatorSet also cancels all of the animations that it + * is responsible for.

+ */ + @Override + public void cancel() { + mTerminated = true; + if (isStarted()) { + ArrayList tmpListeners = null; + if (mListeners != null) { + tmpListeners = (ArrayList) mListeners.clone(); + for (AnimatorListener listener : tmpListeners) { + listener.onAnimationCancel(this); + } + } + if (mDelayAnim != null && mDelayAnim.isRunning()) { + // If we're currently in the startDelay period, just cancel that animator and + // send out the end event to all listeners + mDelayAnim.cancel(); + } else if (mSortedNodes.size() > 0) { + for (Node node : mSortedNodes) { + node.animation.cancel(); + } + } + if (tmpListeners != null) { + for (AnimatorListener listener : tmpListeners) { + listener.onAnimationEnd(this); + } + } + mStarted = false; + } + } + + /** + * {@inheritDoc} + * + *

Note that ending a AnimatorSet also ends all of the animations that it is + * responsible for.

+ */ + @Override + public void end() { + mTerminated = true; + if (isStarted()) { + if (mSortedNodes.size() != mNodes.size()) { + // hasn't been started yet - sort the nodes now, then end them + sortNodes(); + for (Node node : mSortedNodes) { + if (mSetListener == null) { + mSetListener = new AnimatorSetListener(this); + } + node.animation.addListener(mSetListener); + } + } + if (mDelayAnim != null) { + mDelayAnim.cancel(); + } + if (mSortedNodes.size() > 0) { + for (Node node : mSortedNodes) { + node.animation.end(); + } + } + if (mListeners != null) { + ArrayList tmpListeners = + (ArrayList) mListeners.clone(); + for (AnimatorListener listener : tmpListeners) { + listener.onAnimationEnd(this); + } + } + mStarted = false; + } + } + + /** + * Returns true if any of the child animations of this AnimatorSet have been started and have + * not yet ended. + * @return Whether this AnimatorSet has been started and has not yet ended. + */ + @Override + public boolean isRunning() { + for (Node node : mNodes) { + if (node.animation.isRunning()) { + return true; + } + } + return false; + } + + @Override + public boolean isStarted() { + return mStarted; + } + + /** + * The amount of time, in milliseconds, to delay starting the animation after + * {@link #start()} is called. + * + * @return the number of milliseconds to delay running the animation + */ + @Override + public long getStartDelay() { + return mStartDelay; + } + + /** + * The amount of time, in milliseconds, to delay starting the animation after + * {@link #start()} is called. + + * @param startDelay The amount of the delay, in milliseconds + */ + @Override + public void setStartDelay(long startDelay) { + mStartDelay = startDelay; + } + + /** + * Gets the length of each of the child animations of this AnimatorSet. This value may + * be less than 0, which indicates that no duration has been set on this AnimatorSet + * and each of the child animations will use their own duration. + * + * @return The length of the animation, in milliseconds, of each of the child + * animations of this AnimatorSet. + */ + @Override + public long getDuration() { + return mDuration; + } + + /** + * Sets the length of each of the current child animations of this AnimatorSet. By default, + * each child animation will use its own duration. If the duration is set on the AnimatorSet, + * then each child animation inherits this duration. + * + * @param duration The length of the animation, in milliseconds, of each of the child + * animations of this AnimatorSet. + */ + @Override + public AnimatorSet setDuration(long duration) { + if (duration < 0) { + throw new IllegalArgumentException("duration must be a value of zero or greater"); + } + for (Node node : mNodes) { + // TODO: don't set the duration of the timing-only nodes created by AnimatorSet to + // insert "play-after" delays + node.animation.setDuration(duration); + } + mDuration = duration; + return this; + } + + @Override + public void setupStartValues() { + for (Node node : mNodes) { + node.animation.setupStartValues(); + } + } + + @Override + public void setupEndValues() { + for (Node node : mNodes) { + node.animation.setupEndValues(); + } + } + + /** + * {@inheritDoc} + * + *

Starting this AnimatorSet will, in turn, start the animations for which + * it is responsible. The details of when exactly those animations are started depends on + * the dependency relationships that have been set up between the animations. + */ + @Override + public void start() { + mTerminated = false; + mStarted = true; + + // First, sort the nodes (if necessary). This will ensure that sortedNodes + // contains the animation nodes in the correct order. + sortNodes(); + + int numSortedNodes = mSortedNodes.size(); + for (int i = 0; i < numSortedNodes; ++i) { + Node node = mSortedNodes.get(i); + // First, clear out the old listeners + ArrayList oldListeners = node.animation.getListeners(); + if (oldListeners != null && oldListeners.size() > 0) { + final ArrayList clonedListeners = new + ArrayList(oldListeners); + + for (AnimatorListener listener : clonedListeners) { + if (listener instanceof DependencyListener || + listener instanceof AnimatorSetListener) { + node.animation.removeListener(listener); + } + } + } + } + + // nodesToStart holds the list of nodes to be started immediately. We don't want to + // start the animations in the loop directly because we first need to set up + // dependencies on all of the nodes. For example, we don't want to start an animation + // when some other animation also wants to start when the first animation begins. + final ArrayList nodesToStart = new ArrayList(); + for (int i = 0; i < numSortedNodes; ++i) { + Node node = mSortedNodes.get(i); + if (mSetListener == null) { + mSetListener = new AnimatorSetListener(this); + } + if (node.dependencies == null || node.dependencies.size() == 0) { + nodesToStart.add(node); + } else { + int numDependencies = node.dependencies.size(); + for (int j = 0; j < numDependencies; ++j) { + Dependency dependency = node.dependencies.get(j); + dependency.node.animation.addListener( + new DependencyListener(this, node, dependency.rule)); + } + node.tmpDependencies = (ArrayList) node.dependencies.clone(); + } + node.animation.addListener(mSetListener); + } + // Now that all dependencies are set up, start the animations that should be started. + if (mStartDelay <= 0) { + for (Node node : nodesToStart) { + node.animation.start(); + mPlayingSet.add(node.animation); + } + } else { + mDelayAnim = ValueAnimator.ofFloat(0f, 1f); + mDelayAnim.setDuration(mStartDelay); + mDelayAnim.addListener(new AnimatorListenerAdapter() { + boolean canceled = false; + public void onAnimationCancel(Animator anim) { + canceled = true; + } + public void onAnimationEnd(Animator anim) { + if (!canceled) { + int numNodes = nodesToStart.size(); + for (int i = 0; i < numNodes; ++i) { + Node node = nodesToStart.get(i); + node.animation.start(); + mPlayingSet.add(node.animation); + } + } + } + }); + mDelayAnim.start(); + } + if (mListeners != null) { + ArrayList tmpListeners = + (ArrayList) mListeners.clone(); + int numListeners = tmpListeners.size(); + for (int i = 0; i < numListeners; ++i) { + tmpListeners.get(i).onAnimationStart(this); + } + } + if (mNodes.size() == 0 && mStartDelay == 0) { + // Handle unusual case where empty AnimatorSet is started - should send out + // end event immediately since the event will not be sent out at all otherwise + mStarted = false; + if (mListeners != null) { + ArrayList tmpListeners = + (ArrayList) mListeners.clone(); + int numListeners = tmpListeners.size(); + for (int i = 0; i < numListeners; ++i) { + tmpListeners.get(i).onAnimationEnd(this); + } + } + } + } + + @Override + public AnimatorSet clone() { + final AnimatorSet anim = (AnimatorSet) super.clone(); + /* + * The basic clone() operation copies all items. This doesn't work very well for + * AnimatorSet, because it will copy references that need to be recreated and state + * that may not apply. What we need to do now is put the clone in an uninitialized + * state, with fresh, empty data structures. Then we will build up the nodes list + * manually, as we clone each Node (and its animation). The clone will then be sorted, + * and will populate any appropriate lists, when it is started. + */ + anim.mNeedsSort = true; + anim.mTerminated = false; + anim.mStarted = false; + anim.mPlayingSet = new ArrayList(); + anim.mNodeMap = new HashMap(); + anim.mNodes = new ArrayList(); + anim.mSortedNodes = new ArrayList(); + + // Walk through the old nodes list, cloning each node and adding it to the new nodemap. + // One problem is that the old node dependencies point to nodes in the old AnimatorSet. + // We need to track the old/new nodes in order to reconstruct the dependencies in the clone. + HashMap nodeCloneMap = new HashMap(); // + for (Node node : mNodes) { + Node nodeClone = node.clone(); + nodeCloneMap.put(node, nodeClone); + anim.mNodes.add(nodeClone); + anim.mNodeMap.put(nodeClone.animation, nodeClone); + // Clear out the dependencies in the clone; we'll set these up manually later + nodeClone.dependencies = null; + nodeClone.tmpDependencies = null; + nodeClone.nodeDependents = null; + nodeClone.nodeDependencies = null; + // clear out any listeners that were set up by the AnimatorSet; these will + // be set up when the clone's nodes are sorted + ArrayList cloneListeners = nodeClone.animation.getListeners(); + if (cloneListeners != null) { + ArrayList listenersToRemove = null; + for (AnimatorListener listener : cloneListeners) { + if (listener instanceof AnimatorSetListener) { + if (listenersToRemove == null) { + listenersToRemove = new ArrayList(); + } + listenersToRemove.add(listener); + } + } + if (listenersToRemove != null) { + for (AnimatorListener listener : listenersToRemove) { + cloneListeners.remove(listener); + } + } + } + } + // Now that we've cloned all of the nodes, we're ready to walk through their + // dependencies, mapping the old dependencies to the new nodes + for (Node node : mNodes) { + Node nodeClone = nodeCloneMap.get(node); + if (node.dependencies != null) { + for (Dependency dependency : node.dependencies) { + Node clonedDependencyNode = nodeCloneMap.get(dependency.node); + Dependency cloneDependency = new Dependency(clonedDependencyNode, + dependency.rule); + nodeClone.addDependency(cloneDependency); + } + } + } + + return anim; + } + + /** + * This class is the mechanism by which animations are started based on events in other + * animations. If an animation has multiple dependencies on other animations, then + * all dependencies must be satisfied before the animation is started. + */ + private static class DependencyListener implements AnimatorListener { + + private AnimatorSet mAnimatorSet; + + // The node upon which the dependency is based. + private Node mNode; + + // The Dependency rule (WITH or AFTER) that the listener should wait for on + // the node + private int mRule; + + public DependencyListener(AnimatorSet animatorSet, Node node, int rule) { + this.mAnimatorSet = animatorSet; + this.mNode = node; + this.mRule = rule; + } + + /** + * Ignore cancel events for now. We may want to handle this eventually, + * to prevent follow-on animations from running when some dependency + * animation is canceled. + */ + public void onAnimationCancel(Animator animation) { + } + + /** + * An end event is received - see if this is an event we are listening for + */ + public void onAnimationEnd(Animator animation) { + if (mRule == Dependency.AFTER) { + startIfReady(animation); + } + } + + /** + * Ignore repeat events for now + */ + public void onAnimationRepeat(Animator animation) { + } + + /** + * A start event is received - see if this is an event we are listening for + */ + public void onAnimationStart(Animator animation) { + if (mRule == Dependency.WITH) { + startIfReady(animation); + } + } + + /** + * Check whether the event received is one that the node was waiting for. + * If so, mark it as complete and see whether it's time to start + * the animation. + * @param dependencyAnimation the animation that sent the event. + */ + private void startIfReady(Animator dependencyAnimation) { + if (mAnimatorSet.mTerminated) { + // if the parent AnimatorSet was canceled, then don't start any dependent anims + return; + } + Dependency dependencyToRemove = null; + int numDependencies = mNode.tmpDependencies.size(); + for (int i = 0; i < numDependencies; ++i) { + Dependency dependency = mNode.tmpDependencies.get(i); + if (dependency.rule == mRule && + dependency.node.animation == dependencyAnimation) { + // rule fired - remove the dependency and listener and check to + // see whether it's time to start the animation + dependencyToRemove = dependency; + dependencyAnimation.removeListener(this); + break; + } + } + mNode.tmpDependencies.remove(dependencyToRemove); + if (mNode.tmpDependencies.size() == 0) { + // all dependencies satisfied: start the animation + mNode.animation.start(); + mAnimatorSet.mPlayingSet.add(mNode.animation); + } + } + + } + + private class AnimatorSetListener implements AnimatorListener { + + private AnimatorSet mAnimatorSet; + + AnimatorSetListener(AnimatorSet animatorSet) { + mAnimatorSet = animatorSet; + } + + public void onAnimationCancel(Animator animation) { + if (!mTerminated) { + // Listeners are already notified of the AnimatorSet canceling in cancel(). + // The logic below only kicks in when animations end normally + if (mPlayingSet.size() == 0) { + if (mListeners != null) { + int numListeners = mListeners.size(); + for (int i = 0; i < numListeners; ++i) { + mListeners.get(i).onAnimationCancel(mAnimatorSet); + } + } + } + } + } + + public void onAnimationEnd(Animator animation) { + animation.removeListener(this); + mPlayingSet.remove(animation); + Node animNode = mAnimatorSet.mNodeMap.get(animation); + animNode.done = true; + if (!mTerminated) { + // Listeners are already notified of the AnimatorSet ending in cancel() or + // end(); the logic below only kicks in when animations end normally + ArrayList sortedNodes = mAnimatorSet.mSortedNodes; + boolean allDone = true; + int numSortedNodes = sortedNodes.size(); + for (int i = 0; i < numSortedNodes; ++i) { + if (!sortedNodes.get(i).done) { + allDone = false; + break; + } + } + if (allDone) { + // If this was the last child animation to end, then notify listeners that this + // AnimatorSet has ended + if (mListeners != null) { + ArrayList tmpListeners = + (ArrayList) mListeners.clone(); + int numListeners = tmpListeners.size(); + for (int i = 0; i < numListeners; ++i) { + tmpListeners.get(i).onAnimationEnd(mAnimatorSet); + } + } + mAnimatorSet.mStarted = false; + } + } + } + + // Nothing to do + public void onAnimationRepeat(Animator animation) { + } + + // Nothing to do + public void onAnimationStart(Animator animation) { + } + + } + + /** + * This method sorts the current set of nodes, if needed. The sort is a simple + * DependencyGraph sort, which goes like this: + * - All nodes without dependencies become 'roots' + * - while roots list is not null + * - for each root r + * - add r to sorted list + * - remove r as a dependency from any other node + * - any nodes with no dependencies are added to the roots list + */ + private void sortNodes() { + if (mNeedsSort) { + mSortedNodes.clear(); + ArrayList roots = new ArrayList(); + int numNodes = mNodes.size(); + for (int i = 0; i < numNodes; ++i) { + Node node = mNodes.get(i); + if (node.dependencies == null || node.dependencies.size() == 0) { + roots.add(node); + } + } + ArrayList tmpRoots = new ArrayList(); + while (roots.size() > 0) { + int numRoots = roots.size(); + for (int i = 0; i < numRoots; ++i) { + Node root = roots.get(i); + mSortedNodes.add(root); + if (root.nodeDependents != null) { + int numDependents = root.nodeDependents.size(); + for (int j = 0; j < numDependents; ++j) { + Node node = root.nodeDependents.get(j); + node.nodeDependencies.remove(root); + if (node.nodeDependencies.size() == 0) { + tmpRoots.add(node); + } + } + } + } + roots.clear(); + roots.addAll(tmpRoots); + tmpRoots.clear(); + } + mNeedsSort = false; + if (mSortedNodes.size() != mNodes.size()) { + throw new IllegalStateException("Circular dependencies cannot exist" + + " in AnimatorSet"); + } + } else { + // Doesn't need sorting, but still need to add in the nodeDependencies list + // because these get removed as the event listeners fire and the dependencies + // are satisfied + int numNodes = mNodes.size(); + for (int i = 0; i < numNodes; ++i) { + Node node = mNodes.get(i); + if (node.dependencies != null && node.dependencies.size() > 0) { + int numDependencies = node.dependencies.size(); + for (int j = 0; j < numDependencies; ++j) { + Dependency dependency = node.dependencies.get(j); + if (node.nodeDependencies == null) { + node.nodeDependencies = new ArrayList(); + } + if (!node.nodeDependencies.contains(dependency.node)) { + node.nodeDependencies.add(dependency.node); + } + } + } + // nodes are 'done' by default; they become un-done when started, and done + // again when ended + node.done = false; + } + } + } + + /** + * Dependency holds information about the node that some other node is + * dependent upon and the nature of that dependency. + * + */ + private static class Dependency { + static final int WITH = 0; // dependent node must start with this dependency node + static final int AFTER = 1; // dependent node must start when this dependency node finishes + + // The node that the other node with this Dependency is dependent upon + public Node node; + + // The nature of the dependency (WITH or AFTER) + public int rule; + + public Dependency(Node node, int rule) { + this.node = node; + this.rule = rule; + } + } + + /** + * A Node is an embodiment of both the Animator that it wraps as well as + * any dependencies that are associated with that Animation. This includes + * both dependencies upon other nodes (in the dependencies list) as + * well as dependencies of other nodes upon this (in the nodeDependents list). + */ + private static class Node implements Cloneable { + public Animator animation; + + /** + * These are the dependencies that this node's animation has on other + * nodes. For example, if this node's animation should begin with some + * other animation ends, then there will be an item in this node's + * dependencies list for that other animation's node. + */ + public ArrayList dependencies = null; + + /** + * tmpDependencies is a runtime detail. We use the dependencies list for sorting. + * But we also use the list to keep track of when multiple dependencies are satisfied, + * but removing each dependency as it is satisfied. We do not want to remove + * the dependency itself from the list, because we need to retain that information + * if the AnimatorSet is launched in the future. So we create a copy of the dependency + * list when the AnimatorSet starts and use this tmpDependencies list to track the + * list of satisfied dependencies. + */ + public ArrayList tmpDependencies = null; + + /** + * nodeDependencies is just a list of the nodes that this Node is dependent upon. + * This information is used in sortNodes(), to determine when a node is a root. + */ + public ArrayList nodeDependencies = null; + + /** + * nodeDepdendents is the list of nodes that have this node as a dependency. This + * is a utility field used in sortNodes to facilitate removing this node as a + * dependency when it is a root node. + */ + public ArrayList nodeDependents = null; + + /** + * Flag indicating whether the animation in this node is finished. This flag + * is used by AnimatorSet to check, as each animation ends, whether all child animations + * are done and it's time to send out an end event for the entire AnimatorSet. + */ + public boolean done = false; + + /** + * Constructs the Node with the animation that it encapsulates. A Node has no + * dependencies by default; dependencies are added via the addDependency() + * method. + * + * @param animation The animation that the Node encapsulates. + */ + public Node(Animator animation) { + this.animation = animation; + } + + /** + * Add a dependency to this Node. The dependency includes information about the + * node that this node is dependency upon and the nature of the dependency. + * @param dependency + */ + public void addDependency(Dependency dependency) { + if (dependencies == null) { + dependencies = new ArrayList(); + nodeDependencies = new ArrayList(); + } + dependencies.add(dependency); + if (!nodeDependencies.contains(dependency.node)) { + nodeDependencies.add(dependency.node); + } + Node dependencyNode = dependency.node; + if (dependencyNode.nodeDependents == null) { + dependencyNode.nodeDependents = new ArrayList(); + } + dependencyNode.nodeDependents.add(this); + } + + @Override + public Node clone() { + try { + Node node = (Node) super.clone(); + node.animation = animation.clone(); + return node; + } catch (CloneNotSupportedException e) { + throw new AssertionError(); + } + } + } + + /** + * The Builder object is a utility class to facilitate adding animations to a + * AnimatorSet along with the relationships between the various animations. The + * intention of the Builder methods, along with the {@link + * AnimatorSet#play(Animator) play()} method of AnimatorSet is to make it possible + * to express the dependency relationships of animations in a natural way. Developers can also + * use the {@link AnimatorSet#playTogether(Animator[]) playTogether()} and {@link + * AnimatorSet#playSequentially(Animator[]) playSequentially()} methods if these suit the need, + * but it might be easier in some situations to express the AnimatorSet of animations in pairs. + *

+ *

The Builder object cannot be constructed directly, but is rather constructed + * internally via a call to {@link AnimatorSet#play(Animator)}.

+ *

+ *

For example, this sets up a AnimatorSet to play anim1 and anim2 at the same time, anim3 to + * play when anim2 finishes, and anim4 to play when anim3 finishes:

+ *
+     *     AnimatorSet s = new AnimatorSet();
+     *     s.play(anim1).with(anim2);
+     *     s.play(anim2).before(anim3);
+     *     s.play(anim4).after(anim3);
+     * 
+ *

+ *

Note in the example that both {@link Builder#before(Animator)} and {@link + * Builder#after(Animator)} are used. These are just different ways of expressing the same + * relationship and are provided to make it easier to say things in a way that is more natural, + * depending on the situation.

+ *

+ *

It is possible to make several calls into the same Builder object to express + * multiple relationships. However, note that it is only the animation passed into the initial + * {@link AnimatorSet#play(Animator)} method that is the dependency in any of the successive + * calls to the Builder object. For example, the following code starts both anim2 + * and anim3 when anim1 ends; there is no direct dependency relationship between anim2 and + * anim3: + *

+     *   AnimatorSet s = new AnimatorSet();
+     *   s.play(anim1).before(anim2).before(anim3);
+     * 
+ * If the desired result is to play anim1 then anim2 then anim3, this code expresses the + * relationship correctly:

+ *
+     *   AnimatorSet s = new AnimatorSet();
+     *   s.play(anim1).before(anim2);
+     *   s.play(anim2).before(anim3);
+     * 
+ *

+ *

Note that it is possible to express relationships that cannot be resolved and will not + * result in sensible results. For example, play(anim1).after(anim1) makes no + * sense. In general, circular dependencies like this one (or more indirect ones where a depends + * on b, which depends on c, which depends on a) should be avoided. Only create AnimatorSets + * that can boil down to a simple, one-way relationship of animations starting with, before, and + * after other, different, animations.

+ */ + public class Builder { + + /** + * This tracks the current node being processed. It is supplied to the play() method + * of AnimatorSet and passed into the constructor of Builder. + */ + private Node mCurrentNode; + + /** + * package-private constructor. Builders are only constructed by AnimatorSet, when the + * play() method is called. + * + * @param anim The animation that is the dependency for the other animations passed into + * the other methods of this Builder object. + */ + Builder(Animator anim) { + mCurrentNode = mNodeMap.get(anim); + if (mCurrentNode == null) { + mCurrentNode = new Node(anim); + mNodeMap.put(anim, mCurrentNode); + mNodes.add(mCurrentNode); + } + } + + /** + * Sets up the given animation to play at the same time as the animation supplied in the + * {@link AnimatorSet#play(Animator)} call that created this Builder object. + * + * @param anim The animation that will play when the animation supplied to the + * {@link AnimatorSet#play(Animator)} method starts. + */ + public Builder with(Animator anim) { + Node node = mNodeMap.get(anim); + if (node == null) { + node = new Node(anim); + mNodeMap.put(anim, node); + mNodes.add(node); + } + Dependency dependency = new Dependency(mCurrentNode, Dependency.WITH); + node.addDependency(dependency); + return this; + } + + /** + * Sets up the given animation to play when the animation supplied in the + * {@link AnimatorSet#play(Animator)} call that created this Builder object + * ends. + * + * @param anim The animation that will play when the animation supplied to the + * {@link AnimatorSet#play(Animator)} method ends. + */ + public Builder before(Animator anim) { + Node node = mNodeMap.get(anim); + if (node == null) { + node = new Node(anim); + mNodeMap.put(anim, node); + mNodes.add(node); + } + Dependency dependency = new Dependency(mCurrentNode, Dependency.AFTER); + node.addDependency(dependency); + return this; + } + + /** + * Sets up the given animation to play when the animation supplied in the + * {@link AnimatorSet#play(Animator)} call that created this Builder object + * to start when the animation supplied in this method call ends. + * + * @param anim The animation whose end will cause the animation supplied to the + * {@link AnimatorSet#play(Animator)} method to play. + */ + public Builder after(Animator anim) { + Node node = mNodeMap.get(anim); + if (node == null) { + node = new Node(anim); + mNodeMap.put(anim, node); + mNodes.add(node); + } + Dependency dependency = new Dependency(node, Dependency.AFTER); + mCurrentNode.addDependency(dependency); + return this; + } + + /** + * Sets up the animation supplied in the + * {@link AnimatorSet#play(Animator)} call that created this Builder object + * to play when the given amount of time elapses. + * + * @param delay The number of milliseconds that should elapse before the + * animation starts. + */ + public Builder after(long delay) { + // setup dummy ValueAnimator just to run the clock + ValueAnimator anim = ValueAnimator.ofFloat(0f, 1f); + anim.setDuration(delay); + after(anim); + return this; + } + + } + +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatEvaluator.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatEvaluator.java new file mode 100644 index 000000000..e41019364 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatEvaluator.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; + +/** + * This evaluator can be used to perform type interpolation between float values. + */ +public class FloatEvaluator implements TypeEvaluator { + + /** + * This function returns the result of linearly interpolating the start and end values, with + * fraction representing the proportion between the start and end values. The + * calculation is a simple parametric calculation: result = x0 + t * (v1 - v0), + * where x0 is startValue, x1 is endValue, + * and t is fraction. + * + * @param fraction The fraction from the starting to the ending values + * @param startValue The start value; should be of type float or + * Float + * @param endValue The end value; should be of type float or Float + * @return A linear interpolation between the start and end values, given the + * fraction parameter. + */ + public Float evaluate(float fraction, Number startValue, Number endValue) { + float startFloat = startValue.floatValue(); + return startFloat + fraction * (endValue.floatValue() - startFloat); + } +} \ No newline at end of file diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatKeyframeSet.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatKeyframeSet.java new file mode 100644 index 000000000..6d9dafa7a --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatKeyframeSet.java @@ -0,0 +1,136 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; + +import java.util.ArrayList; +import android.view.animation.Interpolator; + +import com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.FloatKeyframe; + +/** + * This class holds a collection of FloatKeyframe objects and is called by ValueAnimator to calculate + * values between those keyframes for a given animation. The class internal to the animation + * package because it is an implementation detail of how Keyframes are stored and used. + * + *

This type-specific subclass of KeyframeSet, along with the other type-specific subclass for + * int, exists to speed up the getValue() method when there is no custom + * TypeEvaluator set for the animation, so that values can be calculated without autoboxing to the + * Object equivalents of these primitive types.

+ */ +@SuppressWarnings("unchecked") +class FloatKeyframeSet extends KeyframeSet { + private float firstValue; + private float lastValue; + private float deltaValue; + private boolean firstTime = true; + + public FloatKeyframeSet(FloatKeyframe... keyframes) { + super(keyframes); + } + + @Override + public Object getValue(float fraction) { + return getFloatValue(fraction); + } + + @Override + public FloatKeyframeSet clone() { + ArrayList keyframes = mKeyframes; + int numKeyframes = mKeyframes.size(); + FloatKeyframe[] newKeyframes = new FloatKeyframe[numKeyframes]; + for (int i = 0; i < numKeyframes; ++i) { + newKeyframes[i] = (FloatKeyframe) keyframes.get(i).clone(); + } + FloatKeyframeSet newSet = new FloatKeyframeSet(newKeyframes); + return newSet; + } + + public float getFloatValue(float fraction) { + if (mNumKeyframes == 2) { + if (firstTime) { + firstTime = false; + firstValue = ((FloatKeyframe) mKeyframes.get(0)).getFloatValue(); + lastValue = ((FloatKeyframe) mKeyframes.get(1)).getFloatValue(); + deltaValue = lastValue - firstValue; + } + if (mInterpolator != null) { + fraction = mInterpolator.getInterpolation(fraction); + } + if (mEvaluator == null) { + return firstValue + fraction * deltaValue; + } else { + return ((Number)mEvaluator.evaluate(fraction, firstValue, lastValue)).floatValue(); + } + } + if (fraction <= 0f) { + final FloatKeyframe prevKeyframe = (FloatKeyframe) mKeyframes.get(0); + final FloatKeyframe nextKeyframe = (FloatKeyframe) mKeyframes.get(1); + float prevValue = prevKeyframe.getFloatValue(); + float nextValue = nextKeyframe.getFloatValue(); + float prevFraction = prevKeyframe.getFraction(); + float nextFraction = nextKeyframe.getFraction(); + final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator(); + if (interpolator != null) { + fraction = interpolator.getInterpolation(fraction); + } + float intervalFraction = (fraction - prevFraction) / (nextFraction - prevFraction); + return mEvaluator == null ? + prevValue + intervalFraction * (nextValue - prevValue) : + ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)). + floatValue(); + } else if (fraction >= 1f) { + final FloatKeyframe prevKeyframe = (FloatKeyframe) mKeyframes.get(mNumKeyframes - 2); + final FloatKeyframe nextKeyframe = (FloatKeyframe) mKeyframes.get(mNumKeyframes - 1); + float prevValue = prevKeyframe.getFloatValue(); + float nextValue = nextKeyframe.getFloatValue(); + float prevFraction = prevKeyframe.getFraction(); + float nextFraction = nextKeyframe.getFraction(); + final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator(); + if (interpolator != null) { + fraction = interpolator.getInterpolation(fraction); + } + float intervalFraction = (fraction - prevFraction) / (nextFraction - prevFraction); + return mEvaluator == null ? + prevValue + intervalFraction * (nextValue - prevValue) : + ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)). + floatValue(); + } + FloatKeyframe prevKeyframe = (FloatKeyframe) mKeyframes.get(0); + for (int i = 1; i < mNumKeyframes; ++i) { + FloatKeyframe nextKeyframe = (FloatKeyframe) mKeyframes.get(i); + if (fraction < nextKeyframe.getFraction()) { + final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator(); + if (interpolator != null) { + fraction = interpolator.getInterpolation(fraction); + } + float intervalFraction = (fraction - prevKeyframe.getFraction()) / + (nextKeyframe.getFraction() - prevKeyframe.getFraction()); + float prevValue = prevKeyframe.getFloatValue(); + float nextValue = nextKeyframe.getFloatValue(); + return mEvaluator == null ? + prevValue + intervalFraction * (nextValue - prevValue) : + ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)). + floatValue(); + } + prevKeyframe = nextKeyframe; + } + // shouldn't get here + return ((Number)mKeyframes.get(mNumKeyframes - 1).getValue()).floatValue(); + } + +} + diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntEvaluator.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntEvaluator.java new file mode 100644 index 000000000..ed5e79ec6 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntEvaluator.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; + +/** + * This evaluator can be used to perform type interpolation between int values. + */ +public class IntEvaluator implements TypeEvaluator { + + /** + * This function returns the result of linearly interpolating the start and end values, with + * fraction representing the proportion between the start and end values. The + * calculation is a simple parametric calculation: result = x0 + t * (v1 - v0), + * where x0 is startValue, x1 is endValue, + * and t is fraction. + * + * @param fraction The fraction from the starting to the ending values + * @param startValue The start value; should be of type int or + * Integer + * @param endValue The end value; should be of type int or Integer + * @return A linear interpolation between the start and end values, given the + * fraction parameter. + */ + public Integer evaluate(float fraction, Integer startValue, Integer endValue) { + int startInt = startValue; + return (int)(startInt + fraction * (endValue - startInt)); + } +} \ No newline at end of file diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntKeyframeSet.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntKeyframeSet.java new file mode 100644 index 000000000..e9215e7f8 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntKeyframeSet.java @@ -0,0 +1,135 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; + +import java.util.ArrayList; +import android.view.animation.Interpolator; + +import com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.IntKeyframe; + +/** + * This class holds a collection of IntKeyframe objects and is called by ValueAnimator to calculate + * values between those keyframes for a given animation. The class internal to the animation + * package because it is an implementation detail of how Keyframes are stored and used. + * + *

This type-specific subclass of KeyframeSet, along with the other type-specific subclass for + * float, exists to speed up the getValue() method when there is no custom + * TypeEvaluator set for the animation, so that values can be calculated without autoboxing to the + * Object equivalents of these primitive types.

+ */ +@SuppressWarnings("unchecked") +class IntKeyframeSet extends KeyframeSet { + private int firstValue; + private int lastValue; + private int deltaValue; + private boolean firstTime = true; + + public IntKeyframeSet(IntKeyframe... keyframes) { + super(keyframes); + } + + @Override + public Object getValue(float fraction) { + return getIntValue(fraction); + } + + @Override + public IntKeyframeSet clone() { + ArrayList keyframes = mKeyframes; + int numKeyframes = mKeyframes.size(); + IntKeyframe[] newKeyframes = new IntKeyframe[numKeyframes]; + for (int i = 0; i < numKeyframes; ++i) { + newKeyframes[i] = (IntKeyframe) keyframes.get(i).clone(); + } + IntKeyframeSet newSet = new IntKeyframeSet(newKeyframes); + return newSet; + } + + public int getIntValue(float fraction) { + if (mNumKeyframes == 2) { + if (firstTime) { + firstTime = false; + firstValue = ((IntKeyframe) mKeyframes.get(0)).getIntValue(); + lastValue = ((IntKeyframe) mKeyframes.get(1)).getIntValue(); + deltaValue = lastValue - firstValue; + } + if (mInterpolator != null) { + fraction = mInterpolator.getInterpolation(fraction); + } + if (mEvaluator == null) { + return firstValue + (int)(fraction * deltaValue); + } else { + return ((Number)mEvaluator.evaluate(fraction, firstValue, lastValue)).intValue(); + } + } + if (fraction <= 0f) { + final IntKeyframe prevKeyframe = (IntKeyframe) mKeyframes.get(0); + final IntKeyframe nextKeyframe = (IntKeyframe) mKeyframes.get(1); + int prevValue = prevKeyframe.getIntValue(); + int nextValue = nextKeyframe.getIntValue(); + float prevFraction = prevKeyframe.getFraction(); + float nextFraction = nextKeyframe.getFraction(); + final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator(); + if (interpolator != null) { + fraction = interpolator.getInterpolation(fraction); + } + float intervalFraction = (fraction - prevFraction) / (nextFraction - prevFraction); + return mEvaluator == null ? + prevValue + (int)(intervalFraction * (nextValue - prevValue)) : + ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)). + intValue(); + } else if (fraction >= 1f) { + final IntKeyframe prevKeyframe = (IntKeyframe) mKeyframes.get(mNumKeyframes - 2); + final IntKeyframe nextKeyframe = (IntKeyframe) mKeyframes.get(mNumKeyframes - 1); + int prevValue = prevKeyframe.getIntValue(); + int nextValue = nextKeyframe.getIntValue(); + float prevFraction = prevKeyframe.getFraction(); + float nextFraction = nextKeyframe.getFraction(); + final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator(); + if (interpolator != null) { + fraction = interpolator.getInterpolation(fraction); + } + float intervalFraction = (fraction - prevFraction) / (nextFraction - prevFraction); + return mEvaluator == null ? + prevValue + (int)(intervalFraction * (nextValue - prevValue)) : + ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)).intValue(); + } + IntKeyframe prevKeyframe = (IntKeyframe) mKeyframes.get(0); + for (int i = 1; i < mNumKeyframes; ++i) { + IntKeyframe nextKeyframe = (IntKeyframe) mKeyframes.get(i); + if (fraction < nextKeyframe.getFraction()) { + final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator(); + if (interpolator != null) { + fraction = interpolator.getInterpolation(fraction); + } + float intervalFraction = (fraction - prevKeyframe.getFraction()) / + (nextKeyframe.getFraction() - prevKeyframe.getFraction()); + int prevValue = prevKeyframe.getIntValue(); + int nextValue = nextKeyframe.getIntValue(); + return mEvaluator == null ? + prevValue + (int)(intervalFraction * (nextValue - prevValue)) : + ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)). + intValue(); + } + prevKeyframe = nextKeyframe; + } + // shouldn't get here + return ((Number)mKeyframes.get(mNumKeyframes - 1).getValue()).intValue(); + } + +} + diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/Keyframe.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/Keyframe.java new file mode 100644 index 000000000..ab76fa7f6 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/Keyframe.java @@ -0,0 +1,361 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; + +import android.view.animation.Interpolator; + +/** + * This class holds a time/value pair for an animation. The Keyframe class is used + * by {@link ValueAnimator} to define the values that the animation target will have over the course + * of the animation. As the time proceeds from one keyframe to the other, the value of the + * target object will animate between the value at the previous keyframe and the value at the + * next keyframe. Each keyframe also holds an optional {@link TimeInterpolator} + * object, which defines the time interpolation over the intervalue preceding the keyframe. + * + *

The Keyframe class itself is abstract. The type-specific factory methods will return + * a subclass of Keyframe specific to the type of value being stored. This is done to improve + * performance when dealing with the most common cases (e.g., float and + * int values). Other types will fall into a more general Keyframe class that + * treats its values as Objects. Unless your animation requires dealing with a custom type + * or a data structure that needs to be animated directly (and evaluated using an implementation + * of {@link TypeEvaluator}), you should stick to using float and int as animations using those + * types have lower runtime overhead than other types.

+ */ +@SuppressWarnings("rawtypes") +public abstract class Keyframe implements Cloneable { + /** + * The time at which mValue will hold true. + */ + float mFraction; + + /** + * The type of the value in this Keyframe. This type is determined at construction time, + * based on the type of the value object passed into the constructor. + */ + Class mValueType; + + /** + * The optional time interpolator for the interval preceding this keyframe. A null interpolator + * (the default) results in linear interpolation over the interval. + */ + private /*Time*/Interpolator mInterpolator = null; + + /** + * Flag to indicate whether this keyframe has a valid value. This flag is used when an + * animation first starts, to populate placeholder keyframes with real values derived + * from the target object. + */ + boolean mHasValue = false; + + /** + * Constructs a Keyframe object with the given time and value. The time defines the + * time, as a proportion of an overall animation's duration, at which the value will hold true + * for the animation. The value for the animation between keyframes will be calculated as + * an interpolation between the values at those keyframes. + * + * @param fraction The time, expressed as a value between 0 and 1, representing the fraction + * of time elapsed of the overall animation duration. + * @param value The value that the object will animate to as the animation time approaches + * the time in this keyframe, and the the value animated from as the time passes the time in + * this keyframe. + */ + public static Keyframe ofInt(float fraction, int value) { + return new IntKeyframe(fraction, value); + } + + /** + * Constructs a Keyframe object with the given time. The value at this time will be derived + * from the target object when the animation first starts (note that this implies that keyframes + * with no initial value must be used as part of an {@link ObjectAnimator}). + * The time defines the + * time, as a proportion of an overall animation's duration, at which the value will hold true + * for the animation. The value for the animation between keyframes will be calculated as + * an interpolation between the values at those keyframes. + * + * @param fraction The time, expressed as a value between 0 and 1, representing the fraction + * of time elapsed of the overall animation duration. + */ + public static Keyframe ofInt(float fraction) { + return new IntKeyframe(fraction); + } + + /** + * Constructs a Keyframe object with the given time and value. The time defines the + * time, as a proportion of an overall animation's duration, at which the value will hold true + * for the animation. The value for the animation between keyframes will be calculated as + * an interpolation between the values at those keyframes. + * + * @param fraction The time, expressed as a value between 0 and 1, representing the fraction + * of time elapsed of the overall animation duration. + * @param value The value that the object will animate to as the animation time approaches + * the time in this keyframe, and the the value animated from as the time passes the time in + * this keyframe. + */ + public static Keyframe ofFloat(float fraction, float value) { + return new FloatKeyframe(fraction, value); + } + + /** + * Constructs a Keyframe object with the given time. The value at this time will be derived + * from the target object when the animation first starts (note that this implies that keyframes + * with no initial value must be used as part of an {@link ObjectAnimator}). + * The time defines the + * time, as a proportion of an overall animation's duration, at which the value will hold true + * for the animation. The value for the animation between keyframes will be calculated as + * an interpolation between the values at those keyframes. + * + * @param fraction The time, expressed as a value between 0 and 1, representing the fraction + * of time elapsed of the overall animation duration. + */ + public static Keyframe ofFloat(float fraction) { + return new FloatKeyframe(fraction); + } + + /** + * Constructs a Keyframe object with the given time and value. The time defines the + * time, as a proportion of an overall animation's duration, at which the value will hold true + * for the animation. The value for the animation between keyframes will be calculated as + * an interpolation between the values at those keyframes. + * + * @param fraction The time, expressed as a value between 0 and 1, representing the fraction + * of time elapsed of the overall animation duration. + * @param value The value that the object will animate to as the animation time approaches + * the time in this keyframe, and the the value animated from as the time passes the time in + * this keyframe. + */ + public static Keyframe ofObject(float fraction, Object value) { + return new ObjectKeyframe(fraction, value); + } + + /** + * Constructs a Keyframe object with the given time. The value at this time will be derived + * from the target object when the animation first starts (note that this implies that keyframes + * with no initial value must be used as part of an {@link ObjectAnimator}). + * The time defines the + * time, as a proportion of an overall animation's duration, at which the value will hold true + * for the animation. The value for the animation between keyframes will be calculated as + * an interpolation between the values at those keyframes. + * + * @param fraction The time, expressed as a value between 0 and 1, representing the fraction + * of time elapsed of the overall animation duration. + */ + public static Keyframe ofObject(float fraction) { + return new ObjectKeyframe(fraction, null); + } + + /** + * Indicates whether this keyframe has a valid value. This method is called internally when + * an {@link ObjectAnimator} first starts; keyframes without values are assigned values at + * that time by deriving the value for the property from the target object. + * + * @return boolean Whether this object has a value assigned. + */ + public boolean hasValue() { + return mHasValue; + } + + /** + * Gets the value for this Keyframe. + * + * @return The value for this Keyframe. + */ + public abstract Object getValue(); + + /** + * Sets the value for this Keyframe. + * + * @param value value for this Keyframe. + */ + public abstract void setValue(Object value); + + /** + * Gets the time for this keyframe, as a fraction of the overall animation duration. + * + * @return The time associated with this keyframe, as a fraction of the overall animation + * duration. This should be a value between 0 and 1. + */ + public float getFraction() { + return mFraction; + } + + /** + * Sets the time for this keyframe, as a fraction of the overall animation duration. + * + * @param fraction time associated with this keyframe, as a fraction of the overall animation + * duration. This should be a value between 0 and 1. + */ + public void setFraction(float fraction) { + mFraction = fraction; + } + + /** + * Gets the optional interpolator for this Keyframe. A value of null indicates + * that there is no interpolation, which is the same as linear interpolation. + * + * @return The optional interpolator for this Keyframe. + */ + public /*Time*/Interpolator getInterpolator() { + return mInterpolator; + } + + /** + * Sets the optional interpolator for this Keyframe. A value of null indicates + * that there is no interpolation, which is the same as linear interpolation. + * + * @return The optional interpolator for this Keyframe. + */ + public void setInterpolator(/*Time*/Interpolator interpolator) { + mInterpolator = interpolator; + } + + /** + * Gets the type of keyframe. This information is used by ValueAnimator to determine the type of + * {@link TypeEvaluator} to use when calculating values between keyframes. The type is based + * on the type of Keyframe created. + * + * @return The type of the value stored in the Keyframe. + */ + public Class getType() { + return mValueType; + } + + @Override + public abstract Keyframe clone(); + + /** + * This internal subclass is used for all types which are not int or float. + */ + static class ObjectKeyframe extends Keyframe { + + /** + * The value of the animation at the time mFraction. + */ + Object mValue; + + ObjectKeyframe(float fraction, Object value) { + mFraction = fraction; + mValue = value; + mHasValue = (value != null); + mValueType = mHasValue ? value.getClass() : Object.class; + } + + public Object getValue() { + return mValue; + } + + public void setValue(Object value) { + mValue = value; + mHasValue = (value != null); + } + + @Override + public ObjectKeyframe clone() { + ObjectKeyframe kfClone = new ObjectKeyframe(getFraction(), mValue); + kfClone.setInterpolator(getInterpolator()); + return kfClone; + } + } + + /** + * Internal subclass used when the keyframe value is of type int. + */ + static class IntKeyframe extends Keyframe { + + /** + * The value of the animation at the time mFraction. + */ + int mValue; + + IntKeyframe(float fraction, int value) { + mFraction = fraction; + mValue = value; + mValueType = int.class; + mHasValue = true; + } + + IntKeyframe(float fraction) { + mFraction = fraction; + mValueType = int.class; + } + + public int getIntValue() { + return mValue; + } + + public Object getValue() { + return mValue; + } + + public void setValue(Object value) { + if (value != null && value.getClass() == Integer.class) { + mValue = ((Integer)value).intValue(); + mHasValue = true; + } + } + + @Override + public IntKeyframe clone() { + IntKeyframe kfClone = new IntKeyframe(getFraction(), mValue); + kfClone.setInterpolator(getInterpolator()); + return kfClone; + } + } + + /** + * Internal subclass used when the keyframe value is of type float. + */ + static class FloatKeyframe extends Keyframe { + /** + * The value of the animation at the time mFraction. + */ + float mValue; + + FloatKeyframe(float fraction, float value) { + mFraction = fraction; + mValue = value; + mValueType = float.class; + mHasValue = true; + } + + FloatKeyframe(float fraction) { + mFraction = fraction; + mValueType = float.class; + } + + public float getFloatValue() { + return mValue; + } + + public Object getValue() { + return mValue; + } + + public void setValue(Object value) { + if (value != null && value.getClass() == Float.class) { + mValue = ((Float)value).floatValue(); + mHasValue = true; + } + } + + @Override + public FloatKeyframe clone() { + FloatKeyframe kfClone = new FloatKeyframe(getFraction(), mValue); + kfClone.setInterpolator(getInterpolator()); + return kfClone; + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/KeyframeSet.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/KeyframeSet.java new file mode 100644 index 000000000..a71e1ad3c --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/KeyframeSet.java @@ -0,0 +1,227 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; + +import java.util.ArrayList; +import java.util.Arrays; +import android.view.animation.Interpolator; + +import com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.FloatKeyframe; +import com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.IntKeyframe; +import com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.ObjectKeyframe; + +/** + * This class holds a collection of Keyframe objects and is called by ValueAnimator to calculate + * values between those keyframes for a given animation. The class internal to the animation + * package because it is an implementation detail of how Keyframes are stored and used. + */ +@SuppressWarnings({"rawtypes", "unchecked"}) +class KeyframeSet { + + int mNumKeyframes; + + Keyframe mFirstKeyframe; + Keyframe mLastKeyframe; + /*Time*/Interpolator mInterpolator; // only used in the 2-keyframe case + ArrayList mKeyframes; // only used when there are not 2 keyframes + TypeEvaluator mEvaluator; + + + public KeyframeSet(Keyframe... keyframes) { + mNumKeyframes = keyframes.length; + mKeyframes = new ArrayList(); + mKeyframes.addAll(Arrays.asList(keyframes)); + mFirstKeyframe = mKeyframes.get(0); + mLastKeyframe = mKeyframes.get(mNumKeyframes - 1); + mInterpolator = mLastKeyframe.getInterpolator(); + } + + public static KeyframeSet ofInt(int... values) { + int numKeyframes = values.length; + IntKeyframe keyframes[] = new IntKeyframe[Math.max(numKeyframes,2)]; + if (numKeyframes == 1) { + keyframes[0] = (IntKeyframe) Keyframe.ofInt(0f); + keyframes[1] = (IntKeyframe) Keyframe.ofInt(1f, values[0]); + } else { + keyframes[0] = (IntKeyframe) Keyframe.ofInt(0f, values[0]); + for (int i = 1; i < numKeyframes; ++i) { + keyframes[i] = (IntKeyframe) Keyframe.ofInt((float) i / (numKeyframes - 1), values[i]); + } + } + return new IntKeyframeSet(keyframes); + } + + public static KeyframeSet ofFloat(float... values) { + int numKeyframes = values.length; + FloatKeyframe keyframes[] = new FloatKeyframe[Math.max(numKeyframes,2)]; + if (numKeyframes == 1) { + keyframes[0] = (FloatKeyframe) Keyframe.ofFloat(0f); + keyframes[1] = (FloatKeyframe) Keyframe.ofFloat(1f, values[0]); + } else { + keyframes[0] = (FloatKeyframe) Keyframe.ofFloat(0f, values[0]); + for (int i = 1; i < numKeyframes; ++i) { + keyframes[i] = (FloatKeyframe) Keyframe.ofFloat((float) i / (numKeyframes - 1), values[i]); + } + } + return new FloatKeyframeSet(keyframes); + } + + public static KeyframeSet ofKeyframe(Keyframe... keyframes) { + // if all keyframes of same primitive type, create the appropriate KeyframeSet + int numKeyframes = keyframes.length; + boolean hasFloat = false; + boolean hasInt = false; + boolean hasOther = false; + for (int i = 0; i < numKeyframes; ++i) { + if (keyframes[i] instanceof FloatKeyframe) { + hasFloat = true; + } else if (keyframes[i] instanceof IntKeyframe) { + hasInt = true; + } else { + hasOther = true; + } + } + if (hasFloat && !hasInt && !hasOther) { + FloatKeyframe floatKeyframes[] = new FloatKeyframe[numKeyframes]; + for (int i = 0; i < numKeyframes; ++i) { + floatKeyframes[i] = (FloatKeyframe) keyframes[i]; + } + return new FloatKeyframeSet(floatKeyframes); + } else if (hasInt && !hasFloat && !hasOther) { + IntKeyframe intKeyframes[] = new IntKeyframe[numKeyframes]; + for (int i = 0; i < numKeyframes; ++i) { + intKeyframes[i] = (IntKeyframe) keyframes[i]; + } + return new IntKeyframeSet(intKeyframes); + } else { + return new KeyframeSet(keyframes); + } + } + + public static KeyframeSet ofObject(Object... values) { + int numKeyframes = values.length; + ObjectKeyframe keyframes[] = new ObjectKeyframe[Math.max(numKeyframes,2)]; + if (numKeyframes == 1) { + keyframes[0] = (ObjectKeyframe) Keyframe.ofObject(0f); + keyframes[1] = (ObjectKeyframe) Keyframe.ofObject(1f, values[0]); + } else { + keyframes[0] = (ObjectKeyframe) Keyframe.ofObject(0f, values[0]); + for (int i = 1; i < numKeyframes; ++i) { + keyframes[i] = (ObjectKeyframe) Keyframe.ofObject((float) i / (numKeyframes - 1), values[i]); + } + } + return new KeyframeSet(keyframes); + } + + /** + * Sets the TypeEvaluator to be used when calculating animated values. This object + * is required only for KeyframeSets that are not either IntKeyframeSet or FloatKeyframeSet, + * both of which assume their own evaluator to speed up calculations with those primitive + * types. + * + * @param evaluator The TypeEvaluator to be used to calculate animated values. + */ + public void setEvaluator(TypeEvaluator evaluator) { + mEvaluator = evaluator; + } + + @Override + public KeyframeSet clone() { + ArrayList keyframes = mKeyframes; + int numKeyframes = mKeyframes.size(); + Keyframe[] newKeyframes = new Keyframe[numKeyframes]; + for (int i = 0; i < numKeyframes; ++i) { + newKeyframes[i] = keyframes.get(i).clone(); + } + KeyframeSet newSet = new KeyframeSet(newKeyframes); + return newSet; + } + + /** + * Gets the animated value, given the elapsed fraction of the animation (interpolated by the + * animation's interpolator) and the evaluator used to calculate in-between values. This + * function maps the input fraction to the appropriate keyframe interval and a fraction + * between them and returns the interpolated value. Note that the input fraction may fall + * outside the [0-1] bounds, if the animation's interpolator made that happen (e.g., a + * spring interpolation that might send the fraction past 1.0). We handle this situation by + * just using the two keyframes at the appropriate end when the value is outside those bounds. + * + * @param fraction The elapsed fraction of the animation + * @return The animated value. + */ + public Object getValue(float fraction) { + + // Special-case optimization for the common case of only two keyframes + if (mNumKeyframes == 2) { + if (mInterpolator != null) { + fraction = mInterpolator.getInterpolation(fraction); + } + return mEvaluator.evaluate(fraction, mFirstKeyframe.getValue(), + mLastKeyframe.getValue()); + } + if (fraction <= 0f) { + final Keyframe nextKeyframe = mKeyframes.get(1); + final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator(); + if (interpolator != null) { + fraction = interpolator.getInterpolation(fraction); + } + final float prevFraction = mFirstKeyframe.getFraction(); + float intervalFraction = (fraction - prevFraction) / + (nextKeyframe.getFraction() - prevFraction); + return mEvaluator.evaluate(intervalFraction, mFirstKeyframe.getValue(), + nextKeyframe.getValue()); + } else if (fraction >= 1f) { + final Keyframe prevKeyframe = mKeyframes.get(mNumKeyframes - 2); + final /*Time*/Interpolator interpolator = mLastKeyframe.getInterpolator(); + if (interpolator != null) { + fraction = interpolator.getInterpolation(fraction); + } + final float prevFraction = prevKeyframe.getFraction(); + float intervalFraction = (fraction - prevFraction) / + (mLastKeyframe.getFraction() - prevFraction); + return mEvaluator.evaluate(intervalFraction, prevKeyframe.getValue(), + mLastKeyframe.getValue()); + } + Keyframe prevKeyframe = mFirstKeyframe; + for (int i = 1; i < mNumKeyframes; ++i) { + Keyframe nextKeyframe = mKeyframes.get(i); + if (fraction < nextKeyframe.getFraction()) { + final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator(); + if (interpolator != null) { + fraction = interpolator.getInterpolation(fraction); + } + final float prevFraction = prevKeyframe.getFraction(); + float intervalFraction = (fraction - prevFraction) / + (nextKeyframe.getFraction() - prevFraction); + return mEvaluator.evaluate(intervalFraction, prevKeyframe.getValue(), + nextKeyframe.getValue()); + } + prevKeyframe = nextKeyframe; + } + // shouldn't reach here + return mLastKeyframe.getValue(); + } + + @Override + public String toString() { + String returnVal = " "; + for (int i = 0; i < mNumKeyframes; ++i) { + returnVal += mKeyframes.get(i).getValue() + " "; + } + return returnVal; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ObjectAnimator.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ObjectAnimator.java new file mode 100644 index 000000000..21d15c02a --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ObjectAnimator.java @@ -0,0 +1,491 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; + +import android.util.Log; +//import android.util.Property; + +//import java.lang.reflect.Method; +import java.util.ArrayList; + +/** + * This subclass of {@link ValueAnimator} provides support for animating properties on target objects. + * The constructors of this class take parameters to define the target object that will be animated + * as well as the name of the property that will be animated. Appropriate set/get functions + * are then determined internally and the animation will call these functions as necessary to + * animate the property. + * + * @see #setPropertyName(String) + * + */ +@SuppressWarnings("rawtypes") +public final class ObjectAnimator extends ValueAnimator { + private static final boolean DBG = false; + + // The target object on which the property exists, set in the constructor + private Object mTarget; + + private String mPropertyName; + + //private Property mProperty; + + /** + * Sets the name of the property that will be animated. This name is used to derive + * a setter function that will be called to set animated values. + * For example, a property name of foo will result + * in a call to the function setFoo() on the target object. If either + * valueFrom or valueTo is null, then a getter function will + * also be derived and called. + * + *

For best performance of the mechanism that calls the setter function determined by the + * name of the property being animated, use float or int typed values, + * and make the setter function for those properties have a void return value. This + * will cause the code to take an optimized path for these constrained circumstances. Other + * property types and return types will work, but will have more overhead in processing + * the requests due to normal reflection mechanisms.

+ * + *

Note that the setter function derived from this property name + * must take the same parameter type as the + * valueFrom and valueTo properties, otherwise the call to + * the setter function will fail.

+ * + *

If this ObjectAnimator has been set up to animate several properties together, + * using more than one PropertyValuesHolder objects, then setting the propertyName simply + * sets the propertyName in the first of those PropertyValuesHolder objects.

+ * + * @param propertyName The name of the property being animated. Should not be null. + */ + public void setPropertyName(String propertyName) { + // mValues could be null if this is being constructed piecemeal. Just record the + // propertyName to be used later when setValues() is called if so. + if (mValues != null) { + PropertyValuesHolder valuesHolder = mValues[0]; + String oldName = valuesHolder.getPropertyName(); + valuesHolder.setPropertyName(propertyName); + mValuesMap.remove(oldName); + mValuesMap.put(propertyName, valuesHolder); + } + mPropertyName = propertyName; + // New property/values/target should cause re-initialization prior to starting + mInitialized = false; + } + + /** + * Sets the property that will be animated. Property objects will take precedence over + * properties specified by the {@link #setPropertyName(String)} method. Animations should + * be set up to use one or the other, not both. + * + * @param property The property being animated. Should not be null. + */ + //public void setProperty(Property property) { + // // mValues could be null if this is being constructed piecemeal. Just record the + // // propertyName to be used later when setValues() is called if so. + // if (mValues != null) { + // PropertyValuesHolder valuesHolder = mValues[0]; + // String oldName = valuesHolder.getPropertyName(); + // valuesHolder.setProperty(property); + // mValuesMap.remove(oldName); + // mValuesMap.put(mPropertyName, valuesHolder); + // } + // if (mProperty != null) { + // mPropertyName = property.getName(); + // } + // mProperty = property; + // // New property/values/target should cause re-initialization prior to starting + // mInitialized = false; + //} + + /** + * Gets the name of the property that will be animated. This name will be used to derive + * a setter function that will be called to set animated values. + * For example, a property name of foo will result + * in a call to the function setFoo() on the target object. If either + * valueFrom or valueTo is null, then a getter function will + * also be derived and called. + */ + public String getPropertyName() { + return mPropertyName; + } + + /** + * Creates a new ObjectAnimator object. This default constructor is primarily for + * use internally; the other constructors which take parameters are more generally + * useful. + */ + public ObjectAnimator() { + } + + /** + * Private utility constructor that initializes the target object and name of the + * property being animated. + * + * @param target The object whose property is to be animated. This object should + * have a public method on it called setName(), where name is + * the value of the propertyName parameter. + * @param propertyName The name of the property being animated. + */ + private ObjectAnimator(Object target, String propertyName) { + mTarget = target; + setPropertyName(propertyName); + } + + /** + * Private utility constructor that initializes the target object and property being animated. + * + * @param target The object whose property is to be animated. + * @param property The property being animated. + */ + //private ObjectAnimator(T target, Property property) { + // mTarget = target; + // setProperty(property); + //} + + /** + * Constructs and returns an ObjectAnimator that animates between int values. A single + * value implies that that value is the one being animated to. Two values imply a starting + * and ending values. More than two values imply a starting value, values to animate through + * along the way, and an ending value (these values will be distributed evenly across + * the duration of the animation). + * + * @param target The object whose property is to be animated. This object should + * have a public method on it called setName(), where name is + * the value of the propertyName parameter. + * @param propertyName The name of the property being animated. + * @param values A set of values that the animation will animate between over time. + * @return An ObjectAnimator object that is set up to animate between the given values. + */ + public static ObjectAnimator ofInt(Object target, String propertyName, int... values) { + ObjectAnimator anim = new ObjectAnimator(target, propertyName); + anim.setIntValues(values); + return anim; + } + + /** + * Constructs and returns an ObjectAnimator that animates between int values. A single + * value implies that that value is the one being animated to. Two values imply a starting + * and ending values. More than two values imply a starting value, values to animate through + * along the way, and an ending value (these values will be distributed evenly across + * the duration of the animation). + * + * @param target The object whose property is to be animated. + * @param property The property being animated. + * @param values A set of values that the animation will animate between over time. + * @return An ObjectAnimator object that is set up to animate between the given values. + */ + //public static ObjectAnimator ofInt(T target, Property property, int... values) { + // ObjectAnimator anim = new ObjectAnimator(target, property); + // anim.setIntValues(values); + // return anim; + //} + + /** + * Constructs and returns an ObjectAnimator that animates between float values. A single + * value implies that that value is the one being animated to. Two values imply a starting + * and ending values. More than two values imply a starting value, values to animate through + * along the way, and an ending value (these values will be distributed evenly across + * the duration of the animation). + * + * @param target The object whose property is to be animated. This object should + * have a public method on it called setName(), where name is + * the value of the propertyName parameter. + * @param propertyName The name of the property being animated. + * @param values A set of values that the animation will animate between over time. + * @return An ObjectAnimator object that is set up to animate between the given values. + */ + public static ObjectAnimator ofFloat(Object target, String propertyName, float... values) { + ObjectAnimator anim = new ObjectAnimator(target, propertyName); + anim.setFloatValues(values); + return anim; + } + + /** + * Constructs and returns an ObjectAnimator that animates between float values. A single + * value implies that that value is the one being animated to. Two values imply a starting + * and ending values. More than two values imply a starting value, values to animate through + * along the way, and an ending value (these values will be distributed evenly across + * the duration of the animation). + * + * @param target The object whose property is to be animated. + * @param property The property being animated. + * @param values A set of values that the animation will animate between over time. + * @return An ObjectAnimator object that is set up to animate between the given values. + */ + //public static ObjectAnimator ofFloat(T target, Property property, + // float... values) { + // ObjectAnimator anim = new ObjectAnimator(target, property); + // anim.setFloatValues(values); + // return anim; + //} + + /** + * Constructs and returns an ObjectAnimator that animates between Object values. A single + * value implies that that value is the one being animated to. Two values imply a starting + * and ending values. More than two values imply a starting value, values to animate through + * along the way, and an ending value (these values will be distributed evenly across + * the duration of the animation). + * + * @param target The object whose property is to be animated. This object should + * have a public method on it called setName(), where name is + * the value of the propertyName parameter. + * @param propertyName The name of the property being animated. + * @param evaluator A TypeEvaluator that will be called on each animation frame to + * provide the necessary interpolation between the Object values to derive the animated + * value. + * @param values A set of values that the animation will animate between over time. + * @return An ObjectAnimator object that is set up to animate between the given values. + */ + public static ObjectAnimator ofObject(Object target, String propertyName, + TypeEvaluator evaluator, Object... values) { + ObjectAnimator anim = new ObjectAnimator(target, propertyName); + anim.setObjectValues(values); + anim.setEvaluator(evaluator); + return anim; + } + + /** + * Constructs and returns an ObjectAnimator that animates between Object values. A single + * value implies that that value is the one being animated to. Two values imply a starting + * and ending values. More than two values imply a starting value, values to animate through + * along the way, and an ending value (these values will be distributed evenly across + * the duration of the animation). + * + * @param target The object whose property is to be animated. + * @param property The property being animated. + * @param evaluator A TypeEvaluator that will be called on each animation frame to + * provide the necessary interpolation between the Object values to derive the animated + * value. + * @param values A set of values that the animation will animate between over time. + * @return An ObjectAnimator object that is set up to animate between the given values. + */ + //public static ObjectAnimator ofObject(T target, Property property, + // TypeEvaluator evaluator, V... values) { + // ObjectAnimator anim = new ObjectAnimator(target, property); + // anim.setObjectValues(values); + // anim.setEvaluator(evaluator); + // return anim; + //} + + /** + * Constructs and returns an ObjectAnimator that animates between the sets of values specified + * in PropertyValueHolder objects. This variant should be used when animating + * several properties at once with the same ObjectAnimator, since PropertyValuesHolder allows + * you to associate a set of animation values with a property name. + * + * @param target The object whose property is to be animated. Depending on how the + * PropertyValuesObjects were constructed, the target object should either have the {@link + * android.util.Property} objects used to construct the PropertyValuesHolder objects or (if the + * PropertyValuesHOlder objects were created with property names) the target object should have + * public methods on it called setName(), where name is the name of + * the property passed in as the propertyName parameter for each of the + * PropertyValuesHolder objects. + * @param values A set of PropertyValuesHolder objects whose values will be animated between + * over time. + * @return An ObjectAnimator object that is set up to animate between the given values. + */ + public static ObjectAnimator ofPropertyValuesHolder(Object target, + PropertyValuesHolder... values) { + ObjectAnimator anim = new ObjectAnimator(); + anim.mTarget = target; + anim.setValues(values); + return anim; + } + + @Override + public void setIntValues(int... values) { + if (mValues == null || mValues.length == 0) { + // No values yet - this animator is being constructed piecemeal. Init the values with + // whatever the current propertyName is + //if (mProperty != null) { + // setValues(PropertyValuesHolder.ofInt(mProperty, values)); + //} else { + setValues(PropertyValuesHolder.ofInt(mPropertyName, values)); + //} + } else { + super.setIntValues(values); + } + } + + @Override + public void setFloatValues(float... values) { + if (mValues == null || mValues.length == 0) { + // No values yet - this animator is being constructed piecemeal. Init the values with + // whatever the current propertyName is + //if (mProperty != null) { + // setValues(PropertyValuesHolder.ofFloat(mProperty, values)); + //} else { + setValues(PropertyValuesHolder.ofFloat(mPropertyName, values)); + //} + } else { + super.setFloatValues(values); + } + } + + @Override + public void setObjectValues(Object... values) { + if (mValues == null || mValues.length == 0) { + // No values yet - this animator is being constructed piecemeal. Init the values with + // whatever the current propertyName is + //if (mProperty != null) { + // setValues(PropertyValuesHolder.ofObject(mProperty, (TypeEvaluator)null, values)); + //} else { + setValues(PropertyValuesHolder.ofObject(mPropertyName, (TypeEvaluator)null, values)); + //} + } else { + super.setObjectValues(values); + } + } + + @Override + public void start() { + if (DBG) { + Log.d("ObjectAnimator", "Anim target, duration: " + mTarget + ", " + getDuration()); + for (int i = 0; i < mValues.length; ++i) { + PropertyValuesHolder pvh = mValues[i]; + ArrayList keyframes = pvh.mKeyframeSet.mKeyframes; + Log.d("ObjectAnimator", " Values[" + i + "]: " + + pvh.getPropertyName() + ", " + keyframes.get(0).getValue() + ", " + + keyframes.get(pvh.mKeyframeSet.mNumKeyframes - 1).getValue()); + } + } + super.start(); + } + + /** + * This function is called immediately before processing the first animation + * frame of an animation. If there is a nonzero startDelay, the + * function is called after that delay ends. + * It takes care of the final initialization steps for the + * animation. This includes setting mEvaluator, if the user has not yet + * set it up, and the setter/getter methods, if the user did not supply + * them. + * + *

Overriders of this method should call the superclass method to cause + * internal mechanisms to be set up correctly.

+ */ + @Override + void initAnimation() { + if (!mInitialized) { + // mValueType may change due to setter/getter setup; do this before calling super.init(), + // which uses mValueType to set up the default type evaluator. + int numValues = mValues.length; + for (int i = 0; i < numValues; ++i) { + mValues[i].setupSetterAndGetter(mTarget); + } + super.initAnimation(); + } + } + + /** + * Sets the length of the animation. The default duration is 300 milliseconds. + * + * @param duration The length of the animation, in milliseconds. + * @return ObjectAnimator The object called with setDuration(). This return + * value makes it easier to compose statements together that construct and then set the + * duration, as in + * ObjectAnimator.ofInt(target, propertyName, 0, 10).setDuration(500).start(). + */ + @Override + public ObjectAnimator setDuration(long duration) { + super.setDuration(duration); + return this; + } + + + /** + * The target object whose property will be animated by this animation + * + * @return The object being animated + */ + public Object getTarget() { + return mTarget; + } + + /** + * Sets the target object whose property will be animated by this animation + * + * @param target The object being animated + */ + @Override + public void setTarget(Object target) { + if (mTarget != target) { + final Object oldTarget = mTarget; + mTarget = target; + if (oldTarget != null && target != null && oldTarget.getClass() == target.getClass()) { + return; + } + // New target type should cause re-initialization prior to starting + mInitialized = false; + } + } + + @Override + public void setupStartValues() { + initAnimation(); + int numValues = mValues.length; + for (int i = 0; i < numValues; ++i) { + mValues[i].setupStartValue(mTarget); + } + } + + @Override + public void setupEndValues() { + initAnimation(); + int numValues = mValues.length; + for (int i = 0; i < numValues; ++i) { + mValues[i].setupEndValue(mTarget); + } + } + + /** + * This method is called with the elapsed fraction of the animation during every + * animation frame. This function turns the elapsed fraction into an interpolated fraction + * and then into an animated value (from the evaluator. The function is called mostly during + * animation updates, but it is also called when the end() + * function is called, to set the final value on the property. + * + *

Overrides of this method must call the superclass to perform the calculation + * of the animated value.

+ * + * @param fraction The elapsed fraction of the animation. + */ + @Override + void animateValue(float fraction) { + super.animateValue(fraction); + int numValues = mValues.length; + for (int i = 0; i < numValues; ++i) { + mValues[i].setAnimatedValue(mTarget); + } + } + + @Override + public ObjectAnimator clone() { + final ObjectAnimator anim = (ObjectAnimator) super.clone(); + return anim; + } + + @Override + public String toString() { + String returnVal = "ObjectAnimator@" + Integer.toHexString(hashCode()) + ", target " + + mTarget; + if (mValues != null) { + for (int i = 0; i < mValues.length; ++i) { + returnVal += "\n " + mValues[i].toString(); + } + } + return returnVal; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/PropertyValuesHolder.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/PropertyValuesHolder.java new file mode 100644 index 000000000..84f7504ab --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/PropertyValuesHolder.java @@ -0,0 +1,1012 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; + +//import android.util.FloatProperty; +//import android.util.IntProperty; +import android.util.Log; +//import android.util.Property; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.concurrent.locks.ReentrantReadWriteLock; + +/** + * This class holds information about a property and the values that that property + * should take on during an animation. PropertyValuesHolder objects can be used to create + * animations with ValueAnimator or ObjectAnimator that operate on several different properties + * in parallel. + */ +@SuppressWarnings({"rawtypes", "unchecked"}) +public class PropertyValuesHolder implements Cloneable { + + /** + * The name of the property associated with the values. This need not be a real property, + * unless this object is being used with ObjectAnimator. But this is the name by which + * aniamted values are looked up with getAnimatedValue(String) in ValueAnimator. + */ + String mPropertyName; + + /** + * @hide + */ + //protected Property mProperty; + + /** + * The setter function, if needed. ObjectAnimator hands off this functionality to + * PropertyValuesHolder, since it holds all of the per-property information. This + * property is automatically + * derived when the animation starts in setupSetterAndGetter() if using ObjectAnimator. + */ + Method mSetter = null; + + /** + * The getter function, if needed. ObjectAnimator hands off this functionality to + * PropertyValuesHolder, since it holds all of the per-property information. This + * property is automatically + * derived when the animation starts in setupSetterAndGetter() if using ObjectAnimator. + * The getter is only derived and used if one of the values is null. + */ + private Method mGetter = null; + + /** + * The type of values supplied. This information is used both in deriving the setter/getter + * functions and in deriving the type of TypeEvaluator. + */ + Class mValueType; + + /** + * The set of keyframes (time/value pairs) that define this animation. + */ + KeyframeSet mKeyframeSet = null; + + + // type evaluators for the primitive types handled by this implementation + private static final TypeEvaluator sIntEvaluator = new IntEvaluator(); + private static final TypeEvaluator sFloatEvaluator = new FloatEvaluator(); + + // We try several different types when searching for appropriate setter/getter functions. + // The caller may have supplied values in a type that does not match the setter/getter + // functions (such as the integers 0 and 1 to represent floating point values for alpha). + // Also, the use of generics in constructors means that we end up with the Object versions + // of primitive types (Float vs. float). But most likely, the setter/getter functions + // will take primitive types instead. + // So we supply an ordered array of other types to try before giving up. + private static Class[] FLOAT_VARIANTS = {float.class, Float.class, double.class, int.class, + Double.class, Integer.class}; + private static Class[] INTEGER_VARIANTS = {int.class, Integer.class, float.class, double.class, + Float.class, Double.class}; + private static Class[] DOUBLE_VARIANTS = {double.class, Double.class, float.class, int.class, + Float.class, Integer.class}; + + // These maps hold all property entries for a particular class. This map + // is used to speed up property/setter/getter lookups for a given class/property + // combination. No need to use reflection on the combination more than once. + private static final HashMap> sSetterPropertyMap = + new HashMap>(); + private static final HashMap> sGetterPropertyMap = + new HashMap>(); + + // This lock is used to ensure that only one thread is accessing the property maps + // at a time. + final ReentrantReadWriteLock mPropertyMapLock = new ReentrantReadWriteLock(); + + // Used to pass single value to varargs parameter in setter invocation + final Object[] mTmpValueArray = new Object[1]; + + /** + * The type evaluator used to calculate the animated values. This evaluator is determined + * automatically based on the type of the start/end objects passed into the constructor, + * but the system only knows about the primitive types int and float. Any other + * type will need to set the evaluator to a custom evaluator for that type. + */ + private TypeEvaluator mEvaluator; + + /** + * The value most recently calculated by calculateValue(). This is set during + * that function and might be retrieved later either by ValueAnimator.animatedValue() or + * by the property-setting logic in ObjectAnimator.animatedValue(). + */ + private Object mAnimatedValue; + + /** + * Internal utility constructor, used by the factory methods to set the property name. + * @param propertyName The name of the property for this holder. + */ + private PropertyValuesHolder(String propertyName) { + mPropertyName = propertyName; + } + + /** + * Internal utility constructor, used by the factory methods to set the property. + * @param property The property for this holder. + */ + //private PropertyValuesHolder(Property property) { + // mProperty = property; + // if (property != null) { + // mPropertyName = property.getName(); + // } + //} + + /** + * Constructs and returns a PropertyValuesHolder with a given property name and + * set of int values. + * @param propertyName The name of the property being animated. + * @param values The values that the named property will animate between. + * @return PropertyValuesHolder The constructed PropertyValuesHolder object. + */ + public static PropertyValuesHolder ofInt(String propertyName, int... values) { + return new IntPropertyValuesHolder(propertyName, values); + } + + /** + * Constructs and returns a PropertyValuesHolder with a given property and + * set of int values. + * @param property The property being animated. Should not be null. + * @param values The values that the property will animate between. + * @return PropertyValuesHolder The constructed PropertyValuesHolder object. + */ + //public static PropertyValuesHolder ofInt(Property property, int... values) { + // return new IntPropertyValuesHolder(property, values); + //} + + /** + * Constructs and returns a PropertyValuesHolder with a given property name and + * set of float values. + * @param propertyName The name of the property being animated. + * @param values The values that the named property will animate between. + * @return PropertyValuesHolder The constructed PropertyValuesHolder object. + */ + public static PropertyValuesHolder ofFloat(String propertyName, float... values) { + return new FloatPropertyValuesHolder(propertyName, values); + } + + /** + * Constructs and returns a PropertyValuesHolder with a given property and + * set of float values. + * @param property The property being animated. Should not be null. + * @param values The values that the property will animate between. + * @return PropertyValuesHolder The constructed PropertyValuesHolder object. + */ + //public static PropertyValuesHolder ofFloat(Property property, float... values) { + // return new FloatPropertyValuesHolder(property, values); + //} + + /** + * Constructs and returns a PropertyValuesHolder with a given property name and + * set of Object values. This variant also takes a TypeEvaluator because the system + * cannot automatically interpolate between objects of unknown type. + * + * @param propertyName The name of the property being animated. + * @param evaluator A TypeEvaluator that will be called on each animation frame to + * provide the necessary interpolation between the Object values to derive the animated + * value. + * @param values The values that the named property will animate between. + * @return PropertyValuesHolder The constructed PropertyValuesHolder object. + */ + public static PropertyValuesHolder ofObject(String propertyName, TypeEvaluator evaluator, + Object... values) { + PropertyValuesHolder pvh = new PropertyValuesHolder(propertyName); + pvh.setObjectValues(values); + pvh.setEvaluator(evaluator); + return pvh; + } + + /** + * Constructs and returns a PropertyValuesHolder with a given property and + * set of Object values. This variant also takes a TypeEvaluator because the system + * cannot automatically interpolate between objects of unknown type. + * + * @param property The property being animated. Should not be null. + * @param evaluator A TypeEvaluator that will be called on each animation frame to + * provide the necessary interpolation between the Object values to derive the animated + * value. + * @param values The values that the property will animate between. + * @return PropertyValuesHolder The constructed PropertyValuesHolder object. + */ + //public static PropertyValuesHolder ofObject(Property property, + // TypeEvaluator evaluator, V... values) { + // PropertyValuesHolder pvh = new PropertyValuesHolder(property); + // pvh.setObjectValues(values); + // pvh.setEvaluator(evaluator); + // return pvh; + //} + + /** + * Constructs and returns a PropertyValuesHolder object with the specified property name and set + * of values. These values can be of any type, but the type should be consistent so that + * an appropriate {@link android.animation.TypeEvaluator} can be found that matches + * the common type. + *

If there is only one value, it is assumed to be the end value of an animation, + * and an initial value will be derived, if possible, by calling a getter function + * on the object. Also, if any value is null, the value will be filled in when the animation + * starts in the same way. This mechanism of automatically getting null values only works + * if the PropertyValuesHolder object is used in conjunction + * {@link ObjectAnimator}, and with a getter function + * derived automatically from propertyName, since otherwise PropertyValuesHolder has + * no way of determining what the value should be. + * @param propertyName The name of the property associated with this set of values. This + * can be the actual property name to be used when using a ObjectAnimator object, or + * just a name used to get animated values, such as if this object is used with an + * ValueAnimator object. + * @param values The set of values to animate between. + */ + public static PropertyValuesHolder ofKeyframe(String propertyName, Keyframe... values) { + KeyframeSet keyframeSet = KeyframeSet.ofKeyframe(values); + if (keyframeSet instanceof IntKeyframeSet) { + return new IntPropertyValuesHolder(propertyName, (IntKeyframeSet) keyframeSet); + } else if (keyframeSet instanceof FloatKeyframeSet) { + return new FloatPropertyValuesHolder(propertyName, (FloatKeyframeSet) keyframeSet); + } + else { + PropertyValuesHolder pvh = new PropertyValuesHolder(propertyName); + pvh.mKeyframeSet = keyframeSet; + pvh.mValueType = values[0].getType(); + return pvh; + } + } + + /** + * Constructs and returns a PropertyValuesHolder object with the specified property and set + * of values. These values can be of any type, but the type should be consistent so that + * an appropriate {@link android.animation.TypeEvaluator} can be found that matches + * the common type. + *

If there is only one value, it is assumed to be the end value of an animation, + * and an initial value will be derived, if possible, by calling the property's + * {@link android.util.Property#get(Object)} function. + * Also, if any value is null, the value will be filled in when the animation + * starts in the same way. This mechanism of automatically getting null values only works + * if the PropertyValuesHolder object is used in conjunction with + * {@link ObjectAnimator}, since otherwise PropertyValuesHolder has + * no way of determining what the value should be. + * @param property The property associated with this set of values. Should not be null. + * @param values The set of values to animate between. + */ + //public static PropertyValuesHolder ofKeyframe(Property property, Keyframe... values) { + // KeyframeSet keyframeSet = KeyframeSet.ofKeyframe(values); + // if (keyframeSet instanceof IntKeyframeSet) { + // return new IntPropertyValuesHolder(property, (IntKeyframeSet) keyframeSet); + // } else if (keyframeSet instanceof FloatKeyframeSet) { + // return new FloatPropertyValuesHolder(property, (FloatKeyframeSet) keyframeSet); + // } + // else { + // PropertyValuesHolder pvh = new PropertyValuesHolder(property); + // pvh.mKeyframeSet = keyframeSet; + // pvh.mValueType = ((Keyframe)values[0]).getType(); + // return pvh; + // } + //} + + /** + * Set the animated values for this object to this set of ints. + * If there is only one value, it is assumed to be the end value of an animation, + * and an initial value will be derived, if possible, by calling a getter function + * on the object. Also, if any value is null, the value will be filled in when the animation + * starts in the same way. This mechanism of automatically getting null values only works + * if the PropertyValuesHolder object is used in conjunction + * {@link ObjectAnimator}, and with a getter function + * derived automatically from propertyName, since otherwise PropertyValuesHolder has + * no way of determining what the value should be. + * + * @param values One or more values that the animation will animate between. + */ + public void setIntValues(int... values) { + mValueType = int.class; + mKeyframeSet = KeyframeSet.ofInt(values); + } + + /** + * Set the animated values for this object to this set of floats. + * If there is only one value, it is assumed to be the end value of an animation, + * and an initial value will be derived, if possible, by calling a getter function + * on the object. Also, if any value is null, the value will be filled in when the animation + * starts in the same way. This mechanism of automatically getting null values only works + * if the PropertyValuesHolder object is used in conjunction + * {@link ObjectAnimator}, and with a getter function + * derived automatically from propertyName, since otherwise PropertyValuesHolder has + * no way of determining what the value should be. + * + * @param values One or more values that the animation will animate between. + */ + public void setFloatValues(float... values) { + mValueType = float.class; + mKeyframeSet = KeyframeSet.ofFloat(values); + } + + /** + * Set the animated values for this object to this set of Keyframes. + * + * @param values One or more values that the animation will animate between. + */ + public void setKeyframes(Keyframe... values) { + int numKeyframes = values.length; + Keyframe keyframes[] = new Keyframe[Math.max(numKeyframes,2)]; + mValueType = values[0].getType(); + for (int i = 0; i < numKeyframes; ++i) { + keyframes[i] = values[i]; + } + mKeyframeSet = new KeyframeSet(keyframes); + } + + /** + * Set the animated values for this object to this set of Objects. + * If there is only one value, it is assumed to be the end value of an animation, + * and an initial value will be derived, if possible, by calling a getter function + * on the object. Also, if any value is null, the value will be filled in when the animation + * starts in the same way. This mechanism of automatically getting null values only works + * if the PropertyValuesHolder object is used in conjunction + * {@link ObjectAnimator}, and with a getter function + * derived automatically from propertyName, since otherwise PropertyValuesHolder has + * no way of determining what the value should be. + * + * @param values One or more values that the animation will animate between. + */ + public void setObjectValues(Object... values) { + mValueType = values[0].getClass(); + mKeyframeSet = KeyframeSet.ofObject(values); + } + + /** + * Determine the setter or getter function using the JavaBeans convention of setFoo or + * getFoo for a property named 'foo'. This function figures out what the name of the + * function should be and uses reflection to find the Method with that name on the + * target object. + * + * @param targetClass The class to search for the method + * @param prefix "set" or "get", depending on whether we need a setter or getter. + * @param valueType The type of the parameter (in the case of a setter). This type + * is derived from the values set on this PropertyValuesHolder. This type is used as + * a first guess at the parameter type, but we check for methods with several different + * types to avoid problems with slight mis-matches between supplied values and actual + * value types used on the setter. + * @return Method the method associated with mPropertyName. + */ + private Method getPropertyFunction(Class targetClass, String prefix, Class valueType) { + // TODO: faster implementation... + Method returnVal = null; + String methodName = getMethodName(prefix, mPropertyName); + Class args[] = null; + if (valueType == null) { + try { + returnVal = targetClass.getMethod(methodName, args); + } catch (NoSuchMethodException e) { + Log.e("PropertyValuesHolder", targetClass.getSimpleName() + " - " + + "Couldn't find no-arg method for property " + mPropertyName + ": " + e); + } + } else { + args = new Class[1]; + Class typeVariants[]; + if (mValueType.equals(Float.class)) { + typeVariants = FLOAT_VARIANTS; + } else if (mValueType.equals(Integer.class)) { + typeVariants = INTEGER_VARIANTS; + } else if (mValueType.equals(Double.class)) { + typeVariants = DOUBLE_VARIANTS; + } else { + typeVariants = new Class[1]; + typeVariants[0] = mValueType; + } + for (Class typeVariant : typeVariants) { + args[0] = typeVariant; + try { + returnVal = targetClass.getMethod(methodName, args); + // change the value type to suit + mValueType = typeVariant; + return returnVal; + } catch (NoSuchMethodException e) { + // Swallow the error and keep trying other variants + } + } + // If we got here, then no appropriate function was found + Log.e("PropertyValuesHolder", + "Couldn't find " + prefix + "ter property " + mPropertyName + + " for " + targetClass.getSimpleName() + + " with value type "+ mValueType); + } + + return returnVal; + } + + + /** + * Returns the setter or getter requested. This utility function checks whether the + * requested method exists in the propertyMapMap cache. If not, it calls another + * utility function to request the Method from the targetClass directly. + * @param targetClass The Class on which the requested method should exist. + * @param propertyMapMap The cache of setters/getters derived so far. + * @param prefix "set" or "get", for the setter or getter. + * @param valueType The type of parameter passed into the method (null for getter). + * @return Method the method associated with mPropertyName. + */ + private Method setupSetterOrGetter(Class targetClass, + HashMap> propertyMapMap, + String prefix, Class valueType) { + Method setterOrGetter = null; + try { + // Have to lock property map prior to reading it, to guard against + // another thread putting something in there after we've checked it + // but before we've added an entry to it + mPropertyMapLock.writeLock().lock(); + HashMap propertyMap = propertyMapMap.get(targetClass); + if (propertyMap != null) { + setterOrGetter = propertyMap.get(mPropertyName); + } + if (setterOrGetter == null) { + setterOrGetter = getPropertyFunction(targetClass, prefix, valueType); + if (propertyMap == null) { + propertyMap = new HashMap(); + propertyMapMap.put(targetClass, propertyMap); + } + propertyMap.put(mPropertyName, setterOrGetter); + } + } finally { + mPropertyMapLock.writeLock().unlock(); + } + return setterOrGetter; + } + + /** + * Utility function to get the setter from targetClass + * @param targetClass The Class on which the requested method should exist. + */ + void setupSetter(Class targetClass) { + mSetter = setupSetterOrGetter(targetClass, sSetterPropertyMap, "set", mValueType); + } + + /** + * Utility function to get the getter from targetClass + */ + private void setupGetter(Class targetClass) { + mGetter = setupSetterOrGetter(targetClass, sGetterPropertyMap, "get", null); + } + + /** + * Internal function (called from ObjectAnimator) to set up the setter and getter + * prior to running the animation. If the setter has not been manually set for this + * object, it will be derived automatically given the property name, target object, and + * types of values supplied. If no getter has been set, it will be supplied iff any of the + * supplied values was null. If there is a null value, then the getter (supplied or derived) + * will be called to set those null values to the current value of the property + * on the target object. + * @param target The object on which the setter (and possibly getter) exist. + */ + void setupSetterAndGetter(Object target) { + //if (mProperty != null) { + // // check to make sure that mProperty is on the class of target + // try { + // Object testValue = mProperty.get(target); + // for (Keyframe kf : mKeyframeSet.mKeyframes) { + // if (!kf.hasValue()) { + // kf.setValue(mProperty.get(target)); + // } + // } + // return; + // } catch (ClassCastException e) { + // Log.e("PropertyValuesHolder","No such property (" + mProperty.getName() + + // ") on target object " + target + ". Trying reflection instead"); + // mProperty = null; + // } + //} + Class targetClass = target.getClass(); + if (mSetter == null) { + setupSetter(targetClass); + } + for (Keyframe kf : mKeyframeSet.mKeyframes) { + if (!kf.hasValue()) { + if (mGetter == null) { + setupGetter(targetClass); + } + try { + kf.setValue(mGetter.invoke(target)); + } catch (InvocationTargetException e) { + Log.e("PropertyValuesHolder", e.toString()); + } catch (IllegalAccessException e) { + Log.e("PropertyValuesHolder", e.toString()); + } + } + } + } + + /** + * Utility function to set the value stored in a particular Keyframe. The value used is + * whatever the value is for the property name specified in the keyframe on the target object. + * + * @param target The target object from which the current value should be extracted. + * @param kf The keyframe which holds the property name and value. + */ + private void setupValue(Object target, Keyframe kf) { + //if (mProperty != null) { + // kf.setValue(mProperty.get(target)); + //} + try { + if (mGetter == null) { + Class targetClass = target.getClass(); + setupGetter(targetClass); + } + kf.setValue(mGetter.invoke(target)); + } catch (InvocationTargetException e) { + Log.e("PropertyValuesHolder", e.toString()); + } catch (IllegalAccessException e) { + Log.e("PropertyValuesHolder", e.toString()); + } + } + + /** + * This function is called by ObjectAnimator when setting the start values for an animation. + * The start values are set according to the current values in the target object. The + * property whose value is extracted is whatever is specified by the propertyName of this + * PropertyValuesHolder object. + * + * @param target The object which holds the start values that should be set. + */ + void setupStartValue(Object target) { + setupValue(target, mKeyframeSet.mKeyframes.get(0)); + } + + /** + * This function is called by ObjectAnimator when setting the end values for an animation. + * The end values are set according to the current values in the target object. The + * property whose value is extracted is whatever is specified by the propertyName of this + * PropertyValuesHolder object. + * + * @param target The object which holds the start values that should be set. + */ + void setupEndValue(Object target) { + setupValue(target, mKeyframeSet.mKeyframes.get(mKeyframeSet.mKeyframes.size() - 1)); + } + + @Override + public PropertyValuesHolder clone() { + try { + PropertyValuesHolder newPVH = (PropertyValuesHolder) super.clone(); + newPVH.mPropertyName = mPropertyName; + //newPVH.mProperty = mProperty; + newPVH.mKeyframeSet = mKeyframeSet.clone(); + newPVH.mEvaluator = mEvaluator; + return newPVH; + } catch (CloneNotSupportedException e) { + // won't reach here + return null; + } + } + + /** + * Internal function to set the value on the target object, using the setter set up + * earlier on this PropertyValuesHolder object. This function is called by ObjectAnimator + * to handle turning the value calculated by ValueAnimator into a value set on the object + * according to the name of the property. + * @param target The target object on which the value is set + */ + void setAnimatedValue(Object target) { + //if (mProperty != null) { + // mProperty.set(target, getAnimatedValue()); + //} + if (mSetter != null) { + try { + mTmpValueArray[0] = getAnimatedValue(); + mSetter.invoke(target, mTmpValueArray); + } catch (InvocationTargetException e) { + Log.e("PropertyValuesHolder", e.toString()); + } catch (IllegalAccessException e) { + Log.e("PropertyValuesHolder", e.toString()); + } + } + } + + /** + * Internal function, called by ValueAnimator, to set up the TypeEvaluator that will be used + * to calculate animated values. + */ + void init() { + if (mEvaluator == null) { + // We already handle int and float automatically, but not their Object + // equivalents + mEvaluator = (mValueType == Integer.class) ? sIntEvaluator : + (mValueType == Float.class) ? sFloatEvaluator : + null; + } + if (mEvaluator != null) { + // KeyframeSet knows how to evaluate the common types - only give it a custom + // evaluator if one has been set on this class + mKeyframeSet.setEvaluator(mEvaluator); + } + } + + /** + * The TypeEvaluator will the automatically determined based on the type of values + * supplied to PropertyValuesHolder. The evaluator can be manually set, however, if so + * desired. This may be important in cases where either the type of the values supplied + * do not match the way that they should be interpolated between, or if the values + * are of a custom type or one not currently understood by the animation system. Currently, + * only values of type float and int (and their Object equivalents: Float + * and Integer) are correctly interpolated; all other types require setting a TypeEvaluator. + * @param evaluator + */ + public void setEvaluator(TypeEvaluator evaluator) { + mEvaluator = evaluator; + mKeyframeSet.setEvaluator(evaluator); + } + + /** + * Function used to calculate the value according to the evaluator set up for + * this PropertyValuesHolder object. This function is called by ValueAnimator.animateValue(). + * + * @param fraction The elapsed, interpolated fraction of the animation. + */ + void calculateValue(float fraction) { + mAnimatedValue = mKeyframeSet.getValue(fraction); + } + + /** + * Sets the name of the property that will be animated. This name is used to derive + * a setter function that will be called to set animated values. + * For example, a property name of foo will result + * in a call to the function setFoo() on the target object. If either + * valueFrom or valueTo is null, then a getter function will + * also be derived and called. + * + *

Note that the setter function derived from this property name + * must take the same parameter type as the + * valueFrom and valueTo properties, otherwise the call to + * the setter function will fail.

+ * + * @param propertyName The name of the property being animated. + */ + public void setPropertyName(String propertyName) { + mPropertyName = propertyName; + } + + /** + * Sets the property that will be animated. + * + *

Note that if this PropertyValuesHolder object is used with ObjectAnimator, the property + * must exist on the target object specified in that ObjectAnimator.

+ * + * @param property The property being animated. + */ + //public void setProperty(Property property) { + // mProperty = property; + //} + + /** + * Gets the name of the property that will be animated. This name will be used to derive + * a setter function that will be called to set animated values. + * For example, a property name of foo will result + * in a call to the function setFoo() on the target object. If either + * valueFrom or valueTo is null, then a getter function will + * also be derived and called. + */ + public String getPropertyName() { + return mPropertyName; + } + + /** + * Internal function, called by ValueAnimator and ObjectAnimator, to retrieve the value + * most recently calculated in calculateValue(). + * @return + */ + Object getAnimatedValue() { + return mAnimatedValue; + } + + @Override + public String toString() { + return mPropertyName + ": " + mKeyframeSet.toString(); + } + + /** + * Utility method to derive a setter/getter method name from a property name, where the + * prefix is typically "set" or "get" and the first letter of the property name is + * capitalized. + * + * @param prefix The precursor to the method name, before the property name begins, typically + * "set" or "get". + * @param propertyName The name of the property that represents the bulk of the method name + * after the prefix. The first letter of this word will be capitalized in the resulting + * method name. + * @return String the property name converted to a method name according to the conventions + * specified above. + */ + static String getMethodName(String prefix, String propertyName) { + if (propertyName == null || propertyName.length() == 0) { + // shouldn't get here + return prefix; + } + char firstLetter = Character.toUpperCase(propertyName.charAt(0)); + String theRest = propertyName.substring(1); + return prefix + firstLetter + theRest; + } + + static class IntPropertyValuesHolder extends PropertyValuesHolder { + + // Cache JNI functions to avoid looking them up twice + //private static final HashMap> sJNISetterPropertyMap = + // new HashMap>(); + //int mJniSetter; + //private IntProperty mIntProperty; + + IntKeyframeSet mIntKeyframeSet; + int mIntAnimatedValue; + + public IntPropertyValuesHolder(String propertyName, IntKeyframeSet keyframeSet) { + super(propertyName); + mValueType = int.class; + mKeyframeSet = keyframeSet; + mIntKeyframeSet = (IntKeyframeSet) mKeyframeSet; + } + + //public IntPropertyValuesHolder(Property property, IntKeyframeSet keyframeSet) { + // super(property); + // mValueType = int.class; + // mKeyframeSet = keyframeSet; + // mIntKeyframeSet = (IntKeyframeSet) mKeyframeSet; + // if (property instanceof IntProperty) { + // mIntProperty = (IntProperty) mProperty; + // } + //} + + public IntPropertyValuesHolder(String propertyName, int... values) { + super(propertyName); + setIntValues(values); + } + + //public IntPropertyValuesHolder(Property property, int... values) { + // super(property); + // setIntValues(values); + // if (property instanceof IntProperty) { + // mIntProperty = (IntProperty) mProperty; + // } + //} + + @Override + public void setIntValues(int... values) { + super.setIntValues(values); + mIntKeyframeSet = (IntKeyframeSet) mKeyframeSet; + } + + @Override + void calculateValue(float fraction) { + mIntAnimatedValue = mIntKeyframeSet.getIntValue(fraction); + } + + @Override + Object getAnimatedValue() { + return mIntAnimatedValue; + } + + @Override + public IntPropertyValuesHolder clone() { + IntPropertyValuesHolder newPVH = (IntPropertyValuesHolder) super.clone(); + newPVH.mIntKeyframeSet = (IntKeyframeSet) newPVH.mKeyframeSet; + return newPVH; + } + + /** + * Internal function to set the value on the target object, using the setter set up + * earlier on this PropertyValuesHolder object. This function is called by ObjectAnimator + * to handle turning the value calculated by ValueAnimator into a value set on the object + * according to the name of the property. + * @param target The target object on which the value is set + */ + @Override + void setAnimatedValue(Object target) { + //if (mIntProperty != null) { + // mIntProperty.setValue(target, mIntAnimatedValue); + // return; + //} + //if (mProperty != null) { + // mProperty.set(target, mIntAnimatedValue); + // return; + //} + //if (mJniSetter != 0) { + // nCallIntMethod(target, mJniSetter, mIntAnimatedValue); + // return; + //} + if (mSetter != null) { + try { + mTmpValueArray[0] = mIntAnimatedValue; + mSetter.invoke(target, mTmpValueArray); + } catch (InvocationTargetException e) { + Log.e("PropertyValuesHolder", e.toString()); + } catch (IllegalAccessException e) { + Log.e("PropertyValuesHolder", e.toString()); + } + } + } + + @Override + void setupSetter(Class targetClass) { + //if (mProperty != null) { + // return; + //} + // Check new static hashmap for setter method + //try { + // mPropertyMapLock.writeLock().lock(); + // HashMap propertyMap = sJNISetterPropertyMap.get(targetClass); + // if (propertyMap != null) { + // Integer mJniSetterInteger = propertyMap.get(mPropertyName); + // if (mJniSetterInteger != null) { + // mJniSetter = mJniSetterInteger; + // } + // } + // if (mJniSetter == 0) { + // String methodName = getMethodName("set", mPropertyName); + // mJniSetter = nGetIntMethod(targetClass, methodName); + // if (mJniSetter != 0) { + // if (propertyMap == null) { + // propertyMap = new HashMap(); + // sJNISetterPropertyMap.put(targetClass, propertyMap); + // } + // propertyMap.put(mPropertyName, mJniSetter); + // } + // } + //} catch (NoSuchMethodError e) { + // Log.d("PropertyValuesHolder", + // "Can't find native method using JNI, use reflection" + e); + //} finally { + // mPropertyMapLock.writeLock().unlock(); + //} + //if (mJniSetter == 0) { + // Couldn't find method through fast JNI approach - just use reflection + super.setupSetter(targetClass); + //} + } + } + + static class FloatPropertyValuesHolder extends PropertyValuesHolder { + + // Cache JNI functions to avoid looking them up twice + //private static final HashMap> sJNISetterPropertyMap = + // new HashMap>(); + //int mJniSetter; + //private FloatProperty mFloatProperty; + + FloatKeyframeSet mFloatKeyframeSet; + float mFloatAnimatedValue; + + public FloatPropertyValuesHolder(String propertyName, FloatKeyframeSet keyframeSet) { + super(propertyName); + mValueType = float.class; + mKeyframeSet = keyframeSet; + mFloatKeyframeSet = (FloatKeyframeSet) mKeyframeSet; + } + + //public FloatPropertyValuesHolder(Property property, FloatKeyframeSet keyframeSet) { + // super(property); + // mValueType = float.class; + // mKeyframeSet = keyframeSet; + // mFloatKeyframeSet = (FloatKeyframeSet) mKeyframeSet; + // if (property instanceof FloatProperty) { + // mFloatProperty = (FloatProperty) mProperty; + // } + //} + + public FloatPropertyValuesHolder(String propertyName, float... values) { + super(propertyName); + setFloatValues(values); + } + + //public FloatPropertyValuesHolder(Property property, float... values) { + // super(property); + // setFloatValues(values); + // if (property instanceof FloatProperty) { + // mFloatProperty = (FloatProperty) mProperty; + // } + //} + + @Override + public void setFloatValues(float... values) { + super.setFloatValues(values); + mFloatKeyframeSet = (FloatKeyframeSet) mKeyframeSet; + } + + @Override + void calculateValue(float fraction) { + mFloatAnimatedValue = mFloatKeyframeSet.getFloatValue(fraction); + } + + @Override + Object getAnimatedValue() { + return mFloatAnimatedValue; + } + + @Override + public FloatPropertyValuesHolder clone() { + FloatPropertyValuesHolder newPVH = (FloatPropertyValuesHolder) super.clone(); + newPVH.mFloatKeyframeSet = (FloatKeyframeSet) newPVH.mKeyframeSet; + return newPVH; + } + + /** + * Internal function to set the value on the target object, using the setter set up + * earlier on this PropertyValuesHolder object. This function is called by ObjectAnimator + * to handle turning the value calculated by ValueAnimator into a value set on the object + * according to the name of the property. + * @param target The target object on which the value is set + */ + @Override + void setAnimatedValue(Object target) { + //if (mFloatProperty != null) { + // mFloatProperty.setValue(target, mFloatAnimatedValue); + // return; + //} + //if (mProperty != null) { + // mProperty.set(target, mFloatAnimatedValue); + // return; + //} + //if (mJniSetter != 0) { + // nCallFloatMethod(target, mJniSetter, mFloatAnimatedValue); + // return; + //} + if (mSetter != null) { + try { + mTmpValueArray[0] = mFloatAnimatedValue; + mSetter.invoke(target, mTmpValueArray); + } catch (InvocationTargetException e) { + Log.e("PropertyValuesHolder", e.toString()); + } catch (IllegalAccessException e) { + Log.e("PropertyValuesHolder", e.toString()); + } + } + } + + @Override + void setupSetter(Class targetClass) { + //if (mProperty != null) { + // return; + //} + // Check new static hashmap for setter method + //try { + // mPropertyMapLock.writeLock().lock(); + // HashMap propertyMap = sJNISetterPropertyMap.get(targetClass); + // if (propertyMap != null) { + // Integer mJniSetterInteger = propertyMap.get(mPropertyName); + // if (mJniSetterInteger != null) { + // mJniSetter = mJniSetterInteger; + // } + // } + // if (mJniSetter == 0) { + // String methodName = getMethodName("set", mPropertyName); + // mJniSetter = nGetFloatMethod(targetClass, methodName); + // if (mJniSetter != 0) { + // if (propertyMap == null) { + // propertyMap = new HashMap(); + // sJNISetterPropertyMap.put(targetClass, propertyMap); + // } + // propertyMap.put(mPropertyName, mJniSetter); + // } + // } + //} catch (NoSuchMethodError e) { + // Log.d("PropertyValuesHolder", + // "Can't find native method using JNI, use reflection" + e); + //} finally { + // mPropertyMapLock.writeLock().unlock(); + //} + //if (mJniSetter == 0) { + // Couldn't find method through fast JNI approach - just use reflection + super.setupSetter(targetClass); + //} + } + + } + + //native static private int nGetIntMethod(Class targetClass, String methodName); + //native static private int nGetFloatMethod(Class targetClass, String methodName); + //native static private void nCallIntMethod(Object target, int methodID, int arg); + //native static private void nCallFloatMethod(Object target, int methodID, float arg); +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/TypeEvaluator.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/TypeEvaluator.java new file mode 100644 index 000000000..0ea319244 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/TypeEvaluator.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; + +/** + * Interface for use with the {@link ValueAnimator#setEvaluator(TypeEvaluator)} function. Evaluators + * allow developers to create animations on arbitrary property types, by allowing them to supply + * custom evaulators for types that are not automatically understood and used by the animation + * system. + * + * @see ValueAnimator#setEvaluator(TypeEvaluator) + */ +public interface TypeEvaluator { + + /** + * This function returns the result of linearly interpolating the start and end values, with + * fraction representing the proportion between the start and end values. The + * calculation is a simple parametric calculation: result = x0 + t * (v1 - v0), + * where x0 is startValue, x1 is endValue, + * and t is fraction. + * + * @param fraction The fraction from the starting to the ending values + * @param startValue The start value. + * @param endValue The end value. + * @return A linear interpolation between the start and end values, given the + * fraction parameter. + */ + public T evaluate(float fraction, T startValue, T endValue); + +} \ No newline at end of file diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java new file mode 100644 index 000000000..d8a12c688 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java @@ -0,0 +1,1265 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; + +import android.os.Handler; +import android.os.Looper; +import android.os.Message; +import android.util.AndroidRuntimeException; +import android.view.animation.AccelerateDecelerateInterpolator; +import android.view.animation.AnimationUtils; +import android.view.animation.Interpolator; +import android.view.animation.LinearInterpolator; + +import java.util.ArrayList; +import java.util.HashMap; + +/** + * This class provides a simple timing engine for running animations + * which calculate animated values and set them on target objects. + * + *

There is a single timing pulse that all animations use. It runs in a + * custom handler to ensure that property changes happen on the UI thread.

+ * + *

By default, ValueAnimator uses non-linear time interpolation, via the + * {@link AccelerateDecelerateInterpolator} class, which accelerates into and decelerates + * out of an animation. This behavior can be changed by calling + * {@link ValueAnimator#setInterpolator(TimeInterpolator)}.

+ */ +@SuppressWarnings({"rawtypes", "unchecked"}) +public class ValueAnimator extends Animator { + + /** + * Internal constants + */ + + /* + * The default amount of time in ms between animation frames + */ + private static final long DEFAULT_FRAME_DELAY = 10; + + /** + * Messages sent to timing handler: START is sent when an animation first begins, FRAME is sent + * by the handler to itself to process the next animation frame + */ + static final int ANIMATION_START = 0; + static final int ANIMATION_FRAME = 1; + + /** + * Values used with internal variable mPlayingState to indicate the current state of an + * animation. + */ + static final int STOPPED = 0; // Not yet playing + static final int RUNNING = 1; // Playing normally + static final int SEEKED = 2; // Seeked to some time value + + /** + * Internal variables + * NOTE: This object implements the clone() method, making a deep copy of any referenced + * objects. As other non-trivial fields are added to this class, make sure to add logic + * to clone() to make deep copies of them. + */ + + // The first time that the animation's animateFrame() method is called. This time is used to + // determine elapsed time (and therefore the elapsed fraction) in subsequent calls + // to animateFrame() + long mStartTime; + + /** + * Set when setCurrentPlayTime() is called. If negative, animation is not currently seeked + * to a value. + */ + long mSeekTime = -1; + + // TODO: We access the following ThreadLocal variables often, some of them on every update. + // If ThreadLocal access is significantly expensive, we may want to put all of these + // fields into a structure sot hat we just access ThreadLocal once to get the reference + // to that structure, then access the structure directly for each field. + + // The static sAnimationHandler processes the internal timing loop on which all animations + // are based + private static ThreadLocal sAnimationHandler = + new ThreadLocal(); + + // The per-thread list of all active animations + private static final ThreadLocal> sAnimations = + new ThreadLocal>() { + @Override + protected ArrayList initialValue() { + return new ArrayList(); + } + }; + + // The per-thread set of animations to be started on the next animation frame + private static final ThreadLocal> sPendingAnimations = + new ThreadLocal>() { + @Override + protected ArrayList initialValue() { + return new ArrayList(); + } + }; + + /** + * Internal per-thread collections used to avoid set collisions as animations start and end + * while being processed. + */ + private static final ThreadLocal> sDelayedAnims = + new ThreadLocal>() { + @Override + protected ArrayList initialValue() { + return new ArrayList(); + } + }; + + private static final ThreadLocal> sEndingAnims = + new ThreadLocal>() { + @Override + protected ArrayList initialValue() { + return new ArrayList(); + } + }; + + private static final ThreadLocal> sReadyAnims = + new ThreadLocal>() { + @Override + protected ArrayList initialValue() { + return new ArrayList(); + } + }; + + // The time interpolator to be used if none is set on the animation + private static final /*Time*/Interpolator sDefaultInterpolator = + new AccelerateDecelerateInterpolator(); + + // type evaluators for the primitive types handled by this implementation + //private static final TypeEvaluator sIntEvaluator = new IntEvaluator(); + //private static final TypeEvaluator sFloatEvaluator = new FloatEvaluator(); + + /** + * Used to indicate whether the animation is currently playing in reverse. This causes the + * elapsed fraction to be inverted to calculate the appropriate values. + */ + private boolean mPlayingBackwards = false; + + /** + * This variable tracks the current iteration that is playing. When mCurrentIteration exceeds the + * repeatCount (if repeatCount!=INFINITE), the animation ends + */ + private int mCurrentIteration = 0; + + /** + * Tracks current elapsed/eased fraction, for querying in getAnimatedFraction(). + */ + private float mCurrentFraction = 0f; + + /** + * Tracks whether a startDelay'd animation has begun playing through the startDelay. + */ + private boolean mStartedDelay = false; + + /** + * Tracks the time at which the animation began playing through its startDelay. This is + * different from the mStartTime variable, which is used to track when the animation became + * active (which is when the startDelay expired and the animation was added to the active + * animations list). + */ + private long mDelayStartTime; + + /** + * Flag that represents the current state of the animation. Used to figure out when to start + * an animation (if state == STOPPED). Also used to end an animation that + * has been cancel()'d or end()'d since the last animation frame. Possible values are + * STOPPED, RUNNING, SEEKED. + */ + int mPlayingState = STOPPED; + + /** + * Additional playing state to indicate whether an animator has been start()'d. There is + * some lag between a call to start() and the first animation frame. We should still note + * that the animation has been started, even if it's first animation frame has not yet + * happened, and reflect that state in isRunning(). + * Note that delayed animations are different: they are not started until their first + * animation frame, which occurs after their delay elapses. + */ + private boolean mRunning = false; + + /** + * Additional playing state to indicate whether an animator has been start()'d, whether or + * not there is a nonzero startDelay. + */ + private boolean mStarted = false; + + /** + * Flag that denotes whether the animation is set up and ready to go. Used to + * set up animation that has not yet been started. + */ + boolean mInitialized = false; + + // + // Backing variables + // + + // How long the animation should last in ms + private long mDuration = 300; + + // The amount of time in ms to delay starting the animation after start() is called + private long mStartDelay = 0; + + // The number of milliseconds between animation frames + private static long sFrameDelay = DEFAULT_FRAME_DELAY; + + // The number of times the animation will repeat. The default is 0, which means the animation + // will play only once + private int mRepeatCount = 0; + + /** + * The type of repetition that will occur when repeatMode is nonzero. RESTART means the + * animation will start from the beginning on every new cycle. REVERSE means the animation + * will reverse directions on each iteration. + */ + private int mRepeatMode = RESTART; + + /** + * The time interpolator to be used. The elapsed fraction of the animation will be passed + * through this interpolator to calculate the interpolated fraction, which is then used to + * calculate the animated values. + */ + private /*Time*/Interpolator mInterpolator = sDefaultInterpolator; + + /** + * The set of listeners to be sent events through the life of an animation. + */ + private ArrayList mUpdateListeners = null; + + /** + * The property/value sets being animated. + */ + PropertyValuesHolder[] mValues; + + /** + * A hashmap of the PropertyValuesHolder objects. This map is used to lookup animated values + * by property name during calls to getAnimatedValue(String). + */ + HashMap mValuesMap; + + /** + * Public constants + */ + + /** + * When the animation reaches the end and repeatCount is INFINITE + * or a positive value, the animation restarts from the beginning. + */ + public static final int RESTART = 1; + /** + * When the animation reaches the end and repeatCount is INFINITE + * or a positive value, the animation reverses direction on every iteration. + */ + public static final int REVERSE = 2; + /** + * This value used used with the {@link #setRepeatCount(int)} property to repeat + * the animation indefinitely. + */ + public static final int INFINITE = -1; + + /** + * Creates a new ValueAnimator object. This default constructor is primarily for + * use internally; the factory methods which take parameters are more generally + * useful. + */ + public ValueAnimator() { + } + + /** + * Constructs and returns a ValueAnimator that animates between int values. A single + * value implies that that value is the one being animated to. However, this is not typically + * useful in a ValueAnimator object because there is no way for the object to determine the + * starting value for the animation (unlike ObjectAnimator, which can derive that value + * from the target object and property being animated). Therefore, there should typically + * be two or more values. + * + * @param values A set of values that the animation will animate between over time. + * @return A ValueAnimator object that is set up to animate between the given values. + */ + public static ValueAnimator ofInt(int... values) { + ValueAnimator anim = new ValueAnimator(); + anim.setIntValues(values); + return anim; + } + + /** + * Constructs and returns a ValueAnimator that animates between float values. A single + * value implies that that value is the one being animated to. However, this is not typically + * useful in a ValueAnimator object because there is no way for the object to determine the + * starting value for the animation (unlike ObjectAnimator, which can derive that value + * from the target object and property being animated). Therefore, there should typically + * be two or more values. + * + * @param values A set of values that the animation will animate between over time. + * @return A ValueAnimator object that is set up to animate between the given values. + */ + public static ValueAnimator ofFloat(float... values) { + ValueAnimator anim = new ValueAnimator(); + anim.setFloatValues(values); + return anim; + } + + /** + * Constructs and returns a ValueAnimator that animates between the values + * specified in the PropertyValuesHolder objects. + * + * @param values A set of PropertyValuesHolder objects whose values will be animated + * between over time. + * @return A ValueAnimator object that is set up to animate between the given values. + */ + public static ValueAnimator ofPropertyValuesHolder(PropertyValuesHolder... values) { + ValueAnimator anim = new ValueAnimator(); + anim.setValues(values); + return anim; + } + /** + * Constructs and returns a ValueAnimator that animates between Object values. A single + * value implies that that value is the one being animated to. However, this is not typically + * useful in a ValueAnimator object because there is no way for the object to determine the + * starting value for the animation (unlike ObjectAnimator, which can derive that value + * from the target object and property being animated). Therefore, there should typically + * be two or more values. + * + *

Since ValueAnimator does not know how to animate between arbitrary Objects, this + * factory method also takes a TypeEvaluator object that the ValueAnimator will use + * to perform that interpolation. + * + * @param evaluator A TypeEvaluator that will be called on each animation frame to + * provide the ncessry interpolation between the Object values to derive the animated + * value. + * @param values A set of values that the animation will animate between over time. + * @return A ValueAnimator object that is set up to animate between the given values. + */ + public static ValueAnimator ofObject(TypeEvaluator evaluator, Object... values) { + ValueAnimator anim = new ValueAnimator(); + anim.setObjectValues(values); + anim.setEvaluator(evaluator); + return anim; + } + + /** + * Sets int values that will be animated between. A single + * value implies that that value is the one being animated to. However, this is not typically + * useful in a ValueAnimator object because there is no way for the object to determine the + * starting value for the animation (unlike ObjectAnimator, which can derive that value + * from the target object and property being animated). Therefore, there should typically + * be two or more values. + * + *

If there are already multiple sets of values defined for this ValueAnimator via more + * than one PropertyValuesHolder object, this method will set the values for the first + * of those objects.

+ * + * @param values A set of values that the animation will animate between over time. + */ + public void setIntValues(int... values) { + if (values == null || values.length == 0) { + return; + } + if (mValues == null || mValues.length == 0) { + setValues(new PropertyValuesHolder[]{PropertyValuesHolder.ofInt("", values)}); + } else { + PropertyValuesHolder valuesHolder = mValues[0]; + valuesHolder.setIntValues(values); + } + // New property/values/target should cause re-initialization prior to starting + mInitialized = false; + } + + /** + * Sets float values that will be animated between. A single + * value implies that that value is the one being animated to. However, this is not typically + * useful in a ValueAnimator object because there is no way for the object to determine the + * starting value for the animation (unlike ObjectAnimator, which can derive that value + * from the target object and property being animated). Therefore, there should typically + * be two or more values. + * + *

If there are already multiple sets of values defined for this ValueAnimator via more + * than one PropertyValuesHolder object, this method will set the values for the first + * of those objects.

+ * + * @param values A set of values that the animation will animate between over time. + */ + public void setFloatValues(float... values) { + if (values == null || values.length == 0) { + return; + } + if (mValues == null || mValues.length == 0) { + setValues(new PropertyValuesHolder[]{PropertyValuesHolder.ofFloat("", values)}); + } else { + PropertyValuesHolder valuesHolder = mValues[0]; + valuesHolder.setFloatValues(values); + } + // New property/values/target should cause re-initialization prior to starting + mInitialized = false; + } + + /** + * Sets the values to animate between for this animation. A single + * value implies that that value is the one being animated to. However, this is not typically + * useful in a ValueAnimator object because there is no way for the object to determine the + * starting value for the animation (unlike ObjectAnimator, which can derive that value + * from the target object and property being animated). Therefore, there should typically + * be two or more values. + * + *

If there are already multiple sets of values defined for this ValueAnimator via more + * than one PropertyValuesHolder object, this method will set the values for the first + * of those objects.

+ * + *

There should be a TypeEvaluator set on the ValueAnimator that knows how to interpolate + * between these value objects. ValueAnimator only knows how to interpolate between the + * primitive types specified in the other setValues() methods.

+ * + * @param values The set of values to animate between. + */ + public void setObjectValues(Object... values) { + if (values == null || values.length == 0) { + return; + } + if (mValues == null || mValues.length == 0) { + setValues(new PropertyValuesHolder[]{PropertyValuesHolder.ofObject("", + (TypeEvaluator)null, values)}); + } else { + PropertyValuesHolder valuesHolder = mValues[0]; + valuesHolder.setObjectValues(values); + } + // New property/values/target should cause re-initialization prior to starting + mInitialized = false; + } + + /** + * Sets the values, per property, being animated between. This function is called internally + * by the constructors of ValueAnimator that take a list of values. But an ValueAnimator can + * be constructed without values and this method can be called to set the values manually + * instead. + * + * @param values The set of values, per property, being animated between. + */ + public void setValues(PropertyValuesHolder... values) { + int numValues = values.length; + mValues = values; + mValuesMap = new HashMap(numValues); + for (int i = 0; i < numValues; ++i) { + PropertyValuesHolder valuesHolder = values[i]; + mValuesMap.put(valuesHolder.getPropertyName(), valuesHolder); + } + // New property/values/target should cause re-initialization prior to starting + mInitialized = false; + } + + /** + * Returns the values that this ValueAnimator animates between. These values are stored in + * PropertyValuesHolder objects, even if the ValueAnimator was created with a simple list + * of value objects instead. + * + * @return PropertyValuesHolder[] An array of PropertyValuesHolder objects which hold the + * values, per property, that define the animation. + */ + public PropertyValuesHolder[] getValues() { + return mValues; + } + + /** + * This function is called immediately before processing the first animation + * frame of an animation. If there is a nonzero startDelay, the + * function is called after that delay ends. + * It takes care of the final initialization steps for the + * animation. + * + *

Overrides of this method should call the superclass method to ensure + * that internal mechanisms for the animation are set up correctly.

+ */ + void initAnimation() { + if (!mInitialized) { + int numValues = mValues.length; + for (int i = 0; i < numValues; ++i) { + mValues[i].init(); + } + mInitialized = true; + } + } + + + /** + * Sets the length of the animation. The default duration is 300 milliseconds. + * + * @param duration The length of the animation, in milliseconds. This value cannot + * be negative. + * @return ValueAnimator The object called with setDuration(). This return + * value makes it easier to compose statements together that construct and then set the + * duration, as in ValueAnimator.ofInt(0, 10).setDuration(500).start(). + */ + public ValueAnimator setDuration(long duration) { + if (duration < 0) { + throw new IllegalArgumentException("Animators cannot have negative duration: " + + duration); + } + mDuration = duration; + return this; + } + + /** + * Gets the length of the animation. The default duration is 300 milliseconds. + * + * @return The length of the animation, in milliseconds. + */ + public long getDuration() { + return mDuration; + } + + /** + * Sets the position of the animation to the specified point in time. This time should + * be between 0 and the total duration of the animation, including any repetition. If + * the animation has not yet been started, then it will not advance forward after it is + * set to this time; it will simply set the time to this value and perform any appropriate + * actions based on that time. If the animation is already running, then setCurrentPlayTime() + * will set the current playing time to this value and continue playing from that point. + * + * @param playTime The time, in milliseconds, to which the animation is advanced or rewound. + */ + public void setCurrentPlayTime(long playTime) { + initAnimation(); + long currentTime = AnimationUtils.currentAnimationTimeMillis(); + if (mPlayingState != RUNNING) { + mSeekTime = playTime; + mPlayingState = SEEKED; + } + mStartTime = currentTime - playTime; + animationFrame(currentTime); + } + + /** + * Gets the current position of the animation in time, which is equal to the current + * time minus the time that the animation started. An animation that is not yet started will + * return a value of zero. + * + * @return The current position in time of the animation. + */ + public long getCurrentPlayTime() { + if (!mInitialized || mPlayingState == STOPPED) { + return 0; + } + return AnimationUtils.currentAnimationTimeMillis() - mStartTime; + } + + /** + * This custom, static handler handles the timing pulse that is shared by + * all active animations. This approach ensures that the setting of animation + * values will happen on the UI thread and that all animations will share + * the same times for calculating their values, which makes synchronizing + * animations possible. + * + */ + private static class AnimationHandler extends Handler { + /** + * There are only two messages that we care about: ANIMATION_START and + * ANIMATION_FRAME. The START message is sent when an animation's start() + * method is called. It cannot start synchronously when start() is called + * because the call may be on the wrong thread, and it would also not be + * synchronized with other animations because it would not start on a common + * timing pulse. So each animation sends a START message to the handler, which + * causes the handler to place the animation on the active animations queue and + * start processing frames for that animation. + * The FRAME message is the one that is sent over and over while there are any + * active animations to process. + */ + @Override + public void handleMessage(Message msg) { + boolean callAgain = true; + ArrayList animations = sAnimations.get(); + ArrayList delayedAnims = sDelayedAnims.get(); + switch (msg.what) { + // TODO: should we avoid sending frame message when starting if we + // were already running? + case ANIMATION_START: + ArrayList pendingAnimations = sPendingAnimations.get(); + if (animations.size() > 0 || delayedAnims.size() > 0) { + callAgain = false; + } + // pendingAnims holds any animations that have requested to be started + // We're going to clear sPendingAnimations, but starting animation may + // cause more to be added to the pending list (for example, if one animation + // starting triggers another starting). So we loop until sPendingAnimations + // is empty. + while (pendingAnimations.size() > 0) { + ArrayList pendingCopy = + (ArrayList) pendingAnimations.clone(); + pendingAnimations.clear(); + int count = pendingCopy.size(); + for (int i = 0; i < count; ++i) { + ValueAnimator anim = pendingCopy.get(i); + // If the animation has a startDelay, place it on the delayed list + if (anim.mStartDelay == 0) { + anim.startAnimation(); + } else { + delayedAnims.add(anim); + } + } + } + // fall through to process first frame of new animations + case ANIMATION_FRAME: + // currentTime holds the common time for all animations processed + // during this frame + long currentTime = AnimationUtils.currentAnimationTimeMillis(); + ArrayList readyAnims = sReadyAnims.get(); + ArrayList endingAnims = sEndingAnims.get(); + + // First, process animations currently sitting on the delayed queue, adding + // them to the active animations if they are ready + int numDelayedAnims = delayedAnims.size(); + for (int i = 0; i < numDelayedAnims; ++i) { + ValueAnimator anim = delayedAnims.get(i); + if (anim.delayedAnimationFrame(currentTime)) { + readyAnims.add(anim); + } + } + int numReadyAnims = readyAnims.size(); + if (numReadyAnims > 0) { + for (int i = 0; i < numReadyAnims; ++i) { + ValueAnimator anim = readyAnims.get(i); + anim.startAnimation(); + anim.mRunning = true; + delayedAnims.remove(anim); + } + readyAnims.clear(); + } + + // Now process all active animations. The return value from animationFrame() + // tells the handler whether it should now be ended + int numAnims = animations.size(); + int i = 0; + while (i < numAnims) { + ValueAnimator anim = animations.get(i); + if (anim.animationFrame(currentTime)) { + endingAnims.add(anim); + } + if (animations.size() == numAnims) { + ++i; + } else { + // An animation might be canceled or ended by client code + // during the animation frame. Check to see if this happened by + // seeing whether the current index is the same as it was before + // calling animationFrame(). Another approach would be to copy + // animations to a temporary list and process that list instead, + // but that entails garbage and processing overhead that would + // be nice to avoid. + --numAnims; + endingAnims.remove(anim); + } + } + if (endingAnims.size() > 0) { + for (i = 0; i < endingAnims.size(); ++i) { + endingAnims.get(i).endAnimation(); + } + endingAnims.clear(); + } + + // If there are still active or delayed animations, call the handler again + // after the frameDelay + if (callAgain && (!animations.isEmpty() || !delayedAnims.isEmpty())) { + sendEmptyMessageDelayed(ANIMATION_FRAME, Math.max(0, sFrameDelay - + (AnimationUtils.currentAnimationTimeMillis() - currentTime))); + } + break; + } + } + } + + /** + * The amount of time, in milliseconds, to delay starting the animation after + * {@link #start()} is called. + * + * @return the number of milliseconds to delay running the animation + */ + public long getStartDelay() { + return mStartDelay; + } + + /** + * The amount of time, in milliseconds, to delay starting the animation after + * {@link #start()} is called. + + * @param startDelay The amount of the delay, in milliseconds + */ + public void setStartDelay(long startDelay) { + this.mStartDelay = startDelay; + } + + /** + * The amount of time, in milliseconds, between each frame of the animation. This is a + * requested time that the animation will attempt to honor, but the actual delay between + * frames may be different, depending on system load and capabilities. This is a static + * function because the same delay will be applied to all animations, since they are all + * run off of a single timing loop. + * + * @return the requested time between frames, in milliseconds + */ + public static long getFrameDelay() { + return sFrameDelay; + } + + /** + * The amount of time, in milliseconds, between each frame of the animation. This is a + * requested time that the animation will attempt to honor, but the actual delay between + * frames may be different, depending on system load and capabilities. This is a static + * function because the same delay will be applied to all animations, since they are all + * run off of a single timing loop. + * + * @param frameDelay the requested time between frames, in milliseconds + */ + public static void setFrameDelay(long frameDelay) { + sFrameDelay = frameDelay; + } + + /** + * The most recent value calculated by this ValueAnimator when there is just one + * property being animated. This value is only sensible while the animation is running. The main + * purpose for this read-only property is to retrieve the value from the ValueAnimator + * during a call to {@link AnimatorUpdateListener#onAnimationUpdate(ValueAnimator)}, which + * is called during each animation frame, immediately after the value is calculated. + * + * @return animatedValue The value most recently calculated by this ValueAnimator for + * the single property being animated. If there are several properties being animated + * (specified by several PropertyValuesHolder objects in the constructor), this function + * returns the animated value for the first of those objects. + */ + public Object getAnimatedValue() { + if (mValues != null && mValues.length > 0) { + return mValues[0].getAnimatedValue(); + } + // Shouldn't get here; should always have values unless ValueAnimator was set up wrong + return null; + } + + /** + * The most recent value calculated by this ValueAnimator for propertyName. + * The main purpose for this read-only property is to retrieve the value from the + * ValueAnimator during a call to + * {@link AnimatorUpdateListener#onAnimationUpdate(ValueAnimator)}, which + * is called during each animation frame, immediately after the value is calculated. + * + * @return animatedValue The value most recently calculated for the named property + * by this ValueAnimator. + */ + public Object getAnimatedValue(String propertyName) { + PropertyValuesHolder valuesHolder = mValuesMap.get(propertyName); + if (valuesHolder != null) { + return valuesHolder.getAnimatedValue(); + } else { + // At least avoid crashing if called with bogus propertyName + return null; + } + } + + /** + * Sets how many times the animation should be repeated. If the repeat + * count is 0, the animation is never repeated. If the repeat count is + * greater than 0 or {@link #INFINITE}, the repeat mode will be taken + * into account. The repeat count is 0 by default. + * + * @param value the number of times the animation should be repeated + */ + public void setRepeatCount(int value) { + mRepeatCount = value; + } + /** + * Defines how many times the animation should repeat. The default value + * is 0. + * + * @return the number of times the animation should repeat, or {@link #INFINITE} + */ + public int getRepeatCount() { + return mRepeatCount; + } + + /** + * Defines what this animation should do when it reaches the end. This + * setting is applied only when the repeat count is either greater than + * 0 or {@link #INFINITE}. Defaults to {@link #RESTART}. + * + * @param value {@link #RESTART} or {@link #REVERSE} + */ + public void setRepeatMode(int value) { + mRepeatMode = value; + } + + /** + * Defines what this animation should do when it reaches the end. + * + * @return either one of {@link #REVERSE} or {@link #RESTART} + */ + public int getRepeatMode() { + return mRepeatMode; + } + + /** + * Adds a listener to the set of listeners that are sent update events through the life of + * an animation. This method is called on all listeners for every frame of the animation, + * after the values for the animation have been calculated. + * + * @param listener the listener to be added to the current set of listeners for this animation. + */ + public void addUpdateListener(AnimatorUpdateListener listener) { + if (mUpdateListeners == null) { + mUpdateListeners = new ArrayList(); + } + mUpdateListeners.add(listener); + } + + /** + * Removes all listeners from the set listening to frame updates for this animation. + */ + public void removeAllUpdateListeners() { + if (mUpdateListeners == null) { + return; + } + mUpdateListeners.clear(); + mUpdateListeners = null; + } + + /** + * Removes a listener from the set listening to frame updates for this animation. + * + * @param listener the listener to be removed from the current set of update listeners + * for this animation. + */ + public void removeUpdateListener(AnimatorUpdateListener listener) { + if (mUpdateListeners == null) { + return; + } + mUpdateListeners.remove(listener); + if (mUpdateListeners.size() == 0) { + mUpdateListeners = null; + } + } + + + /** + * The time interpolator used in calculating the elapsed fraction of this animation. The + * interpolator determines whether the animation runs with linear or non-linear motion, + * such as acceleration and deceleration. The default value is + * {@link android.view.animation.AccelerateDecelerateInterpolator} + * + * @param value the interpolator to be used by this animation. A value of null + * will result in linear interpolation. + */ + @Override + public void setInterpolator(/*Time*/Interpolator value) { + if (value != null) { + mInterpolator = value; + } else { + mInterpolator = new LinearInterpolator(); + } + } + + /** + * Returns the timing interpolator that this ValueAnimator uses. + * + * @return The timing interpolator for this ValueAnimator. + */ + public /*Time*/Interpolator getInterpolator() { + return mInterpolator; + } + + /** + * The type evaluator to be used when calculating the animated values of this animation. + * The system will automatically assign a float or int evaluator based on the type + * of startValue and endValue in the constructor. But if these values + * are not one of these primitive types, or if different evaluation is desired (such as is + * necessary with int values that represent colors), a custom evaluator needs to be assigned. + * For example, when running an animation on color values, the {@link ArgbEvaluator} + * should be used to get correct RGB color interpolation. + * + *

If this ValueAnimator has only one set of values being animated between, this evaluator + * will be used for that set. If there are several sets of values being animated, which is + * the case if PropertyValuesHOlder objects were set on the ValueAnimator, then the evaluator + * is assigned just to the first PropertyValuesHolder object.

+ * + * @param value the evaluator to be used this animation + */ + public void setEvaluator(TypeEvaluator value) { + if (value != null && mValues != null && mValues.length > 0) { + mValues[0].setEvaluator(value); + } + } + + /** + * Start the animation playing. This version of start() takes a boolean flag that indicates + * whether the animation should play in reverse. The flag is usually false, but may be set + * to true if called from the reverse() method. + * + *

The animation started by calling this method will be run on the thread that called + * this method. This thread should have a Looper on it (a runtime exception will be thrown if + * this is not the case). Also, if the animation will animate + * properties of objects in the view hierarchy, then the calling thread should be the UI + * thread for that view hierarchy.

+ * + * @param playBackwards Whether the ValueAnimator should start playing in reverse. + */ + private void start(boolean playBackwards) { + if (Looper.myLooper() == null) { + throw new AndroidRuntimeException("Animators may only be run on Looper threads"); + } + mPlayingBackwards = playBackwards; + mCurrentIteration = 0; + mPlayingState = STOPPED; + mStarted = true; + mStartedDelay = false; + sPendingAnimations.get().add(this); + if (mStartDelay == 0) { + // This sets the initial value of the animation, prior to actually starting it running + setCurrentPlayTime(getCurrentPlayTime()); + mPlayingState = STOPPED; + mRunning = true; + + if (mListeners != null) { + ArrayList tmpListeners = + (ArrayList) mListeners.clone(); + int numListeners = tmpListeners.size(); + for (int i = 0; i < numListeners; ++i) { + tmpListeners.get(i).onAnimationStart(this); + } + } + } + AnimationHandler animationHandler = sAnimationHandler.get(); + if (animationHandler == null) { + animationHandler = new AnimationHandler(); + sAnimationHandler.set(animationHandler); + } + animationHandler.sendEmptyMessage(ANIMATION_START); + } + + @Override + public void start() { + start(false); + } + + @Override + public void cancel() { + // Only cancel if the animation is actually running or has been started and is about + // to run + if (mPlayingState != STOPPED || sPendingAnimations.get().contains(this) || + sDelayedAnims.get().contains(this)) { + // Only notify listeners if the animator has actually started + if (mRunning && mListeners != null) { + ArrayList tmpListeners = + (ArrayList) mListeners.clone(); + for (AnimatorListener listener : tmpListeners) { + listener.onAnimationCancel(this); + } + } + endAnimation(); + } + } + + @Override + public void end() { + if (!sAnimations.get().contains(this) && !sPendingAnimations.get().contains(this)) { + // Special case if the animation has not yet started; get it ready for ending + mStartedDelay = false; + startAnimation(); + } else if (!mInitialized) { + initAnimation(); + } + // The final value set on the target varies, depending on whether the animation + // was supposed to repeat an odd number of times + if (mRepeatCount > 0 && (mRepeatCount & 0x01) == 1) { + animateValue(0f); + } else { + animateValue(1f); + } + endAnimation(); + } + + @Override + public boolean isRunning() { + return (mPlayingState == RUNNING || mRunning); + } + + @Override + public boolean isStarted() { + return mStarted; + } + + /** + * Plays the ValueAnimator in reverse. If the animation is already running, + * it will stop itself and play backwards from the point reached when reverse was called. + * If the animation is not currently running, then it will start from the end and + * play backwards. This behavior is only set for the current animation; future playing + * of the animation will use the default behavior of playing forward. + */ + public void reverse() { + mPlayingBackwards = !mPlayingBackwards; + if (mPlayingState == RUNNING) { + long currentTime = AnimationUtils.currentAnimationTimeMillis(); + long currentPlayTime = currentTime - mStartTime; + long timeLeft = mDuration - currentPlayTime; + mStartTime = currentTime - timeLeft; + } else { + start(true); + } + } + + /** + * Called internally to end an animation by removing it from the animations list. Must be + * called on the UI thread. + */ + private void endAnimation() { + sAnimations.get().remove(this); + sPendingAnimations.get().remove(this); + sDelayedAnims.get().remove(this); + mPlayingState = STOPPED; + if (mRunning && mListeners != null) { + ArrayList tmpListeners = + (ArrayList) mListeners.clone(); + int numListeners = tmpListeners.size(); + for (int i = 0; i < numListeners; ++i) { + tmpListeners.get(i).onAnimationEnd(this); + } + } + mRunning = false; + mStarted = false; + } + + /** + * Called internally to start an animation by adding it to the active animations list. Must be + * called on the UI thread. + */ + private void startAnimation() { + initAnimation(); + sAnimations.get().add(this); + if (mStartDelay > 0 && mListeners != null) { + // Listeners were already notified in start() if startDelay is 0; this is + // just for delayed animations + ArrayList tmpListeners = + (ArrayList) mListeners.clone(); + int numListeners = tmpListeners.size(); + for (int i = 0; i < numListeners; ++i) { + tmpListeners.get(i).onAnimationStart(this); + } + } + } + + /** + * Internal function called to process an animation frame on an animation that is currently + * sleeping through its startDelay phase. The return value indicates whether it + * should be woken up and put on the active animations queue. + * + * @param currentTime The current animation time, used to calculate whether the animation + * has exceeded its startDelay and should be started. + * @return True if the animation's startDelay has been exceeded and the animation + * should be added to the set of active animations. + */ + private boolean delayedAnimationFrame(long currentTime) { + if (!mStartedDelay) { + mStartedDelay = true; + mDelayStartTime = currentTime; + } else { + long deltaTime = currentTime - mDelayStartTime; + if (deltaTime > mStartDelay) { + // startDelay ended - start the anim and record the + // mStartTime appropriately + mStartTime = currentTime - (deltaTime - mStartDelay); + mPlayingState = RUNNING; + return true; + } + } + return false; + } + + /** + * This internal function processes a single animation frame for a given animation. The + * currentTime parameter is the timing pulse sent by the handler, used to calculate the + * elapsed duration, and therefore + * the elapsed fraction, of the animation. The return value indicates whether the animation + * should be ended (which happens when the elapsed time of the animation exceeds the + * animation's duration, including the repeatCount). + * + * @param currentTime The current time, as tracked by the static timing handler + * @return true if the animation's duration, including any repetitions due to + * repeatCount has been exceeded and the animation should be ended. + */ + boolean animationFrame(long currentTime) { + boolean done = false; + + if (mPlayingState == STOPPED) { + mPlayingState = RUNNING; + if (mSeekTime < 0) { + mStartTime = currentTime; + } else { + mStartTime = currentTime - mSeekTime; + // Now that we're playing, reset the seek time + mSeekTime = -1; + } + } + switch (mPlayingState) { + case RUNNING: + case SEEKED: + float fraction = mDuration > 0 ? (float)(currentTime - mStartTime) / mDuration : 1f; + if (fraction >= 1f) { + if (mCurrentIteration < mRepeatCount || mRepeatCount == INFINITE) { + // Time to repeat + if (mListeners != null) { + int numListeners = mListeners.size(); + for (int i = 0; i < numListeners; ++i) { + mListeners.get(i).onAnimationRepeat(this); + } + } + if (mRepeatMode == REVERSE) { + mPlayingBackwards = mPlayingBackwards ? false : true; + } + mCurrentIteration += (int)fraction; + fraction = fraction % 1f; + mStartTime += mDuration; + } else { + done = true; + fraction = Math.min(fraction, 1.0f); + } + } + if (mPlayingBackwards) { + fraction = 1f - fraction; + } + animateValue(fraction); + break; + } + + return done; + } + + /** + * Returns the current animation fraction, which is the elapsed/interpolated fraction used in + * the most recent frame update on the animation. + * + * @return Elapsed/interpolated fraction of the animation. + */ + public float getAnimatedFraction() { + return mCurrentFraction; + } + + /** + * This method is called with the elapsed fraction of the animation during every + * animation frame. This function turns the elapsed fraction into an interpolated fraction + * and then into an animated value (from the evaluator. The function is called mostly during + * animation updates, but it is also called when the end() + * function is called, to set the final value on the property. + * + *

Overrides of this method must call the superclass to perform the calculation + * of the animated value.

+ * + * @param fraction The elapsed fraction of the animation. + */ + void animateValue(float fraction) { + fraction = mInterpolator.getInterpolation(fraction); + mCurrentFraction = fraction; + int numValues = mValues.length; + for (int i = 0; i < numValues; ++i) { + mValues[i].calculateValue(fraction); + } + if (mUpdateListeners != null) { + int numListeners = mUpdateListeners.size(); + for (int i = 0; i < numListeners; ++i) { + mUpdateListeners.get(i).onAnimationUpdate(this); + } + } + } + + @Override + public ValueAnimator clone() { + final ValueAnimator anim = (ValueAnimator) super.clone(); + if (mUpdateListeners != null) { + ArrayList oldListeners = mUpdateListeners; + anim.mUpdateListeners = new ArrayList(); + int numListeners = oldListeners.size(); + for (int i = 0; i < numListeners; ++i) { + anim.mUpdateListeners.add(oldListeners.get(i)); + } + } + anim.mSeekTime = -1; + anim.mPlayingBackwards = false; + anim.mCurrentIteration = 0; + anim.mInitialized = false; + anim.mPlayingState = STOPPED; + anim.mStartedDelay = false; + PropertyValuesHolder[] oldValues = mValues; + if (oldValues != null) { + int numValues = oldValues.length; + anim.mValues = new PropertyValuesHolder[numValues]; + anim.mValuesMap = new HashMap(numValues); + for (int i = 0; i < numValues; ++i) { + PropertyValuesHolder newValuesHolder = oldValues[i].clone(); + anim.mValues[i] = newValuesHolder; + anim.mValuesMap.put(newValuesHolder.getPropertyName(), newValuesHolder); + } + } + return anim; + } + + /** + * Implementors of this interface can add themselves as update listeners + * to an ValueAnimator instance to receive callbacks on every animation + * frame, after the current frame's values have been calculated for that + * ValueAnimator. + */ + public static interface AnimatorUpdateListener { + /** + *

Notifies the occurrence of another frame of the animation.

+ * + * @param animation The animation which was repeated. + */ + void onAnimationUpdate(ValueAnimator animation); + + } + + /** + * Return the number of animations currently running. + * + * Used by StrictMode internally to annotate violations. Only + * called on the main thread. + * + * @hide + */ + public static int getCurrentAnimationsCount() { + return sAnimations.get().size(); + } + + /** + * Clear all animations on this thread, without canceling or ending them. + * This should be used with caution. + * + * @hide + */ + public static void clearAllAnimations() { + sAnimations.get().clear(); + sPendingAnimations.get().clear(); + sDelayedAnims.get().clear(); + } + + @Override + public String toString() { + String returnVal = "ValueAnimator@" + Integer.toHexString(hashCode()); + if (mValues != null) { + for (int i = 0; i < mValues.length; ++i) { + returnVal += "\n " + mValues[i].toString(); + } + } + return returnVal; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/NineViewGroup.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/NineViewGroup.java new file mode 100644 index 000000000..7b830b9c0 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/NineViewGroup.java @@ -0,0 +1,79 @@ +package com.actionbarsherlock.internal.nineoldandroids.view; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.ViewGroup; + +import com.actionbarsherlock.internal.nineoldandroids.view.animation.AnimatorProxy; + +public abstract class NineViewGroup extends ViewGroup { + private final AnimatorProxy mProxy; + + public NineViewGroup(Context context) { + super(context); + mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; + } + public NineViewGroup(Context context, AttributeSet attrs) { + super(context, attrs); + mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; + } + public NineViewGroup(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; + } + + @Override + public void setVisibility(int visibility) { + if (mProxy != null) { + if (visibility == GONE) { + clearAnimation(); + } else if (visibility == VISIBLE) { + setAnimation(mProxy); + } + } + super.setVisibility(visibility); + } + + public float getAlpha() { + if (AnimatorProxy.NEEDS_PROXY) { + return mProxy.getAlpha(); + } else { + return super.getAlpha(); + } + } + public void setAlpha(float alpha) { + if (AnimatorProxy.NEEDS_PROXY) { + mProxy.setAlpha(alpha); + } else { + super.setAlpha(alpha); + } + } + public float getTranslationX() { + if (AnimatorProxy.NEEDS_PROXY) { + return mProxy.getTranslationX(); + } else { + return super.getTranslationX(); + } + } + public void setTranslationX(float translationX) { + if (AnimatorProxy.NEEDS_PROXY) { + mProxy.setTranslationX(translationX); + } else { + super.setTranslationX(translationX); + } + } + public float getTranslationY() { + if (AnimatorProxy.NEEDS_PROXY) { + return mProxy.getTranslationY(); + } else { + return super.getTranslationY(); + } + } + public void setTranslationY(float translationY) { + if (AnimatorProxy.NEEDS_PROXY) { + mProxy.setTranslationY(translationY); + } else { + super.setTranslationY(translationY); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/AnimatorProxy.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/AnimatorProxy.java new file mode 100644 index 000000000..067d0494e --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/AnimatorProxy.java @@ -0,0 +1,212 @@ +package com.actionbarsherlock.internal.nineoldandroids.view.animation; + +import java.lang.ref.WeakReference; +import java.util.WeakHashMap; +import android.graphics.Matrix; +import android.graphics.RectF; +import android.os.Build; +import android.util.FloatMath; +import android.view.View; +import android.view.animation.Animation; +import android.view.animation.Transformation; + +public final class AnimatorProxy extends Animation { + public static final boolean NEEDS_PROXY = Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB; + + private static final WeakHashMap PROXIES = + new WeakHashMap(); + + public static AnimatorProxy wrap(View view) { + AnimatorProxy proxy = PROXIES.get(view); + if (proxy == null) { + proxy = new AnimatorProxy(view); + PROXIES.put(view, proxy); + } + return proxy; + } + + private final WeakReference mView; + + private float mAlpha = 1; + private float mScaleX = 1; + private float mScaleY = 1; + private float mTranslationX; + private float mTranslationY; + + private final RectF mBefore = new RectF(); + private final RectF mAfter = new RectF(); + private final Matrix mTempMatrix = new Matrix(); + + private AnimatorProxy(View view) { + setDuration(0); //perform transformation immediately + setFillAfter(true); //persist transformation beyond duration + view.setAnimation(this); + mView = new WeakReference(view); + } + + public float getAlpha() { + return mAlpha; + } + public void setAlpha(float alpha) { + if (mAlpha != alpha) { + mAlpha = alpha; + View view = mView.get(); + if (view != null) { + view.invalidate(); + } + } + } + public float getScaleX() { + return mScaleX; + } + public void setScaleX(float scaleX) { + if (mScaleX != scaleX) { + prepareForUpdate(); + mScaleX = scaleX; + invalidateAfterUpdate(); + } + } + public float getScaleY() { + return mScaleY; + } + public void setScaleY(float scaleY) { + if (mScaleY != scaleY) { + prepareForUpdate(); + mScaleY = scaleY; + invalidateAfterUpdate(); + } + } + public int getScrollX() { + View view = mView.get(); + if (view == null) { + return 0; + } + return view.getScrollX(); + } + public void setScrollX(int value) { + View view = mView.get(); + if (view != null) { + view.scrollTo(value, view.getScrollY()); + } + } + public int getScrollY() { + View view = mView.get(); + if (view == null) { + return 0; + } + return view.getScrollY(); + } + public void setScrollY(int value) { + View view = mView.get(); + if (view != null) { + view.scrollTo(view.getScrollY(), value); + } + } + + public float getTranslationX() { + return mTranslationX; + } + public void setTranslationX(float translationX) { + if (mTranslationX != translationX) { + prepareForUpdate(); + mTranslationX = translationX; + invalidateAfterUpdate(); + } + } + public float getTranslationY() { + return mTranslationY; + } + public void setTranslationY(float translationY) { + if (mTranslationY != translationY) { + prepareForUpdate(); + mTranslationY = translationY; + invalidateAfterUpdate(); + } + } + + private void prepareForUpdate() { + View view = mView.get(); + if (view != null) { + computeRect(mBefore, view); + } + } + private void invalidateAfterUpdate() { + View view = mView.get(); + if (view == null) { + return; + } + View parent = (View)view.getParent(); + if (parent == null) { + return; + } + + view.setAnimation(this); + + final RectF after = mAfter; + computeRect(after, view); + after.union(mBefore); + + parent.invalidate( + (int) FloatMath.floor(after.left), + (int) FloatMath.floor(after.top), + (int) FloatMath.ceil(after.right), + (int) FloatMath.ceil(after.bottom)); + } + + private void computeRect(final RectF r, View view) { + // compute current rectangle according to matrix transformation + final float w = view.getWidth(); + final float h = view.getHeight(); + + // use a rectangle at 0,0 to make sure we don't run into issues with scaling + r.set(0, 0, w, h); + + final Matrix m = mTempMatrix; + m.reset(); + transformMatrix(m, view); + mTempMatrix.mapRect(r); + + r.offset(view.getLeft(), view.getTop()); + + // Straighten coords if rotations flipped them + if (r.right < r.left) { + final float f = r.right; + r.right = r.left; + r.left = f; + } + if (r.bottom < r.top) { + final float f = r.top; + r.top = r.bottom; + r.bottom = f; + } + } + + private void transformMatrix(Matrix m, View view) { + final float w = view.getWidth(); + final float h = view.getHeight(); + + final float sX = mScaleX; + final float sY = mScaleY; + if ((sX != 1.0f) || (sY != 1.0f)) { + final float deltaSX = ((sX * w) - w) / 2f; + final float deltaSY = ((sY * h) - h) / 2f; + m.postScale(sX, sY); + m.postTranslate(-deltaSX, -deltaSY); + } + m.postTranslate(mTranslationX, mTranslationY); + } + + @Override + protected void applyTransformation(float interpolatedTime, Transformation t) { + View view = mView.get(); + if (view != null) { + t.setAlpha(mAlpha); + transformMatrix(t.getMatrix(), view); + } + } + + @Override + public void reset() { + /* Do nothing. */ + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineFrameLayout.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineFrameLayout.java new file mode 100644 index 000000000..2c428e907 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineFrameLayout.java @@ -0,0 +1,65 @@ +package com.actionbarsherlock.internal.nineoldandroids.widget; + +import android.content.Context; +import android.util.AttributeSet; +import android.widget.FrameLayout; + +import com.actionbarsherlock.internal.nineoldandroids.view.animation.AnimatorProxy; + +public class NineFrameLayout extends FrameLayout { + private final AnimatorProxy mProxy; + + public NineFrameLayout(Context context) { + super(context); + mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; + } + public NineFrameLayout(Context context, AttributeSet attrs) { + super(context, attrs); + mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; + } + public NineFrameLayout(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; + } + + @Override + public void setVisibility(int visibility) { + if (mProxy != null) { + if (visibility == GONE) { + clearAnimation(); + } else if (visibility == VISIBLE) { + setAnimation(mProxy); + } + } + super.setVisibility(visibility); + } + + public float getAlpha() { + if (AnimatorProxy.NEEDS_PROXY) { + return mProxy.getAlpha(); + } else { + return super.getAlpha(); + } + } + public void setAlpha(float alpha) { + if (AnimatorProxy.NEEDS_PROXY) { + mProxy.setAlpha(alpha); + } else { + super.setAlpha(alpha); + } + } + public float getTranslationY() { + if (AnimatorProxy.NEEDS_PROXY) { + return mProxy.getTranslationY(); + } else { + return super.getTranslationY(); + } + } + public void setTranslationY(float translationY) { + if (AnimatorProxy.NEEDS_PROXY) { + mProxy.setTranslationY(translationY); + } else { + super.setTranslationY(translationY); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineHorizontalScrollView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineHorizontalScrollView.java new file mode 100644 index 000000000..129b5aaaa --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineHorizontalScrollView.java @@ -0,0 +1,41 @@ +package com.actionbarsherlock.internal.nineoldandroids.widget; + +import android.content.Context; +import android.widget.HorizontalScrollView; +import com.actionbarsherlock.internal.nineoldandroids.view.animation.AnimatorProxy; + +public class NineHorizontalScrollView extends HorizontalScrollView { + private final AnimatorProxy mProxy; + + public NineHorizontalScrollView(Context context) { + super(context); + mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; + } + + @Override + public void setVisibility(int visibility) { + if (mProxy != null) { + if (visibility == GONE) { + clearAnimation(); + } else if (visibility == VISIBLE) { + setAnimation(mProxy); + } + } + super.setVisibility(visibility); + } + + public float getAlpha() { + if (AnimatorProxy.NEEDS_PROXY) { + return mProxy.getAlpha(); + } else { + return super.getAlpha(); + } + } + public void setAlpha(float alpha) { + if (AnimatorProxy.NEEDS_PROXY) { + mProxy.setAlpha(alpha); + } else { + super.setAlpha(alpha); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineLinearLayout.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineLinearLayout.java new file mode 100644 index 000000000..a670b1f64 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineLinearLayout.java @@ -0,0 +1,65 @@ +package com.actionbarsherlock.internal.nineoldandroids.widget; + +import android.content.Context; +import android.util.AttributeSet; +import android.widget.LinearLayout; + +import com.actionbarsherlock.internal.nineoldandroids.view.animation.AnimatorProxy; + +public class NineLinearLayout extends LinearLayout { + private final AnimatorProxy mProxy; + + public NineLinearLayout(Context context) { + super(context); + mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; + } + public NineLinearLayout(Context context, AttributeSet attrs) { + super(context, attrs); + mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; + } + public NineLinearLayout(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; + } + + @Override + public void setVisibility(int visibility) { + if (mProxy != null) { + if (visibility == GONE) { + clearAnimation(); + } else if (visibility == VISIBLE) { + setAnimation(mProxy); + } + } + super.setVisibility(visibility); + } + + public float getAlpha() { + if (AnimatorProxy.NEEDS_PROXY) { + return mProxy.getAlpha(); + } else { + return super.getAlpha(); + } + } + public void setAlpha(float alpha) { + if (AnimatorProxy.NEEDS_PROXY) { + mProxy.setAlpha(alpha); + } else { + super.setAlpha(alpha); + } + } + public float getTranslationX() { + if (AnimatorProxy.NEEDS_PROXY) { + return mProxy.getTranslationX(); + } else { + return super.getTranslationX(); + } + } + public void setTranslationX(float translationX) { + if (AnimatorProxy.NEEDS_PROXY) { + mProxy.setTranslationX(translationX); + } else { + super.setTranslationX(translationX); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/ActionProviderWrapper.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/ActionProviderWrapper.java new file mode 100644 index 000000000..b136d50f0 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/ActionProviderWrapper.java @@ -0,0 +1,40 @@ +package com.actionbarsherlock.internal.view; + +import com.actionbarsherlock.internal.view.menu.SubMenuWrapper; +import com.actionbarsherlock.view.ActionProvider; +import android.view.View; + +public class ActionProviderWrapper extends android.view.ActionProvider { + private final ActionProvider mProvider; + + + public ActionProviderWrapper(ActionProvider provider) { + super(null/*TODO*/); //XXX this *should* be unused + mProvider = provider; + } + + + public ActionProvider unwrap() { + return mProvider; + } + + @Override + public View onCreateActionView() { + return mProvider.onCreateActionView(); + } + + @Override + public boolean hasSubMenu() { + return mProvider.hasSubMenu(); + } + + @Override + public boolean onPerformDefaultAction() { + return mProvider.onPerformDefaultAction(); + } + + @Override + public void onPrepareSubMenu(android.view.SubMenu subMenu) { + mProvider.onPrepareSubMenu(new SubMenuWrapper(subMenu)); + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/StandaloneActionMode.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/StandaloneActionMode.java new file mode 100644 index 000000000..0a87bd3f7 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/StandaloneActionMode.java @@ -0,0 +1,148 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.view; + +import android.content.Context; +import android.view.View; +import android.view.accessibility.AccessibilityEvent; + +import java.lang.ref.WeakReference; + +import com.actionbarsherlock.internal.view.menu.MenuBuilder; +import com.actionbarsherlock.internal.view.menu.MenuPopupHelper; +import com.actionbarsherlock.internal.view.menu.SubMenuBuilder; +import com.actionbarsherlock.internal.widget.ActionBarContextView; +import com.actionbarsherlock.view.ActionMode; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; + +public class StandaloneActionMode extends ActionMode implements MenuBuilder.Callback { + private Context mContext; + private ActionBarContextView mContextView; + private ActionMode.Callback mCallback; + private WeakReference mCustomView; + private boolean mFinished; + private boolean mFocusable; + + private MenuBuilder mMenu; + + public StandaloneActionMode(Context context, ActionBarContextView view, + ActionMode.Callback callback, boolean isFocusable) { + mContext = context; + mContextView = view; + mCallback = callback; + + mMenu = new MenuBuilder(context).setDefaultShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); + mMenu.setCallback(this); + mFocusable = isFocusable; + } + + @Override + public void setTitle(CharSequence title) { + mContextView.setTitle(title); + } + + @Override + public void setSubtitle(CharSequence subtitle) { + mContextView.setSubtitle(subtitle); + } + + @Override + public void setTitle(int resId) { + setTitle(mContext.getString(resId)); + } + + @Override + public void setSubtitle(int resId) { + setSubtitle(mContext.getString(resId)); + } + + @Override + public void setCustomView(View view) { + mContextView.setCustomView(view); + mCustomView = view != null ? new WeakReference(view) : null; + } + + @Override + public void invalidate() { + mCallback.onPrepareActionMode(this, mMenu); + } + + @Override + public void finish() { + if (mFinished) { + return; + } + mFinished = true; + + mContextView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); + mCallback.onDestroyActionMode(this); + } + + @Override + public Menu getMenu() { + return mMenu; + } + + @Override + public CharSequence getTitle() { + return mContextView.getTitle(); + } + + @Override + public CharSequence getSubtitle() { + return mContextView.getSubtitle(); + } + + @Override + public View getCustomView() { + return mCustomView != null ? mCustomView.get() : null; + } + + @Override + public MenuInflater getMenuInflater() { + return new MenuInflater(mContext); + } + + public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) { + return mCallback.onActionItemClicked(this, item); + } + + public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) { + } + + public boolean onSubMenuSelected(SubMenuBuilder subMenu) { + if (!subMenu.hasVisibleItems()) { + return true; + } + + new MenuPopupHelper(mContext, subMenu).show(); + return true; + } + + public void onCloseSubMenu(SubMenuBuilder menu) { + } + + public void onMenuModeChange(MenuBuilder menu) { + invalidate(); + mContextView.showOverflowMenu(); + } + + public boolean isUiFocusable() { + return mFocusable; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/View_HasStateListenerSupport.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/View_HasStateListenerSupport.java new file mode 100644 index 000000000..7d45e81be --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/View_HasStateListenerSupport.java @@ -0,0 +1,6 @@ +package com.actionbarsherlock.internal.view; + +public interface View_HasStateListenerSupport { + void addOnAttachStateChangeListener(View_OnAttachStateChangeListener listener); + void removeOnAttachStateChangeListener(View_OnAttachStateChangeListener listener); +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/View_OnAttachStateChangeListener.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/View_OnAttachStateChangeListener.java new file mode 100644 index 000000000..3869d3290 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/View_OnAttachStateChangeListener.java @@ -0,0 +1,8 @@ +package com.actionbarsherlock.internal.view; + +import android.view.View; + +public interface View_OnAttachStateChangeListener { + void onViewAttachedToWindow(View v); + void onViewDetachedFromWindow(View v); +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenu.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenu.java new file mode 100644 index 000000000..0354ad1ad --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenu.java @@ -0,0 +1,264 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.view.menu; + +import java.util.ArrayList; +import java.util.List; + +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; +import android.view.KeyEvent; + +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuItem; +import com.actionbarsherlock.view.SubMenu; + +/** + * @hide + */ +public class ActionMenu implements Menu { + private Context mContext; + + private boolean mIsQwerty; + + private ArrayList mItems; + + public ActionMenu(Context context) { + mContext = context; + mItems = new ArrayList(); + } + + public Context getContext() { + return mContext; + } + + public MenuItem add(CharSequence title) { + return add(0, 0, 0, title); + } + + public MenuItem add(int titleRes) { + return add(0, 0, 0, titleRes); + } + + public MenuItem add(int groupId, int itemId, int order, int titleRes) { + return add(groupId, itemId, order, mContext.getResources().getString(titleRes)); + } + + public MenuItem add(int groupId, int itemId, int order, CharSequence title) { + ActionMenuItem item = new ActionMenuItem(getContext(), + groupId, itemId, 0, order, title); + mItems.add(order, item); + return item; + } + + public int addIntentOptions(int groupId, int itemId, int order, + ComponentName caller, Intent[] specifics, Intent intent, int flags, + MenuItem[] outSpecificItems) { + PackageManager pm = mContext.getPackageManager(); + final List lri = + pm.queryIntentActivityOptions(caller, specifics, intent, 0); + final int N = lri != null ? lri.size() : 0; + + if ((flags & FLAG_APPEND_TO_GROUP) == 0) { + removeGroup(groupId); + } + + for (int i=0; i= 0) { + outSpecificItems[ri.specificIndex] = item; + } + } + + return N; + } + + public SubMenu addSubMenu(CharSequence title) { + // TODO Implement submenus + return null; + } + + public SubMenu addSubMenu(int titleRes) { + // TODO Implement submenus + return null; + } + + public SubMenu addSubMenu(int groupId, int itemId, int order, + CharSequence title) { + // TODO Implement submenus + return null; + } + + public SubMenu addSubMenu(int groupId, int itemId, int order, int titleRes) { + // TODO Implement submenus + return null; + } + + public void clear() { + mItems.clear(); + } + + public void close() { + } + + private int findItemIndex(int id) { + final ArrayList items = mItems; + final int itemCount = items.size(); + for (int i = 0; i < itemCount; i++) { + if (items.get(i).getItemId() == id) { + return i; + } + } + + return -1; + } + + public MenuItem findItem(int id) { + return mItems.get(findItemIndex(id)); + } + + public MenuItem getItem(int index) { + return mItems.get(index); + } + + public boolean hasVisibleItems() { + final ArrayList items = mItems; + final int itemCount = items.size(); + + for (int i = 0; i < itemCount; i++) { + if (items.get(i).isVisible()) { + return true; + } + } + + return false; + } + + private ActionMenuItem findItemWithShortcut(int keyCode, KeyEvent event) { + // TODO Make this smarter. + final boolean qwerty = mIsQwerty; + final ArrayList items = mItems; + final int itemCount = items.size(); + + for (int i = 0; i < itemCount; i++) { + ActionMenuItem item = items.get(i); + final char shortcut = qwerty ? item.getAlphabeticShortcut() : + item.getNumericShortcut(); + if (keyCode == shortcut) { + return item; + } + } + return null; + } + + public boolean isShortcutKey(int keyCode, KeyEvent event) { + return findItemWithShortcut(keyCode, event) != null; + } + + public boolean performIdentifierAction(int id, int flags) { + final int index = findItemIndex(id); + if (index < 0) { + return false; + } + + return mItems.get(index).invoke(); + } + + public boolean performShortcut(int keyCode, KeyEvent event, int flags) { + ActionMenuItem item = findItemWithShortcut(keyCode, event); + if (item == null) { + return false; + } + + return item.invoke(); + } + + public void removeGroup(int groupId) { + final ArrayList items = mItems; + int itemCount = items.size(); + int i = 0; + while (i < itemCount) { + if (items.get(i).getGroupId() == groupId) { + items.remove(i); + itemCount--; + } else { + i++; + } + } + } + + public void removeItem(int id) { + mItems.remove(findItemIndex(id)); + } + + public void setGroupCheckable(int group, boolean checkable, + boolean exclusive) { + final ArrayList items = mItems; + final int itemCount = items.size(); + + for (int i = 0; i < itemCount; i++) { + ActionMenuItem item = items.get(i); + if (item.getGroupId() == group) { + item.setCheckable(checkable); + item.setExclusiveCheckable(exclusive); + } + } + } + + public void setGroupEnabled(int group, boolean enabled) { + final ArrayList items = mItems; + final int itemCount = items.size(); + + for (int i = 0; i < itemCount; i++) { + ActionMenuItem item = items.get(i); + if (item.getGroupId() == group) { + item.setEnabled(enabled); + } + } + } + + public void setGroupVisible(int group, boolean visible) { + final ArrayList items = mItems; + final int itemCount = items.size(); + + for (int i = 0; i < itemCount; i++) { + ActionMenuItem item = items.get(i); + if (item.getGroupId() == group) { + item.setVisible(visible); + } + } + } + + public void setQwertyMode(boolean isQwerty) { + mIsQwerty = isQwerty; + } + + public int size() { + return mItems.size(); + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuItem.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuItem.java new file mode 100644 index 000000000..510b97488 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuItem.java @@ -0,0 +1,278 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.view.menu; + +import android.content.Context; +import android.content.Intent; +import android.graphics.drawable.Drawable; +import android.view.ContextMenu.ContextMenuInfo; +import android.view.View; + +import com.actionbarsherlock.view.ActionProvider; +import com.actionbarsherlock.view.MenuItem; +import com.actionbarsherlock.view.SubMenu; + +/** + * @hide + */ +public class ActionMenuItem implements MenuItem { + private final int mId; + private final int mGroup; + //UNUSED private final int mCategoryOrder; + private final int mOrdering; + + private CharSequence mTitle; + private CharSequence mTitleCondensed; + private Intent mIntent; + private char mShortcutNumericChar; + private char mShortcutAlphabeticChar; + + private Drawable mIconDrawable; + //UNUSED private int mIconResId = NO_ICON; + + private Context mContext; + + private MenuItem.OnMenuItemClickListener mClickListener; + + //UNUSED private static final int NO_ICON = 0; + + private int mFlags = ENABLED; + private static final int CHECKABLE = 0x00000001; + private static final int CHECKED = 0x00000002; + private static final int EXCLUSIVE = 0x00000004; + private static final int HIDDEN = 0x00000008; + private static final int ENABLED = 0x00000010; + + public ActionMenuItem(Context context, int group, int id, int categoryOrder, int ordering, + CharSequence title) { + mContext = context; + mId = id; + mGroup = group; + //UNUSED mCategoryOrder = categoryOrder; + mOrdering = ordering; + mTitle = title; + } + + public char getAlphabeticShortcut() { + return mShortcutAlphabeticChar; + } + + public int getGroupId() { + return mGroup; + } + + public Drawable getIcon() { + return mIconDrawable; + } + + public Intent getIntent() { + return mIntent; + } + + public int getItemId() { + return mId; + } + + public ContextMenuInfo getMenuInfo() { + return null; + } + + public char getNumericShortcut() { + return mShortcutNumericChar; + } + + public int getOrder() { + return mOrdering; + } + + public SubMenu getSubMenu() { + return null; + } + + public CharSequence getTitle() { + return mTitle; + } + + public CharSequence getTitleCondensed() { + return mTitleCondensed; + } + + public boolean hasSubMenu() { + return false; + } + + public boolean isCheckable() { + return (mFlags & CHECKABLE) != 0; + } + + public boolean isChecked() { + return (mFlags & CHECKED) != 0; + } + + public boolean isEnabled() { + return (mFlags & ENABLED) != 0; + } + + public boolean isVisible() { + return (mFlags & HIDDEN) == 0; + } + + public MenuItem setAlphabeticShortcut(char alphaChar) { + mShortcutAlphabeticChar = alphaChar; + return this; + } + + public MenuItem setCheckable(boolean checkable) { + mFlags = (mFlags & ~CHECKABLE) | (checkable ? CHECKABLE : 0); + return this; + } + + public ActionMenuItem setExclusiveCheckable(boolean exclusive) { + mFlags = (mFlags & ~EXCLUSIVE) | (exclusive ? EXCLUSIVE : 0); + return this; + } + + public MenuItem setChecked(boolean checked) { + mFlags = (mFlags & ~CHECKED) | (checked ? CHECKED : 0); + return this; + } + + public MenuItem setEnabled(boolean enabled) { + mFlags = (mFlags & ~ENABLED) | (enabled ? ENABLED : 0); + return this; + } + + public MenuItem setIcon(Drawable icon) { + mIconDrawable = icon; + //UNUSED mIconResId = NO_ICON; + return this; + } + + public MenuItem setIcon(int iconRes) { + //UNUSED mIconResId = iconRes; + mIconDrawable = mContext.getResources().getDrawable(iconRes); + return this; + } + + public MenuItem setIntent(Intent intent) { + mIntent = intent; + return this; + } + + public MenuItem setNumericShortcut(char numericChar) { + mShortcutNumericChar = numericChar; + return this; + } + + public MenuItem setOnMenuItemClickListener(OnMenuItemClickListener menuItemClickListener) { + mClickListener = menuItemClickListener; + return this; + } + + public MenuItem setShortcut(char numericChar, char alphaChar) { + mShortcutNumericChar = numericChar; + mShortcutAlphabeticChar = alphaChar; + return this; + } + + public MenuItem setTitle(CharSequence title) { + mTitle = title; + return this; + } + + public MenuItem setTitle(int title) { + mTitle = mContext.getResources().getString(title); + return this; + } + + public MenuItem setTitleCondensed(CharSequence title) { + mTitleCondensed = title; + return this; + } + + public MenuItem setVisible(boolean visible) { + mFlags = (mFlags & HIDDEN) | (visible ? 0 : HIDDEN); + return this; + } + + public boolean invoke() { + if (mClickListener != null && mClickListener.onMenuItemClick(this)) { + return true; + } + + if (mIntent != null) { + mContext.startActivity(mIntent); + return true; + } + + return false; + } + + public void setShowAsAction(int show) { + // Do nothing. ActionMenuItems always show as action buttons. + } + + public MenuItem setActionView(View actionView) { + throw new UnsupportedOperationException(); + } + + public View getActionView() { + return null; + } + + @Override + public MenuItem setActionView(int resId) { + throw new UnsupportedOperationException(); + } + + @Override + public ActionProvider getActionProvider() { + return null; + } + + @Override + public MenuItem setActionProvider(ActionProvider actionProvider) { + throw new UnsupportedOperationException(); + } + + @Override + public MenuItem setShowAsActionFlags(int actionEnum) { + setShowAsAction(actionEnum); + return this; + } + + @Override + public boolean expandActionView() { + return false; + } + + @Override + public boolean collapseActionView() { + return false; + } + + @Override + public boolean isActionViewExpanded() { + return false; + } + + @Override + public MenuItem setOnActionExpandListener(OnActionExpandListener listener) { + // No need to save the listener; ActionMenuItem does not support collapsing items. + return this; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuItemView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuItemView.java new file mode 100644 index 000000000..dcb50f362 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuItemView.java @@ -0,0 +1,295 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.view.menu; + +import java.util.HashSet; +import java.util.Set; +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.Rect; +import android.graphics.drawable.Drawable; +import android.os.Build; +import android.text.TextUtils; +import android.util.AttributeSet; +import android.view.Gravity; +import android.view.MotionEvent; +import android.view.View; +import android.view.accessibility.AccessibilityEvent; +import android.widget.ImageButton; +import android.widget.LinearLayout; +import android.widget.Toast; + +import com.actionbarsherlock.R; +import com.actionbarsherlock.internal.view.View_HasStateListenerSupport; +import com.actionbarsherlock.internal.view.View_OnAttachStateChangeListener; +import com.actionbarsherlock.internal.widget.CapitalizingButton; + +import static com.actionbarsherlock.internal.ResourcesCompat.getResources_getBoolean; + +/** + * @hide + */ +public class ActionMenuItemView extends LinearLayout + implements MenuView.ItemView, View.OnClickListener, View.OnLongClickListener, + ActionMenuView.ActionMenuChildView, View_HasStateListenerSupport { + //UNUSED private static final String TAG = "ActionMenuItemView"; + + private MenuItemImpl mItemData; + private CharSequence mTitle; + private MenuBuilder.ItemInvoker mItemInvoker; + + private ImageButton mImageButton; + private CapitalizingButton mTextButton; + private boolean mAllowTextWithIcon; + private boolean mExpandedFormat; + private int mMinWidth; + + private final Set mListeners = new HashSet(); + + public ActionMenuItemView(Context context) { + this(context, null); + } + + public ActionMenuItemView(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public ActionMenuItemView(Context context, AttributeSet attrs, int defStyle) { + //TODO super(context, attrs, defStyle); + super(context, attrs); + mAllowTextWithIcon = getResources_getBoolean(context, + R.bool.abs__config_allowActionMenuItemTextWithIcon); + TypedArray a = context.obtainStyledAttributes(attrs, + R.styleable.SherlockActionMenuItemView, 0, 0); + mMinWidth = a.getDimensionPixelSize( + R.styleable.SherlockActionMenuItemView_android_minWidth, 0); + a.recycle(); + } + + @Override + public void addOnAttachStateChangeListener(View_OnAttachStateChangeListener listener) { + mListeners.add(listener); + } + + @Override + public void removeOnAttachStateChangeListener(View_OnAttachStateChangeListener listener) { + mListeners.remove(listener); + } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + for (View_OnAttachStateChangeListener listener : mListeners) { + listener.onViewAttachedToWindow(this); + } + } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + for (View_OnAttachStateChangeListener listener : mListeners) { + listener.onViewDetachedFromWindow(this); + } + } + + @Override + public void onFinishInflate() { + + mImageButton = (ImageButton) findViewById(R.id.abs__imageButton); + mTextButton = (CapitalizingButton) findViewById(R.id.abs__textButton); + mImageButton.setOnClickListener(this); + mTextButton.setOnClickListener(this); + mImageButton.setOnLongClickListener(this); + setOnClickListener(this); + setOnLongClickListener(this); + } + + public MenuItemImpl getItemData() { + return mItemData; + } + + public void initialize(MenuItemImpl itemData, int menuType) { + mItemData = itemData; + + setIcon(itemData.getIcon()); + setTitle(itemData.getTitleForItemView(this)); // Title only takes effect if there is no icon + setId(itemData.getItemId()); + + setVisibility(itemData.isVisible() ? View.VISIBLE : View.GONE); + setEnabled(itemData.isEnabled()); + } + + @Override + public void setEnabled(boolean enabled) { + super.setEnabled(enabled); + mImageButton.setEnabled(enabled); + mTextButton.setEnabled(enabled); + } + + public void onClick(View v) { + if (mItemInvoker != null) { + mItemInvoker.invokeItem(mItemData); + } + } + + public void setItemInvoker(MenuBuilder.ItemInvoker invoker) { + mItemInvoker = invoker; + } + + public boolean prefersCondensedTitle() { + return true; + } + + public void setCheckable(boolean checkable) { + // TODO Support checkable action items + } + + public void setChecked(boolean checked) { + // TODO Support checkable action items + } + + public void setExpandedFormat(boolean expandedFormat) { + if (mExpandedFormat != expandedFormat) { + mExpandedFormat = expandedFormat; + if (mItemData != null) { + mItemData.actionFormatChanged(); + } + } + } + + private void updateTextButtonVisibility() { + boolean visible = !TextUtils.isEmpty(mTextButton.getText()); + visible &= mImageButton.getDrawable() == null || + (mItemData.showsTextAsAction() && (mAllowTextWithIcon || mExpandedFormat)); + + mTextButton.setVisibility(visible ? VISIBLE : GONE); + } + + public void setIcon(Drawable icon) { + mImageButton.setImageDrawable(icon); + if (icon != null) { + mImageButton.setVisibility(VISIBLE); + } else { + mImageButton.setVisibility(GONE); + } + + updateTextButtonVisibility(); + } + + public boolean hasText() { + return mTextButton.getVisibility() != GONE; + } + + public void setShortcut(boolean showShortcut, char shortcutKey) { + // Action buttons don't show text for shortcut keys. + } + + public void setTitle(CharSequence title) { + mTitle = title; + + mTextButton.setTextCompat(mTitle); + + setContentDescription(mTitle); + updateTextButtonVisibility(); + } + + @Override + public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { + onPopulateAccessibilityEvent(event); + return true; + } + + @Override + public void onPopulateAccessibilityEvent(AccessibilityEvent event) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { + super.onPopulateAccessibilityEvent(event); + } + final CharSequence cdesc = getContentDescription(); + if (!TextUtils.isEmpty(cdesc)) { + event.getText().add(cdesc); + } + } + + @Override + public boolean dispatchHoverEvent(MotionEvent event) { + // Don't allow children to hover; we want this to be treated as a single component. + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { + return onHoverEvent(event); + } + return false; + } + + public boolean showsIcon() { + return true; + } + + public boolean needsDividerBefore() { + return hasText() && mItemData.getIcon() == null; + } + + public boolean needsDividerAfter() { + return hasText(); + } + + @Override + public boolean onLongClick(View v) { + if (hasText()) { + // Don't show the cheat sheet for items that already show text. + return false; + } + + final int[] screenPos = new int[2]; + final Rect displayFrame = new Rect(); + getLocationOnScreen(screenPos); + getWindowVisibleDisplayFrame(displayFrame); + + final Context context = getContext(); + final int width = getWidth(); + final int height = getHeight(); + final int midy = screenPos[1] + height / 2; + final int screenWidth = context.getResources().getDisplayMetrics().widthPixels; + + Toast cheatSheet = Toast.makeText(context, mItemData.getTitle(), Toast.LENGTH_SHORT); + if (midy < displayFrame.height()) { + // Show along the top; follow action buttons + cheatSheet.setGravity(Gravity.TOP | Gravity.RIGHT, + screenWidth - screenPos[0] - width / 2, height); + } else { + // Show along the bottom center + cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, height); + } + cheatSheet.show(); + return true; + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + + final int widthMode = MeasureSpec.getMode(widthMeasureSpec); + final int specSize = MeasureSpec.getSize(widthMeasureSpec); + final int oldMeasuredWidth = getMeasuredWidth(); + final int targetWidth = widthMode == MeasureSpec.AT_MOST ? Math.min(specSize, mMinWidth) + : mMinWidth; + + if (widthMode != MeasureSpec.EXACTLY && mMinWidth > 0 && oldMeasuredWidth < targetWidth) { + // Remeasure at exactly the minimum width. + super.onMeasure(MeasureSpec.makeMeasureSpec(targetWidth, MeasureSpec.EXACTLY), + heightMeasureSpec); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuPresenter.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuPresenter.java new file mode 100644 index 000000000..6f568c698 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuPresenter.java @@ -0,0 +1,721 @@ +/* + * Copyright (C) 2011 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.actionbarsherlock.internal.view.menu; + +import static com.actionbarsherlock.internal.ResourcesCompat.getResources_getInteger; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; +import android.content.Context; +import android.content.res.Configuration; +import android.content.res.Resources; +import android.content.res.TypedArray; +import android.os.Build; +import android.os.Parcel; +import android.os.Parcelable; +import android.util.SparseBooleanArray; +import android.view.SoundEffectConstants; +import android.view.View; +import android.view.View.MeasureSpec; +import android.view.ViewConfiguration; +import android.view.ViewGroup; +import android.widget.ImageButton; +import com.actionbarsherlock.R; +import com.actionbarsherlock.internal.view.View_HasStateListenerSupport; +import com.actionbarsherlock.internal.view.View_OnAttachStateChangeListener; +import com.actionbarsherlock.internal.view.menu.ActionMenuView.ActionMenuChildView; +import com.actionbarsherlock.view.ActionProvider; +import com.actionbarsherlock.view.MenuItem; + +/** + * MenuPresenter for building action menus as seen in the action bar and action modes. + */ +public class ActionMenuPresenter extends BaseMenuPresenter + implements ActionProvider.SubUiVisibilityListener { + //UNUSED private static final String TAG = "ActionMenuPresenter"; + + private View mOverflowButton; + private boolean mReserveOverflow; + private boolean mReserveOverflowSet; + private int mWidthLimit; + private int mActionItemWidthLimit; + private int mMaxItems; + private boolean mMaxItemsSet; + private boolean mStrictWidthLimit; + private boolean mWidthLimitSet; + private boolean mExpandedActionViewsExclusive; + + private int mMinCellSize; + + // Group IDs that have been added as actions - used temporarily, allocated here for reuse. + private final SparseBooleanArray mActionButtonGroups = new SparseBooleanArray(); + + private View mScrapActionButtonView; + + private OverflowPopup mOverflowPopup; + private ActionButtonSubmenu mActionButtonPopup; + + private OpenOverflowRunnable mPostedOpenRunnable; + + final PopupPresenterCallback mPopupPresenterCallback = new PopupPresenterCallback(); + int mOpenSubMenuId; + + public ActionMenuPresenter(Context context) { + super(context, R.layout.abs__action_menu_layout, + R.layout.abs__action_menu_item_layout); + } + + @Override + public void initForMenu(Context context, MenuBuilder menu) { + super.initForMenu(context, menu); + + final Resources res = context.getResources(); + + if (!mReserveOverflowSet) { + mReserveOverflow = reserveOverflow(mContext); + } + + if (!mWidthLimitSet) { + mWidthLimit = res.getDisplayMetrics().widthPixels / 2; + } + + // Measure for initial configuration + if (!mMaxItemsSet) { + mMaxItems = getResources_getInteger(context, R.integer.abs__max_action_buttons); + } + + int width = mWidthLimit; + if (mReserveOverflow) { + if (mOverflowButton == null) { + mOverflowButton = new OverflowMenuButton(mSystemContext); + final int spec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); + mOverflowButton.measure(spec, spec); + } + width -= mOverflowButton.getMeasuredWidth(); + } else { + mOverflowButton = null; + } + + mActionItemWidthLimit = width; + + mMinCellSize = (int) (ActionMenuView.MIN_CELL_SIZE * res.getDisplayMetrics().density); + + // Drop a scrap view as it may no longer reflect the proper context/config. + mScrapActionButtonView = null; + } + + public static boolean reserveOverflow(Context context) { + //Check for theme-forced overflow action item + TypedArray a = context.getTheme().obtainStyledAttributes(R.styleable.SherlockTheme); + boolean result = a.getBoolean(R.styleable.SherlockTheme_absForceOverflow, false); + a.recycle(); + if (result) { + return true; + } + + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { + return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB); + } else { + return !HasPermanentMenuKey.get(context); + } + } + + private static class HasPermanentMenuKey { + public static boolean get(Context context) { + return ViewConfiguration.get(context).hasPermanentMenuKey(); + } + } + + public void onConfigurationChanged(Configuration newConfig) { + if (!mMaxItemsSet) { + mMaxItems = getResources_getInteger(mContext, + R.integer.abs__max_action_buttons); + if (mMenu != null) { + mMenu.onItemsChanged(true); + } + } + } + + public void setWidthLimit(int width, boolean strict) { + mWidthLimit = width; + mStrictWidthLimit = strict; + mWidthLimitSet = true; + } + + public void setReserveOverflow(boolean reserveOverflow) { + mReserveOverflow = reserveOverflow; + mReserveOverflowSet = true; + } + + public void setItemLimit(int itemCount) { + mMaxItems = itemCount; + mMaxItemsSet = true; + } + + public void setExpandedActionViewsExclusive(boolean isExclusive) { + mExpandedActionViewsExclusive = isExclusive; + } + + @Override + public MenuView getMenuView(ViewGroup root) { + MenuView result = super.getMenuView(root); + ((ActionMenuView) result).setPresenter(this); + return result; + } + + @Override + public View getItemView(MenuItemImpl item, View convertView, ViewGroup parent) { + View actionView = item.getActionView(); + if (actionView == null || item.hasCollapsibleActionView()) { + if (!(convertView instanceof ActionMenuItemView)) { + convertView = null; + } + actionView = super.getItemView(item, convertView, parent); + } + actionView.setVisibility(item.isActionViewExpanded() ? View.GONE : View.VISIBLE); + + final ActionMenuView menuParent = (ActionMenuView) parent; + final ViewGroup.LayoutParams lp = actionView.getLayoutParams(); + if (!menuParent.checkLayoutParams(lp)) { + actionView.setLayoutParams(menuParent.generateLayoutParams(lp)); + } + return actionView; + } + + @Override + public void bindItemView(MenuItemImpl item, MenuView.ItemView itemView) { + itemView.initialize(item, 0); + + final ActionMenuView menuView = (ActionMenuView) mMenuView; + ActionMenuItemView actionItemView = (ActionMenuItemView) itemView; + actionItemView.setItemInvoker(menuView); + } + + @Override + public boolean shouldIncludeItem(int childIndex, MenuItemImpl item) { + return item.isActionButton(); + } + + @Override + public void updateMenuView(boolean cleared) { + super.updateMenuView(cleared); + + if (mMenu != null) { + final ArrayList actionItems = mMenu.getActionItems(); + final int count = actionItems.size(); + for (int i = 0; i < count; i++) { + final ActionProvider provider = actionItems.get(i).getActionProvider(); + if (provider != null) { + provider.setSubUiVisibilityListener(this); + } + } + } + + final ArrayList nonActionItems = mMenu != null ? + mMenu.getNonActionItems() : null; + + boolean hasOverflow = false; + if (mReserveOverflow && nonActionItems != null) { + final int count = nonActionItems.size(); + if (count == 1) { + hasOverflow = !nonActionItems.get(0).isActionViewExpanded(); + } else { + hasOverflow = count > 0; + } + } + + if (hasOverflow) { + if (mOverflowButton == null) { + mOverflowButton = new OverflowMenuButton(mSystemContext); + } + ViewGroup parent = (ViewGroup) mOverflowButton.getParent(); + if (parent != mMenuView) { + if (parent != null) { + parent.removeView(mOverflowButton); + } + ActionMenuView menuView = (ActionMenuView) mMenuView; + menuView.addView(mOverflowButton, menuView.generateOverflowButtonLayoutParams()); + } + } else if (mOverflowButton != null && mOverflowButton.getParent() == mMenuView) { + ((ViewGroup) mMenuView).removeView(mOverflowButton); + } + + ((ActionMenuView) mMenuView).setOverflowReserved(mReserveOverflow); + } + + @Override + public boolean filterLeftoverView(ViewGroup parent, int childIndex) { + if (parent.getChildAt(childIndex) == mOverflowButton) return false; + return super.filterLeftoverView(parent, childIndex); + } + + public boolean onSubMenuSelected(SubMenuBuilder subMenu) { + if (!subMenu.hasVisibleItems()) return false; + + SubMenuBuilder topSubMenu = subMenu; + while (topSubMenu.getParentMenu() != mMenu) { + topSubMenu = (SubMenuBuilder) topSubMenu.getParentMenu(); + } + View anchor = findViewForItem(topSubMenu.getItem()); + if (anchor == null) { + if (mOverflowButton == null) return false; + anchor = mOverflowButton; + } + + mOpenSubMenuId = subMenu.getItem().getItemId(); + mActionButtonPopup = new ActionButtonSubmenu(mContext, subMenu); + mActionButtonPopup.setAnchorView(anchor); + mActionButtonPopup.show(); + super.onSubMenuSelected(subMenu); + return true; + } + + private View findViewForItem(MenuItem item) { + final ViewGroup parent = (ViewGroup) mMenuView; + if (parent == null) return null; + + final int count = parent.getChildCount(); + for (int i = 0; i < count; i++) { + final View child = parent.getChildAt(i); + if (child instanceof MenuView.ItemView && + ((MenuView.ItemView) child).getItemData() == item) { + return child; + } + } + return null; + } + + /** + * Display the overflow menu if one is present. + * @return true if the overflow menu was shown, false otherwise. + */ + public boolean showOverflowMenu() { + if (mReserveOverflow && !isOverflowMenuShowing() && mMenu != null && mMenuView != null && + mPostedOpenRunnable == null && !mMenu.getNonActionItems().isEmpty()) { + OverflowPopup popup = new OverflowPopup(mContext, mMenu, mOverflowButton, true); + mPostedOpenRunnable = new OpenOverflowRunnable(popup); + // Post this for later; we might still need a layout for the anchor to be right. + ((View) mMenuView).post(mPostedOpenRunnable); + + // ActionMenuPresenter uses null as a callback argument here + // to indicate overflow is opening. + super.onSubMenuSelected(null); + + return true; + } + return false; + } + + /** + * Hide the overflow menu if it is currently showing. + * + * @return true if the overflow menu was hidden, false otherwise. + */ + public boolean hideOverflowMenu() { + if (mPostedOpenRunnable != null && mMenuView != null) { + ((View) mMenuView).removeCallbacks(mPostedOpenRunnable); + mPostedOpenRunnable = null; + return true; + } + + MenuPopupHelper popup = mOverflowPopup; + if (popup != null) { + popup.dismiss(); + return true; + } + return false; + } + + /** + * Dismiss all popup menus - overflow and submenus. + * @return true if popups were dismissed, false otherwise. (This can be because none were open.) + */ + public boolean dismissPopupMenus() { + boolean result = hideOverflowMenu(); + result |= hideSubMenus(); + return result; + } + + /** + * Dismiss all submenu popups. + * + * @return true if popups were dismissed, false otherwise. (This can be because none were open.) + */ + public boolean hideSubMenus() { + if (mActionButtonPopup != null) { + mActionButtonPopup.dismiss(); + return true; + } + return false; + } + + /** + * @return true if the overflow menu is currently showing + */ + public boolean isOverflowMenuShowing() { + return mOverflowPopup != null && mOverflowPopup.isShowing(); + } + + /** + * @return true if space has been reserved in the action menu for an overflow item. + */ + public boolean isOverflowReserved() { + return mReserveOverflow; + } + + public boolean flagActionItems() { + final ArrayList visibleItems = mMenu.getVisibleItems(); + final int itemsSize = visibleItems.size(); + int maxActions = mMaxItems; + int widthLimit = mActionItemWidthLimit; + final int querySpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); + final ViewGroup parent = (ViewGroup) mMenuView; + + int requiredItems = 0; + int requestedItems = 0; + int firstActionWidth = 0; + boolean hasOverflow = false; + for (int i = 0; i < itemsSize; i++) { + MenuItemImpl item = visibleItems.get(i); + if (item.requiresActionButton()) { + requiredItems++; + } else if (item.requestsActionButton()) { + requestedItems++; + } else { + hasOverflow = true; + } + if (mExpandedActionViewsExclusive && item.isActionViewExpanded()) { + // Overflow everything if we have an expanded action view and we're + // space constrained. + maxActions = 0; + } + } + + // Reserve a spot for the overflow item if needed. + if (mReserveOverflow && + (hasOverflow || requiredItems + requestedItems > maxActions)) { + maxActions--; + } + maxActions -= requiredItems; + + final SparseBooleanArray seenGroups = mActionButtonGroups; + seenGroups.clear(); + + int cellSize = 0; + int cellsRemaining = 0; + if (mStrictWidthLimit) { + cellsRemaining = widthLimit / mMinCellSize; + final int cellSizeRemaining = widthLimit % mMinCellSize; + cellSize = mMinCellSize + cellSizeRemaining / cellsRemaining; + } + + // Flag as many more requested items as will fit. + for (int i = 0; i < itemsSize; i++) { + MenuItemImpl item = visibleItems.get(i); + + if (item.requiresActionButton()) { + View v = getItemView(item, mScrapActionButtonView, parent); + if (mScrapActionButtonView == null) { + mScrapActionButtonView = v; + } + if (mStrictWidthLimit) { + cellsRemaining -= ActionMenuView.measureChildForCells(v, + cellSize, cellsRemaining, querySpec, 0); + } else { + v.measure(querySpec, querySpec); + } + final int measuredWidth = v.getMeasuredWidth(); + widthLimit -= measuredWidth; + if (firstActionWidth == 0) { + firstActionWidth = measuredWidth; + } + final int groupId = item.getGroupId(); + if (groupId != 0) { + seenGroups.put(groupId, true); + } + item.setIsActionButton(true); + } else if (item.requestsActionButton()) { + // Items in a group with other items that already have an action slot + // can break the max actions rule, but not the width limit. + final int groupId = item.getGroupId(); + final boolean inGroup = seenGroups.get(groupId); + boolean isAction = (maxActions > 0 || inGroup) && widthLimit > 0 && + (!mStrictWidthLimit || cellsRemaining > 0); + + if (isAction) { + View v = getItemView(item, mScrapActionButtonView, parent); + if (mScrapActionButtonView == null) { + mScrapActionButtonView = v; + } + if (mStrictWidthLimit) { + final int cells = ActionMenuView.measureChildForCells(v, + cellSize, cellsRemaining, querySpec, 0); + cellsRemaining -= cells; + if (cells == 0) { + isAction = false; + } + } else { + v.measure(querySpec, querySpec); + } + final int measuredWidth = v.getMeasuredWidth(); + widthLimit -= measuredWidth; + if (firstActionWidth == 0) { + firstActionWidth = measuredWidth; + } + + if (mStrictWidthLimit) { + isAction &= widthLimit >= 0; + } else { + // Did this push the entire first item past the limit? + isAction &= widthLimit + firstActionWidth > 0; + } + } + + if (isAction && groupId != 0) { + seenGroups.put(groupId, true); + } else if (inGroup) { + // We broke the width limit. Demote the whole group, they all overflow now. + seenGroups.put(groupId, false); + for (int j = 0; j < i; j++) { + MenuItemImpl areYouMyGroupie = visibleItems.get(j); + if (areYouMyGroupie.getGroupId() == groupId) { + // Give back the action slot + if (areYouMyGroupie.isActionButton()) maxActions++; + areYouMyGroupie.setIsActionButton(false); + } + } + } + + if (isAction) maxActions--; + + item.setIsActionButton(isAction); + } + } + return true; + } + + @Override + public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) { + dismissPopupMenus(); + super.onCloseMenu(menu, allMenusAreClosing); + } + + @Override + public Parcelable onSaveInstanceState() { + SavedState state = new SavedState(); + state.openSubMenuId = mOpenSubMenuId; + return state; + } + + @Override + public void onRestoreInstanceState(Parcelable state) { + SavedState saved = (SavedState) state; + if (saved.openSubMenuId > 0) { + MenuItem item = mMenu.findItem(saved.openSubMenuId); + if (item != null) { + SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu(); + onSubMenuSelected(subMenu); + } + } + } + + @Override + public void onSubUiVisibilityChanged(boolean isVisible) { + if (isVisible) { + // Not a submenu, but treat it like one. + super.onSubMenuSelected(null); + } else { + mMenu.close(false); + } + } + + private static class SavedState implements Parcelable { + public int openSubMenuId; + + SavedState() { + } + + SavedState(Parcel in) { + openSubMenuId = in.readInt(); + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeInt(openSubMenuId); + } + + @SuppressWarnings("unused") + public static final Parcelable.Creator CREATOR + = new Parcelable.Creator() { + public SavedState createFromParcel(Parcel in) { + return new SavedState(in); + } + + public SavedState[] newArray(int size) { + return new SavedState[size]; + } + }; + } + + private class OverflowMenuButton extends ImageButton implements ActionMenuChildView, View_HasStateListenerSupport { + private final Set mListeners = new HashSet(); + + public OverflowMenuButton(Context context) { + super(context, null, R.attr.actionOverflowButtonStyle); + + setClickable(true); + setFocusable(true); + setVisibility(VISIBLE); + setEnabled(true); + } + + @Override + public boolean performClick() { + if (super.performClick()) { + return true; + } + + playSoundEffect(SoundEffectConstants.CLICK); + showOverflowMenu(); + return true; + } + + public boolean needsDividerBefore() { + return false; + } + + public boolean needsDividerAfter() { + return false; + } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + for (View_OnAttachStateChangeListener listener : mListeners) { + listener.onViewAttachedToWindow(this); + } + } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + for (View_OnAttachStateChangeListener listener : mListeners) { + listener.onViewDetachedFromWindow(this); + } + } + + @Override + public void addOnAttachStateChangeListener(View_OnAttachStateChangeListener listener) { + mListeners.add(listener); + } + + @Override + public void removeOnAttachStateChangeListener(View_OnAttachStateChangeListener listener) { + mListeners.remove(listener); + } + } + + private class OverflowPopup extends MenuPopupHelper { + public OverflowPopup(Context context, MenuBuilder menu, View anchorView, + boolean overflowOnly) { + super(context, menu, anchorView, overflowOnly); + setCallback(mPopupPresenterCallback); + } + + @Override + public void onDismiss() { + super.onDismiss(); + mMenu.close(); + mOverflowPopup = null; + } + } + + private class ActionButtonSubmenu extends MenuPopupHelper { + //UNUSED private SubMenuBuilder mSubMenu; + + public ActionButtonSubmenu(Context context, SubMenuBuilder subMenu) { + super(context, subMenu); + //UNUSED mSubMenu = subMenu; + + MenuItemImpl item = (MenuItemImpl) subMenu.getItem(); + if (!item.isActionButton()) { + // Give a reasonable anchor to nested submenus. + setAnchorView(mOverflowButton == null ? (View) mMenuView : mOverflowButton); + } + + setCallback(mPopupPresenterCallback); + + boolean preserveIconSpacing = false; + final int count = subMenu.size(); + for (int i = 0; i < count; i++) { + MenuItem childItem = subMenu.getItem(i); + if (childItem.isVisible() && childItem.getIcon() != null) { + preserveIconSpacing = true; + break; + } + } + setForceShowIcon(preserveIconSpacing); + } + + @Override + public void onDismiss() { + super.onDismiss(); + mActionButtonPopup = null; + mOpenSubMenuId = 0; + } + } + + private class PopupPresenterCallback implements MenuPresenter.Callback { + + @Override + public boolean onOpenSubMenu(MenuBuilder subMenu) { + if (subMenu == null) return false; + + mOpenSubMenuId = ((SubMenuBuilder) subMenu).getItem().getItemId(); + return false; + } + + @Override + public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) { + if (menu instanceof SubMenuBuilder) { + ((SubMenuBuilder) menu).getRootMenu().close(false); + } + } + } + + private class OpenOverflowRunnable implements Runnable { + private OverflowPopup mPopup; + + public OpenOverflowRunnable(OverflowPopup popup) { + mPopup = popup; + } + + public void run() { + mMenu.changeMenuMode(); + final View menuView = (View) mMenuView; + if (menuView != null && menuView.getWindowToken() != null && mPopup.tryShow()) { + mOverflowPopup = mPopup; + } + mPostedOpenRunnable = null; + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuView.java new file mode 100644 index 000000000..e090677a1 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuView.java @@ -0,0 +1,572 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.view.menu; + +import android.content.Context; +import android.content.res.Configuration; +import android.graphics.Canvas; +import android.os.Build; +import android.util.AttributeSet; +import android.view.Gravity; +import android.view.View; +import android.view.ViewGroup; +import android.view.accessibility.AccessibilityEvent; +import android.widget.LinearLayout; +import com.actionbarsherlock.internal.widget.IcsLinearLayout; + +/** + * @hide + */ +public class ActionMenuView extends IcsLinearLayout implements MenuBuilder.ItemInvoker, MenuView { + //UNUSED private static final String TAG = "ActionMenuView"; + private static final boolean IS_FROYO = Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO; + + static final int MIN_CELL_SIZE = 56; // dips + static final int GENERATED_ITEM_PADDING = 4; // dips + + private MenuBuilder mMenu; + + private boolean mReserveOverflow; + private ActionMenuPresenter mPresenter; + private boolean mFormatItems; + private int mFormatItemsWidth; + private int mMinCellSize; + private int mGeneratedItemPadding; + //UNUSED private int mMeasuredExtraWidth; + + private boolean mFirst = true; + + public ActionMenuView(Context context) { + this(context, null); + } + + public ActionMenuView(Context context, AttributeSet attrs) { + super(context, attrs); + setBaselineAligned(false); + final float density = context.getResources().getDisplayMetrics().density; + mMinCellSize = (int) (MIN_CELL_SIZE * density); + mGeneratedItemPadding = (int) (GENERATED_ITEM_PADDING * density); + } + + public void setPresenter(ActionMenuPresenter presenter) { + mPresenter = presenter; + } + + public boolean isExpandedFormat() { + return mFormatItems; + } + + @Override + public void onConfigurationChanged(Configuration newConfig) { + if (IS_FROYO) { + super.onConfigurationChanged(newConfig); + } + mPresenter.updateMenuView(false); + + if (mPresenter != null && mPresenter.isOverflowMenuShowing()) { + mPresenter.hideOverflowMenu(); + mPresenter.showOverflowMenu(); + } + } + + @Override + protected void onDraw(Canvas canvas) { + //Need to trigger a relayout since we may have been added extremely + //late in the initial rendering (e.g., when contained in a ViewPager). + //See: https://github.com/JakeWharton/ActionBarSherlock/issues/272 + if (!IS_FROYO && mFirst) { + mFirst = false; + requestLayout(); + return; + } + super.onDraw(canvas); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + // If we've been given an exact size to match, apply special formatting during layout. + final boolean wasFormatted = mFormatItems; + mFormatItems = MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.EXACTLY; + + if (wasFormatted != mFormatItems) { + mFormatItemsWidth = 0; // Reset this when switching modes + } + + // Special formatting can change whether items can fit as action buttons. + // Kick the menu and update presenters when this changes. + final int widthSize = MeasureSpec.getMode(widthMeasureSpec); + if (mFormatItems && mMenu != null && widthSize != mFormatItemsWidth) { + mFormatItemsWidth = widthSize; + mMenu.onItemsChanged(true); + } + + if (mFormatItems) { + onMeasureExactFormat(widthMeasureSpec, heightMeasureSpec); + } else { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + } + } + + private void onMeasureExactFormat(int widthMeasureSpec, int heightMeasureSpec) { + // We already know the width mode is EXACTLY if we're here. + final int heightMode = MeasureSpec.getMode(heightMeasureSpec); + int widthSize = MeasureSpec.getSize(widthMeasureSpec); + int heightSize = MeasureSpec.getSize(heightMeasureSpec); + + final int widthPadding = getPaddingLeft() + getPaddingRight(); + final int heightPadding = getPaddingTop() + getPaddingBottom(); + + widthSize -= widthPadding; + + // Divide the view into cells. + final int cellCount = widthSize / mMinCellSize; + final int cellSizeRemaining = widthSize % mMinCellSize; + + if (cellCount == 0) { + // Give up, nothing fits. + setMeasuredDimension(widthSize, 0); + return; + } + + final int cellSize = mMinCellSize + cellSizeRemaining / cellCount; + + int cellsRemaining = cellCount; + int maxChildHeight = 0; + int maxCellsUsed = 0; + int expandableItemCount = 0; + int visibleItemCount = 0; + boolean hasOverflow = false; + + // This is used as a bitfield to locate the smallest items present. Assumes childCount < 64. + long smallestItemsAt = 0; + + final int childCount = getChildCount(); + for (int i = 0; i < childCount; i++) { + final View child = getChildAt(i); + if (child.getVisibility() == GONE) continue; + + final boolean isGeneratedItem = child instanceof ActionMenuItemView; + visibleItemCount++; + + if (isGeneratedItem) { + // Reset padding for generated menu item views; it may change below + // and views are recycled. + child.setPadding(mGeneratedItemPadding, 0, mGeneratedItemPadding, 0); + } + + final LayoutParams lp = (LayoutParams) child.getLayoutParams(); + lp.expanded = false; + lp.extraPixels = 0; + lp.cellsUsed = 0; + lp.expandable = false; + lp.leftMargin = 0; + lp.rightMargin = 0; + lp.preventEdgeOffset = isGeneratedItem && ((ActionMenuItemView) child).hasText(); + + // Overflow always gets 1 cell. No more, no less. + final int cellsAvailable = lp.isOverflowButton ? 1 : cellsRemaining; + + final int cellsUsed = measureChildForCells(child, cellSize, cellsAvailable, + heightMeasureSpec, heightPadding); + + maxCellsUsed = Math.max(maxCellsUsed, cellsUsed); + if (lp.expandable) expandableItemCount++; + if (lp.isOverflowButton) hasOverflow = true; + + cellsRemaining -= cellsUsed; + maxChildHeight = Math.max(maxChildHeight, child.getMeasuredHeight()); + if (cellsUsed == 1) smallestItemsAt |= (1 << i); + } + + // When we have overflow and a single expanded (text) item, we want to try centering it + // visually in the available space even though overflow consumes some of it. + final boolean centerSingleExpandedItem = hasOverflow && visibleItemCount == 2; + + // Divide space for remaining cells if we have items that can expand. + // Try distributing whole leftover cells to smaller items first. + + boolean needsExpansion = false; + while (expandableItemCount > 0 && cellsRemaining > 0) { + int minCells = Integer.MAX_VALUE; + long minCellsAt = 0; // Bit locations are indices of relevant child views + int minCellsItemCount = 0; + for (int i = 0; i < childCount; i++) { + final View child = getChildAt(i); + final LayoutParams lp = (LayoutParams) child.getLayoutParams(); + + // Don't try to expand items that shouldn't. + if (!lp.expandable) continue; + + // Mark indices of children that can receive an extra cell. + if (lp.cellsUsed < minCells) { + minCells = lp.cellsUsed; + minCellsAt = 1 << i; + minCellsItemCount = 1; + } else if (lp.cellsUsed == minCells) { + minCellsAt |= 1 << i; + minCellsItemCount++; + } + } + + // Items that get expanded will always be in the set of smallest items when we're done. + smallestItemsAt |= minCellsAt; + + if (minCellsItemCount > cellsRemaining) break; // Couldn't expand anything evenly. Stop. + + // We have enough cells, all minimum size items will be incremented. + minCells++; + + for (int i = 0; i < childCount; i++) { + final View child = getChildAt(i); + final LayoutParams lp = (LayoutParams) child.getLayoutParams(); + if ((minCellsAt & (1 << i)) == 0) { + // If this item is already at our small item count, mark it for later. + if (lp.cellsUsed == minCells) smallestItemsAt |= 1 << i; + continue; + } + + if (centerSingleExpandedItem && lp.preventEdgeOffset && cellsRemaining == 1) { + // Add padding to this item such that it centers. + child.setPadding(mGeneratedItemPadding + cellSize, 0, mGeneratedItemPadding, 0); + } + lp.cellsUsed++; + lp.expanded = true; + cellsRemaining--; + } + + needsExpansion = true; + } + + // Divide any space left that wouldn't divide along cell boundaries + // evenly among the smallest items + + final boolean singleItem = !hasOverflow && visibleItemCount == 1; + if (cellsRemaining > 0 && smallestItemsAt != 0 && + (cellsRemaining < visibleItemCount - 1 || singleItem || maxCellsUsed > 1)) { + float expandCount = Long.bitCount(smallestItemsAt); + + if (!singleItem) { + // The items at the far edges may only expand by half in order to pin to either side. + if ((smallestItemsAt & 1) != 0) { + LayoutParams lp = (LayoutParams) getChildAt(0).getLayoutParams(); + if (!lp.preventEdgeOffset) expandCount -= 0.5f; + } + if ((smallestItemsAt & (1 << (childCount - 1))) != 0) { + LayoutParams lp = ((LayoutParams) getChildAt(childCount - 1).getLayoutParams()); + if (!lp.preventEdgeOffset) expandCount -= 0.5f; + } + } + + final int extraPixels = expandCount > 0 ? + (int) (cellsRemaining * cellSize / expandCount) : 0; + + for (int i = 0; i < childCount; i++) { + if ((smallestItemsAt & (1 << i)) == 0) continue; + + final View child = getChildAt(i); + final LayoutParams lp = (LayoutParams) child.getLayoutParams(); + if (child instanceof ActionMenuItemView) { + // If this is one of our views, expand and measure at the larger size. + lp.extraPixels = extraPixels; + lp.expanded = true; + if (i == 0 && !lp.preventEdgeOffset) { + // First item gets part of its new padding pushed out of sight. + // The last item will get this implicitly from layout. + lp.leftMargin = -extraPixels / 2; + } + needsExpansion = true; + } else if (lp.isOverflowButton) { + lp.extraPixels = extraPixels; + lp.expanded = true; + lp.rightMargin = -extraPixels / 2; + needsExpansion = true; + } else { + // If we don't know what it is, give it some margins instead + // and let it center within its space. We still want to pin + // against the edges. + if (i != 0) { + lp.leftMargin = extraPixels / 2; + } + if (i != childCount - 1) { + lp.rightMargin = extraPixels / 2; + } + } + } + + cellsRemaining = 0; + } + + // Remeasure any items that have had extra space allocated to them. + if (needsExpansion) { + int heightSpec = MeasureSpec.makeMeasureSpec(heightSize - heightPadding, heightMode); + for (int i = 0; i < childCount; i++) { + final View child = getChildAt(i); + final LayoutParams lp = (LayoutParams) child.getLayoutParams(); + + if (!lp.expanded) continue; + + final int width = lp.cellsUsed * cellSize + lp.extraPixels; + child.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), heightSpec); + } + } + + if (heightMode != MeasureSpec.EXACTLY) { + heightSize = maxChildHeight; + } + + setMeasuredDimension(widthSize, heightSize); + //UNUSED mMeasuredExtraWidth = cellsRemaining * cellSize; + } + + /** + * Measure a child view to fit within cell-based formatting. The child's width + * will be measured to a whole multiple of cellSize. + * + *

Sets the expandable and cellsUsed fields of LayoutParams. + * + * @param child Child to measure + * @param cellSize Size of one cell + * @param cellsRemaining Number of cells remaining that this view can expand to fill + * @param parentHeightMeasureSpec MeasureSpec used by the parent view + * @param parentHeightPadding Padding present in the parent view + * @return Number of cells this child was measured to occupy + */ + static int measureChildForCells(View child, int cellSize, int cellsRemaining, + int parentHeightMeasureSpec, int parentHeightPadding) { + final LayoutParams lp = (LayoutParams) child.getLayoutParams(); + + final int childHeightSize = MeasureSpec.getSize(parentHeightMeasureSpec) - + parentHeightPadding; + final int childHeightMode = MeasureSpec.getMode(parentHeightMeasureSpec); + final int childHeightSpec = MeasureSpec.makeMeasureSpec(childHeightSize, childHeightMode); + + int cellsUsed = 0; + if (cellsRemaining > 0) { + final int childWidthSpec = MeasureSpec.makeMeasureSpec( + cellSize * cellsRemaining, MeasureSpec.AT_MOST); + child.measure(childWidthSpec, childHeightSpec); + + final int measuredWidth = child.getMeasuredWidth(); + cellsUsed = measuredWidth / cellSize; + if (measuredWidth % cellSize != 0) cellsUsed++; + } + + final ActionMenuItemView itemView = child instanceof ActionMenuItemView ? + (ActionMenuItemView) child : null; + final boolean expandable = !lp.isOverflowButton && itemView != null && itemView.hasText(); + lp.expandable = expandable; + + lp.cellsUsed = cellsUsed; + final int targetWidth = cellsUsed * cellSize; + child.measure(MeasureSpec.makeMeasureSpec(targetWidth, MeasureSpec.EXACTLY), + childHeightSpec); + return cellsUsed; + } + + @Override + protected void onLayout(boolean changed, int left, int top, int right, int bottom) { + if (!mFormatItems) { + super.onLayout(changed, left, top, right, bottom); + return; + } + + final int childCount = getChildCount(); + final int midVertical = (top + bottom) / 2; + final int dividerWidth = 0;//getDividerWidth(); + int overflowWidth = 0; + //UNUSED int nonOverflowWidth = 0; + int nonOverflowCount = 0; + int widthRemaining = right - left - getPaddingRight() - getPaddingLeft(); + boolean hasOverflow = false; + for (int i = 0; i < childCount; i++) { + final View v = getChildAt(i); + if (v.getVisibility() == GONE) { + continue; + } + + LayoutParams p = (LayoutParams) v.getLayoutParams(); + if (p.isOverflowButton) { + overflowWidth = v.getMeasuredWidth(); + if (hasDividerBeforeChildAt(i)) { + overflowWidth += dividerWidth; + } + + int height = v.getMeasuredHeight(); + int r = getWidth() - getPaddingRight() - p.rightMargin; + int l = r - overflowWidth; + int t = midVertical - (height / 2); + int b = t + height; + v.layout(l, t, r, b); + + widthRemaining -= overflowWidth; + hasOverflow = true; + } else { + final int size = v.getMeasuredWidth() + p.leftMargin + p.rightMargin; + //UNUSED nonOverflowWidth += size; + widthRemaining -= size; + //if (hasDividerBeforeChildAt(i)) { + //UNUSED nonOverflowWidth += dividerWidth; + //} + nonOverflowCount++; + } + } + + if (childCount == 1 && !hasOverflow) { + // Center a single child + final View v = getChildAt(0); + final int width = v.getMeasuredWidth(); + final int height = v.getMeasuredHeight(); + final int midHorizontal = (right - left) / 2; + final int l = midHorizontal - width / 2; + final int t = midVertical - height / 2; + v.layout(l, t, l + width, t + height); + return; + } + + final int spacerCount = nonOverflowCount - (hasOverflow ? 0 : 1); + final int spacerSize = Math.max(0, spacerCount > 0 ? widthRemaining / spacerCount : 0); + + int startLeft = getPaddingLeft(); + for (int i = 0; i < childCount; i++) { + final View v = getChildAt(i); + final LayoutParams lp = (LayoutParams) v.getLayoutParams(); + if (v.getVisibility() == GONE || lp.isOverflowButton) { + continue; + } + + startLeft += lp.leftMargin; + int width = v.getMeasuredWidth(); + int height = v.getMeasuredHeight(); + int t = midVertical - height / 2; + v.layout(startLeft, t, startLeft + width, t + height); + startLeft += width + lp.rightMargin + spacerSize; + } + } + + @Override + public void onDetachedFromWindow() { + super.onDetachedFromWindow(); + mPresenter.dismissPopupMenus(); + } + + public boolean isOverflowReserved() { + return mReserveOverflow; + } + + public void setOverflowReserved(boolean reserveOverflow) { + mReserveOverflow = reserveOverflow; + } + + @Override + protected LayoutParams generateDefaultLayoutParams() { + LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, + LayoutParams.WRAP_CONTENT); + params.gravity = Gravity.CENTER_VERTICAL; + return params; + } + + @Override + public LayoutParams generateLayoutParams(AttributeSet attrs) { + return new LayoutParams(getContext(), attrs); + } + + @Override + protected LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) { + if (p instanceof LayoutParams) { + LayoutParams result = new LayoutParams((LayoutParams) p); + if (result.gravity <= Gravity.NO_GRAVITY) { + result.gravity = Gravity.CENTER_VERTICAL; + } + return result; + } + return generateDefaultLayoutParams(); + } + + @Override + protected boolean checkLayoutParams(ViewGroup.LayoutParams p) { + return p != null && p instanceof LayoutParams; + } + + public LayoutParams generateOverflowButtonLayoutParams() { + LayoutParams result = generateDefaultLayoutParams(); + result.isOverflowButton = true; + return result; + } + + public boolean invokeItem(MenuItemImpl item) { + return mMenu.performItemAction(item, 0); + } + + public int getWindowAnimations() { + return 0; + } + + public void initialize(MenuBuilder menu) { + mMenu = menu; + } + + //@Override + protected boolean hasDividerBeforeChildAt(int childIndex) { + final View childBefore = getChildAt(childIndex - 1); + final View child = getChildAt(childIndex); + boolean result = false; + if (childIndex < getChildCount() && childBefore instanceof ActionMenuChildView) { + result |= ((ActionMenuChildView) childBefore).needsDividerAfter(); + } + if (childIndex > 0 && child instanceof ActionMenuChildView) { + result |= ((ActionMenuChildView) child).needsDividerBefore(); + } + return result; + } + + public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { + return false; + } + + public interface ActionMenuChildView { + public boolean needsDividerBefore(); + public boolean needsDividerAfter(); + } + + public static class LayoutParams extends LinearLayout.LayoutParams { + public boolean isOverflowButton; + public int cellsUsed; + public int extraPixels; + public boolean expandable; + public boolean preventEdgeOffset; + + public boolean expanded; + + public LayoutParams(Context c, AttributeSet attrs) { + super(c, attrs); + } + + public LayoutParams(LayoutParams other) { + super((LinearLayout.LayoutParams) other); + isOverflowButton = other.isOverflowButton; + } + + public LayoutParams(int width, int height) { + super(width, height); + isOverflowButton = false; + } + + public LayoutParams(int width, int height, boolean isOverflowButton) { + super(width, height); + this.isOverflowButton = isOverflowButton; + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/BaseMenuPresenter.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/BaseMenuPresenter.java new file mode 100644 index 000000000..6da26f2ae --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/BaseMenuPresenter.java @@ -0,0 +1,231 @@ +/* + * Copyright (C) 2011 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.actionbarsherlock.internal.view.menu; + +import java.util.ArrayList; +import android.content.Context; +import android.os.Build; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +/** + * Base class for MenuPresenters that have a consistent container view and item + * views. Behaves similarly to an AdapterView in that existing item views will + * be reused if possible when items change. + */ +public abstract class BaseMenuPresenter implements MenuPresenter { + private static final boolean IS_HONEYCOMB = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB; + + protected Context mSystemContext; + protected Context mContext; + protected MenuBuilder mMenu; + protected LayoutInflater mSystemInflater; + protected LayoutInflater mInflater; + private Callback mCallback; + + private int mMenuLayoutRes; + private int mItemLayoutRes; + + protected MenuView mMenuView; + + private int mId; + + /** + * Construct a new BaseMenuPresenter. + * + * @param context Context for generating system-supplied views + * @param menuLayoutRes Layout resource ID for the menu container view + * @param itemLayoutRes Layout resource ID for a single item view + */ + public BaseMenuPresenter(Context context, int menuLayoutRes, int itemLayoutRes) { + mSystemContext = context; + mSystemInflater = LayoutInflater.from(context); + mMenuLayoutRes = menuLayoutRes; + mItemLayoutRes = itemLayoutRes; + } + + @Override + public void initForMenu(Context context, MenuBuilder menu) { + mContext = context; + mInflater = LayoutInflater.from(mContext); + mMenu = menu; + } + + @Override + public MenuView getMenuView(ViewGroup root) { + if (mMenuView == null) { + mMenuView = (MenuView) mSystemInflater.inflate(mMenuLayoutRes, root, false); + mMenuView.initialize(mMenu); + updateMenuView(true); + } + + return mMenuView; + } + + /** + * Reuses item views when it can + */ + public void updateMenuView(boolean cleared) { + final ViewGroup parent = (ViewGroup) mMenuView; + if (parent == null) return; + + int childIndex = 0; + if (mMenu != null) { + mMenu.flagActionItems(); + ArrayList visibleItems = mMenu.getVisibleItems(); + final int itemCount = visibleItems.size(); + for (int i = 0; i < itemCount; i++) { + MenuItemImpl item = visibleItems.get(i); + if (shouldIncludeItem(childIndex, item)) { + final View convertView = parent.getChildAt(childIndex); + final MenuItemImpl oldItem = convertView instanceof MenuView.ItemView ? + ((MenuView.ItemView) convertView).getItemData() : null; + final View itemView = getItemView(item, convertView, parent); + if (item != oldItem) { + // Don't let old states linger with new data. + itemView.setPressed(false); + if (IS_HONEYCOMB) itemView.jumpDrawablesToCurrentState(); + } + if (itemView != convertView) { + addItemView(itemView, childIndex); + } + childIndex++; + } + } + } + + // Remove leftover views. + while (childIndex < parent.getChildCount()) { + if (!filterLeftoverView(parent, childIndex)) { + childIndex++; + } + } + } + + /** + * Add an item view at the given index. + * + * @param itemView View to add + * @param childIndex Index within the parent to insert at + */ + protected void addItemView(View itemView, int childIndex) { + final ViewGroup currentParent = (ViewGroup) itemView.getParent(); + if (currentParent != null) { + currentParent.removeView(itemView); + } + ((ViewGroup) mMenuView).addView(itemView, childIndex); + } + + /** + * Filter the child view at index and remove it if appropriate. + * @param parent Parent to filter from + * @param childIndex Index to filter + * @return true if the child view at index was removed + */ + protected boolean filterLeftoverView(ViewGroup parent, int childIndex) { + parent.removeViewAt(childIndex); + return true; + } + + public void setCallback(Callback cb) { + mCallback = cb; + } + + /** + * Create a new item view that can be re-bound to other item data later. + * + * @return The new item view + */ + public MenuView.ItemView createItemView(ViewGroup parent) { + return (MenuView.ItemView) mSystemInflater.inflate(mItemLayoutRes, parent, false); + } + + /** + * Prepare an item view for use. See AdapterView for the basic idea at work here. + * This may require creating a new item view, but well-behaved implementations will + * re-use the view passed as convertView if present. The returned view will be populated + * with data from the item parameter. + * + * @param item Item to present + * @param convertView Existing view to reuse + * @param parent Intended parent view - use for inflation. + * @return View that presents the requested menu item + */ + public View getItemView(MenuItemImpl item, View convertView, ViewGroup parent) { + MenuView.ItemView itemView; + if (convertView instanceof MenuView.ItemView) { + itemView = (MenuView.ItemView) convertView; + } else { + itemView = createItemView(parent); + } + bindItemView(item, itemView); + return (View) itemView; + } + + /** + * Bind item data to an existing item view. + * + * @param item Item to bind + * @param itemView View to populate with item data + */ + public abstract void bindItemView(MenuItemImpl item, MenuView.ItemView itemView); + + /** + * Filter item by child index and item data. + * + * @param childIndex Indended presentation index of this item + * @param item Item to present + * @return true if this item should be included in this menu presentation; false otherwise + */ + public boolean shouldIncludeItem(int childIndex, MenuItemImpl item) { + return true; + } + + public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) { + if (mCallback != null) { + mCallback.onCloseMenu(menu, allMenusAreClosing); + } + } + + public boolean onSubMenuSelected(SubMenuBuilder menu) { + if (mCallback != null) { + return mCallback.onOpenSubMenu(menu); + } + return false; + } + + public boolean flagActionItems() { + return false; + } + + public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item) { + return false; + } + + public boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item) { + return false; + } + + public int getId() { + return mId; + } + + public void setId(int id) { + mId = id; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ListMenuItemView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ListMenuItemView.java new file mode 100644 index 000000000..ac25c3736 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ListMenuItemView.java @@ -0,0 +1,278 @@ +/* + * Copyright (C) 2006 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.actionbarsherlock.internal.view.menu; + +import com.actionbarsherlock.R; + +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.drawable.Drawable; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.CheckBox; +import android.widget.CompoundButton; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.RadioButton; +import android.widget.TextView; + +/** + * The item view for each item in the ListView-based MenuViews. + */ +public class ListMenuItemView extends LinearLayout implements MenuView.ItemView { + private MenuItemImpl mItemData; + + private ImageView mIconView; + private RadioButton mRadioButton; + private TextView mTitleView; + private CheckBox mCheckBox; + private TextView mShortcutView; + + private Drawable mBackground; + private int mTextAppearance; + private Context mTextAppearanceContext; + private boolean mPreserveIconSpacing; + + //UNUSED private int mMenuType; + + private LayoutInflater mInflater; + + private boolean mForceShowIcon; + + final Context mContext; + + public ListMenuItemView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs); + mContext = context; + + TypedArray a = + context.obtainStyledAttributes( + attrs, R.styleable.SherlockMenuView, defStyle, 0); + + mBackground = a.getDrawable(R.styleable.SherlockMenuView_itemBackground); + mTextAppearance = a.getResourceId(R.styleable. + SherlockMenuView_itemTextAppearance, -1); + mPreserveIconSpacing = a.getBoolean( + R.styleable.SherlockMenuView_preserveIconSpacing, false); + mTextAppearanceContext = context; + + a.recycle(); + } + + public ListMenuItemView(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + @Override + protected void onFinishInflate() { + super.onFinishInflate(); + + setBackgroundDrawable(mBackground); + + mTitleView = (TextView) findViewById(R.id.abs__title); + if (mTextAppearance != -1) { + mTitleView.setTextAppearance(mTextAppearanceContext, + mTextAppearance); + } + + mShortcutView = (TextView) findViewById(R.id.abs__shortcut); + } + + public void initialize(MenuItemImpl itemData, int menuType) { + mItemData = itemData; + //UNUSED mMenuType = menuType; + + setVisibility(itemData.isVisible() ? View.VISIBLE : View.GONE); + + setTitle(itemData.getTitleForItemView(this)); + setCheckable(itemData.isCheckable()); + setShortcut(itemData.shouldShowShortcut(), itemData.getShortcut()); + setIcon(itemData.getIcon()); + setEnabled(itemData.isEnabled()); + } + + public void setForceShowIcon(boolean forceShow) { + mPreserveIconSpacing = mForceShowIcon = forceShow; + } + + public void setTitle(CharSequence title) { + if (title != null) { + mTitleView.setText(title); + + if (mTitleView.getVisibility() != VISIBLE) mTitleView.setVisibility(VISIBLE); + } else { + if (mTitleView.getVisibility() != GONE) mTitleView.setVisibility(GONE); + } + } + + public MenuItemImpl getItemData() { + return mItemData; + } + + public void setCheckable(boolean checkable) { + + if (!checkable && mRadioButton == null && mCheckBox == null) { + return; + } + + if (mRadioButton == null) { + insertRadioButton(); + } + if (mCheckBox == null) { + insertCheckBox(); + } + + // Depending on whether its exclusive check or not, the checkbox or + // radio button will be the one in use (and the other will be otherCompoundButton) + final CompoundButton compoundButton; + final CompoundButton otherCompoundButton; + + if (mItemData.isExclusiveCheckable()) { + compoundButton = mRadioButton; + otherCompoundButton = mCheckBox; + } else { + compoundButton = mCheckBox; + otherCompoundButton = mRadioButton; + } + + if (checkable) { + compoundButton.setChecked(mItemData.isChecked()); + + final int newVisibility = checkable ? VISIBLE : GONE; + if (compoundButton.getVisibility() != newVisibility) { + compoundButton.setVisibility(newVisibility); + } + + // Make sure the other compound button isn't visible + if (otherCompoundButton.getVisibility() != GONE) { + otherCompoundButton.setVisibility(GONE); + } + } else { + mCheckBox.setVisibility(GONE); + mRadioButton.setVisibility(GONE); + } + } + + public void setChecked(boolean checked) { + CompoundButton compoundButton; + + if (mItemData.isExclusiveCheckable()) { + if (mRadioButton == null) { + insertRadioButton(); + } + compoundButton = mRadioButton; + } else { + if (mCheckBox == null) { + insertCheckBox(); + } + compoundButton = mCheckBox; + } + + compoundButton.setChecked(checked); + } + + public void setShortcut(boolean showShortcut, char shortcutKey) { + final int newVisibility = (showShortcut && mItemData.shouldShowShortcut()) + ? VISIBLE : GONE; + + if (newVisibility == VISIBLE) { + mShortcutView.setText(mItemData.getShortcutLabel()); + } + + if (mShortcutView.getVisibility() != newVisibility) { + mShortcutView.setVisibility(newVisibility); + } + } + + public void setIcon(Drawable icon) { + final boolean showIcon = mItemData.shouldShowIcon() || mForceShowIcon; + if (!showIcon && !mPreserveIconSpacing) { + return; + } + + if (mIconView == null && icon == null && !mPreserveIconSpacing) { + return; + } + + if (mIconView == null) { + insertIconView(); + } + + if (icon != null || mPreserveIconSpacing) { + mIconView.setImageDrawable(showIcon ? icon : null); + + if (mIconView.getVisibility() != VISIBLE) { + mIconView.setVisibility(VISIBLE); + } + } else { + mIconView.setVisibility(GONE); + } + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + if (mIconView != null && mPreserveIconSpacing) { + // Enforce minimum icon spacing + ViewGroup.LayoutParams lp = getLayoutParams(); + LayoutParams iconLp = (LayoutParams) mIconView.getLayoutParams(); + if (lp.height > 0 && iconLp.width <= 0) { + iconLp.width = lp.height; + } + } + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + } + + private void insertIconView() { + LayoutInflater inflater = getInflater(); + mIconView = (ImageView) inflater.inflate(R.layout.abs__list_menu_item_icon, + this, false); + addView(mIconView, 0); + } + + private void insertRadioButton() { + LayoutInflater inflater = getInflater(); + mRadioButton = + (RadioButton) inflater.inflate(R.layout.abs__list_menu_item_radio, + this, false); + addView(mRadioButton); + } + + private void insertCheckBox() { + LayoutInflater inflater = getInflater(); + mCheckBox = + (CheckBox) inflater.inflate(R.layout.abs__list_menu_item_checkbox, + this, false); + addView(mCheckBox); + } + + public boolean prefersCondensedTitle() { + return false; + } + + public boolean showsIcon() { + return mForceShowIcon; + } + + private LayoutInflater getInflater() { + if (mInflater == null) { + mInflater = LayoutInflater.from(mContext); + } + return mInflater; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuBuilder.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuBuilder.java new file mode 100644 index 000000000..179b8f037 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuBuilder.java @@ -0,0 +1,1335 @@ +/* + * Copyright (C) 2006 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.actionbarsherlock.internal.view.menu; + + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; + +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; +import android.content.res.Configuration; +import android.content.res.Resources; +import android.graphics.drawable.Drawable; +import android.os.Bundle; +import android.os.Parcelable; +import android.util.SparseArray; +import android.view.ContextMenu.ContextMenuInfo; +import android.view.KeyCharacterMap; +import android.view.KeyEvent; +import android.view.View; + +import com.actionbarsherlock.R; +import com.actionbarsherlock.view.ActionProvider; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuItem; +import com.actionbarsherlock.view.SubMenu; + +/** + * Implementation of the {@link android.view.Menu} interface for creating a + * standard menu UI. + */ +public class MenuBuilder implements Menu { + //UNUSED private static final String TAG = "MenuBuilder"; + + private static final String PRESENTER_KEY = "android:menu:presenters"; + private static final String ACTION_VIEW_STATES_KEY = "android:menu:actionviewstates"; + private static final String EXPANDED_ACTION_VIEW_ID = "android:menu:expandedactionview"; + + private static final int[] sCategoryToOrder = new int[] { + 1, /* No category */ + 4, /* CONTAINER */ + 5, /* SYSTEM */ + 3, /* SECONDARY */ + 2, /* ALTERNATIVE */ + 0, /* SELECTED_ALTERNATIVE */ + }; + + private final Context mContext; + private final Resources mResources; + + /** + * Whether the shortcuts should be qwerty-accessible. Use isQwertyMode() + * instead of accessing this directly. + */ + private boolean mQwertyMode; + + /** + * Whether the shortcuts should be visible on menus. Use isShortcutsVisible() + * instead of accessing this directly. + */ + private boolean mShortcutsVisible; + + /** + * Callback that will receive the various menu-related events generated by + * this class. Use getCallback to get a reference to the callback. + */ + private Callback mCallback; + + /** Contains all of the items for this menu */ + private ArrayList mItems; + + /** Contains only the items that are currently visible. This will be created/refreshed from + * {@link #getVisibleItems()} */ + private ArrayList mVisibleItems; + /** + * Whether or not the items (or any one item's shown state) has changed since it was last + * fetched from {@link #getVisibleItems()} + */ + private boolean mIsVisibleItemsStale; + + /** + * Contains only the items that should appear in the Action Bar, if present. + */ + private ArrayList mActionItems; + /** + * Contains items that should NOT appear in the Action Bar, if present. + */ + private ArrayList mNonActionItems; + + /** + * Whether or not the items (or any one item's action state) has changed since it was + * last fetched. + */ + private boolean mIsActionItemsStale; + + /** + * Default value for how added items should show in the action list. + */ + private int mDefaultShowAsAction = MenuItem.SHOW_AS_ACTION_NEVER; + + /** + * Current use case is Context Menus: As Views populate the context menu, each one has + * extra information that should be passed along. This is the current menu info that + * should be set on all items added to this menu. + */ + private ContextMenuInfo mCurrentMenuInfo; + + /** Header title for menu types that have a header (context and submenus) */ + CharSequence mHeaderTitle; + /** Header icon for menu types that have a header and support icons (context) */ + Drawable mHeaderIcon; + /** Header custom view for menu types that have a header and support custom views (context) */ + View mHeaderView; + + /** + * Contains the state of the View hierarchy for all menu views when the menu + * was frozen. + */ + //UNUSED private SparseArray mFrozenViewStates; + + /** + * Prevents onItemsChanged from doing its junk, useful for batching commands + * that may individually call onItemsChanged. + */ + private boolean mPreventDispatchingItemsChanged = false; + private boolean mItemsChangedWhileDispatchPrevented = false; + + private boolean mOptionalIconsVisible = false; + + private boolean mIsClosing = false; + + private ArrayList mTempShortcutItemList = new ArrayList(); + + private CopyOnWriteArrayList> mPresenters = + new CopyOnWriteArrayList>(); + + /** + * Currently expanded menu item; must be collapsed when we clear. + */ + private MenuItemImpl mExpandedItem; + + /** + * Called by menu to notify of close and selection changes. + */ + public interface Callback { + /** + * Called when a menu item is selected. + * @param menu The menu that is the parent of the item + * @param item The menu item that is selected + * @return whether the menu item selection was handled + */ + public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item); + + /** + * Called when the mode of the menu changes (for example, from icon to expanded). + * + * @param menu the menu that has changed modes + */ + public void onMenuModeChange(MenuBuilder menu); + } + + /** + * Called by menu items to execute their associated action + */ + public interface ItemInvoker { + public boolean invokeItem(MenuItemImpl item); + } + + public MenuBuilder(Context context) { + mContext = context; + mResources = context.getResources(); + + mItems = new ArrayList(); + + mVisibleItems = new ArrayList(); + mIsVisibleItemsStale = true; + + mActionItems = new ArrayList(); + mNonActionItems = new ArrayList(); + mIsActionItemsStale = true; + + setShortcutsVisibleInner(true); + } + + public MenuBuilder setDefaultShowAsAction(int defaultShowAsAction) { + mDefaultShowAsAction = defaultShowAsAction; + return this; + } + + /** + * Add a presenter to this menu. This will only hold a WeakReference; + * you do not need to explicitly remove a presenter, but you can using + * {@link #removeMenuPresenter(MenuPresenter)}. + * + * @param presenter The presenter to add + */ + public void addMenuPresenter(MenuPresenter presenter) { + mPresenters.add(new WeakReference(presenter)); + presenter.initForMenu(mContext, this); + mIsActionItemsStale = true; + } + + /** + * Remove a presenter from this menu. That presenter will no longer + * receive notifications of updates to this menu's data. + * + * @param presenter The presenter to remove + */ + public void removeMenuPresenter(MenuPresenter presenter) { + for (WeakReference ref : mPresenters) { + final MenuPresenter item = ref.get(); + if (item == null || item == presenter) { + mPresenters.remove(ref); + } + } + } + + private void dispatchPresenterUpdate(boolean cleared) { + if (mPresenters.isEmpty()) return; + + stopDispatchingItemsChanged(); + for (WeakReference ref : mPresenters) { + final MenuPresenter presenter = ref.get(); + if (presenter == null) { + mPresenters.remove(ref); + } else { + presenter.updateMenuView(cleared); + } + } + startDispatchingItemsChanged(); + } + + private boolean dispatchSubMenuSelected(SubMenuBuilder subMenu) { + if (mPresenters.isEmpty()) return false; + + boolean result = false; + + for (WeakReference ref : mPresenters) { + final MenuPresenter presenter = ref.get(); + if (presenter == null) { + mPresenters.remove(ref); + } else if (!result) { + result = presenter.onSubMenuSelected(subMenu); + } + } + return result; + } + + private void dispatchSaveInstanceState(Bundle outState) { + if (mPresenters.isEmpty()) return; + + SparseArray presenterStates = new SparseArray(); + + for (WeakReference ref : mPresenters) { + final MenuPresenter presenter = ref.get(); + if (presenter == null) { + mPresenters.remove(ref); + } else { + final int id = presenter.getId(); + if (id > 0) { + final Parcelable state = presenter.onSaveInstanceState(); + if (state != null) { + presenterStates.put(id, state); + } + } + } + } + + outState.putSparseParcelableArray(PRESENTER_KEY, presenterStates); + } + + private void dispatchRestoreInstanceState(Bundle state) { + SparseArray presenterStates = state.getSparseParcelableArray(PRESENTER_KEY); + + if (presenterStates == null || mPresenters.isEmpty()) return; + + for (WeakReference ref : mPresenters) { + final MenuPresenter presenter = ref.get(); + if (presenter == null) { + mPresenters.remove(ref); + } else { + final int id = presenter.getId(); + if (id > 0) { + Parcelable parcel = presenterStates.get(id); + if (parcel != null) { + presenter.onRestoreInstanceState(parcel); + } + } + } + } + } + + public void savePresenterStates(Bundle outState) { + dispatchSaveInstanceState(outState); + } + + public void restorePresenterStates(Bundle state) { + dispatchRestoreInstanceState(state); + } + + public void saveActionViewStates(Bundle outStates) { + SparseArray viewStates = null; + + final int itemCount = size(); + for (int i = 0; i < itemCount; i++) { + final MenuItem item = getItem(i); + final View v = item.getActionView(); + if (v != null && v.getId() != View.NO_ID) { + if (viewStates == null) { + viewStates = new SparseArray(); + } + v.saveHierarchyState(viewStates); + if (item.isActionViewExpanded()) { + outStates.putInt(EXPANDED_ACTION_VIEW_ID, item.getItemId()); + } + } + if (item.hasSubMenu()) { + final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu(); + subMenu.saveActionViewStates(outStates); + } + } + + if (viewStates != null) { + outStates.putSparseParcelableArray(getActionViewStatesKey(), viewStates); + } + } + + public void restoreActionViewStates(Bundle states) { + if (states == null) { + return; + } + + SparseArray viewStates = states.getSparseParcelableArray( + getActionViewStatesKey()); + + final int itemCount = size(); + for (int i = 0; i < itemCount; i++) { + final MenuItem item = getItem(i); + final View v = item.getActionView(); + if (v != null && v.getId() != View.NO_ID) { + v.restoreHierarchyState(viewStates); + } + if (item.hasSubMenu()) { + final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu(); + subMenu.restoreActionViewStates(states); + } + } + + final int expandedId = states.getInt(EXPANDED_ACTION_VIEW_ID); + if (expandedId > 0) { + MenuItem itemToExpand = findItem(expandedId); + if (itemToExpand != null) { + itemToExpand.expandActionView(); + } + } + } + + protected String getActionViewStatesKey() { + return ACTION_VIEW_STATES_KEY; + } + + public void setCallback(Callback cb) { + mCallback = cb; + } + + /** + * Adds an item to the menu. The other add methods funnel to this. + */ + private MenuItem addInternal(int group, int id, int categoryOrder, CharSequence title) { + final int ordering = getOrdering(categoryOrder); + + final MenuItemImpl item = new MenuItemImpl(this, group, id, categoryOrder, + ordering, title, mDefaultShowAsAction); + + if (mCurrentMenuInfo != null) { + // Pass along the current menu info + item.setMenuInfo(mCurrentMenuInfo); + } + + mItems.add(findInsertIndex(mItems, ordering), item); + onItemsChanged(true); + + return item; + } + + public MenuItem add(CharSequence title) { + return addInternal(0, 0, 0, title); + } + + public MenuItem add(int titleRes) { + return addInternal(0, 0, 0, mResources.getString(titleRes)); + } + + public MenuItem add(int group, int id, int categoryOrder, CharSequence title) { + return addInternal(group, id, categoryOrder, title); + } + + public MenuItem add(int group, int id, int categoryOrder, int title) { + return addInternal(group, id, categoryOrder, mResources.getString(title)); + } + + public SubMenu addSubMenu(CharSequence title) { + return addSubMenu(0, 0, 0, title); + } + + public SubMenu addSubMenu(int titleRes) { + return addSubMenu(0, 0, 0, mResources.getString(titleRes)); + } + + public SubMenu addSubMenu(int group, int id, int categoryOrder, CharSequence title) { + final MenuItemImpl item = (MenuItemImpl) addInternal(group, id, categoryOrder, title); + final SubMenuBuilder subMenu = new SubMenuBuilder(mContext, this, item); + item.setSubMenu(subMenu); + + return subMenu; + } + + public SubMenu addSubMenu(int group, int id, int categoryOrder, int title) { + return addSubMenu(group, id, categoryOrder, mResources.getString(title)); + } + + public int addIntentOptions(int group, int id, int categoryOrder, ComponentName caller, + Intent[] specifics, Intent intent, int flags, MenuItem[] outSpecificItems) { + PackageManager pm = mContext.getPackageManager(); + final List lri = + pm.queryIntentActivityOptions(caller, specifics, intent, 0); + final int N = lri != null ? lri.size() : 0; + + if ((flags & FLAG_APPEND_TO_GROUP) == 0) { + removeGroup(group); + } + + for (int i=0; i= 0) { + outSpecificItems[ri.specificIndex] = item; + } + } + + return N; + } + + public void removeItem(int id) { + removeItemAtInt(findItemIndex(id), true); + } + + public void removeGroup(int group) { + final int i = findGroupIndex(group); + + if (i >= 0) { + final int maxRemovable = mItems.size() - i; + int numRemoved = 0; + while ((numRemoved++ < maxRemovable) && (mItems.get(i).getGroupId() == group)) { + // Don't force update for each one, this method will do it at the end + removeItemAtInt(i, false); + } + + // Notify menu views + onItemsChanged(true); + } + } + + /** + * Remove the item at the given index and optionally forces menu views to + * update. + * + * @param index The index of the item to be removed. If this index is + * invalid an exception is thrown. + * @param updateChildrenOnMenuViews Whether to force update on menu views. + * Please make sure you eventually call this after your batch of + * removals. + */ + private void removeItemAtInt(int index, boolean updateChildrenOnMenuViews) { + if ((index < 0) || (index >= mItems.size())) return; + + mItems.remove(index); + + if (updateChildrenOnMenuViews) onItemsChanged(true); + } + + public void removeItemAt(int index) { + removeItemAtInt(index, true); + } + + public void clearAll() { + mPreventDispatchingItemsChanged = true; + clear(); + clearHeader(); + mPreventDispatchingItemsChanged = false; + mItemsChangedWhileDispatchPrevented = false; + onItemsChanged(true); + } + + public void clear() { + if (mExpandedItem != null) { + collapseItemActionView(mExpandedItem); + } + mItems.clear(); + + onItemsChanged(true); + } + + void setExclusiveItemChecked(MenuItem item) { + final int group = item.getGroupId(); + + final int N = mItems.size(); + for (int i = 0; i < N; i++) { + MenuItemImpl curItem = mItems.get(i); + if (curItem.getGroupId() == group) { + if (!curItem.isExclusiveCheckable()) continue; + if (!curItem.isCheckable()) continue; + + // Check the item meant to be checked, uncheck the others (that are in the group) + curItem.setCheckedInt(curItem == item); + } + } + } + + public void setGroupCheckable(int group, boolean checkable, boolean exclusive) { + final int N = mItems.size(); + + for (int i = 0; i < N; i++) { + MenuItemImpl item = mItems.get(i); + if (item.getGroupId() == group) { + item.setExclusiveCheckable(exclusive); + item.setCheckable(checkable); + } + } + } + + public void setGroupVisible(int group, boolean visible) { + final int N = mItems.size(); + + // We handle the notification of items being changed ourselves, so we use setVisibleInt rather + // than setVisible and at the end notify of items being changed + + boolean changedAtLeastOneItem = false; + for (int i = 0; i < N; i++) { + MenuItemImpl item = mItems.get(i); + if (item.getGroupId() == group) { + if (item.setVisibleInt(visible)) changedAtLeastOneItem = true; + } + } + + if (changedAtLeastOneItem) onItemsChanged(true); + } + + public void setGroupEnabled(int group, boolean enabled) { + final int N = mItems.size(); + + for (int i = 0; i < N; i++) { + MenuItemImpl item = mItems.get(i); + if (item.getGroupId() == group) { + item.setEnabled(enabled); + } + } + } + + public boolean hasVisibleItems() { + final int size = size(); + + for (int i = 0; i < size; i++) { + MenuItemImpl item = mItems.get(i); + if (item.isVisible()) { + return true; + } + } + + return false; + } + + public MenuItem findItem(int id) { + final int size = size(); + for (int i = 0; i < size; i++) { + MenuItemImpl item = mItems.get(i); + if (item.getItemId() == id) { + return item; + } else if (item.hasSubMenu()) { + MenuItem possibleItem = item.getSubMenu().findItem(id); + + if (possibleItem != null) { + return possibleItem; + } + } + } + + return null; + } + + public int findItemIndex(int id) { + final int size = size(); + + for (int i = 0; i < size; i++) { + MenuItemImpl item = mItems.get(i); + if (item.getItemId() == id) { + return i; + } + } + + return -1; + } + + public int findGroupIndex(int group) { + return findGroupIndex(group, 0); + } + + public int findGroupIndex(int group, int start) { + final int size = size(); + + if (start < 0) { + start = 0; + } + + for (int i = start; i < size; i++) { + final MenuItemImpl item = mItems.get(i); + + if (item.getGroupId() == group) { + return i; + } + } + + return -1; + } + + public int size() { + return mItems.size(); + } + + /** {@inheritDoc} */ + public MenuItem getItem(int index) { + return mItems.get(index); + } + + public boolean isShortcutKey(int keyCode, KeyEvent event) { + return findItemWithShortcutForKey(keyCode, event) != null; + } + + public void setQwertyMode(boolean isQwerty) { + mQwertyMode = isQwerty; + + onItemsChanged(false); + } + + /** + * Returns the ordering across all items. This will grab the category from + * the upper bits, find out how to order the category with respect to other + * categories, and combine it with the lower bits. + * + * @param categoryOrder The category order for a particular item (if it has + * not been or/add with a category, the default category is + * assumed). + * @return An ordering integer that can be used to order this item across + * all the items (even from other categories). + */ + private static int getOrdering(int categoryOrder) { + final int index = (categoryOrder & CATEGORY_MASK) >> CATEGORY_SHIFT; + + if (index < 0 || index >= sCategoryToOrder.length) { + throw new IllegalArgumentException("order does not contain a valid category."); + } + + return (sCategoryToOrder[index] << CATEGORY_SHIFT) | (categoryOrder & USER_MASK); + } + + /** + * @return whether the menu shortcuts are in qwerty mode or not + */ + boolean isQwertyMode() { + return mQwertyMode; + } + + /** + * Sets whether the shortcuts should be visible on menus. Devices without hardware + * key input will never make shortcuts visible even if this method is passed 'true'. + * + * @param shortcutsVisible Whether shortcuts should be visible (if true and a + * menu item does not have a shortcut defined, that item will + * still NOT show a shortcut) + */ + public void setShortcutsVisible(boolean shortcutsVisible) { + if (mShortcutsVisible == shortcutsVisible) return; + + setShortcutsVisibleInner(shortcutsVisible); + onItemsChanged(false); + } + + private void setShortcutsVisibleInner(boolean shortcutsVisible) { + mShortcutsVisible = shortcutsVisible + && mResources.getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS + && mResources.getBoolean( + R.bool.abs__config_showMenuShortcutsWhenKeyboardPresent); + } + + /** + * @return Whether shortcuts should be visible on menus. + */ + public boolean isShortcutsVisible() { + return mShortcutsVisible; + } + + Resources getResources() { + return mResources; + } + + public Context getContext() { + return mContext; + } + + boolean dispatchMenuItemSelected(MenuBuilder menu, MenuItem item) { + return mCallback != null && mCallback.onMenuItemSelected(menu, item); + } + + /** + * Dispatch a mode change event to this menu's callback. + */ + public void changeMenuMode() { + if (mCallback != null) { + mCallback.onMenuModeChange(this); + } + } + + private static int findInsertIndex(ArrayList items, int ordering) { + for (int i = items.size() - 1; i >= 0; i--) { + MenuItemImpl item = items.get(i); + if (item.getOrdering() <= ordering) { + return i + 1; + } + } + + return 0; + } + + public boolean performShortcut(int keyCode, KeyEvent event, int flags) { + final MenuItemImpl item = findItemWithShortcutForKey(keyCode, event); + + boolean handled = false; + + if (item != null) { + handled = performItemAction(item, flags); + } + + if ((flags & FLAG_ALWAYS_PERFORM_CLOSE) != 0) { + close(true); + } + + return handled; + } + + /* + * This function will return all the menu and sub-menu items that can + * be directly (the shortcut directly corresponds) and indirectly + * (the ALT-enabled char corresponds to the shortcut) associated + * with the keyCode. + */ + @SuppressWarnings("deprecation") + void findItemsWithShortcutForKey(List items, int keyCode, KeyEvent event) { + final boolean qwerty = isQwertyMode(); + final int metaState = event.getMetaState(); + final KeyCharacterMap.KeyData possibleChars = new KeyCharacterMap.KeyData(); + // Get the chars associated with the keyCode (i.e using any chording combo) + final boolean isKeyCodeMapped = event.getKeyData(possibleChars); + // The delete key is not mapped to '\b' so we treat it specially + if (!isKeyCodeMapped && (keyCode != KeyEvent.KEYCODE_DEL)) { + return; + } + + // Look for an item whose shortcut is this key. + final int N = mItems.size(); + for (int i = 0; i < N; i++) { + MenuItemImpl item = mItems.get(i); + if (item.hasSubMenu()) { + ((MenuBuilder)item.getSubMenu()).findItemsWithShortcutForKey(items, keyCode, event); + } + final char shortcutChar = qwerty ? item.getAlphabeticShortcut() : item.getNumericShortcut(); + if (((metaState & (KeyEvent.META_SHIFT_ON | KeyEvent.META_SYM_ON)) == 0) && + (shortcutChar != 0) && + (shortcutChar == possibleChars.meta[0] + || shortcutChar == possibleChars.meta[2] + || (qwerty && shortcutChar == '\b' && + keyCode == KeyEvent.KEYCODE_DEL)) && + item.isEnabled()) { + items.add(item); + } + } + } + + /* + * We want to return the menu item associated with the key, but if there is no + * ambiguity (i.e. there is only one menu item corresponding to the key) we want + * to return it even if it's not an exact match; this allow the user to + * _not_ use the ALT key for example, making the use of shortcuts slightly more + * user-friendly. An example is on the G1, '!' and '1' are on the same key, and + * in Gmail, Menu+1 will trigger Menu+! (the actual shortcut). + * + * On the other hand, if two (or more) shortcuts corresponds to the same key, + * we have to only return the exact match. + */ + @SuppressWarnings("deprecation") + MenuItemImpl findItemWithShortcutForKey(int keyCode, KeyEvent event) { + // Get all items that can be associated directly or indirectly with the keyCode + ArrayList items = mTempShortcutItemList; + items.clear(); + findItemsWithShortcutForKey(items, keyCode, event); + + if (items.isEmpty()) { + return null; + } + + final int metaState = event.getMetaState(); + final KeyCharacterMap.KeyData possibleChars = new KeyCharacterMap.KeyData(); + // Get the chars associated with the keyCode (i.e using any chording combo) + event.getKeyData(possibleChars); + + // If we have only one element, we can safely returns it + final int size = items.size(); + if (size == 1) { + return items.get(0); + } + + final boolean qwerty = isQwertyMode(); + // If we found more than one item associated with the key, + // we have to return the exact match + for (int i = 0; i < size; i++) { + final MenuItemImpl item = items.get(i); + final char shortcutChar = qwerty ? item.getAlphabeticShortcut() : + item.getNumericShortcut(); + if ((shortcutChar == possibleChars.meta[0] && + (metaState & KeyEvent.META_ALT_ON) == 0) + || (shortcutChar == possibleChars.meta[2] && + (metaState & KeyEvent.META_ALT_ON) != 0) + || (qwerty && shortcutChar == '\b' && + keyCode == KeyEvent.KEYCODE_DEL)) { + return item; + } + } + return null; + } + + public boolean performIdentifierAction(int id, int flags) { + // Look for an item whose identifier is the id. + return performItemAction(findItem(id), flags); + } + + public boolean performItemAction(MenuItem item, int flags) { + MenuItemImpl itemImpl = (MenuItemImpl) item; + + if (itemImpl == null || !itemImpl.isEnabled()) { + return false; + } + + boolean invoked = itemImpl.invoke(); + + if (itemImpl.hasCollapsibleActionView()) { + invoked |= itemImpl.expandActionView(); + if (invoked) close(true); + } else if (item.hasSubMenu()) { + close(false); + + final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu(); + final ActionProvider provider = item.getActionProvider(); + if (provider != null && provider.hasSubMenu()) { + provider.onPrepareSubMenu(subMenu); + } + invoked |= dispatchSubMenuSelected(subMenu); + if (!invoked) close(true); + } else { + if ((flags & FLAG_PERFORM_NO_CLOSE) == 0) { + close(true); + } + } + + return invoked; + } + + /** + * Closes the visible menu. + * + * @param allMenusAreClosing Whether the menus are completely closing (true), + * or whether there is another menu coming in this menu's place + * (false). For example, if the menu is closing because a + * sub menu is about to be shown, allMenusAreClosing + * is false. + */ + final void close(boolean allMenusAreClosing) { + if (mIsClosing) return; + + mIsClosing = true; + for (WeakReference ref : mPresenters) { + final MenuPresenter presenter = ref.get(); + if (presenter == null) { + mPresenters.remove(ref); + } else { + presenter.onCloseMenu(this, allMenusAreClosing); + } + } + mIsClosing = false; + } + + /** {@inheritDoc} */ + public void close() { + close(true); + } + + /** + * Called when an item is added or removed. + * + * @param structureChanged true if the menu structure changed, + * false if only item properties changed. + * (Visibility is a structural property since it affects layout.) + */ + void onItemsChanged(boolean structureChanged) { + if (!mPreventDispatchingItemsChanged) { + if (structureChanged) { + mIsVisibleItemsStale = true; + mIsActionItemsStale = true; + } + + dispatchPresenterUpdate(structureChanged); + } else { + mItemsChangedWhileDispatchPrevented = true; + } + } + + /** + * Stop dispatching item changed events to presenters until + * {@link #startDispatchingItemsChanged()} is called. Useful when + * many menu operations are going to be performed as a batch. + */ + public void stopDispatchingItemsChanged() { + if (!mPreventDispatchingItemsChanged) { + mPreventDispatchingItemsChanged = true; + mItemsChangedWhileDispatchPrevented = false; + } + } + + public void startDispatchingItemsChanged() { + mPreventDispatchingItemsChanged = false; + + if (mItemsChangedWhileDispatchPrevented) { + mItemsChangedWhileDispatchPrevented = false; + onItemsChanged(true); + } + } + + /** + * Called by {@link MenuItemImpl} when its visible flag is changed. + * @param item The item that has gone through a visibility change. + */ + void onItemVisibleChanged(MenuItemImpl item) { + // Notify of items being changed + mIsVisibleItemsStale = true; + onItemsChanged(true); + } + + /** + * Called by {@link MenuItemImpl} when its action request status is changed. + * @param item The item that has gone through a change in action request status. + */ + void onItemActionRequestChanged(MenuItemImpl item) { + // Notify of items being changed + mIsActionItemsStale = true; + onItemsChanged(true); + } + + ArrayList getVisibleItems() { + if (!mIsVisibleItemsStale) return mVisibleItems; + + // Refresh the visible items + mVisibleItems.clear(); + + final int itemsSize = mItems.size(); + MenuItemImpl item; + for (int i = 0; i < itemsSize; i++) { + item = mItems.get(i); + if (item.isVisible()) mVisibleItems.add(item); + } + + mIsVisibleItemsStale = false; + mIsActionItemsStale = true; + + return mVisibleItems; + } + + /** + * This method determines which menu items get to be 'action items' that will appear + * in an action bar and which items should be 'overflow items' in a secondary menu. + * The rules are as follows: + * + *

Items are considered for inclusion in the order specified within the menu. + * There is a limit of mMaxActionItems as a total count, optionally including the overflow + * menu button itself. This is a soft limit; if an item shares a group ID with an item + * previously included as an action item, the new item will stay with its group and become + * an action item itself even if it breaks the max item count limit. This is done to + * limit the conceptual complexity of the items presented within an action bar. Only a few + * unrelated concepts should be presented to the user in this space, and groups are treated + * as a single concept. + * + *

There is also a hard limit of consumed measurable space: mActionWidthLimit. This + * limit may be broken by a single item that exceeds the remaining space, but no further + * items may be added. If an item that is part of a group cannot fit within the remaining + * measured width, the entire group will be demoted to overflow. This is done to ensure room + * for navigation and other affordances in the action bar as well as reduce general UI clutter. + * + *

The space freed by demoting a full group cannot be consumed by future menu items. + * Once items begin to overflow, all future items become overflow items as well. This is + * to avoid inadvertent reordering that may break the app's intended design. + */ + public void flagActionItems() { + if (!mIsActionItemsStale) { + return; + } + + // Presenters flag action items as needed. + boolean flagged = false; + for (WeakReference ref : mPresenters) { + final MenuPresenter presenter = ref.get(); + if (presenter == null) { + mPresenters.remove(ref); + } else { + flagged |= presenter.flagActionItems(); + } + } + + if (flagged) { + mActionItems.clear(); + mNonActionItems.clear(); + ArrayList visibleItems = getVisibleItems(); + final int itemsSize = visibleItems.size(); + for (int i = 0; i < itemsSize; i++) { + MenuItemImpl item = visibleItems.get(i); + if (item.isActionButton()) { + mActionItems.add(item); + } else { + mNonActionItems.add(item); + } + } + } else { + // Nobody flagged anything, everything is a non-action item. + // (This happens during a first pass with no action-item presenters.) + mActionItems.clear(); + mNonActionItems.clear(); + mNonActionItems.addAll(getVisibleItems()); + } + mIsActionItemsStale = false; + } + + ArrayList getActionItems() { + flagActionItems(); + return mActionItems; + } + + ArrayList getNonActionItems() { + flagActionItems(); + return mNonActionItems; + } + + public void clearHeader() { + mHeaderIcon = null; + mHeaderTitle = null; + mHeaderView = null; + + onItemsChanged(false); + } + + private void setHeaderInternal(final int titleRes, final CharSequence title, final int iconRes, + final Drawable icon, final View view) { + final Resources r = getResources(); + + if (view != null) { + mHeaderView = view; + + // If using a custom view, then the title and icon aren't used + mHeaderTitle = null; + mHeaderIcon = null; + } else { + if (titleRes > 0) { + mHeaderTitle = r.getText(titleRes); + } else if (title != null) { + mHeaderTitle = title; + } + + if (iconRes > 0) { + mHeaderIcon = r.getDrawable(iconRes); + } else if (icon != null) { + mHeaderIcon = icon; + } + + // If using the title or icon, then a custom view isn't used + mHeaderView = null; + } + + // Notify of change + onItemsChanged(false); + } + + /** + * Sets the header's title. This replaces the header view. Called by the + * builder-style methods of subclasses. + * + * @param title The new title. + * @return This MenuBuilder so additional setters can be called. + */ + protected MenuBuilder setHeaderTitleInt(CharSequence title) { + setHeaderInternal(0, title, 0, null, null); + return this; + } + + /** + * Sets the header's title. This replaces the header view. Called by the + * builder-style methods of subclasses. + * + * @param titleRes The new title (as a resource ID). + * @return This MenuBuilder so additional setters can be called. + */ + protected MenuBuilder setHeaderTitleInt(int titleRes) { + setHeaderInternal(titleRes, null, 0, null, null); + return this; + } + + /** + * Sets the header's icon. This replaces the header view. Called by the + * builder-style methods of subclasses. + * + * @param icon The new icon. + * @return This MenuBuilder so additional setters can be called. + */ + protected MenuBuilder setHeaderIconInt(Drawable icon) { + setHeaderInternal(0, null, 0, icon, null); + return this; + } + + /** + * Sets the header's icon. This replaces the header view. Called by the + * builder-style methods of subclasses. + * + * @param iconRes The new icon (as a resource ID). + * @return This MenuBuilder so additional setters can be called. + */ + protected MenuBuilder setHeaderIconInt(int iconRes) { + setHeaderInternal(0, null, iconRes, null, null); + return this; + } + + /** + * Sets the header's view. This replaces the title and icon. Called by the + * builder-style methods of subclasses. + * + * @param view The new view. + * @return This MenuBuilder so additional setters can be called. + */ + protected MenuBuilder setHeaderViewInt(View view) { + setHeaderInternal(0, null, 0, null, view); + return this; + } + + public CharSequence getHeaderTitle() { + return mHeaderTitle; + } + + public Drawable getHeaderIcon() { + return mHeaderIcon; + } + + public View getHeaderView() { + return mHeaderView; + } + + /** + * Gets the root menu (if this is a submenu, find its root menu). + * @return The root menu. + */ + public MenuBuilder getRootMenu() { + return this; + } + + /** + * Sets the current menu info that is set on all items added to this menu + * (until this is called again with different menu info, in which case that + * one will be added to all subsequent item additions). + * + * @param menuInfo The extra menu information to add. + */ + public void setCurrentMenuInfo(ContextMenuInfo menuInfo) { + mCurrentMenuInfo = menuInfo; + } + + void setOptionalIconsVisible(boolean visible) { + mOptionalIconsVisible = visible; + } + + boolean getOptionalIconsVisible() { + return mOptionalIconsVisible; + } + + public boolean expandItemActionView(MenuItemImpl item) { + if (mPresenters.isEmpty()) return false; + + boolean expanded = false; + + stopDispatchingItemsChanged(); + for (WeakReference ref : mPresenters) { + final MenuPresenter presenter = ref.get(); + if (presenter == null) { + mPresenters.remove(ref); + } else if ((expanded = presenter.expandItemActionView(this, item))) { + break; + } + } + startDispatchingItemsChanged(); + + if (expanded) { + mExpandedItem = item; + } + return expanded; + } + + public boolean collapseItemActionView(MenuItemImpl item) { + if (mPresenters.isEmpty() || mExpandedItem != item) return false; + + boolean collapsed = false; + + stopDispatchingItemsChanged(); + for (WeakReference ref : mPresenters) { + final MenuPresenter presenter = ref.get(); + if (presenter == null) { + mPresenters.remove(ref); + } else if ((collapsed = presenter.collapseItemActionView(this, item))) { + break; + } + } + startDispatchingItemsChanged(); + + if (collapsed) { + mExpandedItem = null; + } + return collapsed; + } + + public MenuItemImpl getExpandedItem() { + return mExpandedItem; + } + + public boolean bindNativeOverflow(android.view.Menu menu, android.view.MenuItem.OnMenuItemClickListener listener, HashMap map) { + final List nonActionItems = getNonActionItems(); + if (nonActionItems == null || nonActionItems.size() == 0) { + return false; + } + + boolean visible = false; + menu.clear(); + for (MenuItemImpl nonActionItem : nonActionItems) { + if (!nonActionItem.isVisible()) { + continue; + } + visible = true; + + android.view.MenuItem nativeItem; + if (nonActionItem.hasSubMenu()) { + android.view.SubMenu nativeSub = menu.addSubMenu(nonActionItem.getGroupId(), nonActionItem.getItemId(), + nonActionItem.getOrder(), nonActionItem.getTitle()); + + SubMenuBuilder subMenu = (SubMenuBuilder)nonActionItem.getSubMenu(); + for (MenuItemImpl subItem : subMenu.getVisibleItems()) { + android.view.MenuItem nativeSubItem = nativeSub.add(subItem.getGroupId(), subItem.getItemId(), + subItem.getOrder(), subItem.getTitle()); + + nativeSubItem.setIcon(subItem.getIcon()); + nativeSubItem.setOnMenuItemClickListener(listener); + nativeSubItem.setEnabled(subItem.isEnabled()); + nativeSubItem.setIntent(subItem.getIntent()); + nativeSubItem.setNumericShortcut(subItem.getNumericShortcut()); + nativeSubItem.setAlphabeticShortcut(subItem.getAlphabeticShortcut()); + nativeSubItem.setTitleCondensed(subItem.getTitleCondensed()); + nativeSubItem.setCheckable(subItem.isCheckable()); + nativeSubItem.setChecked(subItem.isChecked()); + + if (subItem.isExclusiveCheckable()) { + nativeSub.setGroupCheckable(subItem.getGroupId(), true, true); + } + + map.put(nativeSubItem, subItem); + } + + nativeItem = nativeSub.getItem(); + } else { + nativeItem = menu.add(nonActionItem.getGroupId(), nonActionItem.getItemId(), + nonActionItem.getOrder(), nonActionItem.getTitle()); + } + nativeItem.setIcon(nonActionItem.getIcon()); + nativeItem.setOnMenuItemClickListener(listener); + nativeItem.setEnabled(nonActionItem.isEnabled()); + nativeItem.setIntent(nonActionItem.getIntent()); + nativeItem.setNumericShortcut(nonActionItem.getNumericShortcut()); + nativeItem.setAlphabeticShortcut(nonActionItem.getAlphabeticShortcut()); + nativeItem.setTitleCondensed(nonActionItem.getTitleCondensed()); + nativeItem.setCheckable(nonActionItem.isCheckable()); + nativeItem.setChecked(nonActionItem.isChecked()); + + if (nonActionItem.isExclusiveCheckable()) { + menu.setGroupCheckable(nonActionItem.getGroupId(), true, true); + } + + map.put(nativeItem, nonActionItem); + } + return visible; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemImpl.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemImpl.java new file mode 100644 index 000000000..f5359fb40 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemImpl.java @@ -0,0 +1,647 @@ +/* + * Copyright (C) 2006 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.actionbarsherlock.internal.view.menu; + +import android.content.ActivityNotFoundException; +import android.content.Context; +import android.content.Intent; +import android.graphics.drawable.Drawable; +import android.util.Log; +import android.view.ContextMenu.ContextMenuInfo; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewDebug; +import android.widget.LinearLayout; + +import com.actionbarsherlock.view.ActionProvider; +import com.actionbarsherlock.view.MenuItem; +import com.actionbarsherlock.view.SubMenu; + +/** + * @hide + */ +public final class MenuItemImpl implements MenuItem { + private static final String TAG = "MenuItemImpl"; + + private static final int SHOW_AS_ACTION_MASK = SHOW_AS_ACTION_NEVER | + SHOW_AS_ACTION_IF_ROOM | + SHOW_AS_ACTION_ALWAYS; + + private final int mId; + private final int mGroup; + private final int mCategoryOrder; + private final int mOrdering; + private CharSequence mTitle; + private CharSequence mTitleCondensed; + private Intent mIntent; + private char mShortcutNumericChar; + private char mShortcutAlphabeticChar; + + /** The icon's drawable which is only created as needed */ + private Drawable mIconDrawable; + /** + * The icon's resource ID which is used to get the Drawable when it is + * needed (if the Drawable isn't already obtained--only one of the two is + * needed). + */ + private int mIconResId = NO_ICON; + + /** The menu to which this item belongs */ + private MenuBuilder mMenu; + /** If this item should launch a sub menu, this is the sub menu to launch */ + private SubMenuBuilder mSubMenu; + + private Runnable mItemCallback; + private MenuItem.OnMenuItemClickListener mClickListener; + + private int mFlags = ENABLED; + private static final int CHECKABLE = 0x00000001; + private static final int CHECKED = 0x00000002; + private static final int EXCLUSIVE = 0x00000004; + private static final int HIDDEN = 0x00000008; + private static final int ENABLED = 0x00000010; + private static final int IS_ACTION = 0x00000020; + + private int mShowAsAction = SHOW_AS_ACTION_NEVER; + + private View mActionView; + private ActionProvider mActionProvider; + private OnActionExpandListener mOnActionExpandListener; + private boolean mIsActionViewExpanded = false; + + /** Used for the icon resource ID if this item does not have an icon */ + static final int NO_ICON = 0; + + /** + * Current use case is for context menu: Extra information linked to the + * View that added this item to the context menu. + */ + private ContextMenuInfo mMenuInfo; + + private static String sPrependShortcutLabel; + private static String sEnterShortcutLabel; + private static String sDeleteShortcutLabel; + private static String sSpaceShortcutLabel; + + + /** + * Instantiates this menu item. + * + * @param menu + * @param group Item ordering grouping control. The item will be added after + * all other items whose order is <= this number, and before any + * that are larger than it. This can also be used to define + * groups of items for batch state changes. Normally use 0. + * @param id Unique item ID. Use 0 if you do not need a unique ID. + * @param categoryOrder The ordering for this item. + * @param title The text to display for the item. + */ + MenuItemImpl(MenuBuilder menu, int group, int id, int categoryOrder, int ordering, + CharSequence title, int showAsAction) { + + /* TODO if (sPrependShortcutLabel == null) { + // This is instantiated from the UI thread, so no chance of sync issues + sPrependShortcutLabel = menu.getContext().getResources().getString( + com.android.internal.R.string.prepend_shortcut_label); + sEnterShortcutLabel = menu.getContext().getResources().getString( + com.android.internal.R.string.menu_enter_shortcut_label); + sDeleteShortcutLabel = menu.getContext().getResources().getString( + com.android.internal.R.string.menu_delete_shortcut_label); + sSpaceShortcutLabel = menu.getContext().getResources().getString( + com.android.internal.R.string.menu_space_shortcut_label); + }*/ + + mMenu = menu; + mId = id; + mGroup = group; + mCategoryOrder = categoryOrder; + mOrdering = ordering; + mTitle = title; + mShowAsAction = showAsAction; + } + + /** + * Invokes the item by calling various listeners or callbacks. + * + * @return true if the invocation was handled, false otherwise + */ + public boolean invoke() { + if (mClickListener != null && + mClickListener.onMenuItemClick(this)) { + return true; + } + + if (mMenu.dispatchMenuItemSelected(mMenu.getRootMenu(), this)) { + return true; + } + + if (mItemCallback != null) { + mItemCallback.run(); + return true; + } + + if (mIntent != null) { + try { + mMenu.getContext().startActivity(mIntent); + return true; + } catch (ActivityNotFoundException e) { + Log.e(TAG, "Can't find activity to handle intent; ignoring", e); + } + } + + if (mActionProvider != null && mActionProvider.onPerformDefaultAction()) { + return true; + } + + return false; + } + + public boolean isEnabled() { + return (mFlags & ENABLED) != 0; + } + + public MenuItem setEnabled(boolean enabled) { + if (enabled) { + mFlags |= ENABLED; + } else { + mFlags &= ~ENABLED; + } + + mMenu.onItemsChanged(false); + + return this; + } + + public int getGroupId() { + return mGroup; + } + + @ViewDebug.CapturedViewProperty + public int getItemId() { + return mId; + } + + public int getOrder() { + return mCategoryOrder; + } + + public int getOrdering() { + return mOrdering; + } + + public Intent getIntent() { + return mIntent; + } + + public MenuItem setIntent(Intent intent) { + mIntent = intent; + return this; + } + + Runnable getCallback() { + return mItemCallback; + } + + public MenuItem setCallback(Runnable callback) { + mItemCallback = callback; + return this; + } + + public char getAlphabeticShortcut() { + return mShortcutAlphabeticChar; + } + + public MenuItem setAlphabeticShortcut(char alphaChar) { + if (mShortcutAlphabeticChar == alphaChar) return this; + + mShortcutAlphabeticChar = Character.toLowerCase(alphaChar); + + mMenu.onItemsChanged(false); + + return this; + } + + public char getNumericShortcut() { + return mShortcutNumericChar; + } + + public MenuItem setNumericShortcut(char numericChar) { + if (mShortcutNumericChar == numericChar) return this; + + mShortcutNumericChar = numericChar; + + mMenu.onItemsChanged(false); + + return this; + } + + public MenuItem setShortcut(char numericChar, char alphaChar) { + mShortcutNumericChar = numericChar; + mShortcutAlphabeticChar = Character.toLowerCase(alphaChar); + + mMenu.onItemsChanged(false); + + return this; + } + + /** + * @return The active shortcut (based on QWERTY-mode of the menu). + */ + char getShortcut() { + return (mMenu.isQwertyMode() ? mShortcutAlphabeticChar : mShortcutNumericChar); + } + + /** + * @return The label to show for the shortcut. This includes the chording + * key (for example 'Menu+a'). Also, any non-human readable + * characters should be human readable (for example 'Menu+enter'). + */ + String getShortcutLabel() { + + char shortcut = getShortcut(); + if (shortcut == 0) { + return ""; + } + + StringBuilder sb = new StringBuilder(sPrependShortcutLabel); + switch (shortcut) { + + case '\n': + sb.append(sEnterShortcutLabel); + break; + + case '\b': + sb.append(sDeleteShortcutLabel); + break; + + case ' ': + sb.append(sSpaceShortcutLabel); + break; + + default: + sb.append(shortcut); + break; + } + + return sb.toString(); + } + + /** + * @return Whether this menu item should be showing shortcuts (depends on + * whether the menu should show shortcuts and whether this item has + * a shortcut defined) + */ + boolean shouldShowShortcut() { + // Show shortcuts if the menu is supposed to show shortcuts AND this item has a shortcut + return mMenu.isShortcutsVisible() && (getShortcut() != 0); + } + + public SubMenu getSubMenu() { + return mSubMenu; + } + + public boolean hasSubMenu() { + return mSubMenu != null; + } + + void setSubMenu(SubMenuBuilder subMenu) { + mSubMenu = subMenu; + + subMenu.setHeaderTitle(getTitle()); + } + + @ViewDebug.CapturedViewProperty + public CharSequence getTitle() { + return mTitle; + } + + /** + * Gets the title for a particular {@link ItemView} + * + * @param itemView The ItemView that is receiving the title + * @return Either the title or condensed title based on what the ItemView + * prefers + */ + CharSequence getTitleForItemView(MenuView.ItemView itemView) { + return ((itemView != null) && itemView.prefersCondensedTitle()) + ? getTitleCondensed() + : getTitle(); + } + + public MenuItem setTitle(CharSequence title) { + mTitle = title; + + mMenu.onItemsChanged(false); + + if (mSubMenu != null) { + mSubMenu.setHeaderTitle(title); + } + + return this; + } + + public MenuItem setTitle(int title) { + return setTitle(mMenu.getContext().getString(title)); + } + + public CharSequence getTitleCondensed() { + return mTitleCondensed != null ? mTitleCondensed : mTitle; + } + + public MenuItem setTitleCondensed(CharSequence title) { + mTitleCondensed = title; + + // Could use getTitle() in the loop below, but just cache what it would do here + if (title == null) { + title = mTitle; + } + + mMenu.onItemsChanged(false); + + return this; + } + + public Drawable getIcon() { + if (mIconDrawable != null) { + return mIconDrawable; + } + + if (mIconResId != NO_ICON) { + return mMenu.getResources().getDrawable(mIconResId); + } + + return null; + } + + public MenuItem setIcon(Drawable icon) { + mIconResId = NO_ICON; + mIconDrawable = icon; + mMenu.onItemsChanged(false); + + return this; + } + + public MenuItem setIcon(int iconResId) { + mIconDrawable = null; + mIconResId = iconResId; + + // If we have a view, we need to push the Drawable to them + mMenu.onItemsChanged(false); + + return this; + } + + public boolean isCheckable() { + return (mFlags & CHECKABLE) == CHECKABLE; + } + + public MenuItem setCheckable(boolean checkable) { + final int oldFlags = mFlags; + mFlags = (mFlags & ~CHECKABLE) | (checkable ? CHECKABLE : 0); + if (oldFlags != mFlags) { + mMenu.onItemsChanged(false); + } + + return this; + } + + public void setExclusiveCheckable(boolean exclusive) { + mFlags = (mFlags & ~EXCLUSIVE) | (exclusive ? EXCLUSIVE : 0); + } + + public boolean isExclusiveCheckable() { + return (mFlags & EXCLUSIVE) != 0; + } + + public boolean isChecked() { + return (mFlags & CHECKED) == CHECKED; + } + + public MenuItem setChecked(boolean checked) { + if ((mFlags & EXCLUSIVE) != 0) { + // Call the method on the Menu since it knows about the others in this + // exclusive checkable group + mMenu.setExclusiveItemChecked(this); + } else { + setCheckedInt(checked); + } + + return this; + } + + void setCheckedInt(boolean checked) { + final int oldFlags = mFlags; + mFlags = (mFlags & ~CHECKED) | (checked ? CHECKED : 0); + if (oldFlags != mFlags) { + mMenu.onItemsChanged(false); + } + } + + public boolean isVisible() { + return (mFlags & HIDDEN) == 0; + } + + /** + * Changes the visibility of the item. This method DOES NOT notify the + * parent menu of a change in this item, so this should only be called from + * methods that will eventually trigger this change. If unsure, use {@link #setVisible(boolean)} + * instead. + * + * @param shown Whether to show (true) or hide (false). + * @return Whether the item's shown state was changed + */ + boolean setVisibleInt(boolean shown) { + final int oldFlags = mFlags; + mFlags = (mFlags & ~HIDDEN) | (shown ? 0 : HIDDEN); + return oldFlags != mFlags; + } + + public MenuItem setVisible(boolean shown) { + // Try to set the shown state to the given state. If the shown state was changed + // (i.e. the previous state isn't the same as given state), notify the parent menu that + // the shown state has changed for this item + if (setVisibleInt(shown)) mMenu.onItemVisibleChanged(this); + + return this; + } + + public MenuItem setOnMenuItemClickListener(MenuItem.OnMenuItemClickListener clickListener) { + mClickListener = clickListener; + return this; + } + + @Override + public String toString() { + return mTitle.toString(); + } + + void setMenuInfo(ContextMenuInfo menuInfo) { + mMenuInfo = menuInfo; + } + + public ContextMenuInfo getMenuInfo() { + return mMenuInfo; + } + + public void actionFormatChanged() { + mMenu.onItemActionRequestChanged(this); + } + + /** + * @return Whether the menu should show icons for menu items. + */ + public boolean shouldShowIcon() { + return mMenu.getOptionalIconsVisible(); + } + + public boolean isActionButton() { + return (mFlags & IS_ACTION) == IS_ACTION; + } + + public boolean requestsActionButton() { + return (mShowAsAction & SHOW_AS_ACTION_IF_ROOM) == SHOW_AS_ACTION_IF_ROOM; + } + + public boolean requiresActionButton() { + return (mShowAsAction & SHOW_AS_ACTION_ALWAYS) == SHOW_AS_ACTION_ALWAYS; + } + + public void setIsActionButton(boolean isActionButton) { + if (isActionButton) { + mFlags |= IS_ACTION; + } else { + mFlags &= ~IS_ACTION; + } + } + + public boolean showsTextAsAction() { + return (mShowAsAction & SHOW_AS_ACTION_WITH_TEXT) == SHOW_AS_ACTION_WITH_TEXT; + } + + public void setShowAsAction(int actionEnum) { + switch (actionEnum & SHOW_AS_ACTION_MASK) { + case SHOW_AS_ACTION_ALWAYS: + case SHOW_AS_ACTION_IF_ROOM: + case SHOW_AS_ACTION_NEVER: + // Looks good! + break; + + default: + // Mutually exclusive options selected! + throw new IllegalArgumentException("SHOW_AS_ACTION_ALWAYS, SHOW_AS_ACTION_IF_ROOM," + + " and SHOW_AS_ACTION_NEVER are mutually exclusive."); + } + mShowAsAction = actionEnum; + mMenu.onItemActionRequestChanged(this); + } + + public MenuItem setActionView(View view) { + mActionView = view; + mActionProvider = null; + if (view != null && view.getId() == View.NO_ID && mId > 0) { + view.setId(mId); + } + mMenu.onItemActionRequestChanged(this); + return this; + } + + public MenuItem setActionView(int resId) { + final Context context = mMenu.getContext(); + final LayoutInflater inflater = LayoutInflater.from(context); + setActionView(inflater.inflate(resId, new LinearLayout(context), false)); + return this; + } + + public View getActionView() { + if (mActionView != null) { + return mActionView; + } else if (mActionProvider != null) { + mActionView = mActionProvider.onCreateActionView(); + return mActionView; + } else { + return null; + } + } + + public ActionProvider getActionProvider() { + return mActionProvider; + } + + public MenuItem setActionProvider(ActionProvider actionProvider) { + mActionView = null; + mActionProvider = actionProvider; + mMenu.onItemsChanged(true); // Measurement can be changed + return this; + } + + @Override + public MenuItem setShowAsActionFlags(int actionEnum) { + setShowAsAction(actionEnum); + return this; + } + + @Override + public boolean expandActionView() { + if ((mShowAsAction & SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW) == 0 || mActionView == null) { + return false; + } + + if (mOnActionExpandListener == null || + mOnActionExpandListener.onMenuItemActionExpand(this)) { + return mMenu.expandItemActionView(this); + } + + return false; + } + + @Override + public boolean collapseActionView() { + if ((mShowAsAction & SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW) == 0) { + return false; + } + if (mActionView == null) { + // We're already collapsed if we have no action view. + return true; + } + + if (mOnActionExpandListener == null || + mOnActionExpandListener.onMenuItemActionCollapse(this)) { + return mMenu.collapseItemActionView(this); + } + + return false; + } + + @Override + public MenuItem setOnActionExpandListener(OnActionExpandListener listener) { + mOnActionExpandListener = listener; + return this; + } + + public boolean hasCollapsibleActionView() { + return (mShowAsAction & SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW) != 0 && mActionView != null; + } + + public void setActionViewExpanded(boolean isExpanded) { + mIsActionViewExpanded = isExpanded; + mMenu.onItemsChanged(false); + } + + public boolean isActionViewExpanded() { + return mIsActionViewExpanded; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemWrapper.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemWrapper.java new file mode 100644 index 000000000..907a7aa04 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemWrapper.java @@ -0,0 +1,292 @@ +package com.actionbarsherlock.internal.view.menu; + +import android.content.Intent; +import android.graphics.drawable.Drawable; +import android.view.View; +import android.view.ContextMenu.ContextMenuInfo; +import com.actionbarsherlock.internal.view.ActionProviderWrapper; +import com.actionbarsherlock.view.ActionProvider; +import com.actionbarsherlock.view.MenuItem; +import com.actionbarsherlock.view.SubMenu; + +public class MenuItemWrapper implements MenuItem, android.view.MenuItem.OnMenuItemClickListener { + private final android.view.MenuItem mNativeItem; + private SubMenu mSubMenu = null; + private OnMenuItemClickListener mMenuItemClickListener = null; + private OnActionExpandListener mActionExpandListener = null; + private android.view.MenuItem.OnActionExpandListener mNativeActionExpandListener = null; + + + public MenuItemWrapper(android.view.MenuItem nativeItem) { + if (nativeItem == null) { + throw new IllegalStateException("Wrapped menu item cannot be null."); + } + mNativeItem = nativeItem; + } + + + @Override + public int getItemId() { + return mNativeItem.getItemId(); + } + + @Override + public int getGroupId() { + return mNativeItem.getGroupId(); + } + + @Override + public int getOrder() { + return mNativeItem.getOrder(); + } + + @Override + public MenuItem setTitle(CharSequence title) { + mNativeItem.setTitle(title); + return this; + } + + @Override + public MenuItem setTitle(int title) { + mNativeItem.setTitle(title); + return this; + } + + @Override + public CharSequence getTitle() { + return mNativeItem.getTitle(); + } + + @Override + public MenuItem setTitleCondensed(CharSequence title) { + mNativeItem.setTitleCondensed(title); + return this; + } + + @Override + public CharSequence getTitleCondensed() { + return mNativeItem.getTitleCondensed(); + } + + @Override + public MenuItem setIcon(Drawable icon) { + mNativeItem.setIcon(icon); + return this; + } + + @Override + public MenuItem setIcon(int iconRes) { + mNativeItem.setIcon(iconRes); + return this; + } + + @Override + public Drawable getIcon() { + return mNativeItem.getIcon(); + } + + @Override + public MenuItem setIntent(Intent intent) { + mNativeItem.setIntent(intent); + return this; + } + + @Override + public Intent getIntent() { + return mNativeItem.getIntent(); + } + + @Override + public MenuItem setShortcut(char numericChar, char alphaChar) { + mNativeItem.setShortcut(numericChar, alphaChar); + return this; + } + + @Override + public MenuItem setNumericShortcut(char numericChar) { + mNativeItem.setNumericShortcut(numericChar); + return this; + } + + @Override + public char getNumericShortcut() { + return mNativeItem.getNumericShortcut(); + } + + @Override + public MenuItem setAlphabeticShortcut(char alphaChar) { + mNativeItem.setAlphabeticShortcut(alphaChar); + return this; + } + + @Override + public char getAlphabeticShortcut() { + return mNativeItem.getAlphabeticShortcut(); + } + + @Override + public MenuItem setCheckable(boolean checkable) { + mNativeItem.setCheckable(checkable); + return this; + } + + @Override + public boolean isCheckable() { + return mNativeItem.isCheckable(); + } + + @Override + public MenuItem setChecked(boolean checked) { + mNativeItem.setChecked(checked); + return this; + } + + @Override + public boolean isChecked() { + return mNativeItem.isChecked(); + } + + @Override + public MenuItem setVisible(boolean visible) { + mNativeItem.setVisible(visible); + return this; + } + + @Override + public boolean isVisible() { + return mNativeItem.isVisible(); + } + + @Override + public MenuItem setEnabled(boolean enabled) { + mNativeItem.setEnabled(enabled); + return this; + } + + @Override + public boolean isEnabled() { + return mNativeItem.isEnabled(); + } + + @Override + public boolean hasSubMenu() { + return mNativeItem.hasSubMenu(); + } + + @Override + public SubMenu getSubMenu() { + if (hasSubMenu() && (mSubMenu == null)) { + mSubMenu = new SubMenuWrapper(mNativeItem.getSubMenu()); + } + return mSubMenu; + } + + @Override + public MenuItem setOnMenuItemClickListener(OnMenuItemClickListener menuItemClickListener) { + mMenuItemClickListener = menuItemClickListener; + //Register ourselves as the listener to proxy + mNativeItem.setOnMenuItemClickListener(this); + return this; + } + + @Override + public boolean onMenuItemClick(android.view.MenuItem item) { + if (mMenuItemClickListener != null) { + return mMenuItemClickListener.onMenuItemClick(this); + } + return false; + } + + @Override + public ContextMenuInfo getMenuInfo() { + return mNativeItem.getMenuInfo(); + } + + @Override + public void setShowAsAction(int actionEnum) { + mNativeItem.setShowAsAction(actionEnum); + } + + @Override + public MenuItem setShowAsActionFlags(int actionEnum) { + mNativeItem.setShowAsActionFlags(actionEnum); + return this; + } + + @Override + public MenuItem setActionView(View view) { + mNativeItem.setActionView(view); + return this; + } + + @Override + public MenuItem setActionView(int resId) { + mNativeItem.setActionView(resId); + return this; + } + + @Override + public View getActionView() { + return mNativeItem.getActionView(); + } + + @Override + public MenuItem setActionProvider(ActionProvider actionProvider) { + mNativeItem.setActionProvider(new ActionProviderWrapper(actionProvider)); + return this; + } + + @Override + public ActionProvider getActionProvider() { + android.view.ActionProvider nativeProvider = mNativeItem.getActionProvider(); + if (nativeProvider != null && nativeProvider instanceof ActionProviderWrapper) { + return ((ActionProviderWrapper)nativeProvider).unwrap(); + } + return null; + } + + @Override + public boolean expandActionView() { + return mNativeItem.expandActionView(); + } + + @Override + public boolean collapseActionView() { + return mNativeItem.collapseActionView(); + } + + @Override + public boolean isActionViewExpanded() { + return mNativeItem.isActionViewExpanded(); + } + + @Override + public MenuItem setOnActionExpandListener(OnActionExpandListener listener) { + mActionExpandListener = listener; + + if (mNativeActionExpandListener == null) { + mNativeActionExpandListener = new android.view.MenuItem.OnActionExpandListener() { + @Override + public boolean onMenuItemActionExpand(android.view.MenuItem menuItem) { + if (mActionExpandListener != null) { + return mActionExpandListener.onMenuItemActionExpand(MenuItemWrapper.this); + } + return false; + } + + @Override + public boolean onMenuItemActionCollapse(android.view.MenuItem menuItem) { + if (mActionExpandListener != null) { + return mActionExpandListener.onMenuItemActionCollapse(MenuItemWrapper.this); + } + return false; + } + }; + + //Register our inner-class as the listener to proxy method calls + mNativeItem.setOnActionExpandListener(mNativeActionExpandListener); + } + + return this; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuPopupHelper.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuPopupHelper.java new file mode 100644 index 000000000..f030de310 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuPopupHelper.java @@ -0,0 +1,376 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.view.menu; + +import java.util.ArrayList; +import android.content.Context; +import android.content.res.Resources; +import android.database.DataSetObserver; +import android.os.Parcelable; +import android.view.KeyEvent; +import android.view.LayoutInflater; +import android.view.View; +import android.view.View.MeasureSpec; +import android.view.ViewGroup; +import android.view.ViewTreeObserver; +import android.widget.AdapterView; +import android.widget.BaseAdapter; +import android.widget.FrameLayout; +import android.widget.ListAdapter; +import android.widget.PopupWindow; +import com.actionbarsherlock.R; +import com.actionbarsherlock.internal.view.View_HasStateListenerSupport; +import com.actionbarsherlock.internal.view.View_OnAttachStateChangeListener; +import com.actionbarsherlock.internal.widget.IcsListPopupWindow; +import com.actionbarsherlock.view.MenuItem; + +/** + * Presents a menu as a small, simple popup anchored to another view. + * @hide + */ +public class MenuPopupHelper implements AdapterView.OnItemClickListener, View.OnKeyListener, + ViewTreeObserver.OnGlobalLayoutListener, PopupWindow.OnDismissListener, + View_OnAttachStateChangeListener, MenuPresenter { + //UNUSED private static final String TAG = "MenuPopupHelper"; + + static final int ITEM_LAYOUT = R.layout.abs__popup_menu_item_layout; + + private Context mContext; + private LayoutInflater mInflater; + private IcsListPopupWindow mPopup; + private MenuBuilder mMenu; + private int mPopupMaxWidth; + private View mAnchorView; + private boolean mOverflowOnly; + private ViewTreeObserver mTreeObserver; + + private MenuAdapter mAdapter; + + private Callback mPresenterCallback; + + boolean mForceShowIcon; + + private ViewGroup mMeasureParent; + + public MenuPopupHelper(Context context, MenuBuilder menu) { + this(context, menu, null, false); + } + + public MenuPopupHelper(Context context, MenuBuilder menu, View anchorView) { + this(context, menu, anchorView, false); + } + + public MenuPopupHelper(Context context, MenuBuilder menu, + View anchorView, boolean overflowOnly) { + mContext = context; + mInflater = LayoutInflater.from(context); + mMenu = menu; + mOverflowOnly = overflowOnly; + + final Resources res = context.getResources(); + mPopupMaxWidth = Math.max(res.getDisplayMetrics().widthPixels / 2, + res.getDimensionPixelSize(R.dimen.abs__config_prefDialogWidth)); + + mAnchorView = anchorView; + + menu.addMenuPresenter(this); + } + + public void setAnchorView(View anchor) { + mAnchorView = anchor; + } + + public void setForceShowIcon(boolean forceShow) { + mForceShowIcon = forceShow; + } + + public void show() { + if (!tryShow()) { + throw new IllegalStateException("MenuPopupHelper cannot be used without an anchor"); + } + } + + public boolean tryShow() { + mPopup = new IcsListPopupWindow(mContext, null, R.attr.popupMenuStyle); + mPopup.setOnDismissListener(this); + mPopup.setOnItemClickListener(this); + + mAdapter = new MenuAdapter(mMenu); + mPopup.setAdapter(mAdapter); + mPopup.setModal(true); + + View anchor = mAnchorView; + if (anchor != null) { + final boolean addGlobalListener = mTreeObserver == null; + mTreeObserver = anchor.getViewTreeObserver(); // Refresh to latest + if (addGlobalListener) mTreeObserver.addOnGlobalLayoutListener(this); + ((View_HasStateListenerSupport)anchor).addOnAttachStateChangeListener(this); + mPopup.setAnchorView(anchor); + } else { + return false; + } + + mPopup.setContentWidth(Math.min(measureContentWidth(mAdapter), mPopupMaxWidth)); + mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED); + mPopup.show(); + mPopup.getListView().setOnKeyListener(this); + return true; + } + + public void dismiss() { + if (isShowing()) { + mPopup.dismiss(); + } + } + + public void onDismiss() { + mPopup = null; + mMenu.close(); + if (mTreeObserver != null) { + if (!mTreeObserver.isAlive()) mTreeObserver = mAnchorView.getViewTreeObserver(); + mTreeObserver.removeGlobalOnLayoutListener(this); + mTreeObserver = null; + } + ((View_HasStateListenerSupport)mAnchorView).removeOnAttachStateChangeListener(this); + } + + public boolean isShowing() { + return mPopup != null && mPopup.isShowing(); + } + + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + MenuAdapter adapter = mAdapter; + adapter.mAdapterMenu.performItemAction(adapter.getItem(position), 0); + } + + public boolean onKey(View v, int keyCode, KeyEvent event) { + if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_MENU) { + dismiss(); + return true; + } + return false; + } + + private int measureContentWidth(ListAdapter adapter) { + // Menus don't tend to be long, so this is more sane than it looks. + int width = 0; + View itemView = null; + int itemType = 0; + final int widthMeasureSpec = + MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); + final int heightMeasureSpec = + MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); + final int count = adapter.getCount(); + for (int i = 0; i < count; i++) { + final int positionType = adapter.getItemViewType(i); + if (positionType != itemType) { + itemType = positionType; + itemView = null; + } + if (mMeasureParent == null) { + mMeasureParent = new FrameLayout(mContext); + } + itemView = adapter.getView(i, itemView, mMeasureParent); + itemView.measure(widthMeasureSpec, heightMeasureSpec); + width = Math.max(width, itemView.getMeasuredWidth()); + } + return width; + } + + @Override + public void onGlobalLayout() { + if (isShowing()) { + final View anchor = mAnchorView; + if (anchor == null || !anchor.isShown()) { + dismiss(); + } else if (isShowing()) { + // Recompute window size and position + mPopup.show(); + } + } + } + + @Override + public void onViewAttachedToWindow(View v) { + } + + @Override + public void onViewDetachedFromWindow(View v) { + if (mTreeObserver != null) { + if (!mTreeObserver.isAlive()) mTreeObserver = v.getViewTreeObserver(); + mTreeObserver.removeGlobalOnLayoutListener(this); + } + ((View_HasStateListenerSupport)v).removeOnAttachStateChangeListener(this); + } + + @Override + public void initForMenu(Context context, MenuBuilder menu) { + // Don't need to do anything; we added as a presenter in the constructor. + } + + @Override + public MenuView getMenuView(ViewGroup root) { + throw new UnsupportedOperationException("MenuPopupHelpers manage their own views"); + } + + @Override + public void updateMenuView(boolean cleared) { + if (mAdapter != null) mAdapter.notifyDataSetChanged(); + } + + @Override + public void setCallback(Callback cb) { + mPresenterCallback = cb; + } + + @Override + public boolean onSubMenuSelected(SubMenuBuilder subMenu) { + if (subMenu.hasVisibleItems()) { + MenuPopupHelper subPopup = new MenuPopupHelper(mContext, subMenu, mAnchorView, false); + subPopup.setCallback(mPresenterCallback); + + boolean preserveIconSpacing = false; + final int count = subMenu.size(); + for (int i = 0; i < count; i++) { + MenuItem childItem = subMenu.getItem(i); + if (childItem.isVisible() && childItem.getIcon() != null) { + preserveIconSpacing = true; + break; + } + } + subPopup.setForceShowIcon(preserveIconSpacing); + + if (subPopup.tryShow()) { + if (mPresenterCallback != null) { + mPresenterCallback.onOpenSubMenu(subMenu); + } + return true; + } + } + return false; + } + + @Override + public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) { + // Only care about the (sub)menu we're presenting. + if (menu != mMenu) return; + + dismiss(); + if (mPresenterCallback != null) { + mPresenterCallback.onCloseMenu(menu, allMenusAreClosing); + } + } + + @Override + public boolean flagActionItems() { + return false; + } + + public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item) { + return false; + } + + public boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item) { + return false; + } + + @Override + public int getId() { + return 0; + } + + @Override + public Parcelable onSaveInstanceState() { + return null; + } + + @Override + public void onRestoreInstanceState(Parcelable state) { + } + + private class MenuAdapter extends BaseAdapter { + private MenuBuilder mAdapterMenu; + private int mExpandedIndex = -1; + + public MenuAdapter(MenuBuilder menu) { + mAdapterMenu = menu; + registerDataSetObserver(new ExpandedIndexObserver()); + findExpandedIndex(); + } + + public int getCount() { + ArrayList items = mOverflowOnly ? + mAdapterMenu.getNonActionItems() : mAdapterMenu.getVisibleItems(); + if (mExpandedIndex < 0) { + return items.size(); + } + return items.size() - 1; + } + + public MenuItemImpl getItem(int position) { + ArrayList items = mOverflowOnly ? + mAdapterMenu.getNonActionItems() : mAdapterMenu.getVisibleItems(); + if (mExpandedIndex >= 0 && position >= mExpandedIndex) { + position++; + } + return items.get(position); + } + + public long getItemId(int position) { + // Since a menu item's ID is optional, we'll use the position as an + // ID for the item in the AdapterView + return position; + } + + public View getView(int position, View convertView, ViewGroup parent) { + if (convertView == null) { + convertView = mInflater.inflate(ITEM_LAYOUT, parent, false); + } + + MenuView.ItemView itemView = (MenuView.ItemView) convertView; + if (mForceShowIcon) { + ((ListMenuItemView) convertView).setForceShowIcon(true); + } + itemView.initialize(getItem(position), 0); + return convertView; + } + + void findExpandedIndex() { + final MenuItemImpl expandedItem = mMenu.getExpandedItem(); + if (expandedItem != null) { + final ArrayList items = mMenu.getNonActionItems(); + final int count = items.size(); + for (int i = 0; i < count; i++) { + final MenuItemImpl item = items.get(i); + if (item == expandedItem) { + mExpandedIndex = i; + return; + } + } + } + mExpandedIndex = -1; + } + } + + private class ExpandedIndexObserver extends DataSetObserver { + @Override + public void onChanged() { + mAdapter.findExpandedIndex(); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuPresenter.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuPresenter.java new file mode 100644 index 000000000..c3f35472c --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuPresenter.java @@ -0,0 +1,148 @@ +/* + * Copyright (C) 2011 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.actionbarsherlock.internal.view.menu; + +import android.content.Context; +import android.os.Parcelable; +import android.view.ViewGroup; + +/** + * A MenuPresenter is responsible for building views for a Menu object. + * It takes over some responsibility from the old style monolithic MenuBuilder class. + */ +public interface MenuPresenter { + /** + * Called by menu implementation to notify another component of open/close events. + */ + public interface Callback { + /** + * Called when a menu is closing. + * @param menu + * @param allMenusAreClosing + */ + public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing); + + /** + * Called when a submenu opens. Useful for notifying the application + * of menu state so that it does not attempt to hide the action bar + * while a submenu is open or similar. + * + * @param subMenu Submenu currently being opened + * @return true if the Callback will handle presenting the submenu, false if + * the presenter should attempt to do so. + */ + public boolean onOpenSubMenu(MenuBuilder subMenu); + } + + /** + * Initialize this presenter for the given context and menu. + * This method is called by MenuBuilder when a presenter is + * added. See {@link MenuBuilder#addMenuPresenter(MenuPresenter)} + * + * @param context Context for this presenter; used for view creation and resource management + * @param menu Menu to host + */ + public void initForMenu(Context context, MenuBuilder menu); + + /** + * Retrieve a MenuView to display the menu specified in + * {@link #initForMenu(Context, Menu)}. + * + * @param root Intended parent of the MenuView. + * @return A freshly created MenuView. + */ + public MenuView getMenuView(ViewGroup root); + + /** + * Update the menu UI in response to a change. Called by + * MenuBuilder during the normal course of operation. + * + * @param cleared true if the menu was entirely cleared + */ + public void updateMenuView(boolean cleared); + + /** + * Set a callback object that will be notified of menu events + * related to this specific presentation. + * @param cb Callback that will be notified of future events + */ + public void setCallback(Callback cb); + + /** + * Called by Menu implementations to indicate that a submenu item + * has been selected. An active Callback should be notified, and + * if applicable the presenter should present the submenu. + * + * @param subMenu SubMenu being opened + * @return true if the the event was handled, false otherwise. + */ + public boolean onSubMenuSelected(SubMenuBuilder subMenu); + + /** + * Called by Menu implementations to indicate that a menu or submenu is + * closing. Presenter implementations should close the representation + * of the menu indicated as necessary and notify a registered callback. + * + * @param menu Menu or submenu that is closing. + * @param allMenusAreClosing True if all associated menus are closing. + */ + public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing); + + /** + * Called by Menu implementations to flag items that will be shown as actions. + * @return true if this presenter changed the action status of any items. + */ + public boolean flagActionItems(); + + /** + * Called when a menu item with a collapsable action view should expand its action view. + * + * @param menu Menu containing the item to be expanded + * @param item Item to be expanded + * @return true if this presenter expanded the action view, false otherwise. + */ + public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item); + + /** + * Called when a menu item with a collapsable action view should collapse its action view. + * + * @param menu Menu containing the item to be collapsed + * @param item Item to be collapsed + * @return true if this presenter collapsed the action view, false otherwise. + */ + public boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item); + + /** + * Returns an ID for determining how to save/restore instance state. + * @return a valid ID value. + */ + public int getId(); + + /** + * Returns a Parcelable describing the current state of the presenter. + * It will be passed to the {@link #onRestoreInstanceState(Parcelable)} + * method of the presenter sharing the same ID later. + * @return The saved instance state + */ + public Parcelable onSaveInstanceState(); + + /** + * Supplies the previously saved instance state to be restored. + * @param state The previously saved instance state + */ + public void onRestoreInstanceState(Parcelable state); +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuView.java new file mode 100644 index 000000000..323ba2d88 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuView.java @@ -0,0 +1,120 @@ +/* + * Copyright (C) 2006 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.actionbarsherlock.internal.view.menu; + +import android.graphics.drawable.Drawable; + +/** + * Minimal interface for a menu view. {@link #initialize(MenuBuilder)} must be called for the + * menu to be functional. + * + * @hide + */ +public interface MenuView { + /** + * Initializes the menu to the given menu. This should be called after the + * view is inflated. + * + * @param menu The menu that this MenuView should display. + */ + public void initialize(MenuBuilder menu); + + /** + * Returns the default animations to be used for this menu when entering/exiting. + * @return A resource ID for the default animations to be used for this menu. + */ + public int getWindowAnimations(); + + /** + * Minimal interface for a menu item view. {@link #initialize(MenuItemImpl, int)} must be called + * for the item to be functional. + */ + public interface ItemView { + /** + * Initializes with the provided MenuItemData. This should be called after the view is + * inflated. + * @param itemData The item that this ItemView should display. + * @param menuType The type of this menu, one of + * {@link MenuBuilder#TYPE_ICON}, {@link MenuBuilder#TYPE_EXPANDED}, + * {@link MenuBuilder#TYPE_DIALOG}). + */ + public void initialize(MenuItemImpl itemData, int menuType); + + /** + * Gets the item data that this view is displaying. + * @return the item data, or null if there is not one + */ + public MenuItemImpl getItemData(); + + /** + * Sets the title of the item view. + * @param title The title to set. + */ + public void setTitle(CharSequence title); + + /** + * Sets the enabled state of the item view. + * @param enabled Whether the item view should be enabled. + */ + public void setEnabled(boolean enabled); + + /** + * Displays the checkbox for the item view. This does not ensure the item view will be + * checked, for that use {@link #setChecked}. + * @param checkable Whether to display the checkbox or to hide it + */ + public void setCheckable(boolean checkable); + + /** + * Checks the checkbox for the item view. If the checkbox is hidden, it will NOT be + * made visible, call {@link #setCheckable(boolean)} for that. + * @param checked Whether the checkbox should be checked + */ + public void setChecked(boolean checked); + + /** + * Sets the shortcut for the item. + * @param showShortcut Whether a shortcut should be shown(if false, the value of + * shortcutKey should be ignored). + * @param shortcutKey The shortcut key that should be shown on the ItemView. + */ + public void setShortcut(boolean showShortcut, char shortcutKey); + + /** + * Set the icon of this item view. + * @param icon The icon of this item. null to hide the icon. + */ + public void setIcon(Drawable icon); + + /** + * Whether this item view prefers displaying the condensed title rather + * than the normal title. If a condensed title is not available, the + * normal title will be used. + * + * @return Whether this item view prefers displaying the condensed + * title. + */ + public boolean prefersCondensedTitle(); + + /** + * Whether this item view shows an icon. + * + * @return Whether this item view shows an icon. + */ + public boolean showsIcon(); + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuWrapper.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuWrapper.java new file mode 100644 index 000000000..64fc4aeaa --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuWrapper.java @@ -0,0 +1,180 @@ +package com.actionbarsherlock.internal.view.menu; + +import java.util.WeakHashMap; +import android.content.ComponentName; +import android.content.Intent; +import android.view.KeyEvent; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuItem; +import com.actionbarsherlock.view.SubMenu; + +public class MenuWrapper implements Menu { + private final android.view.Menu mNativeMenu; + + private final WeakHashMap mNativeMap = + new WeakHashMap(); + + + public MenuWrapper(android.view.Menu nativeMenu) { + mNativeMenu = nativeMenu; + } + + public android.view.Menu unwrap() { + return mNativeMenu; + } + + private MenuItem addInternal(android.view.MenuItem nativeItem) { + MenuItem item = new MenuItemWrapper(nativeItem); + mNativeMap.put(nativeItem, item); + return item; + } + + @Override + public MenuItem add(CharSequence title) { + return addInternal(mNativeMenu.add(title)); + } + + @Override + public MenuItem add(int titleRes) { + return addInternal(mNativeMenu.add(titleRes)); + } + + @Override + public MenuItem add(int groupId, int itemId, int order, CharSequence title) { + return addInternal(mNativeMenu.add(groupId, itemId, order, title)); + } + + @Override + public MenuItem add(int groupId, int itemId, int order, int titleRes) { + return addInternal(mNativeMenu.add(groupId, itemId, order, titleRes)); + } + + private SubMenu addInternal(android.view.SubMenu nativeSubMenu) { + SubMenu subMenu = new SubMenuWrapper(nativeSubMenu); + android.view.MenuItem nativeItem = nativeSubMenu.getItem(); + MenuItem item = subMenu.getItem(); + mNativeMap.put(nativeItem, item); + return subMenu; + } + + @Override + public SubMenu addSubMenu(CharSequence title) { + return addInternal(mNativeMenu.addSubMenu(title)); + } + + @Override + public SubMenu addSubMenu(int titleRes) { + return addInternal(mNativeMenu.addSubMenu(titleRes)); + } + + @Override + public SubMenu addSubMenu(int groupId, int itemId, int order, CharSequence title) { + return addInternal(mNativeMenu.addSubMenu(groupId, itemId, order, title)); + } + + @Override + public SubMenu addSubMenu(int groupId, int itemId, int order, int titleRes) { + return addInternal(mNativeMenu.addSubMenu(groupId, itemId, order, titleRes)); + } + + @Override + public int addIntentOptions(int groupId, int itemId, int order, ComponentName caller, Intent[] specifics, Intent intent, int flags, MenuItem[] outSpecificItems) { + android.view.MenuItem[] nativeOutItems = new android.view.MenuItem[outSpecificItems.length]; + int result = mNativeMenu.addIntentOptions(groupId, itemId, order, caller, specifics, intent, flags, nativeOutItems); + for (int i = 0, length = outSpecificItems.length; i < length; i++) { + outSpecificItems[i] = new MenuItemWrapper(nativeOutItems[i]); + } + return result; + } + + @Override + public void removeItem(int id) { + mNativeMenu.removeItem(id); + } + + @Override + public void removeGroup(int groupId) { + mNativeMenu.removeGroup(groupId); + } + + @Override + public void clear() { + mNativeMap.clear(); + mNativeMenu.clear(); + } + + @Override + public void setGroupCheckable(int group, boolean checkable, boolean exclusive) { + mNativeMenu.setGroupCheckable(group, checkable, exclusive); + } + + @Override + public void setGroupVisible(int group, boolean visible) { + mNativeMenu.setGroupVisible(group, visible); + } + + @Override + public void setGroupEnabled(int group, boolean enabled) { + mNativeMenu.setGroupEnabled(group, enabled); + } + + @Override + public boolean hasVisibleItems() { + return mNativeMenu.hasVisibleItems(); + } + + @Override + public MenuItem findItem(int id) { + android.view.MenuItem nativeItem = mNativeMenu.findItem(id); + return findItem(nativeItem); + } + + public MenuItem findItem(android.view.MenuItem nativeItem) { + if (nativeItem == null) { + return null; + } + + MenuItem wrapped = mNativeMap.get(nativeItem); + if (wrapped != null) { + return wrapped; + } + + return addInternal(nativeItem); + } + + @Override + public int size() { + return mNativeMenu.size(); + } + + @Override + public MenuItem getItem(int index) { + android.view.MenuItem nativeItem = mNativeMenu.getItem(index); + return findItem(nativeItem); + } + + @Override + public void close() { + mNativeMenu.close(); + } + + @Override + public boolean performShortcut(int keyCode, KeyEvent event, int flags) { + return mNativeMenu.performShortcut(keyCode, event, flags); + } + + @Override + public boolean isShortcutKey(int keyCode, KeyEvent event) { + return mNativeMenu.isShortcutKey(keyCode, event); + } + + @Override + public boolean performIdentifierAction(int id, int flags) { + return mNativeMenu.performIdentifierAction(id, flags); + } + + @Override + public void setQwertyMode(boolean isQwerty) { + mNativeMenu.setQwertyMode(isQwerty); + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/SubMenuBuilder.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/SubMenuBuilder.java new file mode 100644 index 000000000..6679cf386 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/SubMenuBuilder.java @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2006 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.actionbarsherlock.internal.view.menu; + +import android.content.Context; +import android.graphics.drawable.Drawable; +import android.view.View; + +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuItem; +import com.actionbarsherlock.view.SubMenu; + +/** + * The model for a sub menu, which is an extension of the menu. Most methods are proxied to + * the parent menu. + */ +public class SubMenuBuilder extends MenuBuilder implements SubMenu { + private MenuBuilder mParentMenu; + private MenuItemImpl mItem; + + public SubMenuBuilder(Context context, MenuBuilder parentMenu, MenuItemImpl item) { + super(context); + + mParentMenu = parentMenu; + mItem = item; + } + + @Override + public void setQwertyMode(boolean isQwerty) { + mParentMenu.setQwertyMode(isQwerty); + } + + @Override + public boolean isQwertyMode() { + return mParentMenu.isQwertyMode(); + } + + @Override + public void setShortcutsVisible(boolean shortcutsVisible) { + mParentMenu.setShortcutsVisible(shortcutsVisible); + } + + @Override + public boolean isShortcutsVisible() { + return mParentMenu.isShortcutsVisible(); + } + + public Menu getParentMenu() { + return mParentMenu; + } + + public MenuItem getItem() { + return mItem; + } + + @Override + public void setCallback(Callback callback) { + mParentMenu.setCallback(callback); + } + + @Override + public MenuBuilder getRootMenu() { + return mParentMenu; + } + + @Override + boolean dispatchMenuItemSelected(MenuBuilder menu, MenuItem item) { + return super.dispatchMenuItemSelected(menu, item) || + mParentMenu.dispatchMenuItemSelected(menu, item); + } + + public SubMenu setIcon(Drawable icon) { + mItem.setIcon(icon); + return this; + } + + public SubMenu setIcon(int iconRes) { + mItem.setIcon(iconRes); + return this; + } + + public SubMenu setHeaderIcon(Drawable icon) { + return (SubMenu) super.setHeaderIconInt(icon); + } + + public SubMenu setHeaderIcon(int iconRes) { + return (SubMenu) super.setHeaderIconInt(iconRes); + } + + public SubMenu setHeaderTitle(CharSequence title) { + return (SubMenu) super.setHeaderTitleInt(title); + } + + public SubMenu setHeaderTitle(int titleRes) { + return (SubMenu) super.setHeaderTitleInt(titleRes); + } + + public SubMenu setHeaderView(View view) { + return (SubMenu) super.setHeaderViewInt(view); + } + + @Override + public boolean expandItemActionView(MenuItemImpl item) { + return mParentMenu.expandItemActionView(item); + } + + @Override + public boolean collapseItemActionView(MenuItemImpl item) { + return mParentMenu.collapseItemActionView(item); + } + + @Override + public String getActionViewStatesKey() { + final int itemId = mItem != null ? mItem.getItemId() : 0; + if (itemId == 0) { + return null; + } + return super.getActionViewStatesKey() + ":" + itemId; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/SubMenuWrapper.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/SubMenuWrapper.java new file mode 100644 index 000000000..7d307acb1 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/SubMenuWrapper.java @@ -0,0 +1,72 @@ +package com.actionbarsherlock.internal.view.menu; + +import android.graphics.drawable.Drawable; +import android.view.View; +import com.actionbarsherlock.view.MenuItem; +import com.actionbarsherlock.view.SubMenu; + +public class SubMenuWrapper extends MenuWrapper implements SubMenu { + private final android.view.SubMenu mNativeSubMenu; + private MenuItem mItem = null; + + public SubMenuWrapper(android.view.SubMenu nativeSubMenu) { + super(nativeSubMenu); + mNativeSubMenu = nativeSubMenu; + } + + + @Override + public SubMenu setHeaderTitle(int titleRes) { + mNativeSubMenu.setHeaderTitle(titleRes); + return this; + } + + @Override + public SubMenu setHeaderTitle(CharSequence title) { + mNativeSubMenu.setHeaderTitle(title); + return this; + } + + @Override + public SubMenu setHeaderIcon(int iconRes) { + mNativeSubMenu.setHeaderIcon(iconRes); + return this; + } + + @Override + public SubMenu setHeaderIcon(Drawable icon) { + mNativeSubMenu.setHeaderIcon(icon); + return this; + } + + @Override + public SubMenu setHeaderView(View view) { + mNativeSubMenu.setHeaderView(view); + return this; + } + + @Override + public void clearHeader() { + mNativeSubMenu.clearHeader(); + } + + @Override + public SubMenu setIcon(int iconRes) { + mNativeSubMenu.setIcon(iconRes); + return this; + } + + @Override + public SubMenu setIcon(Drawable icon) { + mNativeSubMenu.setIcon(icon); + return this; + } + + @Override + public MenuItem getItem() { + if (mItem == null) { + mItem = new MenuItemWrapper(mNativeSubMenu.getItem()); + } + return mItem; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/AbsActionBarView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/AbsActionBarView.java new file mode 100644 index 000000000..3a4a44675 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/AbsActionBarView.java @@ -0,0 +1,291 @@ +/* + * Copyright (C) 2011 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.actionbarsherlock.internal.widget; + +import android.content.Context; +import android.content.res.Configuration; +import android.content.res.TypedArray; +import android.os.Build; +import android.util.AttributeSet; +import android.view.View; +import android.view.animation.DecelerateInterpolator; +import android.view.animation.Interpolator; + +import com.actionbarsherlock.R; +import com.actionbarsherlock.internal.nineoldandroids.animation.Animator; +import com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet; +import com.actionbarsherlock.internal.nineoldandroids.animation.ObjectAnimator; +import com.actionbarsherlock.internal.nineoldandroids.view.NineViewGroup; +import com.actionbarsherlock.internal.view.menu.ActionMenuPresenter; +import com.actionbarsherlock.internal.view.menu.ActionMenuView; + +import static com.actionbarsherlock.internal.ResourcesCompat.getResources_getBoolean; + +public abstract class AbsActionBarView extends NineViewGroup { + protected ActionMenuView mMenuView; + protected ActionMenuPresenter mActionMenuPresenter; + protected ActionBarContainer mSplitView; + protected boolean mSplitActionBar; + protected boolean mSplitWhenNarrow; + protected int mContentHeight; + + final Context mContext; + + protected Animator mVisibilityAnim; + protected final VisibilityAnimListener mVisAnimListener = new VisibilityAnimListener(); + + private static final /*Time*/Interpolator sAlphaInterpolator = new DecelerateInterpolator(); + + private static final int FADE_DURATION = 200; + + public AbsActionBarView(Context context) { + super(context); + mContext = context; + } + + public AbsActionBarView(Context context, AttributeSet attrs) { + super(context, attrs); + mContext = context; + } + + public AbsActionBarView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + mContext = context; + } + + /* + * Must be public so we can dispatch pre-2.2 via ActionBarImpl. + */ + @Override + public void onConfigurationChanged(Configuration newConfig) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) { + super.onConfigurationChanged(newConfig); + } else if (mMenuView != null) { + mMenuView.onConfigurationChanged(newConfig); + } + + // Action bar can change size on configuration changes. + // Reread the desired height from the theme-specified style. + TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.SherlockActionBar, + R.attr.actionBarStyle, 0); + setContentHeight(a.getLayoutDimension(R.styleable.SherlockActionBar_height, 0)); + a.recycle(); + if (mSplitWhenNarrow) { + setSplitActionBar(getResources_getBoolean(getContext(), + R.bool.abs__split_action_bar_is_narrow)); + } + if (mActionMenuPresenter != null) { + mActionMenuPresenter.onConfigurationChanged(newConfig); + } + } + + /** + * Sets whether the bar should be split right now, no questions asked. + * @param split true if the bar should split + */ + public void setSplitActionBar(boolean split) { + mSplitActionBar = split; + } + + /** + * Sets whether the bar should split if we enter a narrow screen configuration. + * @param splitWhenNarrow true if the bar should check to split after a config change + */ + public void setSplitWhenNarrow(boolean splitWhenNarrow) { + mSplitWhenNarrow = splitWhenNarrow; + } + + public void setContentHeight(int height) { + mContentHeight = height; + requestLayout(); + } + + public int getContentHeight() { + return mContentHeight; + } + + public void setSplitView(ActionBarContainer splitView) { + mSplitView = splitView; + } + + /** + * @return Current visibility or if animating, the visibility being animated to. + */ + public int getAnimatedVisibility() { + if (mVisibilityAnim != null) { + return mVisAnimListener.mFinalVisibility; + } + return getVisibility(); + } + + public void animateToVisibility(int visibility) { + if (mVisibilityAnim != null) { + mVisibilityAnim.cancel(); + } + if (visibility == VISIBLE) { + if (getVisibility() != VISIBLE) { + setAlpha(0); + if (mSplitView != null && mMenuView != null) { + mMenuView.setAlpha(0); + } + } + ObjectAnimator anim = ObjectAnimator.ofFloat(this, "alpha", 1); + anim.setDuration(FADE_DURATION); + anim.setInterpolator(sAlphaInterpolator); + if (mSplitView != null && mMenuView != null) { + AnimatorSet set = new AnimatorSet(); + ObjectAnimator splitAnim = ObjectAnimator.ofFloat(mMenuView, "alpha", 1); + splitAnim.setDuration(FADE_DURATION); + set.addListener(mVisAnimListener.withFinalVisibility(visibility)); + set.play(anim).with(splitAnim); + set.start(); + } else { + anim.addListener(mVisAnimListener.withFinalVisibility(visibility)); + anim.start(); + } + } else { + ObjectAnimator anim = ObjectAnimator.ofFloat(this, "alpha", 0); + anim.setDuration(FADE_DURATION); + anim.setInterpolator(sAlphaInterpolator); + if (mSplitView != null && mMenuView != null) { + AnimatorSet set = new AnimatorSet(); + ObjectAnimator splitAnim = ObjectAnimator.ofFloat(mMenuView, "alpha", 0); + splitAnim.setDuration(FADE_DURATION); + set.addListener(mVisAnimListener.withFinalVisibility(visibility)); + set.play(anim).with(splitAnim); + set.start(); + } else { + anim.addListener(mVisAnimListener.withFinalVisibility(visibility)); + anim.start(); + } + } + } + + @Override + public void setVisibility(int visibility) { + if (mVisibilityAnim != null) { + mVisibilityAnim.end(); + } + super.setVisibility(visibility); + } + + public boolean showOverflowMenu() { + if (mActionMenuPresenter != null) { + return mActionMenuPresenter.showOverflowMenu(); + } + return false; + } + + public void postShowOverflowMenu() { + post(new Runnable() { + public void run() { + showOverflowMenu(); + } + }); + } + + public boolean hideOverflowMenu() { + if (mActionMenuPresenter != null) { + return mActionMenuPresenter.hideOverflowMenu(); + } + return false; + } + + public boolean isOverflowMenuShowing() { + if (mActionMenuPresenter != null) { + return mActionMenuPresenter.isOverflowMenuShowing(); + } + return false; + } + + public boolean isOverflowReserved() { + return mActionMenuPresenter != null && mActionMenuPresenter.isOverflowReserved(); + } + + public void dismissPopupMenus() { + if (mActionMenuPresenter != null) { + mActionMenuPresenter.dismissPopupMenus(); + } + } + + protected int measureChildView(View child, int availableWidth, int childSpecHeight, + int spacing) { + child.measure(MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST), + childSpecHeight); + + availableWidth -= child.getMeasuredWidth(); + availableWidth -= spacing; + + return Math.max(0, availableWidth); + } + + protected int positionChild(View child, int x, int y, int contentHeight) { + int childWidth = child.getMeasuredWidth(); + int childHeight = child.getMeasuredHeight(); + int childTop = y + (contentHeight - childHeight) / 2; + + child.layout(x, childTop, x + childWidth, childTop + childHeight); + + return childWidth; + } + + protected int positionChildInverse(View child, int x, int y, int contentHeight) { + int childWidth = child.getMeasuredWidth(); + int childHeight = child.getMeasuredHeight(); + int childTop = y + (contentHeight - childHeight) / 2; + + child.layout(x - childWidth, childTop, x, childTop + childHeight); + + return childWidth; + } + + protected class VisibilityAnimListener implements Animator.AnimatorListener { + private boolean mCanceled = false; + int mFinalVisibility; + + public VisibilityAnimListener withFinalVisibility(int visibility) { + mFinalVisibility = visibility; + return this; + } + + @Override + public void onAnimationStart(Animator animation) { + setVisibility(VISIBLE); + mVisibilityAnim = animation; + mCanceled = false; + } + + @Override + public void onAnimationEnd(Animator animation) { + if (mCanceled) return; + + mVisibilityAnim = null; + setVisibility(mFinalVisibility); + if (mSplitView != null && mMenuView != null) { + mMenuView.setVisibility(mFinalVisibility); + } + } + + @Override + public void onAnimationCancel(Animator animation) { + mCanceled = true; + } + + @Override + public void onAnimationRepeat(Animator animation) { + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarContainer.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarContainer.java new file mode 100644 index 000000000..5e5aa2867 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarContainer.java @@ -0,0 +1,245 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.widget; + +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.Canvas; +import android.graphics.drawable.Drawable; +import android.util.AttributeSet; +import android.view.MotionEvent; +import android.view.View; +import android.view.ViewGroup; + +import com.actionbarsherlock.R; +import com.actionbarsherlock.app.ActionBar; +import com.actionbarsherlock.internal.nineoldandroids.widget.NineFrameLayout; + +/** + * This class acts as a container for the action bar view and action mode context views. + * It applies special styles as needed to help handle animated transitions between them. + * @hide + */ +public class ActionBarContainer extends NineFrameLayout { + private boolean mIsTransitioning; + private View mTabContainer; + private ActionBarView mActionBarView; + + private Drawable mBackground; + private Drawable mStackedBackground; + private Drawable mSplitBackground; + private boolean mIsSplit; + private boolean mIsStacked; + + public ActionBarContainer(Context context) { + this(context, null); + } + + public ActionBarContainer(Context context, AttributeSet attrs) { + super(context, attrs); + + setBackgroundDrawable(null); + + TypedArray a = context.obtainStyledAttributes(attrs, + R.styleable.SherlockActionBar); + mBackground = a.getDrawable(R.styleable.SherlockActionBar_background); + mStackedBackground = a.getDrawable( + R.styleable.SherlockActionBar_backgroundStacked); + + if (getId() == R.id.abs__split_action_bar) { + mIsSplit = true; + mSplitBackground = a.getDrawable( + R.styleable.SherlockActionBar_backgroundSplit); + } + a.recycle(); + + setWillNotDraw(mIsSplit ? mSplitBackground == null : + mBackground == null && mStackedBackground == null); + } + + @Override + public void onFinishInflate() { + super.onFinishInflate(); + mActionBarView = (ActionBarView) findViewById(R.id.abs__action_bar); + } + + public void setPrimaryBackground(Drawable bg) { + mBackground = bg; + invalidate(); + } + + public void setStackedBackground(Drawable bg) { + mStackedBackground = bg; + invalidate(); + } + + public void setSplitBackground(Drawable bg) { + mSplitBackground = bg; + invalidate(); + } + + /** + * Set the action bar into a "transitioning" state. While transitioning + * the bar will block focus and touch from all of its descendants. This + * prevents the user from interacting with the bar while it is animating + * in or out. + * + * @param isTransitioning true if the bar is currently transitioning, false otherwise. + */ + public void setTransitioning(boolean isTransitioning) { + mIsTransitioning = isTransitioning; + setDescendantFocusability(isTransitioning ? FOCUS_BLOCK_DESCENDANTS + : FOCUS_AFTER_DESCENDANTS); + } + + @Override + public boolean onInterceptTouchEvent(MotionEvent ev) { + return mIsTransitioning || super.onInterceptTouchEvent(ev); + } + + @Override + public boolean onTouchEvent(MotionEvent ev) { + super.onTouchEvent(ev); + + // An action bar always eats touch events. + return true; + } + + @Override + public boolean onHoverEvent(MotionEvent ev) { + super.onHoverEvent(ev); + + // An action bar always eats hover events. + return true; + } + + public void setTabContainer(ScrollingTabContainerView tabView) { + if (mTabContainer != null) { + removeView(mTabContainer); + } + mTabContainer = tabView; + if (tabView != null) { + addView(tabView); + final ViewGroup.LayoutParams lp = tabView.getLayoutParams(); + lp.width = LayoutParams.MATCH_PARENT; + lp.height = LayoutParams.WRAP_CONTENT; + tabView.setAllowCollapse(false); + } + } + + public View getTabContainer() { + return mTabContainer; + } + + @Override + public void onDraw(Canvas canvas) { + if (getWidth() == 0 || getHeight() == 0) { + return; + } + + if (mIsSplit) { + if (mSplitBackground != null) mSplitBackground.draw(canvas); + } else { + if (mBackground != null) { + mBackground.draw(canvas); + } + if (mStackedBackground != null && mIsStacked) { + mStackedBackground.draw(canvas); + } + } + } + + //This causes the animation reflection to fail on pre-HC platforms + //@Override + //public android.view.ActionMode startActionModeForChild(View child, android.view.ActionMode.Callback callback) { + // // No starting an action mode for an action bar child! (Where would it go?) + // return null; + //} + + @Override + public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + + if (mActionBarView == null) return; + + final LayoutParams lp = (LayoutParams) mActionBarView.getLayoutParams(); + final int actionBarViewHeight = mActionBarView.isCollapsed() ? 0 : + mActionBarView.getMeasuredHeight() + lp.topMargin + lp.bottomMargin; + + if (mTabContainer != null && mTabContainer.getVisibility() != GONE) { + final int mode = MeasureSpec.getMode(heightMeasureSpec); + if (mode == MeasureSpec.AT_MOST) { + final int maxHeight = MeasureSpec.getSize(heightMeasureSpec); + setMeasuredDimension(getMeasuredWidth(), + Math.min(actionBarViewHeight + mTabContainer.getMeasuredHeight(), + maxHeight)); + } + } + } + + @Override + public void onLayout(boolean changed, int l, int t, int r, int b) { + super.onLayout(changed, l, t, r, b); + + final boolean hasTabs = mTabContainer != null && mTabContainer.getVisibility() != GONE; + + if (mTabContainer != null && mTabContainer.getVisibility() != GONE) { + final int containerHeight = getMeasuredHeight(); + final int tabHeight = mTabContainer.getMeasuredHeight(); + + if ((mActionBarView.getDisplayOptions() & ActionBar.DISPLAY_SHOW_HOME) == 0) { + // Not showing home, put tabs on top. + final int count = getChildCount(); + for (int i = 0; i < count; i++) { + final View child = getChildAt(i); + + if (child == mTabContainer) continue; + + if (!mActionBarView.isCollapsed()) { + child.offsetTopAndBottom(tabHeight); + } + } + mTabContainer.layout(l, 0, r, tabHeight); + } else { + mTabContainer.layout(l, containerHeight - tabHeight, r, containerHeight); + } + } + + boolean needsInvalidate = false; + if (mIsSplit) { + if (mSplitBackground != null) { + mSplitBackground.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight()); + needsInvalidate = true; + } + } else { + if (mBackground != null) { + mBackground.setBounds(mActionBarView.getLeft(), mActionBarView.getTop(), + mActionBarView.getRight(), mActionBarView.getBottom()); + needsInvalidate = true; + } + if ((mIsStacked = hasTabs && mStackedBackground != null)) { + mStackedBackground.setBounds(mTabContainer.getLeft(), mTabContainer.getTop(), + mTabContainer.getRight(), mTabContainer.getBottom()); + needsInvalidate = true; + } + } + + if (needsInvalidate) { + invalidate(); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarContextView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarContextView.java new file mode 100644 index 000000000..9ec250f38 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarContextView.java @@ -0,0 +1,518 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.widget; + +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.drawable.Drawable; +import android.text.TextUtils; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.accessibility.AccessibilityEvent; +import android.view.animation.DecelerateInterpolator; +import android.widget.LinearLayout; +import android.widget.TextView; + +import com.actionbarsherlock.R; +import com.actionbarsherlock.internal.nineoldandroids.animation.Animator; +import com.actionbarsherlock.internal.nineoldandroids.animation.Animator.AnimatorListener; +import com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet; +import com.actionbarsherlock.internal.nineoldandroids.animation.ObjectAnimator; +import com.actionbarsherlock.internal.nineoldandroids.view.animation.AnimatorProxy; +import com.actionbarsherlock.internal.nineoldandroids.widget.NineLinearLayout; +import com.actionbarsherlock.internal.view.menu.ActionMenuPresenter; +import com.actionbarsherlock.internal.view.menu.ActionMenuView; +import com.actionbarsherlock.internal.view.menu.MenuBuilder; +import com.actionbarsherlock.view.ActionMode; + +/** + * @hide + */ +public class ActionBarContextView extends AbsActionBarView implements AnimatorListener { + //UNUSED private static final String TAG = "ActionBarContextView"; + + private CharSequence mTitle; + private CharSequence mSubtitle; + + private NineLinearLayout mClose; + private View mCustomView; + private LinearLayout mTitleLayout; + private TextView mTitleView; + private TextView mSubtitleView; + private int mTitleStyleRes; + private int mSubtitleStyleRes; + private Drawable mSplitBackground; + + private Animator mCurrentAnimation; + private boolean mAnimateInOnLayout; + private int mAnimationMode; + + private static final int ANIMATE_IDLE = 0; + private static final int ANIMATE_IN = 1; + private static final int ANIMATE_OUT = 2; + + public ActionBarContextView(Context context) { + this(context, null); + } + + public ActionBarContextView(Context context, AttributeSet attrs) { + this(context, attrs, R.attr.actionModeStyle); + } + + public ActionBarContextView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + + TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockActionMode, defStyle, 0); + setBackgroundDrawable(a.getDrawable( + R.styleable.SherlockActionMode_background)); + mTitleStyleRes = a.getResourceId( + R.styleable.SherlockActionMode_titleTextStyle, 0); + mSubtitleStyleRes = a.getResourceId( + R.styleable.SherlockActionMode_subtitleTextStyle, 0); + + mContentHeight = a.getLayoutDimension( + R.styleable.SherlockActionMode_height, 0); + + mSplitBackground = a.getDrawable( + R.styleable.SherlockActionMode_backgroundSplit); + + a.recycle(); + } + + @Override + public void onDetachedFromWindow() { + super.onDetachedFromWindow(); + if (mActionMenuPresenter != null) { + mActionMenuPresenter.hideOverflowMenu(); + mActionMenuPresenter.hideSubMenus(); + } + } + + @Override + public void setSplitActionBar(boolean split) { + if (mSplitActionBar != split) { + if (mActionMenuPresenter != null) { + // Mode is already active; move everything over and adjust the menu itself. + final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, + LayoutParams.MATCH_PARENT); + if (!split) { + mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this); + mMenuView.setBackgroundDrawable(null); + final ViewGroup oldParent = (ViewGroup) mMenuView.getParent(); + if (oldParent != null) oldParent.removeView(mMenuView); + addView(mMenuView, layoutParams); + } else { + // Allow full screen width in split mode. + mActionMenuPresenter.setWidthLimit( + getContext().getResources().getDisplayMetrics().widthPixels, true); + // No limit to the item count; use whatever will fit. + mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE); + // Span the whole width + layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.height = mContentHeight; + mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this); + mMenuView.setBackgroundDrawable(mSplitBackground); + final ViewGroup oldParent = (ViewGroup) mMenuView.getParent(); + if (oldParent != null) oldParent.removeView(mMenuView); + mSplitView.addView(mMenuView, layoutParams); + } + } + super.setSplitActionBar(split); + } + } + + public void setContentHeight(int height) { + mContentHeight = height; + } + + public void setCustomView(View view) { + if (mCustomView != null) { + removeView(mCustomView); + } + mCustomView = view; + if (mTitleLayout != null) { + removeView(mTitleLayout); + mTitleLayout = null; + } + if (view != null) { + addView(view); + } + requestLayout(); + } + + public void setTitle(CharSequence title) { + mTitle = title; + initTitle(); + } + + public void setSubtitle(CharSequence subtitle) { + mSubtitle = subtitle; + initTitle(); + } + + public CharSequence getTitle() { + return mTitle; + } + + public CharSequence getSubtitle() { + return mSubtitle; + } + + private void initTitle() { + if (mTitleLayout == null) { + LayoutInflater inflater = LayoutInflater.from(getContext()); + inflater.inflate(R.layout.abs__action_bar_title_item, this); + mTitleLayout = (LinearLayout) getChildAt(getChildCount() - 1); + mTitleView = (TextView) mTitleLayout.findViewById(R.id.abs__action_bar_title); + mSubtitleView = (TextView) mTitleLayout.findViewById(R.id.abs__action_bar_subtitle); + if (mTitleStyleRes != 0) { + mTitleView.setTextAppearance(mContext, mTitleStyleRes); + } + if (mSubtitleStyleRes != 0) { + mSubtitleView.setTextAppearance(mContext, mSubtitleStyleRes); + } + } + + mTitleView.setText(mTitle); + mSubtitleView.setText(mSubtitle); + + final boolean hasTitle = !TextUtils.isEmpty(mTitle); + final boolean hasSubtitle = !TextUtils.isEmpty(mSubtitle); + mSubtitleView.setVisibility(hasSubtitle ? VISIBLE : GONE); + mTitleLayout.setVisibility(hasTitle || hasSubtitle ? VISIBLE : GONE); + if (mTitleLayout.getParent() == null) { + addView(mTitleLayout); + } + } + + public void initForMode(final ActionMode mode) { + if (mClose == null) { + LayoutInflater inflater = LayoutInflater.from(mContext); + mClose = (NineLinearLayout)inflater.inflate(R.layout.abs__action_mode_close_item, this, false); + addView(mClose); + } else if (mClose.getParent() == null) { + addView(mClose); + } + + View closeButton = mClose.findViewById(R.id.abs__action_mode_close_button); + closeButton.setOnClickListener(new OnClickListener() { + public void onClick(View v) { + mode.finish(); + } + }); + + final MenuBuilder menu = (MenuBuilder) mode.getMenu(); + if (mActionMenuPresenter != null) { + mActionMenuPresenter.dismissPopupMenus(); + } + mActionMenuPresenter = new ActionMenuPresenter(mContext); + mActionMenuPresenter.setReserveOverflow(true); + + final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, + LayoutParams.MATCH_PARENT); + if (!mSplitActionBar) { + menu.addMenuPresenter(mActionMenuPresenter); + mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this); + mMenuView.setBackgroundDrawable(null); + addView(mMenuView, layoutParams); + } else { + // Allow full screen width in split mode. + mActionMenuPresenter.setWidthLimit( + getContext().getResources().getDisplayMetrics().widthPixels, true); + // No limit to the item count; use whatever will fit. + mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE); + // Span the whole width + layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.height = mContentHeight; + menu.addMenuPresenter(mActionMenuPresenter); + mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this); + mMenuView.setBackgroundDrawable(mSplitBackground); + mSplitView.addView(mMenuView, layoutParams); + } + + mAnimateInOnLayout = true; + } + + public void closeMode() { + if (mAnimationMode == ANIMATE_OUT) { + // Called again during close; just finish what we were doing. + return; + } + if (mClose == null) { + killMode(); + return; + } + + finishAnimation(); + mAnimationMode = ANIMATE_OUT; + mCurrentAnimation = makeOutAnimation(); + mCurrentAnimation.start(); + } + + private void finishAnimation() { + final Animator a = mCurrentAnimation; + if (a != null) { + mCurrentAnimation = null; + a.end(); + } + } + + public void killMode() { + finishAnimation(); + removeAllViews(); + if (mSplitView != null) { + mSplitView.removeView(mMenuView); + } + mCustomView = null; + mMenuView = null; + mAnimateInOnLayout = false; + } + + @Override + public boolean showOverflowMenu() { + if (mActionMenuPresenter != null) { + return mActionMenuPresenter.showOverflowMenu(); + } + return false; + } + + @Override + public boolean hideOverflowMenu() { + if (mActionMenuPresenter != null) { + return mActionMenuPresenter.hideOverflowMenu(); + } + return false; + } + + @Override + public boolean isOverflowMenuShowing() { + if (mActionMenuPresenter != null) { + return mActionMenuPresenter.isOverflowMenuShowing(); + } + return false; + } + + @Override + protected ViewGroup.LayoutParams generateDefaultLayoutParams() { + // Used by custom views if they don't supply layout params. Everything else + // added to an ActionBarContextView should have them already. + return new MarginLayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); + } + + @Override + public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs) { + return new MarginLayoutParams(getContext(), attrs); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + final int widthMode = MeasureSpec.getMode(widthMeasureSpec); + if (widthMode != MeasureSpec.EXACTLY) { + throw new IllegalStateException(getClass().getSimpleName() + " can only be used " + + "with android:layout_width=\"match_parent\" (or fill_parent)"); + } + + final int heightMode = MeasureSpec.getMode(heightMeasureSpec); + if (heightMode == MeasureSpec.UNSPECIFIED) { + throw new IllegalStateException(getClass().getSimpleName() + " can only be used " + + "with android:layout_height=\"wrap_content\""); + } + + final int contentWidth = MeasureSpec.getSize(widthMeasureSpec); + + int maxHeight = mContentHeight > 0 ? + mContentHeight : MeasureSpec.getSize(heightMeasureSpec); + + final int verticalPadding = getPaddingTop() + getPaddingBottom(); + int availableWidth = contentWidth - getPaddingLeft() - getPaddingRight(); + final int height = maxHeight - verticalPadding; + final int childSpecHeight = MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST); + + if (mClose != null) { + availableWidth = measureChildView(mClose, availableWidth, childSpecHeight, 0); + MarginLayoutParams lp = (MarginLayoutParams) mClose.getLayoutParams(); + availableWidth -= lp.leftMargin + lp.rightMargin; + } + + if (mMenuView != null && mMenuView.getParent() == this) { + availableWidth = measureChildView(mMenuView, availableWidth, + childSpecHeight, 0); + } + + if (mTitleLayout != null && mCustomView == null) { + availableWidth = measureChildView(mTitleLayout, availableWidth, childSpecHeight, 0); + } + + if (mCustomView != null) { + ViewGroup.LayoutParams lp = mCustomView.getLayoutParams(); + final int customWidthMode = lp.width != LayoutParams.WRAP_CONTENT ? + MeasureSpec.EXACTLY : MeasureSpec.AT_MOST; + final int customWidth = lp.width >= 0 ? + Math.min(lp.width, availableWidth) : availableWidth; + final int customHeightMode = lp.height != LayoutParams.WRAP_CONTENT ? + MeasureSpec.EXACTLY : MeasureSpec.AT_MOST; + final int customHeight = lp.height >= 0 ? + Math.min(lp.height, height) : height; + mCustomView.measure(MeasureSpec.makeMeasureSpec(customWidth, customWidthMode), + MeasureSpec.makeMeasureSpec(customHeight, customHeightMode)); + } + + if (mContentHeight <= 0) { + int measuredHeight = 0; + final int count = getChildCount(); + for (int i = 0; i < count; i++) { + View v = getChildAt(i); + int paddedViewHeight = v.getMeasuredHeight() + verticalPadding; + if (paddedViewHeight > measuredHeight) { + measuredHeight = paddedViewHeight; + } + } + setMeasuredDimension(contentWidth, measuredHeight); + } else { + setMeasuredDimension(contentWidth, maxHeight); + } + } + + private Animator makeInAnimation() { + mClose.setTranslationX(-mClose.getWidth() - + ((MarginLayoutParams) mClose.getLayoutParams()).leftMargin); + ObjectAnimator buttonAnimator = ObjectAnimator.ofFloat(mClose, "translationX", 0); + buttonAnimator.setDuration(200); + buttonAnimator.addListener(this); + buttonAnimator.setInterpolator(new DecelerateInterpolator()); + + AnimatorSet set = new AnimatorSet(); + AnimatorSet.Builder b = set.play(buttonAnimator); + + if (mMenuView != null) { + final int count = mMenuView.getChildCount(); + if (count > 0) { + for (int i = count - 1, j = 0; i >= 0; i--, j++) { + AnimatorProxy child = AnimatorProxy.wrap(mMenuView.getChildAt(i)); + child.setScaleY(0); + ObjectAnimator a = ObjectAnimator.ofFloat(child, "scaleY", 0, 1); + a.setDuration(100); + a.setStartDelay(j * 70); + b.with(a); + } + } + } + + return set; + } + + private Animator makeOutAnimation() { + ObjectAnimator buttonAnimator = ObjectAnimator.ofFloat(mClose, "translationX", + -mClose.getWidth() - ((MarginLayoutParams) mClose.getLayoutParams()).leftMargin); + buttonAnimator.setDuration(200); + buttonAnimator.addListener(this); + buttonAnimator.setInterpolator(new DecelerateInterpolator()); + + AnimatorSet set = new AnimatorSet(); + AnimatorSet.Builder b = set.play(buttonAnimator); + + if (mMenuView != null) { + final int count = mMenuView.getChildCount(); + if (count > 0) { + for (int i = 0; i < 0; i++) { + AnimatorProxy child = AnimatorProxy.wrap(mMenuView.getChildAt(i)); + child.setScaleY(0); + ObjectAnimator a = ObjectAnimator.ofFloat(child, "scaleY", 0); + a.setDuration(100); + a.setStartDelay(i * 70); + b.with(a); + } + } + } + + return set; + } + + @Override + protected void onLayout(boolean changed, int l, int t, int r, int b) { + int x = getPaddingLeft(); + final int y = getPaddingTop(); + final int contentHeight = b - t - getPaddingTop() - getPaddingBottom(); + + if (mClose != null && mClose.getVisibility() != GONE) { + MarginLayoutParams lp = (MarginLayoutParams) mClose.getLayoutParams(); + x += lp.leftMargin; + x += positionChild(mClose, x, y, contentHeight); + x += lp.rightMargin; + + if (mAnimateInOnLayout) { + mAnimationMode = ANIMATE_IN; + mCurrentAnimation = makeInAnimation(); + mCurrentAnimation.start(); + mAnimateInOnLayout = false; + } + } + + if (mTitleLayout != null && mCustomView == null) { + x += positionChild(mTitleLayout, x, y, contentHeight); + } + + if (mCustomView != null) { + x += positionChild(mCustomView, x, y, contentHeight); + } + + x = r - l - getPaddingRight(); + + if (mMenuView != null) { + x -= positionChildInverse(mMenuView, x, y, contentHeight); + } + } + + @Override + public void onAnimationStart(Animator animation) { + } + + @Override + public void onAnimationEnd(Animator animation) { + if (mAnimationMode == ANIMATE_OUT) { + killMode(); + } + mAnimationMode = ANIMATE_IDLE; + } + + @Override + public void onAnimationCancel(Animator animation) { + } + + @Override + public void onAnimationRepeat(Animator animation) { + } + + @Override + public boolean shouldDelayChildPressedState() { + return false; + } + + @Override + public void onInitializeAccessibilityEvent(AccessibilityEvent event) { + if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { + // Action mode started + //TODO event.setSource(this); + event.setClassName(getClass().getName()); + event.setPackageName(getContext().getPackageName()); + event.setContentDescription(mTitle); + } else { + //TODO super.onInitializeAccessibilityEvent(event); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarView.java new file mode 100644 index 000000000..4636de17f --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarView.java @@ -0,0 +1,1548 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.widget; + +import org.xmlpull.v1.XmlPullParser; +import android.app.Activity; +import android.content.Context; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; +import android.content.res.AssetManager; +import android.content.res.Configuration; +import android.content.res.TypedArray; +import android.content.res.XmlResourceParser; +import android.graphics.drawable.Drawable; +import android.os.Build; +import android.os.Parcel; +import android.os.Parcelable; +import android.text.TextUtils; +import android.util.AttributeSet; +import android.util.Log; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewParent; +import android.view.accessibility.AccessibilityEvent; +import android.widget.FrameLayout; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.SpinnerAdapter; +import android.widget.TextView; + +import com.actionbarsherlock.R; +import com.actionbarsherlock.app.ActionBar; +import com.actionbarsherlock.app.ActionBar.OnNavigationListener; +import com.actionbarsherlock.internal.ActionBarSherlockCompat; +import com.actionbarsherlock.internal.view.menu.ActionMenuItem; +import com.actionbarsherlock.internal.view.menu.ActionMenuPresenter; +import com.actionbarsherlock.internal.view.menu.ActionMenuView; +import com.actionbarsherlock.internal.view.menu.MenuBuilder; +import com.actionbarsherlock.internal.view.menu.MenuItemImpl; +import com.actionbarsherlock.internal.view.menu.MenuPresenter; +import com.actionbarsherlock.internal.view.menu.MenuView; +import com.actionbarsherlock.internal.view.menu.SubMenuBuilder; +import com.actionbarsherlock.view.CollapsibleActionView; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuItem; +import com.actionbarsherlock.view.Window; + +import static com.actionbarsherlock.internal.ResourcesCompat.getResources_getBoolean; + +/** + * @hide + */ +public class ActionBarView extends AbsActionBarView { + private static final String TAG = "ActionBarView"; + private static final boolean DEBUG = false; + + /** + * Display options applied by default + */ + public static final int DISPLAY_DEFAULT = 0; + + /** + * Display options that require re-layout as opposed to a simple invalidate + */ + private static final int DISPLAY_RELAYOUT_MASK = + ActionBar.DISPLAY_SHOW_HOME | + ActionBar.DISPLAY_USE_LOGO | + ActionBar.DISPLAY_HOME_AS_UP | + ActionBar.DISPLAY_SHOW_CUSTOM | + ActionBar.DISPLAY_SHOW_TITLE; + + private static final int DEFAULT_CUSTOM_GRAVITY = Gravity.LEFT | Gravity.CENTER_VERTICAL; + + private int mNavigationMode; + private int mDisplayOptions = -1; + private CharSequence mTitle; + private CharSequence mSubtitle; + private Drawable mIcon; + private Drawable mLogo; + + private HomeView mHomeLayout; + private HomeView mExpandedHomeLayout; + private LinearLayout mTitleLayout; + private TextView mTitleView; + private TextView mSubtitleView; + private View mTitleUpView; + + private IcsSpinner mSpinner; + private IcsLinearLayout mListNavLayout; + private ScrollingTabContainerView mTabScrollView; + private View mCustomNavView; + private IcsProgressBar mProgressView; + private IcsProgressBar mIndeterminateProgressView; + + private int mProgressBarPadding; + private int mItemPadding; + + private int mTitleStyleRes; + private int mSubtitleStyleRes; + private int mProgressStyle; + private int mIndeterminateProgressStyle; + + private boolean mUserTitle; + private boolean mIncludeTabs; + private boolean mIsCollapsable; + private boolean mIsCollapsed; + + private MenuBuilder mOptionsMenu; + + private ActionBarContextView mContextView; + + private ActionMenuItem mLogoNavItem; + + private SpinnerAdapter mSpinnerAdapter; + private OnNavigationListener mCallback; + + //UNUSED private Runnable mTabSelector; + + private ExpandedActionViewMenuPresenter mExpandedMenuPresenter; + View mExpandedActionView; + + Window.Callback mWindowCallback; + + @SuppressWarnings("rawtypes") + private final IcsAdapterView.OnItemSelectedListener mNavItemSelectedListener = + new IcsAdapterView.OnItemSelectedListener() { + public void onItemSelected(IcsAdapterView parent, View view, int position, long id) { + if (mCallback != null) { + mCallback.onNavigationItemSelected(position, id); + } + } + public void onNothingSelected(IcsAdapterView parent) { + // Do nothing + } + }; + + private final OnClickListener mExpandedActionViewUpListener = new OnClickListener() { + @Override + public void onClick(View v) { + final MenuItemImpl item = mExpandedMenuPresenter.mCurrentExpandedItem; + if (item != null) { + item.collapseActionView(); + } + } + }; + + private final OnClickListener mUpClickListener = new OnClickListener() { + public void onClick(View v) { + mWindowCallback.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, mLogoNavItem); + } + }; + + public ActionBarView(Context context, AttributeSet attrs) { + super(context, attrs); + + // Background is always provided by the container. + setBackgroundResource(0); + + TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockActionBar, + R.attr.actionBarStyle, 0); + + ApplicationInfo appInfo = context.getApplicationInfo(); + PackageManager pm = context.getPackageManager(); + mNavigationMode = a.getInt(R.styleable.SherlockActionBar_navigationMode, + ActionBar.NAVIGATION_MODE_STANDARD); + mTitle = a.getText(R.styleable.SherlockActionBar_title); + mSubtitle = a.getText(R.styleable.SherlockActionBar_subtitle); + + mLogo = a.getDrawable(R.styleable.SherlockActionBar_logo); + if (mLogo == null) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + if (context instanceof Activity) { + //Even though native methods existed in API 9 and 10 they don't work + //so just parse the manifest to look for the logo pre-Honeycomb + final int resId = loadLogoFromManifest((Activity) context); + if (resId != 0) { + mLogo = context.getResources().getDrawable(resId); + } + } + } else { + if (context instanceof Activity) { + try { + mLogo = pm.getActivityLogo(((Activity) context).getComponentName()); + } catch (NameNotFoundException e) { + Log.e(TAG, "Activity component name not found!", e); + } + } + if (mLogo == null) { + mLogo = appInfo.loadLogo(pm); + } + } + } + + mIcon = a.getDrawable(R.styleable.SherlockActionBar_icon); + if (mIcon == null) { + if (context instanceof Activity) { + try { + mIcon = pm.getActivityIcon(((Activity) context).getComponentName()); + } catch (NameNotFoundException e) { + Log.e(TAG, "Activity component name not found!", e); + } + } + if (mIcon == null) { + mIcon = appInfo.loadIcon(pm); + } + } + + final LayoutInflater inflater = LayoutInflater.from(context); + + final int homeResId = a.getResourceId( + R.styleable.SherlockActionBar_homeLayout, + R.layout.abs__action_bar_home); + + mHomeLayout = (HomeView) inflater.inflate(homeResId, this, false); + + mExpandedHomeLayout = (HomeView) inflater.inflate(homeResId, this, false); + mExpandedHomeLayout.setUp(true); + mExpandedHomeLayout.setOnClickListener(mExpandedActionViewUpListener); + mExpandedHomeLayout.setContentDescription(getResources().getText( + R.string.abs__action_bar_up_description)); + + mTitleStyleRes = a.getResourceId(R.styleable.SherlockActionBar_titleTextStyle, 0); + mSubtitleStyleRes = a.getResourceId(R.styleable.SherlockActionBar_subtitleTextStyle, 0); + mProgressStyle = a.getResourceId(R.styleable.SherlockActionBar_progressBarStyle, 0); + mIndeterminateProgressStyle = a.getResourceId( + R.styleable.SherlockActionBar_indeterminateProgressStyle, 0); + + mProgressBarPadding = a.getDimensionPixelOffset(R.styleable.SherlockActionBar_progressBarPadding, 0); + mItemPadding = a.getDimensionPixelOffset(R.styleable.SherlockActionBar_itemPadding, 0); + + setDisplayOptions(a.getInt(R.styleable.SherlockActionBar_displayOptions, DISPLAY_DEFAULT)); + + final int customNavId = a.getResourceId(R.styleable.SherlockActionBar_customNavigationLayout, 0); + if (customNavId != 0) { + mCustomNavView = inflater.inflate(customNavId, this, false); + mNavigationMode = ActionBar.NAVIGATION_MODE_STANDARD; + setDisplayOptions(mDisplayOptions | ActionBar.DISPLAY_SHOW_CUSTOM); + } + + mContentHeight = a.getLayoutDimension(R.styleable.SherlockActionBar_height, 0); + + a.recycle(); + + mLogoNavItem = new ActionMenuItem(context, 0, android.R.id.home, 0, 0, mTitle); + mHomeLayout.setOnClickListener(mUpClickListener); + mHomeLayout.setClickable(true); + mHomeLayout.setFocusable(true); + } + + /** + * Attempt to programmatically load the logo from the manifest file of an + * activity by using an XML pull parser. This should allow us to read the + * logo attribute regardless of the platform it is being run on. + * + * @param activity Activity instance. + * @return Logo resource ID. + */ + private static int loadLogoFromManifest(Activity activity) { + int logo = 0; + try { + final String thisPackage = activity.getClass().getName(); + if (DEBUG) Log.i(TAG, "Parsing AndroidManifest.xml for " + thisPackage); + + final String packageName = activity.getApplicationInfo().packageName; + final AssetManager am = activity.createPackageContext(packageName, 0).getAssets(); + final XmlResourceParser xml = am.openXmlResourceParser("AndroidManifest.xml"); + + int eventType = xml.getEventType(); + while (eventType != XmlPullParser.END_DOCUMENT) { + if (eventType == XmlPullParser.START_TAG) { + String name = xml.getName(); + + if ("application".equals(name)) { + //Check if the has the attribute + if (DEBUG) Log.d(TAG, "Got "); + + for (int i = xml.getAttributeCount() - 1; i >= 0; i--) { + if (DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i)); + + if ("logo".equals(xml.getAttributeName(i))) { + logo = xml.getAttributeResourceValue(i, 0); + break; //out of for loop + } + } + } else if ("activity".equals(name)) { + //Check if the is us and has the attribute + if (DEBUG) Log.d(TAG, "Got "); + Integer activityLogo = null; + String activityPackage = null; + boolean isOurActivity = false; + + for (int i = xml.getAttributeCount() - 1; i >= 0; i--) { + if (DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i)); + + //We need both uiOptions and name attributes + String attrName = xml.getAttributeName(i); + if ("logo".equals(attrName)) { + activityLogo = xml.getAttributeResourceValue(i, 0); + } else if ("name".equals(attrName)) { + activityPackage = ActionBarSherlockCompat.cleanActivityName(packageName, xml.getAttributeValue(i)); + if (!thisPackage.equals(activityPackage)) { + break; //on to the next + } + isOurActivity = true; + } + + //Make sure we have both attributes before processing + if ((activityLogo != null) && (activityPackage != null)) { + //Our activity, logo specified, override with our value + logo = activityLogo.intValue(); + } + } + if (isOurActivity) { + //If we matched our activity but it had no logo don't + //do any more processing of the manifest + break; + } + } + } + eventType = xml.nextToken(); + } + } catch (Exception e) { + e.printStackTrace(); + } + if (DEBUG) Log.i(TAG, "Returning " + Integer.toHexString(logo)); + return logo; + } + + /* + * Must be public so we can dispatch pre-2.2 via ActionBarImpl. + */ + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + + mTitleView = null; + mSubtitleView = null; + mTitleUpView = null; + if (mTitleLayout != null && mTitleLayout.getParent() == this) { + removeView(mTitleLayout); + } + mTitleLayout = null; + if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0) { + initTitle(); + } + + if (mTabScrollView != null && mIncludeTabs) { + ViewGroup.LayoutParams lp = mTabScrollView.getLayoutParams(); + if (lp != null) { + lp.width = LayoutParams.WRAP_CONTENT; + lp.height = LayoutParams.MATCH_PARENT; + } + mTabScrollView.setAllowCollapse(true); + } + } + + /** + * Set the window callback used to invoke menu items; used for dispatching home button presses. + * @param cb Window callback to dispatch to + */ + public void setWindowCallback(Window.Callback cb) { + mWindowCallback = cb; + } + + @Override + public void onDetachedFromWindow() { + super.onDetachedFromWindow(); + //UNUSED removeCallbacks(mTabSelector); + if (mActionMenuPresenter != null) { + mActionMenuPresenter.hideOverflowMenu(); + mActionMenuPresenter.hideSubMenus(); + } + } + + @Override + public boolean shouldDelayChildPressedState() { + return false; + } + + public void initProgress() { + mProgressView = new IcsProgressBar(mContext, null, 0, mProgressStyle); + mProgressView.setId(R.id.abs__progress_horizontal); + mProgressView.setMax(10000); + addView(mProgressView); + } + + public void initIndeterminateProgress() { + mIndeterminateProgressView = new IcsProgressBar(mContext, null, 0, mIndeterminateProgressStyle); + mIndeterminateProgressView.setId(R.id.abs__progress_circular); + addView(mIndeterminateProgressView); + } + + @Override + public void setSplitActionBar(boolean splitActionBar) { + if (mSplitActionBar != splitActionBar) { + if (mMenuView != null) { + final ViewGroup oldParent = (ViewGroup) mMenuView.getParent(); + if (oldParent != null) { + oldParent.removeView(mMenuView); + } + if (splitActionBar) { + if (mSplitView != null) { + mSplitView.addView(mMenuView); + } + } else { + addView(mMenuView); + } + } + if (mSplitView != null) { + mSplitView.setVisibility(splitActionBar ? VISIBLE : GONE); + } + super.setSplitActionBar(splitActionBar); + } + } + + public boolean isSplitActionBar() { + return mSplitActionBar; + } + + public boolean hasEmbeddedTabs() { + return mIncludeTabs; + } + + public void setEmbeddedTabView(ScrollingTabContainerView tabs) { + if (mTabScrollView != null) { + removeView(mTabScrollView); + } + mTabScrollView = tabs; + mIncludeTabs = tabs != null; + if (mIncludeTabs && mNavigationMode == ActionBar.NAVIGATION_MODE_TABS) { + addView(mTabScrollView); + ViewGroup.LayoutParams lp = mTabScrollView.getLayoutParams(); + lp.width = LayoutParams.WRAP_CONTENT; + lp.height = LayoutParams.MATCH_PARENT; + tabs.setAllowCollapse(true); + } + } + + public void setCallback(OnNavigationListener callback) { + mCallback = callback; + } + + public void setMenu(Menu menu, MenuPresenter.Callback cb) { + if (menu == mOptionsMenu) return; + + if (mOptionsMenu != null) { + mOptionsMenu.removeMenuPresenter(mActionMenuPresenter); + mOptionsMenu.removeMenuPresenter(mExpandedMenuPresenter); + } + + MenuBuilder builder = (MenuBuilder) menu; + mOptionsMenu = builder; + if (mMenuView != null) { + final ViewGroup oldParent = (ViewGroup) mMenuView.getParent(); + if (oldParent != null) { + oldParent.removeView(mMenuView); + } + } + if (mActionMenuPresenter == null) { + mActionMenuPresenter = new ActionMenuPresenter(mContext); + mActionMenuPresenter.setCallback(cb); + mActionMenuPresenter.setId(R.id.abs__action_menu_presenter); + mExpandedMenuPresenter = new ExpandedActionViewMenuPresenter(); + } + + ActionMenuView menuView; + final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, + LayoutParams.MATCH_PARENT); + if (!mSplitActionBar) { + mActionMenuPresenter.setExpandedActionViewsExclusive( + getResources_getBoolean(getContext(), + R.bool.abs__action_bar_expanded_action_views_exclusive)); + configPresenters(builder); + menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this); + final ViewGroup oldParent = (ViewGroup) menuView.getParent(); + if (oldParent != null && oldParent != this) { + oldParent.removeView(menuView); + } + addView(menuView, layoutParams); + } else { + mActionMenuPresenter.setExpandedActionViewsExclusive(false); + // Allow full screen width in split mode. + mActionMenuPresenter.setWidthLimit( + getContext().getResources().getDisplayMetrics().widthPixels, true); + // No limit to the item count; use whatever will fit. + mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE); + // Span the whole width + layoutParams.width = LayoutParams.MATCH_PARENT; + configPresenters(builder); + menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this); + if (mSplitView != null) { + final ViewGroup oldParent = (ViewGroup) menuView.getParent(); + if (oldParent != null && oldParent != mSplitView) { + oldParent.removeView(menuView); + } + menuView.setVisibility(getAnimatedVisibility()); + mSplitView.addView(menuView, layoutParams); + } else { + // We'll add this later if we missed it this time. + menuView.setLayoutParams(layoutParams); + } + } + mMenuView = menuView; + } + + private void configPresenters(MenuBuilder builder) { + if (builder != null) { + builder.addMenuPresenter(mActionMenuPresenter); + builder.addMenuPresenter(mExpandedMenuPresenter); + } else { + mActionMenuPresenter.initForMenu(mContext, null); + mExpandedMenuPresenter.initForMenu(mContext, null); + mActionMenuPresenter.updateMenuView(true); + mExpandedMenuPresenter.updateMenuView(true); + } + } + + public boolean hasExpandedActionView() { + return mExpandedMenuPresenter != null && + mExpandedMenuPresenter.mCurrentExpandedItem != null; + } + + public void collapseActionView() { + final MenuItemImpl item = mExpandedMenuPresenter == null ? null : + mExpandedMenuPresenter.mCurrentExpandedItem; + if (item != null) { + item.collapseActionView(); + } + } + + public void setCustomNavigationView(View view) { + final boolean showCustom = (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0; + if (mCustomNavView != null && showCustom) { + removeView(mCustomNavView); + } + mCustomNavView = view; + if (mCustomNavView != null && showCustom) { + addView(mCustomNavView); + } + } + + public CharSequence getTitle() { + return mTitle; + } + + /** + * Set the action bar title. This will always replace or override window titles. + * @param title Title to set + * + * @see #setWindowTitle(CharSequence) + */ + public void setTitle(CharSequence title) { + mUserTitle = true; + setTitleImpl(title); + } + + /** + * Set the window title. A window title will always be replaced or overridden by a user title. + * @param title Title to set + * + * @see #setTitle(CharSequence) + */ + public void setWindowTitle(CharSequence title) { + if (!mUserTitle) { + setTitleImpl(title); + } + } + + private void setTitleImpl(CharSequence title) { + mTitle = title; + if (mTitleView != null) { + mTitleView.setText(title); + final boolean visible = mExpandedActionView == null && + (mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0 && + (!TextUtils.isEmpty(mTitle) || !TextUtils.isEmpty(mSubtitle)); + mTitleLayout.setVisibility(visible ? VISIBLE : GONE); + } + if (mLogoNavItem != null) { + mLogoNavItem.setTitle(title); + } + } + + public CharSequence getSubtitle() { + return mSubtitle; + } + + public void setSubtitle(CharSequence subtitle) { + mSubtitle = subtitle; + if (mSubtitleView != null) { + mSubtitleView.setText(subtitle); + mSubtitleView.setVisibility(subtitle != null ? VISIBLE : GONE); + final boolean visible = mExpandedActionView == null && + (mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0 && + (!TextUtils.isEmpty(mTitle) || !TextUtils.isEmpty(mSubtitle)); + mTitleLayout.setVisibility(visible ? VISIBLE : GONE); + } + } + + public void setHomeButtonEnabled(boolean enable) { + mHomeLayout.setEnabled(enable); + mHomeLayout.setFocusable(enable); + // Make sure the home button has an accurate content description for accessibility. + if (!enable) { + mHomeLayout.setContentDescription(null); + } else if ((mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0) { + mHomeLayout.setContentDescription(mContext.getResources().getText( + R.string.abs__action_bar_up_description)); + } else { + mHomeLayout.setContentDescription(mContext.getResources().getText( + R.string.abs__action_bar_home_description)); + } + } + + public void setDisplayOptions(int options) { + final int flagsChanged = mDisplayOptions == -1 ? -1 : options ^ mDisplayOptions; + mDisplayOptions = options; + + if ((flagsChanged & DISPLAY_RELAYOUT_MASK) != 0) { + final boolean showHome = (options & ActionBar.DISPLAY_SHOW_HOME) != 0; + final int vis = showHome && mExpandedActionView == null ? VISIBLE : GONE; + mHomeLayout.setVisibility(vis); + + if ((flagsChanged & ActionBar.DISPLAY_HOME_AS_UP) != 0) { + final boolean setUp = (options & ActionBar.DISPLAY_HOME_AS_UP) != 0; + mHomeLayout.setUp(setUp); + + // Showing home as up implicitly enables interaction with it. + // In honeycomb it was always enabled, so make this transition + // a bit easier for developers in the common case. + // (It would be silly to show it as up without responding to it.) + if (setUp) { + setHomeButtonEnabled(true); + } + } + + if ((flagsChanged & ActionBar.DISPLAY_USE_LOGO) != 0) { + final boolean logoVis = mLogo != null && (options & ActionBar.DISPLAY_USE_LOGO) != 0; + mHomeLayout.setIcon(logoVis ? mLogo : mIcon); + } + + if ((flagsChanged & ActionBar.DISPLAY_SHOW_TITLE) != 0) { + if ((options & ActionBar.DISPLAY_SHOW_TITLE) != 0) { + initTitle(); + } else { + removeView(mTitleLayout); + } + } + + if (mTitleLayout != null && (flagsChanged & + (ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME)) != 0) { + final boolean homeAsUp = (mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0; + mTitleUpView.setVisibility(!showHome ? (homeAsUp ? VISIBLE : INVISIBLE) : GONE); + mTitleLayout.setEnabled(!showHome && homeAsUp); + } + + if ((flagsChanged & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 && mCustomNavView != null) { + if ((options & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) { + addView(mCustomNavView); + } else { + removeView(mCustomNavView); + } + } + + requestLayout(); + } else { + invalidate(); + } + + // Make sure the home button has an accurate content description for accessibility. + if (!mHomeLayout.isEnabled()) { + mHomeLayout.setContentDescription(null); + } else if ((options & ActionBar.DISPLAY_HOME_AS_UP) != 0) { + mHomeLayout.setContentDescription(mContext.getResources().getText( + R.string.abs__action_bar_up_description)); + } else { + mHomeLayout.setContentDescription(mContext.getResources().getText( + R.string.abs__action_bar_home_description)); + } + } + + public void setIcon(Drawable icon) { + mIcon = icon; + if (icon != null && + ((mDisplayOptions & ActionBar.DISPLAY_USE_LOGO) == 0 || mLogo == null)) { + mHomeLayout.setIcon(icon); + } + } + + public void setIcon(int resId) { + setIcon(mContext.getResources().getDrawable(resId)); + } + + public void setLogo(Drawable logo) { + mLogo = logo; + if (logo != null && (mDisplayOptions & ActionBar.DISPLAY_USE_LOGO) != 0) { + mHomeLayout.setIcon(logo); + } + } + + public void setLogo(int resId) { + setLogo(mContext.getResources().getDrawable(resId)); + } + + public void setNavigationMode(int mode) { + final int oldMode = mNavigationMode; + if (mode != oldMode) { + switch (oldMode) { + case ActionBar.NAVIGATION_MODE_LIST: + if (mListNavLayout != null) { + removeView(mListNavLayout); + } + break; + case ActionBar.NAVIGATION_MODE_TABS: + if (mTabScrollView != null && mIncludeTabs) { + removeView(mTabScrollView); + } + } + + switch (mode) { + case ActionBar.NAVIGATION_MODE_LIST: + if (mSpinner == null) { + mSpinner = new IcsSpinner(mContext, null, + R.attr.actionDropDownStyle); + mListNavLayout = (IcsLinearLayout) LayoutInflater.from(mContext) + .inflate(R.layout.abs__action_bar_tab_bar_view, null); + LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( + LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); + params.gravity = Gravity.CENTER; + mListNavLayout.addView(mSpinner, params); + } + if (mSpinner.getAdapter() != mSpinnerAdapter) { + mSpinner.setAdapter(mSpinnerAdapter); + } + mSpinner.setOnItemSelectedListener(mNavItemSelectedListener); + addView(mListNavLayout); + break; + case ActionBar.NAVIGATION_MODE_TABS: + if (mTabScrollView != null && mIncludeTabs) { + addView(mTabScrollView); + } + break; + } + mNavigationMode = mode; + requestLayout(); + } + } + + public void setDropdownAdapter(SpinnerAdapter adapter) { + mSpinnerAdapter = adapter; + if (mSpinner != null) { + mSpinner.setAdapter(adapter); + } + } + + public SpinnerAdapter getDropdownAdapter() { + return mSpinnerAdapter; + } + + public void setDropdownSelectedPosition(int position) { + mSpinner.setSelection(position); + } + + public int getDropdownSelectedPosition() { + return mSpinner.getSelectedItemPosition(); + } + + public View getCustomNavigationView() { + return mCustomNavView; + } + + public int getNavigationMode() { + return mNavigationMode; + } + + public int getDisplayOptions() { + return mDisplayOptions; + } + + @Override + protected ViewGroup.LayoutParams generateDefaultLayoutParams() { + // Used by custom nav views if they don't supply layout params. Everything else + // added to an ActionBarView should have them already. + return new ActionBar.LayoutParams(DEFAULT_CUSTOM_GRAVITY); + } + + @Override + protected void onFinishInflate() { + super.onFinishInflate(); + + addView(mHomeLayout); + + if (mCustomNavView != null && (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) { + final ViewParent parent = mCustomNavView.getParent(); + if (parent != this) { + if (parent instanceof ViewGroup) { + ((ViewGroup) parent).removeView(mCustomNavView); + } + addView(mCustomNavView); + } + } + } + + private void initTitle() { + if (mTitleLayout == null) { + LayoutInflater inflater = LayoutInflater.from(getContext()); + mTitleLayout = (LinearLayout) inflater.inflate(R.layout.abs__action_bar_title_item, + this, false); + mTitleView = (TextView) mTitleLayout.findViewById(R.id.abs__action_bar_title); + mSubtitleView = (TextView) mTitleLayout.findViewById(R.id.abs__action_bar_subtitle); + mTitleUpView = mTitleLayout.findViewById(R.id.abs__up); + + mTitleLayout.setOnClickListener(mUpClickListener); + + if (mTitleStyleRes != 0) { + mTitleView.setTextAppearance(mContext, mTitleStyleRes); + } + if (mTitle != null) { + mTitleView.setText(mTitle); + } + + if (mSubtitleStyleRes != 0) { + mSubtitleView.setTextAppearance(mContext, mSubtitleStyleRes); + } + if (mSubtitle != null) { + mSubtitleView.setText(mSubtitle); + mSubtitleView.setVisibility(VISIBLE); + } + + final boolean homeAsUp = (mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0; + final boolean showHome = (mDisplayOptions & ActionBar.DISPLAY_SHOW_HOME) != 0; + mTitleUpView.setVisibility(!showHome ? (homeAsUp ? VISIBLE : INVISIBLE) : GONE); + mTitleLayout.setEnabled(homeAsUp && !showHome); + } + + addView(mTitleLayout); + if (mExpandedActionView != null || + (TextUtils.isEmpty(mTitle) && TextUtils.isEmpty(mSubtitle))) { + // Don't show while in expanded mode or with empty text + mTitleLayout.setVisibility(GONE); + } + } + + public void setContextView(ActionBarContextView view) { + mContextView = view; + } + + public void setCollapsable(boolean collapsable) { + mIsCollapsable = collapsable; + } + + public boolean isCollapsed() { + return mIsCollapsed; + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + final int childCount = getChildCount(); + if (mIsCollapsable) { + int visibleChildren = 0; + for (int i = 0; i < childCount; i++) { + final View child = getChildAt(i); + if (child.getVisibility() != GONE && + !(child == mMenuView && mMenuView.getChildCount() == 0)) { + visibleChildren++; + } + } + + if (visibleChildren == 0) { + // No size for an empty action bar when collapsable. + setMeasuredDimension(0, 0); + mIsCollapsed = true; + return; + } + } + mIsCollapsed = false; + + int widthMode = MeasureSpec.getMode(widthMeasureSpec); + if (widthMode != MeasureSpec.EXACTLY) { + throw new IllegalStateException(getClass().getSimpleName() + " can only be used " + + "with android:layout_width=\"match_parent\" (or fill_parent)"); + } + + int heightMode = MeasureSpec.getMode(heightMeasureSpec); + if (heightMode != MeasureSpec.AT_MOST) { + throw new IllegalStateException(getClass().getSimpleName() + " can only be used " + + "with android:layout_height=\"wrap_content\""); + } + + int contentWidth = MeasureSpec.getSize(widthMeasureSpec); + + int maxHeight = mContentHeight > 0 ? + mContentHeight : MeasureSpec.getSize(heightMeasureSpec); + + final int verticalPadding = getPaddingTop() + getPaddingBottom(); + final int paddingLeft = getPaddingLeft(); + final int paddingRight = getPaddingRight(); + final int height = maxHeight - verticalPadding; + final int childSpecHeight = MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST); + + int availableWidth = contentWidth - paddingLeft - paddingRight; + int leftOfCenter = availableWidth / 2; + int rightOfCenter = leftOfCenter; + + HomeView homeLayout = mExpandedActionView != null ? mExpandedHomeLayout : mHomeLayout; + + if (homeLayout.getVisibility() != GONE) { + final ViewGroup.LayoutParams lp = homeLayout.getLayoutParams(); + int homeWidthSpec; + if (lp.width < 0) { + homeWidthSpec = MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST); + } else { + homeWidthSpec = MeasureSpec.makeMeasureSpec(lp.width, MeasureSpec.EXACTLY); + } + homeLayout.measure(homeWidthSpec, + MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY)); + final int homeWidth = homeLayout.getMeasuredWidth() + homeLayout.getLeftOffset(); + availableWidth = Math.max(0, availableWidth - homeWidth); + leftOfCenter = Math.max(0, availableWidth - homeWidth); + } + + if (mMenuView != null && mMenuView.getParent() == this) { + availableWidth = measureChildView(mMenuView, availableWidth, + childSpecHeight, 0); + rightOfCenter = Math.max(0, rightOfCenter - mMenuView.getMeasuredWidth()); + } + + if (mIndeterminateProgressView != null && + mIndeterminateProgressView.getVisibility() != GONE) { + availableWidth = measureChildView(mIndeterminateProgressView, availableWidth, + childSpecHeight, 0); + rightOfCenter = Math.max(0, + rightOfCenter - mIndeterminateProgressView.getMeasuredWidth()); + } + + final boolean showTitle = mTitleLayout != null && mTitleLayout.getVisibility() != GONE && + (mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0; + + if (mExpandedActionView == null) { + switch (mNavigationMode) { + case ActionBar.NAVIGATION_MODE_LIST: + if (mListNavLayout != null) { + final int itemPaddingSize = showTitle ? mItemPadding * 2 : mItemPadding; + availableWidth = Math.max(0, availableWidth - itemPaddingSize); + leftOfCenter = Math.max(0, leftOfCenter - itemPaddingSize); + mListNavLayout.measure( + MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST), + MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY)); + final int listNavWidth = mListNavLayout.getMeasuredWidth(); + availableWidth = Math.max(0, availableWidth - listNavWidth); + leftOfCenter = Math.max(0, leftOfCenter - listNavWidth); + } + break; + case ActionBar.NAVIGATION_MODE_TABS: + if (mTabScrollView != null) { + final int itemPaddingSize = showTitle ? mItemPadding * 2 : mItemPadding; + availableWidth = Math.max(0, availableWidth - itemPaddingSize); + leftOfCenter = Math.max(0, leftOfCenter - itemPaddingSize); + mTabScrollView.measure( + MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST), + MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY)); + final int tabWidth = mTabScrollView.getMeasuredWidth(); + availableWidth = Math.max(0, availableWidth - tabWidth); + leftOfCenter = Math.max(0, leftOfCenter - tabWidth); + } + break; + } + } + + View customView = null; + if (mExpandedActionView != null) { + customView = mExpandedActionView; + } else if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 && + mCustomNavView != null) { + customView = mCustomNavView; + } + + if (customView != null) { + final ViewGroup.LayoutParams lp = generateLayoutParams(customView.getLayoutParams()); + final ActionBar.LayoutParams ablp = lp instanceof ActionBar.LayoutParams ? + (ActionBar.LayoutParams) lp : null; + + int horizontalMargin = 0; + int verticalMargin = 0; + if (ablp != null) { + horizontalMargin = ablp.leftMargin + ablp.rightMargin; + verticalMargin = ablp.topMargin + ablp.bottomMargin; + } + + // If the action bar is wrapping to its content height, don't allow a custom + // view to MATCH_PARENT. + int customNavHeightMode; + if (mContentHeight <= 0) { + customNavHeightMode = MeasureSpec.AT_MOST; + } else { + customNavHeightMode = lp.height != LayoutParams.WRAP_CONTENT ? + MeasureSpec.EXACTLY : MeasureSpec.AT_MOST; + } + final int customNavHeight = Math.max(0, + (lp.height >= 0 ? Math.min(lp.height, height) : height) - verticalMargin); + + final int customNavWidthMode = lp.width != LayoutParams.WRAP_CONTENT ? + MeasureSpec.EXACTLY : MeasureSpec.AT_MOST; + int customNavWidth = Math.max(0, + (lp.width >= 0 ? Math.min(lp.width, availableWidth) : availableWidth) + - horizontalMargin); + final int hgrav = (ablp != null ? ablp.gravity : DEFAULT_CUSTOM_GRAVITY) & + Gravity.HORIZONTAL_GRAVITY_MASK; + + // Centering a custom view is treated specially; we try to center within the whole + // action bar rather than in the available space. + if (hgrav == Gravity.CENTER_HORIZONTAL && lp.width == LayoutParams.MATCH_PARENT) { + customNavWidth = Math.min(leftOfCenter, rightOfCenter) * 2; + } + + customView.measure( + MeasureSpec.makeMeasureSpec(customNavWidth, customNavWidthMode), + MeasureSpec.makeMeasureSpec(customNavHeight, customNavHeightMode)); + availableWidth -= horizontalMargin + customView.getMeasuredWidth(); + } + + if (mExpandedActionView == null && showTitle) { + availableWidth = measureChildView(mTitleLayout, availableWidth, + MeasureSpec.makeMeasureSpec(mContentHeight, MeasureSpec.EXACTLY), 0); + leftOfCenter = Math.max(0, leftOfCenter - mTitleLayout.getMeasuredWidth()); + } + + if (mContentHeight <= 0) { + int measuredHeight = 0; + for (int i = 0; i < childCount; i++) { + View v = getChildAt(i); + int paddedViewHeight = v.getMeasuredHeight() + verticalPadding; + if (paddedViewHeight > measuredHeight) { + measuredHeight = paddedViewHeight; + } + } + setMeasuredDimension(contentWidth, measuredHeight); + } else { + setMeasuredDimension(contentWidth, maxHeight); + } + + if (mContextView != null) { + mContextView.setContentHeight(getMeasuredHeight()); + } + + if (mProgressView != null && mProgressView.getVisibility() != GONE) { + mProgressView.measure(MeasureSpec.makeMeasureSpec( + contentWidth - mProgressBarPadding * 2, MeasureSpec.EXACTLY), + MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.AT_MOST)); + } + } + + @Override + protected void onLayout(boolean changed, int l, int t, int r, int b) { + int x = getPaddingLeft(); + final int y = getPaddingTop(); + final int contentHeight = b - t - getPaddingTop() - getPaddingBottom(); + + if (contentHeight <= 0) { + // Nothing to do if we can't see anything. + return; + } + + HomeView homeLayout = mExpandedActionView != null ? mExpandedHomeLayout : mHomeLayout; + if (homeLayout.getVisibility() != GONE) { + final int leftOffset = homeLayout.getLeftOffset(); + x += positionChild(homeLayout, x + leftOffset, y, contentHeight) + leftOffset; + } + + if (mExpandedActionView == null) { + final boolean showTitle = mTitleLayout != null && mTitleLayout.getVisibility() != GONE && + (mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0; + if (showTitle) { + x += positionChild(mTitleLayout, x, y, contentHeight); + } + + switch (mNavigationMode) { + case ActionBar.NAVIGATION_MODE_STANDARD: + break; + case ActionBar.NAVIGATION_MODE_LIST: + if (mListNavLayout != null) { + if (showTitle) x += mItemPadding; + x += positionChild(mListNavLayout, x, y, contentHeight) + mItemPadding; + } + break; + case ActionBar.NAVIGATION_MODE_TABS: + if (mTabScrollView != null) { + if (showTitle) x += mItemPadding; + x += positionChild(mTabScrollView, x, y, contentHeight) + mItemPadding; + } + break; + } + } + + int menuLeft = r - l - getPaddingRight(); + if (mMenuView != null && mMenuView.getParent() == this) { + positionChildInverse(mMenuView, menuLeft, y, contentHeight); + menuLeft -= mMenuView.getMeasuredWidth(); + } + + if (mIndeterminateProgressView != null && + mIndeterminateProgressView.getVisibility() != GONE) { + positionChildInverse(mIndeterminateProgressView, menuLeft, y, contentHeight); + menuLeft -= mIndeterminateProgressView.getMeasuredWidth(); + } + + View customView = null; + if (mExpandedActionView != null) { + customView = mExpandedActionView; + } else if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 && + mCustomNavView != null) { + customView = mCustomNavView; + } + if (customView != null) { + ViewGroup.LayoutParams lp = customView.getLayoutParams(); + final ActionBar.LayoutParams ablp = lp instanceof ActionBar.LayoutParams ? + (ActionBar.LayoutParams) lp : null; + + final int gravity = ablp != null ? ablp.gravity : DEFAULT_CUSTOM_GRAVITY; + final int navWidth = customView.getMeasuredWidth(); + + int topMargin = 0; + int bottomMargin = 0; + if (ablp != null) { + x += ablp.leftMargin; + menuLeft -= ablp.rightMargin; + topMargin = ablp.topMargin; + bottomMargin = ablp.bottomMargin; + } + + int hgravity = gravity & Gravity.HORIZONTAL_GRAVITY_MASK; + // See if we actually have room to truly center; if not push against left or right. + if (hgravity == Gravity.CENTER_HORIZONTAL) { + final int centeredLeft = ((getRight() - getLeft()) - navWidth) / 2; + if (centeredLeft < x) { + hgravity = Gravity.LEFT; + } else if (centeredLeft + navWidth > menuLeft) { + hgravity = Gravity.RIGHT; + } + } else if (gravity == -1) { + hgravity = Gravity.LEFT; + } + + int xpos = 0; + switch (hgravity) { + case Gravity.CENTER_HORIZONTAL: + xpos = ((getRight() - getLeft()) - navWidth) / 2; + break; + case Gravity.LEFT: + xpos = x; + break; + case Gravity.RIGHT: + xpos = menuLeft - navWidth; + break; + } + + int vgravity = gravity & Gravity.VERTICAL_GRAVITY_MASK; + + if (gravity == -1) { + vgravity = Gravity.CENTER_VERTICAL; + } + + int ypos = 0; + switch (vgravity) { + case Gravity.CENTER_VERTICAL: + final int paddedTop = getPaddingTop(); + final int paddedBottom = getBottom() - getTop() - getPaddingBottom(); + ypos = ((paddedBottom - paddedTop) - customView.getMeasuredHeight()) / 2; + break; + case Gravity.TOP: + ypos = getPaddingTop() + topMargin; + break; + case Gravity.BOTTOM: + ypos = getHeight() - getPaddingBottom() - customView.getMeasuredHeight() + - bottomMargin; + break; + } + final int customWidth = customView.getMeasuredWidth(); + customView.layout(xpos, ypos, xpos + customWidth, + ypos + customView.getMeasuredHeight()); + x += customWidth; + } + + if (mProgressView != null) { + mProgressView.bringToFront(); + final int halfProgressHeight = mProgressView.getMeasuredHeight() / 2; + mProgressView.layout(mProgressBarPadding, -halfProgressHeight, + mProgressBarPadding + mProgressView.getMeasuredWidth(), halfProgressHeight); + } + } + + @Override + public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs) { + return new ActionBar.LayoutParams(getContext(), attrs); + } + + @Override + public ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) { + if (lp == null) { + lp = generateDefaultLayoutParams(); + } + return lp; + } + + @Override + public Parcelable onSaveInstanceState() { + Parcelable superState = super.onSaveInstanceState(); + SavedState state = new SavedState(superState); + + if (mExpandedMenuPresenter != null && mExpandedMenuPresenter.mCurrentExpandedItem != null) { + state.expandedMenuItemId = mExpandedMenuPresenter.mCurrentExpandedItem.getItemId(); + } + + state.isOverflowOpen = isOverflowMenuShowing(); + + return state; + } + + @Override + public void onRestoreInstanceState(Parcelable p) { + SavedState state = (SavedState) p; + + super.onRestoreInstanceState(state.getSuperState()); + + if (state.expandedMenuItemId != 0 && + mExpandedMenuPresenter != null && mOptionsMenu != null) { + final MenuItem item = mOptionsMenu.findItem(state.expandedMenuItemId); + if (item != null) { + item.expandActionView(); + } + } + + if (state.isOverflowOpen) { + postShowOverflowMenu(); + } + } + + static class SavedState extends BaseSavedState { + int expandedMenuItemId; + boolean isOverflowOpen; + + SavedState(Parcelable superState) { + super(superState); + } + + private SavedState(Parcel in) { + super(in); + expandedMenuItemId = in.readInt(); + isOverflowOpen = in.readInt() != 0; + } + + @Override + public void writeToParcel(Parcel out, int flags) { + super.writeToParcel(out, flags); + out.writeInt(expandedMenuItemId); + out.writeInt(isOverflowOpen ? 1 : 0); + } + + public static final Parcelable.Creator CREATOR = + new Parcelable.Creator() { + public SavedState createFromParcel(Parcel in) { + return new SavedState(in); + } + + public SavedState[] newArray(int size) { + return new SavedState[size]; + } + }; + } + + public static class HomeView extends FrameLayout { + private View mUpView; + private ImageView mIconView; + private int mUpWidth; + + public HomeView(Context context) { + this(context, null); + } + + public HomeView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public void setUp(boolean isUp) { + mUpView.setVisibility(isUp ? VISIBLE : GONE); + } + + public void setIcon(Drawable icon) { + mIconView.setImageDrawable(icon); + } + + @Override + public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { + onPopulateAccessibilityEvent(event); + return true; + } + + @Override + public void onPopulateAccessibilityEvent(AccessibilityEvent event) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { + super.onPopulateAccessibilityEvent(event); + } + final CharSequence cdesc = getContentDescription(); + if (!TextUtils.isEmpty(cdesc)) { + event.getText().add(cdesc); + } + } + + @Override + public boolean dispatchHoverEvent(MotionEvent event) { + // Don't allow children to hover; we want this to be treated as a single component. + return onHoverEvent(event); + } + + @Override + protected void onFinishInflate() { + mUpView = findViewById(R.id.abs__up); + mIconView = (ImageView) findViewById(R.id.abs__home); + } + + public int getLeftOffset() { + return mUpView.getVisibility() == GONE ? mUpWidth : 0; + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + measureChildWithMargins(mUpView, widthMeasureSpec, 0, heightMeasureSpec, 0); + final LayoutParams upLp = (LayoutParams) mUpView.getLayoutParams(); + mUpWidth = upLp.leftMargin + mUpView.getMeasuredWidth() + upLp.rightMargin; + int width = mUpView.getVisibility() == GONE ? 0 : mUpWidth; + int height = upLp.topMargin + mUpView.getMeasuredHeight() + upLp.bottomMargin; + measureChildWithMargins(mIconView, widthMeasureSpec, width, heightMeasureSpec, 0); + final LayoutParams iconLp = (LayoutParams) mIconView.getLayoutParams(); + width += iconLp.leftMargin + mIconView.getMeasuredWidth() + iconLp.rightMargin; + height = Math.max(height, + iconLp.topMargin + mIconView.getMeasuredHeight() + iconLp.bottomMargin); + + final int widthMode = MeasureSpec.getMode(widthMeasureSpec); + final int heightMode = MeasureSpec.getMode(heightMeasureSpec); + final int widthSize = MeasureSpec.getSize(widthMeasureSpec); + final int heightSize = MeasureSpec.getSize(heightMeasureSpec); + + switch (widthMode) { + case MeasureSpec.AT_MOST: + width = Math.min(width, widthSize); + break; + case MeasureSpec.EXACTLY: + width = widthSize; + break; + case MeasureSpec.UNSPECIFIED: + default: + break; + } + switch (heightMode) { + case MeasureSpec.AT_MOST: + height = Math.min(height, heightSize); + break; + case MeasureSpec.EXACTLY: + height = heightSize; + break; + case MeasureSpec.UNSPECIFIED: + default: + break; + } + setMeasuredDimension(width, height); + } + + @Override + protected void onLayout(boolean changed, int l, int t, int r, int b) { + final int vCenter = (b - t) / 2; + //UNUSED int width = r - l; + int upOffset = 0; + if (mUpView.getVisibility() != GONE) { + final LayoutParams upLp = (LayoutParams) mUpView.getLayoutParams(); + final int upHeight = mUpView.getMeasuredHeight(); + final int upWidth = mUpView.getMeasuredWidth(); + final int upTop = vCenter - upHeight / 2; + mUpView.layout(0, upTop, upWidth, upTop + upHeight); + upOffset = upLp.leftMargin + upWidth + upLp.rightMargin; + //UNUSED width -= upOffset; + l += upOffset; + } + final LayoutParams iconLp = (LayoutParams) mIconView.getLayoutParams(); + final int iconHeight = mIconView.getMeasuredHeight(); + final int iconWidth = mIconView.getMeasuredWidth(); + final int hCenter = (r - l) / 2; + final int iconLeft = upOffset + Math.max(iconLp.leftMargin, hCenter - iconWidth / 2); + final int iconTop = Math.max(iconLp.topMargin, vCenter - iconHeight / 2); + mIconView.layout(iconLeft, iconTop, iconLeft + iconWidth, iconTop + iconHeight); + } + } + + private class ExpandedActionViewMenuPresenter implements MenuPresenter { + MenuBuilder mMenu; + MenuItemImpl mCurrentExpandedItem; + + @Override + public void initForMenu(Context context, MenuBuilder menu) { + // Clear the expanded action view when menus change. + if (mMenu != null && mCurrentExpandedItem != null) { + mMenu.collapseItemActionView(mCurrentExpandedItem); + } + mMenu = menu; + } + + @Override + public MenuView getMenuView(ViewGroup root) { + return null; + } + + @Override + public void updateMenuView(boolean cleared) { + // Make sure the expanded item we have is still there. + if (mCurrentExpandedItem != null) { + boolean found = false; + + if (mMenu != null) { + final int count = mMenu.size(); + for (int i = 0; i < count; i++) { + final MenuItem item = mMenu.getItem(i); + if (item == mCurrentExpandedItem) { + found = true; + break; + } + } + } + + if (!found) { + // The item we had expanded disappeared. Collapse. + collapseItemActionView(mMenu, mCurrentExpandedItem); + } + } + } + + @Override + public void setCallback(Callback cb) { + } + + @Override + public boolean onSubMenuSelected(SubMenuBuilder subMenu) { + return false; + } + + @Override + public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) { + } + + @Override + public boolean flagActionItems() { + return false; + } + + @Override + public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item) { + mExpandedActionView = item.getActionView(); + mExpandedHomeLayout.setIcon(mIcon.getConstantState().newDrawable(/* TODO getResources() */)); + mCurrentExpandedItem = item; + if (mExpandedActionView.getParent() != ActionBarView.this) { + addView(mExpandedActionView); + } + if (mExpandedHomeLayout.getParent() != ActionBarView.this) { + addView(mExpandedHomeLayout); + } + mHomeLayout.setVisibility(GONE); + if (mTitleLayout != null) mTitleLayout.setVisibility(GONE); + if (mTabScrollView != null) mTabScrollView.setVisibility(GONE); + if (mSpinner != null) mSpinner.setVisibility(GONE); + if (mCustomNavView != null) mCustomNavView.setVisibility(GONE); + requestLayout(); + item.setActionViewExpanded(true); + + if (mExpandedActionView instanceof CollapsibleActionView) { + ((CollapsibleActionView) mExpandedActionView).onActionViewExpanded(); + } + + return true; + } + + @Override + public boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item) { + // Do this before detaching the actionview from the hierarchy, in case + // it needs to dismiss the soft keyboard, etc. + if (mExpandedActionView instanceof CollapsibleActionView) { + ((CollapsibleActionView) mExpandedActionView).onActionViewCollapsed(); + } + + removeView(mExpandedActionView); + removeView(mExpandedHomeLayout); + mExpandedActionView = null; + if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_HOME) != 0) { + mHomeLayout.setVisibility(VISIBLE); + } + if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0) { + if (mTitleLayout == null) { + initTitle(); + } else { + mTitleLayout.setVisibility(VISIBLE); + } + } + if (mTabScrollView != null && mNavigationMode == ActionBar.NAVIGATION_MODE_TABS) { + mTabScrollView.setVisibility(VISIBLE); + } + if (mSpinner != null && mNavigationMode == ActionBar.NAVIGATION_MODE_LIST) { + mSpinner.setVisibility(VISIBLE); + } + if (mCustomNavView != null && (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) { + mCustomNavView.setVisibility(VISIBLE); + } + mExpandedHomeLayout.setIcon(null); + mCurrentExpandedItem = null; + requestLayout(); + item.setActionViewExpanded(false); + + return true; + } + + @Override + public int getId() { + return 0; + } + + @Override + public Parcelable onSaveInstanceState() { + return null; + } + + @Override + public void onRestoreInstanceState(Parcelable state) { + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/CapitalizingButton.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/CapitalizingButton.java new file mode 100644 index 000000000..fa3698f3b --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/CapitalizingButton.java @@ -0,0 +1,40 @@ +package com.actionbarsherlock.internal.widget; + +import java.util.Locale; +import android.content.Context; +import android.content.res.TypedArray; +import android.os.Build; +import android.util.AttributeSet; +import android.widget.Button; + +public class CapitalizingButton extends Button { + private static final boolean SANS_ICE_CREAM = Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH; + private static final boolean IS_GINGERBREAD = Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD; + + private static final int[] R_styleable_Button = new int[] { + android.R.attr.textAllCaps + }; + private static final int R_styleable_Button_textAllCaps = 0; + + private boolean mAllCaps; + + public CapitalizingButton(Context context, AttributeSet attrs) { + super(context, attrs); + + TypedArray a = context.obtainStyledAttributes(attrs, R_styleable_Button); + mAllCaps = a.getBoolean(R_styleable_Button_textAllCaps, true); + a.recycle(); + } + + public void setTextCompat(CharSequence text) { + if (SANS_ICE_CREAM && mAllCaps && text != null) { + if (IS_GINGERBREAD) { + setText(text.toString().toUpperCase(Locale.ROOT)); + } else { + setText(text.toString().toUpperCase()); + } + } else { + setText(text); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/CapitalizingTextView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/CapitalizingTextView.java new file mode 100644 index 000000000..673ec554f --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/CapitalizingTextView.java @@ -0,0 +1,44 @@ +package com.actionbarsherlock.internal.widget; + +import java.util.Locale; +import android.content.Context; +import android.content.res.TypedArray; +import android.os.Build; +import android.util.AttributeSet; +import android.widget.TextView; + +public class CapitalizingTextView extends TextView { + private static final boolean SANS_ICE_CREAM = Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH; + private static final boolean IS_GINGERBREAD = Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD; + + private static final int[] R_styleable_TextView = new int[] { + android.R.attr.textAllCaps + }; + private static final int R_styleable_TextView_textAllCaps = 0; + + private boolean mAllCaps; + + public CapitalizingTextView(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public CapitalizingTextView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + + TypedArray a = context.obtainStyledAttributes(attrs, R_styleable_TextView, defStyle, 0); + mAllCaps = a.getBoolean(R_styleable_TextView_textAllCaps, true); + a.recycle(); + } + + public void setTextCompat(CharSequence text) { + if (SANS_ICE_CREAM && mAllCaps && text != null) { + if (IS_GINGERBREAD) { + setText(text.toString().toUpperCase(Locale.ROOT)); + } else { + setText(text.toString().toUpperCase()); + } + } else { + setText(text); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/FakeDialogPhoneWindow.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/FakeDialogPhoneWindow.java new file mode 100644 index 000000000..ad1b4f0a8 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/FakeDialogPhoneWindow.java @@ -0,0 +1,64 @@ +package com.actionbarsherlock.internal.widget; + +import static android.view.View.MeasureSpec.EXACTLY; +import android.content.Context; +import android.content.res.TypedArray; +import android.util.AttributeSet; +import android.util.DisplayMetrics; +import android.util.TypedValue; +import android.widget.LinearLayout; +import com.actionbarsherlock.R; + +public class FakeDialogPhoneWindow extends LinearLayout { + final TypedValue mMinWidthMajor = new TypedValue(); + final TypedValue mMinWidthMinor = new TypedValue(); + + public FakeDialogPhoneWindow(Context context, AttributeSet attrs) { + super(context, attrs); + + TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockTheme); + + a.getValue(R.styleable.SherlockTheme_windowMinWidthMajor, mMinWidthMajor); + a.getValue(R.styleable.SherlockTheme_windowMinWidthMinor, mMinWidthMinor); + + a.recycle(); + } + + /* Stolen from PhoneWindow */ + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + final DisplayMetrics metrics = getContext().getResources().getDisplayMetrics(); + final boolean isPortrait = metrics.widthPixels < metrics.heightPixels; + + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + + int width = getMeasuredWidth(); + boolean measure = false; + + widthMeasureSpec = MeasureSpec.makeMeasureSpec(width, EXACTLY); + + final TypedValue tv = isPortrait ? mMinWidthMinor : mMinWidthMajor; + + if (tv.type != TypedValue.TYPE_NULL) { + final int min; + if (tv.type == TypedValue.TYPE_DIMENSION) { + min = (int)tv.getDimension(metrics); + } else if (tv.type == TypedValue.TYPE_FRACTION) { + min = (int)tv.getFraction(metrics.widthPixels, metrics.widthPixels); + } else { + min = 0; + } + + if (width < min) { + widthMeasureSpec = MeasureSpec.makeMeasureSpec(min, EXACTLY); + measure = true; + } + } + + // TODO: Support height? + + if (measure) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsAbsSpinner.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsAbsSpinner.java new file mode 100644 index 000000000..ce0cb3bca --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsAbsSpinner.java @@ -0,0 +1,479 @@ +/* + * Copyright (C) 2006 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.actionbarsherlock.internal.widget; + +import android.content.Context; +import android.database.DataSetObserver; +import android.graphics.Rect; +import android.os.Build; +import android.os.Parcel; +import android.os.Parcelable; +import android.util.AttributeSet; +import android.util.SparseArray; +import android.view.View; +import android.view.ViewGroup; +import android.widget.SpinnerAdapter; + +/** + * An abstract base class for spinner widgets. SDK users will probably not + * need to use this class. + * + * @attr ref android.R.styleable#AbsSpinner_entries + */ +public abstract class IcsAbsSpinner extends IcsAdapterView { + private static final boolean IS_HONEYCOMB = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB; + + SpinnerAdapter mAdapter; + + int mHeightMeasureSpec; + int mWidthMeasureSpec; + boolean mBlockLayoutRequests; + + int mSelectionLeftPadding = 0; + int mSelectionTopPadding = 0; + int mSelectionRightPadding = 0; + int mSelectionBottomPadding = 0; + final Rect mSpinnerPadding = new Rect(); + + final RecycleBin mRecycler = new RecycleBin(); + private DataSetObserver mDataSetObserver; + + /** Temporary frame to hold a child View's frame rectangle */ + private Rect mTouchFrame; + + public IcsAbsSpinner(Context context) { + super(context); + initAbsSpinner(); + } + + public IcsAbsSpinner(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public IcsAbsSpinner(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + initAbsSpinner(); + + /* + TypedArray a = context.obtainStyledAttributes(attrs, + com.android.internal.R.styleable.AbsSpinner, defStyle, 0); + + CharSequence[] entries = a.getTextArray(R.styleable.AbsSpinner_entries); + if (entries != null) { + ArrayAdapter adapter = + new ArrayAdapter(context, + R.layout.simple_spinner_item, entries); + adapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item); + setAdapter(adapter); + } + + a.recycle(); + */ + } + + /** + * Common code for different constructor flavors + */ + private void initAbsSpinner() { + setFocusable(true); + setWillNotDraw(false); + } + + /** + * The Adapter is used to provide the data which backs this Spinner. + * It also provides methods to transform spinner items based on their position + * relative to the selected item. + * @param adapter The SpinnerAdapter to use for this Spinner + */ + @Override + public void setAdapter(SpinnerAdapter adapter) { + if (null != mAdapter) { + mAdapter.unregisterDataSetObserver(mDataSetObserver); + resetList(); + } + + mAdapter = adapter; + + mOldSelectedPosition = INVALID_POSITION; + mOldSelectedRowId = INVALID_ROW_ID; + + if (mAdapter != null) { + mOldItemCount = mItemCount; + mItemCount = mAdapter.getCount(); + checkFocus(); + + mDataSetObserver = new AdapterDataSetObserver(); + mAdapter.registerDataSetObserver(mDataSetObserver); + + int position = mItemCount > 0 ? 0 : INVALID_POSITION; + + setSelectedPositionInt(position); + setNextSelectedPositionInt(position); + + if (mItemCount == 0) { + // Nothing selected + checkSelectionChanged(); + } + + } else { + checkFocus(); + resetList(); + // Nothing selected + checkSelectionChanged(); + } + + requestLayout(); + } + + /** + * Clear out all children from the list + */ + void resetList() { + mDataChanged = false; + mNeedSync = false; + + removeAllViewsInLayout(); + mOldSelectedPosition = INVALID_POSITION; + mOldSelectedRowId = INVALID_ROW_ID; + + setSelectedPositionInt(INVALID_POSITION); + setNextSelectedPositionInt(INVALID_POSITION); + invalidate(); + } + + /** + * @see android.view.View#measure(int, int) + * + * Figure out the dimensions of this Spinner. The width comes from + * the widthMeasureSpec as Spinnners can't have their width set to + * UNSPECIFIED. The height is based on the height of the selected item + * plus padding. + */ + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + int widthMode = MeasureSpec.getMode(widthMeasureSpec); + int widthSize; + int heightSize; + + final int mPaddingLeft = getPaddingLeft(); + final int mPaddingTop = getPaddingTop(); + final int mPaddingRight = getPaddingRight(); + final int mPaddingBottom = getPaddingBottom(); + + mSpinnerPadding.left = mPaddingLeft > mSelectionLeftPadding ? mPaddingLeft + : mSelectionLeftPadding; + mSpinnerPadding.top = mPaddingTop > mSelectionTopPadding ? mPaddingTop + : mSelectionTopPadding; + mSpinnerPadding.right = mPaddingRight > mSelectionRightPadding ? mPaddingRight + : mSelectionRightPadding; + mSpinnerPadding.bottom = mPaddingBottom > mSelectionBottomPadding ? mPaddingBottom + : mSelectionBottomPadding; + + if (mDataChanged) { + handleDataChanged(); + } + + int preferredHeight = 0; + int preferredWidth = 0; + boolean needsMeasuring = true; + + int selectedPosition = getSelectedItemPosition(); + if (selectedPosition >= 0 && mAdapter != null && selectedPosition < mAdapter.getCount()) { + // Try looking in the recycler. (Maybe we were measured once already) + View view = mRecycler.get(selectedPosition); + if (view == null) { + // Make a new one + view = mAdapter.getView(selectedPosition, null, this); + } + + if (view != null) { + // Put in recycler for re-measuring and/or layout + mRecycler.put(selectedPosition, view); + } + + if (view != null) { + if (view.getLayoutParams() == null) { + mBlockLayoutRequests = true; + view.setLayoutParams(generateDefaultLayoutParams()); + mBlockLayoutRequests = false; + } + measureChild(view, widthMeasureSpec, heightMeasureSpec); + + preferredHeight = getChildHeight(view) + mSpinnerPadding.top + mSpinnerPadding.bottom; + preferredWidth = getChildWidth(view) + mSpinnerPadding.left + mSpinnerPadding.right; + + needsMeasuring = false; + } + } + + if (needsMeasuring) { + // No views -- just use padding + preferredHeight = mSpinnerPadding.top + mSpinnerPadding.bottom; + if (widthMode == MeasureSpec.UNSPECIFIED) { + preferredWidth = mSpinnerPadding.left + mSpinnerPadding.right; + } + } + + preferredHeight = Math.max(preferredHeight, getSuggestedMinimumHeight()); + preferredWidth = Math.max(preferredWidth, getSuggestedMinimumWidth()); + + if (IS_HONEYCOMB) { + heightSize = resolveSizeAndState(preferredHeight, heightMeasureSpec, 0); + widthSize = resolveSizeAndState(preferredWidth, widthMeasureSpec, 0); + } else { + heightSize = resolveSize(preferredHeight, heightMeasureSpec); + widthSize = resolveSize(preferredWidth, widthMeasureSpec); + } + + setMeasuredDimension(widthSize, heightSize); + mHeightMeasureSpec = heightMeasureSpec; + mWidthMeasureSpec = widthMeasureSpec; + } + + int getChildHeight(View child) { + return child.getMeasuredHeight(); + } + + int getChildWidth(View child) { + return child.getMeasuredWidth(); + } + + @Override + protected ViewGroup.LayoutParams generateDefaultLayoutParams() { + return new ViewGroup.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.WRAP_CONTENT); + } + + void recycleAllViews() { + final int childCount = getChildCount(); + final IcsAbsSpinner.RecycleBin recycleBin = mRecycler; + final int position = mFirstPosition; + + // All views go in recycler + for (int i = 0; i < childCount; i++) { + View v = getChildAt(i); + int index = position + i; + recycleBin.put(index, v); + } + } + + /** + * Jump directly to a specific item in the adapter data. + */ + public void setSelection(int position, boolean animate) { + // Animate only if requested position is already on screen somewhere + boolean shouldAnimate = animate && mFirstPosition <= position && + position <= mFirstPosition + getChildCount() - 1; + setSelectionInt(position, shouldAnimate); + } + + @Override + public void setSelection(int position) { + setNextSelectedPositionInt(position); + requestLayout(); + invalidate(); + } + + + /** + * Makes the item at the supplied position selected. + * + * @param position Position to select + * @param animate Should the transition be animated + * + */ + void setSelectionInt(int position, boolean animate) { + if (position != mOldSelectedPosition) { + mBlockLayoutRequests = true; + int delta = position - mSelectedPosition; + setNextSelectedPositionInt(position); + layout(delta, animate); + mBlockLayoutRequests = false; + } + } + + abstract void layout(int delta, boolean animate); + + @Override + public View getSelectedView() { + if (mItemCount > 0 && mSelectedPosition >= 0) { + return getChildAt(mSelectedPosition - mFirstPosition); + } else { + return null; + } + } + + /** + * Override to prevent spamming ourselves with layout requests + * as we place views + * + * @see android.view.View#requestLayout() + */ + @Override + public void requestLayout() { + if (!mBlockLayoutRequests) { + super.requestLayout(); + } + } + + @Override + public SpinnerAdapter getAdapter() { + return mAdapter; + } + + @Override + public int getCount() { + return mItemCount; + } + + /** + * Maps a point to a position in the list. + * + * @param x X in local coordinate + * @param y Y in local coordinate + * @return The position of the item which contains the specified point, or + * {@link #INVALID_POSITION} if the point does not intersect an item. + */ + public int pointToPosition(int x, int y) { + Rect frame = mTouchFrame; + if (frame == null) { + mTouchFrame = new Rect(); + frame = mTouchFrame; + } + + final int count = getChildCount(); + for (int i = count - 1; i >= 0; i--) { + View child = getChildAt(i); + if (child.getVisibility() == View.VISIBLE) { + child.getHitRect(frame); + if (frame.contains(x, y)) { + return mFirstPosition + i; + } + } + } + return INVALID_POSITION; + } + + static class SavedState extends BaseSavedState { + long selectedId; + int position; + + /** + * Constructor called from {@link AbsSpinner#onSaveInstanceState()} + */ + SavedState(Parcelable superState) { + super(superState); + } + + /** + * Constructor called from {@link #CREATOR} + */ + private SavedState(Parcel in) { + super(in); + selectedId = in.readLong(); + position = in.readInt(); + } + + @Override + public void writeToParcel(Parcel out, int flags) { + super.writeToParcel(out, flags); + out.writeLong(selectedId); + out.writeInt(position); + } + + @Override + public String toString() { + return "AbsSpinner.SavedState{" + + Integer.toHexString(System.identityHashCode(this)) + + " selectedId=" + selectedId + + " position=" + position + "}"; + } + + public static final Parcelable.Creator CREATOR + = new Parcelable.Creator() { + public SavedState createFromParcel(Parcel in) { + return new SavedState(in); + } + + public SavedState[] newArray(int size) { + return new SavedState[size]; + } + }; + } + + @Override + public Parcelable onSaveInstanceState() { + Parcelable superState = super.onSaveInstanceState(); + SavedState ss = new SavedState(superState); + ss.selectedId = getSelectedItemId(); + if (ss.selectedId >= 0) { + ss.position = getSelectedItemPosition(); + } else { + ss.position = INVALID_POSITION; + } + return ss; + } + + @Override + public void onRestoreInstanceState(Parcelable state) { + SavedState ss = (SavedState) state; + + super.onRestoreInstanceState(ss.getSuperState()); + + if (ss.selectedId >= 0) { + mDataChanged = true; + mNeedSync = true; + mSyncRowId = ss.selectedId; + mSyncPosition = ss.position; + mSyncMode = SYNC_SELECTED_POSITION; + requestLayout(); + } + } + + class RecycleBin { + private final SparseArray mScrapHeap = new SparseArray(); + + public void put(int position, View v) { + mScrapHeap.put(position, v); + } + + View get(int position) { + // System.out.print("Looking for " + position); + View result = mScrapHeap.get(position); + if (result != null) { + // System.out.println(" HIT"); + mScrapHeap.delete(position); + } else { + // System.out.println(" MISS"); + } + return result; + } + + void clear() { + final SparseArray scrapHeap = mScrapHeap; + final int count = scrapHeap.size(); + for (int i = 0; i < count; i++) { + final View view = scrapHeap.valueAt(i); + if (view != null) { + removeDetachedView(view, true); + } + } + scrapHeap.clear(); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsAdapterView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsAdapterView.java new file mode 100644 index 000000000..c786dc5c1 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsAdapterView.java @@ -0,0 +1,1160 @@ +/* + * Copyright (C) 2006 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.actionbarsherlock.internal.widget; + +import android.content.Context; +import android.database.DataSetObserver; +import android.os.Parcelable; +import android.os.SystemClock; +import android.util.AttributeSet; +import android.util.SparseArray; +import android.view.ContextMenu; +import android.view.SoundEffectConstants; +import android.view.View; +import android.view.ViewDebug; +import android.view.ViewGroup; +import android.view.accessibility.AccessibilityEvent; +import android.view.accessibility.AccessibilityNodeInfo; +import android.widget.Adapter; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.ListView; + + +/** + * An AdapterView is a view whose children are determined by an {@link Adapter}. + * + *

+ * See {@link ListView}, {@link GridView}, {@link Spinner} and + * {@link Gallery} for commonly used subclasses of AdapterView. + * + *

+ *

Developer Guides

+ *

For more information about using AdapterView, read the + * Binding to Data with AdapterView + * developer guide.

+ */ +public abstract class IcsAdapterView extends ViewGroup { + + /** + * The item view type returned by {@link Adapter#getItemViewType(int)} when + * the adapter does not want the item's view recycled. + */ + public static final int ITEM_VIEW_TYPE_IGNORE = -1; + + /** + * The item view type returned by {@link Adapter#getItemViewType(int)} when + * the item is a header or footer. + */ + public static final int ITEM_VIEW_TYPE_HEADER_OR_FOOTER = -2; + + /** + * The position of the first child displayed + */ + @ViewDebug.ExportedProperty(category = "scrolling") + int mFirstPosition = 0; + + /** + * The offset in pixels from the top of the AdapterView to the top + * of the view to select during the next layout. + */ + int mSpecificTop; + + /** + * Position from which to start looking for mSyncRowId + */ + int mSyncPosition; + + /** + * Row id to look for when data has changed + */ + long mSyncRowId = INVALID_ROW_ID; + + /** + * Height of the view when mSyncPosition and mSyncRowId where set + */ + long mSyncHeight; + + /** + * True if we need to sync to mSyncRowId + */ + boolean mNeedSync = false; + + /** + * Indicates whether to sync based on the selection or position. Possible + * values are {@link #SYNC_SELECTED_POSITION} or + * {@link #SYNC_FIRST_POSITION}. + */ + int mSyncMode; + + /** + * Our height after the last layout + */ + private int mLayoutHeight; + + /** + * Sync based on the selected child + */ + static final int SYNC_SELECTED_POSITION = 0; + + /** + * Sync based on the first child displayed + */ + static final int SYNC_FIRST_POSITION = 1; + + /** + * Maximum amount of time to spend in {@link #findSyncPosition()} + */ + static final int SYNC_MAX_DURATION_MILLIS = 100; + + /** + * Indicates that this view is currently being laid out. + */ + boolean mInLayout = false; + + /** + * The listener that receives notifications when an item is selected. + */ + OnItemSelectedListener mOnItemSelectedListener; + + /** + * The listener that receives notifications when an item is clicked. + */ + OnItemClickListener mOnItemClickListener; + + /** + * The listener that receives notifications when an item is long clicked. + */ + OnItemLongClickListener mOnItemLongClickListener; + + /** + * True if the data has changed since the last layout + */ + boolean mDataChanged; + + /** + * The position within the adapter's data set of the item to select + * during the next layout. + */ + @ViewDebug.ExportedProperty(category = "list") + int mNextSelectedPosition = INVALID_POSITION; + + /** + * The item id of the item to select during the next layout. + */ + long mNextSelectedRowId = INVALID_ROW_ID; + + /** + * The position within the adapter's data set of the currently selected item. + */ + @ViewDebug.ExportedProperty(category = "list") + int mSelectedPosition = INVALID_POSITION; + + /** + * The item id of the currently selected item. + */ + long mSelectedRowId = INVALID_ROW_ID; + + /** + * View to show if there are no items to show. + */ + private View mEmptyView; + + /** + * The number of items in the current adapter. + */ + @ViewDebug.ExportedProperty(category = "list") + int mItemCount; + + /** + * The number of items in the adapter before a data changed event occurred. + */ + int mOldItemCount; + + /** + * Represents an invalid position. All valid positions are in the range 0 to 1 less than the + * number of items in the current adapter. + */ + public static final int INVALID_POSITION = -1; + + /** + * Represents an empty or invalid row id + */ + public static final long INVALID_ROW_ID = Long.MIN_VALUE; + + /** + * The last selected position we used when notifying + */ + int mOldSelectedPosition = INVALID_POSITION; + + /** + * The id of the last selected position we used when notifying + */ + long mOldSelectedRowId = INVALID_ROW_ID; + + /** + * Indicates what focusable state is requested when calling setFocusable(). + * In addition to this, this view has other criteria for actually + * determining the focusable state (such as whether its empty or the text + * filter is shown). + * + * @see #setFocusable(boolean) + * @see #checkFocus() + */ + private boolean mDesiredFocusableState; + private boolean mDesiredFocusableInTouchModeState; + + private SelectionNotifier mSelectionNotifier; + /** + * When set to true, calls to requestLayout() will not propagate up the parent hierarchy. + * This is used to layout the children during a layout pass. + */ + boolean mBlockLayoutRequests = false; + + public IcsAdapterView(Context context) { + super(context); + } + + public IcsAdapterView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public IcsAdapterView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + } + + /** + * Register a callback to be invoked when an item in this AdapterView has + * been clicked. + * + * @param listener The callback that will be invoked. + */ + public void setOnItemClickListener(OnItemClickListener listener) { + mOnItemClickListener = listener; + } + + /** + * @return The callback to be invoked with an item in this AdapterView has + * been clicked, or null id no callback has been set. + */ + public final OnItemClickListener getOnItemClickListener() { + return mOnItemClickListener; + } + + /** + * Call the OnItemClickListener, if it is defined. + * + * @param view The view within the AdapterView that was clicked. + * @param position The position of the view in the adapter. + * @param id The row id of the item that was clicked. + * @return True if there was an assigned OnItemClickListener that was + * called, false otherwise is returned. + */ + public boolean performItemClick(View view, int position, long id) { + if (mOnItemClickListener != null) { + playSoundEffect(SoundEffectConstants.CLICK); + if (view != null) { + view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED); + } + mOnItemClickListener.onItemClick(/*this*/null, view, position, id); + return true; + } + + return false; + } + + /** + * Interface definition for a callback to be invoked when an item in this + * view has been clicked and held. + */ + public interface OnItemLongClickListener { + /** + * Callback method to be invoked when an item in this view has been + * clicked and held. + * + * Implementers can call getItemAtPosition(position) if they need to access + * the data associated with the selected item. + * + * @param parent The AbsListView where the click happened + * @param view The view within the AbsListView that was clicked + * @param position The position of the view in the list + * @param id The row id of the item that was clicked + * + * @return true if the callback consumed the long click, false otherwise + */ + boolean onItemLongClick(IcsAdapterView parent, View view, int position, long id); + } + + + /** + * Register a callback to be invoked when an item in this AdapterView has + * been clicked and held + * + * @param listener The callback that will run + */ + public void setOnItemLongClickListener(OnItemLongClickListener listener) { + if (!isLongClickable()) { + setLongClickable(true); + } + mOnItemLongClickListener = listener; + } + + /** + * @return The callback to be invoked with an item in this AdapterView has + * been clicked and held, or null id no callback as been set. + */ + public final OnItemLongClickListener getOnItemLongClickListener() { + return mOnItemLongClickListener; + } + + /** + * Interface definition for a callback to be invoked when + * an item in this view has been selected. + */ + public interface OnItemSelectedListener { + /** + *

Callback method to be invoked when an item in this view has been + * selected. This callback is invoked only when the newly selected + * position is different from the previously selected position or if + * there was no selected item.

+ * + * Impelmenters can call getItemAtPosition(position) if they need to access the + * data associated with the selected item. + * + * @param parent The AdapterView where the selection happened + * @param view The view within the AdapterView that was clicked + * @param position The position of the view in the adapter + * @param id The row id of the item that is selected + */ + void onItemSelected(IcsAdapterView parent, View view, int position, long id); + + /** + * Callback method to be invoked when the selection disappears from this + * view. The selection can disappear for instance when touch is activated + * or when the adapter becomes empty. + * + * @param parent The AdapterView that now contains no selected item. + */ + void onNothingSelected(IcsAdapterView parent); + } + + + /** + * Register a callback to be invoked when an item in this AdapterView has + * been selected. + * + * @param listener The callback that will run + */ + public void setOnItemSelectedListener(OnItemSelectedListener listener) { + mOnItemSelectedListener = listener; + } + + public final OnItemSelectedListener getOnItemSelectedListener() { + return mOnItemSelectedListener; + } + + /** + * Extra menu information provided to the + * {@link android.view.View.OnCreateContextMenuListener#onCreateContextMenu(ContextMenu, View, ContextMenuInfo) } + * callback when a context menu is brought up for this AdapterView. + * + */ + public static class AdapterContextMenuInfo implements ContextMenu.ContextMenuInfo { + + public AdapterContextMenuInfo(View targetView, int position, long id) { + this.targetView = targetView; + this.position = position; + this.id = id; + } + + /** + * The child view for which the context menu is being displayed. This + * will be one of the children of this AdapterView. + */ + public View targetView; + + /** + * The position in the adapter for which the context menu is being + * displayed. + */ + public int position; + + /** + * The row id of the item for which the context menu is being displayed. + */ + public long id; + } + + /** + * Returns the adapter currently associated with this widget. + * + * @return The adapter used to provide this view's content. + */ + public abstract T getAdapter(); + + /** + * Sets the adapter that provides the data and the views to represent the data + * in this widget. + * + * @param adapter The adapter to use to create this view's content. + */ + public abstract void setAdapter(T adapter); + + /** + * This method is not supported and throws an UnsupportedOperationException when called. + * + * @param child Ignored. + * + * @throws UnsupportedOperationException Every time this method is invoked. + */ + @Override + public void addView(View child) { + throw new UnsupportedOperationException("addView(View) is not supported in AdapterView"); + } + + /** + * This method is not supported and throws an UnsupportedOperationException when called. + * + * @param child Ignored. + * @param index Ignored. + * + * @throws UnsupportedOperationException Every time this method is invoked. + */ + @Override + public void addView(View child, int index) { + throw new UnsupportedOperationException("addView(View, int) is not supported in AdapterView"); + } + + /** + * This method is not supported and throws an UnsupportedOperationException when called. + * + * @param child Ignored. + * @param params Ignored. + * + * @throws UnsupportedOperationException Every time this method is invoked. + */ + @Override + public void addView(View child, LayoutParams params) { + throw new UnsupportedOperationException("addView(View, LayoutParams) " + + "is not supported in AdapterView"); + } + + /** + * This method is not supported and throws an UnsupportedOperationException when called. + * + * @param child Ignored. + * @param index Ignored. + * @param params Ignored. + * + * @throws UnsupportedOperationException Every time this method is invoked. + */ + @Override + public void addView(View child, int index, LayoutParams params) { + throw new UnsupportedOperationException("addView(View, int, LayoutParams) " + + "is not supported in AdapterView"); + } + + /** + * This method is not supported and throws an UnsupportedOperationException when called. + * + * @param child Ignored. + * + * @throws UnsupportedOperationException Every time this method is invoked. + */ + @Override + public void removeView(View child) { + throw new UnsupportedOperationException("removeView(View) is not supported in AdapterView"); + } + + /** + * This method is not supported and throws an UnsupportedOperationException when called. + * + * @param index Ignored. + * + * @throws UnsupportedOperationException Every time this method is invoked. + */ + @Override + public void removeViewAt(int index) { + throw new UnsupportedOperationException("removeViewAt(int) is not supported in AdapterView"); + } + + /** + * This method is not supported and throws an UnsupportedOperationException when called. + * + * @throws UnsupportedOperationException Every time this method is invoked. + */ + @Override + public void removeAllViews() { + throw new UnsupportedOperationException("removeAllViews() is not supported in AdapterView"); + } + + @Override + protected void onLayout(boolean changed, int left, int top, int right, int bottom) { + mLayoutHeight = getHeight(); + } + + /** + * Return the position of the currently selected item within the adapter's data set + * + * @return int Position (starting at 0), or {@link #INVALID_POSITION} if there is nothing selected. + */ + @ViewDebug.CapturedViewProperty + public int getSelectedItemPosition() { + return mNextSelectedPosition; + } + + /** + * @return The id corresponding to the currently selected item, or {@link #INVALID_ROW_ID} + * if nothing is selected. + */ + @ViewDebug.CapturedViewProperty + public long getSelectedItemId() { + return mNextSelectedRowId; + } + + /** + * @return The view corresponding to the currently selected item, or null + * if nothing is selected + */ + public abstract View getSelectedView(); + + /** + * @return The data corresponding to the currently selected item, or + * null if there is nothing selected. + */ + public Object getSelectedItem() { + T adapter = getAdapter(); + int selection = getSelectedItemPosition(); + if (adapter != null && adapter.getCount() > 0 && selection >= 0) { + return adapter.getItem(selection); + } else { + return null; + } + } + + /** + * @return The number of items owned by the Adapter associated with this + * AdapterView. (This is the number of data items, which may be + * larger than the number of visible views.) + */ + @ViewDebug.CapturedViewProperty + public int getCount() { + return mItemCount; + } + + /** + * Get the position within the adapter's data set for the view, where view is a an adapter item + * or a descendant of an adapter item. + * + * @param view an adapter item, or a descendant of an adapter item. This must be visible in this + * AdapterView at the time of the call. + * @return the position within the adapter's data set of the view, or {@link #INVALID_POSITION} + * if the view does not correspond to a list item (or it is not currently visible). + */ + public int getPositionForView(View view) { + View listItem = view; + try { + View v; + while (!(v = (View) listItem.getParent()).equals(this)) { + listItem = v; + } + } catch (ClassCastException e) { + // We made it up to the window without find this list view + return INVALID_POSITION; + } + + // Search the children for the list item + final int childCount = getChildCount(); + for (int i = 0; i < childCount; i++) { + if (getChildAt(i).equals(listItem)) { + return mFirstPosition + i; + } + } + + // Child not found! + return INVALID_POSITION; + } + + /** + * Returns the position within the adapter's data set for the first item + * displayed on screen. + * + * @return The position within the adapter's data set + */ + public int getFirstVisiblePosition() { + return mFirstPosition; + } + + /** + * Returns the position within the adapter's data set for the last item + * displayed on screen. + * + * @return The position within the adapter's data set + */ + public int getLastVisiblePosition() { + return mFirstPosition + getChildCount() - 1; + } + + /** + * Sets the currently selected item. To support accessibility subclasses that + * override this method must invoke the overriden super method first. + * + * @param position Index (starting at 0) of the data item to be selected. + */ + public abstract void setSelection(int position); + + /** + * Sets the view to show if the adapter is empty + */ + public void setEmptyView(View emptyView) { + mEmptyView = emptyView; + + final T adapter = getAdapter(); + final boolean empty = ((adapter == null) || adapter.isEmpty()); + updateEmptyStatus(empty); + } + + /** + * When the current adapter is empty, the AdapterView can display a special view + * call the empty view. The empty view is used to provide feedback to the user + * that no data is available in this AdapterView. + * + * @return The view to show if the adapter is empty. + */ + public View getEmptyView() { + return mEmptyView; + } + + /** + * Indicates whether this view is in filter mode. Filter mode can for instance + * be enabled by a user when typing on the keyboard. + * + * @return True if the view is in filter mode, false otherwise. + */ + boolean isInFilterMode() { + return false; + } + + @Override + public void setFocusable(boolean focusable) { + final T adapter = getAdapter(); + final boolean empty = adapter == null || adapter.getCount() == 0; + + mDesiredFocusableState = focusable; + if (!focusable) { + mDesiredFocusableInTouchModeState = false; + } + + super.setFocusable(focusable && (!empty || isInFilterMode())); + } + + @Override + public void setFocusableInTouchMode(boolean focusable) { + final T adapter = getAdapter(); + final boolean empty = adapter == null || adapter.getCount() == 0; + + mDesiredFocusableInTouchModeState = focusable; + if (focusable) { + mDesiredFocusableState = true; + } + + super.setFocusableInTouchMode(focusable && (!empty || isInFilterMode())); + } + + void checkFocus() { + final T adapter = getAdapter(); + final boolean empty = adapter == null || adapter.getCount() == 0; + final boolean focusable = !empty || isInFilterMode(); + // The order in which we set focusable in touch mode/focusable may matter + // for the client, see View.setFocusableInTouchMode() comments for more + // details + super.setFocusableInTouchMode(focusable && mDesiredFocusableInTouchModeState); + super.setFocusable(focusable && mDesiredFocusableState); + if (mEmptyView != null) { + updateEmptyStatus((adapter == null) || adapter.isEmpty()); + } + } + + /** + * Update the status of the list based on the empty parameter. If empty is true and + * we have an empty view, display it. In all the other cases, make sure that the listview + * is VISIBLE and that the empty view is GONE (if it's not null). + */ + private void updateEmptyStatus(boolean empty) { + if (isInFilterMode()) { + empty = false; + } + + if (empty) { + if (mEmptyView != null) { + mEmptyView.setVisibility(View.VISIBLE); + setVisibility(View.GONE); + } else { + // If the caller just removed our empty view, make sure the list view is visible + setVisibility(View.VISIBLE); + } + + // We are now GONE, so pending layouts will not be dispatched. + // Force one here to make sure that the state of the list matches + // the state of the adapter. + if (mDataChanged) { + this.onLayout(false, getLeft(), getTop(), getRight(), getBottom()); + } + } else { + if (mEmptyView != null) mEmptyView.setVisibility(View.GONE); + setVisibility(View.VISIBLE); + } + } + + /** + * Gets the data associated with the specified position in the list. + * + * @param position Which data to get + * @return The data associated with the specified position in the list + */ + public Object getItemAtPosition(int position) { + T adapter = getAdapter(); + return (adapter == null || position < 0) ? null : adapter.getItem(position); + } + + public long getItemIdAtPosition(int position) { + T adapter = getAdapter(); + return (adapter == null || position < 0) ? INVALID_ROW_ID : adapter.getItemId(position); + } + + @Override + public void setOnClickListener(OnClickListener l) { + throw new RuntimeException("Don't call setOnClickListener for an AdapterView. " + + "You probably want setOnItemClickListener instead"); + } + + /** + * Override to prevent freezing of any views created by the adapter. + */ + @Override + protected void dispatchSaveInstanceState(SparseArray container) { + dispatchFreezeSelfOnly(container); + } + + /** + * Override to prevent thawing of any views created by the adapter. + */ + @Override + protected void dispatchRestoreInstanceState(SparseArray container) { + dispatchThawSelfOnly(container); + } + + class AdapterDataSetObserver extends DataSetObserver { + + private Parcelable mInstanceState = null; + + @Override + public void onChanged() { + mDataChanged = true; + mOldItemCount = mItemCount; + mItemCount = getAdapter().getCount(); + + // Detect the case where a cursor that was previously invalidated has + // been repopulated with new data. + if (IcsAdapterView.this.getAdapter().hasStableIds() && mInstanceState != null + && mOldItemCount == 0 && mItemCount > 0) { + IcsAdapterView.this.onRestoreInstanceState(mInstanceState); + mInstanceState = null; + } else { + rememberSyncState(); + } + checkFocus(); + requestLayout(); + } + + @Override + public void onInvalidated() { + mDataChanged = true; + + if (IcsAdapterView.this.getAdapter().hasStableIds()) { + // Remember the current state for the case where our hosting activity is being + // stopped and later restarted + mInstanceState = IcsAdapterView.this.onSaveInstanceState(); + } + + // Data is invalid so we should reset our state + mOldItemCount = mItemCount; + mItemCount = 0; + mSelectedPosition = INVALID_POSITION; + mSelectedRowId = INVALID_ROW_ID; + mNextSelectedPosition = INVALID_POSITION; + mNextSelectedRowId = INVALID_ROW_ID; + mNeedSync = false; + + checkFocus(); + requestLayout(); + } + + public void clearSavedState() { + mInstanceState = null; + } + } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + removeCallbacks(mSelectionNotifier); + } + + private class SelectionNotifier implements Runnable { + public void run() { + if (mDataChanged) { + // Data has changed between when this SelectionNotifier + // was posted and now. We need to wait until the AdapterView + // has been synched to the new data. + if (getAdapter() != null) { + post(this); + } + } else { + fireOnSelected(); + } + } + } + + void selectionChanged() { + if (mOnItemSelectedListener != null) { + if (mInLayout || mBlockLayoutRequests) { + // If we are in a layout traversal, defer notification + // by posting. This ensures that the view tree is + // in a consistent state and is able to accomodate + // new layout or invalidate requests. + if (mSelectionNotifier == null) { + mSelectionNotifier = new SelectionNotifier(); + } + post(mSelectionNotifier); + } else { + fireOnSelected(); + } + } + + // we fire selection events here not in View + if (mSelectedPosition != ListView.INVALID_POSITION && isShown() && !isInTouchMode()) { + sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED); + } + } + + private void fireOnSelected() { + if (mOnItemSelectedListener == null) + return; + + int selection = this.getSelectedItemPosition(); + if (selection >= 0) { + View v = getSelectedView(); + mOnItemSelectedListener.onItemSelected(this, v, selection, + getAdapter().getItemId(selection)); + } else { + mOnItemSelectedListener.onNothingSelected(this); + } + } + + @Override + public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { + View selectedView = getSelectedView(); + if (selectedView != null && selectedView.getVisibility() == VISIBLE + && selectedView.dispatchPopulateAccessibilityEvent(event)) { + return true; + } + return false; + } + + @Override + public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) { + if (super.onRequestSendAccessibilityEvent(child, event)) { + // Add a record for ourselves as well. + AccessibilityEvent record = AccessibilityEvent.obtain(); + onInitializeAccessibilityEvent(record); + // Populate with the text of the requesting child. + child.dispatchPopulateAccessibilityEvent(record); + event.appendRecord(record); + return true; + } + return false; + } + + @Override + public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { + super.onInitializeAccessibilityNodeInfo(info); + info.setScrollable(isScrollableForAccessibility()); + View selectedView = getSelectedView(); + if (selectedView != null) { + info.setEnabled(selectedView.isEnabled()); + } + } + + @Override + public void onInitializeAccessibilityEvent(AccessibilityEvent event) { + super.onInitializeAccessibilityEvent(event); + event.setScrollable(isScrollableForAccessibility()); + View selectedView = getSelectedView(); + if (selectedView != null) { + event.setEnabled(selectedView.isEnabled()); + } + event.setCurrentItemIndex(getSelectedItemPosition()); + event.setFromIndex(getFirstVisiblePosition()); + event.setToIndex(getLastVisiblePosition()); + event.setItemCount(getCount()); + } + + private boolean isScrollableForAccessibility() { + T adapter = getAdapter(); + if (adapter != null) { + final int itemCount = adapter.getCount(); + return itemCount > 0 + && (getFirstVisiblePosition() > 0 || getLastVisiblePosition() < itemCount - 1); + } + return false; + } + + @Override + protected boolean canAnimate() { + return super.canAnimate() && mItemCount > 0; + } + + void handleDataChanged() { + final int count = mItemCount; + boolean found = false; + + if (count > 0) { + + int newPos; + + // Find the row we are supposed to sync to + if (mNeedSync) { + // Update this first, since setNextSelectedPositionInt inspects + // it + mNeedSync = false; + + // See if we can find a position in the new data with the same + // id as the old selection + newPos = findSyncPosition(); + if (newPos >= 0) { + // Verify that new selection is selectable + int selectablePos = lookForSelectablePosition(newPos, true); + if (selectablePos == newPos) { + // Same row id is selected + setNextSelectedPositionInt(newPos); + found = true; + } + } + } + if (!found) { + // Try to use the same position if we can't find matching data + newPos = getSelectedItemPosition(); + + // Pin position to the available range + if (newPos >= count) { + newPos = count - 1; + } + if (newPos < 0) { + newPos = 0; + } + + // Make sure we select something selectable -- first look down + int selectablePos = lookForSelectablePosition(newPos, true); + if (selectablePos < 0) { + // Looking down didn't work -- try looking up + selectablePos = lookForSelectablePosition(newPos, false); + } + if (selectablePos >= 0) { + setNextSelectedPositionInt(selectablePos); + checkSelectionChanged(); + found = true; + } + } + } + if (!found) { + // Nothing is selected + mSelectedPosition = INVALID_POSITION; + mSelectedRowId = INVALID_ROW_ID; + mNextSelectedPosition = INVALID_POSITION; + mNextSelectedRowId = INVALID_ROW_ID; + mNeedSync = false; + checkSelectionChanged(); + } + } + + void checkSelectionChanged() { + if ((mSelectedPosition != mOldSelectedPosition) || (mSelectedRowId != mOldSelectedRowId)) { + selectionChanged(); + mOldSelectedPosition = mSelectedPosition; + mOldSelectedRowId = mSelectedRowId; + } + } + + /** + * Searches the adapter for a position matching mSyncRowId. The search starts at mSyncPosition + * and then alternates between moving up and moving down until 1) we find the right position, or + * 2) we run out of time, or 3) we have looked at every position + * + * @return Position of the row that matches mSyncRowId, or {@link #INVALID_POSITION} if it can't + * be found + */ + int findSyncPosition() { + int count = mItemCount; + + if (count == 0) { + return INVALID_POSITION; + } + + long idToMatch = mSyncRowId; + int seed = mSyncPosition; + + // If there isn't a selection don't hunt for it + if (idToMatch == INVALID_ROW_ID) { + return INVALID_POSITION; + } + + // Pin seed to reasonable values + seed = Math.max(0, seed); + seed = Math.min(count - 1, seed); + + long endTime = SystemClock.uptimeMillis() + SYNC_MAX_DURATION_MILLIS; + + long rowId; + + // first position scanned so far + int first = seed; + + // last position scanned so far + int last = seed; + + // True if we should move down on the next iteration + boolean next = false; + + // True when we have looked at the first item in the data + boolean hitFirst; + + // True when we have looked at the last item in the data + boolean hitLast; + + // Get the item ID locally (instead of getItemIdAtPosition), so + // we need the adapter + T adapter = getAdapter(); + if (adapter == null) { + return INVALID_POSITION; + } + + while (SystemClock.uptimeMillis() <= endTime) { + rowId = adapter.getItemId(seed); + if (rowId == idToMatch) { + // Found it! + return seed; + } + + hitLast = last == count - 1; + hitFirst = first == 0; + + if (hitLast && hitFirst) { + // Looked at everything + break; + } + + if (hitFirst || (next && !hitLast)) { + // Either we hit the top, or we are trying to move down + last++; + seed = last; + // Try going up next time + next = false; + } else if (hitLast || (!next && !hitFirst)) { + // Either we hit the bottom, or we are trying to move up + first--; + seed = first; + // Try going down next time + next = true; + } + + } + + return INVALID_POSITION; + } + + /** + * Find a position that can be selected (i.e., is not a separator). + * + * @param position The starting position to look at. + * @param lookDown Whether to look down for other positions. + * @return The next selectable position starting at position and then searching either up or + * down. Returns {@link #INVALID_POSITION} if nothing can be found. + */ + int lookForSelectablePosition(int position, boolean lookDown) { + return position; + } + + /** + * Utility to keep mSelectedPosition and mSelectedRowId in sync + * @param position Our current position + */ + void setSelectedPositionInt(int position) { + mSelectedPosition = position; + mSelectedRowId = getItemIdAtPosition(position); + } + + /** + * Utility to keep mNextSelectedPosition and mNextSelectedRowId in sync + * @param position Intended value for mSelectedPosition the next time we go + * through layout + */ + void setNextSelectedPositionInt(int position) { + mNextSelectedPosition = position; + mNextSelectedRowId = getItemIdAtPosition(position); + // If we are trying to sync to the selection, update that too + if (mNeedSync && mSyncMode == SYNC_SELECTED_POSITION && position >= 0) { + mSyncPosition = position; + mSyncRowId = mNextSelectedRowId; + } + } + + /** + * Remember enough information to restore the screen state when the data has + * changed. + * + */ + void rememberSyncState() { + if (getChildCount() > 0) { + mNeedSync = true; + mSyncHeight = mLayoutHeight; + if (mSelectedPosition >= 0) { + // Sync the selection state + View v = getChildAt(mSelectedPosition - mFirstPosition); + mSyncRowId = mNextSelectedRowId; + mSyncPosition = mNextSelectedPosition; + if (v != null) { + mSpecificTop = v.getTop(); + } + mSyncMode = SYNC_SELECTED_POSITION; + } else { + // Sync the based on the offset of the first view + View v = getChildAt(0); + T adapter = getAdapter(); + if (mFirstPosition >= 0 && mFirstPosition < adapter.getCount()) { + mSyncRowId = adapter.getItemId(mFirstPosition); + } else { + mSyncRowId = NO_ID; + } + mSyncPosition = mFirstPosition; + if (v != null) { + mSpecificTop = v.getTop(); + } + mSyncMode = SYNC_FIRST_POSITION; + } + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java new file mode 100644 index 000000000..1b4463a59 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java @@ -0,0 +1,272 @@ +package com.actionbarsherlock.internal.widget; + +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.Canvas; +import android.graphics.drawable.Drawable; +import android.util.AttributeSet; +import android.view.View; +import com.actionbarsherlock.internal.nineoldandroids.widget.NineLinearLayout; + +/** + * A simple extension of a regular linear layout that supports the divider API + * of Android 4.0+. The dividers are added adjacent to the children by changing + * their layout params. If you need to rely on the margins which fall in the + * same orientation as the layout you should wrap the child in a simple + * {@link android.widget.FrameLayout} so it can receive the margin. + */ +public class IcsLinearLayout extends NineLinearLayout { + private static final int[] LinearLayout = new int[] { + /* 0 */ android.R.attr.divider, + /* 1 */ android.R.attr.showDividers, + /* 2 */ android.R.attr.dividerPadding, + }; + private static final int LinearLayout_divider = 0; + private static final int LinearLayout_showDividers = 1; + private static final int LinearLayout_dividerPadding = 2; + + /** + * Don't show any dividers. + */ + public static final int SHOW_DIVIDER_NONE = 0; + /** + * Show a divider at the beginning of the group. + */ + public static final int SHOW_DIVIDER_BEGINNING = 1; + /** + * Show dividers between each item in the group. + */ + public static final int SHOW_DIVIDER_MIDDLE = 2; + /** + * Show a divider at the end of the group. + */ + public static final int SHOW_DIVIDER_END = 4; + + + private Drawable mDivider; + private int mDividerWidth; + private int mDividerHeight; + private int mShowDividers; + private int mDividerPadding; + + + public IcsLinearLayout(Context context, AttributeSet attrs) { + super(context, attrs); + + TypedArray a = context.obtainStyledAttributes(attrs, /*com.android.internal.R.styleable.*/LinearLayout); + + setDividerDrawable(a.getDrawable(/*com.android.internal.R.styleable.*/LinearLayout_divider)); + mShowDividers = a.getInt(/*com.android.internal.R.styleable.*/LinearLayout_showDividers, SHOW_DIVIDER_NONE); + mDividerPadding = a.getDimensionPixelSize(/*com.android.internal.R.styleable.*/LinearLayout_dividerPadding, 0); + + a.recycle(); + } + + /** + * Set how dividers should be shown between items in this layout + * + * @param showDividers One or more of {@link #SHOW_DIVIDER_BEGINNING}, + * {@link #SHOW_DIVIDER_MIDDLE}, or {@link #SHOW_DIVIDER_END}, + * or {@link #SHOW_DIVIDER_NONE} to show no dividers. + */ + public void setShowDividers(int showDividers) { + if (showDividers != mShowDividers) { + requestLayout(); + invalidate(); //XXX This is required if you are toggling a divider off + } + mShowDividers = showDividers; + } + + /** + * @return A flag set indicating how dividers should be shown around items. + * @see #setShowDividers(int) + */ + public int getShowDividers() { + return mShowDividers; + } + + /** + * Set a drawable to be used as a divider between items. + * @param divider Drawable that will divide each item. + * @see #setShowDividers(int) + */ + public void setDividerDrawable(Drawable divider) { + if (divider == mDivider) { + return; + } + mDivider = divider; + if (divider != null) { + mDividerWidth = divider.getIntrinsicWidth(); + mDividerHeight = divider.getIntrinsicHeight(); + } else { + mDividerWidth = 0; + mDividerHeight = 0; + } + setWillNotDraw(divider == null); + requestLayout(); + } + + /** + * Set padding displayed on both ends of dividers. + * + * @param padding Padding value in pixels that will be applied to each end + * + * @see #setShowDividers(int) + * @see #setDividerDrawable(Drawable) + * @see #getDividerPadding() + */ + public void setDividerPadding(int padding) { + mDividerPadding = padding; + } + + /** + * Get the padding size used to inset dividers in pixels + * + * @see #setShowDividers(int) + * @see #setDividerDrawable(Drawable) + * @see #setDividerPadding(int) + */ + public int getDividerPadding() { + return mDividerPadding; + } + + /** + * Get the width of the current divider drawable. + * + * @hide Used internally by framework. + */ + public int getDividerWidth() { + return mDividerWidth; + } + + @Override + protected void measureChildWithMargins(View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed) { + final int index = indexOfChild(child); + final int orientation = getOrientation(); + final LayoutParams params = (LayoutParams) child.getLayoutParams(); + if (hasDividerBeforeChildAt(index)) { + if (orientation == VERTICAL) { + //Account for the divider by pushing everything up + params.topMargin = mDividerHeight; + } else { + //Account for the divider by pushing everything left + params.leftMargin = mDividerWidth; + } + } + + final int count = getChildCount(); + if (index == count - 1) { + if (hasDividerBeforeChildAt(count)) { + if (orientation == VERTICAL) { + params.bottomMargin = mDividerHeight; + } else { + params.rightMargin = mDividerWidth; + } + } + } + super.measureChildWithMargins(child, parentWidthMeasureSpec, widthUsed, parentHeightMeasureSpec, heightUsed); + } + + @Override + protected void onDraw(Canvas canvas) { + if (mDivider != null) { + if (getOrientation() == VERTICAL) { + drawDividersVertical(canvas); + } else { + drawDividersHorizontal(canvas); + } + } + super.onDraw(canvas); + } + + void drawDividersVertical(Canvas canvas) { + final int count = getChildCount(); + for (int i = 0; i < count; i++) { + final View child = getChildAt(i); + + if (child != null && child.getVisibility() != GONE) { + if (hasDividerBeforeChildAt(i)) { + final LayoutParams lp = (LayoutParams) child.getLayoutParams(); + final int top = child.getTop() - lp.topMargin/* - mDividerHeight*/; + drawHorizontalDivider(canvas, top); + } + } + } + + if (hasDividerBeforeChildAt(count)) { + final View child = getChildAt(count - 1); + int bottom = 0; + if (child == null) { + bottom = getHeight() - getPaddingBottom() - mDividerHeight; + } else { + final LayoutParams lp = (LayoutParams) child.getLayoutParams(); + bottom = child.getBottom()/* + lp.bottomMargin*/; + } + drawHorizontalDivider(canvas, bottom); + } + } + + void drawDividersHorizontal(Canvas canvas) { + final int count = getChildCount(); + for (int i = 0; i < count; i++) { + final View child = getChildAt(i); + + if (child != null && child.getVisibility() != GONE) { + if (hasDividerBeforeChildAt(i)) { + final LayoutParams lp = (LayoutParams) child.getLayoutParams(); + final int left = child.getLeft() - lp.leftMargin/* - mDividerWidth*/; + drawVerticalDivider(canvas, left); + } + } + } + + if (hasDividerBeforeChildAt(count)) { + final View child = getChildAt(count - 1); + int right = 0; + if (child == null) { + right = getWidth() - getPaddingRight() - mDividerWidth; + } else { + final LayoutParams lp = (LayoutParams) child.getLayoutParams(); + right = child.getRight()/* + lp.rightMargin*/; + } + drawVerticalDivider(canvas, right); + } + } + + void drawHorizontalDivider(Canvas canvas, int top) { + mDivider.setBounds(getPaddingLeft() + mDividerPadding, top, + getWidth() - getPaddingRight() - mDividerPadding, top + mDividerHeight); + mDivider.draw(canvas); + } + + void drawVerticalDivider(Canvas canvas, int left) { + mDivider.setBounds(left, getPaddingTop() + mDividerPadding, + left + mDividerWidth, getHeight() - getPaddingBottom() - mDividerPadding); + mDivider.draw(canvas); + } + + /** + * Determines where to position dividers between children. + * + * @param childIndex Index of child to check for preceding divider + * @return true if there should be a divider before the child at childIndex + * @hide Pending API consideration. Currently only used internally by the system. + */ + protected boolean hasDividerBeforeChildAt(int childIndex) { + if (childIndex == 0) { + return (mShowDividers & SHOW_DIVIDER_BEGINNING) != 0; + } else if (childIndex == getChildCount()) { + return (mShowDividers & SHOW_DIVIDER_END) != 0; + } else if ((mShowDividers & SHOW_DIVIDER_MIDDLE) != 0) { + boolean hasVisibleViewBefore = false; + for (int i = childIndex - 1; i >= 0; i--) { + if (getChildAt(i).getVisibility() != GONE) { + hasVisibleViewBefore = true; + break; + } + } + return hasVisibleViewBefore; + } + return false; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsListPopupWindow.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsListPopupWindow.java new file mode 100644 index 000000000..d13c6cea9 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsListPopupWindow.java @@ -0,0 +1,644 @@ +package com.actionbarsherlock.internal.widget; + +import com.actionbarsherlock.R; + +import android.content.Context; +import android.content.res.Resources; +import android.database.DataSetObserver; +import android.graphics.Rect; +import android.graphics.drawable.Drawable; +import android.os.Build; +import android.os.Handler; +import android.util.AttributeSet; +import android.view.ContextThemeWrapper; +import android.view.MotionEvent; +import android.view.View; +import android.view.View.MeasureSpec; +import android.view.View.OnTouchListener; +import android.view.ViewGroup; +import android.view.ViewParent; +import android.widget.AbsListView; +import android.widget.AdapterView; +import android.widget.LinearLayout; +import android.widget.ListAdapter; +import android.widget.ListView; +import android.widget.PopupWindow; + +/** + * A proxy between pre- and post-Honeycomb implementations of this class. + */ +public class IcsListPopupWindow { + /** + * This value controls the length of time that the user + * must leave a pointer down without scrolling to expand + * the autocomplete dropdown list to cover the IME. + */ + private static final int EXPAND_LIST_TIMEOUT = 250; + + private Context mContext; + private PopupWindow mPopup; + private ListAdapter mAdapter; + private DropDownListView mDropDownList; + + private int mDropDownHeight = ViewGroup.LayoutParams.WRAP_CONTENT; + private int mDropDownWidth = ViewGroup.LayoutParams.WRAP_CONTENT; + private int mDropDownHorizontalOffset; + private int mDropDownVerticalOffset; + private boolean mDropDownVerticalOffsetSet; + + private int mListItemExpandMaximum = Integer.MAX_VALUE; + + private View mPromptView; + private int mPromptPosition = POSITION_PROMPT_ABOVE; + + private DataSetObserver mObserver; + + private View mDropDownAnchorView; + + private Drawable mDropDownListHighlight; + + private AdapterView.OnItemClickListener mItemClickListener; + private AdapterView.OnItemSelectedListener mItemSelectedListener; + + private final ResizePopupRunnable mResizePopupRunnable = new ResizePopupRunnable(); + private final PopupTouchInterceptor mTouchInterceptor = new PopupTouchInterceptor(); + private final PopupScrollListener mScrollListener = new PopupScrollListener(); + private final ListSelectorHider mHideSelector = new ListSelectorHider(); + + private Handler mHandler = new Handler(); + + private Rect mTempRect = new Rect(); + + private boolean mModal; + + public static final int POSITION_PROMPT_ABOVE = 0; + public static final int POSITION_PROMPT_BELOW = 1; + + public IcsListPopupWindow(Context context) { + this(context, null, R.attr.listPopupWindowStyle); + } + + public IcsListPopupWindow(Context context, AttributeSet attrs, int defStyleAttr) { + mContext = context; + mPopup = new PopupWindow(context, attrs, defStyleAttr); + mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED); + } + + public IcsListPopupWindow(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { + mContext = context; + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + Context wrapped = new ContextThemeWrapper(context, defStyleRes); + mPopup = new PopupWindow(wrapped, attrs, defStyleAttr); + } else { + mPopup = new PopupWindow(context, attrs, defStyleAttr, defStyleRes); + } + mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED); + } + + public void setAdapter(ListAdapter adapter) { + if (mObserver == null) { + mObserver = new PopupDataSetObserver(); + } else if (mAdapter != null) { + mAdapter.unregisterDataSetObserver(mObserver); + } + mAdapter = adapter; + if (mAdapter != null) { + adapter.registerDataSetObserver(mObserver); + } + + if (mDropDownList != null) { + mDropDownList.setAdapter(mAdapter); + } + } + + public void setPromptPosition(int position) { + mPromptPosition = position; + } + + public void setModal(boolean modal) { + mModal = true; + mPopup.setFocusable(modal); + } + + public void setBackgroundDrawable(Drawable d) { + mPopup.setBackgroundDrawable(d); + } + + public void setAnchorView(View anchor) { + mDropDownAnchorView = anchor; + } + + public void setHorizontalOffset(int offset) { + mDropDownHorizontalOffset = offset; + } + + public void setVerticalOffset(int offset) { + mDropDownVerticalOffset = offset; + mDropDownVerticalOffsetSet = true; + } + + public void setContentWidth(int width) { + Drawable popupBackground = mPopup.getBackground(); + if (popupBackground != null) { + popupBackground.getPadding(mTempRect); + mDropDownWidth = mTempRect.left + mTempRect.right + width; + } else { + mDropDownWidth = width; + } + } + + public void setOnItemClickListener(AdapterView.OnItemClickListener clickListener) { + mItemClickListener = clickListener; + } + + public void show() { + int height = buildDropDown(); + + int widthSpec = 0; + int heightSpec = 0; + + boolean noInputMethod = isInputMethodNotNeeded(); + //XXX mPopup.setAllowScrollingAnchorParent(!noInputMethod); + + if (mPopup.isShowing()) { + if (mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT) { + // The call to PopupWindow's update method below can accept -1 for any + // value you do not want to update. + widthSpec = -1; + } else if (mDropDownWidth == ViewGroup.LayoutParams.WRAP_CONTENT) { + widthSpec = mDropDownAnchorView.getWidth(); + } else { + widthSpec = mDropDownWidth; + } + + if (mDropDownHeight == ViewGroup.LayoutParams.MATCH_PARENT) { + // The call to PopupWindow's update method below can accept -1 for any + // value you do not want to update. + heightSpec = noInputMethod ? height : ViewGroup.LayoutParams.MATCH_PARENT; + if (noInputMethod) { + mPopup.setWindowLayoutMode( + mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT ? + ViewGroup.LayoutParams.MATCH_PARENT : 0, 0); + } else { + mPopup.setWindowLayoutMode( + mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT ? + ViewGroup.LayoutParams.MATCH_PARENT : 0, + ViewGroup.LayoutParams.MATCH_PARENT); + } + } else if (mDropDownHeight == ViewGroup.LayoutParams.WRAP_CONTENT) { + heightSpec = height; + } else { + heightSpec = mDropDownHeight; + } + + mPopup.setOutsideTouchable(true); + + mPopup.update(mDropDownAnchorView, mDropDownHorizontalOffset, + mDropDownVerticalOffset, widthSpec, heightSpec); + } else { + if (mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT) { + widthSpec = ViewGroup.LayoutParams.MATCH_PARENT; + } else { + if (mDropDownWidth == ViewGroup.LayoutParams.WRAP_CONTENT) { + mPopup.setWidth(mDropDownAnchorView.getWidth()); + } else { + mPopup.setWidth(mDropDownWidth); + } + } + + if (mDropDownHeight == ViewGroup.LayoutParams.MATCH_PARENT) { + heightSpec = ViewGroup.LayoutParams.MATCH_PARENT; + } else { + if (mDropDownHeight == ViewGroup.LayoutParams.WRAP_CONTENT) { + mPopup.setHeight(height); + } else { + mPopup.setHeight(mDropDownHeight); + } + } + + mPopup.setWindowLayoutMode(widthSpec, heightSpec); + //XXX mPopup.setClipToScreenEnabled(true); + + // use outside touchable to dismiss drop down when touching outside of it, so + // only set this if the dropdown is not always visible + mPopup.setOutsideTouchable(true); + mPopup.setTouchInterceptor(mTouchInterceptor); + mPopup.showAsDropDown(mDropDownAnchorView, + mDropDownHorizontalOffset, mDropDownVerticalOffset); + mDropDownList.setSelection(ListView.INVALID_POSITION); + + if (!mModal || mDropDownList.isInTouchMode()) { + clearListSelection(); + } + if (!mModal) { + mHandler.post(mHideSelector); + } + } + } + + public void dismiss() { + mPopup.dismiss(); + if (mPromptView != null) { + final ViewParent parent = mPromptView.getParent(); + if (parent instanceof ViewGroup) { + final ViewGroup group = (ViewGroup) parent; + group.removeView(mPromptView); + } + } + mPopup.setContentView(null); + mDropDownList = null; + mHandler.removeCallbacks(mResizePopupRunnable); + } + + public void setOnDismissListener(PopupWindow.OnDismissListener listener) { + mPopup.setOnDismissListener(listener); + } + + public void setInputMethodMode(int mode) { + mPopup.setInputMethodMode(mode); + } + + public void clearListSelection() { + final DropDownListView list = mDropDownList; + if (list != null) { + // WARNING: Please read the comment where mListSelectionHidden is declared + list.mListSelectionHidden = true; + //XXX list.hideSelector(); + list.requestLayout(); + } + } + + public boolean isShowing() { + return mPopup.isShowing(); + } + + private boolean isInputMethodNotNeeded() { + return mPopup.getInputMethodMode() == PopupWindow.INPUT_METHOD_NOT_NEEDED; + } + + public ListView getListView() { + return mDropDownList; + } + + private int buildDropDown() { + ViewGroup dropDownView; + int otherHeights = 0; + + if (mDropDownList == null) { + Context context = mContext; + + mDropDownList = new DropDownListView(context, !mModal); + if (mDropDownListHighlight != null) { + mDropDownList.setSelector(mDropDownListHighlight); + } + mDropDownList.setAdapter(mAdapter); + mDropDownList.setOnItemClickListener(mItemClickListener); + mDropDownList.setFocusable(true); + mDropDownList.setFocusableInTouchMode(true); + mDropDownList.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + public void onItemSelected(AdapterView parent, View view, + int position, long id) { + + if (position != -1) { + DropDownListView dropDownList = mDropDownList; + + if (dropDownList != null) { + dropDownList.mListSelectionHidden = false; + } + } + } + + public void onNothingSelected(AdapterView parent) { + } + }); + mDropDownList.setOnScrollListener(mScrollListener); + + if (mItemSelectedListener != null) { + mDropDownList.setOnItemSelectedListener(mItemSelectedListener); + } + + dropDownView = mDropDownList; + + View hintView = mPromptView; + if (hintView != null) { + // if an hint has been specified, we accomodate more space for it and + // add a text view in the drop down menu, at the bottom of the list + LinearLayout hintContainer = new LinearLayout(context); + hintContainer.setOrientation(LinearLayout.VERTICAL); + + LinearLayout.LayoutParams hintParams = new LinearLayout.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, 0, 1.0f + ); + + switch (mPromptPosition) { + case POSITION_PROMPT_BELOW: + hintContainer.addView(dropDownView, hintParams); + hintContainer.addView(hintView); + break; + + case POSITION_PROMPT_ABOVE: + hintContainer.addView(hintView); + hintContainer.addView(dropDownView, hintParams); + break; + + default: + break; + } + + // measure the hint's height to find how much more vertical space + // we need to add to the drop down's height + int widthSpec = MeasureSpec.makeMeasureSpec(mDropDownWidth, MeasureSpec.AT_MOST); + int heightSpec = MeasureSpec.UNSPECIFIED; + hintView.measure(widthSpec, heightSpec); + + hintParams = (LinearLayout.LayoutParams) hintView.getLayoutParams(); + otherHeights = hintView.getMeasuredHeight() + hintParams.topMargin + + hintParams.bottomMargin; + + dropDownView = hintContainer; + } + + mPopup.setContentView(dropDownView); + } else { + dropDownView = (ViewGroup) mPopup.getContentView(); + final View view = mPromptView; + if (view != null) { + LinearLayout.LayoutParams hintParams = + (LinearLayout.LayoutParams) view.getLayoutParams(); + otherHeights = view.getMeasuredHeight() + hintParams.topMargin + + hintParams.bottomMargin; + } + } + + // getMaxAvailableHeight() subtracts the padding, so we put it back + // to get the available height for the whole window + int padding = 0; + Drawable background = mPopup.getBackground(); + if (background != null) { + background.getPadding(mTempRect); + padding = mTempRect.top + mTempRect.bottom; + + // If we don't have an explicit vertical offset, determine one from the window + // background so that content will line up. + if (!mDropDownVerticalOffsetSet) { + mDropDownVerticalOffset = -mTempRect.top; + } + } + + // Max height available on the screen for a popup. + boolean ignoreBottomDecorations = + mPopup.getInputMethodMode() == PopupWindow.INPUT_METHOD_NOT_NEEDED; + final int maxHeight = /*mPopup.*/getMaxAvailableHeight( + mDropDownAnchorView, mDropDownVerticalOffset, ignoreBottomDecorations); + + if (mDropDownHeight == ViewGroup.LayoutParams.MATCH_PARENT) { + return maxHeight + padding; + } + + final int listContent = /*mDropDownList.*/measureHeightOfChildren(MeasureSpec.UNSPECIFIED, + 0, -1/*ListView.NO_POSITION*/, maxHeight - otherHeights, -1); + // add padding only if the list has items in it, that way we don't show + // the popup if it is not needed + if (listContent > 0) otherHeights += padding; + + return listContent + otherHeights; + } + + private int getMaxAvailableHeight(View anchor, int yOffset, boolean ignoreBottomDecorations) { + final Rect displayFrame = new Rect(); + anchor.getWindowVisibleDisplayFrame(displayFrame); + + final int[] anchorPos = new int[2]; + anchor.getLocationOnScreen(anchorPos); + + int bottomEdge = displayFrame.bottom; + if (ignoreBottomDecorations) { + Resources res = anchor.getContext().getResources(); + bottomEdge = res.getDisplayMetrics().heightPixels; + } + final int distanceToBottom = bottomEdge - (anchorPos[1] + anchor.getHeight()) - yOffset; + final int distanceToTop = anchorPos[1] - displayFrame.top + yOffset; + + // anchorPos[1] is distance from anchor to top of screen + int returnedHeight = Math.max(distanceToBottom, distanceToTop); + if (mPopup.getBackground() != null) { + mPopup.getBackground().getPadding(mTempRect); + returnedHeight -= mTempRect.top + mTempRect.bottom; + } + + return returnedHeight; + } + + private int measureHeightOfChildren(int widthMeasureSpec, int startPosition, int endPosition, + final int maxHeight, int disallowPartialChildPosition) { + + final ListAdapter adapter = mAdapter; + if (adapter == null) { + return mDropDownList.getListPaddingTop() + mDropDownList.getListPaddingBottom(); + } + + // Include the padding of the list + int returnedHeight = mDropDownList.getListPaddingTop() + mDropDownList.getListPaddingBottom(); + final int dividerHeight = ((mDropDownList.getDividerHeight() > 0) && mDropDownList.getDivider() != null) ? mDropDownList.getDividerHeight() : 0; + // The previous height value that was less than maxHeight and contained + // no partial children + int prevHeightWithoutPartialChild = 0; + int i; + View child; + + // mItemCount - 1 since endPosition parameter is inclusive + endPosition = (endPosition == -1/*NO_POSITION*/) ? adapter.getCount() - 1 : endPosition; + + for (i = startPosition; i <= endPosition; ++i) { + child = mAdapter.getView(i, null, mDropDownList); + if (mDropDownList.getCacheColorHint() != 0) { + child.setDrawingCacheBackgroundColor(mDropDownList.getCacheColorHint()); + } + + measureScrapChild(child, i, widthMeasureSpec); + + if (i > 0) { + // Count the divider for all but one child + returnedHeight += dividerHeight; + } + + returnedHeight += child.getMeasuredHeight(); + + if (returnedHeight >= maxHeight) { + // We went over, figure out which height to return. If returnedHeight > maxHeight, + // then the i'th position did not fit completely. + return (disallowPartialChildPosition >= 0) // Disallowing is enabled (> -1) + && (i > disallowPartialChildPosition) // We've past the min pos + && (prevHeightWithoutPartialChild > 0) // We have a prev height + && (returnedHeight != maxHeight) // i'th child did not fit completely + ? prevHeightWithoutPartialChild + : maxHeight; + } + + if ((disallowPartialChildPosition >= 0) && (i >= disallowPartialChildPosition)) { + prevHeightWithoutPartialChild = returnedHeight; + } + } + + // At this point, we went through the range of children, and they each + // completely fit, so return the returnedHeight + return returnedHeight; + } + private void measureScrapChild(View child, int position, int widthMeasureSpec) { + ListView.LayoutParams p = (ListView.LayoutParams) child.getLayoutParams(); + if (p == null) { + p = new ListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.WRAP_CONTENT, 0); + child.setLayoutParams(p); + } + //XXX p.viewType = mAdapter.getItemViewType(position); + //XXX p.forceAdd = true; + + int childWidthSpec = ViewGroup.getChildMeasureSpec(widthMeasureSpec, + mDropDownList.getPaddingLeft() + mDropDownList.getPaddingRight(), p.width); + int lpHeight = p.height; + int childHeightSpec; + if (lpHeight > 0) { + childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight, MeasureSpec.EXACTLY); + } else { + childHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); + } + child.measure(childWidthSpec, childHeightSpec); + } + + private static class DropDownListView extends ListView { + /* + * WARNING: This is a workaround for a touch mode issue. + * + * Touch mode is propagated lazily to windows. This causes problems in + * the following scenario: + * - Type something in the AutoCompleteTextView and get some results + * - Move down with the d-pad to select an item in the list + * - Move up with the d-pad until the selection disappears + * - Type more text in the AutoCompleteTextView *using the soft keyboard* + * and get new results; you are now in touch mode + * - The selection comes back on the first item in the list, even though + * the list is supposed to be in touch mode + * + * Using the soft keyboard triggers the touch mode change but that change + * is propagated to our window only after the first list layout, therefore + * after the list attempts to resurrect the selection. + * + * The trick to work around this issue is to pretend the list is in touch + * mode when we know that the selection should not appear, that is when + * we know the user moved the selection away from the list. + * + * This boolean is set to true whenever we explicitly hide the list's + * selection and reset to false whenever we know the user moved the + * selection back to the list. + * + * When this boolean is true, isInTouchMode() returns true, otherwise it + * returns super.isInTouchMode(). + */ + private boolean mListSelectionHidden; + + private boolean mHijackFocus; + + public DropDownListView(Context context, boolean hijackFocus) { + super(context, null, /*com.android.internal.*/R.attr.dropDownListViewStyle); + mHijackFocus = hijackFocus; + // TODO: Add an API to control this + setCacheColorHint(0); // Transparent, since the background drawable could be anything. + } + + //XXX @Override + //View obtainView(int position, boolean[] isScrap) { + // View view = super.obtainView(position, isScrap); + + // if (view instanceof TextView) { + // ((TextView) view).setHorizontallyScrolling(true); + // } + + // return view; + //} + + @Override + public boolean isInTouchMode() { + // WARNING: Please read the comment where mListSelectionHidden is declared + return (mHijackFocus && mListSelectionHidden) || super.isInTouchMode(); + } + + @Override + public boolean hasWindowFocus() { + return mHijackFocus || super.hasWindowFocus(); + } + + @Override + public boolean isFocused() { + return mHijackFocus || super.isFocused(); + } + + @Override + public boolean hasFocus() { + return mHijackFocus || super.hasFocus(); + } + } + + private class PopupDataSetObserver extends DataSetObserver { + @Override + public void onChanged() { + if (isShowing()) { + // Resize the popup to fit new content + show(); + } + } + + @Override + public void onInvalidated() { + dismiss(); + } + } + + private class ListSelectorHider implements Runnable { + public void run() { + clearListSelection(); + } + } + + private class ResizePopupRunnable implements Runnable { + public void run() { + if (mDropDownList != null && mDropDownList.getCount() > mDropDownList.getChildCount() && + mDropDownList.getChildCount() <= mListItemExpandMaximum) { + mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED); + show(); + } + } + } + + private class PopupTouchInterceptor implements OnTouchListener { + public boolean onTouch(View v, MotionEvent event) { + final int action = event.getAction(); + final int x = (int) event.getX(); + final int y = (int) event.getY(); + + if (action == MotionEvent.ACTION_DOWN && + mPopup != null && mPopup.isShowing() && + (x >= 0 && x < mPopup.getWidth() && y >= 0 && y < mPopup.getHeight())) { + mHandler.postDelayed(mResizePopupRunnable, EXPAND_LIST_TIMEOUT); + } else if (action == MotionEvent.ACTION_UP) { + mHandler.removeCallbacks(mResizePopupRunnable); + } + return false; + } + } + + private class PopupScrollListener implements ListView.OnScrollListener { + public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, + int totalItemCount) { + + } + + public void onScrollStateChanged(AbsListView view, int scrollState) { + if (scrollState == SCROLL_STATE_TOUCH_SCROLL && + !isInputMethodNotNeeded() && mPopup.getContentView() != null) { + mHandler.removeCallbacks(mResizePopupRunnable); + mResizePopupRunnable.run(); + } + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsProgressBar.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsProgressBar.java new file mode 100644 index 000000000..1c02d4aca --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsProgressBar.java @@ -0,0 +1,1193 @@ +/* + * Copyright (C) 2006 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.actionbarsherlock.internal.widget; + +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.Bitmap; +import android.graphics.BitmapShader; +import android.graphics.Canvas; +import android.graphics.Rect; +import android.graphics.Shader; +import android.graphics.drawable.Animatable; +import android.graphics.drawable.AnimationDrawable; +import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.ClipDrawable; +import android.graphics.drawable.Drawable; +import android.graphics.drawable.LayerDrawable; +import android.graphics.drawable.ShapeDrawable; +import android.graphics.drawable.shapes.RoundRectShape; +import android.graphics.drawable.shapes.Shape; +import android.os.Build; +import android.os.Parcel; +import android.os.Parcelable; +import android.os.SystemClock; +import android.util.AttributeSet; +import android.view.Gravity; +import android.view.View; +import android.view.ViewDebug; +import android.view.accessibility.AccessibilityEvent; +import android.view.accessibility.AccessibilityManager; +import android.view.animation.AlphaAnimation; +import android.view.animation.Animation; +import android.view.animation.AnimationUtils; +import android.view.animation.Interpolator; +import android.view.animation.LinearInterpolator; +import android.view.animation.Transformation; +import android.widget.RemoteViews.RemoteView; + + +/** + *

+ * Visual indicator of progress in some operation. Displays a bar to the user + * representing how far the operation has progressed; the application can + * change the amount of progress (modifying the length of the bar) as it moves + * forward. There is also a secondary progress displayable on a progress bar + * which is useful for displaying intermediate progress, such as the buffer + * level during a streaming playback progress bar. + *

+ * + *

+ * A progress bar can also be made indeterminate. In indeterminate mode, the + * progress bar shows a cyclic animation without an indication of progress. This mode is used by + * applications when the length of the task is unknown. The indeterminate progress bar can be either + * a spinning wheel or a horizontal bar. + *

+ * + *

The following code example shows how a progress bar can be used from + * a worker thread to update the user interface to notify the user of progress: + *

+ * + *
+ * public class MyActivity extends Activity {
+ *     private static final int PROGRESS = 0x1;
+ *
+ *     private ProgressBar mProgress;
+ *     private int mProgressStatus = 0;
+ *
+ *     private Handler mHandler = new Handler();
+ *
+ *     protected void onCreate(Bundle icicle) {
+ *         super.onCreate(icicle);
+ *
+ *         setContentView(R.layout.progressbar_activity);
+ *
+ *         mProgress = (ProgressBar) findViewById(R.id.progress_bar);
+ *
+ *         // Start lengthy operation in a background thread
+ *         new Thread(new Runnable() {
+ *             public void run() {
+ *                 while (mProgressStatus < 100) {
+ *                     mProgressStatus = doWork();
+ *
+ *                     // Update the progress bar
+ *                     mHandler.post(new Runnable() {
+ *                         public void run() {
+ *                             mProgress.setProgress(mProgressStatus);
+ *                         }
+ *                     });
+ *                 }
+ *             }
+ *         }).start();
+ *     }
+ * }
+ * + *

To add a progress bar to a layout file, you can use the {@code <ProgressBar>} element. + * By default, the progress bar is a spinning wheel (an indeterminate indicator). To change to a + * horizontal progress bar, apply the {@link android.R.style#Widget_ProgressBar_Horizontal + * Widget.ProgressBar.Horizontal} style, like so:

+ * + *
+ * <ProgressBar
+ *     style="@android:style/Widget.ProgressBar.Horizontal"
+ *     ... />
+ * + *

If you will use the progress bar to show real progress, you must use the horizontal bar. You + * can then increment the progress with {@link #incrementProgressBy incrementProgressBy()} or + * {@link #setProgress setProgress()}. By default, the progress bar is full when it reaches 100. If + * necessary, you can adjust the maximum value (the value for a full bar) using the {@link + * android.R.styleable#ProgressBar_max android:max} attribute. Other attributes available are listed + * below.

+ * + *

Another common style to apply to the progress bar is {@link + * android.R.style#Widget_ProgressBar_Small Widget.ProgressBar.Small}, which shows a smaller + * version of the spinning wheel—useful when waiting for content to load. + * For example, you can insert this kind of progress bar into your default layout for + * a view that will be populated by some content fetched from the Internet—the spinning wheel + * appears immediately and when your application receives the content, it replaces the progress bar + * with the loaded content. For example:

+ * + *
+ * <LinearLayout
+ *     android:orientation="horizontal"
+ *     ... >
+ *     <ProgressBar
+ *         android:layout_width="wrap_content"
+ *         android:layout_height="wrap_content"
+ *         style="@android:style/Widget.ProgressBar.Small"
+ *         android:layout_marginRight="5dp" />
+ *     <TextView
+ *         android:layout_width="wrap_content"
+ *         android:layout_height="wrap_content"
+ *         android:text="@string/loading" />
+ * </LinearLayout>
+ * + *

Other progress bar styles provided by the system include:

+ *
    + *
  • {@link android.R.style#Widget_ProgressBar_Horizontal Widget.ProgressBar.Horizontal}
  • + *
  • {@link android.R.style#Widget_ProgressBar_Small Widget.ProgressBar.Small}
  • + *
  • {@link android.R.style#Widget_ProgressBar_Large Widget.ProgressBar.Large}
  • + *
  • {@link android.R.style#Widget_ProgressBar_Inverse Widget.ProgressBar.Inverse}
  • + *
  • {@link android.R.style#Widget_ProgressBar_Small_Inverse + * Widget.ProgressBar.Small.Inverse}
  • + *
  • {@link android.R.style#Widget_ProgressBar_Large_Inverse + * Widget.ProgressBar.Large.Inverse}
  • + *
+ *

The "inverse" styles provide an inverse color scheme for the spinner, which may be necessary + * if your application uses a light colored theme (a white background).

+ * + *

XML attributes + *

+ * See {@link android.R.styleable#ProgressBar ProgressBar Attributes}, + * {@link android.R.styleable#View View Attributes} + *

+ * + * @attr ref android.R.styleable#ProgressBar_animationResolution + * @attr ref android.R.styleable#ProgressBar_indeterminate + * @attr ref android.R.styleable#ProgressBar_indeterminateBehavior + * @attr ref android.R.styleable#ProgressBar_indeterminateDrawable + * @attr ref android.R.styleable#ProgressBar_indeterminateDuration + * @attr ref android.R.styleable#ProgressBar_indeterminateOnly + * @attr ref android.R.styleable#ProgressBar_interpolator + * @attr ref android.R.styleable#ProgressBar_max + * @attr ref android.R.styleable#ProgressBar_maxHeight + * @attr ref android.R.styleable#ProgressBar_maxWidth + * @attr ref android.R.styleable#ProgressBar_minHeight + * @attr ref android.R.styleable#ProgressBar_minWidth + * @attr ref android.R.styleable#ProgressBar_progress + * @attr ref android.R.styleable#ProgressBar_progressDrawable + * @attr ref android.R.styleable#ProgressBar_secondaryProgress + */ +@RemoteView +public class IcsProgressBar extends View { + private static final boolean IS_HONEYCOMB = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB; + private static final int MAX_LEVEL = 10000; + private static final int ANIMATION_RESOLUTION = 200; + private static final int TIMEOUT_SEND_ACCESSIBILITY_EVENT = 200; + + private static final int[] ProgressBar = new int[] { + android.R.attr.maxWidth, + android.R.attr.maxHeight, + android.R.attr.max, + android.R.attr.progress, + android.R.attr.secondaryProgress, + android.R.attr.indeterminate, + android.R.attr.indeterminateOnly, + android.R.attr.indeterminateDrawable, + android.R.attr.progressDrawable, + android.R.attr.indeterminateDuration, + android.R.attr.indeterminateBehavior, + android.R.attr.minWidth, + android.R.attr.minHeight, + android.R.attr.interpolator, + android.R.attr.animationResolution, + }; + private static final int ProgressBar_maxWidth = 0; + private static final int ProgressBar_maxHeight = 1; + private static final int ProgressBar_max = 2; + private static final int ProgressBar_progress = 3; + private static final int ProgressBar_secondaryProgress = 4; + private static final int ProgressBar_indeterminate = 5; + private static final int ProgressBar_indeterminateOnly = 6; + private static final int ProgressBar_indeterminateDrawable = 7; + private static final int ProgressBar_progressDrawable = 8; + private static final int ProgressBar_indeterminateDuration = 9; + private static final int ProgressBar_indeterminateBehavior = 10; + private static final int ProgressBar_minWidth = 11; + private static final int ProgressBar_minHeight = 12; + private static final int ProgressBar_interpolator = 13; + private static final int ProgressBar_animationResolution = 14; + + int mMinWidth; + int mMaxWidth; + int mMinHeight; + int mMaxHeight; + + private int mProgress; + private int mSecondaryProgress; + private int mMax; + + private int mBehavior; + private int mDuration; + private boolean mIndeterminate; + private boolean mOnlyIndeterminate; + private Transformation mTransformation; + private AlphaAnimation mAnimation; + private Drawable mIndeterminateDrawable; + private int mIndeterminateRealLeft; + private int mIndeterminateRealTop; + private Drawable mProgressDrawable; + private Drawable mCurrentDrawable; + Bitmap mSampleTile; + private boolean mNoInvalidate; + private Interpolator mInterpolator; + private RefreshProgressRunnable mRefreshProgressRunnable; + private long mUiThreadId; + private boolean mShouldStartAnimationDrawable; + private long mLastDrawTime; + + private boolean mInDrawing; + + private int mAnimationResolution; + + private AccessibilityManager mAccessibilityManager; + private AccessibilityEventSender mAccessibilityEventSender; + + /** + * Create a new progress bar with range 0...100 and initial progress of 0. + * @param context the application environment + */ + public IcsProgressBar(Context context) { + this(context, null); + } + + public IcsProgressBar(Context context, AttributeSet attrs) { + this(context, attrs, android.R.attr.progressBarStyle); + } + + public IcsProgressBar(Context context, AttributeSet attrs, int defStyle) { + this(context, attrs, defStyle, 0); + } + + /** + * @hide + */ + public IcsProgressBar(Context context, AttributeSet attrs, int defStyle, int styleRes) { + super(context, attrs, defStyle); + mUiThreadId = Thread.currentThread().getId(); + initProgressBar(); + + TypedArray a = + context.obtainStyledAttributes(attrs, /*R.styleable.*/ProgressBar, defStyle, styleRes); + + mNoInvalidate = true; + + Drawable drawable = a.getDrawable(/*R.styleable.*/ProgressBar_progressDrawable); + if (drawable != null) { + drawable = tileify(drawable, false); + // Calling this method can set mMaxHeight, make sure the corresponding + // XML attribute for mMaxHeight is read after calling this method + setProgressDrawable(drawable); + } + + + mDuration = a.getInt(/*R.styleable.*/ProgressBar_indeterminateDuration, mDuration); + + mMinWidth = a.getDimensionPixelSize(/*R.styleable.*/ProgressBar_minWidth, mMinWidth); + mMaxWidth = a.getDimensionPixelSize(/*R.styleable.*/ProgressBar_maxWidth, mMaxWidth); + mMinHeight = a.getDimensionPixelSize(/*R.styleable.*/ProgressBar_minHeight, mMinHeight); + mMaxHeight = a.getDimensionPixelSize(/*R.styleable.*/ProgressBar_maxHeight, mMaxHeight); + + mBehavior = a.getInt(/*R.styleable.*/ProgressBar_indeterminateBehavior, mBehavior); + + final int resID = a.getResourceId( + /*com.android.internal.R.styleable.*/ProgressBar_interpolator, + android.R.anim.linear_interpolator); // default to linear interpolator + if (resID > 0) { + setInterpolator(context, resID); + } + + setMax(a.getInt(/*R.styleable.*/ProgressBar_max, mMax)); + + setProgress(a.getInt(/*R.styleable.*/ProgressBar_progress, mProgress)); + + setSecondaryProgress( + a.getInt(/*R.styleable.*/ProgressBar_secondaryProgress, mSecondaryProgress)); + + drawable = a.getDrawable(/*R.styleable.*/ProgressBar_indeterminateDrawable); + if (drawable != null) { + drawable = tileifyIndeterminate(drawable); + setIndeterminateDrawable(drawable); + } + + mOnlyIndeterminate = a.getBoolean( + /*R.styleable.*/ProgressBar_indeterminateOnly, mOnlyIndeterminate); + + mNoInvalidate = false; + + setIndeterminate(mOnlyIndeterminate || a.getBoolean( + /*R.styleable.*/ProgressBar_indeterminate, mIndeterminate)); + + mAnimationResolution = a.getInteger(/*R.styleable.*/ProgressBar_animationResolution, + ANIMATION_RESOLUTION); + + a.recycle(); + + mAccessibilityManager = (AccessibilityManager)context.getSystemService(Context.ACCESSIBILITY_SERVICE); + } + + /** + * Converts a drawable to a tiled version of itself. It will recursively + * traverse layer and state list drawables. + */ + private Drawable tileify(Drawable drawable, boolean clip) { + + if (drawable instanceof LayerDrawable) { + LayerDrawable background = (LayerDrawable) drawable; + final int N = background.getNumberOfLayers(); + Drawable[] outDrawables = new Drawable[N]; + + for (int i = 0; i < N; i++) { + int id = background.getId(i); + outDrawables[i] = tileify(background.getDrawable(i), + (id == android.R.id.progress || id == android.R.id.secondaryProgress)); + } + + LayerDrawable newBg = new LayerDrawable(outDrawables); + + for (int i = 0; i < N; i++) { + newBg.setId(i, background.getId(i)); + } + + return newBg; + + }/* else if (drawable instanceof StateListDrawable) { + StateListDrawable in = (StateListDrawable) drawable; + StateListDrawable out = new StateListDrawable(); + int numStates = in.getStateCount(); + for (int i = 0; i < numStates; i++) { + out.addState(in.getStateSet(i), tileify(in.getStateDrawable(i), clip)); + } + return out; + + }*/ else if (drawable instanceof BitmapDrawable) { + final Bitmap tileBitmap = ((BitmapDrawable) drawable).getBitmap(); + if (mSampleTile == null) { + mSampleTile = tileBitmap; + } + + final ShapeDrawable shapeDrawable = new ShapeDrawable(getDrawableShape()); + + final BitmapShader bitmapShader = new BitmapShader(tileBitmap, + Shader.TileMode.REPEAT, Shader.TileMode.CLAMP); + shapeDrawable.getPaint().setShader(bitmapShader); + + return (clip) ? new ClipDrawable(shapeDrawable, Gravity.LEFT, + ClipDrawable.HORIZONTAL) : shapeDrawable; + } + + return drawable; + } + + Shape getDrawableShape() { + final float[] roundedCorners = new float[] { 5, 5, 5, 5, 5, 5, 5, 5 }; + return new RoundRectShape(roundedCorners, null, null); + } + + /** + * Convert a AnimationDrawable for use as a barberpole animation. + * Each frame of the animation is wrapped in a ClipDrawable and + * given a tiling BitmapShader. + */ + private Drawable tileifyIndeterminate(Drawable drawable) { + if (drawable instanceof AnimationDrawable) { + AnimationDrawable background = (AnimationDrawable) drawable; + final int N = background.getNumberOfFrames(); + AnimationDrawable newBg = new AnimationDrawable(); + newBg.setOneShot(background.isOneShot()); + + for (int i = 0; i < N; i++) { + Drawable frame = tileify(background.getFrame(i), true); + frame.setLevel(10000); + newBg.addFrame(frame, background.getDuration(i)); + } + newBg.setLevel(10000); + drawable = newBg; + } + return drawable; + } + + /** + *

+ * Initialize the progress bar's default values: + *

+ *
    + *
  • progress = 0
  • + *
  • max = 100
  • + *
  • animation duration = 4000 ms
  • + *
  • indeterminate = false
  • + *
  • behavior = repeat
  • + *
+ */ + private void initProgressBar() { + mMax = 100; + mProgress = 0; + mSecondaryProgress = 0; + mIndeterminate = false; + mOnlyIndeterminate = false; + mDuration = 4000; + mBehavior = AlphaAnimation.RESTART; + mMinWidth = 24; + mMaxWidth = 48; + mMinHeight = 24; + mMaxHeight = 48; + } + + /** + *

Indicate whether this progress bar is in indeterminate mode.

+ * + * @return true if the progress bar is in indeterminate mode + */ + @ViewDebug.ExportedProperty(category = "progress") + public synchronized boolean isIndeterminate() { + return mIndeterminate; + } + + /** + *

Change the indeterminate mode for this progress bar. In indeterminate + * mode, the progress is ignored and the progress bar shows an infinite + * animation instead.

+ * + * If this progress bar's style only supports indeterminate mode (such as the circular + * progress bars), then this will be ignored. + * + * @param indeterminate true to enable the indeterminate mode + */ + public synchronized void setIndeterminate(boolean indeterminate) { + if ((!mOnlyIndeterminate || !mIndeterminate) && indeterminate != mIndeterminate) { + mIndeterminate = indeterminate; + + if (indeterminate) { + // swap between indeterminate and regular backgrounds + mCurrentDrawable = mIndeterminateDrawable; + startAnimation(); + } else { + mCurrentDrawable = mProgressDrawable; + stopAnimation(); + } + } + } + + /** + *

Get the drawable used to draw the progress bar in + * indeterminate mode.

+ * + * @return a {@link android.graphics.drawable.Drawable} instance + * + * @see #setIndeterminateDrawable(android.graphics.drawable.Drawable) + * @see #setIndeterminate(boolean) + */ + public Drawable getIndeterminateDrawable() { + return mIndeterminateDrawable; + } + + /** + *

Define the drawable used to draw the progress bar in + * indeterminate mode.

+ * + * @param d the new drawable + * + * @see #getIndeterminateDrawable() + * @see #setIndeterminate(boolean) + */ + public void setIndeterminateDrawable(Drawable d) { + if (d != null) { + d.setCallback(this); + } + mIndeterminateDrawable = d; + if (mIndeterminate) { + mCurrentDrawable = d; + postInvalidate(); + } + } + + /** + *

Get the drawable used to draw the progress bar in + * progress mode.

+ * + * @return a {@link android.graphics.drawable.Drawable} instance + * + * @see #setProgressDrawable(android.graphics.drawable.Drawable) + * @see #setIndeterminate(boolean) + */ + public Drawable getProgressDrawable() { + return mProgressDrawable; + } + + /** + *

Define the drawable used to draw the progress bar in + * progress mode.

+ * + * @param d the new drawable + * + * @see #getProgressDrawable() + * @see #setIndeterminate(boolean) + */ + public void setProgressDrawable(Drawable d) { + boolean needUpdate; + if (mProgressDrawable != null && d != mProgressDrawable) { + mProgressDrawable.setCallback(null); + needUpdate = true; + } else { + needUpdate = false; + } + + if (d != null) { + d.setCallback(this); + + // Make sure the ProgressBar is always tall enough + int drawableHeight = d.getMinimumHeight(); + if (mMaxHeight < drawableHeight) { + mMaxHeight = drawableHeight; + requestLayout(); + } + } + mProgressDrawable = d; + if (!mIndeterminate) { + mCurrentDrawable = d; + postInvalidate(); + } + + if (needUpdate) { + updateDrawableBounds(getWidth(), getHeight()); + updateDrawableState(); + doRefreshProgress(android.R.id.progress, mProgress, false, false); + doRefreshProgress(android.R.id.secondaryProgress, mSecondaryProgress, false, false); + } + } + + /** + * @return The drawable currently used to draw the progress bar + */ + Drawable getCurrentDrawable() { + return mCurrentDrawable; + } + + @Override + protected boolean verifyDrawable(Drawable who) { + return who == mProgressDrawable || who == mIndeterminateDrawable + || super.verifyDrawable(who); + } + + @Override + public void jumpDrawablesToCurrentState() { + super.jumpDrawablesToCurrentState(); + if (mProgressDrawable != null) mProgressDrawable.jumpToCurrentState(); + if (mIndeterminateDrawable != null) mIndeterminateDrawable.jumpToCurrentState(); + } + + @Override + public void postInvalidate() { + if (!mNoInvalidate) { + super.postInvalidate(); + } + } + + private class RefreshProgressRunnable implements Runnable { + + private int mId; + private int mProgress; + private boolean mFromUser; + + RefreshProgressRunnable(int id, int progress, boolean fromUser) { + mId = id; + mProgress = progress; + mFromUser = fromUser; + } + + public void run() { + doRefreshProgress(mId, mProgress, mFromUser, true); + // Put ourselves back in the cache when we are done + mRefreshProgressRunnable = this; + } + + public void setup(int id, int progress, boolean fromUser) { + mId = id; + mProgress = progress; + mFromUser = fromUser; + } + + } + + private synchronized void doRefreshProgress(int id, int progress, boolean fromUser, + boolean callBackToApp) { + float scale = mMax > 0 ? (float) progress / (float) mMax : 0; + final Drawable d = mCurrentDrawable; + if (d != null) { + Drawable progressDrawable = null; + + if (d instanceof LayerDrawable) { + progressDrawable = ((LayerDrawable) d).findDrawableByLayerId(id); + } + + final int level = (int) (scale * MAX_LEVEL); + (progressDrawable != null ? progressDrawable : d).setLevel(level); + } else { + invalidate(); + } + + if (callBackToApp && id == android.R.id.progress) { + onProgressRefresh(scale, fromUser); + } + } + + void onProgressRefresh(float scale, boolean fromUser) { + if (mAccessibilityManager.isEnabled()) { + scheduleAccessibilityEventSender(); + } + } + + private synchronized void refreshProgress(int id, int progress, boolean fromUser) { + if (mUiThreadId == Thread.currentThread().getId()) { + doRefreshProgress(id, progress, fromUser, true); + } else { + RefreshProgressRunnable r; + if (mRefreshProgressRunnable != null) { + // Use cached RefreshProgressRunnable if available + r = mRefreshProgressRunnable; + // Uncache it + mRefreshProgressRunnable = null; + r.setup(id, progress, fromUser); + } else { + // Make a new one + r = new RefreshProgressRunnable(id, progress, fromUser); + } + post(r); + } + } + + /** + *

Set the current progress to the specified value. Does not do anything + * if the progress bar is in indeterminate mode.

+ * + * @param progress the new progress, between 0 and {@link #getMax()} + * + * @see #setIndeterminate(boolean) + * @see #isIndeterminate() + * @see #getProgress() + * @see #incrementProgressBy(int) + */ + public synchronized void setProgress(int progress) { + setProgress(progress, false); + } + + synchronized void setProgress(int progress, boolean fromUser) { + if (mIndeterminate) { + return; + } + + if (progress < 0) { + progress = 0; + } + + if (progress > mMax) { + progress = mMax; + } + + if (progress != mProgress) { + mProgress = progress; + refreshProgress(android.R.id.progress, mProgress, fromUser); + } + } + + /** + *

+ * Set the current secondary progress to the specified value. Does not do + * anything if the progress bar is in indeterminate mode. + *

+ * + * @param secondaryProgress the new secondary progress, between 0 and {@link #getMax()} + * @see #setIndeterminate(boolean) + * @see #isIndeterminate() + * @see #getSecondaryProgress() + * @see #incrementSecondaryProgressBy(int) + */ + public synchronized void setSecondaryProgress(int secondaryProgress) { + if (mIndeterminate) { + return; + } + + if (secondaryProgress < 0) { + secondaryProgress = 0; + } + + if (secondaryProgress > mMax) { + secondaryProgress = mMax; + } + + if (secondaryProgress != mSecondaryProgress) { + mSecondaryProgress = secondaryProgress; + refreshProgress(android.R.id.secondaryProgress, mSecondaryProgress, false); + } + } + + /** + *

Get the progress bar's current level of progress. Return 0 when the + * progress bar is in indeterminate mode.

+ * + * @return the current progress, between 0 and {@link #getMax()} + * + * @see #setIndeterminate(boolean) + * @see #isIndeterminate() + * @see #setProgress(int) + * @see #setMax(int) + * @see #getMax() + */ + @ViewDebug.ExportedProperty(category = "progress") + public synchronized int getProgress() { + return mIndeterminate ? 0 : mProgress; + } + + /** + *

Get the progress bar's current level of secondary progress. Return 0 when the + * progress bar is in indeterminate mode.

+ * + * @return the current secondary progress, between 0 and {@link #getMax()} + * + * @see #setIndeterminate(boolean) + * @see #isIndeterminate() + * @see #setSecondaryProgress(int) + * @see #setMax(int) + * @see #getMax() + */ + @ViewDebug.ExportedProperty(category = "progress") + public synchronized int getSecondaryProgress() { + return mIndeterminate ? 0 : mSecondaryProgress; + } + + /** + *

Return the upper limit of this progress bar's range.

+ * + * @return a positive integer + * + * @see #setMax(int) + * @see #getProgress() + * @see #getSecondaryProgress() + */ + @ViewDebug.ExportedProperty(category = "progress") + public synchronized int getMax() { + return mMax; + } + + /** + *

Set the range of the progress bar to 0...max.

+ * + * @param max the upper range of this progress bar + * + * @see #getMax() + * @see #setProgress(int) + * @see #setSecondaryProgress(int) + */ + public synchronized void setMax(int max) { + if (max < 0) { + max = 0; + } + if (max != mMax) { + mMax = max; + postInvalidate(); + + if (mProgress > max) { + mProgress = max; + } + refreshProgress(android.R.id.progress, mProgress, false); + } + } + + /** + *

Increase the progress bar's progress by the specified amount.

+ * + * @param diff the amount by which the progress must be increased + * + * @see #setProgress(int) + */ + public synchronized final void incrementProgressBy(int diff) { + setProgress(mProgress + diff); + } + + /** + *

Increase the progress bar's secondary progress by the specified amount.

+ * + * @param diff the amount by which the secondary progress must be increased + * + * @see #setSecondaryProgress(int) + */ + public synchronized final void incrementSecondaryProgressBy(int diff) { + setSecondaryProgress(mSecondaryProgress + diff); + } + + /** + *

Start the indeterminate progress animation.

+ */ + void startAnimation() { + if (getVisibility() != VISIBLE) { + return; + } + + if (mIndeterminateDrawable instanceof Animatable) { + mShouldStartAnimationDrawable = true; + mAnimation = null; + } else { + if (mInterpolator == null) { + mInterpolator = new LinearInterpolator(); + } + + mTransformation = new Transformation(); + mAnimation = new AlphaAnimation(0.0f, 1.0f); + mAnimation.setRepeatMode(mBehavior); + mAnimation.setRepeatCount(Animation.INFINITE); + mAnimation.setDuration(mDuration); + mAnimation.setInterpolator(mInterpolator); + mAnimation.setStartTime(Animation.START_ON_FIRST_FRAME); + } + postInvalidate(); + } + + /** + *

Stop the indeterminate progress animation.

+ */ + void stopAnimation() { + mAnimation = null; + mTransformation = null; + if (mIndeterminateDrawable instanceof Animatable) { + ((Animatable) mIndeterminateDrawable).stop(); + mShouldStartAnimationDrawable = false; + } + postInvalidate(); + } + + /** + * Sets the acceleration curve for the indeterminate animation. + * The interpolator is loaded as a resource from the specified context. + * + * @param context The application environment + * @param resID The resource identifier of the interpolator to load + */ + public void setInterpolator(Context context, int resID) { + setInterpolator(AnimationUtils.loadInterpolator(context, resID)); + } + + /** + * Sets the acceleration curve for the indeterminate animation. + * Defaults to a linear interpolation. + * + * @param interpolator The interpolator which defines the acceleration curve + */ + public void setInterpolator(Interpolator interpolator) { + mInterpolator = interpolator; + } + + /** + * Gets the acceleration curve type for the indeterminate animation. + * + * @return the {@link Interpolator} associated to this animation + */ + public Interpolator getInterpolator() { + return mInterpolator; + } + + @Override + public void setVisibility(int v) { + if (getVisibility() != v) { + super.setVisibility(v); + + if (mIndeterminate) { + // let's be nice with the UI thread + if (v == GONE || v == INVISIBLE) { + stopAnimation(); + } else { + startAnimation(); + } + } + } + } + + @Override + protected void onVisibilityChanged(View changedView, int visibility) { + super.onVisibilityChanged(changedView, visibility); + + if (mIndeterminate) { + // let's be nice with the UI thread + if (visibility == GONE || visibility == INVISIBLE) { + stopAnimation(); + } else { + startAnimation(); + } + } + } + + @Override + public void invalidateDrawable(Drawable dr) { + if (!mInDrawing) { + if (verifyDrawable(dr)) { + final Rect dirty = dr.getBounds(); + final int scrollX = getScrollX() + getPaddingLeft(); + final int scrollY = getScrollY() + getPaddingTop(); + + invalidate(dirty.left + scrollX, dirty.top + scrollY, + dirty.right + scrollX, dirty.bottom + scrollY); + } else { + super.invalidateDrawable(dr); + } + } + } + + /** + * @hide + * + @Override + public int getResolvedLayoutDirection(Drawable who) { + return (who == mProgressDrawable || who == mIndeterminateDrawable) ? + getResolvedLayoutDirection() : super.getResolvedLayoutDirection(who); + } + */ + + @Override + protected void onSizeChanged(int w, int h, int oldw, int oldh) { + updateDrawableBounds(w, h); + } + + private void updateDrawableBounds(int w, int h) { + // onDraw will translate the canvas so we draw starting at 0,0 + int right = w - getPaddingRight() - getPaddingLeft(); + int bottom = h - getPaddingBottom() - getPaddingTop(); + int top = 0; + int left = 0; + + if (mIndeterminateDrawable != null) { + // Aspect ratio logic does not apply to AnimationDrawables + if (mOnlyIndeterminate && !(mIndeterminateDrawable instanceof AnimationDrawable)) { + // Maintain aspect ratio. Certain kinds of animated drawables + // get very confused otherwise. + final int intrinsicWidth = mIndeterminateDrawable.getIntrinsicWidth(); + final int intrinsicHeight = mIndeterminateDrawable.getIntrinsicHeight(); + final float intrinsicAspect = (float) intrinsicWidth / intrinsicHeight; + final float boundAspect = (float) w / h; + if (intrinsicAspect != boundAspect) { + if (boundAspect > intrinsicAspect) { + // New width is larger. Make it smaller to match height. + final int width = (int) (h * intrinsicAspect); + left = (w - width) / 2; + right = left + width; + } else { + // New height is larger. Make it smaller to match width. + final int height = (int) (w * (1 / intrinsicAspect)); + top = (h - height) / 2; + bottom = top + height; + } + } + } + mIndeterminateDrawable.setBounds(0, 0, right - left, bottom - top); + mIndeterminateRealLeft = left; + mIndeterminateRealTop = top; + } + + if (mProgressDrawable != null) { + mProgressDrawable.setBounds(0, 0, right, bottom); + } + } + + @Override + protected synchronized void onDraw(Canvas canvas) { + super.onDraw(canvas); + + Drawable d = mCurrentDrawable; + if (d != null) { + // Translate canvas so a indeterminate circular progress bar with padding + // rotates properly in its animation + canvas.save(); + canvas.translate(getPaddingLeft() + mIndeterminateRealLeft, getPaddingTop() + mIndeterminateRealTop); + long time = getDrawingTime(); + if (mAnimation != null) { + mAnimation.getTransformation(time, mTransformation); + float scale = mTransformation.getAlpha(); + try { + mInDrawing = true; + d.setLevel((int) (scale * MAX_LEVEL)); + } finally { + mInDrawing = false; + } + if (SystemClock.uptimeMillis() - mLastDrawTime >= mAnimationResolution) { + mLastDrawTime = SystemClock.uptimeMillis(); + postInvalidateDelayed(mAnimationResolution); + } + } + d.draw(canvas); + canvas.restore(); + if (mShouldStartAnimationDrawable && d instanceof Animatable) { + ((Animatable) d).start(); + mShouldStartAnimationDrawable = false; + } + } + } + + @Override + protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + Drawable d = mCurrentDrawable; + + int dw = 0; + int dh = 0; + if (d != null) { + dw = Math.max(mMinWidth, Math.min(mMaxWidth, d.getIntrinsicWidth())); + dh = Math.max(mMinHeight, Math.min(mMaxHeight, d.getIntrinsicHeight())); + } + updateDrawableState(); + dw += getPaddingLeft() + getPaddingRight(); + dh += getPaddingTop() + getPaddingBottom(); + + if (IS_HONEYCOMB) { + setMeasuredDimension(View.resolveSizeAndState(dw, widthMeasureSpec, 0), + View.resolveSizeAndState(dh, heightMeasureSpec, 0)); + } else { + setMeasuredDimension(View.resolveSize(dw, widthMeasureSpec), + View.resolveSize(dh, heightMeasureSpec)); + } + } + + @Override + protected void drawableStateChanged() { + super.drawableStateChanged(); + updateDrawableState(); + } + + private void updateDrawableState() { + int[] state = getDrawableState(); + + if (mProgressDrawable != null && mProgressDrawable.isStateful()) { + mProgressDrawable.setState(state); + } + + if (mIndeterminateDrawable != null && mIndeterminateDrawable.isStateful()) { + mIndeterminateDrawable.setState(state); + } + } + + static class SavedState extends BaseSavedState { + int progress; + int secondaryProgress; + + /** + * Constructor called from {@link IcsProgressBar#onSaveInstanceState()} + */ + SavedState(Parcelable superState) { + super(superState); + } + + /** + * Constructor called from {@link #CREATOR} + */ + private SavedState(Parcel in) { + super(in); + progress = in.readInt(); + secondaryProgress = in.readInt(); + } + + @Override + public void writeToParcel(Parcel out, int flags) { + super.writeToParcel(out, flags); + out.writeInt(progress); + out.writeInt(secondaryProgress); + } + + public static final Parcelable.Creator CREATOR + = new Parcelable.Creator() { + public SavedState createFromParcel(Parcel in) { + return new SavedState(in); + } + + public SavedState[] newArray(int size) { + return new SavedState[size]; + } + }; + } + + @Override + public Parcelable onSaveInstanceState() { + // Force our ancestor class to save its state + Parcelable superState = super.onSaveInstanceState(); + SavedState ss = new SavedState(superState); + + ss.progress = mProgress; + ss.secondaryProgress = mSecondaryProgress; + + return ss; + } + + @Override + public void onRestoreInstanceState(Parcelable state) { + SavedState ss = (SavedState) state; + super.onRestoreInstanceState(ss.getSuperState()); + + setProgress(ss.progress); + setSecondaryProgress(ss.secondaryProgress); + } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + if (mIndeterminate) { + startAnimation(); + } + } + + @Override + protected void onDetachedFromWindow() { + if (mIndeterminate) { + stopAnimation(); + } + if(mRefreshProgressRunnable != null) { + removeCallbacks(mRefreshProgressRunnable); + } + if (mAccessibilityEventSender != null) { + removeCallbacks(mAccessibilityEventSender); + } + // This should come after stopAnimation(), otherwise an invalidate message remains in the + // queue, which can prevent the entire view hierarchy from being GC'ed during a rotation + super.onDetachedFromWindow(); + } + + @Override + public void onInitializeAccessibilityEvent(AccessibilityEvent event) { + super.onInitializeAccessibilityEvent(event); + event.setItemCount(mMax); + event.setCurrentItemIndex(mProgress); + } + + /** + * Schedule a command for sending an accessibility event. + *
+ * Note: A command is used to ensure that accessibility events + * are sent at most one in a given time frame to save + * system resources while the progress changes quickly. + */ + private void scheduleAccessibilityEventSender() { + if (mAccessibilityEventSender == null) { + mAccessibilityEventSender = new AccessibilityEventSender(); + } else { + removeCallbacks(mAccessibilityEventSender); + } + postDelayed(mAccessibilityEventSender, TIMEOUT_SEND_ACCESSIBILITY_EVENT); + } + + /** + * Command for sending an accessibility event. + */ + private class AccessibilityEventSender implements Runnable { + public void run() { + sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsSpinner.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsSpinner.java new file mode 100644 index 000000000..038d1e031 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsSpinner.java @@ -0,0 +1,703 @@ +/* + * Copyright (C) 2007 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.actionbarsherlock.internal.widget; + +import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; +import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; +import com.actionbarsherlock.R; +import android.content.Context; +import android.content.DialogInterface; +import android.content.DialogInterface.OnClickListener; +import android.content.res.TypedArray; +import android.database.DataSetObserver; +import android.graphics.Rect; +import android.graphics.drawable.Drawable; +import android.util.AttributeSet; +import android.view.Gravity; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.ListAdapter; +import android.widget.ListView; +import android.widget.PopupWindow; +import android.widget.SpinnerAdapter; + + +/** + * A view that displays one child at a time and lets the user pick among them. + * The items in the Spinner come from the {@link Adapter} associated with + * this view. + * + *

See the Spinner + * tutorial.

+ * + * @attr ref android.R.styleable#Spinner_prompt + */ +public class IcsSpinner extends IcsAbsSpinner implements OnClickListener { + //private static final String TAG = "Spinner"; + + // Only measure this many items to get a decent max width. + private static final int MAX_ITEMS_MEASURED = 15; + + /** + * Use a dialog window for selecting spinner options. + */ + //public static final int MODE_DIALOG = 0; + + /** + * Use a dropdown anchored to the Spinner for selecting spinner options. + */ + public static final int MODE_DROPDOWN = 1; + + /** + * Use the theme-supplied value to select the dropdown mode. + */ + //private static final int MODE_THEME = -1; + + private SpinnerPopup mPopup; + private DropDownAdapter mTempAdapter; + int mDropDownWidth; + + private int mGravity; + private boolean mDisableChildrenWhenDisabled; + + private Rect mTempRect = new Rect(); + + public IcsSpinner(Context context, AttributeSet attrs) { + this(context, attrs, R.attr.actionDropDownStyle); + } + + /** + * Construct a new spinner with the given context's theme, the supplied attribute set, + * and default style. + * + * @param context The Context the view is running in, through which it can + * access the current theme, resources, etc. + * @param attrs The attributes of the XML tag that is inflating the view. + * @param defStyle The default style to apply to this view. If 0, no style + * will be applied (beyond what is included in the theme). This may + * either be an attribute resource, whose value will be retrieved + * from the current theme, or an explicit style resource. + */ + public IcsSpinner(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + + TypedArray a = context.obtainStyledAttributes(attrs, + R.styleable.SherlockSpinner, defStyle, 0); + + + DropdownPopup popup = new DropdownPopup(context, attrs, defStyle); + + mDropDownWidth = a.getLayoutDimension( + R.styleable.SherlockSpinner_android_dropDownWidth, + ViewGroup.LayoutParams.WRAP_CONTENT); + popup.setBackgroundDrawable(a.getDrawable( + R.styleable.SherlockSpinner_android_popupBackground)); + final int verticalOffset = a.getDimensionPixelOffset( + R.styleable.SherlockSpinner_android_dropDownVerticalOffset, 0); + if (verticalOffset != 0) { + popup.setVerticalOffset(verticalOffset); + } + + final int horizontalOffset = a.getDimensionPixelOffset( + R.styleable.SherlockSpinner_android_dropDownHorizontalOffset, 0); + if (horizontalOffset != 0) { + popup.setHorizontalOffset(horizontalOffset); + } + + mPopup = popup; + + mGravity = a.getInt(R.styleable.SherlockSpinner_android_gravity, Gravity.CENTER); + + mPopup.setPromptText(a.getString(R.styleable.SherlockSpinner_android_prompt)); + + mDisableChildrenWhenDisabled = true; + + a.recycle(); + + // Base constructor can call setAdapter before we initialize mPopup. + // Finish setting things up if this happened. + if (mTempAdapter != null) { + mPopup.setAdapter(mTempAdapter); + mTempAdapter = null; + } + } + + @Override + public void setEnabled(boolean enabled) { + super.setEnabled(enabled); + if (mDisableChildrenWhenDisabled) { + final int count = getChildCount(); + for (int i = 0; i < count; i++) { + getChildAt(i).setEnabled(enabled); + } + } + } + + /** + * Describes how the selected item view is positioned. Currently only the horizontal component + * is used. The default is determined by the current theme. + * + * @param gravity See {@link android.view.Gravity} + * + * @attr ref android.R.styleable#Spinner_gravity + */ + public void setGravity(int gravity) { + if (mGravity != gravity) { + if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == 0) { + gravity |= Gravity.LEFT; + } + mGravity = gravity; + requestLayout(); + } + } + + @Override + public void setAdapter(SpinnerAdapter adapter) { + super.setAdapter(adapter); + + if (mPopup != null) { + mPopup.setAdapter(new DropDownAdapter(adapter)); + } else { + mTempAdapter = new DropDownAdapter(adapter); + } + } + + @Override + public int getBaseline() { + View child = null; + + if (getChildCount() > 0) { + child = getChildAt(0); + } else if (mAdapter != null && mAdapter.getCount() > 0) { + child = makeAndAddView(0); + mRecycler.put(0, child); + removeAllViewsInLayout(); + } + + if (child != null) { + final int childBaseline = child.getBaseline(); + return childBaseline >= 0 ? child.getTop() + childBaseline : -1; + } else { + return -1; + } + } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + + if (mPopup != null && mPopup.isShowing()) { + mPopup.dismiss(); + } + } + + /** + *

A spinner does not support item click events. Calling this method + * will raise an exception.

+ * + * @param l this listener will be ignored + */ + @Override + public void setOnItemClickListener(OnItemClickListener l) { + throw new RuntimeException("setOnItemClickListener cannot be used with a spinner."); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + if (mPopup != null && MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.AT_MOST) { + final int measuredWidth = getMeasuredWidth(); + setMeasuredDimension(Math.min(Math.max(measuredWidth, + measureContentWidth(getAdapter(), getBackground())), + MeasureSpec.getSize(widthMeasureSpec)), + getMeasuredHeight()); + } + } + + /** + * @see android.view.View#onLayout(boolean,int,int,int,int) + * + * Creates and positions all views + * + */ + @Override + protected void onLayout(boolean changed, int l, int t, int r, int b) { + super.onLayout(changed, l, t, r, b); + mInLayout = true; + layout(0, false); + mInLayout = false; + } + + /** + * Creates and positions all views for this Spinner. + * + * @param delta Change in the selected position. +1 moves selection is moving to the right, + * so views are scrolling to the left. -1 means selection is moving to the left. + */ + @Override + void layout(int delta, boolean animate) { + int childrenLeft = mSpinnerPadding.left; + int childrenWidth = getRight() - getLeft() - mSpinnerPadding.left - mSpinnerPadding.right; + + if (mDataChanged) { + handleDataChanged(); + } + + // Handle the empty set by removing all views + if (mItemCount == 0) { + resetList(); + return; + } + + if (mNextSelectedPosition >= 0) { + setSelectedPositionInt(mNextSelectedPosition); + } + + recycleAllViews(); + + // Clear out old views + removeAllViewsInLayout(); + + // Make selected view and position it + mFirstPosition = mSelectedPosition; + View sel = makeAndAddView(mSelectedPosition); + int width = sel.getMeasuredWidth(); + int selectedOffset = childrenLeft; + switch (mGravity & Gravity.HORIZONTAL_GRAVITY_MASK) { + case Gravity.CENTER_HORIZONTAL: + selectedOffset = childrenLeft + (childrenWidth / 2) - (width / 2); + break; + case Gravity.RIGHT: + selectedOffset = childrenLeft + childrenWidth - width; + break; + } + sel.offsetLeftAndRight(selectedOffset); + + // Flush any cached views that did not get reused above + mRecycler.clear(); + + invalidate(); + + checkSelectionChanged(); + + mDataChanged = false; + mNeedSync = false; + setNextSelectedPositionInt(mSelectedPosition); + } + + /** + * Obtain a view, either by pulling an existing view from the recycler or + * by getting a new one from the adapter. If we are animating, make sure + * there is enough information in the view's layout parameters to animate + * from the old to new positions. + * + * @param position Position in the spinner for the view to obtain + * @return A view that has been added to the spinner + */ + private View makeAndAddView(int position) { + + View child; + + if (!mDataChanged) { + child = mRecycler.get(position); + if (child != null) { + // Position the view + setUpChild(child); + + return child; + } + } + + // Nothing found in the recycler -- ask the adapter for a view + child = mAdapter.getView(position, null, this); + + // Position the view + setUpChild(child); + + return child; + } + + /** + * Helper for makeAndAddView to set the position of a view + * and fill out its layout paramters. + * + * @param child The view to position + */ + private void setUpChild(View child) { + + // Respect layout params that are already in the view. Otherwise + // make some up... + ViewGroup.LayoutParams lp = child.getLayoutParams(); + if (lp == null) { + lp = generateDefaultLayoutParams(); + } + + addViewInLayout(child, 0, lp); + + child.setSelected(hasFocus()); + if (mDisableChildrenWhenDisabled) { + child.setEnabled(isEnabled()); + } + + // Get measure specs + int childHeightSpec = ViewGroup.getChildMeasureSpec(mHeightMeasureSpec, + mSpinnerPadding.top + mSpinnerPadding.bottom, lp.height); + int childWidthSpec = ViewGroup.getChildMeasureSpec(mWidthMeasureSpec, + mSpinnerPadding.left + mSpinnerPadding.right, lp.width); + + // Measure child + child.measure(childWidthSpec, childHeightSpec); + + int childLeft; + int childRight; + + // Position vertically based on gravity setting + int childTop = mSpinnerPadding.top + + ((getMeasuredHeight() - mSpinnerPadding.bottom - + mSpinnerPadding.top - child.getMeasuredHeight()) / 2); + int childBottom = childTop + child.getMeasuredHeight(); + + int width = child.getMeasuredWidth(); + childLeft = 0; + childRight = childLeft + width; + + child.layout(childLeft, childTop, childRight, childBottom); + } + + @Override + public boolean performClick() { + boolean handled = super.performClick(); + + if (!handled) { + handled = true; + + if (!mPopup.isShowing()) { + mPopup.show(); + } + } + + return handled; + } + + public void onClick(DialogInterface dialog, int which) { + setSelection(which); + dialog.dismiss(); + } + + /** + * Sets the prompt to display when the dialog is shown. + * @param prompt the prompt to set + */ + public void setPrompt(CharSequence prompt) { + mPopup.setPromptText(prompt); + } + + /** + * Sets the prompt to display when the dialog is shown. + * @param promptId the resource ID of the prompt to display when the dialog is shown + */ + public void setPromptId(int promptId) { + setPrompt(getContext().getText(promptId)); + } + + /** + * @return The prompt to display when the dialog is shown + */ + public CharSequence getPrompt() { + return mPopup.getHintText(); + } + + int measureContentWidth(SpinnerAdapter adapter, Drawable background) { + if (adapter == null) { + return 0; + } + + int width = 0; + View itemView = null; + int itemType = 0; + final int widthMeasureSpec = + MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); + final int heightMeasureSpec = + MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); + + // Make sure the number of items we'll measure is capped. If it's a huge data set + // with wildly varying sizes, oh well. + int start = Math.max(0, getSelectedItemPosition()); + final int end = Math.min(adapter.getCount(), start + MAX_ITEMS_MEASURED); + final int count = end - start; + start = Math.max(0, start - (MAX_ITEMS_MEASURED - count)); + for (int i = start; i < end; i++) { + final int positionType = adapter.getItemViewType(i); + if (positionType != itemType) { + itemType = positionType; + itemView = null; + } + itemView = adapter.getView(i, itemView, this); + if (itemView.getLayoutParams() == null) { + itemView.setLayoutParams(new ViewGroup.LayoutParams( + ViewGroup.LayoutParams.WRAP_CONTENT, + ViewGroup.LayoutParams.WRAP_CONTENT)); + } + itemView.measure(widthMeasureSpec, heightMeasureSpec); + width = Math.max(width, itemView.getMeasuredWidth()); + } + + // Add background padding to measured width + if (background != null) { + background.getPadding(mTempRect); + width += mTempRect.left + mTempRect.right; + } + + return width; + } + + /** + *

Wrapper class for an Adapter. Transforms the embedded Adapter instance + * into a ListAdapter.

+ */ + private static class DropDownAdapter implements ListAdapter, SpinnerAdapter { + private SpinnerAdapter mAdapter; + private ListAdapter mListAdapter; + + /** + *

Creates a new ListAdapter wrapper for the specified adapter.

+ * + * @param adapter the Adapter to transform into a ListAdapter + */ + public DropDownAdapter(SpinnerAdapter adapter) { + this.mAdapter = adapter; + if (adapter instanceof ListAdapter) { + this.mListAdapter = (ListAdapter) adapter; + } + } + + public int getCount() { + return mAdapter == null ? 0 : mAdapter.getCount(); + } + + public Object getItem(int position) { + return mAdapter == null ? null : mAdapter.getItem(position); + } + + public long getItemId(int position) { + return mAdapter == null ? -1 : mAdapter.getItemId(position); + } + + public View getView(int position, View convertView, ViewGroup parent) { + return getDropDownView(position, convertView, parent); + } + + public View getDropDownView(int position, View convertView, ViewGroup parent) { + return mAdapter == null ? null : + mAdapter.getDropDownView(position, convertView, parent); + } + + public boolean hasStableIds() { + return mAdapter != null && mAdapter.hasStableIds(); + } + + public void registerDataSetObserver(DataSetObserver observer) { + if (mAdapter != null) { + mAdapter.registerDataSetObserver(observer); + } + } + + public void unregisterDataSetObserver(DataSetObserver observer) { + if (mAdapter != null) { + mAdapter.unregisterDataSetObserver(observer); + } + } + + /** + * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call. + * Otherwise, return true. + */ + public boolean areAllItemsEnabled() { + final ListAdapter adapter = mListAdapter; + if (adapter != null) { + return adapter.areAllItemsEnabled(); + } else { + return true; + } + } + + /** + * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call. + * Otherwise, return true. + */ + public boolean isEnabled(int position) { + final ListAdapter adapter = mListAdapter; + if (adapter != null) { + return adapter.isEnabled(position); + } else { + return true; + } + } + + public int getItemViewType(int position) { + return 0; + } + + public int getViewTypeCount() { + return 1; + } + + public boolean isEmpty() { + return getCount() == 0; + } + } + + /** + * Implements some sort of popup selection interface for selecting a spinner option. + * Allows for different spinner modes. + */ + private interface SpinnerPopup { + public void setAdapter(ListAdapter adapter); + + /** + * Show the popup + */ + public void show(); + + /** + * Dismiss the popup + */ + public void dismiss(); + + /** + * @return true if the popup is showing, false otherwise. + */ + public boolean isShowing(); + + /** + * Set hint text to be displayed to the user. This should provide + * a description of the choice being made. + * @param hintText Hint text to set. + */ + public void setPromptText(CharSequence hintText); + public CharSequence getHintText(); + } + + /* + private class DialogPopup implements SpinnerPopup, DialogInterface.OnClickListener { + private AlertDialog mPopup; + private ListAdapter mListAdapter; + private CharSequence mPrompt; + + public void dismiss() { + mPopup.dismiss(); + mPopup = null; + } + + public boolean isShowing() { + return mPopup != null ? mPopup.isShowing() : false; + } + + public void setAdapter(ListAdapter adapter) { + mListAdapter = adapter; + } + + public void setPromptText(CharSequence hintText) { + mPrompt = hintText; + } + + public CharSequence getHintText() { + return mPrompt; + } + + public void show() { + AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); + if (mPrompt != null) { + builder.setTitle(mPrompt); + } + mPopup = builder.setSingleChoiceItems(mListAdapter, + getSelectedItemPosition(), this).show(); + } + + public void onClick(DialogInterface dialog, int which) { + setSelection(which); + dismiss(); + } + } + */ + + private class DropdownPopup extends IcsListPopupWindow implements SpinnerPopup { + private CharSequence mHintText; + private ListAdapter mAdapter; + + public DropdownPopup(Context context, AttributeSet attrs, int defStyleRes) { + super(context, attrs, 0, defStyleRes); + + setAnchorView(IcsSpinner.this); + setModal(true); + setPromptPosition(POSITION_PROMPT_ABOVE); + setOnItemClickListener(new OnItemClickListener() { + @SuppressWarnings("rawtypes") + public void onItemClick(AdapterView parent, View v, int position, long id) { + IcsSpinner.this.setSelection(position); + dismiss(); + } + }); + } + + @Override + public void setAdapter(ListAdapter adapter) { + super.setAdapter(adapter); + mAdapter = adapter; + } + + public CharSequence getHintText() { + return mHintText; + } + + public void setPromptText(CharSequence hintText) { + // Hint text is ignored for dropdowns, but maintain it here. + mHintText = hintText; + } + + @Override + public void show() { + final int spinnerPaddingLeft = IcsSpinner.this.getPaddingLeft(); + if (mDropDownWidth == WRAP_CONTENT) { + final int spinnerWidth = IcsSpinner.this.getWidth(); + final int spinnerPaddingRight = IcsSpinner.this.getPaddingRight(); + setContentWidth(Math.max( + measureContentWidth((SpinnerAdapter) mAdapter, getBackground()), + spinnerWidth - spinnerPaddingLeft - spinnerPaddingRight)); + } else if (mDropDownWidth == MATCH_PARENT) { + final int spinnerWidth = IcsSpinner.this.getWidth(); + final int spinnerPaddingRight = IcsSpinner.this.getPaddingRight(); + setContentWidth(spinnerWidth - spinnerPaddingLeft - spinnerPaddingRight); + } else { + setContentWidth(mDropDownWidth); + } + final Drawable background = getBackground(); + int bgOffset = 0; + if (background != null) { + background.getPadding(mTempRect); + bgOffset = -mTempRect.left; + } + setHorizontalOffset(bgOffset + spinnerPaddingLeft); + setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED); + super.show(); + getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE); + setSelection(IcsSpinner.this.getSelectedItemPosition()); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsView.java new file mode 100644 index 000000000..a7185d082 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsView.java @@ -0,0 +1,21 @@ +package com.actionbarsherlock.internal.widget; + +import android.view.View; + +final class IcsView { + //No instances + private IcsView() {} + + /** + * Return only the state bits of {@link #getMeasuredWidthAndState()} + * and {@link #getMeasuredHeightAndState()}, combined into one integer. + * The width component is in the regular bits {@link #MEASURED_STATE_MASK} + * and the height component is at the shifted bits + * {@link #MEASURED_HEIGHT_STATE_SHIFT}>>{@link #MEASURED_STATE_MASK}. + */ + public static int getMeasuredStateInt(View child) { + return (child.getMeasuredWidth()&View.MEASURED_STATE_MASK) + | ((child.getMeasuredHeight()>>View.MEASURED_HEIGHT_STATE_SHIFT) + & (View.MEASURED_STATE_MASK>>View.MEASURED_HEIGHT_STATE_SHIFT)); + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.java new file mode 100644 index 000000000..1a532e06c --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.java @@ -0,0 +1,545 @@ +/* + * Copyright (C) 2011 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.actionbarsherlock.internal.widget; + +import android.content.Context; +import android.content.res.Configuration; +import android.content.res.TypedArray; +import android.graphics.drawable.Drawable; +import android.text.TextUtils.TruncateAt; +import android.util.AttributeSet; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewParent; +import android.view.animation.DecelerateInterpolator; +import android.view.animation.Interpolator; +import android.widget.BaseAdapter; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.ListView; +import com.actionbarsherlock.R; +import com.actionbarsherlock.app.ActionBar; +import com.actionbarsherlock.internal.nineoldandroids.animation.Animator; +import com.actionbarsherlock.internal.nineoldandroids.animation.ObjectAnimator; +import com.actionbarsherlock.internal.nineoldandroids.widget.NineHorizontalScrollView; + +/** + * This widget implements the dynamic action bar tab behavior that can change + * across different configurations or circumstances. + */ +public class ScrollingTabContainerView extends NineHorizontalScrollView + implements IcsAdapterView.OnItemSelectedListener { + //UNUSED private static final String TAG = "ScrollingTabContainerView"; + Runnable mTabSelector; + private TabClickListener mTabClickListener; + + private IcsLinearLayout mTabLayout; + private IcsSpinner mTabSpinner; + private boolean mAllowCollapse; + + private LayoutInflater mInflater; + + int mMaxTabWidth; + private int mContentHeight; + private int mSelectedTabIndex; + + protected Animator mVisibilityAnim; + protected final VisibilityAnimListener mVisAnimListener = new VisibilityAnimListener(); + + private static final /*Time*/Interpolator sAlphaInterpolator = new DecelerateInterpolator(); + + private static final int FADE_DURATION = 200; + + public ScrollingTabContainerView(Context context) { + super(context); + setHorizontalScrollBarEnabled(false); + + TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.SherlockActionBar, + R.attr.actionBarStyle, 0); + setContentHeight(a.getLayoutDimension(R.styleable.SherlockActionBar_height, 0)); + a.recycle(); + + mInflater = LayoutInflater.from(context); + + mTabLayout = createTabLayout(); + addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, + ViewGroup.LayoutParams.MATCH_PARENT)); + } + + @Override + public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + final int widthMode = MeasureSpec.getMode(widthMeasureSpec); + final boolean lockedExpanded = widthMode == MeasureSpec.EXACTLY; + setFillViewport(lockedExpanded); + + final int childCount = mTabLayout.getChildCount(); + if (childCount > 1 && + (widthMode == MeasureSpec.EXACTLY || widthMode == MeasureSpec.AT_MOST)) { + if (childCount > 2) { + mMaxTabWidth = (int) (MeasureSpec.getSize(widthMeasureSpec) * 0.4f); + } else { + mMaxTabWidth = MeasureSpec.getSize(widthMeasureSpec) / 2; + } + } else { + mMaxTabWidth = -1; + } + + heightMeasureSpec = MeasureSpec.makeMeasureSpec(mContentHeight, MeasureSpec.EXACTLY); + + final boolean canCollapse = !lockedExpanded && mAllowCollapse; + + if (canCollapse) { + // See if we should expand + mTabLayout.measure(MeasureSpec.UNSPECIFIED, heightMeasureSpec); + if (mTabLayout.getMeasuredWidth() > MeasureSpec.getSize(widthMeasureSpec)) { + performCollapse(); + } else { + performExpand(); + } + } else { + performExpand(); + } + + final int oldWidth = getMeasuredWidth(); + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + final int newWidth = getMeasuredWidth(); + + if (lockedExpanded && oldWidth != newWidth) { + // Recenter the tab display if we're at a new (scrollable) size. + setTabSelected(mSelectedTabIndex); + } + } + + /** + * Indicates whether this view is collapsed into a dropdown menu instead + * of traditional tabs. + * @return true if showing as a spinner + */ + private boolean isCollapsed() { + return mTabSpinner != null && mTabSpinner.getParent() == this; + } + + public void setAllowCollapse(boolean allowCollapse) { + mAllowCollapse = allowCollapse; + } + + private void performCollapse() { + if (isCollapsed()) return; + + if (mTabSpinner == null) { + mTabSpinner = createSpinner(); + } + removeView(mTabLayout); + addView(mTabSpinner, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, + ViewGroup.LayoutParams.MATCH_PARENT)); + if (mTabSpinner.getAdapter() == null) { + mTabSpinner.setAdapter(new TabAdapter()); + } + if (mTabSelector != null) { + removeCallbacks(mTabSelector); + mTabSelector = null; + } + mTabSpinner.setSelection(mSelectedTabIndex); + } + + private boolean performExpand() { + if (!isCollapsed()) return false; + + removeView(mTabSpinner); + addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, + ViewGroup.LayoutParams.MATCH_PARENT)); + setTabSelected(mTabSpinner.getSelectedItemPosition()); + return false; + } + + public void setTabSelected(int position) { + mSelectedTabIndex = position; + final int tabCount = mTabLayout.getChildCount(); + for (int i = 0; i < tabCount; i++) { + final View child = mTabLayout.getChildAt(i); + final boolean isSelected = i == position; + child.setSelected(isSelected); + if (isSelected) { + animateToTab(position); + } + } + } + + public void setContentHeight(int contentHeight) { + mContentHeight = contentHeight; + requestLayout(); + } + + private IcsLinearLayout createTabLayout() { + final IcsLinearLayout tabLayout = (IcsLinearLayout) LayoutInflater.from(getContext()) + .inflate(R.layout.abs__action_bar_tab_bar_view, null); + tabLayout.setLayoutParams(new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT)); + return tabLayout; + } + + private IcsSpinner createSpinner() { + final IcsSpinner spinner = new IcsSpinner(getContext(), null, + R.attr.actionDropDownStyle); + spinner.setLayoutParams(new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT)); + spinner.setOnItemSelectedListener(this); + return spinner; + } + + @Override + protected void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + + // Action bar can change size on configuration changes. + // Reread the desired height from the theme-specified style. + TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.SherlockActionBar, + R.attr.actionBarStyle, 0); + setContentHeight(a.getLayoutDimension(R.styleable.SherlockActionBar_height, 0)); + a.recycle(); + } + + public void animateToVisibility(int visibility) { + if (mVisibilityAnim != null) { + mVisibilityAnim.cancel(); + } + if (visibility == VISIBLE) { + if (getVisibility() != VISIBLE) { + setAlpha(0); + } + ObjectAnimator anim = ObjectAnimator.ofFloat(this, "alpha", 1); + anim.setDuration(FADE_DURATION); + anim.setInterpolator(sAlphaInterpolator); + + anim.addListener(mVisAnimListener.withFinalVisibility(visibility)); + anim.start(); + } else { + ObjectAnimator anim = ObjectAnimator.ofFloat(this, "alpha", 0); + anim.setDuration(FADE_DURATION); + anim.setInterpolator(sAlphaInterpolator); + + anim.addListener(mVisAnimListener.withFinalVisibility(visibility)); + anim.start(); + } + } + + public void animateToTab(final int position) { + final View tabView = mTabLayout.getChildAt(position); + if (mTabSelector != null) { + removeCallbacks(mTabSelector); + } + mTabSelector = new Runnable() { + public void run() { + final int scrollPos = tabView.getLeft() - (getWidth() - tabView.getWidth()) / 2; + smoothScrollTo(scrollPos, 0); + mTabSelector = null; + } + }; + post(mTabSelector); + } + + @Override + public void onAttachedToWindow() { + super.onAttachedToWindow(); + if (mTabSelector != null) { + // Re-post the selector we saved + post(mTabSelector); + } + } + + @Override + public void onDetachedFromWindow() { + super.onDetachedFromWindow(); + if (mTabSelector != null) { + removeCallbacks(mTabSelector); + } + } + + private TabView createTabView(ActionBar.Tab tab, boolean forAdapter) { + //Workaround for not being able to pass a defStyle on pre-3.0 + final TabView tabView = (TabView)mInflater.inflate(R.layout.abs__action_bar_tab, null); + tabView.init(this, tab, forAdapter); + + if (forAdapter) { + tabView.setBackgroundDrawable(null); + tabView.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, + mContentHeight)); + } else { + tabView.setFocusable(true); + + if (mTabClickListener == null) { + mTabClickListener = new TabClickListener(); + } + tabView.setOnClickListener(mTabClickListener); + } + return tabView; + } + + public void addTab(ActionBar.Tab tab, boolean setSelected) { + TabView tabView = createTabView(tab, false); + mTabLayout.addView(tabView, new IcsLinearLayout.LayoutParams(0, + LayoutParams.MATCH_PARENT, 1)); + if (mTabSpinner != null) { + ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged(); + } + if (setSelected) { + tabView.setSelected(true); + } + if (mAllowCollapse) { + requestLayout(); + } + } + + public void addTab(ActionBar.Tab tab, int position, boolean setSelected) { + final TabView tabView = createTabView(tab, false); + mTabLayout.addView(tabView, position, new IcsLinearLayout.LayoutParams( + 0, LayoutParams.MATCH_PARENT, 1)); + if (mTabSpinner != null) { + ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged(); + } + if (setSelected) { + tabView.setSelected(true); + } + if (mAllowCollapse) { + requestLayout(); + } + } + + public void updateTab(int position) { + ((TabView) mTabLayout.getChildAt(position)).update(); + if (mTabSpinner != null) { + ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged(); + } + if (mAllowCollapse) { + requestLayout(); + } + } + + public void removeTabAt(int position) { + mTabLayout.removeViewAt(position); + if (mTabSpinner != null) { + ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged(); + } + if (mAllowCollapse) { + requestLayout(); + } + } + + public void removeAllTabs() { + mTabLayout.removeAllViews(); + if (mTabSpinner != null) { + ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged(); + } + if (mAllowCollapse) { + requestLayout(); + } + } + + @Override + public void onItemSelected(IcsAdapterView parent, View view, int position, long id) { + TabView tabView = (TabView) view; + tabView.getTab().select(); + } + + @Override + public void onNothingSelected(IcsAdapterView parent) { + } + + public static class TabView extends LinearLayout { + private ScrollingTabContainerView mParent; + private ActionBar.Tab mTab; + private CapitalizingTextView mTextView; + private ImageView mIconView; + private View mCustomView; + + public TabView(Context context, AttributeSet attrs) { + //TODO super(context, null, R.attr.actionBarTabStyle); + super(context, attrs); + } + + public void init(ScrollingTabContainerView parent, ActionBar.Tab tab, boolean forList) { + mParent = parent; + mTab = tab; + + if (forList) { + setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); + } + + update(); + } + + public void bindTab(ActionBar.Tab tab) { + mTab = tab; + update(); + } + + @Override + public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + + // Re-measure if we went beyond our maximum size. + if (mParent.mMaxTabWidth > 0 && getMeasuredWidth() > mParent.mMaxTabWidth) { + super.onMeasure(MeasureSpec.makeMeasureSpec(mParent.mMaxTabWidth, MeasureSpec.EXACTLY), + heightMeasureSpec); + } + } + + public void update() { + final ActionBar.Tab tab = mTab; + final View custom = tab.getCustomView(); + if (custom != null) { + final ViewParent customParent = custom.getParent(); + if (customParent != this) { + if (customParent != null) ((ViewGroup) customParent).removeView(custom); + addView(custom); + } + mCustomView = custom; + if (mTextView != null) mTextView.setVisibility(GONE); + if (mIconView != null) { + mIconView.setVisibility(GONE); + mIconView.setImageDrawable(null); + } + } else { + if (mCustomView != null) { + removeView(mCustomView); + mCustomView = null; + } + + final Drawable icon = tab.getIcon(); + final CharSequence text = tab.getText(); + + if (icon != null) { + if (mIconView == null) { + ImageView iconView = new ImageView(getContext()); + LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, + LayoutParams.WRAP_CONTENT); + lp.gravity = Gravity.CENTER_VERTICAL; + iconView.setLayoutParams(lp); + addView(iconView, 0); + mIconView = iconView; + } + mIconView.setImageDrawable(icon); + mIconView.setVisibility(VISIBLE); + } else if (mIconView != null) { + mIconView.setVisibility(GONE); + mIconView.setImageDrawable(null); + } + + if (text != null) { + if (mTextView == null) { + CapitalizingTextView textView = new CapitalizingTextView(getContext(), null, + R.attr.actionBarTabTextStyle); + textView.setEllipsize(TruncateAt.END); + LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, + LayoutParams.WRAP_CONTENT); + lp.gravity = Gravity.CENTER_VERTICAL; + textView.setLayoutParams(lp); + addView(textView); + mTextView = textView; + } + mTextView.setTextCompat(text); + mTextView.setVisibility(VISIBLE); + } else if (mTextView != null) { + mTextView.setVisibility(GONE); + mTextView.setText(null); + } + + if (mIconView != null) { + mIconView.setContentDescription(tab.getContentDescription()); + } + } + } + + public ActionBar.Tab getTab() { + return mTab; + } + } + + private class TabAdapter extends BaseAdapter { + @Override + public int getCount() { + return mTabLayout.getChildCount(); + } + + @Override + public Object getItem(int position) { + return ((TabView) mTabLayout.getChildAt(position)).getTab(); + } + + @Override + public long getItemId(int position) { + return position; + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + if (convertView == null) { + convertView = createTabView((ActionBar.Tab) getItem(position), true); + } else { + ((TabView) convertView).bindTab((ActionBar.Tab) getItem(position)); + } + return convertView; + } + } + + private class TabClickListener implements OnClickListener { + public void onClick(View view) { + TabView tabView = (TabView) view; + tabView.getTab().select(); + final int tabCount = mTabLayout.getChildCount(); + for (int i = 0; i < tabCount; i++) { + final View child = mTabLayout.getChildAt(i); + child.setSelected(child == view); + } + } + } + + protected class VisibilityAnimListener implements Animator.AnimatorListener { + private boolean mCanceled = false; + private int mFinalVisibility; + + public VisibilityAnimListener withFinalVisibility(int visibility) { + mFinalVisibility = visibility; + return this; + } + + @Override + public void onAnimationStart(Animator animation) { + setVisibility(VISIBLE); + mVisibilityAnim = animation; + mCanceled = false; + } + + @Override + public void onAnimationEnd(Animator animation) { + if (mCanceled) return; + + mVisibilityAnim = null; + setVisibility(mFinalVisibility); + } + + @Override + public void onAnimationCancel(Animator animation) { + mCanceled = true; + } + + @Override + public void onAnimationRepeat(Animator animation) { + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/view/ActionMode.java b/actionbarsherlock/src/com/actionbarsherlock/view/ActionMode.java new file mode 100644 index 000000000..81b4cd4d2 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/view/ActionMode.java @@ -0,0 +1,224 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.view; + +import android.view.View; + + +/** + * Represents a contextual mode of the user interface. Action modes can be used for + * modal interactions with content and replace parts of the normal UI until finished. + * Examples of good action modes include selection modes, search, content editing, etc. + */ +public abstract class ActionMode { + private Object mTag; + + /** + * Set a tag object associated with this ActionMode. + * + *

Like the tag available to views, this allows applications to associate arbitrary + * data with an ActionMode for later reference. + * + * @param tag Tag to associate with this ActionMode + * + * @see #getTag() + */ + public void setTag(Object tag) { + mTag = tag; + } + + /** + * Retrieve the tag object associated with this ActionMode. + * + *

Like the tag available to views, this allows applications to associate arbitrary + * data with an ActionMode for later reference. + * + * @return Tag associated with this ActionMode + * + * @see #setTag(Object) + */ + public Object getTag() { + return mTag; + } + + /** + * Set the title of the action mode. This method will have no visible effect if + * a custom view has been set. + * + * @param title Title string to set + * + * @see #setTitle(int) + * @see #setCustomView(View) + */ + public abstract void setTitle(CharSequence title); + + /** + * Set the title of the action mode. This method will have no visible effect if + * a custom view has been set. + * + * @param resId Resource ID of a string to set as the title + * + * @see #setTitle(CharSequence) + * @see #setCustomView(View) + */ + public abstract void setTitle(int resId); + + /** + * Set the subtitle of the action mode. This method will have no visible effect if + * a custom view has been set. + * + * @param subtitle Subtitle string to set + * + * @see #setSubtitle(int) + * @see #setCustomView(View) + */ + public abstract void setSubtitle(CharSequence subtitle); + + /** + * Set the subtitle of the action mode. This method will have no visible effect if + * a custom view has been set. + * + * @param resId Resource ID of a string to set as the subtitle + * + * @see #setSubtitle(CharSequence) + * @see #setCustomView(View) + */ + public abstract void setSubtitle(int resId); + + /** + * Set a custom view for this action mode. The custom view will take the place of + * the title and subtitle. Useful for things like search boxes. + * + * @param view Custom view to use in place of the title/subtitle. + * + * @see #setTitle(CharSequence) + * @see #setSubtitle(CharSequence) + */ + public abstract void setCustomView(View view); + + /** + * Invalidate the action mode and refresh menu content. The mode's + * {@link ActionMode.Callback} will have its + * {@link Callback#onPrepareActionMode(ActionMode, Menu)} method called. + * If it returns true the menu will be scanned for updated content and any relevant changes + * will be reflected to the user. + */ + public abstract void invalidate(); + + /** + * Finish and close this action mode. The action mode's {@link ActionMode.Callback} will + * have its {@link Callback#onDestroyActionMode(ActionMode)} method called. + */ + public abstract void finish(); + + /** + * Returns the menu of actions that this action mode presents. + * @return The action mode's menu. + */ + public abstract Menu getMenu(); + + /** + * Returns the current title of this action mode. + * @return Title text + */ + public abstract CharSequence getTitle(); + + /** + * Returns the current subtitle of this action mode. + * @return Subtitle text + */ + public abstract CharSequence getSubtitle(); + + /** + * Returns the current custom view for this action mode. + * @return The current custom view + */ + public abstract View getCustomView(); + + /** + * Returns a {@link MenuInflater} with the ActionMode's context. + */ + public abstract MenuInflater getMenuInflater(); + + /** + * Returns whether the UI presenting this action mode can take focus or not. + * This is used by internal components within the framework that would otherwise + * present an action mode UI that requires focus, such as an EditText as a custom view. + * + * @return true if the UI used to show this action mode can take focus + * @hide Internal use only + */ + public boolean isUiFocusable() { + return true; + } + + /** + * Callback interface for action modes. Supplied to + * {@link View#startActionMode(Callback)}, a Callback + * configures and handles events raised by a user's interaction with an action mode. + * + *

An action mode's lifecycle is as follows: + *

    + *
  • {@link Callback#onCreateActionMode(ActionMode, Menu)} once on initial + * creation
  • + *
  • {@link Callback#onPrepareActionMode(ActionMode, Menu)} after creation + * and any time the {@link ActionMode} is invalidated
  • + *
  • {@link Callback#onActionItemClicked(ActionMode, MenuItem)} any time a + * contextual action button is clicked
  • + *
  • {@link Callback#onDestroyActionMode(ActionMode)} when the action mode + * is closed
  • + *
+ */ + public interface Callback { + /** + * Called when action mode is first created. The menu supplied will be used to + * generate action buttons for the action mode. + * + * @param mode ActionMode being created + * @param menu Menu used to populate action buttons + * @return true if the action mode should be created, false if entering this + * mode should be aborted. + */ + public boolean onCreateActionMode(ActionMode mode, Menu menu); + + /** + * Called to refresh an action mode's action menu whenever it is invalidated. + * + * @param mode ActionMode being prepared + * @param menu Menu used to populate action buttons + * @return true if the menu or action mode was updated, false otherwise. + */ + public boolean onPrepareActionMode(ActionMode mode, Menu menu); + + /** + * Called to report a user click on an action button. + * + * @param mode The current ActionMode + * @param item The item that was clicked + * @return true if this callback handled the event, false if the standard MenuItem + * invocation should continue. + */ + public boolean onActionItemClicked(ActionMode mode, MenuItem item); + + /** + * Called when an action mode is about to be exited and destroyed. + * + * @param mode The current ActionMode being destroyed + */ + public void onDestroyActionMode(ActionMode mode); + } +} \ No newline at end of file diff --git a/actionbarsherlock/src/com/actionbarsherlock/view/ActionProvider.java b/actionbarsherlock/src/com/actionbarsherlock/view/ActionProvider.java new file mode 100644 index 000000000..ae7cb1fe0 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/view/ActionProvider.java @@ -0,0 +1,170 @@ +/* + * Copyright (C) 2011 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.actionbarsherlock.view; + +import android.content.Context; +import android.view.View; + +/** + * This class is a mediator for accomplishing a given task, for example sharing a file. + * It is responsible for creating a view that performs an action that accomplishes the task. + * This class also implements other functions such a performing a default action. + *

+ * An ActionProvider can be optionally specified for a {@link MenuItem} and in such a + * case it will be responsible for creating the action view that appears in the + * {@link android.app.ActionBar} as a substitute for the menu item when the item is + * displayed as an action item. Also the provider is responsible for performing a + * default action if a menu item placed on the overflow menu of the ActionBar is + * selected and none of the menu item callbacks has handled the selection. For this + * case the provider can also optionally provide a sub-menu for accomplishing the + * task at hand. + *

+ *

+ * There are two ways for using an action provider for creating and handling of action views: + *

    + *
  • + * Setting the action provider on a {@link MenuItem} directly by calling + * {@link MenuItem#setActionProvider(ActionProvider)}. + *
  • + *
  • + * Declaring the action provider in the menu XML resource. For example: + *
    + * 
    + *   <item android:id="@+id/my_menu_item"
    + *     android:title="Title"
    + *     android:icon="@drawable/my_menu_item_icon"
    + *     android:showAsAction="ifRoom"
    + *     android:actionProviderClass="foo.bar.SomeActionProvider" />
    + * 
    + * 
    + *
  • + *
+ *

+ * + * @see MenuItem#setActionProvider(ActionProvider) + * @see MenuItem#getActionProvider() + */ +public abstract class ActionProvider { + private SubUiVisibilityListener mSubUiVisibilityListener; + + /** + * Creates a new instance. + * + * @param context Context for accessing resources. + */ + public ActionProvider(Context context) { + } + + /** + * Factory method for creating new action views. + * + * @return A new action view. + */ + public abstract View onCreateActionView(); + + /** + * Performs an optional default action. + *

+ * For the case of an action provider placed in a menu item not shown as an action this + * method is invoked if previous callbacks for processing menu selection has handled + * the event. + *

+ *

+ * A menu item selection is processed in the following order: + *

    + *
  • + * Receiving a call to {@link MenuItem.OnMenuItemClickListener#onMenuItemClick + * MenuItem.OnMenuItemClickListener.onMenuItemClick}. + *
  • + *
  • + * Receiving a call to {@link android.app.Activity#onOptionsItemSelected(MenuItem) + * Activity.onOptionsItemSelected(MenuItem)} + *
  • + *
  • + * Receiving a call to {@link android.app.Fragment#onOptionsItemSelected(MenuItem) + * Fragment.onOptionsItemSelected(MenuItem)} + *
  • + *
  • + * Launching the {@link android.content.Intent} set via + * {@link MenuItem#setIntent(android.content.Intent) MenuItem.setIntent(android.content.Intent)} + *
  • + *
  • + * Invoking this method. + *
  • + *
+ *

+ *

+ * The default implementation does not perform any action and returns false. + *

+ */ + public boolean onPerformDefaultAction() { + return false; + } + + /** + * Determines if this ActionProvider has a submenu associated with it. + * + *

Associated submenus will be shown when an action view is not. This + * provider instance will receive a call to {@link #onPrepareSubMenu(SubMenu)} + * after the call to {@link #onPerformDefaultAction()} and before a submenu is + * displayed to the user. + * + * @return true if the item backed by this provider should have an associated submenu + */ + public boolean hasSubMenu() { + return false; + } + + /** + * Called to prepare an associated submenu for the menu item backed by this ActionProvider. + * + *

if {@link #hasSubMenu()} returns true, this method will be called when the + * menu item is selected to prepare the submenu for presentation to the user. Apps + * may use this to create or alter submenu content right before display. + * + * @param subMenu Submenu that will be displayed + */ + public void onPrepareSubMenu(SubMenu subMenu) { + } + + /** + * Notify the system that the visibility of an action view's sub-UI such as + * an anchored popup has changed. This will affect how other system + * visibility notifications occur. + * + * @hide Pending future API approval + */ + public void subUiVisibilityChanged(boolean isVisible) { + if (mSubUiVisibilityListener != null) { + mSubUiVisibilityListener.onSubUiVisibilityChanged(isVisible); + } + } + + /** + * @hide Internal use only + */ + public void setSubUiVisibilityListener(SubUiVisibilityListener listener) { + mSubUiVisibilityListener = listener; + } + + /** + * @hide Internal use only + */ + public interface SubUiVisibilityListener { + public void onSubUiVisibilityChanged(boolean isVisible); + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/view/CollapsibleActionView.java b/actionbarsherlock/src/com/actionbarsherlock/view/CollapsibleActionView.java new file mode 100644 index 000000000..43281b013 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/view/CollapsibleActionView.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2011 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.actionbarsherlock.view; + +/** + * When a {@link View} implements this interface it will receive callbacks + * when expanded or collapsed as an action view alongside the optional, + * app-specified callbacks to {@link OnActionExpandListener}. + * + *

See {@link MenuItem} for more information about action views. + * See {@link android.app.ActionBar} for more information about the action bar. + */ +public interface CollapsibleActionView { + /** + * Called when this view is expanded as an action view. + * See {@link MenuItem#expandActionView()}. + */ + public void onActionViewExpanded(); + + /** + * Called when this view is collapsed as an action view. + * See {@link MenuItem#collapseActionView()}. + */ + public void onActionViewCollapsed(); +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/view/Menu.java b/actionbarsherlock/src/com/actionbarsherlock/view/Menu.java new file mode 100644 index 000000000..951f4ccef --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/view/Menu.java @@ -0,0 +1,447 @@ +/* + * Copyright (C) 2006 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.actionbarsherlock.view; + +import android.content.ComponentName; +import android.content.Intent; +import android.view.KeyEvent; + +/** + * Interface for managing the items in a menu. + *

+ * By default, every Activity supports an options menu of actions or options. + * You can add items to this menu and handle clicks on your additions. The + * easiest way of adding menu items is inflating an XML file into the + * {@link Menu} via {@link MenuInflater}. The easiest way of attaching code to + * clicks is via {@link Activity#onOptionsItemSelected(MenuItem)} and + * {@link Activity#onContextItemSelected(MenuItem)}. + *

+ * Different menu types support different features: + *

    + *
  1. Context menus: Do not support item shortcuts and item icons. + *
  2. Options menus: The icon menus do not support item check + * marks and only show the item's + * {@link MenuItem#setTitleCondensed(CharSequence) condensed title}. The + * expanded menus (only available if six or more menu items are visible, + * reached via the 'More' item in the icon menu) do not show item icons, and + * item check marks are discouraged. + *
  3. Sub menus: Do not support item icons, or nested sub menus. + *
+ * + *
+ *

Developer Guides

+ *

For more information about creating menus, read the + * Menus developer guide.

+ *
+ */ +public interface Menu { + + /** + * This is the part of an order integer that the user can provide. + * @hide + */ + static final int USER_MASK = 0x0000ffff; + /** + * Bit shift of the user portion of the order integer. + * @hide + */ + static final int USER_SHIFT = 0; + + /** + * This is the part of an order integer that supplies the category of the + * item. + * @hide + */ + static final int CATEGORY_MASK = 0xffff0000; + /** + * Bit shift of the category portion of the order integer. + * @hide + */ + static final int CATEGORY_SHIFT = 16; + + /** + * Value to use for group and item identifier integers when you don't care + * about them. + */ + static final int NONE = 0; + + /** + * First value for group and item identifier integers. + */ + static final int FIRST = 1; + + // Implementation note: Keep these CATEGORY_* in sync with the category enum + // in attrs.xml + + /** + * Category code for the order integer for items/groups that are part of a + * container -- or/add this with your base value. + */ + static final int CATEGORY_CONTAINER = 0x00010000; + + /** + * Category code for the order integer for items/groups that are provided by + * the system -- or/add this with your base value. + */ + static final int CATEGORY_SYSTEM = 0x00020000; + + /** + * Category code for the order integer for items/groups that are + * user-supplied secondary (infrequently used) options -- or/add this with + * your base value. + */ + static final int CATEGORY_SECONDARY = 0x00030000; + + /** + * Category code for the order integer for items/groups that are + * alternative actions on the data that is currently displayed -- or/add + * this with your base value. + */ + static final int CATEGORY_ALTERNATIVE = 0x00040000; + + /** + * Flag for {@link #addIntentOptions}: if set, do not automatically remove + * any existing menu items in the same group. + */ + static final int FLAG_APPEND_TO_GROUP = 0x0001; + + /** + * Flag for {@link #performShortcut}: if set, do not close the menu after + * executing the shortcut. + */ + static final int FLAG_PERFORM_NO_CLOSE = 0x0001; + + /** + * Flag for {@link #performShortcut(int, KeyEvent, int)}: if set, always + * close the menu after executing the shortcut. Closing the menu also resets + * the prepared state. + */ + static final int FLAG_ALWAYS_PERFORM_CLOSE = 0x0002; + + /** + * Add a new item to the menu. This item displays the given title for its + * label. + * + * @param title The text to display for the item. + * @return The newly added menu item. + */ + public MenuItem add(CharSequence title); + + /** + * Add a new item to the menu. This item displays the given title for its + * label. + * + * @param titleRes Resource identifier of title string. + * @return The newly added menu item. + */ + public MenuItem add(int titleRes); + + /** + * Add a new item to the menu. This item displays the given title for its + * label. + * + * @param groupId The group identifier that this item should be part of. + * This can be used to define groups of items for batch state + * changes. Normally use {@link #NONE} if an item should not be in a + * group. + * @param itemId Unique item ID. Use {@link #NONE} if you do not need a + * unique ID. + * @param order The order for the item. Use {@link #NONE} if you do not care + * about the order. See {@link MenuItem#getOrder()}. + * @param title The text to display for the item. + * @return The newly added menu item. + */ + public MenuItem add(int groupId, int itemId, int order, CharSequence title); + + /** + * Variation on {@link #add(int, int, int, CharSequence)} that takes a + * string resource identifier instead of the string itself. + * + * @param groupId The group identifier that this item should be part of. + * This can also be used to define groups of items for batch state + * changes. Normally use {@link #NONE} if an item should not be in a + * group. + * @param itemId Unique item ID. Use {@link #NONE} if you do not need a + * unique ID. + * @param order The order for the item. Use {@link #NONE} if you do not care + * about the order. See {@link MenuItem#getOrder()}. + * @param titleRes Resource identifier of title string. + * @return The newly added menu item. + */ + public MenuItem add(int groupId, int itemId, int order, int titleRes); + + /** + * Add a new sub-menu to the menu. This item displays the given title for + * its label. To modify other attributes on the submenu's menu item, use + * {@link SubMenu#getItem()}. + * + * @param title The text to display for the item. + * @return The newly added sub-menu + */ + SubMenu addSubMenu(final CharSequence title); + + /** + * Add a new sub-menu to the menu. This item displays the given title for + * its label. To modify other attributes on the submenu's menu item, use + * {@link SubMenu#getItem()}. + * + * @param titleRes Resource identifier of title string. + * @return The newly added sub-menu + */ + SubMenu addSubMenu(final int titleRes); + + /** + * Add a new sub-menu to the menu. This item displays the given + * title for its label. To modify other attributes on the + * submenu's menu item, use {@link SubMenu#getItem()}. + *

+ * Note that you can only have one level of sub-menus, i.e. you cannnot add + * a subMenu to a subMenu: An {@link UnsupportedOperationException} will be + * thrown if you try. + * + * @param groupId The group identifier that this item should be part of. + * This can also be used to define groups of items for batch state + * changes. Normally use {@link #NONE} if an item should not be in a + * group. + * @param itemId Unique item ID. Use {@link #NONE} if you do not need a + * unique ID. + * @param order The order for the item. Use {@link #NONE} if you do not care + * about the order. See {@link MenuItem#getOrder()}. + * @param title The text to display for the item. + * @return The newly added sub-menu + */ + SubMenu addSubMenu(final int groupId, final int itemId, int order, final CharSequence title); + + /** + * Variation on {@link #addSubMenu(int, int, int, CharSequence)} that takes + * a string resource identifier for the title instead of the string itself. + * + * @param groupId The group identifier that this item should be part of. + * This can also be used to define groups of items for batch state + * changes. Normally use {@link #NONE} if an item should not be in a group. + * @param itemId Unique item ID. Use {@link #NONE} if you do not need a unique ID. + * @param order The order for the item. Use {@link #NONE} if you do not care about the + * order. See {@link MenuItem#getOrder()}. + * @param titleRes Resource identifier of title string. + * @return The newly added sub-menu + */ + SubMenu addSubMenu(int groupId, int itemId, int order, int titleRes); + + /** + * Add a group of menu items corresponding to actions that can be performed + * for a particular Intent. The Intent is most often configured with a null + * action, the data that the current activity is working with, and includes + * either the {@link Intent#CATEGORY_ALTERNATIVE} or + * {@link Intent#CATEGORY_SELECTED_ALTERNATIVE} to find activities that have + * said they would like to be included as optional action. You can, however, + * use any Intent you want. + * + *

+ * See {@link android.content.pm.PackageManager#queryIntentActivityOptions} + * for more * details on the caller, specifics, and + * intent arguments. The list returned by that function is used + * to populate the resulting menu items. + * + *

+ * All of the menu items of possible options for the intent will be added + * with the given group and id. You can use the group to control ordering of + * the items in relation to other items in the menu. Normally this function + * will automatically remove any existing items in the menu in the same + * group and place a divider above and below the added items; this behavior + * can be modified with the flags parameter. For each of the + * generated items {@link MenuItem#setIntent} is called to associate the + * appropriate Intent with the item; this means the activity will + * automatically be started for you without having to do anything else. + * + * @param groupId The group identifier that the items should be part of. + * This can also be used to define groups of items for batch state + * changes. Normally use {@link #NONE} if the items should not be in + * a group. + * @param itemId Unique item ID. Use {@link #NONE} if you do not need a + * unique ID. + * @param order The order for the items. Use {@link #NONE} if you do not + * care about the order. See {@link MenuItem#getOrder()}. + * @param caller The current activity component name as defined by + * queryIntentActivityOptions(). + * @param specifics Specific items to place first as defined by + * queryIntentActivityOptions(). + * @param intent Intent describing the kinds of items to populate in the + * list as defined by queryIntentActivityOptions(). + * @param flags Additional options controlling how the items are added. + * @param outSpecificItems Optional array in which to place the menu items + * that were generated for each of the specifics that were + * requested. Entries may be null if no activity was found for that + * specific action. + * @return The number of menu items that were added. + * + * @see #FLAG_APPEND_TO_GROUP + * @see MenuItem#setIntent + * @see android.content.pm.PackageManager#queryIntentActivityOptions + */ + public int addIntentOptions(int groupId, int itemId, int order, + ComponentName caller, Intent[] specifics, + Intent intent, int flags, MenuItem[] outSpecificItems); + + /** + * Remove the item with the given identifier. + * + * @param id The item to be removed. If there is no item with this + * identifier, nothing happens. + */ + public void removeItem(int id); + + /** + * Remove all items in the given group. + * + * @param groupId The group to be removed. If there are no items in this + * group, nothing happens. + */ + public void removeGroup(int groupId); + + /** + * Remove all existing items from the menu, leaving it empty as if it had + * just been created. + */ + public void clear(); + + /** + * Control whether a particular group of items can show a check mark. This + * is similar to calling {@link MenuItem#setCheckable} on all of the menu items + * with the given group identifier, but in addition you can control whether + * this group contains a mutually-exclusive set items. This should be called + * after the items of the group have been added to the menu. + * + * @param group The group of items to operate on. + * @param checkable Set to true to allow a check mark, false to + * disallow. The default is false. + * @param exclusive If set to true, only one item in this group can be + * checked at a time; checking an item will automatically + * uncheck all others in the group. If set to false, each + * item can be checked independently of the others. + * + * @see MenuItem#setCheckable + * @see MenuItem#setChecked + */ + public void setGroupCheckable(int group, boolean checkable, boolean exclusive); + + /** + * Show or hide all menu items that are in the given group. + * + * @param group The group of items to operate on. + * @param visible If true the items are visible, else they are hidden. + * + * @see MenuItem#setVisible + */ + public void setGroupVisible(int group, boolean visible); + + /** + * Enable or disable all menu items that are in the given group. + * + * @param group The group of items to operate on. + * @param enabled If true the items will be enabled, else they will be disabled. + * + * @see MenuItem#setEnabled + */ + public void setGroupEnabled(int group, boolean enabled); + + /** + * Return whether the menu currently has item items that are visible. + * + * @return True if there is one or more item visible, + * else false. + */ + public boolean hasVisibleItems(); + + /** + * Return the menu item with a particular identifier. + * + * @param id The identifier to find. + * + * @return The menu item object, or null if there is no item with + * this identifier. + */ + public MenuItem findItem(int id); + + /** + * Get the number of items in the menu. Note that this will change any + * times items are added or removed from the menu. + * + * @return The item count. + */ + public int size(); + + /** + * Gets the menu item at the given index. + * + * @param index The index of the menu item to return. + * @return The menu item. + * @exception IndexOutOfBoundsException + * when {@code index < 0 || >= size()} + */ + public MenuItem getItem(int index); + + /** + * Closes the menu, if open. + */ + public void close(); + + /** + * Execute the menu item action associated with the given shortcut + * character. + * + * @param keyCode The keycode of the shortcut key. + * @param event Key event message. + * @param flags Additional option flags or 0. + * + * @return If the given shortcut exists and is shown, returns + * true; else returns false. + * + * @see #FLAG_PERFORM_NO_CLOSE + */ + public boolean performShortcut(int keyCode, KeyEvent event, int flags); + + /** + * Is a keypress one of the defined shortcut keys for this window. + * @param keyCode the key code from {@link KeyEvent} to check. + * @param event the {@link KeyEvent} to use to help check. + */ + boolean isShortcutKey(int keyCode, KeyEvent event); + + /** + * Execute the menu item action associated with the given menu identifier. + * + * @param id Identifier associated with the menu item. + * @param flags Additional option flags or 0. + * + * @return If the given identifier exists and is shown, returns + * true; else returns false. + * + * @see #FLAG_PERFORM_NO_CLOSE + */ + public boolean performIdentifierAction(int id, int flags); + + + /** + * Control whether the menu should be running in qwerty mode (alphabetic + * shortcuts) or 12-key mode (numeric shortcuts). + * + * @param isQwerty If true the menu will use alphabetic shortcuts; else it + * will use numeric shortcuts. + */ + public void setQwertyMode(boolean isQwerty); +} + diff --git a/actionbarsherlock/src/com/actionbarsherlock/view/MenuInflater.java b/actionbarsherlock/src/com/actionbarsherlock/view/MenuInflater.java new file mode 100644 index 000000000..969459749 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/view/MenuInflater.java @@ -0,0 +1,472 @@ +/* + * Copyright (C) 2006 The Android Open Source Project + * 2011 Jake Wharton + * + * 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.actionbarsherlock.view; + +import java.io.IOException; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; +import android.content.Context; +import android.content.res.TypedArray; +import android.content.res.XmlResourceParser; +import android.util.AttributeSet; +import android.util.Log; +import android.util.TypedValue; +import android.util.Xml; +import android.view.InflateException; +import android.view.View; + +import com.actionbarsherlock.R; +import com.actionbarsherlock.internal.view.menu.MenuItemImpl; + +/** + * This class is used to instantiate menu XML files into Menu objects. + *

+ * For performance reasons, menu inflation relies heavily on pre-processing of + * XML files that is done at build time. Therefore, it is not currently possible + * to use MenuInflater with an XmlPullParser over a plain XML file at runtime; + * it only works with an XmlPullParser returned from a compiled resource (R. + * something file.) + */ +public class MenuInflater { + private static final String LOG_TAG = "MenuInflater"; + + /** Menu tag name in XML. */ + private static final String XML_MENU = "menu"; + + /** Group tag name in XML. */ + private static final String XML_GROUP = "group"; + + /** Item tag name in XML. */ + private static final String XML_ITEM = "item"; + + private static final int NO_ID = 0; + + private static final Class[] ACTION_VIEW_CONSTRUCTOR_SIGNATURE = new Class[] {Context.class}; + + private static final Class[] ACTION_PROVIDER_CONSTRUCTOR_SIGNATURE = ACTION_VIEW_CONSTRUCTOR_SIGNATURE; + + private final Object[] mActionViewConstructorArguments; + + private final Object[] mActionProviderConstructorArguments; + + private Context mContext; + + /** + * Constructs a menu inflater. + * + * @see Activity#getMenuInflater() + */ + public MenuInflater(Context context) { + mContext = context; + mActionViewConstructorArguments = new Object[] {context}; + mActionProviderConstructorArguments = mActionViewConstructorArguments; + } + + /** + * Inflate a menu hierarchy from the specified XML resource. Throws + * {@link InflateException} if there is an error. + * + * @param menuRes Resource ID for an XML layout resource to load (e.g., + * R.menu.main_activity) + * @param menu The Menu to inflate into. The items and submenus will be + * added to this Menu. + */ + public void inflate(int menuRes, Menu menu) { + XmlResourceParser parser = null; + try { + parser = mContext.getResources().getLayout(menuRes); + AttributeSet attrs = Xml.asAttributeSet(parser); + + parseMenu(parser, attrs, menu); + } catch (XmlPullParserException e) { + throw new InflateException("Error inflating menu XML", e); + } catch (IOException e) { + throw new InflateException("Error inflating menu XML", e); + } finally { + if (parser != null) parser.close(); + } + } + + /** + * Called internally to fill the given menu. If a sub menu is seen, it will + * call this recursively. + */ + private void parseMenu(XmlPullParser parser, AttributeSet attrs, Menu menu) + throws XmlPullParserException, IOException { + MenuState menuState = new MenuState(menu); + + int eventType = parser.getEventType(); + String tagName; + boolean lookingForEndOfUnknownTag = false; + String unknownTagName = null; + + // This loop will skip to the menu start tag + do { + if (eventType == XmlPullParser.START_TAG) { + tagName = parser.getName(); + if (tagName.equals(XML_MENU)) { + // Go to next tag + eventType = parser.next(); + break; + } + + throw new RuntimeException("Expecting menu, got " + tagName); + } + eventType = parser.next(); + } while (eventType != XmlPullParser.END_DOCUMENT); + + boolean reachedEndOfMenu = false; + while (!reachedEndOfMenu) { + switch (eventType) { + case XmlPullParser.START_TAG: + if (lookingForEndOfUnknownTag) { + break; + } + + tagName = parser.getName(); + if (tagName.equals(XML_GROUP)) { + menuState.readGroup(attrs); + } else if (tagName.equals(XML_ITEM)) { + menuState.readItem(attrs); + } else if (tagName.equals(XML_MENU)) { + // A menu start tag denotes a submenu for an item + SubMenu subMenu = menuState.addSubMenuItem(); + + // Parse the submenu into returned SubMenu + parseMenu(parser, attrs, subMenu); + } else { + lookingForEndOfUnknownTag = true; + unknownTagName = tagName; + } + break; + + case XmlPullParser.END_TAG: + tagName = parser.getName(); + if (lookingForEndOfUnknownTag && tagName.equals(unknownTagName)) { + lookingForEndOfUnknownTag = false; + unknownTagName = null; + } else if (tagName.equals(XML_GROUP)) { + menuState.resetGroup(); + } else if (tagName.equals(XML_ITEM)) { + // Add the item if it hasn't been added (if the item was + // a submenu, it would have been added already) + if (!menuState.hasAddedItem()) { + if (menuState.itemActionProvider != null && + menuState.itemActionProvider.hasSubMenu()) { + menuState.addSubMenuItem(); + } else { + menuState.addItem(); + } + } + } else if (tagName.equals(XML_MENU)) { + reachedEndOfMenu = true; + } + break; + + case XmlPullParser.END_DOCUMENT: + throw new RuntimeException("Unexpected end of document"); + } + + eventType = parser.next(); + } + } + + private static class InflatedOnMenuItemClickListener + implements MenuItem.OnMenuItemClickListener { + private static final Class[] PARAM_TYPES = new Class[] { MenuItem.class }; + + private Context mContext; + private Method mMethod; + + public InflatedOnMenuItemClickListener(Context context, String methodName) { + mContext = context; + Class c = context.getClass(); + try { + mMethod = c.getMethod(methodName, PARAM_TYPES); + } catch (Exception e) { + InflateException ex = new InflateException( + "Couldn't resolve menu item onClick handler " + methodName + + " in class " + c.getName()); + ex.initCause(e); + throw ex; + } + } + + public boolean onMenuItemClick(MenuItem item) { + try { + if (mMethod.getReturnType() == Boolean.TYPE) { + return (Boolean) mMethod.invoke(mContext, item); + } else { + mMethod.invoke(mContext, item); + return true; + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + + /** + * State for the current menu. + *

+ * Groups can not be nested unless there is another menu (which will have + * its state class). + */ + private class MenuState { + private Menu menu; + + /* + * Group state is set on items as they are added, allowing an item to + * override its group state. (As opposed to set on items at the group end tag.) + */ + private int groupId; + private int groupCategory; + private int groupOrder; + private int groupCheckable; + private boolean groupVisible; + private boolean groupEnabled; + + private boolean itemAdded; + private int itemId; + private int itemCategoryOrder; + private CharSequence itemTitle; + private CharSequence itemTitleCondensed; + private int itemIconResId; + private char itemAlphabeticShortcut; + private char itemNumericShortcut; + /** + * Sync to attrs.xml enum: + * - 0: none + * - 1: all + * - 2: exclusive + */ + private int itemCheckable; + private boolean itemChecked; + private boolean itemVisible; + private boolean itemEnabled; + + /** + * Sync to attrs.xml enum, values in MenuItem: + * - 0: never + * - 1: ifRoom + * - 2: always + * - -1: Safe sentinel for "no value". + */ + private int itemShowAsAction; + + private int itemActionViewLayout; + private String itemActionViewClassName; + private String itemActionProviderClassName; + + private String itemListenerMethodName; + + private ActionProvider itemActionProvider; + + private static final int defaultGroupId = NO_ID; + private static final int defaultItemId = NO_ID; + private static final int defaultItemCategory = 0; + private static final int defaultItemOrder = 0; + private static final int defaultItemCheckable = 0; + private static final boolean defaultItemChecked = false; + private static final boolean defaultItemVisible = true; + private static final boolean defaultItemEnabled = true; + + public MenuState(final Menu menu) { + this.menu = menu; + + resetGroup(); + } + + public void resetGroup() { + groupId = defaultGroupId; + groupCategory = defaultItemCategory; + groupOrder = defaultItemOrder; + groupCheckable = defaultItemCheckable; + groupVisible = defaultItemVisible; + groupEnabled = defaultItemEnabled; + } + + /** + * Called when the parser is pointing to a group tag. + */ + public void readGroup(AttributeSet attrs) { + TypedArray a = mContext.obtainStyledAttributes(attrs, + R.styleable.SherlockMenuGroup); + + groupId = a.getResourceId(R.styleable.SherlockMenuGroup_android_id, defaultGroupId); + groupCategory = a.getInt(R.styleable.SherlockMenuGroup_android_menuCategory, defaultItemCategory); + groupOrder = a.getInt(R.styleable.SherlockMenuGroup_android_orderInCategory, defaultItemOrder); + groupCheckable = a.getInt(R.styleable.SherlockMenuGroup_android_checkableBehavior, defaultItemCheckable); + groupVisible = a.getBoolean(R.styleable.SherlockMenuGroup_android_visible, defaultItemVisible); + groupEnabled = a.getBoolean(R.styleable.SherlockMenuGroup_android_enabled, defaultItemEnabled); + + a.recycle(); + } + + /** + * Called when the parser is pointing to an item tag. + */ + public void readItem(AttributeSet attrs) { + TypedArray a = mContext.obtainStyledAttributes(attrs, + R.styleable.SherlockMenuItem); + + // Inherit attributes from the group as default value + itemId = a.getResourceId(R.styleable.SherlockMenuItem_android_id, defaultItemId); + final int category = a.getInt(R.styleable.SherlockMenuItem_android_menuCategory, groupCategory); + final int order = a.getInt(R.styleable.SherlockMenuItem_android_orderInCategory, groupOrder); + itemCategoryOrder = (category & Menu.CATEGORY_MASK) | (order & Menu.USER_MASK); + itemTitle = a.getText(R.styleable.SherlockMenuItem_android_title); + itemTitleCondensed = a.getText(R.styleable.SherlockMenuItem_android_titleCondensed); + itemIconResId = a.getResourceId(R.styleable.SherlockMenuItem_android_icon, 0); + itemAlphabeticShortcut = + getShortcut(a.getString(R.styleable.SherlockMenuItem_android_alphabeticShortcut)); + itemNumericShortcut = + getShortcut(a.getString(R.styleable.SherlockMenuItem_android_numericShortcut)); + if (a.hasValue(R.styleable.SherlockMenuItem_android_checkable)) { + // Item has attribute checkable, use it + itemCheckable = a.getBoolean(R.styleable.SherlockMenuItem_android_checkable, false) ? 1 : 0; + } else { + // Item does not have attribute, use the group's (group can have one more state + // for checkable that represents the exclusive checkable) + itemCheckable = groupCheckable; + } + + itemChecked = a.getBoolean(R.styleable.SherlockMenuItem_android_checked, defaultItemChecked); + itemVisible = a.getBoolean(R.styleable.SherlockMenuItem_android_visible, groupVisible); + itemEnabled = a.getBoolean(R.styleable.SherlockMenuItem_android_enabled, groupEnabled); + + TypedValue value = new TypedValue(); + a.getValue(R.styleable.SherlockMenuItem_android_showAsAction, value); + itemShowAsAction = value.type == TypedValue.TYPE_INT_HEX ? value.data : -1; + + itemListenerMethodName = a.getString(R.styleable.SherlockMenuItem_android_onClick); + itemActionViewLayout = a.getResourceId(R.styleable.SherlockMenuItem_android_actionLayout, 0); + itemActionViewClassName = a.getString(R.styleable.SherlockMenuItem_android_actionViewClass); + itemActionProviderClassName = a.getString(R.styleable.SherlockMenuItem_android_actionProviderClass); + + final boolean hasActionProvider = itemActionProviderClassName != null; + if (hasActionProvider && itemActionViewLayout == 0 && itemActionViewClassName == null) { + itemActionProvider = newInstance(itemActionProviderClassName, + ACTION_PROVIDER_CONSTRUCTOR_SIGNATURE, + mActionProviderConstructorArguments); + } else { + if (hasActionProvider) { + Log.w(LOG_TAG, "Ignoring attribute 'actionProviderClass'." + + " Action view already specified."); + } + itemActionProvider = null; + } + + a.recycle(); + + itemAdded = false; + } + + private char getShortcut(String shortcutString) { + if (shortcutString == null) { + return 0; + } else { + return shortcutString.charAt(0); + } + } + + private void setItem(MenuItem item) { + item.setChecked(itemChecked) + .setVisible(itemVisible) + .setEnabled(itemEnabled) + .setCheckable(itemCheckable >= 1) + .setTitleCondensed(itemTitleCondensed) + .setIcon(itemIconResId) + .setAlphabeticShortcut(itemAlphabeticShortcut) + .setNumericShortcut(itemNumericShortcut); + + if (itemShowAsAction >= 0) { + item.setShowAsAction(itemShowAsAction); + } + + if (itemListenerMethodName != null) { + if (mContext.isRestricted()) { + throw new IllegalStateException("The android:onClick attribute cannot " + + "be used within a restricted context"); + } + item.setOnMenuItemClickListener( + new InflatedOnMenuItemClickListener(mContext, itemListenerMethodName)); + } + + if (itemCheckable >= 2) { + if (item instanceof MenuItemImpl) { + MenuItemImpl impl = (MenuItemImpl) item; + impl.setExclusiveCheckable(true); + } else { + menu.setGroupCheckable(groupId, true, true); + } + } + + boolean actionViewSpecified = false; + if (itemActionViewClassName != null) { + View actionView = (View) newInstance(itemActionViewClassName, + ACTION_VIEW_CONSTRUCTOR_SIGNATURE, mActionViewConstructorArguments); + item.setActionView(actionView); + actionViewSpecified = true; + } + if (itemActionViewLayout > 0) { + if (!actionViewSpecified) { + item.setActionView(itemActionViewLayout); + actionViewSpecified = true; + } else { + Log.w(LOG_TAG, "Ignoring attribute 'itemActionViewLayout'." + + " Action view already specified."); + } + } + if (itemActionProvider != null) { + item.setActionProvider(itemActionProvider); + } + } + + public void addItem() { + itemAdded = true; + setItem(menu.add(groupId, itemId, itemCategoryOrder, itemTitle)); + } + + public SubMenu addSubMenuItem() { + itemAdded = true; + SubMenu subMenu = menu.addSubMenu(groupId, itemId, itemCategoryOrder, itemTitle); + setItem(subMenu.getItem()); + return subMenu; + } + + public boolean hasAddedItem() { + return itemAdded; + } + + @SuppressWarnings("unchecked") + private T newInstance(String className, Class[] constructorSignature, + Object[] arguments) { + try { + Class clazz = mContext.getClassLoader().loadClass(className); + Constructor constructor = clazz.getConstructor(constructorSignature); + return (T) constructor.newInstance(arguments); + } catch (Exception e) { + Log.w(LOG_TAG, "Cannot instantiate class: " + className, e); + } + return null; + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/view/MenuItem.java b/actionbarsherlock/src/com/actionbarsherlock/view/MenuItem.java new file mode 100644 index 000000000..7fc3aa430 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/view/MenuItem.java @@ -0,0 +1,598 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.actionbarsherlock.view; + +import android.content.Intent; +import android.graphics.drawable.Drawable; +import android.view.ContextMenu.ContextMenuInfo; +import android.view.View; + +/** + * Interface for direct access to a previously created menu item. + *

+ * An Item is returned by calling one of the {@link android.view.Menu#add} + * methods. + *

+ * For a feature set of specific menu types, see {@link Menu}. + * + *

+ *

Developer Guides

+ *

For information about creating menus, read the + * Menus developer guide.

+ *
+ */ +public interface MenuItem { + /* + * These should be kept in sync with attrs.xml enum constants for showAsAction + */ + /** Never show this item as a button in an Action Bar. */ + public static final int SHOW_AS_ACTION_NEVER = android.view.MenuItem.SHOW_AS_ACTION_NEVER; + /** Show this item as a button in an Action Bar if the system decides there is room for it. */ + public static final int SHOW_AS_ACTION_IF_ROOM = android.view.MenuItem.SHOW_AS_ACTION_IF_ROOM; + /** + * Always show this item as a button in an Action Bar. + * Use sparingly! If too many items are set to always show in the Action Bar it can + * crowd the Action Bar and degrade the user experience on devices with smaller screens. + * A good rule of thumb is to have no more than 2 items set to always show at a time. + */ + public static final int SHOW_AS_ACTION_ALWAYS = android.view.MenuItem.SHOW_AS_ACTION_ALWAYS; + + /** + * When this item is in the action bar, always show it with a text label even if + * it also has an icon specified. + */ + public static final int SHOW_AS_ACTION_WITH_TEXT = android.view.MenuItem.SHOW_AS_ACTION_WITH_TEXT; + + /** + * This item's action view collapses to a normal menu item. + * When expanded, the action view temporarily takes over + * a larger segment of its container. + */ + public static final int SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW = android.view.MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW; + + /** + * Interface definition for a callback to be invoked when a menu item is + * clicked. + * + * @see Activity#onContextItemSelected(MenuItem) + * @see Activity#onOptionsItemSelected(MenuItem) + */ + public interface OnMenuItemClickListener { + /** + * Called when a menu item has been invoked. This is the first code + * that is executed; if it returns true, no other callbacks will be + * executed. + * + * @param item The menu item that was invoked. + * + * @return Return true to consume this click and prevent others from + * executing. + */ + public boolean onMenuItemClick(MenuItem item); + } + + /** + * Interface definition for a callback to be invoked when a menu item + * marked with {@link MenuItem#SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW} is + * expanded or collapsed. + * + * @see MenuItem#expandActionView() + * @see MenuItem#collapseActionView() + * @see MenuItem#setShowAsActionFlags(int) + */ + public interface OnActionExpandListener { + /** + * Called when a menu item with {@link MenuItem#SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW} + * is expanded. + * @param item Item that was expanded + * @return true if the item should expand, false if expansion should be suppressed. + */ + public boolean onMenuItemActionExpand(MenuItem item); + + /** + * Called when a menu item with {@link MenuItem#SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW} + * is collapsed. + * @param item Item that was collapsed + * @return true if the item should collapse, false if collapsing should be suppressed. + */ + public boolean onMenuItemActionCollapse(MenuItem item); + } + + /** + * Return the identifier for this menu item. The identifier can not + * be changed after the menu is created. + * + * @return The menu item's identifier. + */ + public int getItemId(); + + /** + * Return the group identifier that this menu item is part of. The group + * identifier can not be changed after the menu is created. + * + * @return The menu item's group identifier. + */ + public int getGroupId(); + + /** + * Return the category and order within the category of this item. This + * item will be shown before all items (within its category) that have + * order greater than this value. + *

+ * An order integer contains the item's category (the upper bits of the + * integer; set by or/add the category with the order within the + * category) and the ordering of the item within that category (the + * lower bits). Example categories are {@link Menu#CATEGORY_SYSTEM}, + * {@link Menu#CATEGORY_SECONDARY}, {@link Menu#CATEGORY_ALTERNATIVE}, + * {@link Menu#CATEGORY_CONTAINER}. See {@link Menu} for a full list. + * + * @return The order of this item. + */ + public int getOrder(); + + /** + * Change the title associated with this item. + * + * @param title The new text to be displayed. + * @return This Item so additional setters can be called. + */ + public MenuItem setTitle(CharSequence title); + + /** + * Change the title associated with this item. + *

+ * Some menu types do not sufficient space to show the full title, and + * instead a condensed title is preferred. See {@link Menu} for more + * information. + * + * @param title The resource id of the new text to be displayed. + * @return This Item so additional setters can be called. + * @see #setTitleCondensed(CharSequence) + */ + + public MenuItem setTitle(int title); + + /** + * Retrieve the current title of the item. + * + * @return The title. + */ + public CharSequence getTitle(); + + /** + * Change the condensed title associated with this item. The condensed + * title is used in situations where the normal title may be too long to + * be displayed. + * + * @param title The new text to be displayed as the condensed title. + * @return This Item so additional setters can be called. + */ + public MenuItem setTitleCondensed(CharSequence title); + + /** + * Retrieve the current condensed title of the item. If a condensed + * title was never set, it will return the normal title. + * + * @return The condensed title, if it exists. + * Otherwise the normal title. + */ + public CharSequence getTitleCondensed(); + + /** + * Change the icon associated with this item. This icon will not always be + * shown, so the title should be sufficient in describing this item. See + * {@link Menu} for the menu types that support icons. + * + * @param icon The new icon (as a Drawable) to be displayed. + * @return This Item so additional setters can be called. + */ + public MenuItem setIcon(Drawable icon); + + /** + * Change the icon associated with this item. This icon will not always be + * shown, so the title should be sufficient in describing this item. See + * {@link Menu} for the menu types that support icons. + *

+ * This method will set the resource ID of the icon which will be used to + * lazily get the Drawable when this item is being shown. + * + * @param iconRes The new icon (as a resource ID) to be displayed. + * @return This Item so additional setters can be called. + */ + public MenuItem setIcon(int iconRes); + + /** + * Returns the icon for this item as a Drawable (getting it from resources if it hasn't been + * loaded before). + * + * @return The icon as a Drawable. + */ + public Drawable getIcon(); + + /** + * Change the Intent associated with this item. By default there is no + * Intent associated with a menu item. If you set one, and nothing + * else handles the item, then the default behavior will be to call + * {@link android.content.Context#startActivity} with the given Intent. + * + *

Note that setIntent() can not be used with the versions of + * {@link Menu#add} that take a Runnable, because {@link Runnable#run} + * does not return a value so there is no way to tell if it handled the + * item. In this case it is assumed that the Runnable always handles + * the item, and the intent will never be started. + * + * @see #getIntent + * @param intent The Intent to associated with the item. This Intent + * object is not copied, so be careful not to + * modify it later. + * @return This Item so additional setters can be called. + */ + public MenuItem setIntent(Intent intent); + + /** + * Return the Intent associated with this item. This returns a + * reference to the Intent which you can change as desired to modify + * what the Item is holding. + * + * @see #setIntent + * @return Returns the last value supplied to {@link #setIntent}, or + * null. + */ + public Intent getIntent(); + + /** + * Change both the numeric and alphabetic shortcut associated with this + * item. Note that the shortcut will be triggered when the key that + * generates the given character is pressed alone or along with with the alt + * key. Also note that case is not significant and that alphabetic shortcut + * characters will be displayed in lower case. + *

+ * See {@link Menu} for the menu types that support shortcuts. + * + * @param numericChar The numeric shortcut key. This is the shortcut when + * using a numeric (e.g., 12-key) keyboard. + * @param alphaChar The alphabetic shortcut key. This is the shortcut when + * using a keyboard with alphabetic keys. + * @return This Item so additional setters can be called. + */ + public MenuItem setShortcut(char numericChar, char alphaChar); + + /** + * Change the numeric shortcut associated with this item. + *

+ * See {@link Menu} for the menu types that support shortcuts. + * + * @param numericChar The numeric shortcut key. This is the shortcut when + * using a 12-key (numeric) keyboard. + * @return This Item so additional setters can be called. + */ + public MenuItem setNumericShortcut(char numericChar); + + /** + * Return the char for this menu item's numeric (12-key) shortcut. + * + * @return Numeric character to use as a shortcut. + */ + public char getNumericShortcut(); + + /** + * Change the alphabetic shortcut associated with this item. The shortcut + * will be triggered when the key that generates the given character is + * pressed alone or along with with the alt key. Case is not significant and + * shortcut characters will be displayed in lower case. Note that menu items + * with the characters '\b' or '\n' as shortcuts will get triggered by the + * Delete key or Carriage Return key, respectively. + *

+ * See {@link Menu} for the menu types that support shortcuts. + * + * @param alphaChar The alphabetic shortcut key. This is the shortcut when + * using a keyboard with alphabetic keys. + * @return This Item so additional setters can be called. + */ + public MenuItem setAlphabeticShortcut(char alphaChar); + + /** + * Return the char for this menu item's alphabetic shortcut. + * + * @return Alphabetic character to use as a shortcut. + */ + public char getAlphabeticShortcut(); + + /** + * Control whether this item can display a check mark. Setting this does + * not actually display a check mark (see {@link #setChecked} for that); + * rather, it ensures there is room in the item in which to display a + * check mark. + *

+ * See {@link Menu} for the menu types that support check marks. + * + * @param checkable Set to true to allow a check mark, false to + * disallow. The default is false. + * @see #setChecked + * @see #isCheckable + * @see Menu#setGroupCheckable + * @return This Item so additional setters can be called. + */ + public MenuItem setCheckable(boolean checkable); + + /** + * Return whether the item can currently display a check mark. + * + * @return If a check mark can be displayed, returns true. + * + * @see #setCheckable + */ + public boolean isCheckable(); + + /** + * Control whether this item is shown with a check mark. Note that you + * must first have enabled checking with {@link #setCheckable} or else + * the check mark will not appear. If this item is a member of a group that contains + * mutually-exclusive items (set via {@link Menu#setGroupCheckable(int, boolean, boolean)}, + * the other items in the group will be unchecked. + *

+ * See {@link Menu} for the menu types that support check marks. + * + * @see #setCheckable + * @see #isChecked + * @see Menu#setGroupCheckable + * @param checked Set to true to display a check mark, false to hide + * it. The default value is false. + * @return This Item so additional setters can be called. + */ + public MenuItem setChecked(boolean checked); + + /** + * Return whether the item is currently displaying a check mark. + * + * @return If a check mark is displayed, returns true. + * + * @see #setChecked + */ + public boolean isChecked(); + + /** + * Sets the visibility of the menu item. Even if a menu item is not visible, + * it may still be invoked via its shortcut (to completely disable an item, + * set it to invisible and {@link #setEnabled(boolean) disabled}). + * + * @param visible If true then the item will be visible; if false it is + * hidden. + * @return This Item so additional setters can be called. + */ + public MenuItem setVisible(boolean visible); + + /** + * Return the visibility of the menu item. + * + * @return If true the item is visible; else it is hidden. + */ + public boolean isVisible(); + + /** + * Sets whether the menu item is enabled. Disabling a menu item will not + * allow it to be invoked via its shortcut. The menu item will still be + * visible. + * + * @param enabled If true then the item will be invokable; if false it is + * won't be invokable. + * @return This Item so additional setters can be called. + */ + public MenuItem setEnabled(boolean enabled); + + /** + * Return the enabled state of the menu item. + * + * @return If true the item is enabled and hence invokable; else it is not. + */ + public boolean isEnabled(); + + /** + * Check whether this item has an associated sub-menu. I.e. it is a + * sub-menu of another menu. + * + * @return If true this item has a menu; else it is a + * normal item. + */ + public boolean hasSubMenu(); + + /** + * Get the sub-menu to be invoked when this item is selected, if it has + * one. See {@link #hasSubMenu()}. + * + * @return The associated menu if there is one, else null + */ + public SubMenu getSubMenu(); + + /** + * Set a custom listener for invocation of this menu item. In most + * situations, it is more efficient and easier to use + * {@link Activity#onOptionsItemSelected(MenuItem)} or + * {@link Activity#onContextItemSelected(MenuItem)}. + * + * @param menuItemClickListener The object to receive invokations. + * @return This Item so additional setters can be called. + * @see Activity#onOptionsItemSelected(MenuItem) + * @see Activity#onContextItemSelected(MenuItem) + */ + public MenuItem setOnMenuItemClickListener(MenuItem.OnMenuItemClickListener menuItemClickListener); + + /** + * Gets the extra information linked to this menu item. This extra + * information is set by the View that added this menu item to the + * menu. + * + * @see OnCreateContextMenuListener + * @return The extra information linked to the View that added this + * menu item to the menu. This can be null. + */ + public ContextMenuInfo getMenuInfo(); + + /** + * Sets how this item should display in the presence of an Action Bar. + * The parameter actionEnum is a flag set. One of {@link #SHOW_AS_ACTION_ALWAYS}, + * {@link #SHOW_AS_ACTION_IF_ROOM}, or {@link #SHOW_AS_ACTION_NEVER} should + * be used, and you may optionally OR the value with {@link #SHOW_AS_ACTION_WITH_TEXT}. + * SHOW_AS_ACTION_WITH_TEXT requests that when the item is shown as an action, + * it should be shown with a text label. + * + * @param actionEnum How the item should display. One of + * {@link #SHOW_AS_ACTION_ALWAYS}, {@link #SHOW_AS_ACTION_IF_ROOM}, or + * {@link #SHOW_AS_ACTION_NEVER}. SHOW_AS_ACTION_NEVER is the default. + * + * @see android.app.ActionBar + * @see #setActionView(View) + */ + public void setShowAsAction(int actionEnum); + + /** + * Sets how this item should display in the presence of an Action Bar. + * The parameter actionEnum is a flag set. One of {@link #SHOW_AS_ACTION_ALWAYS}, + * {@link #SHOW_AS_ACTION_IF_ROOM}, or {@link #SHOW_AS_ACTION_NEVER} should + * be used, and you may optionally OR the value with {@link #SHOW_AS_ACTION_WITH_TEXT}. + * SHOW_AS_ACTION_WITH_TEXT requests that when the item is shown as an action, + * it should be shown with a text label. + * + *

Note: This method differs from {@link #setShowAsAction(int)} only in that it + * returns the current MenuItem instance for call chaining. + * + * @param actionEnum How the item should display. One of + * {@link #SHOW_AS_ACTION_ALWAYS}, {@link #SHOW_AS_ACTION_IF_ROOM}, or + * {@link #SHOW_AS_ACTION_NEVER}. SHOW_AS_ACTION_NEVER is the default. + * + * @see android.app.ActionBar + * @see #setActionView(View) + * @return This MenuItem instance for call chaining. + */ + public MenuItem setShowAsActionFlags(int actionEnum); + + /** + * Set an action view for this menu item. An action view will be displayed in place + * of an automatically generated menu item element in the UI when this item is shown + * as an action within a parent. + *

+ * Note: Setting an action view overrides the action provider + * set via {@link #setActionProvider(ActionProvider)}. + *

+ * + * @param view View to use for presenting this item to the user. + * @return This Item so additional setters can be called. + * + * @see #setShowAsAction(int) + */ + public MenuItem setActionView(View view); + + /** + * Set an action view for this menu item. An action view will be displayed in place + * of an automatically generated menu item element in the UI when this item is shown + * as an action within a parent. + *

+ * Note: Setting an action view overrides the action provider + * set via {@link #setActionProvider(ActionProvider)}. + *

+ * + * @param resId Layout resource to use for presenting this item to the user. + * @return This Item so additional setters can be called. + * + * @see #setShowAsAction(int) + */ + public MenuItem setActionView(int resId); + + /** + * Returns the currently set action view for this menu item. + * + * @return This item's action view + * + * @see #setActionView(View) + * @see #setShowAsAction(int) + */ + public View getActionView(); + + /** + * Sets the {@link ActionProvider} responsible for creating an action view if + * the item is placed on the action bar. The provider also provides a default + * action invoked if the item is placed in the overflow menu. + *

+ * Note: Setting an action provider overrides the action view + * set via {@link #setActionView(int)} or {@link #setActionView(View)}. + *

+ * + * @param actionProvider The action provider. + * @return This Item so additional setters can be called. + * + * @see ActionProvider + */ + public MenuItem setActionProvider(ActionProvider actionProvider); + + /** + * Gets the {@link ActionProvider}. + * + * @return The action provider. + * + * @see ActionProvider + * @see #setActionProvider(ActionProvider) + */ + public ActionProvider getActionProvider(); + + /** + * Expand the action view associated with this menu item. + * The menu item must have an action view set, as well as + * the showAsAction flag {@link #SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW}. + * If a listener has been set using {@link #setOnActionExpandListener(OnActionExpandListener)} + * it will have its {@link OnActionExpandListener#onMenuItemActionExpand(MenuItem)} + * method invoked. The listener may return false from this method to prevent expanding + * the action view. + * + * @return true if the action view was expanded, false otherwise. + */ + public boolean expandActionView(); + + /** + * Collapse the action view associated with this menu item. + * The menu item must have an action view set, as well as the showAsAction flag + * {@link #SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW}. If a listener has been set using + * {@link #setOnActionExpandListener(OnActionExpandListener)} it will have its + * {@link OnActionExpandListener#onMenuItemActionCollapse(MenuItem)} method invoked. + * The listener may return false from this method to prevent collapsing the action view. + * + * @return true if the action view was collapsed, false otherwise. + */ + public boolean collapseActionView(); + + /** + * Returns true if this menu item's action view has been expanded. + * + * @return true if the item's action view is expanded, false otherwise. + * + * @see #expandActionView() + * @see #collapseActionView() + * @see #SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW + * @see OnActionExpandListener + */ + public boolean isActionViewExpanded(); + + /** + * Set an {@link OnActionExpandListener} on this menu item to be notified when + * the associated action view is expanded or collapsed. The menu item must + * be configured to expand or collapse its action view using the flag + * {@link #SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW}. + * + * @param listener Listener that will respond to expand/collapse events + * @return This menu item instance for call chaining + */ + public MenuItem setOnActionExpandListener(OnActionExpandListener listener); +} \ No newline at end of file diff --git a/actionbarsherlock/src/com/actionbarsherlock/view/SubMenu.java b/actionbarsherlock/src/com/actionbarsherlock/view/SubMenu.java new file mode 100644 index 000000000..397fd1c2d --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/view/SubMenu.java @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2007 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.actionbarsherlock.view; + +import android.graphics.drawable.Drawable; +import android.view.View; + +/** + * Subclass of {@link Menu} for sub menus. + *

+ * Sub menus do not support item icons, or nested sub menus. + * + *

+ *

Developer Guides

+ *

For information about creating menus, read the + * Menus developer guide.

+ *
+ */ + +public interface SubMenu extends Menu { + /** + * Sets the submenu header's title to the title given in titleRes + * resource identifier. + * + * @param titleRes The string resource identifier used for the title. + * @return This SubMenu so additional setters can be called. + */ + public SubMenu setHeaderTitle(int titleRes); + + /** + * Sets the submenu header's title to the title given in title. + * + * @param title The character sequence used for the title. + * @return This SubMenu so additional setters can be called. + */ + public SubMenu setHeaderTitle(CharSequence title); + + /** + * Sets the submenu header's icon to the icon given in iconRes + * resource id. + * + * @param iconRes The resource identifier used for the icon. + * @return This SubMenu so additional setters can be called. + */ + public SubMenu setHeaderIcon(int iconRes); + + /** + * Sets the submenu header's icon to the icon given in icon + * {@link Drawable}. + * + * @param icon The {@link Drawable} used for the icon. + * @return This SubMenu so additional setters can be called. + */ + public SubMenu setHeaderIcon(Drawable icon); + + /** + * Sets the header of the submenu to the {@link View} given in + * view. This replaces the header title and icon (and those + * replace this). + * + * @param view The {@link View} used for the header. + * @return This SubMenu so additional setters can be called. + */ + public SubMenu setHeaderView(View view); + + /** + * Clears the header of the submenu. + */ + public void clearHeader(); + + /** + * Change the icon associated with this submenu's item in its parent menu. + * + * @see MenuItem#setIcon(int) + * @param iconRes The new icon (as a resource ID) to be displayed. + * @return This SubMenu so additional setters can be called. + */ + public SubMenu setIcon(int iconRes); + + /** + * Change the icon associated with this submenu's item in its parent menu. + * + * @see MenuItem#setIcon(Drawable) + * @param icon The new icon (as a Drawable) to be displayed. + * @return This SubMenu so additional setters can be called. + */ + public SubMenu setIcon(Drawable icon); + + /** + * Gets the {@link MenuItem} that represents this submenu in the parent + * menu. Use this for setting additional item attributes. + * + * @return The {@link MenuItem} that launches the submenu when invoked. + */ + public MenuItem getItem(); +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/view/Window.java b/actionbarsherlock/src/com/actionbarsherlock/view/Window.java new file mode 100644 index 000000000..a340a4291 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/view/Window.java @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2006 The Android Open Source Project + * Copyright (C) 2011 Jake Wharton + * + * 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.actionbarsherlock.view; + +import android.content.Context; + +/** + *

Abstract base class for a top-level window look and behavior policy. An + * instance of this class should be used as the top-level view added to the + * window manager. It provides standard UI policies such as a background, title + * area, default key processing, etc.

+ * + *

The only existing implementation of this abstract class is + * android.policy.PhoneWindow, which you should instantiate when needing a + * Window. Eventually that class will be refactored and a factory method added + * for creating Window instances without knowing about a particular + * implementation.

+ */ +public abstract class Window extends android.view.Window { + public static final long FEATURE_ACTION_BAR = android.view.Window.FEATURE_ACTION_BAR; + public static final long FEATURE_ACTION_BAR_OVERLAY = android.view.Window.FEATURE_ACTION_BAR_OVERLAY; + public static final long FEATURE_ACTION_MODE_OVERLAY = android.view.Window.FEATURE_ACTION_MODE_OVERLAY; + public static final long FEATURE_NO_TITLE = android.view.Window.FEATURE_NO_TITLE; + public static final long FEATURE_PROGRESS = android.view.Window.FEATURE_PROGRESS; + public static final long FEATURE_INDETERMINATE_PROGRESS = android.view.Window.FEATURE_INDETERMINATE_PROGRESS; + + /** + * Create a new instance for a context. + * + * @param context Context. + */ + private Window(Context context) { + super(context); + } + + + public interface Callback { + /** + * Called when a panel's menu item has been selected by the user. + * + * @param featureId The panel that the menu is in. + * @param item The menu item that was selected. + * + * @return boolean Return true to finish processing of selection, or + * false to perform the normal menu handling (calling its + * Runnable or sending a Message to its target Handler). + */ + public boolean onMenuItemSelected(int featureId, MenuItem item); + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/widget/ActivityChooserModel.java b/actionbarsherlock/src/com/actionbarsherlock/widget/ActivityChooserModel.java new file mode 100644 index 000000000..379207471 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/widget/ActivityChooserModel.java @@ -0,0 +1,1131 @@ +/* + * Copyright (C) 2011 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.actionbarsherlock.widget; + +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.pm.ResolveInfo; +import android.database.DataSetObservable; +import android.os.Handler; +import android.text.TextUtils; +import android.util.Log; +import android.util.Xml; + +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; +import org.xmlpull.v1.XmlSerializer; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.Executor; + +/** + *

+ * This class represents a data model for choosing a component for handing a + * given {@link Intent}. The model is responsible for querying the system for + * activities that can handle the given intent and order found activities + * based on historical data of previous choices. The historical data is stored + * in an application private file. If a client does not want to have persistent + * choice history the file can be omitted, thus the activities will be ordered + * based on historical usage for the current session. + *

+ *

+ * For each backing history file there is a singleton instance of this class. Thus, + * several clients that specify the same history file will share the same model. Note + * that if multiple clients are sharing the same model they should implement semantically + * equivalent functionality since setting the model intent will change the found + * activities and they may be inconsistent with the functionality of some of the clients. + * For example, choosing a share activity can be implemented by a single backing + * model and two different views for performing the selection. If however, one of the + * views is used for sharing but the other for importing, for example, then each + * view should be backed by a separate model. + *

+ *

+ * The way clients interact with this class is as follows: + *

+ *

+ *

+ * 
+ *  // Get a model and set it to a couple of clients with semantically similar function.
+ *  ActivityChooserModel dataModel =
+ *      ActivityChooserModel.get(context, "task_specific_history_file_name.xml");
+ *
+ *  ActivityChooserModelClient modelClient1 = getActivityChooserModelClient1();
+ *  modelClient1.setActivityChooserModel(dataModel);
+ *
+ *  ActivityChooserModelClient modelClient2 = getActivityChooserModelClient2();
+ *  modelClient2.setActivityChooserModel(dataModel);
+ *
+ *  // Set an intent to choose a an activity for.
+ *  dataModel.setIntent(intent);
+ * 
+ * 
+ * 

+ *

+ * Note: This class is thread safe. + *

+ * + * @hide + */ +class ActivityChooserModel extends DataSetObservable { + + /** + * Client that utilizes an {@link ActivityChooserModel}. + */ + public interface ActivityChooserModelClient { + + /** + * Sets the {@link ActivityChooserModel}. + * + * @param dataModel The model. + */ + public void setActivityChooserModel(ActivityChooserModel dataModel); + } + + /** + * Defines a sorter that is responsible for sorting the activities + * based on the provided historical choices and an intent. + */ + public interface ActivitySorter { + + /** + * Sorts the activities in descending order of relevance + * based on previous history and an intent. + * + * @param intent The {@link Intent}. + * @param activities Activities to be sorted. + * @param historicalRecords Historical records. + */ + // This cannot be done by a simple comparator since an Activity weight + // is computed from history. Note that Activity implements Comparable. + public void sort(Intent intent, List activities, + List historicalRecords); + } + + /** + * Listener for choosing an activity. + */ + public interface OnChooseActivityListener { + + /** + * Called when an activity has been chosen. The client can decide whether + * an activity can be chosen and if so the caller of + * {@link ActivityChooserModel#chooseActivity(int)} will receive and {@link Intent} + * for launching it. + *

+ * Note: Modifying the intent is not permitted and + * any changes to the latter will be ignored. + *

+ * + * @param host The listener's host model. + * @param intent The intent for launching the chosen activity. + * @return Whether the intent is handled and should not be delivered to clients. + * + * @see ActivityChooserModel#chooseActivity(int) + */ + public boolean onChooseActivity(ActivityChooserModel host, Intent intent); + } + + /** + * Flag for selecting debug mode. + */ + private static final boolean DEBUG = false; + + /** + * Tag used for logging. + */ + private static final String LOG_TAG = ActivityChooserModel.class.getSimpleName(); + + /** + * The root tag in the history file. + */ + private static final String TAG_HISTORICAL_RECORDS = "historical-records"; + + /** + * The tag for a record in the history file. + */ + private static final String TAG_HISTORICAL_RECORD = "historical-record"; + + /** + * Attribute for the activity. + */ + private static final String ATTRIBUTE_ACTIVITY = "activity"; + + /** + * Attribute for the choice time. + */ + private static final String ATTRIBUTE_TIME = "time"; + + /** + * Attribute for the choice weight. + */ + private static final String ATTRIBUTE_WEIGHT = "weight"; + + /** + * The default name of the choice history file. + */ + public static final String DEFAULT_HISTORY_FILE_NAME = + "activity_choser_model_history.xml"; + + /** + * The default maximal length of the choice history. + */ + public static final int DEFAULT_HISTORY_MAX_LENGTH = 50; + + /** + * The amount with which to inflate a chosen activity when set as default. + */ + private static final int DEFAULT_ACTIVITY_INFLATION = 5; + + /** + * Default weight for a choice record. + */ + private static final float DEFAULT_HISTORICAL_RECORD_WEIGHT = 1.0f; + + /** + * The extension of the history file. + */ + private static final String HISTORY_FILE_EXTENSION = ".xml"; + + /** + * An invalid item index. + */ + private static final int INVALID_INDEX = -1; + + /** + * Lock to guard the model registry. + */ + private static final Object sRegistryLock = new Object(); + + /** + * This the registry for data models. + */ + private static final Map sDataModelRegistry = + new HashMap(); + + /** + * Lock for synchronizing on this instance. + */ + private final Object mInstanceLock = new Object(); + + /** + * List of activities that can handle the current intent. + */ + private final List mActivites = new ArrayList(); + + /** + * List with historical choice records. + */ + private final List mHistoricalRecords = new ArrayList(); + + /** + * Context for accessing resources. + */ + private final Context mContext; + + /** + * The name of the history file that backs this model. + */ + private final String mHistoryFileName; + + /** + * The intent for which a activity is being chosen. + */ + private Intent mIntent; + + /** + * The sorter for ordering activities based on intent and past choices. + */ + private ActivitySorter mActivitySorter = new DefaultSorter(); + + /** + * The maximal length of the choice history. + */ + private int mHistoryMaxSize = DEFAULT_HISTORY_MAX_LENGTH; + + /** + * Flag whether choice history can be read. In general many clients can + * share the same data model and {@link #readHistoricalData()} may be called + * by arbitrary of them any number of times. Therefore, this class guarantees + * that the very first read succeeds and subsequent reads can be performed + * only after a call to {@link #persistHistoricalData()} followed by change + * of the share records. + */ + private boolean mCanReadHistoricalData = true; + + /** + * Flag whether the choice history was read. This is used to enforce that + * before calling {@link #persistHistoricalData()} a call to + * {@link #persistHistoricalData()} has been made. This aims to avoid a + * scenario in which a choice history file exits, it is not read yet and + * it is overwritten. Note that always all historical records are read in + * full and the file is rewritten. This is necessary since we need to + * purge old records that are outside of the sliding window of past choices. + */ + private boolean mReadShareHistoryCalled = false; + + /** + * Flag whether the choice records have changed. In general many clients can + * share the same data model and {@link #persistHistoricalData()} may be called + * by arbitrary of them any number of times. Therefore, this class guarantees + * that choice history will be persisted only if it has changed. + */ + private boolean mHistoricalRecordsChanged = true; + + /** + * Hander for scheduling work on client tread. + */ + private final Handler mHandler = new Handler(); + + /** + * Policy for controlling how the model handles chosen activities. + */ + private OnChooseActivityListener mActivityChoserModelPolicy; + + /** + * Gets the data model backed by the contents of the provided file with historical data. + * Note that only one data model is backed by a given file, thus multiple calls with + * the same file name will return the same model instance. If no such instance is present + * it is created. + *

+ * Note: To use the default historical data file clients should explicitly + * pass as file name {@link #DEFAULT_HISTORY_FILE_NAME}. If no persistence of the choice + * history is desired clients should pass null for the file name. In such + * case a new model is returned for each invocation. + *

+ * + *

+ * Always use difference historical data files for semantically different actions. + * For example, sharing is different from importing. + *

+ * + * @param context Context for loading resources. + * @param historyFileName File name with choice history, null + * if the model should not be backed by a file. In this case the activities + * will be ordered only by data from the current session. + * + * @return The model. + */ + public static ActivityChooserModel get(Context context, String historyFileName) { + synchronized (sRegistryLock) { + ActivityChooserModel dataModel = sDataModelRegistry.get(historyFileName); + if (dataModel == null) { + dataModel = new ActivityChooserModel(context, historyFileName); + sDataModelRegistry.put(historyFileName, dataModel); + } + dataModel.readHistoricalData(); + return dataModel; + } + } + + /** + * Creates a new instance. + * + * @param context Context for loading resources. + * @param historyFileName The history XML file. + */ + private ActivityChooserModel(Context context, String historyFileName) { + mContext = context.getApplicationContext(); + if (!TextUtils.isEmpty(historyFileName) + && !historyFileName.endsWith(HISTORY_FILE_EXTENSION)) { + mHistoryFileName = historyFileName + HISTORY_FILE_EXTENSION; + } else { + mHistoryFileName = historyFileName; + } + } + + /** + * Sets an intent for which to choose a activity. + *

+ * Note: Clients must set only semantically similar + * intents for each data model. + *

+ * + * @param intent The intent. + */ + public void setIntent(Intent intent) { + synchronized (mInstanceLock) { + if (mIntent == intent) { + return; + } + mIntent = intent; + loadActivitiesLocked(); + } + } + + /** + * Gets the intent for which a activity is being chosen. + * + * @return The intent. + */ + public Intent getIntent() { + synchronized (mInstanceLock) { + return mIntent; + } + } + + /** + * Gets the number of activities that can handle the intent. + * + * @return The activity count. + * + * @see #setIntent(Intent) + */ + public int getActivityCount() { + synchronized (mInstanceLock) { + return mActivites.size(); + } + } + + /** + * Gets an activity at a given index. + * + * @return The activity. + * + * @see ActivityResolveInfo + * @see #setIntent(Intent) + */ + public ResolveInfo getActivity(int index) { + synchronized (mInstanceLock) { + return mActivites.get(index).resolveInfo; + } + } + + /** + * Gets the index of a the given activity. + * + * @param activity The activity index. + * + * @return The index if found, -1 otherwise. + */ + public int getActivityIndex(ResolveInfo activity) { + List activities = mActivites; + final int activityCount = activities.size(); + for (int i = 0; i < activityCount; i++) { + ActivityResolveInfo currentActivity = activities.get(i); + if (currentActivity.resolveInfo == activity) { + return i; + } + } + return INVALID_INDEX; + } + + /** + * Chooses a activity to handle the current intent. This will result in + * adding a historical record for that action and construct intent with + * its component name set such that it can be immediately started by the + * client. + *

+ * Note: By calling this method the client guarantees + * that the returned intent will be started. This intent is returned to + * the client solely to let additional customization before the start. + *

+ * + * @return An {@link Intent} for launching the activity or null if the + * policy has consumed the intent. + * + * @see HistoricalRecord + * @see OnChooseActivityListener + */ + public Intent chooseActivity(int index) { + ActivityResolveInfo chosenActivity = mActivites.get(index); + + ComponentName chosenName = new ComponentName( + chosenActivity.resolveInfo.activityInfo.packageName, + chosenActivity.resolveInfo.activityInfo.name); + + Intent choiceIntent = new Intent(mIntent); + choiceIntent.setComponent(chosenName); + + if (mActivityChoserModelPolicy != null) { + // Do not allow the policy to change the intent. + Intent choiceIntentCopy = new Intent(choiceIntent); + final boolean handled = mActivityChoserModelPolicy.onChooseActivity(this, + choiceIntentCopy); + if (handled) { + return null; + } + } + + HistoricalRecord historicalRecord = new HistoricalRecord(chosenName, + System.currentTimeMillis(), DEFAULT_HISTORICAL_RECORD_WEIGHT); + addHisoricalRecord(historicalRecord); + + return choiceIntent; + } + + /** + * Sets the listener for choosing an activity. + * + * @param listener The listener. + */ + public void setOnChooseActivityListener(OnChooseActivityListener listener) { + mActivityChoserModelPolicy = listener; + } + + /** + * Gets the default activity, The default activity is defined as the one + * with highest rank i.e. the first one in the list of activities that can + * handle the intent. + * + * @return The default activity, null id not activities. + * + * @see #getActivity(int) + */ + public ResolveInfo getDefaultActivity() { + synchronized (mInstanceLock) { + if (!mActivites.isEmpty()) { + return mActivites.get(0).resolveInfo; + } + } + return null; + } + + /** + * Sets the default activity. The default activity is set by adding a + * historical record with weight high enough that this activity will + * become the highest ranked. Such a strategy guarantees that the default + * will eventually change if not used. Also the weight of the record for + * setting a default is inflated with a constant amount to guarantee that + * it will stay as default for awhile. + * + * @param index The index of the activity to set as default. + */ + public void setDefaultActivity(int index) { + ActivityResolveInfo newDefaultActivity = mActivites.get(index); + ActivityResolveInfo oldDefaultActivity = mActivites.get(0); + + final float weight; + if (oldDefaultActivity != null) { + // Add a record with weight enough to boost the chosen at the top. + weight = oldDefaultActivity.weight - newDefaultActivity.weight + + DEFAULT_ACTIVITY_INFLATION; + } else { + weight = DEFAULT_HISTORICAL_RECORD_WEIGHT; + } + + ComponentName defaultName = new ComponentName( + newDefaultActivity.resolveInfo.activityInfo.packageName, + newDefaultActivity.resolveInfo.activityInfo.name); + HistoricalRecord historicalRecord = new HistoricalRecord(defaultName, + System.currentTimeMillis(), weight); + addHisoricalRecord(historicalRecord); + } + + /** + * Reads the history data from the backing file if the latter + * was provided. Calling this method more than once before a call + * to {@link #persistHistoricalData()} has been made has no effect. + *

+ * Note: Historical data is read asynchronously and + * as soon as the reading is completed any registered + * {@link DataSetObserver}s will be notified. Also no historical + * data is read until this method is invoked. + *

+ */ + private void readHistoricalData() { + synchronized (mInstanceLock) { + if (!mCanReadHistoricalData || !mHistoricalRecordsChanged) { + return; + } + mCanReadHistoricalData = false; + mReadShareHistoryCalled = true; + if (!TextUtils.isEmpty(mHistoryFileName)) { + /*AsyncTask.*/SERIAL_EXECUTOR.execute(new HistoryLoader()); + } + } + } + + private static final SerialExecutor SERIAL_EXECUTOR = new SerialExecutor(); + + private static class SerialExecutor implements Executor { + final LinkedList mTasks = new LinkedList(); + Runnable mActive; + + public synchronized void execute(final Runnable r) { + mTasks.offer(new Runnable() { + public void run() { + try { + r.run(); + } finally { + scheduleNext(); + } + } + }); + if (mActive == null) { + scheduleNext(); + } + } + + protected synchronized void scheduleNext() { + if ((mActive = mTasks.poll()) != null) { + mActive.run(); + } + } + } + + /** + * Persists the history data to the backing file if the latter + * was provided. Calling this method before a call to {@link #readHistoricalData()} + * throws an exception. Calling this method more than one without choosing an + * activity has not effect. + * + * @throws IllegalStateException If this method is called before a call to + * {@link #readHistoricalData()}. + */ + private void persistHistoricalData() { + synchronized (mInstanceLock) { + if (!mReadShareHistoryCalled) { + throw new IllegalStateException("No preceding call to #readHistoricalData"); + } + if (!mHistoricalRecordsChanged) { + return; + } + mHistoricalRecordsChanged = false; + mCanReadHistoricalData = true; + if (!TextUtils.isEmpty(mHistoryFileName)) { + /*AsyncTask.*/SERIAL_EXECUTOR.execute(new HistoryPersister()); + } + } + } + + /** + * Sets the sorter for ordering activities based on historical data and an intent. + * + * @param activitySorter The sorter. + * + * @see ActivitySorter + */ + public void setActivitySorter(ActivitySorter activitySorter) { + synchronized (mInstanceLock) { + if (mActivitySorter == activitySorter) { + return; + } + mActivitySorter = activitySorter; + sortActivities(); + } + } + + /** + * Sorts the activities based on history and an intent. If + * a sorter is not specified this a default implementation is used. + * + * @see #setActivitySorter(ActivitySorter) + */ + private void sortActivities() { + synchronized (mInstanceLock) { + if (mActivitySorter != null && !mActivites.isEmpty()) { + mActivitySorter.sort(mIntent, mActivites, + Collections.unmodifiableList(mHistoricalRecords)); + notifyChanged(); + } + } + } + + /** + * Sets the maximal size of the historical data. Defaults to + * {@link #DEFAULT_HISTORY_MAX_LENGTH} + *

+ * Note: Setting this property will immediately + * enforce the specified max history size by dropping enough old + * historical records to enforce the desired size. Thus, any + * records that exceed the history size will be discarded and + * irreversibly lost. + *

+ * + * @param historyMaxSize The max history size. + */ + public void setHistoryMaxSize(int historyMaxSize) { + synchronized (mInstanceLock) { + if (mHistoryMaxSize == historyMaxSize) { + return; + } + mHistoryMaxSize = historyMaxSize; + pruneExcessiveHistoricalRecordsLocked(); + sortActivities(); + } + } + + /** + * Gets the history max size. + * + * @return The history max size. + */ + public int getHistoryMaxSize() { + synchronized (mInstanceLock) { + return mHistoryMaxSize; + } + } + + /** + * Gets the history size. + * + * @return The history size. + */ + public int getHistorySize() { + synchronized (mInstanceLock) { + return mHistoricalRecords.size(); + } + } + + /** + * Adds a historical record. + * + * @param historicalRecord The record to add. + * @return True if the record was added. + */ + private boolean addHisoricalRecord(HistoricalRecord historicalRecord) { + synchronized (mInstanceLock) { + final boolean added = mHistoricalRecords.add(historicalRecord); + if (added) { + mHistoricalRecordsChanged = true; + pruneExcessiveHistoricalRecordsLocked(); + persistHistoricalData(); + sortActivities(); + } + return added; + } + } + + /** + * Prunes older excessive records to guarantee {@link #mHistoryMaxSize}. + */ + private void pruneExcessiveHistoricalRecordsLocked() { + List choiceRecords = mHistoricalRecords; + final int pruneCount = choiceRecords.size() - mHistoryMaxSize; + if (pruneCount <= 0) { + return; + } + mHistoricalRecordsChanged = true; + for (int i = 0; i < pruneCount; i++) { + HistoricalRecord prunedRecord = choiceRecords.remove(0); + if (DEBUG) { + Log.i(LOG_TAG, "Pruned: " + prunedRecord); + } + } + } + + /** + * Loads the activities. + */ + private void loadActivitiesLocked() { + mActivites.clear(); + if (mIntent != null) { + List resolveInfos = + mContext.getPackageManager().queryIntentActivities(mIntent, 0); + final int resolveInfoCount = resolveInfos.size(); + for (int i = 0; i < resolveInfoCount; i++) { + ResolveInfo resolveInfo = resolveInfos.get(i); + mActivites.add(new ActivityResolveInfo(resolveInfo)); + } + sortActivities(); + } else { + notifyChanged(); + } + } + + /** + * Represents a record in the history. + */ + public final static class HistoricalRecord { + + /** + * The activity name. + */ + public final ComponentName activity; + + /** + * The choice time. + */ + public final long time; + + /** + * The record weight. + */ + public final float weight; + + /** + * Creates a new instance. + * + * @param activityName The activity component name flattened to string. + * @param time The time the activity was chosen. + * @param weight The weight of the record. + */ + public HistoricalRecord(String activityName, long time, float weight) { + this(ComponentName.unflattenFromString(activityName), time, weight); + } + + /** + * Creates a new instance. + * + * @param activityName The activity name. + * @param time The time the activity was chosen. + * @param weight The weight of the record. + */ + public HistoricalRecord(ComponentName activityName, long time, float weight) { + this.activity = activityName; + this.time = time; + this.weight = weight; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((activity == null) ? 0 : activity.hashCode()); + result = prime * result + (int) (time ^ (time >>> 32)); + result = prime * result + Float.floatToIntBits(weight); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + HistoricalRecord other = (HistoricalRecord) obj; + if (activity == null) { + if (other.activity != null) { + return false; + } + } else if (!activity.equals(other.activity)) { + return false; + } + if (time != other.time) { + return false; + } + if (Float.floatToIntBits(weight) != Float.floatToIntBits(other.weight)) { + return false; + } + return true; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("["); + builder.append("; activity:").append(activity); + builder.append("; time:").append(time); + builder.append("; weight:").append(new BigDecimal(weight)); + builder.append("]"); + return builder.toString(); + } + } + + /** + * Represents an activity. + */ + public final class ActivityResolveInfo implements Comparable { + + /** + * The {@link ResolveInfo} of the activity. + */ + public final ResolveInfo resolveInfo; + + /** + * Weight of the activity. Useful for sorting. + */ + public float weight; + + /** + * Creates a new instance. + * + * @param resolveInfo activity {@link ResolveInfo}. + */ + public ActivityResolveInfo(ResolveInfo resolveInfo) { + this.resolveInfo = resolveInfo; + } + + @Override + public int hashCode() { + return 31 + Float.floatToIntBits(weight); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + ActivityResolveInfo other = (ActivityResolveInfo) obj; + if (Float.floatToIntBits(weight) != Float.floatToIntBits(other.weight)) { + return false; + } + return true; + } + + public int compareTo(ActivityResolveInfo another) { + return Float.floatToIntBits(another.weight) - Float.floatToIntBits(weight); + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("["); + builder.append("resolveInfo:").append(resolveInfo.toString()); + builder.append("; weight:").append(new BigDecimal(weight)); + builder.append("]"); + return builder.toString(); + } + } + + /** + * Default activity sorter implementation. + */ + private final class DefaultSorter implements ActivitySorter { + private static final float WEIGHT_DECAY_COEFFICIENT = 0.95f; + + private final Map mPackageNameToActivityMap = + new HashMap(); + + public void sort(Intent intent, List activities, + List historicalRecords) { + Map packageNameToActivityMap = + mPackageNameToActivityMap; + packageNameToActivityMap.clear(); + + final int activityCount = activities.size(); + for (int i = 0; i < activityCount; i++) { + ActivityResolveInfo activity = activities.get(i); + activity.weight = 0.0f; + String packageName = activity.resolveInfo.activityInfo.packageName; + packageNameToActivityMap.put(packageName, activity); + } + + final int lastShareIndex = historicalRecords.size() - 1; + float nextRecordWeight = 1; + for (int i = lastShareIndex; i >= 0; i--) { + HistoricalRecord historicalRecord = historicalRecords.get(i); + String packageName = historicalRecord.activity.getPackageName(); + ActivityResolveInfo activity = packageNameToActivityMap.get(packageName); + if (activity != null) { + activity.weight += historicalRecord.weight * nextRecordWeight; + nextRecordWeight = nextRecordWeight * WEIGHT_DECAY_COEFFICIENT; + } + } + + Collections.sort(activities); + + if (DEBUG) { + for (int i = 0; i < activityCount; i++) { + Log.i(LOG_TAG, "Sorted: " + activities.get(i)); + } + } + } + } + + /** + * Command for reading the historical records from a file off the UI thread. + */ + private final class HistoryLoader implements Runnable { + + public void run() { + FileInputStream fis = null; + try { + fis = mContext.openFileInput(mHistoryFileName); + } catch (FileNotFoundException fnfe) { + if (DEBUG) { + Log.i(LOG_TAG, "Could not open historical records file: " + mHistoryFileName); + } + return; + } + try { + XmlPullParser parser = Xml.newPullParser(); + parser.setInput(fis, null); + + int type = XmlPullParser.START_DOCUMENT; + while (type != XmlPullParser.END_DOCUMENT && type != XmlPullParser.START_TAG) { + type = parser.next(); + } + + if (!TAG_HISTORICAL_RECORDS.equals(parser.getName())) { + throw new XmlPullParserException("Share records file does not start with " + + TAG_HISTORICAL_RECORDS + " tag."); + } + + List readRecords = new ArrayList(); + + while (true) { + type = parser.next(); + if (type == XmlPullParser.END_DOCUMENT) { + break; + } + if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { + continue; + } + String nodeName = parser.getName(); + if (!TAG_HISTORICAL_RECORD.equals(nodeName)) { + throw new XmlPullParserException("Share records file not well-formed."); + } + + String activity = parser.getAttributeValue(null, ATTRIBUTE_ACTIVITY); + final long time = + Long.parseLong(parser.getAttributeValue(null, ATTRIBUTE_TIME)); + final float weight = + Float.parseFloat(parser.getAttributeValue(null, ATTRIBUTE_WEIGHT)); + + HistoricalRecord readRecord = new HistoricalRecord(activity, time, + weight); + readRecords.add(readRecord); + + if (DEBUG) { + Log.i(LOG_TAG, "Read " + readRecord.toString()); + } + } + + if (DEBUG) { + Log.i(LOG_TAG, "Read " + readRecords.size() + " historical records."); + } + + synchronized (mInstanceLock) { + Set uniqueShareRecords = + new LinkedHashSet(readRecords); + + // Make sure no duplicates. Example: Read a file with + // one record, add one record, persist the two records, + // add a record, read the persisted records - the + // read two records should not be added again. + List historicalRecords = mHistoricalRecords; + final int historicalRecordsCount = historicalRecords.size(); + for (int i = historicalRecordsCount - 1; i >= 0; i--) { + HistoricalRecord historicalRecord = historicalRecords.get(i); + uniqueShareRecords.add(historicalRecord); + } + + if (historicalRecords.size() == uniqueShareRecords.size()) { + return; + } + + // Make sure the oldest records go to the end. + historicalRecords.clear(); + historicalRecords.addAll(uniqueShareRecords); + + mHistoricalRecordsChanged = true; + + // Do this on the client thread since the client may be on the UI + // thread, wait for data changes which happen during sorting, and + // perform UI modification based on the data change. + mHandler.post(new Runnable() { + public void run() { + pruneExcessiveHistoricalRecordsLocked(); + sortActivities(); + } + }); + } + } catch (XmlPullParserException xppe) { + Log.e(LOG_TAG, "Error reading historical recrod file: " + mHistoryFileName, xppe); + } catch (IOException ioe) { + Log.e(LOG_TAG, "Error reading historical recrod file: " + mHistoryFileName, ioe); + } finally { + if (fis != null) { + try { + fis.close(); + } catch (IOException ioe) { + /* ignore */ + } + } + } + } + } + + /** + * Command for persisting the historical records to a file off the UI thread. + */ + private final class HistoryPersister implements Runnable { + + public void run() { + FileOutputStream fos = null; + List records = null; + + synchronized (mInstanceLock) { + records = new ArrayList(mHistoricalRecords); + } + + try { + fos = mContext.openFileOutput(mHistoryFileName, Context.MODE_PRIVATE); + } catch (FileNotFoundException fnfe) { + Log.e(LOG_TAG, "Error writing historical recrod file: " + mHistoryFileName, fnfe); + return; + } + + XmlSerializer serializer = Xml.newSerializer(); + + try { + serializer.setOutput(fos, null); + serializer.startDocument("UTF-8", true); + serializer.startTag(null, TAG_HISTORICAL_RECORDS); + + final int recordCount = records.size(); + for (int i = 0; i < recordCount; i++) { + HistoricalRecord record = records.remove(0); + serializer.startTag(null, TAG_HISTORICAL_RECORD); + serializer.attribute(null, ATTRIBUTE_ACTIVITY, record.activity.flattenToString()); + serializer.attribute(null, ATTRIBUTE_TIME, String.valueOf(record.time)); + serializer.attribute(null, ATTRIBUTE_WEIGHT, String.valueOf(record.weight)); + serializer.endTag(null, TAG_HISTORICAL_RECORD); + if (DEBUG) { + Log.i(LOG_TAG, "Wrote " + record.toString()); + } + } + + serializer.endTag(null, TAG_HISTORICAL_RECORDS); + serializer.endDocument(); + + if (DEBUG) { + Log.i(LOG_TAG, "Wrote " + recordCount + " historical records."); + } + } catch (IllegalArgumentException iae) { + Log.e(LOG_TAG, "Error writing historical recrod file: " + mHistoryFileName, iae); + } catch (IllegalStateException ise) { + Log.e(LOG_TAG, "Error writing historical recrod file: " + mHistoryFileName, ise); + } catch (IOException ioe) { + Log.e(LOG_TAG, "Error writing historical recrod file: " + mHistoryFileName, ioe); + } finally { + if (fos != null) { + try { + fos.close(); + } catch (IOException e) { + /* ignore */ + } + } + } + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/widget/ActivityChooserView.java b/actionbarsherlock/src/com/actionbarsherlock/widget/ActivityChooserView.java new file mode 100644 index 000000000..da13bc99f --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/widget/ActivityChooserView.java @@ -0,0 +1,818 @@ +/* + * Copyright (C) 2011 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.actionbarsherlock.widget; + +import android.os.Build; +import com.actionbarsherlock.R; +import com.actionbarsherlock.internal.widget.IcsLinearLayout; +import com.actionbarsherlock.internal.widget.IcsListPopupWindow; +import com.actionbarsherlock.view.ActionProvider; +import com.actionbarsherlock.widget.ActivityChooserModel.ActivityChooserModelClient; +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; +import android.content.res.Resources; +import android.content.res.TypedArray; +import android.database.DataSetObserver; +import android.graphics.drawable.Drawable; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewTreeObserver; +import android.view.ViewTreeObserver.OnGlobalLayoutListener; +import android.widget.AdapterView; +import android.widget.BaseAdapter; +import android.widget.FrameLayout; +import android.widget.ImageView; +import android.widget.PopupWindow; +import android.widget.TextView; + +/** + * This class is a view for choosing an activity for handling a given {@link Intent}. + *

+ * The view is composed of two adjacent buttons: + *

    + *
  • + * The left button is an immediate action and allows one click activity choosing. + * Tapping this button immediately executes the intent without requiring any further + * user input. Long press on this button shows a popup for changing the default + * activity. + *
  • + *
  • + * The right button is an overflow action and provides an optimized menu + * of additional activities. Tapping this button shows a popup anchored to this + * view, listing the most frequently used activities. This list is initially + * limited to a small number of items in frequency used order. The last item, + * "Show all..." serves as an affordance to display all available activities. + *
  • + *
+ *

+ * + * @hide + */ +class ActivityChooserView extends ViewGroup implements ActivityChooserModelClient { + + /** + * An adapter for displaying the activities in an {@link AdapterView}. + */ + private final ActivityChooserViewAdapter mAdapter; + + /** + * Implementation of various interfaces to avoid publishing them in the APIs. + */ + private final Callbacks mCallbacks; + + /** + * The content of this view. + */ + private final IcsLinearLayout mActivityChooserContent; + + /** + * Stores the background drawable to allow hiding and latter showing. + */ + private final Drawable mActivityChooserContentBackground; + + /** + * The expand activities action button; + */ + private final FrameLayout mExpandActivityOverflowButton; + + /** + * The image for the expand activities action button; + */ + private final ImageView mExpandActivityOverflowButtonImage; + + /** + * The default activities action button; + */ + private final FrameLayout mDefaultActivityButton; + + /** + * The image for the default activities action button; + */ + private final ImageView mDefaultActivityButtonImage; + + /** + * The maximal width of the list popup. + */ + private final int mListPopupMaxWidth; + + /** + * The ActionProvider hosting this view, if applicable. + */ + ActionProvider mProvider; + + /** + * Observer for the model data. + */ + private final DataSetObserver mModelDataSetOberver = new DataSetObserver() { + + @Override + public void onChanged() { + super.onChanged(); + mAdapter.notifyDataSetChanged(); + } + @Override + public void onInvalidated() { + super.onInvalidated(); + mAdapter.notifyDataSetInvalidated(); + } + }; + + private final OnGlobalLayoutListener mOnGlobalLayoutListener = new OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + if (isShowingPopup()) { + if (!isShown()) { + getListPopupWindow().dismiss(); + } else { + getListPopupWindow().show(); + if (mProvider != null) { + mProvider.subUiVisibilityChanged(true); + } + } + } + } + }; + + /** + * Popup window for showing the activity overflow list. + */ + private IcsListPopupWindow mListPopupWindow; + + /** + * Listener for the dismissal of the popup/alert. + */ + private PopupWindow.OnDismissListener mOnDismissListener; + + /** + * Flag whether a default activity currently being selected. + */ + private boolean mIsSelectingDefaultActivity; + + /** + * The count of activities in the popup. + */ + private int mInitialActivityCount = ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_DEFAULT; + + /** + * Flag whether this view is attached to a window. + */ + private boolean mIsAttachedToWindow; + + /** + * String resource for formatting content description of the default target. + */ + private int mDefaultActionButtonContentDescription; + + private final Context mContext; + + /** + * Create a new instance. + * + * @param context The application environment. + */ + public ActivityChooserView(Context context) { + this(context, null); + } + + /** + * Create a new instance. + * + * @param context The application environment. + * @param attrs A collection of attributes. + */ + public ActivityChooserView(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + /** + * Create a new instance. + * + * @param context The application environment. + * @param attrs A collection of attributes. + * @param defStyle The default style to apply to this view. + */ + public ActivityChooserView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + mContext = context; + + TypedArray attributesArray = context.obtainStyledAttributes(attrs, + R.styleable.SherlockActivityChooserView, defStyle, 0); + + mInitialActivityCount = attributesArray.getInt( + R.styleable.SherlockActivityChooserView_initialActivityCount, + ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_DEFAULT); + + Drawable expandActivityOverflowButtonDrawable = attributesArray.getDrawable( + R.styleable.SherlockActivityChooserView_expandActivityOverflowButtonDrawable); + + attributesArray.recycle(); + + LayoutInflater inflater = LayoutInflater.from(mContext); + inflater.inflate(R.layout.abs__activity_chooser_view, this, true); + + mCallbacks = new Callbacks(); + + mActivityChooserContent = (IcsLinearLayout) findViewById(R.id.abs__activity_chooser_view_content); + mActivityChooserContentBackground = mActivityChooserContent.getBackground(); + + mDefaultActivityButton = (FrameLayout) findViewById(R.id.abs__default_activity_button); + mDefaultActivityButton.setOnClickListener(mCallbacks); + mDefaultActivityButton.setOnLongClickListener(mCallbacks); + mDefaultActivityButtonImage = (ImageView) mDefaultActivityButton.findViewById(R.id.abs__image); + + mExpandActivityOverflowButton = (FrameLayout) findViewById(R.id.abs__expand_activities_button); + mExpandActivityOverflowButton.setOnClickListener(mCallbacks); + mExpandActivityOverflowButtonImage = + (ImageView) mExpandActivityOverflowButton.findViewById(R.id.abs__image); + mExpandActivityOverflowButtonImage.setImageDrawable(expandActivityOverflowButtonDrawable); + + mAdapter = new ActivityChooserViewAdapter(); + mAdapter.registerDataSetObserver(new DataSetObserver() { + @Override + public void onChanged() { + super.onChanged(); + updateAppearance(); + } + }); + + Resources resources = context.getResources(); + mListPopupMaxWidth = Math.max(resources.getDisplayMetrics().widthPixels / 2, + resources.getDimensionPixelSize(R.dimen.abs__config_prefDialogWidth)); + } + + /** + * {@inheritDoc} + */ + public void setActivityChooserModel(ActivityChooserModel dataModel) { + mAdapter.setDataModel(dataModel); + if (isShowingPopup()) { + dismissPopup(); + showPopup(); + } + } + + /** + * Sets the background for the button that expands the activity + * overflow list. + * + * Note: Clients would like to set this drawable + * as a clue about the action the chosen activity will perform. For + * example, if a share activity is to be chosen the drawable should + * give a clue that sharing is to be performed. + * + * @param drawable The drawable. + */ + public void setExpandActivityOverflowButtonDrawable(Drawable drawable) { + mExpandActivityOverflowButtonImage.setImageDrawable(drawable); + } + + /** + * Sets the content description for the button that expands the activity + * overflow list. + * + * description as a clue about the action performed by the button. + * For example, if a share activity is to be chosen the content + * description should be something like "Share with". + * + * @param resourceId The content description resource id. + */ + public void setExpandActivityOverflowButtonContentDescription(int resourceId) { + CharSequence contentDescription = mContext.getString(resourceId); + mExpandActivityOverflowButtonImage.setContentDescription(contentDescription); + } + + /** + * Set the provider hosting this view, if applicable. + * @hide Internal use only + */ + public void setProvider(ActionProvider provider) { + mProvider = provider; + } + + /** + * Shows the popup window with activities. + * + * @return True if the popup was shown, false if already showing. + */ + public boolean showPopup() { + if (isShowingPopup() || !mIsAttachedToWindow) { + return false; + } + mIsSelectingDefaultActivity = false; + showPopupUnchecked(mInitialActivityCount); + return true; + } + + /** + * Shows the popup no matter if it was already showing. + * + * @param maxActivityCount The max number of activities to display. + */ + private void showPopupUnchecked(int maxActivityCount) { + if (mAdapter.getDataModel() == null) { + throw new IllegalStateException("No data model. Did you call #setDataModel?"); + } + + getViewTreeObserver().addOnGlobalLayoutListener(mOnGlobalLayoutListener); + + final boolean defaultActivityButtonShown = + mDefaultActivityButton.getVisibility() == VISIBLE; + + final int activityCount = mAdapter.getActivityCount(); + final int maxActivityCountOffset = defaultActivityButtonShown ? 1 : 0; + if (maxActivityCount != ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED + && activityCount > maxActivityCount + maxActivityCountOffset) { + mAdapter.setShowFooterView(true); + mAdapter.setMaxActivityCount(maxActivityCount - 1); + } else { + mAdapter.setShowFooterView(false); + mAdapter.setMaxActivityCount(maxActivityCount); + } + + IcsListPopupWindow popupWindow = getListPopupWindow(); + if (!popupWindow.isShowing()) { + if (mIsSelectingDefaultActivity || !defaultActivityButtonShown) { + mAdapter.setShowDefaultActivity(true, defaultActivityButtonShown); + } else { + mAdapter.setShowDefaultActivity(false, false); + } + final int contentWidth = Math.min(mAdapter.measureContentWidth(), mListPopupMaxWidth); + popupWindow.setContentWidth(contentWidth); + popupWindow.show(); + if (mProvider != null) { + mProvider.subUiVisibilityChanged(true); + } + popupWindow.getListView().setContentDescription(mContext.getString( + R.string.abs__activitychooserview_choose_application)); + } + } + + /** + * Dismisses the popup window with activities. + * + * @return True if dismissed, false if already dismissed. + */ + public boolean dismissPopup() { + if (isShowingPopup()) { + getListPopupWindow().dismiss(); + ViewTreeObserver viewTreeObserver = getViewTreeObserver(); + if (viewTreeObserver.isAlive()) { + viewTreeObserver.removeGlobalOnLayoutListener(mOnGlobalLayoutListener); + } + } + return true; + } + + /** + * Gets whether the popup window with activities is shown. + * + * @return True if the popup is shown. + */ + public boolean isShowingPopup() { + return getListPopupWindow().isShowing(); + } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + ActivityChooserModel dataModel = mAdapter.getDataModel(); + if (dataModel != null) { + dataModel.registerObserver(mModelDataSetOberver); + } + mIsAttachedToWindow = true; + } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + ActivityChooserModel dataModel = mAdapter.getDataModel(); + if (dataModel != null) { + dataModel.unregisterObserver(mModelDataSetOberver); + } + ViewTreeObserver viewTreeObserver = getViewTreeObserver(); + if (viewTreeObserver.isAlive()) { + viewTreeObserver.removeGlobalOnLayoutListener(mOnGlobalLayoutListener); + } + mIsAttachedToWindow = false; + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + View child = mActivityChooserContent; + // If the default action is not visible we want to be as tall as the + // ActionBar so if this widget is used in the latter it will look as + // a normal action button. + if (mDefaultActivityButton.getVisibility() != VISIBLE) { + heightMeasureSpec = MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(heightMeasureSpec), + MeasureSpec.EXACTLY); + } + measureChild(child, widthMeasureSpec, heightMeasureSpec); + setMeasuredDimension(child.getMeasuredWidth(), child.getMeasuredHeight()); + } + + @Override + protected void onLayout(boolean changed, int left, int top, int right, int bottom) { + mActivityChooserContent.layout(0, 0, right - left, bottom - top); + if (getListPopupWindow().isShowing()) { + showPopupUnchecked(mAdapter.getMaxActivityCount()); + } else { + dismissPopup(); + } + } + + public ActivityChooserModel getDataModel() { + return mAdapter.getDataModel(); + } + + /** + * Sets a listener to receive a callback when the popup is dismissed. + * + * @param listener The listener to be notified. + */ + public void setOnDismissListener(PopupWindow.OnDismissListener listener) { + mOnDismissListener = listener; + } + + /** + * Sets the initial count of items shown in the activities popup + * i.e. the items before the popup is expanded. This is an upper + * bound since it is not guaranteed that such number of intent + * handlers exist. + * + * @param itemCount The initial popup item count. + */ + public void setInitialActivityCount(int itemCount) { + mInitialActivityCount = itemCount; + } + + /** + * Sets a content description of the default action button. This + * resource should be a string taking one formatting argument and + * will be used for formatting the content description of the button + * dynamically as the default target changes. For example, a resource + * pointing to the string "share with %1$s" will result in a content + * description "share with Bluetooth" for the Bluetooth activity. + * + * @param resourceId The resource id. + */ + public void setDefaultActionButtonContentDescription(int resourceId) { + mDefaultActionButtonContentDescription = resourceId; + } + + /** + * Gets the list popup window which is lazily initialized. + * + * @return The popup. + */ + private IcsListPopupWindow getListPopupWindow() { + if (mListPopupWindow == null) { + mListPopupWindow = new IcsListPopupWindow(getContext()); + mListPopupWindow.setAdapter(mAdapter); + mListPopupWindow.setAnchorView(ActivityChooserView.this); + mListPopupWindow.setModal(true); + mListPopupWindow.setOnItemClickListener(mCallbacks); + mListPopupWindow.setOnDismissListener(mCallbacks); + } + return mListPopupWindow; + } + + /** + * Updates the buttons state. + */ + private void updateAppearance() { + // Expand overflow button. + if (mAdapter.getCount() > 0) { + mExpandActivityOverflowButton.setEnabled(true); + } else { + mExpandActivityOverflowButton.setEnabled(false); + } + // Default activity button. + final int activityCount = mAdapter.getActivityCount(); + final int historySize = mAdapter.getHistorySize(); + if (activityCount > 0 && historySize > 0) { + mDefaultActivityButton.setVisibility(VISIBLE); + ResolveInfo activity = mAdapter.getDefaultActivity(); + PackageManager packageManager = mContext.getPackageManager(); + mDefaultActivityButtonImage.setImageDrawable(activity.loadIcon(packageManager)); + if (mDefaultActionButtonContentDescription != 0) { + CharSequence label = activity.loadLabel(packageManager); + String contentDescription = mContext.getString( + mDefaultActionButtonContentDescription, label); + mDefaultActivityButton.setContentDescription(contentDescription); + } + } else { + mDefaultActivityButton.setVisibility(View.GONE); + } + // Activity chooser content. + if (mDefaultActivityButton.getVisibility() == VISIBLE) { + mActivityChooserContent.setBackgroundDrawable(mActivityChooserContentBackground); + } else { + mActivityChooserContent.setBackgroundDrawable(null); + } + } + + /** + * Interface implementation to avoid publishing them in the APIs. + */ + private class Callbacks implements AdapterView.OnItemClickListener, + View.OnClickListener, View.OnLongClickListener, PopupWindow.OnDismissListener { + + // AdapterView#OnItemClickListener + public void onItemClick(AdapterView parent, View view, int position, long id) { + ActivityChooserViewAdapter adapter = (ActivityChooserViewAdapter) parent.getAdapter(); + final int itemViewType = adapter.getItemViewType(position); + switch (itemViewType) { + case ActivityChooserViewAdapter.ITEM_VIEW_TYPE_FOOTER: { + showPopupUnchecked(ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED); + } break; + case ActivityChooserViewAdapter.ITEM_VIEW_TYPE_ACTIVITY: { + dismissPopup(); + if (mIsSelectingDefaultActivity) { + // The item at position zero is the default already. + if (position > 0) { + mAdapter.getDataModel().setDefaultActivity(position); + } + } else { + // If the default target is not shown in the list, the first + // item in the model is default action => adjust index + position = mAdapter.getShowDefaultActivity() ? position : position + 1; + Intent launchIntent = mAdapter.getDataModel().chooseActivity(position); + if (launchIntent != null) { + mContext.startActivity(launchIntent); + } + } + } break; + default: + throw new IllegalArgumentException(); + } + } + + // View.OnClickListener + public void onClick(View view) { + if (view == mDefaultActivityButton) { + dismissPopup(); + ResolveInfo defaultActivity = mAdapter.getDefaultActivity(); + final int index = mAdapter.getDataModel().getActivityIndex(defaultActivity); + Intent launchIntent = mAdapter.getDataModel().chooseActivity(index); + if (launchIntent != null) { + mContext.startActivity(launchIntent); + } + } else if (view == mExpandActivityOverflowButton) { + mIsSelectingDefaultActivity = false; + showPopupUnchecked(mInitialActivityCount); + } else { + throw new IllegalArgumentException(); + } + } + + // OnLongClickListener#onLongClick + @Override + public boolean onLongClick(View view) { + if (view == mDefaultActivityButton) { + if (mAdapter.getCount() > 0) { + mIsSelectingDefaultActivity = true; + showPopupUnchecked(mInitialActivityCount); + } + } else { + throw new IllegalArgumentException(); + } + return true; + } + + // PopUpWindow.OnDismissListener#onDismiss + public void onDismiss() { + notifyOnDismissListener(); + if (mProvider != null) { + mProvider.subUiVisibilityChanged(false); + } + } + + private void notifyOnDismissListener() { + if (mOnDismissListener != null) { + mOnDismissListener.onDismiss(); + } + } + } + + private static class SetActivated { + public static void invoke(View view, boolean activated) { + view.setActivated(activated); + } + } + + private static final boolean IS_HONEYCOMB = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB; + + /** + * Adapter for backing the list of activities shown in the popup. + */ + private class ActivityChooserViewAdapter extends BaseAdapter { + + public static final int MAX_ACTIVITY_COUNT_UNLIMITED = Integer.MAX_VALUE; + + public static final int MAX_ACTIVITY_COUNT_DEFAULT = 4; + + private static final int ITEM_VIEW_TYPE_ACTIVITY = 0; + + private static final int ITEM_VIEW_TYPE_FOOTER = 1; + + private static final int ITEM_VIEW_TYPE_COUNT = 3; + + private ActivityChooserModel mDataModel; + + private int mMaxActivityCount = MAX_ACTIVITY_COUNT_DEFAULT; + + private boolean mShowDefaultActivity; + + private boolean mHighlightDefaultActivity; + + private boolean mShowFooterView; + + public void setDataModel(ActivityChooserModel dataModel) { + ActivityChooserModel oldDataModel = mAdapter.getDataModel(); + if (oldDataModel != null && isShown()) { + oldDataModel.unregisterObserver(mModelDataSetOberver); + } + mDataModel = dataModel; + if (dataModel != null && isShown()) { + dataModel.registerObserver(mModelDataSetOberver); + } + notifyDataSetChanged(); + } + + @Override + public int getItemViewType(int position) { + if (mShowFooterView && position == getCount() - 1) { + return ITEM_VIEW_TYPE_FOOTER; + } else { + return ITEM_VIEW_TYPE_ACTIVITY; + } + } + + @Override + public int getViewTypeCount() { + return ITEM_VIEW_TYPE_COUNT; + } + + public int getCount() { + int count = 0; + int activityCount = mDataModel.getActivityCount(); + if (!mShowDefaultActivity && mDataModel.getDefaultActivity() != null) { + activityCount--; + } + count = Math.min(activityCount, mMaxActivityCount); + if (mShowFooterView) { + count++; + } + return count; + } + + public Object getItem(int position) { + final int itemViewType = getItemViewType(position); + switch (itemViewType) { + case ITEM_VIEW_TYPE_FOOTER: + return null; + case ITEM_VIEW_TYPE_ACTIVITY: + if (!mShowDefaultActivity && mDataModel.getDefaultActivity() != null) { + position++; + } + return mDataModel.getActivity(position); + default: + throw new IllegalArgumentException(); + } + } + + public long getItemId(int position) { + return position; + } + + public View getView(int position, View convertView, ViewGroup parent) { + final int itemViewType = getItemViewType(position); + switch (itemViewType) { + case ITEM_VIEW_TYPE_FOOTER: + if (convertView == null || convertView.getId() != ITEM_VIEW_TYPE_FOOTER) { + convertView = LayoutInflater.from(getContext()).inflate( + R.layout.abs__activity_chooser_view_list_item, parent, false); + convertView.setId(ITEM_VIEW_TYPE_FOOTER); + TextView titleView = (TextView) convertView.findViewById(R.id.abs__title); + titleView.setText(mContext.getString( + R.string.abs__activity_chooser_view_see_all)); + } + return convertView; + case ITEM_VIEW_TYPE_ACTIVITY: + if (convertView == null || convertView.getId() != R.id.abs__list_item) { + convertView = LayoutInflater.from(getContext()).inflate( + R.layout.abs__activity_chooser_view_list_item, parent, false); + } + PackageManager packageManager = mContext.getPackageManager(); + // Set the icon + ImageView iconView = (ImageView) convertView.findViewById(R.id.abs__icon); + ResolveInfo activity = (ResolveInfo) getItem(position); + iconView.setImageDrawable(activity.loadIcon(packageManager)); + // Set the title. + TextView titleView = (TextView) convertView.findViewById(R.id.abs__title); + titleView.setText(activity.loadLabel(packageManager)); + if (IS_HONEYCOMB) { + // Highlight the default. + if (mShowDefaultActivity && position == 0 && mHighlightDefaultActivity) { + SetActivated.invoke(convertView, true); + } else { + SetActivated.invoke(convertView, false); + } + } + return convertView; + default: + throw new IllegalArgumentException(); + } + } + + public int measureContentWidth() { + // The user may have specified some of the target not to be shown but we + // want to measure all of them since after expansion they should fit. + final int oldMaxActivityCount = mMaxActivityCount; + mMaxActivityCount = MAX_ACTIVITY_COUNT_UNLIMITED; + + int contentWidth = 0; + View itemView = null; + + final int widthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); + final int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); + final int count = getCount(); + + for (int i = 0; i < count; i++) { + itemView = getView(i, itemView, null); + itemView.measure(widthMeasureSpec, heightMeasureSpec); + contentWidth = Math.max(contentWidth, itemView.getMeasuredWidth()); + } + + mMaxActivityCount = oldMaxActivityCount; + + return contentWidth; + } + + public void setMaxActivityCount(int maxActivityCount) { + if (mMaxActivityCount != maxActivityCount) { + mMaxActivityCount = maxActivityCount; + notifyDataSetChanged(); + } + } + + public ResolveInfo getDefaultActivity() { + return mDataModel.getDefaultActivity(); + } + + public void setShowFooterView(boolean showFooterView) { + if (mShowFooterView != showFooterView) { + mShowFooterView = showFooterView; + notifyDataSetChanged(); + } + } + + public int getActivityCount() { + return mDataModel.getActivityCount(); + } + + public int getHistorySize() { + return mDataModel.getHistorySize(); + } + + public int getMaxActivityCount() { + return mMaxActivityCount; + } + + public ActivityChooserModel getDataModel() { + return mDataModel; + } + + public void setShowDefaultActivity(boolean showDefaultActivity, + boolean highlightDefaultActivity) { + if (mShowDefaultActivity != showDefaultActivity + || mHighlightDefaultActivity != highlightDefaultActivity) { + mShowDefaultActivity = showDefaultActivity; + mHighlightDefaultActivity = highlightDefaultActivity; + notifyDataSetChanged(); + } + } + + public boolean getShowDefaultActivity() { + return mShowDefaultActivity; + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/widget/ShareActionProvider.java b/actionbarsherlock/src/com/actionbarsherlock/widget/ShareActionProvider.java new file mode 100644 index 000000000..83e9f0ca9 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/widget/ShareActionProvider.java @@ -0,0 +1,316 @@ +/* + * Copyright (C) 2011 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.actionbarsherlock.widget; + +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; +import android.graphics.drawable.Drawable; +import android.util.TypedValue; +import android.view.View; + +import com.actionbarsherlock.R; +import com.actionbarsherlock.view.ActionProvider; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuItem; +import com.actionbarsherlock.view.MenuItem.OnMenuItemClickListener; +import com.actionbarsherlock.view.SubMenu; +import com.actionbarsherlock.widget.ActivityChooserModel.OnChooseActivityListener; + +/** + * This is a provider for a share action. It is responsible for creating views + * that enable data sharing and also to show a sub menu with sharing activities + * if the hosting item is placed on the overflow menu. + *

+ * Here is how to use the action provider with custom backing file in a {@link MenuItem}: + *

+ *

+ *

+ * 
+ *  // In Activity#onCreateOptionsMenu
+ *  public boolean onCreateOptionsMenu(Menu menu) {
+ *      // Get the menu item.
+ *      MenuItem menuItem = menu.findItem(R.id.my_menu_item);
+ *      // Get the provider and hold onto it to set/change the share intent.
+ *      mShareActionProvider = (ShareActionProvider) menuItem.getActionProvider();
+ *      // Set history different from the default before getting the action
+ *      // view since a call to {@link MenuItem#getActionView() MenuItem.getActionView()} calls
+ *      // {@link ActionProvider#onCreateActionView()} which uses the backing file name. Omit this
+ *      // line if using the default share history file is desired.
+ *      mShareActionProvider.setShareHistoryFileName("custom_share_history.xml");
+ *      . . .
+ *  }
+ *
+ *  // Somewhere in the application.
+ *  public void doShare(Intent shareIntent) {
+ *      // When you want to share set the share intent.
+ *      mShareActionProvider.setShareIntent(shareIntent);
+ *  }
+ * 
+ * + *

+ *

+ * Note: While the sample snippet demonstrates how to use this provider + * in the context of a menu item, the use of the provider is not limited to menu items. + *

+ * + * @see ActionProvider + */ +public class ShareActionProvider extends ActionProvider { + + /** + * Listener for the event of selecting a share target. + */ + public interface OnShareTargetSelectedListener { + + /** + * Called when a share target has been selected. The client can + * decide whether to handle the intent or rely on the default + * behavior which is launching it. + *

+ * Note: Modifying the intent is not permitted and + * any changes to the latter will be ignored. + *

+ * + * @param source The source of the notification. + * @param intent The intent for launching the chosen share target. + * @return Whether the client has handled the intent. + */ + public boolean onShareTargetSelected(ShareActionProvider source, Intent intent); + } + + /** + * The default for the maximal number of activities shown in the sub-menu. + */ + private static final int DEFAULT_INITIAL_ACTIVITY_COUNT = 4; + + /** + * The the maximum number activities shown in the sub-menu. + */ + private int mMaxShownActivityCount = DEFAULT_INITIAL_ACTIVITY_COUNT; + + /** + * Listener for handling menu item clicks. + */ + private final ShareMenuItemOnMenuItemClickListener mOnMenuItemClickListener = + new ShareMenuItemOnMenuItemClickListener(); + + /** + * The default name for storing share history. + */ + public static final String DEFAULT_SHARE_HISTORY_FILE_NAME = "share_history.xml"; + + /** + * Context for accessing resources. + */ + private final Context mContext; + + /** + * The name of the file with share history data. + */ + private String mShareHistoryFileName = DEFAULT_SHARE_HISTORY_FILE_NAME; + + private OnShareTargetSelectedListener mOnShareTargetSelectedListener; + + private OnChooseActivityListener mOnChooseActivityListener; + + /** + * Creates a new instance. + * + * @param context Context for accessing resources. + */ + public ShareActionProvider(Context context) { + super(context); + mContext = context; + } + + /** + * Sets a listener to be notified when a share target has been selected. + * The listener can optionally decide to handle the selection and + * not rely on the default behavior which is to launch the activity. + *

+ * Note: If you choose the backing share history file + * you will still be notified in this callback. + *

+ * @param listener The listener. + */ + public void setOnShareTargetSelectedListener(OnShareTargetSelectedListener listener) { + mOnShareTargetSelectedListener = listener; + setActivityChooserPolicyIfNeeded(); + } + + /** + * {@inheritDoc} + */ + @Override + public View onCreateActionView() { + // Create the view and set its data model. + ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName); + ActivityChooserView activityChooserView = new ActivityChooserView(mContext); + activityChooserView.setActivityChooserModel(dataModel); + + // Lookup and set the expand action icon. + TypedValue outTypedValue = new TypedValue(); + mContext.getTheme().resolveAttribute(R.attr.actionModeShareDrawable, outTypedValue, true); + Drawable drawable = mContext.getResources().getDrawable(outTypedValue.resourceId); + activityChooserView.setExpandActivityOverflowButtonDrawable(drawable); + activityChooserView.setProvider(this); + + // Set content description. + activityChooserView.setDefaultActionButtonContentDescription( + R.string.abs__shareactionprovider_share_with_application); + activityChooserView.setExpandActivityOverflowButtonContentDescription( + R.string.abs__shareactionprovider_share_with); + + return activityChooserView; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean hasSubMenu() { + return true; + } + + /** + * {@inheritDoc} + */ + @Override + public void onPrepareSubMenu(SubMenu subMenu) { + // Clear since the order of items may change. + subMenu.clear(); + + ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName); + PackageManager packageManager = mContext.getPackageManager(); + + final int expandedActivityCount = dataModel.getActivityCount(); + final int collapsedActivityCount = Math.min(expandedActivityCount, mMaxShownActivityCount); + + // Populate the sub-menu with a sub set of the activities. + for (int i = 0; i < collapsedActivityCount; i++) { + ResolveInfo activity = dataModel.getActivity(i); + subMenu.add(0, i, i, activity.loadLabel(packageManager)) + .setIcon(activity.loadIcon(packageManager)) + .setOnMenuItemClickListener(mOnMenuItemClickListener); + } + + if (collapsedActivityCount < expandedActivityCount) { + // Add a sub-menu for showing all activities as a list item. + SubMenu expandedSubMenu = subMenu.addSubMenu(Menu.NONE, collapsedActivityCount, + collapsedActivityCount, + mContext.getString(R.string.abs__activity_chooser_view_see_all)); + for (int i = 0; i < expandedActivityCount; i++) { + ResolveInfo activity = dataModel.getActivity(i); + expandedSubMenu.add(0, i, i, activity.loadLabel(packageManager)) + .setIcon(activity.loadIcon(packageManager)) + .setOnMenuItemClickListener(mOnMenuItemClickListener); + } + } + } + + /** + * Sets the file name of a file for persisting the share history which + * history will be used for ordering share targets. This file will be used + * for all view created by {@link #onCreateActionView()}. Defaults to + * {@link #DEFAULT_SHARE_HISTORY_FILE_NAME}. Set to null + * if share history should not be persisted between sessions. + *

+ * Note: The history file name can be set any time, however + * only the action views created by {@link #onCreateActionView()} after setting + * the file name will be backed by the provided file. + *

+ * + * @param shareHistoryFile The share history file name. + */ + public void setShareHistoryFileName(String shareHistoryFile) { + mShareHistoryFileName = shareHistoryFile; + setActivityChooserPolicyIfNeeded(); + } + + /** + * Sets an intent with information about the share action. Here is a + * sample for constructing a share intent: + *

+ *

+     * 
+     *  Intent shareIntent = new Intent(Intent.ACTION_SEND);
+     *  shareIntent.setType("image/*");
+     *  Uri uri = Uri.fromFile(new File(getFilesDir(), "foo.jpg"));
+     *  shareIntent.putExtra(Intent.EXTRA_STREAM, uri.toString());
+     * 
+ * + *

+ * + * @param shareIntent The share intent. + * + * @see Intent#ACTION_SEND + * @see Intent#ACTION_SEND_MULTIPLE + */ + public void setShareIntent(Intent shareIntent) { + ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, + mShareHistoryFileName); + dataModel.setIntent(shareIntent); + } + + /** + * Reusable listener for handling share item clicks. + */ + private class ShareMenuItemOnMenuItemClickListener implements OnMenuItemClickListener { + @Override + public boolean onMenuItemClick(MenuItem item) { + ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, + mShareHistoryFileName); + final int itemId = item.getItemId(); + Intent launchIntent = dataModel.chooseActivity(itemId); + if (launchIntent != null) { + mContext.startActivity(launchIntent); + } + return true; + } + } + + /** + * Set the activity chooser policy of the model backed by the current + * share history file if needed which is if there is a registered callback. + */ + private void setActivityChooserPolicyIfNeeded() { + if (mOnShareTargetSelectedListener == null) { + return; + } + if (mOnChooseActivityListener == null) { + mOnChooseActivityListener = new ShareAcitivityChooserModelPolicy(); + } + ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName); + dataModel.setOnChooseActivityListener(mOnChooseActivityListener); + } + + /** + * Policy that delegates to the {@link OnShareTargetSelectedListener}, if such. + */ + private class ShareAcitivityChooserModelPolicy implements OnChooseActivityListener { + @Override + public boolean onChooseActivity(ActivityChooserModel host, Intent intent) { + if (mOnShareTargetSelectedListener != null) { + return mOnShareTargetSelectedListener.onShareTargetSelected( + ShareActionProvider.this, intent); + } + return false; + } + } +} diff --git a/proguard.flags b/proguard.flags index 66e53673e..15e97434e 100644 --- a/proguard.flags +++ b/proguard.flags @@ -35,3 +35,11 @@ # Disable the warnings of using dynamic method calls in EffectsRecorder -dontnote com.android.camera.EffectsRecorder + +# Required for ActionBarSherlock +-keep class android.support.v4.app.** { *; } +-keep interface android.support.v4.app.** { *; } +-keep class com.actionbarsherlock.** { *; } +-keep interface com.actionbarsherlock.** { *; } +-keepattributes *Annotation* + diff --git a/res/values/styles.xml b/res/values/styles.xml index 9bbee9191..10354a146 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -15,7 +15,7 @@ --> - diff --git a/src/com/android/gallery3d/app/MovieActivity.java b/src/com/android/gallery3d/app/MovieActivity.java index 26ae37e43..bf2486927 100644 --- a/src/com/android/gallery3d/app/MovieActivity.java +++ b/src/com/android/gallery3d/app/MovieActivity.java @@ -17,7 +17,6 @@ package com.android.gallery3d.app; import android.annotation.TargetApi; -import android.app.Activity; import android.content.AsyncQueryHandler; import android.content.ContentResolver; import android.content.Intent; @@ -32,12 +31,14 @@ import android.os.Bundle; import android.provider.MediaStore; import android.provider.OpenableColumns; import android.view.KeyEvent; -import android.view.Menu; -import android.view.MenuItem; import android.view.View; import android.view.Window; import android.view.WindowManager; +import com.actionbarsherlock.app.ActionBar; +import com.actionbarsherlock.app.SherlockActivity; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuItem; import com.android.gallery3d.R; import com.android.gallery3d.actionbar.ActionBarInterface; import com.android.gallery3d.actionbar.ActionBarUtils; @@ -51,7 +52,7 @@ import com.android.gallery3d.common.Utils; * to set the action bar logo so the playback process looks more seamlessly integrated with * the original activity. */ -public class MovieActivity extends Activity { +public class MovieActivity extends SherlockActivity { @SuppressWarnings("unused") private static final String TAG = "MovieActivity"; public static final String KEY_LOGO_BITMAP = "logo-bitmap"; @@ -116,19 +117,17 @@ public class MovieActivity extends Activity { win.setBackgroundDrawable(null); } - @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) private void setActionBarLogoFromIntent(Intent intent) { - if (ApiHelper.HAS_ACTION_BAR_SET_LOGO) { - Bitmap logo = intent.getParcelableExtra(KEY_LOGO_BITMAP); - if (logo != null) { - getActionBar().setLogo(new BitmapDrawable(getResources(), logo)); - } + Bitmap logo = intent.getParcelableExtra(KEY_LOGO_BITMAP); + if (logo != null) { + getSupportActionBar().setLogo( + new BitmapDrawable(getResources(), logo)); } } private void initializeActionBar(Intent intent) { mUri = intent.getData(); - final ActionBarInterface actionBar = ActionBarUtils.getActionBar(this); + final ActionBar actionBar = getSupportActionBar(); setActionBarLogoFromIntent(intent); actionBar.setDisplayOptions(ActionBarInterface.DISPLAY_HOME_AS_UP, ActionBarInterface.DISPLAY_HOME_AS_UP); @@ -168,7 +167,8 @@ public class MovieActivity extends Activity { public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); ActionBarInterface actionBar = ActionBarUtils.getActionBar(this); - boolean result = actionBar.createActionMenu(menu, R.menu.movie); + getSupportMenuInflater().inflate(R.menu.movie, menu); + // Document says EXTRA_STREAM should be a content: Uri // So, we only share the video if it's "content:". if (ContentResolver.SCHEME_CONTENT.equals(mUri.getScheme())) { @@ -178,7 +178,7 @@ public class MovieActivity extends Activity { } else { menu.findItem(R.id.action_share).setVisible(false); } - return result; + return true; } private Intent createShareIntent() { -- GitLab From 13da281769d4558c42d86a54536ff6da6826b0ac Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Fri, 24 Aug 2012 13:02:22 +0800 Subject: [PATCH 207/763] Revert "Uses ActionBarSherlock library in MovieActivity." This reverts commit 89b437722a24d0c7d6e2acffc30c215f22814234. --- Android.mk | 9 +- ...s__primary_text_disable_only_holo_dark.xml | 20 - ...__primary_text_disable_only_holo_light.xml | 21 - .../res/color/abs__primary_text_holo_dark.xml | 24 - .../color/abs__primary_text_holo_light.xml | 26 - .../abs__ab_bottom_solid_dark_holo.9.png | Bin 144 -> 0 bytes .../abs__ab_bottom_solid_inverse_holo.9.png | Bin 138 -> 0 bytes .../abs__ab_bottom_solid_light_holo.9.png | Bin 144 -> 0 bytes ...abs__ab_bottom_transparent_dark_holo.9.png | Bin 135 -> 0 bytes ...bs__ab_bottom_transparent_light_holo.9.png | Bin 134 -> 0 bytes .../abs__ab_share_pack_holo_dark.9.png | Bin 2866 -> 0 bytes .../abs__ab_share_pack_holo_light.9.png | Bin 2862 -> 0 bytes .../abs__ab_solid_dark_holo.9.png | Bin 146 -> 0 bytes .../abs__ab_solid_light_holo.9.png | Bin 145 -> 0 bytes .../abs__ab_solid_shadow_holo.9.png | Bin 192 -> 0 bytes .../abs__ab_stacked_solid_dark_holo.9.png | Bin 146 -> 0 bytes .../abs__ab_stacked_solid_light_holo.9.png | Bin 146 -> 0 bytes ...bs__ab_stacked_transparent_dark_holo.9.png | Bin 139 -> 0 bytes ...s__ab_stacked_transparent_light_holo.9.png | Bin 133 -> 0 bytes .../abs__ab_transparent_dark_holo.9.png | Bin 155 -> 0 bytes .../abs__ab_transparent_light_holo.9.png | Bin 145 -> 0 bytes .../abs__btn_cab_done_default_holo_dark.9.png | Bin 104 -> 0 bytes ...abs__btn_cab_done_default_holo_light.9.png | Bin 102 -> 0 bytes .../abs__btn_cab_done_focused_holo_dark.9.png | Bin 112 -> 0 bytes ...abs__btn_cab_done_focused_holo_light.9.png | Bin 108 -> 0 bytes .../abs__btn_cab_done_pressed_holo_dark.9.png | Bin 110 -> 0 bytes ...abs__btn_cab_done_pressed_holo_light.9.png | Bin 108 -> 0 bytes ...abs__cab_background_bottom_holo_dark.9.png | Bin 149 -> 0 bytes ...bs__cab_background_bottom_holo_light.9.png | Bin 145 -> 0 bytes .../abs__cab_background_top_holo_dark.9.png | Bin 147 -> 0 bytes .../abs__cab_background_top_holo_light.9.png | Bin 147 -> 0 bytes .../abs__dialog_full_holo_dark.9.png | Bin 1414 -> 0 bytes .../abs__dialog_full_holo_light.9.png | Bin 1537 -> 0 bytes .../abs__ic_ab_back_holo_dark.png | Bin 602 -> 0 bytes .../abs__ic_ab_back_holo_light.png | Bin 546 -> 0 bytes .../abs__ic_cab_done_holo_dark.png | Bin 713 -> 0 bytes .../abs__ic_cab_done_holo_light.png | Bin 737 -> 0 bytes ..._ic_menu_moreoverflow_normal_holo_dark.png | Bin 144 -> 0 bytes ...ic_menu_moreoverflow_normal_holo_light.png | Bin 148 -> 0 bytes .../abs__ic_menu_share_holo_dark.png | Bin 467 -> 0 bytes .../abs__ic_menu_share_holo_light.png | Bin 505 -> 0 bytes .../abs__list_activated_holo.9.png | Bin 154 -> 0 bytes .../abs__list_divider_holo_dark.9.png | Bin 78 -> 0 bytes .../abs__list_divider_holo_light.9.png | Bin 76 -> 0 bytes .../abs__list_focused_holo.9.png | Bin 159 -> 0 bytes .../abs__list_longpressed_holo.9.png | Bin 154 -> 0 bytes .../abs__list_pressed_holo_dark.9.png | Bin 159 -> 0 bytes .../abs__list_pressed_holo_light.9.png | Bin 159 -> 0 bytes ...bs__list_selector_disabled_holo_dark.9.png | Bin 189 -> 0 bytes ...s__list_selector_disabled_holo_light.9.png | Bin 189 -> 0 bytes .../abs__menu_dropdown_panel_holo_dark.9.png | Bin 922 -> 0 bytes .../abs__menu_dropdown_panel_holo_light.9.png | Bin 1061 -> 0 bytes .../abs__progress_bg_holo_dark.9.png | Bin 178 -> 0 bytes .../abs__progress_bg_holo_light.9.png | Bin 174 -> 0 bytes .../abs__progress_primary_holo_dark.9.png | Bin 917 -> 0 bytes .../abs__progress_primary_holo_light.9.png | Bin 917 -> 0 bytes .../abs__progress_secondary_holo_dark.9.png | Bin 188 -> 0 bytes .../abs__progress_secondary_holo_light.9.png | Bin 188 -> 0 bytes .../abs__spinner_48_inner_holo.png | Bin 2081 -> 0 bytes .../abs__spinner_48_outer_holo.png | Bin 1811 -> 0 bytes .../abs__spinner_ab_default_holo_dark.9.png | Bin 311 -> 0 bytes .../abs__spinner_ab_default_holo_light.9.png | Bin 312 -> 0 bytes .../abs__spinner_ab_disabled_holo_dark.9.png | Bin 306 -> 0 bytes .../abs__spinner_ab_disabled_holo_light.9.png | Bin 306 -> 0 bytes .../abs__spinner_ab_focused_holo_dark.9.png | Bin 524 -> 0 bytes .../abs__spinner_ab_focused_holo_light.9.png | Bin 523 -> 0 bytes .../abs__spinner_ab_pressed_holo_dark.9.png | Bin 464 -> 0 bytes .../abs__spinner_ab_pressed_holo_light.9.png | Bin 458 -> 0 bytes .../abs__tab_selected_focused_holo.9.png | Bin 147 -> 0 bytes .../abs__tab_selected_holo.9.png | Bin 148 -> 0 bytes .../abs__tab_selected_pressed_holo.9.png | Bin 147 -> 0 bytes .../abs__tab_unselected_pressed_holo.9.png | Bin 145 -> 0 bytes .../abs__ab_bottom_solid_dark_holo.9.png | Bin 134 -> 0 bytes .../abs__ab_bottom_solid_inverse_holo.9.png | Bin 129 -> 0 bytes .../abs__ab_bottom_solid_light_holo.9.png | Bin 134 -> 0 bytes ...abs__ab_bottom_transparent_dark_holo.9.png | Bin 123 -> 0 bytes ...bs__ab_bottom_transparent_light_holo.9.png | Bin 123 -> 0 bytes .../abs__ab_share_pack_holo_dark.9.png | Bin 2851 -> 0 bytes .../abs__ab_share_pack_holo_light.9.png | Bin 122 -> 0 bytes .../abs__ab_solid_dark_holo.9.png | Bin 133 -> 0 bytes .../abs__ab_solid_light_holo.9.png | Bin 133 -> 0 bytes .../abs__ab_solid_shadow_holo.9.png | Bin 168 -> 0 bytes .../abs__ab_stacked_solid_dark_holo.9.png | Bin 134 -> 0 bytes .../abs__ab_stacked_solid_light_holo.9.png | Bin 133 -> 0 bytes ...bs__ab_stacked_transparent_dark_holo.9.png | Bin 127 -> 0 bytes ...s__ab_stacked_transparent_light_holo.9.png | Bin 123 -> 0 bytes .../abs__ab_transparent_dark_holo.9.png | Bin 139 -> 0 bytes .../abs__ab_transparent_light_holo.9.png | Bin 133 -> 0 bytes .../abs__btn_cab_done_default_holo_dark.9.png | Bin 101 -> 0 bytes ...abs__btn_cab_done_default_holo_light.9.png | Bin 99 -> 0 bytes .../abs__btn_cab_done_focused_holo_dark.9.png | Bin 109 -> 0 bytes ...abs__btn_cab_done_focused_holo_light.9.png | Bin 105 -> 0 bytes .../abs__btn_cab_done_pressed_holo_dark.9.png | Bin 107 -> 0 bytes ...abs__btn_cab_done_pressed_holo_light.9.png | Bin 105 -> 0 bytes ...abs__cab_background_bottom_holo_dark.9.png | Bin 127 -> 0 bytes ...bs__cab_background_bottom_holo_light.9.png | Bin 124 -> 0 bytes .../abs__cab_background_top_holo_dark.9.png | Bin 130 -> 0 bytes .../abs__cab_background_top_holo_light.9.png | Bin 128 -> 0 bytes .../abs__dialog_full_holo_dark.9.png | Bin 882 -> 0 bytes .../abs__dialog_full_holo_light.9.png | Bin 1003 -> 0 bytes .../abs__ic_ab_back_holo_dark.png | Bin 466 -> 0 bytes .../abs__ic_ab_back_holo_light.png | Bin 438 -> 0 bytes .../abs__ic_cab_done_holo_dark.png | Bin 566 -> 0 bytes .../abs__ic_cab_done_holo_light.png | Bin 552 -> 0 bytes ..._ic_menu_moreoverflow_normal_holo_dark.png | Bin 122 -> 0 bytes ...ic_menu_moreoverflow_normal_holo_light.png | Bin 131 -> 0 bytes .../abs__ic_menu_share_holo_dark.png | Bin 332 -> 0 bytes .../abs__ic_menu_share_holo_light.png | Bin 355 -> 0 bytes .../abs__list_activated_holo.9.png | Bin 151 -> 0 bytes .../abs__list_divider_holo_dark.9.png | Bin 78 -> 0 bytes .../abs__list_divider_holo_light.9.png | Bin 76 -> 0 bytes .../abs__list_focused_holo.9.png | Bin 158 -> 0 bytes .../abs__list_longpressed_holo.9.png | Bin 151 -> 0 bytes .../abs__list_pressed_holo_dark.9.png | Bin 158 -> 0 bytes .../abs__list_pressed_holo_light.9.png | Bin 158 -> 0 bytes ...bs__list_selector_disabled_holo_dark.9.png | Bin 172 -> 0 bytes ...s__list_selector_disabled_holo_light.9.png | Bin 171 -> 0 bytes .../abs__menu_dropdown_panel_holo_dark.9.png | Bin 651 -> 0 bytes .../abs__menu_dropdown_panel_holo_light.9.png | Bin 720 -> 0 bytes .../abs__progress_bg_holo_dark.9.png | Bin 165 -> 0 bytes .../abs__progress_bg_holo_light.9.png | Bin 159 -> 0 bytes .../abs__progress_primary_holo_dark.9.png | Bin 572 -> 0 bytes .../abs__progress_primary_holo_light.9.png | Bin 572 -> 0 bytes .../abs__progress_secondary_holo_dark.9.png | Bin 170 -> 0 bytes .../abs__progress_secondary_holo_light.9.png | Bin 170 -> 0 bytes .../abs__spinner_48_inner_holo.png | Bin 1336 -> 0 bytes .../abs__spinner_48_outer_holo.png | Bin 1165 -> 0 bytes .../abs__spinner_ab_default_holo_dark.9.png | Bin 254 -> 0 bytes .../abs__spinner_ab_default_holo_light.9.png | Bin 255 -> 0 bytes .../abs__spinner_ab_disabled_holo_dark.9.png | Bin 249 -> 0 bytes .../abs__spinner_ab_disabled_holo_light.9.png | Bin 249 -> 0 bytes .../abs__spinner_ab_focused_holo_dark.9.png | Bin 417 -> 0 bytes .../abs__spinner_ab_focused_holo_light.9.png | Bin 424 -> 0 bytes .../abs__spinner_ab_pressed_holo_dark.9.png | Bin 370 -> 0 bytes .../abs__spinner_ab_pressed_holo_light.9.png | Bin 370 -> 0 bytes .../abs__tab_selected_focused_holo.9.png | Bin 148 -> 0 bytes .../abs__tab_selected_holo.9.png | Bin 151 -> 0 bytes .../abs__tab_selected_pressed_holo.9.png | Bin 150 -> 0 bytes .../abs__tab_unselected_pressed_holo.9.png | Bin 155 -> 0 bytes .../abs__progress_medium_holo.xml | 34 - .../abs__ab_bottom_solid_dark_holo.9.png | Bin 165 -> 0 bytes .../abs__ab_bottom_solid_inverse_holo.9.png | Bin 157 -> 0 bytes .../abs__ab_bottom_solid_light_holo.9.png | Bin 166 -> 0 bytes ...abs__ab_bottom_transparent_dark_holo.9.png | Bin 153 -> 0 bytes ...bs__ab_bottom_transparent_light_holo.9.png | Bin 152 -> 0 bytes .../abs__ab_share_pack_holo_dark.9.png | Bin 2875 -> 0 bytes .../abs__ab_share_pack_holo_light.9.png | Bin 2869 -> 0 bytes .../abs__ab_solid_dark_holo.9.png | Bin 163 -> 0 bytes .../abs__ab_solid_light_holo.9.png | Bin 163 -> 0 bytes .../abs__ab_solid_shadow_holo.9.png | Bin 290 -> 0 bytes .../abs__ab_stacked_solid_dark_holo.9.png | Bin 163 -> 0 bytes .../abs__ab_stacked_solid_light_holo.9.png | Bin 163 -> 0 bytes ...bs__ab_stacked_transparent_dark_holo.9.png | Bin 158 -> 0 bytes ...s__ab_stacked_transparent_light_holo.9.png | Bin 152 -> 0 bytes .../abs__ab_transparent_dark_holo.9.png | Bin 171 -> 0 bytes .../abs__ab_transparent_light_holo.9.png | Bin 160 -> 0 bytes .../abs__btn_cab_done_default_holo_dark.9.png | Bin 109 -> 0 bytes ...abs__btn_cab_done_default_holo_light.9.png | Bin 108 -> 0 bytes .../abs__btn_cab_done_focused_holo_dark.9.png | Bin 112 -> 0 bytes ...abs__btn_cab_done_focused_holo_light.9.png | Bin 113 -> 0 bytes .../abs__btn_cab_done_pressed_holo_dark.9.png | Bin 115 -> 0 bytes ...abs__btn_cab_done_pressed_holo_light.9.png | Bin 113 -> 0 bytes ...abs__cab_background_bottom_holo_dark.9.png | Bin 166 -> 0 bytes ...bs__cab_background_bottom_holo_light.9.png | Bin 161 -> 0 bytes .../abs__cab_background_top_holo_dark.9.png | Bin 174 -> 0 bytes .../abs__cab_background_top_holo_light.9.png | Bin 161 -> 0 bytes .../abs__dialog_full_holo_dark.9.png | Bin 2159 -> 0 bytes .../abs__dialog_full_holo_light.9.png | Bin 2302 -> 0 bytes .../abs__ic_ab_back_holo_dark.png | Bin 741 -> 0 bytes .../abs__ic_ab_back_holo_light.png | Bin 661 -> 0 bytes .../abs__ic_cab_done_holo_dark.png | Bin 970 -> 0 bytes .../abs__ic_cab_done_holo_light.png | Bin 915 -> 0 bytes ..._ic_menu_moreoverflow_normal_holo_dark.png | Bin 167 -> 0 bytes ...ic_menu_moreoverflow_normal_holo_light.png | Bin 184 -> 0 bytes .../abs__ic_menu_share_holo_dark.png | Bin 699 -> 0 bytes .../abs__ic_menu_share_holo_light.png | Bin 935 -> 0 bytes .../abs__list_activated_holo.9.png | Bin 158 -> 0 bytes .../abs__list_divider_holo_dark.9.png | Bin 83 -> 0 bytes .../abs__list_divider_holo_light.9.png | Bin 83 -> 0 bytes .../abs__list_focused_holo.9.png | Bin 163 -> 0 bytes .../abs__list_longpressed_holo.9.png | Bin 158 -> 0 bytes .../abs__list_pressed_holo_dark.9.png | Bin 163 -> 0 bytes .../abs__list_pressed_holo_light.9.png | Bin 163 -> 0 bytes ...bs__list_selector_disabled_holo_dark.9.png | Bin 190 -> 0 bytes ...s__list_selector_disabled_holo_light.9.png | Bin 188 -> 0 bytes .../abs__menu_dropdown_panel_holo_dark.9.png | Bin 1362 -> 0 bytes .../abs__menu_dropdown_panel_holo_light.9.png | Bin 1551 -> 0 bytes .../abs__progress_bg_holo_dark.9.png | Bin 174 -> 0 bytes .../abs__progress_bg_holo_light.9.png | Bin 172 -> 0 bytes .../abs__progress_primary_holo_dark.9.png | Bin 1309 -> 0 bytes .../abs__progress_primary_holo_light.9.png | Bin 1309 -> 0 bytes .../abs__progress_secondary_holo_dark.9.png | Bin 184 -> 0 bytes .../abs__progress_secondary_holo_light.9.png | Bin 184 -> 0 bytes .../abs__spinner_48_inner_holo.png | Bin 2769 -> 0 bytes .../abs__spinner_48_outer_holo.png | Bin 2432 -> 0 bytes .../abs__spinner_ab_default_holo_dark.9.png | Bin 395 -> 0 bytes .../abs__spinner_ab_default_holo_light.9.png | Bin 394 -> 0 bytes .../abs__spinner_ab_disabled_holo_dark.9.png | Bin 381 -> 0 bytes .../abs__spinner_ab_disabled_holo_light.9.png | Bin 381 -> 0 bytes .../abs__spinner_ab_focused_holo_dark.9.png | Bin 680 -> 0 bytes .../abs__spinner_ab_focused_holo_light.9.png | Bin 671 -> 0 bytes .../abs__spinner_ab_pressed_holo_dark.9.png | Bin 609 -> 0 bytes .../abs__spinner_ab_pressed_holo_light.9.png | Bin 602 -> 0 bytes .../abs__tab_selected_focused_holo.9.png | Bin 147 -> 0 bytes .../abs__tab_selected_holo.9.png | Bin 153 -> 0 bytes .../abs__tab_selected_pressed_holo.9.png | Bin 147 -> 0 bytes .../abs__tab_unselected_pressed_holo.9.png | Bin 149 -> 0 bytes .../abs__activated_background_holo_dark.xml | 20 - .../abs__activated_background_holo_light.xml | 20 - .../drawable/abs__btn_cab_done_holo_dark.xml | 24 - .../drawable/abs__btn_cab_done_holo_light.xml | 24 - .../abs__ic_menu_moreoverflow_holo_dark.xml | 18 - .../abs__ic_menu_moreoverflow_holo_light.xml | 18 - .../abs__item_background_holo_dark.xml | 26 - .../abs__item_background_holo_light.xml | 26 - ...lector_background_transition_holo_dark.xml | 20 - ...ector_background_transition_holo_light.xml | 20 - .../drawable/abs__list_selector_holo_dark.xml | 27 - .../abs__list_selector_holo_light.xml | 28 - .../abs__progress_horizontal_holo_dark.xml | 32 - .../abs__progress_horizontal_holo_light.xml | 32 - .../drawable/abs__progress_medium_holo.xml | 34 - .../drawable/abs__spinner_ab_holo_dark.xml | 25 - .../drawable/abs__spinner_ab_holo_light.xml | 25 - .../drawable/abs__tab_indicator_ab_holo.xml | 34 - .../abs__action_mode_close_item.xml | 40 - .../sherlock_spinner_dropdown_item.xml | 26 - .../res/layout-v14/sherlock_spinner_item.xml | 26 - .../layout-xlarge/abs__screen_action_bar.xml | 50 - .../abs__screen_action_bar_overlay.xml | 49 - .../res/layout/abs__action_bar_home.xml | 38 - .../res/layout/abs__action_bar_tab.xml | 7 - .../layout/abs__action_bar_tab_bar_view.xml | 6 - .../res/layout/abs__action_bar_title_item.xml | 50 - .../layout/abs__action_menu_item_layout.xml | 56 - .../res/layout/abs__action_menu_layout.xml | 23 - .../res/layout/abs__action_mode_bar.xml | 24 - .../layout/abs__action_mode_close_item.xml | 31 - .../res/layout/abs__activity_chooser_view.xml | 70 - .../abs__activity_chooser_view_list_item.xml | 53 - .../res/layout/abs__dialog_title_holo.xml | 46 - .../layout/abs__list_menu_item_checkbox.xml | 26 - .../res/layout/abs__list_menu_item_icon.xml | 28 - .../res/layout/abs__list_menu_item_layout.xml | 59 - .../res/layout/abs__list_menu_item_radio.xml | 24 - .../layout/abs__popup_menu_item_layout.xml | 60 - .../res/layout/abs__screen_action_bar.xml | 57 - .../layout/abs__screen_action_bar_overlay.xml | 59 - .../res/layout/abs__screen_simple.xml | 38 - ...abs__screen_simple_overlay_action_mode.xml | 38 - .../layout/sherlock_spinner_dropdown_item.xml | 26 - .../res/layout/sherlock_spinner_item.xml | 26 - .../res/values-land/abs__dimens.xml | 33 - .../abs__dimens.xml | 33 - .../abs__dimens.xml | 33 - .../abs__dimens.xml | 33 - .../abs__dimens.xml | 36 - .../res/values-large/abs__dimens.xml | 29 - .../res/values-sw600dp/abs__bools.xml | 19 - .../res/values-sw600dp/abs__dimens.xml | 38 - .../res/values-v11/abs__themes.xml | 12 - .../res/values-v14/abs__styles.xml | 118 -- .../res/values-v14/abs__themes.xml | 32 - .../res/values-w360dp/abs__dimens.xml | 22 - .../res/values-w480dp/abs__bools.xml | 22 - .../res/values-w480dp/abs__config.xml | 29 - .../res/values-w500dp/abs__dimens.xml | 22 - .../res/values-w600dp/abs__dimens.xml | 22 - .../res/values-xlarge/abs__dimens.xml | 45 - actionbarsherlock/res/values/abs__attrs.xml | 380 ---- actionbarsherlock/res/values/abs__bools.xml | 22 - actionbarsherlock/res/values/abs__colors.xml | 27 - actionbarsherlock/res/values/abs__config.xml | 43 - actionbarsherlock/res/values/abs__dimens.xml | 50 - actionbarsherlock/res/values/abs__ids.xml | 26 - actionbarsherlock/res/values/abs__strings.xml | 42 - actionbarsherlock/res/values/abs__styles.xml | 384 ---- actionbarsherlock/res/values/abs__themes.xml | 226 --- .../v4/app/_ActionBarSherlockTrojanHorse.java | 144 -- .../actionbarsherlock/ActionBarSherlock.java | 791 --------- .../com/actionbarsherlock/app/ActionBar.java | 947 ---------- .../app/SherlockActivity.java | 259 --- .../app/SherlockDialogFragment.java | 68 - .../app/SherlockExpandableListActivity.java | 259 --- .../app/SherlockFragment.java | 68 - .../app/SherlockFragmentActivity.java | 292 ---- .../app/SherlockListActivity.java | 259 --- .../app/SherlockListFragment.java | 68 - .../app/SherlockPreferenceActivity.java | 259 --- .../internal/ActionBarSherlockCompat.java | 1207 ------------- .../internal/ActionBarSherlockNative.java | 328 ---- .../internal/ResourcesCompat.java | 95 - .../internal/app/ActionBarImpl.java | 1026 ----------- .../internal/app/ActionBarWrapper.java | 468 ----- .../nineoldandroids/animation/Animator.java | 278 --- .../animation/AnimatorListenerAdapter.java | 54 - .../animation/AnimatorSet.java | 1111 ------------ .../animation/FloatEvaluator.java | 42 - .../animation/FloatKeyframeSet.java | 136 -- .../animation/IntEvaluator.java | 42 - .../animation/IntKeyframeSet.java | 135 -- .../nineoldandroids/animation/Keyframe.java | 361 ---- .../animation/KeyframeSet.java | 227 --- .../animation/ObjectAnimator.java | 491 ------ .../animation/PropertyValuesHolder.java | 1012 ----------- .../animation/TypeEvaluator.java | 44 - .../animation/ValueAnimator.java | 1265 -------------- .../nineoldandroids/view/NineViewGroup.java | 79 - .../view/animation/AnimatorProxy.java | 212 --- .../widget/NineFrameLayout.java | 65 - .../widget/NineHorizontalScrollView.java | 41 - .../widget/NineLinearLayout.java | 65 - .../internal/view/ActionProviderWrapper.java | 40 - .../internal/view/StandaloneActionMode.java | 148 -- .../view/View_HasStateListenerSupport.java | 6 - .../View_OnAttachStateChangeListener.java | 8 - .../internal/view/menu/ActionMenu.java | 264 --- .../internal/view/menu/ActionMenuItem.java | 278 --- .../view/menu/ActionMenuItemView.java | 295 ---- .../view/menu/ActionMenuPresenter.java | 721 -------- .../internal/view/menu/ActionMenuView.java | 572 ------ .../internal/view/menu/BaseMenuPresenter.java | 231 --- .../internal/view/menu/ListMenuItemView.java | 278 --- .../internal/view/menu/MenuBuilder.java | 1335 -------------- .../internal/view/menu/MenuItemImpl.java | 647 ------- .../internal/view/menu/MenuItemWrapper.java | 292 ---- .../internal/view/menu/MenuPopupHelper.java | 376 ---- .../internal/view/menu/MenuPresenter.java | 148 -- .../internal/view/menu/MenuView.java | 120 -- .../internal/view/menu/MenuWrapper.java | 180 -- .../internal/view/menu/SubMenuBuilder.java | 134 -- .../internal/view/menu/SubMenuWrapper.java | 72 - .../internal/widget/AbsActionBarView.java | 291 ---- .../internal/widget/ActionBarContainer.java | 245 --- .../internal/widget/ActionBarContextView.java | 518 ------ .../internal/widget/ActionBarView.java | 1548 ----------------- .../internal/widget/CapitalizingButton.java | 40 - .../internal/widget/CapitalizingTextView.java | 44 - .../widget/FakeDialogPhoneWindow.java | 64 - .../internal/widget/IcsAbsSpinner.java | 479 ----- .../internal/widget/IcsAdapterView.java | 1160 ------------ .../internal/widget/IcsLinearLayout.java | 272 --- .../internal/widget/IcsListPopupWindow.java | 644 ------- .../internal/widget/IcsProgressBar.java | 1193 ------------- .../internal/widget/IcsSpinner.java | 703 -------- .../internal/widget/IcsView.java | 21 - .../widget/ScrollingTabContainerView.java | 545 ------ .../actionbarsherlock/view/ActionMode.java | 224 --- .../view/ActionProvider.java | 170 -- .../view/CollapsibleActionView.java | 39 - .../src/com/actionbarsherlock/view/Menu.java | 447 ----- .../actionbarsherlock/view/MenuInflater.java | 472 ----- .../com/actionbarsherlock/view/MenuItem.java | 598 ------- .../com/actionbarsherlock/view/SubMenu.java | 110 -- .../com/actionbarsherlock/view/Window.java | 65 - .../widget/ActivityChooserModel.java | 1131 ------------ .../widget/ActivityChooserView.java | 818 --------- .../widget/ShareActionProvider.java | 316 ---- proguard.flags | 8 - res/values/styles.xml | 2 +- .../android/gallery3d/app/MovieActivity.java | 26 +- 361 files changed, 16 insertions(+), 33921 deletions(-) delete mode 100644 actionbarsherlock/res/color/abs__primary_text_disable_only_holo_dark.xml delete mode 100644 actionbarsherlock/res/color/abs__primary_text_disable_only_holo_light.xml delete mode 100644 actionbarsherlock/res/color/abs__primary_text_holo_dark.xml delete mode 100644 actionbarsherlock/res/color/abs__primary_text_holo_light.xml delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_bottom_solid_dark_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_bottom_solid_inverse_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_bottom_solid_light_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_bottom_transparent_dark_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_bottom_transparent_light_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_share_pack_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_share_pack_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_solid_dark_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_solid_light_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_solid_shadow_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_stacked_solid_dark_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_stacked_solid_light_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_stacked_transparent_dark_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_stacked_transparent_light_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_transparent_dark_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_transparent_light_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__btn_cab_done_default_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__btn_cab_done_default_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__btn_cab_done_focused_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__btn_cab_done_focused_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__btn_cab_done_pressed_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__btn_cab_done_pressed_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__cab_background_bottom_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__cab_background_bottom_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__cab_background_top_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__cab_background_top_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__dialog_full_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__dialog_full_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ic_ab_back_holo_dark.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ic_ab_back_holo_light.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ic_cab_done_holo_dark.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ic_cab_done_holo_light.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ic_menu_moreoverflow_normal_holo_dark.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ic_menu_moreoverflow_normal_holo_light.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ic_menu_share_holo_dark.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ic_menu_share_holo_light.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__list_activated_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__list_divider_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__list_divider_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__list_focused_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__list_longpressed_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__list_pressed_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__list_pressed_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__list_selector_disabled_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__list_selector_disabled_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__menu_dropdown_panel_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__menu_dropdown_panel_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__progress_bg_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__progress_bg_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__progress_primary_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__progress_primary_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__progress_secondary_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__progress_secondary_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__spinner_48_inner_holo.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__spinner_48_outer_holo.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_default_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_default_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_disabled_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_disabled_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_focused_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_focused_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_pressed_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_pressed_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__tab_selected_focused_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__tab_selected_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__tab_selected_pressed_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-hdpi/abs__tab_unselected_pressed_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_bottom_solid_dark_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_bottom_solid_inverse_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_bottom_solid_light_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_bottom_transparent_dark_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_bottom_transparent_light_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_share_pack_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_share_pack_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_solid_dark_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_solid_light_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_solid_shadow_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_stacked_solid_dark_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_stacked_solid_light_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_stacked_transparent_dark_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_stacked_transparent_light_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_transparent_dark_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_transparent_light_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_default_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_default_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_focused_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_focused_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_pressed_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_pressed_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__cab_background_bottom_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__cab_background_bottom_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__cab_background_top_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__cab_background_top_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__dialog_full_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__dialog_full_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ic_ab_back_holo_dark.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ic_ab_back_holo_light.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ic_cab_done_holo_dark.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ic_cab_done_holo_light.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ic_menu_moreoverflow_normal_holo_dark.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ic_menu_moreoverflow_normal_holo_light.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ic_menu_share_holo_dark.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ic_menu_share_holo_light.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__list_activated_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__list_divider_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__list_divider_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__list_focused_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__list_longpressed_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__list_pressed_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__list_pressed_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__list_selector_disabled_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__list_selector_disabled_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__menu_dropdown_panel_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__menu_dropdown_panel_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__progress_bg_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__progress_bg_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__progress_primary_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__progress_primary_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__progress_secondary_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__progress_secondary_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__spinner_48_inner_holo.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__spinner_48_outer_holo.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__spinner_ab_default_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__spinner_ab_default_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__spinner_ab_disabled_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__spinner_ab_disabled_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__spinner_ab_focused_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__spinner_ab_focused_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__spinner_ab_pressed_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__spinner_ab_pressed_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__tab_selected_focused_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__tab_selected_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__tab_selected_pressed_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-mdpi/abs__tab_unselected_pressed_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-v11/abs__progress_medium_holo.xml delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_bottom_solid_dark_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_bottom_solid_inverse_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_bottom_solid_light_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_bottom_transparent_dark_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_bottom_transparent_light_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_share_pack_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_share_pack_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_solid_dark_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_solid_light_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_solid_shadow_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_stacked_solid_dark_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_stacked_solid_light_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_stacked_transparent_dark_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_stacked_transparent_light_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_transparent_dark_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_transparent_light_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_default_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_default_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_focused_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_focused_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_pressed_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_pressed_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__cab_background_bottom_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__cab_background_bottom_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__cab_background_top_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__cab_background_top_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__dialog_full_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__dialog_full_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ic_ab_back_holo_dark.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ic_ab_back_holo_light.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ic_cab_done_holo_dark.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ic_cab_done_holo_light.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ic_menu_moreoverflow_normal_holo_dark.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ic_menu_moreoverflow_normal_holo_light.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ic_menu_share_holo_dark.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ic_menu_share_holo_light.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__list_activated_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__list_divider_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__list_divider_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__list_focused_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__list_longpressed_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__list_pressed_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__list_pressed_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__list_selector_disabled_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__list_selector_disabled_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__menu_dropdown_panel_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__menu_dropdown_panel_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__progress_bg_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__progress_bg_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__progress_primary_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__progress_primary_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__progress_secondary_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__progress_secondary_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__spinner_48_inner_holo.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__spinner_48_outer_holo.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_default_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_default_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_disabled_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_disabled_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_focused_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_focused_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_pressed_holo_dark.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_pressed_holo_light.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__tab_selected_focused_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__tab_selected_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__tab_selected_pressed_holo.9.png delete mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__tab_unselected_pressed_holo.9.png delete mode 100644 actionbarsherlock/res/drawable/abs__activated_background_holo_dark.xml delete mode 100644 actionbarsherlock/res/drawable/abs__activated_background_holo_light.xml delete mode 100644 actionbarsherlock/res/drawable/abs__btn_cab_done_holo_dark.xml delete mode 100644 actionbarsherlock/res/drawable/abs__btn_cab_done_holo_light.xml delete mode 100644 actionbarsherlock/res/drawable/abs__ic_menu_moreoverflow_holo_dark.xml delete mode 100644 actionbarsherlock/res/drawable/abs__ic_menu_moreoverflow_holo_light.xml delete mode 100644 actionbarsherlock/res/drawable/abs__item_background_holo_dark.xml delete mode 100644 actionbarsherlock/res/drawable/abs__item_background_holo_light.xml delete mode 100644 actionbarsherlock/res/drawable/abs__list_selector_background_transition_holo_dark.xml delete mode 100644 actionbarsherlock/res/drawable/abs__list_selector_background_transition_holo_light.xml delete mode 100644 actionbarsherlock/res/drawable/abs__list_selector_holo_dark.xml delete mode 100644 actionbarsherlock/res/drawable/abs__list_selector_holo_light.xml delete mode 100644 actionbarsherlock/res/drawable/abs__progress_horizontal_holo_dark.xml delete mode 100644 actionbarsherlock/res/drawable/abs__progress_horizontal_holo_light.xml delete mode 100644 actionbarsherlock/res/drawable/abs__progress_medium_holo.xml delete mode 100644 actionbarsherlock/res/drawable/abs__spinner_ab_holo_dark.xml delete mode 100644 actionbarsherlock/res/drawable/abs__spinner_ab_holo_light.xml delete mode 100644 actionbarsherlock/res/drawable/abs__tab_indicator_ab_holo.xml delete mode 100644 actionbarsherlock/res/layout-large/abs__action_mode_close_item.xml delete mode 100644 actionbarsherlock/res/layout-v14/sherlock_spinner_dropdown_item.xml delete mode 100644 actionbarsherlock/res/layout-v14/sherlock_spinner_item.xml delete mode 100644 actionbarsherlock/res/layout-xlarge/abs__screen_action_bar.xml delete mode 100644 actionbarsherlock/res/layout-xlarge/abs__screen_action_bar_overlay.xml delete mode 100644 actionbarsherlock/res/layout/abs__action_bar_home.xml delete mode 100644 actionbarsherlock/res/layout/abs__action_bar_tab.xml delete mode 100644 actionbarsherlock/res/layout/abs__action_bar_tab_bar_view.xml delete mode 100644 actionbarsherlock/res/layout/abs__action_bar_title_item.xml delete mode 100644 actionbarsherlock/res/layout/abs__action_menu_item_layout.xml delete mode 100644 actionbarsherlock/res/layout/abs__action_menu_layout.xml delete mode 100644 actionbarsherlock/res/layout/abs__action_mode_bar.xml delete mode 100644 actionbarsherlock/res/layout/abs__action_mode_close_item.xml delete mode 100644 actionbarsherlock/res/layout/abs__activity_chooser_view.xml delete mode 100644 actionbarsherlock/res/layout/abs__activity_chooser_view_list_item.xml delete mode 100644 actionbarsherlock/res/layout/abs__dialog_title_holo.xml delete mode 100644 actionbarsherlock/res/layout/abs__list_menu_item_checkbox.xml delete mode 100644 actionbarsherlock/res/layout/abs__list_menu_item_icon.xml delete mode 100644 actionbarsherlock/res/layout/abs__list_menu_item_layout.xml delete mode 100644 actionbarsherlock/res/layout/abs__list_menu_item_radio.xml delete mode 100644 actionbarsherlock/res/layout/abs__popup_menu_item_layout.xml delete mode 100644 actionbarsherlock/res/layout/abs__screen_action_bar.xml delete mode 100644 actionbarsherlock/res/layout/abs__screen_action_bar_overlay.xml delete mode 100644 actionbarsherlock/res/layout/abs__screen_simple.xml delete mode 100644 actionbarsherlock/res/layout/abs__screen_simple_overlay_action_mode.xml delete mode 100644 actionbarsherlock/res/layout/sherlock_spinner_dropdown_item.xml delete mode 100644 actionbarsherlock/res/layout/sherlock_spinner_item.xml delete mode 100644 actionbarsherlock/res/values-land/abs__dimens.xml delete mode 100644 actionbarsherlock/res/values-large-hdpi-1024x600/abs__dimens.xml delete mode 100644 actionbarsherlock/res/values-large-land-hdpi-1024x600/abs__dimens.xml delete mode 100644 actionbarsherlock/res/values-large-land-mdpi-1024x600/abs__dimens.xml delete mode 100644 actionbarsherlock/res/values-large-mdpi-1024x600/abs__dimens.xml delete mode 100644 actionbarsherlock/res/values-large/abs__dimens.xml delete mode 100644 actionbarsherlock/res/values-sw600dp/abs__bools.xml delete mode 100644 actionbarsherlock/res/values-sw600dp/abs__dimens.xml delete mode 100644 actionbarsherlock/res/values-v11/abs__themes.xml delete mode 100644 actionbarsherlock/res/values-v14/abs__styles.xml delete mode 100644 actionbarsherlock/res/values-v14/abs__themes.xml delete mode 100644 actionbarsherlock/res/values-w360dp/abs__dimens.xml delete mode 100644 actionbarsherlock/res/values-w480dp/abs__bools.xml delete mode 100644 actionbarsherlock/res/values-w480dp/abs__config.xml delete mode 100644 actionbarsherlock/res/values-w500dp/abs__dimens.xml delete mode 100644 actionbarsherlock/res/values-w600dp/abs__dimens.xml delete mode 100644 actionbarsherlock/res/values-xlarge/abs__dimens.xml delete mode 100644 actionbarsherlock/res/values/abs__attrs.xml delete mode 100644 actionbarsherlock/res/values/abs__bools.xml delete mode 100644 actionbarsherlock/res/values/abs__colors.xml delete mode 100644 actionbarsherlock/res/values/abs__config.xml delete mode 100644 actionbarsherlock/res/values/abs__dimens.xml delete mode 100644 actionbarsherlock/res/values/abs__ids.xml delete mode 100644 actionbarsherlock/res/values/abs__strings.xml delete mode 100644 actionbarsherlock/res/values/abs__styles.xml delete mode 100644 actionbarsherlock/res/values/abs__themes.xml delete mode 100644 actionbarsherlock/src/android/support/v4/app/_ActionBarSherlockTrojanHorse.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/ActionBarSherlock.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/app/ActionBar.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/app/SherlockActivity.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/app/SherlockDialogFragment.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/app/SherlockExpandableListActivity.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/app/SherlockFragment.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/app/SherlockFragmentActivity.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/app/SherlockListActivity.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/app/SherlockListFragment.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/app/SherlockPreferenceActivity.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockCompat.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockNative.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/ResourcesCompat.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/app/ActionBarImpl.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/app/ActionBarWrapper.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/Animator.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorListenerAdapter.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorSet.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatEvaluator.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatKeyframeSet.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntEvaluator.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntKeyframeSet.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/Keyframe.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/KeyframeSet.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ObjectAnimator.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/PropertyValuesHolder.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/TypeEvaluator.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/NineViewGroup.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/AnimatorProxy.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineFrameLayout.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineHorizontalScrollView.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineLinearLayout.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/ActionProviderWrapper.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/StandaloneActionMode.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/View_HasStateListenerSupport.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/View_OnAttachStateChangeListener.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenu.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuItem.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuItemView.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuPresenter.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuView.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/BaseMenuPresenter.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ListMenuItemView.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuBuilder.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemImpl.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemWrapper.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuPopupHelper.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuPresenter.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuView.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuWrapper.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/SubMenuBuilder.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/SubMenuWrapper.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/widget/AbsActionBarView.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarContainer.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarContextView.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarView.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/widget/CapitalizingButton.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/widget/CapitalizingTextView.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/widget/FakeDialogPhoneWindow.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsAbsSpinner.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsAdapterView.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsListPopupWindow.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsProgressBar.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsSpinner.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsView.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/view/ActionMode.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/view/ActionProvider.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/view/CollapsibleActionView.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/view/Menu.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/view/MenuInflater.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/view/MenuItem.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/view/SubMenu.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/view/Window.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/widget/ActivityChooserModel.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/widget/ActivityChooserView.java delete mode 100644 actionbarsherlock/src/com/actionbarsherlock/widget/ShareActionProvider.java diff --git a/Android.mk b/Android.mk index 570b46f30..4854a5c5e 100644 --- a/Android.mk +++ b/Android.mk @@ -9,15 +9,10 @@ LOCAL_STATIC_JAVA_LIBRARIES += com.android.gallery3d.common2 LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_SRC_FILES += $(call all-java-files-under, src_pd) -LOCAL_SRC_FILES += $(call all-java-files-under, actionbarsherlock/src) LOCAL_SRC_FILES += $(call all-java-files-under, ../Camera/src) -LOCAL_RESOURCE_DIR += $(LOCAL_PATH)/res -LOCAL_RESOURCE_DIR += packages/apps/Camera/res -LOCAL_RESOURCE_DIR += $(LOCAL_PATH)/actionbarsherlock/res - -LOCAL_AAPT_FLAGS := --auto-add-overlay \ - --extra-packages com.android.camera:com.actionbarsherlock +LOCAL_RESOURCE_DIR += $(LOCAL_PATH)/res packages/apps/Camera/res +LOCAL_AAPT_FLAGS := --auto-add-overlay --extra-packages com.android.camera LOCAL_PACKAGE_NAME := Gallery2 diff --git a/actionbarsherlock/res/color/abs__primary_text_disable_only_holo_dark.xml b/actionbarsherlock/res/color/abs__primary_text_disable_only_holo_dark.xml deleted file mode 100644 index ea7459aaf..000000000 --- a/actionbarsherlock/res/color/abs__primary_text_disable_only_holo_dark.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - diff --git a/actionbarsherlock/res/color/abs__primary_text_disable_only_holo_light.xml b/actionbarsherlock/res/color/abs__primary_text_disable_only_holo_light.xml deleted file mode 100644 index 0edb33b4b..000000000 --- a/actionbarsherlock/res/color/abs__primary_text_disable_only_holo_light.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - diff --git a/actionbarsherlock/res/color/abs__primary_text_holo_dark.xml b/actionbarsherlock/res/color/abs__primary_text_holo_dark.xml deleted file mode 100644 index 2bcfd0b63..000000000 --- a/actionbarsherlock/res/color/abs__primary_text_holo_dark.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - diff --git a/actionbarsherlock/res/color/abs__primary_text_holo_light.xml b/actionbarsherlock/res/color/abs__primary_text_holo_light.xml deleted file mode 100644 index 198384fed..000000000 --- a/actionbarsherlock/res/color/abs__primary_text_holo_light.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ab_bottom_solid_dark_holo.9.png b/actionbarsherlock/res/drawable-hdpi/abs__ab_bottom_solid_dark_holo.9.png deleted file mode 100644 index 769463b369a5185ba2d2fdf26abf058086ebcd08..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 144 zcmeAS@N?(olHy`uVBq!ia0vp^Y9P$P1|(P5zFY^S!aZFaLn02py|Iz^fCC51!MDwC ze!c%VXGhEQ)_dJsezHtpNMD|7Dac@a*_ZJyulFV2w{5C|YCbaz5)ZX-3ak0tIJ#lm tp_aeGY*)k&iW*FhzahTiJD1r}=BlLiI{(TJ=>e@^@O1TaS?83{1OUpzopr0A6)2vH$=8 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ab_bottom_solid_light_holo.9.png b/actionbarsherlock/res/drawable-hdpi/abs__ab_bottom_solid_light_holo.9.png deleted file mode 100644 index 73050476e77aa798919b829a5566973e231f9d49..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 144 zcmeAS@N?(olHy`uVBq!ia0vp^Y9P$P1|(P5zFY^S!aZFaLn02py|Iz^fCC51!MFRR zxpqaJ>-4UOe6iPKwm$=BLD{Wo!i)yScSSDT-Jo*!N?wFe;-MB!VKtu_20%tEPqwzt q4f{lgTEQ5`;-9UxjMeKCf^DQ_uhd?;-Btm#g2B_(&t;ucLK6V6dokDm diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ab_bottom_transparent_dark_holo.9.png b/actionbarsherlock/res/drawable-hdpi/abs__ab_bottom_transparent_dark_holo.9.png deleted file mode 100644 index 712a551ece87b2544433ac982382a087e7f1731d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 135 zcmeAS@N?(olHy`uVBq!ia0vp^Y9P$P1|(P5zFY^S{5)M8Ln02py}Xf^L4oIp!}}xu zHrx6hVG;aws8xB@i!KMDZA_cCWy>wsRQS4KRST!En$HY_#6vK~{lt8cLjun}a%VT6 c)z9eScC>M27UGHi05qAw)78&qol`;+0QSr+Bme*a diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ab_bottom_transparent_light_holo.9.png b/actionbarsherlock/res/drawable-hdpi/abs__ab_bottom_transparent_light_holo.9.png deleted file mode 100644 index bf3b9438b16543294498ba27e51d4e878c8ead5a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 134 zcmeAS@N?(olHy`uVBq!ia0vp^Y9P$P1|(P5zFY^Sd_7$pLn02py}Xh4fCCS+;oB*H z(}QQZt5vXQMa=PTZk@YrXXvE3+ofW5$)(cU#3WF_jrSY!c@8l>`*HAE!gKCvr?`99 W=bm|#aNiDSFoUP7pUXO@geCw#94y)Z diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ab_share_pack_holo_dark.9.png b/actionbarsherlock/res/drawable-hdpi/abs__ab_share_pack_holo_dark.9.png deleted file mode 100644 index 6c1415772d03a71c0677f6e2461521bfae829ce9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2866 zcmV-23(fS2P)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z00018Nkl%->o_#B0~lM0RR6305`L6c1|?a Q%K!iX07*qoM6N<$g0$>VYybcN diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ab_share_pack_holo_light.9.png b/actionbarsherlock/res/drawable-hdpi/abs__ab_share_pack_holo_light.9.png deleted file mode 100644 index f4ff16be7323486b7fcd49b3e9bb07816a75b53c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2862 zcmV+}3(@q6P)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z00014Nkl-^V;Vpy{TG>rs2jRbt|WpWjh#Ji#?9Gi^wblTEgJz>gTe~DWM4fZg4bX diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ab_stacked_transparent_dark_holo.9.png b/actionbarsherlock/res/drawable-hdpi/abs__ab_stacked_transparent_dark_holo.9.png deleted file mode 100644 index 1e39572224b24a81ed4d73923280ba2724dbaf6e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 139 zcmeAS@N?(olHy`uVBq!ia0vp^Y9P$P1|(P5zFY^Sf;?RuLn02py|Iy(L4oIp!})_Q zZ}wlfoYKNk`|wbZR*CB+2cd0Do4#G+S+1#YsD)El&1Z%|BAjt`!_S2)TNKYc{m-!5 f_v_(jT(cfAPEEXE)c4^Y$T|j3S3j3^P6 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ab_stacked_transparent_light_holo.9.png b/actionbarsherlock/res/drawable-hdpi/abs__ab_stacked_transparent_light_holo.9.png deleted file mode 100644 index a16db853e94af78c0739d9b89b578e2a8021c856..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 133 zcmeAS@N?(olHy`uVBq!ia0vp^Y9P$P1|(P5zFY^Sd^}woLn02py|j?`fP(zopr08IHUH2?qr diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ab_transparent_dark_holo.9.png b/actionbarsherlock/res/drawable-hdpi/abs__ab_transparent_dark_holo.9.png deleted file mode 100644 index 0eff695d82911a73874d871f3a7b23b71dd8ab44..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 155 zcmeAS@N?(olHy`uVBq!ia0vp^Y9P$P1|(P5zFY^Sl001;Ln02py?l}LfC5j;!{`N< zEvnsL$t-6rWU%$psDGg1|4DLDj`q~RzPqNgR|nl=*Rt6dx_ol~p-I||JQ4;82O1ce y*`SQyBHQ|!3>bf({j~je;Zla%ZD->HG+$+yO5M3zoXrBXjlt8^&t;ucLK6T4R5w)s diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ab_transparent_light_holo.9.png b/actionbarsherlock/res/drawable-hdpi/abs__ab_transparent_light_holo.9.png deleted file mode 100644 index 219b170fa67aa2ef8e0b11ebff90c1629ba7e97a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 145 zcmeAS@N?(olHy`uVBq!ia0vp^Y9P$P1|(P5zFY^SB0OCjLn02py?l|AL4l*?;q8?- zrB_<6lUu~-<@8GYocm9fskyGHQx2!G9uAwU_k&&MlS%_4GaHYDLBatTBRp}nY76HL mkjg^D5fnx&0glSHJj>3%>1Jqp^q#PeS;bnL@oAJ;NJ=s*Cb_P#ZKbLh* G2~7YBfgFPX diff --git a/actionbarsherlock/res/drawable-hdpi/abs__btn_cab_done_pressed_holo_dark.9.png b/actionbarsherlock/res/drawable-hdpi/abs__btn_cab_done_pressed_holo_dark.9.png deleted file mode 100644 index 66adffed632f0f6267afe6dc2f518adb6a83ca4a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 110 zcmeAS@N?(olHy`uVBq!ia0vp^EI_Qo!3HFq_#{<Lb diff --git a/actionbarsherlock/res/drawable-hdpi/abs__cab_background_bottom_holo_dark.9.png b/actionbarsherlock/res/drawable-hdpi/abs__cab_background_bottom_holo_dark.9.png deleted file mode 100644 index 1d836f65a1fffea301e9cf36770b21b48b3b8132..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 149 zcmeAS@N?(olHy`uVBq!ia0vp^Y9P$P1|(P5zFY^SVmw_OLn02py|R(B!9jra;>r_8 z?%b*io|Yn;UGT9};ZTu}!9}%xc^%IgtXD4oJ@0X-F7B%4f|j+c$=0hv54CU#tNF|@ sNQ5wMgi8eI0r?xYZ}@0_Yf6jsMX$B_pXOhT0oudh>FVdQ&MBb@0DzD;x&QzG diff --git a/actionbarsherlock/res/drawable-hdpi/abs__cab_background_bottom_holo_light.9.png b/actionbarsherlock/res/drawable-hdpi/abs__cab_background_bottom_holo_light.9.png deleted file mode 100644 index 5818666d4e64b93da73bc3d6dc2764bcb500359c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 145 zcmeAS@N?(olHy`uVBq!ia0vp^Y9P$P1|(P5zFY^SB0OCjLn02py|R(>fCCT9!M7)Q zv diff --git a/actionbarsherlock/res/drawable-hdpi/abs__cab_background_top_holo_dark.9.png b/actionbarsherlock/res/drawable-hdpi/abs__cab_background_top_holo_dark.9.png deleted file mode 100644 index 564fb34b4308750b6922f320e9e114b080ecd538..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 147 zcmeAS@N?(olHy`uVBq!ia0vp^Y9P$P1|(P5zFY^SqC8z3Ln02py}XdO!9jra;!2L@ z<=I|~`ucZlc5hPnsi>TGwM)Is^N?0TPy5{UQpwgqqAoKG5)ZX-3ak0R7;B{1mWZ}( p*lxaUe)ue*Z}vC-G%ee~_}P|!&DqTD7lF1gc)I$ztaD0e0st(KG%NrB diff --git a/actionbarsherlock/res/drawable-hdpi/abs__cab_background_top_holo_light.9.png b/actionbarsherlock/res/drawable-hdpi/abs__cab_background_top_holo_light.9.png deleted file mode 100644 index ae21b760fb1ebecac3389164251b0fa14f580f5a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 147 zcmeAS@N?(olHy`uVBq!ia0vp^Y9P$P1|(P5zFY^SqC8z3Ln02py>gKAfB^?4dC zy{Qwe+I<(;Zrk3}qFy7o$Hqotreyxi(D>i`gF-*@tj&^T;Xws!Omj@dZ?l#4Y_?*} ivA^-x{8q}NM@;fbHo20HF^oW47(8A5T-G@yGywny6)bE3 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__dialog_full_holo_dark.9.png b/actionbarsherlock/res/drawable-hdpi/abs__dialog_full_holo_dark.9.png deleted file mode 100644 index 79e56f522b2837bd9f579b28f037ad5eafaaee8e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1414 zcmV;11$p|3P)cSnqT^=WQ7*OFqW%ysfqGq3fLYCng$eebY1E zq0h)!qMt>^T{!1KLrdv5=!(bMwnfb7mMF4BgVA@!3k##^X|etG%o8VLfn)&kp1$5* zAHx|3EF9@?)w)=}!OothSF(h}LSVs2n}u~V8rR2gA&m?6GFm9LT5i!5ovh2$`aOLf zDMwpCv(UIN+s(qhT71rU;E=VYR%2(wIy9)U9BqNMU?EvKj~0!zxmxOREjkZzh+iq_n}2*GaEP(@ILD!5 zWBguqUH^M`clY;tz5a@wsI&tR0g7j89WEv$&WS`s3jmAj>+65+@9$R+4-crSDsl+t zoXD~ai^by4tE;Qe>-G9CHN@f2j4rXz#$jzQA^^+B$H$Mix3`1-5a+ZsO@p#5Q53}= z0G4QnFC7vyL_!;@%<@Jv>_k)mSUx>Hz18n=PE3d}%kYsC@*I)N0NNv^lI%s;wg9j! z%knLLgEIoQ+bysY63^&#(^_eOc(NT6QxTdoZI(#S<~ro`ne!tS(gH7T&zUX-UZRk7 zy|5!F77`FowzZg?X(M)KAw}<4SRP51e8qZ>m)V;$Z3?tS#CiaZ^hhEi?U_=yRh(%c zcGk9kwMUBGYjYt@pHyCSltyExNUHHFevMy@-l#r~QEjQ;(4?Q~r4samHh{FF{bU7StYxgeBAZQ`6E7N`VLYGS_ z;oj>aHT`D+d1$*FJhVBd!G+`uf(ywR1Q(Js2reXN5G)~C&xiARXWFDHmGF81Z6U>K z;#g%)oXa8RP+ENtZO$MZBP0)Pm&4Jv?h_KbHF>VdnKo?a-t;CVB(9^gh389`0#_~3 z>r7%ovdX{d8amFjk%uF>Vp~*9sp-GKg_vAO(?{&AZLdjA|Mdo3?oA8H>)1>mc|==# zB~EQxV&cD40$n%8&w#s-rjOWJ+ddiIQXYxR!^y#)tE&3)24CJ80l~J_MCXPu>Ml3AI+9BHcJ4%0r(Kw z@2dYHj4#nGKH!fqjRVUuh**Aw_CvMrs{b>Lm!YwzO4di>6N@*}Phg5Tw&B1fy2S@v zNaMh=r`Sx3>1SxA8q+hl==5I;NtblfC(XkF^KkH7ZKuDGcq0~@mC!ryi=K7WXgde? zOwz>rq{P&!A!(hIr~D!&pe-W#G7`?LQYh|`P7hzs(O!weT#2|xih3m$l64(P7wFd8 z$(YnkvI-Blh{l8EAha{kf+|%%mTX6hk;YCcRo{6`6g>|oKBz>Tb24JLyVyI4p!izS z!8wv9b%$RIiIZ@y?B&nGjRPyvaF~-xlb-U|=!P~^8?n&FNw@wIvQA!p;xDy1AK0dR zu~CaAl^btMM>A?9->NQ&|AnVmzdt!!WF>xutSl`;$84s2a_=ari#ecl- zo|KSyJXTD=1$2JI1Ql!6el7Y8-dCZ-i%gs^mMBu<;eLzP8a;YIXA&Hxi>7JtAFa#2 UvCQ(L;{X5v07*qoM6N<$g1g$KMgRZ+ diff --git a/actionbarsherlock/res/drawable-hdpi/abs__dialog_full_holo_light.9.png b/actionbarsherlock/res/drawable-hdpi/abs__dialog_full_holo_light.9.png deleted file mode 100644 index e029f210b9a81ed4765d31e90b6e49dc8aa37bed..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1537 zcmV+c2LAbpP)P*hY@RCILOyI+)4*Y%ioMH6eaT8-v42qXrI z0|4iGEk=d4Xm52^#H?WUz%bBygG}I|;L!cJM*+u%I9T*&&%x@0sx#0Qk0mTmeRX1h$MIxNMY&% zsz{Hz01C^N@8p~dFgXbIRub%{CUOKKzAQ3rfl0r3M&j^DZL~BnC0R+zNTfH*0>l>% z6xe!^4oO*vg0sbY%(i4Znw@-;nUbs&1zN~PIe02zy)Qcz&8uA?+OU=`?e2Zs5}uJN0M*6C#a{)YX?>^k&iO8v%U{pV&i+9YXUL@sAe1fQs10%V6ikBo z^7Qod_s{$xhgN}Tci-i5`3pX{;N4;1Au(Bm7x@)z#1I9LmdL~RrF4uC5rsHs>tE+w zbjvJ)LKv+{MYbuBrU=TBLj=6Xm=@t7;baF+QjNr0K02$09MPPz_Q^dZ5CLh8#Oov4 z0!TsP8|Jz<^->fRi@r;w5OrSCkw6L?N(J|#V;?nA78HxV{Q97DD=gWeOHxKs4U)p3 zSoD>;waz;geHn?ahed6Tq%7rduPgn zV$nDE$&ajtWS5-`4=n>hvFJNE&bxxNGnt2!k)T-g9UO0!_0BFb6cm%bLuC>qYeBK* zyN@VHxuTkNE#cFa@PaJz!! z*)p0eo;YjAyoc}Lcn`@)ql2XA#Le!l%y)3C`#|D`qk*LC#Leoh&{v9irz@IDt(4j|E-ey3YJCdAoj z17Q35`nvale)TKB+I=4%AAxk%w!OMGAf++t+Mb@Cemp-vW4j&J%V|A%#TR&cd&9%S z1Mctdf1tZ-6W>Id5JKwGXhvG!+}wOSKR^Gos;Zyq!S}5X*>+05G4|7V9G{hQ?!VjH z+iw8YkTX)YMrymYx~{`?w$U_yh$q-O1#m*zu<(hQDx}lJ70s)V5Io{ZN7v2rMwVC7 zhTm_2@1*&pTK&uP8_~o&lye*5+om^+1{h zqafFH?O0X{OUO1M^YAPb=F`bd6<0LB=s!LE=ilN39Gach?DYt$CL6UhXTc;$2zpT2dqqQrIZWT*_yH->_|IcgE|Y&S_AJ4lX{3 zlIkT6RWeyS^JtZ1q^3@yK=Cm?J&*-y*C;dpYgTSF&bztX%>V7a(kL+ra#JUT-|=or zs-McUNbE?uO3e#!@v#wf-Fu%ryG^`~69lNs`%MmnTRbrM$471B$+eE{K4hK$mCQ9h-Z$E`tJc<=E)8`p?U8s&`700000NkvXXu0mjfb2aWW diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ic_ab_back_holo_dark.png b/actionbarsherlock/res/drawable-hdpi/abs__ic_ab_back_holo_dark.png deleted file mode 100644 index 897a1c11a06923f0ee630a3ec44b40118c1fa4d3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 602 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM0wlfaz7_*1rX+877l!}s{b%+Ad7K3vkswhI zFm^kcZ3hx8D{xE)(qO#|6+TOsF)%PDdAc};Se)*?;+-wxD8l++z18QgepiI9o*=R4AA9|r|3}>uTm;M6YILUxmVi!uBjgaN)~;(wEWpmNk!cW z(d%Z<{E>P~YK!lT=8FgRsYuTJwQ$0$u+I~@?rdLb^6_f+5jpHV#tRQqPS1ijb30F2_W#pYUFO#_XV=?h zOHP?#2^DqDa diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ic_ab_back_holo_light.png b/actionbarsherlock/res/drawable-hdpi/abs__ic_ab_back_holo_light.png deleted file mode 100644 index 0c89f71407e8d51f92ff6a10b1ae40ec902aa04e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 546 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM0wlfaz7_*1rX+877l!}s{b%+Ad7K3vkswhI zFm^kcZ3hx8D{xE)(qO#|6+TOsF)%P{dAc};Se%}E<)W9gqsXz3_j5LNPFu1pO1DK} z+N#=yeg8w_ofMzAMJao1SUGXl-8U7Joy@GYEX@zknfd?wSxaLcYqyHhr&soQ-EO{p zw!~UfNcQJK)l+|B(yvWaZRmKvsC8=g<+E=!6%t;!XnxPxBUZuOVKlwt*0FipR-Y02 zmCh$xWIQ?dubRMH%k4r1TjlOEFztJ(`Lu4f+1J+&0<|T}CPeP?x_?Pcpm5>hNwa5M zzkQR1sjpY$)<2WmGuJ)*zvffcmaNUK`~10Vr~dw8eVc_z%*|+OqxE^sCGQ0OTrOO6 z<>J@Zf0Ym33CMeTp!xW+<7NU=B(%1ExnpuV-^$?oQTEn-hjMN&=46?A$U{|X$JUzr zjr;q)=$3Bvc`c`@@Ze;4?7{TSRWGgUnXHd<-`o)9JVUa&78r!8C9V-ADTyViR>?)F zK#IZ0z|c_Fz+BhBFvQT<%Fw{d$P~!6GB7Z{-*6d4LvDUbW?Cg~4NgrK`9KYlARB`7 r(@M${i&7aJQ}UBi6+Ckj(^G>|6H_V+Po~-c6)||a`njxgN@xNAF&x-_ diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ic_cab_done_holo_dark.png b/actionbarsherlock/res/drawable-hdpi/abs__ic_cab_done_holo_dark.png deleted file mode 100644 index d8662e3f0fdae62cdee68c184a30fa9e421dc338..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 713 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}a}trX+877l!}s{b%+Ad7K3vk;OpT z1B~5HX4`=T%L*LRfizez!?|}o;S3Cn7d>4ZLn02pop#z!+EApeUwz>goe2TrwSq2J zirU3kvaXhOUTIG}?do{Paly7dd_m%&JI?q_-onB2%KO8{j^-Q>wzNlYp6R5&dH;Rm z|KbvtPbZZ7*R_9QUBqkhp({MdL+G`PeiKVkcC&4Y!{nAd6Z!S-oqj3U!mzMkIqyf? zf)_G(nEp@p{`aZ-I!9g5h7aq1927O&FPT&GvG@NuQA5$TGve!iOqW^IxiY{>!{pzO z!{3V<)Sk6$zkBfg;!caFvF0E2Z#WAV9{aHQL)vPusEmizHw=GVH2J}B^#kKc_ZNxM zzDF#RGe0;TaIo&I-m~b0*sP8To$2@Yde+QKc8kg_`XHU5q@;HFk@ug+O{X5aZ~nk~ zjknIKwfM~0Z^b864VUMM@zwGAdYt)v<(Nz4IlImB@8#qJ%zn(A@Z29bd}4MpKn$sTM506307QmPCTFYr(@#O zpZ-(V%YE!?30QE(DXivDMdI0PFM+AKOT1>hnX-6tX;O6(d#2d)iSBZ_kN7m7WzTRr zzEA`h)2bz|5hW>!C8<`)MX5lF!N|bSP}jgh*T6i)(9Fuf$jaCl$hI;t2>JhQGm3`X z{FKbJN)!#IR;K1a1kqq?mJtlpAPKS|I6tkVJh3R1!7(L2DOJHUH!(dmC^a#qvhZZ8 Q4Nwt-r>mdKI;Vst0K3d3fB*mh diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ic_cab_done_holo_light.png b/actionbarsherlock/res/drawable-hdpi/abs__ic_cab_done_holo_light.png deleted file mode 100644 index ed03f620f8ef9e969d0471ab76329038e25c9f0d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 737 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}a}trX+877l!}s{b%+Ad7K3vk;OpT z1B~5HX4`=T%L*LRfizez!?|}o;S3CnFFjoxLn02py%z6(IY8q0$M=`{k_{&Q=;t<2 zt8!*r>&D`|W2$+>pS=eAb}M##+^cbdA4dCLPr0$oL~Mm8Bn#4$+9@L$(#*Pp%fW0&@t4F~+Q4$6OeIrG`|nG22@uVa-C zJ=H0n)NABBE9V2ZrDh$}Ob?>#U7^{{%b z^;_|*S@)*|RLscvyw85$_Y2}8p?L-UY)vO;|NFUQJ(sNEA?BESpVrme#d7mboB7l} z-Tl+e|M{(6F|!lpnSU$jtXi?CXvKcs<;$n_y<4FKOaZDTt`Q|Ei6yC4$wjF^iowXh z&`{UFLf61N#L&#jz{twj7|6CVFbMhoZ8M67-29Zxv`Q2WrdForKm^fXYnBlV)F276 tAviy+q&%@GmBBG3KPgqgGdD3kH7GSPrLyp3str&PgQu&X%Q~loCIB{EJ2wCT diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ic_menu_moreoverflow_normal_holo_dark.png b/actionbarsherlock/res/drawable-hdpi/abs__ic_menu_moreoverflow_normal_holo_dark.png deleted file mode 100644 index 2abc45809c62513224e9d695542cb8dd8e8087b9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 144 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezt=sPZ!6KjC*gdALL|E;9+*q=6m<7 zlueVX_4IZHnJ0qE#_rG0T(kiyWMEjjhCTn?qu5pu`=4q}27?c$C=-xvpo(CHaDZeV Zn6Yoz!5==w*?y}vd$@?2>|OKBsl;8 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ic_menu_moreoverflow_normal_holo_light.png b/actionbarsherlock/res/drawable-hdpi/abs__ic_menu_moreoverflow_normal_holo_light.png deleted file mode 100644 index bb6aef1d069a14a7fc1cea9780c919c61679e4fa..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 148 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpUtXipc%kc@k8uWjUIP~c#3xZ62X z=G4p^oaPsfxfS0Jish)R3f(&WG9yqa14Evg(y_dGGlfCy2iXqR3?>_SEs{VyhV?DH iJ0OaDc|iOR772{!kNsXaOPT8&i0|p@=d#Wzp$Py$I4IEo diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ic_menu_share_holo_dark.png b/actionbarsherlock/res/drawable-hdpi/abs__ic_menu_share_holo_dark.png deleted file mode 100644 index 6f747c8f065940a8844587c682fb3c9443ad1ca2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 467 zcmV;^0WAKBP)SO)@i{}u0qYYqHziBfu2L*;{L?D;GxhmUqDjP ziMkTn=nm+BxmDP>FsP2fGnnz3AAnfGAiD%ptMDlguG*u-2|uL;kN%Xenfoz6Wm9neQuJ_f08buH`WL4SA>8mzG9{4uwy+$BT^9a|eO3@D0j4;gS>^u3i8D002ov JPDHLkV1mHE(I@}_ diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ic_menu_share_holo_light.png b/actionbarsherlock/res/drawable-hdpi/abs__ic_menu_share_holo_light.png deleted file mode 100644 index 682b2fdec4cdcffe042a0eaba5574fcb553c6fab..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 505 zcmVavhwv6%LZS|`6cHU3BI+s;(j}rxR}U>ALI;t;n}mlvh$!J-yZtua#I%j$ zOwQ&T8Q}wUMSkBn``+6%%Cao-nJ5SZfglhBcnTy*QWjP42;RUuXn|w-Gn@r3!4%9C z+;SJ#1s`+53r;u-JS+&G)8Q=eVjwW)EYS5?U=Q?t+(O%+X%L*ae6USp(Wf44I z{VTBf*DdH$;99e18zd%PPify*mOc4h3DgW)zaXzPJFd#ED}jzd@IKXer+vefz{o(L zSH{%(p8{RZ0^V<-*kS}|(%8UCAfi$^)3kopWmIldEo%J}dR~)`A1WGIol7IL;ao9F zT=*mq(WtgX@b^ z8v#5LPB(Y&Y|7|Y_!S62?p zbb>IW`N`93fr2)kE{-7*QBRJJkl{&7FVVepxUS$Rt1LT2VAvn7lLLt0oo!v4%( tpjG6n=4tr&fORvYRP%q%M>EqU82;Q9of*be(FHVz!PC{xWt~$(699PnDoy|Z diff --git a/actionbarsherlock/res/drawable-hdpi/abs__list_divider_holo_dark.9.png b/actionbarsherlock/res/drawable-hdpi/abs__list_divider_holo_dark.9.png deleted file mode 100644 index 986ab0b9746301f2dd9401829da09e00995621b3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 78 zcmeAS@N?(olHy`uVBq!ia0vp^%plCc1|-8Yw(bW~qMj~}Asp9}6B-)+^BAxRtXRm= az`@Yw&#rLZUbzUUfWgz%&t;ucLK6T(%Mo}0 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__list_divider_holo_light.9.png b/actionbarsherlock/res/drawable-hdpi/abs__list_divider_holo_light.9.png deleted file mode 100644 index 0279e17a123f8cbb3c7e3a9ce5c5af8e693b6977..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 76 zcmeAS@N?(olHy`uVBq!ia0vp^%plCc1|-8Yw(bW~!k#XUAsp9}6B-)+^LX%RmN2q0 Ycy4A9FVZ~13zTN?boFyt=akR{01+Y(GXMYp diff --git a/actionbarsherlock/res/drawable-hdpi/abs__list_focused_holo.9.png b/actionbarsherlock/res/drawable-hdpi/abs__list_focused_holo.9.png deleted file mode 100644 index 516f5c7399c853d112a31d1e17c8c7f17180f9bd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 159 zcmeAS@N?(olHy`uVBq!ia0vp^+#t-s1|(OmDOUqhEX7WqAsj$Z!;#Vf2?p zbb>IW`N`93fr5^nE{-7*QpO1)z4*}Q$iB}R!lH3 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__list_longpressed_holo.9.png b/actionbarsherlock/res/drawable-hdpi/abs__list_longpressed_holo.9.png deleted file mode 100644 index 4ea7afa00e2bfe057472ed5a196080fc80ad7383..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 154 zcmeAS@N?(olHy`uVBq!ia0vp^+#t-s1|(OmDOUqhEX7WqAsj$Z!;#Vf2?p zbb>IW`N`93fr2)kE{-7*QBRJJkl{&7FVVepxUS$Rt1LT2VAvn7lLLt0oo!v4%( tpjG6n=4tr&fORvYRP%q%M>EqU82;Q9of*be(FHVz!PC{xWt~$(699PnDoy|Z diff --git a/actionbarsherlock/res/drawable-hdpi/abs__list_pressed_holo_dark.9.png b/actionbarsherlock/res/drawable-hdpi/abs__list_pressed_holo_dark.9.png deleted file mode 100644 index 5654cd69429fd0a3502a05b5f827bffab89cc7e0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 159 zcmeAS@N?(olHy`uVBq!ia0vp^+#t-s1|(OmDOUqhEX7WqAsj$Z!;#Vf2?p zbb>IW`N`93fr5^nE{-7*QD_LZ%D`aoRl?HIGCc%n7=x#)pUXO@geCyJM=ZAh diff --git a/actionbarsherlock/res/drawable-hdpi/abs__list_pressed_holo_light.9.png b/actionbarsherlock/res/drawable-hdpi/abs__list_pressed_holo_light.9.png deleted file mode 100644 index 5654cd69429fd0a3502a05b5f827bffab89cc7e0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 159 zcmeAS@N?(olHy`uVBq!ia0vp^+#t-s1|(OmDOUqhEX7WqAsj$Z!;#Vf2?p zbb>IW`N`93fr5^nE{-7*QD_LZ%D`aoRl?HIGCc%n7=x#)pUXO@geCyJM=ZAh diff --git a/actionbarsherlock/res/drawable-hdpi/abs__list_selector_disabled_holo_dark.9.png b/actionbarsherlock/res/drawable-hdpi/abs__list_selector_disabled_holo_dark.9.png deleted file mode 100644 index f6fd30dcdc9c39c836e509486854f9da03486892..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 189 zcmeAS@N?(olHy`uVBq!ia0vp^;y~=k!3HF){@Qy1DVAa<&kznEsNqQI0P;BtJR*x3 z7`Qt@n9=;?>9s(?cuyC{kcif|*A4j^95`Gq9-KV8B6o6ra`I!Z80pW;7d5zZGhRBg zm{FnhT6Xzih3ZMUGkfBc^kAT_eS7{3zPQ8d#DAm9s(?cuyC{kcif|*Eb3_81S$-+V)J@yPBVWyvqG&GeYz~KYxJdw0eeyIoHJnOEfn# R{sUUY;OXk;vd$@?2>|r{LWckV diff --git a/actionbarsherlock/res/drawable-hdpi/abs__menu_dropdown_panel_holo_dark.9.png b/actionbarsherlock/res/drawable-hdpi/abs__menu_dropdown_panel_holo_dark.9.png deleted file mode 100644 index 4d3d208578c61662986fdc16bd15c69759b48d6a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 922 zcmV;L17-Y)P)!ytdud6iMT7O&4bD*mP3eKws)UN7D2k#e z%DbYt@4NEYnkjlINEK7=*RV3zwml#Px9r!q%}Y$QM*NqHEZ-wscn^ zf4p9=Kg#ZZAKY%YZvc!aCbL}F6eGxtBSzy=smEUmc6C{?q1YCQrid~5o$!73+BeU$Ee{DI^Yo4#-o87 zao*xiE9Z<+s}ttlWw19HGlEA1nW09+*~|#}a;CkeJh%bU1g9CP5h0^O2}4Hs%y=Lc z5q!OY8j*^uk~rBBK?ljmh#jL84Ev;rDo>_H#K|6e%Mo=CgLzw$rI$Y4Z-kUy6U47Z zMI2w^tmuV~pH%tJq!^(yWY-hbFl2;G2g)+VPqud2Sicc+jL>MvBTKK;HbN#jlrS<8 zl+;FqdPULzJ~Kh_!?j8>!xs^*nQAm$#290~ue;BBnY1w&wMw4#m(pwEDZd_oY1{Ux z>$>N)H(eWD*FCpw`-IsDKF28-6~1bz!JGs-W6Z&R1n>#KR{&q8us99Q}8ID#(NJr3oa@N-D4Rc$qhA--bT2} z_Wpf@Z`4749}#V+fwWJz^oyZKO1~J&exY-1*Kg?D$hu!fixvAiNfpmG;mo&f5BSEA wlE;@gYed_N;JFm#Y)Zw{1W}kQU9GkF3xsHEK4Myn7XSbN07*qoM6N<$g18=|djJ3c diff --git a/actionbarsherlock/res/drawable-hdpi/abs__menu_dropdown_panel_holo_light.9.png b/actionbarsherlock/res/drawable-hdpi/abs__menu_dropdown_panel_holo_light.9.png deleted file mode 100644 index 924a99d173082ba58ca7527822359f228bb14dec..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1061 zcmV+=1ls$FP)#d)-&;4-At916hopygyW1WQa|lkCWZ4-q&QLYwjy>%Jd>?UvK6*fy zdt!`Ep~K-gOUxeEG;B7TCA&L&Y`5FR`f3tF5S^VH!lJsKJqkfK0&PN7nPcRS?`4Ev z7V~vPKouy~L@5%v*=&-(hy0cgM*ETwjWz&8F3NVhH7#V4$3+kVgi2lPw-adOTXm|2 z;f`P0rx+seIw-H@dwPaOx@-q(hY$i2BS4u1XM~+%LI5%mN(D;0XOsl63U@~43e6EU z5mrW96C~;L2O}H%p$jmGc5)7LM&^oyAacV=14{s_wp`K^YIpyDFEM02mXk3OSEw-p zdORS~SGTvf|Cjl{`o#71_3u-2KzcK(ZU7La5JAil5&>9olp#5yVJhG_L?OnQ2x7(v zIfg2+Q2z$cZ7gkJK~)>%8)`3CJSNBlBGKwWz;6QnLDPCN+(q9 zAJ*09wM4d_hZLYxWa z2;mvCbu@F-B1H21)loz{?U-+?@nqk8kw`Vm31QkJFg_V%{OMfZr8mlq(-<|uJGVoHpVClAlh&-bsduQ(hI zi(GsU`1tt1hf_X{d`3<68b|S{tXYwd2YXzXl8Izg4y^21 zp<@H92ON{kB3P1HizBE$;EP~xzks74y{^`3Ur7(FmPO0@t2+WXW`VN|Gc9|AJ43ds z=_5ZJGT6$YN8bIa6HYZ^jFIn`&>W#9La9l$?6@3`ET&WsUkjFK0@?|yO)(6`*1l_s~_L1z$~& z@jZM)qqe)$B+Pe}79nG2sji9uR0#8Z){~%#a(p4yPG;@1CipK8G=YCTO^$u*mj`Me f=rGa5Ym5<}3Pv>t$oVA_00000NkvXXu0mjf+qu}} diff --git a/actionbarsherlock/res/drawable-hdpi/abs__progress_bg_holo_dark.9.png b/actionbarsherlock/res/drawable-hdpi/abs__progress_bg_holo_dark.9.png deleted file mode 100644 index 310c368e7a68479307866c479d1e4eefcf5db311..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 178 zcmeAS@N?(olHy`uVBq!ia0vp^96&6^!3HF|1ZAax6icy_X9x!n)NrJ90QsB+9+AZi z4BVX{%xHe{^je@`h^LEVh{nXLlN`Ak3Qu?vqkba5WyT9CKZ;N%wBhP~?hKK2LK3q{Q@b8ror6q0>Kp=4vJYD@<);T3K0RYm>I5PkM diff --git a/actionbarsherlock/res/drawable-hdpi/abs__progress_bg_holo_light.9.png b/actionbarsherlock/res/drawable-hdpi/abs__progress_bg_holo_light.9.png deleted file mode 100644 index 70cb7fc7e0bcfb850d4b365f1bccb5b743913e21..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 174 zcmeAS@N?(olHy`uVBq!ia0vp^96&6^!3HF|1ZAax6icy_X9x!n)NrJ90QsB+9+AZi z4BVX{%xHe{^je@`fTxRNh{nXLlN`Ak40u@7AASF0zb~yy)74d)-}Q|XM+&=H%L1l~ z70X`DZ5Q8J;=>T6aJiv_zhUdQx9rw$B!4Wi^!v;8!uD-LM?h!CZ3$B@rZO?tz^Iy& QK(iSCDOJO>Ym5d24oA2hD9A9kkZ#C-ocYxQulY$%dG^s1`jD zWrBMf{hI5z?Ps6d&cAMwxpu9tAQSLC;sV+l?CI!atlqGv_K~X}S&7D6#irA$G%zcr zGa^}SvXODrvrsWB#ZkB-c}-Y}>Q0!#L#9IQCX$ZI#7DnF9fJ8(R=8iR{NJvIR3GfdBS0fGXvSYugM@B@Fy~s_l`Jy)|ccqHxmVzApHz{x4N{y z#Xj0V$LH=@zsWY)$4Z)6--edG^VYGh&b$}$F3XeLt5=Uu0`p37@FaypB&t$KuAm9R zq*|yt7WOdr(m%g{dU1bs0-qy(nh~3JDc<<|K^(;cR4G!8UrKd|p;N zi5zZftW#Kk#vM}fdS+hLQ#;Dq?H?_`8P1nhqmR=j>Au${MMR)hh&5HCA z?cjx6pHV1ZFFx`ra1m|YMALE$u3RAxZp(6Eus@DJwzn!G7Cw2Mm%K&AN5Ia`DuuPd r`dvHM#yxB2nYDo;0!e2cs)*3P7gB8$K+RT%00000NkvXXu0mjfr&_ZI diff --git a/actionbarsherlock/res/drawable-hdpi/abs__progress_primary_holo_light.9.png b/actionbarsherlock/res/drawable-hdpi/abs__progress_primary_holo_light.9.png deleted file mode 100644 index 1c269205e874bc6addc308efe5be4fb7c5da0edc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 917 zcmV;G18V$CDOJO>Ym5d24oA2hD9A9kkZ#C-ocYxQulY$%dG^s1`jD zWrBMf{hI5z?Ps6d&cAMwxpu9tAQSLC;sV+l?CI!atlqGv_K~X}S&7D6#irA$G%zcr zGa^}SvXODrvrsWB#ZkB-c}-Y}>Q0!#L#9IQCX$ZI#7DnF9fJ8(R=8iR{NJvIR3GfdBS0fGXvSYugM@B@Fy~s_l`Jy)|ccqHxmVzApHz{x4N{y z#Xj0V$LH=@zsWY)$4Z)6--edG^VYGh&b$}$F3XeLt5=Uu0`p37@FaypB&t$KuAm9R zq*|yt7WOdr(m%g{dU1bs0-qy(nh~3JDc<<|K^(;cR4G!8UrKd|p;N zi5zZftW#Kk#vM}fdS+hLQ#;Dq?H?_`8P1nhqmR=j>Au${MMR)hh&5HCA z?cjx6pHV1ZFFx`ra1m|YMALE$u3RAxZp(6Eus@DJwzn!G7Cw2Mm%K&AN5Ia`DuuPd r`dvHM#yxB2nYDo;0!e2cs)*3P7gB8$K+RT%00000NkvXXu0mjfr&_ZI diff --git a/actionbarsherlock/res/drawable-hdpi/abs__progress_secondary_holo_dark.9.png b/actionbarsherlock/res/drawable-hdpi/abs__progress_secondary_holo_dark.9.png deleted file mode 100644 index 40d0d1645cbf05e30bf092ace45403281da7f318..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 188 zcmeAS@N?(olHy`uVBq!ia0vp^96&6^!3HF|1ZAax6icy_X9x!n)NrJ90QsB+9+AZi z4BVX{%xHe{^je@`oTrOph{nXLlMZq=7znVWA2oV&$ZSjW?F|h7ziq5jS#e}ezd(V) z{M(JTeF@SBrcbxn{QE=WZYK^04VRD=846z*9&b9ovtVvpnl(eT%D#{N!SzC3^S3#* f<|u1MCr7h0-;i__`(soEw28sf)z4*}Q$iB}%FaDT diff --git a/actionbarsherlock/res/drawable-hdpi/abs__progress_secondary_holo_light.9.png b/actionbarsherlock/res/drawable-hdpi/abs__progress_secondary_holo_light.9.png deleted file mode 100644 index 40d0d1645cbf05e30bf092ace45403281da7f318..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 188 zcmeAS@N?(olHy`uVBq!ia0vp^96&6^!3HF|1ZAax6icy_X9x!n)NrJ90QsB+9+AZi z4BVX{%xHe{^je@`oTrOph{nXLlMZq=7znVWA2oV&$ZSjW?F|h7ziq5jS#e}ezd(V) z{M(JTeF@SBrcbxn{QE=WZYK^04VRD=846z*9&b9ovtVvpnl(eT%D#{N!SzC3^S3#* f<|u1MCr7h0-;i__`(soEw28sf)z4*}Q$iB}%FaDT diff --git a/actionbarsherlock/res/drawable-hdpi/abs__spinner_48_inner_holo.png b/actionbarsherlock/res/drawable-hdpi/abs__spinner_48_inner_holo.png deleted file mode 100644 index c8358e9cefce502030416e05dc8faff139b886b2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2081 zcmV++2;TRJP)YIdx5%v}IY-E={))x>B}kD^;1aO=v<01PBB|;(|LQ1lm?k zLWq;Nn-CY=ae0(~!^>I`t6s zs-B%JpquWw-vVT&b%#DKYKZiAR|9AYVtSC>+D1~E4^t2*_YE}4C7t2scS_b&i9ji7 zBYSvMwdlT0Go+O!I1;=rq$n|BisnJx=53v0;@hqm(7l)*=4rJMo!clNrP~Z@m{E-} z^JZ{ZNHx@{flX?mQSo``X|C|5u79fpM_&?X60Kt|A5rbxJ7+XZpRQ<_6xsZ!_#wo! zj#h1_U5!M-Io2>ob>UEYg+LRijsxnVI$Sub8=TigMynU~iXTIjns`*ZXjCM8l?je< z^3e1OfW}cB&*(9#LY#4(p+|S(CFYo)RH;RK=~N=zD5YZ@e|b@)#etF>)Z-yez@UzD zxn@bF&zGN~8oIPk4dfy-rEX5Ww8$EZ0F70%U;9F1W%-Z($&Ga-Maup1vncKQ7_DKl zn9!@7d$FjFqs1PKM)U|Dr6$Db)oTnV%fNxx{Okxr+DM%Qs^$R=K0p5VBBLXP|Go*uWAqrP!s#9EjG3Y5H)_%&0w$xIP8)2<gS?toB)4w_5VP~5v52jeNf?a@l%z&Ft# z7nB8|dUgD~fFBhAa+9}!Fnz66uJJUZMq$&Z-=x+YQJfJpw%hO;S zbE}u#&MHNeP>Upl#AP)>l0hdeKfNO4(#tQm-Akeu&02@RbFR7XY>6_k1%f(YAT(#fsAW zCKBlg4QBOIpq?mn>zJh1X=9x9hp4F}kQ(@481j?!sz3o)0BA?xOCB;{@vwLHR_qA* zZA`n>5_V~?==zrnj46C`9p$WNjB&zGc+-W7;QUT(*KSn_p>ds2!NyfVppL*7{NFHR zx3J%}=U0sLd(^D`)P?PxcXaJb1;-WXet3d^dmIcA@AOk%p(p(THF8j!=km|#V)bYd zpicX$PljfTc@O)})|@FD=Z~mC2i2imPj;N6y7k2(V~h2N*p=p#-z6}HxcB*hYkSJV z`IFSdb9yY-P}dA6b@>ZL?=z9&3we?^d^OD4aqs1Mx13&f#Qiy{cDn?wohTPSPjL-WpW1m}O&Ju5YPHyotYlm=9`GcY zrwYvY8;-f&ZSM33oCpsge2-Ip%afm3V!sl6q6gM{kN3J3%|Xrhwg)`uVUIiGY!FzE zIO3Qa-0aQX;)a}NjB&uQ|K;9KmvHqg(MeCoc*sw<&DEj$2|GyBp7MmJgBi=!jyvfZ z$6Ymtf^mwAKHp@Hd-~&L-Nsi~>l_hPjymE9wjDU*%(E+7 za!uA`P2O+vKSpg~;?JJlUH||9C3HntbYx+4WjbSWWnpw>05UK!F)c7SEiyAyF*Z6g zGdeOeEigAaFfi_TCsF_a03~!qSaf7zbY(hiZ)9m^c>ppnF)=MLI4v?WR53O>Gc!6e zGc7PTIxsMwC7)_* diff --git a/actionbarsherlock/res/drawable-hdpi/abs__spinner_48_outer_holo.png b/actionbarsherlock/res/drawable-hdpi/abs__spinner_48_outer_holo.png deleted file mode 100644 index f62f74bb38e8818fd970b7ec1f7862e543cc9d07..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1811 zcmV+u2kiKXP)Q(x@RlU0R z*6*F+o^#JDHf2*b#j2Gf_PMBSbuGRn) zDJUkGcinCw!4`)d@_D~EMJnC5dvGXBz z^GjW6Gg4BPB{MBwxqQWN<0fP#?6J=Sj@WNJ!AH@8Kl`>9L$xnJF(@mqT0WPnt1qF1 z=Fx+;deGw@bGK5OQ+L*P{Upq+6DX1yGQbK>T~%EkI?XGa@}$o>ppa%>^8?Sie*2l7 zfHK3%D>%7|N++0Avr7*8vd@}G^Jo0fcfyUHfnsLZ&jU?a6Rn7I58e-AIzUHA66jy!AvGyBgcAIA_8&ya%2-o5w@+x^Frq z7x5uqjDu?ciVPZ-34&-=b^T>U$i3owu8N|PCmm@W9a)>Z@0e@OLVt>;Q1iTBsK`Y- zJ#Dm0pva)1q@Sv}wFUZZ<(6Yki*muoJ=kjDtmVDYq#tH=k$<|@5vTpkf+%-~CzQJb zDj5=FGBxvks&SW*YJTnCqA2*7ySf013>jGQpITpe;Jn|eigLRhZQhTXHIx~a$pm$C z{nZbIsz13R7nL1tHd-@KF*$Um(og?cC1;!x<)VYeI|B_UB@HdgHw5UWlj@?}cDp+O zMal|-j9w2i9i`?Cb8^v;J)JZZ3@FG_LfsGv{MVdZZorO4w{8Y134%<%0TH$=m)%OW z_@u(SziK>nET6ihG`KOcU?%zJh~m2+ycN)r5;qQq+h%%Xy;f)Ejn0a3UnsuS^+vZqWP#0th z#x}@k!|oI0qU+rNRV>J4GUFR$v|a9z%jMoM-5IE6CMAy{ll?bZ%p5f-7cDwzt|L%b z^86*Y-fp1pM3X+OAj(~JqWJ*PYCpbZCY5MgZSAj)V(>vz$zUg(ZywPKsOqx1Or~s4 ztCPVxWShrQgx&N<^IZW2u9-7hOofKj5BzxpoW= zdO}GqH|+&2+j}j6LUh@cv}2FCzaLvtWZ?^TwHb8;v&L-C`+P^-e$fT!yBz5Da{oL7hj@h;h3%R$P7X_J;dmT2? z8&V8*_<~22M7c%3b3D}BjlNwczv7fZds1ebGU8;svesTmESU0X4=BlHYF_eOt8iaY zL0I~yq8N;M$m4dU73%)xM=srNe&@#dxWo1;CZw8+{^f0pouFbc zV#*`lZz%0)HGlQf<_c&{Ktx7;z}?CzodgvZopY&OUp7)Q;eaFVO?})iuy4L9j zyLs2K^qSz1EvYP7>Ws{|~_-QddT;IiL%she&}m+lY?b~t3u zik_CPT+O0+6?K`iA!CLOr{nnY$OW(ay)*42s|TRe$lC9I+YPJ$b-IG8H~q!myML>= zroa>ruDyrb zV`&jHgSNQCgmI$=lu=hRYuXKOo3_xM&-4jsmA;l<3@^Ph&(-?zXM#=Hludb0$^QZH zs3&Vcm*{c;001R)MObuXVRU6WV{&C-bY%cCFflPLFgPtTGgL7)Ix{mmGBYhOH##sd z?sz9s0000bbVXQnWMOn=I&E)cX=Zr$HaasiIx;gYFgH3dFrOu# z?f?J)8FWQhbW?9;ba!ELWdK2BZ(?O2No`?gWm08fWO;GPWjp`?002ovPDHLkV1l}_ BPJaLZ diff --git a/actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_default_holo_dark.9.png b/actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_default_holo_dark.9.png deleted file mode 100644 index eb28ff9a5516c15667fa8fafbc22d608d1f77a06..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 311 zcmeAS@N?(olHy`uVBq!ia0vp^%0O(y!3HF+1t+BgDVAa<&kznEsNqQI0P;BtJR*x3 z7`Qt@n9=;?>9s(?o1QL?ArY-_Z*Jr|WFXM+FkX}IYI~tj_}8!bFJ^a4j((ibs-&WN zGIsXEx)Wtn`lnsEAmpSFI79ccn9RKAsn<`<tk;t}o>yjV{qp%WbL{dki&M)*dw`x~@O1TaS?83{1OTcY Bcf0@q diff --git a/actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_default_holo_light.9.png b/actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_default_holo_light.9.png deleted file mode 100644 index d281adb553af892f758407b846bf31810b9d776b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 312 zcmeAS@N?(olHy`uVBq!ia0vp^%0O(y!3HF+1t+BgDVAa<&kznEsNqQI0P;BtJR*x3 z7`Qt@n9=;?>9s(?Tb?eCArY-_Z*Jr|WFXM+FkX}IYP%rckLbO*zpbz{y7bYSIrPClD)2Hc3qcaC*%7oYhKR%+5DyWbJ~oU4#{OKNlluqE0VJm zR?Ud&kaA;Q)O4{aB-unUR3g{I@EB82%f_aZWF5r`AFqi`v@HN~5*v&Qo>cRA$gv99 zHaapFv&*%1#4~?bwda`9)~}vNKHF@K`t|cGZ}Xb{RR4x!PC{xWt~$(69DLj BcXj{( diff --git a/actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_disabled_holo_dark.9.png b/actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_disabled_holo_dark.9.png deleted file mode 100644 index b2985860907ac324b509b76731e8ef9e01bcef39..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 306 zcmeAS@N?(olHy`uVBq!ia0vp^%0O(y!3HF+1t+BgDVAa<&kznEsNqQI0P;BtJR*x3 z7`Qt@n9=;?>9s(?E1oWnArY-_Z#r@{8;G<#%>2r*^uo7)-)HXL@_O1Ny%Iq#{YfeF z(mvLmIJH1t&`=}DOJmBWhqv04yB582t6X;JXNKdwfEg3JZl{PztUeIIdQ8h8YDr!LqoiBzejNy&kDcJs%rP689)vmGI{X_;^jtl6gm^<0^v)GdFRa+YOJx z7F>vKtz@b&Rr+MtRJ_Cdn)*bIu9V&{pI@`*?C`z(Yf|Vzp#K;=UHx3vIVCg!08ssU A5dZ)H diff --git a/actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_disabled_holo_light.9.png b/actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_disabled_holo_light.9.png deleted file mode 100644 index 4215396dd4e51fea9239323d313b72fde0ba86d6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 306 zcmeAS@N?(olHy`uVBq!ia0vp^%0O(y!3HF+1t+BgDVAa<&kznEsNqQI0P;BtJR*x3 z7`Qt@n9=;?>9s(?E1oWnArY-_Z#r@{8;G<#%>2r*^ujlV;{V25Ur(E)S0c!zKPhEi z+Q+&RrxwTy8fpZ2X-wJl@K&30*P>T$mCG*u%y7IHFk@oZ?G!PI)dwP2k7*f%?N0KT z=P~Pe`QZt37-AUDv?qm~sFi(Y>bsQr3FCw4S+92))lbOG-Y30G>`_~0 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_focused_holo_dark.9.png b/actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_focused_holo_dark.9.png deleted file mode 100644 index a280eabf59b5eb69fa2a84280402b63d5e1bb8f0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 524 zcmeAS@N?(olHy`uVBq!ia0vp^%0O(y!3HF+1t+BgDVAa<&kznEsNqQI0P;BtJR*x3 z7`Qt@n9=;?>9q_DjO#pI977^n-`=$MKI|ZI{A2#4tV=npb9cQAXy4X!_bwM}{Q4K( z1sl8bnxc=22fURRmTQmkS`l-5N%{4LzmAq3{WkJ?oSyR(lyW*m>cW(jDj1r7drC_% z+Ahf4U7%?EfVHA#U$%eE)HUhV{* zGqMRv58QeS1t+_UJh{!Nwtjop`q`x&KXzE!mvvsrOU)9V|3+xFYu0w7ttSN+pN66C zV4oMA@AG&3wK%+`$wcPZ<#Ux2T-c9-*heq_yZUm|{V%D1UlxhJm0zYfUETgVr;hpA zt-Fj|Jsx=O$lYh^6WL+vBibSA6WURD#!g`Ij9SHG25Jg!2FnzxlYN}N9h%V=a_mM! z$e|leQ;yweap>IrEpmd};fhV2Zrn5uN|m^)*v*dyQIi{G2ej@g`j zy#1roz10ezmNeBYwbLI^0W9{MT&2dcxOa)`zb@?O?Gu2 z*S413TzCHUdV}>`f)DaiKP_4HkL&Y-WAl>F%y}d1AGY65et#XKh5dqWo7Y|}14bu< Mr>mdKI;Vst0N8Ej(f|Me diff --git a/actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_focused_holo_light.9.png b/actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_focused_holo_light.9.png deleted file mode 100644 index f8d619b4d47ab5b104d6b1042c27fb16a3beca47..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 523 zcmV+m0`&cfP)C3<00004b3#c}2nYxW zdK`GU$CA-E+tg1FUj3CV1Ez}l7r{NB_YWZ zgb+-Kh;2qAgunr)owSNT9jE|#(}iQ{0=K~F)j_f4%AIwfW*LI4SCjSena$3zhl@?`-N)f>fC&00iU>|7tSL}YGdG832Z z7Ry93w=$W@5~IozqskJa$`YfBUCf~8@-tLEe(Yg7ZJ&$d5^vAJVlkbz&)H#>=1rCU z=lI*@D9QucAy4<)W_$YF0~q6}sI5vC!>ie*fX@E1>5KTAKqegRE>ywO`Fw(I}^ N002ovPDHLkV1grX;W+>R diff --git a/actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_pressed_holo_dark.9.png b/actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_pressed_holo_dark.9.png deleted file mode 100644 index 955a2f34061ae8ac853050da355f89409fa0a784..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 464 zcmV;>0WbcEP)C3<00004b3#c}2nYxW zd0`Pl=$b2!s#>@tS z$Y#JV#)+K6SU+tW#+_RkXYzpRi_e9eTN!5>F{(z4su81V#Hi{OLkTB`etUYuM1<4( zFh4)_STHCiBAh-(+2ze7j|0M$*V@)G5^^0JhFHh^fzV_7Tf?-4Si|T*tYCB@#xY$W zMloF>#xN!zMlhxzoiQdMoiL^$+87%UEsQNlYm7|@05m?}iO1-}bYl(D3Ue3c7gw}A zD?zp;CtICi-;5NDtN#ybjCs$)&yQmArGt<$4!&l7(HXO5p7J23`oDJvMC3<00004b3#c}2nYxW zdPRE!~6H3V|7LaeL+kwzxO}{DvWjdA^uWhB*Ox4MVbeVt$Spwgkx< z!VkuXjKgSuY)h6Hw=%|LL;AyKLdLC(F?ASO9Y$7%k=0>jHH%rr7Kwb5&>UvDaCo}j z=j+357qeVAJX{{~a_138(!I8ROa__X7ee%7enXtUzOE0mAw(ah0z?m{B1Ao=21G5U zCPW=Z0YnW(5u`pwA*3EgF{C<11Ed;86J&FYMhHOp8-||_vny?o%`ne52fWVraQiWC zKdv-wupMF9(yd;3%<<_PN8|TOh%C!a80|#$F{54SO;q)d{~Z)(nS?QFWpYf|szS`q zFpt2hCCEz5&mZk`@i_(t4MLWruXxh=CcXUn1{k8P{&E{)e*gdg07*qoM6N<$f@(ay AcmMzZ diff --git a/actionbarsherlock/res/drawable-hdpi/abs__tab_selected_focused_holo.9.png b/actionbarsherlock/res/drawable-hdpi/abs__tab_selected_focused_holo.9.png deleted file mode 100644 index 673e3bf10d60cc54b6dfef2fcda24575073adf61..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 147 zcmeAS@N?(olHy`uVBq!ia0vp^tU%1i!3HFsuehcLq*#ibJVQ8upoSx*1IXtr@Q5sC zVBqcqVMgJWBc+iXw=G=Ra=)z4*}Q$iB}l;b6k diff --git a/actionbarsherlock/res/drawable-hdpi/abs__tab_selected_holo.9.png b/actionbarsherlock/res/drawable-hdpi/abs__tab_selected_holo.9.png deleted file mode 100644 index d57df98b501944b4ba63623766c396b5bccc29ee..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 148 zcmeAS@N?(olHy`uVBq!ia0vp^tU%1i!3HFsuehcLq*#ibJVQ8upoSx*1IXtr@Q5sC zVBqcqVMg}h~fd(*my85}Sb4q9e0H>EG$N&HU diff --git a/actionbarsherlock/res/drawable-hdpi/abs__tab_unselected_pressed_holo.9.png b/actionbarsherlock/res/drawable-hdpi/abs__tab_unselected_pressed_holo.9.png deleted file mode 100644 index aadc6f87b21d7d5139f3bfe860f4c289f75d241f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 145 zcmeAS@N?(olHy`uVBq!ia0vp^tU%1c!3HD^Kbl$tDVAa<&kznEsNqQI0P;BtJR*x3 z7`Qt@n9=;?>9s&XV^0^y5RRG22KRnVX>4qKXwM^^Uwi5RN2-aD!@msM(PIt=evwJLPDoBk{4*AEnmdKI;Vst0H2gA*Z=?k diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ab_bottom_solid_light_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__ab_bottom_solid_light_holo.9.png deleted file mode 100644 index 0706c8af658bde9602634950dfe3d5fa5886163f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 134 zcmeAS@N?(olHy`uVBq!ia0vp^QXtI11|(N{`J4k%zMd|QAs)xyUfsxfz<`JK;_Z5A z-Y@ApO*&r-OgQM+#9X>wkYiu(tId138dhyGKCm}H$eLN@qysZ=3D*)nlM7YC@0xyy hn}nCMmBhQI$CPR`ipOiMnG7_T!PC{xWt~$(698&aE5rZ* diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ab_bottom_transparent_dark_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__ab_bottom_transparent_dark_holo.9.png deleted file mode 100644 index d814d02d31183b8f00f475a05c124004983d9eff..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 123 zcmeAS@N?(olHy`uVBq!ia0vp^QXtI11|(N{`J4k%PM$7~As)w*fBgS%&%9EC|%_%783w8jlt8^&t;ucLK6TeKPwmj diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ab_bottom_transparent_light_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__ab_bottom_transparent_light_holo.9.png deleted file mode 100644 index b139c8e49168e4404df0a46b30a4b30e90c1ccff..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 123 zcmeAS@N?(olHy`uVBq!ia0vp^QXtI11|(N{`J4k%PM$7~As)w*fBgS%&%9ECY>s_{MVWOZ(=mjBT1_sGr W&p6(H%v1uJ#^CAd=d#Wzp$P!PC@9VV diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ab_share_pack_holo_dark.9.png b/actionbarsherlock/res/drawable-mdpi/abs__ab_share_pack_holo_dark.9.png deleted file mode 100644 index ed4ba34ecd9f8ab8c557924fafeae6a89307bd7c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2851 zcmV+;3*7XHP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0000^Nkl8n|1&I002ovPDHLkV1j6N BM!Nt2 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ab_share_pack_holo_light.9.png b/actionbarsherlock/res/drawable-mdpi/abs__ab_share_pack_holo_light.9.png deleted file mode 100644 index 8f10bd5222239e82e49c5120888fc9a07a324b42..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 122 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+1|-AI^@Rf|M^6{W5R22vKmPx>XSQNv;&5z| z@wwFK#IyY<~E UNZ9H+7ibuRr>mdKI;Vst0LZr`*8l(j diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ab_solid_dark_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__ab_solid_dark_holo.9.png deleted file mode 100644 index 743d00b6cd7e446c7badca9dd11d1579404569cc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 133 zcmeAS@N?(olHy`uVBq!ia0vp^QXtI11|(N{`J4k%KAtX)As)xyUQ!e~V8Fq8aW6aH z`M>?!MSK0VJ5DH+1)MRKpSquM-S5BdOIN+&sn~jE%jQNlsf-1UY_}X6mMgq#dKVMx ha^q%Y#@a>3az|3`-r6;1y%^A322WQ%mvv4FO#tkfF|q&v diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ab_solid_light_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__ab_solid_light_holo.9.png deleted file mode 100644 index 17c1fb921f9b7b46aaeefe7afb8302874fb0abd1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 133 zcmeAS@N?(olHy`uVBq!ia0vp^QXtI11|(N{`J4k%KAtX)As)xyURua|z<`JK;_Z5y z;?s*`91mY+Vs~LvSAIRQ|I~ek>wo_(4hk(}+Y^;`>!t%UugL`m=C=w5f(6PQ%h%~C hy?JA^CG4Uk|5eN5b2qlEYyz6g;OXk;vd$@?2>`YpFM0p~ diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ab_solid_shadow_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__ab_solid_shadow_holo.9.png deleted file mode 100644 index ddfc8e3d5c4131f2460254f183938477fc5a0679..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 168 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+1|-AI^@Rhed`}n05R21qr&#kfCPg`@kT=WR_nY-)l@u)2m z9YjR(TNrC5J8zlf@MOx-MX#^q?zd~tP;1Ok`WbQLQ#YGy{=Yfu7pEGW;JmVaai5Cr S@!LSF89ZJ6T-G@yGywoUXh2*5 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ab_stacked_solid_dark_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__ab_stacked_solid_dark_holo.9.png deleted file mode 100644 index 007a4b239244212339b817f8de9474a4dc34fde0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 134 zcmeAS@N?(olHy`uVBq!ia0vp^QXtI11|(N{`J4k%zMd|QAs)xyURua|z<`JK;_L&H z*gyPBj&nSGnTg$nOT)YjBQU;+O3-o%)BNS9GKrK90(RDcPwA0 ir}XBH&6co>lKfV`a~Jh`>I4G~X7F_Nb6Mw<&;$VSc`p(G diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ab_stacked_solid_light_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__ab_stacked_solid_light_holo.9.png deleted file mode 100644 index ad6e1a4d9f3c81e20676f979a53cea2084ce903d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 133 zcmeAS@N?(olHy`uVBq!ia0vp^QXtI11|(N{`J4k%KAtX)As)xyUQ!e~V8Fq8aqs`F z7bNtyi1zwxcbrft3piseKXpIjy5E1@m#%ulQ?d2Tmd%Z9QW*;x*={*DELV8f^e!gW h<;Km*jJ1o5{)rFFF7K diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ab_stacked_transparent_dark_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__ab_stacked_transparent_dark_holo.9.png deleted file mode 100644 index 0ad6c888b4c7e436e7d7c78432dbfdaecc95a7ac..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 127 zcmeAS@N?(olHy`uVBq!ia0vp^QXtI11|(N{`J4k%Zk{fVAs)w*fBgS%&%9ECxB?U?=uVx Y$^4u51wHGE0Gi0)>FVdQ&MBb@0N@ZURR910 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ab_stacked_transparent_light_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__ab_stacked_transparent_light_holo.9.png deleted file mode 100644 index 19b50abcb536602cf2cd36d5a19805464988bd20..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 123 zcmeAS@N?(olHy`uVBq!ia0vp^QXtI11|(N{`J4k%PM$7~As)w*fBgS%&%9ECmdKI;Vst03^XH%m4rY diff --git a/actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_default_holo_dark.9.png b/actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_default_holo_dark.9.png deleted file mode 100644 index 5461b9c00fd3fc513aa4465682e70e87cca36a6d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 101 zcmeAS@N?(olHy`uVBq!ia0vp^EI_Ql!3HEv&)kdyQaYY4jv*T7lQS|h5*V8PD@dJb zGfWV2j%0YY@&Et-(u-Ft=sZxsVYp-gbGr;f^5z}?TUWk$0o2Ff>FVdQ&MBb@07WJt A3jhEB diff --git a/actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_default_holo_light.9.png b/actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_default_holo_light.9.png deleted file mode 100644 index 5dc6f804aea8ca344275ac6eb497b6bfe0f117f3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 99 zcmeAS@N?(olHy`uVBq!ia0vp^EI_Ql!3HEv&)kdyQd*uajv*T7lQS|h5*V8PD@dJb xGfWV2j%0Xds4&4P&{4SYp+J&{BRiiZ!)425)ejdW>;mdy@O1TaS?83{1ORBM8sz{0 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_focused_holo_dark.9.png b/actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_focused_holo_dark.9.png deleted file mode 100644 index a70b53c59af769e3c98973ad9718670ce27259ff..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 109 zcmeAS@N?(olHy`uVBq!ia0vp^EI_Ql!3HEv&)kdyQYM}*jv*T7lYjjGZ_h07hy7xL zS%<;BUsuG{45zRSgeB^>bP0l+XkK D`1l&; diff --git a/actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_pressed_holo_dark.9.png b/actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_pressed_holo_dark.9.png deleted file mode 100644 index 85d7aadd4dfb619883f68f1cc63e629698b5dab5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 107 zcmeAS@N?(olHy`uVBq!ia0vp^EI_Ql!3HEv&)kdyQbwLGjv*T7lQS|h5*V8PD@dJT z6Fe3@|6GeFPb#ATqtK84|Mweqan0i3X%}$jvMQLwz#trO`SaWQ^{znO44$rjF6*2U FngE5o9^U`} diff --git a/actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_pressed_holo_light.9.png b/actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_pressed_holo_light.9.png deleted file mode 100644 index f7b01e012f895bfe2c4241e1d48771fc372b35cb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 105 zcmeAS@N?(olHy`uVBq!ia0vp^EI_Ql!3HEv&)kdyQU;zbjv*T7lQS|h5*V8PD@dJT z6Fe3@|6GeFPb#ATqY%TTAPubyB?B2J9?cgAJee4pt{u!zH{AaisF%Uh)z4*}Q$iB} D0X-aq diff --git a/actionbarsherlock/res/drawable-mdpi/abs__cab_background_bottom_holo_dark.9.png b/actionbarsherlock/res/drawable-mdpi/abs__cab_background_bottom_holo_dark.9.png deleted file mode 100644 index d8f1c8bd54f4f091e79389603095c99cf825cb6c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 127 zcmeAS@N?(olHy`uVBq!ia0vp^QXtI11|(N{`J4k%Zk{fVAs)w*Gcqy~4zxBtu(zuW zGMHg-@7EW5UBeRx4_{GYv)%pQnG{Mujhr&UNqv-pZ`Il{xB Xs2c0@Tz2whppguou6{1-oD!Md5lfPH{+~ zs&ZK!$GJ#`+OXn)bEl7O^s7vMLr%~_eO6@BP#xDsWzJIxbKZ~=QHwoEqiCN;6|k~9&?6VGu8wVeg}kjlqBUkXd|o%rApJ7Xx?SmelE6^*`N?mP%?P7H@yM z@176Te{31>^aeVqCP$2D`iM8b&G*loT1#z02OAN3)TGUD#xbYXQgqexFre>@9yw_< zoN>t9>xRrEIA?_IE1YrUo=P<2hNadJXB=4rbb%a&IXb5^sO2P4AoU2`8OJ_N3+RuU z?3bPMlGWJT{|mv5xDeck3qc!^Tkv+yM^@uWqQKxnw{tZ6G_7EN(=@mR#5tHjEptZL zT?o!N^e&F18P*7EfGlP>S;He0o_$19Sz!q7up>N&hdzT z+KgUQr1}UkLQL4KR;yolWSqh_YPX?lMz7!1&pz~~fd%z~_Z{#V_yT+aKE`}mgO%s( z*Zy2en({y`_&;C`{0061zkwyNiuqzpAev$qeWYoU3d{J#NzC8IACaX$H=;%xu?3!~ z#a`2j|4di>P9KpnLiZ0Fl^vDJdHW{hJgNDYHbk!VsHwq51hhtobGl;RmY>GHkg{)E zesWUhFRGl6)Eh$fMU__)%@X*lTj%8LuWk+fh;ux9b*`$4|A#h$uKO0E`Tzg`07*qo IM6N<$f=1Pyg8%>k diff --git a/actionbarsherlock/res/drawable-mdpi/abs__dialog_full_holo_light.9.png b/actionbarsherlock/res/drawable-mdpi/abs__dialog_full_holo_light.9.png deleted file mode 100644 index f18050ea589eaa31233bc08e4f8a4e361747bc94..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1003 zcmV%vbFc60S)hq5aquQtN zO>~Q-PMt}eDy?tfo9G5^U3x~HVu{=o-l^#5`3AXbFq#7CZ= zx~R)Z%-PngELWXE=jG+4wH{HY%RHtL$z+_dj#xsD@Y&isDVlJd1j7%A; z{S3ob2!NCVl}{yrl8B^V**9f-6IC==^T()w$-W%VAY54pg(^F>UjitZxrB-eCn8Lf zB*stQ-rl}17K`6RG#lbS(&{_eIc1V`#=6_}di{5~T>e4x!ZPZXM|a{QRmt`XV*pbC z)5T)(D?{j2cRHWXf1>hHw<=z1GC@s9Ro2lk0Wc$?r`}K3Qx5<^GzKt(+iwt@SwZ#Y z1K3Z>bSEt!roEr8rydA`NJoVD>nPSV+2(05UE>4T005_GAOuI89vS#iG4B18N9tN{ z^Z@tNBTj+gCOB47*w+ z+2Hb~>!f2H1$Hq!D=_Sb+i%D|qnZ-1^bbIwX<}v&QHjdz0&e>kOOQ$(hHgzP5DjJz z0f>y6M3En>w55Wi4nf3bKUf4p>o0~xvY>6}4YBjHqH^B)8ba{Lja`ks{5OurR;$m< ZjQ=n8%sUGgc=rGR002ovPDHLkV1nUn!$<%C diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ic_ab_back_holo_dark.png b/actionbarsherlock/res/drawable-mdpi/abs__ic_ab_back_holo_dark.png deleted file mode 100644 index df2d3d158e201f4b5bc8f478bfe194c819c762d1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 466 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6n3BBRT^Rni_n+Ah2>S z4={E+nQaFWEGuwK2hw1@3^B*n9tLu5dAc};Xq+#-xYx_sQH13|{`71Pj-*6Uoi`#n zE(U8IKgsQz<^Rb4R70ym$22iPZttV^?_#_6n&0#=x|;ZH&dfx!jETDzs(0U>)g_uQmUhGGNWo+VotE}_5b3Zj`hnf_E}Q2 zkoV^c&!VIWreR+T-g@7!2<2C~cxLXYh02~hOPyXw&7V2OC7#SEE>Kd5q8W@Hc8e16}SQ(iDxmE@S#`ha8qiD#@ zPsvQH#I3=p$s!-9K@wy`aDG}zd16s2gJVj5QmTSyZen_BP-2>S z4={E+nQaFWEGuwK2hw1@3^B*n9tLvudAc};Xq?Zzc+iX4P{i%w`)y*!lC}nMxxP5m z`ipDd|3l#c1q-`17wzs7jap-@cWTC&8}(D4%&X3GaM#!SkY4?Tswdc+PM~^5?gXjDEJr|A(9^w&s1cyzt=Kg=58+)D;SHpB%sRSHFHUToUy>RV`*x3 zp=*`d7Z@F1xvAFw#q#fW_g_%cHx(CZDFFIJwZt`|BqgyV)hf9t6-Y4{85kPs8kp-E z7={=cTNxTy8JPmPRt5&f_Zu#wXvob^$xN%nt--0uA|I$h5@bVgep*R+Vo@rCV@iHf fs)A>3VtQ&&YGO)d;mK4RpdtoOS3j3^P6 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ic_cab_done_holo_dark.png b/actionbarsherlock/res/drawable-mdpi/abs__ic_cab_done_holo_dark.png deleted file mode 100644 index a17b6a78920848c37a67246a76749b4cc1425a15..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 566 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE0wix1Z>k4UOiAAEE)4(M`_JqL@;D1TB8!2v z2N=7Z%(epwmK8Xr18D^?ZvQoBE&~Ijou`Xqh{y4_R~-EgIfxwlm><>K$vu5h!wc4! z9iP>XtrZVs65@3e-rKIN%Hh(x{ewWxt1j(s|L*kJ zSoUnickXv5=i7?TNH`^EJfpg4#&4;Y0qR0+drTg2JXGfUq3}Rr;{P9f_n*&gD7KkW z&D4IqLivGGRq&kmAH6(eA0`F~7S8rex88HAVS=03cY~80?cpzkFa4S5A6;t}xJ7Q# z9-saRVPfVT##U33AAO3A+Ypl|_94?@cK)tT4*8AF;-^j1iVm!a-M-<=iX&Itr@TnW zJpXO;4EOj9!Ar}#BHVL6_dHGGELXBQqN>Q8)gj~`k@s=>rw|ur?|x;upO5s^{asBY zKb@S=&SWDRsQzHyR;N3i0@8Cfnf~0l`P3PA4VeH(Ut{H!I{}l<<aB zB5gMTgH*M|HKHUXu_VC#5QQ<|d}62BjvZR2H60 RwE-$(@O1TaS?83{1OW6u*u?+< diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ic_cab_done_holo_light.png b/actionbarsherlock/res/drawable-mdpi/abs__ic_cab_done_holo_light.png deleted file mode 100644 index b28b3b54f4c81d482f797f31936cbd4013c093b5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 552 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE0wix1Z>k4UOiAAEE)4(M`_JqL@;D1TB8!2v z2N=7Z%(epwmK8Xr18D^?ZvQoBE&~Ijfv1aOh{y4_S9ba-JBqkHTrZXEaifjpNYW7o zp-Ubd&IgJo2<&v8$G35^;Tskk#t2~^NlC?&yDV(Ca&uB1b9CBkO)cqrw|D8TKToRF zI(8j)Hm_*m)V}Gu(AmZ?>+lr!|Ew$fc6F-Mb^2PC^>5kCb?-yw@xD*CTf6%^rv51n zu|M&RMY8TuK!x`HjjgjxbG!Ig&nSGQ(EnVUqiU&qoaH15q1mNr`vuRlFlL+adKX`+ zs(G(GZ+*gGNpURMpV)N-wqLW)~-JKU!1N^uTZarp(au zRVr*pp2gnEY&GXI)J=?c?L+7E14!w(i?Kf2&j6te3n$Zi&Cq1Pnyg64!{5l*E!$ ztK_0oAjM#0U}&goV4-VZ9%5)_Wng4wYz$;u85o58|F#)LLvDUbW?ChR22(3jb0C6f zurx;QVw%w1wevX{81fiqT9$oZHH(4a215zM2{s3I28IOo7eJ#J d>KPlRN5&o6d@ywr|9haR44$rjF6*2UngC}HDAND{ diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ic_menu_share_holo_dark.png b/actionbarsherlock/res/drawable-mdpi/abs__ic_menu_share_holo_dark.png deleted file mode 100644 index 6bf21e307ed392bf00fe80b162a6ce9115e62c84..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 332 zcmV-S0ki&zP)h$s=>Sb2o({EW84x$2Sq@4Qvb1mj$j~;VIQBr2GX>%-APxay9!he7 z8W7h*gD?q**@0LXh%12j6cFzN;xHg)rA0Yl3bh0|IM)O5QD`2|BGz~0I$#-|1SL$5 zlJGbV2jtPKD8?58g7k0zp)`;V#9XwljI@z*K`Om-0V(CcdbDyt4~XM{*o)XuqGd@4 zDx{8=fp<=lEG6&%R0000-rS^s>8d@5ni2hppU0iV;YH8gwNa0%) z{Cz&}Jx|SbT`f+uL?986Pnf0|l@f5k0jz*^zeXXD13Pe$Xi*7R9^s5FmB7$P;6x!% z=kMH0V6IZ20v0@I38qpwTN6bU0_>(U;T<=GYX-1E8)QG}f-;!!681nE=wJ-aU=KPV z^-i_I3K%>@EawIsd5_!T)2R?x1}rE&N|%HcIQa;SqE5+gRv=Fy@M;YVKt`niqbhVk zpSlae%z=$G2Wp@TnqrmWnuKgf72^IDIDhdq{E7X5-;T%%62M`q*b}mOv3|8DyoG;R z;O#l^2#-VHDcnmy=|6xRPAT9SP9@+QP9YE&4z7Z?SGPkvc&h*a002ovPDHLkV1j;z BjTis` diff --git a/actionbarsherlock/res/drawable-mdpi/abs__list_activated_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__list_activated_holo.9.png deleted file mode 100644 index 3bf8e03623c94b68d31963ffe7e59c72c3dcc059..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 151 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqEX7WqAsj$Z!;#Vf4nJ zaCd?*qxs3xYk`86o-U3d5>t~CW>mH@a{g&g;s7!l1y4Byva-KaJLVIiI)OpBYodjS ofJx&-C1HsL_x|*Yp0_#7zz}{&aC*>dO_0?Lp00i_>zopr00f~Zw*UYD diff --git a/actionbarsherlock/res/drawable-mdpi/abs__list_divider_holo_dark.9.png b/actionbarsherlock/res/drawable-mdpi/abs__list_divider_holo_dark.9.png deleted file mode 100644 index 986ab0b9746301f2dd9401829da09e00995621b3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 78 zcmeAS@N?(olHy`uVBq!ia0vp^%plCc1|-8Yw(bW~qMj~}Asp9}6B-)+^BAxRtXRm= az`@Yw&#rLZUbzUUfWgz%&t;ucLK6T(%Mo}0 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__list_divider_holo_light.9.png b/actionbarsherlock/res/drawable-mdpi/abs__list_divider_holo_light.9.png deleted file mode 100644 index 0279e17a123f8cbb3c7e3a9ce5c5af8e693b6977..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 76 zcmeAS@N?(olHy`uVBq!ia0vp^%plCc1|-8Yw(bW~!k#XUAsp9}6B-)+^LX%RmN2q0 Ycy4A9FVZ~13zTN?boFyt=akR{01+Y(GXMYp diff --git a/actionbarsherlock/res/drawable-mdpi/abs__list_focused_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__list_focused_holo.9.png deleted file mode 100644 index 7c0599e3a6fcce1d9b22e47bfdb63afb1d3d9c02..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 158 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqEX7WqAsj$Z!;#Vf4nJ zaCd?*qxs3xYk`6eo-U3d5>t~6?){p=$oZ!|i46oEul1LdSjZF4rt@IU_AhE`IYK8I wIB$ByaB<8!;4zVtCm{dd@wVRWcBu>u-xEd5&snyt0Gh?%>FVdQ&MBb@09FhvcK`qY diff --git a/actionbarsherlock/res/drawable-mdpi/abs__list_longpressed_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__list_longpressed_holo.9.png deleted file mode 100644 index 3bf8e03623c94b68d31963ffe7e59c72c3dcc059..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 151 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqEX7WqAsj$Z!;#Vf4nJ zaCd?*qxs3xYk`86o-U3d5>t~CW>mH@a{g&g;s7!l1y4Byva-KaJLVIiI)OpBYodjS ofJx&-C1HsL_x|*Yp0_#7zz}{&aC*>dO_0?Lp00i_>zopr00f~Zw*UYD diff --git a/actionbarsherlock/res/drawable-mdpi/abs__list_pressed_holo_dark.9.png b/actionbarsherlock/res/drawable-mdpi/abs__list_pressed_holo_dark.9.png deleted file mode 100644 index 6e77525d2dbbc1673145d60d775602c85264330d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 158 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqEX7WqAsj$Z!;#Vf4nJ zaCd?*qxs3xYk`6eo-U3d5>t~6?){p=$oZ!|i46oEul1LdSlBa@C*nY4{!0_J9HA2p woHspUxHx7V@R-QS6OjM!cw6swyHo~-e~lvMp^1B@1I=RaboFyt=akR{0Ay(_r~m)} diff --git a/actionbarsherlock/res/drawable-mdpi/abs__list_pressed_holo_light.9.png b/actionbarsherlock/res/drawable-mdpi/abs__list_pressed_holo_light.9.png deleted file mode 100644 index 6e77525d2dbbc1673145d60d775602c85264330d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 158 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqEX7WqAsj$Z!;#Vf4nJ zaCd?*qxs3xYk`6eo-U3d5>t~6?){p=$oZ!|i46oEul1LdSlBa@C*nY4{!0_J9HA2p woHspUxHx7V@R-QS6OjM!cw6swyHo~-e~lvMp^1B@1I=RaboFyt=akR{0Ay(_r~m)} diff --git a/actionbarsherlock/res/drawable-mdpi/abs__list_selector_disabled_holo_dark.9.png b/actionbarsherlock/res/drawable-mdpi/abs__list_selector_disabled_holo_dark.9.png deleted file mode 100644 index 92da2f0dd3711a2ceb843768cafd6b91a2807b43..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 172 zcmeAS@N?(olHy`uVBq!ia0vp^{6MVD!3HFkzrK_Oq*#ibJVQ8upoSx*1IXtr@Q5sC zVBqcqVMg#;uvX%d>fBtxy+SfFGJhTv9Z9>9n%%Tr7{oI+Q@DMao9hQt@O?p#8;eZd15IY| MboFyt=akR{068-?^#A|> diff --git a/actionbarsherlock/res/drawable-mdpi/abs__list_selector_disabled_holo_light.9.png b/actionbarsherlock/res/drawable-mdpi/abs__list_selector_disabled_holo_light.9.png deleted file mode 100644 index 42cb6463e4c28c6aeffa315c4fc869867dbb6b7c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 171 zcmeAS@N?(olHy`uVBq!ia0vp^{6MVD!3HFkzrK_Oq*#ibJVQ8upoSx*1IXtr@Q5sC zVBqcqVMg@oJyIHz9Y|%SiynA|kd)58s-{92FmHki*;@KxND!%;H%=F4ZU(n;yg$GVRgBd(s L{an^LB{Ts54)-;@ diff --git a/actionbarsherlock/res/drawable-mdpi/abs__menu_dropdown_panel_holo_dark.9.png b/actionbarsherlock/res/drawable-mdpi/abs__menu_dropdown_panel_holo_dark.9.png deleted file mode 100644 index 460ec46eb0786706610e21ac9097de489cedfc33..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 651 zcmV;60(AX}P)!1&^00004b3#c}2nYxW zdZ_-Wf*5)VugS&t+23J}V*z%DOHb#W|`Z#l>;cJ*L_P;jGoKD8nX4Z`xH*Q>s zTvTl`b;%gqS1znaOc|u@tz3t7=|UK<9Hr>BJ|D1%4AOYzE>c>YASL1(e+Y^`_iG?7 z1UL~EK(|`0e*W#*UXt~C{TfUweyI5sSBLVgO?u)p&e9+4(C=i^T1GuQJ|j^LdEE0 zfZFjzm@Nd117_`XxKDqSoJXh_wG-}tW_yHE!!B|TSvyio<6k9eTgoG9O0aTdZJ81x zmbul8Z%fpkT#Wc{ND1L@No&VX#iPVF7hx`c0JdkE;3e2%ZBQYi%Oe#dj=&z+_I>|? zOJi$dCv)FoZJG3n&>Qp|;vSo*JOkf=A5uR{`;uV-QwsX>Ho!a31HXV*se5TxFFA=4 zo=3!%#5;D2+DO|6R;c8b^-B2j{s4XhZw!t1m&l3O!HmBwHn=!)kb6yF?kI1MVX*Vu z<6hz)DH{^YBPWDzO$|0isCW3@P>L98oO;C$E5=4jGEPjLS?XZ=13IvJLaC?O;nLn? z=e?6_T^b`&$N3sK+o1N3^-DyB&=+_N>geY)_rHdJwBJ%s{^4(_WBZ5MLQM53U4RfX laXn(LVYMe-Njr@(d;;;gyUim^Wn%yU002ovPDHLkV1m`SB-{W1 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__menu_dropdown_panel_holo_light.9.png b/actionbarsherlock/res/drawable-mdpi/abs__menu_dropdown_panel_holo_light.9.png deleted file mode 100644 index e84adf2d41604323cdad8b15e7034b6137e02425..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 720 zcmV;>0x$iEP)!1&^00004b3#c}2nYxW zd09!jyup9SJyH%;E_KZI5Ed^B*iNJmRSj zBG=jNc2B+cMg+dzb=~X>SwfDye{PH^oqQ4$1^~*55|NVv2=ckIR8XoEqC|oOgc2g; zEPA&fNb-^8#Mr1#v(VQn5UdVR@QAWs>EP1 zTHM9Zaim5tPqqk+y4R~ii**RWgPIHWkr2Q-rv~$oD_;OFg!*vQOJ?oR%RhjSvm}}N zU}~@)A@q_TOphE%y@J$^Y;2GXG*T-_?U?-%UNYKi5n>WcgjmBq)+~pV5UB*Fc4!_E zr<_OV^tE=(@|l_%K9#lBPBbeU!!Q72CYl{ozqWE(s>}kg*Xy-fB`%jskbX;(+jyxw zA`k(lb8|^3?6_RfL_?Is~gyeh`O%xX?U(f4nJ zaCd?*qxs3xYk`99o-U3d5>wYsbmTgqz{8?`Dg4L(`abqnuZs;wTVv8ZBg|GX^f4xE z5ck=nld$UVv7H|oR+P30etdkz&;0SSW2^3}yn7y4rozh{Dy3k((DE(NNCr<=KbLh* G2~7afj5MhL diff --git a/actionbarsherlock/res/drawable-mdpi/abs__progress_bg_holo_light.9.png b/actionbarsherlock/res/drawable-mdpi/abs__progress_bg_holo_light.9.png deleted file mode 100644 index 4bb22f0e10e621ef31f16100b3f682a09565c65d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 159 zcmeAS@N?(olHy`uVBq!ia0vp^Y(Ol;0U|59*B=E^EX7WqAsj$Z!;#Vf4nJ zaCd?*qxs3xYk`7}o-U3d5>u0Z{Qqyy%*=eaUL!352pYN+StcB)SJP>#V9b+U;=REk xGyYWXA=VWyWA+H$a1!q?zNqxd-sOcoGlO8KcyMa*40E7i44$rjF6*2UngAF=Ek}@P)jR6%Q#K@^;MZ+DwSq^+h% zP_!xtf_Ukr^ybl{hx{k~3HlSfd-tNJf;W#6l*URbZIYUN$+x@DLlQ_#DhP=KbJ@4d z?3>3vm>B@rlxxLQd;P-m9-THgzpAxGG!1yW5D)4ffO-cU4S%t?r)YdGWOO4jhM%lT z$gSE=x_Gve0j_HeH8J^wOM08!a}xvEw9Ce~Da{Pz+J>k}@P)jR6%Q#K@^;MZ+DwSq^+h% zP_!xtf_Ukr^ybl{hx{k~3HlSfd-tNJf;W#6l*URbZIYUN$+x@DLlQ_#DhP=KbJ@4d z?3>3vm>B@rlxxLQd;P-m9-THgzpAxGG!1yW5D)4ffO-cU4S%t?r)YdGWOO4jhM%lT z$gSE=x_Gve0j_HeH8J^wOM08!a}xvEw9Ce~Da{Pz+J>4nJ zaCd?*qxs3xYk`73o-U3d5>u0Z{Qqyy%*=eaUL!352pYN+StcB)SJP>#V9b+U;=RED z2qf|=A9d?gTyt;ZSzN%FWhK6zW!r_Lk7KrU{Nfk4nJ zaCd?*qxs3xYk`73o-U3d5>u0Z{Qqyy%*=eaUL!352pYN+StcB)SJP>#V9b+U;=RED z2qf|=A9d?gTyt;ZSzN%FWhK6zW!r_Lk7KrU{Nfk&05-QPl|NEJxmot~Y-O?6i zSoE4VV50(~VFweNuSbvJvDU(em!@_Gy7>C|bVSGQC`nC9V$w5l5%vk()99rs+U}Ie z#gw!%)oQMv{^i7d*IlE3+&<@%p0;w&$@ypMpUwGhdH?7B;(g3_F4o8CEW7NhbVSM} zqSCB_!=qSev5fPtyGqA?asRjFZK+%zRmuM+<~%bCV-%Sz^PrNaaE@g9foeX-u+5!sBTi~HIW*n>)Nj7ol{rZ9-4nMT zoXaYtmP_*AdKAZAlk-GvO?pRyl>Mh8`+Nc$HY$`qPPFQpUN|M($@0weFZ=q>-Z|;k zASrkFqq&&t!{{3mN^Z2R{c=#?a3WtQ7weUk>iG|Zq$QT}pSIkU{^CTFT;9KIrmSnq zpS&#=uRnCsOK0id8}?`PEg3d8`7hvXW$egc*J6#mVt#e9_pb9<_ciuE6F6vP_s!9j z(P7T51!|6-rEWn-Z!t5pRZaT>G0pp*?o69U6_j*jr;%AU466Xxt@KxFWQ#C`^3eSLB zzg~IIvuD^d>#3#GLD3I7lf(noYc&h)3hc9G_+WKhHsZ8LoPy9%C4Uce+&;>2@bsHn&Pv7xpmx^;r<{ zyLsxJv!X1=e=@5Da9q$kdPVo-a@|{nyH;q}t$!wG=kQ6b{@GG-@nhR69M(itUsa0= zOaD6e(QK|M^YvG#-Ci16Wb}90IdQSr=Hj%|Go@_TnpsY6``Z0AtH!%8u6<>P+?BM| zqEoJFmfFoDzId)kH^*J-T zifmnxrK6#lyVy%(-Id^*OWp5Z{O|Cesp8<@8Fi79bbtkmYKdz^NlIc#s#S7PDv)9@ zGB7mMHL%n*v!UK%rs{7HZyAaH@aKEfTQc z(CR%$S?96abl05G-F(|Si_LUV;?$6kux)>%v=)2DUfpwT%PQ8|6^&m$u}%%W*3rdf zl`oQNvN&>WhAa0khnps!G6EK_TCpZ6=uP_{^)H>%wyt5X^53?*IxN|0o#E77R`PdD zm%Wa|cNB9$z_AP5mH=4J^LP6!o!<(RyDvF+#7%B*F3D>^@) zG3au=^KjWsn^#jyew;NrnOPLU6Z$MNVeT*c)9TLijM8T&&Ec75wYjFybd#W68%QTW}f06Axoa$IU9~?Nqc5iru{em z%^e?{s+j1J=mX5HswJ)wB`Jv|saDBFsX&Us$iUE0*T7QO&@#l()XLb*%EUs~z}(8f zfYD-4D2j&M{FKbJO57R>QdwRCHAsSN2+mI{DNig)WpGT%PfAtr%uP&B4N6T+sVqF1 RY6Dcn;OXk;vd$@?2>^cl_{IPL diff --git a/actionbarsherlock/res/drawable-mdpi/abs__spinner_ab_default_holo_dark.9.png b/actionbarsherlock/res/drawable-mdpi/abs__spinner_ab_default_holo_dark.9.png deleted file mode 100644 index 29aff4d43f71a025f464587ead52aff2ecae6a58..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 254 zcmeAS@N?(olHy`uVBq!ia0vp^59s(?1)eUBAs(G?r*GssWFX)$e`(35Y8e@;SI4XCdOETn3puLX+U@Np z`{}{9$F@!!Tb4}GnD8m&^|D{1rP|_tuSV&+Z=MCoD&l+{? zpGeMToA<;$LF?@fW~rUl3#RU765DB+Fm*PQ+)k?pQ&%&Ye!A+gR)$OeeXHaR#_cxq xcQACD7BHRDw&oXmu9s(?g`O^sAs(G?r*GssWFX)$e`(35d_EZ~i&w|H<&_`ZD(+MedV5zj zu-#_I+lqbxCf!wDY`(!qq|2YPZ`s2sD|KqW({JG~4*WL+Cpx;A`7$XPF&b}JE9dda zdDh0P2cC5-%kKDDBus2)4y)97FmX3?+)izQiL;plcWMSG#q&-%rTF<%+zn>y2h*Mj yizj?!^E*(P`ureMOz-ZiFXWg1cX%y7!FpSm=AYI1UI{?QGI+ZBxvX9s(?*`6+rAs(G?r#o^TG7xZ`zf?Wo$i4qI|8=SuS_>z)W_YPj?%Q>u zIp@ANM{x}Zqe@#*i-Jc_;!9;KcT)!P=e8Z65pgErb%iKSkCNb@A?yTt$n@r z2c`IHF%KKu<@hR|E_CSLV|hUMOZy3b87rAYm)KaVUb9s(?*`6+rAs(G?r#o^TG7xZ`zf?Wo$i2t+|9e$2v=&Zo&G1s6+_&pQ zbIyHljz-QjH&*S{-J;(gu&3N>@$LMyenNedpai4+B)&;SOq0|eu$bkReVyxuhm-Z9>GFCF_99MaBsxVXw=u8GrS3j3^P6KmrqN>Fc^oQq;b>Mt0(a$ z!tgX@A7RK4{kGy^A3#w21maN-UfpV|U0)B)Mu)Zk(%$xiP)OBD#retJ&sicWsshEL!WHUI0Z}S=i2Rqw=-{<_oUlU4$I1(Vt^KG}@Sd2k4!kUV zp9d;G14UN$xn@Z2Tv!X1WCiPlZi?T5Wo`s>dMMw4?2=HB&MqLoAdzh3Gg0e200000 LNkvXXu0mjf#CNP@ diff --git a/actionbarsherlock/res/drawable-mdpi/abs__spinner_ab_focused_holo_light.9.png b/actionbarsherlock/res/drawable-mdpi/abs__spinner_ab_focused_holo_light.9.png deleted file mode 100644 index 6536ee63329bb47bec2bf2384aa494923cc2773a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 424 zcmV;Z0ayNsP)Km%mHHKmbPH_0G1~QE(|Z z3L*$mIy*=P@!u2&!BHHFf;fuc0uio1*2@YRBct9{0AyU2}iGVkcWw7UUPW(q{Hz&m;6;CQrhm;h30w)z2(`W_Vv zws(S3@Pah`KM=_o2%_3&n+}O86bq(Ag>`_N^4m7drC>+{^&N;72|01L0Qm!AONf3s S@;8qF0000Km%VDkFce0=d)+vOWKIG} zhpvGvb*AhYN}o4m@H1o!d4o*tRBGZMkUCTWmkL{wB~SUlAntIEgw4Gc(!&*+NcHqe zdbonr;tjwaz@#r!B?pk5-j_#K1)p#z)*b-3QShBfQxGf+4==MNa*z{HXhG0C1P_4~ zh;-k(7eP#tUz1`!Wij$Dh)MD;xve&Fv5GXEp_kweUysY@i1cm8S?~wm($ky-rf?^L z4cuB_3%3%uz>Nj2a3et6#z@uGqTe`wK1>2-pyo{<@B~f=x)vOqS_S8F z{BbGcPm`Srko*>0TM51dS0?bbgq{a9*ucpHu=A!M^DM~~^Y@aViMI>L4{MrZFUa%^ Q4*&oF07*qoM6N<$f+pdR_W%F@ diff --git a/actionbarsherlock/res/drawable-mdpi/abs__spinner_ab_pressed_holo_light.9.png b/actionbarsherlock/res/drawable-mdpi/abs__spinner_ab_pressed_holo_light.9.png deleted file mode 100644 index 6de0ba8841d25f20f12e14002ecc4c9ec6a7b2f8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 370 zcmV-&0ge8NP)Kmp@CxKpa3{epU;uAYD{w zoy1-2XXsG+d5c4J(@pInLg`pK=_I6J(k2d`5V?BE{Yj@j2pl)OcgK;0qd#7akgCKEJ@PeExDlrpx^Tf8?8gJ#K-Da<_nm z+&*9_w+lGPs|OtA)dC)JfQDKAb-?t#>nbk~ygr<>n4NOeOiNA8R)UE3F)|0PZr-`P z{wS3Lh~%_Rw1t=h$DO2-+|>0Ilo0LghZEP}j*Edw;7F{TKbM3p1iOHI0}cLp61dt? QIsgCw07*qoM6N<$f;wQ9<^TWy diff --git a/actionbarsherlock/res/drawable-mdpi/abs__tab_selected_focused_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__tab_selected_focused_holo.9.png deleted file mode 100644 index c9972e74bb4fc7416960e238afd47b1ac363e316..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 148 zcmeAS@N?(olHy`uVBq!ia0vp^EI`b~!3HEJ|NhSh5-4`^4B-HR8jh3>AfL0qBeIx* zfx8og8O=|gUJDd7^K@|x;h4Gh+(zC520Y9MizoD2>~^~(JZa^V pUoEkkaeSh9w)TUlKa6vZ+qJ0**((%Vy8umK@O1TaS?83{1OR&wE2RJc diff --git a/actionbarsherlock/res/drawable-mdpi/abs__tab_selected_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__tab_selected_holo.9.png deleted file mode 100644 index 587337caf74f9ba3d32ba1c7cc8fb8b0b5ba245b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 151 zcmeAS@N?(olHy`uVBq!ia0vp^EI`b~!3HEJ|NhSh5-4`^4B-HR8jh3>AfL0qBeIx* zfx8og8O=|gUJDeo^mK6y;h4Gh+(zC53JlB#xw8$}k`45e4cLk;e3y7!_%!uv(Z^d6 t0#9x~Qa^f(Id{#0H&;LIP<)f9-+fKc+F|3Yl|VxnJYD@<);T3K0RZ_tFJ}M% diff --git a/actionbarsherlock/res/drawable-mdpi/abs__tab_selected_pressed_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__tab_selected_pressed_holo.9.png deleted file mode 100644 index 155c4fc753ed43185b31df3bea2af1ea5b3e7482..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 150 zcmeAS@N?(olHy`uVBq!ia0vp^EI`b~!3HEJ|NhSh5-4`^4B-HR8jh3>AfL0qBeIx* zfx8og8O=|gUJDeo@N{tu;h33haPQZY#>U2n_RP$O>mRT6my}r88lS< uMnfl1c4A|rBX^f%!~&s(1*$LFm>5oL2|PB@cz*+E5QC?ypUXO@geCw>u`ROz diff --git a/actionbarsherlock/res/drawable-v11/abs__progress_medium_holo.xml b/actionbarsherlock/res/drawable-v11/abs__progress_medium_holo.xml deleted file mode 100644 index 6bcbdb83f..000000000 --- a/actionbarsherlock/res/drawable-v11/abs__progress_medium_holo.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ab_bottom_solid_dark_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__ab_bottom_solid_dark_holo.9.png deleted file mode 100644 index 575334699663b221b5a2b3251572a7c7a23ddb4a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 165 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nET98VX=kc@k8Z|>$jV8FrZ@U7ta z-*T0WQ@><>I%v71J%hiqt0P@2{q!E)%~9Ermd_VC*s;IdoBnhS>rHk6>|lcSgpVF9 tjEp}SQ%vGx1w)$%c)I$ztaD0e0sua~Gttc^?peW`&R>iA3bc>G)78&qol`;+04`QPF8}}l diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ab_bottom_solid_light_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__ab_bottom_solid_light_holo.9.png deleted file mode 100644 index 8155fe840532e1d0fc25450729892ea73c4e007a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 166 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nETTu&Frkc@k8Z|>$jV8FrZ@J;?q zbcL8uwC8*^`8m#29p5Ib=%`p$wC&7oqt#odO)b{rdQv>$UUk^Hs0pFVdQ&MBb@0G6aYR{#J2 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ab_bottom_transparent_light_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__ab_bottom_transparent_light_holo.9.png deleted file mode 100644 index fa4d76af93de31de153c6a7d41c05496bb14d2c0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 152 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nETcuyC{kc@k8Z*AmdP~c#3C@cDZ z^MXtGfey<_%m2nWx~HUtq@RtOD!V+x#J|ag^QD{sZZM%<(R`m!o+Hzd-iC%RO>bP0l+XkKAqp+G diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ab_share_pack_holo_dark.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__ab_share_pack_holo_dark.9.png deleted file mode 100644 index 55099d49db309d03035101e55e64396b62af3054..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2875 zcmV-B3&iw^P)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0001HNkl)K_>U2H>f)F385FtW@2uXtEe@nD6oEa_v00960 Z0|2By^PX-KG@Sqd002ovPDHLkV1g_UPeK3y diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ab_share_pack_holo_light.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__ab_share_pack_holo_light.9.png deleted file mode 100644 index 3c4701fc21a7b70310c0fb65f82c96406bf676c9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2869 zcmV-53(E9~P)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0001BNklg>n)kmH7JfR>L=7gsVyOrjh?O!kd687gq;GddYfQoE z;^b_j0~Z<2SccpV5FkK+00HtJq?RWj0>Wbj0t5&UAQ6yPz9lR;$^ZZW|NjF3iYJRN Tx*zQx00000NkvXXu0mjfH|R+l diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ab_solid_dark_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__ab_solid_dark_holo.9.png deleted file mode 100644 index 6622cbad34409b2e09f69e305455482ee107baa6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 163 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nETEKe85kc@k8FK-lVFc4sN{QB_B z&fog}EEk$2&*T)$|Ch61%h`96?xa8O-xitu^~t0=vn)PNZ(|U lO#br3!H&B!tiEU`L+e4N?emv^?*rP(;OXk;vd$@?2>`X4Gjad` diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ab_solid_light_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__ab_solid_light_holo.9.png deleted file mode 100644 index c4272978338a232aa445ed5190abab61afcedb16..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 163 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nETEKe85kc@k8FK^^+Fc4rl_yt@$W?82D^ReIqPjo#d{bLmpkiN+x lnf&F6gB^EeSbfn>hW*nwPPt#_849$O!PC{xWt~$(697sdG9dr} diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ab_solid_shadow_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__ab_solid_shadow_holo.9.png deleted file mode 100644 index d0df29d8b3fef9f71cda9b7a0975c68dcfb05685..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 290 zcmV+-0p0$IP)(^RAa&-b-qmfdL= zKY^DZ_=R_1v^+>Y{!mW=MF!v|2#Q>Q>z_&4i6T94j-Y4q`P>I~g?cE`S~^QhBCU5$ z-8a`dJ38hrt)qwm8XJx0+%VAuW=z7Jg@`1pBAUrf#Ef=wZl|UqH7RO)u1OwK(@xK~ zuV&5*5lN0GQV~igR!o15*n1TfDTP6ilQ72>QBJOyK^2jQYHlAzlrUMuFCtAA$s$=K oi)4{qME3aCu~lSF#Q4a(0o}otDK%H_Q2+n{07*qoM6N<$f*T@rc>n+a diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ab_stacked_solid_dark_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__ab_stacked_solid_dark_holo.9.png deleted file mode 100644 index a0d9c1b957ea4a6ce62abd120668610d0cb2bd96..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 163 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nETEKe85kc@k8FK^^+Fc4rlxca~( z?t=fRa*SINS}wBuewp3mefy2x$=b4i8MC*B`RkorJG1!P69>HDUX#kpcm>9d6MZKb ky7}`x**qcrtNL{AY0h>p*ZiBQ0JN3C)78&qol`;+0O3wK)&Kwi diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ab_stacked_solid_light_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__ab_stacked_solid_light_holo.9.png deleted file mode 100644 index d36f99fecf223779432fb843b823c04d739f05cb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 163 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nETEKe85kc@k8FK-lVFc4sN{Ca;{ zvU;8e%Y`P%GdTtG|K%*$a`xS%JL%8+w?$@ueKP6JEX#C%J{El7iLS?_f2=|R(l=Qo klfOK1u;Z=_t1sHgP`H~Vw5GX>6KE@gr>mdKI;Vst03NU~l>h($ diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ab_stacked_transparent_dark_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__ab_stacked_transparent_dark_holo.9.png deleted file mode 100644 index 5ad475dc3f478734be31bc5763ff494e5f120914..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 158 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nETR8JSjkc@k8Z!P3yFyvu&IDfHo z*MFzV3!h#&I<8{wJG6*7%`^0A*`zgvpO3}4Jy+2bzzZhGPxw0F1DlG16;n~mnRAu= eo1*Vq{$#i=98+;OAz%&ALIzJ)KbLh*2~7aXVK40f diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ab_stacked_transparent_light_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__ab_stacked_transparent_light_holo.9.png deleted file mode 100644 index 6ade5eeb37d8388813cee512f8adaad0f6c15397..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 152 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nETcuyC{kc@k8FE8XhU?9M9Fk3-& z>Hkf73eN%?4n{M7dy#!$d2ZSCCv)eTUt5@6!ODmi{A7$QW>Hb7V|gN6#Q)yLqkTHN Y-hRf#&+ODnfL1Yhy85}Sb4q9e0PNo==Kufz diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ab_transparent_dark_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__ab_transparent_dark_holo.9.png deleted file mode 100644 index 719b9234df6fefc32c628a212141681df3414d85..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 171 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nETB2O2`kc@k8Z(Za)puoZEAojv! z?q20mzFS+?F-&~oGw)ovvN+_p>pJvXn6S<7W@Fox#)9&t;ucLK6T;ku_WZ diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ab_transparent_light_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__ab_transparent_light_holo.9.png deleted file mode 100644 index 6da264db26b5debc433e570e454f7ad596d3609c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 160 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nETbWaz@kc@k8Z*Aml2;gwNxP9_w z>q*543$-17oYd6QwPclDxvFIP6Y06uZ3-`2R5T~}Ha6e^YubHkRDB$o9=Xj@xc>Lb i$;LIUf5PjFDj6>?G+3v-_OK(+N(N6?KbLh*2~7a3Fg*4E diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_default_holo_dark.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_default_holo_dark.9.png deleted file mode 100644 index 7ef2db75e273c3a4fa34a867d43714d47b67dfd9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 109 zcmeAS@N?(olHy`uVBq!ia0vp^tUzqR!3HEvyN#v+DHBf@#}JFt$r%|L2@FmD6{OlE zCs-P=E^ay;FECBu-~a#X*$!!Fy;QT1l2!H>nDyu1;UEQuS2t(=%(&d{0o2dn>FVdQ I&MBb@0Ph$gIRF3v diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_default_holo_light.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_default_holo_light.9.png deleted file mode 100644 index 2283b4c01f31c24c241101989a028a28e662ff2d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 108 zcmeAS@N?(olHy`uVBq!ia0vp^tUzqR!3HEvyN#v+DPvC;#}JFt$r%|L2@FmD6{OlE zCs-P=E^ay;FECA@!GWvmzw+t@{SPuqdTbmsKKbP0l+XkKVJ9JJ diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_focused_holo_light.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_focused_holo_light.9.png deleted file mode 100644 index 3c909b51306d684dc9fc4deb674ab1e1feb7004e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 113 zcmeAS@N?(olHy`uVBq!ia0vp^tUzqR!3HEvyN#xSIG!$!Ar_~TGcqy~7@GboNVOeo z`FL&lz5>PtO@Rj=>T@VLG&w|ZbqQ*{RI`whRrVK{_2=K=E+vL!&S{*=@1z8QW-xfV L`njxgN@xNAaNr>U diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_pressed_holo_dark.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_pressed_holo_dark.9.png deleted file mode 100644 index 131d1030c9d5b447ef62fc8e336d9d3950ff7519..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 115 zcmeAS@N?(olHy`uVBq!ia0vp^tUzqR!3HEvyN#v+DJxGG#}JFt$r%|L2@FmD6{Ok@ zwtT#{-1s4r1MA|Z!|?(x4J`lv|6k8`NJHzTnuV0CvcJHrKmQJQDKT8Re5&^Sxg#LM O7(8A5T-G@yGywoD=q9NE diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_pressed_holo_light.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_pressed_holo_light.9.png deleted file mode 100644 index 3e7dcdfdbaf66d51a90633e6f601bfe71b0c5069..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 113 zcmeAS@N?(olHy`uVBq!ia0vp^tUzqR!3HEvyN#xSIG!$!Ar_~TGcqy~7@GboNVOeo z`FL%)@k1sD*2PVS;{{wASQ@v8h$x3#@+~m2a+{}M^7C)Is4GMKie-X3Pa7xz&0z3! L^>bP0l+XkKapWP} diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__cab_background_bottom_holo_dark.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__cab_background_bottom_holo_dark.9.png deleted file mode 100644 index 0bd09806f5c85ad3a33ec80c2a526e9dba34d1f3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 166 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nETTu&Frkc@k8uN>rTFyLXm;P>R{ z?#-o|?nQl9Ua&YVWQl+9{Kh9CkJo#*NAA>4+xPwD`<&mEu1}vZI664|W68WNxRjX* q7uY2C$wZnF2qKv(-xu6mlE@I5@4DcHNa}B(#SEUVelF{r5}E+w(lnv~ diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__cab_background_bottom_holo_light.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__cab_background_bottom_holo_light.9.png deleted file mode 100644 index 43ed26d4784aa508b93551bdb0359b959bd2c91b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 161 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nET3{Mxwkc@k8uUzCjV8Fq8;LR1* z*j37dP53cYgnN@8iE~W|ez(m3TTj;06C0 vR9@;$usQD^o~Q2-Eg&#Ke!|DE+S9qyz8u@<_Da1C=l}*!S3j3^P6YLYC-!V(AVEFG+v!>way|q9)89ZJ6T-G@yGywpFG&bP? diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__dialog_full_holo_dark.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__dialog_full_holo_dark.9.png deleted file mode 100644 index f4970ad1c3278235157ac72f71fc98f159fdc439..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2159 zcmV-#2$1)QP)7pj*K04R=GS>IExgb+dqA%qY@2qDDdSi?}MdX75WMJ|ri_~yampZf~b zyDwJPzURp0aERFLx!K0Z6`{S(+b^7Rq0fZm(kDLm@P!|`&m~8kF)y`OQ+*6SLgj(n*c6WFZ`T<6tC6A%w8 z+L+Kg_>sWYRhaz=AtQLA^@LuUvKr4zS(=h&ATdHMd1uOv+V9M9YYe+zz%fKlM3B!~ zyq*EP{ZyC9dltDoQc<8ZrM^eE_Hte#g^dKR2>{;+o?xX#_XJ<6fcSW3 z(2+n3e1qrFpfvl1x~?#Fy4|E$M6lRgKuT?d8dD>b&VB465lv_ms575+OWy%#u@k+N zI%?Q+K~hGrT_7#|a=gF%@ZrOc@87@w`1bAFU(2$bW3Gd+|4`xmgT=9~$+>Rd`_AEe z?tAPdzh~^4zVA1WkB@)c-QE59<;$19v5OvFA}vv41E1cCHa5&@4N;9-`R?7jpWeKA z^Yg>QL%m+FvDt*4cRX_bt0?zBkB(K>DX%%#=N+5R(_-8y- zVb>j!?$Wbc5y%%}IfCs9*+@_USOKV3tJQDczI|KW-rgqvI6{s^UDwxjUH<~$ckEhw z$wzfwA%@V6dv=Zxn=8;sa(#b)ziOIh-@k{Dz1VCvD9chBW?(0HZ$3-*gQG?|lNRhy zsce!AuP~V46@dEg?(QVrAwo2L-=l3?V9=qSyONQk&Kv_~&Lf1nMm8E$0BV|mEX9~d zNP}Lf5}1xu21h4T$+9&-HQuut%PRmY8i6duXoOerBY}OxLGlJ5BU$zc%^yh8OvsW{ z7(^}+!OmYLNsSuWi7|-^5)oDyq5>gHA{u-eOKk`#f#=$OmM4_(@m{kC%_W5DAmmhR z=d>`52C;YCwuB;r{%j}Ebe_P7K+b^`h8A8*tydWpwYtuV2y(IKDEl%UBLZ0(i3V1m zfUn~Tp;05RlF3Ax+6Y;a8pF(Tjoo`iqE#Ca+!sAl5kbmO&cKL3&H*nkK%{gluy`-t zg(lV{G7z#PI)C*NX293=me{C~cPz9KvLxQ9W=NZ^Ugspsp|?>vp+=TQM}wGdXLXG{ zVi`Ci0$G}v=(F^hV}w+)Oe2t`iJ2g)`#yKX$5zN3ft&-L4rl3d-=WWF22RL{IarUJ z10V#?jlh->hk8-+(B={{f_KC0$_Y6UbF}H| z)iXk95=}<}9Szz&zBnPrq{TEU=*R&0y55rN8c7*TmhI~1gq#|$ON79_OO5CMyD7gV z9}@irgLxzpwBV#1S)NvH5*4HjnIZdKqfiE}-PZx=`o6zC@DCwmFGlT6G>P~~(uABG zK}Q3f7d(yIx@nqEUDtg*;O`-1HeJ_!ZJOp2fHih{)cJyq3PN^{5b9^?iHmLcxw*Od zt7)3gecv~S{b_{c(f57RG|lImo14Ed?FxBAs6Zqt*x!B;W5{pK*JF7#9(y&G-;L+K zAIl#wtZ4Xp+<&dElXaOZRbPeOuW5VVgIpFOP7$z(T3Yv~vHW)|AI5VJTZ64^6BEBSg#y zGM}I)%~}j17KiFDEnOcuUt#E@>0HCEcF3*~0j6Ce`xZm1O5Ih`IeuTN+ty1RWW4eh`~TOU@&BM)3MkQgMM@bdYm8B8c#1 z#@ViWE78D40!D<(#Tx`hXJ-KSDrqoae31hLi8 z$z>DjeP}^jBk1AK*j$2rhW(rzJ{2JYJMmiAitr^tE-^SXloO=ZTOgN*_a2ZHvyBd7 z1l@JghOv{s(P7lwc?A9CfSo}^z#H{B))n$biD&`>gkS9e;$0Z5~J8tXRDNuF002ovPDHLkV1mNB_TK;i diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__dialog_full_holo_light.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__dialog_full_holo_light.9.png deleted file mode 100644 index 172fc3b5e3caf3357e706be2a1f0d91f357c8e5f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2302 zcmV2ok^m97efLZMJ76bgmHN3TVPgynL1iZF^o zv0AMLkI|bD5@Z+S7;_RWD$X2Q#-Gi>; z=tN2`078B~PH0>efZ`B@1i||(&~g>qMGRTwTrQXXbnj39hPAQB*)bIg_=HbA_WGzO zR;yL=j9HSDjSEl*;KYv!A@o|O_=;IUA}l9+ObGitX|Dzg#M7mV*iktr2nZlVbl%^^ zH53Ym36TIhGR!|u7{3PC~!L=Y2z z32ZT8B;zY)i(nCqF!62X25hwu6@!!-aVKznAwf{$S4ay%(<6lhDJ|l}=KVE%xD;tO zjxokGV%Vil6ww-?fi&aiwtz1TI;KLw!36;9iSC?$w}w5ZTIo^H5hBZ^Apum+pFjWp*|TRqUSD7TX^iIhX;RaeQQ zE(9uq^MWzvYwRam(2Co38gn;jAmP?U& z&MGvUhjxmcRMYbSg3kR zZt4g}LPgLEq&hYm(J$si0u;4;IwvxY6?fp6l#|X8fH;pmq-q5ISi1H|(Ge;Lg>w@fkyi)P5d7;2~0$MDQ@!DE$`cg61AQt41xJiqTo9Dlsio7bTA}sD9BZvH#!%wZ zmJ%ND@1^DnZ%X(Ld?$$A6k0J~NE59ixD&!XX{j@~=b>7mwKZvxCyp*B)cAo?C*Y0% z?1kZeY?X^e-9W)XxdpU^5OahW`IAUpYa}@W?W5#&t4q8l2swcYLBS!VH7P;dBP@_? zQAk2?GdMjs_n0oBI`TV#(4X2ifxe2hDg*@upKxQ&K(mtAk|`HJPz)_1HaAZ&&GHf7 zsz6IO?f{EsSe^=LZJ-DtRGZRNi3)(P24xANDG)6Gj(#dNGOP_9D0K*+?F8HR`Nj#&1(CYoj<+oYNw{1t4Y0L^ri-RBp`1VD6hPVuR0IkNiMUb`EeV02O|F6c zauGd$;Lv5&C{!~b&}Udb7lOKhLPE$D=wt2>b>Q`^nt&r(EH@_=La)06a5Fwnfw+Sp z&{C)%=8X_pC077s0o1}imRwSiS1dcYq8ac~BtElCsZ+`Ul=zAmLOFfPAwvBY@Kn$$ zk{zOiq+$R>LAX{rQ>;#)$VHAb@IJ99w*HlMq6mNtA~I*7`@~Y7+@e^8prDZQ`Pk}@ zSYXq1DD{)3Sw!SFBRAo~AvKngUU3Lg#cu0$<^+@bU0;P_H1st~XDv}F6a(QX9$Rbi YKbh+rFQXz7g8%>k07*qoM6N<$g2q=E^8f$< diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ic_ab_back_holo_dark.png b/actionbarsherlock/res/drawable-xhdpi/abs__ic_ab_back_holo_dark.png deleted file mode 100644 index 8ded62fb7b6a27a86f7b532c9a2b5a4ae999d34c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 741 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE0wix1Z>k4UOiAAEE)4(M`_JqL@;D1TB8!2v z2N=7Z%(epwmK8Xr18D^?ZvQoBE&~JOTTd6q5Rc^#N8xy%NgI}`eR{7o3SVw~oLF?DlhO#(rS&-V`^Q!s%)gPgzJD$(6 zlPX(2b^RHIj&o60rR$>g!|G>TRxtl*e|^4a{T&6ax|r;1#_KA};b_owfAXfrk8RFR$o&QDy{Vn>#x#sulW#~7Jq)- z)TH!~FS$Xsf0AE4joN$h`JQ|K8Rwjx@86b-rgDVb@NxHUL6S>yvXNP=t#&QB{TPb^Ah ka7@WhN>%X8O-xS>N=;0uEIgTN160J|>FVdQ&MBb@0GkggF#rGn diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ic_ab_back_holo_light.png b/actionbarsherlock/res/drawable-xhdpi/abs__ic_ab_back_holo_light.png deleted file mode 100644 index 517e9f72d0c8d28a22360ad5d73476c25fd4db33..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 661 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE0wix1Z>k4UOiAAEE)4(M`_JqL@;D1TB8!2v z2N=7Z%(epwmK8Xr18D^?ZvQoBE&~JOTu&Fr5Rcj%_$5Ae=jmr`i z3DvOQxBn=~BCIDR#iS^(^w0Zu6&JUPm!vIx7~`u}yzledo5s8M7#uS86ZssvI8sdD z&xg3?2M7HpA7}46mr}+fqP5gidGgVwQ1_}WN$aob&9(OVStj}6Xj_!ShugM~J~IZM zU$@KD($sJ1b4JGMs?Xp43SH*aH+p$-+40a@k*+<>G~DD-|-{tS&vG^x*%GGq=j0Y+3zJN#Vil?OA~@ zukBM`R53;FYi;h*X6Nv`Uq9z3iuI~5j`7&H`BAcUqjcZh^7x-d8^2$_pe40Fq;EPa z%hqE7x*0h;3a++#0KFc4?e_Zv*^k$mEo1DpzWsL9`(v*67M^+IpR-MVa>nHwC6*2c zw&pTkoOQ_aoMO7bofkh1@}JI}ZKA~9;BBq7`S!))DS4@K0yY}FSDK>kZ?)HK*JGG& z7n!~MQ}4z!!HZux9M^8s)pB{g?A$cwGrvCg`RlIwI(LVEXW4OK`|IMz?e(5Emfz@% z$^^!kYKdz^NlIc#s#S7PDv)9@GB7mMH89sTFbpv?wlXxZGBO2ntqcr|?>AgV(U6;; zl9^VCTZ2=RMLtl2B*=!~{Irtt#G+IN$CUh}R0Yr6#Prml)Wnp^!jq{sKt&9mu6{1- HoD!MOjfK$EgnR$;T z=N`Kp(hSrM@CU%evd=bf=-4w^bQmnuhmUH-jd<6WZ; zHl4_>Rk2U@t}L_t|AiwlQ891B3C|YS1B^O3M@oxo5*z)LB91b?+QOQX_r0yH)YX2= zvK_aW4}ZVF|MIp0)1X?{@CS{e_APBtKk;H~nV$PVB{N8HV+L1tOj6 z``KDz%d4l`HAyHPxAByb%b6xG^S8m<-YfXS7v>b+zlZNGcwheZcvv-P0dQ7=MviH9v^t)=yc559VF`j43j z_pMt2oAX|`goy_Fm~UMa9d%t_^^2qU)cXl;U0e%IRZSM> z>7Ksk_VioOmKv*1mN|c~ELg&~mMikt+LpAdYoES)QG3#uo404uV`0ytJ&!XS^rKz< zU6j9{ob*(;{k73gyQmwdmG2d+82l2_J(5-Z=Epp_^THpe+eb5HIvzUo?fW(va5{7P zd0GD0trC|9zjsRjleub%YeY#(Vo9o1a#1RfVlXl=G}JY)&^0g*F*LI>FtRc>2C}UT z3_|{Y+l-q7HAsSN2+mI{DNig)WpGT%PfAtr%uP&B Z4N6T+sVqF1Y6Dcn;OXk;vd$@?2>?&0tquSH diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ic_cab_done_holo_light.png b/actionbarsherlock/res/drawable-xhdpi/abs__ic_cab_done_holo_light.png deleted file mode 100644 index bb19810bc2062509e4e4968099a359ad73818728..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 915 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I0wfs{c7_5;rX+877l!}s{b%+Ad7K3vk;OpT z1B~5HX4`=T%L*LRfwTh{zxw0jNgl<&3j(^ zeD(x}!be9sh1LD$__>xwFX-mty1-MRJ?GVgBPRYo&#phmts!D?ltV3&FI%+a$=z1Z zV;YHl1iMSDgJ+|>#46F---v^ z=n46F|IdfFb=)S0I4Coo@!g}n4Nex)S*)#RZPN@k9D49tzo1o|L;8h-cSg(aGrNAg7qQ^lmAJNnY2BwD zmg$yB$_Kc(9`bFT@$ln4rdg7D8~IZ-f3I60`0mq%qw5167@Xn!BqR{_Lfuy~aYE2x zQ4_Q6{SU<2c z;lT8&TH+c}l9E`GYL#4+3Zxi}3=9o*4J>pG%tH*#tPG5-jE#Y8D+7a&|KB#FXvob^ z$xN$6(O_z2Y7RsY4Yp<(!9Wd?ARB`7(@M${i&7aJQ}UBi6+Ckj(^G>|6H_V+Po~-c P6)||a`njxgN@xNAiwS~- diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ic_menu_moreoverflow_normal_holo_dark.png b/actionbarsherlock/res/drawable-xhdpi/abs__ic_menu_moreoverflow_normal_holo_dark.png deleted file mode 100644 index a92fb1d4af622cfad770d7c494121719a7896e61..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 167 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=d7dtgAr-gYUQ-leFyLX@@b&p` z%gbN)&SLHDYV<0q^J4_6fq?|&@*V6j4#NRakTDF}Z~@#RP$drMna{J{ZM0wU(H|t@ M>FVdQ&MBb@0L8N*<^TWy diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ic_menu_moreoverflow_normal_holo_light.png b/actionbarsherlock/res/drawable-xhdpi/abs__ic_menu_moreoverflow_normal_holo_light.png deleted file mode 100644 index 930ca8d95e8bee5a1240fba645d9dab919abd734..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 184 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=^`0({Ar-gYUf;;epuoZ6aJO@& z%&D0-IKvGL&8p&qV;O7KuliPO1yl(K>(rHwor_8Hg9|Y9Gj8!^hz0Vk4~QZ}ABcvv nF)(akj$uTI?LshtEWgbR4Rf6*RPme*0Ev6L`njxgN@xNAEX^ml diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ic_menu_share_holo_dark.png b/actionbarsherlock/res/drawable-xhdpi/abs__ic_menu_share_holo_dark.png deleted file mode 100644 index 45a0f1da0d01b7c0ba53830285c67d629bd0774a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 699 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7T#lEU~2MoaSW-r^>)^McjrWjeSoS8SCOEBs|%|?VJ7D=T9Yz_dLJ8 zJ9zK=&-=vhubx}{vF6<8-!m`2Et8%6G=f2_fi-~)r;kY>>MAgRkm@i7CT&PKJ^T(I*&Av>d6O5U0r~;hkX|;LrY6t%e!5sze0;lgN zzhmA1v9d1mdTWRDgJXqP4j5dhQr@DSSRpJN-*(9Bjp4$N@%tt%vt{r<#9TCmVT&q5 zPY_dpf5x8W&TrHi1EzgwuzL61gP~v}`*h7_ev9YX^%66WzmeOz)Rwd1sPzfWyZX+; ziqW^(w(Z~haJj|{8OsISSA~|G@%CQ8Y_d#7=yl$KAFm&t%#H|W$kcQ2;yBguIO76W zkG?He)AQ@KipLqRU6Nb%FPk$;xS@jW=|$x{C80dl?QT)`*~FQi^@N=fie6YGbN2D| z=`W4NG-chmgqp9bsxquQQuyVroI59@gwb7QnV5NMi~&p85J-Uv+l!N+#T%5W;<7yr4}f9Ow$JGA?da_{7}kE@t}@ET5LG{B2CIDTQC8`Twj U_qmZcFi|piy85}Sb4q9e0Mf@O?f?J) diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ic_menu_share_holo_light.png b/actionbarsherlock/res/drawable-xhdpi/abs__ic_menu_share_holo_light.png deleted file mode 100644 index 528e554abe239137182dd9069d1fa4ba02a109a1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 935 zcmV;Y16cftP)=+L@6RIMT%_@p^A^X5UDRjLANf13Pq%);A`Pd+=!;23pXx; zAif`nPef)@LW&ftmV!!=U?`shr5Kn0)zPywg_Q~)Xf6@UsrA5Be7{a=6EByPs``206cpncnr4<@!q@mA~gUzaA3%HTX+%kDFHYT5Qf!vm`Me|1djAs_x*GR z&!z%kGhWI$<|3X<1;9qUl5@-=4yFR&S{y_@$C%@oE<1op+>aXzjC~!)$_ii$_F+%K z@y9V;#ya3q+!Mu4ce-D|$M^yJarJ;X=I|E&DieT9a7UE58@rw_;mfG%mg3n4+>X7G zDINV8W$>{wd4UPs8tHyn<_K%Vx4t-F{HB0#CbHyT8aIH=*w&T4zhI%?@Yvw4$UHw9 zfiH|AwZ;Wt3m(R<9MXfe~y?7+&yyx)=z7N}~%m5B!YmPaWaH#7@Q+5E; zIqP##(=Vn1;7AlEd2}e2K@tF-TcIq?su`V~Rw@AYX?JP!=ya5wR`qE`V>4fQR+^F$GWKC7sT4IxUFgD9>&BxJs0#D$E0dq8B&$(De03B_O{zBGgT!>|}k{a55 z!O~xj?u?9>EHL(EoJ!?lWDg$AX}pf&%~Sx?@v3~6qvvqAx*Saezy`dwo-+WR!8JMF zpTip|0k{c|kLwhu)oQ!f;y+34?@=W6(zkfKXdO_i)poDN4CtH&58$o=8{em4rdmY+ zbb?>20J>f0o#8w;#fEn(4AdV*y+C*HYaPJI-C#EObp@bT@IwJeLH&YX7XStYpFDt- zf=?R2Fu^AaVA$Z31du2AoO(cqH+@Lz(5e*i5O+3-*HCUO7(002ov JPDHLkV1h8vxv&5L diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__list_activated_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__list_activated_holo.9.png deleted file mode 100644 index eda10e6123e1e1383c4617228ec0c96680d60dc7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 158 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT0xamSQK*5Dp-y;YjHK@;M7UB8wRq zxI00Z(fs7;wLn1!PZ!4!jfu$#Gb-B{xqtMx1s*(O%+nLV7IxRdaaX6Iu&3070|zpW ye6d-ZyJWwc+pgOl@x443T>9p%`1p8cx&%YrImy|zOvgZGF?hQAxvX30u5yFboFyt=akR{ E00Z(eO#lD@ diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__list_longpressed_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__list_longpressed_holo.9.png deleted file mode 100644 index eda10e6123e1e1383c4617228ec0c96680d60dc7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 158 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT0xamSQK*5Dp-y;YjHK@;M7UB8wRq zxI00Z(fs7;wLn1!PZ!4!jfu$#Gb-B{xqtMx1s*(O%+nLV7IxRdaaX6Iu&3070|zpW ye6d-ZyJWwc+pgOl@x443T>9p%`1p8cx&%YrImy|zOvgZGF?hQAxvX diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__list_pressed_holo_light.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__list_pressed_holo_light.9.png deleted file mode 100644 index e4b33935a3aa4f1af3fa9e9e199b5c47d43f4b74..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 163 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT0xamSQK*5Dp-y;YjHK@;M7UB8wRq zxI00Z(fs7;wLn2vPZ!4!jfu$y_kK-b diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__list_selector_disabled_holo_dark.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__list_selector_disabled_holo_dark.9.png deleted file mode 100644 index 88726b69160589c8545759440e8d4e69dc984c67..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 190 zcmeAS@N?(olHy`uVBq!ia0vp^azGr$!3HF6SgS1tQk(@Ik;M!Q+?^oIXnykaTA*No zr;B4qM&sKXhJ1$tcw7#es=J@sd2yMiyW@jyg@u(=2qh%>1r1WJE1Ls*cJ{|veUO|(2?8OR-p?Vt(<)KXNk*dJ1<_`!jRpab6RMK;Rk47fDU#NEX#7yk4(~&Fr}L7DZp)K} zK)DDZgb+dqA%qY@2q7)3S*px^wsY!a9l?~jW2$HoDfOAoDc4?$q=mJH$Q@HesW|pH zEqI5t5pt#=^`ykNb$bDA+g_!6r>E#0Ebxb)V~E)@66{HSu%o+0#^7QK=<56_<*0g z4?VWXMFRkJB8s~XX6q}?LEeWW=Ef--P!X+fp` zQ#hbt=1@CWv@?Vrj0n$wG-wfB>s2&!$QdDJ0ulZgw-cuRiR{Y>^Hj3K6cvDZyr8vA z8lxp5*y$r9!v6G_XAF7`2PhmT)XW;J_(x39;8bKfgMu`e! zU+jWXwIOOF0-q>8C*JQsY~7_bBCuA z|Ap1-2&vJi9g(t&*dI@qVtrbEm_q)8uxlUymW^N&DQrSTF2REQdw9B(B*Fk-L?96w zfdFVX0=tCgq*<4>5rKwy4p!?>V+1b~mqyqhPm^M8N}pNlWK7Aa(;L|rtB1{dT%;u; z=)dm(?jeLfE6zhUB!2hW01y9MdY)1v=ujhBx3b+Xm&>Pd9KV)clx)K|j$bdA%O^}( zPFj=H`w_B~E-2}`eIdjBd_I2}hT(GvVW{|jkQIawhG7^!pU>wnc#H_%SRreOrJP6k z#f!~#`~_1^!^gPqw^)9R`+vop3DslHn(o!PiI0dTt@|45Za=)m1`%IwEW{fV$LVaF zE9RVsAMaWMjZlg;f(R_4iy{7r`=s=`3SdP<&^M)TPHqgUw5?z25;3$902*NlyMU*S zpa+j$RH$BIEX`7~H`b|A%pl=Pj|o!QHv-L&MvImjnCmfv9y@5Gq|A_|G$L4MNvqdg zg%(@J38}FG4N!(%uhEggMhM*%9HY#I^l zO-Wr$p$z~$ref=30GgqO)XJdORd}!BEq>NeB8p9{v^kJo2|NxCQwf^HCpGf6X;Wp4 zg!hgmb$FtdtQ>ASMriqL^@|$FBEhNWjw@zMktp~+Gzo9nO1w>OhBUKE#}ER(1L)vD UI+1b(O8@`>07*qoM6N<$f~tseq5uE@ diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__menu_dropdown_panel_holo_light.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__menu_dropdown_panel_holo_light.9.png deleted file mode 100644 index 93066c8403ddaac9b19571152ef499620bcc0e02..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1551 zcmV+q2JrcbP)ZMyJc+a5x+ehm5NR9U3;9%`Hyz-(tJnPJWK72_ZxFO$7HJ!wl=MA(TM` z5z;&LLlB#EA&f^$3`&>pe6X)LdJ&`vfROKm-xd+jMbSqLMZ|438|}{L$EEgM9M^%w zHa{i`W4qmEM~t#0eOdu-0W1NOh@<%YUknyuBI#0I?3#!O*zRI&T@|+kOaOda%IhNv zM;99T5trXGZJ+ZJPec%b)$c$hhFbzf1btKUoQ@WxJHBtqt%Djjh@==IkkXLZmr_R= zETUs(|D2YHL30h7B}jQ1@s(0WN*y++$>%9Px0_7;Q^61da}ymGVa5oGC6I`(Se|An zXj@SBzbdSFK)Um(Fw#d8Mr2~>phE(63xW_TA*G~C`G7107k~`S4FDISDe;mJcscGO zI_^QW2+SjBmZ1U=9v>gytZ(L+77q^(-%!w_2qCD0PZix`L1IaO$h(b>d0@F@G3Eaa zi55W^GL}q#AgNiNjxa=>FZdR(r+ zxE>NCSff^sd0^fBMHn)m#E-cU=7+{dF-K!9f{S1|kOWYSoDj6e26s~&lfViRc^MJj z^>Y9iF9eSfmVwbcxJ7UPa3MH8F;)otZ%)TN7|p{_AvpQV#UO5SLMWM?>!O$+C0vaD z8(N!X1GsBg3ar^sKmkXku0dO*!9}nfXnYiL)Hg=pYKs73(^zvc9aG}t;{#B5>C;Y2 z2$?l`wfXukgc)%>9s%7AsDyH^rRNDOAHyeHMgYzG`@1jfJOi4h!RzZQK)65|cOA0& z28%R3H(uBEzOL&YU%_z=>~=fscDp^gsmfTk*1@j+TejVzGC zpG{n`bp4r^(iKT*Io^&x%OHc_WZd_EkhCG`k)*sFZ|A&V23>!#)HToxrIRJ-1q1Q~ z3qHxB_z~+bgihSWK3otqlC9O%9BoMC(eAot5j0oOB3|pwbjUE4*ONZd@_Kxq z*B8(0XhE_FfV`ZZwcn~gXn8&5;sQ&h03_lPHzc@QD2L`A0DB!p$qE$r97Hn6cmgfM z$;^GEI@&qEx+o;VEJ0ZAK#dKOL6F|xU|IwgE6|`&x_D{{k^myy5)6fQcS{yR>LIlD zb0eL(UISu`k;Dp-=L_3_9uII4xG36?ZZ5uUxd1Up2yq&z=dNHjN&oIh<{D_CLJUbUG4w?002ovPDHLkV1n`$ Bwt@fv diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__progress_bg_holo_dark.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__progress_bg_holo_dark.9.png deleted file mode 100644 index 345f5d3067c1b5a2b13f7234238468e8083e75e8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 174 zcmeAS@N?(olHy`uVBq!ia0vp^Ahr?*8<0#p>+uXou@pObhHwBu4M$1`kk47*5n0T@ zz}*SLjOHg#uLTMQc)B=-SoFS~;>gutz{8S$H2ll||1$b2>+ab^8r zChoU9-sVBr1cr+EHAcpdxgPN?*fw!WN@w!F_di=AUe22-xp-2_jNr43yl#?i1$i|o QK(iS+uXou@pObhHwBu4M$1`kk47*5n0T@ zz}*SLjOHg#uLTPFdAc};SoFS~;>gutz{8S$^!?BO&wHlFT~V_1=)TZ8!I{mdT_A)Z zztl5%UbEjFE&+!7%~#Kq{9)d)y{;#I@4EEH*bSem)2!T7Pp)1*OL*gdvC7^*b6)~Y OX7F_Nb6Mw<&;$Uil{z^9 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__progress_primary_holo_dark.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__progress_primary_holo_dark.9.png deleted file mode 100644 index c6c3f1ec248835c16ee8a8f9d253769ea4196468..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1309 zcmV+&1>*XNP)>2T29Hys?P&Vm zZA9*OOSNlf`Pu!y*8AUEO|D+e=9Pi3BR)agfw#}SukU>S5_JQH{fFX7qt#y26-7>F z^lg#%AL~){ay($Vl%dNK|ns=8F95J5u4IuT)_iO}FO5AO!x2YA-ev{((MiCMb95Z27y1N{d~<$0ZOiAzT-4$^Y~d8=D&GctVLiOE-HZCX=>916 zaB}eD93BUF6!cN|FY@&i`W7!}IIL?H*U-;b(9ZeC>T4fo-D~%;%Al$SM;o1{CK^c@ zLsL?U%;F5uW`mKV6p@jG8Wm~81rvcAg~E0r38^#=q@={j6{7*N{-mRal zZyi757l1u@+(UUVUpKQfbx4*^AEZ`NBGTk&djR!;W=;+8vR!2ZvkZUiF_Uw;@^@UHY_tFNo|bZ|HqK}~Z_0kB z>1@!nFOf~^{KOi&lvG5Os4i`3m5LaZ>S{(}C2cS_3u25qx+GSC0x^F*mC<6C%zjX} z`(@Gi@=yT|C0D;bu>bAn+W30Hh5ZfH4VVpRc=$wP71`a_ciV~TTQkNXRQHQat7toU zZx*3Z?Q~QYQO|ZUR_Tl#qXtzIiPWWo(#}&aV(i6KuEST$lYVRUVscgaEz?@VCh+@z zYdAdahv=OS&fP(?9$16?`l0%F3gfnP`B71?hw4@2e4pjZouU=>X|R*`N-YD-DJj}uU$#5 zV>X}RzD~bXHhFf?KK=4JTCWrMiS*`U`G2n9l*Y@cp7B$uQwuKJNIF$*XNP)>2T29Hys?P&Vm zZA9*OOSNlf`Pu!y*8AUEO|D+e=9Pi3BR)agfw#}SukU>S5_JQH{fFX7qt#y26-7>F z^lg#%AL~){ay($Vl%dNK|ns=8F95J5u4IuT)_iO}FO5AO!x2YA-ev{((MiCMb95Z27y1N{d~<$0ZOiAzT-4$^Y~d8=D&GctVLiOE-HZCX=>916 zaB}eD93BUF6!cN|FY@&i`W7!}IIL?H*U-;b(9ZeC>T4fo-D~%;%Al$SM;o1{CK^c@ zLsL?U%;F5uW`mKV6p@jG8Wm~81rvcAg~E0r38^#=q@={j6{7*N{-mRal zZyi757l1u@+(UUVUpKQfbx4*^AEZ`NBGTk&djR!;W=;+8vR!2ZvkZUiF_Uw;@^@UHY_tFNo|bZ|HqK}~Z_0kB z>1@!nFOf~^{KOi&lvG5Os4i`3m5LaZ>S{(}C2cS_3u25qx+GSC0x^F*mC<6C%zjX} z`(@Gi@=yT|C0D;bu>bAn+W30Hh5ZfH4VVpRc=$wP71`a_ciV~TTQkNXRQHQat7toU zZx*3Z?Q~QYQO|ZUR_Tl#qXtzIiPWWo(#}&aV(i6KuEST$lYVRUVscgaEz?@VCh+@z zYdAdahv=OS&fP(?9$16?`l0%F3gfnP`B71?hw4@2e4pjZouU=>X|R*`N-YD-DJj}uU$#5 zV>X}RzD~bXHhFf?KK=4JTCWrMiS*`U`G2n9l*Y@cp7B$uQwuKJNIF$+uXou@pObhHwBu4M$1`kk47*5n0T@ zz}*SLjOHg#uLTN5dAc};So9|U`2XLYnVI=;y-5$#f-D2o4GsT&Tr`prfMCHsr=)`p zy9zZlQWAk&gL|Kjh|gcN+0MxMkn!S`=@A+#%ic(Om>d23|9^ht#EF9It^fc3f1ZP3 Y!dJ=4-o~HPfwnMsy85}Sb4q9e06h#o+yDRo diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__progress_secondary_holo_light.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__progress_secondary_holo_light.9.png deleted file mode 100644 index 205b66e2cdef686c5ed6369b14e64b38d0182984..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 184 zcmeAS@N?(olHy`uVBq!ia0vp^Ahr?*8<0#p>+uXou@pObhHwBu4M$1`kk47*5n0T@ zz}*SLjOHg#uLTN5dAc};So9|U`2XLYnVI=;y-5$#f-D2o4GsT&Tr`prfMCHsr=)`p zy9zZlQWAk&gL|Kjh|gcN+0MxMkn!S`=@A+#%ic(Om>d23|9^ht#EF9It^fc3f1ZP3 Y!dJ=4-o~HPfwnMsy85}Sb4q9e06h#o+yDRo diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__spinner_48_inner_holo.png b/actionbarsherlock/res/drawable-xhdpi/abs__spinner_48_inner_holo.png deleted file mode 100644 index 19517c4b0aee1010c7041a76089fdfdbfa495e80..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2769 zcmZ{mS5y;-5{5|(kkFChhK>RPiYD~XySTIjLIgq!5ZD-yra+_^kSaBR(jkI$M5=;8 zMWiYIH zJ{L4+9lA?MGnNjQqJIVMy|@+Y*x)5n@6@M^X%1QI>%HzU+s^F$A{uGSUK0 z#wO)d1v)g|N-fzez@Pj&KN3PQb&b(W}2sO#Qj`+a3CPNKCA#BE^jjI)tjC2m8529 z02D1x&?I`7IDU{j-Q&y{>)zeY&B`Ma8WJNrGwaNm`0uWt(pYLM@p)H2v)A~R+!)8F zgGA?$X`A<0`mH|V>|FVYItF+KSVc7^pC3V3%7=U@p1B3em})M$K(uwD6N9slB!(`T zi~R)>BQQ>9(EuopaR0r1fiuNtt$$G?AxUQ@M7fdP&b*T=zGv(+u4G zTQ zd|2UbSWW9ez=$eHfGIUaW6HipjZXJlnM;#Ny2G5k&zxqBW-hk8l}RPTCj&~v-_q8B;Zw4m;LP(&&JidwjDQ~ac_8#Y3JSaIVaz} zyux;b;PbeS(XUa_g!cmp3G0eiR1nI#(*cg`;6LDxk&B&UZ8rz&hgBr(y7O6rTkmQT zrhy=2eL5GJ7#qr?o||O28Lv&K7&3aywR-4iQ40MD_ir1|mARNdS-bGJerJz@cDgI~ zKZMq&dh8$ns!+~`c$m66V_VkBL{T))8QD)3VcaS&MzgHdAm9-34$~obv=v4^hN>o|d<8G$j##Q2b(LY)D`ks?MI?Bj|mqM(bkFmmohvBKvt$Q9Eg| zyXZKq$-o~^vIFdVLC`fNajQUh_^L?LN#cyA7T#%e%ecLIINl zaa-|hGb!|t5%rT7|G~~BHKnC(Cj*+1dj}!dLuH7c)m~U}TPtOUpq{v@8E4cSruw}v zP?r25lr7VN4=8*&WtXaomaReN2bA5Qe#=DrTI*iN zxJ0Y_4o7X@C1>APsW`y9ZDRrN?V@GJsw1M)OnX*zAx4o)Ld;Fc$sfnk;RLMHYsyQ7 z+8$_YLBAkmVb>l z^NPw5VgYZOYH|n`ns3NjmDgu2Yu32L2z~FCt<&E4IQ=~=CsQ8d)yQ4oG8NU>uy$+X zNf>bxv!t-TqNU1wX?;O>hN{qoXNl>c=dIC%k}p#8@HvfsRsDS9?sZrlpzpmlEWoa+ zE#xErtO9lePlYW#FAcWM?nI`J4|LI*l2_W>A4QqFId1Eb0cnhc;Y?q-cF6vXA%=Kp zTl&38dA-veWW#-bZt?S-9?&OJE$3JLuL|IS<5T4uf+Q}HNyZFaD2%jPwTM~u zidPW@em-aeW8>{R8XtHB|M< zqzyLS?bn}ASUr2W8?I|FWHX12r754 zKIHBi{Y;&qOIy%S+SoM1eYJ(GwLi*;ERNAj5~-B{`I|d*RT___Ad$P9`7Rm4^0m)} zsgpnGlpgth2w${(wGB%maw|SFY#m=RY*puF$vHJ}IEp_X{mj2^!Zxf%p)#_(m|pMt zE5ufXxyGSypt&mO@{9safwES>rn{ori@%a87<09J2=^iZ2kF4S7tJwTNpFM8jZFXLogNu#ZQIU4NEa~}Pb#!` zYPNgFL_d-(lVB&Hlip61zZTY2@VbiTT;B64r3sR%dn#(|!&|U6v&W%3utzAjiF}0u z2Q;oP0SIE&nDAb$a%|^P3c4L7TmALn#+C4MHD37aFX(F`e=Cjz|Z8 zTiV2qTSXyXz!ly5y;Tj@uBYwjmv&ibj6hkc)XgO>-{#?vk6Cti{l`V8i4PBb&KB=8 zx)P_xpuB=V*IIs%@7Rw??9@{*0Ut3_uPM?V900gEglK(YhnQSDCX73%vt*wGFki_& zP-w5AXw+dW0oHu>X7>3c8>0Og9ztC5>B!W!T}&Kg;TDQ~m3{I2Nm%uq{<)?%O?UqL zPW_qk3y@&xteNb$e(Lz!lfQ26blnGc9k1gZf^lU0VgF zr2~Tjw7VStClC53*w9%B3P=?aA_NH%FrjGZC`F`)4nioBUC=~8AW8|nWPuBU z$_Ax~QpE+Ngl3~F#l&Etsjw_Xv$*Hnhx>3JzWJRg->crS6J%m+QIvUZxhV?Jo-M#nxzF{J^|38LuZ7p2A{3`Uq`=6kIe>?XjoG zr?GU9y(f-uD6ci)?1uQVR4SRTa}|zrSmC&X%{3Uu#s!v3xTlSKYl2xXRH=XldiG8v z(NTpiD;+Y~m>M*QdTK>xZWq^1Gi8i~5S7o}q&SbO8eBpO0}glmjSVvH7iqi26bB%| ze)qmu=vH{`#f$>>(djQ0^Nd<2H1NqlRYSvb%bfxVSE-6hyvT5}iWKJBsJYUTMmHlb zv{AxVJ_-jqG)Isz@a^K$cM^+{e$!&jnX5OO8E8XRNKBd8M%eMRN2h}U8b(CNyXF_g zuNUp7s?z=QD$}|Yd9ZAQ6_1dXY%HHkm_JujD3E@{yoa-`U00;ZS$y^Kch)kpoM#-L z_hl0hcTHdzz3P<)L4tEt9m4YU94$VspFs>kyx$G43>YTSqKXzilVwxd7qomBM?e)0 zk70Hc`|MK3$79>mw09q37_K`7rCCb2Je8#;R&l3wIoUvgp*l01y`!k-Fb_5 zLjfJM*_>#E9is$M8{y8UF zc`)}6IgHUUW3OdBIJ8Hp{C;Gz79e0KH~zPbyGtCwB=d&F=mttg3`f7;P(54xp{|RR zuCSG=W?@N(vW>lt2EpQ^z#T{`#xM4!mdgzNHx)<1u}$v?^g+=6*9ecRo#a#lbymZ)6-p6z^Oni3 zsLEXV)_}Iwfa=*b4{k&Dd=wxu4wfdbo>!(imlp)*j4pv5ge6;)9owM4=9St^swSv{ zskok>E#MxCe6UUVusSMJNGR_6U4pG5H1hlHX%(t~>nKmo-|d0-{MbUO&bU~mKcE&# zK_zv4|CD1!H8jAfY`vSSl6kj5Wt9loIBf}POwl~4S?>?$T&{Mawq7O5qkqy#o-A4N zE|eq~B+4&zVcuWC$vrg@L14-|z}_N{7ai6X+LIyj5pcb|jwUl|0>Ek~Th%i#NI{1_ zBm3pUiwMhzLuXI=foW(FgEeV4z(3A`*yzwk~f+h&vY#xmxsf?5OY1hsd ztM%beiwI=D(k-wWDn9)VJJk!~4z@|bN-=_~*}T5DfK5!C3E@eSEsWaR*+?aH|7J32 zC+By&%_SPM+AS<3m|xNxz3pqO+_l<53yw$fu1oeLjY&kkfdiF=Q*Wdc`etyM*rdK( zp22kBzFv%4ur^fuXEGM-pX|Fkd%Nq2l6dRQ2XKwJF@_oc*%do|>Y6Qv~!9EN3 zF&dggK*AU2RyOj#FqbZdzB>B~aA?KNhqMjCP zxg%^}e6-VnyS`t)yIHRQ48~-EkCwOT+tHm-FNve|j%NMGANQwdwt$uv_8B$5dQ4qt zta;CYDP&5a>BeK^j6`R(AiCG7VaMyHMlZyJ5(>(;W*&VnHGV2AuFnNIz}wiAT7{P6 zzLG`Ao;5|df63pAJnK+9#KTd^>$h)+arJbu4vNUF`f^QCm+L^AP{SFHl{TDz|}ZV(SF{inp3522LyJ zSw}w{j~U+S-eU%!n4i!>i<1qPc*uvvdn0Equ&#u7KRLHmgc+YBp73B#_8nO(jI!6a zd|^=Eg{Z*a-EZraT;7p!4p4Bd9(wNu7coSR1qusz_AQ_YwQYlP_s|#mVMCws=x<_3 zw)$>kM#p7l7$^lrSc}QL@p{n?})PR^#Ne#?) zCgB#K1aGkR_pfe{pyO!Rvn|^H>G<#YXY-5pW!C!5cE@?0?1Se-EtcRG8{ivDI_Xa) z9RNV-BayoL#=1yj7vzbP28Jim7+rm%lluA~Oy{}(F+^Mn2nnS8e?t@r{NcbL_hWF!{4*;x%LlxuUCHn diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_default_holo_dark.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_default_holo_dark.9.png deleted file mode 100644 index d8929fcd1864e92c78f24d34bb07ac0304bf5ebe..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 395 zcmV;60d)R}P)%)khMb;v@5Yo)-?A$vWI3J{&4Tqm)VM&;#i3-!rXQ;}}A|kSK_xLoQ9!D=| zrQuRX_jo!D&!*woG(4MzXVdU(8lG)+!_Dl;%pOYTRyEwrUVwMtwRCnh!_9059DxJy zTsprAUsT~zdJlX8e>K+(FMd_}2<&RF8#?@^bn(8vHtbfpl-_eLJ!>=!D!!z&OE12( zv`a1CqqIva-mA1rDc-ZR3oqWgvUXO(tc zif5K~i;HKMc8iLSDD9eyk1Fk&iksP%L8V=5@ekmQ^NVfO%k2z5z^Qbob@&(X-FR)u p3HS~A?&0(Ut%!)oJooy?_kZokYAURbJh}h?002ovPDHLkV1n7-uz&yn diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_default_holo_light.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_default_holo_light.9.png deleted file mode 100644 index 9174c4e4bc984a89e1ed643bc66b1569466ef52b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 394 zcmV;50d@X~P)pS_@$ zhD#gW|+S$zvH?tjZ06u}I z+WCj@MGelS_rM46*K*DD;uob4z^?VWsl%^ISMTdf({7b>={={?i$=qw;%iE~^x|tv zyVT+%O1re;qe{D!;v-AD@ZzIOyU^khrCnI@sM0Q^cw}ieym)kJH?(+0X*aBRR%th+ zcxGw0x_EYJx2pJz(yqJstkSNlxS72&skG}Y{tg(Y7u%+n+Xa4rW9?Ay@Gs!I^V*st o@Ei2q)9D9V5fPDPZuO7v|4Ms3SH1lZVgLXD07*qoM6N<$f(F>P&Hw-a diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_disabled_holo_dark.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_disabled_holo_dark.9.png deleted file mode 100644 index 3015d307088f12d52a9e99ff4575fd2153127e5b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 381 zcmV-@0fPRCP)hG*08Y#N?T!?S64w!;lKvy+*1?>p3RGdlx#190x$dzj&7b^-9QUftoB@I?dG z(l;!l|3;oEFaA*ajtwD8hd-6>9*;+5M`bO2!%}+FXrQS0p3;u)|QJUO}XO$+G;+dssck%4fw5xbU zX__uxRhp)XSC*#P;_m>iSbo@k`^^CW{9xcU{p|2h0AG{O_A~&$L7!btFK9(XM7DX= bKfeD1Etg?&Fp}qT00000NkvXXu0mjfW#pxI diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_disabled_holo_light.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_disabled_holo_light.9.png deleted file mode 100644 index 126637d1194f1d6609787774fb140818eaa4ba1f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 381 zcmV-@0fPRCP)hG*08Y#N?T!?S64w!;lKvy+*1?>p3RGdlx#190x$dzj&7b^-9QUftoB@I?dG z(l;!l|3;oEFaA*ajtwD8hd-6>9*;+5M`bO2!%}+FXrQS0p3;u)|QJUO}XO$+G;+dssck%4fw5xbU zX__uxRhp)XSC*#P;_m>iSbo@k`^^CW{9xcU{p|2h0AG{O_A~&$L7!btFK9(XM7DX= bKfeD1iaRu(IeFS@00000NkvXXu0mjfR7Ip< diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_focused_holo_dark.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_focused_holo_dark.9.png deleted file mode 100644 index d45c7a864d9b36fc5d06ef7650bd22c228e3533e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 680 zcmV;Z0$2TsP)JMg@Fn128fNR{httc z2n-9ae~A~-WYQOAyjJ3`v+tFS>H?h>cjZI44!YCDJ4vU-UH-NFC!H?dNqTY9^x~%J z#ZA+To2C~xO)qX5=ft;__PrJUYC9#q>!rbyQFMFHPb=3hoe|&n)9~p|baWUbMthlMtLL6k^E5&wx9H zfkWKo4DxGy27JSv%4KLW#~I|sPnXY+fCHfNj(}ks%-+uyBgtHbMG(R)| O00009q_DOpcx|jv*P1Z)f>u3p>g<+)ulGcHZsoOUd0`v$ideb3Xs*rv6J! zg}R0?Ejbavstni13%M+(h~#=Y?=G{+sY|c-R?LyC;M~J_EGz53I-4BR z+cU4@A4T%4{LQ{7{nooe_R?;9Ufq56+wp;!Z_W|LdHU^V zuiix!E)rt*mg%eid+||lw)K3kxzR2XQeoHKTo0e>Tz_Z7KF;I+KDl^G6{a%9AKj}v z@Aq1v55LRoZXbD)<16^lF!*Li$^7}+)mu{zFEMCaSs}k;w&aatvA+!FKCV6>P_Fen z(L?roLe!sxPkWei7+T9&rtD<0W7^%ZdcE}hdZyQpKhHVIBAEwFVGN$GelF{r5}E)^ Cjyh@p diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_pressed_holo_dark.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_pressed_holo_dark.9.png deleted file mode 100644 index 2cb34d7f60401a563454c03e266cc5181d9de996..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 609 zcmV-n0-pVeP)%5ec8;(Nh#y0Zthco9&fD+Scz(J_kqCSd>@N)Jrb#iJx@ z@geV)|0U|;Q8J4AW)%0$DDIn4+&81RZ$@$73{E^#CTa6Odr;zqGLyGk)zfLB)26Y5 z5#LU9dOW?JALQjc$4r{WH?GVFg))<)qMW_Ts@W~*Hgkd(m(u%LwVNxGwVfAK{BG$~ zHD4Zg33jP$CptYU%GrKa?RJ%hK*cvHEqE`!X=%Z0aT}!tZ^dnu7Q7Uk{&1!u)wl@^>7cUfAnUfgwQ!D?|Ir3GuneU%oh6!%$L*todw(!xf?LzEVJ7Y|ih z=v92GOd6`R(5v{nqI~u|T|T)5eQi`_Q>fI*QllCl)AthpQf>YCTIE0c%xyxW%x|6C zG>z*e{-?!>T@(EFL|;a6&!||%qb(l4cp2298zt1@mjOk(atXEgIq-{NzY%9xIi5qk vb6%{!-vcjz*7vDBaRYn@J|M2KzWDwRiVUw(_ikNA00000NkvXXu0mjfOP&sp diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_pressed_holo_light.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_pressed_holo_light.9.png deleted file mode 100644 index 82f752fdc28390f1dae188e66886f9fee783b4f7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 602 zcmV-g0;TXoV&|>P?2N3a|H=XkIpb%g2C{mUcD8z%K5!WW71`A3B@}P?c zNzmeTUM-&`=;A@rh-=e`Ytx8p(}-)+h-=e`Yg0e*Nfwct-zMuNo?gfN+FNCOm6(Rs zNBrh8;rK_F^Mfu~8k>e2?@WdCI_7lHVR+IZj_>A~;=j0*zBpPVOJB@8&9C^w(v!^i zcs#`4qjGbZa60I4akN%e8hjOBptPW0e8JL!ZgC5x1-;^yN((y0EtVGC7q?tma9i9# zX~A7_N2LWf#T}Lw>=$=jTCiJOp|oJHxKe4sPI1N3!s5l1OACt?_fT4>Uffe@p<40r zRpP6(P_6jSy?2bx-x9}n#O>6o(Q^BiC^BxWR1^RB?JvEr|0>Nj5k)!eSD9&8HSzXK z2sbij-vth4?P;pL%~0mos(Tg<|DAn;kcS obzts&Y9%t@53qx{hWg?AJqc6disFjI`v3p{07*qoM6N<$f`4nJ zaCd?*qxs3xYk`8Mo-U3d5>t~6?){q5*x2~c-pCBZ5@_=ERFyG diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__tab_selected_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__tab_selected_holo.9.png deleted file mode 100644 index e4229f26b2771d884934b80d0056b8dd66d10edd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 153 zcmeAS@N?(olHy`uVBq!ia0vp^Y(Ol;0U|59*B=E^EX7WqAsj$Z!;#Vf4nJ zaCd?*qxs3xYk`8+o-U3d5>t~6?){q5*x2~c-l(n1@K5>ymj5$1a2Oc?!34d7Ck`Aq skg(^gW|wXH-lZoEvTk@AJm}J3sQWAGentL}KF}BjPgg&ebxsLQ0KFYBT>t<8 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__tab_selected_pressed_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__tab_selected_pressed_holo.9.png deleted file mode 100644 index e862cb12154541c150fb2d9bb98872bcff506317..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 147 zcmeAS@N?(olHy`uVBq!ia0vp^Y(Ol;0U|59*B=E^EX7WqAsj$Z!;#Vf4nJ zaCd?*qxs3xYk`8Mo-U3d5>t~6?){q5*x2~c-pCBZ5 - - - - - - diff --git a/actionbarsherlock/res/drawable/abs__activated_background_holo_light.xml b/actionbarsherlock/res/drawable/abs__activated_background_holo_light.xml deleted file mode 100644 index 85c2c0212..000000000 --- a/actionbarsherlock/res/drawable/abs__activated_background_holo_light.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - diff --git a/actionbarsherlock/res/drawable/abs__btn_cab_done_holo_dark.xml b/actionbarsherlock/res/drawable/abs__btn_cab_done_holo_dark.xml deleted file mode 100644 index cab896283..000000000 --- a/actionbarsherlock/res/drawable/abs__btn_cab_done_holo_dark.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - diff --git a/actionbarsherlock/res/drawable/abs__btn_cab_done_holo_light.xml b/actionbarsherlock/res/drawable/abs__btn_cab_done_holo_light.xml deleted file mode 100644 index 42ba8a0df..000000000 --- a/actionbarsherlock/res/drawable/abs__btn_cab_done_holo_light.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - diff --git a/actionbarsherlock/res/drawable/abs__ic_menu_moreoverflow_holo_dark.xml b/actionbarsherlock/res/drawable/abs__ic_menu_moreoverflow_holo_dark.xml deleted file mode 100644 index 2588a492d..000000000 --- a/actionbarsherlock/res/drawable/abs__ic_menu_moreoverflow_holo_dark.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - diff --git a/actionbarsherlock/res/drawable/abs__ic_menu_moreoverflow_holo_light.xml b/actionbarsherlock/res/drawable/abs__ic_menu_moreoverflow_holo_light.xml deleted file mode 100644 index e2078c967..000000000 --- a/actionbarsherlock/res/drawable/abs__ic_menu_moreoverflow_holo_light.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - diff --git a/actionbarsherlock/res/drawable/abs__item_background_holo_dark.xml b/actionbarsherlock/res/drawable/abs__item_background_holo_dark.xml deleted file mode 100644 index d99b7a426..000000000 --- a/actionbarsherlock/res/drawable/abs__item_background_holo_dark.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - diff --git a/actionbarsherlock/res/drawable/abs__item_background_holo_light.xml b/actionbarsherlock/res/drawable/abs__item_background_holo_light.xml deleted file mode 100644 index da5fb2e86..000000000 --- a/actionbarsherlock/res/drawable/abs__item_background_holo_light.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - diff --git a/actionbarsherlock/res/drawable/abs__list_selector_background_transition_holo_dark.xml b/actionbarsherlock/res/drawable/abs__list_selector_background_transition_holo_dark.xml deleted file mode 100644 index b2ce4f0f7..000000000 --- a/actionbarsherlock/res/drawable/abs__list_selector_background_transition_holo_dark.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - diff --git a/actionbarsherlock/res/drawable/abs__list_selector_background_transition_holo_light.xml b/actionbarsherlock/res/drawable/abs__list_selector_background_transition_holo_light.xml deleted file mode 100644 index d7e31b1d1..000000000 --- a/actionbarsherlock/res/drawable/abs__list_selector_background_transition_holo_light.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - diff --git a/actionbarsherlock/res/drawable/abs__list_selector_holo_dark.xml b/actionbarsherlock/res/drawable/abs__list_selector_holo_dark.xml deleted file mode 100644 index 08b8b12f3..000000000 --- a/actionbarsherlock/res/drawable/abs__list_selector_holo_dark.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - diff --git a/actionbarsherlock/res/drawable/abs__list_selector_holo_light.xml b/actionbarsherlock/res/drawable/abs__list_selector_holo_light.xml deleted file mode 100644 index ada490bf9..000000000 --- a/actionbarsherlock/res/drawable/abs__list_selector_holo_light.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/actionbarsherlock/res/drawable/abs__progress_horizontal_holo_dark.xml b/actionbarsherlock/res/drawable/abs__progress_horizontal_holo_dark.xml deleted file mode 100644 index bd19140ab..000000000 --- a/actionbarsherlock/res/drawable/abs__progress_horizontal_holo_dark.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/actionbarsherlock/res/drawable/abs__progress_horizontal_holo_light.xml b/actionbarsherlock/res/drawable/abs__progress_horizontal_holo_light.xml deleted file mode 100644 index 321f07c8b..000000000 --- a/actionbarsherlock/res/drawable/abs__progress_horizontal_holo_light.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/actionbarsherlock/res/drawable/abs__progress_medium_holo.xml b/actionbarsherlock/res/drawable/abs__progress_medium_holo.xml deleted file mode 100644 index 6d4814f86..000000000 --- a/actionbarsherlock/res/drawable/abs__progress_medium_holo.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - diff --git a/actionbarsherlock/res/drawable/abs__spinner_ab_holo_dark.xml b/actionbarsherlock/res/drawable/abs__spinner_ab_holo_dark.xml deleted file mode 100644 index 4af5e22a9..000000000 --- a/actionbarsherlock/res/drawable/abs__spinner_ab_holo_dark.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - diff --git a/actionbarsherlock/res/drawable/abs__spinner_ab_holo_light.xml b/actionbarsherlock/res/drawable/abs__spinner_ab_holo_light.xml deleted file mode 100644 index b78508478..000000000 --- a/actionbarsherlock/res/drawable/abs__spinner_ab_holo_light.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - diff --git a/actionbarsherlock/res/drawable/abs__tab_indicator_ab_holo.xml b/actionbarsherlock/res/drawable/abs__tab_indicator_ab_holo.xml deleted file mode 100644 index d34e20811..000000000 --- a/actionbarsherlock/res/drawable/abs__tab_indicator_ab_holo.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/actionbarsherlock/res/layout-large/abs__action_mode_close_item.xml b/actionbarsherlock/res/layout-large/abs__action_mode_close_item.xml deleted file mode 100644 index 8811dad8d..000000000 --- a/actionbarsherlock/res/layout-large/abs__action_mode_close_item.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - diff --git a/actionbarsherlock/res/layout-v14/sherlock_spinner_dropdown_item.xml b/actionbarsherlock/res/layout-v14/sherlock_spinner_dropdown_item.xml deleted file mode 100644 index 6c183c059..000000000 --- a/actionbarsherlock/res/layout-v14/sherlock_spinner_dropdown_item.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - diff --git a/actionbarsherlock/res/layout-v14/sherlock_spinner_item.xml b/actionbarsherlock/res/layout-v14/sherlock_spinner_item.xml deleted file mode 100644 index 61dc02527..000000000 --- a/actionbarsherlock/res/layout-v14/sherlock_spinner_item.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - diff --git a/actionbarsherlock/res/layout-xlarge/abs__screen_action_bar.xml b/actionbarsherlock/res/layout-xlarge/abs__screen_action_bar.xml deleted file mode 100644 index 040df44ab..000000000 --- a/actionbarsherlock/res/layout-xlarge/abs__screen_action_bar.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - diff --git a/actionbarsherlock/res/layout-xlarge/abs__screen_action_bar_overlay.xml b/actionbarsherlock/res/layout-xlarge/abs__screen_action_bar_overlay.xml deleted file mode 100644 index c64ef141b..000000000 --- a/actionbarsherlock/res/layout-xlarge/abs__screen_action_bar_overlay.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - diff --git a/actionbarsherlock/res/layout/abs__action_bar_home.xml b/actionbarsherlock/res/layout/abs__action_bar_home.xml deleted file mode 100644 index 5c1e9ec4b..000000000 --- a/actionbarsherlock/res/layout/abs__action_bar_home.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - diff --git a/actionbarsherlock/res/layout/abs__action_bar_tab.xml b/actionbarsherlock/res/layout/abs__action_bar_tab.xml deleted file mode 100644 index f46f7a044..000000000 --- a/actionbarsherlock/res/layout/abs__action_bar_tab.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - \ No newline at end of file diff --git a/actionbarsherlock/res/layout/abs__action_bar_tab_bar_view.xml b/actionbarsherlock/res/layout/abs__action_bar_tab_bar_view.xml deleted file mode 100644 index 0d51220c9..000000000 --- a/actionbarsherlock/res/layout/abs__action_bar_tab_bar_view.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - \ No newline at end of file diff --git a/actionbarsherlock/res/layout/abs__action_bar_title_item.xml b/actionbarsherlock/res/layout/abs__action_bar_title_item.xml deleted file mode 100644 index dd69acada..000000000 --- a/actionbarsherlock/res/layout/abs__action_bar_title_item.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - diff --git a/actionbarsherlock/res/layout/abs__action_menu_item_layout.xml b/actionbarsherlock/res/layout/abs__action_menu_item_layout.xml deleted file mode 100644 index 13149fd63..000000000 --- a/actionbarsherlock/res/layout/abs__action_menu_item_layout.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - diff --git a/actionbarsherlock/res/layout/abs__action_menu_layout.xml b/actionbarsherlock/res/layout/abs__action_menu_layout.xml deleted file mode 100644 index a6f8e53f8..000000000 --- a/actionbarsherlock/res/layout/abs__action_menu_layout.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - diff --git a/actionbarsherlock/res/layout/abs__action_mode_bar.xml b/actionbarsherlock/res/layout/abs__action_mode_bar.xml deleted file mode 100644 index 7168dc77f..000000000 --- a/actionbarsherlock/res/layout/abs__action_mode_bar.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - diff --git a/actionbarsherlock/res/layout/abs__action_mode_close_item.xml b/actionbarsherlock/res/layout/abs__action_mode_close_item.xml deleted file mode 100644 index 875ec3e1b..000000000 --- a/actionbarsherlock/res/layout/abs__action_mode_close_item.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - diff --git a/actionbarsherlock/res/layout/abs__activity_chooser_view.xml b/actionbarsherlock/res/layout/abs__activity_chooser_view.xml deleted file mode 100644 index 019d14ef4..000000000 --- a/actionbarsherlock/res/layout/abs__activity_chooser_view.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/actionbarsherlock/res/layout/abs__activity_chooser_view_list_item.xml b/actionbarsherlock/res/layout/abs__activity_chooser_view_list_item.xml deleted file mode 100644 index b430032a1..000000000 --- a/actionbarsherlock/res/layout/abs__activity_chooser_view_list_item.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - diff --git a/actionbarsherlock/res/layout/abs__dialog_title_holo.xml b/actionbarsherlock/res/layout/abs__dialog_title_holo.xml deleted file mode 100644 index 6402f28be..000000000 --- a/actionbarsherlock/res/layout/abs__dialog_title_holo.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - diff --git a/actionbarsherlock/res/layout/abs__list_menu_item_checkbox.xml b/actionbarsherlock/res/layout/abs__list_menu_item_checkbox.xml deleted file mode 100644 index 39aca3a8d..000000000 --- a/actionbarsherlock/res/layout/abs__list_menu_item_checkbox.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - diff --git a/actionbarsherlock/res/layout/abs__list_menu_item_icon.xml b/actionbarsherlock/res/layout/abs__list_menu_item_icon.xml deleted file mode 100644 index 55ab28a24..000000000 --- a/actionbarsherlock/res/layout/abs__list_menu_item_icon.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - diff --git a/actionbarsherlock/res/layout/abs__list_menu_item_layout.xml b/actionbarsherlock/res/layout/abs__list_menu_item_layout.xml deleted file mode 100644 index 147f36fe8..000000000 --- a/actionbarsherlock/res/layout/abs__list_menu_item_layout.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/actionbarsherlock/res/layout/abs__list_menu_item_radio.xml b/actionbarsherlock/res/layout/abs__list_menu_item_radio.xml deleted file mode 100644 index ff54bbecd..000000000 --- a/actionbarsherlock/res/layout/abs__list_menu_item_radio.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - diff --git a/actionbarsherlock/res/layout/abs__popup_menu_item_layout.xml b/actionbarsherlock/res/layout/abs__popup_menu_item_layout.xml deleted file mode 100644 index d42425ad3..000000000 --- a/actionbarsherlock/res/layout/abs__popup_menu_item_layout.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/actionbarsherlock/res/layout/abs__screen_action_bar.xml b/actionbarsherlock/res/layout/abs__screen_action_bar.xml deleted file mode 100644 index 1fb82fe9a..000000000 --- a/actionbarsherlock/res/layout/abs__screen_action_bar.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - diff --git a/actionbarsherlock/res/layout/abs__screen_action_bar_overlay.xml b/actionbarsherlock/res/layout/abs__screen_action_bar_overlay.xml deleted file mode 100644 index 0961ef561..000000000 --- a/actionbarsherlock/res/layout/abs__screen_action_bar_overlay.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - diff --git a/actionbarsherlock/res/layout/abs__screen_simple.xml b/actionbarsherlock/res/layout/abs__screen_simple.xml deleted file mode 100644 index 33e2dea0d..000000000 --- a/actionbarsherlock/res/layout/abs__screen_simple.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - diff --git a/actionbarsherlock/res/layout/abs__screen_simple_overlay_action_mode.xml b/actionbarsherlock/res/layout/abs__screen_simple_overlay_action_mode.xml deleted file mode 100644 index f8b9fb185..000000000 --- a/actionbarsherlock/res/layout/abs__screen_simple_overlay_action_mode.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - diff --git a/actionbarsherlock/res/layout/sherlock_spinner_dropdown_item.xml b/actionbarsherlock/res/layout/sherlock_spinner_dropdown_item.xml deleted file mode 100644 index a6c6252d2..000000000 --- a/actionbarsherlock/res/layout/sherlock_spinner_dropdown_item.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - diff --git a/actionbarsherlock/res/layout/sherlock_spinner_item.xml b/actionbarsherlock/res/layout/sherlock_spinner_item.xml deleted file mode 100644 index bea740178..000000000 --- a/actionbarsherlock/res/layout/sherlock_spinner_item.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - diff --git a/actionbarsherlock/res/values-land/abs__dimens.xml b/actionbarsherlock/res/values-land/abs__dimens.xml deleted file mode 100644 index 502cc16a3..000000000 --- a/actionbarsherlock/res/values-land/abs__dimens.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - 40dip - - 4dip - - 16dp - - 12dp - - -2dp - - 4dip - diff --git a/actionbarsherlock/res/values-large-hdpi-1024x600/abs__dimens.xml b/actionbarsherlock/res/values-large-hdpi-1024x600/abs__dimens.xml deleted file mode 100644 index 3312cfa7f..000000000 --- a/actionbarsherlock/res/values-large-hdpi-1024x600/abs__dimens.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - 48dip - - 8dip - - 18dp - - 14dp - - -3dp - - 5dip - diff --git a/actionbarsherlock/res/values-large-land-hdpi-1024x600/abs__dimens.xml b/actionbarsherlock/res/values-large-land-hdpi-1024x600/abs__dimens.xml deleted file mode 100644 index 502cc16a3..000000000 --- a/actionbarsherlock/res/values-large-land-hdpi-1024x600/abs__dimens.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - 40dip - - 4dip - - 16dp - - 12dp - - -2dp - - 4dip - diff --git a/actionbarsherlock/res/values-large-land-mdpi-1024x600/abs__dimens.xml b/actionbarsherlock/res/values-large-land-mdpi-1024x600/abs__dimens.xml deleted file mode 100644 index 3312cfa7f..000000000 --- a/actionbarsherlock/res/values-large-land-mdpi-1024x600/abs__dimens.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - 48dip - - 8dip - - 18dp - - 14dp - - -3dp - - 5dip - diff --git a/actionbarsherlock/res/values-large-mdpi-1024x600/abs__dimens.xml b/actionbarsherlock/res/values-large-mdpi-1024x600/abs__dimens.xml deleted file mode 100644 index 35910333b..000000000 --- a/actionbarsherlock/res/values-large-mdpi-1024x600/abs__dimens.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - 56dip - - 4dip - - 18dp - - 14dp - - -3dp - - 9dip - - - 64dip - diff --git a/actionbarsherlock/res/values-large/abs__dimens.xml b/actionbarsherlock/res/values-large/abs__dimens.xml deleted file mode 100644 index 63b12f7f3..000000000 --- a/actionbarsherlock/res/values-large/abs__dimens.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - 55% - - 80% - diff --git a/actionbarsherlock/res/values-sw600dp/abs__bools.xml b/actionbarsherlock/res/values-sw600dp/abs__bools.xml deleted file mode 100644 index 7a48e1542..000000000 --- a/actionbarsherlock/res/values-sw600dp/abs__bools.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - false - diff --git a/actionbarsherlock/res/values-sw600dp/abs__dimens.xml b/actionbarsherlock/res/values-sw600dp/abs__dimens.xml deleted file mode 100644 index f67853817..000000000 --- a/actionbarsherlock/res/values-sw600dp/abs__dimens.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - 56dip - - 4dip - - 18dp - - 14dp - - -3dp - - 9dip - - 5 - - - 64dip - diff --git a/actionbarsherlock/res/values-v11/abs__themes.xml b/actionbarsherlock/res/values-v11/abs__themes.xml deleted file mode 100644 index 03473572c..000000000 --- a/actionbarsherlock/res/values-v11/abs__themes.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - diff --git a/actionbarsherlock/res/values-v14/abs__styles.xml b/actionbarsherlock/res/values-v14/abs__styles.xml deleted file mode 100644 index f2aa64d2d..000000000 --- a/actionbarsherlock/res/values-v14/abs__styles.xml +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/actionbarsherlock/res/values-v14/abs__themes.xml b/actionbarsherlock/res/values-v14/abs__themes.xml deleted file mode 100644 index ceb960737..000000000 --- a/actionbarsherlock/res/values-v14/abs__themes.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - diff --git a/actionbarsherlock/res/values-w360dp/abs__dimens.xml b/actionbarsherlock/res/values-w360dp/abs__dimens.xml deleted file mode 100644 index 6f49d7e47..000000000 --- a/actionbarsherlock/res/values-w360dp/abs__dimens.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - 3 - diff --git a/actionbarsherlock/res/values-w480dp/abs__bools.xml b/actionbarsherlock/res/values-w480dp/abs__bools.xml deleted file mode 100644 index 3eaf4aee9..000000000 --- a/actionbarsherlock/res/values-w480dp/abs__bools.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - true - false - diff --git a/actionbarsherlock/res/values-w480dp/abs__config.xml b/actionbarsherlock/res/values-w480dp/abs__config.xml deleted file mode 100644 index 88357b0a7..000000000 --- a/actionbarsherlock/res/values-w480dp/abs__config.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - true - - diff --git a/actionbarsherlock/res/values-w500dp/abs__dimens.xml b/actionbarsherlock/res/values-w500dp/abs__dimens.xml deleted file mode 100644 index 2fd4deea2..000000000 --- a/actionbarsherlock/res/values-w500dp/abs__dimens.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - 4 - diff --git a/actionbarsherlock/res/values-w600dp/abs__dimens.xml b/actionbarsherlock/res/values-w600dp/abs__dimens.xml deleted file mode 100644 index b085952d3..000000000 --- a/actionbarsherlock/res/values-w600dp/abs__dimens.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - 5 - diff --git a/actionbarsherlock/res/values-xlarge/abs__dimens.xml b/actionbarsherlock/res/values-xlarge/abs__dimens.xml deleted file mode 100644 index bfc535de1..000000000 --- a/actionbarsherlock/res/values-xlarge/abs__dimens.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - 56dip - - 4dip - - 18dp - - 14dp - - -3dp - - 9dip - - - 64dip - - - 45% - - 72% - diff --git a/actionbarsherlock/res/values/abs__attrs.xml b/actionbarsherlock/res/values/abs__attrs.xml deleted file mode 100644 index bd5ee4404..000000000 --- a/actionbarsherlock/res/values/abs__attrs.xml +++ /dev/null @@ -1,380 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/actionbarsherlock/res/values/abs__bools.xml b/actionbarsherlock/res/values/abs__bools.xml deleted file mode 100644 index 0b432448d..000000000 --- a/actionbarsherlock/res/values/abs__bools.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - false - true - true - - diff --git a/actionbarsherlock/res/values/abs__colors.xml b/actionbarsherlock/res/values/abs__colors.xml deleted file mode 100644 index 625c632ff..000000000 --- a/actionbarsherlock/res/values/abs__colors.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - #ff000000 - #fff3f3f3 - @color/abs__background_holo_light - @color/abs__background_holo_dark - #ff4c4c4c - #ffb2b2b2 - @color/abs__bright_foreground_holo_light - @color/abs__bright_foreground_holo_dark - #ff33b5e5 - diff --git a/actionbarsherlock/res/values/abs__config.xml b/actionbarsherlock/res/values/abs__config.xml deleted file mode 100644 index 4c7b5d459..000000000 --- a/actionbarsherlock/res/values/abs__config.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - 320dp - - - false - - - true - - - false - - diff --git a/actionbarsherlock/res/values/abs__dimens.xml b/actionbarsherlock/res/values/abs__dimens.xml deleted file mode 100644 index 0a409756c..000000000 --- a/actionbarsherlock/res/values/abs__dimens.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - 48dip - - 8dip - - 18dp - - 14dp - - -3dp - - 5dip - - 2 - - - 56dip - - - 64dip - - - 65% - - 95% - diff --git a/actionbarsherlock/res/values/abs__ids.xml b/actionbarsherlock/res/values/abs__ids.xml deleted file mode 100644 index f9f56045b..000000000 --- a/actionbarsherlock/res/values/abs__ids.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - diff --git a/actionbarsherlock/res/values/abs__strings.xml b/actionbarsherlock/res/values/abs__strings.xml deleted file mode 100644 index 1e1c7022c..000000000 --- a/actionbarsherlock/res/values/abs__strings.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - Navigate home - - Navigate up - - More options - - - Done - - - See all... - - Select activity - - Share with... - - Choose an application - - Share with - - Share with %s - diff --git a/actionbarsherlock/res/values/abs__styles.xml b/actionbarsherlock/res/values/abs__styles.xml deleted file mode 100644 index 8cbd36484..000000000 --- a/actionbarsherlock/res/values/abs__styles.xml +++ /dev/null @@ -1,384 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/actionbarsherlock/res/values/abs__themes.xml b/actionbarsherlock/res/values/abs__themes.xml deleted file mode 100644 index 5300dedd6..000000000 --- a/actionbarsherlock/res/values/abs__themes.xml +++ /dev/null @@ -1,226 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/actionbarsherlock/src/android/support/v4/app/_ActionBarSherlockTrojanHorse.java b/actionbarsherlock/src/android/support/v4/app/_ActionBarSherlockTrojanHorse.java deleted file mode 100644 index 3e3db62b7..000000000 --- a/actionbarsherlock/src/android/support/v4/app/_ActionBarSherlockTrojanHorse.java +++ /dev/null @@ -1,144 +0,0 @@ -package android.support.v4.app; - -import android.util.Log; -import android.view.View; -import android.view.Window; -import com.actionbarsherlock.ActionBarSherlock.OnCreatePanelMenuListener; -import com.actionbarsherlock.ActionBarSherlock.OnMenuItemSelectedListener; -import com.actionbarsherlock.ActionBarSherlock.OnPreparePanelListener; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuInflater; -import com.actionbarsherlock.view.MenuItem; - -import java.util.ArrayList; - -/** I'm in ur package. Stealing ur variables. */ -public abstract class _ActionBarSherlockTrojanHorse extends FragmentActivity implements OnCreatePanelMenuListener, OnPreparePanelListener, OnMenuItemSelectedListener { - private static final boolean DEBUG = false; - private static final String TAG = "_ActionBarSherlockTrojanHorse"; - - /** Fragment interface for menu creation callback. */ - public interface OnCreateOptionsMenuListener { - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater); - } - /** Fragment interface for menu preparation callback. */ - public interface OnPrepareOptionsMenuListener { - public void onPrepareOptionsMenu(Menu menu); - } - /** Fragment interface for menu item selection callback. */ - public interface OnOptionsItemSelectedListener { - public boolean onOptionsItemSelected(MenuItem item); - } - - private ArrayList mCreatedMenus; - - - /////////////////////////////////////////////////////////////////////////// - // Sherlock menu handling - /////////////////////////////////////////////////////////////////////////// - - @Override - public boolean onCreatePanelMenu(int featureId, Menu menu) { - if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] featureId: " + featureId + ", menu: " + menu); - - if (featureId == Window.FEATURE_OPTIONS_PANEL) { - boolean result = onCreateOptionsMenu(menu); - if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] activity create result: " + result); - - MenuInflater inflater = getSupportMenuInflater(); - boolean show = false; - ArrayList newMenus = null; - if (mFragments.mActive != null) { - for (int i = 0; i < mFragments.mAdded.size(); i++) { - Fragment f = mFragments.mAdded.get(i); - if (f != null && !f.mHidden && f.mHasMenu && f.mMenuVisible && f instanceof OnCreateOptionsMenuListener) { - show = true; - ((OnCreateOptionsMenuListener)f).onCreateOptionsMenu(menu, inflater); - if (newMenus == null) { - newMenus = new ArrayList(); - } - newMenus.add(f); - } - } - } - - if (mCreatedMenus != null) { - for (int i = 0; i < mCreatedMenus.size(); i++) { - Fragment f = mCreatedMenus.get(i); - if (newMenus == null || !newMenus.contains(f)) { - f.onDestroyOptionsMenu(); - } - } - } - - mCreatedMenus = newMenus; - - if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] fragments create result: " + show); - result |= show; - - if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] returning " + result); - return result; - } - return false; - } - - @Override - public boolean onPreparePanel(int featureId, View view, Menu menu) { - if (DEBUG) Log.d(TAG, "[onPreparePanel] featureId: " + featureId + ", view: " + view + " menu: " + menu); - - if (featureId == Window.FEATURE_OPTIONS_PANEL) { - boolean result = onPrepareOptionsMenu(menu); - if (DEBUG) Log.d(TAG, "[onPreparePanel] activity prepare result: " + result); - - boolean show = false; - if (mFragments.mActive != null) { - for (int i = 0; i < mFragments.mAdded.size(); i++) { - Fragment f = mFragments.mAdded.get(i); - if (f != null && !f.mHidden && f.mHasMenu && f.mMenuVisible && f instanceof OnPrepareOptionsMenuListener) { - show = true; - ((OnPrepareOptionsMenuListener)f).onPrepareOptionsMenu(menu); - } - } - } - - if (DEBUG) Log.d(TAG, "[onPreparePanel] fragments prepare result: " + show); - result |= show; - - result &= menu.hasVisibleItems(); - if (DEBUG) Log.d(TAG, "[onPreparePanel] returning " + result); - return result; - } - return false; - } - - @Override - public boolean onMenuItemSelected(int featureId, MenuItem item) { - if (DEBUG) Log.d(TAG, "[onMenuItemSelected] featureId: " + featureId + ", item: " + item); - - if (featureId == Window.FEATURE_OPTIONS_PANEL) { - if (onOptionsItemSelected(item)) { - return true; - } - - if (mFragments.mActive != null) { - for (int i = 0; i < mFragments.mAdded.size(); i++) { - Fragment f = mFragments.mAdded.get(i); - if (f != null && !f.mHidden && f.mHasMenu && f.mMenuVisible && f instanceof OnOptionsItemSelectedListener) { - if (((OnOptionsItemSelectedListener)f).onOptionsItemSelected(item)) { - return true; - } - } - } - } - } - return false; - } - - public abstract boolean onCreateOptionsMenu(Menu menu); - - public abstract boolean onPrepareOptionsMenu(Menu menu); - - public abstract boolean onOptionsItemSelected(MenuItem item); - - public abstract MenuInflater getSupportMenuInflater(); -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/ActionBarSherlock.java b/actionbarsherlock/src/com/actionbarsherlock/ActionBarSherlock.java deleted file mode 100644 index 8340fb591..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/ActionBarSherlock.java +++ /dev/null @@ -1,791 +0,0 @@ -package com.actionbarsherlock; - -import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.HashMap; -import java.util.Iterator; -import android.app.Activity; -import android.content.Context; -import android.content.res.Configuration; -import android.os.Build; -import android.os.Bundle; -import android.util.DisplayMetrics; -import android.util.Log; -import android.view.KeyEvent; -import android.view.View; -import android.view.ViewGroup; -import android.view.Window; -import com.actionbarsherlock.app.ActionBar; -import com.actionbarsherlock.internal.ActionBarSherlockCompat; -import com.actionbarsherlock.internal.ActionBarSherlockNative; -import com.actionbarsherlock.view.ActionMode; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuInflater; -import com.actionbarsherlock.view.MenuItem; - -/** - *

Helper for implementing the action bar design pattern across all versions - * of Android.

- * - *

This class will manage interaction with a custom action bar based on the - * Android 4.0 source code. The exposed API mirrors that of its native - * counterpart and you should refer to its documentation for instruction.

- * - * @author Jake Wharton - */ -public abstract class ActionBarSherlock { - protected static final String TAG = "ActionBarSherlock"; - protected static final boolean DEBUG = false; - - private static final Class[] CONSTRUCTOR_ARGS = new Class[] { Activity.class, int.class }; - private static final HashMap> IMPLEMENTATIONS = - new HashMap>(); - - static { - //Register our two built-in implementations - registerImplementation(ActionBarSherlockCompat.class); - registerImplementation(ActionBarSherlockNative.class); - } - - - /** - *

Denotes an implementation of ActionBarSherlock which provides an - * action bar-enhanced experience.

- */ - @Target(ElementType.TYPE) - @Retention(RetentionPolicy.RUNTIME) - public @interface Implementation { - static final int DEFAULT_API = -1; - static final int DEFAULT_DPI = -1; - - int api() default DEFAULT_API; - int dpi() default DEFAULT_DPI; - } - - - /** Activity interface for menu creation callback. */ - public interface OnCreatePanelMenuListener { - public boolean onCreatePanelMenu(int featureId, Menu menu); - } - /** Activity interface for menu creation callback. */ - public interface OnCreateOptionsMenuListener { - public boolean onCreateOptionsMenu(Menu menu); - } - /** Activity interface for menu item selection callback. */ - public interface OnMenuItemSelectedListener { - public boolean onMenuItemSelected(int featureId, MenuItem item); - } - /** Activity interface for menu item selection callback. */ - public interface OnOptionsItemSelectedListener { - public boolean onOptionsItemSelected(MenuItem item); - } - /** Activity interface for menu preparation callback. */ - public interface OnPreparePanelListener { - public boolean onPreparePanel(int featureId, View view, Menu menu); - } - /** Activity interface for menu preparation callback. */ - public interface OnPrepareOptionsMenuListener { - public boolean onPrepareOptionsMenu(Menu menu); - } - /** Activity interface for action mode finished callback. */ - public interface OnActionModeFinishedListener { - public void onActionModeFinished(ActionMode mode); - } - /** Activity interface for action mode started callback. */ - public interface OnActionModeStartedListener { - public void onActionModeStarted(ActionMode mode); - } - - - /** - * If set, the logic in these classes will assume that an {@link Activity} - * is dispatching all of the required events to the class. This flag should - * only be used internally or if you are creating your own base activity - * modeled after one of the included types (e.g., {@code SherlockActivity}). - */ - public static final int FLAG_DELEGATE = 1; - - - /** - * Register an ActionBarSherlock implementation. - * - * @param implementationClass Target implementation class which extends - * {@link ActionBarSherlock}. This class must also be annotated with - * {@link Implementation}. - */ - public static void registerImplementation(Class implementationClass) { - if (!implementationClass.isAnnotationPresent(Implementation.class)) { - throw new IllegalArgumentException("Class " + implementationClass.getSimpleName() + " is not annotated with @Implementation"); - } else if (IMPLEMENTATIONS.containsValue(implementationClass)) { - if (DEBUG) Log.w(TAG, "Class " + implementationClass.getSimpleName() + " already registered"); - return; - } - - Implementation impl = implementationClass.getAnnotation(Implementation.class); - if (DEBUG) Log.i(TAG, "Registering " + implementationClass.getSimpleName() + " with qualifier " + impl); - IMPLEMENTATIONS.put(impl, implementationClass); - } - - /** - * Unregister an ActionBarSherlock implementation. This should be - * considered very volatile and you should only use it if you know what - * you are doing. You have been warned. - * - * @param implementationClass Target implementation class. - * @return Boolean indicating whether the class was removed. - */ - public static boolean unregisterImplementation(Class implementationClass) { - return IMPLEMENTATIONS.values().remove(implementationClass); - } - - /** - * Wrap an activity with an action bar abstraction which will enable the - * use of a custom implementation on platforms where a native version does - * not exist. - * - * @param activity Activity to wrap. - * @return Instance to interact with the action bar. - */ - public static ActionBarSherlock wrap(Activity activity) { - return wrap(activity, 0); - } - - /** - * Wrap an activity with an action bar abstraction which will enable the - * use of a custom implementation on platforms where a native version does - * not exist. - * - * @param activity Owning activity. - * @param flags Option flags to control behavior. - * @return Instance to interact with the action bar. - */ - public static ActionBarSherlock wrap(Activity activity, int flags) { - //Create a local implementation map we can modify - HashMap> impls = - new HashMap>(IMPLEMENTATIONS); - boolean hasQualfier; - - /* DPI FILTERING */ - hasQualfier = false; - for (Implementation key : impls.keySet()) { - //Only honor TVDPI as a specific qualifier - if (key.dpi() == DisplayMetrics.DENSITY_TV) { - hasQualfier = true; - break; - } - } - if (hasQualfier) { - final boolean isTvDpi = activity.getResources().getDisplayMetrics().densityDpi == DisplayMetrics.DENSITY_TV; - for (Iterator keys = impls.keySet().iterator(); keys.hasNext(); ) { - int keyDpi = keys.next().dpi(); - if ((isTvDpi && keyDpi != DisplayMetrics.DENSITY_TV) - || (!isTvDpi && keyDpi == DisplayMetrics.DENSITY_TV)) { - keys.remove(); - } - } - } - - /* API FILTERING */ - hasQualfier = false; - for (Implementation key : impls.keySet()) { - if (key.api() != Implementation.DEFAULT_API) { - hasQualfier = true; - break; - } - } - if (hasQualfier) { - final int runtimeApi = Build.VERSION.SDK_INT; - int bestApi = 0; - for (Iterator keys = impls.keySet().iterator(); keys.hasNext(); ) { - int keyApi = keys.next().api(); - if (keyApi > runtimeApi) { - keys.remove(); - } else if (keyApi > bestApi) { - bestApi = keyApi; - } - } - for (Iterator keys = impls.keySet().iterator(); keys.hasNext(); ) { - if (keys.next().api() != bestApi) { - keys.remove(); - } - } - } - - if (impls.size() > 1) { - throw new IllegalStateException("More than one implementation matches configuration."); - } - if (impls.isEmpty()) { - throw new IllegalStateException("No implementations match configuration."); - } - Class impl = impls.values().iterator().next(); - if (DEBUG) Log.i(TAG, "Using implementation: " + impl.getSimpleName()); - - try { - Constructor ctor = impl.getConstructor(CONSTRUCTOR_ARGS); - return ctor.newInstance(activity, flags); - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } catch (IllegalArgumentException e) { - throw new RuntimeException(e); - } catch (InstantiationException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } catch (InvocationTargetException e) { - throw new RuntimeException(e); - } - } - - - /** Activity which is displaying the action bar. Also used for context. */ - protected final Activity mActivity; - /** Whether delegating actions for the activity or managing ourselves. */ - protected final boolean mIsDelegate; - - /** Reference to our custom menu inflater which supports action items. */ - protected MenuInflater mMenuInflater; - - - - protected ActionBarSherlock(Activity activity, int flags) { - if (DEBUG) Log.d(TAG, "[] activity: " + activity + ", flags: " + flags); - - mActivity = activity; - mIsDelegate = (flags & FLAG_DELEGATE) != 0; - } - - - /** - * Get the current action bar instance. - * - * @return Action bar instance. - */ - public abstract ActionBar getActionBar(); - - - /////////////////////////////////////////////////////////////////////////// - // Lifecycle and interaction callbacks when delegating - /////////////////////////////////////////////////////////////////////////// - - /** - * Notify action bar of a configuration change event. Should be dispatched - * after the call to the superclass implementation. - * - *
-     * @Override
-     * public void onConfigurationChanged(Configuration newConfig) {
-     *     super.onConfigurationChanged(newConfig);
-     *     mSherlock.dispatchConfigurationChanged(newConfig);
-     * }
-     * 
- * - * @param newConfig The new device configuration. - */ - public void dispatchConfigurationChanged(Configuration newConfig) {} - - /** - * Notify the action bar that the activity has finished its resuming. This - * should be dispatched after the call to the superclass implementation. - * - *
-     * @Override
-     * protected void onPostResume() {
-     *     super.onPostResume();
-     *     mSherlock.dispatchPostResume();
-     * }
-     * 
- */ - public void dispatchPostResume() {} - - /** - * Notify the action bar that the activity is pausing. This should be - * dispatched before the call to the superclass implementation. - * - *
-     * @Override
-     * protected void onPause() {
-     *     mSherlock.dispatchPause();
-     *     super.onPause();
-     * }
-     * 
- */ - public void dispatchPause() {} - - /** - * Notify the action bar that the activity is stopping. This should be - * called before the superclass implementation. - * - *

- * @Override - * protected void onStop() { - * mSherlock.dispatchStop(); - * super.onStop(); - * } - *

- */ - public void dispatchStop() {} - - /** - * Indicate that the menu should be recreated by calling - * {@link OnCreateOptionsMenuListener#onCreateOptionsMenu(com.actionbarsherlock.view.Menu)}. - */ - public abstract void dispatchInvalidateOptionsMenu(); - - /** - * Notify the action bar that it should display its overflow menu if it is - * appropriate for the device. The implementation should conditionally - * call the superclass method only if this method returns {@code false}. - * - *

- * @Override - * public void openOptionsMenu() { - * if (!mSherlock.dispatchOpenOptionsMenu()) { - * super.openOptionsMenu(); - * } - * } - *

- * - * @return {@code true} if the opening of the menu was handled internally. - */ - public boolean dispatchOpenOptionsMenu() { - return false; - } - - /** - * Notify the action bar that it should close its overflow menu if it is - * appropriate for the device. This implementation should conditionally - * call the superclass method only if this method returns {@code false}. - * - *
-     * @Override
-     * public void closeOptionsMenu() {
-     *     if (!mSherlock.dispatchCloseOptionsMenu()) {
-     *         super.closeOptionsMenu();
-     *     }
-     * }
-     * 
- * - * @return {@code true} if the closing of the menu was handled internally. - */ - public boolean dispatchCloseOptionsMenu() { - return false; - } - - /** - * Notify the class that the activity has finished its creation. This - * should be called after the superclass implementation. - * - *
-     * @Override
-     * protected void onPostCreate(Bundle savedInstanceState) {
-     *     mSherlock.dispatchPostCreate(savedInstanceState);
-     *     super.onPostCreate(savedInstanceState);
-     * }
-     * 
- * - * @param savedInstanceState If the activity is being re-initialized after - * previously being shut down then this Bundle - * contains the data it most recently supplied in - * {@link Activity#}onSaveInstanceState(Bundle)}. - * Note: Otherwise it is null. - */ - public void dispatchPostCreate(Bundle savedInstanceState) {} - - /** - * Notify the action bar that the title has changed and the action bar - * should be updated to reflect the change. This should be called before - * the superclass implementation. - * - *
-     *  @Override
-     *  protected void onTitleChanged(CharSequence title, int color) {
-     *      mSherlock.dispatchTitleChanged(title, color);
-     *      super.onTitleChanged(title, color);
-     *  }
-     * 
- * - * @param title New activity title. - * @param color New activity color. - */ - public void dispatchTitleChanged(CharSequence title, int color) {} - - /** - * Notify the action bar the user has created a key event. This is used to - * toggle the display of the overflow action item with the menu key and to - * close the action mode or expanded action item with the back key. - * - *
-     * @Override
-     * public boolean dispatchKeyEvent(KeyEvent event) {
-     *     if (mSherlock.dispatchKeyEvent(event)) {
-     *         return true;
-     *     }
-     *     return super.dispatchKeyEvent(event);
-     * }
-     * 
- * - * @param event Description of the key event. - * @return {@code true} if the event was handled. - */ - public boolean dispatchKeyEvent(KeyEvent event) { - return false; - } - - /** - * Notify the action bar that the Activity has triggered a menu creation - * which should happen on the conclusion of {@link Activity#onCreate}. This - * will be used to gain a reference to the native menu for native and - * overflow binding as well as to indicate when compatibility create should - * occur for the first time. - * - * @param menu Activity native menu. - * @return {@code true} since we always want to say that we have a native - */ - public abstract boolean dispatchCreateOptionsMenu(android.view.Menu menu); - - /** - * Notify the action bar that the Activity has triggered a menu preparation - * which usually means that the user has requested the overflow menu via a - * hardware menu key. You should return the result of this method call and - * not call the superclass implementation. - * - *

- * @Override - * public final boolean onPrepareOptionsMenu(android.view.Menu menu) { - * return mSherlock.dispatchPrepareOptionsMenu(menu); - * } - *

- * - * @param menu Activity native menu. - * @return {@code true} if menu display should proceed. - */ - public abstract boolean dispatchPrepareOptionsMenu(android.view.Menu menu); - - /** - * Notify the action bar that a native options menu item has been selected. - * The implementation should return the result of this method call. - * - *

- * @Override - * public final boolean onOptionsItemSelected(android.view.MenuItem item) { - * return mSherlock.dispatchOptionsItemSelected(item); - * } - *

- * - * @param item Options menu item. - * @return @{code true} if the selection was handled. - */ - public abstract boolean dispatchOptionsItemSelected(android.view.MenuItem item); - - /** - * Notify the action bar that the overflow menu has been opened. The - * implementation should conditionally return {@code true} if this method - * returns {@code true}, otherwise return the result of the superclass - * method. - * - *

- * @Override - * public final boolean onMenuOpened(int featureId, android.view.Menu menu) { - * if (mSherlock.dispatchMenuOpened(featureId, menu)) { - * return true; - * } - * return super.onMenuOpened(featureId, menu); - * } - *

- * - * @param featureId Window feature which triggered the event. - * @param menu Activity native menu. - * @return {@code true} if the event was handled by this method. - */ - public boolean dispatchMenuOpened(int featureId, android.view.Menu menu) { - return false; - } - - /** - * Notify the action bar that the overflow menu has been closed. This - * method should be called before the superclass implementation. - * - *

- * @Override - * public void onPanelClosed(int featureId, android.view.Menu menu) { - * mSherlock.dispatchPanelClosed(featureId, menu); - * super.onPanelClosed(featureId, menu); - * } - *

- * - * @param featureId - * @param menu - */ - public void dispatchPanelClosed(int featureId, android.view.Menu menu) {} - - /** - * Notify the action bar that the activity has been destroyed. This method - * should be called before the superclass implementation. - * - *

- * @Override - * public void onDestroy() { - * mSherlock.dispatchDestroy(); - * super.onDestroy(); - * } - *

- */ - public void dispatchDestroy() {} - - - /////////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////////// - - - /** - * Internal method to trigger the menu creation process. - * - * @return {@code true} if menu creation should proceed. - */ - protected final boolean callbackCreateOptionsMenu(Menu menu) { - if (DEBUG) Log.d(TAG, "[callbackCreateOptionsMenu] menu: " + menu); - - boolean result = true; - if (mActivity instanceof OnCreatePanelMenuListener) { - OnCreatePanelMenuListener listener = (OnCreatePanelMenuListener)mActivity; - result = listener.onCreatePanelMenu(Window.FEATURE_OPTIONS_PANEL, menu); - } else if (mActivity instanceof OnCreateOptionsMenuListener) { - OnCreateOptionsMenuListener listener = (OnCreateOptionsMenuListener)mActivity; - result = listener.onCreateOptionsMenu(menu); - } - - if (DEBUG) Log.d(TAG, "[callbackCreateOptionsMenu] returning " + result); - return result; - } - - /** - * Internal method to trigger the menu preparation process. - * - * @return {@code true} if menu preparation should proceed. - */ - protected final boolean callbackPrepareOptionsMenu(Menu menu) { - if (DEBUG) Log.d(TAG, "[callbackPrepareOptionsMenu] menu: " + menu); - - boolean result = true; - if (mActivity instanceof OnPreparePanelListener) { - OnPreparePanelListener listener = (OnPreparePanelListener)mActivity; - result = listener.onPreparePanel(Window.FEATURE_OPTIONS_PANEL, null, menu); - } else if (mActivity instanceof OnPrepareOptionsMenuListener) { - OnPrepareOptionsMenuListener listener = (OnPrepareOptionsMenuListener)mActivity; - result = listener.onPrepareOptionsMenu(menu); - } - - if (DEBUG) Log.d(TAG, "[callbackPrepareOptionsMenu] returning " + result); - return result; - } - - /** - * Internal method for dispatching options menu selection to the owning - * activity callback. - * - * @param item Selected options menu item. - * @return {@code true} if the item selection was handled in the callback. - */ - protected final boolean callbackOptionsItemSelected(MenuItem item) { - if (DEBUG) Log.d(TAG, "[callbackOptionsItemSelected] item: " + item.getTitleCondensed()); - - boolean result = false; - if (mActivity instanceof OnMenuItemSelectedListener) { - OnMenuItemSelectedListener listener = (OnMenuItemSelectedListener)mActivity; - result = listener.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, item); - } else if (mActivity instanceof OnOptionsItemSelectedListener) { - OnOptionsItemSelectedListener listener = (OnOptionsItemSelectedListener)mActivity; - result = listener.onOptionsItemSelected(item); - } - - if (DEBUG) Log.d(TAG, "[callbackOptionsItemSelected] returning " + result); - return result; - } - - - /////////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////////// - - - /** - * Query for the availability of a certain feature. - * - * @param featureId The feature ID to check. - * @return {@code true} if feature is enabled, {@code false} otherwise. - */ - public abstract boolean hasFeature(int featureId); - - /** - * Enable extended screen features. This must be called before - * {@code setContentView()}. May be called as many times as desired as long - * as it is before {@code setContentView()}. If not called, no extended - * features will be available. You can not turn off a feature once it is - * requested. - * - * @param featureId The desired features, defined as constants by Window. - * @return Returns true if the requested feature is supported and now - * enabled. - */ - public abstract boolean requestFeature(int featureId); - - /** - * Set extra options that will influence the UI for this window. - * - * @param uiOptions Flags specifying extra options for this window. - */ - public abstract void setUiOptions(int uiOptions); - - /** - * Set extra options that will influence the UI for this window. Only the - * bits filtered by mask will be modified. - * - * @param uiOptions Flags specifying extra options for this window. - * @param mask Flags specifying which options should be modified. Others - * will remain unchanged. - */ - public abstract void setUiOptions(int uiOptions, int mask); - - /** - * Set the content of the activity inside the action bar. - * - * @param layoutResId Layout resource ID. - */ - public abstract void setContentView(int layoutResId); - - /** - * Set the content of the activity inside the action bar. - * - * @param view The desired content to display. - */ - public void setContentView(View view) { - if (DEBUG) Log.d(TAG, "[setContentView] view: " + view); - - setContentView(view, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)); - } - - /** - * Set the content of the activity inside the action bar. - * - * @param view The desired content to display. - * @param params Layout parameters to apply to the view. - */ - public abstract void setContentView(View view, ViewGroup.LayoutParams params); - - /** - * Variation on {@link #setContentView(android.view.View, android.view.ViewGroup.LayoutParams)} - * to add an additional content view to the screen. Added after any - * existing ones on the screen -- existing views are NOT removed. - * - * @param view The desired content to display. - * @param params Layout parameters for the view. - */ - public abstract void addContentView(View view, ViewGroup.LayoutParams params); - - /** - * Change the title associated with this activity. - */ - public abstract void setTitle(CharSequence title); - - /** - * Change the title associated with this activity. - */ - public void setTitle(int resId) { - if (DEBUG) Log.d(TAG, "[setTitle] resId: " + resId); - - setTitle(mActivity.getString(resId)); - } - - /** - * Sets the visibility of the progress bar in the title. - *

- * In order for the progress bar to be shown, the feature must be requested - * via {@link #requestWindowFeature(int)}. - * - * @param visible Whether to show the progress bars in the title. - */ - public abstract void setProgressBarVisibility(boolean visible); - - /** - * Sets the visibility of the indeterminate progress bar in the title. - *

- * In order for the progress bar to be shown, the feature must be requested - * via {@link #requestWindowFeature(int)}. - * - * @param visible Whether to show the progress bars in the title. - */ - public abstract void setProgressBarIndeterminateVisibility(boolean visible); - - /** - * Sets whether the horizontal progress bar in the title should be indeterminate (the circular - * is always indeterminate). - *

- * In order for the progress bar to be shown, the feature must be requested - * via {@link #requestWindowFeature(int)}. - * - * @param indeterminate Whether the horizontal progress bar should be indeterminate. - */ - public abstract void setProgressBarIndeterminate(boolean indeterminate); - - /** - * Sets the progress for the progress bars in the title. - *

- * In order for the progress bar to be shown, the feature must be requested - * via {@link #requestWindowFeature(int)}. - * - * @param progress The progress for the progress bar. Valid ranges are from - * 0 to 10000 (both inclusive). If 10000 is given, the progress - * bar will be completely filled and will fade out. - */ - public abstract void setProgress(int progress); - - /** - * Sets the secondary progress for the progress bar in the title. This - * progress is drawn between the primary progress (set via - * {@link #setProgress(int)} and the background. It can be ideal for media - * scenarios such as showing the buffering progress while the default - * progress shows the play progress. - *

- * In order for the progress bar to be shown, the feature must be requested - * via {@link #requestWindowFeature(int)}. - * - * @param secondaryProgress The secondary progress for the progress bar. Valid ranges are from - * 0 to 10000 (both inclusive). - */ - public abstract void setSecondaryProgress(int secondaryProgress); - - /** - * Get a menu inflater instance which supports the newer menu attributes. - * - * @return Menu inflater instance. - */ - public MenuInflater getMenuInflater() { - if (DEBUG) Log.d(TAG, "[getMenuInflater]"); - - // Make sure that action views can get an appropriate theme. - if (mMenuInflater == null) { - if (getActionBar() != null) { - mMenuInflater = new MenuInflater(getThemedContext()); - } else { - mMenuInflater = new MenuInflater(mActivity); - } - } - return mMenuInflater; - } - - protected abstract Context getThemedContext(); - - /** - * Start an action mode. - * - * @param callback Callback that will manage lifecycle events for this - * context mode. - * @return The ContextMode that was started, or null if it was canceled. - * @see ActionMode - */ - public abstract ActionMode startActionMode(ActionMode.Callback callback); -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/app/ActionBar.java b/actionbarsherlock/src/com/actionbarsherlock/app/ActionBar.java deleted file mode 100644 index 2497d24ff..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/app/ActionBar.java +++ /dev/null @@ -1,947 +0,0 @@ -/* - * Copyright (C) 2010 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.actionbarsherlock.app; - -import android.content.Context; -import android.graphics.drawable.Drawable; -import android.support.v4.app.FragmentTransaction; -import android.util.AttributeSet; -import android.view.Gravity; -import android.view.View; -import android.view.ViewDebug; -import android.view.ViewGroup; -import android.view.ViewGroup.MarginLayoutParams; -import android.widget.SpinnerAdapter; - -/** - * A window feature at the top of the activity that may display the activity title, navigation - * modes, and other interactive items. - *

Beginning with Android 3.0 (API level 11), the action bar appears at the top of an - * activity's window when the activity uses the system's {@link - * android.R.style#Theme_Holo Holo} theme (or one of its descendant themes), which is the default. - * You may otherwise add the action bar by calling {@link - * android.view.Window#requestFeature requestFeature(FEATURE_ACTION_BAR)} or by declaring it in a - * custom theme with the {@link android.R.styleable#Theme_windowActionBar windowActionBar} property. - *

By default, the action bar shows the application icon on - * the left, followed by the activity title. If your activity has an options menu, you can make - * select items accessible directly from the action bar as "action items". You can also - * modify various characteristics of the action bar or remove it completely.

- *

From your activity, you can retrieve an instance of {@link ActionBar} by calling {@link - * android.app.Activity#getActionBar getActionBar()}.

- *

In some cases, the action bar may be overlayed by another bar that enables contextual actions, - * using an {@link android.view.ActionMode}. For example, when the user selects one or more items in - * your activity, you can enable an action mode that offers actions specific to the selected - * items, with a UI that temporarily replaces the action bar. Although the UI may occupy the - * same space, the {@link android.view.ActionMode} APIs are distinct and independent from those for - * {@link ActionBar}. - *

- *

Developer Guides

- *

For information about how to use the action bar, including how to add action items, navigation - * modes and more, read the Action - * Bar developer guide.

- *
- */ -public abstract class ActionBar { - /** - * Standard navigation mode. Consists of either a logo or icon - * and title text with an optional subtitle. Clicking any of these elements - * will dispatch onOptionsItemSelected to the host Activity with - * a MenuItem with item ID android.R.id.home. - */ - public static final int NAVIGATION_MODE_STANDARD = android.app.ActionBar.NAVIGATION_MODE_STANDARD; - - /** - * List navigation mode. Instead of static title text this mode - * presents a list menu for navigation within the activity. - * e.g. this might be presented to the user as a dropdown list. - */ - public static final int NAVIGATION_MODE_LIST = android.app.ActionBar.NAVIGATION_MODE_LIST; - - /** - * Tab navigation mode. Instead of static title text this mode - * presents a series of tabs for navigation within the activity. - */ - public static final int NAVIGATION_MODE_TABS = android.app.ActionBar.NAVIGATION_MODE_TABS; - - /** - * Use logo instead of icon if available. This flag will cause appropriate - * navigation modes to use a wider logo in place of the standard icon. - * - * @see #setDisplayOptions(int) - * @see #setDisplayOptions(int, int) - */ - public static final int DISPLAY_USE_LOGO = android.app.ActionBar.DISPLAY_USE_LOGO; - - /** - * Show 'home' elements in this action bar, leaving more space for other - * navigation elements. This includes logo and icon. - * - * @see #setDisplayOptions(int) - * @see #setDisplayOptions(int, int) - */ - public static final int DISPLAY_SHOW_HOME = android.app.ActionBar.DISPLAY_SHOW_HOME; - - /** - * Display the 'home' element such that it appears as an 'up' affordance. - * e.g. show an arrow to the left indicating the action that will be taken. - * - * Set this flag if selecting the 'home' button in the action bar to return - * up by a single level in your UI rather than back to the top level or front page. - * - *

Setting this option will implicitly enable interaction with the home/up - * button. See {@link #setHomeButtonEnabled(boolean)}. - * - * @see #setDisplayOptions(int) - * @see #setDisplayOptions(int, int) - */ - public static final int DISPLAY_HOME_AS_UP = android.app.ActionBar.DISPLAY_HOME_AS_UP; - - /** - * Show the activity title and subtitle, if present. - * - * @see #setTitle(CharSequence) - * @see #setTitle(int) - * @see #setSubtitle(CharSequence) - * @see #setSubtitle(int) - * @see #setDisplayOptions(int) - * @see #setDisplayOptions(int, int) - */ - public static final int DISPLAY_SHOW_TITLE = android.app.ActionBar.DISPLAY_SHOW_TITLE; - - /** - * Show the custom view if one has been set. - * @see #setCustomView(View) - * @see #setDisplayOptions(int) - * @see #setDisplayOptions(int, int) - */ - public static final int DISPLAY_SHOW_CUSTOM = android.app.ActionBar.DISPLAY_SHOW_CUSTOM; - - /** - * Set the action bar into custom navigation mode, supplying a view - * for custom navigation. - * - * Custom navigation views appear between the application icon and - * any action buttons and may use any space available there. Common - * use cases for custom navigation views might include an auto-suggesting - * address bar for a browser or other navigation mechanisms that do not - * translate well to provided navigation modes. - * - * @param view Custom navigation view to place in the ActionBar. - */ - public abstract void setCustomView(View view); - - /** - * Set the action bar into custom navigation mode, supplying a view - * for custom navigation. - * - *

Custom navigation views appear between the application icon and - * any action buttons and may use any space available there. Common - * use cases for custom navigation views might include an auto-suggesting - * address bar for a browser or other navigation mechanisms that do not - * translate well to provided navigation modes.

- * - *

The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for - * the custom view to be displayed.

- * - * @param view Custom navigation view to place in the ActionBar. - * @param layoutParams How this custom view should layout in the bar. - * - * @see #setDisplayOptions(int, int) - */ - public abstract void setCustomView(View view, LayoutParams layoutParams); - - /** - * Set the action bar into custom navigation mode, supplying a view - * for custom navigation. - * - *

Custom navigation views appear between the application icon and - * any action buttons and may use any space available there. Common - * use cases for custom navigation views might include an auto-suggesting - * address bar for a browser or other navigation mechanisms that do not - * translate well to provided navigation modes.

- * - *

The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for - * the custom view to be displayed.

- * - * @param resId Resource ID of a layout to inflate into the ActionBar. - * - * @see #setDisplayOptions(int, int) - */ - public abstract void setCustomView(int resId); - - /** - * Set the icon to display in the 'home' section of the action bar. - * The action bar will use an icon specified by its style or the - * activity icon by default. - * - * Whether the home section shows an icon or logo is controlled - * by the display option {@link #DISPLAY_USE_LOGO}. - * - * @param resId Resource ID of a drawable to show as an icon. - * - * @see #setDisplayUseLogoEnabled(boolean) - * @see #setDisplayShowHomeEnabled(boolean) - */ - public abstract void setIcon(int resId); - - /** - * Set the icon to display in the 'home' section of the action bar. - * The action bar will use an icon specified by its style or the - * activity icon by default. - * - * Whether the home section shows an icon or logo is controlled - * by the display option {@link #DISPLAY_USE_LOGO}. - * - * @param icon Drawable to show as an icon. - * - * @see #setDisplayUseLogoEnabled(boolean) - * @see #setDisplayShowHomeEnabled(boolean) - */ - public abstract void setIcon(Drawable icon); - - /** - * Set the logo to display in the 'home' section of the action bar. - * The action bar will use a logo specified by its style or the - * activity logo by default. - * - * Whether the home section shows an icon or logo is controlled - * by the display option {@link #DISPLAY_USE_LOGO}. - * - * @param resId Resource ID of a drawable to show as a logo. - * - * @see #setDisplayUseLogoEnabled(boolean) - * @see #setDisplayShowHomeEnabled(boolean) - */ - public abstract void setLogo(int resId); - - /** - * Set the logo to display in the 'home' section of the action bar. - * The action bar will use a logo specified by its style or the - * activity logo by default. - * - * Whether the home section shows an icon or logo is controlled - * by the display option {@link #DISPLAY_USE_LOGO}. - * - * @param logo Drawable to show as a logo. - * - * @see #setDisplayUseLogoEnabled(boolean) - * @see #setDisplayShowHomeEnabled(boolean) - */ - public abstract void setLogo(Drawable logo); - - /** - * Set the adapter and navigation callback for list navigation mode. - * - * The supplied adapter will provide views for the expanded list as well as - * the currently selected item. (These may be displayed differently.) - * - * The supplied OnNavigationListener will alert the application when the user - * changes the current list selection. - * - * @param adapter An adapter that will provide views both to display - * the current navigation selection and populate views - * within the dropdown navigation menu. - * @param callback An OnNavigationListener that will receive events when the user - * selects a navigation item. - */ - public abstract void setListNavigationCallbacks(SpinnerAdapter adapter, - OnNavigationListener callback); - - /** - * Set the selected navigation item in list or tabbed navigation modes. - * - * @param position Position of the item to select. - */ - public abstract void setSelectedNavigationItem(int position); - - /** - * Get the position of the selected navigation item in list or tabbed navigation modes. - * - * @return Position of the selected item. - */ - public abstract int getSelectedNavigationIndex(); - - /** - * Get the number of navigation items present in the current navigation mode. - * - * @return Number of navigation items. - */ - public abstract int getNavigationItemCount(); - - /** - * Set the action bar's title. This will only be displayed if - * {@link #DISPLAY_SHOW_TITLE} is set. - * - * @param title Title to set - * - * @see #setTitle(int) - * @see #setDisplayOptions(int, int) - */ - public abstract void setTitle(CharSequence title); - - /** - * Set the action bar's title. This will only be displayed if - * {@link #DISPLAY_SHOW_TITLE} is set. - * - * @param resId Resource ID of title string to set - * - * @see #setTitle(CharSequence) - * @see #setDisplayOptions(int, int) - */ - public abstract void setTitle(int resId); - - /** - * Set the action bar's subtitle. This will only be displayed if - * {@link #DISPLAY_SHOW_TITLE} is set. Set to null to disable the - * subtitle entirely. - * - * @param subtitle Subtitle to set - * - * @see #setSubtitle(int) - * @see #setDisplayOptions(int, int) - */ - public abstract void setSubtitle(CharSequence subtitle); - - /** - * Set the action bar's subtitle. This will only be displayed if - * {@link #DISPLAY_SHOW_TITLE} is set. - * - * @param resId Resource ID of subtitle string to set - * - * @see #setSubtitle(CharSequence) - * @see #setDisplayOptions(int, int) - */ - public abstract void setSubtitle(int resId); - - /** - * Set display options. This changes all display option bits at once. To change - * a limited subset of display options, see {@link #setDisplayOptions(int, int)}. - * - * @param options A combination of the bits defined by the DISPLAY_ constants - * defined in ActionBar. - */ - public abstract void setDisplayOptions(int options); - - /** - * Set selected display options. Only the options specified by mask will be changed. - * To change all display option bits at once, see {@link #setDisplayOptions(int)}. - * - *

Example: setDisplayOptions(0, DISPLAY_SHOW_HOME) will disable the - * {@link #DISPLAY_SHOW_HOME} option. - * setDisplayOptions(DISPLAY_SHOW_HOME, DISPLAY_SHOW_HOME | DISPLAY_USE_LOGO) - * will enable {@link #DISPLAY_SHOW_HOME} and disable {@link #DISPLAY_USE_LOGO}. - * - * @param options A combination of the bits defined by the DISPLAY_ constants - * defined in ActionBar. - * @param mask A bit mask declaring which display options should be changed. - */ - public abstract void setDisplayOptions(int options, int mask); - - /** - * Set whether to display the activity logo rather than the activity icon. - * A logo is often a wider, more detailed image. - * - *

To set several display options at once, see the setDisplayOptions methods. - * - * @param useLogo true to use the activity logo, false to use the activity icon. - * - * @see #setDisplayOptions(int) - * @see #setDisplayOptions(int, int) - */ - public abstract void setDisplayUseLogoEnabled(boolean useLogo); - - /** - * Set whether to include the application home affordance in the action bar. - * Home is presented as either an activity icon or logo. - * - *

To set several display options at once, see the setDisplayOptions methods. - * - * @param showHome true to show home, false otherwise. - * - * @see #setDisplayOptions(int) - * @see #setDisplayOptions(int, int) - */ - public abstract void setDisplayShowHomeEnabled(boolean showHome); - - /** - * Set whether home should be displayed as an "up" affordance. - * Set this to true if selecting "home" returns up by a single level in your UI - * rather than back to the top level or front page. - * - *

To set several display options at once, see the setDisplayOptions methods. - * - * @param showHomeAsUp true to show the user that selecting home will return one - * level up rather than to the top level of the app. - * - * @see #setDisplayOptions(int) - * @see #setDisplayOptions(int, int) - */ - public abstract void setDisplayHomeAsUpEnabled(boolean showHomeAsUp); - - /** - * Set whether an activity title/subtitle should be displayed. - * - *

To set several display options at once, see the setDisplayOptions methods. - * - * @param showTitle true to display a title/subtitle if present. - * - * @see #setDisplayOptions(int) - * @see #setDisplayOptions(int, int) - */ - public abstract void setDisplayShowTitleEnabled(boolean showTitle); - - /** - * Set whether a custom view should be displayed, if set. - * - *

To set several display options at once, see the setDisplayOptions methods. - * - * @param showCustom true if the currently set custom view should be displayed, false otherwise. - * - * @see #setDisplayOptions(int) - * @see #setDisplayOptions(int, int) - */ - public abstract void setDisplayShowCustomEnabled(boolean showCustom); - - /** - * Set the ActionBar's background. This will be used for the primary - * action bar. - * - * @param d Background drawable - * @see #setStackedBackgroundDrawable(Drawable) - * @see #setSplitBackgroundDrawable(Drawable) - */ - public abstract void setBackgroundDrawable(Drawable d); - - /** - * Set the ActionBar's stacked background. This will appear - * in the second row/stacked bar on some devices and configurations. - * - * @param d Background drawable for the stacked row - */ - public void setStackedBackgroundDrawable(Drawable d) { } - - /** - * Set the ActionBar's split background. This will appear in - * the split action bar containing menu-provided action buttons - * on some devices and configurations. - *

You can enable split action bar with {@link android.R.attr#uiOptions} - * - * @param d Background drawable for the split bar - */ - public void setSplitBackgroundDrawable(Drawable d) { } - - /** - * @return The current custom view. - */ - public abstract View getCustomView(); - - /** - * Returns the current ActionBar title in standard mode. - * Returns null if {@link #getNavigationMode()} would not return - * {@link #NAVIGATION_MODE_STANDARD}. - * - * @return The current ActionBar title or null. - */ - public abstract CharSequence getTitle(); - - /** - * Returns the current ActionBar subtitle in standard mode. - * Returns null if {@link #getNavigationMode()} would not return - * {@link #NAVIGATION_MODE_STANDARD}. - * - * @return The current ActionBar subtitle or null. - */ - public abstract CharSequence getSubtitle(); - - /** - * Returns the current navigation mode. The result will be one of: - *

    - *
  • {@link #NAVIGATION_MODE_STANDARD}
  • - *
  • {@link #NAVIGATION_MODE_LIST}
  • - *
  • {@link #NAVIGATION_MODE_TABS}
  • - *
- * - * @return The current navigation mode. - */ - public abstract int getNavigationMode(); - - /** - * Set the current navigation mode. - * - * @param mode The new mode to set. - * @see #NAVIGATION_MODE_STANDARD - * @see #NAVIGATION_MODE_LIST - * @see #NAVIGATION_MODE_TABS - */ - public abstract void setNavigationMode(int mode); - - /** - * @return The current set of display options. - */ - public abstract int getDisplayOptions(); - - /** - * Create and return a new {@link Tab}. - * This tab will not be included in the action bar until it is added. - * - *

Very often tabs will be used to switch between {@link Fragment} - * objects. Here is a typical implementation of such tabs:

- * - * {@sample development/samples/ApiDemos/src/com/example/android/apis/app/FragmentTabs.java - * complete} - * - * @return A new Tab - * - * @see #addTab(Tab) - */ - public abstract Tab newTab(); - - /** - * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list. - * If this is the first tab to be added it will become the selected tab. - * - * @param tab Tab to add - */ - public abstract void addTab(Tab tab); - - /** - * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list. - * - * @param tab Tab to add - * @param setSelected True if the added tab should become the selected tab. - */ - public abstract void addTab(Tab tab, boolean setSelected); - - /** - * Add a tab for use in tabbed navigation mode. The tab will be inserted at - * position. If this is the first tab to be added it will become - * the selected tab. - * - * @param tab The tab to add - * @param position The new position of the tab - */ - public abstract void addTab(Tab tab, int position); - - /** - * Add a tab for use in tabbed navigation mode. The tab will be insterted at - * position. - * - * @param tab The tab to add - * @param position The new position of the tab - * @param setSelected True if the added tab should become the selected tab. - */ - public abstract void addTab(Tab tab, int position, boolean setSelected); - - /** - * Remove a tab from the action bar. If the removed tab was selected it will be deselected - * and another tab will be selected if present. - * - * @param tab The tab to remove - */ - public abstract void removeTab(Tab tab); - - /** - * Remove a tab from the action bar. If the removed tab was selected it will be deselected - * and another tab will be selected if present. - * - * @param position Position of the tab to remove - */ - public abstract void removeTabAt(int position); - - /** - * Remove all tabs from the action bar and deselect the current tab. - */ - public abstract void removeAllTabs(); - - /** - * Select the specified tab. If it is not a child of this action bar it will be added. - * - *

Note: If you want to select by index, use {@link #setSelectedNavigationItem(int)}.

- * - * @param tab Tab to select - */ - public abstract void selectTab(Tab tab); - - /** - * Returns the currently selected tab if in tabbed navigation mode and there is at least - * one tab present. - * - * @return The currently selected tab or null - */ - public abstract Tab getSelectedTab(); - - /** - * Returns the tab at the specified index. - * - * @param index Index value in the range 0-get - * @return - */ - public abstract Tab getTabAt(int index); - - /** - * Returns the number of tabs currently registered with the action bar. - * @return Tab count - */ - public abstract int getTabCount(); - - /** - * Retrieve the current height of the ActionBar. - * - * @return The ActionBar's height - */ - public abstract int getHeight(); - - /** - * Show the ActionBar if it is not currently showing. - * If the window hosting the ActionBar does not have the feature - * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application - * content to fit the new space available. - */ - public abstract void show(); - - /** - * Hide the ActionBar if it is currently showing. - * If the window hosting the ActionBar does not have the feature - * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application - * content to fit the new space available. - */ - public abstract void hide(); - - /** - * @return true if the ActionBar is showing, false otherwise. - */ - public abstract boolean isShowing(); - - /** - * Add a listener that will respond to menu visibility change events. - * - * @param listener The new listener to add - */ - public abstract void addOnMenuVisibilityListener(OnMenuVisibilityListener listener); - - /** - * Remove a menu visibility listener. This listener will no longer receive menu - * visibility change events. - * - * @param listener A listener to remove that was previously added - */ - public abstract void removeOnMenuVisibilityListener(OnMenuVisibilityListener listener); - - /** - * Enable or disable the "home" button in the corner of the action bar. (Note that this - * is the application home/up affordance on the action bar, not the systemwide home - * button.) - * - *

This defaults to true for packages targeting < API 14. For packages targeting - * API 14 or greater, the application should call this method to enable interaction - * with the home/up affordance. - * - *

Setting the {@link #DISPLAY_HOME_AS_UP} display option will automatically enable - * the home button. - * - * @param enabled true to enable the home button, false to disable the home button. - */ - public void setHomeButtonEnabled(boolean enabled) { } - - /** - * Returns a {@link Context} with an appropriate theme for creating views that - * will appear in the action bar. If you are inflating or instantiating custom views - * that will appear in an action bar, you should use the Context returned by this method. - * (This includes adapters used for list navigation mode.) - * This will ensure that views contrast properly against the action bar. - * - * @return A themed Context for creating views - */ - public Context getThemedContext() { return null; } - - /** - * Listener interface for ActionBar navigation events. - */ - public interface OnNavigationListener { - /** - * This method is called whenever a navigation item in your action bar - * is selected. - * - * @param itemPosition Position of the item clicked. - * @param itemId ID of the item clicked. - * @return True if the event was handled, false otherwise. - */ - public boolean onNavigationItemSelected(int itemPosition, long itemId); - } - - /** - * Listener for receiving events when action bar menus are shown or hidden. - */ - public interface OnMenuVisibilityListener { - /** - * Called when an action bar menu is shown or hidden. Applications may want to use - * this to tune auto-hiding behavior for the action bar or pause/resume video playback, - * gameplay, or other activity within the main content area. - * - * @param isVisible True if an action bar menu is now visible, false if no action bar - * menus are visible. - */ - public void onMenuVisibilityChanged(boolean isVisible); - } - - /** - * A tab in the action bar. - * - *

Tabs manage the hiding and showing of {@link Fragment}s. - */ - public static abstract class Tab { - /** - * An invalid position for a tab. - * - * @see #getPosition() - */ - public static final int INVALID_POSITION = -1; - - /** - * Return the current position of this tab in the action bar. - * - * @return Current position, or {@link #INVALID_POSITION} if this tab is not currently in - * the action bar. - */ - public abstract int getPosition(); - - /** - * Return the icon associated with this tab. - * - * @return The tab's icon - */ - public abstract Drawable getIcon(); - - /** - * Return the text of this tab. - * - * @return The tab's text - */ - public abstract CharSequence getText(); - - /** - * Set the icon displayed on this tab. - * - * @param icon The drawable to use as an icon - * @return The current instance for call chaining - */ - public abstract Tab setIcon(Drawable icon); - - /** - * Set the icon displayed on this tab. - * - * @param resId Resource ID referring to the drawable to use as an icon - * @return The current instance for call chaining - */ - public abstract Tab setIcon(int resId); - - /** - * Set the text displayed on this tab. Text may be truncated if there is not - * room to display the entire string. - * - * @param text The text to display - * @return The current instance for call chaining - */ - public abstract Tab setText(CharSequence text); - - /** - * Set the text displayed on this tab. Text may be truncated if there is not - * room to display the entire string. - * - * @param resId A resource ID referring to the text that should be displayed - * @return The current instance for call chaining - */ - public abstract Tab setText(int resId); - - /** - * Set a custom view to be used for this tab. This overrides values set by - * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}. - * - * @param view Custom view to be used as a tab. - * @return The current instance for call chaining - */ - public abstract Tab setCustomView(View view); - - /** - * Set a custom view to be used for this tab. This overrides values set by - * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}. - * - * @param layoutResId A layout resource to inflate and use as a custom tab view - * @return The current instance for call chaining - */ - public abstract Tab setCustomView(int layoutResId); - - /** - * Retrieve a previously set custom view for this tab. - * - * @return The custom view set by {@link #setCustomView(View)}. - */ - public abstract View getCustomView(); - - /** - * Give this Tab an arbitrary object to hold for later use. - * - * @param obj Object to store - * @return The current instance for call chaining - */ - public abstract Tab setTag(Object obj); - - /** - * @return This Tab's tag object. - */ - public abstract Object getTag(); - - /** - * Set the {@link TabListener} that will handle switching to and from this tab. - * All tabs must have a TabListener set before being added to the ActionBar. - * - * @param listener Listener to handle tab selection events - * @return The current instance for call chaining - */ - public abstract Tab setTabListener(TabListener listener); - - /** - * Select this tab. Only valid if the tab has been added to the action bar. - */ - public abstract void select(); - - /** - * Set a description of this tab's content for use in accessibility support. - * If no content description is provided the title will be used. - * - * @param resId A resource ID referring to the description text - * @return The current instance for call chaining - * @see #setContentDescription(CharSequence) - * @see #getContentDescription() - */ - public abstract Tab setContentDescription(int resId); - - /** - * Set a description of this tab's content for use in accessibility support. - * If no content description is provided the title will be used. - * - * @param contentDesc Description of this tab's content - * @return The current instance for call chaining - * @see #setContentDescription(int) - * @see #getContentDescription() - */ - public abstract Tab setContentDescription(CharSequence contentDesc); - - /** - * Gets a brief description of this tab's content for use in accessibility support. - * - * @return Description of this tab's content - * @see #setContentDescription(CharSequence) - * @see #setContentDescription(int) - */ - public abstract CharSequence getContentDescription(); - } - - /** - * Callback interface invoked when a tab is focused, unfocused, added, or removed. - */ - public interface TabListener { - /** - * Called when a tab enters the selected state. - * - * @param tab The tab that was selected - * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute - * during a tab switch. The previous tab's unselect and this tab's select will be - * executed in a single transaction. This FragmentTransaction does not support - * being added to the back stack. - */ - public void onTabSelected(Tab tab, FragmentTransaction ft); - - /** - * Called when a tab exits the selected state. - * - * @param tab The tab that was unselected - * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute - * during a tab switch. This tab's unselect and the newly selected tab's select - * will be executed in a single transaction. This FragmentTransaction does not - * support being added to the back stack. - */ - public void onTabUnselected(Tab tab, FragmentTransaction ft); - - /** - * Called when a tab that is already selected is chosen again by the user. - * Some applications may use this action to return to the top level of a category. - * - * @param tab The tab that was reselected. - * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute - * once this method returns. This FragmentTransaction does not support - * being added to the back stack. - */ - public void onTabReselected(Tab tab, FragmentTransaction ft); - } - - /** - * Per-child layout information associated with action bar custom views. - * - * @attr ref android.R.styleable#ActionBar_LayoutParams_layout_gravity - */ - public static class LayoutParams extends MarginLayoutParams { - /** - * Gravity for the view associated with these LayoutParams. - * - * @see android.view.Gravity - */ - @ViewDebug.ExportedProperty(mapping = { - @ViewDebug.IntToString(from = -1, to = "NONE"), - @ViewDebug.IntToString(from = Gravity.NO_GRAVITY, to = "NONE"), - @ViewDebug.IntToString(from = Gravity.TOP, to = "TOP"), - @ViewDebug.IntToString(from = Gravity.BOTTOM, to = "BOTTOM"), - @ViewDebug.IntToString(from = Gravity.LEFT, to = "LEFT"), - @ViewDebug.IntToString(from = Gravity.RIGHT, to = "RIGHT"), - @ViewDebug.IntToString(from = Gravity.CENTER_VERTICAL, to = "CENTER_VERTICAL"), - @ViewDebug.IntToString(from = Gravity.FILL_VERTICAL, to = "FILL_VERTICAL"), - @ViewDebug.IntToString(from = Gravity.CENTER_HORIZONTAL, to = "CENTER_HORIZONTAL"), - @ViewDebug.IntToString(from = Gravity.FILL_HORIZONTAL, to = "FILL_HORIZONTAL"), - @ViewDebug.IntToString(from = Gravity.CENTER, to = "CENTER"), - @ViewDebug.IntToString(from = Gravity.FILL, to = "FILL") - }) - public int gravity = -1; - - public LayoutParams(Context c, AttributeSet attrs) { - super(c, attrs); - } - - public LayoutParams(int width, int height) { - super(width, height); - this.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT; - } - - public LayoutParams(int width, int height, int gravity) { - super(width, height); - this.gravity = gravity; - } - - public LayoutParams(int gravity) { - this(WRAP_CONTENT, FILL_PARENT, gravity); - } - - public LayoutParams(LayoutParams source) { - super(source); - - this.gravity = source.gravity; - } - - public LayoutParams(ViewGroup.LayoutParams source) { - super(source); - } - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockActivity.java b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockActivity.java deleted file mode 100644 index 9cb57e95a..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockActivity.java +++ /dev/null @@ -1,259 +0,0 @@ -package com.actionbarsherlock.app; - -import android.app.Activity; -import android.content.res.Configuration; -import android.os.Bundle; -import android.view.KeyEvent; -import android.view.View; -import android.view.Window; -import android.view.ViewGroup.LayoutParams; -import com.actionbarsherlock.ActionBarSherlock; -import com.actionbarsherlock.ActionBarSherlock.OnActionModeFinishedListener; -import com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListener; -import com.actionbarsherlock.ActionBarSherlock.OnCreatePanelMenuListener; -import com.actionbarsherlock.ActionBarSherlock.OnMenuItemSelectedListener; -import com.actionbarsherlock.ActionBarSherlock.OnPreparePanelListener; -import com.actionbarsherlock.view.ActionMode; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuInflater; -import com.actionbarsherlock.view.MenuItem; - -public abstract class SherlockActivity extends Activity implements OnCreatePanelMenuListener, OnPreparePanelListener, OnMenuItemSelectedListener, OnActionModeStartedListener, OnActionModeFinishedListener { - private ActionBarSherlock mSherlock; - - protected final ActionBarSherlock getSherlock() { - if (mSherlock == null) { - mSherlock = ActionBarSherlock.wrap(this, ActionBarSherlock.FLAG_DELEGATE); - } - return mSherlock; - } - - - /////////////////////////////////////////////////////////////////////////// - // Action bar and mode - /////////////////////////////////////////////////////////////////////////// - - public ActionBar getSupportActionBar() { - return getSherlock().getActionBar(); - } - - public ActionMode startActionMode(ActionMode.Callback callback) { - return getSherlock().startActionMode(callback); - } - - @Override - public void onActionModeStarted(ActionMode mode) {} - - @Override - public void onActionModeFinished(ActionMode mode) {} - - - /////////////////////////////////////////////////////////////////////////// - // General lifecycle/callback dispatching - /////////////////////////////////////////////////////////////////////////// - - @Override - public void onConfigurationChanged(Configuration newConfig) { - super.onConfigurationChanged(newConfig); - getSherlock().dispatchConfigurationChanged(newConfig); - } - - @Override - protected void onPostResume() { - super.onPostResume(); - getSherlock().dispatchPostResume(); - } - - @Override - protected void onPause() { - getSherlock().dispatchPause(); - super.onPause(); - } - - @Override - protected void onStop() { - getSherlock().dispatchStop(); - super.onStop(); - } - - @Override - protected void onDestroy() { - getSherlock().dispatchDestroy(); - super.onDestroy(); - } - - @Override - protected void onPostCreate(Bundle savedInstanceState) { - getSherlock().dispatchPostCreate(savedInstanceState); - super.onPostCreate(savedInstanceState); - } - - @Override - protected void onTitleChanged(CharSequence title, int color) { - getSherlock().dispatchTitleChanged(title, color); - super.onTitleChanged(title, color); - } - - @Override - public final boolean onMenuOpened(int featureId, android.view.Menu menu) { - if (getSherlock().dispatchMenuOpened(featureId, menu)) { - return true; - } - return super.onMenuOpened(featureId, menu); - } - - @Override - public void onPanelClosed(int featureId, android.view.Menu menu) { - getSherlock().dispatchPanelClosed(featureId, menu); - super.onPanelClosed(featureId, menu); - } - - @Override - public boolean dispatchKeyEvent(KeyEvent event) { - if (getSherlock().dispatchKeyEvent(event)) { - return true; - } - return super.dispatchKeyEvent(event); - } - - - /////////////////////////////////////////////////////////////////////////// - // Native menu handling - /////////////////////////////////////////////////////////////////////////// - - public MenuInflater getSupportMenuInflater() { - return getSherlock().getMenuInflater(); - } - - public void invalidateOptionsMenu() { - getSherlock().dispatchInvalidateOptionsMenu(); - } - - public void supportInvalidateOptionsMenu() { - invalidateOptionsMenu(); - } - - @Override - public final boolean onCreateOptionsMenu(android.view.Menu menu) { - return getSherlock().dispatchCreateOptionsMenu(menu); - } - - @Override - public final boolean onPrepareOptionsMenu(android.view.Menu menu) { - return getSherlock().dispatchPrepareOptionsMenu(menu); - } - - @Override - public final boolean onOptionsItemSelected(android.view.MenuItem item) { - return getSherlock().dispatchOptionsItemSelected(item); - } - - @Override - public void openOptionsMenu() { - if (!getSherlock().dispatchOpenOptionsMenu()) { - super.openOptionsMenu(); - } - } - - @Override - public void closeOptionsMenu() { - if (!getSherlock().dispatchCloseOptionsMenu()) { - super.closeOptionsMenu(); - } - } - - - /////////////////////////////////////////////////////////////////////////// - // Sherlock menu handling - /////////////////////////////////////////////////////////////////////////// - - @Override - public boolean onCreatePanelMenu(int featureId, Menu menu) { - if (featureId == Window.FEATURE_OPTIONS_PANEL) { - return onCreateOptionsMenu(menu); - } - return false; - } - - public boolean onCreateOptionsMenu(Menu menu) { - return true; - } - - @Override - public boolean onPreparePanel(int featureId, View view, Menu menu) { - if (featureId == Window.FEATURE_OPTIONS_PANEL) { - return onPrepareOptionsMenu(menu); - } - return false; - } - - public boolean onPrepareOptionsMenu(Menu menu) { - return true; - } - - @Override - public boolean onMenuItemSelected(int featureId, MenuItem item) { - if (featureId == Window.FEATURE_OPTIONS_PANEL) { - return onOptionsItemSelected(item); - } - return false; - } - - public boolean onOptionsItemSelected(MenuItem item) { - return false; - } - - - /////////////////////////////////////////////////////////////////////////// - // Content - /////////////////////////////////////////////////////////////////////////// - - @Override - public void addContentView(View view, LayoutParams params) { - getSherlock().addContentView(view, params); - } - - @Override - public void setContentView(int layoutResId) { - getSherlock().setContentView(layoutResId); - } - - @Override - public void setContentView(View view, LayoutParams params) { - getSherlock().setContentView(view, params); - } - - @Override - public void setContentView(View view) { - getSherlock().setContentView(view); - } - - public void requestWindowFeature(long featureId) { - getSherlock().requestFeature((int)featureId); - } - - - /////////////////////////////////////////////////////////////////////////// - // Progress Indication - /////////////////////////////////////////////////////////////////////////// - - public void setSupportProgress(int progress) { - getSherlock().setProgress(progress); - } - - public void setSupportProgressBarIndeterminate(boolean indeterminate) { - getSherlock().setProgressBarIndeterminate(indeterminate); - } - - public void setSupportProgressBarIndeterminateVisibility(boolean visible) { - getSherlock().setProgressBarIndeterminateVisibility(visible); - } - - public void setSupportProgressBarVisibility(boolean visible) { - getSherlock().setProgressBarVisibility(visible); - } - - public void setSupportSecondaryProgress(int secondaryProgress) { - getSherlock().setSecondaryProgress(secondaryProgress); - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockDialogFragment.java b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockDialogFragment.java deleted file mode 100644 index a7c856bf0..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockDialogFragment.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.actionbarsherlock.app; - -import android.app.Activity; -import android.support.v4.app.DialogFragment; -import com.actionbarsherlock.internal.view.menu.MenuItemWrapper; -import com.actionbarsherlock.internal.view.menu.MenuWrapper; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuInflater; -import com.actionbarsherlock.view.MenuItem; - -import static com.actionbarsherlock.app.SherlockFragmentActivity.OnCreateOptionsMenuListener; -import static com.actionbarsherlock.app.SherlockFragmentActivity.OnOptionsItemSelectedListener; -import static com.actionbarsherlock.app.SherlockFragmentActivity.OnPrepareOptionsMenuListener; - -public class SherlockDialogFragment extends DialogFragment implements OnCreateOptionsMenuListener, OnPrepareOptionsMenuListener, OnOptionsItemSelectedListener { - private SherlockFragmentActivity mActivity; - - public SherlockFragmentActivity getSherlockActivity() { - return mActivity; - } - - @Override - public void onAttach(Activity activity) { - if (!(activity instanceof SherlockFragmentActivity)) { - throw new IllegalStateException(getClass().getSimpleName() + " must be attached to a SherlockFragmentActivity."); - } - mActivity = (SherlockFragmentActivity)activity; - - super.onAttach(activity); - } - - @Override - public void onDetach() { - mActivity = null; - super.onDetach(); - } - - @Override - public final void onCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater) { - onCreateOptionsMenu(new MenuWrapper(menu), mActivity.getSupportMenuInflater()); - } - - @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { - //Nothing to see here. - } - - @Override - public final void onPrepareOptionsMenu(android.view.Menu menu) { - onPrepareOptionsMenu(new MenuWrapper(menu)); - } - - @Override - public void onPrepareOptionsMenu(Menu menu) { - //Nothing to see here. - } - - @Override - public final boolean onOptionsItemSelected(android.view.MenuItem item) { - return onOptionsItemSelected(new MenuItemWrapper(item)); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - //Nothing to see here. - return false; - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockExpandableListActivity.java b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockExpandableListActivity.java deleted file mode 100644 index 078f9b0ca..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockExpandableListActivity.java +++ /dev/null @@ -1,259 +0,0 @@ -package com.actionbarsherlock.app; - -import android.app.ExpandableListActivity; -import android.content.res.Configuration; -import android.os.Bundle; -import android.view.KeyEvent; -import android.view.View; -import android.view.ViewGroup.LayoutParams; -import android.view.Window; -import com.actionbarsherlock.ActionBarSherlock; -import com.actionbarsherlock.ActionBarSherlock.OnActionModeFinishedListener; -import com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListener; -import com.actionbarsherlock.ActionBarSherlock.OnCreatePanelMenuListener; -import com.actionbarsherlock.ActionBarSherlock.OnMenuItemSelectedListener; -import com.actionbarsherlock.ActionBarSherlock.OnPreparePanelListener; -import com.actionbarsherlock.view.ActionMode; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuInflater; -import com.actionbarsherlock.view.MenuItem; - -public abstract class SherlockExpandableListActivity extends ExpandableListActivity implements OnCreatePanelMenuListener, OnPreparePanelListener, OnMenuItemSelectedListener, OnActionModeStartedListener, OnActionModeFinishedListener { - private ActionBarSherlock mSherlock; - - protected final ActionBarSherlock getSherlock() { - if (mSherlock == null) { - mSherlock = ActionBarSherlock.wrap(this, ActionBarSherlock.FLAG_DELEGATE); - } - return mSherlock; - } - - - /////////////////////////////////////////////////////////////////////////// - // Action bar and mode - /////////////////////////////////////////////////////////////////////////// - - public ActionBar getSupportActionBar() { - return getSherlock().getActionBar(); - } - - public ActionMode startActionMode(ActionMode.Callback callback) { - return getSherlock().startActionMode(callback); - } - - @Override - public void onActionModeStarted(ActionMode mode) {} - - @Override - public void onActionModeFinished(ActionMode mode) {} - - - /////////////////////////////////////////////////////////////////////////// - // General lifecycle/callback dispatching - /////////////////////////////////////////////////////////////////////////// - - @Override - public void onConfigurationChanged(Configuration newConfig) { - super.onConfigurationChanged(newConfig); - getSherlock().dispatchConfigurationChanged(newConfig); - } - - @Override - protected void onPostResume() { - super.onPostResume(); - getSherlock().dispatchPostResume(); - } - - @Override - protected void onPause() { - getSherlock().dispatchPause(); - super.onPause(); - } - - @Override - protected void onStop() { - getSherlock().dispatchStop(); - super.onStop(); - } - - @Override - protected void onDestroy() { - getSherlock().dispatchDestroy(); - super.onDestroy(); - } - - @Override - protected void onPostCreate(Bundle savedInstanceState) { - getSherlock().dispatchPostCreate(savedInstanceState); - super.onPostCreate(savedInstanceState); - } - - @Override - protected void onTitleChanged(CharSequence title, int color) { - getSherlock().dispatchTitleChanged(title, color); - super.onTitleChanged(title, color); - } - - @Override - public final boolean onMenuOpened(int featureId, android.view.Menu menu) { - if (getSherlock().dispatchMenuOpened(featureId, menu)) { - return true; - } - return super.onMenuOpened(featureId, menu); - } - - @Override - public void onPanelClosed(int featureId, android.view.Menu menu) { - getSherlock().dispatchPanelClosed(featureId, menu); - super.onPanelClosed(featureId, menu); - } - - @Override - public boolean dispatchKeyEvent(KeyEvent event) { - if (getSherlock().dispatchKeyEvent(event)) { - return true; - } - return super.dispatchKeyEvent(event); - } - - - /////////////////////////////////////////////////////////////////////////// - // Native menu handling - /////////////////////////////////////////////////////////////////////////// - - public MenuInflater getSupportMenuInflater() { - return getSherlock().getMenuInflater(); - } - - public void invalidateOptionsMenu() { - getSherlock().dispatchInvalidateOptionsMenu(); - } - - public void supportInvalidateOptionsMenu() { - invalidateOptionsMenu(); - } - - @Override - public final boolean onCreateOptionsMenu(android.view.Menu menu) { - return getSherlock().dispatchCreateOptionsMenu(menu); - } - - @Override - public final boolean onPrepareOptionsMenu(android.view.Menu menu) { - return getSherlock().dispatchPrepareOptionsMenu(menu); - } - - @Override - public final boolean onOptionsItemSelected(android.view.MenuItem item) { - return getSherlock().dispatchOptionsItemSelected(item); - } - - @Override - public void openOptionsMenu() { - if (!getSherlock().dispatchOpenOptionsMenu()) { - super.openOptionsMenu(); - } - } - - @Override - public void closeOptionsMenu() { - if (!getSherlock().dispatchCloseOptionsMenu()) { - super.closeOptionsMenu(); - } - } - - - /////////////////////////////////////////////////////////////////////////// - // Sherlock menu handling - /////////////////////////////////////////////////////////////////////////// - - @Override - public boolean onCreatePanelMenu(int featureId, Menu menu) { - if (featureId == Window.FEATURE_OPTIONS_PANEL) { - return onCreateOptionsMenu(menu); - } - return false; - } - - public boolean onCreateOptionsMenu(Menu menu) { - return true; - } - - @Override - public boolean onPreparePanel(int featureId, View view, Menu menu) { - if (featureId == Window.FEATURE_OPTIONS_PANEL) { - return onPrepareOptionsMenu(menu); - } - return false; - } - - public boolean onPrepareOptionsMenu(Menu menu) { - return true; - } - - @Override - public boolean onMenuItemSelected(int featureId, MenuItem item) { - if (featureId == Window.FEATURE_OPTIONS_PANEL) { - return onOptionsItemSelected(item); - } - return false; - } - - public boolean onOptionsItemSelected(MenuItem item) { - return false; - } - - - /////////////////////////////////////////////////////////////////////////// - // Content - /////////////////////////////////////////////////////////////////////////// - - @Override - public void addContentView(View view, LayoutParams params) { - getSherlock().addContentView(view, params); - } - - @Override - public void setContentView(int layoutResId) { - getSherlock().setContentView(layoutResId); - } - - @Override - public void setContentView(View view, LayoutParams params) { - getSherlock().setContentView(view, params); - } - - @Override - public void setContentView(View view) { - getSherlock().setContentView(view); - } - - public void requestWindowFeature(long featureId) { - getSherlock().requestFeature((int)featureId); - } - - - /////////////////////////////////////////////////////////////////////////// - // Progress Indication - /////////////////////////////////////////////////////////////////////////// - - public void setSupportProgress(int progress) { - getSherlock().setProgress(progress); - } - - public void setSupportProgressBarIndeterminate(boolean indeterminate) { - getSherlock().setProgressBarIndeterminate(indeterminate); - } - - public void setSupportProgressBarIndeterminateVisibility(boolean visible) { - getSherlock().setProgressBarIndeterminateVisibility(visible); - } - - public void setSupportProgressBarVisibility(boolean visible) { - getSherlock().setProgressBarVisibility(visible); - } - - public void setSupportSecondaryProgress(int secondaryProgress) { - getSherlock().setSecondaryProgress(secondaryProgress); - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockFragment.java b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockFragment.java deleted file mode 100644 index 0f24e9c85..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockFragment.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.actionbarsherlock.app; - -import android.app.Activity; -import android.support.v4.app.Fragment; -import com.actionbarsherlock.internal.view.menu.MenuItemWrapper; -import com.actionbarsherlock.internal.view.menu.MenuWrapper; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuInflater; -import com.actionbarsherlock.view.MenuItem; - -import static com.actionbarsherlock.app.SherlockFragmentActivity.OnCreateOptionsMenuListener; -import static com.actionbarsherlock.app.SherlockFragmentActivity.OnOptionsItemSelectedListener; -import static com.actionbarsherlock.app.SherlockFragmentActivity.OnPrepareOptionsMenuListener; - -public class SherlockFragment extends Fragment implements OnCreateOptionsMenuListener, OnPrepareOptionsMenuListener, OnOptionsItemSelectedListener { - private SherlockFragmentActivity mActivity; - - public SherlockFragmentActivity getSherlockActivity() { - return mActivity; - } - - @Override - public void onAttach(Activity activity) { - if (!(activity instanceof SherlockFragmentActivity)) { - throw new IllegalStateException(getClass().getSimpleName() + " must be attached to a SherlockFragmentActivity."); - } - mActivity = (SherlockFragmentActivity)activity; - - super.onAttach(activity); - } - - @Override - public void onDetach() { - mActivity = null; - super.onDetach(); - } - - @Override - public final void onCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater) { - onCreateOptionsMenu(new MenuWrapper(menu), mActivity.getSupportMenuInflater()); - } - - @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { - //Nothing to see here. - } - - @Override - public final void onPrepareOptionsMenu(android.view.Menu menu) { - onPrepareOptionsMenu(new MenuWrapper(menu)); - } - - @Override - public void onPrepareOptionsMenu(Menu menu) { - //Nothing to see here. - } - - @Override - public final boolean onOptionsItemSelected(android.view.MenuItem item) { - return onOptionsItemSelected(new MenuItemWrapper(item)); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - //Nothing to see here. - return false; - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockFragmentActivity.java b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockFragmentActivity.java deleted file mode 100644 index 5cd13ba7c..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockFragmentActivity.java +++ /dev/null @@ -1,292 +0,0 @@ -package com.actionbarsherlock.app; - -import android.content.res.Configuration; -import android.os.Bundle; -import android.support.v4.app._ActionBarSherlockTrojanHorse; -import android.util.Log; -import android.view.KeyEvent; -import android.view.View; -import android.view.ViewGroup.LayoutParams; -import android.view.Window; -import com.actionbarsherlock.ActionBarSherlock; -import com.actionbarsherlock.view.ActionMode; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuInflater; -import com.actionbarsherlock.view.MenuItem; - -import static com.actionbarsherlock.ActionBarSherlock.OnActionModeFinishedListener; -import static com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListener; - -/** @see {@link _ActionBarSherlockTrojanHorse} */ -public class SherlockFragmentActivity extends _ActionBarSherlockTrojanHorse implements OnActionModeStartedListener, OnActionModeFinishedListener { - private static final boolean DEBUG = false; - private static final String TAG = "SherlockFragmentActivity"; - - private ActionBarSherlock mSherlock; - private boolean mIgnoreNativeCreate = false; - private boolean mIgnoreNativePrepare = false; - private boolean mIgnoreNativeSelected = false; - - protected final ActionBarSherlock getSherlock() { - if (mSherlock == null) { - mSherlock = ActionBarSherlock.wrap(this, ActionBarSherlock.FLAG_DELEGATE); - } - return mSherlock; - } - - - /////////////////////////////////////////////////////////////////////////// - // Action bar and mode - /////////////////////////////////////////////////////////////////////////// - - public ActionBar getSupportActionBar() { - return getSherlock().getActionBar(); - } - - public ActionMode startActionMode(ActionMode.Callback callback) { - return getSherlock().startActionMode(callback); - } - - @Override - public void onActionModeStarted(ActionMode mode) {} - - @Override - public void onActionModeFinished(ActionMode mode) {} - - - /////////////////////////////////////////////////////////////////////////// - // General lifecycle/callback dispatching - /////////////////////////////////////////////////////////////////////////// - - @Override - public void onConfigurationChanged(Configuration newConfig) { - super.onConfigurationChanged(newConfig); - getSherlock().dispatchConfigurationChanged(newConfig); - } - - @Override - protected void onPostResume() { - super.onPostResume(); - getSherlock().dispatchPostResume(); - } - - @Override - protected void onPause() { - getSherlock().dispatchPause(); - super.onPause(); - } - - @Override - protected void onStop() { - getSherlock().dispatchStop(); - super.onStop(); - } - - @Override - protected void onDestroy() { - getSherlock().dispatchDestroy(); - super.onDestroy(); - } - - @Override - protected void onPostCreate(Bundle savedInstanceState) { - getSherlock().dispatchPostCreate(savedInstanceState); - super.onPostCreate(savedInstanceState); - } - - @Override - protected void onTitleChanged(CharSequence title, int color) { - getSherlock().dispatchTitleChanged(title, color); - super.onTitleChanged(title, color); - } - - @Override - public final boolean onMenuOpened(int featureId, android.view.Menu menu) { - if (getSherlock().dispatchMenuOpened(featureId, menu)) { - return true; - } - return super.onMenuOpened(featureId, menu); - } - - @Override - public void onPanelClosed(int featureId, android.view.Menu menu) { - getSherlock().dispatchPanelClosed(featureId, menu); - super.onPanelClosed(featureId, menu); - } - - @Override - public boolean dispatchKeyEvent(KeyEvent event) { - if (getSherlock().dispatchKeyEvent(event)) { - return true; - } - return super.dispatchKeyEvent(event); - } - - - /////////////////////////////////////////////////////////////////////////// - // Native menu handling - /////////////////////////////////////////////////////////////////////////// - - public MenuInflater getSupportMenuInflater() { - if (DEBUG) Log.d(TAG, "[getSupportMenuInflater]"); - - return getSherlock().getMenuInflater(); - } - - public void invalidateOptionsMenu() { - if (DEBUG) Log.d(TAG, "[invalidateOptionsMenu]"); - - getSherlock().dispatchInvalidateOptionsMenu(); - } - - public void supportInvalidateOptionsMenu() { - if (DEBUG) Log.d(TAG, "[supportInvalidateOptionsMenu]"); - - invalidateOptionsMenu(); - } - - @Override - public final boolean onCreatePanelMenu(int featureId, android.view.Menu menu) { - if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] featureId: " + featureId + ", menu: " + menu); - - if (featureId == Window.FEATURE_OPTIONS_PANEL && !mIgnoreNativeCreate) { - mIgnoreNativeCreate = true; - boolean result = getSherlock().dispatchCreateOptionsMenu(menu); - mIgnoreNativeCreate = false; - - if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] returning " + result); - return result; - } - return super.onCreatePanelMenu(featureId, menu); - } - - @Override - public final boolean onCreateOptionsMenu(android.view.Menu menu) { - return true; - } - - @Override - public final boolean onPreparePanel(int featureId, View view, android.view.Menu menu) { - if (DEBUG) Log.d(TAG, "[onPreparePanel] featureId: " + featureId + ", view: " + view + ", menu: " + menu); - - if (featureId == Window.FEATURE_OPTIONS_PANEL && !mIgnoreNativePrepare) { - mIgnoreNativePrepare = true; - boolean result = getSherlock().dispatchPrepareOptionsMenu(menu); - mIgnoreNativePrepare = false; - - if (DEBUG) Log.d(TAG, "[onPreparePanel] returning " + result); - return result; - } - return super.onPreparePanel(featureId, view, menu); - } - - @Override - public final boolean onPrepareOptionsMenu(android.view.Menu menu) { - return true; - } - - @Override - public final boolean onMenuItemSelected(int featureId, android.view.MenuItem item) { - if (DEBUG) Log.d(TAG, "[onMenuItemSelected] featureId: " + featureId + ", item: " + item); - - if (featureId == Window.FEATURE_OPTIONS_PANEL && !mIgnoreNativeSelected) { - mIgnoreNativeSelected = true; - boolean result = getSherlock().dispatchOptionsItemSelected(item); - mIgnoreNativeSelected = false; - - if (DEBUG) Log.d(TAG, "[onMenuItemSelected] returning " + result); - return result; - } - return super.onMenuItemSelected(featureId, item); - } - - @Override - public final boolean onOptionsItemSelected(android.view.MenuItem item) { - return false; - } - - @Override - public void openOptionsMenu() { - if (!getSherlock().dispatchOpenOptionsMenu()) { - super.openOptionsMenu(); - } - } - - @Override - public void closeOptionsMenu() { - if (!getSherlock().dispatchCloseOptionsMenu()) { - super.closeOptionsMenu(); - } - } - - - /////////////////////////////////////////////////////////////////////////// - // Sherlock menu handling - /////////////////////////////////////////////////////////////////////////// - - public boolean onCreateOptionsMenu(Menu menu) { - return true; - } - - public boolean onPrepareOptionsMenu(Menu menu) { - return true; - } - - public boolean onOptionsItemSelected(MenuItem item) { - return false; - } - - - /////////////////////////////////////////////////////////////////////////// - // Content - /////////////////////////////////////////////////////////////////////////// - - @Override - public void addContentView(View view, LayoutParams params) { - getSherlock().addContentView(view, params); - } - - @Override - public void setContentView(int layoutResId) { - getSherlock().setContentView(layoutResId); - } - - @Override - public void setContentView(View view, LayoutParams params) { - getSherlock().setContentView(view, params); - } - - @Override - public void setContentView(View view) { - getSherlock().setContentView(view); - } - - public void requestWindowFeature(long featureId) { - getSherlock().requestFeature((int)featureId); - } - - - /////////////////////////////////////////////////////////////////////////// - // Progress Indication - /////////////////////////////////////////////////////////////////////////// - - public void setSupportProgress(int progress) { - getSherlock().setProgress(progress); - } - - public void setSupportProgressBarIndeterminate(boolean indeterminate) { - getSherlock().setProgressBarIndeterminate(indeterminate); - } - - public void setSupportProgressBarIndeterminateVisibility(boolean visible) { - getSherlock().setProgressBarIndeterminateVisibility(visible); - } - - public void setSupportProgressBarVisibility(boolean visible) { - getSherlock().setProgressBarVisibility(visible); - } - - public void setSupportSecondaryProgress(int secondaryProgress) { - getSherlock().setSecondaryProgress(secondaryProgress); - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockListActivity.java b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockListActivity.java deleted file mode 100644 index 00c00fee5..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockListActivity.java +++ /dev/null @@ -1,259 +0,0 @@ -package com.actionbarsherlock.app; - -import android.app.ListActivity; -import android.content.res.Configuration; -import android.os.Bundle; -import android.view.KeyEvent; -import android.view.View; -import android.view.Window; -import android.view.ViewGroup.LayoutParams; -import com.actionbarsherlock.ActionBarSherlock; -import com.actionbarsherlock.ActionBarSherlock.OnActionModeFinishedListener; -import com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListener; -import com.actionbarsherlock.ActionBarSherlock.OnCreatePanelMenuListener; -import com.actionbarsherlock.ActionBarSherlock.OnMenuItemSelectedListener; -import com.actionbarsherlock.ActionBarSherlock.OnPreparePanelListener; -import com.actionbarsherlock.view.ActionMode; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuInflater; -import com.actionbarsherlock.view.MenuItem; - -public abstract class SherlockListActivity extends ListActivity implements OnCreatePanelMenuListener, OnPreparePanelListener, OnMenuItemSelectedListener, OnActionModeStartedListener, OnActionModeFinishedListener { - private ActionBarSherlock mSherlock; - - protected final ActionBarSherlock getSherlock() { - if (mSherlock == null) { - mSherlock = ActionBarSherlock.wrap(this, ActionBarSherlock.FLAG_DELEGATE); - } - return mSherlock; - } - - - /////////////////////////////////////////////////////////////////////////// - // Action bar and mode - /////////////////////////////////////////////////////////////////////////// - - public ActionBar getSupportActionBar() { - return getSherlock().getActionBar(); - } - - public ActionMode startActionMode(ActionMode.Callback callback) { - return getSherlock().startActionMode(callback); - } - - @Override - public void onActionModeStarted(ActionMode mode) {} - - @Override - public void onActionModeFinished(ActionMode mode) {} - - - /////////////////////////////////////////////////////////////////////////// - // General lifecycle/callback dispatching - /////////////////////////////////////////////////////////////////////////// - - @Override - public void onConfigurationChanged(Configuration newConfig) { - super.onConfigurationChanged(newConfig); - getSherlock().dispatchConfigurationChanged(newConfig); - } - - @Override - protected void onPostResume() { - super.onPostResume(); - getSherlock().dispatchPostResume(); - } - - @Override - protected void onPause() { - getSherlock().dispatchPause(); - super.onPause(); - } - - @Override - protected void onStop() { - getSherlock().dispatchStop(); - super.onStop(); - } - - @Override - protected void onDestroy() { - getSherlock().dispatchDestroy(); - super.onDestroy(); - } - - @Override - protected void onPostCreate(Bundle savedInstanceState) { - getSherlock().dispatchPostCreate(savedInstanceState); - super.onPostCreate(savedInstanceState); - } - - @Override - protected void onTitleChanged(CharSequence title, int color) { - getSherlock().dispatchTitleChanged(title, color); - super.onTitleChanged(title, color); - } - - @Override - public final boolean onMenuOpened(int featureId, android.view.Menu menu) { - if (getSherlock().dispatchMenuOpened(featureId, menu)) { - return true; - } - return super.onMenuOpened(featureId, menu); - } - - @Override - public void onPanelClosed(int featureId, android.view.Menu menu) { - getSherlock().dispatchPanelClosed(featureId, menu); - super.onPanelClosed(featureId, menu); - } - - @Override - public boolean dispatchKeyEvent(KeyEvent event) { - if (getSherlock().dispatchKeyEvent(event)) { - return true; - } - return super.dispatchKeyEvent(event); - } - - - /////////////////////////////////////////////////////////////////////////// - // Native menu handling - /////////////////////////////////////////////////////////////////////////// - - public MenuInflater getSupportMenuInflater() { - return getSherlock().getMenuInflater(); - } - - public void invalidateOptionsMenu() { - getSherlock().dispatchInvalidateOptionsMenu(); - } - - public void supportInvalidateOptionsMenu() { - invalidateOptionsMenu(); - } - - @Override - public final boolean onCreateOptionsMenu(android.view.Menu menu) { - return getSherlock().dispatchCreateOptionsMenu(menu); - } - - @Override - public final boolean onPrepareOptionsMenu(android.view.Menu menu) { - return getSherlock().dispatchPrepareOptionsMenu(menu); - } - - @Override - public final boolean onOptionsItemSelected(android.view.MenuItem item) { - return getSherlock().dispatchOptionsItemSelected(item); - } - - @Override - public void openOptionsMenu() { - if (!getSherlock().dispatchOpenOptionsMenu()) { - super.openOptionsMenu(); - } - } - - @Override - public void closeOptionsMenu() { - if (!getSherlock().dispatchCloseOptionsMenu()) { - super.closeOptionsMenu(); - } - } - - - /////////////////////////////////////////////////////////////////////////// - // Sherlock menu handling - /////////////////////////////////////////////////////////////////////////// - - @Override - public boolean onCreatePanelMenu(int featureId, Menu menu) { - if (featureId == Window.FEATURE_OPTIONS_PANEL) { - return onCreateOptionsMenu(menu); - } - return false; - } - - public boolean onCreateOptionsMenu(Menu menu) { - return true; - } - - @Override - public boolean onPreparePanel(int featureId, View view, Menu menu) { - if (featureId == Window.FEATURE_OPTIONS_PANEL) { - return onPrepareOptionsMenu(menu); - } - return false; - } - - public boolean onPrepareOptionsMenu(Menu menu) { - return true; - } - - @Override - public boolean onMenuItemSelected(int featureId, MenuItem item) { - if (featureId == Window.FEATURE_OPTIONS_PANEL) { - return onOptionsItemSelected(item); - } - return false; - } - - public boolean onOptionsItemSelected(MenuItem item) { - return false; - } - - - /////////////////////////////////////////////////////////////////////////// - // Content - /////////////////////////////////////////////////////////////////////////// - - @Override - public void addContentView(View view, LayoutParams params) { - getSherlock().addContentView(view, params); - } - - @Override - public void setContentView(int layoutResId) { - getSherlock().setContentView(layoutResId); - } - - @Override - public void setContentView(View view, LayoutParams params) { - getSherlock().setContentView(view, params); - } - - @Override - public void setContentView(View view) { - getSherlock().setContentView(view); - } - - public void requestWindowFeature(long featureId) { - getSherlock().requestFeature((int)featureId); - } - - - /////////////////////////////////////////////////////////////////////////// - // Progress Indication - /////////////////////////////////////////////////////////////////////////// - - public void setSupportProgress(int progress) { - getSherlock().setProgress(progress); - } - - public void setSupportProgressBarIndeterminate(boolean indeterminate) { - getSherlock().setProgressBarIndeterminate(indeterminate); - } - - public void setSupportProgressBarIndeterminateVisibility(boolean visible) { - getSherlock().setProgressBarIndeterminateVisibility(visible); - } - - public void setSupportProgressBarVisibility(boolean visible) { - getSherlock().setProgressBarVisibility(visible); - } - - public void setSupportSecondaryProgress(int secondaryProgress) { - getSherlock().setSecondaryProgress(secondaryProgress); - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockListFragment.java b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockListFragment.java deleted file mode 100644 index 13ca3c49f..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockListFragment.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.actionbarsherlock.app; - -import android.app.Activity; -import android.support.v4.app.ListFragment; -import com.actionbarsherlock.internal.view.menu.MenuItemWrapper; -import com.actionbarsherlock.internal.view.menu.MenuWrapper; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuInflater; -import com.actionbarsherlock.view.MenuItem; - -import static com.actionbarsherlock.app.SherlockFragmentActivity.OnCreateOptionsMenuListener; -import static com.actionbarsherlock.app.SherlockFragmentActivity.OnOptionsItemSelectedListener; -import static com.actionbarsherlock.app.SherlockFragmentActivity.OnPrepareOptionsMenuListener; - -public class SherlockListFragment extends ListFragment implements OnCreateOptionsMenuListener, OnPrepareOptionsMenuListener, OnOptionsItemSelectedListener { - private SherlockFragmentActivity mActivity; - - public SherlockFragmentActivity getSherlockActivity() { - return mActivity; - } - - @Override - public void onAttach(Activity activity) { - if (!(activity instanceof SherlockFragmentActivity)) { - throw new IllegalStateException(getClass().getSimpleName() + " must be attached to a SherlockFragmentActivity."); - } - mActivity = (SherlockFragmentActivity)activity; - - super.onAttach(activity); - } - - @Override - public void onDetach() { - mActivity = null; - super.onDetach(); - } - - @Override - public final void onCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater) { - onCreateOptionsMenu(new MenuWrapper(menu), mActivity.getSupportMenuInflater()); - } - - @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { - //Nothing to see here. - } - - @Override - public final void onPrepareOptionsMenu(android.view.Menu menu) { - onPrepareOptionsMenu(new MenuWrapper(menu)); - } - - @Override - public void onPrepareOptionsMenu(Menu menu) { - //Nothing to see here. - } - - @Override - public final boolean onOptionsItemSelected(android.view.MenuItem item) { - return onOptionsItemSelected(new MenuItemWrapper(item)); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - //Nothing to see here. - return false; - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockPreferenceActivity.java b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockPreferenceActivity.java deleted file mode 100644 index 4f80be515..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockPreferenceActivity.java +++ /dev/null @@ -1,259 +0,0 @@ -package com.actionbarsherlock.app; - -import android.content.res.Configuration; -import android.os.Bundle; -import android.preference.PreferenceActivity; -import android.view.KeyEvent; -import android.view.View; -import android.view.ViewGroup.LayoutParams; -import android.view.Window; -import com.actionbarsherlock.ActionBarSherlock; -import com.actionbarsherlock.ActionBarSherlock.OnActionModeFinishedListener; -import com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListener; -import com.actionbarsherlock.ActionBarSherlock.OnCreatePanelMenuListener; -import com.actionbarsherlock.ActionBarSherlock.OnMenuItemSelectedListener; -import com.actionbarsherlock.ActionBarSherlock.OnPreparePanelListener; -import com.actionbarsherlock.view.ActionMode; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuInflater; -import com.actionbarsherlock.view.MenuItem; - -public abstract class SherlockPreferenceActivity extends PreferenceActivity implements OnCreatePanelMenuListener, OnPreparePanelListener, OnMenuItemSelectedListener, OnActionModeStartedListener, OnActionModeFinishedListener { - private ActionBarSherlock mSherlock; - - protected final ActionBarSherlock getSherlock() { - if (mSherlock == null) { - mSherlock = ActionBarSherlock.wrap(this, ActionBarSherlock.FLAG_DELEGATE); - } - return mSherlock; - } - - - /////////////////////////////////////////////////////////////////////////// - // Action bar and mode - /////////////////////////////////////////////////////////////////////////// - - public ActionBar getSupportActionBar() { - return getSherlock().getActionBar(); - } - - public ActionMode startActionMode(ActionMode.Callback callback) { - return getSherlock().startActionMode(callback); - } - - @Override - public void onActionModeStarted(ActionMode mode) {} - - @Override - public void onActionModeFinished(ActionMode mode) {} - - - /////////////////////////////////////////////////////////////////////////// - // General lifecycle/callback dispatching - /////////////////////////////////////////////////////////////////////////// - - @Override - public void onConfigurationChanged(Configuration newConfig) { - super.onConfigurationChanged(newConfig); - getSherlock().dispatchConfigurationChanged(newConfig); - } - - @Override - protected void onPostResume() { - super.onPostResume(); - getSherlock().dispatchPostResume(); - } - - @Override - protected void onPause() { - getSherlock().dispatchPause(); - super.onPause(); - } - - @Override - protected void onStop() { - getSherlock().dispatchStop(); - super.onStop(); - } - - @Override - protected void onDestroy() { - getSherlock().dispatchDestroy(); - super.onDestroy(); - } - - @Override - protected void onPostCreate(Bundle savedInstanceState) { - getSherlock().dispatchPostCreate(savedInstanceState); - super.onPostCreate(savedInstanceState); - } - - @Override - protected void onTitleChanged(CharSequence title, int color) { - getSherlock().dispatchTitleChanged(title, color); - super.onTitleChanged(title, color); - } - - @Override - public final boolean onMenuOpened(int featureId, android.view.Menu menu) { - if (getSherlock().dispatchMenuOpened(featureId, menu)) { - return true; - } - return super.onMenuOpened(featureId, menu); - } - - @Override - public void onPanelClosed(int featureId, android.view.Menu menu) { - getSherlock().dispatchPanelClosed(featureId, menu); - super.onPanelClosed(featureId, menu); - } - - @Override - public boolean dispatchKeyEvent(KeyEvent event) { - if (getSherlock().dispatchKeyEvent(event)) { - return true; - } - return super.dispatchKeyEvent(event); - } - - - /////////////////////////////////////////////////////////////////////////// - // Native menu handling - /////////////////////////////////////////////////////////////////////////// - - public MenuInflater getSupportMenuInflater() { - return getSherlock().getMenuInflater(); - } - - public void invalidateOptionsMenu() { - getSherlock().dispatchInvalidateOptionsMenu(); - } - - public void supportInvalidateOptionsMenu() { - invalidateOptionsMenu(); - } - - @Override - public final boolean onCreateOptionsMenu(android.view.Menu menu) { - return getSherlock().dispatchCreateOptionsMenu(menu); - } - - @Override - public final boolean onPrepareOptionsMenu(android.view.Menu menu) { - return getSherlock().dispatchPrepareOptionsMenu(menu); - } - - @Override - public final boolean onOptionsItemSelected(android.view.MenuItem item) { - return getSherlock().dispatchOptionsItemSelected(item); - } - - @Override - public void openOptionsMenu() { - if (!getSherlock().dispatchOpenOptionsMenu()) { - super.openOptionsMenu(); - } - } - - @Override - public void closeOptionsMenu() { - if (!getSherlock().dispatchCloseOptionsMenu()) { - super.closeOptionsMenu(); - } - } - - - /////////////////////////////////////////////////////////////////////////// - // Sherlock menu handling - /////////////////////////////////////////////////////////////////////////// - - @Override - public boolean onCreatePanelMenu(int featureId, Menu menu) { - if (featureId == Window.FEATURE_OPTIONS_PANEL) { - return onCreateOptionsMenu(menu); - } - return false; - } - - public boolean onCreateOptionsMenu(Menu menu) { - return true; - } - - @Override - public boolean onPreparePanel(int featureId, View view, Menu menu) { - if (featureId == Window.FEATURE_OPTIONS_PANEL) { - return onPrepareOptionsMenu(menu); - } - return false; - } - - public boolean onPrepareOptionsMenu(Menu menu) { - return true; - } - - @Override - public boolean onMenuItemSelected(int featureId, MenuItem item) { - if (featureId == Window.FEATURE_OPTIONS_PANEL) { - return onOptionsItemSelected(item); - } - return false; - } - - public boolean onOptionsItemSelected(MenuItem item) { - return false; - } - - - /////////////////////////////////////////////////////////////////////////// - // Content - /////////////////////////////////////////////////////////////////////////// - - @Override - public void addContentView(View view, LayoutParams params) { - getSherlock().addContentView(view, params); - } - - @Override - public void setContentView(int layoutResId) { - getSherlock().setContentView(layoutResId); - } - - @Override - public void setContentView(View view, LayoutParams params) { - getSherlock().setContentView(view, params); - } - - @Override - public void setContentView(View view) { - getSherlock().setContentView(view); - } - - public void requestWindowFeature(long featureId) { - getSherlock().requestFeature((int)featureId); - } - - - /////////////////////////////////////////////////////////////////////////// - // Progress Indication - /////////////////////////////////////////////////////////////////////////// - - public void setSupportProgress(int progress) { - getSherlock().setProgress(progress); - } - - public void setSupportProgressBarIndeterminate(boolean indeterminate) { - getSherlock().setProgressBarIndeterminate(indeterminate); - } - - public void setSupportProgressBarIndeterminateVisibility(boolean visible) { - getSherlock().setProgressBarIndeterminateVisibility(visible); - } - - public void setSupportProgressBarVisibility(boolean visible) { - getSherlock().setProgressBarVisibility(visible); - } - - public void setSupportSecondaryProgress(int secondaryProgress) { - getSherlock().setSecondaryProgress(secondaryProgress); - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockCompat.java b/actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockCompat.java deleted file mode 100644 index 05353d28c..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockCompat.java +++ /dev/null @@ -1,1207 +0,0 @@ -package com.actionbarsherlock.internal; - -import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; -import static com.actionbarsherlock.internal.ResourcesCompat.getResources_getBoolean; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import org.xmlpull.v1.XmlPullParser; -import android.app.Activity; -import android.content.Context; -import android.content.pm.ActivityInfo; -import android.content.res.AssetManager; -import android.content.res.Configuration; -import android.content.res.Resources; -import android.content.res.TypedArray; -import android.content.res.XmlResourceParser; -import android.os.Bundle; -import android.util.AndroidRuntimeException; -import android.util.Log; -import android.util.TypedValue; -import android.view.ContextThemeWrapper; -import android.view.KeyCharacterMap; -import android.view.KeyEvent; -import android.view.View; -import android.view.ViewGroup; -import android.view.ViewStub; -import android.view.Window; -import android.view.accessibility.AccessibilityEvent; -import android.view.animation.Animation; -import android.view.animation.AnimationUtils; -import android.widget.FrameLayout; -import android.widget.TextView; -import com.actionbarsherlock.ActionBarSherlock; -import com.actionbarsherlock.R; -import com.actionbarsherlock.app.ActionBar; -import com.actionbarsherlock.internal.app.ActionBarImpl; -import com.actionbarsherlock.internal.view.StandaloneActionMode; -import com.actionbarsherlock.internal.view.menu.ActionMenuPresenter; -import com.actionbarsherlock.internal.view.menu.MenuBuilder; -import com.actionbarsherlock.internal.view.menu.MenuItemImpl; -import com.actionbarsherlock.internal.view.menu.MenuPresenter; -import com.actionbarsherlock.internal.widget.ActionBarContainer; -import com.actionbarsherlock.internal.widget.ActionBarContextView; -import com.actionbarsherlock.internal.widget.ActionBarView; -import com.actionbarsherlock.internal.widget.IcsProgressBar; -import com.actionbarsherlock.view.ActionMode; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuItem; - -@ActionBarSherlock.Implementation(api = 7) -public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBuilder.Callback, com.actionbarsherlock.view.Window.Callback, MenuPresenter.Callback, android.view.MenuItem.OnMenuItemClickListener { - /** Window features which are enabled by default. */ - protected static final int DEFAULT_FEATURES = 0; - - - public ActionBarSherlockCompat(Activity activity, int flags) { - super(activity, flags); - } - - - /////////////////////////////////////////////////////////////////////////// - // Properties - /////////////////////////////////////////////////////////////////////////// - - /** Whether or not the device has a dedicated menu key button. */ - private boolean mReserveOverflow; - /** Lazy-load indicator for {@link #mReserveOverflow}. */ - private boolean mReserveOverflowSet = false; - - /** Current menu instance for managing action items. */ - private MenuBuilder mMenu; - /** Map between native options items and sherlock items. */ - protected HashMap mNativeItemMap; - /** Indication of a long-press on the hardware menu key. */ - private boolean mMenuKeyIsLongPress = false; - - /** Parent view of the window decoration (action bar, mode, etc.). */ - private ViewGroup mDecor; - /** Parent view of the activity content. */ - private ViewGroup mContentParent; - - /** Whether or not the title is stable and can be displayed. */ - private boolean mIsTitleReady = false; - /** Whether or not the parent activity has been destroyed. */ - private boolean mIsDestroyed = false; - - /* Emulate PanelFeatureState */ - private boolean mClosingActionMenu; - private boolean mMenuIsPrepared; - private boolean mMenuRefreshContent; - private Bundle mMenuFrozenActionViewState; - - /** Implementation which backs the action bar interface API. */ - private ActionBarImpl aActionBar; - /** Main action bar view which displays the core content. */ - private ActionBarView wActionBar; - /** Relevant window and action bar features flags. */ - private int mFeatures = DEFAULT_FEATURES; - /** Relevant user interface option flags. */ - private int mUiOptions = 0; - - /** Decor indeterminate progress indicator. */ - private IcsProgressBar mCircularProgressBar; - /** Decor progress indicator. */ - private IcsProgressBar mHorizontalProgressBar; - - /** Current displayed context action bar, if any. */ - private ActionMode mActionMode; - /** Parent view in which the context action bar is displayed. */ - private ActionBarContextView mActionModeView; - - /** Title view used with dialogs. */ - private TextView mTitleView; - /** Current activity title. */ - private CharSequence mTitle = null; - /** Whether or not this "activity" is floating (i.e., a dialog) */ - private boolean mIsFloating; - - - - /////////////////////////////////////////////////////////////////////////// - // Instance methods - /////////////////////////////////////////////////////////////////////////// - - @Override - public ActionBar getActionBar() { - if (DEBUG) Log.d(TAG, "[getActionBar]"); - - initActionBar(); - return aActionBar; - } - - private void initActionBar() { - if (DEBUG) Log.d(TAG, "[initActionBar]"); - - // Initializing the window decor can change window feature flags. - // Make sure that we have the correct set before performing the test below. - if (mDecor == null) { - installDecor(); - } - - if ((aActionBar != null) || !hasFeature(Window.FEATURE_ACTION_BAR) || hasFeature(Window.FEATURE_NO_TITLE) || mActivity.isChild()) { - return; - } - - aActionBar = new ActionBarImpl(mActivity, mFeatures); - - if (!mIsDelegate) { - //We may never get another chance to set the title - wActionBar.setWindowTitle(mActivity.getTitle()); - } - } - - @Override - protected Context getThemedContext() { - return aActionBar.getThemedContext(); - } - - @Override - public void setTitle(CharSequence title) { - if (DEBUG) Log.d(TAG, "[setTitle] title: " + title); - - dispatchTitleChanged(title, 0); - } - - @Override - public ActionMode startActionMode(ActionMode.Callback callback) { - if (DEBUG) Log.d(TAG, "[startActionMode] callback: " + callback); - - if (mActionMode != null) { - mActionMode.finish(); - } - - final ActionMode.Callback wrappedCallback = new ActionModeCallbackWrapper(callback); - ActionMode mode = null; - - //Emulate Activity's onWindowStartingActionMode: - initActionBar(); - if (aActionBar != null) { - mode = aActionBar.startActionMode(wrappedCallback); - } - - if (mode != null) { - mActionMode = mode; - } else { - if (mActionModeView == null) { - ViewStub stub = (ViewStub)mDecor.findViewById(R.id.abs__action_mode_bar_stub); - if (stub != null) { - mActionModeView = (ActionBarContextView)stub.inflate(); - } - } - if (mActionModeView != null) { - mActionModeView.killMode(); - mode = new StandaloneActionMode(mActivity, mActionModeView, wrappedCallback, true); - if (callback.onCreateActionMode(mode, mode.getMenu())) { - mode.invalidate(); - mActionModeView.initForMode(mode); - mActionModeView.setVisibility(View.VISIBLE); - mActionMode = mode; - mActionModeView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); - } else { - mActionMode = null; - } - } - } - if (mActionMode != null && mActivity instanceof OnActionModeStartedListener) { - ((OnActionModeStartedListener)mActivity).onActionModeStarted(mActionMode); - } - return mActionMode; - } - - - /////////////////////////////////////////////////////////////////////////// - // Lifecycle and interaction callbacks for delegation - /////////////////////////////////////////////////////////////////////////// - - @Override - public void dispatchConfigurationChanged(Configuration newConfig) { - if (DEBUG) Log.d(TAG, "[dispatchConfigurationChanged] newConfig: " + newConfig); - - if (aActionBar != null) { - aActionBar.onConfigurationChanged(newConfig); - } - } - - @Override - public void dispatchPostResume() { - if (DEBUG) Log.d(TAG, "[dispatchPostResume]"); - - if (aActionBar != null) { - aActionBar.setShowHideAnimationEnabled(true); - } - } - - @Override - public void dispatchPause() { - if (DEBUG) Log.d(TAG, "[dispatchPause]"); - - if (wActionBar != null && wActionBar.isOverflowMenuShowing()) { - wActionBar.hideOverflowMenu(); - } - } - - @Override - public void dispatchStop() { - if (DEBUG) Log.d(TAG, "[dispatchStop]"); - - if (aActionBar != null) { - aActionBar.setShowHideAnimationEnabled(false); - } - } - - @Override - public void dispatchInvalidateOptionsMenu() { - if (DEBUG) Log.d(TAG, "[dispatchInvalidateOptionsMenu]"); - - Bundle savedActionViewStates = null; - if (mMenu != null) { - savedActionViewStates = new Bundle(); - mMenu.saveActionViewStates(savedActionViewStates); - if (savedActionViewStates.size() > 0) { - mMenuFrozenActionViewState = savedActionViewStates; - } - // This will be started again when the panel is prepared. - mMenu.stopDispatchingItemsChanged(); - mMenu.clear(); - } - mMenuRefreshContent = true; - - // Prepare the options panel if we have an action bar - if (wActionBar != null) { - mMenuIsPrepared = false; - preparePanel(); - } - } - - @Override - public boolean dispatchOpenOptionsMenu() { - if (DEBUG) Log.d(TAG, "[dispatchOpenOptionsMenu]"); - - if (!isReservingOverflow()) { - return false; - } - - return wActionBar.showOverflowMenu(); - } - - @Override - public boolean dispatchCloseOptionsMenu() { - if (DEBUG) Log.d(TAG, "[dispatchCloseOptionsMenu]"); - - if (!isReservingOverflow()) { - return false; - } - - return wActionBar.hideOverflowMenu(); - } - - @Override - public void dispatchPostCreate(Bundle savedInstanceState) { - if (DEBUG) Log.d(TAG, "[dispatchOnPostCreate]"); - - if (mIsDelegate) { - mIsTitleReady = true; - } - - if (mDecor == null) { - initActionBar(); - } - } - - @Override - public boolean dispatchCreateOptionsMenu(android.view.Menu menu) { - if (DEBUG) { - Log.d(TAG, "[dispatchCreateOptionsMenu] android.view.Menu: " + menu); - Log.d(TAG, "[dispatchCreateOptionsMenu] returning true"); - } - return true; - } - - @Override - public boolean dispatchPrepareOptionsMenu(android.view.Menu menu) { - if (DEBUG) Log.d(TAG, "[dispatchPrepareOptionsMenu] android.view.Menu: " + menu); - - if (mActionMode != null) { - return false; - } - - mMenuIsPrepared = false; - if (!preparePanel()) { - return false; - } - - if (isReservingOverflow()) { - return false; - } - - if (mNativeItemMap == null) { - mNativeItemMap = new HashMap(); - } else { - mNativeItemMap.clear(); - } - - if (mMenu == null) { - return false; - } - - boolean result = mMenu.bindNativeOverflow(menu, this, mNativeItemMap); - if (DEBUG) Log.d(TAG, "[dispatchPrepareOptionsMenu] returning " + result); - return result; - } - - @Override - public boolean dispatchOptionsItemSelected(android.view.MenuItem item) { - throw new IllegalStateException("Native callback invoked. Create a test case and report!"); - } - - @Override - public boolean dispatchMenuOpened(int featureId, android.view.Menu menu) { - if (DEBUG) Log.d(TAG, "[dispatchMenuOpened] featureId: " + featureId + ", menu: " + menu); - - if (featureId == Window.FEATURE_ACTION_BAR || featureId == Window.FEATURE_OPTIONS_PANEL) { - if (aActionBar != null) { - aActionBar.dispatchMenuVisibilityChanged(true); - } - return true; - } - - return false; - } - - @Override - public void dispatchPanelClosed(int featureId, android.view.Menu menu){ - if (DEBUG) Log.d(TAG, "[dispatchPanelClosed] featureId: " + featureId + ", menu: " + menu); - - if (featureId == Window.FEATURE_ACTION_BAR || featureId == Window.FEATURE_OPTIONS_PANEL) { - if (aActionBar != null) { - aActionBar.dispatchMenuVisibilityChanged(false); - } - } - } - - @Override - public void dispatchTitleChanged(CharSequence title, int color) { - if (DEBUG) Log.d(TAG, "[dispatchTitleChanged] title: " + title + ", color: " + color); - - if (!mIsDelegate || mIsTitleReady) { - if (mTitleView != null) { - mTitleView.setText(title); - } else if (wActionBar != null) { - wActionBar.setWindowTitle(title); - } - } - - mTitle = title; - } - - @Override - public boolean dispatchKeyEvent(KeyEvent event) { - if (DEBUG) Log.d(TAG, "[dispatchKeyEvent] event: " + event); - - final int keyCode = event.getKeyCode(); - - // Not handled by the view hierarchy, does the action bar want it - // to cancel out of something special? - if (keyCode == KeyEvent.KEYCODE_BACK) { - final int action = event.getAction(); - // Back cancels action modes first. - if (mActionMode != null) { - if (action == KeyEvent.ACTION_UP) { - mActionMode.finish(); - } - if (DEBUG) Log.d(TAG, "[dispatchKeyEvent] returning true"); - return true; - } - - // Next collapse any expanded action views. - if (wActionBar != null && wActionBar.hasExpandedActionView()) { - if (action == KeyEvent.ACTION_UP) { - wActionBar.collapseActionView(); - } - if (DEBUG) Log.d(TAG, "[dispatchKeyEvent] returning true"); - return true; - } - } - - boolean result = false; - if (keyCode == KeyEvent.KEYCODE_MENU && isReservingOverflow()) { - if (event.getAction() == KeyEvent.ACTION_DOWN && event.isLongPress()) { - mMenuKeyIsLongPress = true; - } else if (event.getAction() == KeyEvent.ACTION_UP) { - if (!mMenuKeyIsLongPress) { - if (mActionMode == null && wActionBar != null) { - if (wActionBar.isOverflowMenuShowing()) { - wActionBar.hideOverflowMenu(); - } else { - wActionBar.showOverflowMenu(); - } - } - result = true; - } - mMenuKeyIsLongPress = false; - } - } - - if (DEBUG) Log.d(TAG, "[dispatchKeyEvent] returning " + result); - return result; - } - - @Override - public void dispatchDestroy() { - mIsDestroyed = true; - } - - - /////////////////////////////////////////////////////////////////////////// - // Menu callback lifecycle and creation - /////////////////////////////////////////////////////////////////////////// - - private boolean preparePanel() { - // Already prepared (isPrepared will be reset to false later) - if (mMenuIsPrepared) { - return true; - } - - // Init the panel state's menu--return false if init failed - if (mMenu == null || mMenuRefreshContent) { - if (mMenu == null) { - if (!initializePanelMenu() || (mMenu == null)) { - return false; - } - } - - if (wActionBar != null) { - wActionBar.setMenu(mMenu, this); - } - - // Call callback, and return if it doesn't want to display menu. - - // Creating the panel menu will involve a lot of manipulation; - // don't dispatch change events to presenters until we're done. - mMenu.stopDispatchingItemsChanged(); - if (!callbackCreateOptionsMenu(mMenu)) { - // Ditch the menu created above - mMenu = null; - - if (wActionBar != null) { - // Don't show it in the action bar either - wActionBar.setMenu(null, this); - } - - return false; - } - - mMenuRefreshContent = false; - } - - // Callback and return if the callback does not want to show the menu - - // Preparing the panel menu can involve a lot of manipulation; - // don't dispatch change events to presenters until we're done. - mMenu.stopDispatchingItemsChanged(); - - // Restore action view state before we prepare. This gives apps - // an opportunity to override frozen/restored state in onPrepare. - if (mMenuFrozenActionViewState != null) { - mMenu.restoreActionViewStates(mMenuFrozenActionViewState); - mMenuFrozenActionViewState = null; - } - - if (!callbackPrepareOptionsMenu(mMenu)) { - if (wActionBar != null) { - // The app didn't want to show the menu for now but it still exists. - // Clear it out of the action bar. - wActionBar.setMenu(null, this); - } - mMenu.startDispatchingItemsChanged(); - return false; - } - - // Set the proper keymap - KeyCharacterMap kmap = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD); - mMenu.setQwertyMode(kmap.getKeyboardType() != KeyCharacterMap.NUMERIC); - mMenu.startDispatchingItemsChanged(); - - // Set other state - mMenuIsPrepared = true; - - return true; - } - - public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) { - return callbackOptionsItemSelected(item); - } - - public void onMenuModeChange(MenuBuilder menu) { - reopenMenu(true); - } - - private void reopenMenu(boolean toggleMenuMode) { - if (wActionBar != null && wActionBar.isOverflowReserved()) { - if (!wActionBar.isOverflowMenuShowing() || !toggleMenuMode) { - if (wActionBar.getVisibility() == View.VISIBLE) { - if (callbackPrepareOptionsMenu(mMenu)) { - wActionBar.showOverflowMenu(); - } - } - } else { - wActionBar.hideOverflowMenu(); - } - return; - } - } - - private boolean initializePanelMenu() { - Context context = mActivity;//getContext(); - - // If we have an action bar, initialize the menu with a context themed for it. - if (wActionBar != null) { - TypedValue outValue = new TypedValue(); - Resources.Theme currentTheme = context.getTheme(); - currentTheme.resolveAttribute(R.attr.actionBarWidgetTheme, - outValue, true); - final int targetThemeRes = outValue.resourceId; - - if (targetThemeRes != 0 /*&& context.getThemeResId() != targetThemeRes*/) { - context = new ContextThemeWrapper(context, targetThemeRes); - } - } - - mMenu = new MenuBuilder(context); - mMenu.setCallback(this); - - return true; - } - - void checkCloseActionMenu(Menu menu) { - if (mClosingActionMenu) { - return; - } - - mClosingActionMenu = true; - wActionBar.dismissPopupMenus(); - //Callback cb = getCallback(); - //if (cb != null && !isDestroyed()) { - // cb.onPanelClosed(FEATURE_ACTION_BAR, menu); - //} - mClosingActionMenu = false; - } - - @Override - public boolean onOpenSubMenu(MenuBuilder subMenu) { - return true; - } - - @Override - public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) { - checkCloseActionMenu(menu); - } - - @Override - public boolean onMenuItemClick(android.view.MenuItem item) { - if (DEBUG) Log.d(TAG, "[mNativeItemListener.onMenuItemClick] item: " + item); - - final MenuItemImpl sherlockItem = mNativeItemMap.get(item); - if (sherlockItem != null) { - sherlockItem.invoke(); - } else { - Log.e(TAG, "Options item \"" + item + "\" not found in mapping"); - } - - return true; //Do not allow continuation of native handling - } - - @Override - public boolean onMenuItemSelected(int featureId, MenuItem item) { - return callbackOptionsItemSelected(item); - } - - - /////////////////////////////////////////////////////////////////////////// - // Progress bar interaction and internal handling - /////////////////////////////////////////////////////////////////////////// - - @Override - public void setProgressBarVisibility(boolean visible) { - if (DEBUG) Log.d(TAG, "[setProgressBarVisibility] visible: " + visible); - - setFeatureInt(Window.FEATURE_PROGRESS, visible ? Window.PROGRESS_VISIBILITY_ON : - Window.PROGRESS_VISIBILITY_OFF); - } - - @Override - public void setProgressBarIndeterminateVisibility(boolean visible) { - if (DEBUG) Log.d(TAG, "[setProgressBarIndeterminateVisibility] visible: " + visible); - - setFeatureInt(Window.FEATURE_INDETERMINATE_PROGRESS, - visible ? Window.PROGRESS_VISIBILITY_ON : Window.PROGRESS_VISIBILITY_OFF); - } - - @Override - public void setProgressBarIndeterminate(boolean indeterminate) { - if (DEBUG) Log.d(TAG, "[setProgressBarIndeterminate] indeterminate: " + indeterminate); - - setFeatureInt(Window.FEATURE_PROGRESS, - indeterminate ? Window.PROGRESS_INDETERMINATE_ON : Window.PROGRESS_INDETERMINATE_OFF); - } - - @Override - public void setProgress(int progress) { - if (DEBUG) Log.d(TAG, "[setProgress] progress: " + progress); - - setFeatureInt(Window.FEATURE_PROGRESS, progress + Window.PROGRESS_START); - } - - @Override - public void setSecondaryProgress(int secondaryProgress) { - if (DEBUG) Log.d(TAG, "[setSecondaryProgress] secondaryProgress: " + secondaryProgress); - - setFeatureInt(Window.FEATURE_PROGRESS, - secondaryProgress + Window.PROGRESS_SECONDARY_START); - } - - private void setFeatureInt(int featureId, int value) { - updateInt(featureId, value, false); - } - - private void updateInt(int featureId, int value, boolean fromResume) { - // Do nothing if the decor is not yet installed... an update will - // need to be forced when we eventually become active. - if (mContentParent == null) { - return; - } - - final int featureMask = 1 << featureId; - - if ((getFeatures() & featureMask) == 0 && !fromResume) { - return; - } - - onIntChanged(featureId, value); - } - - private void onIntChanged(int featureId, int value) { - if (featureId == Window.FEATURE_PROGRESS || featureId == Window.FEATURE_INDETERMINATE_PROGRESS) { - updateProgressBars(value); - } - } - - private void updateProgressBars(int value) { - IcsProgressBar circularProgressBar = getCircularProgressBar(true); - IcsProgressBar horizontalProgressBar = getHorizontalProgressBar(true); - - final int features = mFeatures;//getLocalFeatures(); - if (value == Window.PROGRESS_VISIBILITY_ON) { - if ((features & (1 << Window.FEATURE_PROGRESS)) != 0) { - int level = horizontalProgressBar.getProgress(); - int visibility = (horizontalProgressBar.isIndeterminate() || level < 10000) ? - View.VISIBLE : View.INVISIBLE; - horizontalProgressBar.setVisibility(visibility); - } - if ((features & (1 << Window.FEATURE_INDETERMINATE_PROGRESS)) != 0) { - circularProgressBar.setVisibility(View.VISIBLE); - } - } else if (value == Window.PROGRESS_VISIBILITY_OFF) { - if ((features & (1 << Window.FEATURE_PROGRESS)) != 0) { - horizontalProgressBar.setVisibility(View.GONE); - } - if ((features & (1 << Window.FEATURE_INDETERMINATE_PROGRESS)) != 0) { - circularProgressBar.setVisibility(View.GONE); - } - } else if (value == Window.PROGRESS_INDETERMINATE_ON) { - horizontalProgressBar.setIndeterminate(true); - } else if (value == Window.PROGRESS_INDETERMINATE_OFF) { - horizontalProgressBar.setIndeterminate(false); - } else if (Window.PROGRESS_START <= value && value <= Window.PROGRESS_END) { - // We want to set the progress value before testing for visibility - // so that when the progress bar becomes visible again, it has the - // correct level. - horizontalProgressBar.setProgress(value - Window.PROGRESS_START); - - if (value < Window.PROGRESS_END) { - showProgressBars(horizontalProgressBar, circularProgressBar); - } else { - hideProgressBars(horizontalProgressBar, circularProgressBar); - } - } else if (Window.PROGRESS_SECONDARY_START <= value && value <= Window.PROGRESS_SECONDARY_END) { - horizontalProgressBar.setSecondaryProgress(value - Window.PROGRESS_SECONDARY_START); - - showProgressBars(horizontalProgressBar, circularProgressBar); - } - } - - private void showProgressBars(IcsProgressBar horizontalProgressBar, IcsProgressBar spinnyProgressBar) { - final int features = mFeatures;//getLocalFeatures(); - if ((features & (1 << Window.FEATURE_INDETERMINATE_PROGRESS)) != 0 && - spinnyProgressBar.getVisibility() == View.INVISIBLE) { - spinnyProgressBar.setVisibility(View.VISIBLE); - } - // Only show the progress bars if the primary progress is not complete - if ((features & (1 << Window.FEATURE_PROGRESS)) != 0 && - horizontalProgressBar.getProgress() < 10000) { - horizontalProgressBar.setVisibility(View.VISIBLE); - } - } - - private void hideProgressBars(IcsProgressBar horizontalProgressBar, IcsProgressBar spinnyProgressBar) { - final int features = mFeatures;//getLocalFeatures(); - Animation anim = AnimationUtils.loadAnimation(mActivity, android.R.anim.fade_out); - anim.setDuration(1000); - if ((features & (1 << Window.FEATURE_INDETERMINATE_PROGRESS)) != 0 && - spinnyProgressBar.getVisibility() == View.VISIBLE) { - spinnyProgressBar.startAnimation(anim); - spinnyProgressBar.setVisibility(View.INVISIBLE); - } - if ((features & (1 << Window.FEATURE_PROGRESS)) != 0 && - horizontalProgressBar.getVisibility() == View.VISIBLE) { - horizontalProgressBar.startAnimation(anim); - horizontalProgressBar.setVisibility(View.INVISIBLE); - } - } - - private IcsProgressBar getCircularProgressBar(boolean shouldInstallDecor) { - if (mCircularProgressBar != null) { - return mCircularProgressBar; - } - if (mContentParent == null && shouldInstallDecor) { - installDecor(); - } - mCircularProgressBar = (IcsProgressBar)mDecor.findViewById(R.id.abs__progress_circular); - if (mCircularProgressBar != null) { - mCircularProgressBar.setVisibility(View.INVISIBLE); - } - return mCircularProgressBar; - } - - private IcsProgressBar getHorizontalProgressBar(boolean shouldInstallDecor) { - if (mHorizontalProgressBar != null) { - return mHorizontalProgressBar; - } - if (mContentParent == null && shouldInstallDecor) { - installDecor(); - } - mHorizontalProgressBar = (IcsProgressBar)mDecor.findViewById(R.id.abs__progress_horizontal); - if (mHorizontalProgressBar != null) { - mHorizontalProgressBar.setVisibility(View.INVISIBLE); - } - return mHorizontalProgressBar; - } - - - /////////////////////////////////////////////////////////////////////////// - // Feature management and content interaction and creation - /////////////////////////////////////////////////////////////////////////// - - private int getFeatures() { - if (DEBUG) Log.d(TAG, "[getFeatures] returning " + mFeatures); - - return mFeatures; - } - - @Override - public boolean hasFeature(int featureId) { - if (DEBUG) Log.d(TAG, "[hasFeature] featureId: " + featureId); - - boolean result = (mFeatures & (1 << featureId)) != 0; - if (DEBUG) Log.d(TAG, "[hasFeature] returning " + result); - return result; - } - - @Override - public boolean requestFeature(int featureId) { - if (DEBUG) Log.d(TAG, "[requestFeature] featureId: " + featureId); - - if (mContentParent != null) { - throw new AndroidRuntimeException("requestFeature() must be called before adding content"); - } - - switch (featureId) { - case Window.FEATURE_ACTION_BAR: - case Window.FEATURE_ACTION_BAR_OVERLAY: - case Window.FEATURE_ACTION_MODE_OVERLAY: - case Window.FEATURE_INDETERMINATE_PROGRESS: - case Window.FEATURE_NO_TITLE: - case Window.FEATURE_PROGRESS: - mFeatures |= (1 << featureId); - return true; - - default: - return false; - } - } - - @Override - public void setUiOptions(int uiOptions) { - if (DEBUG) Log.d(TAG, "[setUiOptions] uiOptions: " + uiOptions); - - mUiOptions = uiOptions; - } - - @Override - public void setUiOptions(int uiOptions, int mask) { - if (DEBUG) Log.d(TAG, "[setUiOptions] uiOptions: " + uiOptions + ", mask: " + mask); - - mUiOptions = (mUiOptions & ~mask) | (uiOptions & mask); - } - - @Override - public void setContentView(int layoutResId) { - if (DEBUG) Log.d(TAG, "[setContentView] layoutResId: " + layoutResId); - - if (mContentParent == null) { - installDecor(); - } else { - mContentParent.removeAllViews(); - } - mActivity.getLayoutInflater().inflate(layoutResId, mContentParent); - - android.view.Window.Callback callback = mActivity.getWindow().getCallback(); - if (callback != null) { - callback.onContentChanged(); - } - - initActionBar(); - } - - @Override - public void setContentView(View view, ViewGroup.LayoutParams params) { - if (DEBUG) Log.d(TAG, "[setContentView] view: " + view + ", params: " + params); - - if (mContentParent == null) { - installDecor(); - } else { - mContentParent.removeAllViews(); - } - mContentParent.addView(view, params); - - android.view.Window.Callback callback = mActivity.getWindow().getCallback(); - if (callback != null) { - callback.onContentChanged(); - } - - initActionBar(); - } - - @Override - public void addContentView(View view, ViewGroup.LayoutParams params) { - if (DEBUG) Log.d(TAG, "[addContentView] view: " + view + ", params: " + params); - - if (mContentParent == null) { - installDecor(); - } - mContentParent.addView(view, params); - - initActionBar(); - } - - private void installDecor() { - if (DEBUG) Log.d(TAG, "[installDecor]"); - - if (mDecor == null) { - mDecor = (ViewGroup)mActivity.getWindow().getDecorView().findViewById(android.R.id.content); - } - if (mContentParent == null) { - //Since we are not operating at the window level we need to take - //into account the fact that the true decor may have already been - //initialized and had content attached to it. If that is the case, - //copy over its children to our new content container. - List views = null; - if (mDecor.getChildCount() > 0) { - views = new ArrayList(1); //Usually there's only one child - for (int i = 0, children = mDecor.getChildCount(); i < children; i++) { - View child = mDecor.getChildAt(0); - mDecor.removeView(child); - views.add(child); - } - } - - mContentParent = generateLayout(); - - //Copy over the old children. See above for explanation. - if (views != null) { - for (View child : views) { - mContentParent.addView(child); - } - } - - mTitleView = (TextView)mDecor.findViewById(android.R.id.title); - if (mTitleView != null) { - if (hasFeature(Window.FEATURE_NO_TITLE)) { - mTitleView.setVisibility(View.GONE); - if (mContentParent instanceof FrameLayout) { - ((FrameLayout)mContentParent).setForeground(null); - } - } else { - mTitleView.setText(mTitle); - } - } else { - wActionBar = (ActionBarView)mDecor.findViewById(R.id.abs__action_bar); - if (wActionBar != null) { - wActionBar.setWindowCallback(this); - if (wActionBar.getTitle() == null) { - wActionBar.setWindowTitle(mActivity.getTitle()); - } - if (hasFeature(Window.FEATURE_PROGRESS)) { - wActionBar.initProgress(); - } - if (hasFeature(Window.FEATURE_INDETERMINATE_PROGRESS)) { - wActionBar.initIndeterminateProgress(); - } - - //Since we don't require onCreate dispatching, parse for uiOptions here - int uiOptions = loadUiOptionsFromManifest(mActivity); - if (uiOptions != 0) { - mUiOptions = uiOptions; - } - - boolean splitActionBar = false; - final boolean splitWhenNarrow = (mUiOptions & ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW) != 0; - if (splitWhenNarrow) { - splitActionBar = getResources_getBoolean(mActivity, R.bool.abs__split_action_bar_is_narrow); - } else { - splitActionBar = mActivity.getTheme() - .obtainStyledAttributes(R.styleable.SherlockTheme) - .getBoolean(R.styleable.SherlockTheme_windowSplitActionBar, false); - } - final ActionBarContainer splitView = (ActionBarContainer)mDecor.findViewById(R.id.abs__split_action_bar); - if (splitView != null) { - wActionBar.setSplitView(splitView); - wActionBar.setSplitActionBar(splitActionBar); - wActionBar.setSplitWhenNarrow(splitWhenNarrow); - - mActionModeView = (ActionBarContextView)mDecor.findViewById(R.id.abs__action_context_bar); - mActionModeView.setSplitView(splitView); - mActionModeView.setSplitActionBar(splitActionBar); - mActionModeView.setSplitWhenNarrow(splitWhenNarrow); - } else if (splitActionBar) { - Log.e(TAG, "Requested split action bar with incompatible window decor! Ignoring request."); - } - - // Post the panel invalidate for later; avoid application onCreateOptionsMenu - // being called in the middle of onCreate or similar. - mDecor.post(new Runnable() { - @Override - public void run() { - //Invalidate if the panel menu hasn't been created before this. - if (!mIsDestroyed && !mActivity.isFinishing() && mMenu == null) { - dispatchInvalidateOptionsMenu(); - } - } - }); - } - } - } - } - - private ViewGroup generateLayout() { - if (DEBUG) Log.d(TAG, "[generateLayout]"); - - // Apply data from current theme. - - TypedArray a = mActivity.getTheme().obtainStyledAttributes(R.styleable.SherlockTheme); - - mIsFloating = a.getBoolean(R.styleable.SherlockTheme_android_windowIsFloating, false); - - if (!a.hasValue(R.styleable.SherlockTheme_windowActionBar)) { - throw new IllegalStateException("You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative."); - } - - if (a.getBoolean(R.styleable.SherlockTheme_windowNoTitle, false)) { - requestFeature(Window.FEATURE_NO_TITLE); - } else if (a.getBoolean(R.styleable.SherlockTheme_windowActionBar, false)) { - // Don't allow an action bar if there is no title. - requestFeature(Window.FEATURE_ACTION_BAR); - } - - if (a.getBoolean(R.styleable.SherlockTheme_windowActionBarOverlay, false)) { - requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); - } - - if (a.getBoolean(R.styleable.SherlockTheme_windowActionModeOverlay, false)) { - requestFeature(Window.FEATURE_ACTION_MODE_OVERLAY); - } - - a.recycle(); - - int layoutResource; - if (!hasFeature(Window.FEATURE_NO_TITLE)) { - if (mIsFloating) { - //Trash original dialog LinearLayout - mDecor = (ViewGroup)mDecor.getParent(); - mDecor.removeAllViews(); - - layoutResource = R.layout.abs__dialog_title_holo; - } else { - if (hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY)) { - layoutResource = R.layout.abs__screen_action_bar_overlay; - } else { - layoutResource = R.layout.abs__screen_action_bar; - } - } - } else if (hasFeature(Window.FEATURE_ACTION_MODE_OVERLAY) && !hasFeature(Window.FEATURE_NO_TITLE)) { - layoutResource = R.layout.abs__screen_simple_overlay_action_mode; - } else { - layoutResource = R.layout.abs__screen_simple; - } - - if (DEBUG) Log.d(TAG, "[generateLayout] using screen XML " + mActivity.getResources().getString(layoutResource)); - View in = mActivity.getLayoutInflater().inflate(layoutResource, null); - mDecor.addView(in, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)); - - ViewGroup contentParent = (ViewGroup)mDecor.findViewById(R.id.abs__content); - if (contentParent == null) { - throw new RuntimeException("Couldn't find content container view"); - } - - //Make our new child the true content view (for fragments). VERY VOLATILE! - mDecor.setId(View.NO_ID); - contentParent.setId(android.R.id.content); - - if (hasFeature(Window.FEATURE_INDETERMINATE_PROGRESS)) { - IcsProgressBar progress = getCircularProgressBar(false); - if (progress != null) { - progress.setIndeterminate(true); - } - } - - return contentParent; - } - - - /////////////////////////////////////////////////////////////////////////// - // Miscellaneous - /////////////////////////////////////////////////////////////////////////// - - /** - * Determine whether or not the device has a dedicated menu key. - * - * @return {@code true} if native menu key is present. - */ - private boolean isReservingOverflow() { - if (!mReserveOverflowSet) { - mReserveOverflow = ActionMenuPresenter.reserveOverflow(mActivity); - mReserveOverflowSet = true; - } - return mReserveOverflow; - } - - private static int loadUiOptionsFromManifest(Activity activity) { - int uiOptions = 0; - try { - final String thisPackage = activity.getClass().getName(); - if (DEBUG) Log.i(TAG, "Parsing AndroidManifest.xml for " + thisPackage); - - final String packageName = activity.getApplicationInfo().packageName; - final AssetManager am = activity.createPackageContext(packageName, 0).getAssets(); - final XmlResourceParser xml = am.openXmlResourceParser("AndroidManifest.xml"); - - int eventType = xml.getEventType(); - while (eventType != XmlPullParser.END_DOCUMENT) { - if (eventType == XmlPullParser.START_TAG) { - String name = xml.getName(); - - if ("application".equals(name)) { - //Check if the has the attribute - if (DEBUG) Log.d(TAG, "Got "); - - for (int i = xml.getAttributeCount() - 1; i >= 0; i--) { - if (DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i)); - - if ("uiOptions".equals(xml.getAttributeName(i))) { - uiOptions = xml.getAttributeIntValue(i, 0); - break; //out of for loop - } - } - } else if ("activity".equals(name)) { - //Check if the is us and has the attribute - if (DEBUG) Log.d(TAG, "Got "); - Integer activityUiOptions = null; - String activityPackage = null; - boolean isOurActivity = false; - - for (int i = xml.getAttributeCount() - 1; i >= 0; i--) { - if (DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i)); - - //We need both uiOptions and name attributes - String attrName = xml.getAttributeName(i); - if ("uiOptions".equals(attrName)) { - activityUiOptions = xml.getAttributeIntValue(i, 0); - } else if ("name".equals(attrName)) { - activityPackage = cleanActivityName(packageName, xml.getAttributeValue(i)); - if (!thisPackage.equals(activityPackage)) { - break; //out of for loop - } - isOurActivity = true; - } - - //Make sure we have both attributes before processing - if ((activityUiOptions != null) && (activityPackage != null)) { - //Our activity, uiOptions specified, override with our value - uiOptions = activityUiOptions.intValue(); - } - } - if (isOurActivity) { - //If we matched our activity but it had no logo don't - //do any more processing of the manifest - break; - } - } - } - eventType = xml.nextToken(); - } - } catch (Exception e) { - e.printStackTrace(); - } - if (DEBUG) Log.i(TAG, "Returning " + Integer.toHexString(uiOptions)); - return uiOptions; - } - - public static String cleanActivityName(String manifestPackage, String activityName) { - if (activityName.charAt(0) == '.') { - //Relative activity name (e.g., android:name=".ui.SomeClass") - return manifestPackage + activityName; - } - if (activityName.indexOf('.', 1) == -1) { - //Unqualified activity name (e.g., android:name="SomeClass") - return manifestPackage + "." + activityName; - } - //Fully-qualified activity name (e.g., "com.my.package.SomeClass") - return activityName; - } - - /** - * Clears out internal reference when the action mode is destroyed. - */ - private class ActionModeCallbackWrapper implements ActionMode.Callback { - private final ActionMode.Callback mWrapped; - - public ActionModeCallbackWrapper(ActionMode.Callback wrapped) { - mWrapped = wrapped; - } - - public boolean onCreateActionMode(ActionMode mode, Menu menu) { - return mWrapped.onCreateActionMode(mode, menu); - } - - public boolean onPrepareActionMode(ActionMode mode, Menu menu) { - return mWrapped.onPrepareActionMode(mode, menu); - } - - public boolean onActionItemClicked(ActionMode mode, MenuItem item) { - return mWrapped.onActionItemClicked(mode, item); - } - - public void onDestroyActionMode(ActionMode mode) { - mWrapped.onDestroyActionMode(mode); - if (mActionModeView != null) { - mActionModeView.setVisibility(View.GONE); - mActionModeView.removeAllViews(); - } - if (mActivity instanceof OnActionModeFinishedListener) { - ((OnActionModeFinishedListener)mActivity).onActionModeFinished(mActionMode); - } - mActionMode = null; - } - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockNative.java b/actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockNative.java deleted file mode 100644 index 9afca185a..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockNative.java +++ /dev/null @@ -1,328 +0,0 @@ -package com.actionbarsherlock.internal; - -import com.actionbarsherlock.ActionBarSherlock; -import com.actionbarsherlock.app.ActionBar; -import com.actionbarsherlock.internal.app.ActionBarWrapper; -import com.actionbarsherlock.internal.view.menu.MenuWrapper; -import com.actionbarsherlock.view.ActionMode; -import com.actionbarsherlock.view.MenuInflater; -import android.app.Activity; -import android.content.Context; -import android.util.Log; -import android.util.TypedValue; -import android.view.ContextThemeWrapper; -import android.view.View; -import android.view.Window; -import android.view.ViewGroup.LayoutParams; - -@ActionBarSherlock.Implementation(api = 14) -public class ActionBarSherlockNative extends ActionBarSherlock { - private ActionBarWrapper mActionBar; - private ActionModeWrapper mActionMode; - private MenuWrapper mMenu; - - public ActionBarSherlockNative(Activity activity, int flags) { - super(activity, flags); - } - - - @Override - public ActionBar getActionBar() { - if (DEBUG) Log.d(TAG, "[getActionBar]"); - - initActionBar(); - return mActionBar; - } - - private void initActionBar() { - if (mActionBar != null || mActivity.getActionBar() == null) { - return; - } - - mActionBar = new ActionBarWrapper(mActivity); - } - - @Override - public void dispatchInvalidateOptionsMenu() { - if (DEBUG) Log.d(TAG, "[dispatchInvalidateOptionsMenu]"); - - mActivity.getWindow().invalidatePanelMenu(Window.FEATURE_OPTIONS_PANEL); - } - - @Override - public boolean dispatchCreateOptionsMenu(android.view.Menu menu) { - if (DEBUG) Log.d(TAG, "[dispatchCreateOptionsMenu] menu: " + menu); - - if (mMenu == null || menu != mMenu.unwrap()) { - mMenu = new MenuWrapper(menu); - } - - final boolean result = callbackCreateOptionsMenu(mMenu); - if (DEBUG) Log.d(TAG, "[dispatchCreateOptionsMenu] returning " + result); - return result; - } - - @Override - public boolean dispatchPrepareOptionsMenu(android.view.Menu menu) { - if (DEBUG) Log.d(TAG, "[dispatchPrepareOptionsMenu] menu: " + menu); - - final boolean result = callbackPrepareOptionsMenu(mMenu); - if (DEBUG) Log.d(TAG, "[dispatchPrepareOptionsMenu] returning " + result); - return result; - } - - @Override - public boolean dispatchOptionsItemSelected(android.view.MenuItem item) { - if (DEBUG) Log.d(TAG, "[dispatchOptionsItemSelected] item: " + item.getTitleCondensed()); - - final boolean result = callbackOptionsItemSelected(mMenu.findItem(item)); - if (DEBUG) Log.d(TAG, "[dispatchOptionsItemSelected] returning " + result); - return result; - } - - @Override - public boolean hasFeature(int feature) { - if (DEBUG) Log.d(TAG, "[hasFeature] feature: " + feature); - - final boolean result = mActivity.getWindow().hasFeature(feature); - if (DEBUG) Log.d(TAG, "[hasFeature] returning " + result); - return result; - } - - @Override - public boolean requestFeature(int featureId) { - if (DEBUG) Log.d(TAG, "[requestFeature] featureId: " + featureId); - - final boolean result = mActivity.getWindow().requestFeature(featureId); - if (DEBUG) Log.d(TAG, "[requestFeature] returning " + result); - return result; - } - - @Override - public void setUiOptions(int uiOptions) { - if (DEBUG) Log.d(TAG, "[setUiOptions] uiOptions: " + uiOptions); - - mActivity.getWindow().setUiOptions(uiOptions); - } - - @Override - public void setUiOptions(int uiOptions, int mask) { - if (DEBUG) Log.d(TAG, "[setUiOptions] uiOptions: " + uiOptions + ", mask: " + mask); - - mActivity.getWindow().setUiOptions(uiOptions, mask); - } - - @Override - public void setContentView(int layoutResId) { - if (DEBUG) Log.d(TAG, "[setContentView] layoutResId: " + layoutResId); - - mActivity.getWindow().setContentView(layoutResId); - initActionBar(); - } - - @Override - public void setContentView(View view, LayoutParams params) { - if (DEBUG) Log.d(TAG, "[setContentView] view: " + view + ", params: " + params); - - mActivity.getWindow().setContentView(view, params); - initActionBar(); - } - - @Override - public void addContentView(View view, LayoutParams params) { - if (DEBUG) Log.d(TAG, "[addContentView] view: " + view + ", params: " + params); - - mActivity.getWindow().addContentView(view, params); - initActionBar(); - } - - @Override - public void setTitle(CharSequence title) { - if (DEBUG) Log.d(TAG, "[setTitle] title: " + title); - - mActivity.getWindow().setTitle(title); - } - - @Override - public void setProgressBarVisibility(boolean visible) { - if (DEBUG) Log.d(TAG, "[setProgressBarVisibility] visible: " + visible); - - mActivity.setProgressBarVisibility(visible); - } - - @Override - public void setProgressBarIndeterminateVisibility(boolean visible) { - if (DEBUG) Log.d(TAG, "[setProgressBarIndeterminateVisibility] visible: " + visible); - - mActivity.setProgressBarIndeterminateVisibility(visible); - } - - @Override - public void setProgressBarIndeterminate(boolean indeterminate) { - if (DEBUG) Log.d(TAG, "[setProgressBarIndeterminate] indeterminate: " + indeterminate); - - mActivity.setProgressBarIndeterminate(indeterminate); - } - - @Override - public void setProgress(int progress) { - if (DEBUG) Log.d(TAG, "[setProgress] progress: " + progress); - - mActivity.setProgress(progress); - } - - @Override - public void setSecondaryProgress(int secondaryProgress) { - if (DEBUG) Log.d(TAG, "[setSecondaryProgress] secondaryProgress: " + secondaryProgress); - - mActivity.setSecondaryProgress(secondaryProgress); - } - - @Override - protected Context getThemedContext() { - Context context = mActivity; - TypedValue outValue = new TypedValue(); - mActivity.getTheme().resolveAttribute(android.R.attr.actionBarWidgetTheme, outValue, true); - if (outValue.resourceId != 0) { - //We are unable to test if this is the same as our current theme - //so we just wrap it and hope that if the attribute was specified - //then the user is intentionally specifying an alternate theme. - context = new ContextThemeWrapper(context, outValue.resourceId); - } - return context; - } - - @Override - public ActionMode startActionMode(com.actionbarsherlock.view.ActionMode.Callback callback) { - if (DEBUG) Log.d(TAG, "[startActionMode] callback: " + callback); - - if (mActionMode != null) { - mActionMode.finish(); - } - ActionModeCallbackWrapper wrapped = null; - if (callback != null) { - wrapped = new ActionModeCallbackWrapper(callback); - } - - //Calling this will trigger the callback wrapper's onCreate which - //is where we will set the new instance to mActionMode since we need - //to pass it through to the sherlock callbacks and the call below - //will not have returned yet to store its value. - mActivity.startActionMode(wrapped); - - return mActionMode; - } - - private class ActionModeCallbackWrapper implements android.view.ActionMode.Callback { - private final ActionMode.Callback mCallback; - - public ActionModeCallbackWrapper(ActionMode.Callback callback) { - mCallback = callback; - } - - @Override - public boolean onCreateActionMode(android.view.ActionMode mode, android.view.Menu menu) { - //See ActionBarSherlockNative#startActionMode - mActionMode = new ActionModeWrapper(mode); - - return mCallback.onCreateActionMode(mActionMode, mActionMode.getMenu()); - } - - @Override - public boolean onPrepareActionMode(android.view.ActionMode mode, android.view.Menu menu) { - return mCallback.onPrepareActionMode(mActionMode, mActionMode.getMenu()); - } - - @Override - public boolean onActionItemClicked(android.view.ActionMode mode, android.view.MenuItem item) { - return mCallback.onActionItemClicked(mActionMode, mActionMode.getMenu().findItem(item)); - } - - @Override - public void onDestroyActionMode(android.view.ActionMode mode) { - mCallback.onDestroyActionMode(mActionMode); - } - } - - private class ActionModeWrapper extends ActionMode { - private final android.view.ActionMode mActionMode; - private MenuWrapper mMenu = null; - - ActionModeWrapper(android.view.ActionMode actionMode) { - mActionMode = actionMode; - } - - @Override - public void setTitle(CharSequence title) { - mActionMode.setTitle(title); - } - - @Override - public void setTitle(int resId) { - mActionMode.setTitle(resId); - } - - @Override - public void setSubtitle(CharSequence subtitle) { - mActionMode.setSubtitle(subtitle); - } - - @Override - public void setSubtitle(int resId) { - mActionMode.setSubtitle(resId); - } - - @Override - public void setCustomView(View view) { - mActionMode.setCustomView(view); - } - - @Override - public void invalidate() { - mActionMode.invalidate(); - } - - @Override - public void finish() { - mActionMode.finish(); - } - - @Override - public MenuWrapper getMenu() { - if (mMenu == null) { - mMenu = new MenuWrapper(mActionMode.getMenu()); - } - return mMenu; - } - - @Override - public CharSequence getTitle() { - return mActionMode.getTitle(); - } - - @Override - public CharSequence getSubtitle() { - return mActionMode.getSubtitle(); - } - - @Override - public View getCustomView() { - return mActionMode.getCustomView(); - } - - @Override - public MenuInflater getMenuInflater() { - return ActionBarSherlockNative.this.getMenuInflater(); - } - - @Override - public void setTag(Object tag) { - mActionMode.setTag(tag); - } - - @Override - public Object getTag() { - return mActionMode.getTag(); - } - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/ResourcesCompat.java b/actionbarsherlock/src/com/actionbarsherlock/internal/ResourcesCompat.java deleted file mode 100644 index 8e1efe8c5..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/ResourcesCompat.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.actionbarsherlock.internal; - -import android.content.Context; -import android.os.Build; -import android.util.DisplayMetrics; -import com.actionbarsherlock.R; - -public final class ResourcesCompat { - //No instances - private ResourcesCompat() {} - - - /** - * Support implementation of {@code getResources().getBoolean()} that we - * can use to simulate filtering based on width and smallest width - * qualifiers on pre-3.2. - * - * @param context Context to load booleans from on 3.2+ and to fetch the - * display metrics. - * @param id Id of boolean to load. - * @return Associated boolean value as reflected by the current display - * metrics. - */ - public static boolean getResources_getBoolean(Context context, int id) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { - return context.getResources().getBoolean(id); - } - - DisplayMetrics metrics = context.getResources().getDisplayMetrics(); - float widthDp = metrics.widthPixels / metrics.density; - float heightDp = metrics.heightPixels / metrics.density; - float smallestWidthDp = (widthDp < heightDp) ? widthDp : heightDp; - - if (id == R.bool.abs__action_bar_embed_tabs) { - if (widthDp >= 480) { - return true; //values-w480dp - } - return false; //values - } - if (id == R.bool.abs__split_action_bar_is_narrow) { - if (widthDp >= 480) { - return false; //values-w480dp - } - return true; //values - } - if (id == R.bool.abs__action_bar_expanded_action_views_exclusive) { - if (smallestWidthDp >= 600) { - return false; //values-sw600dp - } - return true; //values - } - if (id == R.bool.abs__config_allowActionMenuItemTextWithIcon) { - if (widthDp >= 480) { - return true; //values-w480dp - } - return false; //values - } - - throw new IllegalArgumentException("Unknown boolean resource ID " + id); - } - - /** - * Support implementation of {@code getResources().getInteger()} that we - * can use to simulate filtering based on width qualifiers on pre-3.2. - * - * @param context Context to load integers from on 3.2+ and to fetch the - * display metrics. - * @param id Id of integer to load. - * @return Associated integer value as reflected by the current display - * metrics. - */ - public static int getResources_getInteger(Context context, int id) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { - return context.getResources().getInteger(id); - } - - DisplayMetrics metrics = context.getResources().getDisplayMetrics(); - float widthDp = metrics.widthPixels / metrics.density; - - if (id == R.integer.abs__max_action_buttons) { - if (widthDp >= 600) { - return 5; //values-w600dp - } - if (widthDp >= 500) { - return 4; //values-w500dp - } - if (widthDp >= 360) { - return 3; //values-w360dp - } - return 2; //values - } - - throw new IllegalArgumentException("Unknown integer resource ID " + id); - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/app/ActionBarImpl.java b/actionbarsherlock/src/com/actionbarsherlock/internal/app/ActionBarImpl.java deleted file mode 100644 index 6ae0402c0..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/app/ActionBarImpl.java +++ /dev/null @@ -1,1026 +0,0 @@ -/* - * Copyright (C) 2010 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.actionbarsherlock.internal.app; - -import java.lang.ref.WeakReference; -import java.util.ArrayList; -import android.app.Activity; -import android.app.Dialog; -import android.content.Context; -import android.content.res.Configuration; -import android.content.res.Resources; -import android.graphics.drawable.Drawable; -import android.os.Build; -import android.os.Handler; -import android.support.v4.app.FragmentTransaction; -import android.util.TypedValue; -import android.view.ContextThemeWrapper; -import android.view.LayoutInflater; -import android.view.View; -import android.view.Window; -import android.view.accessibility.AccessibilityEvent; -import android.widget.SpinnerAdapter; -import com.actionbarsherlock.R; -import com.actionbarsherlock.app.ActionBar; -import com.actionbarsherlock.app.SherlockFragmentActivity; -import com.actionbarsherlock.internal.nineoldandroids.animation.Animator; -import com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorListenerAdapter; -import com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet; -import com.actionbarsherlock.internal.nineoldandroids.animation.ObjectAnimator; -import com.actionbarsherlock.internal.nineoldandroids.animation.Animator.AnimatorListener; -import com.actionbarsherlock.internal.nineoldandroids.widget.NineFrameLayout; -import com.actionbarsherlock.internal.view.menu.MenuBuilder; -import com.actionbarsherlock.internal.view.menu.MenuPopupHelper; -import com.actionbarsherlock.internal.view.menu.SubMenuBuilder; -import com.actionbarsherlock.internal.widget.ActionBarContainer; -import com.actionbarsherlock.internal.widget.ActionBarContextView; -import com.actionbarsherlock.internal.widget.ActionBarView; -import com.actionbarsherlock.internal.widget.ScrollingTabContainerView; -import com.actionbarsherlock.view.ActionMode; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuInflater; -import com.actionbarsherlock.view.MenuItem; -import static com.actionbarsherlock.internal.ResourcesCompat.getResources_getBoolean; - -/** - * ActionBarImpl is the ActionBar implementation used - * by devices of all screen sizes. If it detects a compatible decor, - * it will split contextual modes across both the ActionBarView at - * the top of the screen and a horizontal LinearLayout at the bottom - * which is normally hidden. - */ -public class ActionBarImpl extends ActionBar { - //UNUSED private static final String TAG = "ActionBarImpl"; - - private Context mContext; - private Context mThemedContext; - private Activity mActivity; - //UNUSED private Dialog mDialog; - - private ActionBarContainer mContainerView; - private ActionBarView mActionView; - private ActionBarContextView mContextView; - private ActionBarContainer mSplitView; - private NineFrameLayout mContentView; - private ScrollingTabContainerView mTabScrollView; - - private ArrayList mTabs = new ArrayList(); - - private TabImpl mSelectedTab; - private int mSavedTabPosition = INVALID_POSITION; - - ActionModeImpl mActionMode; - ActionMode mDeferredDestroyActionMode; - ActionMode.Callback mDeferredModeDestroyCallback; - - private boolean mLastMenuVisibility; - private ArrayList mMenuVisibilityListeners = - new ArrayList(); - - private static final int CONTEXT_DISPLAY_NORMAL = 0; - private static final int CONTEXT_DISPLAY_SPLIT = 1; - - private static final int INVALID_POSITION = -1; - - private int mContextDisplayMode; - private boolean mHasEmbeddedTabs; - - final Handler mHandler = new Handler(); - Runnable mTabSelector; - - private Animator mCurrentShowAnim; - private Animator mCurrentModeAnim; - private boolean mShowHideAnimationEnabled; - boolean mWasHiddenBeforeMode; - - final AnimatorListener mHideListener = new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - if (mContentView != null) { - mContentView.setTranslationY(0); - mContainerView.setTranslationY(0); - } - if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) { - mSplitView.setVisibility(View.GONE); - } - mContainerView.setVisibility(View.GONE); - mContainerView.setTransitioning(false); - mCurrentShowAnim = null; - completeDeferredDestroyActionMode(); - } - }; - - final AnimatorListener mShowListener = new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - mCurrentShowAnim = null; - mContainerView.requestLayout(); - } - }; - - public ActionBarImpl(Activity activity, int features) { - mActivity = activity; - Window window = activity.getWindow(); - View decor = window.getDecorView(); - init(decor); - - //window.hasFeature() workaround for pre-3.0 - if ((features & (1 << Window.FEATURE_ACTION_BAR_OVERLAY)) == 0) { - mContentView = (NineFrameLayout)decor.findViewById(android.R.id.content); - } - } - - public ActionBarImpl(Dialog dialog) { - //UNUSED mDialog = dialog; - init(dialog.getWindow().getDecorView()); - } - - private void init(View decor) { - mContext = decor.getContext(); - mActionView = (ActionBarView) decor.findViewById(R.id.abs__action_bar); - mContextView = (ActionBarContextView) decor.findViewById( - R.id.abs__action_context_bar); - mContainerView = (ActionBarContainer) decor.findViewById( - R.id.abs__action_bar_container); - mSplitView = (ActionBarContainer) decor.findViewById( - R.id.abs__split_action_bar); - - if (mActionView == null || mContextView == null || mContainerView == null) { - throw new IllegalStateException(getClass().getSimpleName() + " can only be used " + - "with a compatible window decor layout"); - } - - mActionView.setContextView(mContextView); - mContextDisplayMode = mActionView.isSplitActionBar() ? - CONTEXT_DISPLAY_SPLIT : CONTEXT_DISPLAY_NORMAL; - - // Older apps get the home button interaction enabled by default. - // Newer apps need to enable it explicitly. - setHomeButtonEnabled(mContext.getApplicationInfo().targetSdkVersion < 14); - - setHasEmbeddedTabs(getResources_getBoolean(mContext, - R.bool.abs__action_bar_embed_tabs)); - } - - public void onConfigurationChanged(Configuration newConfig) { - setHasEmbeddedTabs(getResources_getBoolean(mContext, - R.bool.abs__action_bar_embed_tabs)); - - //Manually dispatch a configuration change to the action bar view on pre-2.2 - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) { - mActionView.onConfigurationChanged(newConfig); - if (mContextView != null) { - mContextView.onConfigurationChanged(newConfig); - } - } - } - - private void setHasEmbeddedTabs(boolean hasEmbeddedTabs) { - mHasEmbeddedTabs = hasEmbeddedTabs; - // Switch tab layout configuration if needed - if (!mHasEmbeddedTabs) { - mActionView.setEmbeddedTabView(null); - mContainerView.setTabContainer(mTabScrollView); - } else { - mContainerView.setTabContainer(null); - mActionView.setEmbeddedTabView(mTabScrollView); - } - final boolean isInTabMode = getNavigationMode() == NAVIGATION_MODE_TABS; - if (mTabScrollView != null) { - mTabScrollView.setVisibility(isInTabMode ? View.VISIBLE : View.GONE); - } - mActionView.setCollapsable(!mHasEmbeddedTabs && isInTabMode); - } - - private void ensureTabsExist() { - if (mTabScrollView != null) { - return; - } - - ScrollingTabContainerView tabScroller = new ScrollingTabContainerView(mContext); - - if (mHasEmbeddedTabs) { - tabScroller.setVisibility(View.VISIBLE); - mActionView.setEmbeddedTabView(tabScroller); - } else { - tabScroller.setVisibility(getNavigationMode() == NAVIGATION_MODE_TABS ? - View.VISIBLE : View.GONE); - mContainerView.setTabContainer(tabScroller); - } - mTabScrollView = tabScroller; - } - - void completeDeferredDestroyActionMode() { - if (mDeferredModeDestroyCallback != null) { - mDeferredModeDestroyCallback.onDestroyActionMode(mDeferredDestroyActionMode); - mDeferredDestroyActionMode = null; - mDeferredModeDestroyCallback = null; - } - } - - /** - * Enables or disables animation between show/hide states. - * If animation is disabled using this method, animations in progress - * will be finished. - * - * @param enabled true to animate, false to not animate. - */ - public void setShowHideAnimationEnabled(boolean enabled) { - mShowHideAnimationEnabled = enabled; - if (!enabled && mCurrentShowAnim != null) { - mCurrentShowAnim.end(); - } - } - - public void addOnMenuVisibilityListener(OnMenuVisibilityListener listener) { - mMenuVisibilityListeners.add(listener); - } - - public void removeOnMenuVisibilityListener(OnMenuVisibilityListener listener) { - mMenuVisibilityListeners.remove(listener); - } - - public void dispatchMenuVisibilityChanged(boolean isVisible) { - if (isVisible == mLastMenuVisibility) { - return; - } - mLastMenuVisibility = isVisible; - - final int count = mMenuVisibilityListeners.size(); - for (int i = 0; i < count; i++) { - mMenuVisibilityListeners.get(i).onMenuVisibilityChanged(isVisible); - } - } - - @Override - public void setCustomView(int resId) { - setCustomView(LayoutInflater.from(getThemedContext()).inflate(resId, mActionView, false)); - } - - @Override - public void setDisplayUseLogoEnabled(boolean useLogo) { - setDisplayOptions(useLogo ? DISPLAY_USE_LOGO : 0, DISPLAY_USE_LOGO); - } - - @Override - public void setDisplayShowHomeEnabled(boolean showHome) { - setDisplayOptions(showHome ? DISPLAY_SHOW_HOME : 0, DISPLAY_SHOW_HOME); - } - - @Override - public void setDisplayHomeAsUpEnabled(boolean showHomeAsUp) { - setDisplayOptions(showHomeAsUp ? DISPLAY_HOME_AS_UP : 0, DISPLAY_HOME_AS_UP); - } - - @Override - public void setDisplayShowTitleEnabled(boolean showTitle) { - setDisplayOptions(showTitle ? DISPLAY_SHOW_TITLE : 0, DISPLAY_SHOW_TITLE); - } - - @Override - public void setDisplayShowCustomEnabled(boolean showCustom) { - setDisplayOptions(showCustom ? DISPLAY_SHOW_CUSTOM : 0, DISPLAY_SHOW_CUSTOM); - } - - @Override - public void setHomeButtonEnabled(boolean enable) { - mActionView.setHomeButtonEnabled(enable); - } - - @Override - public void setTitle(int resId) { - setTitle(mContext.getString(resId)); - } - - @Override - public void setSubtitle(int resId) { - setSubtitle(mContext.getString(resId)); - } - - public void setSelectedNavigationItem(int position) { - switch (mActionView.getNavigationMode()) { - case NAVIGATION_MODE_TABS: - selectTab(mTabs.get(position)); - break; - case NAVIGATION_MODE_LIST: - mActionView.setDropdownSelectedPosition(position); - break; - default: - throw new IllegalStateException( - "setSelectedNavigationIndex not valid for current navigation mode"); - } - } - - public void removeAllTabs() { - cleanupTabs(); - } - - private void cleanupTabs() { - if (mSelectedTab != null) { - selectTab(null); - } - mTabs.clear(); - if (mTabScrollView != null) { - mTabScrollView.removeAllTabs(); - } - mSavedTabPosition = INVALID_POSITION; - } - - public void setTitle(CharSequence title) { - mActionView.setTitle(title); - } - - public void setSubtitle(CharSequence subtitle) { - mActionView.setSubtitle(subtitle); - } - - public void setDisplayOptions(int options) { - mActionView.setDisplayOptions(options); - } - - public void setDisplayOptions(int options, int mask) { - final int current = mActionView.getDisplayOptions(); - mActionView.setDisplayOptions((options & mask) | (current & ~mask)); - } - - public void setBackgroundDrawable(Drawable d) { - mContainerView.setPrimaryBackground(d); - } - - public void setStackedBackgroundDrawable(Drawable d) { - mContainerView.setStackedBackground(d); - } - - public void setSplitBackgroundDrawable(Drawable d) { - if (mSplitView != null) { - mSplitView.setSplitBackground(d); - } - } - - public View getCustomView() { - return mActionView.getCustomNavigationView(); - } - - public CharSequence getTitle() { - return mActionView.getTitle(); - } - - public CharSequence getSubtitle() { - return mActionView.getSubtitle(); - } - - public int getNavigationMode() { - return mActionView.getNavigationMode(); - } - - public int getDisplayOptions() { - return mActionView.getDisplayOptions(); - } - - public ActionMode startActionMode(ActionMode.Callback callback) { - boolean wasHidden = false; - if (mActionMode != null) { - wasHidden = mWasHiddenBeforeMode; - mActionMode.finish(); - } - - mContextView.killMode(); - ActionModeImpl mode = new ActionModeImpl(callback); - if (mode.dispatchOnCreate()) { - mWasHiddenBeforeMode = !isShowing() || wasHidden; - mode.invalidate(); - mContextView.initForMode(mode); - animateToMode(true); - if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) { - // TODO animate this - mSplitView.setVisibility(View.VISIBLE); - } - mContextView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); - mActionMode = mode; - return mode; - } - return null; - } - - private void configureTab(Tab tab, int position) { - final TabImpl tabi = (TabImpl) tab; - final ActionBar.TabListener callback = tabi.getCallback(); - - if (callback == null) { - throw new IllegalStateException("Action Bar Tab must have a Callback"); - } - - tabi.setPosition(position); - mTabs.add(position, tabi); - - final int count = mTabs.size(); - for (int i = position + 1; i < count; i++) { - mTabs.get(i).setPosition(i); - } - } - - @Override - public void addTab(Tab tab) { - addTab(tab, mTabs.isEmpty()); - } - - @Override - public void addTab(Tab tab, int position) { - addTab(tab, position, mTabs.isEmpty()); - } - - @Override - public void addTab(Tab tab, boolean setSelected) { - ensureTabsExist(); - mTabScrollView.addTab(tab, setSelected); - configureTab(tab, mTabs.size()); - if (setSelected) { - selectTab(tab); - } - } - - @Override - public void addTab(Tab tab, int position, boolean setSelected) { - ensureTabsExist(); - mTabScrollView.addTab(tab, position, setSelected); - configureTab(tab, position); - if (setSelected) { - selectTab(tab); - } - } - - @Override - public Tab newTab() { - return new TabImpl(); - } - - @Override - public void removeTab(Tab tab) { - removeTabAt(tab.getPosition()); - } - - @Override - public void removeTabAt(int position) { - if (mTabScrollView == null) { - // No tabs around to remove - return; - } - - int selectedTabPosition = mSelectedTab != null - ? mSelectedTab.getPosition() : mSavedTabPosition; - mTabScrollView.removeTabAt(position); - TabImpl removedTab = mTabs.remove(position); - if (removedTab != null) { - removedTab.setPosition(-1); - } - - final int newTabCount = mTabs.size(); - for (int i = position; i < newTabCount; i++) { - mTabs.get(i).setPosition(i); - } - - if (selectedTabPosition == position) { - selectTab(mTabs.isEmpty() ? null : mTabs.get(Math.max(0, position - 1))); - } - } - - @Override - public void selectTab(Tab tab) { - if (getNavigationMode() != NAVIGATION_MODE_TABS) { - mSavedTabPosition = tab != null ? tab.getPosition() : INVALID_POSITION; - return; - } - - FragmentTransaction trans = null; - if (mActivity instanceof SherlockFragmentActivity) { - trans = ((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction() - .disallowAddToBackStack(); - } - - if (mSelectedTab == tab) { - if (mSelectedTab != null) { - mSelectedTab.getCallback().onTabReselected(mSelectedTab, trans); - mTabScrollView.animateToTab(tab.getPosition()); - } - } else { - mTabScrollView.setTabSelected(tab != null ? tab.getPosition() : Tab.INVALID_POSITION); - if (mSelectedTab != null) { - mSelectedTab.getCallback().onTabUnselected(mSelectedTab, trans); - } - mSelectedTab = (TabImpl) tab; - if (mSelectedTab != null) { - mSelectedTab.getCallback().onTabSelected(mSelectedTab, trans); - } - } - - if (trans != null && !trans.isEmpty()) { - trans.commit(); - } - } - - @Override - public Tab getSelectedTab() { - return mSelectedTab; - } - - @Override - public int getHeight() { - return mContainerView.getHeight(); - } - - @Override - public void show() { - show(true); - } - - void show(boolean markHiddenBeforeMode) { - if (mCurrentShowAnim != null) { - mCurrentShowAnim.end(); - } - if (mContainerView.getVisibility() == View.VISIBLE) { - if (markHiddenBeforeMode) mWasHiddenBeforeMode = false; - return; - } - mContainerView.setVisibility(View.VISIBLE); - - if (mShowHideAnimationEnabled) { - mContainerView.setAlpha(0); - AnimatorSet anim = new AnimatorSet(); - AnimatorSet.Builder b = anim.play(ObjectAnimator.ofFloat(mContainerView, "alpha", 1)); - if (mContentView != null) { - b.with(ObjectAnimator.ofFloat(mContentView, "translationY", - -mContainerView.getHeight(), 0)); - mContainerView.setTranslationY(-mContainerView.getHeight()); - b.with(ObjectAnimator.ofFloat(mContainerView, "translationY", 0)); - } - if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) { - mSplitView.setAlpha(0); - mSplitView.setVisibility(View.VISIBLE); - b.with(ObjectAnimator.ofFloat(mSplitView, "alpha", 1)); - } - anim.addListener(mShowListener); - mCurrentShowAnim = anim; - anim.start(); - } else { - mContainerView.setAlpha(1); - mContainerView.setTranslationY(0); - mShowListener.onAnimationEnd(null); - } - } - - @Override - public void hide() { - if (mCurrentShowAnim != null) { - mCurrentShowAnim.end(); - } - if (mContainerView.getVisibility() == View.GONE) { - return; - } - - if (mShowHideAnimationEnabled) { - mContainerView.setAlpha(1); - mContainerView.setTransitioning(true); - AnimatorSet anim = new AnimatorSet(); - AnimatorSet.Builder b = anim.play(ObjectAnimator.ofFloat(mContainerView, "alpha", 0)); - if (mContentView != null) { - b.with(ObjectAnimator.ofFloat(mContentView, "translationY", - 0, -mContainerView.getHeight())); - b.with(ObjectAnimator.ofFloat(mContainerView, "translationY", - -mContainerView.getHeight())); - } - if (mSplitView != null && mSplitView.getVisibility() == View.VISIBLE) { - mSplitView.setAlpha(1); - b.with(ObjectAnimator.ofFloat(mSplitView, "alpha", 0)); - } - anim.addListener(mHideListener); - mCurrentShowAnim = anim; - anim.start(); - } else { - mHideListener.onAnimationEnd(null); - } - } - - public boolean isShowing() { - return mContainerView.getVisibility() == View.VISIBLE; - } - - void animateToMode(boolean toActionMode) { - if (toActionMode) { - show(false); - } - if (mCurrentModeAnim != null) { - mCurrentModeAnim.end(); - } - - mActionView.animateToVisibility(toActionMode ? View.GONE : View.VISIBLE); - mContextView.animateToVisibility(toActionMode ? View.VISIBLE : View.GONE); - if (mTabScrollView != null && !mActionView.hasEmbeddedTabs() && mActionView.isCollapsed()) { - mTabScrollView.animateToVisibility(toActionMode ? View.GONE : View.VISIBLE); - } - } - - public Context getThemedContext() { - if (mThemedContext == null) { - TypedValue outValue = new TypedValue(); - Resources.Theme currentTheme = mContext.getTheme(); - currentTheme.resolveAttribute(R.attr.actionBarWidgetTheme, - outValue, true); - final int targetThemeRes = outValue.resourceId; - - if (targetThemeRes != 0) { //XXX && mContext.getThemeResId() != targetThemeRes) { - mThemedContext = new ContextThemeWrapper(mContext, targetThemeRes); - } else { - mThemedContext = mContext; - } - } - return mThemedContext; - } - - /** - * @hide - */ - public class ActionModeImpl extends ActionMode implements MenuBuilder.Callback { - private ActionMode.Callback mCallback; - private MenuBuilder mMenu; - private WeakReference mCustomView; - - public ActionModeImpl(ActionMode.Callback callback) { - mCallback = callback; - mMenu = new MenuBuilder(getThemedContext()) - .setDefaultShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); - mMenu.setCallback(this); - } - - @Override - public MenuInflater getMenuInflater() { - return new MenuInflater(getThemedContext()); - } - - @Override - public Menu getMenu() { - return mMenu; - } - - @Override - public void finish() { - if (mActionMode != this) { - // Not the active action mode - no-op - return; - } - - // If we were hidden before the mode was shown, defer the onDestroy - // callback until the animation is finished and associated relayout - // is about to happen. This lets apps better anticipate visibility - // and layout behavior. - if (mWasHiddenBeforeMode) { - mDeferredDestroyActionMode = this; - mDeferredModeDestroyCallback = mCallback; - } else { - mCallback.onDestroyActionMode(this); - } - mCallback = null; - animateToMode(false); - - // Clear out the context mode views after the animation finishes - mContextView.closeMode(); - mActionView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); - - mActionMode = null; - - if (mWasHiddenBeforeMode) { - hide(); - } - } - - @Override - public void invalidate() { - mMenu.stopDispatchingItemsChanged(); - try { - mCallback.onPrepareActionMode(this, mMenu); - } finally { - mMenu.startDispatchingItemsChanged(); - } - } - - public boolean dispatchOnCreate() { - mMenu.stopDispatchingItemsChanged(); - try { - return mCallback.onCreateActionMode(this, mMenu); - } finally { - mMenu.startDispatchingItemsChanged(); - } - } - - @Override - public void setCustomView(View view) { - mContextView.setCustomView(view); - mCustomView = new WeakReference(view); - } - - @Override - public void setSubtitle(CharSequence subtitle) { - mContextView.setSubtitle(subtitle); - } - - @Override - public void setTitle(CharSequence title) { - mContextView.setTitle(title); - } - - @Override - public void setTitle(int resId) { - setTitle(mContext.getResources().getString(resId)); - } - - @Override - public void setSubtitle(int resId) { - setSubtitle(mContext.getResources().getString(resId)); - } - - @Override - public CharSequence getTitle() { - return mContextView.getTitle(); - } - - @Override - public CharSequence getSubtitle() { - return mContextView.getSubtitle(); - } - - @Override - public View getCustomView() { - return mCustomView != null ? mCustomView.get() : null; - } - - public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) { - if (mCallback != null) { - return mCallback.onActionItemClicked(this, item); - } else { - return false; - } - } - - public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) { - } - - public boolean onSubMenuSelected(SubMenuBuilder subMenu) { - if (mCallback == null) { - return false; - } - - if (!subMenu.hasVisibleItems()) { - return true; - } - - new MenuPopupHelper(getThemedContext(), subMenu).show(); - return true; - } - - public void onCloseSubMenu(SubMenuBuilder menu) { - } - - public void onMenuModeChange(MenuBuilder menu) { - if (mCallback == null) { - return; - } - invalidate(); - mContextView.showOverflowMenu(); - } - } - - /** - * @hide - */ - public class TabImpl extends ActionBar.Tab { - private ActionBar.TabListener mCallback; - private Object mTag; - private Drawable mIcon; - private CharSequence mText; - private CharSequence mContentDesc; - private int mPosition = -1; - private View mCustomView; - - @Override - public Object getTag() { - return mTag; - } - - @Override - public Tab setTag(Object tag) { - mTag = tag; - return this; - } - - public ActionBar.TabListener getCallback() { - return mCallback; - } - - @Override - public Tab setTabListener(ActionBar.TabListener callback) { - mCallback = callback; - return this; - } - - @Override - public View getCustomView() { - return mCustomView; - } - - @Override - public Tab setCustomView(View view) { - mCustomView = view; - if (mPosition >= 0) { - mTabScrollView.updateTab(mPosition); - } - return this; - } - - @Override - public Tab setCustomView(int layoutResId) { - return setCustomView(LayoutInflater.from(getThemedContext()) - .inflate(layoutResId, null)); - } - - @Override - public Drawable getIcon() { - return mIcon; - } - - @Override - public int getPosition() { - return mPosition; - } - - public void setPosition(int position) { - mPosition = position; - } - - @Override - public CharSequence getText() { - return mText; - } - - @Override - public Tab setIcon(Drawable icon) { - mIcon = icon; - if (mPosition >= 0) { - mTabScrollView.updateTab(mPosition); - } - return this; - } - - @Override - public Tab setIcon(int resId) { - return setIcon(mContext.getResources().getDrawable(resId)); - } - - @Override - public Tab setText(CharSequence text) { - mText = text; - if (mPosition >= 0) { - mTabScrollView.updateTab(mPosition); - } - return this; - } - - @Override - public Tab setText(int resId) { - return setText(mContext.getResources().getText(resId)); - } - - @Override - public void select() { - selectTab(this); - } - - @Override - public Tab setContentDescription(int resId) { - return setContentDescription(mContext.getResources().getText(resId)); - } - - @Override - public Tab setContentDescription(CharSequence contentDesc) { - mContentDesc = contentDesc; - if (mPosition >= 0) { - mTabScrollView.updateTab(mPosition); - } - return this; - } - - @Override - public CharSequence getContentDescription() { - return mContentDesc; - } - } - - @Override - public void setCustomView(View view) { - mActionView.setCustomNavigationView(view); - } - - @Override - public void setCustomView(View view, LayoutParams layoutParams) { - view.setLayoutParams(layoutParams); - mActionView.setCustomNavigationView(view); - } - - @Override - public void setListNavigationCallbacks(SpinnerAdapter adapter, OnNavigationListener callback) { - mActionView.setDropdownAdapter(adapter); - mActionView.setCallback(callback); - } - - @Override - public int getSelectedNavigationIndex() { - switch (mActionView.getNavigationMode()) { - case NAVIGATION_MODE_TABS: - return mSelectedTab != null ? mSelectedTab.getPosition() : -1; - case NAVIGATION_MODE_LIST: - return mActionView.getDropdownSelectedPosition(); - default: - return -1; - } - } - - @Override - public int getNavigationItemCount() { - switch (mActionView.getNavigationMode()) { - case NAVIGATION_MODE_TABS: - return mTabs.size(); - case NAVIGATION_MODE_LIST: - SpinnerAdapter adapter = mActionView.getDropdownAdapter(); - return adapter != null ? adapter.getCount() : 0; - default: - return 0; - } - } - - @Override - public int getTabCount() { - return mTabs.size(); - } - - @Override - public void setNavigationMode(int mode) { - final int oldMode = mActionView.getNavigationMode(); - switch (oldMode) { - case NAVIGATION_MODE_TABS: - mSavedTabPosition = getSelectedNavigationIndex(); - selectTab(null); - mTabScrollView.setVisibility(View.GONE); - break; - } - mActionView.setNavigationMode(mode); - switch (mode) { - case NAVIGATION_MODE_TABS: - ensureTabsExist(); - mTabScrollView.setVisibility(View.VISIBLE); - if (mSavedTabPosition != INVALID_POSITION) { - setSelectedNavigationItem(mSavedTabPosition); - mSavedTabPosition = INVALID_POSITION; - } - break; - } - mActionView.setCollapsable(mode == NAVIGATION_MODE_TABS && !mHasEmbeddedTabs); - } - - @Override - public Tab getTabAt(int index) { - return mTabs.get(index); - } - - - @Override - public void setIcon(int resId) { - mActionView.setIcon(resId); - } - - @Override - public void setIcon(Drawable icon) { - mActionView.setIcon(icon); - } - - @Override - public void setLogo(int resId) { - mActionView.setLogo(resId); - } - - @Override - public void setLogo(Drawable logo) { - mActionView.setLogo(logo); - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/app/ActionBarWrapper.java b/actionbarsherlock/src/com/actionbarsherlock/internal/app/ActionBarWrapper.java deleted file mode 100644 index e390ea428..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/app/ActionBarWrapper.java +++ /dev/null @@ -1,468 +0,0 @@ -package com.actionbarsherlock.internal.app; - -import java.util.HashSet; -import java.util.Set; - -import android.app.Activity; -import android.content.Context; -import android.graphics.drawable.Drawable; -import android.support.v4.app.FragmentTransaction; -import android.view.View; -import android.widget.SpinnerAdapter; - -import com.actionbarsherlock.app.ActionBar; -import com.actionbarsherlock.app.SherlockFragmentActivity; - -public class ActionBarWrapper extends ActionBar implements android.app.ActionBar.OnNavigationListener, android.app.ActionBar.OnMenuVisibilityListener { - private final Activity mActivity; - private final android.app.ActionBar mActionBar; - private ActionBar.OnNavigationListener mNavigationListener; - private Set mMenuVisibilityListeners = new HashSet(1); - private FragmentTransaction mFragmentTransaction; - - - public ActionBarWrapper(Activity activity) { - mActivity = activity; - mActionBar = activity.getActionBar(); - if (mActionBar != null) { - mActionBar.addOnMenuVisibilityListener(this); - } - } - - - @Override - public void setHomeButtonEnabled(boolean enabled) { - mActionBar.setHomeButtonEnabled(enabled); - } - - @Override - public Context getThemedContext() { - return mActionBar.getThemedContext(); - } - - @Override - public void setCustomView(View view) { - mActionBar.setCustomView(view); - } - - @Override - public void setCustomView(View view, LayoutParams layoutParams) { - android.app.ActionBar.LayoutParams lp = new android.app.ActionBar.LayoutParams(layoutParams); - lp.gravity = layoutParams.gravity; - lp.bottomMargin = layoutParams.bottomMargin; - lp.topMargin = layoutParams.topMargin; - lp.leftMargin = layoutParams.leftMargin; - lp.rightMargin = layoutParams.rightMargin; - mActionBar.setCustomView(view, lp); - } - - @Override - public void setCustomView(int resId) { - mActionBar.setCustomView(resId); - } - - @Override - public void setIcon(int resId) { - mActionBar.setIcon(resId); - } - - @Override - public void setIcon(Drawable icon) { - mActionBar.setIcon(icon); - } - - @Override - public void setLogo(int resId) { - mActionBar.setLogo(resId); - } - - @Override - public void setLogo(Drawable logo) { - mActionBar.setLogo(logo); - } - - @Override - public void setListNavigationCallbacks(SpinnerAdapter adapter, OnNavigationListener callback) { - mNavigationListener = callback; - mActionBar.setListNavigationCallbacks(adapter, (callback != null) ? this : null); - } - - @Override - public boolean onNavigationItemSelected(int itemPosition, long itemId) { - //This should never be a NullPointerException since we only set - //ourselves as the listener when the callback is not null. - return mNavigationListener.onNavigationItemSelected(itemPosition, itemId); - } - - @Override - public void setSelectedNavigationItem(int position) { - mActionBar.setSelectedNavigationItem(position); - } - - @Override - public int getSelectedNavigationIndex() { - return mActionBar.getSelectedNavigationIndex(); - } - - @Override - public int getNavigationItemCount() { - return mActionBar.getNavigationItemCount(); - } - - @Override - public void setTitle(CharSequence title) { - mActionBar.setTitle(title); - } - - @Override - public void setTitle(int resId) { - mActionBar.setTitle(resId); - } - - @Override - public void setSubtitle(CharSequence subtitle) { - mActionBar.setSubtitle(subtitle); - } - - @Override - public void setSubtitle(int resId) { - mActionBar.setSubtitle(resId); - } - - @Override - public void setDisplayOptions(int options) { - mActionBar.setDisplayOptions(options); - } - - @Override - public void setDisplayOptions(int options, int mask) { - mActionBar.setDisplayOptions(options, mask); - } - - @Override - public void setDisplayUseLogoEnabled(boolean useLogo) { - mActionBar.setDisplayUseLogoEnabled(useLogo); - } - - @Override - public void setDisplayShowHomeEnabled(boolean showHome) { - mActionBar.setDisplayShowHomeEnabled(showHome); - } - - @Override - public void setDisplayHomeAsUpEnabled(boolean showHomeAsUp) { - mActionBar.setDisplayHomeAsUpEnabled(showHomeAsUp); - } - - @Override - public void setDisplayShowTitleEnabled(boolean showTitle) { - mActionBar.setDisplayShowTitleEnabled(showTitle); - } - - @Override - public void setDisplayShowCustomEnabled(boolean showCustom) { - mActionBar.setDisplayShowCustomEnabled(showCustom); - } - - @Override - public void setBackgroundDrawable(Drawable d) { - mActionBar.setBackgroundDrawable(d); - } - - @Override - public void setStackedBackgroundDrawable(Drawable d) { - mActionBar.setStackedBackgroundDrawable(d); - } - - @Override - public void setSplitBackgroundDrawable(Drawable d) { - mActionBar.setSplitBackgroundDrawable(d); - } - - @Override - public View getCustomView() { - return mActionBar.getCustomView(); - } - - @Override - public CharSequence getTitle() { - return mActionBar.getTitle(); - } - - @Override - public CharSequence getSubtitle() { - return mActionBar.getSubtitle(); - } - - @Override - public int getNavigationMode() { - return mActionBar.getNavigationMode(); - } - - @Override - public void setNavigationMode(int mode) { - mActionBar.setNavigationMode(mode); - } - - @Override - public int getDisplayOptions() { - return mActionBar.getDisplayOptions(); - } - - public class TabWrapper extends ActionBar.Tab implements android.app.ActionBar.TabListener { - final android.app.ActionBar.Tab mNativeTab; - private Object mTag; - private TabListener mListener; - - public TabWrapper(android.app.ActionBar.Tab nativeTab) { - mNativeTab = nativeTab; - mNativeTab.setTag(this); - } - - @Override - public int getPosition() { - return mNativeTab.getPosition(); - } - - @Override - public Drawable getIcon() { - return mNativeTab.getIcon(); - } - - @Override - public CharSequence getText() { - return mNativeTab.getText(); - } - - @Override - public Tab setIcon(Drawable icon) { - mNativeTab.setIcon(icon); - return this; - } - - @Override - public Tab setIcon(int resId) { - mNativeTab.setIcon(resId); - return this; - } - - @Override - public Tab setText(CharSequence text) { - mNativeTab.setText(text); - return this; - } - - @Override - public Tab setText(int resId) { - mNativeTab.setText(resId); - return this; - } - - @Override - public Tab setCustomView(View view) { - mNativeTab.setCustomView(view); - return this; - } - - @Override - public Tab setCustomView(int layoutResId) { - mNativeTab.setCustomView(layoutResId); - return this; - } - - @Override - public View getCustomView() { - return mNativeTab.getCustomView(); - } - - @Override - public Tab setTag(Object obj) { - mTag = obj; - return this; - } - - @Override - public Object getTag() { - return mTag; - } - - @Override - public Tab setTabListener(TabListener listener) { - mNativeTab.setTabListener(listener != null ? this : null); - mListener = listener; - return this; - } - - @Override - public void select() { - mNativeTab.select(); - } - - @Override - public Tab setContentDescription(int resId) { - mNativeTab.setContentDescription(resId); - return this; - } - - @Override - public Tab setContentDescription(CharSequence contentDesc) { - mNativeTab.setContentDescription(contentDesc); - return this; - } - - @Override - public CharSequence getContentDescription() { - return mNativeTab.getContentDescription(); - } - - @Override - public void onTabReselected(android.app.ActionBar.Tab tab, android.app.FragmentTransaction ft) { - if (mListener != null) { - FragmentTransaction trans = null; - if (mActivity instanceof SherlockFragmentActivity) { - trans = ((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction() - .disallowAddToBackStack(); - } - - mListener.onTabReselected(this, trans); - - if (trans != null && !trans.isEmpty()) { - trans.commit(); - } - } - } - - @Override - public void onTabSelected(android.app.ActionBar.Tab tab, android.app.FragmentTransaction ft) { - if (mListener != null) { - - if (mFragmentTransaction == null && mActivity instanceof SherlockFragmentActivity) { - mFragmentTransaction = ((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction() - .disallowAddToBackStack(); - } - - mListener.onTabSelected(this, mFragmentTransaction); - - if (mFragmentTransaction != null) { - if (!mFragmentTransaction.isEmpty()) { - mFragmentTransaction.commit(); - } - mFragmentTransaction = null; - } - } - } - - @Override - public void onTabUnselected(android.app.ActionBar.Tab tab, android.app.FragmentTransaction ft) { - if (mListener != null) { - FragmentTransaction trans = null; - if (mActivity instanceof SherlockFragmentActivity) { - trans = ((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction() - .disallowAddToBackStack(); - mFragmentTransaction = trans; - } - - mListener.onTabUnselected(this, trans); - } - } - } - - @Override - public Tab newTab() { - return new TabWrapper(mActionBar.newTab()); - } - - @Override - public void addTab(Tab tab) { - mActionBar.addTab(((TabWrapper)tab).mNativeTab); - } - - @Override - public void addTab(Tab tab, boolean setSelected) { - mActionBar.addTab(((TabWrapper)tab).mNativeTab, setSelected); - } - - @Override - public void addTab(Tab tab, int position) { - mActionBar.addTab(((TabWrapper)tab).mNativeTab, position); - } - - @Override - public void addTab(Tab tab, int position, boolean setSelected) { - mActionBar.addTab(((TabWrapper)tab).mNativeTab, position, setSelected); - } - - @Override - public void removeTab(Tab tab) { - mActionBar.removeTab(((TabWrapper)tab).mNativeTab); - } - - @Override - public void removeTabAt(int position) { - mActionBar.removeTabAt(position); - } - - @Override - public void removeAllTabs() { - mActionBar.removeAllTabs(); - } - - @Override - public void selectTab(Tab tab) { - mActionBar.selectTab(((TabWrapper)tab).mNativeTab); - } - - @Override - public Tab getSelectedTab() { - android.app.ActionBar.Tab selected = mActionBar.getSelectedTab(); - return (selected != null) ? (Tab)selected.getTag() : null; - } - - @Override - public Tab getTabAt(int index) { - android.app.ActionBar.Tab selected = mActionBar.getTabAt(index); - return (selected != null) ? (Tab)selected.getTag() : null; - } - - @Override - public int getTabCount() { - return mActionBar.getTabCount(); - } - - @Override - public int getHeight() { - return mActionBar.getHeight(); - } - - @Override - public void show() { - mActionBar.show(); - } - - @Override - public void hide() { - mActionBar.hide(); - } - - @Override - public boolean isShowing() { - return mActionBar.isShowing(); - } - - @Override - public void addOnMenuVisibilityListener(OnMenuVisibilityListener listener) { - mMenuVisibilityListeners.add(listener); - } - - @Override - public void removeOnMenuVisibilityListener(OnMenuVisibilityListener listener) { - mMenuVisibilityListeners.remove(listener); - } - - @Override - public void onMenuVisibilityChanged(boolean isVisible) { - for (OnMenuVisibilityListener listener : mMenuVisibilityListeners) { - listener.onMenuVisibilityChanged(isVisible); - } - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/Animator.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/Animator.java deleted file mode 100644 index 2caf5b4a9..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/Animator.java +++ /dev/null @@ -1,278 +0,0 @@ -/* - * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; - -import java.util.ArrayList; - -import android.view.animation.Interpolator; - -/** - * This is the superclass for classes which provide basic support for animations which can be - * started, ended, and have AnimatorListeners added to them. - */ -public abstract class Animator implements Cloneable { - - - /** - * The set of listeners to be sent events through the life of an animation. - */ - ArrayList mListeners = null; - - /** - * Starts this animation. If the animation has a nonzero startDelay, the animation will start - * running after that delay elapses. A non-delayed animation will have its initial - * value(s) set immediately, followed by calls to - * {@link AnimatorListener#onAnimationStart(Animator)} for any listeners of this animator. - * - *

The animation started by calling this method will be run on the thread that called - * this method. This thread should have a Looper on it (a runtime exception will be thrown if - * this is not the case). Also, if the animation will animate - * properties of objects in the view hierarchy, then the calling thread should be the UI - * thread for that view hierarchy.

- * - */ - public void start() { - } - - /** - * Cancels the animation. Unlike {@link #end()}, cancel() causes the animation to - * stop in its tracks, sending an - * {@link android.animation.Animator.AnimatorListener#onAnimationCancel(Animator)} to - * its listeners, followed by an - * {@link android.animation.Animator.AnimatorListener#onAnimationEnd(Animator)} message. - * - *

This method must be called on the thread that is running the animation.

- */ - public void cancel() { - } - - /** - * Ends the animation. This causes the animation to assign the end value of the property being - * animated, then calling the - * {@link android.animation.Animator.AnimatorListener#onAnimationEnd(Animator)} method on - * its listeners. - * - *

This method must be called on the thread that is running the animation.

- */ - public void end() { - } - - /** - * The amount of time, in milliseconds, to delay starting the animation after - * {@link #start()} is called. - * - * @return the number of milliseconds to delay running the animation - */ - public abstract long getStartDelay(); - - /** - * The amount of time, in milliseconds, to delay starting the animation after - * {@link #start()} is called. - - * @param startDelay The amount of the delay, in milliseconds - */ - public abstract void setStartDelay(long startDelay); - - - /** - * Sets the length of the animation. - * - * @param duration The length of the animation, in milliseconds. - */ - public abstract Animator setDuration(long duration); - - /** - * Gets the length of the animation. - * - * @return The length of the animation, in milliseconds. - */ - public abstract long getDuration(); - - /** - * The time interpolator used in calculating the elapsed fraction of this animation. The - * interpolator determines whether the animation runs with linear or non-linear motion, - * such as acceleration and deceleration. The default value is - * {@link android.view.animation.AccelerateDecelerateInterpolator} - * - * @param value the interpolator to be used by this animation - */ - public abstract void setInterpolator(/*Time*/Interpolator value); - - /** - * Returns whether this Animator is currently running (having been started and gone past any - * initial startDelay period and not yet ended). - * - * @return Whether the Animator is running. - */ - public abstract boolean isRunning(); - - /** - * Returns whether this Animator has been started and not yet ended. This state is a superset - * of the state of {@link #isRunning()}, because an Animator with a nonzero - * {@link #getStartDelay() startDelay} will return true for {@link #isStarted()} during the - * delay phase, whereas {@link #isRunning()} will return true only after the delay phase - * is complete. - * - * @return Whether the Animator has been started and not yet ended. - */ - public boolean isStarted() { - // Default method returns value for isRunning(). Subclasses should override to return a - // real value. - return isRunning(); - } - - /** - * Adds a listener to the set of listeners that are sent events through the life of an - * animation, such as start, repeat, and end. - * - * @param listener the listener to be added to the current set of listeners for this animation. - */ - public void addListener(AnimatorListener listener) { - if (mListeners == null) { - mListeners = new ArrayList(); - } - mListeners.add(listener); - } - - /** - * Removes a listener from the set listening to this animation. - * - * @param listener the listener to be removed from the current set of listeners for this - * animation. - */ - public void removeListener(AnimatorListener listener) { - if (mListeners == null) { - return; - } - mListeners.remove(listener); - if (mListeners.size() == 0) { - mListeners = null; - } - } - - /** - * Gets the set of {@link android.animation.Animator.AnimatorListener} objects that are currently - * listening for events on this Animator object. - * - * @return ArrayList The set of listeners. - */ - public ArrayList getListeners() { - return mListeners; - } - - /** - * Removes all listeners from this object. This is equivalent to calling - * getListeners() followed by calling clear() on the - * returned list of listeners. - */ - public void removeAllListeners() { - if (mListeners != null) { - mListeners.clear(); - mListeners = null; - } - } - - @Override - public Animator clone() { - try { - final Animator anim = (Animator) super.clone(); - if (mListeners != null) { - ArrayList oldListeners = mListeners; - anim.mListeners = new ArrayList(); - int numListeners = oldListeners.size(); - for (int i = 0; i < numListeners; ++i) { - anim.mListeners.add(oldListeners.get(i)); - } - } - return anim; - } catch (CloneNotSupportedException e) { - throw new AssertionError(); - } - } - - /** - * This method tells the object to use appropriate information to extract - * starting values for the animation. For example, a AnimatorSet object will pass - * this call to its child objects to tell them to set up the values. A - * ObjectAnimator object will use the information it has about its target object - * and PropertyValuesHolder objects to get the start values for its properties. - * An ValueAnimator object will ignore the request since it does not have enough - * information (such as a target object) to gather these values. - */ - public void setupStartValues() { - } - - /** - * This method tells the object to use appropriate information to extract - * ending values for the animation. For example, a AnimatorSet object will pass - * this call to its child objects to tell them to set up the values. A - * ObjectAnimator object will use the information it has about its target object - * and PropertyValuesHolder objects to get the start values for its properties. - * An ValueAnimator object will ignore the request since it does not have enough - * information (such as a target object) to gather these values. - */ - public void setupEndValues() { - } - - /** - * Sets the target object whose property will be animated by this animation. Not all subclasses - * operate on target objects (for example, {@link ValueAnimator}, but this method - * is on the superclass for the convenience of dealing generically with those subclasses - * that do handle targets. - * - * @param target The object being animated - */ - public void setTarget(Object target) { - } - - /** - *

An animation listener receives notifications from an animation. - * Notifications indicate animation related events, such as the end or the - * repetition of the animation.

- */ - public static interface AnimatorListener { - /** - *

Notifies the start of the animation.

- * - * @param animation The started animation. - */ - void onAnimationStart(Animator animation); - - /** - *

Notifies the end of the animation. This callback is not invoked - * for animations with repeat count set to INFINITE.

- * - * @param animation The animation which reached its end. - */ - void onAnimationEnd(Animator animation); - - /** - *

Notifies the cancellation of the animation. This callback is not invoked - * for animations with repeat count set to INFINITE.

- * - * @param animation The animation which was canceled. - */ - void onAnimationCancel(Animator animation); - - /** - *

Notifies the repetition of the animation.

- * - * @param animation The animation which was repeated. - */ - void onAnimationRepeat(Animator animation); - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorListenerAdapter.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorListenerAdapter.java deleted file mode 100644 index 02ddff48d..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorListenerAdapter.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; - -/** - * This adapter class provides empty implementations of the methods from {@link android.animation.Animator.AnimatorListener}. - * Any custom listener that cares only about a subset of the methods of this listener can - * simply subclass this adapter class instead of implementing the interface directly. - */ -public abstract class AnimatorListenerAdapter implements Animator.AnimatorListener { - - /** - * {@inheritDoc} - */ - @Override - public void onAnimationCancel(Animator animation) { - } - - /** - * {@inheritDoc} - */ - @Override - public void onAnimationEnd(Animator animation) { - } - - /** - * {@inheritDoc} - */ - @Override - public void onAnimationRepeat(Animator animation) { - } - - /** - * {@inheritDoc} - */ - @Override - public void onAnimationStart(Animator animation) { - } - -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorSet.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorSet.java deleted file mode 100644 index 3231080c4..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorSet.java +++ /dev/null @@ -1,1111 +0,0 @@ -/* - * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; - -import android.view.animation.Interpolator; - -/** - * This class plays a set of {@link Animator} objects in the specified order. Animations - * can be set up to play together, in sequence, or after a specified delay. - * - *

There are two different approaches to adding animations to a AnimatorSet: - * either the {@link AnimatorSet#playTogether(Animator[]) playTogether()} or - * {@link AnimatorSet#playSequentially(Animator[]) playSequentially()} methods can be called to add - * a set of animations all at once, or the {@link AnimatorSet#play(Animator)} can be - * used in conjunction with methods in the {@link AnimatorSet.Builder Builder} - * class to add animations - * one by one.

- * - *

It is possible to set up a AnimatorSet with circular dependencies between - * its animations. For example, an animation a1 could be set up to start before animation a2, a2 - * before a3, and a3 before a1. The results of this configuration are undefined, but will typically - * result in none of the affected animations being played. Because of this (and because - * circular dependencies do not make logical sense anyway), circular dependencies - * should be avoided, and the dependency flow of animations should only be in one direction. - */ -@SuppressWarnings("unchecked") -public final class AnimatorSet extends Animator { - - /** - * Internal variables - * NOTE: This object implements the clone() method, making a deep copy of any referenced - * objects. As other non-trivial fields are added to this class, make sure to add logic - * to clone() to make deep copies of them. - */ - - /** - * Tracks animations currently being played, so that we know what to - * cancel or end when cancel() or end() is called on this AnimatorSet - */ - private ArrayList mPlayingSet = new ArrayList(); - - /** - * Contains all nodes, mapped to their respective Animators. When new - * dependency information is added for an Animator, we want to add it - * to a single node representing that Animator, not create a new Node - * if one already exists. - */ - private HashMap mNodeMap = new HashMap(); - - /** - * Set of all nodes created for this AnimatorSet. This list is used upon - * starting the set, and the nodes are placed in sorted order into the - * sortedNodes collection. - */ - private ArrayList mNodes = new ArrayList(); - - /** - * The sorted list of nodes. This is the order in which the animations will - * be played. The details about when exactly they will be played depend - * on the dependency relationships of the nodes. - */ - private ArrayList mSortedNodes = new ArrayList(); - - /** - * Flag indicating whether the nodes should be sorted prior to playing. This - * flag allows us to cache the previous sorted nodes so that if the sequence - * is replayed with no changes, it does not have to re-sort the nodes again. - */ - private boolean mNeedsSort = true; - - private AnimatorSetListener mSetListener = null; - - /** - * Flag indicating that the AnimatorSet has been manually - * terminated (by calling cancel() or end()). - * This flag is used to avoid starting other animations when currently-playing - * child animations of this AnimatorSet end. It also determines whether cancel/end - * notifications are sent out via the normal AnimatorSetListener mechanism. - */ - boolean mTerminated = false; - - /** - * Indicates whether an AnimatorSet has been start()'d, whether or - * not there is a nonzero startDelay. - */ - private boolean mStarted = false; - - // The amount of time in ms to delay starting the animation after start() is called - private long mStartDelay = 0; - - // Animator used for a nonzero startDelay - private ValueAnimator mDelayAnim = null; - - - // How long the child animations should last in ms. The default value is negative, which - // simply means that there is no duration set on the AnimatorSet. When a real duration is - // set, it is passed along to the child animations. - private long mDuration = -1; - - - /** - * Sets up this AnimatorSet to play all of the supplied animations at the same time. - * - * @param items The animations that will be started simultaneously. - */ - public void playTogether(Animator... items) { - if (items != null) { - mNeedsSort = true; - Builder builder = play(items[0]); - for (int i = 1; i < items.length; ++i) { - builder.with(items[i]); - } - } - } - - /** - * Sets up this AnimatorSet to play all of the supplied animations at the same time. - * - * @param items The animations that will be started simultaneously. - */ - public void playTogether(Collection items) { - if (items != null && items.size() > 0) { - mNeedsSort = true; - Builder builder = null; - for (Animator anim : items) { - if (builder == null) { - builder = play(anim); - } else { - builder.with(anim); - } - } - } - } - - /** - * Sets up this AnimatorSet to play each of the supplied animations when the - * previous animation ends. - * - * @param items The animations that will be started one after another. - */ - public void playSequentially(Animator... items) { - if (items != null) { - mNeedsSort = true; - if (items.length == 1) { - play(items[0]); - } else { - for (int i = 0; i < items.length - 1; ++i) { - play(items[i]).before(items[i+1]); - } - } - } - } - - /** - * Sets up this AnimatorSet to play each of the supplied animations when the - * previous animation ends. - * - * @param items The animations that will be started one after another. - */ - public void playSequentially(List items) { - if (items != null && items.size() > 0) { - mNeedsSort = true; - if (items.size() == 1) { - play(items.get(0)); - } else { - for (int i = 0; i < items.size() - 1; ++i) { - play(items.get(i)).before(items.get(i+1)); - } - } - } - } - - /** - * Returns the current list of child Animator objects controlled by this - * AnimatorSet. This is a copy of the internal list; modifications to the returned list - * will not affect the AnimatorSet, although changes to the underlying Animator objects - * will affect those objects being managed by the AnimatorSet. - * - * @return ArrayList The list of child animations of this AnimatorSet. - */ - public ArrayList getChildAnimations() { - ArrayList childList = new ArrayList(); - for (Node node : mNodes) { - childList.add(node.animation); - } - return childList; - } - - /** - * Sets the target object for all current {@link #getChildAnimations() child animations} - * of this AnimatorSet that take targets ({@link ObjectAnimator} and - * AnimatorSet). - * - * @param target The object being animated - */ - @Override - public void setTarget(Object target) { - for (Node node : mNodes) { - Animator animation = node.animation; - if (animation instanceof AnimatorSet) { - ((AnimatorSet)animation).setTarget(target); - } else if (animation instanceof ObjectAnimator) { - ((ObjectAnimator)animation).setTarget(target); - } - } - } - - /** - * Sets the TimeInterpolator for all current {@link #getChildAnimations() child animations} - * of this AnimatorSet. - * - * @param interpolator the interpolator to be used by each child animation of this AnimatorSet - */ - @Override - public void setInterpolator(/*Time*/Interpolator interpolator) { - for (Node node : mNodes) { - node.animation.setInterpolator(interpolator); - } - } - - /** - * This method creates a Builder object, which is used to - * set up playing constraints. This initial play() method - * tells the Builder the animation that is the dependency for - * the succeeding commands to the Builder. For example, - * calling play(a1).with(a2) sets up the AnimatorSet to play - * a1 and a2 at the same time, - * play(a1).before(a2) sets up the AnimatorSet to play - * a1 first, followed by a2, and - * play(a1).after(a2) sets up the AnimatorSet to play - * a2 first, followed by a1. - * - *

Note that play() is the only way to tell the - * Builder the animation upon which the dependency is created, - * so successive calls to the various functions in Builder - * will all refer to the initial parameter supplied in play() - * as the dependency of the other animations. For example, calling - * play(a1).before(a2).before(a3) will play both a2 - * and a3 when a1 ends; it does not set up a dependency between - * a2 and a3.

- * - * @param anim The animation that is the dependency used in later calls to the - * methods in the returned Builder object. A null parameter will result - * in a null Builder return value. - * @return Builder The object that constructs the AnimatorSet based on the dependencies - * outlined in the calls to play and the other methods in the - * BuilderNote that canceling a AnimatorSet also cancels all of the animations that it - * is responsible for.

- */ - @Override - public void cancel() { - mTerminated = true; - if (isStarted()) { - ArrayList tmpListeners = null; - if (mListeners != null) { - tmpListeners = (ArrayList) mListeners.clone(); - for (AnimatorListener listener : tmpListeners) { - listener.onAnimationCancel(this); - } - } - if (mDelayAnim != null && mDelayAnim.isRunning()) { - // If we're currently in the startDelay period, just cancel that animator and - // send out the end event to all listeners - mDelayAnim.cancel(); - } else if (mSortedNodes.size() > 0) { - for (Node node : mSortedNodes) { - node.animation.cancel(); - } - } - if (tmpListeners != null) { - for (AnimatorListener listener : tmpListeners) { - listener.onAnimationEnd(this); - } - } - mStarted = false; - } - } - - /** - * {@inheritDoc} - * - *

Note that ending a AnimatorSet also ends all of the animations that it is - * responsible for.

- */ - @Override - public void end() { - mTerminated = true; - if (isStarted()) { - if (mSortedNodes.size() != mNodes.size()) { - // hasn't been started yet - sort the nodes now, then end them - sortNodes(); - for (Node node : mSortedNodes) { - if (mSetListener == null) { - mSetListener = new AnimatorSetListener(this); - } - node.animation.addListener(mSetListener); - } - } - if (mDelayAnim != null) { - mDelayAnim.cancel(); - } - if (mSortedNodes.size() > 0) { - for (Node node : mSortedNodes) { - node.animation.end(); - } - } - if (mListeners != null) { - ArrayList tmpListeners = - (ArrayList) mListeners.clone(); - for (AnimatorListener listener : tmpListeners) { - listener.onAnimationEnd(this); - } - } - mStarted = false; - } - } - - /** - * Returns true if any of the child animations of this AnimatorSet have been started and have - * not yet ended. - * @return Whether this AnimatorSet has been started and has not yet ended. - */ - @Override - public boolean isRunning() { - for (Node node : mNodes) { - if (node.animation.isRunning()) { - return true; - } - } - return false; - } - - @Override - public boolean isStarted() { - return mStarted; - } - - /** - * The amount of time, in milliseconds, to delay starting the animation after - * {@link #start()} is called. - * - * @return the number of milliseconds to delay running the animation - */ - @Override - public long getStartDelay() { - return mStartDelay; - } - - /** - * The amount of time, in milliseconds, to delay starting the animation after - * {@link #start()} is called. - - * @param startDelay The amount of the delay, in milliseconds - */ - @Override - public void setStartDelay(long startDelay) { - mStartDelay = startDelay; - } - - /** - * Gets the length of each of the child animations of this AnimatorSet. This value may - * be less than 0, which indicates that no duration has been set on this AnimatorSet - * and each of the child animations will use their own duration. - * - * @return The length of the animation, in milliseconds, of each of the child - * animations of this AnimatorSet. - */ - @Override - public long getDuration() { - return mDuration; - } - - /** - * Sets the length of each of the current child animations of this AnimatorSet. By default, - * each child animation will use its own duration. If the duration is set on the AnimatorSet, - * then each child animation inherits this duration. - * - * @param duration The length of the animation, in milliseconds, of each of the child - * animations of this AnimatorSet. - */ - @Override - public AnimatorSet setDuration(long duration) { - if (duration < 0) { - throw new IllegalArgumentException("duration must be a value of zero or greater"); - } - for (Node node : mNodes) { - // TODO: don't set the duration of the timing-only nodes created by AnimatorSet to - // insert "play-after" delays - node.animation.setDuration(duration); - } - mDuration = duration; - return this; - } - - @Override - public void setupStartValues() { - for (Node node : mNodes) { - node.animation.setupStartValues(); - } - } - - @Override - public void setupEndValues() { - for (Node node : mNodes) { - node.animation.setupEndValues(); - } - } - - /** - * {@inheritDoc} - * - *

Starting this AnimatorSet will, in turn, start the animations for which - * it is responsible. The details of when exactly those animations are started depends on - * the dependency relationships that have been set up between the animations. - */ - @Override - public void start() { - mTerminated = false; - mStarted = true; - - // First, sort the nodes (if necessary). This will ensure that sortedNodes - // contains the animation nodes in the correct order. - sortNodes(); - - int numSortedNodes = mSortedNodes.size(); - for (int i = 0; i < numSortedNodes; ++i) { - Node node = mSortedNodes.get(i); - // First, clear out the old listeners - ArrayList oldListeners = node.animation.getListeners(); - if (oldListeners != null && oldListeners.size() > 0) { - final ArrayList clonedListeners = new - ArrayList(oldListeners); - - for (AnimatorListener listener : clonedListeners) { - if (listener instanceof DependencyListener || - listener instanceof AnimatorSetListener) { - node.animation.removeListener(listener); - } - } - } - } - - // nodesToStart holds the list of nodes to be started immediately. We don't want to - // start the animations in the loop directly because we first need to set up - // dependencies on all of the nodes. For example, we don't want to start an animation - // when some other animation also wants to start when the first animation begins. - final ArrayList nodesToStart = new ArrayList(); - for (int i = 0; i < numSortedNodes; ++i) { - Node node = mSortedNodes.get(i); - if (mSetListener == null) { - mSetListener = new AnimatorSetListener(this); - } - if (node.dependencies == null || node.dependencies.size() == 0) { - nodesToStart.add(node); - } else { - int numDependencies = node.dependencies.size(); - for (int j = 0; j < numDependencies; ++j) { - Dependency dependency = node.dependencies.get(j); - dependency.node.animation.addListener( - new DependencyListener(this, node, dependency.rule)); - } - node.tmpDependencies = (ArrayList) node.dependencies.clone(); - } - node.animation.addListener(mSetListener); - } - // Now that all dependencies are set up, start the animations that should be started. - if (mStartDelay <= 0) { - for (Node node : nodesToStart) { - node.animation.start(); - mPlayingSet.add(node.animation); - } - } else { - mDelayAnim = ValueAnimator.ofFloat(0f, 1f); - mDelayAnim.setDuration(mStartDelay); - mDelayAnim.addListener(new AnimatorListenerAdapter() { - boolean canceled = false; - public void onAnimationCancel(Animator anim) { - canceled = true; - } - public void onAnimationEnd(Animator anim) { - if (!canceled) { - int numNodes = nodesToStart.size(); - for (int i = 0; i < numNodes; ++i) { - Node node = nodesToStart.get(i); - node.animation.start(); - mPlayingSet.add(node.animation); - } - } - } - }); - mDelayAnim.start(); - } - if (mListeners != null) { - ArrayList tmpListeners = - (ArrayList) mListeners.clone(); - int numListeners = tmpListeners.size(); - for (int i = 0; i < numListeners; ++i) { - tmpListeners.get(i).onAnimationStart(this); - } - } - if (mNodes.size() == 0 && mStartDelay == 0) { - // Handle unusual case where empty AnimatorSet is started - should send out - // end event immediately since the event will not be sent out at all otherwise - mStarted = false; - if (mListeners != null) { - ArrayList tmpListeners = - (ArrayList) mListeners.clone(); - int numListeners = tmpListeners.size(); - for (int i = 0; i < numListeners; ++i) { - tmpListeners.get(i).onAnimationEnd(this); - } - } - } - } - - @Override - public AnimatorSet clone() { - final AnimatorSet anim = (AnimatorSet) super.clone(); - /* - * The basic clone() operation copies all items. This doesn't work very well for - * AnimatorSet, because it will copy references that need to be recreated and state - * that may not apply. What we need to do now is put the clone in an uninitialized - * state, with fresh, empty data structures. Then we will build up the nodes list - * manually, as we clone each Node (and its animation). The clone will then be sorted, - * and will populate any appropriate lists, when it is started. - */ - anim.mNeedsSort = true; - anim.mTerminated = false; - anim.mStarted = false; - anim.mPlayingSet = new ArrayList(); - anim.mNodeMap = new HashMap(); - anim.mNodes = new ArrayList(); - anim.mSortedNodes = new ArrayList(); - - // Walk through the old nodes list, cloning each node and adding it to the new nodemap. - // One problem is that the old node dependencies point to nodes in the old AnimatorSet. - // We need to track the old/new nodes in order to reconstruct the dependencies in the clone. - HashMap nodeCloneMap = new HashMap(); // - for (Node node : mNodes) { - Node nodeClone = node.clone(); - nodeCloneMap.put(node, nodeClone); - anim.mNodes.add(nodeClone); - anim.mNodeMap.put(nodeClone.animation, nodeClone); - // Clear out the dependencies in the clone; we'll set these up manually later - nodeClone.dependencies = null; - nodeClone.tmpDependencies = null; - nodeClone.nodeDependents = null; - nodeClone.nodeDependencies = null; - // clear out any listeners that were set up by the AnimatorSet; these will - // be set up when the clone's nodes are sorted - ArrayList cloneListeners = nodeClone.animation.getListeners(); - if (cloneListeners != null) { - ArrayList listenersToRemove = null; - for (AnimatorListener listener : cloneListeners) { - if (listener instanceof AnimatorSetListener) { - if (listenersToRemove == null) { - listenersToRemove = new ArrayList(); - } - listenersToRemove.add(listener); - } - } - if (listenersToRemove != null) { - for (AnimatorListener listener : listenersToRemove) { - cloneListeners.remove(listener); - } - } - } - } - // Now that we've cloned all of the nodes, we're ready to walk through their - // dependencies, mapping the old dependencies to the new nodes - for (Node node : mNodes) { - Node nodeClone = nodeCloneMap.get(node); - if (node.dependencies != null) { - for (Dependency dependency : node.dependencies) { - Node clonedDependencyNode = nodeCloneMap.get(dependency.node); - Dependency cloneDependency = new Dependency(clonedDependencyNode, - dependency.rule); - nodeClone.addDependency(cloneDependency); - } - } - } - - return anim; - } - - /** - * This class is the mechanism by which animations are started based on events in other - * animations. If an animation has multiple dependencies on other animations, then - * all dependencies must be satisfied before the animation is started. - */ - private static class DependencyListener implements AnimatorListener { - - private AnimatorSet mAnimatorSet; - - // The node upon which the dependency is based. - private Node mNode; - - // The Dependency rule (WITH or AFTER) that the listener should wait for on - // the node - private int mRule; - - public DependencyListener(AnimatorSet animatorSet, Node node, int rule) { - this.mAnimatorSet = animatorSet; - this.mNode = node; - this.mRule = rule; - } - - /** - * Ignore cancel events for now. We may want to handle this eventually, - * to prevent follow-on animations from running when some dependency - * animation is canceled. - */ - public void onAnimationCancel(Animator animation) { - } - - /** - * An end event is received - see if this is an event we are listening for - */ - public void onAnimationEnd(Animator animation) { - if (mRule == Dependency.AFTER) { - startIfReady(animation); - } - } - - /** - * Ignore repeat events for now - */ - public void onAnimationRepeat(Animator animation) { - } - - /** - * A start event is received - see if this is an event we are listening for - */ - public void onAnimationStart(Animator animation) { - if (mRule == Dependency.WITH) { - startIfReady(animation); - } - } - - /** - * Check whether the event received is one that the node was waiting for. - * If so, mark it as complete and see whether it's time to start - * the animation. - * @param dependencyAnimation the animation that sent the event. - */ - private void startIfReady(Animator dependencyAnimation) { - if (mAnimatorSet.mTerminated) { - // if the parent AnimatorSet was canceled, then don't start any dependent anims - return; - } - Dependency dependencyToRemove = null; - int numDependencies = mNode.tmpDependencies.size(); - for (int i = 0; i < numDependencies; ++i) { - Dependency dependency = mNode.tmpDependencies.get(i); - if (dependency.rule == mRule && - dependency.node.animation == dependencyAnimation) { - // rule fired - remove the dependency and listener and check to - // see whether it's time to start the animation - dependencyToRemove = dependency; - dependencyAnimation.removeListener(this); - break; - } - } - mNode.tmpDependencies.remove(dependencyToRemove); - if (mNode.tmpDependencies.size() == 0) { - // all dependencies satisfied: start the animation - mNode.animation.start(); - mAnimatorSet.mPlayingSet.add(mNode.animation); - } - } - - } - - private class AnimatorSetListener implements AnimatorListener { - - private AnimatorSet mAnimatorSet; - - AnimatorSetListener(AnimatorSet animatorSet) { - mAnimatorSet = animatorSet; - } - - public void onAnimationCancel(Animator animation) { - if (!mTerminated) { - // Listeners are already notified of the AnimatorSet canceling in cancel(). - // The logic below only kicks in when animations end normally - if (mPlayingSet.size() == 0) { - if (mListeners != null) { - int numListeners = mListeners.size(); - for (int i = 0; i < numListeners; ++i) { - mListeners.get(i).onAnimationCancel(mAnimatorSet); - } - } - } - } - } - - public void onAnimationEnd(Animator animation) { - animation.removeListener(this); - mPlayingSet.remove(animation); - Node animNode = mAnimatorSet.mNodeMap.get(animation); - animNode.done = true; - if (!mTerminated) { - // Listeners are already notified of the AnimatorSet ending in cancel() or - // end(); the logic below only kicks in when animations end normally - ArrayList sortedNodes = mAnimatorSet.mSortedNodes; - boolean allDone = true; - int numSortedNodes = sortedNodes.size(); - for (int i = 0; i < numSortedNodes; ++i) { - if (!sortedNodes.get(i).done) { - allDone = false; - break; - } - } - if (allDone) { - // If this was the last child animation to end, then notify listeners that this - // AnimatorSet has ended - if (mListeners != null) { - ArrayList tmpListeners = - (ArrayList) mListeners.clone(); - int numListeners = tmpListeners.size(); - for (int i = 0; i < numListeners; ++i) { - tmpListeners.get(i).onAnimationEnd(mAnimatorSet); - } - } - mAnimatorSet.mStarted = false; - } - } - } - - // Nothing to do - public void onAnimationRepeat(Animator animation) { - } - - // Nothing to do - public void onAnimationStart(Animator animation) { - } - - } - - /** - * This method sorts the current set of nodes, if needed. The sort is a simple - * DependencyGraph sort, which goes like this: - * - All nodes without dependencies become 'roots' - * - while roots list is not null - * - for each root r - * - add r to sorted list - * - remove r as a dependency from any other node - * - any nodes with no dependencies are added to the roots list - */ - private void sortNodes() { - if (mNeedsSort) { - mSortedNodes.clear(); - ArrayList roots = new ArrayList(); - int numNodes = mNodes.size(); - for (int i = 0; i < numNodes; ++i) { - Node node = mNodes.get(i); - if (node.dependencies == null || node.dependencies.size() == 0) { - roots.add(node); - } - } - ArrayList tmpRoots = new ArrayList(); - while (roots.size() > 0) { - int numRoots = roots.size(); - for (int i = 0; i < numRoots; ++i) { - Node root = roots.get(i); - mSortedNodes.add(root); - if (root.nodeDependents != null) { - int numDependents = root.nodeDependents.size(); - for (int j = 0; j < numDependents; ++j) { - Node node = root.nodeDependents.get(j); - node.nodeDependencies.remove(root); - if (node.nodeDependencies.size() == 0) { - tmpRoots.add(node); - } - } - } - } - roots.clear(); - roots.addAll(tmpRoots); - tmpRoots.clear(); - } - mNeedsSort = false; - if (mSortedNodes.size() != mNodes.size()) { - throw new IllegalStateException("Circular dependencies cannot exist" - + " in AnimatorSet"); - } - } else { - // Doesn't need sorting, but still need to add in the nodeDependencies list - // because these get removed as the event listeners fire and the dependencies - // are satisfied - int numNodes = mNodes.size(); - for (int i = 0; i < numNodes; ++i) { - Node node = mNodes.get(i); - if (node.dependencies != null && node.dependencies.size() > 0) { - int numDependencies = node.dependencies.size(); - for (int j = 0; j < numDependencies; ++j) { - Dependency dependency = node.dependencies.get(j); - if (node.nodeDependencies == null) { - node.nodeDependencies = new ArrayList(); - } - if (!node.nodeDependencies.contains(dependency.node)) { - node.nodeDependencies.add(dependency.node); - } - } - } - // nodes are 'done' by default; they become un-done when started, and done - // again when ended - node.done = false; - } - } - } - - /** - * Dependency holds information about the node that some other node is - * dependent upon and the nature of that dependency. - * - */ - private static class Dependency { - static final int WITH = 0; // dependent node must start with this dependency node - static final int AFTER = 1; // dependent node must start when this dependency node finishes - - // The node that the other node with this Dependency is dependent upon - public Node node; - - // The nature of the dependency (WITH or AFTER) - public int rule; - - public Dependency(Node node, int rule) { - this.node = node; - this.rule = rule; - } - } - - /** - * A Node is an embodiment of both the Animator that it wraps as well as - * any dependencies that are associated with that Animation. This includes - * both dependencies upon other nodes (in the dependencies list) as - * well as dependencies of other nodes upon this (in the nodeDependents list). - */ - private static class Node implements Cloneable { - public Animator animation; - - /** - * These are the dependencies that this node's animation has on other - * nodes. For example, if this node's animation should begin with some - * other animation ends, then there will be an item in this node's - * dependencies list for that other animation's node. - */ - public ArrayList dependencies = null; - - /** - * tmpDependencies is a runtime detail. We use the dependencies list for sorting. - * But we also use the list to keep track of when multiple dependencies are satisfied, - * but removing each dependency as it is satisfied. We do not want to remove - * the dependency itself from the list, because we need to retain that information - * if the AnimatorSet is launched in the future. So we create a copy of the dependency - * list when the AnimatorSet starts and use this tmpDependencies list to track the - * list of satisfied dependencies. - */ - public ArrayList tmpDependencies = null; - - /** - * nodeDependencies is just a list of the nodes that this Node is dependent upon. - * This information is used in sortNodes(), to determine when a node is a root. - */ - public ArrayList nodeDependencies = null; - - /** - * nodeDepdendents is the list of nodes that have this node as a dependency. This - * is a utility field used in sortNodes to facilitate removing this node as a - * dependency when it is a root node. - */ - public ArrayList nodeDependents = null; - - /** - * Flag indicating whether the animation in this node is finished. This flag - * is used by AnimatorSet to check, as each animation ends, whether all child animations - * are done and it's time to send out an end event for the entire AnimatorSet. - */ - public boolean done = false; - - /** - * Constructs the Node with the animation that it encapsulates. A Node has no - * dependencies by default; dependencies are added via the addDependency() - * method. - * - * @param animation The animation that the Node encapsulates. - */ - public Node(Animator animation) { - this.animation = animation; - } - - /** - * Add a dependency to this Node. The dependency includes information about the - * node that this node is dependency upon and the nature of the dependency. - * @param dependency - */ - public void addDependency(Dependency dependency) { - if (dependencies == null) { - dependencies = new ArrayList(); - nodeDependencies = new ArrayList(); - } - dependencies.add(dependency); - if (!nodeDependencies.contains(dependency.node)) { - nodeDependencies.add(dependency.node); - } - Node dependencyNode = dependency.node; - if (dependencyNode.nodeDependents == null) { - dependencyNode.nodeDependents = new ArrayList(); - } - dependencyNode.nodeDependents.add(this); - } - - @Override - public Node clone() { - try { - Node node = (Node) super.clone(); - node.animation = animation.clone(); - return node; - } catch (CloneNotSupportedException e) { - throw new AssertionError(); - } - } - } - - /** - * The Builder object is a utility class to facilitate adding animations to a - * AnimatorSet along with the relationships between the various animations. The - * intention of the Builder methods, along with the {@link - * AnimatorSet#play(Animator) play()} method of AnimatorSet is to make it possible - * to express the dependency relationships of animations in a natural way. Developers can also - * use the {@link AnimatorSet#playTogether(Animator[]) playTogether()} and {@link - * AnimatorSet#playSequentially(Animator[]) playSequentially()} methods if these suit the need, - * but it might be easier in some situations to express the AnimatorSet of animations in pairs. - *

- *

The Builder object cannot be constructed directly, but is rather constructed - * internally via a call to {@link AnimatorSet#play(Animator)}.

- *

- *

For example, this sets up a AnimatorSet to play anim1 and anim2 at the same time, anim3 to - * play when anim2 finishes, and anim4 to play when anim3 finishes:

- *
-     *     AnimatorSet s = new AnimatorSet();
-     *     s.play(anim1).with(anim2);
-     *     s.play(anim2).before(anim3);
-     *     s.play(anim4).after(anim3);
-     * 
- *

- *

Note in the example that both {@link Builder#before(Animator)} and {@link - * Builder#after(Animator)} are used. These are just different ways of expressing the same - * relationship and are provided to make it easier to say things in a way that is more natural, - * depending on the situation.

- *

- *

It is possible to make several calls into the same Builder object to express - * multiple relationships. However, note that it is only the animation passed into the initial - * {@link AnimatorSet#play(Animator)} method that is the dependency in any of the successive - * calls to the Builder object. For example, the following code starts both anim2 - * and anim3 when anim1 ends; there is no direct dependency relationship between anim2 and - * anim3: - *

-     *   AnimatorSet s = new AnimatorSet();
-     *   s.play(anim1).before(anim2).before(anim3);
-     * 
- * If the desired result is to play anim1 then anim2 then anim3, this code expresses the - * relationship correctly:

- *
-     *   AnimatorSet s = new AnimatorSet();
-     *   s.play(anim1).before(anim2);
-     *   s.play(anim2).before(anim3);
-     * 
- *

- *

Note that it is possible to express relationships that cannot be resolved and will not - * result in sensible results. For example, play(anim1).after(anim1) makes no - * sense. In general, circular dependencies like this one (or more indirect ones where a depends - * on b, which depends on c, which depends on a) should be avoided. Only create AnimatorSets - * that can boil down to a simple, one-way relationship of animations starting with, before, and - * after other, different, animations.

- */ - public class Builder { - - /** - * This tracks the current node being processed. It is supplied to the play() method - * of AnimatorSet and passed into the constructor of Builder. - */ - private Node mCurrentNode; - - /** - * package-private constructor. Builders are only constructed by AnimatorSet, when the - * play() method is called. - * - * @param anim The animation that is the dependency for the other animations passed into - * the other methods of this Builder object. - */ - Builder(Animator anim) { - mCurrentNode = mNodeMap.get(anim); - if (mCurrentNode == null) { - mCurrentNode = new Node(anim); - mNodeMap.put(anim, mCurrentNode); - mNodes.add(mCurrentNode); - } - } - - /** - * Sets up the given animation to play at the same time as the animation supplied in the - * {@link AnimatorSet#play(Animator)} call that created this Builder object. - * - * @param anim The animation that will play when the animation supplied to the - * {@link AnimatorSet#play(Animator)} method starts. - */ - public Builder with(Animator anim) { - Node node = mNodeMap.get(anim); - if (node == null) { - node = new Node(anim); - mNodeMap.put(anim, node); - mNodes.add(node); - } - Dependency dependency = new Dependency(mCurrentNode, Dependency.WITH); - node.addDependency(dependency); - return this; - } - - /** - * Sets up the given animation to play when the animation supplied in the - * {@link AnimatorSet#play(Animator)} call that created this Builder object - * ends. - * - * @param anim The animation that will play when the animation supplied to the - * {@link AnimatorSet#play(Animator)} method ends. - */ - public Builder before(Animator anim) { - Node node = mNodeMap.get(anim); - if (node == null) { - node = new Node(anim); - mNodeMap.put(anim, node); - mNodes.add(node); - } - Dependency dependency = new Dependency(mCurrentNode, Dependency.AFTER); - node.addDependency(dependency); - return this; - } - - /** - * Sets up the given animation to play when the animation supplied in the - * {@link AnimatorSet#play(Animator)} call that created this Builder object - * to start when the animation supplied in this method call ends. - * - * @param anim The animation whose end will cause the animation supplied to the - * {@link AnimatorSet#play(Animator)} method to play. - */ - public Builder after(Animator anim) { - Node node = mNodeMap.get(anim); - if (node == null) { - node = new Node(anim); - mNodeMap.put(anim, node); - mNodes.add(node); - } - Dependency dependency = new Dependency(node, Dependency.AFTER); - mCurrentNode.addDependency(dependency); - return this; - } - - /** - * Sets up the animation supplied in the - * {@link AnimatorSet#play(Animator)} call that created this Builder object - * to play when the given amount of time elapses. - * - * @param delay The number of milliseconds that should elapse before the - * animation starts. - */ - public Builder after(long delay) { - // setup dummy ValueAnimator just to run the clock - ValueAnimator anim = ValueAnimator.ofFloat(0f, 1f); - anim.setDuration(delay); - after(anim); - return this; - } - - } - -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatEvaluator.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatEvaluator.java deleted file mode 100644 index e41019364..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatEvaluator.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; - -/** - * This evaluator can be used to perform type interpolation between float values. - */ -public class FloatEvaluator implements TypeEvaluator { - - /** - * This function returns the result of linearly interpolating the start and end values, with - * fraction representing the proportion between the start and end values. The - * calculation is a simple parametric calculation: result = x0 + t * (v1 - v0), - * where x0 is startValue, x1 is endValue, - * and t is fraction. - * - * @param fraction The fraction from the starting to the ending values - * @param startValue The start value; should be of type float or - * Float - * @param endValue The end value; should be of type float or Float - * @return A linear interpolation between the start and end values, given the - * fraction parameter. - */ - public Float evaluate(float fraction, Number startValue, Number endValue) { - float startFloat = startValue.floatValue(); - return startFloat + fraction * (endValue.floatValue() - startFloat); - } -} \ No newline at end of file diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatKeyframeSet.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatKeyframeSet.java deleted file mode 100644 index 6d9dafa7a..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatKeyframeSet.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; - -import java.util.ArrayList; -import android.view.animation.Interpolator; - -import com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.FloatKeyframe; - -/** - * This class holds a collection of FloatKeyframe objects and is called by ValueAnimator to calculate - * values between those keyframes for a given animation. The class internal to the animation - * package because it is an implementation detail of how Keyframes are stored and used. - * - *

This type-specific subclass of KeyframeSet, along with the other type-specific subclass for - * int, exists to speed up the getValue() method when there is no custom - * TypeEvaluator set for the animation, so that values can be calculated without autoboxing to the - * Object equivalents of these primitive types.

- */ -@SuppressWarnings("unchecked") -class FloatKeyframeSet extends KeyframeSet { - private float firstValue; - private float lastValue; - private float deltaValue; - private boolean firstTime = true; - - public FloatKeyframeSet(FloatKeyframe... keyframes) { - super(keyframes); - } - - @Override - public Object getValue(float fraction) { - return getFloatValue(fraction); - } - - @Override - public FloatKeyframeSet clone() { - ArrayList keyframes = mKeyframes; - int numKeyframes = mKeyframes.size(); - FloatKeyframe[] newKeyframes = new FloatKeyframe[numKeyframes]; - for (int i = 0; i < numKeyframes; ++i) { - newKeyframes[i] = (FloatKeyframe) keyframes.get(i).clone(); - } - FloatKeyframeSet newSet = new FloatKeyframeSet(newKeyframes); - return newSet; - } - - public float getFloatValue(float fraction) { - if (mNumKeyframes == 2) { - if (firstTime) { - firstTime = false; - firstValue = ((FloatKeyframe) mKeyframes.get(0)).getFloatValue(); - lastValue = ((FloatKeyframe) mKeyframes.get(1)).getFloatValue(); - deltaValue = lastValue - firstValue; - } - if (mInterpolator != null) { - fraction = mInterpolator.getInterpolation(fraction); - } - if (mEvaluator == null) { - return firstValue + fraction * deltaValue; - } else { - return ((Number)mEvaluator.evaluate(fraction, firstValue, lastValue)).floatValue(); - } - } - if (fraction <= 0f) { - final FloatKeyframe prevKeyframe = (FloatKeyframe) mKeyframes.get(0); - final FloatKeyframe nextKeyframe = (FloatKeyframe) mKeyframes.get(1); - float prevValue = prevKeyframe.getFloatValue(); - float nextValue = nextKeyframe.getFloatValue(); - float prevFraction = prevKeyframe.getFraction(); - float nextFraction = nextKeyframe.getFraction(); - final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator(); - if (interpolator != null) { - fraction = interpolator.getInterpolation(fraction); - } - float intervalFraction = (fraction - prevFraction) / (nextFraction - prevFraction); - return mEvaluator == null ? - prevValue + intervalFraction * (nextValue - prevValue) : - ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)). - floatValue(); - } else if (fraction >= 1f) { - final FloatKeyframe prevKeyframe = (FloatKeyframe) mKeyframes.get(mNumKeyframes - 2); - final FloatKeyframe nextKeyframe = (FloatKeyframe) mKeyframes.get(mNumKeyframes - 1); - float prevValue = prevKeyframe.getFloatValue(); - float nextValue = nextKeyframe.getFloatValue(); - float prevFraction = prevKeyframe.getFraction(); - float nextFraction = nextKeyframe.getFraction(); - final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator(); - if (interpolator != null) { - fraction = interpolator.getInterpolation(fraction); - } - float intervalFraction = (fraction - prevFraction) / (nextFraction - prevFraction); - return mEvaluator == null ? - prevValue + intervalFraction * (nextValue - prevValue) : - ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)). - floatValue(); - } - FloatKeyframe prevKeyframe = (FloatKeyframe) mKeyframes.get(0); - for (int i = 1; i < mNumKeyframes; ++i) { - FloatKeyframe nextKeyframe = (FloatKeyframe) mKeyframes.get(i); - if (fraction < nextKeyframe.getFraction()) { - final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator(); - if (interpolator != null) { - fraction = interpolator.getInterpolation(fraction); - } - float intervalFraction = (fraction - prevKeyframe.getFraction()) / - (nextKeyframe.getFraction() - prevKeyframe.getFraction()); - float prevValue = prevKeyframe.getFloatValue(); - float nextValue = nextKeyframe.getFloatValue(); - return mEvaluator == null ? - prevValue + intervalFraction * (nextValue - prevValue) : - ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)). - floatValue(); - } - prevKeyframe = nextKeyframe; - } - // shouldn't get here - return ((Number)mKeyframes.get(mNumKeyframes - 1).getValue()).floatValue(); - } - -} - diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntEvaluator.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntEvaluator.java deleted file mode 100644 index ed5e79ec6..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntEvaluator.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; - -/** - * This evaluator can be used to perform type interpolation between int values. - */ -public class IntEvaluator implements TypeEvaluator { - - /** - * This function returns the result of linearly interpolating the start and end values, with - * fraction representing the proportion between the start and end values. The - * calculation is a simple parametric calculation: result = x0 + t * (v1 - v0), - * where x0 is startValue, x1 is endValue, - * and t is fraction. - * - * @param fraction The fraction from the starting to the ending values - * @param startValue The start value; should be of type int or - * Integer - * @param endValue The end value; should be of type int or Integer - * @return A linear interpolation between the start and end values, given the - * fraction parameter. - */ - public Integer evaluate(float fraction, Integer startValue, Integer endValue) { - int startInt = startValue; - return (int)(startInt + fraction * (endValue - startInt)); - } -} \ No newline at end of file diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntKeyframeSet.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntKeyframeSet.java deleted file mode 100644 index e9215e7f8..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntKeyframeSet.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; - -import java.util.ArrayList; -import android.view.animation.Interpolator; - -import com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.IntKeyframe; - -/** - * This class holds a collection of IntKeyframe objects and is called by ValueAnimator to calculate - * values between those keyframes for a given animation. The class internal to the animation - * package because it is an implementation detail of how Keyframes are stored and used. - * - *

This type-specific subclass of KeyframeSet, along with the other type-specific subclass for - * float, exists to speed up the getValue() method when there is no custom - * TypeEvaluator set for the animation, so that values can be calculated without autoboxing to the - * Object equivalents of these primitive types.

- */ -@SuppressWarnings("unchecked") -class IntKeyframeSet extends KeyframeSet { - private int firstValue; - private int lastValue; - private int deltaValue; - private boolean firstTime = true; - - public IntKeyframeSet(IntKeyframe... keyframes) { - super(keyframes); - } - - @Override - public Object getValue(float fraction) { - return getIntValue(fraction); - } - - @Override - public IntKeyframeSet clone() { - ArrayList keyframes = mKeyframes; - int numKeyframes = mKeyframes.size(); - IntKeyframe[] newKeyframes = new IntKeyframe[numKeyframes]; - for (int i = 0; i < numKeyframes; ++i) { - newKeyframes[i] = (IntKeyframe) keyframes.get(i).clone(); - } - IntKeyframeSet newSet = new IntKeyframeSet(newKeyframes); - return newSet; - } - - public int getIntValue(float fraction) { - if (mNumKeyframes == 2) { - if (firstTime) { - firstTime = false; - firstValue = ((IntKeyframe) mKeyframes.get(0)).getIntValue(); - lastValue = ((IntKeyframe) mKeyframes.get(1)).getIntValue(); - deltaValue = lastValue - firstValue; - } - if (mInterpolator != null) { - fraction = mInterpolator.getInterpolation(fraction); - } - if (mEvaluator == null) { - return firstValue + (int)(fraction * deltaValue); - } else { - return ((Number)mEvaluator.evaluate(fraction, firstValue, lastValue)).intValue(); - } - } - if (fraction <= 0f) { - final IntKeyframe prevKeyframe = (IntKeyframe) mKeyframes.get(0); - final IntKeyframe nextKeyframe = (IntKeyframe) mKeyframes.get(1); - int prevValue = prevKeyframe.getIntValue(); - int nextValue = nextKeyframe.getIntValue(); - float prevFraction = prevKeyframe.getFraction(); - float nextFraction = nextKeyframe.getFraction(); - final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator(); - if (interpolator != null) { - fraction = interpolator.getInterpolation(fraction); - } - float intervalFraction = (fraction - prevFraction) / (nextFraction - prevFraction); - return mEvaluator == null ? - prevValue + (int)(intervalFraction * (nextValue - prevValue)) : - ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)). - intValue(); - } else if (fraction >= 1f) { - final IntKeyframe prevKeyframe = (IntKeyframe) mKeyframes.get(mNumKeyframes - 2); - final IntKeyframe nextKeyframe = (IntKeyframe) mKeyframes.get(mNumKeyframes - 1); - int prevValue = prevKeyframe.getIntValue(); - int nextValue = nextKeyframe.getIntValue(); - float prevFraction = prevKeyframe.getFraction(); - float nextFraction = nextKeyframe.getFraction(); - final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator(); - if (interpolator != null) { - fraction = interpolator.getInterpolation(fraction); - } - float intervalFraction = (fraction - prevFraction) / (nextFraction - prevFraction); - return mEvaluator == null ? - prevValue + (int)(intervalFraction * (nextValue - prevValue)) : - ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)).intValue(); - } - IntKeyframe prevKeyframe = (IntKeyframe) mKeyframes.get(0); - for (int i = 1; i < mNumKeyframes; ++i) { - IntKeyframe nextKeyframe = (IntKeyframe) mKeyframes.get(i); - if (fraction < nextKeyframe.getFraction()) { - final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator(); - if (interpolator != null) { - fraction = interpolator.getInterpolation(fraction); - } - float intervalFraction = (fraction - prevKeyframe.getFraction()) / - (nextKeyframe.getFraction() - prevKeyframe.getFraction()); - int prevValue = prevKeyframe.getIntValue(); - int nextValue = nextKeyframe.getIntValue(); - return mEvaluator == null ? - prevValue + (int)(intervalFraction * (nextValue - prevValue)) : - ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)). - intValue(); - } - prevKeyframe = nextKeyframe; - } - // shouldn't get here - return ((Number)mKeyframes.get(mNumKeyframes - 1).getValue()).intValue(); - } - -} - diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/Keyframe.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/Keyframe.java deleted file mode 100644 index ab76fa7f6..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/Keyframe.java +++ /dev/null @@ -1,361 +0,0 @@ -/* - * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; - -import android.view.animation.Interpolator; - -/** - * This class holds a time/value pair for an animation. The Keyframe class is used - * by {@link ValueAnimator} to define the values that the animation target will have over the course - * of the animation. As the time proceeds from one keyframe to the other, the value of the - * target object will animate between the value at the previous keyframe and the value at the - * next keyframe. Each keyframe also holds an optional {@link TimeInterpolator} - * object, which defines the time interpolation over the intervalue preceding the keyframe. - * - *

The Keyframe class itself is abstract. The type-specific factory methods will return - * a subclass of Keyframe specific to the type of value being stored. This is done to improve - * performance when dealing with the most common cases (e.g., float and - * int values). Other types will fall into a more general Keyframe class that - * treats its values as Objects. Unless your animation requires dealing with a custom type - * or a data structure that needs to be animated directly (and evaluated using an implementation - * of {@link TypeEvaluator}), you should stick to using float and int as animations using those - * types have lower runtime overhead than other types.

- */ -@SuppressWarnings("rawtypes") -public abstract class Keyframe implements Cloneable { - /** - * The time at which mValue will hold true. - */ - float mFraction; - - /** - * The type of the value in this Keyframe. This type is determined at construction time, - * based on the type of the value object passed into the constructor. - */ - Class mValueType; - - /** - * The optional time interpolator for the interval preceding this keyframe. A null interpolator - * (the default) results in linear interpolation over the interval. - */ - private /*Time*/Interpolator mInterpolator = null; - - /** - * Flag to indicate whether this keyframe has a valid value. This flag is used when an - * animation first starts, to populate placeholder keyframes with real values derived - * from the target object. - */ - boolean mHasValue = false; - - /** - * Constructs a Keyframe object with the given time and value. The time defines the - * time, as a proportion of an overall animation's duration, at which the value will hold true - * for the animation. The value for the animation between keyframes will be calculated as - * an interpolation between the values at those keyframes. - * - * @param fraction The time, expressed as a value between 0 and 1, representing the fraction - * of time elapsed of the overall animation duration. - * @param value The value that the object will animate to as the animation time approaches - * the time in this keyframe, and the the value animated from as the time passes the time in - * this keyframe. - */ - public static Keyframe ofInt(float fraction, int value) { - return new IntKeyframe(fraction, value); - } - - /** - * Constructs a Keyframe object with the given time. The value at this time will be derived - * from the target object when the animation first starts (note that this implies that keyframes - * with no initial value must be used as part of an {@link ObjectAnimator}). - * The time defines the - * time, as a proportion of an overall animation's duration, at which the value will hold true - * for the animation. The value for the animation between keyframes will be calculated as - * an interpolation between the values at those keyframes. - * - * @param fraction The time, expressed as a value between 0 and 1, representing the fraction - * of time elapsed of the overall animation duration. - */ - public static Keyframe ofInt(float fraction) { - return new IntKeyframe(fraction); - } - - /** - * Constructs a Keyframe object with the given time and value. The time defines the - * time, as a proportion of an overall animation's duration, at which the value will hold true - * for the animation. The value for the animation between keyframes will be calculated as - * an interpolation between the values at those keyframes. - * - * @param fraction The time, expressed as a value between 0 and 1, representing the fraction - * of time elapsed of the overall animation duration. - * @param value The value that the object will animate to as the animation time approaches - * the time in this keyframe, and the the value animated from as the time passes the time in - * this keyframe. - */ - public static Keyframe ofFloat(float fraction, float value) { - return new FloatKeyframe(fraction, value); - } - - /** - * Constructs a Keyframe object with the given time. The value at this time will be derived - * from the target object when the animation first starts (note that this implies that keyframes - * with no initial value must be used as part of an {@link ObjectAnimator}). - * The time defines the - * time, as a proportion of an overall animation's duration, at which the value will hold true - * for the animation. The value for the animation between keyframes will be calculated as - * an interpolation between the values at those keyframes. - * - * @param fraction The time, expressed as a value between 0 and 1, representing the fraction - * of time elapsed of the overall animation duration. - */ - public static Keyframe ofFloat(float fraction) { - return new FloatKeyframe(fraction); - } - - /** - * Constructs a Keyframe object with the given time and value. The time defines the - * time, as a proportion of an overall animation's duration, at which the value will hold true - * for the animation. The value for the animation between keyframes will be calculated as - * an interpolation between the values at those keyframes. - * - * @param fraction The time, expressed as a value between 0 and 1, representing the fraction - * of time elapsed of the overall animation duration. - * @param value The value that the object will animate to as the animation time approaches - * the time in this keyframe, and the the value animated from as the time passes the time in - * this keyframe. - */ - public static Keyframe ofObject(float fraction, Object value) { - return new ObjectKeyframe(fraction, value); - } - - /** - * Constructs a Keyframe object with the given time. The value at this time will be derived - * from the target object when the animation first starts (note that this implies that keyframes - * with no initial value must be used as part of an {@link ObjectAnimator}). - * The time defines the - * time, as a proportion of an overall animation's duration, at which the value will hold true - * for the animation. The value for the animation between keyframes will be calculated as - * an interpolation between the values at those keyframes. - * - * @param fraction The time, expressed as a value between 0 and 1, representing the fraction - * of time elapsed of the overall animation duration. - */ - public static Keyframe ofObject(float fraction) { - return new ObjectKeyframe(fraction, null); - } - - /** - * Indicates whether this keyframe has a valid value. This method is called internally when - * an {@link ObjectAnimator} first starts; keyframes without values are assigned values at - * that time by deriving the value for the property from the target object. - * - * @return boolean Whether this object has a value assigned. - */ - public boolean hasValue() { - return mHasValue; - } - - /** - * Gets the value for this Keyframe. - * - * @return The value for this Keyframe. - */ - public abstract Object getValue(); - - /** - * Sets the value for this Keyframe. - * - * @param value value for this Keyframe. - */ - public abstract void setValue(Object value); - - /** - * Gets the time for this keyframe, as a fraction of the overall animation duration. - * - * @return The time associated with this keyframe, as a fraction of the overall animation - * duration. This should be a value between 0 and 1. - */ - public float getFraction() { - return mFraction; - } - - /** - * Sets the time for this keyframe, as a fraction of the overall animation duration. - * - * @param fraction time associated with this keyframe, as a fraction of the overall animation - * duration. This should be a value between 0 and 1. - */ - public void setFraction(float fraction) { - mFraction = fraction; - } - - /** - * Gets the optional interpolator for this Keyframe. A value of null indicates - * that there is no interpolation, which is the same as linear interpolation. - * - * @return The optional interpolator for this Keyframe. - */ - public /*Time*/Interpolator getInterpolator() { - return mInterpolator; - } - - /** - * Sets the optional interpolator for this Keyframe. A value of null indicates - * that there is no interpolation, which is the same as linear interpolation. - * - * @return The optional interpolator for this Keyframe. - */ - public void setInterpolator(/*Time*/Interpolator interpolator) { - mInterpolator = interpolator; - } - - /** - * Gets the type of keyframe. This information is used by ValueAnimator to determine the type of - * {@link TypeEvaluator} to use when calculating values between keyframes. The type is based - * on the type of Keyframe created. - * - * @return The type of the value stored in the Keyframe. - */ - public Class getType() { - return mValueType; - } - - @Override - public abstract Keyframe clone(); - - /** - * This internal subclass is used for all types which are not int or float. - */ - static class ObjectKeyframe extends Keyframe { - - /** - * The value of the animation at the time mFraction. - */ - Object mValue; - - ObjectKeyframe(float fraction, Object value) { - mFraction = fraction; - mValue = value; - mHasValue = (value != null); - mValueType = mHasValue ? value.getClass() : Object.class; - } - - public Object getValue() { - return mValue; - } - - public void setValue(Object value) { - mValue = value; - mHasValue = (value != null); - } - - @Override - public ObjectKeyframe clone() { - ObjectKeyframe kfClone = new ObjectKeyframe(getFraction(), mValue); - kfClone.setInterpolator(getInterpolator()); - return kfClone; - } - } - - /** - * Internal subclass used when the keyframe value is of type int. - */ - static class IntKeyframe extends Keyframe { - - /** - * The value of the animation at the time mFraction. - */ - int mValue; - - IntKeyframe(float fraction, int value) { - mFraction = fraction; - mValue = value; - mValueType = int.class; - mHasValue = true; - } - - IntKeyframe(float fraction) { - mFraction = fraction; - mValueType = int.class; - } - - public int getIntValue() { - return mValue; - } - - public Object getValue() { - return mValue; - } - - public void setValue(Object value) { - if (value != null && value.getClass() == Integer.class) { - mValue = ((Integer)value).intValue(); - mHasValue = true; - } - } - - @Override - public IntKeyframe clone() { - IntKeyframe kfClone = new IntKeyframe(getFraction(), mValue); - kfClone.setInterpolator(getInterpolator()); - return kfClone; - } - } - - /** - * Internal subclass used when the keyframe value is of type float. - */ - static class FloatKeyframe extends Keyframe { - /** - * The value of the animation at the time mFraction. - */ - float mValue; - - FloatKeyframe(float fraction, float value) { - mFraction = fraction; - mValue = value; - mValueType = float.class; - mHasValue = true; - } - - FloatKeyframe(float fraction) { - mFraction = fraction; - mValueType = float.class; - } - - public float getFloatValue() { - return mValue; - } - - public Object getValue() { - return mValue; - } - - public void setValue(Object value) { - if (value != null && value.getClass() == Float.class) { - mValue = ((Float)value).floatValue(); - mHasValue = true; - } - } - - @Override - public FloatKeyframe clone() { - FloatKeyframe kfClone = new FloatKeyframe(getFraction(), mValue); - kfClone.setInterpolator(getInterpolator()); - return kfClone; - } - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/KeyframeSet.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/KeyframeSet.java deleted file mode 100644 index a71e1ad3c..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/KeyframeSet.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; - -import java.util.ArrayList; -import java.util.Arrays; -import android.view.animation.Interpolator; - -import com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.FloatKeyframe; -import com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.IntKeyframe; -import com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.ObjectKeyframe; - -/** - * This class holds a collection of Keyframe objects and is called by ValueAnimator to calculate - * values between those keyframes for a given animation. The class internal to the animation - * package because it is an implementation detail of how Keyframes are stored and used. - */ -@SuppressWarnings({"rawtypes", "unchecked"}) -class KeyframeSet { - - int mNumKeyframes; - - Keyframe mFirstKeyframe; - Keyframe mLastKeyframe; - /*Time*/Interpolator mInterpolator; // only used in the 2-keyframe case - ArrayList mKeyframes; // only used when there are not 2 keyframes - TypeEvaluator mEvaluator; - - - public KeyframeSet(Keyframe... keyframes) { - mNumKeyframes = keyframes.length; - mKeyframes = new ArrayList(); - mKeyframes.addAll(Arrays.asList(keyframes)); - mFirstKeyframe = mKeyframes.get(0); - mLastKeyframe = mKeyframes.get(mNumKeyframes - 1); - mInterpolator = mLastKeyframe.getInterpolator(); - } - - public static KeyframeSet ofInt(int... values) { - int numKeyframes = values.length; - IntKeyframe keyframes[] = new IntKeyframe[Math.max(numKeyframes,2)]; - if (numKeyframes == 1) { - keyframes[0] = (IntKeyframe) Keyframe.ofInt(0f); - keyframes[1] = (IntKeyframe) Keyframe.ofInt(1f, values[0]); - } else { - keyframes[0] = (IntKeyframe) Keyframe.ofInt(0f, values[0]); - for (int i = 1; i < numKeyframes; ++i) { - keyframes[i] = (IntKeyframe) Keyframe.ofInt((float) i / (numKeyframes - 1), values[i]); - } - } - return new IntKeyframeSet(keyframes); - } - - public static KeyframeSet ofFloat(float... values) { - int numKeyframes = values.length; - FloatKeyframe keyframes[] = new FloatKeyframe[Math.max(numKeyframes,2)]; - if (numKeyframes == 1) { - keyframes[0] = (FloatKeyframe) Keyframe.ofFloat(0f); - keyframes[1] = (FloatKeyframe) Keyframe.ofFloat(1f, values[0]); - } else { - keyframes[0] = (FloatKeyframe) Keyframe.ofFloat(0f, values[0]); - for (int i = 1; i < numKeyframes; ++i) { - keyframes[i] = (FloatKeyframe) Keyframe.ofFloat((float) i / (numKeyframes - 1), values[i]); - } - } - return new FloatKeyframeSet(keyframes); - } - - public static KeyframeSet ofKeyframe(Keyframe... keyframes) { - // if all keyframes of same primitive type, create the appropriate KeyframeSet - int numKeyframes = keyframes.length; - boolean hasFloat = false; - boolean hasInt = false; - boolean hasOther = false; - for (int i = 0; i < numKeyframes; ++i) { - if (keyframes[i] instanceof FloatKeyframe) { - hasFloat = true; - } else if (keyframes[i] instanceof IntKeyframe) { - hasInt = true; - } else { - hasOther = true; - } - } - if (hasFloat && !hasInt && !hasOther) { - FloatKeyframe floatKeyframes[] = new FloatKeyframe[numKeyframes]; - for (int i = 0; i < numKeyframes; ++i) { - floatKeyframes[i] = (FloatKeyframe) keyframes[i]; - } - return new FloatKeyframeSet(floatKeyframes); - } else if (hasInt && !hasFloat && !hasOther) { - IntKeyframe intKeyframes[] = new IntKeyframe[numKeyframes]; - for (int i = 0; i < numKeyframes; ++i) { - intKeyframes[i] = (IntKeyframe) keyframes[i]; - } - return new IntKeyframeSet(intKeyframes); - } else { - return new KeyframeSet(keyframes); - } - } - - public static KeyframeSet ofObject(Object... values) { - int numKeyframes = values.length; - ObjectKeyframe keyframes[] = new ObjectKeyframe[Math.max(numKeyframes,2)]; - if (numKeyframes == 1) { - keyframes[0] = (ObjectKeyframe) Keyframe.ofObject(0f); - keyframes[1] = (ObjectKeyframe) Keyframe.ofObject(1f, values[0]); - } else { - keyframes[0] = (ObjectKeyframe) Keyframe.ofObject(0f, values[0]); - for (int i = 1; i < numKeyframes; ++i) { - keyframes[i] = (ObjectKeyframe) Keyframe.ofObject((float) i / (numKeyframes - 1), values[i]); - } - } - return new KeyframeSet(keyframes); - } - - /** - * Sets the TypeEvaluator to be used when calculating animated values. This object - * is required only for KeyframeSets that are not either IntKeyframeSet or FloatKeyframeSet, - * both of which assume their own evaluator to speed up calculations with those primitive - * types. - * - * @param evaluator The TypeEvaluator to be used to calculate animated values. - */ - public void setEvaluator(TypeEvaluator evaluator) { - mEvaluator = evaluator; - } - - @Override - public KeyframeSet clone() { - ArrayList keyframes = mKeyframes; - int numKeyframes = mKeyframes.size(); - Keyframe[] newKeyframes = new Keyframe[numKeyframes]; - for (int i = 0; i < numKeyframes; ++i) { - newKeyframes[i] = keyframes.get(i).clone(); - } - KeyframeSet newSet = new KeyframeSet(newKeyframes); - return newSet; - } - - /** - * Gets the animated value, given the elapsed fraction of the animation (interpolated by the - * animation's interpolator) and the evaluator used to calculate in-between values. This - * function maps the input fraction to the appropriate keyframe interval and a fraction - * between them and returns the interpolated value. Note that the input fraction may fall - * outside the [0-1] bounds, if the animation's interpolator made that happen (e.g., a - * spring interpolation that might send the fraction past 1.0). We handle this situation by - * just using the two keyframes at the appropriate end when the value is outside those bounds. - * - * @param fraction The elapsed fraction of the animation - * @return The animated value. - */ - public Object getValue(float fraction) { - - // Special-case optimization for the common case of only two keyframes - if (mNumKeyframes == 2) { - if (mInterpolator != null) { - fraction = mInterpolator.getInterpolation(fraction); - } - return mEvaluator.evaluate(fraction, mFirstKeyframe.getValue(), - mLastKeyframe.getValue()); - } - if (fraction <= 0f) { - final Keyframe nextKeyframe = mKeyframes.get(1); - final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator(); - if (interpolator != null) { - fraction = interpolator.getInterpolation(fraction); - } - final float prevFraction = mFirstKeyframe.getFraction(); - float intervalFraction = (fraction - prevFraction) / - (nextKeyframe.getFraction() - prevFraction); - return mEvaluator.evaluate(intervalFraction, mFirstKeyframe.getValue(), - nextKeyframe.getValue()); - } else if (fraction >= 1f) { - final Keyframe prevKeyframe = mKeyframes.get(mNumKeyframes - 2); - final /*Time*/Interpolator interpolator = mLastKeyframe.getInterpolator(); - if (interpolator != null) { - fraction = interpolator.getInterpolation(fraction); - } - final float prevFraction = prevKeyframe.getFraction(); - float intervalFraction = (fraction - prevFraction) / - (mLastKeyframe.getFraction() - prevFraction); - return mEvaluator.evaluate(intervalFraction, prevKeyframe.getValue(), - mLastKeyframe.getValue()); - } - Keyframe prevKeyframe = mFirstKeyframe; - for (int i = 1; i < mNumKeyframes; ++i) { - Keyframe nextKeyframe = mKeyframes.get(i); - if (fraction < nextKeyframe.getFraction()) { - final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator(); - if (interpolator != null) { - fraction = interpolator.getInterpolation(fraction); - } - final float prevFraction = prevKeyframe.getFraction(); - float intervalFraction = (fraction - prevFraction) / - (nextKeyframe.getFraction() - prevFraction); - return mEvaluator.evaluate(intervalFraction, prevKeyframe.getValue(), - nextKeyframe.getValue()); - } - prevKeyframe = nextKeyframe; - } - // shouldn't reach here - return mLastKeyframe.getValue(); - } - - @Override - public String toString() { - String returnVal = " "; - for (int i = 0; i < mNumKeyframes; ++i) { - returnVal += mKeyframes.get(i).getValue() + " "; - } - return returnVal; - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ObjectAnimator.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ObjectAnimator.java deleted file mode 100644 index 21d15c02a..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ObjectAnimator.java +++ /dev/null @@ -1,491 +0,0 @@ -/* - * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; - -import android.util.Log; -//import android.util.Property; - -//import java.lang.reflect.Method; -import java.util.ArrayList; - -/** - * This subclass of {@link ValueAnimator} provides support for animating properties on target objects. - * The constructors of this class take parameters to define the target object that will be animated - * as well as the name of the property that will be animated. Appropriate set/get functions - * are then determined internally and the animation will call these functions as necessary to - * animate the property. - * - * @see #setPropertyName(String) - * - */ -@SuppressWarnings("rawtypes") -public final class ObjectAnimator extends ValueAnimator { - private static final boolean DBG = false; - - // The target object on which the property exists, set in the constructor - private Object mTarget; - - private String mPropertyName; - - //private Property mProperty; - - /** - * Sets the name of the property that will be animated. This name is used to derive - * a setter function that will be called to set animated values. - * For example, a property name of foo will result - * in a call to the function setFoo() on the target object. If either - * valueFrom or valueTo is null, then a getter function will - * also be derived and called. - * - *

For best performance of the mechanism that calls the setter function determined by the - * name of the property being animated, use float or int typed values, - * and make the setter function for those properties have a void return value. This - * will cause the code to take an optimized path for these constrained circumstances. Other - * property types and return types will work, but will have more overhead in processing - * the requests due to normal reflection mechanisms.

- * - *

Note that the setter function derived from this property name - * must take the same parameter type as the - * valueFrom and valueTo properties, otherwise the call to - * the setter function will fail.

- * - *

If this ObjectAnimator has been set up to animate several properties together, - * using more than one PropertyValuesHolder objects, then setting the propertyName simply - * sets the propertyName in the first of those PropertyValuesHolder objects.

- * - * @param propertyName The name of the property being animated. Should not be null. - */ - public void setPropertyName(String propertyName) { - // mValues could be null if this is being constructed piecemeal. Just record the - // propertyName to be used later when setValues() is called if so. - if (mValues != null) { - PropertyValuesHolder valuesHolder = mValues[0]; - String oldName = valuesHolder.getPropertyName(); - valuesHolder.setPropertyName(propertyName); - mValuesMap.remove(oldName); - mValuesMap.put(propertyName, valuesHolder); - } - mPropertyName = propertyName; - // New property/values/target should cause re-initialization prior to starting - mInitialized = false; - } - - /** - * Sets the property that will be animated. Property objects will take precedence over - * properties specified by the {@link #setPropertyName(String)} method. Animations should - * be set up to use one or the other, not both. - * - * @param property The property being animated. Should not be null. - */ - //public void setProperty(Property property) { - // // mValues could be null if this is being constructed piecemeal. Just record the - // // propertyName to be used later when setValues() is called if so. - // if (mValues != null) { - // PropertyValuesHolder valuesHolder = mValues[0]; - // String oldName = valuesHolder.getPropertyName(); - // valuesHolder.setProperty(property); - // mValuesMap.remove(oldName); - // mValuesMap.put(mPropertyName, valuesHolder); - // } - // if (mProperty != null) { - // mPropertyName = property.getName(); - // } - // mProperty = property; - // // New property/values/target should cause re-initialization prior to starting - // mInitialized = false; - //} - - /** - * Gets the name of the property that will be animated. This name will be used to derive - * a setter function that will be called to set animated values. - * For example, a property name of foo will result - * in a call to the function setFoo() on the target object. If either - * valueFrom or valueTo is null, then a getter function will - * also be derived and called. - */ - public String getPropertyName() { - return mPropertyName; - } - - /** - * Creates a new ObjectAnimator object. This default constructor is primarily for - * use internally; the other constructors which take parameters are more generally - * useful. - */ - public ObjectAnimator() { - } - - /** - * Private utility constructor that initializes the target object and name of the - * property being animated. - * - * @param target The object whose property is to be animated. This object should - * have a public method on it called setName(), where name is - * the value of the propertyName parameter. - * @param propertyName The name of the property being animated. - */ - private ObjectAnimator(Object target, String propertyName) { - mTarget = target; - setPropertyName(propertyName); - } - - /** - * Private utility constructor that initializes the target object and property being animated. - * - * @param target The object whose property is to be animated. - * @param property The property being animated. - */ - //private ObjectAnimator(T target, Property property) { - // mTarget = target; - // setProperty(property); - //} - - /** - * Constructs and returns an ObjectAnimator that animates between int values. A single - * value implies that that value is the one being animated to. Two values imply a starting - * and ending values. More than two values imply a starting value, values to animate through - * along the way, and an ending value (these values will be distributed evenly across - * the duration of the animation). - * - * @param target The object whose property is to be animated. This object should - * have a public method on it called setName(), where name is - * the value of the propertyName parameter. - * @param propertyName The name of the property being animated. - * @param values A set of values that the animation will animate between over time. - * @return An ObjectAnimator object that is set up to animate between the given values. - */ - public static ObjectAnimator ofInt(Object target, String propertyName, int... values) { - ObjectAnimator anim = new ObjectAnimator(target, propertyName); - anim.setIntValues(values); - return anim; - } - - /** - * Constructs and returns an ObjectAnimator that animates between int values. A single - * value implies that that value is the one being animated to. Two values imply a starting - * and ending values. More than two values imply a starting value, values to animate through - * along the way, and an ending value (these values will be distributed evenly across - * the duration of the animation). - * - * @param target The object whose property is to be animated. - * @param property The property being animated. - * @param values A set of values that the animation will animate between over time. - * @return An ObjectAnimator object that is set up to animate between the given values. - */ - //public static ObjectAnimator ofInt(T target, Property property, int... values) { - // ObjectAnimator anim = new ObjectAnimator(target, property); - // anim.setIntValues(values); - // return anim; - //} - - /** - * Constructs and returns an ObjectAnimator that animates between float values. A single - * value implies that that value is the one being animated to. Two values imply a starting - * and ending values. More than two values imply a starting value, values to animate through - * along the way, and an ending value (these values will be distributed evenly across - * the duration of the animation). - * - * @param target The object whose property is to be animated. This object should - * have a public method on it called setName(), where name is - * the value of the propertyName parameter. - * @param propertyName The name of the property being animated. - * @param values A set of values that the animation will animate between over time. - * @return An ObjectAnimator object that is set up to animate between the given values. - */ - public static ObjectAnimator ofFloat(Object target, String propertyName, float... values) { - ObjectAnimator anim = new ObjectAnimator(target, propertyName); - anim.setFloatValues(values); - return anim; - } - - /** - * Constructs and returns an ObjectAnimator that animates between float values. A single - * value implies that that value is the one being animated to. Two values imply a starting - * and ending values. More than two values imply a starting value, values to animate through - * along the way, and an ending value (these values will be distributed evenly across - * the duration of the animation). - * - * @param target The object whose property is to be animated. - * @param property The property being animated. - * @param values A set of values that the animation will animate between over time. - * @return An ObjectAnimator object that is set up to animate between the given values. - */ - //public static ObjectAnimator ofFloat(T target, Property property, - // float... values) { - // ObjectAnimator anim = new ObjectAnimator(target, property); - // anim.setFloatValues(values); - // return anim; - //} - - /** - * Constructs and returns an ObjectAnimator that animates between Object values. A single - * value implies that that value is the one being animated to. Two values imply a starting - * and ending values. More than two values imply a starting value, values to animate through - * along the way, and an ending value (these values will be distributed evenly across - * the duration of the animation). - * - * @param target The object whose property is to be animated. This object should - * have a public method on it called setName(), where name is - * the value of the propertyName parameter. - * @param propertyName The name of the property being animated. - * @param evaluator A TypeEvaluator that will be called on each animation frame to - * provide the necessary interpolation between the Object values to derive the animated - * value. - * @param values A set of values that the animation will animate between over time. - * @return An ObjectAnimator object that is set up to animate between the given values. - */ - public static ObjectAnimator ofObject(Object target, String propertyName, - TypeEvaluator evaluator, Object... values) { - ObjectAnimator anim = new ObjectAnimator(target, propertyName); - anim.setObjectValues(values); - anim.setEvaluator(evaluator); - return anim; - } - - /** - * Constructs and returns an ObjectAnimator that animates between Object values. A single - * value implies that that value is the one being animated to. Two values imply a starting - * and ending values. More than two values imply a starting value, values to animate through - * along the way, and an ending value (these values will be distributed evenly across - * the duration of the animation). - * - * @param target The object whose property is to be animated. - * @param property The property being animated. - * @param evaluator A TypeEvaluator that will be called on each animation frame to - * provide the necessary interpolation between the Object values to derive the animated - * value. - * @param values A set of values that the animation will animate between over time. - * @return An ObjectAnimator object that is set up to animate between the given values. - */ - //public static ObjectAnimator ofObject(T target, Property property, - // TypeEvaluator evaluator, V... values) { - // ObjectAnimator anim = new ObjectAnimator(target, property); - // anim.setObjectValues(values); - // anim.setEvaluator(evaluator); - // return anim; - //} - - /** - * Constructs and returns an ObjectAnimator that animates between the sets of values specified - * in PropertyValueHolder objects. This variant should be used when animating - * several properties at once with the same ObjectAnimator, since PropertyValuesHolder allows - * you to associate a set of animation values with a property name. - * - * @param target The object whose property is to be animated. Depending on how the - * PropertyValuesObjects were constructed, the target object should either have the {@link - * android.util.Property} objects used to construct the PropertyValuesHolder objects or (if the - * PropertyValuesHOlder objects were created with property names) the target object should have - * public methods on it called setName(), where name is the name of - * the property passed in as the propertyName parameter for each of the - * PropertyValuesHolder objects. - * @param values A set of PropertyValuesHolder objects whose values will be animated between - * over time. - * @return An ObjectAnimator object that is set up to animate between the given values. - */ - public static ObjectAnimator ofPropertyValuesHolder(Object target, - PropertyValuesHolder... values) { - ObjectAnimator anim = new ObjectAnimator(); - anim.mTarget = target; - anim.setValues(values); - return anim; - } - - @Override - public void setIntValues(int... values) { - if (mValues == null || mValues.length == 0) { - // No values yet - this animator is being constructed piecemeal. Init the values with - // whatever the current propertyName is - //if (mProperty != null) { - // setValues(PropertyValuesHolder.ofInt(mProperty, values)); - //} else { - setValues(PropertyValuesHolder.ofInt(mPropertyName, values)); - //} - } else { - super.setIntValues(values); - } - } - - @Override - public void setFloatValues(float... values) { - if (mValues == null || mValues.length == 0) { - // No values yet - this animator is being constructed piecemeal. Init the values with - // whatever the current propertyName is - //if (mProperty != null) { - // setValues(PropertyValuesHolder.ofFloat(mProperty, values)); - //} else { - setValues(PropertyValuesHolder.ofFloat(mPropertyName, values)); - //} - } else { - super.setFloatValues(values); - } - } - - @Override - public void setObjectValues(Object... values) { - if (mValues == null || mValues.length == 0) { - // No values yet - this animator is being constructed piecemeal. Init the values with - // whatever the current propertyName is - //if (mProperty != null) { - // setValues(PropertyValuesHolder.ofObject(mProperty, (TypeEvaluator)null, values)); - //} else { - setValues(PropertyValuesHolder.ofObject(mPropertyName, (TypeEvaluator)null, values)); - //} - } else { - super.setObjectValues(values); - } - } - - @Override - public void start() { - if (DBG) { - Log.d("ObjectAnimator", "Anim target, duration: " + mTarget + ", " + getDuration()); - for (int i = 0; i < mValues.length; ++i) { - PropertyValuesHolder pvh = mValues[i]; - ArrayList keyframes = pvh.mKeyframeSet.mKeyframes; - Log.d("ObjectAnimator", " Values[" + i + "]: " + - pvh.getPropertyName() + ", " + keyframes.get(0).getValue() + ", " + - keyframes.get(pvh.mKeyframeSet.mNumKeyframes - 1).getValue()); - } - } - super.start(); - } - - /** - * This function is called immediately before processing the first animation - * frame of an animation. If there is a nonzero startDelay, the - * function is called after that delay ends. - * It takes care of the final initialization steps for the - * animation. This includes setting mEvaluator, if the user has not yet - * set it up, and the setter/getter methods, if the user did not supply - * them. - * - *

Overriders of this method should call the superclass method to cause - * internal mechanisms to be set up correctly.

- */ - @Override - void initAnimation() { - if (!mInitialized) { - // mValueType may change due to setter/getter setup; do this before calling super.init(), - // which uses mValueType to set up the default type evaluator. - int numValues = mValues.length; - for (int i = 0; i < numValues; ++i) { - mValues[i].setupSetterAndGetter(mTarget); - } - super.initAnimation(); - } - } - - /** - * Sets the length of the animation. The default duration is 300 milliseconds. - * - * @param duration The length of the animation, in milliseconds. - * @return ObjectAnimator The object called with setDuration(). This return - * value makes it easier to compose statements together that construct and then set the - * duration, as in - * ObjectAnimator.ofInt(target, propertyName, 0, 10).setDuration(500).start(). - */ - @Override - public ObjectAnimator setDuration(long duration) { - super.setDuration(duration); - return this; - } - - - /** - * The target object whose property will be animated by this animation - * - * @return The object being animated - */ - public Object getTarget() { - return mTarget; - } - - /** - * Sets the target object whose property will be animated by this animation - * - * @param target The object being animated - */ - @Override - public void setTarget(Object target) { - if (mTarget != target) { - final Object oldTarget = mTarget; - mTarget = target; - if (oldTarget != null && target != null && oldTarget.getClass() == target.getClass()) { - return; - } - // New target type should cause re-initialization prior to starting - mInitialized = false; - } - } - - @Override - public void setupStartValues() { - initAnimation(); - int numValues = mValues.length; - for (int i = 0; i < numValues; ++i) { - mValues[i].setupStartValue(mTarget); - } - } - - @Override - public void setupEndValues() { - initAnimation(); - int numValues = mValues.length; - for (int i = 0; i < numValues; ++i) { - mValues[i].setupEndValue(mTarget); - } - } - - /** - * This method is called with the elapsed fraction of the animation during every - * animation frame. This function turns the elapsed fraction into an interpolated fraction - * and then into an animated value (from the evaluator. The function is called mostly during - * animation updates, but it is also called when the end() - * function is called, to set the final value on the property. - * - *

Overrides of this method must call the superclass to perform the calculation - * of the animated value.

- * - * @param fraction The elapsed fraction of the animation. - */ - @Override - void animateValue(float fraction) { - super.animateValue(fraction); - int numValues = mValues.length; - for (int i = 0; i < numValues; ++i) { - mValues[i].setAnimatedValue(mTarget); - } - } - - @Override - public ObjectAnimator clone() { - final ObjectAnimator anim = (ObjectAnimator) super.clone(); - return anim; - } - - @Override - public String toString() { - String returnVal = "ObjectAnimator@" + Integer.toHexString(hashCode()) + ", target " + - mTarget; - if (mValues != null) { - for (int i = 0; i < mValues.length; ++i) { - returnVal += "\n " + mValues[i].toString(); - } - } - return returnVal; - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/PropertyValuesHolder.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/PropertyValuesHolder.java deleted file mode 100644 index 84f7504ab..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/PropertyValuesHolder.java +++ /dev/null @@ -1,1012 +0,0 @@ -/* - * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; - -//import android.util.FloatProperty; -//import android.util.IntProperty; -import android.util.Log; -//import android.util.Property; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.concurrent.locks.ReentrantReadWriteLock; - -/** - * This class holds information about a property and the values that that property - * should take on during an animation. PropertyValuesHolder objects can be used to create - * animations with ValueAnimator or ObjectAnimator that operate on several different properties - * in parallel. - */ -@SuppressWarnings({"rawtypes", "unchecked"}) -public class PropertyValuesHolder implements Cloneable { - - /** - * The name of the property associated with the values. This need not be a real property, - * unless this object is being used with ObjectAnimator. But this is the name by which - * aniamted values are looked up with getAnimatedValue(String) in ValueAnimator. - */ - String mPropertyName; - - /** - * @hide - */ - //protected Property mProperty; - - /** - * The setter function, if needed. ObjectAnimator hands off this functionality to - * PropertyValuesHolder, since it holds all of the per-property information. This - * property is automatically - * derived when the animation starts in setupSetterAndGetter() if using ObjectAnimator. - */ - Method mSetter = null; - - /** - * The getter function, if needed. ObjectAnimator hands off this functionality to - * PropertyValuesHolder, since it holds all of the per-property information. This - * property is automatically - * derived when the animation starts in setupSetterAndGetter() if using ObjectAnimator. - * The getter is only derived and used if one of the values is null. - */ - private Method mGetter = null; - - /** - * The type of values supplied. This information is used both in deriving the setter/getter - * functions and in deriving the type of TypeEvaluator. - */ - Class mValueType; - - /** - * The set of keyframes (time/value pairs) that define this animation. - */ - KeyframeSet mKeyframeSet = null; - - - // type evaluators for the primitive types handled by this implementation - private static final TypeEvaluator sIntEvaluator = new IntEvaluator(); - private static final TypeEvaluator sFloatEvaluator = new FloatEvaluator(); - - // We try several different types when searching for appropriate setter/getter functions. - // The caller may have supplied values in a type that does not match the setter/getter - // functions (such as the integers 0 and 1 to represent floating point values for alpha). - // Also, the use of generics in constructors means that we end up with the Object versions - // of primitive types (Float vs. float). But most likely, the setter/getter functions - // will take primitive types instead. - // So we supply an ordered array of other types to try before giving up. - private static Class[] FLOAT_VARIANTS = {float.class, Float.class, double.class, int.class, - Double.class, Integer.class}; - private static Class[] INTEGER_VARIANTS = {int.class, Integer.class, float.class, double.class, - Float.class, Double.class}; - private static Class[] DOUBLE_VARIANTS = {double.class, Double.class, float.class, int.class, - Float.class, Integer.class}; - - // These maps hold all property entries for a particular class. This map - // is used to speed up property/setter/getter lookups for a given class/property - // combination. No need to use reflection on the combination more than once. - private static final HashMap> sSetterPropertyMap = - new HashMap>(); - private static final HashMap> sGetterPropertyMap = - new HashMap>(); - - // This lock is used to ensure that only one thread is accessing the property maps - // at a time. - final ReentrantReadWriteLock mPropertyMapLock = new ReentrantReadWriteLock(); - - // Used to pass single value to varargs parameter in setter invocation - final Object[] mTmpValueArray = new Object[1]; - - /** - * The type evaluator used to calculate the animated values. This evaluator is determined - * automatically based on the type of the start/end objects passed into the constructor, - * but the system only knows about the primitive types int and float. Any other - * type will need to set the evaluator to a custom evaluator for that type. - */ - private TypeEvaluator mEvaluator; - - /** - * The value most recently calculated by calculateValue(). This is set during - * that function and might be retrieved later either by ValueAnimator.animatedValue() or - * by the property-setting logic in ObjectAnimator.animatedValue(). - */ - private Object mAnimatedValue; - - /** - * Internal utility constructor, used by the factory methods to set the property name. - * @param propertyName The name of the property for this holder. - */ - private PropertyValuesHolder(String propertyName) { - mPropertyName = propertyName; - } - - /** - * Internal utility constructor, used by the factory methods to set the property. - * @param property The property for this holder. - */ - //private PropertyValuesHolder(Property property) { - // mProperty = property; - // if (property != null) { - // mPropertyName = property.getName(); - // } - //} - - /** - * Constructs and returns a PropertyValuesHolder with a given property name and - * set of int values. - * @param propertyName The name of the property being animated. - * @param values The values that the named property will animate between. - * @return PropertyValuesHolder The constructed PropertyValuesHolder object. - */ - public static PropertyValuesHolder ofInt(String propertyName, int... values) { - return new IntPropertyValuesHolder(propertyName, values); - } - - /** - * Constructs and returns a PropertyValuesHolder with a given property and - * set of int values. - * @param property The property being animated. Should not be null. - * @param values The values that the property will animate between. - * @return PropertyValuesHolder The constructed PropertyValuesHolder object. - */ - //public static PropertyValuesHolder ofInt(Property property, int... values) { - // return new IntPropertyValuesHolder(property, values); - //} - - /** - * Constructs and returns a PropertyValuesHolder with a given property name and - * set of float values. - * @param propertyName The name of the property being animated. - * @param values The values that the named property will animate between. - * @return PropertyValuesHolder The constructed PropertyValuesHolder object. - */ - public static PropertyValuesHolder ofFloat(String propertyName, float... values) { - return new FloatPropertyValuesHolder(propertyName, values); - } - - /** - * Constructs and returns a PropertyValuesHolder with a given property and - * set of float values. - * @param property The property being animated. Should not be null. - * @param values The values that the property will animate between. - * @return PropertyValuesHolder The constructed PropertyValuesHolder object. - */ - //public static PropertyValuesHolder ofFloat(Property property, float... values) { - // return new FloatPropertyValuesHolder(property, values); - //} - - /** - * Constructs and returns a PropertyValuesHolder with a given property name and - * set of Object values. This variant also takes a TypeEvaluator because the system - * cannot automatically interpolate between objects of unknown type. - * - * @param propertyName The name of the property being animated. - * @param evaluator A TypeEvaluator that will be called on each animation frame to - * provide the necessary interpolation between the Object values to derive the animated - * value. - * @param values The values that the named property will animate between. - * @return PropertyValuesHolder The constructed PropertyValuesHolder object. - */ - public static PropertyValuesHolder ofObject(String propertyName, TypeEvaluator evaluator, - Object... values) { - PropertyValuesHolder pvh = new PropertyValuesHolder(propertyName); - pvh.setObjectValues(values); - pvh.setEvaluator(evaluator); - return pvh; - } - - /** - * Constructs and returns a PropertyValuesHolder with a given property and - * set of Object values. This variant also takes a TypeEvaluator because the system - * cannot automatically interpolate between objects of unknown type. - * - * @param property The property being animated. Should not be null. - * @param evaluator A TypeEvaluator that will be called on each animation frame to - * provide the necessary interpolation between the Object values to derive the animated - * value. - * @param values The values that the property will animate between. - * @return PropertyValuesHolder The constructed PropertyValuesHolder object. - */ - //public static PropertyValuesHolder ofObject(Property property, - // TypeEvaluator evaluator, V... values) { - // PropertyValuesHolder pvh = new PropertyValuesHolder(property); - // pvh.setObjectValues(values); - // pvh.setEvaluator(evaluator); - // return pvh; - //} - - /** - * Constructs and returns a PropertyValuesHolder object with the specified property name and set - * of values. These values can be of any type, but the type should be consistent so that - * an appropriate {@link android.animation.TypeEvaluator} can be found that matches - * the common type. - *

If there is only one value, it is assumed to be the end value of an animation, - * and an initial value will be derived, if possible, by calling a getter function - * on the object. Also, if any value is null, the value will be filled in when the animation - * starts in the same way. This mechanism of automatically getting null values only works - * if the PropertyValuesHolder object is used in conjunction - * {@link ObjectAnimator}, and with a getter function - * derived automatically from propertyName, since otherwise PropertyValuesHolder has - * no way of determining what the value should be. - * @param propertyName The name of the property associated with this set of values. This - * can be the actual property name to be used when using a ObjectAnimator object, or - * just a name used to get animated values, such as if this object is used with an - * ValueAnimator object. - * @param values The set of values to animate between. - */ - public static PropertyValuesHolder ofKeyframe(String propertyName, Keyframe... values) { - KeyframeSet keyframeSet = KeyframeSet.ofKeyframe(values); - if (keyframeSet instanceof IntKeyframeSet) { - return new IntPropertyValuesHolder(propertyName, (IntKeyframeSet) keyframeSet); - } else if (keyframeSet instanceof FloatKeyframeSet) { - return new FloatPropertyValuesHolder(propertyName, (FloatKeyframeSet) keyframeSet); - } - else { - PropertyValuesHolder pvh = new PropertyValuesHolder(propertyName); - pvh.mKeyframeSet = keyframeSet; - pvh.mValueType = values[0].getType(); - return pvh; - } - } - - /** - * Constructs and returns a PropertyValuesHolder object with the specified property and set - * of values. These values can be of any type, but the type should be consistent so that - * an appropriate {@link android.animation.TypeEvaluator} can be found that matches - * the common type. - *

If there is only one value, it is assumed to be the end value of an animation, - * and an initial value will be derived, if possible, by calling the property's - * {@link android.util.Property#get(Object)} function. - * Also, if any value is null, the value will be filled in when the animation - * starts in the same way. This mechanism of automatically getting null values only works - * if the PropertyValuesHolder object is used in conjunction with - * {@link ObjectAnimator}, since otherwise PropertyValuesHolder has - * no way of determining what the value should be. - * @param property The property associated with this set of values. Should not be null. - * @param values The set of values to animate between. - */ - //public static PropertyValuesHolder ofKeyframe(Property property, Keyframe... values) { - // KeyframeSet keyframeSet = KeyframeSet.ofKeyframe(values); - // if (keyframeSet instanceof IntKeyframeSet) { - // return new IntPropertyValuesHolder(property, (IntKeyframeSet) keyframeSet); - // } else if (keyframeSet instanceof FloatKeyframeSet) { - // return new FloatPropertyValuesHolder(property, (FloatKeyframeSet) keyframeSet); - // } - // else { - // PropertyValuesHolder pvh = new PropertyValuesHolder(property); - // pvh.mKeyframeSet = keyframeSet; - // pvh.mValueType = ((Keyframe)values[0]).getType(); - // return pvh; - // } - //} - - /** - * Set the animated values for this object to this set of ints. - * If there is only one value, it is assumed to be the end value of an animation, - * and an initial value will be derived, if possible, by calling a getter function - * on the object. Also, if any value is null, the value will be filled in when the animation - * starts in the same way. This mechanism of automatically getting null values only works - * if the PropertyValuesHolder object is used in conjunction - * {@link ObjectAnimator}, and with a getter function - * derived automatically from propertyName, since otherwise PropertyValuesHolder has - * no way of determining what the value should be. - * - * @param values One or more values that the animation will animate between. - */ - public void setIntValues(int... values) { - mValueType = int.class; - mKeyframeSet = KeyframeSet.ofInt(values); - } - - /** - * Set the animated values for this object to this set of floats. - * If there is only one value, it is assumed to be the end value of an animation, - * and an initial value will be derived, if possible, by calling a getter function - * on the object. Also, if any value is null, the value will be filled in when the animation - * starts in the same way. This mechanism of automatically getting null values only works - * if the PropertyValuesHolder object is used in conjunction - * {@link ObjectAnimator}, and with a getter function - * derived automatically from propertyName, since otherwise PropertyValuesHolder has - * no way of determining what the value should be. - * - * @param values One or more values that the animation will animate between. - */ - public void setFloatValues(float... values) { - mValueType = float.class; - mKeyframeSet = KeyframeSet.ofFloat(values); - } - - /** - * Set the animated values for this object to this set of Keyframes. - * - * @param values One or more values that the animation will animate between. - */ - public void setKeyframes(Keyframe... values) { - int numKeyframes = values.length; - Keyframe keyframes[] = new Keyframe[Math.max(numKeyframes,2)]; - mValueType = values[0].getType(); - for (int i = 0; i < numKeyframes; ++i) { - keyframes[i] = values[i]; - } - mKeyframeSet = new KeyframeSet(keyframes); - } - - /** - * Set the animated values for this object to this set of Objects. - * If there is only one value, it is assumed to be the end value of an animation, - * and an initial value will be derived, if possible, by calling a getter function - * on the object. Also, if any value is null, the value will be filled in when the animation - * starts in the same way. This mechanism of automatically getting null values only works - * if the PropertyValuesHolder object is used in conjunction - * {@link ObjectAnimator}, and with a getter function - * derived automatically from propertyName, since otherwise PropertyValuesHolder has - * no way of determining what the value should be. - * - * @param values One or more values that the animation will animate between. - */ - public void setObjectValues(Object... values) { - mValueType = values[0].getClass(); - mKeyframeSet = KeyframeSet.ofObject(values); - } - - /** - * Determine the setter or getter function using the JavaBeans convention of setFoo or - * getFoo for a property named 'foo'. This function figures out what the name of the - * function should be and uses reflection to find the Method with that name on the - * target object. - * - * @param targetClass The class to search for the method - * @param prefix "set" or "get", depending on whether we need a setter or getter. - * @param valueType The type of the parameter (in the case of a setter). This type - * is derived from the values set on this PropertyValuesHolder. This type is used as - * a first guess at the parameter type, but we check for methods with several different - * types to avoid problems with slight mis-matches between supplied values and actual - * value types used on the setter. - * @return Method the method associated with mPropertyName. - */ - private Method getPropertyFunction(Class targetClass, String prefix, Class valueType) { - // TODO: faster implementation... - Method returnVal = null; - String methodName = getMethodName(prefix, mPropertyName); - Class args[] = null; - if (valueType == null) { - try { - returnVal = targetClass.getMethod(methodName, args); - } catch (NoSuchMethodException e) { - Log.e("PropertyValuesHolder", targetClass.getSimpleName() + " - " + - "Couldn't find no-arg method for property " + mPropertyName + ": " + e); - } - } else { - args = new Class[1]; - Class typeVariants[]; - if (mValueType.equals(Float.class)) { - typeVariants = FLOAT_VARIANTS; - } else if (mValueType.equals(Integer.class)) { - typeVariants = INTEGER_VARIANTS; - } else if (mValueType.equals(Double.class)) { - typeVariants = DOUBLE_VARIANTS; - } else { - typeVariants = new Class[1]; - typeVariants[0] = mValueType; - } - for (Class typeVariant : typeVariants) { - args[0] = typeVariant; - try { - returnVal = targetClass.getMethod(methodName, args); - // change the value type to suit - mValueType = typeVariant; - return returnVal; - } catch (NoSuchMethodException e) { - // Swallow the error and keep trying other variants - } - } - // If we got here, then no appropriate function was found - Log.e("PropertyValuesHolder", - "Couldn't find " + prefix + "ter property " + mPropertyName + - " for " + targetClass.getSimpleName() + - " with value type "+ mValueType); - } - - return returnVal; - } - - - /** - * Returns the setter or getter requested. This utility function checks whether the - * requested method exists in the propertyMapMap cache. If not, it calls another - * utility function to request the Method from the targetClass directly. - * @param targetClass The Class on which the requested method should exist. - * @param propertyMapMap The cache of setters/getters derived so far. - * @param prefix "set" or "get", for the setter or getter. - * @param valueType The type of parameter passed into the method (null for getter). - * @return Method the method associated with mPropertyName. - */ - private Method setupSetterOrGetter(Class targetClass, - HashMap> propertyMapMap, - String prefix, Class valueType) { - Method setterOrGetter = null; - try { - // Have to lock property map prior to reading it, to guard against - // another thread putting something in there after we've checked it - // but before we've added an entry to it - mPropertyMapLock.writeLock().lock(); - HashMap propertyMap = propertyMapMap.get(targetClass); - if (propertyMap != null) { - setterOrGetter = propertyMap.get(mPropertyName); - } - if (setterOrGetter == null) { - setterOrGetter = getPropertyFunction(targetClass, prefix, valueType); - if (propertyMap == null) { - propertyMap = new HashMap(); - propertyMapMap.put(targetClass, propertyMap); - } - propertyMap.put(mPropertyName, setterOrGetter); - } - } finally { - mPropertyMapLock.writeLock().unlock(); - } - return setterOrGetter; - } - - /** - * Utility function to get the setter from targetClass - * @param targetClass The Class on which the requested method should exist. - */ - void setupSetter(Class targetClass) { - mSetter = setupSetterOrGetter(targetClass, sSetterPropertyMap, "set", mValueType); - } - - /** - * Utility function to get the getter from targetClass - */ - private void setupGetter(Class targetClass) { - mGetter = setupSetterOrGetter(targetClass, sGetterPropertyMap, "get", null); - } - - /** - * Internal function (called from ObjectAnimator) to set up the setter and getter - * prior to running the animation. If the setter has not been manually set for this - * object, it will be derived automatically given the property name, target object, and - * types of values supplied. If no getter has been set, it will be supplied iff any of the - * supplied values was null. If there is a null value, then the getter (supplied or derived) - * will be called to set those null values to the current value of the property - * on the target object. - * @param target The object on which the setter (and possibly getter) exist. - */ - void setupSetterAndGetter(Object target) { - //if (mProperty != null) { - // // check to make sure that mProperty is on the class of target - // try { - // Object testValue = mProperty.get(target); - // for (Keyframe kf : mKeyframeSet.mKeyframes) { - // if (!kf.hasValue()) { - // kf.setValue(mProperty.get(target)); - // } - // } - // return; - // } catch (ClassCastException e) { - // Log.e("PropertyValuesHolder","No such property (" + mProperty.getName() + - // ") on target object " + target + ". Trying reflection instead"); - // mProperty = null; - // } - //} - Class targetClass = target.getClass(); - if (mSetter == null) { - setupSetter(targetClass); - } - for (Keyframe kf : mKeyframeSet.mKeyframes) { - if (!kf.hasValue()) { - if (mGetter == null) { - setupGetter(targetClass); - } - try { - kf.setValue(mGetter.invoke(target)); - } catch (InvocationTargetException e) { - Log.e("PropertyValuesHolder", e.toString()); - } catch (IllegalAccessException e) { - Log.e("PropertyValuesHolder", e.toString()); - } - } - } - } - - /** - * Utility function to set the value stored in a particular Keyframe. The value used is - * whatever the value is for the property name specified in the keyframe on the target object. - * - * @param target The target object from which the current value should be extracted. - * @param kf The keyframe which holds the property name and value. - */ - private void setupValue(Object target, Keyframe kf) { - //if (mProperty != null) { - // kf.setValue(mProperty.get(target)); - //} - try { - if (mGetter == null) { - Class targetClass = target.getClass(); - setupGetter(targetClass); - } - kf.setValue(mGetter.invoke(target)); - } catch (InvocationTargetException e) { - Log.e("PropertyValuesHolder", e.toString()); - } catch (IllegalAccessException e) { - Log.e("PropertyValuesHolder", e.toString()); - } - } - - /** - * This function is called by ObjectAnimator when setting the start values for an animation. - * The start values are set according to the current values in the target object. The - * property whose value is extracted is whatever is specified by the propertyName of this - * PropertyValuesHolder object. - * - * @param target The object which holds the start values that should be set. - */ - void setupStartValue(Object target) { - setupValue(target, mKeyframeSet.mKeyframes.get(0)); - } - - /** - * This function is called by ObjectAnimator when setting the end values for an animation. - * The end values are set according to the current values in the target object. The - * property whose value is extracted is whatever is specified by the propertyName of this - * PropertyValuesHolder object. - * - * @param target The object which holds the start values that should be set. - */ - void setupEndValue(Object target) { - setupValue(target, mKeyframeSet.mKeyframes.get(mKeyframeSet.mKeyframes.size() - 1)); - } - - @Override - public PropertyValuesHolder clone() { - try { - PropertyValuesHolder newPVH = (PropertyValuesHolder) super.clone(); - newPVH.mPropertyName = mPropertyName; - //newPVH.mProperty = mProperty; - newPVH.mKeyframeSet = mKeyframeSet.clone(); - newPVH.mEvaluator = mEvaluator; - return newPVH; - } catch (CloneNotSupportedException e) { - // won't reach here - return null; - } - } - - /** - * Internal function to set the value on the target object, using the setter set up - * earlier on this PropertyValuesHolder object. This function is called by ObjectAnimator - * to handle turning the value calculated by ValueAnimator into a value set on the object - * according to the name of the property. - * @param target The target object on which the value is set - */ - void setAnimatedValue(Object target) { - //if (mProperty != null) { - // mProperty.set(target, getAnimatedValue()); - //} - if (mSetter != null) { - try { - mTmpValueArray[0] = getAnimatedValue(); - mSetter.invoke(target, mTmpValueArray); - } catch (InvocationTargetException e) { - Log.e("PropertyValuesHolder", e.toString()); - } catch (IllegalAccessException e) { - Log.e("PropertyValuesHolder", e.toString()); - } - } - } - - /** - * Internal function, called by ValueAnimator, to set up the TypeEvaluator that will be used - * to calculate animated values. - */ - void init() { - if (mEvaluator == null) { - // We already handle int and float automatically, but not their Object - // equivalents - mEvaluator = (mValueType == Integer.class) ? sIntEvaluator : - (mValueType == Float.class) ? sFloatEvaluator : - null; - } - if (mEvaluator != null) { - // KeyframeSet knows how to evaluate the common types - only give it a custom - // evaluator if one has been set on this class - mKeyframeSet.setEvaluator(mEvaluator); - } - } - - /** - * The TypeEvaluator will the automatically determined based on the type of values - * supplied to PropertyValuesHolder. The evaluator can be manually set, however, if so - * desired. This may be important in cases where either the type of the values supplied - * do not match the way that they should be interpolated between, or if the values - * are of a custom type or one not currently understood by the animation system. Currently, - * only values of type float and int (and their Object equivalents: Float - * and Integer) are correctly interpolated; all other types require setting a TypeEvaluator. - * @param evaluator - */ - public void setEvaluator(TypeEvaluator evaluator) { - mEvaluator = evaluator; - mKeyframeSet.setEvaluator(evaluator); - } - - /** - * Function used to calculate the value according to the evaluator set up for - * this PropertyValuesHolder object. This function is called by ValueAnimator.animateValue(). - * - * @param fraction The elapsed, interpolated fraction of the animation. - */ - void calculateValue(float fraction) { - mAnimatedValue = mKeyframeSet.getValue(fraction); - } - - /** - * Sets the name of the property that will be animated. This name is used to derive - * a setter function that will be called to set animated values. - * For example, a property name of foo will result - * in a call to the function setFoo() on the target object. If either - * valueFrom or valueTo is null, then a getter function will - * also be derived and called. - * - *

Note that the setter function derived from this property name - * must take the same parameter type as the - * valueFrom and valueTo properties, otherwise the call to - * the setter function will fail.

- * - * @param propertyName The name of the property being animated. - */ - public void setPropertyName(String propertyName) { - mPropertyName = propertyName; - } - - /** - * Sets the property that will be animated. - * - *

Note that if this PropertyValuesHolder object is used with ObjectAnimator, the property - * must exist on the target object specified in that ObjectAnimator.

- * - * @param property The property being animated. - */ - //public void setProperty(Property property) { - // mProperty = property; - //} - - /** - * Gets the name of the property that will be animated. This name will be used to derive - * a setter function that will be called to set animated values. - * For example, a property name of foo will result - * in a call to the function setFoo() on the target object. If either - * valueFrom or valueTo is null, then a getter function will - * also be derived and called. - */ - public String getPropertyName() { - return mPropertyName; - } - - /** - * Internal function, called by ValueAnimator and ObjectAnimator, to retrieve the value - * most recently calculated in calculateValue(). - * @return - */ - Object getAnimatedValue() { - return mAnimatedValue; - } - - @Override - public String toString() { - return mPropertyName + ": " + mKeyframeSet.toString(); - } - - /** - * Utility method to derive a setter/getter method name from a property name, where the - * prefix is typically "set" or "get" and the first letter of the property name is - * capitalized. - * - * @param prefix The precursor to the method name, before the property name begins, typically - * "set" or "get". - * @param propertyName The name of the property that represents the bulk of the method name - * after the prefix. The first letter of this word will be capitalized in the resulting - * method name. - * @return String the property name converted to a method name according to the conventions - * specified above. - */ - static String getMethodName(String prefix, String propertyName) { - if (propertyName == null || propertyName.length() == 0) { - // shouldn't get here - return prefix; - } - char firstLetter = Character.toUpperCase(propertyName.charAt(0)); - String theRest = propertyName.substring(1); - return prefix + firstLetter + theRest; - } - - static class IntPropertyValuesHolder extends PropertyValuesHolder { - - // Cache JNI functions to avoid looking them up twice - //private static final HashMap> sJNISetterPropertyMap = - // new HashMap>(); - //int mJniSetter; - //private IntProperty mIntProperty; - - IntKeyframeSet mIntKeyframeSet; - int mIntAnimatedValue; - - public IntPropertyValuesHolder(String propertyName, IntKeyframeSet keyframeSet) { - super(propertyName); - mValueType = int.class; - mKeyframeSet = keyframeSet; - mIntKeyframeSet = (IntKeyframeSet) mKeyframeSet; - } - - //public IntPropertyValuesHolder(Property property, IntKeyframeSet keyframeSet) { - // super(property); - // mValueType = int.class; - // mKeyframeSet = keyframeSet; - // mIntKeyframeSet = (IntKeyframeSet) mKeyframeSet; - // if (property instanceof IntProperty) { - // mIntProperty = (IntProperty) mProperty; - // } - //} - - public IntPropertyValuesHolder(String propertyName, int... values) { - super(propertyName); - setIntValues(values); - } - - //public IntPropertyValuesHolder(Property property, int... values) { - // super(property); - // setIntValues(values); - // if (property instanceof IntProperty) { - // mIntProperty = (IntProperty) mProperty; - // } - //} - - @Override - public void setIntValues(int... values) { - super.setIntValues(values); - mIntKeyframeSet = (IntKeyframeSet) mKeyframeSet; - } - - @Override - void calculateValue(float fraction) { - mIntAnimatedValue = mIntKeyframeSet.getIntValue(fraction); - } - - @Override - Object getAnimatedValue() { - return mIntAnimatedValue; - } - - @Override - public IntPropertyValuesHolder clone() { - IntPropertyValuesHolder newPVH = (IntPropertyValuesHolder) super.clone(); - newPVH.mIntKeyframeSet = (IntKeyframeSet) newPVH.mKeyframeSet; - return newPVH; - } - - /** - * Internal function to set the value on the target object, using the setter set up - * earlier on this PropertyValuesHolder object. This function is called by ObjectAnimator - * to handle turning the value calculated by ValueAnimator into a value set on the object - * according to the name of the property. - * @param target The target object on which the value is set - */ - @Override - void setAnimatedValue(Object target) { - //if (mIntProperty != null) { - // mIntProperty.setValue(target, mIntAnimatedValue); - // return; - //} - //if (mProperty != null) { - // mProperty.set(target, mIntAnimatedValue); - // return; - //} - //if (mJniSetter != 0) { - // nCallIntMethod(target, mJniSetter, mIntAnimatedValue); - // return; - //} - if (mSetter != null) { - try { - mTmpValueArray[0] = mIntAnimatedValue; - mSetter.invoke(target, mTmpValueArray); - } catch (InvocationTargetException e) { - Log.e("PropertyValuesHolder", e.toString()); - } catch (IllegalAccessException e) { - Log.e("PropertyValuesHolder", e.toString()); - } - } - } - - @Override - void setupSetter(Class targetClass) { - //if (mProperty != null) { - // return; - //} - // Check new static hashmap for setter method - //try { - // mPropertyMapLock.writeLock().lock(); - // HashMap propertyMap = sJNISetterPropertyMap.get(targetClass); - // if (propertyMap != null) { - // Integer mJniSetterInteger = propertyMap.get(mPropertyName); - // if (mJniSetterInteger != null) { - // mJniSetter = mJniSetterInteger; - // } - // } - // if (mJniSetter == 0) { - // String methodName = getMethodName("set", mPropertyName); - // mJniSetter = nGetIntMethod(targetClass, methodName); - // if (mJniSetter != 0) { - // if (propertyMap == null) { - // propertyMap = new HashMap(); - // sJNISetterPropertyMap.put(targetClass, propertyMap); - // } - // propertyMap.put(mPropertyName, mJniSetter); - // } - // } - //} catch (NoSuchMethodError e) { - // Log.d("PropertyValuesHolder", - // "Can't find native method using JNI, use reflection" + e); - //} finally { - // mPropertyMapLock.writeLock().unlock(); - //} - //if (mJniSetter == 0) { - // Couldn't find method through fast JNI approach - just use reflection - super.setupSetter(targetClass); - //} - } - } - - static class FloatPropertyValuesHolder extends PropertyValuesHolder { - - // Cache JNI functions to avoid looking them up twice - //private static final HashMap> sJNISetterPropertyMap = - // new HashMap>(); - //int mJniSetter; - //private FloatProperty mFloatProperty; - - FloatKeyframeSet mFloatKeyframeSet; - float mFloatAnimatedValue; - - public FloatPropertyValuesHolder(String propertyName, FloatKeyframeSet keyframeSet) { - super(propertyName); - mValueType = float.class; - mKeyframeSet = keyframeSet; - mFloatKeyframeSet = (FloatKeyframeSet) mKeyframeSet; - } - - //public FloatPropertyValuesHolder(Property property, FloatKeyframeSet keyframeSet) { - // super(property); - // mValueType = float.class; - // mKeyframeSet = keyframeSet; - // mFloatKeyframeSet = (FloatKeyframeSet) mKeyframeSet; - // if (property instanceof FloatProperty) { - // mFloatProperty = (FloatProperty) mProperty; - // } - //} - - public FloatPropertyValuesHolder(String propertyName, float... values) { - super(propertyName); - setFloatValues(values); - } - - //public FloatPropertyValuesHolder(Property property, float... values) { - // super(property); - // setFloatValues(values); - // if (property instanceof FloatProperty) { - // mFloatProperty = (FloatProperty) mProperty; - // } - //} - - @Override - public void setFloatValues(float... values) { - super.setFloatValues(values); - mFloatKeyframeSet = (FloatKeyframeSet) mKeyframeSet; - } - - @Override - void calculateValue(float fraction) { - mFloatAnimatedValue = mFloatKeyframeSet.getFloatValue(fraction); - } - - @Override - Object getAnimatedValue() { - return mFloatAnimatedValue; - } - - @Override - public FloatPropertyValuesHolder clone() { - FloatPropertyValuesHolder newPVH = (FloatPropertyValuesHolder) super.clone(); - newPVH.mFloatKeyframeSet = (FloatKeyframeSet) newPVH.mKeyframeSet; - return newPVH; - } - - /** - * Internal function to set the value on the target object, using the setter set up - * earlier on this PropertyValuesHolder object. This function is called by ObjectAnimator - * to handle turning the value calculated by ValueAnimator into a value set on the object - * according to the name of the property. - * @param target The target object on which the value is set - */ - @Override - void setAnimatedValue(Object target) { - //if (mFloatProperty != null) { - // mFloatProperty.setValue(target, mFloatAnimatedValue); - // return; - //} - //if (mProperty != null) { - // mProperty.set(target, mFloatAnimatedValue); - // return; - //} - //if (mJniSetter != 0) { - // nCallFloatMethod(target, mJniSetter, mFloatAnimatedValue); - // return; - //} - if (mSetter != null) { - try { - mTmpValueArray[0] = mFloatAnimatedValue; - mSetter.invoke(target, mTmpValueArray); - } catch (InvocationTargetException e) { - Log.e("PropertyValuesHolder", e.toString()); - } catch (IllegalAccessException e) { - Log.e("PropertyValuesHolder", e.toString()); - } - } - } - - @Override - void setupSetter(Class targetClass) { - //if (mProperty != null) { - // return; - //} - // Check new static hashmap for setter method - //try { - // mPropertyMapLock.writeLock().lock(); - // HashMap propertyMap = sJNISetterPropertyMap.get(targetClass); - // if (propertyMap != null) { - // Integer mJniSetterInteger = propertyMap.get(mPropertyName); - // if (mJniSetterInteger != null) { - // mJniSetter = mJniSetterInteger; - // } - // } - // if (mJniSetter == 0) { - // String methodName = getMethodName("set", mPropertyName); - // mJniSetter = nGetFloatMethod(targetClass, methodName); - // if (mJniSetter != 0) { - // if (propertyMap == null) { - // propertyMap = new HashMap(); - // sJNISetterPropertyMap.put(targetClass, propertyMap); - // } - // propertyMap.put(mPropertyName, mJniSetter); - // } - // } - //} catch (NoSuchMethodError e) { - // Log.d("PropertyValuesHolder", - // "Can't find native method using JNI, use reflection" + e); - //} finally { - // mPropertyMapLock.writeLock().unlock(); - //} - //if (mJniSetter == 0) { - // Couldn't find method through fast JNI approach - just use reflection - super.setupSetter(targetClass); - //} - } - - } - - //native static private int nGetIntMethod(Class targetClass, String methodName); - //native static private int nGetFloatMethod(Class targetClass, String methodName); - //native static private void nCallIntMethod(Object target, int methodID, int arg); - //native static private void nCallFloatMethod(Object target, int methodID, float arg); -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/TypeEvaluator.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/TypeEvaluator.java deleted file mode 100644 index 0ea319244..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/TypeEvaluator.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; - -/** - * Interface for use with the {@link ValueAnimator#setEvaluator(TypeEvaluator)} function. Evaluators - * allow developers to create animations on arbitrary property types, by allowing them to supply - * custom evaulators for types that are not automatically understood and used by the animation - * system. - * - * @see ValueAnimator#setEvaluator(TypeEvaluator) - */ -public interface TypeEvaluator { - - /** - * This function returns the result of linearly interpolating the start and end values, with - * fraction representing the proportion between the start and end values. The - * calculation is a simple parametric calculation: result = x0 + t * (v1 - v0), - * where x0 is startValue, x1 is endValue, - * and t is fraction. - * - * @param fraction The fraction from the starting to the ending values - * @param startValue The start value. - * @param endValue The end value. - * @return A linear interpolation between the start and end values, given the - * fraction parameter. - */ - public T evaluate(float fraction, T startValue, T endValue); - -} \ No newline at end of file diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java deleted file mode 100644 index d8a12c688..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java +++ /dev/null @@ -1,1265 +0,0 @@ -/* - * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; - -import android.os.Handler; -import android.os.Looper; -import android.os.Message; -import android.util.AndroidRuntimeException; -import android.view.animation.AccelerateDecelerateInterpolator; -import android.view.animation.AnimationUtils; -import android.view.animation.Interpolator; -import android.view.animation.LinearInterpolator; - -import java.util.ArrayList; -import java.util.HashMap; - -/** - * This class provides a simple timing engine for running animations - * which calculate animated values and set them on target objects. - * - *

There is a single timing pulse that all animations use. It runs in a - * custom handler to ensure that property changes happen on the UI thread.

- * - *

By default, ValueAnimator uses non-linear time interpolation, via the - * {@link AccelerateDecelerateInterpolator} class, which accelerates into and decelerates - * out of an animation. This behavior can be changed by calling - * {@link ValueAnimator#setInterpolator(TimeInterpolator)}.

- */ -@SuppressWarnings({"rawtypes", "unchecked"}) -public class ValueAnimator extends Animator { - - /** - * Internal constants - */ - - /* - * The default amount of time in ms between animation frames - */ - private static final long DEFAULT_FRAME_DELAY = 10; - - /** - * Messages sent to timing handler: START is sent when an animation first begins, FRAME is sent - * by the handler to itself to process the next animation frame - */ - static final int ANIMATION_START = 0; - static final int ANIMATION_FRAME = 1; - - /** - * Values used with internal variable mPlayingState to indicate the current state of an - * animation. - */ - static final int STOPPED = 0; // Not yet playing - static final int RUNNING = 1; // Playing normally - static final int SEEKED = 2; // Seeked to some time value - - /** - * Internal variables - * NOTE: This object implements the clone() method, making a deep copy of any referenced - * objects. As other non-trivial fields are added to this class, make sure to add logic - * to clone() to make deep copies of them. - */ - - // The first time that the animation's animateFrame() method is called. This time is used to - // determine elapsed time (and therefore the elapsed fraction) in subsequent calls - // to animateFrame() - long mStartTime; - - /** - * Set when setCurrentPlayTime() is called. If negative, animation is not currently seeked - * to a value. - */ - long mSeekTime = -1; - - // TODO: We access the following ThreadLocal variables often, some of them on every update. - // If ThreadLocal access is significantly expensive, we may want to put all of these - // fields into a structure sot hat we just access ThreadLocal once to get the reference - // to that structure, then access the structure directly for each field. - - // The static sAnimationHandler processes the internal timing loop on which all animations - // are based - private static ThreadLocal sAnimationHandler = - new ThreadLocal(); - - // The per-thread list of all active animations - private static final ThreadLocal> sAnimations = - new ThreadLocal>() { - @Override - protected ArrayList initialValue() { - return new ArrayList(); - } - }; - - // The per-thread set of animations to be started on the next animation frame - private static final ThreadLocal> sPendingAnimations = - new ThreadLocal>() { - @Override - protected ArrayList initialValue() { - return new ArrayList(); - } - }; - - /** - * Internal per-thread collections used to avoid set collisions as animations start and end - * while being processed. - */ - private static final ThreadLocal> sDelayedAnims = - new ThreadLocal>() { - @Override - protected ArrayList initialValue() { - return new ArrayList(); - } - }; - - private static final ThreadLocal> sEndingAnims = - new ThreadLocal>() { - @Override - protected ArrayList initialValue() { - return new ArrayList(); - } - }; - - private static final ThreadLocal> sReadyAnims = - new ThreadLocal>() { - @Override - protected ArrayList initialValue() { - return new ArrayList(); - } - }; - - // The time interpolator to be used if none is set on the animation - private static final /*Time*/Interpolator sDefaultInterpolator = - new AccelerateDecelerateInterpolator(); - - // type evaluators for the primitive types handled by this implementation - //private static final TypeEvaluator sIntEvaluator = new IntEvaluator(); - //private static final TypeEvaluator sFloatEvaluator = new FloatEvaluator(); - - /** - * Used to indicate whether the animation is currently playing in reverse. This causes the - * elapsed fraction to be inverted to calculate the appropriate values. - */ - private boolean mPlayingBackwards = false; - - /** - * This variable tracks the current iteration that is playing. When mCurrentIteration exceeds the - * repeatCount (if repeatCount!=INFINITE), the animation ends - */ - private int mCurrentIteration = 0; - - /** - * Tracks current elapsed/eased fraction, for querying in getAnimatedFraction(). - */ - private float mCurrentFraction = 0f; - - /** - * Tracks whether a startDelay'd animation has begun playing through the startDelay. - */ - private boolean mStartedDelay = false; - - /** - * Tracks the time at which the animation began playing through its startDelay. This is - * different from the mStartTime variable, which is used to track when the animation became - * active (which is when the startDelay expired and the animation was added to the active - * animations list). - */ - private long mDelayStartTime; - - /** - * Flag that represents the current state of the animation. Used to figure out when to start - * an animation (if state == STOPPED). Also used to end an animation that - * has been cancel()'d or end()'d since the last animation frame. Possible values are - * STOPPED, RUNNING, SEEKED. - */ - int mPlayingState = STOPPED; - - /** - * Additional playing state to indicate whether an animator has been start()'d. There is - * some lag between a call to start() and the first animation frame. We should still note - * that the animation has been started, even if it's first animation frame has not yet - * happened, and reflect that state in isRunning(). - * Note that delayed animations are different: they are not started until their first - * animation frame, which occurs after their delay elapses. - */ - private boolean mRunning = false; - - /** - * Additional playing state to indicate whether an animator has been start()'d, whether or - * not there is a nonzero startDelay. - */ - private boolean mStarted = false; - - /** - * Flag that denotes whether the animation is set up and ready to go. Used to - * set up animation that has not yet been started. - */ - boolean mInitialized = false; - - // - // Backing variables - // - - // How long the animation should last in ms - private long mDuration = 300; - - // The amount of time in ms to delay starting the animation after start() is called - private long mStartDelay = 0; - - // The number of milliseconds between animation frames - private static long sFrameDelay = DEFAULT_FRAME_DELAY; - - // The number of times the animation will repeat. The default is 0, which means the animation - // will play only once - private int mRepeatCount = 0; - - /** - * The type of repetition that will occur when repeatMode is nonzero. RESTART means the - * animation will start from the beginning on every new cycle. REVERSE means the animation - * will reverse directions on each iteration. - */ - private int mRepeatMode = RESTART; - - /** - * The time interpolator to be used. The elapsed fraction of the animation will be passed - * through this interpolator to calculate the interpolated fraction, which is then used to - * calculate the animated values. - */ - private /*Time*/Interpolator mInterpolator = sDefaultInterpolator; - - /** - * The set of listeners to be sent events through the life of an animation. - */ - private ArrayList mUpdateListeners = null; - - /** - * The property/value sets being animated. - */ - PropertyValuesHolder[] mValues; - - /** - * A hashmap of the PropertyValuesHolder objects. This map is used to lookup animated values - * by property name during calls to getAnimatedValue(String). - */ - HashMap mValuesMap; - - /** - * Public constants - */ - - /** - * When the animation reaches the end and repeatCount is INFINITE - * or a positive value, the animation restarts from the beginning. - */ - public static final int RESTART = 1; - /** - * When the animation reaches the end and repeatCount is INFINITE - * or a positive value, the animation reverses direction on every iteration. - */ - public static final int REVERSE = 2; - /** - * This value used used with the {@link #setRepeatCount(int)} property to repeat - * the animation indefinitely. - */ - public static final int INFINITE = -1; - - /** - * Creates a new ValueAnimator object. This default constructor is primarily for - * use internally; the factory methods which take parameters are more generally - * useful. - */ - public ValueAnimator() { - } - - /** - * Constructs and returns a ValueAnimator that animates between int values. A single - * value implies that that value is the one being animated to. However, this is not typically - * useful in a ValueAnimator object because there is no way for the object to determine the - * starting value for the animation (unlike ObjectAnimator, which can derive that value - * from the target object and property being animated). Therefore, there should typically - * be two or more values. - * - * @param values A set of values that the animation will animate between over time. - * @return A ValueAnimator object that is set up to animate between the given values. - */ - public static ValueAnimator ofInt(int... values) { - ValueAnimator anim = new ValueAnimator(); - anim.setIntValues(values); - return anim; - } - - /** - * Constructs and returns a ValueAnimator that animates between float values. A single - * value implies that that value is the one being animated to. However, this is not typically - * useful in a ValueAnimator object because there is no way for the object to determine the - * starting value for the animation (unlike ObjectAnimator, which can derive that value - * from the target object and property being animated). Therefore, there should typically - * be two or more values. - * - * @param values A set of values that the animation will animate between over time. - * @return A ValueAnimator object that is set up to animate between the given values. - */ - public static ValueAnimator ofFloat(float... values) { - ValueAnimator anim = new ValueAnimator(); - anim.setFloatValues(values); - return anim; - } - - /** - * Constructs and returns a ValueAnimator that animates between the values - * specified in the PropertyValuesHolder objects. - * - * @param values A set of PropertyValuesHolder objects whose values will be animated - * between over time. - * @return A ValueAnimator object that is set up to animate between the given values. - */ - public static ValueAnimator ofPropertyValuesHolder(PropertyValuesHolder... values) { - ValueAnimator anim = new ValueAnimator(); - anim.setValues(values); - return anim; - } - /** - * Constructs and returns a ValueAnimator that animates between Object values. A single - * value implies that that value is the one being animated to. However, this is not typically - * useful in a ValueAnimator object because there is no way for the object to determine the - * starting value for the animation (unlike ObjectAnimator, which can derive that value - * from the target object and property being animated). Therefore, there should typically - * be two or more values. - * - *

Since ValueAnimator does not know how to animate between arbitrary Objects, this - * factory method also takes a TypeEvaluator object that the ValueAnimator will use - * to perform that interpolation. - * - * @param evaluator A TypeEvaluator that will be called on each animation frame to - * provide the ncessry interpolation between the Object values to derive the animated - * value. - * @param values A set of values that the animation will animate between over time. - * @return A ValueAnimator object that is set up to animate between the given values. - */ - public static ValueAnimator ofObject(TypeEvaluator evaluator, Object... values) { - ValueAnimator anim = new ValueAnimator(); - anim.setObjectValues(values); - anim.setEvaluator(evaluator); - return anim; - } - - /** - * Sets int values that will be animated between. A single - * value implies that that value is the one being animated to. However, this is not typically - * useful in a ValueAnimator object because there is no way for the object to determine the - * starting value for the animation (unlike ObjectAnimator, which can derive that value - * from the target object and property being animated). Therefore, there should typically - * be two or more values. - * - *

If there are already multiple sets of values defined for this ValueAnimator via more - * than one PropertyValuesHolder object, this method will set the values for the first - * of those objects.

- * - * @param values A set of values that the animation will animate between over time. - */ - public void setIntValues(int... values) { - if (values == null || values.length == 0) { - return; - } - if (mValues == null || mValues.length == 0) { - setValues(new PropertyValuesHolder[]{PropertyValuesHolder.ofInt("", values)}); - } else { - PropertyValuesHolder valuesHolder = mValues[0]; - valuesHolder.setIntValues(values); - } - // New property/values/target should cause re-initialization prior to starting - mInitialized = false; - } - - /** - * Sets float values that will be animated between. A single - * value implies that that value is the one being animated to. However, this is not typically - * useful in a ValueAnimator object because there is no way for the object to determine the - * starting value for the animation (unlike ObjectAnimator, which can derive that value - * from the target object and property being animated). Therefore, there should typically - * be two or more values. - * - *

If there are already multiple sets of values defined for this ValueAnimator via more - * than one PropertyValuesHolder object, this method will set the values for the first - * of those objects.

- * - * @param values A set of values that the animation will animate between over time. - */ - public void setFloatValues(float... values) { - if (values == null || values.length == 0) { - return; - } - if (mValues == null || mValues.length == 0) { - setValues(new PropertyValuesHolder[]{PropertyValuesHolder.ofFloat("", values)}); - } else { - PropertyValuesHolder valuesHolder = mValues[0]; - valuesHolder.setFloatValues(values); - } - // New property/values/target should cause re-initialization prior to starting - mInitialized = false; - } - - /** - * Sets the values to animate between for this animation. A single - * value implies that that value is the one being animated to. However, this is not typically - * useful in a ValueAnimator object because there is no way for the object to determine the - * starting value for the animation (unlike ObjectAnimator, which can derive that value - * from the target object and property being animated). Therefore, there should typically - * be two or more values. - * - *

If there are already multiple sets of values defined for this ValueAnimator via more - * than one PropertyValuesHolder object, this method will set the values for the first - * of those objects.

- * - *

There should be a TypeEvaluator set on the ValueAnimator that knows how to interpolate - * between these value objects. ValueAnimator only knows how to interpolate between the - * primitive types specified in the other setValues() methods.

- * - * @param values The set of values to animate between. - */ - public void setObjectValues(Object... values) { - if (values == null || values.length == 0) { - return; - } - if (mValues == null || mValues.length == 0) { - setValues(new PropertyValuesHolder[]{PropertyValuesHolder.ofObject("", - (TypeEvaluator)null, values)}); - } else { - PropertyValuesHolder valuesHolder = mValues[0]; - valuesHolder.setObjectValues(values); - } - // New property/values/target should cause re-initialization prior to starting - mInitialized = false; - } - - /** - * Sets the values, per property, being animated between. This function is called internally - * by the constructors of ValueAnimator that take a list of values. But an ValueAnimator can - * be constructed without values and this method can be called to set the values manually - * instead. - * - * @param values The set of values, per property, being animated between. - */ - public void setValues(PropertyValuesHolder... values) { - int numValues = values.length; - mValues = values; - mValuesMap = new HashMap(numValues); - for (int i = 0; i < numValues; ++i) { - PropertyValuesHolder valuesHolder = values[i]; - mValuesMap.put(valuesHolder.getPropertyName(), valuesHolder); - } - // New property/values/target should cause re-initialization prior to starting - mInitialized = false; - } - - /** - * Returns the values that this ValueAnimator animates between. These values are stored in - * PropertyValuesHolder objects, even if the ValueAnimator was created with a simple list - * of value objects instead. - * - * @return PropertyValuesHolder[] An array of PropertyValuesHolder objects which hold the - * values, per property, that define the animation. - */ - public PropertyValuesHolder[] getValues() { - return mValues; - } - - /** - * This function is called immediately before processing the first animation - * frame of an animation. If there is a nonzero startDelay, the - * function is called after that delay ends. - * It takes care of the final initialization steps for the - * animation. - * - *

Overrides of this method should call the superclass method to ensure - * that internal mechanisms for the animation are set up correctly.

- */ - void initAnimation() { - if (!mInitialized) { - int numValues = mValues.length; - for (int i = 0; i < numValues; ++i) { - mValues[i].init(); - } - mInitialized = true; - } - } - - - /** - * Sets the length of the animation. The default duration is 300 milliseconds. - * - * @param duration The length of the animation, in milliseconds. This value cannot - * be negative. - * @return ValueAnimator The object called with setDuration(). This return - * value makes it easier to compose statements together that construct and then set the - * duration, as in ValueAnimator.ofInt(0, 10).setDuration(500).start(). - */ - public ValueAnimator setDuration(long duration) { - if (duration < 0) { - throw new IllegalArgumentException("Animators cannot have negative duration: " + - duration); - } - mDuration = duration; - return this; - } - - /** - * Gets the length of the animation. The default duration is 300 milliseconds. - * - * @return The length of the animation, in milliseconds. - */ - public long getDuration() { - return mDuration; - } - - /** - * Sets the position of the animation to the specified point in time. This time should - * be between 0 and the total duration of the animation, including any repetition. If - * the animation has not yet been started, then it will not advance forward after it is - * set to this time; it will simply set the time to this value and perform any appropriate - * actions based on that time. If the animation is already running, then setCurrentPlayTime() - * will set the current playing time to this value and continue playing from that point. - * - * @param playTime The time, in milliseconds, to which the animation is advanced or rewound. - */ - public void setCurrentPlayTime(long playTime) { - initAnimation(); - long currentTime = AnimationUtils.currentAnimationTimeMillis(); - if (mPlayingState != RUNNING) { - mSeekTime = playTime; - mPlayingState = SEEKED; - } - mStartTime = currentTime - playTime; - animationFrame(currentTime); - } - - /** - * Gets the current position of the animation in time, which is equal to the current - * time minus the time that the animation started. An animation that is not yet started will - * return a value of zero. - * - * @return The current position in time of the animation. - */ - public long getCurrentPlayTime() { - if (!mInitialized || mPlayingState == STOPPED) { - return 0; - } - return AnimationUtils.currentAnimationTimeMillis() - mStartTime; - } - - /** - * This custom, static handler handles the timing pulse that is shared by - * all active animations. This approach ensures that the setting of animation - * values will happen on the UI thread and that all animations will share - * the same times for calculating their values, which makes synchronizing - * animations possible. - * - */ - private static class AnimationHandler extends Handler { - /** - * There are only two messages that we care about: ANIMATION_START and - * ANIMATION_FRAME. The START message is sent when an animation's start() - * method is called. It cannot start synchronously when start() is called - * because the call may be on the wrong thread, and it would also not be - * synchronized with other animations because it would not start on a common - * timing pulse. So each animation sends a START message to the handler, which - * causes the handler to place the animation on the active animations queue and - * start processing frames for that animation. - * The FRAME message is the one that is sent over and over while there are any - * active animations to process. - */ - @Override - public void handleMessage(Message msg) { - boolean callAgain = true; - ArrayList animations = sAnimations.get(); - ArrayList delayedAnims = sDelayedAnims.get(); - switch (msg.what) { - // TODO: should we avoid sending frame message when starting if we - // were already running? - case ANIMATION_START: - ArrayList pendingAnimations = sPendingAnimations.get(); - if (animations.size() > 0 || delayedAnims.size() > 0) { - callAgain = false; - } - // pendingAnims holds any animations that have requested to be started - // We're going to clear sPendingAnimations, but starting animation may - // cause more to be added to the pending list (for example, if one animation - // starting triggers another starting). So we loop until sPendingAnimations - // is empty. - while (pendingAnimations.size() > 0) { - ArrayList pendingCopy = - (ArrayList) pendingAnimations.clone(); - pendingAnimations.clear(); - int count = pendingCopy.size(); - for (int i = 0; i < count; ++i) { - ValueAnimator anim = pendingCopy.get(i); - // If the animation has a startDelay, place it on the delayed list - if (anim.mStartDelay == 0) { - anim.startAnimation(); - } else { - delayedAnims.add(anim); - } - } - } - // fall through to process first frame of new animations - case ANIMATION_FRAME: - // currentTime holds the common time for all animations processed - // during this frame - long currentTime = AnimationUtils.currentAnimationTimeMillis(); - ArrayList readyAnims = sReadyAnims.get(); - ArrayList endingAnims = sEndingAnims.get(); - - // First, process animations currently sitting on the delayed queue, adding - // them to the active animations if they are ready - int numDelayedAnims = delayedAnims.size(); - for (int i = 0; i < numDelayedAnims; ++i) { - ValueAnimator anim = delayedAnims.get(i); - if (anim.delayedAnimationFrame(currentTime)) { - readyAnims.add(anim); - } - } - int numReadyAnims = readyAnims.size(); - if (numReadyAnims > 0) { - for (int i = 0; i < numReadyAnims; ++i) { - ValueAnimator anim = readyAnims.get(i); - anim.startAnimation(); - anim.mRunning = true; - delayedAnims.remove(anim); - } - readyAnims.clear(); - } - - // Now process all active animations. The return value from animationFrame() - // tells the handler whether it should now be ended - int numAnims = animations.size(); - int i = 0; - while (i < numAnims) { - ValueAnimator anim = animations.get(i); - if (anim.animationFrame(currentTime)) { - endingAnims.add(anim); - } - if (animations.size() == numAnims) { - ++i; - } else { - // An animation might be canceled or ended by client code - // during the animation frame. Check to see if this happened by - // seeing whether the current index is the same as it was before - // calling animationFrame(). Another approach would be to copy - // animations to a temporary list and process that list instead, - // but that entails garbage and processing overhead that would - // be nice to avoid. - --numAnims; - endingAnims.remove(anim); - } - } - if (endingAnims.size() > 0) { - for (i = 0; i < endingAnims.size(); ++i) { - endingAnims.get(i).endAnimation(); - } - endingAnims.clear(); - } - - // If there are still active or delayed animations, call the handler again - // after the frameDelay - if (callAgain && (!animations.isEmpty() || !delayedAnims.isEmpty())) { - sendEmptyMessageDelayed(ANIMATION_FRAME, Math.max(0, sFrameDelay - - (AnimationUtils.currentAnimationTimeMillis() - currentTime))); - } - break; - } - } - } - - /** - * The amount of time, in milliseconds, to delay starting the animation after - * {@link #start()} is called. - * - * @return the number of milliseconds to delay running the animation - */ - public long getStartDelay() { - return mStartDelay; - } - - /** - * The amount of time, in milliseconds, to delay starting the animation after - * {@link #start()} is called. - - * @param startDelay The amount of the delay, in milliseconds - */ - public void setStartDelay(long startDelay) { - this.mStartDelay = startDelay; - } - - /** - * The amount of time, in milliseconds, between each frame of the animation. This is a - * requested time that the animation will attempt to honor, but the actual delay between - * frames may be different, depending on system load and capabilities. This is a static - * function because the same delay will be applied to all animations, since they are all - * run off of a single timing loop. - * - * @return the requested time between frames, in milliseconds - */ - public static long getFrameDelay() { - return sFrameDelay; - } - - /** - * The amount of time, in milliseconds, between each frame of the animation. This is a - * requested time that the animation will attempt to honor, but the actual delay between - * frames may be different, depending on system load and capabilities. This is a static - * function because the same delay will be applied to all animations, since they are all - * run off of a single timing loop. - * - * @param frameDelay the requested time between frames, in milliseconds - */ - public static void setFrameDelay(long frameDelay) { - sFrameDelay = frameDelay; - } - - /** - * The most recent value calculated by this ValueAnimator when there is just one - * property being animated. This value is only sensible while the animation is running. The main - * purpose for this read-only property is to retrieve the value from the ValueAnimator - * during a call to {@link AnimatorUpdateListener#onAnimationUpdate(ValueAnimator)}, which - * is called during each animation frame, immediately after the value is calculated. - * - * @return animatedValue The value most recently calculated by this ValueAnimator for - * the single property being animated. If there are several properties being animated - * (specified by several PropertyValuesHolder objects in the constructor), this function - * returns the animated value for the first of those objects. - */ - public Object getAnimatedValue() { - if (mValues != null && mValues.length > 0) { - return mValues[0].getAnimatedValue(); - } - // Shouldn't get here; should always have values unless ValueAnimator was set up wrong - return null; - } - - /** - * The most recent value calculated by this ValueAnimator for propertyName. - * The main purpose for this read-only property is to retrieve the value from the - * ValueAnimator during a call to - * {@link AnimatorUpdateListener#onAnimationUpdate(ValueAnimator)}, which - * is called during each animation frame, immediately after the value is calculated. - * - * @return animatedValue The value most recently calculated for the named property - * by this ValueAnimator. - */ - public Object getAnimatedValue(String propertyName) { - PropertyValuesHolder valuesHolder = mValuesMap.get(propertyName); - if (valuesHolder != null) { - return valuesHolder.getAnimatedValue(); - } else { - // At least avoid crashing if called with bogus propertyName - return null; - } - } - - /** - * Sets how many times the animation should be repeated. If the repeat - * count is 0, the animation is never repeated. If the repeat count is - * greater than 0 or {@link #INFINITE}, the repeat mode will be taken - * into account. The repeat count is 0 by default. - * - * @param value the number of times the animation should be repeated - */ - public void setRepeatCount(int value) { - mRepeatCount = value; - } - /** - * Defines how many times the animation should repeat. The default value - * is 0. - * - * @return the number of times the animation should repeat, or {@link #INFINITE} - */ - public int getRepeatCount() { - return mRepeatCount; - } - - /** - * Defines what this animation should do when it reaches the end. This - * setting is applied only when the repeat count is either greater than - * 0 or {@link #INFINITE}. Defaults to {@link #RESTART}. - * - * @param value {@link #RESTART} or {@link #REVERSE} - */ - public void setRepeatMode(int value) { - mRepeatMode = value; - } - - /** - * Defines what this animation should do when it reaches the end. - * - * @return either one of {@link #REVERSE} or {@link #RESTART} - */ - public int getRepeatMode() { - return mRepeatMode; - } - - /** - * Adds a listener to the set of listeners that are sent update events through the life of - * an animation. This method is called on all listeners for every frame of the animation, - * after the values for the animation have been calculated. - * - * @param listener the listener to be added to the current set of listeners for this animation. - */ - public void addUpdateListener(AnimatorUpdateListener listener) { - if (mUpdateListeners == null) { - mUpdateListeners = new ArrayList(); - } - mUpdateListeners.add(listener); - } - - /** - * Removes all listeners from the set listening to frame updates for this animation. - */ - public void removeAllUpdateListeners() { - if (mUpdateListeners == null) { - return; - } - mUpdateListeners.clear(); - mUpdateListeners = null; - } - - /** - * Removes a listener from the set listening to frame updates for this animation. - * - * @param listener the listener to be removed from the current set of update listeners - * for this animation. - */ - public void removeUpdateListener(AnimatorUpdateListener listener) { - if (mUpdateListeners == null) { - return; - } - mUpdateListeners.remove(listener); - if (mUpdateListeners.size() == 0) { - mUpdateListeners = null; - } - } - - - /** - * The time interpolator used in calculating the elapsed fraction of this animation. The - * interpolator determines whether the animation runs with linear or non-linear motion, - * such as acceleration and deceleration. The default value is - * {@link android.view.animation.AccelerateDecelerateInterpolator} - * - * @param value the interpolator to be used by this animation. A value of null - * will result in linear interpolation. - */ - @Override - public void setInterpolator(/*Time*/Interpolator value) { - if (value != null) { - mInterpolator = value; - } else { - mInterpolator = new LinearInterpolator(); - } - } - - /** - * Returns the timing interpolator that this ValueAnimator uses. - * - * @return The timing interpolator for this ValueAnimator. - */ - public /*Time*/Interpolator getInterpolator() { - return mInterpolator; - } - - /** - * The type evaluator to be used when calculating the animated values of this animation. - * The system will automatically assign a float or int evaluator based on the type - * of startValue and endValue in the constructor. But if these values - * are not one of these primitive types, or if different evaluation is desired (such as is - * necessary with int values that represent colors), a custom evaluator needs to be assigned. - * For example, when running an animation on color values, the {@link ArgbEvaluator} - * should be used to get correct RGB color interpolation. - * - *

If this ValueAnimator has only one set of values being animated between, this evaluator - * will be used for that set. If there are several sets of values being animated, which is - * the case if PropertyValuesHOlder objects were set on the ValueAnimator, then the evaluator - * is assigned just to the first PropertyValuesHolder object.

- * - * @param value the evaluator to be used this animation - */ - public void setEvaluator(TypeEvaluator value) { - if (value != null && mValues != null && mValues.length > 0) { - mValues[0].setEvaluator(value); - } - } - - /** - * Start the animation playing. This version of start() takes a boolean flag that indicates - * whether the animation should play in reverse. The flag is usually false, but may be set - * to true if called from the reverse() method. - * - *

The animation started by calling this method will be run on the thread that called - * this method. This thread should have a Looper on it (a runtime exception will be thrown if - * this is not the case). Also, if the animation will animate - * properties of objects in the view hierarchy, then the calling thread should be the UI - * thread for that view hierarchy.

- * - * @param playBackwards Whether the ValueAnimator should start playing in reverse. - */ - private void start(boolean playBackwards) { - if (Looper.myLooper() == null) { - throw new AndroidRuntimeException("Animators may only be run on Looper threads"); - } - mPlayingBackwards = playBackwards; - mCurrentIteration = 0; - mPlayingState = STOPPED; - mStarted = true; - mStartedDelay = false; - sPendingAnimations.get().add(this); - if (mStartDelay == 0) { - // This sets the initial value of the animation, prior to actually starting it running - setCurrentPlayTime(getCurrentPlayTime()); - mPlayingState = STOPPED; - mRunning = true; - - if (mListeners != null) { - ArrayList tmpListeners = - (ArrayList) mListeners.clone(); - int numListeners = tmpListeners.size(); - for (int i = 0; i < numListeners; ++i) { - tmpListeners.get(i).onAnimationStart(this); - } - } - } - AnimationHandler animationHandler = sAnimationHandler.get(); - if (animationHandler == null) { - animationHandler = new AnimationHandler(); - sAnimationHandler.set(animationHandler); - } - animationHandler.sendEmptyMessage(ANIMATION_START); - } - - @Override - public void start() { - start(false); - } - - @Override - public void cancel() { - // Only cancel if the animation is actually running or has been started and is about - // to run - if (mPlayingState != STOPPED || sPendingAnimations.get().contains(this) || - sDelayedAnims.get().contains(this)) { - // Only notify listeners if the animator has actually started - if (mRunning && mListeners != null) { - ArrayList tmpListeners = - (ArrayList) mListeners.clone(); - for (AnimatorListener listener : tmpListeners) { - listener.onAnimationCancel(this); - } - } - endAnimation(); - } - } - - @Override - public void end() { - if (!sAnimations.get().contains(this) && !sPendingAnimations.get().contains(this)) { - // Special case if the animation has not yet started; get it ready for ending - mStartedDelay = false; - startAnimation(); - } else if (!mInitialized) { - initAnimation(); - } - // The final value set on the target varies, depending on whether the animation - // was supposed to repeat an odd number of times - if (mRepeatCount > 0 && (mRepeatCount & 0x01) == 1) { - animateValue(0f); - } else { - animateValue(1f); - } - endAnimation(); - } - - @Override - public boolean isRunning() { - return (mPlayingState == RUNNING || mRunning); - } - - @Override - public boolean isStarted() { - return mStarted; - } - - /** - * Plays the ValueAnimator in reverse. If the animation is already running, - * it will stop itself and play backwards from the point reached when reverse was called. - * If the animation is not currently running, then it will start from the end and - * play backwards. This behavior is only set for the current animation; future playing - * of the animation will use the default behavior of playing forward. - */ - public void reverse() { - mPlayingBackwards = !mPlayingBackwards; - if (mPlayingState == RUNNING) { - long currentTime = AnimationUtils.currentAnimationTimeMillis(); - long currentPlayTime = currentTime - mStartTime; - long timeLeft = mDuration - currentPlayTime; - mStartTime = currentTime - timeLeft; - } else { - start(true); - } - } - - /** - * Called internally to end an animation by removing it from the animations list. Must be - * called on the UI thread. - */ - private void endAnimation() { - sAnimations.get().remove(this); - sPendingAnimations.get().remove(this); - sDelayedAnims.get().remove(this); - mPlayingState = STOPPED; - if (mRunning && mListeners != null) { - ArrayList tmpListeners = - (ArrayList) mListeners.clone(); - int numListeners = tmpListeners.size(); - for (int i = 0; i < numListeners; ++i) { - tmpListeners.get(i).onAnimationEnd(this); - } - } - mRunning = false; - mStarted = false; - } - - /** - * Called internally to start an animation by adding it to the active animations list. Must be - * called on the UI thread. - */ - private void startAnimation() { - initAnimation(); - sAnimations.get().add(this); - if (mStartDelay > 0 && mListeners != null) { - // Listeners were already notified in start() if startDelay is 0; this is - // just for delayed animations - ArrayList tmpListeners = - (ArrayList) mListeners.clone(); - int numListeners = tmpListeners.size(); - for (int i = 0; i < numListeners; ++i) { - tmpListeners.get(i).onAnimationStart(this); - } - } - } - - /** - * Internal function called to process an animation frame on an animation that is currently - * sleeping through its startDelay phase. The return value indicates whether it - * should be woken up and put on the active animations queue. - * - * @param currentTime The current animation time, used to calculate whether the animation - * has exceeded its startDelay and should be started. - * @return True if the animation's startDelay has been exceeded and the animation - * should be added to the set of active animations. - */ - private boolean delayedAnimationFrame(long currentTime) { - if (!mStartedDelay) { - mStartedDelay = true; - mDelayStartTime = currentTime; - } else { - long deltaTime = currentTime - mDelayStartTime; - if (deltaTime > mStartDelay) { - // startDelay ended - start the anim and record the - // mStartTime appropriately - mStartTime = currentTime - (deltaTime - mStartDelay); - mPlayingState = RUNNING; - return true; - } - } - return false; - } - - /** - * This internal function processes a single animation frame for a given animation. The - * currentTime parameter is the timing pulse sent by the handler, used to calculate the - * elapsed duration, and therefore - * the elapsed fraction, of the animation. The return value indicates whether the animation - * should be ended (which happens when the elapsed time of the animation exceeds the - * animation's duration, including the repeatCount). - * - * @param currentTime The current time, as tracked by the static timing handler - * @return true if the animation's duration, including any repetitions due to - * repeatCount has been exceeded and the animation should be ended. - */ - boolean animationFrame(long currentTime) { - boolean done = false; - - if (mPlayingState == STOPPED) { - mPlayingState = RUNNING; - if (mSeekTime < 0) { - mStartTime = currentTime; - } else { - mStartTime = currentTime - mSeekTime; - // Now that we're playing, reset the seek time - mSeekTime = -1; - } - } - switch (mPlayingState) { - case RUNNING: - case SEEKED: - float fraction = mDuration > 0 ? (float)(currentTime - mStartTime) / mDuration : 1f; - if (fraction >= 1f) { - if (mCurrentIteration < mRepeatCount || mRepeatCount == INFINITE) { - // Time to repeat - if (mListeners != null) { - int numListeners = mListeners.size(); - for (int i = 0; i < numListeners; ++i) { - mListeners.get(i).onAnimationRepeat(this); - } - } - if (mRepeatMode == REVERSE) { - mPlayingBackwards = mPlayingBackwards ? false : true; - } - mCurrentIteration += (int)fraction; - fraction = fraction % 1f; - mStartTime += mDuration; - } else { - done = true; - fraction = Math.min(fraction, 1.0f); - } - } - if (mPlayingBackwards) { - fraction = 1f - fraction; - } - animateValue(fraction); - break; - } - - return done; - } - - /** - * Returns the current animation fraction, which is the elapsed/interpolated fraction used in - * the most recent frame update on the animation. - * - * @return Elapsed/interpolated fraction of the animation. - */ - public float getAnimatedFraction() { - return mCurrentFraction; - } - - /** - * This method is called with the elapsed fraction of the animation during every - * animation frame. This function turns the elapsed fraction into an interpolated fraction - * and then into an animated value (from the evaluator. The function is called mostly during - * animation updates, but it is also called when the end() - * function is called, to set the final value on the property. - * - *

Overrides of this method must call the superclass to perform the calculation - * of the animated value.

- * - * @param fraction The elapsed fraction of the animation. - */ - void animateValue(float fraction) { - fraction = mInterpolator.getInterpolation(fraction); - mCurrentFraction = fraction; - int numValues = mValues.length; - for (int i = 0; i < numValues; ++i) { - mValues[i].calculateValue(fraction); - } - if (mUpdateListeners != null) { - int numListeners = mUpdateListeners.size(); - for (int i = 0; i < numListeners; ++i) { - mUpdateListeners.get(i).onAnimationUpdate(this); - } - } - } - - @Override - public ValueAnimator clone() { - final ValueAnimator anim = (ValueAnimator) super.clone(); - if (mUpdateListeners != null) { - ArrayList oldListeners = mUpdateListeners; - anim.mUpdateListeners = new ArrayList(); - int numListeners = oldListeners.size(); - for (int i = 0; i < numListeners; ++i) { - anim.mUpdateListeners.add(oldListeners.get(i)); - } - } - anim.mSeekTime = -1; - anim.mPlayingBackwards = false; - anim.mCurrentIteration = 0; - anim.mInitialized = false; - anim.mPlayingState = STOPPED; - anim.mStartedDelay = false; - PropertyValuesHolder[] oldValues = mValues; - if (oldValues != null) { - int numValues = oldValues.length; - anim.mValues = new PropertyValuesHolder[numValues]; - anim.mValuesMap = new HashMap(numValues); - for (int i = 0; i < numValues; ++i) { - PropertyValuesHolder newValuesHolder = oldValues[i].clone(); - anim.mValues[i] = newValuesHolder; - anim.mValuesMap.put(newValuesHolder.getPropertyName(), newValuesHolder); - } - } - return anim; - } - - /** - * Implementors of this interface can add themselves as update listeners - * to an ValueAnimator instance to receive callbacks on every animation - * frame, after the current frame's values have been calculated for that - * ValueAnimator. - */ - public static interface AnimatorUpdateListener { - /** - *

Notifies the occurrence of another frame of the animation.

- * - * @param animation The animation which was repeated. - */ - void onAnimationUpdate(ValueAnimator animation); - - } - - /** - * Return the number of animations currently running. - * - * Used by StrictMode internally to annotate violations. Only - * called on the main thread. - * - * @hide - */ - public static int getCurrentAnimationsCount() { - return sAnimations.get().size(); - } - - /** - * Clear all animations on this thread, without canceling or ending them. - * This should be used with caution. - * - * @hide - */ - public static void clearAllAnimations() { - sAnimations.get().clear(); - sPendingAnimations.get().clear(); - sDelayedAnims.get().clear(); - } - - @Override - public String toString() { - String returnVal = "ValueAnimator@" + Integer.toHexString(hashCode()); - if (mValues != null) { - for (int i = 0; i < mValues.length; ++i) { - returnVal += "\n " + mValues[i].toString(); - } - } - return returnVal; - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/NineViewGroup.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/NineViewGroup.java deleted file mode 100644 index 7b830b9c0..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/NineViewGroup.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.actionbarsherlock.internal.nineoldandroids.view; - -import android.content.Context; -import android.util.AttributeSet; -import android.view.ViewGroup; - -import com.actionbarsherlock.internal.nineoldandroids.view.animation.AnimatorProxy; - -public abstract class NineViewGroup extends ViewGroup { - private final AnimatorProxy mProxy; - - public NineViewGroup(Context context) { - super(context); - mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; - } - public NineViewGroup(Context context, AttributeSet attrs) { - super(context, attrs); - mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; - } - public NineViewGroup(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; - } - - @Override - public void setVisibility(int visibility) { - if (mProxy != null) { - if (visibility == GONE) { - clearAnimation(); - } else if (visibility == VISIBLE) { - setAnimation(mProxy); - } - } - super.setVisibility(visibility); - } - - public float getAlpha() { - if (AnimatorProxy.NEEDS_PROXY) { - return mProxy.getAlpha(); - } else { - return super.getAlpha(); - } - } - public void setAlpha(float alpha) { - if (AnimatorProxy.NEEDS_PROXY) { - mProxy.setAlpha(alpha); - } else { - super.setAlpha(alpha); - } - } - public float getTranslationX() { - if (AnimatorProxy.NEEDS_PROXY) { - return mProxy.getTranslationX(); - } else { - return super.getTranslationX(); - } - } - public void setTranslationX(float translationX) { - if (AnimatorProxy.NEEDS_PROXY) { - mProxy.setTranslationX(translationX); - } else { - super.setTranslationX(translationX); - } - } - public float getTranslationY() { - if (AnimatorProxy.NEEDS_PROXY) { - return mProxy.getTranslationY(); - } else { - return super.getTranslationY(); - } - } - public void setTranslationY(float translationY) { - if (AnimatorProxy.NEEDS_PROXY) { - mProxy.setTranslationY(translationY); - } else { - super.setTranslationY(translationY); - } - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/AnimatorProxy.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/AnimatorProxy.java deleted file mode 100644 index 067d0494e..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/AnimatorProxy.java +++ /dev/null @@ -1,212 +0,0 @@ -package com.actionbarsherlock.internal.nineoldandroids.view.animation; - -import java.lang.ref.WeakReference; -import java.util.WeakHashMap; -import android.graphics.Matrix; -import android.graphics.RectF; -import android.os.Build; -import android.util.FloatMath; -import android.view.View; -import android.view.animation.Animation; -import android.view.animation.Transformation; - -public final class AnimatorProxy extends Animation { - public static final boolean NEEDS_PROXY = Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB; - - private static final WeakHashMap PROXIES = - new WeakHashMap(); - - public static AnimatorProxy wrap(View view) { - AnimatorProxy proxy = PROXIES.get(view); - if (proxy == null) { - proxy = new AnimatorProxy(view); - PROXIES.put(view, proxy); - } - return proxy; - } - - private final WeakReference mView; - - private float mAlpha = 1; - private float mScaleX = 1; - private float mScaleY = 1; - private float mTranslationX; - private float mTranslationY; - - private final RectF mBefore = new RectF(); - private final RectF mAfter = new RectF(); - private final Matrix mTempMatrix = new Matrix(); - - private AnimatorProxy(View view) { - setDuration(0); //perform transformation immediately - setFillAfter(true); //persist transformation beyond duration - view.setAnimation(this); - mView = new WeakReference(view); - } - - public float getAlpha() { - return mAlpha; - } - public void setAlpha(float alpha) { - if (mAlpha != alpha) { - mAlpha = alpha; - View view = mView.get(); - if (view != null) { - view.invalidate(); - } - } - } - public float getScaleX() { - return mScaleX; - } - public void setScaleX(float scaleX) { - if (mScaleX != scaleX) { - prepareForUpdate(); - mScaleX = scaleX; - invalidateAfterUpdate(); - } - } - public float getScaleY() { - return mScaleY; - } - public void setScaleY(float scaleY) { - if (mScaleY != scaleY) { - prepareForUpdate(); - mScaleY = scaleY; - invalidateAfterUpdate(); - } - } - public int getScrollX() { - View view = mView.get(); - if (view == null) { - return 0; - } - return view.getScrollX(); - } - public void setScrollX(int value) { - View view = mView.get(); - if (view != null) { - view.scrollTo(value, view.getScrollY()); - } - } - public int getScrollY() { - View view = mView.get(); - if (view == null) { - return 0; - } - return view.getScrollY(); - } - public void setScrollY(int value) { - View view = mView.get(); - if (view != null) { - view.scrollTo(view.getScrollY(), value); - } - } - - public float getTranslationX() { - return mTranslationX; - } - public void setTranslationX(float translationX) { - if (mTranslationX != translationX) { - prepareForUpdate(); - mTranslationX = translationX; - invalidateAfterUpdate(); - } - } - public float getTranslationY() { - return mTranslationY; - } - public void setTranslationY(float translationY) { - if (mTranslationY != translationY) { - prepareForUpdate(); - mTranslationY = translationY; - invalidateAfterUpdate(); - } - } - - private void prepareForUpdate() { - View view = mView.get(); - if (view != null) { - computeRect(mBefore, view); - } - } - private void invalidateAfterUpdate() { - View view = mView.get(); - if (view == null) { - return; - } - View parent = (View)view.getParent(); - if (parent == null) { - return; - } - - view.setAnimation(this); - - final RectF after = mAfter; - computeRect(after, view); - after.union(mBefore); - - parent.invalidate( - (int) FloatMath.floor(after.left), - (int) FloatMath.floor(after.top), - (int) FloatMath.ceil(after.right), - (int) FloatMath.ceil(after.bottom)); - } - - private void computeRect(final RectF r, View view) { - // compute current rectangle according to matrix transformation - final float w = view.getWidth(); - final float h = view.getHeight(); - - // use a rectangle at 0,0 to make sure we don't run into issues with scaling - r.set(0, 0, w, h); - - final Matrix m = mTempMatrix; - m.reset(); - transformMatrix(m, view); - mTempMatrix.mapRect(r); - - r.offset(view.getLeft(), view.getTop()); - - // Straighten coords if rotations flipped them - if (r.right < r.left) { - final float f = r.right; - r.right = r.left; - r.left = f; - } - if (r.bottom < r.top) { - final float f = r.top; - r.top = r.bottom; - r.bottom = f; - } - } - - private void transformMatrix(Matrix m, View view) { - final float w = view.getWidth(); - final float h = view.getHeight(); - - final float sX = mScaleX; - final float sY = mScaleY; - if ((sX != 1.0f) || (sY != 1.0f)) { - final float deltaSX = ((sX * w) - w) / 2f; - final float deltaSY = ((sY * h) - h) / 2f; - m.postScale(sX, sY); - m.postTranslate(-deltaSX, -deltaSY); - } - m.postTranslate(mTranslationX, mTranslationY); - } - - @Override - protected void applyTransformation(float interpolatedTime, Transformation t) { - View view = mView.get(); - if (view != null) { - t.setAlpha(mAlpha); - transformMatrix(t.getMatrix(), view); - } - } - - @Override - public void reset() { - /* Do nothing. */ - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineFrameLayout.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineFrameLayout.java deleted file mode 100644 index 2c428e907..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineFrameLayout.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.actionbarsherlock.internal.nineoldandroids.widget; - -import android.content.Context; -import android.util.AttributeSet; -import android.widget.FrameLayout; - -import com.actionbarsherlock.internal.nineoldandroids.view.animation.AnimatorProxy; - -public class NineFrameLayout extends FrameLayout { - private final AnimatorProxy mProxy; - - public NineFrameLayout(Context context) { - super(context); - mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; - } - public NineFrameLayout(Context context, AttributeSet attrs) { - super(context, attrs); - mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; - } - public NineFrameLayout(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; - } - - @Override - public void setVisibility(int visibility) { - if (mProxy != null) { - if (visibility == GONE) { - clearAnimation(); - } else if (visibility == VISIBLE) { - setAnimation(mProxy); - } - } - super.setVisibility(visibility); - } - - public float getAlpha() { - if (AnimatorProxy.NEEDS_PROXY) { - return mProxy.getAlpha(); - } else { - return super.getAlpha(); - } - } - public void setAlpha(float alpha) { - if (AnimatorProxy.NEEDS_PROXY) { - mProxy.setAlpha(alpha); - } else { - super.setAlpha(alpha); - } - } - public float getTranslationY() { - if (AnimatorProxy.NEEDS_PROXY) { - return mProxy.getTranslationY(); - } else { - return super.getTranslationY(); - } - } - public void setTranslationY(float translationY) { - if (AnimatorProxy.NEEDS_PROXY) { - mProxy.setTranslationY(translationY); - } else { - super.setTranslationY(translationY); - } - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineHorizontalScrollView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineHorizontalScrollView.java deleted file mode 100644 index 129b5aaaa..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineHorizontalScrollView.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.actionbarsherlock.internal.nineoldandroids.widget; - -import android.content.Context; -import android.widget.HorizontalScrollView; -import com.actionbarsherlock.internal.nineoldandroids.view.animation.AnimatorProxy; - -public class NineHorizontalScrollView extends HorizontalScrollView { - private final AnimatorProxy mProxy; - - public NineHorizontalScrollView(Context context) { - super(context); - mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; - } - - @Override - public void setVisibility(int visibility) { - if (mProxy != null) { - if (visibility == GONE) { - clearAnimation(); - } else if (visibility == VISIBLE) { - setAnimation(mProxy); - } - } - super.setVisibility(visibility); - } - - public float getAlpha() { - if (AnimatorProxy.NEEDS_PROXY) { - return mProxy.getAlpha(); - } else { - return super.getAlpha(); - } - } - public void setAlpha(float alpha) { - if (AnimatorProxy.NEEDS_PROXY) { - mProxy.setAlpha(alpha); - } else { - super.setAlpha(alpha); - } - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineLinearLayout.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineLinearLayout.java deleted file mode 100644 index a670b1f64..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineLinearLayout.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.actionbarsherlock.internal.nineoldandroids.widget; - -import android.content.Context; -import android.util.AttributeSet; -import android.widget.LinearLayout; - -import com.actionbarsherlock.internal.nineoldandroids.view.animation.AnimatorProxy; - -public class NineLinearLayout extends LinearLayout { - private final AnimatorProxy mProxy; - - public NineLinearLayout(Context context) { - super(context); - mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; - } - public NineLinearLayout(Context context, AttributeSet attrs) { - super(context, attrs); - mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; - } - public NineLinearLayout(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; - } - - @Override - public void setVisibility(int visibility) { - if (mProxy != null) { - if (visibility == GONE) { - clearAnimation(); - } else if (visibility == VISIBLE) { - setAnimation(mProxy); - } - } - super.setVisibility(visibility); - } - - public float getAlpha() { - if (AnimatorProxy.NEEDS_PROXY) { - return mProxy.getAlpha(); - } else { - return super.getAlpha(); - } - } - public void setAlpha(float alpha) { - if (AnimatorProxy.NEEDS_PROXY) { - mProxy.setAlpha(alpha); - } else { - super.setAlpha(alpha); - } - } - public float getTranslationX() { - if (AnimatorProxy.NEEDS_PROXY) { - return mProxy.getTranslationX(); - } else { - return super.getTranslationX(); - } - } - public void setTranslationX(float translationX) { - if (AnimatorProxy.NEEDS_PROXY) { - mProxy.setTranslationX(translationX); - } else { - super.setTranslationX(translationX); - } - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/ActionProviderWrapper.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/ActionProviderWrapper.java deleted file mode 100644 index b136d50f0..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/view/ActionProviderWrapper.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.actionbarsherlock.internal.view; - -import com.actionbarsherlock.internal.view.menu.SubMenuWrapper; -import com.actionbarsherlock.view.ActionProvider; -import android.view.View; - -public class ActionProviderWrapper extends android.view.ActionProvider { - private final ActionProvider mProvider; - - - public ActionProviderWrapper(ActionProvider provider) { - super(null/*TODO*/); //XXX this *should* be unused - mProvider = provider; - } - - - public ActionProvider unwrap() { - return mProvider; - } - - @Override - public View onCreateActionView() { - return mProvider.onCreateActionView(); - } - - @Override - public boolean hasSubMenu() { - return mProvider.hasSubMenu(); - } - - @Override - public boolean onPerformDefaultAction() { - return mProvider.onPerformDefaultAction(); - } - - @Override - public void onPrepareSubMenu(android.view.SubMenu subMenu) { - mProvider.onPrepareSubMenu(new SubMenuWrapper(subMenu)); - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/StandaloneActionMode.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/StandaloneActionMode.java deleted file mode 100644 index 0a87bd3f7..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/view/StandaloneActionMode.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (C) 2010 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.actionbarsherlock.internal.view; - -import android.content.Context; -import android.view.View; -import android.view.accessibility.AccessibilityEvent; - -import java.lang.ref.WeakReference; - -import com.actionbarsherlock.internal.view.menu.MenuBuilder; -import com.actionbarsherlock.internal.view.menu.MenuPopupHelper; -import com.actionbarsherlock.internal.view.menu.SubMenuBuilder; -import com.actionbarsherlock.internal.widget.ActionBarContextView; -import com.actionbarsherlock.view.ActionMode; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuInflater; -import com.actionbarsherlock.view.MenuItem; - -public class StandaloneActionMode extends ActionMode implements MenuBuilder.Callback { - private Context mContext; - private ActionBarContextView mContextView; - private ActionMode.Callback mCallback; - private WeakReference mCustomView; - private boolean mFinished; - private boolean mFocusable; - - private MenuBuilder mMenu; - - public StandaloneActionMode(Context context, ActionBarContextView view, - ActionMode.Callback callback, boolean isFocusable) { - mContext = context; - mContextView = view; - mCallback = callback; - - mMenu = new MenuBuilder(context).setDefaultShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); - mMenu.setCallback(this); - mFocusable = isFocusable; - } - - @Override - public void setTitle(CharSequence title) { - mContextView.setTitle(title); - } - - @Override - public void setSubtitle(CharSequence subtitle) { - mContextView.setSubtitle(subtitle); - } - - @Override - public void setTitle(int resId) { - setTitle(mContext.getString(resId)); - } - - @Override - public void setSubtitle(int resId) { - setSubtitle(mContext.getString(resId)); - } - - @Override - public void setCustomView(View view) { - mContextView.setCustomView(view); - mCustomView = view != null ? new WeakReference(view) : null; - } - - @Override - public void invalidate() { - mCallback.onPrepareActionMode(this, mMenu); - } - - @Override - public void finish() { - if (mFinished) { - return; - } - mFinished = true; - - mContextView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); - mCallback.onDestroyActionMode(this); - } - - @Override - public Menu getMenu() { - return mMenu; - } - - @Override - public CharSequence getTitle() { - return mContextView.getTitle(); - } - - @Override - public CharSequence getSubtitle() { - return mContextView.getSubtitle(); - } - - @Override - public View getCustomView() { - return mCustomView != null ? mCustomView.get() : null; - } - - @Override - public MenuInflater getMenuInflater() { - return new MenuInflater(mContext); - } - - public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) { - return mCallback.onActionItemClicked(this, item); - } - - public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) { - } - - public boolean onSubMenuSelected(SubMenuBuilder subMenu) { - if (!subMenu.hasVisibleItems()) { - return true; - } - - new MenuPopupHelper(mContext, subMenu).show(); - return true; - } - - public void onCloseSubMenu(SubMenuBuilder menu) { - } - - public void onMenuModeChange(MenuBuilder menu) { - invalidate(); - mContextView.showOverflowMenu(); - } - - public boolean isUiFocusable() { - return mFocusable; - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/View_HasStateListenerSupport.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/View_HasStateListenerSupport.java deleted file mode 100644 index 7d45e81be..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/view/View_HasStateListenerSupport.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.actionbarsherlock.internal.view; - -public interface View_HasStateListenerSupport { - void addOnAttachStateChangeListener(View_OnAttachStateChangeListener listener); - void removeOnAttachStateChangeListener(View_OnAttachStateChangeListener listener); -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/View_OnAttachStateChangeListener.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/View_OnAttachStateChangeListener.java deleted file mode 100644 index 3869d3290..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/view/View_OnAttachStateChangeListener.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.actionbarsherlock.internal.view; - -import android.view.View; - -public interface View_OnAttachStateChangeListener { - void onViewAttachedToWindow(View v); - void onViewDetachedFromWindow(View v); -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenu.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenu.java deleted file mode 100644 index 0354ad1ad..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenu.java +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Copyright (C) 2010 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.actionbarsherlock.internal.view.menu; - -import java.util.ArrayList; -import java.util.List; - -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; -import android.view.KeyEvent; - -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuItem; -import com.actionbarsherlock.view.SubMenu; - -/** - * @hide - */ -public class ActionMenu implements Menu { - private Context mContext; - - private boolean mIsQwerty; - - private ArrayList mItems; - - public ActionMenu(Context context) { - mContext = context; - mItems = new ArrayList(); - } - - public Context getContext() { - return mContext; - } - - public MenuItem add(CharSequence title) { - return add(0, 0, 0, title); - } - - public MenuItem add(int titleRes) { - return add(0, 0, 0, titleRes); - } - - public MenuItem add(int groupId, int itemId, int order, int titleRes) { - return add(groupId, itemId, order, mContext.getResources().getString(titleRes)); - } - - public MenuItem add(int groupId, int itemId, int order, CharSequence title) { - ActionMenuItem item = new ActionMenuItem(getContext(), - groupId, itemId, 0, order, title); - mItems.add(order, item); - return item; - } - - public int addIntentOptions(int groupId, int itemId, int order, - ComponentName caller, Intent[] specifics, Intent intent, int flags, - MenuItem[] outSpecificItems) { - PackageManager pm = mContext.getPackageManager(); - final List lri = - pm.queryIntentActivityOptions(caller, specifics, intent, 0); - final int N = lri != null ? lri.size() : 0; - - if ((flags & FLAG_APPEND_TO_GROUP) == 0) { - removeGroup(groupId); - } - - for (int i=0; i= 0) { - outSpecificItems[ri.specificIndex] = item; - } - } - - return N; - } - - public SubMenu addSubMenu(CharSequence title) { - // TODO Implement submenus - return null; - } - - public SubMenu addSubMenu(int titleRes) { - // TODO Implement submenus - return null; - } - - public SubMenu addSubMenu(int groupId, int itemId, int order, - CharSequence title) { - // TODO Implement submenus - return null; - } - - public SubMenu addSubMenu(int groupId, int itemId, int order, int titleRes) { - // TODO Implement submenus - return null; - } - - public void clear() { - mItems.clear(); - } - - public void close() { - } - - private int findItemIndex(int id) { - final ArrayList items = mItems; - final int itemCount = items.size(); - for (int i = 0; i < itemCount; i++) { - if (items.get(i).getItemId() == id) { - return i; - } - } - - return -1; - } - - public MenuItem findItem(int id) { - return mItems.get(findItemIndex(id)); - } - - public MenuItem getItem(int index) { - return mItems.get(index); - } - - public boolean hasVisibleItems() { - final ArrayList items = mItems; - final int itemCount = items.size(); - - for (int i = 0; i < itemCount; i++) { - if (items.get(i).isVisible()) { - return true; - } - } - - return false; - } - - private ActionMenuItem findItemWithShortcut(int keyCode, KeyEvent event) { - // TODO Make this smarter. - final boolean qwerty = mIsQwerty; - final ArrayList items = mItems; - final int itemCount = items.size(); - - for (int i = 0; i < itemCount; i++) { - ActionMenuItem item = items.get(i); - final char shortcut = qwerty ? item.getAlphabeticShortcut() : - item.getNumericShortcut(); - if (keyCode == shortcut) { - return item; - } - } - return null; - } - - public boolean isShortcutKey(int keyCode, KeyEvent event) { - return findItemWithShortcut(keyCode, event) != null; - } - - public boolean performIdentifierAction(int id, int flags) { - final int index = findItemIndex(id); - if (index < 0) { - return false; - } - - return mItems.get(index).invoke(); - } - - public boolean performShortcut(int keyCode, KeyEvent event, int flags) { - ActionMenuItem item = findItemWithShortcut(keyCode, event); - if (item == null) { - return false; - } - - return item.invoke(); - } - - public void removeGroup(int groupId) { - final ArrayList items = mItems; - int itemCount = items.size(); - int i = 0; - while (i < itemCount) { - if (items.get(i).getGroupId() == groupId) { - items.remove(i); - itemCount--; - } else { - i++; - } - } - } - - public void removeItem(int id) { - mItems.remove(findItemIndex(id)); - } - - public void setGroupCheckable(int group, boolean checkable, - boolean exclusive) { - final ArrayList items = mItems; - final int itemCount = items.size(); - - for (int i = 0; i < itemCount; i++) { - ActionMenuItem item = items.get(i); - if (item.getGroupId() == group) { - item.setCheckable(checkable); - item.setExclusiveCheckable(exclusive); - } - } - } - - public void setGroupEnabled(int group, boolean enabled) { - final ArrayList items = mItems; - final int itemCount = items.size(); - - for (int i = 0; i < itemCount; i++) { - ActionMenuItem item = items.get(i); - if (item.getGroupId() == group) { - item.setEnabled(enabled); - } - } - } - - public void setGroupVisible(int group, boolean visible) { - final ArrayList items = mItems; - final int itemCount = items.size(); - - for (int i = 0; i < itemCount; i++) { - ActionMenuItem item = items.get(i); - if (item.getGroupId() == group) { - item.setVisible(visible); - } - } - } - - public void setQwertyMode(boolean isQwerty) { - mIsQwerty = isQwerty; - } - - public int size() { - return mItems.size(); - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuItem.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuItem.java deleted file mode 100644 index 510b97488..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuItem.java +++ /dev/null @@ -1,278 +0,0 @@ -/* - * Copyright (C) 2010 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.actionbarsherlock.internal.view.menu; - -import android.content.Context; -import android.content.Intent; -import android.graphics.drawable.Drawable; -import android.view.ContextMenu.ContextMenuInfo; -import android.view.View; - -import com.actionbarsherlock.view.ActionProvider; -import com.actionbarsherlock.view.MenuItem; -import com.actionbarsherlock.view.SubMenu; - -/** - * @hide - */ -public class ActionMenuItem implements MenuItem { - private final int mId; - private final int mGroup; - //UNUSED private final int mCategoryOrder; - private final int mOrdering; - - private CharSequence mTitle; - private CharSequence mTitleCondensed; - private Intent mIntent; - private char mShortcutNumericChar; - private char mShortcutAlphabeticChar; - - private Drawable mIconDrawable; - //UNUSED private int mIconResId = NO_ICON; - - private Context mContext; - - private MenuItem.OnMenuItemClickListener mClickListener; - - //UNUSED private static final int NO_ICON = 0; - - private int mFlags = ENABLED; - private static final int CHECKABLE = 0x00000001; - private static final int CHECKED = 0x00000002; - private static final int EXCLUSIVE = 0x00000004; - private static final int HIDDEN = 0x00000008; - private static final int ENABLED = 0x00000010; - - public ActionMenuItem(Context context, int group, int id, int categoryOrder, int ordering, - CharSequence title) { - mContext = context; - mId = id; - mGroup = group; - //UNUSED mCategoryOrder = categoryOrder; - mOrdering = ordering; - mTitle = title; - } - - public char getAlphabeticShortcut() { - return mShortcutAlphabeticChar; - } - - public int getGroupId() { - return mGroup; - } - - public Drawable getIcon() { - return mIconDrawable; - } - - public Intent getIntent() { - return mIntent; - } - - public int getItemId() { - return mId; - } - - public ContextMenuInfo getMenuInfo() { - return null; - } - - public char getNumericShortcut() { - return mShortcutNumericChar; - } - - public int getOrder() { - return mOrdering; - } - - public SubMenu getSubMenu() { - return null; - } - - public CharSequence getTitle() { - return mTitle; - } - - public CharSequence getTitleCondensed() { - return mTitleCondensed; - } - - public boolean hasSubMenu() { - return false; - } - - public boolean isCheckable() { - return (mFlags & CHECKABLE) != 0; - } - - public boolean isChecked() { - return (mFlags & CHECKED) != 0; - } - - public boolean isEnabled() { - return (mFlags & ENABLED) != 0; - } - - public boolean isVisible() { - return (mFlags & HIDDEN) == 0; - } - - public MenuItem setAlphabeticShortcut(char alphaChar) { - mShortcutAlphabeticChar = alphaChar; - return this; - } - - public MenuItem setCheckable(boolean checkable) { - mFlags = (mFlags & ~CHECKABLE) | (checkable ? CHECKABLE : 0); - return this; - } - - public ActionMenuItem setExclusiveCheckable(boolean exclusive) { - mFlags = (mFlags & ~EXCLUSIVE) | (exclusive ? EXCLUSIVE : 0); - return this; - } - - public MenuItem setChecked(boolean checked) { - mFlags = (mFlags & ~CHECKED) | (checked ? CHECKED : 0); - return this; - } - - public MenuItem setEnabled(boolean enabled) { - mFlags = (mFlags & ~ENABLED) | (enabled ? ENABLED : 0); - return this; - } - - public MenuItem setIcon(Drawable icon) { - mIconDrawable = icon; - //UNUSED mIconResId = NO_ICON; - return this; - } - - public MenuItem setIcon(int iconRes) { - //UNUSED mIconResId = iconRes; - mIconDrawable = mContext.getResources().getDrawable(iconRes); - return this; - } - - public MenuItem setIntent(Intent intent) { - mIntent = intent; - return this; - } - - public MenuItem setNumericShortcut(char numericChar) { - mShortcutNumericChar = numericChar; - return this; - } - - public MenuItem setOnMenuItemClickListener(OnMenuItemClickListener menuItemClickListener) { - mClickListener = menuItemClickListener; - return this; - } - - public MenuItem setShortcut(char numericChar, char alphaChar) { - mShortcutNumericChar = numericChar; - mShortcutAlphabeticChar = alphaChar; - return this; - } - - public MenuItem setTitle(CharSequence title) { - mTitle = title; - return this; - } - - public MenuItem setTitle(int title) { - mTitle = mContext.getResources().getString(title); - return this; - } - - public MenuItem setTitleCondensed(CharSequence title) { - mTitleCondensed = title; - return this; - } - - public MenuItem setVisible(boolean visible) { - mFlags = (mFlags & HIDDEN) | (visible ? 0 : HIDDEN); - return this; - } - - public boolean invoke() { - if (mClickListener != null && mClickListener.onMenuItemClick(this)) { - return true; - } - - if (mIntent != null) { - mContext.startActivity(mIntent); - return true; - } - - return false; - } - - public void setShowAsAction(int show) { - // Do nothing. ActionMenuItems always show as action buttons. - } - - public MenuItem setActionView(View actionView) { - throw new UnsupportedOperationException(); - } - - public View getActionView() { - return null; - } - - @Override - public MenuItem setActionView(int resId) { - throw new UnsupportedOperationException(); - } - - @Override - public ActionProvider getActionProvider() { - return null; - } - - @Override - public MenuItem setActionProvider(ActionProvider actionProvider) { - throw new UnsupportedOperationException(); - } - - @Override - public MenuItem setShowAsActionFlags(int actionEnum) { - setShowAsAction(actionEnum); - return this; - } - - @Override - public boolean expandActionView() { - return false; - } - - @Override - public boolean collapseActionView() { - return false; - } - - @Override - public boolean isActionViewExpanded() { - return false; - } - - @Override - public MenuItem setOnActionExpandListener(OnActionExpandListener listener) { - // No need to save the listener; ActionMenuItem does not support collapsing items. - return this; - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuItemView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuItemView.java deleted file mode 100644 index dcb50f362..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuItemView.java +++ /dev/null @@ -1,295 +0,0 @@ -/* - * Copyright (C) 2010 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.actionbarsherlock.internal.view.menu; - -import java.util.HashSet; -import java.util.Set; -import android.content.Context; -import android.content.res.TypedArray; -import android.graphics.Rect; -import android.graphics.drawable.Drawable; -import android.os.Build; -import android.text.TextUtils; -import android.util.AttributeSet; -import android.view.Gravity; -import android.view.MotionEvent; -import android.view.View; -import android.view.accessibility.AccessibilityEvent; -import android.widget.ImageButton; -import android.widget.LinearLayout; -import android.widget.Toast; - -import com.actionbarsherlock.R; -import com.actionbarsherlock.internal.view.View_HasStateListenerSupport; -import com.actionbarsherlock.internal.view.View_OnAttachStateChangeListener; -import com.actionbarsherlock.internal.widget.CapitalizingButton; - -import static com.actionbarsherlock.internal.ResourcesCompat.getResources_getBoolean; - -/** - * @hide - */ -public class ActionMenuItemView extends LinearLayout - implements MenuView.ItemView, View.OnClickListener, View.OnLongClickListener, - ActionMenuView.ActionMenuChildView, View_HasStateListenerSupport { - //UNUSED private static final String TAG = "ActionMenuItemView"; - - private MenuItemImpl mItemData; - private CharSequence mTitle; - private MenuBuilder.ItemInvoker mItemInvoker; - - private ImageButton mImageButton; - private CapitalizingButton mTextButton; - private boolean mAllowTextWithIcon; - private boolean mExpandedFormat; - private int mMinWidth; - - private final Set mListeners = new HashSet(); - - public ActionMenuItemView(Context context) { - this(context, null); - } - - public ActionMenuItemView(Context context, AttributeSet attrs) { - this(context, attrs, 0); - } - - public ActionMenuItemView(Context context, AttributeSet attrs, int defStyle) { - //TODO super(context, attrs, defStyle); - super(context, attrs); - mAllowTextWithIcon = getResources_getBoolean(context, - R.bool.abs__config_allowActionMenuItemTextWithIcon); - TypedArray a = context.obtainStyledAttributes(attrs, - R.styleable.SherlockActionMenuItemView, 0, 0); - mMinWidth = a.getDimensionPixelSize( - R.styleable.SherlockActionMenuItemView_android_minWidth, 0); - a.recycle(); - } - - @Override - public void addOnAttachStateChangeListener(View_OnAttachStateChangeListener listener) { - mListeners.add(listener); - } - - @Override - public void removeOnAttachStateChangeListener(View_OnAttachStateChangeListener listener) { - mListeners.remove(listener); - } - - @Override - protected void onAttachedToWindow() { - super.onAttachedToWindow(); - for (View_OnAttachStateChangeListener listener : mListeners) { - listener.onViewAttachedToWindow(this); - } - } - - @Override - protected void onDetachedFromWindow() { - super.onDetachedFromWindow(); - for (View_OnAttachStateChangeListener listener : mListeners) { - listener.onViewDetachedFromWindow(this); - } - } - - @Override - public void onFinishInflate() { - - mImageButton = (ImageButton) findViewById(R.id.abs__imageButton); - mTextButton = (CapitalizingButton) findViewById(R.id.abs__textButton); - mImageButton.setOnClickListener(this); - mTextButton.setOnClickListener(this); - mImageButton.setOnLongClickListener(this); - setOnClickListener(this); - setOnLongClickListener(this); - } - - public MenuItemImpl getItemData() { - return mItemData; - } - - public void initialize(MenuItemImpl itemData, int menuType) { - mItemData = itemData; - - setIcon(itemData.getIcon()); - setTitle(itemData.getTitleForItemView(this)); // Title only takes effect if there is no icon - setId(itemData.getItemId()); - - setVisibility(itemData.isVisible() ? View.VISIBLE : View.GONE); - setEnabled(itemData.isEnabled()); - } - - @Override - public void setEnabled(boolean enabled) { - super.setEnabled(enabled); - mImageButton.setEnabled(enabled); - mTextButton.setEnabled(enabled); - } - - public void onClick(View v) { - if (mItemInvoker != null) { - mItemInvoker.invokeItem(mItemData); - } - } - - public void setItemInvoker(MenuBuilder.ItemInvoker invoker) { - mItemInvoker = invoker; - } - - public boolean prefersCondensedTitle() { - return true; - } - - public void setCheckable(boolean checkable) { - // TODO Support checkable action items - } - - public void setChecked(boolean checked) { - // TODO Support checkable action items - } - - public void setExpandedFormat(boolean expandedFormat) { - if (mExpandedFormat != expandedFormat) { - mExpandedFormat = expandedFormat; - if (mItemData != null) { - mItemData.actionFormatChanged(); - } - } - } - - private void updateTextButtonVisibility() { - boolean visible = !TextUtils.isEmpty(mTextButton.getText()); - visible &= mImageButton.getDrawable() == null || - (mItemData.showsTextAsAction() && (mAllowTextWithIcon || mExpandedFormat)); - - mTextButton.setVisibility(visible ? VISIBLE : GONE); - } - - public void setIcon(Drawable icon) { - mImageButton.setImageDrawable(icon); - if (icon != null) { - mImageButton.setVisibility(VISIBLE); - } else { - mImageButton.setVisibility(GONE); - } - - updateTextButtonVisibility(); - } - - public boolean hasText() { - return mTextButton.getVisibility() != GONE; - } - - public void setShortcut(boolean showShortcut, char shortcutKey) { - // Action buttons don't show text for shortcut keys. - } - - public void setTitle(CharSequence title) { - mTitle = title; - - mTextButton.setTextCompat(mTitle); - - setContentDescription(mTitle); - updateTextButtonVisibility(); - } - - @Override - public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { - onPopulateAccessibilityEvent(event); - return true; - } - - @Override - public void onPopulateAccessibilityEvent(AccessibilityEvent event) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { - super.onPopulateAccessibilityEvent(event); - } - final CharSequence cdesc = getContentDescription(); - if (!TextUtils.isEmpty(cdesc)) { - event.getText().add(cdesc); - } - } - - @Override - public boolean dispatchHoverEvent(MotionEvent event) { - // Don't allow children to hover; we want this to be treated as a single component. - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { - return onHoverEvent(event); - } - return false; - } - - public boolean showsIcon() { - return true; - } - - public boolean needsDividerBefore() { - return hasText() && mItemData.getIcon() == null; - } - - public boolean needsDividerAfter() { - return hasText(); - } - - @Override - public boolean onLongClick(View v) { - if (hasText()) { - // Don't show the cheat sheet for items that already show text. - return false; - } - - final int[] screenPos = new int[2]; - final Rect displayFrame = new Rect(); - getLocationOnScreen(screenPos); - getWindowVisibleDisplayFrame(displayFrame); - - final Context context = getContext(); - final int width = getWidth(); - final int height = getHeight(); - final int midy = screenPos[1] + height / 2; - final int screenWidth = context.getResources().getDisplayMetrics().widthPixels; - - Toast cheatSheet = Toast.makeText(context, mItemData.getTitle(), Toast.LENGTH_SHORT); - if (midy < displayFrame.height()) { - // Show along the top; follow action buttons - cheatSheet.setGravity(Gravity.TOP | Gravity.RIGHT, - screenWidth - screenPos[0] - width / 2, height); - } else { - // Show along the bottom center - cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, height); - } - cheatSheet.show(); - return true; - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - - final int widthMode = MeasureSpec.getMode(widthMeasureSpec); - final int specSize = MeasureSpec.getSize(widthMeasureSpec); - final int oldMeasuredWidth = getMeasuredWidth(); - final int targetWidth = widthMode == MeasureSpec.AT_MOST ? Math.min(specSize, mMinWidth) - : mMinWidth; - - if (widthMode != MeasureSpec.EXACTLY && mMinWidth > 0 && oldMeasuredWidth < targetWidth) { - // Remeasure at exactly the minimum width. - super.onMeasure(MeasureSpec.makeMeasureSpec(targetWidth, MeasureSpec.EXACTLY), - heightMeasureSpec); - } - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuPresenter.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuPresenter.java deleted file mode 100644 index 6f568c698..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuPresenter.java +++ /dev/null @@ -1,721 +0,0 @@ -/* - * Copyright (C) 2011 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.actionbarsherlock.internal.view.menu; - -import static com.actionbarsherlock.internal.ResourcesCompat.getResources_getInteger; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Set; -import android.content.Context; -import android.content.res.Configuration; -import android.content.res.Resources; -import android.content.res.TypedArray; -import android.os.Build; -import android.os.Parcel; -import android.os.Parcelable; -import android.util.SparseBooleanArray; -import android.view.SoundEffectConstants; -import android.view.View; -import android.view.View.MeasureSpec; -import android.view.ViewConfiguration; -import android.view.ViewGroup; -import android.widget.ImageButton; -import com.actionbarsherlock.R; -import com.actionbarsherlock.internal.view.View_HasStateListenerSupport; -import com.actionbarsherlock.internal.view.View_OnAttachStateChangeListener; -import com.actionbarsherlock.internal.view.menu.ActionMenuView.ActionMenuChildView; -import com.actionbarsherlock.view.ActionProvider; -import com.actionbarsherlock.view.MenuItem; - -/** - * MenuPresenter for building action menus as seen in the action bar and action modes. - */ -public class ActionMenuPresenter extends BaseMenuPresenter - implements ActionProvider.SubUiVisibilityListener { - //UNUSED private static final String TAG = "ActionMenuPresenter"; - - private View mOverflowButton; - private boolean mReserveOverflow; - private boolean mReserveOverflowSet; - private int mWidthLimit; - private int mActionItemWidthLimit; - private int mMaxItems; - private boolean mMaxItemsSet; - private boolean mStrictWidthLimit; - private boolean mWidthLimitSet; - private boolean mExpandedActionViewsExclusive; - - private int mMinCellSize; - - // Group IDs that have been added as actions - used temporarily, allocated here for reuse. - private final SparseBooleanArray mActionButtonGroups = new SparseBooleanArray(); - - private View mScrapActionButtonView; - - private OverflowPopup mOverflowPopup; - private ActionButtonSubmenu mActionButtonPopup; - - private OpenOverflowRunnable mPostedOpenRunnable; - - final PopupPresenterCallback mPopupPresenterCallback = new PopupPresenterCallback(); - int mOpenSubMenuId; - - public ActionMenuPresenter(Context context) { - super(context, R.layout.abs__action_menu_layout, - R.layout.abs__action_menu_item_layout); - } - - @Override - public void initForMenu(Context context, MenuBuilder menu) { - super.initForMenu(context, menu); - - final Resources res = context.getResources(); - - if (!mReserveOverflowSet) { - mReserveOverflow = reserveOverflow(mContext); - } - - if (!mWidthLimitSet) { - mWidthLimit = res.getDisplayMetrics().widthPixels / 2; - } - - // Measure for initial configuration - if (!mMaxItemsSet) { - mMaxItems = getResources_getInteger(context, R.integer.abs__max_action_buttons); - } - - int width = mWidthLimit; - if (mReserveOverflow) { - if (mOverflowButton == null) { - mOverflowButton = new OverflowMenuButton(mSystemContext); - final int spec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); - mOverflowButton.measure(spec, spec); - } - width -= mOverflowButton.getMeasuredWidth(); - } else { - mOverflowButton = null; - } - - mActionItemWidthLimit = width; - - mMinCellSize = (int) (ActionMenuView.MIN_CELL_SIZE * res.getDisplayMetrics().density); - - // Drop a scrap view as it may no longer reflect the proper context/config. - mScrapActionButtonView = null; - } - - public static boolean reserveOverflow(Context context) { - //Check for theme-forced overflow action item - TypedArray a = context.getTheme().obtainStyledAttributes(R.styleable.SherlockTheme); - boolean result = a.getBoolean(R.styleable.SherlockTheme_absForceOverflow, false); - a.recycle(); - if (result) { - return true; - } - - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { - return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB); - } else { - return !HasPermanentMenuKey.get(context); - } - } - - private static class HasPermanentMenuKey { - public static boolean get(Context context) { - return ViewConfiguration.get(context).hasPermanentMenuKey(); - } - } - - public void onConfigurationChanged(Configuration newConfig) { - if (!mMaxItemsSet) { - mMaxItems = getResources_getInteger(mContext, - R.integer.abs__max_action_buttons); - if (mMenu != null) { - mMenu.onItemsChanged(true); - } - } - } - - public void setWidthLimit(int width, boolean strict) { - mWidthLimit = width; - mStrictWidthLimit = strict; - mWidthLimitSet = true; - } - - public void setReserveOverflow(boolean reserveOverflow) { - mReserveOverflow = reserveOverflow; - mReserveOverflowSet = true; - } - - public void setItemLimit(int itemCount) { - mMaxItems = itemCount; - mMaxItemsSet = true; - } - - public void setExpandedActionViewsExclusive(boolean isExclusive) { - mExpandedActionViewsExclusive = isExclusive; - } - - @Override - public MenuView getMenuView(ViewGroup root) { - MenuView result = super.getMenuView(root); - ((ActionMenuView) result).setPresenter(this); - return result; - } - - @Override - public View getItemView(MenuItemImpl item, View convertView, ViewGroup parent) { - View actionView = item.getActionView(); - if (actionView == null || item.hasCollapsibleActionView()) { - if (!(convertView instanceof ActionMenuItemView)) { - convertView = null; - } - actionView = super.getItemView(item, convertView, parent); - } - actionView.setVisibility(item.isActionViewExpanded() ? View.GONE : View.VISIBLE); - - final ActionMenuView menuParent = (ActionMenuView) parent; - final ViewGroup.LayoutParams lp = actionView.getLayoutParams(); - if (!menuParent.checkLayoutParams(lp)) { - actionView.setLayoutParams(menuParent.generateLayoutParams(lp)); - } - return actionView; - } - - @Override - public void bindItemView(MenuItemImpl item, MenuView.ItemView itemView) { - itemView.initialize(item, 0); - - final ActionMenuView menuView = (ActionMenuView) mMenuView; - ActionMenuItemView actionItemView = (ActionMenuItemView) itemView; - actionItemView.setItemInvoker(menuView); - } - - @Override - public boolean shouldIncludeItem(int childIndex, MenuItemImpl item) { - return item.isActionButton(); - } - - @Override - public void updateMenuView(boolean cleared) { - super.updateMenuView(cleared); - - if (mMenu != null) { - final ArrayList actionItems = mMenu.getActionItems(); - final int count = actionItems.size(); - for (int i = 0; i < count; i++) { - final ActionProvider provider = actionItems.get(i).getActionProvider(); - if (provider != null) { - provider.setSubUiVisibilityListener(this); - } - } - } - - final ArrayList nonActionItems = mMenu != null ? - mMenu.getNonActionItems() : null; - - boolean hasOverflow = false; - if (mReserveOverflow && nonActionItems != null) { - final int count = nonActionItems.size(); - if (count == 1) { - hasOverflow = !nonActionItems.get(0).isActionViewExpanded(); - } else { - hasOverflow = count > 0; - } - } - - if (hasOverflow) { - if (mOverflowButton == null) { - mOverflowButton = new OverflowMenuButton(mSystemContext); - } - ViewGroup parent = (ViewGroup) mOverflowButton.getParent(); - if (parent != mMenuView) { - if (parent != null) { - parent.removeView(mOverflowButton); - } - ActionMenuView menuView = (ActionMenuView) mMenuView; - menuView.addView(mOverflowButton, menuView.generateOverflowButtonLayoutParams()); - } - } else if (mOverflowButton != null && mOverflowButton.getParent() == mMenuView) { - ((ViewGroup) mMenuView).removeView(mOverflowButton); - } - - ((ActionMenuView) mMenuView).setOverflowReserved(mReserveOverflow); - } - - @Override - public boolean filterLeftoverView(ViewGroup parent, int childIndex) { - if (parent.getChildAt(childIndex) == mOverflowButton) return false; - return super.filterLeftoverView(parent, childIndex); - } - - public boolean onSubMenuSelected(SubMenuBuilder subMenu) { - if (!subMenu.hasVisibleItems()) return false; - - SubMenuBuilder topSubMenu = subMenu; - while (topSubMenu.getParentMenu() != mMenu) { - topSubMenu = (SubMenuBuilder) topSubMenu.getParentMenu(); - } - View anchor = findViewForItem(topSubMenu.getItem()); - if (anchor == null) { - if (mOverflowButton == null) return false; - anchor = mOverflowButton; - } - - mOpenSubMenuId = subMenu.getItem().getItemId(); - mActionButtonPopup = new ActionButtonSubmenu(mContext, subMenu); - mActionButtonPopup.setAnchorView(anchor); - mActionButtonPopup.show(); - super.onSubMenuSelected(subMenu); - return true; - } - - private View findViewForItem(MenuItem item) { - final ViewGroup parent = (ViewGroup) mMenuView; - if (parent == null) return null; - - final int count = parent.getChildCount(); - for (int i = 0; i < count; i++) { - final View child = parent.getChildAt(i); - if (child instanceof MenuView.ItemView && - ((MenuView.ItemView) child).getItemData() == item) { - return child; - } - } - return null; - } - - /** - * Display the overflow menu if one is present. - * @return true if the overflow menu was shown, false otherwise. - */ - public boolean showOverflowMenu() { - if (mReserveOverflow && !isOverflowMenuShowing() && mMenu != null && mMenuView != null && - mPostedOpenRunnable == null && !mMenu.getNonActionItems().isEmpty()) { - OverflowPopup popup = new OverflowPopup(mContext, mMenu, mOverflowButton, true); - mPostedOpenRunnable = new OpenOverflowRunnable(popup); - // Post this for later; we might still need a layout for the anchor to be right. - ((View) mMenuView).post(mPostedOpenRunnable); - - // ActionMenuPresenter uses null as a callback argument here - // to indicate overflow is opening. - super.onSubMenuSelected(null); - - return true; - } - return false; - } - - /** - * Hide the overflow menu if it is currently showing. - * - * @return true if the overflow menu was hidden, false otherwise. - */ - public boolean hideOverflowMenu() { - if (mPostedOpenRunnable != null && mMenuView != null) { - ((View) mMenuView).removeCallbacks(mPostedOpenRunnable); - mPostedOpenRunnable = null; - return true; - } - - MenuPopupHelper popup = mOverflowPopup; - if (popup != null) { - popup.dismiss(); - return true; - } - return false; - } - - /** - * Dismiss all popup menus - overflow and submenus. - * @return true if popups were dismissed, false otherwise. (This can be because none were open.) - */ - public boolean dismissPopupMenus() { - boolean result = hideOverflowMenu(); - result |= hideSubMenus(); - return result; - } - - /** - * Dismiss all submenu popups. - * - * @return true if popups were dismissed, false otherwise. (This can be because none were open.) - */ - public boolean hideSubMenus() { - if (mActionButtonPopup != null) { - mActionButtonPopup.dismiss(); - return true; - } - return false; - } - - /** - * @return true if the overflow menu is currently showing - */ - public boolean isOverflowMenuShowing() { - return mOverflowPopup != null && mOverflowPopup.isShowing(); - } - - /** - * @return true if space has been reserved in the action menu for an overflow item. - */ - public boolean isOverflowReserved() { - return mReserveOverflow; - } - - public boolean flagActionItems() { - final ArrayList visibleItems = mMenu.getVisibleItems(); - final int itemsSize = visibleItems.size(); - int maxActions = mMaxItems; - int widthLimit = mActionItemWidthLimit; - final int querySpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); - final ViewGroup parent = (ViewGroup) mMenuView; - - int requiredItems = 0; - int requestedItems = 0; - int firstActionWidth = 0; - boolean hasOverflow = false; - for (int i = 0; i < itemsSize; i++) { - MenuItemImpl item = visibleItems.get(i); - if (item.requiresActionButton()) { - requiredItems++; - } else if (item.requestsActionButton()) { - requestedItems++; - } else { - hasOverflow = true; - } - if (mExpandedActionViewsExclusive && item.isActionViewExpanded()) { - // Overflow everything if we have an expanded action view and we're - // space constrained. - maxActions = 0; - } - } - - // Reserve a spot for the overflow item if needed. - if (mReserveOverflow && - (hasOverflow || requiredItems + requestedItems > maxActions)) { - maxActions--; - } - maxActions -= requiredItems; - - final SparseBooleanArray seenGroups = mActionButtonGroups; - seenGroups.clear(); - - int cellSize = 0; - int cellsRemaining = 0; - if (mStrictWidthLimit) { - cellsRemaining = widthLimit / mMinCellSize; - final int cellSizeRemaining = widthLimit % mMinCellSize; - cellSize = mMinCellSize + cellSizeRemaining / cellsRemaining; - } - - // Flag as many more requested items as will fit. - for (int i = 0; i < itemsSize; i++) { - MenuItemImpl item = visibleItems.get(i); - - if (item.requiresActionButton()) { - View v = getItemView(item, mScrapActionButtonView, parent); - if (mScrapActionButtonView == null) { - mScrapActionButtonView = v; - } - if (mStrictWidthLimit) { - cellsRemaining -= ActionMenuView.measureChildForCells(v, - cellSize, cellsRemaining, querySpec, 0); - } else { - v.measure(querySpec, querySpec); - } - final int measuredWidth = v.getMeasuredWidth(); - widthLimit -= measuredWidth; - if (firstActionWidth == 0) { - firstActionWidth = measuredWidth; - } - final int groupId = item.getGroupId(); - if (groupId != 0) { - seenGroups.put(groupId, true); - } - item.setIsActionButton(true); - } else if (item.requestsActionButton()) { - // Items in a group with other items that already have an action slot - // can break the max actions rule, but not the width limit. - final int groupId = item.getGroupId(); - final boolean inGroup = seenGroups.get(groupId); - boolean isAction = (maxActions > 0 || inGroup) && widthLimit > 0 && - (!mStrictWidthLimit || cellsRemaining > 0); - - if (isAction) { - View v = getItemView(item, mScrapActionButtonView, parent); - if (mScrapActionButtonView == null) { - mScrapActionButtonView = v; - } - if (mStrictWidthLimit) { - final int cells = ActionMenuView.measureChildForCells(v, - cellSize, cellsRemaining, querySpec, 0); - cellsRemaining -= cells; - if (cells == 0) { - isAction = false; - } - } else { - v.measure(querySpec, querySpec); - } - final int measuredWidth = v.getMeasuredWidth(); - widthLimit -= measuredWidth; - if (firstActionWidth == 0) { - firstActionWidth = measuredWidth; - } - - if (mStrictWidthLimit) { - isAction &= widthLimit >= 0; - } else { - // Did this push the entire first item past the limit? - isAction &= widthLimit + firstActionWidth > 0; - } - } - - if (isAction && groupId != 0) { - seenGroups.put(groupId, true); - } else if (inGroup) { - // We broke the width limit. Demote the whole group, they all overflow now. - seenGroups.put(groupId, false); - for (int j = 0; j < i; j++) { - MenuItemImpl areYouMyGroupie = visibleItems.get(j); - if (areYouMyGroupie.getGroupId() == groupId) { - // Give back the action slot - if (areYouMyGroupie.isActionButton()) maxActions++; - areYouMyGroupie.setIsActionButton(false); - } - } - } - - if (isAction) maxActions--; - - item.setIsActionButton(isAction); - } - } - return true; - } - - @Override - public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) { - dismissPopupMenus(); - super.onCloseMenu(menu, allMenusAreClosing); - } - - @Override - public Parcelable onSaveInstanceState() { - SavedState state = new SavedState(); - state.openSubMenuId = mOpenSubMenuId; - return state; - } - - @Override - public void onRestoreInstanceState(Parcelable state) { - SavedState saved = (SavedState) state; - if (saved.openSubMenuId > 0) { - MenuItem item = mMenu.findItem(saved.openSubMenuId); - if (item != null) { - SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu(); - onSubMenuSelected(subMenu); - } - } - } - - @Override - public void onSubUiVisibilityChanged(boolean isVisible) { - if (isVisible) { - // Not a submenu, but treat it like one. - super.onSubMenuSelected(null); - } else { - mMenu.close(false); - } - } - - private static class SavedState implements Parcelable { - public int openSubMenuId; - - SavedState() { - } - - SavedState(Parcel in) { - openSubMenuId = in.readInt(); - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeInt(openSubMenuId); - } - - @SuppressWarnings("unused") - public static final Parcelable.Creator CREATOR - = new Parcelable.Creator() { - public SavedState createFromParcel(Parcel in) { - return new SavedState(in); - } - - public SavedState[] newArray(int size) { - return new SavedState[size]; - } - }; - } - - private class OverflowMenuButton extends ImageButton implements ActionMenuChildView, View_HasStateListenerSupport { - private final Set mListeners = new HashSet(); - - public OverflowMenuButton(Context context) { - super(context, null, R.attr.actionOverflowButtonStyle); - - setClickable(true); - setFocusable(true); - setVisibility(VISIBLE); - setEnabled(true); - } - - @Override - public boolean performClick() { - if (super.performClick()) { - return true; - } - - playSoundEffect(SoundEffectConstants.CLICK); - showOverflowMenu(); - return true; - } - - public boolean needsDividerBefore() { - return false; - } - - public boolean needsDividerAfter() { - return false; - } - - @Override - protected void onAttachedToWindow() { - super.onAttachedToWindow(); - for (View_OnAttachStateChangeListener listener : mListeners) { - listener.onViewAttachedToWindow(this); - } - } - - @Override - protected void onDetachedFromWindow() { - super.onDetachedFromWindow(); - for (View_OnAttachStateChangeListener listener : mListeners) { - listener.onViewDetachedFromWindow(this); - } - } - - @Override - public void addOnAttachStateChangeListener(View_OnAttachStateChangeListener listener) { - mListeners.add(listener); - } - - @Override - public void removeOnAttachStateChangeListener(View_OnAttachStateChangeListener listener) { - mListeners.remove(listener); - } - } - - private class OverflowPopup extends MenuPopupHelper { - public OverflowPopup(Context context, MenuBuilder menu, View anchorView, - boolean overflowOnly) { - super(context, menu, anchorView, overflowOnly); - setCallback(mPopupPresenterCallback); - } - - @Override - public void onDismiss() { - super.onDismiss(); - mMenu.close(); - mOverflowPopup = null; - } - } - - private class ActionButtonSubmenu extends MenuPopupHelper { - //UNUSED private SubMenuBuilder mSubMenu; - - public ActionButtonSubmenu(Context context, SubMenuBuilder subMenu) { - super(context, subMenu); - //UNUSED mSubMenu = subMenu; - - MenuItemImpl item = (MenuItemImpl) subMenu.getItem(); - if (!item.isActionButton()) { - // Give a reasonable anchor to nested submenus. - setAnchorView(mOverflowButton == null ? (View) mMenuView : mOverflowButton); - } - - setCallback(mPopupPresenterCallback); - - boolean preserveIconSpacing = false; - final int count = subMenu.size(); - for (int i = 0; i < count; i++) { - MenuItem childItem = subMenu.getItem(i); - if (childItem.isVisible() && childItem.getIcon() != null) { - preserveIconSpacing = true; - break; - } - } - setForceShowIcon(preserveIconSpacing); - } - - @Override - public void onDismiss() { - super.onDismiss(); - mActionButtonPopup = null; - mOpenSubMenuId = 0; - } - } - - private class PopupPresenterCallback implements MenuPresenter.Callback { - - @Override - public boolean onOpenSubMenu(MenuBuilder subMenu) { - if (subMenu == null) return false; - - mOpenSubMenuId = ((SubMenuBuilder) subMenu).getItem().getItemId(); - return false; - } - - @Override - public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) { - if (menu instanceof SubMenuBuilder) { - ((SubMenuBuilder) menu).getRootMenu().close(false); - } - } - } - - private class OpenOverflowRunnable implements Runnable { - private OverflowPopup mPopup; - - public OpenOverflowRunnable(OverflowPopup popup) { - mPopup = popup; - } - - public void run() { - mMenu.changeMenuMode(); - final View menuView = (View) mMenuView; - if (menuView != null && menuView.getWindowToken() != null && mPopup.tryShow()) { - mOverflowPopup = mPopup; - } - mPostedOpenRunnable = null; - } - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuView.java deleted file mode 100644 index e090677a1..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuView.java +++ /dev/null @@ -1,572 +0,0 @@ -/* - * Copyright (C) 2010 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.actionbarsherlock.internal.view.menu; - -import android.content.Context; -import android.content.res.Configuration; -import android.graphics.Canvas; -import android.os.Build; -import android.util.AttributeSet; -import android.view.Gravity; -import android.view.View; -import android.view.ViewGroup; -import android.view.accessibility.AccessibilityEvent; -import android.widget.LinearLayout; -import com.actionbarsherlock.internal.widget.IcsLinearLayout; - -/** - * @hide - */ -public class ActionMenuView extends IcsLinearLayout implements MenuBuilder.ItemInvoker, MenuView { - //UNUSED private static final String TAG = "ActionMenuView"; - private static final boolean IS_FROYO = Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO; - - static final int MIN_CELL_SIZE = 56; // dips - static final int GENERATED_ITEM_PADDING = 4; // dips - - private MenuBuilder mMenu; - - private boolean mReserveOverflow; - private ActionMenuPresenter mPresenter; - private boolean mFormatItems; - private int mFormatItemsWidth; - private int mMinCellSize; - private int mGeneratedItemPadding; - //UNUSED private int mMeasuredExtraWidth; - - private boolean mFirst = true; - - public ActionMenuView(Context context) { - this(context, null); - } - - public ActionMenuView(Context context, AttributeSet attrs) { - super(context, attrs); - setBaselineAligned(false); - final float density = context.getResources().getDisplayMetrics().density; - mMinCellSize = (int) (MIN_CELL_SIZE * density); - mGeneratedItemPadding = (int) (GENERATED_ITEM_PADDING * density); - } - - public void setPresenter(ActionMenuPresenter presenter) { - mPresenter = presenter; - } - - public boolean isExpandedFormat() { - return mFormatItems; - } - - @Override - public void onConfigurationChanged(Configuration newConfig) { - if (IS_FROYO) { - super.onConfigurationChanged(newConfig); - } - mPresenter.updateMenuView(false); - - if (mPresenter != null && mPresenter.isOverflowMenuShowing()) { - mPresenter.hideOverflowMenu(); - mPresenter.showOverflowMenu(); - } - } - - @Override - protected void onDraw(Canvas canvas) { - //Need to trigger a relayout since we may have been added extremely - //late in the initial rendering (e.g., when contained in a ViewPager). - //See: https://github.com/JakeWharton/ActionBarSherlock/issues/272 - if (!IS_FROYO && mFirst) { - mFirst = false; - requestLayout(); - return; - } - super.onDraw(canvas); - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - // If we've been given an exact size to match, apply special formatting during layout. - final boolean wasFormatted = mFormatItems; - mFormatItems = MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.EXACTLY; - - if (wasFormatted != mFormatItems) { - mFormatItemsWidth = 0; // Reset this when switching modes - } - - // Special formatting can change whether items can fit as action buttons. - // Kick the menu and update presenters when this changes. - final int widthSize = MeasureSpec.getMode(widthMeasureSpec); - if (mFormatItems && mMenu != null && widthSize != mFormatItemsWidth) { - mFormatItemsWidth = widthSize; - mMenu.onItemsChanged(true); - } - - if (mFormatItems) { - onMeasureExactFormat(widthMeasureSpec, heightMeasureSpec); - } else { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - } - } - - private void onMeasureExactFormat(int widthMeasureSpec, int heightMeasureSpec) { - // We already know the width mode is EXACTLY if we're here. - final int heightMode = MeasureSpec.getMode(heightMeasureSpec); - int widthSize = MeasureSpec.getSize(widthMeasureSpec); - int heightSize = MeasureSpec.getSize(heightMeasureSpec); - - final int widthPadding = getPaddingLeft() + getPaddingRight(); - final int heightPadding = getPaddingTop() + getPaddingBottom(); - - widthSize -= widthPadding; - - // Divide the view into cells. - final int cellCount = widthSize / mMinCellSize; - final int cellSizeRemaining = widthSize % mMinCellSize; - - if (cellCount == 0) { - // Give up, nothing fits. - setMeasuredDimension(widthSize, 0); - return; - } - - final int cellSize = mMinCellSize + cellSizeRemaining / cellCount; - - int cellsRemaining = cellCount; - int maxChildHeight = 0; - int maxCellsUsed = 0; - int expandableItemCount = 0; - int visibleItemCount = 0; - boolean hasOverflow = false; - - // This is used as a bitfield to locate the smallest items present. Assumes childCount < 64. - long smallestItemsAt = 0; - - final int childCount = getChildCount(); - for (int i = 0; i < childCount; i++) { - final View child = getChildAt(i); - if (child.getVisibility() == GONE) continue; - - final boolean isGeneratedItem = child instanceof ActionMenuItemView; - visibleItemCount++; - - if (isGeneratedItem) { - // Reset padding for generated menu item views; it may change below - // and views are recycled. - child.setPadding(mGeneratedItemPadding, 0, mGeneratedItemPadding, 0); - } - - final LayoutParams lp = (LayoutParams) child.getLayoutParams(); - lp.expanded = false; - lp.extraPixels = 0; - lp.cellsUsed = 0; - lp.expandable = false; - lp.leftMargin = 0; - lp.rightMargin = 0; - lp.preventEdgeOffset = isGeneratedItem && ((ActionMenuItemView) child).hasText(); - - // Overflow always gets 1 cell. No more, no less. - final int cellsAvailable = lp.isOverflowButton ? 1 : cellsRemaining; - - final int cellsUsed = measureChildForCells(child, cellSize, cellsAvailable, - heightMeasureSpec, heightPadding); - - maxCellsUsed = Math.max(maxCellsUsed, cellsUsed); - if (lp.expandable) expandableItemCount++; - if (lp.isOverflowButton) hasOverflow = true; - - cellsRemaining -= cellsUsed; - maxChildHeight = Math.max(maxChildHeight, child.getMeasuredHeight()); - if (cellsUsed == 1) smallestItemsAt |= (1 << i); - } - - // When we have overflow and a single expanded (text) item, we want to try centering it - // visually in the available space even though overflow consumes some of it. - final boolean centerSingleExpandedItem = hasOverflow && visibleItemCount == 2; - - // Divide space for remaining cells if we have items that can expand. - // Try distributing whole leftover cells to smaller items first. - - boolean needsExpansion = false; - while (expandableItemCount > 0 && cellsRemaining > 0) { - int minCells = Integer.MAX_VALUE; - long minCellsAt = 0; // Bit locations are indices of relevant child views - int minCellsItemCount = 0; - for (int i = 0; i < childCount; i++) { - final View child = getChildAt(i); - final LayoutParams lp = (LayoutParams) child.getLayoutParams(); - - // Don't try to expand items that shouldn't. - if (!lp.expandable) continue; - - // Mark indices of children that can receive an extra cell. - if (lp.cellsUsed < minCells) { - minCells = lp.cellsUsed; - minCellsAt = 1 << i; - minCellsItemCount = 1; - } else if (lp.cellsUsed == minCells) { - minCellsAt |= 1 << i; - minCellsItemCount++; - } - } - - // Items that get expanded will always be in the set of smallest items when we're done. - smallestItemsAt |= minCellsAt; - - if (minCellsItemCount > cellsRemaining) break; // Couldn't expand anything evenly. Stop. - - // We have enough cells, all minimum size items will be incremented. - minCells++; - - for (int i = 0; i < childCount; i++) { - final View child = getChildAt(i); - final LayoutParams lp = (LayoutParams) child.getLayoutParams(); - if ((minCellsAt & (1 << i)) == 0) { - // If this item is already at our small item count, mark it for later. - if (lp.cellsUsed == minCells) smallestItemsAt |= 1 << i; - continue; - } - - if (centerSingleExpandedItem && lp.preventEdgeOffset && cellsRemaining == 1) { - // Add padding to this item such that it centers. - child.setPadding(mGeneratedItemPadding + cellSize, 0, mGeneratedItemPadding, 0); - } - lp.cellsUsed++; - lp.expanded = true; - cellsRemaining--; - } - - needsExpansion = true; - } - - // Divide any space left that wouldn't divide along cell boundaries - // evenly among the smallest items - - final boolean singleItem = !hasOverflow && visibleItemCount == 1; - if (cellsRemaining > 0 && smallestItemsAt != 0 && - (cellsRemaining < visibleItemCount - 1 || singleItem || maxCellsUsed > 1)) { - float expandCount = Long.bitCount(smallestItemsAt); - - if (!singleItem) { - // The items at the far edges may only expand by half in order to pin to either side. - if ((smallestItemsAt & 1) != 0) { - LayoutParams lp = (LayoutParams) getChildAt(0).getLayoutParams(); - if (!lp.preventEdgeOffset) expandCount -= 0.5f; - } - if ((smallestItemsAt & (1 << (childCount - 1))) != 0) { - LayoutParams lp = ((LayoutParams) getChildAt(childCount - 1).getLayoutParams()); - if (!lp.preventEdgeOffset) expandCount -= 0.5f; - } - } - - final int extraPixels = expandCount > 0 ? - (int) (cellsRemaining * cellSize / expandCount) : 0; - - for (int i = 0; i < childCount; i++) { - if ((smallestItemsAt & (1 << i)) == 0) continue; - - final View child = getChildAt(i); - final LayoutParams lp = (LayoutParams) child.getLayoutParams(); - if (child instanceof ActionMenuItemView) { - // If this is one of our views, expand and measure at the larger size. - lp.extraPixels = extraPixels; - lp.expanded = true; - if (i == 0 && !lp.preventEdgeOffset) { - // First item gets part of its new padding pushed out of sight. - // The last item will get this implicitly from layout. - lp.leftMargin = -extraPixels / 2; - } - needsExpansion = true; - } else if (lp.isOverflowButton) { - lp.extraPixels = extraPixels; - lp.expanded = true; - lp.rightMargin = -extraPixels / 2; - needsExpansion = true; - } else { - // If we don't know what it is, give it some margins instead - // and let it center within its space. We still want to pin - // against the edges. - if (i != 0) { - lp.leftMargin = extraPixels / 2; - } - if (i != childCount - 1) { - lp.rightMargin = extraPixels / 2; - } - } - } - - cellsRemaining = 0; - } - - // Remeasure any items that have had extra space allocated to them. - if (needsExpansion) { - int heightSpec = MeasureSpec.makeMeasureSpec(heightSize - heightPadding, heightMode); - for (int i = 0; i < childCount; i++) { - final View child = getChildAt(i); - final LayoutParams lp = (LayoutParams) child.getLayoutParams(); - - if (!lp.expanded) continue; - - final int width = lp.cellsUsed * cellSize + lp.extraPixels; - child.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), heightSpec); - } - } - - if (heightMode != MeasureSpec.EXACTLY) { - heightSize = maxChildHeight; - } - - setMeasuredDimension(widthSize, heightSize); - //UNUSED mMeasuredExtraWidth = cellsRemaining * cellSize; - } - - /** - * Measure a child view to fit within cell-based formatting. The child's width - * will be measured to a whole multiple of cellSize. - * - *

Sets the expandable and cellsUsed fields of LayoutParams. - * - * @param child Child to measure - * @param cellSize Size of one cell - * @param cellsRemaining Number of cells remaining that this view can expand to fill - * @param parentHeightMeasureSpec MeasureSpec used by the parent view - * @param parentHeightPadding Padding present in the parent view - * @return Number of cells this child was measured to occupy - */ - static int measureChildForCells(View child, int cellSize, int cellsRemaining, - int parentHeightMeasureSpec, int parentHeightPadding) { - final LayoutParams lp = (LayoutParams) child.getLayoutParams(); - - final int childHeightSize = MeasureSpec.getSize(parentHeightMeasureSpec) - - parentHeightPadding; - final int childHeightMode = MeasureSpec.getMode(parentHeightMeasureSpec); - final int childHeightSpec = MeasureSpec.makeMeasureSpec(childHeightSize, childHeightMode); - - int cellsUsed = 0; - if (cellsRemaining > 0) { - final int childWidthSpec = MeasureSpec.makeMeasureSpec( - cellSize * cellsRemaining, MeasureSpec.AT_MOST); - child.measure(childWidthSpec, childHeightSpec); - - final int measuredWidth = child.getMeasuredWidth(); - cellsUsed = measuredWidth / cellSize; - if (measuredWidth % cellSize != 0) cellsUsed++; - } - - final ActionMenuItemView itemView = child instanceof ActionMenuItemView ? - (ActionMenuItemView) child : null; - final boolean expandable = !lp.isOverflowButton && itemView != null && itemView.hasText(); - lp.expandable = expandable; - - lp.cellsUsed = cellsUsed; - final int targetWidth = cellsUsed * cellSize; - child.measure(MeasureSpec.makeMeasureSpec(targetWidth, MeasureSpec.EXACTLY), - childHeightSpec); - return cellsUsed; - } - - @Override - protected void onLayout(boolean changed, int left, int top, int right, int bottom) { - if (!mFormatItems) { - super.onLayout(changed, left, top, right, bottom); - return; - } - - final int childCount = getChildCount(); - final int midVertical = (top + bottom) / 2; - final int dividerWidth = 0;//getDividerWidth(); - int overflowWidth = 0; - //UNUSED int nonOverflowWidth = 0; - int nonOverflowCount = 0; - int widthRemaining = right - left - getPaddingRight() - getPaddingLeft(); - boolean hasOverflow = false; - for (int i = 0; i < childCount; i++) { - final View v = getChildAt(i); - if (v.getVisibility() == GONE) { - continue; - } - - LayoutParams p = (LayoutParams) v.getLayoutParams(); - if (p.isOverflowButton) { - overflowWidth = v.getMeasuredWidth(); - if (hasDividerBeforeChildAt(i)) { - overflowWidth += dividerWidth; - } - - int height = v.getMeasuredHeight(); - int r = getWidth() - getPaddingRight() - p.rightMargin; - int l = r - overflowWidth; - int t = midVertical - (height / 2); - int b = t + height; - v.layout(l, t, r, b); - - widthRemaining -= overflowWidth; - hasOverflow = true; - } else { - final int size = v.getMeasuredWidth() + p.leftMargin + p.rightMargin; - //UNUSED nonOverflowWidth += size; - widthRemaining -= size; - //if (hasDividerBeforeChildAt(i)) { - //UNUSED nonOverflowWidth += dividerWidth; - //} - nonOverflowCount++; - } - } - - if (childCount == 1 && !hasOverflow) { - // Center a single child - final View v = getChildAt(0); - final int width = v.getMeasuredWidth(); - final int height = v.getMeasuredHeight(); - final int midHorizontal = (right - left) / 2; - final int l = midHorizontal - width / 2; - final int t = midVertical - height / 2; - v.layout(l, t, l + width, t + height); - return; - } - - final int spacerCount = nonOverflowCount - (hasOverflow ? 0 : 1); - final int spacerSize = Math.max(0, spacerCount > 0 ? widthRemaining / spacerCount : 0); - - int startLeft = getPaddingLeft(); - for (int i = 0; i < childCount; i++) { - final View v = getChildAt(i); - final LayoutParams lp = (LayoutParams) v.getLayoutParams(); - if (v.getVisibility() == GONE || lp.isOverflowButton) { - continue; - } - - startLeft += lp.leftMargin; - int width = v.getMeasuredWidth(); - int height = v.getMeasuredHeight(); - int t = midVertical - height / 2; - v.layout(startLeft, t, startLeft + width, t + height); - startLeft += width + lp.rightMargin + spacerSize; - } - } - - @Override - public void onDetachedFromWindow() { - super.onDetachedFromWindow(); - mPresenter.dismissPopupMenus(); - } - - public boolean isOverflowReserved() { - return mReserveOverflow; - } - - public void setOverflowReserved(boolean reserveOverflow) { - mReserveOverflow = reserveOverflow; - } - - @Override - protected LayoutParams generateDefaultLayoutParams() { - LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, - LayoutParams.WRAP_CONTENT); - params.gravity = Gravity.CENTER_VERTICAL; - return params; - } - - @Override - public LayoutParams generateLayoutParams(AttributeSet attrs) { - return new LayoutParams(getContext(), attrs); - } - - @Override - protected LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) { - if (p instanceof LayoutParams) { - LayoutParams result = new LayoutParams((LayoutParams) p); - if (result.gravity <= Gravity.NO_GRAVITY) { - result.gravity = Gravity.CENTER_VERTICAL; - } - return result; - } - return generateDefaultLayoutParams(); - } - - @Override - protected boolean checkLayoutParams(ViewGroup.LayoutParams p) { - return p != null && p instanceof LayoutParams; - } - - public LayoutParams generateOverflowButtonLayoutParams() { - LayoutParams result = generateDefaultLayoutParams(); - result.isOverflowButton = true; - return result; - } - - public boolean invokeItem(MenuItemImpl item) { - return mMenu.performItemAction(item, 0); - } - - public int getWindowAnimations() { - return 0; - } - - public void initialize(MenuBuilder menu) { - mMenu = menu; - } - - //@Override - protected boolean hasDividerBeforeChildAt(int childIndex) { - final View childBefore = getChildAt(childIndex - 1); - final View child = getChildAt(childIndex); - boolean result = false; - if (childIndex < getChildCount() && childBefore instanceof ActionMenuChildView) { - result |= ((ActionMenuChildView) childBefore).needsDividerAfter(); - } - if (childIndex > 0 && child instanceof ActionMenuChildView) { - result |= ((ActionMenuChildView) child).needsDividerBefore(); - } - return result; - } - - public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { - return false; - } - - public interface ActionMenuChildView { - public boolean needsDividerBefore(); - public boolean needsDividerAfter(); - } - - public static class LayoutParams extends LinearLayout.LayoutParams { - public boolean isOverflowButton; - public int cellsUsed; - public int extraPixels; - public boolean expandable; - public boolean preventEdgeOffset; - - public boolean expanded; - - public LayoutParams(Context c, AttributeSet attrs) { - super(c, attrs); - } - - public LayoutParams(LayoutParams other) { - super((LinearLayout.LayoutParams) other); - isOverflowButton = other.isOverflowButton; - } - - public LayoutParams(int width, int height) { - super(width, height); - isOverflowButton = false; - } - - public LayoutParams(int width, int height, boolean isOverflowButton) { - super(width, height); - this.isOverflowButton = isOverflowButton; - } - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/BaseMenuPresenter.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/BaseMenuPresenter.java deleted file mode 100644 index 6da26f2ae..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/BaseMenuPresenter.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Copyright (C) 2011 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.actionbarsherlock.internal.view.menu; - -import java.util.ArrayList; -import android.content.Context; -import android.os.Build; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -/** - * Base class for MenuPresenters that have a consistent container view and item - * views. Behaves similarly to an AdapterView in that existing item views will - * be reused if possible when items change. - */ -public abstract class BaseMenuPresenter implements MenuPresenter { - private static final boolean IS_HONEYCOMB = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB; - - protected Context mSystemContext; - protected Context mContext; - protected MenuBuilder mMenu; - protected LayoutInflater mSystemInflater; - protected LayoutInflater mInflater; - private Callback mCallback; - - private int mMenuLayoutRes; - private int mItemLayoutRes; - - protected MenuView mMenuView; - - private int mId; - - /** - * Construct a new BaseMenuPresenter. - * - * @param context Context for generating system-supplied views - * @param menuLayoutRes Layout resource ID for the menu container view - * @param itemLayoutRes Layout resource ID for a single item view - */ - public BaseMenuPresenter(Context context, int menuLayoutRes, int itemLayoutRes) { - mSystemContext = context; - mSystemInflater = LayoutInflater.from(context); - mMenuLayoutRes = menuLayoutRes; - mItemLayoutRes = itemLayoutRes; - } - - @Override - public void initForMenu(Context context, MenuBuilder menu) { - mContext = context; - mInflater = LayoutInflater.from(mContext); - mMenu = menu; - } - - @Override - public MenuView getMenuView(ViewGroup root) { - if (mMenuView == null) { - mMenuView = (MenuView) mSystemInflater.inflate(mMenuLayoutRes, root, false); - mMenuView.initialize(mMenu); - updateMenuView(true); - } - - return mMenuView; - } - - /** - * Reuses item views when it can - */ - public void updateMenuView(boolean cleared) { - final ViewGroup parent = (ViewGroup) mMenuView; - if (parent == null) return; - - int childIndex = 0; - if (mMenu != null) { - mMenu.flagActionItems(); - ArrayList visibleItems = mMenu.getVisibleItems(); - final int itemCount = visibleItems.size(); - for (int i = 0; i < itemCount; i++) { - MenuItemImpl item = visibleItems.get(i); - if (shouldIncludeItem(childIndex, item)) { - final View convertView = parent.getChildAt(childIndex); - final MenuItemImpl oldItem = convertView instanceof MenuView.ItemView ? - ((MenuView.ItemView) convertView).getItemData() : null; - final View itemView = getItemView(item, convertView, parent); - if (item != oldItem) { - // Don't let old states linger with new data. - itemView.setPressed(false); - if (IS_HONEYCOMB) itemView.jumpDrawablesToCurrentState(); - } - if (itemView != convertView) { - addItemView(itemView, childIndex); - } - childIndex++; - } - } - } - - // Remove leftover views. - while (childIndex < parent.getChildCount()) { - if (!filterLeftoverView(parent, childIndex)) { - childIndex++; - } - } - } - - /** - * Add an item view at the given index. - * - * @param itemView View to add - * @param childIndex Index within the parent to insert at - */ - protected void addItemView(View itemView, int childIndex) { - final ViewGroup currentParent = (ViewGroup) itemView.getParent(); - if (currentParent != null) { - currentParent.removeView(itemView); - } - ((ViewGroup) mMenuView).addView(itemView, childIndex); - } - - /** - * Filter the child view at index and remove it if appropriate. - * @param parent Parent to filter from - * @param childIndex Index to filter - * @return true if the child view at index was removed - */ - protected boolean filterLeftoverView(ViewGroup parent, int childIndex) { - parent.removeViewAt(childIndex); - return true; - } - - public void setCallback(Callback cb) { - mCallback = cb; - } - - /** - * Create a new item view that can be re-bound to other item data later. - * - * @return The new item view - */ - public MenuView.ItemView createItemView(ViewGroup parent) { - return (MenuView.ItemView) mSystemInflater.inflate(mItemLayoutRes, parent, false); - } - - /** - * Prepare an item view for use. See AdapterView for the basic idea at work here. - * This may require creating a new item view, but well-behaved implementations will - * re-use the view passed as convertView if present. The returned view will be populated - * with data from the item parameter. - * - * @param item Item to present - * @param convertView Existing view to reuse - * @param parent Intended parent view - use for inflation. - * @return View that presents the requested menu item - */ - public View getItemView(MenuItemImpl item, View convertView, ViewGroup parent) { - MenuView.ItemView itemView; - if (convertView instanceof MenuView.ItemView) { - itemView = (MenuView.ItemView) convertView; - } else { - itemView = createItemView(parent); - } - bindItemView(item, itemView); - return (View) itemView; - } - - /** - * Bind item data to an existing item view. - * - * @param item Item to bind - * @param itemView View to populate with item data - */ - public abstract void bindItemView(MenuItemImpl item, MenuView.ItemView itemView); - - /** - * Filter item by child index and item data. - * - * @param childIndex Indended presentation index of this item - * @param item Item to present - * @return true if this item should be included in this menu presentation; false otherwise - */ - public boolean shouldIncludeItem(int childIndex, MenuItemImpl item) { - return true; - } - - public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) { - if (mCallback != null) { - mCallback.onCloseMenu(menu, allMenusAreClosing); - } - } - - public boolean onSubMenuSelected(SubMenuBuilder menu) { - if (mCallback != null) { - return mCallback.onOpenSubMenu(menu); - } - return false; - } - - public boolean flagActionItems() { - return false; - } - - public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item) { - return false; - } - - public boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item) { - return false; - } - - public int getId() { - return mId; - } - - public void setId(int id) { - mId = id; - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ListMenuItemView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ListMenuItemView.java deleted file mode 100644 index ac25c3736..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ListMenuItemView.java +++ /dev/null @@ -1,278 +0,0 @@ -/* - * Copyright (C) 2006 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.actionbarsherlock.internal.view.menu; - -import com.actionbarsherlock.R; - -import android.content.Context; -import android.content.res.TypedArray; -import android.graphics.drawable.Drawable; -import android.util.AttributeSet; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.CheckBox; -import android.widget.CompoundButton; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.RadioButton; -import android.widget.TextView; - -/** - * The item view for each item in the ListView-based MenuViews. - */ -public class ListMenuItemView extends LinearLayout implements MenuView.ItemView { - private MenuItemImpl mItemData; - - private ImageView mIconView; - private RadioButton mRadioButton; - private TextView mTitleView; - private CheckBox mCheckBox; - private TextView mShortcutView; - - private Drawable mBackground; - private int mTextAppearance; - private Context mTextAppearanceContext; - private boolean mPreserveIconSpacing; - - //UNUSED private int mMenuType; - - private LayoutInflater mInflater; - - private boolean mForceShowIcon; - - final Context mContext; - - public ListMenuItemView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs); - mContext = context; - - TypedArray a = - context.obtainStyledAttributes( - attrs, R.styleable.SherlockMenuView, defStyle, 0); - - mBackground = a.getDrawable(R.styleable.SherlockMenuView_itemBackground); - mTextAppearance = a.getResourceId(R.styleable. - SherlockMenuView_itemTextAppearance, -1); - mPreserveIconSpacing = a.getBoolean( - R.styleable.SherlockMenuView_preserveIconSpacing, false); - mTextAppearanceContext = context; - - a.recycle(); - } - - public ListMenuItemView(Context context, AttributeSet attrs) { - this(context, attrs, 0); - } - - @Override - protected void onFinishInflate() { - super.onFinishInflate(); - - setBackgroundDrawable(mBackground); - - mTitleView = (TextView) findViewById(R.id.abs__title); - if (mTextAppearance != -1) { - mTitleView.setTextAppearance(mTextAppearanceContext, - mTextAppearance); - } - - mShortcutView = (TextView) findViewById(R.id.abs__shortcut); - } - - public void initialize(MenuItemImpl itemData, int menuType) { - mItemData = itemData; - //UNUSED mMenuType = menuType; - - setVisibility(itemData.isVisible() ? View.VISIBLE : View.GONE); - - setTitle(itemData.getTitleForItemView(this)); - setCheckable(itemData.isCheckable()); - setShortcut(itemData.shouldShowShortcut(), itemData.getShortcut()); - setIcon(itemData.getIcon()); - setEnabled(itemData.isEnabled()); - } - - public void setForceShowIcon(boolean forceShow) { - mPreserveIconSpacing = mForceShowIcon = forceShow; - } - - public void setTitle(CharSequence title) { - if (title != null) { - mTitleView.setText(title); - - if (mTitleView.getVisibility() != VISIBLE) mTitleView.setVisibility(VISIBLE); - } else { - if (mTitleView.getVisibility() != GONE) mTitleView.setVisibility(GONE); - } - } - - public MenuItemImpl getItemData() { - return mItemData; - } - - public void setCheckable(boolean checkable) { - - if (!checkable && mRadioButton == null && mCheckBox == null) { - return; - } - - if (mRadioButton == null) { - insertRadioButton(); - } - if (mCheckBox == null) { - insertCheckBox(); - } - - // Depending on whether its exclusive check or not, the checkbox or - // radio button will be the one in use (and the other will be otherCompoundButton) - final CompoundButton compoundButton; - final CompoundButton otherCompoundButton; - - if (mItemData.isExclusiveCheckable()) { - compoundButton = mRadioButton; - otherCompoundButton = mCheckBox; - } else { - compoundButton = mCheckBox; - otherCompoundButton = mRadioButton; - } - - if (checkable) { - compoundButton.setChecked(mItemData.isChecked()); - - final int newVisibility = checkable ? VISIBLE : GONE; - if (compoundButton.getVisibility() != newVisibility) { - compoundButton.setVisibility(newVisibility); - } - - // Make sure the other compound button isn't visible - if (otherCompoundButton.getVisibility() != GONE) { - otherCompoundButton.setVisibility(GONE); - } - } else { - mCheckBox.setVisibility(GONE); - mRadioButton.setVisibility(GONE); - } - } - - public void setChecked(boolean checked) { - CompoundButton compoundButton; - - if (mItemData.isExclusiveCheckable()) { - if (mRadioButton == null) { - insertRadioButton(); - } - compoundButton = mRadioButton; - } else { - if (mCheckBox == null) { - insertCheckBox(); - } - compoundButton = mCheckBox; - } - - compoundButton.setChecked(checked); - } - - public void setShortcut(boolean showShortcut, char shortcutKey) { - final int newVisibility = (showShortcut && mItemData.shouldShowShortcut()) - ? VISIBLE : GONE; - - if (newVisibility == VISIBLE) { - mShortcutView.setText(mItemData.getShortcutLabel()); - } - - if (mShortcutView.getVisibility() != newVisibility) { - mShortcutView.setVisibility(newVisibility); - } - } - - public void setIcon(Drawable icon) { - final boolean showIcon = mItemData.shouldShowIcon() || mForceShowIcon; - if (!showIcon && !mPreserveIconSpacing) { - return; - } - - if (mIconView == null && icon == null && !mPreserveIconSpacing) { - return; - } - - if (mIconView == null) { - insertIconView(); - } - - if (icon != null || mPreserveIconSpacing) { - mIconView.setImageDrawable(showIcon ? icon : null); - - if (mIconView.getVisibility() != VISIBLE) { - mIconView.setVisibility(VISIBLE); - } - } else { - mIconView.setVisibility(GONE); - } - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - if (mIconView != null && mPreserveIconSpacing) { - // Enforce minimum icon spacing - ViewGroup.LayoutParams lp = getLayoutParams(); - LayoutParams iconLp = (LayoutParams) mIconView.getLayoutParams(); - if (lp.height > 0 && iconLp.width <= 0) { - iconLp.width = lp.height; - } - } - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - } - - private void insertIconView() { - LayoutInflater inflater = getInflater(); - mIconView = (ImageView) inflater.inflate(R.layout.abs__list_menu_item_icon, - this, false); - addView(mIconView, 0); - } - - private void insertRadioButton() { - LayoutInflater inflater = getInflater(); - mRadioButton = - (RadioButton) inflater.inflate(R.layout.abs__list_menu_item_radio, - this, false); - addView(mRadioButton); - } - - private void insertCheckBox() { - LayoutInflater inflater = getInflater(); - mCheckBox = - (CheckBox) inflater.inflate(R.layout.abs__list_menu_item_checkbox, - this, false); - addView(mCheckBox); - } - - public boolean prefersCondensedTitle() { - return false; - } - - public boolean showsIcon() { - return mForceShowIcon; - } - - private LayoutInflater getInflater() { - if (mInflater == null) { - mInflater = LayoutInflater.from(mContext); - } - return mInflater; - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuBuilder.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuBuilder.java deleted file mode 100644 index 179b8f037..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuBuilder.java +++ /dev/null @@ -1,1335 +0,0 @@ -/* - * Copyright (C) 2006 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.actionbarsherlock.internal.view.menu; - - -import java.lang.ref.WeakReference; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; - -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; -import android.content.res.Configuration; -import android.content.res.Resources; -import android.graphics.drawable.Drawable; -import android.os.Bundle; -import android.os.Parcelable; -import android.util.SparseArray; -import android.view.ContextMenu.ContextMenuInfo; -import android.view.KeyCharacterMap; -import android.view.KeyEvent; -import android.view.View; - -import com.actionbarsherlock.R; -import com.actionbarsherlock.view.ActionProvider; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuItem; -import com.actionbarsherlock.view.SubMenu; - -/** - * Implementation of the {@link android.view.Menu} interface for creating a - * standard menu UI. - */ -public class MenuBuilder implements Menu { - //UNUSED private static final String TAG = "MenuBuilder"; - - private static final String PRESENTER_KEY = "android:menu:presenters"; - private static final String ACTION_VIEW_STATES_KEY = "android:menu:actionviewstates"; - private static final String EXPANDED_ACTION_VIEW_ID = "android:menu:expandedactionview"; - - private static final int[] sCategoryToOrder = new int[] { - 1, /* No category */ - 4, /* CONTAINER */ - 5, /* SYSTEM */ - 3, /* SECONDARY */ - 2, /* ALTERNATIVE */ - 0, /* SELECTED_ALTERNATIVE */ - }; - - private final Context mContext; - private final Resources mResources; - - /** - * Whether the shortcuts should be qwerty-accessible. Use isQwertyMode() - * instead of accessing this directly. - */ - private boolean mQwertyMode; - - /** - * Whether the shortcuts should be visible on menus. Use isShortcutsVisible() - * instead of accessing this directly. - */ - private boolean mShortcutsVisible; - - /** - * Callback that will receive the various menu-related events generated by - * this class. Use getCallback to get a reference to the callback. - */ - private Callback mCallback; - - /** Contains all of the items for this menu */ - private ArrayList mItems; - - /** Contains only the items that are currently visible. This will be created/refreshed from - * {@link #getVisibleItems()} */ - private ArrayList mVisibleItems; - /** - * Whether or not the items (or any one item's shown state) has changed since it was last - * fetched from {@link #getVisibleItems()} - */ - private boolean mIsVisibleItemsStale; - - /** - * Contains only the items that should appear in the Action Bar, if present. - */ - private ArrayList mActionItems; - /** - * Contains items that should NOT appear in the Action Bar, if present. - */ - private ArrayList mNonActionItems; - - /** - * Whether or not the items (or any one item's action state) has changed since it was - * last fetched. - */ - private boolean mIsActionItemsStale; - - /** - * Default value for how added items should show in the action list. - */ - private int mDefaultShowAsAction = MenuItem.SHOW_AS_ACTION_NEVER; - - /** - * Current use case is Context Menus: As Views populate the context menu, each one has - * extra information that should be passed along. This is the current menu info that - * should be set on all items added to this menu. - */ - private ContextMenuInfo mCurrentMenuInfo; - - /** Header title for menu types that have a header (context and submenus) */ - CharSequence mHeaderTitle; - /** Header icon for menu types that have a header and support icons (context) */ - Drawable mHeaderIcon; - /** Header custom view for menu types that have a header and support custom views (context) */ - View mHeaderView; - - /** - * Contains the state of the View hierarchy for all menu views when the menu - * was frozen. - */ - //UNUSED private SparseArray mFrozenViewStates; - - /** - * Prevents onItemsChanged from doing its junk, useful for batching commands - * that may individually call onItemsChanged. - */ - private boolean mPreventDispatchingItemsChanged = false; - private boolean mItemsChangedWhileDispatchPrevented = false; - - private boolean mOptionalIconsVisible = false; - - private boolean mIsClosing = false; - - private ArrayList mTempShortcutItemList = new ArrayList(); - - private CopyOnWriteArrayList> mPresenters = - new CopyOnWriteArrayList>(); - - /** - * Currently expanded menu item; must be collapsed when we clear. - */ - private MenuItemImpl mExpandedItem; - - /** - * Called by menu to notify of close and selection changes. - */ - public interface Callback { - /** - * Called when a menu item is selected. - * @param menu The menu that is the parent of the item - * @param item The menu item that is selected - * @return whether the menu item selection was handled - */ - public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item); - - /** - * Called when the mode of the menu changes (for example, from icon to expanded). - * - * @param menu the menu that has changed modes - */ - public void onMenuModeChange(MenuBuilder menu); - } - - /** - * Called by menu items to execute their associated action - */ - public interface ItemInvoker { - public boolean invokeItem(MenuItemImpl item); - } - - public MenuBuilder(Context context) { - mContext = context; - mResources = context.getResources(); - - mItems = new ArrayList(); - - mVisibleItems = new ArrayList(); - mIsVisibleItemsStale = true; - - mActionItems = new ArrayList(); - mNonActionItems = new ArrayList(); - mIsActionItemsStale = true; - - setShortcutsVisibleInner(true); - } - - public MenuBuilder setDefaultShowAsAction(int defaultShowAsAction) { - mDefaultShowAsAction = defaultShowAsAction; - return this; - } - - /** - * Add a presenter to this menu. This will only hold a WeakReference; - * you do not need to explicitly remove a presenter, but you can using - * {@link #removeMenuPresenter(MenuPresenter)}. - * - * @param presenter The presenter to add - */ - public void addMenuPresenter(MenuPresenter presenter) { - mPresenters.add(new WeakReference(presenter)); - presenter.initForMenu(mContext, this); - mIsActionItemsStale = true; - } - - /** - * Remove a presenter from this menu. That presenter will no longer - * receive notifications of updates to this menu's data. - * - * @param presenter The presenter to remove - */ - public void removeMenuPresenter(MenuPresenter presenter) { - for (WeakReference ref : mPresenters) { - final MenuPresenter item = ref.get(); - if (item == null || item == presenter) { - mPresenters.remove(ref); - } - } - } - - private void dispatchPresenterUpdate(boolean cleared) { - if (mPresenters.isEmpty()) return; - - stopDispatchingItemsChanged(); - for (WeakReference ref : mPresenters) { - final MenuPresenter presenter = ref.get(); - if (presenter == null) { - mPresenters.remove(ref); - } else { - presenter.updateMenuView(cleared); - } - } - startDispatchingItemsChanged(); - } - - private boolean dispatchSubMenuSelected(SubMenuBuilder subMenu) { - if (mPresenters.isEmpty()) return false; - - boolean result = false; - - for (WeakReference ref : mPresenters) { - final MenuPresenter presenter = ref.get(); - if (presenter == null) { - mPresenters.remove(ref); - } else if (!result) { - result = presenter.onSubMenuSelected(subMenu); - } - } - return result; - } - - private void dispatchSaveInstanceState(Bundle outState) { - if (mPresenters.isEmpty()) return; - - SparseArray presenterStates = new SparseArray(); - - for (WeakReference ref : mPresenters) { - final MenuPresenter presenter = ref.get(); - if (presenter == null) { - mPresenters.remove(ref); - } else { - final int id = presenter.getId(); - if (id > 0) { - final Parcelable state = presenter.onSaveInstanceState(); - if (state != null) { - presenterStates.put(id, state); - } - } - } - } - - outState.putSparseParcelableArray(PRESENTER_KEY, presenterStates); - } - - private void dispatchRestoreInstanceState(Bundle state) { - SparseArray presenterStates = state.getSparseParcelableArray(PRESENTER_KEY); - - if (presenterStates == null || mPresenters.isEmpty()) return; - - for (WeakReference ref : mPresenters) { - final MenuPresenter presenter = ref.get(); - if (presenter == null) { - mPresenters.remove(ref); - } else { - final int id = presenter.getId(); - if (id > 0) { - Parcelable parcel = presenterStates.get(id); - if (parcel != null) { - presenter.onRestoreInstanceState(parcel); - } - } - } - } - } - - public void savePresenterStates(Bundle outState) { - dispatchSaveInstanceState(outState); - } - - public void restorePresenterStates(Bundle state) { - dispatchRestoreInstanceState(state); - } - - public void saveActionViewStates(Bundle outStates) { - SparseArray viewStates = null; - - final int itemCount = size(); - for (int i = 0; i < itemCount; i++) { - final MenuItem item = getItem(i); - final View v = item.getActionView(); - if (v != null && v.getId() != View.NO_ID) { - if (viewStates == null) { - viewStates = new SparseArray(); - } - v.saveHierarchyState(viewStates); - if (item.isActionViewExpanded()) { - outStates.putInt(EXPANDED_ACTION_VIEW_ID, item.getItemId()); - } - } - if (item.hasSubMenu()) { - final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu(); - subMenu.saveActionViewStates(outStates); - } - } - - if (viewStates != null) { - outStates.putSparseParcelableArray(getActionViewStatesKey(), viewStates); - } - } - - public void restoreActionViewStates(Bundle states) { - if (states == null) { - return; - } - - SparseArray viewStates = states.getSparseParcelableArray( - getActionViewStatesKey()); - - final int itemCount = size(); - for (int i = 0; i < itemCount; i++) { - final MenuItem item = getItem(i); - final View v = item.getActionView(); - if (v != null && v.getId() != View.NO_ID) { - v.restoreHierarchyState(viewStates); - } - if (item.hasSubMenu()) { - final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu(); - subMenu.restoreActionViewStates(states); - } - } - - final int expandedId = states.getInt(EXPANDED_ACTION_VIEW_ID); - if (expandedId > 0) { - MenuItem itemToExpand = findItem(expandedId); - if (itemToExpand != null) { - itemToExpand.expandActionView(); - } - } - } - - protected String getActionViewStatesKey() { - return ACTION_VIEW_STATES_KEY; - } - - public void setCallback(Callback cb) { - mCallback = cb; - } - - /** - * Adds an item to the menu. The other add methods funnel to this. - */ - private MenuItem addInternal(int group, int id, int categoryOrder, CharSequence title) { - final int ordering = getOrdering(categoryOrder); - - final MenuItemImpl item = new MenuItemImpl(this, group, id, categoryOrder, - ordering, title, mDefaultShowAsAction); - - if (mCurrentMenuInfo != null) { - // Pass along the current menu info - item.setMenuInfo(mCurrentMenuInfo); - } - - mItems.add(findInsertIndex(mItems, ordering), item); - onItemsChanged(true); - - return item; - } - - public MenuItem add(CharSequence title) { - return addInternal(0, 0, 0, title); - } - - public MenuItem add(int titleRes) { - return addInternal(0, 0, 0, mResources.getString(titleRes)); - } - - public MenuItem add(int group, int id, int categoryOrder, CharSequence title) { - return addInternal(group, id, categoryOrder, title); - } - - public MenuItem add(int group, int id, int categoryOrder, int title) { - return addInternal(group, id, categoryOrder, mResources.getString(title)); - } - - public SubMenu addSubMenu(CharSequence title) { - return addSubMenu(0, 0, 0, title); - } - - public SubMenu addSubMenu(int titleRes) { - return addSubMenu(0, 0, 0, mResources.getString(titleRes)); - } - - public SubMenu addSubMenu(int group, int id, int categoryOrder, CharSequence title) { - final MenuItemImpl item = (MenuItemImpl) addInternal(group, id, categoryOrder, title); - final SubMenuBuilder subMenu = new SubMenuBuilder(mContext, this, item); - item.setSubMenu(subMenu); - - return subMenu; - } - - public SubMenu addSubMenu(int group, int id, int categoryOrder, int title) { - return addSubMenu(group, id, categoryOrder, mResources.getString(title)); - } - - public int addIntentOptions(int group, int id, int categoryOrder, ComponentName caller, - Intent[] specifics, Intent intent, int flags, MenuItem[] outSpecificItems) { - PackageManager pm = mContext.getPackageManager(); - final List lri = - pm.queryIntentActivityOptions(caller, specifics, intent, 0); - final int N = lri != null ? lri.size() : 0; - - if ((flags & FLAG_APPEND_TO_GROUP) == 0) { - removeGroup(group); - } - - for (int i=0; i= 0) { - outSpecificItems[ri.specificIndex] = item; - } - } - - return N; - } - - public void removeItem(int id) { - removeItemAtInt(findItemIndex(id), true); - } - - public void removeGroup(int group) { - final int i = findGroupIndex(group); - - if (i >= 0) { - final int maxRemovable = mItems.size() - i; - int numRemoved = 0; - while ((numRemoved++ < maxRemovable) && (mItems.get(i).getGroupId() == group)) { - // Don't force update for each one, this method will do it at the end - removeItemAtInt(i, false); - } - - // Notify menu views - onItemsChanged(true); - } - } - - /** - * Remove the item at the given index and optionally forces menu views to - * update. - * - * @param index The index of the item to be removed. If this index is - * invalid an exception is thrown. - * @param updateChildrenOnMenuViews Whether to force update on menu views. - * Please make sure you eventually call this after your batch of - * removals. - */ - private void removeItemAtInt(int index, boolean updateChildrenOnMenuViews) { - if ((index < 0) || (index >= mItems.size())) return; - - mItems.remove(index); - - if (updateChildrenOnMenuViews) onItemsChanged(true); - } - - public void removeItemAt(int index) { - removeItemAtInt(index, true); - } - - public void clearAll() { - mPreventDispatchingItemsChanged = true; - clear(); - clearHeader(); - mPreventDispatchingItemsChanged = false; - mItemsChangedWhileDispatchPrevented = false; - onItemsChanged(true); - } - - public void clear() { - if (mExpandedItem != null) { - collapseItemActionView(mExpandedItem); - } - mItems.clear(); - - onItemsChanged(true); - } - - void setExclusiveItemChecked(MenuItem item) { - final int group = item.getGroupId(); - - final int N = mItems.size(); - for (int i = 0; i < N; i++) { - MenuItemImpl curItem = mItems.get(i); - if (curItem.getGroupId() == group) { - if (!curItem.isExclusiveCheckable()) continue; - if (!curItem.isCheckable()) continue; - - // Check the item meant to be checked, uncheck the others (that are in the group) - curItem.setCheckedInt(curItem == item); - } - } - } - - public void setGroupCheckable(int group, boolean checkable, boolean exclusive) { - final int N = mItems.size(); - - for (int i = 0; i < N; i++) { - MenuItemImpl item = mItems.get(i); - if (item.getGroupId() == group) { - item.setExclusiveCheckable(exclusive); - item.setCheckable(checkable); - } - } - } - - public void setGroupVisible(int group, boolean visible) { - final int N = mItems.size(); - - // We handle the notification of items being changed ourselves, so we use setVisibleInt rather - // than setVisible and at the end notify of items being changed - - boolean changedAtLeastOneItem = false; - for (int i = 0; i < N; i++) { - MenuItemImpl item = mItems.get(i); - if (item.getGroupId() == group) { - if (item.setVisibleInt(visible)) changedAtLeastOneItem = true; - } - } - - if (changedAtLeastOneItem) onItemsChanged(true); - } - - public void setGroupEnabled(int group, boolean enabled) { - final int N = mItems.size(); - - for (int i = 0; i < N; i++) { - MenuItemImpl item = mItems.get(i); - if (item.getGroupId() == group) { - item.setEnabled(enabled); - } - } - } - - public boolean hasVisibleItems() { - final int size = size(); - - for (int i = 0; i < size; i++) { - MenuItemImpl item = mItems.get(i); - if (item.isVisible()) { - return true; - } - } - - return false; - } - - public MenuItem findItem(int id) { - final int size = size(); - for (int i = 0; i < size; i++) { - MenuItemImpl item = mItems.get(i); - if (item.getItemId() == id) { - return item; - } else if (item.hasSubMenu()) { - MenuItem possibleItem = item.getSubMenu().findItem(id); - - if (possibleItem != null) { - return possibleItem; - } - } - } - - return null; - } - - public int findItemIndex(int id) { - final int size = size(); - - for (int i = 0; i < size; i++) { - MenuItemImpl item = mItems.get(i); - if (item.getItemId() == id) { - return i; - } - } - - return -1; - } - - public int findGroupIndex(int group) { - return findGroupIndex(group, 0); - } - - public int findGroupIndex(int group, int start) { - final int size = size(); - - if (start < 0) { - start = 0; - } - - for (int i = start; i < size; i++) { - final MenuItemImpl item = mItems.get(i); - - if (item.getGroupId() == group) { - return i; - } - } - - return -1; - } - - public int size() { - return mItems.size(); - } - - /** {@inheritDoc} */ - public MenuItem getItem(int index) { - return mItems.get(index); - } - - public boolean isShortcutKey(int keyCode, KeyEvent event) { - return findItemWithShortcutForKey(keyCode, event) != null; - } - - public void setQwertyMode(boolean isQwerty) { - mQwertyMode = isQwerty; - - onItemsChanged(false); - } - - /** - * Returns the ordering across all items. This will grab the category from - * the upper bits, find out how to order the category with respect to other - * categories, and combine it with the lower bits. - * - * @param categoryOrder The category order for a particular item (if it has - * not been or/add with a category, the default category is - * assumed). - * @return An ordering integer that can be used to order this item across - * all the items (even from other categories). - */ - private static int getOrdering(int categoryOrder) { - final int index = (categoryOrder & CATEGORY_MASK) >> CATEGORY_SHIFT; - - if (index < 0 || index >= sCategoryToOrder.length) { - throw new IllegalArgumentException("order does not contain a valid category."); - } - - return (sCategoryToOrder[index] << CATEGORY_SHIFT) | (categoryOrder & USER_MASK); - } - - /** - * @return whether the menu shortcuts are in qwerty mode or not - */ - boolean isQwertyMode() { - return mQwertyMode; - } - - /** - * Sets whether the shortcuts should be visible on menus. Devices without hardware - * key input will never make shortcuts visible even if this method is passed 'true'. - * - * @param shortcutsVisible Whether shortcuts should be visible (if true and a - * menu item does not have a shortcut defined, that item will - * still NOT show a shortcut) - */ - public void setShortcutsVisible(boolean shortcutsVisible) { - if (mShortcutsVisible == shortcutsVisible) return; - - setShortcutsVisibleInner(shortcutsVisible); - onItemsChanged(false); - } - - private void setShortcutsVisibleInner(boolean shortcutsVisible) { - mShortcutsVisible = shortcutsVisible - && mResources.getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS - && mResources.getBoolean( - R.bool.abs__config_showMenuShortcutsWhenKeyboardPresent); - } - - /** - * @return Whether shortcuts should be visible on menus. - */ - public boolean isShortcutsVisible() { - return mShortcutsVisible; - } - - Resources getResources() { - return mResources; - } - - public Context getContext() { - return mContext; - } - - boolean dispatchMenuItemSelected(MenuBuilder menu, MenuItem item) { - return mCallback != null && mCallback.onMenuItemSelected(menu, item); - } - - /** - * Dispatch a mode change event to this menu's callback. - */ - public void changeMenuMode() { - if (mCallback != null) { - mCallback.onMenuModeChange(this); - } - } - - private static int findInsertIndex(ArrayList items, int ordering) { - for (int i = items.size() - 1; i >= 0; i--) { - MenuItemImpl item = items.get(i); - if (item.getOrdering() <= ordering) { - return i + 1; - } - } - - return 0; - } - - public boolean performShortcut(int keyCode, KeyEvent event, int flags) { - final MenuItemImpl item = findItemWithShortcutForKey(keyCode, event); - - boolean handled = false; - - if (item != null) { - handled = performItemAction(item, flags); - } - - if ((flags & FLAG_ALWAYS_PERFORM_CLOSE) != 0) { - close(true); - } - - return handled; - } - - /* - * This function will return all the menu and sub-menu items that can - * be directly (the shortcut directly corresponds) and indirectly - * (the ALT-enabled char corresponds to the shortcut) associated - * with the keyCode. - */ - @SuppressWarnings("deprecation") - void findItemsWithShortcutForKey(List items, int keyCode, KeyEvent event) { - final boolean qwerty = isQwertyMode(); - final int metaState = event.getMetaState(); - final KeyCharacterMap.KeyData possibleChars = new KeyCharacterMap.KeyData(); - // Get the chars associated with the keyCode (i.e using any chording combo) - final boolean isKeyCodeMapped = event.getKeyData(possibleChars); - // The delete key is not mapped to '\b' so we treat it specially - if (!isKeyCodeMapped && (keyCode != KeyEvent.KEYCODE_DEL)) { - return; - } - - // Look for an item whose shortcut is this key. - final int N = mItems.size(); - for (int i = 0; i < N; i++) { - MenuItemImpl item = mItems.get(i); - if (item.hasSubMenu()) { - ((MenuBuilder)item.getSubMenu()).findItemsWithShortcutForKey(items, keyCode, event); - } - final char shortcutChar = qwerty ? item.getAlphabeticShortcut() : item.getNumericShortcut(); - if (((metaState & (KeyEvent.META_SHIFT_ON | KeyEvent.META_SYM_ON)) == 0) && - (shortcutChar != 0) && - (shortcutChar == possibleChars.meta[0] - || shortcutChar == possibleChars.meta[2] - || (qwerty && shortcutChar == '\b' && - keyCode == KeyEvent.KEYCODE_DEL)) && - item.isEnabled()) { - items.add(item); - } - } - } - - /* - * We want to return the menu item associated with the key, but if there is no - * ambiguity (i.e. there is only one menu item corresponding to the key) we want - * to return it even if it's not an exact match; this allow the user to - * _not_ use the ALT key for example, making the use of shortcuts slightly more - * user-friendly. An example is on the G1, '!' and '1' are on the same key, and - * in Gmail, Menu+1 will trigger Menu+! (the actual shortcut). - * - * On the other hand, if two (or more) shortcuts corresponds to the same key, - * we have to only return the exact match. - */ - @SuppressWarnings("deprecation") - MenuItemImpl findItemWithShortcutForKey(int keyCode, KeyEvent event) { - // Get all items that can be associated directly or indirectly with the keyCode - ArrayList items = mTempShortcutItemList; - items.clear(); - findItemsWithShortcutForKey(items, keyCode, event); - - if (items.isEmpty()) { - return null; - } - - final int metaState = event.getMetaState(); - final KeyCharacterMap.KeyData possibleChars = new KeyCharacterMap.KeyData(); - // Get the chars associated with the keyCode (i.e using any chording combo) - event.getKeyData(possibleChars); - - // If we have only one element, we can safely returns it - final int size = items.size(); - if (size == 1) { - return items.get(0); - } - - final boolean qwerty = isQwertyMode(); - // If we found more than one item associated with the key, - // we have to return the exact match - for (int i = 0; i < size; i++) { - final MenuItemImpl item = items.get(i); - final char shortcutChar = qwerty ? item.getAlphabeticShortcut() : - item.getNumericShortcut(); - if ((shortcutChar == possibleChars.meta[0] && - (metaState & KeyEvent.META_ALT_ON) == 0) - || (shortcutChar == possibleChars.meta[2] && - (metaState & KeyEvent.META_ALT_ON) != 0) - || (qwerty && shortcutChar == '\b' && - keyCode == KeyEvent.KEYCODE_DEL)) { - return item; - } - } - return null; - } - - public boolean performIdentifierAction(int id, int flags) { - // Look for an item whose identifier is the id. - return performItemAction(findItem(id), flags); - } - - public boolean performItemAction(MenuItem item, int flags) { - MenuItemImpl itemImpl = (MenuItemImpl) item; - - if (itemImpl == null || !itemImpl.isEnabled()) { - return false; - } - - boolean invoked = itemImpl.invoke(); - - if (itemImpl.hasCollapsibleActionView()) { - invoked |= itemImpl.expandActionView(); - if (invoked) close(true); - } else if (item.hasSubMenu()) { - close(false); - - final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu(); - final ActionProvider provider = item.getActionProvider(); - if (provider != null && provider.hasSubMenu()) { - provider.onPrepareSubMenu(subMenu); - } - invoked |= dispatchSubMenuSelected(subMenu); - if (!invoked) close(true); - } else { - if ((flags & FLAG_PERFORM_NO_CLOSE) == 0) { - close(true); - } - } - - return invoked; - } - - /** - * Closes the visible menu. - * - * @param allMenusAreClosing Whether the menus are completely closing (true), - * or whether there is another menu coming in this menu's place - * (false). For example, if the menu is closing because a - * sub menu is about to be shown, allMenusAreClosing - * is false. - */ - final void close(boolean allMenusAreClosing) { - if (mIsClosing) return; - - mIsClosing = true; - for (WeakReference ref : mPresenters) { - final MenuPresenter presenter = ref.get(); - if (presenter == null) { - mPresenters.remove(ref); - } else { - presenter.onCloseMenu(this, allMenusAreClosing); - } - } - mIsClosing = false; - } - - /** {@inheritDoc} */ - public void close() { - close(true); - } - - /** - * Called when an item is added or removed. - * - * @param structureChanged true if the menu structure changed, - * false if only item properties changed. - * (Visibility is a structural property since it affects layout.) - */ - void onItemsChanged(boolean structureChanged) { - if (!mPreventDispatchingItemsChanged) { - if (structureChanged) { - mIsVisibleItemsStale = true; - mIsActionItemsStale = true; - } - - dispatchPresenterUpdate(structureChanged); - } else { - mItemsChangedWhileDispatchPrevented = true; - } - } - - /** - * Stop dispatching item changed events to presenters until - * {@link #startDispatchingItemsChanged()} is called. Useful when - * many menu operations are going to be performed as a batch. - */ - public void stopDispatchingItemsChanged() { - if (!mPreventDispatchingItemsChanged) { - mPreventDispatchingItemsChanged = true; - mItemsChangedWhileDispatchPrevented = false; - } - } - - public void startDispatchingItemsChanged() { - mPreventDispatchingItemsChanged = false; - - if (mItemsChangedWhileDispatchPrevented) { - mItemsChangedWhileDispatchPrevented = false; - onItemsChanged(true); - } - } - - /** - * Called by {@link MenuItemImpl} when its visible flag is changed. - * @param item The item that has gone through a visibility change. - */ - void onItemVisibleChanged(MenuItemImpl item) { - // Notify of items being changed - mIsVisibleItemsStale = true; - onItemsChanged(true); - } - - /** - * Called by {@link MenuItemImpl} when its action request status is changed. - * @param item The item that has gone through a change in action request status. - */ - void onItemActionRequestChanged(MenuItemImpl item) { - // Notify of items being changed - mIsActionItemsStale = true; - onItemsChanged(true); - } - - ArrayList getVisibleItems() { - if (!mIsVisibleItemsStale) return mVisibleItems; - - // Refresh the visible items - mVisibleItems.clear(); - - final int itemsSize = mItems.size(); - MenuItemImpl item; - for (int i = 0; i < itemsSize; i++) { - item = mItems.get(i); - if (item.isVisible()) mVisibleItems.add(item); - } - - mIsVisibleItemsStale = false; - mIsActionItemsStale = true; - - return mVisibleItems; - } - - /** - * This method determines which menu items get to be 'action items' that will appear - * in an action bar and which items should be 'overflow items' in a secondary menu. - * The rules are as follows: - * - *

Items are considered for inclusion in the order specified within the menu. - * There is a limit of mMaxActionItems as a total count, optionally including the overflow - * menu button itself. This is a soft limit; if an item shares a group ID with an item - * previously included as an action item, the new item will stay with its group and become - * an action item itself even if it breaks the max item count limit. This is done to - * limit the conceptual complexity of the items presented within an action bar. Only a few - * unrelated concepts should be presented to the user in this space, and groups are treated - * as a single concept. - * - *

There is also a hard limit of consumed measurable space: mActionWidthLimit. This - * limit may be broken by a single item that exceeds the remaining space, but no further - * items may be added. If an item that is part of a group cannot fit within the remaining - * measured width, the entire group will be demoted to overflow. This is done to ensure room - * for navigation and other affordances in the action bar as well as reduce general UI clutter. - * - *

The space freed by demoting a full group cannot be consumed by future menu items. - * Once items begin to overflow, all future items become overflow items as well. This is - * to avoid inadvertent reordering that may break the app's intended design. - */ - public void flagActionItems() { - if (!mIsActionItemsStale) { - return; - } - - // Presenters flag action items as needed. - boolean flagged = false; - for (WeakReference ref : mPresenters) { - final MenuPresenter presenter = ref.get(); - if (presenter == null) { - mPresenters.remove(ref); - } else { - flagged |= presenter.flagActionItems(); - } - } - - if (flagged) { - mActionItems.clear(); - mNonActionItems.clear(); - ArrayList visibleItems = getVisibleItems(); - final int itemsSize = visibleItems.size(); - for (int i = 0; i < itemsSize; i++) { - MenuItemImpl item = visibleItems.get(i); - if (item.isActionButton()) { - mActionItems.add(item); - } else { - mNonActionItems.add(item); - } - } - } else { - // Nobody flagged anything, everything is a non-action item. - // (This happens during a first pass with no action-item presenters.) - mActionItems.clear(); - mNonActionItems.clear(); - mNonActionItems.addAll(getVisibleItems()); - } - mIsActionItemsStale = false; - } - - ArrayList getActionItems() { - flagActionItems(); - return mActionItems; - } - - ArrayList getNonActionItems() { - flagActionItems(); - return mNonActionItems; - } - - public void clearHeader() { - mHeaderIcon = null; - mHeaderTitle = null; - mHeaderView = null; - - onItemsChanged(false); - } - - private void setHeaderInternal(final int titleRes, final CharSequence title, final int iconRes, - final Drawable icon, final View view) { - final Resources r = getResources(); - - if (view != null) { - mHeaderView = view; - - // If using a custom view, then the title and icon aren't used - mHeaderTitle = null; - mHeaderIcon = null; - } else { - if (titleRes > 0) { - mHeaderTitle = r.getText(titleRes); - } else if (title != null) { - mHeaderTitle = title; - } - - if (iconRes > 0) { - mHeaderIcon = r.getDrawable(iconRes); - } else if (icon != null) { - mHeaderIcon = icon; - } - - // If using the title or icon, then a custom view isn't used - mHeaderView = null; - } - - // Notify of change - onItemsChanged(false); - } - - /** - * Sets the header's title. This replaces the header view. Called by the - * builder-style methods of subclasses. - * - * @param title The new title. - * @return This MenuBuilder so additional setters can be called. - */ - protected MenuBuilder setHeaderTitleInt(CharSequence title) { - setHeaderInternal(0, title, 0, null, null); - return this; - } - - /** - * Sets the header's title. This replaces the header view. Called by the - * builder-style methods of subclasses. - * - * @param titleRes The new title (as a resource ID). - * @return This MenuBuilder so additional setters can be called. - */ - protected MenuBuilder setHeaderTitleInt(int titleRes) { - setHeaderInternal(titleRes, null, 0, null, null); - return this; - } - - /** - * Sets the header's icon. This replaces the header view. Called by the - * builder-style methods of subclasses. - * - * @param icon The new icon. - * @return This MenuBuilder so additional setters can be called. - */ - protected MenuBuilder setHeaderIconInt(Drawable icon) { - setHeaderInternal(0, null, 0, icon, null); - return this; - } - - /** - * Sets the header's icon. This replaces the header view. Called by the - * builder-style methods of subclasses. - * - * @param iconRes The new icon (as a resource ID). - * @return This MenuBuilder so additional setters can be called. - */ - protected MenuBuilder setHeaderIconInt(int iconRes) { - setHeaderInternal(0, null, iconRes, null, null); - return this; - } - - /** - * Sets the header's view. This replaces the title and icon. Called by the - * builder-style methods of subclasses. - * - * @param view The new view. - * @return This MenuBuilder so additional setters can be called. - */ - protected MenuBuilder setHeaderViewInt(View view) { - setHeaderInternal(0, null, 0, null, view); - return this; - } - - public CharSequence getHeaderTitle() { - return mHeaderTitle; - } - - public Drawable getHeaderIcon() { - return mHeaderIcon; - } - - public View getHeaderView() { - return mHeaderView; - } - - /** - * Gets the root menu (if this is a submenu, find its root menu). - * @return The root menu. - */ - public MenuBuilder getRootMenu() { - return this; - } - - /** - * Sets the current menu info that is set on all items added to this menu - * (until this is called again with different menu info, in which case that - * one will be added to all subsequent item additions). - * - * @param menuInfo The extra menu information to add. - */ - public void setCurrentMenuInfo(ContextMenuInfo menuInfo) { - mCurrentMenuInfo = menuInfo; - } - - void setOptionalIconsVisible(boolean visible) { - mOptionalIconsVisible = visible; - } - - boolean getOptionalIconsVisible() { - return mOptionalIconsVisible; - } - - public boolean expandItemActionView(MenuItemImpl item) { - if (mPresenters.isEmpty()) return false; - - boolean expanded = false; - - stopDispatchingItemsChanged(); - for (WeakReference ref : mPresenters) { - final MenuPresenter presenter = ref.get(); - if (presenter == null) { - mPresenters.remove(ref); - } else if ((expanded = presenter.expandItemActionView(this, item))) { - break; - } - } - startDispatchingItemsChanged(); - - if (expanded) { - mExpandedItem = item; - } - return expanded; - } - - public boolean collapseItemActionView(MenuItemImpl item) { - if (mPresenters.isEmpty() || mExpandedItem != item) return false; - - boolean collapsed = false; - - stopDispatchingItemsChanged(); - for (WeakReference ref : mPresenters) { - final MenuPresenter presenter = ref.get(); - if (presenter == null) { - mPresenters.remove(ref); - } else if ((collapsed = presenter.collapseItemActionView(this, item))) { - break; - } - } - startDispatchingItemsChanged(); - - if (collapsed) { - mExpandedItem = null; - } - return collapsed; - } - - public MenuItemImpl getExpandedItem() { - return mExpandedItem; - } - - public boolean bindNativeOverflow(android.view.Menu menu, android.view.MenuItem.OnMenuItemClickListener listener, HashMap map) { - final List nonActionItems = getNonActionItems(); - if (nonActionItems == null || nonActionItems.size() == 0) { - return false; - } - - boolean visible = false; - menu.clear(); - for (MenuItemImpl nonActionItem : nonActionItems) { - if (!nonActionItem.isVisible()) { - continue; - } - visible = true; - - android.view.MenuItem nativeItem; - if (nonActionItem.hasSubMenu()) { - android.view.SubMenu nativeSub = menu.addSubMenu(nonActionItem.getGroupId(), nonActionItem.getItemId(), - nonActionItem.getOrder(), nonActionItem.getTitle()); - - SubMenuBuilder subMenu = (SubMenuBuilder)nonActionItem.getSubMenu(); - for (MenuItemImpl subItem : subMenu.getVisibleItems()) { - android.view.MenuItem nativeSubItem = nativeSub.add(subItem.getGroupId(), subItem.getItemId(), - subItem.getOrder(), subItem.getTitle()); - - nativeSubItem.setIcon(subItem.getIcon()); - nativeSubItem.setOnMenuItemClickListener(listener); - nativeSubItem.setEnabled(subItem.isEnabled()); - nativeSubItem.setIntent(subItem.getIntent()); - nativeSubItem.setNumericShortcut(subItem.getNumericShortcut()); - nativeSubItem.setAlphabeticShortcut(subItem.getAlphabeticShortcut()); - nativeSubItem.setTitleCondensed(subItem.getTitleCondensed()); - nativeSubItem.setCheckable(subItem.isCheckable()); - nativeSubItem.setChecked(subItem.isChecked()); - - if (subItem.isExclusiveCheckable()) { - nativeSub.setGroupCheckable(subItem.getGroupId(), true, true); - } - - map.put(nativeSubItem, subItem); - } - - nativeItem = nativeSub.getItem(); - } else { - nativeItem = menu.add(nonActionItem.getGroupId(), nonActionItem.getItemId(), - nonActionItem.getOrder(), nonActionItem.getTitle()); - } - nativeItem.setIcon(nonActionItem.getIcon()); - nativeItem.setOnMenuItemClickListener(listener); - nativeItem.setEnabled(nonActionItem.isEnabled()); - nativeItem.setIntent(nonActionItem.getIntent()); - nativeItem.setNumericShortcut(nonActionItem.getNumericShortcut()); - nativeItem.setAlphabeticShortcut(nonActionItem.getAlphabeticShortcut()); - nativeItem.setTitleCondensed(nonActionItem.getTitleCondensed()); - nativeItem.setCheckable(nonActionItem.isCheckable()); - nativeItem.setChecked(nonActionItem.isChecked()); - - if (nonActionItem.isExclusiveCheckable()) { - menu.setGroupCheckable(nonActionItem.getGroupId(), true, true); - } - - map.put(nativeItem, nonActionItem); - } - return visible; - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemImpl.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemImpl.java deleted file mode 100644 index f5359fb40..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemImpl.java +++ /dev/null @@ -1,647 +0,0 @@ -/* - * Copyright (C) 2006 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.actionbarsherlock.internal.view.menu; - -import android.content.ActivityNotFoundException; -import android.content.Context; -import android.content.Intent; -import android.graphics.drawable.Drawable; -import android.util.Log; -import android.view.ContextMenu.ContextMenuInfo; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewDebug; -import android.widget.LinearLayout; - -import com.actionbarsherlock.view.ActionProvider; -import com.actionbarsherlock.view.MenuItem; -import com.actionbarsherlock.view.SubMenu; - -/** - * @hide - */ -public final class MenuItemImpl implements MenuItem { - private static final String TAG = "MenuItemImpl"; - - private static final int SHOW_AS_ACTION_MASK = SHOW_AS_ACTION_NEVER | - SHOW_AS_ACTION_IF_ROOM | - SHOW_AS_ACTION_ALWAYS; - - private final int mId; - private final int mGroup; - private final int mCategoryOrder; - private final int mOrdering; - private CharSequence mTitle; - private CharSequence mTitleCondensed; - private Intent mIntent; - private char mShortcutNumericChar; - private char mShortcutAlphabeticChar; - - /** The icon's drawable which is only created as needed */ - private Drawable mIconDrawable; - /** - * The icon's resource ID which is used to get the Drawable when it is - * needed (if the Drawable isn't already obtained--only one of the two is - * needed). - */ - private int mIconResId = NO_ICON; - - /** The menu to which this item belongs */ - private MenuBuilder mMenu; - /** If this item should launch a sub menu, this is the sub menu to launch */ - private SubMenuBuilder mSubMenu; - - private Runnable mItemCallback; - private MenuItem.OnMenuItemClickListener mClickListener; - - private int mFlags = ENABLED; - private static final int CHECKABLE = 0x00000001; - private static final int CHECKED = 0x00000002; - private static final int EXCLUSIVE = 0x00000004; - private static final int HIDDEN = 0x00000008; - private static final int ENABLED = 0x00000010; - private static final int IS_ACTION = 0x00000020; - - private int mShowAsAction = SHOW_AS_ACTION_NEVER; - - private View mActionView; - private ActionProvider mActionProvider; - private OnActionExpandListener mOnActionExpandListener; - private boolean mIsActionViewExpanded = false; - - /** Used for the icon resource ID if this item does not have an icon */ - static final int NO_ICON = 0; - - /** - * Current use case is for context menu: Extra information linked to the - * View that added this item to the context menu. - */ - private ContextMenuInfo mMenuInfo; - - private static String sPrependShortcutLabel; - private static String sEnterShortcutLabel; - private static String sDeleteShortcutLabel; - private static String sSpaceShortcutLabel; - - - /** - * Instantiates this menu item. - * - * @param menu - * @param group Item ordering grouping control. The item will be added after - * all other items whose order is <= this number, and before any - * that are larger than it. This can also be used to define - * groups of items for batch state changes. Normally use 0. - * @param id Unique item ID. Use 0 if you do not need a unique ID. - * @param categoryOrder The ordering for this item. - * @param title The text to display for the item. - */ - MenuItemImpl(MenuBuilder menu, int group, int id, int categoryOrder, int ordering, - CharSequence title, int showAsAction) { - - /* TODO if (sPrependShortcutLabel == null) { - // This is instantiated from the UI thread, so no chance of sync issues - sPrependShortcutLabel = menu.getContext().getResources().getString( - com.android.internal.R.string.prepend_shortcut_label); - sEnterShortcutLabel = menu.getContext().getResources().getString( - com.android.internal.R.string.menu_enter_shortcut_label); - sDeleteShortcutLabel = menu.getContext().getResources().getString( - com.android.internal.R.string.menu_delete_shortcut_label); - sSpaceShortcutLabel = menu.getContext().getResources().getString( - com.android.internal.R.string.menu_space_shortcut_label); - }*/ - - mMenu = menu; - mId = id; - mGroup = group; - mCategoryOrder = categoryOrder; - mOrdering = ordering; - mTitle = title; - mShowAsAction = showAsAction; - } - - /** - * Invokes the item by calling various listeners or callbacks. - * - * @return true if the invocation was handled, false otherwise - */ - public boolean invoke() { - if (mClickListener != null && - mClickListener.onMenuItemClick(this)) { - return true; - } - - if (mMenu.dispatchMenuItemSelected(mMenu.getRootMenu(), this)) { - return true; - } - - if (mItemCallback != null) { - mItemCallback.run(); - return true; - } - - if (mIntent != null) { - try { - mMenu.getContext().startActivity(mIntent); - return true; - } catch (ActivityNotFoundException e) { - Log.e(TAG, "Can't find activity to handle intent; ignoring", e); - } - } - - if (mActionProvider != null && mActionProvider.onPerformDefaultAction()) { - return true; - } - - return false; - } - - public boolean isEnabled() { - return (mFlags & ENABLED) != 0; - } - - public MenuItem setEnabled(boolean enabled) { - if (enabled) { - mFlags |= ENABLED; - } else { - mFlags &= ~ENABLED; - } - - mMenu.onItemsChanged(false); - - return this; - } - - public int getGroupId() { - return mGroup; - } - - @ViewDebug.CapturedViewProperty - public int getItemId() { - return mId; - } - - public int getOrder() { - return mCategoryOrder; - } - - public int getOrdering() { - return mOrdering; - } - - public Intent getIntent() { - return mIntent; - } - - public MenuItem setIntent(Intent intent) { - mIntent = intent; - return this; - } - - Runnable getCallback() { - return mItemCallback; - } - - public MenuItem setCallback(Runnable callback) { - mItemCallback = callback; - return this; - } - - public char getAlphabeticShortcut() { - return mShortcutAlphabeticChar; - } - - public MenuItem setAlphabeticShortcut(char alphaChar) { - if (mShortcutAlphabeticChar == alphaChar) return this; - - mShortcutAlphabeticChar = Character.toLowerCase(alphaChar); - - mMenu.onItemsChanged(false); - - return this; - } - - public char getNumericShortcut() { - return mShortcutNumericChar; - } - - public MenuItem setNumericShortcut(char numericChar) { - if (mShortcutNumericChar == numericChar) return this; - - mShortcutNumericChar = numericChar; - - mMenu.onItemsChanged(false); - - return this; - } - - public MenuItem setShortcut(char numericChar, char alphaChar) { - mShortcutNumericChar = numericChar; - mShortcutAlphabeticChar = Character.toLowerCase(alphaChar); - - mMenu.onItemsChanged(false); - - return this; - } - - /** - * @return The active shortcut (based on QWERTY-mode of the menu). - */ - char getShortcut() { - return (mMenu.isQwertyMode() ? mShortcutAlphabeticChar : mShortcutNumericChar); - } - - /** - * @return The label to show for the shortcut. This includes the chording - * key (for example 'Menu+a'). Also, any non-human readable - * characters should be human readable (for example 'Menu+enter'). - */ - String getShortcutLabel() { - - char shortcut = getShortcut(); - if (shortcut == 0) { - return ""; - } - - StringBuilder sb = new StringBuilder(sPrependShortcutLabel); - switch (shortcut) { - - case '\n': - sb.append(sEnterShortcutLabel); - break; - - case '\b': - sb.append(sDeleteShortcutLabel); - break; - - case ' ': - sb.append(sSpaceShortcutLabel); - break; - - default: - sb.append(shortcut); - break; - } - - return sb.toString(); - } - - /** - * @return Whether this menu item should be showing shortcuts (depends on - * whether the menu should show shortcuts and whether this item has - * a shortcut defined) - */ - boolean shouldShowShortcut() { - // Show shortcuts if the menu is supposed to show shortcuts AND this item has a shortcut - return mMenu.isShortcutsVisible() && (getShortcut() != 0); - } - - public SubMenu getSubMenu() { - return mSubMenu; - } - - public boolean hasSubMenu() { - return mSubMenu != null; - } - - void setSubMenu(SubMenuBuilder subMenu) { - mSubMenu = subMenu; - - subMenu.setHeaderTitle(getTitle()); - } - - @ViewDebug.CapturedViewProperty - public CharSequence getTitle() { - return mTitle; - } - - /** - * Gets the title for a particular {@link ItemView} - * - * @param itemView The ItemView that is receiving the title - * @return Either the title or condensed title based on what the ItemView - * prefers - */ - CharSequence getTitleForItemView(MenuView.ItemView itemView) { - return ((itemView != null) && itemView.prefersCondensedTitle()) - ? getTitleCondensed() - : getTitle(); - } - - public MenuItem setTitle(CharSequence title) { - mTitle = title; - - mMenu.onItemsChanged(false); - - if (mSubMenu != null) { - mSubMenu.setHeaderTitle(title); - } - - return this; - } - - public MenuItem setTitle(int title) { - return setTitle(mMenu.getContext().getString(title)); - } - - public CharSequence getTitleCondensed() { - return mTitleCondensed != null ? mTitleCondensed : mTitle; - } - - public MenuItem setTitleCondensed(CharSequence title) { - mTitleCondensed = title; - - // Could use getTitle() in the loop below, but just cache what it would do here - if (title == null) { - title = mTitle; - } - - mMenu.onItemsChanged(false); - - return this; - } - - public Drawable getIcon() { - if (mIconDrawable != null) { - return mIconDrawable; - } - - if (mIconResId != NO_ICON) { - return mMenu.getResources().getDrawable(mIconResId); - } - - return null; - } - - public MenuItem setIcon(Drawable icon) { - mIconResId = NO_ICON; - mIconDrawable = icon; - mMenu.onItemsChanged(false); - - return this; - } - - public MenuItem setIcon(int iconResId) { - mIconDrawable = null; - mIconResId = iconResId; - - // If we have a view, we need to push the Drawable to them - mMenu.onItemsChanged(false); - - return this; - } - - public boolean isCheckable() { - return (mFlags & CHECKABLE) == CHECKABLE; - } - - public MenuItem setCheckable(boolean checkable) { - final int oldFlags = mFlags; - mFlags = (mFlags & ~CHECKABLE) | (checkable ? CHECKABLE : 0); - if (oldFlags != mFlags) { - mMenu.onItemsChanged(false); - } - - return this; - } - - public void setExclusiveCheckable(boolean exclusive) { - mFlags = (mFlags & ~EXCLUSIVE) | (exclusive ? EXCLUSIVE : 0); - } - - public boolean isExclusiveCheckable() { - return (mFlags & EXCLUSIVE) != 0; - } - - public boolean isChecked() { - return (mFlags & CHECKED) == CHECKED; - } - - public MenuItem setChecked(boolean checked) { - if ((mFlags & EXCLUSIVE) != 0) { - // Call the method on the Menu since it knows about the others in this - // exclusive checkable group - mMenu.setExclusiveItemChecked(this); - } else { - setCheckedInt(checked); - } - - return this; - } - - void setCheckedInt(boolean checked) { - final int oldFlags = mFlags; - mFlags = (mFlags & ~CHECKED) | (checked ? CHECKED : 0); - if (oldFlags != mFlags) { - mMenu.onItemsChanged(false); - } - } - - public boolean isVisible() { - return (mFlags & HIDDEN) == 0; - } - - /** - * Changes the visibility of the item. This method DOES NOT notify the - * parent menu of a change in this item, so this should only be called from - * methods that will eventually trigger this change. If unsure, use {@link #setVisible(boolean)} - * instead. - * - * @param shown Whether to show (true) or hide (false). - * @return Whether the item's shown state was changed - */ - boolean setVisibleInt(boolean shown) { - final int oldFlags = mFlags; - mFlags = (mFlags & ~HIDDEN) | (shown ? 0 : HIDDEN); - return oldFlags != mFlags; - } - - public MenuItem setVisible(boolean shown) { - // Try to set the shown state to the given state. If the shown state was changed - // (i.e. the previous state isn't the same as given state), notify the parent menu that - // the shown state has changed for this item - if (setVisibleInt(shown)) mMenu.onItemVisibleChanged(this); - - return this; - } - - public MenuItem setOnMenuItemClickListener(MenuItem.OnMenuItemClickListener clickListener) { - mClickListener = clickListener; - return this; - } - - @Override - public String toString() { - return mTitle.toString(); - } - - void setMenuInfo(ContextMenuInfo menuInfo) { - mMenuInfo = menuInfo; - } - - public ContextMenuInfo getMenuInfo() { - return mMenuInfo; - } - - public void actionFormatChanged() { - mMenu.onItemActionRequestChanged(this); - } - - /** - * @return Whether the menu should show icons for menu items. - */ - public boolean shouldShowIcon() { - return mMenu.getOptionalIconsVisible(); - } - - public boolean isActionButton() { - return (mFlags & IS_ACTION) == IS_ACTION; - } - - public boolean requestsActionButton() { - return (mShowAsAction & SHOW_AS_ACTION_IF_ROOM) == SHOW_AS_ACTION_IF_ROOM; - } - - public boolean requiresActionButton() { - return (mShowAsAction & SHOW_AS_ACTION_ALWAYS) == SHOW_AS_ACTION_ALWAYS; - } - - public void setIsActionButton(boolean isActionButton) { - if (isActionButton) { - mFlags |= IS_ACTION; - } else { - mFlags &= ~IS_ACTION; - } - } - - public boolean showsTextAsAction() { - return (mShowAsAction & SHOW_AS_ACTION_WITH_TEXT) == SHOW_AS_ACTION_WITH_TEXT; - } - - public void setShowAsAction(int actionEnum) { - switch (actionEnum & SHOW_AS_ACTION_MASK) { - case SHOW_AS_ACTION_ALWAYS: - case SHOW_AS_ACTION_IF_ROOM: - case SHOW_AS_ACTION_NEVER: - // Looks good! - break; - - default: - // Mutually exclusive options selected! - throw new IllegalArgumentException("SHOW_AS_ACTION_ALWAYS, SHOW_AS_ACTION_IF_ROOM," - + " and SHOW_AS_ACTION_NEVER are mutually exclusive."); - } - mShowAsAction = actionEnum; - mMenu.onItemActionRequestChanged(this); - } - - public MenuItem setActionView(View view) { - mActionView = view; - mActionProvider = null; - if (view != null && view.getId() == View.NO_ID && mId > 0) { - view.setId(mId); - } - mMenu.onItemActionRequestChanged(this); - return this; - } - - public MenuItem setActionView(int resId) { - final Context context = mMenu.getContext(); - final LayoutInflater inflater = LayoutInflater.from(context); - setActionView(inflater.inflate(resId, new LinearLayout(context), false)); - return this; - } - - public View getActionView() { - if (mActionView != null) { - return mActionView; - } else if (mActionProvider != null) { - mActionView = mActionProvider.onCreateActionView(); - return mActionView; - } else { - return null; - } - } - - public ActionProvider getActionProvider() { - return mActionProvider; - } - - public MenuItem setActionProvider(ActionProvider actionProvider) { - mActionView = null; - mActionProvider = actionProvider; - mMenu.onItemsChanged(true); // Measurement can be changed - return this; - } - - @Override - public MenuItem setShowAsActionFlags(int actionEnum) { - setShowAsAction(actionEnum); - return this; - } - - @Override - public boolean expandActionView() { - if ((mShowAsAction & SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW) == 0 || mActionView == null) { - return false; - } - - if (mOnActionExpandListener == null || - mOnActionExpandListener.onMenuItemActionExpand(this)) { - return mMenu.expandItemActionView(this); - } - - return false; - } - - @Override - public boolean collapseActionView() { - if ((mShowAsAction & SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW) == 0) { - return false; - } - if (mActionView == null) { - // We're already collapsed if we have no action view. - return true; - } - - if (mOnActionExpandListener == null || - mOnActionExpandListener.onMenuItemActionCollapse(this)) { - return mMenu.collapseItemActionView(this); - } - - return false; - } - - @Override - public MenuItem setOnActionExpandListener(OnActionExpandListener listener) { - mOnActionExpandListener = listener; - return this; - } - - public boolean hasCollapsibleActionView() { - return (mShowAsAction & SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW) != 0 && mActionView != null; - } - - public void setActionViewExpanded(boolean isExpanded) { - mIsActionViewExpanded = isExpanded; - mMenu.onItemsChanged(false); - } - - public boolean isActionViewExpanded() { - return mIsActionViewExpanded; - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemWrapper.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemWrapper.java deleted file mode 100644 index 907a7aa04..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemWrapper.java +++ /dev/null @@ -1,292 +0,0 @@ -package com.actionbarsherlock.internal.view.menu; - -import android.content.Intent; -import android.graphics.drawable.Drawable; -import android.view.View; -import android.view.ContextMenu.ContextMenuInfo; -import com.actionbarsherlock.internal.view.ActionProviderWrapper; -import com.actionbarsherlock.view.ActionProvider; -import com.actionbarsherlock.view.MenuItem; -import com.actionbarsherlock.view.SubMenu; - -public class MenuItemWrapper implements MenuItem, android.view.MenuItem.OnMenuItemClickListener { - private final android.view.MenuItem mNativeItem; - private SubMenu mSubMenu = null; - private OnMenuItemClickListener mMenuItemClickListener = null; - private OnActionExpandListener mActionExpandListener = null; - private android.view.MenuItem.OnActionExpandListener mNativeActionExpandListener = null; - - - public MenuItemWrapper(android.view.MenuItem nativeItem) { - if (nativeItem == null) { - throw new IllegalStateException("Wrapped menu item cannot be null."); - } - mNativeItem = nativeItem; - } - - - @Override - public int getItemId() { - return mNativeItem.getItemId(); - } - - @Override - public int getGroupId() { - return mNativeItem.getGroupId(); - } - - @Override - public int getOrder() { - return mNativeItem.getOrder(); - } - - @Override - public MenuItem setTitle(CharSequence title) { - mNativeItem.setTitle(title); - return this; - } - - @Override - public MenuItem setTitle(int title) { - mNativeItem.setTitle(title); - return this; - } - - @Override - public CharSequence getTitle() { - return mNativeItem.getTitle(); - } - - @Override - public MenuItem setTitleCondensed(CharSequence title) { - mNativeItem.setTitleCondensed(title); - return this; - } - - @Override - public CharSequence getTitleCondensed() { - return mNativeItem.getTitleCondensed(); - } - - @Override - public MenuItem setIcon(Drawable icon) { - mNativeItem.setIcon(icon); - return this; - } - - @Override - public MenuItem setIcon(int iconRes) { - mNativeItem.setIcon(iconRes); - return this; - } - - @Override - public Drawable getIcon() { - return mNativeItem.getIcon(); - } - - @Override - public MenuItem setIntent(Intent intent) { - mNativeItem.setIntent(intent); - return this; - } - - @Override - public Intent getIntent() { - return mNativeItem.getIntent(); - } - - @Override - public MenuItem setShortcut(char numericChar, char alphaChar) { - mNativeItem.setShortcut(numericChar, alphaChar); - return this; - } - - @Override - public MenuItem setNumericShortcut(char numericChar) { - mNativeItem.setNumericShortcut(numericChar); - return this; - } - - @Override - public char getNumericShortcut() { - return mNativeItem.getNumericShortcut(); - } - - @Override - public MenuItem setAlphabeticShortcut(char alphaChar) { - mNativeItem.setAlphabeticShortcut(alphaChar); - return this; - } - - @Override - public char getAlphabeticShortcut() { - return mNativeItem.getAlphabeticShortcut(); - } - - @Override - public MenuItem setCheckable(boolean checkable) { - mNativeItem.setCheckable(checkable); - return this; - } - - @Override - public boolean isCheckable() { - return mNativeItem.isCheckable(); - } - - @Override - public MenuItem setChecked(boolean checked) { - mNativeItem.setChecked(checked); - return this; - } - - @Override - public boolean isChecked() { - return mNativeItem.isChecked(); - } - - @Override - public MenuItem setVisible(boolean visible) { - mNativeItem.setVisible(visible); - return this; - } - - @Override - public boolean isVisible() { - return mNativeItem.isVisible(); - } - - @Override - public MenuItem setEnabled(boolean enabled) { - mNativeItem.setEnabled(enabled); - return this; - } - - @Override - public boolean isEnabled() { - return mNativeItem.isEnabled(); - } - - @Override - public boolean hasSubMenu() { - return mNativeItem.hasSubMenu(); - } - - @Override - public SubMenu getSubMenu() { - if (hasSubMenu() && (mSubMenu == null)) { - mSubMenu = new SubMenuWrapper(mNativeItem.getSubMenu()); - } - return mSubMenu; - } - - @Override - public MenuItem setOnMenuItemClickListener(OnMenuItemClickListener menuItemClickListener) { - mMenuItemClickListener = menuItemClickListener; - //Register ourselves as the listener to proxy - mNativeItem.setOnMenuItemClickListener(this); - return this; - } - - @Override - public boolean onMenuItemClick(android.view.MenuItem item) { - if (mMenuItemClickListener != null) { - return mMenuItemClickListener.onMenuItemClick(this); - } - return false; - } - - @Override - public ContextMenuInfo getMenuInfo() { - return mNativeItem.getMenuInfo(); - } - - @Override - public void setShowAsAction(int actionEnum) { - mNativeItem.setShowAsAction(actionEnum); - } - - @Override - public MenuItem setShowAsActionFlags(int actionEnum) { - mNativeItem.setShowAsActionFlags(actionEnum); - return this; - } - - @Override - public MenuItem setActionView(View view) { - mNativeItem.setActionView(view); - return this; - } - - @Override - public MenuItem setActionView(int resId) { - mNativeItem.setActionView(resId); - return this; - } - - @Override - public View getActionView() { - return mNativeItem.getActionView(); - } - - @Override - public MenuItem setActionProvider(ActionProvider actionProvider) { - mNativeItem.setActionProvider(new ActionProviderWrapper(actionProvider)); - return this; - } - - @Override - public ActionProvider getActionProvider() { - android.view.ActionProvider nativeProvider = mNativeItem.getActionProvider(); - if (nativeProvider != null && nativeProvider instanceof ActionProviderWrapper) { - return ((ActionProviderWrapper)nativeProvider).unwrap(); - } - return null; - } - - @Override - public boolean expandActionView() { - return mNativeItem.expandActionView(); - } - - @Override - public boolean collapseActionView() { - return mNativeItem.collapseActionView(); - } - - @Override - public boolean isActionViewExpanded() { - return mNativeItem.isActionViewExpanded(); - } - - @Override - public MenuItem setOnActionExpandListener(OnActionExpandListener listener) { - mActionExpandListener = listener; - - if (mNativeActionExpandListener == null) { - mNativeActionExpandListener = new android.view.MenuItem.OnActionExpandListener() { - @Override - public boolean onMenuItemActionExpand(android.view.MenuItem menuItem) { - if (mActionExpandListener != null) { - return mActionExpandListener.onMenuItemActionExpand(MenuItemWrapper.this); - } - return false; - } - - @Override - public boolean onMenuItemActionCollapse(android.view.MenuItem menuItem) { - if (mActionExpandListener != null) { - return mActionExpandListener.onMenuItemActionCollapse(MenuItemWrapper.this); - } - return false; - } - }; - - //Register our inner-class as the listener to proxy method calls - mNativeItem.setOnActionExpandListener(mNativeActionExpandListener); - } - - return this; - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuPopupHelper.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuPopupHelper.java deleted file mode 100644 index f030de310..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuPopupHelper.java +++ /dev/null @@ -1,376 +0,0 @@ -/* - * Copyright (C) 2010 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.actionbarsherlock.internal.view.menu; - -import java.util.ArrayList; -import android.content.Context; -import android.content.res.Resources; -import android.database.DataSetObserver; -import android.os.Parcelable; -import android.view.KeyEvent; -import android.view.LayoutInflater; -import android.view.View; -import android.view.View.MeasureSpec; -import android.view.ViewGroup; -import android.view.ViewTreeObserver; -import android.widget.AdapterView; -import android.widget.BaseAdapter; -import android.widget.FrameLayout; -import android.widget.ListAdapter; -import android.widget.PopupWindow; -import com.actionbarsherlock.R; -import com.actionbarsherlock.internal.view.View_HasStateListenerSupport; -import com.actionbarsherlock.internal.view.View_OnAttachStateChangeListener; -import com.actionbarsherlock.internal.widget.IcsListPopupWindow; -import com.actionbarsherlock.view.MenuItem; - -/** - * Presents a menu as a small, simple popup anchored to another view. - * @hide - */ -public class MenuPopupHelper implements AdapterView.OnItemClickListener, View.OnKeyListener, - ViewTreeObserver.OnGlobalLayoutListener, PopupWindow.OnDismissListener, - View_OnAttachStateChangeListener, MenuPresenter { - //UNUSED private static final String TAG = "MenuPopupHelper"; - - static final int ITEM_LAYOUT = R.layout.abs__popup_menu_item_layout; - - private Context mContext; - private LayoutInflater mInflater; - private IcsListPopupWindow mPopup; - private MenuBuilder mMenu; - private int mPopupMaxWidth; - private View mAnchorView; - private boolean mOverflowOnly; - private ViewTreeObserver mTreeObserver; - - private MenuAdapter mAdapter; - - private Callback mPresenterCallback; - - boolean mForceShowIcon; - - private ViewGroup mMeasureParent; - - public MenuPopupHelper(Context context, MenuBuilder menu) { - this(context, menu, null, false); - } - - public MenuPopupHelper(Context context, MenuBuilder menu, View anchorView) { - this(context, menu, anchorView, false); - } - - public MenuPopupHelper(Context context, MenuBuilder menu, - View anchorView, boolean overflowOnly) { - mContext = context; - mInflater = LayoutInflater.from(context); - mMenu = menu; - mOverflowOnly = overflowOnly; - - final Resources res = context.getResources(); - mPopupMaxWidth = Math.max(res.getDisplayMetrics().widthPixels / 2, - res.getDimensionPixelSize(R.dimen.abs__config_prefDialogWidth)); - - mAnchorView = anchorView; - - menu.addMenuPresenter(this); - } - - public void setAnchorView(View anchor) { - mAnchorView = anchor; - } - - public void setForceShowIcon(boolean forceShow) { - mForceShowIcon = forceShow; - } - - public void show() { - if (!tryShow()) { - throw new IllegalStateException("MenuPopupHelper cannot be used without an anchor"); - } - } - - public boolean tryShow() { - mPopup = new IcsListPopupWindow(mContext, null, R.attr.popupMenuStyle); - mPopup.setOnDismissListener(this); - mPopup.setOnItemClickListener(this); - - mAdapter = new MenuAdapter(mMenu); - mPopup.setAdapter(mAdapter); - mPopup.setModal(true); - - View anchor = mAnchorView; - if (anchor != null) { - final boolean addGlobalListener = mTreeObserver == null; - mTreeObserver = anchor.getViewTreeObserver(); // Refresh to latest - if (addGlobalListener) mTreeObserver.addOnGlobalLayoutListener(this); - ((View_HasStateListenerSupport)anchor).addOnAttachStateChangeListener(this); - mPopup.setAnchorView(anchor); - } else { - return false; - } - - mPopup.setContentWidth(Math.min(measureContentWidth(mAdapter), mPopupMaxWidth)); - mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED); - mPopup.show(); - mPopup.getListView().setOnKeyListener(this); - return true; - } - - public void dismiss() { - if (isShowing()) { - mPopup.dismiss(); - } - } - - public void onDismiss() { - mPopup = null; - mMenu.close(); - if (mTreeObserver != null) { - if (!mTreeObserver.isAlive()) mTreeObserver = mAnchorView.getViewTreeObserver(); - mTreeObserver.removeGlobalOnLayoutListener(this); - mTreeObserver = null; - } - ((View_HasStateListenerSupport)mAnchorView).removeOnAttachStateChangeListener(this); - } - - public boolean isShowing() { - return mPopup != null && mPopup.isShowing(); - } - - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { - MenuAdapter adapter = mAdapter; - adapter.mAdapterMenu.performItemAction(adapter.getItem(position), 0); - } - - public boolean onKey(View v, int keyCode, KeyEvent event) { - if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_MENU) { - dismiss(); - return true; - } - return false; - } - - private int measureContentWidth(ListAdapter adapter) { - // Menus don't tend to be long, so this is more sane than it looks. - int width = 0; - View itemView = null; - int itemType = 0; - final int widthMeasureSpec = - MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); - final int heightMeasureSpec = - MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); - final int count = adapter.getCount(); - for (int i = 0; i < count; i++) { - final int positionType = adapter.getItemViewType(i); - if (positionType != itemType) { - itemType = positionType; - itemView = null; - } - if (mMeasureParent == null) { - mMeasureParent = new FrameLayout(mContext); - } - itemView = adapter.getView(i, itemView, mMeasureParent); - itemView.measure(widthMeasureSpec, heightMeasureSpec); - width = Math.max(width, itemView.getMeasuredWidth()); - } - return width; - } - - @Override - public void onGlobalLayout() { - if (isShowing()) { - final View anchor = mAnchorView; - if (anchor == null || !anchor.isShown()) { - dismiss(); - } else if (isShowing()) { - // Recompute window size and position - mPopup.show(); - } - } - } - - @Override - public void onViewAttachedToWindow(View v) { - } - - @Override - public void onViewDetachedFromWindow(View v) { - if (mTreeObserver != null) { - if (!mTreeObserver.isAlive()) mTreeObserver = v.getViewTreeObserver(); - mTreeObserver.removeGlobalOnLayoutListener(this); - } - ((View_HasStateListenerSupport)v).removeOnAttachStateChangeListener(this); - } - - @Override - public void initForMenu(Context context, MenuBuilder menu) { - // Don't need to do anything; we added as a presenter in the constructor. - } - - @Override - public MenuView getMenuView(ViewGroup root) { - throw new UnsupportedOperationException("MenuPopupHelpers manage their own views"); - } - - @Override - public void updateMenuView(boolean cleared) { - if (mAdapter != null) mAdapter.notifyDataSetChanged(); - } - - @Override - public void setCallback(Callback cb) { - mPresenterCallback = cb; - } - - @Override - public boolean onSubMenuSelected(SubMenuBuilder subMenu) { - if (subMenu.hasVisibleItems()) { - MenuPopupHelper subPopup = new MenuPopupHelper(mContext, subMenu, mAnchorView, false); - subPopup.setCallback(mPresenterCallback); - - boolean preserveIconSpacing = false; - final int count = subMenu.size(); - for (int i = 0; i < count; i++) { - MenuItem childItem = subMenu.getItem(i); - if (childItem.isVisible() && childItem.getIcon() != null) { - preserveIconSpacing = true; - break; - } - } - subPopup.setForceShowIcon(preserveIconSpacing); - - if (subPopup.tryShow()) { - if (mPresenterCallback != null) { - mPresenterCallback.onOpenSubMenu(subMenu); - } - return true; - } - } - return false; - } - - @Override - public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) { - // Only care about the (sub)menu we're presenting. - if (menu != mMenu) return; - - dismiss(); - if (mPresenterCallback != null) { - mPresenterCallback.onCloseMenu(menu, allMenusAreClosing); - } - } - - @Override - public boolean flagActionItems() { - return false; - } - - public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item) { - return false; - } - - public boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item) { - return false; - } - - @Override - public int getId() { - return 0; - } - - @Override - public Parcelable onSaveInstanceState() { - return null; - } - - @Override - public void onRestoreInstanceState(Parcelable state) { - } - - private class MenuAdapter extends BaseAdapter { - private MenuBuilder mAdapterMenu; - private int mExpandedIndex = -1; - - public MenuAdapter(MenuBuilder menu) { - mAdapterMenu = menu; - registerDataSetObserver(new ExpandedIndexObserver()); - findExpandedIndex(); - } - - public int getCount() { - ArrayList items = mOverflowOnly ? - mAdapterMenu.getNonActionItems() : mAdapterMenu.getVisibleItems(); - if (mExpandedIndex < 0) { - return items.size(); - } - return items.size() - 1; - } - - public MenuItemImpl getItem(int position) { - ArrayList items = mOverflowOnly ? - mAdapterMenu.getNonActionItems() : mAdapterMenu.getVisibleItems(); - if (mExpandedIndex >= 0 && position >= mExpandedIndex) { - position++; - } - return items.get(position); - } - - public long getItemId(int position) { - // Since a menu item's ID is optional, we'll use the position as an - // ID for the item in the AdapterView - return position; - } - - public View getView(int position, View convertView, ViewGroup parent) { - if (convertView == null) { - convertView = mInflater.inflate(ITEM_LAYOUT, parent, false); - } - - MenuView.ItemView itemView = (MenuView.ItemView) convertView; - if (mForceShowIcon) { - ((ListMenuItemView) convertView).setForceShowIcon(true); - } - itemView.initialize(getItem(position), 0); - return convertView; - } - - void findExpandedIndex() { - final MenuItemImpl expandedItem = mMenu.getExpandedItem(); - if (expandedItem != null) { - final ArrayList items = mMenu.getNonActionItems(); - final int count = items.size(); - for (int i = 0; i < count; i++) { - final MenuItemImpl item = items.get(i); - if (item == expandedItem) { - mExpandedIndex = i; - return; - } - } - } - mExpandedIndex = -1; - } - } - - private class ExpandedIndexObserver extends DataSetObserver { - @Override - public void onChanged() { - mAdapter.findExpandedIndex(); - } - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuPresenter.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuPresenter.java deleted file mode 100644 index c3f35472c..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuPresenter.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (C) 2011 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.actionbarsherlock.internal.view.menu; - -import android.content.Context; -import android.os.Parcelable; -import android.view.ViewGroup; - -/** - * A MenuPresenter is responsible for building views for a Menu object. - * It takes over some responsibility from the old style monolithic MenuBuilder class. - */ -public interface MenuPresenter { - /** - * Called by menu implementation to notify another component of open/close events. - */ - public interface Callback { - /** - * Called when a menu is closing. - * @param menu - * @param allMenusAreClosing - */ - public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing); - - /** - * Called when a submenu opens. Useful for notifying the application - * of menu state so that it does not attempt to hide the action bar - * while a submenu is open or similar. - * - * @param subMenu Submenu currently being opened - * @return true if the Callback will handle presenting the submenu, false if - * the presenter should attempt to do so. - */ - public boolean onOpenSubMenu(MenuBuilder subMenu); - } - - /** - * Initialize this presenter for the given context and menu. - * This method is called by MenuBuilder when a presenter is - * added. See {@link MenuBuilder#addMenuPresenter(MenuPresenter)} - * - * @param context Context for this presenter; used for view creation and resource management - * @param menu Menu to host - */ - public void initForMenu(Context context, MenuBuilder menu); - - /** - * Retrieve a MenuView to display the menu specified in - * {@link #initForMenu(Context, Menu)}. - * - * @param root Intended parent of the MenuView. - * @return A freshly created MenuView. - */ - public MenuView getMenuView(ViewGroup root); - - /** - * Update the menu UI in response to a change. Called by - * MenuBuilder during the normal course of operation. - * - * @param cleared true if the menu was entirely cleared - */ - public void updateMenuView(boolean cleared); - - /** - * Set a callback object that will be notified of menu events - * related to this specific presentation. - * @param cb Callback that will be notified of future events - */ - public void setCallback(Callback cb); - - /** - * Called by Menu implementations to indicate that a submenu item - * has been selected. An active Callback should be notified, and - * if applicable the presenter should present the submenu. - * - * @param subMenu SubMenu being opened - * @return true if the the event was handled, false otherwise. - */ - public boolean onSubMenuSelected(SubMenuBuilder subMenu); - - /** - * Called by Menu implementations to indicate that a menu or submenu is - * closing. Presenter implementations should close the representation - * of the menu indicated as necessary and notify a registered callback. - * - * @param menu Menu or submenu that is closing. - * @param allMenusAreClosing True if all associated menus are closing. - */ - public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing); - - /** - * Called by Menu implementations to flag items that will be shown as actions. - * @return true if this presenter changed the action status of any items. - */ - public boolean flagActionItems(); - - /** - * Called when a menu item with a collapsable action view should expand its action view. - * - * @param menu Menu containing the item to be expanded - * @param item Item to be expanded - * @return true if this presenter expanded the action view, false otherwise. - */ - public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item); - - /** - * Called when a menu item with a collapsable action view should collapse its action view. - * - * @param menu Menu containing the item to be collapsed - * @param item Item to be collapsed - * @return true if this presenter collapsed the action view, false otherwise. - */ - public boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item); - - /** - * Returns an ID for determining how to save/restore instance state. - * @return a valid ID value. - */ - public int getId(); - - /** - * Returns a Parcelable describing the current state of the presenter. - * It will be passed to the {@link #onRestoreInstanceState(Parcelable)} - * method of the presenter sharing the same ID later. - * @return The saved instance state - */ - public Parcelable onSaveInstanceState(); - - /** - * Supplies the previously saved instance state to be restored. - * @param state The previously saved instance state - */ - public void onRestoreInstanceState(Parcelable state); -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuView.java deleted file mode 100644 index 323ba2d88..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuView.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (C) 2006 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.actionbarsherlock.internal.view.menu; - -import android.graphics.drawable.Drawable; - -/** - * Minimal interface for a menu view. {@link #initialize(MenuBuilder)} must be called for the - * menu to be functional. - * - * @hide - */ -public interface MenuView { - /** - * Initializes the menu to the given menu. This should be called after the - * view is inflated. - * - * @param menu The menu that this MenuView should display. - */ - public void initialize(MenuBuilder menu); - - /** - * Returns the default animations to be used for this menu when entering/exiting. - * @return A resource ID for the default animations to be used for this menu. - */ - public int getWindowAnimations(); - - /** - * Minimal interface for a menu item view. {@link #initialize(MenuItemImpl, int)} must be called - * for the item to be functional. - */ - public interface ItemView { - /** - * Initializes with the provided MenuItemData. This should be called after the view is - * inflated. - * @param itemData The item that this ItemView should display. - * @param menuType The type of this menu, one of - * {@link MenuBuilder#TYPE_ICON}, {@link MenuBuilder#TYPE_EXPANDED}, - * {@link MenuBuilder#TYPE_DIALOG}). - */ - public void initialize(MenuItemImpl itemData, int menuType); - - /** - * Gets the item data that this view is displaying. - * @return the item data, or null if there is not one - */ - public MenuItemImpl getItemData(); - - /** - * Sets the title of the item view. - * @param title The title to set. - */ - public void setTitle(CharSequence title); - - /** - * Sets the enabled state of the item view. - * @param enabled Whether the item view should be enabled. - */ - public void setEnabled(boolean enabled); - - /** - * Displays the checkbox for the item view. This does not ensure the item view will be - * checked, for that use {@link #setChecked}. - * @param checkable Whether to display the checkbox or to hide it - */ - public void setCheckable(boolean checkable); - - /** - * Checks the checkbox for the item view. If the checkbox is hidden, it will NOT be - * made visible, call {@link #setCheckable(boolean)} for that. - * @param checked Whether the checkbox should be checked - */ - public void setChecked(boolean checked); - - /** - * Sets the shortcut for the item. - * @param showShortcut Whether a shortcut should be shown(if false, the value of - * shortcutKey should be ignored). - * @param shortcutKey The shortcut key that should be shown on the ItemView. - */ - public void setShortcut(boolean showShortcut, char shortcutKey); - - /** - * Set the icon of this item view. - * @param icon The icon of this item. null to hide the icon. - */ - public void setIcon(Drawable icon); - - /** - * Whether this item view prefers displaying the condensed title rather - * than the normal title. If a condensed title is not available, the - * normal title will be used. - * - * @return Whether this item view prefers displaying the condensed - * title. - */ - public boolean prefersCondensedTitle(); - - /** - * Whether this item view shows an icon. - * - * @return Whether this item view shows an icon. - */ - public boolean showsIcon(); - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuWrapper.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuWrapper.java deleted file mode 100644 index 64fc4aeaa..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuWrapper.java +++ /dev/null @@ -1,180 +0,0 @@ -package com.actionbarsherlock.internal.view.menu; - -import java.util.WeakHashMap; -import android.content.ComponentName; -import android.content.Intent; -import android.view.KeyEvent; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuItem; -import com.actionbarsherlock.view.SubMenu; - -public class MenuWrapper implements Menu { - private final android.view.Menu mNativeMenu; - - private final WeakHashMap mNativeMap = - new WeakHashMap(); - - - public MenuWrapper(android.view.Menu nativeMenu) { - mNativeMenu = nativeMenu; - } - - public android.view.Menu unwrap() { - return mNativeMenu; - } - - private MenuItem addInternal(android.view.MenuItem nativeItem) { - MenuItem item = new MenuItemWrapper(nativeItem); - mNativeMap.put(nativeItem, item); - return item; - } - - @Override - public MenuItem add(CharSequence title) { - return addInternal(mNativeMenu.add(title)); - } - - @Override - public MenuItem add(int titleRes) { - return addInternal(mNativeMenu.add(titleRes)); - } - - @Override - public MenuItem add(int groupId, int itemId, int order, CharSequence title) { - return addInternal(mNativeMenu.add(groupId, itemId, order, title)); - } - - @Override - public MenuItem add(int groupId, int itemId, int order, int titleRes) { - return addInternal(mNativeMenu.add(groupId, itemId, order, titleRes)); - } - - private SubMenu addInternal(android.view.SubMenu nativeSubMenu) { - SubMenu subMenu = new SubMenuWrapper(nativeSubMenu); - android.view.MenuItem nativeItem = nativeSubMenu.getItem(); - MenuItem item = subMenu.getItem(); - mNativeMap.put(nativeItem, item); - return subMenu; - } - - @Override - public SubMenu addSubMenu(CharSequence title) { - return addInternal(mNativeMenu.addSubMenu(title)); - } - - @Override - public SubMenu addSubMenu(int titleRes) { - return addInternal(mNativeMenu.addSubMenu(titleRes)); - } - - @Override - public SubMenu addSubMenu(int groupId, int itemId, int order, CharSequence title) { - return addInternal(mNativeMenu.addSubMenu(groupId, itemId, order, title)); - } - - @Override - public SubMenu addSubMenu(int groupId, int itemId, int order, int titleRes) { - return addInternal(mNativeMenu.addSubMenu(groupId, itemId, order, titleRes)); - } - - @Override - public int addIntentOptions(int groupId, int itemId, int order, ComponentName caller, Intent[] specifics, Intent intent, int flags, MenuItem[] outSpecificItems) { - android.view.MenuItem[] nativeOutItems = new android.view.MenuItem[outSpecificItems.length]; - int result = mNativeMenu.addIntentOptions(groupId, itemId, order, caller, specifics, intent, flags, nativeOutItems); - for (int i = 0, length = outSpecificItems.length; i < length; i++) { - outSpecificItems[i] = new MenuItemWrapper(nativeOutItems[i]); - } - return result; - } - - @Override - public void removeItem(int id) { - mNativeMenu.removeItem(id); - } - - @Override - public void removeGroup(int groupId) { - mNativeMenu.removeGroup(groupId); - } - - @Override - public void clear() { - mNativeMap.clear(); - mNativeMenu.clear(); - } - - @Override - public void setGroupCheckable(int group, boolean checkable, boolean exclusive) { - mNativeMenu.setGroupCheckable(group, checkable, exclusive); - } - - @Override - public void setGroupVisible(int group, boolean visible) { - mNativeMenu.setGroupVisible(group, visible); - } - - @Override - public void setGroupEnabled(int group, boolean enabled) { - mNativeMenu.setGroupEnabled(group, enabled); - } - - @Override - public boolean hasVisibleItems() { - return mNativeMenu.hasVisibleItems(); - } - - @Override - public MenuItem findItem(int id) { - android.view.MenuItem nativeItem = mNativeMenu.findItem(id); - return findItem(nativeItem); - } - - public MenuItem findItem(android.view.MenuItem nativeItem) { - if (nativeItem == null) { - return null; - } - - MenuItem wrapped = mNativeMap.get(nativeItem); - if (wrapped != null) { - return wrapped; - } - - return addInternal(nativeItem); - } - - @Override - public int size() { - return mNativeMenu.size(); - } - - @Override - public MenuItem getItem(int index) { - android.view.MenuItem nativeItem = mNativeMenu.getItem(index); - return findItem(nativeItem); - } - - @Override - public void close() { - mNativeMenu.close(); - } - - @Override - public boolean performShortcut(int keyCode, KeyEvent event, int flags) { - return mNativeMenu.performShortcut(keyCode, event, flags); - } - - @Override - public boolean isShortcutKey(int keyCode, KeyEvent event) { - return mNativeMenu.isShortcutKey(keyCode, event); - } - - @Override - public boolean performIdentifierAction(int id, int flags) { - return mNativeMenu.performIdentifierAction(id, flags); - } - - @Override - public void setQwertyMode(boolean isQwerty) { - mNativeMenu.setQwertyMode(isQwerty); - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/SubMenuBuilder.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/SubMenuBuilder.java deleted file mode 100644 index 6679cf386..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/SubMenuBuilder.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (C) 2006 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.actionbarsherlock.internal.view.menu; - -import android.content.Context; -import android.graphics.drawable.Drawable; -import android.view.View; - -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuItem; -import com.actionbarsherlock.view.SubMenu; - -/** - * The model for a sub menu, which is an extension of the menu. Most methods are proxied to - * the parent menu. - */ -public class SubMenuBuilder extends MenuBuilder implements SubMenu { - private MenuBuilder mParentMenu; - private MenuItemImpl mItem; - - public SubMenuBuilder(Context context, MenuBuilder parentMenu, MenuItemImpl item) { - super(context); - - mParentMenu = parentMenu; - mItem = item; - } - - @Override - public void setQwertyMode(boolean isQwerty) { - mParentMenu.setQwertyMode(isQwerty); - } - - @Override - public boolean isQwertyMode() { - return mParentMenu.isQwertyMode(); - } - - @Override - public void setShortcutsVisible(boolean shortcutsVisible) { - mParentMenu.setShortcutsVisible(shortcutsVisible); - } - - @Override - public boolean isShortcutsVisible() { - return mParentMenu.isShortcutsVisible(); - } - - public Menu getParentMenu() { - return mParentMenu; - } - - public MenuItem getItem() { - return mItem; - } - - @Override - public void setCallback(Callback callback) { - mParentMenu.setCallback(callback); - } - - @Override - public MenuBuilder getRootMenu() { - return mParentMenu; - } - - @Override - boolean dispatchMenuItemSelected(MenuBuilder menu, MenuItem item) { - return super.dispatchMenuItemSelected(menu, item) || - mParentMenu.dispatchMenuItemSelected(menu, item); - } - - public SubMenu setIcon(Drawable icon) { - mItem.setIcon(icon); - return this; - } - - public SubMenu setIcon(int iconRes) { - mItem.setIcon(iconRes); - return this; - } - - public SubMenu setHeaderIcon(Drawable icon) { - return (SubMenu) super.setHeaderIconInt(icon); - } - - public SubMenu setHeaderIcon(int iconRes) { - return (SubMenu) super.setHeaderIconInt(iconRes); - } - - public SubMenu setHeaderTitle(CharSequence title) { - return (SubMenu) super.setHeaderTitleInt(title); - } - - public SubMenu setHeaderTitle(int titleRes) { - return (SubMenu) super.setHeaderTitleInt(titleRes); - } - - public SubMenu setHeaderView(View view) { - return (SubMenu) super.setHeaderViewInt(view); - } - - @Override - public boolean expandItemActionView(MenuItemImpl item) { - return mParentMenu.expandItemActionView(item); - } - - @Override - public boolean collapseItemActionView(MenuItemImpl item) { - return mParentMenu.collapseItemActionView(item); - } - - @Override - public String getActionViewStatesKey() { - final int itemId = mItem != null ? mItem.getItemId() : 0; - if (itemId == 0) { - return null; - } - return super.getActionViewStatesKey() + ":" + itemId; - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/SubMenuWrapper.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/SubMenuWrapper.java deleted file mode 100644 index 7d307acb1..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/SubMenuWrapper.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.actionbarsherlock.internal.view.menu; - -import android.graphics.drawable.Drawable; -import android.view.View; -import com.actionbarsherlock.view.MenuItem; -import com.actionbarsherlock.view.SubMenu; - -public class SubMenuWrapper extends MenuWrapper implements SubMenu { - private final android.view.SubMenu mNativeSubMenu; - private MenuItem mItem = null; - - public SubMenuWrapper(android.view.SubMenu nativeSubMenu) { - super(nativeSubMenu); - mNativeSubMenu = nativeSubMenu; - } - - - @Override - public SubMenu setHeaderTitle(int titleRes) { - mNativeSubMenu.setHeaderTitle(titleRes); - return this; - } - - @Override - public SubMenu setHeaderTitle(CharSequence title) { - mNativeSubMenu.setHeaderTitle(title); - return this; - } - - @Override - public SubMenu setHeaderIcon(int iconRes) { - mNativeSubMenu.setHeaderIcon(iconRes); - return this; - } - - @Override - public SubMenu setHeaderIcon(Drawable icon) { - mNativeSubMenu.setHeaderIcon(icon); - return this; - } - - @Override - public SubMenu setHeaderView(View view) { - mNativeSubMenu.setHeaderView(view); - return this; - } - - @Override - public void clearHeader() { - mNativeSubMenu.clearHeader(); - } - - @Override - public SubMenu setIcon(int iconRes) { - mNativeSubMenu.setIcon(iconRes); - return this; - } - - @Override - public SubMenu setIcon(Drawable icon) { - mNativeSubMenu.setIcon(icon); - return this; - } - - @Override - public MenuItem getItem() { - if (mItem == null) { - mItem = new MenuItemWrapper(mNativeSubMenu.getItem()); - } - return mItem; - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/AbsActionBarView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/AbsActionBarView.java deleted file mode 100644 index 3a4a44675..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/AbsActionBarView.java +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Copyright (C) 2011 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.actionbarsherlock.internal.widget; - -import android.content.Context; -import android.content.res.Configuration; -import android.content.res.TypedArray; -import android.os.Build; -import android.util.AttributeSet; -import android.view.View; -import android.view.animation.DecelerateInterpolator; -import android.view.animation.Interpolator; - -import com.actionbarsherlock.R; -import com.actionbarsherlock.internal.nineoldandroids.animation.Animator; -import com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet; -import com.actionbarsherlock.internal.nineoldandroids.animation.ObjectAnimator; -import com.actionbarsherlock.internal.nineoldandroids.view.NineViewGroup; -import com.actionbarsherlock.internal.view.menu.ActionMenuPresenter; -import com.actionbarsherlock.internal.view.menu.ActionMenuView; - -import static com.actionbarsherlock.internal.ResourcesCompat.getResources_getBoolean; - -public abstract class AbsActionBarView extends NineViewGroup { - protected ActionMenuView mMenuView; - protected ActionMenuPresenter mActionMenuPresenter; - protected ActionBarContainer mSplitView; - protected boolean mSplitActionBar; - protected boolean mSplitWhenNarrow; - protected int mContentHeight; - - final Context mContext; - - protected Animator mVisibilityAnim; - protected final VisibilityAnimListener mVisAnimListener = new VisibilityAnimListener(); - - private static final /*Time*/Interpolator sAlphaInterpolator = new DecelerateInterpolator(); - - private static final int FADE_DURATION = 200; - - public AbsActionBarView(Context context) { - super(context); - mContext = context; - } - - public AbsActionBarView(Context context, AttributeSet attrs) { - super(context, attrs); - mContext = context; - } - - public AbsActionBarView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - mContext = context; - } - - /* - * Must be public so we can dispatch pre-2.2 via ActionBarImpl. - */ - @Override - public void onConfigurationChanged(Configuration newConfig) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) { - super.onConfigurationChanged(newConfig); - } else if (mMenuView != null) { - mMenuView.onConfigurationChanged(newConfig); - } - - // Action bar can change size on configuration changes. - // Reread the desired height from the theme-specified style. - TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.SherlockActionBar, - R.attr.actionBarStyle, 0); - setContentHeight(a.getLayoutDimension(R.styleable.SherlockActionBar_height, 0)); - a.recycle(); - if (mSplitWhenNarrow) { - setSplitActionBar(getResources_getBoolean(getContext(), - R.bool.abs__split_action_bar_is_narrow)); - } - if (mActionMenuPresenter != null) { - mActionMenuPresenter.onConfigurationChanged(newConfig); - } - } - - /** - * Sets whether the bar should be split right now, no questions asked. - * @param split true if the bar should split - */ - public void setSplitActionBar(boolean split) { - mSplitActionBar = split; - } - - /** - * Sets whether the bar should split if we enter a narrow screen configuration. - * @param splitWhenNarrow true if the bar should check to split after a config change - */ - public void setSplitWhenNarrow(boolean splitWhenNarrow) { - mSplitWhenNarrow = splitWhenNarrow; - } - - public void setContentHeight(int height) { - mContentHeight = height; - requestLayout(); - } - - public int getContentHeight() { - return mContentHeight; - } - - public void setSplitView(ActionBarContainer splitView) { - mSplitView = splitView; - } - - /** - * @return Current visibility or if animating, the visibility being animated to. - */ - public int getAnimatedVisibility() { - if (mVisibilityAnim != null) { - return mVisAnimListener.mFinalVisibility; - } - return getVisibility(); - } - - public void animateToVisibility(int visibility) { - if (mVisibilityAnim != null) { - mVisibilityAnim.cancel(); - } - if (visibility == VISIBLE) { - if (getVisibility() != VISIBLE) { - setAlpha(0); - if (mSplitView != null && mMenuView != null) { - mMenuView.setAlpha(0); - } - } - ObjectAnimator anim = ObjectAnimator.ofFloat(this, "alpha", 1); - anim.setDuration(FADE_DURATION); - anim.setInterpolator(sAlphaInterpolator); - if (mSplitView != null && mMenuView != null) { - AnimatorSet set = new AnimatorSet(); - ObjectAnimator splitAnim = ObjectAnimator.ofFloat(mMenuView, "alpha", 1); - splitAnim.setDuration(FADE_DURATION); - set.addListener(mVisAnimListener.withFinalVisibility(visibility)); - set.play(anim).with(splitAnim); - set.start(); - } else { - anim.addListener(mVisAnimListener.withFinalVisibility(visibility)); - anim.start(); - } - } else { - ObjectAnimator anim = ObjectAnimator.ofFloat(this, "alpha", 0); - anim.setDuration(FADE_DURATION); - anim.setInterpolator(sAlphaInterpolator); - if (mSplitView != null && mMenuView != null) { - AnimatorSet set = new AnimatorSet(); - ObjectAnimator splitAnim = ObjectAnimator.ofFloat(mMenuView, "alpha", 0); - splitAnim.setDuration(FADE_DURATION); - set.addListener(mVisAnimListener.withFinalVisibility(visibility)); - set.play(anim).with(splitAnim); - set.start(); - } else { - anim.addListener(mVisAnimListener.withFinalVisibility(visibility)); - anim.start(); - } - } - } - - @Override - public void setVisibility(int visibility) { - if (mVisibilityAnim != null) { - mVisibilityAnim.end(); - } - super.setVisibility(visibility); - } - - public boolean showOverflowMenu() { - if (mActionMenuPresenter != null) { - return mActionMenuPresenter.showOverflowMenu(); - } - return false; - } - - public void postShowOverflowMenu() { - post(new Runnable() { - public void run() { - showOverflowMenu(); - } - }); - } - - public boolean hideOverflowMenu() { - if (mActionMenuPresenter != null) { - return mActionMenuPresenter.hideOverflowMenu(); - } - return false; - } - - public boolean isOverflowMenuShowing() { - if (mActionMenuPresenter != null) { - return mActionMenuPresenter.isOverflowMenuShowing(); - } - return false; - } - - public boolean isOverflowReserved() { - return mActionMenuPresenter != null && mActionMenuPresenter.isOverflowReserved(); - } - - public void dismissPopupMenus() { - if (mActionMenuPresenter != null) { - mActionMenuPresenter.dismissPopupMenus(); - } - } - - protected int measureChildView(View child, int availableWidth, int childSpecHeight, - int spacing) { - child.measure(MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST), - childSpecHeight); - - availableWidth -= child.getMeasuredWidth(); - availableWidth -= spacing; - - return Math.max(0, availableWidth); - } - - protected int positionChild(View child, int x, int y, int contentHeight) { - int childWidth = child.getMeasuredWidth(); - int childHeight = child.getMeasuredHeight(); - int childTop = y + (contentHeight - childHeight) / 2; - - child.layout(x, childTop, x + childWidth, childTop + childHeight); - - return childWidth; - } - - protected int positionChildInverse(View child, int x, int y, int contentHeight) { - int childWidth = child.getMeasuredWidth(); - int childHeight = child.getMeasuredHeight(); - int childTop = y + (contentHeight - childHeight) / 2; - - child.layout(x - childWidth, childTop, x, childTop + childHeight); - - return childWidth; - } - - protected class VisibilityAnimListener implements Animator.AnimatorListener { - private boolean mCanceled = false; - int mFinalVisibility; - - public VisibilityAnimListener withFinalVisibility(int visibility) { - mFinalVisibility = visibility; - return this; - } - - @Override - public void onAnimationStart(Animator animation) { - setVisibility(VISIBLE); - mVisibilityAnim = animation; - mCanceled = false; - } - - @Override - public void onAnimationEnd(Animator animation) { - if (mCanceled) return; - - mVisibilityAnim = null; - setVisibility(mFinalVisibility); - if (mSplitView != null && mMenuView != null) { - mMenuView.setVisibility(mFinalVisibility); - } - } - - @Override - public void onAnimationCancel(Animator animation) { - mCanceled = true; - } - - @Override - public void onAnimationRepeat(Animator animation) { - } - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarContainer.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarContainer.java deleted file mode 100644 index 5e5aa2867..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarContainer.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright (C) 2010 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.actionbarsherlock.internal.widget; - -import android.content.Context; -import android.content.res.TypedArray; -import android.graphics.Canvas; -import android.graphics.drawable.Drawable; -import android.util.AttributeSet; -import android.view.MotionEvent; -import android.view.View; -import android.view.ViewGroup; - -import com.actionbarsherlock.R; -import com.actionbarsherlock.app.ActionBar; -import com.actionbarsherlock.internal.nineoldandroids.widget.NineFrameLayout; - -/** - * This class acts as a container for the action bar view and action mode context views. - * It applies special styles as needed to help handle animated transitions between them. - * @hide - */ -public class ActionBarContainer extends NineFrameLayout { - private boolean mIsTransitioning; - private View mTabContainer; - private ActionBarView mActionBarView; - - private Drawable mBackground; - private Drawable mStackedBackground; - private Drawable mSplitBackground; - private boolean mIsSplit; - private boolean mIsStacked; - - public ActionBarContainer(Context context) { - this(context, null); - } - - public ActionBarContainer(Context context, AttributeSet attrs) { - super(context, attrs); - - setBackgroundDrawable(null); - - TypedArray a = context.obtainStyledAttributes(attrs, - R.styleable.SherlockActionBar); - mBackground = a.getDrawable(R.styleable.SherlockActionBar_background); - mStackedBackground = a.getDrawable( - R.styleable.SherlockActionBar_backgroundStacked); - - if (getId() == R.id.abs__split_action_bar) { - mIsSplit = true; - mSplitBackground = a.getDrawable( - R.styleable.SherlockActionBar_backgroundSplit); - } - a.recycle(); - - setWillNotDraw(mIsSplit ? mSplitBackground == null : - mBackground == null && mStackedBackground == null); - } - - @Override - public void onFinishInflate() { - super.onFinishInflate(); - mActionBarView = (ActionBarView) findViewById(R.id.abs__action_bar); - } - - public void setPrimaryBackground(Drawable bg) { - mBackground = bg; - invalidate(); - } - - public void setStackedBackground(Drawable bg) { - mStackedBackground = bg; - invalidate(); - } - - public void setSplitBackground(Drawable bg) { - mSplitBackground = bg; - invalidate(); - } - - /** - * Set the action bar into a "transitioning" state. While transitioning - * the bar will block focus and touch from all of its descendants. This - * prevents the user from interacting with the bar while it is animating - * in or out. - * - * @param isTransitioning true if the bar is currently transitioning, false otherwise. - */ - public void setTransitioning(boolean isTransitioning) { - mIsTransitioning = isTransitioning; - setDescendantFocusability(isTransitioning ? FOCUS_BLOCK_DESCENDANTS - : FOCUS_AFTER_DESCENDANTS); - } - - @Override - public boolean onInterceptTouchEvent(MotionEvent ev) { - return mIsTransitioning || super.onInterceptTouchEvent(ev); - } - - @Override - public boolean onTouchEvent(MotionEvent ev) { - super.onTouchEvent(ev); - - // An action bar always eats touch events. - return true; - } - - @Override - public boolean onHoverEvent(MotionEvent ev) { - super.onHoverEvent(ev); - - // An action bar always eats hover events. - return true; - } - - public void setTabContainer(ScrollingTabContainerView tabView) { - if (mTabContainer != null) { - removeView(mTabContainer); - } - mTabContainer = tabView; - if (tabView != null) { - addView(tabView); - final ViewGroup.LayoutParams lp = tabView.getLayoutParams(); - lp.width = LayoutParams.MATCH_PARENT; - lp.height = LayoutParams.WRAP_CONTENT; - tabView.setAllowCollapse(false); - } - } - - public View getTabContainer() { - return mTabContainer; - } - - @Override - public void onDraw(Canvas canvas) { - if (getWidth() == 0 || getHeight() == 0) { - return; - } - - if (mIsSplit) { - if (mSplitBackground != null) mSplitBackground.draw(canvas); - } else { - if (mBackground != null) { - mBackground.draw(canvas); - } - if (mStackedBackground != null && mIsStacked) { - mStackedBackground.draw(canvas); - } - } - } - - //This causes the animation reflection to fail on pre-HC platforms - //@Override - //public android.view.ActionMode startActionModeForChild(View child, android.view.ActionMode.Callback callback) { - // // No starting an action mode for an action bar child! (Where would it go?) - // return null; - //} - - @Override - public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - - if (mActionBarView == null) return; - - final LayoutParams lp = (LayoutParams) mActionBarView.getLayoutParams(); - final int actionBarViewHeight = mActionBarView.isCollapsed() ? 0 : - mActionBarView.getMeasuredHeight() + lp.topMargin + lp.bottomMargin; - - if (mTabContainer != null && mTabContainer.getVisibility() != GONE) { - final int mode = MeasureSpec.getMode(heightMeasureSpec); - if (mode == MeasureSpec.AT_MOST) { - final int maxHeight = MeasureSpec.getSize(heightMeasureSpec); - setMeasuredDimension(getMeasuredWidth(), - Math.min(actionBarViewHeight + mTabContainer.getMeasuredHeight(), - maxHeight)); - } - } - } - - @Override - public void onLayout(boolean changed, int l, int t, int r, int b) { - super.onLayout(changed, l, t, r, b); - - final boolean hasTabs = mTabContainer != null && mTabContainer.getVisibility() != GONE; - - if (mTabContainer != null && mTabContainer.getVisibility() != GONE) { - final int containerHeight = getMeasuredHeight(); - final int tabHeight = mTabContainer.getMeasuredHeight(); - - if ((mActionBarView.getDisplayOptions() & ActionBar.DISPLAY_SHOW_HOME) == 0) { - // Not showing home, put tabs on top. - final int count = getChildCount(); - for (int i = 0; i < count; i++) { - final View child = getChildAt(i); - - if (child == mTabContainer) continue; - - if (!mActionBarView.isCollapsed()) { - child.offsetTopAndBottom(tabHeight); - } - } - mTabContainer.layout(l, 0, r, tabHeight); - } else { - mTabContainer.layout(l, containerHeight - tabHeight, r, containerHeight); - } - } - - boolean needsInvalidate = false; - if (mIsSplit) { - if (mSplitBackground != null) { - mSplitBackground.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight()); - needsInvalidate = true; - } - } else { - if (mBackground != null) { - mBackground.setBounds(mActionBarView.getLeft(), mActionBarView.getTop(), - mActionBarView.getRight(), mActionBarView.getBottom()); - needsInvalidate = true; - } - if ((mIsStacked = hasTabs && mStackedBackground != null)) { - mStackedBackground.setBounds(mTabContainer.getLeft(), mTabContainer.getTop(), - mTabContainer.getRight(), mTabContainer.getBottom()); - needsInvalidate = true; - } - } - - if (needsInvalidate) { - invalidate(); - } - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarContextView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarContextView.java deleted file mode 100644 index 9ec250f38..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarContextView.java +++ /dev/null @@ -1,518 +0,0 @@ -/* - * Copyright (C) 2010 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.actionbarsherlock.internal.widget; - -import android.content.Context; -import android.content.res.TypedArray; -import android.graphics.drawable.Drawable; -import android.text.TextUtils; -import android.util.AttributeSet; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.accessibility.AccessibilityEvent; -import android.view.animation.DecelerateInterpolator; -import android.widget.LinearLayout; -import android.widget.TextView; - -import com.actionbarsherlock.R; -import com.actionbarsherlock.internal.nineoldandroids.animation.Animator; -import com.actionbarsherlock.internal.nineoldandroids.animation.Animator.AnimatorListener; -import com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet; -import com.actionbarsherlock.internal.nineoldandroids.animation.ObjectAnimator; -import com.actionbarsherlock.internal.nineoldandroids.view.animation.AnimatorProxy; -import com.actionbarsherlock.internal.nineoldandroids.widget.NineLinearLayout; -import com.actionbarsherlock.internal.view.menu.ActionMenuPresenter; -import com.actionbarsherlock.internal.view.menu.ActionMenuView; -import com.actionbarsherlock.internal.view.menu.MenuBuilder; -import com.actionbarsherlock.view.ActionMode; - -/** - * @hide - */ -public class ActionBarContextView extends AbsActionBarView implements AnimatorListener { - //UNUSED private static final String TAG = "ActionBarContextView"; - - private CharSequence mTitle; - private CharSequence mSubtitle; - - private NineLinearLayout mClose; - private View mCustomView; - private LinearLayout mTitleLayout; - private TextView mTitleView; - private TextView mSubtitleView; - private int mTitleStyleRes; - private int mSubtitleStyleRes; - private Drawable mSplitBackground; - - private Animator mCurrentAnimation; - private boolean mAnimateInOnLayout; - private int mAnimationMode; - - private static final int ANIMATE_IDLE = 0; - private static final int ANIMATE_IN = 1; - private static final int ANIMATE_OUT = 2; - - public ActionBarContextView(Context context) { - this(context, null); - } - - public ActionBarContextView(Context context, AttributeSet attrs) { - this(context, attrs, R.attr.actionModeStyle); - } - - public ActionBarContextView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - - TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockActionMode, defStyle, 0); - setBackgroundDrawable(a.getDrawable( - R.styleable.SherlockActionMode_background)); - mTitleStyleRes = a.getResourceId( - R.styleable.SherlockActionMode_titleTextStyle, 0); - mSubtitleStyleRes = a.getResourceId( - R.styleable.SherlockActionMode_subtitleTextStyle, 0); - - mContentHeight = a.getLayoutDimension( - R.styleable.SherlockActionMode_height, 0); - - mSplitBackground = a.getDrawable( - R.styleable.SherlockActionMode_backgroundSplit); - - a.recycle(); - } - - @Override - public void onDetachedFromWindow() { - super.onDetachedFromWindow(); - if (mActionMenuPresenter != null) { - mActionMenuPresenter.hideOverflowMenu(); - mActionMenuPresenter.hideSubMenus(); - } - } - - @Override - public void setSplitActionBar(boolean split) { - if (mSplitActionBar != split) { - if (mActionMenuPresenter != null) { - // Mode is already active; move everything over and adjust the menu itself. - final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, - LayoutParams.MATCH_PARENT); - if (!split) { - mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this); - mMenuView.setBackgroundDrawable(null); - final ViewGroup oldParent = (ViewGroup) mMenuView.getParent(); - if (oldParent != null) oldParent.removeView(mMenuView); - addView(mMenuView, layoutParams); - } else { - // Allow full screen width in split mode. - mActionMenuPresenter.setWidthLimit( - getContext().getResources().getDisplayMetrics().widthPixels, true); - // No limit to the item count; use whatever will fit. - mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE); - // Span the whole width - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = mContentHeight; - mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this); - mMenuView.setBackgroundDrawable(mSplitBackground); - final ViewGroup oldParent = (ViewGroup) mMenuView.getParent(); - if (oldParent != null) oldParent.removeView(mMenuView); - mSplitView.addView(mMenuView, layoutParams); - } - } - super.setSplitActionBar(split); - } - } - - public void setContentHeight(int height) { - mContentHeight = height; - } - - public void setCustomView(View view) { - if (mCustomView != null) { - removeView(mCustomView); - } - mCustomView = view; - if (mTitleLayout != null) { - removeView(mTitleLayout); - mTitleLayout = null; - } - if (view != null) { - addView(view); - } - requestLayout(); - } - - public void setTitle(CharSequence title) { - mTitle = title; - initTitle(); - } - - public void setSubtitle(CharSequence subtitle) { - mSubtitle = subtitle; - initTitle(); - } - - public CharSequence getTitle() { - return mTitle; - } - - public CharSequence getSubtitle() { - return mSubtitle; - } - - private void initTitle() { - if (mTitleLayout == null) { - LayoutInflater inflater = LayoutInflater.from(getContext()); - inflater.inflate(R.layout.abs__action_bar_title_item, this); - mTitleLayout = (LinearLayout) getChildAt(getChildCount() - 1); - mTitleView = (TextView) mTitleLayout.findViewById(R.id.abs__action_bar_title); - mSubtitleView = (TextView) mTitleLayout.findViewById(R.id.abs__action_bar_subtitle); - if (mTitleStyleRes != 0) { - mTitleView.setTextAppearance(mContext, mTitleStyleRes); - } - if (mSubtitleStyleRes != 0) { - mSubtitleView.setTextAppearance(mContext, mSubtitleStyleRes); - } - } - - mTitleView.setText(mTitle); - mSubtitleView.setText(mSubtitle); - - final boolean hasTitle = !TextUtils.isEmpty(mTitle); - final boolean hasSubtitle = !TextUtils.isEmpty(mSubtitle); - mSubtitleView.setVisibility(hasSubtitle ? VISIBLE : GONE); - mTitleLayout.setVisibility(hasTitle || hasSubtitle ? VISIBLE : GONE); - if (mTitleLayout.getParent() == null) { - addView(mTitleLayout); - } - } - - public void initForMode(final ActionMode mode) { - if (mClose == null) { - LayoutInflater inflater = LayoutInflater.from(mContext); - mClose = (NineLinearLayout)inflater.inflate(R.layout.abs__action_mode_close_item, this, false); - addView(mClose); - } else if (mClose.getParent() == null) { - addView(mClose); - } - - View closeButton = mClose.findViewById(R.id.abs__action_mode_close_button); - closeButton.setOnClickListener(new OnClickListener() { - public void onClick(View v) { - mode.finish(); - } - }); - - final MenuBuilder menu = (MenuBuilder) mode.getMenu(); - if (mActionMenuPresenter != null) { - mActionMenuPresenter.dismissPopupMenus(); - } - mActionMenuPresenter = new ActionMenuPresenter(mContext); - mActionMenuPresenter.setReserveOverflow(true); - - final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, - LayoutParams.MATCH_PARENT); - if (!mSplitActionBar) { - menu.addMenuPresenter(mActionMenuPresenter); - mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this); - mMenuView.setBackgroundDrawable(null); - addView(mMenuView, layoutParams); - } else { - // Allow full screen width in split mode. - mActionMenuPresenter.setWidthLimit( - getContext().getResources().getDisplayMetrics().widthPixels, true); - // No limit to the item count; use whatever will fit. - mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE); - // Span the whole width - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = mContentHeight; - menu.addMenuPresenter(mActionMenuPresenter); - mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this); - mMenuView.setBackgroundDrawable(mSplitBackground); - mSplitView.addView(mMenuView, layoutParams); - } - - mAnimateInOnLayout = true; - } - - public void closeMode() { - if (mAnimationMode == ANIMATE_OUT) { - // Called again during close; just finish what we were doing. - return; - } - if (mClose == null) { - killMode(); - return; - } - - finishAnimation(); - mAnimationMode = ANIMATE_OUT; - mCurrentAnimation = makeOutAnimation(); - mCurrentAnimation.start(); - } - - private void finishAnimation() { - final Animator a = mCurrentAnimation; - if (a != null) { - mCurrentAnimation = null; - a.end(); - } - } - - public void killMode() { - finishAnimation(); - removeAllViews(); - if (mSplitView != null) { - mSplitView.removeView(mMenuView); - } - mCustomView = null; - mMenuView = null; - mAnimateInOnLayout = false; - } - - @Override - public boolean showOverflowMenu() { - if (mActionMenuPresenter != null) { - return mActionMenuPresenter.showOverflowMenu(); - } - return false; - } - - @Override - public boolean hideOverflowMenu() { - if (mActionMenuPresenter != null) { - return mActionMenuPresenter.hideOverflowMenu(); - } - return false; - } - - @Override - public boolean isOverflowMenuShowing() { - if (mActionMenuPresenter != null) { - return mActionMenuPresenter.isOverflowMenuShowing(); - } - return false; - } - - @Override - protected ViewGroup.LayoutParams generateDefaultLayoutParams() { - // Used by custom views if they don't supply layout params. Everything else - // added to an ActionBarContextView should have them already. - return new MarginLayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); - } - - @Override - public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs) { - return new MarginLayoutParams(getContext(), attrs); - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - final int widthMode = MeasureSpec.getMode(widthMeasureSpec); - if (widthMode != MeasureSpec.EXACTLY) { - throw new IllegalStateException(getClass().getSimpleName() + " can only be used " + - "with android:layout_width=\"match_parent\" (or fill_parent)"); - } - - final int heightMode = MeasureSpec.getMode(heightMeasureSpec); - if (heightMode == MeasureSpec.UNSPECIFIED) { - throw new IllegalStateException(getClass().getSimpleName() + " can only be used " + - "with android:layout_height=\"wrap_content\""); - } - - final int contentWidth = MeasureSpec.getSize(widthMeasureSpec); - - int maxHeight = mContentHeight > 0 ? - mContentHeight : MeasureSpec.getSize(heightMeasureSpec); - - final int verticalPadding = getPaddingTop() + getPaddingBottom(); - int availableWidth = contentWidth - getPaddingLeft() - getPaddingRight(); - final int height = maxHeight - verticalPadding; - final int childSpecHeight = MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST); - - if (mClose != null) { - availableWidth = measureChildView(mClose, availableWidth, childSpecHeight, 0); - MarginLayoutParams lp = (MarginLayoutParams) mClose.getLayoutParams(); - availableWidth -= lp.leftMargin + lp.rightMargin; - } - - if (mMenuView != null && mMenuView.getParent() == this) { - availableWidth = measureChildView(mMenuView, availableWidth, - childSpecHeight, 0); - } - - if (mTitleLayout != null && mCustomView == null) { - availableWidth = measureChildView(mTitleLayout, availableWidth, childSpecHeight, 0); - } - - if (mCustomView != null) { - ViewGroup.LayoutParams lp = mCustomView.getLayoutParams(); - final int customWidthMode = lp.width != LayoutParams.WRAP_CONTENT ? - MeasureSpec.EXACTLY : MeasureSpec.AT_MOST; - final int customWidth = lp.width >= 0 ? - Math.min(lp.width, availableWidth) : availableWidth; - final int customHeightMode = lp.height != LayoutParams.WRAP_CONTENT ? - MeasureSpec.EXACTLY : MeasureSpec.AT_MOST; - final int customHeight = lp.height >= 0 ? - Math.min(lp.height, height) : height; - mCustomView.measure(MeasureSpec.makeMeasureSpec(customWidth, customWidthMode), - MeasureSpec.makeMeasureSpec(customHeight, customHeightMode)); - } - - if (mContentHeight <= 0) { - int measuredHeight = 0; - final int count = getChildCount(); - for (int i = 0; i < count; i++) { - View v = getChildAt(i); - int paddedViewHeight = v.getMeasuredHeight() + verticalPadding; - if (paddedViewHeight > measuredHeight) { - measuredHeight = paddedViewHeight; - } - } - setMeasuredDimension(contentWidth, measuredHeight); - } else { - setMeasuredDimension(contentWidth, maxHeight); - } - } - - private Animator makeInAnimation() { - mClose.setTranslationX(-mClose.getWidth() - - ((MarginLayoutParams) mClose.getLayoutParams()).leftMargin); - ObjectAnimator buttonAnimator = ObjectAnimator.ofFloat(mClose, "translationX", 0); - buttonAnimator.setDuration(200); - buttonAnimator.addListener(this); - buttonAnimator.setInterpolator(new DecelerateInterpolator()); - - AnimatorSet set = new AnimatorSet(); - AnimatorSet.Builder b = set.play(buttonAnimator); - - if (mMenuView != null) { - final int count = mMenuView.getChildCount(); - if (count > 0) { - for (int i = count - 1, j = 0; i >= 0; i--, j++) { - AnimatorProxy child = AnimatorProxy.wrap(mMenuView.getChildAt(i)); - child.setScaleY(0); - ObjectAnimator a = ObjectAnimator.ofFloat(child, "scaleY", 0, 1); - a.setDuration(100); - a.setStartDelay(j * 70); - b.with(a); - } - } - } - - return set; - } - - private Animator makeOutAnimation() { - ObjectAnimator buttonAnimator = ObjectAnimator.ofFloat(mClose, "translationX", - -mClose.getWidth() - ((MarginLayoutParams) mClose.getLayoutParams()).leftMargin); - buttonAnimator.setDuration(200); - buttonAnimator.addListener(this); - buttonAnimator.setInterpolator(new DecelerateInterpolator()); - - AnimatorSet set = new AnimatorSet(); - AnimatorSet.Builder b = set.play(buttonAnimator); - - if (mMenuView != null) { - final int count = mMenuView.getChildCount(); - if (count > 0) { - for (int i = 0; i < 0; i++) { - AnimatorProxy child = AnimatorProxy.wrap(mMenuView.getChildAt(i)); - child.setScaleY(0); - ObjectAnimator a = ObjectAnimator.ofFloat(child, "scaleY", 0); - a.setDuration(100); - a.setStartDelay(i * 70); - b.with(a); - } - } - } - - return set; - } - - @Override - protected void onLayout(boolean changed, int l, int t, int r, int b) { - int x = getPaddingLeft(); - final int y = getPaddingTop(); - final int contentHeight = b - t - getPaddingTop() - getPaddingBottom(); - - if (mClose != null && mClose.getVisibility() != GONE) { - MarginLayoutParams lp = (MarginLayoutParams) mClose.getLayoutParams(); - x += lp.leftMargin; - x += positionChild(mClose, x, y, contentHeight); - x += lp.rightMargin; - - if (mAnimateInOnLayout) { - mAnimationMode = ANIMATE_IN; - mCurrentAnimation = makeInAnimation(); - mCurrentAnimation.start(); - mAnimateInOnLayout = false; - } - } - - if (mTitleLayout != null && mCustomView == null) { - x += positionChild(mTitleLayout, x, y, contentHeight); - } - - if (mCustomView != null) { - x += positionChild(mCustomView, x, y, contentHeight); - } - - x = r - l - getPaddingRight(); - - if (mMenuView != null) { - x -= positionChildInverse(mMenuView, x, y, contentHeight); - } - } - - @Override - public void onAnimationStart(Animator animation) { - } - - @Override - public void onAnimationEnd(Animator animation) { - if (mAnimationMode == ANIMATE_OUT) { - killMode(); - } - mAnimationMode = ANIMATE_IDLE; - } - - @Override - public void onAnimationCancel(Animator animation) { - } - - @Override - public void onAnimationRepeat(Animator animation) { - } - - @Override - public boolean shouldDelayChildPressedState() { - return false; - } - - @Override - public void onInitializeAccessibilityEvent(AccessibilityEvent event) { - if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { - // Action mode started - //TODO event.setSource(this); - event.setClassName(getClass().getName()); - event.setPackageName(getContext().getPackageName()); - event.setContentDescription(mTitle); - } else { - //TODO super.onInitializeAccessibilityEvent(event); - } - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarView.java deleted file mode 100644 index 4636de17f..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarView.java +++ /dev/null @@ -1,1548 +0,0 @@ -/* - * Copyright (C) 2010 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.actionbarsherlock.internal.widget; - -import org.xmlpull.v1.XmlPullParser; -import android.app.Activity; -import android.content.Context; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageManager; -import android.content.pm.PackageManager.NameNotFoundException; -import android.content.res.AssetManager; -import android.content.res.Configuration; -import android.content.res.TypedArray; -import android.content.res.XmlResourceParser; -import android.graphics.drawable.Drawable; -import android.os.Build; -import android.os.Parcel; -import android.os.Parcelable; -import android.text.TextUtils; -import android.util.AttributeSet; -import android.util.Log; -import android.view.Gravity; -import android.view.LayoutInflater; -import android.view.MotionEvent; -import android.view.View; -import android.view.ViewGroup; -import android.view.ViewParent; -import android.view.accessibility.AccessibilityEvent; -import android.widget.FrameLayout; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.SpinnerAdapter; -import android.widget.TextView; - -import com.actionbarsherlock.R; -import com.actionbarsherlock.app.ActionBar; -import com.actionbarsherlock.app.ActionBar.OnNavigationListener; -import com.actionbarsherlock.internal.ActionBarSherlockCompat; -import com.actionbarsherlock.internal.view.menu.ActionMenuItem; -import com.actionbarsherlock.internal.view.menu.ActionMenuPresenter; -import com.actionbarsherlock.internal.view.menu.ActionMenuView; -import com.actionbarsherlock.internal.view.menu.MenuBuilder; -import com.actionbarsherlock.internal.view.menu.MenuItemImpl; -import com.actionbarsherlock.internal.view.menu.MenuPresenter; -import com.actionbarsherlock.internal.view.menu.MenuView; -import com.actionbarsherlock.internal.view.menu.SubMenuBuilder; -import com.actionbarsherlock.view.CollapsibleActionView; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuItem; -import com.actionbarsherlock.view.Window; - -import static com.actionbarsherlock.internal.ResourcesCompat.getResources_getBoolean; - -/** - * @hide - */ -public class ActionBarView extends AbsActionBarView { - private static final String TAG = "ActionBarView"; - private static final boolean DEBUG = false; - - /** - * Display options applied by default - */ - public static final int DISPLAY_DEFAULT = 0; - - /** - * Display options that require re-layout as opposed to a simple invalidate - */ - private static final int DISPLAY_RELAYOUT_MASK = - ActionBar.DISPLAY_SHOW_HOME | - ActionBar.DISPLAY_USE_LOGO | - ActionBar.DISPLAY_HOME_AS_UP | - ActionBar.DISPLAY_SHOW_CUSTOM | - ActionBar.DISPLAY_SHOW_TITLE; - - private static final int DEFAULT_CUSTOM_GRAVITY = Gravity.LEFT | Gravity.CENTER_VERTICAL; - - private int mNavigationMode; - private int mDisplayOptions = -1; - private CharSequence mTitle; - private CharSequence mSubtitle; - private Drawable mIcon; - private Drawable mLogo; - - private HomeView mHomeLayout; - private HomeView mExpandedHomeLayout; - private LinearLayout mTitleLayout; - private TextView mTitleView; - private TextView mSubtitleView; - private View mTitleUpView; - - private IcsSpinner mSpinner; - private IcsLinearLayout mListNavLayout; - private ScrollingTabContainerView mTabScrollView; - private View mCustomNavView; - private IcsProgressBar mProgressView; - private IcsProgressBar mIndeterminateProgressView; - - private int mProgressBarPadding; - private int mItemPadding; - - private int mTitleStyleRes; - private int mSubtitleStyleRes; - private int mProgressStyle; - private int mIndeterminateProgressStyle; - - private boolean mUserTitle; - private boolean mIncludeTabs; - private boolean mIsCollapsable; - private boolean mIsCollapsed; - - private MenuBuilder mOptionsMenu; - - private ActionBarContextView mContextView; - - private ActionMenuItem mLogoNavItem; - - private SpinnerAdapter mSpinnerAdapter; - private OnNavigationListener mCallback; - - //UNUSED private Runnable mTabSelector; - - private ExpandedActionViewMenuPresenter mExpandedMenuPresenter; - View mExpandedActionView; - - Window.Callback mWindowCallback; - - @SuppressWarnings("rawtypes") - private final IcsAdapterView.OnItemSelectedListener mNavItemSelectedListener = - new IcsAdapterView.OnItemSelectedListener() { - public void onItemSelected(IcsAdapterView parent, View view, int position, long id) { - if (mCallback != null) { - mCallback.onNavigationItemSelected(position, id); - } - } - public void onNothingSelected(IcsAdapterView parent) { - // Do nothing - } - }; - - private final OnClickListener mExpandedActionViewUpListener = new OnClickListener() { - @Override - public void onClick(View v) { - final MenuItemImpl item = mExpandedMenuPresenter.mCurrentExpandedItem; - if (item != null) { - item.collapseActionView(); - } - } - }; - - private final OnClickListener mUpClickListener = new OnClickListener() { - public void onClick(View v) { - mWindowCallback.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, mLogoNavItem); - } - }; - - public ActionBarView(Context context, AttributeSet attrs) { - super(context, attrs); - - // Background is always provided by the container. - setBackgroundResource(0); - - TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockActionBar, - R.attr.actionBarStyle, 0); - - ApplicationInfo appInfo = context.getApplicationInfo(); - PackageManager pm = context.getPackageManager(); - mNavigationMode = a.getInt(R.styleable.SherlockActionBar_navigationMode, - ActionBar.NAVIGATION_MODE_STANDARD); - mTitle = a.getText(R.styleable.SherlockActionBar_title); - mSubtitle = a.getText(R.styleable.SherlockActionBar_subtitle); - - mLogo = a.getDrawable(R.styleable.SherlockActionBar_logo); - if (mLogo == null) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { - if (context instanceof Activity) { - //Even though native methods existed in API 9 and 10 they don't work - //so just parse the manifest to look for the logo pre-Honeycomb - final int resId = loadLogoFromManifest((Activity) context); - if (resId != 0) { - mLogo = context.getResources().getDrawable(resId); - } - } - } else { - if (context instanceof Activity) { - try { - mLogo = pm.getActivityLogo(((Activity) context).getComponentName()); - } catch (NameNotFoundException e) { - Log.e(TAG, "Activity component name not found!", e); - } - } - if (mLogo == null) { - mLogo = appInfo.loadLogo(pm); - } - } - } - - mIcon = a.getDrawable(R.styleable.SherlockActionBar_icon); - if (mIcon == null) { - if (context instanceof Activity) { - try { - mIcon = pm.getActivityIcon(((Activity) context).getComponentName()); - } catch (NameNotFoundException e) { - Log.e(TAG, "Activity component name not found!", e); - } - } - if (mIcon == null) { - mIcon = appInfo.loadIcon(pm); - } - } - - final LayoutInflater inflater = LayoutInflater.from(context); - - final int homeResId = a.getResourceId( - R.styleable.SherlockActionBar_homeLayout, - R.layout.abs__action_bar_home); - - mHomeLayout = (HomeView) inflater.inflate(homeResId, this, false); - - mExpandedHomeLayout = (HomeView) inflater.inflate(homeResId, this, false); - mExpandedHomeLayout.setUp(true); - mExpandedHomeLayout.setOnClickListener(mExpandedActionViewUpListener); - mExpandedHomeLayout.setContentDescription(getResources().getText( - R.string.abs__action_bar_up_description)); - - mTitleStyleRes = a.getResourceId(R.styleable.SherlockActionBar_titleTextStyle, 0); - mSubtitleStyleRes = a.getResourceId(R.styleable.SherlockActionBar_subtitleTextStyle, 0); - mProgressStyle = a.getResourceId(R.styleable.SherlockActionBar_progressBarStyle, 0); - mIndeterminateProgressStyle = a.getResourceId( - R.styleable.SherlockActionBar_indeterminateProgressStyle, 0); - - mProgressBarPadding = a.getDimensionPixelOffset(R.styleable.SherlockActionBar_progressBarPadding, 0); - mItemPadding = a.getDimensionPixelOffset(R.styleable.SherlockActionBar_itemPadding, 0); - - setDisplayOptions(a.getInt(R.styleable.SherlockActionBar_displayOptions, DISPLAY_DEFAULT)); - - final int customNavId = a.getResourceId(R.styleable.SherlockActionBar_customNavigationLayout, 0); - if (customNavId != 0) { - mCustomNavView = inflater.inflate(customNavId, this, false); - mNavigationMode = ActionBar.NAVIGATION_MODE_STANDARD; - setDisplayOptions(mDisplayOptions | ActionBar.DISPLAY_SHOW_CUSTOM); - } - - mContentHeight = a.getLayoutDimension(R.styleable.SherlockActionBar_height, 0); - - a.recycle(); - - mLogoNavItem = new ActionMenuItem(context, 0, android.R.id.home, 0, 0, mTitle); - mHomeLayout.setOnClickListener(mUpClickListener); - mHomeLayout.setClickable(true); - mHomeLayout.setFocusable(true); - } - - /** - * Attempt to programmatically load the logo from the manifest file of an - * activity by using an XML pull parser. This should allow us to read the - * logo attribute regardless of the platform it is being run on. - * - * @param activity Activity instance. - * @return Logo resource ID. - */ - private static int loadLogoFromManifest(Activity activity) { - int logo = 0; - try { - final String thisPackage = activity.getClass().getName(); - if (DEBUG) Log.i(TAG, "Parsing AndroidManifest.xml for " + thisPackage); - - final String packageName = activity.getApplicationInfo().packageName; - final AssetManager am = activity.createPackageContext(packageName, 0).getAssets(); - final XmlResourceParser xml = am.openXmlResourceParser("AndroidManifest.xml"); - - int eventType = xml.getEventType(); - while (eventType != XmlPullParser.END_DOCUMENT) { - if (eventType == XmlPullParser.START_TAG) { - String name = xml.getName(); - - if ("application".equals(name)) { - //Check if the has the attribute - if (DEBUG) Log.d(TAG, "Got "); - - for (int i = xml.getAttributeCount() - 1; i >= 0; i--) { - if (DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i)); - - if ("logo".equals(xml.getAttributeName(i))) { - logo = xml.getAttributeResourceValue(i, 0); - break; //out of for loop - } - } - } else if ("activity".equals(name)) { - //Check if the is us and has the attribute - if (DEBUG) Log.d(TAG, "Got "); - Integer activityLogo = null; - String activityPackage = null; - boolean isOurActivity = false; - - for (int i = xml.getAttributeCount() - 1; i >= 0; i--) { - if (DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i)); - - //We need both uiOptions and name attributes - String attrName = xml.getAttributeName(i); - if ("logo".equals(attrName)) { - activityLogo = xml.getAttributeResourceValue(i, 0); - } else if ("name".equals(attrName)) { - activityPackage = ActionBarSherlockCompat.cleanActivityName(packageName, xml.getAttributeValue(i)); - if (!thisPackage.equals(activityPackage)) { - break; //on to the next - } - isOurActivity = true; - } - - //Make sure we have both attributes before processing - if ((activityLogo != null) && (activityPackage != null)) { - //Our activity, logo specified, override with our value - logo = activityLogo.intValue(); - } - } - if (isOurActivity) { - //If we matched our activity but it had no logo don't - //do any more processing of the manifest - break; - } - } - } - eventType = xml.nextToken(); - } - } catch (Exception e) { - e.printStackTrace(); - } - if (DEBUG) Log.i(TAG, "Returning " + Integer.toHexString(logo)); - return logo; - } - - /* - * Must be public so we can dispatch pre-2.2 via ActionBarImpl. - */ - @Override - public void onConfigurationChanged(Configuration newConfig) { - super.onConfigurationChanged(newConfig); - - mTitleView = null; - mSubtitleView = null; - mTitleUpView = null; - if (mTitleLayout != null && mTitleLayout.getParent() == this) { - removeView(mTitleLayout); - } - mTitleLayout = null; - if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0) { - initTitle(); - } - - if (mTabScrollView != null && mIncludeTabs) { - ViewGroup.LayoutParams lp = mTabScrollView.getLayoutParams(); - if (lp != null) { - lp.width = LayoutParams.WRAP_CONTENT; - lp.height = LayoutParams.MATCH_PARENT; - } - mTabScrollView.setAllowCollapse(true); - } - } - - /** - * Set the window callback used to invoke menu items; used for dispatching home button presses. - * @param cb Window callback to dispatch to - */ - public void setWindowCallback(Window.Callback cb) { - mWindowCallback = cb; - } - - @Override - public void onDetachedFromWindow() { - super.onDetachedFromWindow(); - //UNUSED removeCallbacks(mTabSelector); - if (mActionMenuPresenter != null) { - mActionMenuPresenter.hideOverflowMenu(); - mActionMenuPresenter.hideSubMenus(); - } - } - - @Override - public boolean shouldDelayChildPressedState() { - return false; - } - - public void initProgress() { - mProgressView = new IcsProgressBar(mContext, null, 0, mProgressStyle); - mProgressView.setId(R.id.abs__progress_horizontal); - mProgressView.setMax(10000); - addView(mProgressView); - } - - public void initIndeterminateProgress() { - mIndeterminateProgressView = new IcsProgressBar(mContext, null, 0, mIndeterminateProgressStyle); - mIndeterminateProgressView.setId(R.id.abs__progress_circular); - addView(mIndeterminateProgressView); - } - - @Override - public void setSplitActionBar(boolean splitActionBar) { - if (mSplitActionBar != splitActionBar) { - if (mMenuView != null) { - final ViewGroup oldParent = (ViewGroup) mMenuView.getParent(); - if (oldParent != null) { - oldParent.removeView(mMenuView); - } - if (splitActionBar) { - if (mSplitView != null) { - mSplitView.addView(mMenuView); - } - } else { - addView(mMenuView); - } - } - if (mSplitView != null) { - mSplitView.setVisibility(splitActionBar ? VISIBLE : GONE); - } - super.setSplitActionBar(splitActionBar); - } - } - - public boolean isSplitActionBar() { - return mSplitActionBar; - } - - public boolean hasEmbeddedTabs() { - return mIncludeTabs; - } - - public void setEmbeddedTabView(ScrollingTabContainerView tabs) { - if (mTabScrollView != null) { - removeView(mTabScrollView); - } - mTabScrollView = tabs; - mIncludeTabs = tabs != null; - if (mIncludeTabs && mNavigationMode == ActionBar.NAVIGATION_MODE_TABS) { - addView(mTabScrollView); - ViewGroup.LayoutParams lp = mTabScrollView.getLayoutParams(); - lp.width = LayoutParams.WRAP_CONTENT; - lp.height = LayoutParams.MATCH_PARENT; - tabs.setAllowCollapse(true); - } - } - - public void setCallback(OnNavigationListener callback) { - mCallback = callback; - } - - public void setMenu(Menu menu, MenuPresenter.Callback cb) { - if (menu == mOptionsMenu) return; - - if (mOptionsMenu != null) { - mOptionsMenu.removeMenuPresenter(mActionMenuPresenter); - mOptionsMenu.removeMenuPresenter(mExpandedMenuPresenter); - } - - MenuBuilder builder = (MenuBuilder) menu; - mOptionsMenu = builder; - if (mMenuView != null) { - final ViewGroup oldParent = (ViewGroup) mMenuView.getParent(); - if (oldParent != null) { - oldParent.removeView(mMenuView); - } - } - if (mActionMenuPresenter == null) { - mActionMenuPresenter = new ActionMenuPresenter(mContext); - mActionMenuPresenter.setCallback(cb); - mActionMenuPresenter.setId(R.id.abs__action_menu_presenter); - mExpandedMenuPresenter = new ExpandedActionViewMenuPresenter(); - } - - ActionMenuView menuView; - final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, - LayoutParams.MATCH_PARENT); - if (!mSplitActionBar) { - mActionMenuPresenter.setExpandedActionViewsExclusive( - getResources_getBoolean(getContext(), - R.bool.abs__action_bar_expanded_action_views_exclusive)); - configPresenters(builder); - menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this); - final ViewGroup oldParent = (ViewGroup) menuView.getParent(); - if (oldParent != null && oldParent != this) { - oldParent.removeView(menuView); - } - addView(menuView, layoutParams); - } else { - mActionMenuPresenter.setExpandedActionViewsExclusive(false); - // Allow full screen width in split mode. - mActionMenuPresenter.setWidthLimit( - getContext().getResources().getDisplayMetrics().widthPixels, true); - // No limit to the item count; use whatever will fit. - mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE); - // Span the whole width - layoutParams.width = LayoutParams.MATCH_PARENT; - configPresenters(builder); - menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this); - if (mSplitView != null) { - final ViewGroup oldParent = (ViewGroup) menuView.getParent(); - if (oldParent != null && oldParent != mSplitView) { - oldParent.removeView(menuView); - } - menuView.setVisibility(getAnimatedVisibility()); - mSplitView.addView(menuView, layoutParams); - } else { - // We'll add this later if we missed it this time. - menuView.setLayoutParams(layoutParams); - } - } - mMenuView = menuView; - } - - private void configPresenters(MenuBuilder builder) { - if (builder != null) { - builder.addMenuPresenter(mActionMenuPresenter); - builder.addMenuPresenter(mExpandedMenuPresenter); - } else { - mActionMenuPresenter.initForMenu(mContext, null); - mExpandedMenuPresenter.initForMenu(mContext, null); - mActionMenuPresenter.updateMenuView(true); - mExpandedMenuPresenter.updateMenuView(true); - } - } - - public boolean hasExpandedActionView() { - return mExpandedMenuPresenter != null && - mExpandedMenuPresenter.mCurrentExpandedItem != null; - } - - public void collapseActionView() { - final MenuItemImpl item = mExpandedMenuPresenter == null ? null : - mExpandedMenuPresenter.mCurrentExpandedItem; - if (item != null) { - item.collapseActionView(); - } - } - - public void setCustomNavigationView(View view) { - final boolean showCustom = (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0; - if (mCustomNavView != null && showCustom) { - removeView(mCustomNavView); - } - mCustomNavView = view; - if (mCustomNavView != null && showCustom) { - addView(mCustomNavView); - } - } - - public CharSequence getTitle() { - return mTitle; - } - - /** - * Set the action bar title. This will always replace or override window titles. - * @param title Title to set - * - * @see #setWindowTitle(CharSequence) - */ - public void setTitle(CharSequence title) { - mUserTitle = true; - setTitleImpl(title); - } - - /** - * Set the window title. A window title will always be replaced or overridden by a user title. - * @param title Title to set - * - * @see #setTitle(CharSequence) - */ - public void setWindowTitle(CharSequence title) { - if (!mUserTitle) { - setTitleImpl(title); - } - } - - private void setTitleImpl(CharSequence title) { - mTitle = title; - if (mTitleView != null) { - mTitleView.setText(title); - final boolean visible = mExpandedActionView == null && - (mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0 && - (!TextUtils.isEmpty(mTitle) || !TextUtils.isEmpty(mSubtitle)); - mTitleLayout.setVisibility(visible ? VISIBLE : GONE); - } - if (mLogoNavItem != null) { - mLogoNavItem.setTitle(title); - } - } - - public CharSequence getSubtitle() { - return mSubtitle; - } - - public void setSubtitle(CharSequence subtitle) { - mSubtitle = subtitle; - if (mSubtitleView != null) { - mSubtitleView.setText(subtitle); - mSubtitleView.setVisibility(subtitle != null ? VISIBLE : GONE); - final boolean visible = mExpandedActionView == null && - (mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0 && - (!TextUtils.isEmpty(mTitle) || !TextUtils.isEmpty(mSubtitle)); - mTitleLayout.setVisibility(visible ? VISIBLE : GONE); - } - } - - public void setHomeButtonEnabled(boolean enable) { - mHomeLayout.setEnabled(enable); - mHomeLayout.setFocusable(enable); - // Make sure the home button has an accurate content description for accessibility. - if (!enable) { - mHomeLayout.setContentDescription(null); - } else if ((mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0) { - mHomeLayout.setContentDescription(mContext.getResources().getText( - R.string.abs__action_bar_up_description)); - } else { - mHomeLayout.setContentDescription(mContext.getResources().getText( - R.string.abs__action_bar_home_description)); - } - } - - public void setDisplayOptions(int options) { - final int flagsChanged = mDisplayOptions == -1 ? -1 : options ^ mDisplayOptions; - mDisplayOptions = options; - - if ((flagsChanged & DISPLAY_RELAYOUT_MASK) != 0) { - final boolean showHome = (options & ActionBar.DISPLAY_SHOW_HOME) != 0; - final int vis = showHome && mExpandedActionView == null ? VISIBLE : GONE; - mHomeLayout.setVisibility(vis); - - if ((flagsChanged & ActionBar.DISPLAY_HOME_AS_UP) != 0) { - final boolean setUp = (options & ActionBar.DISPLAY_HOME_AS_UP) != 0; - mHomeLayout.setUp(setUp); - - // Showing home as up implicitly enables interaction with it. - // In honeycomb it was always enabled, so make this transition - // a bit easier for developers in the common case. - // (It would be silly to show it as up without responding to it.) - if (setUp) { - setHomeButtonEnabled(true); - } - } - - if ((flagsChanged & ActionBar.DISPLAY_USE_LOGO) != 0) { - final boolean logoVis = mLogo != null && (options & ActionBar.DISPLAY_USE_LOGO) != 0; - mHomeLayout.setIcon(logoVis ? mLogo : mIcon); - } - - if ((flagsChanged & ActionBar.DISPLAY_SHOW_TITLE) != 0) { - if ((options & ActionBar.DISPLAY_SHOW_TITLE) != 0) { - initTitle(); - } else { - removeView(mTitleLayout); - } - } - - if (mTitleLayout != null && (flagsChanged & - (ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME)) != 0) { - final boolean homeAsUp = (mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0; - mTitleUpView.setVisibility(!showHome ? (homeAsUp ? VISIBLE : INVISIBLE) : GONE); - mTitleLayout.setEnabled(!showHome && homeAsUp); - } - - if ((flagsChanged & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 && mCustomNavView != null) { - if ((options & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) { - addView(mCustomNavView); - } else { - removeView(mCustomNavView); - } - } - - requestLayout(); - } else { - invalidate(); - } - - // Make sure the home button has an accurate content description for accessibility. - if (!mHomeLayout.isEnabled()) { - mHomeLayout.setContentDescription(null); - } else if ((options & ActionBar.DISPLAY_HOME_AS_UP) != 0) { - mHomeLayout.setContentDescription(mContext.getResources().getText( - R.string.abs__action_bar_up_description)); - } else { - mHomeLayout.setContentDescription(mContext.getResources().getText( - R.string.abs__action_bar_home_description)); - } - } - - public void setIcon(Drawable icon) { - mIcon = icon; - if (icon != null && - ((mDisplayOptions & ActionBar.DISPLAY_USE_LOGO) == 0 || mLogo == null)) { - mHomeLayout.setIcon(icon); - } - } - - public void setIcon(int resId) { - setIcon(mContext.getResources().getDrawable(resId)); - } - - public void setLogo(Drawable logo) { - mLogo = logo; - if (logo != null && (mDisplayOptions & ActionBar.DISPLAY_USE_LOGO) != 0) { - mHomeLayout.setIcon(logo); - } - } - - public void setLogo(int resId) { - setLogo(mContext.getResources().getDrawable(resId)); - } - - public void setNavigationMode(int mode) { - final int oldMode = mNavigationMode; - if (mode != oldMode) { - switch (oldMode) { - case ActionBar.NAVIGATION_MODE_LIST: - if (mListNavLayout != null) { - removeView(mListNavLayout); - } - break; - case ActionBar.NAVIGATION_MODE_TABS: - if (mTabScrollView != null && mIncludeTabs) { - removeView(mTabScrollView); - } - } - - switch (mode) { - case ActionBar.NAVIGATION_MODE_LIST: - if (mSpinner == null) { - mSpinner = new IcsSpinner(mContext, null, - R.attr.actionDropDownStyle); - mListNavLayout = (IcsLinearLayout) LayoutInflater.from(mContext) - .inflate(R.layout.abs__action_bar_tab_bar_view, null); - LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( - LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); - params.gravity = Gravity.CENTER; - mListNavLayout.addView(mSpinner, params); - } - if (mSpinner.getAdapter() != mSpinnerAdapter) { - mSpinner.setAdapter(mSpinnerAdapter); - } - mSpinner.setOnItemSelectedListener(mNavItemSelectedListener); - addView(mListNavLayout); - break; - case ActionBar.NAVIGATION_MODE_TABS: - if (mTabScrollView != null && mIncludeTabs) { - addView(mTabScrollView); - } - break; - } - mNavigationMode = mode; - requestLayout(); - } - } - - public void setDropdownAdapter(SpinnerAdapter adapter) { - mSpinnerAdapter = adapter; - if (mSpinner != null) { - mSpinner.setAdapter(adapter); - } - } - - public SpinnerAdapter getDropdownAdapter() { - return mSpinnerAdapter; - } - - public void setDropdownSelectedPosition(int position) { - mSpinner.setSelection(position); - } - - public int getDropdownSelectedPosition() { - return mSpinner.getSelectedItemPosition(); - } - - public View getCustomNavigationView() { - return mCustomNavView; - } - - public int getNavigationMode() { - return mNavigationMode; - } - - public int getDisplayOptions() { - return mDisplayOptions; - } - - @Override - protected ViewGroup.LayoutParams generateDefaultLayoutParams() { - // Used by custom nav views if they don't supply layout params. Everything else - // added to an ActionBarView should have them already. - return new ActionBar.LayoutParams(DEFAULT_CUSTOM_GRAVITY); - } - - @Override - protected void onFinishInflate() { - super.onFinishInflate(); - - addView(mHomeLayout); - - if (mCustomNavView != null && (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) { - final ViewParent parent = mCustomNavView.getParent(); - if (parent != this) { - if (parent instanceof ViewGroup) { - ((ViewGroup) parent).removeView(mCustomNavView); - } - addView(mCustomNavView); - } - } - } - - private void initTitle() { - if (mTitleLayout == null) { - LayoutInflater inflater = LayoutInflater.from(getContext()); - mTitleLayout = (LinearLayout) inflater.inflate(R.layout.abs__action_bar_title_item, - this, false); - mTitleView = (TextView) mTitleLayout.findViewById(R.id.abs__action_bar_title); - mSubtitleView = (TextView) mTitleLayout.findViewById(R.id.abs__action_bar_subtitle); - mTitleUpView = mTitleLayout.findViewById(R.id.abs__up); - - mTitleLayout.setOnClickListener(mUpClickListener); - - if (mTitleStyleRes != 0) { - mTitleView.setTextAppearance(mContext, mTitleStyleRes); - } - if (mTitle != null) { - mTitleView.setText(mTitle); - } - - if (mSubtitleStyleRes != 0) { - mSubtitleView.setTextAppearance(mContext, mSubtitleStyleRes); - } - if (mSubtitle != null) { - mSubtitleView.setText(mSubtitle); - mSubtitleView.setVisibility(VISIBLE); - } - - final boolean homeAsUp = (mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0; - final boolean showHome = (mDisplayOptions & ActionBar.DISPLAY_SHOW_HOME) != 0; - mTitleUpView.setVisibility(!showHome ? (homeAsUp ? VISIBLE : INVISIBLE) : GONE); - mTitleLayout.setEnabled(homeAsUp && !showHome); - } - - addView(mTitleLayout); - if (mExpandedActionView != null || - (TextUtils.isEmpty(mTitle) && TextUtils.isEmpty(mSubtitle))) { - // Don't show while in expanded mode or with empty text - mTitleLayout.setVisibility(GONE); - } - } - - public void setContextView(ActionBarContextView view) { - mContextView = view; - } - - public void setCollapsable(boolean collapsable) { - mIsCollapsable = collapsable; - } - - public boolean isCollapsed() { - return mIsCollapsed; - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - final int childCount = getChildCount(); - if (mIsCollapsable) { - int visibleChildren = 0; - for (int i = 0; i < childCount; i++) { - final View child = getChildAt(i); - if (child.getVisibility() != GONE && - !(child == mMenuView && mMenuView.getChildCount() == 0)) { - visibleChildren++; - } - } - - if (visibleChildren == 0) { - // No size for an empty action bar when collapsable. - setMeasuredDimension(0, 0); - mIsCollapsed = true; - return; - } - } - mIsCollapsed = false; - - int widthMode = MeasureSpec.getMode(widthMeasureSpec); - if (widthMode != MeasureSpec.EXACTLY) { - throw new IllegalStateException(getClass().getSimpleName() + " can only be used " + - "with android:layout_width=\"match_parent\" (or fill_parent)"); - } - - int heightMode = MeasureSpec.getMode(heightMeasureSpec); - if (heightMode != MeasureSpec.AT_MOST) { - throw new IllegalStateException(getClass().getSimpleName() + " can only be used " + - "with android:layout_height=\"wrap_content\""); - } - - int contentWidth = MeasureSpec.getSize(widthMeasureSpec); - - int maxHeight = mContentHeight > 0 ? - mContentHeight : MeasureSpec.getSize(heightMeasureSpec); - - final int verticalPadding = getPaddingTop() + getPaddingBottom(); - final int paddingLeft = getPaddingLeft(); - final int paddingRight = getPaddingRight(); - final int height = maxHeight - verticalPadding; - final int childSpecHeight = MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST); - - int availableWidth = contentWidth - paddingLeft - paddingRight; - int leftOfCenter = availableWidth / 2; - int rightOfCenter = leftOfCenter; - - HomeView homeLayout = mExpandedActionView != null ? mExpandedHomeLayout : mHomeLayout; - - if (homeLayout.getVisibility() != GONE) { - final ViewGroup.LayoutParams lp = homeLayout.getLayoutParams(); - int homeWidthSpec; - if (lp.width < 0) { - homeWidthSpec = MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST); - } else { - homeWidthSpec = MeasureSpec.makeMeasureSpec(lp.width, MeasureSpec.EXACTLY); - } - homeLayout.measure(homeWidthSpec, - MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY)); - final int homeWidth = homeLayout.getMeasuredWidth() + homeLayout.getLeftOffset(); - availableWidth = Math.max(0, availableWidth - homeWidth); - leftOfCenter = Math.max(0, availableWidth - homeWidth); - } - - if (mMenuView != null && mMenuView.getParent() == this) { - availableWidth = measureChildView(mMenuView, availableWidth, - childSpecHeight, 0); - rightOfCenter = Math.max(0, rightOfCenter - mMenuView.getMeasuredWidth()); - } - - if (mIndeterminateProgressView != null && - mIndeterminateProgressView.getVisibility() != GONE) { - availableWidth = measureChildView(mIndeterminateProgressView, availableWidth, - childSpecHeight, 0); - rightOfCenter = Math.max(0, - rightOfCenter - mIndeterminateProgressView.getMeasuredWidth()); - } - - final boolean showTitle = mTitleLayout != null && mTitleLayout.getVisibility() != GONE && - (mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0; - - if (mExpandedActionView == null) { - switch (mNavigationMode) { - case ActionBar.NAVIGATION_MODE_LIST: - if (mListNavLayout != null) { - final int itemPaddingSize = showTitle ? mItemPadding * 2 : mItemPadding; - availableWidth = Math.max(0, availableWidth - itemPaddingSize); - leftOfCenter = Math.max(0, leftOfCenter - itemPaddingSize); - mListNavLayout.measure( - MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST), - MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY)); - final int listNavWidth = mListNavLayout.getMeasuredWidth(); - availableWidth = Math.max(0, availableWidth - listNavWidth); - leftOfCenter = Math.max(0, leftOfCenter - listNavWidth); - } - break; - case ActionBar.NAVIGATION_MODE_TABS: - if (mTabScrollView != null) { - final int itemPaddingSize = showTitle ? mItemPadding * 2 : mItemPadding; - availableWidth = Math.max(0, availableWidth - itemPaddingSize); - leftOfCenter = Math.max(0, leftOfCenter - itemPaddingSize); - mTabScrollView.measure( - MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST), - MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY)); - final int tabWidth = mTabScrollView.getMeasuredWidth(); - availableWidth = Math.max(0, availableWidth - tabWidth); - leftOfCenter = Math.max(0, leftOfCenter - tabWidth); - } - break; - } - } - - View customView = null; - if (mExpandedActionView != null) { - customView = mExpandedActionView; - } else if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 && - mCustomNavView != null) { - customView = mCustomNavView; - } - - if (customView != null) { - final ViewGroup.LayoutParams lp = generateLayoutParams(customView.getLayoutParams()); - final ActionBar.LayoutParams ablp = lp instanceof ActionBar.LayoutParams ? - (ActionBar.LayoutParams) lp : null; - - int horizontalMargin = 0; - int verticalMargin = 0; - if (ablp != null) { - horizontalMargin = ablp.leftMargin + ablp.rightMargin; - verticalMargin = ablp.topMargin + ablp.bottomMargin; - } - - // If the action bar is wrapping to its content height, don't allow a custom - // view to MATCH_PARENT. - int customNavHeightMode; - if (mContentHeight <= 0) { - customNavHeightMode = MeasureSpec.AT_MOST; - } else { - customNavHeightMode = lp.height != LayoutParams.WRAP_CONTENT ? - MeasureSpec.EXACTLY : MeasureSpec.AT_MOST; - } - final int customNavHeight = Math.max(0, - (lp.height >= 0 ? Math.min(lp.height, height) : height) - verticalMargin); - - final int customNavWidthMode = lp.width != LayoutParams.WRAP_CONTENT ? - MeasureSpec.EXACTLY : MeasureSpec.AT_MOST; - int customNavWidth = Math.max(0, - (lp.width >= 0 ? Math.min(lp.width, availableWidth) : availableWidth) - - horizontalMargin); - final int hgrav = (ablp != null ? ablp.gravity : DEFAULT_CUSTOM_GRAVITY) & - Gravity.HORIZONTAL_GRAVITY_MASK; - - // Centering a custom view is treated specially; we try to center within the whole - // action bar rather than in the available space. - if (hgrav == Gravity.CENTER_HORIZONTAL && lp.width == LayoutParams.MATCH_PARENT) { - customNavWidth = Math.min(leftOfCenter, rightOfCenter) * 2; - } - - customView.measure( - MeasureSpec.makeMeasureSpec(customNavWidth, customNavWidthMode), - MeasureSpec.makeMeasureSpec(customNavHeight, customNavHeightMode)); - availableWidth -= horizontalMargin + customView.getMeasuredWidth(); - } - - if (mExpandedActionView == null && showTitle) { - availableWidth = measureChildView(mTitleLayout, availableWidth, - MeasureSpec.makeMeasureSpec(mContentHeight, MeasureSpec.EXACTLY), 0); - leftOfCenter = Math.max(0, leftOfCenter - mTitleLayout.getMeasuredWidth()); - } - - if (mContentHeight <= 0) { - int measuredHeight = 0; - for (int i = 0; i < childCount; i++) { - View v = getChildAt(i); - int paddedViewHeight = v.getMeasuredHeight() + verticalPadding; - if (paddedViewHeight > measuredHeight) { - measuredHeight = paddedViewHeight; - } - } - setMeasuredDimension(contentWidth, measuredHeight); - } else { - setMeasuredDimension(contentWidth, maxHeight); - } - - if (mContextView != null) { - mContextView.setContentHeight(getMeasuredHeight()); - } - - if (mProgressView != null && mProgressView.getVisibility() != GONE) { - mProgressView.measure(MeasureSpec.makeMeasureSpec( - contentWidth - mProgressBarPadding * 2, MeasureSpec.EXACTLY), - MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.AT_MOST)); - } - } - - @Override - protected void onLayout(boolean changed, int l, int t, int r, int b) { - int x = getPaddingLeft(); - final int y = getPaddingTop(); - final int contentHeight = b - t - getPaddingTop() - getPaddingBottom(); - - if (contentHeight <= 0) { - // Nothing to do if we can't see anything. - return; - } - - HomeView homeLayout = mExpandedActionView != null ? mExpandedHomeLayout : mHomeLayout; - if (homeLayout.getVisibility() != GONE) { - final int leftOffset = homeLayout.getLeftOffset(); - x += positionChild(homeLayout, x + leftOffset, y, contentHeight) + leftOffset; - } - - if (mExpandedActionView == null) { - final boolean showTitle = mTitleLayout != null && mTitleLayout.getVisibility() != GONE && - (mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0; - if (showTitle) { - x += positionChild(mTitleLayout, x, y, contentHeight); - } - - switch (mNavigationMode) { - case ActionBar.NAVIGATION_MODE_STANDARD: - break; - case ActionBar.NAVIGATION_MODE_LIST: - if (mListNavLayout != null) { - if (showTitle) x += mItemPadding; - x += positionChild(mListNavLayout, x, y, contentHeight) + mItemPadding; - } - break; - case ActionBar.NAVIGATION_MODE_TABS: - if (mTabScrollView != null) { - if (showTitle) x += mItemPadding; - x += positionChild(mTabScrollView, x, y, contentHeight) + mItemPadding; - } - break; - } - } - - int menuLeft = r - l - getPaddingRight(); - if (mMenuView != null && mMenuView.getParent() == this) { - positionChildInverse(mMenuView, menuLeft, y, contentHeight); - menuLeft -= mMenuView.getMeasuredWidth(); - } - - if (mIndeterminateProgressView != null && - mIndeterminateProgressView.getVisibility() != GONE) { - positionChildInverse(mIndeterminateProgressView, menuLeft, y, contentHeight); - menuLeft -= mIndeterminateProgressView.getMeasuredWidth(); - } - - View customView = null; - if (mExpandedActionView != null) { - customView = mExpandedActionView; - } else if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 && - mCustomNavView != null) { - customView = mCustomNavView; - } - if (customView != null) { - ViewGroup.LayoutParams lp = customView.getLayoutParams(); - final ActionBar.LayoutParams ablp = lp instanceof ActionBar.LayoutParams ? - (ActionBar.LayoutParams) lp : null; - - final int gravity = ablp != null ? ablp.gravity : DEFAULT_CUSTOM_GRAVITY; - final int navWidth = customView.getMeasuredWidth(); - - int topMargin = 0; - int bottomMargin = 0; - if (ablp != null) { - x += ablp.leftMargin; - menuLeft -= ablp.rightMargin; - topMargin = ablp.topMargin; - bottomMargin = ablp.bottomMargin; - } - - int hgravity = gravity & Gravity.HORIZONTAL_GRAVITY_MASK; - // See if we actually have room to truly center; if not push against left or right. - if (hgravity == Gravity.CENTER_HORIZONTAL) { - final int centeredLeft = ((getRight() - getLeft()) - navWidth) / 2; - if (centeredLeft < x) { - hgravity = Gravity.LEFT; - } else if (centeredLeft + navWidth > menuLeft) { - hgravity = Gravity.RIGHT; - } - } else if (gravity == -1) { - hgravity = Gravity.LEFT; - } - - int xpos = 0; - switch (hgravity) { - case Gravity.CENTER_HORIZONTAL: - xpos = ((getRight() - getLeft()) - navWidth) / 2; - break; - case Gravity.LEFT: - xpos = x; - break; - case Gravity.RIGHT: - xpos = menuLeft - navWidth; - break; - } - - int vgravity = gravity & Gravity.VERTICAL_GRAVITY_MASK; - - if (gravity == -1) { - vgravity = Gravity.CENTER_VERTICAL; - } - - int ypos = 0; - switch (vgravity) { - case Gravity.CENTER_VERTICAL: - final int paddedTop = getPaddingTop(); - final int paddedBottom = getBottom() - getTop() - getPaddingBottom(); - ypos = ((paddedBottom - paddedTop) - customView.getMeasuredHeight()) / 2; - break; - case Gravity.TOP: - ypos = getPaddingTop() + topMargin; - break; - case Gravity.BOTTOM: - ypos = getHeight() - getPaddingBottom() - customView.getMeasuredHeight() - - bottomMargin; - break; - } - final int customWidth = customView.getMeasuredWidth(); - customView.layout(xpos, ypos, xpos + customWidth, - ypos + customView.getMeasuredHeight()); - x += customWidth; - } - - if (mProgressView != null) { - mProgressView.bringToFront(); - final int halfProgressHeight = mProgressView.getMeasuredHeight() / 2; - mProgressView.layout(mProgressBarPadding, -halfProgressHeight, - mProgressBarPadding + mProgressView.getMeasuredWidth(), halfProgressHeight); - } - } - - @Override - public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs) { - return new ActionBar.LayoutParams(getContext(), attrs); - } - - @Override - public ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) { - if (lp == null) { - lp = generateDefaultLayoutParams(); - } - return lp; - } - - @Override - public Parcelable onSaveInstanceState() { - Parcelable superState = super.onSaveInstanceState(); - SavedState state = new SavedState(superState); - - if (mExpandedMenuPresenter != null && mExpandedMenuPresenter.mCurrentExpandedItem != null) { - state.expandedMenuItemId = mExpandedMenuPresenter.mCurrentExpandedItem.getItemId(); - } - - state.isOverflowOpen = isOverflowMenuShowing(); - - return state; - } - - @Override - public void onRestoreInstanceState(Parcelable p) { - SavedState state = (SavedState) p; - - super.onRestoreInstanceState(state.getSuperState()); - - if (state.expandedMenuItemId != 0 && - mExpandedMenuPresenter != null && mOptionsMenu != null) { - final MenuItem item = mOptionsMenu.findItem(state.expandedMenuItemId); - if (item != null) { - item.expandActionView(); - } - } - - if (state.isOverflowOpen) { - postShowOverflowMenu(); - } - } - - static class SavedState extends BaseSavedState { - int expandedMenuItemId; - boolean isOverflowOpen; - - SavedState(Parcelable superState) { - super(superState); - } - - private SavedState(Parcel in) { - super(in); - expandedMenuItemId = in.readInt(); - isOverflowOpen = in.readInt() != 0; - } - - @Override - public void writeToParcel(Parcel out, int flags) { - super.writeToParcel(out, flags); - out.writeInt(expandedMenuItemId); - out.writeInt(isOverflowOpen ? 1 : 0); - } - - public static final Parcelable.Creator CREATOR = - new Parcelable.Creator() { - public SavedState createFromParcel(Parcel in) { - return new SavedState(in); - } - - public SavedState[] newArray(int size) { - return new SavedState[size]; - } - }; - } - - public static class HomeView extends FrameLayout { - private View mUpView; - private ImageView mIconView; - private int mUpWidth; - - public HomeView(Context context) { - this(context, null); - } - - public HomeView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public void setUp(boolean isUp) { - mUpView.setVisibility(isUp ? VISIBLE : GONE); - } - - public void setIcon(Drawable icon) { - mIconView.setImageDrawable(icon); - } - - @Override - public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { - onPopulateAccessibilityEvent(event); - return true; - } - - @Override - public void onPopulateAccessibilityEvent(AccessibilityEvent event) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { - super.onPopulateAccessibilityEvent(event); - } - final CharSequence cdesc = getContentDescription(); - if (!TextUtils.isEmpty(cdesc)) { - event.getText().add(cdesc); - } - } - - @Override - public boolean dispatchHoverEvent(MotionEvent event) { - // Don't allow children to hover; we want this to be treated as a single component. - return onHoverEvent(event); - } - - @Override - protected void onFinishInflate() { - mUpView = findViewById(R.id.abs__up); - mIconView = (ImageView) findViewById(R.id.abs__home); - } - - public int getLeftOffset() { - return mUpView.getVisibility() == GONE ? mUpWidth : 0; - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - measureChildWithMargins(mUpView, widthMeasureSpec, 0, heightMeasureSpec, 0); - final LayoutParams upLp = (LayoutParams) mUpView.getLayoutParams(); - mUpWidth = upLp.leftMargin + mUpView.getMeasuredWidth() + upLp.rightMargin; - int width = mUpView.getVisibility() == GONE ? 0 : mUpWidth; - int height = upLp.topMargin + mUpView.getMeasuredHeight() + upLp.bottomMargin; - measureChildWithMargins(mIconView, widthMeasureSpec, width, heightMeasureSpec, 0); - final LayoutParams iconLp = (LayoutParams) mIconView.getLayoutParams(); - width += iconLp.leftMargin + mIconView.getMeasuredWidth() + iconLp.rightMargin; - height = Math.max(height, - iconLp.topMargin + mIconView.getMeasuredHeight() + iconLp.bottomMargin); - - final int widthMode = MeasureSpec.getMode(widthMeasureSpec); - final int heightMode = MeasureSpec.getMode(heightMeasureSpec); - final int widthSize = MeasureSpec.getSize(widthMeasureSpec); - final int heightSize = MeasureSpec.getSize(heightMeasureSpec); - - switch (widthMode) { - case MeasureSpec.AT_MOST: - width = Math.min(width, widthSize); - break; - case MeasureSpec.EXACTLY: - width = widthSize; - break; - case MeasureSpec.UNSPECIFIED: - default: - break; - } - switch (heightMode) { - case MeasureSpec.AT_MOST: - height = Math.min(height, heightSize); - break; - case MeasureSpec.EXACTLY: - height = heightSize; - break; - case MeasureSpec.UNSPECIFIED: - default: - break; - } - setMeasuredDimension(width, height); - } - - @Override - protected void onLayout(boolean changed, int l, int t, int r, int b) { - final int vCenter = (b - t) / 2; - //UNUSED int width = r - l; - int upOffset = 0; - if (mUpView.getVisibility() != GONE) { - final LayoutParams upLp = (LayoutParams) mUpView.getLayoutParams(); - final int upHeight = mUpView.getMeasuredHeight(); - final int upWidth = mUpView.getMeasuredWidth(); - final int upTop = vCenter - upHeight / 2; - mUpView.layout(0, upTop, upWidth, upTop + upHeight); - upOffset = upLp.leftMargin + upWidth + upLp.rightMargin; - //UNUSED width -= upOffset; - l += upOffset; - } - final LayoutParams iconLp = (LayoutParams) mIconView.getLayoutParams(); - final int iconHeight = mIconView.getMeasuredHeight(); - final int iconWidth = mIconView.getMeasuredWidth(); - final int hCenter = (r - l) / 2; - final int iconLeft = upOffset + Math.max(iconLp.leftMargin, hCenter - iconWidth / 2); - final int iconTop = Math.max(iconLp.topMargin, vCenter - iconHeight / 2); - mIconView.layout(iconLeft, iconTop, iconLeft + iconWidth, iconTop + iconHeight); - } - } - - private class ExpandedActionViewMenuPresenter implements MenuPresenter { - MenuBuilder mMenu; - MenuItemImpl mCurrentExpandedItem; - - @Override - public void initForMenu(Context context, MenuBuilder menu) { - // Clear the expanded action view when menus change. - if (mMenu != null && mCurrentExpandedItem != null) { - mMenu.collapseItemActionView(mCurrentExpandedItem); - } - mMenu = menu; - } - - @Override - public MenuView getMenuView(ViewGroup root) { - return null; - } - - @Override - public void updateMenuView(boolean cleared) { - // Make sure the expanded item we have is still there. - if (mCurrentExpandedItem != null) { - boolean found = false; - - if (mMenu != null) { - final int count = mMenu.size(); - for (int i = 0; i < count; i++) { - final MenuItem item = mMenu.getItem(i); - if (item == mCurrentExpandedItem) { - found = true; - break; - } - } - } - - if (!found) { - // The item we had expanded disappeared. Collapse. - collapseItemActionView(mMenu, mCurrentExpandedItem); - } - } - } - - @Override - public void setCallback(Callback cb) { - } - - @Override - public boolean onSubMenuSelected(SubMenuBuilder subMenu) { - return false; - } - - @Override - public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) { - } - - @Override - public boolean flagActionItems() { - return false; - } - - @Override - public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item) { - mExpandedActionView = item.getActionView(); - mExpandedHomeLayout.setIcon(mIcon.getConstantState().newDrawable(/* TODO getResources() */)); - mCurrentExpandedItem = item; - if (mExpandedActionView.getParent() != ActionBarView.this) { - addView(mExpandedActionView); - } - if (mExpandedHomeLayout.getParent() != ActionBarView.this) { - addView(mExpandedHomeLayout); - } - mHomeLayout.setVisibility(GONE); - if (mTitleLayout != null) mTitleLayout.setVisibility(GONE); - if (mTabScrollView != null) mTabScrollView.setVisibility(GONE); - if (mSpinner != null) mSpinner.setVisibility(GONE); - if (mCustomNavView != null) mCustomNavView.setVisibility(GONE); - requestLayout(); - item.setActionViewExpanded(true); - - if (mExpandedActionView instanceof CollapsibleActionView) { - ((CollapsibleActionView) mExpandedActionView).onActionViewExpanded(); - } - - return true; - } - - @Override - public boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item) { - // Do this before detaching the actionview from the hierarchy, in case - // it needs to dismiss the soft keyboard, etc. - if (mExpandedActionView instanceof CollapsibleActionView) { - ((CollapsibleActionView) mExpandedActionView).onActionViewCollapsed(); - } - - removeView(mExpandedActionView); - removeView(mExpandedHomeLayout); - mExpandedActionView = null; - if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_HOME) != 0) { - mHomeLayout.setVisibility(VISIBLE); - } - if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0) { - if (mTitleLayout == null) { - initTitle(); - } else { - mTitleLayout.setVisibility(VISIBLE); - } - } - if (mTabScrollView != null && mNavigationMode == ActionBar.NAVIGATION_MODE_TABS) { - mTabScrollView.setVisibility(VISIBLE); - } - if (mSpinner != null && mNavigationMode == ActionBar.NAVIGATION_MODE_LIST) { - mSpinner.setVisibility(VISIBLE); - } - if (mCustomNavView != null && (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) { - mCustomNavView.setVisibility(VISIBLE); - } - mExpandedHomeLayout.setIcon(null); - mCurrentExpandedItem = null; - requestLayout(); - item.setActionViewExpanded(false); - - return true; - } - - @Override - public int getId() { - return 0; - } - - @Override - public Parcelable onSaveInstanceState() { - return null; - } - - @Override - public void onRestoreInstanceState(Parcelable state) { - } - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/CapitalizingButton.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/CapitalizingButton.java deleted file mode 100644 index fa3698f3b..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/CapitalizingButton.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.actionbarsherlock.internal.widget; - -import java.util.Locale; -import android.content.Context; -import android.content.res.TypedArray; -import android.os.Build; -import android.util.AttributeSet; -import android.widget.Button; - -public class CapitalizingButton extends Button { - private static final boolean SANS_ICE_CREAM = Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH; - private static final boolean IS_GINGERBREAD = Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD; - - private static final int[] R_styleable_Button = new int[] { - android.R.attr.textAllCaps - }; - private static final int R_styleable_Button_textAllCaps = 0; - - private boolean mAllCaps; - - public CapitalizingButton(Context context, AttributeSet attrs) { - super(context, attrs); - - TypedArray a = context.obtainStyledAttributes(attrs, R_styleable_Button); - mAllCaps = a.getBoolean(R_styleable_Button_textAllCaps, true); - a.recycle(); - } - - public void setTextCompat(CharSequence text) { - if (SANS_ICE_CREAM && mAllCaps && text != null) { - if (IS_GINGERBREAD) { - setText(text.toString().toUpperCase(Locale.ROOT)); - } else { - setText(text.toString().toUpperCase()); - } - } else { - setText(text); - } - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/CapitalizingTextView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/CapitalizingTextView.java deleted file mode 100644 index 673ec554f..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/CapitalizingTextView.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.actionbarsherlock.internal.widget; - -import java.util.Locale; -import android.content.Context; -import android.content.res.TypedArray; -import android.os.Build; -import android.util.AttributeSet; -import android.widget.TextView; - -public class CapitalizingTextView extends TextView { - private static final boolean SANS_ICE_CREAM = Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH; - private static final boolean IS_GINGERBREAD = Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD; - - private static final int[] R_styleable_TextView = new int[] { - android.R.attr.textAllCaps - }; - private static final int R_styleable_TextView_textAllCaps = 0; - - private boolean mAllCaps; - - public CapitalizingTextView(Context context, AttributeSet attrs) { - this(context, attrs, 0); - } - - public CapitalizingTextView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - - TypedArray a = context.obtainStyledAttributes(attrs, R_styleable_TextView, defStyle, 0); - mAllCaps = a.getBoolean(R_styleable_TextView_textAllCaps, true); - a.recycle(); - } - - public void setTextCompat(CharSequence text) { - if (SANS_ICE_CREAM && mAllCaps && text != null) { - if (IS_GINGERBREAD) { - setText(text.toString().toUpperCase(Locale.ROOT)); - } else { - setText(text.toString().toUpperCase()); - } - } else { - setText(text); - } - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/FakeDialogPhoneWindow.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/FakeDialogPhoneWindow.java deleted file mode 100644 index ad1b4f0a8..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/FakeDialogPhoneWindow.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.actionbarsherlock.internal.widget; - -import static android.view.View.MeasureSpec.EXACTLY; -import android.content.Context; -import android.content.res.TypedArray; -import android.util.AttributeSet; -import android.util.DisplayMetrics; -import android.util.TypedValue; -import android.widget.LinearLayout; -import com.actionbarsherlock.R; - -public class FakeDialogPhoneWindow extends LinearLayout { - final TypedValue mMinWidthMajor = new TypedValue(); - final TypedValue mMinWidthMinor = new TypedValue(); - - public FakeDialogPhoneWindow(Context context, AttributeSet attrs) { - super(context, attrs); - - TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockTheme); - - a.getValue(R.styleable.SherlockTheme_windowMinWidthMajor, mMinWidthMajor); - a.getValue(R.styleable.SherlockTheme_windowMinWidthMinor, mMinWidthMinor); - - a.recycle(); - } - - /* Stolen from PhoneWindow */ - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - final DisplayMetrics metrics = getContext().getResources().getDisplayMetrics(); - final boolean isPortrait = metrics.widthPixels < metrics.heightPixels; - - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - - int width = getMeasuredWidth(); - boolean measure = false; - - widthMeasureSpec = MeasureSpec.makeMeasureSpec(width, EXACTLY); - - final TypedValue tv = isPortrait ? mMinWidthMinor : mMinWidthMajor; - - if (tv.type != TypedValue.TYPE_NULL) { - final int min; - if (tv.type == TypedValue.TYPE_DIMENSION) { - min = (int)tv.getDimension(metrics); - } else if (tv.type == TypedValue.TYPE_FRACTION) { - min = (int)tv.getFraction(metrics.widthPixels, metrics.widthPixels); - } else { - min = 0; - } - - if (width < min) { - widthMeasureSpec = MeasureSpec.makeMeasureSpec(min, EXACTLY); - measure = true; - } - } - - // TODO: Support height? - - if (measure) { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - } - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsAbsSpinner.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsAbsSpinner.java deleted file mode 100644 index ce0cb3bca..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsAbsSpinner.java +++ /dev/null @@ -1,479 +0,0 @@ -/* - * Copyright (C) 2006 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.actionbarsherlock.internal.widget; - -import android.content.Context; -import android.database.DataSetObserver; -import android.graphics.Rect; -import android.os.Build; -import android.os.Parcel; -import android.os.Parcelable; -import android.util.AttributeSet; -import android.util.SparseArray; -import android.view.View; -import android.view.ViewGroup; -import android.widget.SpinnerAdapter; - -/** - * An abstract base class for spinner widgets. SDK users will probably not - * need to use this class. - * - * @attr ref android.R.styleable#AbsSpinner_entries - */ -public abstract class IcsAbsSpinner extends IcsAdapterView { - private static final boolean IS_HONEYCOMB = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB; - - SpinnerAdapter mAdapter; - - int mHeightMeasureSpec; - int mWidthMeasureSpec; - boolean mBlockLayoutRequests; - - int mSelectionLeftPadding = 0; - int mSelectionTopPadding = 0; - int mSelectionRightPadding = 0; - int mSelectionBottomPadding = 0; - final Rect mSpinnerPadding = new Rect(); - - final RecycleBin mRecycler = new RecycleBin(); - private DataSetObserver mDataSetObserver; - - /** Temporary frame to hold a child View's frame rectangle */ - private Rect mTouchFrame; - - public IcsAbsSpinner(Context context) { - super(context); - initAbsSpinner(); - } - - public IcsAbsSpinner(Context context, AttributeSet attrs) { - this(context, attrs, 0); - } - - public IcsAbsSpinner(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - initAbsSpinner(); - - /* - TypedArray a = context.obtainStyledAttributes(attrs, - com.android.internal.R.styleable.AbsSpinner, defStyle, 0); - - CharSequence[] entries = a.getTextArray(R.styleable.AbsSpinner_entries); - if (entries != null) { - ArrayAdapter adapter = - new ArrayAdapter(context, - R.layout.simple_spinner_item, entries); - adapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item); - setAdapter(adapter); - } - - a.recycle(); - */ - } - - /** - * Common code for different constructor flavors - */ - private void initAbsSpinner() { - setFocusable(true); - setWillNotDraw(false); - } - - /** - * The Adapter is used to provide the data which backs this Spinner. - * It also provides methods to transform spinner items based on their position - * relative to the selected item. - * @param adapter The SpinnerAdapter to use for this Spinner - */ - @Override - public void setAdapter(SpinnerAdapter adapter) { - if (null != mAdapter) { - mAdapter.unregisterDataSetObserver(mDataSetObserver); - resetList(); - } - - mAdapter = adapter; - - mOldSelectedPosition = INVALID_POSITION; - mOldSelectedRowId = INVALID_ROW_ID; - - if (mAdapter != null) { - mOldItemCount = mItemCount; - mItemCount = mAdapter.getCount(); - checkFocus(); - - mDataSetObserver = new AdapterDataSetObserver(); - mAdapter.registerDataSetObserver(mDataSetObserver); - - int position = mItemCount > 0 ? 0 : INVALID_POSITION; - - setSelectedPositionInt(position); - setNextSelectedPositionInt(position); - - if (mItemCount == 0) { - // Nothing selected - checkSelectionChanged(); - } - - } else { - checkFocus(); - resetList(); - // Nothing selected - checkSelectionChanged(); - } - - requestLayout(); - } - - /** - * Clear out all children from the list - */ - void resetList() { - mDataChanged = false; - mNeedSync = false; - - removeAllViewsInLayout(); - mOldSelectedPosition = INVALID_POSITION; - mOldSelectedRowId = INVALID_ROW_ID; - - setSelectedPositionInt(INVALID_POSITION); - setNextSelectedPositionInt(INVALID_POSITION); - invalidate(); - } - - /** - * @see android.view.View#measure(int, int) - * - * Figure out the dimensions of this Spinner. The width comes from - * the widthMeasureSpec as Spinnners can't have their width set to - * UNSPECIFIED. The height is based on the height of the selected item - * plus padding. - */ - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - int widthMode = MeasureSpec.getMode(widthMeasureSpec); - int widthSize; - int heightSize; - - final int mPaddingLeft = getPaddingLeft(); - final int mPaddingTop = getPaddingTop(); - final int mPaddingRight = getPaddingRight(); - final int mPaddingBottom = getPaddingBottom(); - - mSpinnerPadding.left = mPaddingLeft > mSelectionLeftPadding ? mPaddingLeft - : mSelectionLeftPadding; - mSpinnerPadding.top = mPaddingTop > mSelectionTopPadding ? mPaddingTop - : mSelectionTopPadding; - mSpinnerPadding.right = mPaddingRight > mSelectionRightPadding ? mPaddingRight - : mSelectionRightPadding; - mSpinnerPadding.bottom = mPaddingBottom > mSelectionBottomPadding ? mPaddingBottom - : mSelectionBottomPadding; - - if (mDataChanged) { - handleDataChanged(); - } - - int preferredHeight = 0; - int preferredWidth = 0; - boolean needsMeasuring = true; - - int selectedPosition = getSelectedItemPosition(); - if (selectedPosition >= 0 && mAdapter != null && selectedPosition < mAdapter.getCount()) { - // Try looking in the recycler. (Maybe we were measured once already) - View view = mRecycler.get(selectedPosition); - if (view == null) { - // Make a new one - view = mAdapter.getView(selectedPosition, null, this); - } - - if (view != null) { - // Put in recycler for re-measuring and/or layout - mRecycler.put(selectedPosition, view); - } - - if (view != null) { - if (view.getLayoutParams() == null) { - mBlockLayoutRequests = true; - view.setLayoutParams(generateDefaultLayoutParams()); - mBlockLayoutRequests = false; - } - measureChild(view, widthMeasureSpec, heightMeasureSpec); - - preferredHeight = getChildHeight(view) + mSpinnerPadding.top + mSpinnerPadding.bottom; - preferredWidth = getChildWidth(view) + mSpinnerPadding.left + mSpinnerPadding.right; - - needsMeasuring = false; - } - } - - if (needsMeasuring) { - // No views -- just use padding - preferredHeight = mSpinnerPadding.top + mSpinnerPadding.bottom; - if (widthMode == MeasureSpec.UNSPECIFIED) { - preferredWidth = mSpinnerPadding.left + mSpinnerPadding.right; - } - } - - preferredHeight = Math.max(preferredHeight, getSuggestedMinimumHeight()); - preferredWidth = Math.max(preferredWidth, getSuggestedMinimumWidth()); - - if (IS_HONEYCOMB) { - heightSize = resolveSizeAndState(preferredHeight, heightMeasureSpec, 0); - widthSize = resolveSizeAndState(preferredWidth, widthMeasureSpec, 0); - } else { - heightSize = resolveSize(preferredHeight, heightMeasureSpec); - widthSize = resolveSize(preferredWidth, widthMeasureSpec); - } - - setMeasuredDimension(widthSize, heightSize); - mHeightMeasureSpec = heightMeasureSpec; - mWidthMeasureSpec = widthMeasureSpec; - } - - int getChildHeight(View child) { - return child.getMeasuredHeight(); - } - - int getChildWidth(View child) { - return child.getMeasuredWidth(); - } - - @Override - protected ViewGroup.LayoutParams generateDefaultLayoutParams() { - return new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT); - } - - void recycleAllViews() { - final int childCount = getChildCount(); - final IcsAbsSpinner.RecycleBin recycleBin = mRecycler; - final int position = mFirstPosition; - - // All views go in recycler - for (int i = 0; i < childCount; i++) { - View v = getChildAt(i); - int index = position + i; - recycleBin.put(index, v); - } - } - - /** - * Jump directly to a specific item in the adapter data. - */ - public void setSelection(int position, boolean animate) { - // Animate only if requested position is already on screen somewhere - boolean shouldAnimate = animate && mFirstPosition <= position && - position <= mFirstPosition + getChildCount() - 1; - setSelectionInt(position, shouldAnimate); - } - - @Override - public void setSelection(int position) { - setNextSelectedPositionInt(position); - requestLayout(); - invalidate(); - } - - - /** - * Makes the item at the supplied position selected. - * - * @param position Position to select - * @param animate Should the transition be animated - * - */ - void setSelectionInt(int position, boolean animate) { - if (position != mOldSelectedPosition) { - mBlockLayoutRequests = true; - int delta = position - mSelectedPosition; - setNextSelectedPositionInt(position); - layout(delta, animate); - mBlockLayoutRequests = false; - } - } - - abstract void layout(int delta, boolean animate); - - @Override - public View getSelectedView() { - if (mItemCount > 0 && mSelectedPosition >= 0) { - return getChildAt(mSelectedPosition - mFirstPosition); - } else { - return null; - } - } - - /** - * Override to prevent spamming ourselves with layout requests - * as we place views - * - * @see android.view.View#requestLayout() - */ - @Override - public void requestLayout() { - if (!mBlockLayoutRequests) { - super.requestLayout(); - } - } - - @Override - public SpinnerAdapter getAdapter() { - return mAdapter; - } - - @Override - public int getCount() { - return mItemCount; - } - - /** - * Maps a point to a position in the list. - * - * @param x X in local coordinate - * @param y Y in local coordinate - * @return The position of the item which contains the specified point, or - * {@link #INVALID_POSITION} if the point does not intersect an item. - */ - public int pointToPosition(int x, int y) { - Rect frame = mTouchFrame; - if (frame == null) { - mTouchFrame = new Rect(); - frame = mTouchFrame; - } - - final int count = getChildCount(); - for (int i = count - 1; i >= 0; i--) { - View child = getChildAt(i); - if (child.getVisibility() == View.VISIBLE) { - child.getHitRect(frame); - if (frame.contains(x, y)) { - return mFirstPosition + i; - } - } - } - return INVALID_POSITION; - } - - static class SavedState extends BaseSavedState { - long selectedId; - int position; - - /** - * Constructor called from {@link AbsSpinner#onSaveInstanceState()} - */ - SavedState(Parcelable superState) { - super(superState); - } - - /** - * Constructor called from {@link #CREATOR} - */ - private SavedState(Parcel in) { - super(in); - selectedId = in.readLong(); - position = in.readInt(); - } - - @Override - public void writeToParcel(Parcel out, int flags) { - super.writeToParcel(out, flags); - out.writeLong(selectedId); - out.writeInt(position); - } - - @Override - public String toString() { - return "AbsSpinner.SavedState{" - + Integer.toHexString(System.identityHashCode(this)) - + " selectedId=" + selectedId - + " position=" + position + "}"; - } - - public static final Parcelable.Creator CREATOR - = new Parcelable.Creator() { - public SavedState createFromParcel(Parcel in) { - return new SavedState(in); - } - - public SavedState[] newArray(int size) { - return new SavedState[size]; - } - }; - } - - @Override - public Parcelable onSaveInstanceState() { - Parcelable superState = super.onSaveInstanceState(); - SavedState ss = new SavedState(superState); - ss.selectedId = getSelectedItemId(); - if (ss.selectedId >= 0) { - ss.position = getSelectedItemPosition(); - } else { - ss.position = INVALID_POSITION; - } - return ss; - } - - @Override - public void onRestoreInstanceState(Parcelable state) { - SavedState ss = (SavedState) state; - - super.onRestoreInstanceState(ss.getSuperState()); - - if (ss.selectedId >= 0) { - mDataChanged = true; - mNeedSync = true; - mSyncRowId = ss.selectedId; - mSyncPosition = ss.position; - mSyncMode = SYNC_SELECTED_POSITION; - requestLayout(); - } - } - - class RecycleBin { - private final SparseArray mScrapHeap = new SparseArray(); - - public void put(int position, View v) { - mScrapHeap.put(position, v); - } - - View get(int position) { - // System.out.print("Looking for " + position); - View result = mScrapHeap.get(position); - if (result != null) { - // System.out.println(" HIT"); - mScrapHeap.delete(position); - } else { - // System.out.println(" MISS"); - } - return result; - } - - void clear() { - final SparseArray scrapHeap = mScrapHeap; - final int count = scrapHeap.size(); - for (int i = 0; i < count; i++) { - final View view = scrapHeap.valueAt(i); - if (view != null) { - removeDetachedView(view, true); - } - } - scrapHeap.clear(); - } - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsAdapterView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsAdapterView.java deleted file mode 100644 index c786dc5c1..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsAdapterView.java +++ /dev/null @@ -1,1160 +0,0 @@ -/* - * Copyright (C) 2006 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.actionbarsherlock.internal.widget; - -import android.content.Context; -import android.database.DataSetObserver; -import android.os.Parcelable; -import android.os.SystemClock; -import android.util.AttributeSet; -import android.util.SparseArray; -import android.view.ContextMenu; -import android.view.SoundEffectConstants; -import android.view.View; -import android.view.ViewDebug; -import android.view.ViewGroup; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; -import android.widget.Adapter; -import android.widget.AdapterView.OnItemClickListener; -import android.widget.ListView; - - -/** - * An AdapterView is a view whose children are determined by an {@link Adapter}. - * - *

- * See {@link ListView}, {@link GridView}, {@link Spinner} and - * {@link Gallery} for commonly used subclasses of AdapterView. - * - *

- *

Developer Guides

- *

For more information about using AdapterView, read the - * Binding to Data with AdapterView - * developer guide.

- */ -public abstract class IcsAdapterView extends ViewGroup { - - /** - * The item view type returned by {@link Adapter#getItemViewType(int)} when - * the adapter does not want the item's view recycled. - */ - public static final int ITEM_VIEW_TYPE_IGNORE = -1; - - /** - * The item view type returned by {@link Adapter#getItemViewType(int)} when - * the item is a header or footer. - */ - public static final int ITEM_VIEW_TYPE_HEADER_OR_FOOTER = -2; - - /** - * The position of the first child displayed - */ - @ViewDebug.ExportedProperty(category = "scrolling") - int mFirstPosition = 0; - - /** - * The offset in pixels from the top of the AdapterView to the top - * of the view to select during the next layout. - */ - int mSpecificTop; - - /** - * Position from which to start looking for mSyncRowId - */ - int mSyncPosition; - - /** - * Row id to look for when data has changed - */ - long mSyncRowId = INVALID_ROW_ID; - - /** - * Height of the view when mSyncPosition and mSyncRowId where set - */ - long mSyncHeight; - - /** - * True if we need to sync to mSyncRowId - */ - boolean mNeedSync = false; - - /** - * Indicates whether to sync based on the selection or position. Possible - * values are {@link #SYNC_SELECTED_POSITION} or - * {@link #SYNC_FIRST_POSITION}. - */ - int mSyncMode; - - /** - * Our height after the last layout - */ - private int mLayoutHeight; - - /** - * Sync based on the selected child - */ - static final int SYNC_SELECTED_POSITION = 0; - - /** - * Sync based on the first child displayed - */ - static final int SYNC_FIRST_POSITION = 1; - - /** - * Maximum amount of time to spend in {@link #findSyncPosition()} - */ - static final int SYNC_MAX_DURATION_MILLIS = 100; - - /** - * Indicates that this view is currently being laid out. - */ - boolean mInLayout = false; - - /** - * The listener that receives notifications when an item is selected. - */ - OnItemSelectedListener mOnItemSelectedListener; - - /** - * The listener that receives notifications when an item is clicked. - */ - OnItemClickListener mOnItemClickListener; - - /** - * The listener that receives notifications when an item is long clicked. - */ - OnItemLongClickListener mOnItemLongClickListener; - - /** - * True if the data has changed since the last layout - */ - boolean mDataChanged; - - /** - * The position within the adapter's data set of the item to select - * during the next layout. - */ - @ViewDebug.ExportedProperty(category = "list") - int mNextSelectedPosition = INVALID_POSITION; - - /** - * The item id of the item to select during the next layout. - */ - long mNextSelectedRowId = INVALID_ROW_ID; - - /** - * The position within the adapter's data set of the currently selected item. - */ - @ViewDebug.ExportedProperty(category = "list") - int mSelectedPosition = INVALID_POSITION; - - /** - * The item id of the currently selected item. - */ - long mSelectedRowId = INVALID_ROW_ID; - - /** - * View to show if there are no items to show. - */ - private View mEmptyView; - - /** - * The number of items in the current adapter. - */ - @ViewDebug.ExportedProperty(category = "list") - int mItemCount; - - /** - * The number of items in the adapter before a data changed event occurred. - */ - int mOldItemCount; - - /** - * Represents an invalid position. All valid positions are in the range 0 to 1 less than the - * number of items in the current adapter. - */ - public static final int INVALID_POSITION = -1; - - /** - * Represents an empty or invalid row id - */ - public static final long INVALID_ROW_ID = Long.MIN_VALUE; - - /** - * The last selected position we used when notifying - */ - int mOldSelectedPosition = INVALID_POSITION; - - /** - * The id of the last selected position we used when notifying - */ - long mOldSelectedRowId = INVALID_ROW_ID; - - /** - * Indicates what focusable state is requested when calling setFocusable(). - * In addition to this, this view has other criteria for actually - * determining the focusable state (such as whether its empty or the text - * filter is shown). - * - * @see #setFocusable(boolean) - * @see #checkFocus() - */ - private boolean mDesiredFocusableState; - private boolean mDesiredFocusableInTouchModeState; - - private SelectionNotifier mSelectionNotifier; - /** - * When set to true, calls to requestLayout() will not propagate up the parent hierarchy. - * This is used to layout the children during a layout pass. - */ - boolean mBlockLayoutRequests = false; - - public IcsAdapterView(Context context) { - super(context); - } - - public IcsAdapterView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public IcsAdapterView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - /** - * Register a callback to be invoked when an item in this AdapterView has - * been clicked. - * - * @param listener The callback that will be invoked. - */ - public void setOnItemClickListener(OnItemClickListener listener) { - mOnItemClickListener = listener; - } - - /** - * @return The callback to be invoked with an item in this AdapterView has - * been clicked, or null id no callback has been set. - */ - public final OnItemClickListener getOnItemClickListener() { - return mOnItemClickListener; - } - - /** - * Call the OnItemClickListener, if it is defined. - * - * @param view The view within the AdapterView that was clicked. - * @param position The position of the view in the adapter. - * @param id The row id of the item that was clicked. - * @return True if there was an assigned OnItemClickListener that was - * called, false otherwise is returned. - */ - public boolean performItemClick(View view, int position, long id) { - if (mOnItemClickListener != null) { - playSoundEffect(SoundEffectConstants.CLICK); - if (view != null) { - view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED); - } - mOnItemClickListener.onItemClick(/*this*/null, view, position, id); - return true; - } - - return false; - } - - /** - * Interface definition for a callback to be invoked when an item in this - * view has been clicked and held. - */ - public interface OnItemLongClickListener { - /** - * Callback method to be invoked when an item in this view has been - * clicked and held. - * - * Implementers can call getItemAtPosition(position) if they need to access - * the data associated with the selected item. - * - * @param parent The AbsListView where the click happened - * @param view The view within the AbsListView that was clicked - * @param position The position of the view in the list - * @param id The row id of the item that was clicked - * - * @return true if the callback consumed the long click, false otherwise - */ - boolean onItemLongClick(IcsAdapterView parent, View view, int position, long id); - } - - - /** - * Register a callback to be invoked when an item in this AdapterView has - * been clicked and held - * - * @param listener The callback that will run - */ - public void setOnItemLongClickListener(OnItemLongClickListener listener) { - if (!isLongClickable()) { - setLongClickable(true); - } - mOnItemLongClickListener = listener; - } - - /** - * @return The callback to be invoked with an item in this AdapterView has - * been clicked and held, or null id no callback as been set. - */ - public final OnItemLongClickListener getOnItemLongClickListener() { - return mOnItemLongClickListener; - } - - /** - * Interface definition for a callback to be invoked when - * an item in this view has been selected. - */ - public interface OnItemSelectedListener { - /** - *

Callback method to be invoked when an item in this view has been - * selected. This callback is invoked only when the newly selected - * position is different from the previously selected position or if - * there was no selected item.

- * - * Impelmenters can call getItemAtPosition(position) if they need to access the - * data associated with the selected item. - * - * @param parent The AdapterView where the selection happened - * @param view The view within the AdapterView that was clicked - * @param position The position of the view in the adapter - * @param id The row id of the item that is selected - */ - void onItemSelected(IcsAdapterView parent, View view, int position, long id); - - /** - * Callback method to be invoked when the selection disappears from this - * view. The selection can disappear for instance when touch is activated - * or when the adapter becomes empty. - * - * @param parent The AdapterView that now contains no selected item. - */ - void onNothingSelected(IcsAdapterView parent); - } - - - /** - * Register a callback to be invoked when an item in this AdapterView has - * been selected. - * - * @param listener The callback that will run - */ - public void setOnItemSelectedListener(OnItemSelectedListener listener) { - mOnItemSelectedListener = listener; - } - - public final OnItemSelectedListener getOnItemSelectedListener() { - return mOnItemSelectedListener; - } - - /** - * Extra menu information provided to the - * {@link android.view.View.OnCreateContextMenuListener#onCreateContextMenu(ContextMenu, View, ContextMenuInfo) } - * callback when a context menu is brought up for this AdapterView. - * - */ - public static class AdapterContextMenuInfo implements ContextMenu.ContextMenuInfo { - - public AdapterContextMenuInfo(View targetView, int position, long id) { - this.targetView = targetView; - this.position = position; - this.id = id; - } - - /** - * The child view for which the context menu is being displayed. This - * will be one of the children of this AdapterView. - */ - public View targetView; - - /** - * The position in the adapter for which the context menu is being - * displayed. - */ - public int position; - - /** - * The row id of the item for which the context menu is being displayed. - */ - public long id; - } - - /** - * Returns the adapter currently associated with this widget. - * - * @return The adapter used to provide this view's content. - */ - public abstract T getAdapter(); - - /** - * Sets the adapter that provides the data and the views to represent the data - * in this widget. - * - * @param adapter The adapter to use to create this view's content. - */ - public abstract void setAdapter(T adapter); - - /** - * This method is not supported and throws an UnsupportedOperationException when called. - * - * @param child Ignored. - * - * @throws UnsupportedOperationException Every time this method is invoked. - */ - @Override - public void addView(View child) { - throw new UnsupportedOperationException("addView(View) is not supported in AdapterView"); - } - - /** - * This method is not supported and throws an UnsupportedOperationException when called. - * - * @param child Ignored. - * @param index Ignored. - * - * @throws UnsupportedOperationException Every time this method is invoked. - */ - @Override - public void addView(View child, int index) { - throw new UnsupportedOperationException("addView(View, int) is not supported in AdapterView"); - } - - /** - * This method is not supported and throws an UnsupportedOperationException when called. - * - * @param child Ignored. - * @param params Ignored. - * - * @throws UnsupportedOperationException Every time this method is invoked. - */ - @Override - public void addView(View child, LayoutParams params) { - throw new UnsupportedOperationException("addView(View, LayoutParams) " - + "is not supported in AdapterView"); - } - - /** - * This method is not supported and throws an UnsupportedOperationException when called. - * - * @param child Ignored. - * @param index Ignored. - * @param params Ignored. - * - * @throws UnsupportedOperationException Every time this method is invoked. - */ - @Override - public void addView(View child, int index, LayoutParams params) { - throw new UnsupportedOperationException("addView(View, int, LayoutParams) " - + "is not supported in AdapterView"); - } - - /** - * This method is not supported and throws an UnsupportedOperationException when called. - * - * @param child Ignored. - * - * @throws UnsupportedOperationException Every time this method is invoked. - */ - @Override - public void removeView(View child) { - throw new UnsupportedOperationException("removeView(View) is not supported in AdapterView"); - } - - /** - * This method is not supported and throws an UnsupportedOperationException when called. - * - * @param index Ignored. - * - * @throws UnsupportedOperationException Every time this method is invoked. - */ - @Override - public void removeViewAt(int index) { - throw new UnsupportedOperationException("removeViewAt(int) is not supported in AdapterView"); - } - - /** - * This method is not supported and throws an UnsupportedOperationException when called. - * - * @throws UnsupportedOperationException Every time this method is invoked. - */ - @Override - public void removeAllViews() { - throw new UnsupportedOperationException("removeAllViews() is not supported in AdapterView"); - } - - @Override - protected void onLayout(boolean changed, int left, int top, int right, int bottom) { - mLayoutHeight = getHeight(); - } - - /** - * Return the position of the currently selected item within the adapter's data set - * - * @return int Position (starting at 0), or {@link #INVALID_POSITION} if there is nothing selected. - */ - @ViewDebug.CapturedViewProperty - public int getSelectedItemPosition() { - return mNextSelectedPosition; - } - - /** - * @return The id corresponding to the currently selected item, or {@link #INVALID_ROW_ID} - * if nothing is selected. - */ - @ViewDebug.CapturedViewProperty - public long getSelectedItemId() { - return mNextSelectedRowId; - } - - /** - * @return The view corresponding to the currently selected item, or null - * if nothing is selected - */ - public abstract View getSelectedView(); - - /** - * @return The data corresponding to the currently selected item, or - * null if there is nothing selected. - */ - public Object getSelectedItem() { - T adapter = getAdapter(); - int selection = getSelectedItemPosition(); - if (adapter != null && adapter.getCount() > 0 && selection >= 0) { - return adapter.getItem(selection); - } else { - return null; - } - } - - /** - * @return The number of items owned by the Adapter associated with this - * AdapterView. (This is the number of data items, which may be - * larger than the number of visible views.) - */ - @ViewDebug.CapturedViewProperty - public int getCount() { - return mItemCount; - } - - /** - * Get the position within the adapter's data set for the view, where view is a an adapter item - * or a descendant of an adapter item. - * - * @param view an adapter item, or a descendant of an adapter item. This must be visible in this - * AdapterView at the time of the call. - * @return the position within the adapter's data set of the view, or {@link #INVALID_POSITION} - * if the view does not correspond to a list item (or it is not currently visible). - */ - public int getPositionForView(View view) { - View listItem = view; - try { - View v; - while (!(v = (View) listItem.getParent()).equals(this)) { - listItem = v; - } - } catch (ClassCastException e) { - // We made it up to the window without find this list view - return INVALID_POSITION; - } - - // Search the children for the list item - final int childCount = getChildCount(); - for (int i = 0; i < childCount; i++) { - if (getChildAt(i).equals(listItem)) { - return mFirstPosition + i; - } - } - - // Child not found! - return INVALID_POSITION; - } - - /** - * Returns the position within the adapter's data set for the first item - * displayed on screen. - * - * @return The position within the adapter's data set - */ - public int getFirstVisiblePosition() { - return mFirstPosition; - } - - /** - * Returns the position within the adapter's data set for the last item - * displayed on screen. - * - * @return The position within the adapter's data set - */ - public int getLastVisiblePosition() { - return mFirstPosition + getChildCount() - 1; - } - - /** - * Sets the currently selected item. To support accessibility subclasses that - * override this method must invoke the overriden super method first. - * - * @param position Index (starting at 0) of the data item to be selected. - */ - public abstract void setSelection(int position); - - /** - * Sets the view to show if the adapter is empty - */ - public void setEmptyView(View emptyView) { - mEmptyView = emptyView; - - final T adapter = getAdapter(); - final boolean empty = ((adapter == null) || adapter.isEmpty()); - updateEmptyStatus(empty); - } - - /** - * When the current adapter is empty, the AdapterView can display a special view - * call the empty view. The empty view is used to provide feedback to the user - * that no data is available in this AdapterView. - * - * @return The view to show if the adapter is empty. - */ - public View getEmptyView() { - return mEmptyView; - } - - /** - * Indicates whether this view is in filter mode. Filter mode can for instance - * be enabled by a user when typing on the keyboard. - * - * @return True if the view is in filter mode, false otherwise. - */ - boolean isInFilterMode() { - return false; - } - - @Override - public void setFocusable(boolean focusable) { - final T adapter = getAdapter(); - final boolean empty = adapter == null || adapter.getCount() == 0; - - mDesiredFocusableState = focusable; - if (!focusable) { - mDesiredFocusableInTouchModeState = false; - } - - super.setFocusable(focusable && (!empty || isInFilterMode())); - } - - @Override - public void setFocusableInTouchMode(boolean focusable) { - final T adapter = getAdapter(); - final boolean empty = adapter == null || adapter.getCount() == 0; - - mDesiredFocusableInTouchModeState = focusable; - if (focusable) { - mDesiredFocusableState = true; - } - - super.setFocusableInTouchMode(focusable && (!empty || isInFilterMode())); - } - - void checkFocus() { - final T adapter = getAdapter(); - final boolean empty = adapter == null || adapter.getCount() == 0; - final boolean focusable = !empty || isInFilterMode(); - // The order in which we set focusable in touch mode/focusable may matter - // for the client, see View.setFocusableInTouchMode() comments for more - // details - super.setFocusableInTouchMode(focusable && mDesiredFocusableInTouchModeState); - super.setFocusable(focusable && mDesiredFocusableState); - if (mEmptyView != null) { - updateEmptyStatus((adapter == null) || adapter.isEmpty()); - } - } - - /** - * Update the status of the list based on the empty parameter. If empty is true and - * we have an empty view, display it. In all the other cases, make sure that the listview - * is VISIBLE and that the empty view is GONE (if it's not null). - */ - private void updateEmptyStatus(boolean empty) { - if (isInFilterMode()) { - empty = false; - } - - if (empty) { - if (mEmptyView != null) { - mEmptyView.setVisibility(View.VISIBLE); - setVisibility(View.GONE); - } else { - // If the caller just removed our empty view, make sure the list view is visible - setVisibility(View.VISIBLE); - } - - // We are now GONE, so pending layouts will not be dispatched. - // Force one here to make sure that the state of the list matches - // the state of the adapter. - if (mDataChanged) { - this.onLayout(false, getLeft(), getTop(), getRight(), getBottom()); - } - } else { - if (mEmptyView != null) mEmptyView.setVisibility(View.GONE); - setVisibility(View.VISIBLE); - } - } - - /** - * Gets the data associated with the specified position in the list. - * - * @param position Which data to get - * @return The data associated with the specified position in the list - */ - public Object getItemAtPosition(int position) { - T adapter = getAdapter(); - return (adapter == null || position < 0) ? null : adapter.getItem(position); - } - - public long getItemIdAtPosition(int position) { - T adapter = getAdapter(); - return (adapter == null || position < 0) ? INVALID_ROW_ID : adapter.getItemId(position); - } - - @Override - public void setOnClickListener(OnClickListener l) { - throw new RuntimeException("Don't call setOnClickListener for an AdapterView. " - + "You probably want setOnItemClickListener instead"); - } - - /** - * Override to prevent freezing of any views created by the adapter. - */ - @Override - protected void dispatchSaveInstanceState(SparseArray container) { - dispatchFreezeSelfOnly(container); - } - - /** - * Override to prevent thawing of any views created by the adapter. - */ - @Override - protected void dispatchRestoreInstanceState(SparseArray container) { - dispatchThawSelfOnly(container); - } - - class AdapterDataSetObserver extends DataSetObserver { - - private Parcelable mInstanceState = null; - - @Override - public void onChanged() { - mDataChanged = true; - mOldItemCount = mItemCount; - mItemCount = getAdapter().getCount(); - - // Detect the case where a cursor that was previously invalidated has - // been repopulated with new data. - if (IcsAdapterView.this.getAdapter().hasStableIds() && mInstanceState != null - && mOldItemCount == 0 && mItemCount > 0) { - IcsAdapterView.this.onRestoreInstanceState(mInstanceState); - mInstanceState = null; - } else { - rememberSyncState(); - } - checkFocus(); - requestLayout(); - } - - @Override - public void onInvalidated() { - mDataChanged = true; - - if (IcsAdapterView.this.getAdapter().hasStableIds()) { - // Remember the current state for the case where our hosting activity is being - // stopped and later restarted - mInstanceState = IcsAdapterView.this.onSaveInstanceState(); - } - - // Data is invalid so we should reset our state - mOldItemCount = mItemCount; - mItemCount = 0; - mSelectedPosition = INVALID_POSITION; - mSelectedRowId = INVALID_ROW_ID; - mNextSelectedPosition = INVALID_POSITION; - mNextSelectedRowId = INVALID_ROW_ID; - mNeedSync = false; - - checkFocus(); - requestLayout(); - } - - public void clearSavedState() { - mInstanceState = null; - } - } - - @Override - protected void onDetachedFromWindow() { - super.onDetachedFromWindow(); - removeCallbacks(mSelectionNotifier); - } - - private class SelectionNotifier implements Runnable { - public void run() { - if (mDataChanged) { - // Data has changed between when this SelectionNotifier - // was posted and now. We need to wait until the AdapterView - // has been synched to the new data. - if (getAdapter() != null) { - post(this); - } - } else { - fireOnSelected(); - } - } - } - - void selectionChanged() { - if (mOnItemSelectedListener != null) { - if (mInLayout || mBlockLayoutRequests) { - // If we are in a layout traversal, defer notification - // by posting. This ensures that the view tree is - // in a consistent state and is able to accomodate - // new layout or invalidate requests. - if (mSelectionNotifier == null) { - mSelectionNotifier = new SelectionNotifier(); - } - post(mSelectionNotifier); - } else { - fireOnSelected(); - } - } - - // we fire selection events here not in View - if (mSelectedPosition != ListView.INVALID_POSITION && isShown() && !isInTouchMode()) { - sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED); - } - } - - private void fireOnSelected() { - if (mOnItemSelectedListener == null) - return; - - int selection = this.getSelectedItemPosition(); - if (selection >= 0) { - View v = getSelectedView(); - mOnItemSelectedListener.onItemSelected(this, v, selection, - getAdapter().getItemId(selection)); - } else { - mOnItemSelectedListener.onNothingSelected(this); - } - } - - @Override - public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { - View selectedView = getSelectedView(); - if (selectedView != null && selectedView.getVisibility() == VISIBLE - && selectedView.dispatchPopulateAccessibilityEvent(event)) { - return true; - } - return false; - } - - @Override - public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) { - if (super.onRequestSendAccessibilityEvent(child, event)) { - // Add a record for ourselves as well. - AccessibilityEvent record = AccessibilityEvent.obtain(); - onInitializeAccessibilityEvent(record); - // Populate with the text of the requesting child. - child.dispatchPopulateAccessibilityEvent(record); - event.appendRecord(record); - return true; - } - return false; - } - - @Override - public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfo(info); - info.setScrollable(isScrollableForAccessibility()); - View selectedView = getSelectedView(); - if (selectedView != null) { - info.setEnabled(selectedView.isEnabled()); - } - } - - @Override - public void onInitializeAccessibilityEvent(AccessibilityEvent event) { - super.onInitializeAccessibilityEvent(event); - event.setScrollable(isScrollableForAccessibility()); - View selectedView = getSelectedView(); - if (selectedView != null) { - event.setEnabled(selectedView.isEnabled()); - } - event.setCurrentItemIndex(getSelectedItemPosition()); - event.setFromIndex(getFirstVisiblePosition()); - event.setToIndex(getLastVisiblePosition()); - event.setItemCount(getCount()); - } - - private boolean isScrollableForAccessibility() { - T adapter = getAdapter(); - if (adapter != null) { - final int itemCount = adapter.getCount(); - return itemCount > 0 - && (getFirstVisiblePosition() > 0 || getLastVisiblePosition() < itemCount - 1); - } - return false; - } - - @Override - protected boolean canAnimate() { - return super.canAnimate() && mItemCount > 0; - } - - void handleDataChanged() { - final int count = mItemCount; - boolean found = false; - - if (count > 0) { - - int newPos; - - // Find the row we are supposed to sync to - if (mNeedSync) { - // Update this first, since setNextSelectedPositionInt inspects - // it - mNeedSync = false; - - // See if we can find a position in the new data with the same - // id as the old selection - newPos = findSyncPosition(); - if (newPos >= 0) { - // Verify that new selection is selectable - int selectablePos = lookForSelectablePosition(newPos, true); - if (selectablePos == newPos) { - // Same row id is selected - setNextSelectedPositionInt(newPos); - found = true; - } - } - } - if (!found) { - // Try to use the same position if we can't find matching data - newPos = getSelectedItemPosition(); - - // Pin position to the available range - if (newPos >= count) { - newPos = count - 1; - } - if (newPos < 0) { - newPos = 0; - } - - // Make sure we select something selectable -- first look down - int selectablePos = lookForSelectablePosition(newPos, true); - if (selectablePos < 0) { - // Looking down didn't work -- try looking up - selectablePos = lookForSelectablePosition(newPos, false); - } - if (selectablePos >= 0) { - setNextSelectedPositionInt(selectablePos); - checkSelectionChanged(); - found = true; - } - } - } - if (!found) { - // Nothing is selected - mSelectedPosition = INVALID_POSITION; - mSelectedRowId = INVALID_ROW_ID; - mNextSelectedPosition = INVALID_POSITION; - mNextSelectedRowId = INVALID_ROW_ID; - mNeedSync = false; - checkSelectionChanged(); - } - } - - void checkSelectionChanged() { - if ((mSelectedPosition != mOldSelectedPosition) || (mSelectedRowId != mOldSelectedRowId)) { - selectionChanged(); - mOldSelectedPosition = mSelectedPosition; - mOldSelectedRowId = mSelectedRowId; - } - } - - /** - * Searches the adapter for a position matching mSyncRowId. The search starts at mSyncPosition - * and then alternates between moving up and moving down until 1) we find the right position, or - * 2) we run out of time, or 3) we have looked at every position - * - * @return Position of the row that matches mSyncRowId, or {@link #INVALID_POSITION} if it can't - * be found - */ - int findSyncPosition() { - int count = mItemCount; - - if (count == 0) { - return INVALID_POSITION; - } - - long idToMatch = mSyncRowId; - int seed = mSyncPosition; - - // If there isn't a selection don't hunt for it - if (idToMatch == INVALID_ROW_ID) { - return INVALID_POSITION; - } - - // Pin seed to reasonable values - seed = Math.max(0, seed); - seed = Math.min(count - 1, seed); - - long endTime = SystemClock.uptimeMillis() + SYNC_MAX_DURATION_MILLIS; - - long rowId; - - // first position scanned so far - int first = seed; - - // last position scanned so far - int last = seed; - - // True if we should move down on the next iteration - boolean next = false; - - // True when we have looked at the first item in the data - boolean hitFirst; - - // True when we have looked at the last item in the data - boolean hitLast; - - // Get the item ID locally (instead of getItemIdAtPosition), so - // we need the adapter - T adapter = getAdapter(); - if (adapter == null) { - return INVALID_POSITION; - } - - while (SystemClock.uptimeMillis() <= endTime) { - rowId = adapter.getItemId(seed); - if (rowId == idToMatch) { - // Found it! - return seed; - } - - hitLast = last == count - 1; - hitFirst = first == 0; - - if (hitLast && hitFirst) { - // Looked at everything - break; - } - - if (hitFirst || (next && !hitLast)) { - // Either we hit the top, or we are trying to move down - last++; - seed = last; - // Try going up next time - next = false; - } else if (hitLast || (!next && !hitFirst)) { - // Either we hit the bottom, or we are trying to move up - first--; - seed = first; - // Try going down next time - next = true; - } - - } - - return INVALID_POSITION; - } - - /** - * Find a position that can be selected (i.e., is not a separator). - * - * @param position The starting position to look at. - * @param lookDown Whether to look down for other positions. - * @return The next selectable position starting at position and then searching either up or - * down. Returns {@link #INVALID_POSITION} if nothing can be found. - */ - int lookForSelectablePosition(int position, boolean lookDown) { - return position; - } - - /** - * Utility to keep mSelectedPosition and mSelectedRowId in sync - * @param position Our current position - */ - void setSelectedPositionInt(int position) { - mSelectedPosition = position; - mSelectedRowId = getItemIdAtPosition(position); - } - - /** - * Utility to keep mNextSelectedPosition and mNextSelectedRowId in sync - * @param position Intended value for mSelectedPosition the next time we go - * through layout - */ - void setNextSelectedPositionInt(int position) { - mNextSelectedPosition = position; - mNextSelectedRowId = getItemIdAtPosition(position); - // If we are trying to sync to the selection, update that too - if (mNeedSync && mSyncMode == SYNC_SELECTED_POSITION && position >= 0) { - mSyncPosition = position; - mSyncRowId = mNextSelectedRowId; - } - } - - /** - * Remember enough information to restore the screen state when the data has - * changed. - * - */ - void rememberSyncState() { - if (getChildCount() > 0) { - mNeedSync = true; - mSyncHeight = mLayoutHeight; - if (mSelectedPosition >= 0) { - // Sync the selection state - View v = getChildAt(mSelectedPosition - mFirstPosition); - mSyncRowId = mNextSelectedRowId; - mSyncPosition = mNextSelectedPosition; - if (v != null) { - mSpecificTop = v.getTop(); - } - mSyncMode = SYNC_SELECTED_POSITION; - } else { - // Sync the based on the offset of the first view - View v = getChildAt(0); - T adapter = getAdapter(); - if (mFirstPosition >= 0 && mFirstPosition < adapter.getCount()) { - mSyncRowId = adapter.getItemId(mFirstPosition); - } else { - mSyncRowId = NO_ID; - } - mSyncPosition = mFirstPosition; - if (v != null) { - mSpecificTop = v.getTop(); - } - mSyncMode = SYNC_FIRST_POSITION; - } - } - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java deleted file mode 100644 index 1b4463a59..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java +++ /dev/null @@ -1,272 +0,0 @@ -package com.actionbarsherlock.internal.widget; - -import android.content.Context; -import android.content.res.TypedArray; -import android.graphics.Canvas; -import android.graphics.drawable.Drawable; -import android.util.AttributeSet; -import android.view.View; -import com.actionbarsherlock.internal.nineoldandroids.widget.NineLinearLayout; - -/** - * A simple extension of a regular linear layout that supports the divider API - * of Android 4.0+. The dividers are added adjacent to the children by changing - * their layout params. If you need to rely on the margins which fall in the - * same orientation as the layout you should wrap the child in a simple - * {@link android.widget.FrameLayout} so it can receive the margin. - */ -public class IcsLinearLayout extends NineLinearLayout { - private static final int[] LinearLayout = new int[] { - /* 0 */ android.R.attr.divider, - /* 1 */ android.R.attr.showDividers, - /* 2 */ android.R.attr.dividerPadding, - }; - private static final int LinearLayout_divider = 0; - private static final int LinearLayout_showDividers = 1; - private static final int LinearLayout_dividerPadding = 2; - - /** - * Don't show any dividers. - */ - public static final int SHOW_DIVIDER_NONE = 0; - /** - * Show a divider at the beginning of the group. - */ - public static final int SHOW_DIVIDER_BEGINNING = 1; - /** - * Show dividers between each item in the group. - */ - public static final int SHOW_DIVIDER_MIDDLE = 2; - /** - * Show a divider at the end of the group. - */ - public static final int SHOW_DIVIDER_END = 4; - - - private Drawable mDivider; - private int mDividerWidth; - private int mDividerHeight; - private int mShowDividers; - private int mDividerPadding; - - - public IcsLinearLayout(Context context, AttributeSet attrs) { - super(context, attrs); - - TypedArray a = context.obtainStyledAttributes(attrs, /*com.android.internal.R.styleable.*/LinearLayout); - - setDividerDrawable(a.getDrawable(/*com.android.internal.R.styleable.*/LinearLayout_divider)); - mShowDividers = a.getInt(/*com.android.internal.R.styleable.*/LinearLayout_showDividers, SHOW_DIVIDER_NONE); - mDividerPadding = a.getDimensionPixelSize(/*com.android.internal.R.styleable.*/LinearLayout_dividerPadding, 0); - - a.recycle(); - } - - /** - * Set how dividers should be shown between items in this layout - * - * @param showDividers One or more of {@link #SHOW_DIVIDER_BEGINNING}, - * {@link #SHOW_DIVIDER_MIDDLE}, or {@link #SHOW_DIVIDER_END}, - * or {@link #SHOW_DIVIDER_NONE} to show no dividers. - */ - public void setShowDividers(int showDividers) { - if (showDividers != mShowDividers) { - requestLayout(); - invalidate(); //XXX This is required if you are toggling a divider off - } - mShowDividers = showDividers; - } - - /** - * @return A flag set indicating how dividers should be shown around items. - * @see #setShowDividers(int) - */ - public int getShowDividers() { - return mShowDividers; - } - - /** - * Set a drawable to be used as a divider between items. - * @param divider Drawable that will divide each item. - * @see #setShowDividers(int) - */ - public void setDividerDrawable(Drawable divider) { - if (divider == mDivider) { - return; - } - mDivider = divider; - if (divider != null) { - mDividerWidth = divider.getIntrinsicWidth(); - mDividerHeight = divider.getIntrinsicHeight(); - } else { - mDividerWidth = 0; - mDividerHeight = 0; - } - setWillNotDraw(divider == null); - requestLayout(); - } - - /** - * Set padding displayed on both ends of dividers. - * - * @param padding Padding value in pixels that will be applied to each end - * - * @see #setShowDividers(int) - * @see #setDividerDrawable(Drawable) - * @see #getDividerPadding() - */ - public void setDividerPadding(int padding) { - mDividerPadding = padding; - } - - /** - * Get the padding size used to inset dividers in pixels - * - * @see #setShowDividers(int) - * @see #setDividerDrawable(Drawable) - * @see #setDividerPadding(int) - */ - public int getDividerPadding() { - return mDividerPadding; - } - - /** - * Get the width of the current divider drawable. - * - * @hide Used internally by framework. - */ - public int getDividerWidth() { - return mDividerWidth; - } - - @Override - protected void measureChildWithMargins(View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed) { - final int index = indexOfChild(child); - final int orientation = getOrientation(); - final LayoutParams params = (LayoutParams) child.getLayoutParams(); - if (hasDividerBeforeChildAt(index)) { - if (orientation == VERTICAL) { - //Account for the divider by pushing everything up - params.topMargin = mDividerHeight; - } else { - //Account for the divider by pushing everything left - params.leftMargin = mDividerWidth; - } - } - - final int count = getChildCount(); - if (index == count - 1) { - if (hasDividerBeforeChildAt(count)) { - if (orientation == VERTICAL) { - params.bottomMargin = mDividerHeight; - } else { - params.rightMargin = mDividerWidth; - } - } - } - super.measureChildWithMargins(child, parentWidthMeasureSpec, widthUsed, parentHeightMeasureSpec, heightUsed); - } - - @Override - protected void onDraw(Canvas canvas) { - if (mDivider != null) { - if (getOrientation() == VERTICAL) { - drawDividersVertical(canvas); - } else { - drawDividersHorizontal(canvas); - } - } - super.onDraw(canvas); - } - - void drawDividersVertical(Canvas canvas) { - final int count = getChildCount(); - for (int i = 0; i < count; i++) { - final View child = getChildAt(i); - - if (child != null && child.getVisibility() != GONE) { - if (hasDividerBeforeChildAt(i)) { - final LayoutParams lp = (LayoutParams) child.getLayoutParams(); - final int top = child.getTop() - lp.topMargin/* - mDividerHeight*/; - drawHorizontalDivider(canvas, top); - } - } - } - - if (hasDividerBeforeChildAt(count)) { - final View child = getChildAt(count - 1); - int bottom = 0; - if (child == null) { - bottom = getHeight() - getPaddingBottom() - mDividerHeight; - } else { - final LayoutParams lp = (LayoutParams) child.getLayoutParams(); - bottom = child.getBottom()/* + lp.bottomMargin*/; - } - drawHorizontalDivider(canvas, bottom); - } - } - - void drawDividersHorizontal(Canvas canvas) { - final int count = getChildCount(); - for (int i = 0; i < count; i++) { - final View child = getChildAt(i); - - if (child != null && child.getVisibility() != GONE) { - if (hasDividerBeforeChildAt(i)) { - final LayoutParams lp = (LayoutParams) child.getLayoutParams(); - final int left = child.getLeft() - lp.leftMargin/* - mDividerWidth*/; - drawVerticalDivider(canvas, left); - } - } - } - - if (hasDividerBeforeChildAt(count)) { - final View child = getChildAt(count - 1); - int right = 0; - if (child == null) { - right = getWidth() - getPaddingRight() - mDividerWidth; - } else { - final LayoutParams lp = (LayoutParams) child.getLayoutParams(); - right = child.getRight()/* + lp.rightMargin*/; - } - drawVerticalDivider(canvas, right); - } - } - - void drawHorizontalDivider(Canvas canvas, int top) { - mDivider.setBounds(getPaddingLeft() + mDividerPadding, top, - getWidth() - getPaddingRight() - mDividerPadding, top + mDividerHeight); - mDivider.draw(canvas); - } - - void drawVerticalDivider(Canvas canvas, int left) { - mDivider.setBounds(left, getPaddingTop() + mDividerPadding, - left + mDividerWidth, getHeight() - getPaddingBottom() - mDividerPadding); - mDivider.draw(canvas); - } - - /** - * Determines where to position dividers between children. - * - * @param childIndex Index of child to check for preceding divider - * @return true if there should be a divider before the child at childIndex - * @hide Pending API consideration. Currently only used internally by the system. - */ - protected boolean hasDividerBeforeChildAt(int childIndex) { - if (childIndex == 0) { - return (mShowDividers & SHOW_DIVIDER_BEGINNING) != 0; - } else if (childIndex == getChildCount()) { - return (mShowDividers & SHOW_DIVIDER_END) != 0; - } else if ((mShowDividers & SHOW_DIVIDER_MIDDLE) != 0) { - boolean hasVisibleViewBefore = false; - for (int i = childIndex - 1; i >= 0; i--) { - if (getChildAt(i).getVisibility() != GONE) { - hasVisibleViewBefore = true; - break; - } - } - return hasVisibleViewBefore; - } - return false; - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsListPopupWindow.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsListPopupWindow.java deleted file mode 100644 index d13c6cea9..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsListPopupWindow.java +++ /dev/null @@ -1,644 +0,0 @@ -package com.actionbarsherlock.internal.widget; - -import com.actionbarsherlock.R; - -import android.content.Context; -import android.content.res.Resources; -import android.database.DataSetObserver; -import android.graphics.Rect; -import android.graphics.drawable.Drawable; -import android.os.Build; -import android.os.Handler; -import android.util.AttributeSet; -import android.view.ContextThemeWrapper; -import android.view.MotionEvent; -import android.view.View; -import android.view.View.MeasureSpec; -import android.view.View.OnTouchListener; -import android.view.ViewGroup; -import android.view.ViewParent; -import android.widget.AbsListView; -import android.widget.AdapterView; -import android.widget.LinearLayout; -import android.widget.ListAdapter; -import android.widget.ListView; -import android.widget.PopupWindow; - -/** - * A proxy between pre- and post-Honeycomb implementations of this class. - */ -public class IcsListPopupWindow { - /** - * This value controls the length of time that the user - * must leave a pointer down without scrolling to expand - * the autocomplete dropdown list to cover the IME. - */ - private static final int EXPAND_LIST_TIMEOUT = 250; - - private Context mContext; - private PopupWindow mPopup; - private ListAdapter mAdapter; - private DropDownListView mDropDownList; - - private int mDropDownHeight = ViewGroup.LayoutParams.WRAP_CONTENT; - private int mDropDownWidth = ViewGroup.LayoutParams.WRAP_CONTENT; - private int mDropDownHorizontalOffset; - private int mDropDownVerticalOffset; - private boolean mDropDownVerticalOffsetSet; - - private int mListItemExpandMaximum = Integer.MAX_VALUE; - - private View mPromptView; - private int mPromptPosition = POSITION_PROMPT_ABOVE; - - private DataSetObserver mObserver; - - private View mDropDownAnchorView; - - private Drawable mDropDownListHighlight; - - private AdapterView.OnItemClickListener mItemClickListener; - private AdapterView.OnItemSelectedListener mItemSelectedListener; - - private final ResizePopupRunnable mResizePopupRunnable = new ResizePopupRunnable(); - private final PopupTouchInterceptor mTouchInterceptor = new PopupTouchInterceptor(); - private final PopupScrollListener mScrollListener = new PopupScrollListener(); - private final ListSelectorHider mHideSelector = new ListSelectorHider(); - - private Handler mHandler = new Handler(); - - private Rect mTempRect = new Rect(); - - private boolean mModal; - - public static final int POSITION_PROMPT_ABOVE = 0; - public static final int POSITION_PROMPT_BELOW = 1; - - public IcsListPopupWindow(Context context) { - this(context, null, R.attr.listPopupWindowStyle); - } - - public IcsListPopupWindow(Context context, AttributeSet attrs, int defStyleAttr) { - mContext = context; - mPopup = new PopupWindow(context, attrs, defStyleAttr); - mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED); - } - - public IcsListPopupWindow(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { - mContext = context; - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { - Context wrapped = new ContextThemeWrapper(context, defStyleRes); - mPopup = new PopupWindow(wrapped, attrs, defStyleAttr); - } else { - mPopup = new PopupWindow(context, attrs, defStyleAttr, defStyleRes); - } - mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED); - } - - public void setAdapter(ListAdapter adapter) { - if (mObserver == null) { - mObserver = new PopupDataSetObserver(); - } else if (mAdapter != null) { - mAdapter.unregisterDataSetObserver(mObserver); - } - mAdapter = adapter; - if (mAdapter != null) { - adapter.registerDataSetObserver(mObserver); - } - - if (mDropDownList != null) { - mDropDownList.setAdapter(mAdapter); - } - } - - public void setPromptPosition(int position) { - mPromptPosition = position; - } - - public void setModal(boolean modal) { - mModal = true; - mPopup.setFocusable(modal); - } - - public void setBackgroundDrawable(Drawable d) { - mPopup.setBackgroundDrawable(d); - } - - public void setAnchorView(View anchor) { - mDropDownAnchorView = anchor; - } - - public void setHorizontalOffset(int offset) { - mDropDownHorizontalOffset = offset; - } - - public void setVerticalOffset(int offset) { - mDropDownVerticalOffset = offset; - mDropDownVerticalOffsetSet = true; - } - - public void setContentWidth(int width) { - Drawable popupBackground = mPopup.getBackground(); - if (popupBackground != null) { - popupBackground.getPadding(mTempRect); - mDropDownWidth = mTempRect.left + mTempRect.right + width; - } else { - mDropDownWidth = width; - } - } - - public void setOnItemClickListener(AdapterView.OnItemClickListener clickListener) { - mItemClickListener = clickListener; - } - - public void show() { - int height = buildDropDown(); - - int widthSpec = 0; - int heightSpec = 0; - - boolean noInputMethod = isInputMethodNotNeeded(); - //XXX mPopup.setAllowScrollingAnchorParent(!noInputMethod); - - if (mPopup.isShowing()) { - if (mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT) { - // The call to PopupWindow's update method below can accept -1 for any - // value you do not want to update. - widthSpec = -1; - } else if (mDropDownWidth == ViewGroup.LayoutParams.WRAP_CONTENT) { - widthSpec = mDropDownAnchorView.getWidth(); - } else { - widthSpec = mDropDownWidth; - } - - if (mDropDownHeight == ViewGroup.LayoutParams.MATCH_PARENT) { - // The call to PopupWindow's update method below can accept -1 for any - // value you do not want to update. - heightSpec = noInputMethod ? height : ViewGroup.LayoutParams.MATCH_PARENT; - if (noInputMethod) { - mPopup.setWindowLayoutMode( - mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT ? - ViewGroup.LayoutParams.MATCH_PARENT : 0, 0); - } else { - mPopup.setWindowLayoutMode( - mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT ? - ViewGroup.LayoutParams.MATCH_PARENT : 0, - ViewGroup.LayoutParams.MATCH_PARENT); - } - } else if (mDropDownHeight == ViewGroup.LayoutParams.WRAP_CONTENT) { - heightSpec = height; - } else { - heightSpec = mDropDownHeight; - } - - mPopup.setOutsideTouchable(true); - - mPopup.update(mDropDownAnchorView, mDropDownHorizontalOffset, - mDropDownVerticalOffset, widthSpec, heightSpec); - } else { - if (mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT) { - widthSpec = ViewGroup.LayoutParams.MATCH_PARENT; - } else { - if (mDropDownWidth == ViewGroup.LayoutParams.WRAP_CONTENT) { - mPopup.setWidth(mDropDownAnchorView.getWidth()); - } else { - mPopup.setWidth(mDropDownWidth); - } - } - - if (mDropDownHeight == ViewGroup.LayoutParams.MATCH_PARENT) { - heightSpec = ViewGroup.LayoutParams.MATCH_PARENT; - } else { - if (mDropDownHeight == ViewGroup.LayoutParams.WRAP_CONTENT) { - mPopup.setHeight(height); - } else { - mPopup.setHeight(mDropDownHeight); - } - } - - mPopup.setWindowLayoutMode(widthSpec, heightSpec); - //XXX mPopup.setClipToScreenEnabled(true); - - // use outside touchable to dismiss drop down when touching outside of it, so - // only set this if the dropdown is not always visible - mPopup.setOutsideTouchable(true); - mPopup.setTouchInterceptor(mTouchInterceptor); - mPopup.showAsDropDown(mDropDownAnchorView, - mDropDownHorizontalOffset, mDropDownVerticalOffset); - mDropDownList.setSelection(ListView.INVALID_POSITION); - - if (!mModal || mDropDownList.isInTouchMode()) { - clearListSelection(); - } - if (!mModal) { - mHandler.post(mHideSelector); - } - } - } - - public void dismiss() { - mPopup.dismiss(); - if (mPromptView != null) { - final ViewParent parent = mPromptView.getParent(); - if (parent instanceof ViewGroup) { - final ViewGroup group = (ViewGroup) parent; - group.removeView(mPromptView); - } - } - mPopup.setContentView(null); - mDropDownList = null; - mHandler.removeCallbacks(mResizePopupRunnable); - } - - public void setOnDismissListener(PopupWindow.OnDismissListener listener) { - mPopup.setOnDismissListener(listener); - } - - public void setInputMethodMode(int mode) { - mPopup.setInputMethodMode(mode); - } - - public void clearListSelection() { - final DropDownListView list = mDropDownList; - if (list != null) { - // WARNING: Please read the comment where mListSelectionHidden is declared - list.mListSelectionHidden = true; - //XXX list.hideSelector(); - list.requestLayout(); - } - } - - public boolean isShowing() { - return mPopup.isShowing(); - } - - private boolean isInputMethodNotNeeded() { - return mPopup.getInputMethodMode() == PopupWindow.INPUT_METHOD_NOT_NEEDED; - } - - public ListView getListView() { - return mDropDownList; - } - - private int buildDropDown() { - ViewGroup dropDownView; - int otherHeights = 0; - - if (mDropDownList == null) { - Context context = mContext; - - mDropDownList = new DropDownListView(context, !mModal); - if (mDropDownListHighlight != null) { - mDropDownList.setSelector(mDropDownListHighlight); - } - mDropDownList.setAdapter(mAdapter); - mDropDownList.setOnItemClickListener(mItemClickListener); - mDropDownList.setFocusable(true); - mDropDownList.setFocusableInTouchMode(true); - mDropDownList.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { - public void onItemSelected(AdapterView parent, View view, - int position, long id) { - - if (position != -1) { - DropDownListView dropDownList = mDropDownList; - - if (dropDownList != null) { - dropDownList.mListSelectionHidden = false; - } - } - } - - public void onNothingSelected(AdapterView parent) { - } - }); - mDropDownList.setOnScrollListener(mScrollListener); - - if (mItemSelectedListener != null) { - mDropDownList.setOnItemSelectedListener(mItemSelectedListener); - } - - dropDownView = mDropDownList; - - View hintView = mPromptView; - if (hintView != null) { - // if an hint has been specified, we accomodate more space for it and - // add a text view in the drop down menu, at the bottom of the list - LinearLayout hintContainer = new LinearLayout(context); - hintContainer.setOrientation(LinearLayout.VERTICAL); - - LinearLayout.LayoutParams hintParams = new LinearLayout.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, 0, 1.0f - ); - - switch (mPromptPosition) { - case POSITION_PROMPT_BELOW: - hintContainer.addView(dropDownView, hintParams); - hintContainer.addView(hintView); - break; - - case POSITION_PROMPT_ABOVE: - hintContainer.addView(hintView); - hintContainer.addView(dropDownView, hintParams); - break; - - default: - break; - } - - // measure the hint's height to find how much more vertical space - // we need to add to the drop down's height - int widthSpec = MeasureSpec.makeMeasureSpec(mDropDownWidth, MeasureSpec.AT_MOST); - int heightSpec = MeasureSpec.UNSPECIFIED; - hintView.measure(widthSpec, heightSpec); - - hintParams = (LinearLayout.LayoutParams) hintView.getLayoutParams(); - otherHeights = hintView.getMeasuredHeight() + hintParams.topMargin - + hintParams.bottomMargin; - - dropDownView = hintContainer; - } - - mPopup.setContentView(dropDownView); - } else { - dropDownView = (ViewGroup) mPopup.getContentView(); - final View view = mPromptView; - if (view != null) { - LinearLayout.LayoutParams hintParams = - (LinearLayout.LayoutParams) view.getLayoutParams(); - otherHeights = view.getMeasuredHeight() + hintParams.topMargin - + hintParams.bottomMargin; - } - } - - // getMaxAvailableHeight() subtracts the padding, so we put it back - // to get the available height for the whole window - int padding = 0; - Drawable background = mPopup.getBackground(); - if (background != null) { - background.getPadding(mTempRect); - padding = mTempRect.top + mTempRect.bottom; - - // If we don't have an explicit vertical offset, determine one from the window - // background so that content will line up. - if (!mDropDownVerticalOffsetSet) { - mDropDownVerticalOffset = -mTempRect.top; - } - } - - // Max height available on the screen for a popup. - boolean ignoreBottomDecorations = - mPopup.getInputMethodMode() == PopupWindow.INPUT_METHOD_NOT_NEEDED; - final int maxHeight = /*mPopup.*/getMaxAvailableHeight( - mDropDownAnchorView, mDropDownVerticalOffset, ignoreBottomDecorations); - - if (mDropDownHeight == ViewGroup.LayoutParams.MATCH_PARENT) { - return maxHeight + padding; - } - - final int listContent = /*mDropDownList.*/measureHeightOfChildren(MeasureSpec.UNSPECIFIED, - 0, -1/*ListView.NO_POSITION*/, maxHeight - otherHeights, -1); - // add padding only if the list has items in it, that way we don't show - // the popup if it is not needed - if (listContent > 0) otherHeights += padding; - - return listContent + otherHeights; - } - - private int getMaxAvailableHeight(View anchor, int yOffset, boolean ignoreBottomDecorations) { - final Rect displayFrame = new Rect(); - anchor.getWindowVisibleDisplayFrame(displayFrame); - - final int[] anchorPos = new int[2]; - anchor.getLocationOnScreen(anchorPos); - - int bottomEdge = displayFrame.bottom; - if (ignoreBottomDecorations) { - Resources res = anchor.getContext().getResources(); - bottomEdge = res.getDisplayMetrics().heightPixels; - } - final int distanceToBottom = bottomEdge - (anchorPos[1] + anchor.getHeight()) - yOffset; - final int distanceToTop = anchorPos[1] - displayFrame.top + yOffset; - - // anchorPos[1] is distance from anchor to top of screen - int returnedHeight = Math.max(distanceToBottom, distanceToTop); - if (mPopup.getBackground() != null) { - mPopup.getBackground().getPadding(mTempRect); - returnedHeight -= mTempRect.top + mTempRect.bottom; - } - - return returnedHeight; - } - - private int measureHeightOfChildren(int widthMeasureSpec, int startPosition, int endPosition, - final int maxHeight, int disallowPartialChildPosition) { - - final ListAdapter adapter = mAdapter; - if (adapter == null) { - return mDropDownList.getListPaddingTop() + mDropDownList.getListPaddingBottom(); - } - - // Include the padding of the list - int returnedHeight = mDropDownList.getListPaddingTop() + mDropDownList.getListPaddingBottom(); - final int dividerHeight = ((mDropDownList.getDividerHeight() > 0) && mDropDownList.getDivider() != null) ? mDropDownList.getDividerHeight() : 0; - // The previous height value that was less than maxHeight and contained - // no partial children - int prevHeightWithoutPartialChild = 0; - int i; - View child; - - // mItemCount - 1 since endPosition parameter is inclusive - endPosition = (endPosition == -1/*NO_POSITION*/) ? adapter.getCount() - 1 : endPosition; - - for (i = startPosition; i <= endPosition; ++i) { - child = mAdapter.getView(i, null, mDropDownList); - if (mDropDownList.getCacheColorHint() != 0) { - child.setDrawingCacheBackgroundColor(mDropDownList.getCacheColorHint()); - } - - measureScrapChild(child, i, widthMeasureSpec); - - if (i > 0) { - // Count the divider for all but one child - returnedHeight += dividerHeight; - } - - returnedHeight += child.getMeasuredHeight(); - - if (returnedHeight >= maxHeight) { - // We went over, figure out which height to return. If returnedHeight > maxHeight, - // then the i'th position did not fit completely. - return (disallowPartialChildPosition >= 0) // Disallowing is enabled (> -1) - && (i > disallowPartialChildPosition) // We've past the min pos - && (prevHeightWithoutPartialChild > 0) // We have a prev height - && (returnedHeight != maxHeight) // i'th child did not fit completely - ? prevHeightWithoutPartialChild - : maxHeight; - } - - if ((disallowPartialChildPosition >= 0) && (i >= disallowPartialChildPosition)) { - prevHeightWithoutPartialChild = returnedHeight; - } - } - - // At this point, we went through the range of children, and they each - // completely fit, so return the returnedHeight - return returnedHeight; - } - private void measureScrapChild(View child, int position, int widthMeasureSpec) { - ListView.LayoutParams p = (ListView.LayoutParams) child.getLayoutParams(); - if (p == null) { - p = new ListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT, 0); - child.setLayoutParams(p); - } - //XXX p.viewType = mAdapter.getItemViewType(position); - //XXX p.forceAdd = true; - - int childWidthSpec = ViewGroup.getChildMeasureSpec(widthMeasureSpec, - mDropDownList.getPaddingLeft() + mDropDownList.getPaddingRight(), p.width); - int lpHeight = p.height; - int childHeightSpec; - if (lpHeight > 0) { - childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight, MeasureSpec.EXACTLY); - } else { - childHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); - } - child.measure(childWidthSpec, childHeightSpec); - } - - private static class DropDownListView extends ListView { - /* - * WARNING: This is a workaround for a touch mode issue. - * - * Touch mode is propagated lazily to windows. This causes problems in - * the following scenario: - * - Type something in the AutoCompleteTextView and get some results - * - Move down with the d-pad to select an item in the list - * - Move up with the d-pad until the selection disappears - * - Type more text in the AutoCompleteTextView *using the soft keyboard* - * and get new results; you are now in touch mode - * - The selection comes back on the first item in the list, even though - * the list is supposed to be in touch mode - * - * Using the soft keyboard triggers the touch mode change but that change - * is propagated to our window only after the first list layout, therefore - * after the list attempts to resurrect the selection. - * - * The trick to work around this issue is to pretend the list is in touch - * mode when we know that the selection should not appear, that is when - * we know the user moved the selection away from the list. - * - * This boolean is set to true whenever we explicitly hide the list's - * selection and reset to false whenever we know the user moved the - * selection back to the list. - * - * When this boolean is true, isInTouchMode() returns true, otherwise it - * returns super.isInTouchMode(). - */ - private boolean mListSelectionHidden; - - private boolean mHijackFocus; - - public DropDownListView(Context context, boolean hijackFocus) { - super(context, null, /*com.android.internal.*/R.attr.dropDownListViewStyle); - mHijackFocus = hijackFocus; - // TODO: Add an API to control this - setCacheColorHint(0); // Transparent, since the background drawable could be anything. - } - - //XXX @Override - //View obtainView(int position, boolean[] isScrap) { - // View view = super.obtainView(position, isScrap); - - // if (view instanceof TextView) { - // ((TextView) view).setHorizontallyScrolling(true); - // } - - // return view; - //} - - @Override - public boolean isInTouchMode() { - // WARNING: Please read the comment where mListSelectionHidden is declared - return (mHijackFocus && mListSelectionHidden) || super.isInTouchMode(); - } - - @Override - public boolean hasWindowFocus() { - return mHijackFocus || super.hasWindowFocus(); - } - - @Override - public boolean isFocused() { - return mHijackFocus || super.isFocused(); - } - - @Override - public boolean hasFocus() { - return mHijackFocus || super.hasFocus(); - } - } - - private class PopupDataSetObserver extends DataSetObserver { - @Override - public void onChanged() { - if (isShowing()) { - // Resize the popup to fit new content - show(); - } - } - - @Override - public void onInvalidated() { - dismiss(); - } - } - - private class ListSelectorHider implements Runnable { - public void run() { - clearListSelection(); - } - } - - private class ResizePopupRunnable implements Runnable { - public void run() { - if (mDropDownList != null && mDropDownList.getCount() > mDropDownList.getChildCount() && - mDropDownList.getChildCount() <= mListItemExpandMaximum) { - mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED); - show(); - } - } - } - - private class PopupTouchInterceptor implements OnTouchListener { - public boolean onTouch(View v, MotionEvent event) { - final int action = event.getAction(); - final int x = (int) event.getX(); - final int y = (int) event.getY(); - - if (action == MotionEvent.ACTION_DOWN && - mPopup != null && mPopup.isShowing() && - (x >= 0 && x < mPopup.getWidth() && y >= 0 && y < mPopup.getHeight())) { - mHandler.postDelayed(mResizePopupRunnable, EXPAND_LIST_TIMEOUT); - } else if (action == MotionEvent.ACTION_UP) { - mHandler.removeCallbacks(mResizePopupRunnable); - } - return false; - } - } - - private class PopupScrollListener implements ListView.OnScrollListener { - public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, - int totalItemCount) { - - } - - public void onScrollStateChanged(AbsListView view, int scrollState) { - if (scrollState == SCROLL_STATE_TOUCH_SCROLL && - !isInputMethodNotNeeded() && mPopup.getContentView() != null) { - mHandler.removeCallbacks(mResizePopupRunnable); - mResizePopupRunnable.run(); - } - } - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsProgressBar.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsProgressBar.java deleted file mode 100644 index 1c02d4aca..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsProgressBar.java +++ /dev/null @@ -1,1193 +0,0 @@ -/* - * Copyright (C) 2006 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.actionbarsherlock.internal.widget; - -import android.content.Context; -import android.content.res.TypedArray; -import android.graphics.Bitmap; -import android.graphics.BitmapShader; -import android.graphics.Canvas; -import android.graphics.Rect; -import android.graphics.Shader; -import android.graphics.drawable.Animatable; -import android.graphics.drawable.AnimationDrawable; -import android.graphics.drawable.BitmapDrawable; -import android.graphics.drawable.ClipDrawable; -import android.graphics.drawable.Drawable; -import android.graphics.drawable.LayerDrawable; -import android.graphics.drawable.ShapeDrawable; -import android.graphics.drawable.shapes.RoundRectShape; -import android.graphics.drawable.shapes.Shape; -import android.os.Build; -import android.os.Parcel; -import android.os.Parcelable; -import android.os.SystemClock; -import android.util.AttributeSet; -import android.view.Gravity; -import android.view.View; -import android.view.ViewDebug; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityManager; -import android.view.animation.AlphaAnimation; -import android.view.animation.Animation; -import android.view.animation.AnimationUtils; -import android.view.animation.Interpolator; -import android.view.animation.LinearInterpolator; -import android.view.animation.Transformation; -import android.widget.RemoteViews.RemoteView; - - -/** - *

- * Visual indicator of progress in some operation. Displays a bar to the user - * representing how far the operation has progressed; the application can - * change the amount of progress (modifying the length of the bar) as it moves - * forward. There is also a secondary progress displayable on a progress bar - * which is useful for displaying intermediate progress, such as the buffer - * level during a streaming playback progress bar. - *

- * - *

- * A progress bar can also be made indeterminate. In indeterminate mode, the - * progress bar shows a cyclic animation without an indication of progress. This mode is used by - * applications when the length of the task is unknown. The indeterminate progress bar can be either - * a spinning wheel or a horizontal bar. - *

- * - *

The following code example shows how a progress bar can be used from - * a worker thread to update the user interface to notify the user of progress: - *

- * - *
- * public class MyActivity extends Activity {
- *     private static final int PROGRESS = 0x1;
- *
- *     private ProgressBar mProgress;
- *     private int mProgressStatus = 0;
- *
- *     private Handler mHandler = new Handler();
- *
- *     protected void onCreate(Bundle icicle) {
- *         super.onCreate(icicle);
- *
- *         setContentView(R.layout.progressbar_activity);
- *
- *         mProgress = (ProgressBar) findViewById(R.id.progress_bar);
- *
- *         // Start lengthy operation in a background thread
- *         new Thread(new Runnable() {
- *             public void run() {
- *                 while (mProgressStatus < 100) {
- *                     mProgressStatus = doWork();
- *
- *                     // Update the progress bar
- *                     mHandler.post(new Runnable() {
- *                         public void run() {
- *                             mProgress.setProgress(mProgressStatus);
- *                         }
- *                     });
- *                 }
- *             }
- *         }).start();
- *     }
- * }
- * - *

To add a progress bar to a layout file, you can use the {@code <ProgressBar>} element. - * By default, the progress bar is a spinning wheel (an indeterminate indicator). To change to a - * horizontal progress bar, apply the {@link android.R.style#Widget_ProgressBar_Horizontal - * Widget.ProgressBar.Horizontal} style, like so:

- * - *
- * <ProgressBar
- *     style="@android:style/Widget.ProgressBar.Horizontal"
- *     ... />
- * - *

If you will use the progress bar to show real progress, you must use the horizontal bar. You - * can then increment the progress with {@link #incrementProgressBy incrementProgressBy()} or - * {@link #setProgress setProgress()}. By default, the progress bar is full when it reaches 100. If - * necessary, you can adjust the maximum value (the value for a full bar) using the {@link - * android.R.styleable#ProgressBar_max android:max} attribute. Other attributes available are listed - * below.

- * - *

Another common style to apply to the progress bar is {@link - * android.R.style#Widget_ProgressBar_Small Widget.ProgressBar.Small}, which shows a smaller - * version of the spinning wheel—useful when waiting for content to load. - * For example, you can insert this kind of progress bar into your default layout for - * a view that will be populated by some content fetched from the Internet—the spinning wheel - * appears immediately and when your application receives the content, it replaces the progress bar - * with the loaded content. For example:

- * - *
- * <LinearLayout
- *     android:orientation="horizontal"
- *     ... >
- *     <ProgressBar
- *         android:layout_width="wrap_content"
- *         android:layout_height="wrap_content"
- *         style="@android:style/Widget.ProgressBar.Small"
- *         android:layout_marginRight="5dp" />
- *     <TextView
- *         android:layout_width="wrap_content"
- *         android:layout_height="wrap_content"
- *         android:text="@string/loading" />
- * </LinearLayout>
- * - *

Other progress bar styles provided by the system include:

- *
    - *
  • {@link android.R.style#Widget_ProgressBar_Horizontal Widget.ProgressBar.Horizontal}
  • - *
  • {@link android.R.style#Widget_ProgressBar_Small Widget.ProgressBar.Small}
  • - *
  • {@link android.R.style#Widget_ProgressBar_Large Widget.ProgressBar.Large}
  • - *
  • {@link android.R.style#Widget_ProgressBar_Inverse Widget.ProgressBar.Inverse}
  • - *
  • {@link android.R.style#Widget_ProgressBar_Small_Inverse - * Widget.ProgressBar.Small.Inverse}
  • - *
  • {@link android.R.style#Widget_ProgressBar_Large_Inverse - * Widget.ProgressBar.Large.Inverse}
  • - *
- *

The "inverse" styles provide an inverse color scheme for the spinner, which may be necessary - * if your application uses a light colored theme (a white background).

- * - *

XML attributes - *

- * See {@link android.R.styleable#ProgressBar ProgressBar Attributes}, - * {@link android.R.styleable#View View Attributes} - *

- * - * @attr ref android.R.styleable#ProgressBar_animationResolution - * @attr ref android.R.styleable#ProgressBar_indeterminate - * @attr ref android.R.styleable#ProgressBar_indeterminateBehavior - * @attr ref android.R.styleable#ProgressBar_indeterminateDrawable - * @attr ref android.R.styleable#ProgressBar_indeterminateDuration - * @attr ref android.R.styleable#ProgressBar_indeterminateOnly - * @attr ref android.R.styleable#ProgressBar_interpolator - * @attr ref android.R.styleable#ProgressBar_max - * @attr ref android.R.styleable#ProgressBar_maxHeight - * @attr ref android.R.styleable#ProgressBar_maxWidth - * @attr ref android.R.styleable#ProgressBar_minHeight - * @attr ref android.R.styleable#ProgressBar_minWidth - * @attr ref android.R.styleable#ProgressBar_progress - * @attr ref android.R.styleable#ProgressBar_progressDrawable - * @attr ref android.R.styleable#ProgressBar_secondaryProgress - */ -@RemoteView -public class IcsProgressBar extends View { - private static final boolean IS_HONEYCOMB = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB; - private static final int MAX_LEVEL = 10000; - private static final int ANIMATION_RESOLUTION = 200; - private static final int TIMEOUT_SEND_ACCESSIBILITY_EVENT = 200; - - private static final int[] ProgressBar = new int[] { - android.R.attr.maxWidth, - android.R.attr.maxHeight, - android.R.attr.max, - android.R.attr.progress, - android.R.attr.secondaryProgress, - android.R.attr.indeterminate, - android.R.attr.indeterminateOnly, - android.R.attr.indeterminateDrawable, - android.R.attr.progressDrawable, - android.R.attr.indeterminateDuration, - android.R.attr.indeterminateBehavior, - android.R.attr.minWidth, - android.R.attr.minHeight, - android.R.attr.interpolator, - android.R.attr.animationResolution, - }; - private static final int ProgressBar_maxWidth = 0; - private static final int ProgressBar_maxHeight = 1; - private static final int ProgressBar_max = 2; - private static final int ProgressBar_progress = 3; - private static final int ProgressBar_secondaryProgress = 4; - private static final int ProgressBar_indeterminate = 5; - private static final int ProgressBar_indeterminateOnly = 6; - private static final int ProgressBar_indeterminateDrawable = 7; - private static final int ProgressBar_progressDrawable = 8; - private static final int ProgressBar_indeterminateDuration = 9; - private static final int ProgressBar_indeterminateBehavior = 10; - private static final int ProgressBar_minWidth = 11; - private static final int ProgressBar_minHeight = 12; - private static final int ProgressBar_interpolator = 13; - private static final int ProgressBar_animationResolution = 14; - - int mMinWidth; - int mMaxWidth; - int mMinHeight; - int mMaxHeight; - - private int mProgress; - private int mSecondaryProgress; - private int mMax; - - private int mBehavior; - private int mDuration; - private boolean mIndeterminate; - private boolean mOnlyIndeterminate; - private Transformation mTransformation; - private AlphaAnimation mAnimation; - private Drawable mIndeterminateDrawable; - private int mIndeterminateRealLeft; - private int mIndeterminateRealTop; - private Drawable mProgressDrawable; - private Drawable mCurrentDrawable; - Bitmap mSampleTile; - private boolean mNoInvalidate; - private Interpolator mInterpolator; - private RefreshProgressRunnable mRefreshProgressRunnable; - private long mUiThreadId; - private boolean mShouldStartAnimationDrawable; - private long mLastDrawTime; - - private boolean mInDrawing; - - private int mAnimationResolution; - - private AccessibilityManager mAccessibilityManager; - private AccessibilityEventSender mAccessibilityEventSender; - - /** - * Create a new progress bar with range 0...100 and initial progress of 0. - * @param context the application environment - */ - public IcsProgressBar(Context context) { - this(context, null); - } - - public IcsProgressBar(Context context, AttributeSet attrs) { - this(context, attrs, android.R.attr.progressBarStyle); - } - - public IcsProgressBar(Context context, AttributeSet attrs, int defStyle) { - this(context, attrs, defStyle, 0); - } - - /** - * @hide - */ - public IcsProgressBar(Context context, AttributeSet attrs, int defStyle, int styleRes) { - super(context, attrs, defStyle); - mUiThreadId = Thread.currentThread().getId(); - initProgressBar(); - - TypedArray a = - context.obtainStyledAttributes(attrs, /*R.styleable.*/ProgressBar, defStyle, styleRes); - - mNoInvalidate = true; - - Drawable drawable = a.getDrawable(/*R.styleable.*/ProgressBar_progressDrawable); - if (drawable != null) { - drawable = tileify(drawable, false); - // Calling this method can set mMaxHeight, make sure the corresponding - // XML attribute for mMaxHeight is read after calling this method - setProgressDrawable(drawable); - } - - - mDuration = a.getInt(/*R.styleable.*/ProgressBar_indeterminateDuration, mDuration); - - mMinWidth = a.getDimensionPixelSize(/*R.styleable.*/ProgressBar_minWidth, mMinWidth); - mMaxWidth = a.getDimensionPixelSize(/*R.styleable.*/ProgressBar_maxWidth, mMaxWidth); - mMinHeight = a.getDimensionPixelSize(/*R.styleable.*/ProgressBar_minHeight, mMinHeight); - mMaxHeight = a.getDimensionPixelSize(/*R.styleable.*/ProgressBar_maxHeight, mMaxHeight); - - mBehavior = a.getInt(/*R.styleable.*/ProgressBar_indeterminateBehavior, mBehavior); - - final int resID = a.getResourceId( - /*com.android.internal.R.styleable.*/ProgressBar_interpolator, - android.R.anim.linear_interpolator); // default to linear interpolator - if (resID > 0) { - setInterpolator(context, resID); - } - - setMax(a.getInt(/*R.styleable.*/ProgressBar_max, mMax)); - - setProgress(a.getInt(/*R.styleable.*/ProgressBar_progress, mProgress)); - - setSecondaryProgress( - a.getInt(/*R.styleable.*/ProgressBar_secondaryProgress, mSecondaryProgress)); - - drawable = a.getDrawable(/*R.styleable.*/ProgressBar_indeterminateDrawable); - if (drawable != null) { - drawable = tileifyIndeterminate(drawable); - setIndeterminateDrawable(drawable); - } - - mOnlyIndeterminate = a.getBoolean( - /*R.styleable.*/ProgressBar_indeterminateOnly, mOnlyIndeterminate); - - mNoInvalidate = false; - - setIndeterminate(mOnlyIndeterminate || a.getBoolean( - /*R.styleable.*/ProgressBar_indeterminate, mIndeterminate)); - - mAnimationResolution = a.getInteger(/*R.styleable.*/ProgressBar_animationResolution, - ANIMATION_RESOLUTION); - - a.recycle(); - - mAccessibilityManager = (AccessibilityManager)context.getSystemService(Context.ACCESSIBILITY_SERVICE); - } - - /** - * Converts a drawable to a tiled version of itself. It will recursively - * traverse layer and state list drawables. - */ - private Drawable tileify(Drawable drawable, boolean clip) { - - if (drawable instanceof LayerDrawable) { - LayerDrawable background = (LayerDrawable) drawable; - final int N = background.getNumberOfLayers(); - Drawable[] outDrawables = new Drawable[N]; - - for (int i = 0; i < N; i++) { - int id = background.getId(i); - outDrawables[i] = tileify(background.getDrawable(i), - (id == android.R.id.progress || id == android.R.id.secondaryProgress)); - } - - LayerDrawable newBg = new LayerDrawable(outDrawables); - - for (int i = 0; i < N; i++) { - newBg.setId(i, background.getId(i)); - } - - return newBg; - - }/* else if (drawable instanceof StateListDrawable) { - StateListDrawable in = (StateListDrawable) drawable; - StateListDrawable out = new StateListDrawable(); - int numStates = in.getStateCount(); - for (int i = 0; i < numStates; i++) { - out.addState(in.getStateSet(i), tileify(in.getStateDrawable(i), clip)); - } - return out; - - }*/ else if (drawable instanceof BitmapDrawable) { - final Bitmap tileBitmap = ((BitmapDrawable) drawable).getBitmap(); - if (mSampleTile == null) { - mSampleTile = tileBitmap; - } - - final ShapeDrawable shapeDrawable = new ShapeDrawable(getDrawableShape()); - - final BitmapShader bitmapShader = new BitmapShader(tileBitmap, - Shader.TileMode.REPEAT, Shader.TileMode.CLAMP); - shapeDrawable.getPaint().setShader(bitmapShader); - - return (clip) ? new ClipDrawable(shapeDrawable, Gravity.LEFT, - ClipDrawable.HORIZONTAL) : shapeDrawable; - } - - return drawable; - } - - Shape getDrawableShape() { - final float[] roundedCorners = new float[] { 5, 5, 5, 5, 5, 5, 5, 5 }; - return new RoundRectShape(roundedCorners, null, null); - } - - /** - * Convert a AnimationDrawable for use as a barberpole animation. - * Each frame of the animation is wrapped in a ClipDrawable and - * given a tiling BitmapShader. - */ - private Drawable tileifyIndeterminate(Drawable drawable) { - if (drawable instanceof AnimationDrawable) { - AnimationDrawable background = (AnimationDrawable) drawable; - final int N = background.getNumberOfFrames(); - AnimationDrawable newBg = new AnimationDrawable(); - newBg.setOneShot(background.isOneShot()); - - for (int i = 0; i < N; i++) { - Drawable frame = tileify(background.getFrame(i), true); - frame.setLevel(10000); - newBg.addFrame(frame, background.getDuration(i)); - } - newBg.setLevel(10000); - drawable = newBg; - } - return drawable; - } - - /** - *

- * Initialize the progress bar's default values: - *

- *
    - *
  • progress = 0
  • - *
  • max = 100
  • - *
  • animation duration = 4000 ms
  • - *
  • indeterminate = false
  • - *
  • behavior = repeat
  • - *
- */ - private void initProgressBar() { - mMax = 100; - mProgress = 0; - mSecondaryProgress = 0; - mIndeterminate = false; - mOnlyIndeterminate = false; - mDuration = 4000; - mBehavior = AlphaAnimation.RESTART; - mMinWidth = 24; - mMaxWidth = 48; - mMinHeight = 24; - mMaxHeight = 48; - } - - /** - *

Indicate whether this progress bar is in indeterminate mode.

- * - * @return true if the progress bar is in indeterminate mode - */ - @ViewDebug.ExportedProperty(category = "progress") - public synchronized boolean isIndeterminate() { - return mIndeterminate; - } - - /** - *

Change the indeterminate mode for this progress bar. In indeterminate - * mode, the progress is ignored and the progress bar shows an infinite - * animation instead.

- * - * If this progress bar's style only supports indeterminate mode (such as the circular - * progress bars), then this will be ignored. - * - * @param indeterminate true to enable the indeterminate mode - */ - public synchronized void setIndeterminate(boolean indeterminate) { - if ((!mOnlyIndeterminate || !mIndeterminate) && indeterminate != mIndeterminate) { - mIndeterminate = indeterminate; - - if (indeterminate) { - // swap between indeterminate and regular backgrounds - mCurrentDrawable = mIndeterminateDrawable; - startAnimation(); - } else { - mCurrentDrawable = mProgressDrawable; - stopAnimation(); - } - } - } - - /** - *

Get the drawable used to draw the progress bar in - * indeterminate mode.

- * - * @return a {@link android.graphics.drawable.Drawable} instance - * - * @see #setIndeterminateDrawable(android.graphics.drawable.Drawable) - * @see #setIndeterminate(boolean) - */ - public Drawable getIndeterminateDrawable() { - return mIndeterminateDrawable; - } - - /** - *

Define the drawable used to draw the progress bar in - * indeterminate mode.

- * - * @param d the new drawable - * - * @see #getIndeterminateDrawable() - * @see #setIndeterminate(boolean) - */ - public void setIndeterminateDrawable(Drawable d) { - if (d != null) { - d.setCallback(this); - } - mIndeterminateDrawable = d; - if (mIndeterminate) { - mCurrentDrawable = d; - postInvalidate(); - } - } - - /** - *

Get the drawable used to draw the progress bar in - * progress mode.

- * - * @return a {@link android.graphics.drawable.Drawable} instance - * - * @see #setProgressDrawable(android.graphics.drawable.Drawable) - * @see #setIndeterminate(boolean) - */ - public Drawable getProgressDrawable() { - return mProgressDrawable; - } - - /** - *

Define the drawable used to draw the progress bar in - * progress mode.

- * - * @param d the new drawable - * - * @see #getProgressDrawable() - * @see #setIndeterminate(boolean) - */ - public void setProgressDrawable(Drawable d) { - boolean needUpdate; - if (mProgressDrawable != null && d != mProgressDrawable) { - mProgressDrawable.setCallback(null); - needUpdate = true; - } else { - needUpdate = false; - } - - if (d != null) { - d.setCallback(this); - - // Make sure the ProgressBar is always tall enough - int drawableHeight = d.getMinimumHeight(); - if (mMaxHeight < drawableHeight) { - mMaxHeight = drawableHeight; - requestLayout(); - } - } - mProgressDrawable = d; - if (!mIndeterminate) { - mCurrentDrawable = d; - postInvalidate(); - } - - if (needUpdate) { - updateDrawableBounds(getWidth(), getHeight()); - updateDrawableState(); - doRefreshProgress(android.R.id.progress, mProgress, false, false); - doRefreshProgress(android.R.id.secondaryProgress, mSecondaryProgress, false, false); - } - } - - /** - * @return The drawable currently used to draw the progress bar - */ - Drawable getCurrentDrawable() { - return mCurrentDrawable; - } - - @Override - protected boolean verifyDrawable(Drawable who) { - return who == mProgressDrawable || who == mIndeterminateDrawable - || super.verifyDrawable(who); - } - - @Override - public void jumpDrawablesToCurrentState() { - super.jumpDrawablesToCurrentState(); - if (mProgressDrawable != null) mProgressDrawable.jumpToCurrentState(); - if (mIndeterminateDrawable != null) mIndeterminateDrawable.jumpToCurrentState(); - } - - @Override - public void postInvalidate() { - if (!mNoInvalidate) { - super.postInvalidate(); - } - } - - private class RefreshProgressRunnable implements Runnable { - - private int mId; - private int mProgress; - private boolean mFromUser; - - RefreshProgressRunnable(int id, int progress, boolean fromUser) { - mId = id; - mProgress = progress; - mFromUser = fromUser; - } - - public void run() { - doRefreshProgress(mId, mProgress, mFromUser, true); - // Put ourselves back in the cache when we are done - mRefreshProgressRunnable = this; - } - - public void setup(int id, int progress, boolean fromUser) { - mId = id; - mProgress = progress; - mFromUser = fromUser; - } - - } - - private synchronized void doRefreshProgress(int id, int progress, boolean fromUser, - boolean callBackToApp) { - float scale = mMax > 0 ? (float) progress / (float) mMax : 0; - final Drawable d = mCurrentDrawable; - if (d != null) { - Drawable progressDrawable = null; - - if (d instanceof LayerDrawable) { - progressDrawable = ((LayerDrawable) d).findDrawableByLayerId(id); - } - - final int level = (int) (scale * MAX_LEVEL); - (progressDrawable != null ? progressDrawable : d).setLevel(level); - } else { - invalidate(); - } - - if (callBackToApp && id == android.R.id.progress) { - onProgressRefresh(scale, fromUser); - } - } - - void onProgressRefresh(float scale, boolean fromUser) { - if (mAccessibilityManager.isEnabled()) { - scheduleAccessibilityEventSender(); - } - } - - private synchronized void refreshProgress(int id, int progress, boolean fromUser) { - if (mUiThreadId == Thread.currentThread().getId()) { - doRefreshProgress(id, progress, fromUser, true); - } else { - RefreshProgressRunnable r; - if (mRefreshProgressRunnable != null) { - // Use cached RefreshProgressRunnable if available - r = mRefreshProgressRunnable; - // Uncache it - mRefreshProgressRunnable = null; - r.setup(id, progress, fromUser); - } else { - // Make a new one - r = new RefreshProgressRunnable(id, progress, fromUser); - } - post(r); - } - } - - /** - *

Set the current progress to the specified value. Does not do anything - * if the progress bar is in indeterminate mode.

- * - * @param progress the new progress, between 0 and {@link #getMax()} - * - * @see #setIndeterminate(boolean) - * @see #isIndeterminate() - * @see #getProgress() - * @see #incrementProgressBy(int) - */ - public synchronized void setProgress(int progress) { - setProgress(progress, false); - } - - synchronized void setProgress(int progress, boolean fromUser) { - if (mIndeterminate) { - return; - } - - if (progress < 0) { - progress = 0; - } - - if (progress > mMax) { - progress = mMax; - } - - if (progress != mProgress) { - mProgress = progress; - refreshProgress(android.R.id.progress, mProgress, fromUser); - } - } - - /** - *

- * Set the current secondary progress to the specified value. Does not do - * anything if the progress bar is in indeterminate mode. - *

- * - * @param secondaryProgress the new secondary progress, between 0 and {@link #getMax()} - * @see #setIndeterminate(boolean) - * @see #isIndeterminate() - * @see #getSecondaryProgress() - * @see #incrementSecondaryProgressBy(int) - */ - public synchronized void setSecondaryProgress(int secondaryProgress) { - if (mIndeterminate) { - return; - } - - if (secondaryProgress < 0) { - secondaryProgress = 0; - } - - if (secondaryProgress > mMax) { - secondaryProgress = mMax; - } - - if (secondaryProgress != mSecondaryProgress) { - mSecondaryProgress = secondaryProgress; - refreshProgress(android.R.id.secondaryProgress, mSecondaryProgress, false); - } - } - - /** - *

Get the progress bar's current level of progress. Return 0 when the - * progress bar is in indeterminate mode.

- * - * @return the current progress, between 0 and {@link #getMax()} - * - * @see #setIndeterminate(boolean) - * @see #isIndeterminate() - * @see #setProgress(int) - * @see #setMax(int) - * @see #getMax() - */ - @ViewDebug.ExportedProperty(category = "progress") - public synchronized int getProgress() { - return mIndeterminate ? 0 : mProgress; - } - - /** - *

Get the progress bar's current level of secondary progress. Return 0 when the - * progress bar is in indeterminate mode.

- * - * @return the current secondary progress, between 0 and {@link #getMax()} - * - * @see #setIndeterminate(boolean) - * @see #isIndeterminate() - * @see #setSecondaryProgress(int) - * @see #setMax(int) - * @see #getMax() - */ - @ViewDebug.ExportedProperty(category = "progress") - public synchronized int getSecondaryProgress() { - return mIndeterminate ? 0 : mSecondaryProgress; - } - - /** - *

Return the upper limit of this progress bar's range.

- * - * @return a positive integer - * - * @see #setMax(int) - * @see #getProgress() - * @see #getSecondaryProgress() - */ - @ViewDebug.ExportedProperty(category = "progress") - public synchronized int getMax() { - return mMax; - } - - /** - *

Set the range of the progress bar to 0...max.

- * - * @param max the upper range of this progress bar - * - * @see #getMax() - * @see #setProgress(int) - * @see #setSecondaryProgress(int) - */ - public synchronized void setMax(int max) { - if (max < 0) { - max = 0; - } - if (max != mMax) { - mMax = max; - postInvalidate(); - - if (mProgress > max) { - mProgress = max; - } - refreshProgress(android.R.id.progress, mProgress, false); - } - } - - /** - *

Increase the progress bar's progress by the specified amount.

- * - * @param diff the amount by which the progress must be increased - * - * @see #setProgress(int) - */ - public synchronized final void incrementProgressBy(int diff) { - setProgress(mProgress + diff); - } - - /** - *

Increase the progress bar's secondary progress by the specified amount.

- * - * @param diff the amount by which the secondary progress must be increased - * - * @see #setSecondaryProgress(int) - */ - public synchronized final void incrementSecondaryProgressBy(int diff) { - setSecondaryProgress(mSecondaryProgress + diff); - } - - /** - *

Start the indeterminate progress animation.

- */ - void startAnimation() { - if (getVisibility() != VISIBLE) { - return; - } - - if (mIndeterminateDrawable instanceof Animatable) { - mShouldStartAnimationDrawable = true; - mAnimation = null; - } else { - if (mInterpolator == null) { - mInterpolator = new LinearInterpolator(); - } - - mTransformation = new Transformation(); - mAnimation = new AlphaAnimation(0.0f, 1.0f); - mAnimation.setRepeatMode(mBehavior); - mAnimation.setRepeatCount(Animation.INFINITE); - mAnimation.setDuration(mDuration); - mAnimation.setInterpolator(mInterpolator); - mAnimation.setStartTime(Animation.START_ON_FIRST_FRAME); - } - postInvalidate(); - } - - /** - *

Stop the indeterminate progress animation.

- */ - void stopAnimation() { - mAnimation = null; - mTransformation = null; - if (mIndeterminateDrawable instanceof Animatable) { - ((Animatable) mIndeterminateDrawable).stop(); - mShouldStartAnimationDrawable = false; - } - postInvalidate(); - } - - /** - * Sets the acceleration curve for the indeterminate animation. - * The interpolator is loaded as a resource from the specified context. - * - * @param context The application environment - * @param resID The resource identifier of the interpolator to load - */ - public void setInterpolator(Context context, int resID) { - setInterpolator(AnimationUtils.loadInterpolator(context, resID)); - } - - /** - * Sets the acceleration curve for the indeterminate animation. - * Defaults to a linear interpolation. - * - * @param interpolator The interpolator which defines the acceleration curve - */ - public void setInterpolator(Interpolator interpolator) { - mInterpolator = interpolator; - } - - /** - * Gets the acceleration curve type for the indeterminate animation. - * - * @return the {@link Interpolator} associated to this animation - */ - public Interpolator getInterpolator() { - return mInterpolator; - } - - @Override - public void setVisibility(int v) { - if (getVisibility() != v) { - super.setVisibility(v); - - if (mIndeterminate) { - // let's be nice with the UI thread - if (v == GONE || v == INVISIBLE) { - stopAnimation(); - } else { - startAnimation(); - } - } - } - } - - @Override - protected void onVisibilityChanged(View changedView, int visibility) { - super.onVisibilityChanged(changedView, visibility); - - if (mIndeterminate) { - // let's be nice with the UI thread - if (visibility == GONE || visibility == INVISIBLE) { - stopAnimation(); - } else { - startAnimation(); - } - } - } - - @Override - public void invalidateDrawable(Drawable dr) { - if (!mInDrawing) { - if (verifyDrawable(dr)) { - final Rect dirty = dr.getBounds(); - final int scrollX = getScrollX() + getPaddingLeft(); - final int scrollY = getScrollY() + getPaddingTop(); - - invalidate(dirty.left + scrollX, dirty.top + scrollY, - dirty.right + scrollX, dirty.bottom + scrollY); - } else { - super.invalidateDrawable(dr); - } - } - } - - /** - * @hide - * - @Override - public int getResolvedLayoutDirection(Drawable who) { - return (who == mProgressDrawable || who == mIndeterminateDrawable) ? - getResolvedLayoutDirection() : super.getResolvedLayoutDirection(who); - } - */ - - @Override - protected void onSizeChanged(int w, int h, int oldw, int oldh) { - updateDrawableBounds(w, h); - } - - private void updateDrawableBounds(int w, int h) { - // onDraw will translate the canvas so we draw starting at 0,0 - int right = w - getPaddingRight() - getPaddingLeft(); - int bottom = h - getPaddingBottom() - getPaddingTop(); - int top = 0; - int left = 0; - - if (mIndeterminateDrawable != null) { - // Aspect ratio logic does not apply to AnimationDrawables - if (mOnlyIndeterminate && !(mIndeterminateDrawable instanceof AnimationDrawable)) { - // Maintain aspect ratio. Certain kinds of animated drawables - // get very confused otherwise. - final int intrinsicWidth = mIndeterminateDrawable.getIntrinsicWidth(); - final int intrinsicHeight = mIndeterminateDrawable.getIntrinsicHeight(); - final float intrinsicAspect = (float) intrinsicWidth / intrinsicHeight; - final float boundAspect = (float) w / h; - if (intrinsicAspect != boundAspect) { - if (boundAspect > intrinsicAspect) { - // New width is larger. Make it smaller to match height. - final int width = (int) (h * intrinsicAspect); - left = (w - width) / 2; - right = left + width; - } else { - // New height is larger. Make it smaller to match width. - final int height = (int) (w * (1 / intrinsicAspect)); - top = (h - height) / 2; - bottom = top + height; - } - } - } - mIndeterminateDrawable.setBounds(0, 0, right - left, bottom - top); - mIndeterminateRealLeft = left; - mIndeterminateRealTop = top; - } - - if (mProgressDrawable != null) { - mProgressDrawable.setBounds(0, 0, right, bottom); - } - } - - @Override - protected synchronized void onDraw(Canvas canvas) { - super.onDraw(canvas); - - Drawable d = mCurrentDrawable; - if (d != null) { - // Translate canvas so a indeterminate circular progress bar with padding - // rotates properly in its animation - canvas.save(); - canvas.translate(getPaddingLeft() + mIndeterminateRealLeft, getPaddingTop() + mIndeterminateRealTop); - long time = getDrawingTime(); - if (mAnimation != null) { - mAnimation.getTransformation(time, mTransformation); - float scale = mTransformation.getAlpha(); - try { - mInDrawing = true; - d.setLevel((int) (scale * MAX_LEVEL)); - } finally { - mInDrawing = false; - } - if (SystemClock.uptimeMillis() - mLastDrawTime >= mAnimationResolution) { - mLastDrawTime = SystemClock.uptimeMillis(); - postInvalidateDelayed(mAnimationResolution); - } - } - d.draw(canvas); - canvas.restore(); - if (mShouldStartAnimationDrawable && d instanceof Animatable) { - ((Animatable) d).start(); - mShouldStartAnimationDrawable = false; - } - } - } - - @Override - protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - Drawable d = mCurrentDrawable; - - int dw = 0; - int dh = 0; - if (d != null) { - dw = Math.max(mMinWidth, Math.min(mMaxWidth, d.getIntrinsicWidth())); - dh = Math.max(mMinHeight, Math.min(mMaxHeight, d.getIntrinsicHeight())); - } - updateDrawableState(); - dw += getPaddingLeft() + getPaddingRight(); - dh += getPaddingTop() + getPaddingBottom(); - - if (IS_HONEYCOMB) { - setMeasuredDimension(View.resolveSizeAndState(dw, widthMeasureSpec, 0), - View.resolveSizeAndState(dh, heightMeasureSpec, 0)); - } else { - setMeasuredDimension(View.resolveSize(dw, widthMeasureSpec), - View.resolveSize(dh, heightMeasureSpec)); - } - } - - @Override - protected void drawableStateChanged() { - super.drawableStateChanged(); - updateDrawableState(); - } - - private void updateDrawableState() { - int[] state = getDrawableState(); - - if (mProgressDrawable != null && mProgressDrawable.isStateful()) { - mProgressDrawable.setState(state); - } - - if (mIndeterminateDrawable != null && mIndeterminateDrawable.isStateful()) { - mIndeterminateDrawable.setState(state); - } - } - - static class SavedState extends BaseSavedState { - int progress; - int secondaryProgress; - - /** - * Constructor called from {@link IcsProgressBar#onSaveInstanceState()} - */ - SavedState(Parcelable superState) { - super(superState); - } - - /** - * Constructor called from {@link #CREATOR} - */ - private SavedState(Parcel in) { - super(in); - progress = in.readInt(); - secondaryProgress = in.readInt(); - } - - @Override - public void writeToParcel(Parcel out, int flags) { - super.writeToParcel(out, flags); - out.writeInt(progress); - out.writeInt(secondaryProgress); - } - - public static final Parcelable.Creator CREATOR - = new Parcelable.Creator() { - public SavedState createFromParcel(Parcel in) { - return new SavedState(in); - } - - public SavedState[] newArray(int size) { - return new SavedState[size]; - } - }; - } - - @Override - public Parcelable onSaveInstanceState() { - // Force our ancestor class to save its state - Parcelable superState = super.onSaveInstanceState(); - SavedState ss = new SavedState(superState); - - ss.progress = mProgress; - ss.secondaryProgress = mSecondaryProgress; - - return ss; - } - - @Override - public void onRestoreInstanceState(Parcelable state) { - SavedState ss = (SavedState) state; - super.onRestoreInstanceState(ss.getSuperState()); - - setProgress(ss.progress); - setSecondaryProgress(ss.secondaryProgress); - } - - @Override - protected void onAttachedToWindow() { - super.onAttachedToWindow(); - if (mIndeterminate) { - startAnimation(); - } - } - - @Override - protected void onDetachedFromWindow() { - if (mIndeterminate) { - stopAnimation(); - } - if(mRefreshProgressRunnable != null) { - removeCallbacks(mRefreshProgressRunnable); - } - if (mAccessibilityEventSender != null) { - removeCallbacks(mAccessibilityEventSender); - } - // This should come after stopAnimation(), otherwise an invalidate message remains in the - // queue, which can prevent the entire view hierarchy from being GC'ed during a rotation - super.onDetachedFromWindow(); - } - - @Override - public void onInitializeAccessibilityEvent(AccessibilityEvent event) { - super.onInitializeAccessibilityEvent(event); - event.setItemCount(mMax); - event.setCurrentItemIndex(mProgress); - } - - /** - * Schedule a command for sending an accessibility event. - *
- * Note: A command is used to ensure that accessibility events - * are sent at most one in a given time frame to save - * system resources while the progress changes quickly. - */ - private void scheduleAccessibilityEventSender() { - if (mAccessibilityEventSender == null) { - mAccessibilityEventSender = new AccessibilityEventSender(); - } else { - removeCallbacks(mAccessibilityEventSender); - } - postDelayed(mAccessibilityEventSender, TIMEOUT_SEND_ACCESSIBILITY_EVENT); - } - - /** - * Command for sending an accessibility event. - */ - private class AccessibilityEventSender implements Runnable { - public void run() { - sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED); - } - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsSpinner.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsSpinner.java deleted file mode 100644 index 038d1e031..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsSpinner.java +++ /dev/null @@ -1,703 +0,0 @@ -/* - * Copyright (C) 2007 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.actionbarsherlock.internal.widget; - -import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; -import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; -import com.actionbarsherlock.R; -import android.content.Context; -import android.content.DialogInterface; -import android.content.DialogInterface.OnClickListener; -import android.content.res.TypedArray; -import android.database.DataSetObserver; -import android.graphics.Rect; -import android.graphics.drawable.Drawable; -import android.util.AttributeSet; -import android.view.Gravity; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemClickListener; -import android.widget.ListAdapter; -import android.widget.ListView; -import android.widget.PopupWindow; -import android.widget.SpinnerAdapter; - - -/** - * A view that displays one child at a time and lets the user pick among them. - * The items in the Spinner come from the {@link Adapter} associated with - * this view. - * - *

See the Spinner - * tutorial.

- * - * @attr ref android.R.styleable#Spinner_prompt - */ -public class IcsSpinner extends IcsAbsSpinner implements OnClickListener { - //private static final String TAG = "Spinner"; - - // Only measure this many items to get a decent max width. - private static final int MAX_ITEMS_MEASURED = 15; - - /** - * Use a dialog window for selecting spinner options. - */ - //public static final int MODE_DIALOG = 0; - - /** - * Use a dropdown anchored to the Spinner for selecting spinner options. - */ - public static final int MODE_DROPDOWN = 1; - - /** - * Use the theme-supplied value to select the dropdown mode. - */ - //private static final int MODE_THEME = -1; - - private SpinnerPopup mPopup; - private DropDownAdapter mTempAdapter; - int mDropDownWidth; - - private int mGravity; - private boolean mDisableChildrenWhenDisabled; - - private Rect mTempRect = new Rect(); - - public IcsSpinner(Context context, AttributeSet attrs) { - this(context, attrs, R.attr.actionDropDownStyle); - } - - /** - * Construct a new spinner with the given context's theme, the supplied attribute set, - * and default style. - * - * @param context The Context the view is running in, through which it can - * access the current theme, resources, etc. - * @param attrs The attributes of the XML tag that is inflating the view. - * @param defStyle The default style to apply to this view. If 0, no style - * will be applied (beyond what is included in the theme). This may - * either be an attribute resource, whose value will be retrieved - * from the current theme, or an explicit style resource. - */ - public IcsSpinner(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - - TypedArray a = context.obtainStyledAttributes(attrs, - R.styleable.SherlockSpinner, defStyle, 0); - - - DropdownPopup popup = new DropdownPopup(context, attrs, defStyle); - - mDropDownWidth = a.getLayoutDimension( - R.styleable.SherlockSpinner_android_dropDownWidth, - ViewGroup.LayoutParams.WRAP_CONTENT); - popup.setBackgroundDrawable(a.getDrawable( - R.styleable.SherlockSpinner_android_popupBackground)); - final int verticalOffset = a.getDimensionPixelOffset( - R.styleable.SherlockSpinner_android_dropDownVerticalOffset, 0); - if (verticalOffset != 0) { - popup.setVerticalOffset(verticalOffset); - } - - final int horizontalOffset = a.getDimensionPixelOffset( - R.styleable.SherlockSpinner_android_dropDownHorizontalOffset, 0); - if (horizontalOffset != 0) { - popup.setHorizontalOffset(horizontalOffset); - } - - mPopup = popup; - - mGravity = a.getInt(R.styleable.SherlockSpinner_android_gravity, Gravity.CENTER); - - mPopup.setPromptText(a.getString(R.styleable.SherlockSpinner_android_prompt)); - - mDisableChildrenWhenDisabled = true; - - a.recycle(); - - // Base constructor can call setAdapter before we initialize mPopup. - // Finish setting things up if this happened. - if (mTempAdapter != null) { - mPopup.setAdapter(mTempAdapter); - mTempAdapter = null; - } - } - - @Override - public void setEnabled(boolean enabled) { - super.setEnabled(enabled); - if (mDisableChildrenWhenDisabled) { - final int count = getChildCount(); - for (int i = 0; i < count; i++) { - getChildAt(i).setEnabled(enabled); - } - } - } - - /** - * Describes how the selected item view is positioned. Currently only the horizontal component - * is used. The default is determined by the current theme. - * - * @param gravity See {@link android.view.Gravity} - * - * @attr ref android.R.styleable#Spinner_gravity - */ - public void setGravity(int gravity) { - if (mGravity != gravity) { - if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == 0) { - gravity |= Gravity.LEFT; - } - mGravity = gravity; - requestLayout(); - } - } - - @Override - public void setAdapter(SpinnerAdapter adapter) { - super.setAdapter(adapter); - - if (mPopup != null) { - mPopup.setAdapter(new DropDownAdapter(adapter)); - } else { - mTempAdapter = new DropDownAdapter(adapter); - } - } - - @Override - public int getBaseline() { - View child = null; - - if (getChildCount() > 0) { - child = getChildAt(0); - } else if (mAdapter != null && mAdapter.getCount() > 0) { - child = makeAndAddView(0); - mRecycler.put(0, child); - removeAllViewsInLayout(); - } - - if (child != null) { - final int childBaseline = child.getBaseline(); - return childBaseline >= 0 ? child.getTop() + childBaseline : -1; - } else { - return -1; - } - } - - @Override - protected void onDetachedFromWindow() { - super.onDetachedFromWindow(); - - if (mPopup != null && mPopup.isShowing()) { - mPopup.dismiss(); - } - } - - /** - *

A spinner does not support item click events. Calling this method - * will raise an exception.

- * - * @param l this listener will be ignored - */ - @Override - public void setOnItemClickListener(OnItemClickListener l) { - throw new RuntimeException("setOnItemClickListener cannot be used with a spinner."); - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - if (mPopup != null && MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.AT_MOST) { - final int measuredWidth = getMeasuredWidth(); - setMeasuredDimension(Math.min(Math.max(measuredWidth, - measureContentWidth(getAdapter(), getBackground())), - MeasureSpec.getSize(widthMeasureSpec)), - getMeasuredHeight()); - } - } - - /** - * @see android.view.View#onLayout(boolean,int,int,int,int) - * - * Creates and positions all views - * - */ - @Override - protected void onLayout(boolean changed, int l, int t, int r, int b) { - super.onLayout(changed, l, t, r, b); - mInLayout = true; - layout(0, false); - mInLayout = false; - } - - /** - * Creates and positions all views for this Spinner. - * - * @param delta Change in the selected position. +1 moves selection is moving to the right, - * so views are scrolling to the left. -1 means selection is moving to the left. - */ - @Override - void layout(int delta, boolean animate) { - int childrenLeft = mSpinnerPadding.left; - int childrenWidth = getRight() - getLeft() - mSpinnerPadding.left - mSpinnerPadding.right; - - if (mDataChanged) { - handleDataChanged(); - } - - // Handle the empty set by removing all views - if (mItemCount == 0) { - resetList(); - return; - } - - if (mNextSelectedPosition >= 0) { - setSelectedPositionInt(mNextSelectedPosition); - } - - recycleAllViews(); - - // Clear out old views - removeAllViewsInLayout(); - - // Make selected view and position it - mFirstPosition = mSelectedPosition; - View sel = makeAndAddView(mSelectedPosition); - int width = sel.getMeasuredWidth(); - int selectedOffset = childrenLeft; - switch (mGravity & Gravity.HORIZONTAL_GRAVITY_MASK) { - case Gravity.CENTER_HORIZONTAL: - selectedOffset = childrenLeft + (childrenWidth / 2) - (width / 2); - break; - case Gravity.RIGHT: - selectedOffset = childrenLeft + childrenWidth - width; - break; - } - sel.offsetLeftAndRight(selectedOffset); - - // Flush any cached views that did not get reused above - mRecycler.clear(); - - invalidate(); - - checkSelectionChanged(); - - mDataChanged = false; - mNeedSync = false; - setNextSelectedPositionInt(mSelectedPosition); - } - - /** - * Obtain a view, either by pulling an existing view from the recycler or - * by getting a new one from the adapter. If we are animating, make sure - * there is enough information in the view's layout parameters to animate - * from the old to new positions. - * - * @param position Position in the spinner for the view to obtain - * @return A view that has been added to the spinner - */ - private View makeAndAddView(int position) { - - View child; - - if (!mDataChanged) { - child = mRecycler.get(position); - if (child != null) { - // Position the view - setUpChild(child); - - return child; - } - } - - // Nothing found in the recycler -- ask the adapter for a view - child = mAdapter.getView(position, null, this); - - // Position the view - setUpChild(child); - - return child; - } - - /** - * Helper for makeAndAddView to set the position of a view - * and fill out its layout paramters. - * - * @param child The view to position - */ - private void setUpChild(View child) { - - // Respect layout params that are already in the view. Otherwise - // make some up... - ViewGroup.LayoutParams lp = child.getLayoutParams(); - if (lp == null) { - lp = generateDefaultLayoutParams(); - } - - addViewInLayout(child, 0, lp); - - child.setSelected(hasFocus()); - if (mDisableChildrenWhenDisabled) { - child.setEnabled(isEnabled()); - } - - // Get measure specs - int childHeightSpec = ViewGroup.getChildMeasureSpec(mHeightMeasureSpec, - mSpinnerPadding.top + mSpinnerPadding.bottom, lp.height); - int childWidthSpec = ViewGroup.getChildMeasureSpec(mWidthMeasureSpec, - mSpinnerPadding.left + mSpinnerPadding.right, lp.width); - - // Measure child - child.measure(childWidthSpec, childHeightSpec); - - int childLeft; - int childRight; - - // Position vertically based on gravity setting - int childTop = mSpinnerPadding.top - + ((getMeasuredHeight() - mSpinnerPadding.bottom - - mSpinnerPadding.top - child.getMeasuredHeight()) / 2); - int childBottom = childTop + child.getMeasuredHeight(); - - int width = child.getMeasuredWidth(); - childLeft = 0; - childRight = childLeft + width; - - child.layout(childLeft, childTop, childRight, childBottom); - } - - @Override - public boolean performClick() { - boolean handled = super.performClick(); - - if (!handled) { - handled = true; - - if (!mPopup.isShowing()) { - mPopup.show(); - } - } - - return handled; - } - - public void onClick(DialogInterface dialog, int which) { - setSelection(which); - dialog.dismiss(); - } - - /** - * Sets the prompt to display when the dialog is shown. - * @param prompt the prompt to set - */ - public void setPrompt(CharSequence prompt) { - mPopup.setPromptText(prompt); - } - - /** - * Sets the prompt to display when the dialog is shown. - * @param promptId the resource ID of the prompt to display when the dialog is shown - */ - public void setPromptId(int promptId) { - setPrompt(getContext().getText(promptId)); - } - - /** - * @return The prompt to display when the dialog is shown - */ - public CharSequence getPrompt() { - return mPopup.getHintText(); - } - - int measureContentWidth(SpinnerAdapter adapter, Drawable background) { - if (adapter == null) { - return 0; - } - - int width = 0; - View itemView = null; - int itemType = 0; - final int widthMeasureSpec = - MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); - final int heightMeasureSpec = - MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); - - // Make sure the number of items we'll measure is capped. If it's a huge data set - // with wildly varying sizes, oh well. - int start = Math.max(0, getSelectedItemPosition()); - final int end = Math.min(adapter.getCount(), start + MAX_ITEMS_MEASURED); - final int count = end - start; - start = Math.max(0, start - (MAX_ITEMS_MEASURED - count)); - for (int i = start; i < end; i++) { - final int positionType = adapter.getItemViewType(i); - if (positionType != itemType) { - itemType = positionType; - itemView = null; - } - itemView = adapter.getView(i, itemView, this); - if (itemView.getLayoutParams() == null) { - itemView.setLayoutParams(new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.WRAP_CONTENT, - ViewGroup.LayoutParams.WRAP_CONTENT)); - } - itemView.measure(widthMeasureSpec, heightMeasureSpec); - width = Math.max(width, itemView.getMeasuredWidth()); - } - - // Add background padding to measured width - if (background != null) { - background.getPadding(mTempRect); - width += mTempRect.left + mTempRect.right; - } - - return width; - } - - /** - *

Wrapper class for an Adapter. Transforms the embedded Adapter instance - * into a ListAdapter.

- */ - private static class DropDownAdapter implements ListAdapter, SpinnerAdapter { - private SpinnerAdapter mAdapter; - private ListAdapter mListAdapter; - - /** - *

Creates a new ListAdapter wrapper for the specified adapter.

- * - * @param adapter the Adapter to transform into a ListAdapter - */ - public DropDownAdapter(SpinnerAdapter adapter) { - this.mAdapter = adapter; - if (adapter instanceof ListAdapter) { - this.mListAdapter = (ListAdapter) adapter; - } - } - - public int getCount() { - return mAdapter == null ? 0 : mAdapter.getCount(); - } - - public Object getItem(int position) { - return mAdapter == null ? null : mAdapter.getItem(position); - } - - public long getItemId(int position) { - return mAdapter == null ? -1 : mAdapter.getItemId(position); - } - - public View getView(int position, View convertView, ViewGroup parent) { - return getDropDownView(position, convertView, parent); - } - - public View getDropDownView(int position, View convertView, ViewGroup parent) { - return mAdapter == null ? null : - mAdapter.getDropDownView(position, convertView, parent); - } - - public boolean hasStableIds() { - return mAdapter != null && mAdapter.hasStableIds(); - } - - public void registerDataSetObserver(DataSetObserver observer) { - if (mAdapter != null) { - mAdapter.registerDataSetObserver(observer); - } - } - - public void unregisterDataSetObserver(DataSetObserver observer) { - if (mAdapter != null) { - mAdapter.unregisterDataSetObserver(observer); - } - } - - /** - * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call. - * Otherwise, return true. - */ - public boolean areAllItemsEnabled() { - final ListAdapter adapter = mListAdapter; - if (adapter != null) { - return adapter.areAllItemsEnabled(); - } else { - return true; - } - } - - /** - * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call. - * Otherwise, return true. - */ - public boolean isEnabled(int position) { - final ListAdapter adapter = mListAdapter; - if (adapter != null) { - return adapter.isEnabled(position); - } else { - return true; - } - } - - public int getItemViewType(int position) { - return 0; - } - - public int getViewTypeCount() { - return 1; - } - - public boolean isEmpty() { - return getCount() == 0; - } - } - - /** - * Implements some sort of popup selection interface for selecting a spinner option. - * Allows for different spinner modes. - */ - private interface SpinnerPopup { - public void setAdapter(ListAdapter adapter); - - /** - * Show the popup - */ - public void show(); - - /** - * Dismiss the popup - */ - public void dismiss(); - - /** - * @return true if the popup is showing, false otherwise. - */ - public boolean isShowing(); - - /** - * Set hint text to be displayed to the user. This should provide - * a description of the choice being made. - * @param hintText Hint text to set. - */ - public void setPromptText(CharSequence hintText); - public CharSequence getHintText(); - } - - /* - private class DialogPopup implements SpinnerPopup, DialogInterface.OnClickListener { - private AlertDialog mPopup; - private ListAdapter mListAdapter; - private CharSequence mPrompt; - - public void dismiss() { - mPopup.dismiss(); - mPopup = null; - } - - public boolean isShowing() { - return mPopup != null ? mPopup.isShowing() : false; - } - - public void setAdapter(ListAdapter adapter) { - mListAdapter = adapter; - } - - public void setPromptText(CharSequence hintText) { - mPrompt = hintText; - } - - public CharSequence getHintText() { - return mPrompt; - } - - public void show() { - AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); - if (mPrompt != null) { - builder.setTitle(mPrompt); - } - mPopup = builder.setSingleChoiceItems(mListAdapter, - getSelectedItemPosition(), this).show(); - } - - public void onClick(DialogInterface dialog, int which) { - setSelection(which); - dismiss(); - } - } - */ - - private class DropdownPopup extends IcsListPopupWindow implements SpinnerPopup { - private CharSequence mHintText; - private ListAdapter mAdapter; - - public DropdownPopup(Context context, AttributeSet attrs, int defStyleRes) { - super(context, attrs, 0, defStyleRes); - - setAnchorView(IcsSpinner.this); - setModal(true); - setPromptPosition(POSITION_PROMPT_ABOVE); - setOnItemClickListener(new OnItemClickListener() { - @SuppressWarnings("rawtypes") - public void onItemClick(AdapterView parent, View v, int position, long id) { - IcsSpinner.this.setSelection(position); - dismiss(); - } - }); - } - - @Override - public void setAdapter(ListAdapter adapter) { - super.setAdapter(adapter); - mAdapter = adapter; - } - - public CharSequence getHintText() { - return mHintText; - } - - public void setPromptText(CharSequence hintText) { - // Hint text is ignored for dropdowns, but maintain it here. - mHintText = hintText; - } - - @Override - public void show() { - final int spinnerPaddingLeft = IcsSpinner.this.getPaddingLeft(); - if (mDropDownWidth == WRAP_CONTENT) { - final int spinnerWidth = IcsSpinner.this.getWidth(); - final int spinnerPaddingRight = IcsSpinner.this.getPaddingRight(); - setContentWidth(Math.max( - measureContentWidth((SpinnerAdapter) mAdapter, getBackground()), - spinnerWidth - spinnerPaddingLeft - spinnerPaddingRight)); - } else if (mDropDownWidth == MATCH_PARENT) { - final int spinnerWidth = IcsSpinner.this.getWidth(); - final int spinnerPaddingRight = IcsSpinner.this.getPaddingRight(); - setContentWidth(spinnerWidth - spinnerPaddingLeft - spinnerPaddingRight); - } else { - setContentWidth(mDropDownWidth); - } - final Drawable background = getBackground(); - int bgOffset = 0; - if (background != null) { - background.getPadding(mTempRect); - bgOffset = -mTempRect.left; - } - setHorizontalOffset(bgOffset + spinnerPaddingLeft); - setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED); - super.show(); - getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE); - setSelection(IcsSpinner.this.getSelectedItemPosition()); - } - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsView.java deleted file mode 100644 index a7185d082..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsView.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.actionbarsherlock.internal.widget; - -import android.view.View; - -final class IcsView { - //No instances - private IcsView() {} - - /** - * Return only the state bits of {@link #getMeasuredWidthAndState()} - * and {@link #getMeasuredHeightAndState()}, combined into one integer. - * The width component is in the regular bits {@link #MEASURED_STATE_MASK} - * and the height component is at the shifted bits - * {@link #MEASURED_HEIGHT_STATE_SHIFT}>>{@link #MEASURED_STATE_MASK}. - */ - public static int getMeasuredStateInt(View child) { - return (child.getMeasuredWidth()&View.MEASURED_STATE_MASK) - | ((child.getMeasuredHeight()>>View.MEASURED_HEIGHT_STATE_SHIFT) - & (View.MEASURED_STATE_MASK>>View.MEASURED_HEIGHT_STATE_SHIFT)); - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.java deleted file mode 100644 index 1a532e06c..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.java +++ /dev/null @@ -1,545 +0,0 @@ -/* - * Copyright (C) 2011 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.actionbarsherlock.internal.widget; - -import android.content.Context; -import android.content.res.Configuration; -import android.content.res.TypedArray; -import android.graphics.drawable.Drawable; -import android.text.TextUtils.TruncateAt; -import android.util.AttributeSet; -import android.view.Gravity; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.ViewParent; -import android.view.animation.DecelerateInterpolator; -import android.view.animation.Interpolator; -import android.widget.BaseAdapter; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.ListView; -import com.actionbarsherlock.R; -import com.actionbarsherlock.app.ActionBar; -import com.actionbarsherlock.internal.nineoldandroids.animation.Animator; -import com.actionbarsherlock.internal.nineoldandroids.animation.ObjectAnimator; -import com.actionbarsherlock.internal.nineoldandroids.widget.NineHorizontalScrollView; - -/** - * This widget implements the dynamic action bar tab behavior that can change - * across different configurations or circumstances. - */ -public class ScrollingTabContainerView extends NineHorizontalScrollView - implements IcsAdapterView.OnItemSelectedListener { - //UNUSED private static final String TAG = "ScrollingTabContainerView"; - Runnable mTabSelector; - private TabClickListener mTabClickListener; - - private IcsLinearLayout mTabLayout; - private IcsSpinner mTabSpinner; - private boolean mAllowCollapse; - - private LayoutInflater mInflater; - - int mMaxTabWidth; - private int mContentHeight; - private int mSelectedTabIndex; - - protected Animator mVisibilityAnim; - protected final VisibilityAnimListener mVisAnimListener = new VisibilityAnimListener(); - - private static final /*Time*/Interpolator sAlphaInterpolator = new DecelerateInterpolator(); - - private static final int FADE_DURATION = 200; - - public ScrollingTabContainerView(Context context) { - super(context); - setHorizontalScrollBarEnabled(false); - - TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.SherlockActionBar, - R.attr.actionBarStyle, 0); - setContentHeight(a.getLayoutDimension(R.styleable.SherlockActionBar_height, 0)); - a.recycle(); - - mInflater = LayoutInflater.from(context); - - mTabLayout = createTabLayout(); - addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, - ViewGroup.LayoutParams.MATCH_PARENT)); - } - - @Override - public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - final int widthMode = MeasureSpec.getMode(widthMeasureSpec); - final boolean lockedExpanded = widthMode == MeasureSpec.EXACTLY; - setFillViewport(lockedExpanded); - - final int childCount = mTabLayout.getChildCount(); - if (childCount > 1 && - (widthMode == MeasureSpec.EXACTLY || widthMode == MeasureSpec.AT_MOST)) { - if (childCount > 2) { - mMaxTabWidth = (int) (MeasureSpec.getSize(widthMeasureSpec) * 0.4f); - } else { - mMaxTabWidth = MeasureSpec.getSize(widthMeasureSpec) / 2; - } - } else { - mMaxTabWidth = -1; - } - - heightMeasureSpec = MeasureSpec.makeMeasureSpec(mContentHeight, MeasureSpec.EXACTLY); - - final boolean canCollapse = !lockedExpanded && mAllowCollapse; - - if (canCollapse) { - // See if we should expand - mTabLayout.measure(MeasureSpec.UNSPECIFIED, heightMeasureSpec); - if (mTabLayout.getMeasuredWidth() > MeasureSpec.getSize(widthMeasureSpec)) { - performCollapse(); - } else { - performExpand(); - } - } else { - performExpand(); - } - - final int oldWidth = getMeasuredWidth(); - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - final int newWidth = getMeasuredWidth(); - - if (lockedExpanded && oldWidth != newWidth) { - // Recenter the tab display if we're at a new (scrollable) size. - setTabSelected(mSelectedTabIndex); - } - } - - /** - * Indicates whether this view is collapsed into a dropdown menu instead - * of traditional tabs. - * @return true if showing as a spinner - */ - private boolean isCollapsed() { - return mTabSpinner != null && mTabSpinner.getParent() == this; - } - - public void setAllowCollapse(boolean allowCollapse) { - mAllowCollapse = allowCollapse; - } - - private void performCollapse() { - if (isCollapsed()) return; - - if (mTabSpinner == null) { - mTabSpinner = createSpinner(); - } - removeView(mTabLayout); - addView(mTabSpinner, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, - ViewGroup.LayoutParams.MATCH_PARENT)); - if (mTabSpinner.getAdapter() == null) { - mTabSpinner.setAdapter(new TabAdapter()); - } - if (mTabSelector != null) { - removeCallbacks(mTabSelector); - mTabSelector = null; - } - mTabSpinner.setSelection(mSelectedTabIndex); - } - - private boolean performExpand() { - if (!isCollapsed()) return false; - - removeView(mTabSpinner); - addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, - ViewGroup.LayoutParams.MATCH_PARENT)); - setTabSelected(mTabSpinner.getSelectedItemPosition()); - return false; - } - - public void setTabSelected(int position) { - mSelectedTabIndex = position; - final int tabCount = mTabLayout.getChildCount(); - for (int i = 0; i < tabCount; i++) { - final View child = mTabLayout.getChildAt(i); - final boolean isSelected = i == position; - child.setSelected(isSelected); - if (isSelected) { - animateToTab(position); - } - } - } - - public void setContentHeight(int contentHeight) { - mContentHeight = contentHeight; - requestLayout(); - } - - private IcsLinearLayout createTabLayout() { - final IcsLinearLayout tabLayout = (IcsLinearLayout) LayoutInflater.from(getContext()) - .inflate(R.layout.abs__action_bar_tab_bar_view, null); - tabLayout.setLayoutParams(new LinearLayout.LayoutParams( - LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT)); - return tabLayout; - } - - private IcsSpinner createSpinner() { - final IcsSpinner spinner = new IcsSpinner(getContext(), null, - R.attr.actionDropDownStyle); - spinner.setLayoutParams(new LinearLayout.LayoutParams( - LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT)); - spinner.setOnItemSelectedListener(this); - return spinner; - } - - @Override - protected void onConfigurationChanged(Configuration newConfig) { - super.onConfigurationChanged(newConfig); - - // Action bar can change size on configuration changes. - // Reread the desired height from the theme-specified style. - TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.SherlockActionBar, - R.attr.actionBarStyle, 0); - setContentHeight(a.getLayoutDimension(R.styleable.SherlockActionBar_height, 0)); - a.recycle(); - } - - public void animateToVisibility(int visibility) { - if (mVisibilityAnim != null) { - mVisibilityAnim.cancel(); - } - if (visibility == VISIBLE) { - if (getVisibility() != VISIBLE) { - setAlpha(0); - } - ObjectAnimator anim = ObjectAnimator.ofFloat(this, "alpha", 1); - anim.setDuration(FADE_DURATION); - anim.setInterpolator(sAlphaInterpolator); - - anim.addListener(mVisAnimListener.withFinalVisibility(visibility)); - anim.start(); - } else { - ObjectAnimator anim = ObjectAnimator.ofFloat(this, "alpha", 0); - anim.setDuration(FADE_DURATION); - anim.setInterpolator(sAlphaInterpolator); - - anim.addListener(mVisAnimListener.withFinalVisibility(visibility)); - anim.start(); - } - } - - public void animateToTab(final int position) { - final View tabView = mTabLayout.getChildAt(position); - if (mTabSelector != null) { - removeCallbacks(mTabSelector); - } - mTabSelector = new Runnable() { - public void run() { - final int scrollPos = tabView.getLeft() - (getWidth() - tabView.getWidth()) / 2; - smoothScrollTo(scrollPos, 0); - mTabSelector = null; - } - }; - post(mTabSelector); - } - - @Override - public void onAttachedToWindow() { - super.onAttachedToWindow(); - if (mTabSelector != null) { - // Re-post the selector we saved - post(mTabSelector); - } - } - - @Override - public void onDetachedFromWindow() { - super.onDetachedFromWindow(); - if (mTabSelector != null) { - removeCallbacks(mTabSelector); - } - } - - private TabView createTabView(ActionBar.Tab tab, boolean forAdapter) { - //Workaround for not being able to pass a defStyle on pre-3.0 - final TabView tabView = (TabView)mInflater.inflate(R.layout.abs__action_bar_tab, null); - tabView.init(this, tab, forAdapter); - - if (forAdapter) { - tabView.setBackgroundDrawable(null); - tabView.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, - mContentHeight)); - } else { - tabView.setFocusable(true); - - if (mTabClickListener == null) { - mTabClickListener = new TabClickListener(); - } - tabView.setOnClickListener(mTabClickListener); - } - return tabView; - } - - public void addTab(ActionBar.Tab tab, boolean setSelected) { - TabView tabView = createTabView(tab, false); - mTabLayout.addView(tabView, new IcsLinearLayout.LayoutParams(0, - LayoutParams.MATCH_PARENT, 1)); - if (mTabSpinner != null) { - ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged(); - } - if (setSelected) { - tabView.setSelected(true); - } - if (mAllowCollapse) { - requestLayout(); - } - } - - public void addTab(ActionBar.Tab tab, int position, boolean setSelected) { - final TabView tabView = createTabView(tab, false); - mTabLayout.addView(tabView, position, new IcsLinearLayout.LayoutParams( - 0, LayoutParams.MATCH_PARENT, 1)); - if (mTabSpinner != null) { - ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged(); - } - if (setSelected) { - tabView.setSelected(true); - } - if (mAllowCollapse) { - requestLayout(); - } - } - - public void updateTab(int position) { - ((TabView) mTabLayout.getChildAt(position)).update(); - if (mTabSpinner != null) { - ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged(); - } - if (mAllowCollapse) { - requestLayout(); - } - } - - public void removeTabAt(int position) { - mTabLayout.removeViewAt(position); - if (mTabSpinner != null) { - ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged(); - } - if (mAllowCollapse) { - requestLayout(); - } - } - - public void removeAllTabs() { - mTabLayout.removeAllViews(); - if (mTabSpinner != null) { - ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged(); - } - if (mAllowCollapse) { - requestLayout(); - } - } - - @Override - public void onItemSelected(IcsAdapterView parent, View view, int position, long id) { - TabView tabView = (TabView) view; - tabView.getTab().select(); - } - - @Override - public void onNothingSelected(IcsAdapterView parent) { - } - - public static class TabView extends LinearLayout { - private ScrollingTabContainerView mParent; - private ActionBar.Tab mTab; - private CapitalizingTextView mTextView; - private ImageView mIconView; - private View mCustomView; - - public TabView(Context context, AttributeSet attrs) { - //TODO super(context, null, R.attr.actionBarTabStyle); - super(context, attrs); - } - - public void init(ScrollingTabContainerView parent, ActionBar.Tab tab, boolean forList) { - mParent = parent; - mTab = tab; - - if (forList) { - setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); - } - - update(); - } - - public void bindTab(ActionBar.Tab tab) { - mTab = tab; - update(); - } - - @Override - public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - - // Re-measure if we went beyond our maximum size. - if (mParent.mMaxTabWidth > 0 && getMeasuredWidth() > mParent.mMaxTabWidth) { - super.onMeasure(MeasureSpec.makeMeasureSpec(mParent.mMaxTabWidth, MeasureSpec.EXACTLY), - heightMeasureSpec); - } - } - - public void update() { - final ActionBar.Tab tab = mTab; - final View custom = tab.getCustomView(); - if (custom != null) { - final ViewParent customParent = custom.getParent(); - if (customParent != this) { - if (customParent != null) ((ViewGroup) customParent).removeView(custom); - addView(custom); - } - mCustomView = custom; - if (mTextView != null) mTextView.setVisibility(GONE); - if (mIconView != null) { - mIconView.setVisibility(GONE); - mIconView.setImageDrawable(null); - } - } else { - if (mCustomView != null) { - removeView(mCustomView); - mCustomView = null; - } - - final Drawable icon = tab.getIcon(); - final CharSequence text = tab.getText(); - - if (icon != null) { - if (mIconView == null) { - ImageView iconView = new ImageView(getContext()); - LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, - LayoutParams.WRAP_CONTENT); - lp.gravity = Gravity.CENTER_VERTICAL; - iconView.setLayoutParams(lp); - addView(iconView, 0); - mIconView = iconView; - } - mIconView.setImageDrawable(icon); - mIconView.setVisibility(VISIBLE); - } else if (mIconView != null) { - mIconView.setVisibility(GONE); - mIconView.setImageDrawable(null); - } - - if (text != null) { - if (mTextView == null) { - CapitalizingTextView textView = new CapitalizingTextView(getContext(), null, - R.attr.actionBarTabTextStyle); - textView.setEllipsize(TruncateAt.END); - LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, - LayoutParams.WRAP_CONTENT); - lp.gravity = Gravity.CENTER_VERTICAL; - textView.setLayoutParams(lp); - addView(textView); - mTextView = textView; - } - mTextView.setTextCompat(text); - mTextView.setVisibility(VISIBLE); - } else if (mTextView != null) { - mTextView.setVisibility(GONE); - mTextView.setText(null); - } - - if (mIconView != null) { - mIconView.setContentDescription(tab.getContentDescription()); - } - } - } - - public ActionBar.Tab getTab() { - return mTab; - } - } - - private class TabAdapter extends BaseAdapter { - @Override - public int getCount() { - return mTabLayout.getChildCount(); - } - - @Override - public Object getItem(int position) { - return ((TabView) mTabLayout.getChildAt(position)).getTab(); - } - - @Override - public long getItemId(int position) { - return position; - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - if (convertView == null) { - convertView = createTabView((ActionBar.Tab) getItem(position), true); - } else { - ((TabView) convertView).bindTab((ActionBar.Tab) getItem(position)); - } - return convertView; - } - } - - private class TabClickListener implements OnClickListener { - public void onClick(View view) { - TabView tabView = (TabView) view; - tabView.getTab().select(); - final int tabCount = mTabLayout.getChildCount(); - for (int i = 0; i < tabCount; i++) { - final View child = mTabLayout.getChildAt(i); - child.setSelected(child == view); - } - } - } - - protected class VisibilityAnimListener implements Animator.AnimatorListener { - private boolean mCanceled = false; - private int mFinalVisibility; - - public VisibilityAnimListener withFinalVisibility(int visibility) { - mFinalVisibility = visibility; - return this; - } - - @Override - public void onAnimationStart(Animator animation) { - setVisibility(VISIBLE); - mVisibilityAnim = animation; - mCanceled = false; - } - - @Override - public void onAnimationEnd(Animator animation) { - if (mCanceled) return; - - mVisibilityAnim = null; - setVisibility(mFinalVisibility); - } - - @Override - public void onAnimationCancel(Animator animation) { - mCanceled = true; - } - - @Override - public void onAnimationRepeat(Animator animation) { - } - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/view/ActionMode.java b/actionbarsherlock/src/com/actionbarsherlock/view/ActionMode.java deleted file mode 100644 index 81b4cd4d2..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/view/ActionMode.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (C) 2010 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.actionbarsherlock.view; - -import android.view.View; - - -/** - * Represents a contextual mode of the user interface. Action modes can be used for - * modal interactions with content and replace parts of the normal UI until finished. - * Examples of good action modes include selection modes, search, content editing, etc. - */ -public abstract class ActionMode { - private Object mTag; - - /** - * Set a tag object associated with this ActionMode. - * - *

Like the tag available to views, this allows applications to associate arbitrary - * data with an ActionMode for later reference. - * - * @param tag Tag to associate with this ActionMode - * - * @see #getTag() - */ - public void setTag(Object tag) { - mTag = tag; - } - - /** - * Retrieve the tag object associated with this ActionMode. - * - *

Like the tag available to views, this allows applications to associate arbitrary - * data with an ActionMode for later reference. - * - * @return Tag associated with this ActionMode - * - * @see #setTag(Object) - */ - public Object getTag() { - return mTag; - } - - /** - * Set the title of the action mode. This method will have no visible effect if - * a custom view has been set. - * - * @param title Title string to set - * - * @see #setTitle(int) - * @see #setCustomView(View) - */ - public abstract void setTitle(CharSequence title); - - /** - * Set the title of the action mode. This method will have no visible effect if - * a custom view has been set. - * - * @param resId Resource ID of a string to set as the title - * - * @see #setTitle(CharSequence) - * @see #setCustomView(View) - */ - public abstract void setTitle(int resId); - - /** - * Set the subtitle of the action mode. This method will have no visible effect if - * a custom view has been set. - * - * @param subtitle Subtitle string to set - * - * @see #setSubtitle(int) - * @see #setCustomView(View) - */ - public abstract void setSubtitle(CharSequence subtitle); - - /** - * Set the subtitle of the action mode. This method will have no visible effect if - * a custom view has been set. - * - * @param resId Resource ID of a string to set as the subtitle - * - * @see #setSubtitle(CharSequence) - * @see #setCustomView(View) - */ - public abstract void setSubtitle(int resId); - - /** - * Set a custom view for this action mode. The custom view will take the place of - * the title and subtitle. Useful for things like search boxes. - * - * @param view Custom view to use in place of the title/subtitle. - * - * @see #setTitle(CharSequence) - * @see #setSubtitle(CharSequence) - */ - public abstract void setCustomView(View view); - - /** - * Invalidate the action mode and refresh menu content. The mode's - * {@link ActionMode.Callback} will have its - * {@link Callback#onPrepareActionMode(ActionMode, Menu)} method called. - * If it returns true the menu will be scanned for updated content and any relevant changes - * will be reflected to the user. - */ - public abstract void invalidate(); - - /** - * Finish and close this action mode. The action mode's {@link ActionMode.Callback} will - * have its {@link Callback#onDestroyActionMode(ActionMode)} method called. - */ - public abstract void finish(); - - /** - * Returns the menu of actions that this action mode presents. - * @return The action mode's menu. - */ - public abstract Menu getMenu(); - - /** - * Returns the current title of this action mode. - * @return Title text - */ - public abstract CharSequence getTitle(); - - /** - * Returns the current subtitle of this action mode. - * @return Subtitle text - */ - public abstract CharSequence getSubtitle(); - - /** - * Returns the current custom view for this action mode. - * @return The current custom view - */ - public abstract View getCustomView(); - - /** - * Returns a {@link MenuInflater} with the ActionMode's context. - */ - public abstract MenuInflater getMenuInflater(); - - /** - * Returns whether the UI presenting this action mode can take focus or not. - * This is used by internal components within the framework that would otherwise - * present an action mode UI that requires focus, such as an EditText as a custom view. - * - * @return true if the UI used to show this action mode can take focus - * @hide Internal use only - */ - public boolean isUiFocusable() { - return true; - } - - /** - * Callback interface for action modes. Supplied to - * {@link View#startActionMode(Callback)}, a Callback - * configures and handles events raised by a user's interaction with an action mode. - * - *

An action mode's lifecycle is as follows: - *

    - *
  • {@link Callback#onCreateActionMode(ActionMode, Menu)} once on initial - * creation
  • - *
  • {@link Callback#onPrepareActionMode(ActionMode, Menu)} after creation - * and any time the {@link ActionMode} is invalidated
  • - *
  • {@link Callback#onActionItemClicked(ActionMode, MenuItem)} any time a - * contextual action button is clicked
  • - *
  • {@link Callback#onDestroyActionMode(ActionMode)} when the action mode - * is closed
  • - *
- */ - public interface Callback { - /** - * Called when action mode is first created. The menu supplied will be used to - * generate action buttons for the action mode. - * - * @param mode ActionMode being created - * @param menu Menu used to populate action buttons - * @return true if the action mode should be created, false if entering this - * mode should be aborted. - */ - public boolean onCreateActionMode(ActionMode mode, Menu menu); - - /** - * Called to refresh an action mode's action menu whenever it is invalidated. - * - * @param mode ActionMode being prepared - * @param menu Menu used to populate action buttons - * @return true if the menu or action mode was updated, false otherwise. - */ - public boolean onPrepareActionMode(ActionMode mode, Menu menu); - - /** - * Called to report a user click on an action button. - * - * @param mode The current ActionMode - * @param item The item that was clicked - * @return true if this callback handled the event, false if the standard MenuItem - * invocation should continue. - */ - public boolean onActionItemClicked(ActionMode mode, MenuItem item); - - /** - * Called when an action mode is about to be exited and destroyed. - * - * @param mode The current ActionMode being destroyed - */ - public void onDestroyActionMode(ActionMode mode); - } -} \ No newline at end of file diff --git a/actionbarsherlock/src/com/actionbarsherlock/view/ActionProvider.java b/actionbarsherlock/src/com/actionbarsherlock/view/ActionProvider.java deleted file mode 100644 index ae7cb1fe0..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/view/ActionProvider.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (C) 2011 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.actionbarsherlock.view; - -import android.content.Context; -import android.view.View; - -/** - * This class is a mediator for accomplishing a given task, for example sharing a file. - * It is responsible for creating a view that performs an action that accomplishes the task. - * This class also implements other functions such a performing a default action. - *

- * An ActionProvider can be optionally specified for a {@link MenuItem} and in such a - * case it will be responsible for creating the action view that appears in the - * {@link android.app.ActionBar} as a substitute for the menu item when the item is - * displayed as an action item. Also the provider is responsible for performing a - * default action if a menu item placed on the overflow menu of the ActionBar is - * selected and none of the menu item callbacks has handled the selection. For this - * case the provider can also optionally provide a sub-menu for accomplishing the - * task at hand. - *

- *

- * There are two ways for using an action provider for creating and handling of action views: - *

    - *
  • - * Setting the action provider on a {@link MenuItem} directly by calling - * {@link MenuItem#setActionProvider(ActionProvider)}. - *
  • - *
  • - * Declaring the action provider in the menu XML resource. For example: - *
    - * 
    - *   <item android:id="@+id/my_menu_item"
    - *     android:title="Title"
    - *     android:icon="@drawable/my_menu_item_icon"
    - *     android:showAsAction="ifRoom"
    - *     android:actionProviderClass="foo.bar.SomeActionProvider" />
    - * 
    - * 
    - *
  • - *
- *

- * - * @see MenuItem#setActionProvider(ActionProvider) - * @see MenuItem#getActionProvider() - */ -public abstract class ActionProvider { - private SubUiVisibilityListener mSubUiVisibilityListener; - - /** - * Creates a new instance. - * - * @param context Context for accessing resources. - */ - public ActionProvider(Context context) { - } - - /** - * Factory method for creating new action views. - * - * @return A new action view. - */ - public abstract View onCreateActionView(); - - /** - * Performs an optional default action. - *

- * For the case of an action provider placed in a menu item not shown as an action this - * method is invoked if previous callbacks for processing menu selection has handled - * the event. - *

- *

- * A menu item selection is processed in the following order: - *

    - *
  • - * Receiving a call to {@link MenuItem.OnMenuItemClickListener#onMenuItemClick - * MenuItem.OnMenuItemClickListener.onMenuItemClick}. - *
  • - *
  • - * Receiving a call to {@link android.app.Activity#onOptionsItemSelected(MenuItem) - * Activity.onOptionsItemSelected(MenuItem)} - *
  • - *
  • - * Receiving a call to {@link android.app.Fragment#onOptionsItemSelected(MenuItem) - * Fragment.onOptionsItemSelected(MenuItem)} - *
  • - *
  • - * Launching the {@link android.content.Intent} set via - * {@link MenuItem#setIntent(android.content.Intent) MenuItem.setIntent(android.content.Intent)} - *
  • - *
  • - * Invoking this method. - *
  • - *
- *

- *

- * The default implementation does not perform any action and returns false. - *

- */ - public boolean onPerformDefaultAction() { - return false; - } - - /** - * Determines if this ActionProvider has a submenu associated with it. - * - *

Associated submenus will be shown when an action view is not. This - * provider instance will receive a call to {@link #onPrepareSubMenu(SubMenu)} - * after the call to {@link #onPerformDefaultAction()} and before a submenu is - * displayed to the user. - * - * @return true if the item backed by this provider should have an associated submenu - */ - public boolean hasSubMenu() { - return false; - } - - /** - * Called to prepare an associated submenu for the menu item backed by this ActionProvider. - * - *

if {@link #hasSubMenu()} returns true, this method will be called when the - * menu item is selected to prepare the submenu for presentation to the user. Apps - * may use this to create or alter submenu content right before display. - * - * @param subMenu Submenu that will be displayed - */ - public void onPrepareSubMenu(SubMenu subMenu) { - } - - /** - * Notify the system that the visibility of an action view's sub-UI such as - * an anchored popup has changed. This will affect how other system - * visibility notifications occur. - * - * @hide Pending future API approval - */ - public void subUiVisibilityChanged(boolean isVisible) { - if (mSubUiVisibilityListener != null) { - mSubUiVisibilityListener.onSubUiVisibilityChanged(isVisible); - } - } - - /** - * @hide Internal use only - */ - public void setSubUiVisibilityListener(SubUiVisibilityListener listener) { - mSubUiVisibilityListener = listener; - } - - /** - * @hide Internal use only - */ - public interface SubUiVisibilityListener { - public void onSubUiVisibilityChanged(boolean isVisible); - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/view/CollapsibleActionView.java b/actionbarsherlock/src/com/actionbarsherlock/view/CollapsibleActionView.java deleted file mode 100644 index 43281b013..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/view/CollapsibleActionView.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2011 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.actionbarsherlock.view; - -/** - * When a {@link View} implements this interface it will receive callbacks - * when expanded or collapsed as an action view alongside the optional, - * app-specified callbacks to {@link OnActionExpandListener}. - * - *

See {@link MenuItem} for more information about action views. - * See {@link android.app.ActionBar} for more information about the action bar. - */ -public interface CollapsibleActionView { - /** - * Called when this view is expanded as an action view. - * See {@link MenuItem#expandActionView()}. - */ - public void onActionViewExpanded(); - - /** - * Called when this view is collapsed as an action view. - * See {@link MenuItem#collapseActionView()}. - */ - public void onActionViewCollapsed(); -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/view/Menu.java b/actionbarsherlock/src/com/actionbarsherlock/view/Menu.java deleted file mode 100644 index 951f4ccef..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/view/Menu.java +++ /dev/null @@ -1,447 +0,0 @@ -/* - * Copyright (C) 2006 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.actionbarsherlock.view; - -import android.content.ComponentName; -import android.content.Intent; -import android.view.KeyEvent; - -/** - * Interface for managing the items in a menu. - *

- * By default, every Activity supports an options menu of actions or options. - * You can add items to this menu and handle clicks on your additions. The - * easiest way of adding menu items is inflating an XML file into the - * {@link Menu} via {@link MenuInflater}. The easiest way of attaching code to - * clicks is via {@link Activity#onOptionsItemSelected(MenuItem)} and - * {@link Activity#onContextItemSelected(MenuItem)}. - *

- * Different menu types support different features: - *

    - *
  1. Context menus: Do not support item shortcuts and item icons. - *
  2. Options menus: The icon menus do not support item check - * marks and only show the item's - * {@link MenuItem#setTitleCondensed(CharSequence) condensed title}. The - * expanded menus (only available if six or more menu items are visible, - * reached via the 'More' item in the icon menu) do not show item icons, and - * item check marks are discouraged. - *
  3. Sub menus: Do not support item icons, or nested sub menus. - *
- * - *
- *

Developer Guides

- *

For more information about creating menus, read the - * Menus developer guide.

- *
- */ -public interface Menu { - - /** - * This is the part of an order integer that the user can provide. - * @hide - */ - static final int USER_MASK = 0x0000ffff; - /** - * Bit shift of the user portion of the order integer. - * @hide - */ - static final int USER_SHIFT = 0; - - /** - * This is the part of an order integer that supplies the category of the - * item. - * @hide - */ - static final int CATEGORY_MASK = 0xffff0000; - /** - * Bit shift of the category portion of the order integer. - * @hide - */ - static final int CATEGORY_SHIFT = 16; - - /** - * Value to use for group and item identifier integers when you don't care - * about them. - */ - static final int NONE = 0; - - /** - * First value for group and item identifier integers. - */ - static final int FIRST = 1; - - // Implementation note: Keep these CATEGORY_* in sync with the category enum - // in attrs.xml - - /** - * Category code for the order integer for items/groups that are part of a - * container -- or/add this with your base value. - */ - static final int CATEGORY_CONTAINER = 0x00010000; - - /** - * Category code for the order integer for items/groups that are provided by - * the system -- or/add this with your base value. - */ - static final int CATEGORY_SYSTEM = 0x00020000; - - /** - * Category code for the order integer for items/groups that are - * user-supplied secondary (infrequently used) options -- or/add this with - * your base value. - */ - static final int CATEGORY_SECONDARY = 0x00030000; - - /** - * Category code for the order integer for items/groups that are - * alternative actions on the data that is currently displayed -- or/add - * this with your base value. - */ - static final int CATEGORY_ALTERNATIVE = 0x00040000; - - /** - * Flag for {@link #addIntentOptions}: if set, do not automatically remove - * any existing menu items in the same group. - */ - static final int FLAG_APPEND_TO_GROUP = 0x0001; - - /** - * Flag for {@link #performShortcut}: if set, do not close the menu after - * executing the shortcut. - */ - static final int FLAG_PERFORM_NO_CLOSE = 0x0001; - - /** - * Flag for {@link #performShortcut(int, KeyEvent, int)}: if set, always - * close the menu after executing the shortcut. Closing the menu also resets - * the prepared state. - */ - static final int FLAG_ALWAYS_PERFORM_CLOSE = 0x0002; - - /** - * Add a new item to the menu. This item displays the given title for its - * label. - * - * @param title The text to display for the item. - * @return The newly added menu item. - */ - public MenuItem add(CharSequence title); - - /** - * Add a new item to the menu. This item displays the given title for its - * label. - * - * @param titleRes Resource identifier of title string. - * @return The newly added menu item. - */ - public MenuItem add(int titleRes); - - /** - * Add a new item to the menu. This item displays the given title for its - * label. - * - * @param groupId The group identifier that this item should be part of. - * This can be used to define groups of items for batch state - * changes. Normally use {@link #NONE} if an item should not be in a - * group. - * @param itemId Unique item ID. Use {@link #NONE} if you do not need a - * unique ID. - * @param order The order for the item. Use {@link #NONE} if you do not care - * about the order. See {@link MenuItem#getOrder()}. - * @param title The text to display for the item. - * @return The newly added menu item. - */ - public MenuItem add(int groupId, int itemId, int order, CharSequence title); - - /** - * Variation on {@link #add(int, int, int, CharSequence)} that takes a - * string resource identifier instead of the string itself. - * - * @param groupId The group identifier that this item should be part of. - * This can also be used to define groups of items for batch state - * changes. Normally use {@link #NONE} if an item should not be in a - * group. - * @param itemId Unique item ID. Use {@link #NONE} if you do not need a - * unique ID. - * @param order The order for the item. Use {@link #NONE} if you do not care - * about the order. See {@link MenuItem#getOrder()}. - * @param titleRes Resource identifier of title string. - * @return The newly added menu item. - */ - public MenuItem add(int groupId, int itemId, int order, int titleRes); - - /** - * Add a new sub-menu to the menu. This item displays the given title for - * its label. To modify other attributes on the submenu's menu item, use - * {@link SubMenu#getItem()}. - * - * @param title The text to display for the item. - * @return The newly added sub-menu - */ - SubMenu addSubMenu(final CharSequence title); - - /** - * Add a new sub-menu to the menu. This item displays the given title for - * its label. To modify other attributes on the submenu's menu item, use - * {@link SubMenu#getItem()}. - * - * @param titleRes Resource identifier of title string. - * @return The newly added sub-menu - */ - SubMenu addSubMenu(final int titleRes); - - /** - * Add a new sub-menu to the menu. This item displays the given - * title for its label. To modify other attributes on the - * submenu's menu item, use {@link SubMenu#getItem()}. - *

- * Note that you can only have one level of sub-menus, i.e. you cannnot add - * a subMenu to a subMenu: An {@link UnsupportedOperationException} will be - * thrown if you try. - * - * @param groupId The group identifier that this item should be part of. - * This can also be used to define groups of items for batch state - * changes. Normally use {@link #NONE} if an item should not be in a - * group. - * @param itemId Unique item ID. Use {@link #NONE} if you do not need a - * unique ID. - * @param order The order for the item. Use {@link #NONE} if you do not care - * about the order. See {@link MenuItem#getOrder()}. - * @param title The text to display for the item. - * @return The newly added sub-menu - */ - SubMenu addSubMenu(final int groupId, final int itemId, int order, final CharSequence title); - - /** - * Variation on {@link #addSubMenu(int, int, int, CharSequence)} that takes - * a string resource identifier for the title instead of the string itself. - * - * @param groupId The group identifier that this item should be part of. - * This can also be used to define groups of items for batch state - * changes. Normally use {@link #NONE} if an item should not be in a group. - * @param itemId Unique item ID. Use {@link #NONE} if you do not need a unique ID. - * @param order The order for the item. Use {@link #NONE} if you do not care about the - * order. See {@link MenuItem#getOrder()}. - * @param titleRes Resource identifier of title string. - * @return The newly added sub-menu - */ - SubMenu addSubMenu(int groupId, int itemId, int order, int titleRes); - - /** - * Add a group of menu items corresponding to actions that can be performed - * for a particular Intent. The Intent is most often configured with a null - * action, the data that the current activity is working with, and includes - * either the {@link Intent#CATEGORY_ALTERNATIVE} or - * {@link Intent#CATEGORY_SELECTED_ALTERNATIVE} to find activities that have - * said they would like to be included as optional action. You can, however, - * use any Intent you want. - * - *

- * See {@link android.content.pm.PackageManager#queryIntentActivityOptions} - * for more * details on the caller, specifics, and - * intent arguments. The list returned by that function is used - * to populate the resulting menu items. - * - *

- * All of the menu items of possible options for the intent will be added - * with the given group and id. You can use the group to control ordering of - * the items in relation to other items in the menu. Normally this function - * will automatically remove any existing items in the menu in the same - * group and place a divider above and below the added items; this behavior - * can be modified with the flags parameter. For each of the - * generated items {@link MenuItem#setIntent} is called to associate the - * appropriate Intent with the item; this means the activity will - * automatically be started for you without having to do anything else. - * - * @param groupId The group identifier that the items should be part of. - * This can also be used to define groups of items for batch state - * changes. Normally use {@link #NONE} if the items should not be in - * a group. - * @param itemId Unique item ID. Use {@link #NONE} if you do not need a - * unique ID. - * @param order The order for the items. Use {@link #NONE} if you do not - * care about the order. See {@link MenuItem#getOrder()}. - * @param caller The current activity component name as defined by - * queryIntentActivityOptions(). - * @param specifics Specific items to place first as defined by - * queryIntentActivityOptions(). - * @param intent Intent describing the kinds of items to populate in the - * list as defined by queryIntentActivityOptions(). - * @param flags Additional options controlling how the items are added. - * @param outSpecificItems Optional array in which to place the menu items - * that were generated for each of the specifics that were - * requested. Entries may be null if no activity was found for that - * specific action. - * @return The number of menu items that were added. - * - * @see #FLAG_APPEND_TO_GROUP - * @see MenuItem#setIntent - * @see android.content.pm.PackageManager#queryIntentActivityOptions - */ - public int addIntentOptions(int groupId, int itemId, int order, - ComponentName caller, Intent[] specifics, - Intent intent, int flags, MenuItem[] outSpecificItems); - - /** - * Remove the item with the given identifier. - * - * @param id The item to be removed. If there is no item with this - * identifier, nothing happens. - */ - public void removeItem(int id); - - /** - * Remove all items in the given group. - * - * @param groupId The group to be removed. If there are no items in this - * group, nothing happens. - */ - public void removeGroup(int groupId); - - /** - * Remove all existing items from the menu, leaving it empty as if it had - * just been created. - */ - public void clear(); - - /** - * Control whether a particular group of items can show a check mark. This - * is similar to calling {@link MenuItem#setCheckable} on all of the menu items - * with the given group identifier, but in addition you can control whether - * this group contains a mutually-exclusive set items. This should be called - * after the items of the group have been added to the menu. - * - * @param group The group of items to operate on. - * @param checkable Set to true to allow a check mark, false to - * disallow. The default is false. - * @param exclusive If set to true, only one item in this group can be - * checked at a time; checking an item will automatically - * uncheck all others in the group. If set to false, each - * item can be checked independently of the others. - * - * @see MenuItem#setCheckable - * @see MenuItem#setChecked - */ - public void setGroupCheckable(int group, boolean checkable, boolean exclusive); - - /** - * Show or hide all menu items that are in the given group. - * - * @param group The group of items to operate on. - * @param visible If true the items are visible, else they are hidden. - * - * @see MenuItem#setVisible - */ - public void setGroupVisible(int group, boolean visible); - - /** - * Enable or disable all menu items that are in the given group. - * - * @param group The group of items to operate on. - * @param enabled If true the items will be enabled, else they will be disabled. - * - * @see MenuItem#setEnabled - */ - public void setGroupEnabled(int group, boolean enabled); - - /** - * Return whether the menu currently has item items that are visible. - * - * @return True if there is one or more item visible, - * else false. - */ - public boolean hasVisibleItems(); - - /** - * Return the menu item with a particular identifier. - * - * @param id The identifier to find. - * - * @return The menu item object, or null if there is no item with - * this identifier. - */ - public MenuItem findItem(int id); - - /** - * Get the number of items in the menu. Note that this will change any - * times items are added or removed from the menu. - * - * @return The item count. - */ - public int size(); - - /** - * Gets the menu item at the given index. - * - * @param index The index of the menu item to return. - * @return The menu item. - * @exception IndexOutOfBoundsException - * when {@code index < 0 || >= size()} - */ - public MenuItem getItem(int index); - - /** - * Closes the menu, if open. - */ - public void close(); - - /** - * Execute the menu item action associated with the given shortcut - * character. - * - * @param keyCode The keycode of the shortcut key. - * @param event Key event message. - * @param flags Additional option flags or 0. - * - * @return If the given shortcut exists and is shown, returns - * true; else returns false. - * - * @see #FLAG_PERFORM_NO_CLOSE - */ - public boolean performShortcut(int keyCode, KeyEvent event, int flags); - - /** - * Is a keypress one of the defined shortcut keys for this window. - * @param keyCode the key code from {@link KeyEvent} to check. - * @param event the {@link KeyEvent} to use to help check. - */ - boolean isShortcutKey(int keyCode, KeyEvent event); - - /** - * Execute the menu item action associated with the given menu identifier. - * - * @param id Identifier associated with the menu item. - * @param flags Additional option flags or 0. - * - * @return If the given identifier exists and is shown, returns - * true; else returns false. - * - * @see #FLAG_PERFORM_NO_CLOSE - */ - public boolean performIdentifierAction(int id, int flags); - - - /** - * Control whether the menu should be running in qwerty mode (alphabetic - * shortcuts) or 12-key mode (numeric shortcuts). - * - * @param isQwerty If true the menu will use alphabetic shortcuts; else it - * will use numeric shortcuts. - */ - public void setQwertyMode(boolean isQwerty); -} - diff --git a/actionbarsherlock/src/com/actionbarsherlock/view/MenuInflater.java b/actionbarsherlock/src/com/actionbarsherlock/view/MenuInflater.java deleted file mode 100644 index 969459749..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/view/MenuInflater.java +++ /dev/null @@ -1,472 +0,0 @@ -/* - * Copyright (C) 2006 The Android Open Source Project - * 2011 Jake Wharton - * - * 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.actionbarsherlock.view; - -import java.io.IOException; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; -import android.content.Context; -import android.content.res.TypedArray; -import android.content.res.XmlResourceParser; -import android.util.AttributeSet; -import android.util.Log; -import android.util.TypedValue; -import android.util.Xml; -import android.view.InflateException; -import android.view.View; - -import com.actionbarsherlock.R; -import com.actionbarsherlock.internal.view.menu.MenuItemImpl; - -/** - * This class is used to instantiate menu XML files into Menu objects. - *

- * For performance reasons, menu inflation relies heavily on pre-processing of - * XML files that is done at build time. Therefore, it is not currently possible - * to use MenuInflater with an XmlPullParser over a plain XML file at runtime; - * it only works with an XmlPullParser returned from a compiled resource (R. - * something file.) - */ -public class MenuInflater { - private static final String LOG_TAG = "MenuInflater"; - - /** Menu tag name in XML. */ - private static final String XML_MENU = "menu"; - - /** Group tag name in XML. */ - private static final String XML_GROUP = "group"; - - /** Item tag name in XML. */ - private static final String XML_ITEM = "item"; - - private static final int NO_ID = 0; - - private static final Class[] ACTION_VIEW_CONSTRUCTOR_SIGNATURE = new Class[] {Context.class}; - - private static final Class[] ACTION_PROVIDER_CONSTRUCTOR_SIGNATURE = ACTION_VIEW_CONSTRUCTOR_SIGNATURE; - - private final Object[] mActionViewConstructorArguments; - - private final Object[] mActionProviderConstructorArguments; - - private Context mContext; - - /** - * Constructs a menu inflater. - * - * @see Activity#getMenuInflater() - */ - public MenuInflater(Context context) { - mContext = context; - mActionViewConstructorArguments = new Object[] {context}; - mActionProviderConstructorArguments = mActionViewConstructorArguments; - } - - /** - * Inflate a menu hierarchy from the specified XML resource. Throws - * {@link InflateException} if there is an error. - * - * @param menuRes Resource ID for an XML layout resource to load (e.g., - * R.menu.main_activity) - * @param menu The Menu to inflate into. The items and submenus will be - * added to this Menu. - */ - public void inflate(int menuRes, Menu menu) { - XmlResourceParser parser = null; - try { - parser = mContext.getResources().getLayout(menuRes); - AttributeSet attrs = Xml.asAttributeSet(parser); - - parseMenu(parser, attrs, menu); - } catch (XmlPullParserException e) { - throw new InflateException("Error inflating menu XML", e); - } catch (IOException e) { - throw new InflateException("Error inflating menu XML", e); - } finally { - if (parser != null) parser.close(); - } - } - - /** - * Called internally to fill the given menu. If a sub menu is seen, it will - * call this recursively. - */ - private void parseMenu(XmlPullParser parser, AttributeSet attrs, Menu menu) - throws XmlPullParserException, IOException { - MenuState menuState = new MenuState(menu); - - int eventType = parser.getEventType(); - String tagName; - boolean lookingForEndOfUnknownTag = false; - String unknownTagName = null; - - // This loop will skip to the menu start tag - do { - if (eventType == XmlPullParser.START_TAG) { - tagName = parser.getName(); - if (tagName.equals(XML_MENU)) { - // Go to next tag - eventType = parser.next(); - break; - } - - throw new RuntimeException("Expecting menu, got " + tagName); - } - eventType = parser.next(); - } while (eventType != XmlPullParser.END_DOCUMENT); - - boolean reachedEndOfMenu = false; - while (!reachedEndOfMenu) { - switch (eventType) { - case XmlPullParser.START_TAG: - if (lookingForEndOfUnknownTag) { - break; - } - - tagName = parser.getName(); - if (tagName.equals(XML_GROUP)) { - menuState.readGroup(attrs); - } else if (tagName.equals(XML_ITEM)) { - menuState.readItem(attrs); - } else if (tagName.equals(XML_MENU)) { - // A menu start tag denotes a submenu for an item - SubMenu subMenu = menuState.addSubMenuItem(); - - // Parse the submenu into returned SubMenu - parseMenu(parser, attrs, subMenu); - } else { - lookingForEndOfUnknownTag = true; - unknownTagName = tagName; - } - break; - - case XmlPullParser.END_TAG: - tagName = parser.getName(); - if (lookingForEndOfUnknownTag && tagName.equals(unknownTagName)) { - lookingForEndOfUnknownTag = false; - unknownTagName = null; - } else if (tagName.equals(XML_GROUP)) { - menuState.resetGroup(); - } else if (tagName.equals(XML_ITEM)) { - // Add the item if it hasn't been added (if the item was - // a submenu, it would have been added already) - if (!menuState.hasAddedItem()) { - if (menuState.itemActionProvider != null && - menuState.itemActionProvider.hasSubMenu()) { - menuState.addSubMenuItem(); - } else { - menuState.addItem(); - } - } - } else if (tagName.equals(XML_MENU)) { - reachedEndOfMenu = true; - } - break; - - case XmlPullParser.END_DOCUMENT: - throw new RuntimeException("Unexpected end of document"); - } - - eventType = parser.next(); - } - } - - private static class InflatedOnMenuItemClickListener - implements MenuItem.OnMenuItemClickListener { - private static final Class[] PARAM_TYPES = new Class[] { MenuItem.class }; - - private Context mContext; - private Method mMethod; - - public InflatedOnMenuItemClickListener(Context context, String methodName) { - mContext = context; - Class c = context.getClass(); - try { - mMethod = c.getMethod(methodName, PARAM_TYPES); - } catch (Exception e) { - InflateException ex = new InflateException( - "Couldn't resolve menu item onClick handler " + methodName + - " in class " + c.getName()); - ex.initCause(e); - throw ex; - } - } - - public boolean onMenuItemClick(MenuItem item) { - try { - if (mMethod.getReturnType() == Boolean.TYPE) { - return (Boolean) mMethod.invoke(mContext, item); - } else { - mMethod.invoke(mContext, item); - return true; - } - } catch (Exception e) { - throw new RuntimeException(e); - } - } - } - - /** - * State for the current menu. - *

- * Groups can not be nested unless there is another menu (which will have - * its state class). - */ - private class MenuState { - private Menu menu; - - /* - * Group state is set on items as they are added, allowing an item to - * override its group state. (As opposed to set on items at the group end tag.) - */ - private int groupId; - private int groupCategory; - private int groupOrder; - private int groupCheckable; - private boolean groupVisible; - private boolean groupEnabled; - - private boolean itemAdded; - private int itemId; - private int itemCategoryOrder; - private CharSequence itemTitle; - private CharSequence itemTitleCondensed; - private int itemIconResId; - private char itemAlphabeticShortcut; - private char itemNumericShortcut; - /** - * Sync to attrs.xml enum: - * - 0: none - * - 1: all - * - 2: exclusive - */ - private int itemCheckable; - private boolean itemChecked; - private boolean itemVisible; - private boolean itemEnabled; - - /** - * Sync to attrs.xml enum, values in MenuItem: - * - 0: never - * - 1: ifRoom - * - 2: always - * - -1: Safe sentinel for "no value". - */ - private int itemShowAsAction; - - private int itemActionViewLayout; - private String itemActionViewClassName; - private String itemActionProviderClassName; - - private String itemListenerMethodName; - - private ActionProvider itemActionProvider; - - private static final int defaultGroupId = NO_ID; - private static final int defaultItemId = NO_ID; - private static final int defaultItemCategory = 0; - private static final int defaultItemOrder = 0; - private static final int defaultItemCheckable = 0; - private static final boolean defaultItemChecked = false; - private static final boolean defaultItemVisible = true; - private static final boolean defaultItemEnabled = true; - - public MenuState(final Menu menu) { - this.menu = menu; - - resetGroup(); - } - - public void resetGroup() { - groupId = defaultGroupId; - groupCategory = defaultItemCategory; - groupOrder = defaultItemOrder; - groupCheckable = defaultItemCheckable; - groupVisible = defaultItemVisible; - groupEnabled = defaultItemEnabled; - } - - /** - * Called when the parser is pointing to a group tag. - */ - public void readGroup(AttributeSet attrs) { - TypedArray a = mContext.obtainStyledAttributes(attrs, - R.styleable.SherlockMenuGroup); - - groupId = a.getResourceId(R.styleable.SherlockMenuGroup_android_id, defaultGroupId); - groupCategory = a.getInt(R.styleable.SherlockMenuGroup_android_menuCategory, defaultItemCategory); - groupOrder = a.getInt(R.styleable.SherlockMenuGroup_android_orderInCategory, defaultItemOrder); - groupCheckable = a.getInt(R.styleable.SherlockMenuGroup_android_checkableBehavior, defaultItemCheckable); - groupVisible = a.getBoolean(R.styleable.SherlockMenuGroup_android_visible, defaultItemVisible); - groupEnabled = a.getBoolean(R.styleable.SherlockMenuGroup_android_enabled, defaultItemEnabled); - - a.recycle(); - } - - /** - * Called when the parser is pointing to an item tag. - */ - public void readItem(AttributeSet attrs) { - TypedArray a = mContext.obtainStyledAttributes(attrs, - R.styleable.SherlockMenuItem); - - // Inherit attributes from the group as default value - itemId = a.getResourceId(R.styleable.SherlockMenuItem_android_id, defaultItemId); - final int category = a.getInt(R.styleable.SherlockMenuItem_android_menuCategory, groupCategory); - final int order = a.getInt(R.styleable.SherlockMenuItem_android_orderInCategory, groupOrder); - itemCategoryOrder = (category & Menu.CATEGORY_MASK) | (order & Menu.USER_MASK); - itemTitle = a.getText(R.styleable.SherlockMenuItem_android_title); - itemTitleCondensed = a.getText(R.styleable.SherlockMenuItem_android_titleCondensed); - itemIconResId = a.getResourceId(R.styleable.SherlockMenuItem_android_icon, 0); - itemAlphabeticShortcut = - getShortcut(a.getString(R.styleable.SherlockMenuItem_android_alphabeticShortcut)); - itemNumericShortcut = - getShortcut(a.getString(R.styleable.SherlockMenuItem_android_numericShortcut)); - if (a.hasValue(R.styleable.SherlockMenuItem_android_checkable)) { - // Item has attribute checkable, use it - itemCheckable = a.getBoolean(R.styleable.SherlockMenuItem_android_checkable, false) ? 1 : 0; - } else { - // Item does not have attribute, use the group's (group can have one more state - // for checkable that represents the exclusive checkable) - itemCheckable = groupCheckable; - } - - itemChecked = a.getBoolean(R.styleable.SherlockMenuItem_android_checked, defaultItemChecked); - itemVisible = a.getBoolean(R.styleable.SherlockMenuItem_android_visible, groupVisible); - itemEnabled = a.getBoolean(R.styleable.SherlockMenuItem_android_enabled, groupEnabled); - - TypedValue value = new TypedValue(); - a.getValue(R.styleable.SherlockMenuItem_android_showAsAction, value); - itemShowAsAction = value.type == TypedValue.TYPE_INT_HEX ? value.data : -1; - - itemListenerMethodName = a.getString(R.styleable.SherlockMenuItem_android_onClick); - itemActionViewLayout = a.getResourceId(R.styleable.SherlockMenuItem_android_actionLayout, 0); - itemActionViewClassName = a.getString(R.styleable.SherlockMenuItem_android_actionViewClass); - itemActionProviderClassName = a.getString(R.styleable.SherlockMenuItem_android_actionProviderClass); - - final boolean hasActionProvider = itemActionProviderClassName != null; - if (hasActionProvider && itemActionViewLayout == 0 && itemActionViewClassName == null) { - itemActionProvider = newInstance(itemActionProviderClassName, - ACTION_PROVIDER_CONSTRUCTOR_SIGNATURE, - mActionProviderConstructorArguments); - } else { - if (hasActionProvider) { - Log.w(LOG_TAG, "Ignoring attribute 'actionProviderClass'." - + " Action view already specified."); - } - itemActionProvider = null; - } - - a.recycle(); - - itemAdded = false; - } - - private char getShortcut(String shortcutString) { - if (shortcutString == null) { - return 0; - } else { - return shortcutString.charAt(0); - } - } - - private void setItem(MenuItem item) { - item.setChecked(itemChecked) - .setVisible(itemVisible) - .setEnabled(itemEnabled) - .setCheckable(itemCheckable >= 1) - .setTitleCondensed(itemTitleCondensed) - .setIcon(itemIconResId) - .setAlphabeticShortcut(itemAlphabeticShortcut) - .setNumericShortcut(itemNumericShortcut); - - if (itemShowAsAction >= 0) { - item.setShowAsAction(itemShowAsAction); - } - - if (itemListenerMethodName != null) { - if (mContext.isRestricted()) { - throw new IllegalStateException("The android:onClick attribute cannot " - + "be used within a restricted context"); - } - item.setOnMenuItemClickListener( - new InflatedOnMenuItemClickListener(mContext, itemListenerMethodName)); - } - - if (itemCheckable >= 2) { - if (item instanceof MenuItemImpl) { - MenuItemImpl impl = (MenuItemImpl) item; - impl.setExclusiveCheckable(true); - } else { - menu.setGroupCheckable(groupId, true, true); - } - } - - boolean actionViewSpecified = false; - if (itemActionViewClassName != null) { - View actionView = (View) newInstance(itemActionViewClassName, - ACTION_VIEW_CONSTRUCTOR_SIGNATURE, mActionViewConstructorArguments); - item.setActionView(actionView); - actionViewSpecified = true; - } - if (itemActionViewLayout > 0) { - if (!actionViewSpecified) { - item.setActionView(itemActionViewLayout); - actionViewSpecified = true; - } else { - Log.w(LOG_TAG, "Ignoring attribute 'itemActionViewLayout'." - + " Action view already specified."); - } - } - if (itemActionProvider != null) { - item.setActionProvider(itemActionProvider); - } - } - - public void addItem() { - itemAdded = true; - setItem(menu.add(groupId, itemId, itemCategoryOrder, itemTitle)); - } - - public SubMenu addSubMenuItem() { - itemAdded = true; - SubMenu subMenu = menu.addSubMenu(groupId, itemId, itemCategoryOrder, itemTitle); - setItem(subMenu.getItem()); - return subMenu; - } - - public boolean hasAddedItem() { - return itemAdded; - } - - @SuppressWarnings("unchecked") - private T newInstance(String className, Class[] constructorSignature, - Object[] arguments) { - try { - Class clazz = mContext.getClassLoader().loadClass(className); - Constructor constructor = clazz.getConstructor(constructorSignature); - return (T) constructor.newInstance(arguments); - } catch (Exception e) { - Log.w(LOG_TAG, "Cannot instantiate class: " + className, e); - } - return null; - } - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/view/MenuItem.java b/actionbarsherlock/src/com/actionbarsherlock/view/MenuItem.java deleted file mode 100644 index 7fc3aa430..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/view/MenuItem.java +++ /dev/null @@ -1,598 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.actionbarsherlock.view; - -import android.content.Intent; -import android.graphics.drawable.Drawable; -import android.view.ContextMenu.ContextMenuInfo; -import android.view.View; - -/** - * Interface for direct access to a previously created menu item. - *

- * An Item is returned by calling one of the {@link android.view.Menu#add} - * methods. - *

- * For a feature set of specific menu types, see {@link Menu}. - * - *

- *

Developer Guides

- *

For information about creating menus, read the - * Menus developer guide.

- *
- */ -public interface MenuItem { - /* - * These should be kept in sync with attrs.xml enum constants for showAsAction - */ - /** Never show this item as a button in an Action Bar. */ - public static final int SHOW_AS_ACTION_NEVER = android.view.MenuItem.SHOW_AS_ACTION_NEVER; - /** Show this item as a button in an Action Bar if the system decides there is room for it. */ - public static final int SHOW_AS_ACTION_IF_ROOM = android.view.MenuItem.SHOW_AS_ACTION_IF_ROOM; - /** - * Always show this item as a button in an Action Bar. - * Use sparingly! If too many items are set to always show in the Action Bar it can - * crowd the Action Bar and degrade the user experience on devices with smaller screens. - * A good rule of thumb is to have no more than 2 items set to always show at a time. - */ - public static final int SHOW_AS_ACTION_ALWAYS = android.view.MenuItem.SHOW_AS_ACTION_ALWAYS; - - /** - * When this item is in the action bar, always show it with a text label even if - * it also has an icon specified. - */ - public static final int SHOW_AS_ACTION_WITH_TEXT = android.view.MenuItem.SHOW_AS_ACTION_WITH_TEXT; - - /** - * This item's action view collapses to a normal menu item. - * When expanded, the action view temporarily takes over - * a larger segment of its container. - */ - public static final int SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW = android.view.MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW; - - /** - * Interface definition for a callback to be invoked when a menu item is - * clicked. - * - * @see Activity#onContextItemSelected(MenuItem) - * @see Activity#onOptionsItemSelected(MenuItem) - */ - public interface OnMenuItemClickListener { - /** - * Called when a menu item has been invoked. This is the first code - * that is executed; if it returns true, no other callbacks will be - * executed. - * - * @param item The menu item that was invoked. - * - * @return Return true to consume this click and prevent others from - * executing. - */ - public boolean onMenuItemClick(MenuItem item); - } - - /** - * Interface definition for a callback to be invoked when a menu item - * marked with {@link MenuItem#SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW} is - * expanded or collapsed. - * - * @see MenuItem#expandActionView() - * @see MenuItem#collapseActionView() - * @see MenuItem#setShowAsActionFlags(int) - */ - public interface OnActionExpandListener { - /** - * Called when a menu item with {@link MenuItem#SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW} - * is expanded. - * @param item Item that was expanded - * @return true if the item should expand, false if expansion should be suppressed. - */ - public boolean onMenuItemActionExpand(MenuItem item); - - /** - * Called when a menu item with {@link MenuItem#SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW} - * is collapsed. - * @param item Item that was collapsed - * @return true if the item should collapse, false if collapsing should be suppressed. - */ - public boolean onMenuItemActionCollapse(MenuItem item); - } - - /** - * Return the identifier for this menu item. The identifier can not - * be changed after the menu is created. - * - * @return The menu item's identifier. - */ - public int getItemId(); - - /** - * Return the group identifier that this menu item is part of. The group - * identifier can not be changed after the menu is created. - * - * @return The menu item's group identifier. - */ - public int getGroupId(); - - /** - * Return the category and order within the category of this item. This - * item will be shown before all items (within its category) that have - * order greater than this value. - *

- * An order integer contains the item's category (the upper bits of the - * integer; set by or/add the category with the order within the - * category) and the ordering of the item within that category (the - * lower bits). Example categories are {@link Menu#CATEGORY_SYSTEM}, - * {@link Menu#CATEGORY_SECONDARY}, {@link Menu#CATEGORY_ALTERNATIVE}, - * {@link Menu#CATEGORY_CONTAINER}. See {@link Menu} for a full list. - * - * @return The order of this item. - */ - public int getOrder(); - - /** - * Change the title associated with this item. - * - * @param title The new text to be displayed. - * @return This Item so additional setters can be called. - */ - public MenuItem setTitle(CharSequence title); - - /** - * Change the title associated with this item. - *

- * Some menu types do not sufficient space to show the full title, and - * instead a condensed title is preferred. See {@link Menu} for more - * information. - * - * @param title The resource id of the new text to be displayed. - * @return This Item so additional setters can be called. - * @see #setTitleCondensed(CharSequence) - */ - - public MenuItem setTitle(int title); - - /** - * Retrieve the current title of the item. - * - * @return The title. - */ - public CharSequence getTitle(); - - /** - * Change the condensed title associated with this item. The condensed - * title is used in situations where the normal title may be too long to - * be displayed. - * - * @param title The new text to be displayed as the condensed title. - * @return This Item so additional setters can be called. - */ - public MenuItem setTitleCondensed(CharSequence title); - - /** - * Retrieve the current condensed title of the item. If a condensed - * title was never set, it will return the normal title. - * - * @return The condensed title, if it exists. - * Otherwise the normal title. - */ - public CharSequence getTitleCondensed(); - - /** - * Change the icon associated with this item. This icon will not always be - * shown, so the title should be sufficient in describing this item. See - * {@link Menu} for the menu types that support icons. - * - * @param icon The new icon (as a Drawable) to be displayed. - * @return This Item so additional setters can be called. - */ - public MenuItem setIcon(Drawable icon); - - /** - * Change the icon associated with this item. This icon will not always be - * shown, so the title should be sufficient in describing this item. See - * {@link Menu} for the menu types that support icons. - *

- * This method will set the resource ID of the icon which will be used to - * lazily get the Drawable when this item is being shown. - * - * @param iconRes The new icon (as a resource ID) to be displayed. - * @return This Item so additional setters can be called. - */ - public MenuItem setIcon(int iconRes); - - /** - * Returns the icon for this item as a Drawable (getting it from resources if it hasn't been - * loaded before). - * - * @return The icon as a Drawable. - */ - public Drawable getIcon(); - - /** - * Change the Intent associated with this item. By default there is no - * Intent associated with a menu item. If you set one, and nothing - * else handles the item, then the default behavior will be to call - * {@link android.content.Context#startActivity} with the given Intent. - * - *

Note that setIntent() can not be used with the versions of - * {@link Menu#add} that take a Runnable, because {@link Runnable#run} - * does not return a value so there is no way to tell if it handled the - * item. In this case it is assumed that the Runnable always handles - * the item, and the intent will never be started. - * - * @see #getIntent - * @param intent The Intent to associated with the item. This Intent - * object is not copied, so be careful not to - * modify it later. - * @return This Item so additional setters can be called. - */ - public MenuItem setIntent(Intent intent); - - /** - * Return the Intent associated with this item. This returns a - * reference to the Intent which you can change as desired to modify - * what the Item is holding. - * - * @see #setIntent - * @return Returns the last value supplied to {@link #setIntent}, or - * null. - */ - public Intent getIntent(); - - /** - * Change both the numeric and alphabetic shortcut associated with this - * item. Note that the shortcut will be triggered when the key that - * generates the given character is pressed alone or along with with the alt - * key. Also note that case is not significant and that alphabetic shortcut - * characters will be displayed in lower case. - *

- * See {@link Menu} for the menu types that support shortcuts. - * - * @param numericChar The numeric shortcut key. This is the shortcut when - * using a numeric (e.g., 12-key) keyboard. - * @param alphaChar The alphabetic shortcut key. This is the shortcut when - * using a keyboard with alphabetic keys. - * @return This Item so additional setters can be called. - */ - public MenuItem setShortcut(char numericChar, char alphaChar); - - /** - * Change the numeric shortcut associated with this item. - *

- * See {@link Menu} for the menu types that support shortcuts. - * - * @param numericChar The numeric shortcut key. This is the shortcut when - * using a 12-key (numeric) keyboard. - * @return This Item so additional setters can be called. - */ - public MenuItem setNumericShortcut(char numericChar); - - /** - * Return the char for this menu item's numeric (12-key) shortcut. - * - * @return Numeric character to use as a shortcut. - */ - public char getNumericShortcut(); - - /** - * Change the alphabetic shortcut associated with this item. The shortcut - * will be triggered when the key that generates the given character is - * pressed alone or along with with the alt key. Case is not significant and - * shortcut characters will be displayed in lower case. Note that menu items - * with the characters '\b' or '\n' as shortcuts will get triggered by the - * Delete key or Carriage Return key, respectively. - *

- * See {@link Menu} for the menu types that support shortcuts. - * - * @param alphaChar The alphabetic shortcut key. This is the shortcut when - * using a keyboard with alphabetic keys. - * @return This Item so additional setters can be called. - */ - public MenuItem setAlphabeticShortcut(char alphaChar); - - /** - * Return the char for this menu item's alphabetic shortcut. - * - * @return Alphabetic character to use as a shortcut. - */ - public char getAlphabeticShortcut(); - - /** - * Control whether this item can display a check mark. Setting this does - * not actually display a check mark (see {@link #setChecked} for that); - * rather, it ensures there is room in the item in which to display a - * check mark. - *

- * See {@link Menu} for the menu types that support check marks. - * - * @param checkable Set to true to allow a check mark, false to - * disallow. The default is false. - * @see #setChecked - * @see #isCheckable - * @see Menu#setGroupCheckable - * @return This Item so additional setters can be called. - */ - public MenuItem setCheckable(boolean checkable); - - /** - * Return whether the item can currently display a check mark. - * - * @return If a check mark can be displayed, returns true. - * - * @see #setCheckable - */ - public boolean isCheckable(); - - /** - * Control whether this item is shown with a check mark. Note that you - * must first have enabled checking with {@link #setCheckable} or else - * the check mark will not appear. If this item is a member of a group that contains - * mutually-exclusive items (set via {@link Menu#setGroupCheckable(int, boolean, boolean)}, - * the other items in the group will be unchecked. - *

- * See {@link Menu} for the menu types that support check marks. - * - * @see #setCheckable - * @see #isChecked - * @see Menu#setGroupCheckable - * @param checked Set to true to display a check mark, false to hide - * it. The default value is false. - * @return This Item so additional setters can be called. - */ - public MenuItem setChecked(boolean checked); - - /** - * Return whether the item is currently displaying a check mark. - * - * @return If a check mark is displayed, returns true. - * - * @see #setChecked - */ - public boolean isChecked(); - - /** - * Sets the visibility of the menu item. Even if a menu item is not visible, - * it may still be invoked via its shortcut (to completely disable an item, - * set it to invisible and {@link #setEnabled(boolean) disabled}). - * - * @param visible If true then the item will be visible; if false it is - * hidden. - * @return This Item so additional setters can be called. - */ - public MenuItem setVisible(boolean visible); - - /** - * Return the visibility of the menu item. - * - * @return If true the item is visible; else it is hidden. - */ - public boolean isVisible(); - - /** - * Sets whether the menu item is enabled. Disabling a menu item will not - * allow it to be invoked via its shortcut. The menu item will still be - * visible. - * - * @param enabled If true then the item will be invokable; if false it is - * won't be invokable. - * @return This Item so additional setters can be called. - */ - public MenuItem setEnabled(boolean enabled); - - /** - * Return the enabled state of the menu item. - * - * @return If true the item is enabled and hence invokable; else it is not. - */ - public boolean isEnabled(); - - /** - * Check whether this item has an associated sub-menu. I.e. it is a - * sub-menu of another menu. - * - * @return If true this item has a menu; else it is a - * normal item. - */ - public boolean hasSubMenu(); - - /** - * Get the sub-menu to be invoked when this item is selected, if it has - * one. See {@link #hasSubMenu()}. - * - * @return The associated menu if there is one, else null - */ - public SubMenu getSubMenu(); - - /** - * Set a custom listener for invocation of this menu item. In most - * situations, it is more efficient and easier to use - * {@link Activity#onOptionsItemSelected(MenuItem)} or - * {@link Activity#onContextItemSelected(MenuItem)}. - * - * @param menuItemClickListener The object to receive invokations. - * @return This Item so additional setters can be called. - * @see Activity#onOptionsItemSelected(MenuItem) - * @see Activity#onContextItemSelected(MenuItem) - */ - public MenuItem setOnMenuItemClickListener(MenuItem.OnMenuItemClickListener menuItemClickListener); - - /** - * Gets the extra information linked to this menu item. This extra - * information is set by the View that added this menu item to the - * menu. - * - * @see OnCreateContextMenuListener - * @return The extra information linked to the View that added this - * menu item to the menu. This can be null. - */ - public ContextMenuInfo getMenuInfo(); - - /** - * Sets how this item should display in the presence of an Action Bar. - * The parameter actionEnum is a flag set. One of {@link #SHOW_AS_ACTION_ALWAYS}, - * {@link #SHOW_AS_ACTION_IF_ROOM}, or {@link #SHOW_AS_ACTION_NEVER} should - * be used, and you may optionally OR the value with {@link #SHOW_AS_ACTION_WITH_TEXT}. - * SHOW_AS_ACTION_WITH_TEXT requests that when the item is shown as an action, - * it should be shown with a text label. - * - * @param actionEnum How the item should display. One of - * {@link #SHOW_AS_ACTION_ALWAYS}, {@link #SHOW_AS_ACTION_IF_ROOM}, or - * {@link #SHOW_AS_ACTION_NEVER}. SHOW_AS_ACTION_NEVER is the default. - * - * @see android.app.ActionBar - * @see #setActionView(View) - */ - public void setShowAsAction(int actionEnum); - - /** - * Sets how this item should display in the presence of an Action Bar. - * The parameter actionEnum is a flag set. One of {@link #SHOW_AS_ACTION_ALWAYS}, - * {@link #SHOW_AS_ACTION_IF_ROOM}, or {@link #SHOW_AS_ACTION_NEVER} should - * be used, and you may optionally OR the value with {@link #SHOW_AS_ACTION_WITH_TEXT}. - * SHOW_AS_ACTION_WITH_TEXT requests that when the item is shown as an action, - * it should be shown with a text label. - * - *

Note: This method differs from {@link #setShowAsAction(int)} only in that it - * returns the current MenuItem instance for call chaining. - * - * @param actionEnum How the item should display. One of - * {@link #SHOW_AS_ACTION_ALWAYS}, {@link #SHOW_AS_ACTION_IF_ROOM}, or - * {@link #SHOW_AS_ACTION_NEVER}. SHOW_AS_ACTION_NEVER is the default. - * - * @see android.app.ActionBar - * @see #setActionView(View) - * @return This MenuItem instance for call chaining. - */ - public MenuItem setShowAsActionFlags(int actionEnum); - - /** - * Set an action view for this menu item. An action view will be displayed in place - * of an automatically generated menu item element in the UI when this item is shown - * as an action within a parent. - *

- * Note: Setting an action view overrides the action provider - * set via {@link #setActionProvider(ActionProvider)}. - *

- * - * @param view View to use for presenting this item to the user. - * @return This Item so additional setters can be called. - * - * @see #setShowAsAction(int) - */ - public MenuItem setActionView(View view); - - /** - * Set an action view for this menu item. An action view will be displayed in place - * of an automatically generated menu item element in the UI when this item is shown - * as an action within a parent. - *

- * Note: Setting an action view overrides the action provider - * set via {@link #setActionProvider(ActionProvider)}. - *

- * - * @param resId Layout resource to use for presenting this item to the user. - * @return This Item so additional setters can be called. - * - * @see #setShowAsAction(int) - */ - public MenuItem setActionView(int resId); - - /** - * Returns the currently set action view for this menu item. - * - * @return This item's action view - * - * @see #setActionView(View) - * @see #setShowAsAction(int) - */ - public View getActionView(); - - /** - * Sets the {@link ActionProvider} responsible for creating an action view if - * the item is placed on the action bar. The provider also provides a default - * action invoked if the item is placed in the overflow menu. - *

- * Note: Setting an action provider overrides the action view - * set via {@link #setActionView(int)} or {@link #setActionView(View)}. - *

- * - * @param actionProvider The action provider. - * @return This Item so additional setters can be called. - * - * @see ActionProvider - */ - public MenuItem setActionProvider(ActionProvider actionProvider); - - /** - * Gets the {@link ActionProvider}. - * - * @return The action provider. - * - * @see ActionProvider - * @see #setActionProvider(ActionProvider) - */ - public ActionProvider getActionProvider(); - - /** - * Expand the action view associated with this menu item. - * The menu item must have an action view set, as well as - * the showAsAction flag {@link #SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW}. - * If a listener has been set using {@link #setOnActionExpandListener(OnActionExpandListener)} - * it will have its {@link OnActionExpandListener#onMenuItemActionExpand(MenuItem)} - * method invoked. The listener may return false from this method to prevent expanding - * the action view. - * - * @return true if the action view was expanded, false otherwise. - */ - public boolean expandActionView(); - - /** - * Collapse the action view associated with this menu item. - * The menu item must have an action view set, as well as the showAsAction flag - * {@link #SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW}. If a listener has been set using - * {@link #setOnActionExpandListener(OnActionExpandListener)} it will have its - * {@link OnActionExpandListener#onMenuItemActionCollapse(MenuItem)} method invoked. - * The listener may return false from this method to prevent collapsing the action view. - * - * @return true if the action view was collapsed, false otherwise. - */ - public boolean collapseActionView(); - - /** - * Returns true if this menu item's action view has been expanded. - * - * @return true if the item's action view is expanded, false otherwise. - * - * @see #expandActionView() - * @see #collapseActionView() - * @see #SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW - * @see OnActionExpandListener - */ - public boolean isActionViewExpanded(); - - /** - * Set an {@link OnActionExpandListener} on this menu item to be notified when - * the associated action view is expanded or collapsed. The menu item must - * be configured to expand or collapse its action view using the flag - * {@link #SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW}. - * - * @param listener Listener that will respond to expand/collapse events - * @return This menu item instance for call chaining - */ - public MenuItem setOnActionExpandListener(OnActionExpandListener listener); -} \ No newline at end of file diff --git a/actionbarsherlock/src/com/actionbarsherlock/view/SubMenu.java b/actionbarsherlock/src/com/actionbarsherlock/view/SubMenu.java deleted file mode 100644 index 397fd1c2d..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/view/SubMenu.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2007 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.actionbarsherlock.view; - -import android.graphics.drawable.Drawable; -import android.view.View; - -/** - * Subclass of {@link Menu} for sub menus. - *

- * Sub menus do not support item icons, or nested sub menus. - * - *

- *

Developer Guides

- *

For information about creating menus, read the - * Menus developer guide.

- *
- */ - -public interface SubMenu extends Menu { - /** - * Sets the submenu header's title to the title given in titleRes - * resource identifier. - * - * @param titleRes The string resource identifier used for the title. - * @return This SubMenu so additional setters can be called. - */ - public SubMenu setHeaderTitle(int titleRes); - - /** - * Sets the submenu header's title to the title given in title. - * - * @param title The character sequence used for the title. - * @return This SubMenu so additional setters can be called. - */ - public SubMenu setHeaderTitle(CharSequence title); - - /** - * Sets the submenu header's icon to the icon given in iconRes - * resource id. - * - * @param iconRes The resource identifier used for the icon. - * @return This SubMenu so additional setters can be called. - */ - public SubMenu setHeaderIcon(int iconRes); - - /** - * Sets the submenu header's icon to the icon given in icon - * {@link Drawable}. - * - * @param icon The {@link Drawable} used for the icon. - * @return This SubMenu so additional setters can be called. - */ - public SubMenu setHeaderIcon(Drawable icon); - - /** - * Sets the header of the submenu to the {@link View} given in - * view. This replaces the header title and icon (and those - * replace this). - * - * @param view The {@link View} used for the header. - * @return This SubMenu so additional setters can be called. - */ - public SubMenu setHeaderView(View view); - - /** - * Clears the header of the submenu. - */ - public void clearHeader(); - - /** - * Change the icon associated with this submenu's item in its parent menu. - * - * @see MenuItem#setIcon(int) - * @param iconRes The new icon (as a resource ID) to be displayed. - * @return This SubMenu so additional setters can be called. - */ - public SubMenu setIcon(int iconRes); - - /** - * Change the icon associated with this submenu's item in its parent menu. - * - * @see MenuItem#setIcon(Drawable) - * @param icon The new icon (as a Drawable) to be displayed. - * @return This SubMenu so additional setters can be called. - */ - public SubMenu setIcon(Drawable icon); - - /** - * Gets the {@link MenuItem} that represents this submenu in the parent - * menu. Use this for setting additional item attributes. - * - * @return The {@link MenuItem} that launches the submenu when invoked. - */ - public MenuItem getItem(); -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/view/Window.java b/actionbarsherlock/src/com/actionbarsherlock/view/Window.java deleted file mode 100644 index a340a4291..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/view/Window.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2006 The Android Open Source Project - * Copyright (C) 2011 Jake Wharton - * - * 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.actionbarsherlock.view; - -import android.content.Context; - -/** - *

Abstract base class for a top-level window look and behavior policy. An - * instance of this class should be used as the top-level view added to the - * window manager. It provides standard UI policies such as a background, title - * area, default key processing, etc.

- * - *

The only existing implementation of this abstract class is - * android.policy.PhoneWindow, which you should instantiate when needing a - * Window. Eventually that class will be refactored and a factory method added - * for creating Window instances without knowing about a particular - * implementation.

- */ -public abstract class Window extends android.view.Window { - public static final long FEATURE_ACTION_BAR = android.view.Window.FEATURE_ACTION_BAR; - public static final long FEATURE_ACTION_BAR_OVERLAY = android.view.Window.FEATURE_ACTION_BAR_OVERLAY; - public static final long FEATURE_ACTION_MODE_OVERLAY = android.view.Window.FEATURE_ACTION_MODE_OVERLAY; - public static final long FEATURE_NO_TITLE = android.view.Window.FEATURE_NO_TITLE; - public static final long FEATURE_PROGRESS = android.view.Window.FEATURE_PROGRESS; - public static final long FEATURE_INDETERMINATE_PROGRESS = android.view.Window.FEATURE_INDETERMINATE_PROGRESS; - - /** - * Create a new instance for a context. - * - * @param context Context. - */ - private Window(Context context) { - super(context); - } - - - public interface Callback { - /** - * Called when a panel's menu item has been selected by the user. - * - * @param featureId The panel that the menu is in. - * @param item The menu item that was selected. - * - * @return boolean Return true to finish processing of selection, or - * false to perform the normal menu handling (calling its - * Runnable or sending a Message to its target Handler). - */ - public boolean onMenuItemSelected(int featureId, MenuItem item); - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/widget/ActivityChooserModel.java b/actionbarsherlock/src/com/actionbarsherlock/widget/ActivityChooserModel.java deleted file mode 100644 index 379207471..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/widget/ActivityChooserModel.java +++ /dev/null @@ -1,1131 +0,0 @@ -/* - * Copyright (C) 2011 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.actionbarsherlock.widget; - -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.pm.ResolveInfo; -import android.database.DataSetObservable; -import android.os.Handler; -import android.text.TextUtils; -import android.util.Log; -import android.util.Xml; - -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; -import org.xmlpull.v1.XmlSerializer; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.Executor; - -/** - *

- * This class represents a data model for choosing a component for handing a - * given {@link Intent}. The model is responsible for querying the system for - * activities that can handle the given intent and order found activities - * based on historical data of previous choices. The historical data is stored - * in an application private file. If a client does not want to have persistent - * choice history the file can be omitted, thus the activities will be ordered - * based on historical usage for the current session. - *

- *

- * For each backing history file there is a singleton instance of this class. Thus, - * several clients that specify the same history file will share the same model. Note - * that if multiple clients are sharing the same model they should implement semantically - * equivalent functionality since setting the model intent will change the found - * activities and they may be inconsistent with the functionality of some of the clients. - * For example, choosing a share activity can be implemented by a single backing - * model and two different views for performing the selection. If however, one of the - * views is used for sharing but the other for importing, for example, then each - * view should be backed by a separate model. - *

- *

- * The way clients interact with this class is as follows: - *

- *

- *

- * 
- *  // Get a model and set it to a couple of clients with semantically similar function.
- *  ActivityChooserModel dataModel =
- *      ActivityChooserModel.get(context, "task_specific_history_file_name.xml");
- *
- *  ActivityChooserModelClient modelClient1 = getActivityChooserModelClient1();
- *  modelClient1.setActivityChooserModel(dataModel);
- *
- *  ActivityChooserModelClient modelClient2 = getActivityChooserModelClient2();
- *  modelClient2.setActivityChooserModel(dataModel);
- *
- *  // Set an intent to choose a an activity for.
- *  dataModel.setIntent(intent);
- * 
- * 
- * 

- *

- * Note: This class is thread safe. - *

- * - * @hide - */ -class ActivityChooserModel extends DataSetObservable { - - /** - * Client that utilizes an {@link ActivityChooserModel}. - */ - public interface ActivityChooserModelClient { - - /** - * Sets the {@link ActivityChooserModel}. - * - * @param dataModel The model. - */ - public void setActivityChooserModel(ActivityChooserModel dataModel); - } - - /** - * Defines a sorter that is responsible for sorting the activities - * based on the provided historical choices and an intent. - */ - public interface ActivitySorter { - - /** - * Sorts the activities in descending order of relevance - * based on previous history and an intent. - * - * @param intent The {@link Intent}. - * @param activities Activities to be sorted. - * @param historicalRecords Historical records. - */ - // This cannot be done by a simple comparator since an Activity weight - // is computed from history. Note that Activity implements Comparable. - public void sort(Intent intent, List activities, - List historicalRecords); - } - - /** - * Listener for choosing an activity. - */ - public interface OnChooseActivityListener { - - /** - * Called when an activity has been chosen. The client can decide whether - * an activity can be chosen and if so the caller of - * {@link ActivityChooserModel#chooseActivity(int)} will receive and {@link Intent} - * for launching it. - *

- * Note: Modifying the intent is not permitted and - * any changes to the latter will be ignored. - *

- * - * @param host The listener's host model. - * @param intent The intent for launching the chosen activity. - * @return Whether the intent is handled and should not be delivered to clients. - * - * @see ActivityChooserModel#chooseActivity(int) - */ - public boolean onChooseActivity(ActivityChooserModel host, Intent intent); - } - - /** - * Flag for selecting debug mode. - */ - private static final boolean DEBUG = false; - - /** - * Tag used for logging. - */ - private static final String LOG_TAG = ActivityChooserModel.class.getSimpleName(); - - /** - * The root tag in the history file. - */ - private static final String TAG_HISTORICAL_RECORDS = "historical-records"; - - /** - * The tag for a record in the history file. - */ - private static final String TAG_HISTORICAL_RECORD = "historical-record"; - - /** - * Attribute for the activity. - */ - private static final String ATTRIBUTE_ACTIVITY = "activity"; - - /** - * Attribute for the choice time. - */ - private static final String ATTRIBUTE_TIME = "time"; - - /** - * Attribute for the choice weight. - */ - private static final String ATTRIBUTE_WEIGHT = "weight"; - - /** - * The default name of the choice history file. - */ - public static final String DEFAULT_HISTORY_FILE_NAME = - "activity_choser_model_history.xml"; - - /** - * The default maximal length of the choice history. - */ - public static final int DEFAULT_HISTORY_MAX_LENGTH = 50; - - /** - * The amount with which to inflate a chosen activity when set as default. - */ - private static final int DEFAULT_ACTIVITY_INFLATION = 5; - - /** - * Default weight for a choice record. - */ - private static final float DEFAULT_HISTORICAL_RECORD_WEIGHT = 1.0f; - - /** - * The extension of the history file. - */ - private static final String HISTORY_FILE_EXTENSION = ".xml"; - - /** - * An invalid item index. - */ - private static final int INVALID_INDEX = -1; - - /** - * Lock to guard the model registry. - */ - private static final Object sRegistryLock = new Object(); - - /** - * This the registry for data models. - */ - private static final Map sDataModelRegistry = - new HashMap(); - - /** - * Lock for synchronizing on this instance. - */ - private final Object mInstanceLock = new Object(); - - /** - * List of activities that can handle the current intent. - */ - private final List mActivites = new ArrayList(); - - /** - * List with historical choice records. - */ - private final List mHistoricalRecords = new ArrayList(); - - /** - * Context for accessing resources. - */ - private final Context mContext; - - /** - * The name of the history file that backs this model. - */ - private final String mHistoryFileName; - - /** - * The intent for which a activity is being chosen. - */ - private Intent mIntent; - - /** - * The sorter for ordering activities based on intent and past choices. - */ - private ActivitySorter mActivitySorter = new DefaultSorter(); - - /** - * The maximal length of the choice history. - */ - private int mHistoryMaxSize = DEFAULT_HISTORY_MAX_LENGTH; - - /** - * Flag whether choice history can be read. In general many clients can - * share the same data model and {@link #readHistoricalData()} may be called - * by arbitrary of them any number of times. Therefore, this class guarantees - * that the very first read succeeds and subsequent reads can be performed - * only after a call to {@link #persistHistoricalData()} followed by change - * of the share records. - */ - private boolean mCanReadHistoricalData = true; - - /** - * Flag whether the choice history was read. This is used to enforce that - * before calling {@link #persistHistoricalData()} a call to - * {@link #persistHistoricalData()} has been made. This aims to avoid a - * scenario in which a choice history file exits, it is not read yet and - * it is overwritten. Note that always all historical records are read in - * full and the file is rewritten. This is necessary since we need to - * purge old records that are outside of the sliding window of past choices. - */ - private boolean mReadShareHistoryCalled = false; - - /** - * Flag whether the choice records have changed. In general many clients can - * share the same data model and {@link #persistHistoricalData()} may be called - * by arbitrary of them any number of times. Therefore, this class guarantees - * that choice history will be persisted only if it has changed. - */ - private boolean mHistoricalRecordsChanged = true; - - /** - * Hander for scheduling work on client tread. - */ - private final Handler mHandler = new Handler(); - - /** - * Policy for controlling how the model handles chosen activities. - */ - private OnChooseActivityListener mActivityChoserModelPolicy; - - /** - * Gets the data model backed by the contents of the provided file with historical data. - * Note that only one data model is backed by a given file, thus multiple calls with - * the same file name will return the same model instance. If no such instance is present - * it is created. - *

- * Note: To use the default historical data file clients should explicitly - * pass as file name {@link #DEFAULT_HISTORY_FILE_NAME}. If no persistence of the choice - * history is desired clients should pass null for the file name. In such - * case a new model is returned for each invocation. - *

- * - *

- * Always use difference historical data files for semantically different actions. - * For example, sharing is different from importing. - *

- * - * @param context Context for loading resources. - * @param historyFileName File name with choice history, null - * if the model should not be backed by a file. In this case the activities - * will be ordered only by data from the current session. - * - * @return The model. - */ - public static ActivityChooserModel get(Context context, String historyFileName) { - synchronized (sRegistryLock) { - ActivityChooserModel dataModel = sDataModelRegistry.get(historyFileName); - if (dataModel == null) { - dataModel = new ActivityChooserModel(context, historyFileName); - sDataModelRegistry.put(historyFileName, dataModel); - } - dataModel.readHistoricalData(); - return dataModel; - } - } - - /** - * Creates a new instance. - * - * @param context Context for loading resources. - * @param historyFileName The history XML file. - */ - private ActivityChooserModel(Context context, String historyFileName) { - mContext = context.getApplicationContext(); - if (!TextUtils.isEmpty(historyFileName) - && !historyFileName.endsWith(HISTORY_FILE_EXTENSION)) { - mHistoryFileName = historyFileName + HISTORY_FILE_EXTENSION; - } else { - mHistoryFileName = historyFileName; - } - } - - /** - * Sets an intent for which to choose a activity. - *

- * Note: Clients must set only semantically similar - * intents for each data model. - *

- * - * @param intent The intent. - */ - public void setIntent(Intent intent) { - synchronized (mInstanceLock) { - if (mIntent == intent) { - return; - } - mIntent = intent; - loadActivitiesLocked(); - } - } - - /** - * Gets the intent for which a activity is being chosen. - * - * @return The intent. - */ - public Intent getIntent() { - synchronized (mInstanceLock) { - return mIntent; - } - } - - /** - * Gets the number of activities that can handle the intent. - * - * @return The activity count. - * - * @see #setIntent(Intent) - */ - public int getActivityCount() { - synchronized (mInstanceLock) { - return mActivites.size(); - } - } - - /** - * Gets an activity at a given index. - * - * @return The activity. - * - * @see ActivityResolveInfo - * @see #setIntent(Intent) - */ - public ResolveInfo getActivity(int index) { - synchronized (mInstanceLock) { - return mActivites.get(index).resolveInfo; - } - } - - /** - * Gets the index of a the given activity. - * - * @param activity The activity index. - * - * @return The index if found, -1 otherwise. - */ - public int getActivityIndex(ResolveInfo activity) { - List activities = mActivites; - final int activityCount = activities.size(); - for (int i = 0; i < activityCount; i++) { - ActivityResolveInfo currentActivity = activities.get(i); - if (currentActivity.resolveInfo == activity) { - return i; - } - } - return INVALID_INDEX; - } - - /** - * Chooses a activity to handle the current intent. This will result in - * adding a historical record for that action and construct intent with - * its component name set such that it can be immediately started by the - * client. - *

- * Note: By calling this method the client guarantees - * that the returned intent will be started. This intent is returned to - * the client solely to let additional customization before the start. - *

- * - * @return An {@link Intent} for launching the activity or null if the - * policy has consumed the intent. - * - * @see HistoricalRecord - * @see OnChooseActivityListener - */ - public Intent chooseActivity(int index) { - ActivityResolveInfo chosenActivity = mActivites.get(index); - - ComponentName chosenName = new ComponentName( - chosenActivity.resolveInfo.activityInfo.packageName, - chosenActivity.resolveInfo.activityInfo.name); - - Intent choiceIntent = new Intent(mIntent); - choiceIntent.setComponent(chosenName); - - if (mActivityChoserModelPolicy != null) { - // Do not allow the policy to change the intent. - Intent choiceIntentCopy = new Intent(choiceIntent); - final boolean handled = mActivityChoserModelPolicy.onChooseActivity(this, - choiceIntentCopy); - if (handled) { - return null; - } - } - - HistoricalRecord historicalRecord = new HistoricalRecord(chosenName, - System.currentTimeMillis(), DEFAULT_HISTORICAL_RECORD_WEIGHT); - addHisoricalRecord(historicalRecord); - - return choiceIntent; - } - - /** - * Sets the listener for choosing an activity. - * - * @param listener The listener. - */ - public void setOnChooseActivityListener(OnChooseActivityListener listener) { - mActivityChoserModelPolicy = listener; - } - - /** - * Gets the default activity, The default activity is defined as the one - * with highest rank i.e. the first one in the list of activities that can - * handle the intent. - * - * @return The default activity, null id not activities. - * - * @see #getActivity(int) - */ - public ResolveInfo getDefaultActivity() { - synchronized (mInstanceLock) { - if (!mActivites.isEmpty()) { - return mActivites.get(0).resolveInfo; - } - } - return null; - } - - /** - * Sets the default activity. The default activity is set by adding a - * historical record with weight high enough that this activity will - * become the highest ranked. Such a strategy guarantees that the default - * will eventually change if not used. Also the weight of the record for - * setting a default is inflated with a constant amount to guarantee that - * it will stay as default for awhile. - * - * @param index The index of the activity to set as default. - */ - public void setDefaultActivity(int index) { - ActivityResolveInfo newDefaultActivity = mActivites.get(index); - ActivityResolveInfo oldDefaultActivity = mActivites.get(0); - - final float weight; - if (oldDefaultActivity != null) { - // Add a record with weight enough to boost the chosen at the top. - weight = oldDefaultActivity.weight - newDefaultActivity.weight - + DEFAULT_ACTIVITY_INFLATION; - } else { - weight = DEFAULT_HISTORICAL_RECORD_WEIGHT; - } - - ComponentName defaultName = new ComponentName( - newDefaultActivity.resolveInfo.activityInfo.packageName, - newDefaultActivity.resolveInfo.activityInfo.name); - HistoricalRecord historicalRecord = new HistoricalRecord(defaultName, - System.currentTimeMillis(), weight); - addHisoricalRecord(historicalRecord); - } - - /** - * Reads the history data from the backing file if the latter - * was provided. Calling this method more than once before a call - * to {@link #persistHistoricalData()} has been made has no effect. - *

- * Note: Historical data is read asynchronously and - * as soon as the reading is completed any registered - * {@link DataSetObserver}s will be notified. Also no historical - * data is read until this method is invoked. - *

- */ - private void readHistoricalData() { - synchronized (mInstanceLock) { - if (!mCanReadHistoricalData || !mHistoricalRecordsChanged) { - return; - } - mCanReadHistoricalData = false; - mReadShareHistoryCalled = true; - if (!TextUtils.isEmpty(mHistoryFileName)) { - /*AsyncTask.*/SERIAL_EXECUTOR.execute(new HistoryLoader()); - } - } - } - - private static final SerialExecutor SERIAL_EXECUTOR = new SerialExecutor(); - - private static class SerialExecutor implements Executor { - final LinkedList mTasks = new LinkedList(); - Runnable mActive; - - public synchronized void execute(final Runnable r) { - mTasks.offer(new Runnable() { - public void run() { - try { - r.run(); - } finally { - scheduleNext(); - } - } - }); - if (mActive == null) { - scheduleNext(); - } - } - - protected synchronized void scheduleNext() { - if ((mActive = mTasks.poll()) != null) { - mActive.run(); - } - } - } - - /** - * Persists the history data to the backing file if the latter - * was provided. Calling this method before a call to {@link #readHistoricalData()} - * throws an exception. Calling this method more than one without choosing an - * activity has not effect. - * - * @throws IllegalStateException If this method is called before a call to - * {@link #readHistoricalData()}. - */ - private void persistHistoricalData() { - synchronized (mInstanceLock) { - if (!mReadShareHistoryCalled) { - throw new IllegalStateException("No preceding call to #readHistoricalData"); - } - if (!mHistoricalRecordsChanged) { - return; - } - mHistoricalRecordsChanged = false; - mCanReadHistoricalData = true; - if (!TextUtils.isEmpty(mHistoryFileName)) { - /*AsyncTask.*/SERIAL_EXECUTOR.execute(new HistoryPersister()); - } - } - } - - /** - * Sets the sorter for ordering activities based on historical data and an intent. - * - * @param activitySorter The sorter. - * - * @see ActivitySorter - */ - public void setActivitySorter(ActivitySorter activitySorter) { - synchronized (mInstanceLock) { - if (mActivitySorter == activitySorter) { - return; - } - mActivitySorter = activitySorter; - sortActivities(); - } - } - - /** - * Sorts the activities based on history and an intent. If - * a sorter is not specified this a default implementation is used. - * - * @see #setActivitySorter(ActivitySorter) - */ - private void sortActivities() { - synchronized (mInstanceLock) { - if (mActivitySorter != null && !mActivites.isEmpty()) { - mActivitySorter.sort(mIntent, mActivites, - Collections.unmodifiableList(mHistoricalRecords)); - notifyChanged(); - } - } - } - - /** - * Sets the maximal size of the historical data. Defaults to - * {@link #DEFAULT_HISTORY_MAX_LENGTH} - *

- * Note: Setting this property will immediately - * enforce the specified max history size by dropping enough old - * historical records to enforce the desired size. Thus, any - * records that exceed the history size will be discarded and - * irreversibly lost. - *

- * - * @param historyMaxSize The max history size. - */ - public void setHistoryMaxSize(int historyMaxSize) { - synchronized (mInstanceLock) { - if (mHistoryMaxSize == historyMaxSize) { - return; - } - mHistoryMaxSize = historyMaxSize; - pruneExcessiveHistoricalRecordsLocked(); - sortActivities(); - } - } - - /** - * Gets the history max size. - * - * @return The history max size. - */ - public int getHistoryMaxSize() { - synchronized (mInstanceLock) { - return mHistoryMaxSize; - } - } - - /** - * Gets the history size. - * - * @return The history size. - */ - public int getHistorySize() { - synchronized (mInstanceLock) { - return mHistoricalRecords.size(); - } - } - - /** - * Adds a historical record. - * - * @param historicalRecord The record to add. - * @return True if the record was added. - */ - private boolean addHisoricalRecord(HistoricalRecord historicalRecord) { - synchronized (mInstanceLock) { - final boolean added = mHistoricalRecords.add(historicalRecord); - if (added) { - mHistoricalRecordsChanged = true; - pruneExcessiveHistoricalRecordsLocked(); - persistHistoricalData(); - sortActivities(); - } - return added; - } - } - - /** - * Prunes older excessive records to guarantee {@link #mHistoryMaxSize}. - */ - private void pruneExcessiveHistoricalRecordsLocked() { - List choiceRecords = mHistoricalRecords; - final int pruneCount = choiceRecords.size() - mHistoryMaxSize; - if (pruneCount <= 0) { - return; - } - mHistoricalRecordsChanged = true; - for (int i = 0; i < pruneCount; i++) { - HistoricalRecord prunedRecord = choiceRecords.remove(0); - if (DEBUG) { - Log.i(LOG_TAG, "Pruned: " + prunedRecord); - } - } - } - - /** - * Loads the activities. - */ - private void loadActivitiesLocked() { - mActivites.clear(); - if (mIntent != null) { - List resolveInfos = - mContext.getPackageManager().queryIntentActivities(mIntent, 0); - final int resolveInfoCount = resolveInfos.size(); - for (int i = 0; i < resolveInfoCount; i++) { - ResolveInfo resolveInfo = resolveInfos.get(i); - mActivites.add(new ActivityResolveInfo(resolveInfo)); - } - sortActivities(); - } else { - notifyChanged(); - } - } - - /** - * Represents a record in the history. - */ - public final static class HistoricalRecord { - - /** - * The activity name. - */ - public final ComponentName activity; - - /** - * The choice time. - */ - public final long time; - - /** - * The record weight. - */ - public final float weight; - - /** - * Creates a new instance. - * - * @param activityName The activity component name flattened to string. - * @param time The time the activity was chosen. - * @param weight The weight of the record. - */ - public HistoricalRecord(String activityName, long time, float weight) { - this(ComponentName.unflattenFromString(activityName), time, weight); - } - - /** - * Creates a new instance. - * - * @param activityName The activity name. - * @param time The time the activity was chosen. - * @param weight The weight of the record. - */ - public HistoricalRecord(ComponentName activityName, long time, float weight) { - this.activity = activityName; - this.time = time; - this.weight = weight; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((activity == null) ? 0 : activity.hashCode()); - result = prime * result + (int) (time ^ (time >>> 32)); - result = prime * result + Float.floatToIntBits(weight); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - HistoricalRecord other = (HistoricalRecord) obj; - if (activity == null) { - if (other.activity != null) { - return false; - } - } else if (!activity.equals(other.activity)) { - return false; - } - if (time != other.time) { - return false; - } - if (Float.floatToIntBits(weight) != Float.floatToIntBits(other.weight)) { - return false; - } - return true; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("["); - builder.append("; activity:").append(activity); - builder.append("; time:").append(time); - builder.append("; weight:").append(new BigDecimal(weight)); - builder.append("]"); - return builder.toString(); - } - } - - /** - * Represents an activity. - */ - public final class ActivityResolveInfo implements Comparable { - - /** - * The {@link ResolveInfo} of the activity. - */ - public final ResolveInfo resolveInfo; - - /** - * Weight of the activity. Useful for sorting. - */ - public float weight; - - /** - * Creates a new instance. - * - * @param resolveInfo activity {@link ResolveInfo}. - */ - public ActivityResolveInfo(ResolveInfo resolveInfo) { - this.resolveInfo = resolveInfo; - } - - @Override - public int hashCode() { - return 31 + Float.floatToIntBits(weight); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - ActivityResolveInfo other = (ActivityResolveInfo) obj; - if (Float.floatToIntBits(weight) != Float.floatToIntBits(other.weight)) { - return false; - } - return true; - } - - public int compareTo(ActivityResolveInfo another) { - return Float.floatToIntBits(another.weight) - Float.floatToIntBits(weight); - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("["); - builder.append("resolveInfo:").append(resolveInfo.toString()); - builder.append("; weight:").append(new BigDecimal(weight)); - builder.append("]"); - return builder.toString(); - } - } - - /** - * Default activity sorter implementation. - */ - private final class DefaultSorter implements ActivitySorter { - private static final float WEIGHT_DECAY_COEFFICIENT = 0.95f; - - private final Map mPackageNameToActivityMap = - new HashMap(); - - public void sort(Intent intent, List activities, - List historicalRecords) { - Map packageNameToActivityMap = - mPackageNameToActivityMap; - packageNameToActivityMap.clear(); - - final int activityCount = activities.size(); - for (int i = 0; i < activityCount; i++) { - ActivityResolveInfo activity = activities.get(i); - activity.weight = 0.0f; - String packageName = activity.resolveInfo.activityInfo.packageName; - packageNameToActivityMap.put(packageName, activity); - } - - final int lastShareIndex = historicalRecords.size() - 1; - float nextRecordWeight = 1; - for (int i = lastShareIndex; i >= 0; i--) { - HistoricalRecord historicalRecord = historicalRecords.get(i); - String packageName = historicalRecord.activity.getPackageName(); - ActivityResolveInfo activity = packageNameToActivityMap.get(packageName); - if (activity != null) { - activity.weight += historicalRecord.weight * nextRecordWeight; - nextRecordWeight = nextRecordWeight * WEIGHT_DECAY_COEFFICIENT; - } - } - - Collections.sort(activities); - - if (DEBUG) { - for (int i = 0; i < activityCount; i++) { - Log.i(LOG_TAG, "Sorted: " + activities.get(i)); - } - } - } - } - - /** - * Command for reading the historical records from a file off the UI thread. - */ - private final class HistoryLoader implements Runnable { - - public void run() { - FileInputStream fis = null; - try { - fis = mContext.openFileInput(mHistoryFileName); - } catch (FileNotFoundException fnfe) { - if (DEBUG) { - Log.i(LOG_TAG, "Could not open historical records file: " + mHistoryFileName); - } - return; - } - try { - XmlPullParser parser = Xml.newPullParser(); - parser.setInput(fis, null); - - int type = XmlPullParser.START_DOCUMENT; - while (type != XmlPullParser.END_DOCUMENT && type != XmlPullParser.START_TAG) { - type = parser.next(); - } - - if (!TAG_HISTORICAL_RECORDS.equals(parser.getName())) { - throw new XmlPullParserException("Share records file does not start with " - + TAG_HISTORICAL_RECORDS + " tag."); - } - - List readRecords = new ArrayList(); - - while (true) { - type = parser.next(); - if (type == XmlPullParser.END_DOCUMENT) { - break; - } - if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { - continue; - } - String nodeName = parser.getName(); - if (!TAG_HISTORICAL_RECORD.equals(nodeName)) { - throw new XmlPullParserException("Share records file not well-formed."); - } - - String activity = parser.getAttributeValue(null, ATTRIBUTE_ACTIVITY); - final long time = - Long.parseLong(parser.getAttributeValue(null, ATTRIBUTE_TIME)); - final float weight = - Float.parseFloat(parser.getAttributeValue(null, ATTRIBUTE_WEIGHT)); - - HistoricalRecord readRecord = new HistoricalRecord(activity, time, - weight); - readRecords.add(readRecord); - - if (DEBUG) { - Log.i(LOG_TAG, "Read " + readRecord.toString()); - } - } - - if (DEBUG) { - Log.i(LOG_TAG, "Read " + readRecords.size() + " historical records."); - } - - synchronized (mInstanceLock) { - Set uniqueShareRecords = - new LinkedHashSet(readRecords); - - // Make sure no duplicates. Example: Read a file with - // one record, add one record, persist the two records, - // add a record, read the persisted records - the - // read two records should not be added again. - List historicalRecords = mHistoricalRecords; - final int historicalRecordsCount = historicalRecords.size(); - for (int i = historicalRecordsCount - 1; i >= 0; i--) { - HistoricalRecord historicalRecord = historicalRecords.get(i); - uniqueShareRecords.add(historicalRecord); - } - - if (historicalRecords.size() == uniqueShareRecords.size()) { - return; - } - - // Make sure the oldest records go to the end. - historicalRecords.clear(); - historicalRecords.addAll(uniqueShareRecords); - - mHistoricalRecordsChanged = true; - - // Do this on the client thread since the client may be on the UI - // thread, wait for data changes which happen during sorting, and - // perform UI modification based on the data change. - mHandler.post(new Runnable() { - public void run() { - pruneExcessiveHistoricalRecordsLocked(); - sortActivities(); - } - }); - } - } catch (XmlPullParserException xppe) { - Log.e(LOG_TAG, "Error reading historical recrod file: " + mHistoryFileName, xppe); - } catch (IOException ioe) { - Log.e(LOG_TAG, "Error reading historical recrod file: " + mHistoryFileName, ioe); - } finally { - if (fis != null) { - try { - fis.close(); - } catch (IOException ioe) { - /* ignore */ - } - } - } - } - } - - /** - * Command for persisting the historical records to a file off the UI thread. - */ - private final class HistoryPersister implements Runnable { - - public void run() { - FileOutputStream fos = null; - List records = null; - - synchronized (mInstanceLock) { - records = new ArrayList(mHistoricalRecords); - } - - try { - fos = mContext.openFileOutput(mHistoryFileName, Context.MODE_PRIVATE); - } catch (FileNotFoundException fnfe) { - Log.e(LOG_TAG, "Error writing historical recrod file: " + mHistoryFileName, fnfe); - return; - } - - XmlSerializer serializer = Xml.newSerializer(); - - try { - serializer.setOutput(fos, null); - serializer.startDocument("UTF-8", true); - serializer.startTag(null, TAG_HISTORICAL_RECORDS); - - final int recordCount = records.size(); - for (int i = 0; i < recordCount; i++) { - HistoricalRecord record = records.remove(0); - serializer.startTag(null, TAG_HISTORICAL_RECORD); - serializer.attribute(null, ATTRIBUTE_ACTIVITY, record.activity.flattenToString()); - serializer.attribute(null, ATTRIBUTE_TIME, String.valueOf(record.time)); - serializer.attribute(null, ATTRIBUTE_WEIGHT, String.valueOf(record.weight)); - serializer.endTag(null, TAG_HISTORICAL_RECORD); - if (DEBUG) { - Log.i(LOG_TAG, "Wrote " + record.toString()); - } - } - - serializer.endTag(null, TAG_HISTORICAL_RECORDS); - serializer.endDocument(); - - if (DEBUG) { - Log.i(LOG_TAG, "Wrote " + recordCount + " historical records."); - } - } catch (IllegalArgumentException iae) { - Log.e(LOG_TAG, "Error writing historical recrod file: " + mHistoryFileName, iae); - } catch (IllegalStateException ise) { - Log.e(LOG_TAG, "Error writing historical recrod file: " + mHistoryFileName, ise); - } catch (IOException ioe) { - Log.e(LOG_TAG, "Error writing historical recrod file: " + mHistoryFileName, ioe); - } finally { - if (fos != null) { - try { - fos.close(); - } catch (IOException e) { - /* ignore */ - } - } - } - } - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/widget/ActivityChooserView.java b/actionbarsherlock/src/com/actionbarsherlock/widget/ActivityChooserView.java deleted file mode 100644 index da13bc99f..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/widget/ActivityChooserView.java +++ /dev/null @@ -1,818 +0,0 @@ -/* - * Copyright (C) 2011 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.actionbarsherlock.widget; - -import android.os.Build; -import com.actionbarsherlock.R; -import com.actionbarsherlock.internal.widget.IcsLinearLayout; -import com.actionbarsherlock.internal.widget.IcsListPopupWindow; -import com.actionbarsherlock.view.ActionProvider; -import com.actionbarsherlock.widget.ActivityChooserModel.ActivityChooserModelClient; -import android.content.Context; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; -import android.content.res.Resources; -import android.content.res.TypedArray; -import android.database.DataSetObserver; -import android.graphics.drawable.Drawable; -import android.util.AttributeSet; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.ViewTreeObserver; -import android.view.ViewTreeObserver.OnGlobalLayoutListener; -import android.widget.AdapterView; -import android.widget.BaseAdapter; -import android.widget.FrameLayout; -import android.widget.ImageView; -import android.widget.PopupWindow; -import android.widget.TextView; - -/** - * This class is a view for choosing an activity for handling a given {@link Intent}. - *

- * The view is composed of two adjacent buttons: - *

    - *
  • - * The left button is an immediate action and allows one click activity choosing. - * Tapping this button immediately executes the intent without requiring any further - * user input. Long press on this button shows a popup for changing the default - * activity. - *
  • - *
  • - * The right button is an overflow action and provides an optimized menu - * of additional activities. Tapping this button shows a popup anchored to this - * view, listing the most frequently used activities. This list is initially - * limited to a small number of items in frequency used order. The last item, - * "Show all..." serves as an affordance to display all available activities. - *
  • - *
- *

- * - * @hide - */ -class ActivityChooserView extends ViewGroup implements ActivityChooserModelClient { - - /** - * An adapter for displaying the activities in an {@link AdapterView}. - */ - private final ActivityChooserViewAdapter mAdapter; - - /** - * Implementation of various interfaces to avoid publishing them in the APIs. - */ - private final Callbacks mCallbacks; - - /** - * The content of this view. - */ - private final IcsLinearLayout mActivityChooserContent; - - /** - * Stores the background drawable to allow hiding and latter showing. - */ - private final Drawable mActivityChooserContentBackground; - - /** - * The expand activities action button; - */ - private final FrameLayout mExpandActivityOverflowButton; - - /** - * The image for the expand activities action button; - */ - private final ImageView mExpandActivityOverflowButtonImage; - - /** - * The default activities action button; - */ - private final FrameLayout mDefaultActivityButton; - - /** - * The image for the default activities action button; - */ - private final ImageView mDefaultActivityButtonImage; - - /** - * The maximal width of the list popup. - */ - private final int mListPopupMaxWidth; - - /** - * The ActionProvider hosting this view, if applicable. - */ - ActionProvider mProvider; - - /** - * Observer for the model data. - */ - private final DataSetObserver mModelDataSetOberver = new DataSetObserver() { - - @Override - public void onChanged() { - super.onChanged(); - mAdapter.notifyDataSetChanged(); - } - @Override - public void onInvalidated() { - super.onInvalidated(); - mAdapter.notifyDataSetInvalidated(); - } - }; - - private final OnGlobalLayoutListener mOnGlobalLayoutListener = new OnGlobalLayoutListener() { - @Override - public void onGlobalLayout() { - if (isShowingPopup()) { - if (!isShown()) { - getListPopupWindow().dismiss(); - } else { - getListPopupWindow().show(); - if (mProvider != null) { - mProvider.subUiVisibilityChanged(true); - } - } - } - } - }; - - /** - * Popup window for showing the activity overflow list. - */ - private IcsListPopupWindow mListPopupWindow; - - /** - * Listener for the dismissal of the popup/alert. - */ - private PopupWindow.OnDismissListener mOnDismissListener; - - /** - * Flag whether a default activity currently being selected. - */ - private boolean mIsSelectingDefaultActivity; - - /** - * The count of activities in the popup. - */ - private int mInitialActivityCount = ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_DEFAULT; - - /** - * Flag whether this view is attached to a window. - */ - private boolean mIsAttachedToWindow; - - /** - * String resource for formatting content description of the default target. - */ - private int mDefaultActionButtonContentDescription; - - private final Context mContext; - - /** - * Create a new instance. - * - * @param context The application environment. - */ - public ActivityChooserView(Context context) { - this(context, null); - } - - /** - * Create a new instance. - * - * @param context The application environment. - * @param attrs A collection of attributes. - */ - public ActivityChooserView(Context context, AttributeSet attrs) { - this(context, attrs, 0); - } - - /** - * Create a new instance. - * - * @param context The application environment. - * @param attrs A collection of attributes. - * @param defStyle The default style to apply to this view. - */ - public ActivityChooserView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - mContext = context; - - TypedArray attributesArray = context.obtainStyledAttributes(attrs, - R.styleable.SherlockActivityChooserView, defStyle, 0); - - mInitialActivityCount = attributesArray.getInt( - R.styleable.SherlockActivityChooserView_initialActivityCount, - ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_DEFAULT); - - Drawable expandActivityOverflowButtonDrawable = attributesArray.getDrawable( - R.styleable.SherlockActivityChooserView_expandActivityOverflowButtonDrawable); - - attributesArray.recycle(); - - LayoutInflater inflater = LayoutInflater.from(mContext); - inflater.inflate(R.layout.abs__activity_chooser_view, this, true); - - mCallbacks = new Callbacks(); - - mActivityChooserContent = (IcsLinearLayout) findViewById(R.id.abs__activity_chooser_view_content); - mActivityChooserContentBackground = mActivityChooserContent.getBackground(); - - mDefaultActivityButton = (FrameLayout) findViewById(R.id.abs__default_activity_button); - mDefaultActivityButton.setOnClickListener(mCallbacks); - mDefaultActivityButton.setOnLongClickListener(mCallbacks); - mDefaultActivityButtonImage = (ImageView) mDefaultActivityButton.findViewById(R.id.abs__image); - - mExpandActivityOverflowButton = (FrameLayout) findViewById(R.id.abs__expand_activities_button); - mExpandActivityOverflowButton.setOnClickListener(mCallbacks); - mExpandActivityOverflowButtonImage = - (ImageView) mExpandActivityOverflowButton.findViewById(R.id.abs__image); - mExpandActivityOverflowButtonImage.setImageDrawable(expandActivityOverflowButtonDrawable); - - mAdapter = new ActivityChooserViewAdapter(); - mAdapter.registerDataSetObserver(new DataSetObserver() { - @Override - public void onChanged() { - super.onChanged(); - updateAppearance(); - } - }); - - Resources resources = context.getResources(); - mListPopupMaxWidth = Math.max(resources.getDisplayMetrics().widthPixels / 2, - resources.getDimensionPixelSize(R.dimen.abs__config_prefDialogWidth)); - } - - /** - * {@inheritDoc} - */ - public void setActivityChooserModel(ActivityChooserModel dataModel) { - mAdapter.setDataModel(dataModel); - if (isShowingPopup()) { - dismissPopup(); - showPopup(); - } - } - - /** - * Sets the background for the button that expands the activity - * overflow list. - * - * Note: Clients would like to set this drawable - * as a clue about the action the chosen activity will perform. For - * example, if a share activity is to be chosen the drawable should - * give a clue that sharing is to be performed. - * - * @param drawable The drawable. - */ - public void setExpandActivityOverflowButtonDrawable(Drawable drawable) { - mExpandActivityOverflowButtonImage.setImageDrawable(drawable); - } - - /** - * Sets the content description for the button that expands the activity - * overflow list. - * - * description as a clue about the action performed by the button. - * For example, if a share activity is to be chosen the content - * description should be something like "Share with". - * - * @param resourceId The content description resource id. - */ - public void setExpandActivityOverflowButtonContentDescription(int resourceId) { - CharSequence contentDescription = mContext.getString(resourceId); - mExpandActivityOverflowButtonImage.setContentDescription(contentDescription); - } - - /** - * Set the provider hosting this view, if applicable. - * @hide Internal use only - */ - public void setProvider(ActionProvider provider) { - mProvider = provider; - } - - /** - * Shows the popup window with activities. - * - * @return True if the popup was shown, false if already showing. - */ - public boolean showPopup() { - if (isShowingPopup() || !mIsAttachedToWindow) { - return false; - } - mIsSelectingDefaultActivity = false; - showPopupUnchecked(mInitialActivityCount); - return true; - } - - /** - * Shows the popup no matter if it was already showing. - * - * @param maxActivityCount The max number of activities to display. - */ - private void showPopupUnchecked(int maxActivityCount) { - if (mAdapter.getDataModel() == null) { - throw new IllegalStateException("No data model. Did you call #setDataModel?"); - } - - getViewTreeObserver().addOnGlobalLayoutListener(mOnGlobalLayoutListener); - - final boolean defaultActivityButtonShown = - mDefaultActivityButton.getVisibility() == VISIBLE; - - final int activityCount = mAdapter.getActivityCount(); - final int maxActivityCountOffset = defaultActivityButtonShown ? 1 : 0; - if (maxActivityCount != ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED - && activityCount > maxActivityCount + maxActivityCountOffset) { - mAdapter.setShowFooterView(true); - mAdapter.setMaxActivityCount(maxActivityCount - 1); - } else { - mAdapter.setShowFooterView(false); - mAdapter.setMaxActivityCount(maxActivityCount); - } - - IcsListPopupWindow popupWindow = getListPopupWindow(); - if (!popupWindow.isShowing()) { - if (mIsSelectingDefaultActivity || !defaultActivityButtonShown) { - mAdapter.setShowDefaultActivity(true, defaultActivityButtonShown); - } else { - mAdapter.setShowDefaultActivity(false, false); - } - final int contentWidth = Math.min(mAdapter.measureContentWidth(), mListPopupMaxWidth); - popupWindow.setContentWidth(contentWidth); - popupWindow.show(); - if (mProvider != null) { - mProvider.subUiVisibilityChanged(true); - } - popupWindow.getListView().setContentDescription(mContext.getString( - R.string.abs__activitychooserview_choose_application)); - } - } - - /** - * Dismisses the popup window with activities. - * - * @return True if dismissed, false if already dismissed. - */ - public boolean dismissPopup() { - if (isShowingPopup()) { - getListPopupWindow().dismiss(); - ViewTreeObserver viewTreeObserver = getViewTreeObserver(); - if (viewTreeObserver.isAlive()) { - viewTreeObserver.removeGlobalOnLayoutListener(mOnGlobalLayoutListener); - } - } - return true; - } - - /** - * Gets whether the popup window with activities is shown. - * - * @return True if the popup is shown. - */ - public boolean isShowingPopup() { - return getListPopupWindow().isShowing(); - } - - @Override - protected void onAttachedToWindow() { - super.onAttachedToWindow(); - ActivityChooserModel dataModel = mAdapter.getDataModel(); - if (dataModel != null) { - dataModel.registerObserver(mModelDataSetOberver); - } - mIsAttachedToWindow = true; - } - - @Override - protected void onDetachedFromWindow() { - super.onDetachedFromWindow(); - ActivityChooserModel dataModel = mAdapter.getDataModel(); - if (dataModel != null) { - dataModel.unregisterObserver(mModelDataSetOberver); - } - ViewTreeObserver viewTreeObserver = getViewTreeObserver(); - if (viewTreeObserver.isAlive()) { - viewTreeObserver.removeGlobalOnLayoutListener(mOnGlobalLayoutListener); - } - mIsAttachedToWindow = false; - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - View child = mActivityChooserContent; - // If the default action is not visible we want to be as tall as the - // ActionBar so if this widget is used in the latter it will look as - // a normal action button. - if (mDefaultActivityButton.getVisibility() != VISIBLE) { - heightMeasureSpec = MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(heightMeasureSpec), - MeasureSpec.EXACTLY); - } - measureChild(child, widthMeasureSpec, heightMeasureSpec); - setMeasuredDimension(child.getMeasuredWidth(), child.getMeasuredHeight()); - } - - @Override - protected void onLayout(boolean changed, int left, int top, int right, int bottom) { - mActivityChooserContent.layout(0, 0, right - left, bottom - top); - if (getListPopupWindow().isShowing()) { - showPopupUnchecked(mAdapter.getMaxActivityCount()); - } else { - dismissPopup(); - } - } - - public ActivityChooserModel getDataModel() { - return mAdapter.getDataModel(); - } - - /** - * Sets a listener to receive a callback when the popup is dismissed. - * - * @param listener The listener to be notified. - */ - public void setOnDismissListener(PopupWindow.OnDismissListener listener) { - mOnDismissListener = listener; - } - - /** - * Sets the initial count of items shown in the activities popup - * i.e. the items before the popup is expanded. This is an upper - * bound since it is not guaranteed that such number of intent - * handlers exist. - * - * @param itemCount The initial popup item count. - */ - public void setInitialActivityCount(int itemCount) { - mInitialActivityCount = itemCount; - } - - /** - * Sets a content description of the default action button. This - * resource should be a string taking one formatting argument and - * will be used for formatting the content description of the button - * dynamically as the default target changes. For example, a resource - * pointing to the string "share with %1$s" will result in a content - * description "share with Bluetooth" for the Bluetooth activity. - * - * @param resourceId The resource id. - */ - public void setDefaultActionButtonContentDescription(int resourceId) { - mDefaultActionButtonContentDescription = resourceId; - } - - /** - * Gets the list popup window which is lazily initialized. - * - * @return The popup. - */ - private IcsListPopupWindow getListPopupWindow() { - if (mListPopupWindow == null) { - mListPopupWindow = new IcsListPopupWindow(getContext()); - mListPopupWindow.setAdapter(mAdapter); - mListPopupWindow.setAnchorView(ActivityChooserView.this); - mListPopupWindow.setModal(true); - mListPopupWindow.setOnItemClickListener(mCallbacks); - mListPopupWindow.setOnDismissListener(mCallbacks); - } - return mListPopupWindow; - } - - /** - * Updates the buttons state. - */ - private void updateAppearance() { - // Expand overflow button. - if (mAdapter.getCount() > 0) { - mExpandActivityOverflowButton.setEnabled(true); - } else { - mExpandActivityOverflowButton.setEnabled(false); - } - // Default activity button. - final int activityCount = mAdapter.getActivityCount(); - final int historySize = mAdapter.getHistorySize(); - if (activityCount > 0 && historySize > 0) { - mDefaultActivityButton.setVisibility(VISIBLE); - ResolveInfo activity = mAdapter.getDefaultActivity(); - PackageManager packageManager = mContext.getPackageManager(); - mDefaultActivityButtonImage.setImageDrawable(activity.loadIcon(packageManager)); - if (mDefaultActionButtonContentDescription != 0) { - CharSequence label = activity.loadLabel(packageManager); - String contentDescription = mContext.getString( - mDefaultActionButtonContentDescription, label); - mDefaultActivityButton.setContentDescription(contentDescription); - } - } else { - mDefaultActivityButton.setVisibility(View.GONE); - } - // Activity chooser content. - if (mDefaultActivityButton.getVisibility() == VISIBLE) { - mActivityChooserContent.setBackgroundDrawable(mActivityChooserContentBackground); - } else { - mActivityChooserContent.setBackgroundDrawable(null); - } - } - - /** - * Interface implementation to avoid publishing them in the APIs. - */ - private class Callbacks implements AdapterView.OnItemClickListener, - View.OnClickListener, View.OnLongClickListener, PopupWindow.OnDismissListener { - - // AdapterView#OnItemClickListener - public void onItemClick(AdapterView parent, View view, int position, long id) { - ActivityChooserViewAdapter adapter = (ActivityChooserViewAdapter) parent.getAdapter(); - final int itemViewType = adapter.getItemViewType(position); - switch (itemViewType) { - case ActivityChooserViewAdapter.ITEM_VIEW_TYPE_FOOTER: { - showPopupUnchecked(ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED); - } break; - case ActivityChooserViewAdapter.ITEM_VIEW_TYPE_ACTIVITY: { - dismissPopup(); - if (mIsSelectingDefaultActivity) { - // The item at position zero is the default already. - if (position > 0) { - mAdapter.getDataModel().setDefaultActivity(position); - } - } else { - // If the default target is not shown in the list, the first - // item in the model is default action => adjust index - position = mAdapter.getShowDefaultActivity() ? position : position + 1; - Intent launchIntent = mAdapter.getDataModel().chooseActivity(position); - if (launchIntent != null) { - mContext.startActivity(launchIntent); - } - } - } break; - default: - throw new IllegalArgumentException(); - } - } - - // View.OnClickListener - public void onClick(View view) { - if (view == mDefaultActivityButton) { - dismissPopup(); - ResolveInfo defaultActivity = mAdapter.getDefaultActivity(); - final int index = mAdapter.getDataModel().getActivityIndex(defaultActivity); - Intent launchIntent = mAdapter.getDataModel().chooseActivity(index); - if (launchIntent != null) { - mContext.startActivity(launchIntent); - } - } else if (view == mExpandActivityOverflowButton) { - mIsSelectingDefaultActivity = false; - showPopupUnchecked(mInitialActivityCount); - } else { - throw new IllegalArgumentException(); - } - } - - // OnLongClickListener#onLongClick - @Override - public boolean onLongClick(View view) { - if (view == mDefaultActivityButton) { - if (mAdapter.getCount() > 0) { - mIsSelectingDefaultActivity = true; - showPopupUnchecked(mInitialActivityCount); - } - } else { - throw new IllegalArgumentException(); - } - return true; - } - - // PopUpWindow.OnDismissListener#onDismiss - public void onDismiss() { - notifyOnDismissListener(); - if (mProvider != null) { - mProvider.subUiVisibilityChanged(false); - } - } - - private void notifyOnDismissListener() { - if (mOnDismissListener != null) { - mOnDismissListener.onDismiss(); - } - } - } - - private static class SetActivated { - public static void invoke(View view, boolean activated) { - view.setActivated(activated); - } - } - - private static final boolean IS_HONEYCOMB = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB; - - /** - * Adapter for backing the list of activities shown in the popup. - */ - private class ActivityChooserViewAdapter extends BaseAdapter { - - public static final int MAX_ACTIVITY_COUNT_UNLIMITED = Integer.MAX_VALUE; - - public static final int MAX_ACTIVITY_COUNT_DEFAULT = 4; - - private static final int ITEM_VIEW_TYPE_ACTIVITY = 0; - - private static final int ITEM_VIEW_TYPE_FOOTER = 1; - - private static final int ITEM_VIEW_TYPE_COUNT = 3; - - private ActivityChooserModel mDataModel; - - private int mMaxActivityCount = MAX_ACTIVITY_COUNT_DEFAULT; - - private boolean mShowDefaultActivity; - - private boolean mHighlightDefaultActivity; - - private boolean mShowFooterView; - - public void setDataModel(ActivityChooserModel dataModel) { - ActivityChooserModel oldDataModel = mAdapter.getDataModel(); - if (oldDataModel != null && isShown()) { - oldDataModel.unregisterObserver(mModelDataSetOberver); - } - mDataModel = dataModel; - if (dataModel != null && isShown()) { - dataModel.registerObserver(mModelDataSetOberver); - } - notifyDataSetChanged(); - } - - @Override - public int getItemViewType(int position) { - if (mShowFooterView && position == getCount() - 1) { - return ITEM_VIEW_TYPE_FOOTER; - } else { - return ITEM_VIEW_TYPE_ACTIVITY; - } - } - - @Override - public int getViewTypeCount() { - return ITEM_VIEW_TYPE_COUNT; - } - - public int getCount() { - int count = 0; - int activityCount = mDataModel.getActivityCount(); - if (!mShowDefaultActivity && mDataModel.getDefaultActivity() != null) { - activityCount--; - } - count = Math.min(activityCount, mMaxActivityCount); - if (mShowFooterView) { - count++; - } - return count; - } - - public Object getItem(int position) { - final int itemViewType = getItemViewType(position); - switch (itemViewType) { - case ITEM_VIEW_TYPE_FOOTER: - return null; - case ITEM_VIEW_TYPE_ACTIVITY: - if (!mShowDefaultActivity && mDataModel.getDefaultActivity() != null) { - position++; - } - return mDataModel.getActivity(position); - default: - throw new IllegalArgumentException(); - } - } - - public long getItemId(int position) { - return position; - } - - public View getView(int position, View convertView, ViewGroup parent) { - final int itemViewType = getItemViewType(position); - switch (itemViewType) { - case ITEM_VIEW_TYPE_FOOTER: - if (convertView == null || convertView.getId() != ITEM_VIEW_TYPE_FOOTER) { - convertView = LayoutInflater.from(getContext()).inflate( - R.layout.abs__activity_chooser_view_list_item, parent, false); - convertView.setId(ITEM_VIEW_TYPE_FOOTER); - TextView titleView = (TextView) convertView.findViewById(R.id.abs__title); - titleView.setText(mContext.getString( - R.string.abs__activity_chooser_view_see_all)); - } - return convertView; - case ITEM_VIEW_TYPE_ACTIVITY: - if (convertView == null || convertView.getId() != R.id.abs__list_item) { - convertView = LayoutInflater.from(getContext()).inflate( - R.layout.abs__activity_chooser_view_list_item, parent, false); - } - PackageManager packageManager = mContext.getPackageManager(); - // Set the icon - ImageView iconView = (ImageView) convertView.findViewById(R.id.abs__icon); - ResolveInfo activity = (ResolveInfo) getItem(position); - iconView.setImageDrawable(activity.loadIcon(packageManager)); - // Set the title. - TextView titleView = (TextView) convertView.findViewById(R.id.abs__title); - titleView.setText(activity.loadLabel(packageManager)); - if (IS_HONEYCOMB) { - // Highlight the default. - if (mShowDefaultActivity && position == 0 && mHighlightDefaultActivity) { - SetActivated.invoke(convertView, true); - } else { - SetActivated.invoke(convertView, false); - } - } - return convertView; - default: - throw new IllegalArgumentException(); - } - } - - public int measureContentWidth() { - // The user may have specified some of the target not to be shown but we - // want to measure all of them since after expansion they should fit. - final int oldMaxActivityCount = mMaxActivityCount; - mMaxActivityCount = MAX_ACTIVITY_COUNT_UNLIMITED; - - int contentWidth = 0; - View itemView = null; - - final int widthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); - final int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); - final int count = getCount(); - - for (int i = 0; i < count; i++) { - itemView = getView(i, itemView, null); - itemView.measure(widthMeasureSpec, heightMeasureSpec); - contentWidth = Math.max(contentWidth, itemView.getMeasuredWidth()); - } - - mMaxActivityCount = oldMaxActivityCount; - - return contentWidth; - } - - public void setMaxActivityCount(int maxActivityCount) { - if (mMaxActivityCount != maxActivityCount) { - mMaxActivityCount = maxActivityCount; - notifyDataSetChanged(); - } - } - - public ResolveInfo getDefaultActivity() { - return mDataModel.getDefaultActivity(); - } - - public void setShowFooterView(boolean showFooterView) { - if (mShowFooterView != showFooterView) { - mShowFooterView = showFooterView; - notifyDataSetChanged(); - } - } - - public int getActivityCount() { - return mDataModel.getActivityCount(); - } - - public int getHistorySize() { - return mDataModel.getHistorySize(); - } - - public int getMaxActivityCount() { - return mMaxActivityCount; - } - - public ActivityChooserModel getDataModel() { - return mDataModel; - } - - public void setShowDefaultActivity(boolean showDefaultActivity, - boolean highlightDefaultActivity) { - if (mShowDefaultActivity != showDefaultActivity - || mHighlightDefaultActivity != highlightDefaultActivity) { - mShowDefaultActivity = showDefaultActivity; - mHighlightDefaultActivity = highlightDefaultActivity; - notifyDataSetChanged(); - } - } - - public boolean getShowDefaultActivity() { - return mShowDefaultActivity; - } - } -} diff --git a/actionbarsherlock/src/com/actionbarsherlock/widget/ShareActionProvider.java b/actionbarsherlock/src/com/actionbarsherlock/widget/ShareActionProvider.java deleted file mode 100644 index 83e9f0ca9..000000000 --- a/actionbarsherlock/src/com/actionbarsherlock/widget/ShareActionProvider.java +++ /dev/null @@ -1,316 +0,0 @@ -/* - * Copyright (C) 2011 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.actionbarsherlock.widget; - -import android.content.Context; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; -import android.graphics.drawable.Drawable; -import android.util.TypedValue; -import android.view.View; - -import com.actionbarsherlock.R; -import com.actionbarsherlock.view.ActionProvider; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuItem; -import com.actionbarsherlock.view.MenuItem.OnMenuItemClickListener; -import com.actionbarsherlock.view.SubMenu; -import com.actionbarsherlock.widget.ActivityChooserModel.OnChooseActivityListener; - -/** - * This is a provider for a share action. It is responsible for creating views - * that enable data sharing and also to show a sub menu with sharing activities - * if the hosting item is placed on the overflow menu. - *

- * Here is how to use the action provider with custom backing file in a {@link MenuItem}: - *

- *

- *

- * 
- *  // In Activity#onCreateOptionsMenu
- *  public boolean onCreateOptionsMenu(Menu menu) {
- *      // Get the menu item.
- *      MenuItem menuItem = menu.findItem(R.id.my_menu_item);
- *      // Get the provider and hold onto it to set/change the share intent.
- *      mShareActionProvider = (ShareActionProvider) menuItem.getActionProvider();
- *      // Set history different from the default before getting the action
- *      // view since a call to {@link MenuItem#getActionView() MenuItem.getActionView()} calls
- *      // {@link ActionProvider#onCreateActionView()} which uses the backing file name. Omit this
- *      // line if using the default share history file is desired.
- *      mShareActionProvider.setShareHistoryFileName("custom_share_history.xml");
- *      . . .
- *  }
- *
- *  // Somewhere in the application.
- *  public void doShare(Intent shareIntent) {
- *      // When you want to share set the share intent.
- *      mShareActionProvider.setShareIntent(shareIntent);
- *  }
- * 
- * - *

- *

- * Note: While the sample snippet demonstrates how to use this provider - * in the context of a menu item, the use of the provider is not limited to menu items. - *

- * - * @see ActionProvider - */ -public class ShareActionProvider extends ActionProvider { - - /** - * Listener for the event of selecting a share target. - */ - public interface OnShareTargetSelectedListener { - - /** - * Called when a share target has been selected. The client can - * decide whether to handle the intent or rely on the default - * behavior which is launching it. - *

- * Note: Modifying the intent is not permitted and - * any changes to the latter will be ignored. - *

- * - * @param source The source of the notification. - * @param intent The intent for launching the chosen share target. - * @return Whether the client has handled the intent. - */ - public boolean onShareTargetSelected(ShareActionProvider source, Intent intent); - } - - /** - * The default for the maximal number of activities shown in the sub-menu. - */ - private static final int DEFAULT_INITIAL_ACTIVITY_COUNT = 4; - - /** - * The the maximum number activities shown in the sub-menu. - */ - private int mMaxShownActivityCount = DEFAULT_INITIAL_ACTIVITY_COUNT; - - /** - * Listener for handling menu item clicks. - */ - private final ShareMenuItemOnMenuItemClickListener mOnMenuItemClickListener = - new ShareMenuItemOnMenuItemClickListener(); - - /** - * The default name for storing share history. - */ - public static final String DEFAULT_SHARE_HISTORY_FILE_NAME = "share_history.xml"; - - /** - * Context for accessing resources. - */ - private final Context mContext; - - /** - * The name of the file with share history data. - */ - private String mShareHistoryFileName = DEFAULT_SHARE_HISTORY_FILE_NAME; - - private OnShareTargetSelectedListener mOnShareTargetSelectedListener; - - private OnChooseActivityListener mOnChooseActivityListener; - - /** - * Creates a new instance. - * - * @param context Context for accessing resources. - */ - public ShareActionProvider(Context context) { - super(context); - mContext = context; - } - - /** - * Sets a listener to be notified when a share target has been selected. - * The listener can optionally decide to handle the selection and - * not rely on the default behavior which is to launch the activity. - *

- * Note: If you choose the backing share history file - * you will still be notified in this callback. - *

- * @param listener The listener. - */ - public void setOnShareTargetSelectedListener(OnShareTargetSelectedListener listener) { - mOnShareTargetSelectedListener = listener; - setActivityChooserPolicyIfNeeded(); - } - - /** - * {@inheritDoc} - */ - @Override - public View onCreateActionView() { - // Create the view and set its data model. - ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName); - ActivityChooserView activityChooserView = new ActivityChooserView(mContext); - activityChooserView.setActivityChooserModel(dataModel); - - // Lookup and set the expand action icon. - TypedValue outTypedValue = new TypedValue(); - mContext.getTheme().resolveAttribute(R.attr.actionModeShareDrawable, outTypedValue, true); - Drawable drawable = mContext.getResources().getDrawable(outTypedValue.resourceId); - activityChooserView.setExpandActivityOverflowButtonDrawable(drawable); - activityChooserView.setProvider(this); - - // Set content description. - activityChooserView.setDefaultActionButtonContentDescription( - R.string.abs__shareactionprovider_share_with_application); - activityChooserView.setExpandActivityOverflowButtonContentDescription( - R.string.abs__shareactionprovider_share_with); - - return activityChooserView; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean hasSubMenu() { - return true; - } - - /** - * {@inheritDoc} - */ - @Override - public void onPrepareSubMenu(SubMenu subMenu) { - // Clear since the order of items may change. - subMenu.clear(); - - ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName); - PackageManager packageManager = mContext.getPackageManager(); - - final int expandedActivityCount = dataModel.getActivityCount(); - final int collapsedActivityCount = Math.min(expandedActivityCount, mMaxShownActivityCount); - - // Populate the sub-menu with a sub set of the activities. - for (int i = 0; i < collapsedActivityCount; i++) { - ResolveInfo activity = dataModel.getActivity(i); - subMenu.add(0, i, i, activity.loadLabel(packageManager)) - .setIcon(activity.loadIcon(packageManager)) - .setOnMenuItemClickListener(mOnMenuItemClickListener); - } - - if (collapsedActivityCount < expandedActivityCount) { - // Add a sub-menu for showing all activities as a list item. - SubMenu expandedSubMenu = subMenu.addSubMenu(Menu.NONE, collapsedActivityCount, - collapsedActivityCount, - mContext.getString(R.string.abs__activity_chooser_view_see_all)); - for (int i = 0; i < expandedActivityCount; i++) { - ResolveInfo activity = dataModel.getActivity(i); - expandedSubMenu.add(0, i, i, activity.loadLabel(packageManager)) - .setIcon(activity.loadIcon(packageManager)) - .setOnMenuItemClickListener(mOnMenuItemClickListener); - } - } - } - - /** - * Sets the file name of a file for persisting the share history which - * history will be used for ordering share targets. This file will be used - * for all view created by {@link #onCreateActionView()}. Defaults to - * {@link #DEFAULT_SHARE_HISTORY_FILE_NAME}. Set to null - * if share history should not be persisted between sessions. - *

- * Note: The history file name can be set any time, however - * only the action views created by {@link #onCreateActionView()} after setting - * the file name will be backed by the provided file. - *

- * - * @param shareHistoryFile The share history file name. - */ - public void setShareHistoryFileName(String shareHistoryFile) { - mShareHistoryFileName = shareHistoryFile; - setActivityChooserPolicyIfNeeded(); - } - - /** - * Sets an intent with information about the share action. Here is a - * sample for constructing a share intent: - *

- *

-     * 
-     *  Intent shareIntent = new Intent(Intent.ACTION_SEND);
-     *  shareIntent.setType("image/*");
-     *  Uri uri = Uri.fromFile(new File(getFilesDir(), "foo.jpg"));
-     *  shareIntent.putExtra(Intent.EXTRA_STREAM, uri.toString());
-     * 
- * - *

- * - * @param shareIntent The share intent. - * - * @see Intent#ACTION_SEND - * @see Intent#ACTION_SEND_MULTIPLE - */ - public void setShareIntent(Intent shareIntent) { - ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, - mShareHistoryFileName); - dataModel.setIntent(shareIntent); - } - - /** - * Reusable listener for handling share item clicks. - */ - private class ShareMenuItemOnMenuItemClickListener implements OnMenuItemClickListener { - @Override - public boolean onMenuItemClick(MenuItem item) { - ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, - mShareHistoryFileName); - final int itemId = item.getItemId(); - Intent launchIntent = dataModel.chooseActivity(itemId); - if (launchIntent != null) { - mContext.startActivity(launchIntent); - } - return true; - } - } - - /** - * Set the activity chooser policy of the model backed by the current - * share history file if needed which is if there is a registered callback. - */ - private void setActivityChooserPolicyIfNeeded() { - if (mOnShareTargetSelectedListener == null) { - return; - } - if (mOnChooseActivityListener == null) { - mOnChooseActivityListener = new ShareAcitivityChooserModelPolicy(); - } - ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName); - dataModel.setOnChooseActivityListener(mOnChooseActivityListener); - } - - /** - * Policy that delegates to the {@link OnShareTargetSelectedListener}, if such. - */ - private class ShareAcitivityChooserModelPolicy implements OnChooseActivityListener { - @Override - public boolean onChooseActivity(ActivityChooserModel host, Intent intent) { - if (mOnShareTargetSelectedListener != null) { - return mOnShareTargetSelectedListener.onShareTargetSelected( - ShareActionProvider.this, intent); - } - return false; - } - } -} diff --git a/proguard.flags b/proguard.flags index 15e97434e..66e53673e 100644 --- a/proguard.flags +++ b/proguard.flags @@ -35,11 +35,3 @@ # Disable the warnings of using dynamic method calls in EffectsRecorder -dontnote com.android.camera.EffectsRecorder - -# Required for ActionBarSherlock --keep class android.support.v4.app.** { *; } --keep interface android.support.v4.app.** { *; } --keep class com.actionbarsherlock.** { *; } --keep interface com.actionbarsherlock.** { *; } --keepattributes *Annotation* - diff --git a/res/values/styles.xml b/res/values/styles.xml index 10354a146..9bbee9191 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -15,7 +15,7 @@ --> - diff --git a/src/com/android/gallery3d/app/MovieActivity.java b/src/com/android/gallery3d/app/MovieActivity.java index bf2486927..26ae37e43 100644 --- a/src/com/android/gallery3d/app/MovieActivity.java +++ b/src/com/android/gallery3d/app/MovieActivity.java @@ -17,6 +17,7 @@ package com.android.gallery3d.app; import android.annotation.TargetApi; +import android.app.Activity; import android.content.AsyncQueryHandler; import android.content.ContentResolver; import android.content.Intent; @@ -31,14 +32,12 @@ import android.os.Bundle; import android.provider.MediaStore; import android.provider.OpenableColumns; import android.view.KeyEvent; +import android.view.Menu; +import android.view.MenuItem; import android.view.View; import android.view.Window; import android.view.WindowManager; -import com.actionbarsherlock.app.ActionBar; -import com.actionbarsherlock.app.SherlockActivity; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuItem; import com.android.gallery3d.R; import com.android.gallery3d.actionbar.ActionBarInterface; import com.android.gallery3d.actionbar.ActionBarUtils; @@ -52,7 +51,7 @@ import com.android.gallery3d.common.Utils; * to set the action bar logo so the playback process looks more seamlessly integrated with * the original activity. */ -public class MovieActivity extends SherlockActivity { +public class MovieActivity extends Activity { @SuppressWarnings("unused") private static final String TAG = "MovieActivity"; public static final String KEY_LOGO_BITMAP = "logo-bitmap"; @@ -117,17 +116,19 @@ public class MovieActivity extends SherlockActivity { win.setBackgroundDrawable(null); } + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) private void setActionBarLogoFromIntent(Intent intent) { - Bitmap logo = intent.getParcelableExtra(KEY_LOGO_BITMAP); - if (logo != null) { - getSupportActionBar().setLogo( - new BitmapDrawable(getResources(), logo)); + if (ApiHelper.HAS_ACTION_BAR_SET_LOGO) { + Bitmap logo = intent.getParcelableExtra(KEY_LOGO_BITMAP); + if (logo != null) { + getActionBar().setLogo(new BitmapDrawable(getResources(), logo)); + } } } private void initializeActionBar(Intent intent) { mUri = intent.getData(); - final ActionBar actionBar = getSupportActionBar(); + final ActionBarInterface actionBar = ActionBarUtils.getActionBar(this); setActionBarLogoFromIntent(intent); actionBar.setDisplayOptions(ActionBarInterface.DISPLAY_HOME_AS_UP, ActionBarInterface.DISPLAY_HOME_AS_UP); @@ -167,8 +168,7 @@ public class MovieActivity extends SherlockActivity { public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); ActionBarInterface actionBar = ActionBarUtils.getActionBar(this); - getSupportMenuInflater().inflate(R.menu.movie, menu); - + boolean result = actionBar.createActionMenu(menu, R.menu.movie); // Document says EXTRA_STREAM should be a content: Uri // So, we only share the video if it's "content:". if (ContentResolver.SCHEME_CONTENT.equals(mUri.getScheme())) { @@ -178,7 +178,7 @@ public class MovieActivity extends SherlockActivity { } else { menu.findItem(R.id.action_share).setVisible(false); } - return true; + return result; } private Intent createShareIntent() { -- GitLab From 8a861a02136d15b45b9dbdc80e4f3bcc9de057c8 Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Fri, 24 Aug 2012 15:09:42 +0800 Subject: [PATCH 208/763] Revert "Revert "Uses ActionBarSherlock library in MovieActivity."" This reverts commit 13da281769d4558c42d86a54536ff6da6826b0ac. --- Android.mk | 9 +- ...s__primary_text_disable_only_holo_dark.xml | 20 + ...__primary_text_disable_only_holo_light.xml | 21 + .../res/color/abs__primary_text_holo_dark.xml | 24 + .../color/abs__primary_text_holo_light.xml | 26 + .../abs__ab_bottom_solid_dark_holo.9.png | Bin 0 -> 144 bytes .../abs__ab_bottom_solid_inverse_holo.9.png | Bin 0 -> 138 bytes .../abs__ab_bottom_solid_light_holo.9.png | Bin 0 -> 144 bytes ...abs__ab_bottom_transparent_dark_holo.9.png | Bin 0 -> 135 bytes ...bs__ab_bottom_transparent_light_holo.9.png | Bin 0 -> 134 bytes .../abs__ab_share_pack_holo_dark.9.png | Bin 0 -> 2866 bytes .../abs__ab_share_pack_holo_light.9.png | Bin 0 -> 2862 bytes .../abs__ab_solid_dark_holo.9.png | Bin 0 -> 146 bytes .../abs__ab_solid_light_holo.9.png | Bin 0 -> 145 bytes .../abs__ab_solid_shadow_holo.9.png | Bin 0 -> 192 bytes .../abs__ab_stacked_solid_dark_holo.9.png | Bin 0 -> 146 bytes .../abs__ab_stacked_solid_light_holo.9.png | Bin 0 -> 146 bytes ...bs__ab_stacked_transparent_dark_holo.9.png | Bin 0 -> 139 bytes ...s__ab_stacked_transparent_light_holo.9.png | Bin 0 -> 133 bytes .../abs__ab_transparent_dark_holo.9.png | Bin 0 -> 155 bytes .../abs__ab_transparent_light_holo.9.png | Bin 0 -> 145 bytes .../abs__btn_cab_done_default_holo_dark.9.png | Bin 0 -> 104 bytes ...abs__btn_cab_done_default_holo_light.9.png | Bin 0 -> 102 bytes .../abs__btn_cab_done_focused_holo_dark.9.png | Bin 0 -> 112 bytes ...abs__btn_cab_done_focused_holo_light.9.png | Bin 0 -> 108 bytes .../abs__btn_cab_done_pressed_holo_dark.9.png | Bin 0 -> 110 bytes ...abs__btn_cab_done_pressed_holo_light.9.png | Bin 0 -> 108 bytes ...abs__cab_background_bottom_holo_dark.9.png | Bin 0 -> 149 bytes ...bs__cab_background_bottom_holo_light.9.png | Bin 0 -> 145 bytes .../abs__cab_background_top_holo_dark.9.png | Bin 0 -> 147 bytes .../abs__cab_background_top_holo_light.9.png | Bin 0 -> 147 bytes .../abs__dialog_full_holo_dark.9.png | Bin 0 -> 1414 bytes .../abs__dialog_full_holo_light.9.png | Bin 0 -> 1537 bytes .../abs__ic_ab_back_holo_dark.png | Bin 0 -> 602 bytes .../abs__ic_ab_back_holo_light.png | Bin 0 -> 546 bytes .../abs__ic_cab_done_holo_dark.png | Bin 0 -> 713 bytes .../abs__ic_cab_done_holo_light.png | Bin 0 -> 737 bytes ..._ic_menu_moreoverflow_normal_holo_dark.png | Bin 0 -> 144 bytes ...ic_menu_moreoverflow_normal_holo_light.png | Bin 0 -> 148 bytes .../abs__ic_menu_share_holo_dark.png | Bin 0 -> 467 bytes .../abs__ic_menu_share_holo_light.png | Bin 0 -> 505 bytes .../abs__list_activated_holo.9.png | Bin 0 -> 154 bytes .../abs__list_divider_holo_dark.9.png | Bin 0 -> 78 bytes .../abs__list_divider_holo_light.9.png | Bin 0 -> 76 bytes .../abs__list_focused_holo.9.png | Bin 0 -> 159 bytes .../abs__list_longpressed_holo.9.png | Bin 0 -> 154 bytes .../abs__list_pressed_holo_dark.9.png | Bin 0 -> 159 bytes .../abs__list_pressed_holo_light.9.png | Bin 0 -> 159 bytes ...bs__list_selector_disabled_holo_dark.9.png | Bin 0 -> 189 bytes ...s__list_selector_disabled_holo_light.9.png | Bin 0 -> 189 bytes .../abs__menu_dropdown_panel_holo_dark.9.png | Bin 0 -> 922 bytes .../abs__menu_dropdown_panel_holo_light.9.png | Bin 0 -> 1061 bytes .../abs__progress_bg_holo_dark.9.png | Bin 0 -> 178 bytes .../abs__progress_bg_holo_light.9.png | Bin 0 -> 174 bytes .../abs__progress_primary_holo_dark.9.png | Bin 0 -> 917 bytes .../abs__progress_primary_holo_light.9.png | Bin 0 -> 917 bytes .../abs__progress_secondary_holo_dark.9.png | Bin 0 -> 188 bytes .../abs__progress_secondary_holo_light.9.png | Bin 0 -> 188 bytes .../abs__spinner_48_inner_holo.png | Bin 0 -> 2081 bytes .../abs__spinner_48_outer_holo.png | Bin 0 -> 1811 bytes .../abs__spinner_ab_default_holo_dark.9.png | Bin 0 -> 311 bytes .../abs__spinner_ab_default_holo_light.9.png | Bin 0 -> 312 bytes .../abs__spinner_ab_disabled_holo_dark.9.png | Bin 0 -> 306 bytes .../abs__spinner_ab_disabled_holo_light.9.png | Bin 0 -> 306 bytes .../abs__spinner_ab_focused_holo_dark.9.png | Bin 0 -> 524 bytes .../abs__spinner_ab_focused_holo_light.9.png | Bin 0 -> 523 bytes .../abs__spinner_ab_pressed_holo_dark.9.png | Bin 0 -> 464 bytes .../abs__spinner_ab_pressed_holo_light.9.png | Bin 0 -> 458 bytes .../abs__tab_selected_focused_holo.9.png | Bin 0 -> 147 bytes .../abs__tab_selected_holo.9.png | Bin 0 -> 148 bytes .../abs__tab_selected_pressed_holo.9.png | Bin 0 -> 147 bytes .../abs__tab_unselected_pressed_holo.9.png | Bin 0 -> 145 bytes .../abs__ab_bottom_solid_dark_holo.9.png | Bin 0 -> 134 bytes .../abs__ab_bottom_solid_inverse_holo.9.png | Bin 0 -> 129 bytes .../abs__ab_bottom_solid_light_holo.9.png | Bin 0 -> 134 bytes ...abs__ab_bottom_transparent_dark_holo.9.png | Bin 0 -> 123 bytes ...bs__ab_bottom_transparent_light_holo.9.png | Bin 0 -> 123 bytes .../abs__ab_share_pack_holo_dark.9.png | Bin 0 -> 2851 bytes .../abs__ab_share_pack_holo_light.9.png | Bin 0 -> 122 bytes .../abs__ab_solid_dark_holo.9.png | Bin 0 -> 133 bytes .../abs__ab_solid_light_holo.9.png | Bin 0 -> 133 bytes .../abs__ab_solid_shadow_holo.9.png | Bin 0 -> 168 bytes .../abs__ab_stacked_solid_dark_holo.9.png | Bin 0 -> 134 bytes .../abs__ab_stacked_solid_light_holo.9.png | Bin 0 -> 133 bytes ...bs__ab_stacked_transparent_dark_holo.9.png | Bin 0 -> 127 bytes ...s__ab_stacked_transparent_light_holo.9.png | Bin 0 -> 123 bytes .../abs__ab_transparent_dark_holo.9.png | Bin 0 -> 139 bytes .../abs__ab_transparent_light_holo.9.png | Bin 0 -> 133 bytes .../abs__btn_cab_done_default_holo_dark.9.png | Bin 0 -> 101 bytes ...abs__btn_cab_done_default_holo_light.9.png | Bin 0 -> 99 bytes .../abs__btn_cab_done_focused_holo_dark.9.png | Bin 0 -> 109 bytes ...abs__btn_cab_done_focused_holo_light.9.png | Bin 0 -> 105 bytes .../abs__btn_cab_done_pressed_holo_dark.9.png | Bin 0 -> 107 bytes ...abs__btn_cab_done_pressed_holo_light.9.png | Bin 0 -> 105 bytes ...abs__cab_background_bottom_holo_dark.9.png | Bin 0 -> 127 bytes ...bs__cab_background_bottom_holo_light.9.png | Bin 0 -> 124 bytes .../abs__cab_background_top_holo_dark.9.png | Bin 0 -> 130 bytes .../abs__cab_background_top_holo_light.9.png | Bin 0 -> 128 bytes .../abs__dialog_full_holo_dark.9.png | Bin 0 -> 882 bytes .../abs__dialog_full_holo_light.9.png | Bin 0 -> 1003 bytes .../abs__ic_ab_back_holo_dark.png | Bin 0 -> 466 bytes .../abs__ic_ab_back_holo_light.png | Bin 0 -> 438 bytes .../abs__ic_cab_done_holo_dark.png | Bin 0 -> 566 bytes .../abs__ic_cab_done_holo_light.png | Bin 0 -> 552 bytes ..._ic_menu_moreoverflow_normal_holo_dark.png | Bin 0 -> 122 bytes ...ic_menu_moreoverflow_normal_holo_light.png | Bin 0 -> 131 bytes .../abs__ic_menu_share_holo_dark.png | Bin 0 -> 332 bytes .../abs__ic_menu_share_holo_light.png | Bin 0 -> 355 bytes .../abs__list_activated_holo.9.png | Bin 0 -> 151 bytes .../abs__list_divider_holo_dark.9.png | Bin 0 -> 78 bytes .../abs__list_divider_holo_light.9.png | Bin 0 -> 76 bytes .../abs__list_focused_holo.9.png | Bin 0 -> 158 bytes .../abs__list_longpressed_holo.9.png | Bin 0 -> 151 bytes .../abs__list_pressed_holo_dark.9.png | Bin 0 -> 158 bytes .../abs__list_pressed_holo_light.9.png | Bin 0 -> 158 bytes ...bs__list_selector_disabled_holo_dark.9.png | Bin 0 -> 172 bytes ...s__list_selector_disabled_holo_light.9.png | Bin 0 -> 171 bytes .../abs__menu_dropdown_panel_holo_dark.9.png | Bin 0 -> 651 bytes .../abs__menu_dropdown_panel_holo_light.9.png | Bin 0 -> 720 bytes .../abs__progress_bg_holo_dark.9.png | Bin 0 -> 165 bytes .../abs__progress_bg_holo_light.9.png | Bin 0 -> 159 bytes .../abs__progress_primary_holo_dark.9.png | Bin 0 -> 572 bytes .../abs__progress_primary_holo_light.9.png | Bin 0 -> 572 bytes .../abs__progress_secondary_holo_dark.9.png | Bin 0 -> 170 bytes .../abs__progress_secondary_holo_light.9.png | Bin 0 -> 170 bytes .../abs__spinner_48_inner_holo.png | Bin 0 -> 1336 bytes .../abs__spinner_48_outer_holo.png | Bin 0 -> 1165 bytes .../abs__spinner_ab_default_holo_dark.9.png | Bin 0 -> 254 bytes .../abs__spinner_ab_default_holo_light.9.png | Bin 0 -> 255 bytes .../abs__spinner_ab_disabled_holo_dark.9.png | Bin 0 -> 249 bytes .../abs__spinner_ab_disabled_holo_light.9.png | Bin 0 -> 249 bytes .../abs__spinner_ab_focused_holo_dark.9.png | Bin 0 -> 417 bytes .../abs__spinner_ab_focused_holo_light.9.png | Bin 0 -> 424 bytes .../abs__spinner_ab_pressed_holo_dark.9.png | Bin 0 -> 370 bytes .../abs__spinner_ab_pressed_holo_light.9.png | Bin 0 -> 370 bytes .../abs__tab_selected_focused_holo.9.png | Bin 0 -> 148 bytes .../abs__tab_selected_holo.9.png | Bin 0 -> 151 bytes .../abs__tab_selected_pressed_holo.9.png | Bin 0 -> 150 bytes .../abs__tab_unselected_pressed_holo.9.png | Bin 0 -> 155 bytes .../abs__progress_medium_holo.xml | 34 + .../abs__ab_bottom_solid_dark_holo.9.png | Bin 0 -> 165 bytes .../abs__ab_bottom_solid_inverse_holo.9.png | Bin 0 -> 157 bytes .../abs__ab_bottom_solid_light_holo.9.png | Bin 0 -> 166 bytes ...abs__ab_bottom_transparent_dark_holo.9.png | Bin 0 -> 153 bytes ...bs__ab_bottom_transparent_light_holo.9.png | Bin 0 -> 152 bytes .../abs__ab_share_pack_holo_dark.9.png | Bin 0 -> 2875 bytes .../abs__ab_share_pack_holo_light.9.png | Bin 0 -> 2869 bytes .../abs__ab_solid_dark_holo.9.png | Bin 0 -> 163 bytes .../abs__ab_solid_light_holo.9.png | Bin 0 -> 163 bytes .../abs__ab_solid_shadow_holo.9.png | Bin 0 -> 290 bytes .../abs__ab_stacked_solid_dark_holo.9.png | Bin 0 -> 163 bytes .../abs__ab_stacked_solid_light_holo.9.png | Bin 0 -> 163 bytes ...bs__ab_stacked_transparent_dark_holo.9.png | Bin 0 -> 158 bytes ...s__ab_stacked_transparent_light_holo.9.png | Bin 0 -> 152 bytes .../abs__ab_transparent_dark_holo.9.png | Bin 0 -> 171 bytes .../abs__ab_transparent_light_holo.9.png | Bin 0 -> 160 bytes .../abs__btn_cab_done_default_holo_dark.9.png | Bin 0 -> 109 bytes ...abs__btn_cab_done_default_holo_light.9.png | Bin 0 -> 108 bytes .../abs__btn_cab_done_focused_holo_dark.9.png | Bin 0 -> 112 bytes ...abs__btn_cab_done_focused_holo_light.9.png | Bin 0 -> 113 bytes .../abs__btn_cab_done_pressed_holo_dark.9.png | Bin 0 -> 115 bytes ...abs__btn_cab_done_pressed_holo_light.9.png | Bin 0 -> 113 bytes ...abs__cab_background_bottom_holo_dark.9.png | Bin 0 -> 166 bytes ...bs__cab_background_bottom_holo_light.9.png | Bin 0 -> 161 bytes .../abs__cab_background_top_holo_dark.9.png | Bin 0 -> 174 bytes .../abs__cab_background_top_holo_light.9.png | Bin 0 -> 161 bytes .../abs__dialog_full_holo_dark.9.png | Bin 0 -> 2159 bytes .../abs__dialog_full_holo_light.9.png | Bin 0 -> 2302 bytes .../abs__ic_ab_back_holo_dark.png | Bin 0 -> 741 bytes .../abs__ic_ab_back_holo_light.png | Bin 0 -> 661 bytes .../abs__ic_cab_done_holo_dark.png | Bin 0 -> 970 bytes .../abs__ic_cab_done_holo_light.png | Bin 0 -> 915 bytes ..._ic_menu_moreoverflow_normal_holo_dark.png | Bin 0 -> 167 bytes ...ic_menu_moreoverflow_normal_holo_light.png | Bin 0 -> 184 bytes .../abs__ic_menu_share_holo_dark.png | Bin 0 -> 699 bytes .../abs__ic_menu_share_holo_light.png | Bin 0 -> 935 bytes .../abs__list_activated_holo.9.png | Bin 0 -> 158 bytes .../abs__list_divider_holo_dark.9.png | Bin 0 -> 83 bytes .../abs__list_divider_holo_light.9.png | Bin 0 -> 83 bytes .../abs__list_focused_holo.9.png | Bin 0 -> 163 bytes .../abs__list_longpressed_holo.9.png | Bin 0 -> 158 bytes .../abs__list_pressed_holo_dark.9.png | Bin 0 -> 163 bytes .../abs__list_pressed_holo_light.9.png | Bin 0 -> 163 bytes ...bs__list_selector_disabled_holo_dark.9.png | Bin 0 -> 190 bytes ...s__list_selector_disabled_holo_light.9.png | Bin 0 -> 188 bytes .../abs__menu_dropdown_panel_holo_dark.9.png | Bin 0 -> 1362 bytes .../abs__menu_dropdown_panel_holo_light.9.png | Bin 0 -> 1551 bytes .../abs__progress_bg_holo_dark.9.png | Bin 0 -> 174 bytes .../abs__progress_bg_holo_light.9.png | Bin 0 -> 172 bytes .../abs__progress_primary_holo_dark.9.png | Bin 0 -> 1309 bytes .../abs__progress_primary_holo_light.9.png | Bin 0 -> 1309 bytes .../abs__progress_secondary_holo_dark.9.png | Bin 0 -> 184 bytes .../abs__progress_secondary_holo_light.9.png | Bin 0 -> 184 bytes .../abs__spinner_48_inner_holo.png | Bin 0 -> 2769 bytes .../abs__spinner_48_outer_holo.png | Bin 0 -> 2432 bytes .../abs__spinner_ab_default_holo_dark.9.png | Bin 0 -> 395 bytes .../abs__spinner_ab_default_holo_light.9.png | Bin 0 -> 394 bytes .../abs__spinner_ab_disabled_holo_dark.9.png | Bin 0 -> 381 bytes .../abs__spinner_ab_disabled_holo_light.9.png | Bin 0 -> 381 bytes .../abs__spinner_ab_focused_holo_dark.9.png | Bin 0 -> 680 bytes .../abs__spinner_ab_focused_holo_light.9.png | Bin 0 -> 671 bytes .../abs__spinner_ab_pressed_holo_dark.9.png | Bin 0 -> 609 bytes .../abs__spinner_ab_pressed_holo_light.9.png | Bin 0 -> 602 bytes .../abs__tab_selected_focused_holo.9.png | Bin 0 -> 147 bytes .../abs__tab_selected_holo.9.png | Bin 0 -> 153 bytes .../abs__tab_selected_pressed_holo.9.png | Bin 0 -> 147 bytes .../abs__tab_unselected_pressed_holo.9.png | Bin 0 -> 149 bytes .../abs__activated_background_holo_dark.xml | 20 + .../abs__activated_background_holo_light.xml | 20 + .../drawable/abs__btn_cab_done_holo_dark.xml | 24 + .../drawable/abs__btn_cab_done_holo_light.xml | 24 + .../abs__ic_menu_moreoverflow_holo_dark.xml | 18 + .../abs__ic_menu_moreoverflow_holo_light.xml | 18 + .../abs__item_background_holo_dark.xml | 26 + .../abs__item_background_holo_light.xml | 26 + ...lector_background_transition_holo_dark.xml | 20 + ...ector_background_transition_holo_light.xml | 20 + .../drawable/abs__list_selector_holo_dark.xml | 27 + .../abs__list_selector_holo_light.xml | 28 + .../abs__progress_horizontal_holo_dark.xml | 32 + .../abs__progress_horizontal_holo_light.xml | 32 + .../drawable/abs__progress_medium_holo.xml | 34 + .../drawable/abs__spinner_ab_holo_dark.xml | 25 + .../drawable/abs__spinner_ab_holo_light.xml | 25 + .../drawable/abs__tab_indicator_ab_holo.xml | 34 + .../abs__action_mode_close_item.xml | 40 + .../sherlock_spinner_dropdown_item.xml | 26 + .../res/layout-v14/sherlock_spinner_item.xml | 26 + .../layout-xlarge/abs__screen_action_bar.xml | 50 + .../abs__screen_action_bar_overlay.xml | 49 + .../res/layout/abs__action_bar_home.xml | 38 + .../res/layout/abs__action_bar_tab.xml | 7 + .../layout/abs__action_bar_tab_bar_view.xml | 6 + .../res/layout/abs__action_bar_title_item.xml | 50 + .../layout/abs__action_menu_item_layout.xml | 56 + .../res/layout/abs__action_menu_layout.xml | 23 + .../res/layout/abs__action_mode_bar.xml | 24 + .../layout/abs__action_mode_close_item.xml | 31 + .../res/layout/abs__activity_chooser_view.xml | 70 + .../abs__activity_chooser_view_list_item.xml | 53 + .../res/layout/abs__dialog_title_holo.xml | 46 + .../layout/abs__list_menu_item_checkbox.xml | 26 + .../res/layout/abs__list_menu_item_icon.xml | 28 + .../res/layout/abs__list_menu_item_layout.xml | 59 + .../res/layout/abs__list_menu_item_radio.xml | 24 + .../layout/abs__popup_menu_item_layout.xml | 60 + .../res/layout/abs__screen_action_bar.xml | 57 + .../layout/abs__screen_action_bar_overlay.xml | 59 + .../res/layout/abs__screen_simple.xml | 38 + ...abs__screen_simple_overlay_action_mode.xml | 38 + .../layout/sherlock_spinner_dropdown_item.xml | 26 + .../res/layout/sherlock_spinner_item.xml | 26 + .../res/values-land/abs__dimens.xml | 33 + .../abs__dimens.xml | 33 + .../abs__dimens.xml | 33 + .../abs__dimens.xml | 33 + .../abs__dimens.xml | 36 + .../res/values-large/abs__dimens.xml | 29 + .../res/values-sw600dp/abs__bools.xml | 19 + .../res/values-sw600dp/abs__dimens.xml | 38 + .../res/values-v11/abs__themes.xml | 12 + .../res/values-v14/abs__styles.xml | 118 ++ .../res/values-v14/abs__themes.xml | 32 + .../res/values-w360dp/abs__dimens.xml | 22 + .../res/values-w480dp/abs__bools.xml | 22 + .../res/values-w480dp/abs__config.xml | 29 + .../res/values-w500dp/abs__dimens.xml | 22 + .../res/values-w600dp/abs__dimens.xml | 22 + .../res/values-xlarge/abs__dimens.xml | 45 + actionbarsherlock/res/values/abs__attrs.xml | 380 ++++ actionbarsherlock/res/values/abs__bools.xml | 22 + actionbarsherlock/res/values/abs__colors.xml | 27 + actionbarsherlock/res/values/abs__config.xml | 43 + actionbarsherlock/res/values/abs__dimens.xml | 50 + actionbarsherlock/res/values/abs__ids.xml | 26 + actionbarsherlock/res/values/abs__strings.xml | 42 + actionbarsherlock/res/values/abs__styles.xml | 384 ++++ actionbarsherlock/res/values/abs__themes.xml | 226 +++ .../v4/app/_ActionBarSherlockTrojanHorse.java | 144 ++ .../actionbarsherlock/ActionBarSherlock.java | 791 +++++++++ .../com/actionbarsherlock/app/ActionBar.java | 947 ++++++++++ .../app/SherlockActivity.java | 259 +++ .../app/SherlockDialogFragment.java | 68 + .../app/SherlockExpandableListActivity.java | 259 +++ .../app/SherlockFragment.java | 68 + .../app/SherlockFragmentActivity.java | 292 ++++ .../app/SherlockListActivity.java | 259 +++ .../app/SherlockListFragment.java | 68 + .../app/SherlockPreferenceActivity.java | 259 +++ .../internal/ActionBarSherlockCompat.java | 1207 +++++++++++++ .../internal/ActionBarSherlockNative.java | 328 ++++ .../internal/ResourcesCompat.java | 95 + .../internal/app/ActionBarImpl.java | 1026 +++++++++++ .../internal/app/ActionBarWrapper.java | 468 +++++ .../nineoldandroids/animation/Animator.java | 278 +++ .../animation/AnimatorListenerAdapter.java | 54 + .../animation/AnimatorSet.java | 1111 ++++++++++++ .../animation/FloatEvaluator.java | 42 + .../animation/FloatKeyframeSet.java | 136 ++ .../animation/IntEvaluator.java | 42 + .../animation/IntKeyframeSet.java | 135 ++ .../nineoldandroids/animation/Keyframe.java | 361 ++++ .../animation/KeyframeSet.java | 227 +++ .../animation/ObjectAnimator.java | 491 ++++++ .../animation/PropertyValuesHolder.java | 1012 +++++++++++ .../animation/TypeEvaluator.java | 44 + .../animation/ValueAnimator.java | 1265 ++++++++++++++ .../nineoldandroids/view/NineViewGroup.java | 79 + .../view/animation/AnimatorProxy.java | 212 +++ .../widget/NineFrameLayout.java | 65 + .../widget/NineHorizontalScrollView.java | 41 + .../widget/NineLinearLayout.java | 65 + .../internal/view/ActionProviderWrapper.java | 40 + .../internal/view/StandaloneActionMode.java | 148 ++ .../view/View_HasStateListenerSupport.java | 6 + .../View_OnAttachStateChangeListener.java | 8 + .../internal/view/menu/ActionMenu.java | 264 +++ .../internal/view/menu/ActionMenuItem.java | 278 +++ .../view/menu/ActionMenuItemView.java | 295 ++++ .../view/menu/ActionMenuPresenter.java | 721 ++++++++ .../internal/view/menu/ActionMenuView.java | 572 ++++++ .../internal/view/menu/BaseMenuPresenter.java | 231 +++ .../internal/view/menu/ListMenuItemView.java | 278 +++ .../internal/view/menu/MenuBuilder.java | 1335 ++++++++++++++ .../internal/view/menu/MenuItemImpl.java | 647 +++++++ .../internal/view/menu/MenuItemWrapper.java | 292 ++++ .../internal/view/menu/MenuPopupHelper.java | 376 ++++ .../internal/view/menu/MenuPresenter.java | 148 ++ .../internal/view/menu/MenuView.java | 120 ++ .../internal/view/menu/MenuWrapper.java | 180 ++ .../internal/view/menu/SubMenuBuilder.java | 134 ++ .../internal/view/menu/SubMenuWrapper.java | 72 + .../internal/widget/AbsActionBarView.java | 291 ++++ .../internal/widget/ActionBarContainer.java | 245 +++ .../internal/widget/ActionBarContextView.java | 518 ++++++ .../internal/widget/ActionBarView.java | 1548 +++++++++++++++++ .../internal/widget/CapitalizingButton.java | 40 + .../internal/widget/CapitalizingTextView.java | 44 + .../widget/FakeDialogPhoneWindow.java | 64 + .../internal/widget/IcsAbsSpinner.java | 479 +++++ .../internal/widget/IcsAdapterView.java | 1160 ++++++++++++ .../internal/widget/IcsLinearLayout.java | 272 +++ .../internal/widget/IcsListPopupWindow.java | 644 +++++++ .../internal/widget/IcsProgressBar.java | 1193 +++++++++++++ .../internal/widget/IcsSpinner.java | 703 ++++++++ .../internal/widget/IcsView.java | 21 + .../widget/ScrollingTabContainerView.java | 545 ++++++ .../actionbarsherlock/view/ActionMode.java | 224 +++ .../view/ActionProvider.java | 170 ++ .../view/CollapsibleActionView.java | 39 + .../src/com/actionbarsherlock/view/Menu.java | 447 +++++ .../actionbarsherlock/view/MenuInflater.java | 472 +++++ .../com/actionbarsherlock/view/MenuItem.java | 598 +++++++ .../com/actionbarsherlock/view/SubMenu.java | 110 ++ .../com/actionbarsherlock/view/Window.java | 65 + .../widget/ActivityChooserModel.java | 1131 ++++++++++++ .../widget/ActivityChooserView.java | 818 +++++++++ .../widget/ShareActionProvider.java | 316 ++++ proguard.flags | 8 + res/values/styles.xml | 2 +- .../android/gallery3d/app/MovieActivity.java | 26 +- 361 files changed, 33921 insertions(+), 16 deletions(-) create mode 100644 actionbarsherlock/res/color/abs__primary_text_disable_only_holo_dark.xml create mode 100644 actionbarsherlock/res/color/abs__primary_text_disable_only_holo_light.xml create mode 100644 actionbarsherlock/res/color/abs__primary_text_holo_dark.xml create mode 100644 actionbarsherlock/res/color/abs__primary_text_holo_light.xml create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_bottom_solid_dark_holo.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_bottom_solid_inverse_holo.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_bottom_solid_light_holo.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_bottom_transparent_dark_holo.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_bottom_transparent_light_holo.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_share_pack_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_share_pack_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_solid_dark_holo.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_solid_light_holo.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_solid_shadow_holo.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_stacked_solid_dark_holo.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_stacked_solid_light_holo.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_stacked_transparent_dark_holo.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_stacked_transparent_light_holo.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_transparent_dark_holo.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ab_transparent_light_holo.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__btn_cab_done_default_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__btn_cab_done_default_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__btn_cab_done_focused_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__btn_cab_done_focused_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__btn_cab_done_pressed_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__btn_cab_done_pressed_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__cab_background_bottom_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__cab_background_bottom_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__cab_background_top_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__cab_background_top_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__dialog_full_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__dialog_full_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ic_ab_back_holo_dark.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ic_ab_back_holo_light.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ic_cab_done_holo_dark.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ic_cab_done_holo_light.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ic_menu_moreoverflow_normal_holo_dark.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ic_menu_moreoverflow_normal_holo_light.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ic_menu_share_holo_dark.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__ic_menu_share_holo_light.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__list_activated_holo.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__list_divider_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__list_divider_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__list_focused_holo.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__list_longpressed_holo.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__list_pressed_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__list_pressed_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__list_selector_disabled_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__list_selector_disabled_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__menu_dropdown_panel_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__menu_dropdown_panel_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__progress_bg_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__progress_bg_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__progress_primary_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__progress_primary_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__progress_secondary_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__progress_secondary_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__spinner_48_inner_holo.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__spinner_48_outer_holo.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_default_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_default_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_disabled_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_disabled_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_focused_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_focused_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_pressed_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_pressed_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__tab_selected_focused_holo.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__tab_selected_holo.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__tab_selected_pressed_holo.9.png create mode 100644 actionbarsherlock/res/drawable-hdpi/abs__tab_unselected_pressed_holo.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_bottom_solid_dark_holo.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_bottom_solid_inverse_holo.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_bottom_solid_light_holo.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_bottom_transparent_dark_holo.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_bottom_transparent_light_holo.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_share_pack_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_share_pack_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_solid_dark_holo.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_solid_light_holo.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_solid_shadow_holo.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_stacked_solid_dark_holo.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_stacked_solid_light_holo.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_stacked_transparent_dark_holo.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_stacked_transparent_light_holo.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_transparent_dark_holo.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ab_transparent_light_holo.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_default_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_default_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_focused_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_focused_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_pressed_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_pressed_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__cab_background_bottom_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__cab_background_bottom_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__cab_background_top_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__cab_background_top_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__dialog_full_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__dialog_full_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ic_ab_back_holo_dark.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ic_ab_back_holo_light.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ic_cab_done_holo_dark.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ic_cab_done_holo_light.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ic_menu_moreoverflow_normal_holo_dark.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ic_menu_moreoverflow_normal_holo_light.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ic_menu_share_holo_dark.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__ic_menu_share_holo_light.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__list_activated_holo.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__list_divider_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__list_divider_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__list_focused_holo.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__list_longpressed_holo.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__list_pressed_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__list_pressed_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__list_selector_disabled_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__list_selector_disabled_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__menu_dropdown_panel_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__menu_dropdown_panel_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__progress_bg_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__progress_bg_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__progress_primary_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__progress_primary_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__progress_secondary_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__progress_secondary_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__spinner_48_inner_holo.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__spinner_48_outer_holo.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__spinner_ab_default_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__spinner_ab_default_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__spinner_ab_disabled_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__spinner_ab_disabled_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__spinner_ab_focused_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__spinner_ab_focused_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__spinner_ab_pressed_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__spinner_ab_pressed_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__tab_selected_focused_holo.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__tab_selected_holo.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__tab_selected_pressed_holo.9.png create mode 100644 actionbarsherlock/res/drawable-mdpi/abs__tab_unselected_pressed_holo.9.png create mode 100644 actionbarsherlock/res/drawable-v11/abs__progress_medium_holo.xml create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_bottom_solid_dark_holo.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_bottom_solid_inverse_holo.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_bottom_solid_light_holo.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_bottom_transparent_dark_holo.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_bottom_transparent_light_holo.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_share_pack_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_share_pack_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_solid_dark_holo.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_solid_light_holo.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_solid_shadow_holo.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_stacked_solid_dark_holo.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_stacked_solid_light_holo.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_stacked_transparent_dark_holo.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_stacked_transparent_light_holo.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_transparent_dark_holo.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ab_transparent_light_holo.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_default_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_default_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_focused_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_focused_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_pressed_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_pressed_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__cab_background_bottom_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__cab_background_bottom_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__cab_background_top_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__cab_background_top_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__dialog_full_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__dialog_full_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ic_ab_back_holo_dark.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ic_ab_back_holo_light.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ic_cab_done_holo_dark.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ic_cab_done_holo_light.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ic_menu_moreoverflow_normal_holo_dark.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ic_menu_moreoverflow_normal_holo_light.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ic_menu_share_holo_dark.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__ic_menu_share_holo_light.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__list_activated_holo.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__list_divider_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__list_divider_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__list_focused_holo.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__list_longpressed_holo.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__list_pressed_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__list_pressed_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__list_selector_disabled_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__list_selector_disabled_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__menu_dropdown_panel_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__menu_dropdown_panel_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__progress_bg_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__progress_bg_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__progress_primary_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__progress_primary_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__progress_secondary_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__progress_secondary_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__spinner_48_inner_holo.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__spinner_48_outer_holo.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_default_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_default_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_disabled_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_disabled_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_focused_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_focused_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_pressed_holo_dark.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_pressed_holo_light.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__tab_selected_focused_holo.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__tab_selected_holo.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__tab_selected_pressed_holo.9.png create mode 100644 actionbarsherlock/res/drawable-xhdpi/abs__tab_unselected_pressed_holo.9.png create mode 100644 actionbarsherlock/res/drawable/abs__activated_background_holo_dark.xml create mode 100644 actionbarsherlock/res/drawable/abs__activated_background_holo_light.xml create mode 100644 actionbarsherlock/res/drawable/abs__btn_cab_done_holo_dark.xml create mode 100644 actionbarsherlock/res/drawable/abs__btn_cab_done_holo_light.xml create mode 100644 actionbarsherlock/res/drawable/abs__ic_menu_moreoverflow_holo_dark.xml create mode 100644 actionbarsherlock/res/drawable/abs__ic_menu_moreoverflow_holo_light.xml create mode 100644 actionbarsherlock/res/drawable/abs__item_background_holo_dark.xml create mode 100644 actionbarsherlock/res/drawable/abs__item_background_holo_light.xml create mode 100644 actionbarsherlock/res/drawable/abs__list_selector_background_transition_holo_dark.xml create mode 100644 actionbarsherlock/res/drawable/abs__list_selector_background_transition_holo_light.xml create mode 100644 actionbarsherlock/res/drawable/abs__list_selector_holo_dark.xml create mode 100644 actionbarsherlock/res/drawable/abs__list_selector_holo_light.xml create mode 100644 actionbarsherlock/res/drawable/abs__progress_horizontal_holo_dark.xml create mode 100644 actionbarsherlock/res/drawable/abs__progress_horizontal_holo_light.xml create mode 100644 actionbarsherlock/res/drawable/abs__progress_medium_holo.xml create mode 100644 actionbarsherlock/res/drawable/abs__spinner_ab_holo_dark.xml create mode 100644 actionbarsherlock/res/drawable/abs__spinner_ab_holo_light.xml create mode 100644 actionbarsherlock/res/drawable/abs__tab_indicator_ab_holo.xml create mode 100644 actionbarsherlock/res/layout-large/abs__action_mode_close_item.xml create mode 100644 actionbarsherlock/res/layout-v14/sherlock_spinner_dropdown_item.xml create mode 100644 actionbarsherlock/res/layout-v14/sherlock_spinner_item.xml create mode 100644 actionbarsherlock/res/layout-xlarge/abs__screen_action_bar.xml create mode 100644 actionbarsherlock/res/layout-xlarge/abs__screen_action_bar_overlay.xml create mode 100644 actionbarsherlock/res/layout/abs__action_bar_home.xml create mode 100644 actionbarsherlock/res/layout/abs__action_bar_tab.xml create mode 100644 actionbarsherlock/res/layout/abs__action_bar_tab_bar_view.xml create mode 100644 actionbarsherlock/res/layout/abs__action_bar_title_item.xml create mode 100644 actionbarsherlock/res/layout/abs__action_menu_item_layout.xml create mode 100644 actionbarsherlock/res/layout/abs__action_menu_layout.xml create mode 100644 actionbarsherlock/res/layout/abs__action_mode_bar.xml create mode 100644 actionbarsherlock/res/layout/abs__action_mode_close_item.xml create mode 100644 actionbarsherlock/res/layout/abs__activity_chooser_view.xml create mode 100644 actionbarsherlock/res/layout/abs__activity_chooser_view_list_item.xml create mode 100644 actionbarsherlock/res/layout/abs__dialog_title_holo.xml create mode 100644 actionbarsherlock/res/layout/abs__list_menu_item_checkbox.xml create mode 100644 actionbarsherlock/res/layout/abs__list_menu_item_icon.xml create mode 100644 actionbarsherlock/res/layout/abs__list_menu_item_layout.xml create mode 100644 actionbarsherlock/res/layout/abs__list_menu_item_radio.xml create mode 100644 actionbarsherlock/res/layout/abs__popup_menu_item_layout.xml create mode 100644 actionbarsherlock/res/layout/abs__screen_action_bar.xml create mode 100644 actionbarsherlock/res/layout/abs__screen_action_bar_overlay.xml create mode 100644 actionbarsherlock/res/layout/abs__screen_simple.xml create mode 100644 actionbarsherlock/res/layout/abs__screen_simple_overlay_action_mode.xml create mode 100644 actionbarsherlock/res/layout/sherlock_spinner_dropdown_item.xml create mode 100644 actionbarsherlock/res/layout/sherlock_spinner_item.xml create mode 100644 actionbarsherlock/res/values-land/abs__dimens.xml create mode 100644 actionbarsherlock/res/values-large-hdpi-1024x600/abs__dimens.xml create mode 100644 actionbarsherlock/res/values-large-land-hdpi-1024x600/abs__dimens.xml create mode 100644 actionbarsherlock/res/values-large-land-mdpi-1024x600/abs__dimens.xml create mode 100644 actionbarsherlock/res/values-large-mdpi-1024x600/abs__dimens.xml create mode 100644 actionbarsherlock/res/values-large/abs__dimens.xml create mode 100644 actionbarsherlock/res/values-sw600dp/abs__bools.xml create mode 100644 actionbarsherlock/res/values-sw600dp/abs__dimens.xml create mode 100644 actionbarsherlock/res/values-v11/abs__themes.xml create mode 100644 actionbarsherlock/res/values-v14/abs__styles.xml create mode 100644 actionbarsherlock/res/values-v14/abs__themes.xml create mode 100644 actionbarsherlock/res/values-w360dp/abs__dimens.xml create mode 100644 actionbarsherlock/res/values-w480dp/abs__bools.xml create mode 100644 actionbarsherlock/res/values-w480dp/abs__config.xml create mode 100644 actionbarsherlock/res/values-w500dp/abs__dimens.xml create mode 100644 actionbarsherlock/res/values-w600dp/abs__dimens.xml create mode 100644 actionbarsherlock/res/values-xlarge/abs__dimens.xml create mode 100644 actionbarsherlock/res/values/abs__attrs.xml create mode 100644 actionbarsherlock/res/values/abs__bools.xml create mode 100644 actionbarsherlock/res/values/abs__colors.xml create mode 100644 actionbarsherlock/res/values/abs__config.xml create mode 100644 actionbarsherlock/res/values/abs__dimens.xml create mode 100644 actionbarsherlock/res/values/abs__ids.xml create mode 100644 actionbarsherlock/res/values/abs__strings.xml create mode 100644 actionbarsherlock/res/values/abs__styles.xml create mode 100644 actionbarsherlock/res/values/abs__themes.xml create mode 100644 actionbarsherlock/src/android/support/v4/app/_ActionBarSherlockTrojanHorse.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/ActionBarSherlock.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/app/ActionBar.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/app/SherlockActivity.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/app/SherlockDialogFragment.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/app/SherlockExpandableListActivity.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/app/SherlockFragment.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/app/SherlockFragmentActivity.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/app/SherlockListActivity.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/app/SherlockListFragment.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/app/SherlockPreferenceActivity.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockCompat.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockNative.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/ResourcesCompat.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/app/ActionBarImpl.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/app/ActionBarWrapper.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/Animator.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorListenerAdapter.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorSet.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatEvaluator.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatKeyframeSet.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntEvaluator.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntKeyframeSet.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/Keyframe.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/KeyframeSet.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ObjectAnimator.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/PropertyValuesHolder.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/TypeEvaluator.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/NineViewGroup.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/AnimatorProxy.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineFrameLayout.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineHorizontalScrollView.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineLinearLayout.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/ActionProviderWrapper.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/StandaloneActionMode.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/View_HasStateListenerSupport.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/View_OnAttachStateChangeListener.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenu.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuItem.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuItemView.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuPresenter.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuView.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/BaseMenuPresenter.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ListMenuItemView.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuBuilder.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemImpl.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemWrapper.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuPopupHelper.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuPresenter.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuView.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuWrapper.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/SubMenuBuilder.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/SubMenuWrapper.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/widget/AbsActionBarView.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarContainer.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarContextView.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarView.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/widget/CapitalizingButton.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/widget/CapitalizingTextView.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/widget/FakeDialogPhoneWindow.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsAbsSpinner.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsAdapterView.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsListPopupWindow.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsProgressBar.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsSpinner.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsView.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/view/ActionMode.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/view/ActionProvider.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/view/CollapsibleActionView.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/view/Menu.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/view/MenuInflater.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/view/MenuItem.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/view/SubMenu.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/view/Window.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/widget/ActivityChooserModel.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/widget/ActivityChooserView.java create mode 100644 actionbarsherlock/src/com/actionbarsherlock/widget/ShareActionProvider.java diff --git a/Android.mk b/Android.mk index 4854a5c5e..570b46f30 100644 --- a/Android.mk +++ b/Android.mk @@ -9,10 +9,15 @@ LOCAL_STATIC_JAVA_LIBRARIES += com.android.gallery3d.common2 LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_SRC_FILES += $(call all-java-files-under, src_pd) +LOCAL_SRC_FILES += $(call all-java-files-under, actionbarsherlock/src) LOCAL_SRC_FILES += $(call all-java-files-under, ../Camera/src) -LOCAL_RESOURCE_DIR += $(LOCAL_PATH)/res packages/apps/Camera/res -LOCAL_AAPT_FLAGS := --auto-add-overlay --extra-packages com.android.camera +LOCAL_RESOURCE_DIR += $(LOCAL_PATH)/res +LOCAL_RESOURCE_DIR += packages/apps/Camera/res +LOCAL_RESOURCE_DIR += $(LOCAL_PATH)/actionbarsherlock/res + +LOCAL_AAPT_FLAGS := --auto-add-overlay \ + --extra-packages com.android.camera:com.actionbarsherlock LOCAL_PACKAGE_NAME := Gallery2 diff --git a/actionbarsherlock/res/color/abs__primary_text_disable_only_holo_dark.xml b/actionbarsherlock/res/color/abs__primary_text_disable_only_holo_dark.xml new file mode 100644 index 000000000..ea7459aaf --- /dev/null +++ b/actionbarsherlock/res/color/abs__primary_text_disable_only_holo_dark.xml @@ -0,0 +1,20 @@ + + + + + + + diff --git a/actionbarsherlock/res/color/abs__primary_text_disable_only_holo_light.xml b/actionbarsherlock/res/color/abs__primary_text_disable_only_holo_light.xml new file mode 100644 index 000000000..0edb33b4b --- /dev/null +++ b/actionbarsherlock/res/color/abs__primary_text_disable_only_holo_light.xml @@ -0,0 +1,21 @@ + + + + + + + + diff --git a/actionbarsherlock/res/color/abs__primary_text_holo_dark.xml b/actionbarsherlock/res/color/abs__primary_text_holo_dark.xml new file mode 100644 index 000000000..2bcfd0b63 --- /dev/null +++ b/actionbarsherlock/res/color/abs__primary_text_holo_dark.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + diff --git a/actionbarsherlock/res/color/abs__primary_text_holo_light.xml b/actionbarsherlock/res/color/abs__primary_text_holo_light.xml new file mode 100644 index 000000000..198384fed --- /dev/null +++ b/actionbarsherlock/res/color/abs__primary_text_holo_light.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ab_bottom_solid_dark_holo.9.png b/actionbarsherlock/res/drawable-hdpi/abs__ab_bottom_solid_dark_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..769463b369a5185ba2d2fdf26abf058086ebcd08 GIT binary patch literal 144 zcmeAS@N?(olHy`uVBq!ia0vp^Y9P$P1|(P5zFY^S!aZFaLn02py|Iz^fCC51!MDwC ze!c%VXGhEQ)_dJsezHtpNMD|7Dac@a*_ZJyulFV2w{5C|YCbaz5)ZX-3ak0tIJ#lm tp_aeGY*)k&iW*FhzahTiJD1r}=BlLiI{(TJ=>e@^@O1TaS?83{1OUpzopr0A6)2vH$=8 literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ab_bottom_solid_light_holo.9.png b/actionbarsherlock/res/drawable-hdpi/abs__ab_bottom_solid_light_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..73050476e77aa798919b829a5566973e231f9d49 GIT binary patch literal 144 zcmeAS@N?(olHy`uVBq!ia0vp^Y9P$P1|(P5zFY^S!aZFaLn02py|Iz^fCC51!MFRR zxpqaJ>-4UOe6iPKwm$=BLD{Wo!i)yScSSDT-Jo*!N?wFe;-MB!VKtu_20%tEPqwzt q4f{lgTEQ5`;-9UxjMeKCf^DQ_uhd?;-Btm#g2B_(&t;ucLK6V6dokDm literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ab_bottom_transparent_dark_holo.9.png b/actionbarsherlock/res/drawable-hdpi/abs__ab_bottom_transparent_dark_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..712a551ece87b2544433ac982382a087e7f1731d GIT binary patch literal 135 zcmeAS@N?(olHy`uVBq!ia0vp^Y9P$P1|(P5zFY^S{5)M8Ln02py}Xf^L4oIp!}}xu zHrx6hVG;aws8xB@i!KMDZA_cCWy>wsRQS4KRST!En$HY_#6vK~{lt8cLjun}a%VT6 c)z9eScC>M27UGHi05qAw)78&qol`;+0QSr+Bme*a literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ab_bottom_transparent_light_holo.9.png b/actionbarsherlock/res/drawable-hdpi/abs__ab_bottom_transparent_light_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..bf3b9438b16543294498ba27e51d4e878c8ead5a GIT binary patch literal 134 zcmeAS@N?(olHy`uVBq!ia0vp^Y9P$P1|(P5zFY^Sd_7$pLn02py}Xh4fCCS+;oB*H z(}QQZt5vXQMa=PTZk@YrXXvE3+ofW5$)(cU#3WF_jrSY!c@8l>`*HAE!gKCvr?`99 W=bm|#aNiDSFoUP7pUXO@geCw#94y)Z literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ab_share_pack_holo_dark.9.png b/actionbarsherlock/res/drawable-hdpi/abs__ab_share_pack_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..6c1415772d03a71c0677f6e2461521bfae829ce9 GIT binary patch literal 2866 zcmV-23(fS2P)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z00018Nkl%->o_#B0~lM0RR6305`L6c1|?a Q%K!iX07*qoM6N<$g0$>VYybcN literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ab_share_pack_holo_light.9.png b/actionbarsherlock/res/drawable-hdpi/abs__ab_share_pack_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..f4ff16be7323486b7fcd49b3e9bb07816a75b53c GIT binary patch literal 2862 zcmV+}3(@q6P)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z00014Nkl-^V;Vpy{TG>rs2jRbt|WpWjh#Ji#?9Gi^wblTEgJz>gTe~DWM4fZg4bX literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ab_stacked_transparent_dark_holo.9.png b/actionbarsherlock/res/drawable-hdpi/abs__ab_stacked_transparent_dark_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..1e39572224b24a81ed4d73923280ba2724dbaf6e GIT binary patch literal 139 zcmeAS@N?(olHy`uVBq!ia0vp^Y9P$P1|(P5zFY^Sf;?RuLn02py|Iy(L4oIp!})_Q zZ}wlfoYKNk`|wbZR*CB+2cd0Do4#G+S+1#YsD)El&1Z%|BAjt`!_S2)TNKYc{m-!5 f_v_(jT(cfAPEEXE)c4^Y$T|j3S3j3^P6 literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ab_stacked_transparent_light_holo.9.png b/actionbarsherlock/res/drawable-hdpi/abs__ab_stacked_transparent_light_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..a16db853e94af78c0739d9b89b578e2a8021c856 GIT binary patch literal 133 zcmeAS@N?(olHy`uVBq!ia0vp^Y9P$P1|(P5zFY^Sd^}woLn02py|j?`fP(zopr08IHUH2?qr literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ab_transparent_dark_holo.9.png b/actionbarsherlock/res/drawable-hdpi/abs__ab_transparent_dark_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..0eff695d82911a73874d871f3a7b23b71dd8ab44 GIT binary patch literal 155 zcmeAS@N?(olHy`uVBq!ia0vp^Y9P$P1|(P5zFY^Sl001;Ln02py?l}LfC5j;!{`N< zEvnsL$t-6rWU%$psDGg1|4DLDj`q~RzPqNgR|nl=*Rt6dx_ol~p-I||JQ4;82O1ce y*`SQyBHQ|!3>bf({j~je;Zla%ZD->HG+$+yO5M3zoXrBXjlt8^&t;ucLK6T4R5w)s literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ab_transparent_light_holo.9.png b/actionbarsherlock/res/drawable-hdpi/abs__ab_transparent_light_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..219b170fa67aa2ef8e0b11ebff90c1629ba7e97a GIT binary patch literal 145 zcmeAS@N?(olHy`uVBq!ia0vp^Y9P$P1|(P5zFY^SB0OCjLn02py?l|AL4l*?;q8?- zrB_<6lUu~-<@8GYocm9fskyGHQx2!G9uAwU_k&&MlS%_4GaHYDLBatTBRp}nY76HL mkjg^D5fnx&0glSHJj>3%>1Jqp^q#PeS;bnL@oAJ;NJ=s*Cb_P#ZKbLh* G2~7YBfgFPX literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__btn_cab_done_pressed_holo_dark.9.png b/actionbarsherlock/res/drawable-hdpi/abs__btn_cab_done_pressed_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..66adffed632f0f6267afe6dc2f518adb6a83ca4a GIT binary patch literal 110 zcmeAS@N?(olHy`uVBq!ia0vp^EI_Qo!3HFq_#{<Lb literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__cab_background_bottom_holo_dark.9.png b/actionbarsherlock/res/drawable-hdpi/abs__cab_background_bottom_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..1d836f65a1fffea301e9cf36770b21b48b3b8132 GIT binary patch literal 149 zcmeAS@N?(olHy`uVBq!ia0vp^Y9P$P1|(P5zFY^SVmw_OLn02py|R(B!9jra;>r_8 z?%b*io|Yn;UGT9};ZTu}!9}%xc^%IgtXD4oJ@0X-F7B%4f|j+c$=0hv54CU#tNF|@ sNQ5wMgi8eI0r?xYZ}@0_Yf6jsMX$B_pXOhT0oudh>FVdQ&MBb@0DzD;x&QzG literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__cab_background_bottom_holo_light.9.png b/actionbarsherlock/res/drawable-hdpi/abs__cab_background_bottom_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..5818666d4e64b93da73bc3d6dc2764bcb500359c GIT binary patch literal 145 zcmeAS@N?(olHy`uVBq!ia0vp^Y9P$P1|(P5zFY^SB0OCjLn02py|R(>fCCT9!M7)Q zv literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__cab_background_top_holo_dark.9.png b/actionbarsherlock/res/drawable-hdpi/abs__cab_background_top_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..564fb34b4308750b6922f320e9e114b080ecd538 GIT binary patch literal 147 zcmeAS@N?(olHy`uVBq!ia0vp^Y9P$P1|(P5zFY^SqC8z3Ln02py}XdO!9jra;!2L@ z<=I|~`ucZlc5hPnsi>TGwM)Is^N?0TPy5{UQpwgqqAoKG5)ZX-3ak0R7;B{1mWZ}( p*lxaUe)ue*Z}vC-G%ee~_}P|!&DqTD7lF1gc)I$ztaD0e0st(KG%NrB literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__cab_background_top_holo_light.9.png b/actionbarsherlock/res/drawable-hdpi/abs__cab_background_top_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..ae21b760fb1ebecac3389164251b0fa14f580f5a GIT binary patch literal 147 zcmeAS@N?(olHy`uVBq!ia0vp^Y9P$P1|(P5zFY^SqC8z3Ln02py>gKAfB^?4dC zy{Qwe+I<(;Zrk3}qFy7o$Hqotreyxi(D>i`gF-*@tj&^T;Xws!Omj@dZ?l#4Y_?*} ivA^-x{8q}NM@;fbHo20HF^oW47(8A5T-G@yGywny6)bE3 literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__dialog_full_holo_dark.9.png b/actionbarsherlock/res/drawable-hdpi/abs__dialog_full_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..79e56f522b2837bd9f579b28f037ad5eafaaee8e GIT binary patch literal 1414 zcmV;11$p|3P)cSnqT^=WQ7*OFqW%ysfqGq3fLYCng$eebY1E zq0h)!qMt>^T{!1KLrdv5=!(bMwnfb7mMF4BgVA@!3k##^X|etG%o8VLfn)&kp1$5* zAHx|3EF9@?)w)=}!OothSF(h}LSVs2n}u~V8rR2gA&m?6GFm9LT5i!5ovh2$`aOLf zDMwpCv(UIN+s(qhT71rU;E=VYR%2(wIy9)U9BqNMU?EvKj~0!zxmxOREjkZzh+iq_n}2*GaEP(@ILD!5 zWBguqUH^M`clY;tz5a@wsI&tR0g7j89WEv$&WS`s3jmAj>+65+@9$R+4-crSDsl+t zoXD~ai^by4tE;Qe>-G9CHN@f2j4rXz#$jzQA^^+B$H$Mix3`1-5a+ZsO@p#5Q53}= z0G4QnFC7vyL_!;@%<@Jv>_k)mSUx>Hz18n=PE3d}%kYsC@*I)N0NNv^lI%s;wg9j! z%knLLgEIoQ+bysY63^&#(^_eOc(NT6QxTdoZI(#S<~ro`ne!tS(gH7T&zUX-UZRk7 zy|5!F77`FowzZg?X(M)KAw}<4SRP51e8qZ>m)V;$Z3?tS#CiaZ^hhEi?U_=yRh(%c zcGk9kwMUBGYjYt@pHyCSltyExNUHHFevMy@-l#r~QEjQ;(4?Q~r4samHh{FF{bU7StYxgeBAZQ`6E7N`VLYGS_ z;oj>aHT`D+d1$*FJhVBd!G+`uf(ywR1Q(Js2reXN5G)~C&xiARXWFDHmGF81Z6U>K z;#g%)oXa8RP+ENtZO$MZBP0)Pm&4Jv?h_KbHF>VdnKo?a-t;CVB(9^gh389`0#_~3 z>r7%ovdX{d8amFjk%uF>Vp~*9sp-GKg_vAO(?{&AZLdjA|Mdo3?oA8H>)1>mc|==# zB~EQxV&cD40$n%8&w#s-rjOWJ+ddiIQXYxR!^y#)tE&3)24CJ80l~J_MCXPu>Ml3AI+9BHcJ4%0r(Kw z@2dYHj4#nGKH!fqjRVUuh**Aw_CvMrs{b>Lm!YwzO4di>6N@*}Phg5Tw&B1fy2S@v zNaMh=r`Sx3>1SxA8q+hl==5I;NtblfC(XkF^KkH7ZKuDGcq0~@mC!ryi=K7WXgde? zOwz>rq{P&!A!(hIr~D!&pe-W#G7`?LQYh|`P7hzs(O!weT#2|xih3m$l64(P7wFd8 z$(YnkvI-Blh{l8EAha{kf+|%%mTX6hk;YCcRo{6`6g>|oKBz>Tb24JLyVyI4p!izS z!8wv9b%$RIiIZ@y?B&nGjRPyvaF~-xlb-U|=!P~^8?n&FNw@wIvQA!p;xDy1AK0dR zu~CaAl^btMM>A?9->NQ&|AnVmzdt!!WF>xutSl`;$84s2a_=ari#ecl- zo|KSyJXTD=1$2JI1Ql!6el7Y8-dCZ-i%gs^mMBu<;eLzP8a;YIXA&Hxi>7JtAFa#2 UvCQ(L;{X5v07*qoM6N<$g1g$KMgRZ+ literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__dialog_full_holo_light.9.png b/actionbarsherlock/res/drawable-hdpi/abs__dialog_full_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..e029f210b9a81ed4765d31e90b6e49dc8aa37bed GIT binary patch literal 1537 zcmV+c2LAbpP)P*hY@RCILOyI+)4*Y%ioMH6eaT8-v42qXrI z0|4iGEk=d4Xm52^#H?WUz%bBygG}I|;L!cJM*+u%I9T*&&%x@0sx#0Qk0mTmeRX1h$MIxNMY&% zsz{Hz01C^N@8p~dFgXbIRub%{CUOKKzAQ3rfl0r3M&j^DZL~BnC0R+zNTfH*0>l>% z6xe!^4oO*vg0sbY%(i4Znw@-;nUbs&1zN~PIe02zy)Qcz&8uA?+OU=`?e2Zs5}uJN0M*6C#a{)YX?>^k&iO8v%U{pV&i+9YXUL@sAe1fQs10%V6ikBo z^7Qod_s{$xhgN}Tci-i5`3pX{;N4;1Au(Bm7x@)z#1I9LmdL~RrF4uC5rsHs>tE+w zbjvJ)LKv+{MYbuBrU=TBLj=6Xm=@t7;baF+QjNr0K02$09MPPz_Q^dZ5CLh8#Oov4 z0!TsP8|Jz<^->fRi@r;w5OrSCkw6L?N(J|#V;?nA78HxV{Q97DD=gWeOHxKs4U)p3 zSoD>;waz;geHn?ahed6Tq%7rduPgn zV$nDE$&ajtWS5-`4=n>hvFJNE&bxxNGnt2!k)T-g9UO0!_0BFb6cm%bLuC>qYeBK* zyN@VHxuTkNE#cFa@PaJz!! z*)p0eo;YjAyoc}Lcn`@)ql2XA#Le!l%y)3C`#|D`qk*LC#Leoh&{v9irz@IDt(4j|E-ey3YJCdAoj z17Q35`nvale)TKB+I=4%AAxk%w!OMGAf++t+Mb@Cemp-vW4j&J%V|A%#TR&cd&9%S z1Mctdf1tZ-6W>Id5JKwGXhvG!+}wOSKR^Gos;Zyq!S}5X*>+05G4|7V9G{hQ?!VjH z+iw8YkTX)YMrymYx~{`?w$U_yh$q-O1#m*zu<(hQDx}lJ70s)V5Io{ZN7v2rMwVC7 zhTm_2@1*&pTK&uP8_~o&lye*5+om^+1{h zqafFH?O0X{OUO1M^YAPb=F`bd6<0LB=s!LE=ilN39Gach?DYt$CL6UhXTc;$2zpT2dqqQrIZWT*_yH->_|IcgE|Y&S_AJ4lX{3 zlIkT6RWeyS^JtZ1q^3@yK=Cm?J&*-y*C;dpYgTSF&bztX%>V7a(kL+ra#JUT-|=or zs-McUNbE?uO3e#!@v#wf-Fu%ryG^`~69lNs`%MmnTRbrM$471B$+eE{K4hK$mCQ9h-Z$E`tJc<=E)8`p?U8s&`700000NkvXXu0mjfb2aWW literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ic_ab_back_holo_dark.png b/actionbarsherlock/res/drawable-hdpi/abs__ic_ab_back_holo_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..897a1c11a06923f0ee630a3ec44b40118c1fa4d3 GIT binary patch literal 602 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM0wlfaz7_*1rX+877l!}s{b%+Ad7K3vkswhI zFm^kcZ3hx8D{xE)(qO#|6+TOsF)%PDdAc};Se)*?;+-wxD8l++z18QgepiI9o*=R4AA9|r|3}>uTm;M6YILUxmVi!uBjgaN)~;(wEWpmNk!cW z(d%Z<{E>P~YK!lT=8FgRsYuTJwQ$0$u+I~@?rdLb^6_f+5jpHV#tRQqPS1ijb30F2_W#pYUFO#_XV=?h zOHP?#2^DqDa literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ic_ab_back_holo_light.png b/actionbarsherlock/res/drawable-hdpi/abs__ic_ab_back_holo_light.png new file mode 100644 index 0000000000000000000000000000000000000000..0c89f71407e8d51f92ff6a10b1ae40ec902aa04e GIT binary patch literal 546 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM0wlfaz7_*1rX+877l!}s{b%+Ad7K3vkswhI zFm^kcZ3hx8D{xE)(qO#|6+TOsF)%P{dAc};Se%}E<)W9gqsXz3_j5LNPFu1pO1DK} z+N#=yeg8w_ofMzAMJao1SUGXl-8U7Joy@GYEX@zknfd?wSxaLcYqyHhr&soQ-EO{p zw!~UfNcQJK)l+|B(yvWaZRmKvsC8=g<+E=!6%t;!XnxPxBUZuOVKlwt*0FipR-Y02 zmCh$xWIQ?dubRMH%k4r1TjlOEFztJ(`Lu4f+1J+&0<|T}CPeP?x_?Pcpm5>hNwa5M zzkQR1sjpY$)<2WmGuJ)*zvffcmaNUK`~10Vr~dw8eVc_z%*|+OqxE^sCGQ0OTrOO6 z<>J@Zf0Ym33CMeTp!xW+<7NU=B(%1ExnpuV-^$?oQTEn-hjMN&=46?A$U{|X$JUzr zjr;q)=$3Bvc`c`@@Ze;4?7{TSRWGgUnXHd<-`o)9JVUa&78r!8C9V-ADTyViR>?)F zK#IZ0z|c_Fz+BhBFvQT<%Fw{d$P~!6GB7Z{-*6d4LvDUbW?Cg~4NgrK`9KYlARB`7 r(@M${i&7aJQ}UBi6+Ckj(^G>|6H_V+Po~-c6)||a`njxgN@xNAF&x-_ literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ic_cab_done_holo_dark.png b/actionbarsherlock/res/drawable-hdpi/abs__ic_cab_done_holo_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..d8662e3f0fdae62cdee68c184a30fa9e421dc338 GIT binary patch literal 713 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}a}trX+877l!}s{b%+Ad7K3vk;OpT z1B~5HX4`=T%L*LRfizez!?|}o;S3Cn7d>4ZLn02pop#z!+EApeUwz>goe2TrwSq2J zirU3kvaXhOUTIG}?do{Paly7dd_m%&JI?q_-onB2%KO8{j^-Q>wzNlYp6R5&dH;Rm z|KbvtPbZZ7*R_9QUBqkhp({MdL+G`PeiKVkcC&4Y!{nAd6Z!S-oqj3U!mzMkIqyf? zf)_G(nEp@p{`aZ-I!9g5h7aq1927O&FPT&GvG@NuQA5$TGve!iOqW^IxiY{>!{pzO z!{3V<)Sk6$zkBfg;!caFvF0E2Z#WAV9{aHQL)vPusEmizHw=GVH2J}B^#kKc_ZNxM zzDF#RGe0;TaIo&I-m~b0*sP8To$2@Yde+QKc8kg_`XHU5q@;HFk@ug+O{X5aZ~nk~ zjknIKwfM~0Z^b864VUMM@zwGAdYt)v<(Nz4IlImB@8#qJ%zn(A@Z29bd}4MpKn$sTM506307QmPCTFYr(@#O zpZ-(V%YE!?30QE(DXivDMdI0PFM+AKOT1>hnX-6tX;O6(d#2d)iSBZ_kN7m7WzTRr zzEA`h)2bz|5hW>!C8<`)MX5lF!N|bSP}jgh*T6i)(9Fuf$jaCl$hI;t2>JhQGm3`X z{FKbJN)!#IR;K1a1kqq?mJtlpAPKS|I6tkVJh3R1!7(L2DOJHUH!(dmC^a#qvhZZ8 Q4Nwt-r>mdKI;Vst0K3d3fB*mh literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ic_cab_done_holo_light.png b/actionbarsherlock/res/drawable-hdpi/abs__ic_cab_done_holo_light.png new file mode 100644 index 0000000000000000000000000000000000000000..ed03f620f8ef9e969d0471ab76329038e25c9f0d GIT binary patch literal 737 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}a}trX+877l!}s{b%+Ad7K3vk;OpT z1B~5HX4`=T%L*LRfizez!?|}o;S3CnFFjoxLn02py%z6(IY8q0$M=`{k_{&Q=;t<2 zt8!*r>&D`|W2$+>pS=eAb}M##+^cbdA4dCLPr0$oL~Mm8Bn#4$+9@L$(#*Pp%fW0&@t4F~+Q4$6OeIrG`|nG22@uVa-C zJ=H0n)NABBE9V2ZrDh$}Ob?>#U7^{{%b z^;_|*S@)*|RLscvyw85$_Y2}8p?L-UY)vO;|NFUQJ(sNEA?BESpVrme#d7mboB7l} z-Tl+e|M{(6F|!lpnSU$jtXi?CXvKcs<;$n_y<4FKOaZDTt`Q|Ei6yC4$wjF^iowXh z&`{UFLf61N#L&#jz{twj7|6CVFbMhoZ8M67-29Zxv`Q2WrdForKm^fXYnBlV)F276 tAviy+q&%@GmBBG3KPgqgGdD3kH7GSPrLyp3str&PgQu&X%Q~loCIB{EJ2wCT literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ic_menu_moreoverflow_normal_holo_dark.png b/actionbarsherlock/res/drawable-hdpi/abs__ic_menu_moreoverflow_normal_holo_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..2abc45809c62513224e9d695542cb8dd8e8087b9 GIT binary patch literal 144 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezt=sPZ!6KjC*gdALL|E;9+*q=6m<7 zlueVX_4IZHnJ0qE#_rG0T(kiyWMEjjhCTn?qu5pu`=4q}27?c$C=-xvpo(CHaDZeV Zn6Yoz!5==w*?y}vd$@?2>|OKBsl;8 literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ic_menu_moreoverflow_normal_holo_light.png b/actionbarsherlock/res/drawable-hdpi/abs__ic_menu_moreoverflow_normal_holo_light.png new file mode 100644 index 0000000000000000000000000000000000000000..bb6aef1d069a14a7fc1cea9780c919c61679e4fa GIT binary patch literal 148 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpUtXipc%kc@k8uWjUIP~c#3xZ62X z=G4p^oaPsfxfS0Jish)R3f(&WG9yqa14Evg(y_dGGlfCy2iXqR3?>_SEs{VyhV?DH iJ0OaDc|iOR772{!kNsXaOPT8&i0|p@=d#Wzp$Py$I4IEo literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ic_menu_share_holo_dark.png b/actionbarsherlock/res/drawable-hdpi/abs__ic_menu_share_holo_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..6f747c8f065940a8844587c682fb3c9443ad1ca2 GIT binary patch literal 467 zcmV;^0WAKBP)SO)@i{}u0qYYqHziBfu2L*;{L?D;GxhmUqDjP ziMkTn=nm+BxmDP>FsP2fGnnz3AAnfGAiD%ptMDlguG*u-2|uL;kN%Xenfoz6Wm9neQuJ_f08buH`WL4SA>8mzG9{4uwy+$BT^9a|eO3@D0j4;gS>^u3i8D002ov JPDHLkV1mHE(I@}_ literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__ic_menu_share_holo_light.png b/actionbarsherlock/res/drawable-hdpi/abs__ic_menu_share_holo_light.png new file mode 100644 index 0000000000000000000000000000000000000000..682b2fdec4cdcffe042a0eaba5574fcb553c6fab GIT binary patch literal 505 zcmVavhwv6%LZS|`6cHU3BI+s;(j}rxR}U>ALI;t;n}mlvh$!J-yZtua#I%j$ zOwQ&T8Q}wUMSkBn``+6%%Cao-nJ5SZfglhBcnTy*QWjP42;RUuXn|w-Gn@r3!4%9C z+;SJ#1s`+53r;u-JS+&G)8Q=eVjwW)EYS5?U=Q?t+(O%+X%L*ae6USp(Wf44I z{VTBf*DdH$;99e18zd%PPify*mOc4h3DgW)zaXzPJFd#ED}jzd@IKXer+vefz{o(L zSH{%(p8{RZ0^V<-*kS}|(%8UCAfi$^)3kopWmIldEo%J}dR~)`A1WGIol7IL;ao9F zT=*mq(WtgX@b^ z8v#5LPB(Y&Y|7|Y_!S62?p zbb>IW`N`93fr2)kE{-7*QBRJJkl{&7FVVepxUS$Rt1LT2VAvn7lLLt0oo!v4%( tpjG6n=4tr&fORvYRP%q%M>EqU82;Q9of*be(FHVz!PC{xWt~$(699PnDoy|Z literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__list_divider_holo_dark.9.png b/actionbarsherlock/res/drawable-hdpi/abs__list_divider_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..986ab0b9746301f2dd9401829da09e00995621b3 GIT binary patch literal 78 zcmeAS@N?(olHy`uVBq!ia0vp^%plCc1|-8Yw(bW~qMj~}Asp9}6B-)+^BAxRtXRm= az`@Yw&#rLZUbzUUfWgz%&t;ucLK6T(%Mo}0 literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__list_divider_holo_light.9.png b/actionbarsherlock/res/drawable-hdpi/abs__list_divider_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..0279e17a123f8cbb3c7e3a9ce5c5af8e693b6977 GIT binary patch literal 76 zcmeAS@N?(olHy`uVBq!ia0vp^%plCc1|-8Yw(bW~!k#XUAsp9}6B-)+^LX%RmN2q0 Ycy4A9FVZ~13zTN?boFyt=akR{01+Y(GXMYp literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__list_focused_holo.9.png b/actionbarsherlock/res/drawable-hdpi/abs__list_focused_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..516f5c7399c853d112a31d1e17c8c7f17180f9bd GIT binary patch literal 159 zcmeAS@N?(olHy`uVBq!ia0vp^+#t-s1|(OmDOUqhEX7WqAsj$Z!;#Vf2?p zbb>IW`N`93fr5^nE{-7*QpO1)z4*}Q$iB}R!lH3 literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__list_longpressed_holo.9.png b/actionbarsherlock/res/drawable-hdpi/abs__list_longpressed_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..4ea7afa00e2bfe057472ed5a196080fc80ad7383 GIT binary patch literal 154 zcmeAS@N?(olHy`uVBq!ia0vp^+#t-s1|(OmDOUqhEX7WqAsj$Z!;#Vf2?p zbb>IW`N`93fr2)kE{-7*QBRJJkl{&7FVVepxUS$Rt1LT2VAvn7lLLt0oo!v4%( tpjG6n=4tr&fORvYRP%q%M>EqU82;Q9of*be(FHVz!PC{xWt~$(699PnDoy|Z literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__list_pressed_holo_dark.9.png b/actionbarsherlock/res/drawable-hdpi/abs__list_pressed_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..5654cd69429fd0a3502a05b5f827bffab89cc7e0 GIT binary patch literal 159 zcmeAS@N?(olHy`uVBq!ia0vp^+#t-s1|(OmDOUqhEX7WqAsj$Z!;#Vf2?p zbb>IW`N`93fr5^nE{-7*QD_LZ%D`aoRl?HIGCc%n7=x#)pUXO@geCyJM=ZAh literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__list_pressed_holo_light.9.png b/actionbarsherlock/res/drawable-hdpi/abs__list_pressed_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..5654cd69429fd0a3502a05b5f827bffab89cc7e0 GIT binary patch literal 159 zcmeAS@N?(olHy`uVBq!ia0vp^+#t-s1|(OmDOUqhEX7WqAsj$Z!;#Vf2?p zbb>IW`N`93fr5^nE{-7*QD_LZ%D`aoRl?HIGCc%n7=x#)pUXO@geCyJM=ZAh literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__list_selector_disabled_holo_dark.9.png b/actionbarsherlock/res/drawable-hdpi/abs__list_selector_disabled_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..f6fd30dcdc9c39c836e509486854f9da03486892 GIT binary patch literal 189 zcmeAS@N?(olHy`uVBq!ia0vp^;y~=k!3HF){@Qy1DVAa<&kznEsNqQI0P;BtJR*x3 z7`Qt@n9=;?>9s(?cuyC{kcif|*A4j^95`Gq9-KV8B6o6ra`I!Z80pW;7d5zZGhRBg zm{FnhT6Xzih3ZMUGkfBc^kAT_eS7{3zPQ8d#DAm9s(?cuyC{kcif|*Eb3_81S$-+V)J@yPBVWyvqG&GeYz~KYxJdw0eeyIoHJnOEfn# R{sUUY;OXk;vd$@?2>|r{LWckV literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__menu_dropdown_panel_holo_dark.9.png b/actionbarsherlock/res/drawable-hdpi/abs__menu_dropdown_panel_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..4d3d208578c61662986fdc16bd15c69759b48d6a GIT binary patch literal 922 zcmV;L17-Y)P)!ytdud6iMT7O&4bD*mP3eKws)UN7D2k#e z%DbYt@4NEYnkjlINEK7=*RV3zwml#Px9r!q%}Y$QM*NqHEZ-wscn^ zf4p9=Kg#ZZAKY%YZvc!aCbL}F6eGxtBSzy=smEUmc6C{?q1YCQrid~5o$!73+BeU$Ee{DI^Yo4#-o87 zao*xiE9Z<+s}ttlWw19HGlEA1nW09+*~|#}a;CkeJh%bU1g9CP5h0^O2}4Hs%y=Lc z5q!OY8j*^uk~rBBK?ljmh#jL84Ev;rDo>_H#K|6e%Mo=CgLzw$rI$Y4Z-kUy6U47Z zMI2w^tmuV~pH%tJq!^(yWY-hbFl2;G2g)+VPqud2Sicc+jL>MvBTKK;HbN#jlrS<8 zl+;FqdPULzJ~Kh_!?j8>!xs^*nQAm$#290~ue;BBnY1w&wMw4#m(pwEDZd_oY1{Ux z>$>N)H(eWD*FCpw`-IsDKF28-6~1bz!JGs-W6Z&R1n>#KR{&q8us99Q}8ID#(NJr3oa@N-D4Rc$qhA--bT2} z_Wpf@Z`4749}#V+fwWJz^oyZKO1~J&exY-1*Kg?D$hu!fixvAiNfpmG;mo&f5BSEA wlE;@gYed_N;JFm#Y)Zw{1W}kQU9GkF3xsHEK4Myn7XSbN07*qoM6N<$g18=|djJ3c literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__menu_dropdown_panel_holo_light.9.png b/actionbarsherlock/res/drawable-hdpi/abs__menu_dropdown_panel_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..924a99d173082ba58ca7527822359f228bb14dec GIT binary patch literal 1061 zcmV+=1ls$FP)#d)-&;4-At916hopygyW1WQa|lkCWZ4-q&QLYwjy>%Jd>?UvK6*fy zdt!`Ep~K-gOUxeEG;B7TCA&L&Y`5FR`f3tF5S^VH!lJsKJqkfK0&PN7nPcRS?`4Ev z7V~vPKouy~L@5%v*=&-(hy0cgM*ETwjWz&8F3NVhH7#V4$3+kVgi2lPw-adOTXm|2 z;f`P0rx+seIw-H@dwPaOx@-q(hY$i2BS4u1XM~+%LI5%mN(D;0XOsl63U@~43e6EU z5mrW96C~;L2O}H%p$jmGc5)7LM&^oyAacV=14{s_wp`K^YIpyDFEM02mXk3OSEw-p zdORS~SGTvf|Cjl{`o#71_3u-2KzcK(ZU7La5JAil5&>9olp#5yVJhG_L?OnQ2x7(v zIfg2+Q2z$cZ7gkJK~)>%8)`3CJSNBlBGKwWz;6QnLDPCN+(q9 zAJ*09wM4d_hZLYxWa z2;mvCbu@F-B1H21)loz{?U-+?@nqk8kw`Vm31QkJFg_V%{OMfZr8mlq(-<|uJGVoHpVClAlh&-bsduQ(hI zi(GsU`1tt1hf_X{d`3<68b|S{tXYwd2YXzXl8Izg4y^21 zp<@H92ON{kB3P1HizBE$;EP~xzks74y{^`3Ur7(FmPO0@t2+WXW`VN|Gc9|AJ43ds z=_5ZJGT6$YN8bIa6HYZ^jFIn`&>W#9La9l$?6@3`ET&WsUkjFK0@?|yO)(6`*1l_s~_L1z$~& z@jZM)qqe)$B+Pe}79nG2sji9uR0#8Z){~%#a(p4yPG;@1CipK8G=YCTO^$u*mj`Me f=rGa5Ym5<}3Pv>t$oVA_00000NkvXXu0mjf+qu}} literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__progress_bg_holo_dark.9.png b/actionbarsherlock/res/drawable-hdpi/abs__progress_bg_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..310c368e7a68479307866c479d1e4eefcf5db311 GIT binary patch literal 178 zcmeAS@N?(olHy`uVBq!ia0vp^96&6^!3HF|1ZAax6icy_X9x!n)NrJ90QsB+9+AZi z4BVX{%xHe{^je@`h^LEVh{nXLlN`Ak3Qu?vqkba5WyT9CKZ;N%wBhP~?hKK2LK3q{Q@b8ror6q0>Kp=4vJYD@<);T3K0RYm>I5PkM literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__progress_bg_holo_light.9.png b/actionbarsherlock/res/drawable-hdpi/abs__progress_bg_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..70cb7fc7e0bcfb850d4b365f1bccb5b743913e21 GIT binary patch literal 174 zcmeAS@N?(olHy`uVBq!ia0vp^96&6^!3HF|1ZAax6icy_X9x!n)NrJ90QsB+9+AZi z4BVX{%xHe{^je@`fTxRNh{nXLlN`Ak40u@7AASF0zb~yy)74d)-}Q|XM+&=H%L1l~ z70X`DZ5Q8J;=>T6aJiv_zhUdQx9rw$B!4Wi^!v;8!uD-LM?h!CZ3$B@rZO?tz^Iy& QK(iSCDOJO>Ym5d24oA2hD9A9kkZ#C-ocYxQulY$%dG^s1`jD zWrBMf{hI5z?Ps6d&cAMwxpu9tAQSLC;sV+l?CI!atlqGv_K~X}S&7D6#irA$G%zcr zGa^}SvXODrvrsWB#ZkB-c}-Y}>Q0!#L#9IQCX$ZI#7DnF9fJ8(R=8iR{NJvIR3GfdBS0fGXvSYugM@B@Fy~s_l`Jy)|ccqHxmVzApHz{x4N{y z#Xj0V$LH=@zsWY)$4Z)6--edG^VYGh&b$}$F3XeLt5=Uu0`p37@FaypB&t$KuAm9R zq*|yt7WOdr(m%g{dU1bs0-qy(nh~3JDc<<|K^(;cR4G!8UrKd|p;N zi5zZftW#Kk#vM}fdS+hLQ#;Dq?H?_`8P1nhqmR=j>Au${MMR)hh&5HCA z?cjx6pHV1ZFFx`ra1m|YMALE$u3RAxZp(6Eus@DJwzn!G7Cw2Mm%K&AN5Ia`DuuPd r`dvHM#yxB2nYDo;0!e2cs)*3P7gB8$K+RT%00000NkvXXu0mjfr&_ZI literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__progress_primary_holo_light.9.png b/actionbarsherlock/res/drawable-hdpi/abs__progress_primary_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..1c269205e874bc6addc308efe5be4fb7c5da0edc GIT binary patch literal 917 zcmV;G18V$CDOJO>Ym5d24oA2hD9A9kkZ#C-ocYxQulY$%dG^s1`jD zWrBMf{hI5z?Ps6d&cAMwxpu9tAQSLC;sV+l?CI!atlqGv_K~X}S&7D6#irA$G%zcr zGa^}SvXODrvrsWB#ZkB-c}-Y}>Q0!#L#9IQCX$ZI#7DnF9fJ8(R=8iR{NJvIR3GfdBS0fGXvSYugM@B@Fy~s_l`Jy)|ccqHxmVzApHz{x4N{y z#Xj0V$LH=@zsWY)$4Z)6--edG^VYGh&b$}$F3XeLt5=Uu0`p37@FaypB&t$KuAm9R zq*|yt7WOdr(m%g{dU1bs0-qy(nh~3JDc<<|K^(;cR4G!8UrKd|p;N zi5zZftW#Kk#vM}fdS+hLQ#;Dq?H?_`8P1nhqmR=j>Au${MMR)hh&5HCA z?cjx6pHV1ZFFx`ra1m|YMALE$u3RAxZp(6Eus@DJwzn!G7Cw2Mm%K&AN5Ia`DuuPd r`dvHM#yxB2nYDo;0!e2cs)*3P7gB8$K+RT%00000NkvXXu0mjfr&_ZI literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__progress_secondary_holo_dark.9.png b/actionbarsherlock/res/drawable-hdpi/abs__progress_secondary_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..40d0d1645cbf05e30bf092ace45403281da7f318 GIT binary patch literal 188 zcmeAS@N?(olHy`uVBq!ia0vp^96&6^!3HF|1ZAax6icy_X9x!n)NrJ90QsB+9+AZi z4BVX{%xHe{^je@`oTrOph{nXLlMZq=7znVWA2oV&$ZSjW?F|h7ziq5jS#e}ezd(V) z{M(JTeF@SBrcbxn{QE=WZYK^04VRD=846z*9&b9ovtVvpnl(eT%D#{N!SzC3^S3#* f<|u1MCr7h0-;i__`(soEw28sf)z4*}Q$iB}%FaDT literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__progress_secondary_holo_light.9.png b/actionbarsherlock/res/drawable-hdpi/abs__progress_secondary_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..40d0d1645cbf05e30bf092ace45403281da7f318 GIT binary patch literal 188 zcmeAS@N?(olHy`uVBq!ia0vp^96&6^!3HF|1ZAax6icy_X9x!n)NrJ90QsB+9+AZi z4BVX{%xHe{^je@`oTrOph{nXLlMZq=7znVWA2oV&$ZSjW?F|h7ziq5jS#e}ezd(V) z{M(JTeF@SBrcbxn{QE=WZYK^04VRD=846z*9&b9ovtVvpnl(eT%D#{N!SzC3^S3#* f<|u1MCr7h0-;i__`(soEw28sf)z4*}Q$iB}%FaDT literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__spinner_48_inner_holo.png b/actionbarsherlock/res/drawable-hdpi/abs__spinner_48_inner_holo.png new file mode 100644 index 0000000000000000000000000000000000000000..c8358e9cefce502030416e05dc8faff139b886b2 GIT binary patch literal 2081 zcmV++2;TRJP)YIdx5%v}IY-E={))x>B}kD^;1aO=v<01PBB|;(|LQ1lm?k zLWq;Nn-CY=ae0(~!^>I`t6s zs-B%JpquWw-vVT&b%#DKYKZiAR|9AYVtSC>+D1~E4^t2*_YE}4C7t2scS_b&i9ji7 zBYSvMwdlT0Go+O!I1;=rq$n|BisnJx=53v0;@hqm(7l)*=4rJMo!clNrP~Z@m{E-} z^JZ{ZNHx@{flX?mQSo``X|C|5u79fpM_&?X60Kt|A5rbxJ7+XZpRQ<_6xsZ!_#wo! zj#h1_U5!M-Io2>ob>UEYg+LRijsxnVI$Sub8=TigMynU~iXTIjns`*ZXjCM8l?je< z^3e1OfW}cB&*(9#LY#4(p+|S(CFYo)RH;RK=~N=zD5YZ@e|b@)#etF>)Z-yez@UzD zxn@bF&zGN~8oIPk4dfy-rEX5Ww8$EZ0F70%U;9F1W%-Z($&Ga-Maup1vncKQ7_DKl zn9!@7d$FjFqs1PKM)U|Dr6$Db)oTnV%fNxx{Okxr+DM%Qs^$R=K0p5VBBLXP|Go*uWAqrP!s#9EjG3Y5H)_%&0w$xIP8)2<gS?toB)4w_5VP~5v52jeNf?a@l%z&Ft# z7nB8|dUgD~fFBhAa+9}!Fnz66uJJUZMq$&Z-=x+YQJfJpw%hO;S zbE}u#&MHNeP>Upl#AP)>l0hdeKfNO4(#tQm-Akeu&02@RbFR7XY>6_k1%f(YAT(#fsAW zCKBlg4QBOIpq?mn>zJh1X=9x9hp4F}kQ(@481j?!sz3o)0BA?xOCB;{@vwLHR_qA* zZA`n>5_V~?==zrnj46C`9p$WNjB&zGc+-W7;QUT(*KSn_p>ds2!NyfVppL*7{NFHR zx3J%}=U0sLd(^D`)P?PxcXaJb1;-WXet3d^dmIcA@AOk%p(p(THF8j!=km|#V)bYd zpicX$PljfTc@O)})|@FD=Z~mC2i2imPj;N6y7k2(V~h2N*p=p#-z6}HxcB*hYkSJV z`IFSdb9yY-P}dA6b@>ZL?=z9&3we?^d^OD4aqs1Mx13&f#Qiy{cDn?wohTPSPjL-WpW1m}O&Ju5YPHyotYlm=9`GcY zrwYvY8;-f&ZSM33oCpsge2-Ip%afm3V!sl6q6gM{kN3J3%|Xrhwg)`uVUIiGY!FzE zIO3Qa-0aQX;)a}NjB&uQ|K;9KmvHqg(MeCoc*sw<&DEj$2|GyBp7MmJgBi=!jyvfZ z$6Ymtf^mwAKHp@Hd-~&L-Nsi~>l_hPjymE9wjDU*%(E+7 za!uA`P2O+vKSpg~;?JJlUH||9C3HntbYx+4WjbSWWnpw>05UK!F)c7SEiyAyF*Z6g zGdeOeEigAaFfi_TCsF_a03~!qSaf7zbY(hiZ)9m^c>ppnF)=MLI4v?WR53O>Gc!6e zGc7PTIxsMwC7)_* literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__spinner_48_outer_holo.png b/actionbarsherlock/res/drawable-hdpi/abs__spinner_48_outer_holo.png new file mode 100644 index 0000000000000000000000000000000000000000..f62f74bb38e8818fd970b7ec1f7862e543cc9d07 GIT binary patch literal 1811 zcmV+u2kiKXP)Q(x@RlU0R z*6*F+o^#JDHf2*b#j2Gf_PMBSbuGRn) zDJUkGcinCw!4`)d@_D~EMJnC5dvGXBz z^GjW6Gg4BPB{MBwxqQWN<0fP#?6J=Sj@WNJ!AH@8Kl`>9L$xnJF(@mqT0WPnt1qF1 z=Fx+;deGw@bGK5OQ+L*P{Upq+6DX1yGQbK>T~%EkI?XGa@}$o>ppa%>^8?Sie*2l7 zfHK3%D>%7|N++0Avr7*8vd@}G^Jo0fcfyUHfnsLZ&jU?a6Rn7I58e-AIzUHA66jy!AvGyBgcAIA_8&ya%2-o5w@+x^Frq z7x5uqjDu?ciVPZ-34&-=b^T>U$i3owu8N|PCmm@W9a)>Z@0e@OLVt>;Q1iTBsK`Y- zJ#Dm0pva)1q@Sv}wFUZZ<(6Yki*muoJ=kjDtmVDYq#tH=k$<|@5vTpkf+%-~CzQJb zDj5=FGBxvks&SW*YJTnCqA2*7ySf013>jGQpITpe;Jn|eigLRhZQhTXHIx~a$pm$C z{nZbIsz13R7nL1tHd-@KF*$Um(og?cC1;!x<)VYeI|B_UB@HdgHw5UWlj@?}cDp+O zMal|-j9w2i9i`?Cb8^v;J)JZZ3@FG_LfsGv{MVdZZorO4w{8Y134%<%0TH$=m)%OW z_@u(SziK>nET6ihG`KOcU?%zJh~m2+ycN)r5;qQq+h%%Xy;f)Ejn0a3UnsuS^+vZqWP#0th z#x}@k!|oI0qU+rNRV>J4GUFR$v|a9z%jMoM-5IE6CMAy{ll?bZ%p5f-7cDwzt|L%b z^86*Y-fp1pM3X+OAj(~JqWJ*PYCpbZCY5MgZSAj)V(>vz$zUg(ZywPKsOqx1Or~s4 ztCPVxWShrQgx&N<^IZW2u9-7hOofKj5BzxpoW= zdO}GqH|+&2+j}j6LUh@cv}2FCzaLvtWZ?^TwHb8;v&L-C`+P^-e$fT!yBz5Da{oL7hj@h;h3%R$P7X_J;dmT2? z8&V8*_<~22M7c%3b3D}BjlNwczv7fZds1ebGU8;svesTmESU0X4=BlHYF_eOt8iaY zL0I~yq8N;M$m4dU73%)xM=srNe&@#dxWo1;CZw8+{^f0pouFbc zV#*`lZz%0)HGlQf<_c&{Ktx7;z}?CzodgvZopY&OUp7)Q;eaFVO?})iuy4L9j zyLs2K^qSz1EvYP7>Ws{|~_-QddT;IiL%she&}m+lY?b~t3u zik_CPT+O0+6?K`iA!CLOr{nnY$OW(ay)*42s|TRe$lC9I+YPJ$b-IG8H~q!myML>= zroa>ruDyrb zV`&jHgSNQCgmI$=lu=hRYuXKOo3_xM&-4jsmA;l<3@^Ph&(-?zXM#=Hludb0$^QZH zs3&Vcm*{c;001R)MObuXVRU6WV{&C-bY%cCFflPLFgPtTGgL7)Ix{mmGBYhOH##sd z?sz9s0000bbVXQnWMOn=I&E)cX=Zr$HaasiIx;gYFgH3dFrOu# z?f?J)8FWQhbW?9;ba!ELWdK2BZ(?O2No`?gWm08fWO;GPWjp`?002ovPDHLkV1l}_ BPJaLZ literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_default_holo_dark.9.png b/actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_default_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..eb28ff9a5516c15667fa8fafbc22d608d1f77a06 GIT binary patch literal 311 zcmeAS@N?(olHy`uVBq!ia0vp^%0O(y!3HF+1t+BgDVAa<&kznEsNqQI0P;BtJR*x3 z7`Qt@n9=;?>9s(?o1QL?ArY-_Z*Jr|WFXM+FkX}IYI~tj_}8!bFJ^a4j((ibs-&WN zGIsXEx)Wtn`lnsEAmpSFI79ccn9RKAsn<`<tk;t}o>yjV{qp%WbL{dki&M)*dw`x~@O1TaS?83{1OTcY Bcf0@q literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_default_holo_light.9.png b/actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_default_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..d281adb553af892f758407b846bf31810b9d776b GIT binary patch literal 312 zcmeAS@N?(olHy`uVBq!ia0vp^%0O(y!3HF+1t+BgDVAa<&kznEsNqQI0P;BtJR*x3 z7`Qt@n9=;?>9s(?Tb?eCArY-_Z*Jr|WFXM+FkX}IYP%rckLbO*zpbz{y7bYSIrPClD)2Hc3qcaC*%7oYhKR%+5DyWbJ~oU4#{OKNlluqE0VJm zR?Ud&kaA;Q)O4{aB-unUR3g{I@EB82%f_aZWF5r`AFqi`v@HN~5*v&Qo>cRA$gv99 zHaapFv&*%1#4~?bwda`9)~}vNKHF@K`t|cGZ}Xb{RR4x!PC{xWt~$(69DLj BcXj{( literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_disabled_holo_dark.9.png b/actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_disabled_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..b2985860907ac324b509b76731e8ef9e01bcef39 GIT binary patch literal 306 zcmeAS@N?(olHy`uVBq!ia0vp^%0O(y!3HF+1t+BgDVAa<&kznEsNqQI0P;BtJR*x3 z7`Qt@n9=;?>9s(?E1oWnArY-_Z#r@{8;G<#%>2r*^uo7)-)HXL@_O1Ny%Iq#{YfeF z(mvLmIJH1t&`=}DOJmBWhqv04yB582t6X;JXNKdwfEg3JZl{PztUeIIdQ8h8YDr!LqoiBzejNy&kDcJs%rP689)vmGI{X_;^jtl6gm^<0^v)GdFRa+YOJx z7F>vKtz@b&Rr+MtRJ_Cdn)*bIu9V&{pI@`*?C`z(Yf|Vzp#K;=UHx3vIVCg!08ssU A5dZ)H literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_disabled_holo_light.9.png b/actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_disabled_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..4215396dd4e51fea9239323d313b72fde0ba86d6 GIT binary patch literal 306 zcmeAS@N?(olHy`uVBq!ia0vp^%0O(y!3HF+1t+BgDVAa<&kznEsNqQI0P;BtJR*x3 z7`Qt@n9=;?>9s(?E1oWnArY-_Z#r@{8;G<#%>2r*^ujlV;{V25Ur(E)S0c!zKPhEi z+Q+&RrxwTy8fpZ2X-wJl@K&30*P>T$mCG*u%y7IHFk@oZ?G!PI)dwP2k7*f%?N0KT z=P~Pe`QZt37-AUDv?qm~sFi(Y>bsQr3FCw4S+92))lbOG-Y30G>`_~0 literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_focused_holo_dark.9.png b/actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_focused_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..a280eabf59b5eb69fa2a84280402b63d5e1bb8f0 GIT binary patch literal 524 zcmeAS@N?(olHy`uVBq!ia0vp^%0O(y!3HF+1t+BgDVAa<&kznEsNqQI0P;BtJR*x3 z7`Qt@n9=;?>9q_DjO#pI977^n-`=$MKI|ZI{A2#4tV=npb9cQAXy4X!_bwM}{Q4K( z1sl8bnxc=22fURRmTQmkS`l-5N%{4LzmAq3{WkJ?oSyR(lyW*m>cW(jDj1r7drC_% z+Ahf4U7%?EfVHA#U$%eE)HUhV{* zGqMRv58QeS1t+_UJh{!Nwtjop`q`x&KXzE!mvvsrOU)9V|3+xFYu0w7ttSN+pN66C zV4oMA@AG&3wK%+`$wcPZ<#Ux2T-c9-*heq_yZUm|{V%D1UlxhJm0zYfUETgVr;hpA zt-Fj|Jsx=O$lYh^6WL+vBibSA6WURD#!g`Ij9SHG25Jg!2FnzxlYN}N9h%V=a_mM! z$e|leQ;yweap>IrEpmd};fhV2Zrn5uN|m^)*v*dyQIi{G2ej@g`j zy#1roz10ezmNeBYwbLI^0W9{MT&2dcxOa)`zb@?O?Gu2 z*S413TzCHUdV}>`f)DaiKP_4HkL&Y-WAl>F%y}d1AGY65et#XKh5dqWo7Y|}14bu< Mr>mdKI;Vst0N8Ej(f|Me literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_focused_holo_light.9.png b/actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_focused_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..f8d619b4d47ab5b104d6b1042c27fb16a3beca47 GIT binary patch literal 523 zcmV+m0`&cfP)C3<00004b3#c}2nYxW zdK`GU$CA-E+tg1FUj3CV1Ez}l7r{NB_YWZ zgb+-Kh;2qAgunr)owSNT9jE|#(}iQ{0=K~F)j_f4%AIwfW*LI4SCjSena$3zhl@?`-N)f>fC&00iU>|7tSL}YGdG832Z z7Ry93w=$W@5~IozqskJa$`YfBUCf~8@-tLEe(Yg7ZJ&$d5^vAJVlkbz&)H#>=1rCU z=lI*@D9QucAy4<)W_$YF0~q6}sI5vC!>ie*fX@E1>5KTAKqegRE>ywO`Fw(I}^ N002ovPDHLkV1grX;W+>R literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_pressed_holo_dark.9.png b/actionbarsherlock/res/drawable-hdpi/abs__spinner_ab_pressed_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..955a2f34061ae8ac853050da355f89409fa0a784 GIT binary patch literal 464 zcmV;>0WbcEP)C3<00004b3#c}2nYxW zd0`Pl=$b2!s#>@tS z$Y#JV#)+K6SU+tW#+_RkXYzpRi_e9eTN!5>F{(z4su81V#Hi{OLkTB`etUYuM1<4( zFh4)_STHCiBAh-(+2ze7j|0M$*V@)G5^^0JhFHh^fzV_7Tf?-4Si|T*tYCB@#xY$W zMloF>#xN!zMlhxzoiQdMoiL^$+87%UEsQNlYm7|@05m?}iO1-}bYl(D3Ue3c7gw}A zD?zp;CtICi-;5NDtN#ybjCs$)&yQmArGt<$4!&l7(HXO5p7J23`oDJvMC3<00004b3#c}2nYxW zdPRE!~6H3V|7LaeL+kwzxO}{DvWjdA^uWhB*Ox4MVbeVt$Spwgkx< z!VkuXjKgSuY)h6Hw=%|LL;AyKLdLC(F?ASO9Y$7%k=0>jHH%rr7Kwb5&>UvDaCo}j z=j+357qeVAJX{{~a_138(!I8ROa__X7ee%7enXtUzOE0mAw(ah0z?m{B1Ao=21G5U zCPW=Z0YnW(5u`pwA*3EgF{C<11Ed;86J&FYMhHOp8-||_vny?o%`ne52fWVraQiWC zKdv-wupMF9(yd;3%<<_PN8|TOh%C!a80|#$F{54SO;q)d{~Z)(nS?QFWpYf|szS`q zFpt2hCCEz5&mZk`@i_(t4MLWruXxh=CcXUn1{k8P{&E{)e*gdg07*qoM6N<$f@(ay AcmMzZ literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__tab_selected_focused_holo.9.png b/actionbarsherlock/res/drawable-hdpi/abs__tab_selected_focused_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..673e3bf10d60cc54b6dfef2fcda24575073adf61 GIT binary patch literal 147 zcmeAS@N?(olHy`uVBq!ia0vp^tU%1i!3HFsuehcLq*#ibJVQ8upoSx*1IXtr@Q5sC zVBqcqVMgJWBc+iXw=G=Ra=)z4*}Q$iB}l;b6k literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__tab_selected_holo.9.png b/actionbarsherlock/res/drawable-hdpi/abs__tab_selected_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..d57df98b501944b4ba63623766c396b5bccc29ee GIT binary patch literal 148 zcmeAS@N?(olHy`uVBq!ia0vp^tU%1i!3HFsuehcLq*#ibJVQ8upoSx*1IXtr@Q5sC zVBqcqVMg}h~fd(*my85}Sb4q9e0H>EG$N&HU literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-hdpi/abs__tab_unselected_pressed_holo.9.png b/actionbarsherlock/res/drawable-hdpi/abs__tab_unselected_pressed_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..aadc6f87b21d7d5139f3bfe860f4c289f75d241f GIT binary patch literal 145 zcmeAS@N?(olHy`uVBq!ia0vp^tU%1c!3HD^Kbl$tDVAa<&kznEsNqQI0P;BtJR*x3 z7`Qt@n9=;?>9s&XV^0^y5RRG22KRnVX>4qKXwM^^Uwi5RN2-aD!@msM(PIt=evwJLPDoBk{4*AEnmdKI;Vst0H2gA*Z=?k literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ab_bottom_solid_light_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__ab_bottom_solid_light_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..0706c8af658bde9602634950dfe3d5fa5886163f GIT binary patch literal 134 zcmeAS@N?(olHy`uVBq!ia0vp^QXtI11|(N{`J4k%zMd|QAs)xyUfsxfz<`JK;_Z5A z-Y@ApO*&r-OgQM+#9X>wkYiu(tId138dhyGKCm}H$eLN@qysZ=3D*)nlM7YC@0xyy hn}nCMmBhQI$CPR`ipOiMnG7_T!PC{xWt~$(698&aE5rZ* literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ab_bottom_transparent_dark_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__ab_bottom_transparent_dark_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..d814d02d31183b8f00f475a05c124004983d9eff GIT binary patch literal 123 zcmeAS@N?(olHy`uVBq!ia0vp^QXtI11|(N{`J4k%PM$7~As)w*fBgS%&%9EC|%_%783w8jlt8^&t;ucLK6TeKPwmj literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ab_bottom_transparent_light_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__ab_bottom_transparent_light_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..b139c8e49168e4404df0a46b30a4b30e90c1ccff GIT binary patch literal 123 zcmeAS@N?(olHy`uVBq!ia0vp^QXtI11|(N{`J4k%PM$7~As)w*fBgS%&%9ECY>s_{MVWOZ(=mjBT1_sGr W&p6(H%v1uJ#^CAd=d#Wzp$P!PC@9VV literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ab_share_pack_holo_dark.9.png b/actionbarsherlock/res/drawable-mdpi/abs__ab_share_pack_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..ed4ba34ecd9f8ab8c557924fafeae6a89307bd7c GIT binary patch literal 2851 zcmV+;3*7XHP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0000^Nkl8n|1&I002ovPDHLkV1j6N BM!Nt2 literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ab_share_pack_holo_light.9.png b/actionbarsherlock/res/drawable-mdpi/abs__ab_share_pack_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..8f10bd5222239e82e49c5120888fc9a07a324b42 GIT binary patch literal 122 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+1|-AI^@Rf|M^6{W5R22vKmPx>XSQNv;&5z| z@wwFK#IyY<~E UNZ9H+7ibuRr>mdKI;Vst0LZr`*8l(j literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ab_solid_dark_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__ab_solid_dark_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..743d00b6cd7e446c7badca9dd11d1579404569cc GIT binary patch literal 133 zcmeAS@N?(olHy`uVBq!ia0vp^QXtI11|(N{`J4k%KAtX)As)xyUQ!e~V8Fq8aW6aH z`M>?!MSK0VJ5DH+1)MRKpSquM-S5BdOIN+&sn~jE%jQNlsf-1UY_}X6mMgq#dKVMx ha^q%Y#@a>3az|3`-r6;1y%^A322WQ%mvv4FO#tkfF|q&v literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ab_solid_light_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__ab_solid_light_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..17c1fb921f9b7b46aaeefe7afb8302874fb0abd1 GIT binary patch literal 133 zcmeAS@N?(olHy`uVBq!ia0vp^QXtI11|(N{`J4k%KAtX)As)xyURua|z<`JK;_Z5y z;?s*`91mY+Vs~LvSAIRQ|I~ek>wo_(4hk(}+Y^;`>!t%UugL`m=C=w5f(6PQ%h%~C hy?JA^CG4Uk|5eN5b2qlEYyz6g;OXk;vd$@?2>`YpFM0p~ literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ab_solid_shadow_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__ab_solid_shadow_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..ddfc8e3d5c4131f2460254f183938477fc5a0679 GIT binary patch literal 168 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+1|-AI^@Rhed`}n05R21qr&#kfCPg`@kT=WR_nY-)l@u)2m z9YjR(TNrC5J8zlf@MOx-MX#^q?zd~tP;1Ok`WbQLQ#YGy{=Yfu7pEGW;JmVaai5Cr S@!LSF89ZJ6T-G@yGywoUXh2*5 literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ab_stacked_solid_dark_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__ab_stacked_solid_dark_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..007a4b239244212339b817f8de9474a4dc34fde0 GIT binary patch literal 134 zcmeAS@N?(olHy`uVBq!ia0vp^QXtI11|(N{`J4k%zMd|QAs)xyURua|z<`JK;_L&H z*gyPBj&nSGnTg$nOT)YjBQU;+O3-o%)BNS9GKrK90(RDcPwA0 ir}XBH&6co>lKfV`a~Jh`>I4G~X7F_Nb6Mw<&;$VSc`p(G literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ab_stacked_solid_light_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__ab_stacked_solid_light_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..ad6e1a4d9f3c81e20676f979a53cea2084ce903d GIT binary patch literal 133 zcmeAS@N?(olHy`uVBq!ia0vp^QXtI11|(N{`J4k%KAtX)As)xyUQ!e~V8Fq8aqs`F z7bNtyi1zwxcbrft3piseKXpIjy5E1@m#%ulQ?d2Tmd%Z9QW*;x*={*DELV8f^e!gW h<;Km*jJ1o5{)rFFF7K literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ab_stacked_transparent_dark_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__ab_stacked_transparent_dark_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..0ad6c888b4c7e436e7d7c78432dbfdaecc95a7ac GIT binary patch literal 127 zcmeAS@N?(olHy`uVBq!ia0vp^QXtI11|(N{`J4k%Zk{fVAs)w*fBgS%&%9ECxB?U?=uVx Y$^4u51wHGE0Gi0)>FVdQ&MBb@0N@ZURR910 literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ab_stacked_transparent_light_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__ab_stacked_transparent_light_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..19b50abcb536602cf2cd36d5a19805464988bd20 GIT binary patch literal 123 zcmeAS@N?(olHy`uVBq!ia0vp^QXtI11|(N{`J4k%PM$7~As)w*fBgS%&%9ECmdKI;Vst03^XH%m4rY literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_default_holo_dark.9.png b/actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_default_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..5461b9c00fd3fc513aa4465682e70e87cca36a6d GIT binary patch literal 101 zcmeAS@N?(olHy`uVBq!ia0vp^EI_Ql!3HEv&)kdyQaYY4jv*T7lQS|h5*V8PD@dJb zGfWV2j%0YY@&Et-(u-Ft=sZxsVYp-gbGr;f^5z}?TUWk$0o2Ff>FVdQ&MBb@07WJt A3jhEB literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_default_holo_light.9.png b/actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_default_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..5dc6f804aea8ca344275ac6eb497b6bfe0f117f3 GIT binary patch literal 99 zcmeAS@N?(olHy`uVBq!ia0vp^EI_Ql!3HEv&)kdyQd*uajv*T7lQS|h5*V8PD@dJb xGfWV2j%0Xds4&4P&{4SYp+J&{BRiiZ!)425)ejdW>;mdy@O1TaS?83{1ORBM8sz{0 literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_focused_holo_dark.9.png b/actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_focused_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..a70b53c59af769e3c98973ad9718670ce27259ff GIT binary patch literal 109 zcmeAS@N?(olHy`uVBq!ia0vp^EI_Ql!3HEv&)kdyQYM}*jv*T7lYjjGZ_h07hy7xL zS%<;BUsuG{45zRSgeB^>bP0l+XkK D`1l&; literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_pressed_holo_dark.9.png b/actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_pressed_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..85d7aadd4dfb619883f68f1cc63e629698b5dab5 GIT binary patch literal 107 zcmeAS@N?(olHy`uVBq!ia0vp^EI_Ql!3HEv&)kdyQbwLGjv*T7lQS|h5*V8PD@dJT z6Fe3@|6GeFPb#ATqtK84|Mweqan0i3X%}$jvMQLwz#trO`SaWQ^{znO44$rjF6*2U FngE5o9^U`} literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_pressed_holo_light.9.png b/actionbarsherlock/res/drawable-mdpi/abs__btn_cab_done_pressed_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..f7b01e012f895bfe2c4241e1d48771fc372b35cb GIT binary patch literal 105 zcmeAS@N?(olHy`uVBq!ia0vp^EI_Ql!3HEv&)kdyQU;zbjv*T7lQS|h5*V8PD@dJT z6Fe3@|6GeFPb#ATqY%TTAPubyB?B2J9?cgAJee4pt{u!zH{AaisF%Uh)z4*}Q$iB} D0X-aq literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__cab_background_bottom_holo_dark.9.png b/actionbarsherlock/res/drawable-mdpi/abs__cab_background_bottom_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..d8f1c8bd54f4f091e79389603095c99cf825cb6c GIT binary patch literal 127 zcmeAS@N?(olHy`uVBq!ia0vp^QXtI11|(N{`J4k%Zk{fVAs)w*Gcqy~4zxBtu(zuW zGMHg-@7EW5UBeRx4_{GYv)%pQnG{Mujhr&UNqv-pZ`Il{xB Xs2c0@Tz2whppguou6{1-oD!Md5lfPH{+~ zs&ZK!$GJ#`+OXn)bEl7O^s7vMLr%~_eO6@BP#xDsWzJIxbKZ~=QHwoEqiCN;6|k~9&?6VGu8wVeg}kjlqBUkXd|o%rApJ7Xx?SmelE6^*`N?mP%?P7H@yM z@176Te{31>^aeVqCP$2D`iM8b&G*loT1#z02OAN3)TGUD#xbYXQgqexFre>@9yw_< zoN>t9>xRrEIA?_IE1YrUo=P<2hNadJXB=4rbb%a&IXb5^sO2P4AoU2`8OJ_N3+RuU z?3bPMlGWJT{|mv5xDeck3qc!^Tkv+yM^@uWqQKxnw{tZ6G_7EN(=@mR#5tHjEptZL zT?o!N^e&F18P*7EfGlP>S;He0o_$19Sz!q7up>N&hdzT z+KgUQr1}UkLQL4KR;yolWSqh_YPX?lMz7!1&pz~~fd%z~_Z{#V_yT+aKE`}mgO%s( z*Zy2en({y`_&;C`{0061zkwyNiuqzpAev$qeWYoU3d{J#NzC8IACaX$H=;%xu?3!~ z#a`2j|4di>P9KpnLiZ0Fl^vDJdHW{hJgNDYHbk!VsHwq51hhtobGl;RmY>GHkg{)E zesWUhFRGl6)Eh$fMU__)%@X*lTj%8LuWk+fh;ux9b*`$4|A#h$uKO0E`Tzg`07*qo IM6N<$f=1Pyg8%>k literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__dialog_full_holo_light.9.png b/actionbarsherlock/res/drawable-mdpi/abs__dialog_full_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..f18050ea589eaa31233bc08e4f8a4e361747bc94 GIT binary patch literal 1003 zcmV%vbFc60S)hq5aquQtN zO>~Q-PMt}eDy?tfo9G5^U3x~HVu{=o-l^#5`3AXbFq#7CZ= zx~R)Z%-PngELWXE=jG+4wH{HY%RHtL$z+_dj#xsD@Y&isDVlJd1j7%A; z{S3ob2!NCVl}{yrl8B^V**9f-6IC==^T()w$-W%VAY54pg(^F>UjitZxrB-eCn8Lf zB*stQ-rl}17K`6RG#lbS(&{_eIc1V`#=6_}di{5~T>e4x!ZPZXM|a{QRmt`XV*pbC z)5T)(D?{j2cRHWXf1>hHw<=z1GC@s9Ro2lk0Wc$?r`}K3Qx5<^GzKt(+iwt@SwZ#Y z1K3Z>bSEt!roEr8rydA`NJoVD>nPSV+2(05UE>4T005_GAOuI89vS#iG4B18N9tN{ z^Z@tNBTj+gCOB47*w+ z+2Hb~>!f2H1$Hq!D=_Sb+i%D|qnZ-1^bbIwX<}v&QHjdz0&e>kOOQ$(hHgzP5DjJz z0f>y6M3En>w55Wi4nf3bKUf4p>o0~xvY>6}4YBjHqH^B)8ba{Lja`ks{5OurR;$m< ZjQ=n8%sUGgc=rGR002ovPDHLkV1nUn!$<%C literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ic_ab_back_holo_dark.png b/actionbarsherlock/res/drawable-mdpi/abs__ic_ab_back_holo_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..df2d3d158e201f4b5bc8f478bfe194c819c762d1 GIT binary patch literal 466 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6n3BBRT^Rni_n+Ah2>S z4={E+nQaFWEGuwK2hw1@3^B*n9tLu5dAc};Xq+#-xYx_sQH13|{`71Pj-*6Uoi`#n zE(U8IKgsQz<^Rb4R70ym$22iPZttV^?_#_6n&0#=x|;ZH&dfx!jETDzs(0U>)g_uQmUhGGNWo+VotE}_5b3Zj`hnf_E}Q2 zkoV^c&!VIWreR+T-g@7!2<2C~cxLXYh02~hOPyXw&7V2OC7#SEE>Kd5q8W@Hc8e16}SQ(iDxmE@S#`ha8qiD#@ zPsvQH#I3=p$s!-9K@wy`aDG}zd16s2gJVj5QmTSyZen_BP-2>S z4={E+nQaFWEGuwK2hw1@3^B*n9tLvudAc};Xq?Zzc+iX4P{i%w`)y*!lC}nMxxP5m z`ipDd|3l#c1q-`17wzs7jap-@cWTC&8}(D4%&X3GaM#!SkY4?Tswdc+PM~^5?gXjDEJr|A(9^w&s1cyzt=Kg=58+)D;SHpB%sRSHFHUToUy>RV`*x3 zp=*`d7Z@F1xvAFw#q#fW_g_%cHx(CZDFFIJwZt`|BqgyV)hf9t6-Y4{85kPs8kp-E z7={=cTNxTy8JPmPRt5&f_Zu#wXvob^$xN%nt--0uA|I$h5@bVgep*R+Vo@rCV@iHf fs)A>3VtQ&&YGO)d;mK4RpdtoOS3j3^P6 literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ic_cab_done_holo_dark.png b/actionbarsherlock/res/drawable-mdpi/abs__ic_cab_done_holo_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..a17b6a78920848c37a67246a76749b4cc1425a15 GIT binary patch literal 566 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE0wix1Z>k4UOiAAEE)4(M`_JqL@;D1TB8!2v z2N=7Z%(epwmK8Xr18D^?ZvQoBE&~Ijou`Xqh{y4_R~-EgIfxwlm><>K$vu5h!wc4! z9iP>XtrZVs65@3e-rKIN%Hh(x{ewWxt1j(s|L*kJ zSoUnickXv5=i7?TNH`^EJfpg4#&4;Y0qR0+drTg2JXGfUq3}Rr;{P9f_n*&gD7KkW z&D4IqLivGGRq&kmAH6(eA0`F~7S8rex88HAVS=03cY~80?cpzkFa4S5A6;t}xJ7Q# z9-saRVPfVT##U33AAO3A+Ypl|_94?@cK)tT4*8AF;-^j1iVm!a-M-<=iX&Itr@TnW zJpXO;4EOj9!Ar}#BHVL6_dHGGELXBQqN>Q8)gj~`k@s=>rw|ur?|x;upO5s^{asBY zKb@S=&SWDRsQzHyR;N3i0@8Cfnf~0l`P3PA4VeH(Ut{H!I{}l<<aB zB5gMTgH*M|HKHUXu_VC#5QQ<|d}62BjvZR2H60 RwE-$(@O1TaS?83{1OW6u*u?+< literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ic_cab_done_holo_light.png b/actionbarsherlock/res/drawable-mdpi/abs__ic_cab_done_holo_light.png new file mode 100644 index 0000000000000000000000000000000000000000..b28b3b54f4c81d482f797f31936cbd4013c093b5 GIT binary patch literal 552 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE0wix1Z>k4UOiAAEE)4(M`_JqL@;D1TB8!2v z2N=7Z%(epwmK8Xr18D^?ZvQoBE&~Ijfv1aOh{y4_S9ba-JBqkHTrZXEaifjpNYW7o zp-Ubd&IgJo2<&v8$G35^;Tskk#t2~^NlC?&yDV(Ca&uB1b9CBkO)cqrw|D8TKToRF zI(8j)Hm_*m)V}Gu(AmZ?>+lr!|Ew$fc6F-Mb^2PC^>5kCb?-yw@xD*CTf6%^rv51n zu|M&RMY8TuK!x`HjjgjxbG!Ig&nSGQ(EnVUqiU&qoaH15q1mNr`vuRlFlL+adKX`+ zs(G(GZ+*gGNpURMpV)N-wqLW)~-JKU!1N^uTZarp(au zRVr*pp2gnEY&GXI)J=?c?L+7E14!w(i?Kf2&j6te3n$Zi&Cq1Pnyg64!{5l*E!$ ztK_0oAjM#0U}&goV4-VZ9%5)_Wng4wYz$;u85o58|F#)LLvDUbW?ChR22(3jb0C6f zurx;QVw%w1wevX{81fiqT9$oZHH(4a215zM2{s3I28IOo7eJ#J d>KPlRN5&o6d@ywr|9haR44$rjF6*2UngC}HDAND{ literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__ic_menu_share_holo_dark.png b/actionbarsherlock/res/drawable-mdpi/abs__ic_menu_share_holo_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..6bf21e307ed392bf00fe80b162a6ce9115e62c84 GIT binary patch literal 332 zcmV-S0ki&zP)h$s=>Sb2o({EW84x$2Sq@4Qvb1mj$j~;VIQBr2GX>%-APxay9!he7 z8W7h*gD?q**@0LXh%12j6cFzN;xHg)rA0Yl3bh0|IM)O5QD`2|BGz~0I$#-|1SL$5 zlJGbV2jtPKD8?58g7k0zp)`;V#9XwljI@z*K`Om-0V(CcdbDyt4~XM{*o)XuqGd@4 zDx{8=fp<=lEG6&%R0000-rS^s>8d@5ni2hppU0iV;YH8gwNa0%) z{Cz&}Jx|SbT`f+uL?986Pnf0|l@f5k0jz*^zeXXD13Pe$Xi*7R9^s5FmB7$P;6x!% z=kMH0V6IZ20v0@I38qpwTN6bU0_>(U;T<=GYX-1E8)QG}f-;!!681nE=wJ-aU=KPV z^-i_I3K%>@EawIsd5_!T)2R?x1}rE&N|%HcIQa;SqE5+gRv=Fy@M;YVKt`niqbhVk zpSlae%z=$G2Wp@TnqrmWnuKgf72^IDIDhdq{E7X5-;T%%62M`q*b}mOv3|8DyoG;R z;O#l^2#-VHDcnmy=|6xRPAT9SP9@+QP9YE&4z7Z?SGPkvc&h*a002ovPDHLkV1j;z BjTis` literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__list_activated_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__list_activated_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..3bf8e03623c94b68d31963ffe7e59c72c3dcc059 GIT binary patch literal 151 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqEX7WqAsj$Z!;#Vf4nJ zaCd?*qxs3xYk`86o-U3d5>t~CW>mH@a{g&g;s7!l1y4Byva-KaJLVIiI)OpBYodjS ofJx&-C1HsL_x|*Yp0_#7zz}{&aC*>dO_0?Lp00i_>zopr00f~Zw*UYD literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__list_divider_holo_dark.9.png b/actionbarsherlock/res/drawable-mdpi/abs__list_divider_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..986ab0b9746301f2dd9401829da09e00995621b3 GIT binary patch literal 78 zcmeAS@N?(olHy`uVBq!ia0vp^%plCc1|-8Yw(bW~qMj~}Asp9}6B-)+^BAxRtXRm= az`@Yw&#rLZUbzUUfWgz%&t;ucLK6T(%Mo}0 literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__list_divider_holo_light.9.png b/actionbarsherlock/res/drawable-mdpi/abs__list_divider_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..0279e17a123f8cbb3c7e3a9ce5c5af8e693b6977 GIT binary patch literal 76 zcmeAS@N?(olHy`uVBq!ia0vp^%plCc1|-8Yw(bW~!k#XUAsp9}6B-)+^LX%RmN2q0 Ycy4A9FVZ~13zTN?boFyt=akR{01+Y(GXMYp literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__list_focused_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__list_focused_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..7c0599e3a6fcce1d9b22e47bfdb63afb1d3d9c02 GIT binary patch literal 158 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqEX7WqAsj$Z!;#Vf4nJ zaCd?*qxs3xYk`6eo-U3d5>t~6?){p=$oZ!|i46oEul1LdSjZF4rt@IU_AhE`IYK8I wIB$ByaB<8!;4zVtCm{dd@wVRWcBu>u-xEd5&snyt0Gh?%>FVdQ&MBb@09FhvcK`qY literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__list_longpressed_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__list_longpressed_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..3bf8e03623c94b68d31963ffe7e59c72c3dcc059 GIT binary patch literal 151 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqEX7WqAsj$Z!;#Vf4nJ zaCd?*qxs3xYk`86o-U3d5>t~CW>mH@a{g&g;s7!l1y4Byva-KaJLVIiI)OpBYodjS ofJx&-C1HsL_x|*Yp0_#7zz}{&aC*>dO_0?Lp00i_>zopr00f~Zw*UYD literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__list_pressed_holo_dark.9.png b/actionbarsherlock/res/drawable-mdpi/abs__list_pressed_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..6e77525d2dbbc1673145d60d775602c85264330d GIT binary patch literal 158 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqEX7WqAsj$Z!;#Vf4nJ zaCd?*qxs3xYk`6eo-U3d5>t~6?){p=$oZ!|i46oEul1LdSlBa@C*nY4{!0_J9HA2p woHspUxHx7V@R-QS6OjM!cw6swyHo~-e~lvMp^1B@1I=RaboFyt=akR{0Ay(_r~m)} literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__list_pressed_holo_light.9.png b/actionbarsherlock/res/drawable-mdpi/abs__list_pressed_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..6e77525d2dbbc1673145d60d775602c85264330d GIT binary patch literal 158 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqEX7WqAsj$Z!;#Vf4nJ zaCd?*qxs3xYk`6eo-U3d5>t~6?){p=$oZ!|i46oEul1LdSlBa@C*nY4{!0_J9HA2p woHspUxHx7V@R-QS6OjM!cw6swyHo~-e~lvMp^1B@1I=RaboFyt=akR{0Ay(_r~m)} literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__list_selector_disabled_holo_dark.9.png b/actionbarsherlock/res/drawable-mdpi/abs__list_selector_disabled_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..92da2f0dd3711a2ceb843768cafd6b91a2807b43 GIT binary patch literal 172 zcmeAS@N?(olHy`uVBq!ia0vp^{6MVD!3HFkzrK_Oq*#ibJVQ8upoSx*1IXtr@Q5sC zVBqcqVMg#;uvX%d>fBtxy+SfFGJhTv9Z9>9n%%Tr7{oI+Q@DMao9hQt@O?p#8;eZd15IY| MboFyt=akR{068-?^#A|> literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__list_selector_disabled_holo_light.9.png b/actionbarsherlock/res/drawable-mdpi/abs__list_selector_disabled_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..42cb6463e4c28c6aeffa315c4fc869867dbb6b7c GIT binary patch literal 171 zcmeAS@N?(olHy`uVBq!ia0vp^{6MVD!3HFkzrK_Oq*#ibJVQ8upoSx*1IXtr@Q5sC zVBqcqVMg@oJyIHz9Y|%SiynA|kd)58s-{92FmHki*;@KxND!%;H%=F4ZU(n;yg$GVRgBd(s L{an^LB{Ts54)-;@ literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__menu_dropdown_panel_holo_dark.9.png b/actionbarsherlock/res/drawable-mdpi/abs__menu_dropdown_panel_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..460ec46eb0786706610e21ac9097de489cedfc33 GIT binary patch literal 651 zcmV;60(AX}P)!1&^00004b3#c}2nYxW zdZ_-Wf*5)VugS&t+23J}V*z%DOHb#W|`Z#l>;cJ*L_P;jGoKD8nX4Z`xH*Q>s zTvTl`b;%gqS1znaOc|u@tz3t7=|UK<9Hr>BJ|D1%4AOYzE>c>YASL1(e+Y^`_iG?7 z1UL~EK(|`0e*W#*UXt~C{TfUweyI5sSBLVgO?u)p&e9+4(C=i^T1GuQJ|j^LdEE0 zfZFjzm@Nd117_`XxKDqSoJXh_wG-}tW_yHE!!B|TSvyio<6k9eTgoG9O0aTdZJ81x zmbul8Z%fpkT#Wc{ND1L@No&VX#iPVF7hx`c0JdkE;3e2%ZBQYi%Oe#dj=&z+_I>|? zOJi$dCv)FoZJG3n&>Qp|;vSo*JOkf=A5uR{`;uV-QwsX>Ho!a31HXV*se5TxFFA=4 zo=3!%#5;D2+DO|6R;c8b^-B2j{s4XhZw!t1m&l3O!HmBwHn=!)kb6yF?kI1MVX*Vu z<6hz)DH{^YBPWDzO$|0isCW3@P>L98oO;C$E5=4jGEPjLS?XZ=13IvJLaC?O;nLn? z=e?6_T^b`&$N3sK+o1N3^-DyB&=+_N>geY)_rHdJwBJ%s{^4(_WBZ5MLQM53U4RfX laXn(LVYMe-Njr@(d;;;gyUim^Wn%yU002ovPDHLkV1m`SB-{W1 literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__menu_dropdown_panel_holo_light.9.png b/actionbarsherlock/res/drawable-mdpi/abs__menu_dropdown_panel_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..e84adf2d41604323cdad8b15e7034b6137e02425 GIT binary patch literal 720 zcmV;>0x$iEP)!1&^00004b3#c}2nYxW zd09!jyup9SJyH%;E_KZI5Ed^B*iNJmRSj zBG=jNc2B+cMg+dzb=~X>SwfDye{PH^oqQ4$1^~*55|NVv2=ckIR8XoEqC|oOgc2g; zEPA&fNb-^8#Mr1#v(VQn5UdVR@QAWs>EP1 zTHM9Zaim5tPqqk+y4R~ii**RWgPIHWkr2Q-rv~$oD_;OFg!*vQOJ?oR%RhjSvm}}N zU}~@)A@q_TOphE%y@J$^Y;2GXG*T-_?U?-%UNYKi5n>WcgjmBq)+~pV5UB*Fc4!_E zr<_OV^tE=(@|l_%K9#lBPBbeU!!Q72CYl{ozqWE(s>}kg*Xy-fB`%jskbX;(+jyxw zA`k(lb8|^3?6_RfL_?Is~gyeh`O%xX?U(f4nJ zaCd?*qxs3xYk`99o-U3d5>wYsbmTgqz{8?`Dg4L(`abqnuZs;wTVv8ZBg|GX^f4xE z5ck=nld$UVv7H|oR+P30etdkz&;0SSW2^3}yn7y4rozh{Dy3k((DE(NNCr<=KbLh* G2~7afj5MhL literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__progress_bg_holo_light.9.png b/actionbarsherlock/res/drawable-mdpi/abs__progress_bg_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..4bb22f0e10e621ef31f16100b3f682a09565c65d GIT binary patch literal 159 zcmeAS@N?(olHy`uVBq!ia0vp^Y(Ol;0U|59*B=E^EX7WqAsj$Z!;#Vf4nJ zaCd?*qxs3xYk`7}o-U3d5>u0Z{Qqyy%*=eaUL!352pYN+StcB)SJP>#V9b+U;=REk xGyYWXA=VWyWA+H$a1!q?zNqxd-sOcoGlO8KcyMa*40E7i44$rjF6*2UngAF=Ek}@P)jR6%Q#K@^;MZ+DwSq^+h% zP_!xtf_Ukr^ybl{hx{k~3HlSfd-tNJf;W#6l*URbZIYUN$+x@DLlQ_#DhP=KbJ@4d z?3>3vm>B@rlxxLQd;P-m9-THgzpAxGG!1yW5D)4ffO-cU4S%t?r)YdGWOO4jhM%lT z$gSE=x_Gve0j_HeH8J^wOM08!a}xvEw9Ce~Da{Pz+J>k}@P)jR6%Q#K@^;MZ+DwSq^+h% zP_!xtf_Ukr^ybl{hx{k~3HlSfd-tNJf;W#6l*URbZIYUN$+x@DLlQ_#DhP=KbJ@4d z?3>3vm>B@rlxxLQd;P-m9-THgzpAxGG!1yW5D)4ffO-cU4S%t?r)YdGWOO4jhM%lT z$gSE=x_Gve0j_HeH8J^wOM08!a}xvEw9Ce~Da{Pz+J>4nJ zaCd?*qxs3xYk`73o-U3d5>u0Z{Qqyy%*=eaUL!352pYN+StcB)SJP>#V9b+U;=RED z2qf|=A9d?gTyt;ZSzN%FWhK6zW!r_Lk7KrU{Nfk4nJ zaCd?*qxs3xYk`73o-U3d5>u0Z{Qqyy%*=eaUL!352pYN+StcB)SJP>#V9b+U;=RED z2qf|=A9d?gTyt;ZSzN%FWhK6zW!r_Lk7KrU{Nfk&05-QPl|NEJxmot~Y-O?6i zSoE4VV50(~VFweNuSbvJvDU(em!@_Gy7>C|bVSGQC`nC9V$w5l5%vk()99rs+U}Ie z#gw!%)oQMv{^i7d*IlE3+&<@%p0;w&$@ypMpUwGhdH?7B;(g3_F4o8CEW7NhbVSM} zqSCB_!=qSev5fPtyGqA?asRjFZK+%zRmuM+<~%bCV-%Sz^PrNaaE@g9foeX-u+5!sBTi~HIW*n>)Nj7ol{rZ9-4nMT zoXaYtmP_*AdKAZAlk-GvO?pRyl>Mh8`+Nc$HY$`qPPFQpUN|M($@0weFZ=q>-Z|;k zASrkFqq&&t!{{3mN^Z2R{c=#?a3WtQ7weUk>iG|Zq$QT}pSIkU{^CTFT;9KIrmSnq zpS&#=uRnCsOK0id8}?`PEg3d8`7hvXW$egc*J6#mVt#e9_pb9<_ciuE6F6vP_s!9j z(P7T51!|6-rEWn-Z!t5pRZaT>G0pp*?o69U6_j*jr;%AU466Xxt@KxFWQ#C`^3eSLB zzg~IIvuD^d>#3#GLD3I7lf(noYc&h)3hc9G_+WKhHsZ8LoPy9%C4Uce+&;>2@bsHn&Pv7xpmx^;r<{ zyLsxJv!X1=e=@5Da9q$kdPVo-a@|{nyH;q}t$!wG=kQ6b{@GG-@nhR69M(itUsa0= zOaD6e(QK|M^YvG#-Ci16Wb}90IdQSr=Hj%|Go@_TnpsY6``Z0AtH!%8u6<>P+?BM| zqEoJFmfFoDzId)kH^*J-T zifmnxrK6#lyVy%(-Id^*OWp5Z{O|Cesp8<@8Fi79bbtkmYKdz^NlIc#s#S7PDv)9@ zGB7mMHL%n*v!UK%rs{7HZyAaH@aKEfTQc z(CR%$S?96abl05G-F(|Si_LUV;?$6kux)>%v=)2DUfpwT%PQ8|6^&m$u}%%W*3rdf zl`oQNvN&>WhAa0khnps!G6EK_TCpZ6=uP_{^)H>%wyt5X^53?*IxN|0o#E77R`PdD zm%Wa|cNB9$z_AP5mH=4J^LP6!o!<(RyDvF+#7%B*F3D>^@) zG3au=^KjWsn^#jyew;NrnOPLU6Z$MNVeT*c)9TLijM8T&&Ec75wYjFybd#W68%QTW}f06Axoa$IU9~?Nqc5iru{em z%^e?{s+j1J=mX5HswJ)wB`Jv|saDBFsX&Us$iUE0*T7QO&@#l()XLb*%EUs~z}(8f zfYD-4D2j&M{FKbJO57R>QdwRCHAsSN2+mI{DNig)WpGT%PfAtr%uP&B4N6T+sVqF1 RY6Dcn;OXk;vd$@?2>^cl_{IPL literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__spinner_ab_default_holo_dark.9.png b/actionbarsherlock/res/drawable-mdpi/abs__spinner_ab_default_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..29aff4d43f71a025f464587ead52aff2ecae6a58 GIT binary patch literal 254 zcmeAS@N?(olHy`uVBq!ia0vp^59s(?1)eUBAs(G?r*GssWFX)$e`(35Y8e@;SI4XCdOETn3puLX+U@Np z`{}{9$F@!!Tb4}GnD8m&^|D{1rP|_tuSV&+Z=MCoD&l+{? zpGeMToA<;$LF?@fW~rUl3#RU765DB+Fm*PQ+)k?pQ&%&Ye!A+gR)$OeeXHaR#_cxq xcQACD7BHRDw&oXmu9s(?g`O^sAs(G?r*GssWFX)$e`(35d_EZ~i&w|H<&_`ZD(+MedV5zj zu-#_I+lqbxCf!wDY`(!qq|2YPZ`s2sD|KqW({JG~4*WL+Cpx;A`7$XPF&b}JE9dda zdDh0P2cC5-%kKDDBus2)4y)97FmX3?+)izQiL;plcWMSG#q&-%rTF<%+zn>y2h*Mj yizj?!^E*(P`ureMOz-ZiFXWg1cX%y7!FpSm=AYI1UI{?QGI+ZBxvX9s(?*`6+rAs(G?r#o^TG7xZ`zf?Wo$i4qI|8=SuS_>z)W_YPj?%Q>u zIp@ANM{x}Zqe@#*i-Jc_;!9;KcT)!P=e8Z65pgErb%iKSkCNb@A?yTt$n@r z2c`IHF%KKu<@hR|E_CSLV|hUMOZy3b87rAYm)KaVUb9s(?*`6+rAs(G?r#o^TG7xZ`zf?Wo$i2t+|9e$2v=&Zo&G1s6+_&pQ zbIyHljz-QjH&*S{-J;(gu&3N>@$LMyenNedpai4+B)&;SOq0|eu$bkReVyxuhm-Z9>GFCF_99MaBsxVXw=u8GrS3j3^P6KmrqN>Fc^oQq;b>Mt0(a$ z!tgX@A7RK4{kGy^A3#w21maN-UfpV|U0)B)Mu)Zk(%$xiP)OBD#retJ&sicWsshEL!WHUI0Z}S=i2Rqw=-{<_oUlU4$I1(Vt^KG}@Sd2k4!kUV zp9d;G14UN$xn@Z2Tv!X1WCiPlZi?T5Wo`s>dMMw4?2=HB&MqLoAdzh3Gg0e200000 LNkvXXu0mjf#CNP@ literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__spinner_ab_focused_holo_light.9.png b/actionbarsherlock/res/drawable-mdpi/abs__spinner_ab_focused_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..6536ee63329bb47bec2bf2384aa494923cc2773a GIT binary patch literal 424 zcmV;Z0ayNsP)Km%mHHKmbPH_0G1~QE(|Z z3L*$mIy*=P@!u2&!BHHFf;fuc0uio1*2@YRBct9{0AyU2}iGVkcWw7UUPW(q{Hz&m;6;CQrhm;h30w)z2(`W_Vv zws(S3@Pah`KM=_o2%_3&n+}O86bq(Ag>`_N^4m7drC>+{^&N;72|01L0Qm!AONf3s S@;8qF0000Km%VDkFce0=d)+vOWKIG} zhpvGvb*AhYN}o4m@H1o!d4o*tRBGZMkUCTWmkL{wB~SUlAntIEgw4Gc(!&*+NcHqe zdbonr;tjwaz@#r!B?pk5-j_#K1)p#z)*b-3QShBfQxGf+4==MNa*z{HXhG0C1P_4~ zh;-k(7eP#tUz1`!Wij$Dh)MD;xve&Fv5GXEp_kweUysY@i1cm8S?~wm($ky-rf?^L z4cuB_3%3%uz>Nj2a3et6#z@uGqTe`wK1>2-pyo{<@B~f=x)vOqS_S8F z{BbGcPm`Srko*>0TM51dS0?bbgq{a9*ucpHu=A!M^DM~~^Y@aViMI>L4{MrZFUa%^ Q4*&oF07*qoM6N<$f+pdR_W%F@ literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__spinner_ab_pressed_holo_light.9.png b/actionbarsherlock/res/drawable-mdpi/abs__spinner_ab_pressed_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..6de0ba8841d25f20f12e14002ecc4c9ec6a7b2f8 GIT binary patch literal 370 zcmV-&0ge8NP)Kmp@CxKpa3{epU;uAYD{w zoy1-2XXsG+d5c4J(@pInLg`pK=_I6J(k2d`5V?BE{Yj@j2pl)OcgK;0qd#7akgCKEJ@PeExDlrpx^Tf8?8gJ#K-Da<_nm z+&*9_w+lGPs|OtA)dC)JfQDKAb-?t#>nbk~ygr<>n4NOeOiNA8R)UE3F)|0PZr-`P z{wS3Lh~%_Rw1t=h$DO2-+|>0Ilo0LghZEP}j*Edw;7F{TKbM3p1iOHI0}cLp61dt? QIsgCw07*qoM6N<$f;wQ9<^TWy literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__tab_selected_focused_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__tab_selected_focused_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..c9972e74bb4fc7416960e238afd47b1ac363e316 GIT binary patch literal 148 zcmeAS@N?(olHy`uVBq!ia0vp^EI`b~!3HEJ|NhSh5-4`^4B-HR8jh3>AfL0qBeIx* zfx8og8O=|gUJDd7^K@|x;h4Gh+(zC520Y9MizoD2>~^~(JZa^V pUoEkkaeSh9w)TUlKa6vZ+qJ0**((%Vy8umK@O1TaS?83{1OR&wE2RJc literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__tab_selected_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__tab_selected_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..587337caf74f9ba3d32ba1c7cc8fb8b0b5ba245b GIT binary patch literal 151 zcmeAS@N?(olHy`uVBq!ia0vp^EI`b~!3HEJ|NhSh5-4`^4B-HR8jh3>AfL0qBeIx* zfx8og8O=|gUJDeo^mK6y;h4Gh+(zC53JlB#xw8$}k`45e4cLk;e3y7!_%!uv(Z^d6 t0#9x~Qa^f(Id{#0H&;LIP<)f9-+fKc+F|3Yl|VxnJYD@<);T3K0RZ_tFJ}M% literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-mdpi/abs__tab_selected_pressed_holo.9.png b/actionbarsherlock/res/drawable-mdpi/abs__tab_selected_pressed_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..155c4fc753ed43185b31df3bea2af1ea5b3e7482 GIT binary patch literal 150 zcmeAS@N?(olHy`uVBq!ia0vp^EI`b~!3HEJ|NhSh5-4`^4B-HR8jh3>AfL0qBeIx* zfx8og8O=|gUJDeo@N{tu;h33haPQZY#>U2n_RP$O>mRT6my}r88lS< uMnfl1c4A|rBX^f%!~&s(1*$LFm>5oL2|PB@cz*+E5QC?ypUXO@geCw>u`ROz literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-v11/abs__progress_medium_holo.xml b/actionbarsherlock/res/drawable-v11/abs__progress_medium_holo.xml new file mode 100644 index 000000000..6bcbdb83f --- /dev/null +++ b/actionbarsherlock/res/drawable-v11/abs__progress_medium_holo.xml @@ -0,0 +1,34 @@ + + + + + + + + + + diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ab_bottom_solid_dark_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__ab_bottom_solid_dark_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..575334699663b221b5a2b3251572a7c7a23ddb4a GIT binary patch literal 165 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nET98VX=kc@k8Z|>$jV8FrZ@U7ta z-*T0WQ@><>I%v71J%hiqt0P@2{q!E)%~9Ermd_VC*s;IdoBnhS>rHk6>|lcSgpVF9 tjEp}SQ%vGx1w)$%c)I$ztaD0e0sua~Gttc^?peW`&R>iA3bc>G)78&qol`;+04`QPF8}}l literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ab_bottom_solid_light_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__ab_bottom_solid_light_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..8155fe840532e1d0fc25450729892ea73c4e007a GIT binary patch literal 166 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nETTu&Frkc@k8Z|>$jV8FrZ@J;?q zbcL8uwC8*^`8m#29p5Ib=%`p$wC&7oqt#odO)b{rdQv>$UUk^Hs0pFVdQ&MBb@0G6aYR{#J2 literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ab_bottom_transparent_light_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__ab_bottom_transparent_light_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..fa4d76af93de31de153c6a7d41c05496bb14d2c0 GIT binary patch literal 152 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nETcuyC{kc@k8Z*AmdP~c#3C@cDZ z^MXtGfey<_%m2nWx~HUtq@RtOD!V+x#J|ag^QD{sZZM%<(R`m!o+Hzd-iC%RO>bP0l+XkKAqp+G literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ab_share_pack_holo_dark.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__ab_share_pack_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..55099d49db309d03035101e55e64396b62af3054 GIT binary patch literal 2875 zcmV-B3&iw^P)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0001HNkl)K_>U2H>f)F385FtW@2uXtEe@nD6oEa_v00960 Z0|2By^PX-KG@Sqd002ovPDHLkV1g_UPeK3y literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ab_share_pack_holo_light.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__ab_share_pack_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..3c4701fc21a7b70310c0fb65f82c96406bf676c9 GIT binary patch literal 2869 zcmV-53(E9~P)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0001BNklg>n)kmH7JfR>L=7gsVyOrjh?O!kd687gq;GddYfQoE z;^b_j0~Z<2SccpV5FkK+00HtJq?RWj0>Wbj0t5&UAQ6yPz9lR;$^ZZW|NjF3iYJRN Tx*zQx00000NkvXXu0mjfH|R+l literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ab_solid_dark_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__ab_solid_dark_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..6622cbad34409b2e09f69e305455482ee107baa6 GIT binary patch literal 163 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nETEKe85kc@k8FK-lVFc4sN{QB_B z&fog}EEk$2&*T)$|Ch61%h`96?xa8O-xitu^~t0=vn)PNZ(|U lO#br3!H&B!tiEU`L+e4N?emv^?*rP(;OXk;vd$@?2>`X4Gjad` literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ab_solid_light_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__ab_solid_light_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..c4272978338a232aa445ed5190abab61afcedb16 GIT binary patch literal 163 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nETEKe85kc@k8FK^^+Fc4rl_yt@$W?82D^ReIqPjo#d{bLmpkiN+x lnf&F6gB^EeSbfn>hW*nwPPt#_849$O!PC{xWt~$(697sdG9dr} literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ab_solid_shadow_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__ab_solid_shadow_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..d0df29d8b3fef9f71cda9b7a0975c68dcfb05685 GIT binary patch literal 290 zcmV+-0p0$IP)(^RAa&-b-qmfdL= zKY^DZ_=R_1v^+>Y{!mW=MF!v|2#Q>Q>z_&4i6T94j-Y4q`P>I~g?cE`S~^QhBCU5$ z-8a`dJ38hrt)qwm8XJx0+%VAuW=z7Jg@`1pBAUrf#Ef=wZl|UqH7RO)u1OwK(@xK~ zuV&5*5lN0GQV~igR!o15*n1TfDTP6ilQ72>QBJOyK^2jQYHlAzlrUMuFCtAA$s$=K oi)4{qME3aCu~lSF#Q4a(0o}otDK%H_Q2+n{07*qoM6N<$f*T@rc>n+a literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ab_stacked_solid_dark_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__ab_stacked_solid_dark_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..a0d9c1b957ea4a6ce62abd120668610d0cb2bd96 GIT binary patch literal 163 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nETEKe85kc@k8FK^^+Fc4rlxca~( z?t=fRa*SINS}wBuewp3mefy2x$=b4i8MC*B`RkorJG1!P69>HDUX#kpcm>9d6MZKb ky7}`x**qcrtNL{AY0h>p*ZiBQ0JN3C)78&qol`;+0O3wK)&Kwi literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ab_stacked_solid_light_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__ab_stacked_solid_light_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..d36f99fecf223779432fb843b823c04d739f05cb GIT binary patch literal 163 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nETEKe85kc@k8FK-lVFc4sN{Ca;{ zvU;8e%Y`P%GdTtG|K%*$a`xS%JL%8+w?$@ueKP6JEX#C%J{El7iLS?_f2=|R(l=Qo klfOK1u;Z=_t1sHgP`H~Vw5GX>6KE@gr>mdKI;Vst03NU~l>h($ literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ab_stacked_transparent_dark_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__ab_stacked_transparent_dark_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..5ad475dc3f478734be31bc5763ff494e5f120914 GIT binary patch literal 158 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nETR8JSjkc@k8Z!P3yFyvu&IDfHo z*MFzV3!h#&I<8{wJG6*7%`^0A*`zgvpO3}4Jy+2bzzZhGPxw0F1DlG16;n~mnRAu= eo1*Vq{$#i=98+;OAz%&ALIzJ)KbLh*2~7aXVK40f literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ab_stacked_transparent_light_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__ab_stacked_transparent_light_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..6ade5eeb37d8388813cee512f8adaad0f6c15397 GIT binary patch literal 152 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nETcuyC{kc@k8FE8XhU?9M9Fk3-& z>Hkf73eN%?4n{M7dy#!$d2ZSCCv)eTUt5@6!ODmi{A7$QW>Hb7V|gN6#Q)yLqkTHN Y-hRf#&+ODnfL1Yhy85}Sb4q9e0PNo==Kufz literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ab_transparent_dark_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__ab_transparent_dark_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..719b9234df6fefc32c628a212141681df3414d85 GIT binary patch literal 171 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nETB2O2`kc@k8Z(Za)puoZEAojv! z?q20mzFS+?F-&~oGw)ovvN+_p>pJvXn6S<7W@Fox#)9&t;ucLK6T;ku_WZ literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ab_transparent_light_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__ab_transparent_light_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..6da264db26b5debc433e570e454f7ad596d3609c GIT binary patch literal 160 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nETbWaz@kc@k8Z*Aml2;gwNxP9_w z>q*543$-17oYd6QwPclDxvFIP6Y06uZ3-`2R5T~}Ha6e^YubHkRDB$o9=Xj@xc>Lb i$;LIUf5PjFDj6>?G+3v-_OK(+N(N6?KbLh*2~7a3Fg*4E literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_default_holo_dark.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_default_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..7ef2db75e273c3a4fa34a867d43714d47b67dfd9 GIT binary patch literal 109 zcmeAS@N?(olHy`uVBq!ia0vp^tUzqR!3HEvyN#v+DHBf@#}JFt$r%|L2@FmD6{OlE zCs-P=E^ay;FECBu-~a#X*$!!Fy;QT1l2!H>nDyu1;UEQuS2t(=%(&d{0o2dn>FVdQ I&MBb@0Ph$gIRF3v literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_default_holo_light.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_default_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..2283b4c01f31c24c241101989a028a28e662ff2d GIT binary patch literal 108 zcmeAS@N?(olHy`uVBq!ia0vp^tUzqR!3HEvyN#v+DPvC;#}JFt$r%|L2@FmD6{OlE zCs-P=E^ay;FECA@!GWvmzw+t@{SPuqdTbmsKKbP0l+XkKVJ9JJ literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_focused_holo_light.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_focused_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..3c909b51306d684dc9fc4deb674ab1e1feb7004e GIT binary patch literal 113 zcmeAS@N?(olHy`uVBq!ia0vp^tUzqR!3HEvyN#xSIG!$!Ar_~TGcqy~7@GboNVOeo z`FL&lz5>PtO@Rj=>T@VLG&w|ZbqQ*{RI`whRrVK{_2=K=E+vL!&S{*=@1z8QW-xfV L`njxgN@xNAaNr>U literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_pressed_holo_dark.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_pressed_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..131d1030c9d5b447ef62fc8e336d9d3950ff7519 GIT binary patch literal 115 zcmeAS@N?(olHy`uVBq!ia0vp^tUzqR!3HEvyN#v+DJxGG#}JFt$r%|L2@FmD6{Ok@ zwtT#{-1s4r1MA|Z!|?(x4J`lv|6k8`NJHzTnuV0CvcJHrKmQJQDKT8Re5&^Sxg#LM O7(8A5T-G@yGywoD=q9NE literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_pressed_holo_light.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__btn_cab_done_pressed_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..3e7dcdfdbaf66d51a90633e6f601bfe71b0c5069 GIT binary patch literal 113 zcmeAS@N?(olHy`uVBq!ia0vp^tUzqR!3HEvyN#xSIG!$!Ar_~TGcqy~7@GboNVOeo z`FL%)@k1sD*2PVS;{{wASQ@v8h$x3#@+~m2a+{}M^7C)Is4GMKie-X3Pa7xz&0z3! L^>bP0l+XkKapWP} literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__cab_background_bottom_holo_dark.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__cab_background_bottom_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..0bd09806f5c85ad3a33ec80c2a526e9dba34d1f3 GIT binary patch literal 166 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nETTu&Frkc@k8uN>rTFyLXm;P>R{ z?#-o|?nQl9Ua&YVWQl+9{Kh9CkJo#*NAA>4+xPwD`<&mEu1}vZI664|W68WNxRjX* q7uY2C$wZnF2qKv(-xu6mlE@I5@4DcHNa}B(#SEUVelF{r5}E+w(lnv~ literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__cab_background_bottom_holo_light.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__cab_background_bottom_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..43ed26d4784aa508b93551bdb0359b959bd2c91b GIT binary patch literal 161 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nET3{Mxwkc@k8uUzCjV8Fq8;LR1* z*j37dP53cYgnN@8iE~W|ez(m3TTj;06C0 vR9@;$usQD^o~Q2-Eg&#Ke!|DE+S9qyz8u@<_Da1C=l}*!S3j3^P6YLYC-!V(AVEFG+v!>way|q9)89ZJ6T-G@yGywpFG&bP? literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__dialog_full_holo_dark.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__dialog_full_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..f4970ad1c3278235157ac72f71fc98f159fdc439 GIT binary patch literal 2159 zcmV-#2$1)QP)7pj*K04R=GS>IExgb+dqA%qY@2qDDdSi?}MdX75WMJ|ri_~yampZf~b zyDwJPzURp0aERFLx!K0Z6`{S(+b^7Rq0fZm(kDLm@P!|`&m~8kF)y`OQ+*6SLgj(n*c6WFZ`T<6tC6A%w8 z+L+Kg_>sWYRhaz=AtQLA^@LuUvKr4zS(=h&ATdHMd1uOv+V9M9YYe+zz%fKlM3B!~ zyq*EP{ZyC9dltDoQc<8ZrM^eE_Hte#g^dKR2>{;+o?xX#_XJ<6fcSW3 z(2+n3e1qrFpfvl1x~?#Fy4|E$M6lRgKuT?d8dD>b&VB465lv_ms575+OWy%#u@k+N zI%?Q+K~hGrT_7#|a=gF%@ZrOc@87@w`1bAFU(2$bW3Gd+|4`xmgT=9~$+>Rd`_AEe z?tAPdzh~^4zVA1WkB@)c-QE59<;$19v5OvFA}vv41E1cCHa5&@4N;9-`R?7jpWeKA z^Yg>QL%m+FvDt*4cRX_bt0?zBkB(K>DX%%#=N+5R(_-8y- zVb>j!?$Wbc5y%%}IfCs9*+@_USOKV3tJQDczI|KW-rgqvI6{s^UDwxjUH<~$ckEhw z$wzfwA%@V6dv=Zxn=8;sa(#b)ziOIh-@k{Dz1VCvD9chBW?(0HZ$3-*gQG?|lNRhy zsce!AuP~V46@dEg?(QVrAwo2L-=l3?V9=qSyONQk&Kv_~&Lf1nMm8E$0BV|mEX9~d zNP}Lf5}1xu21h4T$+9&-HQuut%PRmY8i6duXoOerBY}OxLGlJ5BU$zc%^yh8OvsW{ z7(^}+!OmYLNsSuWi7|-^5)oDyq5>gHA{u-eOKk`#f#=$OmM4_(@m{kC%_W5DAmmhR z=d>`52C;YCwuB;r{%j}Ebe_P7K+b^`h8A8*tydWpwYtuV2y(IKDEl%UBLZ0(i3V1m zfUn~Tp;05RlF3Ax+6Y;a8pF(Tjoo`iqE#Ca+!sAl5kbmO&cKL3&H*nkK%{gluy`-t zg(lV{G7z#PI)C*NX293=me{C~cPz9KvLxQ9W=NZ^Ugspsp|?>vp+=TQM}wGdXLXG{ zVi`Ci0$G}v=(F^hV}w+)Oe2t`iJ2g)`#yKX$5zN3ft&-L4rl3d-=WWF22RL{IarUJ z10V#?jlh->hk8-+(B={{f_KC0$_Y6UbF}H| z)iXk95=}<}9Szz&zBnPrq{TEU=*R&0y55rN8c7*TmhI~1gq#|$ON79_OO5CMyD7gV z9}@irgLxzpwBV#1S)NvH5*4HjnIZdKqfiE}-PZx=`o6zC@DCwmFGlT6G>P~~(uABG zK}Q3f7d(yIx@nqEUDtg*;O`-1HeJ_!ZJOp2fHih{)cJyq3PN^{5b9^?iHmLcxw*Od zt7)3gecv~S{b_{c(f57RG|lImo14Ed?FxBAs6Zqt*x!B;W5{pK*JF7#9(y&G-;L+K zAIl#wtZ4Xp+<&dElXaOZRbPeOuW5VVgIpFOP7$z(T3Yv~vHW)|AI5VJTZ64^6BEBSg#y zGM}I)%~}j17KiFDEnOcuUt#E@>0HCEcF3*~0j6Ce`xZm1O5Ih`IeuTN+ty1RWW4eh`~TOU@&BM)3MkQgMM@bdYm8B8c#1 z#@ViWE78D40!D<(#Tx`hXJ-KSDrqoae31hLi8 z$z>DjeP}^jBk1AK*j$2rhW(rzJ{2JYJMmiAitr^tE-^SXloO=ZTOgN*_a2ZHvyBd7 z1l@JghOv{s(P7lwc?A9CfSo}^z#H{B))n$biD&`>gkS9e;$0Z5~J8tXRDNuF002ovPDHLkV1mNB_TK;i literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__dialog_full_holo_light.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__dialog_full_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..172fc3b5e3caf3357e706be2a1f0d91f357c8e5f GIT binary patch literal 2302 zcmV2ok^m97efLZMJ76bgmHN3TVPgynL1iZF^o zv0AMLkI|bD5@Z+S7;_RWD$X2Q#-Gi>; z=tN2`078B~PH0>efZ`B@1i||(&~g>qMGRTwTrQXXbnj39hPAQB*)bIg_=HbA_WGzO zR;yL=j9HSDjSEl*;KYv!A@o|O_=;IUA}l9+ObGitX|Dzg#M7mV*iktr2nZlVbl%^^ zH53Ym36TIhGR!|u7{3PC~!L=Y2z z32ZT8B;zY)i(nCqF!62X25hwu6@!!-aVKznAwf{$S4ay%(<6lhDJ|l}=KVE%xD;tO zjxokGV%Vil6ww-?fi&aiwtz1TI;KLw!36;9iSC?$w}w5ZTIo^H5hBZ^Apum+pFjWp*|TRqUSD7TX^iIhX;RaeQQ zE(9uq^MWzvYwRam(2Co38gn;jAmP?U& z&MGvUhjxmcRMYbSg3kR zZt4g}LPgLEq&hYm(J$si0u;4;IwvxY6?fp6l#|X8fH;pmq-q5ISi1H|(Ge;Lg>w@fkyi)P5d7;2~0$MDQ@!DE$`cg61AQt41xJiqTo9Dlsio7bTA}sD9BZvH#!%wZ zmJ%ND@1^DnZ%X(Ld?$$A6k0J~NE59ixD&!XX{j@~=b>7mwKZvxCyp*B)cAo?C*Y0% z?1kZeY?X^e-9W)XxdpU^5OahW`IAUpYa}@W?W5#&t4q8l2swcYLBS!VH7P;dBP@_? zQAk2?GdMjs_n0oBI`TV#(4X2ifxe2hDg*@upKxQ&K(mtAk|`HJPz)_1HaAZ&&GHf7 zsz6IO?f{EsSe^=LZJ-DtRGZRNi3)(P24xANDG)6Gj(#dNGOP_9D0K*+?F8HR`Nj#&1(CYoj<+oYNw{1t4Y0L^ri-RBp`1VD6hPVuR0IkNiMUb`EeV02O|F6c zauGd$;Lv5&C{!~b&}Udb7lOKhLPE$D=wt2>b>Q`^nt&r(EH@_=La)06a5Fwnfw+Sp z&{C)%=8X_pC077s0o1}imRwSiS1dcYq8ac~BtElCsZ+`Ul=zAmLOFfPAwvBY@Kn$$ zk{zOiq+$R>LAX{rQ>;#)$VHAb@IJ99w*HlMq6mNtA~I*7`@~Y7+@e^8prDZQ`Pk}@ zSYXq1DD{)3Sw!SFBRAo~AvKngUU3Lg#cu0$<^+@bU0;P_H1st~XDv}F6a(QX9$Rbi YKbh+rFQXz7g8%>k07*qoM6N<$g2q=E^8f$< literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ic_ab_back_holo_dark.png b/actionbarsherlock/res/drawable-xhdpi/abs__ic_ab_back_holo_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..8ded62fb7b6a27a86f7b532c9a2b5a4ae999d34c GIT binary patch literal 741 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE0wix1Z>k4UOiAAEE)4(M`_JqL@;D1TB8!2v z2N=7Z%(epwmK8Xr18D^?ZvQoBE&~JOTTd6q5Rc^#N8xy%NgI}`eR{7o3SVw~oLF?DlhO#(rS&-V`^Q!s%)gPgzJD$(6 zlPX(2b^RHIj&o60rR$>g!|G>TRxtl*e|^4a{T&6ax|r;1#_KA};b_owfAXfrk8RFR$o&QDy{Vn>#x#sulW#~7Jq)- z)TH!~FS$Xsf0AE4joN$h`JQ|K8Rwjx@86b-rgDVb@NxHUL6S>yvXNP=t#&QB{TPb^Ah ka7@WhN>%X8O-xS>N=;0uEIgTN160J|>FVdQ&MBb@0GkggF#rGn literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ic_ab_back_holo_light.png b/actionbarsherlock/res/drawable-xhdpi/abs__ic_ab_back_holo_light.png new file mode 100644 index 0000000000000000000000000000000000000000..517e9f72d0c8d28a22360ad5d73476c25fd4db33 GIT binary patch literal 661 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE0wix1Z>k4UOiAAEE)4(M`_JqL@;D1TB8!2v z2N=7Z%(epwmK8Xr18D^?ZvQoBE&~JOTu&Fr5Rcj%_$5Ae=jmr`i z3DvOQxBn=~BCIDR#iS^(^w0Zu6&JUPm!vIx7~`u}yzledo5s8M7#uS86ZssvI8sdD z&xg3?2M7HpA7}46mr}+fqP5gidGgVwQ1_}WN$aob&9(OVStj}6Xj_!ShugM~J~IZM zU$@KD($sJ1b4JGMs?Xp43SH*aH+p$-+40a@k*+<>G~DD-|-{tS&vG^x*%GGq=j0Y+3zJN#Vil?OA~@ zukBM`R53;FYi;h*X6Nv`Uq9z3iuI~5j`7&H`BAcUqjcZh^7x-d8^2$_pe40Fq;EPa z%hqE7x*0h;3a++#0KFc4?e_Zv*^k$mEo1DpzWsL9`(v*67M^+IpR-MVa>nHwC6*2c zw&pTkoOQ_aoMO7bofkh1@}JI}ZKA~9;BBq7`S!))DS4@K0yY}FSDK>kZ?)HK*JGG& z7n!~MQ}4z!!HZux9M^8s)pB{g?A$cwGrvCg`RlIwI(LVEXW4OK`|IMz?e(5Emfz@% z$^^!kYKdz^NlIc#s#S7PDv)9@GB7mMH89sTFbpv?wlXxZGBO2ntqcr|?>AgV(U6;; zl9^VCTZ2=RMLtl2B*=!~{Irtt#G+IN$CUh}R0Yr6#Prml)Wnp^!jq{sKt&9mu6{1- HoD!MOjfK$EgnR$;T z=N`Kp(hSrM@CU%evd=bf=-4w^bQmnuhmUH-jd<6WZ; zHl4_>Rk2U@t}L_t|AiwlQ891B3C|YS1B^O3M@oxo5*z)LB91b?+QOQX_r0yH)YX2= zvK_aW4}ZVF|MIp0)1X?{@CS{e_APBtKk;H~nV$PVB{N8HV+L1tOj6 z``KDz%d4l`HAyHPxAByb%b6xG^S8m<-YfXS7v>b+zlZNGcwheZcvv-P0dQ7=MviH9v^t)=yc559VF`j43j z_pMt2oAX|`goy_Fm~UMa9d%t_^^2qU)cXl;U0e%IRZSM> z>7Ksk_VioOmKv*1mN|c~ELg&~mMikt+LpAdYoES)QG3#uo404uV`0ytJ&!XS^rKz< zU6j9{ob*(;{k73gyQmwdmG2d+82l2_J(5-Z=Epp_^THpe+eb5HIvzUo?fW(va5{7P zd0GD0trC|9zjsRjleub%YeY#(Vo9o1a#1RfVlXl=G}JY)&^0g*F*LI>FtRc>2C}UT z3_|{Y+l-q7HAsSN2+mI{DNig)WpGT%PfAtr%uP&B Z4N6T+sVqF1Y6Dcn;OXk;vd$@?2>?&0tquSH literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ic_cab_done_holo_light.png b/actionbarsherlock/res/drawable-xhdpi/abs__ic_cab_done_holo_light.png new file mode 100644 index 0000000000000000000000000000000000000000..bb19810bc2062509e4e4968099a359ad73818728 GIT binary patch literal 915 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I0wfs{c7_5;rX+877l!}s{b%+Ad7K3vk;OpT z1B~5HX4`=T%L*LRfwTh{zxw0jNgl<&3j(^ zeD(x}!be9sh1LD$__>xwFX-mty1-MRJ?GVgBPRYo&#phmts!D?ltV3&FI%+a$=z1Z zV;YHl1iMSDgJ+|>#46F---v^ z=n46F|IdfFb=)S0I4Coo@!g}n4Nex)S*)#RZPN@k9D49tzo1o|L;8h-cSg(aGrNAg7qQ^lmAJNnY2BwD zmg$yB$_Kc(9`bFT@$ln4rdg7D8~IZ-f3I60`0mq%qw5167@Xn!BqR{_Lfuy~aYE2x zQ4_Q6{SU<2c z;lT8&TH+c}l9E`GYL#4+3Zxi}3=9o*4J>pG%tH*#tPG5-jE#Y8D+7a&|KB#FXvob^ z$xN$6(O_z2Y7RsY4Yp<(!9Wd?ARB`7(@M${i&7aJQ}UBi6+Ckj(^G>|6H_V+Po~-c P6)||a`njxgN@xNAiwS~- literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ic_menu_moreoverflow_normal_holo_dark.png b/actionbarsherlock/res/drawable-xhdpi/abs__ic_menu_moreoverflow_normal_holo_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..a92fb1d4af622cfad770d7c494121719a7896e61 GIT binary patch literal 167 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=d7dtgAr-gYUQ-leFyLX@@b&p` z%gbN)&SLHDYV<0q^J4_6fq?|&@*V6j4#NRakTDF}Z~@#RP$drMna{J{ZM0wU(H|t@ M>FVdQ&MBb@0L8N*<^TWy literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ic_menu_moreoverflow_normal_holo_light.png b/actionbarsherlock/res/drawable-xhdpi/abs__ic_menu_moreoverflow_normal_holo_light.png new file mode 100644 index 0000000000000000000000000000000000000000..930ca8d95e8bee5a1240fba645d9dab919abd734 GIT binary patch literal 184 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=^`0({Ar-gYUf;;epuoZ6aJO@& z%&D0-IKvGL&8p&qV;O7KuliPO1yl(K>(rHwor_8Hg9|Y9Gj8!^hz0Vk4~QZ}ABcvv nF)(akj$uTI?LshtEWgbR4Rf6*RPme*0Ev6L`njxgN@xNAEX^ml literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ic_menu_share_holo_dark.png b/actionbarsherlock/res/drawable-xhdpi/abs__ic_menu_share_holo_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..45a0f1da0d01b7c0ba53830285c67d629bd0774a GIT binary patch literal 699 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7T#lEU~2MoaSW-r^>)^McjrWjeSoS8SCOEBs|%|?VJ7D=T9Yz_dLJ8 zJ9zK=&-=vhubx}{vF6<8-!m`2Et8%6G=f2_fi-~)r;kY>>MAgRkm@i7CT&PKJ^T(I*&Av>d6O5U0r~;hkX|;LrY6t%e!5sze0;lgN zzhmA1v9d1mdTWRDgJXqP4j5dhQr@DSSRpJN-*(9Bjp4$N@%tt%vt{r<#9TCmVT&q5 zPY_dpf5x8W&TrHi1EzgwuzL61gP~v}`*h7_ev9YX^%66WzmeOz)Rwd1sPzfWyZX+; ziqW^(w(Z~haJj|{8OsISSA~|G@%CQ8Y_d#7=yl$KAFm&t%#H|W$kcQ2;yBguIO76W zkG?He)AQ@KipLqRU6Nb%FPk$;xS@jW=|$x{C80dl?QT)`*~FQi^@N=fie6YGbN2D| z=`W4NG-chmgqp9bsxquQQuyVroI59@gwb7QnV5NMi~&p85J-Uv+l!N+#T%5W;<7yr4}f9Ow$JGA?da_{7}kE@t}@ET5LG{B2CIDTQC8`Twj U_qmZcFi|piy85}Sb4q9e0Mf@O?f?J) literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__ic_menu_share_holo_light.png b/actionbarsherlock/res/drawable-xhdpi/abs__ic_menu_share_holo_light.png new file mode 100644 index 0000000000000000000000000000000000000000..528e554abe239137182dd9069d1fa4ba02a109a1 GIT binary patch literal 935 zcmV;Y16cftP)=+L@6RIMT%_@p^A^X5UDRjLANf13Pq%);A`Pd+=!;23pXx; zAif`nPef)@LW&ftmV!!=U?`shr5Kn0)zPywg_Q~)Xf6@UsrA5Be7{a=6EByPs``206cpncnr4<@!q@mA~gUzaA3%HTX+%kDFHYT5Qf!vm`Me|1djAs_x*GR z&!z%kGhWI$<|3X<1;9qUl5@-=4yFR&S{y_@$C%@oE<1op+>aXzjC~!)$_ii$_F+%K z@y9V;#ya3q+!Mu4ce-D|$M^yJarJ;X=I|E&DieT9a7UE58@rw_;mfG%mg3n4+>X7G zDINV8W$>{wd4UPs8tHyn<_K%Vx4t-F{HB0#CbHyT8aIH=*w&T4zhI%?@Yvw4$UHw9 zfiH|AwZ;Wt3m(R<9MXfe~y?7+&yyx)=z7N}~%m5B!YmPaWaH#7@Q+5E; zIqP##(=Vn1;7AlEd2}e2K@tF-TcIq?su`V~Rw@AYX?JP!=ya5wR`qE`V>4fQR+^F$GWKC7sT4IxUFgD9>&BxJs0#D$E0dq8B&$(De03B_O{zBGgT!>|}k{a55 z!O~xj?u?9>EHL(EoJ!?lWDg$AX}pf&%~Sx?@v3~6qvvqAx*Saezy`dwo-+WR!8JMF zpTip|0k{c|kLwhu)oQ!f;y+34?@=W6(zkfKXdO_i)poDN4CtH&58$o=8{em4rdmY+ zbb?>20J>f0o#8w;#fEn(4AdV*y+C*HYaPJI-C#EObp@bT@IwJeLH&YX7XStYpFDt- zf=?R2Fu^AaVA$Z31du2AoO(cqH+@Lz(5e*i5O+3-*HCUO7(002ov JPDHLkV1h8vxv&5L literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__list_activated_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__list_activated_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..eda10e6123e1e1383c4617228ec0c96680d60dc7 GIT binary patch literal 158 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT0xamSQK*5Dp-y;YjHK@;M7UB8wRq zxI00Z(fs7;wLn1!PZ!4!jfu$#Gb-B{xqtMx1s*(O%+nLV7IxRdaaX6Iu&3070|zpW ye6d-ZyJWwc+pgOl@x443T>9p%`1p8cx&%YrImy|zOvgZGF?hQAxvX30u5yFboFyt=akR{ E00Z(eO#lD@ literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__list_longpressed_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__list_longpressed_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..eda10e6123e1e1383c4617228ec0c96680d60dc7 GIT binary patch literal 158 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT0xamSQK*5Dp-y;YjHK@;M7UB8wRq zxI00Z(fs7;wLn1!PZ!4!jfu$#Gb-B{xqtMx1s*(O%+nLV7IxRdaaX6Iu&3070|zpW ye6d-ZyJWwc+pgOl@x443T>9p%`1p8cx&%YrImy|zOvgZGF?hQAxvX literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__list_pressed_holo_light.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__list_pressed_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..e4b33935a3aa4f1af3fa9e9e199b5c47d43f4b74 GIT binary patch literal 163 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT0xamSQK*5Dp-y;YjHK@;M7UB8wRq zxI00Z(fs7;wLn2vPZ!4!jfu$y_kK-b literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__list_selector_disabled_holo_dark.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__list_selector_disabled_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..88726b69160589c8545759440e8d4e69dc984c67 GIT binary patch literal 190 zcmeAS@N?(olHy`uVBq!ia0vp^azGr$!3HF6SgS1tQk(@Ik;M!Q+?^oIXnykaTA*No zr;B4qM&sKXhJ1$tcw7#es=J@sd2yMiyW@jyg@u(=2qh%>1r1WJE1Ls*cJ{|veUO|(2?8OR-p?Vt(<)KXNk*dJ1<_`!jRpab6RMK;Rk47fDU#NEX#7yk4(~&Fr}L7DZp)K} zK)DDZgb+dqA%qY@2q7)3S*px^wsY!a9l?~jW2$HoDfOAoDc4?$q=mJH$Q@HesW|pH zEqI5t5pt#=^`ykNb$bDA+g_!6r>E#0Ebxb)V~E)@66{HSu%o+0#^7QK=<56_<*0g z4?VWXMFRkJB8s~XX6q}?LEeWW=Ef--P!X+fp` zQ#hbt=1@CWv@?Vrj0n$wG-wfB>s2&!$QdDJ0ulZgw-cuRiR{Y>^Hj3K6cvDZyr8vA z8lxp5*y$r9!v6G_XAF7`2PhmT)XW;J_(x39;8bKfgMu`e! zU+jWXwIOOF0-q>8C*JQsY~7_bBCuA z|Ap1-2&vJi9g(t&*dI@qVtrbEm_q)8uxlUymW^N&DQrSTF2REQdw9B(B*Fk-L?96w zfdFVX0=tCgq*<4>5rKwy4p!?>V+1b~mqyqhPm^M8N}pNlWK7Aa(;L|rtB1{dT%;u; z=)dm(?jeLfE6zhUB!2hW01y9MdY)1v=ujhBx3b+Xm&>Pd9KV)clx)K|j$bdA%O^}( zPFj=H`w_B~E-2}`eIdjBd_I2}hT(GvVW{|jkQIawhG7^!pU>wnc#H_%SRreOrJP6k z#f!~#`~_1^!^gPqw^)9R`+vop3DslHn(o!PiI0dTt@|45Za=)m1`%IwEW{fV$LVaF zE9RVsAMaWMjZlg;f(R_4iy{7r`=s=`3SdP<&^M)TPHqgUw5?z25;3$902*NlyMU*S zpa+j$RH$BIEX`7~H`b|A%pl=Pj|o!QHv-L&MvImjnCmfv9y@5Gq|A_|G$L4MNvqdg zg%(@J38}FG4N!(%uhEggMhM*%9HY#I^l zO-Wr$p$z~$ref=30GgqO)XJdORd}!BEq>NeB8p9{v^kJo2|NxCQwf^HCpGf6X;Wp4 zg!hgmb$FtdtQ>ASMriqL^@|$FBEhNWjw@zMktp~+Gzo9nO1w>OhBUKE#}ER(1L)vD UI+1b(O8@`>07*qoM6N<$f~tseq5uE@ literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__menu_dropdown_panel_holo_light.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__menu_dropdown_panel_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..93066c8403ddaac9b19571152ef499620bcc0e02 GIT binary patch literal 1551 zcmV+q2JrcbP)ZMyJc+a5x+ehm5NR9U3;9%`Hyz-(tJnPJWK72_ZxFO$7HJ!wl=MA(TM` z5z;&LLlB#EA&f^$3`&>pe6X)LdJ&`vfROKm-xd+jMbSqLMZ|438|}{L$EEgM9M^%w zHa{i`W4qmEM~t#0eOdu-0W1NOh@<%YUknyuBI#0I?3#!O*zRI&T@|+kOaOda%IhNv zM;99T5trXGZJ+ZJPec%b)$c$hhFbzf1btKUoQ@WxJHBtqt%Djjh@==IkkXLZmr_R= zETUs(|D2YHL30h7B}jQ1@s(0WN*y++$>%9Px0_7;Q^61da}ymGVa5oGC6I`(Se|An zXj@SBzbdSFK)Um(Fw#d8Mr2~>phE(63xW_TA*G~C`G7107k~`S4FDISDe;mJcscGO zI_^QW2+SjBmZ1U=9v>gytZ(L+77q^(-%!w_2qCD0PZix`L1IaO$h(b>d0@F@G3Eaa zi55W^GL}q#AgNiNjxa=>FZdR(r+ zxE>NCSff^sd0^fBMHn)m#E-cU=7+{dF-K!9f{S1|kOWYSoDj6e26s~&lfViRc^MJj z^>Y9iF9eSfmVwbcxJ7UPa3MH8F;)otZ%)TN7|p{_AvpQV#UO5SLMWM?>!O$+C0vaD z8(N!X1GsBg3ar^sKmkXku0dO*!9}nfXnYiL)Hg=pYKs73(^zvc9aG}t;{#B5>C;Y2 z2$?l`wfXukgc)%>9s%7AsDyH^rRNDOAHyeHMgYzG`@1jfJOi4h!RzZQK)65|cOA0& z28%R3H(uBEzOL&YU%_z=>~=fscDp^gsmfTk*1@j+TejVzGC zpG{n`bp4r^(iKT*Io^&x%OHc_WZd_EkhCG`k)*sFZ|A&V23>!#)HToxrIRJ-1q1Q~ z3qHxB_z~+bgihSWK3otqlC9O%9BoMC(eAot5j0oOB3|pwbjUE4*ONZd@_Kxq z*B8(0XhE_FfV`ZZwcn~gXn8&5;sQ&h03_lPHzc@QD2L`A0DB!p$qE$r97Hn6cmgfM z$;^GEI@&qEx+o;VEJ0ZAK#dKOL6F|xU|IwgE6|`&x_D{{k^myy5)6fQcS{yR>LIlD zb0eL(UISu`k;Dp-=L_3_9uII4xG36?ZZ5uUxd1Up2yq&z=dNHjN&oIh<{D_CLJUbUG4w?002ovPDHLkV1n`$ Bwt@fv literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__progress_bg_holo_dark.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__progress_bg_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..345f5d3067c1b5a2b13f7234238468e8083e75e8 GIT binary patch literal 174 zcmeAS@N?(olHy`uVBq!ia0vp^Ahr?*8<0#p>+uXou@pObhHwBu4M$1`kk47*5n0T@ zz}*SLjOHg#uLTMQc)B=-SoFS~;>gutz{8S$H2ll||1$b2>+ab^8r zChoU9-sVBr1cr+EHAcpdxgPN?*fw!WN@w!F_di=AUe22-xp-2_jNr43yl#?i1$i|o QK(iS+uXou@pObhHwBu4M$1`kk47*5n0T@ zz}*SLjOHg#uLTPFdAc};SoFS~;>gutz{8S$^!?BO&wHlFT~V_1=)TZ8!I{mdT_A)Z zztl5%UbEjFE&+!7%~#Kq{9)d)y{;#I@4EEH*bSem)2!T7Pp)1*OL*gdvC7^*b6)~Y OX7F_Nb6Mw<&;$Uil{z^9 literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__progress_primary_holo_dark.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__progress_primary_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..c6c3f1ec248835c16ee8a8f9d253769ea4196468 GIT binary patch literal 1309 zcmV+&1>*XNP)>2T29Hys?P&Vm zZA9*OOSNlf`Pu!y*8AUEO|D+e=9Pi3BR)agfw#}SukU>S5_JQH{fFX7qt#y26-7>F z^lg#%AL~){ay($Vl%dNK|ns=8F95J5u4IuT)_iO}FO5AO!x2YA-ev{((MiCMb95Z27y1N{d~<$0ZOiAzT-4$^Y~d8=D&GctVLiOE-HZCX=>916 zaB}eD93BUF6!cN|FY@&i`W7!}IIL?H*U-;b(9ZeC>T4fo-D~%;%Al$SM;o1{CK^c@ zLsL?U%;F5uW`mKV6p@jG8Wm~81rvcAg~E0r38^#=q@={j6{7*N{-mRal zZyi757l1u@+(UUVUpKQfbx4*^AEZ`NBGTk&djR!;W=;+8vR!2ZvkZUiF_Uw;@^@UHY_tFNo|bZ|HqK}~Z_0kB z>1@!nFOf~^{KOi&lvG5Os4i`3m5LaZ>S{(}C2cS_3u25qx+GSC0x^F*mC<6C%zjX} z`(@Gi@=yT|C0D;bu>bAn+W30Hh5ZfH4VVpRc=$wP71`a_ciV~TTQkNXRQHQat7toU zZx*3Z?Q~QYQO|ZUR_Tl#qXtzIiPWWo(#}&aV(i6KuEST$lYVRUVscgaEz?@VCh+@z zYdAdahv=OS&fP(?9$16?`l0%F3gfnP`B71?hw4@2e4pjZouU=>X|R*`N-YD-DJj}uU$#5 zV>X}RzD~bXHhFf?KK=4JTCWrMiS*`U`G2n9l*Y@cp7B$uQwuKJNIF$*XNP)>2T29Hys?P&Vm zZA9*OOSNlf`Pu!y*8AUEO|D+e=9Pi3BR)agfw#}SukU>S5_JQH{fFX7qt#y26-7>F z^lg#%AL~){ay($Vl%dNK|ns=8F95J5u4IuT)_iO}FO5AO!x2YA-ev{((MiCMb95Z27y1N{d~<$0ZOiAzT-4$^Y~d8=D&GctVLiOE-HZCX=>916 zaB}eD93BUF6!cN|FY@&i`W7!}IIL?H*U-;b(9ZeC>T4fo-D~%;%Al$SM;o1{CK^c@ zLsL?U%;F5uW`mKV6p@jG8Wm~81rvcAg~E0r38^#=q@={j6{7*N{-mRal zZyi757l1u@+(UUVUpKQfbx4*^AEZ`NBGTk&djR!;W=;+8vR!2ZvkZUiF_Uw;@^@UHY_tFNo|bZ|HqK}~Z_0kB z>1@!nFOf~^{KOi&lvG5Os4i`3m5LaZ>S{(}C2cS_3u25qx+GSC0x^F*mC<6C%zjX} z`(@Gi@=yT|C0D;bu>bAn+W30Hh5ZfH4VVpRc=$wP71`a_ciV~TTQkNXRQHQat7toU zZx*3Z?Q~QYQO|ZUR_Tl#qXtzIiPWWo(#}&aV(i6KuEST$lYVRUVscgaEz?@VCh+@z zYdAdahv=OS&fP(?9$16?`l0%F3gfnP`B71?hw4@2e4pjZouU=>X|R*`N-YD-DJj}uU$#5 zV>X}RzD~bXHhFf?KK=4JTCWrMiS*`U`G2n9l*Y@cp7B$uQwuKJNIF$+uXou@pObhHwBu4M$1`kk47*5n0T@ zz}*SLjOHg#uLTN5dAc};So9|U`2XLYnVI=;y-5$#f-D2o4GsT&Tr`prfMCHsr=)`p zy9zZlQWAk&gL|Kjh|gcN+0MxMkn!S`=@A+#%ic(Om>d23|9^ht#EF9It^fc3f1ZP3 Y!dJ=4-o~HPfwnMsy85}Sb4q9e06h#o+yDRo literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__progress_secondary_holo_light.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__progress_secondary_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..205b66e2cdef686c5ed6369b14e64b38d0182984 GIT binary patch literal 184 zcmeAS@N?(olHy`uVBq!ia0vp^Ahr?*8<0#p>+uXou@pObhHwBu4M$1`kk47*5n0T@ zz}*SLjOHg#uLTN5dAc};So9|U`2XLYnVI=;y-5$#f-D2o4GsT&Tr`prfMCHsr=)`p zy9zZlQWAk&gL|Kjh|gcN+0MxMkn!S`=@A+#%ic(Om>d23|9^ht#EF9It^fc3f1ZP3 Y!dJ=4-o~HPfwnMsy85}Sb4q9e06h#o+yDRo literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__spinner_48_inner_holo.png b/actionbarsherlock/res/drawable-xhdpi/abs__spinner_48_inner_holo.png new file mode 100644 index 0000000000000000000000000000000000000000..19517c4b0aee1010c7041a76089fdfdbfa495e80 GIT binary patch literal 2769 zcmZ{mS5y;-5{5|(kkFChhK>RPiYD~XySTIjLIgq!5ZD-yra+_^kSaBR(jkI$M5=;8 zMWiYIH zJ{L4+9lA?MGnNjQqJIVMy|@+Y*x)5n@6@M^X%1QI>%HzU+s^F$A{uGSUK0 z#wO)d1v)g|N-fzez@Pj&KN3PQb&b(W}2sO#Qj`+a3CPNKCA#BE^jjI)tjC2m8529 z02D1x&?I`7IDU{j-Q&y{>)zeY&B`Ma8WJNrGwaNm`0uWt(pYLM@p)H2v)A~R+!)8F zgGA?$X`A<0`mH|V>|FVYItF+KSVc7^pC3V3%7=U@p1B3em})M$K(uwD6N9slB!(`T zi~R)>BQQ>9(EuopaR0r1fiuNtt$$G?AxUQ@M7fdP&b*T=zGv(+u4G zTQ zd|2UbSWW9ez=$eHfGIUaW6HipjZXJlnM;#Ny2G5k&zxqBW-hk8l}RPTCj&~v-_q8B;Zw4m;LP(&&JidwjDQ~ac_8#Y3JSaIVaz} zyux;b;PbeS(XUa_g!cmp3G0eiR1nI#(*cg`;6LDxk&B&UZ8rz&hgBr(y7O6rTkmQT zrhy=2eL5GJ7#qr?o||O28Lv&K7&3aywR-4iQ40MD_ir1|mARNdS-bGJerJz@cDgI~ zKZMq&dh8$ns!+~`c$m66V_VkBL{T))8QD)3VcaS&MzgHdAm9-34$~obv=v4^hN>o|d<8G$j##Q2b(LY)D`ks?MI?Bj|mqM(bkFmmohvBKvt$Q9Eg| zyXZKq$-o~^vIFdVLC`fNajQUh_^L?LN#cyA7T#%e%ecLIINl zaa-|hGb!|t5%rT7|G~~BHKnC(Cj*+1dj}!dLuH7c)m~U}TPtOUpq{v@8E4cSruw}v zP?r25lr7VN4=8*&WtXaomaReN2bA5Qe#=DrTI*iN zxJ0Y_4o7X@C1>APsW`y9ZDRrN?V@GJsw1M)OnX*zAx4o)Ld;Fc$sfnk;RLMHYsyQ7 z+8$_YLBAkmVb>l z^NPw5VgYZOYH|n`ns3NjmDgu2Yu32L2z~FCt<&E4IQ=~=CsQ8d)yQ4oG8NU>uy$+X zNf>bxv!t-TqNU1wX?;O>hN{qoXNl>c=dIC%k}p#8@HvfsRsDS9?sZrlpzpmlEWoa+ zE#xErtO9lePlYW#FAcWM?nI`J4|LI*l2_W>A4QqFId1Eb0cnhc;Y?q-cF6vXA%=Kp zTl&38dA-veWW#-bZt?S-9?&OJE$3JLuL|IS<5T4uf+Q}HNyZFaD2%jPwTM~u zidPW@em-aeW8>{R8XtHB|M< zqzyLS?bn}ASUr2W8?I|FWHX12r754 zKIHBi{Y;&qOIy%S+SoM1eYJ(GwLi*;ERNAj5~-B{`I|d*RT___Ad$P9`7Rm4^0m)} zsgpnGlpgth2w${(wGB%maw|SFY#m=RY*puF$vHJ}IEp_X{mj2^!Zxf%p)#_(m|pMt zE5ufXxyGSypt&mO@{9safwES>rn{ori@%a87<09J2=^iZ2kF4S7tJwTNpFM8jZFXLogNu#ZQIU4NEa~}Pb#!` zYPNgFL_d-(lVB&Hlip61zZTY2@VbiTT;B64r3sR%dn#(|!&|U6v&W%3utzAjiF}0u z2Q;oP0SIE&nDAb$a%|^P3c4L7TmALn#+C4MHD37aFX(F`e=Cjz|Z8 zTiV2qTSXyXz!ly5y;Tj@uBYwjmv&ibj6hkc)XgO>-{#?vk6Cti{l`V8i4PBb&KB=8 zx)P_xpuB=V*IIs%@7Rw??9@{*0Ut3_uPM?V900gEglK(YhnQSDCX73%vt*wGFki_& zP-w5AXw+dW0oHu>X7>3c8>0Og9ztC5>B!W!T}&Kg;TDQ~m3{I2Nm%uq{<)?%O?UqL zPW_qk3y@&xteNb$e(Lz!lfQ26blnGc9k1gZf^lU0VgF zr2~Tjw7VStClC53*w9%B3P=?aA_NH%FrjGZC`F`)4nioBUC=~8AW8|nWPuBU z$_Ax~QpE+Ngl3~F#l&Etsjw_Xv$*Hnhx>3JzWJRg->crS6J%m+QIvUZxhV?Jo-M#nxzF{J^|38LuZ7p2A{3`Uq`=6kIe>?XjoG zr?GU9y(f-uD6ci)?1uQVR4SRTa}|zrSmC&X%{3Uu#s!v3xTlSKYl2xXRH=XldiG8v z(NTpiD;+Y~m>M*QdTK>xZWq^1Gi8i~5S7o}q&SbO8eBpO0}glmjSVvH7iqi26bB%| ze)qmu=vH{`#f$>>(djQ0^Nd<2H1NqlRYSvb%bfxVSE-6hyvT5}iWKJBsJYUTMmHlb zv{AxVJ_-jqG)Isz@a^K$cM^+{e$!&jnX5OO8E8XRNKBd8M%eMRN2h}U8b(CNyXF_g zuNUp7s?z=QD$}|Yd9ZAQ6_1dXY%HHkm_JujD3E@{yoa-`U00;ZS$y^Kch)kpoM#-L z_hl0hcTHdzz3P<)L4tEt9m4YU94$VspFs>kyx$G43>YTSqKXzilVwxd7qomBM?e)0 zk70Hc`|MK3$79>mw09q37_K`7rCCb2Je8#;R&l3wIoUvgp*l01y`!k-Fb_5 zLjfJM*_>#E9is$M8{y8UF zc`)}6IgHUUW3OdBIJ8Hp{C;Gz79e0KH~zPbyGtCwB=d&F=mttg3`f7;P(54xp{|RR zuCSG=W?@N(vW>lt2EpQ^z#T{`#xM4!mdgzNHx)<1u}$v?^g+=6*9ecRo#a#lbymZ)6-p6z^Oni3 zsLEXV)_}Iwfa=*b4{k&Dd=wxu4wfdbo>!(imlp)*j4pv5ge6;)9owM4=9St^swSv{ zskok>E#MxCe6UUVusSMJNGR_6U4pG5H1hlHX%(t~>nKmo-|d0-{MbUO&bU~mKcE&# zK_zv4|CD1!H8jAfY`vSSl6kj5Wt9loIBf}POwl~4S?>?$T&{Mawq7O5qkqy#o-A4N zE|eq~B+4&zVcuWC$vrg@L14-|z}_N{7ai6X+LIyj5pcb|jwUl|0>Ek~Th%i#NI{1_ zBm3pUiwMhzLuXI=foW(FgEeV4z(3A`*yzwk~f+h&vY#xmxsf?5OY1hsd ztM%beiwI=D(k-wWDn9)VJJk!~4z@|bN-=_~*}T5DfK5!C3E@eSEsWaR*+?aH|7J32 zC+By&%_SPM+AS<3m|xNxz3pqO+_l<53yw$fu1oeLjY&kkfdiF=Q*Wdc`etyM*rdK( zp22kBzFv%4ur^fuXEGM-pX|Fkd%Nq2l6dRQ2XKwJF@_oc*%do|>Y6Qv~!9EN3 zF&dggK*AU2RyOj#FqbZdzB>B~aA?KNhqMjCP zxg%^}e6-VnyS`t)yIHRQ48~-EkCwOT+tHm-FNve|j%NMGANQwdwt$uv_8B$5dQ4qt zta;CYDP&5a>BeK^j6`R(AiCG7VaMyHMlZyJ5(>(;W*&VnHGV2AuFnNIz}wiAT7{P6 zzLG`Ao;5|df63pAJnK+9#KTd^>$h)+arJbu4vNUF`f^QCm+L^AP{SFHl{TDz|}ZV(SF{inp3522LyJ zSw}w{j~U+S-eU%!n4i!>i<1qPc*uvvdn0Equ&#u7KRLHmgc+YBp73B#_8nO(jI!6a zd|^=Eg{Z*a-EZraT;7p!4p4Bd9(wNu7coSR1qusz_AQ_YwQYlP_s|#mVMCws=x<_3 zw)$>kM#p7l7$^lrSc}QL@p{n?})PR^#Ne#?) zCgB#K1aGkR_pfe{pyO!Rvn|^H>G<#YXY-5pW!C!5cE@?0?1Se-EtcRG8{ivDI_Xa) z9RNV-BayoL#=1yj7vzbP28Jim7+rm%lluA~Oy{}(F+^Mn2nnS8e?t@r{NcbL_hWF!{4*;x%LlxuUCHn literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_default_holo_dark.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_default_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..d8929fcd1864e92c78f24d34bb07ac0304bf5ebe GIT binary patch literal 395 zcmV;60d)R}P)%)khMb;v@5Yo)-?A$vWI3J{&4Tqm)VM&;#i3-!rXQ;}}A|kSK_xLoQ9!D=| zrQuRX_jo!D&!*woG(4MzXVdU(8lG)+!_Dl;%pOYTRyEwrUVwMtwRCnh!_9059DxJy zTsprAUsT~zdJlX8e>K+(FMd_}2<&RF8#?@^bn(8vHtbfpl-_eLJ!>=!D!!z&OE12( zv`a1CqqIva-mA1rDc-ZR3oqWgvUXO(tc zif5K~i;HKMc8iLSDD9eyk1Fk&iksP%L8V=5@ekmQ^NVfO%k2z5z^Qbob@&(X-FR)u p3HS~A?&0(Ut%!)oJooy?_kZokYAURbJh}h?002ovPDHLkV1n7-uz&yn literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_default_holo_light.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_default_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..9174c4e4bc984a89e1ed643bc66b1569466ef52b GIT binary patch literal 394 zcmV;50d@X~P)pS_@$ zhD#gW|+S$zvH?tjZ06u}I z+WCj@MGelS_rM46*K*DD;uob4z^?VWsl%^ISMTdf({7b>={={?i$=qw;%iE~^x|tv zyVT+%O1re;qe{D!;v-AD@ZzIOyU^khrCnI@sM0Q^cw}ieym)kJH?(+0X*aBRR%th+ zcxGw0x_EYJx2pJz(yqJstkSNlxS72&skG}Y{tg(Y7u%+n+Xa4rW9?Ay@Gs!I^V*st o@Ei2q)9D9V5fPDPZuO7v|4Ms3SH1lZVgLXD07*qoM6N<$f(F>P&Hw-a literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_disabled_holo_dark.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_disabled_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..3015d307088f12d52a9e99ff4575fd2153127e5b GIT binary patch literal 381 zcmV-@0fPRCP)hG*08Y#N?T!?S64w!;lKvy+*1?>p3RGdlx#190x$dzj&7b^-9QUftoB@I?dG z(l;!l|3;oEFaA*ajtwD8hd-6>9*;+5M`bO2!%}+FXrQS0p3;u)|QJUO}XO$+G;+dssck%4fw5xbU zX__uxRhp)XSC*#P;_m>iSbo@k`^^CW{9xcU{p|2h0AG{O_A~&$L7!btFK9(XM7DX= bKfeD1Etg?&Fp}qT00000NkvXXu0mjfW#pxI literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_disabled_holo_light.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_disabled_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..126637d1194f1d6609787774fb140818eaa4ba1f GIT binary patch literal 381 zcmV-@0fPRCP)hG*08Y#N?T!?S64w!;lKvy+*1?>p3RGdlx#190x$dzj&7b^-9QUftoB@I?dG z(l;!l|3;oEFaA*ajtwD8hd-6>9*;+5M`bO2!%}+FXrQS0p3;u)|QJUO}XO$+G;+dssck%4fw5xbU zX__uxRhp)XSC*#P;_m>iSbo@k`^^CW{9xcU{p|2h0AG{O_A~&$L7!btFK9(XM7DX= bKfeD1iaRu(IeFS@00000NkvXXu0mjfR7Ip< literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_focused_holo_dark.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_focused_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..d45c7a864d9b36fc5d06ef7650bd22c228e3533e GIT binary patch literal 680 zcmV;Z0$2TsP)JMg@Fn128fNR{httc z2n-9ae~A~-WYQOAyjJ3`v+tFS>H?h>cjZI44!YCDJ4vU-UH-NFC!H?dNqTY9^x~%J z#ZA+To2C~xO)qX5=ft;__PrJUYC9#q>!rbyQFMFHPb=3hoe|&n)9~p|baWUbMthlMtLL6k^E5&wx9H zfkWKo4DxGy27JSv%4KLW#~I|sPnXY+fCHfNj(}ks%-+uyBgtHbMG(R)| O00009q_DOpcx|jv*P1Z)f>u3p>g<+)ulGcHZsoOUd0`v$ideb3Xs*rv6J! zg}R0?Ejbavstni13%M+(h~#=Y?=G{+sY|c-R?LyC;M~J_EGz53I-4BR z+cU4@A4T%4{LQ{7{nooe_R?;9Ufq56+wp;!Z_W|LdHU^V zuiix!E)rt*mg%eid+||lw)K3kxzR2XQeoHKTo0e>Tz_Z7KF;I+KDl^G6{a%9AKj}v z@Aq1v55LRoZXbD)<16^lF!*Li$^7}+)mu{zFEMCaSs}k;w&aatvA+!FKCV6>P_Fen z(L?roLe!sxPkWei7+T9&rtD<0W7^%ZdcE}hdZyQpKhHVIBAEwFVGN$GelF{r5}E)^ Cjyh@p literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_pressed_holo_dark.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_pressed_holo_dark.9.png new file mode 100644 index 0000000000000000000000000000000000000000..2cb34d7f60401a563454c03e266cc5181d9de996 GIT binary patch literal 609 zcmV-n0-pVeP)%5ec8;(Nh#y0Zthco9&fD+Scz(J_kqCSd>@N)Jrb#iJx@ z@geV)|0U|;Q8J4AW)%0$DDIn4+&81RZ$@$73{E^#CTa6Odr;zqGLyGk)zfLB)26Y5 z5#LU9dOW?JALQjc$4r{WH?GVFg))<)qMW_Ts@W~*Hgkd(m(u%LwVNxGwVfAK{BG$~ zHD4Zg33jP$CptYU%GrKa?RJ%hK*cvHEqE`!X=%Z0aT}!tZ^dnu7Q7Uk{&1!u)wl@^>7cUfAnUfgwQ!D?|Ir3GuneU%oh6!%$L*todw(!xf?LzEVJ7Y|ih z=v92GOd6`R(5v{nqI~u|T|T)5eQi`_Q>fI*QllCl)AthpQf>YCTIE0c%xyxW%x|6C zG>z*e{-?!>T@(EFL|;a6&!||%qb(l4cp2298zt1@mjOk(atXEgIq-{NzY%9xIi5qk vb6%{!-vcjz*7vDBaRYn@J|M2KzWDwRiVUw(_ikNA00000NkvXXu0mjfOP&sp literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_pressed_holo_light.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__spinner_ab_pressed_holo_light.9.png new file mode 100644 index 0000000000000000000000000000000000000000..82f752fdc28390f1dae188e66886f9fee783b4f7 GIT binary patch literal 602 zcmV-g0;TXoV&|>P?2N3a|H=XkIpb%g2C{mUcD8z%K5!WW71`A3B@}P?c zNzmeTUM-&`=;A@rh-=e`Ytx8p(}-)+h-=e`Yg0e*Nfwct-zMuNo?gfN+FNCOm6(Rs zNBrh8;rK_F^Mfu~8k>e2?@WdCI_7lHVR+IZj_>A~;=j0*zBpPVOJB@8&9C^w(v!^i zcs#`4qjGbZa60I4akN%e8hjOBptPW0e8JL!ZgC5x1-;^yN((y0EtVGC7q?tma9i9# zX~A7_N2LWf#T}Lw>=$=jTCiJOp|oJHxKe4sPI1N3!s5l1OACt?_fT4>Uffe@p<40r zRpP6(P_6jSy?2bx-x9}n#O>6o(Q^BiC^BxWR1^RB?JvEr|0>Nj5k)!eSD9&8HSzXK z2sbij-vth4?P;pL%~0mos(Tg<|DAn;kcS obzts&Y9%t@53qx{hWg?AJqc6disFjI`v3p{07*qoM6N<$f`4nJ zaCd?*qxs3xYk`8Mo-U3d5>t~6?){q5*x2~c-pCBZ5@_=ERFyG literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__tab_selected_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__tab_selected_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..e4229f26b2771d884934b80d0056b8dd66d10edd GIT binary patch literal 153 zcmeAS@N?(olHy`uVBq!ia0vp^Y(Ol;0U|59*B=E^EX7WqAsj$Z!;#Vf4nJ zaCd?*qxs3xYk`8+o-U3d5>t~6?){q5*x2~c-l(n1@K5>ymj5$1a2Oc?!34d7Ck`Aq skg(^gW|wXH-lZoEvTk@AJm}J3sQWAGentL}KF}BjPgg&ebxsLQ0KFYBT>t<8 literal 0 HcmV?d00001 diff --git a/actionbarsherlock/res/drawable-xhdpi/abs__tab_selected_pressed_holo.9.png b/actionbarsherlock/res/drawable-xhdpi/abs__tab_selected_pressed_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..e862cb12154541c150fb2d9bb98872bcff506317 GIT binary patch literal 147 zcmeAS@N?(olHy`uVBq!ia0vp^Y(Ol;0U|59*B=E^EX7WqAsj$Z!;#Vf4nJ zaCd?*qxs3xYk`8Mo-U3d5>t~6?){q5*x2~c-pCBZ5 + + + + + + diff --git a/actionbarsherlock/res/drawable/abs__activated_background_holo_light.xml b/actionbarsherlock/res/drawable/abs__activated_background_holo_light.xml new file mode 100644 index 000000000..85c2c0212 --- /dev/null +++ b/actionbarsherlock/res/drawable/abs__activated_background_holo_light.xml @@ -0,0 +1,20 @@ + + + + + + + diff --git a/actionbarsherlock/res/drawable/abs__btn_cab_done_holo_dark.xml b/actionbarsherlock/res/drawable/abs__btn_cab_done_holo_dark.xml new file mode 100644 index 000000000..cab896283 --- /dev/null +++ b/actionbarsherlock/res/drawable/abs__btn_cab_done_holo_dark.xml @@ -0,0 +1,24 @@ + + + + + + + + diff --git a/actionbarsherlock/res/drawable/abs__btn_cab_done_holo_light.xml b/actionbarsherlock/res/drawable/abs__btn_cab_done_holo_light.xml new file mode 100644 index 000000000..42ba8a0df --- /dev/null +++ b/actionbarsherlock/res/drawable/abs__btn_cab_done_holo_light.xml @@ -0,0 +1,24 @@ + + + + + + + + diff --git a/actionbarsherlock/res/drawable/abs__ic_menu_moreoverflow_holo_dark.xml b/actionbarsherlock/res/drawable/abs__ic_menu_moreoverflow_holo_dark.xml new file mode 100644 index 000000000..2588a492d --- /dev/null +++ b/actionbarsherlock/res/drawable/abs__ic_menu_moreoverflow_holo_dark.xml @@ -0,0 +1,18 @@ + + + + + diff --git a/actionbarsherlock/res/drawable/abs__ic_menu_moreoverflow_holo_light.xml b/actionbarsherlock/res/drawable/abs__ic_menu_moreoverflow_holo_light.xml new file mode 100644 index 000000000..e2078c967 --- /dev/null +++ b/actionbarsherlock/res/drawable/abs__ic_menu_moreoverflow_holo_light.xml @@ -0,0 +1,18 @@ + + + + + diff --git a/actionbarsherlock/res/drawable/abs__item_background_holo_dark.xml b/actionbarsherlock/res/drawable/abs__item_background_holo_dark.xml new file mode 100644 index 000000000..d99b7a426 --- /dev/null +++ b/actionbarsherlock/res/drawable/abs__item_background_holo_dark.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + diff --git a/actionbarsherlock/res/drawable/abs__item_background_holo_light.xml b/actionbarsherlock/res/drawable/abs__item_background_holo_light.xml new file mode 100644 index 000000000..da5fb2e86 --- /dev/null +++ b/actionbarsherlock/res/drawable/abs__item_background_holo_light.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + diff --git a/actionbarsherlock/res/drawable/abs__list_selector_background_transition_holo_dark.xml b/actionbarsherlock/res/drawable/abs__list_selector_background_transition_holo_dark.xml new file mode 100644 index 000000000..b2ce4f0f7 --- /dev/null +++ b/actionbarsherlock/res/drawable/abs__list_selector_background_transition_holo_dark.xml @@ -0,0 +1,20 @@ + + + + + + + diff --git a/actionbarsherlock/res/drawable/abs__list_selector_background_transition_holo_light.xml b/actionbarsherlock/res/drawable/abs__list_selector_background_transition_holo_light.xml new file mode 100644 index 000000000..d7e31b1d1 --- /dev/null +++ b/actionbarsherlock/res/drawable/abs__list_selector_background_transition_holo_light.xml @@ -0,0 +1,20 @@ + + + + + + + diff --git a/actionbarsherlock/res/drawable/abs__list_selector_holo_dark.xml b/actionbarsherlock/res/drawable/abs__list_selector_holo_dark.xml new file mode 100644 index 000000000..08b8b12f3 --- /dev/null +++ b/actionbarsherlock/res/drawable/abs__list_selector_holo_dark.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + diff --git a/actionbarsherlock/res/drawable/abs__list_selector_holo_light.xml b/actionbarsherlock/res/drawable/abs__list_selector_holo_light.xml new file mode 100644 index 000000000..ada490bf9 --- /dev/null +++ b/actionbarsherlock/res/drawable/abs__list_selector_holo_light.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + diff --git a/actionbarsherlock/res/drawable/abs__progress_horizontal_holo_dark.xml b/actionbarsherlock/res/drawable/abs__progress_horizontal_holo_dark.xml new file mode 100644 index 000000000..bd19140ab --- /dev/null +++ b/actionbarsherlock/res/drawable/abs__progress_horizontal_holo_dark.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + diff --git a/actionbarsherlock/res/drawable/abs__progress_horizontal_holo_light.xml b/actionbarsherlock/res/drawable/abs__progress_horizontal_holo_light.xml new file mode 100644 index 000000000..321f07c8b --- /dev/null +++ b/actionbarsherlock/res/drawable/abs__progress_horizontal_holo_light.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + diff --git a/actionbarsherlock/res/drawable/abs__progress_medium_holo.xml b/actionbarsherlock/res/drawable/abs__progress_medium_holo.xml new file mode 100644 index 000000000..6d4814f86 --- /dev/null +++ b/actionbarsherlock/res/drawable/abs__progress_medium_holo.xml @@ -0,0 +1,34 @@ + + + + + + + + + + diff --git a/actionbarsherlock/res/drawable/abs__spinner_ab_holo_dark.xml b/actionbarsherlock/res/drawable/abs__spinner_ab_holo_dark.xml new file mode 100644 index 000000000..4af5e22a9 --- /dev/null +++ b/actionbarsherlock/res/drawable/abs__spinner_ab_holo_dark.xml @@ -0,0 +1,25 @@ + + + + + + + + + diff --git a/actionbarsherlock/res/drawable/abs__spinner_ab_holo_light.xml b/actionbarsherlock/res/drawable/abs__spinner_ab_holo_light.xml new file mode 100644 index 000000000..b78508478 --- /dev/null +++ b/actionbarsherlock/res/drawable/abs__spinner_ab_holo_light.xml @@ -0,0 +1,25 @@ + + + + + + + + + diff --git a/actionbarsherlock/res/drawable/abs__tab_indicator_ab_holo.xml b/actionbarsherlock/res/drawable/abs__tab_indicator_ab_holo.xml new file mode 100644 index 000000000..d34e20811 --- /dev/null +++ b/actionbarsherlock/res/drawable/abs__tab_indicator_ab_holo.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/actionbarsherlock/res/layout-large/abs__action_mode_close_item.xml b/actionbarsherlock/res/layout-large/abs__action_mode_close_item.xml new file mode 100644 index 000000000..8811dad8d --- /dev/null +++ b/actionbarsherlock/res/layout-large/abs__action_mode_close_item.xml @@ -0,0 +1,40 @@ + + + + + + + diff --git a/actionbarsherlock/res/layout-v14/sherlock_spinner_dropdown_item.xml b/actionbarsherlock/res/layout-v14/sherlock_spinner_dropdown_item.xml new file mode 100644 index 000000000..6c183c059 --- /dev/null +++ b/actionbarsherlock/res/layout-v14/sherlock_spinner_dropdown_item.xml @@ -0,0 +1,26 @@ + + + diff --git a/actionbarsherlock/res/layout-v14/sherlock_spinner_item.xml b/actionbarsherlock/res/layout-v14/sherlock_spinner_item.xml new file mode 100644 index 000000000..61dc02527 --- /dev/null +++ b/actionbarsherlock/res/layout-v14/sherlock_spinner_item.xml @@ -0,0 +1,26 @@ + + + diff --git a/actionbarsherlock/res/layout-xlarge/abs__screen_action_bar.xml b/actionbarsherlock/res/layout-xlarge/abs__screen_action_bar.xml new file mode 100644 index 000000000..040df44ab --- /dev/null +++ b/actionbarsherlock/res/layout-xlarge/abs__screen_action_bar.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + diff --git a/actionbarsherlock/res/layout-xlarge/abs__screen_action_bar_overlay.xml b/actionbarsherlock/res/layout-xlarge/abs__screen_action_bar_overlay.xml new file mode 100644 index 000000000..c64ef141b --- /dev/null +++ b/actionbarsherlock/res/layout-xlarge/abs__screen_action_bar_overlay.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + diff --git a/actionbarsherlock/res/layout/abs__action_bar_home.xml b/actionbarsherlock/res/layout/abs__action_bar_home.xml new file mode 100644 index 000000000..5c1e9ec4b --- /dev/null +++ b/actionbarsherlock/res/layout/abs__action_bar_home.xml @@ -0,0 +1,38 @@ + + + + + + + diff --git a/actionbarsherlock/res/layout/abs__action_bar_tab.xml b/actionbarsherlock/res/layout/abs__action_bar_tab.xml new file mode 100644 index 000000000..f46f7a044 --- /dev/null +++ b/actionbarsherlock/res/layout/abs__action_bar_tab.xml @@ -0,0 +1,7 @@ + + + \ No newline at end of file diff --git a/actionbarsherlock/res/layout/abs__action_bar_tab_bar_view.xml b/actionbarsherlock/res/layout/abs__action_bar_tab_bar_view.xml new file mode 100644 index 000000000..0d51220c9 --- /dev/null +++ b/actionbarsherlock/res/layout/abs__action_bar_tab_bar_view.xml @@ -0,0 +1,6 @@ + + + \ No newline at end of file diff --git a/actionbarsherlock/res/layout/abs__action_bar_title_item.xml b/actionbarsherlock/res/layout/abs__action_bar_title_item.xml new file mode 100644 index 000000000..dd69acada --- /dev/null +++ b/actionbarsherlock/res/layout/abs__action_bar_title_item.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + diff --git a/actionbarsherlock/res/layout/abs__action_menu_item_layout.xml b/actionbarsherlock/res/layout/abs__action_menu_item_layout.xml new file mode 100644 index 000000000..13149fd63 --- /dev/null +++ b/actionbarsherlock/res/layout/abs__action_menu_item_layout.xml @@ -0,0 +1,56 @@ + + + + + + + diff --git a/actionbarsherlock/res/layout/abs__action_menu_layout.xml b/actionbarsherlock/res/layout/abs__action_menu_layout.xml new file mode 100644 index 000000000..a6f8e53f8 --- /dev/null +++ b/actionbarsherlock/res/layout/abs__action_menu_layout.xml @@ -0,0 +1,23 @@ + + + + diff --git a/actionbarsherlock/res/layout/abs__action_mode_bar.xml b/actionbarsherlock/res/layout/abs__action_mode_bar.xml new file mode 100644 index 000000000..7168dc77f --- /dev/null +++ b/actionbarsherlock/res/layout/abs__action_mode_bar.xml @@ -0,0 +1,24 @@ + + + diff --git a/actionbarsherlock/res/layout/abs__action_mode_close_item.xml b/actionbarsherlock/res/layout/abs__action_mode_close_item.xml new file mode 100644 index 000000000..875ec3e1b --- /dev/null +++ b/actionbarsherlock/res/layout/abs__action_mode_close_item.xml @@ -0,0 +1,31 @@ + + + + + + diff --git a/actionbarsherlock/res/layout/abs__activity_chooser_view.xml b/actionbarsherlock/res/layout/abs__activity_chooser_view.xml new file mode 100644 index 000000000..019d14ef4 --- /dev/null +++ b/actionbarsherlock/res/layout/abs__activity_chooser_view.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + diff --git a/actionbarsherlock/res/layout/abs__activity_chooser_view_list_item.xml b/actionbarsherlock/res/layout/abs__activity_chooser_view_list_item.xml new file mode 100644 index 000000000..b430032a1 --- /dev/null +++ b/actionbarsherlock/res/layout/abs__activity_chooser_view_list_item.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + diff --git a/actionbarsherlock/res/layout/abs__dialog_title_holo.xml b/actionbarsherlock/res/layout/abs__dialog_title_holo.xml new file mode 100644 index 000000000..6402f28be --- /dev/null +++ b/actionbarsherlock/res/layout/abs__dialog_title_holo.xml @@ -0,0 +1,46 @@ + + + + + + + + + + diff --git a/actionbarsherlock/res/layout/abs__list_menu_item_checkbox.xml b/actionbarsherlock/res/layout/abs__list_menu_item_checkbox.xml new file mode 100644 index 000000000..39aca3a8d --- /dev/null +++ b/actionbarsherlock/res/layout/abs__list_menu_item_checkbox.xml @@ -0,0 +1,26 @@ + + + + + + diff --git a/actionbarsherlock/res/layout/abs__list_menu_item_icon.xml b/actionbarsherlock/res/layout/abs__list_menu_item_icon.xml new file mode 100644 index 000000000..55ab28a24 --- /dev/null +++ b/actionbarsherlock/res/layout/abs__list_menu_item_icon.xml @@ -0,0 +1,28 @@ + + + + + diff --git a/actionbarsherlock/res/layout/abs__list_menu_item_layout.xml b/actionbarsherlock/res/layout/abs__list_menu_item_layout.xml new file mode 100644 index 000000000..147f36fe8 --- /dev/null +++ b/actionbarsherlock/res/layout/abs__list_menu_item_layout.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + diff --git a/actionbarsherlock/res/layout/abs__list_menu_item_radio.xml b/actionbarsherlock/res/layout/abs__list_menu_item_radio.xml new file mode 100644 index 000000000..ff54bbecd --- /dev/null +++ b/actionbarsherlock/res/layout/abs__list_menu_item_radio.xml @@ -0,0 +1,24 @@ + + + + diff --git a/actionbarsherlock/res/layout/abs__popup_menu_item_layout.xml b/actionbarsherlock/res/layout/abs__popup_menu_item_layout.xml new file mode 100644 index 000000000..d42425ad3 --- /dev/null +++ b/actionbarsherlock/res/layout/abs__popup_menu_item_layout.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + diff --git a/actionbarsherlock/res/layout/abs__screen_action_bar.xml b/actionbarsherlock/res/layout/abs__screen_action_bar.xml new file mode 100644 index 000000000..1fb82fe9a --- /dev/null +++ b/actionbarsherlock/res/layout/abs__screen_action_bar.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + diff --git a/actionbarsherlock/res/layout/abs__screen_action_bar_overlay.xml b/actionbarsherlock/res/layout/abs__screen_action_bar_overlay.xml new file mode 100644 index 000000000..0961ef561 --- /dev/null +++ b/actionbarsherlock/res/layout/abs__screen_action_bar_overlay.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + diff --git a/actionbarsherlock/res/layout/abs__screen_simple.xml b/actionbarsherlock/res/layout/abs__screen_simple.xml new file mode 100644 index 000000000..33e2dea0d --- /dev/null +++ b/actionbarsherlock/res/layout/abs__screen_simple.xml @@ -0,0 +1,38 @@ + + + + + + + diff --git a/actionbarsherlock/res/layout/abs__screen_simple_overlay_action_mode.xml b/actionbarsherlock/res/layout/abs__screen_simple_overlay_action_mode.xml new file mode 100644 index 000000000..f8b9fb185 --- /dev/null +++ b/actionbarsherlock/res/layout/abs__screen_simple_overlay_action_mode.xml @@ -0,0 +1,38 @@ + + + + + + + diff --git a/actionbarsherlock/res/layout/sherlock_spinner_dropdown_item.xml b/actionbarsherlock/res/layout/sherlock_spinner_dropdown_item.xml new file mode 100644 index 000000000..a6c6252d2 --- /dev/null +++ b/actionbarsherlock/res/layout/sherlock_spinner_dropdown_item.xml @@ -0,0 +1,26 @@ + + + diff --git a/actionbarsherlock/res/layout/sherlock_spinner_item.xml b/actionbarsherlock/res/layout/sherlock_spinner_item.xml new file mode 100644 index 000000000..bea740178 --- /dev/null +++ b/actionbarsherlock/res/layout/sherlock_spinner_item.xml @@ -0,0 +1,26 @@ + + + diff --git a/actionbarsherlock/res/values-land/abs__dimens.xml b/actionbarsherlock/res/values-land/abs__dimens.xml new file mode 100644 index 000000000..502cc16a3 --- /dev/null +++ b/actionbarsherlock/res/values-land/abs__dimens.xml @@ -0,0 +1,33 @@ + + + + + 40dip + + 4dip + + 16dp + + 12dp + + -2dp + + 4dip + diff --git a/actionbarsherlock/res/values-large-hdpi-1024x600/abs__dimens.xml b/actionbarsherlock/res/values-large-hdpi-1024x600/abs__dimens.xml new file mode 100644 index 000000000..3312cfa7f --- /dev/null +++ b/actionbarsherlock/res/values-large-hdpi-1024x600/abs__dimens.xml @@ -0,0 +1,33 @@ + + + + + 48dip + + 8dip + + 18dp + + 14dp + + -3dp + + 5dip + diff --git a/actionbarsherlock/res/values-large-land-hdpi-1024x600/abs__dimens.xml b/actionbarsherlock/res/values-large-land-hdpi-1024x600/abs__dimens.xml new file mode 100644 index 000000000..502cc16a3 --- /dev/null +++ b/actionbarsherlock/res/values-large-land-hdpi-1024x600/abs__dimens.xml @@ -0,0 +1,33 @@ + + + + + 40dip + + 4dip + + 16dp + + 12dp + + -2dp + + 4dip + diff --git a/actionbarsherlock/res/values-large-land-mdpi-1024x600/abs__dimens.xml b/actionbarsherlock/res/values-large-land-mdpi-1024x600/abs__dimens.xml new file mode 100644 index 000000000..3312cfa7f --- /dev/null +++ b/actionbarsherlock/res/values-large-land-mdpi-1024x600/abs__dimens.xml @@ -0,0 +1,33 @@ + + + + + 48dip + + 8dip + + 18dp + + 14dp + + -3dp + + 5dip + diff --git a/actionbarsherlock/res/values-large-mdpi-1024x600/abs__dimens.xml b/actionbarsherlock/res/values-large-mdpi-1024x600/abs__dimens.xml new file mode 100644 index 000000000..35910333b --- /dev/null +++ b/actionbarsherlock/res/values-large-mdpi-1024x600/abs__dimens.xml @@ -0,0 +1,36 @@ + + + + + 56dip + + 4dip + + 18dp + + 14dp + + -3dp + + 9dip + + + 64dip + diff --git a/actionbarsherlock/res/values-large/abs__dimens.xml b/actionbarsherlock/res/values-large/abs__dimens.xml new file mode 100644 index 000000000..63b12f7f3 --- /dev/null +++ b/actionbarsherlock/res/values-large/abs__dimens.xml @@ -0,0 +1,29 @@ + + + + + 55% + + 80% + diff --git a/actionbarsherlock/res/values-sw600dp/abs__bools.xml b/actionbarsherlock/res/values-sw600dp/abs__bools.xml new file mode 100644 index 000000000..7a48e1542 --- /dev/null +++ b/actionbarsherlock/res/values-sw600dp/abs__bools.xml @@ -0,0 +1,19 @@ + + + + + false + diff --git a/actionbarsherlock/res/values-sw600dp/abs__dimens.xml b/actionbarsherlock/res/values-sw600dp/abs__dimens.xml new file mode 100644 index 000000000..f67853817 --- /dev/null +++ b/actionbarsherlock/res/values-sw600dp/abs__dimens.xml @@ -0,0 +1,38 @@ + + + + + 56dip + + 4dip + + 18dp + + 14dp + + -3dp + + 9dip + + 5 + + + 64dip + diff --git a/actionbarsherlock/res/values-v11/abs__themes.xml b/actionbarsherlock/res/values-v11/abs__themes.xml new file mode 100644 index 000000000..03473572c --- /dev/null +++ b/actionbarsherlock/res/values-v11/abs__themes.xml @@ -0,0 +1,12 @@ + + + + + + diff --git a/actionbarsherlock/res/values-v14/abs__styles.xml b/actionbarsherlock/res/values-v14/abs__styles.xml new file mode 100644 index 000000000..f2aa64d2d --- /dev/null +++ b/actionbarsherlock/res/values-v14/abs__styles.xml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/actionbarsherlock/res/values-v14/abs__themes.xml b/actionbarsherlock/res/values-v14/abs__themes.xml new file mode 100644 index 000000000..ceb960737 --- /dev/null +++ b/actionbarsherlock/res/values-v14/abs__themes.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + diff --git a/actionbarsherlock/res/values-w360dp/abs__dimens.xml b/actionbarsherlock/res/values-w360dp/abs__dimens.xml new file mode 100644 index 000000000..6f49d7e47 --- /dev/null +++ b/actionbarsherlock/res/values-w360dp/abs__dimens.xml @@ -0,0 +1,22 @@ + + + + 3 + diff --git a/actionbarsherlock/res/values-w480dp/abs__bools.xml b/actionbarsherlock/res/values-w480dp/abs__bools.xml new file mode 100644 index 000000000..3eaf4aee9 --- /dev/null +++ b/actionbarsherlock/res/values-w480dp/abs__bools.xml @@ -0,0 +1,22 @@ + + + + true + false + diff --git a/actionbarsherlock/res/values-w480dp/abs__config.xml b/actionbarsherlock/res/values-w480dp/abs__config.xml new file mode 100644 index 000000000..88357b0a7 --- /dev/null +++ b/actionbarsherlock/res/values-w480dp/abs__config.xml @@ -0,0 +1,29 @@ + + + + + + + + true + + diff --git a/actionbarsherlock/res/values-w500dp/abs__dimens.xml b/actionbarsherlock/res/values-w500dp/abs__dimens.xml new file mode 100644 index 000000000..2fd4deea2 --- /dev/null +++ b/actionbarsherlock/res/values-w500dp/abs__dimens.xml @@ -0,0 +1,22 @@ + + + + 4 + diff --git a/actionbarsherlock/res/values-w600dp/abs__dimens.xml b/actionbarsherlock/res/values-w600dp/abs__dimens.xml new file mode 100644 index 000000000..b085952d3 --- /dev/null +++ b/actionbarsherlock/res/values-w600dp/abs__dimens.xml @@ -0,0 +1,22 @@ + + + + 5 + diff --git a/actionbarsherlock/res/values-xlarge/abs__dimens.xml b/actionbarsherlock/res/values-xlarge/abs__dimens.xml new file mode 100644 index 000000000..bfc535de1 --- /dev/null +++ b/actionbarsherlock/res/values-xlarge/abs__dimens.xml @@ -0,0 +1,45 @@ + + + + + 56dip + + 4dip + + 18dp + + 14dp + + -3dp + + 9dip + + + 64dip + + + 45% + + 72% + diff --git a/actionbarsherlock/res/values/abs__attrs.xml b/actionbarsherlock/res/values/abs__attrs.xml new file mode 100644 index 000000000..bd5ee4404 --- /dev/null +++ b/actionbarsherlock/res/values/abs__attrs.xml @@ -0,0 +1,380 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/actionbarsherlock/res/values/abs__bools.xml b/actionbarsherlock/res/values/abs__bools.xml new file mode 100644 index 000000000..0b432448d --- /dev/null +++ b/actionbarsherlock/res/values/abs__bools.xml @@ -0,0 +1,22 @@ + + + + + false + true + true + + diff --git a/actionbarsherlock/res/values/abs__colors.xml b/actionbarsherlock/res/values/abs__colors.xml new file mode 100644 index 000000000..625c632ff --- /dev/null +++ b/actionbarsherlock/res/values/abs__colors.xml @@ -0,0 +1,27 @@ + + + + + #ff000000 + #fff3f3f3 + @color/abs__background_holo_light + @color/abs__background_holo_dark + #ff4c4c4c + #ffb2b2b2 + @color/abs__bright_foreground_holo_light + @color/abs__bright_foreground_holo_dark + #ff33b5e5 + diff --git a/actionbarsherlock/res/values/abs__config.xml b/actionbarsherlock/res/values/abs__config.xml new file mode 100644 index 000000000..4c7b5d459 --- /dev/null +++ b/actionbarsherlock/res/values/abs__config.xml @@ -0,0 +1,43 @@ + + + + + + + + 320dp + + + false + + + true + + + false + + diff --git a/actionbarsherlock/res/values/abs__dimens.xml b/actionbarsherlock/res/values/abs__dimens.xml new file mode 100644 index 000000000..0a409756c --- /dev/null +++ b/actionbarsherlock/res/values/abs__dimens.xml @@ -0,0 +1,50 @@ + + + + + 48dip + + 8dip + + 18dp + + 14dp + + -3dp + + 5dip + + 2 + + + 56dip + + + 64dip + + + 65% + + 95% + diff --git a/actionbarsherlock/res/values/abs__ids.xml b/actionbarsherlock/res/values/abs__ids.xml new file mode 100644 index 000000000..f9f56045b --- /dev/null +++ b/actionbarsherlock/res/values/abs__ids.xml @@ -0,0 +1,26 @@ + + + + + + + + + + diff --git a/actionbarsherlock/res/values/abs__strings.xml b/actionbarsherlock/res/values/abs__strings.xml new file mode 100644 index 000000000..1e1c7022c --- /dev/null +++ b/actionbarsherlock/res/values/abs__strings.xml @@ -0,0 +1,42 @@ + + + + + Navigate home + + Navigate up + + More options + + + Done + + + See all... + + Select activity + + Share with... + + Choose an application + + Share with + + Share with %s + diff --git a/actionbarsherlock/res/values/abs__styles.xml b/actionbarsherlock/res/values/abs__styles.xml new file mode 100644 index 000000000..8cbd36484 --- /dev/null +++ b/actionbarsherlock/res/values/abs__styles.xml @@ -0,0 +1,384 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/actionbarsherlock/res/values/abs__themes.xml b/actionbarsherlock/res/values/abs__themes.xml new file mode 100644 index 000000000..5300dedd6 --- /dev/null +++ b/actionbarsherlock/res/values/abs__themes.xml @@ -0,0 +1,226 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/actionbarsherlock/src/android/support/v4/app/_ActionBarSherlockTrojanHorse.java b/actionbarsherlock/src/android/support/v4/app/_ActionBarSherlockTrojanHorse.java new file mode 100644 index 000000000..3e3db62b7 --- /dev/null +++ b/actionbarsherlock/src/android/support/v4/app/_ActionBarSherlockTrojanHorse.java @@ -0,0 +1,144 @@ +package android.support.v4.app; + +import android.util.Log; +import android.view.View; +import android.view.Window; +import com.actionbarsherlock.ActionBarSherlock.OnCreatePanelMenuListener; +import com.actionbarsherlock.ActionBarSherlock.OnMenuItemSelectedListener; +import com.actionbarsherlock.ActionBarSherlock.OnPreparePanelListener; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; + +import java.util.ArrayList; + +/** I'm in ur package. Stealing ur variables. */ +public abstract class _ActionBarSherlockTrojanHorse extends FragmentActivity implements OnCreatePanelMenuListener, OnPreparePanelListener, OnMenuItemSelectedListener { + private static final boolean DEBUG = false; + private static final String TAG = "_ActionBarSherlockTrojanHorse"; + + /** Fragment interface for menu creation callback. */ + public interface OnCreateOptionsMenuListener { + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater); + } + /** Fragment interface for menu preparation callback. */ + public interface OnPrepareOptionsMenuListener { + public void onPrepareOptionsMenu(Menu menu); + } + /** Fragment interface for menu item selection callback. */ + public interface OnOptionsItemSelectedListener { + public boolean onOptionsItemSelected(MenuItem item); + } + + private ArrayList mCreatedMenus; + + + /////////////////////////////////////////////////////////////////////////// + // Sherlock menu handling + /////////////////////////////////////////////////////////////////////////// + + @Override + public boolean onCreatePanelMenu(int featureId, Menu menu) { + if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] featureId: " + featureId + ", menu: " + menu); + + if (featureId == Window.FEATURE_OPTIONS_PANEL) { + boolean result = onCreateOptionsMenu(menu); + if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] activity create result: " + result); + + MenuInflater inflater = getSupportMenuInflater(); + boolean show = false; + ArrayList newMenus = null; + if (mFragments.mActive != null) { + for (int i = 0; i < mFragments.mAdded.size(); i++) { + Fragment f = mFragments.mAdded.get(i); + if (f != null && !f.mHidden && f.mHasMenu && f.mMenuVisible && f instanceof OnCreateOptionsMenuListener) { + show = true; + ((OnCreateOptionsMenuListener)f).onCreateOptionsMenu(menu, inflater); + if (newMenus == null) { + newMenus = new ArrayList(); + } + newMenus.add(f); + } + } + } + + if (mCreatedMenus != null) { + for (int i = 0; i < mCreatedMenus.size(); i++) { + Fragment f = mCreatedMenus.get(i); + if (newMenus == null || !newMenus.contains(f)) { + f.onDestroyOptionsMenu(); + } + } + } + + mCreatedMenus = newMenus; + + if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] fragments create result: " + show); + result |= show; + + if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] returning " + result); + return result; + } + return false; + } + + @Override + public boolean onPreparePanel(int featureId, View view, Menu menu) { + if (DEBUG) Log.d(TAG, "[onPreparePanel] featureId: " + featureId + ", view: " + view + " menu: " + menu); + + if (featureId == Window.FEATURE_OPTIONS_PANEL) { + boolean result = onPrepareOptionsMenu(menu); + if (DEBUG) Log.d(TAG, "[onPreparePanel] activity prepare result: " + result); + + boolean show = false; + if (mFragments.mActive != null) { + for (int i = 0; i < mFragments.mAdded.size(); i++) { + Fragment f = mFragments.mAdded.get(i); + if (f != null && !f.mHidden && f.mHasMenu && f.mMenuVisible && f instanceof OnPrepareOptionsMenuListener) { + show = true; + ((OnPrepareOptionsMenuListener)f).onPrepareOptionsMenu(menu); + } + } + } + + if (DEBUG) Log.d(TAG, "[onPreparePanel] fragments prepare result: " + show); + result |= show; + + result &= menu.hasVisibleItems(); + if (DEBUG) Log.d(TAG, "[onPreparePanel] returning " + result); + return result; + } + return false; + } + + @Override + public boolean onMenuItemSelected(int featureId, MenuItem item) { + if (DEBUG) Log.d(TAG, "[onMenuItemSelected] featureId: " + featureId + ", item: " + item); + + if (featureId == Window.FEATURE_OPTIONS_PANEL) { + if (onOptionsItemSelected(item)) { + return true; + } + + if (mFragments.mActive != null) { + for (int i = 0; i < mFragments.mAdded.size(); i++) { + Fragment f = mFragments.mAdded.get(i); + if (f != null && !f.mHidden && f.mHasMenu && f.mMenuVisible && f instanceof OnOptionsItemSelectedListener) { + if (((OnOptionsItemSelectedListener)f).onOptionsItemSelected(item)) { + return true; + } + } + } + } + } + return false; + } + + public abstract boolean onCreateOptionsMenu(Menu menu); + + public abstract boolean onPrepareOptionsMenu(Menu menu); + + public abstract boolean onOptionsItemSelected(MenuItem item); + + public abstract MenuInflater getSupportMenuInflater(); +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/ActionBarSherlock.java b/actionbarsherlock/src/com/actionbarsherlock/ActionBarSherlock.java new file mode 100644 index 000000000..8340fb591 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/ActionBarSherlock.java @@ -0,0 +1,791 @@ +package com.actionbarsherlock; + +import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; +import java.util.Iterator; +import android.app.Activity; +import android.content.Context; +import android.content.res.Configuration; +import android.os.Build; +import android.os.Bundle; +import android.util.DisplayMetrics; +import android.util.Log; +import android.view.KeyEvent; +import android.view.View; +import android.view.ViewGroup; +import android.view.Window; +import com.actionbarsherlock.app.ActionBar; +import com.actionbarsherlock.internal.ActionBarSherlockCompat; +import com.actionbarsherlock.internal.ActionBarSherlockNative; +import com.actionbarsherlock.view.ActionMode; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; + +/** + *

Helper for implementing the action bar design pattern across all versions + * of Android.

+ * + *

This class will manage interaction with a custom action bar based on the + * Android 4.0 source code. The exposed API mirrors that of its native + * counterpart and you should refer to its documentation for instruction.

+ * + * @author Jake Wharton + */ +public abstract class ActionBarSherlock { + protected static final String TAG = "ActionBarSherlock"; + protected static final boolean DEBUG = false; + + private static final Class[] CONSTRUCTOR_ARGS = new Class[] { Activity.class, int.class }; + private static final HashMap> IMPLEMENTATIONS = + new HashMap>(); + + static { + //Register our two built-in implementations + registerImplementation(ActionBarSherlockCompat.class); + registerImplementation(ActionBarSherlockNative.class); + } + + + /** + *

Denotes an implementation of ActionBarSherlock which provides an + * action bar-enhanced experience.

+ */ + @Target(ElementType.TYPE) + @Retention(RetentionPolicy.RUNTIME) + public @interface Implementation { + static final int DEFAULT_API = -1; + static final int DEFAULT_DPI = -1; + + int api() default DEFAULT_API; + int dpi() default DEFAULT_DPI; + } + + + /** Activity interface for menu creation callback. */ + public interface OnCreatePanelMenuListener { + public boolean onCreatePanelMenu(int featureId, Menu menu); + } + /** Activity interface for menu creation callback. */ + public interface OnCreateOptionsMenuListener { + public boolean onCreateOptionsMenu(Menu menu); + } + /** Activity interface for menu item selection callback. */ + public interface OnMenuItemSelectedListener { + public boolean onMenuItemSelected(int featureId, MenuItem item); + } + /** Activity interface for menu item selection callback. */ + public interface OnOptionsItemSelectedListener { + public boolean onOptionsItemSelected(MenuItem item); + } + /** Activity interface for menu preparation callback. */ + public interface OnPreparePanelListener { + public boolean onPreparePanel(int featureId, View view, Menu menu); + } + /** Activity interface for menu preparation callback. */ + public interface OnPrepareOptionsMenuListener { + public boolean onPrepareOptionsMenu(Menu menu); + } + /** Activity interface for action mode finished callback. */ + public interface OnActionModeFinishedListener { + public void onActionModeFinished(ActionMode mode); + } + /** Activity interface for action mode started callback. */ + public interface OnActionModeStartedListener { + public void onActionModeStarted(ActionMode mode); + } + + + /** + * If set, the logic in these classes will assume that an {@link Activity} + * is dispatching all of the required events to the class. This flag should + * only be used internally or if you are creating your own base activity + * modeled after one of the included types (e.g., {@code SherlockActivity}). + */ + public static final int FLAG_DELEGATE = 1; + + + /** + * Register an ActionBarSherlock implementation. + * + * @param implementationClass Target implementation class which extends + * {@link ActionBarSherlock}. This class must also be annotated with + * {@link Implementation}. + */ + public static void registerImplementation(Class implementationClass) { + if (!implementationClass.isAnnotationPresent(Implementation.class)) { + throw new IllegalArgumentException("Class " + implementationClass.getSimpleName() + " is not annotated with @Implementation"); + } else if (IMPLEMENTATIONS.containsValue(implementationClass)) { + if (DEBUG) Log.w(TAG, "Class " + implementationClass.getSimpleName() + " already registered"); + return; + } + + Implementation impl = implementationClass.getAnnotation(Implementation.class); + if (DEBUG) Log.i(TAG, "Registering " + implementationClass.getSimpleName() + " with qualifier " + impl); + IMPLEMENTATIONS.put(impl, implementationClass); + } + + /** + * Unregister an ActionBarSherlock implementation. This should be + * considered very volatile and you should only use it if you know what + * you are doing. You have been warned. + * + * @param implementationClass Target implementation class. + * @return Boolean indicating whether the class was removed. + */ + public static boolean unregisterImplementation(Class implementationClass) { + return IMPLEMENTATIONS.values().remove(implementationClass); + } + + /** + * Wrap an activity with an action bar abstraction which will enable the + * use of a custom implementation on platforms where a native version does + * not exist. + * + * @param activity Activity to wrap. + * @return Instance to interact with the action bar. + */ + public static ActionBarSherlock wrap(Activity activity) { + return wrap(activity, 0); + } + + /** + * Wrap an activity with an action bar abstraction which will enable the + * use of a custom implementation on platforms where a native version does + * not exist. + * + * @param activity Owning activity. + * @param flags Option flags to control behavior. + * @return Instance to interact with the action bar. + */ + public static ActionBarSherlock wrap(Activity activity, int flags) { + //Create a local implementation map we can modify + HashMap> impls = + new HashMap>(IMPLEMENTATIONS); + boolean hasQualfier; + + /* DPI FILTERING */ + hasQualfier = false; + for (Implementation key : impls.keySet()) { + //Only honor TVDPI as a specific qualifier + if (key.dpi() == DisplayMetrics.DENSITY_TV) { + hasQualfier = true; + break; + } + } + if (hasQualfier) { + final boolean isTvDpi = activity.getResources().getDisplayMetrics().densityDpi == DisplayMetrics.DENSITY_TV; + for (Iterator keys = impls.keySet().iterator(); keys.hasNext(); ) { + int keyDpi = keys.next().dpi(); + if ((isTvDpi && keyDpi != DisplayMetrics.DENSITY_TV) + || (!isTvDpi && keyDpi == DisplayMetrics.DENSITY_TV)) { + keys.remove(); + } + } + } + + /* API FILTERING */ + hasQualfier = false; + for (Implementation key : impls.keySet()) { + if (key.api() != Implementation.DEFAULT_API) { + hasQualfier = true; + break; + } + } + if (hasQualfier) { + final int runtimeApi = Build.VERSION.SDK_INT; + int bestApi = 0; + for (Iterator keys = impls.keySet().iterator(); keys.hasNext(); ) { + int keyApi = keys.next().api(); + if (keyApi > runtimeApi) { + keys.remove(); + } else if (keyApi > bestApi) { + bestApi = keyApi; + } + } + for (Iterator keys = impls.keySet().iterator(); keys.hasNext(); ) { + if (keys.next().api() != bestApi) { + keys.remove(); + } + } + } + + if (impls.size() > 1) { + throw new IllegalStateException("More than one implementation matches configuration."); + } + if (impls.isEmpty()) { + throw new IllegalStateException("No implementations match configuration."); + } + Class impl = impls.values().iterator().next(); + if (DEBUG) Log.i(TAG, "Using implementation: " + impl.getSimpleName()); + + try { + Constructor ctor = impl.getConstructor(CONSTRUCTOR_ARGS); + return ctor.newInstance(activity, flags); + } catch (NoSuchMethodException e) { + throw new RuntimeException(e); + } catch (IllegalArgumentException e) { + throw new RuntimeException(e); + } catch (InstantiationException e) { + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } catch (InvocationTargetException e) { + throw new RuntimeException(e); + } + } + + + /** Activity which is displaying the action bar. Also used for context. */ + protected final Activity mActivity; + /** Whether delegating actions for the activity or managing ourselves. */ + protected final boolean mIsDelegate; + + /** Reference to our custom menu inflater which supports action items. */ + protected MenuInflater mMenuInflater; + + + + protected ActionBarSherlock(Activity activity, int flags) { + if (DEBUG) Log.d(TAG, "[] activity: " + activity + ", flags: " + flags); + + mActivity = activity; + mIsDelegate = (flags & FLAG_DELEGATE) != 0; + } + + + /** + * Get the current action bar instance. + * + * @return Action bar instance. + */ + public abstract ActionBar getActionBar(); + + + /////////////////////////////////////////////////////////////////////////// + // Lifecycle and interaction callbacks when delegating + /////////////////////////////////////////////////////////////////////////// + + /** + * Notify action bar of a configuration change event. Should be dispatched + * after the call to the superclass implementation. + * + *
+     * @Override
+     * public void onConfigurationChanged(Configuration newConfig) {
+     *     super.onConfigurationChanged(newConfig);
+     *     mSherlock.dispatchConfigurationChanged(newConfig);
+     * }
+     * 
+ * + * @param newConfig The new device configuration. + */ + public void dispatchConfigurationChanged(Configuration newConfig) {} + + /** + * Notify the action bar that the activity has finished its resuming. This + * should be dispatched after the call to the superclass implementation. + * + *
+     * @Override
+     * protected void onPostResume() {
+     *     super.onPostResume();
+     *     mSherlock.dispatchPostResume();
+     * }
+     * 
+ */ + public void dispatchPostResume() {} + + /** + * Notify the action bar that the activity is pausing. This should be + * dispatched before the call to the superclass implementation. + * + *
+     * @Override
+     * protected void onPause() {
+     *     mSherlock.dispatchPause();
+     *     super.onPause();
+     * }
+     * 
+ */ + public void dispatchPause() {} + + /** + * Notify the action bar that the activity is stopping. This should be + * called before the superclass implementation. + * + *

+ * @Override + * protected void onStop() { + * mSherlock.dispatchStop(); + * super.onStop(); + * } + *

+ */ + public void dispatchStop() {} + + /** + * Indicate that the menu should be recreated by calling + * {@link OnCreateOptionsMenuListener#onCreateOptionsMenu(com.actionbarsherlock.view.Menu)}. + */ + public abstract void dispatchInvalidateOptionsMenu(); + + /** + * Notify the action bar that it should display its overflow menu if it is + * appropriate for the device. The implementation should conditionally + * call the superclass method only if this method returns {@code false}. + * + *

+ * @Override + * public void openOptionsMenu() { + * if (!mSherlock.dispatchOpenOptionsMenu()) { + * super.openOptionsMenu(); + * } + * } + *

+ * + * @return {@code true} if the opening of the menu was handled internally. + */ + public boolean dispatchOpenOptionsMenu() { + return false; + } + + /** + * Notify the action bar that it should close its overflow menu if it is + * appropriate for the device. This implementation should conditionally + * call the superclass method only if this method returns {@code false}. + * + *
+     * @Override
+     * public void closeOptionsMenu() {
+     *     if (!mSherlock.dispatchCloseOptionsMenu()) {
+     *         super.closeOptionsMenu();
+     *     }
+     * }
+     * 
+ * + * @return {@code true} if the closing of the menu was handled internally. + */ + public boolean dispatchCloseOptionsMenu() { + return false; + } + + /** + * Notify the class that the activity has finished its creation. This + * should be called after the superclass implementation. + * + *
+     * @Override
+     * protected void onPostCreate(Bundle savedInstanceState) {
+     *     mSherlock.dispatchPostCreate(savedInstanceState);
+     *     super.onPostCreate(savedInstanceState);
+     * }
+     * 
+ * + * @param savedInstanceState If the activity is being re-initialized after + * previously being shut down then this Bundle + * contains the data it most recently supplied in + * {@link Activity#}onSaveInstanceState(Bundle)}. + * Note: Otherwise it is null. + */ + public void dispatchPostCreate(Bundle savedInstanceState) {} + + /** + * Notify the action bar that the title has changed and the action bar + * should be updated to reflect the change. This should be called before + * the superclass implementation. + * + *
+     *  @Override
+     *  protected void onTitleChanged(CharSequence title, int color) {
+     *      mSherlock.dispatchTitleChanged(title, color);
+     *      super.onTitleChanged(title, color);
+     *  }
+     * 
+ * + * @param title New activity title. + * @param color New activity color. + */ + public void dispatchTitleChanged(CharSequence title, int color) {} + + /** + * Notify the action bar the user has created a key event. This is used to + * toggle the display of the overflow action item with the menu key and to + * close the action mode or expanded action item with the back key. + * + *
+     * @Override
+     * public boolean dispatchKeyEvent(KeyEvent event) {
+     *     if (mSherlock.dispatchKeyEvent(event)) {
+     *         return true;
+     *     }
+     *     return super.dispatchKeyEvent(event);
+     * }
+     * 
+ * + * @param event Description of the key event. + * @return {@code true} if the event was handled. + */ + public boolean dispatchKeyEvent(KeyEvent event) { + return false; + } + + /** + * Notify the action bar that the Activity has triggered a menu creation + * which should happen on the conclusion of {@link Activity#onCreate}. This + * will be used to gain a reference to the native menu for native and + * overflow binding as well as to indicate when compatibility create should + * occur for the first time. + * + * @param menu Activity native menu. + * @return {@code true} since we always want to say that we have a native + */ + public abstract boolean dispatchCreateOptionsMenu(android.view.Menu menu); + + /** + * Notify the action bar that the Activity has triggered a menu preparation + * which usually means that the user has requested the overflow menu via a + * hardware menu key. You should return the result of this method call and + * not call the superclass implementation. + * + *

+ * @Override + * public final boolean onPrepareOptionsMenu(android.view.Menu menu) { + * return mSherlock.dispatchPrepareOptionsMenu(menu); + * } + *

+ * + * @param menu Activity native menu. + * @return {@code true} if menu display should proceed. + */ + public abstract boolean dispatchPrepareOptionsMenu(android.view.Menu menu); + + /** + * Notify the action bar that a native options menu item has been selected. + * The implementation should return the result of this method call. + * + *

+ * @Override + * public final boolean onOptionsItemSelected(android.view.MenuItem item) { + * return mSherlock.dispatchOptionsItemSelected(item); + * } + *

+ * + * @param item Options menu item. + * @return @{code true} if the selection was handled. + */ + public abstract boolean dispatchOptionsItemSelected(android.view.MenuItem item); + + /** + * Notify the action bar that the overflow menu has been opened. The + * implementation should conditionally return {@code true} if this method + * returns {@code true}, otherwise return the result of the superclass + * method. + * + *

+ * @Override + * public final boolean onMenuOpened(int featureId, android.view.Menu menu) { + * if (mSherlock.dispatchMenuOpened(featureId, menu)) { + * return true; + * } + * return super.onMenuOpened(featureId, menu); + * } + *

+ * + * @param featureId Window feature which triggered the event. + * @param menu Activity native menu. + * @return {@code true} if the event was handled by this method. + */ + public boolean dispatchMenuOpened(int featureId, android.view.Menu menu) { + return false; + } + + /** + * Notify the action bar that the overflow menu has been closed. This + * method should be called before the superclass implementation. + * + *

+ * @Override + * public void onPanelClosed(int featureId, android.view.Menu menu) { + * mSherlock.dispatchPanelClosed(featureId, menu); + * super.onPanelClosed(featureId, menu); + * } + *

+ * + * @param featureId + * @param menu + */ + public void dispatchPanelClosed(int featureId, android.view.Menu menu) {} + + /** + * Notify the action bar that the activity has been destroyed. This method + * should be called before the superclass implementation. + * + *

+ * @Override + * public void onDestroy() { + * mSherlock.dispatchDestroy(); + * super.onDestroy(); + * } + *

+ */ + public void dispatchDestroy() {} + + + /////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// + + + /** + * Internal method to trigger the menu creation process. + * + * @return {@code true} if menu creation should proceed. + */ + protected final boolean callbackCreateOptionsMenu(Menu menu) { + if (DEBUG) Log.d(TAG, "[callbackCreateOptionsMenu] menu: " + menu); + + boolean result = true; + if (mActivity instanceof OnCreatePanelMenuListener) { + OnCreatePanelMenuListener listener = (OnCreatePanelMenuListener)mActivity; + result = listener.onCreatePanelMenu(Window.FEATURE_OPTIONS_PANEL, menu); + } else if (mActivity instanceof OnCreateOptionsMenuListener) { + OnCreateOptionsMenuListener listener = (OnCreateOptionsMenuListener)mActivity; + result = listener.onCreateOptionsMenu(menu); + } + + if (DEBUG) Log.d(TAG, "[callbackCreateOptionsMenu] returning " + result); + return result; + } + + /** + * Internal method to trigger the menu preparation process. + * + * @return {@code true} if menu preparation should proceed. + */ + protected final boolean callbackPrepareOptionsMenu(Menu menu) { + if (DEBUG) Log.d(TAG, "[callbackPrepareOptionsMenu] menu: " + menu); + + boolean result = true; + if (mActivity instanceof OnPreparePanelListener) { + OnPreparePanelListener listener = (OnPreparePanelListener)mActivity; + result = listener.onPreparePanel(Window.FEATURE_OPTIONS_PANEL, null, menu); + } else if (mActivity instanceof OnPrepareOptionsMenuListener) { + OnPrepareOptionsMenuListener listener = (OnPrepareOptionsMenuListener)mActivity; + result = listener.onPrepareOptionsMenu(menu); + } + + if (DEBUG) Log.d(TAG, "[callbackPrepareOptionsMenu] returning " + result); + return result; + } + + /** + * Internal method for dispatching options menu selection to the owning + * activity callback. + * + * @param item Selected options menu item. + * @return {@code true} if the item selection was handled in the callback. + */ + protected final boolean callbackOptionsItemSelected(MenuItem item) { + if (DEBUG) Log.d(TAG, "[callbackOptionsItemSelected] item: " + item.getTitleCondensed()); + + boolean result = false; + if (mActivity instanceof OnMenuItemSelectedListener) { + OnMenuItemSelectedListener listener = (OnMenuItemSelectedListener)mActivity; + result = listener.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, item); + } else if (mActivity instanceof OnOptionsItemSelectedListener) { + OnOptionsItemSelectedListener listener = (OnOptionsItemSelectedListener)mActivity; + result = listener.onOptionsItemSelected(item); + } + + if (DEBUG) Log.d(TAG, "[callbackOptionsItemSelected] returning " + result); + return result; + } + + + /////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// + + + /** + * Query for the availability of a certain feature. + * + * @param featureId The feature ID to check. + * @return {@code true} if feature is enabled, {@code false} otherwise. + */ + public abstract boolean hasFeature(int featureId); + + /** + * Enable extended screen features. This must be called before + * {@code setContentView()}. May be called as many times as desired as long + * as it is before {@code setContentView()}. If not called, no extended + * features will be available. You can not turn off a feature once it is + * requested. + * + * @param featureId The desired features, defined as constants by Window. + * @return Returns true if the requested feature is supported and now + * enabled. + */ + public abstract boolean requestFeature(int featureId); + + /** + * Set extra options that will influence the UI for this window. + * + * @param uiOptions Flags specifying extra options for this window. + */ + public abstract void setUiOptions(int uiOptions); + + /** + * Set extra options that will influence the UI for this window. Only the + * bits filtered by mask will be modified. + * + * @param uiOptions Flags specifying extra options for this window. + * @param mask Flags specifying which options should be modified. Others + * will remain unchanged. + */ + public abstract void setUiOptions(int uiOptions, int mask); + + /** + * Set the content of the activity inside the action bar. + * + * @param layoutResId Layout resource ID. + */ + public abstract void setContentView(int layoutResId); + + /** + * Set the content of the activity inside the action bar. + * + * @param view The desired content to display. + */ + public void setContentView(View view) { + if (DEBUG) Log.d(TAG, "[setContentView] view: " + view); + + setContentView(view, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)); + } + + /** + * Set the content of the activity inside the action bar. + * + * @param view The desired content to display. + * @param params Layout parameters to apply to the view. + */ + public abstract void setContentView(View view, ViewGroup.LayoutParams params); + + /** + * Variation on {@link #setContentView(android.view.View, android.view.ViewGroup.LayoutParams)} + * to add an additional content view to the screen. Added after any + * existing ones on the screen -- existing views are NOT removed. + * + * @param view The desired content to display. + * @param params Layout parameters for the view. + */ + public abstract void addContentView(View view, ViewGroup.LayoutParams params); + + /** + * Change the title associated with this activity. + */ + public abstract void setTitle(CharSequence title); + + /** + * Change the title associated with this activity. + */ + public void setTitle(int resId) { + if (DEBUG) Log.d(TAG, "[setTitle] resId: " + resId); + + setTitle(mActivity.getString(resId)); + } + + /** + * Sets the visibility of the progress bar in the title. + *

+ * In order for the progress bar to be shown, the feature must be requested + * via {@link #requestWindowFeature(int)}. + * + * @param visible Whether to show the progress bars in the title. + */ + public abstract void setProgressBarVisibility(boolean visible); + + /** + * Sets the visibility of the indeterminate progress bar in the title. + *

+ * In order for the progress bar to be shown, the feature must be requested + * via {@link #requestWindowFeature(int)}. + * + * @param visible Whether to show the progress bars in the title. + */ + public abstract void setProgressBarIndeterminateVisibility(boolean visible); + + /** + * Sets whether the horizontal progress bar in the title should be indeterminate (the circular + * is always indeterminate). + *

+ * In order for the progress bar to be shown, the feature must be requested + * via {@link #requestWindowFeature(int)}. + * + * @param indeterminate Whether the horizontal progress bar should be indeterminate. + */ + public abstract void setProgressBarIndeterminate(boolean indeterminate); + + /** + * Sets the progress for the progress bars in the title. + *

+ * In order for the progress bar to be shown, the feature must be requested + * via {@link #requestWindowFeature(int)}. + * + * @param progress The progress for the progress bar. Valid ranges are from + * 0 to 10000 (both inclusive). If 10000 is given, the progress + * bar will be completely filled and will fade out. + */ + public abstract void setProgress(int progress); + + /** + * Sets the secondary progress for the progress bar in the title. This + * progress is drawn between the primary progress (set via + * {@link #setProgress(int)} and the background. It can be ideal for media + * scenarios such as showing the buffering progress while the default + * progress shows the play progress. + *

+ * In order for the progress bar to be shown, the feature must be requested + * via {@link #requestWindowFeature(int)}. + * + * @param secondaryProgress The secondary progress for the progress bar. Valid ranges are from + * 0 to 10000 (both inclusive). + */ + public abstract void setSecondaryProgress(int secondaryProgress); + + /** + * Get a menu inflater instance which supports the newer menu attributes. + * + * @return Menu inflater instance. + */ + public MenuInflater getMenuInflater() { + if (DEBUG) Log.d(TAG, "[getMenuInflater]"); + + // Make sure that action views can get an appropriate theme. + if (mMenuInflater == null) { + if (getActionBar() != null) { + mMenuInflater = new MenuInflater(getThemedContext()); + } else { + mMenuInflater = new MenuInflater(mActivity); + } + } + return mMenuInflater; + } + + protected abstract Context getThemedContext(); + + /** + * Start an action mode. + * + * @param callback Callback that will manage lifecycle events for this + * context mode. + * @return The ContextMode that was started, or null if it was canceled. + * @see ActionMode + */ + public abstract ActionMode startActionMode(ActionMode.Callback callback); +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/app/ActionBar.java b/actionbarsherlock/src/com/actionbarsherlock/app/ActionBar.java new file mode 100644 index 000000000..2497d24ff --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/app/ActionBar.java @@ -0,0 +1,947 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.app; + +import android.content.Context; +import android.graphics.drawable.Drawable; +import android.support.v4.app.FragmentTransaction; +import android.util.AttributeSet; +import android.view.Gravity; +import android.view.View; +import android.view.ViewDebug; +import android.view.ViewGroup; +import android.view.ViewGroup.MarginLayoutParams; +import android.widget.SpinnerAdapter; + +/** + * A window feature at the top of the activity that may display the activity title, navigation + * modes, and other interactive items. + *

Beginning with Android 3.0 (API level 11), the action bar appears at the top of an + * activity's window when the activity uses the system's {@link + * android.R.style#Theme_Holo Holo} theme (or one of its descendant themes), which is the default. + * You may otherwise add the action bar by calling {@link + * android.view.Window#requestFeature requestFeature(FEATURE_ACTION_BAR)} or by declaring it in a + * custom theme with the {@link android.R.styleable#Theme_windowActionBar windowActionBar} property. + *

By default, the action bar shows the application icon on + * the left, followed by the activity title. If your activity has an options menu, you can make + * select items accessible directly from the action bar as "action items". You can also + * modify various characteristics of the action bar or remove it completely.

+ *

From your activity, you can retrieve an instance of {@link ActionBar} by calling {@link + * android.app.Activity#getActionBar getActionBar()}.

+ *

In some cases, the action bar may be overlayed by another bar that enables contextual actions, + * using an {@link android.view.ActionMode}. For example, when the user selects one or more items in + * your activity, you can enable an action mode that offers actions specific to the selected + * items, with a UI that temporarily replaces the action bar. Although the UI may occupy the + * same space, the {@link android.view.ActionMode} APIs are distinct and independent from those for + * {@link ActionBar}. + *

+ *

Developer Guides

+ *

For information about how to use the action bar, including how to add action items, navigation + * modes and more, read the Action + * Bar developer guide.

+ *
+ */ +public abstract class ActionBar { + /** + * Standard navigation mode. Consists of either a logo or icon + * and title text with an optional subtitle. Clicking any of these elements + * will dispatch onOptionsItemSelected to the host Activity with + * a MenuItem with item ID android.R.id.home. + */ + public static final int NAVIGATION_MODE_STANDARD = android.app.ActionBar.NAVIGATION_MODE_STANDARD; + + /** + * List navigation mode. Instead of static title text this mode + * presents a list menu for navigation within the activity. + * e.g. this might be presented to the user as a dropdown list. + */ + public static final int NAVIGATION_MODE_LIST = android.app.ActionBar.NAVIGATION_MODE_LIST; + + /** + * Tab navigation mode. Instead of static title text this mode + * presents a series of tabs for navigation within the activity. + */ + public static final int NAVIGATION_MODE_TABS = android.app.ActionBar.NAVIGATION_MODE_TABS; + + /** + * Use logo instead of icon if available. This flag will cause appropriate + * navigation modes to use a wider logo in place of the standard icon. + * + * @see #setDisplayOptions(int) + * @see #setDisplayOptions(int, int) + */ + public static final int DISPLAY_USE_LOGO = android.app.ActionBar.DISPLAY_USE_LOGO; + + /** + * Show 'home' elements in this action bar, leaving more space for other + * navigation elements. This includes logo and icon. + * + * @see #setDisplayOptions(int) + * @see #setDisplayOptions(int, int) + */ + public static final int DISPLAY_SHOW_HOME = android.app.ActionBar.DISPLAY_SHOW_HOME; + + /** + * Display the 'home' element such that it appears as an 'up' affordance. + * e.g. show an arrow to the left indicating the action that will be taken. + * + * Set this flag if selecting the 'home' button in the action bar to return + * up by a single level in your UI rather than back to the top level or front page. + * + *

Setting this option will implicitly enable interaction with the home/up + * button. See {@link #setHomeButtonEnabled(boolean)}. + * + * @see #setDisplayOptions(int) + * @see #setDisplayOptions(int, int) + */ + public static final int DISPLAY_HOME_AS_UP = android.app.ActionBar.DISPLAY_HOME_AS_UP; + + /** + * Show the activity title and subtitle, if present. + * + * @see #setTitle(CharSequence) + * @see #setTitle(int) + * @see #setSubtitle(CharSequence) + * @see #setSubtitle(int) + * @see #setDisplayOptions(int) + * @see #setDisplayOptions(int, int) + */ + public static final int DISPLAY_SHOW_TITLE = android.app.ActionBar.DISPLAY_SHOW_TITLE; + + /** + * Show the custom view if one has been set. + * @see #setCustomView(View) + * @see #setDisplayOptions(int) + * @see #setDisplayOptions(int, int) + */ + public static final int DISPLAY_SHOW_CUSTOM = android.app.ActionBar.DISPLAY_SHOW_CUSTOM; + + /** + * Set the action bar into custom navigation mode, supplying a view + * for custom navigation. + * + * Custom navigation views appear between the application icon and + * any action buttons and may use any space available there. Common + * use cases for custom navigation views might include an auto-suggesting + * address bar for a browser or other navigation mechanisms that do not + * translate well to provided navigation modes. + * + * @param view Custom navigation view to place in the ActionBar. + */ + public abstract void setCustomView(View view); + + /** + * Set the action bar into custom navigation mode, supplying a view + * for custom navigation. + * + *

Custom navigation views appear between the application icon and + * any action buttons and may use any space available there. Common + * use cases for custom navigation views might include an auto-suggesting + * address bar for a browser or other navigation mechanisms that do not + * translate well to provided navigation modes.

+ * + *

The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for + * the custom view to be displayed.

+ * + * @param view Custom navigation view to place in the ActionBar. + * @param layoutParams How this custom view should layout in the bar. + * + * @see #setDisplayOptions(int, int) + */ + public abstract void setCustomView(View view, LayoutParams layoutParams); + + /** + * Set the action bar into custom navigation mode, supplying a view + * for custom navigation. + * + *

Custom navigation views appear between the application icon and + * any action buttons and may use any space available there. Common + * use cases for custom navigation views might include an auto-suggesting + * address bar for a browser or other navigation mechanisms that do not + * translate well to provided navigation modes.

+ * + *

The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for + * the custom view to be displayed.

+ * + * @param resId Resource ID of a layout to inflate into the ActionBar. + * + * @see #setDisplayOptions(int, int) + */ + public abstract void setCustomView(int resId); + + /** + * Set the icon to display in the 'home' section of the action bar. + * The action bar will use an icon specified by its style or the + * activity icon by default. + * + * Whether the home section shows an icon or logo is controlled + * by the display option {@link #DISPLAY_USE_LOGO}. + * + * @param resId Resource ID of a drawable to show as an icon. + * + * @see #setDisplayUseLogoEnabled(boolean) + * @see #setDisplayShowHomeEnabled(boolean) + */ + public abstract void setIcon(int resId); + + /** + * Set the icon to display in the 'home' section of the action bar. + * The action bar will use an icon specified by its style or the + * activity icon by default. + * + * Whether the home section shows an icon or logo is controlled + * by the display option {@link #DISPLAY_USE_LOGO}. + * + * @param icon Drawable to show as an icon. + * + * @see #setDisplayUseLogoEnabled(boolean) + * @see #setDisplayShowHomeEnabled(boolean) + */ + public abstract void setIcon(Drawable icon); + + /** + * Set the logo to display in the 'home' section of the action bar. + * The action bar will use a logo specified by its style or the + * activity logo by default. + * + * Whether the home section shows an icon or logo is controlled + * by the display option {@link #DISPLAY_USE_LOGO}. + * + * @param resId Resource ID of a drawable to show as a logo. + * + * @see #setDisplayUseLogoEnabled(boolean) + * @see #setDisplayShowHomeEnabled(boolean) + */ + public abstract void setLogo(int resId); + + /** + * Set the logo to display in the 'home' section of the action bar. + * The action bar will use a logo specified by its style or the + * activity logo by default. + * + * Whether the home section shows an icon or logo is controlled + * by the display option {@link #DISPLAY_USE_LOGO}. + * + * @param logo Drawable to show as a logo. + * + * @see #setDisplayUseLogoEnabled(boolean) + * @see #setDisplayShowHomeEnabled(boolean) + */ + public abstract void setLogo(Drawable logo); + + /** + * Set the adapter and navigation callback for list navigation mode. + * + * The supplied adapter will provide views for the expanded list as well as + * the currently selected item. (These may be displayed differently.) + * + * The supplied OnNavigationListener will alert the application when the user + * changes the current list selection. + * + * @param adapter An adapter that will provide views both to display + * the current navigation selection and populate views + * within the dropdown navigation menu. + * @param callback An OnNavigationListener that will receive events when the user + * selects a navigation item. + */ + public abstract void setListNavigationCallbacks(SpinnerAdapter adapter, + OnNavigationListener callback); + + /** + * Set the selected navigation item in list or tabbed navigation modes. + * + * @param position Position of the item to select. + */ + public abstract void setSelectedNavigationItem(int position); + + /** + * Get the position of the selected navigation item in list or tabbed navigation modes. + * + * @return Position of the selected item. + */ + public abstract int getSelectedNavigationIndex(); + + /** + * Get the number of navigation items present in the current navigation mode. + * + * @return Number of navigation items. + */ + public abstract int getNavigationItemCount(); + + /** + * Set the action bar's title. This will only be displayed if + * {@link #DISPLAY_SHOW_TITLE} is set. + * + * @param title Title to set + * + * @see #setTitle(int) + * @see #setDisplayOptions(int, int) + */ + public abstract void setTitle(CharSequence title); + + /** + * Set the action bar's title. This will only be displayed if + * {@link #DISPLAY_SHOW_TITLE} is set. + * + * @param resId Resource ID of title string to set + * + * @see #setTitle(CharSequence) + * @see #setDisplayOptions(int, int) + */ + public abstract void setTitle(int resId); + + /** + * Set the action bar's subtitle. This will only be displayed if + * {@link #DISPLAY_SHOW_TITLE} is set. Set to null to disable the + * subtitle entirely. + * + * @param subtitle Subtitle to set + * + * @see #setSubtitle(int) + * @see #setDisplayOptions(int, int) + */ + public abstract void setSubtitle(CharSequence subtitle); + + /** + * Set the action bar's subtitle. This will only be displayed if + * {@link #DISPLAY_SHOW_TITLE} is set. + * + * @param resId Resource ID of subtitle string to set + * + * @see #setSubtitle(CharSequence) + * @see #setDisplayOptions(int, int) + */ + public abstract void setSubtitle(int resId); + + /** + * Set display options. This changes all display option bits at once. To change + * a limited subset of display options, see {@link #setDisplayOptions(int, int)}. + * + * @param options A combination of the bits defined by the DISPLAY_ constants + * defined in ActionBar. + */ + public abstract void setDisplayOptions(int options); + + /** + * Set selected display options. Only the options specified by mask will be changed. + * To change all display option bits at once, see {@link #setDisplayOptions(int)}. + * + *

Example: setDisplayOptions(0, DISPLAY_SHOW_HOME) will disable the + * {@link #DISPLAY_SHOW_HOME} option. + * setDisplayOptions(DISPLAY_SHOW_HOME, DISPLAY_SHOW_HOME | DISPLAY_USE_LOGO) + * will enable {@link #DISPLAY_SHOW_HOME} and disable {@link #DISPLAY_USE_LOGO}. + * + * @param options A combination of the bits defined by the DISPLAY_ constants + * defined in ActionBar. + * @param mask A bit mask declaring which display options should be changed. + */ + public abstract void setDisplayOptions(int options, int mask); + + /** + * Set whether to display the activity logo rather than the activity icon. + * A logo is often a wider, more detailed image. + * + *

To set several display options at once, see the setDisplayOptions methods. + * + * @param useLogo true to use the activity logo, false to use the activity icon. + * + * @see #setDisplayOptions(int) + * @see #setDisplayOptions(int, int) + */ + public abstract void setDisplayUseLogoEnabled(boolean useLogo); + + /** + * Set whether to include the application home affordance in the action bar. + * Home is presented as either an activity icon or logo. + * + *

To set several display options at once, see the setDisplayOptions methods. + * + * @param showHome true to show home, false otherwise. + * + * @see #setDisplayOptions(int) + * @see #setDisplayOptions(int, int) + */ + public abstract void setDisplayShowHomeEnabled(boolean showHome); + + /** + * Set whether home should be displayed as an "up" affordance. + * Set this to true if selecting "home" returns up by a single level in your UI + * rather than back to the top level or front page. + * + *

To set several display options at once, see the setDisplayOptions methods. + * + * @param showHomeAsUp true to show the user that selecting home will return one + * level up rather than to the top level of the app. + * + * @see #setDisplayOptions(int) + * @see #setDisplayOptions(int, int) + */ + public abstract void setDisplayHomeAsUpEnabled(boolean showHomeAsUp); + + /** + * Set whether an activity title/subtitle should be displayed. + * + *

To set several display options at once, see the setDisplayOptions methods. + * + * @param showTitle true to display a title/subtitle if present. + * + * @see #setDisplayOptions(int) + * @see #setDisplayOptions(int, int) + */ + public abstract void setDisplayShowTitleEnabled(boolean showTitle); + + /** + * Set whether a custom view should be displayed, if set. + * + *

To set several display options at once, see the setDisplayOptions methods. + * + * @param showCustom true if the currently set custom view should be displayed, false otherwise. + * + * @see #setDisplayOptions(int) + * @see #setDisplayOptions(int, int) + */ + public abstract void setDisplayShowCustomEnabled(boolean showCustom); + + /** + * Set the ActionBar's background. This will be used for the primary + * action bar. + * + * @param d Background drawable + * @see #setStackedBackgroundDrawable(Drawable) + * @see #setSplitBackgroundDrawable(Drawable) + */ + public abstract void setBackgroundDrawable(Drawable d); + + /** + * Set the ActionBar's stacked background. This will appear + * in the second row/stacked bar on some devices and configurations. + * + * @param d Background drawable for the stacked row + */ + public void setStackedBackgroundDrawable(Drawable d) { } + + /** + * Set the ActionBar's split background. This will appear in + * the split action bar containing menu-provided action buttons + * on some devices and configurations. + *

You can enable split action bar with {@link android.R.attr#uiOptions} + * + * @param d Background drawable for the split bar + */ + public void setSplitBackgroundDrawable(Drawable d) { } + + /** + * @return The current custom view. + */ + public abstract View getCustomView(); + + /** + * Returns the current ActionBar title in standard mode. + * Returns null if {@link #getNavigationMode()} would not return + * {@link #NAVIGATION_MODE_STANDARD}. + * + * @return The current ActionBar title or null. + */ + public abstract CharSequence getTitle(); + + /** + * Returns the current ActionBar subtitle in standard mode. + * Returns null if {@link #getNavigationMode()} would not return + * {@link #NAVIGATION_MODE_STANDARD}. + * + * @return The current ActionBar subtitle or null. + */ + public abstract CharSequence getSubtitle(); + + /** + * Returns the current navigation mode. The result will be one of: + *

    + *
  • {@link #NAVIGATION_MODE_STANDARD}
  • + *
  • {@link #NAVIGATION_MODE_LIST}
  • + *
  • {@link #NAVIGATION_MODE_TABS}
  • + *
+ * + * @return The current navigation mode. + */ + public abstract int getNavigationMode(); + + /** + * Set the current navigation mode. + * + * @param mode The new mode to set. + * @see #NAVIGATION_MODE_STANDARD + * @see #NAVIGATION_MODE_LIST + * @see #NAVIGATION_MODE_TABS + */ + public abstract void setNavigationMode(int mode); + + /** + * @return The current set of display options. + */ + public abstract int getDisplayOptions(); + + /** + * Create and return a new {@link Tab}. + * This tab will not be included in the action bar until it is added. + * + *

Very often tabs will be used to switch between {@link Fragment} + * objects. Here is a typical implementation of such tabs:

+ * + * {@sample development/samples/ApiDemos/src/com/example/android/apis/app/FragmentTabs.java + * complete} + * + * @return A new Tab + * + * @see #addTab(Tab) + */ + public abstract Tab newTab(); + + /** + * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list. + * If this is the first tab to be added it will become the selected tab. + * + * @param tab Tab to add + */ + public abstract void addTab(Tab tab); + + /** + * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list. + * + * @param tab Tab to add + * @param setSelected True if the added tab should become the selected tab. + */ + public abstract void addTab(Tab tab, boolean setSelected); + + /** + * Add a tab for use in tabbed navigation mode. The tab will be inserted at + * position. If this is the first tab to be added it will become + * the selected tab. + * + * @param tab The tab to add + * @param position The new position of the tab + */ + public abstract void addTab(Tab tab, int position); + + /** + * Add a tab for use in tabbed navigation mode. The tab will be insterted at + * position. + * + * @param tab The tab to add + * @param position The new position of the tab + * @param setSelected True if the added tab should become the selected tab. + */ + public abstract void addTab(Tab tab, int position, boolean setSelected); + + /** + * Remove a tab from the action bar. If the removed tab was selected it will be deselected + * and another tab will be selected if present. + * + * @param tab The tab to remove + */ + public abstract void removeTab(Tab tab); + + /** + * Remove a tab from the action bar. If the removed tab was selected it will be deselected + * and another tab will be selected if present. + * + * @param position Position of the tab to remove + */ + public abstract void removeTabAt(int position); + + /** + * Remove all tabs from the action bar and deselect the current tab. + */ + public abstract void removeAllTabs(); + + /** + * Select the specified tab. If it is not a child of this action bar it will be added. + * + *

Note: If you want to select by index, use {@link #setSelectedNavigationItem(int)}.

+ * + * @param tab Tab to select + */ + public abstract void selectTab(Tab tab); + + /** + * Returns the currently selected tab if in tabbed navigation mode and there is at least + * one tab present. + * + * @return The currently selected tab or null + */ + public abstract Tab getSelectedTab(); + + /** + * Returns the tab at the specified index. + * + * @param index Index value in the range 0-get + * @return + */ + public abstract Tab getTabAt(int index); + + /** + * Returns the number of tabs currently registered with the action bar. + * @return Tab count + */ + public abstract int getTabCount(); + + /** + * Retrieve the current height of the ActionBar. + * + * @return The ActionBar's height + */ + public abstract int getHeight(); + + /** + * Show the ActionBar if it is not currently showing. + * If the window hosting the ActionBar does not have the feature + * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application + * content to fit the new space available. + */ + public abstract void show(); + + /** + * Hide the ActionBar if it is currently showing. + * If the window hosting the ActionBar does not have the feature + * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application + * content to fit the new space available. + */ + public abstract void hide(); + + /** + * @return true if the ActionBar is showing, false otherwise. + */ + public abstract boolean isShowing(); + + /** + * Add a listener that will respond to menu visibility change events. + * + * @param listener The new listener to add + */ + public abstract void addOnMenuVisibilityListener(OnMenuVisibilityListener listener); + + /** + * Remove a menu visibility listener. This listener will no longer receive menu + * visibility change events. + * + * @param listener A listener to remove that was previously added + */ + public abstract void removeOnMenuVisibilityListener(OnMenuVisibilityListener listener); + + /** + * Enable or disable the "home" button in the corner of the action bar. (Note that this + * is the application home/up affordance on the action bar, not the systemwide home + * button.) + * + *

This defaults to true for packages targeting < API 14. For packages targeting + * API 14 or greater, the application should call this method to enable interaction + * with the home/up affordance. + * + *

Setting the {@link #DISPLAY_HOME_AS_UP} display option will automatically enable + * the home button. + * + * @param enabled true to enable the home button, false to disable the home button. + */ + public void setHomeButtonEnabled(boolean enabled) { } + + /** + * Returns a {@link Context} with an appropriate theme for creating views that + * will appear in the action bar. If you are inflating or instantiating custom views + * that will appear in an action bar, you should use the Context returned by this method. + * (This includes adapters used for list navigation mode.) + * This will ensure that views contrast properly against the action bar. + * + * @return A themed Context for creating views + */ + public Context getThemedContext() { return null; } + + /** + * Listener interface for ActionBar navigation events. + */ + public interface OnNavigationListener { + /** + * This method is called whenever a navigation item in your action bar + * is selected. + * + * @param itemPosition Position of the item clicked. + * @param itemId ID of the item clicked. + * @return True if the event was handled, false otherwise. + */ + public boolean onNavigationItemSelected(int itemPosition, long itemId); + } + + /** + * Listener for receiving events when action bar menus are shown or hidden. + */ + public interface OnMenuVisibilityListener { + /** + * Called when an action bar menu is shown or hidden. Applications may want to use + * this to tune auto-hiding behavior for the action bar or pause/resume video playback, + * gameplay, or other activity within the main content area. + * + * @param isVisible True if an action bar menu is now visible, false if no action bar + * menus are visible. + */ + public void onMenuVisibilityChanged(boolean isVisible); + } + + /** + * A tab in the action bar. + * + *

Tabs manage the hiding and showing of {@link Fragment}s. + */ + public static abstract class Tab { + /** + * An invalid position for a tab. + * + * @see #getPosition() + */ + public static final int INVALID_POSITION = -1; + + /** + * Return the current position of this tab in the action bar. + * + * @return Current position, or {@link #INVALID_POSITION} if this tab is not currently in + * the action bar. + */ + public abstract int getPosition(); + + /** + * Return the icon associated with this tab. + * + * @return The tab's icon + */ + public abstract Drawable getIcon(); + + /** + * Return the text of this tab. + * + * @return The tab's text + */ + public abstract CharSequence getText(); + + /** + * Set the icon displayed on this tab. + * + * @param icon The drawable to use as an icon + * @return The current instance for call chaining + */ + public abstract Tab setIcon(Drawable icon); + + /** + * Set the icon displayed on this tab. + * + * @param resId Resource ID referring to the drawable to use as an icon + * @return The current instance for call chaining + */ + public abstract Tab setIcon(int resId); + + /** + * Set the text displayed on this tab. Text may be truncated if there is not + * room to display the entire string. + * + * @param text The text to display + * @return The current instance for call chaining + */ + public abstract Tab setText(CharSequence text); + + /** + * Set the text displayed on this tab. Text may be truncated if there is not + * room to display the entire string. + * + * @param resId A resource ID referring to the text that should be displayed + * @return The current instance for call chaining + */ + public abstract Tab setText(int resId); + + /** + * Set a custom view to be used for this tab. This overrides values set by + * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}. + * + * @param view Custom view to be used as a tab. + * @return The current instance for call chaining + */ + public abstract Tab setCustomView(View view); + + /** + * Set a custom view to be used for this tab. This overrides values set by + * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}. + * + * @param layoutResId A layout resource to inflate and use as a custom tab view + * @return The current instance for call chaining + */ + public abstract Tab setCustomView(int layoutResId); + + /** + * Retrieve a previously set custom view for this tab. + * + * @return The custom view set by {@link #setCustomView(View)}. + */ + public abstract View getCustomView(); + + /** + * Give this Tab an arbitrary object to hold for later use. + * + * @param obj Object to store + * @return The current instance for call chaining + */ + public abstract Tab setTag(Object obj); + + /** + * @return This Tab's tag object. + */ + public abstract Object getTag(); + + /** + * Set the {@link TabListener} that will handle switching to and from this tab. + * All tabs must have a TabListener set before being added to the ActionBar. + * + * @param listener Listener to handle tab selection events + * @return The current instance for call chaining + */ + public abstract Tab setTabListener(TabListener listener); + + /** + * Select this tab. Only valid if the tab has been added to the action bar. + */ + public abstract void select(); + + /** + * Set a description of this tab's content for use in accessibility support. + * If no content description is provided the title will be used. + * + * @param resId A resource ID referring to the description text + * @return The current instance for call chaining + * @see #setContentDescription(CharSequence) + * @see #getContentDescription() + */ + public abstract Tab setContentDescription(int resId); + + /** + * Set a description of this tab's content for use in accessibility support. + * If no content description is provided the title will be used. + * + * @param contentDesc Description of this tab's content + * @return The current instance for call chaining + * @see #setContentDescription(int) + * @see #getContentDescription() + */ + public abstract Tab setContentDescription(CharSequence contentDesc); + + /** + * Gets a brief description of this tab's content for use in accessibility support. + * + * @return Description of this tab's content + * @see #setContentDescription(CharSequence) + * @see #setContentDescription(int) + */ + public abstract CharSequence getContentDescription(); + } + + /** + * Callback interface invoked when a tab is focused, unfocused, added, or removed. + */ + public interface TabListener { + /** + * Called when a tab enters the selected state. + * + * @param tab The tab that was selected + * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute + * during a tab switch. The previous tab's unselect and this tab's select will be + * executed in a single transaction. This FragmentTransaction does not support + * being added to the back stack. + */ + public void onTabSelected(Tab tab, FragmentTransaction ft); + + /** + * Called when a tab exits the selected state. + * + * @param tab The tab that was unselected + * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute + * during a tab switch. This tab's unselect and the newly selected tab's select + * will be executed in a single transaction. This FragmentTransaction does not + * support being added to the back stack. + */ + public void onTabUnselected(Tab tab, FragmentTransaction ft); + + /** + * Called when a tab that is already selected is chosen again by the user. + * Some applications may use this action to return to the top level of a category. + * + * @param tab The tab that was reselected. + * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute + * once this method returns. This FragmentTransaction does not support + * being added to the back stack. + */ + public void onTabReselected(Tab tab, FragmentTransaction ft); + } + + /** + * Per-child layout information associated with action bar custom views. + * + * @attr ref android.R.styleable#ActionBar_LayoutParams_layout_gravity + */ + public static class LayoutParams extends MarginLayoutParams { + /** + * Gravity for the view associated with these LayoutParams. + * + * @see android.view.Gravity + */ + @ViewDebug.ExportedProperty(mapping = { + @ViewDebug.IntToString(from = -1, to = "NONE"), + @ViewDebug.IntToString(from = Gravity.NO_GRAVITY, to = "NONE"), + @ViewDebug.IntToString(from = Gravity.TOP, to = "TOP"), + @ViewDebug.IntToString(from = Gravity.BOTTOM, to = "BOTTOM"), + @ViewDebug.IntToString(from = Gravity.LEFT, to = "LEFT"), + @ViewDebug.IntToString(from = Gravity.RIGHT, to = "RIGHT"), + @ViewDebug.IntToString(from = Gravity.CENTER_VERTICAL, to = "CENTER_VERTICAL"), + @ViewDebug.IntToString(from = Gravity.FILL_VERTICAL, to = "FILL_VERTICAL"), + @ViewDebug.IntToString(from = Gravity.CENTER_HORIZONTAL, to = "CENTER_HORIZONTAL"), + @ViewDebug.IntToString(from = Gravity.FILL_HORIZONTAL, to = "FILL_HORIZONTAL"), + @ViewDebug.IntToString(from = Gravity.CENTER, to = "CENTER"), + @ViewDebug.IntToString(from = Gravity.FILL, to = "FILL") + }) + public int gravity = -1; + + public LayoutParams(Context c, AttributeSet attrs) { + super(c, attrs); + } + + public LayoutParams(int width, int height) { + super(width, height); + this.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT; + } + + public LayoutParams(int width, int height, int gravity) { + super(width, height); + this.gravity = gravity; + } + + public LayoutParams(int gravity) { + this(WRAP_CONTENT, FILL_PARENT, gravity); + } + + public LayoutParams(LayoutParams source) { + super(source); + + this.gravity = source.gravity; + } + + public LayoutParams(ViewGroup.LayoutParams source) { + super(source); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockActivity.java b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockActivity.java new file mode 100644 index 000000000..9cb57e95a --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockActivity.java @@ -0,0 +1,259 @@ +package com.actionbarsherlock.app; + +import android.app.Activity; +import android.content.res.Configuration; +import android.os.Bundle; +import android.view.KeyEvent; +import android.view.View; +import android.view.Window; +import android.view.ViewGroup.LayoutParams; +import com.actionbarsherlock.ActionBarSherlock; +import com.actionbarsherlock.ActionBarSherlock.OnActionModeFinishedListener; +import com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListener; +import com.actionbarsherlock.ActionBarSherlock.OnCreatePanelMenuListener; +import com.actionbarsherlock.ActionBarSherlock.OnMenuItemSelectedListener; +import com.actionbarsherlock.ActionBarSherlock.OnPreparePanelListener; +import com.actionbarsherlock.view.ActionMode; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; + +public abstract class SherlockActivity extends Activity implements OnCreatePanelMenuListener, OnPreparePanelListener, OnMenuItemSelectedListener, OnActionModeStartedListener, OnActionModeFinishedListener { + private ActionBarSherlock mSherlock; + + protected final ActionBarSherlock getSherlock() { + if (mSherlock == null) { + mSherlock = ActionBarSherlock.wrap(this, ActionBarSherlock.FLAG_DELEGATE); + } + return mSherlock; + } + + + /////////////////////////////////////////////////////////////////////////// + // Action bar and mode + /////////////////////////////////////////////////////////////////////////// + + public ActionBar getSupportActionBar() { + return getSherlock().getActionBar(); + } + + public ActionMode startActionMode(ActionMode.Callback callback) { + return getSherlock().startActionMode(callback); + } + + @Override + public void onActionModeStarted(ActionMode mode) {} + + @Override + public void onActionModeFinished(ActionMode mode) {} + + + /////////////////////////////////////////////////////////////////////////// + // General lifecycle/callback dispatching + /////////////////////////////////////////////////////////////////////////// + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + getSherlock().dispatchConfigurationChanged(newConfig); + } + + @Override + protected void onPostResume() { + super.onPostResume(); + getSherlock().dispatchPostResume(); + } + + @Override + protected void onPause() { + getSherlock().dispatchPause(); + super.onPause(); + } + + @Override + protected void onStop() { + getSherlock().dispatchStop(); + super.onStop(); + } + + @Override + protected void onDestroy() { + getSherlock().dispatchDestroy(); + super.onDestroy(); + } + + @Override + protected void onPostCreate(Bundle savedInstanceState) { + getSherlock().dispatchPostCreate(savedInstanceState); + super.onPostCreate(savedInstanceState); + } + + @Override + protected void onTitleChanged(CharSequence title, int color) { + getSherlock().dispatchTitleChanged(title, color); + super.onTitleChanged(title, color); + } + + @Override + public final boolean onMenuOpened(int featureId, android.view.Menu menu) { + if (getSherlock().dispatchMenuOpened(featureId, menu)) { + return true; + } + return super.onMenuOpened(featureId, menu); + } + + @Override + public void onPanelClosed(int featureId, android.view.Menu menu) { + getSherlock().dispatchPanelClosed(featureId, menu); + super.onPanelClosed(featureId, menu); + } + + @Override + public boolean dispatchKeyEvent(KeyEvent event) { + if (getSherlock().dispatchKeyEvent(event)) { + return true; + } + return super.dispatchKeyEvent(event); + } + + + /////////////////////////////////////////////////////////////////////////// + // Native menu handling + /////////////////////////////////////////////////////////////////////////// + + public MenuInflater getSupportMenuInflater() { + return getSherlock().getMenuInflater(); + } + + public void invalidateOptionsMenu() { + getSherlock().dispatchInvalidateOptionsMenu(); + } + + public void supportInvalidateOptionsMenu() { + invalidateOptionsMenu(); + } + + @Override + public final boolean onCreateOptionsMenu(android.view.Menu menu) { + return getSherlock().dispatchCreateOptionsMenu(menu); + } + + @Override + public final boolean onPrepareOptionsMenu(android.view.Menu menu) { + return getSherlock().dispatchPrepareOptionsMenu(menu); + } + + @Override + public final boolean onOptionsItemSelected(android.view.MenuItem item) { + return getSherlock().dispatchOptionsItemSelected(item); + } + + @Override + public void openOptionsMenu() { + if (!getSherlock().dispatchOpenOptionsMenu()) { + super.openOptionsMenu(); + } + } + + @Override + public void closeOptionsMenu() { + if (!getSherlock().dispatchCloseOptionsMenu()) { + super.closeOptionsMenu(); + } + } + + + /////////////////////////////////////////////////////////////////////////// + // Sherlock menu handling + /////////////////////////////////////////////////////////////////////////// + + @Override + public boolean onCreatePanelMenu(int featureId, Menu menu) { + if (featureId == Window.FEATURE_OPTIONS_PANEL) { + return onCreateOptionsMenu(menu); + } + return false; + } + + public boolean onCreateOptionsMenu(Menu menu) { + return true; + } + + @Override + public boolean onPreparePanel(int featureId, View view, Menu menu) { + if (featureId == Window.FEATURE_OPTIONS_PANEL) { + return onPrepareOptionsMenu(menu); + } + return false; + } + + public boolean onPrepareOptionsMenu(Menu menu) { + return true; + } + + @Override + public boolean onMenuItemSelected(int featureId, MenuItem item) { + if (featureId == Window.FEATURE_OPTIONS_PANEL) { + return onOptionsItemSelected(item); + } + return false; + } + + public boolean onOptionsItemSelected(MenuItem item) { + return false; + } + + + /////////////////////////////////////////////////////////////////////////// + // Content + /////////////////////////////////////////////////////////////////////////// + + @Override + public void addContentView(View view, LayoutParams params) { + getSherlock().addContentView(view, params); + } + + @Override + public void setContentView(int layoutResId) { + getSherlock().setContentView(layoutResId); + } + + @Override + public void setContentView(View view, LayoutParams params) { + getSherlock().setContentView(view, params); + } + + @Override + public void setContentView(View view) { + getSherlock().setContentView(view); + } + + public void requestWindowFeature(long featureId) { + getSherlock().requestFeature((int)featureId); + } + + + /////////////////////////////////////////////////////////////////////////// + // Progress Indication + /////////////////////////////////////////////////////////////////////////// + + public void setSupportProgress(int progress) { + getSherlock().setProgress(progress); + } + + public void setSupportProgressBarIndeterminate(boolean indeterminate) { + getSherlock().setProgressBarIndeterminate(indeterminate); + } + + public void setSupportProgressBarIndeterminateVisibility(boolean visible) { + getSherlock().setProgressBarIndeterminateVisibility(visible); + } + + public void setSupportProgressBarVisibility(boolean visible) { + getSherlock().setProgressBarVisibility(visible); + } + + public void setSupportSecondaryProgress(int secondaryProgress) { + getSherlock().setSecondaryProgress(secondaryProgress); + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockDialogFragment.java b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockDialogFragment.java new file mode 100644 index 000000000..a7c856bf0 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockDialogFragment.java @@ -0,0 +1,68 @@ +package com.actionbarsherlock.app; + +import android.app.Activity; +import android.support.v4.app.DialogFragment; +import com.actionbarsherlock.internal.view.menu.MenuItemWrapper; +import com.actionbarsherlock.internal.view.menu.MenuWrapper; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; + +import static com.actionbarsherlock.app.SherlockFragmentActivity.OnCreateOptionsMenuListener; +import static com.actionbarsherlock.app.SherlockFragmentActivity.OnOptionsItemSelectedListener; +import static com.actionbarsherlock.app.SherlockFragmentActivity.OnPrepareOptionsMenuListener; + +public class SherlockDialogFragment extends DialogFragment implements OnCreateOptionsMenuListener, OnPrepareOptionsMenuListener, OnOptionsItemSelectedListener { + private SherlockFragmentActivity mActivity; + + public SherlockFragmentActivity getSherlockActivity() { + return mActivity; + } + + @Override + public void onAttach(Activity activity) { + if (!(activity instanceof SherlockFragmentActivity)) { + throw new IllegalStateException(getClass().getSimpleName() + " must be attached to a SherlockFragmentActivity."); + } + mActivity = (SherlockFragmentActivity)activity; + + super.onAttach(activity); + } + + @Override + public void onDetach() { + mActivity = null; + super.onDetach(); + } + + @Override + public final void onCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater) { + onCreateOptionsMenu(new MenuWrapper(menu), mActivity.getSupportMenuInflater()); + } + + @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + //Nothing to see here. + } + + @Override + public final void onPrepareOptionsMenu(android.view.Menu menu) { + onPrepareOptionsMenu(new MenuWrapper(menu)); + } + + @Override + public void onPrepareOptionsMenu(Menu menu) { + //Nothing to see here. + } + + @Override + public final boolean onOptionsItemSelected(android.view.MenuItem item) { + return onOptionsItemSelected(new MenuItemWrapper(item)); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + //Nothing to see here. + return false; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockExpandableListActivity.java b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockExpandableListActivity.java new file mode 100644 index 000000000..078f9b0ca --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockExpandableListActivity.java @@ -0,0 +1,259 @@ +package com.actionbarsherlock.app; + +import android.app.ExpandableListActivity; +import android.content.res.Configuration; +import android.os.Bundle; +import android.view.KeyEvent; +import android.view.View; +import android.view.ViewGroup.LayoutParams; +import android.view.Window; +import com.actionbarsherlock.ActionBarSherlock; +import com.actionbarsherlock.ActionBarSherlock.OnActionModeFinishedListener; +import com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListener; +import com.actionbarsherlock.ActionBarSherlock.OnCreatePanelMenuListener; +import com.actionbarsherlock.ActionBarSherlock.OnMenuItemSelectedListener; +import com.actionbarsherlock.ActionBarSherlock.OnPreparePanelListener; +import com.actionbarsherlock.view.ActionMode; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; + +public abstract class SherlockExpandableListActivity extends ExpandableListActivity implements OnCreatePanelMenuListener, OnPreparePanelListener, OnMenuItemSelectedListener, OnActionModeStartedListener, OnActionModeFinishedListener { + private ActionBarSherlock mSherlock; + + protected final ActionBarSherlock getSherlock() { + if (mSherlock == null) { + mSherlock = ActionBarSherlock.wrap(this, ActionBarSherlock.FLAG_DELEGATE); + } + return mSherlock; + } + + + /////////////////////////////////////////////////////////////////////////// + // Action bar and mode + /////////////////////////////////////////////////////////////////////////// + + public ActionBar getSupportActionBar() { + return getSherlock().getActionBar(); + } + + public ActionMode startActionMode(ActionMode.Callback callback) { + return getSherlock().startActionMode(callback); + } + + @Override + public void onActionModeStarted(ActionMode mode) {} + + @Override + public void onActionModeFinished(ActionMode mode) {} + + + /////////////////////////////////////////////////////////////////////////// + // General lifecycle/callback dispatching + /////////////////////////////////////////////////////////////////////////// + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + getSherlock().dispatchConfigurationChanged(newConfig); + } + + @Override + protected void onPostResume() { + super.onPostResume(); + getSherlock().dispatchPostResume(); + } + + @Override + protected void onPause() { + getSherlock().dispatchPause(); + super.onPause(); + } + + @Override + protected void onStop() { + getSherlock().dispatchStop(); + super.onStop(); + } + + @Override + protected void onDestroy() { + getSherlock().dispatchDestroy(); + super.onDestroy(); + } + + @Override + protected void onPostCreate(Bundle savedInstanceState) { + getSherlock().dispatchPostCreate(savedInstanceState); + super.onPostCreate(savedInstanceState); + } + + @Override + protected void onTitleChanged(CharSequence title, int color) { + getSherlock().dispatchTitleChanged(title, color); + super.onTitleChanged(title, color); + } + + @Override + public final boolean onMenuOpened(int featureId, android.view.Menu menu) { + if (getSherlock().dispatchMenuOpened(featureId, menu)) { + return true; + } + return super.onMenuOpened(featureId, menu); + } + + @Override + public void onPanelClosed(int featureId, android.view.Menu menu) { + getSherlock().dispatchPanelClosed(featureId, menu); + super.onPanelClosed(featureId, menu); + } + + @Override + public boolean dispatchKeyEvent(KeyEvent event) { + if (getSherlock().dispatchKeyEvent(event)) { + return true; + } + return super.dispatchKeyEvent(event); + } + + + /////////////////////////////////////////////////////////////////////////// + // Native menu handling + /////////////////////////////////////////////////////////////////////////// + + public MenuInflater getSupportMenuInflater() { + return getSherlock().getMenuInflater(); + } + + public void invalidateOptionsMenu() { + getSherlock().dispatchInvalidateOptionsMenu(); + } + + public void supportInvalidateOptionsMenu() { + invalidateOptionsMenu(); + } + + @Override + public final boolean onCreateOptionsMenu(android.view.Menu menu) { + return getSherlock().dispatchCreateOptionsMenu(menu); + } + + @Override + public final boolean onPrepareOptionsMenu(android.view.Menu menu) { + return getSherlock().dispatchPrepareOptionsMenu(menu); + } + + @Override + public final boolean onOptionsItemSelected(android.view.MenuItem item) { + return getSherlock().dispatchOptionsItemSelected(item); + } + + @Override + public void openOptionsMenu() { + if (!getSherlock().dispatchOpenOptionsMenu()) { + super.openOptionsMenu(); + } + } + + @Override + public void closeOptionsMenu() { + if (!getSherlock().dispatchCloseOptionsMenu()) { + super.closeOptionsMenu(); + } + } + + + /////////////////////////////////////////////////////////////////////////// + // Sherlock menu handling + /////////////////////////////////////////////////////////////////////////// + + @Override + public boolean onCreatePanelMenu(int featureId, Menu menu) { + if (featureId == Window.FEATURE_OPTIONS_PANEL) { + return onCreateOptionsMenu(menu); + } + return false; + } + + public boolean onCreateOptionsMenu(Menu menu) { + return true; + } + + @Override + public boolean onPreparePanel(int featureId, View view, Menu menu) { + if (featureId == Window.FEATURE_OPTIONS_PANEL) { + return onPrepareOptionsMenu(menu); + } + return false; + } + + public boolean onPrepareOptionsMenu(Menu menu) { + return true; + } + + @Override + public boolean onMenuItemSelected(int featureId, MenuItem item) { + if (featureId == Window.FEATURE_OPTIONS_PANEL) { + return onOptionsItemSelected(item); + } + return false; + } + + public boolean onOptionsItemSelected(MenuItem item) { + return false; + } + + + /////////////////////////////////////////////////////////////////////////// + // Content + /////////////////////////////////////////////////////////////////////////// + + @Override + public void addContentView(View view, LayoutParams params) { + getSherlock().addContentView(view, params); + } + + @Override + public void setContentView(int layoutResId) { + getSherlock().setContentView(layoutResId); + } + + @Override + public void setContentView(View view, LayoutParams params) { + getSherlock().setContentView(view, params); + } + + @Override + public void setContentView(View view) { + getSherlock().setContentView(view); + } + + public void requestWindowFeature(long featureId) { + getSherlock().requestFeature((int)featureId); + } + + + /////////////////////////////////////////////////////////////////////////// + // Progress Indication + /////////////////////////////////////////////////////////////////////////// + + public void setSupportProgress(int progress) { + getSherlock().setProgress(progress); + } + + public void setSupportProgressBarIndeterminate(boolean indeterminate) { + getSherlock().setProgressBarIndeterminate(indeterminate); + } + + public void setSupportProgressBarIndeterminateVisibility(boolean visible) { + getSherlock().setProgressBarIndeterminateVisibility(visible); + } + + public void setSupportProgressBarVisibility(boolean visible) { + getSherlock().setProgressBarVisibility(visible); + } + + public void setSupportSecondaryProgress(int secondaryProgress) { + getSherlock().setSecondaryProgress(secondaryProgress); + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockFragment.java b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockFragment.java new file mode 100644 index 000000000..0f24e9c85 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockFragment.java @@ -0,0 +1,68 @@ +package com.actionbarsherlock.app; + +import android.app.Activity; +import android.support.v4.app.Fragment; +import com.actionbarsherlock.internal.view.menu.MenuItemWrapper; +import com.actionbarsherlock.internal.view.menu.MenuWrapper; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; + +import static com.actionbarsherlock.app.SherlockFragmentActivity.OnCreateOptionsMenuListener; +import static com.actionbarsherlock.app.SherlockFragmentActivity.OnOptionsItemSelectedListener; +import static com.actionbarsherlock.app.SherlockFragmentActivity.OnPrepareOptionsMenuListener; + +public class SherlockFragment extends Fragment implements OnCreateOptionsMenuListener, OnPrepareOptionsMenuListener, OnOptionsItemSelectedListener { + private SherlockFragmentActivity mActivity; + + public SherlockFragmentActivity getSherlockActivity() { + return mActivity; + } + + @Override + public void onAttach(Activity activity) { + if (!(activity instanceof SherlockFragmentActivity)) { + throw new IllegalStateException(getClass().getSimpleName() + " must be attached to a SherlockFragmentActivity."); + } + mActivity = (SherlockFragmentActivity)activity; + + super.onAttach(activity); + } + + @Override + public void onDetach() { + mActivity = null; + super.onDetach(); + } + + @Override + public final void onCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater) { + onCreateOptionsMenu(new MenuWrapper(menu), mActivity.getSupportMenuInflater()); + } + + @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + //Nothing to see here. + } + + @Override + public final void onPrepareOptionsMenu(android.view.Menu menu) { + onPrepareOptionsMenu(new MenuWrapper(menu)); + } + + @Override + public void onPrepareOptionsMenu(Menu menu) { + //Nothing to see here. + } + + @Override + public final boolean onOptionsItemSelected(android.view.MenuItem item) { + return onOptionsItemSelected(new MenuItemWrapper(item)); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + //Nothing to see here. + return false; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockFragmentActivity.java b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockFragmentActivity.java new file mode 100644 index 000000000..5cd13ba7c --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockFragmentActivity.java @@ -0,0 +1,292 @@ +package com.actionbarsherlock.app; + +import android.content.res.Configuration; +import android.os.Bundle; +import android.support.v4.app._ActionBarSherlockTrojanHorse; +import android.util.Log; +import android.view.KeyEvent; +import android.view.View; +import android.view.ViewGroup.LayoutParams; +import android.view.Window; +import com.actionbarsherlock.ActionBarSherlock; +import com.actionbarsherlock.view.ActionMode; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; + +import static com.actionbarsherlock.ActionBarSherlock.OnActionModeFinishedListener; +import static com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListener; + +/** @see {@link _ActionBarSherlockTrojanHorse} */ +public class SherlockFragmentActivity extends _ActionBarSherlockTrojanHorse implements OnActionModeStartedListener, OnActionModeFinishedListener { + private static final boolean DEBUG = false; + private static final String TAG = "SherlockFragmentActivity"; + + private ActionBarSherlock mSherlock; + private boolean mIgnoreNativeCreate = false; + private boolean mIgnoreNativePrepare = false; + private boolean mIgnoreNativeSelected = false; + + protected final ActionBarSherlock getSherlock() { + if (mSherlock == null) { + mSherlock = ActionBarSherlock.wrap(this, ActionBarSherlock.FLAG_DELEGATE); + } + return mSherlock; + } + + + /////////////////////////////////////////////////////////////////////////// + // Action bar and mode + /////////////////////////////////////////////////////////////////////////// + + public ActionBar getSupportActionBar() { + return getSherlock().getActionBar(); + } + + public ActionMode startActionMode(ActionMode.Callback callback) { + return getSherlock().startActionMode(callback); + } + + @Override + public void onActionModeStarted(ActionMode mode) {} + + @Override + public void onActionModeFinished(ActionMode mode) {} + + + /////////////////////////////////////////////////////////////////////////// + // General lifecycle/callback dispatching + /////////////////////////////////////////////////////////////////////////// + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + getSherlock().dispatchConfigurationChanged(newConfig); + } + + @Override + protected void onPostResume() { + super.onPostResume(); + getSherlock().dispatchPostResume(); + } + + @Override + protected void onPause() { + getSherlock().dispatchPause(); + super.onPause(); + } + + @Override + protected void onStop() { + getSherlock().dispatchStop(); + super.onStop(); + } + + @Override + protected void onDestroy() { + getSherlock().dispatchDestroy(); + super.onDestroy(); + } + + @Override + protected void onPostCreate(Bundle savedInstanceState) { + getSherlock().dispatchPostCreate(savedInstanceState); + super.onPostCreate(savedInstanceState); + } + + @Override + protected void onTitleChanged(CharSequence title, int color) { + getSherlock().dispatchTitleChanged(title, color); + super.onTitleChanged(title, color); + } + + @Override + public final boolean onMenuOpened(int featureId, android.view.Menu menu) { + if (getSherlock().dispatchMenuOpened(featureId, menu)) { + return true; + } + return super.onMenuOpened(featureId, menu); + } + + @Override + public void onPanelClosed(int featureId, android.view.Menu menu) { + getSherlock().dispatchPanelClosed(featureId, menu); + super.onPanelClosed(featureId, menu); + } + + @Override + public boolean dispatchKeyEvent(KeyEvent event) { + if (getSherlock().dispatchKeyEvent(event)) { + return true; + } + return super.dispatchKeyEvent(event); + } + + + /////////////////////////////////////////////////////////////////////////// + // Native menu handling + /////////////////////////////////////////////////////////////////////////// + + public MenuInflater getSupportMenuInflater() { + if (DEBUG) Log.d(TAG, "[getSupportMenuInflater]"); + + return getSherlock().getMenuInflater(); + } + + public void invalidateOptionsMenu() { + if (DEBUG) Log.d(TAG, "[invalidateOptionsMenu]"); + + getSherlock().dispatchInvalidateOptionsMenu(); + } + + public void supportInvalidateOptionsMenu() { + if (DEBUG) Log.d(TAG, "[supportInvalidateOptionsMenu]"); + + invalidateOptionsMenu(); + } + + @Override + public final boolean onCreatePanelMenu(int featureId, android.view.Menu menu) { + if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] featureId: " + featureId + ", menu: " + menu); + + if (featureId == Window.FEATURE_OPTIONS_PANEL && !mIgnoreNativeCreate) { + mIgnoreNativeCreate = true; + boolean result = getSherlock().dispatchCreateOptionsMenu(menu); + mIgnoreNativeCreate = false; + + if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] returning " + result); + return result; + } + return super.onCreatePanelMenu(featureId, menu); + } + + @Override + public final boolean onCreateOptionsMenu(android.view.Menu menu) { + return true; + } + + @Override + public final boolean onPreparePanel(int featureId, View view, android.view.Menu menu) { + if (DEBUG) Log.d(TAG, "[onPreparePanel] featureId: " + featureId + ", view: " + view + ", menu: " + menu); + + if (featureId == Window.FEATURE_OPTIONS_PANEL && !mIgnoreNativePrepare) { + mIgnoreNativePrepare = true; + boolean result = getSherlock().dispatchPrepareOptionsMenu(menu); + mIgnoreNativePrepare = false; + + if (DEBUG) Log.d(TAG, "[onPreparePanel] returning " + result); + return result; + } + return super.onPreparePanel(featureId, view, menu); + } + + @Override + public final boolean onPrepareOptionsMenu(android.view.Menu menu) { + return true; + } + + @Override + public final boolean onMenuItemSelected(int featureId, android.view.MenuItem item) { + if (DEBUG) Log.d(TAG, "[onMenuItemSelected] featureId: " + featureId + ", item: " + item); + + if (featureId == Window.FEATURE_OPTIONS_PANEL && !mIgnoreNativeSelected) { + mIgnoreNativeSelected = true; + boolean result = getSherlock().dispatchOptionsItemSelected(item); + mIgnoreNativeSelected = false; + + if (DEBUG) Log.d(TAG, "[onMenuItemSelected] returning " + result); + return result; + } + return super.onMenuItemSelected(featureId, item); + } + + @Override + public final boolean onOptionsItemSelected(android.view.MenuItem item) { + return false; + } + + @Override + public void openOptionsMenu() { + if (!getSherlock().dispatchOpenOptionsMenu()) { + super.openOptionsMenu(); + } + } + + @Override + public void closeOptionsMenu() { + if (!getSherlock().dispatchCloseOptionsMenu()) { + super.closeOptionsMenu(); + } + } + + + /////////////////////////////////////////////////////////////////////////// + // Sherlock menu handling + /////////////////////////////////////////////////////////////////////////// + + public boolean onCreateOptionsMenu(Menu menu) { + return true; + } + + public boolean onPrepareOptionsMenu(Menu menu) { + return true; + } + + public boolean onOptionsItemSelected(MenuItem item) { + return false; + } + + + /////////////////////////////////////////////////////////////////////////// + // Content + /////////////////////////////////////////////////////////////////////////// + + @Override + public void addContentView(View view, LayoutParams params) { + getSherlock().addContentView(view, params); + } + + @Override + public void setContentView(int layoutResId) { + getSherlock().setContentView(layoutResId); + } + + @Override + public void setContentView(View view, LayoutParams params) { + getSherlock().setContentView(view, params); + } + + @Override + public void setContentView(View view) { + getSherlock().setContentView(view); + } + + public void requestWindowFeature(long featureId) { + getSherlock().requestFeature((int)featureId); + } + + + /////////////////////////////////////////////////////////////////////////// + // Progress Indication + /////////////////////////////////////////////////////////////////////////// + + public void setSupportProgress(int progress) { + getSherlock().setProgress(progress); + } + + public void setSupportProgressBarIndeterminate(boolean indeterminate) { + getSherlock().setProgressBarIndeterminate(indeterminate); + } + + public void setSupportProgressBarIndeterminateVisibility(boolean visible) { + getSherlock().setProgressBarIndeterminateVisibility(visible); + } + + public void setSupportProgressBarVisibility(boolean visible) { + getSherlock().setProgressBarVisibility(visible); + } + + public void setSupportSecondaryProgress(int secondaryProgress) { + getSherlock().setSecondaryProgress(secondaryProgress); + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockListActivity.java b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockListActivity.java new file mode 100644 index 000000000..00c00fee5 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockListActivity.java @@ -0,0 +1,259 @@ +package com.actionbarsherlock.app; + +import android.app.ListActivity; +import android.content.res.Configuration; +import android.os.Bundle; +import android.view.KeyEvent; +import android.view.View; +import android.view.Window; +import android.view.ViewGroup.LayoutParams; +import com.actionbarsherlock.ActionBarSherlock; +import com.actionbarsherlock.ActionBarSherlock.OnActionModeFinishedListener; +import com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListener; +import com.actionbarsherlock.ActionBarSherlock.OnCreatePanelMenuListener; +import com.actionbarsherlock.ActionBarSherlock.OnMenuItemSelectedListener; +import com.actionbarsherlock.ActionBarSherlock.OnPreparePanelListener; +import com.actionbarsherlock.view.ActionMode; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; + +public abstract class SherlockListActivity extends ListActivity implements OnCreatePanelMenuListener, OnPreparePanelListener, OnMenuItemSelectedListener, OnActionModeStartedListener, OnActionModeFinishedListener { + private ActionBarSherlock mSherlock; + + protected final ActionBarSherlock getSherlock() { + if (mSherlock == null) { + mSherlock = ActionBarSherlock.wrap(this, ActionBarSherlock.FLAG_DELEGATE); + } + return mSherlock; + } + + + /////////////////////////////////////////////////////////////////////////// + // Action bar and mode + /////////////////////////////////////////////////////////////////////////// + + public ActionBar getSupportActionBar() { + return getSherlock().getActionBar(); + } + + public ActionMode startActionMode(ActionMode.Callback callback) { + return getSherlock().startActionMode(callback); + } + + @Override + public void onActionModeStarted(ActionMode mode) {} + + @Override + public void onActionModeFinished(ActionMode mode) {} + + + /////////////////////////////////////////////////////////////////////////// + // General lifecycle/callback dispatching + /////////////////////////////////////////////////////////////////////////// + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + getSherlock().dispatchConfigurationChanged(newConfig); + } + + @Override + protected void onPostResume() { + super.onPostResume(); + getSherlock().dispatchPostResume(); + } + + @Override + protected void onPause() { + getSherlock().dispatchPause(); + super.onPause(); + } + + @Override + protected void onStop() { + getSherlock().dispatchStop(); + super.onStop(); + } + + @Override + protected void onDestroy() { + getSherlock().dispatchDestroy(); + super.onDestroy(); + } + + @Override + protected void onPostCreate(Bundle savedInstanceState) { + getSherlock().dispatchPostCreate(savedInstanceState); + super.onPostCreate(savedInstanceState); + } + + @Override + protected void onTitleChanged(CharSequence title, int color) { + getSherlock().dispatchTitleChanged(title, color); + super.onTitleChanged(title, color); + } + + @Override + public final boolean onMenuOpened(int featureId, android.view.Menu menu) { + if (getSherlock().dispatchMenuOpened(featureId, menu)) { + return true; + } + return super.onMenuOpened(featureId, menu); + } + + @Override + public void onPanelClosed(int featureId, android.view.Menu menu) { + getSherlock().dispatchPanelClosed(featureId, menu); + super.onPanelClosed(featureId, menu); + } + + @Override + public boolean dispatchKeyEvent(KeyEvent event) { + if (getSherlock().dispatchKeyEvent(event)) { + return true; + } + return super.dispatchKeyEvent(event); + } + + + /////////////////////////////////////////////////////////////////////////// + // Native menu handling + /////////////////////////////////////////////////////////////////////////// + + public MenuInflater getSupportMenuInflater() { + return getSherlock().getMenuInflater(); + } + + public void invalidateOptionsMenu() { + getSherlock().dispatchInvalidateOptionsMenu(); + } + + public void supportInvalidateOptionsMenu() { + invalidateOptionsMenu(); + } + + @Override + public final boolean onCreateOptionsMenu(android.view.Menu menu) { + return getSherlock().dispatchCreateOptionsMenu(menu); + } + + @Override + public final boolean onPrepareOptionsMenu(android.view.Menu menu) { + return getSherlock().dispatchPrepareOptionsMenu(menu); + } + + @Override + public final boolean onOptionsItemSelected(android.view.MenuItem item) { + return getSherlock().dispatchOptionsItemSelected(item); + } + + @Override + public void openOptionsMenu() { + if (!getSherlock().dispatchOpenOptionsMenu()) { + super.openOptionsMenu(); + } + } + + @Override + public void closeOptionsMenu() { + if (!getSherlock().dispatchCloseOptionsMenu()) { + super.closeOptionsMenu(); + } + } + + + /////////////////////////////////////////////////////////////////////////// + // Sherlock menu handling + /////////////////////////////////////////////////////////////////////////// + + @Override + public boolean onCreatePanelMenu(int featureId, Menu menu) { + if (featureId == Window.FEATURE_OPTIONS_PANEL) { + return onCreateOptionsMenu(menu); + } + return false; + } + + public boolean onCreateOptionsMenu(Menu menu) { + return true; + } + + @Override + public boolean onPreparePanel(int featureId, View view, Menu menu) { + if (featureId == Window.FEATURE_OPTIONS_PANEL) { + return onPrepareOptionsMenu(menu); + } + return false; + } + + public boolean onPrepareOptionsMenu(Menu menu) { + return true; + } + + @Override + public boolean onMenuItemSelected(int featureId, MenuItem item) { + if (featureId == Window.FEATURE_OPTIONS_PANEL) { + return onOptionsItemSelected(item); + } + return false; + } + + public boolean onOptionsItemSelected(MenuItem item) { + return false; + } + + + /////////////////////////////////////////////////////////////////////////// + // Content + /////////////////////////////////////////////////////////////////////////// + + @Override + public void addContentView(View view, LayoutParams params) { + getSherlock().addContentView(view, params); + } + + @Override + public void setContentView(int layoutResId) { + getSherlock().setContentView(layoutResId); + } + + @Override + public void setContentView(View view, LayoutParams params) { + getSherlock().setContentView(view, params); + } + + @Override + public void setContentView(View view) { + getSherlock().setContentView(view); + } + + public void requestWindowFeature(long featureId) { + getSherlock().requestFeature((int)featureId); + } + + + /////////////////////////////////////////////////////////////////////////// + // Progress Indication + /////////////////////////////////////////////////////////////////////////// + + public void setSupportProgress(int progress) { + getSherlock().setProgress(progress); + } + + public void setSupportProgressBarIndeterminate(boolean indeterminate) { + getSherlock().setProgressBarIndeterminate(indeterminate); + } + + public void setSupportProgressBarIndeterminateVisibility(boolean visible) { + getSherlock().setProgressBarIndeterminateVisibility(visible); + } + + public void setSupportProgressBarVisibility(boolean visible) { + getSherlock().setProgressBarVisibility(visible); + } + + public void setSupportSecondaryProgress(int secondaryProgress) { + getSherlock().setSecondaryProgress(secondaryProgress); + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockListFragment.java b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockListFragment.java new file mode 100644 index 000000000..13ca3c49f --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockListFragment.java @@ -0,0 +1,68 @@ +package com.actionbarsherlock.app; + +import android.app.Activity; +import android.support.v4.app.ListFragment; +import com.actionbarsherlock.internal.view.menu.MenuItemWrapper; +import com.actionbarsherlock.internal.view.menu.MenuWrapper; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; + +import static com.actionbarsherlock.app.SherlockFragmentActivity.OnCreateOptionsMenuListener; +import static com.actionbarsherlock.app.SherlockFragmentActivity.OnOptionsItemSelectedListener; +import static com.actionbarsherlock.app.SherlockFragmentActivity.OnPrepareOptionsMenuListener; + +public class SherlockListFragment extends ListFragment implements OnCreateOptionsMenuListener, OnPrepareOptionsMenuListener, OnOptionsItemSelectedListener { + private SherlockFragmentActivity mActivity; + + public SherlockFragmentActivity getSherlockActivity() { + return mActivity; + } + + @Override + public void onAttach(Activity activity) { + if (!(activity instanceof SherlockFragmentActivity)) { + throw new IllegalStateException(getClass().getSimpleName() + " must be attached to a SherlockFragmentActivity."); + } + mActivity = (SherlockFragmentActivity)activity; + + super.onAttach(activity); + } + + @Override + public void onDetach() { + mActivity = null; + super.onDetach(); + } + + @Override + public final void onCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater) { + onCreateOptionsMenu(new MenuWrapper(menu), mActivity.getSupportMenuInflater()); + } + + @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + //Nothing to see here. + } + + @Override + public final void onPrepareOptionsMenu(android.view.Menu menu) { + onPrepareOptionsMenu(new MenuWrapper(menu)); + } + + @Override + public void onPrepareOptionsMenu(Menu menu) { + //Nothing to see here. + } + + @Override + public final boolean onOptionsItemSelected(android.view.MenuItem item) { + return onOptionsItemSelected(new MenuItemWrapper(item)); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + //Nothing to see here. + return false; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/app/SherlockPreferenceActivity.java b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockPreferenceActivity.java new file mode 100644 index 000000000..4f80be515 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/app/SherlockPreferenceActivity.java @@ -0,0 +1,259 @@ +package com.actionbarsherlock.app; + +import android.content.res.Configuration; +import android.os.Bundle; +import android.preference.PreferenceActivity; +import android.view.KeyEvent; +import android.view.View; +import android.view.ViewGroup.LayoutParams; +import android.view.Window; +import com.actionbarsherlock.ActionBarSherlock; +import com.actionbarsherlock.ActionBarSherlock.OnActionModeFinishedListener; +import com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListener; +import com.actionbarsherlock.ActionBarSherlock.OnCreatePanelMenuListener; +import com.actionbarsherlock.ActionBarSherlock.OnMenuItemSelectedListener; +import com.actionbarsherlock.ActionBarSherlock.OnPreparePanelListener; +import com.actionbarsherlock.view.ActionMode; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; + +public abstract class SherlockPreferenceActivity extends PreferenceActivity implements OnCreatePanelMenuListener, OnPreparePanelListener, OnMenuItemSelectedListener, OnActionModeStartedListener, OnActionModeFinishedListener { + private ActionBarSherlock mSherlock; + + protected final ActionBarSherlock getSherlock() { + if (mSherlock == null) { + mSherlock = ActionBarSherlock.wrap(this, ActionBarSherlock.FLAG_DELEGATE); + } + return mSherlock; + } + + + /////////////////////////////////////////////////////////////////////////// + // Action bar and mode + /////////////////////////////////////////////////////////////////////////// + + public ActionBar getSupportActionBar() { + return getSherlock().getActionBar(); + } + + public ActionMode startActionMode(ActionMode.Callback callback) { + return getSherlock().startActionMode(callback); + } + + @Override + public void onActionModeStarted(ActionMode mode) {} + + @Override + public void onActionModeFinished(ActionMode mode) {} + + + /////////////////////////////////////////////////////////////////////////// + // General lifecycle/callback dispatching + /////////////////////////////////////////////////////////////////////////// + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + getSherlock().dispatchConfigurationChanged(newConfig); + } + + @Override + protected void onPostResume() { + super.onPostResume(); + getSherlock().dispatchPostResume(); + } + + @Override + protected void onPause() { + getSherlock().dispatchPause(); + super.onPause(); + } + + @Override + protected void onStop() { + getSherlock().dispatchStop(); + super.onStop(); + } + + @Override + protected void onDestroy() { + getSherlock().dispatchDestroy(); + super.onDestroy(); + } + + @Override + protected void onPostCreate(Bundle savedInstanceState) { + getSherlock().dispatchPostCreate(savedInstanceState); + super.onPostCreate(savedInstanceState); + } + + @Override + protected void onTitleChanged(CharSequence title, int color) { + getSherlock().dispatchTitleChanged(title, color); + super.onTitleChanged(title, color); + } + + @Override + public final boolean onMenuOpened(int featureId, android.view.Menu menu) { + if (getSherlock().dispatchMenuOpened(featureId, menu)) { + return true; + } + return super.onMenuOpened(featureId, menu); + } + + @Override + public void onPanelClosed(int featureId, android.view.Menu menu) { + getSherlock().dispatchPanelClosed(featureId, menu); + super.onPanelClosed(featureId, menu); + } + + @Override + public boolean dispatchKeyEvent(KeyEvent event) { + if (getSherlock().dispatchKeyEvent(event)) { + return true; + } + return super.dispatchKeyEvent(event); + } + + + /////////////////////////////////////////////////////////////////////////// + // Native menu handling + /////////////////////////////////////////////////////////////////////////// + + public MenuInflater getSupportMenuInflater() { + return getSherlock().getMenuInflater(); + } + + public void invalidateOptionsMenu() { + getSherlock().dispatchInvalidateOptionsMenu(); + } + + public void supportInvalidateOptionsMenu() { + invalidateOptionsMenu(); + } + + @Override + public final boolean onCreateOptionsMenu(android.view.Menu menu) { + return getSherlock().dispatchCreateOptionsMenu(menu); + } + + @Override + public final boolean onPrepareOptionsMenu(android.view.Menu menu) { + return getSherlock().dispatchPrepareOptionsMenu(menu); + } + + @Override + public final boolean onOptionsItemSelected(android.view.MenuItem item) { + return getSherlock().dispatchOptionsItemSelected(item); + } + + @Override + public void openOptionsMenu() { + if (!getSherlock().dispatchOpenOptionsMenu()) { + super.openOptionsMenu(); + } + } + + @Override + public void closeOptionsMenu() { + if (!getSherlock().dispatchCloseOptionsMenu()) { + super.closeOptionsMenu(); + } + } + + + /////////////////////////////////////////////////////////////////////////// + // Sherlock menu handling + /////////////////////////////////////////////////////////////////////////// + + @Override + public boolean onCreatePanelMenu(int featureId, Menu menu) { + if (featureId == Window.FEATURE_OPTIONS_PANEL) { + return onCreateOptionsMenu(menu); + } + return false; + } + + public boolean onCreateOptionsMenu(Menu menu) { + return true; + } + + @Override + public boolean onPreparePanel(int featureId, View view, Menu menu) { + if (featureId == Window.FEATURE_OPTIONS_PANEL) { + return onPrepareOptionsMenu(menu); + } + return false; + } + + public boolean onPrepareOptionsMenu(Menu menu) { + return true; + } + + @Override + public boolean onMenuItemSelected(int featureId, MenuItem item) { + if (featureId == Window.FEATURE_OPTIONS_PANEL) { + return onOptionsItemSelected(item); + } + return false; + } + + public boolean onOptionsItemSelected(MenuItem item) { + return false; + } + + + /////////////////////////////////////////////////////////////////////////// + // Content + /////////////////////////////////////////////////////////////////////////// + + @Override + public void addContentView(View view, LayoutParams params) { + getSherlock().addContentView(view, params); + } + + @Override + public void setContentView(int layoutResId) { + getSherlock().setContentView(layoutResId); + } + + @Override + public void setContentView(View view, LayoutParams params) { + getSherlock().setContentView(view, params); + } + + @Override + public void setContentView(View view) { + getSherlock().setContentView(view); + } + + public void requestWindowFeature(long featureId) { + getSherlock().requestFeature((int)featureId); + } + + + /////////////////////////////////////////////////////////////////////////// + // Progress Indication + /////////////////////////////////////////////////////////////////////////// + + public void setSupportProgress(int progress) { + getSherlock().setProgress(progress); + } + + public void setSupportProgressBarIndeterminate(boolean indeterminate) { + getSherlock().setProgressBarIndeterminate(indeterminate); + } + + public void setSupportProgressBarIndeterminateVisibility(boolean visible) { + getSherlock().setProgressBarIndeterminateVisibility(visible); + } + + public void setSupportProgressBarVisibility(boolean visible) { + getSherlock().setProgressBarVisibility(visible); + } + + public void setSupportSecondaryProgress(int secondaryProgress) { + getSherlock().setSecondaryProgress(secondaryProgress); + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockCompat.java b/actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockCompat.java new file mode 100644 index 000000000..05353d28c --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockCompat.java @@ -0,0 +1,1207 @@ +package com.actionbarsherlock.internal; + +import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; +import static com.actionbarsherlock.internal.ResourcesCompat.getResources_getBoolean; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import org.xmlpull.v1.XmlPullParser; +import android.app.Activity; +import android.content.Context; +import android.content.pm.ActivityInfo; +import android.content.res.AssetManager; +import android.content.res.Configuration; +import android.content.res.Resources; +import android.content.res.TypedArray; +import android.content.res.XmlResourceParser; +import android.os.Bundle; +import android.util.AndroidRuntimeException; +import android.util.Log; +import android.util.TypedValue; +import android.view.ContextThemeWrapper; +import android.view.KeyCharacterMap; +import android.view.KeyEvent; +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewStub; +import android.view.Window; +import android.view.accessibility.AccessibilityEvent; +import android.view.animation.Animation; +import android.view.animation.AnimationUtils; +import android.widget.FrameLayout; +import android.widget.TextView; +import com.actionbarsherlock.ActionBarSherlock; +import com.actionbarsherlock.R; +import com.actionbarsherlock.app.ActionBar; +import com.actionbarsherlock.internal.app.ActionBarImpl; +import com.actionbarsherlock.internal.view.StandaloneActionMode; +import com.actionbarsherlock.internal.view.menu.ActionMenuPresenter; +import com.actionbarsherlock.internal.view.menu.MenuBuilder; +import com.actionbarsherlock.internal.view.menu.MenuItemImpl; +import com.actionbarsherlock.internal.view.menu.MenuPresenter; +import com.actionbarsherlock.internal.widget.ActionBarContainer; +import com.actionbarsherlock.internal.widget.ActionBarContextView; +import com.actionbarsherlock.internal.widget.ActionBarView; +import com.actionbarsherlock.internal.widget.IcsProgressBar; +import com.actionbarsherlock.view.ActionMode; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuItem; + +@ActionBarSherlock.Implementation(api = 7) +public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBuilder.Callback, com.actionbarsherlock.view.Window.Callback, MenuPresenter.Callback, android.view.MenuItem.OnMenuItemClickListener { + /** Window features which are enabled by default. */ + protected static final int DEFAULT_FEATURES = 0; + + + public ActionBarSherlockCompat(Activity activity, int flags) { + super(activity, flags); + } + + + /////////////////////////////////////////////////////////////////////////// + // Properties + /////////////////////////////////////////////////////////////////////////// + + /** Whether or not the device has a dedicated menu key button. */ + private boolean mReserveOverflow; + /** Lazy-load indicator for {@link #mReserveOverflow}. */ + private boolean mReserveOverflowSet = false; + + /** Current menu instance for managing action items. */ + private MenuBuilder mMenu; + /** Map between native options items and sherlock items. */ + protected HashMap mNativeItemMap; + /** Indication of a long-press on the hardware menu key. */ + private boolean mMenuKeyIsLongPress = false; + + /** Parent view of the window decoration (action bar, mode, etc.). */ + private ViewGroup mDecor; + /** Parent view of the activity content. */ + private ViewGroup mContentParent; + + /** Whether or not the title is stable and can be displayed. */ + private boolean mIsTitleReady = false; + /** Whether or not the parent activity has been destroyed. */ + private boolean mIsDestroyed = false; + + /* Emulate PanelFeatureState */ + private boolean mClosingActionMenu; + private boolean mMenuIsPrepared; + private boolean mMenuRefreshContent; + private Bundle mMenuFrozenActionViewState; + + /** Implementation which backs the action bar interface API. */ + private ActionBarImpl aActionBar; + /** Main action bar view which displays the core content. */ + private ActionBarView wActionBar; + /** Relevant window and action bar features flags. */ + private int mFeatures = DEFAULT_FEATURES; + /** Relevant user interface option flags. */ + private int mUiOptions = 0; + + /** Decor indeterminate progress indicator. */ + private IcsProgressBar mCircularProgressBar; + /** Decor progress indicator. */ + private IcsProgressBar mHorizontalProgressBar; + + /** Current displayed context action bar, if any. */ + private ActionMode mActionMode; + /** Parent view in which the context action bar is displayed. */ + private ActionBarContextView mActionModeView; + + /** Title view used with dialogs. */ + private TextView mTitleView; + /** Current activity title. */ + private CharSequence mTitle = null; + /** Whether or not this "activity" is floating (i.e., a dialog) */ + private boolean mIsFloating; + + + + /////////////////////////////////////////////////////////////////////////// + // Instance methods + /////////////////////////////////////////////////////////////////////////// + + @Override + public ActionBar getActionBar() { + if (DEBUG) Log.d(TAG, "[getActionBar]"); + + initActionBar(); + return aActionBar; + } + + private void initActionBar() { + if (DEBUG) Log.d(TAG, "[initActionBar]"); + + // Initializing the window decor can change window feature flags. + // Make sure that we have the correct set before performing the test below. + if (mDecor == null) { + installDecor(); + } + + if ((aActionBar != null) || !hasFeature(Window.FEATURE_ACTION_BAR) || hasFeature(Window.FEATURE_NO_TITLE) || mActivity.isChild()) { + return; + } + + aActionBar = new ActionBarImpl(mActivity, mFeatures); + + if (!mIsDelegate) { + //We may never get another chance to set the title + wActionBar.setWindowTitle(mActivity.getTitle()); + } + } + + @Override + protected Context getThemedContext() { + return aActionBar.getThemedContext(); + } + + @Override + public void setTitle(CharSequence title) { + if (DEBUG) Log.d(TAG, "[setTitle] title: " + title); + + dispatchTitleChanged(title, 0); + } + + @Override + public ActionMode startActionMode(ActionMode.Callback callback) { + if (DEBUG) Log.d(TAG, "[startActionMode] callback: " + callback); + + if (mActionMode != null) { + mActionMode.finish(); + } + + final ActionMode.Callback wrappedCallback = new ActionModeCallbackWrapper(callback); + ActionMode mode = null; + + //Emulate Activity's onWindowStartingActionMode: + initActionBar(); + if (aActionBar != null) { + mode = aActionBar.startActionMode(wrappedCallback); + } + + if (mode != null) { + mActionMode = mode; + } else { + if (mActionModeView == null) { + ViewStub stub = (ViewStub)mDecor.findViewById(R.id.abs__action_mode_bar_stub); + if (stub != null) { + mActionModeView = (ActionBarContextView)stub.inflate(); + } + } + if (mActionModeView != null) { + mActionModeView.killMode(); + mode = new StandaloneActionMode(mActivity, mActionModeView, wrappedCallback, true); + if (callback.onCreateActionMode(mode, mode.getMenu())) { + mode.invalidate(); + mActionModeView.initForMode(mode); + mActionModeView.setVisibility(View.VISIBLE); + mActionMode = mode; + mActionModeView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); + } else { + mActionMode = null; + } + } + } + if (mActionMode != null && mActivity instanceof OnActionModeStartedListener) { + ((OnActionModeStartedListener)mActivity).onActionModeStarted(mActionMode); + } + return mActionMode; + } + + + /////////////////////////////////////////////////////////////////////////// + // Lifecycle and interaction callbacks for delegation + /////////////////////////////////////////////////////////////////////////// + + @Override + public void dispatchConfigurationChanged(Configuration newConfig) { + if (DEBUG) Log.d(TAG, "[dispatchConfigurationChanged] newConfig: " + newConfig); + + if (aActionBar != null) { + aActionBar.onConfigurationChanged(newConfig); + } + } + + @Override + public void dispatchPostResume() { + if (DEBUG) Log.d(TAG, "[dispatchPostResume]"); + + if (aActionBar != null) { + aActionBar.setShowHideAnimationEnabled(true); + } + } + + @Override + public void dispatchPause() { + if (DEBUG) Log.d(TAG, "[dispatchPause]"); + + if (wActionBar != null && wActionBar.isOverflowMenuShowing()) { + wActionBar.hideOverflowMenu(); + } + } + + @Override + public void dispatchStop() { + if (DEBUG) Log.d(TAG, "[dispatchStop]"); + + if (aActionBar != null) { + aActionBar.setShowHideAnimationEnabled(false); + } + } + + @Override + public void dispatchInvalidateOptionsMenu() { + if (DEBUG) Log.d(TAG, "[dispatchInvalidateOptionsMenu]"); + + Bundle savedActionViewStates = null; + if (mMenu != null) { + savedActionViewStates = new Bundle(); + mMenu.saveActionViewStates(savedActionViewStates); + if (savedActionViewStates.size() > 0) { + mMenuFrozenActionViewState = savedActionViewStates; + } + // This will be started again when the panel is prepared. + mMenu.stopDispatchingItemsChanged(); + mMenu.clear(); + } + mMenuRefreshContent = true; + + // Prepare the options panel if we have an action bar + if (wActionBar != null) { + mMenuIsPrepared = false; + preparePanel(); + } + } + + @Override + public boolean dispatchOpenOptionsMenu() { + if (DEBUG) Log.d(TAG, "[dispatchOpenOptionsMenu]"); + + if (!isReservingOverflow()) { + return false; + } + + return wActionBar.showOverflowMenu(); + } + + @Override + public boolean dispatchCloseOptionsMenu() { + if (DEBUG) Log.d(TAG, "[dispatchCloseOptionsMenu]"); + + if (!isReservingOverflow()) { + return false; + } + + return wActionBar.hideOverflowMenu(); + } + + @Override + public void dispatchPostCreate(Bundle savedInstanceState) { + if (DEBUG) Log.d(TAG, "[dispatchOnPostCreate]"); + + if (mIsDelegate) { + mIsTitleReady = true; + } + + if (mDecor == null) { + initActionBar(); + } + } + + @Override + public boolean dispatchCreateOptionsMenu(android.view.Menu menu) { + if (DEBUG) { + Log.d(TAG, "[dispatchCreateOptionsMenu] android.view.Menu: " + menu); + Log.d(TAG, "[dispatchCreateOptionsMenu] returning true"); + } + return true; + } + + @Override + public boolean dispatchPrepareOptionsMenu(android.view.Menu menu) { + if (DEBUG) Log.d(TAG, "[dispatchPrepareOptionsMenu] android.view.Menu: " + menu); + + if (mActionMode != null) { + return false; + } + + mMenuIsPrepared = false; + if (!preparePanel()) { + return false; + } + + if (isReservingOverflow()) { + return false; + } + + if (mNativeItemMap == null) { + mNativeItemMap = new HashMap(); + } else { + mNativeItemMap.clear(); + } + + if (mMenu == null) { + return false; + } + + boolean result = mMenu.bindNativeOverflow(menu, this, mNativeItemMap); + if (DEBUG) Log.d(TAG, "[dispatchPrepareOptionsMenu] returning " + result); + return result; + } + + @Override + public boolean dispatchOptionsItemSelected(android.view.MenuItem item) { + throw new IllegalStateException("Native callback invoked. Create a test case and report!"); + } + + @Override + public boolean dispatchMenuOpened(int featureId, android.view.Menu menu) { + if (DEBUG) Log.d(TAG, "[dispatchMenuOpened] featureId: " + featureId + ", menu: " + menu); + + if (featureId == Window.FEATURE_ACTION_BAR || featureId == Window.FEATURE_OPTIONS_PANEL) { + if (aActionBar != null) { + aActionBar.dispatchMenuVisibilityChanged(true); + } + return true; + } + + return false; + } + + @Override + public void dispatchPanelClosed(int featureId, android.view.Menu menu){ + if (DEBUG) Log.d(TAG, "[dispatchPanelClosed] featureId: " + featureId + ", menu: " + menu); + + if (featureId == Window.FEATURE_ACTION_BAR || featureId == Window.FEATURE_OPTIONS_PANEL) { + if (aActionBar != null) { + aActionBar.dispatchMenuVisibilityChanged(false); + } + } + } + + @Override + public void dispatchTitleChanged(CharSequence title, int color) { + if (DEBUG) Log.d(TAG, "[dispatchTitleChanged] title: " + title + ", color: " + color); + + if (!mIsDelegate || mIsTitleReady) { + if (mTitleView != null) { + mTitleView.setText(title); + } else if (wActionBar != null) { + wActionBar.setWindowTitle(title); + } + } + + mTitle = title; + } + + @Override + public boolean dispatchKeyEvent(KeyEvent event) { + if (DEBUG) Log.d(TAG, "[dispatchKeyEvent] event: " + event); + + final int keyCode = event.getKeyCode(); + + // Not handled by the view hierarchy, does the action bar want it + // to cancel out of something special? + if (keyCode == KeyEvent.KEYCODE_BACK) { + final int action = event.getAction(); + // Back cancels action modes first. + if (mActionMode != null) { + if (action == KeyEvent.ACTION_UP) { + mActionMode.finish(); + } + if (DEBUG) Log.d(TAG, "[dispatchKeyEvent] returning true"); + return true; + } + + // Next collapse any expanded action views. + if (wActionBar != null && wActionBar.hasExpandedActionView()) { + if (action == KeyEvent.ACTION_UP) { + wActionBar.collapseActionView(); + } + if (DEBUG) Log.d(TAG, "[dispatchKeyEvent] returning true"); + return true; + } + } + + boolean result = false; + if (keyCode == KeyEvent.KEYCODE_MENU && isReservingOverflow()) { + if (event.getAction() == KeyEvent.ACTION_DOWN && event.isLongPress()) { + mMenuKeyIsLongPress = true; + } else if (event.getAction() == KeyEvent.ACTION_UP) { + if (!mMenuKeyIsLongPress) { + if (mActionMode == null && wActionBar != null) { + if (wActionBar.isOverflowMenuShowing()) { + wActionBar.hideOverflowMenu(); + } else { + wActionBar.showOverflowMenu(); + } + } + result = true; + } + mMenuKeyIsLongPress = false; + } + } + + if (DEBUG) Log.d(TAG, "[dispatchKeyEvent] returning " + result); + return result; + } + + @Override + public void dispatchDestroy() { + mIsDestroyed = true; + } + + + /////////////////////////////////////////////////////////////////////////// + // Menu callback lifecycle and creation + /////////////////////////////////////////////////////////////////////////// + + private boolean preparePanel() { + // Already prepared (isPrepared will be reset to false later) + if (mMenuIsPrepared) { + return true; + } + + // Init the panel state's menu--return false if init failed + if (mMenu == null || mMenuRefreshContent) { + if (mMenu == null) { + if (!initializePanelMenu() || (mMenu == null)) { + return false; + } + } + + if (wActionBar != null) { + wActionBar.setMenu(mMenu, this); + } + + // Call callback, and return if it doesn't want to display menu. + + // Creating the panel menu will involve a lot of manipulation; + // don't dispatch change events to presenters until we're done. + mMenu.stopDispatchingItemsChanged(); + if (!callbackCreateOptionsMenu(mMenu)) { + // Ditch the menu created above + mMenu = null; + + if (wActionBar != null) { + // Don't show it in the action bar either + wActionBar.setMenu(null, this); + } + + return false; + } + + mMenuRefreshContent = false; + } + + // Callback and return if the callback does not want to show the menu + + // Preparing the panel menu can involve a lot of manipulation; + // don't dispatch change events to presenters until we're done. + mMenu.stopDispatchingItemsChanged(); + + // Restore action view state before we prepare. This gives apps + // an opportunity to override frozen/restored state in onPrepare. + if (mMenuFrozenActionViewState != null) { + mMenu.restoreActionViewStates(mMenuFrozenActionViewState); + mMenuFrozenActionViewState = null; + } + + if (!callbackPrepareOptionsMenu(mMenu)) { + if (wActionBar != null) { + // The app didn't want to show the menu for now but it still exists. + // Clear it out of the action bar. + wActionBar.setMenu(null, this); + } + mMenu.startDispatchingItemsChanged(); + return false; + } + + // Set the proper keymap + KeyCharacterMap kmap = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD); + mMenu.setQwertyMode(kmap.getKeyboardType() != KeyCharacterMap.NUMERIC); + mMenu.startDispatchingItemsChanged(); + + // Set other state + mMenuIsPrepared = true; + + return true; + } + + public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) { + return callbackOptionsItemSelected(item); + } + + public void onMenuModeChange(MenuBuilder menu) { + reopenMenu(true); + } + + private void reopenMenu(boolean toggleMenuMode) { + if (wActionBar != null && wActionBar.isOverflowReserved()) { + if (!wActionBar.isOverflowMenuShowing() || !toggleMenuMode) { + if (wActionBar.getVisibility() == View.VISIBLE) { + if (callbackPrepareOptionsMenu(mMenu)) { + wActionBar.showOverflowMenu(); + } + } + } else { + wActionBar.hideOverflowMenu(); + } + return; + } + } + + private boolean initializePanelMenu() { + Context context = mActivity;//getContext(); + + // If we have an action bar, initialize the menu with a context themed for it. + if (wActionBar != null) { + TypedValue outValue = new TypedValue(); + Resources.Theme currentTheme = context.getTheme(); + currentTheme.resolveAttribute(R.attr.actionBarWidgetTheme, + outValue, true); + final int targetThemeRes = outValue.resourceId; + + if (targetThemeRes != 0 /*&& context.getThemeResId() != targetThemeRes*/) { + context = new ContextThemeWrapper(context, targetThemeRes); + } + } + + mMenu = new MenuBuilder(context); + mMenu.setCallback(this); + + return true; + } + + void checkCloseActionMenu(Menu menu) { + if (mClosingActionMenu) { + return; + } + + mClosingActionMenu = true; + wActionBar.dismissPopupMenus(); + //Callback cb = getCallback(); + //if (cb != null && !isDestroyed()) { + // cb.onPanelClosed(FEATURE_ACTION_BAR, menu); + //} + mClosingActionMenu = false; + } + + @Override + public boolean onOpenSubMenu(MenuBuilder subMenu) { + return true; + } + + @Override + public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) { + checkCloseActionMenu(menu); + } + + @Override + public boolean onMenuItemClick(android.view.MenuItem item) { + if (DEBUG) Log.d(TAG, "[mNativeItemListener.onMenuItemClick] item: " + item); + + final MenuItemImpl sherlockItem = mNativeItemMap.get(item); + if (sherlockItem != null) { + sherlockItem.invoke(); + } else { + Log.e(TAG, "Options item \"" + item + "\" not found in mapping"); + } + + return true; //Do not allow continuation of native handling + } + + @Override + public boolean onMenuItemSelected(int featureId, MenuItem item) { + return callbackOptionsItemSelected(item); + } + + + /////////////////////////////////////////////////////////////////////////// + // Progress bar interaction and internal handling + /////////////////////////////////////////////////////////////////////////// + + @Override + public void setProgressBarVisibility(boolean visible) { + if (DEBUG) Log.d(TAG, "[setProgressBarVisibility] visible: " + visible); + + setFeatureInt(Window.FEATURE_PROGRESS, visible ? Window.PROGRESS_VISIBILITY_ON : + Window.PROGRESS_VISIBILITY_OFF); + } + + @Override + public void setProgressBarIndeterminateVisibility(boolean visible) { + if (DEBUG) Log.d(TAG, "[setProgressBarIndeterminateVisibility] visible: " + visible); + + setFeatureInt(Window.FEATURE_INDETERMINATE_PROGRESS, + visible ? Window.PROGRESS_VISIBILITY_ON : Window.PROGRESS_VISIBILITY_OFF); + } + + @Override + public void setProgressBarIndeterminate(boolean indeterminate) { + if (DEBUG) Log.d(TAG, "[setProgressBarIndeterminate] indeterminate: " + indeterminate); + + setFeatureInt(Window.FEATURE_PROGRESS, + indeterminate ? Window.PROGRESS_INDETERMINATE_ON : Window.PROGRESS_INDETERMINATE_OFF); + } + + @Override + public void setProgress(int progress) { + if (DEBUG) Log.d(TAG, "[setProgress] progress: " + progress); + + setFeatureInt(Window.FEATURE_PROGRESS, progress + Window.PROGRESS_START); + } + + @Override + public void setSecondaryProgress(int secondaryProgress) { + if (DEBUG) Log.d(TAG, "[setSecondaryProgress] secondaryProgress: " + secondaryProgress); + + setFeatureInt(Window.FEATURE_PROGRESS, + secondaryProgress + Window.PROGRESS_SECONDARY_START); + } + + private void setFeatureInt(int featureId, int value) { + updateInt(featureId, value, false); + } + + private void updateInt(int featureId, int value, boolean fromResume) { + // Do nothing if the decor is not yet installed... an update will + // need to be forced when we eventually become active. + if (mContentParent == null) { + return; + } + + final int featureMask = 1 << featureId; + + if ((getFeatures() & featureMask) == 0 && !fromResume) { + return; + } + + onIntChanged(featureId, value); + } + + private void onIntChanged(int featureId, int value) { + if (featureId == Window.FEATURE_PROGRESS || featureId == Window.FEATURE_INDETERMINATE_PROGRESS) { + updateProgressBars(value); + } + } + + private void updateProgressBars(int value) { + IcsProgressBar circularProgressBar = getCircularProgressBar(true); + IcsProgressBar horizontalProgressBar = getHorizontalProgressBar(true); + + final int features = mFeatures;//getLocalFeatures(); + if (value == Window.PROGRESS_VISIBILITY_ON) { + if ((features & (1 << Window.FEATURE_PROGRESS)) != 0) { + int level = horizontalProgressBar.getProgress(); + int visibility = (horizontalProgressBar.isIndeterminate() || level < 10000) ? + View.VISIBLE : View.INVISIBLE; + horizontalProgressBar.setVisibility(visibility); + } + if ((features & (1 << Window.FEATURE_INDETERMINATE_PROGRESS)) != 0) { + circularProgressBar.setVisibility(View.VISIBLE); + } + } else if (value == Window.PROGRESS_VISIBILITY_OFF) { + if ((features & (1 << Window.FEATURE_PROGRESS)) != 0) { + horizontalProgressBar.setVisibility(View.GONE); + } + if ((features & (1 << Window.FEATURE_INDETERMINATE_PROGRESS)) != 0) { + circularProgressBar.setVisibility(View.GONE); + } + } else if (value == Window.PROGRESS_INDETERMINATE_ON) { + horizontalProgressBar.setIndeterminate(true); + } else if (value == Window.PROGRESS_INDETERMINATE_OFF) { + horizontalProgressBar.setIndeterminate(false); + } else if (Window.PROGRESS_START <= value && value <= Window.PROGRESS_END) { + // We want to set the progress value before testing for visibility + // so that when the progress bar becomes visible again, it has the + // correct level. + horizontalProgressBar.setProgress(value - Window.PROGRESS_START); + + if (value < Window.PROGRESS_END) { + showProgressBars(horizontalProgressBar, circularProgressBar); + } else { + hideProgressBars(horizontalProgressBar, circularProgressBar); + } + } else if (Window.PROGRESS_SECONDARY_START <= value && value <= Window.PROGRESS_SECONDARY_END) { + horizontalProgressBar.setSecondaryProgress(value - Window.PROGRESS_SECONDARY_START); + + showProgressBars(horizontalProgressBar, circularProgressBar); + } + } + + private void showProgressBars(IcsProgressBar horizontalProgressBar, IcsProgressBar spinnyProgressBar) { + final int features = mFeatures;//getLocalFeatures(); + if ((features & (1 << Window.FEATURE_INDETERMINATE_PROGRESS)) != 0 && + spinnyProgressBar.getVisibility() == View.INVISIBLE) { + spinnyProgressBar.setVisibility(View.VISIBLE); + } + // Only show the progress bars if the primary progress is not complete + if ((features & (1 << Window.FEATURE_PROGRESS)) != 0 && + horizontalProgressBar.getProgress() < 10000) { + horizontalProgressBar.setVisibility(View.VISIBLE); + } + } + + private void hideProgressBars(IcsProgressBar horizontalProgressBar, IcsProgressBar spinnyProgressBar) { + final int features = mFeatures;//getLocalFeatures(); + Animation anim = AnimationUtils.loadAnimation(mActivity, android.R.anim.fade_out); + anim.setDuration(1000); + if ((features & (1 << Window.FEATURE_INDETERMINATE_PROGRESS)) != 0 && + spinnyProgressBar.getVisibility() == View.VISIBLE) { + spinnyProgressBar.startAnimation(anim); + spinnyProgressBar.setVisibility(View.INVISIBLE); + } + if ((features & (1 << Window.FEATURE_PROGRESS)) != 0 && + horizontalProgressBar.getVisibility() == View.VISIBLE) { + horizontalProgressBar.startAnimation(anim); + horizontalProgressBar.setVisibility(View.INVISIBLE); + } + } + + private IcsProgressBar getCircularProgressBar(boolean shouldInstallDecor) { + if (mCircularProgressBar != null) { + return mCircularProgressBar; + } + if (mContentParent == null && shouldInstallDecor) { + installDecor(); + } + mCircularProgressBar = (IcsProgressBar)mDecor.findViewById(R.id.abs__progress_circular); + if (mCircularProgressBar != null) { + mCircularProgressBar.setVisibility(View.INVISIBLE); + } + return mCircularProgressBar; + } + + private IcsProgressBar getHorizontalProgressBar(boolean shouldInstallDecor) { + if (mHorizontalProgressBar != null) { + return mHorizontalProgressBar; + } + if (mContentParent == null && shouldInstallDecor) { + installDecor(); + } + mHorizontalProgressBar = (IcsProgressBar)mDecor.findViewById(R.id.abs__progress_horizontal); + if (mHorizontalProgressBar != null) { + mHorizontalProgressBar.setVisibility(View.INVISIBLE); + } + return mHorizontalProgressBar; + } + + + /////////////////////////////////////////////////////////////////////////// + // Feature management and content interaction and creation + /////////////////////////////////////////////////////////////////////////// + + private int getFeatures() { + if (DEBUG) Log.d(TAG, "[getFeatures] returning " + mFeatures); + + return mFeatures; + } + + @Override + public boolean hasFeature(int featureId) { + if (DEBUG) Log.d(TAG, "[hasFeature] featureId: " + featureId); + + boolean result = (mFeatures & (1 << featureId)) != 0; + if (DEBUG) Log.d(TAG, "[hasFeature] returning " + result); + return result; + } + + @Override + public boolean requestFeature(int featureId) { + if (DEBUG) Log.d(TAG, "[requestFeature] featureId: " + featureId); + + if (mContentParent != null) { + throw new AndroidRuntimeException("requestFeature() must be called before adding content"); + } + + switch (featureId) { + case Window.FEATURE_ACTION_BAR: + case Window.FEATURE_ACTION_BAR_OVERLAY: + case Window.FEATURE_ACTION_MODE_OVERLAY: + case Window.FEATURE_INDETERMINATE_PROGRESS: + case Window.FEATURE_NO_TITLE: + case Window.FEATURE_PROGRESS: + mFeatures |= (1 << featureId); + return true; + + default: + return false; + } + } + + @Override + public void setUiOptions(int uiOptions) { + if (DEBUG) Log.d(TAG, "[setUiOptions] uiOptions: " + uiOptions); + + mUiOptions = uiOptions; + } + + @Override + public void setUiOptions(int uiOptions, int mask) { + if (DEBUG) Log.d(TAG, "[setUiOptions] uiOptions: " + uiOptions + ", mask: " + mask); + + mUiOptions = (mUiOptions & ~mask) | (uiOptions & mask); + } + + @Override + public void setContentView(int layoutResId) { + if (DEBUG) Log.d(TAG, "[setContentView] layoutResId: " + layoutResId); + + if (mContentParent == null) { + installDecor(); + } else { + mContentParent.removeAllViews(); + } + mActivity.getLayoutInflater().inflate(layoutResId, mContentParent); + + android.view.Window.Callback callback = mActivity.getWindow().getCallback(); + if (callback != null) { + callback.onContentChanged(); + } + + initActionBar(); + } + + @Override + public void setContentView(View view, ViewGroup.LayoutParams params) { + if (DEBUG) Log.d(TAG, "[setContentView] view: " + view + ", params: " + params); + + if (mContentParent == null) { + installDecor(); + } else { + mContentParent.removeAllViews(); + } + mContentParent.addView(view, params); + + android.view.Window.Callback callback = mActivity.getWindow().getCallback(); + if (callback != null) { + callback.onContentChanged(); + } + + initActionBar(); + } + + @Override + public void addContentView(View view, ViewGroup.LayoutParams params) { + if (DEBUG) Log.d(TAG, "[addContentView] view: " + view + ", params: " + params); + + if (mContentParent == null) { + installDecor(); + } + mContentParent.addView(view, params); + + initActionBar(); + } + + private void installDecor() { + if (DEBUG) Log.d(TAG, "[installDecor]"); + + if (mDecor == null) { + mDecor = (ViewGroup)mActivity.getWindow().getDecorView().findViewById(android.R.id.content); + } + if (mContentParent == null) { + //Since we are not operating at the window level we need to take + //into account the fact that the true decor may have already been + //initialized and had content attached to it. If that is the case, + //copy over its children to our new content container. + List views = null; + if (mDecor.getChildCount() > 0) { + views = new ArrayList(1); //Usually there's only one child + for (int i = 0, children = mDecor.getChildCount(); i < children; i++) { + View child = mDecor.getChildAt(0); + mDecor.removeView(child); + views.add(child); + } + } + + mContentParent = generateLayout(); + + //Copy over the old children. See above for explanation. + if (views != null) { + for (View child : views) { + mContentParent.addView(child); + } + } + + mTitleView = (TextView)mDecor.findViewById(android.R.id.title); + if (mTitleView != null) { + if (hasFeature(Window.FEATURE_NO_TITLE)) { + mTitleView.setVisibility(View.GONE); + if (mContentParent instanceof FrameLayout) { + ((FrameLayout)mContentParent).setForeground(null); + } + } else { + mTitleView.setText(mTitle); + } + } else { + wActionBar = (ActionBarView)mDecor.findViewById(R.id.abs__action_bar); + if (wActionBar != null) { + wActionBar.setWindowCallback(this); + if (wActionBar.getTitle() == null) { + wActionBar.setWindowTitle(mActivity.getTitle()); + } + if (hasFeature(Window.FEATURE_PROGRESS)) { + wActionBar.initProgress(); + } + if (hasFeature(Window.FEATURE_INDETERMINATE_PROGRESS)) { + wActionBar.initIndeterminateProgress(); + } + + //Since we don't require onCreate dispatching, parse for uiOptions here + int uiOptions = loadUiOptionsFromManifest(mActivity); + if (uiOptions != 0) { + mUiOptions = uiOptions; + } + + boolean splitActionBar = false; + final boolean splitWhenNarrow = (mUiOptions & ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW) != 0; + if (splitWhenNarrow) { + splitActionBar = getResources_getBoolean(mActivity, R.bool.abs__split_action_bar_is_narrow); + } else { + splitActionBar = mActivity.getTheme() + .obtainStyledAttributes(R.styleable.SherlockTheme) + .getBoolean(R.styleable.SherlockTheme_windowSplitActionBar, false); + } + final ActionBarContainer splitView = (ActionBarContainer)mDecor.findViewById(R.id.abs__split_action_bar); + if (splitView != null) { + wActionBar.setSplitView(splitView); + wActionBar.setSplitActionBar(splitActionBar); + wActionBar.setSplitWhenNarrow(splitWhenNarrow); + + mActionModeView = (ActionBarContextView)mDecor.findViewById(R.id.abs__action_context_bar); + mActionModeView.setSplitView(splitView); + mActionModeView.setSplitActionBar(splitActionBar); + mActionModeView.setSplitWhenNarrow(splitWhenNarrow); + } else if (splitActionBar) { + Log.e(TAG, "Requested split action bar with incompatible window decor! Ignoring request."); + } + + // Post the panel invalidate for later; avoid application onCreateOptionsMenu + // being called in the middle of onCreate or similar. + mDecor.post(new Runnable() { + @Override + public void run() { + //Invalidate if the panel menu hasn't been created before this. + if (!mIsDestroyed && !mActivity.isFinishing() && mMenu == null) { + dispatchInvalidateOptionsMenu(); + } + } + }); + } + } + } + } + + private ViewGroup generateLayout() { + if (DEBUG) Log.d(TAG, "[generateLayout]"); + + // Apply data from current theme. + + TypedArray a = mActivity.getTheme().obtainStyledAttributes(R.styleable.SherlockTheme); + + mIsFloating = a.getBoolean(R.styleable.SherlockTheme_android_windowIsFloating, false); + + if (!a.hasValue(R.styleable.SherlockTheme_windowActionBar)) { + throw new IllegalStateException("You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative."); + } + + if (a.getBoolean(R.styleable.SherlockTheme_windowNoTitle, false)) { + requestFeature(Window.FEATURE_NO_TITLE); + } else if (a.getBoolean(R.styleable.SherlockTheme_windowActionBar, false)) { + // Don't allow an action bar if there is no title. + requestFeature(Window.FEATURE_ACTION_BAR); + } + + if (a.getBoolean(R.styleable.SherlockTheme_windowActionBarOverlay, false)) { + requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); + } + + if (a.getBoolean(R.styleable.SherlockTheme_windowActionModeOverlay, false)) { + requestFeature(Window.FEATURE_ACTION_MODE_OVERLAY); + } + + a.recycle(); + + int layoutResource; + if (!hasFeature(Window.FEATURE_NO_TITLE)) { + if (mIsFloating) { + //Trash original dialog LinearLayout + mDecor = (ViewGroup)mDecor.getParent(); + mDecor.removeAllViews(); + + layoutResource = R.layout.abs__dialog_title_holo; + } else { + if (hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY)) { + layoutResource = R.layout.abs__screen_action_bar_overlay; + } else { + layoutResource = R.layout.abs__screen_action_bar; + } + } + } else if (hasFeature(Window.FEATURE_ACTION_MODE_OVERLAY) && !hasFeature(Window.FEATURE_NO_TITLE)) { + layoutResource = R.layout.abs__screen_simple_overlay_action_mode; + } else { + layoutResource = R.layout.abs__screen_simple; + } + + if (DEBUG) Log.d(TAG, "[generateLayout] using screen XML " + mActivity.getResources().getString(layoutResource)); + View in = mActivity.getLayoutInflater().inflate(layoutResource, null); + mDecor.addView(in, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)); + + ViewGroup contentParent = (ViewGroup)mDecor.findViewById(R.id.abs__content); + if (contentParent == null) { + throw new RuntimeException("Couldn't find content container view"); + } + + //Make our new child the true content view (for fragments). VERY VOLATILE! + mDecor.setId(View.NO_ID); + contentParent.setId(android.R.id.content); + + if (hasFeature(Window.FEATURE_INDETERMINATE_PROGRESS)) { + IcsProgressBar progress = getCircularProgressBar(false); + if (progress != null) { + progress.setIndeterminate(true); + } + } + + return contentParent; + } + + + /////////////////////////////////////////////////////////////////////////// + // Miscellaneous + /////////////////////////////////////////////////////////////////////////// + + /** + * Determine whether or not the device has a dedicated menu key. + * + * @return {@code true} if native menu key is present. + */ + private boolean isReservingOverflow() { + if (!mReserveOverflowSet) { + mReserveOverflow = ActionMenuPresenter.reserveOverflow(mActivity); + mReserveOverflowSet = true; + } + return mReserveOverflow; + } + + private static int loadUiOptionsFromManifest(Activity activity) { + int uiOptions = 0; + try { + final String thisPackage = activity.getClass().getName(); + if (DEBUG) Log.i(TAG, "Parsing AndroidManifest.xml for " + thisPackage); + + final String packageName = activity.getApplicationInfo().packageName; + final AssetManager am = activity.createPackageContext(packageName, 0).getAssets(); + final XmlResourceParser xml = am.openXmlResourceParser("AndroidManifest.xml"); + + int eventType = xml.getEventType(); + while (eventType != XmlPullParser.END_DOCUMENT) { + if (eventType == XmlPullParser.START_TAG) { + String name = xml.getName(); + + if ("application".equals(name)) { + //Check if the has the attribute + if (DEBUG) Log.d(TAG, "Got "); + + for (int i = xml.getAttributeCount() - 1; i >= 0; i--) { + if (DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i)); + + if ("uiOptions".equals(xml.getAttributeName(i))) { + uiOptions = xml.getAttributeIntValue(i, 0); + break; //out of for loop + } + } + } else if ("activity".equals(name)) { + //Check if the is us and has the attribute + if (DEBUG) Log.d(TAG, "Got "); + Integer activityUiOptions = null; + String activityPackage = null; + boolean isOurActivity = false; + + for (int i = xml.getAttributeCount() - 1; i >= 0; i--) { + if (DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i)); + + //We need both uiOptions and name attributes + String attrName = xml.getAttributeName(i); + if ("uiOptions".equals(attrName)) { + activityUiOptions = xml.getAttributeIntValue(i, 0); + } else if ("name".equals(attrName)) { + activityPackage = cleanActivityName(packageName, xml.getAttributeValue(i)); + if (!thisPackage.equals(activityPackage)) { + break; //out of for loop + } + isOurActivity = true; + } + + //Make sure we have both attributes before processing + if ((activityUiOptions != null) && (activityPackage != null)) { + //Our activity, uiOptions specified, override with our value + uiOptions = activityUiOptions.intValue(); + } + } + if (isOurActivity) { + //If we matched our activity but it had no logo don't + //do any more processing of the manifest + break; + } + } + } + eventType = xml.nextToken(); + } + } catch (Exception e) { + e.printStackTrace(); + } + if (DEBUG) Log.i(TAG, "Returning " + Integer.toHexString(uiOptions)); + return uiOptions; + } + + public static String cleanActivityName(String manifestPackage, String activityName) { + if (activityName.charAt(0) == '.') { + //Relative activity name (e.g., android:name=".ui.SomeClass") + return manifestPackage + activityName; + } + if (activityName.indexOf('.', 1) == -1) { + //Unqualified activity name (e.g., android:name="SomeClass") + return manifestPackage + "." + activityName; + } + //Fully-qualified activity name (e.g., "com.my.package.SomeClass") + return activityName; + } + + /** + * Clears out internal reference when the action mode is destroyed. + */ + private class ActionModeCallbackWrapper implements ActionMode.Callback { + private final ActionMode.Callback mWrapped; + + public ActionModeCallbackWrapper(ActionMode.Callback wrapped) { + mWrapped = wrapped; + } + + public boolean onCreateActionMode(ActionMode mode, Menu menu) { + return mWrapped.onCreateActionMode(mode, menu); + } + + public boolean onPrepareActionMode(ActionMode mode, Menu menu) { + return mWrapped.onPrepareActionMode(mode, menu); + } + + public boolean onActionItemClicked(ActionMode mode, MenuItem item) { + return mWrapped.onActionItemClicked(mode, item); + } + + public void onDestroyActionMode(ActionMode mode) { + mWrapped.onDestroyActionMode(mode); + if (mActionModeView != null) { + mActionModeView.setVisibility(View.GONE); + mActionModeView.removeAllViews(); + } + if (mActivity instanceof OnActionModeFinishedListener) { + ((OnActionModeFinishedListener)mActivity).onActionModeFinished(mActionMode); + } + mActionMode = null; + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockNative.java b/actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockNative.java new file mode 100644 index 000000000..9afca185a --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/ActionBarSherlockNative.java @@ -0,0 +1,328 @@ +package com.actionbarsherlock.internal; + +import com.actionbarsherlock.ActionBarSherlock; +import com.actionbarsherlock.app.ActionBar; +import com.actionbarsherlock.internal.app.ActionBarWrapper; +import com.actionbarsherlock.internal.view.menu.MenuWrapper; +import com.actionbarsherlock.view.ActionMode; +import com.actionbarsherlock.view.MenuInflater; +import android.app.Activity; +import android.content.Context; +import android.util.Log; +import android.util.TypedValue; +import android.view.ContextThemeWrapper; +import android.view.View; +import android.view.Window; +import android.view.ViewGroup.LayoutParams; + +@ActionBarSherlock.Implementation(api = 14) +public class ActionBarSherlockNative extends ActionBarSherlock { + private ActionBarWrapper mActionBar; + private ActionModeWrapper mActionMode; + private MenuWrapper mMenu; + + public ActionBarSherlockNative(Activity activity, int flags) { + super(activity, flags); + } + + + @Override + public ActionBar getActionBar() { + if (DEBUG) Log.d(TAG, "[getActionBar]"); + + initActionBar(); + return mActionBar; + } + + private void initActionBar() { + if (mActionBar != null || mActivity.getActionBar() == null) { + return; + } + + mActionBar = new ActionBarWrapper(mActivity); + } + + @Override + public void dispatchInvalidateOptionsMenu() { + if (DEBUG) Log.d(TAG, "[dispatchInvalidateOptionsMenu]"); + + mActivity.getWindow().invalidatePanelMenu(Window.FEATURE_OPTIONS_PANEL); + } + + @Override + public boolean dispatchCreateOptionsMenu(android.view.Menu menu) { + if (DEBUG) Log.d(TAG, "[dispatchCreateOptionsMenu] menu: " + menu); + + if (mMenu == null || menu != mMenu.unwrap()) { + mMenu = new MenuWrapper(menu); + } + + final boolean result = callbackCreateOptionsMenu(mMenu); + if (DEBUG) Log.d(TAG, "[dispatchCreateOptionsMenu] returning " + result); + return result; + } + + @Override + public boolean dispatchPrepareOptionsMenu(android.view.Menu menu) { + if (DEBUG) Log.d(TAG, "[dispatchPrepareOptionsMenu] menu: " + menu); + + final boolean result = callbackPrepareOptionsMenu(mMenu); + if (DEBUG) Log.d(TAG, "[dispatchPrepareOptionsMenu] returning " + result); + return result; + } + + @Override + public boolean dispatchOptionsItemSelected(android.view.MenuItem item) { + if (DEBUG) Log.d(TAG, "[dispatchOptionsItemSelected] item: " + item.getTitleCondensed()); + + final boolean result = callbackOptionsItemSelected(mMenu.findItem(item)); + if (DEBUG) Log.d(TAG, "[dispatchOptionsItemSelected] returning " + result); + return result; + } + + @Override + public boolean hasFeature(int feature) { + if (DEBUG) Log.d(TAG, "[hasFeature] feature: " + feature); + + final boolean result = mActivity.getWindow().hasFeature(feature); + if (DEBUG) Log.d(TAG, "[hasFeature] returning " + result); + return result; + } + + @Override + public boolean requestFeature(int featureId) { + if (DEBUG) Log.d(TAG, "[requestFeature] featureId: " + featureId); + + final boolean result = mActivity.getWindow().requestFeature(featureId); + if (DEBUG) Log.d(TAG, "[requestFeature] returning " + result); + return result; + } + + @Override + public void setUiOptions(int uiOptions) { + if (DEBUG) Log.d(TAG, "[setUiOptions] uiOptions: " + uiOptions); + + mActivity.getWindow().setUiOptions(uiOptions); + } + + @Override + public void setUiOptions(int uiOptions, int mask) { + if (DEBUG) Log.d(TAG, "[setUiOptions] uiOptions: " + uiOptions + ", mask: " + mask); + + mActivity.getWindow().setUiOptions(uiOptions, mask); + } + + @Override + public void setContentView(int layoutResId) { + if (DEBUG) Log.d(TAG, "[setContentView] layoutResId: " + layoutResId); + + mActivity.getWindow().setContentView(layoutResId); + initActionBar(); + } + + @Override + public void setContentView(View view, LayoutParams params) { + if (DEBUG) Log.d(TAG, "[setContentView] view: " + view + ", params: " + params); + + mActivity.getWindow().setContentView(view, params); + initActionBar(); + } + + @Override + public void addContentView(View view, LayoutParams params) { + if (DEBUG) Log.d(TAG, "[addContentView] view: " + view + ", params: " + params); + + mActivity.getWindow().addContentView(view, params); + initActionBar(); + } + + @Override + public void setTitle(CharSequence title) { + if (DEBUG) Log.d(TAG, "[setTitle] title: " + title); + + mActivity.getWindow().setTitle(title); + } + + @Override + public void setProgressBarVisibility(boolean visible) { + if (DEBUG) Log.d(TAG, "[setProgressBarVisibility] visible: " + visible); + + mActivity.setProgressBarVisibility(visible); + } + + @Override + public void setProgressBarIndeterminateVisibility(boolean visible) { + if (DEBUG) Log.d(TAG, "[setProgressBarIndeterminateVisibility] visible: " + visible); + + mActivity.setProgressBarIndeterminateVisibility(visible); + } + + @Override + public void setProgressBarIndeterminate(boolean indeterminate) { + if (DEBUG) Log.d(TAG, "[setProgressBarIndeterminate] indeterminate: " + indeterminate); + + mActivity.setProgressBarIndeterminate(indeterminate); + } + + @Override + public void setProgress(int progress) { + if (DEBUG) Log.d(TAG, "[setProgress] progress: " + progress); + + mActivity.setProgress(progress); + } + + @Override + public void setSecondaryProgress(int secondaryProgress) { + if (DEBUG) Log.d(TAG, "[setSecondaryProgress] secondaryProgress: " + secondaryProgress); + + mActivity.setSecondaryProgress(secondaryProgress); + } + + @Override + protected Context getThemedContext() { + Context context = mActivity; + TypedValue outValue = new TypedValue(); + mActivity.getTheme().resolveAttribute(android.R.attr.actionBarWidgetTheme, outValue, true); + if (outValue.resourceId != 0) { + //We are unable to test if this is the same as our current theme + //so we just wrap it and hope that if the attribute was specified + //then the user is intentionally specifying an alternate theme. + context = new ContextThemeWrapper(context, outValue.resourceId); + } + return context; + } + + @Override + public ActionMode startActionMode(com.actionbarsherlock.view.ActionMode.Callback callback) { + if (DEBUG) Log.d(TAG, "[startActionMode] callback: " + callback); + + if (mActionMode != null) { + mActionMode.finish(); + } + ActionModeCallbackWrapper wrapped = null; + if (callback != null) { + wrapped = new ActionModeCallbackWrapper(callback); + } + + //Calling this will trigger the callback wrapper's onCreate which + //is where we will set the new instance to mActionMode since we need + //to pass it through to the sherlock callbacks and the call below + //will not have returned yet to store its value. + mActivity.startActionMode(wrapped); + + return mActionMode; + } + + private class ActionModeCallbackWrapper implements android.view.ActionMode.Callback { + private final ActionMode.Callback mCallback; + + public ActionModeCallbackWrapper(ActionMode.Callback callback) { + mCallback = callback; + } + + @Override + public boolean onCreateActionMode(android.view.ActionMode mode, android.view.Menu menu) { + //See ActionBarSherlockNative#startActionMode + mActionMode = new ActionModeWrapper(mode); + + return mCallback.onCreateActionMode(mActionMode, mActionMode.getMenu()); + } + + @Override + public boolean onPrepareActionMode(android.view.ActionMode mode, android.view.Menu menu) { + return mCallback.onPrepareActionMode(mActionMode, mActionMode.getMenu()); + } + + @Override + public boolean onActionItemClicked(android.view.ActionMode mode, android.view.MenuItem item) { + return mCallback.onActionItemClicked(mActionMode, mActionMode.getMenu().findItem(item)); + } + + @Override + public void onDestroyActionMode(android.view.ActionMode mode) { + mCallback.onDestroyActionMode(mActionMode); + } + } + + private class ActionModeWrapper extends ActionMode { + private final android.view.ActionMode mActionMode; + private MenuWrapper mMenu = null; + + ActionModeWrapper(android.view.ActionMode actionMode) { + mActionMode = actionMode; + } + + @Override + public void setTitle(CharSequence title) { + mActionMode.setTitle(title); + } + + @Override + public void setTitle(int resId) { + mActionMode.setTitle(resId); + } + + @Override + public void setSubtitle(CharSequence subtitle) { + mActionMode.setSubtitle(subtitle); + } + + @Override + public void setSubtitle(int resId) { + mActionMode.setSubtitle(resId); + } + + @Override + public void setCustomView(View view) { + mActionMode.setCustomView(view); + } + + @Override + public void invalidate() { + mActionMode.invalidate(); + } + + @Override + public void finish() { + mActionMode.finish(); + } + + @Override + public MenuWrapper getMenu() { + if (mMenu == null) { + mMenu = new MenuWrapper(mActionMode.getMenu()); + } + return mMenu; + } + + @Override + public CharSequence getTitle() { + return mActionMode.getTitle(); + } + + @Override + public CharSequence getSubtitle() { + return mActionMode.getSubtitle(); + } + + @Override + public View getCustomView() { + return mActionMode.getCustomView(); + } + + @Override + public MenuInflater getMenuInflater() { + return ActionBarSherlockNative.this.getMenuInflater(); + } + + @Override + public void setTag(Object tag) { + mActionMode.setTag(tag); + } + + @Override + public Object getTag() { + return mActionMode.getTag(); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/ResourcesCompat.java b/actionbarsherlock/src/com/actionbarsherlock/internal/ResourcesCompat.java new file mode 100644 index 000000000..8e1efe8c5 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/ResourcesCompat.java @@ -0,0 +1,95 @@ +package com.actionbarsherlock.internal; + +import android.content.Context; +import android.os.Build; +import android.util.DisplayMetrics; +import com.actionbarsherlock.R; + +public final class ResourcesCompat { + //No instances + private ResourcesCompat() {} + + + /** + * Support implementation of {@code getResources().getBoolean()} that we + * can use to simulate filtering based on width and smallest width + * qualifiers on pre-3.2. + * + * @param context Context to load booleans from on 3.2+ and to fetch the + * display metrics. + * @param id Id of boolean to load. + * @return Associated boolean value as reflected by the current display + * metrics. + */ + public static boolean getResources_getBoolean(Context context, int id) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { + return context.getResources().getBoolean(id); + } + + DisplayMetrics metrics = context.getResources().getDisplayMetrics(); + float widthDp = metrics.widthPixels / metrics.density; + float heightDp = metrics.heightPixels / metrics.density; + float smallestWidthDp = (widthDp < heightDp) ? widthDp : heightDp; + + if (id == R.bool.abs__action_bar_embed_tabs) { + if (widthDp >= 480) { + return true; //values-w480dp + } + return false; //values + } + if (id == R.bool.abs__split_action_bar_is_narrow) { + if (widthDp >= 480) { + return false; //values-w480dp + } + return true; //values + } + if (id == R.bool.abs__action_bar_expanded_action_views_exclusive) { + if (smallestWidthDp >= 600) { + return false; //values-sw600dp + } + return true; //values + } + if (id == R.bool.abs__config_allowActionMenuItemTextWithIcon) { + if (widthDp >= 480) { + return true; //values-w480dp + } + return false; //values + } + + throw new IllegalArgumentException("Unknown boolean resource ID " + id); + } + + /** + * Support implementation of {@code getResources().getInteger()} that we + * can use to simulate filtering based on width qualifiers on pre-3.2. + * + * @param context Context to load integers from on 3.2+ and to fetch the + * display metrics. + * @param id Id of integer to load. + * @return Associated integer value as reflected by the current display + * metrics. + */ + public static int getResources_getInteger(Context context, int id) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { + return context.getResources().getInteger(id); + } + + DisplayMetrics metrics = context.getResources().getDisplayMetrics(); + float widthDp = metrics.widthPixels / metrics.density; + + if (id == R.integer.abs__max_action_buttons) { + if (widthDp >= 600) { + return 5; //values-w600dp + } + if (widthDp >= 500) { + return 4; //values-w500dp + } + if (widthDp >= 360) { + return 3; //values-w360dp + } + return 2; //values + } + + throw new IllegalArgumentException("Unknown integer resource ID " + id); + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/app/ActionBarImpl.java b/actionbarsherlock/src/com/actionbarsherlock/internal/app/ActionBarImpl.java new file mode 100644 index 000000000..6ae0402c0 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/app/ActionBarImpl.java @@ -0,0 +1,1026 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.app; + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import android.app.Activity; +import android.app.Dialog; +import android.content.Context; +import android.content.res.Configuration; +import android.content.res.Resources; +import android.graphics.drawable.Drawable; +import android.os.Build; +import android.os.Handler; +import android.support.v4.app.FragmentTransaction; +import android.util.TypedValue; +import android.view.ContextThemeWrapper; +import android.view.LayoutInflater; +import android.view.View; +import android.view.Window; +import android.view.accessibility.AccessibilityEvent; +import android.widget.SpinnerAdapter; +import com.actionbarsherlock.R; +import com.actionbarsherlock.app.ActionBar; +import com.actionbarsherlock.app.SherlockFragmentActivity; +import com.actionbarsherlock.internal.nineoldandroids.animation.Animator; +import com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorListenerAdapter; +import com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet; +import com.actionbarsherlock.internal.nineoldandroids.animation.ObjectAnimator; +import com.actionbarsherlock.internal.nineoldandroids.animation.Animator.AnimatorListener; +import com.actionbarsherlock.internal.nineoldandroids.widget.NineFrameLayout; +import com.actionbarsherlock.internal.view.menu.MenuBuilder; +import com.actionbarsherlock.internal.view.menu.MenuPopupHelper; +import com.actionbarsherlock.internal.view.menu.SubMenuBuilder; +import com.actionbarsherlock.internal.widget.ActionBarContainer; +import com.actionbarsherlock.internal.widget.ActionBarContextView; +import com.actionbarsherlock.internal.widget.ActionBarView; +import com.actionbarsherlock.internal.widget.ScrollingTabContainerView; +import com.actionbarsherlock.view.ActionMode; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; +import static com.actionbarsherlock.internal.ResourcesCompat.getResources_getBoolean; + +/** + * ActionBarImpl is the ActionBar implementation used + * by devices of all screen sizes. If it detects a compatible decor, + * it will split contextual modes across both the ActionBarView at + * the top of the screen and a horizontal LinearLayout at the bottom + * which is normally hidden. + */ +public class ActionBarImpl extends ActionBar { + //UNUSED private static final String TAG = "ActionBarImpl"; + + private Context mContext; + private Context mThemedContext; + private Activity mActivity; + //UNUSED private Dialog mDialog; + + private ActionBarContainer mContainerView; + private ActionBarView mActionView; + private ActionBarContextView mContextView; + private ActionBarContainer mSplitView; + private NineFrameLayout mContentView; + private ScrollingTabContainerView mTabScrollView; + + private ArrayList mTabs = new ArrayList(); + + private TabImpl mSelectedTab; + private int mSavedTabPosition = INVALID_POSITION; + + ActionModeImpl mActionMode; + ActionMode mDeferredDestroyActionMode; + ActionMode.Callback mDeferredModeDestroyCallback; + + private boolean mLastMenuVisibility; + private ArrayList mMenuVisibilityListeners = + new ArrayList(); + + private static final int CONTEXT_DISPLAY_NORMAL = 0; + private static final int CONTEXT_DISPLAY_SPLIT = 1; + + private static final int INVALID_POSITION = -1; + + private int mContextDisplayMode; + private boolean mHasEmbeddedTabs; + + final Handler mHandler = new Handler(); + Runnable mTabSelector; + + private Animator mCurrentShowAnim; + private Animator mCurrentModeAnim; + private boolean mShowHideAnimationEnabled; + boolean mWasHiddenBeforeMode; + + final AnimatorListener mHideListener = new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + if (mContentView != null) { + mContentView.setTranslationY(0); + mContainerView.setTranslationY(0); + } + if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) { + mSplitView.setVisibility(View.GONE); + } + mContainerView.setVisibility(View.GONE); + mContainerView.setTransitioning(false); + mCurrentShowAnim = null; + completeDeferredDestroyActionMode(); + } + }; + + final AnimatorListener mShowListener = new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + mCurrentShowAnim = null; + mContainerView.requestLayout(); + } + }; + + public ActionBarImpl(Activity activity, int features) { + mActivity = activity; + Window window = activity.getWindow(); + View decor = window.getDecorView(); + init(decor); + + //window.hasFeature() workaround for pre-3.0 + if ((features & (1 << Window.FEATURE_ACTION_BAR_OVERLAY)) == 0) { + mContentView = (NineFrameLayout)decor.findViewById(android.R.id.content); + } + } + + public ActionBarImpl(Dialog dialog) { + //UNUSED mDialog = dialog; + init(dialog.getWindow().getDecorView()); + } + + private void init(View decor) { + mContext = decor.getContext(); + mActionView = (ActionBarView) decor.findViewById(R.id.abs__action_bar); + mContextView = (ActionBarContextView) decor.findViewById( + R.id.abs__action_context_bar); + mContainerView = (ActionBarContainer) decor.findViewById( + R.id.abs__action_bar_container); + mSplitView = (ActionBarContainer) decor.findViewById( + R.id.abs__split_action_bar); + + if (mActionView == null || mContextView == null || mContainerView == null) { + throw new IllegalStateException(getClass().getSimpleName() + " can only be used " + + "with a compatible window decor layout"); + } + + mActionView.setContextView(mContextView); + mContextDisplayMode = mActionView.isSplitActionBar() ? + CONTEXT_DISPLAY_SPLIT : CONTEXT_DISPLAY_NORMAL; + + // Older apps get the home button interaction enabled by default. + // Newer apps need to enable it explicitly. + setHomeButtonEnabled(mContext.getApplicationInfo().targetSdkVersion < 14); + + setHasEmbeddedTabs(getResources_getBoolean(mContext, + R.bool.abs__action_bar_embed_tabs)); + } + + public void onConfigurationChanged(Configuration newConfig) { + setHasEmbeddedTabs(getResources_getBoolean(mContext, + R.bool.abs__action_bar_embed_tabs)); + + //Manually dispatch a configuration change to the action bar view on pre-2.2 + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) { + mActionView.onConfigurationChanged(newConfig); + if (mContextView != null) { + mContextView.onConfigurationChanged(newConfig); + } + } + } + + private void setHasEmbeddedTabs(boolean hasEmbeddedTabs) { + mHasEmbeddedTabs = hasEmbeddedTabs; + // Switch tab layout configuration if needed + if (!mHasEmbeddedTabs) { + mActionView.setEmbeddedTabView(null); + mContainerView.setTabContainer(mTabScrollView); + } else { + mContainerView.setTabContainer(null); + mActionView.setEmbeddedTabView(mTabScrollView); + } + final boolean isInTabMode = getNavigationMode() == NAVIGATION_MODE_TABS; + if (mTabScrollView != null) { + mTabScrollView.setVisibility(isInTabMode ? View.VISIBLE : View.GONE); + } + mActionView.setCollapsable(!mHasEmbeddedTabs && isInTabMode); + } + + private void ensureTabsExist() { + if (mTabScrollView != null) { + return; + } + + ScrollingTabContainerView tabScroller = new ScrollingTabContainerView(mContext); + + if (mHasEmbeddedTabs) { + tabScroller.setVisibility(View.VISIBLE); + mActionView.setEmbeddedTabView(tabScroller); + } else { + tabScroller.setVisibility(getNavigationMode() == NAVIGATION_MODE_TABS ? + View.VISIBLE : View.GONE); + mContainerView.setTabContainer(tabScroller); + } + mTabScrollView = tabScroller; + } + + void completeDeferredDestroyActionMode() { + if (mDeferredModeDestroyCallback != null) { + mDeferredModeDestroyCallback.onDestroyActionMode(mDeferredDestroyActionMode); + mDeferredDestroyActionMode = null; + mDeferredModeDestroyCallback = null; + } + } + + /** + * Enables or disables animation between show/hide states. + * If animation is disabled using this method, animations in progress + * will be finished. + * + * @param enabled true to animate, false to not animate. + */ + public void setShowHideAnimationEnabled(boolean enabled) { + mShowHideAnimationEnabled = enabled; + if (!enabled && mCurrentShowAnim != null) { + mCurrentShowAnim.end(); + } + } + + public void addOnMenuVisibilityListener(OnMenuVisibilityListener listener) { + mMenuVisibilityListeners.add(listener); + } + + public void removeOnMenuVisibilityListener(OnMenuVisibilityListener listener) { + mMenuVisibilityListeners.remove(listener); + } + + public void dispatchMenuVisibilityChanged(boolean isVisible) { + if (isVisible == mLastMenuVisibility) { + return; + } + mLastMenuVisibility = isVisible; + + final int count = mMenuVisibilityListeners.size(); + for (int i = 0; i < count; i++) { + mMenuVisibilityListeners.get(i).onMenuVisibilityChanged(isVisible); + } + } + + @Override + public void setCustomView(int resId) { + setCustomView(LayoutInflater.from(getThemedContext()).inflate(resId, mActionView, false)); + } + + @Override + public void setDisplayUseLogoEnabled(boolean useLogo) { + setDisplayOptions(useLogo ? DISPLAY_USE_LOGO : 0, DISPLAY_USE_LOGO); + } + + @Override + public void setDisplayShowHomeEnabled(boolean showHome) { + setDisplayOptions(showHome ? DISPLAY_SHOW_HOME : 0, DISPLAY_SHOW_HOME); + } + + @Override + public void setDisplayHomeAsUpEnabled(boolean showHomeAsUp) { + setDisplayOptions(showHomeAsUp ? DISPLAY_HOME_AS_UP : 0, DISPLAY_HOME_AS_UP); + } + + @Override + public void setDisplayShowTitleEnabled(boolean showTitle) { + setDisplayOptions(showTitle ? DISPLAY_SHOW_TITLE : 0, DISPLAY_SHOW_TITLE); + } + + @Override + public void setDisplayShowCustomEnabled(boolean showCustom) { + setDisplayOptions(showCustom ? DISPLAY_SHOW_CUSTOM : 0, DISPLAY_SHOW_CUSTOM); + } + + @Override + public void setHomeButtonEnabled(boolean enable) { + mActionView.setHomeButtonEnabled(enable); + } + + @Override + public void setTitle(int resId) { + setTitle(mContext.getString(resId)); + } + + @Override + public void setSubtitle(int resId) { + setSubtitle(mContext.getString(resId)); + } + + public void setSelectedNavigationItem(int position) { + switch (mActionView.getNavigationMode()) { + case NAVIGATION_MODE_TABS: + selectTab(mTabs.get(position)); + break; + case NAVIGATION_MODE_LIST: + mActionView.setDropdownSelectedPosition(position); + break; + default: + throw new IllegalStateException( + "setSelectedNavigationIndex not valid for current navigation mode"); + } + } + + public void removeAllTabs() { + cleanupTabs(); + } + + private void cleanupTabs() { + if (mSelectedTab != null) { + selectTab(null); + } + mTabs.clear(); + if (mTabScrollView != null) { + mTabScrollView.removeAllTabs(); + } + mSavedTabPosition = INVALID_POSITION; + } + + public void setTitle(CharSequence title) { + mActionView.setTitle(title); + } + + public void setSubtitle(CharSequence subtitle) { + mActionView.setSubtitle(subtitle); + } + + public void setDisplayOptions(int options) { + mActionView.setDisplayOptions(options); + } + + public void setDisplayOptions(int options, int mask) { + final int current = mActionView.getDisplayOptions(); + mActionView.setDisplayOptions((options & mask) | (current & ~mask)); + } + + public void setBackgroundDrawable(Drawable d) { + mContainerView.setPrimaryBackground(d); + } + + public void setStackedBackgroundDrawable(Drawable d) { + mContainerView.setStackedBackground(d); + } + + public void setSplitBackgroundDrawable(Drawable d) { + if (mSplitView != null) { + mSplitView.setSplitBackground(d); + } + } + + public View getCustomView() { + return mActionView.getCustomNavigationView(); + } + + public CharSequence getTitle() { + return mActionView.getTitle(); + } + + public CharSequence getSubtitle() { + return mActionView.getSubtitle(); + } + + public int getNavigationMode() { + return mActionView.getNavigationMode(); + } + + public int getDisplayOptions() { + return mActionView.getDisplayOptions(); + } + + public ActionMode startActionMode(ActionMode.Callback callback) { + boolean wasHidden = false; + if (mActionMode != null) { + wasHidden = mWasHiddenBeforeMode; + mActionMode.finish(); + } + + mContextView.killMode(); + ActionModeImpl mode = new ActionModeImpl(callback); + if (mode.dispatchOnCreate()) { + mWasHiddenBeforeMode = !isShowing() || wasHidden; + mode.invalidate(); + mContextView.initForMode(mode); + animateToMode(true); + if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) { + // TODO animate this + mSplitView.setVisibility(View.VISIBLE); + } + mContextView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); + mActionMode = mode; + return mode; + } + return null; + } + + private void configureTab(Tab tab, int position) { + final TabImpl tabi = (TabImpl) tab; + final ActionBar.TabListener callback = tabi.getCallback(); + + if (callback == null) { + throw new IllegalStateException("Action Bar Tab must have a Callback"); + } + + tabi.setPosition(position); + mTabs.add(position, tabi); + + final int count = mTabs.size(); + for (int i = position + 1; i < count; i++) { + mTabs.get(i).setPosition(i); + } + } + + @Override + public void addTab(Tab tab) { + addTab(tab, mTabs.isEmpty()); + } + + @Override + public void addTab(Tab tab, int position) { + addTab(tab, position, mTabs.isEmpty()); + } + + @Override + public void addTab(Tab tab, boolean setSelected) { + ensureTabsExist(); + mTabScrollView.addTab(tab, setSelected); + configureTab(tab, mTabs.size()); + if (setSelected) { + selectTab(tab); + } + } + + @Override + public void addTab(Tab tab, int position, boolean setSelected) { + ensureTabsExist(); + mTabScrollView.addTab(tab, position, setSelected); + configureTab(tab, position); + if (setSelected) { + selectTab(tab); + } + } + + @Override + public Tab newTab() { + return new TabImpl(); + } + + @Override + public void removeTab(Tab tab) { + removeTabAt(tab.getPosition()); + } + + @Override + public void removeTabAt(int position) { + if (mTabScrollView == null) { + // No tabs around to remove + return; + } + + int selectedTabPosition = mSelectedTab != null + ? mSelectedTab.getPosition() : mSavedTabPosition; + mTabScrollView.removeTabAt(position); + TabImpl removedTab = mTabs.remove(position); + if (removedTab != null) { + removedTab.setPosition(-1); + } + + final int newTabCount = mTabs.size(); + for (int i = position; i < newTabCount; i++) { + mTabs.get(i).setPosition(i); + } + + if (selectedTabPosition == position) { + selectTab(mTabs.isEmpty() ? null : mTabs.get(Math.max(0, position - 1))); + } + } + + @Override + public void selectTab(Tab tab) { + if (getNavigationMode() != NAVIGATION_MODE_TABS) { + mSavedTabPosition = tab != null ? tab.getPosition() : INVALID_POSITION; + return; + } + + FragmentTransaction trans = null; + if (mActivity instanceof SherlockFragmentActivity) { + trans = ((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction() + .disallowAddToBackStack(); + } + + if (mSelectedTab == tab) { + if (mSelectedTab != null) { + mSelectedTab.getCallback().onTabReselected(mSelectedTab, trans); + mTabScrollView.animateToTab(tab.getPosition()); + } + } else { + mTabScrollView.setTabSelected(tab != null ? tab.getPosition() : Tab.INVALID_POSITION); + if (mSelectedTab != null) { + mSelectedTab.getCallback().onTabUnselected(mSelectedTab, trans); + } + mSelectedTab = (TabImpl) tab; + if (mSelectedTab != null) { + mSelectedTab.getCallback().onTabSelected(mSelectedTab, trans); + } + } + + if (trans != null && !trans.isEmpty()) { + trans.commit(); + } + } + + @Override + public Tab getSelectedTab() { + return mSelectedTab; + } + + @Override + public int getHeight() { + return mContainerView.getHeight(); + } + + @Override + public void show() { + show(true); + } + + void show(boolean markHiddenBeforeMode) { + if (mCurrentShowAnim != null) { + mCurrentShowAnim.end(); + } + if (mContainerView.getVisibility() == View.VISIBLE) { + if (markHiddenBeforeMode) mWasHiddenBeforeMode = false; + return; + } + mContainerView.setVisibility(View.VISIBLE); + + if (mShowHideAnimationEnabled) { + mContainerView.setAlpha(0); + AnimatorSet anim = new AnimatorSet(); + AnimatorSet.Builder b = anim.play(ObjectAnimator.ofFloat(mContainerView, "alpha", 1)); + if (mContentView != null) { + b.with(ObjectAnimator.ofFloat(mContentView, "translationY", + -mContainerView.getHeight(), 0)); + mContainerView.setTranslationY(-mContainerView.getHeight()); + b.with(ObjectAnimator.ofFloat(mContainerView, "translationY", 0)); + } + if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) { + mSplitView.setAlpha(0); + mSplitView.setVisibility(View.VISIBLE); + b.with(ObjectAnimator.ofFloat(mSplitView, "alpha", 1)); + } + anim.addListener(mShowListener); + mCurrentShowAnim = anim; + anim.start(); + } else { + mContainerView.setAlpha(1); + mContainerView.setTranslationY(0); + mShowListener.onAnimationEnd(null); + } + } + + @Override + public void hide() { + if (mCurrentShowAnim != null) { + mCurrentShowAnim.end(); + } + if (mContainerView.getVisibility() == View.GONE) { + return; + } + + if (mShowHideAnimationEnabled) { + mContainerView.setAlpha(1); + mContainerView.setTransitioning(true); + AnimatorSet anim = new AnimatorSet(); + AnimatorSet.Builder b = anim.play(ObjectAnimator.ofFloat(mContainerView, "alpha", 0)); + if (mContentView != null) { + b.with(ObjectAnimator.ofFloat(mContentView, "translationY", + 0, -mContainerView.getHeight())); + b.with(ObjectAnimator.ofFloat(mContainerView, "translationY", + -mContainerView.getHeight())); + } + if (mSplitView != null && mSplitView.getVisibility() == View.VISIBLE) { + mSplitView.setAlpha(1); + b.with(ObjectAnimator.ofFloat(mSplitView, "alpha", 0)); + } + anim.addListener(mHideListener); + mCurrentShowAnim = anim; + anim.start(); + } else { + mHideListener.onAnimationEnd(null); + } + } + + public boolean isShowing() { + return mContainerView.getVisibility() == View.VISIBLE; + } + + void animateToMode(boolean toActionMode) { + if (toActionMode) { + show(false); + } + if (mCurrentModeAnim != null) { + mCurrentModeAnim.end(); + } + + mActionView.animateToVisibility(toActionMode ? View.GONE : View.VISIBLE); + mContextView.animateToVisibility(toActionMode ? View.VISIBLE : View.GONE); + if (mTabScrollView != null && !mActionView.hasEmbeddedTabs() && mActionView.isCollapsed()) { + mTabScrollView.animateToVisibility(toActionMode ? View.GONE : View.VISIBLE); + } + } + + public Context getThemedContext() { + if (mThemedContext == null) { + TypedValue outValue = new TypedValue(); + Resources.Theme currentTheme = mContext.getTheme(); + currentTheme.resolveAttribute(R.attr.actionBarWidgetTheme, + outValue, true); + final int targetThemeRes = outValue.resourceId; + + if (targetThemeRes != 0) { //XXX && mContext.getThemeResId() != targetThemeRes) { + mThemedContext = new ContextThemeWrapper(mContext, targetThemeRes); + } else { + mThemedContext = mContext; + } + } + return mThemedContext; + } + + /** + * @hide + */ + public class ActionModeImpl extends ActionMode implements MenuBuilder.Callback { + private ActionMode.Callback mCallback; + private MenuBuilder mMenu; + private WeakReference mCustomView; + + public ActionModeImpl(ActionMode.Callback callback) { + mCallback = callback; + mMenu = new MenuBuilder(getThemedContext()) + .setDefaultShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); + mMenu.setCallback(this); + } + + @Override + public MenuInflater getMenuInflater() { + return new MenuInflater(getThemedContext()); + } + + @Override + public Menu getMenu() { + return mMenu; + } + + @Override + public void finish() { + if (mActionMode != this) { + // Not the active action mode - no-op + return; + } + + // If we were hidden before the mode was shown, defer the onDestroy + // callback until the animation is finished and associated relayout + // is about to happen. This lets apps better anticipate visibility + // and layout behavior. + if (mWasHiddenBeforeMode) { + mDeferredDestroyActionMode = this; + mDeferredModeDestroyCallback = mCallback; + } else { + mCallback.onDestroyActionMode(this); + } + mCallback = null; + animateToMode(false); + + // Clear out the context mode views after the animation finishes + mContextView.closeMode(); + mActionView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); + + mActionMode = null; + + if (mWasHiddenBeforeMode) { + hide(); + } + } + + @Override + public void invalidate() { + mMenu.stopDispatchingItemsChanged(); + try { + mCallback.onPrepareActionMode(this, mMenu); + } finally { + mMenu.startDispatchingItemsChanged(); + } + } + + public boolean dispatchOnCreate() { + mMenu.stopDispatchingItemsChanged(); + try { + return mCallback.onCreateActionMode(this, mMenu); + } finally { + mMenu.startDispatchingItemsChanged(); + } + } + + @Override + public void setCustomView(View view) { + mContextView.setCustomView(view); + mCustomView = new WeakReference(view); + } + + @Override + public void setSubtitle(CharSequence subtitle) { + mContextView.setSubtitle(subtitle); + } + + @Override + public void setTitle(CharSequence title) { + mContextView.setTitle(title); + } + + @Override + public void setTitle(int resId) { + setTitle(mContext.getResources().getString(resId)); + } + + @Override + public void setSubtitle(int resId) { + setSubtitle(mContext.getResources().getString(resId)); + } + + @Override + public CharSequence getTitle() { + return mContextView.getTitle(); + } + + @Override + public CharSequence getSubtitle() { + return mContextView.getSubtitle(); + } + + @Override + public View getCustomView() { + return mCustomView != null ? mCustomView.get() : null; + } + + public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) { + if (mCallback != null) { + return mCallback.onActionItemClicked(this, item); + } else { + return false; + } + } + + public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) { + } + + public boolean onSubMenuSelected(SubMenuBuilder subMenu) { + if (mCallback == null) { + return false; + } + + if (!subMenu.hasVisibleItems()) { + return true; + } + + new MenuPopupHelper(getThemedContext(), subMenu).show(); + return true; + } + + public void onCloseSubMenu(SubMenuBuilder menu) { + } + + public void onMenuModeChange(MenuBuilder menu) { + if (mCallback == null) { + return; + } + invalidate(); + mContextView.showOverflowMenu(); + } + } + + /** + * @hide + */ + public class TabImpl extends ActionBar.Tab { + private ActionBar.TabListener mCallback; + private Object mTag; + private Drawable mIcon; + private CharSequence mText; + private CharSequence mContentDesc; + private int mPosition = -1; + private View mCustomView; + + @Override + public Object getTag() { + return mTag; + } + + @Override + public Tab setTag(Object tag) { + mTag = tag; + return this; + } + + public ActionBar.TabListener getCallback() { + return mCallback; + } + + @Override + public Tab setTabListener(ActionBar.TabListener callback) { + mCallback = callback; + return this; + } + + @Override + public View getCustomView() { + return mCustomView; + } + + @Override + public Tab setCustomView(View view) { + mCustomView = view; + if (mPosition >= 0) { + mTabScrollView.updateTab(mPosition); + } + return this; + } + + @Override + public Tab setCustomView(int layoutResId) { + return setCustomView(LayoutInflater.from(getThemedContext()) + .inflate(layoutResId, null)); + } + + @Override + public Drawable getIcon() { + return mIcon; + } + + @Override + public int getPosition() { + return mPosition; + } + + public void setPosition(int position) { + mPosition = position; + } + + @Override + public CharSequence getText() { + return mText; + } + + @Override + public Tab setIcon(Drawable icon) { + mIcon = icon; + if (mPosition >= 0) { + mTabScrollView.updateTab(mPosition); + } + return this; + } + + @Override + public Tab setIcon(int resId) { + return setIcon(mContext.getResources().getDrawable(resId)); + } + + @Override + public Tab setText(CharSequence text) { + mText = text; + if (mPosition >= 0) { + mTabScrollView.updateTab(mPosition); + } + return this; + } + + @Override + public Tab setText(int resId) { + return setText(mContext.getResources().getText(resId)); + } + + @Override + public void select() { + selectTab(this); + } + + @Override + public Tab setContentDescription(int resId) { + return setContentDescription(mContext.getResources().getText(resId)); + } + + @Override + public Tab setContentDescription(CharSequence contentDesc) { + mContentDesc = contentDesc; + if (mPosition >= 0) { + mTabScrollView.updateTab(mPosition); + } + return this; + } + + @Override + public CharSequence getContentDescription() { + return mContentDesc; + } + } + + @Override + public void setCustomView(View view) { + mActionView.setCustomNavigationView(view); + } + + @Override + public void setCustomView(View view, LayoutParams layoutParams) { + view.setLayoutParams(layoutParams); + mActionView.setCustomNavigationView(view); + } + + @Override + public void setListNavigationCallbacks(SpinnerAdapter adapter, OnNavigationListener callback) { + mActionView.setDropdownAdapter(adapter); + mActionView.setCallback(callback); + } + + @Override + public int getSelectedNavigationIndex() { + switch (mActionView.getNavigationMode()) { + case NAVIGATION_MODE_TABS: + return mSelectedTab != null ? mSelectedTab.getPosition() : -1; + case NAVIGATION_MODE_LIST: + return mActionView.getDropdownSelectedPosition(); + default: + return -1; + } + } + + @Override + public int getNavigationItemCount() { + switch (mActionView.getNavigationMode()) { + case NAVIGATION_MODE_TABS: + return mTabs.size(); + case NAVIGATION_MODE_LIST: + SpinnerAdapter adapter = mActionView.getDropdownAdapter(); + return adapter != null ? adapter.getCount() : 0; + default: + return 0; + } + } + + @Override + public int getTabCount() { + return mTabs.size(); + } + + @Override + public void setNavigationMode(int mode) { + final int oldMode = mActionView.getNavigationMode(); + switch (oldMode) { + case NAVIGATION_MODE_TABS: + mSavedTabPosition = getSelectedNavigationIndex(); + selectTab(null); + mTabScrollView.setVisibility(View.GONE); + break; + } + mActionView.setNavigationMode(mode); + switch (mode) { + case NAVIGATION_MODE_TABS: + ensureTabsExist(); + mTabScrollView.setVisibility(View.VISIBLE); + if (mSavedTabPosition != INVALID_POSITION) { + setSelectedNavigationItem(mSavedTabPosition); + mSavedTabPosition = INVALID_POSITION; + } + break; + } + mActionView.setCollapsable(mode == NAVIGATION_MODE_TABS && !mHasEmbeddedTabs); + } + + @Override + public Tab getTabAt(int index) { + return mTabs.get(index); + } + + + @Override + public void setIcon(int resId) { + mActionView.setIcon(resId); + } + + @Override + public void setIcon(Drawable icon) { + mActionView.setIcon(icon); + } + + @Override + public void setLogo(int resId) { + mActionView.setLogo(resId); + } + + @Override + public void setLogo(Drawable logo) { + mActionView.setLogo(logo); + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/app/ActionBarWrapper.java b/actionbarsherlock/src/com/actionbarsherlock/internal/app/ActionBarWrapper.java new file mode 100644 index 000000000..e390ea428 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/app/ActionBarWrapper.java @@ -0,0 +1,468 @@ +package com.actionbarsherlock.internal.app; + +import java.util.HashSet; +import java.util.Set; + +import android.app.Activity; +import android.content.Context; +import android.graphics.drawable.Drawable; +import android.support.v4.app.FragmentTransaction; +import android.view.View; +import android.widget.SpinnerAdapter; + +import com.actionbarsherlock.app.ActionBar; +import com.actionbarsherlock.app.SherlockFragmentActivity; + +public class ActionBarWrapper extends ActionBar implements android.app.ActionBar.OnNavigationListener, android.app.ActionBar.OnMenuVisibilityListener { + private final Activity mActivity; + private final android.app.ActionBar mActionBar; + private ActionBar.OnNavigationListener mNavigationListener; + private Set mMenuVisibilityListeners = new HashSet(1); + private FragmentTransaction mFragmentTransaction; + + + public ActionBarWrapper(Activity activity) { + mActivity = activity; + mActionBar = activity.getActionBar(); + if (mActionBar != null) { + mActionBar.addOnMenuVisibilityListener(this); + } + } + + + @Override + public void setHomeButtonEnabled(boolean enabled) { + mActionBar.setHomeButtonEnabled(enabled); + } + + @Override + public Context getThemedContext() { + return mActionBar.getThemedContext(); + } + + @Override + public void setCustomView(View view) { + mActionBar.setCustomView(view); + } + + @Override + public void setCustomView(View view, LayoutParams layoutParams) { + android.app.ActionBar.LayoutParams lp = new android.app.ActionBar.LayoutParams(layoutParams); + lp.gravity = layoutParams.gravity; + lp.bottomMargin = layoutParams.bottomMargin; + lp.topMargin = layoutParams.topMargin; + lp.leftMargin = layoutParams.leftMargin; + lp.rightMargin = layoutParams.rightMargin; + mActionBar.setCustomView(view, lp); + } + + @Override + public void setCustomView(int resId) { + mActionBar.setCustomView(resId); + } + + @Override + public void setIcon(int resId) { + mActionBar.setIcon(resId); + } + + @Override + public void setIcon(Drawable icon) { + mActionBar.setIcon(icon); + } + + @Override + public void setLogo(int resId) { + mActionBar.setLogo(resId); + } + + @Override + public void setLogo(Drawable logo) { + mActionBar.setLogo(logo); + } + + @Override + public void setListNavigationCallbacks(SpinnerAdapter adapter, OnNavigationListener callback) { + mNavigationListener = callback; + mActionBar.setListNavigationCallbacks(adapter, (callback != null) ? this : null); + } + + @Override + public boolean onNavigationItemSelected(int itemPosition, long itemId) { + //This should never be a NullPointerException since we only set + //ourselves as the listener when the callback is not null. + return mNavigationListener.onNavigationItemSelected(itemPosition, itemId); + } + + @Override + public void setSelectedNavigationItem(int position) { + mActionBar.setSelectedNavigationItem(position); + } + + @Override + public int getSelectedNavigationIndex() { + return mActionBar.getSelectedNavigationIndex(); + } + + @Override + public int getNavigationItemCount() { + return mActionBar.getNavigationItemCount(); + } + + @Override + public void setTitle(CharSequence title) { + mActionBar.setTitle(title); + } + + @Override + public void setTitle(int resId) { + mActionBar.setTitle(resId); + } + + @Override + public void setSubtitle(CharSequence subtitle) { + mActionBar.setSubtitle(subtitle); + } + + @Override + public void setSubtitle(int resId) { + mActionBar.setSubtitle(resId); + } + + @Override + public void setDisplayOptions(int options) { + mActionBar.setDisplayOptions(options); + } + + @Override + public void setDisplayOptions(int options, int mask) { + mActionBar.setDisplayOptions(options, mask); + } + + @Override + public void setDisplayUseLogoEnabled(boolean useLogo) { + mActionBar.setDisplayUseLogoEnabled(useLogo); + } + + @Override + public void setDisplayShowHomeEnabled(boolean showHome) { + mActionBar.setDisplayShowHomeEnabled(showHome); + } + + @Override + public void setDisplayHomeAsUpEnabled(boolean showHomeAsUp) { + mActionBar.setDisplayHomeAsUpEnabled(showHomeAsUp); + } + + @Override + public void setDisplayShowTitleEnabled(boolean showTitle) { + mActionBar.setDisplayShowTitleEnabled(showTitle); + } + + @Override + public void setDisplayShowCustomEnabled(boolean showCustom) { + mActionBar.setDisplayShowCustomEnabled(showCustom); + } + + @Override + public void setBackgroundDrawable(Drawable d) { + mActionBar.setBackgroundDrawable(d); + } + + @Override + public void setStackedBackgroundDrawable(Drawable d) { + mActionBar.setStackedBackgroundDrawable(d); + } + + @Override + public void setSplitBackgroundDrawable(Drawable d) { + mActionBar.setSplitBackgroundDrawable(d); + } + + @Override + public View getCustomView() { + return mActionBar.getCustomView(); + } + + @Override + public CharSequence getTitle() { + return mActionBar.getTitle(); + } + + @Override + public CharSequence getSubtitle() { + return mActionBar.getSubtitle(); + } + + @Override + public int getNavigationMode() { + return mActionBar.getNavigationMode(); + } + + @Override + public void setNavigationMode(int mode) { + mActionBar.setNavigationMode(mode); + } + + @Override + public int getDisplayOptions() { + return mActionBar.getDisplayOptions(); + } + + public class TabWrapper extends ActionBar.Tab implements android.app.ActionBar.TabListener { + final android.app.ActionBar.Tab mNativeTab; + private Object mTag; + private TabListener mListener; + + public TabWrapper(android.app.ActionBar.Tab nativeTab) { + mNativeTab = nativeTab; + mNativeTab.setTag(this); + } + + @Override + public int getPosition() { + return mNativeTab.getPosition(); + } + + @Override + public Drawable getIcon() { + return mNativeTab.getIcon(); + } + + @Override + public CharSequence getText() { + return mNativeTab.getText(); + } + + @Override + public Tab setIcon(Drawable icon) { + mNativeTab.setIcon(icon); + return this; + } + + @Override + public Tab setIcon(int resId) { + mNativeTab.setIcon(resId); + return this; + } + + @Override + public Tab setText(CharSequence text) { + mNativeTab.setText(text); + return this; + } + + @Override + public Tab setText(int resId) { + mNativeTab.setText(resId); + return this; + } + + @Override + public Tab setCustomView(View view) { + mNativeTab.setCustomView(view); + return this; + } + + @Override + public Tab setCustomView(int layoutResId) { + mNativeTab.setCustomView(layoutResId); + return this; + } + + @Override + public View getCustomView() { + return mNativeTab.getCustomView(); + } + + @Override + public Tab setTag(Object obj) { + mTag = obj; + return this; + } + + @Override + public Object getTag() { + return mTag; + } + + @Override + public Tab setTabListener(TabListener listener) { + mNativeTab.setTabListener(listener != null ? this : null); + mListener = listener; + return this; + } + + @Override + public void select() { + mNativeTab.select(); + } + + @Override + public Tab setContentDescription(int resId) { + mNativeTab.setContentDescription(resId); + return this; + } + + @Override + public Tab setContentDescription(CharSequence contentDesc) { + mNativeTab.setContentDescription(contentDesc); + return this; + } + + @Override + public CharSequence getContentDescription() { + return mNativeTab.getContentDescription(); + } + + @Override + public void onTabReselected(android.app.ActionBar.Tab tab, android.app.FragmentTransaction ft) { + if (mListener != null) { + FragmentTransaction trans = null; + if (mActivity instanceof SherlockFragmentActivity) { + trans = ((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction() + .disallowAddToBackStack(); + } + + mListener.onTabReselected(this, trans); + + if (trans != null && !trans.isEmpty()) { + trans.commit(); + } + } + } + + @Override + public void onTabSelected(android.app.ActionBar.Tab tab, android.app.FragmentTransaction ft) { + if (mListener != null) { + + if (mFragmentTransaction == null && mActivity instanceof SherlockFragmentActivity) { + mFragmentTransaction = ((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction() + .disallowAddToBackStack(); + } + + mListener.onTabSelected(this, mFragmentTransaction); + + if (mFragmentTransaction != null) { + if (!mFragmentTransaction.isEmpty()) { + mFragmentTransaction.commit(); + } + mFragmentTransaction = null; + } + } + } + + @Override + public void onTabUnselected(android.app.ActionBar.Tab tab, android.app.FragmentTransaction ft) { + if (mListener != null) { + FragmentTransaction trans = null; + if (mActivity instanceof SherlockFragmentActivity) { + trans = ((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction() + .disallowAddToBackStack(); + mFragmentTransaction = trans; + } + + mListener.onTabUnselected(this, trans); + } + } + } + + @Override + public Tab newTab() { + return new TabWrapper(mActionBar.newTab()); + } + + @Override + public void addTab(Tab tab) { + mActionBar.addTab(((TabWrapper)tab).mNativeTab); + } + + @Override + public void addTab(Tab tab, boolean setSelected) { + mActionBar.addTab(((TabWrapper)tab).mNativeTab, setSelected); + } + + @Override + public void addTab(Tab tab, int position) { + mActionBar.addTab(((TabWrapper)tab).mNativeTab, position); + } + + @Override + public void addTab(Tab tab, int position, boolean setSelected) { + mActionBar.addTab(((TabWrapper)tab).mNativeTab, position, setSelected); + } + + @Override + public void removeTab(Tab tab) { + mActionBar.removeTab(((TabWrapper)tab).mNativeTab); + } + + @Override + public void removeTabAt(int position) { + mActionBar.removeTabAt(position); + } + + @Override + public void removeAllTabs() { + mActionBar.removeAllTabs(); + } + + @Override + public void selectTab(Tab tab) { + mActionBar.selectTab(((TabWrapper)tab).mNativeTab); + } + + @Override + public Tab getSelectedTab() { + android.app.ActionBar.Tab selected = mActionBar.getSelectedTab(); + return (selected != null) ? (Tab)selected.getTag() : null; + } + + @Override + public Tab getTabAt(int index) { + android.app.ActionBar.Tab selected = mActionBar.getTabAt(index); + return (selected != null) ? (Tab)selected.getTag() : null; + } + + @Override + public int getTabCount() { + return mActionBar.getTabCount(); + } + + @Override + public int getHeight() { + return mActionBar.getHeight(); + } + + @Override + public void show() { + mActionBar.show(); + } + + @Override + public void hide() { + mActionBar.hide(); + } + + @Override + public boolean isShowing() { + return mActionBar.isShowing(); + } + + @Override + public void addOnMenuVisibilityListener(OnMenuVisibilityListener listener) { + mMenuVisibilityListeners.add(listener); + } + + @Override + public void removeOnMenuVisibilityListener(OnMenuVisibilityListener listener) { + mMenuVisibilityListeners.remove(listener); + } + + @Override + public void onMenuVisibilityChanged(boolean isVisible) { + for (OnMenuVisibilityListener listener : mMenuVisibilityListeners) { + listener.onMenuVisibilityChanged(isVisible); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/Animator.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/Animator.java new file mode 100644 index 000000000..2caf5b4a9 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/Animator.java @@ -0,0 +1,278 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; + +import java.util.ArrayList; + +import android.view.animation.Interpolator; + +/** + * This is the superclass for classes which provide basic support for animations which can be + * started, ended, and have AnimatorListeners added to them. + */ +public abstract class Animator implements Cloneable { + + + /** + * The set of listeners to be sent events through the life of an animation. + */ + ArrayList mListeners = null; + + /** + * Starts this animation. If the animation has a nonzero startDelay, the animation will start + * running after that delay elapses. A non-delayed animation will have its initial + * value(s) set immediately, followed by calls to + * {@link AnimatorListener#onAnimationStart(Animator)} for any listeners of this animator. + * + *

The animation started by calling this method will be run on the thread that called + * this method. This thread should have a Looper on it (a runtime exception will be thrown if + * this is not the case). Also, if the animation will animate + * properties of objects in the view hierarchy, then the calling thread should be the UI + * thread for that view hierarchy.

+ * + */ + public void start() { + } + + /** + * Cancels the animation. Unlike {@link #end()}, cancel() causes the animation to + * stop in its tracks, sending an + * {@link android.animation.Animator.AnimatorListener#onAnimationCancel(Animator)} to + * its listeners, followed by an + * {@link android.animation.Animator.AnimatorListener#onAnimationEnd(Animator)} message. + * + *

This method must be called on the thread that is running the animation.

+ */ + public void cancel() { + } + + /** + * Ends the animation. This causes the animation to assign the end value of the property being + * animated, then calling the + * {@link android.animation.Animator.AnimatorListener#onAnimationEnd(Animator)} method on + * its listeners. + * + *

This method must be called on the thread that is running the animation.

+ */ + public void end() { + } + + /** + * The amount of time, in milliseconds, to delay starting the animation after + * {@link #start()} is called. + * + * @return the number of milliseconds to delay running the animation + */ + public abstract long getStartDelay(); + + /** + * The amount of time, in milliseconds, to delay starting the animation after + * {@link #start()} is called. + + * @param startDelay The amount of the delay, in milliseconds + */ + public abstract void setStartDelay(long startDelay); + + + /** + * Sets the length of the animation. + * + * @param duration The length of the animation, in milliseconds. + */ + public abstract Animator setDuration(long duration); + + /** + * Gets the length of the animation. + * + * @return The length of the animation, in milliseconds. + */ + public abstract long getDuration(); + + /** + * The time interpolator used in calculating the elapsed fraction of this animation. The + * interpolator determines whether the animation runs with linear or non-linear motion, + * such as acceleration and deceleration. The default value is + * {@link android.view.animation.AccelerateDecelerateInterpolator} + * + * @param value the interpolator to be used by this animation + */ + public abstract void setInterpolator(/*Time*/Interpolator value); + + /** + * Returns whether this Animator is currently running (having been started and gone past any + * initial startDelay period and not yet ended). + * + * @return Whether the Animator is running. + */ + public abstract boolean isRunning(); + + /** + * Returns whether this Animator has been started and not yet ended. This state is a superset + * of the state of {@link #isRunning()}, because an Animator with a nonzero + * {@link #getStartDelay() startDelay} will return true for {@link #isStarted()} during the + * delay phase, whereas {@link #isRunning()} will return true only after the delay phase + * is complete. + * + * @return Whether the Animator has been started and not yet ended. + */ + public boolean isStarted() { + // Default method returns value for isRunning(). Subclasses should override to return a + // real value. + return isRunning(); + } + + /** + * Adds a listener to the set of listeners that are sent events through the life of an + * animation, such as start, repeat, and end. + * + * @param listener the listener to be added to the current set of listeners for this animation. + */ + public void addListener(AnimatorListener listener) { + if (mListeners == null) { + mListeners = new ArrayList(); + } + mListeners.add(listener); + } + + /** + * Removes a listener from the set listening to this animation. + * + * @param listener the listener to be removed from the current set of listeners for this + * animation. + */ + public void removeListener(AnimatorListener listener) { + if (mListeners == null) { + return; + } + mListeners.remove(listener); + if (mListeners.size() == 0) { + mListeners = null; + } + } + + /** + * Gets the set of {@link android.animation.Animator.AnimatorListener} objects that are currently + * listening for events on this Animator object. + * + * @return ArrayList The set of listeners. + */ + public ArrayList getListeners() { + return mListeners; + } + + /** + * Removes all listeners from this object. This is equivalent to calling + * getListeners() followed by calling clear() on the + * returned list of listeners. + */ + public void removeAllListeners() { + if (mListeners != null) { + mListeners.clear(); + mListeners = null; + } + } + + @Override + public Animator clone() { + try { + final Animator anim = (Animator) super.clone(); + if (mListeners != null) { + ArrayList oldListeners = mListeners; + anim.mListeners = new ArrayList(); + int numListeners = oldListeners.size(); + for (int i = 0; i < numListeners; ++i) { + anim.mListeners.add(oldListeners.get(i)); + } + } + return anim; + } catch (CloneNotSupportedException e) { + throw new AssertionError(); + } + } + + /** + * This method tells the object to use appropriate information to extract + * starting values for the animation. For example, a AnimatorSet object will pass + * this call to its child objects to tell them to set up the values. A + * ObjectAnimator object will use the information it has about its target object + * and PropertyValuesHolder objects to get the start values for its properties. + * An ValueAnimator object will ignore the request since it does not have enough + * information (such as a target object) to gather these values. + */ + public void setupStartValues() { + } + + /** + * This method tells the object to use appropriate information to extract + * ending values for the animation. For example, a AnimatorSet object will pass + * this call to its child objects to tell them to set up the values. A + * ObjectAnimator object will use the information it has about its target object + * and PropertyValuesHolder objects to get the start values for its properties. + * An ValueAnimator object will ignore the request since it does not have enough + * information (such as a target object) to gather these values. + */ + public void setupEndValues() { + } + + /** + * Sets the target object whose property will be animated by this animation. Not all subclasses + * operate on target objects (for example, {@link ValueAnimator}, but this method + * is on the superclass for the convenience of dealing generically with those subclasses + * that do handle targets. + * + * @param target The object being animated + */ + public void setTarget(Object target) { + } + + /** + *

An animation listener receives notifications from an animation. + * Notifications indicate animation related events, such as the end or the + * repetition of the animation.

+ */ + public static interface AnimatorListener { + /** + *

Notifies the start of the animation.

+ * + * @param animation The started animation. + */ + void onAnimationStart(Animator animation); + + /** + *

Notifies the end of the animation. This callback is not invoked + * for animations with repeat count set to INFINITE.

+ * + * @param animation The animation which reached its end. + */ + void onAnimationEnd(Animator animation); + + /** + *

Notifies the cancellation of the animation. This callback is not invoked + * for animations with repeat count set to INFINITE.

+ * + * @param animation The animation which was canceled. + */ + void onAnimationCancel(Animator animation); + + /** + *

Notifies the repetition of the animation.

+ * + * @param animation The animation which was repeated. + */ + void onAnimationRepeat(Animator animation); + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorListenerAdapter.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorListenerAdapter.java new file mode 100644 index 000000000..02ddff48d --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorListenerAdapter.java @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; + +/** + * This adapter class provides empty implementations of the methods from {@link android.animation.Animator.AnimatorListener}. + * Any custom listener that cares only about a subset of the methods of this listener can + * simply subclass this adapter class instead of implementing the interface directly. + */ +public abstract class AnimatorListenerAdapter implements Animator.AnimatorListener { + + /** + * {@inheritDoc} + */ + @Override + public void onAnimationCancel(Animator animation) { + } + + /** + * {@inheritDoc} + */ + @Override + public void onAnimationEnd(Animator animation) { + } + + /** + * {@inheritDoc} + */ + @Override + public void onAnimationRepeat(Animator animation) { + } + + /** + * {@inheritDoc} + */ + @Override + public void onAnimationStart(Animator animation) { + } + +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorSet.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorSet.java new file mode 100644 index 000000000..3231080c4 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorSet.java @@ -0,0 +1,1111 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; + +import android.view.animation.Interpolator; + +/** + * This class plays a set of {@link Animator} objects in the specified order. Animations + * can be set up to play together, in sequence, or after a specified delay. + * + *

There are two different approaches to adding animations to a AnimatorSet: + * either the {@link AnimatorSet#playTogether(Animator[]) playTogether()} or + * {@link AnimatorSet#playSequentially(Animator[]) playSequentially()} methods can be called to add + * a set of animations all at once, or the {@link AnimatorSet#play(Animator)} can be + * used in conjunction with methods in the {@link AnimatorSet.Builder Builder} + * class to add animations + * one by one.

+ * + *

It is possible to set up a AnimatorSet with circular dependencies between + * its animations. For example, an animation a1 could be set up to start before animation a2, a2 + * before a3, and a3 before a1. The results of this configuration are undefined, but will typically + * result in none of the affected animations being played. Because of this (and because + * circular dependencies do not make logical sense anyway), circular dependencies + * should be avoided, and the dependency flow of animations should only be in one direction. + */ +@SuppressWarnings("unchecked") +public final class AnimatorSet extends Animator { + + /** + * Internal variables + * NOTE: This object implements the clone() method, making a deep copy of any referenced + * objects. As other non-trivial fields are added to this class, make sure to add logic + * to clone() to make deep copies of them. + */ + + /** + * Tracks animations currently being played, so that we know what to + * cancel or end when cancel() or end() is called on this AnimatorSet + */ + private ArrayList mPlayingSet = new ArrayList(); + + /** + * Contains all nodes, mapped to their respective Animators. When new + * dependency information is added for an Animator, we want to add it + * to a single node representing that Animator, not create a new Node + * if one already exists. + */ + private HashMap mNodeMap = new HashMap(); + + /** + * Set of all nodes created for this AnimatorSet. This list is used upon + * starting the set, and the nodes are placed in sorted order into the + * sortedNodes collection. + */ + private ArrayList mNodes = new ArrayList(); + + /** + * The sorted list of nodes. This is the order in which the animations will + * be played. The details about when exactly they will be played depend + * on the dependency relationships of the nodes. + */ + private ArrayList mSortedNodes = new ArrayList(); + + /** + * Flag indicating whether the nodes should be sorted prior to playing. This + * flag allows us to cache the previous sorted nodes so that if the sequence + * is replayed with no changes, it does not have to re-sort the nodes again. + */ + private boolean mNeedsSort = true; + + private AnimatorSetListener mSetListener = null; + + /** + * Flag indicating that the AnimatorSet has been manually + * terminated (by calling cancel() or end()). + * This flag is used to avoid starting other animations when currently-playing + * child animations of this AnimatorSet end. It also determines whether cancel/end + * notifications are sent out via the normal AnimatorSetListener mechanism. + */ + boolean mTerminated = false; + + /** + * Indicates whether an AnimatorSet has been start()'d, whether or + * not there is a nonzero startDelay. + */ + private boolean mStarted = false; + + // The amount of time in ms to delay starting the animation after start() is called + private long mStartDelay = 0; + + // Animator used for a nonzero startDelay + private ValueAnimator mDelayAnim = null; + + + // How long the child animations should last in ms. The default value is negative, which + // simply means that there is no duration set on the AnimatorSet. When a real duration is + // set, it is passed along to the child animations. + private long mDuration = -1; + + + /** + * Sets up this AnimatorSet to play all of the supplied animations at the same time. + * + * @param items The animations that will be started simultaneously. + */ + public void playTogether(Animator... items) { + if (items != null) { + mNeedsSort = true; + Builder builder = play(items[0]); + for (int i = 1; i < items.length; ++i) { + builder.with(items[i]); + } + } + } + + /** + * Sets up this AnimatorSet to play all of the supplied animations at the same time. + * + * @param items The animations that will be started simultaneously. + */ + public void playTogether(Collection items) { + if (items != null && items.size() > 0) { + mNeedsSort = true; + Builder builder = null; + for (Animator anim : items) { + if (builder == null) { + builder = play(anim); + } else { + builder.with(anim); + } + } + } + } + + /** + * Sets up this AnimatorSet to play each of the supplied animations when the + * previous animation ends. + * + * @param items The animations that will be started one after another. + */ + public void playSequentially(Animator... items) { + if (items != null) { + mNeedsSort = true; + if (items.length == 1) { + play(items[0]); + } else { + for (int i = 0; i < items.length - 1; ++i) { + play(items[i]).before(items[i+1]); + } + } + } + } + + /** + * Sets up this AnimatorSet to play each of the supplied animations when the + * previous animation ends. + * + * @param items The animations that will be started one after another. + */ + public void playSequentially(List items) { + if (items != null && items.size() > 0) { + mNeedsSort = true; + if (items.size() == 1) { + play(items.get(0)); + } else { + for (int i = 0; i < items.size() - 1; ++i) { + play(items.get(i)).before(items.get(i+1)); + } + } + } + } + + /** + * Returns the current list of child Animator objects controlled by this + * AnimatorSet. This is a copy of the internal list; modifications to the returned list + * will not affect the AnimatorSet, although changes to the underlying Animator objects + * will affect those objects being managed by the AnimatorSet. + * + * @return ArrayList The list of child animations of this AnimatorSet. + */ + public ArrayList getChildAnimations() { + ArrayList childList = new ArrayList(); + for (Node node : mNodes) { + childList.add(node.animation); + } + return childList; + } + + /** + * Sets the target object for all current {@link #getChildAnimations() child animations} + * of this AnimatorSet that take targets ({@link ObjectAnimator} and + * AnimatorSet). + * + * @param target The object being animated + */ + @Override + public void setTarget(Object target) { + for (Node node : mNodes) { + Animator animation = node.animation; + if (animation instanceof AnimatorSet) { + ((AnimatorSet)animation).setTarget(target); + } else if (animation instanceof ObjectAnimator) { + ((ObjectAnimator)animation).setTarget(target); + } + } + } + + /** + * Sets the TimeInterpolator for all current {@link #getChildAnimations() child animations} + * of this AnimatorSet. + * + * @param interpolator the interpolator to be used by each child animation of this AnimatorSet + */ + @Override + public void setInterpolator(/*Time*/Interpolator interpolator) { + for (Node node : mNodes) { + node.animation.setInterpolator(interpolator); + } + } + + /** + * This method creates a Builder object, which is used to + * set up playing constraints. This initial play() method + * tells the Builder the animation that is the dependency for + * the succeeding commands to the Builder. For example, + * calling play(a1).with(a2) sets up the AnimatorSet to play + * a1 and a2 at the same time, + * play(a1).before(a2) sets up the AnimatorSet to play + * a1 first, followed by a2, and + * play(a1).after(a2) sets up the AnimatorSet to play + * a2 first, followed by a1. + * + *

Note that play() is the only way to tell the + * Builder the animation upon which the dependency is created, + * so successive calls to the various functions in Builder + * will all refer to the initial parameter supplied in play() + * as the dependency of the other animations. For example, calling + * play(a1).before(a2).before(a3) will play both a2 + * and a3 when a1 ends; it does not set up a dependency between + * a2 and a3.

+ * + * @param anim The animation that is the dependency used in later calls to the + * methods in the returned Builder object. A null parameter will result + * in a null Builder return value. + * @return Builder The object that constructs the AnimatorSet based on the dependencies + * outlined in the calls to play and the other methods in the + * BuilderNote that canceling a AnimatorSet also cancels all of the animations that it + * is responsible for.

+ */ + @Override + public void cancel() { + mTerminated = true; + if (isStarted()) { + ArrayList tmpListeners = null; + if (mListeners != null) { + tmpListeners = (ArrayList) mListeners.clone(); + for (AnimatorListener listener : tmpListeners) { + listener.onAnimationCancel(this); + } + } + if (mDelayAnim != null && mDelayAnim.isRunning()) { + // If we're currently in the startDelay period, just cancel that animator and + // send out the end event to all listeners + mDelayAnim.cancel(); + } else if (mSortedNodes.size() > 0) { + for (Node node : mSortedNodes) { + node.animation.cancel(); + } + } + if (tmpListeners != null) { + for (AnimatorListener listener : tmpListeners) { + listener.onAnimationEnd(this); + } + } + mStarted = false; + } + } + + /** + * {@inheritDoc} + * + *

Note that ending a AnimatorSet also ends all of the animations that it is + * responsible for.

+ */ + @Override + public void end() { + mTerminated = true; + if (isStarted()) { + if (mSortedNodes.size() != mNodes.size()) { + // hasn't been started yet - sort the nodes now, then end them + sortNodes(); + for (Node node : mSortedNodes) { + if (mSetListener == null) { + mSetListener = new AnimatorSetListener(this); + } + node.animation.addListener(mSetListener); + } + } + if (mDelayAnim != null) { + mDelayAnim.cancel(); + } + if (mSortedNodes.size() > 0) { + for (Node node : mSortedNodes) { + node.animation.end(); + } + } + if (mListeners != null) { + ArrayList tmpListeners = + (ArrayList) mListeners.clone(); + for (AnimatorListener listener : tmpListeners) { + listener.onAnimationEnd(this); + } + } + mStarted = false; + } + } + + /** + * Returns true if any of the child animations of this AnimatorSet have been started and have + * not yet ended. + * @return Whether this AnimatorSet has been started and has not yet ended. + */ + @Override + public boolean isRunning() { + for (Node node : mNodes) { + if (node.animation.isRunning()) { + return true; + } + } + return false; + } + + @Override + public boolean isStarted() { + return mStarted; + } + + /** + * The amount of time, in milliseconds, to delay starting the animation after + * {@link #start()} is called. + * + * @return the number of milliseconds to delay running the animation + */ + @Override + public long getStartDelay() { + return mStartDelay; + } + + /** + * The amount of time, in milliseconds, to delay starting the animation after + * {@link #start()} is called. + + * @param startDelay The amount of the delay, in milliseconds + */ + @Override + public void setStartDelay(long startDelay) { + mStartDelay = startDelay; + } + + /** + * Gets the length of each of the child animations of this AnimatorSet. This value may + * be less than 0, which indicates that no duration has been set on this AnimatorSet + * and each of the child animations will use their own duration. + * + * @return The length of the animation, in milliseconds, of each of the child + * animations of this AnimatorSet. + */ + @Override + public long getDuration() { + return mDuration; + } + + /** + * Sets the length of each of the current child animations of this AnimatorSet. By default, + * each child animation will use its own duration. If the duration is set on the AnimatorSet, + * then each child animation inherits this duration. + * + * @param duration The length of the animation, in milliseconds, of each of the child + * animations of this AnimatorSet. + */ + @Override + public AnimatorSet setDuration(long duration) { + if (duration < 0) { + throw new IllegalArgumentException("duration must be a value of zero or greater"); + } + for (Node node : mNodes) { + // TODO: don't set the duration of the timing-only nodes created by AnimatorSet to + // insert "play-after" delays + node.animation.setDuration(duration); + } + mDuration = duration; + return this; + } + + @Override + public void setupStartValues() { + for (Node node : mNodes) { + node.animation.setupStartValues(); + } + } + + @Override + public void setupEndValues() { + for (Node node : mNodes) { + node.animation.setupEndValues(); + } + } + + /** + * {@inheritDoc} + * + *

Starting this AnimatorSet will, in turn, start the animations for which + * it is responsible. The details of when exactly those animations are started depends on + * the dependency relationships that have been set up between the animations. + */ + @Override + public void start() { + mTerminated = false; + mStarted = true; + + // First, sort the nodes (if necessary). This will ensure that sortedNodes + // contains the animation nodes in the correct order. + sortNodes(); + + int numSortedNodes = mSortedNodes.size(); + for (int i = 0; i < numSortedNodes; ++i) { + Node node = mSortedNodes.get(i); + // First, clear out the old listeners + ArrayList oldListeners = node.animation.getListeners(); + if (oldListeners != null && oldListeners.size() > 0) { + final ArrayList clonedListeners = new + ArrayList(oldListeners); + + for (AnimatorListener listener : clonedListeners) { + if (listener instanceof DependencyListener || + listener instanceof AnimatorSetListener) { + node.animation.removeListener(listener); + } + } + } + } + + // nodesToStart holds the list of nodes to be started immediately. We don't want to + // start the animations in the loop directly because we first need to set up + // dependencies on all of the nodes. For example, we don't want to start an animation + // when some other animation also wants to start when the first animation begins. + final ArrayList nodesToStart = new ArrayList(); + for (int i = 0; i < numSortedNodes; ++i) { + Node node = mSortedNodes.get(i); + if (mSetListener == null) { + mSetListener = new AnimatorSetListener(this); + } + if (node.dependencies == null || node.dependencies.size() == 0) { + nodesToStart.add(node); + } else { + int numDependencies = node.dependencies.size(); + for (int j = 0; j < numDependencies; ++j) { + Dependency dependency = node.dependencies.get(j); + dependency.node.animation.addListener( + new DependencyListener(this, node, dependency.rule)); + } + node.tmpDependencies = (ArrayList) node.dependencies.clone(); + } + node.animation.addListener(mSetListener); + } + // Now that all dependencies are set up, start the animations that should be started. + if (mStartDelay <= 0) { + for (Node node : nodesToStart) { + node.animation.start(); + mPlayingSet.add(node.animation); + } + } else { + mDelayAnim = ValueAnimator.ofFloat(0f, 1f); + mDelayAnim.setDuration(mStartDelay); + mDelayAnim.addListener(new AnimatorListenerAdapter() { + boolean canceled = false; + public void onAnimationCancel(Animator anim) { + canceled = true; + } + public void onAnimationEnd(Animator anim) { + if (!canceled) { + int numNodes = nodesToStart.size(); + for (int i = 0; i < numNodes; ++i) { + Node node = nodesToStart.get(i); + node.animation.start(); + mPlayingSet.add(node.animation); + } + } + } + }); + mDelayAnim.start(); + } + if (mListeners != null) { + ArrayList tmpListeners = + (ArrayList) mListeners.clone(); + int numListeners = tmpListeners.size(); + for (int i = 0; i < numListeners; ++i) { + tmpListeners.get(i).onAnimationStart(this); + } + } + if (mNodes.size() == 0 && mStartDelay == 0) { + // Handle unusual case where empty AnimatorSet is started - should send out + // end event immediately since the event will not be sent out at all otherwise + mStarted = false; + if (mListeners != null) { + ArrayList tmpListeners = + (ArrayList) mListeners.clone(); + int numListeners = tmpListeners.size(); + for (int i = 0; i < numListeners; ++i) { + tmpListeners.get(i).onAnimationEnd(this); + } + } + } + } + + @Override + public AnimatorSet clone() { + final AnimatorSet anim = (AnimatorSet) super.clone(); + /* + * The basic clone() operation copies all items. This doesn't work very well for + * AnimatorSet, because it will copy references that need to be recreated and state + * that may not apply. What we need to do now is put the clone in an uninitialized + * state, with fresh, empty data structures. Then we will build up the nodes list + * manually, as we clone each Node (and its animation). The clone will then be sorted, + * and will populate any appropriate lists, when it is started. + */ + anim.mNeedsSort = true; + anim.mTerminated = false; + anim.mStarted = false; + anim.mPlayingSet = new ArrayList(); + anim.mNodeMap = new HashMap(); + anim.mNodes = new ArrayList(); + anim.mSortedNodes = new ArrayList(); + + // Walk through the old nodes list, cloning each node and adding it to the new nodemap. + // One problem is that the old node dependencies point to nodes in the old AnimatorSet. + // We need to track the old/new nodes in order to reconstruct the dependencies in the clone. + HashMap nodeCloneMap = new HashMap(); // + for (Node node : mNodes) { + Node nodeClone = node.clone(); + nodeCloneMap.put(node, nodeClone); + anim.mNodes.add(nodeClone); + anim.mNodeMap.put(nodeClone.animation, nodeClone); + // Clear out the dependencies in the clone; we'll set these up manually later + nodeClone.dependencies = null; + nodeClone.tmpDependencies = null; + nodeClone.nodeDependents = null; + nodeClone.nodeDependencies = null; + // clear out any listeners that were set up by the AnimatorSet; these will + // be set up when the clone's nodes are sorted + ArrayList cloneListeners = nodeClone.animation.getListeners(); + if (cloneListeners != null) { + ArrayList listenersToRemove = null; + for (AnimatorListener listener : cloneListeners) { + if (listener instanceof AnimatorSetListener) { + if (listenersToRemove == null) { + listenersToRemove = new ArrayList(); + } + listenersToRemove.add(listener); + } + } + if (listenersToRemove != null) { + for (AnimatorListener listener : listenersToRemove) { + cloneListeners.remove(listener); + } + } + } + } + // Now that we've cloned all of the nodes, we're ready to walk through their + // dependencies, mapping the old dependencies to the new nodes + for (Node node : mNodes) { + Node nodeClone = nodeCloneMap.get(node); + if (node.dependencies != null) { + for (Dependency dependency : node.dependencies) { + Node clonedDependencyNode = nodeCloneMap.get(dependency.node); + Dependency cloneDependency = new Dependency(clonedDependencyNode, + dependency.rule); + nodeClone.addDependency(cloneDependency); + } + } + } + + return anim; + } + + /** + * This class is the mechanism by which animations are started based on events in other + * animations. If an animation has multiple dependencies on other animations, then + * all dependencies must be satisfied before the animation is started. + */ + private static class DependencyListener implements AnimatorListener { + + private AnimatorSet mAnimatorSet; + + // The node upon which the dependency is based. + private Node mNode; + + // The Dependency rule (WITH or AFTER) that the listener should wait for on + // the node + private int mRule; + + public DependencyListener(AnimatorSet animatorSet, Node node, int rule) { + this.mAnimatorSet = animatorSet; + this.mNode = node; + this.mRule = rule; + } + + /** + * Ignore cancel events for now. We may want to handle this eventually, + * to prevent follow-on animations from running when some dependency + * animation is canceled. + */ + public void onAnimationCancel(Animator animation) { + } + + /** + * An end event is received - see if this is an event we are listening for + */ + public void onAnimationEnd(Animator animation) { + if (mRule == Dependency.AFTER) { + startIfReady(animation); + } + } + + /** + * Ignore repeat events for now + */ + public void onAnimationRepeat(Animator animation) { + } + + /** + * A start event is received - see if this is an event we are listening for + */ + public void onAnimationStart(Animator animation) { + if (mRule == Dependency.WITH) { + startIfReady(animation); + } + } + + /** + * Check whether the event received is one that the node was waiting for. + * If so, mark it as complete and see whether it's time to start + * the animation. + * @param dependencyAnimation the animation that sent the event. + */ + private void startIfReady(Animator dependencyAnimation) { + if (mAnimatorSet.mTerminated) { + // if the parent AnimatorSet was canceled, then don't start any dependent anims + return; + } + Dependency dependencyToRemove = null; + int numDependencies = mNode.tmpDependencies.size(); + for (int i = 0; i < numDependencies; ++i) { + Dependency dependency = mNode.tmpDependencies.get(i); + if (dependency.rule == mRule && + dependency.node.animation == dependencyAnimation) { + // rule fired - remove the dependency and listener and check to + // see whether it's time to start the animation + dependencyToRemove = dependency; + dependencyAnimation.removeListener(this); + break; + } + } + mNode.tmpDependencies.remove(dependencyToRemove); + if (mNode.tmpDependencies.size() == 0) { + // all dependencies satisfied: start the animation + mNode.animation.start(); + mAnimatorSet.mPlayingSet.add(mNode.animation); + } + } + + } + + private class AnimatorSetListener implements AnimatorListener { + + private AnimatorSet mAnimatorSet; + + AnimatorSetListener(AnimatorSet animatorSet) { + mAnimatorSet = animatorSet; + } + + public void onAnimationCancel(Animator animation) { + if (!mTerminated) { + // Listeners are already notified of the AnimatorSet canceling in cancel(). + // The logic below only kicks in when animations end normally + if (mPlayingSet.size() == 0) { + if (mListeners != null) { + int numListeners = mListeners.size(); + for (int i = 0; i < numListeners; ++i) { + mListeners.get(i).onAnimationCancel(mAnimatorSet); + } + } + } + } + } + + public void onAnimationEnd(Animator animation) { + animation.removeListener(this); + mPlayingSet.remove(animation); + Node animNode = mAnimatorSet.mNodeMap.get(animation); + animNode.done = true; + if (!mTerminated) { + // Listeners are already notified of the AnimatorSet ending in cancel() or + // end(); the logic below only kicks in when animations end normally + ArrayList sortedNodes = mAnimatorSet.mSortedNodes; + boolean allDone = true; + int numSortedNodes = sortedNodes.size(); + for (int i = 0; i < numSortedNodes; ++i) { + if (!sortedNodes.get(i).done) { + allDone = false; + break; + } + } + if (allDone) { + // If this was the last child animation to end, then notify listeners that this + // AnimatorSet has ended + if (mListeners != null) { + ArrayList tmpListeners = + (ArrayList) mListeners.clone(); + int numListeners = tmpListeners.size(); + for (int i = 0; i < numListeners; ++i) { + tmpListeners.get(i).onAnimationEnd(mAnimatorSet); + } + } + mAnimatorSet.mStarted = false; + } + } + } + + // Nothing to do + public void onAnimationRepeat(Animator animation) { + } + + // Nothing to do + public void onAnimationStart(Animator animation) { + } + + } + + /** + * This method sorts the current set of nodes, if needed. The sort is a simple + * DependencyGraph sort, which goes like this: + * - All nodes without dependencies become 'roots' + * - while roots list is not null + * - for each root r + * - add r to sorted list + * - remove r as a dependency from any other node + * - any nodes with no dependencies are added to the roots list + */ + private void sortNodes() { + if (mNeedsSort) { + mSortedNodes.clear(); + ArrayList roots = new ArrayList(); + int numNodes = mNodes.size(); + for (int i = 0; i < numNodes; ++i) { + Node node = mNodes.get(i); + if (node.dependencies == null || node.dependencies.size() == 0) { + roots.add(node); + } + } + ArrayList tmpRoots = new ArrayList(); + while (roots.size() > 0) { + int numRoots = roots.size(); + for (int i = 0; i < numRoots; ++i) { + Node root = roots.get(i); + mSortedNodes.add(root); + if (root.nodeDependents != null) { + int numDependents = root.nodeDependents.size(); + for (int j = 0; j < numDependents; ++j) { + Node node = root.nodeDependents.get(j); + node.nodeDependencies.remove(root); + if (node.nodeDependencies.size() == 0) { + tmpRoots.add(node); + } + } + } + } + roots.clear(); + roots.addAll(tmpRoots); + tmpRoots.clear(); + } + mNeedsSort = false; + if (mSortedNodes.size() != mNodes.size()) { + throw new IllegalStateException("Circular dependencies cannot exist" + + " in AnimatorSet"); + } + } else { + // Doesn't need sorting, but still need to add in the nodeDependencies list + // because these get removed as the event listeners fire and the dependencies + // are satisfied + int numNodes = mNodes.size(); + for (int i = 0; i < numNodes; ++i) { + Node node = mNodes.get(i); + if (node.dependencies != null && node.dependencies.size() > 0) { + int numDependencies = node.dependencies.size(); + for (int j = 0; j < numDependencies; ++j) { + Dependency dependency = node.dependencies.get(j); + if (node.nodeDependencies == null) { + node.nodeDependencies = new ArrayList(); + } + if (!node.nodeDependencies.contains(dependency.node)) { + node.nodeDependencies.add(dependency.node); + } + } + } + // nodes are 'done' by default; they become un-done when started, and done + // again when ended + node.done = false; + } + } + } + + /** + * Dependency holds information about the node that some other node is + * dependent upon and the nature of that dependency. + * + */ + private static class Dependency { + static final int WITH = 0; // dependent node must start with this dependency node + static final int AFTER = 1; // dependent node must start when this dependency node finishes + + // The node that the other node with this Dependency is dependent upon + public Node node; + + // The nature of the dependency (WITH or AFTER) + public int rule; + + public Dependency(Node node, int rule) { + this.node = node; + this.rule = rule; + } + } + + /** + * A Node is an embodiment of both the Animator that it wraps as well as + * any dependencies that are associated with that Animation. This includes + * both dependencies upon other nodes (in the dependencies list) as + * well as dependencies of other nodes upon this (in the nodeDependents list). + */ + private static class Node implements Cloneable { + public Animator animation; + + /** + * These are the dependencies that this node's animation has on other + * nodes. For example, if this node's animation should begin with some + * other animation ends, then there will be an item in this node's + * dependencies list for that other animation's node. + */ + public ArrayList dependencies = null; + + /** + * tmpDependencies is a runtime detail. We use the dependencies list for sorting. + * But we also use the list to keep track of when multiple dependencies are satisfied, + * but removing each dependency as it is satisfied. We do not want to remove + * the dependency itself from the list, because we need to retain that information + * if the AnimatorSet is launched in the future. So we create a copy of the dependency + * list when the AnimatorSet starts and use this tmpDependencies list to track the + * list of satisfied dependencies. + */ + public ArrayList tmpDependencies = null; + + /** + * nodeDependencies is just a list of the nodes that this Node is dependent upon. + * This information is used in sortNodes(), to determine when a node is a root. + */ + public ArrayList nodeDependencies = null; + + /** + * nodeDepdendents is the list of nodes that have this node as a dependency. This + * is a utility field used in sortNodes to facilitate removing this node as a + * dependency when it is a root node. + */ + public ArrayList nodeDependents = null; + + /** + * Flag indicating whether the animation in this node is finished. This flag + * is used by AnimatorSet to check, as each animation ends, whether all child animations + * are done and it's time to send out an end event for the entire AnimatorSet. + */ + public boolean done = false; + + /** + * Constructs the Node with the animation that it encapsulates. A Node has no + * dependencies by default; dependencies are added via the addDependency() + * method. + * + * @param animation The animation that the Node encapsulates. + */ + public Node(Animator animation) { + this.animation = animation; + } + + /** + * Add a dependency to this Node. The dependency includes information about the + * node that this node is dependency upon and the nature of the dependency. + * @param dependency + */ + public void addDependency(Dependency dependency) { + if (dependencies == null) { + dependencies = new ArrayList(); + nodeDependencies = new ArrayList(); + } + dependencies.add(dependency); + if (!nodeDependencies.contains(dependency.node)) { + nodeDependencies.add(dependency.node); + } + Node dependencyNode = dependency.node; + if (dependencyNode.nodeDependents == null) { + dependencyNode.nodeDependents = new ArrayList(); + } + dependencyNode.nodeDependents.add(this); + } + + @Override + public Node clone() { + try { + Node node = (Node) super.clone(); + node.animation = animation.clone(); + return node; + } catch (CloneNotSupportedException e) { + throw new AssertionError(); + } + } + } + + /** + * The Builder object is a utility class to facilitate adding animations to a + * AnimatorSet along with the relationships between the various animations. The + * intention of the Builder methods, along with the {@link + * AnimatorSet#play(Animator) play()} method of AnimatorSet is to make it possible + * to express the dependency relationships of animations in a natural way. Developers can also + * use the {@link AnimatorSet#playTogether(Animator[]) playTogether()} and {@link + * AnimatorSet#playSequentially(Animator[]) playSequentially()} methods if these suit the need, + * but it might be easier in some situations to express the AnimatorSet of animations in pairs. + *

+ *

The Builder object cannot be constructed directly, but is rather constructed + * internally via a call to {@link AnimatorSet#play(Animator)}.

+ *

+ *

For example, this sets up a AnimatorSet to play anim1 and anim2 at the same time, anim3 to + * play when anim2 finishes, and anim4 to play when anim3 finishes:

+ *
+     *     AnimatorSet s = new AnimatorSet();
+     *     s.play(anim1).with(anim2);
+     *     s.play(anim2).before(anim3);
+     *     s.play(anim4).after(anim3);
+     * 
+ *

+ *

Note in the example that both {@link Builder#before(Animator)} and {@link + * Builder#after(Animator)} are used. These are just different ways of expressing the same + * relationship and are provided to make it easier to say things in a way that is more natural, + * depending on the situation.

+ *

+ *

It is possible to make several calls into the same Builder object to express + * multiple relationships. However, note that it is only the animation passed into the initial + * {@link AnimatorSet#play(Animator)} method that is the dependency in any of the successive + * calls to the Builder object. For example, the following code starts both anim2 + * and anim3 when anim1 ends; there is no direct dependency relationship between anim2 and + * anim3: + *

+     *   AnimatorSet s = new AnimatorSet();
+     *   s.play(anim1).before(anim2).before(anim3);
+     * 
+ * If the desired result is to play anim1 then anim2 then anim3, this code expresses the + * relationship correctly:

+ *
+     *   AnimatorSet s = new AnimatorSet();
+     *   s.play(anim1).before(anim2);
+     *   s.play(anim2).before(anim3);
+     * 
+ *

+ *

Note that it is possible to express relationships that cannot be resolved and will not + * result in sensible results. For example, play(anim1).after(anim1) makes no + * sense. In general, circular dependencies like this one (or more indirect ones where a depends + * on b, which depends on c, which depends on a) should be avoided. Only create AnimatorSets + * that can boil down to a simple, one-way relationship of animations starting with, before, and + * after other, different, animations.

+ */ + public class Builder { + + /** + * This tracks the current node being processed. It is supplied to the play() method + * of AnimatorSet and passed into the constructor of Builder. + */ + private Node mCurrentNode; + + /** + * package-private constructor. Builders are only constructed by AnimatorSet, when the + * play() method is called. + * + * @param anim The animation that is the dependency for the other animations passed into + * the other methods of this Builder object. + */ + Builder(Animator anim) { + mCurrentNode = mNodeMap.get(anim); + if (mCurrentNode == null) { + mCurrentNode = new Node(anim); + mNodeMap.put(anim, mCurrentNode); + mNodes.add(mCurrentNode); + } + } + + /** + * Sets up the given animation to play at the same time as the animation supplied in the + * {@link AnimatorSet#play(Animator)} call that created this Builder object. + * + * @param anim The animation that will play when the animation supplied to the + * {@link AnimatorSet#play(Animator)} method starts. + */ + public Builder with(Animator anim) { + Node node = mNodeMap.get(anim); + if (node == null) { + node = new Node(anim); + mNodeMap.put(anim, node); + mNodes.add(node); + } + Dependency dependency = new Dependency(mCurrentNode, Dependency.WITH); + node.addDependency(dependency); + return this; + } + + /** + * Sets up the given animation to play when the animation supplied in the + * {@link AnimatorSet#play(Animator)} call that created this Builder object + * ends. + * + * @param anim The animation that will play when the animation supplied to the + * {@link AnimatorSet#play(Animator)} method ends. + */ + public Builder before(Animator anim) { + Node node = mNodeMap.get(anim); + if (node == null) { + node = new Node(anim); + mNodeMap.put(anim, node); + mNodes.add(node); + } + Dependency dependency = new Dependency(mCurrentNode, Dependency.AFTER); + node.addDependency(dependency); + return this; + } + + /** + * Sets up the given animation to play when the animation supplied in the + * {@link AnimatorSet#play(Animator)} call that created this Builder object + * to start when the animation supplied in this method call ends. + * + * @param anim The animation whose end will cause the animation supplied to the + * {@link AnimatorSet#play(Animator)} method to play. + */ + public Builder after(Animator anim) { + Node node = mNodeMap.get(anim); + if (node == null) { + node = new Node(anim); + mNodeMap.put(anim, node); + mNodes.add(node); + } + Dependency dependency = new Dependency(node, Dependency.AFTER); + mCurrentNode.addDependency(dependency); + return this; + } + + /** + * Sets up the animation supplied in the + * {@link AnimatorSet#play(Animator)} call that created this Builder object + * to play when the given amount of time elapses. + * + * @param delay The number of milliseconds that should elapse before the + * animation starts. + */ + public Builder after(long delay) { + // setup dummy ValueAnimator just to run the clock + ValueAnimator anim = ValueAnimator.ofFloat(0f, 1f); + anim.setDuration(delay); + after(anim); + return this; + } + + } + +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatEvaluator.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatEvaluator.java new file mode 100644 index 000000000..e41019364 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatEvaluator.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; + +/** + * This evaluator can be used to perform type interpolation between float values. + */ +public class FloatEvaluator implements TypeEvaluator { + + /** + * This function returns the result of linearly interpolating the start and end values, with + * fraction representing the proportion between the start and end values. The + * calculation is a simple parametric calculation: result = x0 + t * (v1 - v0), + * where x0 is startValue, x1 is endValue, + * and t is fraction. + * + * @param fraction The fraction from the starting to the ending values + * @param startValue The start value; should be of type float or + * Float + * @param endValue The end value; should be of type float or Float + * @return A linear interpolation between the start and end values, given the + * fraction parameter. + */ + public Float evaluate(float fraction, Number startValue, Number endValue) { + float startFloat = startValue.floatValue(); + return startFloat + fraction * (endValue.floatValue() - startFloat); + } +} \ No newline at end of file diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatKeyframeSet.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatKeyframeSet.java new file mode 100644 index 000000000..6d9dafa7a --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatKeyframeSet.java @@ -0,0 +1,136 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; + +import java.util.ArrayList; +import android.view.animation.Interpolator; + +import com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.FloatKeyframe; + +/** + * This class holds a collection of FloatKeyframe objects and is called by ValueAnimator to calculate + * values between those keyframes for a given animation. The class internal to the animation + * package because it is an implementation detail of how Keyframes are stored and used. + * + *

This type-specific subclass of KeyframeSet, along with the other type-specific subclass for + * int, exists to speed up the getValue() method when there is no custom + * TypeEvaluator set for the animation, so that values can be calculated without autoboxing to the + * Object equivalents of these primitive types.

+ */ +@SuppressWarnings("unchecked") +class FloatKeyframeSet extends KeyframeSet { + private float firstValue; + private float lastValue; + private float deltaValue; + private boolean firstTime = true; + + public FloatKeyframeSet(FloatKeyframe... keyframes) { + super(keyframes); + } + + @Override + public Object getValue(float fraction) { + return getFloatValue(fraction); + } + + @Override + public FloatKeyframeSet clone() { + ArrayList keyframes = mKeyframes; + int numKeyframes = mKeyframes.size(); + FloatKeyframe[] newKeyframes = new FloatKeyframe[numKeyframes]; + for (int i = 0; i < numKeyframes; ++i) { + newKeyframes[i] = (FloatKeyframe) keyframes.get(i).clone(); + } + FloatKeyframeSet newSet = new FloatKeyframeSet(newKeyframes); + return newSet; + } + + public float getFloatValue(float fraction) { + if (mNumKeyframes == 2) { + if (firstTime) { + firstTime = false; + firstValue = ((FloatKeyframe) mKeyframes.get(0)).getFloatValue(); + lastValue = ((FloatKeyframe) mKeyframes.get(1)).getFloatValue(); + deltaValue = lastValue - firstValue; + } + if (mInterpolator != null) { + fraction = mInterpolator.getInterpolation(fraction); + } + if (mEvaluator == null) { + return firstValue + fraction * deltaValue; + } else { + return ((Number)mEvaluator.evaluate(fraction, firstValue, lastValue)).floatValue(); + } + } + if (fraction <= 0f) { + final FloatKeyframe prevKeyframe = (FloatKeyframe) mKeyframes.get(0); + final FloatKeyframe nextKeyframe = (FloatKeyframe) mKeyframes.get(1); + float prevValue = prevKeyframe.getFloatValue(); + float nextValue = nextKeyframe.getFloatValue(); + float prevFraction = prevKeyframe.getFraction(); + float nextFraction = nextKeyframe.getFraction(); + final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator(); + if (interpolator != null) { + fraction = interpolator.getInterpolation(fraction); + } + float intervalFraction = (fraction - prevFraction) / (nextFraction - prevFraction); + return mEvaluator == null ? + prevValue + intervalFraction * (nextValue - prevValue) : + ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)). + floatValue(); + } else if (fraction >= 1f) { + final FloatKeyframe prevKeyframe = (FloatKeyframe) mKeyframes.get(mNumKeyframes - 2); + final FloatKeyframe nextKeyframe = (FloatKeyframe) mKeyframes.get(mNumKeyframes - 1); + float prevValue = prevKeyframe.getFloatValue(); + float nextValue = nextKeyframe.getFloatValue(); + float prevFraction = prevKeyframe.getFraction(); + float nextFraction = nextKeyframe.getFraction(); + final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator(); + if (interpolator != null) { + fraction = interpolator.getInterpolation(fraction); + } + float intervalFraction = (fraction - prevFraction) / (nextFraction - prevFraction); + return mEvaluator == null ? + prevValue + intervalFraction * (nextValue - prevValue) : + ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)). + floatValue(); + } + FloatKeyframe prevKeyframe = (FloatKeyframe) mKeyframes.get(0); + for (int i = 1; i < mNumKeyframes; ++i) { + FloatKeyframe nextKeyframe = (FloatKeyframe) mKeyframes.get(i); + if (fraction < nextKeyframe.getFraction()) { + final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator(); + if (interpolator != null) { + fraction = interpolator.getInterpolation(fraction); + } + float intervalFraction = (fraction - prevKeyframe.getFraction()) / + (nextKeyframe.getFraction() - prevKeyframe.getFraction()); + float prevValue = prevKeyframe.getFloatValue(); + float nextValue = nextKeyframe.getFloatValue(); + return mEvaluator == null ? + prevValue + intervalFraction * (nextValue - prevValue) : + ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)). + floatValue(); + } + prevKeyframe = nextKeyframe; + } + // shouldn't get here + return ((Number)mKeyframes.get(mNumKeyframes - 1).getValue()).floatValue(); + } + +} + diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntEvaluator.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntEvaluator.java new file mode 100644 index 000000000..ed5e79ec6 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntEvaluator.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; + +/** + * This evaluator can be used to perform type interpolation between int values. + */ +public class IntEvaluator implements TypeEvaluator { + + /** + * This function returns the result of linearly interpolating the start and end values, with + * fraction representing the proportion between the start and end values. The + * calculation is a simple parametric calculation: result = x0 + t * (v1 - v0), + * where x0 is startValue, x1 is endValue, + * and t is fraction. + * + * @param fraction The fraction from the starting to the ending values + * @param startValue The start value; should be of type int or + * Integer + * @param endValue The end value; should be of type int or Integer + * @return A linear interpolation between the start and end values, given the + * fraction parameter. + */ + public Integer evaluate(float fraction, Integer startValue, Integer endValue) { + int startInt = startValue; + return (int)(startInt + fraction * (endValue - startInt)); + } +} \ No newline at end of file diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntKeyframeSet.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntKeyframeSet.java new file mode 100644 index 000000000..e9215e7f8 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntKeyframeSet.java @@ -0,0 +1,135 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; + +import java.util.ArrayList; +import android.view.animation.Interpolator; + +import com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.IntKeyframe; + +/** + * This class holds a collection of IntKeyframe objects and is called by ValueAnimator to calculate + * values between those keyframes for a given animation. The class internal to the animation + * package because it is an implementation detail of how Keyframes are stored and used. + * + *

This type-specific subclass of KeyframeSet, along with the other type-specific subclass for + * float, exists to speed up the getValue() method when there is no custom + * TypeEvaluator set for the animation, so that values can be calculated without autoboxing to the + * Object equivalents of these primitive types.

+ */ +@SuppressWarnings("unchecked") +class IntKeyframeSet extends KeyframeSet { + private int firstValue; + private int lastValue; + private int deltaValue; + private boolean firstTime = true; + + public IntKeyframeSet(IntKeyframe... keyframes) { + super(keyframes); + } + + @Override + public Object getValue(float fraction) { + return getIntValue(fraction); + } + + @Override + public IntKeyframeSet clone() { + ArrayList keyframes = mKeyframes; + int numKeyframes = mKeyframes.size(); + IntKeyframe[] newKeyframes = new IntKeyframe[numKeyframes]; + for (int i = 0; i < numKeyframes; ++i) { + newKeyframes[i] = (IntKeyframe) keyframes.get(i).clone(); + } + IntKeyframeSet newSet = new IntKeyframeSet(newKeyframes); + return newSet; + } + + public int getIntValue(float fraction) { + if (mNumKeyframes == 2) { + if (firstTime) { + firstTime = false; + firstValue = ((IntKeyframe) mKeyframes.get(0)).getIntValue(); + lastValue = ((IntKeyframe) mKeyframes.get(1)).getIntValue(); + deltaValue = lastValue - firstValue; + } + if (mInterpolator != null) { + fraction = mInterpolator.getInterpolation(fraction); + } + if (mEvaluator == null) { + return firstValue + (int)(fraction * deltaValue); + } else { + return ((Number)mEvaluator.evaluate(fraction, firstValue, lastValue)).intValue(); + } + } + if (fraction <= 0f) { + final IntKeyframe prevKeyframe = (IntKeyframe) mKeyframes.get(0); + final IntKeyframe nextKeyframe = (IntKeyframe) mKeyframes.get(1); + int prevValue = prevKeyframe.getIntValue(); + int nextValue = nextKeyframe.getIntValue(); + float prevFraction = prevKeyframe.getFraction(); + float nextFraction = nextKeyframe.getFraction(); + final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator(); + if (interpolator != null) { + fraction = interpolator.getInterpolation(fraction); + } + float intervalFraction = (fraction - prevFraction) / (nextFraction - prevFraction); + return mEvaluator == null ? + prevValue + (int)(intervalFraction * (nextValue - prevValue)) : + ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)). + intValue(); + } else if (fraction >= 1f) { + final IntKeyframe prevKeyframe = (IntKeyframe) mKeyframes.get(mNumKeyframes - 2); + final IntKeyframe nextKeyframe = (IntKeyframe) mKeyframes.get(mNumKeyframes - 1); + int prevValue = prevKeyframe.getIntValue(); + int nextValue = nextKeyframe.getIntValue(); + float prevFraction = prevKeyframe.getFraction(); + float nextFraction = nextKeyframe.getFraction(); + final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator(); + if (interpolator != null) { + fraction = interpolator.getInterpolation(fraction); + } + float intervalFraction = (fraction - prevFraction) / (nextFraction - prevFraction); + return mEvaluator == null ? + prevValue + (int)(intervalFraction * (nextValue - prevValue)) : + ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)).intValue(); + } + IntKeyframe prevKeyframe = (IntKeyframe) mKeyframes.get(0); + for (int i = 1; i < mNumKeyframes; ++i) { + IntKeyframe nextKeyframe = (IntKeyframe) mKeyframes.get(i); + if (fraction < nextKeyframe.getFraction()) { + final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator(); + if (interpolator != null) { + fraction = interpolator.getInterpolation(fraction); + } + float intervalFraction = (fraction - prevKeyframe.getFraction()) / + (nextKeyframe.getFraction() - prevKeyframe.getFraction()); + int prevValue = prevKeyframe.getIntValue(); + int nextValue = nextKeyframe.getIntValue(); + return mEvaluator == null ? + prevValue + (int)(intervalFraction * (nextValue - prevValue)) : + ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)). + intValue(); + } + prevKeyframe = nextKeyframe; + } + // shouldn't get here + return ((Number)mKeyframes.get(mNumKeyframes - 1).getValue()).intValue(); + } + +} + diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/Keyframe.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/Keyframe.java new file mode 100644 index 000000000..ab76fa7f6 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/Keyframe.java @@ -0,0 +1,361 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; + +import android.view.animation.Interpolator; + +/** + * This class holds a time/value pair for an animation. The Keyframe class is used + * by {@link ValueAnimator} to define the values that the animation target will have over the course + * of the animation. As the time proceeds from one keyframe to the other, the value of the + * target object will animate between the value at the previous keyframe and the value at the + * next keyframe. Each keyframe also holds an optional {@link TimeInterpolator} + * object, which defines the time interpolation over the intervalue preceding the keyframe. + * + *

The Keyframe class itself is abstract. The type-specific factory methods will return + * a subclass of Keyframe specific to the type of value being stored. This is done to improve + * performance when dealing with the most common cases (e.g., float and + * int values). Other types will fall into a more general Keyframe class that + * treats its values as Objects. Unless your animation requires dealing with a custom type + * or a data structure that needs to be animated directly (and evaluated using an implementation + * of {@link TypeEvaluator}), you should stick to using float and int as animations using those + * types have lower runtime overhead than other types.

+ */ +@SuppressWarnings("rawtypes") +public abstract class Keyframe implements Cloneable { + /** + * The time at which mValue will hold true. + */ + float mFraction; + + /** + * The type of the value in this Keyframe. This type is determined at construction time, + * based on the type of the value object passed into the constructor. + */ + Class mValueType; + + /** + * The optional time interpolator for the interval preceding this keyframe. A null interpolator + * (the default) results in linear interpolation over the interval. + */ + private /*Time*/Interpolator mInterpolator = null; + + /** + * Flag to indicate whether this keyframe has a valid value. This flag is used when an + * animation first starts, to populate placeholder keyframes with real values derived + * from the target object. + */ + boolean mHasValue = false; + + /** + * Constructs a Keyframe object with the given time and value. The time defines the + * time, as a proportion of an overall animation's duration, at which the value will hold true + * for the animation. The value for the animation between keyframes will be calculated as + * an interpolation between the values at those keyframes. + * + * @param fraction The time, expressed as a value between 0 and 1, representing the fraction + * of time elapsed of the overall animation duration. + * @param value The value that the object will animate to as the animation time approaches + * the time in this keyframe, and the the value animated from as the time passes the time in + * this keyframe. + */ + public static Keyframe ofInt(float fraction, int value) { + return new IntKeyframe(fraction, value); + } + + /** + * Constructs a Keyframe object with the given time. The value at this time will be derived + * from the target object when the animation first starts (note that this implies that keyframes + * with no initial value must be used as part of an {@link ObjectAnimator}). + * The time defines the + * time, as a proportion of an overall animation's duration, at which the value will hold true + * for the animation. The value for the animation between keyframes will be calculated as + * an interpolation between the values at those keyframes. + * + * @param fraction The time, expressed as a value between 0 and 1, representing the fraction + * of time elapsed of the overall animation duration. + */ + public static Keyframe ofInt(float fraction) { + return new IntKeyframe(fraction); + } + + /** + * Constructs a Keyframe object with the given time and value. The time defines the + * time, as a proportion of an overall animation's duration, at which the value will hold true + * for the animation. The value for the animation between keyframes will be calculated as + * an interpolation between the values at those keyframes. + * + * @param fraction The time, expressed as a value between 0 and 1, representing the fraction + * of time elapsed of the overall animation duration. + * @param value The value that the object will animate to as the animation time approaches + * the time in this keyframe, and the the value animated from as the time passes the time in + * this keyframe. + */ + public static Keyframe ofFloat(float fraction, float value) { + return new FloatKeyframe(fraction, value); + } + + /** + * Constructs a Keyframe object with the given time. The value at this time will be derived + * from the target object when the animation first starts (note that this implies that keyframes + * with no initial value must be used as part of an {@link ObjectAnimator}). + * The time defines the + * time, as a proportion of an overall animation's duration, at which the value will hold true + * for the animation. The value for the animation between keyframes will be calculated as + * an interpolation between the values at those keyframes. + * + * @param fraction The time, expressed as a value between 0 and 1, representing the fraction + * of time elapsed of the overall animation duration. + */ + public static Keyframe ofFloat(float fraction) { + return new FloatKeyframe(fraction); + } + + /** + * Constructs a Keyframe object with the given time and value. The time defines the + * time, as a proportion of an overall animation's duration, at which the value will hold true + * for the animation. The value for the animation between keyframes will be calculated as + * an interpolation between the values at those keyframes. + * + * @param fraction The time, expressed as a value between 0 and 1, representing the fraction + * of time elapsed of the overall animation duration. + * @param value The value that the object will animate to as the animation time approaches + * the time in this keyframe, and the the value animated from as the time passes the time in + * this keyframe. + */ + public static Keyframe ofObject(float fraction, Object value) { + return new ObjectKeyframe(fraction, value); + } + + /** + * Constructs a Keyframe object with the given time. The value at this time will be derived + * from the target object when the animation first starts (note that this implies that keyframes + * with no initial value must be used as part of an {@link ObjectAnimator}). + * The time defines the + * time, as a proportion of an overall animation's duration, at which the value will hold true + * for the animation. The value for the animation between keyframes will be calculated as + * an interpolation between the values at those keyframes. + * + * @param fraction The time, expressed as a value between 0 and 1, representing the fraction + * of time elapsed of the overall animation duration. + */ + public static Keyframe ofObject(float fraction) { + return new ObjectKeyframe(fraction, null); + } + + /** + * Indicates whether this keyframe has a valid value. This method is called internally when + * an {@link ObjectAnimator} first starts; keyframes without values are assigned values at + * that time by deriving the value for the property from the target object. + * + * @return boolean Whether this object has a value assigned. + */ + public boolean hasValue() { + return mHasValue; + } + + /** + * Gets the value for this Keyframe. + * + * @return The value for this Keyframe. + */ + public abstract Object getValue(); + + /** + * Sets the value for this Keyframe. + * + * @param value value for this Keyframe. + */ + public abstract void setValue(Object value); + + /** + * Gets the time for this keyframe, as a fraction of the overall animation duration. + * + * @return The time associated with this keyframe, as a fraction of the overall animation + * duration. This should be a value between 0 and 1. + */ + public float getFraction() { + return mFraction; + } + + /** + * Sets the time for this keyframe, as a fraction of the overall animation duration. + * + * @param fraction time associated with this keyframe, as a fraction of the overall animation + * duration. This should be a value between 0 and 1. + */ + public void setFraction(float fraction) { + mFraction = fraction; + } + + /** + * Gets the optional interpolator for this Keyframe. A value of null indicates + * that there is no interpolation, which is the same as linear interpolation. + * + * @return The optional interpolator for this Keyframe. + */ + public /*Time*/Interpolator getInterpolator() { + return mInterpolator; + } + + /** + * Sets the optional interpolator for this Keyframe. A value of null indicates + * that there is no interpolation, which is the same as linear interpolation. + * + * @return The optional interpolator for this Keyframe. + */ + public void setInterpolator(/*Time*/Interpolator interpolator) { + mInterpolator = interpolator; + } + + /** + * Gets the type of keyframe. This information is used by ValueAnimator to determine the type of + * {@link TypeEvaluator} to use when calculating values between keyframes. The type is based + * on the type of Keyframe created. + * + * @return The type of the value stored in the Keyframe. + */ + public Class getType() { + return mValueType; + } + + @Override + public abstract Keyframe clone(); + + /** + * This internal subclass is used for all types which are not int or float. + */ + static class ObjectKeyframe extends Keyframe { + + /** + * The value of the animation at the time mFraction. + */ + Object mValue; + + ObjectKeyframe(float fraction, Object value) { + mFraction = fraction; + mValue = value; + mHasValue = (value != null); + mValueType = mHasValue ? value.getClass() : Object.class; + } + + public Object getValue() { + return mValue; + } + + public void setValue(Object value) { + mValue = value; + mHasValue = (value != null); + } + + @Override + public ObjectKeyframe clone() { + ObjectKeyframe kfClone = new ObjectKeyframe(getFraction(), mValue); + kfClone.setInterpolator(getInterpolator()); + return kfClone; + } + } + + /** + * Internal subclass used when the keyframe value is of type int. + */ + static class IntKeyframe extends Keyframe { + + /** + * The value of the animation at the time mFraction. + */ + int mValue; + + IntKeyframe(float fraction, int value) { + mFraction = fraction; + mValue = value; + mValueType = int.class; + mHasValue = true; + } + + IntKeyframe(float fraction) { + mFraction = fraction; + mValueType = int.class; + } + + public int getIntValue() { + return mValue; + } + + public Object getValue() { + return mValue; + } + + public void setValue(Object value) { + if (value != null && value.getClass() == Integer.class) { + mValue = ((Integer)value).intValue(); + mHasValue = true; + } + } + + @Override + public IntKeyframe clone() { + IntKeyframe kfClone = new IntKeyframe(getFraction(), mValue); + kfClone.setInterpolator(getInterpolator()); + return kfClone; + } + } + + /** + * Internal subclass used when the keyframe value is of type float. + */ + static class FloatKeyframe extends Keyframe { + /** + * The value of the animation at the time mFraction. + */ + float mValue; + + FloatKeyframe(float fraction, float value) { + mFraction = fraction; + mValue = value; + mValueType = float.class; + mHasValue = true; + } + + FloatKeyframe(float fraction) { + mFraction = fraction; + mValueType = float.class; + } + + public float getFloatValue() { + return mValue; + } + + public Object getValue() { + return mValue; + } + + public void setValue(Object value) { + if (value != null && value.getClass() == Float.class) { + mValue = ((Float)value).floatValue(); + mHasValue = true; + } + } + + @Override + public FloatKeyframe clone() { + FloatKeyframe kfClone = new FloatKeyframe(getFraction(), mValue); + kfClone.setInterpolator(getInterpolator()); + return kfClone; + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/KeyframeSet.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/KeyframeSet.java new file mode 100644 index 000000000..a71e1ad3c --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/KeyframeSet.java @@ -0,0 +1,227 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; + +import java.util.ArrayList; +import java.util.Arrays; +import android.view.animation.Interpolator; + +import com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.FloatKeyframe; +import com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.IntKeyframe; +import com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.ObjectKeyframe; + +/** + * This class holds a collection of Keyframe objects and is called by ValueAnimator to calculate + * values between those keyframes for a given animation. The class internal to the animation + * package because it is an implementation detail of how Keyframes are stored and used. + */ +@SuppressWarnings({"rawtypes", "unchecked"}) +class KeyframeSet { + + int mNumKeyframes; + + Keyframe mFirstKeyframe; + Keyframe mLastKeyframe; + /*Time*/Interpolator mInterpolator; // only used in the 2-keyframe case + ArrayList mKeyframes; // only used when there are not 2 keyframes + TypeEvaluator mEvaluator; + + + public KeyframeSet(Keyframe... keyframes) { + mNumKeyframes = keyframes.length; + mKeyframes = new ArrayList(); + mKeyframes.addAll(Arrays.asList(keyframes)); + mFirstKeyframe = mKeyframes.get(0); + mLastKeyframe = mKeyframes.get(mNumKeyframes - 1); + mInterpolator = mLastKeyframe.getInterpolator(); + } + + public static KeyframeSet ofInt(int... values) { + int numKeyframes = values.length; + IntKeyframe keyframes[] = new IntKeyframe[Math.max(numKeyframes,2)]; + if (numKeyframes == 1) { + keyframes[0] = (IntKeyframe) Keyframe.ofInt(0f); + keyframes[1] = (IntKeyframe) Keyframe.ofInt(1f, values[0]); + } else { + keyframes[0] = (IntKeyframe) Keyframe.ofInt(0f, values[0]); + for (int i = 1; i < numKeyframes; ++i) { + keyframes[i] = (IntKeyframe) Keyframe.ofInt((float) i / (numKeyframes - 1), values[i]); + } + } + return new IntKeyframeSet(keyframes); + } + + public static KeyframeSet ofFloat(float... values) { + int numKeyframes = values.length; + FloatKeyframe keyframes[] = new FloatKeyframe[Math.max(numKeyframes,2)]; + if (numKeyframes == 1) { + keyframes[0] = (FloatKeyframe) Keyframe.ofFloat(0f); + keyframes[1] = (FloatKeyframe) Keyframe.ofFloat(1f, values[0]); + } else { + keyframes[0] = (FloatKeyframe) Keyframe.ofFloat(0f, values[0]); + for (int i = 1; i < numKeyframes; ++i) { + keyframes[i] = (FloatKeyframe) Keyframe.ofFloat((float) i / (numKeyframes - 1), values[i]); + } + } + return new FloatKeyframeSet(keyframes); + } + + public static KeyframeSet ofKeyframe(Keyframe... keyframes) { + // if all keyframes of same primitive type, create the appropriate KeyframeSet + int numKeyframes = keyframes.length; + boolean hasFloat = false; + boolean hasInt = false; + boolean hasOther = false; + for (int i = 0; i < numKeyframes; ++i) { + if (keyframes[i] instanceof FloatKeyframe) { + hasFloat = true; + } else if (keyframes[i] instanceof IntKeyframe) { + hasInt = true; + } else { + hasOther = true; + } + } + if (hasFloat && !hasInt && !hasOther) { + FloatKeyframe floatKeyframes[] = new FloatKeyframe[numKeyframes]; + for (int i = 0; i < numKeyframes; ++i) { + floatKeyframes[i] = (FloatKeyframe) keyframes[i]; + } + return new FloatKeyframeSet(floatKeyframes); + } else if (hasInt && !hasFloat && !hasOther) { + IntKeyframe intKeyframes[] = new IntKeyframe[numKeyframes]; + for (int i = 0; i < numKeyframes; ++i) { + intKeyframes[i] = (IntKeyframe) keyframes[i]; + } + return new IntKeyframeSet(intKeyframes); + } else { + return new KeyframeSet(keyframes); + } + } + + public static KeyframeSet ofObject(Object... values) { + int numKeyframes = values.length; + ObjectKeyframe keyframes[] = new ObjectKeyframe[Math.max(numKeyframes,2)]; + if (numKeyframes == 1) { + keyframes[0] = (ObjectKeyframe) Keyframe.ofObject(0f); + keyframes[1] = (ObjectKeyframe) Keyframe.ofObject(1f, values[0]); + } else { + keyframes[0] = (ObjectKeyframe) Keyframe.ofObject(0f, values[0]); + for (int i = 1; i < numKeyframes; ++i) { + keyframes[i] = (ObjectKeyframe) Keyframe.ofObject((float) i / (numKeyframes - 1), values[i]); + } + } + return new KeyframeSet(keyframes); + } + + /** + * Sets the TypeEvaluator to be used when calculating animated values. This object + * is required only for KeyframeSets that are not either IntKeyframeSet or FloatKeyframeSet, + * both of which assume their own evaluator to speed up calculations with those primitive + * types. + * + * @param evaluator The TypeEvaluator to be used to calculate animated values. + */ + public void setEvaluator(TypeEvaluator evaluator) { + mEvaluator = evaluator; + } + + @Override + public KeyframeSet clone() { + ArrayList keyframes = mKeyframes; + int numKeyframes = mKeyframes.size(); + Keyframe[] newKeyframes = new Keyframe[numKeyframes]; + for (int i = 0; i < numKeyframes; ++i) { + newKeyframes[i] = keyframes.get(i).clone(); + } + KeyframeSet newSet = new KeyframeSet(newKeyframes); + return newSet; + } + + /** + * Gets the animated value, given the elapsed fraction of the animation (interpolated by the + * animation's interpolator) and the evaluator used to calculate in-between values. This + * function maps the input fraction to the appropriate keyframe interval and a fraction + * between them and returns the interpolated value. Note that the input fraction may fall + * outside the [0-1] bounds, if the animation's interpolator made that happen (e.g., a + * spring interpolation that might send the fraction past 1.0). We handle this situation by + * just using the two keyframes at the appropriate end when the value is outside those bounds. + * + * @param fraction The elapsed fraction of the animation + * @return The animated value. + */ + public Object getValue(float fraction) { + + // Special-case optimization for the common case of only two keyframes + if (mNumKeyframes == 2) { + if (mInterpolator != null) { + fraction = mInterpolator.getInterpolation(fraction); + } + return mEvaluator.evaluate(fraction, mFirstKeyframe.getValue(), + mLastKeyframe.getValue()); + } + if (fraction <= 0f) { + final Keyframe nextKeyframe = mKeyframes.get(1); + final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator(); + if (interpolator != null) { + fraction = interpolator.getInterpolation(fraction); + } + final float prevFraction = mFirstKeyframe.getFraction(); + float intervalFraction = (fraction - prevFraction) / + (nextKeyframe.getFraction() - prevFraction); + return mEvaluator.evaluate(intervalFraction, mFirstKeyframe.getValue(), + nextKeyframe.getValue()); + } else if (fraction >= 1f) { + final Keyframe prevKeyframe = mKeyframes.get(mNumKeyframes - 2); + final /*Time*/Interpolator interpolator = mLastKeyframe.getInterpolator(); + if (interpolator != null) { + fraction = interpolator.getInterpolation(fraction); + } + final float prevFraction = prevKeyframe.getFraction(); + float intervalFraction = (fraction - prevFraction) / + (mLastKeyframe.getFraction() - prevFraction); + return mEvaluator.evaluate(intervalFraction, prevKeyframe.getValue(), + mLastKeyframe.getValue()); + } + Keyframe prevKeyframe = mFirstKeyframe; + for (int i = 1; i < mNumKeyframes; ++i) { + Keyframe nextKeyframe = mKeyframes.get(i); + if (fraction < nextKeyframe.getFraction()) { + final /*Time*/Interpolator interpolator = nextKeyframe.getInterpolator(); + if (interpolator != null) { + fraction = interpolator.getInterpolation(fraction); + } + final float prevFraction = prevKeyframe.getFraction(); + float intervalFraction = (fraction - prevFraction) / + (nextKeyframe.getFraction() - prevFraction); + return mEvaluator.evaluate(intervalFraction, prevKeyframe.getValue(), + nextKeyframe.getValue()); + } + prevKeyframe = nextKeyframe; + } + // shouldn't reach here + return mLastKeyframe.getValue(); + } + + @Override + public String toString() { + String returnVal = " "; + for (int i = 0; i < mNumKeyframes; ++i) { + returnVal += mKeyframes.get(i).getValue() + " "; + } + return returnVal; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ObjectAnimator.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ObjectAnimator.java new file mode 100644 index 000000000..21d15c02a --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ObjectAnimator.java @@ -0,0 +1,491 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; + +import android.util.Log; +//import android.util.Property; + +//import java.lang.reflect.Method; +import java.util.ArrayList; + +/** + * This subclass of {@link ValueAnimator} provides support for animating properties on target objects. + * The constructors of this class take parameters to define the target object that will be animated + * as well as the name of the property that will be animated. Appropriate set/get functions + * are then determined internally and the animation will call these functions as necessary to + * animate the property. + * + * @see #setPropertyName(String) + * + */ +@SuppressWarnings("rawtypes") +public final class ObjectAnimator extends ValueAnimator { + private static final boolean DBG = false; + + // The target object on which the property exists, set in the constructor + private Object mTarget; + + private String mPropertyName; + + //private Property mProperty; + + /** + * Sets the name of the property that will be animated. This name is used to derive + * a setter function that will be called to set animated values. + * For example, a property name of foo will result + * in a call to the function setFoo() on the target object. If either + * valueFrom or valueTo is null, then a getter function will + * also be derived and called. + * + *

For best performance of the mechanism that calls the setter function determined by the + * name of the property being animated, use float or int typed values, + * and make the setter function for those properties have a void return value. This + * will cause the code to take an optimized path for these constrained circumstances. Other + * property types and return types will work, but will have more overhead in processing + * the requests due to normal reflection mechanisms.

+ * + *

Note that the setter function derived from this property name + * must take the same parameter type as the + * valueFrom and valueTo properties, otherwise the call to + * the setter function will fail.

+ * + *

If this ObjectAnimator has been set up to animate several properties together, + * using more than one PropertyValuesHolder objects, then setting the propertyName simply + * sets the propertyName in the first of those PropertyValuesHolder objects.

+ * + * @param propertyName The name of the property being animated. Should not be null. + */ + public void setPropertyName(String propertyName) { + // mValues could be null if this is being constructed piecemeal. Just record the + // propertyName to be used later when setValues() is called if so. + if (mValues != null) { + PropertyValuesHolder valuesHolder = mValues[0]; + String oldName = valuesHolder.getPropertyName(); + valuesHolder.setPropertyName(propertyName); + mValuesMap.remove(oldName); + mValuesMap.put(propertyName, valuesHolder); + } + mPropertyName = propertyName; + // New property/values/target should cause re-initialization prior to starting + mInitialized = false; + } + + /** + * Sets the property that will be animated. Property objects will take precedence over + * properties specified by the {@link #setPropertyName(String)} method. Animations should + * be set up to use one or the other, not both. + * + * @param property The property being animated. Should not be null. + */ + //public void setProperty(Property property) { + // // mValues could be null if this is being constructed piecemeal. Just record the + // // propertyName to be used later when setValues() is called if so. + // if (mValues != null) { + // PropertyValuesHolder valuesHolder = mValues[0]; + // String oldName = valuesHolder.getPropertyName(); + // valuesHolder.setProperty(property); + // mValuesMap.remove(oldName); + // mValuesMap.put(mPropertyName, valuesHolder); + // } + // if (mProperty != null) { + // mPropertyName = property.getName(); + // } + // mProperty = property; + // // New property/values/target should cause re-initialization prior to starting + // mInitialized = false; + //} + + /** + * Gets the name of the property that will be animated. This name will be used to derive + * a setter function that will be called to set animated values. + * For example, a property name of foo will result + * in a call to the function setFoo() on the target object. If either + * valueFrom or valueTo is null, then a getter function will + * also be derived and called. + */ + public String getPropertyName() { + return mPropertyName; + } + + /** + * Creates a new ObjectAnimator object. This default constructor is primarily for + * use internally; the other constructors which take parameters are more generally + * useful. + */ + public ObjectAnimator() { + } + + /** + * Private utility constructor that initializes the target object and name of the + * property being animated. + * + * @param target The object whose property is to be animated. This object should + * have a public method on it called setName(), where name is + * the value of the propertyName parameter. + * @param propertyName The name of the property being animated. + */ + private ObjectAnimator(Object target, String propertyName) { + mTarget = target; + setPropertyName(propertyName); + } + + /** + * Private utility constructor that initializes the target object and property being animated. + * + * @param target The object whose property is to be animated. + * @param property The property being animated. + */ + //private ObjectAnimator(T target, Property property) { + // mTarget = target; + // setProperty(property); + //} + + /** + * Constructs and returns an ObjectAnimator that animates between int values. A single + * value implies that that value is the one being animated to. Two values imply a starting + * and ending values. More than two values imply a starting value, values to animate through + * along the way, and an ending value (these values will be distributed evenly across + * the duration of the animation). + * + * @param target The object whose property is to be animated. This object should + * have a public method on it called setName(), where name is + * the value of the propertyName parameter. + * @param propertyName The name of the property being animated. + * @param values A set of values that the animation will animate between over time. + * @return An ObjectAnimator object that is set up to animate between the given values. + */ + public static ObjectAnimator ofInt(Object target, String propertyName, int... values) { + ObjectAnimator anim = new ObjectAnimator(target, propertyName); + anim.setIntValues(values); + return anim; + } + + /** + * Constructs and returns an ObjectAnimator that animates between int values. A single + * value implies that that value is the one being animated to. Two values imply a starting + * and ending values. More than two values imply a starting value, values to animate through + * along the way, and an ending value (these values will be distributed evenly across + * the duration of the animation). + * + * @param target The object whose property is to be animated. + * @param property The property being animated. + * @param values A set of values that the animation will animate between over time. + * @return An ObjectAnimator object that is set up to animate between the given values. + */ + //public static ObjectAnimator ofInt(T target, Property property, int... values) { + // ObjectAnimator anim = new ObjectAnimator(target, property); + // anim.setIntValues(values); + // return anim; + //} + + /** + * Constructs and returns an ObjectAnimator that animates between float values. A single + * value implies that that value is the one being animated to. Two values imply a starting + * and ending values. More than two values imply a starting value, values to animate through + * along the way, and an ending value (these values will be distributed evenly across + * the duration of the animation). + * + * @param target The object whose property is to be animated. This object should + * have a public method on it called setName(), where name is + * the value of the propertyName parameter. + * @param propertyName The name of the property being animated. + * @param values A set of values that the animation will animate between over time. + * @return An ObjectAnimator object that is set up to animate between the given values. + */ + public static ObjectAnimator ofFloat(Object target, String propertyName, float... values) { + ObjectAnimator anim = new ObjectAnimator(target, propertyName); + anim.setFloatValues(values); + return anim; + } + + /** + * Constructs and returns an ObjectAnimator that animates between float values. A single + * value implies that that value is the one being animated to. Two values imply a starting + * and ending values. More than two values imply a starting value, values to animate through + * along the way, and an ending value (these values will be distributed evenly across + * the duration of the animation). + * + * @param target The object whose property is to be animated. + * @param property The property being animated. + * @param values A set of values that the animation will animate between over time. + * @return An ObjectAnimator object that is set up to animate between the given values. + */ + //public static ObjectAnimator ofFloat(T target, Property property, + // float... values) { + // ObjectAnimator anim = new ObjectAnimator(target, property); + // anim.setFloatValues(values); + // return anim; + //} + + /** + * Constructs and returns an ObjectAnimator that animates between Object values. A single + * value implies that that value is the one being animated to. Two values imply a starting + * and ending values. More than two values imply a starting value, values to animate through + * along the way, and an ending value (these values will be distributed evenly across + * the duration of the animation). + * + * @param target The object whose property is to be animated. This object should + * have a public method on it called setName(), where name is + * the value of the propertyName parameter. + * @param propertyName The name of the property being animated. + * @param evaluator A TypeEvaluator that will be called on each animation frame to + * provide the necessary interpolation between the Object values to derive the animated + * value. + * @param values A set of values that the animation will animate between over time. + * @return An ObjectAnimator object that is set up to animate between the given values. + */ + public static ObjectAnimator ofObject(Object target, String propertyName, + TypeEvaluator evaluator, Object... values) { + ObjectAnimator anim = new ObjectAnimator(target, propertyName); + anim.setObjectValues(values); + anim.setEvaluator(evaluator); + return anim; + } + + /** + * Constructs and returns an ObjectAnimator that animates between Object values. A single + * value implies that that value is the one being animated to. Two values imply a starting + * and ending values. More than two values imply a starting value, values to animate through + * along the way, and an ending value (these values will be distributed evenly across + * the duration of the animation). + * + * @param target The object whose property is to be animated. + * @param property The property being animated. + * @param evaluator A TypeEvaluator that will be called on each animation frame to + * provide the necessary interpolation between the Object values to derive the animated + * value. + * @param values A set of values that the animation will animate between over time. + * @return An ObjectAnimator object that is set up to animate between the given values. + */ + //public static ObjectAnimator ofObject(T target, Property property, + // TypeEvaluator evaluator, V... values) { + // ObjectAnimator anim = new ObjectAnimator(target, property); + // anim.setObjectValues(values); + // anim.setEvaluator(evaluator); + // return anim; + //} + + /** + * Constructs and returns an ObjectAnimator that animates between the sets of values specified + * in PropertyValueHolder objects. This variant should be used when animating + * several properties at once with the same ObjectAnimator, since PropertyValuesHolder allows + * you to associate a set of animation values with a property name. + * + * @param target The object whose property is to be animated. Depending on how the + * PropertyValuesObjects were constructed, the target object should either have the {@link + * android.util.Property} objects used to construct the PropertyValuesHolder objects or (if the + * PropertyValuesHOlder objects were created with property names) the target object should have + * public methods on it called setName(), where name is the name of + * the property passed in as the propertyName parameter for each of the + * PropertyValuesHolder objects. + * @param values A set of PropertyValuesHolder objects whose values will be animated between + * over time. + * @return An ObjectAnimator object that is set up to animate between the given values. + */ + public static ObjectAnimator ofPropertyValuesHolder(Object target, + PropertyValuesHolder... values) { + ObjectAnimator anim = new ObjectAnimator(); + anim.mTarget = target; + anim.setValues(values); + return anim; + } + + @Override + public void setIntValues(int... values) { + if (mValues == null || mValues.length == 0) { + // No values yet - this animator is being constructed piecemeal. Init the values with + // whatever the current propertyName is + //if (mProperty != null) { + // setValues(PropertyValuesHolder.ofInt(mProperty, values)); + //} else { + setValues(PropertyValuesHolder.ofInt(mPropertyName, values)); + //} + } else { + super.setIntValues(values); + } + } + + @Override + public void setFloatValues(float... values) { + if (mValues == null || mValues.length == 0) { + // No values yet - this animator is being constructed piecemeal. Init the values with + // whatever the current propertyName is + //if (mProperty != null) { + // setValues(PropertyValuesHolder.ofFloat(mProperty, values)); + //} else { + setValues(PropertyValuesHolder.ofFloat(mPropertyName, values)); + //} + } else { + super.setFloatValues(values); + } + } + + @Override + public void setObjectValues(Object... values) { + if (mValues == null || mValues.length == 0) { + // No values yet - this animator is being constructed piecemeal. Init the values with + // whatever the current propertyName is + //if (mProperty != null) { + // setValues(PropertyValuesHolder.ofObject(mProperty, (TypeEvaluator)null, values)); + //} else { + setValues(PropertyValuesHolder.ofObject(mPropertyName, (TypeEvaluator)null, values)); + //} + } else { + super.setObjectValues(values); + } + } + + @Override + public void start() { + if (DBG) { + Log.d("ObjectAnimator", "Anim target, duration: " + mTarget + ", " + getDuration()); + for (int i = 0; i < mValues.length; ++i) { + PropertyValuesHolder pvh = mValues[i]; + ArrayList keyframes = pvh.mKeyframeSet.mKeyframes; + Log.d("ObjectAnimator", " Values[" + i + "]: " + + pvh.getPropertyName() + ", " + keyframes.get(0).getValue() + ", " + + keyframes.get(pvh.mKeyframeSet.mNumKeyframes - 1).getValue()); + } + } + super.start(); + } + + /** + * This function is called immediately before processing the first animation + * frame of an animation. If there is a nonzero startDelay, the + * function is called after that delay ends. + * It takes care of the final initialization steps for the + * animation. This includes setting mEvaluator, if the user has not yet + * set it up, and the setter/getter methods, if the user did not supply + * them. + * + *

Overriders of this method should call the superclass method to cause + * internal mechanisms to be set up correctly.

+ */ + @Override + void initAnimation() { + if (!mInitialized) { + // mValueType may change due to setter/getter setup; do this before calling super.init(), + // which uses mValueType to set up the default type evaluator. + int numValues = mValues.length; + for (int i = 0; i < numValues; ++i) { + mValues[i].setupSetterAndGetter(mTarget); + } + super.initAnimation(); + } + } + + /** + * Sets the length of the animation. The default duration is 300 milliseconds. + * + * @param duration The length of the animation, in milliseconds. + * @return ObjectAnimator The object called with setDuration(). This return + * value makes it easier to compose statements together that construct and then set the + * duration, as in + * ObjectAnimator.ofInt(target, propertyName, 0, 10).setDuration(500).start(). + */ + @Override + public ObjectAnimator setDuration(long duration) { + super.setDuration(duration); + return this; + } + + + /** + * The target object whose property will be animated by this animation + * + * @return The object being animated + */ + public Object getTarget() { + return mTarget; + } + + /** + * Sets the target object whose property will be animated by this animation + * + * @param target The object being animated + */ + @Override + public void setTarget(Object target) { + if (mTarget != target) { + final Object oldTarget = mTarget; + mTarget = target; + if (oldTarget != null && target != null && oldTarget.getClass() == target.getClass()) { + return; + } + // New target type should cause re-initialization prior to starting + mInitialized = false; + } + } + + @Override + public void setupStartValues() { + initAnimation(); + int numValues = mValues.length; + for (int i = 0; i < numValues; ++i) { + mValues[i].setupStartValue(mTarget); + } + } + + @Override + public void setupEndValues() { + initAnimation(); + int numValues = mValues.length; + for (int i = 0; i < numValues; ++i) { + mValues[i].setupEndValue(mTarget); + } + } + + /** + * This method is called with the elapsed fraction of the animation during every + * animation frame. This function turns the elapsed fraction into an interpolated fraction + * and then into an animated value (from the evaluator. The function is called mostly during + * animation updates, but it is also called when the end() + * function is called, to set the final value on the property. + * + *

Overrides of this method must call the superclass to perform the calculation + * of the animated value.

+ * + * @param fraction The elapsed fraction of the animation. + */ + @Override + void animateValue(float fraction) { + super.animateValue(fraction); + int numValues = mValues.length; + for (int i = 0; i < numValues; ++i) { + mValues[i].setAnimatedValue(mTarget); + } + } + + @Override + public ObjectAnimator clone() { + final ObjectAnimator anim = (ObjectAnimator) super.clone(); + return anim; + } + + @Override + public String toString() { + String returnVal = "ObjectAnimator@" + Integer.toHexString(hashCode()) + ", target " + + mTarget; + if (mValues != null) { + for (int i = 0; i < mValues.length; ++i) { + returnVal += "\n " + mValues[i].toString(); + } + } + return returnVal; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/PropertyValuesHolder.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/PropertyValuesHolder.java new file mode 100644 index 000000000..84f7504ab --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/PropertyValuesHolder.java @@ -0,0 +1,1012 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; + +//import android.util.FloatProperty; +//import android.util.IntProperty; +import android.util.Log; +//import android.util.Property; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.concurrent.locks.ReentrantReadWriteLock; + +/** + * This class holds information about a property and the values that that property + * should take on during an animation. PropertyValuesHolder objects can be used to create + * animations with ValueAnimator or ObjectAnimator that operate on several different properties + * in parallel. + */ +@SuppressWarnings({"rawtypes", "unchecked"}) +public class PropertyValuesHolder implements Cloneable { + + /** + * The name of the property associated with the values. This need not be a real property, + * unless this object is being used with ObjectAnimator. But this is the name by which + * aniamted values are looked up with getAnimatedValue(String) in ValueAnimator. + */ + String mPropertyName; + + /** + * @hide + */ + //protected Property mProperty; + + /** + * The setter function, if needed. ObjectAnimator hands off this functionality to + * PropertyValuesHolder, since it holds all of the per-property information. This + * property is automatically + * derived when the animation starts in setupSetterAndGetter() if using ObjectAnimator. + */ + Method mSetter = null; + + /** + * The getter function, if needed. ObjectAnimator hands off this functionality to + * PropertyValuesHolder, since it holds all of the per-property information. This + * property is automatically + * derived when the animation starts in setupSetterAndGetter() if using ObjectAnimator. + * The getter is only derived and used if one of the values is null. + */ + private Method mGetter = null; + + /** + * The type of values supplied. This information is used both in deriving the setter/getter + * functions and in deriving the type of TypeEvaluator. + */ + Class mValueType; + + /** + * The set of keyframes (time/value pairs) that define this animation. + */ + KeyframeSet mKeyframeSet = null; + + + // type evaluators for the primitive types handled by this implementation + private static final TypeEvaluator sIntEvaluator = new IntEvaluator(); + private static final TypeEvaluator sFloatEvaluator = new FloatEvaluator(); + + // We try several different types when searching for appropriate setter/getter functions. + // The caller may have supplied values in a type that does not match the setter/getter + // functions (such as the integers 0 and 1 to represent floating point values for alpha). + // Also, the use of generics in constructors means that we end up with the Object versions + // of primitive types (Float vs. float). But most likely, the setter/getter functions + // will take primitive types instead. + // So we supply an ordered array of other types to try before giving up. + private static Class[] FLOAT_VARIANTS = {float.class, Float.class, double.class, int.class, + Double.class, Integer.class}; + private static Class[] INTEGER_VARIANTS = {int.class, Integer.class, float.class, double.class, + Float.class, Double.class}; + private static Class[] DOUBLE_VARIANTS = {double.class, Double.class, float.class, int.class, + Float.class, Integer.class}; + + // These maps hold all property entries for a particular class. This map + // is used to speed up property/setter/getter lookups for a given class/property + // combination. No need to use reflection on the combination more than once. + private static final HashMap> sSetterPropertyMap = + new HashMap>(); + private static final HashMap> sGetterPropertyMap = + new HashMap>(); + + // This lock is used to ensure that only one thread is accessing the property maps + // at a time. + final ReentrantReadWriteLock mPropertyMapLock = new ReentrantReadWriteLock(); + + // Used to pass single value to varargs parameter in setter invocation + final Object[] mTmpValueArray = new Object[1]; + + /** + * The type evaluator used to calculate the animated values. This evaluator is determined + * automatically based on the type of the start/end objects passed into the constructor, + * but the system only knows about the primitive types int and float. Any other + * type will need to set the evaluator to a custom evaluator for that type. + */ + private TypeEvaluator mEvaluator; + + /** + * The value most recently calculated by calculateValue(). This is set during + * that function and might be retrieved later either by ValueAnimator.animatedValue() or + * by the property-setting logic in ObjectAnimator.animatedValue(). + */ + private Object mAnimatedValue; + + /** + * Internal utility constructor, used by the factory methods to set the property name. + * @param propertyName The name of the property for this holder. + */ + private PropertyValuesHolder(String propertyName) { + mPropertyName = propertyName; + } + + /** + * Internal utility constructor, used by the factory methods to set the property. + * @param property The property for this holder. + */ + //private PropertyValuesHolder(Property property) { + // mProperty = property; + // if (property != null) { + // mPropertyName = property.getName(); + // } + //} + + /** + * Constructs and returns a PropertyValuesHolder with a given property name and + * set of int values. + * @param propertyName The name of the property being animated. + * @param values The values that the named property will animate between. + * @return PropertyValuesHolder The constructed PropertyValuesHolder object. + */ + public static PropertyValuesHolder ofInt(String propertyName, int... values) { + return new IntPropertyValuesHolder(propertyName, values); + } + + /** + * Constructs and returns a PropertyValuesHolder with a given property and + * set of int values. + * @param property The property being animated. Should not be null. + * @param values The values that the property will animate between. + * @return PropertyValuesHolder The constructed PropertyValuesHolder object. + */ + //public static PropertyValuesHolder ofInt(Property property, int... values) { + // return new IntPropertyValuesHolder(property, values); + //} + + /** + * Constructs and returns a PropertyValuesHolder with a given property name and + * set of float values. + * @param propertyName The name of the property being animated. + * @param values The values that the named property will animate between. + * @return PropertyValuesHolder The constructed PropertyValuesHolder object. + */ + public static PropertyValuesHolder ofFloat(String propertyName, float... values) { + return new FloatPropertyValuesHolder(propertyName, values); + } + + /** + * Constructs and returns a PropertyValuesHolder with a given property and + * set of float values. + * @param property The property being animated. Should not be null. + * @param values The values that the property will animate between. + * @return PropertyValuesHolder The constructed PropertyValuesHolder object. + */ + //public static PropertyValuesHolder ofFloat(Property property, float... values) { + // return new FloatPropertyValuesHolder(property, values); + //} + + /** + * Constructs and returns a PropertyValuesHolder with a given property name and + * set of Object values. This variant also takes a TypeEvaluator because the system + * cannot automatically interpolate between objects of unknown type. + * + * @param propertyName The name of the property being animated. + * @param evaluator A TypeEvaluator that will be called on each animation frame to + * provide the necessary interpolation between the Object values to derive the animated + * value. + * @param values The values that the named property will animate between. + * @return PropertyValuesHolder The constructed PropertyValuesHolder object. + */ + public static PropertyValuesHolder ofObject(String propertyName, TypeEvaluator evaluator, + Object... values) { + PropertyValuesHolder pvh = new PropertyValuesHolder(propertyName); + pvh.setObjectValues(values); + pvh.setEvaluator(evaluator); + return pvh; + } + + /** + * Constructs and returns a PropertyValuesHolder with a given property and + * set of Object values. This variant also takes a TypeEvaluator because the system + * cannot automatically interpolate between objects of unknown type. + * + * @param property The property being animated. Should not be null. + * @param evaluator A TypeEvaluator that will be called on each animation frame to + * provide the necessary interpolation between the Object values to derive the animated + * value. + * @param values The values that the property will animate between. + * @return PropertyValuesHolder The constructed PropertyValuesHolder object. + */ + //public static PropertyValuesHolder ofObject(Property property, + // TypeEvaluator evaluator, V... values) { + // PropertyValuesHolder pvh = new PropertyValuesHolder(property); + // pvh.setObjectValues(values); + // pvh.setEvaluator(evaluator); + // return pvh; + //} + + /** + * Constructs and returns a PropertyValuesHolder object with the specified property name and set + * of values. These values can be of any type, but the type should be consistent so that + * an appropriate {@link android.animation.TypeEvaluator} can be found that matches + * the common type. + *

If there is only one value, it is assumed to be the end value of an animation, + * and an initial value will be derived, if possible, by calling a getter function + * on the object. Also, if any value is null, the value will be filled in when the animation + * starts in the same way. This mechanism of automatically getting null values only works + * if the PropertyValuesHolder object is used in conjunction + * {@link ObjectAnimator}, and with a getter function + * derived automatically from propertyName, since otherwise PropertyValuesHolder has + * no way of determining what the value should be. + * @param propertyName The name of the property associated with this set of values. This + * can be the actual property name to be used when using a ObjectAnimator object, or + * just a name used to get animated values, such as if this object is used with an + * ValueAnimator object. + * @param values The set of values to animate between. + */ + public static PropertyValuesHolder ofKeyframe(String propertyName, Keyframe... values) { + KeyframeSet keyframeSet = KeyframeSet.ofKeyframe(values); + if (keyframeSet instanceof IntKeyframeSet) { + return new IntPropertyValuesHolder(propertyName, (IntKeyframeSet) keyframeSet); + } else if (keyframeSet instanceof FloatKeyframeSet) { + return new FloatPropertyValuesHolder(propertyName, (FloatKeyframeSet) keyframeSet); + } + else { + PropertyValuesHolder pvh = new PropertyValuesHolder(propertyName); + pvh.mKeyframeSet = keyframeSet; + pvh.mValueType = values[0].getType(); + return pvh; + } + } + + /** + * Constructs and returns a PropertyValuesHolder object with the specified property and set + * of values. These values can be of any type, but the type should be consistent so that + * an appropriate {@link android.animation.TypeEvaluator} can be found that matches + * the common type. + *

If there is only one value, it is assumed to be the end value of an animation, + * and an initial value will be derived, if possible, by calling the property's + * {@link android.util.Property#get(Object)} function. + * Also, if any value is null, the value will be filled in when the animation + * starts in the same way. This mechanism of automatically getting null values only works + * if the PropertyValuesHolder object is used in conjunction with + * {@link ObjectAnimator}, since otherwise PropertyValuesHolder has + * no way of determining what the value should be. + * @param property The property associated with this set of values. Should not be null. + * @param values The set of values to animate between. + */ + //public static PropertyValuesHolder ofKeyframe(Property property, Keyframe... values) { + // KeyframeSet keyframeSet = KeyframeSet.ofKeyframe(values); + // if (keyframeSet instanceof IntKeyframeSet) { + // return new IntPropertyValuesHolder(property, (IntKeyframeSet) keyframeSet); + // } else if (keyframeSet instanceof FloatKeyframeSet) { + // return new FloatPropertyValuesHolder(property, (FloatKeyframeSet) keyframeSet); + // } + // else { + // PropertyValuesHolder pvh = new PropertyValuesHolder(property); + // pvh.mKeyframeSet = keyframeSet; + // pvh.mValueType = ((Keyframe)values[0]).getType(); + // return pvh; + // } + //} + + /** + * Set the animated values for this object to this set of ints. + * If there is only one value, it is assumed to be the end value of an animation, + * and an initial value will be derived, if possible, by calling a getter function + * on the object. Also, if any value is null, the value will be filled in when the animation + * starts in the same way. This mechanism of automatically getting null values only works + * if the PropertyValuesHolder object is used in conjunction + * {@link ObjectAnimator}, and with a getter function + * derived automatically from propertyName, since otherwise PropertyValuesHolder has + * no way of determining what the value should be. + * + * @param values One or more values that the animation will animate between. + */ + public void setIntValues(int... values) { + mValueType = int.class; + mKeyframeSet = KeyframeSet.ofInt(values); + } + + /** + * Set the animated values for this object to this set of floats. + * If there is only one value, it is assumed to be the end value of an animation, + * and an initial value will be derived, if possible, by calling a getter function + * on the object. Also, if any value is null, the value will be filled in when the animation + * starts in the same way. This mechanism of automatically getting null values only works + * if the PropertyValuesHolder object is used in conjunction + * {@link ObjectAnimator}, and with a getter function + * derived automatically from propertyName, since otherwise PropertyValuesHolder has + * no way of determining what the value should be. + * + * @param values One or more values that the animation will animate between. + */ + public void setFloatValues(float... values) { + mValueType = float.class; + mKeyframeSet = KeyframeSet.ofFloat(values); + } + + /** + * Set the animated values for this object to this set of Keyframes. + * + * @param values One or more values that the animation will animate between. + */ + public void setKeyframes(Keyframe... values) { + int numKeyframes = values.length; + Keyframe keyframes[] = new Keyframe[Math.max(numKeyframes,2)]; + mValueType = values[0].getType(); + for (int i = 0; i < numKeyframes; ++i) { + keyframes[i] = values[i]; + } + mKeyframeSet = new KeyframeSet(keyframes); + } + + /** + * Set the animated values for this object to this set of Objects. + * If there is only one value, it is assumed to be the end value of an animation, + * and an initial value will be derived, if possible, by calling a getter function + * on the object. Also, if any value is null, the value will be filled in when the animation + * starts in the same way. This mechanism of automatically getting null values only works + * if the PropertyValuesHolder object is used in conjunction + * {@link ObjectAnimator}, and with a getter function + * derived automatically from propertyName, since otherwise PropertyValuesHolder has + * no way of determining what the value should be. + * + * @param values One or more values that the animation will animate between. + */ + public void setObjectValues(Object... values) { + mValueType = values[0].getClass(); + mKeyframeSet = KeyframeSet.ofObject(values); + } + + /** + * Determine the setter or getter function using the JavaBeans convention of setFoo or + * getFoo for a property named 'foo'. This function figures out what the name of the + * function should be and uses reflection to find the Method with that name on the + * target object. + * + * @param targetClass The class to search for the method + * @param prefix "set" or "get", depending on whether we need a setter or getter. + * @param valueType The type of the parameter (in the case of a setter). This type + * is derived from the values set on this PropertyValuesHolder. This type is used as + * a first guess at the parameter type, but we check for methods with several different + * types to avoid problems with slight mis-matches between supplied values and actual + * value types used on the setter. + * @return Method the method associated with mPropertyName. + */ + private Method getPropertyFunction(Class targetClass, String prefix, Class valueType) { + // TODO: faster implementation... + Method returnVal = null; + String methodName = getMethodName(prefix, mPropertyName); + Class args[] = null; + if (valueType == null) { + try { + returnVal = targetClass.getMethod(methodName, args); + } catch (NoSuchMethodException e) { + Log.e("PropertyValuesHolder", targetClass.getSimpleName() + " - " + + "Couldn't find no-arg method for property " + mPropertyName + ": " + e); + } + } else { + args = new Class[1]; + Class typeVariants[]; + if (mValueType.equals(Float.class)) { + typeVariants = FLOAT_VARIANTS; + } else if (mValueType.equals(Integer.class)) { + typeVariants = INTEGER_VARIANTS; + } else if (mValueType.equals(Double.class)) { + typeVariants = DOUBLE_VARIANTS; + } else { + typeVariants = new Class[1]; + typeVariants[0] = mValueType; + } + for (Class typeVariant : typeVariants) { + args[0] = typeVariant; + try { + returnVal = targetClass.getMethod(methodName, args); + // change the value type to suit + mValueType = typeVariant; + return returnVal; + } catch (NoSuchMethodException e) { + // Swallow the error and keep trying other variants + } + } + // If we got here, then no appropriate function was found + Log.e("PropertyValuesHolder", + "Couldn't find " + prefix + "ter property " + mPropertyName + + " for " + targetClass.getSimpleName() + + " with value type "+ mValueType); + } + + return returnVal; + } + + + /** + * Returns the setter or getter requested. This utility function checks whether the + * requested method exists in the propertyMapMap cache. If not, it calls another + * utility function to request the Method from the targetClass directly. + * @param targetClass The Class on which the requested method should exist. + * @param propertyMapMap The cache of setters/getters derived so far. + * @param prefix "set" or "get", for the setter or getter. + * @param valueType The type of parameter passed into the method (null for getter). + * @return Method the method associated with mPropertyName. + */ + private Method setupSetterOrGetter(Class targetClass, + HashMap> propertyMapMap, + String prefix, Class valueType) { + Method setterOrGetter = null; + try { + // Have to lock property map prior to reading it, to guard against + // another thread putting something in there after we've checked it + // but before we've added an entry to it + mPropertyMapLock.writeLock().lock(); + HashMap propertyMap = propertyMapMap.get(targetClass); + if (propertyMap != null) { + setterOrGetter = propertyMap.get(mPropertyName); + } + if (setterOrGetter == null) { + setterOrGetter = getPropertyFunction(targetClass, prefix, valueType); + if (propertyMap == null) { + propertyMap = new HashMap(); + propertyMapMap.put(targetClass, propertyMap); + } + propertyMap.put(mPropertyName, setterOrGetter); + } + } finally { + mPropertyMapLock.writeLock().unlock(); + } + return setterOrGetter; + } + + /** + * Utility function to get the setter from targetClass + * @param targetClass The Class on which the requested method should exist. + */ + void setupSetter(Class targetClass) { + mSetter = setupSetterOrGetter(targetClass, sSetterPropertyMap, "set", mValueType); + } + + /** + * Utility function to get the getter from targetClass + */ + private void setupGetter(Class targetClass) { + mGetter = setupSetterOrGetter(targetClass, sGetterPropertyMap, "get", null); + } + + /** + * Internal function (called from ObjectAnimator) to set up the setter and getter + * prior to running the animation. If the setter has not been manually set for this + * object, it will be derived automatically given the property name, target object, and + * types of values supplied. If no getter has been set, it will be supplied iff any of the + * supplied values was null. If there is a null value, then the getter (supplied or derived) + * will be called to set those null values to the current value of the property + * on the target object. + * @param target The object on which the setter (and possibly getter) exist. + */ + void setupSetterAndGetter(Object target) { + //if (mProperty != null) { + // // check to make sure that mProperty is on the class of target + // try { + // Object testValue = mProperty.get(target); + // for (Keyframe kf : mKeyframeSet.mKeyframes) { + // if (!kf.hasValue()) { + // kf.setValue(mProperty.get(target)); + // } + // } + // return; + // } catch (ClassCastException e) { + // Log.e("PropertyValuesHolder","No such property (" + mProperty.getName() + + // ") on target object " + target + ". Trying reflection instead"); + // mProperty = null; + // } + //} + Class targetClass = target.getClass(); + if (mSetter == null) { + setupSetter(targetClass); + } + for (Keyframe kf : mKeyframeSet.mKeyframes) { + if (!kf.hasValue()) { + if (mGetter == null) { + setupGetter(targetClass); + } + try { + kf.setValue(mGetter.invoke(target)); + } catch (InvocationTargetException e) { + Log.e("PropertyValuesHolder", e.toString()); + } catch (IllegalAccessException e) { + Log.e("PropertyValuesHolder", e.toString()); + } + } + } + } + + /** + * Utility function to set the value stored in a particular Keyframe. The value used is + * whatever the value is for the property name specified in the keyframe on the target object. + * + * @param target The target object from which the current value should be extracted. + * @param kf The keyframe which holds the property name and value. + */ + private void setupValue(Object target, Keyframe kf) { + //if (mProperty != null) { + // kf.setValue(mProperty.get(target)); + //} + try { + if (mGetter == null) { + Class targetClass = target.getClass(); + setupGetter(targetClass); + } + kf.setValue(mGetter.invoke(target)); + } catch (InvocationTargetException e) { + Log.e("PropertyValuesHolder", e.toString()); + } catch (IllegalAccessException e) { + Log.e("PropertyValuesHolder", e.toString()); + } + } + + /** + * This function is called by ObjectAnimator when setting the start values for an animation. + * The start values are set according to the current values in the target object. The + * property whose value is extracted is whatever is specified by the propertyName of this + * PropertyValuesHolder object. + * + * @param target The object which holds the start values that should be set. + */ + void setupStartValue(Object target) { + setupValue(target, mKeyframeSet.mKeyframes.get(0)); + } + + /** + * This function is called by ObjectAnimator when setting the end values for an animation. + * The end values are set according to the current values in the target object. The + * property whose value is extracted is whatever is specified by the propertyName of this + * PropertyValuesHolder object. + * + * @param target The object which holds the start values that should be set. + */ + void setupEndValue(Object target) { + setupValue(target, mKeyframeSet.mKeyframes.get(mKeyframeSet.mKeyframes.size() - 1)); + } + + @Override + public PropertyValuesHolder clone() { + try { + PropertyValuesHolder newPVH = (PropertyValuesHolder) super.clone(); + newPVH.mPropertyName = mPropertyName; + //newPVH.mProperty = mProperty; + newPVH.mKeyframeSet = mKeyframeSet.clone(); + newPVH.mEvaluator = mEvaluator; + return newPVH; + } catch (CloneNotSupportedException e) { + // won't reach here + return null; + } + } + + /** + * Internal function to set the value on the target object, using the setter set up + * earlier on this PropertyValuesHolder object. This function is called by ObjectAnimator + * to handle turning the value calculated by ValueAnimator into a value set on the object + * according to the name of the property. + * @param target The target object on which the value is set + */ + void setAnimatedValue(Object target) { + //if (mProperty != null) { + // mProperty.set(target, getAnimatedValue()); + //} + if (mSetter != null) { + try { + mTmpValueArray[0] = getAnimatedValue(); + mSetter.invoke(target, mTmpValueArray); + } catch (InvocationTargetException e) { + Log.e("PropertyValuesHolder", e.toString()); + } catch (IllegalAccessException e) { + Log.e("PropertyValuesHolder", e.toString()); + } + } + } + + /** + * Internal function, called by ValueAnimator, to set up the TypeEvaluator that will be used + * to calculate animated values. + */ + void init() { + if (mEvaluator == null) { + // We already handle int and float automatically, but not their Object + // equivalents + mEvaluator = (mValueType == Integer.class) ? sIntEvaluator : + (mValueType == Float.class) ? sFloatEvaluator : + null; + } + if (mEvaluator != null) { + // KeyframeSet knows how to evaluate the common types - only give it a custom + // evaluator if one has been set on this class + mKeyframeSet.setEvaluator(mEvaluator); + } + } + + /** + * The TypeEvaluator will the automatically determined based on the type of values + * supplied to PropertyValuesHolder. The evaluator can be manually set, however, if so + * desired. This may be important in cases where either the type of the values supplied + * do not match the way that they should be interpolated between, or if the values + * are of a custom type or one not currently understood by the animation system. Currently, + * only values of type float and int (and their Object equivalents: Float + * and Integer) are correctly interpolated; all other types require setting a TypeEvaluator. + * @param evaluator + */ + public void setEvaluator(TypeEvaluator evaluator) { + mEvaluator = evaluator; + mKeyframeSet.setEvaluator(evaluator); + } + + /** + * Function used to calculate the value according to the evaluator set up for + * this PropertyValuesHolder object. This function is called by ValueAnimator.animateValue(). + * + * @param fraction The elapsed, interpolated fraction of the animation. + */ + void calculateValue(float fraction) { + mAnimatedValue = mKeyframeSet.getValue(fraction); + } + + /** + * Sets the name of the property that will be animated. This name is used to derive + * a setter function that will be called to set animated values. + * For example, a property name of foo will result + * in a call to the function setFoo() on the target object. If either + * valueFrom or valueTo is null, then a getter function will + * also be derived and called. + * + *

Note that the setter function derived from this property name + * must take the same parameter type as the + * valueFrom and valueTo properties, otherwise the call to + * the setter function will fail.

+ * + * @param propertyName The name of the property being animated. + */ + public void setPropertyName(String propertyName) { + mPropertyName = propertyName; + } + + /** + * Sets the property that will be animated. + * + *

Note that if this PropertyValuesHolder object is used with ObjectAnimator, the property + * must exist on the target object specified in that ObjectAnimator.

+ * + * @param property The property being animated. + */ + //public void setProperty(Property property) { + // mProperty = property; + //} + + /** + * Gets the name of the property that will be animated. This name will be used to derive + * a setter function that will be called to set animated values. + * For example, a property name of foo will result + * in a call to the function setFoo() on the target object. If either + * valueFrom or valueTo is null, then a getter function will + * also be derived and called. + */ + public String getPropertyName() { + return mPropertyName; + } + + /** + * Internal function, called by ValueAnimator and ObjectAnimator, to retrieve the value + * most recently calculated in calculateValue(). + * @return + */ + Object getAnimatedValue() { + return mAnimatedValue; + } + + @Override + public String toString() { + return mPropertyName + ": " + mKeyframeSet.toString(); + } + + /** + * Utility method to derive a setter/getter method name from a property name, where the + * prefix is typically "set" or "get" and the first letter of the property name is + * capitalized. + * + * @param prefix The precursor to the method name, before the property name begins, typically + * "set" or "get". + * @param propertyName The name of the property that represents the bulk of the method name + * after the prefix. The first letter of this word will be capitalized in the resulting + * method name. + * @return String the property name converted to a method name according to the conventions + * specified above. + */ + static String getMethodName(String prefix, String propertyName) { + if (propertyName == null || propertyName.length() == 0) { + // shouldn't get here + return prefix; + } + char firstLetter = Character.toUpperCase(propertyName.charAt(0)); + String theRest = propertyName.substring(1); + return prefix + firstLetter + theRest; + } + + static class IntPropertyValuesHolder extends PropertyValuesHolder { + + // Cache JNI functions to avoid looking them up twice + //private static final HashMap> sJNISetterPropertyMap = + // new HashMap>(); + //int mJniSetter; + //private IntProperty mIntProperty; + + IntKeyframeSet mIntKeyframeSet; + int mIntAnimatedValue; + + public IntPropertyValuesHolder(String propertyName, IntKeyframeSet keyframeSet) { + super(propertyName); + mValueType = int.class; + mKeyframeSet = keyframeSet; + mIntKeyframeSet = (IntKeyframeSet) mKeyframeSet; + } + + //public IntPropertyValuesHolder(Property property, IntKeyframeSet keyframeSet) { + // super(property); + // mValueType = int.class; + // mKeyframeSet = keyframeSet; + // mIntKeyframeSet = (IntKeyframeSet) mKeyframeSet; + // if (property instanceof IntProperty) { + // mIntProperty = (IntProperty) mProperty; + // } + //} + + public IntPropertyValuesHolder(String propertyName, int... values) { + super(propertyName); + setIntValues(values); + } + + //public IntPropertyValuesHolder(Property property, int... values) { + // super(property); + // setIntValues(values); + // if (property instanceof IntProperty) { + // mIntProperty = (IntProperty) mProperty; + // } + //} + + @Override + public void setIntValues(int... values) { + super.setIntValues(values); + mIntKeyframeSet = (IntKeyframeSet) mKeyframeSet; + } + + @Override + void calculateValue(float fraction) { + mIntAnimatedValue = mIntKeyframeSet.getIntValue(fraction); + } + + @Override + Object getAnimatedValue() { + return mIntAnimatedValue; + } + + @Override + public IntPropertyValuesHolder clone() { + IntPropertyValuesHolder newPVH = (IntPropertyValuesHolder) super.clone(); + newPVH.mIntKeyframeSet = (IntKeyframeSet) newPVH.mKeyframeSet; + return newPVH; + } + + /** + * Internal function to set the value on the target object, using the setter set up + * earlier on this PropertyValuesHolder object. This function is called by ObjectAnimator + * to handle turning the value calculated by ValueAnimator into a value set on the object + * according to the name of the property. + * @param target The target object on which the value is set + */ + @Override + void setAnimatedValue(Object target) { + //if (mIntProperty != null) { + // mIntProperty.setValue(target, mIntAnimatedValue); + // return; + //} + //if (mProperty != null) { + // mProperty.set(target, mIntAnimatedValue); + // return; + //} + //if (mJniSetter != 0) { + // nCallIntMethod(target, mJniSetter, mIntAnimatedValue); + // return; + //} + if (mSetter != null) { + try { + mTmpValueArray[0] = mIntAnimatedValue; + mSetter.invoke(target, mTmpValueArray); + } catch (InvocationTargetException e) { + Log.e("PropertyValuesHolder", e.toString()); + } catch (IllegalAccessException e) { + Log.e("PropertyValuesHolder", e.toString()); + } + } + } + + @Override + void setupSetter(Class targetClass) { + //if (mProperty != null) { + // return; + //} + // Check new static hashmap for setter method + //try { + // mPropertyMapLock.writeLock().lock(); + // HashMap propertyMap = sJNISetterPropertyMap.get(targetClass); + // if (propertyMap != null) { + // Integer mJniSetterInteger = propertyMap.get(mPropertyName); + // if (mJniSetterInteger != null) { + // mJniSetter = mJniSetterInteger; + // } + // } + // if (mJniSetter == 0) { + // String methodName = getMethodName("set", mPropertyName); + // mJniSetter = nGetIntMethod(targetClass, methodName); + // if (mJniSetter != 0) { + // if (propertyMap == null) { + // propertyMap = new HashMap(); + // sJNISetterPropertyMap.put(targetClass, propertyMap); + // } + // propertyMap.put(mPropertyName, mJniSetter); + // } + // } + //} catch (NoSuchMethodError e) { + // Log.d("PropertyValuesHolder", + // "Can't find native method using JNI, use reflection" + e); + //} finally { + // mPropertyMapLock.writeLock().unlock(); + //} + //if (mJniSetter == 0) { + // Couldn't find method through fast JNI approach - just use reflection + super.setupSetter(targetClass); + //} + } + } + + static class FloatPropertyValuesHolder extends PropertyValuesHolder { + + // Cache JNI functions to avoid looking them up twice + //private static final HashMap> sJNISetterPropertyMap = + // new HashMap>(); + //int mJniSetter; + //private FloatProperty mFloatProperty; + + FloatKeyframeSet mFloatKeyframeSet; + float mFloatAnimatedValue; + + public FloatPropertyValuesHolder(String propertyName, FloatKeyframeSet keyframeSet) { + super(propertyName); + mValueType = float.class; + mKeyframeSet = keyframeSet; + mFloatKeyframeSet = (FloatKeyframeSet) mKeyframeSet; + } + + //public FloatPropertyValuesHolder(Property property, FloatKeyframeSet keyframeSet) { + // super(property); + // mValueType = float.class; + // mKeyframeSet = keyframeSet; + // mFloatKeyframeSet = (FloatKeyframeSet) mKeyframeSet; + // if (property instanceof FloatProperty) { + // mFloatProperty = (FloatProperty) mProperty; + // } + //} + + public FloatPropertyValuesHolder(String propertyName, float... values) { + super(propertyName); + setFloatValues(values); + } + + //public FloatPropertyValuesHolder(Property property, float... values) { + // super(property); + // setFloatValues(values); + // if (property instanceof FloatProperty) { + // mFloatProperty = (FloatProperty) mProperty; + // } + //} + + @Override + public void setFloatValues(float... values) { + super.setFloatValues(values); + mFloatKeyframeSet = (FloatKeyframeSet) mKeyframeSet; + } + + @Override + void calculateValue(float fraction) { + mFloatAnimatedValue = mFloatKeyframeSet.getFloatValue(fraction); + } + + @Override + Object getAnimatedValue() { + return mFloatAnimatedValue; + } + + @Override + public FloatPropertyValuesHolder clone() { + FloatPropertyValuesHolder newPVH = (FloatPropertyValuesHolder) super.clone(); + newPVH.mFloatKeyframeSet = (FloatKeyframeSet) newPVH.mKeyframeSet; + return newPVH; + } + + /** + * Internal function to set the value on the target object, using the setter set up + * earlier on this PropertyValuesHolder object. This function is called by ObjectAnimator + * to handle turning the value calculated by ValueAnimator into a value set on the object + * according to the name of the property. + * @param target The target object on which the value is set + */ + @Override + void setAnimatedValue(Object target) { + //if (mFloatProperty != null) { + // mFloatProperty.setValue(target, mFloatAnimatedValue); + // return; + //} + //if (mProperty != null) { + // mProperty.set(target, mFloatAnimatedValue); + // return; + //} + //if (mJniSetter != 0) { + // nCallFloatMethod(target, mJniSetter, mFloatAnimatedValue); + // return; + //} + if (mSetter != null) { + try { + mTmpValueArray[0] = mFloatAnimatedValue; + mSetter.invoke(target, mTmpValueArray); + } catch (InvocationTargetException e) { + Log.e("PropertyValuesHolder", e.toString()); + } catch (IllegalAccessException e) { + Log.e("PropertyValuesHolder", e.toString()); + } + } + } + + @Override + void setupSetter(Class targetClass) { + //if (mProperty != null) { + // return; + //} + // Check new static hashmap for setter method + //try { + // mPropertyMapLock.writeLock().lock(); + // HashMap propertyMap = sJNISetterPropertyMap.get(targetClass); + // if (propertyMap != null) { + // Integer mJniSetterInteger = propertyMap.get(mPropertyName); + // if (mJniSetterInteger != null) { + // mJniSetter = mJniSetterInteger; + // } + // } + // if (mJniSetter == 0) { + // String methodName = getMethodName("set", mPropertyName); + // mJniSetter = nGetFloatMethod(targetClass, methodName); + // if (mJniSetter != 0) { + // if (propertyMap == null) { + // propertyMap = new HashMap(); + // sJNISetterPropertyMap.put(targetClass, propertyMap); + // } + // propertyMap.put(mPropertyName, mJniSetter); + // } + // } + //} catch (NoSuchMethodError e) { + // Log.d("PropertyValuesHolder", + // "Can't find native method using JNI, use reflection" + e); + //} finally { + // mPropertyMapLock.writeLock().unlock(); + //} + //if (mJniSetter == 0) { + // Couldn't find method through fast JNI approach - just use reflection + super.setupSetter(targetClass); + //} + } + + } + + //native static private int nGetIntMethod(Class targetClass, String methodName); + //native static private int nGetFloatMethod(Class targetClass, String methodName); + //native static private void nCallIntMethod(Object target, int methodID, int arg); + //native static private void nCallFloatMethod(Object target, int methodID, float arg); +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/TypeEvaluator.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/TypeEvaluator.java new file mode 100644 index 000000000..0ea319244 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/TypeEvaluator.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; + +/** + * Interface for use with the {@link ValueAnimator#setEvaluator(TypeEvaluator)} function. Evaluators + * allow developers to create animations on arbitrary property types, by allowing them to supply + * custom evaulators for types that are not automatically understood and used by the animation + * system. + * + * @see ValueAnimator#setEvaluator(TypeEvaluator) + */ +public interface TypeEvaluator { + + /** + * This function returns the result of linearly interpolating the start and end values, with + * fraction representing the proportion between the start and end values. The + * calculation is a simple parametric calculation: result = x0 + t * (v1 - v0), + * where x0 is startValue, x1 is endValue, + * and t is fraction. + * + * @param fraction The fraction from the starting to the ending values + * @param startValue The start value. + * @param endValue The end value. + * @return A linear interpolation between the start and end values, given the + * fraction parameter. + */ + public T evaluate(float fraction, T startValue, T endValue); + +} \ No newline at end of file diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java new file mode 100644 index 000000000..d8a12c688 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java @@ -0,0 +1,1265 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.nineoldandroids.animation; + +import android.os.Handler; +import android.os.Looper; +import android.os.Message; +import android.util.AndroidRuntimeException; +import android.view.animation.AccelerateDecelerateInterpolator; +import android.view.animation.AnimationUtils; +import android.view.animation.Interpolator; +import android.view.animation.LinearInterpolator; + +import java.util.ArrayList; +import java.util.HashMap; + +/** + * This class provides a simple timing engine for running animations + * which calculate animated values and set them on target objects. + * + *

There is a single timing pulse that all animations use. It runs in a + * custom handler to ensure that property changes happen on the UI thread.

+ * + *

By default, ValueAnimator uses non-linear time interpolation, via the + * {@link AccelerateDecelerateInterpolator} class, which accelerates into and decelerates + * out of an animation. This behavior can be changed by calling + * {@link ValueAnimator#setInterpolator(TimeInterpolator)}.

+ */ +@SuppressWarnings({"rawtypes", "unchecked"}) +public class ValueAnimator extends Animator { + + /** + * Internal constants + */ + + /* + * The default amount of time in ms between animation frames + */ + private static final long DEFAULT_FRAME_DELAY = 10; + + /** + * Messages sent to timing handler: START is sent when an animation first begins, FRAME is sent + * by the handler to itself to process the next animation frame + */ + static final int ANIMATION_START = 0; + static final int ANIMATION_FRAME = 1; + + /** + * Values used with internal variable mPlayingState to indicate the current state of an + * animation. + */ + static final int STOPPED = 0; // Not yet playing + static final int RUNNING = 1; // Playing normally + static final int SEEKED = 2; // Seeked to some time value + + /** + * Internal variables + * NOTE: This object implements the clone() method, making a deep copy of any referenced + * objects. As other non-trivial fields are added to this class, make sure to add logic + * to clone() to make deep copies of them. + */ + + // The first time that the animation's animateFrame() method is called. This time is used to + // determine elapsed time (and therefore the elapsed fraction) in subsequent calls + // to animateFrame() + long mStartTime; + + /** + * Set when setCurrentPlayTime() is called. If negative, animation is not currently seeked + * to a value. + */ + long mSeekTime = -1; + + // TODO: We access the following ThreadLocal variables often, some of them on every update. + // If ThreadLocal access is significantly expensive, we may want to put all of these + // fields into a structure sot hat we just access ThreadLocal once to get the reference + // to that structure, then access the structure directly for each field. + + // The static sAnimationHandler processes the internal timing loop on which all animations + // are based + private static ThreadLocal sAnimationHandler = + new ThreadLocal(); + + // The per-thread list of all active animations + private static final ThreadLocal> sAnimations = + new ThreadLocal>() { + @Override + protected ArrayList initialValue() { + return new ArrayList(); + } + }; + + // The per-thread set of animations to be started on the next animation frame + private static final ThreadLocal> sPendingAnimations = + new ThreadLocal>() { + @Override + protected ArrayList initialValue() { + return new ArrayList(); + } + }; + + /** + * Internal per-thread collections used to avoid set collisions as animations start and end + * while being processed. + */ + private static final ThreadLocal> sDelayedAnims = + new ThreadLocal>() { + @Override + protected ArrayList initialValue() { + return new ArrayList(); + } + }; + + private static final ThreadLocal> sEndingAnims = + new ThreadLocal>() { + @Override + protected ArrayList initialValue() { + return new ArrayList(); + } + }; + + private static final ThreadLocal> sReadyAnims = + new ThreadLocal>() { + @Override + protected ArrayList initialValue() { + return new ArrayList(); + } + }; + + // The time interpolator to be used if none is set on the animation + private static final /*Time*/Interpolator sDefaultInterpolator = + new AccelerateDecelerateInterpolator(); + + // type evaluators for the primitive types handled by this implementation + //private static final TypeEvaluator sIntEvaluator = new IntEvaluator(); + //private static final TypeEvaluator sFloatEvaluator = new FloatEvaluator(); + + /** + * Used to indicate whether the animation is currently playing in reverse. This causes the + * elapsed fraction to be inverted to calculate the appropriate values. + */ + private boolean mPlayingBackwards = false; + + /** + * This variable tracks the current iteration that is playing. When mCurrentIteration exceeds the + * repeatCount (if repeatCount!=INFINITE), the animation ends + */ + private int mCurrentIteration = 0; + + /** + * Tracks current elapsed/eased fraction, for querying in getAnimatedFraction(). + */ + private float mCurrentFraction = 0f; + + /** + * Tracks whether a startDelay'd animation has begun playing through the startDelay. + */ + private boolean mStartedDelay = false; + + /** + * Tracks the time at which the animation began playing through its startDelay. This is + * different from the mStartTime variable, which is used to track when the animation became + * active (which is when the startDelay expired and the animation was added to the active + * animations list). + */ + private long mDelayStartTime; + + /** + * Flag that represents the current state of the animation. Used to figure out when to start + * an animation (if state == STOPPED). Also used to end an animation that + * has been cancel()'d or end()'d since the last animation frame. Possible values are + * STOPPED, RUNNING, SEEKED. + */ + int mPlayingState = STOPPED; + + /** + * Additional playing state to indicate whether an animator has been start()'d. There is + * some lag between a call to start() and the first animation frame. We should still note + * that the animation has been started, even if it's first animation frame has not yet + * happened, and reflect that state in isRunning(). + * Note that delayed animations are different: they are not started until their first + * animation frame, which occurs after their delay elapses. + */ + private boolean mRunning = false; + + /** + * Additional playing state to indicate whether an animator has been start()'d, whether or + * not there is a nonzero startDelay. + */ + private boolean mStarted = false; + + /** + * Flag that denotes whether the animation is set up and ready to go. Used to + * set up animation that has not yet been started. + */ + boolean mInitialized = false; + + // + // Backing variables + // + + // How long the animation should last in ms + private long mDuration = 300; + + // The amount of time in ms to delay starting the animation after start() is called + private long mStartDelay = 0; + + // The number of milliseconds between animation frames + private static long sFrameDelay = DEFAULT_FRAME_DELAY; + + // The number of times the animation will repeat. The default is 0, which means the animation + // will play only once + private int mRepeatCount = 0; + + /** + * The type of repetition that will occur when repeatMode is nonzero. RESTART means the + * animation will start from the beginning on every new cycle. REVERSE means the animation + * will reverse directions on each iteration. + */ + private int mRepeatMode = RESTART; + + /** + * The time interpolator to be used. The elapsed fraction of the animation will be passed + * through this interpolator to calculate the interpolated fraction, which is then used to + * calculate the animated values. + */ + private /*Time*/Interpolator mInterpolator = sDefaultInterpolator; + + /** + * The set of listeners to be sent events through the life of an animation. + */ + private ArrayList mUpdateListeners = null; + + /** + * The property/value sets being animated. + */ + PropertyValuesHolder[] mValues; + + /** + * A hashmap of the PropertyValuesHolder objects. This map is used to lookup animated values + * by property name during calls to getAnimatedValue(String). + */ + HashMap mValuesMap; + + /** + * Public constants + */ + + /** + * When the animation reaches the end and repeatCount is INFINITE + * or a positive value, the animation restarts from the beginning. + */ + public static final int RESTART = 1; + /** + * When the animation reaches the end and repeatCount is INFINITE + * or a positive value, the animation reverses direction on every iteration. + */ + public static final int REVERSE = 2; + /** + * This value used used with the {@link #setRepeatCount(int)} property to repeat + * the animation indefinitely. + */ + public static final int INFINITE = -1; + + /** + * Creates a new ValueAnimator object. This default constructor is primarily for + * use internally; the factory methods which take parameters are more generally + * useful. + */ + public ValueAnimator() { + } + + /** + * Constructs and returns a ValueAnimator that animates between int values. A single + * value implies that that value is the one being animated to. However, this is not typically + * useful in a ValueAnimator object because there is no way for the object to determine the + * starting value for the animation (unlike ObjectAnimator, which can derive that value + * from the target object and property being animated). Therefore, there should typically + * be two or more values. + * + * @param values A set of values that the animation will animate between over time. + * @return A ValueAnimator object that is set up to animate between the given values. + */ + public static ValueAnimator ofInt(int... values) { + ValueAnimator anim = new ValueAnimator(); + anim.setIntValues(values); + return anim; + } + + /** + * Constructs and returns a ValueAnimator that animates between float values. A single + * value implies that that value is the one being animated to. However, this is not typically + * useful in a ValueAnimator object because there is no way for the object to determine the + * starting value for the animation (unlike ObjectAnimator, which can derive that value + * from the target object and property being animated). Therefore, there should typically + * be two or more values. + * + * @param values A set of values that the animation will animate between over time. + * @return A ValueAnimator object that is set up to animate between the given values. + */ + public static ValueAnimator ofFloat(float... values) { + ValueAnimator anim = new ValueAnimator(); + anim.setFloatValues(values); + return anim; + } + + /** + * Constructs and returns a ValueAnimator that animates between the values + * specified in the PropertyValuesHolder objects. + * + * @param values A set of PropertyValuesHolder objects whose values will be animated + * between over time. + * @return A ValueAnimator object that is set up to animate between the given values. + */ + public static ValueAnimator ofPropertyValuesHolder(PropertyValuesHolder... values) { + ValueAnimator anim = new ValueAnimator(); + anim.setValues(values); + return anim; + } + /** + * Constructs and returns a ValueAnimator that animates between Object values. A single + * value implies that that value is the one being animated to. However, this is not typically + * useful in a ValueAnimator object because there is no way for the object to determine the + * starting value for the animation (unlike ObjectAnimator, which can derive that value + * from the target object and property being animated). Therefore, there should typically + * be two or more values. + * + *

Since ValueAnimator does not know how to animate between arbitrary Objects, this + * factory method also takes a TypeEvaluator object that the ValueAnimator will use + * to perform that interpolation. + * + * @param evaluator A TypeEvaluator that will be called on each animation frame to + * provide the ncessry interpolation between the Object values to derive the animated + * value. + * @param values A set of values that the animation will animate between over time. + * @return A ValueAnimator object that is set up to animate between the given values. + */ + public static ValueAnimator ofObject(TypeEvaluator evaluator, Object... values) { + ValueAnimator anim = new ValueAnimator(); + anim.setObjectValues(values); + anim.setEvaluator(evaluator); + return anim; + } + + /** + * Sets int values that will be animated between. A single + * value implies that that value is the one being animated to. However, this is not typically + * useful in a ValueAnimator object because there is no way for the object to determine the + * starting value for the animation (unlike ObjectAnimator, which can derive that value + * from the target object and property being animated). Therefore, there should typically + * be two or more values. + * + *

If there are already multiple sets of values defined for this ValueAnimator via more + * than one PropertyValuesHolder object, this method will set the values for the first + * of those objects.

+ * + * @param values A set of values that the animation will animate between over time. + */ + public void setIntValues(int... values) { + if (values == null || values.length == 0) { + return; + } + if (mValues == null || mValues.length == 0) { + setValues(new PropertyValuesHolder[]{PropertyValuesHolder.ofInt("", values)}); + } else { + PropertyValuesHolder valuesHolder = mValues[0]; + valuesHolder.setIntValues(values); + } + // New property/values/target should cause re-initialization prior to starting + mInitialized = false; + } + + /** + * Sets float values that will be animated between. A single + * value implies that that value is the one being animated to. However, this is not typically + * useful in a ValueAnimator object because there is no way for the object to determine the + * starting value for the animation (unlike ObjectAnimator, which can derive that value + * from the target object and property being animated). Therefore, there should typically + * be two or more values. + * + *

If there are already multiple sets of values defined for this ValueAnimator via more + * than one PropertyValuesHolder object, this method will set the values for the first + * of those objects.

+ * + * @param values A set of values that the animation will animate between over time. + */ + public void setFloatValues(float... values) { + if (values == null || values.length == 0) { + return; + } + if (mValues == null || mValues.length == 0) { + setValues(new PropertyValuesHolder[]{PropertyValuesHolder.ofFloat("", values)}); + } else { + PropertyValuesHolder valuesHolder = mValues[0]; + valuesHolder.setFloatValues(values); + } + // New property/values/target should cause re-initialization prior to starting + mInitialized = false; + } + + /** + * Sets the values to animate between for this animation. A single + * value implies that that value is the one being animated to. However, this is not typically + * useful in a ValueAnimator object because there is no way for the object to determine the + * starting value for the animation (unlike ObjectAnimator, which can derive that value + * from the target object and property being animated). Therefore, there should typically + * be two or more values. + * + *

If there are already multiple sets of values defined for this ValueAnimator via more + * than one PropertyValuesHolder object, this method will set the values for the first + * of those objects.

+ * + *

There should be a TypeEvaluator set on the ValueAnimator that knows how to interpolate + * between these value objects. ValueAnimator only knows how to interpolate between the + * primitive types specified in the other setValues() methods.

+ * + * @param values The set of values to animate between. + */ + public void setObjectValues(Object... values) { + if (values == null || values.length == 0) { + return; + } + if (mValues == null || mValues.length == 0) { + setValues(new PropertyValuesHolder[]{PropertyValuesHolder.ofObject("", + (TypeEvaluator)null, values)}); + } else { + PropertyValuesHolder valuesHolder = mValues[0]; + valuesHolder.setObjectValues(values); + } + // New property/values/target should cause re-initialization prior to starting + mInitialized = false; + } + + /** + * Sets the values, per property, being animated between. This function is called internally + * by the constructors of ValueAnimator that take a list of values. But an ValueAnimator can + * be constructed without values and this method can be called to set the values manually + * instead. + * + * @param values The set of values, per property, being animated between. + */ + public void setValues(PropertyValuesHolder... values) { + int numValues = values.length; + mValues = values; + mValuesMap = new HashMap(numValues); + for (int i = 0; i < numValues; ++i) { + PropertyValuesHolder valuesHolder = values[i]; + mValuesMap.put(valuesHolder.getPropertyName(), valuesHolder); + } + // New property/values/target should cause re-initialization prior to starting + mInitialized = false; + } + + /** + * Returns the values that this ValueAnimator animates between. These values are stored in + * PropertyValuesHolder objects, even if the ValueAnimator was created with a simple list + * of value objects instead. + * + * @return PropertyValuesHolder[] An array of PropertyValuesHolder objects which hold the + * values, per property, that define the animation. + */ + public PropertyValuesHolder[] getValues() { + return mValues; + } + + /** + * This function is called immediately before processing the first animation + * frame of an animation. If there is a nonzero startDelay, the + * function is called after that delay ends. + * It takes care of the final initialization steps for the + * animation. + * + *

Overrides of this method should call the superclass method to ensure + * that internal mechanisms for the animation are set up correctly.

+ */ + void initAnimation() { + if (!mInitialized) { + int numValues = mValues.length; + for (int i = 0; i < numValues; ++i) { + mValues[i].init(); + } + mInitialized = true; + } + } + + + /** + * Sets the length of the animation. The default duration is 300 milliseconds. + * + * @param duration The length of the animation, in milliseconds. This value cannot + * be negative. + * @return ValueAnimator The object called with setDuration(). This return + * value makes it easier to compose statements together that construct and then set the + * duration, as in ValueAnimator.ofInt(0, 10).setDuration(500).start(). + */ + public ValueAnimator setDuration(long duration) { + if (duration < 0) { + throw new IllegalArgumentException("Animators cannot have negative duration: " + + duration); + } + mDuration = duration; + return this; + } + + /** + * Gets the length of the animation. The default duration is 300 milliseconds. + * + * @return The length of the animation, in milliseconds. + */ + public long getDuration() { + return mDuration; + } + + /** + * Sets the position of the animation to the specified point in time. This time should + * be between 0 and the total duration of the animation, including any repetition. If + * the animation has not yet been started, then it will not advance forward after it is + * set to this time; it will simply set the time to this value and perform any appropriate + * actions based on that time. If the animation is already running, then setCurrentPlayTime() + * will set the current playing time to this value and continue playing from that point. + * + * @param playTime The time, in milliseconds, to which the animation is advanced or rewound. + */ + public void setCurrentPlayTime(long playTime) { + initAnimation(); + long currentTime = AnimationUtils.currentAnimationTimeMillis(); + if (mPlayingState != RUNNING) { + mSeekTime = playTime; + mPlayingState = SEEKED; + } + mStartTime = currentTime - playTime; + animationFrame(currentTime); + } + + /** + * Gets the current position of the animation in time, which is equal to the current + * time minus the time that the animation started. An animation that is not yet started will + * return a value of zero. + * + * @return The current position in time of the animation. + */ + public long getCurrentPlayTime() { + if (!mInitialized || mPlayingState == STOPPED) { + return 0; + } + return AnimationUtils.currentAnimationTimeMillis() - mStartTime; + } + + /** + * This custom, static handler handles the timing pulse that is shared by + * all active animations. This approach ensures that the setting of animation + * values will happen on the UI thread and that all animations will share + * the same times for calculating their values, which makes synchronizing + * animations possible. + * + */ + private static class AnimationHandler extends Handler { + /** + * There are only two messages that we care about: ANIMATION_START and + * ANIMATION_FRAME. The START message is sent when an animation's start() + * method is called. It cannot start synchronously when start() is called + * because the call may be on the wrong thread, and it would also not be + * synchronized with other animations because it would not start on a common + * timing pulse. So each animation sends a START message to the handler, which + * causes the handler to place the animation on the active animations queue and + * start processing frames for that animation. + * The FRAME message is the one that is sent over and over while there are any + * active animations to process. + */ + @Override + public void handleMessage(Message msg) { + boolean callAgain = true; + ArrayList animations = sAnimations.get(); + ArrayList delayedAnims = sDelayedAnims.get(); + switch (msg.what) { + // TODO: should we avoid sending frame message when starting if we + // were already running? + case ANIMATION_START: + ArrayList pendingAnimations = sPendingAnimations.get(); + if (animations.size() > 0 || delayedAnims.size() > 0) { + callAgain = false; + } + // pendingAnims holds any animations that have requested to be started + // We're going to clear sPendingAnimations, but starting animation may + // cause more to be added to the pending list (for example, if one animation + // starting triggers another starting). So we loop until sPendingAnimations + // is empty. + while (pendingAnimations.size() > 0) { + ArrayList pendingCopy = + (ArrayList) pendingAnimations.clone(); + pendingAnimations.clear(); + int count = pendingCopy.size(); + for (int i = 0; i < count; ++i) { + ValueAnimator anim = pendingCopy.get(i); + // If the animation has a startDelay, place it on the delayed list + if (anim.mStartDelay == 0) { + anim.startAnimation(); + } else { + delayedAnims.add(anim); + } + } + } + // fall through to process first frame of new animations + case ANIMATION_FRAME: + // currentTime holds the common time for all animations processed + // during this frame + long currentTime = AnimationUtils.currentAnimationTimeMillis(); + ArrayList readyAnims = sReadyAnims.get(); + ArrayList endingAnims = sEndingAnims.get(); + + // First, process animations currently sitting on the delayed queue, adding + // them to the active animations if they are ready + int numDelayedAnims = delayedAnims.size(); + for (int i = 0; i < numDelayedAnims; ++i) { + ValueAnimator anim = delayedAnims.get(i); + if (anim.delayedAnimationFrame(currentTime)) { + readyAnims.add(anim); + } + } + int numReadyAnims = readyAnims.size(); + if (numReadyAnims > 0) { + for (int i = 0; i < numReadyAnims; ++i) { + ValueAnimator anim = readyAnims.get(i); + anim.startAnimation(); + anim.mRunning = true; + delayedAnims.remove(anim); + } + readyAnims.clear(); + } + + // Now process all active animations. The return value from animationFrame() + // tells the handler whether it should now be ended + int numAnims = animations.size(); + int i = 0; + while (i < numAnims) { + ValueAnimator anim = animations.get(i); + if (anim.animationFrame(currentTime)) { + endingAnims.add(anim); + } + if (animations.size() == numAnims) { + ++i; + } else { + // An animation might be canceled or ended by client code + // during the animation frame. Check to see if this happened by + // seeing whether the current index is the same as it was before + // calling animationFrame(). Another approach would be to copy + // animations to a temporary list and process that list instead, + // but that entails garbage and processing overhead that would + // be nice to avoid. + --numAnims; + endingAnims.remove(anim); + } + } + if (endingAnims.size() > 0) { + for (i = 0; i < endingAnims.size(); ++i) { + endingAnims.get(i).endAnimation(); + } + endingAnims.clear(); + } + + // If there are still active or delayed animations, call the handler again + // after the frameDelay + if (callAgain && (!animations.isEmpty() || !delayedAnims.isEmpty())) { + sendEmptyMessageDelayed(ANIMATION_FRAME, Math.max(0, sFrameDelay - + (AnimationUtils.currentAnimationTimeMillis() - currentTime))); + } + break; + } + } + } + + /** + * The amount of time, in milliseconds, to delay starting the animation after + * {@link #start()} is called. + * + * @return the number of milliseconds to delay running the animation + */ + public long getStartDelay() { + return mStartDelay; + } + + /** + * The amount of time, in milliseconds, to delay starting the animation after + * {@link #start()} is called. + + * @param startDelay The amount of the delay, in milliseconds + */ + public void setStartDelay(long startDelay) { + this.mStartDelay = startDelay; + } + + /** + * The amount of time, in milliseconds, between each frame of the animation. This is a + * requested time that the animation will attempt to honor, but the actual delay between + * frames may be different, depending on system load and capabilities. This is a static + * function because the same delay will be applied to all animations, since they are all + * run off of a single timing loop. + * + * @return the requested time between frames, in milliseconds + */ + public static long getFrameDelay() { + return sFrameDelay; + } + + /** + * The amount of time, in milliseconds, between each frame of the animation. This is a + * requested time that the animation will attempt to honor, but the actual delay between + * frames may be different, depending on system load and capabilities. This is a static + * function because the same delay will be applied to all animations, since they are all + * run off of a single timing loop. + * + * @param frameDelay the requested time between frames, in milliseconds + */ + public static void setFrameDelay(long frameDelay) { + sFrameDelay = frameDelay; + } + + /** + * The most recent value calculated by this ValueAnimator when there is just one + * property being animated. This value is only sensible while the animation is running. The main + * purpose for this read-only property is to retrieve the value from the ValueAnimator + * during a call to {@link AnimatorUpdateListener#onAnimationUpdate(ValueAnimator)}, which + * is called during each animation frame, immediately after the value is calculated. + * + * @return animatedValue The value most recently calculated by this ValueAnimator for + * the single property being animated. If there are several properties being animated + * (specified by several PropertyValuesHolder objects in the constructor), this function + * returns the animated value for the first of those objects. + */ + public Object getAnimatedValue() { + if (mValues != null && mValues.length > 0) { + return mValues[0].getAnimatedValue(); + } + // Shouldn't get here; should always have values unless ValueAnimator was set up wrong + return null; + } + + /** + * The most recent value calculated by this ValueAnimator for propertyName. + * The main purpose for this read-only property is to retrieve the value from the + * ValueAnimator during a call to + * {@link AnimatorUpdateListener#onAnimationUpdate(ValueAnimator)}, which + * is called during each animation frame, immediately after the value is calculated. + * + * @return animatedValue The value most recently calculated for the named property + * by this ValueAnimator. + */ + public Object getAnimatedValue(String propertyName) { + PropertyValuesHolder valuesHolder = mValuesMap.get(propertyName); + if (valuesHolder != null) { + return valuesHolder.getAnimatedValue(); + } else { + // At least avoid crashing if called with bogus propertyName + return null; + } + } + + /** + * Sets how many times the animation should be repeated. If the repeat + * count is 0, the animation is never repeated. If the repeat count is + * greater than 0 or {@link #INFINITE}, the repeat mode will be taken + * into account. The repeat count is 0 by default. + * + * @param value the number of times the animation should be repeated + */ + public void setRepeatCount(int value) { + mRepeatCount = value; + } + /** + * Defines how many times the animation should repeat. The default value + * is 0. + * + * @return the number of times the animation should repeat, or {@link #INFINITE} + */ + public int getRepeatCount() { + return mRepeatCount; + } + + /** + * Defines what this animation should do when it reaches the end. This + * setting is applied only when the repeat count is either greater than + * 0 or {@link #INFINITE}. Defaults to {@link #RESTART}. + * + * @param value {@link #RESTART} or {@link #REVERSE} + */ + public void setRepeatMode(int value) { + mRepeatMode = value; + } + + /** + * Defines what this animation should do when it reaches the end. + * + * @return either one of {@link #REVERSE} or {@link #RESTART} + */ + public int getRepeatMode() { + return mRepeatMode; + } + + /** + * Adds a listener to the set of listeners that are sent update events through the life of + * an animation. This method is called on all listeners for every frame of the animation, + * after the values for the animation have been calculated. + * + * @param listener the listener to be added to the current set of listeners for this animation. + */ + public void addUpdateListener(AnimatorUpdateListener listener) { + if (mUpdateListeners == null) { + mUpdateListeners = new ArrayList(); + } + mUpdateListeners.add(listener); + } + + /** + * Removes all listeners from the set listening to frame updates for this animation. + */ + public void removeAllUpdateListeners() { + if (mUpdateListeners == null) { + return; + } + mUpdateListeners.clear(); + mUpdateListeners = null; + } + + /** + * Removes a listener from the set listening to frame updates for this animation. + * + * @param listener the listener to be removed from the current set of update listeners + * for this animation. + */ + public void removeUpdateListener(AnimatorUpdateListener listener) { + if (mUpdateListeners == null) { + return; + } + mUpdateListeners.remove(listener); + if (mUpdateListeners.size() == 0) { + mUpdateListeners = null; + } + } + + + /** + * The time interpolator used in calculating the elapsed fraction of this animation. The + * interpolator determines whether the animation runs with linear or non-linear motion, + * such as acceleration and deceleration. The default value is + * {@link android.view.animation.AccelerateDecelerateInterpolator} + * + * @param value the interpolator to be used by this animation. A value of null + * will result in linear interpolation. + */ + @Override + public void setInterpolator(/*Time*/Interpolator value) { + if (value != null) { + mInterpolator = value; + } else { + mInterpolator = new LinearInterpolator(); + } + } + + /** + * Returns the timing interpolator that this ValueAnimator uses. + * + * @return The timing interpolator for this ValueAnimator. + */ + public /*Time*/Interpolator getInterpolator() { + return mInterpolator; + } + + /** + * The type evaluator to be used when calculating the animated values of this animation. + * The system will automatically assign a float or int evaluator based on the type + * of startValue and endValue in the constructor. But if these values + * are not one of these primitive types, or if different evaluation is desired (such as is + * necessary with int values that represent colors), a custom evaluator needs to be assigned. + * For example, when running an animation on color values, the {@link ArgbEvaluator} + * should be used to get correct RGB color interpolation. + * + *

If this ValueAnimator has only one set of values being animated between, this evaluator + * will be used for that set. If there are several sets of values being animated, which is + * the case if PropertyValuesHOlder objects were set on the ValueAnimator, then the evaluator + * is assigned just to the first PropertyValuesHolder object.

+ * + * @param value the evaluator to be used this animation + */ + public void setEvaluator(TypeEvaluator value) { + if (value != null && mValues != null && mValues.length > 0) { + mValues[0].setEvaluator(value); + } + } + + /** + * Start the animation playing. This version of start() takes a boolean flag that indicates + * whether the animation should play in reverse. The flag is usually false, but may be set + * to true if called from the reverse() method. + * + *

The animation started by calling this method will be run on the thread that called + * this method. This thread should have a Looper on it (a runtime exception will be thrown if + * this is not the case). Also, if the animation will animate + * properties of objects in the view hierarchy, then the calling thread should be the UI + * thread for that view hierarchy.

+ * + * @param playBackwards Whether the ValueAnimator should start playing in reverse. + */ + private void start(boolean playBackwards) { + if (Looper.myLooper() == null) { + throw new AndroidRuntimeException("Animators may only be run on Looper threads"); + } + mPlayingBackwards = playBackwards; + mCurrentIteration = 0; + mPlayingState = STOPPED; + mStarted = true; + mStartedDelay = false; + sPendingAnimations.get().add(this); + if (mStartDelay == 0) { + // This sets the initial value of the animation, prior to actually starting it running + setCurrentPlayTime(getCurrentPlayTime()); + mPlayingState = STOPPED; + mRunning = true; + + if (mListeners != null) { + ArrayList tmpListeners = + (ArrayList) mListeners.clone(); + int numListeners = tmpListeners.size(); + for (int i = 0; i < numListeners; ++i) { + tmpListeners.get(i).onAnimationStart(this); + } + } + } + AnimationHandler animationHandler = sAnimationHandler.get(); + if (animationHandler == null) { + animationHandler = new AnimationHandler(); + sAnimationHandler.set(animationHandler); + } + animationHandler.sendEmptyMessage(ANIMATION_START); + } + + @Override + public void start() { + start(false); + } + + @Override + public void cancel() { + // Only cancel if the animation is actually running or has been started and is about + // to run + if (mPlayingState != STOPPED || sPendingAnimations.get().contains(this) || + sDelayedAnims.get().contains(this)) { + // Only notify listeners if the animator has actually started + if (mRunning && mListeners != null) { + ArrayList tmpListeners = + (ArrayList) mListeners.clone(); + for (AnimatorListener listener : tmpListeners) { + listener.onAnimationCancel(this); + } + } + endAnimation(); + } + } + + @Override + public void end() { + if (!sAnimations.get().contains(this) && !sPendingAnimations.get().contains(this)) { + // Special case if the animation has not yet started; get it ready for ending + mStartedDelay = false; + startAnimation(); + } else if (!mInitialized) { + initAnimation(); + } + // The final value set on the target varies, depending on whether the animation + // was supposed to repeat an odd number of times + if (mRepeatCount > 0 && (mRepeatCount & 0x01) == 1) { + animateValue(0f); + } else { + animateValue(1f); + } + endAnimation(); + } + + @Override + public boolean isRunning() { + return (mPlayingState == RUNNING || mRunning); + } + + @Override + public boolean isStarted() { + return mStarted; + } + + /** + * Plays the ValueAnimator in reverse. If the animation is already running, + * it will stop itself and play backwards from the point reached when reverse was called. + * If the animation is not currently running, then it will start from the end and + * play backwards. This behavior is only set for the current animation; future playing + * of the animation will use the default behavior of playing forward. + */ + public void reverse() { + mPlayingBackwards = !mPlayingBackwards; + if (mPlayingState == RUNNING) { + long currentTime = AnimationUtils.currentAnimationTimeMillis(); + long currentPlayTime = currentTime - mStartTime; + long timeLeft = mDuration - currentPlayTime; + mStartTime = currentTime - timeLeft; + } else { + start(true); + } + } + + /** + * Called internally to end an animation by removing it from the animations list. Must be + * called on the UI thread. + */ + private void endAnimation() { + sAnimations.get().remove(this); + sPendingAnimations.get().remove(this); + sDelayedAnims.get().remove(this); + mPlayingState = STOPPED; + if (mRunning && mListeners != null) { + ArrayList tmpListeners = + (ArrayList) mListeners.clone(); + int numListeners = tmpListeners.size(); + for (int i = 0; i < numListeners; ++i) { + tmpListeners.get(i).onAnimationEnd(this); + } + } + mRunning = false; + mStarted = false; + } + + /** + * Called internally to start an animation by adding it to the active animations list. Must be + * called on the UI thread. + */ + private void startAnimation() { + initAnimation(); + sAnimations.get().add(this); + if (mStartDelay > 0 && mListeners != null) { + // Listeners were already notified in start() if startDelay is 0; this is + // just for delayed animations + ArrayList tmpListeners = + (ArrayList) mListeners.clone(); + int numListeners = tmpListeners.size(); + for (int i = 0; i < numListeners; ++i) { + tmpListeners.get(i).onAnimationStart(this); + } + } + } + + /** + * Internal function called to process an animation frame on an animation that is currently + * sleeping through its startDelay phase. The return value indicates whether it + * should be woken up and put on the active animations queue. + * + * @param currentTime The current animation time, used to calculate whether the animation + * has exceeded its startDelay and should be started. + * @return True if the animation's startDelay has been exceeded and the animation + * should be added to the set of active animations. + */ + private boolean delayedAnimationFrame(long currentTime) { + if (!mStartedDelay) { + mStartedDelay = true; + mDelayStartTime = currentTime; + } else { + long deltaTime = currentTime - mDelayStartTime; + if (deltaTime > mStartDelay) { + // startDelay ended - start the anim and record the + // mStartTime appropriately + mStartTime = currentTime - (deltaTime - mStartDelay); + mPlayingState = RUNNING; + return true; + } + } + return false; + } + + /** + * This internal function processes a single animation frame for a given animation. The + * currentTime parameter is the timing pulse sent by the handler, used to calculate the + * elapsed duration, and therefore + * the elapsed fraction, of the animation. The return value indicates whether the animation + * should be ended (which happens when the elapsed time of the animation exceeds the + * animation's duration, including the repeatCount). + * + * @param currentTime The current time, as tracked by the static timing handler + * @return true if the animation's duration, including any repetitions due to + * repeatCount has been exceeded and the animation should be ended. + */ + boolean animationFrame(long currentTime) { + boolean done = false; + + if (mPlayingState == STOPPED) { + mPlayingState = RUNNING; + if (mSeekTime < 0) { + mStartTime = currentTime; + } else { + mStartTime = currentTime - mSeekTime; + // Now that we're playing, reset the seek time + mSeekTime = -1; + } + } + switch (mPlayingState) { + case RUNNING: + case SEEKED: + float fraction = mDuration > 0 ? (float)(currentTime - mStartTime) / mDuration : 1f; + if (fraction >= 1f) { + if (mCurrentIteration < mRepeatCount || mRepeatCount == INFINITE) { + // Time to repeat + if (mListeners != null) { + int numListeners = mListeners.size(); + for (int i = 0; i < numListeners; ++i) { + mListeners.get(i).onAnimationRepeat(this); + } + } + if (mRepeatMode == REVERSE) { + mPlayingBackwards = mPlayingBackwards ? false : true; + } + mCurrentIteration += (int)fraction; + fraction = fraction % 1f; + mStartTime += mDuration; + } else { + done = true; + fraction = Math.min(fraction, 1.0f); + } + } + if (mPlayingBackwards) { + fraction = 1f - fraction; + } + animateValue(fraction); + break; + } + + return done; + } + + /** + * Returns the current animation fraction, which is the elapsed/interpolated fraction used in + * the most recent frame update on the animation. + * + * @return Elapsed/interpolated fraction of the animation. + */ + public float getAnimatedFraction() { + return mCurrentFraction; + } + + /** + * This method is called with the elapsed fraction of the animation during every + * animation frame. This function turns the elapsed fraction into an interpolated fraction + * and then into an animated value (from the evaluator. The function is called mostly during + * animation updates, but it is also called when the end() + * function is called, to set the final value on the property. + * + *

Overrides of this method must call the superclass to perform the calculation + * of the animated value.

+ * + * @param fraction The elapsed fraction of the animation. + */ + void animateValue(float fraction) { + fraction = mInterpolator.getInterpolation(fraction); + mCurrentFraction = fraction; + int numValues = mValues.length; + for (int i = 0; i < numValues; ++i) { + mValues[i].calculateValue(fraction); + } + if (mUpdateListeners != null) { + int numListeners = mUpdateListeners.size(); + for (int i = 0; i < numListeners; ++i) { + mUpdateListeners.get(i).onAnimationUpdate(this); + } + } + } + + @Override + public ValueAnimator clone() { + final ValueAnimator anim = (ValueAnimator) super.clone(); + if (mUpdateListeners != null) { + ArrayList oldListeners = mUpdateListeners; + anim.mUpdateListeners = new ArrayList(); + int numListeners = oldListeners.size(); + for (int i = 0; i < numListeners; ++i) { + anim.mUpdateListeners.add(oldListeners.get(i)); + } + } + anim.mSeekTime = -1; + anim.mPlayingBackwards = false; + anim.mCurrentIteration = 0; + anim.mInitialized = false; + anim.mPlayingState = STOPPED; + anim.mStartedDelay = false; + PropertyValuesHolder[] oldValues = mValues; + if (oldValues != null) { + int numValues = oldValues.length; + anim.mValues = new PropertyValuesHolder[numValues]; + anim.mValuesMap = new HashMap(numValues); + for (int i = 0; i < numValues; ++i) { + PropertyValuesHolder newValuesHolder = oldValues[i].clone(); + anim.mValues[i] = newValuesHolder; + anim.mValuesMap.put(newValuesHolder.getPropertyName(), newValuesHolder); + } + } + return anim; + } + + /** + * Implementors of this interface can add themselves as update listeners + * to an ValueAnimator instance to receive callbacks on every animation + * frame, after the current frame's values have been calculated for that + * ValueAnimator. + */ + public static interface AnimatorUpdateListener { + /** + *

Notifies the occurrence of another frame of the animation.

+ * + * @param animation The animation which was repeated. + */ + void onAnimationUpdate(ValueAnimator animation); + + } + + /** + * Return the number of animations currently running. + * + * Used by StrictMode internally to annotate violations. Only + * called on the main thread. + * + * @hide + */ + public static int getCurrentAnimationsCount() { + return sAnimations.get().size(); + } + + /** + * Clear all animations on this thread, without canceling or ending them. + * This should be used with caution. + * + * @hide + */ + public static void clearAllAnimations() { + sAnimations.get().clear(); + sPendingAnimations.get().clear(); + sDelayedAnims.get().clear(); + } + + @Override + public String toString() { + String returnVal = "ValueAnimator@" + Integer.toHexString(hashCode()); + if (mValues != null) { + for (int i = 0; i < mValues.length; ++i) { + returnVal += "\n " + mValues[i].toString(); + } + } + return returnVal; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/NineViewGroup.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/NineViewGroup.java new file mode 100644 index 000000000..7b830b9c0 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/NineViewGroup.java @@ -0,0 +1,79 @@ +package com.actionbarsherlock.internal.nineoldandroids.view; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.ViewGroup; + +import com.actionbarsherlock.internal.nineoldandroids.view.animation.AnimatorProxy; + +public abstract class NineViewGroup extends ViewGroup { + private final AnimatorProxy mProxy; + + public NineViewGroup(Context context) { + super(context); + mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; + } + public NineViewGroup(Context context, AttributeSet attrs) { + super(context, attrs); + mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; + } + public NineViewGroup(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; + } + + @Override + public void setVisibility(int visibility) { + if (mProxy != null) { + if (visibility == GONE) { + clearAnimation(); + } else if (visibility == VISIBLE) { + setAnimation(mProxy); + } + } + super.setVisibility(visibility); + } + + public float getAlpha() { + if (AnimatorProxy.NEEDS_PROXY) { + return mProxy.getAlpha(); + } else { + return super.getAlpha(); + } + } + public void setAlpha(float alpha) { + if (AnimatorProxy.NEEDS_PROXY) { + mProxy.setAlpha(alpha); + } else { + super.setAlpha(alpha); + } + } + public float getTranslationX() { + if (AnimatorProxy.NEEDS_PROXY) { + return mProxy.getTranslationX(); + } else { + return super.getTranslationX(); + } + } + public void setTranslationX(float translationX) { + if (AnimatorProxy.NEEDS_PROXY) { + mProxy.setTranslationX(translationX); + } else { + super.setTranslationX(translationX); + } + } + public float getTranslationY() { + if (AnimatorProxy.NEEDS_PROXY) { + return mProxy.getTranslationY(); + } else { + return super.getTranslationY(); + } + } + public void setTranslationY(float translationY) { + if (AnimatorProxy.NEEDS_PROXY) { + mProxy.setTranslationY(translationY); + } else { + super.setTranslationY(translationY); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/AnimatorProxy.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/AnimatorProxy.java new file mode 100644 index 000000000..067d0494e --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/AnimatorProxy.java @@ -0,0 +1,212 @@ +package com.actionbarsherlock.internal.nineoldandroids.view.animation; + +import java.lang.ref.WeakReference; +import java.util.WeakHashMap; +import android.graphics.Matrix; +import android.graphics.RectF; +import android.os.Build; +import android.util.FloatMath; +import android.view.View; +import android.view.animation.Animation; +import android.view.animation.Transformation; + +public final class AnimatorProxy extends Animation { + public static final boolean NEEDS_PROXY = Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB; + + private static final WeakHashMap PROXIES = + new WeakHashMap(); + + public static AnimatorProxy wrap(View view) { + AnimatorProxy proxy = PROXIES.get(view); + if (proxy == null) { + proxy = new AnimatorProxy(view); + PROXIES.put(view, proxy); + } + return proxy; + } + + private final WeakReference mView; + + private float mAlpha = 1; + private float mScaleX = 1; + private float mScaleY = 1; + private float mTranslationX; + private float mTranslationY; + + private final RectF mBefore = new RectF(); + private final RectF mAfter = new RectF(); + private final Matrix mTempMatrix = new Matrix(); + + private AnimatorProxy(View view) { + setDuration(0); //perform transformation immediately + setFillAfter(true); //persist transformation beyond duration + view.setAnimation(this); + mView = new WeakReference(view); + } + + public float getAlpha() { + return mAlpha; + } + public void setAlpha(float alpha) { + if (mAlpha != alpha) { + mAlpha = alpha; + View view = mView.get(); + if (view != null) { + view.invalidate(); + } + } + } + public float getScaleX() { + return mScaleX; + } + public void setScaleX(float scaleX) { + if (mScaleX != scaleX) { + prepareForUpdate(); + mScaleX = scaleX; + invalidateAfterUpdate(); + } + } + public float getScaleY() { + return mScaleY; + } + public void setScaleY(float scaleY) { + if (mScaleY != scaleY) { + prepareForUpdate(); + mScaleY = scaleY; + invalidateAfterUpdate(); + } + } + public int getScrollX() { + View view = mView.get(); + if (view == null) { + return 0; + } + return view.getScrollX(); + } + public void setScrollX(int value) { + View view = mView.get(); + if (view != null) { + view.scrollTo(value, view.getScrollY()); + } + } + public int getScrollY() { + View view = mView.get(); + if (view == null) { + return 0; + } + return view.getScrollY(); + } + public void setScrollY(int value) { + View view = mView.get(); + if (view != null) { + view.scrollTo(view.getScrollY(), value); + } + } + + public float getTranslationX() { + return mTranslationX; + } + public void setTranslationX(float translationX) { + if (mTranslationX != translationX) { + prepareForUpdate(); + mTranslationX = translationX; + invalidateAfterUpdate(); + } + } + public float getTranslationY() { + return mTranslationY; + } + public void setTranslationY(float translationY) { + if (mTranslationY != translationY) { + prepareForUpdate(); + mTranslationY = translationY; + invalidateAfterUpdate(); + } + } + + private void prepareForUpdate() { + View view = mView.get(); + if (view != null) { + computeRect(mBefore, view); + } + } + private void invalidateAfterUpdate() { + View view = mView.get(); + if (view == null) { + return; + } + View parent = (View)view.getParent(); + if (parent == null) { + return; + } + + view.setAnimation(this); + + final RectF after = mAfter; + computeRect(after, view); + after.union(mBefore); + + parent.invalidate( + (int) FloatMath.floor(after.left), + (int) FloatMath.floor(after.top), + (int) FloatMath.ceil(after.right), + (int) FloatMath.ceil(after.bottom)); + } + + private void computeRect(final RectF r, View view) { + // compute current rectangle according to matrix transformation + final float w = view.getWidth(); + final float h = view.getHeight(); + + // use a rectangle at 0,0 to make sure we don't run into issues with scaling + r.set(0, 0, w, h); + + final Matrix m = mTempMatrix; + m.reset(); + transformMatrix(m, view); + mTempMatrix.mapRect(r); + + r.offset(view.getLeft(), view.getTop()); + + // Straighten coords if rotations flipped them + if (r.right < r.left) { + final float f = r.right; + r.right = r.left; + r.left = f; + } + if (r.bottom < r.top) { + final float f = r.top; + r.top = r.bottom; + r.bottom = f; + } + } + + private void transformMatrix(Matrix m, View view) { + final float w = view.getWidth(); + final float h = view.getHeight(); + + final float sX = mScaleX; + final float sY = mScaleY; + if ((sX != 1.0f) || (sY != 1.0f)) { + final float deltaSX = ((sX * w) - w) / 2f; + final float deltaSY = ((sY * h) - h) / 2f; + m.postScale(sX, sY); + m.postTranslate(-deltaSX, -deltaSY); + } + m.postTranslate(mTranslationX, mTranslationY); + } + + @Override + protected void applyTransformation(float interpolatedTime, Transformation t) { + View view = mView.get(); + if (view != null) { + t.setAlpha(mAlpha); + transformMatrix(t.getMatrix(), view); + } + } + + @Override + public void reset() { + /* Do nothing. */ + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineFrameLayout.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineFrameLayout.java new file mode 100644 index 000000000..2c428e907 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineFrameLayout.java @@ -0,0 +1,65 @@ +package com.actionbarsherlock.internal.nineoldandroids.widget; + +import android.content.Context; +import android.util.AttributeSet; +import android.widget.FrameLayout; + +import com.actionbarsherlock.internal.nineoldandroids.view.animation.AnimatorProxy; + +public class NineFrameLayout extends FrameLayout { + private final AnimatorProxy mProxy; + + public NineFrameLayout(Context context) { + super(context); + mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; + } + public NineFrameLayout(Context context, AttributeSet attrs) { + super(context, attrs); + mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; + } + public NineFrameLayout(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; + } + + @Override + public void setVisibility(int visibility) { + if (mProxy != null) { + if (visibility == GONE) { + clearAnimation(); + } else if (visibility == VISIBLE) { + setAnimation(mProxy); + } + } + super.setVisibility(visibility); + } + + public float getAlpha() { + if (AnimatorProxy.NEEDS_PROXY) { + return mProxy.getAlpha(); + } else { + return super.getAlpha(); + } + } + public void setAlpha(float alpha) { + if (AnimatorProxy.NEEDS_PROXY) { + mProxy.setAlpha(alpha); + } else { + super.setAlpha(alpha); + } + } + public float getTranslationY() { + if (AnimatorProxy.NEEDS_PROXY) { + return mProxy.getTranslationY(); + } else { + return super.getTranslationY(); + } + } + public void setTranslationY(float translationY) { + if (AnimatorProxy.NEEDS_PROXY) { + mProxy.setTranslationY(translationY); + } else { + super.setTranslationY(translationY); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineHorizontalScrollView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineHorizontalScrollView.java new file mode 100644 index 000000000..129b5aaaa --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineHorizontalScrollView.java @@ -0,0 +1,41 @@ +package com.actionbarsherlock.internal.nineoldandroids.widget; + +import android.content.Context; +import android.widget.HorizontalScrollView; +import com.actionbarsherlock.internal.nineoldandroids.view.animation.AnimatorProxy; + +public class NineHorizontalScrollView extends HorizontalScrollView { + private final AnimatorProxy mProxy; + + public NineHorizontalScrollView(Context context) { + super(context); + mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; + } + + @Override + public void setVisibility(int visibility) { + if (mProxy != null) { + if (visibility == GONE) { + clearAnimation(); + } else if (visibility == VISIBLE) { + setAnimation(mProxy); + } + } + super.setVisibility(visibility); + } + + public float getAlpha() { + if (AnimatorProxy.NEEDS_PROXY) { + return mProxy.getAlpha(); + } else { + return super.getAlpha(); + } + } + public void setAlpha(float alpha) { + if (AnimatorProxy.NEEDS_PROXY) { + mProxy.setAlpha(alpha); + } else { + super.setAlpha(alpha); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineLinearLayout.java b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineLinearLayout.java new file mode 100644 index 000000000..a670b1f64 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/widget/NineLinearLayout.java @@ -0,0 +1,65 @@ +package com.actionbarsherlock.internal.nineoldandroids.widget; + +import android.content.Context; +import android.util.AttributeSet; +import android.widget.LinearLayout; + +import com.actionbarsherlock.internal.nineoldandroids.view.animation.AnimatorProxy; + +public class NineLinearLayout extends LinearLayout { + private final AnimatorProxy mProxy; + + public NineLinearLayout(Context context) { + super(context); + mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; + } + public NineLinearLayout(Context context, AttributeSet attrs) { + super(context, attrs); + mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; + } + public NineLinearLayout(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; + } + + @Override + public void setVisibility(int visibility) { + if (mProxy != null) { + if (visibility == GONE) { + clearAnimation(); + } else if (visibility == VISIBLE) { + setAnimation(mProxy); + } + } + super.setVisibility(visibility); + } + + public float getAlpha() { + if (AnimatorProxy.NEEDS_PROXY) { + return mProxy.getAlpha(); + } else { + return super.getAlpha(); + } + } + public void setAlpha(float alpha) { + if (AnimatorProxy.NEEDS_PROXY) { + mProxy.setAlpha(alpha); + } else { + super.setAlpha(alpha); + } + } + public float getTranslationX() { + if (AnimatorProxy.NEEDS_PROXY) { + return mProxy.getTranslationX(); + } else { + return super.getTranslationX(); + } + } + public void setTranslationX(float translationX) { + if (AnimatorProxy.NEEDS_PROXY) { + mProxy.setTranslationX(translationX); + } else { + super.setTranslationX(translationX); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/ActionProviderWrapper.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/ActionProviderWrapper.java new file mode 100644 index 000000000..b136d50f0 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/ActionProviderWrapper.java @@ -0,0 +1,40 @@ +package com.actionbarsherlock.internal.view; + +import com.actionbarsherlock.internal.view.menu.SubMenuWrapper; +import com.actionbarsherlock.view.ActionProvider; +import android.view.View; + +public class ActionProviderWrapper extends android.view.ActionProvider { + private final ActionProvider mProvider; + + + public ActionProviderWrapper(ActionProvider provider) { + super(null/*TODO*/); //XXX this *should* be unused + mProvider = provider; + } + + + public ActionProvider unwrap() { + return mProvider; + } + + @Override + public View onCreateActionView() { + return mProvider.onCreateActionView(); + } + + @Override + public boolean hasSubMenu() { + return mProvider.hasSubMenu(); + } + + @Override + public boolean onPerformDefaultAction() { + return mProvider.onPerformDefaultAction(); + } + + @Override + public void onPrepareSubMenu(android.view.SubMenu subMenu) { + mProvider.onPrepareSubMenu(new SubMenuWrapper(subMenu)); + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/StandaloneActionMode.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/StandaloneActionMode.java new file mode 100644 index 000000000..0a87bd3f7 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/StandaloneActionMode.java @@ -0,0 +1,148 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.view; + +import android.content.Context; +import android.view.View; +import android.view.accessibility.AccessibilityEvent; + +import java.lang.ref.WeakReference; + +import com.actionbarsherlock.internal.view.menu.MenuBuilder; +import com.actionbarsherlock.internal.view.menu.MenuPopupHelper; +import com.actionbarsherlock.internal.view.menu.SubMenuBuilder; +import com.actionbarsherlock.internal.widget.ActionBarContextView; +import com.actionbarsherlock.view.ActionMode; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; + +public class StandaloneActionMode extends ActionMode implements MenuBuilder.Callback { + private Context mContext; + private ActionBarContextView mContextView; + private ActionMode.Callback mCallback; + private WeakReference mCustomView; + private boolean mFinished; + private boolean mFocusable; + + private MenuBuilder mMenu; + + public StandaloneActionMode(Context context, ActionBarContextView view, + ActionMode.Callback callback, boolean isFocusable) { + mContext = context; + mContextView = view; + mCallback = callback; + + mMenu = new MenuBuilder(context).setDefaultShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); + mMenu.setCallback(this); + mFocusable = isFocusable; + } + + @Override + public void setTitle(CharSequence title) { + mContextView.setTitle(title); + } + + @Override + public void setSubtitle(CharSequence subtitle) { + mContextView.setSubtitle(subtitle); + } + + @Override + public void setTitle(int resId) { + setTitle(mContext.getString(resId)); + } + + @Override + public void setSubtitle(int resId) { + setSubtitle(mContext.getString(resId)); + } + + @Override + public void setCustomView(View view) { + mContextView.setCustomView(view); + mCustomView = view != null ? new WeakReference(view) : null; + } + + @Override + public void invalidate() { + mCallback.onPrepareActionMode(this, mMenu); + } + + @Override + public void finish() { + if (mFinished) { + return; + } + mFinished = true; + + mContextView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); + mCallback.onDestroyActionMode(this); + } + + @Override + public Menu getMenu() { + return mMenu; + } + + @Override + public CharSequence getTitle() { + return mContextView.getTitle(); + } + + @Override + public CharSequence getSubtitle() { + return mContextView.getSubtitle(); + } + + @Override + public View getCustomView() { + return mCustomView != null ? mCustomView.get() : null; + } + + @Override + public MenuInflater getMenuInflater() { + return new MenuInflater(mContext); + } + + public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) { + return mCallback.onActionItemClicked(this, item); + } + + public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) { + } + + public boolean onSubMenuSelected(SubMenuBuilder subMenu) { + if (!subMenu.hasVisibleItems()) { + return true; + } + + new MenuPopupHelper(mContext, subMenu).show(); + return true; + } + + public void onCloseSubMenu(SubMenuBuilder menu) { + } + + public void onMenuModeChange(MenuBuilder menu) { + invalidate(); + mContextView.showOverflowMenu(); + } + + public boolean isUiFocusable() { + return mFocusable; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/View_HasStateListenerSupport.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/View_HasStateListenerSupport.java new file mode 100644 index 000000000..7d45e81be --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/View_HasStateListenerSupport.java @@ -0,0 +1,6 @@ +package com.actionbarsherlock.internal.view; + +public interface View_HasStateListenerSupport { + void addOnAttachStateChangeListener(View_OnAttachStateChangeListener listener); + void removeOnAttachStateChangeListener(View_OnAttachStateChangeListener listener); +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/View_OnAttachStateChangeListener.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/View_OnAttachStateChangeListener.java new file mode 100644 index 000000000..3869d3290 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/View_OnAttachStateChangeListener.java @@ -0,0 +1,8 @@ +package com.actionbarsherlock.internal.view; + +import android.view.View; + +public interface View_OnAttachStateChangeListener { + void onViewAttachedToWindow(View v); + void onViewDetachedFromWindow(View v); +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenu.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenu.java new file mode 100644 index 000000000..0354ad1ad --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenu.java @@ -0,0 +1,264 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.view.menu; + +import java.util.ArrayList; +import java.util.List; + +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; +import android.view.KeyEvent; + +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuItem; +import com.actionbarsherlock.view.SubMenu; + +/** + * @hide + */ +public class ActionMenu implements Menu { + private Context mContext; + + private boolean mIsQwerty; + + private ArrayList mItems; + + public ActionMenu(Context context) { + mContext = context; + mItems = new ArrayList(); + } + + public Context getContext() { + return mContext; + } + + public MenuItem add(CharSequence title) { + return add(0, 0, 0, title); + } + + public MenuItem add(int titleRes) { + return add(0, 0, 0, titleRes); + } + + public MenuItem add(int groupId, int itemId, int order, int titleRes) { + return add(groupId, itemId, order, mContext.getResources().getString(titleRes)); + } + + public MenuItem add(int groupId, int itemId, int order, CharSequence title) { + ActionMenuItem item = new ActionMenuItem(getContext(), + groupId, itemId, 0, order, title); + mItems.add(order, item); + return item; + } + + public int addIntentOptions(int groupId, int itemId, int order, + ComponentName caller, Intent[] specifics, Intent intent, int flags, + MenuItem[] outSpecificItems) { + PackageManager pm = mContext.getPackageManager(); + final List lri = + pm.queryIntentActivityOptions(caller, specifics, intent, 0); + final int N = lri != null ? lri.size() : 0; + + if ((flags & FLAG_APPEND_TO_GROUP) == 0) { + removeGroup(groupId); + } + + for (int i=0; i= 0) { + outSpecificItems[ri.specificIndex] = item; + } + } + + return N; + } + + public SubMenu addSubMenu(CharSequence title) { + // TODO Implement submenus + return null; + } + + public SubMenu addSubMenu(int titleRes) { + // TODO Implement submenus + return null; + } + + public SubMenu addSubMenu(int groupId, int itemId, int order, + CharSequence title) { + // TODO Implement submenus + return null; + } + + public SubMenu addSubMenu(int groupId, int itemId, int order, int titleRes) { + // TODO Implement submenus + return null; + } + + public void clear() { + mItems.clear(); + } + + public void close() { + } + + private int findItemIndex(int id) { + final ArrayList items = mItems; + final int itemCount = items.size(); + for (int i = 0; i < itemCount; i++) { + if (items.get(i).getItemId() == id) { + return i; + } + } + + return -1; + } + + public MenuItem findItem(int id) { + return mItems.get(findItemIndex(id)); + } + + public MenuItem getItem(int index) { + return mItems.get(index); + } + + public boolean hasVisibleItems() { + final ArrayList items = mItems; + final int itemCount = items.size(); + + for (int i = 0; i < itemCount; i++) { + if (items.get(i).isVisible()) { + return true; + } + } + + return false; + } + + private ActionMenuItem findItemWithShortcut(int keyCode, KeyEvent event) { + // TODO Make this smarter. + final boolean qwerty = mIsQwerty; + final ArrayList items = mItems; + final int itemCount = items.size(); + + for (int i = 0; i < itemCount; i++) { + ActionMenuItem item = items.get(i); + final char shortcut = qwerty ? item.getAlphabeticShortcut() : + item.getNumericShortcut(); + if (keyCode == shortcut) { + return item; + } + } + return null; + } + + public boolean isShortcutKey(int keyCode, KeyEvent event) { + return findItemWithShortcut(keyCode, event) != null; + } + + public boolean performIdentifierAction(int id, int flags) { + final int index = findItemIndex(id); + if (index < 0) { + return false; + } + + return mItems.get(index).invoke(); + } + + public boolean performShortcut(int keyCode, KeyEvent event, int flags) { + ActionMenuItem item = findItemWithShortcut(keyCode, event); + if (item == null) { + return false; + } + + return item.invoke(); + } + + public void removeGroup(int groupId) { + final ArrayList items = mItems; + int itemCount = items.size(); + int i = 0; + while (i < itemCount) { + if (items.get(i).getGroupId() == groupId) { + items.remove(i); + itemCount--; + } else { + i++; + } + } + } + + public void removeItem(int id) { + mItems.remove(findItemIndex(id)); + } + + public void setGroupCheckable(int group, boolean checkable, + boolean exclusive) { + final ArrayList items = mItems; + final int itemCount = items.size(); + + for (int i = 0; i < itemCount; i++) { + ActionMenuItem item = items.get(i); + if (item.getGroupId() == group) { + item.setCheckable(checkable); + item.setExclusiveCheckable(exclusive); + } + } + } + + public void setGroupEnabled(int group, boolean enabled) { + final ArrayList items = mItems; + final int itemCount = items.size(); + + for (int i = 0; i < itemCount; i++) { + ActionMenuItem item = items.get(i); + if (item.getGroupId() == group) { + item.setEnabled(enabled); + } + } + } + + public void setGroupVisible(int group, boolean visible) { + final ArrayList items = mItems; + final int itemCount = items.size(); + + for (int i = 0; i < itemCount; i++) { + ActionMenuItem item = items.get(i); + if (item.getGroupId() == group) { + item.setVisible(visible); + } + } + } + + public void setQwertyMode(boolean isQwerty) { + mIsQwerty = isQwerty; + } + + public int size() { + return mItems.size(); + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuItem.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuItem.java new file mode 100644 index 000000000..510b97488 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuItem.java @@ -0,0 +1,278 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.view.menu; + +import android.content.Context; +import android.content.Intent; +import android.graphics.drawable.Drawable; +import android.view.ContextMenu.ContextMenuInfo; +import android.view.View; + +import com.actionbarsherlock.view.ActionProvider; +import com.actionbarsherlock.view.MenuItem; +import com.actionbarsherlock.view.SubMenu; + +/** + * @hide + */ +public class ActionMenuItem implements MenuItem { + private final int mId; + private final int mGroup; + //UNUSED private final int mCategoryOrder; + private final int mOrdering; + + private CharSequence mTitle; + private CharSequence mTitleCondensed; + private Intent mIntent; + private char mShortcutNumericChar; + private char mShortcutAlphabeticChar; + + private Drawable mIconDrawable; + //UNUSED private int mIconResId = NO_ICON; + + private Context mContext; + + private MenuItem.OnMenuItemClickListener mClickListener; + + //UNUSED private static final int NO_ICON = 0; + + private int mFlags = ENABLED; + private static final int CHECKABLE = 0x00000001; + private static final int CHECKED = 0x00000002; + private static final int EXCLUSIVE = 0x00000004; + private static final int HIDDEN = 0x00000008; + private static final int ENABLED = 0x00000010; + + public ActionMenuItem(Context context, int group, int id, int categoryOrder, int ordering, + CharSequence title) { + mContext = context; + mId = id; + mGroup = group; + //UNUSED mCategoryOrder = categoryOrder; + mOrdering = ordering; + mTitle = title; + } + + public char getAlphabeticShortcut() { + return mShortcutAlphabeticChar; + } + + public int getGroupId() { + return mGroup; + } + + public Drawable getIcon() { + return mIconDrawable; + } + + public Intent getIntent() { + return mIntent; + } + + public int getItemId() { + return mId; + } + + public ContextMenuInfo getMenuInfo() { + return null; + } + + public char getNumericShortcut() { + return mShortcutNumericChar; + } + + public int getOrder() { + return mOrdering; + } + + public SubMenu getSubMenu() { + return null; + } + + public CharSequence getTitle() { + return mTitle; + } + + public CharSequence getTitleCondensed() { + return mTitleCondensed; + } + + public boolean hasSubMenu() { + return false; + } + + public boolean isCheckable() { + return (mFlags & CHECKABLE) != 0; + } + + public boolean isChecked() { + return (mFlags & CHECKED) != 0; + } + + public boolean isEnabled() { + return (mFlags & ENABLED) != 0; + } + + public boolean isVisible() { + return (mFlags & HIDDEN) == 0; + } + + public MenuItem setAlphabeticShortcut(char alphaChar) { + mShortcutAlphabeticChar = alphaChar; + return this; + } + + public MenuItem setCheckable(boolean checkable) { + mFlags = (mFlags & ~CHECKABLE) | (checkable ? CHECKABLE : 0); + return this; + } + + public ActionMenuItem setExclusiveCheckable(boolean exclusive) { + mFlags = (mFlags & ~EXCLUSIVE) | (exclusive ? EXCLUSIVE : 0); + return this; + } + + public MenuItem setChecked(boolean checked) { + mFlags = (mFlags & ~CHECKED) | (checked ? CHECKED : 0); + return this; + } + + public MenuItem setEnabled(boolean enabled) { + mFlags = (mFlags & ~ENABLED) | (enabled ? ENABLED : 0); + return this; + } + + public MenuItem setIcon(Drawable icon) { + mIconDrawable = icon; + //UNUSED mIconResId = NO_ICON; + return this; + } + + public MenuItem setIcon(int iconRes) { + //UNUSED mIconResId = iconRes; + mIconDrawable = mContext.getResources().getDrawable(iconRes); + return this; + } + + public MenuItem setIntent(Intent intent) { + mIntent = intent; + return this; + } + + public MenuItem setNumericShortcut(char numericChar) { + mShortcutNumericChar = numericChar; + return this; + } + + public MenuItem setOnMenuItemClickListener(OnMenuItemClickListener menuItemClickListener) { + mClickListener = menuItemClickListener; + return this; + } + + public MenuItem setShortcut(char numericChar, char alphaChar) { + mShortcutNumericChar = numericChar; + mShortcutAlphabeticChar = alphaChar; + return this; + } + + public MenuItem setTitle(CharSequence title) { + mTitle = title; + return this; + } + + public MenuItem setTitle(int title) { + mTitle = mContext.getResources().getString(title); + return this; + } + + public MenuItem setTitleCondensed(CharSequence title) { + mTitleCondensed = title; + return this; + } + + public MenuItem setVisible(boolean visible) { + mFlags = (mFlags & HIDDEN) | (visible ? 0 : HIDDEN); + return this; + } + + public boolean invoke() { + if (mClickListener != null && mClickListener.onMenuItemClick(this)) { + return true; + } + + if (mIntent != null) { + mContext.startActivity(mIntent); + return true; + } + + return false; + } + + public void setShowAsAction(int show) { + // Do nothing. ActionMenuItems always show as action buttons. + } + + public MenuItem setActionView(View actionView) { + throw new UnsupportedOperationException(); + } + + public View getActionView() { + return null; + } + + @Override + public MenuItem setActionView(int resId) { + throw new UnsupportedOperationException(); + } + + @Override + public ActionProvider getActionProvider() { + return null; + } + + @Override + public MenuItem setActionProvider(ActionProvider actionProvider) { + throw new UnsupportedOperationException(); + } + + @Override + public MenuItem setShowAsActionFlags(int actionEnum) { + setShowAsAction(actionEnum); + return this; + } + + @Override + public boolean expandActionView() { + return false; + } + + @Override + public boolean collapseActionView() { + return false; + } + + @Override + public boolean isActionViewExpanded() { + return false; + } + + @Override + public MenuItem setOnActionExpandListener(OnActionExpandListener listener) { + // No need to save the listener; ActionMenuItem does not support collapsing items. + return this; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuItemView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuItemView.java new file mode 100644 index 000000000..dcb50f362 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuItemView.java @@ -0,0 +1,295 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.view.menu; + +import java.util.HashSet; +import java.util.Set; +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.Rect; +import android.graphics.drawable.Drawable; +import android.os.Build; +import android.text.TextUtils; +import android.util.AttributeSet; +import android.view.Gravity; +import android.view.MotionEvent; +import android.view.View; +import android.view.accessibility.AccessibilityEvent; +import android.widget.ImageButton; +import android.widget.LinearLayout; +import android.widget.Toast; + +import com.actionbarsherlock.R; +import com.actionbarsherlock.internal.view.View_HasStateListenerSupport; +import com.actionbarsherlock.internal.view.View_OnAttachStateChangeListener; +import com.actionbarsherlock.internal.widget.CapitalizingButton; + +import static com.actionbarsherlock.internal.ResourcesCompat.getResources_getBoolean; + +/** + * @hide + */ +public class ActionMenuItemView extends LinearLayout + implements MenuView.ItemView, View.OnClickListener, View.OnLongClickListener, + ActionMenuView.ActionMenuChildView, View_HasStateListenerSupport { + //UNUSED private static final String TAG = "ActionMenuItemView"; + + private MenuItemImpl mItemData; + private CharSequence mTitle; + private MenuBuilder.ItemInvoker mItemInvoker; + + private ImageButton mImageButton; + private CapitalizingButton mTextButton; + private boolean mAllowTextWithIcon; + private boolean mExpandedFormat; + private int mMinWidth; + + private final Set mListeners = new HashSet(); + + public ActionMenuItemView(Context context) { + this(context, null); + } + + public ActionMenuItemView(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public ActionMenuItemView(Context context, AttributeSet attrs, int defStyle) { + //TODO super(context, attrs, defStyle); + super(context, attrs); + mAllowTextWithIcon = getResources_getBoolean(context, + R.bool.abs__config_allowActionMenuItemTextWithIcon); + TypedArray a = context.obtainStyledAttributes(attrs, + R.styleable.SherlockActionMenuItemView, 0, 0); + mMinWidth = a.getDimensionPixelSize( + R.styleable.SherlockActionMenuItemView_android_minWidth, 0); + a.recycle(); + } + + @Override + public void addOnAttachStateChangeListener(View_OnAttachStateChangeListener listener) { + mListeners.add(listener); + } + + @Override + public void removeOnAttachStateChangeListener(View_OnAttachStateChangeListener listener) { + mListeners.remove(listener); + } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + for (View_OnAttachStateChangeListener listener : mListeners) { + listener.onViewAttachedToWindow(this); + } + } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + for (View_OnAttachStateChangeListener listener : mListeners) { + listener.onViewDetachedFromWindow(this); + } + } + + @Override + public void onFinishInflate() { + + mImageButton = (ImageButton) findViewById(R.id.abs__imageButton); + mTextButton = (CapitalizingButton) findViewById(R.id.abs__textButton); + mImageButton.setOnClickListener(this); + mTextButton.setOnClickListener(this); + mImageButton.setOnLongClickListener(this); + setOnClickListener(this); + setOnLongClickListener(this); + } + + public MenuItemImpl getItemData() { + return mItemData; + } + + public void initialize(MenuItemImpl itemData, int menuType) { + mItemData = itemData; + + setIcon(itemData.getIcon()); + setTitle(itemData.getTitleForItemView(this)); // Title only takes effect if there is no icon + setId(itemData.getItemId()); + + setVisibility(itemData.isVisible() ? View.VISIBLE : View.GONE); + setEnabled(itemData.isEnabled()); + } + + @Override + public void setEnabled(boolean enabled) { + super.setEnabled(enabled); + mImageButton.setEnabled(enabled); + mTextButton.setEnabled(enabled); + } + + public void onClick(View v) { + if (mItemInvoker != null) { + mItemInvoker.invokeItem(mItemData); + } + } + + public void setItemInvoker(MenuBuilder.ItemInvoker invoker) { + mItemInvoker = invoker; + } + + public boolean prefersCondensedTitle() { + return true; + } + + public void setCheckable(boolean checkable) { + // TODO Support checkable action items + } + + public void setChecked(boolean checked) { + // TODO Support checkable action items + } + + public void setExpandedFormat(boolean expandedFormat) { + if (mExpandedFormat != expandedFormat) { + mExpandedFormat = expandedFormat; + if (mItemData != null) { + mItemData.actionFormatChanged(); + } + } + } + + private void updateTextButtonVisibility() { + boolean visible = !TextUtils.isEmpty(mTextButton.getText()); + visible &= mImageButton.getDrawable() == null || + (mItemData.showsTextAsAction() && (mAllowTextWithIcon || mExpandedFormat)); + + mTextButton.setVisibility(visible ? VISIBLE : GONE); + } + + public void setIcon(Drawable icon) { + mImageButton.setImageDrawable(icon); + if (icon != null) { + mImageButton.setVisibility(VISIBLE); + } else { + mImageButton.setVisibility(GONE); + } + + updateTextButtonVisibility(); + } + + public boolean hasText() { + return mTextButton.getVisibility() != GONE; + } + + public void setShortcut(boolean showShortcut, char shortcutKey) { + // Action buttons don't show text for shortcut keys. + } + + public void setTitle(CharSequence title) { + mTitle = title; + + mTextButton.setTextCompat(mTitle); + + setContentDescription(mTitle); + updateTextButtonVisibility(); + } + + @Override + public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { + onPopulateAccessibilityEvent(event); + return true; + } + + @Override + public void onPopulateAccessibilityEvent(AccessibilityEvent event) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { + super.onPopulateAccessibilityEvent(event); + } + final CharSequence cdesc = getContentDescription(); + if (!TextUtils.isEmpty(cdesc)) { + event.getText().add(cdesc); + } + } + + @Override + public boolean dispatchHoverEvent(MotionEvent event) { + // Don't allow children to hover; we want this to be treated as a single component. + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { + return onHoverEvent(event); + } + return false; + } + + public boolean showsIcon() { + return true; + } + + public boolean needsDividerBefore() { + return hasText() && mItemData.getIcon() == null; + } + + public boolean needsDividerAfter() { + return hasText(); + } + + @Override + public boolean onLongClick(View v) { + if (hasText()) { + // Don't show the cheat sheet for items that already show text. + return false; + } + + final int[] screenPos = new int[2]; + final Rect displayFrame = new Rect(); + getLocationOnScreen(screenPos); + getWindowVisibleDisplayFrame(displayFrame); + + final Context context = getContext(); + final int width = getWidth(); + final int height = getHeight(); + final int midy = screenPos[1] + height / 2; + final int screenWidth = context.getResources().getDisplayMetrics().widthPixels; + + Toast cheatSheet = Toast.makeText(context, mItemData.getTitle(), Toast.LENGTH_SHORT); + if (midy < displayFrame.height()) { + // Show along the top; follow action buttons + cheatSheet.setGravity(Gravity.TOP | Gravity.RIGHT, + screenWidth - screenPos[0] - width / 2, height); + } else { + // Show along the bottom center + cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, height); + } + cheatSheet.show(); + return true; + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + + final int widthMode = MeasureSpec.getMode(widthMeasureSpec); + final int specSize = MeasureSpec.getSize(widthMeasureSpec); + final int oldMeasuredWidth = getMeasuredWidth(); + final int targetWidth = widthMode == MeasureSpec.AT_MOST ? Math.min(specSize, mMinWidth) + : mMinWidth; + + if (widthMode != MeasureSpec.EXACTLY && mMinWidth > 0 && oldMeasuredWidth < targetWidth) { + // Remeasure at exactly the minimum width. + super.onMeasure(MeasureSpec.makeMeasureSpec(targetWidth, MeasureSpec.EXACTLY), + heightMeasureSpec); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuPresenter.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuPresenter.java new file mode 100644 index 000000000..6f568c698 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuPresenter.java @@ -0,0 +1,721 @@ +/* + * Copyright (C) 2011 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.actionbarsherlock.internal.view.menu; + +import static com.actionbarsherlock.internal.ResourcesCompat.getResources_getInteger; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; +import android.content.Context; +import android.content.res.Configuration; +import android.content.res.Resources; +import android.content.res.TypedArray; +import android.os.Build; +import android.os.Parcel; +import android.os.Parcelable; +import android.util.SparseBooleanArray; +import android.view.SoundEffectConstants; +import android.view.View; +import android.view.View.MeasureSpec; +import android.view.ViewConfiguration; +import android.view.ViewGroup; +import android.widget.ImageButton; +import com.actionbarsherlock.R; +import com.actionbarsherlock.internal.view.View_HasStateListenerSupport; +import com.actionbarsherlock.internal.view.View_OnAttachStateChangeListener; +import com.actionbarsherlock.internal.view.menu.ActionMenuView.ActionMenuChildView; +import com.actionbarsherlock.view.ActionProvider; +import com.actionbarsherlock.view.MenuItem; + +/** + * MenuPresenter for building action menus as seen in the action bar and action modes. + */ +public class ActionMenuPresenter extends BaseMenuPresenter + implements ActionProvider.SubUiVisibilityListener { + //UNUSED private static final String TAG = "ActionMenuPresenter"; + + private View mOverflowButton; + private boolean mReserveOverflow; + private boolean mReserveOverflowSet; + private int mWidthLimit; + private int mActionItemWidthLimit; + private int mMaxItems; + private boolean mMaxItemsSet; + private boolean mStrictWidthLimit; + private boolean mWidthLimitSet; + private boolean mExpandedActionViewsExclusive; + + private int mMinCellSize; + + // Group IDs that have been added as actions - used temporarily, allocated here for reuse. + private final SparseBooleanArray mActionButtonGroups = new SparseBooleanArray(); + + private View mScrapActionButtonView; + + private OverflowPopup mOverflowPopup; + private ActionButtonSubmenu mActionButtonPopup; + + private OpenOverflowRunnable mPostedOpenRunnable; + + final PopupPresenterCallback mPopupPresenterCallback = new PopupPresenterCallback(); + int mOpenSubMenuId; + + public ActionMenuPresenter(Context context) { + super(context, R.layout.abs__action_menu_layout, + R.layout.abs__action_menu_item_layout); + } + + @Override + public void initForMenu(Context context, MenuBuilder menu) { + super.initForMenu(context, menu); + + final Resources res = context.getResources(); + + if (!mReserveOverflowSet) { + mReserveOverflow = reserveOverflow(mContext); + } + + if (!mWidthLimitSet) { + mWidthLimit = res.getDisplayMetrics().widthPixels / 2; + } + + // Measure for initial configuration + if (!mMaxItemsSet) { + mMaxItems = getResources_getInteger(context, R.integer.abs__max_action_buttons); + } + + int width = mWidthLimit; + if (mReserveOverflow) { + if (mOverflowButton == null) { + mOverflowButton = new OverflowMenuButton(mSystemContext); + final int spec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); + mOverflowButton.measure(spec, spec); + } + width -= mOverflowButton.getMeasuredWidth(); + } else { + mOverflowButton = null; + } + + mActionItemWidthLimit = width; + + mMinCellSize = (int) (ActionMenuView.MIN_CELL_SIZE * res.getDisplayMetrics().density); + + // Drop a scrap view as it may no longer reflect the proper context/config. + mScrapActionButtonView = null; + } + + public static boolean reserveOverflow(Context context) { + //Check for theme-forced overflow action item + TypedArray a = context.getTheme().obtainStyledAttributes(R.styleable.SherlockTheme); + boolean result = a.getBoolean(R.styleable.SherlockTheme_absForceOverflow, false); + a.recycle(); + if (result) { + return true; + } + + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { + return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB); + } else { + return !HasPermanentMenuKey.get(context); + } + } + + private static class HasPermanentMenuKey { + public static boolean get(Context context) { + return ViewConfiguration.get(context).hasPermanentMenuKey(); + } + } + + public void onConfigurationChanged(Configuration newConfig) { + if (!mMaxItemsSet) { + mMaxItems = getResources_getInteger(mContext, + R.integer.abs__max_action_buttons); + if (mMenu != null) { + mMenu.onItemsChanged(true); + } + } + } + + public void setWidthLimit(int width, boolean strict) { + mWidthLimit = width; + mStrictWidthLimit = strict; + mWidthLimitSet = true; + } + + public void setReserveOverflow(boolean reserveOverflow) { + mReserveOverflow = reserveOverflow; + mReserveOverflowSet = true; + } + + public void setItemLimit(int itemCount) { + mMaxItems = itemCount; + mMaxItemsSet = true; + } + + public void setExpandedActionViewsExclusive(boolean isExclusive) { + mExpandedActionViewsExclusive = isExclusive; + } + + @Override + public MenuView getMenuView(ViewGroup root) { + MenuView result = super.getMenuView(root); + ((ActionMenuView) result).setPresenter(this); + return result; + } + + @Override + public View getItemView(MenuItemImpl item, View convertView, ViewGroup parent) { + View actionView = item.getActionView(); + if (actionView == null || item.hasCollapsibleActionView()) { + if (!(convertView instanceof ActionMenuItemView)) { + convertView = null; + } + actionView = super.getItemView(item, convertView, parent); + } + actionView.setVisibility(item.isActionViewExpanded() ? View.GONE : View.VISIBLE); + + final ActionMenuView menuParent = (ActionMenuView) parent; + final ViewGroup.LayoutParams lp = actionView.getLayoutParams(); + if (!menuParent.checkLayoutParams(lp)) { + actionView.setLayoutParams(menuParent.generateLayoutParams(lp)); + } + return actionView; + } + + @Override + public void bindItemView(MenuItemImpl item, MenuView.ItemView itemView) { + itemView.initialize(item, 0); + + final ActionMenuView menuView = (ActionMenuView) mMenuView; + ActionMenuItemView actionItemView = (ActionMenuItemView) itemView; + actionItemView.setItemInvoker(menuView); + } + + @Override + public boolean shouldIncludeItem(int childIndex, MenuItemImpl item) { + return item.isActionButton(); + } + + @Override + public void updateMenuView(boolean cleared) { + super.updateMenuView(cleared); + + if (mMenu != null) { + final ArrayList actionItems = mMenu.getActionItems(); + final int count = actionItems.size(); + for (int i = 0; i < count; i++) { + final ActionProvider provider = actionItems.get(i).getActionProvider(); + if (provider != null) { + provider.setSubUiVisibilityListener(this); + } + } + } + + final ArrayList nonActionItems = mMenu != null ? + mMenu.getNonActionItems() : null; + + boolean hasOverflow = false; + if (mReserveOverflow && nonActionItems != null) { + final int count = nonActionItems.size(); + if (count == 1) { + hasOverflow = !nonActionItems.get(0).isActionViewExpanded(); + } else { + hasOverflow = count > 0; + } + } + + if (hasOverflow) { + if (mOverflowButton == null) { + mOverflowButton = new OverflowMenuButton(mSystemContext); + } + ViewGroup parent = (ViewGroup) mOverflowButton.getParent(); + if (parent != mMenuView) { + if (parent != null) { + parent.removeView(mOverflowButton); + } + ActionMenuView menuView = (ActionMenuView) mMenuView; + menuView.addView(mOverflowButton, menuView.generateOverflowButtonLayoutParams()); + } + } else if (mOverflowButton != null && mOverflowButton.getParent() == mMenuView) { + ((ViewGroup) mMenuView).removeView(mOverflowButton); + } + + ((ActionMenuView) mMenuView).setOverflowReserved(mReserveOverflow); + } + + @Override + public boolean filterLeftoverView(ViewGroup parent, int childIndex) { + if (parent.getChildAt(childIndex) == mOverflowButton) return false; + return super.filterLeftoverView(parent, childIndex); + } + + public boolean onSubMenuSelected(SubMenuBuilder subMenu) { + if (!subMenu.hasVisibleItems()) return false; + + SubMenuBuilder topSubMenu = subMenu; + while (topSubMenu.getParentMenu() != mMenu) { + topSubMenu = (SubMenuBuilder) topSubMenu.getParentMenu(); + } + View anchor = findViewForItem(topSubMenu.getItem()); + if (anchor == null) { + if (mOverflowButton == null) return false; + anchor = mOverflowButton; + } + + mOpenSubMenuId = subMenu.getItem().getItemId(); + mActionButtonPopup = new ActionButtonSubmenu(mContext, subMenu); + mActionButtonPopup.setAnchorView(anchor); + mActionButtonPopup.show(); + super.onSubMenuSelected(subMenu); + return true; + } + + private View findViewForItem(MenuItem item) { + final ViewGroup parent = (ViewGroup) mMenuView; + if (parent == null) return null; + + final int count = parent.getChildCount(); + for (int i = 0; i < count; i++) { + final View child = parent.getChildAt(i); + if (child instanceof MenuView.ItemView && + ((MenuView.ItemView) child).getItemData() == item) { + return child; + } + } + return null; + } + + /** + * Display the overflow menu if one is present. + * @return true if the overflow menu was shown, false otherwise. + */ + public boolean showOverflowMenu() { + if (mReserveOverflow && !isOverflowMenuShowing() && mMenu != null && mMenuView != null && + mPostedOpenRunnable == null && !mMenu.getNonActionItems().isEmpty()) { + OverflowPopup popup = new OverflowPopup(mContext, mMenu, mOverflowButton, true); + mPostedOpenRunnable = new OpenOverflowRunnable(popup); + // Post this for later; we might still need a layout for the anchor to be right. + ((View) mMenuView).post(mPostedOpenRunnable); + + // ActionMenuPresenter uses null as a callback argument here + // to indicate overflow is opening. + super.onSubMenuSelected(null); + + return true; + } + return false; + } + + /** + * Hide the overflow menu if it is currently showing. + * + * @return true if the overflow menu was hidden, false otherwise. + */ + public boolean hideOverflowMenu() { + if (mPostedOpenRunnable != null && mMenuView != null) { + ((View) mMenuView).removeCallbacks(mPostedOpenRunnable); + mPostedOpenRunnable = null; + return true; + } + + MenuPopupHelper popup = mOverflowPopup; + if (popup != null) { + popup.dismiss(); + return true; + } + return false; + } + + /** + * Dismiss all popup menus - overflow and submenus. + * @return true if popups were dismissed, false otherwise. (This can be because none were open.) + */ + public boolean dismissPopupMenus() { + boolean result = hideOverflowMenu(); + result |= hideSubMenus(); + return result; + } + + /** + * Dismiss all submenu popups. + * + * @return true if popups were dismissed, false otherwise. (This can be because none were open.) + */ + public boolean hideSubMenus() { + if (mActionButtonPopup != null) { + mActionButtonPopup.dismiss(); + return true; + } + return false; + } + + /** + * @return true if the overflow menu is currently showing + */ + public boolean isOverflowMenuShowing() { + return mOverflowPopup != null && mOverflowPopup.isShowing(); + } + + /** + * @return true if space has been reserved in the action menu for an overflow item. + */ + public boolean isOverflowReserved() { + return mReserveOverflow; + } + + public boolean flagActionItems() { + final ArrayList visibleItems = mMenu.getVisibleItems(); + final int itemsSize = visibleItems.size(); + int maxActions = mMaxItems; + int widthLimit = mActionItemWidthLimit; + final int querySpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); + final ViewGroup parent = (ViewGroup) mMenuView; + + int requiredItems = 0; + int requestedItems = 0; + int firstActionWidth = 0; + boolean hasOverflow = false; + for (int i = 0; i < itemsSize; i++) { + MenuItemImpl item = visibleItems.get(i); + if (item.requiresActionButton()) { + requiredItems++; + } else if (item.requestsActionButton()) { + requestedItems++; + } else { + hasOverflow = true; + } + if (mExpandedActionViewsExclusive && item.isActionViewExpanded()) { + // Overflow everything if we have an expanded action view and we're + // space constrained. + maxActions = 0; + } + } + + // Reserve a spot for the overflow item if needed. + if (mReserveOverflow && + (hasOverflow || requiredItems + requestedItems > maxActions)) { + maxActions--; + } + maxActions -= requiredItems; + + final SparseBooleanArray seenGroups = mActionButtonGroups; + seenGroups.clear(); + + int cellSize = 0; + int cellsRemaining = 0; + if (mStrictWidthLimit) { + cellsRemaining = widthLimit / mMinCellSize; + final int cellSizeRemaining = widthLimit % mMinCellSize; + cellSize = mMinCellSize + cellSizeRemaining / cellsRemaining; + } + + // Flag as many more requested items as will fit. + for (int i = 0; i < itemsSize; i++) { + MenuItemImpl item = visibleItems.get(i); + + if (item.requiresActionButton()) { + View v = getItemView(item, mScrapActionButtonView, parent); + if (mScrapActionButtonView == null) { + mScrapActionButtonView = v; + } + if (mStrictWidthLimit) { + cellsRemaining -= ActionMenuView.measureChildForCells(v, + cellSize, cellsRemaining, querySpec, 0); + } else { + v.measure(querySpec, querySpec); + } + final int measuredWidth = v.getMeasuredWidth(); + widthLimit -= measuredWidth; + if (firstActionWidth == 0) { + firstActionWidth = measuredWidth; + } + final int groupId = item.getGroupId(); + if (groupId != 0) { + seenGroups.put(groupId, true); + } + item.setIsActionButton(true); + } else if (item.requestsActionButton()) { + // Items in a group with other items that already have an action slot + // can break the max actions rule, but not the width limit. + final int groupId = item.getGroupId(); + final boolean inGroup = seenGroups.get(groupId); + boolean isAction = (maxActions > 0 || inGroup) && widthLimit > 0 && + (!mStrictWidthLimit || cellsRemaining > 0); + + if (isAction) { + View v = getItemView(item, mScrapActionButtonView, parent); + if (mScrapActionButtonView == null) { + mScrapActionButtonView = v; + } + if (mStrictWidthLimit) { + final int cells = ActionMenuView.measureChildForCells(v, + cellSize, cellsRemaining, querySpec, 0); + cellsRemaining -= cells; + if (cells == 0) { + isAction = false; + } + } else { + v.measure(querySpec, querySpec); + } + final int measuredWidth = v.getMeasuredWidth(); + widthLimit -= measuredWidth; + if (firstActionWidth == 0) { + firstActionWidth = measuredWidth; + } + + if (mStrictWidthLimit) { + isAction &= widthLimit >= 0; + } else { + // Did this push the entire first item past the limit? + isAction &= widthLimit + firstActionWidth > 0; + } + } + + if (isAction && groupId != 0) { + seenGroups.put(groupId, true); + } else if (inGroup) { + // We broke the width limit. Demote the whole group, they all overflow now. + seenGroups.put(groupId, false); + for (int j = 0; j < i; j++) { + MenuItemImpl areYouMyGroupie = visibleItems.get(j); + if (areYouMyGroupie.getGroupId() == groupId) { + // Give back the action slot + if (areYouMyGroupie.isActionButton()) maxActions++; + areYouMyGroupie.setIsActionButton(false); + } + } + } + + if (isAction) maxActions--; + + item.setIsActionButton(isAction); + } + } + return true; + } + + @Override + public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) { + dismissPopupMenus(); + super.onCloseMenu(menu, allMenusAreClosing); + } + + @Override + public Parcelable onSaveInstanceState() { + SavedState state = new SavedState(); + state.openSubMenuId = mOpenSubMenuId; + return state; + } + + @Override + public void onRestoreInstanceState(Parcelable state) { + SavedState saved = (SavedState) state; + if (saved.openSubMenuId > 0) { + MenuItem item = mMenu.findItem(saved.openSubMenuId); + if (item != null) { + SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu(); + onSubMenuSelected(subMenu); + } + } + } + + @Override + public void onSubUiVisibilityChanged(boolean isVisible) { + if (isVisible) { + // Not a submenu, but treat it like one. + super.onSubMenuSelected(null); + } else { + mMenu.close(false); + } + } + + private static class SavedState implements Parcelable { + public int openSubMenuId; + + SavedState() { + } + + SavedState(Parcel in) { + openSubMenuId = in.readInt(); + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeInt(openSubMenuId); + } + + @SuppressWarnings("unused") + public static final Parcelable.Creator CREATOR + = new Parcelable.Creator() { + public SavedState createFromParcel(Parcel in) { + return new SavedState(in); + } + + public SavedState[] newArray(int size) { + return new SavedState[size]; + } + }; + } + + private class OverflowMenuButton extends ImageButton implements ActionMenuChildView, View_HasStateListenerSupport { + private final Set mListeners = new HashSet(); + + public OverflowMenuButton(Context context) { + super(context, null, R.attr.actionOverflowButtonStyle); + + setClickable(true); + setFocusable(true); + setVisibility(VISIBLE); + setEnabled(true); + } + + @Override + public boolean performClick() { + if (super.performClick()) { + return true; + } + + playSoundEffect(SoundEffectConstants.CLICK); + showOverflowMenu(); + return true; + } + + public boolean needsDividerBefore() { + return false; + } + + public boolean needsDividerAfter() { + return false; + } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + for (View_OnAttachStateChangeListener listener : mListeners) { + listener.onViewAttachedToWindow(this); + } + } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + for (View_OnAttachStateChangeListener listener : mListeners) { + listener.onViewDetachedFromWindow(this); + } + } + + @Override + public void addOnAttachStateChangeListener(View_OnAttachStateChangeListener listener) { + mListeners.add(listener); + } + + @Override + public void removeOnAttachStateChangeListener(View_OnAttachStateChangeListener listener) { + mListeners.remove(listener); + } + } + + private class OverflowPopup extends MenuPopupHelper { + public OverflowPopup(Context context, MenuBuilder menu, View anchorView, + boolean overflowOnly) { + super(context, menu, anchorView, overflowOnly); + setCallback(mPopupPresenterCallback); + } + + @Override + public void onDismiss() { + super.onDismiss(); + mMenu.close(); + mOverflowPopup = null; + } + } + + private class ActionButtonSubmenu extends MenuPopupHelper { + //UNUSED private SubMenuBuilder mSubMenu; + + public ActionButtonSubmenu(Context context, SubMenuBuilder subMenu) { + super(context, subMenu); + //UNUSED mSubMenu = subMenu; + + MenuItemImpl item = (MenuItemImpl) subMenu.getItem(); + if (!item.isActionButton()) { + // Give a reasonable anchor to nested submenus. + setAnchorView(mOverflowButton == null ? (View) mMenuView : mOverflowButton); + } + + setCallback(mPopupPresenterCallback); + + boolean preserveIconSpacing = false; + final int count = subMenu.size(); + for (int i = 0; i < count; i++) { + MenuItem childItem = subMenu.getItem(i); + if (childItem.isVisible() && childItem.getIcon() != null) { + preserveIconSpacing = true; + break; + } + } + setForceShowIcon(preserveIconSpacing); + } + + @Override + public void onDismiss() { + super.onDismiss(); + mActionButtonPopup = null; + mOpenSubMenuId = 0; + } + } + + private class PopupPresenterCallback implements MenuPresenter.Callback { + + @Override + public boolean onOpenSubMenu(MenuBuilder subMenu) { + if (subMenu == null) return false; + + mOpenSubMenuId = ((SubMenuBuilder) subMenu).getItem().getItemId(); + return false; + } + + @Override + public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) { + if (menu instanceof SubMenuBuilder) { + ((SubMenuBuilder) menu).getRootMenu().close(false); + } + } + } + + private class OpenOverflowRunnable implements Runnable { + private OverflowPopup mPopup; + + public OpenOverflowRunnable(OverflowPopup popup) { + mPopup = popup; + } + + public void run() { + mMenu.changeMenuMode(); + final View menuView = (View) mMenuView; + if (menuView != null && menuView.getWindowToken() != null && mPopup.tryShow()) { + mOverflowPopup = mPopup; + } + mPostedOpenRunnable = null; + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuView.java new file mode 100644 index 000000000..e090677a1 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuView.java @@ -0,0 +1,572 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.view.menu; + +import android.content.Context; +import android.content.res.Configuration; +import android.graphics.Canvas; +import android.os.Build; +import android.util.AttributeSet; +import android.view.Gravity; +import android.view.View; +import android.view.ViewGroup; +import android.view.accessibility.AccessibilityEvent; +import android.widget.LinearLayout; +import com.actionbarsherlock.internal.widget.IcsLinearLayout; + +/** + * @hide + */ +public class ActionMenuView extends IcsLinearLayout implements MenuBuilder.ItemInvoker, MenuView { + //UNUSED private static final String TAG = "ActionMenuView"; + private static final boolean IS_FROYO = Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO; + + static final int MIN_CELL_SIZE = 56; // dips + static final int GENERATED_ITEM_PADDING = 4; // dips + + private MenuBuilder mMenu; + + private boolean mReserveOverflow; + private ActionMenuPresenter mPresenter; + private boolean mFormatItems; + private int mFormatItemsWidth; + private int mMinCellSize; + private int mGeneratedItemPadding; + //UNUSED private int mMeasuredExtraWidth; + + private boolean mFirst = true; + + public ActionMenuView(Context context) { + this(context, null); + } + + public ActionMenuView(Context context, AttributeSet attrs) { + super(context, attrs); + setBaselineAligned(false); + final float density = context.getResources().getDisplayMetrics().density; + mMinCellSize = (int) (MIN_CELL_SIZE * density); + mGeneratedItemPadding = (int) (GENERATED_ITEM_PADDING * density); + } + + public void setPresenter(ActionMenuPresenter presenter) { + mPresenter = presenter; + } + + public boolean isExpandedFormat() { + return mFormatItems; + } + + @Override + public void onConfigurationChanged(Configuration newConfig) { + if (IS_FROYO) { + super.onConfigurationChanged(newConfig); + } + mPresenter.updateMenuView(false); + + if (mPresenter != null && mPresenter.isOverflowMenuShowing()) { + mPresenter.hideOverflowMenu(); + mPresenter.showOverflowMenu(); + } + } + + @Override + protected void onDraw(Canvas canvas) { + //Need to trigger a relayout since we may have been added extremely + //late in the initial rendering (e.g., when contained in a ViewPager). + //See: https://github.com/JakeWharton/ActionBarSherlock/issues/272 + if (!IS_FROYO && mFirst) { + mFirst = false; + requestLayout(); + return; + } + super.onDraw(canvas); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + // If we've been given an exact size to match, apply special formatting during layout. + final boolean wasFormatted = mFormatItems; + mFormatItems = MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.EXACTLY; + + if (wasFormatted != mFormatItems) { + mFormatItemsWidth = 0; // Reset this when switching modes + } + + // Special formatting can change whether items can fit as action buttons. + // Kick the menu and update presenters when this changes. + final int widthSize = MeasureSpec.getMode(widthMeasureSpec); + if (mFormatItems && mMenu != null && widthSize != mFormatItemsWidth) { + mFormatItemsWidth = widthSize; + mMenu.onItemsChanged(true); + } + + if (mFormatItems) { + onMeasureExactFormat(widthMeasureSpec, heightMeasureSpec); + } else { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + } + } + + private void onMeasureExactFormat(int widthMeasureSpec, int heightMeasureSpec) { + // We already know the width mode is EXACTLY if we're here. + final int heightMode = MeasureSpec.getMode(heightMeasureSpec); + int widthSize = MeasureSpec.getSize(widthMeasureSpec); + int heightSize = MeasureSpec.getSize(heightMeasureSpec); + + final int widthPadding = getPaddingLeft() + getPaddingRight(); + final int heightPadding = getPaddingTop() + getPaddingBottom(); + + widthSize -= widthPadding; + + // Divide the view into cells. + final int cellCount = widthSize / mMinCellSize; + final int cellSizeRemaining = widthSize % mMinCellSize; + + if (cellCount == 0) { + // Give up, nothing fits. + setMeasuredDimension(widthSize, 0); + return; + } + + final int cellSize = mMinCellSize + cellSizeRemaining / cellCount; + + int cellsRemaining = cellCount; + int maxChildHeight = 0; + int maxCellsUsed = 0; + int expandableItemCount = 0; + int visibleItemCount = 0; + boolean hasOverflow = false; + + // This is used as a bitfield to locate the smallest items present. Assumes childCount < 64. + long smallestItemsAt = 0; + + final int childCount = getChildCount(); + for (int i = 0; i < childCount; i++) { + final View child = getChildAt(i); + if (child.getVisibility() == GONE) continue; + + final boolean isGeneratedItem = child instanceof ActionMenuItemView; + visibleItemCount++; + + if (isGeneratedItem) { + // Reset padding for generated menu item views; it may change below + // and views are recycled. + child.setPadding(mGeneratedItemPadding, 0, mGeneratedItemPadding, 0); + } + + final LayoutParams lp = (LayoutParams) child.getLayoutParams(); + lp.expanded = false; + lp.extraPixels = 0; + lp.cellsUsed = 0; + lp.expandable = false; + lp.leftMargin = 0; + lp.rightMargin = 0; + lp.preventEdgeOffset = isGeneratedItem && ((ActionMenuItemView) child).hasText(); + + // Overflow always gets 1 cell. No more, no less. + final int cellsAvailable = lp.isOverflowButton ? 1 : cellsRemaining; + + final int cellsUsed = measureChildForCells(child, cellSize, cellsAvailable, + heightMeasureSpec, heightPadding); + + maxCellsUsed = Math.max(maxCellsUsed, cellsUsed); + if (lp.expandable) expandableItemCount++; + if (lp.isOverflowButton) hasOverflow = true; + + cellsRemaining -= cellsUsed; + maxChildHeight = Math.max(maxChildHeight, child.getMeasuredHeight()); + if (cellsUsed == 1) smallestItemsAt |= (1 << i); + } + + // When we have overflow and a single expanded (text) item, we want to try centering it + // visually in the available space even though overflow consumes some of it. + final boolean centerSingleExpandedItem = hasOverflow && visibleItemCount == 2; + + // Divide space for remaining cells if we have items that can expand. + // Try distributing whole leftover cells to smaller items first. + + boolean needsExpansion = false; + while (expandableItemCount > 0 && cellsRemaining > 0) { + int minCells = Integer.MAX_VALUE; + long minCellsAt = 0; // Bit locations are indices of relevant child views + int minCellsItemCount = 0; + for (int i = 0; i < childCount; i++) { + final View child = getChildAt(i); + final LayoutParams lp = (LayoutParams) child.getLayoutParams(); + + // Don't try to expand items that shouldn't. + if (!lp.expandable) continue; + + // Mark indices of children that can receive an extra cell. + if (lp.cellsUsed < minCells) { + minCells = lp.cellsUsed; + minCellsAt = 1 << i; + minCellsItemCount = 1; + } else if (lp.cellsUsed == minCells) { + minCellsAt |= 1 << i; + minCellsItemCount++; + } + } + + // Items that get expanded will always be in the set of smallest items when we're done. + smallestItemsAt |= minCellsAt; + + if (minCellsItemCount > cellsRemaining) break; // Couldn't expand anything evenly. Stop. + + // We have enough cells, all minimum size items will be incremented. + minCells++; + + for (int i = 0; i < childCount; i++) { + final View child = getChildAt(i); + final LayoutParams lp = (LayoutParams) child.getLayoutParams(); + if ((minCellsAt & (1 << i)) == 0) { + // If this item is already at our small item count, mark it for later. + if (lp.cellsUsed == minCells) smallestItemsAt |= 1 << i; + continue; + } + + if (centerSingleExpandedItem && lp.preventEdgeOffset && cellsRemaining == 1) { + // Add padding to this item such that it centers. + child.setPadding(mGeneratedItemPadding + cellSize, 0, mGeneratedItemPadding, 0); + } + lp.cellsUsed++; + lp.expanded = true; + cellsRemaining--; + } + + needsExpansion = true; + } + + // Divide any space left that wouldn't divide along cell boundaries + // evenly among the smallest items + + final boolean singleItem = !hasOverflow && visibleItemCount == 1; + if (cellsRemaining > 0 && smallestItemsAt != 0 && + (cellsRemaining < visibleItemCount - 1 || singleItem || maxCellsUsed > 1)) { + float expandCount = Long.bitCount(smallestItemsAt); + + if (!singleItem) { + // The items at the far edges may only expand by half in order to pin to either side. + if ((smallestItemsAt & 1) != 0) { + LayoutParams lp = (LayoutParams) getChildAt(0).getLayoutParams(); + if (!lp.preventEdgeOffset) expandCount -= 0.5f; + } + if ((smallestItemsAt & (1 << (childCount - 1))) != 0) { + LayoutParams lp = ((LayoutParams) getChildAt(childCount - 1).getLayoutParams()); + if (!lp.preventEdgeOffset) expandCount -= 0.5f; + } + } + + final int extraPixels = expandCount > 0 ? + (int) (cellsRemaining * cellSize / expandCount) : 0; + + for (int i = 0; i < childCount; i++) { + if ((smallestItemsAt & (1 << i)) == 0) continue; + + final View child = getChildAt(i); + final LayoutParams lp = (LayoutParams) child.getLayoutParams(); + if (child instanceof ActionMenuItemView) { + // If this is one of our views, expand and measure at the larger size. + lp.extraPixels = extraPixels; + lp.expanded = true; + if (i == 0 && !lp.preventEdgeOffset) { + // First item gets part of its new padding pushed out of sight. + // The last item will get this implicitly from layout. + lp.leftMargin = -extraPixels / 2; + } + needsExpansion = true; + } else if (lp.isOverflowButton) { + lp.extraPixels = extraPixels; + lp.expanded = true; + lp.rightMargin = -extraPixels / 2; + needsExpansion = true; + } else { + // If we don't know what it is, give it some margins instead + // and let it center within its space. We still want to pin + // against the edges. + if (i != 0) { + lp.leftMargin = extraPixels / 2; + } + if (i != childCount - 1) { + lp.rightMargin = extraPixels / 2; + } + } + } + + cellsRemaining = 0; + } + + // Remeasure any items that have had extra space allocated to them. + if (needsExpansion) { + int heightSpec = MeasureSpec.makeMeasureSpec(heightSize - heightPadding, heightMode); + for (int i = 0; i < childCount; i++) { + final View child = getChildAt(i); + final LayoutParams lp = (LayoutParams) child.getLayoutParams(); + + if (!lp.expanded) continue; + + final int width = lp.cellsUsed * cellSize + lp.extraPixels; + child.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), heightSpec); + } + } + + if (heightMode != MeasureSpec.EXACTLY) { + heightSize = maxChildHeight; + } + + setMeasuredDimension(widthSize, heightSize); + //UNUSED mMeasuredExtraWidth = cellsRemaining * cellSize; + } + + /** + * Measure a child view to fit within cell-based formatting. The child's width + * will be measured to a whole multiple of cellSize. + * + *

Sets the expandable and cellsUsed fields of LayoutParams. + * + * @param child Child to measure + * @param cellSize Size of one cell + * @param cellsRemaining Number of cells remaining that this view can expand to fill + * @param parentHeightMeasureSpec MeasureSpec used by the parent view + * @param parentHeightPadding Padding present in the parent view + * @return Number of cells this child was measured to occupy + */ + static int measureChildForCells(View child, int cellSize, int cellsRemaining, + int parentHeightMeasureSpec, int parentHeightPadding) { + final LayoutParams lp = (LayoutParams) child.getLayoutParams(); + + final int childHeightSize = MeasureSpec.getSize(parentHeightMeasureSpec) - + parentHeightPadding; + final int childHeightMode = MeasureSpec.getMode(parentHeightMeasureSpec); + final int childHeightSpec = MeasureSpec.makeMeasureSpec(childHeightSize, childHeightMode); + + int cellsUsed = 0; + if (cellsRemaining > 0) { + final int childWidthSpec = MeasureSpec.makeMeasureSpec( + cellSize * cellsRemaining, MeasureSpec.AT_MOST); + child.measure(childWidthSpec, childHeightSpec); + + final int measuredWidth = child.getMeasuredWidth(); + cellsUsed = measuredWidth / cellSize; + if (measuredWidth % cellSize != 0) cellsUsed++; + } + + final ActionMenuItemView itemView = child instanceof ActionMenuItemView ? + (ActionMenuItemView) child : null; + final boolean expandable = !lp.isOverflowButton && itemView != null && itemView.hasText(); + lp.expandable = expandable; + + lp.cellsUsed = cellsUsed; + final int targetWidth = cellsUsed * cellSize; + child.measure(MeasureSpec.makeMeasureSpec(targetWidth, MeasureSpec.EXACTLY), + childHeightSpec); + return cellsUsed; + } + + @Override + protected void onLayout(boolean changed, int left, int top, int right, int bottom) { + if (!mFormatItems) { + super.onLayout(changed, left, top, right, bottom); + return; + } + + final int childCount = getChildCount(); + final int midVertical = (top + bottom) / 2; + final int dividerWidth = 0;//getDividerWidth(); + int overflowWidth = 0; + //UNUSED int nonOverflowWidth = 0; + int nonOverflowCount = 0; + int widthRemaining = right - left - getPaddingRight() - getPaddingLeft(); + boolean hasOverflow = false; + for (int i = 0; i < childCount; i++) { + final View v = getChildAt(i); + if (v.getVisibility() == GONE) { + continue; + } + + LayoutParams p = (LayoutParams) v.getLayoutParams(); + if (p.isOverflowButton) { + overflowWidth = v.getMeasuredWidth(); + if (hasDividerBeforeChildAt(i)) { + overflowWidth += dividerWidth; + } + + int height = v.getMeasuredHeight(); + int r = getWidth() - getPaddingRight() - p.rightMargin; + int l = r - overflowWidth; + int t = midVertical - (height / 2); + int b = t + height; + v.layout(l, t, r, b); + + widthRemaining -= overflowWidth; + hasOverflow = true; + } else { + final int size = v.getMeasuredWidth() + p.leftMargin + p.rightMargin; + //UNUSED nonOverflowWidth += size; + widthRemaining -= size; + //if (hasDividerBeforeChildAt(i)) { + //UNUSED nonOverflowWidth += dividerWidth; + //} + nonOverflowCount++; + } + } + + if (childCount == 1 && !hasOverflow) { + // Center a single child + final View v = getChildAt(0); + final int width = v.getMeasuredWidth(); + final int height = v.getMeasuredHeight(); + final int midHorizontal = (right - left) / 2; + final int l = midHorizontal - width / 2; + final int t = midVertical - height / 2; + v.layout(l, t, l + width, t + height); + return; + } + + final int spacerCount = nonOverflowCount - (hasOverflow ? 0 : 1); + final int spacerSize = Math.max(0, spacerCount > 0 ? widthRemaining / spacerCount : 0); + + int startLeft = getPaddingLeft(); + for (int i = 0; i < childCount; i++) { + final View v = getChildAt(i); + final LayoutParams lp = (LayoutParams) v.getLayoutParams(); + if (v.getVisibility() == GONE || lp.isOverflowButton) { + continue; + } + + startLeft += lp.leftMargin; + int width = v.getMeasuredWidth(); + int height = v.getMeasuredHeight(); + int t = midVertical - height / 2; + v.layout(startLeft, t, startLeft + width, t + height); + startLeft += width + lp.rightMargin + spacerSize; + } + } + + @Override + public void onDetachedFromWindow() { + super.onDetachedFromWindow(); + mPresenter.dismissPopupMenus(); + } + + public boolean isOverflowReserved() { + return mReserveOverflow; + } + + public void setOverflowReserved(boolean reserveOverflow) { + mReserveOverflow = reserveOverflow; + } + + @Override + protected LayoutParams generateDefaultLayoutParams() { + LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, + LayoutParams.WRAP_CONTENT); + params.gravity = Gravity.CENTER_VERTICAL; + return params; + } + + @Override + public LayoutParams generateLayoutParams(AttributeSet attrs) { + return new LayoutParams(getContext(), attrs); + } + + @Override + protected LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) { + if (p instanceof LayoutParams) { + LayoutParams result = new LayoutParams((LayoutParams) p); + if (result.gravity <= Gravity.NO_GRAVITY) { + result.gravity = Gravity.CENTER_VERTICAL; + } + return result; + } + return generateDefaultLayoutParams(); + } + + @Override + protected boolean checkLayoutParams(ViewGroup.LayoutParams p) { + return p != null && p instanceof LayoutParams; + } + + public LayoutParams generateOverflowButtonLayoutParams() { + LayoutParams result = generateDefaultLayoutParams(); + result.isOverflowButton = true; + return result; + } + + public boolean invokeItem(MenuItemImpl item) { + return mMenu.performItemAction(item, 0); + } + + public int getWindowAnimations() { + return 0; + } + + public void initialize(MenuBuilder menu) { + mMenu = menu; + } + + //@Override + protected boolean hasDividerBeforeChildAt(int childIndex) { + final View childBefore = getChildAt(childIndex - 1); + final View child = getChildAt(childIndex); + boolean result = false; + if (childIndex < getChildCount() && childBefore instanceof ActionMenuChildView) { + result |= ((ActionMenuChildView) childBefore).needsDividerAfter(); + } + if (childIndex > 0 && child instanceof ActionMenuChildView) { + result |= ((ActionMenuChildView) child).needsDividerBefore(); + } + return result; + } + + public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { + return false; + } + + public interface ActionMenuChildView { + public boolean needsDividerBefore(); + public boolean needsDividerAfter(); + } + + public static class LayoutParams extends LinearLayout.LayoutParams { + public boolean isOverflowButton; + public int cellsUsed; + public int extraPixels; + public boolean expandable; + public boolean preventEdgeOffset; + + public boolean expanded; + + public LayoutParams(Context c, AttributeSet attrs) { + super(c, attrs); + } + + public LayoutParams(LayoutParams other) { + super((LinearLayout.LayoutParams) other); + isOverflowButton = other.isOverflowButton; + } + + public LayoutParams(int width, int height) { + super(width, height); + isOverflowButton = false; + } + + public LayoutParams(int width, int height, boolean isOverflowButton) { + super(width, height); + this.isOverflowButton = isOverflowButton; + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/BaseMenuPresenter.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/BaseMenuPresenter.java new file mode 100644 index 000000000..6da26f2ae --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/BaseMenuPresenter.java @@ -0,0 +1,231 @@ +/* + * Copyright (C) 2011 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.actionbarsherlock.internal.view.menu; + +import java.util.ArrayList; +import android.content.Context; +import android.os.Build; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +/** + * Base class for MenuPresenters that have a consistent container view and item + * views. Behaves similarly to an AdapterView in that existing item views will + * be reused if possible when items change. + */ +public abstract class BaseMenuPresenter implements MenuPresenter { + private static final boolean IS_HONEYCOMB = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB; + + protected Context mSystemContext; + protected Context mContext; + protected MenuBuilder mMenu; + protected LayoutInflater mSystemInflater; + protected LayoutInflater mInflater; + private Callback mCallback; + + private int mMenuLayoutRes; + private int mItemLayoutRes; + + protected MenuView mMenuView; + + private int mId; + + /** + * Construct a new BaseMenuPresenter. + * + * @param context Context for generating system-supplied views + * @param menuLayoutRes Layout resource ID for the menu container view + * @param itemLayoutRes Layout resource ID for a single item view + */ + public BaseMenuPresenter(Context context, int menuLayoutRes, int itemLayoutRes) { + mSystemContext = context; + mSystemInflater = LayoutInflater.from(context); + mMenuLayoutRes = menuLayoutRes; + mItemLayoutRes = itemLayoutRes; + } + + @Override + public void initForMenu(Context context, MenuBuilder menu) { + mContext = context; + mInflater = LayoutInflater.from(mContext); + mMenu = menu; + } + + @Override + public MenuView getMenuView(ViewGroup root) { + if (mMenuView == null) { + mMenuView = (MenuView) mSystemInflater.inflate(mMenuLayoutRes, root, false); + mMenuView.initialize(mMenu); + updateMenuView(true); + } + + return mMenuView; + } + + /** + * Reuses item views when it can + */ + public void updateMenuView(boolean cleared) { + final ViewGroup parent = (ViewGroup) mMenuView; + if (parent == null) return; + + int childIndex = 0; + if (mMenu != null) { + mMenu.flagActionItems(); + ArrayList visibleItems = mMenu.getVisibleItems(); + final int itemCount = visibleItems.size(); + for (int i = 0; i < itemCount; i++) { + MenuItemImpl item = visibleItems.get(i); + if (shouldIncludeItem(childIndex, item)) { + final View convertView = parent.getChildAt(childIndex); + final MenuItemImpl oldItem = convertView instanceof MenuView.ItemView ? + ((MenuView.ItemView) convertView).getItemData() : null; + final View itemView = getItemView(item, convertView, parent); + if (item != oldItem) { + // Don't let old states linger with new data. + itemView.setPressed(false); + if (IS_HONEYCOMB) itemView.jumpDrawablesToCurrentState(); + } + if (itemView != convertView) { + addItemView(itemView, childIndex); + } + childIndex++; + } + } + } + + // Remove leftover views. + while (childIndex < parent.getChildCount()) { + if (!filterLeftoverView(parent, childIndex)) { + childIndex++; + } + } + } + + /** + * Add an item view at the given index. + * + * @param itemView View to add + * @param childIndex Index within the parent to insert at + */ + protected void addItemView(View itemView, int childIndex) { + final ViewGroup currentParent = (ViewGroup) itemView.getParent(); + if (currentParent != null) { + currentParent.removeView(itemView); + } + ((ViewGroup) mMenuView).addView(itemView, childIndex); + } + + /** + * Filter the child view at index and remove it if appropriate. + * @param parent Parent to filter from + * @param childIndex Index to filter + * @return true if the child view at index was removed + */ + protected boolean filterLeftoverView(ViewGroup parent, int childIndex) { + parent.removeViewAt(childIndex); + return true; + } + + public void setCallback(Callback cb) { + mCallback = cb; + } + + /** + * Create a new item view that can be re-bound to other item data later. + * + * @return The new item view + */ + public MenuView.ItemView createItemView(ViewGroup parent) { + return (MenuView.ItemView) mSystemInflater.inflate(mItemLayoutRes, parent, false); + } + + /** + * Prepare an item view for use. See AdapterView for the basic idea at work here. + * This may require creating a new item view, but well-behaved implementations will + * re-use the view passed as convertView if present. The returned view will be populated + * with data from the item parameter. + * + * @param item Item to present + * @param convertView Existing view to reuse + * @param parent Intended parent view - use for inflation. + * @return View that presents the requested menu item + */ + public View getItemView(MenuItemImpl item, View convertView, ViewGroup parent) { + MenuView.ItemView itemView; + if (convertView instanceof MenuView.ItemView) { + itemView = (MenuView.ItemView) convertView; + } else { + itemView = createItemView(parent); + } + bindItemView(item, itemView); + return (View) itemView; + } + + /** + * Bind item data to an existing item view. + * + * @param item Item to bind + * @param itemView View to populate with item data + */ + public abstract void bindItemView(MenuItemImpl item, MenuView.ItemView itemView); + + /** + * Filter item by child index and item data. + * + * @param childIndex Indended presentation index of this item + * @param item Item to present + * @return true if this item should be included in this menu presentation; false otherwise + */ + public boolean shouldIncludeItem(int childIndex, MenuItemImpl item) { + return true; + } + + public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) { + if (mCallback != null) { + mCallback.onCloseMenu(menu, allMenusAreClosing); + } + } + + public boolean onSubMenuSelected(SubMenuBuilder menu) { + if (mCallback != null) { + return mCallback.onOpenSubMenu(menu); + } + return false; + } + + public boolean flagActionItems() { + return false; + } + + public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item) { + return false; + } + + public boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item) { + return false; + } + + public int getId() { + return mId; + } + + public void setId(int id) { + mId = id; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ListMenuItemView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ListMenuItemView.java new file mode 100644 index 000000000..ac25c3736 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/ListMenuItemView.java @@ -0,0 +1,278 @@ +/* + * Copyright (C) 2006 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.actionbarsherlock.internal.view.menu; + +import com.actionbarsherlock.R; + +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.drawable.Drawable; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.CheckBox; +import android.widget.CompoundButton; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.RadioButton; +import android.widget.TextView; + +/** + * The item view for each item in the ListView-based MenuViews. + */ +public class ListMenuItemView extends LinearLayout implements MenuView.ItemView { + private MenuItemImpl mItemData; + + private ImageView mIconView; + private RadioButton mRadioButton; + private TextView mTitleView; + private CheckBox mCheckBox; + private TextView mShortcutView; + + private Drawable mBackground; + private int mTextAppearance; + private Context mTextAppearanceContext; + private boolean mPreserveIconSpacing; + + //UNUSED private int mMenuType; + + private LayoutInflater mInflater; + + private boolean mForceShowIcon; + + final Context mContext; + + public ListMenuItemView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs); + mContext = context; + + TypedArray a = + context.obtainStyledAttributes( + attrs, R.styleable.SherlockMenuView, defStyle, 0); + + mBackground = a.getDrawable(R.styleable.SherlockMenuView_itemBackground); + mTextAppearance = a.getResourceId(R.styleable. + SherlockMenuView_itemTextAppearance, -1); + mPreserveIconSpacing = a.getBoolean( + R.styleable.SherlockMenuView_preserveIconSpacing, false); + mTextAppearanceContext = context; + + a.recycle(); + } + + public ListMenuItemView(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + @Override + protected void onFinishInflate() { + super.onFinishInflate(); + + setBackgroundDrawable(mBackground); + + mTitleView = (TextView) findViewById(R.id.abs__title); + if (mTextAppearance != -1) { + mTitleView.setTextAppearance(mTextAppearanceContext, + mTextAppearance); + } + + mShortcutView = (TextView) findViewById(R.id.abs__shortcut); + } + + public void initialize(MenuItemImpl itemData, int menuType) { + mItemData = itemData; + //UNUSED mMenuType = menuType; + + setVisibility(itemData.isVisible() ? View.VISIBLE : View.GONE); + + setTitle(itemData.getTitleForItemView(this)); + setCheckable(itemData.isCheckable()); + setShortcut(itemData.shouldShowShortcut(), itemData.getShortcut()); + setIcon(itemData.getIcon()); + setEnabled(itemData.isEnabled()); + } + + public void setForceShowIcon(boolean forceShow) { + mPreserveIconSpacing = mForceShowIcon = forceShow; + } + + public void setTitle(CharSequence title) { + if (title != null) { + mTitleView.setText(title); + + if (mTitleView.getVisibility() != VISIBLE) mTitleView.setVisibility(VISIBLE); + } else { + if (mTitleView.getVisibility() != GONE) mTitleView.setVisibility(GONE); + } + } + + public MenuItemImpl getItemData() { + return mItemData; + } + + public void setCheckable(boolean checkable) { + + if (!checkable && mRadioButton == null && mCheckBox == null) { + return; + } + + if (mRadioButton == null) { + insertRadioButton(); + } + if (mCheckBox == null) { + insertCheckBox(); + } + + // Depending on whether its exclusive check or not, the checkbox or + // radio button will be the one in use (and the other will be otherCompoundButton) + final CompoundButton compoundButton; + final CompoundButton otherCompoundButton; + + if (mItemData.isExclusiveCheckable()) { + compoundButton = mRadioButton; + otherCompoundButton = mCheckBox; + } else { + compoundButton = mCheckBox; + otherCompoundButton = mRadioButton; + } + + if (checkable) { + compoundButton.setChecked(mItemData.isChecked()); + + final int newVisibility = checkable ? VISIBLE : GONE; + if (compoundButton.getVisibility() != newVisibility) { + compoundButton.setVisibility(newVisibility); + } + + // Make sure the other compound button isn't visible + if (otherCompoundButton.getVisibility() != GONE) { + otherCompoundButton.setVisibility(GONE); + } + } else { + mCheckBox.setVisibility(GONE); + mRadioButton.setVisibility(GONE); + } + } + + public void setChecked(boolean checked) { + CompoundButton compoundButton; + + if (mItemData.isExclusiveCheckable()) { + if (mRadioButton == null) { + insertRadioButton(); + } + compoundButton = mRadioButton; + } else { + if (mCheckBox == null) { + insertCheckBox(); + } + compoundButton = mCheckBox; + } + + compoundButton.setChecked(checked); + } + + public void setShortcut(boolean showShortcut, char shortcutKey) { + final int newVisibility = (showShortcut && mItemData.shouldShowShortcut()) + ? VISIBLE : GONE; + + if (newVisibility == VISIBLE) { + mShortcutView.setText(mItemData.getShortcutLabel()); + } + + if (mShortcutView.getVisibility() != newVisibility) { + mShortcutView.setVisibility(newVisibility); + } + } + + public void setIcon(Drawable icon) { + final boolean showIcon = mItemData.shouldShowIcon() || mForceShowIcon; + if (!showIcon && !mPreserveIconSpacing) { + return; + } + + if (mIconView == null && icon == null && !mPreserveIconSpacing) { + return; + } + + if (mIconView == null) { + insertIconView(); + } + + if (icon != null || mPreserveIconSpacing) { + mIconView.setImageDrawable(showIcon ? icon : null); + + if (mIconView.getVisibility() != VISIBLE) { + mIconView.setVisibility(VISIBLE); + } + } else { + mIconView.setVisibility(GONE); + } + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + if (mIconView != null && mPreserveIconSpacing) { + // Enforce minimum icon spacing + ViewGroup.LayoutParams lp = getLayoutParams(); + LayoutParams iconLp = (LayoutParams) mIconView.getLayoutParams(); + if (lp.height > 0 && iconLp.width <= 0) { + iconLp.width = lp.height; + } + } + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + } + + private void insertIconView() { + LayoutInflater inflater = getInflater(); + mIconView = (ImageView) inflater.inflate(R.layout.abs__list_menu_item_icon, + this, false); + addView(mIconView, 0); + } + + private void insertRadioButton() { + LayoutInflater inflater = getInflater(); + mRadioButton = + (RadioButton) inflater.inflate(R.layout.abs__list_menu_item_radio, + this, false); + addView(mRadioButton); + } + + private void insertCheckBox() { + LayoutInflater inflater = getInflater(); + mCheckBox = + (CheckBox) inflater.inflate(R.layout.abs__list_menu_item_checkbox, + this, false); + addView(mCheckBox); + } + + public boolean prefersCondensedTitle() { + return false; + } + + public boolean showsIcon() { + return mForceShowIcon; + } + + private LayoutInflater getInflater() { + if (mInflater == null) { + mInflater = LayoutInflater.from(mContext); + } + return mInflater; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuBuilder.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuBuilder.java new file mode 100644 index 000000000..179b8f037 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuBuilder.java @@ -0,0 +1,1335 @@ +/* + * Copyright (C) 2006 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.actionbarsherlock.internal.view.menu; + + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; + +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; +import android.content.res.Configuration; +import android.content.res.Resources; +import android.graphics.drawable.Drawable; +import android.os.Bundle; +import android.os.Parcelable; +import android.util.SparseArray; +import android.view.ContextMenu.ContextMenuInfo; +import android.view.KeyCharacterMap; +import android.view.KeyEvent; +import android.view.View; + +import com.actionbarsherlock.R; +import com.actionbarsherlock.view.ActionProvider; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuItem; +import com.actionbarsherlock.view.SubMenu; + +/** + * Implementation of the {@link android.view.Menu} interface for creating a + * standard menu UI. + */ +public class MenuBuilder implements Menu { + //UNUSED private static final String TAG = "MenuBuilder"; + + private static final String PRESENTER_KEY = "android:menu:presenters"; + private static final String ACTION_VIEW_STATES_KEY = "android:menu:actionviewstates"; + private static final String EXPANDED_ACTION_VIEW_ID = "android:menu:expandedactionview"; + + private static final int[] sCategoryToOrder = new int[] { + 1, /* No category */ + 4, /* CONTAINER */ + 5, /* SYSTEM */ + 3, /* SECONDARY */ + 2, /* ALTERNATIVE */ + 0, /* SELECTED_ALTERNATIVE */ + }; + + private final Context mContext; + private final Resources mResources; + + /** + * Whether the shortcuts should be qwerty-accessible. Use isQwertyMode() + * instead of accessing this directly. + */ + private boolean mQwertyMode; + + /** + * Whether the shortcuts should be visible on menus. Use isShortcutsVisible() + * instead of accessing this directly. + */ + private boolean mShortcutsVisible; + + /** + * Callback that will receive the various menu-related events generated by + * this class. Use getCallback to get a reference to the callback. + */ + private Callback mCallback; + + /** Contains all of the items for this menu */ + private ArrayList mItems; + + /** Contains only the items that are currently visible. This will be created/refreshed from + * {@link #getVisibleItems()} */ + private ArrayList mVisibleItems; + /** + * Whether or not the items (or any one item's shown state) has changed since it was last + * fetched from {@link #getVisibleItems()} + */ + private boolean mIsVisibleItemsStale; + + /** + * Contains only the items that should appear in the Action Bar, if present. + */ + private ArrayList mActionItems; + /** + * Contains items that should NOT appear in the Action Bar, if present. + */ + private ArrayList mNonActionItems; + + /** + * Whether or not the items (or any one item's action state) has changed since it was + * last fetched. + */ + private boolean mIsActionItemsStale; + + /** + * Default value for how added items should show in the action list. + */ + private int mDefaultShowAsAction = MenuItem.SHOW_AS_ACTION_NEVER; + + /** + * Current use case is Context Menus: As Views populate the context menu, each one has + * extra information that should be passed along. This is the current menu info that + * should be set on all items added to this menu. + */ + private ContextMenuInfo mCurrentMenuInfo; + + /** Header title for menu types that have a header (context and submenus) */ + CharSequence mHeaderTitle; + /** Header icon for menu types that have a header and support icons (context) */ + Drawable mHeaderIcon; + /** Header custom view for menu types that have a header and support custom views (context) */ + View mHeaderView; + + /** + * Contains the state of the View hierarchy for all menu views when the menu + * was frozen. + */ + //UNUSED private SparseArray mFrozenViewStates; + + /** + * Prevents onItemsChanged from doing its junk, useful for batching commands + * that may individually call onItemsChanged. + */ + private boolean mPreventDispatchingItemsChanged = false; + private boolean mItemsChangedWhileDispatchPrevented = false; + + private boolean mOptionalIconsVisible = false; + + private boolean mIsClosing = false; + + private ArrayList mTempShortcutItemList = new ArrayList(); + + private CopyOnWriteArrayList> mPresenters = + new CopyOnWriteArrayList>(); + + /** + * Currently expanded menu item; must be collapsed when we clear. + */ + private MenuItemImpl mExpandedItem; + + /** + * Called by menu to notify of close and selection changes. + */ + public interface Callback { + /** + * Called when a menu item is selected. + * @param menu The menu that is the parent of the item + * @param item The menu item that is selected + * @return whether the menu item selection was handled + */ + public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item); + + /** + * Called when the mode of the menu changes (for example, from icon to expanded). + * + * @param menu the menu that has changed modes + */ + public void onMenuModeChange(MenuBuilder menu); + } + + /** + * Called by menu items to execute their associated action + */ + public interface ItemInvoker { + public boolean invokeItem(MenuItemImpl item); + } + + public MenuBuilder(Context context) { + mContext = context; + mResources = context.getResources(); + + mItems = new ArrayList(); + + mVisibleItems = new ArrayList(); + mIsVisibleItemsStale = true; + + mActionItems = new ArrayList(); + mNonActionItems = new ArrayList(); + mIsActionItemsStale = true; + + setShortcutsVisibleInner(true); + } + + public MenuBuilder setDefaultShowAsAction(int defaultShowAsAction) { + mDefaultShowAsAction = defaultShowAsAction; + return this; + } + + /** + * Add a presenter to this menu. This will only hold a WeakReference; + * you do not need to explicitly remove a presenter, but you can using + * {@link #removeMenuPresenter(MenuPresenter)}. + * + * @param presenter The presenter to add + */ + public void addMenuPresenter(MenuPresenter presenter) { + mPresenters.add(new WeakReference(presenter)); + presenter.initForMenu(mContext, this); + mIsActionItemsStale = true; + } + + /** + * Remove a presenter from this menu. That presenter will no longer + * receive notifications of updates to this menu's data. + * + * @param presenter The presenter to remove + */ + public void removeMenuPresenter(MenuPresenter presenter) { + for (WeakReference ref : mPresenters) { + final MenuPresenter item = ref.get(); + if (item == null || item == presenter) { + mPresenters.remove(ref); + } + } + } + + private void dispatchPresenterUpdate(boolean cleared) { + if (mPresenters.isEmpty()) return; + + stopDispatchingItemsChanged(); + for (WeakReference ref : mPresenters) { + final MenuPresenter presenter = ref.get(); + if (presenter == null) { + mPresenters.remove(ref); + } else { + presenter.updateMenuView(cleared); + } + } + startDispatchingItemsChanged(); + } + + private boolean dispatchSubMenuSelected(SubMenuBuilder subMenu) { + if (mPresenters.isEmpty()) return false; + + boolean result = false; + + for (WeakReference ref : mPresenters) { + final MenuPresenter presenter = ref.get(); + if (presenter == null) { + mPresenters.remove(ref); + } else if (!result) { + result = presenter.onSubMenuSelected(subMenu); + } + } + return result; + } + + private void dispatchSaveInstanceState(Bundle outState) { + if (mPresenters.isEmpty()) return; + + SparseArray presenterStates = new SparseArray(); + + for (WeakReference ref : mPresenters) { + final MenuPresenter presenter = ref.get(); + if (presenter == null) { + mPresenters.remove(ref); + } else { + final int id = presenter.getId(); + if (id > 0) { + final Parcelable state = presenter.onSaveInstanceState(); + if (state != null) { + presenterStates.put(id, state); + } + } + } + } + + outState.putSparseParcelableArray(PRESENTER_KEY, presenterStates); + } + + private void dispatchRestoreInstanceState(Bundle state) { + SparseArray presenterStates = state.getSparseParcelableArray(PRESENTER_KEY); + + if (presenterStates == null || mPresenters.isEmpty()) return; + + for (WeakReference ref : mPresenters) { + final MenuPresenter presenter = ref.get(); + if (presenter == null) { + mPresenters.remove(ref); + } else { + final int id = presenter.getId(); + if (id > 0) { + Parcelable parcel = presenterStates.get(id); + if (parcel != null) { + presenter.onRestoreInstanceState(parcel); + } + } + } + } + } + + public void savePresenterStates(Bundle outState) { + dispatchSaveInstanceState(outState); + } + + public void restorePresenterStates(Bundle state) { + dispatchRestoreInstanceState(state); + } + + public void saveActionViewStates(Bundle outStates) { + SparseArray viewStates = null; + + final int itemCount = size(); + for (int i = 0; i < itemCount; i++) { + final MenuItem item = getItem(i); + final View v = item.getActionView(); + if (v != null && v.getId() != View.NO_ID) { + if (viewStates == null) { + viewStates = new SparseArray(); + } + v.saveHierarchyState(viewStates); + if (item.isActionViewExpanded()) { + outStates.putInt(EXPANDED_ACTION_VIEW_ID, item.getItemId()); + } + } + if (item.hasSubMenu()) { + final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu(); + subMenu.saveActionViewStates(outStates); + } + } + + if (viewStates != null) { + outStates.putSparseParcelableArray(getActionViewStatesKey(), viewStates); + } + } + + public void restoreActionViewStates(Bundle states) { + if (states == null) { + return; + } + + SparseArray viewStates = states.getSparseParcelableArray( + getActionViewStatesKey()); + + final int itemCount = size(); + for (int i = 0; i < itemCount; i++) { + final MenuItem item = getItem(i); + final View v = item.getActionView(); + if (v != null && v.getId() != View.NO_ID) { + v.restoreHierarchyState(viewStates); + } + if (item.hasSubMenu()) { + final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu(); + subMenu.restoreActionViewStates(states); + } + } + + final int expandedId = states.getInt(EXPANDED_ACTION_VIEW_ID); + if (expandedId > 0) { + MenuItem itemToExpand = findItem(expandedId); + if (itemToExpand != null) { + itemToExpand.expandActionView(); + } + } + } + + protected String getActionViewStatesKey() { + return ACTION_VIEW_STATES_KEY; + } + + public void setCallback(Callback cb) { + mCallback = cb; + } + + /** + * Adds an item to the menu. The other add methods funnel to this. + */ + private MenuItem addInternal(int group, int id, int categoryOrder, CharSequence title) { + final int ordering = getOrdering(categoryOrder); + + final MenuItemImpl item = new MenuItemImpl(this, group, id, categoryOrder, + ordering, title, mDefaultShowAsAction); + + if (mCurrentMenuInfo != null) { + // Pass along the current menu info + item.setMenuInfo(mCurrentMenuInfo); + } + + mItems.add(findInsertIndex(mItems, ordering), item); + onItemsChanged(true); + + return item; + } + + public MenuItem add(CharSequence title) { + return addInternal(0, 0, 0, title); + } + + public MenuItem add(int titleRes) { + return addInternal(0, 0, 0, mResources.getString(titleRes)); + } + + public MenuItem add(int group, int id, int categoryOrder, CharSequence title) { + return addInternal(group, id, categoryOrder, title); + } + + public MenuItem add(int group, int id, int categoryOrder, int title) { + return addInternal(group, id, categoryOrder, mResources.getString(title)); + } + + public SubMenu addSubMenu(CharSequence title) { + return addSubMenu(0, 0, 0, title); + } + + public SubMenu addSubMenu(int titleRes) { + return addSubMenu(0, 0, 0, mResources.getString(titleRes)); + } + + public SubMenu addSubMenu(int group, int id, int categoryOrder, CharSequence title) { + final MenuItemImpl item = (MenuItemImpl) addInternal(group, id, categoryOrder, title); + final SubMenuBuilder subMenu = new SubMenuBuilder(mContext, this, item); + item.setSubMenu(subMenu); + + return subMenu; + } + + public SubMenu addSubMenu(int group, int id, int categoryOrder, int title) { + return addSubMenu(group, id, categoryOrder, mResources.getString(title)); + } + + public int addIntentOptions(int group, int id, int categoryOrder, ComponentName caller, + Intent[] specifics, Intent intent, int flags, MenuItem[] outSpecificItems) { + PackageManager pm = mContext.getPackageManager(); + final List lri = + pm.queryIntentActivityOptions(caller, specifics, intent, 0); + final int N = lri != null ? lri.size() : 0; + + if ((flags & FLAG_APPEND_TO_GROUP) == 0) { + removeGroup(group); + } + + for (int i=0; i= 0) { + outSpecificItems[ri.specificIndex] = item; + } + } + + return N; + } + + public void removeItem(int id) { + removeItemAtInt(findItemIndex(id), true); + } + + public void removeGroup(int group) { + final int i = findGroupIndex(group); + + if (i >= 0) { + final int maxRemovable = mItems.size() - i; + int numRemoved = 0; + while ((numRemoved++ < maxRemovable) && (mItems.get(i).getGroupId() == group)) { + // Don't force update for each one, this method will do it at the end + removeItemAtInt(i, false); + } + + // Notify menu views + onItemsChanged(true); + } + } + + /** + * Remove the item at the given index and optionally forces menu views to + * update. + * + * @param index The index of the item to be removed. If this index is + * invalid an exception is thrown. + * @param updateChildrenOnMenuViews Whether to force update on menu views. + * Please make sure you eventually call this after your batch of + * removals. + */ + private void removeItemAtInt(int index, boolean updateChildrenOnMenuViews) { + if ((index < 0) || (index >= mItems.size())) return; + + mItems.remove(index); + + if (updateChildrenOnMenuViews) onItemsChanged(true); + } + + public void removeItemAt(int index) { + removeItemAtInt(index, true); + } + + public void clearAll() { + mPreventDispatchingItemsChanged = true; + clear(); + clearHeader(); + mPreventDispatchingItemsChanged = false; + mItemsChangedWhileDispatchPrevented = false; + onItemsChanged(true); + } + + public void clear() { + if (mExpandedItem != null) { + collapseItemActionView(mExpandedItem); + } + mItems.clear(); + + onItemsChanged(true); + } + + void setExclusiveItemChecked(MenuItem item) { + final int group = item.getGroupId(); + + final int N = mItems.size(); + for (int i = 0; i < N; i++) { + MenuItemImpl curItem = mItems.get(i); + if (curItem.getGroupId() == group) { + if (!curItem.isExclusiveCheckable()) continue; + if (!curItem.isCheckable()) continue; + + // Check the item meant to be checked, uncheck the others (that are in the group) + curItem.setCheckedInt(curItem == item); + } + } + } + + public void setGroupCheckable(int group, boolean checkable, boolean exclusive) { + final int N = mItems.size(); + + for (int i = 0; i < N; i++) { + MenuItemImpl item = mItems.get(i); + if (item.getGroupId() == group) { + item.setExclusiveCheckable(exclusive); + item.setCheckable(checkable); + } + } + } + + public void setGroupVisible(int group, boolean visible) { + final int N = mItems.size(); + + // We handle the notification of items being changed ourselves, so we use setVisibleInt rather + // than setVisible and at the end notify of items being changed + + boolean changedAtLeastOneItem = false; + for (int i = 0; i < N; i++) { + MenuItemImpl item = mItems.get(i); + if (item.getGroupId() == group) { + if (item.setVisibleInt(visible)) changedAtLeastOneItem = true; + } + } + + if (changedAtLeastOneItem) onItemsChanged(true); + } + + public void setGroupEnabled(int group, boolean enabled) { + final int N = mItems.size(); + + for (int i = 0; i < N; i++) { + MenuItemImpl item = mItems.get(i); + if (item.getGroupId() == group) { + item.setEnabled(enabled); + } + } + } + + public boolean hasVisibleItems() { + final int size = size(); + + for (int i = 0; i < size; i++) { + MenuItemImpl item = mItems.get(i); + if (item.isVisible()) { + return true; + } + } + + return false; + } + + public MenuItem findItem(int id) { + final int size = size(); + for (int i = 0; i < size; i++) { + MenuItemImpl item = mItems.get(i); + if (item.getItemId() == id) { + return item; + } else if (item.hasSubMenu()) { + MenuItem possibleItem = item.getSubMenu().findItem(id); + + if (possibleItem != null) { + return possibleItem; + } + } + } + + return null; + } + + public int findItemIndex(int id) { + final int size = size(); + + for (int i = 0; i < size; i++) { + MenuItemImpl item = mItems.get(i); + if (item.getItemId() == id) { + return i; + } + } + + return -1; + } + + public int findGroupIndex(int group) { + return findGroupIndex(group, 0); + } + + public int findGroupIndex(int group, int start) { + final int size = size(); + + if (start < 0) { + start = 0; + } + + for (int i = start; i < size; i++) { + final MenuItemImpl item = mItems.get(i); + + if (item.getGroupId() == group) { + return i; + } + } + + return -1; + } + + public int size() { + return mItems.size(); + } + + /** {@inheritDoc} */ + public MenuItem getItem(int index) { + return mItems.get(index); + } + + public boolean isShortcutKey(int keyCode, KeyEvent event) { + return findItemWithShortcutForKey(keyCode, event) != null; + } + + public void setQwertyMode(boolean isQwerty) { + mQwertyMode = isQwerty; + + onItemsChanged(false); + } + + /** + * Returns the ordering across all items. This will grab the category from + * the upper bits, find out how to order the category with respect to other + * categories, and combine it with the lower bits. + * + * @param categoryOrder The category order for a particular item (if it has + * not been or/add with a category, the default category is + * assumed). + * @return An ordering integer that can be used to order this item across + * all the items (even from other categories). + */ + private static int getOrdering(int categoryOrder) { + final int index = (categoryOrder & CATEGORY_MASK) >> CATEGORY_SHIFT; + + if (index < 0 || index >= sCategoryToOrder.length) { + throw new IllegalArgumentException("order does not contain a valid category."); + } + + return (sCategoryToOrder[index] << CATEGORY_SHIFT) | (categoryOrder & USER_MASK); + } + + /** + * @return whether the menu shortcuts are in qwerty mode or not + */ + boolean isQwertyMode() { + return mQwertyMode; + } + + /** + * Sets whether the shortcuts should be visible on menus. Devices without hardware + * key input will never make shortcuts visible even if this method is passed 'true'. + * + * @param shortcutsVisible Whether shortcuts should be visible (if true and a + * menu item does not have a shortcut defined, that item will + * still NOT show a shortcut) + */ + public void setShortcutsVisible(boolean shortcutsVisible) { + if (mShortcutsVisible == shortcutsVisible) return; + + setShortcutsVisibleInner(shortcutsVisible); + onItemsChanged(false); + } + + private void setShortcutsVisibleInner(boolean shortcutsVisible) { + mShortcutsVisible = shortcutsVisible + && mResources.getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS + && mResources.getBoolean( + R.bool.abs__config_showMenuShortcutsWhenKeyboardPresent); + } + + /** + * @return Whether shortcuts should be visible on menus. + */ + public boolean isShortcutsVisible() { + return mShortcutsVisible; + } + + Resources getResources() { + return mResources; + } + + public Context getContext() { + return mContext; + } + + boolean dispatchMenuItemSelected(MenuBuilder menu, MenuItem item) { + return mCallback != null && mCallback.onMenuItemSelected(menu, item); + } + + /** + * Dispatch a mode change event to this menu's callback. + */ + public void changeMenuMode() { + if (mCallback != null) { + mCallback.onMenuModeChange(this); + } + } + + private static int findInsertIndex(ArrayList items, int ordering) { + for (int i = items.size() - 1; i >= 0; i--) { + MenuItemImpl item = items.get(i); + if (item.getOrdering() <= ordering) { + return i + 1; + } + } + + return 0; + } + + public boolean performShortcut(int keyCode, KeyEvent event, int flags) { + final MenuItemImpl item = findItemWithShortcutForKey(keyCode, event); + + boolean handled = false; + + if (item != null) { + handled = performItemAction(item, flags); + } + + if ((flags & FLAG_ALWAYS_PERFORM_CLOSE) != 0) { + close(true); + } + + return handled; + } + + /* + * This function will return all the menu and sub-menu items that can + * be directly (the shortcut directly corresponds) and indirectly + * (the ALT-enabled char corresponds to the shortcut) associated + * with the keyCode. + */ + @SuppressWarnings("deprecation") + void findItemsWithShortcutForKey(List items, int keyCode, KeyEvent event) { + final boolean qwerty = isQwertyMode(); + final int metaState = event.getMetaState(); + final KeyCharacterMap.KeyData possibleChars = new KeyCharacterMap.KeyData(); + // Get the chars associated with the keyCode (i.e using any chording combo) + final boolean isKeyCodeMapped = event.getKeyData(possibleChars); + // The delete key is not mapped to '\b' so we treat it specially + if (!isKeyCodeMapped && (keyCode != KeyEvent.KEYCODE_DEL)) { + return; + } + + // Look for an item whose shortcut is this key. + final int N = mItems.size(); + for (int i = 0; i < N; i++) { + MenuItemImpl item = mItems.get(i); + if (item.hasSubMenu()) { + ((MenuBuilder)item.getSubMenu()).findItemsWithShortcutForKey(items, keyCode, event); + } + final char shortcutChar = qwerty ? item.getAlphabeticShortcut() : item.getNumericShortcut(); + if (((metaState & (KeyEvent.META_SHIFT_ON | KeyEvent.META_SYM_ON)) == 0) && + (shortcutChar != 0) && + (shortcutChar == possibleChars.meta[0] + || shortcutChar == possibleChars.meta[2] + || (qwerty && shortcutChar == '\b' && + keyCode == KeyEvent.KEYCODE_DEL)) && + item.isEnabled()) { + items.add(item); + } + } + } + + /* + * We want to return the menu item associated with the key, but if there is no + * ambiguity (i.e. there is only one menu item corresponding to the key) we want + * to return it even if it's not an exact match; this allow the user to + * _not_ use the ALT key for example, making the use of shortcuts slightly more + * user-friendly. An example is on the G1, '!' and '1' are on the same key, and + * in Gmail, Menu+1 will trigger Menu+! (the actual shortcut). + * + * On the other hand, if two (or more) shortcuts corresponds to the same key, + * we have to only return the exact match. + */ + @SuppressWarnings("deprecation") + MenuItemImpl findItemWithShortcutForKey(int keyCode, KeyEvent event) { + // Get all items that can be associated directly or indirectly with the keyCode + ArrayList items = mTempShortcutItemList; + items.clear(); + findItemsWithShortcutForKey(items, keyCode, event); + + if (items.isEmpty()) { + return null; + } + + final int metaState = event.getMetaState(); + final KeyCharacterMap.KeyData possibleChars = new KeyCharacterMap.KeyData(); + // Get the chars associated with the keyCode (i.e using any chording combo) + event.getKeyData(possibleChars); + + // If we have only one element, we can safely returns it + final int size = items.size(); + if (size == 1) { + return items.get(0); + } + + final boolean qwerty = isQwertyMode(); + // If we found more than one item associated with the key, + // we have to return the exact match + for (int i = 0; i < size; i++) { + final MenuItemImpl item = items.get(i); + final char shortcutChar = qwerty ? item.getAlphabeticShortcut() : + item.getNumericShortcut(); + if ((shortcutChar == possibleChars.meta[0] && + (metaState & KeyEvent.META_ALT_ON) == 0) + || (shortcutChar == possibleChars.meta[2] && + (metaState & KeyEvent.META_ALT_ON) != 0) + || (qwerty && shortcutChar == '\b' && + keyCode == KeyEvent.KEYCODE_DEL)) { + return item; + } + } + return null; + } + + public boolean performIdentifierAction(int id, int flags) { + // Look for an item whose identifier is the id. + return performItemAction(findItem(id), flags); + } + + public boolean performItemAction(MenuItem item, int flags) { + MenuItemImpl itemImpl = (MenuItemImpl) item; + + if (itemImpl == null || !itemImpl.isEnabled()) { + return false; + } + + boolean invoked = itemImpl.invoke(); + + if (itemImpl.hasCollapsibleActionView()) { + invoked |= itemImpl.expandActionView(); + if (invoked) close(true); + } else if (item.hasSubMenu()) { + close(false); + + final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu(); + final ActionProvider provider = item.getActionProvider(); + if (provider != null && provider.hasSubMenu()) { + provider.onPrepareSubMenu(subMenu); + } + invoked |= dispatchSubMenuSelected(subMenu); + if (!invoked) close(true); + } else { + if ((flags & FLAG_PERFORM_NO_CLOSE) == 0) { + close(true); + } + } + + return invoked; + } + + /** + * Closes the visible menu. + * + * @param allMenusAreClosing Whether the menus are completely closing (true), + * or whether there is another menu coming in this menu's place + * (false). For example, if the menu is closing because a + * sub menu is about to be shown, allMenusAreClosing + * is false. + */ + final void close(boolean allMenusAreClosing) { + if (mIsClosing) return; + + mIsClosing = true; + for (WeakReference ref : mPresenters) { + final MenuPresenter presenter = ref.get(); + if (presenter == null) { + mPresenters.remove(ref); + } else { + presenter.onCloseMenu(this, allMenusAreClosing); + } + } + mIsClosing = false; + } + + /** {@inheritDoc} */ + public void close() { + close(true); + } + + /** + * Called when an item is added or removed. + * + * @param structureChanged true if the menu structure changed, + * false if only item properties changed. + * (Visibility is a structural property since it affects layout.) + */ + void onItemsChanged(boolean structureChanged) { + if (!mPreventDispatchingItemsChanged) { + if (structureChanged) { + mIsVisibleItemsStale = true; + mIsActionItemsStale = true; + } + + dispatchPresenterUpdate(structureChanged); + } else { + mItemsChangedWhileDispatchPrevented = true; + } + } + + /** + * Stop dispatching item changed events to presenters until + * {@link #startDispatchingItemsChanged()} is called. Useful when + * many menu operations are going to be performed as a batch. + */ + public void stopDispatchingItemsChanged() { + if (!mPreventDispatchingItemsChanged) { + mPreventDispatchingItemsChanged = true; + mItemsChangedWhileDispatchPrevented = false; + } + } + + public void startDispatchingItemsChanged() { + mPreventDispatchingItemsChanged = false; + + if (mItemsChangedWhileDispatchPrevented) { + mItemsChangedWhileDispatchPrevented = false; + onItemsChanged(true); + } + } + + /** + * Called by {@link MenuItemImpl} when its visible flag is changed. + * @param item The item that has gone through a visibility change. + */ + void onItemVisibleChanged(MenuItemImpl item) { + // Notify of items being changed + mIsVisibleItemsStale = true; + onItemsChanged(true); + } + + /** + * Called by {@link MenuItemImpl} when its action request status is changed. + * @param item The item that has gone through a change in action request status. + */ + void onItemActionRequestChanged(MenuItemImpl item) { + // Notify of items being changed + mIsActionItemsStale = true; + onItemsChanged(true); + } + + ArrayList getVisibleItems() { + if (!mIsVisibleItemsStale) return mVisibleItems; + + // Refresh the visible items + mVisibleItems.clear(); + + final int itemsSize = mItems.size(); + MenuItemImpl item; + for (int i = 0; i < itemsSize; i++) { + item = mItems.get(i); + if (item.isVisible()) mVisibleItems.add(item); + } + + mIsVisibleItemsStale = false; + mIsActionItemsStale = true; + + return mVisibleItems; + } + + /** + * This method determines which menu items get to be 'action items' that will appear + * in an action bar and which items should be 'overflow items' in a secondary menu. + * The rules are as follows: + * + *

Items are considered for inclusion in the order specified within the menu. + * There is a limit of mMaxActionItems as a total count, optionally including the overflow + * menu button itself. This is a soft limit; if an item shares a group ID with an item + * previously included as an action item, the new item will stay with its group and become + * an action item itself even if it breaks the max item count limit. This is done to + * limit the conceptual complexity of the items presented within an action bar. Only a few + * unrelated concepts should be presented to the user in this space, and groups are treated + * as a single concept. + * + *

There is also a hard limit of consumed measurable space: mActionWidthLimit. This + * limit may be broken by a single item that exceeds the remaining space, but no further + * items may be added. If an item that is part of a group cannot fit within the remaining + * measured width, the entire group will be demoted to overflow. This is done to ensure room + * for navigation and other affordances in the action bar as well as reduce general UI clutter. + * + *

The space freed by demoting a full group cannot be consumed by future menu items. + * Once items begin to overflow, all future items become overflow items as well. This is + * to avoid inadvertent reordering that may break the app's intended design. + */ + public void flagActionItems() { + if (!mIsActionItemsStale) { + return; + } + + // Presenters flag action items as needed. + boolean flagged = false; + for (WeakReference ref : mPresenters) { + final MenuPresenter presenter = ref.get(); + if (presenter == null) { + mPresenters.remove(ref); + } else { + flagged |= presenter.flagActionItems(); + } + } + + if (flagged) { + mActionItems.clear(); + mNonActionItems.clear(); + ArrayList visibleItems = getVisibleItems(); + final int itemsSize = visibleItems.size(); + for (int i = 0; i < itemsSize; i++) { + MenuItemImpl item = visibleItems.get(i); + if (item.isActionButton()) { + mActionItems.add(item); + } else { + mNonActionItems.add(item); + } + } + } else { + // Nobody flagged anything, everything is a non-action item. + // (This happens during a first pass with no action-item presenters.) + mActionItems.clear(); + mNonActionItems.clear(); + mNonActionItems.addAll(getVisibleItems()); + } + mIsActionItemsStale = false; + } + + ArrayList getActionItems() { + flagActionItems(); + return mActionItems; + } + + ArrayList getNonActionItems() { + flagActionItems(); + return mNonActionItems; + } + + public void clearHeader() { + mHeaderIcon = null; + mHeaderTitle = null; + mHeaderView = null; + + onItemsChanged(false); + } + + private void setHeaderInternal(final int titleRes, final CharSequence title, final int iconRes, + final Drawable icon, final View view) { + final Resources r = getResources(); + + if (view != null) { + mHeaderView = view; + + // If using a custom view, then the title and icon aren't used + mHeaderTitle = null; + mHeaderIcon = null; + } else { + if (titleRes > 0) { + mHeaderTitle = r.getText(titleRes); + } else if (title != null) { + mHeaderTitle = title; + } + + if (iconRes > 0) { + mHeaderIcon = r.getDrawable(iconRes); + } else if (icon != null) { + mHeaderIcon = icon; + } + + // If using the title or icon, then a custom view isn't used + mHeaderView = null; + } + + // Notify of change + onItemsChanged(false); + } + + /** + * Sets the header's title. This replaces the header view. Called by the + * builder-style methods of subclasses. + * + * @param title The new title. + * @return This MenuBuilder so additional setters can be called. + */ + protected MenuBuilder setHeaderTitleInt(CharSequence title) { + setHeaderInternal(0, title, 0, null, null); + return this; + } + + /** + * Sets the header's title. This replaces the header view. Called by the + * builder-style methods of subclasses. + * + * @param titleRes The new title (as a resource ID). + * @return This MenuBuilder so additional setters can be called. + */ + protected MenuBuilder setHeaderTitleInt(int titleRes) { + setHeaderInternal(titleRes, null, 0, null, null); + return this; + } + + /** + * Sets the header's icon. This replaces the header view. Called by the + * builder-style methods of subclasses. + * + * @param icon The new icon. + * @return This MenuBuilder so additional setters can be called. + */ + protected MenuBuilder setHeaderIconInt(Drawable icon) { + setHeaderInternal(0, null, 0, icon, null); + return this; + } + + /** + * Sets the header's icon. This replaces the header view. Called by the + * builder-style methods of subclasses. + * + * @param iconRes The new icon (as a resource ID). + * @return This MenuBuilder so additional setters can be called. + */ + protected MenuBuilder setHeaderIconInt(int iconRes) { + setHeaderInternal(0, null, iconRes, null, null); + return this; + } + + /** + * Sets the header's view. This replaces the title and icon. Called by the + * builder-style methods of subclasses. + * + * @param view The new view. + * @return This MenuBuilder so additional setters can be called. + */ + protected MenuBuilder setHeaderViewInt(View view) { + setHeaderInternal(0, null, 0, null, view); + return this; + } + + public CharSequence getHeaderTitle() { + return mHeaderTitle; + } + + public Drawable getHeaderIcon() { + return mHeaderIcon; + } + + public View getHeaderView() { + return mHeaderView; + } + + /** + * Gets the root menu (if this is a submenu, find its root menu). + * @return The root menu. + */ + public MenuBuilder getRootMenu() { + return this; + } + + /** + * Sets the current menu info that is set on all items added to this menu + * (until this is called again with different menu info, in which case that + * one will be added to all subsequent item additions). + * + * @param menuInfo The extra menu information to add. + */ + public void setCurrentMenuInfo(ContextMenuInfo menuInfo) { + mCurrentMenuInfo = menuInfo; + } + + void setOptionalIconsVisible(boolean visible) { + mOptionalIconsVisible = visible; + } + + boolean getOptionalIconsVisible() { + return mOptionalIconsVisible; + } + + public boolean expandItemActionView(MenuItemImpl item) { + if (mPresenters.isEmpty()) return false; + + boolean expanded = false; + + stopDispatchingItemsChanged(); + for (WeakReference ref : mPresenters) { + final MenuPresenter presenter = ref.get(); + if (presenter == null) { + mPresenters.remove(ref); + } else if ((expanded = presenter.expandItemActionView(this, item))) { + break; + } + } + startDispatchingItemsChanged(); + + if (expanded) { + mExpandedItem = item; + } + return expanded; + } + + public boolean collapseItemActionView(MenuItemImpl item) { + if (mPresenters.isEmpty() || mExpandedItem != item) return false; + + boolean collapsed = false; + + stopDispatchingItemsChanged(); + for (WeakReference ref : mPresenters) { + final MenuPresenter presenter = ref.get(); + if (presenter == null) { + mPresenters.remove(ref); + } else if ((collapsed = presenter.collapseItemActionView(this, item))) { + break; + } + } + startDispatchingItemsChanged(); + + if (collapsed) { + mExpandedItem = null; + } + return collapsed; + } + + public MenuItemImpl getExpandedItem() { + return mExpandedItem; + } + + public boolean bindNativeOverflow(android.view.Menu menu, android.view.MenuItem.OnMenuItemClickListener listener, HashMap map) { + final List nonActionItems = getNonActionItems(); + if (nonActionItems == null || nonActionItems.size() == 0) { + return false; + } + + boolean visible = false; + menu.clear(); + for (MenuItemImpl nonActionItem : nonActionItems) { + if (!nonActionItem.isVisible()) { + continue; + } + visible = true; + + android.view.MenuItem nativeItem; + if (nonActionItem.hasSubMenu()) { + android.view.SubMenu nativeSub = menu.addSubMenu(nonActionItem.getGroupId(), nonActionItem.getItemId(), + nonActionItem.getOrder(), nonActionItem.getTitle()); + + SubMenuBuilder subMenu = (SubMenuBuilder)nonActionItem.getSubMenu(); + for (MenuItemImpl subItem : subMenu.getVisibleItems()) { + android.view.MenuItem nativeSubItem = nativeSub.add(subItem.getGroupId(), subItem.getItemId(), + subItem.getOrder(), subItem.getTitle()); + + nativeSubItem.setIcon(subItem.getIcon()); + nativeSubItem.setOnMenuItemClickListener(listener); + nativeSubItem.setEnabled(subItem.isEnabled()); + nativeSubItem.setIntent(subItem.getIntent()); + nativeSubItem.setNumericShortcut(subItem.getNumericShortcut()); + nativeSubItem.setAlphabeticShortcut(subItem.getAlphabeticShortcut()); + nativeSubItem.setTitleCondensed(subItem.getTitleCondensed()); + nativeSubItem.setCheckable(subItem.isCheckable()); + nativeSubItem.setChecked(subItem.isChecked()); + + if (subItem.isExclusiveCheckable()) { + nativeSub.setGroupCheckable(subItem.getGroupId(), true, true); + } + + map.put(nativeSubItem, subItem); + } + + nativeItem = nativeSub.getItem(); + } else { + nativeItem = menu.add(nonActionItem.getGroupId(), nonActionItem.getItemId(), + nonActionItem.getOrder(), nonActionItem.getTitle()); + } + nativeItem.setIcon(nonActionItem.getIcon()); + nativeItem.setOnMenuItemClickListener(listener); + nativeItem.setEnabled(nonActionItem.isEnabled()); + nativeItem.setIntent(nonActionItem.getIntent()); + nativeItem.setNumericShortcut(nonActionItem.getNumericShortcut()); + nativeItem.setAlphabeticShortcut(nonActionItem.getAlphabeticShortcut()); + nativeItem.setTitleCondensed(nonActionItem.getTitleCondensed()); + nativeItem.setCheckable(nonActionItem.isCheckable()); + nativeItem.setChecked(nonActionItem.isChecked()); + + if (nonActionItem.isExclusiveCheckable()) { + menu.setGroupCheckable(nonActionItem.getGroupId(), true, true); + } + + map.put(nativeItem, nonActionItem); + } + return visible; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemImpl.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemImpl.java new file mode 100644 index 000000000..f5359fb40 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemImpl.java @@ -0,0 +1,647 @@ +/* + * Copyright (C) 2006 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.actionbarsherlock.internal.view.menu; + +import android.content.ActivityNotFoundException; +import android.content.Context; +import android.content.Intent; +import android.graphics.drawable.Drawable; +import android.util.Log; +import android.view.ContextMenu.ContextMenuInfo; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewDebug; +import android.widget.LinearLayout; + +import com.actionbarsherlock.view.ActionProvider; +import com.actionbarsherlock.view.MenuItem; +import com.actionbarsherlock.view.SubMenu; + +/** + * @hide + */ +public final class MenuItemImpl implements MenuItem { + private static final String TAG = "MenuItemImpl"; + + private static final int SHOW_AS_ACTION_MASK = SHOW_AS_ACTION_NEVER | + SHOW_AS_ACTION_IF_ROOM | + SHOW_AS_ACTION_ALWAYS; + + private final int mId; + private final int mGroup; + private final int mCategoryOrder; + private final int mOrdering; + private CharSequence mTitle; + private CharSequence mTitleCondensed; + private Intent mIntent; + private char mShortcutNumericChar; + private char mShortcutAlphabeticChar; + + /** The icon's drawable which is only created as needed */ + private Drawable mIconDrawable; + /** + * The icon's resource ID which is used to get the Drawable when it is + * needed (if the Drawable isn't already obtained--only one of the two is + * needed). + */ + private int mIconResId = NO_ICON; + + /** The menu to which this item belongs */ + private MenuBuilder mMenu; + /** If this item should launch a sub menu, this is the sub menu to launch */ + private SubMenuBuilder mSubMenu; + + private Runnable mItemCallback; + private MenuItem.OnMenuItemClickListener mClickListener; + + private int mFlags = ENABLED; + private static final int CHECKABLE = 0x00000001; + private static final int CHECKED = 0x00000002; + private static final int EXCLUSIVE = 0x00000004; + private static final int HIDDEN = 0x00000008; + private static final int ENABLED = 0x00000010; + private static final int IS_ACTION = 0x00000020; + + private int mShowAsAction = SHOW_AS_ACTION_NEVER; + + private View mActionView; + private ActionProvider mActionProvider; + private OnActionExpandListener mOnActionExpandListener; + private boolean mIsActionViewExpanded = false; + + /** Used for the icon resource ID if this item does not have an icon */ + static final int NO_ICON = 0; + + /** + * Current use case is for context menu: Extra information linked to the + * View that added this item to the context menu. + */ + private ContextMenuInfo mMenuInfo; + + private static String sPrependShortcutLabel; + private static String sEnterShortcutLabel; + private static String sDeleteShortcutLabel; + private static String sSpaceShortcutLabel; + + + /** + * Instantiates this menu item. + * + * @param menu + * @param group Item ordering grouping control. The item will be added after + * all other items whose order is <= this number, and before any + * that are larger than it. This can also be used to define + * groups of items for batch state changes. Normally use 0. + * @param id Unique item ID. Use 0 if you do not need a unique ID. + * @param categoryOrder The ordering for this item. + * @param title The text to display for the item. + */ + MenuItemImpl(MenuBuilder menu, int group, int id, int categoryOrder, int ordering, + CharSequence title, int showAsAction) { + + /* TODO if (sPrependShortcutLabel == null) { + // This is instantiated from the UI thread, so no chance of sync issues + sPrependShortcutLabel = menu.getContext().getResources().getString( + com.android.internal.R.string.prepend_shortcut_label); + sEnterShortcutLabel = menu.getContext().getResources().getString( + com.android.internal.R.string.menu_enter_shortcut_label); + sDeleteShortcutLabel = menu.getContext().getResources().getString( + com.android.internal.R.string.menu_delete_shortcut_label); + sSpaceShortcutLabel = menu.getContext().getResources().getString( + com.android.internal.R.string.menu_space_shortcut_label); + }*/ + + mMenu = menu; + mId = id; + mGroup = group; + mCategoryOrder = categoryOrder; + mOrdering = ordering; + mTitle = title; + mShowAsAction = showAsAction; + } + + /** + * Invokes the item by calling various listeners or callbacks. + * + * @return true if the invocation was handled, false otherwise + */ + public boolean invoke() { + if (mClickListener != null && + mClickListener.onMenuItemClick(this)) { + return true; + } + + if (mMenu.dispatchMenuItemSelected(mMenu.getRootMenu(), this)) { + return true; + } + + if (mItemCallback != null) { + mItemCallback.run(); + return true; + } + + if (mIntent != null) { + try { + mMenu.getContext().startActivity(mIntent); + return true; + } catch (ActivityNotFoundException e) { + Log.e(TAG, "Can't find activity to handle intent; ignoring", e); + } + } + + if (mActionProvider != null && mActionProvider.onPerformDefaultAction()) { + return true; + } + + return false; + } + + public boolean isEnabled() { + return (mFlags & ENABLED) != 0; + } + + public MenuItem setEnabled(boolean enabled) { + if (enabled) { + mFlags |= ENABLED; + } else { + mFlags &= ~ENABLED; + } + + mMenu.onItemsChanged(false); + + return this; + } + + public int getGroupId() { + return mGroup; + } + + @ViewDebug.CapturedViewProperty + public int getItemId() { + return mId; + } + + public int getOrder() { + return mCategoryOrder; + } + + public int getOrdering() { + return mOrdering; + } + + public Intent getIntent() { + return mIntent; + } + + public MenuItem setIntent(Intent intent) { + mIntent = intent; + return this; + } + + Runnable getCallback() { + return mItemCallback; + } + + public MenuItem setCallback(Runnable callback) { + mItemCallback = callback; + return this; + } + + public char getAlphabeticShortcut() { + return mShortcutAlphabeticChar; + } + + public MenuItem setAlphabeticShortcut(char alphaChar) { + if (mShortcutAlphabeticChar == alphaChar) return this; + + mShortcutAlphabeticChar = Character.toLowerCase(alphaChar); + + mMenu.onItemsChanged(false); + + return this; + } + + public char getNumericShortcut() { + return mShortcutNumericChar; + } + + public MenuItem setNumericShortcut(char numericChar) { + if (mShortcutNumericChar == numericChar) return this; + + mShortcutNumericChar = numericChar; + + mMenu.onItemsChanged(false); + + return this; + } + + public MenuItem setShortcut(char numericChar, char alphaChar) { + mShortcutNumericChar = numericChar; + mShortcutAlphabeticChar = Character.toLowerCase(alphaChar); + + mMenu.onItemsChanged(false); + + return this; + } + + /** + * @return The active shortcut (based on QWERTY-mode of the menu). + */ + char getShortcut() { + return (mMenu.isQwertyMode() ? mShortcutAlphabeticChar : mShortcutNumericChar); + } + + /** + * @return The label to show for the shortcut. This includes the chording + * key (for example 'Menu+a'). Also, any non-human readable + * characters should be human readable (for example 'Menu+enter'). + */ + String getShortcutLabel() { + + char shortcut = getShortcut(); + if (shortcut == 0) { + return ""; + } + + StringBuilder sb = new StringBuilder(sPrependShortcutLabel); + switch (shortcut) { + + case '\n': + sb.append(sEnterShortcutLabel); + break; + + case '\b': + sb.append(sDeleteShortcutLabel); + break; + + case ' ': + sb.append(sSpaceShortcutLabel); + break; + + default: + sb.append(shortcut); + break; + } + + return sb.toString(); + } + + /** + * @return Whether this menu item should be showing shortcuts (depends on + * whether the menu should show shortcuts and whether this item has + * a shortcut defined) + */ + boolean shouldShowShortcut() { + // Show shortcuts if the menu is supposed to show shortcuts AND this item has a shortcut + return mMenu.isShortcutsVisible() && (getShortcut() != 0); + } + + public SubMenu getSubMenu() { + return mSubMenu; + } + + public boolean hasSubMenu() { + return mSubMenu != null; + } + + void setSubMenu(SubMenuBuilder subMenu) { + mSubMenu = subMenu; + + subMenu.setHeaderTitle(getTitle()); + } + + @ViewDebug.CapturedViewProperty + public CharSequence getTitle() { + return mTitle; + } + + /** + * Gets the title for a particular {@link ItemView} + * + * @param itemView The ItemView that is receiving the title + * @return Either the title or condensed title based on what the ItemView + * prefers + */ + CharSequence getTitleForItemView(MenuView.ItemView itemView) { + return ((itemView != null) && itemView.prefersCondensedTitle()) + ? getTitleCondensed() + : getTitle(); + } + + public MenuItem setTitle(CharSequence title) { + mTitle = title; + + mMenu.onItemsChanged(false); + + if (mSubMenu != null) { + mSubMenu.setHeaderTitle(title); + } + + return this; + } + + public MenuItem setTitle(int title) { + return setTitle(mMenu.getContext().getString(title)); + } + + public CharSequence getTitleCondensed() { + return mTitleCondensed != null ? mTitleCondensed : mTitle; + } + + public MenuItem setTitleCondensed(CharSequence title) { + mTitleCondensed = title; + + // Could use getTitle() in the loop below, but just cache what it would do here + if (title == null) { + title = mTitle; + } + + mMenu.onItemsChanged(false); + + return this; + } + + public Drawable getIcon() { + if (mIconDrawable != null) { + return mIconDrawable; + } + + if (mIconResId != NO_ICON) { + return mMenu.getResources().getDrawable(mIconResId); + } + + return null; + } + + public MenuItem setIcon(Drawable icon) { + mIconResId = NO_ICON; + mIconDrawable = icon; + mMenu.onItemsChanged(false); + + return this; + } + + public MenuItem setIcon(int iconResId) { + mIconDrawable = null; + mIconResId = iconResId; + + // If we have a view, we need to push the Drawable to them + mMenu.onItemsChanged(false); + + return this; + } + + public boolean isCheckable() { + return (mFlags & CHECKABLE) == CHECKABLE; + } + + public MenuItem setCheckable(boolean checkable) { + final int oldFlags = mFlags; + mFlags = (mFlags & ~CHECKABLE) | (checkable ? CHECKABLE : 0); + if (oldFlags != mFlags) { + mMenu.onItemsChanged(false); + } + + return this; + } + + public void setExclusiveCheckable(boolean exclusive) { + mFlags = (mFlags & ~EXCLUSIVE) | (exclusive ? EXCLUSIVE : 0); + } + + public boolean isExclusiveCheckable() { + return (mFlags & EXCLUSIVE) != 0; + } + + public boolean isChecked() { + return (mFlags & CHECKED) == CHECKED; + } + + public MenuItem setChecked(boolean checked) { + if ((mFlags & EXCLUSIVE) != 0) { + // Call the method on the Menu since it knows about the others in this + // exclusive checkable group + mMenu.setExclusiveItemChecked(this); + } else { + setCheckedInt(checked); + } + + return this; + } + + void setCheckedInt(boolean checked) { + final int oldFlags = mFlags; + mFlags = (mFlags & ~CHECKED) | (checked ? CHECKED : 0); + if (oldFlags != mFlags) { + mMenu.onItemsChanged(false); + } + } + + public boolean isVisible() { + return (mFlags & HIDDEN) == 0; + } + + /** + * Changes the visibility of the item. This method DOES NOT notify the + * parent menu of a change in this item, so this should only be called from + * methods that will eventually trigger this change. If unsure, use {@link #setVisible(boolean)} + * instead. + * + * @param shown Whether to show (true) or hide (false). + * @return Whether the item's shown state was changed + */ + boolean setVisibleInt(boolean shown) { + final int oldFlags = mFlags; + mFlags = (mFlags & ~HIDDEN) | (shown ? 0 : HIDDEN); + return oldFlags != mFlags; + } + + public MenuItem setVisible(boolean shown) { + // Try to set the shown state to the given state. If the shown state was changed + // (i.e. the previous state isn't the same as given state), notify the parent menu that + // the shown state has changed for this item + if (setVisibleInt(shown)) mMenu.onItemVisibleChanged(this); + + return this; + } + + public MenuItem setOnMenuItemClickListener(MenuItem.OnMenuItemClickListener clickListener) { + mClickListener = clickListener; + return this; + } + + @Override + public String toString() { + return mTitle.toString(); + } + + void setMenuInfo(ContextMenuInfo menuInfo) { + mMenuInfo = menuInfo; + } + + public ContextMenuInfo getMenuInfo() { + return mMenuInfo; + } + + public void actionFormatChanged() { + mMenu.onItemActionRequestChanged(this); + } + + /** + * @return Whether the menu should show icons for menu items. + */ + public boolean shouldShowIcon() { + return mMenu.getOptionalIconsVisible(); + } + + public boolean isActionButton() { + return (mFlags & IS_ACTION) == IS_ACTION; + } + + public boolean requestsActionButton() { + return (mShowAsAction & SHOW_AS_ACTION_IF_ROOM) == SHOW_AS_ACTION_IF_ROOM; + } + + public boolean requiresActionButton() { + return (mShowAsAction & SHOW_AS_ACTION_ALWAYS) == SHOW_AS_ACTION_ALWAYS; + } + + public void setIsActionButton(boolean isActionButton) { + if (isActionButton) { + mFlags |= IS_ACTION; + } else { + mFlags &= ~IS_ACTION; + } + } + + public boolean showsTextAsAction() { + return (mShowAsAction & SHOW_AS_ACTION_WITH_TEXT) == SHOW_AS_ACTION_WITH_TEXT; + } + + public void setShowAsAction(int actionEnum) { + switch (actionEnum & SHOW_AS_ACTION_MASK) { + case SHOW_AS_ACTION_ALWAYS: + case SHOW_AS_ACTION_IF_ROOM: + case SHOW_AS_ACTION_NEVER: + // Looks good! + break; + + default: + // Mutually exclusive options selected! + throw new IllegalArgumentException("SHOW_AS_ACTION_ALWAYS, SHOW_AS_ACTION_IF_ROOM," + + " and SHOW_AS_ACTION_NEVER are mutually exclusive."); + } + mShowAsAction = actionEnum; + mMenu.onItemActionRequestChanged(this); + } + + public MenuItem setActionView(View view) { + mActionView = view; + mActionProvider = null; + if (view != null && view.getId() == View.NO_ID && mId > 0) { + view.setId(mId); + } + mMenu.onItemActionRequestChanged(this); + return this; + } + + public MenuItem setActionView(int resId) { + final Context context = mMenu.getContext(); + final LayoutInflater inflater = LayoutInflater.from(context); + setActionView(inflater.inflate(resId, new LinearLayout(context), false)); + return this; + } + + public View getActionView() { + if (mActionView != null) { + return mActionView; + } else if (mActionProvider != null) { + mActionView = mActionProvider.onCreateActionView(); + return mActionView; + } else { + return null; + } + } + + public ActionProvider getActionProvider() { + return mActionProvider; + } + + public MenuItem setActionProvider(ActionProvider actionProvider) { + mActionView = null; + mActionProvider = actionProvider; + mMenu.onItemsChanged(true); // Measurement can be changed + return this; + } + + @Override + public MenuItem setShowAsActionFlags(int actionEnum) { + setShowAsAction(actionEnum); + return this; + } + + @Override + public boolean expandActionView() { + if ((mShowAsAction & SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW) == 0 || mActionView == null) { + return false; + } + + if (mOnActionExpandListener == null || + mOnActionExpandListener.onMenuItemActionExpand(this)) { + return mMenu.expandItemActionView(this); + } + + return false; + } + + @Override + public boolean collapseActionView() { + if ((mShowAsAction & SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW) == 0) { + return false; + } + if (mActionView == null) { + // We're already collapsed if we have no action view. + return true; + } + + if (mOnActionExpandListener == null || + mOnActionExpandListener.onMenuItemActionCollapse(this)) { + return mMenu.collapseItemActionView(this); + } + + return false; + } + + @Override + public MenuItem setOnActionExpandListener(OnActionExpandListener listener) { + mOnActionExpandListener = listener; + return this; + } + + public boolean hasCollapsibleActionView() { + return (mShowAsAction & SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW) != 0 && mActionView != null; + } + + public void setActionViewExpanded(boolean isExpanded) { + mIsActionViewExpanded = isExpanded; + mMenu.onItemsChanged(false); + } + + public boolean isActionViewExpanded() { + return mIsActionViewExpanded; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemWrapper.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemWrapper.java new file mode 100644 index 000000000..907a7aa04 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuItemWrapper.java @@ -0,0 +1,292 @@ +package com.actionbarsherlock.internal.view.menu; + +import android.content.Intent; +import android.graphics.drawable.Drawable; +import android.view.View; +import android.view.ContextMenu.ContextMenuInfo; +import com.actionbarsherlock.internal.view.ActionProviderWrapper; +import com.actionbarsherlock.view.ActionProvider; +import com.actionbarsherlock.view.MenuItem; +import com.actionbarsherlock.view.SubMenu; + +public class MenuItemWrapper implements MenuItem, android.view.MenuItem.OnMenuItemClickListener { + private final android.view.MenuItem mNativeItem; + private SubMenu mSubMenu = null; + private OnMenuItemClickListener mMenuItemClickListener = null; + private OnActionExpandListener mActionExpandListener = null; + private android.view.MenuItem.OnActionExpandListener mNativeActionExpandListener = null; + + + public MenuItemWrapper(android.view.MenuItem nativeItem) { + if (nativeItem == null) { + throw new IllegalStateException("Wrapped menu item cannot be null."); + } + mNativeItem = nativeItem; + } + + + @Override + public int getItemId() { + return mNativeItem.getItemId(); + } + + @Override + public int getGroupId() { + return mNativeItem.getGroupId(); + } + + @Override + public int getOrder() { + return mNativeItem.getOrder(); + } + + @Override + public MenuItem setTitle(CharSequence title) { + mNativeItem.setTitle(title); + return this; + } + + @Override + public MenuItem setTitle(int title) { + mNativeItem.setTitle(title); + return this; + } + + @Override + public CharSequence getTitle() { + return mNativeItem.getTitle(); + } + + @Override + public MenuItem setTitleCondensed(CharSequence title) { + mNativeItem.setTitleCondensed(title); + return this; + } + + @Override + public CharSequence getTitleCondensed() { + return mNativeItem.getTitleCondensed(); + } + + @Override + public MenuItem setIcon(Drawable icon) { + mNativeItem.setIcon(icon); + return this; + } + + @Override + public MenuItem setIcon(int iconRes) { + mNativeItem.setIcon(iconRes); + return this; + } + + @Override + public Drawable getIcon() { + return mNativeItem.getIcon(); + } + + @Override + public MenuItem setIntent(Intent intent) { + mNativeItem.setIntent(intent); + return this; + } + + @Override + public Intent getIntent() { + return mNativeItem.getIntent(); + } + + @Override + public MenuItem setShortcut(char numericChar, char alphaChar) { + mNativeItem.setShortcut(numericChar, alphaChar); + return this; + } + + @Override + public MenuItem setNumericShortcut(char numericChar) { + mNativeItem.setNumericShortcut(numericChar); + return this; + } + + @Override + public char getNumericShortcut() { + return mNativeItem.getNumericShortcut(); + } + + @Override + public MenuItem setAlphabeticShortcut(char alphaChar) { + mNativeItem.setAlphabeticShortcut(alphaChar); + return this; + } + + @Override + public char getAlphabeticShortcut() { + return mNativeItem.getAlphabeticShortcut(); + } + + @Override + public MenuItem setCheckable(boolean checkable) { + mNativeItem.setCheckable(checkable); + return this; + } + + @Override + public boolean isCheckable() { + return mNativeItem.isCheckable(); + } + + @Override + public MenuItem setChecked(boolean checked) { + mNativeItem.setChecked(checked); + return this; + } + + @Override + public boolean isChecked() { + return mNativeItem.isChecked(); + } + + @Override + public MenuItem setVisible(boolean visible) { + mNativeItem.setVisible(visible); + return this; + } + + @Override + public boolean isVisible() { + return mNativeItem.isVisible(); + } + + @Override + public MenuItem setEnabled(boolean enabled) { + mNativeItem.setEnabled(enabled); + return this; + } + + @Override + public boolean isEnabled() { + return mNativeItem.isEnabled(); + } + + @Override + public boolean hasSubMenu() { + return mNativeItem.hasSubMenu(); + } + + @Override + public SubMenu getSubMenu() { + if (hasSubMenu() && (mSubMenu == null)) { + mSubMenu = new SubMenuWrapper(mNativeItem.getSubMenu()); + } + return mSubMenu; + } + + @Override + public MenuItem setOnMenuItemClickListener(OnMenuItemClickListener menuItemClickListener) { + mMenuItemClickListener = menuItemClickListener; + //Register ourselves as the listener to proxy + mNativeItem.setOnMenuItemClickListener(this); + return this; + } + + @Override + public boolean onMenuItemClick(android.view.MenuItem item) { + if (mMenuItemClickListener != null) { + return mMenuItemClickListener.onMenuItemClick(this); + } + return false; + } + + @Override + public ContextMenuInfo getMenuInfo() { + return mNativeItem.getMenuInfo(); + } + + @Override + public void setShowAsAction(int actionEnum) { + mNativeItem.setShowAsAction(actionEnum); + } + + @Override + public MenuItem setShowAsActionFlags(int actionEnum) { + mNativeItem.setShowAsActionFlags(actionEnum); + return this; + } + + @Override + public MenuItem setActionView(View view) { + mNativeItem.setActionView(view); + return this; + } + + @Override + public MenuItem setActionView(int resId) { + mNativeItem.setActionView(resId); + return this; + } + + @Override + public View getActionView() { + return mNativeItem.getActionView(); + } + + @Override + public MenuItem setActionProvider(ActionProvider actionProvider) { + mNativeItem.setActionProvider(new ActionProviderWrapper(actionProvider)); + return this; + } + + @Override + public ActionProvider getActionProvider() { + android.view.ActionProvider nativeProvider = mNativeItem.getActionProvider(); + if (nativeProvider != null && nativeProvider instanceof ActionProviderWrapper) { + return ((ActionProviderWrapper)nativeProvider).unwrap(); + } + return null; + } + + @Override + public boolean expandActionView() { + return mNativeItem.expandActionView(); + } + + @Override + public boolean collapseActionView() { + return mNativeItem.collapseActionView(); + } + + @Override + public boolean isActionViewExpanded() { + return mNativeItem.isActionViewExpanded(); + } + + @Override + public MenuItem setOnActionExpandListener(OnActionExpandListener listener) { + mActionExpandListener = listener; + + if (mNativeActionExpandListener == null) { + mNativeActionExpandListener = new android.view.MenuItem.OnActionExpandListener() { + @Override + public boolean onMenuItemActionExpand(android.view.MenuItem menuItem) { + if (mActionExpandListener != null) { + return mActionExpandListener.onMenuItemActionExpand(MenuItemWrapper.this); + } + return false; + } + + @Override + public boolean onMenuItemActionCollapse(android.view.MenuItem menuItem) { + if (mActionExpandListener != null) { + return mActionExpandListener.onMenuItemActionCollapse(MenuItemWrapper.this); + } + return false; + } + }; + + //Register our inner-class as the listener to proxy method calls + mNativeItem.setOnActionExpandListener(mNativeActionExpandListener); + } + + return this; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuPopupHelper.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuPopupHelper.java new file mode 100644 index 000000000..f030de310 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuPopupHelper.java @@ -0,0 +1,376 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.view.menu; + +import java.util.ArrayList; +import android.content.Context; +import android.content.res.Resources; +import android.database.DataSetObserver; +import android.os.Parcelable; +import android.view.KeyEvent; +import android.view.LayoutInflater; +import android.view.View; +import android.view.View.MeasureSpec; +import android.view.ViewGroup; +import android.view.ViewTreeObserver; +import android.widget.AdapterView; +import android.widget.BaseAdapter; +import android.widget.FrameLayout; +import android.widget.ListAdapter; +import android.widget.PopupWindow; +import com.actionbarsherlock.R; +import com.actionbarsherlock.internal.view.View_HasStateListenerSupport; +import com.actionbarsherlock.internal.view.View_OnAttachStateChangeListener; +import com.actionbarsherlock.internal.widget.IcsListPopupWindow; +import com.actionbarsherlock.view.MenuItem; + +/** + * Presents a menu as a small, simple popup anchored to another view. + * @hide + */ +public class MenuPopupHelper implements AdapterView.OnItemClickListener, View.OnKeyListener, + ViewTreeObserver.OnGlobalLayoutListener, PopupWindow.OnDismissListener, + View_OnAttachStateChangeListener, MenuPresenter { + //UNUSED private static final String TAG = "MenuPopupHelper"; + + static final int ITEM_LAYOUT = R.layout.abs__popup_menu_item_layout; + + private Context mContext; + private LayoutInflater mInflater; + private IcsListPopupWindow mPopup; + private MenuBuilder mMenu; + private int mPopupMaxWidth; + private View mAnchorView; + private boolean mOverflowOnly; + private ViewTreeObserver mTreeObserver; + + private MenuAdapter mAdapter; + + private Callback mPresenterCallback; + + boolean mForceShowIcon; + + private ViewGroup mMeasureParent; + + public MenuPopupHelper(Context context, MenuBuilder menu) { + this(context, menu, null, false); + } + + public MenuPopupHelper(Context context, MenuBuilder menu, View anchorView) { + this(context, menu, anchorView, false); + } + + public MenuPopupHelper(Context context, MenuBuilder menu, + View anchorView, boolean overflowOnly) { + mContext = context; + mInflater = LayoutInflater.from(context); + mMenu = menu; + mOverflowOnly = overflowOnly; + + final Resources res = context.getResources(); + mPopupMaxWidth = Math.max(res.getDisplayMetrics().widthPixels / 2, + res.getDimensionPixelSize(R.dimen.abs__config_prefDialogWidth)); + + mAnchorView = anchorView; + + menu.addMenuPresenter(this); + } + + public void setAnchorView(View anchor) { + mAnchorView = anchor; + } + + public void setForceShowIcon(boolean forceShow) { + mForceShowIcon = forceShow; + } + + public void show() { + if (!tryShow()) { + throw new IllegalStateException("MenuPopupHelper cannot be used without an anchor"); + } + } + + public boolean tryShow() { + mPopup = new IcsListPopupWindow(mContext, null, R.attr.popupMenuStyle); + mPopup.setOnDismissListener(this); + mPopup.setOnItemClickListener(this); + + mAdapter = new MenuAdapter(mMenu); + mPopup.setAdapter(mAdapter); + mPopup.setModal(true); + + View anchor = mAnchorView; + if (anchor != null) { + final boolean addGlobalListener = mTreeObserver == null; + mTreeObserver = anchor.getViewTreeObserver(); // Refresh to latest + if (addGlobalListener) mTreeObserver.addOnGlobalLayoutListener(this); + ((View_HasStateListenerSupport)anchor).addOnAttachStateChangeListener(this); + mPopup.setAnchorView(anchor); + } else { + return false; + } + + mPopup.setContentWidth(Math.min(measureContentWidth(mAdapter), mPopupMaxWidth)); + mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED); + mPopup.show(); + mPopup.getListView().setOnKeyListener(this); + return true; + } + + public void dismiss() { + if (isShowing()) { + mPopup.dismiss(); + } + } + + public void onDismiss() { + mPopup = null; + mMenu.close(); + if (mTreeObserver != null) { + if (!mTreeObserver.isAlive()) mTreeObserver = mAnchorView.getViewTreeObserver(); + mTreeObserver.removeGlobalOnLayoutListener(this); + mTreeObserver = null; + } + ((View_HasStateListenerSupport)mAnchorView).removeOnAttachStateChangeListener(this); + } + + public boolean isShowing() { + return mPopup != null && mPopup.isShowing(); + } + + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + MenuAdapter adapter = mAdapter; + adapter.mAdapterMenu.performItemAction(adapter.getItem(position), 0); + } + + public boolean onKey(View v, int keyCode, KeyEvent event) { + if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_MENU) { + dismiss(); + return true; + } + return false; + } + + private int measureContentWidth(ListAdapter adapter) { + // Menus don't tend to be long, so this is more sane than it looks. + int width = 0; + View itemView = null; + int itemType = 0; + final int widthMeasureSpec = + MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); + final int heightMeasureSpec = + MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); + final int count = adapter.getCount(); + for (int i = 0; i < count; i++) { + final int positionType = adapter.getItemViewType(i); + if (positionType != itemType) { + itemType = positionType; + itemView = null; + } + if (mMeasureParent == null) { + mMeasureParent = new FrameLayout(mContext); + } + itemView = adapter.getView(i, itemView, mMeasureParent); + itemView.measure(widthMeasureSpec, heightMeasureSpec); + width = Math.max(width, itemView.getMeasuredWidth()); + } + return width; + } + + @Override + public void onGlobalLayout() { + if (isShowing()) { + final View anchor = mAnchorView; + if (anchor == null || !anchor.isShown()) { + dismiss(); + } else if (isShowing()) { + // Recompute window size and position + mPopup.show(); + } + } + } + + @Override + public void onViewAttachedToWindow(View v) { + } + + @Override + public void onViewDetachedFromWindow(View v) { + if (mTreeObserver != null) { + if (!mTreeObserver.isAlive()) mTreeObserver = v.getViewTreeObserver(); + mTreeObserver.removeGlobalOnLayoutListener(this); + } + ((View_HasStateListenerSupport)v).removeOnAttachStateChangeListener(this); + } + + @Override + public void initForMenu(Context context, MenuBuilder menu) { + // Don't need to do anything; we added as a presenter in the constructor. + } + + @Override + public MenuView getMenuView(ViewGroup root) { + throw new UnsupportedOperationException("MenuPopupHelpers manage their own views"); + } + + @Override + public void updateMenuView(boolean cleared) { + if (mAdapter != null) mAdapter.notifyDataSetChanged(); + } + + @Override + public void setCallback(Callback cb) { + mPresenterCallback = cb; + } + + @Override + public boolean onSubMenuSelected(SubMenuBuilder subMenu) { + if (subMenu.hasVisibleItems()) { + MenuPopupHelper subPopup = new MenuPopupHelper(mContext, subMenu, mAnchorView, false); + subPopup.setCallback(mPresenterCallback); + + boolean preserveIconSpacing = false; + final int count = subMenu.size(); + for (int i = 0; i < count; i++) { + MenuItem childItem = subMenu.getItem(i); + if (childItem.isVisible() && childItem.getIcon() != null) { + preserveIconSpacing = true; + break; + } + } + subPopup.setForceShowIcon(preserveIconSpacing); + + if (subPopup.tryShow()) { + if (mPresenterCallback != null) { + mPresenterCallback.onOpenSubMenu(subMenu); + } + return true; + } + } + return false; + } + + @Override + public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) { + // Only care about the (sub)menu we're presenting. + if (menu != mMenu) return; + + dismiss(); + if (mPresenterCallback != null) { + mPresenterCallback.onCloseMenu(menu, allMenusAreClosing); + } + } + + @Override + public boolean flagActionItems() { + return false; + } + + public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item) { + return false; + } + + public boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item) { + return false; + } + + @Override + public int getId() { + return 0; + } + + @Override + public Parcelable onSaveInstanceState() { + return null; + } + + @Override + public void onRestoreInstanceState(Parcelable state) { + } + + private class MenuAdapter extends BaseAdapter { + private MenuBuilder mAdapterMenu; + private int mExpandedIndex = -1; + + public MenuAdapter(MenuBuilder menu) { + mAdapterMenu = menu; + registerDataSetObserver(new ExpandedIndexObserver()); + findExpandedIndex(); + } + + public int getCount() { + ArrayList items = mOverflowOnly ? + mAdapterMenu.getNonActionItems() : mAdapterMenu.getVisibleItems(); + if (mExpandedIndex < 0) { + return items.size(); + } + return items.size() - 1; + } + + public MenuItemImpl getItem(int position) { + ArrayList items = mOverflowOnly ? + mAdapterMenu.getNonActionItems() : mAdapterMenu.getVisibleItems(); + if (mExpandedIndex >= 0 && position >= mExpandedIndex) { + position++; + } + return items.get(position); + } + + public long getItemId(int position) { + // Since a menu item's ID is optional, we'll use the position as an + // ID for the item in the AdapterView + return position; + } + + public View getView(int position, View convertView, ViewGroup parent) { + if (convertView == null) { + convertView = mInflater.inflate(ITEM_LAYOUT, parent, false); + } + + MenuView.ItemView itemView = (MenuView.ItemView) convertView; + if (mForceShowIcon) { + ((ListMenuItemView) convertView).setForceShowIcon(true); + } + itemView.initialize(getItem(position), 0); + return convertView; + } + + void findExpandedIndex() { + final MenuItemImpl expandedItem = mMenu.getExpandedItem(); + if (expandedItem != null) { + final ArrayList items = mMenu.getNonActionItems(); + final int count = items.size(); + for (int i = 0; i < count; i++) { + final MenuItemImpl item = items.get(i); + if (item == expandedItem) { + mExpandedIndex = i; + return; + } + } + } + mExpandedIndex = -1; + } + } + + private class ExpandedIndexObserver extends DataSetObserver { + @Override + public void onChanged() { + mAdapter.findExpandedIndex(); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuPresenter.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuPresenter.java new file mode 100644 index 000000000..c3f35472c --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuPresenter.java @@ -0,0 +1,148 @@ +/* + * Copyright (C) 2011 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.actionbarsherlock.internal.view.menu; + +import android.content.Context; +import android.os.Parcelable; +import android.view.ViewGroup; + +/** + * A MenuPresenter is responsible for building views for a Menu object. + * It takes over some responsibility from the old style monolithic MenuBuilder class. + */ +public interface MenuPresenter { + /** + * Called by menu implementation to notify another component of open/close events. + */ + public interface Callback { + /** + * Called when a menu is closing. + * @param menu + * @param allMenusAreClosing + */ + public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing); + + /** + * Called when a submenu opens. Useful for notifying the application + * of menu state so that it does not attempt to hide the action bar + * while a submenu is open or similar. + * + * @param subMenu Submenu currently being opened + * @return true if the Callback will handle presenting the submenu, false if + * the presenter should attempt to do so. + */ + public boolean onOpenSubMenu(MenuBuilder subMenu); + } + + /** + * Initialize this presenter for the given context and menu. + * This method is called by MenuBuilder when a presenter is + * added. See {@link MenuBuilder#addMenuPresenter(MenuPresenter)} + * + * @param context Context for this presenter; used for view creation and resource management + * @param menu Menu to host + */ + public void initForMenu(Context context, MenuBuilder menu); + + /** + * Retrieve a MenuView to display the menu specified in + * {@link #initForMenu(Context, Menu)}. + * + * @param root Intended parent of the MenuView. + * @return A freshly created MenuView. + */ + public MenuView getMenuView(ViewGroup root); + + /** + * Update the menu UI in response to a change. Called by + * MenuBuilder during the normal course of operation. + * + * @param cleared true if the menu was entirely cleared + */ + public void updateMenuView(boolean cleared); + + /** + * Set a callback object that will be notified of menu events + * related to this specific presentation. + * @param cb Callback that will be notified of future events + */ + public void setCallback(Callback cb); + + /** + * Called by Menu implementations to indicate that a submenu item + * has been selected. An active Callback should be notified, and + * if applicable the presenter should present the submenu. + * + * @param subMenu SubMenu being opened + * @return true if the the event was handled, false otherwise. + */ + public boolean onSubMenuSelected(SubMenuBuilder subMenu); + + /** + * Called by Menu implementations to indicate that a menu or submenu is + * closing. Presenter implementations should close the representation + * of the menu indicated as necessary and notify a registered callback. + * + * @param menu Menu or submenu that is closing. + * @param allMenusAreClosing True if all associated menus are closing. + */ + public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing); + + /** + * Called by Menu implementations to flag items that will be shown as actions. + * @return true if this presenter changed the action status of any items. + */ + public boolean flagActionItems(); + + /** + * Called when a menu item with a collapsable action view should expand its action view. + * + * @param menu Menu containing the item to be expanded + * @param item Item to be expanded + * @return true if this presenter expanded the action view, false otherwise. + */ + public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item); + + /** + * Called when a menu item with a collapsable action view should collapse its action view. + * + * @param menu Menu containing the item to be collapsed + * @param item Item to be collapsed + * @return true if this presenter collapsed the action view, false otherwise. + */ + public boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item); + + /** + * Returns an ID for determining how to save/restore instance state. + * @return a valid ID value. + */ + public int getId(); + + /** + * Returns a Parcelable describing the current state of the presenter. + * It will be passed to the {@link #onRestoreInstanceState(Parcelable)} + * method of the presenter sharing the same ID later. + * @return The saved instance state + */ + public Parcelable onSaveInstanceState(); + + /** + * Supplies the previously saved instance state to be restored. + * @param state The previously saved instance state + */ + public void onRestoreInstanceState(Parcelable state); +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuView.java new file mode 100644 index 000000000..323ba2d88 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuView.java @@ -0,0 +1,120 @@ +/* + * Copyright (C) 2006 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.actionbarsherlock.internal.view.menu; + +import android.graphics.drawable.Drawable; + +/** + * Minimal interface for a menu view. {@link #initialize(MenuBuilder)} must be called for the + * menu to be functional. + * + * @hide + */ +public interface MenuView { + /** + * Initializes the menu to the given menu. This should be called after the + * view is inflated. + * + * @param menu The menu that this MenuView should display. + */ + public void initialize(MenuBuilder menu); + + /** + * Returns the default animations to be used for this menu when entering/exiting. + * @return A resource ID for the default animations to be used for this menu. + */ + public int getWindowAnimations(); + + /** + * Minimal interface for a menu item view. {@link #initialize(MenuItemImpl, int)} must be called + * for the item to be functional. + */ + public interface ItemView { + /** + * Initializes with the provided MenuItemData. This should be called after the view is + * inflated. + * @param itemData The item that this ItemView should display. + * @param menuType The type of this menu, one of + * {@link MenuBuilder#TYPE_ICON}, {@link MenuBuilder#TYPE_EXPANDED}, + * {@link MenuBuilder#TYPE_DIALOG}). + */ + public void initialize(MenuItemImpl itemData, int menuType); + + /** + * Gets the item data that this view is displaying. + * @return the item data, or null if there is not one + */ + public MenuItemImpl getItemData(); + + /** + * Sets the title of the item view. + * @param title The title to set. + */ + public void setTitle(CharSequence title); + + /** + * Sets the enabled state of the item view. + * @param enabled Whether the item view should be enabled. + */ + public void setEnabled(boolean enabled); + + /** + * Displays the checkbox for the item view. This does not ensure the item view will be + * checked, for that use {@link #setChecked}. + * @param checkable Whether to display the checkbox or to hide it + */ + public void setCheckable(boolean checkable); + + /** + * Checks the checkbox for the item view. If the checkbox is hidden, it will NOT be + * made visible, call {@link #setCheckable(boolean)} for that. + * @param checked Whether the checkbox should be checked + */ + public void setChecked(boolean checked); + + /** + * Sets the shortcut for the item. + * @param showShortcut Whether a shortcut should be shown(if false, the value of + * shortcutKey should be ignored). + * @param shortcutKey The shortcut key that should be shown on the ItemView. + */ + public void setShortcut(boolean showShortcut, char shortcutKey); + + /** + * Set the icon of this item view. + * @param icon The icon of this item. null to hide the icon. + */ + public void setIcon(Drawable icon); + + /** + * Whether this item view prefers displaying the condensed title rather + * than the normal title. If a condensed title is not available, the + * normal title will be used. + * + * @return Whether this item view prefers displaying the condensed + * title. + */ + public boolean prefersCondensedTitle(); + + /** + * Whether this item view shows an icon. + * + * @return Whether this item view shows an icon. + */ + public boolean showsIcon(); + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuWrapper.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuWrapper.java new file mode 100644 index 000000000..64fc4aeaa --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/MenuWrapper.java @@ -0,0 +1,180 @@ +package com.actionbarsherlock.internal.view.menu; + +import java.util.WeakHashMap; +import android.content.ComponentName; +import android.content.Intent; +import android.view.KeyEvent; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuItem; +import com.actionbarsherlock.view.SubMenu; + +public class MenuWrapper implements Menu { + private final android.view.Menu mNativeMenu; + + private final WeakHashMap mNativeMap = + new WeakHashMap(); + + + public MenuWrapper(android.view.Menu nativeMenu) { + mNativeMenu = nativeMenu; + } + + public android.view.Menu unwrap() { + return mNativeMenu; + } + + private MenuItem addInternal(android.view.MenuItem nativeItem) { + MenuItem item = new MenuItemWrapper(nativeItem); + mNativeMap.put(nativeItem, item); + return item; + } + + @Override + public MenuItem add(CharSequence title) { + return addInternal(mNativeMenu.add(title)); + } + + @Override + public MenuItem add(int titleRes) { + return addInternal(mNativeMenu.add(titleRes)); + } + + @Override + public MenuItem add(int groupId, int itemId, int order, CharSequence title) { + return addInternal(mNativeMenu.add(groupId, itemId, order, title)); + } + + @Override + public MenuItem add(int groupId, int itemId, int order, int titleRes) { + return addInternal(mNativeMenu.add(groupId, itemId, order, titleRes)); + } + + private SubMenu addInternal(android.view.SubMenu nativeSubMenu) { + SubMenu subMenu = new SubMenuWrapper(nativeSubMenu); + android.view.MenuItem nativeItem = nativeSubMenu.getItem(); + MenuItem item = subMenu.getItem(); + mNativeMap.put(nativeItem, item); + return subMenu; + } + + @Override + public SubMenu addSubMenu(CharSequence title) { + return addInternal(mNativeMenu.addSubMenu(title)); + } + + @Override + public SubMenu addSubMenu(int titleRes) { + return addInternal(mNativeMenu.addSubMenu(titleRes)); + } + + @Override + public SubMenu addSubMenu(int groupId, int itemId, int order, CharSequence title) { + return addInternal(mNativeMenu.addSubMenu(groupId, itemId, order, title)); + } + + @Override + public SubMenu addSubMenu(int groupId, int itemId, int order, int titleRes) { + return addInternal(mNativeMenu.addSubMenu(groupId, itemId, order, titleRes)); + } + + @Override + public int addIntentOptions(int groupId, int itemId, int order, ComponentName caller, Intent[] specifics, Intent intent, int flags, MenuItem[] outSpecificItems) { + android.view.MenuItem[] nativeOutItems = new android.view.MenuItem[outSpecificItems.length]; + int result = mNativeMenu.addIntentOptions(groupId, itemId, order, caller, specifics, intent, flags, nativeOutItems); + for (int i = 0, length = outSpecificItems.length; i < length; i++) { + outSpecificItems[i] = new MenuItemWrapper(nativeOutItems[i]); + } + return result; + } + + @Override + public void removeItem(int id) { + mNativeMenu.removeItem(id); + } + + @Override + public void removeGroup(int groupId) { + mNativeMenu.removeGroup(groupId); + } + + @Override + public void clear() { + mNativeMap.clear(); + mNativeMenu.clear(); + } + + @Override + public void setGroupCheckable(int group, boolean checkable, boolean exclusive) { + mNativeMenu.setGroupCheckable(group, checkable, exclusive); + } + + @Override + public void setGroupVisible(int group, boolean visible) { + mNativeMenu.setGroupVisible(group, visible); + } + + @Override + public void setGroupEnabled(int group, boolean enabled) { + mNativeMenu.setGroupEnabled(group, enabled); + } + + @Override + public boolean hasVisibleItems() { + return mNativeMenu.hasVisibleItems(); + } + + @Override + public MenuItem findItem(int id) { + android.view.MenuItem nativeItem = mNativeMenu.findItem(id); + return findItem(nativeItem); + } + + public MenuItem findItem(android.view.MenuItem nativeItem) { + if (nativeItem == null) { + return null; + } + + MenuItem wrapped = mNativeMap.get(nativeItem); + if (wrapped != null) { + return wrapped; + } + + return addInternal(nativeItem); + } + + @Override + public int size() { + return mNativeMenu.size(); + } + + @Override + public MenuItem getItem(int index) { + android.view.MenuItem nativeItem = mNativeMenu.getItem(index); + return findItem(nativeItem); + } + + @Override + public void close() { + mNativeMenu.close(); + } + + @Override + public boolean performShortcut(int keyCode, KeyEvent event, int flags) { + return mNativeMenu.performShortcut(keyCode, event, flags); + } + + @Override + public boolean isShortcutKey(int keyCode, KeyEvent event) { + return mNativeMenu.isShortcutKey(keyCode, event); + } + + @Override + public boolean performIdentifierAction(int id, int flags) { + return mNativeMenu.performIdentifierAction(id, flags); + } + + @Override + public void setQwertyMode(boolean isQwerty) { + mNativeMenu.setQwertyMode(isQwerty); + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/SubMenuBuilder.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/SubMenuBuilder.java new file mode 100644 index 000000000..6679cf386 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/SubMenuBuilder.java @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2006 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.actionbarsherlock.internal.view.menu; + +import android.content.Context; +import android.graphics.drawable.Drawable; +import android.view.View; + +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuItem; +import com.actionbarsherlock.view.SubMenu; + +/** + * The model for a sub menu, which is an extension of the menu. Most methods are proxied to + * the parent menu. + */ +public class SubMenuBuilder extends MenuBuilder implements SubMenu { + private MenuBuilder mParentMenu; + private MenuItemImpl mItem; + + public SubMenuBuilder(Context context, MenuBuilder parentMenu, MenuItemImpl item) { + super(context); + + mParentMenu = parentMenu; + mItem = item; + } + + @Override + public void setQwertyMode(boolean isQwerty) { + mParentMenu.setQwertyMode(isQwerty); + } + + @Override + public boolean isQwertyMode() { + return mParentMenu.isQwertyMode(); + } + + @Override + public void setShortcutsVisible(boolean shortcutsVisible) { + mParentMenu.setShortcutsVisible(shortcutsVisible); + } + + @Override + public boolean isShortcutsVisible() { + return mParentMenu.isShortcutsVisible(); + } + + public Menu getParentMenu() { + return mParentMenu; + } + + public MenuItem getItem() { + return mItem; + } + + @Override + public void setCallback(Callback callback) { + mParentMenu.setCallback(callback); + } + + @Override + public MenuBuilder getRootMenu() { + return mParentMenu; + } + + @Override + boolean dispatchMenuItemSelected(MenuBuilder menu, MenuItem item) { + return super.dispatchMenuItemSelected(menu, item) || + mParentMenu.dispatchMenuItemSelected(menu, item); + } + + public SubMenu setIcon(Drawable icon) { + mItem.setIcon(icon); + return this; + } + + public SubMenu setIcon(int iconRes) { + mItem.setIcon(iconRes); + return this; + } + + public SubMenu setHeaderIcon(Drawable icon) { + return (SubMenu) super.setHeaderIconInt(icon); + } + + public SubMenu setHeaderIcon(int iconRes) { + return (SubMenu) super.setHeaderIconInt(iconRes); + } + + public SubMenu setHeaderTitle(CharSequence title) { + return (SubMenu) super.setHeaderTitleInt(title); + } + + public SubMenu setHeaderTitle(int titleRes) { + return (SubMenu) super.setHeaderTitleInt(titleRes); + } + + public SubMenu setHeaderView(View view) { + return (SubMenu) super.setHeaderViewInt(view); + } + + @Override + public boolean expandItemActionView(MenuItemImpl item) { + return mParentMenu.expandItemActionView(item); + } + + @Override + public boolean collapseItemActionView(MenuItemImpl item) { + return mParentMenu.collapseItemActionView(item); + } + + @Override + public String getActionViewStatesKey() { + final int itemId = mItem != null ? mItem.getItemId() : 0; + if (itemId == 0) { + return null; + } + return super.getActionViewStatesKey() + ":" + itemId; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/SubMenuWrapper.java b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/SubMenuWrapper.java new file mode 100644 index 000000000..7d307acb1 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/SubMenuWrapper.java @@ -0,0 +1,72 @@ +package com.actionbarsherlock.internal.view.menu; + +import android.graphics.drawable.Drawable; +import android.view.View; +import com.actionbarsherlock.view.MenuItem; +import com.actionbarsherlock.view.SubMenu; + +public class SubMenuWrapper extends MenuWrapper implements SubMenu { + private final android.view.SubMenu mNativeSubMenu; + private MenuItem mItem = null; + + public SubMenuWrapper(android.view.SubMenu nativeSubMenu) { + super(nativeSubMenu); + mNativeSubMenu = nativeSubMenu; + } + + + @Override + public SubMenu setHeaderTitle(int titleRes) { + mNativeSubMenu.setHeaderTitle(titleRes); + return this; + } + + @Override + public SubMenu setHeaderTitle(CharSequence title) { + mNativeSubMenu.setHeaderTitle(title); + return this; + } + + @Override + public SubMenu setHeaderIcon(int iconRes) { + mNativeSubMenu.setHeaderIcon(iconRes); + return this; + } + + @Override + public SubMenu setHeaderIcon(Drawable icon) { + mNativeSubMenu.setHeaderIcon(icon); + return this; + } + + @Override + public SubMenu setHeaderView(View view) { + mNativeSubMenu.setHeaderView(view); + return this; + } + + @Override + public void clearHeader() { + mNativeSubMenu.clearHeader(); + } + + @Override + public SubMenu setIcon(int iconRes) { + mNativeSubMenu.setIcon(iconRes); + return this; + } + + @Override + public SubMenu setIcon(Drawable icon) { + mNativeSubMenu.setIcon(icon); + return this; + } + + @Override + public MenuItem getItem() { + if (mItem == null) { + mItem = new MenuItemWrapper(mNativeSubMenu.getItem()); + } + return mItem; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/AbsActionBarView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/AbsActionBarView.java new file mode 100644 index 000000000..3a4a44675 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/AbsActionBarView.java @@ -0,0 +1,291 @@ +/* + * Copyright (C) 2011 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.actionbarsherlock.internal.widget; + +import android.content.Context; +import android.content.res.Configuration; +import android.content.res.TypedArray; +import android.os.Build; +import android.util.AttributeSet; +import android.view.View; +import android.view.animation.DecelerateInterpolator; +import android.view.animation.Interpolator; + +import com.actionbarsherlock.R; +import com.actionbarsherlock.internal.nineoldandroids.animation.Animator; +import com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet; +import com.actionbarsherlock.internal.nineoldandroids.animation.ObjectAnimator; +import com.actionbarsherlock.internal.nineoldandroids.view.NineViewGroup; +import com.actionbarsherlock.internal.view.menu.ActionMenuPresenter; +import com.actionbarsherlock.internal.view.menu.ActionMenuView; + +import static com.actionbarsherlock.internal.ResourcesCompat.getResources_getBoolean; + +public abstract class AbsActionBarView extends NineViewGroup { + protected ActionMenuView mMenuView; + protected ActionMenuPresenter mActionMenuPresenter; + protected ActionBarContainer mSplitView; + protected boolean mSplitActionBar; + protected boolean mSplitWhenNarrow; + protected int mContentHeight; + + final Context mContext; + + protected Animator mVisibilityAnim; + protected final VisibilityAnimListener mVisAnimListener = new VisibilityAnimListener(); + + private static final /*Time*/Interpolator sAlphaInterpolator = new DecelerateInterpolator(); + + private static final int FADE_DURATION = 200; + + public AbsActionBarView(Context context) { + super(context); + mContext = context; + } + + public AbsActionBarView(Context context, AttributeSet attrs) { + super(context, attrs); + mContext = context; + } + + public AbsActionBarView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + mContext = context; + } + + /* + * Must be public so we can dispatch pre-2.2 via ActionBarImpl. + */ + @Override + public void onConfigurationChanged(Configuration newConfig) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) { + super.onConfigurationChanged(newConfig); + } else if (mMenuView != null) { + mMenuView.onConfigurationChanged(newConfig); + } + + // Action bar can change size on configuration changes. + // Reread the desired height from the theme-specified style. + TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.SherlockActionBar, + R.attr.actionBarStyle, 0); + setContentHeight(a.getLayoutDimension(R.styleable.SherlockActionBar_height, 0)); + a.recycle(); + if (mSplitWhenNarrow) { + setSplitActionBar(getResources_getBoolean(getContext(), + R.bool.abs__split_action_bar_is_narrow)); + } + if (mActionMenuPresenter != null) { + mActionMenuPresenter.onConfigurationChanged(newConfig); + } + } + + /** + * Sets whether the bar should be split right now, no questions asked. + * @param split true if the bar should split + */ + public void setSplitActionBar(boolean split) { + mSplitActionBar = split; + } + + /** + * Sets whether the bar should split if we enter a narrow screen configuration. + * @param splitWhenNarrow true if the bar should check to split after a config change + */ + public void setSplitWhenNarrow(boolean splitWhenNarrow) { + mSplitWhenNarrow = splitWhenNarrow; + } + + public void setContentHeight(int height) { + mContentHeight = height; + requestLayout(); + } + + public int getContentHeight() { + return mContentHeight; + } + + public void setSplitView(ActionBarContainer splitView) { + mSplitView = splitView; + } + + /** + * @return Current visibility or if animating, the visibility being animated to. + */ + public int getAnimatedVisibility() { + if (mVisibilityAnim != null) { + return mVisAnimListener.mFinalVisibility; + } + return getVisibility(); + } + + public void animateToVisibility(int visibility) { + if (mVisibilityAnim != null) { + mVisibilityAnim.cancel(); + } + if (visibility == VISIBLE) { + if (getVisibility() != VISIBLE) { + setAlpha(0); + if (mSplitView != null && mMenuView != null) { + mMenuView.setAlpha(0); + } + } + ObjectAnimator anim = ObjectAnimator.ofFloat(this, "alpha", 1); + anim.setDuration(FADE_DURATION); + anim.setInterpolator(sAlphaInterpolator); + if (mSplitView != null && mMenuView != null) { + AnimatorSet set = new AnimatorSet(); + ObjectAnimator splitAnim = ObjectAnimator.ofFloat(mMenuView, "alpha", 1); + splitAnim.setDuration(FADE_DURATION); + set.addListener(mVisAnimListener.withFinalVisibility(visibility)); + set.play(anim).with(splitAnim); + set.start(); + } else { + anim.addListener(mVisAnimListener.withFinalVisibility(visibility)); + anim.start(); + } + } else { + ObjectAnimator anim = ObjectAnimator.ofFloat(this, "alpha", 0); + anim.setDuration(FADE_DURATION); + anim.setInterpolator(sAlphaInterpolator); + if (mSplitView != null && mMenuView != null) { + AnimatorSet set = new AnimatorSet(); + ObjectAnimator splitAnim = ObjectAnimator.ofFloat(mMenuView, "alpha", 0); + splitAnim.setDuration(FADE_DURATION); + set.addListener(mVisAnimListener.withFinalVisibility(visibility)); + set.play(anim).with(splitAnim); + set.start(); + } else { + anim.addListener(mVisAnimListener.withFinalVisibility(visibility)); + anim.start(); + } + } + } + + @Override + public void setVisibility(int visibility) { + if (mVisibilityAnim != null) { + mVisibilityAnim.end(); + } + super.setVisibility(visibility); + } + + public boolean showOverflowMenu() { + if (mActionMenuPresenter != null) { + return mActionMenuPresenter.showOverflowMenu(); + } + return false; + } + + public void postShowOverflowMenu() { + post(new Runnable() { + public void run() { + showOverflowMenu(); + } + }); + } + + public boolean hideOverflowMenu() { + if (mActionMenuPresenter != null) { + return mActionMenuPresenter.hideOverflowMenu(); + } + return false; + } + + public boolean isOverflowMenuShowing() { + if (mActionMenuPresenter != null) { + return mActionMenuPresenter.isOverflowMenuShowing(); + } + return false; + } + + public boolean isOverflowReserved() { + return mActionMenuPresenter != null && mActionMenuPresenter.isOverflowReserved(); + } + + public void dismissPopupMenus() { + if (mActionMenuPresenter != null) { + mActionMenuPresenter.dismissPopupMenus(); + } + } + + protected int measureChildView(View child, int availableWidth, int childSpecHeight, + int spacing) { + child.measure(MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST), + childSpecHeight); + + availableWidth -= child.getMeasuredWidth(); + availableWidth -= spacing; + + return Math.max(0, availableWidth); + } + + protected int positionChild(View child, int x, int y, int contentHeight) { + int childWidth = child.getMeasuredWidth(); + int childHeight = child.getMeasuredHeight(); + int childTop = y + (contentHeight - childHeight) / 2; + + child.layout(x, childTop, x + childWidth, childTop + childHeight); + + return childWidth; + } + + protected int positionChildInverse(View child, int x, int y, int contentHeight) { + int childWidth = child.getMeasuredWidth(); + int childHeight = child.getMeasuredHeight(); + int childTop = y + (contentHeight - childHeight) / 2; + + child.layout(x - childWidth, childTop, x, childTop + childHeight); + + return childWidth; + } + + protected class VisibilityAnimListener implements Animator.AnimatorListener { + private boolean mCanceled = false; + int mFinalVisibility; + + public VisibilityAnimListener withFinalVisibility(int visibility) { + mFinalVisibility = visibility; + return this; + } + + @Override + public void onAnimationStart(Animator animation) { + setVisibility(VISIBLE); + mVisibilityAnim = animation; + mCanceled = false; + } + + @Override + public void onAnimationEnd(Animator animation) { + if (mCanceled) return; + + mVisibilityAnim = null; + setVisibility(mFinalVisibility); + if (mSplitView != null && mMenuView != null) { + mMenuView.setVisibility(mFinalVisibility); + } + } + + @Override + public void onAnimationCancel(Animator animation) { + mCanceled = true; + } + + @Override + public void onAnimationRepeat(Animator animation) { + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarContainer.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarContainer.java new file mode 100644 index 000000000..5e5aa2867 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarContainer.java @@ -0,0 +1,245 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.widget; + +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.Canvas; +import android.graphics.drawable.Drawable; +import android.util.AttributeSet; +import android.view.MotionEvent; +import android.view.View; +import android.view.ViewGroup; + +import com.actionbarsherlock.R; +import com.actionbarsherlock.app.ActionBar; +import com.actionbarsherlock.internal.nineoldandroids.widget.NineFrameLayout; + +/** + * This class acts as a container for the action bar view and action mode context views. + * It applies special styles as needed to help handle animated transitions between them. + * @hide + */ +public class ActionBarContainer extends NineFrameLayout { + private boolean mIsTransitioning; + private View mTabContainer; + private ActionBarView mActionBarView; + + private Drawable mBackground; + private Drawable mStackedBackground; + private Drawable mSplitBackground; + private boolean mIsSplit; + private boolean mIsStacked; + + public ActionBarContainer(Context context) { + this(context, null); + } + + public ActionBarContainer(Context context, AttributeSet attrs) { + super(context, attrs); + + setBackgroundDrawable(null); + + TypedArray a = context.obtainStyledAttributes(attrs, + R.styleable.SherlockActionBar); + mBackground = a.getDrawable(R.styleable.SherlockActionBar_background); + mStackedBackground = a.getDrawable( + R.styleable.SherlockActionBar_backgroundStacked); + + if (getId() == R.id.abs__split_action_bar) { + mIsSplit = true; + mSplitBackground = a.getDrawable( + R.styleable.SherlockActionBar_backgroundSplit); + } + a.recycle(); + + setWillNotDraw(mIsSplit ? mSplitBackground == null : + mBackground == null && mStackedBackground == null); + } + + @Override + public void onFinishInflate() { + super.onFinishInflate(); + mActionBarView = (ActionBarView) findViewById(R.id.abs__action_bar); + } + + public void setPrimaryBackground(Drawable bg) { + mBackground = bg; + invalidate(); + } + + public void setStackedBackground(Drawable bg) { + mStackedBackground = bg; + invalidate(); + } + + public void setSplitBackground(Drawable bg) { + mSplitBackground = bg; + invalidate(); + } + + /** + * Set the action bar into a "transitioning" state. While transitioning + * the bar will block focus and touch from all of its descendants. This + * prevents the user from interacting with the bar while it is animating + * in or out. + * + * @param isTransitioning true if the bar is currently transitioning, false otherwise. + */ + public void setTransitioning(boolean isTransitioning) { + mIsTransitioning = isTransitioning; + setDescendantFocusability(isTransitioning ? FOCUS_BLOCK_DESCENDANTS + : FOCUS_AFTER_DESCENDANTS); + } + + @Override + public boolean onInterceptTouchEvent(MotionEvent ev) { + return mIsTransitioning || super.onInterceptTouchEvent(ev); + } + + @Override + public boolean onTouchEvent(MotionEvent ev) { + super.onTouchEvent(ev); + + // An action bar always eats touch events. + return true; + } + + @Override + public boolean onHoverEvent(MotionEvent ev) { + super.onHoverEvent(ev); + + // An action bar always eats hover events. + return true; + } + + public void setTabContainer(ScrollingTabContainerView tabView) { + if (mTabContainer != null) { + removeView(mTabContainer); + } + mTabContainer = tabView; + if (tabView != null) { + addView(tabView); + final ViewGroup.LayoutParams lp = tabView.getLayoutParams(); + lp.width = LayoutParams.MATCH_PARENT; + lp.height = LayoutParams.WRAP_CONTENT; + tabView.setAllowCollapse(false); + } + } + + public View getTabContainer() { + return mTabContainer; + } + + @Override + public void onDraw(Canvas canvas) { + if (getWidth() == 0 || getHeight() == 0) { + return; + } + + if (mIsSplit) { + if (mSplitBackground != null) mSplitBackground.draw(canvas); + } else { + if (mBackground != null) { + mBackground.draw(canvas); + } + if (mStackedBackground != null && mIsStacked) { + mStackedBackground.draw(canvas); + } + } + } + + //This causes the animation reflection to fail on pre-HC platforms + //@Override + //public android.view.ActionMode startActionModeForChild(View child, android.view.ActionMode.Callback callback) { + // // No starting an action mode for an action bar child! (Where would it go?) + // return null; + //} + + @Override + public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + + if (mActionBarView == null) return; + + final LayoutParams lp = (LayoutParams) mActionBarView.getLayoutParams(); + final int actionBarViewHeight = mActionBarView.isCollapsed() ? 0 : + mActionBarView.getMeasuredHeight() + lp.topMargin + lp.bottomMargin; + + if (mTabContainer != null && mTabContainer.getVisibility() != GONE) { + final int mode = MeasureSpec.getMode(heightMeasureSpec); + if (mode == MeasureSpec.AT_MOST) { + final int maxHeight = MeasureSpec.getSize(heightMeasureSpec); + setMeasuredDimension(getMeasuredWidth(), + Math.min(actionBarViewHeight + mTabContainer.getMeasuredHeight(), + maxHeight)); + } + } + } + + @Override + public void onLayout(boolean changed, int l, int t, int r, int b) { + super.onLayout(changed, l, t, r, b); + + final boolean hasTabs = mTabContainer != null && mTabContainer.getVisibility() != GONE; + + if (mTabContainer != null && mTabContainer.getVisibility() != GONE) { + final int containerHeight = getMeasuredHeight(); + final int tabHeight = mTabContainer.getMeasuredHeight(); + + if ((mActionBarView.getDisplayOptions() & ActionBar.DISPLAY_SHOW_HOME) == 0) { + // Not showing home, put tabs on top. + final int count = getChildCount(); + for (int i = 0; i < count; i++) { + final View child = getChildAt(i); + + if (child == mTabContainer) continue; + + if (!mActionBarView.isCollapsed()) { + child.offsetTopAndBottom(tabHeight); + } + } + mTabContainer.layout(l, 0, r, tabHeight); + } else { + mTabContainer.layout(l, containerHeight - tabHeight, r, containerHeight); + } + } + + boolean needsInvalidate = false; + if (mIsSplit) { + if (mSplitBackground != null) { + mSplitBackground.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight()); + needsInvalidate = true; + } + } else { + if (mBackground != null) { + mBackground.setBounds(mActionBarView.getLeft(), mActionBarView.getTop(), + mActionBarView.getRight(), mActionBarView.getBottom()); + needsInvalidate = true; + } + if ((mIsStacked = hasTabs && mStackedBackground != null)) { + mStackedBackground.setBounds(mTabContainer.getLeft(), mTabContainer.getTop(), + mTabContainer.getRight(), mTabContainer.getBottom()); + needsInvalidate = true; + } + } + + if (needsInvalidate) { + invalidate(); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarContextView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarContextView.java new file mode 100644 index 000000000..9ec250f38 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarContextView.java @@ -0,0 +1,518 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.widget; + +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.drawable.Drawable; +import android.text.TextUtils; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.accessibility.AccessibilityEvent; +import android.view.animation.DecelerateInterpolator; +import android.widget.LinearLayout; +import android.widget.TextView; + +import com.actionbarsherlock.R; +import com.actionbarsherlock.internal.nineoldandroids.animation.Animator; +import com.actionbarsherlock.internal.nineoldandroids.animation.Animator.AnimatorListener; +import com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet; +import com.actionbarsherlock.internal.nineoldandroids.animation.ObjectAnimator; +import com.actionbarsherlock.internal.nineoldandroids.view.animation.AnimatorProxy; +import com.actionbarsherlock.internal.nineoldandroids.widget.NineLinearLayout; +import com.actionbarsherlock.internal.view.menu.ActionMenuPresenter; +import com.actionbarsherlock.internal.view.menu.ActionMenuView; +import com.actionbarsherlock.internal.view.menu.MenuBuilder; +import com.actionbarsherlock.view.ActionMode; + +/** + * @hide + */ +public class ActionBarContextView extends AbsActionBarView implements AnimatorListener { + //UNUSED private static final String TAG = "ActionBarContextView"; + + private CharSequence mTitle; + private CharSequence mSubtitle; + + private NineLinearLayout mClose; + private View mCustomView; + private LinearLayout mTitleLayout; + private TextView mTitleView; + private TextView mSubtitleView; + private int mTitleStyleRes; + private int mSubtitleStyleRes; + private Drawable mSplitBackground; + + private Animator mCurrentAnimation; + private boolean mAnimateInOnLayout; + private int mAnimationMode; + + private static final int ANIMATE_IDLE = 0; + private static final int ANIMATE_IN = 1; + private static final int ANIMATE_OUT = 2; + + public ActionBarContextView(Context context) { + this(context, null); + } + + public ActionBarContextView(Context context, AttributeSet attrs) { + this(context, attrs, R.attr.actionModeStyle); + } + + public ActionBarContextView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + + TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockActionMode, defStyle, 0); + setBackgroundDrawable(a.getDrawable( + R.styleable.SherlockActionMode_background)); + mTitleStyleRes = a.getResourceId( + R.styleable.SherlockActionMode_titleTextStyle, 0); + mSubtitleStyleRes = a.getResourceId( + R.styleable.SherlockActionMode_subtitleTextStyle, 0); + + mContentHeight = a.getLayoutDimension( + R.styleable.SherlockActionMode_height, 0); + + mSplitBackground = a.getDrawable( + R.styleable.SherlockActionMode_backgroundSplit); + + a.recycle(); + } + + @Override + public void onDetachedFromWindow() { + super.onDetachedFromWindow(); + if (mActionMenuPresenter != null) { + mActionMenuPresenter.hideOverflowMenu(); + mActionMenuPresenter.hideSubMenus(); + } + } + + @Override + public void setSplitActionBar(boolean split) { + if (mSplitActionBar != split) { + if (mActionMenuPresenter != null) { + // Mode is already active; move everything over and adjust the menu itself. + final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, + LayoutParams.MATCH_PARENT); + if (!split) { + mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this); + mMenuView.setBackgroundDrawable(null); + final ViewGroup oldParent = (ViewGroup) mMenuView.getParent(); + if (oldParent != null) oldParent.removeView(mMenuView); + addView(mMenuView, layoutParams); + } else { + // Allow full screen width in split mode. + mActionMenuPresenter.setWidthLimit( + getContext().getResources().getDisplayMetrics().widthPixels, true); + // No limit to the item count; use whatever will fit. + mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE); + // Span the whole width + layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.height = mContentHeight; + mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this); + mMenuView.setBackgroundDrawable(mSplitBackground); + final ViewGroup oldParent = (ViewGroup) mMenuView.getParent(); + if (oldParent != null) oldParent.removeView(mMenuView); + mSplitView.addView(mMenuView, layoutParams); + } + } + super.setSplitActionBar(split); + } + } + + public void setContentHeight(int height) { + mContentHeight = height; + } + + public void setCustomView(View view) { + if (mCustomView != null) { + removeView(mCustomView); + } + mCustomView = view; + if (mTitleLayout != null) { + removeView(mTitleLayout); + mTitleLayout = null; + } + if (view != null) { + addView(view); + } + requestLayout(); + } + + public void setTitle(CharSequence title) { + mTitle = title; + initTitle(); + } + + public void setSubtitle(CharSequence subtitle) { + mSubtitle = subtitle; + initTitle(); + } + + public CharSequence getTitle() { + return mTitle; + } + + public CharSequence getSubtitle() { + return mSubtitle; + } + + private void initTitle() { + if (mTitleLayout == null) { + LayoutInflater inflater = LayoutInflater.from(getContext()); + inflater.inflate(R.layout.abs__action_bar_title_item, this); + mTitleLayout = (LinearLayout) getChildAt(getChildCount() - 1); + mTitleView = (TextView) mTitleLayout.findViewById(R.id.abs__action_bar_title); + mSubtitleView = (TextView) mTitleLayout.findViewById(R.id.abs__action_bar_subtitle); + if (mTitleStyleRes != 0) { + mTitleView.setTextAppearance(mContext, mTitleStyleRes); + } + if (mSubtitleStyleRes != 0) { + mSubtitleView.setTextAppearance(mContext, mSubtitleStyleRes); + } + } + + mTitleView.setText(mTitle); + mSubtitleView.setText(mSubtitle); + + final boolean hasTitle = !TextUtils.isEmpty(mTitle); + final boolean hasSubtitle = !TextUtils.isEmpty(mSubtitle); + mSubtitleView.setVisibility(hasSubtitle ? VISIBLE : GONE); + mTitleLayout.setVisibility(hasTitle || hasSubtitle ? VISIBLE : GONE); + if (mTitleLayout.getParent() == null) { + addView(mTitleLayout); + } + } + + public void initForMode(final ActionMode mode) { + if (mClose == null) { + LayoutInflater inflater = LayoutInflater.from(mContext); + mClose = (NineLinearLayout)inflater.inflate(R.layout.abs__action_mode_close_item, this, false); + addView(mClose); + } else if (mClose.getParent() == null) { + addView(mClose); + } + + View closeButton = mClose.findViewById(R.id.abs__action_mode_close_button); + closeButton.setOnClickListener(new OnClickListener() { + public void onClick(View v) { + mode.finish(); + } + }); + + final MenuBuilder menu = (MenuBuilder) mode.getMenu(); + if (mActionMenuPresenter != null) { + mActionMenuPresenter.dismissPopupMenus(); + } + mActionMenuPresenter = new ActionMenuPresenter(mContext); + mActionMenuPresenter.setReserveOverflow(true); + + final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, + LayoutParams.MATCH_PARENT); + if (!mSplitActionBar) { + menu.addMenuPresenter(mActionMenuPresenter); + mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this); + mMenuView.setBackgroundDrawable(null); + addView(mMenuView, layoutParams); + } else { + // Allow full screen width in split mode. + mActionMenuPresenter.setWidthLimit( + getContext().getResources().getDisplayMetrics().widthPixels, true); + // No limit to the item count; use whatever will fit. + mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE); + // Span the whole width + layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.height = mContentHeight; + menu.addMenuPresenter(mActionMenuPresenter); + mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this); + mMenuView.setBackgroundDrawable(mSplitBackground); + mSplitView.addView(mMenuView, layoutParams); + } + + mAnimateInOnLayout = true; + } + + public void closeMode() { + if (mAnimationMode == ANIMATE_OUT) { + // Called again during close; just finish what we were doing. + return; + } + if (mClose == null) { + killMode(); + return; + } + + finishAnimation(); + mAnimationMode = ANIMATE_OUT; + mCurrentAnimation = makeOutAnimation(); + mCurrentAnimation.start(); + } + + private void finishAnimation() { + final Animator a = mCurrentAnimation; + if (a != null) { + mCurrentAnimation = null; + a.end(); + } + } + + public void killMode() { + finishAnimation(); + removeAllViews(); + if (mSplitView != null) { + mSplitView.removeView(mMenuView); + } + mCustomView = null; + mMenuView = null; + mAnimateInOnLayout = false; + } + + @Override + public boolean showOverflowMenu() { + if (mActionMenuPresenter != null) { + return mActionMenuPresenter.showOverflowMenu(); + } + return false; + } + + @Override + public boolean hideOverflowMenu() { + if (mActionMenuPresenter != null) { + return mActionMenuPresenter.hideOverflowMenu(); + } + return false; + } + + @Override + public boolean isOverflowMenuShowing() { + if (mActionMenuPresenter != null) { + return mActionMenuPresenter.isOverflowMenuShowing(); + } + return false; + } + + @Override + protected ViewGroup.LayoutParams generateDefaultLayoutParams() { + // Used by custom views if they don't supply layout params. Everything else + // added to an ActionBarContextView should have them already. + return new MarginLayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); + } + + @Override + public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs) { + return new MarginLayoutParams(getContext(), attrs); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + final int widthMode = MeasureSpec.getMode(widthMeasureSpec); + if (widthMode != MeasureSpec.EXACTLY) { + throw new IllegalStateException(getClass().getSimpleName() + " can only be used " + + "with android:layout_width=\"match_parent\" (or fill_parent)"); + } + + final int heightMode = MeasureSpec.getMode(heightMeasureSpec); + if (heightMode == MeasureSpec.UNSPECIFIED) { + throw new IllegalStateException(getClass().getSimpleName() + " can only be used " + + "with android:layout_height=\"wrap_content\""); + } + + final int contentWidth = MeasureSpec.getSize(widthMeasureSpec); + + int maxHeight = mContentHeight > 0 ? + mContentHeight : MeasureSpec.getSize(heightMeasureSpec); + + final int verticalPadding = getPaddingTop() + getPaddingBottom(); + int availableWidth = contentWidth - getPaddingLeft() - getPaddingRight(); + final int height = maxHeight - verticalPadding; + final int childSpecHeight = MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST); + + if (mClose != null) { + availableWidth = measureChildView(mClose, availableWidth, childSpecHeight, 0); + MarginLayoutParams lp = (MarginLayoutParams) mClose.getLayoutParams(); + availableWidth -= lp.leftMargin + lp.rightMargin; + } + + if (mMenuView != null && mMenuView.getParent() == this) { + availableWidth = measureChildView(mMenuView, availableWidth, + childSpecHeight, 0); + } + + if (mTitleLayout != null && mCustomView == null) { + availableWidth = measureChildView(mTitleLayout, availableWidth, childSpecHeight, 0); + } + + if (mCustomView != null) { + ViewGroup.LayoutParams lp = mCustomView.getLayoutParams(); + final int customWidthMode = lp.width != LayoutParams.WRAP_CONTENT ? + MeasureSpec.EXACTLY : MeasureSpec.AT_MOST; + final int customWidth = lp.width >= 0 ? + Math.min(lp.width, availableWidth) : availableWidth; + final int customHeightMode = lp.height != LayoutParams.WRAP_CONTENT ? + MeasureSpec.EXACTLY : MeasureSpec.AT_MOST; + final int customHeight = lp.height >= 0 ? + Math.min(lp.height, height) : height; + mCustomView.measure(MeasureSpec.makeMeasureSpec(customWidth, customWidthMode), + MeasureSpec.makeMeasureSpec(customHeight, customHeightMode)); + } + + if (mContentHeight <= 0) { + int measuredHeight = 0; + final int count = getChildCount(); + for (int i = 0; i < count; i++) { + View v = getChildAt(i); + int paddedViewHeight = v.getMeasuredHeight() + verticalPadding; + if (paddedViewHeight > measuredHeight) { + measuredHeight = paddedViewHeight; + } + } + setMeasuredDimension(contentWidth, measuredHeight); + } else { + setMeasuredDimension(contentWidth, maxHeight); + } + } + + private Animator makeInAnimation() { + mClose.setTranslationX(-mClose.getWidth() - + ((MarginLayoutParams) mClose.getLayoutParams()).leftMargin); + ObjectAnimator buttonAnimator = ObjectAnimator.ofFloat(mClose, "translationX", 0); + buttonAnimator.setDuration(200); + buttonAnimator.addListener(this); + buttonAnimator.setInterpolator(new DecelerateInterpolator()); + + AnimatorSet set = new AnimatorSet(); + AnimatorSet.Builder b = set.play(buttonAnimator); + + if (mMenuView != null) { + final int count = mMenuView.getChildCount(); + if (count > 0) { + for (int i = count - 1, j = 0; i >= 0; i--, j++) { + AnimatorProxy child = AnimatorProxy.wrap(mMenuView.getChildAt(i)); + child.setScaleY(0); + ObjectAnimator a = ObjectAnimator.ofFloat(child, "scaleY", 0, 1); + a.setDuration(100); + a.setStartDelay(j * 70); + b.with(a); + } + } + } + + return set; + } + + private Animator makeOutAnimation() { + ObjectAnimator buttonAnimator = ObjectAnimator.ofFloat(mClose, "translationX", + -mClose.getWidth() - ((MarginLayoutParams) mClose.getLayoutParams()).leftMargin); + buttonAnimator.setDuration(200); + buttonAnimator.addListener(this); + buttonAnimator.setInterpolator(new DecelerateInterpolator()); + + AnimatorSet set = new AnimatorSet(); + AnimatorSet.Builder b = set.play(buttonAnimator); + + if (mMenuView != null) { + final int count = mMenuView.getChildCount(); + if (count > 0) { + for (int i = 0; i < 0; i++) { + AnimatorProxy child = AnimatorProxy.wrap(mMenuView.getChildAt(i)); + child.setScaleY(0); + ObjectAnimator a = ObjectAnimator.ofFloat(child, "scaleY", 0); + a.setDuration(100); + a.setStartDelay(i * 70); + b.with(a); + } + } + } + + return set; + } + + @Override + protected void onLayout(boolean changed, int l, int t, int r, int b) { + int x = getPaddingLeft(); + final int y = getPaddingTop(); + final int contentHeight = b - t - getPaddingTop() - getPaddingBottom(); + + if (mClose != null && mClose.getVisibility() != GONE) { + MarginLayoutParams lp = (MarginLayoutParams) mClose.getLayoutParams(); + x += lp.leftMargin; + x += positionChild(mClose, x, y, contentHeight); + x += lp.rightMargin; + + if (mAnimateInOnLayout) { + mAnimationMode = ANIMATE_IN; + mCurrentAnimation = makeInAnimation(); + mCurrentAnimation.start(); + mAnimateInOnLayout = false; + } + } + + if (mTitleLayout != null && mCustomView == null) { + x += positionChild(mTitleLayout, x, y, contentHeight); + } + + if (mCustomView != null) { + x += positionChild(mCustomView, x, y, contentHeight); + } + + x = r - l - getPaddingRight(); + + if (mMenuView != null) { + x -= positionChildInverse(mMenuView, x, y, contentHeight); + } + } + + @Override + public void onAnimationStart(Animator animation) { + } + + @Override + public void onAnimationEnd(Animator animation) { + if (mAnimationMode == ANIMATE_OUT) { + killMode(); + } + mAnimationMode = ANIMATE_IDLE; + } + + @Override + public void onAnimationCancel(Animator animation) { + } + + @Override + public void onAnimationRepeat(Animator animation) { + } + + @Override + public boolean shouldDelayChildPressedState() { + return false; + } + + @Override + public void onInitializeAccessibilityEvent(AccessibilityEvent event) { + if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { + // Action mode started + //TODO event.setSource(this); + event.setClassName(getClass().getName()); + event.setPackageName(getContext().getPackageName()); + event.setContentDescription(mTitle); + } else { + //TODO super.onInitializeAccessibilityEvent(event); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarView.java new file mode 100644 index 000000000..4636de17f --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ActionBarView.java @@ -0,0 +1,1548 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.internal.widget; + +import org.xmlpull.v1.XmlPullParser; +import android.app.Activity; +import android.content.Context; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; +import android.content.res.AssetManager; +import android.content.res.Configuration; +import android.content.res.TypedArray; +import android.content.res.XmlResourceParser; +import android.graphics.drawable.Drawable; +import android.os.Build; +import android.os.Parcel; +import android.os.Parcelable; +import android.text.TextUtils; +import android.util.AttributeSet; +import android.util.Log; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewParent; +import android.view.accessibility.AccessibilityEvent; +import android.widget.FrameLayout; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.SpinnerAdapter; +import android.widget.TextView; + +import com.actionbarsherlock.R; +import com.actionbarsherlock.app.ActionBar; +import com.actionbarsherlock.app.ActionBar.OnNavigationListener; +import com.actionbarsherlock.internal.ActionBarSherlockCompat; +import com.actionbarsherlock.internal.view.menu.ActionMenuItem; +import com.actionbarsherlock.internal.view.menu.ActionMenuPresenter; +import com.actionbarsherlock.internal.view.menu.ActionMenuView; +import com.actionbarsherlock.internal.view.menu.MenuBuilder; +import com.actionbarsherlock.internal.view.menu.MenuItemImpl; +import com.actionbarsherlock.internal.view.menu.MenuPresenter; +import com.actionbarsherlock.internal.view.menu.MenuView; +import com.actionbarsherlock.internal.view.menu.SubMenuBuilder; +import com.actionbarsherlock.view.CollapsibleActionView; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuItem; +import com.actionbarsherlock.view.Window; + +import static com.actionbarsherlock.internal.ResourcesCompat.getResources_getBoolean; + +/** + * @hide + */ +public class ActionBarView extends AbsActionBarView { + private static final String TAG = "ActionBarView"; + private static final boolean DEBUG = false; + + /** + * Display options applied by default + */ + public static final int DISPLAY_DEFAULT = 0; + + /** + * Display options that require re-layout as opposed to a simple invalidate + */ + private static final int DISPLAY_RELAYOUT_MASK = + ActionBar.DISPLAY_SHOW_HOME | + ActionBar.DISPLAY_USE_LOGO | + ActionBar.DISPLAY_HOME_AS_UP | + ActionBar.DISPLAY_SHOW_CUSTOM | + ActionBar.DISPLAY_SHOW_TITLE; + + private static final int DEFAULT_CUSTOM_GRAVITY = Gravity.LEFT | Gravity.CENTER_VERTICAL; + + private int mNavigationMode; + private int mDisplayOptions = -1; + private CharSequence mTitle; + private CharSequence mSubtitle; + private Drawable mIcon; + private Drawable mLogo; + + private HomeView mHomeLayout; + private HomeView mExpandedHomeLayout; + private LinearLayout mTitleLayout; + private TextView mTitleView; + private TextView mSubtitleView; + private View mTitleUpView; + + private IcsSpinner mSpinner; + private IcsLinearLayout mListNavLayout; + private ScrollingTabContainerView mTabScrollView; + private View mCustomNavView; + private IcsProgressBar mProgressView; + private IcsProgressBar mIndeterminateProgressView; + + private int mProgressBarPadding; + private int mItemPadding; + + private int mTitleStyleRes; + private int mSubtitleStyleRes; + private int mProgressStyle; + private int mIndeterminateProgressStyle; + + private boolean mUserTitle; + private boolean mIncludeTabs; + private boolean mIsCollapsable; + private boolean mIsCollapsed; + + private MenuBuilder mOptionsMenu; + + private ActionBarContextView mContextView; + + private ActionMenuItem mLogoNavItem; + + private SpinnerAdapter mSpinnerAdapter; + private OnNavigationListener mCallback; + + //UNUSED private Runnable mTabSelector; + + private ExpandedActionViewMenuPresenter mExpandedMenuPresenter; + View mExpandedActionView; + + Window.Callback mWindowCallback; + + @SuppressWarnings("rawtypes") + private final IcsAdapterView.OnItemSelectedListener mNavItemSelectedListener = + new IcsAdapterView.OnItemSelectedListener() { + public void onItemSelected(IcsAdapterView parent, View view, int position, long id) { + if (mCallback != null) { + mCallback.onNavigationItemSelected(position, id); + } + } + public void onNothingSelected(IcsAdapterView parent) { + // Do nothing + } + }; + + private final OnClickListener mExpandedActionViewUpListener = new OnClickListener() { + @Override + public void onClick(View v) { + final MenuItemImpl item = mExpandedMenuPresenter.mCurrentExpandedItem; + if (item != null) { + item.collapseActionView(); + } + } + }; + + private final OnClickListener mUpClickListener = new OnClickListener() { + public void onClick(View v) { + mWindowCallback.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, mLogoNavItem); + } + }; + + public ActionBarView(Context context, AttributeSet attrs) { + super(context, attrs); + + // Background is always provided by the container. + setBackgroundResource(0); + + TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockActionBar, + R.attr.actionBarStyle, 0); + + ApplicationInfo appInfo = context.getApplicationInfo(); + PackageManager pm = context.getPackageManager(); + mNavigationMode = a.getInt(R.styleable.SherlockActionBar_navigationMode, + ActionBar.NAVIGATION_MODE_STANDARD); + mTitle = a.getText(R.styleable.SherlockActionBar_title); + mSubtitle = a.getText(R.styleable.SherlockActionBar_subtitle); + + mLogo = a.getDrawable(R.styleable.SherlockActionBar_logo); + if (mLogo == null) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + if (context instanceof Activity) { + //Even though native methods existed in API 9 and 10 they don't work + //so just parse the manifest to look for the logo pre-Honeycomb + final int resId = loadLogoFromManifest((Activity) context); + if (resId != 0) { + mLogo = context.getResources().getDrawable(resId); + } + } + } else { + if (context instanceof Activity) { + try { + mLogo = pm.getActivityLogo(((Activity) context).getComponentName()); + } catch (NameNotFoundException e) { + Log.e(TAG, "Activity component name not found!", e); + } + } + if (mLogo == null) { + mLogo = appInfo.loadLogo(pm); + } + } + } + + mIcon = a.getDrawable(R.styleable.SherlockActionBar_icon); + if (mIcon == null) { + if (context instanceof Activity) { + try { + mIcon = pm.getActivityIcon(((Activity) context).getComponentName()); + } catch (NameNotFoundException e) { + Log.e(TAG, "Activity component name not found!", e); + } + } + if (mIcon == null) { + mIcon = appInfo.loadIcon(pm); + } + } + + final LayoutInflater inflater = LayoutInflater.from(context); + + final int homeResId = a.getResourceId( + R.styleable.SherlockActionBar_homeLayout, + R.layout.abs__action_bar_home); + + mHomeLayout = (HomeView) inflater.inflate(homeResId, this, false); + + mExpandedHomeLayout = (HomeView) inflater.inflate(homeResId, this, false); + mExpandedHomeLayout.setUp(true); + mExpandedHomeLayout.setOnClickListener(mExpandedActionViewUpListener); + mExpandedHomeLayout.setContentDescription(getResources().getText( + R.string.abs__action_bar_up_description)); + + mTitleStyleRes = a.getResourceId(R.styleable.SherlockActionBar_titleTextStyle, 0); + mSubtitleStyleRes = a.getResourceId(R.styleable.SherlockActionBar_subtitleTextStyle, 0); + mProgressStyle = a.getResourceId(R.styleable.SherlockActionBar_progressBarStyle, 0); + mIndeterminateProgressStyle = a.getResourceId( + R.styleable.SherlockActionBar_indeterminateProgressStyle, 0); + + mProgressBarPadding = a.getDimensionPixelOffset(R.styleable.SherlockActionBar_progressBarPadding, 0); + mItemPadding = a.getDimensionPixelOffset(R.styleable.SherlockActionBar_itemPadding, 0); + + setDisplayOptions(a.getInt(R.styleable.SherlockActionBar_displayOptions, DISPLAY_DEFAULT)); + + final int customNavId = a.getResourceId(R.styleable.SherlockActionBar_customNavigationLayout, 0); + if (customNavId != 0) { + mCustomNavView = inflater.inflate(customNavId, this, false); + mNavigationMode = ActionBar.NAVIGATION_MODE_STANDARD; + setDisplayOptions(mDisplayOptions | ActionBar.DISPLAY_SHOW_CUSTOM); + } + + mContentHeight = a.getLayoutDimension(R.styleable.SherlockActionBar_height, 0); + + a.recycle(); + + mLogoNavItem = new ActionMenuItem(context, 0, android.R.id.home, 0, 0, mTitle); + mHomeLayout.setOnClickListener(mUpClickListener); + mHomeLayout.setClickable(true); + mHomeLayout.setFocusable(true); + } + + /** + * Attempt to programmatically load the logo from the manifest file of an + * activity by using an XML pull parser. This should allow us to read the + * logo attribute regardless of the platform it is being run on. + * + * @param activity Activity instance. + * @return Logo resource ID. + */ + private static int loadLogoFromManifest(Activity activity) { + int logo = 0; + try { + final String thisPackage = activity.getClass().getName(); + if (DEBUG) Log.i(TAG, "Parsing AndroidManifest.xml for " + thisPackage); + + final String packageName = activity.getApplicationInfo().packageName; + final AssetManager am = activity.createPackageContext(packageName, 0).getAssets(); + final XmlResourceParser xml = am.openXmlResourceParser("AndroidManifest.xml"); + + int eventType = xml.getEventType(); + while (eventType != XmlPullParser.END_DOCUMENT) { + if (eventType == XmlPullParser.START_TAG) { + String name = xml.getName(); + + if ("application".equals(name)) { + //Check if the has the attribute + if (DEBUG) Log.d(TAG, "Got "); + + for (int i = xml.getAttributeCount() - 1; i >= 0; i--) { + if (DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i)); + + if ("logo".equals(xml.getAttributeName(i))) { + logo = xml.getAttributeResourceValue(i, 0); + break; //out of for loop + } + } + } else if ("activity".equals(name)) { + //Check if the is us and has the attribute + if (DEBUG) Log.d(TAG, "Got "); + Integer activityLogo = null; + String activityPackage = null; + boolean isOurActivity = false; + + for (int i = xml.getAttributeCount() - 1; i >= 0; i--) { + if (DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i)); + + //We need both uiOptions and name attributes + String attrName = xml.getAttributeName(i); + if ("logo".equals(attrName)) { + activityLogo = xml.getAttributeResourceValue(i, 0); + } else if ("name".equals(attrName)) { + activityPackage = ActionBarSherlockCompat.cleanActivityName(packageName, xml.getAttributeValue(i)); + if (!thisPackage.equals(activityPackage)) { + break; //on to the next + } + isOurActivity = true; + } + + //Make sure we have both attributes before processing + if ((activityLogo != null) && (activityPackage != null)) { + //Our activity, logo specified, override with our value + logo = activityLogo.intValue(); + } + } + if (isOurActivity) { + //If we matched our activity but it had no logo don't + //do any more processing of the manifest + break; + } + } + } + eventType = xml.nextToken(); + } + } catch (Exception e) { + e.printStackTrace(); + } + if (DEBUG) Log.i(TAG, "Returning " + Integer.toHexString(logo)); + return logo; + } + + /* + * Must be public so we can dispatch pre-2.2 via ActionBarImpl. + */ + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + + mTitleView = null; + mSubtitleView = null; + mTitleUpView = null; + if (mTitleLayout != null && mTitleLayout.getParent() == this) { + removeView(mTitleLayout); + } + mTitleLayout = null; + if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0) { + initTitle(); + } + + if (mTabScrollView != null && mIncludeTabs) { + ViewGroup.LayoutParams lp = mTabScrollView.getLayoutParams(); + if (lp != null) { + lp.width = LayoutParams.WRAP_CONTENT; + lp.height = LayoutParams.MATCH_PARENT; + } + mTabScrollView.setAllowCollapse(true); + } + } + + /** + * Set the window callback used to invoke menu items; used for dispatching home button presses. + * @param cb Window callback to dispatch to + */ + public void setWindowCallback(Window.Callback cb) { + mWindowCallback = cb; + } + + @Override + public void onDetachedFromWindow() { + super.onDetachedFromWindow(); + //UNUSED removeCallbacks(mTabSelector); + if (mActionMenuPresenter != null) { + mActionMenuPresenter.hideOverflowMenu(); + mActionMenuPresenter.hideSubMenus(); + } + } + + @Override + public boolean shouldDelayChildPressedState() { + return false; + } + + public void initProgress() { + mProgressView = new IcsProgressBar(mContext, null, 0, mProgressStyle); + mProgressView.setId(R.id.abs__progress_horizontal); + mProgressView.setMax(10000); + addView(mProgressView); + } + + public void initIndeterminateProgress() { + mIndeterminateProgressView = new IcsProgressBar(mContext, null, 0, mIndeterminateProgressStyle); + mIndeterminateProgressView.setId(R.id.abs__progress_circular); + addView(mIndeterminateProgressView); + } + + @Override + public void setSplitActionBar(boolean splitActionBar) { + if (mSplitActionBar != splitActionBar) { + if (mMenuView != null) { + final ViewGroup oldParent = (ViewGroup) mMenuView.getParent(); + if (oldParent != null) { + oldParent.removeView(mMenuView); + } + if (splitActionBar) { + if (mSplitView != null) { + mSplitView.addView(mMenuView); + } + } else { + addView(mMenuView); + } + } + if (mSplitView != null) { + mSplitView.setVisibility(splitActionBar ? VISIBLE : GONE); + } + super.setSplitActionBar(splitActionBar); + } + } + + public boolean isSplitActionBar() { + return mSplitActionBar; + } + + public boolean hasEmbeddedTabs() { + return mIncludeTabs; + } + + public void setEmbeddedTabView(ScrollingTabContainerView tabs) { + if (mTabScrollView != null) { + removeView(mTabScrollView); + } + mTabScrollView = tabs; + mIncludeTabs = tabs != null; + if (mIncludeTabs && mNavigationMode == ActionBar.NAVIGATION_MODE_TABS) { + addView(mTabScrollView); + ViewGroup.LayoutParams lp = mTabScrollView.getLayoutParams(); + lp.width = LayoutParams.WRAP_CONTENT; + lp.height = LayoutParams.MATCH_PARENT; + tabs.setAllowCollapse(true); + } + } + + public void setCallback(OnNavigationListener callback) { + mCallback = callback; + } + + public void setMenu(Menu menu, MenuPresenter.Callback cb) { + if (menu == mOptionsMenu) return; + + if (mOptionsMenu != null) { + mOptionsMenu.removeMenuPresenter(mActionMenuPresenter); + mOptionsMenu.removeMenuPresenter(mExpandedMenuPresenter); + } + + MenuBuilder builder = (MenuBuilder) menu; + mOptionsMenu = builder; + if (mMenuView != null) { + final ViewGroup oldParent = (ViewGroup) mMenuView.getParent(); + if (oldParent != null) { + oldParent.removeView(mMenuView); + } + } + if (mActionMenuPresenter == null) { + mActionMenuPresenter = new ActionMenuPresenter(mContext); + mActionMenuPresenter.setCallback(cb); + mActionMenuPresenter.setId(R.id.abs__action_menu_presenter); + mExpandedMenuPresenter = new ExpandedActionViewMenuPresenter(); + } + + ActionMenuView menuView; + final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, + LayoutParams.MATCH_PARENT); + if (!mSplitActionBar) { + mActionMenuPresenter.setExpandedActionViewsExclusive( + getResources_getBoolean(getContext(), + R.bool.abs__action_bar_expanded_action_views_exclusive)); + configPresenters(builder); + menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this); + final ViewGroup oldParent = (ViewGroup) menuView.getParent(); + if (oldParent != null && oldParent != this) { + oldParent.removeView(menuView); + } + addView(menuView, layoutParams); + } else { + mActionMenuPresenter.setExpandedActionViewsExclusive(false); + // Allow full screen width in split mode. + mActionMenuPresenter.setWidthLimit( + getContext().getResources().getDisplayMetrics().widthPixels, true); + // No limit to the item count; use whatever will fit. + mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE); + // Span the whole width + layoutParams.width = LayoutParams.MATCH_PARENT; + configPresenters(builder); + menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this); + if (mSplitView != null) { + final ViewGroup oldParent = (ViewGroup) menuView.getParent(); + if (oldParent != null && oldParent != mSplitView) { + oldParent.removeView(menuView); + } + menuView.setVisibility(getAnimatedVisibility()); + mSplitView.addView(menuView, layoutParams); + } else { + // We'll add this later if we missed it this time. + menuView.setLayoutParams(layoutParams); + } + } + mMenuView = menuView; + } + + private void configPresenters(MenuBuilder builder) { + if (builder != null) { + builder.addMenuPresenter(mActionMenuPresenter); + builder.addMenuPresenter(mExpandedMenuPresenter); + } else { + mActionMenuPresenter.initForMenu(mContext, null); + mExpandedMenuPresenter.initForMenu(mContext, null); + mActionMenuPresenter.updateMenuView(true); + mExpandedMenuPresenter.updateMenuView(true); + } + } + + public boolean hasExpandedActionView() { + return mExpandedMenuPresenter != null && + mExpandedMenuPresenter.mCurrentExpandedItem != null; + } + + public void collapseActionView() { + final MenuItemImpl item = mExpandedMenuPresenter == null ? null : + mExpandedMenuPresenter.mCurrentExpandedItem; + if (item != null) { + item.collapseActionView(); + } + } + + public void setCustomNavigationView(View view) { + final boolean showCustom = (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0; + if (mCustomNavView != null && showCustom) { + removeView(mCustomNavView); + } + mCustomNavView = view; + if (mCustomNavView != null && showCustom) { + addView(mCustomNavView); + } + } + + public CharSequence getTitle() { + return mTitle; + } + + /** + * Set the action bar title. This will always replace or override window titles. + * @param title Title to set + * + * @see #setWindowTitle(CharSequence) + */ + public void setTitle(CharSequence title) { + mUserTitle = true; + setTitleImpl(title); + } + + /** + * Set the window title. A window title will always be replaced or overridden by a user title. + * @param title Title to set + * + * @see #setTitle(CharSequence) + */ + public void setWindowTitle(CharSequence title) { + if (!mUserTitle) { + setTitleImpl(title); + } + } + + private void setTitleImpl(CharSequence title) { + mTitle = title; + if (mTitleView != null) { + mTitleView.setText(title); + final boolean visible = mExpandedActionView == null && + (mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0 && + (!TextUtils.isEmpty(mTitle) || !TextUtils.isEmpty(mSubtitle)); + mTitleLayout.setVisibility(visible ? VISIBLE : GONE); + } + if (mLogoNavItem != null) { + mLogoNavItem.setTitle(title); + } + } + + public CharSequence getSubtitle() { + return mSubtitle; + } + + public void setSubtitle(CharSequence subtitle) { + mSubtitle = subtitle; + if (mSubtitleView != null) { + mSubtitleView.setText(subtitle); + mSubtitleView.setVisibility(subtitle != null ? VISIBLE : GONE); + final boolean visible = mExpandedActionView == null && + (mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0 && + (!TextUtils.isEmpty(mTitle) || !TextUtils.isEmpty(mSubtitle)); + mTitleLayout.setVisibility(visible ? VISIBLE : GONE); + } + } + + public void setHomeButtonEnabled(boolean enable) { + mHomeLayout.setEnabled(enable); + mHomeLayout.setFocusable(enable); + // Make sure the home button has an accurate content description for accessibility. + if (!enable) { + mHomeLayout.setContentDescription(null); + } else if ((mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0) { + mHomeLayout.setContentDescription(mContext.getResources().getText( + R.string.abs__action_bar_up_description)); + } else { + mHomeLayout.setContentDescription(mContext.getResources().getText( + R.string.abs__action_bar_home_description)); + } + } + + public void setDisplayOptions(int options) { + final int flagsChanged = mDisplayOptions == -1 ? -1 : options ^ mDisplayOptions; + mDisplayOptions = options; + + if ((flagsChanged & DISPLAY_RELAYOUT_MASK) != 0) { + final boolean showHome = (options & ActionBar.DISPLAY_SHOW_HOME) != 0; + final int vis = showHome && mExpandedActionView == null ? VISIBLE : GONE; + mHomeLayout.setVisibility(vis); + + if ((flagsChanged & ActionBar.DISPLAY_HOME_AS_UP) != 0) { + final boolean setUp = (options & ActionBar.DISPLAY_HOME_AS_UP) != 0; + mHomeLayout.setUp(setUp); + + // Showing home as up implicitly enables interaction with it. + // In honeycomb it was always enabled, so make this transition + // a bit easier for developers in the common case. + // (It would be silly to show it as up without responding to it.) + if (setUp) { + setHomeButtonEnabled(true); + } + } + + if ((flagsChanged & ActionBar.DISPLAY_USE_LOGO) != 0) { + final boolean logoVis = mLogo != null && (options & ActionBar.DISPLAY_USE_LOGO) != 0; + mHomeLayout.setIcon(logoVis ? mLogo : mIcon); + } + + if ((flagsChanged & ActionBar.DISPLAY_SHOW_TITLE) != 0) { + if ((options & ActionBar.DISPLAY_SHOW_TITLE) != 0) { + initTitle(); + } else { + removeView(mTitleLayout); + } + } + + if (mTitleLayout != null && (flagsChanged & + (ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME)) != 0) { + final boolean homeAsUp = (mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0; + mTitleUpView.setVisibility(!showHome ? (homeAsUp ? VISIBLE : INVISIBLE) : GONE); + mTitleLayout.setEnabled(!showHome && homeAsUp); + } + + if ((flagsChanged & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 && mCustomNavView != null) { + if ((options & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) { + addView(mCustomNavView); + } else { + removeView(mCustomNavView); + } + } + + requestLayout(); + } else { + invalidate(); + } + + // Make sure the home button has an accurate content description for accessibility. + if (!mHomeLayout.isEnabled()) { + mHomeLayout.setContentDescription(null); + } else if ((options & ActionBar.DISPLAY_HOME_AS_UP) != 0) { + mHomeLayout.setContentDescription(mContext.getResources().getText( + R.string.abs__action_bar_up_description)); + } else { + mHomeLayout.setContentDescription(mContext.getResources().getText( + R.string.abs__action_bar_home_description)); + } + } + + public void setIcon(Drawable icon) { + mIcon = icon; + if (icon != null && + ((mDisplayOptions & ActionBar.DISPLAY_USE_LOGO) == 0 || mLogo == null)) { + mHomeLayout.setIcon(icon); + } + } + + public void setIcon(int resId) { + setIcon(mContext.getResources().getDrawable(resId)); + } + + public void setLogo(Drawable logo) { + mLogo = logo; + if (logo != null && (mDisplayOptions & ActionBar.DISPLAY_USE_LOGO) != 0) { + mHomeLayout.setIcon(logo); + } + } + + public void setLogo(int resId) { + setLogo(mContext.getResources().getDrawable(resId)); + } + + public void setNavigationMode(int mode) { + final int oldMode = mNavigationMode; + if (mode != oldMode) { + switch (oldMode) { + case ActionBar.NAVIGATION_MODE_LIST: + if (mListNavLayout != null) { + removeView(mListNavLayout); + } + break; + case ActionBar.NAVIGATION_MODE_TABS: + if (mTabScrollView != null && mIncludeTabs) { + removeView(mTabScrollView); + } + } + + switch (mode) { + case ActionBar.NAVIGATION_MODE_LIST: + if (mSpinner == null) { + mSpinner = new IcsSpinner(mContext, null, + R.attr.actionDropDownStyle); + mListNavLayout = (IcsLinearLayout) LayoutInflater.from(mContext) + .inflate(R.layout.abs__action_bar_tab_bar_view, null); + LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( + LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); + params.gravity = Gravity.CENTER; + mListNavLayout.addView(mSpinner, params); + } + if (mSpinner.getAdapter() != mSpinnerAdapter) { + mSpinner.setAdapter(mSpinnerAdapter); + } + mSpinner.setOnItemSelectedListener(mNavItemSelectedListener); + addView(mListNavLayout); + break; + case ActionBar.NAVIGATION_MODE_TABS: + if (mTabScrollView != null && mIncludeTabs) { + addView(mTabScrollView); + } + break; + } + mNavigationMode = mode; + requestLayout(); + } + } + + public void setDropdownAdapter(SpinnerAdapter adapter) { + mSpinnerAdapter = adapter; + if (mSpinner != null) { + mSpinner.setAdapter(adapter); + } + } + + public SpinnerAdapter getDropdownAdapter() { + return mSpinnerAdapter; + } + + public void setDropdownSelectedPosition(int position) { + mSpinner.setSelection(position); + } + + public int getDropdownSelectedPosition() { + return mSpinner.getSelectedItemPosition(); + } + + public View getCustomNavigationView() { + return mCustomNavView; + } + + public int getNavigationMode() { + return mNavigationMode; + } + + public int getDisplayOptions() { + return mDisplayOptions; + } + + @Override + protected ViewGroup.LayoutParams generateDefaultLayoutParams() { + // Used by custom nav views if they don't supply layout params. Everything else + // added to an ActionBarView should have them already. + return new ActionBar.LayoutParams(DEFAULT_CUSTOM_GRAVITY); + } + + @Override + protected void onFinishInflate() { + super.onFinishInflate(); + + addView(mHomeLayout); + + if (mCustomNavView != null && (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) { + final ViewParent parent = mCustomNavView.getParent(); + if (parent != this) { + if (parent instanceof ViewGroup) { + ((ViewGroup) parent).removeView(mCustomNavView); + } + addView(mCustomNavView); + } + } + } + + private void initTitle() { + if (mTitleLayout == null) { + LayoutInflater inflater = LayoutInflater.from(getContext()); + mTitleLayout = (LinearLayout) inflater.inflate(R.layout.abs__action_bar_title_item, + this, false); + mTitleView = (TextView) mTitleLayout.findViewById(R.id.abs__action_bar_title); + mSubtitleView = (TextView) mTitleLayout.findViewById(R.id.abs__action_bar_subtitle); + mTitleUpView = mTitleLayout.findViewById(R.id.abs__up); + + mTitleLayout.setOnClickListener(mUpClickListener); + + if (mTitleStyleRes != 0) { + mTitleView.setTextAppearance(mContext, mTitleStyleRes); + } + if (mTitle != null) { + mTitleView.setText(mTitle); + } + + if (mSubtitleStyleRes != 0) { + mSubtitleView.setTextAppearance(mContext, mSubtitleStyleRes); + } + if (mSubtitle != null) { + mSubtitleView.setText(mSubtitle); + mSubtitleView.setVisibility(VISIBLE); + } + + final boolean homeAsUp = (mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0; + final boolean showHome = (mDisplayOptions & ActionBar.DISPLAY_SHOW_HOME) != 0; + mTitleUpView.setVisibility(!showHome ? (homeAsUp ? VISIBLE : INVISIBLE) : GONE); + mTitleLayout.setEnabled(homeAsUp && !showHome); + } + + addView(mTitleLayout); + if (mExpandedActionView != null || + (TextUtils.isEmpty(mTitle) && TextUtils.isEmpty(mSubtitle))) { + // Don't show while in expanded mode or with empty text + mTitleLayout.setVisibility(GONE); + } + } + + public void setContextView(ActionBarContextView view) { + mContextView = view; + } + + public void setCollapsable(boolean collapsable) { + mIsCollapsable = collapsable; + } + + public boolean isCollapsed() { + return mIsCollapsed; + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + final int childCount = getChildCount(); + if (mIsCollapsable) { + int visibleChildren = 0; + for (int i = 0; i < childCount; i++) { + final View child = getChildAt(i); + if (child.getVisibility() != GONE && + !(child == mMenuView && mMenuView.getChildCount() == 0)) { + visibleChildren++; + } + } + + if (visibleChildren == 0) { + // No size for an empty action bar when collapsable. + setMeasuredDimension(0, 0); + mIsCollapsed = true; + return; + } + } + mIsCollapsed = false; + + int widthMode = MeasureSpec.getMode(widthMeasureSpec); + if (widthMode != MeasureSpec.EXACTLY) { + throw new IllegalStateException(getClass().getSimpleName() + " can only be used " + + "with android:layout_width=\"match_parent\" (or fill_parent)"); + } + + int heightMode = MeasureSpec.getMode(heightMeasureSpec); + if (heightMode != MeasureSpec.AT_MOST) { + throw new IllegalStateException(getClass().getSimpleName() + " can only be used " + + "with android:layout_height=\"wrap_content\""); + } + + int contentWidth = MeasureSpec.getSize(widthMeasureSpec); + + int maxHeight = mContentHeight > 0 ? + mContentHeight : MeasureSpec.getSize(heightMeasureSpec); + + final int verticalPadding = getPaddingTop() + getPaddingBottom(); + final int paddingLeft = getPaddingLeft(); + final int paddingRight = getPaddingRight(); + final int height = maxHeight - verticalPadding; + final int childSpecHeight = MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST); + + int availableWidth = contentWidth - paddingLeft - paddingRight; + int leftOfCenter = availableWidth / 2; + int rightOfCenter = leftOfCenter; + + HomeView homeLayout = mExpandedActionView != null ? mExpandedHomeLayout : mHomeLayout; + + if (homeLayout.getVisibility() != GONE) { + final ViewGroup.LayoutParams lp = homeLayout.getLayoutParams(); + int homeWidthSpec; + if (lp.width < 0) { + homeWidthSpec = MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST); + } else { + homeWidthSpec = MeasureSpec.makeMeasureSpec(lp.width, MeasureSpec.EXACTLY); + } + homeLayout.measure(homeWidthSpec, + MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY)); + final int homeWidth = homeLayout.getMeasuredWidth() + homeLayout.getLeftOffset(); + availableWidth = Math.max(0, availableWidth - homeWidth); + leftOfCenter = Math.max(0, availableWidth - homeWidth); + } + + if (mMenuView != null && mMenuView.getParent() == this) { + availableWidth = measureChildView(mMenuView, availableWidth, + childSpecHeight, 0); + rightOfCenter = Math.max(0, rightOfCenter - mMenuView.getMeasuredWidth()); + } + + if (mIndeterminateProgressView != null && + mIndeterminateProgressView.getVisibility() != GONE) { + availableWidth = measureChildView(mIndeterminateProgressView, availableWidth, + childSpecHeight, 0); + rightOfCenter = Math.max(0, + rightOfCenter - mIndeterminateProgressView.getMeasuredWidth()); + } + + final boolean showTitle = mTitleLayout != null && mTitleLayout.getVisibility() != GONE && + (mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0; + + if (mExpandedActionView == null) { + switch (mNavigationMode) { + case ActionBar.NAVIGATION_MODE_LIST: + if (mListNavLayout != null) { + final int itemPaddingSize = showTitle ? mItemPadding * 2 : mItemPadding; + availableWidth = Math.max(0, availableWidth - itemPaddingSize); + leftOfCenter = Math.max(0, leftOfCenter - itemPaddingSize); + mListNavLayout.measure( + MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST), + MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY)); + final int listNavWidth = mListNavLayout.getMeasuredWidth(); + availableWidth = Math.max(0, availableWidth - listNavWidth); + leftOfCenter = Math.max(0, leftOfCenter - listNavWidth); + } + break; + case ActionBar.NAVIGATION_MODE_TABS: + if (mTabScrollView != null) { + final int itemPaddingSize = showTitle ? mItemPadding * 2 : mItemPadding; + availableWidth = Math.max(0, availableWidth - itemPaddingSize); + leftOfCenter = Math.max(0, leftOfCenter - itemPaddingSize); + mTabScrollView.measure( + MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST), + MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY)); + final int tabWidth = mTabScrollView.getMeasuredWidth(); + availableWidth = Math.max(0, availableWidth - tabWidth); + leftOfCenter = Math.max(0, leftOfCenter - tabWidth); + } + break; + } + } + + View customView = null; + if (mExpandedActionView != null) { + customView = mExpandedActionView; + } else if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 && + mCustomNavView != null) { + customView = mCustomNavView; + } + + if (customView != null) { + final ViewGroup.LayoutParams lp = generateLayoutParams(customView.getLayoutParams()); + final ActionBar.LayoutParams ablp = lp instanceof ActionBar.LayoutParams ? + (ActionBar.LayoutParams) lp : null; + + int horizontalMargin = 0; + int verticalMargin = 0; + if (ablp != null) { + horizontalMargin = ablp.leftMargin + ablp.rightMargin; + verticalMargin = ablp.topMargin + ablp.bottomMargin; + } + + // If the action bar is wrapping to its content height, don't allow a custom + // view to MATCH_PARENT. + int customNavHeightMode; + if (mContentHeight <= 0) { + customNavHeightMode = MeasureSpec.AT_MOST; + } else { + customNavHeightMode = lp.height != LayoutParams.WRAP_CONTENT ? + MeasureSpec.EXACTLY : MeasureSpec.AT_MOST; + } + final int customNavHeight = Math.max(0, + (lp.height >= 0 ? Math.min(lp.height, height) : height) - verticalMargin); + + final int customNavWidthMode = lp.width != LayoutParams.WRAP_CONTENT ? + MeasureSpec.EXACTLY : MeasureSpec.AT_MOST; + int customNavWidth = Math.max(0, + (lp.width >= 0 ? Math.min(lp.width, availableWidth) : availableWidth) + - horizontalMargin); + final int hgrav = (ablp != null ? ablp.gravity : DEFAULT_CUSTOM_GRAVITY) & + Gravity.HORIZONTAL_GRAVITY_MASK; + + // Centering a custom view is treated specially; we try to center within the whole + // action bar rather than in the available space. + if (hgrav == Gravity.CENTER_HORIZONTAL && lp.width == LayoutParams.MATCH_PARENT) { + customNavWidth = Math.min(leftOfCenter, rightOfCenter) * 2; + } + + customView.measure( + MeasureSpec.makeMeasureSpec(customNavWidth, customNavWidthMode), + MeasureSpec.makeMeasureSpec(customNavHeight, customNavHeightMode)); + availableWidth -= horizontalMargin + customView.getMeasuredWidth(); + } + + if (mExpandedActionView == null && showTitle) { + availableWidth = measureChildView(mTitleLayout, availableWidth, + MeasureSpec.makeMeasureSpec(mContentHeight, MeasureSpec.EXACTLY), 0); + leftOfCenter = Math.max(0, leftOfCenter - mTitleLayout.getMeasuredWidth()); + } + + if (mContentHeight <= 0) { + int measuredHeight = 0; + for (int i = 0; i < childCount; i++) { + View v = getChildAt(i); + int paddedViewHeight = v.getMeasuredHeight() + verticalPadding; + if (paddedViewHeight > measuredHeight) { + measuredHeight = paddedViewHeight; + } + } + setMeasuredDimension(contentWidth, measuredHeight); + } else { + setMeasuredDimension(contentWidth, maxHeight); + } + + if (mContextView != null) { + mContextView.setContentHeight(getMeasuredHeight()); + } + + if (mProgressView != null && mProgressView.getVisibility() != GONE) { + mProgressView.measure(MeasureSpec.makeMeasureSpec( + contentWidth - mProgressBarPadding * 2, MeasureSpec.EXACTLY), + MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.AT_MOST)); + } + } + + @Override + protected void onLayout(boolean changed, int l, int t, int r, int b) { + int x = getPaddingLeft(); + final int y = getPaddingTop(); + final int contentHeight = b - t - getPaddingTop() - getPaddingBottom(); + + if (contentHeight <= 0) { + // Nothing to do if we can't see anything. + return; + } + + HomeView homeLayout = mExpandedActionView != null ? mExpandedHomeLayout : mHomeLayout; + if (homeLayout.getVisibility() != GONE) { + final int leftOffset = homeLayout.getLeftOffset(); + x += positionChild(homeLayout, x + leftOffset, y, contentHeight) + leftOffset; + } + + if (mExpandedActionView == null) { + final boolean showTitle = mTitleLayout != null && mTitleLayout.getVisibility() != GONE && + (mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0; + if (showTitle) { + x += positionChild(mTitleLayout, x, y, contentHeight); + } + + switch (mNavigationMode) { + case ActionBar.NAVIGATION_MODE_STANDARD: + break; + case ActionBar.NAVIGATION_MODE_LIST: + if (mListNavLayout != null) { + if (showTitle) x += mItemPadding; + x += positionChild(mListNavLayout, x, y, contentHeight) + mItemPadding; + } + break; + case ActionBar.NAVIGATION_MODE_TABS: + if (mTabScrollView != null) { + if (showTitle) x += mItemPadding; + x += positionChild(mTabScrollView, x, y, contentHeight) + mItemPadding; + } + break; + } + } + + int menuLeft = r - l - getPaddingRight(); + if (mMenuView != null && mMenuView.getParent() == this) { + positionChildInverse(mMenuView, menuLeft, y, contentHeight); + menuLeft -= mMenuView.getMeasuredWidth(); + } + + if (mIndeterminateProgressView != null && + mIndeterminateProgressView.getVisibility() != GONE) { + positionChildInverse(mIndeterminateProgressView, menuLeft, y, contentHeight); + menuLeft -= mIndeterminateProgressView.getMeasuredWidth(); + } + + View customView = null; + if (mExpandedActionView != null) { + customView = mExpandedActionView; + } else if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 && + mCustomNavView != null) { + customView = mCustomNavView; + } + if (customView != null) { + ViewGroup.LayoutParams lp = customView.getLayoutParams(); + final ActionBar.LayoutParams ablp = lp instanceof ActionBar.LayoutParams ? + (ActionBar.LayoutParams) lp : null; + + final int gravity = ablp != null ? ablp.gravity : DEFAULT_CUSTOM_GRAVITY; + final int navWidth = customView.getMeasuredWidth(); + + int topMargin = 0; + int bottomMargin = 0; + if (ablp != null) { + x += ablp.leftMargin; + menuLeft -= ablp.rightMargin; + topMargin = ablp.topMargin; + bottomMargin = ablp.bottomMargin; + } + + int hgravity = gravity & Gravity.HORIZONTAL_GRAVITY_MASK; + // See if we actually have room to truly center; if not push against left or right. + if (hgravity == Gravity.CENTER_HORIZONTAL) { + final int centeredLeft = ((getRight() - getLeft()) - navWidth) / 2; + if (centeredLeft < x) { + hgravity = Gravity.LEFT; + } else if (centeredLeft + navWidth > menuLeft) { + hgravity = Gravity.RIGHT; + } + } else if (gravity == -1) { + hgravity = Gravity.LEFT; + } + + int xpos = 0; + switch (hgravity) { + case Gravity.CENTER_HORIZONTAL: + xpos = ((getRight() - getLeft()) - navWidth) / 2; + break; + case Gravity.LEFT: + xpos = x; + break; + case Gravity.RIGHT: + xpos = menuLeft - navWidth; + break; + } + + int vgravity = gravity & Gravity.VERTICAL_GRAVITY_MASK; + + if (gravity == -1) { + vgravity = Gravity.CENTER_VERTICAL; + } + + int ypos = 0; + switch (vgravity) { + case Gravity.CENTER_VERTICAL: + final int paddedTop = getPaddingTop(); + final int paddedBottom = getBottom() - getTop() - getPaddingBottom(); + ypos = ((paddedBottom - paddedTop) - customView.getMeasuredHeight()) / 2; + break; + case Gravity.TOP: + ypos = getPaddingTop() + topMargin; + break; + case Gravity.BOTTOM: + ypos = getHeight() - getPaddingBottom() - customView.getMeasuredHeight() + - bottomMargin; + break; + } + final int customWidth = customView.getMeasuredWidth(); + customView.layout(xpos, ypos, xpos + customWidth, + ypos + customView.getMeasuredHeight()); + x += customWidth; + } + + if (mProgressView != null) { + mProgressView.bringToFront(); + final int halfProgressHeight = mProgressView.getMeasuredHeight() / 2; + mProgressView.layout(mProgressBarPadding, -halfProgressHeight, + mProgressBarPadding + mProgressView.getMeasuredWidth(), halfProgressHeight); + } + } + + @Override + public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs) { + return new ActionBar.LayoutParams(getContext(), attrs); + } + + @Override + public ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) { + if (lp == null) { + lp = generateDefaultLayoutParams(); + } + return lp; + } + + @Override + public Parcelable onSaveInstanceState() { + Parcelable superState = super.onSaveInstanceState(); + SavedState state = new SavedState(superState); + + if (mExpandedMenuPresenter != null && mExpandedMenuPresenter.mCurrentExpandedItem != null) { + state.expandedMenuItemId = mExpandedMenuPresenter.mCurrentExpandedItem.getItemId(); + } + + state.isOverflowOpen = isOverflowMenuShowing(); + + return state; + } + + @Override + public void onRestoreInstanceState(Parcelable p) { + SavedState state = (SavedState) p; + + super.onRestoreInstanceState(state.getSuperState()); + + if (state.expandedMenuItemId != 0 && + mExpandedMenuPresenter != null && mOptionsMenu != null) { + final MenuItem item = mOptionsMenu.findItem(state.expandedMenuItemId); + if (item != null) { + item.expandActionView(); + } + } + + if (state.isOverflowOpen) { + postShowOverflowMenu(); + } + } + + static class SavedState extends BaseSavedState { + int expandedMenuItemId; + boolean isOverflowOpen; + + SavedState(Parcelable superState) { + super(superState); + } + + private SavedState(Parcel in) { + super(in); + expandedMenuItemId = in.readInt(); + isOverflowOpen = in.readInt() != 0; + } + + @Override + public void writeToParcel(Parcel out, int flags) { + super.writeToParcel(out, flags); + out.writeInt(expandedMenuItemId); + out.writeInt(isOverflowOpen ? 1 : 0); + } + + public static final Parcelable.Creator CREATOR = + new Parcelable.Creator() { + public SavedState createFromParcel(Parcel in) { + return new SavedState(in); + } + + public SavedState[] newArray(int size) { + return new SavedState[size]; + } + }; + } + + public static class HomeView extends FrameLayout { + private View mUpView; + private ImageView mIconView; + private int mUpWidth; + + public HomeView(Context context) { + this(context, null); + } + + public HomeView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public void setUp(boolean isUp) { + mUpView.setVisibility(isUp ? VISIBLE : GONE); + } + + public void setIcon(Drawable icon) { + mIconView.setImageDrawable(icon); + } + + @Override + public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { + onPopulateAccessibilityEvent(event); + return true; + } + + @Override + public void onPopulateAccessibilityEvent(AccessibilityEvent event) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { + super.onPopulateAccessibilityEvent(event); + } + final CharSequence cdesc = getContentDescription(); + if (!TextUtils.isEmpty(cdesc)) { + event.getText().add(cdesc); + } + } + + @Override + public boolean dispatchHoverEvent(MotionEvent event) { + // Don't allow children to hover; we want this to be treated as a single component. + return onHoverEvent(event); + } + + @Override + protected void onFinishInflate() { + mUpView = findViewById(R.id.abs__up); + mIconView = (ImageView) findViewById(R.id.abs__home); + } + + public int getLeftOffset() { + return mUpView.getVisibility() == GONE ? mUpWidth : 0; + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + measureChildWithMargins(mUpView, widthMeasureSpec, 0, heightMeasureSpec, 0); + final LayoutParams upLp = (LayoutParams) mUpView.getLayoutParams(); + mUpWidth = upLp.leftMargin + mUpView.getMeasuredWidth() + upLp.rightMargin; + int width = mUpView.getVisibility() == GONE ? 0 : mUpWidth; + int height = upLp.topMargin + mUpView.getMeasuredHeight() + upLp.bottomMargin; + measureChildWithMargins(mIconView, widthMeasureSpec, width, heightMeasureSpec, 0); + final LayoutParams iconLp = (LayoutParams) mIconView.getLayoutParams(); + width += iconLp.leftMargin + mIconView.getMeasuredWidth() + iconLp.rightMargin; + height = Math.max(height, + iconLp.topMargin + mIconView.getMeasuredHeight() + iconLp.bottomMargin); + + final int widthMode = MeasureSpec.getMode(widthMeasureSpec); + final int heightMode = MeasureSpec.getMode(heightMeasureSpec); + final int widthSize = MeasureSpec.getSize(widthMeasureSpec); + final int heightSize = MeasureSpec.getSize(heightMeasureSpec); + + switch (widthMode) { + case MeasureSpec.AT_MOST: + width = Math.min(width, widthSize); + break; + case MeasureSpec.EXACTLY: + width = widthSize; + break; + case MeasureSpec.UNSPECIFIED: + default: + break; + } + switch (heightMode) { + case MeasureSpec.AT_MOST: + height = Math.min(height, heightSize); + break; + case MeasureSpec.EXACTLY: + height = heightSize; + break; + case MeasureSpec.UNSPECIFIED: + default: + break; + } + setMeasuredDimension(width, height); + } + + @Override + protected void onLayout(boolean changed, int l, int t, int r, int b) { + final int vCenter = (b - t) / 2; + //UNUSED int width = r - l; + int upOffset = 0; + if (mUpView.getVisibility() != GONE) { + final LayoutParams upLp = (LayoutParams) mUpView.getLayoutParams(); + final int upHeight = mUpView.getMeasuredHeight(); + final int upWidth = mUpView.getMeasuredWidth(); + final int upTop = vCenter - upHeight / 2; + mUpView.layout(0, upTop, upWidth, upTop + upHeight); + upOffset = upLp.leftMargin + upWidth + upLp.rightMargin; + //UNUSED width -= upOffset; + l += upOffset; + } + final LayoutParams iconLp = (LayoutParams) mIconView.getLayoutParams(); + final int iconHeight = mIconView.getMeasuredHeight(); + final int iconWidth = mIconView.getMeasuredWidth(); + final int hCenter = (r - l) / 2; + final int iconLeft = upOffset + Math.max(iconLp.leftMargin, hCenter - iconWidth / 2); + final int iconTop = Math.max(iconLp.topMargin, vCenter - iconHeight / 2); + mIconView.layout(iconLeft, iconTop, iconLeft + iconWidth, iconTop + iconHeight); + } + } + + private class ExpandedActionViewMenuPresenter implements MenuPresenter { + MenuBuilder mMenu; + MenuItemImpl mCurrentExpandedItem; + + @Override + public void initForMenu(Context context, MenuBuilder menu) { + // Clear the expanded action view when menus change. + if (mMenu != null && mCurrentExpandedItem != null) { + mMenu.collapseItemActionView(mCurrentExpandedItem); + } + mMenu = menu; + } + + @Override + public MenuView getMenuView(ViewGroup root) { + return null; + } + + @Override + public void updateMenuView(boolean cleared) { + // Make sure the expanded item we have is still there. + if (mCurrentExpandedItem != null) { + boolean found = false; + + if (mMenu != null) { + final int count = mMenu.size(); + for (int i = 0; i < count; i++) { + final MenuItem item = mMenu.getItem(i); + if (item == mCurrentExpandedItem) { + found = true; + break; + } + } + } + + if (!found) { + // The item we had expanded disappeared. Collapse. + collapseItemActionView(mMenu, mCurrentExpandedItem); + } + } + } + + @Override + public void setCallback(Callback cb) { + } + + @Override + public boolean onSubMenuSelected(SubMenuBuilder subMenu) { + return false; + } + + @Override + public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) { + } + + @Override + public boolean flagActionItems() { + return false; + } + + @Override + public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item) { + mExpandedActionView = item.getActionView(); + mExpandedHomeLayout.setIcon(mIcon.getConstantState().newDrawable(/* TODO getResources() */)); + mCurrentExpandedItem = item; + if (mExpandedActionView.getParent() != ActionBarView.this) { + addView(mExpandedActionView); + } + if (mExpandedHomeLayout.getParent() != ActionBarView.this) { + addView(mExpandedHomeLayout); + } + mHomeLayout.setVisibility(GONE); + if (mTitleLayout != null) mTitleLayout.setVisibility(GONE); + if (mTabScrollView != null) mTabScrollView.setVisibility(GONE); + if (mSpinner != null) mSpinner.setVisibility(GONE); + if (mCustomNavView != null) mCustomNavView.setVisibility(GONE); + requestLayout(); + item.setActionViewExpanded(true); + + if (mExpandedActionView instanceof CollapsibleActionView) { + ((CollapsibleActionView) mExpandedActionView).onActionViewExpanded(); + } + + return true; + } + + @Override + public boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item) { + // Do this before detaching the actionview from the hierarchy, in case + // it needs to dismiss the soft keyboard, etc. + if (mExpandedActionView instanceof CollapsibleActionView) { + ((CollapsibleActionView) mExpandedActionView).onActionViewCollapsed(); + } + + removeView(mExpandedActionView); + removeView(mExpandedHomeLayout); + mExpandedActionView = null; + if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_HOME) != 0) { + mHomeLayout.setVisibility(VISIBLE); + } + if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0) { + if (mTitleLayout == null) { + initTitle(); + } else { + mTitleLayout.setVisibility(VISIBLE); + } + } + if (mTabScrollView != null && mNavigationMode == ActionBar.NAVIGATION_MODE_TABS) { + mTabScrollView.setVisibility(VISIBLE); + } + if (mSpinner != null && mNavigationMode == ActionBar.NAVIGATION_MODE_LIST) { + mSpinner.setVisibility(VISIBLE); + } + if (mCustomNavView != null && (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) { + mCustomNavView.setVisibility(VISIBLE); + } + mExpandedHomeLayout.setIcon(null); + mCurrentExpandedItem = null; + requestLayout(); + item.setActionViewExpanded(false); + + return true; + } + + @Override + public int getId() { + return 0; + } + + @Override + public Parcelable onSaveInstanceState() { + return null; + } + + @Override + public void onRestoreInstanceState(Parcelable state) { + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/CapitalizingButton.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/CapitalizingButton.java new file mode 100644 index 000000000..fa3698f3b --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/CapitalizingButton.java @@ -0,0 +1,40 @@ +package com.actionbarsherlock.internal.widget; + +import java.util.Locale; +import android.content.Context; +import android.content.res.TypedArray; +import android.os.Build; +import android.util.AttributeSet; +import android.widget.Button; + +public class CapitalizingButton extends Button { + private static final boolean SANS_ICE_CREAM = Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH; + private static final boolean IS_GINGERBREAD = Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD; + + private static final int[] R_styleable_Button = new int[] { + android.R.attr.textAllCaps + }; + private static final int R_styleable_Button_textAllCaps = 0; + + private boolean mAllCaps; + + public CapitalizingButton(Context context, AttributeSet attrs) { + super(context, attrs); + + TypedArray a = context.obtainStyledAttributes(attrs, R_styleable_Button); + mAllCaps = a.getBoolean(R_styleable_Button_textAllCaps, true); + a.recycle(); + } + + public void setTextCompat(CharSequence text) { + if (SANS_ICE_CREAM && mAllCaps && text != null) { + if (IS_GINGERBREAD) { + setText(text.toString().toUpperCase(Locale.ROOT)); + } else { + setText(text.toString().toUpperCase()); + } + } else { + setText(text); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/CapitalizingTextView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/CapitalizingTextView.java new file mode 100644 index 000000000..673ec554f --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/CapitalizingTextView.java @@ -0,0 +1,44 @@ +package com.actionbarsherlock.internal.widget; + +import java.util.Locale; +import android.content.Context; +import android.content.res.TypedArray; +import android.os.Build; +import android.util.AttributeSet; +import android.widget.TextView; + +public class CapitalizingTextView extends TextView { + private static final boolean SANS_ICE_CREAM = Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH; + private static final boolean IS_GINGERBREAD = Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD; + + private static final int[] R_styleable_TextView = new int[] { + android.R.attr.textAllCaps + }; + private static final int R_styleable_TextView_textAllCaps = 0; + + private boolean mAllCaps; + + public CapitalizingTextView(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public CapitalizingTextView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + + TypedArray a = context.obtainStyledAttributes(attrs, R_styleable_TextView, defStyle, 0); + mAllCaps = a.getBoolean(R_styleable_TextView_textAllCaps, true); + a.recycle(); + } + + public void setTextCompat(CharSequence text) { + if (SANS_ICE_CREAM && mAllCaps && text != null) { + if (IS_GINGERBREAD) { + setText(text.toString().toUpperCase(Locale.ROOT)); + } else { + setText(text.toString().toUpperCase()); + } + } else { + setText(text); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/FakeDialogPhoneWindow.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/FakeDialogPhoneWindow.java new file mode 100644 index 000000000..ad1b4f0a8 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/FakeDialogPhoneWindow.java @@ -0,0 +1,64 @@ +package com.actionbarsherlock.internal.widget; + +import static android.view.View.MeasureSpec.EXACTLY; +import android.content.Context; +import android.content.res.TypedArray; +import android.util.AttributeSet; +import android.util.DisplayMetrics; +import android.util.TypedValue; +import android.widget.LinearLayout; +import com.actionbarsherlock.R; + +public class FakeDialogPhoneWindow extends LinearLayout { + final TypedValue mMinWidthMajor = new TypedValue(); + final TypedValue mMinWidthMinor = new TypedValue(); + + public FakeDialogPhoneWindow(Context context, AttributeSet attrs) { + super(context, attrs); + + TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockTheme); + + a.getValue(R.styleable.SherlockTheme_windowMinWidthMajor, mMinWidthMajor); + a.getValue(R.styleable.SherlockTheme_windowMinWidthMinor, mMinWidthMinor); + + a.recycle(); + } + + /* Stolen from PhoneWindow */ + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + final DisplayMetrics metrics = getContext().getResources().getDisplayMetrics(); + final boolean isPortrait = metrics.widthPixels < metrics.heightPixels; + + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + + int width = getMeasuredWidth(); + boolean measure = false; + + widthMeasureSpec = MeasureSpec.makeMeasureSpec(width, EXACTLY); + + final TypedValue tv = isPortrait ? mMinWidthMinor : mMinWidthMajor; + + if (tv.type != TypedValue.TYPE_NULL) { + final int min; + if (tv.type == TypedValue.TYPE_DIMENSION) { + min = (int)tv.getDimension(metrics); + } else if (tv.type == TypedValue.TYPE_FRACTION) { + min = (int)tv.getFraction(metrics.widthPixels, metrics.widthPixels); + } else { + min = 0; + } + + if (width < min) { + widthMeasureSpec = MeasureSpec.makeMeasureSpec(min, EXACTLY); + measure = true; + } + } + + // TODO: Support height? + + if (measure) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsAbsSpinner.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsAbsSpinner.java new file mode 100644 index 000000000..ce0cb3bca --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsAbsSpinner.java @@ -0,0 +1,479 @@ +/* + * Copyright (C) 2006 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.actionbarsherlock.internal.widget; + +import android.content.Context; +import android.database.DataSetObserver; +import android.graphics.Rect; +import android.os.Build; +import android.os.Parcel; +import android.os.Parcelable; +import android.util.AttributeSet; +import android.util.SparseArray; +import android.view.View; +import android.view.ViewGroup; +import android.widget.SpinnerAdapter; + +/** + * An abstract base class for spinner widgets. SDK users will probably not + * need to use this class. + * + * @attr ref android.R.styleable#AbsSpinner_entries + */ +public abstract class IcsAbsSpinner extends IcsAdapterView { + private static final boolean IS_HONEYCOMB = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB; + + SpinnerAdapter mAdapter; + + int mHeightMeasureSpec; + int mWidthMeasureSpec; + boolean mBlockLayoutRequests; + + int mSelectionLeftPadding = 0; + int mSelectionTopPadding = 0; + int mSelectionRightPadding = 0; + int mSelectionBottomPadding = 0; + final Rect mSpinnerPadding = new Rect(); + + final RecycleBin mRecycler = new RecycleBin(); + private DataSetObserver mDataSetObserver; + + /** Temporary frame to hold a child View's frame rectangle */ + private Rect mTouchFrame; + + public IcsAbsSpinner(Context context) { + super(context); + initAbsSpinner(); + } + + public IcsAbsSpinner(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public IcsAbsSpinner(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + initAbsSpinner(); + + /* + TypedArray a = context.obtainStyledAttributes(attrs, + com.android.internal.R.styleable.AbsSpinner, defStyle, 0); + + CharSequence[] entries = a.getTextArray(R.styleable.AbsSpinner_entries); + if (entries != null) { + ArrayAdapter adapter = + new ArrayAdapter(context, + R.layout.simple_spinner_item, entries); + adapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item); + setAdapter(adapter); + } + + a.recycle(); + */ + } + + /** + * Common code for different constructor flavors + */ + private void initAbsSpinner() { + setFocusable(true); + setWillNotDraw(false); + } + + /** + * The Adapter is used to provide the data which backs this Spinner. + * It also provides methods to transform spinner items based on their position + * relative to the selected item. + * @param adapter The SpinnerAdapter to use for this Spinner + */ + @Override + public void setAdapter(SpinnerAdapter adapter) { + if (null != mAdapter) { + mAdapter.unregisterDataSetObserver(mDataSetObserver); + resetList(); + } + + mAdapter = adapter; + + mOldSelectedPosition = INVALID_POSITION; + mOldSelectedRowId = INVALID_ROW_ID; + + if (mAdapter != null) { + mOldItemCount = mItemCount; + mItemCount = mAdapter.getCount(); + checkFocus(); + + mDataSetObserver = new AdapterDataSetObserver(); + mAdapter.registerDataSetObserver(mDataSetObserver); + + int position = mItemCount > 0 ? 0 : INVALID_POSITION; + + setSelectedPositionInt(position); + setNextSelectedPositionInt(position); + + if (mItemCount == 0) { + // Nothing selected + checkSelectionChanged(); + } + + } else { + checkFocus(); + resetList(); + // Nothing selected + checkSelectionChanged(); + } + + requestLayout(); + } + + /** + * Clear out all children from the list + */ + void resetList() { + mDataChanged = false; + mNeedSync = false; + + removeAllViewsInLayout(); + mOldSelectedPosition = INVALID_POSITION; + mOldSelectedRowId = INVALID_ROW_ID; + + setSelectedPositionInt(INVALID_POSITION); + setNextSelectedPositionInt(INVALID_POSITION); + invalidate(); + } + + /** + * @see android.view.View#measure(int, int) + * + * Figure out the dimensions of this Spinner. The width comes from + * the widthMeasureSpec as Spinnners can't have their width set to + * UNSPECIFIED. The height is based on the height of the selected item + * plus padding. + */ + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + int widthMode = MeasureSpec.getMode(widthMeasureSpec); + int widthSize; + int heightSize; + + final int mPaddingLeft = getPaddingLeft(); + final int mPaddingTop = getPaddingTop(); + final int mPaddingRight = getPaddingRight(); + final int mPaddingBottom = getPaddingBottom(); + + mSpinnerPadding.left = mPaddingLeft > mSelectionLeftPadding ? mPaddingLeft + : mSelectionLeftPadding; + mSpinnerPadding.top = mPaddingTop > mSelectionTopPadding ? mPaddingTop + : mSelectionTopPadding; + mSpinnerPadding.right = mPaddingRight > mSelectionRightPadding ? mPaddingRight + : mSelectionRightPadding; + mSpinnerPadding.bottom = mPaddingBottom > mSelectionBottomPadding ? mPaddingBottom + : mSelectionBottomPadding; + + if (mDataChanged) { + handleDataChanged(); + } + + int preferredHeight = 0; + int preferredWidth = 0; + boolean needsMeasuring = true; + + int selectedPosition = getSelectedItemPosition(); + if (selectedPosition >= 0 && mAdapter != null && selectedPosition < mAdapter.getCount()) { + // Try looking in the recycler. (Maybe we were measured once already) + View view = mRecycler.get(selectedPosition); + if (view == null) { + // Make a new one + view = mAdapter.getView(selectedPosition, null, this); + } + + if (view != null) { + // Put in recycler for re-measuring and/or layout + mRecycler.put(selectedPosition, view); + } + + if (view != null) { + if (view.getLayoutParams() == null) { + mBlockLayoutRequests = true; + view.setLayoutParams(generateDefaultLayoutParams()); + mBlockLayoutRequests = false; + } + measureChild(view, widthMeasureSpec, heightMeasureSpec); + + preferredHeight = getChildHeight(view) + mSpinnerPadding.top + mSpinnerPadding.bottom; + preferredWidth = getChildWidth(view) + mSpinnerPadding.left + mSpinnerPadding.right; + + needsMeasuring = false; + } + } + + if (needsMeasuring) { + // No views -- just use padding + preferredHeight = mSpinnerPadding.top + mSpinnerPadding.bottom; + if (widthMode == MeasureSpec.UNSPECIFIED) { + preferredWidth = mSpinnerPadding.left + mSpinnerPadding.right; + } + } + + preferredHeight = Math.max(preferredHeight, getSuggestedMinimumHeight()); + preferredWidth = Math.max(preferredWidth, getSuggestedMinimumWidth()); + + if (IS_HONEYCOMB) { + heightSize = resolveSizeAndState(preferredHeight, heightMeasureSpec, 0); + widthSize = resolveSizeAndState(preferredWidth, widthMeasureSpec, 0); + } else { + heightSize = resolveSize(preferredHeight, heightMeasureSpec); + widthSize = resolveSize(preferredWidth, widthMeasureSpec); + } + + setMeasuredDimension(widthSize, heightSize); + mHeightMeasureSpec = heightMeasureSpec; + mWidthMeasureSpec = widthMeasureSpec; + } + + int getChildHeight(View child) { + return child.getMeasuredHeight(); + } + + int getChildWidth(View child) { + return child.getMeasuredWidth(); + } + + @Override + protected ViewGroup.LayoutParams generateDefaultLayoutParams() { + return new ViewGroup.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.WRAP_CONTENT); + } + + void recycleAllViews() { + final int childCount = getChildCount(); + final IcsAbsSpinner.RecycleBin recycleBin = mRecycler; + final int position = mFirstPosition; + + // All views go in recycler + for (int i = 0; i < childCount; i++) { + View v = getChildAt(i); + int index = position + i; + recycleBin.put(index, v); + } + } + + /** + * Jump directly to a specific item in the adapter data. + */ + public void setSelection(int position, boolean animate) { + // Animate only if requested position is already on screen somewhere + boolean shouldAnimate = animate && mFirstPosition <= position && + position <= mFirstPosition + getChildCount() - 1; + setSelectionInt(position, shouldAnimate); + } + + @Override + public void setSelection(int position) { + setNextSelectedPositionInt(position); + requestLayout(); + invalidate(); + } + + + /** + * Makes the item at the supplied position selected. + * + * @param position Position to select + * @param animate Should the transition be animated + * + */ + void setSelectionInt(int position, boolean animate) { + if (position != mOldSelectedPosition) { + mBlockLayoutRequests = true; + int delta = position - mSelectedPosition; + setNextSelectedPositionInt(position); + layout(delta, animate); + mBlockLayoutRequests = false; + } + } + + abstract void layout(int delta, boolean animate); + + @Override + public View getSelectedView() { + if (mItemCount > 0 && mSelectedPosition >= 0) { + return getChildAt(mSelectedPosition - mFirstPosition); + } else { + return null; + } + } + + /** + * Override to prevent spamming ourselves with layout requests + * as we place views + * + * @see android.view.View#requestLayout() + */ + @Override + public void requestLayout() { + if (!mBlockLayoutRequests) { + super.requestLayout(); + } + } + + @Override + public SpinnerAdapter getAdapter() { + return mAdapter; + } + + @Override + public int getCount() { + return mItemCount; + } + + /** + * Maps a point to a position in the list. + * + * @param x X in local coordinate + * @param y Y in local coordinate + * @return The position of the item which contains the specified point, or + * {@link #INVALID_POSITION} if the point does not intersect an item. + */ + public int pointToPosition(int x, int y) { + Rect frame = mTouchFrame; + if (frame == null) { + mTouchFrame = new Rect(); + frame = mTouchFrame; + } + + final int count = getChildCount(); + for (int i = count - 1; i >= 0; i--) { + View child = getChildAt(i); + if (child.getVisibility() == View.VISIBLE) { + child.getHitRect(frame); + if (frame.contains(x, y)) { + return mFirstPosition + i; + } + } + } + return INVALID_POSITION; + } + + static class SavedState extends BaseSavedState { + long selectedId; + int position; + + /** + * Constructor called from {@link AbsSpinner#onSaveInstanceState()} + */ + SavedState(Parcelable superState) { + super(superState); + } + + /** + * Constructor called from {@link #CREATOR} + */ + private SavedState(Parcel in) { + super(in); + selectedId = in.readLong(); + position = in.readInt(); + } + + @Override + public void writeToParcel(Parcel out, int flags) { + super.writeToParcel(out, flags); + out.writeLong(selectedId); + out.writeInt(position); + } + + @Override + public String toString() { + return "AbsSpinner.SavedState{" + + Integer.toHexString(System.identityHashCode(this)) + + " selectedId=" + selectedId + + " position=" + position + "}"; + } + + public static final Parcelable.Creator CREATOR + = new Parcelable.Creator() { + public SavedState createFromParcel(Parcel in) { + return new SavedState(in); + } + + public SavedState[] newArray(int size) { + return new SavedState[size]; + } + }; + } + + @Override + public Parcelable onSaveInstanceState() { + Parcelable superState = super.onSaveInstanceState(); + SavedState ss = new SavedState(superState); + ss.selectedId = getSelectedItemId(); + if (ss.selectedId >= 0) { + ss.position = getSelectedItemPosition(); + } else { + ss.position = INVALID_POSITION; + } + return ss; + } + + @Override + public void onRestoreInstanceState(Parcelable state) { + SavedState ss = (SavedState) state; + + super.onRestoreInstanceState(ss.getSuperState()); + + if (ss.selectedId >= 0) { + mDataChanged = true; + mNeedSync = true; + mSyncRowId = ss.selectedId; + mSyncPosition = ss.position; + mSyncMode = SYNC_SELECTED_POSITION; + requestLayout(); + } + } + + class RecycleBin { + private final SparseArray mScrapHeap = new SparseArray(); + + public void put(int position, View v) { + mScrapHeap.put(position, v); + } + + View get(int position) { + // System.out.print("Looking for " + position); + View result = mScrapHeap.get(position); + if (result != null) { + // System.out.println(" HIT"); + mScrapHeap.delete(position); + } else { + // System.out.println(" MISS"); + } + return result; + } + + void clear() { + final SparseArray scrapHeap = mScrapHeap; + final int count = scrapHeap.size(); + for (int i = 0; i < count; i++) { + final View view = scrapHeap.valueAt(i); + if (view != null) { + removeDetachedView(view, true); + } + } + scrapHeap.clear(); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsAdapterView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsAdapterView.java new file mode 100644 index 000000000..c786dc5c1 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsAdapterView.java @@ -0,0 +1,1160 @@ +/* + * Copyright (C) 2006 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.actionbarsherlock.internal.widget; + +import android.content.Context; +import android.database.DataSetObserver; +import android.os.Parcelable; +import android.os.SystemClock; +import android.util.AttributeSet; +import android.util.SparseArray; +import android.view.ContextMenu; +import android.view.SoundEffectConstants; +import android.view.View; +import android.view.ViewDebug; +import android.view.ViewGroup; +import android.view.accessibility.AccessibilityEvent; +import android.view.accessibility.AccessibilityNodeInfo; +import android.widget.Adapter; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.ListView; + + +/** + * An AdapterView is a view whose children are determined by an {@link Adapter}. + * + *

+ * See {@link ListView}, {@link GridView}, {@link Spinner} and + * {@link Gallery} for commonly used subclasses of AdapterView. + * + *

+ *

Developer Guides

+ *

For more information about using AdapterView, read the + * Binding to Data with AdapterView + * developer guide.

+ */ +public abstract class IcsAdapterView extends ViewGroup { + + /** + * The item view type returned by {@link Adapter#getItemViewType(int)} when + * the adapter does not want the item's view recycled. + */ + public static final int ITEM_VIEW_TYPE_IGNORE = -1; + + /** + * The item view type returned by {@link Adapter#getItemViewType(int)} when + * the item is a header or footer. + */ + public static final int ITEM_VIEW_TYPE_HEADER_OR_FOOTER = -2; + + /** + * The position of the first child displayed + */ + @ViewDebug.ExportedProperty(category = "scrolling") + int mFirstPosition = 0; + + /** + * The offset in pixels from the top of the AdapterView to the top + * of the view to select during the next layout. + */ + int mSpecificTop; + + /** + * Position from which to start looking for mSyncRowId + */ + int mSyncPosition; + + /** + * Row id to look for when data has changed + */ + long mSyncRowId = INVALID_ROW_ID; + + /** + * Height of the view when mSyncPosition and mSyncRowId where set + */ + long mSyncHeight; + + /** + * True if we need to sync to mSyncRowId + */ + boolean mNeedSync = false; + + /** + * Indicates whether to sync based on the selection or position. Possible + * values are {@link #SYNC_SELECTED_POSITION} or + * {@link #SYNC_FIRST_POSITION}. + */ + int mSyncMode; + + /** + * Our height after the last layout + */ + private int mLayoutHeight; + + /** + * Sync based on the selected child + */ + static final int SYNC_SELECTED_POSITION = 0; + + /** + * Sync based on the first child displayed + */ + static final int SYNC_FIRST_POSITION = 1; + + /** + * Maximum amount of time to spend in {@link #findSyncPosition()} + */ + static final int SYNC_MAX_DURATION_MILLIS = 100; + + /** + * Indicates that this view is currently being laid out. + */ + boolean mInLayout = false; + + /** + * The listener that receives notifications when an item is selected. + */ + OnItemSelectedListener mOnItemSelectedListener; + + /** + * The listener that receives notifications when an item is clicked. + */ + OnItemClickListener mOnItemClickListener; + + /** + * The listener that receives notifications when an item is long clicked. + */ + OnItemLongClickListener mOnItemLongClickListener; + + /** + * True if the data has changed since the last layout + */ + boolean mDataChanged; + + /** + * The position within the adapter's data set of the item to select + * during the next layout. + */ + @ViewDebug.ExportedProperty(category = "list") + int mNextSelectedPosition = INVALID_POSITION; + + /** + * The item id of the item to select during the next layout. + */ + long mNextSelectedRowId = INVALID_ROW_ID; + + /** + * The position within the adapter's data set of the currently selected item. + */ + @ViewDebug.ExportedProperty(category = "list") + int mSelectedPosition = INVALID_POSITION; + + /** + * The item id of the currently selected item. + */ + long mSelectedRowId = INVALID_ROW_ID; + + /** + * View to show if there are no items to show. + */ + private View mEmptyView; + + /** + * The number of items in the current adapter. + */ + @ViewDebug.ExportedProperty(category = "list") + int mItemCount; + + /** + * The number of items in the adapter before a data changed event occurred. + */ + int mOldItemCount; + + /** + * Represents an invalid position. All valid positions are in the range 0 to 1 less than the + * number of items in the current adapter. + */ + public static final int INVALID_POSITION = -1; + + /** + * Represents an empty or invalid row id + */ + public static final long INVALID_ROW_ID = Long.MIN_VALUE; + + /** + * The last selected position we used when notifying + */ + int mOldSelectedPosition = INVALID_POSITION; + + /** + * The id of the last selected position we used when notifying + */ + long mOldSelectedRowId = INVALID_ROW_ID; + + /** + * Indicates what focusable state is requested when calling setFocusable(). + * In addition to this, this view has other criteria for actually + * determining the focusable state (such as whether its empty or the text + * filter is shown). + * + * @see #setFocusable(boolean) + * @see #checkFocus() + */ + private boolean mDesiredFocusableState; + private boolean mDesiredFocusableInTouchModeState; + + private SelectionNotifier mSelectionNotifier; + /** + * When set to true, calls to requestLayout() will not propagate up the parent hierarchy. + * This is used to layout the children during a layout pass. + */ + boolean mBlockLayoutRequests = false; + + public IcsAdapterView(Context context) { + super(context); + } + + public IcsAdapterView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public IcsAdapterView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + } + + /** + * Register a callback to be invoked when an item in this AdapterView has + * been clicked. + * + * @param listener The callback that will be invoked. + */ + public void setOnItemClickListener(OnItemClickListener listener) { + mOnItemClickListener = listener; + } + + /** + * @return The callback to be invoked with an item in this AdapterView has + * been clicked, or null id no callback has been set. + */ + public final OnItemClickListener getOnItemClickListener() { + return mOnItemClickListener; + } + + /** + * Call the OnItemClickListener, if it is defined. + * + * @param view The view within the AdapterView that was clicked. + * @param position The position of the view in the adapter. + * @param id The row id of the item that was clicked. + * @return True if there was an assigned OnItemClickListener that was + * called, false otherwise is returned. + */ + public boolean performItemClick(View view, int position, long id) { + if (mOnItemClickListener != null) { + playSoundEffect(SoundEffectConstants.CLICK); + if (view != null) { + view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED); + } + mOnItemClickListener.onItemClick(/*this*/null, view, position, id); + return true; + } + + return false; + } + + /** + * Interface definition for a callback to be invoked when an item in this + * view has been clicked and held. + */ + public interface OnItemLongClickListener { + /** + * Callback method to be invoked when an item in this view has been + * clicked and held. + * + * Implementers can call getItemAtPosition(position) if they need to access + * the data associated with the selected item. + * + * @param parent The AbsListView where the click happened + * @param view The view within the AbsListView that was clicked + * @param position The position of the view in the list + * @param id The row id of the item that was clicked + * + * @return true if the callback consumed the long click, false otherwise + */ + boolean onItemLongClick(IcsAdapterView parent, View view, int position, long id); + } + + + /** + * Register a callback to be invoked when an item in this AdapterView has + * been clicked and held + * + * @param listener The callback that will run + */ + public void setOnItemLongClickListener(OnItemLongClickListener listener) { + if (!isLongClickable()) { + setLongClickable(true); + } + mOnItemLongClickListener = listener; + } + + /** + * @return The callback to be invoked with an item in this AdapterView has + * been clicked and held, or null id no callback as been set. + */ + public final OnItemLongClickListener getOnItemLongClickListener() { + return mOnItemLongClickListener; + } + + /** + * Interface definition for a callback to be invoked when + * an item in this view has been selected. + */ + public interface OnItemSelectedListener { + /** + *

Callback method to be invoked when an item in this view has been + * selected. This callback is invoked only when the newly selected + * position is different from the previously selected position or if + * there was no selected item.

+ * + * Impelmenters can call getItemAtPosition(position) if they need to access the + * data associated with the selected item. + * + * @param parent The AdapterView where the selection happened + * @param view The view within the AdapterView that was clicked + * @param position The position of the view in the adapter + * @param id The row id of the item that is selected + */ + void onItemSelected(IcsAdapterView parent, View view, int position, long id); + + /** + * Callback method to be invoked when the selection disappears from this + * view. The selection can disappear for instance when touch is activated + * or when the adapter becomes empty. + * + * @param parent The AdapterView that now contains no selected item. + */ + void onNothingSelected(IcsAdapterView parent); + } + + + /** + * Register a callback to be invoked when an item in this AdapterView has + * been selected. + * + * @param listener The callback that will run + */ + public void setOnItemSelectedListener(OnItemSelectedListener listener) { + mOnItemSelectedListener = listener; + } + + public final OnItemSelectedListener getOnItemSelectedListener() { + return mOnItemSelectedListener; + } + + /** + * Extra menu information provided to the + * {@link android.view.View.OnCreateContextMenuListener#onCreateContextMenu(ContextMenu, View, ContextMenuInfo) } + * callback when a context menu is brought up for this AdapterView. + * + */ + public static class AdapterContextMenuInfo implements ContextMenu.ContextMenuInfo { + + public AdapterContextMenuInfo(View targetView, int position, long id) { + this.targetView = targetView; + this.position = position; + this.id = id; + } + + /** + * The child view for which the context menu is being displayed. This + * will be one of the children of this AdapterView. + */ + public View targetView; + + /** + * The position in the adapter for which the context menu is being + * displayed. + */ + public int position; + + /** + * The row id of the item for which the context menu is being displayed. + */ + public long id; + } + + /** + * Returns the adapter currently associated with this widget. + * + * @return The adapter used to provide this view's content. + */ + public abstract T getAdapter(); + + /** + * Sets the adapter that provides the data and the views to represent the data + * in this widget. + * + * @param adapter The adapter to use to create this view's content. + */ + public abstract void setAdapter(T adapter); + + /** + * This method is not supported and throws an UnsupportedOperationException when called. + * + * @param child Ignored. + * + * @throws UnsupportedOperationException Every time this method is invoked. + */ + @Override + public void addView(View child) { + throw new UnsupportedOperationException("addView(View) is not supported in AdapterView"); + } + + /** + * This method is not supported and throws an UnsupportedOperationException when called. + * + * @param child Ignored. + * @param index Ignored. + * + * @throws UnsupportedOperationException Every time this method is invoked. + */ + @Override + public void addView(View child, int index) { + throw new UnsupportedOperationException("addView(View, int) is not supported in AdapterView"); + } + + /** + * This method is not supported and throws an UnsupportedOperationException when called. + * + * @param child Ignored. + * @param params Ignored. + * + * @throws UnsupportedOperationException Every time this method is invoked. + */ + @Override + public void addView(View child, LayoutParams params) { + throw new UnsupportedOperationException("addView(View, LayoutParams) " + + "is not supported in AdapterView"); + } + + /** + * This method is not supported and throws an UnsupportedOperationException when called. + * + * @param child Ignored. + * @param index Ignored. + * @param params Ignored. + * + * @throws UnsupportedOperationException Every time this method is invoked. + */ + @Override + public void addView(View child, int index, LayoutParams params) { + throw new UnsupportedOperationException("addView(View, int, LayoutParams) " + + "is not supported in AdapterView"); + } + + /** + * This method is not supported and throws an UnsupportedOperationException when called. + * + * @param child Ignored. + * + * @throws UnsupportedOperationException Every time this method is invoked. + */ + @Override + public void removeView(View child) { + throw new UnsupportedOperationException("removeView(View) is not supported in AdapterView"); + } + + /** + * This method is not supported and throws an UnsupportedOperationException when called. + * + * @param index Ignored. + * + * @throws UnsupportedOperationException Every time this method is invoked. + */ + @Override + public void removeViewAt(int index) { + throw new UnsupportedOperationException("removeViewAt(int) is not supported in AdapterView"); + } + + /** + * This method is not supported and throws an UnsupportedOperationException when called. + * + * @throws UnsupportedOperationException Every time this method is invoked. + */ + @Override + public void removeAllViews() { + throw new UnsupportedOperationException("removeAllViews() is not supported in AdapterView"); + } + + @Override + protected void onLayout(boolean changed, int left, int top, int right, int bottom) { + mLayoutHeight = getHeight(); + } + + /** + * Return the position of the currently selected item within the adapter's data set + * + * @return int Position (starting at 0), or {@link #INVALID_POSITION} if there is nothing selected. + */ + @ViewDebug.CapturedViewProperty + public int getSelectedItemPosition() { + return mNextSelectedPosition; + } + + /** + * @return The id corresponding to the currently selected item, or {@link #INVALID_ROW_ID} + * if nothing is selected. + */ + @ViewDebug.CapturedViewProperty + public long getSelectedItemId() { + return mNextSelectedRowId; + } + + /** + * @return The view corresponding to the currently selected item, or null + * if nothing is selected + */ + public abstract View getSelectedView(); + + /** + * @return The data corresponding to the currently selected item, or + * null if there is nothing selected. + */ + public Object getSelectedItem() { + T adapter = getAdapter(); + int selection = getSelectedItemPosition(); + if (adapter != null && adapter.getCount() > 0 && selection >= 0) { + return adapter.getItem(selection); + } else { + return null; + } + } + + /** + * @return The number of items owned by the Adapter associated with this + * AdapterView. (This is the number of data items, which may be + * larger than the number of visible views.) + */ + @ViewDebug.CapturedViewProperty + public int getCount() { + return mItemCount; + } + + /** + * Get the position within the adapter's data set for the view, where view is a an adapter item + * or a descendant of an adapter item. + * + * @param view an adapter item, or a descendant of an adapter item. This must be visible in this + * AdapterView at the time of the call. + * @return the position within the adapter's data set of the view, or {@link #INVALID_POSITION} + * if the view does not correspond to a list item (or it is not currently visible). + */ + public int getPositionForView(View view) { + View listItem = view; + try { + View v; + while (!(v = (View) listItem.getParent()).equals(this)) { + listItem = v; + } + } catch (ClassCastException e) { + // We made it up to the window without find this list view + return INVALID_POSITION; + } + + // Search the children for the list item + final int childCount = getChildCount(); + for (int i = 0; i < childCount; i++) { + if (getChildAt(i).equals(listItem)) { + return mFirstPosition + i; + } + } + + // Child not found! + return INVALID_POSITION; + } + + /** + * Returns the position within the adapter's data set for the first item + * displayed on screen. + * + * @return The position within the adapter's data set + */ + public int getFirstVisiblePosition() { + return mFirstPosition; + } + + /** + * Returns the position within the adapter's data set for the last item + * displayed on screen. + * + * @return The position within the adapter's data set + */ + public int getLastVisiblePosition() { + return mFirstPosition + getChildCount() - 1; + } + + /** + * Sets the currently selected item. To support accessibility subclasses that + * override this method must invoke the overriden super method first. + * + * @param position Index (starting at 0) of the data item to be selected. + */ + public abstract void setSelection(int position); + + /** + * Sets the view to show if the adapter is empty + */ + public void setEmptyView(View emptyView) { + mEmptyView = emptyView; + + final T adapter = getAdapter(); + final boolean empty = ((adapter == null) || adapter.isEmpty()); + updateEmptyStatus(empty); + } + + /** + * When the current adapter is empty, the AdapterView can display a special view + * call the empty view. The empty view is used to provide feedback to the user + * that no data is available in this AdapterView. + * + * @return The view to show if the adapter is empty. + */ + public View getEmptyView() { + return mEmptyView; + } + + /** + * Indicates whether this view is in filter mode. Filter mode can for instance + * be enabled by a user when typing on the keyboard. + * + * @return True if the view is in filter mode, false otherwise. + */ + boolean isInFilterMode() { + return false; + } + + @Override + public void setFocusable(boolean focusable) { + final T adapter = getAdapter(); + final boolean empty = adapter == null || adapter.getCount() == 0; + + mDesiredFocusableState = focusable; + if (!focusable) { + mDesiredFocusableInTouchModeState = false; + } + + super.setFocusable(focusable && (!empty || isInFilterMode())); + } + + @Override + public void setFocusableInTouchMode(boolean focusable) { + final T adapter = getAdapter(); + final boolean empty = adapter == null || adapter.getCount() == 0; + + mDesiredFocusableInTouchModeState = focusable; + if (focusable) { + mDesiredFocusableState = true; + } + + super.setFocusableInTouchMode(focusable && (!empty || isInFilterMode())); + } + + void checkFocus() { + final T adapter = getAdapter(); + final boolean empty = adapter == null || adapter.getCount() == 0; + final boolean focusable = !empty || isInFilterMode(); + // The order in which we set focusable in touch mode/focusable may matter + // for the client, see View.setFocusableInTouchMode() comments for more + // details + super.setFocusableInTouchMode(focusable && mDesiredFocusableInTouchModeState); + super.setFocusable(focusable && mDesiredFocusableState); + if (mEmptyView != null) { + updateEmptyStatus((adapter == null) || adapter.isEmpty()); + } + } + + /** + * Update the status of the list based on the empty parameter. If empty is true and + * we have an empty view, display it. In all the other cases, make sure that the listview + * is VISIBLE and that the empty view is GONE (if it's not null). + */ + private void updateEmptyStatus(boolean empty) { + if (isInFilterMode()) { + empty = false; + } + + if (empty) { + if (mEmptyView != null) { + mEmptyView.setVisibility(View.VISIBLE); + setVisibility(View.GONE); + } else { + // If the caller just removed our empty view, make sure the list view is visible + setVisibility(View.VISIBLE); + } + + // We are now GONE, so pending layouts will not be dispatched. + // Force one here to make sure that the state of the list matches + // the state of the adapter. + if (mDataChanged) { + this.onLayout(false, getLeft(), getTop(), getRight(), getBottom()); + } + } else { + if (mEmptyView != null) mEmptyView.setVisibility(View.GONE); + setVisibility(View.VISIBLE); + } + } + + /** + * Gets the data associated with the specified position in the list. + * + * @param position Which data to get + * @return The data associated with the specified position in the list + */ + public Object getItemAtPosition(int position) { + T adapter = getAdapter(); + return (adapter == null || position < 0) ? null : adapter.getItem(position); + } + + public long getItemIdAtPosition(int position) { + T adapter = getAdapter(); + return (adapter == null || position < 0) ? INVALID_ROW_ID : adapter.getItemId(position); + } + + @Override + public void setOnClickListener(OnClickListener l) { + throw new RuntimeException("Don't call setOnClickListener for an AdapterView. " + + "You probably want setOnItemClickListener instead"); + } + + /** + * Override to prevent freezing of any views created by the adapter. + */ + @Override + protected void dispatchSaveInstanceState(SparseArray container) { + dispatchFreezeSelfOnly(container); + } + + /** + * Override to prevent thawing of any views created by the adapter. + */ + @Override + protected void dispatchRestoreInstanceState(SparseArray container) { + dispatchThawSelfOnly(container); + } + + class AdapterDataSetObserver extends DataSetObserver { + + private Parcelable mInstanceState = null; + + @Override + public void onChanged() { + mDataChanged = true; + mOldItemCount = mItemCount; + mItemCount = getAdapter().getCount(); + + // Detect the case where a cursor that was previously invalidated has + // been repopulated with new data. + if (IcsAdapterView.this.getAdapter().hasStableIds() && mInstanceState != null + && mOldItemCount == 0 && mItemCount > 0) { + IcsAdapterView.this.onRestoreInstanceState(mInstanceState); + mInstanceState = null; + } else { + rememberSyncState(); + } + checkFocus(); + requestLayout(); + } + + @Override + public void onInvalidated() { + mDataChanged = true; + + if (IcsAdapterView.this.getAdapter().hasStableIds()) { + // Remember the current state for the case where our hosting activity is being + // stopped and later restarted + mInstanceState = IcsAdapterView.this.onSaveInstanceState(); + } + + // Data is invalid so we should reset our state + mOldItemCount = mItemCount; + mItemCount = 0; + mSelectedPosition = INVALID_POSITION; + mSelectedRowId = INVALID_ROW_ID; + mNextSelectedPosition = INVALID_POSITION; + mNextSelectedRowId = INVALID_ROW_ID; + mNeedSync = false; + + checkFocus(); + requestLayout(); + } + + public void clearSavedState() { + mInstanceState = null; + } + } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + removeCallbacks(mSelectionNotifier); + } + + private class SelectionNotifier implements Runnable { + public void run() { + if (mDataChanged) { + // Data has changed between when this SelectionNotifier + // was posted and now. We need to wait until the AdapterView + // has been synched to the new data. + if (getAdapter() != null) { + post(this); + } + } else { + fireOnSelected(); + } + } + } + + void selectionChanged() { + if (mOnItemSelectedListener != null) { + if (mInLayout || mBlockLayoutRequests) { + // If we are in a layout traversal, defer notification + // by posting. This ensures that the view tree is + // in a consistent state and is able to accomodate + // new layout or invalidate requests. + if (mSelectionNotifier == null) { + mSelectionNotifier = new SelectionNotifier(); + } + post(mSelectionNotifier); + } else { + fireOnSelected(); + } + } + + // we fire selection events here not in View + if (mSelectedPosition != ListView.INVALID_POSITION && isShown() && !isInTouchMode()) { + sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED); + } + } + + private void fireOnSelected() { + if (mOnItemSelectedListener == null) + return; + + int selection = this.getSelectedItemPosition(); + if (selection >= 0) { + View v = getSelectedView(); + mOnItemSelectedListener.onItemSelected(this, v, selection, + getAdapter().getItemId(selection)); + } else { + mOnItemSelectedListener.onNothingSelected(this); + } + } + + @Override + public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { + View selectedView = getSelectedView(); + if (selectedView != null && selectedView.getVisibility() == VISIBLE + && selectedView.dispatchPopulateAccessibilityEvent(event)) { + return true; + } + return false; + } + + @Override + public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) { + if (super.onRequestSendAccessibilityEvent(child, event)) { + // Add a record for ourselves as well. + AccessibilityEvent record = AccessibilityEvent.obtain(); + onInitializeAccessibilityEvent(record); + // Populate with the text of the requesting child. + child.dispatchPopulateAccessibilityEvent(record); + event.appendRecord(record); + return true; + } + return false; + } + + @Override + public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { + super.onInitializeAccessibilityNodeInfo(info); + info.setScrollable(isScrollableForAccessibility()); + View selectedView = getSelectedView(); + if (selectedView != null) { + info.setEnabled(selectedView.isEnabled()); + } + } + + @Override + public void onInitializeAccessibilityEvent(AccessibilityEvent event) { + super.onInitializeAccessibilityEvent(event); + event.setScrollable(isScrollableForAccessibility()); + View selectedView = getSelectedView(); + if (selectedView != null) { + event.setEnabled(selectedView.isEnabled()); + } + event.setCurrentItemIndex(getSelectedItemPosition()); + event.setFromIndex(getFirstVisiblePosition()); + event.setToIndex(getLastVisiblePosition()); + event.setItemCount(getCount()); + } + + private boolean isScrollableForAccessibility() { + T adapter = getAdapter(); + if (adapter != null) { + final int itemCount = adapter.getCount(); + return itemCount > 0 + && (getFirstVisiblePosition() > 0 || getLastVisiblePosition() < itemCount - 1); + } + return false; + } + + @Override + protected boolean canAnimate() { + return super.canAnimate() && mItemCount > 0; + } + + void handleDataChanged() { + final int count = mItemCount; + boolean found = false; + + if (count > 0) { + + int newPos; + + // Find the row we are supposed to sync to + if (mNeedSync) { + // Update this first, since setNextSelectedPositionInt inspects + // it + mNeedSync = false; + + // See if we can find a position in the new data with the same + // id as the old selection + newPos = findSyncPosition(); + if (newPos >= 0) { + // Verify that new selection is selectable + int selectablePos = lookForSelectablePosition(newPos, true); + if (selectablePos == newPos) { + // Same row id is selected + setNextSelectedPositionInt(newPos); + found = true; + } + } + } + if (!found) { + // Try to use the same position if we can't find matching data + newPos = getSelectedItemPosition(); + + // Pin position to the available range + if (newPos >= count) { + newPos = count - 1; + } + if (newPos < 0) { + newPos = 0; + } + + // Make sure we select something selectable -- first look down + int selectablePos = lookForSelectablePosition(newPos, true); + if (selectablePos < 0) { + // Looking down didn't work -- try looking up + selectablePos = lookForSelectablePosition(newPos, false); + } + if (selectablePos >= 0) { + setNextSelectedPositionInt(selectablePos); + checkSelectionChanged(); + found = true; + } + } + } + if (!found) { + // Nothing is selected + mSelectedPosition = INVALID_POSITION; + mSelectedRowId = INVALID_ROW_ID; + mNextSelectedPosition = INVALID_POSITION; + mNextSelectedRowId = INVALID_ROW_ID; + mNeedSync = false; + checkSelectionChanged(); + } + } + + void checkSelectionChanged() { + if ((mSelectedPosition != mOldSelectedPosition) || (mSelectedRowId != mOldSelectedRowId)) { + selectionChanged(); + mOldSelectedPosition = mSelectedPosition; + mOldSelectedRowId = mSelectedRowId; + } + } + + /** + * Searches the adapter for a position matching mSyncRowId. The search starts at mSyncPosition + * and then alternates between moving up and moving down until 1) we find the right position, or + * 2) we run out of time, or 3) we have looked at every position + * + * @return Position of the row that matches mSyncRowId, or {@link #INVALID_POSITION} if it can't + * be found + */ + int findSyncPosition() { + int count = mItemCount; + + if (count == 0) { + return INVALID_POSITION; + } + + long idToMatch = mSyncRowId; + int seed = mSyncPosition; + + // If there isn't a selection don't hunt for it + if (idToMatch == INVALID_ROW_ID) { + return INVALID_POSITION; + } + + // Pin seed to reasonable values + seed = Math.max(0, seed); + seed = Math.min(count - 1, seed); + + long endTime = SystemClock.uptimeMillis() + SYNC_MAX_DURATION_MILLIS; + + long rowId; + + // first position scanned so far + int first = seed; + + // last position scanned so far + int last = seed; + + // True if we should move down on the next iteration + boolean next = false; + + // True when we have looked at the first item in the data + boolean hitFirst; + + // True when we have looked at the last item in the data + boolean hitLast; + + // Get the item ID locally (instead of getItemIdAtPosition), so + // we need the adapter + T adapter = getAdapter(); + if (adapter == null) { + return INVALID_POSITION; + } + + while (SystemClock.uptimeMillis() <= endTime) { + rowId = adapter.getItemId(seed); + if (rowId == idToMatch) { + // Found it! + return seed; + } + + hitLast = last == count - 1; + hitFirst = first == 0; + + if (hitLast && hitFirst) { + // Looked at everything + break; + } + + if (hitFirst || (next && !hitLast)) { + // Either we hit the top, or we are trying to move down + last++; + seed = last; + // Try going up next time + next = false; + } else if (hitLast || (!next && !hitFirst)) { + // Either we hit the bottom, or we are trying to move up + first--; + seed = first; + // Try going down next time + next = true; + } + + } + + return INVALID_POSITION; + } + + /** + * Find a position that can be selected (i.e., is not a separator). + * + * @param position The starting position to look at. + * @param lookDown Whether to look down for other positions. + * @return The next selectable position starting at position and then searching either up or + * down. Returns {@link #INVALID_POSITION} if nothing can be found. + */ + int lookForSelectablePosition(int position, boolean lookDown) { + return position; + } + + /** + * Utility to keep mSelectedPosition and mSelectedRowId in sync + * @param position Our current position + */ + void setSelectedPositionInt(int position) { + mSelectedPosition = position; + mSelectedRowId = getItemIdAtPosition(position); + } + + /** + * Utility to keep mNextSelectedPosition and mNextSelectedRowId in sync + * @param position Intended value for mSelectedPosition the next time we go + * through layout + */ + void setNextSelectedPositionInt(int position) { + mNextSelectedPosition = position; + mNextSelectedRowId = getItemIdAtPosition(position); + // If we are trying to sync to the selection, update that too + if (mNeedSync && mSyncMode == SYNC_SELECTED_POSITION && position >= 0) { + mSyncPosition = position; + mSyncRowId = mNextSelectedRowId; + } + } + + /** + * Remember enough information to restore the screen state when the data has + * changed. + * + */ + void rememberSyncState() { + if (getChildCount() > 0) { + mNeedSync = true; + mSyncHeight = mLayoutHeight; + if (mSelectedPosition >= 0) { + // Sync the selection state + View v = getChildAt(mSelectedPosition - mFirstPosition); + mSyncRowId = mNextSelectedRowId; + mSyncPosition = mNextSelectedPosition; + if (v != null) { + mSpecificTop = v.getTop(); + } + mSyncMode = SYNC_SELECTED_POSITION; + } else { + // Sync the based on the offset of the first view + View v = getChildAt(0); + T adapter = getAdapter(); + if (mFirstPosition >= 0 && mFirstPosition < adapter.getCount()) { + mSyncRowId = adapter.getItemId(mFirstPosition); + } else { + mSyncRowId = NO_ID; + } + mSyncPosition = mFirstPosition; + if (v != null) { + mSpecificTop = v.getTop(); + } + mSyncMode = SYNC_FIRST_POSITION; + } + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java new file mode 100644 index 000000000..1b4463a59 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java @@ -0,0 +1,272 @@ +package com.actionbarsherlock.internal.widget; + +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.Canvas; +import android.graphics.drawable.Drawable; +import android.util.AttributeSet; +import android.view.View; +import com.actionbarsherlock.internal.nineoldandroids.widget.NineLinearLayout; + +/** + * A simple extension of a regular linear layout that supports the divider API + * of Android 4.0+. The dividers are added adjacent to the children by changing + * their layout params. If you need to rely on the margins which fall in the + * same orientation as the layout you should wrap the child in a simple + * {@link android.widget.FrameLayout} so it can receive the margin. + */ +public class IcsLinearLayout extends NineLinearLayout { + private static final int[] LinearLayout = new int[] { + /* 0 */ android.R.attr.divider, + /* 1 */ android.R.attr.showDividers, + /* 2 */ android.R.attr.dividerPadding, + }; + private static final int LinearLayout_divider = 0; + private static final int LinearLayout_showDividers = 1; + private static final int LinearLayout_dividerPadding = 2; + + /** + * Don't show any dividers. + */ + public static final int SHOW_DIVIDER_NONE = 0; + /** + * Show a divider at the beginning of the group. + */ + public static final int SHOW_DIVIDER_BEGINNING = 1; + /** + * Show dividers between each item in the group. + */ + public static final int SHOW_DIVIDER_MIDDLE = 2; + /** + * Show a divider at the end of the group. + */ + public static final int SHOW_DIVIDER_END = 4; + + + private Drawable mDivider; + private int mDividerWidth; + private int mDividerHeight; + private int mShowDividers; + private int mDividerPadding; + + + public IcsLinearLayout(Context context, AttributeSet attrs) { + super(context, attrs); + + TypedArray a = context.obtainStyledAttributes(attrs, /*com.android.internal.R.styleable.*/LinearLayout); + + setDividerDrawable(a.getDrawable(/*com.android.internal.R.styleable.*/LinearLayout_divider)); + mShowDividers = a.getInt(/*com.android.internal.R.styleable.*/LinearLayout_showDividers, SHOW_DIVIDER_NONE); + mDividerPadding = a.getDimensionPixelSize(/*com.android.internal.R.styleable.*/LinearLayout_dividerPadding, 0); + + a.recycle(); + } + + /** + * Set how dividers should be shown between items in this layout + * + * @param showDividers One or more of {@link #SHOW_DIVIDER_BEGINNING}, + * {@link #SHOW_DIVIDER_MIDDLE}, or {@link #SHOW_DIVIDER_END}, + * or {@link #SHOW_DIVIDER_NONE} to show no dividers. + */ + public void setShowDividers(int showDividers) { + if (showDividers != mShowDividers) { + requestLayout(); + invalidate(); //XXX This is required if you are toggling a divider off + } + mShowDividers = showDividers; + } + + /** + * @return A flag set indicating how dividers should be shown around items. + * @see #setShowDividers(int) + */ + public int getShowDividers() { + return mShowDividers; + } + + /** + * Set a drawable to be used as a divider between items. + * @param divider Drawable that will divide each item. + * @see #setShowDividers(int) + */ + public void setDividerDrawable(Drawable divider) { + if (divider == mDivider) { + return; + } + mDivider = divider; + if (divider != null) { + mDividerWidth = divider.getIntrinsicWidth(); + mDividerHeight = divider.getIntrinsicHeight(); + } else { + mDividerWidth = 0; + mDividerHeight = 0; + } + setWillNotDraw(divider == null); + requestLayout(); + } + + /** + * Set padding displayed on both ends of dividers. + * + * @param padding Padding value in pixels that will be applied to each end + * + * @see #setShowDividers(int) + * @see #setDividerDrawable(Drawable) + * @see #getDividerPadding() + */ + public void setDividerPadding(int padding) { + mDividerPadding = padding; + } + + /** + * Get the padding size used to inset dividers in pixels + * + * @see #setShowDividers(int) + * @see #setDividerDrawable(Drawable) + * @see #setDividerPadding(int) + */ + public int getDividerPadding() { + return mDividerPadding; + } + + /** + * Get the width of the current divider drawable. + * + * @hide Used internally by framework. + */ + public int getDividerWidth() { + return mDividerWidth; + } + + @Override + protected void measureChildWithMargins(View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed) { + final int index = indexOfChild(child); + final int orientation = getOrientation(); + final LayoutParams params = (LayoutParams) child.getLayoutParams(); + if (hasDividerBeforeChildAt(index)) { + if (orientation == VERTICAL) { + //Account for the divider by pushing everything up + params.topMargin = mDividerHeight; + } else { + //Account for the divider by pushing everything left + params.leftMargin = mDividerWidth; + } + } + + final int count = getChildCount(); + if (index == count - 1) { + if (hasDividerBeforeChildAt(count)) { + if (orientation == VERTICAL) { + params.bottomMargin = mDividerHeight; + } else { + params.rightMargin = mDividerWidth; + } + } + } + super.measureChildWithMargins(child, parentWidthMeasureSpec, widthUsed, parentHeightMeasureSpec, heightUsed); + } + + @Override + protected void onDraw(Canvas canvas) { + if (mDivider != null) { + if (getOrientation() == VERTICAL) { + drawDividersVertical(canvas); + } else { + drawDividersHorizontal(canvas); + } + } + super.onDraw(canvas); + } + + void drawDividersVertical(Canvas canvas) { + final int count = getChildCount(); + for (int i = 0; i < count; i++) { + final View child = getChildAt(i); + + if (child != null && child.getVisibility() != GONE) { + if (hasDividerBeforeChildAt(i)) { + final LayoutParams lp = (LayoutParams) child.getLayoutParams(); + final int top = child.getTop() - lp.topMargin/* - mDividerHeight*/; + drawHorizontalDivider(canvas, top); + } + } + } + + if (hasDividerBeforeChildAt(count)) { + final View child = getChildAt(count - 1); + int bottom = 0; + if (child == null) { + bottom = getHeight() - getPaddingBottom() - mDividerHeight; + } else { + final LayoutParams lp = (LayoutParams) child.getLayoutParams(); + bottom = child.getBottom()/* + lp.bottomMargin*/; + } + drawHorizontalDivider(canvas, bottom); + } + } + + void drawDividersHorizontal(Canvas canvas) { + final int count = getChildCount(); + for (int i = 0; i < count; i++) { + final View child = getChildAt(i); + + if (child != null && child.getVisibility() != GONE) { + if (hasDividerBeforeChildAt(i)) { + final LayoutParams lp = (LayoutParams) child.getLayoutParams(); + final int left = child.getLeft() - lp.leftMargin/* - mDividerWidth*/; + drawVerticalDivider(canvas, left); + } + } + } + + if (hasDividerBeforeChildAt(count)) { + final View child = getChildAt(count - 1); + int right = 0; + if (child == null) { + right = getWidth() - getPaddingRight() - mDividerWidth; + } else { + final LayoutParams lp = (LayoutParams) child.getLayoutParams(); + right = child.getRight()/* + lp.rightMargin*/; + } + drawVerticalDivider(canvas, right); + } + } + + void drawHorizontalDivider(Canvas canvas, int top) { + mDivider.setBounds(getPaddingLeft() + mDividerPadding, top, + getWidth() - getPaddingRight() - mDividerPadding, top + mDividerHeight); + mDivider.draw(canvas); + } + + void drawVerticalDivider(Canvas canvas, int left) { + mDivider.setBounds(left, getPaddingTop() + mDividerPadding, + left + mDividerWidth, getHeight() - getPaddingBottom() - mDividerPadding); + mDivider.draw(canvas); + } + + /** + * Determines where to position dividers between children. + * + * @param childIndex Index of child to check for preceding divider + * @return true if there should be a divider before the child at childIndex + * @hide Pending API consideration. Currently only used internally by the system. + */ + protected boolean hasDividerBeforeChildAt(int childIndex) { + if (childIndex == 0) { + return (mShowDividers & SHOW_DIVIDER_BEGINNING) != 0; + } else if (childIndex == getChildCount()) { + return (mShowDividers & SHOW_DIVIDER_END) != 0; + } else if ((mShowDividers & SHOW_DIVIDER_MIDDLE) != 0) { + boolean hasVisibleViewBefore = false; + for (int i = childIndex - 1; i >= 0; i--) { + if (getChildAt(i).getVisibility() != GONE) { + hasVisibleViewBefore = true; + break; + } + } + return hasVisibleViewBefore; + } + return false; + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsListPopupWindow.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsListPopupWindow.java new file mode 100644 index 000000000..d13c6cea9 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsListPopupWindow.java @@ -0,0 +1,644 @@ +package com.actionbarsherlock.internal.widget; + +import com.actionbarsherlock.R; + +import android.content.Context; +import android.content.res.Resources; +import android.database.DataSetObserver; +import android.graphics.Rect; +import android.graphics.drawable.Drawable; +import android.os.Build; +import android.os.Handler; +import android.util.AttributeSet; +import android.view.ContextThemeWrapper; +import android.view.MotionEvent; +import android.view.View; +import android.view.View.MeasureSpec; +import android.view.View.OnTouchListener; +import android.view.ViewGroup; +import android.view.ViewParent; +import android.widget.AbsListView; +import android.widget.AdapterView; +import android.widget.LinearLayout; +import android.widget.ListAdapter; +import android.widget.ListView; +import android.widget.PopupWindow; + +/** + * A proxy between pre- and post-Honeycomb implementations of this class. + */ +public class IcsListPopupWindow { + /** + * This value controls the length of time that the user + * must leave a pointer down without scrolling to expand + * the autocomplete dropdown list to cover the IME. + */ + private static final int EXPAND_LIST_TIMEOUT = 250; + + private Context mContext; + private PopupWindow mPopup; + private ListAdapter mAdapter; + private DropDownListView mDropDownList; + + private int mDropDownHeight = ViewGroup.LayoutParams.WRAP_CONTENT; + private int mDropDownWidth = ViewGroup.LayoutParams.WRAP_CONTENT; + private int mDropDownHorizontalOffset; + private int mDropDownVerticalOffset; + private boolean mDropDownVerticalOffsetSet; + + private int mListItemExpandMaximum = Integer.MAX_VALUE; + + private View mPromptView; + private int mPromptPosition = POSITION_PROMPT_ABOVE; + + private DataSetObserver mObserver; + + private View mDropDownAnchorView; + + private Drawable mDropDownListHighlight; + + private AdapterView.OnItemClickListener mItemClickListener; + private AdapterView.OnItemSelectedListener mItemSelectedListener; + + private final ResizePopupRunnable mResizePopupRunnable = new ResizePopupRunnable(); + private final PopupTouchInterceptor mTouchInterceptor = new PopupTouchInterceptor(); + private final PopupScrollListener mScrollListener = new PopupScrollListener(); + private final ListSelectorHider mHideSelector = new ListSelectorHider(); + + private Handler mHandler = new Handler(); + + private Rect mTempRect = new Rect(); + + private boolean mModal; + + public static final int POSITION_PROMPT_ABOVE = 0; + public static final int POSITION_PROMPT_BELOW = 1; + + public IcsListPopupWindow(Context context) { + this(context, null, R.attr.listPopupWindowStyle); + } + + public IcsListPopupWindow(Context context, AttributeSet attrs, int defStyleAttr) { + mContext = context; + mPopup = new PopupWindow(context, attrs, defStyleAttr); + mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED); + } + + public IcsListPopupWindow(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { + mContext = context; + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + Context wrapped = new ContextThemeWrapper(context, defStyleRes); + mPopup = new PopupWindow(wrapped, attrs, defStyleAttr); + } else { + mPopup = new PopupWindow(context, attrs, defStyleAttr, defStyleRes); + } + mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED); + } + + public void setAdapter(ListAdapter adapter) { + if (mObserver == null) { + mObserver = new PopupDataSetObserver(); + } else if (mAdapter != null) { + mAdapter.unregisterDataSetObserver(mObserver); + } + mAdapter = adapter; + if (mAdapter != null) { + adapter.registerDataSetObserver(mObserver); + } + + if (mDropDownList != null) { + mDropDownList.setAdapter(mAdapter); + } + } + + public void setPromptPosition(int position) { + mPromptPosition = position; + } + + public void setModal(boolean modal) { + mModal = true; + mPopup.setFocusable(modal); + } + + public void setBackgroundDrawable(Drawable d) { + mPopup.setBackgroundDrawable(d); + } + + public void setAnchorView(View anchor) { + mDropDownAnchorView = anchor; + } + + public void setHorizontalOffset(int offset) { + mDropDownHorizontalOffset = offset; + } + + public void setVerticalOffset(int offset) { + mDropDownVerticalOffset = offset; + mDropDownVerticalOffsetSet = true; + } + + public void setContentWidth(int width) { + Drawable popupBackground = mPopup.getBackground(); + if (popupBackground != null) { + popupBackground.getPadding(mTempRect); + mDropDownWidth = mTempRect.left + mTempRect.right + width; + } else { + mDropDownWidth = width; + } + } + + public void setOnItemClickListener(AdapterView.OnItemClickListener clickListener) { + mItemClickListener = clickListener; + } + + public void show() { + int height = buildDropDown(); + + int widthSpec = 0; + int heightSpec = 0; + + boolean noInputMethod = isInputMethodNotNeeded(); + //XXX mPopup.setAllowScrollingAnchorParent(!noInputMethod); + + if (mPopup.isShowing()) { + if (mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT) { + // The call to PopupWindow's update method below can accept -1 for any + // value you do not want to update. + widthSpec = -1; + } else if (mDropDownWidth == ViewGroup.LayoutParams.WRAP_CONTENT) { + widthSpec = mDropDownAnchorView.getWidth(); + } else { + widthSpec = mDropDownWidth; + } + + if (mDropDownHeight == ViewGroup.LayoutParams.MATCH_PARENT) { + // The call to PopupWindow's update method below can accept -1 for any + // value you do not want to update. + heightSpec = noInputMethod ? height : ViewGroup.LayoutParams.MATCH_PARENT; + if (noInputMethod) { + mPopup.setWindowLayoutMode( + mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT ? + ViewGroup.LayoutParams.MATCH_PARENT : 0, 0); + } else { + mPopup.setWindowLayoutMode( + mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT ? + ViewGroup.LayoutParams.MATCH_PARENT : 0, + ViewGroup.LayoutParams.MATCH_PARENT); + } + } else if (mDropDownHeight == ViewGroup.LayoutParams.WRAP_CONTENT) { + heightSpec = height; + } else { + heightSpec = mDropDownHeight; + } + + mPopup.setOutsideTouchable(true); + + mPopup.update(mDropDownAnchorView, mDropDownHorizontalOffset, + mDropDownVerticalOffset, widthSpec, heightSpec); + } else { + if (mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT) { + widthSpec = ViewGroup.LayoutParams.MATCH_PARENT; + } else { + if (mDropDownWidth == ViewGroup.LayoutParams.WRAP_CONTENT) { + mPopup.setWidth(mDropDownAnchorView.getWidth()); + } else { + mPopup.setWidth(mDropDownWidth); + } + } + + if (mDropDownHeight == ViewGroup.LayoutParams.MATCH_PARENT) { + heightSpec = ViewGroup.LayoutParams.MATCH_PARENT; + } else { + if (mDropDownHeight == ViewGroup.LayoutParams.WRAP_CONTENT) { + mPopup.setHeight(height); + } else { + mPopup.setHeight(mDropDownHeight); + } + } + + mPopup.setWindowLayoutMode(widthSpec, heightSpec); + //XXX mPopup.setClipToScreenEnabled(true); + + // use outside touchable to dismiss drop down when touching outside of it, so + // only set this if the dropdown is not always visible + mPopup.setOutsideTouchable(true); + mPopup.setTouchInterceptor(mTouchInterceptor); + mPopup.showAsDropDown(mDropDownAnchorView, + mDropDownHorizontalOffset, mDropDownVerticalOffset); + mDropDownList.setSelection(ListView.INVALID_POSITION); + + if (!mModal || mDropDownList.isInTouchMode()) { + clearListSelection(); + } + if (!mModal) { + mHandler.post(mHideSelector); + } + } + } + + public void dismiss() { + mPopup.dismiss(); + if (mPromptView != null) { + final ViewParent parent = mPromptView.getParent(); + if (parent instanceof ViewGroup) { + final ViewGroup group = (ViewGroup) parent; + group.removeView(mPromptView); + } + } + mPopup.setContentView(null); + mDropDownList = null; + mHandler.removeCallbacks(mResizePopupRunnable); + } + + public void setOnDismissListener(PopupWindow.OnDismissListener listener) { + mPopup.setOnDismissListener(listener); + } + + public void setInputMethodMode(int mode) { + mPopup.setInputMethodMode(mode); + } + + public void clearListSelection() { + final DropDownListView list = mDropDownList; + if (list != null) { + // WARNING: Please read the comment where mListSelectionHidden is declared + list.mListSelectionHidden = true; + //XXX list.hideSelector(); + list.requestLayout(); + } + } + + public boolean isShowing() { + return mPopup.isShowing(); + } + + private boolean isInputMethodNotNeeded() { + return mPopup.getInputMethodMode() == PopupWindow.INPUT_METHOD_NOT_NEEDED; + } + + public ListView getListView() { + return mDropDownList; + } + + private int buildDropDown() { + ViewGroup dropDownView; + int otherHeights = 0; + + if (mDropDownList == null) { + Context context = mContext; + + mDropDownList = new DropDownListView(context, !mModal); + if (mDropDownListHighlight != null) { + mDropDownList.setSelector(mDropDownListHighlight); + } + mDropDownList.setAdapter(mAdapter); + mDropDownList.setOnItemClickListener(mItemClickListener); + mDropDownList.setFocusable(true); + mDropDownList.setFocusableInTouchMode(true); + mDropDownList.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + public void onItemSelected(AdapterView parent, View view, + int position, long id) { + + if (position != -1) { + DropDownListView dropDownList = mDropDownList; + + if (dropDownList != null) { + dropDownList.mListSelectionHidden = false; + } + } + } + + public void onNothingSelected(AdapterView parent) { + } + }); + mDropDownList.setOnScrollListener(mScrollListener); + + if (mItemSelectedListener != null) { + mDropDownList.setOnItemSelectedListener(mItemSelectedListener); + } + + dropDownView = mDropDownList; + + View hintView = mPromptView; + if (hintView != null) { + // if an hint has been specified, we accomodate more space for it and + // add a text view in the drop down menu, at the bottom of the list + LinearLayout hintContainer = new LinearLayout(context); + hintContainer.setOrientation(LinearLayout.VERTICAL); + + LinearLayout.LayoutParams hintParams = new LinearLayout.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, 0, 1.0f + ); + + switch (mPromptPosition) { + case POSITION_PROMPT_BELOW: + hintContainer.addView(dropDownView, hintParams); + hintContainer.addView(hintView); + break; + + case POSITION_PROMPT_ABOVE: + hintContainer.addView(hintView); + hintContainer.addView(dropDownView, hintParams); + break; + + default: + break; + } + + // measure the hint's height to find how much more vertical space + // we need to add to the drop down's height + int widthSpec = MeasureSpec.makeMeasureSpec(mDropDownWidth, MeasureSpec.AT_MOST); + int heightSpec = MeasureSpec.UNSPECIFIED; + hintView.measure(widthSpec, heightSpec); + + hintParams = (LinearLayout.LayoutParams) hintView.getLayoutParams(); + otherHeights = hintView.getMeasuredHeight() + hintParams.topMargin + + hintParams.bottomMargin; + + dropDownView = hintContainer; + } + + mPopup.setContentView(dropDownView); + } else { + dropDownView = (ViewGroup) mPopup.getContentView(); + final View view = mPromptView; + if (view != null) { + LinearLayout.LayoutParams hintParams = + (LinearLayout.LayoutParams) view.getLayoutParams(); + otherHeights = view.getMeasuredHeight() + hintParams.topMargin + + hintParams.bottomMargin; + } + } + + // getMaxAvailableHeight() subtracts the padding, so we put it back + // to get the available height for the whole window + int padding = 0; + Drawable background = mPopup.getBackground(); + if (background != null) { + background.getPadding(mTempRect); + padding = mTempRect.top + mTempRect.bottom; + + // If we don't have an explicit vertical offset, determine one from the window + // background so that content will line up. + if (!mDropDownVerticalOffsetSet) { + mDropDownVerticalOffset = -mTempRect.top; + } + } + + // Max height available on the screen for a popup. + boolean ignoreBottomDecorations = + mPopup.getInputMethodMode() == PopupWindow.INPUT_METHOD_NOT_NEEDED; + final int maxHeight = /*mPopup.*/getMaxAvailableHeight( + mDropDownAnchorView, mDropDownVerticalOffset, ignoreBottomDecorations); + + if (mDropDownHeight == ViewGroup.LayoutParams.MATCH_PARENT) { + return maxHeight + padding; + } + + final int listContent = /*mDropDownList.*/measureHeightOfChildren(MeasureSpec.UNSPECIFIED, + 0, -1/*ListView.NO_POSITION*/, maxHeight - otherHeights, -1); + // add padding only if the list has items in it, that way we don't show + // the popup if it is not needed + if (listContent > 0) otherHeights += padding; + + return listContent + otherHeights; + } + + private int getMaxAvailableHeight(View anchor, int yOffset, boolean ignoreBottomDecorations) { + final Rect displayFrame = new Rect(); + anchor.getWindowVisibleDisplayFrame(displayFrame); + + final int[] anchorPos = new int[2]; + anchor.getLocationOnScreen(anchorPos); + + int bottomEdge = displayFrame.bottom; + if (ignoreBottomDecorations) { + Resources res = anchor.getContext().getResources(); + bottomEdge = res.getDisplayMetrics().heightPixels; + } + final int distanceToBottom = bottomEdge - (anchorPos[1] + anchor.getHeight()) - yOffset; + final int distanceToTop = anchorPos[1] - displayFrame.top + yOffset; + + // anchorPos[1] is distance from anchor to top of screen + int returnedHeight = Math.max(distanceToBottom, distanceToTop); + if (mPopup.getBackground() != null) { + mPopup.getBackground().getPadding(mTempRect); + returnedHeight -= mTempRect.top + mTempRect.bottom; + } + + return returnedHeight; + } + + private int measureHeightOfChildren(int widthMeasureSpec, int startPosition, int endPosition, + final int maxHeight, int disallowPartialChildPosition) { + + final ListAdapter adapter = mAdapter; + if (adapter == null) { + return mDropDownList.getListPaddingTop() + mDropDownList.getListPaddingBottom(); + } + + // Include the padding of the list + int returnedHeight = mDropDownList.getListPaddingTop() + mDropDownList.getListPaddingBottom(); + final int dividerHeight = ((mDropDownList.getDividerHeight() > 0) && mDropDownList.getDivider() != null) ? mDropDownList.getDividerHeight() : 0; + // The previous height value that was less than maxHeight and contained + // no partial children + int prevHeightWithoutPartialChild = 0; + int i; + View child; + + // mItemCount - 1 since endPosition parameter is inclusive + endPosition = (endPosition == -1/*NO_POSITION*/) ? adapter.getCount() - 1 : endPosition; + + for (i = startPosition; i <= endPosition; ++i) { + child = mAdapter.getView(i, null, mDropDownList); + if (mDropDownList.getCacheColorHint() != 0) { + child.setDrawingCacheBackgroundColor(mDropDownList.getCacheColorHint()); + } + + measureScrapChild(child, i, widthMeasureSpec); + + if (i > 0) { + // Count the divider for all but one child + returnedHeight += dividerHeight; + } + + returnedHeight += child.getMeasuredHeight(); + + if (returnedHeight >= maxHeight) { + // We went over, figure out which height to return. If returnedHeight > maxHeight, + // then the i'th position did not fit completely. + return (disallowPartialChildPosition >= 0) // Disallowing is enabled (> -1) + && (i > disallowPartialChildPosition) // We've past the min pos + && (prevHeightWithoutPartialChild > 0) // We have a prev height + && (returnedHeight != maxHeight) // i'th child did not fit completely + ? prevHeightWithoutPartialChild + : maxHeight; + } + + if ((disallowPartialChildPosition >= 0) && (i >= disallowPartialChildPosition)) { + prevHeightWithoutPartialChild = returnedHeight; + } + } + + // At this point, we went through the range of children, and they each + // completely fit, so return the returnedHeight + return returnedHeight; + } + private void measureScrapChild(View child, int position, int widthMeasureSpec) { + ListView.LayoutParams p = (ListView.LayoutParams) child.getLayoutParams(); + if (p == null) { + p = new ListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.WRAP_CONTENT, 0); + child.setLayoutParams(p); + } + //XXX p.viewType = mAdapter.getItemViewType(position); + //XXX p.forceAdd = true; + + int childWidthSpec = ViewGroup.getChildMeasureSpec(widthMeasureSpec, + mDropDownList.getPaddingLeft() + mDropDownList.getPaddingRight(), p.width); + int lpHeight = p.height; + int childHeightSpec; + if (lpHeight > 0) { + childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight, MeasureSpec.EXACTLY); + } else { + childHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); + } + child.measure(childWidthSpec, childHeightSpec); + } + + private static class DropDownListView extends ListView { + /* + * WARNING: This is a workaround for a touch mode issue. + * + * Touch mode is propagated lazily to windows. This causes problems in + * the following scenario: + * - Type something in the AutoCompleteTextView and get some results + * - Move down with the d-pad to select an item in the list + * - Move up with the d-pad until the selection disappears + * - Type more text in the AutoCompleteTextView *using the soft keyboard* + * and get new results; you are now in touch mode + * - The selection comes back on the first item in the list, even though + * the list is supposed to be in touch mode + * + * Using the soft keyboard triggers the touch mode change but that change + * is propagated to our window only after the first list layout, therefore + * after the list attempts to resurrect the selection. + * + * The trick to work around this issue is to pretend the list is in touch + * mode when we know that the selection should not appear, that is when + * we know the user moved the selection away from the list. + * + * This boolean is set to true whenever we explicitly hide the list's + * selection and reset to false whenever we know the user moved the + * selection back to the list. + * + * When this boolean is true, isInTouchMode() returns true, otherwise it + * returns super.isInTouchMode(). + */ + private boolean mListSelectionHidden; + + private boolean mHijackFocus; + + public DropDownListView(Context context, boolean hijackFocus) { + super(context, null, /*com.android.internal.*/R.attr.dropDownListViewStyle); + mHijackFocus = hijackFocus; + // TODO: Add an API to control this + setCacheColorHint(0); // Transparent, since the background drawable could be anything. + } + + //XXX @Override + //View obtainView(int position, boolean[] isScrap) { + // View view = super.obtainView(position, isScrap); + + // if (view instanceof TextView) { + // ((TextView) view).setHorizontallyScrolling(true); + // } + + // return view; + //} + + @Override + public boolean isInTouchMode() { + // WARNING: Please read the comment where mListSelectionHidden is declared + return (mHijackFocus && mListSelectionHidden) || super.isInTouchMode(); + } + + @Override + public boolean hasWindowFocus() { + return mHijackFocus || super.hasWindowFocus(); + } + + @Override + public boolean isFocused() { + return mHijackFocus || super.isFocused(); + } + + @Override + public boolean hasFocus() { + return mHijackFocus || super.hasFocus(); + } + } + + private class PopupDataSetObserver extends DataSetObserver { + @Override + public void onChanged() { + if (isShowing()) { + // Resize the popup to fit new content + show(); + } + } + + @Override + public void onInvalidated() { + dismiss(); + } + } + + private class ListSelectorHider implements Runnable { + public void run() { + clearListSelection(); + } + } + + private class ResizePopupRunnable implements Runnable { + public void run() { + if (mDropDownList != null && mDropDownList.getCount() > mDropDownList.getChildCount() && + mDropDownList.getChildCount() <= mListItemExpandMaximum) { + mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED); + show(); + } + } + } + + private class PopupTouchInterceptor implements OnTouchListener { + public boolean onTouch(View v, MotionEvent event) { + final int action = event.getAction(); + final int x = (int) event.getX(); + final int y = (int) event.getY(); + + if (action == MotionEvent.ACTION_DOWN && + mPopup != null && mPopup.isShowing() && + (x >= 0 && x < mPopup.getWidth() && y >= 0 && y < mPopup.getHeight())) { + mHandler.postDelayed(mResizePopupRunnable, EXPAND_LIST_TIMEOUT); + } else if (action == MotionEvent.ACTION_UP) { + mHandler.removeCallbacks(mResizePopupRunnable); + } + return false; + } + } + + private class PopupScrollListener implements ListView.OnScrollListener { + public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, + int totalItemCount) { + + } + + public void onScrollStateChanged(AbsListView view, int scrollState) { + if (scrollState == SCROLL_STATE_TOUCH_SCROLL && + !isInputMethodNotNeeded() && mPopup.getContentView() != null) { + mHandler.removeCallbacks(mResizePopupRunnable); + mResizePopupRunnable.run(); + } + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsProgressBar.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsProgressBar.java new file mode 100644 index 000000000..1c02d4aca --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsProgressBar.java @@ -0,0 +1,1193 @@ +/* + * Copyright (C) 2006 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.actionbarsherlock.internal.widget; + +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.Bitmap; +import android.graphics.BitmapShader; +import android.graphics.Canvas; +import android.graphics.Rect; +import android.graphics.Shader; +import android.graphics.drawable.Animatable; +import android.graphics.drawable.AnimationDrawable; +import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.ClipDrawable; +import android.graphics.drawable.Drawable; +import android.graphics.drawable.LayerDrawable; +import android.graphics.drawable.ShapeDrawable; +import android.graphics.drawable.shapes.RoundRectShape; +import android.graphics.drawable.shapes.Shape; +import android.os.Build; +import android.os.Parcel; +import android.os.Parcelable; +import android.os.SystemClock; +import android.util.AttributeSet; +import android.view.Gravity; +import android.view.View; +import android.view.ViewDebug; +import android.view.accessibility.AccessibilityEvent; +import android.view.accessibility.AccessibilityManager; +import android.view.animation.AlphaAnimation; +import android.view.animation.Animation; +import android.view.animation.AnimationUtils; +import android.view.animation.Interpolator; +import android.view.animation.LinearInterpolator; +import android.view.animation.Transformation; +import android.widget.RemoteViews.RemoteView; + + +/** + *

+ * Visual indicator of progress in some operation. Displays a bar to the user + * representing how far the operation has progressed; the application can + * change the amount of progress (modifying the length of the bar) as it moves + * forward. There is also a secondary progress displayable on a progress bar + * which is useful for displaying intermediate progress, such as the buffer + * level during a streaming playback progress bar. + *

+ * + *

+ * A progress bar can also be made indeterminate. In indeterminate mode, the + * progress bar shows a cyclic animation without an indication of progress. This mode is used by + * applications when the length of the task is unknown. The indeterminate progress bar can be either + * a spinning wheel or a horizontal bar. + *

+ * + *

The following code example shows how a progress bar can be used from + * a worker thread to update the user interface to notify the user of progress: + *

+ * + *
+ * public class MyActivity extends Activity {
+ *     private static final int PROGRESS = 0x1;
+ *
+ *     private ProgressBar mProgress;
+ *     private int mProgressStatus = 0;
+ *
+ *     private Handler mHandler = new Handler();
+ *
+ *     protected void onCreate(Bundle icicle) {
+ *         super.onCreate(icicle);
+ *
+ *         setContentView(R.layout.progressbar_activity);
+ *
+ *         mProgress = (ProgressBar) findViewById(R.id.progress_bar);
+ *
+ *         // Start lengthy operation in a background thread
+ *         new Thread(new Runnable() {
+ *             public void run() {
+ *                 while (mProgressStatus < 100) {
+ *                     mProgressStatus = doWork();
+ *
+ *                     // Update the progress bar
+ *                     mHandler.post(new Runnable() {
+ *                         public void run() {
+ *                             mProgress.setProgress(mProgressStatus);
+ *                         }
+ *                     });
+ *                 }
+ *             }
+ *         }).start();
+ *     }
+ * }
+ * + *

To add a progress bar to a layout file, you can use the {@code <ProgressBar>} element. + * By default, the progress bar is a spinning wheel (an indeterminate indicator). To change to a + * horizontal progress bar, apply the {@link android.R.style#Widget_ProgressBar_Horizontal + * Widget.ProgressBar.Horizontal} style, like so:

+ * + *
+ * <ProgressBar
+ *     style="@android:style/Widget.ProgressBar.Horizontal"
+ *     ... />
+ * + *

If you will use the progress bar to show real progress, you must use the horizontal bar. You + * can then increment the progress with {@link #incrementProgressBy incrementProgressBy()} or + * {@link #setProgress setProgress()}. By default, the progress bar is full when it reaches 100. If + * necessary, you can adjust the maximum value (the value for a full bar) using the {@link + * android.R.styleable#ProgressBar_max android:max} attribute. Other attributes available are listed + * below.

+ * + *

Another common style to apply to the progress bar is {@link + * android.R.style#Widget_ProgressBar_Small Widget.ProgressBar.Small}, which shows a smaller + * version of the spinning wheel—useful when waiting for content to load. + * For example, you can insert this kind of progress bar into your default layout for + * a view that will be populated by some content fetched from the Internet—the spinning wheel + * appears immediately and when your application receives the content, it replaces the progress bar + * with the loaded content. For example:

+ * + *
+ * <LinearLayout
+ *     android:orientation="horizontal"
+ *     ... >
+ *     <ProgressBar
+ *         android:layout_width="wrap_content"
+ *         android:layout_height="wrap_content"
+ *         style="@android:style/Widget.ProgressBar.Small"
+ *         android:layout_marginRight="5dp" />
+ *     <TextView
+ *         android:layout_width="wrap_content"
+ *         android:layout_height="wrap_content"
+ *         android:text="@string/loading" />
+ * </LinearLayout>
+ * + *

Other progress bar styles provided by the system include:

+ *
    + *
  • {@link android.R.style#Widget_ProgressBar_Horizontal Widget.ProgressBar.Horizontal}
  • + *
  • {@link android.R.style#Widget_ProgressBar_Small Widget.ProgressBar.Small}
  • + *
  • {@link android.R.style#Widget_ProgressBar_Large Widget.ProgressBar.Large}
  • + *
  • {@link android.R.style#Widget_ProgressBar_Inverse Widget.ProgressBar.Inverse}
  • + *
  • {@link android.R.style#Widget_ProgressBar_Small_Inverse + * Widget.ProgressBar.Small.Inverse}
  • + *
  • {@link android.R.style#Widget_ProgressBar_Large_Inverse + * Widget.ProgressBar.Large.Inverse}
  • + *
+ *

The "inverse" styles provide an inverse color scheme for the spinner, which may be necessary + * if your application uses a light colored theme (a white background).

+ * + *

XML attributes + *

+ * See {@link android.R.styleable#ProgressBar ProgressBar Attributes}, + * {@link android.R.styleable#View View Attributes} + *

+ * + * @attr ref android.R.styleable#ProgressBar_animationResolution + * @attr ref android.R.styleable#ProgressBar_indeterminate + * @attr ref android.R.styleable#ProgressBar_indeterminateBehavior + * @attr ref android.R.styleable#ProgressBar_indeterminateDrawable + * @attr ref android.R.styleable#ProgressBar_indeterminateDuration + * @attr ref android.R.styleable#ProgressBar_indeterminateOnly + * @attr ref android.R.styleable#ProgressBar_interpolator + * @attr ref android.R.styleable#ProgressBar_max + * @attr ref android.R.styleable#ProgressBar_maxHeight + * @attr ref android.R.styleable#ProgressBar_maxWidth + * @attr ref android.R.styleable#ProgressBar_minHeight + * @attr ref android.R.styleable#ProgressBar_minWidth + * @attr ref android.R.styleable#ProgressBar_progress + * @attr ref android.R.styleable#ProgressBar_progressDrawable + * @attr ref android.R.styleable#ProgressBar_secondaryProgress + */ +@RemoteView +public class IcsProgressBar extends View { + private static final boolean IS_HONEYCOMB = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB; + private static final int MAX_LEVEL = 10000; + private static final int ANIMATION_RESOLUTION = 200; + private static final int TIMEOUT_SEND_ACCESSIBILITY_EVENT = 200; + + private static final int[] ProgressBar = new int[] { + android.R.attr.maxWidth, + android.R.attr.maxHeight, + android.R.attr.max, + android.R.attr.progress, + android.R.attr.secondaryProgress, + android.R.attr.indeterminate, + android.R.attr.indeterminateOnly, + android.R.attr.indeterminateDrawable, + android.R.attr.progressDrawable, + android.R.attr.indeterminateDuration, + android.R.attr.indeterminateBehavior, + android.R.attr.minWidth, + android.R.attr.minHeight, + android.R.attr.interpolator, + android.R.attr.animationResolution, + }; + private static final int ProgressBar_maxWidth = 0; + private static final int ProgressBar_maxHeight = 1; + private static final int ProgressBar_max = 2; + private static final int ProgressBar_progress = 3; + private static final int ProgressBar_secondaryProgress = 4; + private static final int ProgressBar_indeterminate = 5; + private static final int ProgressBar_indeterminateOnly = 6; + private static final int ProgressBar_indeterminateDrawable = 7; + private static final int ProgressBar_progressDrawable = 8; + private static final int ProgressBar_indeterminateDuration = 9; + private static final int ProgressBar_indeterminateBehavior = 10; + private static final int ProgressBar_minWidth = 11; + private static final int ProgressBar_minHeight = 12; + private static final int ProgressBar_interpolator = 13; + private static final int ProgressBar_animationResolution = 14; + + int mMinWidth; + int mMaxWidth; + int mMinHeight; + int mMaxHeight; + + private int mProgress; + private int mSecondaryProgress; + private int mMax; + + private int mBehavior; + private int mDuration; + private boolean mIndeterminate; + private boolean mOnlyIndeterminate; + private Transformation mTransformation; + private AlphaAnimation mAnimation; + private Drawable mIndeterminateDrawable; + private int mIndeterminateRealLeft; + private int mIndeterminateRealTop; + private Drawable mProgressDrawable; + private Drawable mCurrentDrawable; + Bitmap mSampleTile; + private boolean mNoInvalidate; + private Interpolator mInterpolator; + private RefreshProgressRunnable mRefreshProgressRunnable; + private long mUiThreadId; + private boolean mShouldStartAnimationDrawable; + private long mLastDrawTime; + + private boolean mInDrawing; + + private int mAnimationResolution; + + private AccessibilityManager mAccessibilityManager; + private AccessibilityEventSender mAccessibilityEventSender; + + /** + * Create a new progress bar with range 0...100 and initial progress of 0. + * @param context the application environment + */ + public IcsProgressBar(Context context) { + this(context, null); + } + + public IcsProgressBar(Context context, AttributeSet attrs) { + this(context, attrs, android.R.attr.progressBarStyle); + } + + public IcsProgressBar(Context context, AttributeSet attrs, int defStyle) { + this(context, attrs, defStyle, 0); + } + + /** + * @hide + */ + public IcsProgressBar(Context context, AttributeSet attrs, int defStyle, int styleRes) { + super(context, attrs, defStyle); + mUiThreadId = Thread.currentThread().getId(); + initProgressBar(); + + TypedArray a = + context.obtainStyledAttributes(attrs, /*R.styleable.*/ProgressBar, defStyle, styleRes); + + mNoInvalidate = true; + + Drawable drawable = a.getDrawable(/*R.styleable.*/ProgressBar_progressDrawable); + if (drawable != null) { + drawable = tileify(drawable, false); + // Calling this method can set mMaxHeight, make sure the corresponding + // XML attribute for mMaxHeight is read after calling this method + setProgressDrawable(drawable); + } + + + mDuration = a.getInt(/*R.styleable.*/ProgressBar_indeterminateDuration, mDuration); + + mMinWidth = a.getDimensionPixelSize(/*R.styleable.*/ProgressBar_minWidth, mMinWidth); + mMaxWidth = a.getDimensionPixelSize(/*R.styleable.*/ProgressBar_maxWidth, mMaxWidth); + mMinHeight = a.getDimensionPixelSize(/*R.styleable.*/ProgressBar_minHeight, mMinHeight); + mMaxHeight = a.getDimensionPixelSize(/*R.styleable.*/ProgressBar_maxHeight, mMaxHeight); + + mBehavior = a.getInt(/*R.styleable.*/ProgressBar_indeterminateBehavior, mBehavior); + + final int resID = a.getResourceId( + /*com.android.internal.R.styleable.*/ProgressBar_interpolator, + android.R.anim.linear_interpolator); // default to linear interpolator + if (resID > 0) { + setInterpolator(context, resID); + } + + setMax(a.getInt(/*R.styleable.*/ProgressBar_max, mMax)); + + setProgress(a.getInt(/*R.styleable.*/ProgressBar_progress, mProgress)); + + setSecondaryProgress( + a.getInt(/*R.styleable.*/ProgressBar_secondaryProgress, mSecondaryProgress)); + + drawable = a.getDrawable(/*R.styleable.*/ProgressBar_indeterminateDrawable); + if (drawable != null) { + drawable = tileifyIndeterminate(drawable); + setIndeterminateDrawable(drawable); + } + + mOnlyIndeterminate = a.getBoolean( + /*R.styleable.*/ProgressBar_indeterminateOnly, mOnlyIndeterminate); + + mNoInvalidate = false; + + setIndeterminate(mOnlyIndeterminate || a.getBoolean( + /*R.styleable.*/ProgressBar_indeterminate, mIndeterminate)); + + mAnimationResolution = a.getInteger(/*R.styleable.*/ProgressBar_animationResolution, + ANIMATION_RESOLUTION); + + a.recycle(); + + mAccessibilityManager = (AccessibilityManager)context.getSystemService(Context.ACCESSIBILITY_SERVICE); + } + + /** + * Converts a drawable to a tiled version of itself. It will recursively + * traverse layer and state list drawables. + */ + private Drawable tileify(Drawable drawable, boolean clip) { + + if (drawable instanceof LayerDrawable) { + LayerDrawable background = (LayerDrawable) drawable; + final int N = background.getNumberOfLayers(); + Drawable[] outDrawables = new Drawable[N]; + + for (int i = 0; i < N; i++) { + int id = background.getId(i); + outDrawables[i] = tileify(background.getDrawable(i), + (id == android.R.id.progress || id == android.R.id.secondaryProgress)); + } + + LayerDrawable newBg = new LayerDrawable(outDrawables); + + for (int i = 0; i < N; i++) { + newBg.setId(i, background.getId(i)); + } + + return newBg; + + }/* else if (drawable instanceof StateListDrawable) { + StateListDrawable in = (StateListDrawable) drawable; + StateListDrawable out = new StateListDrawable(); + int numStates = in.getStateCount(); + for (int i = 0; i < numStates; i++) { + out.addState(in.getStateSet(i), tileify(in.getStateDrawable(i), clip)); + } + return out; + + }*/ else if (drawable instanceof BitmapDrawable) { + final Bitmap tileBitmap = ((BitmapDrawable) drawable).getBitmap(); + if (mSampleTile == null) { + mSampleTile = tileBitmap; + } + + final ShapeDrawable shapeDrawable = new ShapeDrawable(getDrawableShape()); + + final BitmapShader bitmapShader = new BitmapShader(tileBitmap, + Shader.TileMode.REPEAT, Shader.TileMode.CLAMP); + shapeDrawable.getPaint().setShader(bitmapShader); + + return (clip) ? new ClipDrawable(shapeDrawable, Gravity.LEFT, + ClipDrawable.HORIZONTAL) : shapeDrawable; + } + + return drawable; + } + + Shape getDrawableShape() { + final float[] roundedCorners = new float[] { 5, 5, 5, 5, 5, 5, 5, 5 }; + return new RoundRectShape(roundedCorners, null, null); + } + + /** + * Convert a AnimationDrawable for use as a barberpole animation. + * Each frame of the animation is wrapped in a ClipDrawable and + * given a tiling BitmapShader. + */ + private Drawable tileifyIndeterminate(Drawable drawable) { + if (drawable instanceof AnimationDrawable) { + AnimationDrawable background = (AnimationDrawable) drawable; + final int N = background.getNumberOfFrames(); + AnimationDrawable newBg = new AnimationDrawable(); + newBg.setOneShot(background.isOneShot()); + + for (int i = 0; i < N; i++) { + Drawable frame = tileify(background.getFrame(i), true); + frame.setLevel(10000); + newBg.addFrame(frame, background.getDuration(i)); + } + newBg.setLevel(10000); + drawable = newBg; + } + return drawable; + } + + /** + *

+ * Initialize the progress bar's default values: + *

+ *
    + *
  • progress = 0
  • + *
  • max = 100
  • + *
  • animation duration = 4000 ms
  • + *
  • indeterminate = false
  • + *
  • behavior = repeat
  • + *
+ */ + private void initProgressBar() { + mMax = 100; + mProgress = 0; + mSecondaryProgress = 0; + mIndeterminate = false; + mOnlyIndeterminate = false; + mDuration = 4000; + mBehavior = AlphaAnimation.RESTART; + mMinWidth = 24; + mMaxWidth = 48; + mMinHeight = 24; + mMaxHeight = 48; + } + + /** + *

Indicate whether this progress bar is in indeterminate mode.

+ * + * @return true if the progress bar is in indeterminate mode + */ + @ViewDebug.ExportedProperty(category = "progress") + public synchronized boolean isIndeterminate() { + return mIndeterminate; + } + + /** + *

Change the indeterminate mode for this progress bar. In indeterminate + * mode, the progress is ignored and the progress bar shows an infinite + * animation instead.

+ * + * If this progress bar's style only supports indeterminate mode (such as the circular + * progress bars), then this will be ignored. + * + * @param indeterminate true to enable the indeterminate mode + */ + public synchronized void setIndeterminate(boolean indeterminate) { + if ((!mOnlyIndeterminate || !mIndeterminate) && indeterminate != mIndeterminate) { + mIndeterminate = indeterminate; + + if (indeterminate) { + // swap between indeterminate and regular backgrounds + mCurrentDrawable = mIndeterminateDrawable; + startAnimation(); + } else { + mCurrentDrawable = mProgressDrawable; + stopAnimation(); + } + } + } + + /** + *

Get the drawable used to draw the progress bar in + * indeterminate mode.

+ * + * @return a {@link android.graphics.drawable.Drawable} instance + * + * @see #setIndeterminateDrawable(android.graphics.drawable.Drawable) + * @see #setIndeterminate(boolean) + */ + public Drawable getIndeterminateDrawable() { + return mIndeterminateDrawable; + } + + /** + *

Define the drawable used to draw the progress bar in + * indeterminate mode.

+ * + * @param d the new drawable + * + * @see #getIndeterminateDrawable() + * @see #setIndeterminate(boolean) + */ + public void setIndeterminateDrawable(Drawable d) { + if (d != null) { + d.setCallback(this); + } + mIndeterminateDrawable = d; + if (mIndeterminate) { + mCurrentDrawable = d; + postInvalidate(); + } + } + + /** + *

Get the drawable used to draw the progress bar in + * progress mode.

+ * + * @return a {@link android.graphics.drawable.Drawable} instance + * + * @see #setProgressDrawable(android.graphics.drawable.Drawable) + * @see #setIndeterminate(boolean) + */ + public Drawable getProgressDrawable() { + return mProgressDrawable; + } + + /** + *

Define the drawable used to draw the progress bar in + * progress mode.

+ * + * @param d the new drawable + * + * @see #getProgressDrawable() + * @see #setIndeterminate(boolean) + */ + public void setProgressDrawable(Drawable d) { + boolean needUpdate; + if (mProgressDrawable != null && d != mProgressDrawable) { + mProgressDrawable.setCallback(null); + needUpdate = true; + } else { + needUpdate = false; + } + + if (d != null) { + d.setCallback(this); + + // Make sure the ProgressBar is always tall enough + int drawableHeight = d.getMinimumHeight(); + if (mMaxHeight < drawableHeight) { + mMaxHeight = drawableHeight; + requestLayout(); + } + } + mProgressDrawable = d; + if (!mIndeterminate) { + mCurrentDrawable = d; + postInvalidate(); + } + + if (needUpdate) { + updateDrawableBounds(getWidth(), getHeight()); + updateDrawableState(); + doRefreshProgress(android.R.id.progress, mProgress, false, false); + doRefreshProgress(android.R.id.secondaryProgress, mSecondaryProgress, false, false); + } + } + + /** + * @return The drawable currently used to draw the progress bar + */ + Drawable getCurrentDrawable() { + return mCurrentDrawable; + } + + @Override + protected boolean verifyDrawable(Drawable who) { + return who == mProgressDrawable || who == mIndeterminateDrawable + || super.verifyDrawable(who); + } + + @Override + public void jumpDrawablesToCurrentState() { + super.jumpDrawablesToCurrentState(); + if (mProgressDrawable != null) mProgressDrawable.jumpToCurrentState(); + if (mIndeterminateDrawable != null) mIndeterminateDrawable.jumpToCurrentState(); + } + + @Override + public void postInvalidate() { + if (!mNoInvalidate) { + super.postInvalidate(); + } + } + + private class RefreshProgressRunnable implements Runnable { + + private int mId; + private int mProgress; + private boolean mFromUser; + + RefreshProgressRunnable(int id, int progress, boolean fromUser) { + mId = id; + mProgress = progress; + mFromUser = fromUser; + } + + public void run() { + doRefreshProgress(mId, mProgress, mFromUser, true); + // Put ourselves back in the cache when we are done + mRefreshProgressRunnable = this; + } + + public void setup(int id, int progress, boolean fromUser) { + mId = id; + mProgress = progress; + mFromUser = fromUser; + } + + } + + private synchronized void doRefreshProgress(int id, int progress, boolean fromUser, + boolean callBackToApp) { + float scale = mMax > 0 ? (float) progress / (float) mMax : 0; + final Drawable d = mCurrentDrawable; + if (d != null) { + Drawable progressDrawable = null; + + if (d instanceof LayerDrawable) { + progressDrawable = ((LayerDrawable) d).findDrawableByLayerId(id); + } + + final int level = (int) (scale * MAX_LEVEL); + (progressDrawable != null ? progressDrawable : d).setLevel(level); + } else { + invalidate(); + } + + if (callBackToApp && id == android.R.id.progress) { + onProgressRefresh(scale, fromUser); + } + } + + void onProgressRefresh(float scale, boolean fromUser) { + if (mAccessibilityManager.isEnabled()) { + scheduleAccessibilityEventSender(); + } + } + + private synchronized void refreshProgress(int id, int progress, boolean fromUser) { + if (mUiThreadId == Thread.currentThread().getId()) { + doRefreshProgress(id, progress, fromUser, true); + } else { + RefreshProgressRunnable r; + if (mRefreshProgressRunnable != null) { + // Use cached RefreshProgressRunnable if available + r = mRefreshProgressRunnable; + // Uncache it + mRefreshProgressRunnable = null; + r.setup(id, progress, fromUser); + } else { + // Make a new one + r = new RefreshProgressRunnable(id, progress, fromUser); + } + post(r); + } + } + + /** + *

Set the current progress to the specified value. Does not do anything + * if the progress bar is in indeterminate mode.

+ * + * @param progress the new progress, between 0 and {@link #getMax()} + * + * @see #setIndeterminate(boolean) + * @see #isIndeterminate() + * @see #getProgress() + * @see #incrementProgressBy(int) + */ + public synchronized void setProgress(int progress) { + setProgress(progress, false); + } + + synchronized void setProgress(int progress, boolean fromUser) { + if (mIndeterminate) { + return; + } + + if (progress < 0) { + progress = 0; + } + + if (progress > mMax) { + progress = mMax; + } + + if (progress != mProgress) { + mProgress = progress; + refreshProgress(android.R.id.progress, mProgress, fromUser); + } + } + + /** + *

+ * Set the current secondary progress to the specified value. Does not do + * anything if the progress bar is in indeterminate mode. + *

+ * + * @param secondaryProgress the new secondary progress, between 0 and {@link #getMax()} + * @see #setIndeterminate(boolean) + * @see #isIndeterminate() + * @see #getSecondaryProgress() + * @see #incrementSecondaryProgressBy(int) + */ + public synchronized void setSecondaryProgress(int secondaryProgress) { + if (mIndeterminate) { + return; + } + + if (secondaryProgress < 0) { + secondaryProgress = 0; + } + + if (secondaryProgress > mMax) { + secondaryProgress = mMax; + } + + if (secondaryProgress != mSecondaryProgress) { + mSecondaryProgress = secondaryProgress; + refreshProgress(android.R.id.secondaryProgress, mSecondaryProgress, false); + } + } + + /** + *

Get the progress bar's current level of progress. Return 0 when the + * progress bar is in indeterminate mode.

+ * + * @return the current progress, between 0 and {@link #getMax()} + * + * @see #setIndeterminate(boolean) + * @see #isIndeterminate() + * @see #setProgress(int) + * @see #setMax(int) + * @see #getMax() + */ + @ViewDebug.ExportedProperty(category = "progress") + public synchronized int getProgress() { + return mIndeterminate ? 0 : mProgress; + } + + /** + *

Get the progress bar's current level of secondary progress. Return 0 when the + * progress bar is in indeterminate mode.

+ * + * @return the current secondary progress, between 0 and {@link #getMax()} + * + * @see #setIndeterminate(boolean) + * @see #isIndeterminate() + * @see #setSecondaryProgress(int) + * @see #setMax(int) + * @see #getMax() + */ + @ViewDebug.ExportedProperty(category = "progress") + public synchronized int getSecondaryProgress() { + return mIndeterminate ? 0 : mSecondaryProgress; + } + + /** + *

Return the upper limit of this progress bar's range.

+ * + * @return a positive integer + * + * @see #setMax(int) + * @see #getProgress() + * @see #getSecondaryProgress() + */ + @ViewDebug.ExportedProperty(category = "progress") + public synchronized int getMax() { + return mMax; + } + + /** + *

Set the range of the progress bar to 0...max.

+ * + * @param max the upper range of this progress bar + * + * @see #getMax() + * @see #setProgress(int) + * @see #setSecondaryProgress(int) + */ + public synchronized void setMax(int max) { + if (max < 0) { + max = 0; + } + if (max != mMax) { + mMax = max; + postInvalidate(); + + if (mProgress > max) { + mProgress = max; + } + refreshProgress(android.R.id.progress, mProgress, false); + } + } + + /** + *

Increase the progress bar's progress by the specified amount.

+ * + * @param diff the amount by which the progress must be increased + * + * @see #setProgress(int) + */ + public synchronized final void incrementProgressBy(int diff) { + setProgress(mProgress + diff); + } + + /** + *

Increase the progress bar's secondary progress by the specified amount.

+ * + * @param diff the amount by which the secondary progress must be increased + * + * @see #setSecondaryProgress(int) + */ + public synchronized final void incrementSecondaryProgressBy(int diff) { + setSecondaryProgress(mSecondaryProgress + diff); + } + + /** + *

Start the indeterminate progress animation.

+ */ + void startAnimation() { + if (getVisibility() != VISIBLE) { + return; + } + + if (mIndeterminateDrawable instanceof Animatable) { + mShouldStartAnimationDrawable = true; + mAnimation = null; + } else { + if (mInterpolator == null) { + mInterpolator = new LinearInterpolator(); + } + + mTransformation = new Transformation(); + mAnimation = new AlphaAnimation(0.0f, 1.0f); + mAnimation.setRepeatMode(mBehavior); + mAnimation.setRepeatCount(Animation.INFINITE); + mAnimation.setDuration(mDuration); + mAnimation.setInterpolator(mInterpolator); + mAnimation.setStartTime(Animation.START_ON_FIRST_FRAME); + } + postInvalidate(); + } + + /** + *

Stop the indeterminate progress animation.

+ */ + void stopAnimation() { + mAnimation = null; + mTransformation = null; + if (mIndeterminateDrawable instanceof Animatable) { + ((Animatable) mIndeterminateDrawable).stop(); + mShouldStartAnimationDrawable = false; + } + postInvalidate(); + } + + /** + * Sets the acceleration curve for the indeterminate animation. + * The interpolator is loaded as a resource from the specified context. + * + * @param context The application environment + * @param resID The resource identifier of the interpolator to load + */ + public void setInterpolator(Context context, int resID) { + setInterpolator(AnimationUtils.loadInterpolator(context, resID)); + } + + /** + * Sets the acceleration curve for the indeterminate animation. + * Defaults to a linear interpolation. + * + * @param interpolator The interpolator which defines the acceleration curve + */ + public void setInterpolator(Interpolator interpolator) { + mInterpolator = interpolator; + } + + /** + * Gets the acceleration curve type for the indeterminate animation. + * + * @return the {@link Interpolator} associated to this animation + */ + public Interpolator getInterpolator() { + return mInterpolator; + } + + @Override + public void setVisibility(int v) { + if (getVisibility() != v) { + super.setVisibility(v); + + if (mIndeterminate) { + // let's be nice with the UI thread + if (v == GONE || v == INVISIBLE) { + stopAnimation(); + } else { + startAnimation(); + } + } + } + } + + @Override + protected void onVisibilityChanged(View changedView, int visibility) { + super.onVisibilityChanged(changedView, visibility); + + if (mIndeterminate) { + // let's be nice with the UI thread + if (visibility == GONE || visibility == INVISIBLE) { + stopAnimation(); + } else { + startAnimation(); + } + } + } + + @Override + public void invalidateDrawable(Drawable dr) { + if (!mInDrawing) { + if (verifyDrawable(dr)) { + final Rect dirty = dr.getBounds(); + final int scrollX = getScrollX() + getPaddingLeft(); + final int scrollY = getScrollY() + getPaddingTop(); + + invalidate(dirty.left + scrollX, dirty.top + scrollY, + dirty.right + scrollX, dirty.bottom + scrollY); + } else { + super.invalidateDrawable(dr); + } + } + } + + /** + * @hide + * + @Override + public int getResolvedLayoutDirection(Drawable who) { + return (who == mProgressDrawable || who == mIndeterminateDrawable) ? + getResolvedLayoutDirection() : super.getResolvedLayoutDirection(who); + } + */ + + @Override + protected void onSizeChanged(int w, int h, int oldw, int oldh) { + updateDrawableBounds(w, h); + } + + private void updateDrawableBounds(int w, int h) { + // onDraw will translate the canvas so we draw starting at 0,0 + int right = w - getPaddingRight() - getPaddingLeft(); + int bottom = h - getPaddingBottom() - getPaddingTop(); + int top = 0; + int left = 0; + + if (mIndeterminateDrawable != null) { + // Aspect ratio logic does not apply to AnimationDrawables + if (mOnlyIndeterminate && !(mIndeterminateDrawable instanceof AnimationDrawable)) { + // Maintain aspect ratio. Certain kinds of animated drawables + // get very confused otherwise. + final int intrinsicWidth = mIndeterminateDrawable.getIntrinsicWidth(); + final int intrinsicHeight = mIndeterminateDrawable.getIntrinsicHeight(); + final float intrinsicAspect = (float) intrinsicWidth / intrinsicHeight; + final float boundAspect = (float) w / h; + if (intrinsicAspect != boundAspect) { + if (boundAspect > intrinsicAspect) { + // New width is larger. Make it smaller to match height. + final int width = (int) (h * intrinsicAspect); + left = (w - width) / 2; + right = left + width; + } else { + // New height is larger. Make it smaller to match width. + final int height = (int) (w * (1 / intrinsicAspect)); + top = (h - height) / 2; + bottom = top + height; + } + } + } + mIndeterminateDrawable.setBounds(0, 0, right - left, bottom - top); + mIndeterminateRealLeft = left; + mIndeterminateRealTop = top; + } + + if (mProgressDrawable != null) { + mProgressDrawable.setBounds(0, 0, right, bottom); + } + } + + @Override + protected synchronized void onDraw(Canvas canvas) { + super.onDraw(canvas); + + Drawable d = mCurrentDrawable; + if (d != null) { + // Translate canvas so a indeterminate circular progress bar with padding + // rotates properly in its animation + canvas.save(); + canvas.translate(getPaddingLeft() + mIndeterminateRealLeft, getPaddingTop() + mIndeterminateRealTop); + long time = getDrawingTime(); + if (mAnimation != null) { + mAnimation.getTransformation(time, mTransformation); + float scale = mTransformation.getAlpha(); + try { + mInDrawing = true; + d.setLevel((int) (scale * MAX_LEVEL)); + } finally { + mInDrawing = false; + } + if (SystemClock.uptimeMillis() - mLastDrawTime >= mAnimationResolution) { + mLastDrawTime = SystemClock.uptimeMillis(); + postInvalidateDelayed(mAnimationResolution); + } + } + d.draw(canvas); + canvas.restore(); + if (mShouldStartAnimationDrawable && d instanceof Animatable) { + ((Animatable) d).start(); + mShouldStartAnimationDrawable = false; + } + } + } + + @Override + protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + Drawable d = mCurrentDrawable; + + int dw = 0; + int dh = 0; + if (d != null) { + dw = Math.max(mMinWidth, Math.min(mMaxWidth, d.getIntrinsicWidth())); + dh = Math.max(mMinHeight, Math.min(mMaxHeight, d.getIntrinsicHeight())); + } + updateDrawableState(); + dw += getPaddingLeft() + getPaddingRight(); + dh += getPaddingTop() + getPaddingBottom(); + + if (IS_HONEYCOMB) { + setMeasuredDimension(View.resolveSizeAndState(dw, widthMeasureSpec, 0), + View.resolveSizeAndState(dh, heightMeasureSpec, 0)); + } else { + setMeasuredDimension(View.resolveSize(dw, widthMeasureSpec), + View.resolveSize(dh, heightMeasureSpec)); + } + } + + @Override + protected void drawableStateChanged() { + super.drawableStateChanged(); + updateDrawableState(); + } + + private void updateDrawableState() { + int[] state = getDrawableState(); + + if (mProgressDrawable != null && mProgressDrawable.isStateful()) { + mProgressDrawable.setState(state); + } + + if (mIndeterminateDrawable != null && mIndeterminateDrawable.isStateful()) { + mIndeterminateDrawable.setState(state); + } + } + + static class SavedState extends BaseSavedState { + int progress; + int secondaryProgress; + + /** + * Constructor called from {@link IcsProgressBar#onSaveInstanceState()} + */ + SavedState(Parcelable superState) { + super(superState); + } + + /** + * Constructor called from {@link #CREATOR} + */ + private SavedState(Parcel in) { + super(in); + progress = in.readInt(); + secondaryProgress = in.readInt(); + } + + @Override + public void writeToParcel(Parcel out, int flags) { + super.writeToParcel(out, flags); + out.writeInt(progress); + out.writeInt(secondaryProgress); + } + + public static final Parcelable.Creator CREATOR + = new Parcelable.Creator() { + public SavedState createFromParcel(Parcel in) { + return new SavedState(in); + } + + public SavedState[] newArray(int size) { + return new SavedState[size]; + } + }; + } + + @Override + public Parcelable onSaveInstanceState() { + // Force our ancestor class to save its state + Parcelable superState = super.onSaveInstanceState(); + SavedState ss = new SavedState(superState); + + ss.progress = mProgress; + ss.secondaryProgress = mSecondaryProgress; + + return ss; + } + + @Override + public void onRestoreInstanceState(Parcelable state) { + SavedState ss = (SavedState) state; + super.onRestoreInstanceState(ss.getSuperState()); + + setProgress(ss.progress); + setSecondaryProgress(ss.secondaryProgress); + } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + if (mIndeterminate) { + startAnimation(); + } + } + + @Override + protected void onDetachedFromWindow() { + if (mIndeterminate) { + stopAnimation(); + } + if(mRefreshProgressRunnable != null) { + removeCallbacks(mRefreshProgressRunnable); + } + if (mAccessibilityEventSender != null) { + removeCallbacks(mAccessibilityEventSender); + } + // This should come after stopAnimation(), otherwise an invalidate message remains in the + // queue, which can prevent the entire view hierarchy from being GC'ed during a rotation + super.onDetachedFromWindow(); + } + + @Override + public void onInitializeAccessibilityEvent(AccessibilityEvent event) { + super.onInitializeAccessibilityEvent(event); + event.setItemCount(mMax); + event.setCurrentItemIndex(mProgress); + } + + /** + * Schedule a command for sending an accessibility event. + *
+ * Note: A command is used to ensure that accessibility events + * are sent at most one in a given time frame to save + * system resources while the progress changes quickly. + */ + private void scheduleAccessibilityEventSender() { + if (mAccessibilityEventSender == null) { + mAccessibilityEventSender = new AccessibilityEventSender(); + } else { + removeCallbacks(mAccessibilityEventSender); + } + postDelayed(mAccessibilityEventSender, TIMEOUT_SEND_ACCESSIBILITY_EVENT); + } + + /** + * Command for sending an accessibility event. + */ + private class AccessibilityEventSender implements Runnable { + public void run() { + sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsSpinner.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsSpinner.java new file mode 100644 index 000000000..038d1e031 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsSpinner.java @@ -0,0 +1,703 @@ +/* + * Copyright (C) 2007 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.actionbarsherlock.internal.widget; + +import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; +import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; +import com.actionbarsherlock.R; +import android.content.Context; +import android.content.DialogInterface; +import android.content.DialogInterface.OnClickListener; +import android.content.res.TypedArray; +import android.database.DataSetObserver; +import android.graphics.Rect; +import android.graphics.drawable.Drawable; +import android.util.AttributeSet; +import android.view.Gravity; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.ListAdapter; +import android.widget.ListView; +import android.widget.PopupWindow; +import android.widget.SpinnerAdapter; + + +/** + * A view that displays one child at a time and lets the user pick among them. + * The items in the Spinner come from the {@link Adapter} associated with + * this view. + * + *

See the Spinner + * tutorial.

+ * + * @attr ref android.R.styleable#Spinner_prompt + */ +public class IcsSpinner extends IcsAbsSpinner implements OnClickListener { + //private static final String TAG = "Spinner"; + + // Only measure this many items to get a decent max width. + private static final int MAX_ITEMS_MEASURED = 15; + + /** + * Use a dialog window for selecting spinner options. + */ + //public static final int MODE_DIALOG = 0; + + /** + * Use a dropdown anchored to the Spinner for selecting spinner options. + */ + public static final int MODE_DROPDOWN = 1; + + /** + * Use the theme-supplied value to select the dropdown mode. + */ + //private static final int MODE_THEME = -1; + + private SpinnerPopup mPopup; + private DropDownAdapter mTempAdapter; + int mDropDownWidth; + + private int mGravity; + private boolean mDisableChildrenWhenDisabled; + + private Rect mTempRect = new Rect(); + + public IcsSpinner(Context context, AttributeSet attrs) { + this(context, attrs, R.attr.actionDropDownStyle); + } + + /** + * Construct a new spinner with the given context's theme, the supplied attribute set, + * and default style. + * + * @param context The Context the view is running in, through which it can + * access the current theme, resources, etc. + * @param attrs The attributes of the XML tag that is inflating the view. + * @param defStyle The default style to apply to this view. If 0, no style + * will be applied (beyond what is included in the theme). This may + * either be an attribute resource, whose value will be retrieved + * from the current theme, or an explicit style resource. + */ + public IcsSpinner(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + + TypedArray a = context.obtainStyledAttributes(attrs, + R.styleable.SherlockSpinner, defStyle, 0); + + + DropdownPopup popup = new DropdownPopup(context, attrs, defStyle); + + mDropDownWidth = a.getLayoutDimension( + R.styleable.SherlockSpinner_android_dropDownWidth, + ViewGroup.LayoutParams.WRAP_CONTENT); + popup.setBackgroundDrawable(a.getDrawable( + R.styleable.SherlockSpinner_android_popupBackground)); + final int verticalOffset = a.getDimensionPixelOffset( + R.styleable.SherlockSpinner_android_dropDownVerticalOffset, 0); + if (verticalOffset != 0) { + popup.setVerticalOffset(verticalOffset); + } + + final int horizontalOffset = a.getDimensionPixelOffset( + R.styleable.SherlockSpinner_android_dropDownHorizontalOffset, 0); + if (horizontalOffset != 0) { + popup.setHorizontalOffset(horizontalOffset); + } + + mPopup = popup; + + mGravity = a.getInt(R.styleable.SherlockSpinner_android_gravity, Gravity.CENTER); + + mPopup.setPromptText(a.getString(R.styleable.SherlockSpinner_android_prompt)); + + mDisableChildrenWhenDisabled = true; + + a.recycle(); + + // Base constructor can call setAdapter before we initialize mPopup. + // Finish setting things up if this happened. + if (mTempAdapter != null) { + mPopup.setAdapter(mTempAdapter); + mTempAdapter = null; + } + } + + @Override + public void setEnabled(boolean enabled) { + super.setEnabled(enabled); + if (mDisableChildrenWhenDisabled) { + final int count = getChildCount(); + for (int i = 0; i < count; i++) { + getChildAt(i).setEnabled(enabled); + } + } + } + + /** + * Describes how the selected item view is positioned. Currently only the horizontal component + * is used. The default is determined by the current theme. + * + * @param gravity See {@link android.view.Gravity} + * + * @attr ref android.R.styleable#Spinner_gravity + */ + public void setGravity(int gravity) { + if (mGravity != gravity) { + if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == 0) { + gravity |= Gravity.LEFT; + } + mGravity = gravity; + requestLayout(); + } + } + + @Override + public void setAdapter(SpinnerAdapter adapter) { + super.setAdapter(adapter); + + if (mPopup != null) { + mPopup.setAdapter(new DropDownAdapter(adapter)); + } else { + mTempAdapter = new DropDownAdapter(adapter); + } + } + + @Override + public int getBaseline() { + View child = null; + + if (getChildCount() > 0) { + child = getChildAt(0); + } else if (mAdapter != null && mAdapter.getCount() > 0) { + child = makeAndAddView(0); + mRecycler.put(0, child); + removeAllViewsInLayout(); + } + + if (child != null) { + final int childBaseline = child.getBaseline(); + return childBaseline >= 0 ? child.getTop() + childBaseline : -1; + } else { + return -1; + } + } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + + if (mPopup != null && mPopup.isShowing()) { + mPopup.dismiss(); + } + } + + /** + *

A spinner does not support item click events. Calling this method + * will raise an exception.

+ * + * @param l this listener will be ignored + */ + @Override + public void setOnItemClickListener(OnItemClickListener l) { + throw new RuntimeException("setOnItemClickListener cannot be used with a spinner."); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + if (mPopup != null && MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.AT_MOST) { + final int measuredWidth = getMeasuredWidth(); + setMeasuredDimension(Math.min(Math.max(measuredWidth, + measureContentWidth(getAdapter(), getBackground())), + MeasureSpec.getSize(widthMeasureSpec)), + getMeasuredHeight()); + } + } + + /** + * @see android.view.View#onLayout(boolean,int,int,int,int) + * + * Creates and positions all views + * + */ + @Override + protected void onLayout(boolean changed, int l, int t, int r, int b) { + super.onLayout(changed, l, t, r, b); + mInLayout = true; + layout(0, false); + mInLayout = false; + } + + /** + * Creates and positions all views for this Spinner. + * + * @param delta Change in the selected position. +1 moves selection is moving to the right, + * so views are scrolling to the left. -1 means selection is moving to the left. + */ + @Override + void layout(int delta, boolean animate) { + int childrenLeft = mSpinnerPadding.left; + int childrenWidth = getRight() - getLeft() - mSpinnerPadding.left - mSpinnerPadding.right; + + if (mDataChanged) { + handleDataChanged(); + } + + // Handle the empty set by removing all views + if (mItemCount == 0) { + resetList(); + return; + } + + if (mNextSelectedPosition >= 0) { + setSelectedPositionInt(mNextSelectedPosition); + } + + recycleAllViews(); + + // Clear out old views + removeAllViewsInLayout(); + + // Make selected view and position it + mFirstPosition = mSelectedPosition; + View sel = makeAndAddView(mSelectedPosition); + int width = sel.getMeasuredWidth(); + int selectedOffset = childrenLeft; + switch (mGravity & Gravity.HORIZONTAL_GRAVITY_MASK) { + case Gravity.CENTER_HORIZONTAL: + selectedOffset = childrenLeft + (childrenWidth / 2) - (width / 2); + break; + case Gravity.RIGHT: + selectedOffset = childrenLeft + childrenWidth - width; + break; + } + sel.offsetLeftAndRight(selectedOffset); + + // Flush any cached views that did not get reused above + mRecycler.clear(); + + invalidate(); + + checkSelectionChanged(); + + mDataChanged = false; + mNeedSync = false; + setNextSelectedPositionInt(mSelectedPosition); + } + + /** + * Obtain a view, either by pulling an existing view from the recycler or + * by getting a new one from the adapter. If we are animating, make sure + * there is enough information in the view's layout parameters to animate + * from the old to new positions. + * + * @param position Position in the spinner for the view to obtain + * @return A view that has been added to the spinner + */ + private View makeAndAddView(int position) { + + View child; + + if (!mDataChanged) { + child = mRecycler.get(position); + if (child != null) { + // Position the view + setUpChild(child); + + return child; + } + } + + // Nothing found in the recycler -- ask the adapter for a view + child = mAdapter.getView(position, null, this); + + // Position the view + setUpChild(child); + + return child; + } + + /** + * Helper for makeAndAddView to set the position of a view + * and fill out its layout paramters. + * + * @param child The view to position + */ + private void setUpChild(View child) { + + // Respect layout params that are already in the view. Otherwise + // make some up... + ViewGroup.LayoutParams lp = child.getLayoutParams(); + if (lp == null) { + lp = generateDefaultLayoutParams(); + } + + addViewInLayout(child, 0, lp); + + child.setSelected(hasFocus()); + if (mDisableChildrenWhenDisabled) { + child.setEnabled(isEnabled()); + } + + // Get measure specs + int childHeightSpec = ViewGroup.getChildMeasureSpec(mHeightMeasureSpec, + mSpinnerPadding.top + mSpinnerPadding.bottom, lp.height); + int childWidthSpec = ViewGroup.getChildMeasureSpec(mWidthMeasureSpec, + mSpinnerPadding.left + mSpinnerPadding.right, lp.width); + + // Measure child + child.measure(childWidthSpec, childHeightSpec); + + int childLeft; + int childRight; + + // Position vertically based on gravity setting + int childTop = mSpinnerPadding.top + + ((getMeasuredHeight() - mSpinnerPadding.bottom - + mSpinnerPadding.top - child.getMeasuredHeight()) / 2); + int childBottom = childTop + child.getMeasuredHeight(); + + int width = child.getMeasuredWidth(); + childLeft = 0; + childRight = childLeft + width; + + child.layout(childLeft, childTop, childRight, childBottom); + } + + @Override + public boolean performClick() { + boolean handled = super.performClick(); + + if (!handled) { + handled = true; + + if (!mPopup.isShowing()) { + mPopup.show(); + } + } + + return handled; + } + + public void onClick(DialogInterface dialog, int which) { + setSelection(which); + dialog.dismiss(); + } + + /** + * Sets the prompt to display when the dialog is shown. + * @param prompt the prompt to set + */ + public void setPrompt(CharSequence prompt) { + mPopup.setPromptText(prompt); + } + + /** + * Sets the prompt to display when the dialog is shown. + * @param promptId the resource ID of the prompt to display when the dialog is shown + */ + public void setPromptId(int promptId) { + setPrompt(getContext().getText(promptId)); + } + + /** + * @return The prompt to display when the dialog is shown + */ + public CharSequence getPrompt() { + return mPopup.getHintText(); + } + + int measureContentWidth(SpinnerAdapter adapter, Drawable background) { + if (adapter == null) { + return 0; + } + + int width = 0; + View itemView = null; + int itemType = 0; + final int widthMeasureSpec = + MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); + final int heightMeasureSpec = + MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); + + // Make sure the number of items we'll measure is capped. If it's a huge data set + // with wildly varying sizes, oh well. + int start = Math.max(0, getSelectedItemPosition()); + final int end = Math.min(adapter.getCount(), start + MAX_ITEMS_MEASURED); + final int count = end - start; + start = Math.max(0, start - (MAX_ITEMS_MEASURED - count)); + for (int i = start; i < end; i++) { + final int positionType = adapter.getItemViewType(i); + if (positionType != itemType) { + itemType = positionType; + itemView = null; + } + itemView = adapter.getView(i, itemView, this); + if (itemView.getLayoutParams() == null) { + itemView.setLayoutParams(new ViewGroup.LayoutParams( + ViewGroup.LayoutParams.WRAP_CONTENT, + ViewGroup.LayoutParams.WRAP_CONTENT)); + } + itemView.measure(widthMeasureSpec, heightMeasureSpec); + width = Math.max(width, itemView.getMeasuredWidth()); + } + + // Add background padding to measured width + if (background != null) { + background.getPadding(mTempRect); + width += mTempRect.left + mTempRect.right; + } + + return width; + } + + /** + *

Wrapper class for an Adapter. Transforms the embedded Adapter instance + * into a ListAdapter.

+ */ + private static class DropDownAdapter implements ListAdapter, SpinnerAdapter { + private SpinnerAdapter mAdapter; + private ListAdapter mListAdapter; + + /** + *

Creates a new ListAdapter wrapper for the specified adapter.

+ * + * @param adapter the Adapter to transform into a ListAdapter + */ + public DropDownAdapter(SpinnerAdapter adapter) { + this.mAdapter = adapter; + if (adapter instanceof ListAdapter) { + this.mListAdapter = (ListAdapter) adapter; + } + } + + public int getCount() { + return mAdapter == null ? 0 : mAdapter.getCount(); + } + + public Object getItem(int position) { + return mAdapter == null ? null : mAdapter.getItem(position); + } + + public long getItemId(int position) { + return mAdapter == null ? -1 : mAdapter.getItemId(position); + } + + public View getView(int position, View convertView, ViewGroup parent) { + return getDropDownView(position, convertView, parent); + } + + public View getDropDownView(int position, View convertView, ViewGroup parent) { + return mAdapter == null ? null : + mAdapter.getDropDownView(position, convertView, parent); + } + + public boolean hasStableIds() { + return mAdapter != null && mAdapter.hasStableIds(); + } + + public void registerDataSetObserver(DataSetObserver observer) { + if (mAdapter != null) { + mAdapter.registerDataSetObserver(observer); + } + } + + public void unregisterDataSetObserver(DataSetObserver observer) { + if (mAdapter != null) { + mAdapter.unregisterDataSetObserver(observer); + } + } + + /** + * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call. + * Otherwise, return true. + */ + public boolean areAllItemsEnabled() { + final ListAdapter adapter = mListAdapter; + if (adapter != null) { + return adapter.areAllItemsEnabled(); + } else { + return true; + } + } + + /** + * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call. + * Otherwise, return true. + */ + public boolean isEnabled(int position) { + final ListAdapter adapter = mListAdapter; + if (adapter != null) { + return adapter.isEnabled(position); + } else { + return true; + } + } + + public int getItemViewType(int position) { + return 0; + } + + public int getViewTypeCount() { + return 1; + } + + public boolean isEmpty() { + return getCount() == 0; + } + } + + /** + * Implements some sort of popup selection interface for selecting a spinner option. + * Allows for different spinner modes. + */ + private interface SpinnerPopup { + public void setAdapter(ListAdapter adapter); + + /** + * Show the popup + */ + public void show(); + + /** + * Dismiss the popup + */ + public void dismiss(); + + /** + * @return true if the popup is showing, false otherwise. + */ + public boolean isShowing(); + + /** + * Set hint text to be displayed to the user. This should provide + * a description of the choice being made. + * @param hintText Hint text to set. + */ + public void setPromptText(CharSequence hintText); + public CharSequence getHintText(); + } + + /* + private class DialogPopup implements SpinnerPopup, DialogInterface.OnClickListener { + private AlertDialog mPopup; + private ListAdapter mListAdapter; + private CharSequence mPrompt; + + public void dismiss() { + mPopup.dismiss(); + mPopup = null; + } + + public boolean isShowing() { + return mPopup != null ? mPopup.isShowing() : false; + } + + public void setAdapter(ListAdapter adapter) { + mListAdapter = adapter; + } + + public void setPromptText(CharSequence hintText) { + mPrompt = hintText; + } + + public CharSequence getHintText() { + return mPrompt; + } + + public void show() { + AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); + if (mPrompt != null) { + builder.setTitle(mPrompt); + } + mPopup = builder.setSingleChoiceItems(mListAdapter, + getSelectedItemPosition(), this).show(); + } + + public void onClick(DialogInterface dialog, int which) { + setSelection(which); + dismiss(); + } + } + */ + + private class DropdownPopup extends IcsListPopupWindow implements SpinnerPopup { + private CharSequence mHintText; + private ListAdapter mAdapter; + + public DropdownPopup(Context context, AttributeSet attrs, int defStyleRes) { + super(context, attrs, 0, defStyleRes); + + setAnchorView(IcsSpinner.this); + setModal(true); + setPromptPosition(POSITION_PROMPT_ABOVE); + setOnItemClickListener(new OnItemClickListener() { + @SuppressWarnings("rawtypes") + public void onItemClick(AdapterView parent, View v, int position, long id) { + IcsSpinner.this.setSelection(position); + dismiss(); + } + }); + } + + @Override + public void setAdapter(ListAdapter adapter) { + super.setAdapter(adapter); + mAdapter = adapter; + } + + public CharSequence getHintText() { + return mHintText; + } + + public void setPromptText(CharSequence hintText) { + // Hint text is ignored for dropdowns, but maintain it here. + mHintText = hintText; + } + + @Override + public void show() { + final int spinnerPaddingLeft = IcsSpinner.this.getPaddingLeft(); + if (mDropDownWidth == WRAP_CONTENT) { + final int spinnerWidth = IcsSpinner.this.getWidth(); + final int spinnerPaddingRight = IcsSpinner.this.getPaddingRight(); + setContentWidth(Math.max( + measureContentWidth((SpinnerAdapter) mAdapter, getBackground()), + spinnerWidth - spinnerPaddingLeft - spinnerPaddingRight)); + } else if (mDropDownWidth == MATCH_PARENT) { + final int spinnerWidth = IcsSpinner.this.getWidth(); + final int spinnerPaddingRight = IcsSpinner.this.getPaddingRight(); + setContentWidth(spinnerWidth - spinnerPaddingLeft - spinnerPaddingRight); + } else { + setContentWidth(mDropDownWidth); + } + final Drawable background = getBackground(); + int bgOffset = 0; + if (background != null) { + background.getPadding(mTempRect); + bgOffset = -mTempRect.left; + } + setHorizontalOffset(bgOffset + spinnerPaddingLeft); + setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED); + super.show(); + getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE); + setSelection(IcsSpinner.this.getSelectedItemPosition()); + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsView.java new file mode 100644 index 000000000..a7185d082 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/IcsView.java @@ -0,0 +1,21 @@ +package com.actionbarsherlock.internal.widget; + +import android.view.View; + +final class IcsView { + //No instances + private IcsView() {} + + /** + * Return only the state bits of {@link #getMeasuredWidthAndState()} + * and {@link #getMeasuredHeightAndState()}, combined into one integer. + * The width component is in the regular bits {@link #MEASURED_STATE_MASK} + * and the height component is at the shifted bits + * {@link #MEASURED_HEIGHT_STATE_SHIFT}>>{@link #MEASURED_STATE_MASK}. + */ + public static int getMeasuredStateInt(View child) { + return (child.getMeasuredWidth()&View.MEASURED_STATE_MASK) + | ((child.getMeasuredHeight()>>View.MEASURED_HEIGHT_STATE_SHIFT) + & (View.MEASURED_STATE_MASK>>View.MEASURED_HEIGHT_STATE_SHIFT)); + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.java b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.java new file mode 100644 index 000000000..1a532e06c --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.java @@ -0,0 +1,545 @@ +/* + * Copyright (C) 2011 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.actionbarsherlock.internal.widget; + +import android.content.Context; +import android.content.res.Configuration; +import android.content.res.TypedArray; +import android.graphics.drawable.Drawable; +import android.text.TextUtils.TruncateAt; +import android.util.AttributeSet; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewParent; +import android.view.animation.DecelerateInterpolator; +import android.view.animation.Interpolator; +import android.widget.BaseAdapter; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.ListView; +import com.actionbarsherlock.R; +import com.actionbarsherlock.app.ActionBar; +import com.actionbarsherlock.internal.nineoldandroids.animation.Animator; +import com.actionbarsherlock.internal.nineoldandroids.animation.ObjectAnimator; +import com.actionbarsherlock.internal.nineoldandroids.widget.NineHorizontalScrollView; + +/** + * This widget implements the dynamic action bar tab behavior that can change + * across different configurations or circumstances. + */ +public class ScrollingTabContainerView extends NineHorizontalScrollView + implements IcsAdapterView.OnItemSelectedListener { + //UNUSED private static final String TAG = "ScrollingTabContainerView"; + Runnable mTabSelector; + private TabClickListener mTabClickListener; + + private IcsLinearLayout mTabLayout; + private IcsSpinner mTabSpinner; + private boolean mAllowCollapse; + + private LayoutInflater mInflater; + + int mMaxTabWidth; + private int mContentHeight; + private int mSelectedTabIndex; + + protected Animator mVisibilityAnim; + protected final VisibilityAnimListener mVisAnimListener = new VisibilityAnimListener(); + + private static final /*Time*/Interpolator sAlphaInterpolator = new DecelerateInterpolator(); + + private static final int FADE_DURATION = 200; + + public ScrollingTabContainerView(Context context) { + super(context); + setHorizontalScrollBarEnabled(false); + + TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.SherlockActionBar, + R.attr.actionBarStyle, 0); + setContentHeight(a.getLayoutDimension(R.styleable.SherlockActionBar_height, 0)); + a.recycle(); + + mInflater = LayoutInflater.from(context); + + mTabLayout = createTabLayout(); + addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, + ViewGroup.LayoutParams.MATCH_PARENT)); + } + + @Override + public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + final int widthMode = MeasureSpec.getMode(widthMeasureSpec); + final boolean lockedExpanded = widthMode == MeasureSpec.EXACTLY; + setFillViewport(lockedExpanded); + + final int childCount = mTabLayout.getChildCount(); + if (childCount > 1 && + (widthMode == MeasureSpec.EXACTLY || widthMode == MeasureSpec.AT_MOST)) { + if (childCount > 2) { + mMaxTabWidth = (int) (MeasureSpec.getSize(widthMeasureSpec) * 0.4f); + } else { + mMaxTabWidth = MeasureSpec.getSize(widthMeasureSpec) / 2; + } + } else { + mMaxTabWidth = -1; + } + + heightMeasureSpec = MeasureSpec.makeMeasureSpec(mContentHeight, MeasureSpec.EXACTLY); + + final boolean canCollapse = !lockedExpanded && mAllowCollapse; + + if (canCollapse) { + // See if we should expand + mTabLayout.measure(MeasureSpec.UNSPECIFIED, heightMeasureSpec); + if (mTabLayout.getMeasuredWidth() > MeasureSpec.getSize(widthMeasureSpec)) { + performCollapse(); + } else { + performExpand(); + } + } else { + performExpand(); + } + + final int oldWidth = getMeasuredWidth(); + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + final int newWidth = getMeasuredWidth(); + + if (lockedExpanded && oldWidth != newWidth) { + // Recenter the tab display if we're at a new (scrollable) size. + setTabSelected(mSelectedTabIndex); + } + } + + /** + * Indicates whether this view is collapsed into a dropdown menu instead + * of traditional tabs. + * @return true if showing as a spinner + */ + private boolean isCollapsed() { + return mTabSpinner != null && mTabSpinner.getParent() == this; + } + + public void setAllowCollapse(boolean allowCollapse) { + mAllowCollapse = allowCollapse; + } + + private void performCollapse() { + if (isCollapsed()) return; + + if (mTabSpinner == null) { + mTabSpinner = createSpinner(); + } + removeView(mTabLayout); + addView(mTabSpinner, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, + ViewGroup.LayoutParams.MATCH_PARENT)); + if (mTabSpinner.getAdapter() == null) { + mTabSpinner.setAdapter(new TabAdapter()); + } + if (mTabSelector != null) { + removeCallbacks(mTabSelector); + mTabSelector = null; + } + mTabSpinner.setSelection(mSelectedTabIndex); + } + + private boolean performExpand() { + if (!isCollapsed()) return false; + + removeView(mTabSpinner); + addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, + ViewGroup.LayoutParams.MATCH_PARENT)); + setTabSelected(mTabSpinner.getSelectedItemPosition()); + return false; + } + + public void setTabSelected(int position) { + mSelectedTabIndex = position; + final int tabCount = mTabLayout.getChildCount(); + for (int i = 0; i < tabCount; i++) { + final View child = mTabLayout.getChildAt(i); + final boolean isSelected = i == position; + child.setSelected(isSelected); + if (isSelected) { + animateToTab(position); + } + } + } + + public void setContentHeight(int contentHeight) { + mContentHeight = contentHeight; + requestLayout(); + } + + private IcsLinearLayout createTabLayout() { + final IcsLinearLayout tabLayout = (IcsLinearLayout) LayoutInflater.from(getContext()) + .inflate(R.layout.abs__action_bar_tab_bar_view, null); + tabLayout.setLayoutParams(new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT)); + return tabLayout; + } + + private IcsSpinner createSpinner() { + final IcsSpinner spinner = new IcsSpinner(getContext(), null, + R.attr.actionDropDownStyle); + spinner.setLayoutParams(new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT)); + spinner.setOnItemSelectedListener(this); + return spinner; + } + + @Override + protected void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + + // Action bar can change size on configuration changes. + // Reread the desired height from the theme-specified style. + TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.SherlockActionBar, + R.attr.actionBarStyle, 0); + setContentHeight(a.getLayoutDimension(R.styleable.SherlockActionBar_height, 0)); + a.recycle(); + } + + public void animateToVisibility(int visibility) { + if (mVisibilityAnim != null) { + mVisibilityAnim.cancel(); + } + if (visibility == VISIBLE) { + if (getVisibility() != VISIBLE) { + setAlpha(0); + } + ObjectAnimator anim = ObjectAnimator.ofFloat(this, "alpha", 1); + anim.setDuration(FADE_DURATION); + anim.setInterpolator(sAlphaInterpolator); + + anim.addListener(mVisAnimListener.withFinalVisibility(visibility)); + anim.start(); + } else { + ObjectAnimator anim = ObjectAnimator.ofFloat(this, "alpha", 0); + anim.setDuration(FADE_DURATION); + anim.setInterpolator(sAlphaInterpolator); + + anim.addListener(mVisAnimListener.withFinalVisibility(visibility)); + anim.start(); + } + } + + public void animateToTab(final int position) { + final View tabView = mTabLayout.getChildAt(position); + if (mTabSelector != null) { + removeCallbacks(mTabSelector); + } + mTabSelector = new Runnable() { + public void run() { + final int scrollPos = tabView.getLeft() - (getWidth() - tabView.getWidth()) / 2; + smoothScrollTo(scrollPos, 0); + mTabSelector = null; + } + }; + post(mTabSelector); + } + + @Override + public void onAttachedToWindow() { + super.onAttachedToWindow(); + if (mTabSelector != null) { + // Re-post the selector we saved + post(mTabSelector); + } + } + + @Override + public void onDetachedFromWindow() { + super.onDetachedFromWindow(); + if (mTabSelector != null) { + removeCallbacks(mTabSelector); + } + } + + private TabView createTabView(ActionBar.Tab tab, boolean forAdapter) { + //Workaround for not being able to pass a defStyle on pre-3.0 + final TabView tabView = (TabView)mInflater.inflate(R.layout.abs__action_bar_tab, null); + tabView.init(this, tab, forAdapter); + + if (forAdapter) { + tabView.setBackgroundDrawable(null); + tabView.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, + mContentHeight)); + } else { + tabView.setFocusable(true); + + if (mTabClickListener == null) { + mTabClickListener = new TabClickListener(); + } + tabView.setOnClickListener(mTabClickListener); + } + return tabView; + } + + public void addTab(ActionBar.Tab tab, boolean setSelected) { + TabView tabView = createTabView(tab, false); + mTabLayout.addView(tabView, new IcsLinearLayout.LayoutParams(0, + LayoutParams.MATCH_PARENT, 1)); + if (mTabSpinner != null) { + ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged(); + } + if (setSelected) { + tabView.setSelected(true); + } + if (mAllowCollapse) { + requestLayout(); + } + } + + public void addTab(ActionBar.Tab tab, int position, boolean setSelected) { + final TabView tabView = createTabView(tab, false); + mTabLayout.addView(tabView, position, new IcsLinearLayout.LayoutParams( + 0, LayoutParams.MATCH_PARENT, 1)); + if (mTabSpinner != null) { + ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged(); + } + if (setSelected) { + tabView.setSelected(true); + } + if (mAllowCollapse) { + requestLayout(); + } + } + + public void updateTab(int position) { + ((TabView) mTabLayout.getChildAt(position)).update(); + if (mTabSpinner != null) { + ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged(); + } + if (mAllowCollapse) { + requestLayout(); + } + } + + public void removeTabAt(int position) { + mTabLayout.removeViewAt(position); + if (mTabSpinner != null) { + ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged(); + } + if (mAllowCollapse) { + requestLayout(); + } + } + + public void removeAllTabs() { + mTabLayout.removeAllViews(); + if (mTabSpinner != null) { + ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged(); + } + if (mAllowCollapse) { + requestLayout(); + } + } + + @Override + public void onItemSelected(IcsAdapterView parent, View view, int position, long id) { + TabView tabView = (TabView) view; + tabView.getTab().select(); + } + + @Override + public void onNothingSelected(IcsAdapterView parent) { + } + + public static class TabView extends LinearLayout { + private ScrollingTabContainerView mParent; + private ActionBar.Tab mTab; + private CapitalizingTextView mTextView; + private ImageView mIconView; + private View mCustomView; + + public TabView(Context context, AttributeSet attrs) { + //TODO super(context, null, R.attr.actionBarTabStyle); + super(context, attrs); + } + + public void init(ScrollingTabContainerView parent, ActionBar.Tab tab, boolean forList) { + mParent = parent; + mTab = tab; + + if (forList) { + setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); + } + + update(); + } + + public void bindTab(ActionBar.Tab tab) { + mTab = tab; + update(); + } + + @Override + public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + + // Re-measure if we went beyond our maximum size. + if (mParent.mMaxTabWidth > 0 && getMeasuredWidth() > mParent.mMaxTabWidth) { + super.onMeasure(MeasureSpec.makeMeasureSpec(mParent.mMaxTabWidth, MeasureSpec.EXACTLY), + heightMeasureSpec); + } + } + + public void update() { + final ActionBar.Tab tab = mTab; + final View custom = tab.getCustomView(); + if (custom != null) { + final ViewParent customParent = custom.getParent(); + if (customParent != this) { + if (customParent != null) ((ViewGroup) customParent).removeView(custom); + addView(custom); + } + mCustomView = custom; + if (mTextView != null) mTextView.setVisibility(GONE); + if (mIconView != null) { + mIconView.setVisibility(GONE); + mIconView.setImageDrawable(null); + } + } else { + if (mCustomView != null) { + removeView(mCustomView); + mCustomView = null; + } + + final Drawable icon = tab.getIcon(); + final CharSequence text = tab.getText(); + + if (icon != null) { + if (mIconView == null) { + ImageView iconView = new ImageView(getContext()); + LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, + LayoutParams.WRAP_CONTENT); + lp.gravity = Gravity.CENTER_VERTICAL; + iconView.setLayoutParams(lp); + addView(iconView, 0); + mIconView = iconView; + } + mIconView.setImageDrawable(icon); + mIconView.setVisibility(VISIBLE); + } else if (mIconView != null) { + mIconView.setVisibility(GONE); + mIconView.setImageDrawable(null); + } + + if (text != null) { + if (mTextView == null) { + CapitalizingTextView textView = new CapitalizingTextView(getContext(), null, + R.attr.actionBarTabTextStyle); + textView.setEllipsize(TruncateAt.END); + LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, + LayoutParams.WRAP_CONTENT); + lp.gravity = Gravity.CENTER_VERTICAL; + textView.setLayoutParams(lp); + addView(textView); + mTextView = textView; + } + mTextView.setTextCompat(text); + mTextView.setVisibility(VISIBLE); + } else if (mTextView != null) { + mTextView.setVisibility(GONE); + mTextView.setText(null); + } + + if (mIconView != null) { + mIconView.setContentDescription(tab.getContentDescription()); + } + } + } + + public ActionBar.Tab getTab() { + return mTab; + } + } + + private class TabAdapter extends BaseAdapter { + @Override + public int getCount() { + return mTabLayout.getChildCount(); + } + + @Override + public Object getItem(int position) { + return ((TabView) mTabLayout.getChildAt(position)).getTab(); + } + + @Override + public long getItemId(int position) { + return position; + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + if (convertView == null) { + convertView = createTabView((ActionBar.Tab) getItem(position), true); + } else { + ((TabView) convertView).bindTab((ActionBar.Tab) getItem(position)); + } + return convertView; + } + } + + private class TabClickListener implements OnClickListener { + public void onClick(View view) { + TabView tabView = (TabView) view; + tabView.getTab().select(); + final int tabCount = mTabLayout.getChildCount(); + for (int i = 0; i < tabCount; i++) { + final View child = mTabLayout.getChildAt(i); + child.setSelected(child == view); + } + } + } + + protected class VisibilityAnimListener implements Animator.AnimatorListener { + private boolean mCanceled = false; + private int mFinalVisibility; + + public VisibilityAnimListener withFinalVisibility(int visibility) { + mFinalVisibility = visibility; + return this; + } + + @Override + public void onAnimationStart(Animator animation) { + setVisibility(VISIBLE); + mVisibilityAnim = animation; + mCanceled = false; + } + + @Override + public void onAnimationEnd(Animator animation) { + if (mCanceled) return; + + mVisibilityAnim = null; + setVisibility(mFinalVisibility); + } + + @Override + public void onAnimationCancel(Animator animation) { + mCanceled = true; + } + + @Override + public void onAnimationRepeat(Animator animation) { + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/view/ActionMode.java b/actionbarsherlock/src/com/actionbarsherlock/view/ActionMode.java new file mode 100644 index 000000000..81b4cd4d2 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/view/ActionMode.java @@ -0,0 +1,224 @@ +/* + * Copyright (C) 2010 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.actionbarsherlock.view; + +import android.view.View; + + +/** + * Represents a contextual mode of the user interface. Action modes can be used for + * modal interactions with content and replace parts of the normal UI until finished. + * Examples of good action modes include selection modes, search, content editing, etc. + */ +public abstract class ActionMode { + private Object mTag; + + /** + * Set a tag object associated with this ActionMode. + * + *

Like the tag available to views, this allows applications to associate arbitrary + * data with an ActionMode for later reference. + * + * @param tag Tag to associate with this ActionMode + * + * @see #getTag() + */ + public void setTag(Object tag) { + mTag = tag; + } + + /** + * Retrieve the tag object associated with this ActionMode. + * + *

Like the tag available to views, this allows applications to associate arbitrary + * data with an ActionMode for later reference. + * + * @return Tag associated with this ActionMode + * + * @see #setTag(Object) + */ + public Object getTag() { + return mTag; + } + + /** + * Set the title of the action mode. This method will have no visible effect if + * a custom view has been set. + * + * @param title Title string to set + * + * @see #setTitle(int) + * @see #setCustomView(View) + */ + public abstract void setTitle(CharSequence title); + + /** + * Set the title of the action mode. This method will have no visible effect if + * a custom view has been set. + * + * @param resId Resource ID of a string to set as the title + * + * @see #setTitle(CharSequence) + * @see #setCustomView(View) + */ + public abstract void setTitle(int resId); + + /** + * Set the subtitle of the action mode. This method will have no visible effect if + * a custom view has been set. + * + * @param subtitle Subtitle string to set + * + * @see #setSubtitle(int) + * @see #setCustomView(View) + */ + public abstract void setSubtitle(CharSequence subtitle); + + /** + * Set the subtitle of the action mode. This method will have no visible effect if + * a custom view has been set. + * + * @param resId Resource ID of a string to set as the subtitle + * + * @see #setSubtitle(CharSequence) + * @see #setCustomView(View) + */ + public abstract void setSubtitle(int resId); + + /** + * Set a custom view for this action mode. The custom view will take the place of + * the title and subtitle. Useful for things like search boxes. + * + * @param view Custom view to use in place of the title/subtitle. + * + * @see #setTitle(CharSequence) + * @see #setSubtitle(CharSequence) + */ + public abstract void setCustomView(View view); + + /** + * Invalidate the action mode and refresh menu content. The mode's + * {@link ActionMode.Callback} will have its + * {@link Callback#onPrepareActionMode(ActionMode, Menu)} method called. + * If it returns true the menu will be scanned for updated content and any relevant changes + * will be reflected to the user. + */ + public abstract void invalidate(); + + /** + * Finish and close this action mode. The action mode's {@link ActionMode.Callback} will + * have its {@link Callback#onDestroyActionMode(ActionMode)} method called. + */ + public abstract void finish(); + + /** + * Returns the menu of actions that this action mode presents. + * @return The action mode's menu. + */ + public abstract Menu getMenu(); + + /** + * Returns the current title of this action mode. + * @return Title text + */ + public abstract CharSequence getTitle(); + + /** + * Returns the current subtitle of this action mode. + * @return Subtitle text + */ + public abstract CharSequence getSubtitle(); + + /** + * Returns the current custom view for this action mode. + * @return The current custom view + */ + public abstract View getCustomView(); + + /** + * Returns a {@link MenuInflater} with the ActionMode's context. + */ + public abstract MenuInflater getMenuInflater(); + + /** + * Returns whether the UI presenting this action mode can take focus or not. + * This is used by internal components within the framework that would otherwise + * present an action mode UI that requires focus, such as an EditText as a custom view. + * + * @return true if the UI used to show this action mode can take focus + * @hide Internal use only + */ + public boolean isUiFocusable() { + return true; + } + + /** + * Callback interface for action modes. Supplied to + * {@link View#startActionMode(Callback)}, a Callback + * configures and handles events raised by a user's interaction with an action mode. + * + *

An action mode's lifecycle is as follows: + *

    + *
  • {@link Callback#onCreateActionMode(ActionMode, Menu)} once on initial + * creation
  • + *
  • {@link Callback#onPrepareActionMode(ActionMode, Menu)} after creation + * and any time the {@link ActionMode} is invalidated
  • + *
  • {@link Callback#onActionItemClicked(ActionMode, MenuItem)} any time a + * contextual action button is clicked
  • + *
  • {@link Callback#onDestroyActionMode(ActionMode)} when the action mode + * is closed
  • + *
+ */ + public interface Callback { + /** + * Called when action mode is first created. The menu supplied will be used to + * generate action buttons for the action mode. + * + * @param mode ActionMode being created + * @param menu Menu used to populate action buttons + * @return true if the action mode should be created, false if entering this + * mode should be aborted. + */ + public boolean onCreateActionMode(ActionMode mode, Menu menu); + + /** + * Called to refresh an action mode's action menu whenever it is invalidated. + * + * @param mode ActionMode being prepared + * @param menu Menu used to populate action buttons + * @return true if the menu or action mode was updated, false otherwise. + */ + public boolean onPrepareActionMode(ActionMode mode, Menu menu); + + /** + * Called to report a user click on an action button. + * + * @param mode The current ActionMode + * @param item The item that was clicked + * @return true if this callback handled the event, false if the standard MenuItem + * invocation should continue. + */ + public boolean onActionItemClicked(ActionMode mode, MenuItem item); + + /** + * Called when an action mode is about to be exited and destroyed. + * + * @param mode The current ActionMode being destroyed + */ + public void onDestroyActionMode(ActionMode mode); + } +} \ No newline at end of file diff --git a/actionbarsherlock/src/com/actionbarsherlock/view/ActionProvider.java b/actionbarsherlock/src/com/actionbarsherlock/view/ActionProvider.java new file mode 100644 index 000000000..ae7cb1fe0 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/view/ActionProvider.java @@ -0,0 +1,170 @@ +/* + * Copyright (C) 2011 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.actionbarsherlock.view; + +import android.content.Context; +import android.view.View; + +/** + * This class is a mediator for accomplishing a given task, for example sharing a file. + * It is responsible for creating a view that performs an action that accomplishes the task. + * This class also implements other functions such a performing a default action. + *

+ * An ActionProvider can be optionally specified for a {@link MenuItem} and in such a + * case it will be responsible for creating the action view that appears in the + * {@link android.app.ActionBar} as a substitute for the menu item when the item is + * displayed as an action item. Also the provider is responsible for performing a + * default action if a menu item placed on the overflow menu of the ActionBar is + * selected and none of the menu item callbacks has handled the selection. For this + * case the provider can also optionally provide a sub-menu for accomplishing the + * task at hand. + *

+ *

+ * There are two ways for using an action provider for creating and handling of action views: + *

    + *
  • + * Setting the action provider on a {@link MenuItem} directly by calling + * {@link MenuItem#setActionProvider(ActionProvider)}. + *
  • + *
  • + * Declaring the action provider in the menu XML resource. For example: + *
    + * 
    + *   <item android:id="@+id/my_menu_item"
    + *     android:title="Title"
    + *     android:icon="@drawable/my_menu_item_icon"
    + *     android:showAsAction="ifRoom"
    + *     android:actionProviderClass="foo.bar.SomeActionProvider" />
    + * 
    + * 
    + *
  • + *
+ *

+ * + * @see MenuItem#setActionProvider(ActionProvider) + * @see MenuItem#getActionProvider() + */ +public abstract class ActionProvider { + private SubUiVisibilityListener mSubUiVisibilityListener; + + /** + * Creates a new instance. + * + * @param context Context for accessing resources. + */ + public ActionProvider(Context context) { + } + + /** + * Factory method for creating new action views. + * + * @return A new action view. + */ + public abstract View onCreateActionView(); + + /** + * Performs an optional default action. + *

+ * For the case of an action provider placed in a menu item not shown as an action this + * method is invoked if previous callbacks for processing menu selection has handled + * the event. + *

+ *

+ * A menu item selection is processed in the following order: + *

    + *
  • + * Receiving a call to {@link MenuItem.OnMenuItemClickListener#onMenuItemClick + * MenuItem.OnMenuItemClickListener.onMenuItemClick}. + *
  • + *
  • + * Receiving a call to {@link android.app.Activity#onOptionsItemSelected(MenuItem) + * Activity.onOptionsItemSelected(MenuItem)} + *
  • + *
  • + * Receiving a call to {@link android.app.Fragment#onOptionsItemSelected(MenuItem) + * Fragment.onOptionsItemSelected(MenuItem)} + *
  • + *
  • + * Launching the {@link android.content.Intent} set via + * {@link MenuItem#setIntent(android.content.Intent) MenuItem.setIntent(android.content.Intent)} + *
  • + *
  • + * Invoking this method. + *
  • + *
+ *

+ *

+ * The default implementation does not perform any action and returns false. + *

+ */ + public boolean onPerformDefaultAction() { + return false; + } + + /** + * Determines if this ActionProvider has a submenu associated with it. + * + *

Associated submenus will be shown when an action view is not. This + * provider instance will receive a call to {@link #onPrepareSubMenu(SubMenu)} + * after the call to {@link #onPerformDefaultAction()} and before a submenu is + * displayed to the user. + * + * @return true if the item backed by this provider should have an associated submenu + */ + public boolean hasSubMenu() { + return false; + } + + /** + * Called to prepare an associated submenu for the menu item backed by this ActionProvider. + * + *

if {@link #hasSubMenu()} returns true, this method will be called when the + * menu item is selected to prepare the submenu for presentation to the user. Apps + * may use this to create or alter submenu content right before display. + * + * @param subMenu Submenu that will be displayed + */ + public void onPrepareSubMenu(SubMenu subMenu) { + } + + /** + * Notify the system that the visibility of an action view's sub-UI such as + * an anchored popup has changed. This will affect how other system + * visibility notifications occur. + * + * @hide Pending future API approval + */ + public void subUiVisibilityChanged(boolean isVisible) { + if (mSubUiVisibilityListener != null) { + mSubUiVisibilityListener.onSubUiVisibilityChanged(isVisible); + } + } + + /** + * @hide Internal use only + */ + public void setSubUiVisibilityListener(SubUiVisibilityListener listener) { + mSubUiVisibilityListener = listener; + } + + /** + * @hide Internal use only + */ + public interface SubUiVisibilityListener { + public void onSubUiVisibilityChanged(boolean isVisible); + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/view/CollapsibleActionView.java b/actionbarsherlock/src/com/actionbarsherlock/view/CollapsibleActionView.java new file mode 100644 index 000000000..43281b013 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/view/CollapsibleActionView.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2011 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.actionbarsherlock.view; + +/** + * When a {@link View} implements this interface it will receive callbacks + * when expanded or collapsed as an action view alongside the optional, + * app-specified callbacks to {@link OnActionExpandListener}. + * + *

See {@link MenuItem} for more information about action views. + * See {@link android.app.ActionBar} for more information about the action bar. + */ +public interface CollapsibleActionView { + /** + * Called when this view is expanded as an action view. + * See {@link MenuItem#expandActionView()}. + */ + public void onActionViewExpanded(); + + /** + * Called when this view is collapsed as an action view. + * See {@link MenuItem#collapseActionView()}. + */ + public void onActionViewCollapsed(); +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/view/Menu.java b/actionbarsherlock/src/com/actionbarsherlock/view/Menu.java new file mode 100644 index 000000000..951f4ccef --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/view/Menu.java @@ -0,0 +1,447 @@ +/* + * Copyright (C) 2006 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.actionbarsherlock.view; + +import android.content.ComponentName; +import android.content.Intent; +import android.view.KeyEvent; + +/** + * Interface for managing the items in a menu. + *

+ * By default, every Activity supports an options menu of actions or options. + * You can add items to this menu and handle clicks on your additions. The + * easiest way of adding menu items is inflating an XML file into the + * {@link Menu} via {@link MenuInflater}. The easiest way of attaching code to + * clicks is via {@link Activity#onOptionsItemSelected(MenuItem)} and + * {@link Activity#onContextItemSelected(MenuItem)}. + *

+ * Different menu types support different features: + *

    + *
  1. Context menus: Do not support item shortcuts and item icons. + *
  2. Options menus: The icon menus do not support item check + * marks and only show the item's + * {@link MenuItem#setTitleCondensed(CharSequence) condensed title}. The + * expanded menus (only available if six or more menu items are visible, + * reached via the 'More' item in the icon menu) do not show item icons, and + * item check marks are discouraged. + *
  3. Sub menus: Do not support item icons, or nested sub menus. + *
+ * + *
+ *

Developer Guides

+ *

For more information about creating menus, read the + * Menus developer guide.

+ *
+ */ +public interface Menu { + + /** + * This is the part of an order integer that the user can provide. + * @hide + */ + static final int USER_MASK = 0x0000ffff; + /** + * Bit shift of the user portion of the order integer. + * @hide + */ + static final int USER_SHIFT = 0; + + /** + * This is the part of an order integer that supplies the category of the + * item. + * @hide + */ + static final int CATEGORY_MASK = 0xffff0000; + /** + * Bit shift of the category portion of the order integer. + * @hide + */ + static final int CATEGORY_SHIFT = 16; + + /** + * Value to use for group and item identifier integers when you don't care + * about them. + */ + static final int NONE = 0; + + /** + * First value for group and item identifier integers. + */ + static final int FIRST = 1; + + // Implementation note: Keep these CATEGORY_* in sync with the category enum + // in attrs.xml + + /** + * Category code for the order integer for items/groups that are part of a + * container -- or/add this with your base value. + */ + static final int CATEGORY_CONTAINER = 0x00010000; + + /** + * Category code for the order integer for items/groups that are provided by + * the system -- or/add this with your base value. + */ + static final int CATEGORY_SYSTEM = 0x00020000; + + /** + * Category code for the order integer for items/groups that are + * user-supplied secondary (infrequently used) options -- or/add this with + * your base value. + */ + static final int CATEGORY_SECONDARY = 0x00030000; + + /** + * Category code for the order integer for items/groups that are + * alternative actions on the data that is currently displayed -- or/add + * this with your base value. + */ + static final int CATEGORY_ALTERNATIVE = 0x00040000; + + /** + * Flag for {@link #addIntentOptions}: if set, do not automatically remove + * any existing menu items in the same group. + */ + static final int FLAG_APPEND_TO_GROUP = 0x0001; + + /** + * Flag for {@link #performShortcut}: if set, do not close the menu after + * executing the shortcut. + */ + static final int FLAG_PERFORM_NO_CLOSE = 0x0001; + + /** + * Flag for {@link #performShortcut(int, KeyEvent, int)}: if set, always + * close the menu after executing the shortcut. Closing the menu also resets + * the prepared state. + */ + static final int FLAG_ALWAYS_PERFORM_CLOSE = 0x0002; + + /** + * Add a new item to the menu. This item displays the given title for its + * label. + * + * @param title The text to display for the item. + * @return The newly added menu item. + */ + public MenuItem add(CharSequence title); + + /** + * Add a new item to the menu. This item displays the given title for its + * label. + * + * @param titleRes Resource identifier of title string. + * @return The newly added menu item. + */ + public MenuItem add(int titleRes); + + /** + * Add a new item to the menu. This item displays the given title for its + * label. + * + * @param groupId The group identifier that this item should be part of. + * This can be used to define groups of items for batch state + * changes. Normally use {@link #NONE} if an item should not be in a + * group. + * @param itemId Unique item ID. Use {@link #NONE} if you do not need a + * unique ID. + * @param order The order for the item. Use {@link #NONE} if you do not care + * about the order. See {@link MenuItem#getOrder()}. + * @param title The text to display for the item. + * @return The newly added menu item. + */ + public MenuItem add(int groupId, int itemId, int order, CharSequence title); + + /** + * Variation on {@link #add(int, int, int, CharSequence)} that takes a + * string resource identifier instead of the string itself. + * + * @param groupId The group identifier that this item should be part of. + * This can also be used to define groups of items for batch state + * changes. Normally use {@link #NONE} if an item should not be in a + * group. + * @param itemId Unique item ID. Use {@link #NONE} if you do not need a + * unique ID. + * @param order The order for the item. Use {@link #NONE} if you do not care + * about the order. See {@link MenuItem#getOrder()}. + * @param titleRes Resource identifier of title string. + * @return The newly added menu item. + */ + public MenuItem add(int groupId, int itemId, int order, int titleRes); + + /** + * Add a new sub-menu to the menu. This item displays the given title for + * its label. To modify other attributes on the submenu's menu item, use + * {@link SubMenu#getItem()}. + * + * @param title The text to display for the item. + * @return The newly added sub-menu + */ + SubMenu addSubMenu(final CharSequence title); + + /** + * Add a new sub-menu to the menu. This item displays the given title for + * its label. To modify other attributes on the submenu's menu item, use + * {@link SubMenu#getItem()}. + * + * @param titleRes Resource identifier of title string. + * @return The newly added sub-menu + */ + SubMenu addSubMenu(final int titleRes); + + /** + * Add a new sub-menu to the menu. This item displays the given + * title for its label. To modify other attributes on the + * submenu's menu item, use {@link SubMenu#getItem()}. + *

+ * Note that you can only have one level of sub-menus, i.e. you cannnot add + * a subMenu to a subMenu: An {@link UnsupportedOperationException} will be + * thrown if you try. + * + * @param groupId The group identifier that this item should be part of. + * This can also be used to define groups of items for batch state + * changes. Normally use {@link #NONE} if an item should not be in a + * group. + * @param itemId Unique item ID. Use {@link #NONE} if you do not need a + * unique ID. + * @param order The order for the item. Use {@link #NONE} if you do not care + * about the order. See {@link MenuItem#getOrder()}. + * @param title The text to display for the item. + * @return The newly added sub-menu + */ + SubMenu addSubMenu(final int groupId, final int itemId, int order, final CharSequence title); + + /** + * Variation on {@link #addSubMenu(int, int, int, CharSequence)} that takes + * a string resource identifier for the title instead of the string itself. + * + * @param groupId The group identifier that this item should be part of. + * This can also be used to define groups of items for batch state + * changes. Normally use {@link #NONE} if an item should not be in a group. + * @param itemId Unique item ID. Use {@link #NONE} if you do not need a unique ID. + * @param order The order for the item. Use {@link #NONE} if you do not care about the + * order. See {@link MenuItem#getOrder()}. + * @param titleRes Resource identifier of title string. + * @return The newly added sub-menu + */ + SubMenu addSubMenu(int groupId, int itemId, int order, int titleRes); + + /** + * Add a group of menu items corresponding to actions that can be performed + * for a particular Intent. The Intent is most often configured with a null + * action, the data that the current activity is working with, and includes + * either the {@link Intent#CATEGORY_ALTERNATIVE} or + * {@link Intent#CATEGORY_SELECTED_ALTERNATIVE} to find activities that have + * said they would like to be included as optional action. You can, however, + * use any Intent you want. + * + *

+ * See {@link android.content.pm.PackageManager#queryIntentActivityOptions} + * for more * details on the caller, specifics, and + * intent arguments. The list returned by that function is used + * to populate the resulting menu items. + * + *

+ * All of the menu items of possible options for the intent will be added + * with the given group and id. You can use the group to control ordering of + * the items in relation to other items in the menu. Normally this function + * will automatically remove any existing items in the menu in the same + * group and place a divider above and below the added items; this behavior + * can be modified with the flags parameter. For each of the + * generated items {@link MenuItem#setIntent} is called to associate the + * appropriate Intent with the item; this means the activity will + * automatically be started for you without having to do anything else. + * + * @param groupId The group identifier that the items should be part of. + * This can also be used to define groups of items for batch state + * changes. Normally use {@link #NONE} if the items should not be in + * a group. + * @param itemId Unique item ID. Use {@link #NONE} if you do not need a + * unique ID. + * @param order The order for the items. Use {@link #NONE} if you do not + * care about the order. See {@link MenuItem#getOrder()}. + * @param caller The current activity component name as defined by + * queryIntentActivityOptions(). + * @param specifics Specific items to place first as defined by + * queryIntentActivityOptions(). + * @param intent Intent describing the kinds of items to populate in the + * list as defined by queryIntentActivityOptions(). + * @param flags Additional options controlling how the items are added. + * @param outSpecificItems Optional array in which to place the menu items + * that were generated for each of the specifics that were + * requested. Entries may be null if no activity was found for that + * specific action. + * @return The number of menu items that were added. + * + * @see #FLAG_APPEND_TO_GROUP + * @see MenuItem#setIntent + * @see android.content.pm.PackageManager#queryIntentActivityOptions + */ + public int addIntentOptions(int groupId, int itemId, int order, + ComponentName caller, Intent[] specifics, + Intent intent, int flags, MenuItem[] outSpecificItems); + + /** + * Remove the item with the given identifier. + * + * @param id The item to be removed. If there is no item with this + * identifier, nothing happens. + */ + public void removeItem(int id); + + /** + * Remove all items in the given group. + * + * @param groupId The group to be removed. If there are no items in this + * group, nothing happens. + */ + public void removeGroup(int groupId); + + /** + * Remove all existing items from the menu, leaving it empty as if it had + * just been created. + */ + public void clear(); + + /** + * Control whether a particular group of items can show a check mark. This + * is similar to calling {@link MenuItem#setCheckable} on all of the menu items + * with the given group identifier, but in addition you can control whether + * this group contains a mutually-exclusive set items. This should be called + * after the items of the group have been added to the menu. + * + * @param group The group of items to operate on. + * @param checkable Set to true to allow a check mark, false to + * disallow. The default is false. + * @param exclusive If set to true, only one item in this group can be + * checked at a time; checking an item will automatically + * uncheck all others in the group. If set to false, each + * item can be checked independently of the others. + * + * @see MenuItem#setCheckable + * @see MenuItem#setChecked + */ + public void setGroupCheckable(int group, boolean checkable, boolean exclusive); + + /** + * Show or hide all menu items that are in the given group. + * + * @param group The group of items to operate on. + * @param visible If true the items are visible, else they are hidden. + * + * @see MenuItem#setVisible + */ + public void setGroupVisible(int group, boolean visible); + + /** + * Enable or disable all menu items that are in the given group. + * + * @param group The group of items to operate on. + * @param enabled If true the items will be enabled, else they will be disabled. + * + * @see MenuItem#setEnabled + */ + public void setGroupEnabled(int group, boolean enabled); + + /** + * Return whether the menu currently has item items that are visible. + * + * @return True if there is one or more item visible, + * else false. + */ + public boolean hasVisibleItems(); + + /** + * Return the menu item with a particular identifier. + * + * @param id The identifier to find. + * + * @return The menu item object, or null if there is no item with + * this identifier. + */ + public MenuItem findItem(int id); + + /** + * Get the number of items in the menu. Note that this will change any + * times items are added or removed from the menu. + * + * @return The item count. + */ + public int size(); + + /** + * Gets the menu item at the given index. + * + * @param index The index of the menu item to return. + * @return The menu item. + * @exception IndexOutOfBoundsException + * when {@code index < 0 || >= size()} + */ + public MenuItem getItem(int index); + + /** + * Closes the menu, if open. + */ + public void close(); + + /** + * Execute the menu item action associated with the given shortcut + * character. + * + * @param keyCode The keycode of the shortcut key. + * @param event Key event message. + * @param flags Additional option flags or 0. + * + * @return If the given shortcut exists and is shown, returns + * true; else returns false. + * + * @see #FLAG_PERFORM_NO_CLOSE + */ + public boolean performShortcut(int keyCode, KeyEvent event, int flags); + + /** + * Is a keypress one of the defined shortcut keys for this window. + * @param keyCode the key code from {@link KeyEvent} to check. + * @param event the {@link KeyEvent} to use to help check. + */ + boolean isShortcutKey(int keyCode, KeyEvent event); + + /** + * Execute the menu item action associated with the given menu identifier. + * + * @param id Identifier associated with the menu item. + * @param flags Additional option flags or 0. + * + * @return If the given identifier exists and is shown, returns + * true; else returns false. + * + * @see #FLAG_PERFORM_NO_CLOSE + */ + public boolean performIdentifierAction(int id, int flags); + + + /** + * Control whether the menu should be running in qwerty mode (alphabetic + * shortcuts) or 12-key mode (numeric shortcuts). + * + * @param isQwerty If true the menu will use alphabetic shortcuts; else it + * will use numeric shortcuts. + */ + public void setQwertyMode(boolean isQwerty); +} + diff --git a/actionbarsherlock/src/com/actionbarsherlock/view/MenuInflater.java b/actionbarsherlock/src/com/actionbarsherlock/view/MenuInflater.java new file mode 100644 index 000000000..969459749 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/view/MenuInflater.java @@ -0,0 +1,472 @@ +/* + * Copyright (C) 2006 The Android Open Source Project + * 2011 Jake Wharton + * + * 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.actionbarsherlock.view; + +import java.io.IOException; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; +import android.content.Context; +import android.content.res.TypedArray; +import android.content.res.XmlResourceParser; +import android.util.AttributeSet; +import android.util.Log; +import android.util.TypedValue; +import android.util.Xml; +import android.view.InflateException; +import android.view.View; + +import com.actionbarsherlock.R; +import com.actionbarsherlock.internal.view.menu.MenuItemImpl; + +/** + * This class is used to instantiate menu XML files into Menu objects. + *

+ * For performance reasons, menu inflation relies heavily on pre-processing of + * XML files that is done at build time. Therefore, it is not currently possible + * to use MenuInflater with an XmlPullParser over a plain XML file at runtime; + * it only works with an XmlPullParser returned from a compiled resource (R. + * something file.) + */ +public class MenuInflater { + private static final String LOG_TAG = "MenuInflater"; + + /** Menu tag name in XML. */ + private static final String XML_MENU = "menu"; + + /** Group tag name in XML. */ + private static final String XML_GROUP = "group"; + + /** Item tag name in XML. */ + private static final String XML_ITEM = "item"; + + private static final int NO_ID = 0; + + private static final Class[] ACTION_VIEW_CONSTRUCTOR_SIGNATURE = new Class[] {Context.class}; + + private static final Class[] ACTION_PROVIDER_CONSTRUCTOR_SIGNATURE = ACTION_VIEW_CONSTRUCTOR_SIGNATURE; + + private final Object[] mActionViewConstructorArguments; + + private final Object[] mActionProviderConstructorArguments; + + private Context mContext; + + /** + * Constructs a menu inflater. + * + * @see Activity#getMenuInflater() + */ + public MenuInflater(Context context) { + mContext = context; + mActionViewConstructorArguments = new Object[] {context}; + mActionProviderConstructorArguments = mActionViewConstructorArguments; + } + + /** + * Inflate a menu hierarchy from the specified XML resource. Throws + * {@link InflateException} if there is an error. + * + * @param menuRes Resource ID for an XML layout resource to load (e.g., + * R.menu.main_activity) + * @param menu The Menu to inflate into. The items and submenus will be + * added to this Menu. + */ + public void inflate(int menuRes, Menu menu) { + XmlResourceParser parser = null; + try { + parser = mContext.getResources().getLayout(menuRes); + AttributeSet attrs = Xml.asAttributeSet(parser); + + parseMenu(parser, attrs, menu); + } catch (XmlPullParserException e) { + throw new InflateException("Error inflating menu XML", e); + } catch (IOException e) { + throw new InflateException("Error inflating menu XML", e); + } finally { + if (parser != null) parser.close(); + } + } + + /** + * Called internally to fill the given menu. If a sub menu is seen, it will + * call this recursively. + */ + private void parseMenu(XmlPullParser parser, AttributeSet attrs, Menu menu) + throws XmlPullParserException, IOException { + MenuState menuState = new MenuState(menu); + + int eventType = parser.getEventType(); + String tagName; + boolean lookingForEndOfUnknownTag = false; + String unknownTagName = null; + + // This loop will skip to the menu start tag + do { + if (eventType == XmlPullParser.START_TAG) { + tagName = parser.getName(); + if (tagName.equals(XML_MENU)) { + // Go to next tag + eventType = parser.next(); + break; + } + + throw new RuntimeException("Expecting menu, got " + tagName); + } + eventType = parser.next(); + } while (eventType != XmlPullParser.END_DOCUMENT); + + boolean reachedEndOfMenu = false; + while (!reachedEndOfMenu) { + switch (eventType) { + case XmlPullParser.START_TAG: + if (lookingForEndOfUnknownTag) { + break; + } + + tagName = parser.getName(); + if (tagName.equals(XML_GROUP)) { + menuState.readGroup(attrs); + } else if (tagName.equals(XML_ITEM)) { + menuState.readItem(attrs); + } else if (tagName.equals(XML_MENU)) { + // A menu start tag denotes a submenu for an item + SubMenu subMenu = menuState.addSubMenuItem(); + + // Parse the submenu into returned SubMenu + parseMenu(parser, attrs, subMenu); + } else { + lookingForEndOfUnknownTag = true; + unknownTagName = tagName; + } + break; + + case XmlPullParser.END_TAG: + tagName = parser.getName(); + if (lookingForEndOfUnknownTag && tagName.equals(unknownTagName)) { + lookingForEndOfUnknownTag = false; + unknownTagName = null; + } else if (tagName.equals(XML_GROUP)) { + menuState.resetGroup(); + } else if (tagName.equals(XML_ITEM)) { + // Add the item if it hasn't been added (if the item was + // a submenu, it would have been added already) + if (!menuState.hasAddedItem()) { + if (menuState.itemActionProvider != null && + menuState.itemActionProvider.hasSubMenu()) { + menuState.addSubMenuItem(); + } else { + menuState.addItem(); + } + } + } else if (tagName.equals(XML_MENU)) { + reachedEndOfMenu = true; + } + break; + + case XmlPullParser.END_DOCUMENT: + throw new RuntimeException("Unexpected end of document"); + } + + eventType = parser.next(); + } + } + + private static class InflatedOnMenuItemClickListener + implements MenuItem.OnMenuItemClickListener { + private static final Class[] PARAM_TYPES = new Class[] { MenuItem.class }; + + private Context mContext; + private Method mMethod; + + public InflatedOnMenuItemClickListener(Context context, String methodName) { + mContext = context; + Class c = context.getClass(); + try { + mMethod = c.getMethod(methodName, PARAM_TYPES); + } catch (Exception e) { + InflateException ex = new InflateException( + "Couldn't resolve menu item onClick handler " + methodName + + " in class " + c.getName()); + ex.initCause(e); + throw ex; + } + } + + public boolean onMenuItemClick(MenuItem item) { + try { + if (mMethod.getReturnType() == Boolean.TYPE) { + return (Boolean) mMethod.invoke(mContext, item); + } else { + mMethod.invoke(mContext, item); + return true; + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + + /** + * State for the current menu. + *

+ * Groups can not be nested unless there is another menu (which will have + * its state class). + */ + private class MenuState { + private Menu menu; + + /* + * Group state is set on items as they are added, allowing an item to + * override its group state. (As opposed to set on items at the group end tag.) + */ + private int groupId; + private int groupCategory; + private int groupOrder; + private int groupCheckable; + private boolean groupVisible; + private boolean groupEnabled; + + private boolean itemAdded; + private int itemId; + private int itemCategoryOrder; + private CharSequence itemTitle; + private CharSequence itemTitleCondensed; + private int itemIconResId; + private char itemAlphabeticShortcut; + private char itemNumericShortcut; + /** + * Sync to attrs.xml enum: + * - 0: none + * - 1: all + * - 2: exclusive + */ + private int itemCheckable; + private boolean itemChecked; + private boolean itemVisible; + private boolean itemEnabled; + + /** + * Sync to attrs.xml enum, values in MenuItem: + * - 0: never + * - 1: ifRoom + * - 2: always + * - -1: Safe sentinel for "no value". + */ + private int itemShowAsAction; + + private int itemActionViewLayout; + private String itemActionViewClassName; + private String itemActionProviderClassName; + + private String itemListenerMethodName; + + private ActionProvider itemActionProvider; + + private static final int defaultGroupId = NO_ID; + private static final int defaultItemId = NO_ID; + private static final int defaultItemCategory = 0; + private static final int defaultItemOrder = 0; + private static final int defaultItemCheckable = 0; + private static final boolean defaultItemChecked = false; + private static final boolean defaultItemVisible = true; + private static final boolean defaultItemEnabled = true; + + public MenuState(final Menu menu) { + this.menu = menu; + + resetGroup(); + } + + public void resetGroup() { + groupId = defaultGroupId; + groupCategory = defaultItemCategory; + groupOrder = defaultItemOrder; + groupCheckable = defaultItemCheckable; + groupVisible = defaultItemVisible; + groupEnabled = defaultItemEnabled; + } + + /** + * Called when the parser is pointing to a group tag. + */ + public void readGroup(AttributeSet attrs) { + TypedArray a = mContext.obtainStyledAttributes(attrs, + R.styleable.SherlockMenuGroup); + + groupId = a.getResourceId(R.styleable.SherlockMenuGroup_android_id, defaultGroupId); + groupCategory = a.getInt(R.styleable.SherlockMenuGroup_android_menuCategory, defaultItemCategory); + groupOrder = a.getInt(R.styleable.SherlockMenuGroup_android_orderInCategory, defaultItemOrder); + groupCheckable = a.getInt(R.styleable.SherlockMenuGroup_android_checkableBehavior, defaultItemCheckable); + groupVisible = a.getBoolean(R.styleable.SherlockMenuGroup_android_visible, defaultItemVisible); + groupEnabled = a.getBoolean(R.styleable.SherlockMenuGroup_android_enabled, defaultItemEnabled); + + a.recycle(); + } + + /** + * Called when the parser is pointing to an item tag. + */ + public void readItem(AttributeSet attrs) { + TypedArray a = mContext.obtainStyledAttributes(attrs, + R.styleable.SherlockMenuItem); + + // Inherit attributes from the group as default value + itemId = a.getResourceId(R.styleable.SherlockMenuItem_android_id, defaultItemId); + final int category = a.getInt(R.styleable.SherlockMenuItem_android_menuCategory, groupCategory); + final int order = a.getInt(R.styleable.SherlockMenuItem_android_orderInCategory, groupOrder); + itemCategoryOrder = (category & Menu.CATEGORY_MASK) | (order & Menu.USER_MASK); + itemTitle = a.getText(R.styleable.SherlockMenuItem_android_title); + itemTitleCondensed = a.getText(R.styleable.SherlockMenuItem_android_titleCondensed); + itemIconResId = a.getResourceId(R.styleable.SherlockMenuItem_android_icon, 0); + itemAlphabeticShortcut = + getShortcut(a.getString(R.styleable.SherlockMenuItem_android_alphabeticShortcut)); + itemNumericShortcut = + getShortcut(a.getString(R.styleable.SherlockMenuItem_android_numericShortcut)); + if (a.hasValue(R.styleable.SherlockMenuItem_android_checkable)) { + // Item has attribute checkable, use it + itemCheckable = a.getBoolean(R.styleable.SherlockMenuItem_android_checkable, false) ? 1 : 0; + } else { + // Item does not have attribute, use the group's (group can have one more state + // for checkable that represents the exclusive checkable) + itemCheckable = groupCheckable; + } + + itemChecked = a.getBoolean(R.styleable.SherlockMenuItem_android_checked, defaultItemChecked); + itemVisible = a.getBoolean(R.styleable.SherlockMenuItem_android_visible, groupVisible); + itemEnabled = a.getBoolean(R.styleable.SherlockMenuItem_android_enabled, groupEnabled); + + TypedValue value = new TypedValue(); + a.getValue(R.styleable.SherlockMenuItem_android_showAsAction, value); + itemShowAsAction = value.type == TypedValue.TYPE_INT_HEX ? value.data : -1; + + itemListenerMethodName = a.getString(R.styleable.SherlockMenuItem_android_onClick); + itemActionViewLayout = a.getResourceId(R.styleable.SherlockMenuItem_android_actionLayout, 0); + itemActionViewClassName = a.getString(R.styleable.SherlockMenuItem_android_actionViewClass); + itemActionProviderClassName = a.getString(R.styleable.SherlockMenuItem_android_actionProviderClass); + + final boolean hasActionProvider = itemActionProviderClassName != null; + if (hasActionProvider && itemActionViewLayout == 0 && itemActionViewClassName == null) { + itemActionProvider = newInstance(itemActionProviderClassName, + ACTION_PROVIDER_CONSTRUCTOR_SIGNATURE, + mActionProviderConstructorArguments); + } else { + if (hasActionProvider) { + Log.w(LOG_TAG, "Ignoring attribute 'actionProviderClass'." + + " Action view already specified."); + } + itemActionProvider = null; + } + + a.recycle(); + + itemAdded = false; + } + + private char getShortcut(String shortcutString) { + if (shortcutString == null) { + return 0; + } else { + return shortcutString.charAt(0); + } + } + + private void setItem(MenuItem item) { + item.setChecked(itemChecked) + .setVisible(itemVisible) + .setEnabled(itemEnabled) + .setCheckable(itemCheckable >= 1) + .setTitleCondensed(itemTitleCondensed) + .setIcon(itemIconResId) + .setAlphabeticShortcut(itemAlphabeticShortcut) + .setNumericShortcut(itemNumericShortcut); + + if (itemShowAsAction >= 0) { + item.setShowAsAction(itemShowAsAction); + } + + if (itemListenerMethodName != null) { + if (mContext.isRestricted()) { + throw new IllegalStateException("The android:onClick attribute cannot " + + "be used within a restricted context"); + } + item.setOnMenuItemClickListener( + new InflatedOnMenuItemClickListener(mContext, itemListenerMethodName)); + } + + if (itemCheckable >= 2) { + if (item instanceof MenuItemImpl) { + MenuItemImpl impl = (MenuItemImpl) item; + impl.setExclusiveCheckable(true); + } else { + menu.setGroupCheckable(groupId, true, true); + } + } + + boolean actionViewSpecified = false; + if (itemActionViewClassName != null) { + View actionView = (View) newInstance(itemActionViewClassName, + ACTION_VIEW_CONSTRUCTOR_SIGNATURE, mActionViewConstructorArguments); + item.setActionView(actionView); + actionViewSpecified = true; + } + if (itemActionViewLayout > 0) { + if (!actionViewSpecified) { + item.setActionView(itemActionViewLayout); + actionViewSpecified = true; + } else { + Log.w(LOG_TAG, "Ignoring attribute 'itemActionViewLayout'." + + " Action view already specified."); + } + } + if (itemActionProvider != null) { + item.setActionProvider(itemActionProvider); + } + } + + public void addItem() { + itemAdded = true; + setItem(menu.add(groupId, itemId, itemCategoryOrder, itemTitle)); + } + + public SubMenu addSubMenuItem() { + itemAdded = true; + SubMenu subMenu = menu.addSubMenu(groupId, itemId, itemCategoryOrder, itemTitle); + setItem(subMenu.getItem()); + return subMenu; + } + + public boolean hasAddedItem() { + return itemAdded; + } + + @SuppressWarnings("unchecked") + private T newInstance(String className, Class[] constructorSignature, + Object[] arguments) { + try { + Class clazz = mContext.getClassLoader().loadClass(className); + Constructor constructor = clazz.getConstructor(constructorSignature); + return (T) constructor.newInstance(arguments); + } catch (Exception e) { + Log.w(LOG_TAG, "Cannot instantiate class: " + className, e); + } + return null; + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/view/MenuItem.java b/actionbarsherlock/src/com/actionbarsherlock/view/MenuItem.java new file mode 100644 index 000000000..7fc3aa430 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/view/MenuItem.java @@ -0,0 +1,598 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.actionbarsherlock.view; + +import android.content.Intent; +import android.graphics.drawable.Drawable; +import android.view.ContextMenu.ContextMenuInfo; +import android.view.View; + +/** + * Interface for direct access to a previously created menu item. + *

+ * An Item is returned by calling one of the {@link android.view.Menu#add} + * methods. + *

+ * For a feature set of specific menu types, see {@link Menu}. + * + *

+ *

Developer Guides

+ *

For information about creating menus, read the + * Menus developer guide.

+ *
+ */ +public interface MenuItem { + /* + * These should be kept in sync with attrs.xml enum constants for showAsAction + */ + /** Never show this item as a button in an Action Bar. */ + public static final int SHOW_AS_ACTION_NEVER = android.view.MenuItem.SHOW_AS_ACTION_NEVER; + /** Show this item as a button in an Action Bar if the system decides there is room for it. */ + public static final int SHOW_AS_ACTION_IF_ROOM = android.view.MenuItem.SHOW_AS_ACTION_IF_ROOM; + /** + * Always show this item as a button in an Action Bar. + * Use sparingly! If too many items are set to always show in the Action Bar it can + * crowd the Action Bar and degrade the user experience on devices with smaller screens. + * A good rule of thumb is to have no more than 2 items set to always show at a time. + */ + public static final int SHOW_AS_ACTION_ALWAYS = android.view.MenuItem.SHOW_AS_ACTION_ALWAYS; + + /** + * When this item is in the action bar, always show it with a text label even if + * it also has an icon specified. + */ + public static final int SHOW_AS_ACTION_WITH_TEXT = android.view.MenuItem.SHOW_AS_ACTION_WITH_TEXT; + + /** + * This item's action view collapses to a normal menu item. + * When expanded, the action view temporarily takes over + * a larger segment of its container. + */ + public static final int SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW = android.view.MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW; + + /** + * Interface definition for a callback to be invoked when a menu item is + * clicked. + * + * @see Activity#onContextItemSelected(MenuItem) + * @see Activity#onOptionsItemSelected(MenuItem) + */ + public interface OnMenuItemClickListener { + /** + * Called when a menu item has been invoked. This is the first code + * that is executed; if it returns true, no other callbacks will be + * executed. + * + * @param item The menu item that was invoked. + * + * @return Return true to consume this click and prevent others from + * executing. + */ + public boolean onMenuItemClick(MenuItem item); + } + + /** + * Interface definition for a callback to be invoked when a menu item + * marked with {@link MenuItem#SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW} is + * expanded or collapsed. + * + * @see MenuItem#expandActionView() + * @see MenuItem#collapseActionView() + * @see MenuItem#setShowAsActionFlags(int) + */ + public interface OnActionExpandListener { + /** + * Called when a menu item with {@link MenuItem#SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW} + * is expanded. + * @param item Item that was expanded + * @return true if the item should expand, false if expansion should be suppressed. + */ + public boolean onMenuItemActionExpand(MenuItem item); + + /** + * Called when a menu item with {@link MenuItem#SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW} + * is collapsed. + * @param item Item that was collapsed + * @return true if the item should collapse, false if collapsing should be suppressed. + */ + public boolean onMenuItemActionCollapse(MenuItem item); + } + + /** + * Return the identifier for this menu item. The identifier can not + * be changed after the menu is created. + * + * @return The menu item's identifier. + */ + public int getItemId(); + + /** + * Return the group identifier that this menu item is part of. The group + * identifier can not be changed after the menu is created. + * + * @return The menu item's group identifier. + */ + public int getGroupId(); + + /** + * Return the category and order within the category of this item. This + * item will be shown before all items (within its category) that have + * order greater than this value. + *

+ * An order integer contains the item's category (the upper bits of the + * integer; set by or/add the category with the order within the + * category) and the ordering of the item within that category (the + * lower bits). Example categories are {@link Menu#CATEGORY_SYSTEM}, + * {@link Menu#CATEGORY_SECONDARY}, {@link Menu#CATEGORY_ALTERNATIVE}, + * {@link Menu#CATEGORY_CONTAINER}. See {@link Menu} for a full list. + * + * @return The order of this item. + */ + public int getOrder(); + + /** + * Change the title associated with this item. + * + * @param title The new text to be displayed. + * @return This Item so additional setters can be called. + */ + public MenuItem setTitle(CharSequence title); + + /** + * Change the title associated with this item. + *

+ * Some menu types do not sufficient space to show the full title, and + * instead a condensed title is preferred. See {@link Menu} for more + * information. + * + * @param title The resource id of the new text to be displayed. + * @return This Item so additional setters can be called. + * @see #setTitleCondensed(CharSequence) + */ + + public MenuItem setTitle(int title); + + /** + * Retrieve the current title of the item. + * + * @return The title. + */ + public CharSequence getTitle(); + + /** + * Change the condensed title associated with this item. The condensed + * title is used in situations where the normal title may be too long to + * be displayed. + * + * @param title The new text to be displayed as the condensed title. + * @return This Item so additional setters can be called. + */ + public MenuItem setTitleCondensed(CharSequence title); + + /** + * Retrieve the current condensed title of the item. If a condensed + * title was never set, it will return the normal title. + * + * @return The condensed title, if it exists. + * Otherwise the normal title. + */ + public CharSequence getTitleCondensed(); + + /** + * Change the icon associated with this item. This icon will not always be + * shown, so the title should be sufficient in describing this item. See + * {@link Menu} for the menu types that support icons. + * + * @param icon The new icon (as a Drawable) to be displayed. + * @return This Item so additional setters can be called. + */ + public MenuItem setIcon(Drawable icon); + + /** + * Change the icon associated with this item. This icon will not always be + * shown, so the title should be sufficient in describing this item. See + * {@link Menu} for the menu types that support icons. + *

+ * This method will set the resource ID of the icon which will be used to + * lazily get the Drawable when this item is being shown. + * + * @param iconRes The new icon (as a resource ID) to be displayed. + * @return This Item so additional setters can be called. + */ + public MenuItem setIcon(int iconRes); + + /** + * Returns the icon for this item as a Drawable (getting it from resources if it hasn't been + * loaded before). + * + * @return The icon as a Drawable. + */ + public Drawable getIcon(); + + /** + * Change the Intent associated with this item. By default there is no + * Intent associated with a menu item. If you set one, and nothing + * else handles the item, then the default behavior will be to call + * {@link android.content.Context#startActivity} with the given Intent. + * + *

Note that setIntent() can not be used with the versions of + * {@link Menu#add} that take a Runnable, because {@link Runnable#run} + * does not return a value so there is no way to tell if it handled the + * item. In this case it is assumed that the Runnable always handles + * the item, and the intent will never be started. + * + * @see #getIntent + * @param intent The Intent to associated with the item. This Intent + * object is not copied, so be careful not to + * modify it later. + * @return This Item so additional setters can be called. + */ + public MenuItem setIntent(Intent intent); + + /** + * Return the Intent associated with this item. This returns a + * reference to the Intent which you can change as desired to modify + * what the Item is holding. + * + * @see #setIntent + * @return Returns the last value supplied to {@link #setIntent}, or + * null. + */ + public Intent getIntent(); + + /** + * Change both the numeric and alphabetic shortcut associated with this + * item. Note that the shortcut will be triggered when the key that + * generates the given character is pressed alone or along with with the alt + * key. Also note that case is not significant and that alphabetic shortcut + * characters will be displayed in lower case. + *

+ * See {@link Menu} for the menu types that support shortcuts. + * + * @param numericChar The numeric shortcut key. This is the shortcut when + * using a numeric (e.g., 12-key) keyboard. + * @param alphaChar The alphabetic shortcut key. This is the shortcut when + * using a keyboard with alphabetic keys. + * @return This Item so additional setters can be called. + */ + public MenuItem setShortcut(char numericChar, char alphaChar); + + /** + * Change the numeric shortcut associated with this item. + *

+ * See {@link Menu} for the menu types that support shortcuts. + * + * @param numericChar The numeric shortcut key. This is the shortcut when + * using a 12-key (numeric) keyboard. + * @return This Item so additional setters can be called. + */ + public MenuItem setNumericShortcut(char numericChar); + + /** + * Return the char for this menu item's numeric (12-key) shortcut. + * + * @return Numeric character to use as a shortcut. + */ + public char getNumericShortcut(); + + /** + * Change the alphabetic shortcut associated with this item. The shortcut + * will be triggered when the key that generates the given character is + * pressed alone or along with with the alt key. Case is not significant and + * shortcut characters will be displayed in lower case. Note that menu items + * with the characters '\b' or '\n' as shortcuts will get triggered by the + * Delete key or Carriage Return key, respectively. + *

+ * See {@link Menu} for the menu types that support shortcuts. + * + * @param alphaChar The alphabetic shortcut key. This is the shortcut when + * using a keyboard with alphabetic keys. + * @return This Item so additional setters can be called. + */ + public MenuItem setAlphabeticShortcut(char alphaChar); + + /** + * Return the char for this menu item's alphabetic shortcut. + * + * @return Alphabetic character to use as a shortcut. + */ + public char getAlphabeticShortcut(); + + /** + * Control whether this item can display a check mark. Setting this does + * not actually display a check mark (see {@link #setChecked} for that); + * rather, it ensures there is room in the item in which to display a + * check mark. + *

+ * See {@link Menu} for the menu types that support check marks. + * + * @param checkable Set to true to allow a check mark, false to + * disallow. The default is false. + * @see #setChecked + * @see #isCheckable + * @see Menu#setGroupCheckable + * @return This Item so additional setters can be called. + */ + public MenuItem setCheckable(boolean checkable); + + /** + * Return whether the item can currently display a check mark. + * + * @return If a check mark can be displayed, returns true. + * + * @see #setCheckable + */ + public boolean isCheckable(); + + /** + * Control whether this item is shown with a check mark. Note that you + * must first have enabled checking with {@link #setCheckable} or else + * the check mark will not appear. If this item is a member of a group that contains + * mutually-exclusive items (set via {@link Menu#setGroupCheckable(int, boolean, boolean)}, + * the other items in the group will be unchecked. + *

+ * See {@link Menu} for the menu types that support check marks. + * + * @see #setCheckable + * @see #isChecked + * @see Menu#setGroupCheckable + * @param checked Set to true to display a check mark, false to hide + * it. The default value is false. + * @return This Item so additional setters can be called. + */ + public MenuItem setChecked(boolean checked); + + /** + * Return whether the item is currently displaying a check mark. + * + * @return If a check mark is displayed, returns true. + * + * @see #setChecked + */ + public boolean isChecked(); + + /** + * Sets the visibility of the menu item. Even if a menu item is not visible, + * it may still be invoked via its shortcut (to completely disable an item, + * set it to invisible and {@link #setEnabled(boolean) disabled}). + * + * @param visible If true then the item will be visible; if false it is + * hidden. + * @return This Item so additional setters can be called. + */ + public MenuItem setVisible(boolean visible); + + /** + * Return the visibility of the menu item. + * + * @return If true the item is visible; else it is hidden. + */ + public boolean isVisible(); + + /** + * Sets whether the menu item is enabled. Disabling a menu item will not + * allow it to be invoked via its shortcut. The menu item will still be + * visible. + * + * @param enabled If true then the item will be invokable; if false it is + * won't be invokable. + * @return This Item so additional setters can be called. + */ + public MenuItem setEnabled(boolean enabled); + + /** + * Return the enabled state of the menu item. + * + * @return If true the item is enabled and hence invokable; else it is not. + */ + public boolean isEnabled(); + + /** + * Check whether this item has an associated sub-menu. I.e. it is a + * sub-menu of another menu. + * + * @return If true this item has a menu; else it is a + * normal item. + */ + public boolean hasSubMenu(); + + /** + * Get the sub-menu to be invoked when this item is selected, if it has + * one. See {@link #hasSubMenu()}. + * + * @return The associated menu if there is one, else null + */ + public SubMenu getSubMenu(); + + /** + * Set a custom listener for invocation of this menu item. In most + * situations, it is more efficient and easier to use + * {@link Activity#onOptionsItemSelected(MenuItem)} or + * {@link Activity#onContextItemSelected(MenuItem)}. + * + * @param menuItemClickListener The object to receive invokations. + * @return This Item so additional setters can be called. + * @see Activity#onOptionsItemSelected(MenuItem) + * @see Activity#onContextItemSelected(MenuItem) + */ + public MenuItem setOnMenuItemClickListener(MenuItem.OnMenuItemClickListener menuItemClickListener); + + /** + * Gets the extra information linked to this menu item. This extra + * information is set by the View that added this menu item to the + * menu. + * + * @see OnCreateContextMenuListener + * @return The extra information linked to the View that added this + * menu item to the menu. This can be null. + */ + public ContextMenuInfo getMenuInfo(); + + /** + * Sets how this item should display in the presence of an Action Bar. + * The parameter actionEnum is a flag set. One of {@link #SHOW_AS_ACTION_ALWAYS}, + * {@link #SHOW_AS_ACTION_IF_ROOM}, or {@link #SHOW_AS_ACTION_NEVER} should + * be used, and you may optionally OR the value with {@link #SHOW_AS_ACTION_WITH_TEXT}. + * SHOW_AS_ACTION_WITH_TEXT requests that when the item is shown as an action, + * it should be shown with a text label. + * + * @param actionEnum How the item should display. One of + * {@link #SHOW_AS_ACTION_ALWAYS}, {@link #SHOW_AS_ACTION_IF_ROOM}, or + * {@link #SHOW_AS_ACTION_NEVER}. SHOW_AS_ACTION_NEVER is the default. + * + * @see android.app.ActionBar + * @see #setActionView(View) + */ + public void setShowAsAction(int actionEnum); + + /** + * Sets how this item should display in the presence of an Action Bar. + * The parameter actionEnum is a flag set. One of {@link #SHOW_AS_ACTION_ALWAYS}, + * {@link #SHOW_AS_ACTION_IF_ROOM}, or {@link #SHOW_AS_ACTION_NEVER} should + * be used, and you may optionally OR the value with {@link #SHOW_AS_ACTION_WITH_TEXT}. + * SHOW_AS_ACTION_WITH_TEXT requests that when the item is shown as an action, + * it should be shown with a text label. + * + *

Note: This method differs from {@link #setShowAsAction(int)} only in that it + * returns the current MenuItem instance for call chaining. + * + * @param actionEnum How the item should display. One of + * {@link #SHOW_AS_ACTION_ALWAYS}, {@link #SHOW_AS_ACTION_IF_ROOM}, or + * {@link #SHOW_AS_ACTION_NEVER}. SHOW_AS_ACTION_NEVER is the default. + * + * @see android.app.ActionBar + * @see #setActionView(View) + * @return This MenuItem instance for call chaining. + */ + public MenuItem setShowAsActionFlags(int actionEnum); + + /** + * Set an action view for this menu item. An action view will be displayed in place + * of an automatically generated menu item element in the UI when this item is shown + * as an action within a parent. + *

+ * Note: Setting an action view overrides the action provider + * set via {@link #setActionProvider(ActionProvider)}. + *

+ * + * @param view View to use for presenting this item to the user. + * @return This Item so additional setters can be called. + * + * @see #setShowAsAction(int) + */ + public MenuItem setActionView(View view); + + /** + * Set an action view for this menu item. An action view will be displayed in place + * of an automatically generated menu item element in the UI when this item is shown + * as an action within a parent. + *

+ * Note: Setting an action view overrides the action provider + * set via {@link #setActionProvider(ActionProvider)}. + *

+ * + * @param resId Layout resource to use for presenting this item to the user. + * @return This Item so additional setters can be called. + * + * @see #setShowAsAction(int) + */ + public MenuItem setActionView(int resId); + + /** + * Returns the currently set action view for this menu item. + * + * @return This item's action view + * + * @see #setActionView(View) + * @see #setShowAsAction(int) + */ + public View getActionView(); + + /** + * Sets the {@link ActionProvider} responsible for creating an action view if + * the item is placed on the action bar. The provider also provides a default + * action invoked if the item is placed in the overflow menu. + *

+ * Note: Setting an action provider overrides the action view + * set via {@link #setActionView(int)} or {@link #setActionView(View)}. + *

+ * + * @param actionProvider The action provider. + * @return This Item so additional setters can be called. + * + * @see ActionProvider + */ + public MenuItem setActionProvider(ActionProvider actionProvider); + + /** + * Gets the {@link ActionProvider}. + * + * @return The action provider. + * + * @see ActionProvider + * @see #setActionProvider(ActionProvider) + */ + public ActionProvider getActionProvider(); + + /** + * Expand the action view associated with this menu item. + * The menu item must have an action view set, as well as + * the showAsAction flag {@link #SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW}. + * If a listener has been set using {@link #setOnActionExpandListener(OnActionExpandListener)} + * it will have its {@link OnActionExpandListener#onMenuItemActionExpand(MenuItem)} + * method invoked. The listener may return false from this method to prevent expanding + * the action view. + * + * @return true if the action view was expanded, false otherwise. + */ + public boolean expandActionView(); + + /** + * Collapse the action view associated with this menu item. + * The menu item must have an action view set, as well as the showAsAction flag + * {@link #SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW}. If a listener has been set using + * {@link #setOnActionExpandListener(OnActionExpandListener)} it will have its + * {@link OnActionExpandListener#onMenuItemActionCollapse(MenuItem)} method invoked. + * The listener may return false from this method to prevent collapsing the action view. + * + * @return true if the action view was collapsed, false otherwise. + */ + public boolean collapseActionView(); + + /** + * Returns true if this menu item's action view has been expanded. + * + * @return true if the item's action view is expanded, false otherwise. + * + * @see #expandActionView() + * @see #collapseActionView() + * @see #SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW + * @see OnActionExpandListener + */ + public boolean isActionViewExpanded(); + + /** + * Set an {@link OnActionExpandListener} on this menu item to be notified when + * the associated action view is expanded or collapsed. The menu item must + * be configured to expand or collapse its action view using the flag + * {@link #SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW}. + * + * @param listener Listener that will respond to expand/collapse events + * @return This menu item instance for call chaining + */ + public MenuItem setOnActionExpandListener(OnActionExpandListener listener); +} \ No newline at end of file diff --git a/actionbarsherlock/src/com/actionbarsherlock/view/SubMenu.java b/actionbarsherlock/src/com/actionbarsherlock/view/SubMenu.java new file mode 100644 index 000000000..397fd1c2d --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/view/SubMenu.java @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2007 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.actionbarsherlock.view; + +import android.graphics.drawable.Drawable; +import android.view.View; + +/** + * Subclass of {@link Menu} for sub menus. + *

+ * Sub menus do not support item icons, or nested sub menus. + * + *

+ *

Developer Guides

+ *

For information about creating menus, read the + * Menus developer guide.

+ *
+ */ + +public interface SubMenu extends Menu { + /** + * Sets the submenu header's title to the title given in titleRes + * resource identifier. + * + * @param titleRes The string resource identifier used for the title. + * @return This SubMenu so additional setters can be called. + */ + public SubMenu setHeaderTitle(int titleRes); + + /** + * Sets the submenu header's title to the title given in title. + * + * @param title The character sequence used for the title. + * @return This SubMenu so additional setters can be called. + */ + public SubMenu setHeaderTitle(CharSequence title); + + /** + * Sets the submenu header's icon to the icon given in iconRes + * resource id. + * + * @param iconRes The resource identifier used for the icon. + * @return This SubMenu so additional setters can be called. + */ + public SubMenu setHeaderIcon(int iconRes); + + /** + * Sets the submenu header's icon to the icon given in icon + * {@link Drawable}. + * + * @param icon The {@link Drawable} used for the icon. + * @return This SubMenu so additional setters can be called. + */ + public SubMenu setHeaderIcon(Drawable icon); + + /** + * Sets the header of the submenu to the {@link View} given in + * view. This replaces the header title and icon (and those + * replace this). + * + * @param view The {@link View} used for the header. + * @return This SubMenu so additional setters can be called. + */ + public SubMenu setHeaderView(View view); + + /** + * Clears the header of the submenu. + */ + public void clearHeader(); + + /** + * Change the icon associated with this submenu's item in its parent menu. + * + * @see MenuItem#setIcon(int) + * @param iconRes The new icon (as a resource ID) to be displayed. + * @return This SubMenu so additional setters can be called. + */ + public SubMenu setIcon(int iconRes); + + /** + * Change the icon associated with this submenu's item in its parent menu. + * + * @see MenuItem#setIcon(Drawable) + * @param icon The new icon (as a Drawable) to be displayed. + * @return This SubMenu so additional setters can be called. + */ + public SubMenu setIcon(Drawable icon); + + /** + * Gets the {@link MenuItem} that represents this submenu in the parent + * menu. Use this for setting additional item attributes. + * + * @return The {@link MenuItem} that launches the submenu when invoked. + */ + public MenuItem getItem(); +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/view/Window.java b/actionbarsherlock/src/com/actionbarsherlock/view/Window.java new file mode 100644 index 000000000..a340a4291 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/view/Window.java @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2006 The Android Open Source Project + * Copyright (C) 2011 Jake Wharton + * + * 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.actionbarsherlock.view; + +import android.content.Context; + +/** + *

Abstract base class for a top-level window look and behavior policy. An + * instance of this class should be used as the top-level view added to the + * window manager. It provides standard UI policies such as a background, title + * area, default key processing, etc.

+ * + *

The only existing implementation of this abstract class is + * android.policy.PhoneWindow, which you should instantiate when needing a + * Window. Eventually that class will be refactored and a factory method added + * for creating Window instances without knowing about a particular + * implementation.

+ */ +public abstract class Window extends android.view.Window { + public static final long FEATURE_ACTION_BAR = android.view.Window.FEATURE_ACTION_BAR; + public static final long FEATURE_ACTION_BAR_OVERLAY = android.view.Window.FEATURE_ACTION_BAR_OVERLAY; + public static final long FEATURE_ACTION_MODE_OVERLAY = android.view.Window.FEATURE_ACTION_MODE_OVERLAY; + public static final long FEATURE_NO_TITLE = android.view.Window.FEATURE_NO_TITLE; + public static final long FEATURE_PROGRESS = android.view.Window.FEATURE_PROGRESS; + public static final long FEATURE_INDETERMINATE_PROGRESS = android.view.Window.FEATURE_INDETERMINATE_PROGRESS; + + /** + * Create a new instance for a context. + * + * @param context Context. + */ + private Window(Context context) { + super(context); + } + + + public interface Callback { + /** + * Called when a panel's menu item has been selected by the user. + * + * @param featureId The panel that the menu is in. + * @param item The menu item that was selected. + * + * @return boolean Return true to finish processing of selection, or + * false to perform the normal menu handling (calling its + * Runnable or sending a Message to its target Handler). + */ + public boolean onMenuItemSelected(int featureId, MenuItem item); + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/widget/ActivityChooserModel.java b/actionbarsherlock/src/com/actionbarsherlock/widget/ActivityChooserModel.java new file mode 100644 index 000000000..379207471 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/widget/ActivityChooserModel.java @@ -0,0 +1,1131 @@ +/* + * Copyright (C) 2011 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.actionbarsherlock.widget; + +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.pm.ResolveInfo; +import android.database.DataSetObservable; +import android.os.Handler; +import android.text.TextUtils; +import android.util.Log; +import android.util.Xml; + +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; +import org.xmlpull.v1.XmlSerializer; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.Executor; + +/** + *

+ * This class represents a data model for choosing a component for handing a + * given {@link Intent}. The model is responsible for querying the system for + * activities that can handle the given intent and order found activities + * based on historical data of previous choices. The historical data is stored + * in an application private file. If a client does not want to have persistent + * choice history the file can be omitted, thus the activities will be ordered + * based on historical usage for the current session. + *

+ *

+ * For each backing history file there is a singleton instance of this class. Thus, + * several clients that specify the same history file will share the same model. Note + * that if multiple clients are sharing the same model they should implement semantically + * equivalent functionality since setting the model intent will change the found + * activities and they may be inconsistent with the functionality of some of the clients. + * For example, choosing a share activity can be implemented by a single backing + * model and two different views for performing the selection. If however, one of the + * views is used for sharing but the other for importing, for example, then each + * view should be backed by a separate model. + *

+ *

+ * The way clients interact with this class is as follows: + *

+ *

+ *

+ * 
+ *  // Get a model and set it to a couple of clients with semantically similar function.
+ *  ActivityChooserModel dataModel =
+ *      ActivityChooserModel.get(context, "task_specific_history_file_name.xml");
+ *
+ *  ActivityChooserModelClient modelClient1 = getActivityChooserModelClient1();
+ *  modelClient1.setActivityChooserModel(dataModel);
+ *
+ *  ActivityChooserModelClient modelClient2 = getActivityChooserModelClient2();
+ *  modelClient2.setActivityChooserModel(dataModel);
+ *
+ *  // Set an intent to choose a an activity for.
+ *  dataModel.setIntent(intent);
+ * 
+ * 
+ * 

+ *

+ * Note: This class is thread safe. + *

+ * + * @hide + */ +class ActivityChooserModel extends DataSetObservable { + + /** + * Client that utilizes an {@link ActivityChooserModel}. + */ + public interface ActivityChooserModelClient { + + /** + * Sets the {@link ActivityChooserModel}. + * + * @param dataModel The model. + */ + public void setActivityChooserModel(ActivityChooserModel dataModel); + } + + /** + * Defines a sorter that is responsible for sorting the activities + * based on the provided historical choices and an intent. + */ + public interface ActivitySorter { + + /** + * Sorts the activities in descending order of relevance + * based on previous history and an intent. + * + * @param intent The {@link Intent}. + * @param activities Activities to be sorted. + * @param historicalRecords Historical records. + */ + // This cannot be done by a simple comparator since an Activity weight + // is computed from history. Note that Activity implements Comparable. + public void sort(Intent intent, List activities, + List historicalRecords); + } + + /** + * Listener for choosing an activity. + */ + public interface OnChooseActivityListener { + + /** + * Called when an activity has been chosen. The client can decide whether + * an activity can be chosen and if so the caller of + * {@link ActivityChooserModel#chooseActivity(int)} will receive and {@link Intent} + * for launching it. + *

+ * Note: Modifying the intent is not permitted and + * any changes to the latter will be ignored. + *

+ * + * @param host The listener's host model. + * @param intent The intent for launching the chosen activity. + * @return Whether the intent is handled and should not be delivered to clients. + * + * @see ActivityChooserModel#chooseActivity(int) + */ + public boolean onChooseActivity(ActivityChooserModel host, Intent intent); + } + + /** + * Flag for selecting debug mode. + */ + private static final boolean DEBUG = false; + + /** + * Tag used for logging. + */ + private static final String LOG_TAG = ActivityChooserModel.class.getSimpleName(); + + /** + * The root tag in the history file. + */ + private static final String TAG_HISTORICAL_RECORDS = "historical-records"; + + /** + * The tag for a record in the history file. + */ + private static final String TAG_HISTORICAL_RECORD = "historical-record"; + + /** + * Attribute for the activity. + */ + private static final String ATTRIBUTE_ACTIVITY = "activity"; + + /** + * Attribute for the choice time. + */ + private static final String ATTRIBUTE_TIME = "time"; + + /** + * Attribute for the choice weight. + */ + private static final String ATTRIBUTE_WEIGHT = "weight"; + + /** + * The default name of the choice history file. + */ + public static final String DEFAULT_HISTORY_FILE_NAME = + "activity_choser_model_history.xml"; + + /** + * The default maximal length of the choice history. + */ + public static final int DEFAULT_HISTORY_MAX_LENGTH = 50; + + /** + * The amount with which to inflate a chosen activity when set as default. + */ + private static final int DEFAULT_ACTIVITY_INFLATION = 5; + + /** + * Default weight for a choice record. + */ + private static final float DEFAULT_HISTORICAL_RECORD_WEIGHT = 1.0f; + + /** + * The extension of the history file. + */ + private static final String HISTORY_FILE_EXTENSION = ".xml"; + + /** + * An invalid item index. + */ + private static final int INVALID_INDEX = -1; + + /** + * Lock to guard the model registry. + */ + private static final Object sRegistryLock = new Object(); + + /** + * This the registry for data models. + */ + private static final Map sDataModelRegistry = + new HashMap(); + + /** + * Lock for synchronizing on this instance. + */ + private final Object mInstanceLock = new Object(); + + /** + * List of activities that can handle the current intent. + */ + private final List mActivites = new ArrayList(); + + /** + * List with historical choice records. + */ + private final List mHistoricalRecords = new ArrayList(); + + /** + * Context for accessing resources. + */ + private final Context mContext; + + /** + * The name of the history file that backs this model. + */ + private final String mHistoryFileName; + + /** + * The intent for which a activity is being chosen. + */ + private Intent mIntent; + + /** + * The sorter for ordering activities based on intent and past choices. + */ + private ActivitySorter mActivitySorter = new DefaultSorter(); + + /** + * The maximal length of the choice history. + */ + private int mHistoryMaxSize = DEFAULT_HISTORY_MAX_LENGTH; + + /** + * Flag whether choice history can be read. In general many clients can + * share the same data model and {@link #readHistoricalData()} may be called + * by arbitrary of them any number of times. Therefore, this class guarantees + * that the very first read succeeds and subsequent reads can be performed + * only after a call to {@link #persistHistoricalData()} followed by change + * of the share records. + */ + private boolean mCanReadHistoricalData = true; + + /** + * Flag whether the choice history was read. This is used to enforce that + * before calling {@link #persistHistoricalData()} a call to + * {@link #persistHistoricalData()} has been made. This aims to avoid a + * scenario in which a choice history file exits, it is not read yet and + * it is overwritten. Note that always all historical records are read in + * full and the file is rewritten. This is necessary since we need to + * purge old records that are outside of the sliding window of past choices. + */ + private boolean mReadShareHistoryCalled = false; + + /** + * Flag whether the choice records have changed. In general many clients can + * share the same data model and {@link #persistHistoricalData()} may be called + * by arbitrary of them any number of times. Therefore, this class guarantees + * that choice history will be persisted only if it has changed. + */ + private boolean mHistoricalRecordsChanged = true; + + /** + * Hander for scheduling work on client tread. + */ + private final Handler mHandler = new Handler(); + + /** + * Policy for controlling how the model handles chosen activities. + */ + private OnChooseActivityListener mActivityChoserModelPolicy; + + /** + * Gets the data model backed by the contents of the provided file with historical data. + * Note that only one data model is backed by a given file, thus multiple calls with + * the same file name will return the same model instance. If no such instance is present + * it is created. + *

+ * Note: To use the default historical data file clients should explicitly + * pass as file name {@link #DEFAULT_HISTORY_FILE_NAME}. If no persistence of the choice + * history is desired clients should pass null for the file name. In such + * case a new model is returned for each invocation. + *

+ * + *

+ * Always use difference historical data files for semantically different actions. + * For example, sharing is different from importing. + *

+ * + * @param context Context for loading resources. + * @param historyFileName File name with choice history, null + * if the model should not be backed by a file. In this case the activities + * will be ordered only by data from the current session. + * + * @return The model. + */ + public static ActivityChooserModel get(Context context, String historyFileName) { + synchronized (sRegistryLock) { + ActivityChooserModel dataModel = sDataModelRegistry.get(historyFileName); + if (dataModel == null) { + dataModel = new ActivityChooserModel(context, historyFileName); + sDataModelRegistry.put(historyFileName, dataModel); + } + dataModel.readHistoricalData(); + return dataModel; + } + } + + /** + * Creates a new instance. + * + * @param context Context for loading resources. + * @param historyFileName The history XML file. + */ + private ActivityChooserModel(Context context, String historyFileName) { + mContext = context.getApplicationContext(); + if (!TextUtils.isEmpty(historyFileName) + && !historyFileName.endsWith(HISTORY_FILE_EXTENSION)) { + mHistoryFileName = historyFileName + HISTORY_FILE_EXTENSION; + } else { + mHistoryFileName = historyFileName; + } + } + + /** + * Sets an intent for which to choose a activity. + *

+ * Note: Clients must set only semantically similar + * intents for each data model. + *

+ * + * @param intent The intent. + */ + public void setIntent(Intent intent) { + synchronized (mInstanceLock) { + if (mIntent == intent) { + return; + } + mIntent = intent; + loadActivitiesLocked(); + } + } + + /** + * Gets the intent for which a activity is being chosen. + * + * @return The intent. + */ + public Intent getIntent() { + synchronized (mInstanceLock) { + return mIntent; + } + } + + /** + * Gets the number of activities that can handle the intent. + * + * @return The activity count. + * + * @see #setIntent(Intent) + */ + public int getActivityCount() { + synchronized (mInstanceLock) { + return mActivites.size(); + } + } + + /** + * Gets an activity at a given index. + * + * @return The activity. + * + * @see ActivityResolveInfo + * @see #setIntent(Intent) + */ + public ResolveInfo getActivity(int index) { + synchronized (mInstanceLock) { + return mActivites.get(index).resolveInfo; + } + } + + /** + * Gets the index of a the given activity. + * + * @param activity The activity index. + * + * @return The index if found, -1 otherwise. + */ + public int getActivityIndex(ResolveInfo activity) { + List activities = mActivites; + final int activityCount = activities.size(); + for (int i = 0; i < activityCount; i++) { + ActivityResolveInfo currentActivity = activities.get(i); + if (currentActivity.resolveInfo == activity) { + return i; + } + } + return INVALID_INDEX; + } + + /** + * Chooses a activity to handle the current intent. This will result in + * adding a historical record for that action and construct intent with + * its component name set such that it can be immediately started by the + * client. + *

+ * Note: By calling this method the client guarantees + * that the returned intent will be started. This intent is returned to + * the client solely to let additional customization before the start. + *

+ * + * @return An {@link Intent} for launching the activity or null if the + * policy has consumed the intent. + * + * @see HistoricalRecord + * @see OnChooseActivityListener + */ + public Intent chooseActivity(int index) { + ActivityResolveInfo chosenActivity = mActivites.get(index); + + ComponentName chosenName = new ComponentName( + chosenActivity.resolveInfo.activityInfo.packageName, + chosenActivity.resolveInfo.activityInfo.name); + + Intent choiceIntent = new Intent(mIntent); + choiceIntent.setComponent(chosenName); + + if (mActivityChoserModelPolicy != null) { + // Do not allow the policy to change the intent. + Intent choiceIntentCopy = new Intent(choiceIntent); + final boolean handled = mActivityChoserModelPolicy.onChooseActivity(this, + choiceIntentCopy); + if (handled) { + return null; + } + } + + HistoricalRecord historicalRecord = new HistoricalRecord(chosenName, + System.currentTimeMillis(), DEFAULT_HISTORICAL_RECORD_WEIGHT); + addHisoricalRecord(historicalRecord); + + return choiceIntent; + } + + /** + * Sets the listener for choosing an activity. + * + * @param listener The listener. + */ + public void setOnChooseActivityListener(OnChooseActivityListener listener) { + mActivityChoserModelPolicy = listener; + } + + /** + * Gets the default activity, The default activity is defined as the one + * with highest rank i.e. the first one in the list of activities that can + * handle the intent. + * + * @return The default activity, null id not activities. + * + * @see #getActivity(int) + */ + public ResolveInfo getDefaultActivity() { + synchronized (mInstanceLock) { + if (!mActivites.isEmpty()) { + return mActivites.get(0).resolveInfo; + } + } + return null; + } + + /** + * Sets the default activity. The default activity is set by adding a + * historical record with weight high enough that this activity will + * become the highest ranked. Such a strategy guarantees that the default + * will eventually change if not used. Also the weight of the record for + * setting a default is inflated with a constant amount to guarantee that + * it will stay as default for awhile. + * + * @param index The index of the activity to set as default. + */ + public void setDefaultActivity(int index) { + ActivityResolveInfo newDefaultActivity = mActivites.get(index); + ActivityResolveInfo oldDefaultActivity = mActivites.get(0); + + final float weight; + if (oldDefaultActivity != null) { + // Add a record with weight enough to boost the chosen at the top. + weight = oldDefaultActivity.weight - newDefaultActivity.weight + + DEFAULT_ACTIVITY_INFLATION; + } else { + weight = DEFAULT_HISTORICAL_RECORD_WEIGHT; + } + + ComponentName defaultName = new ComponentName( + newDefaultActivity.resolveInfo.activityInfo.packageName, + newDefaultActivity.resolveInfo.activityInfo.name); + HistoricalRecord historicalRecord = new HistoricalRecord(defaultName, + System.currentTimeMillis(), weight); + addHisoricalRecord(historicalRecord); + } + + /** + * Reads the history data from the backing file if the latter + * was provided. Calling this method more than once before a call + * to {@link #persistHistoricalData()} has been made has no effect. + *

+ * Note: Historical data is read asynchronously and + * as soon as the reading is completed any registered + * {@link DataSetObserver}s will be notified. Also no historical + * data is read until this method is invoked. + *

+ */ + private void readHistoricalData() { + synchronized (mInstanceLock) { + if (!mCanReadHistoricalData || !mHistoricalRecordsChanged) { + return; + } + mCanReadHistoricalData = false; + mReadShareHistoryCalled = true; + if (!TextUtils.isEmpty(mHistoryFileName)) { + /*AsyncTask.*/SERIAL_EXECUTOR.execute(new HistoryLoader()); + } + } + } + + private static final SerialExecutor SERIAL_EXECUTOR = new SerialExecutor(); + + private static class SerialExecutor implements Executor { + final LinkedList mTasks = new LinkedList(); + Runnable mActive; + + public synchronized void execute(final Runnable r) { + mTasks.offer(new Runnable() { + public void run() { + try { + r.run(); + } finally { + scheduleNext(); + } + } + }); + if (mActive == null) { + scheduleNext(); + } + } + + protected synchronized void scheduleNext() { + if ((mActive = mTasks.poll()) != null) { + mActive.run(); + } + } + } + + /** + * Persists the history data to the backing file if the latter + * was provided. Calling this method before a call to {@link #readHistoricalData()} + * throws an exception. Calling this method more than one without choosing an + * activity has not effect. + * + * @throws IllegalStateException If this method is called before a call to + * {@link #readHistoricalData()}. + */ + private void persistHistoricalData() { + synchronized (mInstanceLock) { + if (!mReadShareHistoryCalled) { + throw new IllegalStateException("No preceding call to #readHistoricalData"); + } + if (!mHistoricalRecordsChanged) { + return; + } + mHistoricalRecordsChanged = false; + mCanReadHistoricalData = true; + if (!TextUtils.isEmpty(mHistoryFileName)) { + /*AsyncTask.*/SERIAL_EXECUTOR.execute(new HistoryPersister()); + } + } + } + + /** + * Sets the sorter for ordering activities based on historical data and an intent. + * + * @param activitySorter The sorter. + * + * @see ActivitySorter + */ + public void setActivitySorter(ActivitySorter activitySorter) { + synchronized (mInstanceLock) { + if (mActivitySorter == activitySorter) { + return; + } + mActivitySorter = activitySorter; + sortActivities(); + } + } + + /** + * Sorts the activities based on history and an intent. If + * a sorter is not specified this a default implementation is used. + * + * @see #setActivitySorter(ActivitySorter) + */ + private void sortActivities() { + synchronized (mInstanceLock) { + if (mActivitySorter != null && !mActivites.isEmpty()) { + mActivitySorter.sort(mIntent, mActivites, + Collections.unmodifiableList(mHistoricalRecords)); + notifyChanged(); + } + } + } + + /** + * Sets the maximal size of the historical data. Defaults to + * {@link #DEFAULT_HISTORY_MAX_LENGTH} + *

+ * Note: Setting this property will immediately + * enforce the specified max history size by dropping enough old + * historical records to enforce the desired size. Thus, any + * records that exceed the history size will be discarded and + * irreversibly lost. + *

+ * + * @param historyMaxSize The max history size. + */ + public void setHistoryMaxSize(int historyMaxSize) { + synchronized (mInstanceLock) { + if (mHistoryMaxSize == historyMaxSize) { + return; + } + mHistoryMaxSize = historyMaxSize; + pruneExcessiveHistoricalRecordsLocked(); + sortActivities(); + } + } + + /** + * Gets the history max size. + * + * @return The history max size. + */ + public int getHistoryMaxSize() { + synchronized (mInstanceLock) { + return mHistoryMaxSize; + } + } + + /** + * Gets the history size. + * + * @return The history size. + */ + public int getHistorySize() { + synchronized (mInstanceLock) { + return mHistoricalRecords.size(); + } + } + + /** + * Adds a historical record. + * + * @param historicalRecord The record to add. + * @return True if the record was added. + */ + private boolean addHisoricalRecord(HistoricalRecord historicalRecord) { + synchronized (mInstanceLock) { + final boolean added = mHistoricalRecords.add(historicalRecord); + if (added) { + mHistoricalRecordsChanged = true; + pruneExcessiveHistoricalRecordsLocked(); + persistHistoricalData(); + sortActivities(); + } + return added; + } + } + + /** + * Prunes older excessive records to guarantee {@link #mHistoryMaxSize}. + */ + private void pruneExcessiveHistoricalRecordsLocked() { + List choiceRecords = mHistoricalRecords; + final int pruneCount = choiceRecords.size() - mHistoryMaxSize; + if (pruneCount <= 0) { + return; + } + mHistoricalRecordsChanged = true; + for (int i = 0; i < pruneCount; i++) { + HistoricalRecord prunedRecord = choiceRecords.remove(0); + if (DEBUG) { + Log.i(LOG_TAG, "Pruned: " + prunedRecord); + } + } + } + + /** + * Loads the activities. + */ + private void loadActivitiesLocked() { + mActivites.clear(); + if (mIntent != null) { + List resolveInfos = + mContext.getPackageManager().queryIntentActivities(mIntent, 0); + final int resolveInfoCount = resolveInfos.size(); + for (int i = 0; i < resolveInfoCount; i++) { + ResolveInfo resolveInfo = resolveInfos.get(i); + mActivites.add(new ActivityResolveInfo(resolveInfo)); + } + sortActivities(); + } else { + notifyChanged(); + } + } + + /** + * Represents a record in the history. + */ + public final static class HistoricalRecord { + + /** + * The activity name. + */ + public final ComponentName activity; + + /** + * The choice time. + */ + public final long time; + + /** + * The record weight. + */ + public final float weight; + + /** + * Creates a new instance. + * + * @param activityName The activity component name flattened to string. + * @param time The time the activity was chosen. + * @param weight The weight of the record. + */ + public HistoricalRecord(String activityName, long time, float weight) { + this(ComponentName.unflattenFromString(activityName), time, weight); + } + + /** + * Creates a new instance. + * + * @param activityName The activity name. + * @param time The time the activity was chosen. + * @param weight The weight of the record. + */ + public HistoricalRecord(ComponentName activityName, long time, float weight) { + this.activity = activityName; + this.time = time; + this.weight = weight; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((activity == null) ? 0 : activity.hashCode()); + result = prime * result + (int) (time ^ (time >>> 32)); + result = prime * result + Float.floatToIntBits(weight); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + HistoricalRecord other = (HistoricalRecord) obj; + if (activity == null) { + if (other.activity != null) { + return false; + } + } else if (!activity.equals(other.activity)) { + return false; + } + if (time != other.time) { + return false; + } + if (Float.floatToIntBits(weight) != Float.floatToIntBits(other.weight)) { + return false; + } + return true; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("["); + builder.append("; activity:").append(activity); + builder.append("; time:").append(time); + builder.append("; weight:").append(new BigDecimal(weight)); + builder.append("]"); + return builder.toString(); + } + } + + /** + * Represents an activity. + */ + public final class ActivityResolveInfo implements Comparable { + + /** + * The {@link ResolveInfo} of the activity. + */ + public final ResolveInfo resolveInfo; + + /** + * Weight of the activity. Useful for sorting. + */ + public float weight; + + /** + * Creates a new instance. + * + * @param resolveInfo activity {@link ResolveInfo}. + */ + public ActivityResolveInfo(ResolveInfo resolveInfo) { + this.resolveInfo = resolveInfo; + } + + @Override + public int hashCode() { + return 31 + Float.floatToIntBits(weight); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + ActivityResolveInfo other = (ActivityResolveInfo) obj; + if (Float.floatToIntBits(weight) != Float.floatToIntBits(other.weight)) { + return false; + } + return true; + } + + public int compareTo(ActivityResolveInfo another) { + return Float.floatToIntBits(another.weight) - Float.floatToIntBits(weight); + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("["); + builder.append("resolveInfo:").append(resolveInfo.toString()); + builder.append("; weight:").append(new BigDecimal(weight)); + builder.append("]"); + return builder.toString(); + } + } + + /** + * Default activity sorter implementation. + */ + private final class DefaultSorter implements ActivitySorter { + private static final float WEIGHT_DECAY_COEFFICIENT = 0.95f; + + private final Map mPackageNameToActivityMap = + new HashMap(); + + public void sort(Intent intent, List activities, + List historicalRecords) { + Map packageNameToActivityMap = + mPackageNameToActivityMap; + packageNameToActivityMap.clear(); + + final int activityCount = activities.size(); + for (int i = 0; i < activityCount; i++) { + ActivityResolveInfo activity = activities.get(i); + activity.weight = 0.0f; + String packageName = activity.resolveInfo.activityInfo.packageName; + packageNameToActivityMap.put(packageName, activity); + } + + final int lastShareIndex = historicalRecords.size() - 1; + float nextRecordWeight = 1; + for (int i = lastShareIndex; i >= 0; i--) { + HistoricalRecord historicalRecord = historicalRecords.get(i); + String packageName = historicalRecord.activity.getPackageName(); + ActivityResolveInfo activity = packageNameToActivityMap.get(packageName); + if (activity != null) { + activity.weight += historicalRecord.weight * nextRecordWeight; + nextRecordWeight = nextRecordWeight * WEIGHT_DECAY_COEFFICIENT; + } + } + + Collections.sort(activities); + + if (DEBUG) { + for (int i = 0; i < activityCount; i++) { + Log.i(LOG_TAG, "Sorted: " + activities.get(i)); + } + } + } + } + + /** + * Command for reading the historical records from a file off the UI thread. + */ + private final class HistoryLoader implements Runnable { + + public void run() { + FileInputStream fis = null; + try { + fis = mContext.openFileInput(mHistoryFileName); + } catch (FileNotFoundException fnfe) { + if (DEBUG) { + Log.i(LOG_TAG, "Could not open historical records file: " + mHistoryFileName); + } + return; + } + try { + XmlPullParser parser = Xml.newPullParser(); + parser.setInput(fis, null); + + int type = XmlPullParser.START_DOCUMENT; + while (type != XmlPullParser.END_DOCUMENT && type != XmlPullParser.START_TAG) { + type = parser.next(); + } + + if (!TAG_HISTORICAL_RECORDS.equals(parser.getName())) { + throw new XmlPullParserException("Share records file does not start with " + + TAG_HISTORICAL_RECORDS + " tag."); + } + + List readRecords = new ArrayList(); + + while (true) { + type = parser.next(); + if (type == XmlPullParser.END_DOCUMENT) { + break; + } + if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { + continue; + } + String nodeName = parser.getName(); + if (!TAG_HISTORICAL_RECORD.equals(nodeName)) { + throw new XmlPullParserException("Share records file not well-formed."); + } + + String activity = parser.getAttributeValue(null, ATTRIBUTE_ACTIVITY); + final long time = + Long.parseLong(parser.getAttributeValue(null, ATTRIBUTE_TIME)); + final float weight = + Float.parseFloat(parser.getAttributeValue(null, ATTRIBUTE_WEIGHT)); + + HistoricalRecord readRecord = new HistoricalRecord(activity, time, + weight); + readRecords.add(readRecord); + + if (DEBUG) { + Log.i(LOG_TAG, "Read " + readRecord.toString()); + } + } + + if (DEBUG) { + Log.i(LOG_TAG, "Read " + readRecords.size() + " historical records."); + } + + synchronized (mInstanceLock) { + Set uniqueShareRecords = + new LinkedHashSet(readRecords); + + // Make sure no duplicates. Example: Read a file with + // one record, add one record, persist the two records, + // add a record, read the persisted records - the + // read two records should not be added again. + List historicalRecords = mHistoricalRecords; + final int historicalRecordsCount = historicalRecords.size(); + for (int i = historicalRecordsCount - 1; i >= 0; i--) { + HistoricalRecord historicalRecord = historicalRecords.get(i); + uniqueShareRecords.add(historicalRecord); + } + + if (historicalRecords.size() == uniqueShareRecords.size()) { + return; + } + + // Make sure the oldest records go to the end. + historicalRecords.clear(); + historicalRecords.addAll(uniqueShareRecords); + + mHistoricalRecordsChanged = true; + + // Do this on the client thread since the client may be on the UI + // thread, wait for data changes which happen during sorting, and + // perform UI modification based on the data change. + mHandler.post(new Runnable() { + public void run() { + pruneExcessiveHistoricalRecordsLocked(); + sortActivities(); + } + }); + } + } catch (XmlPullParserException xppe) { + Log.e(LOG_TAG, "Error reading historical recrod file: " + mHistoryFileName, xppe); + } catch (IOException ioe) { + Log.e(LOG_TAG, "Error reading historical recrod file: " + mHistoryFileName, ioe); + } finally { + if (fis != null) { + try { + fis.close(); + } catch (IOException ioe) { + /* ignore */ + } + } + } + } + } + + /** + * Command for persisting the historical records to a file off the UI thread. + */ + private final class HistoryPersister implements Runnable { + + public void run() { + FileOutputStream fos = null; + List records = null; + + synchronized (mInstanceLock) { + records = new ArrayList(mHistoricalRecords); + } + + try { + fos = mContext.openFileOutput(mHistoryFileName, Context.MODE_PRIVATE); + } catch (FileNotFoundException fnfe) { + Log.e(LOG_TAG, "Error writing historical recrod file: " + mHistoryFileName, fnfe); + return; + } + + XmlSerializer serializer = Xml.newSerializer(); + + try { + serializer.setOutput(fos, null); + serializer.startDocument("UTF-8", true); + serializer.startTag(null, TAG_HISTORICAL_RECORDS); + + final int recordCount = records.size(); + for (int i = 0; i < recordCount; i++) { + HistoricalRecord record = records.remove(0); + serializer.startTag(null, TAG_HISTORICAL_RECORD); + serializer.attribute(null, ATTRIBUTE_ACTIVITY, record.activity.flattenToString()); + serializer.attribute(null, ATTRIBUTE_TIME, String.valueOf(record.time)); + serializer.attribute(null, ATTRIBUTE_WEIGHT, String.valueOf(record.weight)); + serializer.endTag(null, TAG_HISTORICAL_RECORD); + if (DEBUG) { + Log.i(LOG_TAG, "Wrote " + record.toString()); + } + } + + serializer.endTag(null, TAG_HISTORICAL_RECORDS); + serializer.endDocument(); + + if (DEBUG) { + Log.i(LOG_TAG, "Wrote " + recordCount + " historical records."); + } + } catch (IllegalArgumentException iae) { + Log.e(LOG_TAG, "Error writing historical recrod file: " + mHistoryFileName, iae); + } catch (IllegalStateException ise) { + Log.e(LOG_TAG, "Error writing historical recrod file: " + mHistoryFileName, ise); + } catch (IOException ioe) { + Log.e(LOG_TAG, "Error writing historical recrod file: " + mHistoryFileName, ioe); + } finally { + if (fos != null) { + try { + fos.close(); + } catch (IOException e) { + /* ignore */ + } + } + } + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/widget/ActivityChooserView.java b/actionbarsherlock/src/com/actionbarsherlock/widget/ActivityChooserView.java new file mode 100644 index 000000000..da13bc99f --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/widget/ActivityChooserView.java @@ -0,0 +1,818 @@ +/* + * Copyright (C) 2011 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.actionbarsherlock.widget; + +import android.os.Build; +import com.actionbarsherlock.R; +import com.actionbarsherlock.internal.widget.IcsLinearLayout; +import com.actionbarsherlock.internal.widget.IcsListPopupWindow; +import com.actionbarsherlock.view.ActionProvider; +import com.actionbarsherlock.widget.ActivityChooserModel.ActivityChooserModelClient; +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; +import android.content.res.Resources; +import android.content.res.TypedArray; +import android.database.DataSetObserver; +import android.graphics.drawable.Drawable; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewTreeObserver; +import android.view.ViewTreeObserver.OnGlobalLayoutListener; +import android.widget.AdapterView; +import android.widget.BaseAdapter; +import android.widget.FrameLayout; +import android.widget.ImageView; +import android.widget.PopupWindow; +import android.widget.TextView; + +/** + * This class is a view for choosing an activity for handling a given {@link Intent}. + *

+ * The view is composed of two adjacent buttons: + *

    + *
  • + * The left button is an immediate action and allows one click activity choosing. + * Tapping this button immediately executes the intent without requiring any further + * user input. Long press on this button shows a popup for changing the default + * activity. + *
  • + *
  • + * The right button is an overflow action and provides an optimized menu + * of additional activities. Tapping this button shows a popup anchored to this + * view, listing the most frequently used activities. This list is initially + * limited to a small number of items in frequency used order. The last item, + * "Show all..." serves as an affordance to display all available activities. + *
  • + *
+ *

+ * + * @hide + */ +class ActivityChooserView extends ViewGroup implements ActivityChooserModelClient { + + /** + * An adapter for displaying the activities in an {@link AdapterView}. + */ + private final ActivityChooserViewAdapter mAdapter; + + /** + * Implementation of various interfaces to avoid publishing them in the APIs. + */ + private final Callbacks mCallbacks; + + /** + * The content of this view. + */ + private final IcsLinearLayout mActivityChooserContent; + + /** + * Stores the background drawable to allow hiding and latter showing. + */ + private final Drawable mActivityChooserContentBackground; + + /** + * The expand activities action button; + */ + private final FrameLayout mExpandActivityOverflowButton; + + /** + * The image for the expand activities action button; + */ + private final ImageView mExpandActivityOverflowButtonImage; + + /** + * The default activities action button; + */ + private final FrameLayout mDefaultActivityButton; + + /** + * The image for the default activities action button; + */ + private final ImageView mDefaultActivityButtonImage; + + /** + * The maximal width of the list popup. + */ + private final int mListPopupMaxWidth; + + /** + * The ActionProvider hosting this view, if applicable. + */ + ActionProvider mProvider; + + /** + * Observer for the model data. + */ + private final DataSetObserver mModelDataSetOberver = new DataSetObserver() { + + @Override + public void onChanged() { + super.onChanged(); + mAdapter.notifyDataSetChanged(); + } + @Override + public void onInvalidated() { + super.onInvalidated(); + mAdapter.notifyDataSetInvalidated(); + } + }; + + private final OnGlobalLayoutListener mOnGlobalLayoutListener = new OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + if (isShowingPopup()) { + if (!isShown()) { + getListPopupWindow().dismiss(); + } else { + getListPopupWindow().show(); + if (mProvider != null) { + mProvider.subUiVisibilityChanged(true); + } + } + } + } + }; + + /** + * Popup window for showing the activity overflow list. + */ + private IcsListPopupWindow mListPopupWindow; + + /** + * Listener for the dismissal of the popup/alert. + */ + private PopupWindow.OnDismissListener mOnDismissListener; + + /** + * Flag whether a default activity currently being selected. + */ + private boolean mIsSelectingDefaultActivity; + + /** + * The count of activities in the popup. + */ + private int mInitialActivityCount = ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_DEFAULT; + + /** + * Flag whether this view is attached to a window. + */ + private boolean mIsAttachedToWindow; + + /** + * String resource for formatting content description of the default target. + */ + private int mDefaultActionButtonContentDescription; + + private final Context mContext; + + /** + * Create a new instance. + * + * @param context The application environment. + */ + public ActivityChooserView(Context context) { + this(context, null); + } + + /** + * Create a new instance. + * + * @param context The application environment. + * @param attrs A collection of attributes. + */ + public ActivityChooserView(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + /** + * Create a new instance. + * + * @param context The application environment. + * @param attrs A collection of attributes. + * @param defStyle The default style to apply to this view. + */ + public ActivityChooserView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + mContext = context; + + TypedArray attributesArray = context.obtainStyledAttributes(attrs, + R.styleable.SherlockActivityChooserView, defStyle, 0); + + mInitialActivityCount = attributesArray.getInt( + R.styleable.SherlockActivityChooserView_initialActivityCount, + ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_DEFAULT); + + Drawable expandActivityOverflowButtonDrawable = attributesArray.getDrawable( + R.styleable.SherlockActivityChooserView_expandActivityOverflowButtonDrawable); + + attributesArray.recycle(); + + LayoutInflater inflater = LayoutInflater.from(mContext); + inflater.inflate(R.layout.abs__activity_chooser_view, this, true); + + mCallbacks = new Callbacks(); + + mActivityChooserContent = (IcsLinearLayout) findViewById(R.id.abs__activity_chooser_view_content); + mActivityChooserContentBackground = mActivityChooserContent.getBackground(); + + mDefaultActivityButton = (FrameLayout) findViewById(R.id.abs__default_activity_button); + mDefaultActivityButton.setOnClickListener(mCallbacks); + mDefaultActivityButton.setOnLongClickListener(mCallbacks); + mDefaultActivityButtonImage = (ImageView) mDefaultActivityButton.findViewById(R.id.abs__image); + + mExpandActivityOverflowButton = (FrameLayout) findViewById(R.id.abs__expand_activities_button); + mExpandActivityOverflowButton.setOnClickListener(mCallbacks); + mExpandActivityOverflowButtonImage = + (ImageView) mExpandActivityOverflowButton.findViewById(R.id.abs__image); + mExpandActivityOverflowButtonImage.setImageDrawable(expandActivityOverflowButtonDrawable); + + mAdapter = new ActivityChooserViewAdapter(); + mAdapter.registerDataSetObserver(new DataSetObserver() { + @Override + public void onChanged() { + super.onChanged(); + updateAppearance(); + } + }); + + Resources resources = context.getResources(); + mListPopupMaxWidth = Math.max(resources.getDisplayMetrics().widthPixels / 2, + resources.getDimensionPixelSize(R.dimen.abs__config_prefDialogWidth)); + } + + /** + * {@inheritDoc} + */ + public void setActivityChooserModel(ActivityChooserModel dataModel) { + mAdapter.setDataModel(dataModel); + if (isShowingPopup()) { + dismissPopup(); + showPopup(); + } + } + + /** + * Sets the background for the button that expands the activity + * overflow list. + * + * Note: Clients would like to set this drawable + * as a clue about the action the chosen activity will perform. For + * example, if a share activity is to be chosen the drawable should + * give a clue that sharing is to be performed. + * + * @param drawable The drawable. + */ + public void setExpandActivityOverflowButtonDrawable(Drawable drawable) { + mExpandActivityOverflowButtonImage.setImageDrawable(drawable); + } + + /** + * Sets the content description for the button that expands the activity + * overflow list. + * + * description as a clue about the action performed by the button. + * For example, if a share activity is to be chosen the content + * description should be something like "Share with". + * + * @param resourceId The content description resource id. + */ + public void setExpandActivityOverflowButtonContentDescription(int resourceId) { + CharSequence contentDescription = mContext.getString(resourceId); + mExpandActivityOverflowButtonImage.setContentDescription(contentDescription); + } + + /** + * Set the provider hosting this view, if applicable. + * @hide Internal use only + */ + public void setProvider(ActionProvider provider) { + mProvider = provider; + } + + /** + * Shows the popup window with activities. + * + * @return True if the popup was shown, false if already showing. + */ + public boolean showPopup() { + if (isShowingPopup() || !mIsAttachedToWindow) { + return false; + } + mIsSelectingDefaultActivity = false; + showPopupUnchecked(mInitialActivityCount); + return true; + } + + /** + * Shows the popup no matter if it was already showing. + * + * @param maxActivityCount The max number of activities to display. + */ + private void showPopupUnchecked(int maxActivityCount) { + if (mAdapter.getDataModel() == null) { + throw new IllegalStateException("No data model. Did you call #setDataModel?"); + } + + getViewTreeObserver().addOnGlobalLayoutListener(mOnGlobalLayoutListener); + + final boolean defaultActivityButtonShown = + mDefaultActivityButton.getVisibility() == VISIBLE; + + final int activityCount = mAdapter.getActivityCount(); + final int maxActivityCountOffset = defaultActivityButtonShown ? 1 : 0; + if (maxActivityCount != ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED + && activityCount > maxActivityCount + maxActivityCountOffset) { + mAdapter.setShowFooterView(true); + mAdapter.setMaxActivityCount(maxActivityCount - 1); + } else { + mAdapter.setShowFooterView(false); + mAdapter.setMaxActivityCount(maxActivityCount); + } + + IcsListPopupWindow popupWindow = getListPopupWindow(); + if (!popupWindow.isShowing()) { + if (mIsSelectingDefaultActivity || !defaultActivityButtonShown) { + mAdapter.setShowDefaultActivity(true, defaultActivityButtonShown); + } else { + mAdapter.setShowDefaultActivity(false, false); + } + final int contentWidth = Math.min(mAdapter.measureContentWidth(), mListPopupMaxWidth); + popupWindow.setContentWidth(contentWidth); + popupWindow.show(); + if (mProvider != null) { + mProvider.subUiVisibilityChanged(true); + } + popupWindow.getListView().setContentDescription(mContext.getString( + R.string.abs__activitychooserview_choose_application)); + } + } + + /** + * Dismisses the popup window with activities. + * + * @return True if dismissed, false if already dismissed. + */ + public boolean dismissPopup() { + if (isShowingPopup()) { + getListPopupWindow().dismiss(); + ViewTreeObserver viewTreeObserver = getViewTreeObserver(); + if (viewTreeObserver.isAlive()) { + viewTreeObserver.removeGlobalOnLayoutListener(mOnGlobalLayoutListener); + } + } + return true; + } + + /** + * Gets whether the popup window with activities is shown. + * + * @return True if the popup is shown. + */ + public boolean isShowingPopup() { + return getListPopupWindow().isShowing(); + } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + ActivityChooserModel dataModel = mAdapter.getDataModel(); + if (dataModel != null) { + dataModel.registerObserver(mModelDataSetOberver); + } + mIsAttachedToWindow = true; + } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + ActivityChooserModel dataModel = mAdapter.getDataModel(); + if (dataModel != null) { + dataModel.unregisterObserver(mModelDataSetOberver); + } + ViewTreeObserver viewTreeObserver = getViewTreeObserver(); + if (viewTreeObserver.isAlive()) { + viewTreeObserver.removeGlobalOnLayoutListener(mOnGlobalLayoutListener); + } + mIsAttachedToWindow = false; + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + View child = mActivityChooserContent; + // If the default action is not visible we want to be as tall as the + // ActionBar so if this widget is used in the latter it will look as + // a normal action button. + if (mDefaultActivityButton.getVisibility() != VISIBLE) { + heightMeasureSpec = MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(heightMeasureSpec), + MeasureSpec.EXACTLY); + } + measureChild(child, widthMeasureSpec, heightMeasureSpec); + setMeasuredDimension(child.getMeasuredWidth(), child.getMeasuredHeight()); + } + + @Override + protected void onLayout(boolean changed, int left, int top, int right, int bottom) { + mActivityChooserContent.layout(0, 0, right - left, bottom - top); + if (getListPopupWindow().isShowing()) { + showPopupUnchecked(mAdapter.getMaxActivityCount()); + } else { + dismissPopup(); + } + } + + public ActivityChooserModel getDataModel() { + return mAdapter.getDataModel(); + } + + /** + * Sets a listener to receive a callback when the popup is dismissed. + * + * @param listener The listener to be notified. + */ + public void setOnDismissListener(PopupWindow.OnDismissListener listener) { + mOnDismissListener = listener; + } + + /** + * Sets the initial count of items shown in the activities popup + * i.e. the items before the popup is expanded. This is an upper + * bound since it is not guaranteed that such number of intent + * handlers exist. + * + * @param itemCount The initial popup item count. + */ + public void setInitialActivityCount(int itemCount) { + mInitialActivityCount = itemCount; + } + + /** + * Sets a content description of the default action button. This + * resource should be a string taking one formatting argument and + * will be used for formatting the content description of the button + * dynamically as the default target changes. For example, a resource + * pointing to the string "share with %1$s" will result in a content + * description "share with Bluetooth" for the Bluetooth activity. + * + * @param resourceId The resource id. + */ + public void setDefaultActionButtonContentDescription(int resourceId) { + mDefaultActionButtonContentDescription = resourceId; + } + + /** + * Gets the list popup window which is lazily initialized. + * + * @return The popup. + */ + private IcsListPopupWindow getListPopupWindow() { + if (mListPopupWindow == null) { + mListPopupWindow = new IcsListPopupWindow(getContext()); + mListPopupWindow.setAdapter(mAdapter); + mListPopupWindow.setAnchorView(ActivityChooserView.this); + mListPopupWindow.setModal(true); + mListPopupWindow.setOnItemClickListener(mCallbacks); + mListPopupWindow.setOnDismissListener(mCallbacks); + } + return mListPopupWindow; + } + + /** + * Updates the buttons state. + */ + private void updateAppearance() { + // Expand overflow button. + if (mAdapter.getCount() > 0) { + mExpandActivityOverflowButton.setEnabled(true); + } else { + mExpandActivityOverflowButton.setEnabled(false); + } + // Default activity button. + final int activityCount = mAdapter.getActivityCount(); + final int historySize = mAdapter.getHistorySize(); + if (activityCount > 0 && historySize > 0) { + mDefaultActivityButton.setVisibility(VISIBLE); + ResolveInfo activity = mAdapter.getDefaultActivity(); + PackageManager packageManager = mContext.getPackageManager(); + mDefaultActivityButtonImage.setImageDrawable(activity.loadIcon(packageManager)); + if (mDefaultActionButtonContentDescription != 0) { + CharSequence label = activity.loadLabel(packageManager); + String contentDescription = mContext.getString( + mDefaultActionButtonContentDescription, label); + mDefaultActivityButton.setContentDescription(contentDescription); + } + } else { + mDefaultActivityButton.setVisibility(View.GONE); + } + // Activity chooser content. + if (mDefaultActivityButton.getVisibility() == VISIBLE) { + mActivityChooserContent.setBackgroundDrawable(mActivityChooserContentBackground); + } else { + mActivityChooserContent.setBackgroundDrawable(null); + } + } + + /** + * Interface implementation to avoid publishing them in the APIs. + */ + private class Callbacks implements AdapterView.OnItemClickListener, + View.OnClickListener, View.OnLongClickListener, PopupWindow.OnDismissListener { + + // AdapterView#OnItemClickListener + public void onItemClick(AdapterView parent, View view, int position, long id) { + ActivityChooserViewAdapter adapter = (ActivityChooserViewAdapter) parent.getAdapter(); + final int itemViewType = adapter.getItemViewType(position); + switch (itemViewType) { + case ActivityChooserViewAdapter.ITEM_VIEW_TYPE_FOOTER: { + showPopupUnchecked(ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED); + } break; + case ActivityChooserViewAdapter.ITEM_VIEW_TYPE_ACTIVITY: { + dismissPopup(); + if (mIsSelectingDefaultActivity) { + // The item at position zero is the default already. + if (position > 0) { + mAdapter.getDataModel().setDefaultActivity(position); + } + } else { + // If the default target is not shown in the list, the first + // item in the model is default action => adjust index + position = mAdapter.getShowDefaultActivity() ? position : position + 1; + Intent launchIntent = mAdapter.getDataModel().chooseActivity(position); + if (launchIntent != null) { + mContext.startActivity(launchIntent); + } + } + } break; + default: + throw new IllegalArgumentException(); + } + } + + // View.OnClickListener + public void onClick(View view) { + if (view == mDefaultActivityButton) { + dismissPopup(); + ResolveInfo defaultActivity = mAdapter.getDefaultActivity(); + final int index = mAdapter.getDataModel().getActivityIndex(defaultActivity); + Intent launchIntent = mAdapter.getDataModel().chooseActivity(index); + if (launchIntent != null) { + mContext.startActivity(launchIntent); + } + } else if (view == mExpandActivityOverflowButton) { + mIsSelectingDefaultActivity = false; + showPopupUnchecked(mInitialActivityCount); + } else { + throw new IllegalArgumentException(); + } + } + + // OnLongClickListener#onLongClick + @Override + public boolean onLongClick(View view) { + if (view == mDefaultActivityButton) { + if (mAdapter.getCount() > 0) { + mIsSelectingDefaultActivity = true; + showPopupUnchecked(mInitialActivityCount); + } + } else { + throw new IllegalArgumentException(); + } + return true; + } + + // PopUpWindow.OnDismissListener#onDismiss + public void onDismiss() { + notifyOnDismissListener(); + if (mProvider != null) { + mProvider.subUiVisibilityChanged(false); + } + } + + private void notifyOnDismissListener() { + if (mOnDismissListener != null) { + mOnDismissListener.onDismiss(); + } + } + } + + private static class SetActivated { + public static void invoke(View view, boolean activated) { + view.setActivated(activated); + } + } + + private static final boolean IS_HONEYCOMB = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB; + + /** + * Adapter for backing the list of activities shown in the popup. + */ + private class ActivityChooserViewAdapter extends BaseAdapter { + + public static final int MAX_ACTIVITY_COUNT_UNLIMITED = Integer.MAX_VALUE; + + public static final int MAX_ACTIVITY_COUNT_DEFAULT = 4; + + private static final int ITEM_VIEW_TYPE_ACTIVITY = 0; + + private static final int ITEM_VIEW_TYPE_FOOTER = 1; + + private static final int ITEM_VIEW_TYPE_COUNT = 3; + + private ActivityChooserModel mDataModel; + + private int mMaxActivityCount = MAX_ACTIVITY_COUNT_DEFAULT; + + private boolean mShowDefaultActivity; + + private boolean mHighlightDefaultActivity; + + private boolean mShowFooterView; + + public void setDataModel(ActivityChooserModel dataModel) { + ActivityChooserModel oldDataModel = mAdapter.getDataModel(); + if (oldDataModel != null && isShown()) { + oldDataModel.unregisterObserver(mModelDataSetOberver); + } + mDataModel = dataModel; + if (dataModel != null && isShown()) { + dataModel.registerObserver(mModelDataSetOberver); + } + notifyDataSetChanged(); + } + + @Override + public int getItemViewType(int position) { + if (mShowFooterView && position == getCount() - 1) { + return ITEM_VIEW_TYPE_FOOTER; + } else { + return ITEM_VIEW_TYPE_ACTIVITY; + } + } + + @Override + public int getViewTypeCount() { + return ITEM_VIEW_TYPE_COUNT; + } + + public int getCount() { + int count = 0; + int activityCount = mDataModel.getActivityCount(); + if (!mShowDefaultActivity && mDataModel.getDefaultActivity() != null) { + activityCount--; + } + count = Math.min(activityCount, mMaxActivityCount); + if (mShowFooterView) { + count++; + } + return count; + } + + public Object getItem(int position) { + final int itemViewType = getItemViewType(position); + switch (itemViewType) { + case ITEM_VIEW_TYPE_FOOTER: + return null; + case ITEM_VIEW_TYPE_ACTIVITY: + if (!mShowDefaultActivity && mDataModel.getDefaultActivity() != null) { + position++; + } + return mDataModel.getActivity(position); + default: + throw new IllegalArgumentException(); + } + } + + public long getItemId(int position) { + return position; + } + + public View getView(int position, View convertView, ViewGroup parent) { + final int itemViewType = getItemViewType(position); + switch (itemViewType) { + case ITEM_VIEW_TYPE_FOOTER: + if (convertView == null || convertView.getId() != ITEM_VIEW_TYPE_FOOTER) { + convertView = LayoutInflater.from(getContext()).inflate( + R.layout.abs__activity_chooser_view_list_item, parent, false); + convertView.setId(ITEM_VIEW_TYPE_FOOTER); + TextView titleView = (TextView) convertView.findViewById(R.id.abs__title); + titleView.setText(mContext.getString( + R.string.abs__activity_chooser_view_see_all)); + } + return convertView; + case ITEM_VIEW_TYPE_ACTIVITY: + if (convertView == null || convertView.getId() != R.id.abs__list_item) { + convertView = LayoutInflater.from(getContext()).inflate( + R.layout.abs__activity_chooser_view_list_item, parent, false); + } + PackageManager packageManager = mContext.getPackageManager(); + // Set the icon + ImageView iconView = (ImageView) convertView.findViewById(R.id.abs__icon); + ResolveInfo activity = (ResolveInfo) getItem(position); + iconView.setImageDrawable(activity.loadIcon(packageManager)); + // Set the title. + TextView titleView = (TextView) convertView.findViewById(R.id.abs__title); + titleView.setText(activity.loadLabel(packageManager)); + if (IS_HONEYCOMB) { + // Highlight the default. + if (mShowDefaultActivity && position == 0 && mHighlightDefaultActivity) { + SetActivated.invoke(convertView, true); + } else { + SetActivated.invoke(convertView, false); + } + } + return convertView; + default: + throw new IllegalArgumentException(); + } + } + + public int measureContentWidth() { + // The user may have specified some of the target not to be shown but we + // want to measure all of them since after expansion they should fit. + final int oldMaxActivityCount = mMaxActivityCount; + mMaxActivityCount = MAX_ACTIVITY_COUNT_UNLIMITED; + + int contentWidth = 0; + View itemView = null; + + final int widthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); + final int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); + final int count = getCount(); + + for (int i = 0; i < count; i++) { + itemView = getView(i, itemView, null); + itemView.measure(widthMeasureSpec, heightMeasureSpec); + contentWidth = Math.max(contentWidth, itemView.getMeasuredWidth()); + } + + mMaxActivityCount = oldMaxActivityCount; + + return contentWidth; + } + + public void setMaxActivityCount(int maxActivityCount) { + if (mMaxActivityCount != maxActivityCount) { + mMaxActivityCount = maxActivityCount; + notifyDataSetChanged(); + } + } + + public ResolveInfo getDefaultActivity() { + return mDataModel.getDefaultActivity(); + } + + public void setShowFooterView(boolean showFooterView) { + if (mShowFooterView != showFooterView) { + mShowFooterView = showFooterView; + notifyDataSetChanged(); + } + } + + public int getActivityCount() { + return mDataModel.getActivityCount(); + } + + public int getHistorySize() { + return mDataModel.getHistorySize(); + } + + public int getMaxActivityCount() { + return mMaxActivityCount; + } + + public ActivityChooserModel getDataModel() { + return mDataModel; + } + + public void setShowDefaultActivity(boolean showDefaultActivity, + boolean highlightDefaultActivity) { + if (mShowDefaultActivity != showDefaultActivity + || mHighlightDefaultActivity != highlightDefaultActivity) { + mShowDefaultActivity = showDefaultActivity; + mHighlightDefaultActivity = highlightDefaultActivity; + notifyDataSetChanged(); + } + } + + public boolean getShowDefaultActivity() { + return mShowDefaultActivity; + } + } +} diff --git a/actionbarsherlock/src/com/actionbarsherlock/widget/ShareActionProvider.java b/actionbarsherlock/src/com/actionbarsherlock/widget/ShareActionProvider.java new file mode 100644 index 000000000..83e9f0ca9 --- /dev/null +++ b/actionbarsherlock/src/com/actionbarsherlock/widget/ShareActionProvider.java @@ -0,0 +1,316 @@ +/* + * Copyright (C) 2011 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.actionbarsherlock.widget; + +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; +import android.graphics.drawable.Drawable; +import android.util.TypedValue; +import android.view.View; + +import com.actionbarsherlock.R; +import com.actionbarsherlock.view.ActionProvider; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuItem; +import com.actionbarsherlock.view.MenuItem.OnMenuItemClickListener; +import com.actionbarsherlock.view.SubMenu; +import com.actionbarsherlock.widget.ActivityChooserModel.OnChooseActivityListener; + +/** + * This is a provider for a share action. It is responsible for creating views + * that enable data sharing and also to show a sub menu with sharing activities + * if the hosting item is placed on the overflow menu. + *

+ * Here is how to use the action provider with custom backing file in a {@link MenuItem}: + *

+ *

+ *

+ * 
+ *  // In Activity#onCreateOptionsMenu
+ *  public boolean onCreateOptionsMenu(Menu menu) {
+ *      // Get the menu item.
+ *      MenuItem menuItem = menu.findItem(R.id.my_menu_item);
+ *      // Get the provider and hold onto it to set/change the share intent.
+ *      mShareActionProvider = (ShareActionProvider) menuItem.getActionProvider();
+ *      // Set history different from the default before getting the action
+ *      // view since a call to {@link MenuItem#getActionView() MenuItem.getActionView()} calls
+ *      // {@link ActionProvider#onCreateActionView()} which uses the backing file name. Omit this
+ *      // line if using the default share history file is desired.
+ *      mShareActionProvider.setShareHistoryFileName("custom_share_history.xml");
+ *      . . .
+ *  }
+ *
+ *  // Somewhere in the application.
+ *  public void doShare(Intent shareIntent) {
+ *      // When you want to share set the share intent.
+ *      mShareActionProvider.setShareIntent(shareIntent);
+ *  }
+ * 
+ * + *

+ *

+ * Note: While the sample snippet demonstrates how to use this provider + * in the context of a menu item, the use of the provider is not limited to menu items. + *

+ * + * @see ActionProvider + */ +public class ShareActionProvider extends ActionProvider { + + /** + * Listener for the event of selecting a share target. + */ + public interface OnShareTargetSelectedListener { + + /** + * Called when a share target has been selected. The client can + * decide whether to handle the intent or rely on the default + * behavior which is launching it. + *

+ * Note: Modifying the intent is not permitted and + * any changes to the latter will be ignored. + *

+ * + * @param source The source of the notification. + * @param intent The intent for launching the chosen share target. + * @return Whether the client has handled the intent. + */ + public boolean onShareTargetSelected(ShareActionProvider source, Intent intent); + } + + /** + * The default for the maximal number of activities shown in the sub-menu. + */ + private static final int DEFAULT_INITIAL_ACTIVITY_COUNT = 4; + + /** + * The the maximum number activities shown in the sub-menu. + */ + private int mMaxShownActivityCount = DEFAULT_INITIAL_ACTIVITY_COUNT; + + /** + * Listener for handling menu item clicks. + */ + private final ShareMenuItemOnMenuItemClickListener mOnMenuItemClickListener = + new ShareMenuItemOnMenuItemClickListener(); + + /** + * The default name for storing share history. + */ + public static final String DEFAULT_SHARE_HISTORY_FILE_NAME = "share_history.xml"; + + /** + * Context for accessing resources. + */ + private final Context mContext; + + /** + * The name of the file with share history data. + */ + private String mShareHistoryFileName = DEFAULT_SHARE_HISTORY_FILE_NAME; + + private OnShareTargetSelectedListener mOnShareTargetSelectedListener; + + private OnChooseActivityListener mOnChooseActivityListener; + + /** + * Creates a new instance. + * + * @param context Context for accessing resources. + */ + public ShareActionProvider(Context context) { + super(context); + mContext = context; + } + + /** + * Sets a listener to be notified when a share target has been selected. + * The listener can optionally decide to handle the selection and + * not rely on the default behavior which is to launch the activity. + *

+ * Note: If you choose the backing share history file + * you will still be notified in this callback. + *

+ * @param listener The listener. + */ + public void setOnShareTargetSelectedListener(OnShareTargetSelectedListener listener) { + mOnShareTargetSelectedListener = listener; + setActivityChooserPolicyIfNeeded(); + } + + /** + * {@inheritDoc} + */ + @Override + public View onCreateActionView() { + // Create the view and set its data model. + ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName); + ActivityChooserView activityChooserView = new ActivityChooserView(mContext); + activityChooserView.setActivityChooserModel(dataModel); + + // Lookup and set the expand action icon. + TypedValue outTypedValue = new TypedValue(); + mContext.getTheme().resolveAttribute(R.attr.actionModeShareDrawable, outTypedValue, true); + Drawable drawable = mContext.getResources().getDrawable(outTypedValue.resourceId); + activityChooserView.setExpandActivityOverflowButtonDrawable(drawable); + activityChooserView.setProvider(this); + + // Set content description. + activityChooserView.setDefaultActionButtonContentDescription( + R.string.abs__shareactionprovider_share_with_application); + activityChooserView.setExpandActivityOverflowButtonContentDescription( + R.string.abs__shareactionprovider_share_with); + + return activityChooserView; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean hasSubMenu() { + return true; + } + + /** + * {@inheritDoc} + */ + @Override + public void onPrepareSubMenu(SubMenu subMenu) { + // Clear since the order of items may change. + subMenu.clear(); + + ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName); + PackageManager packageManager = mContext.getPackageManager(); + + final int expandedActivityCount = dataModel.getActivityCount(); + final int collapsedActivityCount = Math.min(expandedActivityCount, mMaxShownActivityCount); + + // Populate the sub-menu with a sub set of the activities. + for (int i = 0; i < collapsedActivityCount; i++) { + ResolveInfo activity = dataModel.getActivity(i); + subMenu.add(0, i, i, activity.loadLabel(packageManager)) + .setIcon(activity.loadIcon(packageManager)) + .setOnMenuItemClickListener(mOnMenuItemClickListener); + } + + if (collapsedActivityCount < expandedActivityCount) { + // Add a sub-menu for showing all activities as a list item. + SubMenu expandedSubMenu = subMenu.addSubMenu(Menu.NONE, collapsedActivityCount, + collapsedActivityCount, + mContext.getString(R.string.abs__activity_chooser_view_see_all)); + for (int i = 0; i < expandedActivityCount; i++) { + ResolveInfo activity = dataModel.getActivity(i); + expandedSubMenu.add(0, i, i, activity.loadLabel(packageManager)) + .setIcon(activity.loadIcon(packageManager)) + .setOnMenuItemClickListener(mOnMenuItemClickListener); + } + } + } + + /** + * Sets the file name of a file for persisting the share history which + * history will be used for ordering share targets. This file will be used + * for all view created by {@link #onCreateActionView()}. Defaults to + * {@link #DEFAULT_SHARE_HISTORY_FILE_NAME}. Set to null + * if share history should not be persisted between sessions. + *

+ * Note: The history file name can be set any time, however + * only the action views created by {@link #onCreateActionView()} after setting + * the file name will be backed by the provided file. + *

+ * + * @param shareHistoryFile The share history file name. + */ + public void setShareHistoryFileName(String shareHistoryFile) { + mShareHistoryFileName = shareHistoryFile; + setActivityChooserPolicyIfNeeded(); + } + + /** + * Sets an intent with information about the share action. Here is a + * sample for constructing a share intent: + *

+ *

+     * 
+     *  Intent shareIntent = new Intent(Intent.ACTION_SEND);
+     *  shareIntent.setType("image/*");
+     *  Uri uri = Uri.fromFile(new File(getFilesDir(), "foo.jpg"));
+     *  shareIntent.putExtra(Intent.EXTRA_STREAM, uri.toString());
+     * 
+ * + *

+ * + * @param shareIntent The share intent. + * + * @see Intent#ACTION_SEND + * @see Intent#ACTION_SEND_MULTIPLE + */ + public void setShareIntent(Intent shareIntent) { + ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, + mShareHistoryFileName); + dataModel.setIntent(shareIntent); + } + + /** + * Reusable listener for handling share item clicks. + */ + private class ShareMenuItemOnMenuItemClickListener implements OnMenuItemClickListener { + @Override + public boolean onMenuItemClick(MenuItem item) { + ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, + mShareHistoryFileName); + final int itemId = item.getItemId(); + Intent launchIntent = dataModel.chooseActivity(itemId); + if (launchIntent != null) { + mContext.startActivity(launchIntent); + } + return true; + } + } + + /** + * Set the activity chooser policy of the model backed by the current + * share history file if needed which is if there is a registered callback. + */ + private void setActivityChooserPolicyIfNeeded() { + if (mOnShareTargetSelectedListener == null) { + return; + } + if (mOnChooseActivityListener == null) { + mOnChooseActivityListener = new ShareAcitivityChooserModelPolicy(); + } + ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName); + dataModel.setOnChooseActivityListener(mOnChooseActivityListener); + } + + /** + * Policy that delegates to the {@link OnShareTargetSelectedListener}, if such. + */ + private class ShareAcitivityChooserModelPolicy implements OnChooseActivityListener { + @Override + public boolean onChooseActivity(ActivityChooserModel host, Intent intent) { + if (mOnShareTargetSelectedListener != null) { + return mOnShareTargetSelectedListener.onShareTargetSelected( + ShareActionProvider.this, intent); + } + return false; + } + } +} diff --git a/proguard.flags b/proguard.flags index 66e53673e..15e97434e 100644 --- a/proguard.flags +++ b/proguard.flags @@ -35,3 +35,11 @@ # Disable the warnings of using dynamic method calls in EffectsRecorder -dontnote com.android.camera.EffectsRecorder + +# Required for ActionBarSherlock +-keep class android.support.v4.app.** { *; } +-keep interface android.support.v4.app.** { *; } +-keep class com.actionbarsherlock.** { *; } +-keep interface com.actionbarsherlock.** { *; } +-keepattributes *Annotation* + diff --git a/res/values/styles.xml b/res/values/styles.xml index 9bbee9191..10354a146 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -15,7 +15,7 @@ --> - diff --git a/src/com/android/gallery3d/app/MovieActivity.java b/src/com/android/gallery3d/app/MovieActivity.java index 26ae37e43..bf2486927 100644 --- a/src/com/android/gallery3d/app/MovieActivity.java +++ b/src/com/android/gallery3d/app/MovieActivity.java @@ -17,7 +17,6 @@ package com.android.gallery3d.app; import android.annotation.TargetApi; -import android.app.Activity; import android.content.AsyncQueryHandler; import android.content.ContentResolver; import android.content.Intent; @@ -32,12 +31,14 @@ import android.os.Bundle; import android.provider.MediaStore; import android.provider.OpenableColumns; import android.view.KeyEvent; -import android.view.Menu; -import android.view.MenuItem; import android.view.View; import android.view.Window; import android.view.WindowManager; +import com.actionbarsherlock.app.ActionBar; +import com.actionbarsherlock.app.SherlockActivity; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuItem; import com.android.gallery3d.R; import com.android.gallery3d.actionbar.ActionBarInterface; import com.android.gallery3d.actionbar.ActionBarUtils; @@ -51,7 +52,7 @@ import com.android.gallery3d.common.Utils; * to set the action bar logo so the playback process looks more seamlessly integrated with * the original activity. */ -public class MovieActivity extends Activity { +public class MovieActivity extends SherlockActivity { @SuppressWarnings("unused") private static final String TAG = "MovieActivity"; public static final String KEY_LOGO_BITMAP = "logo-bitmap"; @@ -116,19 +117,17 @@ public class MovieActivity extends Activity { win.setBackgroundDrawable(null); } - @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) private void setActionBarLogoFromIntent(Intent intent) { - if (ApiHelper.HAS_ACTION_BAR_SET_LOGO) { - Bitmap logo = intent.getParcelableExtra(KEY_LOGO_BITMAP); - if (logo != null) { - getActionBar().setLogo(new BitmapDrawable(getResources(), logo)); - } + Bitmap logo = intent.getParcelableExtra(KEY_LOGO_BITMAP); + if (logo != null) { + getSupportActionBar().setLogo( + new BitmapDrawable(getResources(), logo)); } } private void initializeActionBar(Intent intent) { mUri = intent.getData(); - final ActionBarInterface actionBar = ActionBarUtils.getActionBar(this); + final ActionBar actionBar = getSupportActionBar(); setActionBarLogoFromIntent(intent); actionBar.setDisplayOptions(ActionBarInterface.DISPLAY_HOME_AS_UP, ActionBarInterface.DISPLAY_HOME_AS_UP); @@ -168,7 +167,8 @@ public class MovieActivity extends Activity { public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); ActionBarInterface actionBar = ActionBarUtils.getActionBar(this); - boolean result = actionBar.createActionMenu(menu, R.menu.movie); + getSupportMenuInflater().inflate(R.menu.movie, menu); + // Document says EXTRA_STREAM should be a content: Uri // So, we only share the video if it's "content:". if (ContentResolver.SCHEME_CONTENT.equals(mUri.getScheme())) { @@ -178,7 +178,7 @@ public class MovieActivity extends Activity { } else { menu.findItem(R.id.action_share).setVisible(false); } - return result; + return true; } private Intent createShareIntent() { -- GitLab From 4ae9b211fee74f801f003bc9ad716e214de1a4f0 Mon Sep 17 00:00:00 2001 From: Earl Ou Date: Tue, 14 Aug 2012 17:50:08 +0800 Subject: [PATCH 209/763] Re-design ExifParser for some strange Exif header The previous design failed to parser file with strange IFD position. Therefore we need a new design. Change-Id: I9f008a9259df6ef7d9a5022e126d6f25069e3d00 --- src/com/android/gallery3d/exif/ExifData.java | 37 +- .../android/gallery3d/exif/ExifParser.java | 653 +++++++++++++++++- .../android/gallery3d/exif/ExifReader.java | 146 +--- src/com/android/gallery3d/exif/ExifTag.java | 244 ++++++- src/com/android/gallery3d/exif/IfdData.java | 121 ++-- src/com/android/gallery3d/exif/IfdId.java | 26 + src/com/android/gallery3d/exif/IfdParser.java | 170 ----- src/com/android/gallery3d/exif/Rational.java | 2 +- .../gallery3d/exif/ExifParserTest.java | 419 ++++------- .../gallery3d/exif/ExifReaderTest.java | 61 +- .../android/gallery3d/exif/ExifXmlReader.java | 2 +- 11 files changed, 1119 insertions(+), 762 deletions(-) create mode 100644 src/com/android/gallery3d/exif/IfdId.java delete mode 100644 src/com/android/gallery3d/exif/IfdParser.java diff --git a/src/com/android/gallery3d/exif/ExifData.java b/src/com/android/gallery3d/exif/ExifData.java index 2c316f701..712698ef4 100644 --- a/src/com/android/gallery3d/exif/ExifData.java +++ b/src/com/android/gallery3d/exif/ExifData.java @@ -15,22 +15,33 @@ */ package com.android.gallery3d.exif; - - +/** + * This class stores the EXIF header in IFDs according to the JPEG specification. + * It is the result produced by {@link ExifReader}. + * @see ExifReader + * @see IfdData + */ public class ExifData { - public static final int TYPE_IFD_0 = 0; - public static final int TYPE_IFD_EXIF = 1; - public static final int TYPE_IFD_1 = 2; - public static final int TYPE_IFD_GPS = 3; - public static final int TYPE_IFD_INTEROPERABILITY = 4; - - private final IfdData[] mIfdDatas = new IfdData[5]; + private final IfdData[] mIfdDatas = new IfdData[IfdId.TYPE_IFD_COUNT]; - public IfdData getIfdData(int ifdType) { - return mIfdDatas[ifdType]; + /** + * Gets the IFD data of the specified IFD. + * + * @see IfdId#TYPE_IFD_0 + * @see IfdId#TYPE_IFD_1 + * @see IfdId#TYPE_IFD_EXIF + * @see IfdId#TYPE_IFD_GPS + * @see IfdId#TYPE_IFD_INTEROPERABILITY + */ + public IfdData getIfdData(int ifdId) { + return mIfdDatas[ifdId]; } + /** + * Adds IFD data. If IFD data of the same type already exists, + * it will be replaced by the new data. + */ public void addIfdData(IfdData data) { - mIfdDatas[data.getIfdType()] = data; + mIfdDatas[data.getId()] = data; } -} +} \ No newline at end of file diff --git a/src/com/android/gallery3d/exif/ExifParser.java b/src/com/android/gallery3d/exif/ExifParser.java index f536a55f4..4249a7241 100644 --- a/src/com/android/gallery3d/exif/ExifParser.java +++ b/src/com/android/gallery3d/exif/ExifParser.java @@ -21,10 +21,106 @@ import java.io.EOFException; import java.io.IOException; import java.io.InputStream; import java.nio.ByteOrder; +import java.nio.charset.Charset; +import java.util.Map.Entry; +import java.util.TreeMap; +/** + * This class provides a low-level EXIF parsing API. Given a JPEG format InputStream, the caller + * can request which IFD's to read via {@link #parse(InputStream, int)} with given options. + *

+ * Below is an example of getting EXIF data from IFD 0 and EXIF IFD using the parser. + *

+ * void parse() {
+ *     ExifParser parser = ExifParser.parse(mImageInputStream,
+ *             ExifParser.OPTION_IFD_0 | ExifParser.OPTIONS_IFD_EXIF);
+ *     int event = parser.next();
+ *     while (event != ExifParser.EVENT_END) {
+ *         switch (event) {
+ *             case ExifParser.EVENT_START_OF_IFD:
+ *                 break;
+ *             case ExifParser.EVENT_NEW_TAG:
+ *                 ExifTag tag = parser.getTag();
+ *                 if (!tag.hasValue()) {
+ *                     parser.registerForTagValue(tag);
+ *                 } else {
+ *                     processTag(tag);
+ *                 }
+ *                 break;
+ *             case ExifParser.EVENT_VALUE_OF_REGISTERED_TAG:
+ *                 tag = parser.getTag();
+ *                 if (tag.getDataType() != ExifTag.TYPE_UNDEFINED) {
+ *                     processTag(tag);
+ *                 }
+ *                 break;
+ *         }
+ *         event = parser.next();
+ *     }
+ * }
+ *
+ * void processTag(ExifTag tag) {
+ *     // process the tag as you like.
+ * }
+ * 
+ */ public class ExifParser { + /** + * When the parser reaches a new IFD area. Call + * {@link #getCurrentIfd()} to know which IFD we are in. + */ + public static final int EVENT_START_OF_IFD = 0; + /** + * When the parser reaches a new tag. Call {@link #getTag()}to get the + * corresponding tag. + */ + public static final int EVENT_NEW_TAG = 1; + /** + * When the parser reaches the value area of tag that is registered by + * {@link #registerForTagValue(ExifTag)} previously. Call + * {@link #getTag()} to get the corresponding tag. + */ + public static final int EVENT_VALUE_OF_REGISTERED_TAG = 2; - private static final String TAG = "ExifParser"; + /** + * When the parser reaches the compressed image area. + */ + public static final int EVENT_COMPRESSED_IMAGE = 3; + /** + * When the parser reaches the uncompressed image strip. + * Call {@link #getStripIndex()} to get the index of the strip. + * @see #getStripIndex() + * @see #getStripCount() + */ + public static final int EVENT_UNCOMPRESSED_STRIP = 4; + /** + * When there is nothing more to parse. + */ + public static final int EVENT_END = 5; + + /** + * Option bit to request to parse IFD0. + */ + public static final int OPTION_IFD_0 = 1 << 0; + /** + * Option bit to request to parse IFD1. + */ + public static final int OPTION_IFD_1 = 1 << 1; + /** + * Option bit to request to parse Exif-IFD. + */ + public static final int OPTION_IFD_EXIF = 1 << 2; + /** + * Option bit to request to parse GPS-IFD. + */ + public static final int OPTION_IFD_GPS = 1 << 3; + /** + * Option bit to request to parse Interoperability-IFD. + */ + public static final int OPTION_IFD_INTEROPERABILITY = 1 << 4; + /** + * Option bit to request to parse thumbnail. + */ + public static final int OPTION_THUMBNAIL = 1 << 5; private static final short SOI = (short) 0xFFD8; // SOI marker of JPEG private static final short APP1 = (short) 0xFFE1; // APP1 marker of JPEG @@ -38,41 +134,471 @@ public class ExifParser { private static final short BIG_ENDIAN_TAG = (short) 0x4d4d; // "MM" private static final short TIFF_HEADER_TAIL = 0x002A; - public IfdParser parse(InputStream inputStream) throws ExifInvalidFormatException, IOException{ - if (!seekTiffData(inputStream)) { - return null; + private static final int TAG_SIZE = 12; + private static final int OFFSET_SIZE = 2; + + private final TiffInputStream mTiffStream; + private final int mOptions; + private int mIfdStartOffset = 0; + private int mNumOfTagInIfd = 0; + private int mIfdType; + private ExifTag mTag; + private ImageEvent mImageEvent; + private int mStripCount; + private ExifTag mStripSizeTag; + private ExifTag mJpegSizeTag; + private boolean mNeedToParseOffsetsInCurrentIfd; + + private final TreeMap mCorrespondingEvent = new TreeMap(); + + private boolean isIfdRequested(int ifdType) { + switch (ifdType) { + case IfdId.TYPE_IFD_0: + return (mOptions & OPTION_IFD_0) != 0; + case IfdId.TYPE_IFD_1: + return (mOptions & OPTION_IFD_1) != 0; + case IfdId.TYPE_IFD_EXIF: + return (mOptions & OPTION_IFD_EXIF) != 0; + case IfdId.TYPE_IFD_GPS: + return (mOptions & OPTION_IFD_GPS) != 0; + case IfdId.TYPE_IFD_INTEROPERABILITY: + return (mOptions & OPTION_IFD_INTEROPERABILITY) != 0; + } + return false; + } + + private boolean isThumbnailRequested() { + return (mOptions & OPTION_THUMBNAIL) != 0; + } + + private ExifParser(InputStream inputStream, int options) + throws IOException, ExifInvalidFormatException { + seekTiffData(inputStream); + mTiffStream = new TiffInputStream(inputStream); + mOptions = options; + if (mTiffStream.getReadByteCount() == 0) { + parseTiffHeader(); + long offset = mTiffStream.readUnsignedInt(); + registerIfd(IfdId.TYPE_IFD_0, offset); + } + } + + /** + * Parses the the given InputStream with the given options + * @exception IOException + * @exception ExifInvalidFormatException + */ + public static ExifParser parse(InputStream inputStream, int options) + throws IOException, ExifInvalidFormatException { + return new ExifParser(inputStream, options); + } + + /** + * Parses the the given InputStream with default options; that is, every IFD and thumbnaill + * will be parsed. + * @exception IOException + * @exception ExifInvalidFormatException + * @see #parse(InputStream, int) + */ + public static ExifParser parse(InputStream inputStream) + throws IOException, ExifInvalidFormatException { + return new ExifParser(inputStream, OPTION_IFD_0 | OPTION_IFD_1 + | OPTION_IFD_EXIF | OPTION_IFD_GPS | OPTION_IFD_INTEROPERABILITY + | OPTION_THUMBNAIL); + } + + /** + * Moves the parser forward and returns the next parsing event + * + * @exception IOException + * @exception ExifInvalidFormatException + * @see #EVENT_START_OF_IFD + * @see #EVENT_NEW_TAG + * @see #EVENT_VALUE_OF_REGISTERED_TAG + * @see #EVENT_COMPRESSED_IMAGE + * @see #EVENT_UNCOMPRESSED_STRIP + * @see #EVENT_END + */ + public int next() throws IOException, ExifInvalidFormatException { + int offset = mTiffStream.getReadByteCount(); + int endOfTags = mIfdStartOffset + OFFSET_SIZE + TAG_SIZE * mNumOfTagInIfd; + if (offset < endOfTags) { + mTag = readTag(); + if (mNeedToParseOffsetsInCurrentIfd) { + checkOffsetOrImageTag(mTag); + } + return EVENT_NEW_TAG; + } else if (offset == endOfTags) { + long ifdOffset = readUnsignedInt(); + // There is a link to ifd1 at the end of ifd0 + if (mIfdType == IfdId.TYPE_IFD_0) { + if (isIfdRequested(IfdId.TYPE_IFD_1) || isThumbnailRequested()) { + if (ifdOffset != 0) { + registerIfd(IfdId.TYPE_IFD_1, ifdOffset); + } + } + } else { + if (ifdOffset != 0) { + throw new ExifInvalidFormatException("Invalid link to next IFD"); + } + } + } + while(mCorrespondingEvent.size() != 0) { + Entry entry = mCorrespondingEvent.pollFirstEntry(); + Object event = entry.getValue(); + skipTo(entry.getKey()); + if (event instanceof IfdEvent) { + mIfdType = ((IfdEvent) event).ifd; + mNumOfTagInIfd = mTiffStream.readUnsignedShort(); + mIfdStartOffset = entry.getKey(); + mNeedToParseOffsetsInCurrentIfd = needToParseOffsetsInCurrentIfd(); + if (((IfdEvent) event).isRequested) { + return EVENT_START_OF_IFD; + } else { + skipRemainingTagsInCurrentIfd(); + } + } else if (event instanceof ImageEvent) { + mImageEvent = (ImageEvent) event; + return mImageEvent.type; + } else { + ExifTagEvent tagEvent = (ExifTagEvent) event; + mTag = tagEvent.tag; + if (mTag.getDataType() != ExifTag.TYPE_UNDEFINED) { + readFullTagValue(mTag); + checkOffsetOrImageTag(mTag); + } + if (tagEvent.isRequested) { + return EVENT_VALUE_OF_REGISTERED_TAG; + } + } + } + return EVENT_END; + } + + /** + * Skips the tags area of current IFD, if the parser is not in the tag area, nothing will + * happen. + * + * @throws IOException + * @throws ExifInvalidFormatException + */ + public void skipRemainingTagsInCurrentIfd() throws IOException, ExifInvalidFormatException { + int endOfTags = mIfdStartOffset + OFFSET_SIZE + TAG_SIZE * mNumOfTagInIfd; + int offset = mTiffStream.getReadByteCount(); + if (offset > endOfTags) return; + if (mNeedToParseOffsetsInCurrentIfd) { + while (offset < endOfTags) { + mTag = readTag(); + checkOffsetOrImageTag(mTag); + offset += TAG_SIZE; + } + } else { + skipTo(endOfTags); + } + long ifdOffset = readUnsignedInt(); + // For ifd0, there is a link to ifd1 in the end of all tags + if (mIfdType == IfdId.TYPE_IFD_0 + && (isIfdRequested(IfdId.TYPE_IFD_1) || isThumbnailRequested())) { + if (ifdOffset > 0) { + registerIfd(IfdId.TYPE_IFD_1, ifdOffset); + } + } + } + + private boolean needToParseOffsetsInCurrentIfd() { + switch (mIfdType) { + case IfdId.TYPE_IFD_0: + return isIfdRequested(IfdId.TYPE_IFD_EXIF) || isIfdRequested(IfdId.TYPE_IFD_GPS) + || isIfdRequested(IfdId.TYPE_IFD_INTEROPERABILITY); + case IfdId.TYPE_IFD_1: + return isThumbnailRequested(); + case IfdId.TYPE_IFD_EXIF: + // The offset to interoperability IFD is located in Exif IFD + return isIfdRequested(IfdId.TYPE_IFD_INTEROPERABILITY); + default: + return false; + } + } + + /** + * If {@link #next()} return {@link #EVENT_NEW_TAG} or {@link #EVENT_VALUE_OF_REGISTERED_TAG}, + * call this function to get the corresponding tag. + *

+ * + * For {@link #EVENT_NEW_TAG}, the tag may not contain the value if the size of the value is + * greater than 4 bytes. One should call {@link ExifTag#hasValue()} to check if the tag + * contains value. + * If there is no value,call {@link #registerForTagValue(ExifTag)} to have the parser emit + * {@link #EVENT_VALUE_OF_REGISTERED_TAG} when it reaches the area pointed by the offset. + * + *

+ * When {@link #EVENT_VALUE_OF_REGISTERED_TAG} is emitted, the value of the tag will have + * already been read except for tags of undefined type. For tags of undefined type, call + * one of the read methods to get the value. + * + * @see #registerForTagValue(ExifTag) + * @see #read(byte[]) + * @see #read(byte[], int, int) + * @see #readInt() + * @see #readRational() + * @see #readShort() + * @see #readString(int) + * @see #readString(int, Charset) + */ + public ExifTag getTag() { + return mTag; + } + + /** + * Gets number of tags in the current IFD area. + */ + public int getTagCountInCurrentIfd() { + return mNumOfTagInIfd; + } + + /** + * Gets the ID of current IFD. + * + * @see IfdId#TYPE_IFD_0 + * @see IfdId#TYPE_IFD_1 + * @see IfdId#TYPE_IFD_GPS + * @see IfdId#TYPE_IFD_INTEROPERABILITY + * @see IfdId#TYPE_IFD_EXIF + */ + public int getCurrentIfd() { + return mIfdType; + } + + /** + * When receiving {@link #EVENT_UNCOMPRESSED_STRIP}, + * call this function to get the index of this strip. + * @see #getStripCount() + */ + public int getStripIndex() { + return mImageEvent.stripIndex; + } + + /** + * When receiving {@link #EVENT_UNCOMPRESSED_STRIP}, call this function to get the number + * of strip data. + * @see #getStripIndex() + */ + public int getStripCount() { + return mStripCount; + } + + /** + * When receiving {@link #EVENT_UNCOMPRESSED_STRIP}, call this function to get the strip size. + */ + public int getStripSize() { + if (mStripSizeTag == null) return 0; + if (mStripSizeTag.getDataType() == ExifTag.TYPE_UNSIGNED_SHORT) { + return mStripSizeTag.getUnsignedShort(mImageEvent.stripIndex); + } else { + return (int) mStripSizeTag.getUnsignedInt(mImageEvent.stripIndex); } - TiffInputStream tiffStream = new TiffInputStream(inputStream); - parseTiffHeader(tiffStream); - long offset = tiffStream.readUnsignedInt(); - if (offset > Integer.MAX_VALUE) { - throw new ExifInvalidFormatException("Offset value is larger than Integer.MAX_VALUE"); + } + + /** + * When receiving {@link #EVENT_COMPRESSED_IMAGE}, call this function to get the image data + * size. + */ + public int getCompressedImageSize() { + if (mJpegSizeTag == null) return 0; + return (int) mJpegSizeTag.getUnsignedInt(); + } + + private void skipTo(int offset) throws IOException { + mTiffStream.skipTo(offset); + while (!mCorrespondingEvent.isEmpty() && mCorrespondingEvent.firstKey() < offset) { + mCorrespondingEvent.pollFirstEntry(); } - return new IfdParser(tiffStream, (int)offset); } - private void parseTiffHeader(TiffInputStream tiffStream) throws IOException, + /** + * When getting {@link #EVENT_NEW_TAG} in the tag area of IFD, + * the tag may not contain the value if the size of the value is greater than 4 bytes. + * When the value is not available here, call this method so that the parser will emit + * {@link #EVENT_VALUE_OF_REGISTERED_TAG} when it reaches the area where the value is located. + + * @see #EVENT_VALUE_OF_REGISTERED_TAG + */ + public void registerForTagValue(ExifTag tag) { + mCorrespondingEvent.put(tag.getOffset(), new ExifTagEvent(tag, true)); + } + + private void registerIfd(int ifdType, long offset) { + mCorrespondingEvent.put((int) offset, new IfdEvent(ifdType, isIfdRequested(ifdType))); + } + + private void registerCompressedImage(long offset) { + mCorrespondingEvent.put((int) offset, new ImageEvent(EVENT_COMPRESSED_IMAGE)); + } + + private void registerUncompressedStrip(int stripIndex, long offset) { + mCorrespondingEvent.put((int) offset, new ImageEvent(EVENT_UNCOMPRESSED_STRIP + , stripIndex)); + } + + private ExifTag readTag() throws IOException, ExifInvalidFormatException { + short tagId = mTiffStream.readShort(); + short dataFormat = mTiffStream.readShort(); + long numOfComp = mTiffStream.readUnsignedInt(); + if (numOfComp > Integer.MAX_VALUE) { + throw new ExifInvalidFormatException( + "Number of component is larger then Integer.MAX_VALUE"); + } + ExifTag tag = new ExifTag(tagId, dataFormat, (int) numOfComp, mIfdType); + if (tag.getDataSize() > 4) { + long offset = mTiffStream.readUnsignedInt(); + if (offset > Integer.MAX_VALUE) { + throw new ExifInvalidFormatException( + "offset is larger then Integer.MAX_VALUE"); + } + tag.setOffset((int) offset); + } else { + readFullTagValue(tag); + mTiffStream.skip(4 - tag.getDataSize()); + } + return tag; + } + + /** + * Check the tag, if the tag is one of the offset tag that points to the IFD or image the + * caller is interested in, register the IFD or image. + */ + private void checkOffsetOrImageTag(ExifTag tag) { + switch (tag.getTagId()) { + case ExifTag.TIFF_TAG.TAG_EXIF_IFD: + if (isIfdRequested(IfdId.TYPE_IFD_EXIF) + || isIfdRequested(IfdId.TYPE_IFD_INTEROPERABILITY)) { + registerIfd(IfdId.TYPE_IFD_EXIF, tag.getUnsignedInt()); + } + break; + case ExifTag.TIFF_TAG.TAG_GPS_IFD: + if (isIfdRequested(IfdId.TYPE_IFD_GPS)) { + registerIfd(IfdId.TYPE_IFD_GPS, tag.getUnsignedInt()); + } + break; + case ExifTag.EXIF_TAG.TAG_INTEROPERABILITY_IFD: + if (isIfdRequested(IfdId.TYPE_IFD_INTEROPERABILITY)) { + registerIfd(IfdId.TYPE_IFD_INTEROPERABILITY, tag.getUnsignedInt()); + } + break; + case ExifTag.TIFF_TAG.TAG_JPEG_INTERCHANGE_FORMAT: + if (isThumbnailRequested()) { + registerCompressedImage(tag.getUnsignedInt()); + } + break; + case ExifTag.TIFF_TAG.TAG_JPEG_INTERCHANGE_FORMAT_LENGTH: + if (isThumbnailRequested()) { + mJpegSizeTag = tag; + } + break; + case ExifTag.TIFF_TAG.TAG_STRIP_OFFSETS: + if (isThumbnailRequested()) { + if (tag.hasValue()) { + for (int i = 0; i < tag.getComponentCount(); i++) { + if (tag.getDataType() == ExifTag.TYPE_UNSIGNED_SHORT) { + registerUncompressedStrip(i, tag.getUnsignedShort(i)); + } else { + registerUncompressedStrip(i, tag.getUnsignedInt(i)); + } + } + } else { + mCorrespondingEvent.put(tag.getOffset(), new ExifTagEvent(tag, false)); + } + } + break; + case ExifTag.TIFF_TAG.TAG_STRIP_BYTE_COUNTS: + if (isThumbnailRequested()) { + if (tag.hasValue()) { + mStripSizeTag = tag; + } + } + break; + } + } + + private void readFullTagValue(ExifTag tag) throws IOException { + switch(tag.getDataType()) { + case ExifTag.TYPE_UNSIGNED_BYTE: + case ExifTag.TYPE_UNDEFINED: + { + byte buf[] = new byte[tag.getComponentCount()]; + read(buf); + tag.setValue(buf); + } + break; + case ExifTag.TYPE_ASCII: + tag.setValue(readString(tag.getComponentCount())); + break; + case ExifTag.TYPE_UNSIGNED_INT: + { + long value[] = new long[tag.getComponentCount()]; + for (int i = 0, n = value.length; i < n; i++) { + value[i] = readUnsignedInt(); + } + tag.setValue(value); + } + break; + case ExifTag.TYPE_UNSIGNED_RATIONAL: + { + Rational value[] = new Rational[tag.getComponentCount()]; + for (int i = 0, n = value.length; i < n; i++) { + value[i] = readUnsignedRational(); + } + tag.setValue(value); + } + break; + case ExifTag.TYPE_UNSIGNED_SHORT: + { + int value[] = new int[tag.getComponentCount()]; + for (int i = 0, n = value.length; i < n; i++) { + value[i] = readUnsignedShort(); + } + tag.setValue(value); + } + break; + case ExifTag.TYPE_INT: + { + int value[] = new int[tag.getComponentCount()]; + for (int i = 0, n = value.length; i < n; i++) { + value[i] = readInt(); + } + tag.setValue(value); + } + break; + case ExifTag.TYPE_RATIONAL: + { + Rational value[] = new Rational[tag.getComponentCount()]; + for (int i = 0, n = value.length; i < n; i++) { + value[i] = readRational(); + } + tag.setValue(value); + } + break; + } + } + + private void parseTiffHeader() throws IOException, ExifInvalidFormatException { - short byteOrder = tiffStream.readShort(); + short byteOrder = mTiffStream.readShort(); ByteOrder order; if (LITTLE_ENDIAN_TAG == byteOrder) { - tiffStream.setByteOrder(ByteOrder.LITTLE_ENDIAN); + mTiffStream.setByteOrder(ByteOrder.LITTLE_ENDIAN); } else if (BIG_ENDIAN_TAG == byteOrder) { - tiffStream.setByteOrder(ByteOrder.BIG_ENDIAN); + mTiffStream.setByteOrder(ByteOrder.BIG_ENDIAN); } else { throw new ExifInvalidFormatException("Invalid TIFF header"); } - if (tiffStream.readShort() != TIFF_HEADER_TAIL) { + if (mTiffStream.readShort() != TIFF_HEADER_TAIL) { throw new ExifInvalidFormatException("Invalid TIFF header"); } } - /** - * Try to seek the tiff data. If there is no tiff data, return false, else return true and - * the inputstream will be at the start of tiff data - */ - private boolean seekTiffData(InputStream inputStream) throws IOException, + private void seekTiffData(InputStream inputStream) throws IOException, ExifInvalidFormatException { DataInputStream dataStream = new DataInputStream(inputStream); @@ -91,7 +617,7 @@ public class ExifParser { } if (tag != APP1) { - return false; + throw new ExifInvalidFormatException("No APP1 segment"); } // APP1 length, it's not used for us @@ -101,9 +627,90 @@ public class ExifParser { if (dataStream.readInt() != EXIF_HEADER || dataStream.readShort() != EXIF_HEADER_TAIL) { // There is no EXIF data; - return false; + throw new ExifInvalidFormatException("No Exif header in APP1"); + } + } + + public int read(byte[] buffer, int offset, int length) throws IOException { + return mTiffStream.read(buffer, offset, length); + } + + public int read(byte[] buffer) throws IOException { + return mTiffStream.read(buffer); + } + + public String readString(int n) throws IOException { + if (n > 0) { + byte[] buf = new byte[n]; + mTiffStream.readOrThrow(buf); + return new String(buf, 0, n - 1, "UTF8"); + } else { + return ""; + } + } + + public String readString(int n, Charset charset) throws IOException { + byte[] buf = new byte[n]; + mTiffStream.readOrThrow(buf); + return new String(buf, 0, n - 1, charset); + } + + public int readUnsignedShort() throws IOException { + return readShort() & 0xffff; + } + + public long readUnsignedInt() throws IOException { + return readInt() & 0xffffffffL; + } + + public Rational readUnsignedRational() throws IOException { + long nomi = readUnsignedInt(); + long denomi = readUnsignedInt(); + return new Rational(nomi, denomi); + } + + public int readInt() throws IOException { + return mTiffStream.readInt(); + } + + public short readShort() throws IOException { + return mTiffStream.readShort(); + } + + public Rational readRational() throws IOException { + int nomi = readInt(); + int denomi = readInt(); + return new Rational(nomi, denomi); + } + + private static class ImageEvent { + int stripIndex; + int type; + ImageEvent(int type) { + this.stripIndex = 0; + this.type = type; } + ImageEvent(int type, int stripIndex) { + this.type = type; + this.stripIndex = stripIndex; + } + } - return true; + private static class IfdEvent { + int ifd; + boolean isRequested; + IfdEvent(int ifd, boolean isInterestedIfd) { + this.ifd = ifd; + this.isRequested = isInterestedIfd; + } + } + + private static class ExifTagEvent { + ExifTag tag; + boolean isRequested; + ExifTagEvent(ExifTag tag, boolean isRequireByUser) { + this.tag = tag; + this.isRequested = isRequireByUser; + } } } \ No newline at end of file diff --git a/src/com/android/gallery3d/exif/ExifReader.java b/src/com/android/gallery3d/exif/ExifReader.java index f406cb739..125b6c65e 100644 --- a/src/com/android/gallery3d/exif/ExifReader.java +++ b/src/com/android/gallery3d/exif/ExifReader.java @@ -19,132 +19,46 @@ package com.android.gallery3d.exif; import java.io.IOException; import java.io.InputStream; +/** + * This class reads the EXIF header of a JPEG file and stores it in {@link ExifData}. + */ public class ExifReader { - + /** + * Parse the inputStream and return all Exif data. + * @throws ExifInvalidFormatException + * @throws IOException + */ public ExifData getExifData(InputStream inputStream) throws ExifInvalidFormatException, IOException { - ExifParser parser = new ExifParser(); - IfdParser ifdParser = parser.parse(inputStream); + ExifParser parser = ExifParser.parse(inputStream); ExifData exifData = new ExifData(); - IfdData ifdData = new IfdData(ExifData.TYPE_IFD_0); - parseIfd(ifdParser, ifdData, exifData); - exifData.addIfdData(ifdData); - return exifData; - } - public void parseIfd(IfdParser ifdParser, IfdData ifdData, ExifData exifData) - throws IOException, ExifInvalidFormatException { - int type = ifdParser.next(); - while (type != IfdParser.TYPE_END) { - switch (type) { - case IfdParser.TYPE_NEW_TAG: - ExifTag tag = ifdParser.readTag(); - if (tag.getDataSize() > 4) { - long offset = ifdParser.readUnsignedInt(); - ifdParser.waitValueOfTag(tag, offset); - } else if (tag.getTagId() == ExifTag.TIFF_TAG.TAG_EXIF_IFD - || tag.getTagId() == ExifTag.TIFF_TAG.TAG_GPS_IFD - || tag.getTagId() == ExifTag.EXIF_TAG.TAG_INTEROPERABILITY_IFD) { - long offset = ifdParser.readUnsignedInt(); - ifdParser.waitValueOfTag(tag, offset); - ifdData.addTag(tag, offset); + int event = parser.next(); + while (event != ExifParser.EVENT_END) { + switch (event) { + case ExifParser.EVENT_START_OF_IFD: + exifData.addIfdData(new IfdData(parser.getCurrentIfd())); + break; + case ExifParser.EVENT_NEW_TAG: + ExifTag tag = parser.getTag(); + if (!tag.hasValue()) { + parser.registerForTagValue(tag); } else { - readAndSaveTag(tag, ifdParser, ifdData); + exifData.getIfdData(tag.getIfd()).setTag(tag); } break; - case IfdParser.TYPE_NEXT_IFD: - IfdData ifd1 = new IfdData(ExifData.TYPE_IFD_1); - parseIfd(ifdParser.parseIfdBlock(), ifd1, exifData); - exifData.addIfdData(ifd1); - break; - case IfdParser.TYPE_VALUE_OF_PREV_TAG: - tag = ifdParser.getCorrespodingExifTag(); - if(tag.getTagId() == ExifTag.TIFF_TAG.TAG_EXIF_IFD) { - IfdData ifd = new IfdData(ExifData.TYPE_IFD_EXIF); - parseIfd(ifdParser.parseIfdBlock(), ifd, exifData); - exifData.addIfdData(ifd); - } else if(tag.getTagId() == ExifTag.TIFF_TAG.TAG_GPS_IFD) { - IfdData ifd = new IfdData(ExifData.TYPE_IFD_GPS); - parseIfd(ifdParser.parseIfdBlock(), ifd, exifData); - exifData.addIfdData(ifd); - } else if(tag.getTagId() == ExifTag.EXIF_TAG.TAG_INTEROPERABILITY_IFD) { - IfdData ifd = new IfdData(ExifData.TYPE_IFD_INTEROPERABILITY); - parseIfd(ifdParser.parseIfdBlock(), ifd, exifData); - exifData.addIfdData(ifd); - } else { - readAndSaveTag(tag, ifdParser, ifdData); + case ExifParser.EVENT_VALUE_OF_REGISTERED_TAG: + tag = parser.getTag(); + if (tag.getDataType() == ExifTag.TYPE_UNDEFINED) { + byte[] buf = new byte[tag.getComponentCount()]; + parser.read(buf); + tag.setValue(buf); } + exifData.getIfdData(tag.getIfd()).setTag(tag); break; } - type = ifdParser.next(); - } - } - - public void readAndSaveTag(ExifTag tag, IfdParser parser, IfdData ifdData) - throws IOException { - switch(tag.getDataType()) { - case ExifTag.TYPE_BYTE: - { - byte buf[] = new byte[tag.getComponentCount()]; - parser.read(buf); - ifdData.addTag(tag, buf); - break; - } - case ExifTag.TYPE_ASCII: - ifdData.addTag(tag, parser.readString(tag.getComponentCount())); - break; - case ExifTag.TYPE_INT: - { - long value[] = new long[tag.getComponentCount()]; - for (int i = 0, n = value.length; i < n; i++) { - value[i] = parser.readUnsignedInt(); - } - ifdData.addTag(tag, value); - break; - } - case ExifTag.TYPE_RATIONAL: - { - Rational value[] = new Rational[tag.getComponentCount()]; - for (int i = 0, n = value.length; i < n; i++) { - value[i] = parser.readUnsignedRational(); - } - ifdData.addTag(tag, value); - break; - } - case ExifTag.TYPE_SHORT: - { - int value[] = new int[tag.getComponentCount()]; - for (int i = 0, n = value.length; i < n; i++) { - value[i] = parser.readUnsignedShort(); - } - ifdData.addTag(tag, value); - break; - } - case ExifTag.TYPE_SINT: - { - int value[] = new int[tag.getComponentCount()]; - for (int i = 0, n = value.length; i < n; i++) { - value[i] = parser.readInt(); - } - ifdData.addTag(tag, value); - break; - } - case ExifTag.TYPE_SRATIONAL: - { - Rational value[] = new Rational[tag.getComponentCount()]; - for (int i = 0, n = value.length; i < n; i++) { - value[i] = parser.readRational(); - } - ifdData.addTag(tag, value); - break; - } - case ExifTag.TYPE_UNDEFINED: - { - byte buf[] = new byte[tag.getComponentCount()]; - parser.read(buf); - ifdData.addTag(tag, buf); - break; - } + event = parser.next(); } + return exifData; } -} +} \ No newline at end of file diff --git a/src/com/android/gallery3d/exif/ExifTag.java b/src/com/android/gallery3d/exif/ExifTag.java index c11171c79..7b5a2eb6b 100644 --- a/src/com/android/gallery3d/exif/ExifTag.java +++ b/src/com/android/gallery3d/exif/ExifTag.java @@ -16,6 +16,15 @@ package com.android.gallery3d.exif; +import java.lang.reflect.Array; + +/** + * This class stores information of an EXIF tag. + * @see ExifParser + * @see ExifReader + * @see IfdData + * @see ExifData + */ public class ExifTag { public static interface TIFF_TAG { public static final short TAG_IMAGE_WIDTH = 0x100; @@ -315,54 +324,259 @@ public class ExifTag { public static final short INTEROPERABILITY_INDEX = 1; } - public static final short TYPE_BYTE = 1; + public static final short TYPE_UNSIGNED_BYTE = 1; public static final short TYPE_ASCII = 2; - public static final short TYPE_SHORT = 3; - public static final short TYPE_INT = 4; - public static final short TYPE_RATIONAL = 5; + public static final short TYPE_UNSIGNED_SHORT = 3; + public static final short TYPE_UNSIGNED_INT = 4; + public static final short TYPE_UNSIGNED_RATIONAL = 5; public static final short TYPE_UNDEFINED = 7; - public static final short TYPE_SINT = 9; - public static final short TYPE_SRATIONAL = 10; + public static final short TYPE_INT = 9; + public static final short TYPE_RATIONAL = 10; private static final int TYPE_TO_SIZE_MAP[] = new int[11]; static { - TYPE_TO_SIZE_MAP[TYPE_BYTE] = 1; + TYPE_TO_SIZE_MAP[TYPE_UNSIGNED_BYTE] = 1; TYPE_TO_SIZE_MAP[TYPE_ASCII] = 1; - TYPE_TO_SIZE_MAP[TYPE_SHORT] = 2; + TYPE_TO_SIZE_MAP[TYPE_UNSIGNED_SHORT] = 2; + TYPE_TO_SIZE_MAP[TYPE_UNSIGNED_INT] = 4; + TYPE_TO_SIZE_MAP[TYPE_UNSIGNED_RATIONAL] = 8; + TYPE_TO_SIZE_MAP[TYPE_UNDEFINED] = 1; TYPE_TO_SIZE_MAP[TYPE_INT] = 4; TYPE_TO_SIZE_MAP[TYPE_RATIONAL] = 8; - TYPE_TO_SIZE_MAP[TYPE_UNDEFINED] = 1; - TYPE_TO_SIZE_MAP[TYPE_SINT] = 4; - TYPE_TO_SIZE_MAP[TYPE_SRATIONAL] = 8; } + /** + * Gets the element size of the given data type. + * + * @see #TYPE_ASCII + * @see #TYPE_INT + * @see #TYPE_RATIONAL + * @see #TYPE_UNDEFINED + * @see #TYPE_UNSIGNED_BYTE + * @see #TYPE_UNSIGNED_INT + * @see #TYPE_UNSIGNED_RATIONAL + * @see #TYPE_UNSIGNED_SHORT + */ public static int getElementSize(short type) { return TYPE_TO_SIZE_MAP[type]; } private final short mTagId; private final short mDataType; - private final int mDataCount; + private final int mComponentCount; + private final int mIfd; + private Object mValue; + private int mOffset; - ExifTag(short tagId, short type, int dataCount) { + ExifTag(short tagId, short type, int componentCount, int ifd) { mTagId = tagId; mDataType = type; - mDataCount = dataCount; + mComponentCount = componentCount; + mIfd = ifd; } + /** + * Returns the ID of the IFD this tag belongs to. + * + * @see IfdId#TYPE_IFD_0 + * @see IfdId#TYPE_IFD_1 + * @see IfdId#TYPE_IFD_EXIF + * @see IfdId#TYPE_IFD_GPS + * @see IfdId#TYPE_IFD_INTEROPERABILITY + */ + public int getIfd() { + return mIfd; + } + + /** + * Gets the ID of this tag. + */ public short getTagId() { return mTagId; } + /** + * Gets the data type of this tag + * + * @see #TYPE_ASCII + * @see #TYPE_INT + * @see #TYPE_RATIONAL + * @see #TYPE_UNDEFINED + * @see #TYPE_UNSIGNED_BYTE + * @see #TYPE_UNSIGNED_INT + * @see #TYPE_UNSIGNED_RATIONAL + * @see #TYPE_UNSIGNED_SHORT + */ public short getDataType() { return mDataType; } + /** + * Gets the total data size in bytes of the value of this tag. + */ public int getDataSize() { return getComponentCount() * getElementSize(getDataType()); } + /** + * Gets the component count of this tag. + */ public int getComponentCount() { - return mDataCount; + return mComponentCount; + } + + /** + * Returns true if this ExifTag contains value; otherwise, this tag will contain an offset value + * that links to the area where the actual value is located. + * + * @see #getOffset() + */ + public boolean hasValue() { + return mValue != null; + } + + /** + * Gets the offset of this tag. This is only valid if this data size > 4 and contains an offset + * to the location of the actual value. + */ + public int getOffset() { + return mOffset; + } + + /** + * Sets the offset of this tag. + */ + void setOffset(int offset) { + mOffset = offset; + } + + /** + * Sets the value of this tag. This is useful when we want to modify the tags and write it back + * to the JPEG file + */ + public void setValue(Object object) { + if (object.getClass().isArray()) { + assert(mComponentCount == Array.getLength(object)); + mValue = object; + } else if (object instanceof String) { + assert(mComponentCount == ((String) object).length() + 1); + mValue = object; + } else { + // Wrap object with an array because user may try to get object by get method with + // index 0 when size = 1 + // e.g. getShort(0) + assert(mComponentCount == 1); + Object array = Array.newInstance(object.getClass(), 1); + Array.set(array, 0, object); + mValue = array; + } + } + + public short getShort(int index) { + return (Short) Array.get(mValue, index); + } + + public short getShort() { + return (Short) Array.get(mValue, 0); + } + + public int getUnsignedShort(int index) { + return (Integer) Array.get(mValue, index); + } + + public int getUnsignedShort() { + return (Integer) Array.get(mValue, 0); + } + + public int getInt(int index) { + return (Integer) Array.get(mValue, index); + } + + public int getInt() { + return (Integer) Array.get(mValue, 0); + } + + public long getUnsignedInt(int index) { + return (Long) Array.get(mValue, index); + } + + public long getUnsignedInt() { + return (Long) Array.get(mValue, 0); + } + + public String getString() { + return (String) mValue; + } + + public Rational getRational(int index) { + return ((Rational[]) mValue)[index]; + } + + public Rational getRational() { + return ((Rational[]) mValue)[0]; + } + + public int getBytes(byte[] buf) { + return getBytes(buf, 0, buf.length); + } + + public int getBytes(byte[] buf, int offset, int length) { + byte[] data = (byte[]) mValue; + if (data.length < length + offset) { + System.arraycopy(data, offset, buf, 0, data.length - offset); + return data.length - offset; + } else { + System.arraycopy(data, offset, buf, 0, length); + return length; + } + } + + /** + * Returns a string representation of the value of this tag. + */ + public String valueToString() { + StringBuilder sbuilder = new StringBuilder(); + switch(getDataType()) { + case ExifTag.TYPE_UNDEFINED: + case ExifTag.TYPE_UNSIGNED_BYTE: + byte buf[] = new byte[getComponentCount()]; + getBytes(buf); + for(int i = 0; i < getComponentCount(); i++) { + if(i != 0) sbuilder.append(" "); + sbuilder.append(String.format("%02x", buf[i])); + } + break; + case ExifTag.TYPE_ASCII: + // trim the string for comparison between xml + sbuilder.append(getString().trim()); + break; + case ExifTag.TYPE_UNSIGNED_INT: + for(int i = 0; i < getComponentCount(); i++) { + if(i != 0) sbuilder.append(" "); + sbuilder.append(getUnsignedInt(i)); + } + break; + case ExifTag.TYPE_RATIONAL: + case ExifTag.TYPE_UNSIGNED_RATIONAL: + for(int i = 0; i < getComponentCount(); i++) { + Rational r = getRational(i); + if(i != 0) sbuilder.append(" "); + sbuilder.append(r.getNominator()).append("/").append(r.getDenominator()); + } + break; + case ExifTag.TYPE_UNSIGNED_SHORT: + for(int i = 0; i < getComponentCount(); i++) { + if(i != 0) sbuilder.append(" "); + sbuilder.append(getUnsignedShort(i)); + } + break; + case ExifTag.TYPE_INT: + for(int i = 0; i < getComponentCount(); i++) { + if(i != 0) sbuilder.append(" "); + sbuilder.append(getInt(i)); + } + break; + } + return sbuilder.toString(); } } \ No newline at end of file diff --git a/src/com/android/gallery3d/exif/IfdData.java b/src/com/android/gallery3d/exif/IfdData.java index b0d063023..4747c3cce 100644 --- a/src/com/android/gallery3d/exif/IfdData.java +++ b/src/com/android/gallery3d/exif/IfdData.java @@ -16,99 +16,64 @@ package com.android.gallery3d.exif; -import java.lang.reflect.Array; import java.util.HashMap; import java.util.Map; +/** + * This class stores all the tags in an IFD. + * + * @see ExifData + * @see ExifTag + */ public class IfdData { - private final int mIfdType; + private final int mIfdId; private final Map mExifTags = new HashMap(); - private final Map mValues = new HashMap(); - - public IfdData(int ifdType) { - mIfdType = ifdType; - } + /** + * Creates an IfdData with given IFD ID. + * + * @see IfdId#TYPE_IFD_0 + * @see IfdId#TYPE_IFD_1 + * @see IfdId#TYPE_IFD_EXIF + * @see IfdId#TYPE_IFD_GPS + * @see IfdId#TYPE_IFD_INTEROPERABILITY + */ + public IfdData(int ifdId) { + mIfdId = ifdId; + } + + /** + * Get a array the contains all {@link ExifTag} in this IFD. + */ public ExifTag[] getAllTags(ExifTag[] outTag) { return mExifTags.values().toArray(outTag); } - public int getIfdType() { - return mIfdType; + /** + * Gets the ID of this IFD. + * + * @see IfdId#TYPE_IFD_0 + * @see IfdId#TYPE_IFD_1 + * @see IfdId#TYPE_IFD_EXIF + * @see IfdId#TYPE_IFD_GPS + * @see IfdId#TYPE_IFD_INTEROPERABILITY + */ + public int getId() { + return mIfdId; } + /** + * Gets the {@link ExifTag} with given tag id. Return null if there is no such tag. + */ public ExifTag getTag(short tagId) { return mExifTags.get(tagId); } - public short getShort(short tagId, int index) { - return (Short) Array.get(mValues.get(tagId), index); - } - - public short getShort(short tagId) { - return (Short) Array.get(mValues.get(tagId), 0); - } - - public int getUnsignedShort(short tagId, int index) { - return (Integer) Array.get(mValues.get(tagId), index); - } - - public int getUnsignedShort(short tagId) { - return (Integer) Array.get(mValues.get(tagId), 0); - } - - public int getInt(short tagId, int index) { - return (Integer) Array.get(mValues.get(tagId), index); - } - - public int getInt(short tagId) { - return (Integer) Array.get(mValues.get(tagId), 0); - } - - public long getUnsignedInt(short tagId, int index) { - return (Long) Array.get(mValues.get(tagId), index); - } - - public long getUnsignedInt(short tagId) { - return (Long) Array.get(mValues.get(tagId), 0); - } - - public String getString(short tagId) { - return (String) mValues.get(tagId); - } - - public Rational getRational(short tagId, int index) { - return ((Rational[]) mValues.get(tagId))[index]; - } - - public Rational getRational(short tagId) { - return ((Rational[]) mValues.get(tagId))[0]; - } - - public int getBytes(short tagId, byte[] buf) { - return getBytes(tagId, buf, 0, buf.length); - } - - public int getBytes(short tagId, byte[] buf, int offset, int length) { - Object data = mValues.get(tagId); - if (Array.getLength(data) < length + offset) { - System.arraycopy(data, offset, buf, 0, Array.getLength(data) - offset); - return Array.getLength(data) - offset; - } else { - System.arraycopy(data, offset, buf, 0, length); - return length; - } - } - - public void addTag(ExifTag tag, Object object) { - mExifTags.put(tag.getTagId(), tag); - if (object.getClass().isArray() || object.getClass() == String.class) { - mValues.put(tag.getTagId(), object); - } else { - Object array = Array.newInstance(object.getClass(), 1); - Array.set(array, 0, object); - mValues.put(tag.getTagId(), array); - } + /** + * Adds or replaces a {@link ExifTag}. + */ + public void setTag(ExifTag tag) { + mExifTags.put(tag.getTagId(), tag); } -} +} \ No newline at end of file diff --git a/src/com/android/gallery3d/exif/IfdId.java b/src/com/android/gallery3d/exif/IfdId.java new file mode 100644 index 000000000..1b9634369 --- /dev/null +++ b/src/com/android/gallery3d/exif/IfdId.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2012 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.android.gallery3d.exif; + +public interface IfdId { + public static final int TYPE_IFD_0 = 0; + public static final int TYPE_IFD_1 = 1; + public static final int TYPE_IFD_EXIF = 2; + public static final int TYPE_IFD_INTEROPERABILITY = 3; + public static final int TYPE_IFD_GPS = 4; + /* This is use in ExifData to allocate enough IfdData */ + static final int TYPE_IFD_COUNT = 5; +} diff --git a/src/com/android/gallery3d/exif/IfdParser.java b/src/com/android/gallery3d/exif/IfdParser.java deleted file mode 100644 index 0d1059cb0..000000000 --- a/src/com/android/gallery3d/exif/IfdParser.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (C) 2012 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.android.gallery3d.exif; - -import java.io.IOException; -import java.nio.charset.Charset; -import java.util.Map.Entry; -import java.util.TreeMap; - -public class IfdParser { - - private static final int TAG_SIZE = 12; - - private final TiffInputStream mTiffStream; - private final int mEndOfTagOffset; - private final int mNumOfTag; - private int mNextOffset; - private int mOffsetToNextIfd = 0; - - private TreeMap mCorrespondingTag = new TreeMap(); - - private ExifTag mCurrTag; - private int mCurrTagOffset; - - public static final int TYPE_NEW_TAG = 0; - public static final int TYPE_VALUE_OF_PREV_TAG = 1; - public static final int TYPE_NEXT_IFD = 2; - public static final int TYPE_END = 3; - - IfdParser(TiffInputStream tiffStream, int offset) throws IOException { - mTiffStream = tiffStream; - mTiffStream.skipTo(offset); - mNumOfTag = mTiffStream.readUnsignedShort(); - mEndOfTagOffset = offset + mNumOfTag * TAG_SIZE + 2; - mNextOffset = offset + 2; - } - - public int next() throws IOException { - int offset = mTiffStream.getReadByteCount(); - if (offset < mEndOfTagOffset) { - offset = mNextOffset; - skipTo(mNextOffset); - - if(mNextOffset < mEndOfTagOffset) { - mNextOffset += TAG_SIZE; - return TYPE_NEW_TAG; - } - } - - if (offset == mEndOfTagOffset) { - mOffsetToNextIfd = mTiffStream.readInt(); - } - - if (!mCorrespondingTag.isEmpty()) { - Entry entry = mCorrespondingTag.pollFirstEntry(); - mCurrTag = entry.getValue(); - mCurrTagOffset = entry.getKey(); - skipTo(entry.getKey()); - return TYPE_VALUE_OF_PREV_TAG; - } else { - if (offset <= mOffsetToNextIfd) { - skipTo(mOffsetToNextIfd); - // Reset mOffsetToNextIfd to 0 so next call to next() will point to the end - mOffsetToNextIfd = 0; - return TYPE_NEXT_IFD; - } else { - return TYPE_END; - } - } - } - - public ExifTag readTag() throws IOException, ExifInvalidFormatException { - short tagId = mTiffStream.readShort(); - short dataFormat = mTiffStream.readShort(); - long numOfComp = mTiffStream.readUnsignedInt(); - if (numOfComp > Integer.MAX_VALUE) { - throw new ExifInvalidFormatException( - "Number of component is larger then Integer.MAX_VALUE"); - } - return new ExifTag(tagId, dataFormat, (int) numOfComp); - } - - public ExifTag getCorrespodingExifTag() { - return mCurrTagOffset != mTiffStream.getReadByteCount() ? null : mCurrTag; - } - - public void waitValueOfTag(ExifTag tag, long offset) { - if (offset > Integer.MAX_VALUE || offset < 0) { - throw new IllegalArgumentException(offset + " must be in 0 ~ " + Integer.MAX_VALUE); - } - mCorrespondingTag.put((int) offset, tag); - } - - public void skipTo(int offset) throws IOException { - mTiffStream.skipTo(offset); - while (!mCorrespondingTag.isEmpty() && mCorrespondingTag.firstKey() < offset) { - mCorrespondingTag.pollFirstEntry(); - } - } - - public IfdParser parseIfdBlock() throws IOException { - return new IfdParser(mTiffStream, mTiffStream.getReadByteCount()); - } - - public int read(byte[] buffer, int offset, int length) throws IOException { - return mTiffStream.read(buffer, offset, length); - } - - public int read(byte[] buffer) throws IOException { - return mTiffStream.read(buffer); - } - - public String readString(int n) throws IOException { - if (n > 0) { - byte[] buf = new byte[n]; - mTiffStream.readOrThrow(buf); - return new String(buf, 0, n - 1, "UTF8"); - } else { - return ""; - } - } - - public String readString(int n, Charset charset) throws IOException { - byte[] buf = new byte[n]; - mTiffStream.readOrThrow(buf); - return new String(buf, 0, n - 1, charset); - } - - public int readUnsignedShort() throws IOException { - return readShort() & 0xffff; - } - - public long readUnsignedInt() throws IOException { - return readInt() & 0xffffffffL; - } - - public Rational readUnsignedRational() throws IOException { - long nomi = readUnsignedInt(); - long denomi = readUnsignedInt(); - return new Rational(nomi, denomi); - } - - public int readInt() throws IOException { - return mTiffStream.readInt(); - } - - public short readShort() throws IOException { - return mTiffStream.readShort(); - } - - public Rational readRational() throws IOException { - int nomi = readInt(); - int denomi = readInt(); - return new Rational(nomi, denomi); - } -} \ No newline at end of file diff --git a/src/com/android/gallery3d/exif/Rational.java b/src/com/android/gallery3d/exif/Rational.java index cef6c9112..4c3c77ffb 100644 --- a/src/com/android/gallery3d/exif/Rational.java +++ b/src/com/android/gallery3d/exif/Rational.java @@ -33,4 +33,4 @@ public class Rational { public long getDenominator() { return mDenominator; } -} +} \ No newline at end of file diff --git a/tests/src/com/android/gallery3d/exif/ExifParserTest.java b/tests/src/com/android/gallery3d/exif/ExifParserTest.java index 86ef12fa7..241aaf575 100644 --- a/tests/src/com/android/gallery3d/exif/ExifParserTest.java +++ b/tests/src/com/android/gallery3d/exif/ExifParserTest.java @@ -20,7 +20,6 @@ import android.content.res.XmlResourceParser; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.test.InstrumentationTestCase; -import android.util.Log; import java.io.IOException; import java.io.InputStream; @@ -58,338 +57,176 @@ public class ExifParserTest extends InstrumentationTestCase { } public void testParse() throws IOException, ExifInvalidFormatException { - ExifParser parser = new ExifParser(); - parseIfd0(parser.parse(mImageInputStream)); - } - - private void parseIfd0(IfdParser ifdParser) throws IOException, - ExifInvalidFormatException { - int type = ifdParser.next(); - int tagNumber=0; - boolean isEnterNextIfd = false; - boolean isEnterExifIfd = false; - while (type != IfdParser.TYPE_END) { - switch (type) { - case IfdParser.TYPE_NEW_TAG: - ExifTag tag = ifdParser.readTag(); - if (tag.getDataSize() > 4 || tag.getTagId() == ExifTag.TIFF_TAG.TAG_EXIF_IFD) { - long offset = ifdParser.readUnsignedInt(); - assertTrue(offset <= Integer.MAX_VALUE); - ifdParser.waitValueOfTag(tag, offset); + ExifParser parser = ExifParser.parse(mImageInputStream); + int event = parser.next(); + while (event != ExifParser.EVENT_END) { + switch (event) { + case ExifParser.EVENT_START_OF_IFD: + break; + case ExifParser.EVENT_NEW_TAG: + ExifTag tag = parser.getTag(); + if (!tag.hasValue()) { + parser.registerForTagValue(tag); } else { - checkTag(tag, ifdParser, mIfd0Value); + checkTag(tag); } - tagNumber++; break; - case IfdParser.TYPE_NEXT_IFD: - parseIfd1(ifdParser.parseIfdBlock()); - isEnterNextIfd = true; - break; - case IfdParser.TYPE_VALUE_OF_PREV_TAG: - tag = ifdParser.getCorrespodingExifTag(); - if(tag.getTagId() == ExifTag.TIFF_TAG.TAG_EXIF_IFD) { - parseExifIfd(ifdParser.parseIfdBlock()); - isEnterExifIfd = true; - } else { - checkTag(ifdParser.getCorrespodingExifTag(), ifdParser, mIfd0Value); + case ExifParser.EVENT_VALUE_OF_REGISTERED_TAG: + tag = parser.getTag(); + if (tag.getDataType() == ExifTag.TYPE_UNDEFINED) { + byte[] buf = new byte[tag.getComponentCount()]; + parser.read(buf); + tag.setValue(buf); } + checkTag(tag); break; } - type = ifdParser.next(); + event = parser.next(); } - assertEquals(mIfd0Value.size(), tagNumber); - assertTrue(isEnterNextIfd); - assertTrue(isEnterExifIfd); } - private void parseIfd1(IfdParser ifdParser) throws IOException, - ExifInvalidFormatException { - int type = ifdParser.next(); - int tagNumber = 0; - while (type != IfdParser.TYPE_END) { - switch (type) { - case IfdParser.TYPE_NEW_TAG: - ExifTag tag = ifdParser.readTag(); - if (tag.getDataSize() > 4) { - long offset = ifdParser.readUnsignedInt(); - assertTrue(offset <= Integer.MAX_VALUE); - ifdParser.waitValueOfTag(tag, offset); - } else { - checkTag(tag, ifdParser, mIfd1Value); - } - tagNumber++; - break; - case IfdParser.TYPE_NEXT_IFD: - fail("Find a ifd after ifd1"); - break; - case IfdParser.TYPE_VALUE_OF_PREV_TAG: - checkTag(ifdParser.getCorrespodingExifTag(), ifdParser, mIfd1Value); - break; - } - type = ifdParser.next(); + private void checkTag(ExifTag tag) { + HashMap truth = null; + switch (tag.getIfd()) { + case IfdId.TYPE_IFD_0: + truth = mIfd0Value; + break; + case IfdId.TYPE_IFD_1: + truth = mIfd1Value; + break; + case IfdId.TYPE_IFD_EXIF: + truth = mExifIfdValue; + break; + case IfdId.TYPE_IFD_INTEROPERABILITY: + truth = mInteroperabilityIfdValue; + break; } - assertEquals(mIfd1Value.size(), tagNumber); - } - private void parseExifIfd(IfdParser ifdParser) throws IOException, - ExifInvalidFormatException { - int type = ifdParser.next(); - int tagNumber = 0; - boolean isHasInterIfd = false; - boolean isEnterInterIfd = false; - while (type != IfdParser.TYPE_END) { - switch (type) { - case IfdParser.TYPE_NEW_TAG: - ExifTag tag = ifdParser.readTag(); - if (tag.getDataSize() > 4) { - long offset = ifdParser.readUnsignedInt(); - assertTrue(offset <= Integer.MAX_VALUE); - ifdParser.waitValueOfTag(tag, offset); - } else if (tag.getTagId() == ExifTag.EXIF_TAG.TAG_INTEROPERABILITY_IFD) { - long offset = ifdParser.readUnsignedInt(); - assertTrue(offset <= Integer.MAX_VALUE); - ifdParser.waitValueOfTag(tag, offset); - isHasInterIfd = true; - } else { - checkTag(tag, ifdParser, mExifIfdValue); - } - tagNumber++; - break; - case IfdParser.TYPE_NEXT_IFD: - fail("Find a ifd after exif ifd"); - break; - case IfdParser.TYPE_VALUE_OF_PREV_TAG: - tag = ifdParser.getCorrespodingExifTag(); - if (tag.getTagId() == ExifTag.EXIF_TAG.TAG_INTEROPERABILITY_IFD) { - parseInteroperabilityIfd(ifdParser.parseIfdBlock()); - isEnterInterIfd = true; - } else { - checkTag(ifdParser.getCorrespodingExifTag(), ifdParser, mExifIfdValue); - } - break; - } - type = ifdParser.next(); - } - assertEquals(mExifIfdValue.size(), tagNumber); - if (isHasInterIfd) { - assertTrue(isEnterInterIfd); + String truthString = truth.get(tag.getTagId()); + String dataString = tag.valueToString(); + if (truthString == null) { + fail(String.format("Unknown Tag %02x", tag.getTagId())); } + assertEquals(String.format("Tag %02x", tag.getTagId()), truthString, dataString); } - private void parseInteroperabilityIfd(IfdParser ifdParser) throws IOException, - ExifInvalidFormatException { - int type = ifdParser.next(); - int tagNumber = 0; - while (type != IfdParser.TYPE_END) { - switch (type) { - case IfdParser.TYPE_NEW_TAG: - ExifTag tag = ifdParser.readTag(); - if (tag.getDataSize() > 4) { - long offset = ifdParser.readUnsignedInt(); - assertTrue(offset <= Integer.MAX_VALUE); - ifdParser.waitValueOfTag(tag, offset); + + private void parseOneIfd(int ifd, int options, HashMap expectedResult) + throws IOException, ExifInvalidFormatException { + int numOfTag = 0; + ExifParser parser = ExifParser.parse(mImageInputStream, options); + int event = parser.next(); + while(event != ExifParser.EVENT_END) { + switch (event) { + case ExifParser.EVENT_START_OF_IFD: + assertEquals(ifd, parser.getCurrentIfd()); + break; + case ExifParser.EVENT_NEW_TAG: + numOfTag++; + ExifTag tag = parser.getTag(); + if (tag.hasValue()) { + checkTag(tag); } else { - checkTag(tag, ifdParser, mInteroperabilityIfdValue); + parser.registerForTagValue(tag); } - tagNumber++; break; - case IfdParser.TYPE_NEXT_IFD: - fail("Find a ifd after exif ifd"); + case ExifParser.EVENT_VALUE_OF_REGISTERED_TAG: + tag = parser.getTag(); + if (tag.getDataType() == ExifTag.TYPE_UNDEFINED) { + byte[] buf = new byte[tag.getComponentCount()]; + parser.read(buf); + tag.setValue(buf); + } + checkTag(tag); break; - case IfdParser.TYPE_VALUE_OF_PREV_TAG: - checkTag(ifdParser.getCorrespodingExifTag(), ifdParser - , mInteroperabilityIfdValue); + case ExifParser.EVENT_COMPRESSED_IMAGE: + case ExifParser.EVENT_UNCOMPRESSED_STRIP: + fail("Invalid Event type: " + event); break; } - type = ifdParser.next(); + event = parser.next(); } - assertEquals(mInteroperabilityIfdValue.size(), tagNumber); + assertEquals(expectedResult.size(), numOfTag); } - private void checkTag(ExifTag tag, IfdParser ifdParser, HashMap truth) - throws IOException { - String truthString = truth.get(tag.getTagId()); - if (truthString == null) { - fail(String.format("Unknown Tag %02x", tag.getTagId())); - } - String dataString = readValueToString(tag, ifdParser); - if (!truthString.equals(dataString)) { - fail(String.format("Tag %02x: expect %s but %s", - tag.getTagId(), truthString, dataString)); - } + public void testOnlyExifIfd() throws IOException, ExifInvalidFormatException { + parseOneIfd(IfdId.TYPE_IFD_EXIF, ExifParser.OPTION_IFD_EXIF, mExifIfdValue); } - private String readValueToString(ExifTag tag, IfdParser parser) throws IOException { - StringBuilder sbuilder = new StringBuilder(); - switch(tag.getDataType()) { - case ExifTag.TYPE_BYTE: - byte buf[] = new byte[tag.getComponentCount()]; - parser.read(buf); - for(int i = 0; i < tag.getComponentCount(); i++) { - if(i != 0) sbuilder.append(" "); - sbuilder.append(String.format("%02x", buf[i])); - } - break; - case ExifTag.TYPE_ASCII: - // trim the string for comparison between xml - sbuilder.append(parser.readString(tag.getComponentCount()).trim()); - break; - case ExifTag.TYPE_INT: - for(int i = 0; i < tag.getComponentCount(); i++) { - if(i != 0) sbuilder.append(" "); - sbuilder.append(parser.readUnsignedInt()); - } - break; - case ExifTag.TYPE_RATIONAL: - for(int i = 0; i < tag.getComponentCount(); i++) { - Rational r = parser.readUnsignedRational(); - if(i != 0) sbuilder.append(" "); - sbuilder.append(r.getNominator()).append("/").append(r.getDenominator()); - } - break; - case ExifTag.TYPE_SHORT: - for(int i = 0; i < tag.getComponentCount(); i++) { - if(i != 0) sbuilder.append(" "); - sbuilder.append(parser.readUnsignedShort()); - } - break; - case ExifTag.TYPE_SINT: - for(int i = 0; i < tag.getComponentCount(); i++) { - if(i != 0) sbuilder.append(" "); - sbuilder.append(parser.readInt()); - } - break; - case ExifTag.TYPE_SRATIONAL: - for(int i = 0; i < tag.getComponentCount(); i++) { - Rational r = parser.readRational(); - if(i != 0) sbuilder.append(" "); - sbuilder.append(r.getNominator()).append("/").append(r.getDenominator()); - } - break; - case ExifTag.TYPE_UNDEFINED: - byte buffer[] = new byte[tag.getComponentCount()]; - parser.read(buffer); - for(int i = 0; i < tag.getComponentCount(); i++) { - if(i != 0) sbuilder.append(" "); - sbuilder.append(String.format("%02x", buffer[i])); - } - break; - } - return sbuilder.toString(); + public void testOnlyIfd0() throws IOException, ExifInvalidFormatException { + parseOneIfd(IfdId.TYPE_IFD_0, ExifParser.OPTION_IFD_0, mIfd0Value); } - public void testSkipToNextIfd() throws ExifInvalidFormatException, IOException { - ExifParser exifParser = new ExifParser(); - IfdParser ifdParser = exifParser.parse(mImageInputStream); - int type = ifdParser.next(); - boolean isEnterNextIfd = false; - while (type != IfdParser.TYPE_END) { - switch (type) { - case IfdParser.TYPE_NEW_TAG: - // Do nothing, we don't care - break; - case IfdParser.TYPE_NEXT_IFD: - parseIfd1(ifdParser.parseIfdBlock()); - isEnterNextIfd = true; - break; - case IfdParser.TYPE_VALUE_OF_PREV_TAG: - // We won't get this since to skip everything - fail("Get value of previous tag but we've skip everything"); - break; - } - type = ifdParser.next(); - } - assertTrue(isEnterNextIfd); + public void testOnlyIfd1() throws IOException, ExifInvalidFormatException { + parseOneIfd(IfdId.TYPE_IFD_1, ExifParser.OPTION_IFD_1, mIfd1Value); + } + + public void testOnlyInteroperabilityIfd() throws IOException, ExifInvalidFormatException { + parseOneIfd(IfdId.TYPE_IFD_INTEROPERABILITY, ExifParser.OPTION_IFD_INTEROPERABILITY + , mInteroperabilityIfdValue); } - public void testOnlySaveSomeValue() throws ExifInvalidFormatException, IOException { - ExifParser exifParser = new ExifParser(); - IfdParser ifdParser = exifParser.parse(mImageInputStream); - boolean isEnterNextIfd = false; - boolean isEnterExifIfd = false; - int type = ifdParser.next(); - while (type != IfdParser.TYPE_END) { - switch (type) { - case IfdParser.TYPE_NEW_TAG: - ExifTag tag = ifdParser.readTag(); - // only interested in these two tags - if (tag.getDataSize() > 4 || tag.getTagId() == ExifTag.TIFF_TAG.TAG_EXIF_IFD) { - if(tag.getTagId() == ExifTag.TIFF_TAG.TAG_MODEL - || tag.getTagId() == ExifTag.TIFF_TAG.TAG_EXIF_IFD) { - long offset = ifdParser.readUnsignedInt(); - assertTrue(offset <= Integer.MAX_VALUE); - ifdParser.waitValueOfTag(tag, offset); + public void testOnlyReadSomeTag() throws IOException, ExifInvalidFormatException { + ExifParser parser = ExifParser.parse(mImageInputStream, ExifParser.OPTION_IFD_0); + int event = parser.next(); + boolean isTagFound = false; + while (event != ExifParser.EVENT_END) { + switch (event) { + case ExifParser.EVENT_START_OF_IFD: + assertEquals(IfdId.TYPE_IFD_0, parser.getCurrentIfd()); + break; + case ExifParser.EVENT_NEW_TAG: + ExifTag tag = parser.getTag(); + if (tag.getTagId() == ExifTag.TIFF_TAG.TAG_MODEL) { + if (tag.hasValue()) { + isTagFound = true; + checkTag(tag); + } else { + parser.registerForTagValue(tag); } + parser.skipRemainingTagsInCurrentIfd(); } break; - case IfdParser.TYPE_NEXT_IFD: - parseIfd1(ifdParser.parseIfdBlock()); - isEnterNextIfd = true; - break; - case IfdParser.TYPE_VALUE_OF_PREV_TAG: - tag = ifdParser.getCorrespodingExifTag(); - if(tag.getTagId() == ExifTag.TIFF_TAG.TAG_EXIF_IFD) { - parseExifIfd(ifdParser.parseIfdBlock()); - isEnterExifIfd = true; - } else { - checkTag(ifdParser.getCorrespodingExifTag(), ifdParser, mIfd0Value); - } + case ExifParser.EVENT_VALUE_OF_REGISTERED_TAG: + tag = parser.getTag(); + assertEquals(ExifTag.TIFF_TAG.TAG_MODEL, tag.getTagId()); + checkTag(tag); + isTagFound = true; break; } - type = ifdParser.next(); + event = parser.next(); } - assertTrue(isEnterNextIfd); - assertTrue(isEnterExifIfd); + assertTrue(isTagFound); } public void testReadThumbnail() throws ExifInvalidFormatException, IOException { - ExifParser exifParser = new ExifParser(); - IfdParser ifdParser = exifParser.parse(mImageInputStream); - int type = ifdParser.next(); - while (type != IfdParser.TYPE_END && type != IfdParser.TYPE_NEXT_IFD) { - type = ifdParser.next(); - } - if (type == IfdParser.TYPE_END) { - Log.i(TAG, "No Thumbnail"); - return; - } - IfdParser ifd1Parser = ifdParser.parseIfdBlock(); - int thumbOffset = 0; - int thumbSize = 0; - boolean isFinishRead = false; - while (!isFinishRead) { - switch (ifd1Parser.next()) { - case IfdParser.TYPE_NEW_TAG: - ExifTag tag = ifd1Parser.readTag(); - if (tag.getTagId() == ExifTag.TIFF_TAG.TAG_JPEG_INTERCHANGE_FORMAT) { - long unsignedInt = ifdParser.readUnsignedInt(); - assertTrue(unsignedInt <= Integer.MAX_VALUE); - thumbOffset = (int) unsignedInt; - } else if (tag.getTagId() == - ExifTag.TIFF_TAG.TAG_JPEG_INTERCHANGE_FORMAT_LENGTH) { - long unsignedInt = ifdParser.readUnsignedInt(); - assertTrue(unsignedInt <= Integer.MAX_VALUE); - thumbSize = (int) unsignedInt; - } else if (tag.getTagId() == ExifTag.TIFF_TAG.TAG_COMPRESSION) { - if (ifdParser.readUnsignedShort() == - ExifTag.TIFF_TAG.COMPRESSION_UNCOMPRESSION) { - // This test doesn't apply to uncompression thumbnail. - return; + ExifParser parser = ExifParser.parse(mImageInputStream, + ExifParser.OPTION_IFD_1 | ExifParser.OPTION_THUMBNAIL); + + int event = parser.next(); + Bitmap bmp = null; + boolean mIsContainCompressedImage = false; + while (event != ExifParser.EVENT_END) { + switch (event) { + case ExifParser.EVENT_NEW_TAG: + ExifTag tag = parser.getTag(); + if (tag.getTagId() == ExifTag.TIFF_TAG.TAG_COMPRESSION) { + if (tag.getUnsignedShort() == ExifTag.TIFF_TAG.COMPRESSION_JPEG) { + mIsContainCompressedImage = true; } } - isFinishRead = thumbOffset != 0 && thumbSize != 0; break; - case IfdParser.TYPE_END: - fail("No thumbnail information found"); + case ExifParser.EVENT_COMPRESSED_IMAGE: + int imageSize = parser.getCompressedImageSize(); + byte buf[] = new byte[imageSize]; + parser.read(buf); + bmp = BitmapFactory.decodeByteArray(buf, 0, imageSize); break; } + event = parser.next(); + } + if (mIsContainCompressedImage) { + assertNotNull(bmp); } - - byte buf[] = new byte[thumbSize]; - ifd1Parser.skipTo(thumbOffset); - ifd1Parser.read(buf); - Bitmap bmp = BitmapFactory.decodeByteArray(buf, 0, thumbSize); - // Check correctly decoded - assertTrue(bmp != null); } @Override @@ -399,4 +236,4 @@ public class ExifParserTest extends InstrumentationTestCase { mIfd1Value.clear(); mExifIfdValue.clear(); } -} +} \ No newline at end of file diff --git a/tests/src/com/android/gallery3d/exif/ExifReaderTest.java b/tests/src/com/android/gallery3d/exif/ExifReaderTest.java index 9964997f2..c0c2f9f81 100644 --- a/tests/src/com/android/gallery3d/exif/ExifReaderTest.java +++ b/tests/src/com/android/gallery3d/exif/ExifReaderTest.java @@ -57,72 +57,25 @@ public class ExifReaderTest extends InstrumentationTestCase { public void testRead() throws ExifInvalidFormatException, IOException { ExifReader reader = new ExifReader(); ExifData exifData = reader.getExifData(mImageInputStream); - checkIfd(exifData, ExifData.TYPE_IFD_0, mIfd0Value); - checkIfd(exifData, ExifData.TYPE_IFD_1, mIfd1Value); - checkIfd(exifData, ExifData.TYPE_IFD_EXIF, mExifIfdValue); - checkIfd(exifData, ExifData.TYPE_IFD_INTEROPERABILITY, mInteroperabilityIfdValue); + checkIfd(exifData.getIfdData(IfdId.TYPE_IFD_0), mIfd0Value); + checkIfd(exifData.getIfdData(IfdId.TYPE_IFD_1), mIfd1Value); + checkIfd(exifData.getIfdData(IfdId.TYPE_IFD_EXIF), mExifIfdValue); + checkIfd(exifData.getIfdData(IfdId.TYPE_IFD_INTEROPERABILITY), + mInteroperabilityIfdValue); } - private void checkIfd(ExifData exifData, int ifdType, HashMap ifdValue) - throws IOException { - IfdData ifd = exifData.getIfdData(ifdType); + private void checkIfd(IfdData ifd, HashMap ifdValue) { if (ifd == null) { assertEquals(0 ,ifdValue.size()); return; } ExifTag[] tags = ifd.getAllTags(new ExifTag[0]); for (ExifTag tag : tags) { - assertEquals(ifdValue.get(tag.getTagId()), readValueToString(tag, ifd)); + assertEquals(ifdValue.get(tag.getTagId()), tag.valueToString()); } assertEquals(ifdValue.size(), tags.length); } - private String readValueToString(ExifTag tag, IfdData ifdData) throws IOException { - StringBuilder sbuilder = new StringBuilder(); - switch(tag.getDataType()) { - case ExifTag.TYPE_UNDEFINED: - case ExifTag.TYPE_BYTE: - byte buf[] = new byte[tag.getComponentCount()]; - ifdData.getBytes(tag.getTagId(), buf); - for(int i = 0; i < tag.getComponentCount(); i++) { - if(i != 0) sbuilder.append(" "); - sbuilder.append(String.format("%02x", buf[i])); - } - break; - case ExifTag.TYPE_ASCII: - // trim the string for comparison between xml - sbuilder.append(ifdData.getString(tag.getTagId()).trim()); - break; - case ExifTag.TYPE_INT: - for(int i = 0; i < tag.getComponentCount(); i++) { - if(i != 0) sbuilder.append(" "); - sbuilder.append(ifdData.getUnsignedInt(tag.getTagId(), i)); - } - break; - case ExifTag.TYPE_SRATIONAL: - case ExifTag.TYPE_RATIONAL: - for(int i = 0; i < tag.getComponentCount(); i++) { - Rational r = ifdData.getRational(tag.getTagId(), i); - if(i != 0) sbuilder.append(" "); - sbuilder.append(r.getNominator()).append("/").append(r.getDenominator()); - } - break; - case ExifTag.TYPE_SHORT: - for(int i = 0; i < tag.getComponentCount(); i++) { - if(i != 0) sbuilder.append(" "); - sbuilder.append(ifdData.getUnsignedShort(tag.getTagId(), i)); - } - break; - case ExifTag.TYPE_SINT: - for(int i = 0; i < tag.getComponentCount(); i++) { - if(i != 0) sbuilder.append(" "); - sbuilder.append(ifdData.getInt(tag.getTagId(), i)); - } - break; - } - return sbuilder.toString(); - } - @Override public void tearDown() throws Exception { mImageInputStream.close(); diff --git a/tests/src/com/android/gallery3d/exif/ExifXmlReader.java b/tests/src/com/android/gallery3d/exif/ExifXmlReader.java index ea748cc18..72dd31373 100644 --- a/tests/src/com/android/gallery3d/exif/ExifXmlReader.java +++ b/tests/src/com/android/gallery3d/exif/ExifXmlReader.java @@ -94,4 +94,4 @@ public class ExifXmlReader { data.put(id, value); parser.require(XmlPullParser.END_TAG, null, XML_TAG); } -} +} \ No newline at end of file -- GitLab From bdbf57f29db2c98dd2e0d05cd062c063fe90cd54 Mon Sep 17 00:00:00 2001 From: Earl Ou Date: Wed, 15 Aug 2012 17:55:55 +0800 Subject: [PATCH 210/763] Rename TiffInputStream to CountedDataInputStream Change-Id: Ie52ab9a58ae47f5a0b9113c6006844b73567d864 --- ...nputStream.java => CountedDataInputStream.java} | 14 ++++++++------ src/com/android/gallery3d/exif/ExifParser.java | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) rename src/com/android/gallery3d/exif/{TiffInputStream.java => CountedDataInputStream.java} (91%) diff --git a/src/com/android/gallery3d/exif/TiffInputStream.java b/src/com/android/gallery3d/exif/CountedDataInputStream.java similarity index 91% rename from src/com/android/gallery3d/exif/TiffInputStream.java rename to src/com/android/gallery3d/exif/CountedDataInputStream.java index 2b0054c46..dfd4a1a10 100644 --- a/src/com/android/gallery3d/exif/TiffInputStream.java +++ b/src/com/android/gallery3d/exif/CountedDataInputStream.java @@ -24,7 +24,7 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.charset.Charset; -class TiffInputStream extends FilterInputStream { +class CountedDataInputStream extends FilterInputStream { private int mCount = 0; @@ -32,7 +32,7 @@ class TiffInputStream extends FilterInputStream { private final byte mByteArray[] = new byte[8]; private final ByteBuffer mByteBuffer = ByteBuffer.wrap(mByteArray); - protected TiffInputStream(InputStream in) { + protected CountedDataInputStream(InputStream in) { super(in); } @@ -42,26 +42,28 @@ class TiffInputStream extends FilterInputStream { @Override public int read(byte[] b) throws IOException { - return read(b, 0, b.length); + int r = in.read(b); + mCount += (r >= 0) ? r : 0; + return r; } @Override public int read(byte[] b, int off, int len) throws IOException { - int r = super.read(b, off, len); + int r = in.read(b, off, len); mCount += (r >= 0) ? r : 0; return r; } @Override public int read() throws IOException { - int r = super.read(); + int r = in.read(); mCount += (r >= 0) ? 1 : 0; return r; } @Override public long skip(long length) throws IOException { - long skip = super.skip(length); + long skip = in.skip(length); mCount += skip; return skip; } diff --git a/src/com/android/gallery3d/exif/ExifParser.java b/src/com/android/gallery3d/exif/ExifParser.java index 4249a7241..bd8a97dac 100644 --- a/src/com/android/gallery3d/exif/ExifParser.java +++ b/src/com/android/gallery3d/exif/ExifParser.java @@ -137,7 +137,7 @@ public class ExifParser { private static final int TAG_SIZE = 12; private static final int OFFSET_SIZE = 2; - private final TiffInputStream mTiffStream; + private final CountedDataInputStream mTiffStream; private final int mOptions; private int mIfdStartOffset = 0; private int mNumOfTagInIfd = 0; @@ -174,7 +174,7 @@ public class ExifParser { private ExifParser(InputStream inputStream, int options) throws IOException, ExifInvalidFormatException { seekTiffData(inputStream); - mTiffStream = new TiffInputStream(inputStream); + mTiffStream = new CountedDataInputStream(inputStream); mOptions = options; if (mTiffStream.getReadByteCount() == 0) { parseTiffHeader(); -- GitLab From ed3f467915e1e9b869674b1bd6acf0c4fa2372d1 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Queru Date: Fri, 24 Aug 2012 10:35:52 -0700 Subject: [PATCH 211/763] Fine-tune SDK versions Change-Id: Ic8ebb95d51a4a66da7b026ea93572db1781bed35 --- AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 2a69ce1e3..15b0198c6 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -7,7 +7,7 @@ - + -- GitLab From 015de507c0cd8543546dcf6fc673ba2f15576228 Mon Sep 17 00:00:00 2001 From: Baligh Uddin Date: Fri, 24 Aug 2012 12:07:09 -0700 Subject: [PATCH 212/763] Import translations. DO NOT MERGE Change-Id: I87825a89d6a75f65528c6d2edfcebd753040457e Auto-generated-cl: translation import --- res/values-sw/photoeditor_strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values-sw/photoeditor_strings.xml b/res/values-sw/photoeditor_strings.xml index 24146e78b..5b983952b 100644 --- a/res/values-sw/photoeditor_strings.xml +++ b/res/values-sw/photoeditor_strings.xml @@ -57,7 +57,7 @@ "Gonga kwenye macho mekundu ili kuyaondoa" "kokota picha ili kuizungusha" "Kokota picha ili kuizungusha" - "Athari za mfichuo" + "Athari za kiwango cha mwangaza" "Athari za rangi" "Athari za kisanii" "Rekebisha" -- GitLab From 915c2c5b2c367df71599370613af0924bd7c4887 Mon Sep 17 00:00:00 2001 From: Bobby Georgescu Date: Thu, 23 Aug 2012 13:05:53 -0700 Subject: [PATCH 213/763] Ongoing reskin of Gallery app Bug: 7050303 Moved the majority of color settings from hardcoded to colors.xml in order to allow rapid iteration with UX input. Started changing some colors and layouts to reflect latest UX mocks. Change-Id: I300338e9f75c71f3ed3f36140d16e893387f3184 --- res/values/colors.xml | 41 +++++++++++++++++++ res/values/dimensions.xml | 20 ++++----- .../android/gallery3d/app/ActivityState.java | 14 +++++++ src/com/android/gallery3d/app/AlbumPage.java | 10 ++++- .../android/gallery3d/app/AlbumSetPage.java | 10 ++++- src/com/android/gallery3d/app/Config.java | 12 ++++++ .../gallery3d/app/ManageCachePage.java | 7 +++- src/com/android/gallery3d/app/PhotoPage.java | 9 +++- .../android/gallery3d/app/SlideshowPage.java | 8 +++- .../android/gallery3d/ui/AlbumLabelMaker.java | 11 ++--- .../gallery3d/ui/AlbumSetSlotRenderer.java | 15 ++++--- .../gallery3d/ui/AlbumSlotRenderer.java | 9 ++-- .../gallery3d/ui/BitmapScreenNail.java | 18 +++++--- src/com/android/gallery3d/ui/GLCanvas.java | 3 +- .../android/gallery3d/ui/GLCanvasImpl.java | 11 +++-- .../gallery3d/ui/ManageCacheDrawer.java | 3 +- src/com/android/gallery3d/ui/PhotoView.java | 6 ++- src/com/android/gallery3d/ui/SlotView.java | 3 +- .../android/gallery3d/util/GalleryUtils.java | 15 +++++++ .../android/gallery3d/ui/GLCanvasStub.java | 2 +- 20 files changed, 175 insertions(+), 52 deletions(-) create mode 100644 res/values/colors.xml diff --git a/res/values/colors.xml b/res/values/colors.xml new file mode 100644 index 000000000..96db24368 --- /dev/null +++ b/res/values/colors.xml @@ -0,0 +1,41 @@ + + + + #FF000000 + + + #FF000000 + #FFDDDDDD + #FFCCCCCC + #FF000000 + #80000000 + + + #FF000000 + #FFDDDDDD + + + #FF000000 + #FF222222 + + + #FF000000 + #FFDDDDDD + + #FF222222 + + #FF000000 + diff --git a/res/values/dimensions.xml b/res/values/dimensions.xml index 906dbdb83..e586f9329 100644 --- a/res/values/dimensions.xml +++ b/res/values/dimensions.xml @@ -20,20 +20,20 @@ 120dp - 1 - 2 - 15dp - 15dp - 12dp + 2 + 3 + 7dp + 7dp + 7dp - 45dp + 25dp 10dp 10dp - 20sp - 12sp + 12sp + 9sp 6dp - 30dp - 20dp + 20dp + 15dp 2 diff --git a/src/com/android/gallery3d/app/ActivityState.java b/src/com/android/gallery3d/app/ActivityState.java index 13cd1509a..a86351b66 100644 --- a/src/com/android/gallery3d/app/ActivityState.java +++ b/src/com/android/gallery3d/app/ActivityState.java @@ -33,9 +33,11 @@ import android.view.MenuItem; import android.view.Window; import android.view.WindowManager; +import com.android.gallery3d.R; import com.android.gallery3d.actionbar.ActionBarInterface; import com.android.gallery3d.actionbar.ActionBarUtils; import com.android.gallery3d.ui.GLView; +import com.android.gallery3d.util.GalleryUtils; abstract public class ActivityState { protected static final int FLAG_HIDE_ACTION_BAR = 1; @@ -105,7 +107,19 @@ abstract public class ActivityState { protected void onStateResult(int requestCode, int resultCode, Intent data) { } + protected float[] mBackgroundColor; + + protected int getBackgroundColorId() { + return R.color.default_background; + } + + protected float[] getBackgroundColor() { + return mBackgroundColor; + } + protected void onCreate(Bundle data, Bundle storedState) { + mBackgroundColor = GalleryUtils.intColorToFloatARGBArray( + mActivity.getResources().getColor(getBackgroundColorId())); } protected void clearStateResult() { diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java index a39195007..e44dae194 100644 --- a/src/com/android/gallery3d/app/AlbumPage.java +++ b/src/com/android/gallery3d/app/AlbumPage.java @@ -136,12 +136,17 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster } }; + @Override + protected int getBackgroundColorId() { + return R.color.album_background; + } + private final GLView mRootPane = new GLView() { private final float mMatrix[] = new float[16]; @Override protected void renderBackground(GLCanvas view) { - view.clearBuffer(); + view.clearBuffer(getBackgroundColor()); } @Override @@ -453,7 +458,8 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster mSelectionManager.setSelectionListener(this); Config.AlbumPage config = Config.AlbumPage.get((Context) mActivity); mSlotView = new SlotView(mActivity, config.slotViewSpec); - mAlbumView = new AlbumSlotRenderer(mActivity, mSlotView, mSelectionManager); + mAlbumView = new AlbumSlotRenderer(mActivity, mSlotView, + mSelectionManager, config.placeholderColor); mSlotView.setSlotRenderer(mAlbumView); mRootPane.addComponent(mSlotView); mSlotView.setListener(new SlotView.SimpleListener() { diff --git a/src/com/android/gallery3d/app/AlbumSetPage.java b/src/com/android/gallery3d/app/AlbumSetPage.java index 5d7d0850a..a5a24810a 100644 --- a/src/com/android/gallery3d/app/AlbumSetPage.java +++ b/src/com/android/gallery3d/app/AlbumSetPage.java @@ -109,12 +109,17 @@ public class AlbumSetPage extends ActivityState implements private int mLoadingBits = 0; private boolean mInitialSynced = false; + @Override + protected int getBackgroundColorId() { + return R.color.albumset_background; + } + private final GLView mRootPane = new GLView() { private final float mMatrix[] = new float[16]; @Override protected void renderBackground(GLCanvas view) { - view.clearBuffer(); + view.clearBuffer(getBackgroundColor()); } @Override @@ -369,7 +374,8 @@ public class AlbumSetPage extends ActivityState implements mConfig = Config.AlbumSetPage.get((Context) mActivity); mSlotView = new SlotView(mActivity, mConfig.slotViewSpec); mAlbumSetView = new AlbumSetSlotRenderer( - mActivity, mSelectionManager, mSlotView, mConfig.labelSpec); + mActivity, mSelectionManager, mSlotView, mConfig.labelSpec, + mConfig.placeholderColor); mSlotView.setSlotRenderer(mAlbumSetView); mSlotView.setListener(new SlotView.SimpleListener() { @Override diff --git a/src/com/android/gallery3d/app/Config.java b/src/com/android/gallery3d/app/Config.java index 6fb24ec81..04b210e0e 100644 --- a/src/com/android/gallery3d/app/Config.java +++ b/src/com/android/gallery3d/app/Config.java @@ -31,6 +31,7 @@ final class Config { public AlbumSetSlotRenderer.LabelSpec labelSpec; public int paddingTop; public int paddingBottom; + public int placeholderColor; public static synchronized AlbumSetPage get(Context context) { if (sInstance == null) { @@ -42,10 +43,14 @@ final class Config { private AlbumSetPage(Context context) { Resources r = context.getResources(); + placeholderColor = r.getColor(R.color.albumset_placeholder); + slotViewSpec = new SlotView.Spec(); slotViewSpec.rowsLand = r.getInteger(R.integer.albumset_rows_land); slotViewSpec.rowsPort = r.getInteger(R.integer.albumset_rows_port); slotViewSpec.slotGap = r.getDimensionPixelSize(R.dimen.albumset_slot_gap); + slotViewSpec.slotHeightAdditional = r.getDimensionPixelSize( + R.dimen.albumset_label_background_height); paddingTop = r.getDimensionPixelSize(R.dimen.albumset_padding_top); paddingBottom = r.getDimensionPixelSize(R.dimen.albumset_padding_bottom); @@ -67,6 +72,10 @@ final class Config { R.dimen.albumset_title_right_margin); labelSpec.iconSize = r.getDimensionPixelSize( R.dimen.albumset_icon_size); + labelSpec.backgroundColor = r.getColor( + R.color.albumset_label_background); + labelSpec.titleColor = r.getColor(R.color.albumset_label_title); + labelSpec.countColor = r.getColor(R.color.albumset_label_count); } } @@ -74,6 +83,7 @@ final class Config { private static AlbumPage sInstance; public SlotView.Spec slotViewSpec; + public int placeholderColor; public static synchronized AlbumPage get(Context context) { if (sInstance == null) { @@ -85,6 +95,8 @@ final class Config { private AlbumPage(Context context) { Resources r = context.getResources(); + placeholderColor = r.getColor(R.color.album_placeholder); + slotViewSpec = new SlotView.Spec(); slotViewSpec.rowsLand = r.getInteger(R.integer.album_rows_land); slotViewSpec.rowsPort = r.getInteger(R.integer.album_rows_port); diff --git a/src/com/android/gallery3d/app/ManageCachePage.java b/src/com/android/gallery3d/app/ManageCachePage.java index b02d129b0..847adf6e6 100644 --- a/src/com/android/gallery3d/app/ManageCachePage.java +++ b/src/com/android/gallery3d/app/ManageCachePage.java @@ -86,12 +86,17 @@ public class ManageCachePage extends ActivityState implements private Handler mHandler; private boolean mLayoutReady = false; + @Override + protected int getBackgroundColorId() { + return R.color.cache_background; + } + private GLView mRootPane = new GLView() { private float mMatrix[] = new float[16]; @Override protected void renderBackground(GLCanvas view) { - view.clearBuffer(); + view.clearBuffer(getBackgroundColor()); } @Override diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index 2774440ba..8b38abbb2 100644 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -168,6 +168,11 @@ public class PhotoPage extends ActivityState implements private final FloatAnimation mBackgroundFade = new BackgroundFadeOut(); + @Override + protected int getBackgroundColorId() { + return R.color.photo_background; + } + private final GLView mRootPane = new GLView() { @Override protected void renderBackground(GLCanvas view) { @@ -180,7 +185,7 @@ public class PhotoPage extends ActivityState implements } else { float fadeAlpha = mBackgroundFade.get(); if(fadeAlpha < 1f) { - view.clearBuffer(0f, 0f, 0f, 1f); + view.clearBuffer(getBackgroundColor()); view.setAlpha(fadeAlpha); } mFadeOutTexture.draw(view, 0, 0); @@ -188,7 +193,7 @@ public class PhotoPage extends ActivityState implements return; } } - view.clearBuffer(0f, 0f, 0f, 1f); + view.clearBuffer(getBackgroundColor()); } @Override diff --git a/src/com/android/gallery3d/app/SlideshowPage.java b/src/com/android/gallery3d/app/SlideshowPage.java index c0e35be26..09a239e25 100644 --- a/src/com/android/gallery3d/app/SlideshowPage.java +++ b/src/com/android/gallery3d/app/SlideshowPage.java @@ -24,6 +24,7 @@ import android.os.Handler; import android.os.Message; import android.view.MotionEvent; +import com.android.gallery3d.R; import com.android.gallery3d.common.Utils; import com.android.gallery3d.data.ContentListener; import com.android.gallery3d.data.MediaItem; @@ -83,6 +84,11 @@ public class SlideshowPage extends ActivityState { private boolean mIsActive = false; private final Intent mResultIntent = new Intent(); + @Override + protected int getBackgroundColorId() { + return R.color.slideshow_background; + } + private final GLView mRootPane = new GLView() { @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { @@ -99,7 +105,7 @@ public class SlideshowPage extends ActivityState { @Override protected void renderBackground(GLCanvas canvas) { - canvas.clearBuffer(0f, 0f, 0f, 0f); + canvas.clearBuffer(getBackgroundColor()); } }; diff --git a/src/com/android/gallery3d/ui/AlbumLabelMaker.java b/src/com/android/gallery3d/ui/AlbumLabelMaker.java index 4a1d545b7..cd6c77861 100644 --- a/src/com/android/gallery3d/ui/AlbumLabelMaker.java +++ b/src/com/android/gallery3d/ui/AlbumLabelMaker.java @@ -21,7 +21,6 @@ import android.graphics.Bitmap; import android.graphics.Bitmap.Config; import android.graphics.BitmapFactory; import android.graphics.Canvas; -import android.graphics.Color; import android.graphics.PorterDuff; import android.graphics.Typeface; import android.text.TextPaint; @@ -34,11 +33,7 @@ import com.android.gallery3d.util.ThreadPool; import com.android.gallery3d.util.ThreadPool.JobContext; public class AlbumLabelMaker { - private static final int FONT_COLOR_TITLE = Color.BLACK; - private static final int FONT_COLOR_COUNT = 0x80000000; - private static final int BORDER_SIZE = 0; - private static final int BACKGROUND_COLOR = 0xFFFFFFFF; private final AlbumSetSlotRenderer.LabelSpec mSpec; private final TextPaint mTitlePaint; @@ -56,8 +51,8 @@ public class AlbumLabelMaker { public AlbumLabelMaker(Context context, AlbumSetSlotRenderer.LabelSpec spec) { mContext = context; mSpec = spec; - mTitlePaint = getTextPaint(spec.titleFontSize, FONT_COLOR_TITLE, false); - mCountPaint = getTextPaint(spec.countFontSize, FONT_COLOR_COUNT, false); + mTitlePaint = getTextPaint(spec.titleFontSize, spec.titleColor, false); + mCountPaint = getTextPaint(spec.countFontSize, spec.countColor, false); mLocalSetIcon = new LazyLoadedBitmap(R.drawable.frame_overlay_gallery_folder); mPicasaIcon = new LazyLoadedBitmap(R.drawable.frame_overlay_gallery_picasa); @@ -174,7 +169,7 @@ public class AlbumLabelMaker { canvas.clipRect(BORDER_SIZE, BORDER_SIZE, bitmap.getWidth() - BORDER_SIZE, bitmap.getHeight() - BORDER_SIZE); - canvas.drawColor(BACKGROUND_COLOR, PorterDuff.Mode.SRC); + canvas.drawColor(mSpec.backgroundColor, PorterDuff.Mode.SRC); canvas.translate(BORDER_SIZE, BORDER_SIZE); diff --git a/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java b/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java index cee36d969..bdc0e676e 100644 --- a/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java +++ b/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java @@ -28,7 +28,7 @@ public class AlbumSetSlotRenderer extends AbstractSlotRenderer { @SuppressWarnings("unused") private static final String TAG = "AlbumSetView"; private static final int CACHE_SIZE = 96; - private static final int PLACEHOLDER_COLOR = 0xFFDDDDDD; + private final int mPlaceholderColor; private final ColorTexture mWaitLoadingTexture; private final GalleryActivity mActivity; @@ -52,20 +52,23 @@ public class AlbumSetSlotRenderer extends AbstractSlotRenderer { public int leftMargin; public int iconSize; public int titleRightMargin; + public int backgroundColor; + public int titleColor; + public int countColor; + public int borderSize; } public AlbumSetSlotRenderer(GalleryActivity activity, SelectionManager selectionManager, - SlotView slotView, LabelSpec labelSpec) { + SlotView slotView, LabelSpec labelSpec, int placeholderColor) { super ((Context) activity); mActivity = activity; mSelectionManager = selectionManager; mSlotView = slotView; mLabelSpec = labelSpec; + mPlaceholderColor = placeholderColor; - mWaitLoadingTexture = new ColorTexture(PLACEHOLDER_COLOR); + mWaitLoadingTexture = new ColorTexture(mPlaceholderColor); mWaitLoadingTexture.setSize(1, 1); - - Context context = activity.getAndroidContext(); } public void setPressedIndex(int index) { @@ -149,7 +152,7 @@ public class AlbumSetSlotRenderer extends AbstractSlotRenderer { entry.isWaitLoadingDisplayed = true; } else if (entry.isWaitLoadingDisplayed) { entry.isWaitLoadingDisplayed = false; - content = new FadeInTexture(PLACEHOLDER_COLOR, entry.bitmapTexture); + content = new FadeInTexture(mPlaceholderColor, entry.bitmapTexture); entry.content = content; } drawContent(canvas, content, width, height, entry.rotation); diff --git a/src/com/android/gallery3d/ui/AlbumSlotRenderer.java b/src/com/android/gallery3d/ui/AlbumSlotRenderer.java index dee9a0b11..f6df3b380 100644 --- a/src/com/android/gallery3d/ui/AlbumSlotRenderer.java +++ b/src/com/android/gallery3d/ui/AlbumSlotRenderer.java @@ -31,7 +31,7 @@ public class AlbumSlotRenderer extends AbstractSlotRenderer { public boolean acceptSlot(int index); } - private static final int PLACEHOLDER_COLOR = 0xFFDDDDDD; + private final int mPlaceholderColor; private static final int CACHE_SIZE = 96; private AlbumSlidingWindow mDataWindow; @@ -48,13 +48,14 @@ public class AlbumSlotRenderer extends AbstractSlotRenderer { private SlotFilter mSlotFilter; public AlbumSlotRenderer(GalleryActivity activity, SlotView slotView, - SelectionManager selectionManager) { + SelectionManager selectionManager, int placeholderColor) { super((Context) activity); mActivity = activity; mSlotView = slotView; mSelectionManager = selectionManager; + mPlaceholderColor = placeholderColor; - mWaitLoadingTexture = new ColorTexture(PLACEHOLDER_COLOR); + mWaitLoadingTexture = new ColorTexture(mPlaceholderColor); mWaitLoadingTexture.setSize(1, 1); } @@ -110,7 +111,7 @@ public class AlbumSlotRenderer extends AbstractSlotRenderer { entry.isWaitDisplayed = true; } else if (entry.isWaitDisplayed) { entry.isWaitDisplayed = false; - content = new FadeInTexture(PLACEHOLDER_COLOR, entry.bitmapTexture); + content = new FadeInTexture(mPlaceholderColor, entry.bitmapTexture); entry.content = content; } drawContent(canvas, content, width, height, entry.rotation); diff --git a/src/com/android/gallery3d/ui/BitmapScreenNail.java b/src/com/android/gallery3d/ui/BitmapScreenNail.java index 57685e8e5..6fbcf0137 100644 --- a/src/com/android/gallery3d/ui/BitmapScreenNail.java +++ b/src/com/android/gallery3d/ui/BitmapScreenNail.java @@ -33,10 +33,9 @@ import com.android.gallery3d.data.MediaItem; public class BitmapScreenNail implements ScreenNail { @SuppressWarnings("unused") private static final String TAG = "BitmapScreenNail"; - private static final int PLACEHOLDER_COLOR = 0xFF222222; + // The duration of the fading animation in milliseconds private static final int DURATION = 180; - private static boolean mDrawPlaceholder = true; private static final int MAX_SIDE = 640; @@ -63,6 +62,15 @@ public class BitmapScreenNail implements ScreenNail { setSize(width, height); } + // This gets overridden by bitmap_screennail_placeholder + // in GalleryUtils.initialize + private static int mPlaceholderColor = 0xFF222222; + private static boolean mDrawPlaceholder = true; + + public static void setPlaceholderColor(int color) { + mPlaceholderColor = color; + } + private void setSize(int width, int height) { if (width == 0 || height == 0) { width = 640; @@ -155,7 +163,7 @@ public class BitmapScreenNail implements ScreenNail { mAnimationStartTime = ANIMATION_NEEDED; } if(mDrawPlaceholder) { - canvas.fillRect(x, y, width, height, PLACEHOLDER_COLOR); + canvas.fillRect(x, y, width, height, mPlaceholderColor); } return; } @@ -169,7 +177,7 @@ public class BitmapScreenNail implements ScreenNail { } if (isAnimating()) { - canvas.drawMixed(mTexture, PLACEHOLDER_COLOR, getRatio(), x, y, + canvas.drawMixed(mTexture, mPlaceholderColor, getRatio(), x, y, width, height); } else { mTexture.draw(canvas, x, y, width, height); @@ -180,7 +188,7 @@ public class BitmapScreenNail implements ScreenNail { public void draw(GLCanvas canvas, RectF source, RectF dest) { if (mBitmap == null) { canvas.fillRect(dest.left, dest.top, dest.width(), dest.height(), - PLACEHOLDER_COLOR); + mPlaceholderColor); return; } diff --git a/src/com/android/gallery3d/ui/GLCanvas.java b/src/com/android/gallery3d/ui/GLCanvas.java index 6d9aa4271..e3a32ef08 100644 --- a/src/com/android/gallery3d/ui/GLCanvas.java +++ b/src/com/android/gallery3d/ui/GLCanvas.java @@ -36,6 +36,7 @@ public interface GLCanvas { // Clear the drawing buffers. This should only be used by GLRoot. public void clearBuffer(); + public void clearBuffer(float[] argb); // Sets and gets the current alpha, alpha must be in [0, 1]. public void setAlpha(float alpha); @@ -121,6 +122,4 @@ public interface GLCanvas { public void beginRenderTarget(RawTexture texture); public void endRenderTarget(); - - public void clearBuffer(float r, float g, float b, float a); } diff --git a/src/com/android/gallery3d/ui/GLCanvasImpl.java b/src/com/android/gallery3d/ui/GLCanvasImpl.java index a254bcce4..d83daf3e4 100644 --- a/src/com/android/gallery3d/ui/GLCanvasImpl.java +++ b/src/com/android/gallery3d/ui/GLCanvasImpl.java @@ -649,15 +649,18 @@ public class GLCanvasImpl implements GLCanvas { } @Override - public void clearBuffer(float r, float g, float b, float a) { - mGL.glClearColor(r, g, b, a); + public void clearBuffer(float[] argb) { + if(argb != null && argb.length == 4) { + mGL.glClearColor(argb[1], argb[2], argb[3], argb[0]); + } else { + mGL.glClearColor(0, 0, 0, 1); + } mGL.glClear(GL10.GL_COLOR_BUFFER_BIT); } @Override public void clearBuffer() { - // TODO: Make this grey background color constant - clearBuffer(0.93f, 0.93f, 0.93f, 1); + clearBuffer(null); } private void setTextureCoords(RectF source) { diff --git a/src/com/android/gallery3d/ui/ManageCacheDrawer.java b/src/com/android/gallery3d/ui/ManageCacheDrawer.java index ba31fc653..91dc7ac44 100644 --- a/src/com/android/gallery3d/ui/ManageCacheDrawer.java +++ b/src/com/android/gallery3d/ui/ManageCacheDrawer.java @@ -38,7 +38,8 @@ public class ManageCacheDrawer extends AlbumSetSlotRenderer { public ManageCacheDrawer(GalleryActivity activity, SelectionManager selectionManager, SlotView slotView, LabelSpec labelSpec, int cachePinSize, int cachePinMargin) { - super(activity, selectionManager, slotView, labelSpec); + super(activity, selectionManager, slotView, labelSpec, + activity.getResources().getColor(R.color.cache_placeholder)); Context context = (Context) activity; mCheckedItem = new ResourceTexture( context, R.drawable.btn_make_offline_normal_on_holo_dark); diff --git a/src/com/android/gallery3d/ui/PhotoView.java b/src/com/android/gallery3d/ui/PhotoView.java index 0dee1b04b..16d93ca20 100644 --- a/src/com/android/gallery3d/ui/PhotoView.java +++ b/src/com/android/gallery3d/ui/PhotoView.java @@ -39,7 +39,7 @@ import com.android.gallery3d.util.RangeArray; public class PhotoView extends GLView { @SuppressWarnings("unused") private static final String TAG = "PhotoView"; - private static final int PLACEHOLDER_COLOR = 0xFF222222; + private final int mPlaceholderColor; public static final int INVALID_SIZE = -1; public static final long INVALID_DATA_VERSION = @@ -236,6 +236,8 @@ public class PhotoView extends GLView { mTileView = new TileImageView(activity); addComponent(mTileView); Context context = activity.getAndroidContext(); + mPlaceholderColor = context.getResources().getColor( + R.color.photo_placeholder); mEdgeView = new EdgeView(context); addComponent(mEdgeView); mUndoBar = new UndoBarView(context); @@ -886,7 +888,7 @@ public class PhotoView extends GLView { // Draw a gray placeholder in the specified rectangle. private void drawPlaceHolder(GLCanvas canvas, Rect r) { - canvas.fillRect(r.left, r.top, r.width(), r.height(), PLACEHOLDER_COLOR); + canvas.fillRect(r.left, r.top, r.width(), r.height(), mPlaceholderColor); } // Draw the video play icon (in the place where the spinner was) diff --git a/src/com/android/gallery3d/ui/SlotView.java b/src/com/android/gallery3d/ui/SlotView.java index 88a2e0d3c..1325aecd6 100644 --- a/src/com/android/gallery3d/ui/SlotView.java +++ b/src/com/android/gallery3d/ui/SlotView.java @@ -386,6 +386,7 @@ public class SlotView extends GLView { public static class Spec { public int slotWidth = -1; public int slotHeight = -1; + public int slotHeightAdditional = 0; public int rowsLand = -1; public int rowsPort = -1; @@ -501,7 +502,7 @@ public class SlotView extends GLView { int rows = (mWidth > mHeight) ? mSpec.rowsLand : mSpec.rowsPort; mSlotGap = mSpec.slotGap; mSlotHeight = Math.max(1, (mHeight - (rows - 1) * mSlotGap) / rows); - mSlotWidth = mSlotHeight; + mSlotWidth = mSlotHeight - mSpec.slotHeightAdditional; } if (mRenderer != null) { diff --git a/src/com/android/gallery3d/util/GalleryUtils.java b/src/com/android/gallery3d/util/GalleryUtils.java index 3b73d344c..e750e2769 100644 --- a/src/com/android/gallery3d/util/GalleryUtils.java +++ b/src/com/android/gallery3d/util/GalleryUtils.java @@ -24,6 +24,8 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; +import android.content.res.Resources; +import android.graphics.Color; import android.net.Uri; import android.os.ConditionVariable; import android.os.Environment; @@ -39,6 +41,7 @@ import com.android.gallery3d.app.PackagesMonitor; import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.data.DataManager; import com.android.gallery3d.data.MediaItem; +import com.android.gallery3d.ui.BitmapScreenNail; import com.android.gallery3d.util.ThreadPool.CancelListener; import com.android.gallery3d.util.ThreadPool.JobContext; @@ -76,6 +79,18 @@ public class GalleryUtils { wm.getDefaultDisplay().getMetrics(metrics); sPixelDensity = metrics.density; } + Resources r = context.getResources(); + BitmapScreenNail.setPlaceholderColor(r.getColor( + R.color.bitmap_screennail_placeholder)); + } + + public static float[] intColorToFloatARGBArray(int from) { + return new float[] { + (float) Color.alpha(from) / 255f, + (float) Color.red(from) / 255f, + (float) Color.green(from) / 255f, + (float) Color.blue(from) / 255f + }; } public static float dpToPixel(float dp) { diff --git a/tests/src/com/android/gallery3d/ui/GLCanvasStub.java b/tests/src/com/android/gallery3d/ui/GLCanvasStub.java index f30b57964..2f2d753e0 100644 --- a/tests/src/com/android/gallery3d/ui/GLCanvasStub.java +++ b/tests/src/com/android/gallery3d/ui/GLCanvasStub.java @@ -23,7 +23,7 @@ import javax.microedition.khronos.opengles.GL11; public class GLCanvasStub implements GLCanvas { public void setSize(int width, int height) {} public void clearBuffer() {} - public void clearBuffer(float r, float g, float b, float a) {} + public void clearBuffer(float[] argb) {} public void setCurrentAnimationTimeMillis(long time) {} public long currentAnimationTimeMillis() { throw new UnsupportedOperationException(); -- GitLab From 8745db70dec195c8e5fcfe997f167e8ba1a33264 Mon Sep 17 00:00:00 2001 From: Wu-cheng Li Date: Sun, 26 Aug 2012 23:53:13 +0800 Subject: [PATCH 214/763] Register STILL_IMAGE_CAMERA_SECURE intent in the manifest. bug:7053266 Change-Id: I6468a82f5da5afb98316d52b31117f1cc4f82fb9 --- AndroidManifest.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 2ef8086c2..b48af2890 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -270,6 +270,10 @@ + + + + Date: Thu, 16 Aug 2012 10:41:57 +0800 Subject: [PATCH 215/763] Read thumbnail into ExifData Change-Id: Iccc0fbbda1734795ff431075bade700ca5076a08 --- src/com/android/gallery3d/exif/ExifData.java | 57 ++++++++++++++++++ .../android/gallery3d/exif/ExifReader.java | 14 ++++- .../gallery3d/exif/ExifReaderTest.java | 58 ++++++++++++++++++- 3 files changed, 126 insertions(+), 3 deletions(-) diff --git a/src/com/android/gallery3d/exif/ExifData.java b/src/com/android/gallery3d/exif/ExifData.java index 712698ef4..5b0e3d8e4 100644 --- a/src/com/android/gallery3d/exif/ExifData.java +++ b/src/com/android/gallery3d/exif/ExifData.java @@ -15,6 +15,9 @@ */ package com.android.gallery3d.exif; + +import java.util.ArrayList; + /** * This class stores the EXIF header in IFDs according to the JPEG specification. * It is the result produced by {@link ExifReader}. @@ -23,6 +26,8 @@ package com.android.gallery3d.exif; */ public class ExifData { private final IfdData[] mIfdDatas = new IfdData[IfdId.TYPE_IFD_COUNT]; + private byte[] mThumbnail; + private ArrayList mStripBytes = new ArrayList(); /** * Gets the IFD data of the specified IFD. @@ -44,4 +49,56 @@ public class ExifData { public void addIfdData(IfdData data) { mIfdDatas[data.getId()] = data; } + + /** + * Gets the compressed thumbnail. Returns null if there is no compressed thumbnail. + * + * @see #hasCompressedThumbnail() + */ + public byte[] getCompressedThumbnail() { + return mThumbnail; + } + + /** + * Sets the compressed thumbnail. + */ + public void setCompressedThumbnail(byte[] thumbnail) { + mThumbnail = thumbnail; + } + + /** + * Returns true it this header contains a compressed thumbnail. + */ + public boolean hasCompressedThumbnail() { + return mThumbnail != null; + } + + /** + * Adds an uncompressed strip. + */ + public void setStripBytes(int index, byte[] strip) { + if (index < mStripBytes.size()) { + mStripBytes.set(index, strip); + } else { + for (int i = mStripBytes.size(); i < index; i++) { + mStripBytes.add(null); + } + mStripBytes.add(strip); + } + } + + /** + * Gets the strip count + */ + public int getStripCount() { + return mStripBytes.size(); + } + + /** + * Gets the strip at the specified index. + * @exceptions #IndexOutOfBoundException + */ + public byte[] getStrip(int index) { + return mStripBytes.get(index); + } } \ No newline at end of file diff --git a/src/com/android/gallery3d/exif/ExifReader.java b/src/com/android/gallery3d/exif/ExifReader.java index 125b6c65e..c259461f2 100644 --- a/src/com/android/gallery3d/exif/ExifReader.java +++ b/src/com/android/gallery3d/exif/ExifReader.java @@ -24,11 +24,11 @@ import java.io.InputStream; */ public class ExifReader { /** - * Parse the inputStream and return all Exif data. + * Parses the inputStream and and returns the EXIF data in an {@link ExifData}. * @throws ExifInvalidFormatException * @throws IOException */ - public ExifData getExifData(InputStream inputStream) throws ExifInvalidFormatException, + public ExifData read(InputStream inputStream) throws ExifInvalidFormatException, IOException { ExifParser parser = ExifParser.parse(inputStream); ExifData exifData = new ExifData(); @@ -56,6 +56,16 @@ public class ExifReader { } exifData.getIfdData(tag.getIfd()).setTag(tag); break; + case ExifParser.EVENT_COMPRESSED_IMAGE: + byte buf[] = new byte[parser.getCompressedImageSize()]; + parser.read(buf); + exifData.setCompressedThumbnail(buf); + break; + case ExifParser.EVENT_UNCOMPRESSED_STRIP: + buf = new byte[parser.getStripSize()]; + parser.read(buf); + exifData.setStripBytes(parser.getStripIndex(), buf); + break; } event = parser.next(); } diff --git a/tests/src/com/android/gallery3d/exif/ExifReaderTest.java b/tests/src/com/android/gallery3d/exif/ExifReaderTest.java index c0c2f9f81..67e695682 100644 --- a/tests/src/com/android/gallery3d/exif/ExifReaderTest.java +++ b/tests/src/com/android/gallery3d/exif/ExifReaderTest.java @@ -17,6 +17,7 @@ package com.android.gallery3d.exif; import android.content.res.XmlResourceParser; +import android.graphics.BitmapFactory; import android.test.InstrumentationTestCase; import java.io.IOException; @@ -56,12 +57,67 @@ public class ExifReaderTest extends InstrumentationTestCase { public void testRead() throws ExifInvalidFormatException, IOException { ExifReader reader = new ExifReader(); - ExifData exifData = reader.getExifData(mImageInputStream); + ExifData exifData = reader.read(mImageInputStream); checkIfd(exifData.getIfdData(IfdId.TYPE_IFD_0), mIfd0Value); checkIfd(exifData.getIfdData(IfdId.TYPE_IFD_1), mIfd1Value); checkIfd(exifData.getIfdData(IfdId.TYPE_IFD_EXIF), mExifIfdValue); checkIfd(exifData.getIfdData(IfdId.TYPE_IFD_INTEROPERABILITY), mInteroperabilityIfdValue); + checkThumbnail(exifData); + } + + private void checkThumbnail(ExifData exifData) { + IfdData ifd1 = exifData.getIfdData(IfdId.TYPE_IFD_1); + if (ifd1 != null) { + if (ifd1.getTag(ExifTag.TIFF_TAG.TAG_COMPRESSION).getUnsignedShort() == + ExifTag.TIFF_TAG.COMPRESSION_JPEG) { + assertTrue(exifData.hasCompressedThumbnail()); + byte[] thumbnail = exifData.getCompressedThumbnail(); + assertTrue(BitmapFactory.decodeByteArray(thumbnail, 0, thumbnail.length) != null); + } else { + // Try to check the strip count with the formula provided by EXIF spec. + int planarType = ExifTag.TIFF_TAG.PLANAR_CONFIGURATION_CHUNKY; + ExifTag planarTag = ifd1.getTag(ExifTag.TIFF_TAG.TAG_PLANAR_CONFIGURATION); + if (planarTag != null) { + planarType = planarTag.getUnsignedShort(); + } + + ExifTag heightTag = ifd1.getTag(ExifTag.TIFF_TAG.TAG_IMAGE_HEIGHT); + ExifTag rowPerStripTag = ifd1.getTag(ExifTag.TIFF_TAG.TAG_ROWS_PER_STRIP); + + int imageLength = getUnsignedIntOrShort(heightTag); + int rowsPerStrip = getUnsignedIntOrShort(rowPerStripTag); + int stripCount = ifd1.getTag( + ExifTag.TIFF_TAG.TAG_STRIP_OFFSETS).getComponentCount(); + + if (planarType == ExifTag.TIFF_TAG.PLANAR_CONFIGURATION_CHUNKY) { + assertTrue(stripCount == (imageLength + rowsPerStrip - 1) / rowsPerStrip); + } else { + ExifTag samplePerPixelTag = ifd1.getTag(ExifTag.TIFF_TAG.TAG_SAMPLES_PER_PIXEL); + int samplePerPixel = samplePerPixelTag.getUnsignedShort(); + assertTrue(stripCount == + (imageLength + rowsPerStrip - 1) / rowsPerStrip * samplePerPixel); + } + + for (int i = 0; i < stripCount; i++) { + ExifTag byteCountTag = ifd1.getTag(ExifTag.TIFF_TAG.TAG_STRIP_BYTE_COUNTS); + if (byteCountTag.getDataType() == ExifTag.TYPE_UNSIGNED_SHORT) { + assertEquals(byteCountTag.getUnsignedShort(i), exifData.getStrip(i).length); + } else { + assertEquals( + byteCountTag.getUnsignedInt(i), exifData.getStrip(i).length); + } + } + } + } + } + + private int getUnsignedIntOrShort(ExifTag tag) { + if (tag.getDataType() == ExifTag.TYPE_UNSIGNED_SHORT) { + return tag.getUnsignedShort(); + } else { + return (int) tag.getUnsignedInt(); + } } private void checkIfd(IfdData ifd, HashMap ifdValue) { -- GitLab From b21b8e58a604f6c701245d84b141b5b87663192b Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Fri, 24 Aug 2012 12:25:57 +0800 Subject: [PATCH 216/763] Uses ActionBarSherlock in Gallery bug: 6927267 Change-Id: I1c22975d1a1f3a36510ad93e6a0cefea110ca38f --- .../android/gallery3d/common/ApiHelper.java | 16 -- .../gallery3d/common/HttpClientFactory.java | 2 +- .../com/android/gallery3d/common/Utils.java | 2 +- res/layout/action_bar_text.xml | 2 +- res/menu/movie.xml | 1 + res/menu/operation.xml | 1 + res/menu/photo.xml | 1 + res/values-v14/styles.xml | 2 +- .../actionbar/ActionBarInterface.java | 64 ------ .../gallery3d/actionbar/ActionBarUtils.java | 40 ---- .../actionbar/ActionModeInterface.java | 46 ----- .../gallery3d/actionbar/MenuHolder.java | 25 --- .../gallery3d/actionbar/SimpleActionBar.java | 136 ------------- .../actionbar/SimpleActionBarView.java | 54 ----- .../gallery3d/actionbar/SimpleActionMode.java | 44 ---- .../gallery3d/actionbar/SimpleMenu.java | 87 -------- .../actionbar/SimpleMenuInflater.java | 132 ------------ .../actionbar/SystemActionBarWrapper.java | 190 ------------------ .../actionbar/SystemActionModeWrapper.java | 148 -------------- .../app/AbstractGalleryActivity.java | 27 +-- .../android/gallery3d/app/ActivityState.java | 22 +- .../gallery3d/app/AlbumDataLoader.java | 2 +- src/com/android/gallery3d/app/AlbumPage.java | 38 ++-- .../gallery3d/app/AlbumSetDataLoader.java | 2 +- .../android/gallery3d/app/AlbumSetPage.java | 47 ++--- src/com/android/gallery3d/app/CropImage.java | 15 +- .../android/gallery3d/app/FilterUtils.java | 20 +- .../gallery3d/app/GalleryActionBar.java | 65 +++--- .../gallery3d/app/GalleryActivity.java | 27 --- .../android/gallery3d/app/MovieActivity.java | 18 +- .../gallery3d/app/PhotoDataAdapter.java | 2 +- src/com/android/gallery3d/app/PhotoPage.java | 18 +- .../android/gallery3d/app/PickerActivity.java | 8 +- .../gallery3d/app/SinglePhotoDataAdapter.java | 2 +- .../android/gallery3d/app/StateManager.java | 22 +- .../gallery3d/ui/ActionModeHandler.java | 90 +++++---- .../gallery3d/ui/AlbumSetSlidingWindow.java | 4 +- .../gallery3d/ui/AlbumSetSlotRenderer.java | 11 +- .../gallery3d/ui/AlbumSlidingWindow.java | 4 +- .../gallery3d/ui/AlbumSlotRenderer.java | 10 +- .../gallery3d/ui/CacheStorageUsageInfo.java | 6 +- src/com/android/gallery3d/ui/CropView.java | 6 +- .../gallery3d/ui/DetailsAddressResolver.java | 6 +- .../android/gallery3d/ui/DetailsHelper.java | 6 +- .../gallery3d/ui/DialogDetailsView.java | 21 +- .../gallery3d/ui/ImportCompleteListener.java | 6 +- .../gallery3d/ui/ManageCacheDrawer.java | 6 +- .../android/gallery3d/ui/MenuExecutor.java | 50 ++--- src/com/android/gallery3d/ui/PhotoView.java | 4 +- .../gallery3d/ui/SelectionManager.java | 6 +- src/com/android/gallery3d/ui/SlotView.java | 10 +- 51 files changed, 274 insertions(+), 1300 deletions(-) delete mode 100644 src/com/android/gallery3d/actionbar/ActionBarInterface.java delete mode 100644 src/com/android/gallery3d/actionbar/ActionBarUtils.java delete mode 100644 src/com/android/gallery3d/actionbar/ActionModeInterface.java delete mode 100644 src/com/android/gallery3d/actionbar/MenuHolder.java delete mode 100644 src/com/android/gallery3d/actionbar/SimpleActionBar.java delete mode 100644 src/com/android/gallery3d/actionbar/SimpleActionBarView.java delete mode 100644 src/com/android/gallery3d/actionbar/SimpleActionMode.java delete mode 100644 src/com/android/gallery3d/actionbar/SimpleMenu.java delete mode 100644 src/com/android/gallery3d/actionbar/SimpleMenuInflater.java delete mode 100644 src/com/android/gallery3d/actionbar/SystemActionBarWrapper.java delete mode 100644 src/com/android/gallery3d/actionbar/SystemActionModeWrapper.java delete mode 100644 src/com/android/gallery3d/app/GalleryActivity.java diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java index 03181ca64..c726719a8 100644 --- a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java +++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java @@ -16,7 +16,6 @@ package com.android.gallery3d.common; -import android.app.Activity; import android.app.admin.DevicePolicyManager; import android.content.ComponentName; import android.hardware.Camera; @@ -75,9 +74,6 @@ public class ApiHelper { public static final boolean HAS_AUTO_FOCUS_MOVE_CALLBACK = Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN; - public static final boolean HAS_ACTIVITY_INVALIDATE_OPTIONS_MENU = - hasMethod(Activity.class, "invalidateOptionsMenu"); - public static final boolean HAS_REMOTE_VIEWS_SERVICE = Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB; @@ -130,9 +126,6 @@ public class ApiHelper { public static final boolean HAS_MOTION_EVENT_TRANSFORM = Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB; - public static final boolean HAS_SHARE_ACTION_PROVIDER = - Build.VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH; - public static final boolean HAS_EFFECTS_RECORDING = false; public static final boolean HAS_GET_SUPPORTED_VIDEO_SIZE = @@ -141,21 +134,12 @@ public class ApiHelper { public static final boolean HAS_SET_ICON_ATTRIBUTE = Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB; - public static final boolean HAS_ACTION_BAR_SET_LOGO = - Build.VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH; - - public static final boolean HAS_ACTION_BAR_SET_HOME_BUTTON_ENABLED = - Build.VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH; - public static final boolean HAS_MEDIA_PROVIDER_FILES_TABLE = Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB; public static final boolean HAS_SURFACE_TEXTURE_RECORDING = Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN; - public static final boolean HAS_MENU_ITEM_SHOW_AS_ACTION = - Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB; - public static final boolean HAS_ACTION_BAR = Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB; diff --git a/gallerycommon/src/com/android/gallery3d/common/HttpClientFactory.java b/gallerycommon/src/com/android/gallery3d/common/HttpClientFactory.java index 9e327aa51..18b7a8875 100644 --- a/gallerycommon/src/com/android/gallery3d/common/HttpClientFactory.java +++ b/gallerycommon/src/com/android/gallery3d/common/HttpClientFactory.java @@ -121,7 +121,7 @@ public final class HttpClientFactory { Build.DEVICE, Build.MODEL, Build.ID, - Build.VERSION.SDK, + Build.VERSION.SDK_INT, Build.VERSION.RELEASE, Build.VERSION.INCREMENTAL); } diff --git a/gallerycommon/src/com/android/gallery3d/common/Utils.java b/gallerycommon/src/com/android/gallery3d/common/Utils.java index 391b22535..f5a266706 100644 --- a/gallerycommon/src/com/android/gallery3d/common/Utils.java +++ b/gallerycommon/src/com/android/gallery3d/common/Utils.java @@ -310,7 +310,7 @@ public class Utils { Build.DEVICE, Build.MODEL, Build.ID, - Build.VERSION.SDK, + Build.VERSION.SDK_INT, Build.VERSION.RELEASE, Build.VERSION.INCREMENTAL); } diff --git a/res/layout/action_bar_text.xml b/res/layout/action_bar_text.xml index 7fccf0268..bded20102 100644 --- a/res/layout/action_bar_text.xml +++ b/res/layout/action_bar_text.xml @@ -16,7 +16,7 @@ diff --git a/res/menu/operation.xml b/res/menu/operation.xml index 918c532cc..aeef78fdd 100644 --- a/res/menu/operation.xml +++ b/res/menu/operation.xml @@ -23,6 +23,7 @@ android:icon="@drawable/ic_menu_share_holo_light" android:title="@string/share" android:visible="false" + android:actionProviderClass="com.actionbarsherlock.widget.ShareActionProvider" android:showAsAction="ifRoom"> - diff --git a/src/com/android/gallery3d/actionbar/ActionBarInterface.java b/src/com/android/gallery3d/actionbar/ActionBarInterface.java deleted file mode 100644 index db732483f..000000000 --- a/src/com/android/gallery3d/actionbar/ActionBarInterface.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2012 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.android.gallery3d.actionbar; - -import android.content.Intent; -import android.graphics.drawable.Drawable; -import android.view.Menu; -import android.widget.SpinnerAdapter; - -public interface ActionBarInterface extends MenuHolder { - // These values are copied from android.app.ActionBar - public static final int NAVIGATION_MODE_LIST = 1; - public static final int NAVIGATION_MODE_STANDARD = 0; - - // These values are copied from android.app.ActionBar - public static final int DISPLAY_HOME_AS_UP = 4; - public static final int DISPLAY_SHOW_TITLE = 8; - - public static interface OnNavigationListener { - public boolean onNavigationItemSelected(int itemPosition, long itemId); - } - - public static interface OnMenuVisibilityListener { - public void onMenuVisibilityChanged(boolean isVisible); - } - - public int getHeight(); - - public void setListNavigationCallbacks( - SpinnerAdapter adapter, OnNavigationListener listener); - public void setNavigationMode(int mode); - public void setSelectedNavigationItem(int index); - - public void addOnMenuVisibilityListener(OnMenuVisibilityListener l); - public void removeOnMenuVisibilityListener(OnMenuVisibilityListener l); - - public void setDisplayOptions(int options, int mask); - public void setHomeButtonEnabled(boolean enabled); - public void setTitle(String title); - public void setSubtitle(String subtitle); - public void show(); - public void hide(); - - public void setShareIntent(Intent intent); - - public void setLogo(Drawable logo); - - public boolean createActionMenu(Menu menu, int menuResId); - public boolean hasShareMenuItem(); -} diff --git a/src/com/android/gallery3d/actionbar/ActionBarUtils.java b/src/com/android/gallery3d/actionbar/ActionBarUtils.java deleted file mode 100644 index 4df8d5c10..000000000 --- a/src/com/android/gallery3d/actionbar/ActionBarUtils.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2012 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.android.gallery3d.actionbar; - -import android.app.Activity; - -import com.android.gallery3d.common.ApiHelper; - -public class ActionBarUtils { - - public static ActionBarInterface getActionBar(Activity activity) { - if (ApiHelper.HAS_ACTION_BAR) { - if (activity.getActionBar() == null) return null; - return new SystemActionBarWrapper(activity); - } else { - return new SimpleActionBar(activity); - } - } - - public static ActionModeInterface startActionMode( - Activity activity, ActionModeInterface.Callback callback) { - return ApiHelper.HAS_ACTION_BAR - ? new SystemActionModeWrapper(activity, callback) - : new SimpleActionMode(); - } -} diff --git a/src/com/android/gallery3d/actionbar/ActionModeInterface.java b/src/com/android/gallery3d/actionbar/ActionModeInterface.java deleted file mode 100644 index 32cf815f3..000000000 --- a/src/com/android/gallery3d/actionbar/ActionModeInterface.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2012 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.android.gallery3d.actionbar; - -import android.content.Intent; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; - -public interface ActionModeInterface extends MenuHolder { - - public static interface Callback { - - public boolean onCreateActionMode(ActionModeInterface mode, Menu menu); - - public void onDestroyActionMode(ActionModeInterface mode); - - public boolean onActionItemClicked(ActionModeInterface mode, MenuItem item); - } - - public static interface OnShareTargetSelectedListener { - public boolean onShareTargetSelected(Intent shareIntent); - } - - public void inflateMenu(int operation); - public void setCustomView(View view); - public void finish(); - - public void setShareIntent(Intent intent); - public boolean hasShareButton(); - public void setOnShareTargetSelectedListener(OnShareTargetSelectedListener listener); -} diff --git a/src/com/android/gallery3d/actionbar/MenuHolder.java b/src/com/android/gallery3d/actionbar/MenuHolder.java deleted file mode 100644 index 2001d087a..000000000 --- a/src/com/android/gallery3d/actionbar/MenuHolder.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2012 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.android.gallery3d.actionbar; - -import android.content.Intent; - -public interface MenuHolder { - public void setMenuItemVisible(int menuItemId, boolean visible); - public void setMenuItemTitle(int menuItemId, String title); - public void setMenuItemIntent(int menuItemId, Intent intent); -} diff --git a/src/com/android/gallery3d/actionbar/SimpleActionBar.java b/src/com/android/gallery3d/actionbar/SimpleActionBar.java deleted file mode 100644 index 8d709a946..000000000 --- a/src/com/android/gallery3d/actionbar/SimpleActionBar.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (C) 2012 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.android.gallery3d.actionbar; - -import android.app.Activity; -import android.content.Context; -import android.content.Intent; -import android.graphics.drawable.Drawable; -import android.view.Menu; -import android.view.ViewGroup.LayoutParams; -import android.widget.FrameLayout; -import android.widget.SpinnerAdapter; - -import com.android.gallery3d.R; - -public class SimpleActionBar implements ActionBarInterface { - private final FrameLayout mHeaderView; - private final SimpleActionBarView mActionBar; - private final SimpleMenu mOptionsMenu = new SimpleMenu(); - private final Context mContext; - - public SimpleActionBar(Activity activity) { - mContext = activity; - mHeaderView = (FrameLayout) activity.findViewById(R.id.header); - mActionBar = new SimpleActionBarView(activity, null); - - if (mHeaderView != null) { - FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( - LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); - - // Unhide the next line to show the menu button - // mHeaderView.setVisibility(View.VISIBLE); - mHeaderView.addView(mActionBar, params); - } - } - - @Override - public void setMenuItemVisible(int menuItemId, boolean visible) { - mOptionsMenu.setMenuItemVisible(menuItemId, visible); - } - - @Override - public void setMenuItemTitle(int menuItemId, String title) { - mOptionsMenu.setMenuItemTitle(menuItemId, title); - } - - @Override - public void setMenuItemIntent(int menuItemId, Intent intent) { - mOptionsMenu.setMenuItemIntent(menuItemId, intent); - } - - @Override - public int getHeight() { - return mActionBar.getHeight(); - } - - @Override - public void setListNavigationCallbacks(SpinnerAdapter adapter, OnNavigationListener listener) { - } - - @Override - public void setNavigationMode(int mode) { - } - - @Override - public void setSelectedNavigationItem(int index) { - } - - @Override - public void addOnMenuVisibilityListener(OnMenuVisibilityListener l) { - } - - @Override - public void removeOnMenuVisibilityListener(OnMenuVisibilityListener l) { - } - - @Override - public void setDisplayOptions(int options, int mask) { - } - - @Override - public void setHomeButtonEnabled(boolean enabled) { - } - - @Override - public void setTitle(String title) { - } - - @Override - public void setSubtitle(String subtitle) { - } - - @Override - public void show() { - } - - @Override - public void hide() { - } - - @Override - public void setShareIntent(Intent intent) { - } - - @Override - public void setLogo(Drawable logo) { - } - - @Override - public boolean createActionMenu(Menu menu, int menuResId) { - SimpleMenuInflater inflater = new SimpleMenuInflater(mContext); - mOptionsMenu.clear(); - inflater.inflate(mOptionsMenu, menuResId); - mActionBar.setOptionsMenu(mOptionsMenu); - return false; - } - - @Override - public boolean hasShareMenuItem() { - return false; - } -} diff --git a/src/com/android/gallery3d/actionbar/SimpleActionBarView.java b/src/com/android/gallery3d/actionbar/SimpleActionBarView.java deleted file mode 100644 index 94ba56b0b..000000000 --- a/src/com/android/gallery3d/actionbar/SimpleActionBarView.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2012 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.android.gallery3d.actionbar; -import android.content.Context; -import android.util.AttributeSet; -import android.view.LayoutInflater; -import android.view.View; -import android.widget.Button; -import android.widget.LinearLayout; - -import com.android.gallery3d.R; -import com.android.gallery3d.ui.PopupList; - - -public class SimpleActionBarView extends LinearLayout { - - private PopupList mPopupList; - - public SimpleActionBarView(Context context, AttributeSet attrs) { - super(context, attrs); - LayoutInflater.from(context).inflate(R.layout.simple_action_bar, this); - Button button = (Button) findViewById(R.id.menu_button); - button.setText("Menu"); - mPopupList = new PopupList(context, button); - button.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View view) { - mPopupList.show(); - } - }); - } - - public void setOptionsMenu(SimpleMenu menu) { - mPopupList.clearItems(); - for (int i = 0, n = menu.getItemCount(); i < n; ++i) { - SimpleMenu.Item item = menu.getItem(i); - mPopupList.addItem(item.id, item.title); - } - } -} diff --git a/src/com/android/gallery3d/actionbar/SimpleActionMode.java b/src/com/android/gallery3d/actionbar/SimpleActionMode.java deleted file mode 100644 index 33733d173..000000000 --- a/src/com/android/gallery3d/actionbar/SimpleActionMode.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.android.gallery3d.actionbar; - -import android.content.Intent; -import android.view.View; - -public class SimpleActionMode implements ActionModeInterface { - - @Override - public void setMenuItemVisible(int menuItemId, boolean visible) { - } - - @Override - public void setMenuItemTitle(int menuItemId, String title) { - } - - @Override - public void setMenuItemIntent(int menuItemId, Intent intent) { - } - - @Override - public void inflateMenu(int operation) { - } - - @Override - public void setCustomView(View view) { - } - - @Override - public void finish() { - } - - @Override - public void setShareIntent(Intent intent) { - } - - @Override - public boolean hasShareButton() { - return false; - } - - @Override - public void setOnShareTargetSelectedListener(OnShareTargetSelectedListener listener) { - } -} diff --git a/src/com/android/gallery3d/actionbar/SimpleMenu.java b/src/com/android/gallery3d/actionbar/SimpleMenu.java deleted file mode 100644 index 8bc55808a..000000000 --- a/src/com/android/gallery3d/actionbar/SimpleMenu.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2012 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.android.gallery3d.actionbar; - -import android.content.Intent; - -import java.util.ArrayList; - -public class SimpleMenu implements MenuHolder { - // These values are copied from MenuItem in HoneyComb - private static final int SHOW_AS_ACTION_NEVER = 0; - private static final int SHOW_AS_ACTION_ALWAYS = 1; - private static final int SHOW_AS_ACTION_IFROOM = 2; - private static final int SHOW_AS_ACTION_WITH_TEXT = 4; - - // A bit mask to get WHEN to show as action. It is one of the following - // values: SHOW_AS_ACTION_NEVER, SHOW_AS_ACTION_ALWAYS, or - // SHOW_AS_ACTION_IFROOM. - private static final int SHOW_AS_ACTION_MASK = 0x03; - - public static class Item { - public int id; - public int iconId; - public String title; - public boolean visible; - public int showAsAction; - public Intent intent; - } - - private ArrayList mItems = new ArrayList(); - - public void clear() { - mItems.clear(); - } - - public void addItem(Item item) { - mItems.add(item); - } - - @Override - public void setMenuItemVisible(int menuItemId, boolean visible) { - Item item = findItem(menuItemId); - if (item != null) item.visible = visible; - } - - public int getItemCount() { - return mItems.size(); - } - - public Item getItem(int index) { - return mItems.get(index); - } - - public Item findItem(int menuItemId) { - for (int i = 0, n = mItems.size(); i < n; ++i) { - Item item = mItems.get(i); - if (item.id == menuItemId) return item; - } - return null; - } - - @Override - public void setMenuItemTitle(int menuItemId, String title) { - Item item = findItem(menuItemId); - if (item != null) item.title = title; - } - - @Override - public void setMenuItemIntent(int menuItemId, Intent intent) { - Item item = findItem(menuItemId); - if (item != null) item.intent = intent; - } -} diff --git a/src/com/android/gallery3d/actionbar/SimpleMenuInflater.java b/src/com/android/gallery3d/actionbar/SimpleMenuInflater.java deleted file mode 100644 index 885a4d3bc..000000000 --- a/src/com/android/gallery3d/actionbar/SimpleMenuInflater.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (C) 2012 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.android.gallery3d.actionbar; - -import android.content.Context; -import android.content.res.Resources; -import android.content.res.XmlResourceParser; -import android.util.AttributeSet; -import android.util.Xml; -import android.view.InflateException; - -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - -import java.io.IOException; - -public class SimpleMenuInflater { - - private static final String TAG_MENU = "menu"; - private static final String TAG_ITEM = "item"; - - private final Context mContext; - - public SimpleMenuInflater(Context context) { - mContext = context; - } - - public SimpleMenu inflate(SimpleMenu menu, int menuRes) throws InflateException { - XmlResourceParser parser = mContext.getResources().getXml(menuRes); - try { - return inflateInternal(menu, parser); - } catch (XmlPullParserException e) { - throw new InflateException(e); - } catch (IOException e) { - throw new InflateException(e); - } finally { - if (parser != null) parser.close(); - } - } - - private SimpleMenu inflateInternal(SimpleMenu menu, XmlPullParser parser) - throws XmlPullParserException, IOException { - int eventType = parser.getEventType(); - do { - if (eventType == XmlPullParser.START_TAG) { - String tagName = parser.getName(); - if (TAG_MENU.equals(tagName)) { - eventType = parser.next(); - break; - } - throw new RuntimeException("unexpected tag: " + tagName); - } - eventType = parser.next(); - } while (eventType != XmlPullParser.END_DOCUMENT); - - if (menu == null) menu = new SimpleMenu(); - AttributeSet attrs = Xml.asAttributeSet(parser); - - boolean reachedEndOfMenu = false; - while (!reachedEndOfMenu) { - switch (eventType) { - case XmlPullParser.START_TAG: { - String tagName = parser.getName(); - if (TAG_ITEM.equals(tagName)) { - menu.addItem(parseItem(attrs)); - } else if (TAG_MENU.equals(tagName)) { - throw new RuntimeException("nested menu not supported"); - } else { - // ignore all other tags - parser.next(); - } - break; - } - case XmlPullParser.END_TAG: { - String tagName = parser.getName(); - if (TAG_MENU.equals(tagName)) { - reachedEndOfMenu = true; - break; - } - break; - } - case XmlPullParser.END_DOCUMENT: { - throw new RuntimeException("unexpected end of document"); - } - } - eventType = parser.next(); - } - return menu; - } - - private static final String ATTR_ID = "id"; - private static final String ATTR_ICON = "icon"; - private static final String ATTR_TITLE = "title"; - private static final String ATTR_VISIBLE = "visible"; - private static final String ATTR_SHOW_AS_ACTION = "showAsAction"; - - private SimpleMenu.Item parseItem(AttributeSet attrs) { - SimpleMenu.Item item = new SimpleMenu.Item(); - Resources res = mContext.getResources(); - for (int i = 0, n = attrs.getAttributeCount(); i < n; ++i) { - String attrName = attrs.getAttributeName(i); - if (ATTR_ID.equals(attrName)) { - item.id = attrs.getAttributeResourceValue(i, 0); - } else if (ATTR_ICON.equals(attrName)) { - item.iconId = attrs.getAttributeResourceValue(i, 0); - } else if (ATTR_TITLE.equals(attrName)) { - int id = attrs.getAttributeResourceValue(i, 0); - item.title = id == 0 ? null : res.getString(id); - } else if (ATTR_VISIBLE.equals(attrName)) { - item.visible = attrs.getAttributeBooleanValue(i, true); - } else if (ATTR_SHOW_AS_ACTION.equals(attrName)) { - item.showAsAction = attrs.getAttributeIntValue(i, 0); - } - } - return item; - } - -} diff --git a/src/com/android/gallery3d/actionbar/SystemActionBarWrapper.java b/src/com/android/gallery3d/actionbar/SystemActionBarWrapper.java deleted file mode 100644 index 2d70aa609..000000000 --- a/src/com/android/gallery3d/actionbar/SystemActionBarWrapper.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (C) 2012 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.android.gallery3d.actionbar; - -import android.annotation.TargetApi; -import android.app.ActionBar; -import android.app.Activity; -import android.content.Intent; -import android.graphics.drawable.Drawable; -import android.view.Menu; -import android.view.MenuItem; -import android.widget.ShareActionProvider; -import android.widget.SpinnerAdapter; - -import com.android.gallery3d.R; -import com.android.gallery3d.common.ApiHelper; -import com.android.gallery3d.common.Utils; -import com.android.gallery3d.util.Holder; - -import java.util.HashMap; - -@TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB) -public class SystemActionBarWrapper implements ActionBarInterface { - private final ActionBar mActionBar; - private final Activity mActivity; - private final HashMap mListenerMap = new HashMap(); - - private Menu mMenu; - private MenuItem mShareMenuItem; - private Holder mShareActionProvider = new Holder(); - - @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) - public SystemActionBarWrapper(Activity activity) { - mActivity = activity; - mActionBar = activity.getActionBar(); - if (ApiHelper.HAS_SHARE_ACTION_PROVIDER) { - mShareActionProvider.set(new ShareActionProvider(activity)); - } - } - - @Override - public int getHeight() { - return mActionBar.getHeight(); - } - - @Override - public void setListNavigationCallbacks( - SpinnerAdapter adapter, final OnNavigationListener listener) { - mActionBar.setListNavigationCallbacks(adapter, new ActionBar.OnNavigationListener() { - @Override - public boolean onNavigationItemSelected(int itemPosition, long itemId) { - return listener.onNavigationItemSelected(itemPosition, itemId); - } - }); - } - - @Override - public void setNavigationMode(int mode) { - mActionBar.setNavigationMode(mode); - } - - @Override - public void setSelectedNavigationItem(int index) { - mActionBar.setSelectedNavigationItem(index); - } - - @Override - public void addOnMenuVisibilityListener(final OnMenuVisibilityListener l) { - ActionBar.OnMenuVisibilityListener wrapper = - new ActionBar.OnMenuVisibilityListener() { - @Override - public void onMenuVisibilityChanged(boolean isVisible) { - l.onMenuVisibilityChanged(isVisible); - } - }; - Utils.assertTrue(mListenerMap.put(System.identityHashCode(l), wrapper) == null); - mActionBar.addOnMenuVisibilityListener(wrapper); - } - - @Override - public void removeOnMenuVisibilityListener(OnMenuVisibilityListener l) { - ActionBar.OnMenuVisibilityListener wrapper = (ActionBar.OnMenuVisibilityListener) - mListenerMap.remove(System.identityHashCode(l)); - if (wrapper != null) mActionBar.removeOnMenuVisibilityListener(wrapper); - } - - @Override - public void setDisplayOptions(int options, int mask) { - mActionBar.setDisplayOptions(options, mask); - } - - @Override - @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) - public void setHomeButtonEnabled(boolean enabled) { - if (ApiHelper.HAS_ACTION_BAR_SET_HOME_BUTTON_ENABLED) { - mActionBar.setHomeButtonEnabled(enabled); - } - } - - @Override - public void setTitle(String title) { - mActionBar.setTitle(title); - } - - @Override - @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) - public void setLogo(Drawable logo) { - if (ApiHelper.HAS_ACTION_BAR_SET_LOGO) { - mActionBar.setLogo(logo); - } - } - - @Override - public void setSubtitle(String subtitle) { - mActionBar.setSubtitle(subtitle); - } - - @Override - public void show() { - mActionBar.show(); - } - - @Override - public void hide() { - mActionBar.hide(); - } - - @Override - @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) - public void setShareIntent(Intent intent) { - if (mShareMenuItem != null) { - mShareMenuItem.setEnabled(intent != null); - if (ApiHelper.HAS_SHARE_ACTION_PROVIDER) { - mShareActionProvider.get().setShareIntent(intent); - } - } - } - - @Override - @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) - public boolean createActionMenu(Menu menu, int menuRes) { - mActivity.getMenuInflater().inflate(menuRes, menu); - mMenu = menu; - mShareMenuItem = menu.findItem(R.id.action_share); - if (mShareMenuItem != null && ApiHelper.HAS_SHARE_ACTION_PROVIDER) { - mShareMenuItem.setActionProvider(mShareActionProvider.get()); - } - return true; - } - - @Override - public boolean hasShareMenuItem() { - return mShareMenuItem != null; - } - - @Override - public void setMenuItemVisible(int menuItemId, boolean visible) { - if (mMenu == null) return; - MenuItem item = mMenu.findItem(menuItemId); - if (item != null) item.setVisible(visible); - } - - @Override - public void setMenuItemTitle(int menuItemId, String title) { - if (mMenu == null) return; - MenuItem item = mMenu.findItem(menuItemId); - if (item != null) item.setTitle(title); - } - - @Override - public void setMenuItemIntent(int menuItemId, Intent intent) { - if (mMenu == null) return; - MenuItem item = mMenu.findItem(menuItemId); - if (item != null) item.setIntent(intent); - } -} \ No newline at end of file diff --git a/src/com/android/gallery3d/actionbar/SystemActionModeWrapper.java b/src/com/android/gallery3d/actionbar/SystemActionModeWrapper.java deleted file mode 100644 index 202a58568..000000000 --- a/src/com/android/gallery3d/actionbar/SystemActionModeWrapper.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (C) 2012 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.android.gallery3d.actionbar; - -import android.annotation.TargetApi; -import android.app.Activity; -import android.content.Intent; -import android.view.ActionMode; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.widget.ShareActionProvider; - -import com.android.gallery3d.R; -import com.android.gallery3d.common.ApiHelper; -import com.android.gallery3d.common.Utils; -import com.android.gallery3d.util.Holder; - -@TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB) -public class SystemActionModeWrapper implements ActionModeInterface { - private ActionMode mActionMode; - private Menu mMenu; - private MenuItem mShareMenuItem; - private Holder mShareActionProvider = new Holder(); - - @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) - public SystemActionModeWrapper(Activity activity, ActionModeInterface.Callback callback) { - if (ApiHelper.HAS_SHARE_ACTION_PROVIDER) { - mShareActionProvider.set(new ShareActionProvider(activity)); - } - // mActionMode will be set in callback.onCreateActionMode - activity.startActionMode(new CallbackWrapper(callback)); - } - - private class CallbackWrapper implements ActionMode.Callback { - ActionModeInterface.Callback mActual; - - public CallbackWrapper(Callback callback) { - mActual = callback; - } - - @Override - public boolean onCreateActionMode(ActionMode mode, Menu menu) { - mMenu = menu; - mActionMode = mode; - return mActual.onCreateActionMode(SystemActionModeWrapper.this, menu); - } - - @Override - public boolean onPrepareActionMode(ActionMode mode, Menu menu) { - // return true to turn on the system action mode - return true; - } - - @Override - public boolean onActionItemClicked(ActionMode mode, MenuItem item) { - return mActual.onActionItemClicked(SystemActionModeWrapper.this, item); - } - - @Override - public void onDestroyActionMode(ActionMode mode) { - mActual.onDestroyActionMode(SystemActionModeWrapper.this); - } - } - - @Override - public void setCustomView(View view) { - mActionMode.setCustomView(view); - } - - @Override - public void finish() { - mActionMode.finish(); - } - - @Override - @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) - public void inflateMenu(int menuRes) { - Utils.assertTrue(mMenu != null); - mActionMode.getMenuInflater().inflate(menuRes, mMenu); - mShareMenuItem = mMenu.findItem(R.id.action_share); - if (mShareMenuItem != null && ApiHelper.HAS_SHARE_ACTION_PROVIDER) { - mShareMenuItem.setActionProvider(mShareActionProvider.get()); - } - } - - @Override - @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) - public void setShareIntent(Intent shareIntent) { - if (mShareMenuItem != null) { - mShareMenuItem.setEnabled(shareIntent != null); - if (ApiHelper.HAS_SHARE_ACTION_PROVIDER) { - mShareActionProvider.get().setShareIntent(shareIntent); - } - } - } - - @Override - public boolean hasShareButton() { - return mShareMenuItem != null; - } - - @Override - @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) - public void setOnShareTargetSelectedListener(final OnShareTargetSelectedListener listener) { - if (mShareActionProvider.get() == null) return; - - mShareActionProvider.get().setOnShareTargetSelectedListener( - new ShareActionProvider.OnShareTargetSelectedListener() { - @Override - public boolean onShareTargetSelected(ShareActionProvider source, Intent intent) { - return listener.onShareTargetSelected(intent); - } - }); - } - - @Override - public void setMenuItemVisible(int menuItemId, boolean visible) { - MenuItem item = mMenu.findItem(menuItemId); - if (item != null) item.setVisible(visible); - } - - @Override - public void setMenuItemTitle(int menuItemId, String title) { - MenuItem item = mMenu.findItem(menuItemId); - if (item != null) item.setTitle(title); - } - - @Override - public void setMenuItemIntent(int menuItemId, Intent intent) { - MenuItem item = mMenu.findItem(menuItemId); - if (item != null) item.setIntent(intent); - } -} diff --git a/src/com/android/gallery3d/app/AbstractGalleryActivity.java b/src/com/android/gallery3d/app/AbstractGalleryActivity.java index 6b0b106aa..b11db39a1 100644 --- a/src/com/android/gallery3d/app/AbstractGalleryActivity.java +++ b/src/com/android/gallery3d/app/AbstractGalleryActivity.java @@ -17,7 +17,6 @@ package com.android.gallery3d.app; import android.annotation.TargetApi; -import android.app.Activity; import android.app.AlertDialog; import android.content.BroadcastReceiver; import android.content.Context; @@ -28,11 +27,12 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.res.Configuration; import android.os.Bundle; -import android.view.Menu; -import android.view.MenuItem; import android.view.Window; import android.view.WindowManager; +import com.actionbarsherlock.app.SherlockActivity; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuItem; import com.android.gallery3d.R; import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.data.BitmapPool; @@ -42,7 +42,7 @@ import com.android.gallery3d.ui.GLRoot; import com.android.gallery3d.ui.GLRootView; import com.android.gallery3d.util.ThreadPool; -public class AbstractGalleryActivity extends Activity implements GalleryActivity { +public class AbstractGalleryActivity extends SherlockActivity implements GalleryContext { @SuppressWarnings("unused") private static final String TAG = "AbstractGalleryActivity"; private GLRootView mGLRootView; @@ -88,26 +88,12 @@ public class AbstractGalleryActivity extends Activity implements GalleryActivity toggleStatusBarByOrientation(); } - private Menu mOptionsMenu; - @Override public boolean onCreateOptionsMenu(Menu menu) { - mOptionsMenu = menu; super.onCreateOptionsMenu(menu); return getStateManager().createOptionsMenu(menu); } - @Override - @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB) - public void invalidateOptionsMenu() { - if (ApiHelper.HAS_ACTIVITY_INVALIDATE_OPTIONS_MENU) { - super.invalidateOptionsMenu(); - } else if (mOptionsMenu != null) { - mOptionsMenu.clear(); - getStateManager().createOptionsMenu(mOptionsMenu); - } - } - @Override public Context getAndroidContext() { return this; @@ -123,7 +109,6 @@ public class AbstractGalleryActivity extends Activity implements GalleryActivity return ((GalleryApp) getApplication()).getThreadPool(); } - @Override public synchronized StateManager getStateManager() { if (mStateManager == null) { mStateManager = new StateManager(this); @@ -131,12 +116,10 @@ public class AbstractGalleryActivity extends Activity implements GalleryActivity return mStateManager; } - @Override public GLRoot getGLRoot() { return mGLRootView; } - @Override public OrientationManager getOrientationManager() { return mOrientationManager; } @@ -272,7 +255,6 @@ public class AbstractGalleryActivity extends Activity implements GalleryActivity } } - @Override public GalleryActionBar getGalleryActionBar() { if (mActionBar == null) { mActionBar = new GalleryActionBar(this); @@ -307,7 +289,6 @@ public class AbstractGalleryActivity extends Activity implements GalleryActivity } } - @Override public TransitionStore getTransitionStore() { return mTransitionStore; } diff --git a/src/com/android/gallery3d/app/ActivityState.java b/src/com/android/gallery3d/app/ActivityState.java index a86351b66..aef1ee1a6 100644 --- a/src/com/android/gallery3d/app/ActivityState.java +++ b/src/com/android/gallery3d/app/ActivityState.java @@ -16,7 +16,6 @@ package com.android.gallery3d.app; -import android.app.ActionBar; import android.app.Activity; import android.content.BroadcastReceiver; import android.content.ContentResolver; @@ -28,14 +27,15 @@ import android.os.BatteryManager; import android.os.Bundle; import android.provider.Settings; import android.provider.Settings.SettingNotFoundException; -import android.view.Menu; -import android.view.MenuItem; import android.view.Window; import android.view.WindowManager; +import com.actionbarsherlock.app.ActionBar; +import com.actionbarsherlock.app.SherlockActivity; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; import com.android.gallery3d.R; -import com.android.gallery3d.actionbar.ActionBarInterface; -import com.android.gallery3d.actionbar.ActionBarUtils; import com.android.gallery3d.ui.GLView; import com.android.gallery3d.util.GalleryUtils; @@ -51,7 +51,7 @@ abstract public class ActivityState { | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED ); - protected GalleryActivity mActivity; + protected AbstractGalleryActivity mActivity; protected Bundle mData; protected int mFlags; @@ -78,7 +78,7 @@ abstract public class ActivityState { mActivity.getGLRoot().setContentPane(content); } - void initialize(GalleryActivity activity, Bundle data) { + void initialize(AbstractGalleryActivity activity, Bundle data) { mActivity = activity; mData = data; mContentResolver = activity.getAndroidContext().getContentResolver(); @@ -160,8 +160,8 @@ abstract public class ActivityState { // should only be called by StateManager void resume() { - AbstractGalleryActivity activity = (AbstractGalleryActivity) mActivity; - ActionBarInterface actionBar = ActionBarUtils.getActionBar(activity); + AbstractGalleryActivity activity = mActivity; + ActionBar actionBar = ((SherlockActivity) activity).getSupportActionBar(); if (actionBar != null) { if ((mFlags & FLAG_HIDE_ACTION_BAR) != 0) { actionBar.hide(); @@ -232,4 +232,8 @@ abstract public class ActivityState { public boolean isFinishing() { return mIsFinishing; } + + protected MenuInflater getSupportMenuInflater() { + return ((SherlockActivity) mActivity).getSupportMenuInflater(); + } } diff --git a/src/com/android/gallery3d/app/AlbumDataLoader.java b/src/com/android/gallery3d/app/AlbumDataLoader.java index 8e6fcf5c2..ff950522a 100644 --- a/src/com/android/gallery3d/app/AlbumDataLoader.java +++ b/src/com/android/gallery3d/app/AlbumDataLoader.java @@ -74,7 +74,7 @@ public class AlbumDataLoader { private ReloadTask mReloadTask; - public AlbumDataLoader(GalleryActivity context, MediaSet mediaSet) { + public AlbumDataLoader(AbstractGalleryActivity context, MediaSet mediaSet) { mSource = mediaSet; mData = new MediaItem[DATA_CACHE_SIZE]; diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java index e44dae194..5328678ab 100644 --- a/src/com/android/gallery3d/app/AlbumPage.java +++ b/src/com/android/gallery3d/app/AlbumPage.java @@ -26,10 +26,11 @@ import android.os.Handler; import android.os.Message; import android.os.Vibrator; import android.provider.MediaStore; -import android.view.Menu; -import android.view.MenuItem; import android.widget.Toast; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; import com.android.gallery3d.R; import com.android.gallery3d.common.Utils; import com.android.gallery3d.data.DataManager; @@ -310,7 +311,7 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster private void onGetContent(final MediaItem item) { DataManager dm = mActivity.getDataManager(); - Activity activity = (Activity) mActivity; + Activity activity = mActivity; if (mData.getString(Gallery.EXTRA_CROP) != null) { // TODO: Handle MtpImagew Uri uri = dm.getContentUri(item.getPath()); @@ -456,7 +457,7 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster private void initializeViews() { mSelectionManager = new SelectionManager(mActivity, false); mSelectionManager.setSelectionListener(this); - Config.AlbumPage config = Config.AlbumPage.get((Context) mActivity); + Config.AlbumPage config = Config.AlbumPage.get(mActivity); mSlotView = new SlotView(mActivity, config.slotViewSpec); mAlbumView = new AlbumSlotRenderer(mActivity, mSlotView, mSelectionManager, config.placeholderColor); @@ -529,30 +530,29 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster @Override protected boolean onCreateActionBar(Menu menu) { GalleryActionBar actionBar = mActivity.getGalleryActionBar(); - boolean result; + MenuInflater inflator = getSupportMenuInflater(); if (mGetContent) { - result = actionBar.createActionMenu(menu, R.menu.pickup); + inflator.inflate(R.menu.pickup, menu); int typeBits = mData.getInt(Gallery.KEY_TYPE_BITS, DataManager.INCLUDE_IMAGE); - actionBar.setTitle(GalleryUtils.getSelectionModePrompt(typeBits)); } else { - result = actionBar.createActionMenu(menu, R.menu.album); + inflator.inflate(R.menu.album, menu); actionBar.setTitle(mMediaSet.getName()); - actionBar.setMenuItemVisible( - R.id.action_slideshow, !(mMediaSet instanceof MtpDevice)); + + menu.findItem(R.id.action_slideshow) + .setVisible(!(mMediaSet instanceof MtpDevice)); FilterUtils.setupMenuItems(actionBar, mMediaSetPath, true); - actionBar.setMenuItemVisible(R.id.action_group_by, mShowClusterMenu); - actionBar.setMenuItemVisible(R.id.action_camera, + + menu.findItem(R.id.action_group_by).setVisible(mShowClusterMenu); + menu.findItem(R.id.action_camera).setVisible( MediaSetUtils.isCameraSource(mMediaSetPath) - && GalleryUtils.isCameraAvailable((Activity) mActivity)); + && GalleryUtils.isCameraAvailable(mActivity)); - actionBar.setTitle(mMediaSet.getName()); } actionBar.setSubtitle(null); - - return result; + return true; } @Override @@ -591,7 +591,7 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster return true; } case R.id.action_camera: { - GalleryUtils.startCameraActivity((Activity) mActivity); + GalleryUtils.startCameraActivity(mActivity); return true; } default: @@ -669,7 +669,7 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster if (resultCode == MediaSet.SYNC_RESULT_ERROR && mIsActive && (mAlbumDataAdapter.size() == 0)) { // show error toast only if the album is empty - Toast.makeText((Context) mActivity, R.string.sync_album_error, + Toast.makeText(mActivity, R.string.sync_album_error, Toast.LENGTH_LONG).show(); } } finally { @@ -687,7 +687,7 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster mLoadingBits &= ~loadTaskBit; if (mLoadingBits == 0 && mIsActive) { if (mAlbumDataAdapter.size() == 0) { - Toast.makeText((Context) mActivity, + Toast.makeText(mActivity, R.string.empty_album, Toast.LENGTH_LONG).show(); mActivity.getStateManager().finishState(AlbumPage.this); } diff --git a/src/com/android/gallery3d/app/AlbumSetDataLoader.java b/src/com/android/gallery3d/app/AlbumSetDataLoader.java index 9613f99ec..80bc48a46 100644 --- a/src/com/android/gallery3d/app/AlbumSetDataLoader.java +++ b/src/com/android/gallery3d/app/AlbumSetDataLoader.java @@ -76,7 +76,7 @@ public class AlbumSetDataLoader { private final MySourceListener mSourceListener = new MySourceListener(); - public AlbumSetDataLoader(GalleryActivity activity, MediaSet albumSet, int cacheSize) { + public AlbumSetDataLoader(AbstractGalleryActivity activity, MediaSet albumSet, int cacheSize) { mSource = Utils.checkNotNull(albumSet); mCoverItem = new MediaItem[cacheSize]; mData = new MediaSet[cacheSize]; diff --git a/src/com/android/gallery3d/app/AlbumSetPage.java b/src/com/android/gallery3d/app/AlbumSetPage.java index a5a24810a..a3d7dc430 100644 --- a/src/com/android/gallery3d/app/AlbumSetPage.java +++ b/src/com/android/gallery3d/app/AlbumSetPage.java @@ -24,15 +24,15 @@ import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.os.Vibrator; -import android.view.Menu; -import android.view.MenuItem; import android.widget.Toast; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; import com.android.gallery3d.R; import com.android.gallery3d.common.Utils; import com.android.gallery3d.data.DataManager; import com.android.gallery3d.data.MediaDetails; -import com.android.gallery3d.data.MediaItem; import com.android.gallery3d.data.MediaObject; import com.android.gallery3d.data.MediaSet; import com.android.gallery3d.data.Path; @@ -211,7 +211,7 @@ public class AlbumSetPage extends ActivityState implements getSlotCenter(slotIndex, center); data.putIntArray(AlbumPage.KEY_SET_CENTER, center); if (mGetAlbum && targetSet.isLeafAlbum()) { - Activity activity = (Activity) mActivity; + Activity activity = mActivity; Intent result = new Intent() .putExtra(AlbumPicker.KEY_ALBUM_PATH, targetSet.getPath().toString()); activity.setResult(Activity.RESULT_OK, result); @@ -303,7 +303,7 @@ public class AlbumSetPage extends ActivityState implements // the page. Toast is redundant if we are going to stay on this page. if ((mAlbumSetDataAdapter.size() == 0)) { if (mActivity.getStateManager().getStateCount() > 1) { - Toast.makeText((Context) mActivity, + Toast.makeText(mActivity, R.string.empty_album, Toast.LENGTH_LONG).show(); mActivity.getStateManager().finishState(this); } @@ -371,7 +371,7 @@ public class AlbumSetPage extends ActivityState implements mSelectionManager = new SelectionManager(mActivity, true); mSelectionManager.setSelectionListener(this); - mConfig = Config.AlbumSetPage.get((Context) mActivity); + mConfig = Config.AlbumSetPage.get(mActivity); mSlotView = new SlotView(mActivity, mConfig.slotViewSpec); mAlbumSetView = new AlbumSetSlotRenderer( mActivity, mSelectionManager, mSlotView, mConfig.labelSpec, @@ -411,46 +411,47 @@ public class AlbumSetPage extends ActivityState implements @Override protected boolean onCreateActionBar(Menu menu) { - Activity activity = (Activity) mActivity; + Activity activity = mActivity; final boolean inAlbum = mActivity.getStateManager().hasStateClass(AlbumPage.class); - boolean result; + MenuInflater inflater = getSupportMenuInflater(); + if (mGetContent) { - result = mActionBar.createActionMenu(menu, R.menu.pickup); + inflater.inflate(R.menu.pickup, menu); int typeBits = mData.getInt( Gallery.KEY_TYPE_BITS, DataManager.INCLUDE_IMAGE); mActionBar.setTitle(GalleryUtils.getSelectionModePrompt(typeBits)); } else if (mGetAlbum) { - result = mActionBar.createActionMenu(menu, R.menu.pickup); + inflater.inflate(R.menu.pickup, menu); mActionBar.setTitle(R.string.select_album); } else { - result = mActionBar.createActionMenu(menu, R.menu.albumset); + inflater.inflate(R.menu.albumset, menu); mShowClusterMenu = !inAlbum; boolean selectAlbums = !inAlbum && mActionBar.getClusterTypeAction() == FilterUtils.CLUSTER_BY_ALBUM; - mActionBar.setMenuItemTitle(R.id.action_select, activity.getString( + MenuItem selectItem = menu.findItem(R.id.action_select); + selectItem.setTitle(activity.getString( selectAlbums ? R.string.select_album : R.string.select_group)); - FilterUtils.setupMenuItems(mActionBar, mMediaSet.getPath(), false); + MenuItem cameraItem = menu.findItem(R.id.action_camera); + cameraItem.setVisible(GalleryUtils.isCameraAvailable(activity)); - mActionBar.setMenuItemVisible( - R.id.action_camera, GalleryUtils.isCameraAvailable(activity)); + FilterUtils.setupMenuItems(mActionBar, mMediaSet.getPath(), false); Intent helpIntent = HelpUtils.getHelpIntent(activity, R.string.help_url_gallery_main); - if (helpIntent == null) { - mActionBar.setMenuItemVisible(R.id.action_general_help, false); - } else { - mActionBar.setMenuItemVisible(R.id.action_general_help, true); - mActionBar.setMenuItemIntent(R.id.action_general_help, helpIntent); - } + + MenuItem helpItem = menu.findItem(R.id.action_general_help); + helpItem.setVisible(helpIntent != null); + if (helpIntent != null) helpItem.setIntent(helpIntent); + mActionBar.setTitle(mTitle); mActionBar.setSubtitle(mSubtitle); } - return result; + return true; } @Override protected boolean onItemSelected(MenuItem item) { - Activity activity = (Activity) mActivity; + Activity activity = mActivity; switch (item.getItemId()) { case R.id.action_cancel: activity.setResult(Activity.RESULT_CANCELED); diff --git a/src/com/android/gallery3d/app/CropImage.java b/src/com/android/gallery3d/app/CropImage.java index f27e181d7..7798e7682 100644 --- a/src/com/android/gallery3d/app/CropImage.java +++ b/src/com/android/gallery3d/app/CropImage.java @@ -40,14 +40,13 @@ import android.os.Message; import android.provider.MediaStore; import android.provider.MediaStore.Images; import android.util.FloatMath; -import android.view.Menu; -import android.view.MenuItem; import android.view.Window; import android.widget.Toast; +import com.actionbarsherlock.app.ActionBar; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuItem; import com.android.gallery3d.R; -import com.android.gallery3d.actionbar.ActionBarUtils; -import com.android.gallery3d.actionbar.ActionBarInterface; import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.common.BitmapUtils; import com.android.gallery3d.common.ExifTags; @@ -163,9 +162,9 @@ public class CropImage extends AbstractGalleryActivity { mCropView = new CropView(this); getGLRoot().setContentPane(mCropView); - ActionBarInterface actionBar = ActionBarUtils.getActionBar(this); - int displayOptions = ActionBarInterface.DISPLAY_HOME_AS_UP - | ActionBarInterface.DISPLAY_SHOW_TITLE; + ActionBar actionBar = getSupportActionBar(); + int displayOptions = ActionBar.DISPLAY_HOME_AS_UP + | ActionBar.DISPLAY_SHOW_TITLE; actionBar.setDisplayOptions(displayOptions, displayOptions); Bundle extra = getIntent().getExtras(); @@ -216,7 +215,7 @@ public class CropImage extends AbstractGalleryActivity { @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); - getMenuInflater().inflate(R.menu.crop, menu); + getSupportMenuInflater().inflate(R.menu.crop, menu); return true; } diff --git a/src/com/android/gallery3d/app/FilterUtils.java b/src/com/android/gallery3d/app/FilterUtils.java index 61a261f2c..bc28a9cc1 100644 --- a/src/com/android/gallery3d/app/FilterUtils.java +++ b/src/com/android/gallery3d/app/FilterUtils.java @@ -77,7 +77,7 @@ public class FilterUtils { private static final int CLUSTER_CURRENT_TYPE = 4; private static final int FILTER_CURRENT_TYPE = 5; - public static void setupMenuItems(GalleryActionBar model, Path path, boolean inAlbum) { + public static void setupMenuItems(GalleryActionBar actionBar, Path path, boolean inAlbum) { int[] result = new int[6]; getAppliedFilters(path, result); int ctype = result[CLUSTER_TYPE]; @@ -86,31 +86,31 @@ public class FilterUtils { int ccurrent = result[CLUSTER_CURRENT_TYPE]; int fcurrent = result[FILTER_CURRENT_TYPE]; - setMenuItemApplied(model, CLUSTER_BY_TIME, + setMenuItemApplied(actionBar, CLUSTER_BY_TIME, (ctype & CLUSTER_BY_TIME) != 0, (ccurrent & CLUSTER_BY_TIME) != 0); - setMenuItemApplied(model, CLUSTER_BY_LOCATION, + setMenuItemApplied(actionBar, CLUSTER_BY_LOCATION, (ctype & CLUSTER_BY_LOCATION) != 0, (ccurrent & CLUSTER_BY_LOCATION) != 0); - setMenuItemApplied(model, CLUSTER_BY_TAG, + setMenuItemApplied(actionBar, CLUSTER_BY_TAG, (ctype & CLUSTER_BY_TAG) != 0, (ccurrent & CLUSTER_BY_TAG) != 0); - setMenuItemApplied(model, CLUSTER_BY_FACE, + setMenuItemApplied(actionBar, CLUSTER_BY_FACE, (ctype & CLUSTER_BY_FACE) != 0, (ccurrent & CLUSTER_BY_FACE) != 0); - model.setClusterItemVisibility(CLUSTER_BY_ALBUM, !inAlbum || ctype == 0); + actionBar.setClusterItemVisibility(CLUSTER_BY_ALBUM, !inAlbum || ctype == 0); - setMenuItemApplied(model, R.id.action_cluster_album, ctype == 0, + setMenuItemApplied(actionBar, R.id.action_cluster_album, ctype == 0, ccurrent == 0); // A filtering is available if it's not applied, and the old filtering // (if any) is not fixed. - setMenuItemAppliedEnabled(model, R.string.show_images_only, + setMenuItemAppliedEnabled(actionBar, R.string.show_images_only, (ftype & FILTER_IMAGE_ONLY) != 0, (ftype & FILTER_IMAGE_ONLY) == 0 && ftypef == 0, (fcurrent & FILTER_IMAGE_ONLY) != 0); - setMenuItemAppliedEnabled(model, R.string.show_videos_only, + setMenuItemAppliedEnabled(actionBar, R.string.show_videos_only, (ftype & FILTER_VIDEO_ONLY) != 0, (ftype & FILTER_VIDEO_ONLY) == 0 && ftypef == 0, (fcurrent & FILTER_VIDEO_ONLY) != 0); - setMenuItemAppliedEnabled(model, R.string.show_all, + setMenuItemAppliedEnabled(actionBar, R.string.show_all, ftype == 0, ftype != 0 && ftypef == 0, fcurrent == 0); } diff --git a/src/com/android/gallery3d/app/GalleryActionBar.java b/src/com/android/gallery3d/app/GalleryActionBar.java index 4c6a56309..0f7579e60 100644 --- a/src/com/android/gallery3d/app/GalleryActionBar.java +++ b/src/com/android/gallery3d/app/GalleryActionBar.java @@ -23,22 +23,23 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.view.LayoutInflater; -import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.TextView; +import com.actionbarsherlock.app.ActionBar; +import com.actionbarsherlock.app.ActionBar.OnMenuVisibilityListener; +import com.actionbarsherlock.app.ActionBar.OnNavigationListener; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuItem; +import com.actionbarsherlock.widget.ShareActionProvider; import com.android.gallery3d.R; -import com.android.gallery3d.actionbar.ActionBarInterface; -import com.android.gallery3d.actionbar.ActionBarInterface.OnMenuVisibilityListener; -import com.android.gallery3d.actionbar.ActionBarUtils; -import com.android.gallery3d.actionbar.MenuHolder; import com.android.gallery3d.common.ApiHelper; import java.util.ArrayList; -public class GalleryActionBar implements ActionBarInterface.OnNavigationListener, MenuHolder { +public class GalleryActionBar implements OnNavigationListener { @SuppressWarnings("unused") private static final String TAG = "GalleryActionBar"; @@ -47,8 +48,8 @@ public class GalleryActionBar implements ActionBarInterface.OnNavigationListener private ArrayList mActions; private Context mContext; private LayoutInflater mInflater; - private GalleryActivity mActivity; - private ActionBarInterface mActionBar; + private AbstractGalleryActivity mActivity; + private ActionBar mActionBar; private int mCurrentIndex; private ClusterAdapter mAdapter = new ClusterAdapter(); @@ -131,8 +132,8 @@ public class GalleryActionBar implements ActionBarInterface.OnNavigationListener return null; } - public GalleryActionBar(GalleryActivity activity) { - mActionBar = ActionBarUtils.getActionBar((Activity) activity); + public GalleryActionBar(AbstractGalleryActivity activity) { + mActionBar = activity.getSupportActionBar(); mContext = activity.getAndroidContext(); mActivity = activity; mInflater = ((Activity) mActivity).getLayoutInflater(); @@ -183,7 +184,7 @@ public class GalleryActionBar implements ActionBarInterface.OnNavigationListener // Don't set cluster runner until action bar is ready. mClusterRunner = null; mActionBar.setListNavigationCallbacks(mAdapter, this); - mActionBar.setNavigationMode(ActionBarInterface.NAVIGATION_MODE_LIST); + mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); setSelectedAction(action); mClusterRunner = runner; } @@ -196,7 +197,7 @@ public class GalleryActionBar implements ActionBarInterface.OnNavigationListener if (mActionBar != null) { mClusterRunner = null; if (hideMenu) { - mActionBar.setNavigationMode(ActionBarInterface.NAVIGATION_MODE_STANDARD); + mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); } } } @@ -222,19 +223,17 @@ public class GalleryActionBar implements ActionBarInterface.OnNavigationListener @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) private void setHomeButtonEnabled(boolean enabled) { - if (ApiHelper.HAS_ACTION_BAR_SET_HOME_BUTTON_ENABLED) { - mActionBar.setHomeButtonEnabled(enabled); - } + if (mActionBar != null) mActionBar.setHomeButtonEnabled(enabled); } public void setDisplayOptions(boolean displayHomeAsUp, boolean showTitle) { if (mActionBar == null) return; int options = 0; - if (displayHomeAsUp) options |= ActionBarInterface.DISPLAY_HOME_AS_UP; - if (showTitle) options |= ActionBarInterface.DISPLAY_SHOW_TITLE; + if (displayHomeAsUp) options |= ActionBar.DISPLAY_HOME_AS_UP; + if (showTitle) options |= ActionBar.DISPLAY_SHOW_TITLE; mActionBar.setDisplayOptions(options, - ActionBarInterface.DISPLAY_HOME_AS_UP | ActionBarInterface.DISPLAY_SHOW_TITLE); + ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE); mActionBar.setHomeButtonEnabled(displayHomeAsUp); } @@ -297,29 +296,29 @@ public class GalleryActionBar implements ActionBarInterface.OnNavigationListener return false; } - public boolean hasShareMenuItem() { - return mActionBar == null ? false : mActionBar.hasShareMenuItem(); - } + private Menu mActionBarMenu; + private MenuItem mShareMenuItem; - public void setShareIntent(Intent intent) { - mActionBar.setShareIntent(intent); + public void createActionBarMenu(int menuRes, Menu menu) { + mActivity.getSupportMenuInflater().inflate(menuRes, menu); + mActionBarMenu = menu; + mShareMenuItem = menu.findItem(R.id.action_share); } - public boolean createActionMenu(Menu menu, int menuRes) { - return mActionBar.createActionMenu(menu, menuRes); + public Menu getMenu() { + return mActionBarMenu; } - @Override - public void setMenuItemVisible(int menuItemId, boolean visible) { - mActionBar.setMenuItemVisible(menuItemId, visible); + public boolean hasShareMenuItem() { + return mShareMenuItem != null; } - @Override - public void setMenuItemTitle(int menuItemId, String title) { - mActionBar.setMenuItemTitle(menuItemId, title); + public void setShareIntent(Intent shareIntent) { + ((ShareActionProvider) mShareMenuItem.getActionProvider()) + .setShareIntent(shareIntent); } - public void setMenuItemIntent(int menuItemId, Intent intent) { - mActionBar.setMenuItemIntent(menuItemId, intent); + public MenuItem findMenuItem(int itemId) { + return mActionBarMenu.findItem(itemId); } } diff --git a/src/com/android/gallery3d/app/GalleryActivity.java b/src/com/android/gallery3d/app/GalleryActivity.java deleted file mode 100644 index 33c77fb4c..000000000 --- a/src/com/android/gallery3d/app/GalleryActivity.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2010 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.android.gallery3d.app; - -import com.android.gallery3d.ui.GLRoot; - -public interface GalleryActivity extends GalleryContext { - public StateManager getStateManager(); - public GLRoot getGLRoot(); - public GalleryActionBar getGalleryActionBar(); - public OrientationManager getOrientationManager(); - public TransitionStore getTransitionStore(); -} diff --git a/src/com/android/gallery3d/app/MovieActivity.java b/src/com/android/gallery3d/app/MovieActivity.java index bf2486927..820bd1003 100644 --- a/src/com/android/gallery3d/app/MovieActivity.java +++ b/src/com/android/gallery3d/app/MovieActivity.java @@ -39,9 +39,8 @@ import com.actionbarsherlock.app.ActionBar; import com.actionbarsherlock.app.SherlockActivity; import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.MenuItem; +import com.actionbarsherlock.widget.ShareActionProvider; import com.android.gallery3d.R; -import com.android.gallery3d.actionbar.ActionBarInterface; -import com.android.gallery3d.actionbar.ActionBarUtils; import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.common.Utils; @@ -129,8 +128,9 @@ public class MovieActivity extends SherlockActivity { mUri = intent.getData(); final ActionBar actionBar = getSupportActionBar(); setActionBarLogoFromIntent(intent); - actionBar.setDisplayOptions(ActionBarInterface.DISPLAY_HOME_AS_UP, - ActionBarInterface.DISPLAY_HOME_AS_UP); + actionBar.setDisplayOptions( + ActionBar.DISPLAY_HOME_AS_UP, + ActionBar.DISPLAY_HOME_AS_UP); String title = intent.getStringExtra(Intent.EXTRA_TITLE); if (title != null) { @@ -166,17 +166,17 @@ public class MovieActivity extends SherlockActivity { @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); - ActionBarInterface actionBar = ActionBarUtils.getActionBar(this); getSupportMenuInflater().inflate(R.menu.movie, menu); // Document says EXTRA_STREAM should be a content: Uri // So, we only share the video if it's "content:". + MenuItem shareItem = menu.findItem(R.id.action_share); if (ContentResolver.SCHEME_CONTENT.equals(mUri.getScheme())) { - if (actionBar.hasShareMenuItem()) { - actionBar.setShareIntent(createShareIntent()); - } + shareItem.setVisible(true); + ((ShareActionProvider) shareItem.getActionProvider()) + .setShareIntent(createShareIntent()); } else { - menu.findItem(R.id.action_share).setVisible(false); + shareItem.setVisible(false); } return true; } diff --git a/src/com/android/gallery3d/app/PhotoDataAdapter.java b/src/com/android/gallery3d/app/PhotoDataAdapter.java index b61e4f491..d565f26b5 100644 --- a/src/com/android/gallery3d/app/PhotoDataAdapter.java +++ b/src/com/android/gallery3d/app/PhotoDataAdapter.java @@ -169,7 +169,7 @@ public class PhotoDataAdapter implements PhotoPage.Model { // can find the item. If mItemPath is null, then we use the mCurrentIndex to // find the image being viewed. cameraIndex is the index of the camera // preview. If cameraIndex < 0, there is no camera preview. - public PhotoDataAdapter(GalleryActivity activity, PhotoView view, + public PhotoDataAdapter(AbstractGalleryActivity activity, PhotoView view, MediaSet mediaSet, Path itemPath, int indexHint, int cameraIndex, boolean isPanorama, boolean isStaticCamera) { mSource = Utils.checkNotNull(mediaSet); diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index 8b38abbb2..2458b9a98 100644 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -28,13 +28,13 @@ import android.nfc.NfcAdapter; import android.os.Bundle; import android.os.Handler; import android.os.Message; -import android.view.Menu; -import android.view.MenuItem; import android.view.animation.AccelerateInterpolator; import android.widget.Toast; +import com.actionbarsherlock.app.ActionBar.OnMenuVisibilityListener; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuItem; import com.android.gallery3d.R; -import com.android.gallery3d.actionbar.ActionBarInterface.OnMenuVisibilityListener; import com.android.gallery3d.anim.FloatAnimation; import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.common.Utils; @@ -141,6 +141,8 @@ public class PhotoPage extends ActivityState implements private NfcAdapter mNfcAdapter; + private Menu mActionBarMenu; + private final MyMenuVisibilityListener mMenuVisibilityListener = new MyMenuVisibilityListener(); @@ -419,13 +421,14 @@ public class PhotoPage extends ActivityState implements } private void updateMenuOperations() { - mActionBar.setMenuItemVisible(R.id.action_slideshow, canDoSlideShow()); + MenuItem item = mActionBar.findMenuItem(R.id.action_slideshow); + item.setVisible(canDoSlideShow()); if (mCurrentPhoto == null) return; int supportedOperations = mCurrentPhoto.getSupportedOperations(); if (!GalleryUtils.isEditorAvailable((Context) mActivity, "image/*")) { supportedOperations &= ~MediaObject.SUPPORT_EDIT; } - MenuExecutor.updateMenuOperation(mActionBar, supportedOperations); + MenuExecutor.updateMenuOperation(mActionBar.getMenu(), supportedOperations); } private boolean canDoSlideShow() { @@ -578,12 +581,11 @@ public class PhotoPage extends ActivityState implements @Override protected boolean onCreateActionBar(Menu menu) { - GalleryActionBar actionBar = mActionBar; - boolean result = actionBar.createActionMenu(menu, R.menu.photo); + mActionBar.createActionBarMenu(R.menu.photo, menu); if (mPendingSharePath != null) updateShareURI(mPendingSharePath); updateMenuOperations(); updateTitle(); - return result; + return true; } private MenuExecutor.ProgressListener mConfirmDialogListener = diff --git a/src/com/android/gallery3d/app/PickerActivity.java b/src/com/android/gallery3d/app/PickerActivity.java index d5bb218ea..a26711e15 100644 --- a/src/com/android/gallery3d/app/PickerActivity.java +++ b/src/com/android/gallery3d/app/PickerActivity.java @@ -17,13 +17,13 @@ package com.android.gallery3d.app; import android.os.Bundle; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.Window; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; import com.android.gallery3d.R; import com.android.gallery3d.ui.GLRootView; @@ -62,7 +62,7 @@ public class PickerActivity extends AbstractGalleryActivity @Override public boolean onCreateOptionsMenu(Menu menu) { - MenuInflater inflater = getMenuInflater(); + MenuInflater inflater = getSupportMenuInflater(); inflater.inflate(R.menu.pickup, menu); return true; } diff --git a/src/com/android/gallery3d/app/SinglePhotoDataAdapter.java b/src/com/android/gallery3d/app/SinglePhotoDataAdapter.java index 254f672b9..2f6f16f3a 100644 --- a/src/com/android/gallery3d/app/SinglePhotoDataAdapter.java +++ b/src/com/android/gallery3d/app/SinglePhotoDataAdapter.java @@ -52,7 +52,7 @@ public class SinglePhotoDataAdapter extends TileImageViewAdapter private int mLoadingState = LOADING_INIT; public SinglePhotoDataAdapter( - GalleryActivity activity, PhotoView view, MediaItem item) { + AbstractGalleryActivity activity, PhotoView view, MediaItem item) { mItem = Utils.checkNotNull(item); mHasFullImage = (item.getSupportedOperations() & MediaItem.SUPPORT_FULL_IMAGE) != 0; diff --git a/src/com/android/gallery3d/app/StateManager.java b/src/com/android/gallery3d/app/StateManager.java index f05ab01a6..7cc0ac42c 100644 --- a/src/com/android/gallery3d/app/StateManager.java +++ b/src/com/android/gallery3d/app/StateManager.java @@ -21,9 +21,9 @@ import android.content.Intent; import android.content.res.Configuration; import android.os.Bundle; import android.os.Parcelable; -import android.view.Menu; -import android.view.MenuItem; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuItem; import com.android.gallery3d.common.Utils; import java.util.Stack; @@ -38,12 +38,12 @@ public class StateManager { private static final String KEY_STATE = "bundle"; private static final String KEY_CLASS = "class"; - private GalleryActivity mContext; + private AbstractGalleryActivity mActivity; private Stack mStack = new Stack(); private ActivityState.ResultEntry mResult; - public StateManager(GalleryActivity context) { - mContext = context; + public StateManager(AbstractGalleryActivity activity) { + mActivity = activity; } public void startState(Class klass, @@ -59,7 +59,7 @@ public class StateManager { ActivityState top = getTopState(); if (mIsResumed) top.onPause(); } - state.initialize(mContext, data); + state.initialize(mActivity, data); mStack.push(new StateEntry(data, state)); state.onCreate(data, null); @@ -75,7 +75,7 @@ public class StateManager { } catch (Exception e) { throw new AssertionError(e); } - state.initialize(mContext, data); + state.initialize(mActivity, data); state.mResult = new ActivityState.ResultEntry(); state.mResult.requestCode = requestCode; @@ -155,7 +155,7 @@ public class StateManager { // The finish() request could be rejected (only happens under Monkey), // If it is rejected, we won't close the last page. if (mStack.size() == 1) { - Activity activity = (Activity) mContext.getAndroidContext(); + Activity activity = (Activity) mActivity.getAndroidContext(); if (mResult != null) { activity.setResult(mResult.resultCode, mResult.resultData); } @@ -183,7 +183,7 @@ public class StateManager { mStack.pop(); state.mIsFinishing = true; if (mIsResumed) state.onPause(); - mContext.getGLRoot().setContentPane(null); + mActivity.getGLRoot().setContentPane(null); state.onDestroy(); if (!mStack.isEmpty()) { @@ -213,7 +213,7 @@ public class StateManager { } catch (Exception e) { throw new AssertionError(e); } - state.initialize(mContext, data); + state.initialize(mActivity, data); mStack.push(new StateEntry(data, state)); state.onCreate(data, null); if (mIsResumed) state.resume(); @@ -246,7 +246,7 @@ public class StateManager { } catch (Exception e) { throw new AssertionError(e); } - activityState.initialize(mContext, data); + activityState.initialize(mActivity, data); activityState.onCreate(data, state); mStack.push(new StateEntry(data, activityState)); } diff --git a/src/com/android/gallery3d/ui/ActionModeHandler.java b/src/com/android/gallery3d/ui/ActionModeHandler.java index 7deee5bc8..379f79c76 100644 --- a/src/com/android/gallery3d/ui/ActionModeHandler.java +++ b/src/com/android/gallery3d/ui/ActionModeHandler.java @@ -17,23 +17,23 @@ package com.android.gallery3d.ui; import android.annotation.TargetApi; -import android.app.Activity; -import android.content.Context; import android.content.Intent; import android.net.Uri; import android.nfc.NfcAdapter; import android.os.Handler; import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuItem; import android.view.View; import android.widget.Button; +import com.actionbarsherlock.app.SherlockActivity; +import com.actionbarsherlock.view.ActionMode; +import com.actionbarsherlock.view.ActionMode.Callback; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuItem; +import com.actionbarsherlock.widget.ShareActionProvider; +import com.actionbarsherlock.widget.ShareActionProvider.OnShareTargetSelectedListener; import com.android.gallery3d.R; -import com.android.gallery3d.actionbar.ActionBarUtils; -import com.android.gallery3d.actionbar.ActionModeInterface; -import com.android.gallery3d.actionbar.ActionModeInterface.OnShareTargetSelectedListener; -import com.android.gallery3d.app.GalleryActivity; +import com.android.gallery3d.app.AbstractGalleryActivity; import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.common.Utils; import com.android.gallery3d.data.DataManager; @@ -47,8 +47,7 @@ import com.android.gallery3d.util.ThreadPool.JobContext; import java.util.ArrayList; -public class ActionModeHandler implements - ActionModeInterface.Callback, PopupList.OnPopupItemClickListener { +public class ActionModeHandler implements Callback, PopupList.OnPopupItemClickListener { @SuppressWarnings("unused") private static final String TAG = "ActionModeHandler"; @@ -61,19 +60,20 @@ public class ActionModeHandler implements public boolean onActionItemClicked(MenuItem item); } - private final GalleryActivity mActivity; + private final AbstractGalleryActivity mActivity; private final MenuExecutor mMenuExecutor; private final SelectionManager mSelectionManager; private final NfcAdapter mNfcAdapter; private Menu mMenu; + private MenuItem mShareMenuItem; private SelectionMenu mSelectionMenu; private ActionModeListener mListener; private Future mMenuTask; private final Handler mMainHandler; - private ActionModeInterface mActionMode; + private ActionMode mActionMode; public ActionModeHandler( - GalleryActivity activity, SelectionManager selectionManager) { + AbstractGalleryActivity activity, SelectionManager selectionManager) { mActivity = Utils.checkNotNull(activity); mSelectionManager = Utils.checkNotNull(selectionManager); mMenuExecutor = new MenuExecutor(activity, selectionManager); @@ -82,8 +82,8 @@ public class ActionModeHandler implements } public void startActionMode() { - Activity a = (Activity) mActivity; - mActionMode = ActionBarUtils.startActionMode(a, this); + SherlockActivity a = mActivity; + mActionMode = a.startActionMode(this); View customView = LayoutInflater.from(a).inflate( R.layout.action_mode, null); mActionMode.setCustomView(customView); @@ -105,7 +105,7 @@ public class ActionModeHandler implements } @Override - public boolean onActionItemClicked(ActionModeInterface mode, MenuItem item) { + public boolean onActionItemClicked(ActionMode mode, MenuItem item) { GLRoot root = mActivity.getGLRoot(); root.lockRenderThread(); try { @@ -164,24 +164,35 @@ public class ActionModeHandler implements mSelectionMenu.updateSelectAllMode(mSelectionManager.inSelectAllMode()); } + private final OnShareTargetSelectedListener mShareTargetSelectedListener = + new OnShareTargetSelectedListener() { + @Override + public boolean onShareTargetSelected(ShareActionProvider source, Intent intent) { + mSelectionManager.leaveSelectionMode(); + return false; + } + }; + @Override - public boolean onCreateActionMode(ActionModeInterface mode, Menu menu) { - mode.inflateMenu(R.menu.operation); + public boolean onPrepareActionMode(ActionMode mode, Menu menu) { + return false; + } + + @Override + public boolean onCreateActionMode(ActionMode mode, Menu menu) { + mode.getMenuInflater().inflate(R.menu.operation, menu); - OnShareTargetSelectedListener listener = new OnShareTargetSelectedListener() { - @Override - public boolean onShareTargetSelected(Intent intent) { - mSelectionManager.leaveSelectionMode(); - return false; - } - }; - mode.setOnShareTargetSelectedListener(listener); mMenu = menu; + mShareMenuItem = menu.findItem(R.id.action_share); + if (mShareMenuItem != null) { + ((ShareActionProvider) mShareMenuItem.getActionProvider()) + .setOnShareTargetSelectedListener(mShareTargetSelectedListener); + } return true; } @Override - public void onDestroyActionMode(ActionModeInterface mode) { + public void onDestroyActionMode(ActionMode mode) { mSelectionManager.leaveSelectionMode(); } @@ -209,7 +220,7 @@ public class ActionModeHandler implements switch (unexpandedPaths.size()) { case 1: final String mimeType = MenuExecutor.getMimeType(type); - if (!GalleryUtils.isEditorAvailable((Context) mActivity, mimeType)) { + if (!GalleryUtils.isEditorAvailable(mActivity, mimeType)) { operation &= ~MediaObject.SUPPORT_EDIT; } break; @@ -223,7 +234,7 @@ public class ActionModeHandler implements @TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN) private void setNfcBeamPushUris(Uri[] uris) { if (mNfcAdapter != null && ApiHelper.HAS_SET_BEAM_PUSH_URIS) { - mNfcAdapter.setBeamPushUris(uris, (Activity)mActivity); + mNfcAdapter.setBeamPushUris(uris, mActivity); } } @@ -275,15 +286,12 @@ public class ActionModeHandler implements public void updateSupportedOperation() { // Interrupt previous unfinished task, mMenuTask is only accessed in main thread - if (mMenuTask != null) { - mMenuTask.cancel(); - } + if (mMenuTask != null) mMenuTask.cancel(); updateSelectionMenu(); // Disable share action until share intent is in good shape - final boolean hasShareButton = mActionMode.hasShareButton(); - if (hasShareButton) mActionMode.setShareIntent(null); + if (mShareMenuItem != null) mShareMenuItem.setEnabled(false); // Generate sharing intent and update supported operations in the background // The task can take a long time and be canceled in the mean time. @@ -294,17 +302,17 @@ public class ActionModeHandler implements final int operation = computeMenuOptions(jc); // Pass2: Deal with expanded media object list for sharing operation. - final Intent intent = hasShareButton ? computeSharingIntent(jc) : null; + final Intent intent = (mShareMenuItem != null) ? computeSharingIntent(jc) : null; mMainHandler.post(new Runnable() { @Override public void run() { mMenuTask = null; - if (!jc.isCancelled()) { - MenuExecutor.updateMenuOperation(mActionMode, operation); - if (hasShareButton) { - mActionMode.setShareIntent(intent); - mMenuExecutor.setShareIntent(intent); - } + if (jc.isCancelled()) return; + MenuExecutor.updateMenuOperation(mMenu, operation); + if (mShareMenuItem != null) { + mShareMenuItem.setEnabled(true); + ((ShareActionProvider) mShareMenuItem.getActionProvider()) + .setShareIntent(intent); } } }); diff --git a/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java b/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java index 449c6f9d3..e32ec5160 100644 --- a/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java +++ b/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java @@ -20,8 +20,8 @@ import android.graphics.Bitmap; import android.os.Message; import com.android.gallery3d.R; +import com.android.gallery3d.app.AbstractGalleryActivity; import com.android.gallery3d.app.AlbumSetDataLoader; -import com.android.gallery3d.app.GalleryActivity; import com.android.gallery3d.common.Utils; import com.android.gallery3d.data.BitmapPool; import com.android.gallery3d.data.DataSourceType; @@ -89,7 +89,7 @@ public class AlbumSetSlidingWindow implements AlbumSetDataLoader.DataListener { private BitmapLoader coverLoader; } - public AlbumSetSlidingWindow(GalleryActivity activity, + public AlbumSetSlidingWindow(AbstractGalleryActivity activity, AlbumSetDataLoader source, AlbumSetSlotRenderer.LabelSpec labelSpec, int cacheSize) { source.setModelListener(this); mSource = source; diff --git a/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java b/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java index bdc0e676e..a1f2b4c4f 100644 --- a/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java +++ b/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java @@ -16,10 +16,8 @@ package com.android.gallery3d.ui; -import android.content.Context; - +import com.android.gallery3d.app.AbstractGalleryActivity; import com.android.gallery3d.app.AlbumSetDataLoader; -import com.android.gallery3d.app.GalleryActivity; import com.android.gallery3d.data.MediaObject; import com.android.gallery3d.data.Path; import com.android.gallery3d.ui.AlbumSetSlidingWindow.AlbumSetEntry; @@ -31,7 +29,7 @@ public class AlbumSetSlotRenderer extends AbstractSlotRenderer { private final int mPlaceholderColor; private final ColorTexture mWaitLoadingTexture; - private final GalleryActivity mActivity; + private final AbstractGalleryActivity mActivity; private final SelectionManager mSelectionManager; protected final LabelSpec mLabelSpec; @@ -58,9 +56,10 @@ public class AlbumSetSlotRenderer extends AbstractSlotRenderer { public int borderSize; } - public AlbumSetSlotRenderer(GalleryActivity activity, SelectionManager selectionManager, + public AlbumSetSlotRenderer(AbstractGalleryActivity activity, + SelectionManager selectionManager, SlotView slotView, LabelSpec labelSpec, int placeholderColor) { - super ((Context) activity); + super (activity); mActivity = activity; mSelectionManager = selectionManager; mSlotView = slotView; diff --git a/src/com/android/gallery3d/ui/AlbumSlidingWindow.java b/src/com/android/gallery3d/ui/AlbumSlidingWindow.java index d5d90a9ea..e4d636a7a 100644 --- a/src/com/android/gallery3d/ui/AlbumSlidingWindow.java +++ b/src/com/android/gallery3d/ui/AlbumSlidingWindow.java @@ -19,8 +19,8 @@ package com.android.gallery3d.ui; import android.graphics.Bitmap; import android.os.Message; +import com.android.gallery3d.app.AbstractGalleryActivity; import com.android.gallery3d.app.AlbumDataLoader; -import com.android.gallery3d.app.GalleryActivity; import com.android.gallery3d.common.Utils; import com.android.gallery3d.data.BitmapPool; import com.android.gallery3d.data.MediaItem; @@ -73,7 +73,7 @@ public class AlbumSlidingWindow implements AlbumDataLoader.DataListener { private int mActiveRequestCount = 0; private boolean mIsActive = false; - public AlbumSlidingWindow(GalleryActivity activity, + public AlbumSlidingWindow(AbstractGalleryActivity activity, AlbumDataLoader source, int cacheSize) { source.setDataListener(this); mSource = source; diff --git a/src/com/android/gallery3d/ui/AlbumSlotRenderer.java b/src/com/android/gallery3d/ui/AlbumSlotRenderer.java index f6df3b380..d9e3fb7ae 100644 --- a/src/com/android/gallery3d/ui/AlbumSlotRenderer.java +++ b/src/com/android/gallery3d/ui/AlbumSlotRenderer.java @@ -16,10 +16,8 @@ package com.android.gallery3d.ui; -import android.content.Context; - +import com.android.gallery3d.app.AbstractGalleryActivity; import com.android.gallery3d.app.AlbumDataLoader; -import com.android.gallery3d.app.GalleryActivity; import com.android.gallery3d.data.MediaObject; import com.android.gallery3d.data.Path; @@ -35,7 +33,7 @@ public class AlbumSlotRenderer extends AbstractSlotRenderer { private static final int CACHE_SIZE = 96; private AlbumSlidingWindow mDataWindow; - private final GalleryActivity mActivity; + private final AbstractGalleryActivity mActivity; private final ColorTexture mWaitLoadingTexture; private final SlotView mSlotView; private final SelectionManager mSelectionManager; @@ -47,9 +45,9 @@ public class AlbumSlotRenderer extends AbstractSlotRenderer { private SlotFilter mSlotFilter; - public AlbumSlotRenderer(GalleryActivity activity, SlotView slotView, + public AlbumSlotRenderer(AbstractGalleryActivity activity, SlotView slotView, SelectionManager selectionManager, int placeholderColor) { - super((Context) activity); + super(activity); mActivity = activity; mSlotView = slotView; mSelectionManager = selectionManager; diff --git a/src/com/android/gallery3d/ui/CacheStorageUsageInfo.java b/src/com/android/gallery3d/ui/CacheStorageUsageInfo.java index 611648a29..46f7a2433 100644 --- a/src/com/android/gallery3d/ui/CacheStorageUsageInfo.java +++ b/src/com/android/gallery3d/ui/CacheStorageUsageInfo.java @@ -19,7 +19,7 @@ package com.android.gallery3d.ui; import android.content.Context; import android.os.StatFs; -import com.android.gallery3d.app.GalleryActivity; +import com.android.gallery3d.app.AbstractGalleryActivity; import com.android.gallery3d.util.ThreadPool.JobContext; import java.io.File; @@ -40,11 +40,11 @@ public class CacheStorageUsageInfo { // number of bytes used for the cache if all pending downloads (and removals) are completed. private long mTargetCacheBytes; - private GalleryActivity mActivity; + private AbstractGalleryActivity mActivity; private Context mContext; private long mUserChangeDelta; - public CacheStorageUsageInfo(GalleryActivity activity) { + public CacheStorageUsageInfo(AbstractGalleryActivity activity) { mActivity = activity; mContext = activity.getAndroidContext(); } diff --git a/src/com/android/gallery3d/ui/CropView.java b/src/com/android/gallery3d/ui/CropView.java index 8c2c3df2a..1890c7630 100644 --- a/src/com/android/gallery3d/ui/CropView.java +++ b/src/com/android/gallery3d/ui/CropView.java @@ -33,7 +33,7 @@ import android.widget.Toast; import com.android.gallery3d.R; import com.android.gallery3d.anim.Animation; -import com.android.gallery3d.app.GalleryActivity; +import com.android.gallery3d.app.AbstractGalleryActivity; import com.android.gallery3d.common.Utils; import java.util.ArrayList; @@ -92,14 +92,14 @@ public class CropView extends GLView { private int mImageWidth = SIZE_UNKNOWN; private int mImageHeight = SIZE_UNKNOWN; - private GalleryActivity mActivity; + private AbstractGalleryActivity mActivity; private GLPaint mPaint = new GLPaint(); private GLPaint mFacePaint = new GLPaint(); private int mImageRotation; - public CropView(GalleryActivity activity) { + public CropView(AbstractGalleryActivity activity) { mActivity = activity; mImageView = new TileImageView(activity); mFaceDetectionView = new FaceHighlightView(); diff --git a/src/com/android/gallery3d/ui/DetailsAddressResolver.java b/src/com/android/gallery3d/ui/DetailsAddressResolver.java index 3dd20a5e0..8de667745 100644 --- a/src/com/android/gallery3d/ui/DetailsAddressResolver.java +++ b/src/com/android/gallery3d/ui/DetailsAddressResolver.java @@ -21,7 +21,7 @@ import android.location.Address; import android.os.Handler; import android.os.Looper; -import com.android.gallery3d.app.GalleryActivity; +import com.android.gallery3d.app.AbstractGalleryActivity; import com.android.gallery3d.data.MediaDetails; import com.android.gallery3d.util.Future; import com.android.gallery3d.util.FutureListener; @@ -32,7 +32,7 @@ import com.android.gallery3d.util.ThreadPool.JobContext; public class DetailsAddressResolver { private AddressResolvingListener mListener; - private final GalleryActivity mContext; + private final AbstractGalleryActivity mContext; private Future

mAddressLookupJob; private final Handler mHandler; @@ -54,7 +54,7 @@ public class DetailsAddressResolver { public void onAddressAvailable(String address); } - public DetailsAddressResolver(GalleryActivity context) { + public DetailsAddressResolver(AbstractGalleryActivity context) { mContext = context; mHandler = new Handler(Looper.getMainLooper()); } diff --git a/src/com/android/gallery3d/ui/DetailsHelper.java b/src/com/android/gallery3d/ui/DetailsHelper.java index f86ffbe05..301601156 100644 --- a/src/com/android/gallery3d/ui/DetailsHelper.java +++ b/src/com/android/gallery3d/ui/DetailsHelper.java @@ -19,7 +19,7 @@ import android.content.Context; import android.view.View.MeasureSpec; import com.android.gallery3d.R; -import com.android.gallery3d.app.GalleryActivity; +import com.android.gallery3d.app.AbstractGalleryActivity; import com.android.gallery3d.data.MediaDetails; import com.android.gallery3d.ui.DetailsAddressResolver.AddressResolvingListener; @@ -44,7 +44,7 @@ public class DetailsHelper { public void hide(); } - public DetailsHelper(GalleryActivity activity, GLView rootPane, DetailsSource source) { + public DetailsHelper(AbstractGalleryActivity activity, GLView rootPane, DetailsSource source) { mContainer = new DialogDetailsView(activity, source); } @@ -65,7 +65,7 @@ public class DetailsHelper { mContainer.setCloseListener(listener); } - public static String resolveAddress(GalleryActivity activity, double[] latlng, + public static String resolveAddress(AbstractGalleryActivity activity, double[] latlng, AddressResolvingListener listener) { if (sAddressResolver == null) { sAddressResolver = new DetailsAddressResolver(activity); diff --git a/src/com/android/gallery3d/ui/DialogDetailsView.java b/src/com/android/gallery3d/ui/DialogDetailsView.java index a55660035..fb6ccf5ae 100644 --- a/src/com/android/gallery3d/ui/DialogDetailsView.java +++ b/src/com/android/gallery3d/ui/DialogDetailsView.java @@ -16,7 +16,6 @@ package com.android.gallery3d.ui; -import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.content.Context; @@ -31,7 +30,7 @@ import android.widget.ListView; import android.widget.TextView; import com.android.gallery3d.R; -import com.android.gallery3d.app.GalleryActivity; +import com.android.gallery3d.app.AbstractGalleryActivity; import com.android.gallery3d.common.Utils; import com.android.gallery3d.data.MediaDetails; import com.android.gallery3d.ui.DetailsAddressResolver.AddressResolvingListener; @@ -46,7 +45,7 @@ public class DialogDetailsView implements DetailsViewContainer { @SuppressWarnings("unused") private static final String TAG = "DialogDetailsView"; - private final GalleryActivity mContext; + private final AbstractGalleryActivity mActivity; private DetailsAdapter mAdapter; private MediaDetails mDetails; private final DetailsSource mSource; @@ -54,8 +53,8 @@ public class DialogDetailsView implements DetailsViewContainer { private Dialog mDialog; private CloseListener mListener; - public DialogDetailsView(GalleryActivity activity, DetailsSource source) { - mContext = activity; + public DialogDetailsView(AbstractGalleryActivity activity, DetailsSource source) { + mActivity = activity; mSource = source; } @@ -86,12 +85,12 @@ public class DialogDetailsView implements DetailsViewContainer { private void setDetails(MediaDetails details) { mAdapter = new DetailsAdapter(details); String title = String.format( - mContext.getAndroidContext().getString(R.string.details_title), + mActivity.getAndroidContext().getString(R.string.details_title), mIndex + 1, mSource.size()); - ListView detailsList = (ListView) LayoutInflater.from(mContext.getAndroidContext()).inflate( + ListView detailsList = (ListView) LayoutInflater.from(mActivity.getAndroidContext()).inflate( R.layout.details_list, null, false); detailsList.setAdapter(mAdapter); - mDialog = new AlertDialog.Builder((Activity) mContext) + mDialog = new AlertDialog.Builder(mActivity) .setView(detailsList) .setTitle(title) .setPositiveButton(R.string.close, new DialogInterface.OnClickListener() { @@ -117,7 +116,7 @@ public class DialogDetailsView implements DetailsViewContainer { private int mLocationIndex; public DetailsAdapter(MediaDetails details) { - Context context = mContext.getAndroidContext(); + Context context = mActivity.getAndroidContext(); mItems = new ArrayList(details.size()); mLocationIndex = -1; setDetails(context, details); @@ -130,7 +129,7 @@ public class DialogDetailsView implements DetailsViewContainer { case MediaDetails.INDEX_LOCATION: { double[] latlng = (double[]) detail.getValue(); mLocationIndex = mItems.size(); - value = DetailsHelper.resolveAddress(mContext, latlng, this); + value = DetailsHelper.resolveAddress(mActivity, latlng, this); break; } case MediaDetails.INDEX_SIZE: { @@ -222,7 +221,7 @@ public class DialogDetailsView implements DetailsViewContainer { public View getView(int position, View convertView, ViewGroup parent) { TextView tv; if (convertView == null) { - tv = (TextView) LayoutInflater.from(mContext.getAndroidContext()).inflate( + tv = (TextView) LayoutInflater.from(mActivity.getAndroidContext()).inflate( R.layout.details, parent, false); } else { tv = (TextView) convertView; diff --git a/src/com/android/gallery3d/ui/ImportCompleteListener.java b/src/com/android/gallery3d/ui/ImportCompleteListener.java index 5b6e0a17f..30af47065 100644 --- a/src/com/android/gallery3d/ui/ImportCompleteListener.java +++ b/src/com/android/gallery3d/ui/ImportCompleteListener.java @@ -23,15 +23,15 @@ import android.os.PowerManager; import android.widget.Toast; import com.android.gallery3d.R; +import com.android.gallery3d.app.AbstractGalleryActivity; import com.android.gallery3d.app.AlbumPage; -import com.android.gallery3d.app.GalleryActivity; import com.android.gallery3d.util.MediaSetUtils; public class ImportCompleteListener implements MenuExecutor.ProgressListener { - private GalleryActivity mActivity; + private AbstractGalleryActivity mActivity; private PowerManager.WakeLock mWakeLock; - public ImportCompleteListener(GalleryActivity galleryActivity) { + public ImportCompleteListener(AbstractGalleryActivity galleryActivity) { mActivity = galleryActivity; PowerManager pm = (PowerManager) ((Activity) mActivity).getSystemService(Context.POWER_SERVICE); diff --git a/src/com/android/gallery3d/ui/ManageCacheDrawer.java b/src/com/android/gallery3d/ui/ManageCacheDrawer.java index 91dc7ac44..e989af27d 100644 --- a/src/com/android/gallery3d/ui/ManageCacheDrawer.java +++ b/src/com/android/gallery3d/ui/ManageCacheDrawer.java @@ -19,7 +19,7 @@ package com.android.gallery3d.ui; import android.content.Context; import com.android.gallery3d.R; -import com.android.gallery3d.app.GalleryActivity; +import com.android.gallery3d.app.AbstractGalleryActivity; import com.android.gallery3d.data.DataSourceType; import com.android.gallery3d.data.MediaSet; import com.android.gallery3d.data.Path; @@ -36,11 +36,11 @@ public class ManageCacheDrawer extends AlbumSetSlotRenderer { private final int mCachePinSize; private final int mCachePinMargin; - public ManageCacheDrawer(GalleryActivity activity, SelectionManager selectionManager, + public ManageCacheDrawer(AbstractGalleryActivity activity, SelectionManager selectionManager, SlotView slotView, LabelSpec labelSpec, int cachePinSize, int cachePinMargin) { super(activity, selectionManager, slotView, labelSpec, activity.getResources().getColor(R.color.cache_placeholder)); - Context context = (Context) activity; + Context context = activity; mCheckedItem = new ResourceTexture( context, R.drawable.btn_make_offline_normal_on_holo_dark); mUnCheckedItem = new ResourceTexture( diff --git a/src/com/android/gallery3d/ui/MenuExecutor.java b/src/com/android/gallery3d/ui/MenuExecutor.java index ff6a61f7a..7bccda84c 100644 --- a/src/com/android/gallery3d/ui/MenuExecutor.java +++ b/src/com/android/gallery3d/ui/MenuExecutor.java @@ -26,13 +26,12 @@ import android.content.DialogInterface.OnClickListener; import android.content.Intent; import android.os.Handler; import android.os.Message; -import android.view.MenuItem; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuItem; import com.android.gallery3d.R; -import com.android.gallery3d.actionbar.MenuHolder; +import com.android.gallery3d.app.AbstractGalleryActivity; import com.android.gallery3d.app.CropImage; -import com.android.gallery3d.app.GalleryActivity; -import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.common.Utils; import com.android.gallery3d.data.DataManager; import com.android.gallery3d.data.MediaItem; @@ -64,7 +63,7 @@ public class MenuExecutor { private boolean mWaitOnStop; private Intent mShareIntent; - private final GalleryActivity mActivity; + private final AbstractGalleryActivity mActivity; private final SelectionManager mSelectionManager; private final Handler mHandler; @@ -90,7 +89,7 @@ public class MenuExecutor { } public MenuExecutor( - GalleryActivity activity, SelectionManager selectionManager) { + AbstractGalleryActivity activity, SelectionManager selectionManager) { mActivity = Utils.checkNotNull(activity); mSelectionManager = Utils.checkNotNull(selectionManager); mHandler = new SynchronizedHandler(mActivity.getGLRoot()) { @@ -157,7 +156,7 @@ public class MenuExecutor { mHandler.sendMessage(mHandler.obtainMessage(MSG_TASK_COMPLETE, result, 0, listener)); } - public static void updateMenuOperation(MenuHolder menu, int supported) { + public static void updateMenuOperation(Menu menu, int supported) { boolean supportDelete = (supported & MediaObject.SUPPORT_DELETE) != 0; boolean supportRotate = (supported & MediaObject.SUPPORT_ROTATE) != 0; boolean supportCrop = (supported & MediaObject.SUPPORT_CROP) != 0; @@ -169,16 +168,21 @@ public class MenuExecutor { boolean supportInfo = (supported & MediaObject.SUPPORT_INFO) != 0; boolean supportImport = (supported & MediaObject.SUPPORT_IMPORT) != 0; - menu.setMenuItemVisible(R.id.action_delete, supportDelete); - menu.setMenuItemVisible(R.id.action_rotate_ccw, supportRotate); - menu.setMenuItemVisible(R.id.action_rotate_cw, supportRotate); - menu.setMenuItemVisible(R.id.action_crop, supportCrop); - menu.setMenuItemVisible(R.id.action_share, supportShare); - menu.setMenuItemVisible(R.id.action_setas, supportSetAs); - menu.setMenuItemVisible(R.id.action_show_on_map, supportShowOnMap); - menu.setMenuItemVisible(R.id.action_edit, supportEdit); - menu.setMenuItemVisible(R.id.action_details, supportInfo); - menu.setMenuItemVisible(R.id.action_import, supportImport); + setMenuItemVisible(menu, R.id.action_delete, supportDelete); + setMenuItemVisible(menu, R.id.action_rotate_ccw, supportRotate); + setMenuItemVisible(menu, R.id.action_rotate_cw, supportRotate); + setMenuItemVisible(menu, R.id.action_crop, supportCrop); + setMenuItemVisible(menu, R.id.action_share, supportShare); + setMenuItemVisible(menu, R.id.action_setas, supportSetAs); + setMenuItemVisible(menu, R.id.action_show_on_map, supportShowOnMap); + setMenuItemVisible(menu, R.id.action_edit, supportEdit); + setMenuItemVisible(menu, R.id.action_details, supportInfo); + setMenuItemVisible(menu, R.id.action_import, supportImport); + } + + private static void setMenuItemVisible(Menu menu, int itemId, boolean visible) { + MenuItem item = menu.findItem(itemId); + if (item != null) item.setVisible(visible); } private Path getSingleSelectedPath() { @@ -244,14 +248,6 @@ public class MenuExecutor { case R.id.action_import: title = R.string.Import; break; - case R.id.action_share: { - if (!ApiHelper.HAS_SHARE_ACTION_PROVIDER) { - Activity activity = (Activity) mActivity; - activity.startActivity(Intent.createChooser( - mShareIntent, activity.getString(R.string.share))); - } - return; - } default: return; } @@ -326,10 +322,6 @@ public class MenuExecutor { mWaitOnStop = waitOnStop; } - public void setShareIntent(Intent intent) { - mShareIntent = intent; - } - public static String getMimeType(int type) { switch (type) { case MediaObject.MEDIA_TYPE_IMAGE : diff --git a/src/com/android/gallery3d/ui/PhotoView.java b/src/com/android/gallery3d/ui/PhotoView.java index 16d93ca20..25d3154a9 100644 --- a/src/com/android/gallery3d/ui/PhotoView.java +++ b/src/com/android/gallery3d/ui/PhotoView.java @@ -28,7 +28,7 @@ import android.view.View.MeasureSpec; import android.view.animation.AccelerateInterpolator; import com.android.gallery3d.R; -import com.android.gallery3d.app.GalleryActivity; +import com.android.gallery3d.app.AbstractGalleryActivity; import com.android.gallery3d.common.Utils; import com.android.gallery3d.data.MediaItem; import com.android.gallery3d.data.MediaObject; @@ -232,7 +232,7 @@ public class PhotoView extends GLView { // item. The value Integer.MAX_VALUE means there is no such hint. private int mUndoIndexHint = Integer.MAX_VALUE; - public PhotoView(GalleryActivity activity) { + public PhotoView(AbstractGalleryActivity activity) { mTileView = new TileImageView(activity); addComponent(mTileView); Context context = activity.getAndroidContext(); diff --git a/src/com/android/gallery3d/ui/SelectionManager.java b/src/com/android/gallery3d/ui/SelectionManager.java index 86e92da90..a6be0dd9f 100644 --- a/src/com/android/gallery3d/ui/SelectionManager.java +++ b/src/com/android/gallery3d/ui/SelectionManager.java @@ -16,7 +16,7 @@ package com.android.gallery3d.ui; -import com.android.gallery3d.app.GalleryContext; +import com.android.gallery3d.app.AbstractGalleryActivity; import com.android.gallery3d.data.DataManager; import com.android.gallery3d.data.MediaItem; import com.android.gallery3d.data.MediaSet; @@ -49,8 +49,8 @@ public class SelectionManager { public void onSelectionChange(Path path, boolean selected); } - public SelectionManager(GalleryContext galleryContext, boolean isAlbumSet) { - mDataManager = galleryContext.getDataManager(); + public SelectionManager(AbstractGalleryActivity activity, boolean isAlbumSet) { + mDataManager = activity.getDataManager(); mClickedSet = new HashSet(); mIsAlbumSet = isAlbumSet; mTotal = -1; diff --git a/src/com/android/gallery3d/ui/SlotView.java b/src/com/android/gallery3d/ui/SlotView.java index 1325aecd6..d77080adb 100644 --- a/src/com/android/gallery3d/ui/SlotView.java +++ b/src/com/android/gallery3d/ui/SlotView.java @@ -16,7 +16,6 @@ package com.android.gallery3d.ui; -import android.content.Context; import android.graphics.Rect; import android.os.Handler; import android.view.GestureDetector; @@ -24,7 +23,7 @@ import android.view.MotionEvent; import android.view.animation.DecelerateInterpolator; import com.android.gallery3d.anim.Animation; -import com.android.gallery3d.app.GalleryActivity; +import com.android.gallery3d.app.AbstractGalleryActivity; import com.android.gallery3d.common.Utils; public class SlotView extends GLView { @@ -88,10 +87,9 @@ public class SlotView extends GLView { // to prevent allocating memory private final Rect mTempRect = new Rect(); - public SlotView(GalleryActivity activity, Spec spec) { - mGestureDetector = new GestureDetector( - (Context) activity, new MyGestureListener()); - mScroller = new ScrollerHelper((Context) activity); + public SlotView(AbstractGalleryActivity activity, Spec spec) { + mGestureDetector = new GestureDetector(activity, new MyGestureListener()); + mScroller = new ScrollerHelper(activity); mHandler = new SynchronizedHandler(activity.getGLRoot()); setSlotSpec(spec); } -- GitLab From 5992daf6f4cb56742cbf33a014c5c2c142c6957e Mon Sep 17 00:00:00 2001 From: Bobby Georgescu Date: Wed, 22 Aug 2012 18:26:03 -0700 Subject: [PATCH 217/763] Offer to launch camera when Gallery completely empty Bug: 7009464 Rather than showing a blank screen, alerts the user that the gallery is empty and offers to launch the camera, if the device has one. Change-Id: I0bf71f1cbe7c96a4dc063b5d38b9a282538234c9 --- .../android/gallery3d/app/AlbumSetPage.java | 43 ++++++++++++++++++- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/src/com/android/gallery3d/app/AlbumSetPage.java b/src/com/android/gallery3d/app/AlbumSetPage.java index a3d7dc430..f0f4354e1 100644 --- a/src/com/android/gallery3d/app/AlbumSetPage.java +++ b/src/com/android/gallery3d/app/AlbumSetPage.java @@ -17,8 +17,12 @@ package com.android.gallery3d.app; import android.app.Activity; +import android.app.AlertDialog; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; +import android.content.DialogInterface.OnCancelListener; +import android.content.DialogInterface.OnClickListener; import android.graphics.Rect; import android.os.Bundle; import android.os.Handler; @@ -299,16 +303,50 @@ public class AlbumSetPage extends ActivityState implements private void clearLoadingBit(int loadingBit) { mLoadingBits &= ~loadingBit; if (mLoadingBits == 0 && mIsActive) { - // Only show toast when there's no album and we are going to finish - // the page. Toast is redundant if we are going to stay on this page. if ((mAlbumSetDataAdapter.size() == 0)) { + // Only show toast when there's no album and we are going to + // finish, otherwise prompt user to add some pictures if (mActivity.getStateManager().getStateCount() > 1) { Toast.makeText(mActivity, R.string.empty_album, Toast.LENGTH_LONG).show(); mActivity.getStateManager().finishState(this); + } else { + emptyGalleryPrompt((Activity) mActivity); } + } else if (mEmptyGalleryPrompt != null) { + mEmptyGalleryPrompt = null; + } + } + } + + private AlertDialog mEmptyGalleryPrompt; + + private void emptyGalleryPrompt(final Context c) { + if (mEmptyGalleryPrompt != null) { + mEmptyGalleryPrompt.show(); + return; + } + + AlertDialog.Builder builder = new AlertDialog.Builder(c); + builder.setTitle(R.string.empty_album); + builder.setNegativeButton(android.R.string.ok, new OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.cancel(); } + }); + if(GalleryUtils.isCameraAvailable(c)) { + builder.setPositiveButton(R.string.switch_to_camera, + new OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.cancel(); + GalleryUtils.startCameraActivity(c); + } + }); } + mEmptyGalleryPrompt = builder.create(); + mEmptyGalleryPrompt.show(); } private void setLoadingBit(int loadingBit) { @@ -317,6 +355,7 @@ public class AlbumSetPage extends ActivityState implements @Override public void onPause() { + if (mEmptyGalleryPrompt != null) mEmptyGalleryPrompt.dismiss(); super.onPause(); mIsActive = false; mActionModeHandler.pause(); -- GitLab From 02ef48574ef7099ebaa0386bd6fd676bd2fd5489 Mon Sep 17 00:00:00 2001 From: Bobby Georgescu Date: Fri, 24 Aug 2012 23:59:28 -0700 Subject: [PATCH 218/763] Make transition from album page to photo page even smoother Bug: 6979922 Bug: 7050303 Change-Id: Iaa2582125f0706a34317fa90fea73749cd2cf995 --- src/com/android/gallery3d/app/AlbumPage.java | 5 ++--- src/com/android/gallery3d/app/PhotoPage.java | 4 ++-- src/com/android/gallery3d/ui/PositionController.java | 4 +--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java index 5328678ab..8e65bc0b9 100644 --- a/src/com/android/gallery3d/app/AlbumPage.java +++ b/src/com/android/gallery3d/app/AlbumPage.java @@ -269,10 +269,9 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster } else { // Show pressed-up animation for the single-tap. mAlbumView.setPressedIndex(slotIndex); - mAlbumView.setPressedUp(); - mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_PICK_PHOTO, slotIndex, 0), - FadeTexture.DURATION); prepareFadeOutTexture(); + mAlbumView.setPressedIndex(-1); + pickPhoto(slotIndex); } } diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index 2458b9a98..43867bbfe 100644 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -133,7 +133,7 @@ public class PhotoPage extends ActivityState implements private RawTexture mFadeOutTexture; private Rect mOpenAnimationRect; - public static final int ANIM_TIME_OPENING = 300; + public static final int ANIM_TIME_OPENING = 400; // The item that is deleted (but it can still be undeleted before commiting) private Path mDeletePath; @@ -191,7 +191,7 @@ public class PhotoPage extends ActivityState implements view.setAlpha(fadeAlpha); } mFadeOutTexture.draw(view, 0, 0); - view.setAlpha(1f); + view.setAlpha(1f - fadeAlpha); return; } } diff --git a/src/com/android/gallery3d/ui/PositionController.java b/src/com/android/gallery3d/ui/PositionController.java index b1b3c37ab..16e9f7ba1 100644 --- a/src/com/android/gallery3d/ui/PositionController.java +++ b/src/com/android/gallery3d/ui/PositionController.java @@ -1417,12 +1417,10 @@ class PositionController { case ANIM_KIND_CAPTURE: progress = 1 - f; // linear break; + case ANIM_KIND_OPENING: case ANIM_KIND_SCALE: progress = 1 - f * f; // quadratic break; - case ANIM_KIND_OPENING: - progress = 1 - f * f * f; // x^3 - break; case ANIM_KIND_SNAPBACK: case ANIM_KIND_ZOOM: case ANIM_KIND_SLIDE: -- GitLab From 541e25df9f933d58d4678f58519558473db5a333 Mon Sep 17 00:00:00 2001 From: Bobby Georgescu Date: Fri, 24 Aug 2012 23:25:23 -0700 Subject: [PATCH 219/763] Reskin: show placeholder color before album label is ready Bug: 7050303 Change-Id: I679ecf6360f2ae3bfe19fc0677998ac8b1589bcf --- res/values/colors.xml | 2 +- src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/res/values/colors.xml b/res/values/colors.xml index 96db24368..c4afedef2 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -18,7 +18,7 @@ #FF000000 - #FFDDDDDD + #FF444444 #FFCCCCCC #FF000000 #80000000 diff --git a/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java b/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java index a1f2b4c4f..f2b576f5f 100644 --- a/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java +++ b/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java @@ -174,11 +174,13 @@ public class AlbumSetSlotRenderer extends AbstractSlotRenderer { protected int renderLabel( GLCanvas canvas, AlbumSetEntry entry, int width, int height) { Texture content = checkTexture(entry.labelTexture); - if (content != null) { - int b = AlbumLabelMaker.getBorderSize(); - int h = content.getHeight(); - content.draw(canvas, -b, height - h + b, width + b + b, h); + if (content == null) { + content = mWaitLoadingTexture; } + int b = AlbumLabelMaker.getBorderSize(); + int h = mLabelSpec.labelBackgroundHeight; + content.draw(canvas, -b, height - h + b, width + b + b, h); + return 0; } -- GitLab From b0c2d70af79673fed3fda13657f92bccec35da19 Mon Sep 17 00:00:00 2001 From: Angus Kong Date: Mon, 27 Aug 2012 12:47:21 +0800 Subject: [PATCH 220/763] Add LightCycle helper class. LightCycleHelper also receives event of package changes to get updated. bug:6912297 Change-Id: Ib822ee778537b64986389bf8eeec36f61c9289f2 --- .../gallery3d/common/LightCycleHelper.java | 79 +++++++++++++++++++ .../gallery3d/app/PackagesMonitor.java | 4 + 2 files changed, 83 insertions(+) create mode 100644 gallerycommon/src/com/android/gallery3d/common/LightCycleHelper.java diff --git a/gallerycommon/src/com/android/gallery3d/common/LightCycleHelper.java b/gallerycommon/src/com/android/gallery3d/common/LightCycleHelper.java new file mode 100644 index 000000000..f8df29dd4 --- /dev/null +++ b/gallerycommon/src/com/android/gallery3d/common/LightCycleHelper.java @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2012 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.android.gallery3d.common; + +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageManager; + +public class LightCycleHelper { + public static final String LIGHTCYCLE_PACKAGE = + "com.google.android.apps.lightcycle"; + public static final String LIGHTCYCLE_CAPTURE_CLASS = + "com.google.android.apps.lightcycle.PanoramaCaptureActivity"; + public static final String LIGHTCYCLE_VIEW_CLASS = + "com.google.android.apps.lightcycle.PanoramaViewActivity"; + public static final String EXTRA_OUTPUT_DIR = "output_dir"; + + private static boolean sUpdated; + private static boolean sHasViewActivity; + private static boolean sHasCaptureActivity; + + private static boolean hasLightCycleActivity(PackageManager pm, String activityClass) { + Intent it = new Intent(); + it.setClassName(LIGHTCYCLE_PACKAGE, activityClass); + return (pm.resolveActivity(it, 0) != null); + } + + private static void update(PackageManager pm) { + sUpdated = true; + sHasViewActivity = hasLightCycleActivity(pm, LIGHTCYCLE_VIEW_CLASS); + sHasCaptureActivity = hasLightCycleActivity(pm, LIGHTCYCLE_CAPTURE_CLASS); + } + + public synchronized static boolean hasLightCycleView(PackageManager pm) { + if (!sUpdated) { + update(pm); + } + return sHasViewActivity; + } + + public synchronized static boolean hasLightCycleCapture(PackageManager pm) { + if (!sUpdated) { + update(pm); + } + return sHasCaptureActivity; + } + + public synchronized static void onPackageAdded(Context context, String packageName) { + if (LIGHTCYCLE_PACKAGE.equals(packageName)) { + update(context.getPackageManager()); + } + } + + public synchronized static void onPackageRemoved(Context context, String packageName) { + if (LIGHTCYCLE_PACKAGE.equals(packageName)) { + update(context.getPackageManager()); + } + } + + public synchronized static void onPackageChanged(Context context, String packageName) { + if (LIGHTCYCLE_PACKAGE.equals(packageName)) { + update(context.getPackageManager()); + } + } +} diff --git a/src/com/android/gallery3d/app/PackagesMonitor.java b/src/com/android/gallery3d/app/PackagesMonitor.java index d8aa8c914..05a2bd7f6 100644 --- a/src/com/android/gallery3d/app/PackagesMonitor.java +++ b/src/com/android/gallery3d/app/PackagesMonitor.java @@ -23,6 +23,7 @@ import android.content.Intent; import android.content.SharedPreferences; import android.preference.PreferenceManager; +import com.android.gallery3d.common.LightCycleHelper; import com.android.gallery3d.picasasource.PicasaSource; public class PackagesMonitor extends BroadcastReceiver { @@ -61,10 +62,13 @@ public class PackagesMonitor extends BroadcastReceiver { String packageName = intent.getData().getSchemeSpecificPart(); if (Intent.ACTION_PACKAGE_ADDED.equals(action)) { PicasaSource.onPackageAdded(context, packageName); + LightCycleHelper.onPackageAdded(context, packageName); } else if (Intent.ACTION_PACKAGE_REMOVED.equals(action)) { PicasaSource.onPackageRemoved(context, packageName); + LightCycleHelper.onPackageRemoved(context, packageName); } else if (Intent.ACTION_PACKAGE_CHANGED.equals(action)) { PicasaSource.onPackageChanged(context, packageName); + LightCycleHelper.onPackageChanged(context, packageName); } } } -- GitLab From a0ce682e40c39ce046c48d8a7f989fff01bb9f2c Mon Sep 17 00:00:00 2001 From: Wu-cheng Li Date: Wed, 22 Aug 2012 19:15:35 +0800 Subject: [PATCH 221/763] Add secure album support for lock screen camera. Secure album only shows the media items added by the camera. bug:5955016 Change-Id: Id26abec4dfcc036cf9de682398fed25eed73d1a5 --- src/com/android/gallery3d/app/AppBridge.java | 2 + src/com/android/gallery3d/app/PhotoPage.java | 16 ++++ .../gallery3d/data/ChangeNotifier.java | 8 +- .../android/gallery3d/data/DataManager.java | 1 + .../android/gallery3d/data/LocalAlbumSet.java | 16 ++-- .../android/gallery3d/data/SecureAlbum.java | 96 +++++++++++++++++++ .../android/gallery3d/data/SecureSource.java | 48 ++++++++++ 7 files changed, 176 insertions(+), 11 deletions(-) create mode 100644 src/com/android/gallery3d/data/SecureAlbum.java create mode 100644 src/com/android/gallery3d/data/SecureSource.java diff --git a/src/com/android/gallery3d/app/AppBridge.java b/src/com/android/gallery3d/app/AppBridge.java index e3deb810d..ee55fa6db 100644 --- a/src/com/android/gallery3d/app/AppBridge.java +++ b/src/com/android/gallery3d/app/AppBridge.java @@ -63,6 +63,8 @@ public abstract class AppBridge implements Parcelable { public void setSwipingEnabled(boolean enabled); // Notify that the ScreenNail is changed. public void notifyScreenNailChanged(); + // Add a new media item to the secure album. + public void addSecureAlbumItem(boolean isVideo, int id); } // If server is null, the services are not available. diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index 43867bbfe..2f8573e60 100644 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -46,6 +46,8 @@ import com.android.gallery3d.data.MediaObject; import com.android.gallery3d.data.MediaSet; import com.android.gallery3d.data.MtpSource; import com.android.gallery3d.data.Path; +import com.android.gallery3d.data.SecureAlbum; +import com.android.gallery3d.data.SecureSource; import com.android.gallery3d.data.SnailAlbum; import com.android.gallery3d.data.SnailItem; import com.android.gallery3d.data.SnailSource; @@ -112,6 +114,9 @@ public class PhotoPage extends ActivityState implements // E.g., viewing a photo in gmail attachment private FilterDeleteSet mMediaSet; + // The mediaset used by camera launched from secure lock screen. + private SecureAlbum mSecureAlbum; + private int mCurrentIndex = 0; private Handler mHandler; private boolean mShowBars = true; @@ -244,6 +249,12 @@ public class PhotoPage extends ActivityState implements .getMediaObject(screenNailItemPath); mScreenNailItem.setScreenNail(mAppBridge.attachScreenNail()); + // Check if the path is a secure album. + if (SecureSource.isSecurePath(mSetPathString)) { + mSecureAlbum = (SecureAlbum) mActivity.getDataManager() + .getMediaSet(mSetPathString); + } + // Combine the original MediaSet with the one for ScreenNail // from AppBridge. mSetPathString = "/combo/item/{" + screenNailSetPath + @@ -579,6 +590,11 @@ public class PhotoPage extends ActivityState implements mScreenNailSet.notifyChange(); } + @Override + public void addSecureAlbumItem(boolean isVideo, int id) { + mSecureAlbum.addMediaItem(isVideo, id); + } + @Override protected boolean onCreateActionBar(Menu menu) { mActionBar.createActionBarMenu(R.menu.photo, menu); diff --git a/src/com/android/gallery3d/data/ChangeNotifier.java b/src/com/android/gallery3d/data/ChangeNotifier.java index 35be2dc5b..558a8648e 100644 --- a/src/com/android/gallery3d/data/ChangeNotifier.java +++ b/src/com/android/gallery3d/data/ChangeNotifier.java @@ -33,12 +33,18 @@ public class ChangeNotifier { application.getDataManager().registerChangeNotifier(uri, this); } + public ChangeNotifier(MediaSet set, Uri[] uris, GalleryApp application) { + mMediaSet = set; + for (int i = 0; i < uris.length; i++) { + application.getDataManager().registerChangeNotifier(uris[i], this); + } + } + // Returns the dirty flag and clear it. public boolean isDirty() { return mContentDirty.compareAndSet(true, false); } - // For debugging only. public void fakeChange() { onChange(false); } diff --git a/src/com/android/gallery3d/data/DataManager.java b/src/com/android/gallery3d/data/DataManager.java index 386f6c3fc..0b4dae2c2 100644 --- a/src/com/android/gallery3d/data/DataManager.java +++ b/src/com/android/gallery3d/data/DataManager.java @@ -127,6 +127,7 @@ public class DataManager { addSource(new ComboSource(mApplication)); addSource(new ClusterSource(mApplication)); addSource(new FilterSource(mApplication)); + addSource(new SecureSource(mApplication)); addSource(new UriSource(mApplication)); addSource(new SnailSource(mApplication)); diff --git a/src/com/android/gallery3d/data/LocalAlbumSet.java b/src/com/android/gallery3d/data/LocalAlbumSet.java index 579a71e9b..5d01c064a 100644 --- a/src/com/android/gallery3d/data/LocalAlbumSet.java +++ b/src/com/android/gallery3d/data/LocalAlbumSet.java @@ -43,14 +43,13 @@ public class LocalAlbumSet extends MediaSet private static final String TAG = "LocalAlbumSet"; - private static final Uri mWatchUriImage = Images.Media.EXTERNAL_CONTENT_URI; - private static final Uri mWatchUriVideo = Video.Media.EXTERNAL_CONTENT_URI; + private static final Uri[] mWatchUris = + {Images.Media.EXTERNAL_CONTENT_URI, Video.Media.EXTERNAL_CONTENT_URI}; private final GalleryApp mApplication; private final int mType; private ArrayList mAlbums = new ArrayList(); - private final ChangeNotifier mNotifierImage; - private final ChangeNotifier mNotifierVideo; + private final ChangeNotifier mNotifier; private final String mName; private final Handler mHandler; private boolean mIsLoading; @@ -63,8 +62,7 @@ public class LocalAlbumSet extends MediaSet mApplication = application; mHandler = new Handler(application.getMainLooper()); mType = getTypeFromPath(path); - mNotifierImage = new ChangeNotifier(this, mWatchUriImage, application); - mNotifierVideo = new ChangeNotifier(this, mWatchUriVideo, application); + mNotifier = new ChangeNotifier(this, mWatchUris, application); mName = application.getResources().getString( R.string.set_label_local_albums); } @@ -165,8 +163,7 @@ public class LocalAlbumSet extends MediaSet // 1. Prevent calling reload() concurrently. // 2. Prevent calling onFutureDone() and reload() concurrently public synchronized long reload() { - // "|" is used instead of "||" because we want to clear both flags. - if (mNotifierImage.isDirty() | mNotifierVideo.isDirty()) { + if (mNotifier.isDirty()) { if (mLoadTask != null) mLoadTask.cancel(); mIsLoading = true; mLoadTask = mApplication.getThreadPool().submit(new AlbumsLoader(), this); @@ -198,8 +195,7 @@ public class LocalAlbumSet extends MediaSet // For debug only. Fake there is a ContentObserver.onChange() event. void fakeChange() { - mNotifierImage.fakeChange(); - mNotifierVideo.fakeChange(); + mNotifier.fakeChange(); } // Circular shift the array range from a[i] to a[j] (inclusive). That is, diff --git a/src/com/android/gallery3d/data/SecureAlbum.java b/src/com/android/gallery3d/data/SecureAlbum.java new file mode 100644 index 000000000..a8de5ddcf --- /dev/null +++ b/src/com/android/gallery3d/data/SecureAlbum.java @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2012 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.android.gallery3d.data; + +import android.net.Uri; +import android.provider.MediaStore.Images; +import android.provider.MediaStore.Video; + +import com.android.gallery3d.app.GalleryApp; + +import java.util.ArrayList; + +// This class lists all media items added by the client. +public class SecureAlbum extends MediaSet { + @SuppressWarnings("unused") + private static final String TAG = "SecureAlbum"; + private ArrayList mItems = new ArrayList(); + private DataManager mDataManager; + private static final Uri[] mWatchUris = + {Images.Media.EXTERNAL_CONTENT_URI, Video.Media.EXTERNAL_CONTENT_URI}; + private final ChangeNotifier mNotifier; + + public SecureAlbum(Path path, GalleryApp application) { + super(path, nextVersionNumber()); + mDataManager = application.getDataManager(); + mNotifier = new ChangeNotifier(this, mWatchUris, application); + } + + public void addMediaItem(boolean isVideo, int id) { + if (isVideo) { + mItems.add(0, Path.fromString("/local/video/item/" + id)); + } else { + mItems.add(0, Path.fromString("/local/image/item/" + id)); + } + mNotifier.fakeChange(); + } + + @Override + public ArrayList getMediaItem(int start, int count) { + if (start >= mItems.size()) { + return new ArrayList(); + } + int end = Math.min(start + count, mItems.size()); + ArrayList subset = new ArrayList(mItems.subList(start, end)); + final MediaItem[] buf = new MediaItem[end - start]; + ItemConsumer consumer = new ItemConsumer() { + @Override + public void consume(int index, MediaItem item) { + buf[index] = item; + } + }; + mDataManager.mapMediaItems(subset, consumer, 0); + ArrayList result = new ArrayList(end - start); + for (int i = 0; i < buf.length; i++) { + result.add(buf[i]); + } + return result; + } + + @Override + public int getMediaItemCount() { + return mItems.size(); + } + + @Override + public String getName() { + return "secure"; + } + + @Override + public long reload() { + if (mNotifier.isDirty()) { + mDataVersion = nextVersionNumber(); + } + return mDataVersion; + } + + @Override + public boolean isLeafAlbum() { + return true; + } +} diff --git a/src/com/android/gallery3d/data/SecureSource.java b/src/com/android/gallery3d/data/SecureSource.java new file mode 100644 index 000000000..9e89438e6 --- /dev/null +++ b/src/com/android/gallery3d/data/SecureSource.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2012 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.android.gallery3d.data; + +import com.android.gallery3d.app.GalleryApp; + +public class SecureSource extends MediaSource { + private GalleryApp mApplication; + private static PathMatcher mMatcher = new PathMatcher(); + private static final int SECURE_ALBUM = 0; + + static { + mMatcher.add("/secure/all/*", SECURE_ALBUM); + } + + public SecureSource(GalleryApp context) { + super("secure"); + mApplication = context; + } + + public static boolean isSecurePath(String path) { + return (SECURE_ALBUM == mMatcher.match(Path.fromString(path))); + } + + @Override + public MediaObject createMediaObject(Path path) { + switch (mMatcher.match(path)) { + case SECURE_ALBUM: + return new SecureAlbum(path, mApplication); + default: + throw new RuntimeException("bad path: " + path); + } + } +} -- GitLab From 45c56f2d34c71d0bc9b84ebeef6d1314738d0fc0 Mon Sep 17 00:00:00 2001 From: Bobby Georgescu Date: Sun, 26 Aug 2012 23:47:19 -0700 Subject: [PATCH 222/763] Reskin: tweaks to colors and spacings to match mocks Bug: 7050303 - Call super.onCreate in ActivityState subclasses in order to correctly initialize background colors, correcting oversight in previous change - Tweak background and label colors to match mocks - Tweak grid spacings to match mocks Change-Id: Iba5cba6c60e8a750d8e50c1d0c14c916754a95c2 --- res/values/colors.xml | 28 +++++++++---------- res/values/dimensions.xml | 2 +- src/com/android/gallery3d/app/AlbumPage.java | 1 + .../android/gallery3d/app/AlbumSetPage.java | 1 + src/com/android/gallery3d/app/PhotoPage.java | 1 + .../android/gallery3d/app/SlideshowPage.java | 1 + 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/res/values/colors.xml b/res/values/colors.xml index c4afedef2..e86d236bd 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -14,28 +14,28 @@ limitations under the License. --> - #FF000000 + #000 - #FF000000 - #FF444444 - #FFCCCCCC - #FF000000 - #80000000 + #181A19 + #777 + #BBB + #171717 + #6F6F6F - #FF000000 - #FFDDDDDD + #181A19 + #777 - #FF000000 - #FF222222 + #181A19 + #777 - #FF000000 - #FFDDDDDD + #181A19 + #777 - #FF222222 + #777 - #FF000000 + #181A19 diff --git a/res/values/dimensions.xml b/res/values/dimensions.xml index e586f9329..c425feade 100644 --- a/res/values/dimensions.xml +++ b/res/values/dimensions.xml @@ -38,7 +38,7 @@ 2 4 - 4dp + 5dp 24dp diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java index 8e65bc0b9..195c8e71a 100644 --- a/src/com/android/gallery3d/app/AlbumPage.java +++ b/src/com/android/gallery3d/app/AlbumPage.java @@ -358,6 +358,7 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster @Override protected void onCreate(Bundle data, Bundle restoreState) { + super.onCreate(data, restoreState); mUserDistance = GalleryUtils.meterToPixel(USER_DISTANCE_METER); initializeViews(); initializeData(data); diff --git a/src/com/android/gallery3d/app/AlbumSetPage.java b/src/com/android/gallery3d/app/AlbumSetPage.java index f0f4354e1..c7046be7d 100644 --- a/src/com/android/gallery3d/app/AlbumSetPage.java +++ b/src/com/android/gallery3d/app/AlbumSetPage.java @@ -272,6 +272,7 @@ public class AlbumSetPage extends ActivityState implements @Override public void onCreate(Bundle data, Bundle restoreState) { + super.onCreate(data, restoreState); initializeViews(); initializeData(data); Context context = mActivity.getAndroidContext(); diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index 2f8573e60..4698b88d0 100644 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -215,6 +215,7 @@ public class PhotoPage extends ActivityState implements @Override public void onCreate(Bundle data, Bundle restoreState) { + super.onCreate(data, restoreState); mActionBar = mActivity.getGalleryActionBar(); mSelectionManager = new SelectionManager(mActivity, false); mMenuExecutor = new MenuExecutor(mActivity, mSelectionManager); diff --git a/src/com/android/gallery3d/app/SlideshowPage.java b/src/com/android/gallery3d/app/SlideshowPage.java index 09a239e25..9c52b9106 100644 --- a/src/com/android/gallery3d/app/SlideshowPage.java +++ b/src/com/android/gallery3d/app/SlideshowPage.java @@ -111,6 +111,7 @@ public class SlideshowPage extends ActivityState { @Override public void onCreate(Bundle data, Bundle restoreState) { + super.onCreate(data, restoreState); mFlags |= (FLAG_HIDE_ACTION_BAR | FLAG_HIDE_STATUS_BAR); if (data.getBoolean(KEY_DREAM)) { // Dream screensaver only keeps screen on for plugged devices. -- GitLab From 50ea2d2938218ac6b2039f0e42998cfbbc45d1f1 Mon Sep 17 00:00:00 2001 From: Teng-Hui Zhu Date: Thu, 23 Aug 2012 16:45:11 -0700 Subject: [PATCH 223/763] add the menu button to support trimming This is only visible for video item. Change-Id: I17f8e902f3560cc8524f890705c020901331df74 --- res/menu/photo.xml | 3 +++ res/values/strings.xml | 1 + src/com/android/gallery3d/app/PhotoPage.java | 4 ++++ src/com/android/gallery3d/data/LocalVideo.java | 2 +- src/com/android/gallery3d/data/MediaObject.java | 1 + src/com/android/gallery3d/ui/MenuExecutor.java | 2 ++ 6 files changed, 12 insertions(+), 1 deletion(-) diff --git a/res/menu/photo.xml b/res/menu/photo.xml index b3820c3a6..eb23684ad 100644 --- a/res/menu/photo.xml +++ b/res/menu/photo.xml @@ -48,6 +48,9 @@ + diff --git a/res/values/strings.xml b/res/values/strings.xml index 0000c61e4..a52723bfa 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -175,6 +175,7 @@ Caching\u2026 Crop + Trim Set as diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index 4698b88d0..2d2375bd3 100644 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -668,6 +668,10 @@ public class PhotoPage extends ActivityState implements : REQUEST_CROP); return true; } + case R.id.action_trim: { + // TODO: Add trimming activity here. + return true; + } case R.id.action_edit: { Intent intent = new Intent(Intent.ACTION_EDIT) .setData(manager.getContentUri(path)) diff --git a/src/com/android/gallery3d/data/LocalVideo.java b/src/com/android/gallery3d/data/LocalVideo.java index 5ccc21b93..addb8fdbd 100644 --- a/src/com/android/gallery3d/data/LocalVideo.java +++ b/src/com/android/gallery3d/data/LocalVideo.java @@ -178,7 +178,7 @@ public class LocalVideo extends LocalMediaItem { @Override public int getSupportedOperations() { - return SUPPORT_DELETE | SUPPORT_SHARE | SUPPORT_PLAY | SUPPORT_INFO; + return SUPPORT_DELETE | SUPPORT_SHARE | SUPPORT_PLAY | SUPPORT_INFO | SUPPORT_TRIM; } @Override diff --git a/src/com/android/gallery3d/data/MediaObject.java b/src/com/android/gallery3d/data/MediaObject.java index 0ed5b7a9a..45f425fdd 100644 --- a/src/com/android/gallery3d/data/MediaObject.java +++ b/src/com/android/gallery3d/data/MediaObject.java @@ -36,6 +36,7 @@ public abstract class MediaObject { public static final int SUPPORT_EDIT = 1 << 9; public static final int SUPPORT_INFO = 1 << 10; public static final int SUPPORT_IMPORT = 1 << 11; + public static final int SUPPORT_TRIM = 1 << 12; public static final int SUPPORT_ALL = 0xffffffff; // These are the bits returned from getMediaType(): diff --git a/src/com/android/gallery3d/ui/MenuExecutor.java b/src/com/android/gallery3d/ui/MenuExecutor.java index 7bccda84c..691056294 100644 --- a/src/com/android/gallery3d/ui/MenuExecutor.java +++ b/src/com/android/gallery3d/ui/MenuExecutor.java @@ -160,6 +160,7 @@ public class MenuExecutor { boolean supportDelete = (supported & MediaObject.SUPPORT_DELETE) != 0; boolean supportRotate = (supported & MediaObject.SUPPORT_ROTATE) != 0; boolean supportCrop = (supported & MediaObject.SUPPORT_CROP) != 0; + boolean supportTrim = (supported & MediaObject.SUPPORT_TRIM) != 0; boolean supportShare = (supported & MediaObject.SUPPORT_SHARE) != 0; boolean supportSetAs = (supported & MediaObject.SUPPORT_SETAS) != 0; boolean supportShowOnMap = (supported & MediaObject.SUPPORT_SHOW_ON_MAP) != 0; @@ -172,6 +173,7 @@ public class MenuExecutor { setMenuItemVisible(menu, R.id.action_rotate_ccw, supportRotate); setMenuItemVisible(menu, R.id.action_rotate_cw, supportRotate); setMenuItemVisible(menu, R.id.action_crop, supportCrop); + setMenuItemVisible(menu, R.id.action_trim, supportTrim); setMenuItemVisible(menu, R.id.action_share, supportShare); setMenuItemVisible(menu, R.id.action_setas, supportSetAs); setMenuItemVisible(menu, R.id.action_show_on_map, supportShowOnMap); -- GitLab From 46f9d24b8440fe790aa4bdd625dbf231b140df17 Mon Sep 17 00:00:00 2001 From: Wu-cheng Li Date: Sat, 25 Aug 2012 21:10:04 +0800 Subject: [PATCH 224/763] Add api check for camera HDR. bug:7054776 Change-Id: Id551b7f1d76168b7735f0a48c19619431b93b66e --- gallerycommon/src/com/android/gallery3d/common/ApiHelper.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java index c726719a8..402424123 100644 --- a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java +++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java @@ -35,6 +35,7 @@ public class ApiHelper { public static final int ICE_CREAM_SANDWICH = 14; public static final int ICE_CREAM_SANDWICH_MR1 = 15; public static final int JELLY_BEAN = 16; + public static final int JELLY_BEAN_MR1 = 17; } public static final boolean ENABLE_PHOTO_EDITOR = @@ -147,6 +148,9 @@ public class ApiHelper { public static final boolean HAS_VIEW_TRANSFORM_PROPERTIES = Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB; + public static final boolean HAS_CAMERA_HDR = + Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1; + public static final boolean CAN_START_PREVIEW_IN_JPEG_CALLBACK = Build.VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH; -- GitLab From 898a2f4540635528a0916b0a6b0a177869854ae9 Mon Sep 17 00:00:00 2001 From: Wu-cheng Li Date: Mon, 27 Aug 2012 00:10:38 +0800 Subject: [PATCH 225/763] Disable action bar home button and menu items in secure album. All menu items are disabled except delete. bug:5955016 Change-Id: Ibf947b0c50b0591a774d298fbfbe692c9a88575d --- src/com/android/gallery3d/app/PhotoPage.java | 22 ++++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index 2d2375bd3..4b4817943 100644 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -416,7 +416,8 @@ public class PhotoPage extends ActivityState implements if (mShowDetails) { mDetailsHelper.reloadDetails(); } - if ((photo.getSupportedOperations() & MediaItem.SUPPORT_SHARE) != 0) { + if ((mSecureAlbum == null) + && (photo.getSupportedOperations() & MediaItem.SUPPORT_SHARE) != 0) { updateShareURI(photo.getPath()); } } @@ -434,10 +435,12 @@ public class PhotoPage extends ActivityState implements private void updateMenuOperations() { MenuItem item = mActionBar.findMenuItem(R.id.action_slideshow); - item.setVisible(canDoSlideShow()); + item.setVisible((mSecureAlbum == null) && canDoSlideShow()); if (mCurrentPhoto == null) return; int supportedOperations = mCurrentPhoto.getSupportedOperations(); - if (!GalleryUtils.isEditorAvailable((Context) mActivity, "image/*")) { + if (mSecureAlbum != null) { + supportedOperations = supportedOperations & MediaObject.SUPPORT_DELETE; + } else if (!GalleryUtils.isEditorAvailable(mActivity, "image/*")) { supportedOperations &= ~MediaObject.SUPPORT_EDIT; } MenuExecutor.updateMenuOperation(mActionBar.getMenu(), supportedOperations); @@ -659,7 +662,7 @@ public class PhotoPage extends ActivityState implements return true; } case R.id.action_crop: { - Activity activity = (Activity) mActivity; + Activity activity = mActivity; Intent intent = new Intent(CropImage.CROP_ACTION); intent.setClass(activity, CropImage.class); intent.setData(manager.getContentUri(path)); @@ -706,7 +709,7 @@ public class PhotoPage extends ActivityState implements new ImportCompleteListener(mActivity)); return true; case R.id.action_share: - Activity activity = (Activity) mActivity; + Activity activity = mActivity; Intent intent = createShareIntent(mCurrentPhoto.getPath()); activity.startActivity(Intent.createChooser(intent, activity.getString(R.string.share))); @@ -750,8 +753,8 @@ public class PhotoPage extends ActivityState implements return; } - boolean playVideo = - (item.getSupportedOperations() & MediaItem.SUPPORT_PLAY) != 0; + boolean playVideo = (mSecureAlbum == null) && + ((item.getSupportedOperations() & MediaItem.SUPPORT_PLAY) != 0); if (playVideo) { // determine if the point is at center (1/6) of the photo view. @@ -763,7 +766,7 @@ public class PhotoPage extends ActivityState implements } if (playVideo) { - playVideo((Activity) mActivity, item.getPlayUri(), item.getName()); + playVideo(mActivity, item.getPlayUri(), item.getName()); } else { toggleBars(); } @@ -960,7 +963,8 @@ public class PhotoPage extends ActivityState implements mModel.resume(); mPhotoView.resume(); - mActionBar.setDisplayOptions(mSetPathString != null, true); + mActionBar.setDisplayOptions( + ((mSecureAlbum == null) && (mSetPathString != null)), true); mActionBar.addOnMenuVisibilityListener(mMenuVisibilityListener); if (mAppBridge != null && !mHasActivityResult) { -- GitLab From 3fa6947fc3909020f3a37cc1fd9a9b9d4d9f93e8 Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Mon, 27 Aug 2012 10:01:22 +0800 Subject: [PATCH 226/763] Fix some UI bugs in using SherlockActionBar. - Use sherlock's verion of requestWindowFeature. - Use sherlock's theme in Custom selection list. bug: 6927267 Change-Id: I706e45378b10e6e088e048d97fcaca57fb4bf3f4 --- res/layout/action_mode.xml | 4 +++- res/layout/popup_list_item.xml | 5 ++-- res/values-v11/styles.xml | 23 ------------------- res/values/styles.xml | 2 +- src/com/android/gallery3d/app/CropImage.java | 2 +- src/com/android/gallery3d/app/Gallery.java | 2 +- .../android/gallery3d/app/MovieActivity.java | 4 ++-- .../android/gallery3d/app/PickerActivity.java | 2 +- src/com/android/gallery3d/ui/PopupList.java | 4 +++- 9 files changed, 15 insertions(+), 33 deletions(-) delete mode 100644 res/values-v11/styles.xml diff --git a/res/layout/action_mode.xml b/res/layout/action_mode.xml index d4b3c23d3..9650de69d 100644 --- a/res/layout/action_mode.xml +++ b/res/layout/action_mode.xml @@ -29,8 +29,10 @@ android:layout_height="match_parent" android:src="@drawable/dropdown_ic_arrow_normal_holo_dark" />