mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-07 05:24:46 +01:00
make FirstRunDialog a DialogFragment
It was disappearing when the device rotated. Using the same XWDialogFragment mechanism as everything else fixes that.
This commit is contained in:
parent
b6665a15c4
commit
7164ab92f6
3 changed files with 38 additions and 23 deletions
|
@ -19,6 +19,7 @@
|
|||
|
||||
package org.eehouse.android.xw4;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
|
@ -47,8 +48,8 @@ public class AboutAlert extends XWDialogFragment {
|
|||
@Override
|
||||
public Dialog onCreateDialog( Bundle sis )
|
||||
{
|
||||
final Context context = getActivity();
|
||||
final View view = LocUtils.inflate( context, R.layout.about_dlg );
|
||||
Context context = getActivity();
|
||||
View view = LocUtils.inflate( context, R.layout.about_dlg );
|
||||
TextView vers = (TextView)view.findViewById( R.id.version_string );
|
||||
|
||||
DateFormat df = DateFormat.getDateTimeInstance( DateFormat.FULL,
|
||||
|
@ -67,21 +68,23 @@ public class AboutAlert extends XWDialogFragment {
|
|||
xlator.setVisibility( View.GONE );
|
||||
}
|
||||
|
||||
return LocUtils.makeAlertBuilder( context )
|
||||
AlertDialog.Builder builder = LocUtils.makeAlertBuilder( context )
|
||||
.setIcon( R.drawable.icon48x48 )
|
||||
.setTitle( R.string.app_name )
|
||||
.setView( view )
|
||||
.setNegativeButton( R.string.changes_button,
|
||||
new OnClickListener() {
|
||||
@Override
|
||||
public void onClick( DialogInterface dlg,
|
||||
int which )
|
||||
{
|
||||
FirstRunDialog.show( context );
|
||||
}
|
||||
} )
|
||||
.setPositiveButton( android.R.string.ok, null )
|
||||
.create();
|
||||
.setPositiveButton( android.R.string.ok, null );
|
||||
|
||||
if ( context instanceof XWActivity ) {
|
||||
final XWActivity activity = (XWActivity)context;
|
||||
builder.setNegativeButton( R.string.changes_button, new OnClickListener() {
|
||||
@Override
|
||||
public void onClick( DialogInterface dlg, int which ) {
|
||||
activity.show( FirstRunDialog.newInstance() );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,8 +20,9 @@
|
|||
|
||||
package org.eehouse.android.xw4;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
|
||||
|
@ -31,14 +32,23 @@ import org.eehouse.android.xw4.loc.LocUtils;
|
|||
* similar feature in OpenSudoku, to whose author "Thanks".
|
||||
*/
|
||||
|
||||
public class FirstRunDialog {
|
||||
public static void show( final Context context )
|
||||
public class FirstRunDialog extends XWDialogFragment {
|
||||
private static final String TAG = FirstRunDialog.class.getSimpleName();
|
||||
|
||||
public static FirstRunDialog newInstance()
|
||||
{
|
||||
final boolean showSurvey = !Utils.onFirstVersion( context );
|
||||
return new FirstRunDialog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog( Bundle sis )
|
||||
{
|
||||
final Context context = getActivity();
|
||||
// boolean showSurvey = !Utils.onFirstVersion( context );
|
||||
|
||||
// This won't support e.g mailto refs. Probably want to
|
||||
// launch the browser with an intent eventually.
|
||||
final WebView view = new WebView( context );
|
||||
WebView view = new WebView( context );
|
||||
view.setWebViewClient( new WebViewClient() {
|
||||
private boolean m_loaded = false;
|
||||
@Override
|
||||
|
@ -65,12 +75,14 @@ public class FirstRunDialog {
|
|||
view.getSettings().setJavaScriptEnabled( true ); // for surveymonkey
|
||||
view.loadUrl("file:///android_asset/changes.html");
|
||||
|
||||
LocUtils.makeAlertBuilder( context )
|
||||
return LocUtils.makeAlertBuilder( context )
|
||||
.setIcon(android.R.drawable.ic_menu_info_details)
|
||||
.setTitle( R.string.changes_title )
|
||||
.setView( view )
|
||||
.setPositiveButton( android.R.string.ok, null)
|
||||
.create()
|
||||
.show();
|
||||
.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getFragTag() { return TAG; }
|
||||
}
|
||||
|
|
|
@ -946,7 +946,7 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
if ( isUpgrade ) {
|
||||
if ( !s_firstShown ) {
|
||||
if ( LocUtils.getCurLangCode( m_activity ).equals( "en" ) ) {
|
||||
FirstRunDialog.show( m_activity );
|
||||
show( FirstRunDialog.newInstance() );
|
||||
}
|
||||
s_firstShown = true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue