aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/ui
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-08-03 20:28:13 +0200
committeriNPUTmice <daniel@gultsch.de>2014-08-03 20:28:13 +0200
commitdaab16bdef2f24f57d117efaa0144c578c883a6b (patch)
treefbea06de6eecf760161b95fe13b149c118acdef5 /src/eu/siacs/conversations/ui
parent88d1bd356c9408df6f12829dcd427b92af1e3969 (diff)
activity for future avatar publications. not working yet
Diffstat (limited to 'src/eu/siacs/conversations/ui')
-rw-r--r--src/eu/siacs/conversations/ui/ManageAccountActivity.java2
-rw-r--r--src/eu/siacs/conversations/ui/PublishProfilePictureActivity.java101
2 files changed, 103 insertions, 0 deletions
diff --git a/src/eu/siacs/conversations/ui/ManageAccountActivity.java b/src/eu/siacs/conversations/ui/ManageAccountActivity.java
index 15f904c39..105275cea 100644
--- a/src/eu/siacs/conversations/ui/ManageAccountActivity.java
+++ b/src/eu/siacs/conversations/ui/ManageAccountActivity.java
@@ -99,6 +99,8 @@ public class ManageAccountActivity extends XmppActivity {
xmppConnectionService
.updateAccount(selectedAccountForActionMode);
mode.finish();
+ } else if (item.getItemId() == R.id.mgmt_account_publish_avatar) {
+ startActivity(new Intent(getApplicationContext(), PublishProfilePictureActivity.class));
} else if (item.getItemId() == R.id.mgmt_account_delete) {
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(getString(R.string.mgmt_account_are_you_sure));
diff --git a/src/eu/siacs/conversations/ui/PublishProfilePictureActivity.java b/src/eu/siacs/conversations/ui/PublishProfilePictureActivity.java
new file mode 100644
index 000000000..0e369a97a
--- /dev/null
+++ b/src/eu/siacs/conversations/ui/PublishProfilePictureActivity.java
@@ -0,0 +1,101 @@
+package eu.siacs.conversations.ui;
+
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.net.Uri;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.TextView;
+import eu.siacs.conversations.R;
+import eu.siacs.conversations.utils.PhoneHelper;
+
+public class PublishProfilePictureActivity extends XmppActivity {
+
+ private static final int REQUEST_CHOOSE_FILE = 0xac23;
+
+ private ImageView avatar;
+ private TextView explanation;
+ private Button cancelButton;
+ private Button publishButton;
+
+ private Uri avatarUri;
+
+ @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.publishButton.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ if (avatarUri!=null) {
+ xmppConnectionService.pushAvatar(null, avatarUri);
+ finish();
+ }
+ }
+ });
+ 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();
+ attachFileIntent.setType("image/*");
+ attachFileIntent.setAction(Intent.ACTION_GET_CONTENT);
+ Intent chooser = Intent.createChooser(attachFileIntent,
+ getString(R.string.attach_file));
+ startActivityForResult(chooser, REQUEST_CHOOSE_FILE);
+ }
+ });
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode,
+ final Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ Log.d("xmppService","on activity result");
+ if (resultCode == RESULT_OK) {
+ if (requestCode == REQUEST_CHOOSE_FILE) {
+ Log.d("xmppService","bla");
+ this.avatarUri = data.getData();
+ }
+ }
+ }
+
+ @Override
+ protected void onBackendConnected() {
+ Log.d("xmppService","on backend connected");
+ if (this.avatarUri == null) {
+ avatarUri = PhoneHelper.getSefliUri(getApplicationContext());
+ }
+ loadImageIntoPreview(avatarUri);
+ String explainText = getString(R.string.publish_avatar_explanation,"daniel@gultsch.de");
+ this.explanation.setText(explainText);
+ }
+
+ protected void loadImageIntoPreview(Uri uri) {
+ Bitmap bm = xmppConnectionService.getFileBackend().cropCenterSquare(uri, 384);
+ this.avatar.setImageBitmap(bm);
+ enablePublishButton();
+ }
+
+ protected void enablePublishButton() {
+ this.publishButton.setEnabled(true);
+ this.publishButton.setTextColor(getPrimaryTextColor());
+ }
+
+}