mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-04 23:02:02 +01:00
don't show check-for-updates menuitem unless we can update something: we're not installed from the Play store OR we've installed at least one wordlist.
This commit is contained in:
parent
b4df0125cc
commit
6256e2a843
2 changed files with 44 additions and 13 deletions
|
@ -77,7 +77,6 @@ public class GamesList extends XWExpandableListActivity
|
||||||
private static final int[] DEBUG_ITEMS = {
|
private static final int[] DEBUG_ITEMS = {
|
||||||
// R.id.games_menu_loaddb,
|
// R.id.games_menu_loaddb,
|
||||||
R.id.games_menu_storedb,
|
R.id.games_menu_storedb,
|
||||||
R.id.games_menu_checkupdates,
|
|
||||||
};
|
};
|
||||||
private static final int[] NOSEL_ITEMS = {
|
private static final int[] NOSEL_ITEMS = {
|
||||||
R.id.games_menu_newgroup,
|
R.id.games_menu_newgroup,
|
||||||
|
@ -658,6 +657,10 @@ public class GamesList extends XWExpandableListActivity
|
||||||
showItemsIf( ONEGAME_ITEMS, menu, 1 == nGamesSelected );
|
showItemsIf( ONEGAME_ITEMS, menu, 1 == nGamesSelected );
|
||||||
showItemsIf( ONEGROUP_ITEMS, menu, 1 == nGroupsSelected );
|
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;
|
int selGroupPos = -1;
|
||||||
if ( 1 == nGroupsSelected ) {
|
if ( 1 == nGroupsSelected ) {
|
||||||
long id = m_selGroupIDs.iterator().next();
|
long id = m_selGroupIDs.iterator().next();
|
||||||
|
@ -677,7 +680,7 @@ public class GamesList extends XWExpandableListActivity
|
||||||
// selected
|
// selected
|
||||||
Utils.setItemVisible( menu, R.id.games_group_moveup,
|
Utils.setItemVisible( menu, R.id.games_group_moveup,
|
||||||
0 < selGroupPos );
|
0 < selGroupPos );
|
||||||
boolean enable = 0 <= selGroupPos
|
enable = 0 <= selGroupPos
|
||||||
&& (selGroupPos + 1) < m_adapter.getGroupCount();
|
&& (selGroupPos + 1) < m_adapter.getGroupCount();
|
||||||
Utils.setItemVisible( menu, R.id.games_group_movedown, enable );
|
Utils.setItemVisible( menu, R.id.games_group_movedown, enable );
|
||||||
|
|
||||||
|
|
|
@ -103,6 +103,16 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
|
||||||
interval_millis, pi );
|
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 )
|
public static void checkVersions( Context context, boolean fromUI )
|
||||||
{
|
{
|
||||||
JSONObject params = new JSONObject();
|
JSONObject params = new JSONObject();
|
||||||
|
@ -134,18 +144,12 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
|
||||||
DbgUtils.loge( jse );
|
DbgUtils.loge( jse );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
JSONArray dictParams = new JSONArray();
|
DictUtils.DictAndLoc[] dals = getDownloadedDicts( context );
|
||||||
DictUtils.DictAndLoc[] dals = DictUtils.dictList( context );
|
if ( null != dals ) {
|
||||||
for ( int ii = 0; ii < dals.length; ++ii ) {
|
JSONArray dictParams = new JSONArray();
|
||||||
DictUtils.DictAndLoc dal = dals[ii];
|
for ( int ii = 0; ii < dals.length; ++ii ) {
|
||||||
switch ( dal.loc ) {
|
dictParams.put( makeDictParams( context, dals[ii], ii ) );
|
||||||
// case DOWNLOAD:
|
|
||||||
case EXTERNAL:
|
|
||||||
case INTERNAL:
|
|
||||||
dictParams.put( makeDictParams( context, dal, ii ) );
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if ( 0 < dictParams.length() ) {
|
|
||||||
try {
|
try {
|
||||||
params.put( k_DICTS, dictParams );
|
params.put( k_DICTS, dictParams );
|
||||||
params.put( k_DEVID, XWPrefs.getDevID( context ) );
|
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 )
|
private static HttpPost makePost( Context context, String proc )
|
||||||
{
|
{
|
||||||
String url = String.format( "%s/%s",
|
String url = String.format( "%s/%s",
|
||||||
|
|
Loading…
Reference in a new issue