Merge change 6187 into donut

* changes:
  Fix strings.
This commit is contained in:
Android (Google) Code Review
2009-07-03 09:44:29 -07:00
2 changed files with 12 additions and 15 deletions

View File

@@ -3,9 +3,8 @@
<!-- Title for the VPN Services activity. --> <!-- Title for the VPN Services activity. -->
<string name="app_label">VPN Services</string> <string name="app_label">VPN Services</string>
<string name="vpn_notification_title">%s VPN %s</string> <string name="vpn_notification_title_connected">%s VPN connected</string>
<string name="vpn_notification_connected">connected</string> <string name="vpn_notification_title_disconnected">%s VPN disconnected</string>
<string name="vpn_notification_disconnected">disconnected</string> <string name="vpn_notification_hint_disconnected">Touch to reconnect to a VPN.</string>
<string name="vpn_notification_connected_message">Up time: %s</string>
</resources> </resources>

View File

@@ -490,16 +490,15 @@ abstract class VpnService<E extends VpnProfile> {
} }
private String getNotificationTitle(boolean connected) { private String getNotificationTitle(boolean connected) {
String connectedOrNot = connected String formatString = connected
? mContext.getString(R.string.vpn_notification_connected) ? mContext.getString(
R.string.vpn_notification_title_connected)
: mContext.getString( : mContext.getString(
R.string.vpn_notification_disconnected); R.string.vpn_notification_title_disconnected);
return String.format( return String.format(formatString, mProfile.getName());
mContext.getString(R.string.vpn_notification_title),
mProfile.getName(), connectedOrNot);
} }
private String getTimeFormat(long duration) { private String getFormattedTime(long duration) {
long hours = duration / 3600; long hours = duration / 3600;
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (hours > 0) sb.append(hours).append(':'); if (hours > 0) sb.append(hours).append(':');
@@ -511,11 +510,10 @@ abstract class VpnService<E extends VpnProfile> {
private String getNotificationMessage(boolean connected) { private String getNotificationMessage(boolean connected) {
if (connected) { if (connected) {
long time = (System.currentTimeMillis() - mStartTime) / 1000; long time = (System.currentTimeMillis() - mStartTime) / 1000;
return String.format(mContext.getString( return getFormattedTime(time);
R.string.vpn_notification_connected_message),
getTimeFormat(time));
} else { } else {
return ""; return mContext.getString(
R.string.vpn_notification_hint_disconnected);
} }
} }
} }