Created ImportAccountOptionsFragment that shows up when the user wants to ImportAccount

This commit is contained in:
Severiano Jaramillo 2018-01-25 20:48:04 -06:00
parent d01f84c198
commit 9527c3b758
5 changed files with 174 additions and 55 deletions

View file

@ -10,6 +10,8 @@ import android.content.Intent;
import android.media.MediaPlayer; import android.media.MediaPlayer;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.view.SurfaceHolder; import android.view.SurfaceHolder;
import android.view.SurfaceView; import android.view.SurfaceView;
@ -23,6 +25,7 @@ import butterknife.ButterKnife;
import butterknife.OnClick; import butterknife.OnClick;
import cy.agorise.crystalwallet.R; import cy.agorise.crystalwallet.R;
import cy.agorise.crystalwallet.dao.CrystalDatabase; import cy.agorise.crystalwallet.dao.CrystalDatabase;
import cy.agorise.crystalwallet.fragments.ImportAccountOptionsFragment;
import cy.agorise.crystalwallet.models.AccountSeed; import cy.agorise.crystalwallet.models.AccountSeed;
import cy.agorise.crystalwallet.models.CryptoCoinBalance; import cy.agorise.crystalwallet.models.CryptoCoinBalance;
import cy.agorise.crystalwallet.models.CryptoCoinTransaction; import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
@ -139,6 +142,15 @@ public class IntroActivity extends AppCompatActivity {
@OnClick(R.id.btnImportAccount) @OnClick(R.id.btnImportAccount)
public void importAccount() { public void importAccount() {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
Fragment prev = getSupportFragmentManager().findFragmentByTag("importAccountOptions");
if (prev != null) {
ft.remove(prev);
}
ft.addToBackStack(null);
// Create and show the dialog.
ImportAccountOptionsFragment newFragment = ImportAccountOptionsFragment.newInstance();
newFragment.show(ft, "importAccountOptions");
} }
} }

View file

@ -0,0 +1,72 @@
package cy.agorise.crystalwallet.fragments;
import android.app.Dialog;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cy.agorise.crystalwallet.R;
/**
* Created by xd on 1/25/18.
* Shows a dialog where the user can select how to import his/her existing account
*/
public class ImportAccountOptionsFragment extends DialogFragment {
@BindView(R.id.btnCancel)
Button btnClose;
public ImportAccountOptionsFragment() {
// Required empty public constructor
}
public static ImportAccountOptionsFragment newInstance() {
ImportAccountOptionsFragment fragment = new ImportAccountOptionsFragment();
Bundle args = new Bundle();
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.fragment_import_account_options, null);
ButterKnife.bind(this, view);
return builder.setView(view).create();
}
@Override
public void onResume() {
super.onResume();
// Force dialog fragment to use the full width of the screen
Window dialogWindow = getDialog().getWindow();
assert dialogWindow != null;
dialogWindow.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}
@OnClick(R.id.btnCancel)
public void cancel() {
dismiss();
}
}

View file

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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="wrap_content"
android:paddingBottom="24dp">
<TextView
android:id="@+id/tvDescription"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
android:layout_marginStart="24dp"
android:layout_marginTop="24dp"
android:text="@string/import_account_options_description"
android:textSize="18sp"
android:textAlignment="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/btnImportBackup"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="48dp"
android:background="@color/colorPrimary"
android:text="@string/import_account_backup"
android:textAllCaps="false"
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintTop_toBottomOf="@id/tvDescription"
app:layout_constraintStart_toStartOf="@id/tvDescription"
app:layout_constraintEnd_toEndOf="@id/tvDescription"/>
<Button
android:id="@+id/btnImportSeed"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:background="@color/colorPrimary"
android:text="@string/import_account_seed"
android:textAllCaps="false"
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintTop_toBottomOf="@id/btnImportBackup"
app:layout_constraintStart_toStartOf="@id/btnImportBackup"
app:layout_constraintEnd_toEndOf="@id/btnImportBackup"/>
<Button
android:id="@+id/btnCancel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:background="@color/redcolor"
android:text="@string/dialog_cancel"
android:textAllCaps="false"
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintTop_toBottomOf="@id/btnImportSeed"
app:layout_constraintStart_toStartOf="@id/btnImportSeed"
app:layout_constraintEnd_toEndOf="@id/btnImportSeed"/>
</android.support.constraint.ConstraintLayout>

View file

@ -1,14 +1,24 @@
<?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:tools="http://schemas.android.com/tools" 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"
android:orientation="vertical" android:orientation="vertical"
android:paddingBottom="0dp" tools:context=".activities.ImportSeedActivity">
android:paddingLeft="0dp" <!--
android:paddingRight="0dp" <android.support.design.widget.TextInputLayout
android:paddingTop="@dimen/activity_vertical_margin"> android:id="@+id/tilPin"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="@+id/tietPin"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
-->
<TextView <TextView
android:id="@+id/tvPin" android:id="@+id/tvPin"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -175,56 +185,9 @@
</LinearLayout> </LinearLayout>
<LinearLayout <cy.agorise.crystalwallet.util.BottomStatusBar
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:background="@color/white" android:layout_gravity="bottom"/>
android:gravity="bottom"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/black"></LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="35dp"
android:background="@color/bottomBarColor"
android:gravity="bottom"
android:orientation="horizontal">
<TextView
android:id="@+id/tvAppVersion_brain_key_activity"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/v_1_0_beta" />
<TextView
android:id="@+id/tvBlockNumberHead_brain_key_activity"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:gravity="center"
android:text="@string/block_number" />
<ImageView
android:id="@+id/ivSocketConnected_brain_key_activity"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.5" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.5"
android:src="@drawable/icon_setting"
android:visibility="invisible" />
</LinearLayout>
</LinearLayout>
</LinearLayout> </LinearLayout>

View file

@ -503,4 +503,7 @@
<string name="camera_feed_to_scan_qr">Camera feed to scan QR</string> <string name="camera_feed_to_scan_qr">Camera feed to scan QR</string>
<string name="create_account">Create Account</string> <string name="create_account">Create Account</string>
<string name="import_account">Import Account</string> <string name="import_account">Import Account</string>
<string name="import_account_options_description">Select one option to import your existing account</string>
<string name="import_account_seed">Import Account Seed</string>
<string name="import_account_backup">Import Account Backup</string>
</resources> </resources>