mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-09 05:24:44 +01:00
SMS-enable alert: Add cancel button, and disable OK button until user
selects an enabling option
This commit is contained in:
parent
54b18c898d
commit
b8193d635d
5 changed files with 40 additions and 1 deletions
|
@ -652,6 +652,7 @@ public final class R {
|
||||||
*/
|
*/
|
||||||
public static final int button_download=0x7f05018b;
|
public static final int button_download=0x7f05018b;
|
||||||
public static final int button_edit=0x7f0502c4;
|
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_bt=0x7f050224;
|
||||||
public static final int button_enable_sms=0x7f050223;
|
public static final int button_enable_sms=0x7f050223;
|
||||||
public static final int button_go_settings=0x7f05025b;
|
public static final int button_go_settings=0x7f05025b;
|
||||||
|
|
|
@ -2491,4 +2491,6 @@
|
||||||
<string name="confirm_drop_relay_sms">Not all carriers support play
|
<string name="confirm_drop_relay_sms">Not all carriers support play
|
||||||
via SMS.</string>
|
via SMS.</string>
|
||||||
|
|
||||||
|
<string name="button_enable">Enable</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -2154,4 +2154,5 @@
|
||||||
secived.</string>
|
secived.</string>
|
||||||
<string name="confirm_drop_relay_sms">Ton lla sreirrac troppus yalp
|
<string name="confirm_drop_relay_sms">Ton lla sreirrac troppus yalp
|
||||||
aiv SMS.</string>
|
aiv SMS.</string>
|
||||||
|
<string name="button_enable">Elbane</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -2154,4 +2154,5 @@
|
||||||
DEVICES.</string>
|
DEVICES.</string>
|
||||||
<string name="confirm_drop_relay_sms">NOT ALL CARRIERS SUPPORT PLAY
|
<string name="confirm_drop_relay_sms">NOT ALL CARRIERS SUPPORT PLAY
|
||||||
VIA SMS.</string>
|
VIA SMS.</string>
|
||||||
|
<string name="button_enable">ENABLE</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -31,10 +31,13 @@ import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.AdapterView.OnItemSelectedListener;
|
||||||
|
import android.widget.AdapterView;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -239,6 +242,9 @@ public class DlgDelegate {
|
||||||
case INVITE_CHOICES_THEN:
|
case INVITE_CHOICES_THEN:
|
||||||
prepareInviteChoicesDialog( dialog );
|
prepareInviteChoicesDialog( dialog );
|
||||||
break;
|
break;
|
||||||
|
case DIALOG_ENABLESMS:
|
||||||
|
prepareEnableSMSDialog( dialog );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -691,6 +697,7 @@ public class DlgDelegate {
|
||||||
Spinner reasons = (Spinner)
|
Spinner reasons = (Spinner)
|
||||||
layout.findViewById( R.id.confirm_sms_reasons );
|
layout.findViewById( R.id.confirm_sms_reasons );
|
||||||
boolean enabled = 0 < reasons.getSelectedItemPosition();
|
boolean enabled = 0 < reasons.getSelectedItemPosition();
|
||||||
|
Assert.assertTrue( enabled );
|
||||||
Object[] params = { new Boolean(enabled), };
|
Object[] params = { new Boolean(enabled), };
|
||||||
m_clickCallback.dlgButtonClicked( state.m_action,
|
m_clickCallback.dlgButtonClicked( state.m_action,
|
||||||
AlertDialog.BUTTON_POSITIVE,
|
AlertDialog.BUTTON_POSITIVE,
|
||||||
|
@ -701,12 +708,39 @@ public class DlgDelegate {
|
||||||
Dialog dialog = LocUtils.makeAlertBuilder( m_activity )
|
Dialog dialog = LocUtils.makeAlertBuilder( m_activity )
|
||||||
.setTitle( R.string.confirm_sms_title )
|
.setTitle( R.string.confirm_sms_title )
|
||||||
.setView( layout )
|
.setView( layout )
|
||||||
.setPositiveButton( android.R.string.ok, lstnr )
|
.setPositiveButton( R.string.button_enable, lstnr )
|
||||||
|
.setNegativeButton( android.R.string.cancel, null )
|
||||||
.create();
|
.create();
|
||||||
Utils.setRemoveOnDismiss( m_activity, dialog, dlgID );
|
Utils.setRemoveOnDismiss( m_activity, dialog, dlgID );
|
||||||
return dialog;
|
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,
|
private OnClickListener mkCallbackClickListener( final DlgState state,
|
||||||
final NotAgainView naView )
|
final NotAgainView naView )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue