mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-04 20:46:28 +01:00
convert About alert to DialogFragment
As a first experiment. Untested on non-dualpane and on older OS versions.
This commit is contained in:
parent
121c35b728
commit
0e23c191b5
5 changed files with 22 additions and 58 deletions
|
@ -22,13 +22,14 @@ package org.eehouse.android.xw4;
|
|||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.content.DialogInterface.OnCancelListener;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
|
@ -421,6 +422,15 @@ public class DelegateBase implements DlgClickNotify,
|
|||
m_dlgDelegate.showDialog( dlgID );
|
||||
}
|
||||
|
||||
protected void show( DialogFragment df )
|
||||
{
|
||||
if ( m_activity instanceof MainActivity ) {
|
||||
((MainActivity)m_activity).show( df );
|
||||
} else {
|
||||
Assert.assertTrue( !BuildConfig.DEBUG );
|
||||
}
|
||||
}
|
||||
|
||||
protected void removeDialog( DlgID dlgID )
|
||||
{
|
||||
removeDialog( dlgID.ordinal() );
|
||||
|
@ -482,12 +492,6 @@ public class DelegateBase implements DlgClickNotify,
|
|||
return m_dlgDelegate.makeNotAgainBuilder( msgId, key );
|
||||
}
|
||||
|
||||
// It sucks that these must be duplicated here and XWActivity
|
||||
protected void showAboutDialog()
|
||||
{
|
||||
m_dlgDelegate.showAboutDialog();
|
||||
}
|
||||
|
||||
public ConfirmThenBuilder makeConfirmThenBuilder( String msg, Action action ) {
|
||||
return m_dlgDelegate.makeConfirmThenBuilder( msg, action );
|
||||
}
|
||||
|
|
|
@ -23,16 +23,17 @@ package org.eehouse.android.xw4;
|
|||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnCancelListener;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemSelectedListener;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Button;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
@ -387,9 +388,6 @@ public class DlgDelegate {
|
|||
case LOOKUP:
|
||||
dialog = createLookupDialog();
|
||||
break;
|
||||
case DIALOG_ABOUT:
|
||||
dialog = createAboutDialog();
|
||||
break;
|
||||
case DIALOG_OKONLY:
|
||||
dialog = createOKDialog( state, dlgID );
|
||||
break;
|
||||
|
@ -442,11 +440,6 @@ public class DlgDelegate {
|
|||
showDialog( DlgID.DLG_DICTGONE );
|
||||
}
|
||||
|
||||
public void showAboutDialog()
|
||||
{
|
||||
showDialog( DlgID.DIALOG_ABOUT );
|
||||
}
|
||||
|
||||
// Puts up alert asking to choose a reason to enable SMS, and on dismiss
|
||||
// calls onPosButton/onNegButton with the action and in params a Boolean
|
||||
// indicating whether enabling is now ok.
|
||||
|
@ -623,44 +616,6 @@ public class DlgDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
private Dialog createAboutDialog()
|
||||
{
|
||||
final View view = LocUtils.inflate( m_activity, R.layout.about_dlg );
|
||||
TextView vers = (TextView)view.findViewById( R.id.version_string );
|
||||
|
||||
DateFormat df = DateFormat.getDateTimeInstance( DateFormat.FULL,
|
||||
DateFormat.FULL );
|
||||
String dateString
|
||||
= df.format( new Date( BuildConfig.BUILD_STAMP * 1000 ) );
|
||||
vers.setText( getString( R.string.about_vers_fmt,
|
||||
getString( R.string.app_version ),
|
||||
BuildConfig.GIT_REV, dateString ) );
|
||||
|
||||
TextView xlator = (TextView)view.findViewById( R.id.about_xlator );
|
||||
String str = getString( R.string.xlator );
|
||||
if ( str.length() > 0 && !str.equals("[empty]") ) {
|
||||
xlator.setText( str );
|
||||
} else {
|
||||
xlator.setVisibility( View.GONE );
|
||||
}
|
||||
|
||||
return LocUtils.makeAlertBuilder( m_activity )
|
||||
.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( m_activity );
|
||||
}
|
||||
} )
|
||||
.setPositiveButton( android.R.string.ok, null )
|
||||
.create();
|
||||
}
|
||||
|
||||
private Dialog createLookupDialog()
|
||||
{
|
||||
Dialog result = null;
|
||||
|
|
|
@ -26,7 +26,6 @@ public enum DlgID {
|
|||
, CONFIRM_CHANGE
|
||||
, CONFIRM_CHANGE_PLAY
|
||||
, CONFIRM_THEN
|
||||
, DIALOG_ABOUT
|
||||
, DIALOG_NOTAGAIN
|
||||
, DIALOG_OKONLY
|
||||
, DIALOG_ENABLESMS
|
||||
|
|
|
@ -1630,7 +1630,7 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
break;
|
||||
|
||||
case R.id.games_menu_about:
|
||||
showAboutDialog();
|
||||
show( AboutAlert.newInstance() );
|
||||
break;
|
||||
|
||||
case R.id.games_menu_email:
|
||||
|
|
|
@ -25,10 +25,11 @@ import android.content.res.Configuration;
|
|||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
|
@ -111,6 +112,11 @@ public class MainActivity extends XWActivity
|
|||
m_dlgt.handleNewIntent( intent );
|
||||
}
|
||||
|
||||
protected void show( DialogFragment df )
|
||||
{
|
||||
df.show( getSupportFragmentManager(), "dialog" );
|
||||
}
|
||||
|
||||
/* Sometimes I'm getting crashes because views don't have fragments
|
||||
* associated yet. I suspect that's because adding them's been postponed
|
||||
* via the m_runWhenSafe mechanism. So: postpone handling intents too.
|
||||
|
|
Loading…
Add table
Reference in a new issue