convert ok-only dialog to fragments

This commit is contained in:
Eric House 2017-02-10 05:47:17 -08:00
parent a724ef734f
commit c9bc7b6c49
2 changed files with 70 additions and 18 deletions

View file

@ -376,18 +376,16 @@ public class DlgDelegate {
dialog = createLookupDialog();
break;
case DIALOG_OKONLY:
dialog = createOKDialog( state, dlgID );
Assert.assertFalse( BuildConfig.DEBUG );
break;
case DIALOG_NOTAGAIN:
Assert.assertFalse( BuildConfig.DEBUG );
// dialog = createNotAgainDialog( state, dlgID );
break;
case CONFIRM_THEN:
dialog = createConfirmThenDialog( state, dlgID );
break;
case INVITE_CHOICES_THEN:
Assert.assertFalse( BuildConfig.DEBUG );
// dialog = createInviteChoicesDialog( state, dlgID );
break;
case DLG_DICTGONE:
dialog = createDictGoneDialog();
@ -418,14 +416,12 @@ public class DlgDelegate {
private void showOKOnlyDialogThen( String msg, Action action,
Object[] params, int titleId )
{
// Assert.assertNull( m_dlgStates );
DlgState state = new DlgState( DlgID.DIALOG_OKONLY )
.setMsg( msg )
.setParams( params )
.setTitle( titleId )
.setAction(action);
addState( state );
showDialog( DlgID.DIALOG_OKONLY );
m_dlgt.show( OkOnlyAlert.newInstance( state ) );
}
public void showDictGoneFinish()
@ -620,18 +616,6 @@ public class DlgDelegate {
return result;
}
private Dialog createOKDialog( DlgState state, DlgID dlgID )
{
Dialog dialog = LocUtils.makeAlertBuilder( m_activity )
.setTitle( state.m_titleId == 0 ? R.string.info_title : state.m_titleId )
.setMessage( state.m_msg )
.setPositiveButton( android.R.string.ok, null )
.create();
dialog = setCallbackDismissListener( dialog, state, dlgID );
return dialog;
}
private Dialog createConfirmThenDialog( DlgState state, DlgID dlgID )
{
NotAgainView naView = (NotAgainView)

View file

@ -0,0 +1,68 @@
/* -*- compile-command: "find-and-gradle.sh insXw4Debug"; -*- */
/*
* Copyright 2017 by Eric House (xwords@eehouse.org). All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.eehouse.android.xw4;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface.OnClickListener;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import org.eehouse.android.xw4.DlgDelegate.Action;
import org.eehouse.android.xw4.DlgDelegate.ActionPair;
import junit.framework.Assert;
import org.eehouse.android.xw4.loc.LocUtils;
public class OkOnlyAlert extends DlgDelegateAlert {
private static final String TAG = OkOnlyAlert.class.getSimpleName();
public static OkOnlyAlert newInstance( DlgState state )
{
return new OkOnlyAlert( state );
}
public OkOnlyAlert( DlgState state )
{
super( state );
}
public OkOnlyAlert() {}
@Override
public Dialog onCreateDialog( Bundle sis )
{
final Context context = getActivity();
getBundleData( sis );
final DlgState state = getState();
Dialog dialog = LocUtils.makeAlertBuilder( getActivity() )
.setTitle( state.m_titleId == 0 ? R.string.info_title : state.m_titleId )
.setMessage( state.m_msg )
.setPositiveButton( android.R.string.ok, null )
.create();
// dialog = setCallbackDismissListener( dialog, state, dlgID );
return dialog;
}
}