Shouldn't be able to remove self from shared list using the x's (too easy to hit, should just use delete button instead)

pull/14/head
Sam Bosley 12 years ago
parent 04a1999070
commit b210048fd3

@ -334,7 +334,7 @@ public class TagSettingsActivity extends SherlockFragmentActivity {
public void onClick(DialogInterface d, int which) { public void onClick(DialogInterface d, int which) {
tagMembers.removeAllViews(); tagMembers.removeAllViews();
tagMembers.addPerson("", ""); //$NON-NLS-1$ tagMembers.addPerson("", "", false); //$NON-NLS-1$
} }
}; };
DialogUtilities.okCancelCustomDialog(TagSettingsActivity.this, getString(R.string.actfm_EPA_login_button), DialogUtilities.okCancelCustomDialog(TagSettingsActivity.this, getString(R.string.actfm_EPA_login_button),
@ -496,7 +496,7 @@ public class TagSettingsActivity extends SherlockFragmentActivity {
} }
} }
tagMembers.addPerson("", ""); //$NON-NLS-1$ tagMembers.addPerson("", "", false); //$NON-NLS-1$
} }
@Override @Override

@ -179,7 +179,6 @@ public class ActFmSyncThread {
public synchronized void startSyncThread() { public synchronized void startSyncThread() {
if (thread == null || !thread.isAlive()) { if (thread == null || !thread.isAlive()) {
setTimeForBackgroundSync(true);
thread = new Thread(new Runnable() { thread = new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {

@ -67,11 +67,11 @@ public class PeopleContainer extends LinearLayout {
// --- methods // --- methods
public TextView addPerson() { public TextView addPerson() {
return addPerson("", ""); //$NON-NLS-1$ //$NON-NLS-2$ return addPerson("", "", false); //$NON-NLS-1$ //$NON-NLS-2$
} }
/** Adds a tag to the tag field */ /** Adds a tag to the tag field */
public TextView addPerson(String person, String image) { public TextView addPerson(String person, String image, boolean isSelf) {
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// check if already exists // check if already exists
@ -98,20 +98,23 @@ public class PeopleContainer extends LinearLayout {
} }
final ImageButton removeButton = (ImageButton)tagItem.findViewById(R.id.button1); final ImageButton removeButton = (ImageButton)tagItem.findViewById(R.id.button1);
removeButton.setOnClickListener(new View.OnClickListener() { if (isSelf)
public void onClick(View v) { removeButton.setVisibility(View.GONE);
TextView lastView = getLastTextView(); else
if(lastView == textView && textView.getText().length() == 0) removeButton.setOnClickListener(new View.OnClickListener() {
return; public void onClick(View v) {
TextView lastView = getLastTextView();
if(getChildCount() > 1) if(lastView == textView && textView.getText().length() == 0)
removeView(tagItem); return;
else {
textView.setText(""); //$NON-NLS-1$ if(getChildCount() > 1)
textView.setEnabled(true); removeView(tagItem);
else {
textView.setText(""); //$NON-NLS-1$
textView.setEnabled(true);
}
} }
} });
});
final AsyncImageView imageView = (AsyncImageView)tagItem. final AsyncImageView imageView = (AsyncImageView)tagItem.
findViewById(R.id.icon); findViewById(R.id.icon);
@ -119,8 +122,7 @@ public class PeopleContainer extends LinearLayout {
if (TextUtils.isEmpty(textView.getText())) { if (TextUtils.isEmpty(textView.getText())) {
imageView.setDefaultImageDrawable(ResourceDrawableCache.getImageDrawableFromId(resources, R.drawable.icn_add_contact)); imageView.setDefaultImageDrawable(ResourceDrawableCache.getImageDrawableFromId(resources, R.drawable.icn_add_contact));
removeButton.setVisibility(View.GONE); removeButton.setVisibility(View.GONE);
} } else if (!isSelf) {
else {
imageView.setDefaultImageDrawable(ResourceDrawableCache.getImageDrawableFromId(resources, R.drawable.icn_default_person_image)); imageView.setDefaultImageDrawable(ResourceDrawableCache.getImageDrawableFromId(resources, R.drawable.icn_default_person_image));
removeButton.setVisibility(View.VISIBLE); removeButton.setVisibility(View.VISIBLE);
} }
@ -141,7 +143,7 @@ public class PeopleContainer extends LinearLayout {
public void onTextChanged(CharSequence s, int start, int before, public void onTextChanged(CharSequence s, int start, int before,
int count) { int count) {
if(count > 0 && getLastTextView() == textView) { if(count > 0 && getLastTextView() == textView) {
addPerson("", ""); addPerson("", "", false);
} }
if (TextUtils.isEmpty(textView.getText())) { if (TextUtils.isEmpty(textView.getText())) {
imageView.setDefaultImageDrawable(ResourceDrawableCache.getImageDrawableFromId(resources, R.drawable.icn_add_contact)); imageView.setDefaultImageDrawable(ResourceDrawableCache.getImageDrawableFromId(resources, R.drawable.icn_add_contact));
@ -164,7 +166,7 @@ public class PeopleContainer extends LinearLayout {
if(actionId != EditorInfo.IME_NULL) if(actionId != EditorInfo.IME_NULL)
return false; return false;
if(getLastTextView().getText().length() != 0) { if(getLastTextView().getText().length() != 0) {
addPerson("", ""); addPerson("", "", false);
} }
return true; return true;
} }
@ -276,11 +278,11 @@ public class PeopleContainer extends LinearLayout {
TextView textView = null; TextView textView = null;
String imageURL = person.optString("picture", ""); String imageURL = person.optString("picture", "");
if(person.has("id") && ActFmPreferenceService.userId().equals(person.getString("id"))) if(person.has("id") && ActFmPreferenceService.userId().equals(person.getString("id")))
textView = addPerson(Preferences.getStringValue(ActFmPreferenceService.PREF_NAME), imageURL); textView = addPerson(Preferences.getStringValue(ActFmPreferenceService.PREF_NAME), imageURL, true);
else if(!TextUtils.isEmpty(person.optString("name")) && !"null".equals(person.optString("name"))) else if(!TextUtils.isEmpty(person.optString("name")) && !"null".equals(person.optString("name")))
textView = addPerson(person.getString("name"), imageURL); textView = addPerson(person.getString("name"), imageURL, false);
else if(!TextUtils.isEmpty(person.optString("email")) && !"null".equals(person.optString("email"))) else if(!TextUtils.isEmpty(person.optString("email")) && !"null".equals(person.optString("email")))
textView = addPerson(person.getString("email"), imageURL); textView = addPerson(person.getString("email"), imageURL, false);
if(textView != null) { if(textView != null) {
textView.setTag(person); textView.setTag(person);

Loading…
Cancel
Save