mirror of https://github.com/beemdevelopment/Aegis
Merge branch 'master' of https://github.com/alexbakker/Aegis
commit
855f5e519f
@ -1,88 +0,0 @@
|
||||
package me.impy.aegis;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import me.impy.aegis.crypto.KeyInfo;
|
||||
|
||||
public class AddProfileActivity extends AegisActivity {
|
||||
private KeyProfile _keyProfile;
|
||||
|
||||
private EditText _profileName;
|
||||
private TextView _textAlgorithm;
|
||||
private TextView _textIssuer;
|
||||
private TextView _textPeriod;
|
||||
private TextView _textOtp;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.activity_add_profile);
|
||||
|
||||
_profileName = findViewById(R.id.addProfileName);
|
||||
_textAlgorithm = findViewById(R.id.tvAlgorithm);
|
||||
_textIssuer = findViewById(R.id.tvIssuer);
|
||||
_textPeriod = findViewById(R.id.tvPeriod);
|
||||
_textOtp = findViewById(R.id.tvOtp);
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setDisplayShowTitleEnabled(false);
|
||||
|
||||
_keyProfile = (KeyProfile) getIntent().getSerializableExtra("KeyProfile");
|
||||
|
||||
initializeForm();
|
||||
|
||||
FloatingActionButton fab = findViewById(R.id.fab);
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent resultIntent = new Intent();
|
||||
|
||||
_keyProfile.getEntry().setName(_profileName.getText().toString());
|
||||
resultIntent.putExtra("KeyProfile", _keyProfile);
|
||||
|
||||
setResult(Activity.RESULT_OK, resultIntent);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
//_profileName.setText(_keyProfile.Info.getAccountName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setPreferredTheme(boolean nightMode) {
|
||||
if (nightMode) {
|
||||
setTheme(R.style.AppTheme_Dark_TransparentActionBar);
|
||||
} else {
|
||||
setTheme(R.style.AppTheme_Default_TransparentActionBar);
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeForm() {
|
||||
KeyInfo info = _keyProfile.getEntry().getInfo();
|
||||
_profileName.setText(info.getAccountName());
|
||||
_textAlgorithm.setText(info.getAlgorithm(false));
|
||||
_textIssuer.setText(info.getIssuer());
|
||||
_textPeriod.setText(info.getPeriod() + " seconds");
|
||||
|
||||
String otp = _keyProfile.refreshCode();
|
||||
_textOtp.setText(otp.substring(0, 3) + " " + otp.substring(3));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
onBackPressed();
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package me.impy.aegis;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.support.annotation.CallSuper;
|
||||
|
||||
public abstract class ProgressDialogTask<Params, Result> extends AsyncTask<Params, Void, Result> {
|
||||
private ProgressDialog _dialog;
|
||||
|
||||
public ProgressDialogTask(Context context, String message) {
|
||||
_dialog = new ProgressDialog(context);
|
||||
_dialog.setCancelable(false);
|
||||
_dialog.setMessage(message);
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
_dialog.show();
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
@Override
|
||||
protected void onPostExecute(Result result) {
|
||||
if (_dialog.isShowing()) {
|
||||
_dialog.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
protected final ProgressDialog getDialog() {
|
||||
return _dialog;
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package me.impy.aegis.helpers;
|
||||
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
||||
|
||||
public class TextDrawableHelper {
|
||||
private TextDrawableHelper() {
|
||||
|
||||
}
|
||||
|
||||
public static TextDrawable generate(String s) {
|
||||
if (s == null || s.length() <= 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||
int color = generator.getColor(s);
|
||||
return TextDrawable.builder().buildRound(s.substring(0, 1).toUpperCase(), color);
|
||||
}
|
||||
}
|
@ -1,182 +0,0 @@
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/viewA"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.6"
|
||||
android:background="@color/colorPrimary"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="360dp"
|
||||
android:layout_height="80dp"
|
||||
android:paddingLeft="50dp"
|
||||
android:layout_gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:text="Profile name"
|
||||
android:layout_width="111dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/textView"
|
||||
android:layout_weight="0.53"
|
||||
android:gravity="bottom"
|
||||
android:textSize="16sp"
|
||||
android:textColor="@color/secondary_text_inverted"
|
||||
android:layout_marginLeft="3dp"/>
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textPersonName"
|
||||
android:ems="10"
|
||||
android:textColor="@color/primary_text_inverted"
|
||||
android:paddingTop="0dp"
|
||||
android:id="@+id/addProfileName"
|
||||
android:textSize="28sp"
|
||||
android:paddingRight="0dp" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/viewB"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.4"
|
||||
android:background="?attr/background"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="250dp"
|
||||
>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:srcCompat="@drawable/ic_vpn_key_black_24dp"
|
||||
android:id="@+id/imageView3"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_marginTop="16dp"
|
||||
android:tint="@color/cardview_dark_background"/>
|
||||
|
||||
<TextView
|
||||
android:text="SHA1"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/tvAlgorithm"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:textColor="?attr/primaryText"
|
||||
android:textSize="18sp"
|
||||
android:layout_alignBottom="@+id/imageView3"
|
||||
android:layout_toRightOf="@+id/imageView3"
|
||||
android:layout_toEndOf="@+id/imageView3"/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:srcCompat="@drawable/ic_person_black_24dp"
|
||||
android:id="@+id/ivIssuer"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginTop="10dp"
|
||||
android:tint="@color/cardview_dark_background"
|
||||
android:layout_below="@+id/imageView3"
|
||||
android:layout_alignLeft="@+id/imageView3"
|
||||
android:layout_alignStart="@+id/imageView3"/>
|
||||
|
||||
<TextView
|
||||
android:text="GitHub"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/tvIssuer"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="wrap_content"
|
||||
android:textSize="18sp"
|
||||
android:textColor="?attr/primaryText"
|
||||
android:layout_alignBottom="@+id/ivIssuer"
|
||||
android:layout_alignLeft="@+id/tvAlgorithm"
|
||||
android:layout_alignStart="@+id/tvAlgorithm"/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:srcCompat="@drawable/ic_timelapse_black_24dp"
|
||||
android:id="@+id/ivPeriod"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginTop="13dp"
|
||||
android:tint="@color/cardview_dark_background"
|
||||
android:layout_below="@+id/ivIssuer"
|
||||
android:layout_alignLeft="@+id/ivIssuer"
|
||||
android:layout_alignStart="@+id/ivIssuer"/>
|
||||
|
||||
<TextView
|
||||
android:text="30 seconds"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/tvPeriod"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="wrap_content"
|
||||
android:textSize="18sp"
|
||||
android:textColor="?attr/primaryText"
|
||||
android:layout_alignBottom="@+id/ivPeriod"
|
||||
android:layout_alignLeft="@+id/tvIssuer"
|
||||
android:layout_alignStart="@+id/tvIssuer"
|
||||
android:layout_marginBottom="2dp"/>
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="Medium Text"
|
||||
android:id="@+id/tvOtp"
|
||||
android:textSize="36sp"
|
||||
android:textColor="?attr/primaryText"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_toRightOf="@+id/tvAlgorithm"
|
||||
android:layout_toEndOf="@+id/tvAlgorithm"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_horizontal|center"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:clickable="true"
|
||||
app:layout_anchor="@id/viewA"
|
||||
app:layout_anchorGravity="bottom|right|end"
|
||||
android:src="@drawable/ic_check"/>
|
||||
|
||||
<!---->
|
||||
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
Loading…
Reference in New Issue