mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-24 07:58:34 +01:00
move user-vis strings (resIDs) into enum
This commit is contained in:
parent
9e2ef3a698
commit
608b4010a0
2 changed files with 32 additions and 30 deletions
|
@ -330,11 +330,21 @@ public class DlgDelegate {
|
||||||
// These are stored in the INVITES table. Don't change order
|
// These are stored in the INVITES table. Don't change order
|
||||||
// gratuitously
|
// gratuitously
|
||||||
public static enum InviteMeans {
|
public static enum InviteMeans {
|
||||||
SMS_DATA, // classic NBS-based data sms
|
SMS_DATA(R.string.invite_choice_data_sms), // classic NBS-based data sms
|
||||||
EMAIL, NFC, BLUETOOTH, CLIPBOARD, RELAY, WIFIDIRECT,
|
EMAIL(R.string.invite_choice_email),
|
||||||
SMS_USER, // just launch the SMS app, as with email
|
NFC(R.string.invite_choice_nfc),
|
||||||
MQTT,
|
BLUETOOTH(R.string.invite_choice_bt),
|
||||||
|
CLIPBOARD(R.string.slmenu_copy_sel),
|
||||||
|
RELAY(R.string.invite_choice_relay),
|
||||||
|
WIFIDIRECT(R.string.invite_choice_p2p),
|
||||||
|
SMS_USER(R.string.invite_choice_user_sms), // just launch the SMS app, as with email
|
||||||
|
MQTT(R.string.invite_choice_mqtt);
|
||||||
|
|
||||||
|
private InviteMeans( int resid) { mResID = resid; }
|
||||||
|
private int mResID;
|
||||||
|
public int getUserDescID() { return mResID; }
|
||||||
};
|
};
|
||||||
|
|
||||||
boolean onPosButton( Action action, Object... params );
|
boolean onPosButton( Action action, Object... params );
|
||||||
boolean onNegButton( Action action, Object... params );
|
boolean onNegButton( Action action, Object... params );
|
||||||
boolean onDismissed( Action action, Object... params );
|
boolean onDismissed( Action action, Object... params );
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/* -*- compile-command: "find-and-gradle.sh inXw4dDebug"; -*- */
|
/* -*- compile-command: "find-and-gradle.sh inXw4dDebug"; -*- */
|
||||||
/*
|
/*
|
||||||
* Copyright 2017 by Eric House (xwords@eehouse.org). All rights reserved.
|
* Copyright 2017 - 2020 by Eric House (xwords@eehouse.org). All rights
|
||||||
|
* reserved.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License as
|
* modify it under the terms of the GNU General Public License as
|
||||||
|
@ -49,7 +50,6 @@ public class InviteChoicesAlert extends DlgDelegateAlert {
|
||||||
AlertDialog.Builder builder )
|
AlertDialog.Builder builder )
|
||||||
{
|
{
|
||||||
final ArrayList<InviteMeans> means = new ArrayList<>();
|
final ArrayList<InviteMeans> means = new ArrayList<>();
|
||||||
ArrayList<String> items = new ArrayList<>();
|
|
||||||
InviteMeans lastMeans = null;
|
InviteMeans lastMeans = null;
|
||||||
Object[] params = state.getParams();
|
Object[] params = state.getParams();
|
||||||
if ( null != params
|
if ( null != params
|
||||||
|
@ -57,36 +57,36 @@ public class InviteChoicesAlert extends DlgDelegateAlert {
|
||||||
lastMeans = ((SentInvitesInfo)params[0]).getLastMeans();
|
lastMeans = ((SentInvitesInfo)params[0]).getLastMeans();
|
||||||
}
|
}
|
||||||
|
|
||||||
add( items, means, R.string.invite_choice_email, InviteMeans.EMAIL );
|
means.add( InviteMeans.EMAIL );
|
||||||
add( items, means, R.string.invite_choice_user_sms, InviteMeans.SMS_USER );
|
means.add( InviteMeans.SMS_USER );
|
||||||
|
|
||||||
if ( BTService.BTAvailable() ) {
|
if ( BTService.BTAvailable() ) {
|
||||||
add( items, means, R.string.invite_choice_bt, InviteMeans.BLUETOOTH );
|
means.add( InviteMeans.BLUETOOTH );
|
||||||
}
|
}
|
||||||
if ( Utils.deviceSupportsNBS(context) ) {
|
if ( Utils.deviceSupportsNBS(context) ) {
|
||||||
add( items, means, R.string.invite_choice_data_sms, InviteMeans.SMS_DATA );
|
means.add( InviteMeans.SMS_DATA );
|
||||||
}
|
}
|
||||||
if ( BuildConfig.NON_RELEASE ) {
|
if ( BuildConfig.NON_RELEASE ) {
|
||||||
add( items, means, R.string.invite_choice_relay, InviteMeans.RELAY );
|
means.add( InviteMeans.RELAY );
|
||||||
}
|
}
|
||||||
if ( BuildConfig.NON_RELEASE && BuildConfig.OFFER_MQTT ) {
|
if ( BuildConfig.NON_RELEASE && BuildConfig.OFFER_MQTT ) {
|
||||||
add( items, means, R.string.invite_choice_mqtt, InviteMeans.MQTT );
|
means.add( InviteMeans.MQTT );
|
||||||
}
|
}
|
||||||
if ( WiDirWrapper.enabled() ) {
|
if ( WiDirWrapper.enabled() ) {
|
||||||
add( items, means, R.string.invite_choice_p2p, InviteMeans.WIFIDIRECT );
|
means.add( InviteMeans.WIFIDIRECT );
|
||||||
}
|
}
|
||||||
if ( NFCUtils.nfcAvail( context )[0] ) {
|
if ( NFCUtils.nfcAvail( context )[0] ) {
|
||||||
add( items, means, R.string.invite_choice_nfc, InviteMeans.NFC );
|
means.add( InviteMeans.NFC );
|
||||||
}
|
}
|
||||||
add( items, means, R.string.slmenu_copy_sel, InviteMeans.CLIPBOARD );
|
means.add( InviteMeans.CLIPBOARD );
|
||||||
|
|
||||||
|
String[] items = new String[means.size()];
|
||||||
final int[] sel = { -1 };
|
final int[] sel = { -1 };
|
||||||
if ( null != lastMeans ) {
|
for ( int ii = 0; ii < items.length; ++ii ) {
|
||||||
for ( int ii = 0; ii < means.size(); ++ii ) {
|
InviteMeans oneMeans = means.get(ii);
|
||||||
if ( lastMeans == means.get(ii) ) {
|
items[ii] = getString( oneMeans.getUserDescID() );
|
||||||
sel[0] = ii;
|
if ( lastMeans == oneMeans ) {
|
||||||
break;
|
sel[0] = ii;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,8 +149,7 @@ public class InviteChoicesAlert extends DlgDelegateAlert {
|
||||||
};
|
};
|
||||||
|
|
||||||
builder.setTitle( R.string.invite_choice_title )
|
builder.setTitle( R.string.invite_choice_title )
|
||||||
.setSingleChoiceItems( items.toArray( new String[items.size()] ),
|
.setSingleChoiceItems( items, sel[0], selChanged )
|
||||||
sel[0], selChanged )
|
|
||||||
.setPositiveButton( android.R.string.ok, okClicked )
|
.setPositiveButton( android.R.string.ok, okClicked )
|
||||||
.setNegativeButton( android.R.string.cancel, null );
|
.setNegativeButton( android.R.string.cancel, null );
|
||||||
if ( BuildConfig.DEBUG ) {
|
if ( BuildConfig.DEBUG ) {
|
||||||
|
@ -168,11 +167,4 @@ public class InviteChoicesAlert extends DlgDelegateAlert {
|
||||||
builder.setNeutralButton( R.string.ok_with_robots, ocl );
|
builder.setNeutralButton( R.string.ok_with_robots, ocl );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void add( List<String> items, List<InviteMeans> means,
|
|
||||||
int resID, InviteMeans oneMeans )
|
|
||||||
{
|
|
||||||
items.add( getString( resID ) );
|
|
||||||
means.add( oneMeans );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue