From 92e150bb1e97af4b6637ad91932e5c7ebc9d6484 Mon Sep 17 00:00:00 2001 From: Eric House Date: Fri, 10 Feb 2017 06:00:26 -0800 Subject: [PATCH] convert confirmThen alert --- .../eehouse/android/xw4/ConfirmThenAlert.java | 60 +++++++++++++++++++ .../org/eehouse/android/xw4/DlgDelegate.java | 30 +--------- 2 files changed, 61 insertions(+), 29 deletions(-) create mode 100644 xwords4/android/app/src/main/java/org/eehouse/android/xw4/ConfirmThenAlert.java diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/ConfirmThenAlert.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/ConfirmThenAlert.java new file mode 100644 index 000000000..83b9f6fa4 --- /dev/null +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/ConfirmThenAlert.java @@ -0,0 +1,60 @@ +/* -*- 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.Dialog; +import android.content.Context; +import android.content.DialogInterface.OnClickListener; +import android.os.Bundle; + +import org.eehouse.android.xw4.loc.LocUtils; + +public class ConfirmThenAlert extends DlgDelegateAlert { + + public static ConfirmThenAlert newInstance( DlgState state ) + { + return new ConfirmThenAlert( state ); + } + + public ConfirmThenAlert() {} + public ConfirmThenAlert( DlgState state ) { super( state ); } + + @Override + public Dialog onCreateDialog( Bundle sis ) + { + final Context context = getActivity(); + + getBundleData( sis ); + final DlgState state = getState(); + + NotAgainView naView = (NotAgainView) + LocUtils.inflate( context, R.layout.not_again_view ); + naView.setMessage( state.m_msg ); + naView.setShowNACheckbox( null != state.m_onNAChecked ); + OnClickListener lstnr = mkCallbackClickListener( naView ); + + return LocUtils.makeAlertBuilder( context ) + .setTitle( state.m_titleId == 0 ? R.string.query_title : state.m_titleId ) + .setView( naView ) + .setPositiveButton( state.m_posButton, lstnr ) + .setNegativeButton( state.m_negButton, lstnr ) + .create(); + } +} 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 1bf955a42..6b4222dbd 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,14 +376,8 @@ public class DlgDelegate { dialog = createLookupDialog(); break; case DIALOG_OKONLY: - Assert.assertFalse( BuildConfig.DEBUG ); - break; case DIALOG_NOTAGAIN: - Assert.assertFalse( BuildConfig.DEBUG ); - break; case CONFIRM_THEN: - dialog = createConfirmThenDialog( state, dlgID ); - break; case INVITE_CHOICES_THEN: Assert.assertFalse( BuildConfig.DEBUG ); break; @@ -460,8 +454,6 @@ public class DlgDelegate { DlgState state = new DlgState( DlgID.DIALOG_NOTAGAIN ) .setMsg( msg).setPrefsKey( prefsKey ).setAction( action ) .setActionPair( more ).setParams( params ); - // addState( state ); - // showDialog( DlgID.DIALOG_NOTAGAIN ); m_dlgt.show( NotAgainAlert.newInstance( state ) ); } } @@ -479,8 +471,7 @@ public class DlgDelegate { .setAction( action ) .setTitle( titleId ) .setParams( params ); - addState( state ); - showDialog( DlgID.CONFIRM_THEN ); + m_dlgt.show( ConfirmThenAlert.newInstance( state ) ); } } @@ -495,8 +486,6 @@ public class DlgDelegate { DlgState state = new DlgState( DlgID.INVITE_CHOICES_THEN ) .setAction( action ) .setParams( info ); - // addState( state ); - // showDialog( DlgID.INVITE_CHOICES_THEN ); m_dlgt.show( InviteChoicesAlert.newInstance( state ) ); } else { post( new Runnable() { @@ -616,23 +605,6 @@ public class DlgDelegate { return result; } - private Dialog createConfirmThenDialog( DlgState state, DlgID dlgID ) - { - NotAgainView naView = (NotAgainView) - LocUtils.inflate( m_activity, R.layout.not_again_view ); - naView.setMessage( state.m_msg ); - naView.setShowNACheckbox( null != state.m_onNAChecked ); - OnClickListener lstnr = mkCallbackClickListener( state, naView ); - - AlertDialog.Builder builder = LocUtils.makeAlertBuilder( m_activity ) - .setTitle( state.m_titleId == 0 ? R.string.query_title : state.m_titleId ) - .setView( naView ) - .setPositiveButton( state.m_posButton, lstnr ) - .setNegativeButton( state.m_negButton, lstnr ); - - return setCallbackDismissListener( builder.create(), state, dlgID ); - } - private Dialog createDictGoneDialog() { Dialog dialog = LocUtils.makeAlertBuilder( m_activity )