mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-04-21 06:19:12 +00:00
Fixed ability to add profiles again
This commit is contained in:
parent
c5626a41a7
commit
61e932a8bc
6 changed files with 86 additions and 14 deletions
|
@ -23,7 +23,7 @@
|
||||||
<activity android:name=".ScannerActivity">
|
<activity android:name=".ScannerActivity">
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name=".AddProfileActivity"
|
<activity android:name=".AddProfileActivity"
|
||||||
android:theme="@style/Theme.AppCompat.NoActionBar" >
|
android:theme="@style/AppTheme.TransparentActionBar" >
|
||||||
</activity>
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,55 @@
|
||||||
package me.impy.aegis;
|
package me.impy.aegis;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.support.design.widget.FloatingActionButton;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
|
import android.widget.EditText;
|
||||||
|
|
||||||
public class AddProfileActivity extends Activity {
|
public class AddProfileActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
EditText profileName;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_add_profile);
|
setContentView(R.layout.activity_add_profile);
|
||||||
|
|
||||||
|
profileName = (EditText) findViewById(R.id.addProfileName);
|
||||||
|
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
getSupportActionBar().setDisplayShowTitleEnabled(false);
|
||||||
|
|
||||||
|
final KeyProfile keyProfile = (KeyProfile)getIntent().getSerializableExtra("KeyProfile");
|
||||||
|
|
||||||
|
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||||
|
fab.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
Intent resultIntent = new Intent();
|
||||||
|
|
||||||
|
keyProfile.Name = profileName.getText().toString();
|
||||||
|
resultIntent.putExtra("KeyProfile", keyProfile);
|
||||||
|
|
||||||
|
setResult(Activity.RESULT_OK, resultIntent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//profileName.setText(keyProfile.Info.getAccountName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case android.R.id.home:
|
||||||
|
onBackPressed();
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,8 @@ import me.impy.aegis.db.Database;
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
static final int GET_KEYINFO = 1;
|
static final int GET_KEYINFO = 1;
|
||||||
|
static final int ADD_KEYINFO = 2;
|
||||||
|
|
||||||
RecyclerView rvKeyProfiles;
|
RecyclerView rvKeyProfiles;
|
||||||
KeyProfileAdapter mKeyProfileAdapter;
|
KeyProfileAdapter mKeyProfileAdapter;
|
||||||
ArrayList<KeyProfile> mKeyProfiles;
|
ArrayList<KeyProfile> mKeyProfiles;
|
||||||
|
@ -104,17 +106,9 @@ public class MainActivity extends AppCompatActivity {
|
||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK) {
|
||||||
final KeyProfile keyProfile = (KeyProfile)data.getSerializableExtra("KeyProfile");
|
final KeyProfile keyProfile = (KeyProfile)data.getSerializableExtra("KeyProfile");
|
||||||
|
|
||||||
String otp;
|
|
||||||
try {
|
|
||||||
otp = OTP.generateOTP(keyProfile.Info);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
keyProfile.Code = otp;
|
|
||||||
Intent intent = new Intent(this, AddProfileActivity.class);
|
Intent intent = new Intent(this, AddProfileActivity.class);
|
||||||
startActivity(intent);
|
intent.putExtra("KeyProfile", keyProfile);
|
||||||
|
startActivityForResult(intent, ADD_KEYINFO);
|
||||||
/* new LovelyTextInputDialog(this, R.style.EditTextTintTheme)
|
/* new LovelyTextInputDialog(this, R.style.EditTextTintTheme)
|
||||||
.setTopColorRes(R.color.colorHeaderSuccess)
|
.setTopColorRes(R.color.colorHeaderSuccess)
|
||||||
.setTitle("New profile added")
|
.setTitle("New profile added")
|
||||||
|
@ -147,6 +141,30 @@ public class MainActivity extends AppCompatActivity {
|
||||||
//TODO: do something with the result.
|
//TODO: do something with the result.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (requestCode == ADD_KEYINFO) {
|
||||||
|
// Make sure the request was successful
|
||||||
|
if (resultCode == RESULT_OK) {
|
||||||
|
final KeyProfile keyProfile = (KeyProfile)data.getSerializableExtra("KeyProfile");
|
||||||
|
|
||||||
|
String otp;
|
||||||
|
try {
|
||||||
|
otp = OTP.generateOTP(keyProfile.Info);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
keyProfile.Code = otp;
|
||||||
|
mKeyProfiles.add(keyProfile);
|
||||||
|
mKeyProfileAdapter.notifyDataSetChanged();
|
||||||
|
|
||||||
|
try {
|
||||||
|
database.addKey(keyProfile);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
android:inputType="textPersonName"
|
android:inputType="textPersonName"
|
||||||
android:ems="10"
|
android:ems="10"
|
||||||
android:paddingTop="0dp"
|
android:paddingTop="0dp"
|
||||||
android:id="@+id/editText3"
|
android:id="@+id/addProfileName"
|
||||||
android:textSize="28sp"
|
android:textSize="28sp"
|
||||||
/>
|
/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -14,6 +14,6 @@
|
||||||
android:inputType="textPersonName"
|
android:inputType="textPersonName"
|
||||||
android:text="Name"
|
android:text="Name"
|
||||||
android:ems="10"
|
android:ems="10"
|
||||||
android:id="@+id/editText"
|
android:id="@+id/profile_name"
|
||||||
android:layout_weight="0.96"/>
|
android:layout_weight="0.96"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -8,6 +8,20 @@
|
||||||
<item name="colorAccent">@color/colorAccent</item>
|
<item name="colorAccent">@color/colorAccent</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="AppTheme.TransparentActionBar">
|
||||||
|
<item name="android:actionBarStyle">@style/ThemeActionBar</item>
|
||||||
|
<item name="android:windowActionBarOverlay">true</item>
|
||||||
|
<!-- Support library compatibility -->
|
||||||
|
<item name="actionBarStyle">@style/ThemeActionBar</item>
|
||||||
|
<item name="windowActionBarOverlay">true</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="ThemeActionBar" parent="Widget.AppCompat.Light.ActionBar.Solid">
|
||||||
|
<item name="android:background">@null</item>
|
||||||
|
<!-- Support library compatibility -->
|
||||||
|
<item name="background">@null</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="AppTheme.NoActionBar">
|
<style name="AppTheme.NoActionBar">
|
||||||
<item name="windowActionBar">false</item>
|
<item name="windowActionBar">false</item>
|
||||||
<item name="windowNoTitle">true</item>
|
<item name="windowNoTitle">true</item>
|
||||||
|
|
Loading…
Add table
Reference in a new issue