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
|
@ -36,6 +36,8 @@ dependencies {
|
||||||
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
|
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
|
||||||
implementation 'me.dm7.barcodescanner:zxing:1.9'
|
implementation 'me.dm7.barcodescanner:zxing:1.9'
|
||||||
implementation 'com.android.support:cardview-v7:27.1.1'
|
implementation 'com.android.support:cardview-v7:27.1.1'
|
||||||
|
implementation 'com.github.esafirm.android-image-picker:imagepicker:1.13.0'
|
||||||
|
compile 'com.github.avito-tech:krop:3e65e12'
|
||||||
implementation 'com.android.support:support-v4:27.1.1'
|
implementation 'com.android.support:support-v4:27.1.1'
|
||||||
implementation 'com.mattprecious.swirl:swirl:1.0.0'
|
implementation 'com.mattprecious.swirl:swirl:1.0.0'
|
||||||
implementation 'com.madgag.spongycastle:core:1.56.0.0'
|
implementation 'com.madgag.spongycastle:core:1.56.0.0'
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package me.impy.aegis.ui;
|
package me.impy.aegis.ui;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.ArrayRes;
|
import android.support.annotation.ArrayRes;
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
|
@ -21,6 +24,10 @@ import android.widget.RelativeLayout;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
|
||||||
import com.amulyakhare.textdrawable.TextDrawable;
|
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.R;
|
||||||
import me.impy.aegis.crypto.KeyInfo;
|
import me.impy.aegis.crypto.KeyInfo;
|
||||||
|
@ -50,6 +57,8 @@ public class EditProfileActivity extends AegisActivity {
|
||||||
private Spinner _spinnerDigits;
|
private Spinner _spinnerDigits;
|
||||||
private SpinnerItemSelectedListener _selectedListener = new SpinnerItemSelectedListener();
|
private SpinnerItemSelectedListener _selectedListener = new SpinnerItemSelectedListener();
|
||||||
|
|
||||||
|
private KropView _kropView;
|
||||||
|
|
||||||
private RelativeLayout _advancedSettingsHeader;
|
private RelativeLayout _advancedSettingsHeader;
|
||||||
private RelativeLayout _advancedSettings;
|
private RelativeLayout _advancedSettings;
|
||||||
|
|
||||||
|
@ -74,6 +83,7 @@ public class EditProfileActivity extends AegisActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
_iconView = findViewById(R.id.profile_drawable);
|
_iconView = findViewById(R.id.profile_drawable);
|
||||||
|
_kropView = findViewById(R.id.krop_view);
|
||||||
_textName = findViewById(R.id.text_name);
|
_textName = findViewById(R.id.text_name);
|
||||||
_textIssuer = findViewById(R.id.text_issuer);
|
_textIssuer = findViewById(R.id.text_issuer);
|
||||||
_textPeriod = findViewById(R.id.text_period);
|
_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 -> {
|
_advancedSettingsHeader.setOnClickListener(v -> {
|
||||||
openAdvancedSettings();
|
openAdvancedSettings();
|
||||||
});
|
});
|
||||||
|
@ -258,6 +286,20 @@ public class EditProfileActivity extends AegisActivity {
|
||||||
finish();
|
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() {
|
private boolean onSave() {
|
||||||
if (_textSecret.length() == 0) {
|
if (_textSecret.length() == 0) {
|
||||||
onError("Secret is a required field.");
|
onError("Secret is a required field.");
|
||||||
|
|
|
@ -16,18 +16,28 @@
|
||||||
android:layout_height="250dp"
|
android:layout_height="250dp"
|
||||||
android:background="@color/colorPrimary">
|
android:background="@color/colorPrimary">
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="200dp"
|
|
||||||
android:paddingTop="100dp"
|
|
||||||
android:background="@color/colorPrimary">
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
android:id="@+id/profile_drawable"
|
||||||
android:layout_width="100dp"
|
android:layout_width="100dp"
|
||||||
android:layout_height="100dp"
|
android:layout_height="100dp"
|
||||||
android:id="@+id/profile_drawable"
|
android:layout_centerHorizontal="true"
|
||||||
android:scaleType="centerCrop"
|
android:layout_centerVertical="true"
|
||||||
android:layout_centerHorizontal="true"/>
|
android:scaleType="centerCrop" />
|
||||||
</RelativeLayout>
|
|
||||||
|
<com.avito.android.krop.KropView
|
||||||
|
android:id="@+id/krop_view"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:visibility="invisible"
|
||||||
|
app:krop_aspectX="1"
|
||||||
|
app:krop_aspectY="1"
|
||||||
|
app:krop_offset="70dp"
|
||||||
|
app:krop_overlayColor="#aaffffff" >
|
||||||
|
|
||||||
|
</com.avito.android.krop.KropView>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue