Commit 143a7e20 authored by Michael Chan's avatar Michael Chan
Browse files

Per "designer" request:

Removed the one and only text which explains what the heck does the sun symbol mean
Set the sun symbol to gray
Removed current and recent labels

Also removed dead code that deals with search by time zone

Bug: 8600495
Change-Id: If4b2414e0ddef4eae943e413758b22dde4a3df0b
parent 4a2eba00
......@@ -25,21 +25,6 @@
android:paddingLeft="20dp"
android:paddingRight="20dp" >
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginBottom="0dp"
android:layout_marginTop="0dp"
android:ellipsize="marquee"
android:gravity="center_vertical"
android:minHeight="32dp"
android:padding="0dp"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="bold" />
<TextView
android:id="@+id/time_zone"
style="@style/font_family_thin"
......
......@@ -67,24 +67,4 @@
android:background="#FFECECEC"
android:choiceMode="singleChoice" >
</ListView>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:attr/listDivider"
tools:ignore="PxUsage" />
<TextView
style="@style/font_family_thin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFECECEC"
android:ellipsize="marquee"
android:paddingBottom="8dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="8dp"
android:text="@string/dst_note"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2013 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Legend for the * symbol to mean that the time zone has
a future day light savings time [CHAR LIMIT=30] -->
<string name="dst_note">\u2600 Observes daylight saving time</string>
</resources>
\ No newline at end of file
......@@ -20,22 +20,9 @@
[CHAR LIMIT=25] -->
<string name="hint_time_zone_search">Country</string>
<!-- Label for the currently selected time zone [CHAR LIMIT=30] -->
<string name="current_time_zone">CURRENT TIME ZONE</string>
<!-- Label for the recently selected time zones [CHAR LIMIT=30] -->
<plurals name="recent_time_zone">
<item quantity="one">RECENT TIME ZONE</item>
<!-- This is the label for 2 or more time zones. -->
<item quantity="other">RECENT TIME ZONES</item>
</plurals>
<!-- Label for a list of time zones searched by country name [CHAR LIMIT=30] -->
<string name="country">Country</string>
<!-- Label for a list of time zones searched by time zone name [CHAR LIMIT=30] -->
<string name="time_zone">Time zones</string>
<!-- Label for a list of time zones searched by GMT Offset [CHAR LIMIT=30] -->
<string name="gmt_offset">GMT offset</string>
......@@ -51,10 +38,6 @@
<!-- Label for a list of time zones in a certain hour of the day [CHAR LIMIT=25] -->
<string name="results_local_type">"TIME ZONES AT <xliff:g id="local_time">%s</xliff:g>"</string>
<!-- Legend for the * symbol to mean that the time zone has
a future day light savings time [CHAR LIMIT=30] -->
<string name="dst_note">\u002A Observes daylight saving time</string>
<!-- Description of clear icon in the search bar, for accessibility. [CHAR LIMIT=NONE]-->
<string name="searchview_description_clear">Clear query</string>
</resources>
\ No newline at end of file
......@@ -36,10 +36,9 @@ public class TimeZoneFilterTypeAdapter extends BaseAdapter implements Filterable
public static final int FILTER_TYPE_EMPTY = -1;
public static final int FILTER_TYPE_NONE = 0;
public static final int FILTER_TYPE_TIME = 1;
public static final int FILTER_TYPE_TIME_ZONE = 2;
public static final int FILTER_TYPE_COUNTRY = 3;
public static final int FILTER_TYPE_STATE = 4;
public static final int FILTER_TYPE_GMT = 5;
public static final int FILTER_TYPE_COUNTRY = 2;
public static final int FILTER_TYPE_STATE = 3;
public static final int FILTER_TYPE_GMT = 4;
public interface OnSetFilterListener {
void onSetFilter(int filterType, String str, int time);
......@@ -153,9 +152,6 @@ public class TimeZoneFilterTypeAdapter extends BaseAdapter implements Filterable
case FILTER_TYPE_TIME:
resId = R.string.local_time;
break;
case FILTER_TYPE_TIME_ZONE:
resId = R.string.time_zone;
break;
case FILTER_TYPE_COUNTRY:
resId = R.string.country;
break;
......
......@@ -17,8 +17,11 @@
package com.android.timezonepicker;
import android.content.Context;
import android.text.Spannable;
import android.text.Spannable.Factory;
import android.text.format.DateUtils;
import android.text.format.Time;
import android.text.style.ForegroundColorSpan;
import android.util.Log;
import android.util.SparseArray;
......@@ -31,11 +34,13 @@ import java.util.Locale;
import java.util.TimeZone;
public class TimeZoneInfo implements Comparable<TimeZoneInfo> {
private static final int DST_SYMBOL_COLOR = 0xFF606060;
private static final char SEPARATOR = ',';
private static final String TAG = null;
public static int NUM_OF_TRANSITIONS = 6;
public static long time = System.currentTimeMillis() / 1000;
public static boolean is24HourFormat;
private static final Factory mSpannableFactory = Spannable.Factory.getInstance();
TimeZone mTz;
public String mTzId;
......@@ -43,7 +48,6 @@ public class TimeZoneInfo implements Comparable<TimeZoneInfo> {
public int[] mTransitions; // may have trailing 0's.
public String mCountry;
public int groupId;
private boolean hasDst;
public String mDisplayName;
private Time recycledTime = new Time();
private static StringBuilder mSB = new StringBuilder(50);
......@@ -54,7 +58,6 @@ public class TimeZoneInfo implements Comparable<TimeZoneInfo> {
mTzId = tz.getID();
mCountry = country;
mRawoffset = tz.getRawOffset();
hasDst = tz.useDaylightTime();
try {
mTransitions = getTransitions(tz, time);
......@@ -67,7 +70,8 @@ public class TimeZoneInfo implements Comparable<TimeZoneInfo> {
SparseArray<String> mLocalTimeCache = new SparseArray<String>();
long mLocalTimeCacheReferenceTime = 0;
static private long mGmtDisplayNameUpdateTime;
static private SparseArray<String> mGmtDisplayNameCache = new SparseArray<String>();
static private SparseArray<CharSequence> mGmtDisplayNameCache =
new SparseArray<CharSequence>();
public String getLocalTime(long referenceTime) {
recycledTime.timezone = TimeZone.getDefault().getID();
......@@ -125,7 +129,7 @@ public class TimeZoneInfo implements Comparable<TimeZoneInfo> {
* mFormatter, per instance. If there are multiple callers for
* getGmtDisplayName, the output may be mangled.
*/
public synchronized String getGmtDisplayName(Context context) {
public synchronized CharSequence getGmtDisplayName(Context context) {
// TODO Note: The local time is shown in current time (current GMT
// offset) which may be different from the time specified by
// mTimeMillis
......@@ -142,7 +146,7 @@ public class TimeZoneInfo implements Comparable<TimeZoneInfo> {
cacheKey = (int) (gmtOffset - 36 * DateUtils.HOUR_IN_MILLIS);
}
String displayName = null;
CharSequence displayName = null;
if (mGmtDisplayNameUpdateTime != nowMinute) {
mGmtDisplayNameUpdateTime = nowMinute;
mGmtDisplayNameCache.clear();
......@@ -160,34 +164,22 @@ public class TimeZoneInfo implements Comparable<TimeZoneInfo> {
// mFormatter writes to mSB
DateUtils.formatDateRange(context, mFormatter, now, now, flags, mTzId);
mSB.append(" (GMT");
if (gmtOffset < 0) {
mSB.append('-');
} else {
mSB.append('+');
}
final int p = Math.abs(gmtOffset);
mSB.append(p / DateUtils.HOUR_IN_MILLIS); // Hour
final int min = (p / 60000) % 60;
if (min != 0) { // Show minutes if non-zero
mSB.append(':');
if (min < 10) {
mSB.append('0');
}
mSB.append(min);
}
mSB.append(')');
mSB.append(' ');
TimeZonePickerUtils.appendGmtOffset(mSB, gmtOffset);
if (hasFutureDST) {
String dstSymbol = TimeZonePickerUtils.getDstSymbol();
mSB.append(" ");
mSB.append(dstSymbol); // Sun symbol
mSB.append(' ');
mSB.append(TimeZonePickerUtils.getDstSymbol()); // Sun symbol
final int end = mSB.length();
final int start = end - 1;
Spannable spannableText = mSpannableFactory.newSpannable(mSB);
spannableText.setSpan(new ForegroundColorSpan(DST_SYMBOL_COLOR), start, end,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
displayName = spannableText;
} else {
displayName = mSB.toString();
}
displayName = mSB.toString();
mGmtDisplayNameCache.put(cacheKey, displayName);
}
return displayName;
......
......@@ -75,9 +75,23 @@ public class TimeZonePickerUtils {
time.set(timeMillis);
StringBuilder sb = new StringBuilder();
final int gmtOffset = tz.getOffset(timeMillis);
appendGmtOffset(sb, gmtOffset);
String displayName = getDisplayName(tz, time.isDst != 0);
sb.append(" ");
sb.append(displayName);
if (tz.useDaylightTime()) {
sb.append(" ");
sb.append(getDstSymbol()); // Sun symbol
}
return sb.toString();
}
public static void appendGmtOffset(StringBuilder sb, final int gmtOffset) {
sb.append("(GMT");
final int gmtOffset = tz.getOffset(timeMillis);
if (gmtOffset < 0) {
sb.append('-');
} else {
......@@ -95,24 +109,14 @@ public class TimeZonePickerUtils {
}
sb.append(min);
}
sb.append(") ");
String displayName = getDisplayName(tz, time.isDst != 0);
sb.append(displayName);
if (tz.useDaylightTime()) {
String dstSymbol = getDstSymbol();
sb.append(" ");
sb.append(dstSymbol); // Sun symbol
}
return sb.toString();
sb.append(')');
}
public static String getDstSymbol() {
public static char getDstSymbol() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
return "\u2600"; // The Sun emoji icon.
return '\u2600'; // The Sun emoji icon.
} else {
return "*";
return '*';
}
}
......
......@@ -32,9 +32,7 @@ import com.android.timezonepicker.TimeZoneFilterTypeAdapter.OnSetFilterListener;
import com.android.timezonepicker.TimeZonePickerView.OnTimeZoneSetListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.LinkedHashSet;
public class TimeZoneResultAdapter extends BaseAdapter implements OnItemClickListener,
OnSetFilterListener {
......@@ -54,21 +52,16 @@ public class TimeZoneResultAdapter extends BaseAdapter implements OnItemClickLis
/** The maximum number of recent timezones to save */
private static final int MAX_RECENT_TIMEZONES = 3;
private static final int RESULT_LABEL_RECENT = -100;
private static final int RESULT_LABEL_CURRENT = -200;
static class ViewHolder {
TextView timeZone;
TextView timeOffset;
TextView location;
TextView label;
static void setupViewHolder(View v) {
ViewHolder vh = new ViewHolder();
vh.timeZone = (TextView) v.findViewById(R.id.time_zone);
vh.timeOffset = (TextView) v.findViewById(R.id.time_offset);
vh.location = (TextView) v.findViewById(R.id.location);
vh.label = (TextView) v.findViewById(R.id.label);
v.setTag(vh);
}
}
......@@ -81,7 +74,6 @@ public class TimeZoneResultAdapter extends BaseAdapter implements OnItemClickLis
private int[] mFilteredTimeZoneIndices;
private int mFilteredTimeZoneLength = 0;
private int mFilterType;
public TimeZoneResultAdapter(Context context, TimeZoneData tzd,
com.android.timezonepicker.TimeZonePickerView.OnTimeZoneSetListener l) {
......@@ -103,7 +95,6 @@ public class TimeZoneResultAdapter extends BaseAdapter implements OnItemClickLis
public void onSetFilter(int filterType, String str, int time) {
Log.d(TAG, "onSetFilter: " + filterType + " [" + str + "] " + time);
mFilterType = filterType;
mFilteredTimeZoneLength = 0;
int idx = 0;
......@@ -114,7 +105,6 @@ public class TimeZoneResultAdapter extends BaseAdapter implements OnItemClickLis
// Show the default/current value first
int defaultTzIndex = mTimeZoneData.getDefaultTimeZoneIndex();
if (defaultTzIndex != -1) {
mFilteredTimeZoneIndices[mFilteredTimeZoneLength++] = RESULT_LABEL_CURRENT;
mFilteredTimeZoneIndices[mFilteredTimeZoneLength++] = defaultTzIndex;
}
......@@ -124,17 +114,11 @@ public class TimeZoneResultAdapter extends BaseAdapter implements OnItemClickLis
String recentsString = prefs.getString(KEY_RECENT_TIMEZONES, null);
if (!TextUtils.isEmpty(recentsString)) {
String[] recents = recentsString.split(RECENT_TIMEZONES_DELIMITER);
boolean first = true;
for (int i = recents.length - 1; i >= 0; i--) {
if (!TextUtils.isEmpty(recents[i])
&& !recents[i].equals(mTimeZoneData.mDefaultTimeZoneId)) {
int index = mTimeZoneData.findIndexByTimeZoneIdSlow(recents[i]);
if (index != -1) {
if (first) {
mFilteredTimeZoneIndices[mFilteredTimeZoneLength++] =
RESULT_LABEL_RECENT;
first = false;
}
mFilteredTimeZoneIndices[mFilteredTimeZoneLength++] = index;
}
}
......@@ -168,16 +152,6 @@ public class TimeZoneResultAdapter extends BaseAdapter implements OnItemClickLis
idx++;
}
break;
case TimeZoneFilterTypeAdapter.FILTER_TYPE_TIME_ZONE:
if (str != null) {
for (TimeZoneInfo tzi : mTimeZoneData.mTimeZones) {
if (str.equalsIgnoreCase(tzi.mDisplayName)) {
mFilteredTimeZoneIndices[mFilteredTimeZoneLength++] = idx;
}
idx++;
}
}
break;
case TimeZoneFilterTypeAdapter.FILTER_TYPE_COUNTRY:
ArrayList<Integer> tzIds = mTimeZoneData.mTimeZonesByCountry.get(str);
if (tzIds != null) {
......@@ -210,13 +184,11 @@ public class TimeZoneResultAdapter extends BaseAdapter implements OnItemClickLis
if (recentsString == null) {
recentsString = id;
} else {
List<String> recents = new ArrayList<String>(
Arrays.asList(recentsString.split(RECENT_TIMEZONES_DELIMITER)));
Iterator<String> it = recents.iterator();
while (it.hasNext()) {
String tz = it.next();
if (id.equals(tz)) {
it.remove();
// De-dup
LinkedHashSet<String> recents = new LinkedHashSet<String>();
for(String tzId : recentsString.split(RECENT_TIMEZONES_DELIMITER)) {
if (!recents.contains(tzId) && !id.equals(tzId)) {
recents.add(tzId);
}
}
......@@ -252,13 +224,6 @@ public class TimeZoneResultAdapter extends BaseAdapter implements OnItemClickLis
return null;
}
switch (mFilteredTimeZoneIndices[position]) {
case RESULT_LABEL_CURRENT:
return "CURRENT TIME ZONE";
case RESULT_LABEL_RECENT:
return "RECENT TIME ZONE";
}
return mTimeZoneData.get(mFilteredTimeZoneIndices[position]);
}
......@@ -288,36 +253,19 @@ public class TimeZoneResultAdapter extends BaseAdapter implements OnItemClickLis
ViewHolder vh = (ViewHolder) v.getTag();
if (mFilteredTimeZoneIndices[position] >= 0) {
TimeZoneInfo tzi = mTimeZoneData.get(mFilteredTimeZoneIndices[position]);
v.setTag(VIEW_TAG_TIME_ZONE, tzi);
TimeZoneInfo tzi = mTimeZoneData.get(mFilteredTimeZoneIndices[position]);
v.setTag(VIEW_TAG_TIME_ZONE, tzi);
vh.label.setVisibility(View.GONE);
vh.timeZone.setText(tzi.mDisplayName);
vh.timeZone.setVisibility(View.VISIBLE);
vh.timeZone.setText(tzi.mDisplayName);
vh.timeOffset.setText(tzi.getGmtDisplayName(mContext));
vh.timeOffset.setVisibility(View.VISIBLE);
vh.timeOffset.setText(tzi.getGmtDisplayName(mContext));
String location = tzi.mCountry;
if (location == null) {
vh.location.setVisibility(View.INVISIBLE);
} else {
vh.location.setText(location);
vh.location.setVisibility(View.VISIBLE);
}
String location = tzi.mCountry;
if (location == null) {
vh.location.setVisibility(View.INVISIBLE);
} else {
if (mFilteredTimeZoneIndices[position] == RESULT_LABEL_CURRENT) {
vh.label.setText(v.getResources().getText(R.string.current_time_zone));
} else if (mFilteredTimeZoneIndices[position] == RESULT_LABEL_RECENT) {
vh.label.setText(v.getResources().getQuantityText(R.plurals.recent_time_zone,
/* num of recent tzs */ mFilteredTimeZoneLength - position - 1));
}
vh.label.setVisibility(View.VISIBLE);
vh.timeZone.setVisibility(View.GONE);
vh.timeOffset.setVisibility(View.GONE);
vh.location.setVisibility(View.GONE);
v.setTag(VIEW_TAG_TIME_ZONE, null);
vh.location.setText(location);
vh.location.setVisibility(View.VISIBLE);
}
return v;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment