Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xabber-android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
xabber-android
Commits
282ac0b1
Commit
282ac0b1
authored
Aug 03, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First implementation of avatar select using jdamcd/android-crop library.
parent
d1ffe032
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
8 deletions
+47
-8
build.gradle
app/build.gradle
+2
-0
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+3
-0
AccountInfoEditor.java
...rc/main/java/com/xabber/android/ui/AccountInfoEditor.java
+8
-0
AccountInfoEditorFragment.java
...java/com/xabber/android/ui/AccountInfoEditorFragment.java
+34
-8
No files found.
app/build.gradle
View file @
282ac0b1
...
...
@@ -71,4 +71,6 @@ dependencies {
compile
"org.igniterealtime.smack:smack-tcp:$smackVersion"
compile
project
(
'otr4j'
)
compile
project
(
'MemorizingTrustManager'
)
compile
'com.soundcloud.android:android-crop:1.0.0@aar'
}
app/src/main/AndroidManifest.xml
View file @
282ac0b1
...
...
@@ -442,6 +442,9 @@
<activity
android:name=
"de.duenndns.ssl.MemorizingActivity"
/>
<activity
android:name=
"com.soundcloud.android.crop.CropImageActivity"
/>
<receiver
android:name=
".receiver.GoAwayReceiver"
/>
<receiver
android:name=
".receiver.GoXaReceiver"
/>
<receiver
android:name=
".receiver.ComposingPausedReceiver"
/>
...
...
app/src/main/java/com/xabber/android/ui/AccountInfoEditor.java
View file @
282ac0b1
...
...
@@ -12,6 +12,7 @@ import android.view.WindowManager;
import
com.xabber.android.R
;
import
com.xabber.android.data.Application
;
import
com.xabber.android.data.LogManager
;
import
com.xabber.android.data.account.AccountManager
;
import
com.xabber.android.data.account.OnAccountChangedListener
;
import
com.xabber.android.data.intent.EntityIntentBuilder
;
...
...
@@ -130,4 +131,11 @@ public class AccountInfoEditor extends ManagedActivity implements OnAccountChang
return
super
.
onOptionsItemSelected
(
item
);
}
}
@Override
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
getFragmentManager
().
findFragmentById
(
R
.
id
.
fragment_container
).
onActivityResult
(
requestCode
,
resultCode
,
data
);
}
}
app/src/main/java/com/xabber/android/ui/AccountInfoEditorFragment.java
View file @
282ac0b1
...
...
@@ -14,6 +14,7 @@ import android.widget.ImageView;
import
android.widget.LinearLayout
;
import
android.widget.Toast
;
import
com.soundcloud.android.crop.Crop
;
import
com.xabber.android.R
;
import
com.xabber.android.data.Application
;
import
com.xabber.android.data.LogManager
;
...
...
@@ -30,6 +31,7 @@ import org.jivesoftware.smackx.vcardtemp.packet.VCard;
import
org.xmlpull.v1.XmlPullParserException
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStream
;
...
...
@@ -200,21 +202,45 @@ public class AccountInfoEditorFragment extends Fragment implements OnVCardSaveLi
}
private
void
changeAvatar
()
{
Intent
pickAvatar
=
new
Intent
(
Intent
.
ACTION_PICK
,
android
.
provider
.
MediaStore
.
Images
.
Media
.
EXTERNAL_CONTENT_URI
);
startActivityForResult
(
pickAvatar
,
1
);
// Intent pickAvatar = new Intent(Intent.ACTION_PICK,
// android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
// startActivityForResult(pickAvatar, 1);
Crop
.
pickImage
(
getActivity
());
}
@Override
public
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
if
(
requestCode
==
1
&&
resultCode
==
Activity
.
RESULT_OK
)
{
imageUri
=
data
.
getData
();
avatar
.
setImageURI
(
imageUri
);
public
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
result
)
{
LogManager
.
i
(
this
,
"onActivityResult"
);
// super.onActivityResult(requestCode, resultCode, data);
// if (requestCode == 1 && resultCode == Activity.RESULT_OK) {
// imageUri = data.getData();
// avatar.setImageURI(imageUri);
// }
if
(
requestCode
==
Crop
.
REQUEST_PICK
&&
resultCode
==
Activity
.
RESULT_OK
)
{
beginCrop
(
result
.
getData
());
}
else
if
(
requestCode
==
Crop
.
REQUEST_CROP
)
{
handleCrop
(
resultCode
,
result
);
}
}
private
void
beginCrop
(
Uri
source
)
{
imageUri
=
Uri
.
fromFile
(
new
File
(
getActivity
().
getCacheDir
(),
"cropped"
));
Crop
.
of
(
source
,
imageUri
).
asSquare
().
start
(
getActivity
());
}
private
void
handleCrop
(
int
resultCode
,
Intent
result
)
{
if
(
resultCode
==
Activity
.
RESULT_OK
)
{
avatar
.
setImageURI
(
Crop
.
getOutput
(
result
));
}
else
if
(
resultCode
==
Crop
.
RESULT_ERROR
)
{
Toast
.
makeText
(
getActivity
(),
Crop
.
getError
(
result
).
getMessage
(),
Toast
.
LENGTH_SHORT
).
show
();
}
}
public
static
byte
[]
getBytes
(
InputStream
inputStream
)
throws
IOException
{
ByteArrayOutputStream
byteBuffer
=
new
ByteArrayOutputStream
();
int
bufferSize
=
1024
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment