mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-14 14:02:49 +00:00
Started working on custom profile images
This commit is contained in:
parent
8b280ddbb0
commit
04e6e36811
3 changed files with 63 additions and 9 deletions
|
@ -1,6 +1,9 @@
|
|||
package me.impy.aegis.ui;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.ArrayRes;
|
||||
import android.support.v7.app.ActionBar;
|
||||
|
@ -21,6 +24,10 @@ import android.widget.RelativeLayout;
|
|||
import android.widget.Spinner;
|
||||
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import com.avito.android.krop.KropView;
|
||||
import com.esafirm.imagepicker.features.ImagePicker;
|
||||
import com.esafirm.imagepicker.features.ReturnMode;
|
||||
import com.esafirm.imagepicker.model.Image;
|
||||
|
||||
import me.impy.aegis.R;
|
||||
import me.impy.aegis.crypto.KeyInfo;
|
||||
|
@ -50,6 +57,8 @@ public class EditProfileActivity extends AegisActivity {
|
|||
private Spinner _spinnerDigits;
|
||||
private SpinnerItemSelectedListener _selectedListener = new SpinnerItemSelectedListener();
|
||||
|
||||
private KropView _kropView;
|
||||
|
||||
private RelativeLayout _advancedSettingsHeader;
|
||||
private RelativeLayout _advancedSettings;
|
||||
|
||||
|
@ -74,6 +83,7 @@ public class EditProfileActivity extends AegisActivity {
|
|||
}
|
||||
|
||||
_iconView = findViewById(R.id.profile_drawable);
|
||||
_kropView = findViewById(R.id.krop_view);
|
||||
_textName = findViewById(R.id.text_name);
|
||||
_textIssuer = findViewById(R.id.text_issuer);
|
||||
_textPeriod = findViewById(R.id.text_period);
|
||||
|
@ -118,6 +128,24 @@ public class EditProfileActivity extends AegisActivity {
|
|||
}
|
||||
});
|
||||
|
||||
ImagePicker imagePicker = ImagePicker.create(EditProfileActivity.this)
|
||||
.returnMode(ReturnMode.ALL) // set whether pick and / or camera action should return immediate result or not.
|
||||
.folderMode(true) // folder mode (false by default)
|
||||
.toolbarFolderTitle("Folder") // folder selection title
|
||||
.toolbarImageTitle("Tap to select") // image selection title
|
||||
.toolbarArrowColor(Color.BLACK) // Toolbar 'up' arrow color
|
||||
.single() // single mode
|
||||
.showCamera(false) // show camera or not (true by default)
|
||||
.imageDirectory("Camera");
|
||||
|
||||
// Open ImagePicker when clicking on the icon
|
||||
_iconView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
imagePicker.start(); // start image picker activity with request code
|
||||
}
|
||||
});
|
||||
|
||||
_advancedSettingsHeader.setOnClickListener(v -> {
|
||||
openAdvancedSettings();
|
||||
});
|
||||
|
@ -258,6 +286,20 @@ public class EditProfileActivity extends AegisActivity {
|
|||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, final int resultCode, Intent data) {
|
||||
if (ImagePicker.shouldHandle(requestCode, resultCode, data)) {
|
||||
// or get a single image only
|
||||
Image image = ImagePicker.getFirstImageOrNull(data);
|
||||
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
|
||||
Bitmap bitmap = BitmapFactory.decodeFile(image.getPath(),bmOptions);
|
||||
_kropView.setBitmap(bitmap);
|
||||
_kropView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
private boolean onSave() {
|
||||
if (_textSecret.length() == 0) {
|
||||
onError("Secret is a required field.");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue