All context menus switched to action mode pattern.

Completed transition to Holo theme.
This commit is contained in:
dkeen@dkeen-laptop 2012-07-22 07:57:17 -07:00
parent 749f8ac124
commit fb9ea894be
49 changed files with 680 additions and 1596 deletions

View File

@ -43,7 +43,7 @@
<activity
android:name="AddRouteActivity"
android:label="@string/add_route"
android:theme="@android:style/Theme.Dialog" >
android:theme="@style/DialogHoloDark" >
<intent-filter>
<action android:name="android.intent.action.INSERT" />
@ -55,7 +55,7 @@
<activity
android:name="QuickRouteActivity"
android:label="@string/quick_departure_lookup"
android:theme="@android:style/Theme.Dialog" >
android:theme="@style/DialogHoloDark" >
<intent-filter>
<action android:name="android.intent.action.PICK" />

92
board.svg Normal file
View File

@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="72"
height="72"
id="svg2"
sodipodi:version="0.32"
inkscape:version="0.48.2 r9819"
version="1.0"
sodipodi:docname="board.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
inkscape:export-filename="F:\Workspaces\Android\bartrunner\res\drawable-hdpi\boarding_icon.png"
inkscape:export-xdpi="60"
inkscape:export-ydpi="60">
<defs
id="defs4">
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 526.18109 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="744.09448 : 526.18109 : 1"
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
id="perspective10" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
gridtolerance="10000"
guidetolerance="10"
objecttolerance="10"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="8.2888628"
inkscape:cx="8.7438681"
inkscape:cy="22.864462"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
width="72px"
inkscape:window-width="1920"
inkscape:window-height="1052"
inkscape:window-x="-9"
inkscape:window-y="-8"
inkscape:snap-global="false"
inkscape:window-maximized="0" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<g
id="g3936"
transform="matrix(1.07372,0,0,1.2253945,-3.3921025,-6.4292846)">
<path
id="rect3822"
d="m 31.5625,16.1875 0,0.28125 c 0.06233,-0.09701 0.116505,-0.202952 0.1875,-0.28125 l -0.1875,0 z m 2.1875,0.96875 c -0.590149,0 -1.103388,0.628761 -1.3125,1.53125 l 4.25,0 c 0.8481,0 1.53125,1.177592 1.53125,2.65625 l 0,10.625 c 0,1.478658 -0.68315,2.65625 -1.53125,2.65625 l -4.34375,0 0,15.03125 c 0,1.371605 0.627703,2.46875 1.40625,2.46875 l 6.6875,0 c 0.164809,-0.429092 0.25,-0.945503 0.25,-1.5 l 0,-31.75 c 0,-0.652773 -0.122056,-1.251936 -0.34375,-1.71875 l -6.59375,0 z m -2.1875,35.65625 0,0.5 0.46875,0 c -0.178003,-0.118196 -0.32966,-0.281382 -0.46875,-0.5 z"
style="fill:#ebebeb;fill-opacity:0.92156863"
inkscape:connector-curvature="0" />
<path
id="rect2997"
d="m 8.59375,13.75 c -1.662,0 -3,1.338 -3,3 l 0,35.75 c 0,1.662 1.338,3 3,3 l 56.1875,0 c 1.662,0 3,-1.338 3,-3 l 0,-35.75 c 0,-1.662 -1.338,-3 -3,-3 l -56.1875,0 z m 24.53125,2.3125 28.6875,0 c 0.8481,0 1.53125,1.177592 1.53125,2.65625 l 0,31.8125 c 0,1.478657 -0.68315,2.6875 -1.53125,2.6875 l -28.6875,0 c -0.8481,0 -1.53125,-1.208843 -1.53125,-2.6875 l 0,-31.8125 c 0,-1.478658 0.68315,-2.65625 1.53125,-2.65625 z m -13.90625,6.21875 c 2.134279,0 3.875,1.918195 3.875,4.28125 0,2.363054 -1.740721,4.28125 -3.875,4.28125 -2.134281,0 -3.875,-1.918196 -3.875,-4.28125 0,-2.363055 1.740719,-4.28125 3.875,-4.28125 z m -0.625,9.4375 0.625,0 c 0.76757,0 1.427333,0.323204 1.90625,0.8125 0.01382,0.0044 0.01744,0.02645 0.03125,0.03125 0.398269,0.138416 0.795793,0.426894 1.09375,0.84375 l 2.90625,4.0625 c 0.04418,0.06181 0.08746,0.124004 0.125,0.1875 l 2.875,1.875 c 0.636709,0.412254 0.811942,1.223592 0.40625,1.84375 l -0.03125,0.0625 c -0.405692,0.620158 -1.238291,0.787254 -1.875,0.375 L 23.625,39.84375 C 23.58353,39.82223 23.54078,39.80606 23.5,39.78125 23.45693,39.75336 23.4139,39.71903 23.375,39.6875 23.33873,39.66154 23.31659,39.62235 23.28125,39.59375 23.115691,39.459753 22.947672,39.314112 22.8125,39.125 l -0.96875,-1.34375 0,5.09375 c 0,0.05417 -0.02767,0.102996 -0.03125,0.15625 0.02054,0.02235 0.04275,0.03894 0.0625,0.0625 l 2.53125,3 c 0.489868,0.212626 0.81955,0.683211 0.8125,1.25 L 25.1875,51.0625 c -0.0094,0.755719 -0.646632,1.3844 -1.40625,1.375 -0.759617,-0.0094 -1.35315,-0.650531 -1.34375,-1.40625 l 0.03125,-2.8125 -2.5,-3 c -0.238476,0.06628 -0.487796,0.125 -0.75,0.125 l -0.625,0 c -0.09625,0 -0.18776,-0.02191 -0.28125,-0.03125 l -1.09375,2.78125 c -0.01891,0.118226 -0.04136,0.229499 -0.09375,0.34375 l -0.21875,0.46875 -0.3125,0.8125 c -0.08499,0.218647 -0.18381,0.421185 -0.3125,0.59375 -0.01657,0.02222 -0.04534,0.04113 -0.0625,0.0625 L 15.5625,51.84375 C 15.247183,52.531351 14.441145,52.813699 13.75,52.5 13.058847,52.186301 12.778433,51.375098 13.09375,50.6875 L 13.8125,49.125 c 0.0039,-0.0199 -0.0044,-0.04254 0,-0.0625 0.02743,-0.123055 0.04578,-0.251597 0.09375,-0.375 l 1.8125,-4.65625 c 0.0861,-0.221492 0.212909,-0.388359 0.34375,-0.5625 -0.04965,-0.190791 -0.09375,-0.387629 -0.09375,-0.59375 l 0,-5.59375 -0.9375,1.25 c -0.01858,0.02492 -0.04329,0.03852 -0.0625,0.0625 9.34e-4,0.02076 0,0.04151 0,0.0625 l 0,3.71875 c 0,0.755778 -0.584072,1.375 -1.34375,1.375 -0.759675,0 -1.375,-0.619222 -1.375,-1.375 l 0,-3.71875 c 0,-0.119479 0.03376,-0.233457 0.0625,-0.34375 -0.04472,-0.476122 0.08051,-1.021319 0.4375,-1.5 l 2.96875,-4 c 0.475465,-0.637541 1.16346,-0.948192 1.75,-0.875 0.0088,-0.0039 0.0224,0.0038 0.03125,0 0.331847,-0.141407 0.703884,-0.21875 1.09375,-0.21875 z"
style="fill:#ebebeb;fill-opacity:0.92156863"
inkscape:connector-curvature="0" />
<path
id="rect3822-0"
d="m 63.425059,16.243187 0,0.28125 c -0.06233,-0.09701 -0.116505,-0.202952 -0.1875,-0.28125 l 0.1875,0 z m -2.1875,0.96875 c 0.590149,0 1.103388,0.628761 1.3125,1.53125 l -4.25,0 c -0.8481,0 -1.53125,1.177592 -1.53125,2.65625 l 0,10.625 c 0,1.478658 0.68315,2.65625 1.53125,2.65625 l 4.34375,0 0,15.03125 c 0,1.371605 -0.627703,2.46875 -1.40625,2.46875 l -6.6875,0 c -0.164809,-0.429092 -0.25,-0.945503 -0.25,-1.5 l 0,-31.75 c 0,-0.652773 0.122056,-1.251936 0.34375,-1.71875 l 6.59375,0 z m 2.1875,35.65625 0,0.5 -0.46875,0 c 0.178003,-0.118196 0.32966,-0.281382 0.46875,-0.5 z"
style="fill:#ebebeb;fill-opacity:0.92156863"
inkscape:connector-curvature="0" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 6.5 KiB

BIN
departure.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

203
departure.svg Normal file
View File

@ -0,0 +1,203 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="72"
height="72"
id="svg2"
sodipodi:version="0.32"
inkscape:version="0.48.2 r9819"
version="1.0"
sodipodi:docname="departure.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
inkscape:export-filename="F:\Workspaces\Android\bartrunner\res\drawable-hdpi\departure_icon.png"
inkscape:export-xdpi="60"
inkscape:export-ydpi="60">
<defs
id="defs4">
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 526.18109 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="744.09448 : 526.18109 : 1"
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
id="perspective10" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
gridtolerance="10000"
guidetolerance="10"
objecttolerance="10"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="12.736111"
inkscape:cx="11.942478"
inkscape:cy="37.983218"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
width="72px"
inkscape:window-width="1920"
inkscape:window-height="1052"
inkscape:window-x="-9"
inkscape:window-y="-8"
inkscape:snap-global="false"
inkscape:window-maximized="0" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<path
style="fill:#ebebeb;fill-opacity:0.92156863;fill-rule:evenodd;stroke:none"
d="m 24.743145,11.609206 c -6.026936,0.01276 -12.038191,1.041686 -15.6562502,3.3125 -2.2743865,1.374178 -5.4688336,32.650782 -2.625,34.34375 3.411287,2.030779 35.3254332,1.511637 37.2500002,0.75 2.789572,-1.103959 0.153375,-34.051105 -3.21875,-35.65625 -3.689897,-1.756404 -9.723064,-2.762765 -15.75,-2.75 z m -4.0625,4.53125 c 1.062477,-0.02811 1.892689,0.06556 2.25,0.28125 1.238507,0.747614 0.568709,23.049807 -0.71875,23.875 -0.923705,0.592046 -12.9122822,0.480838 -13.8437502,-0.65625 -1.12794,-1.376932 1.7050042,-19.923758 2.7187502,-21.09375 1.095658,-1.264526 6.40632,-2.321932 9.59375,-2.40625 z m -10.8125002,27.625 c 0.9719972,-0.01644 1.9046142,0.734366 2.0625002,1.6875 0.157886,0.953134 -0.496753,1.733559 -1.46875,1.75 -0.9719962,0.01644 -1.9046144,-0.734366 -2.0625002,-1.6875 -0.1578858,-0.953134 0.4967539,-1.733559 1.46875,-1.75 z m 29.0937502,0.46875 c 1.023155,-0.01731 1.985343,0.812007 2.15625,1.84375 0.170907,1.031743 -0.539345,1.888943 -1.5625,1.90625 -1.023154,0.01731 -1.985343,-0.812007 -2.15625,-1.84375 -0.170907,-1.031743 0.539346,-1.888943 1.5625,-1.90625 z"
id="path2393"
inkscape:connector-curvature="0" />
<rect
style="fill:#ebebeb;fill-opacity:0.92156863"
id="rect3899"
width="3.1943014"
height="11.719805"
x="26.055975"
y="43.383099"
ry="1.6742576"
transform="matrix(0.97210432,0.23454889,-0.21232976,0.97719807,0,0)"
inkscape:transform-center-x="0.45927426"
inkscape:transform-center-y="1.8227312" />
<rect
style="fill:#ebebeb;fill-opacity:0.92156863"
id="rect3899-1"
width="3.1949658"
height="11.717586"
x="20.555859"
y="55.671436"
ry="1.6739407"
transform="matrix(0.96996262,-0.24325402,0.22029776,0.97543267,0,0)" />
<rect
style="fill:#ebebeb;fill-opacity:0.92156863"
id="rect3921"
width="19.909697"
height="16.784204"
x="46.749786"
y="40.111366"
ry="1.6784203" />
<path
sodipodi:type="arc"
style="fill:#ebebeb;fill-opacity:0.92156863"
id="path3925"
sodipodi:cx="56.610687"
sodipodi:cy="23.986914"
sodipodi:rx="2.4340241"
sodipodi:ry="2.7088332"
d="m 59.044711,23.986914 a 2.4340241,2.7088332 0 1 1 -4.868048,0 2.4340241,2.7088332 0 1 1 4.868048,0 z"
transform="matrix(1.0142884,0,0,1.0688274,-2.8651784,-3.0240355)" />
<rect
style="fill:#ebebeb;fill-opacity:0.92156863"
id="rect3927"
width="3.7430229"
height="9.2313118"
x="52.881977"
y="26.096556"
ry="1.6784203" />
<rect
style="fill:#ebebeb;fill-opacity:0.92156863"
id="rect3929"
width="1.8673232"
height="5.852253"
x="29.147854"
y="54.950256"
ry="1.2698284"
transform="matrix(0.78735859,-0.61649529,0.57570614,0.81765668,0,0)"
inkscape:transform-center-x="-1.9979099"
inkscape:transform-center-y="1.6057666" />
<rect
style="fill:#ebebeb;fill-opacity:0.92156863"
id="rect3931"
width="1.7520533"
height="4.363893"
x="57.262108"
y="29.873003"
ry="0.92313117" />
<rect
style="fill:#ebebeb;fill-opacity:0.92156863"
id="rect3929-7"
width="1.865285"
height="5.8580422"
x="58.925991"
y="-10.999067"
ry="1.2710847"
transform="matrix(0.80068044,0.59909167,-0.55936824,0.82891928,0,0)"
inkscape:transform-center-x="0.83145975"
inkscape:transform-center-y="2.4986547" />
<rect
style="fill:#ebebeb;fill-opacity:0.92156863"
id="rect3931-4"
width="1.8187417"
height="4.208703"
x="53.571827"
y="-28.423727"
ry="0.89030248"
transform="matrix(0.52546884,0.85081284,-0.8246912,0.56558325,0,0)" />
<rect
style="fill:#ebebeb;fill-opacity:0.92156863"
id="rect3929-7-0"
width="1.8448521"
height="5.9197183"
x="39.623714"
y="52.104515"
ry="1.2844672"
transform="matrix(0.92577842,-0.37806654,0.34453051,0.93877512,0,0)"
inkscape:transform-center-x="-1.5204516"
inkscape:transform-center-y="2.1080532" />
<rect
style="fill:#ebebeb;fill-opacity:0.92156863"
id="rect3931-9"
width="1.7686416"
height="4.3263474"
x="36.450794"
y="57.070484"
ry="0.91518885"
transform="matrix(0.90125744,-0.433284,0.39730647,0.91768599,0,0)" />
<rect
style="fill:#ebebeb;fill-opacity:0.92156863"
id="rect3929-7-4"
width="1.8729073"
height="5.0959587"
x="62.501968"
y="-10.766301"
ry="1.1057268"
transform="matrix(0.74968262,0.66179753,-0.62049151,0.78421316,0,0)"
inkscape:transform-center-x="0.81643284"
inkscape:transform-center-y="2.1779835" />
<rect
style="fill:#ebebeb;fill-opacity:0.92156863"
id="rect3931-9-8"
width="1.7520682"
height="4.3638597"
x="50.280754"
y="36.420254"
ry="0.92312407"
transform="matrix(0.99991421,-0.01309843,0.01179598,0.99993043,0,0)" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 7.3 KiB

BIN
departure_Med.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 742 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 953 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 952 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 817 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1020 B

View File

@ -1,23 +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.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/actionbar_compat_item_pressed"
android:state_pressed="true" />
<item android:drawable="@drawable/actionbar_compat_item_focused"
android:state_focused="true" />
<item android:drawable="@android:color/transparent" />
</selector>

View File

@ -1,19 +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.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#ef7000" />
</shape>

View File

@ -1,19 +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.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#eda700" />
</shape>

View File

@ -0,0 +1,11 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/transparent" android:state_enabled="true" android:state_window_focused="false"/>
<item android:drawable="@drawable/btn_default_disabled_holo_dark" android:state_enabled="false" android:state_window_focused="false"/>
<item android:drawable="@drawable/btn_default_pressed_holo_dark" android:state_pressed="true"/>
<item android:drawable="@drawable/btn_default_focused_holo_dark" android:state_enabled="true" android:state_focused="true"/>
<item android:drawable="@drawable/transparent" android:state_enabled="true"/>
<item android:drawable="@drawable/btn_default_disabled_focused_holo_dark" android:state_focused="true"/>
<item android:drawable="@drawable/btn_default_disabled_holo_dark"/>
</selector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
</shape>

View File

@ -1,27 +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.
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center">
<ProgressBar android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_gravity="center"
style="?android:attr/indeterminateProgressStyle" />
</FrameLayout>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:textColor="#000"
android:paddingBottom="10dip"
android:paddingLeft="5dip"
android:paddingRight="5dip"
android:paddingTop="10dip"
android:singleLine="true" >
</TextView>

View File

@ -1,21 +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.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@id/actionbar_compat"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" />

View File

@ -1,71 +1,108 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="5dp"
android:paddingRight="5dp" >
android:layout_width="300dp"
android:layout_height="wrap_content"
android:gravity="center_vertical" >
<View
android:id="@+id/titleDivider"
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_alignParentTop="true"
android:background="@color/abs__holo_blue_light" />
<Spinner
android:id="@+id/origin_spinner"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@id/titleDivider"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="15dip" />
<TextView
android:id="@+id/origin_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignBottom="@+id/origin_spinner"
android:layout_alignParentLeft="true"
android:layout_below="@id/titleDivider"
android:gravity="center_vertical"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="15dip"
android:text="@string/origin"
android:textSize="15dp" >
android:textSize="15sp" >
</TextView>
<Spinner
android:id="@+id/origin_spinner"
android:layout_width="fill_parent"
android:id="@+id/destination_spinner"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_below="@id/origin_label" />
android:layout_alignParentRight="true"
android:layout_below="@+id/origin_spinner"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="15dip" />
<TextView
android:id="@+id/destination_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/origin_spinner"
android:layout_alignBottom="@+id/destination_spinner"
android:layout_alignParentLeft="true"
android:layout_below="@+id/origin_spinner"
android:gravity="center_vertical"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="15dip"
android:text="@string/destination"
android:textSize="15dp" >
android:textSize="15sp" >
</TextView>
<Spinner
android:id="@+id/destination_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/destination_label" />
<TextView
android:id="@+id/return_checkbox_text"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_below="@id/destination_spinner"
android:layout_centerHorizontal="true"
android:gravity="center_vertical"
android:text="@string/also_add_return_route"
android:visibility="gone" />
<CheckBox
android:id="@+id/return_checkbox"
android:layout_width="fill_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/destination_spinner"
android:text="@string/also_add_return_route"
android:layout_toLeftOf="@id/return_checkbox_text"
android:visibility="gone" />
<LinearLayout
android:id="@+id/buttonBar"
style="@style/ButtonBar"
android:layout_width="fill_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/return_checkbox"
android:orientation="horizontal" >
<Button
android:id="@+id/okButton"
android:id="@+id/cancelButton"
style="ButtonHoloBorderless"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/ok" >
android:text="@android:string/cancel" >
</Button>
<Button
android:id="@+id/cancelButton"
android:id="@+id/okButton"
style="ButtonHoloBorderless"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/cancel" >
android:text="@android:string/ok" >
</Button>
</LinearLayout>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:textColor="#fff"
android:paddingBottom="10dip"
android:paddingLeft="5dip"
android:paddingRight="5dip"
android:paddingTop="10dip"
android:singleLine="true" >
</TextView>

View File

@ -1,8 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:paddingTop="15dip" android:paddingBottom="15dip"
android:paddingLeft="5dip" android:paddingRight="5dip" android:id="@android:id/text1"
android:ellipsize="marquee" android:textColor="@color/black"
android:singleLine="true">
</TextView>
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" >
</TextView>

View File

@ -1,4 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:title="@string/getting_on_this_train" android:id="@+id/boardTrain"></item>
<item
android:id="@+id/boardTrain"
android:icon="@drawable/boarding_icon"
android:showAsAction="ifRoom|withText"
android:title="@string/getting_on_this_train">
</item>
</menu>

View File

@ -1,5 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:title="@string/view_departures" android:id="@+id/view"></item>
<item android:title="@string/delete" android:id="@+id/delete"></item>
</menu>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/view"
android:icon="@drawable/departure_icon"
android:showAsAction="ifRoom|withText"
android:title="@string/view_departures">
</item>
<item
android:id="@+id/delete"
android:icon="@drawable/delete_icon"
android:showAsAction="ifRoom|withText"
android:title="@string/delete">
</item>
</menu>

View File

@ -1,34 +1,6 @@
<!--
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.
-->
<resources>
<style name="AppTheme" parent="android:style/Theme.Holo">
<item name="android:actionBarStyle">@style/ActionBar</item>
<item name="android:windowContentOverlay">@drawable/actionbar_shadow</item>
</style>
<style name="ActionBar" parent="android:style/Widget.Holo.ActionBar">
<item name="android:background">#222</item>
<item name="android:titleTextStyle">@style/ActionBarTitle</item>
<item name="android:icon">@drawable/icon</item>
</style>
<style name="ActionBarTitle">
<item name="android:textColor">@color/actionbar_title_color</item>
</style>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="ButtonHoloBorderless" parent="@android:style/Widget.Holo.Button.Borderless.Small"></style>
</resources>

View File

@ -1,23 +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.
-->
<resources>
<style name="ActionBarTitle" parent="android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">@color/actionbar_title_color</item>
</style>
</resources>

View File

@ -18,16 +18,6 @@
<attr name="tickInterval" format="integer" />
<declare-styleable name="AppTheme">
<attr name="actionbarCompatTitleStyle" format="reference" />
<attr name="actionbarCompatItemStyle" format="reference" />
<attr name="actionbarCompatItemHomeStyle" format="reference" />
<attr name="actionbarCompatProgressIndicatorStyle" format="reference" />
</declare-styleable>
<declare-styleable name="BezelImageView">
<attr name="maskDrawable" format="reference" />
<attr name="borderDrawable" format="reference" />
</declare-styleable>
<declare-styleable name="CountdownTextView">
<attr name="tickInterval" />
</declare-styleable>

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="black">#FF000000</color>
<color name="actionbar_title_color">#EEEEEE</color>
</resources>

View File

@ -1,21 +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.
-->
<resources>
<dimen name="actionbar_compat_height">48dp</dimen>
<dimen name="actionbar_compat_button_width">48dp</dimen>
<dimen name="actionbar_compat_button_home_width">56dp</dimen>
</resources>

View File

@ -1,23 +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.
-->
<resources>
<item type="id" name="actionbar_compat" />
<item type="id" name="actionbar_compat_title" />
<item type="id" name="actionbar_compat_item_refresh_progress" />
<item type="id" name="actionbar_compat_item_refresh" />
<item type="id" name="menu_refresh" />
</resources>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">BART Runner</string>
<string name="favorite_routes">Favorite Routes</string>
<string name="favorite_routes">Favorite routes</string>
<string name="empty_favorites_list_message">No favorite routes have been added yet</string>
<string name="add_route">Add a route</string>
<string name="origin">Origin</string>
@ -32,7 +32,7 @@
<string name="departures">Departures</string>
<string name="ok">OK</string>
<string name="quick_departure_lookup">Quick departure lookup</string>
<string name="getting_on_this_train">I\'m getting on this train</string>
<string name="getting_on_this_train">I will board this train</string>
<string name="departure_options">Departure options</string>
<string name="your_train">Your train</string>
</resources>

View File

@ -2,52 +2,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Base application theme is the default theme. -->
<style name="AppTheme" parent="@android:Theme">
<item name="android:windowTitleSize">@dimen/actionbar_compat_height</item>
<item name="android:windowTitleBackgroundStyle">@style/ActionBarCompat</item>
<item name="android:windowContentOverlay">@drawable/actionbar_shadow</item>
<!-- for programmatic instantiation -->
<item name="actionbarCompatTitleStyle">@style/ActionBarCompatTitle</item>
<item name="actionbarCompatItemStyle">@style/ActionBarCompatItem</item>
<item name="actionbarCompatItemHomeStyle">@style/ActionBarCompatHomeItem</item>
<item name="actionbarCompatProgressIndicatorStyle">@style/ActionBarCompatProgressIndicator</item>
</style>
<style name="ActionBarCompat">
<item name="android:background">#222</item>
</style>
<style name="ActionBarCompatItemBase">
<!-- layout_width/height must be set in code -->
<item name="android:scaleType">center</item>
<item name="android:background">@drawable/actionbar_compat_item</item>
</style>
<style name="ActionBarCompatProgressIndicator" parent="android:style/Widget.ProgressBar.Large">
<item name="android:indeterminate">true</item>
</style>
<style name="ActionBarCompatTitleBase">
<item name="android:id">@id/actionbar_compat_title</item>
<!-- layout_width/height/weight must be set in code -->
<item name="android:gravity">center_vertical</item>
<item name="android:textSize">18sp</item>
<item name="android:paddingLeft">6dp</item>
<item name="android:paddingRight">6dp</item>
<item name="android:singleLine">false</item>
<item name="android:maxLines">2</item>
<item name="android:ellipsize">marquee</item>
</style>
<style name="ActionBarCompatTitle" parent="style/ActionBarCompatTitleBase">
<item name="android:textColor">@color/actionbar_title_color</item>
</style>
<style name="ActionBarCompatItem" parent="style/ActionBarCompatItemBase"></style>
<style name="ActionBarCompatHomeItem" parent="style/ActionBarCompatItemBase"></style>
<style name="AppTheme" parent="@style/Theme.HoloEverywhereDark.Sherlock"></style>
<style name="ButtonBar">
<item name="android:layout_width">fill_parent</item>
@ -124,9 +79,14 @@
<item name="android:layout_marginRight">87dp</item>
<item name="android:layout_marginBottom">5dp</item>
</style>
<style name="bottomButton">
<item name="android:background">#222</item>
</style>
<style name="ButtonHoloBorderless" parent="ButtonHoloDark">
<item name="android:background">@drawable/btn_borderless_holo_dark</item>
<item name="android:textColor">#ffffff</item>
</style>
</resources>

View File

@ -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<Station>(this,
R.layout.simple_spinner_item, Station.getStationList());
ArrayAdapter<Station> originSpinnerAdapter = new ArrayAdapter<Station>(
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<Station>(
this, R.layout.simple_spinner_item, Station.getStationList());
ArrayAdapter<Station> destinationSpinnerAdapter = new ArrayAdapter<Station>(
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);

View File

@ -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

View File

@ -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;
}
}
}

View File

@ -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;
}
}
}

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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 <em>menu</em> 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);
}

View File

@ -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<Integer> mActionItemIds = new HashSet<Integer>();
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
* <code>menu_refresh</code>, 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) {
}
}

View File

@ -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);
}
}

View File

@ -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();
}
}

View File

@ -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);
}
}

View File

@ -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 <em>really</em> dumb implementation of the {@link android.view.Menu} interface, that's only
* useful for our actionbar-compat purposes. See
* <code>com.android.internal.view.menu.MenuBuilder</code> in AOSP for a more complete
* implementation.
*/
public class SimpleMenu implements Menu {
private Context mContext;
private Resources mResources;
private ArrayList<SimpleMenuItem> mItems;
public SimpleMenu(Context context) {
mContext = context;
mResources = context.getResources();
mItems = new ArrayList<SimpleMenuItem>();
}
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<? extends MenuItem> 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");
}
}

View File

@ -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 <em>really</em> dumb implementation of the {@link android.view.MenuItem}
* interface, that's only useful for our actionbar-compat purposes. See
* <code>com.android.internal.view.menu.MenuItemImpl</code> 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;
}
}

View File

@ -40,7 +40,7 @@ public class Ticker {
mForceStop = false;
return;
}
Log.w("Ticker", "Tick #: " + mTickCount);
long startTimeNanos = System.nanoTime();
Iterator<TickSubscriber> iterator = publisher.mSubscribers.keySet()
.iterator();

View File

@ -230,16 +230,22 @@ public class Departure implements Parcelable, Comparable<Departure> {
}
}
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)";
}
}