only show the survey invitation when this isn't the first version

you've installed, i.e. after at least one upgrade.
This commit is contained in:
Eric House 2014-08-18 07:12:50 -07:00
parent ad7a32504a
commit f374d67aab
5 changed files with 91 additions and 60 deletions

View file

@ -1,46 +1,49 @@
<html>
<head>
<style type="text/css">
body {font-size: smaller;}
</style>
</head>
<head>
<script>
showSurvey = function() {
var div = document.getElementById('survey');
div.style.display = 'inline';
};
</script>
<style type="text/css">
body {font-size: smaller;}
#survey { display: none;
}
h2,h3 { text-align: center; }
</style>
</head>
<body>
<b>Crosswords 4.4 beta 87 release</b>
<h2>Crosswords 4.4 beta 88 release</h2>
<p>Please
consider <a href="https://www.surveymonkey.com/s/GX3XLHR">taking this
survey</a> to help me improve Crosswords.</p>
<div id="survey">
<p>Please <a href="https://www.surveymonkey.com/s/GX3XLHR">take
this survey</a> to help determine what gets done next in
Crosswords.</p>
</div>
<h3>New with this (and prev.) releases</h3>
<ul>
<li>Don't prevent board displaying in the landscape orientation on
large and x-large devices (tablets)</li>
<li>Fix changes for above to not crash on small-screened phones
(thanks Anonymous)</li>
<li>Fix changes for above so Nexus 10 and other x-large devices
still use the full screen in the portrait orientation (thanks DS)</li>
<li>Fix reported crash in new toolbar code (thanks Anonymous)</li>
<li>Fix reported crash receiving malformed SMS (thanks Anonymous)</li>
</ul>
<h3>New with this release</h3>
<ul>
<li>Post reminder notifications when it&apos;s been your turn for
one, two or three days.</li>
</ul>
<p>(The full changelog
is <a href="http://xwords.sf.net/and_changes.php">here</a>.)</p>
<p>(The full changelog
is <a href="http://xwords.sf.net/and_changes.php">here</a>.)</p>
<h3>Next up</h3>
<ul>
<li>Side-by-side display (e.g. games list and a game open at the
same time) for tablets in landscape mode</li>
<li>Look, again, at play via Bluetooth now that HTC phones aren't quite so common</li>
<li>Fix SMS play for KitKat</li>
<li>Offer "Rematch" when game's over</li>
</ul>
<h3>Next up</h3>
<ul>
<li>Look, again, at play via Bluetooth now that HTC phones aren&apos;t quite so common</li>
<li>Fix SMS play for KitKat</li>
<li>Offer &quot;Rematch&quot; when game&apos;s over</li>
</ul>
<p>This is beta software. Please let me know (at eehouse@eehouse.org)
what's broken and what features you'd most like to see. And if you
do get a crash, please let your phone report it to Google so I can
see it!</p>
<p>This is beta software. Please let me know (email
eehouse@eehouse.org) what&apos;s broken and what features you&apos;d
most like to see. And if you do get a crash, please let your phone
report it to Google so I can see it!</p>
<p>Thanks!<br>--Eric</p>
<p>Thanks!<br>--Eric</p>
</body>
</html>

View file

@ -458,7 +458,10 @@ public class DlgDelegate {
public void onClick( DialogInterface dlg,
int which )
{
FirstRunDialog.show( m_activity );
boolean firstVersion =
Utils.onFirstVersion( m_activity );
FirstRunDialog.show( m_activity,
!firstVersion );
}
} )
.setPositiveButton( R.string.button_ok, null )

View file

@ -36,12 +36,13 @@ import org.eehouse.android.xw4.loc.LocUtils;
*/
public class FirstRunDialog {
public static void show( final Context context )
public static void show( final Context context, final boolean isUpgrade )
{
// This won't support e.g mailto refs. Probably want to
// launch the browser with an intent eventually.
WebView view = new WebView( context );
final WebView view = new WebView( context );
view.setWebViewClient( new WebViewClient() {
private boolean m_loaded = false;
@Override
public boolean shouldOverrideUrlLoading( WebView view,
String url ) {
@ -52,6 +53,16 @@ public class FirstRunDialog {
}
return result;
}
@Override
public void onPageFinished(WebView view, String url)
{
if ( !m_loaded ) {
m_loaded = true;
if ( isUpgrade ) {
view.loadUrl( "javascript:showSurvey();" );
}
}
}
});
view.getSettings().setJavaScriptEnabled( true ); // for surveymonkey
view.loadUrl("file:///android_asset/changes.html");

View file

@ -765,7 +765,7 @@ public class GamesListDelegate extends ListDelegateBase
boolean isUpgrade = Utils.firstBootThisVersion( m_activity );
if ( isUpgrade && !s_firstShown ) {
FirstRunDialog.show( m_activity );
FirstRunDialog.show( m_activity, isUpgrade );
s_firstShown = true;
}

View file

@ -63,9 +63,11 @@ public class Utils {
private static final String DB_PATH = "XW_GAMES";
private static final String HIDDEN_PREFS = "xwprefs_hidden";
private static final String FIRST_VERSION_KEY = "FIRST_VERSION_KEY";
private static final String SHOWN_VERSION_KEY = "SHOWN_VERSION_KEY";
private static Boolean s_isFirstBootThisVersion = null;
private static Boolean s_firstVersion = null;
private static Boolean s_deviceSupportSMS = null;
private static Boolean s_isFirstBootEver = null;
private static Integer s_appVersion = null;
@ -81,19 +83,21 @@ public class Utils {
return s_random.nextInt();
}
public static boolean onFirstVersion( Context context )
{
setFirstBootStatics( context );
return s_firstVersion;
}
public static boolean firstBootEver( Context context )
{
if ( null == s_isFirstBootEver ) {
setFirstBootStatics( context );
}
setFirstBootStatics( context );
return s_isFirstBootEver;
}
public static boolean firstBootThisVersion( Context context )
{
if ( null == s_isFirstBootThisVersion ) {
setFirstBootStatics( context );
}
setFirstBootStatics( context );
return s_isFirstBootThisVersion;
}
@ -508,24 +512,34 @@ public class Utils {
private static void setFirstBootStatics( Context context )
{
int thisVersion = getAppVersion( context );
int prevVersion = 0;
if ( null == s_isFirstBootThisVersion ) {
int thisVersion = getAppVersion( context );
int prevVersion = 0;
SharedPreferences prefs =
context.getSharedPreferences( HIDDEN_PREFS,
Context.MODE_PRIVATE );
SharedPreferences prefs = null;
if ( 0 < thisVersion ) {
prefs = context.getSharedPreferences( HIDDEN_PREFS,
Context.MODE_PRIVATE );
prevVersion = prefs.getInt( SHOWN_VERSION_KEY, -1 );
}
boolean newVersion = prevVersion != thisVersion;
if ( 0 < thisVersion ) {
prefs = context.getSharedPreferences( HIDDEN_PREFS,
Context.MODE_PRIVATE );
prevVersion = prefs.getInt( SHOWN_VERSION_KEY, -1 );
}
boolean newVersion = prevVersion != thisVersion;
s_isFirstBootThisVersion = new Boolean( newVersion );
s_isFirstBootEver = new Boolean( -1 == prevVersion );
s_isFirstBootThisVersion = new Boolean( newVersion );
s_isFirstBootEver = new Boolean( -1 == prevVersion );
if ( newVersion ) {
prefs.edit()
.putInt( SHOWN_VERSION_KEY, thisVersion )
.commit();
int firstVersion = prefs.getInt( FIRST_VERSION_KEY, thisVersion );
s_firstVersion = new Boolean( firstVersion == thisVersion );
if ( newVersion || s_firstVersion ) {
SharedPreferences.Editor editor = prefs.edit()
.putInt( SHOWN_VERSION_KEY, thisVersion );
if ( 0 == firstVersion ) {
editor.putInt( FIRST_VERSION_KEY, thisVersion );
}
editor.commit();
}
}
}