copy Avatar Crop patch
This commit is contained in:
commit
40d20b2aed
4 changed files with 32 additions and 16 deletions
|
@ -14,6 +14,9 @@ allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
jcenter()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
maven {
|
||||||
|
url 'http://lorenzo.villani.me/android-cropimage/'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +30,7 @@ repositories {
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':libs:openpgp-api-lib')
|
compile project(':libs:openpgp-api-lib')
|
||||||
compile project(':libs:MemorizingTrustManager')
|
compile project(':libs:MemorizingTrustManager')
|
||||||
|
compile 'com.soundcloud.android:android-crop:1.0.1@aar'
|
||||||
compile 'com.android.support:support-v13:23.0.1'
|
compile 'com.android.support:support-v13:23.0.1'
|
||||||
compile 'org.bouncycastle:bcprov-jdk15on:1.52'
|
compile 'org.bouncycastle:bcprov-jdk15on:1.52'
|
||||||
compile 'org.bouncycastle:bcmail-jdk15on:1.52'
|
compile 'org.bouncycastle:bcmail-jdk15on:1.52'
|
||||||
|
|
|
@ -169,6 +169,7 @@
|
||||||
android:theme="@style/ConversationsTheme"
|
android:theme="@style/ConversationsTheme"
|
||||||
android:label="@string/title_activity_updater" >
|
android:label="@string/title_activity_updater" >
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity android:name="com.soundcloud.android.crop.CropImageActivity" />
|
||||||
<service android:name=".services.UpdaterWebService" />
|
<service android:name=".services.UpdaterWebService" />
|
||||||
<service android:name=".services.CheckAppVersionService" />
|
<service android:name=".services.CheckAppVersionService" />
|
||||||
<service android:name=".services.ExportLogsService" />
|
<service android:name=".services.ExportLogsService" />
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
package eu.siacs.conversations.ui;
|
package eu.siacs.conversations.ui;
|
||||||
|
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.provider.MediaStore;
|
||||||
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;
|
||||||
|
@ -13,6 +17,12 @@ import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.soundcloud.android.crop.Crop;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import eu.siacs.conversations.Config;
|
import eu.siacs.conversations.Config;
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
import eu.siacs.conversations.entities.Account;
|
import eu.siacs.conversations.entities.Account;
|
||||||
|
@ -32,6 +42,7 @@ public class PublishProfilePictureActivity extends XmppActivity {
|
||||||
private Button cancelButton;
|
private Button cancelButton;
|
||||||
private Button publishButton;
|
private Button publishButton;
|
||||||
|
|
||||||
|
final static int REQUEST_CROP_PICTURE = 92374;
|
||||||
private Uri avatarUri;
|
private Uri avatarUri;
|
||||||
private Uri defaultUri;
|
private Uri defaultUri;
|
||||||
private OnLongClickListener backToDefaultListener = new OnLongClickListener() {
|
private OnLongClickListener backToDefaultListener = new OnLongClickListener() {
|
||||||
|
@ -129,12 +140,7 @@ public class PublishProfilePictureActivity extends XmppActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Intent attachFileIntent = new Intent();
|
Crop.pickImage(PublishProfilePictureActivity.this);
|
||||||
attachFileIntent.setType("image/*");
|
|
||||||
attachFileIntent.setAction(Intent.ACTION_GET_CONTENT);
|
|
||||||
Intent chooser = Intent.createChooser(attachFileIntent,
|
|
||||||
getString(R.string.attach_file));
|
|
||||||
startActivityForResult(chooser, REQUEST_CHOOSE_FILE);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.defaultUri = PhoneHelper.getSefliUri(getApplicationContext());
|
this.defaultUri = PhoneHelper.getSefliUri(getApplicationContext());
|
||||||
|
@ -144,13 +150,13 @@ public class PublishProfilePictureActivity extends XmppActivity {
|
||||||
protected void onActivityResult(int requestCode, int resultCode,
|
protected void onActivityResult(int requestCode, int resultCode,
|
||||||
final Intent data) {
|
final Intent data) {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK && requestCode == Crop.REQUEST_PICK) {
|
||||||
if (requestCode == REQUEST_CHOOSE_FILE) {
|
Uri destination = Uri.fromFile(new File(getCacheDir(), "croppedAvatar"));
|
||||||
this.avatarUri = data.getData();
|
Crop.of(data.getData(), destination).withMaxSize(Config.AVATAR_SIZE, Config.AVATAR_SIZE).asSquare().start(PublishProfilePictureActivity.this);
|
||||||
if (xmppConnectionServiceBound) {
|
}
|
||||||
loadImageIntoPreview(this.avatarUri);
|
if (requestCode == Crop.REQUEST_CROP) {
|
||||||
}
|
this.avatarUri = Uri.fromFile(new File(getCacheDir(), "croppedAvatar"));
|
||||||
}
|
loadImageIntoPreview(this.avatarUri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,8 +224,13 @@ public class PublishProfilePictureActivity extends XmppActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void loadImageIntoPreview(Uri uri) {
|
protected void loadImageIntoPreview(Uri uri) {
|
||||||
Bitmap bm = xmppConnectionService.getFileBackend().cropCenterSquare(
|
Bitmap bm = null;
|
||||||
uri, Config.AVATAR_SIZE);
|
try{
|
||||||
|
bm = MediaStore.Images.Media.getBitmap(this.getContentResolver(), uri);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
if (bm == null) {
|
if (bm == null) {
|
||||||
disablePublishButton();
|
disablePublishButton();
|
||||||
this.hintOrWarning.setTextColor(getWarningTextColor());
|
this.hintOrWarning.setTextColor(getWarningTextColor());
|
||||||
|
@ -261,5 +272,4 @@ public class PublishProfilePictureActivity extends XmppActivity {
|
||||||
public void refreshUiReal() {
|
public void refreshUiReal() {
|
||||||
//nothing to do. This Activity doesn't implement any listeners
|
//nothing to do. This Activity doesn't implement any listeners
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -314,6 +314,7 @@
|
||||||
\n\nhttps://github.com/kyleduo/SwitchButton\n(Apache License, Version 2.0)
|
\n\nhttps://github.com/kyleduo/SwitchButton\n(Apache License, Version 2.0)
|
||||||
\n\nhttps://github.com/WhisperSystems/libaxolotl-java\n(GPLv3)
|
\n\nhttps://github.com/WhisperSystems/libaxolotl-java\n(GPLv3)
|
||||||
\n\nhttps://github.com/vinc3m1/RoundedImageView\n(Apache License, Version 2.0)
|
\n\nhttps://github.com/vinc3m1/RoundedImageView\n(Apache License, Version 2.0)
|
||||||
|
\n\nhttps://github.com/jdamcd/android-crop\n(Apache License, Version 2.0)
|
||||||
</string>
|
</string>
|
||||||
<string name="title_pref_quiet_hours">Quiet Hours</string>
|
<string name="title_pref_quiet_hours">Quiet Hours</string>
|
||||||
<string name="title_pref_quiet_hours_start_time">Start time</string>
|
<string name="title_pref_quiet_hours_start_time">Start time</string>
|
||||||
|
|
Reference in a new issue