# HG changeset patch # User Da Risk # Date 1299110545 -3600 # Node ID c0a2d2743f38c797a7db4c4dc6baea1c7a151f5a # Parent 0b9c08ea320dde0566f9924bc1043798ba1c59a1 Add a way to disable avatar. diff -r 0b9c08ea320d -r c0a2d2743f38 res/values-fr/strings.xml --- a/res/values-fr/strings.xml Wed Mar 02 00:58:11 2011 +0100 +++ b/res/values-fr/strings.xml Thu Mar 03 01:02:25 2011 +0100 @@ -57,9 +57,11 @@ Mise à jour du statut Rien à changer Mon avatar + Choisissez votre avatar Prendre une photo Choisir une image - Sélecteur d'image non disponible + Pas d\'avatar + Sélecteur d\'image non disponible Saisissez votre identifiant de connexion diff -r 0b9c08ea320d -r c0a2d2743f38 res/values/strings.xml --- a/res/values/strings.xml Wed Mar 02 00:58:11 2011 +0100 +++ b/res/values/strings.xml Thu Mar 03 01:02:25 2011 +0100 @@ -56,8 +56,10 @@ Updating status Nothing to change My avatar + Choose your avatar Take a photo Select a picture + No avatar Photo picker not found diff -r 0b9c08ea320d -r c0a2d2743f38 src/com/beem/project/beem/service/XmppConnectionAdapter.java --- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java Wed Mar 02 00:58:11 2011 +0100 +++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java Thu Mar 03 01:02:25 2011 +0100 @@ -165,7 +165,7 @@ mPassword = password; mService = service; Context ctx = mService.getApplicationContext(); - mUserInfo = new UserInfo(jid); + mUserInfo = new UserInfo(jid.toLowerCase()); if (ctx instanceof BeemApplication) { mApplication = (BeemApplication) ctx; } diff -r 0b9c08ea320d -r c0a2d2743f38 src/com/beem/project/beem/ui/ChangeStatus.java --- a/src/com/beem/project/beem/ui/ChangeStatus.java Wed Mar 02 00:58:11 2011 +0100 +++ b/src/com/beem/project/beem/ui/ChangeStatus.java Thu Mar 03 01:02:25 2011 +0100 @@ -56,7 +56,6 @@ import android.content.ServiceConnection; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; -import android.media.MediaScannerConnection; import android.net.Uri; import android.os.Bundle; import android.os.Environment; @@ -121,7 +120,7 @@ private static final String KEY_CURRENT_PHOTO_FILE = "currentphotofile"; - private static final Uri MY_AVATAR_URI = Uri.parse(AvatarProvider.CONTENT_URI + "my_avatar"); + private static final Uri MY_AVATAR_URI = Uri.parse(AvatarProvider.CONTENT_URI + "/my_avatar"); private EditText mStatusMessageEditText; private Toast mToast; @@ -139,11 +138,9 @@ private final OnClickListener mOnClickOk = new MyOnClickListener(); private final BeemBroadcastReceiver mReceiver = new BeemBroadcastReceiver(); private boolean mShowCurrentAvatar = true; + private boolean mDisableAvatar; private File mCurrentPhotoFile; - // BAD HACK - private MediaScannerConnection mMsConnection; - /** * Constructor. */ @@ -256,8 +253,12 @@ switch (requestCode) { case PHOTO_PICKED_WITH_DATA: mAvatarUri = Uri.parse(data.getAction()); - if (mAvatarUri != null) + Log.d(TAG, "selected avatar uri " + mAvatarUri); + if (mAvatarUri != null) { mAvatar.setImageURI(mAvatarUri); + mDisableAvatar = false; + mShowCurrentAvatar = false; + } break; case CAMERA_WITH_DATA: @@ -332,10 +333,11 @@ * Publish the selected avatar. */ private void publishAvatar() { - if (mAvatarUri == null) - return; try { - mXmppFacade.publishAvatar(mAvatarUri); + if (mDisableAvatar) + mXmppFacade.disableAvatarPublishing(); + else if (mAvatarUri != null) + mXmppFacade.publishAvatar(mAvatarUri); } catch (RemoteException e) { Log.e(TAG, "Error while publishing avatar", e); } @@ -348,8 +350,11 @@ try { UserInfo ui = mXmppFacade.getUserInfo(); String avatarId = ui.getAvatarId(); - Uri uri = AvatarProvider.CONTENT_URI.buildUpon().appendPath(avatarId).build(); - mAvatar.setImageURI(uri); + Log.d(TAG, "User info ; avatar id " + avatarId); + if (avatarId != null) { + Uri uri = AvatarProvider.CONTENT_URI.buildUpon().appendPath(avatarId).build(); + mAvatar.setImageURI(uri); + } } catch (RemoteException e) { Log.e(TAG, "Error while displaying current avatar", e); } @@ -372,14 +377,17 @@ String[] choices; - choices = new String[2]; + + choices = new String[3]; choices[0] = getString(R.string.take_photo); choices[1] = getString(R.string.pick_photo); + choices[2] = getString(R.string.delete_avatar); + final ListAdapter adapter = new ArrayAdapter(dialogContext, android.R.layout.simple_list_item_1, choices); final AlertDialog.Builder builder = new AlertDialog.Builder(dialogContext); - builder.setTitle("Select a picture"); + builder.setTitle(R.string.select_avatar); builder.setSingleChoiceItems(adapter, -1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); @@ -390,6 +398,10 @@ case 1: doPickPhotoFromGallery(); break; + case 2: + mDisableAvatar = true; + mAvatar.setImageURI(null); + break; default: Log.w(TAG, "DialogInterface onClick : invalid which code"); }