Merge remote-tracking branch 'origin/custom-images'

This commit is contained in:
Alexander Bakker 2018-06-07 12:27:42 +02:00
commit 04dbb71cd7
17 changed files with 302 additions and 93 deletions

2
.idea/misc.xml generated
View file

@ -24,7 +24,7 @@
</value> </value>
</option> </option>
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

View file

@ -32,10 +32,13 @@ dependencies {
implementation 'com.android.support:recyclerview-v7:27.1.1' implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1' implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1' implementation 'com.android.support:design:27.1.1'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.takisoft.fix:preference-v7:27.1.1.1' implementation 'com.takisoft.fix:preference-v7:27.1.1.1'
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'
implementation '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.58.0.0' implementation 'com.madgag.spongycastle:core:1.58.0.0'

View file

@ -6,6 +6,7 @@ import org.json.JSONObject;
import java.util.List; import java.util.List;
import me.impy.aegis.encoding.Base64Exception;
import me.impy.aegis.otp.OtpInfoException; import me.impy.aegis.otp.OtpInfoException;
public class Database { public class Database {
@ -43,7 +44,7 @@ public class Database {
entry.deserialize(array.getJSONObject(i)); entry.deserialize(array.getJSONObject(i));
addEntry(entry); addEntry(entry);
} }
} catch (OtpInfoException | JSONException e) { } catch (Base64Exception | OtpInfoException | JSONException e) {
throw new DatabaseException(e); throw new DatabaseException(e);
} }
} }

View file

@ -6,6 +6,8 @@ import org.json.JSONObject;
import java.io.Serializable; import java.io.Serializable;
import java.util.UUID; import java.util.UUID;
import me.impy.aegis.encoding.Base64;
import me.impy.aegis.encoding.Base64Exception;
import me.impy.aegis.otp.OtpInfo; import me.impy.aegis.otp.OtpInfo;
import me.impy.aegis.otp.OtpInfoException; import me.impy.aegis.otp.OtpInfoException;
@ -13,8 +15,8 @@ public class DatabaseEntry implements Serializable {
private UUID _uuid; private UUID _uuid;
private String _name = ""; private String _name = "";
private String _issuer = ""; private String _issuer = "";
private String _icon = "";
private OtpInfo _info; private OtpInfo _info;
private byte[] _icon;
public DatabaseEntry(OtpInfo info) { public DatabaseEntry(OtpInfo info) {
_info = info; _info = info;
@ -36,6 +38,7 @@ public class DatabaseEntry implements Serializable {
obj.put("name", _name); obj.put("name", _name);
obj.put("issuer", _issuer); obj.put("issuer", _issuer);
obj.put("info", _info.toJson()); obj.put("info", _info.toJson());
obj.put("icon", _icon == null ? JSONObject.NULL : Base64.encode(_icon));
} catch (JSONException e) { } catch (JSONException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@ -43,7 +46,7 @@ public class DatabaseEntry implements Serializable {
return obj; return obj;
} }
public void deserialize(JSONObject obj) throws JSONException, OtpInfoException { public void deserialize(JSONObject obj) throws JSONException, OtpInfoException, Base64Exception {
// if there is no uuid, generate a new one // if there is no uuid, generate a new one
if (!obj.has("uuid")) { if (!obj.has("uuid")) {
_uuid = UUID.randomUUID(); _uuid = UUID.randomUUID();
@ -53,6 +56,11 @@ public class DatabaseEntry implements Serializable {
_name = obj.getString("name"); _name = obj.getString("name");
_issuer = obj.getString("issuer"); _issuer = obj.getString("issuer");
_info = OtpInfo.parseJson(obj.getString("type"), obj.getJSONObject("info")); _info = OtpInfo.parseJson(obj.getString("type"), obj.getJSONObject("info"));
String icon = obj.optString("icon", null);
if (icon != null) {
_icon = Base64.decode(icon);
}
} }
public UUID getUUID() { public UUID getUUID() {
@ -67,7 +75,7 @@ public class DatabaseEntry implements Serializable {
return _issuer; return _issuer;
} }
public String getIcon() { public byte[] getIcon() {
return _icon; return _icon;
} }
@ -83,11 +91,11 @@ public class DatabaseEntry implements Serializable {
_issuer = issuer; _issuer = issuer;
} }
public void setIcon(String icon) {
_icon = icon;
}
public void setInfo(OtpInfo info) { public void setInfo(OtpInfo info) {
_info = info; _info = info;
} }
public void setIcon(byte[] icon) {
_icon = icon;
}
} }

View file

@ -1,5 +1,7 @@
package me.impy.aegis.helpers; package me.impy.aegis.helpers;
import android.view.View;
import com.amulyakhare.textdrawable.TextDrawable; import com.amulyakhare.textdrawable.TextDrawable;
import com.amulyakhare.textdrawable.util.ColorGenerator; import com.amulyakhare.textdrawable.util.ColorGenerator;
@ -8,7 +10,7 @@ public class TextDrawableHelper {
} }
public static TextDrawable generate(String text, String fallback) { public static TextDrawable generate(String text, String fallback, View view) {
if (text == null || text.isEmpty()) { if (text == null || text.isEmpty()) {
if (fallback == null || fallback.isEmpty()) { if (fallback == null || fallback.isEmpty()) {
return null; return null;
@ -18,6 +20,8 @@ public class TextDrawableHelper {
ColorGenerator generator = ColorGenerator.MATERIAL; ColorGenerator generator = ColorGenerator.MATERIAL;
int color = generator.getColor(text); int color = generator.getColor(text);
return TextDrawable.builder().buildRound(text.substring(0, 1).toUpperCase(), color); return TextDrawable.builder().beginConfig()
.width(view.getWidth())
.height(view.getHeight()).endConfig().buildRect(text.substring(0, 1).toUpperCase(), color);
} }
} }

View file

@ -1,6 +1,12 @@
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.Canvas;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
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;
@ -22,7 +28,14 @@ import android.widget.Spinner;
import android.widget.TableRow; import android.widget.TableRow;
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 java.io.ByteArrayOutputStream;
import de.hdodenhof.circleimageview.CircleImageView;
import me.impy.aegis.R; import me.impy.aegis.R;
import me.impy.aegis.db.DatabaseEntry; import me.impy.aegis.db.DatabaseEntry;
import me.impy.aegis.encoding.Base32; import me.impy.aegis.encoding.Base32;
@ -40,8 +53,9 @@ public class EditEntryActivity extends AegisActivity {
private boolean _isNew = false; private boolean _isNew = false;
private boolean _edited = false; private boolean _edited = false;
private DatabaseEntry _entry; private DatabaseEntry _entry;
private boolean _hasCustomImage = false;
private ImageView _iconView; private CircleImageView _iconView;
private ImageView _saveImageButton;
private EditText _textName; private EditText _textName;
private EditText _textIssuer; private EditText _textIssuer;
@ -57,6 +71,8 @@ public class EditEntryActivity 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;
@ -79,6 +95,8 @@ public class EditEntryActivity extends AegisActivity {
// set up fields // set up fields
_iconView = findViewById(R.id.profile_drawable); _iconView = findViewById(R.id.profile_drawable);
_kropView = findViewById(R.id.krop_view);
_saveImageButton = findViewById(R.id.iv_saveImage);
_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);
@ -97,8 +115,15 @@ public class EditEntryActivity extends AegisActivity {
// fill the fields with values if possible // fill the fields with values if possible
if (_entry != null) { if (_entry != null) {
TextDrawable drawable = TextDrawableHelper.generate(_entry.getIssuer(), _entry.getName()); if (_entry.getIcon() != null) {
byte[] imageBytes = _entry.getIcon();
Bitmap image = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length);
_iconView.setImageBitmap(image);
_hasCustomImage = true;
} else {
TextDrawable drawable = TextDrawableHelper.generate(_entry.getIssuer(), _entry.getName(), _iconView);
_iconView.setImageDrawable(drawable); _iconView.setImageDrawable(drawable);
}
_textName.setText(_entry.getName()); _textName.setText(_entry.getName());
_textIssuer.setText(_entry.getIssuer()); _textIssuer.setText(_entry.getIssuer());
@ -173,6 +198,24 @@ public class EditEntryActivity extends AegisActivity {
} }
}); });
ImagePicker imagePicker = ImagePicker.create(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();
}); });
@ -265,6 +308,10 @@ public class EditEntryActivity extends AegisActivity {
finish(true); finish(true);
}); });
break; break;
case R.id.action_default_image:
TextDrawable drawable = TextDrawableHelper.generate(_entry.getIssuer(), _entry.getName(), _iconView);
_iconView.setImageDrawable(drawable);
_hasCustomImage = false;
default: default:
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
@ -278,6 +325,10 @@ public class EditEntryActivity extends AegisActivity {
if (_isNew) { if (_isNew) {
menu.findItem(R.id.action_delete).setVisible(false); menu.findItem(R.id.action_delete).setVisible(false);
} }
if (!_hasCustomImage) {
menu.findItem(R.id.action_default_image).setVisible(false);
}
return true; return true;
} }
@ -289,6 +340,29 @@ public class EditEntryActivity 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);
_saveImageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
_iconView.setImageBitmap(_kropView.getCroppedBitmap());
_kropView.setVisibility(View.GONE);
_hasCustomImage = true;
}
});
}
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.");
@ -359,6 +433,15 @@ public class EditEntryActivity extends AegisActivity {
entry.setIssuer(_textIssuer.getText().toString()); entry.setIssuer(_textIssuer.getText().toString());
entry.setName(_textName.getText().toString()); entry.setName(_textName.getText().toString());
if (_hasCustomImage) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
drawableToBitmap(_iconView.getDrawable()).compress(Bitmap.CompressFormat.JPEG, 100, stream);
byte[] bitmapdata = stream.toByteArray();
entry.setIcon(bitmapdata);
} else {
entry.setIcon(null);
}
_entry = entry; _entry = entry;
finish(false); finish(false);
return true; return true;
@ -404,9 +487,11 @@ public class EditEntryActivity extends AegisActivity {
@Override @Override
public void afterTextChanged(Editable s) { public void afterTextChanged(Editable s) {
TextDrawable drawable = TextDrawableHelper.generate(_textIssuer.getText().toString(), _textName.getText().toString()); if (!_hasCustomImage) {
TextDrawable drawable = TextDrawableHelper.generate(_textIssuer.getText().toString(), _textName.getText().toString(), _iconView);
_iconView.setImageDrawable(drawable); _iconView.setImageDrawable(drawable);
} }
}
}; };
private class SpinnerItemSelectedListener implements AdapterView.OnItemSelectedListener, View.OnTouchListener { private class SpinnerItemSelectedListener implements AdapterView.OnItemSelectedListener, View.OnTouchListener {
@ -441,4 +526,25 @@ public class EditEntryActivity extends AegisActivity {
} }
return -1; return -1;
} }
public static Bitmap drawableToBitmap(Drawable drawable) {
if (drawable instanceof BitmapDrawable) {
return ((BitmapDrawable) drawable).getBitmap();
}
final int width = !drawable.getBounds().isEmpty() ? drawable
.getBounds().width() : drawable.getIntrinsicWidth();
final int height = !drawable.getBounds().isEmpty() ? drawable
.getBounds().height() : drawable.getIntrinsicHeight();
final Bitmap bitmap = Bitmap.createBitmap(width <= 0 ? 1 : width,
height <= 0 ? 1 : height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable.draw(canvas);
return bitmap;
}
} }

View file

@ -1,6 +1,5 @@
package me.impy.aegis.ui; package me.impy.aegis.ui;
import android.Manifest;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
@ -57,7 +56,9 @@ public class IntroActivity extends AppIntro implements DerivationTask.Callback {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE); getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
} }
setWizardMode(true);
showSkipButton(false); showSkipButton(false);
pager.setPagingEnabled(false);
//showPagerIndicator(false); //showPagerIndicator(false);
setGoBackLock(true); setGoBackLock(true);
@ -68,19 +69,6 @@ public class IntroActivity extends AppIntro implements DerivationTask.Callback {
homeSliderPage.setBgColor(getResources().getColor(R.color.colorPrimary)); homeSliderPage.setBgColor(getResources().getColor(R.color.colorPrimary));
addSlide(AppIntroFragment.newInstance(homeSliderPage)); addSlide(AppIntroFragment.newInstance(homeSliderPage));
SliderPage permSliderPage = new SliderPage();
permSliderPage.setTitle("Permissions");
permSliderPage.setDescription("Aegis needs permission to use your camera in order to scan QR codes. " +
"It also needs access to external storage to able to export the database.");
permSliderPage.setImageDrawable(R.drawable.intro_scanner);
permSliderPage.setBgColor(getResources().getColor(R.color.colorAccent));
addSlide(AppIntroFragment.newInstance(permSliderPage));
askForPermissions(new String[]{
Manifest.permission.CAMERA,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE
}, 2);
_authenticationSlide = new CustomAuthenticationSlide(); _authenticationSlide = new CustomAuthenticationSlide();
_authenticationSlide.setBgColor(getResources().getColor(R.color.colorHeaderSuccess)); _authenticationSlide.setBgColor(getResources().getColor(R.color.colorHeaderSuccess));
addSlide(_authenticationSlide); addSlide(_authenticationSlide);
@ -121,7 +109,7 @@ public class IntroActivity extends AppIntro implements DerivationTask.Callback {
// skip to the last slide if no encryption will be used // skip to the last slide if no encryption will be used
if (cryptType == CustomAuthenticationSlide.CRYPT_TYPE_NONE) { if (cryptType == CustomAuthenticationSlide.CRYPT_TYPE_NONE) {
// TODO: no magic indices // TODO: no magic indices
getPager().setCurrentItem(5); getPager().setCurrentItem(4);
} }
} }
} }

View file

@ -8,8 +8,10 @@ import android.support.v4.app.Fragment;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.RadioButton; import android.widget.RadioButton;
import android.widget.RadioGroup; import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import com.github.paolorotolo.appintro.ISlidePolicy; import com.github.paolorotolo.appintro.ISlidePolicy;
@ -23,6 +25,7 @@ public class CustomAuthenticationSlide extends Fragment implements ISlidePolicy,
public static final int CRYPT_TYPE_PASS = 2; public static final int CRYPT_TYPE_PASS = 2;
public static final int CRYPT_TYPE_FINGER = 3; public static final int CRYPT_TYPE_FINGER = 3;
private Spinner _authenticationSpinner;
private RadioGroup _buttonGroup; private RadioGroup _buttonGroup;
private int _bgColor; private int _bgColor;
@ -38,8 +41,8 @@ public class CustomAuthenticationSlide extends Fragment implements ISlidePolicy,
if (manager != null) { if (manager != null) {
RadioButton button = view.findViewById(R.id.rb_fingerprint); RadioButton button = view.findViewById(R.id.rb_fingerprint);
TextView text = view.findViewById(R.id.text_rb_fingerprint); TextView text = view.findViewById(R.id.text_rb_fingerprint);
button.setVisibility(View.VISIBLE); button.setEnabled(false);
text.setVisibility(View.VISIBLE); text.setEnabled(false);
} }
view.findViewById(R.id.main).setBackgroundColor(_bgColor); view.findViewById(R.id.main).setBackgroundColor(_bgColor);

View file

@ -1,6 +1,10 @@
package me.impy.aegis.ui.views; package me.impy.aegis.ui.views;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.view.View; import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
@ -72,8 +76,14 @@ public class EntryHolder extends RecyclerView.ViewHolder {
_profileIssuer.setText(" - " + entry.getIssuer()); _profileIssuer.setText(" - " + entry.getIssuer());
} }
TextDrawable drawable = TextDrawableHelper.generate(entry.getIssuer(), entry.getName()); if (entry.getIcon() != null) {
byte[] imageBytes = entry.getIcon();
Bitmap image = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length);
_profileDrawable.setImageBitmap(image);
} else {
TextDrawable drawable = TextDrawableHelper.generate(entry.getIssuer(), entry.getName(), _profileDrawable);
_profileDrawable.setImageDrawable(drawable); _profileDrawable.setImageDrawable(drawable);
}
refreshCode(); refreshCode();
} }

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_enabled="false"
android:color="#78efefef"
/>
<item
android:state_enabled="true"
android:color="#efefef"
/>
</selector>

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z"/>
</vector>

View file

@ -0,0 +1,23 @@
<vector android:height="24dp" android:viewportHeight="501.551"
android:viewportWidth="501.551" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#F2F2F2" android:pathData="M480.7,124.3H20.9C9.4,124.3 0,133.7 0,145.2v335.4c0,11.5 9.4,20.9 20.9,20.9h459.8c11.5,0 20.9,-9.4 20.9,-20.9V145.2C501.6,133.7 492.1,124.3 480.7,124.3z"/>
<path android:fillColor="#FFFFFF" android:pathData="M312.4,151.5H189.1c-5.2,0 -9.4,4.2 -9.4,9.4s4.2,9.4 9.4,9.4h124.3c5.2,0 9.4,-4.2 9.4,-9.4C321.8,155.7 317.6,151.5 312.4,151.5z"/>
<path android:fillColor="#FF7058" android:pathData="M198.5,0h104.5v160.9h-104.5z"/>
<path android:fillColor="#84DBFF" android:pathData="M47,194.4h180.8v200.6h-180.8z"/>
<path android:fillColor="#CDD6E0" android:pathData="M277.9,252.9h176.6v24h-176.6z"/>
<path android:fillColor="#CDD6E0" android:pathData="M277.9,311.4h176.6v24h-176.6z"/>
<path android:fillColor="#CDD6E0" android:pathData="M277.9,370.9h176.6v24h-176.6z"/>
<path android:fillColor="#CDD6E0" android:pathData="M48.1,429.5h406.5v24h-406.5z"/>
<path android:fillColor="#F8B64C" android:pathData="M105.4,284a10.4,4.2 78.7,1 0,-4.1 -20.5a10.4,4.2 78.7,1 0,4.1 20.5z"/>
<path android:fillColor="#F8B64C" android:pathData="M175.8,275.1a10.4,4.2 101.3,1 0,-8.2 -1.6a10.4,4.2 101.3,1 0,8.2 1.6z"/>
<path android:fillColor="#FFFFFF" android:pathData="M224.7,395H50.2c0,0 3.1,-35.5 14.6,-52.2c0,0 0,0 1,0c7.3,-3.1 35.5,-13.6 49.1,-24l1,-6.3c0,0 5.2,11.5 17.8,12.5c1,0 2.1,0 4.2,0c1,0 3.1,0 4.2,0c12.5,-2.1 17.8,-12.5 17.8,-12.5l1,6.3c13.6,10.4 41.8,20.9 48.1,23c1,0 1,0 1,0C221.5,358.4 224.7,395 224.7,395z"/>
<path android:fillColor="#CDD6E0" android:pathData="M117,338.5l5.2,9.4l8.4,-12.5l-2.1,-2.1l-6.3,9.4l-7.3,-13.6C114.9,332.3 116,335.4 117,338.5z"/>
<path android:fillColor="#F8B64C" android:pathData="M158.8,312.4c0,0 -5.2,11.5 -17.8,12.5c-1,0 -2.1,0 -4.2,0c-1,0 -3.1,0 -4.2,0c-12.5,-2.1 -17.8,-12.5 -17.8,-12.5s0,-2.1 0,-4.2c0,-1 0,-2.1 0,-3.1c10.4,12.5 20.9,14.6 20.9,14.6s11.5,-2.1 20.9,-14.6c0,1 0,2.1 0,3.1C158.8,310.3 158.8,312.4 158.8,312.4z"/>
<path android:fillColor="#F7AF48" android:pathData="M158.8,308.2c-9.4,11.5 -19.9,12.5 -20.9,12.5l0,0l0,0c-1,0 -11.5,-2.1 -20.9,-12.5c0,-1 0,-2.1 0,-3.1c10.4,12.5 20.9,14.6 20.9,14.6s11.5,-2.1 20.9,-14.6C158.8,305.1 158.8,307.2 158.8,308.2z"/>
<path android:fillColor="#FFD15C" android:pathData="M173.5,264.4c0,2.1 -1,3.1 -1,3.1c-6.3,47 -35.5,51.2 -35.5,51.2s-29.3,-5.2 -35.5,-51.2c0,0 0,-1 -1,-3.1l0,0c-1,-11.5 -3.1,-47 35.5,-47C176.6,217.3 174.5,252.9 173.5,264.4z"/>
<path android:fillColor="#40596B" android:pathData="M137.9,382.4v11.5h58.5l13.6,-51.2l-1,-1c-7.3,-2.1 -35.5,-12.5 -49.1,-23l0,0c0,0 3.1,11.5 -7.3,33.4C152.6,352.1 143.2,369.9 137.9,382.4z"/>
<path android:fillColor="#CDD6E0" android:pathData="M157.8,338.5l-5.2,9.4l-8.4,-12.5l2.1,-2.1l6.3,9.4l7.3,-13.6C159.9,332.3 158.8,335.4 157.8,338.5z"/>
<path android:fillColor="#FF7058" android:pathData="M141.1,340.6l4.2,26.1c-3.1,5.2 -5.2,11.5 -8.4,16.7c-2.1,-5.2 -5.2,-11.5 -8.4,-16.7l4.2,-26.1l-5.2,-6.3l5.2,-8.4l0,0c1,0 2.1,0 4.2,0c1,0 3.1,0 4.2,0l0,0l5.2,8.4L141.1,340.6z"/>
<path android:fillColor="#334A5E" android:pathData="M143.2,395H78.4l-13.6,-51.2l1,-1c7.3,-3.1 35.5,-13.6 49.1,-24l0,0l0,0c0,0 -3.1,11.5 7.3,33.4c0,0 9.4,17.8 15.7,30.3C140,388.7 142.1,392.9 143.2,395z"/>
<path android:fillColor="#334A5E" android:pathData="M173.5,264.4l-1,1c0,0 -2.1,-18.8 -10.4,-31.3c0,0 -5.2,8.4 -24,8.4s-24,-8.4 -24,-8.4c-8.4,13.6 -10.4,31.3 -10.4,31.3l-1,-1l0,0c-1,-11.5 -3.1,-47 35.5,-47S174.5,252.9 173.5,264.4z"/>
</vector>

View file

@ -16,18 +16,36 @@
android:layout_height="250dp" android:layout_height="250dp"
android:background="@color/colorPrimary"> android:background="@color/colorPrimary">
<RelativeLayout <de.hdodenhof.circleimageview.CircleImageView
android:layout_width="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="200dp" android:id="@+id/profile_drawable"
android:paddingTop="100dp"
android:background="@color/colorPrimary">
<ImageView
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"/> />
</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" >
<ImageView
android:id="@+id/iv_saveImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_margin="15dp"
android:src="@drawable/ic_check_black_24dp"
android:tint="?attr/iconColorPrimary" />
</com.avito.android.krop.KropView>
</RelativeLayout> </RelativeLayout>

View file

@ -21,12 +21,14 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:paddingLeft="16dp"> android:paddingLeft="16dp">
<ImageView android:layout_width="60dp" <de.hdodenhof.circleimageview.CircleImageView
android:layout_height="60dp"
android:id="@+id/ivTextDrawable" android:id="@+id/ivTextDrawable"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/> android:layout_alignParentStart="true"
/>
</RelativeLayout> </RelativeLayout>
<RelativeLayout <RelativeLayout

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main" android:id="@+id/main"
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -7,78 +8,94 @@
android:padding="32dp"> android:padding="32dp">
<TextView <TextView
android:text="@string/choose_authentication_method" android:id="@+id/textView2"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="24sp" android:text="@string/choose_authentication_method"
android:textAlignment="center"
android:textColor="@color/primary_text_inverted" android:textColor="@color/primary_text_inverted"
android:id="@+id/textView2" /> android:textSize="24sp"
android:layout_marginTop="30dp"
android:textStyle="bold" />
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="140dp"
android:layout_marginBottom="100dp"
android:layout_marginTop="70dp"
app:srcCompat="@drawable/ic_id_card" />
<LinearLayout <LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="200dp" android:layout_height="200dp"
android:layout_marginTop="12dp"> android:layout_alignParentBottom="true"
android:layout_marginTop="12dp"
android:orientation="horizontal">
<RadioGroup <RadioGroup
android:layout_width="match_parent"
android:id="@+id/rg_authenticationMethod" android:id="@+id/rg_authenticationMethod"
android:layout_width="match_parent"
android:layout_height="187dp"> android:layout_height="187dp">
<RadioButton <RadioButton
android:id="@+id/rb_none"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="16sp" android:text="@string/authentication_method_none"
android:id="@+id/rb_none" android:textSize="16sp" />
android:text="@string/authentication_method_none"/>
<TextView <TextView
android:text="@string/authentication_method_none_description"
android:layout_width="match_parent" android:layout_width="match_parent"
android:textColor="@color/secondary_text_inverted"
android:layout_marginTop="-5dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="32dp" android:layout_marginStart="32dp"
android:layout_marginTop="-5dp"
android:text="@string/authentication_method_none_description"
android:textColor="@color/secondary_text_inverted" />
<RadioButton
android:id="@+id/rb_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="true"
android:text="@string/authentication_method_password"
android:textSize="16sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="-5dp"
android:text="@string/authentication_method_password_description"
android:textColor="@color/secondary_text_inverted" />
<RadioButton
android:id="@+id/rb_fingerprint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/authentication_method_fingerprint"
android:textSize="16sp"
/> />
<RadioButton
android:text="@string/authentication_method_password"
android:layout_width="match_parent"
android:textSize="16sp"
android:layout_height="wrap_content"
android:id="@+id/rb_password"
android:checked="true"/>
<TextView
android:text="@string/authentication_method_password_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="-5dp"
android:textColor="@color/secondary_text_inverted"
android:layout_marginStart="32dp"/>
<RadioButton
android:text="@string/authentication_method_fingerprint"
android:layout_width="match_parent"
android:textSize="16sp"
android:layout_height="wrap_content"
android:id="@+id/rb_fingerprint"
android:visibility="invisible"/>
<TextView <TextView
android:id="@+id/text_rb_fingerprint" android:id="@+id/text_rb_fingerprint"
android:text="@string/authentication_method_fingerprint_description"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="-5dp"
android:textColor="@color/secondary_text_inverted"
android:layout_marginStart="32dp" android:layout_marginStart="32dp"
android:visibility="invisible"/> android:layout_marginTop="-5dp"
android:text="@string/authentication_method_fingerprint_description"
android:textColor="@color/disabled_textview_colors"
/>
</RadioGroup> </RadioGroup>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:orientation="horizontal" android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"

View file

@ -11,4 +11,9 @@
android:id="@+id/action_delete" android:id="@+id/action_delete"
android:title="@string/action_delete" android:title="@string/action_delete"
app:showAsAction="never"/> app:showAsAction="never"/>
<item
android:id="@+id/action_default_image"
android:title="@string/action_default_image"
app:showAsAction="never"/>
</menu> </menu>

View file

@ -3,6 +3,7 @@
<string name="action_settings">Settings</string> <string name="action_settings">Settings</string>
<string name="action_import">Import</string> <string name="action_import">Import</string>
<string name="action_delete">Delete</string> <string name="action_delete">Delete</string>
<string name="action_default_image">Set default image</string>
<string name="discard">Discard</string> <string name="discard">Discard</string>
<string name="save">Save</string> <string name="save">Save</string>
<string name="title_activity_intro">IntroActivity</string> <string name="title_activity_intro">IntroActivity</string>
@ -34,7 +35,7 @@
<string name="authentication_method_none_description">The database will be stored in plain text</string> <string name="authentication_method_none_description">The database will be stored in plain text</string>
<string name="authentication_method_password">Password</string> <string name="authentication_method_password">Password</string>
<string name="authentication_method_password_description">The database will be encrypted with a key derived from a password</string> <string name="authentication_method_password_description">The database will be encrypted with a key derived from a password</string>
<string name="authentication_method_fingerprint">Password &amp; Fingerprint</string> <string name="authentication_method_fingerprint">Fingerprint</string>
<string name="authentication_method_fingerprint_description">In addition to a password, fingerprints registered on this device can be used to decrypt the database</string> <string name="authentication_method_fingerprint_description">In addition to a password, fingerprints registered on this device can be used to decrypt the database</string>
<string name="authentication_method_set_password">Password</string> <string name="authentication_method_set_password">Password</string>
<string name="authentication_enter_password">Enter your password</string> <string name="authentication_enter_password">Enter your password</string>
@ -45,7 +46,7 @@
<string-array name="authentication_methods"> <string-array name="authentication_methods">
<item>None</item> <item>None</item>
<item>Password</item> <item>Password</item>
<item>Password &amp; Fingerprint</item> <item>Fingerprint</item>
</string-array> </string-array>
<string-array name="otp_types_array"> <string-array name="otp_types_array">