Bug 1002575 - Part 2: Display "Last synced" time in Synced tabs panel. r=rnewman

For the resources, I kept the client/last_synced (group) text sizes the
same as the tab/url (child) text sizes; and I kept the group height the
same as the child height (since I didn't want to calculate the new group
size); and I stripped the (unnecessary) backgrounds.
This commit is contained in:
Nick Alexander 2014-05-07 17:05:50 -07:00
parent 1d42100370
commit d5343615f6
7 changed files with 94 additions and 45 deletions

View File

@ -434,3 +434,11 @@ just addresses the organization to follow, e.g. "This site is run by " -->
They are never shown to users -->
<!ENTITY actionbar_menu "Menu">
<!ENTITY actionbar_done "Done">
<!-- Localization note (remote_tabs_last_synced): the variable is replaced by a
"relative time span string" produced by Android. This string describes the
time the tabs were last synced relative to the current time; examples
include "42 minutes ago", "4 days ago", "last week", etc. The subject of
"Last synced" is one of the user's other Sync clients, typically Firefox on
their desktop or laptop.-->
<!ENTITY remote_tabs_last_synced "Last synced: &formatS;">

View File

@ -4,24 +4,24 @@
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/action_bar_button_inverse"
android:gravity="center_vertical"
android:layout_width="fill_parent"
android:layout_height="@dimen/remote_tab_child_row_height"
android:gravity="center_vertical"
android:orientation="vertical"
android:background="@drawable/action_bar_button_inverse"
android:paddingLeft="2dp"
android:paddingRight="2dp">
<TextView android:id="@+id/tab"
style="@style/TabRowTextAppearance"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="@style/TabRowTextAppearance"
android:textSize="14sp"/>
<TextView android:id="@+id/url"
style="@style/TabRowTextAppearance.Url"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="@style/TabRowTextAppearance.Url"
android:textSize="12sp"/>
</LinearLayout>

View File

@ -3,16 +3,28 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<org.mozilla.gecko.widget.AllCapsTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/client"
android:layout_width="fill_parent"
android:layout_height="@dimen/remote_tab_group_row_height"
style="@style/TabRowTextAppearance.Url"
android:background="@android:color/transparent"
android:paddingLeft="2dip"
android:paddingRight="2dip"
android:textStyle="bold"
android:textSize="12sp"
android:singleLine="false"
android:maxLines="2"
android:gravity="center_vertical"/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@android:color/transparent"
android:layout_width="fill_parent"
android:layout_height="@dimen/remote_tab_child_row_height"
android:gravity="center_vertical"
android:orientation="vertical"
android:paddingLeft="2dp"
android:paddingRight="2dp">
<org.mozilla.gecko.widget.AllCapsTextView android:id="@+id/client"
style="@style/TabRowTextAppearance"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:maxLines="2"
android:singleLine="false"
android:textSize="14sp"
android:textStyle="bold" />
<TextView android:id="@+id/last_synced"
style="@style/TabRowTextAppearance.Url"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="12sp"/>
</LinearLayout>

View File

@ -4,25 +4,25 @@
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@android:color/transparent"
android:gravity="center_vertical"
android:layout_width="fill_parent"
android:layout_height="@dimen/remote_tab_child_row_height"
android:gravity="center_vertical"
android:orientation="vertical"
android:background="@drawable/action_bar_button_inverse"
android:paddingLeft="4dp"
android:paddingRight="4dp">
<TextView android:id="@+id/tab"
style="@style/TabRowTextAppearance"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="@style/TabRowTextAppearance"
android:textSize="18sp"/>
android:textSize="18sp" />
<TextView android:id="@+id/url"
style="@style/TabRowTextAppearance.Url"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="@style/TabRowTextAppearance.Url"
android:textSize="14sp"
android:maxLength="1024"/>
android:maxLength="1024"
android:textSize="14sp" />
</LinearLayout>

View File

@ -3,14 +3,27 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<org.mozilla.gecko.widget.AllCapsTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/client"
android:layout_width="fill_parent"
android:layout_height="@dimen/remote_tab_group_row_height"
style="@style/TabRowTextAppearance.Url"
android:background="@android:color/transparent"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:textStyle="bold"
android:textSize="14sp"
android:gravity="center_vertical"/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@android:color/transparent"
android:layout_width="fill_parent"
android:layout_height="@dimen/remote_tab_child_row_height"
android:gravity="center_vertical"
android:orientation="vertical"
android:paddingLeft="4dp"
android:paddingRight="4dp" >
<org.mozilla.gecko.widget.AllCapsTextView android:id="@+id/client"
style="@style/TabRowTextAppearance"
android:layout_width="fill_parent"
android:layout_height="@dimen/remote_tab_group_row_height"
android:textSize="18sp"
android:textStyle="bold" />
<TextView android:id="@+id/last_synced"
style="@style/TabRowTextAppearance.Url"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:maxLength="1024"
android:textSize="14sp" />
</LinearLayout>

View File

@ -404,4 +404,5 @@
<!-- Miscellaneous -->
<string name="ellipsis">&ellipsis;</string>
<string name="remote_tabs_last_synced">&remote_tabs_last_synced;</string>
</resources>

View File

@ -4,14 +4,6 @@
package org.mozilla.gecko.tabspanel;
import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ExpandableListView;
import android.widget.SimpleExpandableListAdapter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -22,6 +14,14 @@ import org.mozilla.gecko.TabsAccessor;
import org.mozilla.gecko.Telemetry;
import org.mozilla.gecko.TelemetryContract;
import android.content.Context;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ExpandableListView;
import android.widget.SimpleExpandableListAdapter;
/**
* The actual list of synced tabs. This serves as the only child view of {@link RemoteTabsContainer}
* so it can be refreshed using a swipe-to-refresh gesture.
@ -30,9 +30,9 @@ class RemoteTabsList extends ExpandableListView
implements ExpandableListView.OnGroupClickListener,
ExpandableListView.OnChildClickListener,
TabsAccessor.OnQueryTabsCompleteListener {
private static final String[] CLIENT_KEY = new String[] { "name" };
private static final String[] CLIENT_KEY = new String[] { "name", "last_synced" };
private static final String[] TAB_KEY = new String[] { "title", "url" };
private static final int[] CLIENT_RESOURCE = new int[] { R.id.client };
private static final int[] CLIENT_RESOURCE = new int[] { R.id.client, R.id.last_synced };
private static final int[] TAB_RESOURCE = new int[] { R.id.tab, R.id.url };
private final Context context;
@ -92,10 +92,13 @@ class RemoteTabsList extends ExpandableListView
HashMap <String, String> client;
HashMap <String, String> tab;
final long now = System.currentTimeMillis();
for (TabsAccessor.RemoteTab remoteTab : remoteTabs) {
if (oldGuid == null || !TextUtils.equals(oldGuid, remoteTab.guid)) {
client = new HashMap <String, String>();
client.put("name", remoteTab.name);
client.put("last_synced", getLastSyncedString(now, remoteTab.lastModified));
clients.add(client);
tabsForClient = new ArrayList <HashMap <String, String>>();
@ -124,4 +127,16 @@ class RemoteTabsList extends ExpandableListView
expandGroup(i);
}
}
/**
* Return a relative "Last synced" time span for the given tab record.
*
* @param now local time.
* @param time to format string for.
* @return string describing time span
*/
protected String getLastSyncedString(long now, long time) {
CharSequence relativeTimeSpanString = DateUtils.getRelativeTimeSpanString(time, now, DateUtils.MINUTE_IN_MILLIS);
return getResources().getString(R.string.remote_tabs_last_synced, relativeTimeSpanString);
}
}