Added more details to AddActivity

This commit is contained in:
Michael Schättgen 2016-08-25 00:37:31 +02:00
parent 6463d6fb9e
commit 0c45315c21
5 changed files with 171 additions and 4 deletions

View file

@ -9,10 +9,20 @@ import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.Window; import android.view.Window;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView;
import me.impy.aegis.crypto.OTP;
public class AddProfileActivity extends AppCompatActivity { public class AddProfileActivity extends AppCompatActivity {
KeyProfile keyProfile;
EditText profileName; EditText profileName;
TextView tvAlgorithm;
TextView tvIssuer;
TextView tvPeriod;
TextView tvOtp;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -20,12 +30,17 @@ public class AddProfileActivity extends AppCompatActivity {
setContentView(R.layout.activity_add_profile); setContentView(R.layout.activity_add_profile);
profileName = (EditText) findViewById(R.id.addProfileName); profileName = (EditText) findViewById(R.id.addProfileName);
tvAlgorithm = (TextView) findViewById(R.id.tvAlgorithm);
tvIssuer = (TextView) findViewById(R.id.tvIssuer);
tvPeriod = (TextView) findViewById(R.id.tvPeriod);
tvOtp = (TextView) findViewById(R.id.tvOtp);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(false); getSupportActionBar().setDisplayShowTitleEnabled(false);
final KeyProfile keyProfile = (KeyProfile)getIntent().getSerializableExtra("KeyProfile"); keyProfile = (KeyProfile)getIntent().getSerializableExtra("KeyProfile");
profileName.setText(keyProfile.Info.getAccountName());
initializeForm();
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() { fab.setOnClickListener(new View.OnClickListener() {
@ -43,6 +58,25 @@ public class AddProfileActivity extends AppCompatActivity {
//profileName.setText(keyProfile.Info.getAccountName()); //profileName.setText(keyProfile.Info.getAccountName());
} }
private void initializeForm()
{
profileName.setText(keyProfile.Info.getAccountName());
tvAlgorithm.setText(keyProfile.Info.getAlgorithm());
tvIssuer.setText(keyProfile.Info.getIssuer());
tvPeriod.setText(keyProfile.Info.getPeriod() + " seconds");
String otp;
try {
otp = OTP.generateOTP(keyProfile.Info);
} catch (Exception e) {
e.printStackTrace();
return;
}
keyProfile.Code = otp;
tvOtp.setText(otp.substring(0, 3) + " " + otp.substring(3));
}
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {

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="M12,12c2.21,0 4,-1.79 4,-4s-1.79,-4 -4,-4 -4,1.79 -4,4 1.79,4 4,4zM12,14c-2.67,0 -8,1.34 -8,4v2h16v-2c0,-2.66 -5.33,-4 -8,-4z"/>
</vector>

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="M16.24,7.76C15.07,6.59 13.54,6 12,6v6l-4.24,4.24c2.34,2.34 6.14,2.34 8.49,0 2.34,-2.34 2.34,-6.14 -0.01,-8.48zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z"/>
</vector>

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="M12.65,10C11.83,7.67 9.61,6 7,6c-3.31,0 -6,2.69 -6,6s2.69,6 6,6c2.61,0 4.83,-1.67 5.65,-4H17v4h4v-4h2v-4H12.65zM7,14c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2z"/>
</vector>

View file

@ -1,6 +1,7 @@
<android.support.design.widget.CoordinatorLayout <android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
@ -54,7 +55,111 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="0.4" android:layout_weight="0.4"
android:background="@color/background" android:background="@color/background"
android:orientation="horizontal"/> 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: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: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: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="@color/primary_text"
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> </LinearLayout>
@ -67,6 +172,7 @@
app:layout_anchor="@id/viewA" app:layout_anchor="@id/viewA"
app:layout_anchorGravity="bottom|right|end" app:layout_anchorGravity="bottom|right|end"
android:src="@drawable/ic_check"/> android:src="@drawable/ic_check"/>
<!----> <!---->