From 0c45315c21d42d6f38958a925e2fbf81324297ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Sch=C3=A4ttgen?= Date: Thu, 25 Aug 2016 00:37:31 +0200 Subject: [PATCH] Added more details to AddActivity --- .../me/impy/aegis/AddProfileActivity.java | 38 +++++- .../res/drawable/ic_person_black_24dp.xml | 9 ++ .../res/drawable/ic_timelapse_black_24dp.xml | 9 ++ .../res/drawable/ic_vpn_key_black_24dp.xml | 9 ++ .../main/res/layout/activity_add_profile.xml | 110 +++++++++++++++++- 5 files changed, 171 insertions(+), 4 deletions(-) create mode 100644 app/src/main/res/drawable/ic_person_black_24dp.xml create mode 100644 app/src/main/res/drawable/ic_timelapse_black_24dp.xml create mode 100644 app/src/main/res/drawable/ic_vpn_key_black_24dp.xml diff --git a/app/src/main/java/me/impy/aegis/AddProfileActivity.java b/app/src/main/java/me/impy/aegis/AddProfileActivity.java index 3ba3bb84..ef21b6c5 100644 --- a/app/src/main/java/me/impy/aegis/AddProfileActivity.java +++ b/app/src/main/java/me/impy/aegis/AddProfileActivity.java @@ -9,10 +9,20 @@ import android.view.MenuItem; import android.view.View; import android.view.Window; import android.widget.EditText; +import android.widget.TextView; + +import me.impy.aegis.crypto.OTP; public class AddProfileActivity extends AppCompatActivity { + KeyProfile keyProfile; + EditText profileName; + TextView tvAlgorithm; + TextView tvIssuer; + TextView tvPeriod; + TextView tvOtp; + @Override protected void onCreate(Bundle savedInstanceState) { @@ -20,12 +30,17 @@ public class AddProfileActivity extends AppCompatActivity { setContentView(R.layout.activity_add_profile); 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().setDisplayShowTitleEnabled(false); - final KeyProfile keyProfile = (KeyProfile)getIntent().getSerializableExtra("KeyProfile"); - profileName.setText(keyProfile.Info.getAccountName()); + keyProfile = (KeyProfile)getIntent().getSerializableExtra("KeyProfile"); + + initializeForm(); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @@ -43,6 +58,25 @@ public class AddProfileActivity extends AppCompatActivity { //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 public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { diff --git a/app/src/main/res/drawable/ic_person_black_24dp.xml b/app/src/main/res/drawable/ic_person_black_24dp.xml new file mode 100644 index 00000000..b2cb337b --- /dev/null +++ b/app/src/main/res/drawable/ic_person_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_timelapse_black_24dp.xml b/app/src/main/res/drawable/ic_timelapse_black_24dp.xml new file mode 100644 index 00000000..6e1ad692 --- /dev/null +++ b/app/src/main/res/drawable/ic_timelapse_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_vpn_key_black_24dp.xml b/app/src/main/res/drawable/ic_vpn_key_black_24dp.xml new file mode 100644 index 00000000..2eddd16f --- /dev/null +++ b/app/src/main/res/drawable/ic_vpn_key_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/activity_add_profile.xml b/app/src/main/res/layout/activity_add_profile.xml index 91d3e8cd..2d80da0a 100644 --- a/app/src/main/res/layout/activity_add_profile.xml +++ b/app/src/main/res/layout/activity_add_profile.xml @@ -1,6 +1,7 @@ @@ -54,7 +55,111 @@ android:layout_height="match_parent" android:layout_weight="0.4" android:background="@color/background" - android:orientation="horizontal"/> + android:orientation="vertical"> + + + + + + + + + + + + + + + + + + + + + + + + @@ -67,7 +172,8 @@ app:layout_anchor="@id/viewA" app:layout_anchorGravity="bottom|right|end" android:src="@drawable/ic_check"/> - + + \ No newline at end of file