error messages for publish avatar

This commit is contained in:
iNPUTmice 2014-08-05 12:21:08 +02:00
parent f8b4d5f338
commit 9aba9a4059
4 changed files with 37 additions and 12 deletions

View file

@ -69,7 +69,8 @@
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:layout_above="@+id/button_bar" android:layout_above="@+id/button_bar"
android:layout_below="@+id/hint" android:layout_below="@+id/hint"
android:layout_centerHorizontal="true" android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="vertical" android:orientation="vertical"
android:paddingLeft="8dp" android:paddingLeft="8dp"
@ -83,12 +84,14 @@
android:textSize="18sp"/> android:textSize="18sp"/>
<TextView <TextView
android:id="@+id/hint_or_warning"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/publish_avatar_explanation" android:text="@string/publish_avatar_explanation"
android:textColor="@color/primarytext" android:textColor="@color/primarytext"
android:textSize="14sp" /> android:textSize="14sp"
android:minLines="3" />
</LinearLayout> </LinearLayout>
</RelativeLayout> </RelativeLayout>

View file

@ -271,4 +271,7 @@
<string name="publish_avatar">Publish avatar</string> <string name="publish_avatar">Publish avatar</string>
<string name="touch_to_choose_picture">Touch avatar to select picture from gallary</string> <string name="touch_to_choose_picture">Touch avatar to select picture from gallary</string>
<string name="publish_avatar_explanation">Please note: Everyone subscribed to your presence updates will be allowed to see this picture.</string> <string name="publish_avatar_explanation">Please note: Everyone subscribed to your presence updates will be allowed to see this picture.</string>
<string name="publishing">Publishing&#8230;</string>
<string name="error_publish_avatar_server_reject">The server rejected your publication</string>
<string name="error_publish_avatar_converting">Something went wrong while converting your picture</string>
</resources> </resources>

View file

@ -1216,17 +1216,17 @@ public class XmppConnectionService extends Service {
if (result.getType() == IqPacket.TYPE_RESULT) { if (result.getType() == IqPacket.TYPE_RESULT) {
callback.success(avatar); callback.success(avatar);
} else { } else {
callback.error(R.string.error, avatar); callback.error(R.string.error_publish_avatar_server_reject, avatar);
} }
} }
}); });
} else { } else {
callback.error(R.string.error, avatar); callback.error(R.string.error_publish_avatar_server_reject, avatar);
} }
} }
}); });
} else { } else {
callback.error(R.string.error, null); callback.error(R.string.error_publish_avatar_converting, null);
} }
} }

View file

@ -22,6 +22,7 @@ public class PublishProfilePictureActivity extends XmppActivity {
private ImageView avatar; private ImageView avatar;
private TextView accountTextView; private TextView accountTextView;
private TextView hintOrWarning;
private Button cancelButton; private Button cancelButton;
private Button publishButton; private Button publishButton;
@ -33,19 +34,32 @@ public class PublishProfilePictureActivity extends XmppActivity {
@Override @Override
public void success(Avatar object) { public void success(Avatar object) {
runOnUiThread(new Runnable() {
@Override
public void run() {
finish(); finish();
} }
});
}
@Override @Override
public void error(int errorCode, Avatar object) { public void error(final int errorCode, Avatar object) {
// TODO Auto-generated method stub runOnUiThread(new Runnable() {
@Override
public void run() {
hintOrWarning.setText(errorCode);
hintOrWarning.setTextColor(getWarningTextColor());
publishButton.setText(R.string.publish_avatar);
enablePublishButton();
}
});
} }
@Override @Override
public void userInputRequried(PendingIntent pi, Avatar object) { public void userInputRequried(PendingIntent pi, Avatar object) {
// TODO Auto-generated method stub
} }
}; };
@ -57,11 +71,13 @@ public class PublishProfilePictureActivity extends XmppActivity {
this.cancelButton = (Button) findViewById(R.id.cancel_button); this.cancelButton = (Button) findViewById(R.id.cancel_button);
this.publishButton = (Button) findViewById(R.id.publish_button); this.publishButton = (Button) findViewById(R.id.publish_button);
this.accountTextView = (TextView) findViewById(R.id.account); this.accountTextView = (TextView) findViewById(R.id.account);
this.hintOrWarning = (TextView) findViewById(R.id.hint_or_warning);
this.publishButton.setOnClickListener(new OnClickListener() { this.publishButton.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (avatarUri != null) { if (avatarUri != null) {
publishButton.setText(R.string.publishing);
disablePublishButton(); disablePublishButton();
xmppConnectionService.publishAvatar(account, avatarUri, xmppConnectionService.publishAvatar(account, avatarUri,
avatarPublication); avatarPublication);
@ -133,6 +149,9 @@ public class PublishProfilePictureActivity extends XmppActivity {
uri, 384); uri, 384);
this.avatar.setImageBitmap(bm); this.avatar.setImageBitmap(bm);
enablePublishButton(); enablePublishButton();
this.publishButton.setText(R.string.publish_avatar);
this.hintOrWarning.setText(R.string.publish_avatar_explanation);
this.hintOrWarning.setTextColor(getPrimaryTextColor());
} }
protected void enablePublishButton() { protected void enablePublishButton() {