mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-23 07:27:22 +01:00
don't make unsolicited upgrade offer more than once
Debug build checks for upgrades every hour, and when I don't want one it's annoying to keep dismissing notifications. Should have no impact on release builds.
This commit is contained in:
parent
ba5a141b3f
commit
3b51eb0629
1 changed files with 43 additions and 24 deletions
|
@ -51,6 +51,7 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
|
||||||
private static final long INTERVAL_ONEHOUR = 1000 * 60 * 60;
|
private static final long INTERVAL_ONEHOUR = 1000 * 60 * 60;
|
||||||
private static final long INTERVAL_ONEDAY = INTERVAL_ONEHOUR * 24;
|
private static final long INTERVAL_ONEDAY = INTERVAL_ONEHOUR * 24;
|
||||||
private static final long INTERVAL_NDAYS = 1;
|
private static final long INTERVAL_NDAYS = 1;
|
||||||
|
private static final String KEY_PREV_URL = "PREV_URL";
|
||||||
|
|
||||||
// constants that are also used in info.py
|
// constants that are also used in info.py
|
||||||
private static final String k_NAME = "name";
|
private static final String k_NAME = "name";
|
||||||
|
@ -290,12 +291,12 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
|
||||||
if ( LOG_QUERIES ) {
|
if ( LOG_QUERIES ) {
|
||||||
Log.d( TAG, "onPostExecute(): received: %s", json );
|
Log.d( TAG, "onPostExecute(): received: %s", json );
|
||||||
}
|
}
|
||||||
makeNotificationsIf( json, m_params );
|
makeNotificationsIf( json );
|
||||||
XWPrefs.setHaveCheckedUpgrades( m_context, true );
|
XWPrefs.setHaveCheckedUpgrades( m_context, true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void makeNotificationsIf( String jstr, JSONObject params )
|
private void makeNotificationsIf( String jstr )
|
||||||
{
|
{
|
||||||
boolean gotOne = false;
|
boolean gotOne = false;
|
||||||
try {
|
try {
|
||||||
|
@ -324,8 +325,25 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
|
||||||
useBrowser = !Utils.canInstall( m_context, tmp );
|
useBrowser = !Utils.canInstall( m_context, tmp );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String urlParm = app.getString( k_URL );
|
||||||
|
|
||||||
|
// Debug builds check frequently on a timer and
|
||||||
|
// when it's something we don't want it's annoying
|
||||||
|
// to get a lot of offers. So track the URL used,
|
||||||
|
// and only offer once per URL unless the request
|
||||||
|
// was manual.
|
||||||
|
boolean skipIt = false;
|
||||||
|
if ( BuildConfig.NON_RELEASE && !m_fromUI ) {
|
||||||
|
String prevURL = DBUtils.getStringFor( m_context, KEY_PREV_URL );
|
||||||
|
if ( urlParm.equals( prevURL ) ) {
|
||||||
|
skipIt = true;
|
||||||
|
} else {
|
||||||
|
DBUtils.setStringFor( m_context, KEY_PREV_URL, urlParm );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( !skipIt ) {
|
||||||
|
String url = NetUtils.ensureHttps( urlParm );
|
||||||
Intent intent;
|
Intent intent;
|
||||||
String url = NetUtils.ensureHttps( app.getString( k_URL ) );
|
|
||||||
if ( useBrowser ) {
|
if ( useBrowser ) {
|
||||||
intent = new Intent( Intent.ACTION_VIEW,
|
intent = new Intent( Intent.ACTION_VIEW,
|
||||||
Uri.parse(url) );
|
Uri.parse(url) );
|
||||||
|
@ -350,6 +368,7 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
|
||||||
gotOne = true;
|
gotOne = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// dictionaries upgrade
|
// dictionaries upgrade
|
||||||
if ( jobj.has( k_DICTS ) ) {
|
if ( jobj.has( k_DICTS ) ) {
|
||||||
|
@ -382,7 +401,7 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
|
||||||
}
|
}
|
||||||
} catch ( org.json.JSONException jse ) {
|
} catch ( org.json.JSONException jse ) {
|
||||||
Log.ex( TAG, jse );
|
Log.ex( TAG, jse );
|
||||||
Log.w( TAG, "sent: \"%s\"", params.toString() );
|
Log.w( TAG, "sent: \"%s\"", m_params.toString() );
|
||||||
Log.w( TAG, "received: \"%s\"", jstr );
|
Log.w( TAG, "received: \"%s\"", jstr );
|
||||||
} catch ( PackageManager.NameNotFoundException nnfe ) {
|
} catch ( PackageManager.NameNotFoundException nnfe ) {
|
||||||
Log.ex( TAG, nnfe );
|
Log.ex( TAG, nnfe );
|
||||||
|
|
Loading…
Add table
Reference in a new issue