mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-27 07:58:49 +01:00
save sms-invite contacts across uses of the dialog
This commit is contained in:
parent
84496b3012
commit
ba44f1355c
3 changed files with 56 additions and 5 deletions
|
@ -61,6 +61,8 @@
|
|||
<string name="key_closed_langs">key_closed_langs</string>
|
||||
<string name="key_bt_names">key_bt_names</string>
|
||||
<string name="key_bt_addrs">key_bt_addrs</string>
|
||||
<string name="key_nbs_names">key_nbs_names</string>
|
||||
<string name="key_nbs_phones">key_nbs_phones</string>
|
||||
|
||||
<string name="key_notagain_sync">key_notagain_sync</string>
|
||||
<string name="key_notagain_chat">key_notagain_chat</string>
|
||||
|
|
|
@ -35,9 +35,10 @@ import android.widget.Button;
|
|||
import android.widget.EditText;
|
||||
import android.widget.ListView;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eehouse.android.xw4.jni.CommonPrefs;
|
||||
|
||||
public class NBSInviteActivity extends InviteActivity
|
||||
implements View.OnClickListener {
|
||||
public static final String DEVS = "DEVS";
|
||||
|
@ -56,9 +57,8 @@ public class NBSInviteActivity extends InviteActivity
|
|||
R.id.button_invite, R.id.button_add,
|
||||
R.id.button_clear, R.id.invite_desc,
|
||||
R.string.invite_nbs_descf );
|
||||
|
||||
m_names = new ArrayList<String>();
|
||||
m_phones = new ArrayList<String>();
|
||||
getSavedState();
|
||||
rebuildList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -93,6 +93,7 @@ public class NBSInviteActivity extends InviteActivity
|
|||
m_names.remove( ii );
|
||||
}
|
||||
}
|
||||
saveState();
|
||||
rebuildList();
|
||||
// int index = m_phones.size();
|
||||
// while ( index-- > 0 ) {
|
||||
|
@ -151,6 +152,7 @@ public class NBSInviteActivity extends InviteActivity
|
|||
}
|
||||
}
|
||||
if ( len_before != m_phones.size() ) {
|
||||
saveState();
|
||||
rebuildList();
|
||||
}
|
||||
}
|
||||
|
@ -165,6 +167,18 @@ public class NBSInviteActivity extends InviteActivity
|
|||
tryEnable();
|
||||
}
|
||||
|
||||
private void getSavedState()
|
||||
{
|
||||
m_names = CommonPrefs.getNBSNames( this );
|
||||
m_phones = CommonPrefs.getNBSPhones( this );
|
||||
}
|
||||
|
||||
private void saveState()
|
||||
{
|
||||
CommonPrefs.setNBSNames( this, m_names );
|
||||
CommonPrefs.setNBSPhones( this, m_phones );
|
||||
}
|
||||
|
||||
private class NBSPhonesAdapter extends XWListAdapter {
|
||||
private NBSListItem[] m_items;
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import android.content.res.Resources;
|
|||
import android.graphics.Paint;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.TextUtils;
|
||||
import java.util.ArrayList;
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eehouse.android.xw4.R;
|
||||
|
@ -348,11 +349,33 @@ public class CommonPrefs {
|
|||
setPrefsStringArray( context, R.string.key_bt_names, names );
|
||||
}
|
||||
|
||||
public static void setNBSNames( Context context, ArrayList<String> names )
|
||||
{
|
||||
String[] array = names.toArray( new String[names.size()] );
|
||||
setPrefsStringArray( context, R.string.key_nbs_names, array );
|
||||
}
|
||||
|
||||
public static void setNBSPhones( Context context, ArrayList<String> names )
|
||||
{
|
||||
String[] array = names.toArray( new String[names.size()] );
|
||||
setPrefsStringArray( context, R.string.key_nbs_phones, array );
|
||||
}
|
||||
|
||||
public static String[] getBTNames( Context context )
|
||||
{
|
||||
return getPrefsStringArray( context, R.string.key_bt_names );
|
||||
}
|
||||
|
||||
public static ArrayList<String> getNBSNames( Context context )
|
||||
{
|
||||
return getPrefsStringArrayList( context, R.string.key_nbs_names );
|
||||
}
|
||||
|
||||
public static ArrayList<String> getNBSPhones( Context context )
|
||||
{
|
||||
return getPrefsStringArrayList( context, R.string.key_nbs_phones );
|
||||
}
|
||||
|
||||
public static void setBTAddresses( Context context, String[] addrs )
|
||||
{
|
||||
setPrefsStringArray( context, R.string.key_bt_addrs, addrs );
|
||||
|
@ -402,7 +425,6 @@ public class CommonPrefs {
|
|||
editor.commit();
|
||||
}
|
||||
|
||||
|
||||
private static String[] getPrefsStringArray( Context context, int keyID )
|
||||
{
|
||||
String asStr = getString( context, keyID );
|
||||
|
@ -410,6 +432,19 @@ public class CommonPrefs {
|
|||
return result;
|
||||
}
|
||||
|
||||
private static ArrayList<String> getPrefsStringArrayList( Context context,
|
||||
int keyID )
|
||||
{
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
String[] strs = getPrefsStringArray( context, keyID );
|
||||
if ( null != strs ) {
|
||||
for ( int ii = 0; ii < strs.length; ++ii ) {
|
||||
list.add( strs[ii] );
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private static void setPrefsStringArray( Context context, int keyID,
|
||||
String[] value )
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue