From 6947c502380e974084b172c1d88af1dd383be3b1 Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 15 Aug 2012 07:22:10 -0700 Subject: [PATCH] pass lang instead of lang code; include app name in notification text --- .../android/XWords4/res/values/strings.xml | 8 ++--- .../src/org/eehouse/android/xw4/NetUtils.java | 12 ++++--- xwords4/android/scripts/info.py | 33 +++---------------- 3 files changed, 15 insertions(+), 38 deletions(-) diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml index 7152b496b..6d39bf2bf 100644 --- a/xwords4/android/XWords4/res/values/strings.xml +++ b/xwords4/android/XWords4/res/values/strings.xml @@ -1997,9 +1997,9 @@ Check for updates - New Wordlist available - %s has been updated - New app available - Click to download + New wordlist available + Tap to update %s + New version of %s + Tap to download diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetUtils.java index ca6ed962a..1e84ea322 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetUtils.java @@ -22,6 +22,7 @@ package org.eehouse.android.xw4; import android.content.Context; import android.content.Intent; +import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.net.Uri; import java.io.ByteArrayOutputStream; @@ -320,12 +321,11 @@ public class NetUtils { String sum ) { int lang = DictLangCache.getDictLangCode( context, dal ); + String langStr = DictLangCache.getLangName( context, lang ); HttpPost post = makePost( "dictVersion" ); List nvp = new ArrayList(); nvp.add( new BasicNameValuePair( "name", dal.name ) ); - nvp.add( new BasicNameValuePair( "lang", - String.format( "%d", - lang ) ) ); + nvp.add( new BasicNameValuePair( "lang", langStr ) ); nvp.add( new BasicNameValuePair( "md5sum", sum ) ); return runPost( post, nvp ); } @@ -351,10 +351,12 @@ public class NetUtils { versionCode ) ) ); String url = runPost( post, nvp ); if ( null != url ) { + ApplicationInfo ai = pm.getApplicationInfo( packageName, 0); + String label = pm.getApplicationLabel( ai ).toString(); Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse(url) ); - String title = Utils.format( context, R.string.new_app_availf, - packageName ); + String title = + Utils.format( context, R.string.new_app_availf, label ); String body = context.getString( R.string.new_app_avail ); Utils.postNotification( context, intent, title, body, url.hashCode() ); diff --git a/xwords4/android/scripts/info.py b/xwords4/android/scripts/info.py index 6e5dc2905..1bd53a0fd 100755 --- a/xwords4/android/scripts/info.py +++ b/xwords4/android/scripts/info.py @@ -68,45 +68,20 @@ def curVersion( req, name, version ): logging.debug( 'Error: bad name ' + name ) return result -# Order determined by language_names in -# android/XWords4/res/values/common_rsrc.xml -def langStr( lang ): - langs = ( '' - ,'English' - ,'French' - ,'German' - ,'Turkish' - ,'Arabic' - ,'Spanish' - ,'Swedish' - ,'Polish' - ,'Danish' - ,'Italian' - ,'Dutch' - ,'Catalan' - ,'Portuguese' - ,'' - ,'Russian' - ,'' - ,'Czech' - ,'Greek' - ,'Slovak' ) - return langs[int(lang)] - # public def dictVersion( req, name, lang, md5sum ): result = '' if not name.endswith(k_suffix): name += k_suffix dictSums = getDictSums() - path = langStr(lang) + "/" + name + path = lang + "/" + name if not path in dictSums: sum = md5Checksum( dictSums, path ) if sum: dictSums[path] = sum s_shelf['sums'] = dictSums - if path in dictSums and dictSums[path] != md5sum: - logging.debug( dictSums[path] + " vs " + md5sum ) - result = k_urlbase + "and_wordlists/" + path + if path in dictSums: + if dictSums[path] != md5sum: + result = k_urlbase + "and_wordlists/" + path else: logging.debug( path + " not known" ) s_shelf.close()