SMS-enable alert: Add cancel button, and disable OK button until user

selects an enabling option
This commit is contained in:
Eric House 2015-06-23 08:11:18 -07:00
parent 54b18c898d
commit b8193d635d
5 changed files with 40 additions and 1 deletions

View file

@ -652,6 +652,7 @@ public final class R {
*/
public static final int button_download=0x7f05018b;
public static final int button_edit=0x7f0502c4;
public static final int button_enable=0x7f050304;
public static final int button_enable_bt=0x7f050224;
public static final int button_enable_sms=0x7f050223;
public static final int button_go_settings=0x7f05025b;

View file

@ -2491,4 +2491,6 @@
<string name="confirm_drop_relay_sms">Not all carriers support play
via SMS.</string>
<string name="button_enable">Enable</string>
</resources>

View file

@ -2154,4 +2154,5 @@
secived.</string>
<string name="confirm_drop_relay_sms">Ton lla sreirrac troppus yalp
aiv SMS.</string>
<string name="button_enable">Elbane</string>
</resources>

View file

@ -2154,4 +2154,5 @@
DEVICES.</string>
<string name="confirm_drop_relay_sms">NOT ALL CARRIERS SUPPORT PLAY
VIA SMS.</string>
<string name="button_enable">ENABLE</string>
</resources>

View file

@ -31,10 +31,13 @@ import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
@ -239,6 +242,9 @@ public class DlgDelegate {
case INVITE_CHOICES_THEN:
prepareInviteChoicesDialog( dialog );
break;
case DIALOG_ENABLESMS:
prepareEnableSMSDialog( dialog );
break;
}
}
@ -691,6 +697,7 @@ public class DlgDelegate {
Spinner reasons = (Spinner)
layout.findViewById( R.id.confirm_sms_reasons );
boolean enabled = 0 < reasons.getSelectedItemPosition();
Assert.assertTrue( enabled );
Object[] params = { new Boolean(enabled), };
m_clickCallback.dlgButtonClicked( state.m_action,
AlertDialog.BUTTON_POSITIVE,
@ -701,12 +708,39 @@ public class DlgDelegate {
Dialog dialog = LocUtils.makeAlertBuilder( m_activity )
.setTitle( R.string.confirm_sms_title )
.setView( layout )
.setPositiveButton( android.R.string.ok, lstnr )
.setPositiveButton( R.string.button_enable, lstnr )
.setNegativeButton( android.R.string.cancel, null )
.create();
Utils.setRemoveOnDismiss( m_activity, dialog, dlgID );
return dialog;
}
private void checkEnableButton( Dialog dialog, Spinner reasons )
{
boolean enabled = 0 < reasons.getSelectedItemPosition();
AlertDialog adlg = (AlertDialog)dialog;
Button button = adlg.getButton( AlertDialog.BUTTON_POSITIVE );
button.setEnabled( enabled );
}
private void prepareEnableSMSDialog( final Dialog dialog )
{
final Spinner reasons = (Spinner)
dialog.findViewById( R.id.confirm_sms_reasons );
OnItemSelectedListener onItemSel = new OnItemSelectedListener() {
public void onItemSelected( AdapterView<?> parent, View view,
int position, long id )
{
checkEnableButton( dialog, reasons );
}
public void onNothingSelected( AdapterView<?> parent ) {}
};
reasons.setOnItemSelectedListener( onItemSel );
checkEnableButton( dialog, reasons );
}
private OnClickListener mkCallbackClickListener( final DlgState state,
final NotAgainView naView )
{