Commit d08c144c authored by newt's avatar newt Committed by Commit bot

Show last updated time in About Chrome for non-official builds.

BUG=454037

Review URL: https://codereview.chromium.org/878523005

Cr-Commit-Position: refs/heads/master@{#314249}
parent a6afbb6a
...@@ -4,12 +4,17 @@ ...@@ -4,12 +4,17 @@
package org.chromium.chrome.browser.preferences; package org.chromium.chrome.browser.preferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle; import android.os.Bundle;
import android.preference.Preference; import android.preference.Preference;
import android.preference.PreferenceFragment; import android.preference.PreferenceFragment;
import android.text.format.DateUtils;
import android.view.ContextThemeWrapper; import android.view.ContextThemeWrapper;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeVersionInfo;
import org.chromium.chrome.browser.preferences.PrefServiceBridge.AboutVersionStrings;
import org.chromium.chrome.browser.preferences.PrefServiceBridge.ProfilePathCallback; import org.chromium.chrome.browser.preferences.PrefServiceBridge.ProfilePathCallback;
import org.chromium.chrome.browser.util.FeatureUtilities; import org.chromium.chrome.browser.util.FeatureUtilities;
...@@ -46,10 +51,9 @@ public class AboutChromePreferences extends PreferenceFragment implements ...@@ -46,10 +51,9 @@ public class AboutChromePreferences extends PreferenceFragment implements
} }
PrefServiceBridge prefServiceBridge = PrefServiceBridge.getInstance(); PrefServiceBridge prefServiceBridge = PrefServiceBridge.getInstance();
PrefServiceBridge.AboutVersionStrings versionStrings = AboutVersionStrings versionStrings = prefServiceBridge.getAboutVersionStrings();
prefServiceBridge.getAboutVersionStrings();
Preference p = findPreference(PREF_APPLICATION_VERSION); Preference p = findPreference(PREF_APPLICATION_VERSION);
p.setSummary(versionStrings.getApplicationVersion()); p.setSummary(getApplicationVersion(versionStrings.getApplicationVersion()));
p = findPreference(PREF_OS_VERSION); p = findPreference(PREF_OS_VERSION);
p.setSummary(versionStrings.getOSVersion()); p.setSummary(versionStrings.getOSVersion());
p = findPreference(PREF_WEBKIT_VERSION); p = findPreference(PREF_WEBKIT_VERSION);
...@@ -65,6 +69,25 @@ public class AboutChromePreferences extends PreferenceFragment implements ...@@ -65,6 +69,25 @@ public class AboutChromePreferences extends PreferenceFragment implements
prefServiceBridge.getProfilePath(this); prefServiceBridge.getProfilePath(this);
} }
private String getApplicationVersion(String version) {
if (ChromeVersionInfo.isOfficialBuild()) {
return version;
}
// For developer builds, show how recently the app was installed/updated.
PackageInfo info;
try {
info = getActivity().getPackageManager().getPackageInfo(
getActivity().getPackageName(), 0);
} catch (NameNotFoundException e) {
return version;
}
CharSequence updateTimeString = DateUtils.getRelativeTimeSpanString(
info.lastUpdateTime, System.currentTimeMillis(), 0);
return getActivity().getString(R.string.version_with_update_time, version,
updateTimeString);
}
@Override @Override
public void onGotProfilePath(String profilePath) { public void onGotProfilePath(String profilePath) {
Preference pref = findPreference(PREF_PROFILE_PATH); Preference pref = findPreference(PREF_PROFILE_PATH);
......
...@@ -450,6 +450,9 @@ To obtain new licenses, connect to the internet and play your downloaded content ...@@ -450,6 +450,9 @@ To obtain new licenses, connect to the internet and play your downloaded content
<message name="IDS_APPLICATION_VERSION_TITLE" desc="Title for application version"> <message name="IDS_APPLICATION_VERSION_TITLE" desc="Title for application version">
Application version Application version
</message> </message>
<message name="IDS_VERSION_WITH_UPDATE_TIME" desc="Message showing Chrome's version and the time it was last updated">
<ph name="VERSION">%1$s<ex>Chrome 40.0.2214.67</ex></ph> (Updated <ph name="TIME_SINCE_UPDATE">%2$s<ex>5 minutes ago</ex></ph>)
</message>
<message name="IDS_OS_VERSION_TITLE" desc="Title for operating system version"> <message name="IDS_OS_VERSION_TITLE" desc="Title for operating system version">
Operating system Operating system
</message> </message>
......
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