ability to bring default picture back with long press in publish avatar

This commit is contained in:
iNPUTmice 2014-08-09 09:38:52 +02:00
parent f6615843f9
commit 96a41b5b51
3 changed files with 36 additions and 6 deletions

View File

@ -29,6 +29,15 @@
android:text="@string/touch_to_choose_picture" android:text="@string/touch_to_choose_picture"
android:textColor="@color/secondarytext" /> android:textColor="@color/secondarytext" />
<TextView
android:id="@+id/secondary_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/hint"
android:layout_centerHorizontal="true"
android:text="@string/or_long_press_for_default"
android:textColor="@color/secondarytext" />
<LinearLayout <LinearLayout
android:id="@+id/button_bar" android:id="@+id/button_bar"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -68,7 +77,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
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/secondary_hint"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:gravity="center_vertical" android:gravity="center_vertical"

View File

@ -275,4 +275,5 @@
<string name="error_publish_avatar_server_reject">The server rejected your publication</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> <string name="error_publish_avatar_converting">Something went wrong while converting your picture</string>
<string name="error_saving_avatar">Could not save avatar to disk</string> <string name="error_saving_avatar">Could not save avatar to disk</string>
<string name="or_long_press_for_default">(Or long press to bring back default)</string>
</resources> </resources>

View File

@ -5,10 +5,10 @@ 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.util.Log;
import android.view.MenuItem; 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.widget.Button; import android.widget.Button;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
@ -24,10 +24,12 @@ public class PublishProfilePictureActivity extends XmppActivity {
private ImageView avatar; private ImageView avatar;
private TextView accountTextView; private TextView accountTextView;
private TextView hintOrWarning; private TextView hintOrWarning;
private TextView secondaryHint;
private Button cancelButton; private Button cancelButton;
private Button publishButton; private Button publishButton;
private Uri avatarUri; private Uri avatarUri;
private Uri defaultUri;
private Account account; private Account account;
@ -64,6 +66,16 @@ public class PublishProfilePictureActivity extends XmppActivity {
} }
}; };
private OnLongClickListener backToDefaultListener = new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
avatarUri = defaultUri;
loadImageIntoPreview(defaultUri);
return true;
}
};
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -73,6 +85,7 @@ public class PublishProfilePictureActivity extends XmppActivity {
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.hintOrWarning = (TextView) findViewById(R.id.hint_or_warning);
this.secondaryHint = (TextView) findViewById(R.id.secondary_hint);
this.publishButton.setOnClickListener(new OnClickListener() { this.publishButton.setOnClickListener(new OnClickListener() {
@Override @Override
@ -104,6 +117,7 @@ public class PublishProfilePictureActivity extends XmppActivity {
startActivityForResult(chooser, REQUEST_CHOOSE_FILE); startActivityForResult(chooser, REQUEST_CHOOSE_FILE);
} }
}); });
this.defaultUri = PhoneHelper.getSefliUri(getApplicationContext());
} }
@Override @Override
@ -139,10 +153,9 @@ public class PublishProfilePictureActivity extends XmppActivity {
this.avatar.setImageBitmap(this.account.getImage( this.avatar.setImageBitmap(this.account.getImage(
getApplicationContext(), 384)); getApplicationContext(), 384));
} else { } else {
this.avatarUri = PhoneHelper if (this.defaultUri != null) {
.getSefliUri(getApplicationContext()); this.avatarUri = this.defaultUri;
if (this.avatarUri != null) { loadImageIntoPreview(this.defaultUri);
loadImageIntoPreview(this.avatarUri);
} }
} }
} else { } else {
@ -162,6 +175,13 @@ public class PublishProfilePictureActivity extends XmppActivity {
this.publishButton.setText(R.string.publish_avatar); this.publishButton.setText(R.string.publish_avatar);
this.hintOrWarning.setText(R.string.publish_avatar_explanation); this.hintOrWarning.setText(R.string.publish_avatar_explanation);
this.hintOrWarning.setTextColor(getPrimaryTextColor()); this.hintOrWarning.setTextColor(getPrimaryTextColor());
if (this.defaultUri != null && uri.equals(this.defaultUri)) {
this.secondaryHint.setVisibility(View.INVISIBLE);
this.avatar.setOnLongClickListener(null);
} else {
this.secondaryHint.setVisibility(View.VISIBLE);
this.avatar.setOnLongClickListener(this.backToDefaultListener );
}
} }
protected void enablePublishButton() { protected void enablePublishButton() {