aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/ui/PublishProfilePictureActivity.java
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-08-05 01:36:17 +0200
committeriNPUTmice <daniel@gultsch.de>2014-08-05 01:36:17 +0200
commitf8b4d5f338aede361c2562379d816b45f7bed3b8 (patch)
tree82ea92f7e35b94400e618387d8d522daeb62dc70 /src/eu/siacs/conversations/ui/PublishProfilePictureActivity.java
parent629ff3afcdba5e6721a1b63cd0d497d97e3bdbed (diff)
publish avatars
Diffstat (limited to '')
-rw-r--r--src/eu/siacs/conversations/ui/PublishProfilePictureActivity.java89
1 files changed, 64 insertions, 25 deletions
diff --git a/src/eu/siacs/conversations/ui/PublishProfilePictureActivity.java b/src/eu/siacs/conversations/ui/PublishProfilePictureActivity.java
index 776ed774..a2cc84a6 100644
--- a/src/eu/siacs/conversations/ui/PublishProfilePictureActivity.java
+++ b/src/eu/siacs/conversations/ui/PublishProfilePictureActivity.java
@@ -1,10 +1,11 @@
package eu.siacs.conversations.ui;
+import android.app.PendingIntent;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
-import android.util.Log;
+import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
@@ -13,47 +14,69 @@ import android.widget.TextView;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.utils.PhoneHelper;
+import eu.siacs.conversations.xmpp.pep.Avatar;
public class PublishProfilePictureActivity extends XmppActivity {
-
+
private static final int REQUEST_CHOOSE_FILE = 0xac23;
-
+
private ImageView avatar;
- private TextView explanation;
+ private TextView accountTextView;
private Button cancelButton;
private Button publishButton;
-
+
private Uri avatarUri;
-
+
private Account account;
-
+
+ private UiCallback<Avatar> avatarPublication = new UiCallback<Avatar>() {
+
+ @Override
+ public void success(Avatar object) {
+ finish();
+ }
+
+ @Override
+ public void error(int errorCode, Avatar object) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void userInputRequried(PendingIntent pi, Avatar object) {
+ // TODO Auto-generated method stub
+
+ }
+ };
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_publish_profile_picture);
this.avatar = (ImageView) findViewById(R.id.account_image);
- this.explanation = (TextView) findViewById(R.id.explanation);
this.cancelButton = (Button) findViewById(R.id.cancel_button);
this.publishButton = (Button) findViewById(R.id.publish_button);
+ this.accountTextView = (TextView) findViewById(R.id.account);
this.publishButton.setOnClickListener(new OnClickListener() {
-
+
@Override
public void onClick(View v) {
- if (avatarUri!=null) {
- xmppConnectionService.pushAvatar(account, avatarUri);
- finish();
+ if (avatarUri != null) {
+ disablePublishButton();
+ xmppConnectionService.publishAvatar(account, avatarUri,
+ avatarPublication);
}
}
});
this.cancelButton.setOnClickListener(new OnClickListener() {
-
+
@Override
public void onClick(View v) {
finish();
}
});
this.avatar.setOnClickListener(new OnClickListener() {
-
+
@Override
public void onClick(View v) {
Intent attachFileIntent = new Intent();
@@ -65,45 +88,61 @@ public class PublishProfilePictureActivity extends XmppActivity {
}
});
}
-
+
@Override
protected void onActivityResult(int requestCode, int resultCode,
final Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
if (requestCode == REQUEST_CHOOSE_FILE) {
- Log.d("xmppService","bla");
this.avatarUri = data.getData();
}
}
}
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem menuItem) {
+ super.onOptionsItemSelected(menuItem);
+ switch (menuItem.getItemId()) {
+ case android.R.id.home:
+ finish();
+ break;
+ }
+ return true;
+ }
@Override
protected void onBackendConnected() {
- if (getIntent()!=null) {
+ if (getIntent() != null) {
String jid = getIntent().getStringExtra("account");
- if (jid!=null) {
+ if (jid != null) {
this.account = xmppConnectionService.findAccountByJid(jid);
if (this.avatarUri == null) {
- avatarUri = PhoneHelper.getSefliUri(getApplicationContext());
+ avatarUri = PhoneHelper
+ .getSefliUri(getApplicationContext());
}
loadImageIntoPreview(avatarUri);
- String explainText = getString(R.string.publish_avatar_explanation,account.getJid());
- this.explanation.setText(explainText);
+ this.accountTextView.setText(this.account.getJid());
}
}
-
+
}
-
+
protected void loadImageIntoPreview(Uri uri) {
- Bitmap bm = xmppConnectionService.getFileBackend().cropCenterSquare(uri, 384);
+ Bitmap bm = xmppConnectionService.getFileBackend().cropCenterSquare(
+ uri, 384);
this.avatar.setImageBitmap(bm);
enablePublishButton();
}
-
+
protected void enablePublishButton() {
this.publishButton.setEnabled(true);
this.publishButton.setTextColor(getPrimaryTextColor());
}
+
+ protected void disablePublishButton() {
+ this.publishButton.setEnabled(false);
+ this.publishButton.setTextColor(getSecondaryTextColor());
+ }
}