diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java index dde0bc5c2..58a024309 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java @@ -77,7 +77,6 @@ public class GamesList extends XWExpandableListActivity private static final int[] DEBUG_ITEMS = { // R.id.games_menu_loaddb, R.id.games_menu_storedb, - R.id.games_menu_checkupdates, }; private static final int[] NOSEL_ITEMS = { R.id.games_menu_newgroup, @@ -658,6 +657,10 @@ public class GamesList extends XWExpandableListActivity showItemsIf( ONEGAME_ITEMS, menu, 1 == nGamesSelected ); showItemsIf( ONEGROUP_ITEMS, menu, 1 == nGroupsSelected ); + boolean enable = showDbg && nothingSelected + && UpdateCheckReceiver.haveToCheck( this ); + Utils.setItemVisible( menu, R.id.games_menu_checkupdates, enable ); + int selGroupPos = -1; if ( 1 == nGroupsSelected ) { long id = m_selGroupIDs.iterator().next(); @@ -677,7 +680,7 @@ public class GamesList extends XWExpandableListActivity // selected Utils.setItemVisible( menu, R.id.games_group_moveup, 0 < selGroupPos ); - boolean enable = 0 <= selGroupPos + enable = 0 <= selGroupPos && (selGroupPos + 1) < m_adapter.getGroupCount(); Utils.setItemVisible( menu, R.id.games_group_movedown, enable ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/UpdateCheckReceiver.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/UpdateCheckReceiver.java index fd8c19a0a..f99922ed9 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/UpdateCheckReceiver.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/UpdateCheckReceiver.java @@ -103,6 +103,16 @@ public class UpdateCheckReceiver extends BroadcastReceiver { interval_millis, pi ); } + // Is app upgradeable OR have we installed any dicts? + public static boolean haveToCheck( Context context ) + { + boolean result = !Utils.isGooglePlayApp( context ); + if ( !result ) { // give another chance + result = null != getDownloadedDicts( context ); + } + return result; + } + public static void checkVersions( Context context, boolean fromUI ) { JSONObject params = new JSONObject(); @@ -134,18 +144,12 @@ public class UpdateCheckReceiver extends BroadcastReceiver { DbgUtils.loge( jse ); } } - JSONArray dictParams = new JSONArray(); - DictUtils.DictAndLoc[] dals = DictUtils.dictList( context ); - for ( int ii = 0; ii < dals.length; ++ii ) { - DictUtils.DictAndLoc dal = dals[ii]; - switch ( dal.loc ) { - // case DOWNLOAD: - case EXTERNAL: - case INTERNAL: - dictParams.put( makeDictParams( context, dal, ii ) ); + DictUtils.DictAndLoc[] dals = getDownloadedDicts( context ); + if ( null != dals ) { + JSONArray dictParams = new JSONArray(); + for ( int ii = 0; ii < dals.length; ++ii ) { + dictParams.put( makeDictParams( context, dals[ii], ii ) ); } - } - if ( 0 < dictParams.length() ) { try { params.put( k_DICTS, dictParams ); params.put( k_DEVID, XWPrefs.getDevID( context ) ); @@ -160,6 +164,30 @@ public class UpdateCheckReceiver extends BroadcastReceiver { } } + private static DictUtils.DictAndLoc[] getDownloadedDicts( Context context ) + { + DictUtils.DictAndLoc[] result = null; + DictUtils.DictAndLoc[] dals = DictUtils.dictList( context ); + DictUtils.DictAndLoc[] tmp = new DictUtils.DictAndLoc[dals.length]; + int indx = 0; + for ( int ii = 0; ii < dals.length; ++ii ) { + DictUtils.DictAndLoc dal = dals[ii]; + switch ( dal.loc ) { + // case DOWNLOAD: + case EXTERNAL: + case INTERNAL: + tmp[indx++] = dal; + break; + } + } + + if ( 0 < indx ) { + result = new DictUtils.DictAndLoc[indx]; + System.arraycopy( tmp, 0, result, 0, indx ); + } + return result; + } + private static HttpPost makePost( Context context, String proc ) { String url = String.format( "%s/%s",