From c9bc7b6c497dbda5e071292a0c571618ef3e29a0 Mon Sep 17 00:00:00 2001 From: Eric House Date: Fri, 10 Feb 2017 05:47:17 -0800 Subject: [PATCH] convert ok-only dialog to fragments --- .../org/eehouse/android/xw4/DlgDelegate.java | 20 +----- .../org/eehouse/android/xw4/OkOnlyAlert.java | 68 +++++++++++++++++++ 2 files changed, 70 insertions(+), 18 deletions(-) create mode 100644 xwords4/android/app/src/main/java/org/eehouse/android/xw4/OkOnlyAlert.java diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DlgDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DlgDelegate.java index cdb86890f..1bf955a42 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DlgDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DlgDelegate.java @@ -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) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/OkOnlyAlert.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/OkOnlyAlert.java new file mode 100644 index 000000000..a6cdf8239 --- /dev/null +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/OkOnlyAlert.java @@ -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; + } +}