changed workflow on inital avatar publication

This commit is contained in:
Daniel Gultsch 2014-08-23 20:00:05 +02:00
parent f7437ecc36
commit d504daec16
3 changed files with 40 additions and 11 deletions

View file

@ -282,5 +282,6 @@
<string name="next">Next</string> <string name="next">Next</string>
<string name="server_info_session_established">Current session established</string> <string name="server_info_session_established">Current session established</string>
<string name="additional_information">Additional Information</string> <string name="additional_information">Additional Information</string>
<string name="skip">Skip</string>
</resources> </resources>

View file

@ -165,6 +165,7 @@ public class EditAccountActivity extends XmppActivity {
intent = new Intent(getApplicationContext(), intent = new Intent(getApplicationContext(),
PublishProfilePictureActivity.class); PublishProfilePictureActivity.class);
intent.putExtra("account", mAccount.getJid()); intent.putExtra("account", mAccount.getJid());
intent.putExtra("setup", true);
} }
startActivity(intent); startActivity(intent);
finish(); finish();

View file

@ -5,7 +5,6 @@ import android.content.Intent;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener; import android.view.View.OnLongClickListener;
@ -35,6 +34,8 @@ public class PublishProfilePictureActivity extends XmppActivity {
private boolean support = false; private boolean support = false;
private boolean mInitialAccountSetup;
private UiCallback<Avatar> avatarPublication = new UiCallback<Avatar>() { private UiCallback<Avatar> avatarPublication = new UiCallback<Avatar>() {
@Override @Override
@ -43,6 +44,10 @@ public class PublishProfilePictureActivity extends XmppActivity {
@Override @Override
public void run() { public void run() {
if (mInitialAccountSetup) {
startActivity(new Intent(getApplicationContext(),
StartConversationActivity.class));
}
finish(); finish();
} }
}); });
@ -104,6 +109,10 @@ public class PublishProfilePictureActivity extends XmppActivity {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (mInitialAccountSetup) {
startActivity(new Intent(getApplicationContext(),
StartConversationActivity.class));
}
finish(); finish();
} }
}); });
@ -143,10 +152,12 @@ public class PublishProfilePictureActivity extends XmppActivity {
if (jid != null) { if (jid != null) {
this.account = xmppConnectionService.findAccountByJid(jid); this.account = xmppConnectionService.findAccountByJid(jid);
if (this.account.getXmppConnection() != null) { if (this.account.getXmppConnection() != null) {
this.support = this.account.getXmppConnection().getFeatures().pubsub(); this.support = this.account.getXmppConnection()
.getFeatures().pubsub();
} }
if (this.avatarUri == null) { if (this.avatarUri == null) {
if (this.account.getAvatar() != null || this.defaultUri == null) { if (this.account.getAvatar() != null
|| this.defaultUri == null) {
this.avatar.setImageBitmap(this.account.getImage( this.avatar.setImageBitmap(this.account.getImage(
getApplicationContext(), 384)); getApplicationContext(), 384));
if (this.defaultUri != null) { if (this.defaultUri != null) {
@ -156,8 +167,10 @@ public class PublishProfilePictureActivity extends XmppActivity {
this.secondaryHint.setVisibility(View.INVISIBLE); this.secondaryHint.setVisibility(View.INVISIBLE);
} }
if (!support) { if (!support) {
this.hintOrWarning.setTextColor(getWarningTextColor()); this.hintOrWarning
this.hintOrWarning.setText(R.string.error_publish_avatar_no_server_support); .setTextColor(getWarningTextColor());
this.hintOrWarning
.setText(R.string.error_publish_avatar_no_server_support);
} }
} else { } else {
this.avatarUri = this.defaultUri; this.avatarUri = this.defaultUri;
@ -173,13 +186,26 @@ public class PublishProfilePictureActivity extends XmppActivity {
} }
@Override
protected void onStart() {
super.onStart();
if (getIntent() != null) {
this.mInitialAccountSetup = getIntent().getBooleanExtra("setup",
false);
}
if (this.mInitialAccountSetup) {
this.cancelButton.setText(R.string.skip);
}
}
protected void loadImageIntoPreview(Uri uri) { protected void loadImageIntoPreview(Uri uri) {
Bitmap bm = xmppConnectionService.getFileBackend().cropCenterSquare( Bitmap bm = xmppConnectionService.getFileBackend().cropCenterSquare(
uri, 384); uri, 384);
if (bm==null) { if (bm == null) {
disablePublishButton(); disablePublishButton();
this.hintOrWarning.setTextColor(getWarningTextColor()); this.hintOrWarning.setTextColor(getWarningTextColor());
this.hintOrWarning.setText(R.string.error_publish_avatar_converting); this.hintOrWarning
.setText(R.string.error_publish_avatar_converting);
return; return;
} }
this.avatar.setImageBitmap(bm); this.avatar.setImageBitmap(bm);
@ -191,12 +217,13 @@ public class PublishProfilePictureActivity extends XmppActivity {
} else { } else {
disablePublishButton(); disablePublishButton();
this.hintOrWarning.setTextColor(getWarningTextColor()); this.hintOrWarning.setTextColor(getWarningTextColor());
this.hintOrWarning.setText(R.string.error_publish_avatar_no_server_support); this.hintOrWarning
.setText(R.string.error_publish_avatar_no_server_support);
} }
if (this.defaultUri != null && uri.equals(this.defaultUri)) { if (this.defaultUri != null && uri.equals(this.defaultUri)) {
this.secondaryHint.setVisibility(View.INVISIBLE); this.secondaryHint.setVisibility(View.INVISIBLE);
this.avatar.setOnLongClickListener(null); this.avatar.setOnLongClickListener(null);
} else if (this.defaultUri != null ) { } else if (this.defaultUri != null) {
this.secondaryHint.setVisibility(View.VISIBLE); this.secondaryHint.setVisibility(View.VISIBLE);
this.avatar.setOnLongClickListener(this.backToDefaultListener); this.avatar.setOnLongClickListener(this.backToDefaultListener);
} }