From fb9ea894be4209ee3893c5a6b5362e1f8cfd030f Mon Sep 17 00:00:00 2001 From: "dkeen@dkeen-laptop" Date: Sun, 22 Jul 2012 07:57:17 -0700 Subject: [PATCH] All context menus switched to action mode pattern. Completed transition to Holo theme. --- AndroidManifest.xml | 4 +- board.svg | 92 +++++ departure.png | Bin 0 -> 2078 bytes departure.svg | 203 +++++++++++ departure_Med.png | Bin 0 -> 742 bytes res/drawable-hdpi/actionbar_shadow.9.png | Bin 953 -> 0 bytes res/drawable-hdpi/boarding_icon.png | Bin 0 -> 1250 bytes res/drawable-hdpi/delete_icon.png | Bin 0 -> 1611 bytes res/drawable-hdpi/departure_icon.png | Bin 0 -> 1490 bytes res/drawable-mdpi/actionbar_shadow.9.png | Bin 952 -> 0 bytes res/drawable-mdpi/boarding_icon.png | Bin 0 -> 817 bytes res/drawable-mdpi/delete_icon.png | Bin 0 -> 1358 bytes res/drawable-mdpi/departure_icon.png | Bin 0 -> 1020 bytes res/drawable/actionbar_compat_item.xml | 23 -- .../actionbar_compat_item_focused.xml | 19 - .../actionbar_compat_item_pressed.xml | 19 - res/drawable/btn_borderless_holo_dark.xml | 11 + res/drawable/transparent.xml | 5 + .../actionbar_indeterminate_progress.xml | 27 -- .../simple_spinner_dropdown_item.xml | 14 + res/layout/actionbar_compat.xml | 21 -- res/layout/route_form.xml | 83 +++-- res/layout/simple_spinner_dropdown_item.xml | 14 + res/layout/simple_spinner_item.xml | 19 +- res/menu/departure_context_menu.xml | 7 +- res/menu/route_context_menu.xml | 20 +- res/values-v11/styles.xml | 40 +-- res/values-v13/styles.xml | 23 -- res/values/attrs.xml | 10 - res/values/colors.xml | 3 +- res/values/dimens.xml | 21 -- res/values/ids.xml | 23 -- res/values/strings.xml | 4 +- res/values/styles.xml | 54 +-- .../bart/AbstractRouteSelectionActivity.java | 16 +- src/com/dougkeen/bart/AddRouteActivity.java | 11 +- src/com/dougkeen/bart/RoutesListActivity.java | 168 ++++++--- .../dougkeen/bart/ViewDeparturesActivity.java | 114 +++--- src/com/dougkeen/bart/ViewMapActivity.java | 19 +- .../actionbarcompat/ActionBarActivity.java | 63 ---- .../bart/actionbarcompat/ActionBarHelper.java | 108 ------ .../actionbarcompat/ActionBarHelperBase.java | 327 ------------------ .../ActionBarHelperHoneycomb.java | 90 ----- .../actionbarcompat/ActionBarHelperICS.java | 35 -- .../ActionBarListActivity.java | 84 ----- .../bart/actionbarcompat/SimpleMenu.java | 203 ----------- .../bart/actionbarcompat/SimpleMenuItem.java | 263 -------------- src/com/dougkeen/bart/controls/Ticker.java | 2 +- src/com/dougkeen/bart/model/Departure.java | 14 +- 49 files changed, 680 insertions(+), 1596 deletions(-) create mode 100644 board.svg create mode 100644 departure.png create mode 100644 departure.svg create mode 100644 departure_Med.png delete mode 100644 res/drawable-hdpi/actionbar_shadow.9.png create mode 100644 res/drawable-hdpi/boarding_icon.png create mode 100644 res/drawable-hdpi/delete_icon.png create mode 100644 res/drawable-hdpi/departure_icon.png delete mode 100644 res/drawable-mdpi/actionbar_shadow.9.png create mode 100644 res/drawable-mdpi/boarding_icon.png create mode 100644 res/drawable-mdpi/delete_icon.png create mode 100644 res/drawable-mdpi/departure_icon.png delete mode 100644 res/drawable/actionbar_compat_item.xml delete mode 100644 res/drawable/actionbar_compat_item_focused.xml delete mode 100644 res/drawable/actionbar_compat_item_pressed.xml create mode 100644 res/drawable/btn_borderless_holo_dark.xml create mode 100644 res/drawable/transparent.xml delete mode 100644 res/layout-v11/actionbar_indeterminate_progress.xml create mode 100644 res/layout-v11/simple_spinner_dropdown_item.xml delete mode 100644 res/layout/actionbar_compat.xml create mode 100644 res/layout/simple_spinner_dropdown_item.xml delete mode 100644 res/values-v13/styles.xml delete mode 100644 res/values/dimens.xml delete mode 100644 res/values/ids.xml delete mode 100644 src/com/dougkeen/bart/actionbarcompat/ActionBarActivity.java delete mode 100644 src/com/dougkeen/bart/actionbarcompat/ActionBarHelper.java delete mode 100644 src/com/dougkeen/bart/actionbarcompat/ActionBarHelperBase.java delete mode 100644 src/com/dougkeen/bart/actionbarcompat/ActionBarHelperHoneycomb.java delete mode 100644 src/com/dougkeen/bart/actionbarcompat/ActionBarHelperICS.java delete mode 100644 src/com/dougkeen/bart/actionbarcompat/ActionBarListActivity.java delete mode 100644 src/com/dougkeen/bart/actionbarcompat/SimpleMenu.java delete mode 100644 src/com/dougkeen/bart/actionbarcompat/SimpleMenuItem.java diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 6827ac0..534ab20 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -43,7 +43,7 @@ + android:theme="@style/DialogHoloDark" > @@ -55,7 +55,7 @@ + android:theme="@style/DialogHoloDark" > diff --git a/board.svg b/board.svg new file mode 100644 index 0000000..d3a5e7f --- /dev/null +++ b/board.svg @@ -0,0 +1,92 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/departure.png b/departure.png new file mode 100644 index 0000000000000000000000000000000000000000..0dbf7ca206b1fca425a5d00dbace594e5a259c2b GIT binary patch literal 2078 zcmV+(2;ujMP)e@&qE$;qWJz^XKT@DpY6K3P z6ma1JL5udMMNuFD`kkWvF@m6I^HcPr=!g5!7AXoNtrMhf^Dv?|tsik^IhL)rWYLuP zvLwFA-aBXRotZm#20Q|^-GeR%iR0B98+2Ns(C4t0*GH4-`Ecz1dgS_Y zAj1^u=q@_2>ailO(L6uwKQrUHXDeZ-GFEp2u z020Sf9_%~r_g%RB(Y^IZ)8#{TVy6!e%Cai)d@Pxc=km#Hemk4X71%C|>DdE48VpmV zTZ3WW96$U85c^7hk5uLX7DBO^_3(TsHXn}V3hb`NufH@g+UrrPex%23qI9V|qxQp^ zP$Z@$@P6mc)W5y9aq(X_Bgu3XL7{kRv{$uy4Tg>Typ!`Qs=ur$S?LFVrvuk$03eym z|LV$Qbyh;N`g$QJ=UL6<`)Ob0gDVzH*6biM9$u**^9R}90x{p`rG0bg({ z{<}|ZpgXN1F=-2$55-UfaitQX%3bhS%_NR1jorl1z_*S*0{~vDnZPx_c>fbbv5KzP zEv|=4(M@$dRS6A-d97xpUyu8JQhD6xrAX9>LY^3gVeSqy02E85hg)$q{j3MwHq@<> zN0up1%weRp1P%b0{`q5(8XYT9e9CYwHZlAc1S&kwJlU~JEE>FyEG6;ozm|y_lFdCG8 z>UY}SJby+A)?OYP{>h)-i=}Gpr~>5Yn9ZOU3j5=VdM&9Z$;x^X$6q^rQVKyy9Dns2 zCor^#REZc306fo!5=q3)QF1*)hs{V=R(|)ySa;dFk}a@9p3axYhEW8{6SEs>0ElPv z=u0B4YlxV=g4o&7p)(_gvW3Uz(ZFWBz!hIPHcAn-ce831+e~NCdq!)u=#7;$3LtU( z#}miDck;^saOu`vsh;7uxlmMtVFpT9Q=kknJxS_F0suDC8T6jf+J-D<6=yX7e08Ab z)X+dAk$U63t5@#Kl{XW!Cbc(e8Jil#@la>6#$3^?e{6)$R)fF(@YBy$gAB{znkSZu zVu_djuMSyaJ5IHg**{k-|D0jDPZu5tA&3k8~|=C2LNDV z*pHYnl3Nu;9Yy4`qs^eNnMJJ*y24_aLID7#0~~R{^-=PL++KpW_&Z9N#_fxJd?^Z z2U3@oet5SFh(-_WRErJ>axewyYcTp;(^dM!H?n)N1-z z%2+HZ9=|8&R;Je0XE&m6U718r57oqtmB7#5`R5z&e*DWTlTu|KIZJ~G8Dc3h;23l{ zg%QnGTtPH~XmaP!aBDRvozR=B0%Tn=Arc$%biRJ})cuX7>)jwwiz&1v11QJlZancwuck((6Io5Yb_!^>4j$c6K8=&}ElG#G02LY9Zr_xdQv= z8`J2i$vR-rX^-}ITj|G#%b8%fxhmw72bZVr{p0g_uhs1CFn7>;hl%c>^>!nzB?vu9 zx;sn&!1H{u#7i#)P*5zD@+`*{OPN9;!|eQfl*)t>ssEN`e47HrtO&z#E3vJW*w(K4 zuMPIUcKRd$B=gJKe%`aJ+^KHs^57GiuYzq zkw;P`TP#+&Lt6~Tc%H{FOh*t0oVLZX5BCnLU*`D5dph*~WeaR@duLf6bUD>(tPkpl zX$f4q5L^ta82AOTv1IVQhB{*XPMdHsUE=wrh>8orh49X`=plD!m1d;|reBGFB05q> zOu8=)ZY6T8idaFq@3k8APLtvlL@bqAtyr!QaeX;Z{-?Ud)xZMMM}UAzjzM4^=fR}LQ{XgGj}HtQmbigbK6Ae!in_T*QXh7 z592ifHJR07*qo IM6N<$g2u`Gb^rhX literal 0 HcmV?d00001 diff --git a/departure.svg b/departure.svg new file mode 100644 index 0000000..8d86936 --- /dev/null +++ b/departure.svg @@ -0,0 +1,203 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/departure_Med.png b/departure_Med.png new file mode 100644 index 0000000000000000000000000000000000000000..795012912a49c2515e958a842b855b877ef8eee7 GIT binary patch literal 742 zcmVB@4GgGa`eLVbn}0xkQ*8i|767^Un8v-}{X;8~-}J&-1$O z=RD^*-=v5zk(fN8-v1N8lm_p+umWvZgjRgSJG{prdhu)A3?d>g3nJohMBIyVcpDKH zBVt>PwHnH#8mHhA_TeXP;w6T#4twf+%R{XH+XzgFhz}8QAtKsx?{=1m#>QqNkWa!b zn1{0%$-Vnr;(PYy=B>DkLq!I80;{CZ_tnt-Qi8y$+SnY$crM8s%Bd@6Yr zSI`#`m$UJ*h`3h5rXwQ8l;VTfjMY+ATq!jo1DK8(7{%92)=T%sYkZTA+E6nA$P;*$ zNd;FjN81bRhtZEC%{Z+_qn@x^x=xF58(VAq{&Fqi zsAKm4Z&0%*tVnxA^hfFui*(jzIM()AKy<=RI#W9%i?1Z!-*&tsfdKx^K~y zNvG)l;_a(%bh|~WUDC#VGO;m>#PA#fcXK9)`13@T{o9?nA4o;5o5Y-FnrEZqmiSfc_S zA{L0fBR|q&9nN(%dQPr62<8wn(&1H5U9$-)I7C2Z`JBz?d5{-aLE2Xo1p`HP=mx~aK1dX;9v%}N(nzmT@Pd`BA1%s63&zD(zzHm$q_hN@=KrCdw?apx zg|6dWD;#yE0peOH!sF1UjqC3vt^%zRB8%X#gYnU_ip?P=I2z&rRN68yE!*`IdyY3v zt?oy}@@-T%bVwCg*LAc5TH}IP5UY|Q3qqAI=cQ_;R#jwP5d>APEV%}@#~$*@lIvV^ zrH$NV6uf|XHc;rEAg2~$56n~6+%>TXikjaql+}%T3$C*!mIb%Gk;~CwxTLZFG&CCI^hxCEM!6Gz@BO~KEN$(cX6~la>6@7kg^L&H97g9q lUjEs6bLS)cvYUEvdV@KUvpb*8nopC*RIfISvx6tk{sPCWCuRTu diff --git a/res/drawable-hdpi/boarding_icon.png b/res/drawable-hdpi/boarding_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..8c4fd2c1d2b272f061ef806551afcdddf91f902e GIT binary patch literal 1250 zcmV<81ReW{P)!y{8Zc3zx7}Fmc-kD5I;!I|ocaDp^ zsgu|Fxzo&J8psC&@0@$iyWcn5zjrRFDz-Arpb2ai+X4oSZ2^OZ7qe5PQYkwSCXUGE za;pHshE0uSl$rMeH~?VRV5m9cPXGt4wMT*f1*DkyGyvO=9#r)rfYpAys{taq6+kL7 z*;+dVAS6`9vp%(p^Bcd6>csm(ef`j{p!Na!nxs z5Rs#WLg5^MYV-?R1@|hT+G9M%#>V~uQ0z6&^SnP?;#>us1@N%7cA{RdKL+4juY{6< zlK>)m(^~s8039D6KSe}uB+SbhE&{6cdj0EWM`ZUroRWZxfHToJzKqB|lMJQa;38mZ zb#-;a(iPe9&1N8Q5nw8n%HC#2WM2~}S*MMRhz=Bs#kz=`0B|o6y`C&Bcew7v8C9J& z#yqI15A~3jI9!O7j4{vozJCG$mX?+#MC33W=fL9P;&3XJ$^$sx3o#LybcyRaj#c%w z26+JRegEvx(9kr1zg;@;Ja5LOpBDW-zOb;6>-zpK?ca`!jC>MzX0zF#TCE;b)pz4< zB61Tm2XX&Z;Lc1YGsnyV07P`SRZypYrc6XHw`tWztpYj; zIG)ev&liiu0yA$o3I{=u1)w7G5_%ll{YF~>syYV%A~K_@!?ETU=jZ2lj*gE0UM`pK z2XHJ&lAX|2fH6h@AeBm8F;9#!HxCaFe-Q-1ZIhFeC2Q>rfL{~j*%nv5n-bA(BKjr> zg8j?O%Q*m~l&)G;(E#=>1x)mLSE>=rjkOW#&Uf^dx|l<~Gms z4gnY(>n3y>Le~S>CnBe;wSO`54a|IB5Cqv=E_WL1MX-UR>m2Yr@3ZJ}KY&k(=xqS7 z)_$m}-z7=T1>FSHRP{>$P}O~r@2OI$^i1^pUSiA~(M`Z{-}je;AQ&g2Jq>3VhA#jB z5mgdp=YWm^RQ2=d@#$D>+aeDURRJV%@wU>+*-gOr08&Kse5@%807P_SJco#U0Ih1E zmt0sHW7?f^e*v&F?)0LhmK6qL%&W{?2M{j{?qcS50NfqVQPoGnFr4;0Z^QRO7=}*8 zt#ms5L#Sh0n8((ax?>CtpET3 M07*qoM6N<$f^O$8qW}N^ literal 0 HcmV?d00001 diff --git a/res/drawable-hdpi/delete_icon.png b/res/drawable-hdpi/delete_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ffd19d9e80b07c6fdf216f2b728a9337e438d1c4 GIT binary patch literal 1611 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTC$r9IylHmNblJdl&R0hYC{G?O` z&)mfH)S%SFl*+=BsWuD@%qp275hW46K32*3xq68pHF_1f1wh>l3^w)^1&PVosU-?Y zsp*+{wo31J?^jaDOtDo8H}y5}EpSfF$n>ZxN)4{^3rViZPPR-@vbR&PsjvbXkegbP zs8ErclUHn2VXFi-*9yo63F|8hm3bwJ6}oxF$}kgLQj3#|G7CyF^YauyCMG83 zmzLNn0bL65LT&-v*t}wBFaZNhzap_f-%!s00+w{G(#^lGsVi)*~rk%+1S<8$-vFf(ACh=#L&{!#L3yw z&D7A`#K{n**Cju>G&eP`1g19ytk=TX(Za+Lr(RHE$SnZc?2=lPS(cjOR+OKs0QR(1 zCT_Pl<1`PdHwCL(!2WQ-saGH97=2LGB1JV!2$+6AOnAZta^OinH4m8Hi+~Ax_NSC; z1_q|Ro-U3d6}R5ZjQ19GlsHyi)<2I+TTnztb;AoS-#^X*68FllPJeMI@3Zm`!B2}$ zFY3P_-tj{3qKL~y1+S*APcKf!oWE&o+kE~|fyMEXv~zE~tUok2pFX$m{F&eB_X0gM zn?KtedN8No$wBc!y?8*8ML5g5M#c$qHYA*W5G=>))4*D=@@(6ugT z1GX1zi+Vr4x@n^EypUZ;Y9I46$2FWQn6S< zt9D%C>|Ix=e#lI3+AhDD)=ORFnzSOA&L3>|%%>3`{oP$bstt}e(f~YY53RoV9rdrXH4v&H=~_{ub%sV zt+S;#w3h2e`GndpfzRh0-FhnXxIWtkZE>qdbMCRI^f8CcnwRIxDq~^ex177^L9oM8 z=ExO~f*W2q*l^8fdS&x{$F0WL%Ug1^7F;YTOx0E}vyHmVQ83p{I&#N^ZYPPfhfXhd zuPamd6x+%CZDZ0llYelb#{Ni?uWQ|IJ&xn-(=TK<5f7DoCcXLWylc+4*#kb# k{{>7-3j`*-{Gok-LH)?F>j~0pmV=6SPgg&ebxsLQ0FuvZE&u=k literal 0 HcmV?d00001 diff --git a/res/drawable-hdpi/departure_icon.png b/res/drawable-hdpi/departure_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..422dae9dabc96859f1f8581876608559ea4763f9 GIT binary patch literal 1490 zcmV;@1ugoCP)ca#MQ zQAt=3j4L)8mu@s}To_i0A(F5mA;hRG#K#UrVpl{1gBp`T!Nk%DPNq4x;0z6Nq+en8{@N6NyAh zDb){PIv$UkWHNabK&f}>wTHA@2h!35sl*CtHxa1|TCM z36etqVh(XuliY`Lh2H5h*QRLt5tH0eCFV#T0I;J_D6H374{NQr`@X+TM851K7|Fe( zqoXc_ozb)cBC>-dNFK;$vmcC%j1*hw{n_DOYWdL6&}INXb&+dRG*lp;Hr< zU$sge07(ATX+V-swR&cZ*=vkB9t6STuKpS-V69yTASxo)ec!)$D`RVIQAAv0g&1zu zIXykC0elD`N-_oD1s7)x6%dit06_9r0JhWY9I&QYXR%mZ1|U)q6Ryr$5&&?%n zK(kKI^TtKwAb>1@{jSa$2v}=xHvxZgap0w6FZ*f{yKtz7-KF3=l7K=3u zqaX-2SZjY2kvEi5pBrPIb@A0efaDqgSAE~V($-k1KBtW9P%4#%s^xS#9VK}PKpy42 zREFfCiHV8jZF6WMuL96Ec>u81u5ik@K8RBD6)?uE+_-V$Hvl#O7^`$&5|L6Q5@|W* z&ikqsa=Baz<*mWrj=6M2pz1q=h`b^qGa~W?fZ0kn0bGkjB5h}*`gI^Qm~cr%DV6Nz zRzoS341fE+e;B}F01;!%eE=dN(r2wb5sgOMP9!xIh{a+df!keyhOr$4!FvEa0LMu_ zJTo)%Nq>L;<#xVm2vj+CTEIxIbkVDah%Bp?gCJOCt$ho?KCShe0Ok^j#M>^u>ObPJ z0#0w1$@@j*-fprFD=;=T79SiOe56<`CL)o@@mwzVBmgL-j*;9Q%2jr``qN#_iOd+Y z2f)WoViLd&0Db7qMZg8E^)o>b93{E46GIW%w~v)YK&P2;6(uUq*AGmaB~gmIb5ejMRGF$kUZB; zS!;a>dv>RsVRSaeBA5Qu9MdG s503vk?)d-6mIy31mIy31?sx+K0W=tpVMiMg&Hw-a07*qoM6N<$f-@|Rxc~qF literal 0 HcmV?d00001 diff --git a/res/drawable-mdpi/actionbar_shadow.9.png b/res/drawable-mdpi/actionbar_shadow.9.png deleted file mode 100644 index cae1778f439bf96bfd43d73c8756c6deb4a71ba6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 952 zcmaJ=J#W)M7`9Xt(n>*{P+>raE0`L8rH*4OCZw@Ljc^pDkq8?X`;u6xea5~JClj!- zG4c~&fE6JmU|?b34>0f-7-0+NG)@@^md3N>_^Paa`cM3aKcNm5#SjR?(?pt(S z%;)I;+xuUy>2`&fJ#vBvWC|n1)Lq<1!1Cb`br5uCkG`TRC9z(&M|$=>&A~ngQw*2* zA!Rd6wU&g?86yJvXy^qx`}4ym7I?1C-j{8`4jX9X9nT|lGH-RA`Pfliwss3t6O9V^ zh(M6|r$MYGI=j@>=sCUSS+InVvCf_a)wA26fg=QDPAED;Spa2`6HAARq8tE85CvY4 zcu^{fidK>|K>(|drQRZUpmmJq$``eCc0@?1@%(f;<)$SLM?+pzRW;R+q#{KW<5@sp zQVin#Ou<006L}%=Z~#(8*vAv1vozAP6#Q^48^o(J(Sq>_40(|g(v&iwZT}zY`)hPe zI_Ny!e+tLlS%~-!it!|JXyXR^sjEC? z)~p~VFmRA%=qy#>JkQmRXpJjUrEHcASrkp7UM`u9rm4t+B8sZq$hZb}CO!&C#&yrR z%0_NF3VujE8z}M~Bexl0A1qVWyv?y3Zq!?G-OaJc8@W6UhEE&&SEI8lIz8!eJ+{eP!hN+o_zV8nMFd>OB3~vFru*f>! z0sLBm{}%k|{D5<=uiSydi>W|zB$Z0_liU*z6@1@+R4KPuEFMUuQk`))uBw|zUMYKO zTrgef=4w*aw@?~|U3GA_%^ti8Q`7yzOu@<`sU zmP^tD@WMIwIL_~$^Ds4hJ_EQeBG2paj5omiv)V*e01-LkoE!9g|0IBq4VWxR6#+;V zecykVfT`Do|!|)RTn%P6ue~qv73I-=8CMHXz(gpw+85!~79dWOYNj-T0G9og^a{+*e zd{EV605$?ZKA+D9LD1uzyGyd?KOq*V;u=V&)0#Z0iAY}*MLSgWKFNvY1X$1kGwU+5 zL*>}>yeRjTO>yvoDH}_cHOf~(V(Hg*S#6S_}*I|uM00000NkvXXu0mjfq`YQo literal 0 HcmV?d00001 diff --git a/res/drawable-mdpi/delete_icon.png b/res/drawable-mdpi/delete_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a8ee5f253f83e715845337278cb7d08ebd623dfa GIT binary patch literal 1358 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz$r9IylHmNblJdl&R0hYC{G?O` z&)mfH)S%SFl*+=BsWuD@%qp275hW46K32*3xq68pHF_1f1wh>l3^w)^1&PVosU-?Y zsp*+{wo31J?^jaDOtDo8H}y5}EpSfF$n>ZxN)4{^3rViZPPR-@vbR&PsjvbXkegbP zs8ErclUHn2VXFi-*9yo63F|8hm3bwJ6}oxF$}kgLQj3#|G7CyF^YauyCMG83 zmzLNn0bL65LT&-v*t}wBFaZNhzap_f-%!s00+w{G(#^lGsVi)*}~b;!oG&eP`1g19yq1P3sUQlAlEdbi=l3J8mmYU*Ll%J~r_Ow+dZnrq$ zG!Lpb1-DzAaq86vIz}H9wMbD769T3m5EGtofgE_!Pt60S_ab1zKDm-XlYxQpfTxRN zNX4x;(|3C@JBqYzzFE;3$l@rVKf_HxH0RBga)D~WjUVQ+)G`TbTW`E@>DVo$IA<4u zmX!RHX@A)N9WZd&WNoe3YWd;drkOMUKA&U!+($;yC2zvC^Sn3On7G)A#SWSkZ22y? zgR!@c+k&zEfiy?zT+ITOyx+PDShOB6{1Dm5=jVIPSWqGMKFdO(Hij(+JYF3Yy3)wG zfqB~jqll&AHmaRVCn)`3S^t35rlGp;w8{gXH%(?8JBxq5(Mo2yFZzOY`lELT3a<&| zGK>Ao}C=DMV}IPaOv4u)u>YTN8 zUzlwg-9Mx{AJCY=eqK{}56>!|_+{ zrd0FbF3x8zORpcF%+(?JSmR`q*NrB7Kd)DLH?DN~UDA79n3u+=boAWU3!KqRe^@qN z|J|DJ?eKiga#4XBdjwnAn4D%ay<)Qr*siHyAdq0nGA~gmN;n|3Q1Z2*`gy}oejoBa zdzG!d^3C!ad-!WsLtE9|4^^K>?40ycb(@dis8p3m zh(px_2qX@0;SbCcx@+0ghS`DPqXvp`*}0F@9m1Ja+GF{RQ)!<{{g^{@k^yrIjgGYR5cIefV%-B zBB82=su~(&7It=aKAoDH+B__PbiD<}T6+a}61Zo`9FeLnRIAlz4+FBV1(izWA>er+ z4ZJHNmm7`7(;{*a_&FwrCn9H3snk;k6^E`CIOi^iNJ&J_1wnAD^PaVK9XJ`6$T{~6 z@On3#wKg|CK3r?!1nfbw$l-Y;j6&H#>U2}p#W6%gmdn@ znAkx8?C$RFtB|T51N@PZk+FdQ<#IU%1i(VCKvf+GpsLedK$n0QGnvc}0|7kGn*!AH zyv3e@##9FZh)5e?ZEbBVkw|PyYuf{3lEha)*sD-qQ`I|K<8(TGNmV~~&Rr9ct8sJM8>ELKx~OU&zlAQ2!h~7Ovu*&Q4~Gg>GXZy^7k9m)0}fR+wpyZW`RZa_VRyN zHk&PmVORpr0PnZ_>2&&+Fbp3h=98{ouWLS^|9l{T=XuwoC|d8c5S(*Y>9Kuhv)LO! qT;=vz_ebe}Zb$xKa2w#r0saCg+G6|XQ_SiB0000 - - - - - - diff --git a/res/drawable/actionbar_compat_item_focused.xml b/res/drawable/actionbar_compat_item_focused.xml deleted file mode 100644 index 04811d3..0000000 --- a/res/drawable/actionbar_compat_item_focused.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - diff --git a/res/drawable/actionbar_compat_item_pressed.xml b/res/drawable/actionbar_compat_item_pressed.xml deleted file mode 100644 index 72ff4b4..0000000 --- a/res/drawable/actionbar_compat_item_pressed.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - diff --git a/res/drawable/btn_borderless_holo_dark.xml b/res/drawable/btn_borderless_holo_dark.xml new file mode 100644 index 0000000..84b68f8 --- /dev/null +++ b/res/drawable/btn_borderless_holo_dark.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/res/drawable/transparent.xml b/res/drawable/transparent.xml new file mode 100644 index 0000000..223e90e --- /dev/null +++ b/res/drawable/transparent.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/res/layout-v11/actionbar_indeterminate_progress.xml b/res/layout-v11/actionbar_indeterminate_progress.xml deleted file mode 100644 index c05750e..0000000 --- a/res/layout-v11/actionbar_indeterminate_progress.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - diff --git a/res/layout-v11/simple_spinner_dropdown_item.xml b/res/layout-v11/simple_spinner_dropdown_item.xml new file mode 100644 index 0000000..3493305 --- /dev/null +++ b/res/layout-v11/simple_spinner_dropdown_item.xml @@ -0,0 +1,14 @@ + + + + \ No newline at end of file diff --git a/res/layout/actionbar_compat.xml b/res/layout/actionbar_compat.xml deleted file mode 100644 index ae6c44b..0000000 --- a/res/layout/actionbar_compat.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - diff --git a/res/layout/route_form.xml b/res/layout/route_form.xml index 6b05eb4..8fb26a6 100644 --- a/res/layout/route_form.xml +++ b/res/layout/route_form.xml @@ -1,71 +1,108 @@ + android:layout_width="300dp" + android:layout_height="wrap_content" + android:gravity="center_vertical" > + + + + + android:textSize="15sp" > + android:layout_alignParentRight="true" + android:layout_below="@+id/origin_spinner" + android:paddingLeft="5dp" + android:paddingRight="5dp" + android:paddingTop="15dip" /> + android:textSize="15sp" > - + diff --git a/res/layout/simple_spinner_dropdown_item.xml b/res/layout/simple_spinner_dropdown_item.xml new file mode 100644 index 0000000..ce1de16 --- /dev/null +++ b/res/layout/simple_spinner_dropdown_item.xml @@ -0,0 +1,14 @@ + + + + \ No newline at end of file diff --git a/res/layout/simple_spinner_item.xml b/res/layout/simple_spinner_item.xml index d20985a..918bbb3 100644 --- a/res/layout/simple_spinner_item.xml +++ b/res/layout/simple_spinner_item.xml @@ -1,8 +1,15 @@ - + android:id="@android:id/text1" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:ellipsize="marquee" + android:background="#282829" + android:textColor="#fff" + android:paddingBottom="12dip" + android:paddingLeft="5dip" + android:paddingRight="5dip" + android:paddingTop="12dip" + android:singleLine="true" > + + \ No newline at end of file diff --git a/res/menu/departure_context_menu.xml b/res/menu/departure_context_menu.xml index 59b3690..24022b3 100644 --- a/res/menu/departure_context_menu.xml +++ b/res/menu/departure_context_menu.xml @@ -1,4 +1,9 @@ - + + \ No newline at end of file diff --git a/res/menu/route_context_menu.xml b/res/menu/route_context_menu.xml index d8461d3..41f6c9e 100644 --- a/res/menu/route_context_menu.xml +++ b/res/menu/route_context_menu.xml @@ -1,5 +1,17 @@ - - - - + + + + + + + + \ No newline at end of file diff --git a/res/values-v11/styles.xml b/res/values-v11/styles.xml index 0d65e77..4e9e2df 100644 --- a/res/values-v11/styles.xml +++ b/res/values-v11/styles.xml @@ -1,34 +1,6 @@ - - - - - - - - - - - + + + + + + \ No newline at end of file diff --git a/res/values-v13/styles.xml b/res/values-v13/styles.xml deleted file mode 100644 index 8a042b4..0000000 --- a/res/values-v13/styles.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - diff --git a/res/values/attrs.xml b/res/values/attrs.xml index 99d492f..187a49e 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -18,16 +18,6 @@ - - - - - - - - - - diff --git a/res/values/colors.xml b/res/values/colors.xml index ec349a6..f65b2d8 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -1,5 +1,6 @@ + #FF000000 - #EEEEEE + \ No newline at end of file diff --git a/res/values/dimens.xml b/res/values/dimens.xml deleted file mode 100644 index 67c8436..0000000 --- a/res/values/dimens.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - 48dp - 48dp - 56dp - diff --git a/res/values/ids.xml b/res/values/ids.xml deleted file mode 100644 index e0a4745..0000000 --- a/res/values/ids.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - diff --git a/res/values/strings.xml b/res/values/strings.xml index e08dbbd..ce12110 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1,7 +1,7 @@ BART Runner - Favorite Routes + Favorite routes No favorite routes have been added yet Add a route Origin @@ -32,7 +32,7 @@ Departures OK Quick departure lookup - I\'m getting on this train + I will board this train Departure options Your train diff --git a/res/values/styles.xml b/res/values/styles.xml index e86670f..f7184e4 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -2,52 +2,7 @@ - - - - - - - - - - - - - - - + - + + + \ No newline at end of file diff --git a/src/com/dougkeen/bart/AbstractRouteSelectionActivity.java b/src/com/dougkeen/bart/AbstractRouteSelectionActivity.java index 7a074f6..4d1d529 100644 --- a/src/com/dougkeen/bart/AbstractRouteSelectionActivity.java +++ b/src/com/dougkeen/bart/AbstractRouteSelectionActivity.java @@ -6,7 +6,6 @@ import android.view.View; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.Spinner; -import android.widget.SpinnerAdapter; import android.widget.Toast; import com.dougkeen.bart.model.Station; @@ -23,13 +22,20 @@ public abstract class AbstractRouteSelectionActivity extends Activity { setContentView(R.layout.route_form); - SpinnerAdapter originSpinnerAdapter = new ArrayAdapter(this, - R.layout.simple_spinner_item, Station.getStationList()); + ArrayAdapter originSpinnerAdapter = new ArrayAdapter( + this, android.R.layout.simple_spinner_item, + Station.getStationList()); + originSpinnerAdapter + .setDropDownViewResource(R.layout.simple_spinner_dropdown_item); ((Spinner) findViewById(R.id.origin_spinner)) .setAdapter(originSpinnerAdapter); - SpinnerAdapter destinationSpinnerAdapter = new ArrayAdapter( - this, R.layout.simple_spinner_item, Station.getStationList()); + ArrayAdapter destinationSpinnerAdapter = new ArrayAdapter( + this, android.R.layout.simple_spinner_item, + Station.getStationList()); + destinationSpinnerAdapter + .setDropDownViewResource(R.layout.simple_spinner_dropdown_item); + ((Spinner) findViewById(R.id.destination_spinner)) .setAdapter(destinationSpinnerAdapter); diff --git a/src/com/dougkeen/bart/AddRouteActivity.java b/src/com/dougkeen/bart/AddRouteActivity.java index 49b7510..906b7ca 100644 --- a/src/com/dougkeen/bart/AddRouteActivity.java +++ b/src/com/dougkeen/bart/AddRouteActivity.java @@ -15,7 +15,16 @@ public class AddRouteActivity extends AbstractRouteSelectionActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - findViewById(R.id.return_checkbox).setVisibility(View.VISIBLE); + final View checkboxText = findViewById(R.id.return_checkbox_text); + final View checkbox = findViewById(R.id.return_checkbox); + checkboxText.setVisibility(View.VISIBLE); + checkbox.setVisibility(View.VISIBLE); + checkboxText.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + checkbox.performClick(); + } + }); } @Override diff --git a/src/com/dougkeen/bart/RoutesListActivity.java b/src/com/dougkeen/bart/RoutesListActivity.java index abc79c4..6a97a9a 100644 --- a/src/com/dougkeen/bart/RoutesListActivity.java +++ b/src/com/dougkeen/bart/RoutesListActivity.java @@ -14,27 +14,26 @@ import android.database.Cursor; import android.database.CursorWrapper; import android.net.Uri; import android.os.Bundle; -import android.view.ContextMenu; -import android.view.ContextMenu.ContextMenuInfo; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; import android.view.View; -import android.widget.AdapterView.AdapterContextMenuInfo; +import android.widget.AdapterView; import android.widget.Button; import android.widget.ListView; import android.widget.SimpleCursorAdapter; import android.widget.SimpleCursorAdapter.ViewBinder; import android.widget.TextView; -import com.dougkeen.bart.actionbarcompat.ActionBarListActivity; +import com.actionbarsherlock.app.SherlockListActivity; +import com.actionbarsherlock.view.ActionMode; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; import com.dougkeen.bart.data.CursorUtils; import com.dougkeen.bart.data.RoutesColumns; import com.dougkeen.bart.model.Constants; import com.dougkeen.bart.model.Station; import com.dougkeen.bart.networktasks.GetRouteFareTask; -public class RoutesListActivity extends ActionBarListActivity { +public class RoutesListActivity extends SherlockListActivity { private static final TimeZone PACIFIC_TIME = TimeZone .getTimeZone("America/Los_Angeles"); @@ -44,7 +43,10 @@ public class RoutesListActivity extends ActionBarListActivity { private Uri mCurrentlySelectedUri; - private String mCurrentlySelectedRouteName; + private Station mCurrentlySelectedOrigin; + private Station mCurrentlySelectedDestination; + + private ActionMode mActionMode; /** Called when the activity is first created. */ @Override @@ -88,7 +90,31 @@ public class RoutesListActivity extends ActionBarListActivity { setListAdapter(adapter); - registerForContextMenu(getListView()); + getListView().setOnItemLongClickListener( + new AdapterView.OnItemLongClickListener() { + @Override + public boolean onItemLongClick(AdapterView parent, + View view, int position, long id) { + if (mActionMode != null) { + mActionMode.finish(); + } + + mCurrentlySelectedUri = ContentUris.withAppendedId( + Constants.FAVORITE_CONTENT_URI, id); + + CursorWrapper item = (CursorWrapper) getListAdapter() + .getItem(position); + Station orig = Station.getByAbbreviation(CursorUtils + .getString(item, RoutesColumns.FROM_STATION)); + Station dest = Station.getByAbbreviation(CursorUtils + .getString(item, RoutesColumns.TO_STATION)); + mCurrentlySelectedOrigin = orig; + mCurrentlySelectedDestination = dest; + + startContextualActionMode(); + return true; + } + }); ((Button) findViewById(R.id.quickLookupButton)) .setOnClickListener(new View.OnClickListener() { @@ -98,6 +124,26 @@ public class RoutesListActivity extends ActionBarListActivity { Constants.ARBITRARY_ROUTE_CONTENT_URI_ROOT)); } }); + + if (savedInstanceState != null) { + if (savedInstanceState.getString("currentlySelectedOrigin") != null) { + mCurrentlySelectedOrigin = Station + .getByAbbreviation(savedInstanceState + .getString("currentlySelectedOrigin")); + } + if (savedInstanceState.getString("currentlySelectedDestination") != null) { + mCurrentlySelectedDestination = Station + .getByAbbreviation(savedInstanceState + .getString("currentlySelectedDestination")); + } + if (savedInstanceState.getParcelable("currentlySelectedUri") != null) { + mCurrentlySelectedUri = (Uri) savedInstanceState + .getParcelable("currentlySelectedUri"); + } + if (savedInstanceState.getBoolean("hasActionMode")) { + startContextualActionMode(); + } + } } private void refreshFares() { @@ -146,6 +192,19 @@ public class RoutesListActivity extends ActionBarListActivity { } } + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + if (mCurrentlySelectedOrigin != null) + outState.putString("currentlySelectedOrigin", + mCurrentlySelectedOrigin.abbreviation); + if (mCurrentlySelectedDestination != null) + outState.putString("currentlySelectedDestination", + mCurrentlySelectedDestination.abbreviation); + outState.putParcelable("currentlySelectedUri", mCurrentlySelectedUri); + outState.putBoolean("hasActionMode", mActionMode != null); + } + @Override protected void onResume() { super.onResume(); @@ -154,14 +213,12 @@ public class RoutesListActivity extends ActionBarListActivity { refreshFares(); } - @Override public boolean onCreateOptionsMenu(Menu menu) { - MenuInflater inflater = getMenuInflater(); + MenuInflater inflater = getSupportMenuInflater(); inflater.inflate(R.menu.routes_list_menu, menu); - return true; + return super.onCreateOptionsMenu(menu); } - @Override public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); if (itemId == R.id.add_favorite_menu_button) { @@ -182,47 +239,10 @@ public class RoutesListActivity extends ActionBarListActivity { ContentUris.withAppendedId(Constants.FAVORITE_CONTENT_URI, id))); } - @Override - public void onCreateContextMenu(ContextMenu menu, View v, - ContextMenuInfo menuInfo) { - super.onCreateContextMenu(menu, v, menuInfo); - - MenuInflater inflater = getMenuInflater(); - inflater.inflate(R.menu.route_context_menu, menu); - - AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; - CursorWrapper item = (CursorWrapper) getListAdapter().getItem( - info.position); - Station orig = Station.getByAbbreviation(CursorUtils.getString(item, - RoutesColumns.FROM_STATION)); - Station dest = Station.getByAbbreviation(CursorUtils.getString(item, - RoutesColumns.TO_STATION)); - mCurrentlySelectedRouteName = orig.name + " - " + dest.name; - menu.setHeaderTitle(mCurrentlySelectedRouteName); - } - - @Override - public boolean onContextItemSelected(MenuItem item) { - AdapterContextMenuInfo info = (AdapterContextMenuInfo) item - .getMenuInfo(); - mCurrentlySelectedUri = ContentUris.withAppendedId( - Constants.FAVORITE_CONTENT_URI, info.id); - - if (item.getItemId() == R.id.view) { - startActivity(new Intent(Intent.ACTION_VIEW, mCurrentlySelectedUri)); - return true; - } else if (item.getItemId() == R.id.delete) { - showDialog(DIALOG_DELETE_EVENT); - return true; - } - return super.onContextItemSelected(item); - } - @Override protected Dialog onCreateDialog(int id) { if (id == DIALOG_DELETE_EVENT && mCurrentlySelectedUri != null) { final AlertDialog.Builder builder = new Builder(this); - builder.setTitle(mCurrentlySelectedRouteName); builder.setCancelable(false); builder.setMessage("Are you sure you want to delete this route?"); builder.setPositiveButton(R.string.yes, @@ -231,15 +251,15 @@ public class RoutesListActivity extends ActionBarListActivity { getContentResolver().delete(mCurrentlySelectedUri, null, null); mCurrentlySelectedUri = null; - mCurrentlySelectedRouteName = null; + mCurrentlySelectedOrigin = null; + mCurrentlySelectedDestination = null; + mActionMode.finish(); removeDialog(DIALOG_DELETE_EVENT); } }); builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { - mCurrentlySelectedUri = null; - mCurrentlySelectedRouteName = null; removeDialog(DIALOG_DELETE_EVENT); } }); @@ -248,4 +268,44 @@ public class RoutesListActivity extends ActionBarListActivity { return super.onCreateDialog(id); } + private void startContextualActionMode() { + mActionMode = startActionMode(new RouteActionMode()); + mActionMode.setTitle(mCurrentlySelectedOrigin.name); + mActionMode.setSubtitle("to " + mCurrentlySelectedDestination.name); + } + + private final class RouteActionMode implements ActionMode.Callback { + + @Override + public boolean onCreateActionMode(ActionMode mode, Menu menu) { + mode.getMenuInflater().inflate(R.menu.route_context_menu, menu); + return true; + } + + @Override + public boolean onPrepareActionMode(ActionMode mode, Menu menu) { + return false; + } + + @Override + public boolean onActionItemClicked(ActionMode mode, MenuItem item) { + if (item.getItemId() == R.id.view) { + startActivity(new Intent(Intent.ACTION_VIEW, + mCurrentlySelectedUri)); + mode.finish(); + return true; + } else if (item.getItemId() == R.id.delete) { + showDialog(DIALOG_DELETE_EVENT); + return false; + } + + return false; + } + + @Override + public void onDestroyActionMode(ActionMode mode) { + mActionMode = null; + } + + } } \ No newline at end of file diff --git a/src/com/dougkeen/bart/ViewDeparturesActivity.java b/src/com/dougkeen/bart/ViewDeparturesActivity.java index bed4509..7a6e3f4 100644 --- a/src/com/dougkeen/bart/ViewDeparturesActivity.java +++ b/src/com/dougkeen/bart/ViewDeparturesActivity.java @@ -18,18 +18,17 @@ import android.os.PowerManager; import android.text.format.DateFormat; import android.text.util.Linkify; import android.util.Log; -import android.view.ContextMenu; -import android.view.ContextMenu.ContextMenuInfo; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; import android.view.View; -import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.ImageView; +import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; -import com.dougkeen.bart.actionbarcompat.ActionBarListActivity; +import com.actionbarsherlock.app.SherlockListActivity; +import com.actionbarsherlock.view.ActionMode; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; import com.dougkeen.bart.controls.CountdownTextView; import com.dougkeen.bart.controls.Ticker; import com.dougkeen.bart.data.RoutesColumns; @@ -44,7 +43,7 @@ import com.dougkeen.bart.model.TextProvider; import com.dougkeen.bart.networktasks.GetRealTimeDeparturesTask; import com.dougkeen.bart.networktasks.GetScheduleInformationTask; -public class ViewDeparturesActivity extends ActionBarListActivity { +public class ViewDeparturesActivity extends SherlockListActivity { private static final int UNCERTAINTY_THRESHOLD = 17; @@ -72,6 +71,8 @@ public class ViewDeparturesActivity extends ActionBarListActivity { private boolean mDepartureFetchIsPending; private boolean mScheduleFetchIsPending; + private ActionMode mActionMode; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -120,17 +121,22 @@ public class ViewDeparturesActivity extends ActionBarListActivity { mBoardedDeparture = (Departure) savedInstanceState .getParcelable("boardedDeparture"); } + if (savedInstanceState.containsKey("selectedDeparture")) { + mSelectedDeparture = (Departure) savedInstanceState + .getParcelable("selectedDeparture"); + } + if(savedInstanceState.getBoolean("hasActionMode") && mSelectedDeparture != null) { + startDepartureActionMode(); + } } setListAdapter(mDeparturesAdapter); - registerForContextMenu(getListView()); - findViewById(R.id.missingDepartureText).setVisibility(View.VISIBLE); refreshBoardedDeparture(); - getActionBarHelper().setHomeButtonEnabled(true); - getActionBarHelper().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setHomeButtonEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); } @Override @@ -166,6 +172,8 @@ public class ViewDeparturesActivity extends ActionBarListActivity { } outState.putParcelableArray("departures", departures); outState.putParcelable("boardedDeparture", mBoardedDeparture); + outState.putParcelable("selectedDeparture", mSelectedDeparture); + outState.putBoolean("hasActionMode", mActionMode != null); } @Override @@ -529,7 +537,7 @@ public class ViewDeparturesActivity extends ActionBarListActivity { @Override public boolean onCreateOptionsMenu(Menu menu) { - MenuInflater inflater = getMenuInflater(); + MenuInflater inflater = getSupportMenuInflater(); inflater.inflate(R.menu.route_menu, menu); return true; } @@ -538,8 +546,7 @@ public class ViewDeparturesActivity extends ActionBarListActivity { public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); if (itemId == android.R.id.home) { - startActivity(new Intent(Intent.ACTION_PICK, - Constants.FAVORITE_CONTENT_URI)); + finish(); return true; } else if (itemId == R.id.view_on_bart_site_button) { startActivity(new Intent( @@ -560,30 +567,6 @@ public class ViewDeparturesActivity extends ActionBarListActivity { } } - @Override - public void onCreateContextMenu(ContextMenu menu, View v, - ContextMenuInfo menuInfo) { - super.onCreateContextMenu(menu, v, menuInfo); - - MenuInflater inflater = getMenuInflater(); - inflater.inflate(R.menu.departure_context_menu, menu); - - AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; - mSelectedDeparture = (Departure) getListAdapter() - .getItem(info.position); - menu.setHeaderTitle(R.string.departure_options); - } - - @Override - public boolean onContextItemSelected(MenuItem item) { - if (item.getItemId() == R.id.boardTrain) { - mBoardedDeparture = mSelectedDeparture; - refreshBoardedDeparture(); - return true; - } - return super.onContextItemSelected(item); - } - private void refreshBoardedDeparture() { if (mBoardedDeparture == null) return; @@ -630,13 +613,60 @@ public class ViewDeparturesActivity extends ActionBarListActivity { } }); - arrivalCountdown - .setText(departure.getEstimatedArrivalMinutesLeftText()); + arrivalCountdown.setText(departure + .getEstimatedArrivalMinutesLeftText(this)); arrivalCountdown.setTextProvider(new TextProvider() { @Override public String getText() { - return departure.getEstimatedArrivalMinutesLeftText(); + return departure + .getEstimatedArrivalMinutesLeftText(ViewDeparturesActivity.this); } }); } + + @Override + protected void onListItemClick(ListView l, View v, int position, long id) { + mSelectedDeparture = (Departure) getListAdapter().getItem(position); + if (mActionMode != null) { + mActionMode.finish(); + } + startDepartureActionMode(); + } + + private void startDepartureActionMode() { + mActionMode = startActionMode(new DepartureActionMode()); + mActionMode.setTitle(mSelectedDeparture.getDestinationName()); + mActionMode.setSubtitle(mSelectedDeparture.getTrainLengthText()); + } + + private class DepartureActionMode implements ActionMode.Callback { + + @Override + public boolean onCreateActionMode(ActionMode mode, Menu menu) { + mode.getMenuInflater().inflate(R.menu.departure_context_menu, menu); + return true; + } + + @Override + public boolean onPrepareActionMode(ActionMode mode, Menu menu) { + return false; + } + + @Override + public boolean onActionItemClicked(ActionMode mode, MenuItem item) { + if (item.getItemId() == R.id.boardTrain) { + mBoardedDeparture = mSelectedDeparture; + refreshBoardedDeparture(); + mode.finish(); + return true; + } + return false; + } + + @Override + public void onDestroyActionMode(ActionMode mode) { + mActionMode = null; + } + + } } diff --git a/src/com/dougkeen/bart/ViewMapActivity.java b/src/com/dougkeen/bart/ViewMapActivity.java index 760c950..c95dd18 100644 --- a/src/com/dougkeen/bart/ViewMapActivity.java +++ b/src/com/dougkeen/bart/ViewMapActivity.java @@ -2,15 +2,15 @@ package com.dougkeen.bart; import android.content.Intent; import android.os.Bundle; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; import android.webkit.WebView; -import com.dougkeen.bart.actionbarcompat.ActionBarActivity; +import com.actionbarsherlock.app.SherlockActivity; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; import com.dougkeen.bart.model.Constants; -public class ViewMapActivity extends ActionBarActivity { +public class ViewMapActivity extends SherlockActivity { @Override protected void onCreate(Bundle savedInstanceState) { @@ -24,13 +24,13 @@ public class ViewMapActivity extends ActionBarActivity { webview.loadUrl("file:///android_res/drawable/map.png"); - getActionBarHelper().setHomeButtonEnabled(true); - getActionBarHelper().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setHomeButtonEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); } @Override public boolean onCreateOptionsMenu(Menu menu) { - MenuInflater inflater = getMenuInflater(); + MenuInflater inflater = getSupportMenuInflater(); inflater.inflate(R.menu.system_map_menu, menu); return true; } @@ -38,8 +38,7 @@ public class ViewMapActivity extends ActionBarActivity { @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { - startActivity(new Intent(Intent.ACTION_PICK, - Constants.FAVORITE_CONTENT_URI)); + finish(); return true; } return super.onOptionsItemSelected(item); diff --git a/src/com/dougkeen/bart/actionbarcompat/ActionBarActivity.java b/src/com/dougkeen/bart/actionbarcompat/ActionBarActivity.java deleted file mode 100644 index 02ea24e..0000000 --- a/src/com/dougkeen/bart/actionbarcompat/ActionBarActivity.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.dougkeen.bart.actionbarcompat; - -import android.app.Activity; -import android.os.Bundle; -import android.view.Menu; -import android.view.MenuInflater; - -/** - * Damn, I wish Java had mixins - */ -public class ActionBarActivity extends Activity { - final ActionBarHelper mActionBarHelper = ActionBarHelper - .createInstance(this); - - /** - * Returns the {@link ActionBarHelper} for this activity. - */ - protected ActionBarHelper getActionBarHelper() { - return mActionBarHelper; - } - - /** {@inheritDoc} */ - @Override - public MenuInflater getMenuInflater() { - return mActionBarHelper.getMenuInflater(super.getMenuInflater()); - } - - /** {@inheritDoc} */ - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - mActionBarHelper.onCreate(savedInstanceState); - } - - /** {@inheritDoc} */ - @Override - protected void onPostCreate(Bundle savedInstanceState) { - super.onPostCreate(savedInstanceState); - mActionBarHelper.onPostCreate(savedInstanceState); - } - - /** - * Base action bar-aware implementation for - * {@link Activity#onCreateOptionsMenu(android.view.Menu)}. - * - * Note: marking menu items as invisible/visible is not currently supported. - */ - @Override - public boolean onCreateOptionsMenu(Menu menu) { - boolean retValue = false; - retValue |= mActionBarHelper.onCreateOptionsMenu(menu); - retValue |= super.onCreateOptionsMenu(menu); - return retValue; - } - - /** {@inheritDoc} */ - @Override - protected void onTitleChanged(CharSequence title, int color) { - mActionBarHelper.onTitleChanged(title, color); - super.onTitleChanged(title, color); - } - -} diff --git a/src/com/dougkeen/bart/actionbarcompat/ActionBarHelper.java b/src/com/dougkeen/bart/actionbarcompat/ActionBarHelper.java deleted file mode 100644 index f4a2ab4..0000000 --- a/src/com/dougkeen/bart/actionbarcompat/ActionBarHelper.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright 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.dougkeen.bart.actionbarcompat; - -import android.app.Activity; -import android.os.Build; -import android.os.Bundle; -import android.view.Menu; -import android.view.MenuInflater; - -/** - * An abstract class that handles some common action bar-related functionality - * in the app. This class provides functionality useful for both phones and - * tablets, and does not require any Android 3.0-specific features, although it - * uses them if available. - * - * Two implementations of this class are {@link ActionBarHelperBase} for a - * pre-Honeycomb version of the action bar, and {@link ActionBarHelperHoneycomb} - * , which uses the built-in ActionBar features in Android 3.0 and later. - */ -public abstract class ActionBarHelper { - protected Activity mActivity; - - /** - * Factory method for creating {@link ActionBarHelper} objects for a given - * activity. Depending on which device the app is running, either a basic - * helper or Honeycomb-specific helper will be returned. - */ - public static ActionBarHelper createInstance(Activity activity) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { - return new ActionBarHelperICS(activity); - } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - return new ActionBarHelperHoneycomb(activity); - } else { - return new ActionBarHelperBase(activity); - } - } - - protected ActionBarHelper(Activity activity) { - mActivity = activity; - } - - /** - * Action bar helper code to be run in - * {@link Activity#onCreate(android.os.Bundle)}. - */ - public void onCreate(Bundle savedInstanceState) { - } - - /** - * Action bar helper code to be run in - * {@link Activity#onPostCreate(android.os.Bundle)}. - */ - public void onPostCreate(Bundle savedInstanceState) { - } - - /** - * Action bar helper code to be run in - * {@link Activity#onCreateOptionsMenu(android.view.Menu)}. - * - * NOTE: Setting the visibility of menu items in menu is not - * currently supported. - */ - public boolean onCreateOptionsMenu(Menu menu) { - return true; - } - - /** - * Action bar helper code to be run in - * {@link Activity#onTitleChanged(CharSequence, int)}. - */ - protected void onTitleChanged(CharSequence title, int color) { - } - - /** - * Sets the indeterminate loading state of the item with ID - * {@link R.id.menu_refresh}. (where the item ID was menu_refresh). - */ - public abstract void setRefreshActionItemState(boolean refreshing); - - /** - * Returns a {@link MenuInflater} for use when inflating menus. The - * implementation of this method in {@link ActionBarHelperBase} returns a - * wrapped menu inflater that can read action bar metadata from a menu - * resource pre-Honeycomb. - */ - public MenuInflater getMenuInflater(MenuInflater superMenuInflater) { - return superMenuInflater; - } - - abstract public void setHomeButtonEnabled(boolean enabled); - - abstract public void setDisplayHomeAsUpEnabled(boolean enabled); -} diff --git a/src/com/dougkeen/bart/actionbarcompat/ActionBarHelperBase.java b/src/com/dougkeen/bart/actionbarcompat/ActionBarHelperBase.java deleted file mode 100644 index d6d36ed..0000000 --- a/src/com/dougkeen/bart/actionbarcompat/ActionBarHelperBase.java +++ /dev/null @@ -1,327 +0,0 @@ -/* - * Copyright 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.dougkeen.bart.actionbarcompat; - -import java.io.IOException; -import java.util.HashSet; -import java.util.Set; - -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - -import android.app.Activity; -import android.content.Context; -import android.content.res.XmlResourceParser; -import android.os.Bundle; -import android.view.InflateException; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.View; -import android.view.ViewGroup; -import android.view.Window; -import android.widget.ImageButton; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.ProgressBar; -import android.widget.TextView; - -import com.dougkeen.bart.R; - -/** - * A class that implements the action bar pattern for pre-Honeycomb devices. - */ -public class ActionBarHelperBase extends ActionBarHelper { - private static final String MENU_RES_NAMESPACE = "http://schemas.android.com/apk/res/android"; - private static final String MENU_ATTR_ID = "id"; - private static final String MENU_ATTR_SHOW_AS_ACTION = "showAsAction"; - - protected Set mActionItemIds = new HashSet(); - - protected ActionBarHelperBase(Activity activity) { - super(activity); - } - - /** {@inheritDoc} */ - @Override - public void onCreate(Bundle savedInstanceState) { - mActivity.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); - } - - /** {@inheritDoc} */ - @Override - public void onPostCreate(Bundle savedInstanceState) { - mActivity.getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, - R.layout.actionbar_compat); - setupActionBar(); - - SimpleMenu menu = new SimpleMenu(mActivity); - mActivity.onCreatePanelMenu(Window.FEATURE_OPTIONS_PANEL, menu); - mActivity.onPrepareOptionsMenu(menu); - for (int i = 0; i < menu.size(); i++) { - MenuItem item = menu.getItem(i); - if (mActionItemIds.contains(item.getItemId())) { - addActionItemCompatFromMenuItem(item); - } - } - } - - /** - * Sets up the compatibility action bar with the given title. - */ - private void setupActionBar() { - final ViewGroup actionBarCompat = getActionBarCompat(); - if (actionBarCompat == null) { - return; - } - - LinearLayout.LayoutParams springLayoutParams = new LinearLayout.LayoutParams( - 0, ViewGroup.LayoutParams.FILL_PARENT); - springLayoutParams.weight = 1; - - // Add Home button - SimpleMenu tempMenu = new SimpleMenu(mActivity); - SimpleMenuItem homeItem = new SimpleMenuItem(tempMenu, - android.R.id.home, 0, mActivity.getString(R.string.app_name)); - homeItem.setIcon(R.drawable.icon); - addActionItemCompatFromMenuItem(homeItem); - - // Add title text - TextView titleText = new TextView(mActivity, null, - R.attr.actionbarCompatTitleStyle); - titleText.setLayoutParams(springLayoutParams); - titleText.setText(mActivity.getTitle()); - actionBarCompat.addView(titleText); - } - - /** {@inheritDoc} */ - @Override - public void setRefreshActionItemState(boolean refreshing) { - View refreshButton = mActivity - .findViewById(R.id.actionbar_compat_item_refresh); - View refreshIndicator = mActivity - .findViewById(R.id.actionbar_compat_item_refresh_progress); - - if (refreshButton != null) { - refreshButton.setVisibility(refreshing ? View.GONE : View.VISIBLE); - } - if (refreshIndicator != null) { - refreshIndicator.setVisibility(refreshing ? View.VISIBLE - : View.GONE); - } - } - - /** - * Action bar helper code to be run in - * {@link Activity#onCreateOptionsMenu(android.view.Menu)}. - * - * NOTE: This code will mark on-screen menu items as invisible. - */ - @Override - public boolean onCreateOptionsMenu(Menu menu) { - // Hides on-screen action items from the options menu. - for (Integer id : mActionItemIds) { - menu.findItem(id).setVisible(false); - } - return true; - } - - /** {@inheritDoc} */ - @Override - protected void onTitleChanged(CharSequence title, int color) { - TextView titleView = (TextView) mActivity - .findViewById(R.id.actionbar_compat_title); - if (titleView != null) { - titleView.setText(title); - } - } - - /** - * Returns a {@link android.view.MenuInflater} that can read action bar - * metadata on pre-Honeycomb devices. - */ - public MenuInflater getMenuInflater(MenuInflater superMenuInflater) { - return new WrappedMenuInflater(mActivity, superMenuInflater); - } - - /** - * Returns the {@link android.view.ViewGroup} for the action bar on phones - * (compatibility action bar). Can return null, and will return null on - * Honeycomb. - */ - private ViewGroup getActionBarCompat() { - return (ViewGroup) mActivity.findViewById(R.id.actionbar_compat); - } - - /** - * Adds an action button to the compatibility action bar, using menu - * information from a {@link android.view.MenuItem}. If the menu item ID is - * menu_refresh, the menu item's state can be changed to show a - * loading spinner using - * {@link com.example.android.actionbarcompat.ActionBarHelperBase#setRefreshActionItemState(boolean)} - * . - */ - private View addActionItemCompatFromMenuItem(final MenuItem item) { - final int itemId = item.getItemId(); - - final ViewGroup actionBar = getActionBarCompat(); - if (actionBar == null) { - return null; - } - - // Create the button - ImageButton actionButton = new ImageButton( - mActivity, - null, - itemId == android.R.id.home ? R.attr.actionbarCompatItemHomeStyle - : R.attr.actionbarCompatItemStyle); - actionButton - .setLayoutParams(new ViewGroup.LayoutParams( - (int) mActivity - .getResources() - .getDimension( - itemId == android.R.id.home ? R.dimen.actionbar_compat_button_home_width - : R.dimen.actionbar_compat_button_width), - ViewGroup.LayoutParams.FILL_PARENT)); - if (itemId == R.id.menu_refresh) { - actionButton.setId(R.id.actionbar_compat_item_refresh); - } - actionButton.setImageDrawable(item.getIcon()); - actionButton.setScaleType(ImageView.ScaleType.CENTER); - actionButton.setContentDescription(item.getTitle()); - actionButton.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - mActivity - .onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, item); - } - }); - - actionBar.addView(actionButton); - - if (item.getItemId() == R.id.menu_refresh) { - // Refresh buttons should be stateful, and allow for indeterminate - // progress indicators, - // so add those. - ProgressBar indicator = new ProgressBar(mActivity, null, - R.attr.actionbarCompatProgressIndicatorStyle); - - final int buttonWidth = mActivity.getResources() - .getDimensionPixelSize( - R.dimen.actionbar_compat_button_width); - final int buttonHeight = mActivity.getResources() - .getDimensionPixelSize(R.dimen.actionbar_compat_height); - final int progressIndicatorWidth = buttonWidth / 2; - - LinearLayout.LayoutParams indicatorLayoutParams = new LinearLayout.LayoutParams( - progressIndicatorWidth, progressIndicatorWidth); - indicatorLayoutParams.setMargins( - (buttonWidth - progressIndicatorWidth) / 2, - (buttonHeight - progressIndicatorWidth) / 2, - (buttonWidth - progressIndicatorWidth) / 2, 0); - indicator.setLayoutParams(indicatorLayoutParams); - indicator.setVisibility(View.GONE); - indicator.setId(R.id.actionbar_compat_item_refresh_progress); - actionBar.addView(indicator); - } - - return actionButton; - } - - /** - * A {@link android.view.MenuInflater} that reads action bar metadata. - */ - private class WrappedMenuInflater extends MenuInflater { - MenuInflater mInflater; - - public WrappedMenuInflater(Context context, MenuInflater inflater) { - super(context); - mInflater = inflater; - } - - @Override - public void inflate(int menuRes, Menu menu) { - loadActionBarMetadata(menuRes); - mInflater.inflate(menuRes, menu); - } - - /** - * Loads action bar metadata from a menu resource, storing a list of - * menu item IDs that should be shown on-screen (i.e. those with - * showAsAction set to always or ifRoom). - * - * @param menuResId - */ - private void loadActionBarMetadata(int menuResId) { - XmlResourceParser parser = null; - try { - parser = mActivity.getResources().getXml(menuResId); - - int eventType = parser.getEventType(); - int itemId; - int showAsAction; - - boolean eof = false; - while (!eof) { - switch (eventType) { - case XmlPullParser.START_TAG: - if (!parser.getName().equals("item")) { - break; - } - - itemId = parser.getAttributeResourceValue( - MENU_RES_NAMESPACE, MENU_ATTR_ID, 0); - if (itemId == 0) { - break; - } - - showAsAction = parser.getAttributeIntValue( - MENU_RES_NAMESPACE, MENU_ATTR_SHOW_AS_ACTION, - -1); - if ((showAsAction & MenuItem.SHOW_AS_ACTION_ALWAYS) > 0 - || (showAsAction & MenuItem.SHOW_AS_ACTION_IF_ROOM) > 0) { - mActionItemIds.add(itemId); - } - break; - - case XmlPullParser.END_DOCUMENT: - eof = true; - break; - } - - eventType = parser.next(); - } - } 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(); - } - } - } - - } - - @Override - public void setHomeButtonEnabled(boolean enabled) { - } - - @Override - public void setDisplayHomeAsUpEnabled(boolean enabled) { - } -} diff --git a/src/com/dougkeen/bart/actionbarcompat/ActionBarHelperHoneycomb.java b/src/com/dougkeen/bart/actionbarcompat/ActionBarHelperHoneycomb.java deleted file mode 100644 index 8dbf070..0000000 --- a/src/com/dougkeen/bart/actionbarcompat/ActionBarHelperHoneycomb.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 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.dougkeen.bart.actionbarcompat; - -import android.app.Activity; -import android.content.Context; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; - -import com.dougkeen.bart.R; - -/** - * An extension of {@link ActionBarHelper} that provides Android 3.0-specific - * functionality for Honeycomb tablets. It thus requires API level 11. - */ -public class ActionBarHelperHoneycomb extends ActionBarHelper { - private Menu mOptionsMenu; - private View mRefreshIndeterminateProgressView = null; - - protected ActionBarHelperHoneycomb(Activity activity) { - super(activity); - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - mOptionsMenu = menu; - return super.onCreateOptionsMenu(menu); - } - - @Override - public void setRefreshActionItemState(boolean refreshing) { - // On Honeycomb, we can set the state of the refresh button by giving it - // a custom - // action view. - if (mOptionsMenu == null) { - return; - } - - final MenuItem refreshItem = mOptionsMenu.findItem(R.id.menu_refresh); - if (refreshItem != null) { - if (refreshing) { - if (mRefreshIndeterminateProgressView == null) { - LayoutInflater inflater = (LayoutInflater) getActionBarThemedContext() - .getSystemService(Context.LAYOUT_INFLATER_SERVICE); - mRefreshIndeterminateProgressView = inflater.inflate( - R.layout.actionbar_indeterminate_progress, null); - } - - refreshItem.setActionView(mRefreshIndeterminateProgressView); - } else { - refreshItem.setActionView(null); - } - } - } - - /** - * Returns a {@link Context} suitable for inflating layouts for the action - * bar. The implementation for this method in {@link ActionBarHelperICS} - * asks the action bar for a themed context. - */ - protected Context getActionBarThemedContext() { - return mActivity; - } - - @Override - public void setHomeButtonEnabled(boolean enabled) { - mActivity.getActionBar().setHomeButtonEnabled(enabled); - } - - @Override - public void setDisplayHomeAsUpEnabled(boolean enabled) { - mActivity.getActionBar().setDisplayHomeAsUpEnabled(enabled); - } -} diff --git a/src/com/dougkeen/bart/actionbarcompat/ActionBarHelperICS.java b/src/com/dougkeen/bart/actionbarcompat/ActionBarHelperICS.java deleted file mode 100644 index d71b045..0000000 --- a/src/com/dougkeen/bart/actionbarcompat/ActionBarHelperICS.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 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.dougkeen.bart.actionbarcompat; - -import android.app.Activity; -import android.content.Context; - -/** - * An extension of {@link com.example.android.actionbarcompat.ActionBarHelper} that provides Android - * 4.0-specific functionality for IceCreamSandwich devices. It thus requires API level 14. - */ -public class ActionBarHelperICS extends ActionBarHelperHoneycomb { - protected ActionBarHelperICS(Activity activity) { - super(activity); - } - - @Override - protected Context getActionBarThemedContext() { - return mActivity.getActionBar().getThemedContext(); - } -} diff --git a/src/com/dougkeen/bart/actionbarcompat/ActionBarListActivity.java b/src/com/dougkeen/bart/actionbarcompat/ActionBarListActivity.java deleted file mode 100644 index 256efad..0000000 --- a/src/com/dougkeen/bart/actionbarcompat/ActionBarListActivity.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 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.dougkeen.bart.actionbarcompat; - -import android.app.Activity; -import android.app.ListActivity; -import android.os.Bundle; -import android.view.Menu; -import android.view.MenuInflater; - -/** - * A base activity that defers common functionality across app activities to an {@link - * ActionBarHelper}. - * - * NOTE: dynamically marking menu items as invisible/visible is not currently supported. - * - * NOTE: this may used with the Android Compatibility Package by extending - * android.support.v4.app.FragmentActivity instead of {@link Activity}. - */ -public abstract class ActionBarListActivity extends ListActivity { - final ActionBarHelper mActionBarHelper = ActionBarHelper.createInstance(this); - - /** - * Returns the {@link ActionBarHelper} for this activity. - */ - protected ActionBarHelper getActionBarHelper() { - return mActionBarHelper; - } - - /**{@inheritDoc}*/ - @Override - public MenuInflater getMenuInflater() { - return mActionBarHelper.getMenuInflater(super.getMenuInflater()); - } - - /**{@inheritDoc}*/ - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - mActionBarHelper.onCreate(savedInstanceState); - } - - /**{@inheritDoc}*/ - @Override - protected void onPostCreate(Bundle savedInstanceState) { - super.onPostCreate(savedInstanceState); - mActionBarHelper.onPostCreate(savedInstanceState); - } - - /** - * Base action bar-aware implementation for - * {@link Activity#onCreateOptionsMenu(android.view.Menu)}. - * - * Note: marking menu items as invisible/visible is not currently supported. - */ - @Override - public boolean onCreateOptionsMenu(Menu menu) { - boolean retValue = false; - retValue |= mActionBarHelper.onCreateOptionsMenu(menu); - retValue |= super.onCreateOptionsMenu(menu); - return retValue; - } - - /**{@inheritDoc}*/ - @Override - protected void onTitleChanged(CharSequence title, int color) { - mActionBarHelper.onTitleChanged(title, color); - super.onTitleChanged(title, color); - } -} diff --git a/src/com/dougkeen/bart/actionbarcompat/SimpleMenu.java b/src/com/dougkeen/bart/actionbarcompat/SimpleMenu.java deleted file mode 100644 index d2dc936..0000000 --- a/src/com/dougkeen/bart/actionbarcompat/SimpleMenu.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright 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.dougkeen.bart.actionbarcompat; - -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.res.Resources; -import android.view.KeyEvent; -import android.view.Menu; -import android.view.MenuItem; -import android.view.SubMenu; - -import java.util.ArrayList; - -/** - * A really dumb implementation of the {@link android.view.Menu} interface, that's only - * useful for our actionbar-compat purposes. See - * com.android.internal.view.menu.MenuBuilder in AOSP for a more complete - * implementation. - */ -public class SimpleMenu implements Menu { - - private Context mContext; - private Resources mResources; - - private ArrayList mItems; - - public SimpleMenu(Context context) { - mContext = context; - mResources = context.getResources(); - mItems = new ArrayList(); - } - - public Context getContext() { - return mContext; - } - - public Resources getResources() { - return mResources; - } - - public MenuItem add(CharSequence title) { - return addInternal(0, 0, title); - } - - public MenuItem add(int titleRes) { - return addInternal(0, 0, mResources.getString(titleRes)); - } - - public MenuItem add(int groupId, int itemId, int order, CharSequence title) { - return addInternal(itemId, order, title); - } - - public MenuItem add(int groupId, int itemId, int order, int titleRes) { - return addInternal(itemId, order, mResources.getString(titleRes)); - } - - /** - * Adds an item to the menu. The other add methods funnel to this. - */ - private MenuItem addInternal(int itemId, int order, CharSequence title) { - final SimpleMenuItem item = new SimpleMenuItem(this, itemId, order, title); - mItems.add(findInsertIndex(mItems, order), item); - return item; - } - - private static int findInsertIndex(ArrayList items, int order) { - for (int i = items.size() - 1; i >= 0; i--) { - MenuItem item = items.get(i); - if (item.getOrder() <= order) { - return i + 1; - } - } - - return 0; - } - - public int findItemIndex(int id) { - final int size = size(); - - for (int i = 0; i < size; i++) { - SimpleMenuItem item = mItems.get(i); - if (item.getItemId() == id) { - return i; - } - } - - return -1; - } - - public void removeItem(int itemId) { - removeItemAtInt(findItemIndex(itemId)); - } - - private void removeItemAtInt(int index) { - if ((index < 0) || (index >= mItems.size())) { - return; - } - mItems.remove(index); - } - - public void clear() { - mItems.clear(); - } - - public MenuItem findItem(int id) { - final int size = size(); - for (int i = 0; i < size; i++) { - SimpleMenuItem item = mItems.get(i); - if (item.getItemId() == id) { - return item; - } - } - - return null; - } - - public int size() { - return mItems.size(); - } - - public MenuItem getItem(int index) { - return mItems.get(index); - } - - // Unsupported operations. - - public SubMenu addSubMenu(CharSequence charSequence) { - throw new UnsupportedOperationException("This operation is not supported for SimpleMenu"); - } - - public SubMenu addSubMenu(int titleRes) { - throw new UnsupportedOperationException("This operation is not supported for SimpleMenu"); - } - - public SubMenu addSubMenu(int groupId, int itemId, int order, CharSequence title) { - throw new UnsupportedOperationException("This operation is not supported for SimpleMenu"); - } - - public SubMenu addSubMenu(int groupId, int itemId, int order, int titleRes) { - throw new UnsupportedOperationException("This operation is not supported for SimpleMenu"); - } - - public int addIntentOptions(int i, int i1, int i2, ComponentName componentName, - Intent[] intents, Intent intent, int i3, MenuItem[] menuItems) { - throw new UnsupportedOperationException("This operation is not supported for SimpleMenu"); - } - - public void removeGroup(int i) { - throw new UnsupportedOperationException("This operation is not supported for SimpleMenu"); - } - - public void setGroupCheckable(int i, boolean b, boolean b1) { - throw new UnsupportedOperationException("This operation is not supported for SimpleMenu"); - } - - public void setGroupVisible(int i, boolean b) { - throw new UnsupportedOperationException("This operation is not supported for SimpleMenu"); - } - - public void setGroupEnabled(int i, boolean b) { - throw new UnsupportedOperationException("This operation is not supported for SimpleMenu"); - } - - public boolean hasVisibleItems() { - throw new UnsupportedOperationException("This operation is not supported for SimpleMenu"); - } - - public void close() { - throw new UnsupportedOperationException("This operation is not supported for SimpleMenu"); - } - - public boolean performShortcut(int i, KeyEvent keyEvent, int i1) { - throw new UnsupportedOperationException("This operation is not supported for SimpleMenu"); - } - - public boolean isShortcutKey(int i, KeyEvent keyEvent) { - throw new UnsupportedOperationException("This operation is not supported for SimpleMenu"); - } - - public boolean performIdentifierAction(int i, int i1) { - throw new UnsupportedOperationException("This operation is not supported for SimpleMenu"); - } - - public void setQwertyMode(boolean b) { - throw new UnsupportedOperationException("This operation is not supported for SimpleMenu"); - } -} diff --git a/src/com/dougkeen/bart/actionbarcompat/SimpleMenuItem.java b/src/com/dougkeen/bart/actionbarcompat/SimpleMenuItem.java deleted file mode 100644 index 54722e2..0000000 --- a/src/com/dougkeen/bart/actionbarcompat/SimpleMenuItem.java +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Copyright 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.dougkeen.bart.actionbarcompat; - -import android.content.Intent; -import android.graphics.drawable.Drawable; -import android.view.ActionProvider; -import android.view.ContextMenu; -import android.view.MenuItem; -import android.view.SubMenu; -import android.view.View; - -/** - * A really dumb implementation of the {@link android.view.MenuItem} - * interface, that's only useful for our actionbar-compat purposes. See - * com.android.internal.view.menu.MenuItemImpl in AOSP for a more - * complete implementation. - */ -public class SimpleMenuItem implements MenuItem { - - private SimpleMenu mMenu; - - private final int mId; - private final int mOrder; - private CharSequence mTitle; - private CharSequence mTitleCondensed; - private Drawable mIconDrawable; - private int mIconResId = 0; - private boolean mEnabled = true; - - public SimpleMenuItem(SimpleMenu menu, int id, int order, CharSequence title) { - mMenu = menu; - mId = id; - mOrder = order; - mTitle = title; - } - - public int getItemId() { - return mId; - } - - public int getOrder() { - return mOrder; - } - - public MenuItem setTitle(CharSequence title) { - mTitle = title; - return this; - } - - public MenuItem setTitle(int titleRes) { - return setTitle(mMenu.getContext().getString(titleRes)); - } - - public CharSequence getTitle() { - return mTitle; - } - - public MenuItem setTitleCondensed(CharSequence title) { - mTitleCondensed = title; - return this; - } - - public CharSequence getTitleCondensed() { - return mTitleCondensed != null ? mTitleCondensed : mTitle; - } - - public MenuItem setIcon(Drawable icon) { - mIconResId = 0; - mIconDrawable = icon; - return this; - } - - public MenuItem setIcon(int iconResId) { - mIconDrawable = null; - mIconResId = iconResId; - return this; - } - - public Drawable getIcon() { - if (mIconDrawable != null) { - return mIconDrawable; - } - - if (mIconResId != 0) { - return mMenu.getResources().getDrawable(mIconResId); - } - - return null; - } - - public MenuItem setEnabled(boolean enabled) { - mEnabled = enabled; - return this; - } - - public boolean isEnabled() { - return mEnabled; - } - - // No-op operations. We use no-ops to allow inflation from menu XML. - - public int getGroupId() { - // Noop - return 0; - } - - public View getActionView() { - // Noop - return null; - } - - public MenuItem setActionProvider(ActionProvider actionProvider) { - // Noop - return this; - } - - public ActionProvider getActionProvider() { - // Noop - return null; - } - - public boolean expandActionView() { - // Noop - return false; - } - - public boolean collapseActionView() { - // Noop - return false; - } - - public boolean isActionViewExpanded() { - // Noop - return false; - } - - @Override - public MenuItem setOnActionExpandListener( - OnActionExpandListener onActionExpandListener) { - // Noop - return this; - } - - public MenuItem setIntent(Intent intent) { - // Noop - return this; - } - - public Intent getIntent() { - // Noop - return null; - } - - public MenuItem setShortcut(char c, char c1) { - // Noop - return this; - } - - public MenuItem setNumericShortcut(char c) { - // Noop - return this; - } - - public char getNumericShortcut() { - // Noop - return 0; - } - - public MenuItem setAlphabeticShortcut(char c) { - // Noop - return this; - } - - public char getAlphabeticShortcut() { - // Noop - return 0; - } - - public MenuItem setCheckable(boolean b) { - // Noop - return this; - } - - public boolean isCheckable() { - // Noop - return false; - } - - public MenuItem setChecked(boolean b) { - // Noop - return this; - } - - public boolean isChecked() { - // Noop - return false; - } - - public MenuItem setVisible(boolean b) { - // Noop - return this; - } - - public boolean isVisible() { - // Noop - return true; - } - - public boolean hasSubMenu() { - // Noop - return false; - } - - public SubMenu getSubMenu() { - // Noop - return null; - } - - public MenuItem setOnMenuItemClickListener( - OnMenuItemClickListener onMenuItemClickListener) { - // Noop - return this; - } - - public ContextMenu.ContextMenuInfo getMenuInfo() { - // Noop - return null; - } - - public void setShowAsAction(int i) { - // Noop - } - - public MenuItem setShowAsActionFlags(int i) { - // Noop - return null; - } - - public MenuItem setActionView(View view) { - // Noop - return this; - } - - public MenuItem setActionView(int i) { - // Noop - return this; - } -} diff --git a/src/com/dougkeen/bart/controls/Ticker.java b/src/com/dougkeen/bart/controls/Ticker.java index 83d502a..a9a9af9 100644 --- a/src/com/dougkeen/bart/controls/Ticker.java +++ b/src/com/dougkeen/bart/controls/Ticker.java @@ -40,7 +40,7 @@ public class Ticker { mForceStop = false; return; } - Log.w("Ticker", "Tick #: " + mTickCount); + long startTimeNanos = System.nanoTime(); Iterator iterator = publisher.mSubscribers.keySet() .iterator(); diff --git a/src/com/dougkeen/bart/model/Departure.java b/src/com/dougkeen/bart/model/Departure.java index 19ecc69..b31e5d7 100644 --- a/src/com/dougkeen/bart/model/Departure.java +++ b/src/com/dougkeen/bart/model/Departure.java @@ -230,16 +230,22 @@ public class Departure implements Parcelable, Comparable { } } - public String getEstimatedArrivalMinutesLeftText() { + public String getEstimatedArrivalMinutesLeftText(Context context) { + if (!hasAnyArrivalEstimate()) { + return "Estimated arrival unknown"; + } long minutesLeft = getEstimatedArrivalMinutesLeft(); if (minutesLeft < 0) { return "Arrived at destination"; } else if (minutesLeft == 0) { - return "Estimated arrival in < 1 min."; + return "Arrives around " + getEstimatedArrivalTimeText(context) + + " (<1 min)"; } else if (minutesLeft == 1) { - return "Estimated arrival in 1 min."; + return "Arrives around " + getEstimatedArrivalTimeText(context) + + " (1 min)"; } else { - return "Estimated arrival in " + minutesLeft + " mins."; + return "Arrives around " + getEstimatedArrivalTimeText(context) + + " (" + minutesLeft + " mins)"; } }