diff --git a/app/src/main/java/cy/agorise/crystalwallet/activities/BackupSeedActivity.java b/app/src/main/java/cy/agorise/crystalwallet/activities/BackupSeedActivity.java index db40e29..64cee76 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/BackupSeedActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/BackupSeedActivity.java @@ -39,11 +39,6 @@ public class BackupSeedActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.backup_seed); - //Note: Test porpouses - /*final TextView textView = findViewById(R.id.tvBrainKey); - textView.setText("sakk902909321o p3k21kldsa0'dsa90'e930eidakdñsakdñlsakdi90i03 2i90idopsasakk902909321op3k21 kldsa0'dsa90'e930eid akdñsakdñlsakdi90i032i90idopsa"); - */ - ButterKnife.bind(this); long seedId = getIntent().getLongExtra("SEED_ID",-1); @@ -61,17 +56,22 @@ public class BackupSeedActivity extends AppCompatActivity { accountSeedViewModel.loadSeed(seedId); } else { - finish(); } } @OnClick(R.id.btnCancel) + public void btnCancelClick(){ + Intent intent = new Intent(this, BoardActivity.class); + startActivity(intent); + finish(); + } + + @OnClick(R.id.btnOK) public void btnOkClick(){ Intent intent = new Intent(this, BoardActivity.class); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); - //finish(); + finish(); } /* diff --git a/app/src/main/java/cy/agorise/crystalwallet/activities/BoardActivity.java b/app/src/main/java/cy/agorise/crystalwallet/activities/BoardActivity.java index 23a3eb9..815e70f 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/BoardActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/BoardActivity.java @@ -120,50 +120,50 @@ public class BoardActivity extends CustomActivity { * Listener tabLayout to resalt text when clicked * */ final TabLayout tabLayoutFinal = tabLayout; - tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { - @Override - public void onTabSelected(final TabLayout.Tab tab) { - - globalActivity.runOnUiThread(new Runnable() { - @Override - public void run() { - - LinearLayout tabLayout = (LinearLayout)((ViewGroup) tabLayoutFinal.getChildAt(0)).getChildAt(tab.getPosition()); - tabLayout.setBackgroundColor(Color.TRANSPARENT); - TextView tabTextView = (TextView) tabLayout.getChildAt(1); - //tabTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP ,50); - Spannable WordtoSpan = new SpannableString(tabTextView.getText()); - WordtoSpan.setSpan(new ForegroundColorSpan(Color.WHITE), 0, tabTextView.getText().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); - tabTextView.setText(WordtoSpan); - tabTextView.setTypeface(tabTextView.getTypeface(), Typeface.BOLD); - } - }); - } - - @Override - public void onTabUnselected(final TabLayout.Tab tab) { - - globalActivity.runOnUiThread(new Runnable() { - @Override - public void run() { - - LinearLayout tabLayout = (LinearLayout)((ViewGroup) tabLayoutFinal.getChildAt(0)).getChildAt(tab.getPosition()); - TextView tabTextView = (TextView) tabLayout.getChildAt(1); - //tabTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP ,50); - Spannable WordtoSpan = new SpannableString(tabTextView.getText()); - WordtoSpan.setSpan(new ForegroundColorSpan(globalActivity.getResources().getColor(R.color.lightGrayClear)), 0, tabTextView.getText().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); - tabTextView.setText(WordtoSpan); - tabTextView.setTypeface(tabTextView.getTypeface(), Typeface.NORMAL); - } - }); - } - - @Override - public void onTabReselected(TabLayout.Tab tab) { - - - } - }); +// tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { +// @Override +// public void onTabSelected(final TabLayout.Tab tab) { +// +// globalActivity.runOnUiThread(new Runnable() { +// @Override +// public void run() { +// +// LinearLayout tabLayout = (LinearLayout)((ViewGroup) tabLayoutFinal.getChildAt(0)).getChildAt(tab.getPosition()); +// tabLayout.setBackgroundColor(Color.TRANSPARENT); +// TextView tabTextView = (TextView) tabLayout.getChildAt(1); +// //tabTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP ,50); +// Spannable WordtoSpan = new SpannableString(tabTextView.getText()); +// WordtoSpan.setSpan(new ForegroundColorSpan(Color.WHITE), 0, tabTextView.getText().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); +// tabTextView.setText(WordtoSpan); +// tabTextView.setTypeface(tabTextView.getTypeface(), Typeface.BOLD); +// } +// }); +// } +// +// @Override +// public void onTabUnselected(final TabLayout.Tab tab) { +// +// globalActivity.runOnUiThread(new Runnable() { +// @Override +// public void run() { +// +// LinearLayout tabLayout = (LinearLayout)((ViewGroup) tabLayoutFinal.getChildAt(0)).getChildAt(tab.getPosition()); +// TextView tabTextView = (TextView) tabLayout.getChildAt(1); +// //tabTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP ,50); +// Spannable WordtoSpan = new SpannableString(tabTextView.getText()); +// WordtoSpan.setSpan(new ForegroundColorSpan(globalActivity.getResources().getColor(R.color.lightGrayClear)), 0, tabTextView.getText().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); +// tabTextView.setText(WordtoSpan); +// tabTextView.setTypeface(tabTextView.getTypeface(), Typeface.NORMAL); +// } +// }); +// } +// +// @Override +// public void onTabReselected(TabLayout.Tab tab) { +// +// +// } +// }); // Appbar animation mSurfaceView.getHolder().addCallback(new SurfaceHolder.Callback() { @@ -234,12 +234,19 @@ public class BoardActivity extends CustomActivity { .setInterpolator(new LinearInterpolator()).start(); break; - default: + case 2: fabReceive.hide(); fabSend.hide(); fabAddContact.animate().translationY(0) .setInterpolator(new LinearInterpolator()).start(); break; + + default: + fabReceive.hide(); + fabSend.hide(); + fabAddContact.animate().translationY(fabDistanceToHide) + .setInterpolator(new LinearInterpolator()).start(); + break; } } diff --git a/app/src/main/java/cy/agorise/crystalwallet/activities/CreateSeedActivity.kt b/app/src/main/java/cy/agorise/crystalwallet/activities/CreateSeedActivity.kt index 9996daf..1f3f535 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/CreateSeedActivity.kt +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/CreateSeedActivity.kt @@ -9,8 +9,9 @@ import android.widget.Toast import butterknife.ButterKnife import butterknife.OnClick import butterknife.OnTextChanged +import com.vincent.filepicker.ToastUtil import cy.agorise.crystalwallet.R -import cy.agorise.crystalwallet.dialogs.material.CrystalDialog +import cy.agorise.crystalwallet.dialogs.material.* import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests import cy.agorise.crystalwallet.requestmanagers.ValidateCreateBitsharesAccountRequest import cy.agorise.crystalwallet.requestmanagers.ValidateExistBitsharesAccountRequest @@ -167,39 +168,61 @@ class CreateSeedActivity : CustomActivity() { @OnClick(R.id.btnCreate) fun createSeed() { - // Make request to create a bitshare account - val request = ValidateCreateBitsharesAccountRequest(tietAccountName?.getText().toString(), applicationContext) - - //DTVV: Friday 27 July 2018 - //Makes dialog to tell the user that the account is been created - val creatingAccountMaterialDialog = CrystalDialog(this) - creatingAccountMaterialDialog.setText(this.resources.getString(R.string.window_create_seed_DialogMessage)) - creatingAccountMaterialDialog.progress() - this@CreateSeedActivity.runOnUiThread { - creatingAccountMaterialDialog.show() - } - request.setListener { - creatingAccountMaterialDialog.dismiss() - if (request.status == ValidateCreateBitsharesAccountRequest.StatusCode.SUCCEEDED) { - val accountSeed = request.account - val intent = Intent(applicationContext, BackupSeedActivity::class.java) - intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK - intent.putExtra("SEED_ID", accountSeed.id) - startActivity(intent) - } else { - fieldsValidator.validate() + /* + * Question if continue or not + * */ + var questionDialog:QuestionDialog = QuestionDialog(globalActivity) + questionDialog.setText(getString(R.string.continue_question)) + questionDialog.setOnNegative(object : NegativeResponse{ + override fun onNegative(dialogMaterial: DialogMaterial) { + dialogMaterial.dismiss() } - } + }) + questionDialog.setOnPositive(object : PositiveResponse{ + override fun onPositive() { - (object : Thread() { - override fun run() { + // Make request to create a bitshare account + var accountName:String = tietAccountName?.getText().toString().trim() + val request = ValidateCreateBitsharesAccountRequest(accountName, applicationContext) - /* - * - * Run thread*/ - CryptoNetInfoRequests.getInstance().addRequest(request) + //DTVV: Friday 27 July 2018 + //Makes dialog to tell the user that the account is been created + val creatingAccountMaterialDialog = CrystalDialog(globalActivity) + creatingAccountMaterialDialog.setText(globalActivity.resources.getString(R.string.window_create_seed_DialogMessage)) + creatingAccountMaterialDialog.progress() + this@CreateSeedActivity.runOnUiThread { + creatingAccountMaterialDialog.show() + } + request.setListener { + creatingAccountMaterialDialog.dismiss() + if (request.status == ValidateCreateBitsharesAccountRequest.StatusCode.SUCCEEDED) { + val accountSeed = request.account + val intent = Intent(applicationContext, BackupSeedActivity::class.java) + intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK + intent.putExtra("SEED_ID", accountSeed.id) + startActivity(intent) + } + else if (request.status == ValidateCreateBitsharesAccountRequest.StatusCode.ACCOUNT_EXIST) { + ToastUtil.getInstance(globalActivity).showToast(globalActivity.getString(R.string.Account_already_exists)) + disableCreate() + } + else { + fieldsValidator.validate() + } + } + + (object : Thread() { + override fun run() { + + /* + * + * Run thread*/ + CryptoNetInfoRequests.getInstance().addRequest(request) + } + }).start() } - }).start() + }) + questionDialog.show() } /* diff --git a/app/src/main/java/cy/agorise/crystalwallet/apigenerator/BitsharesFaucetApiGenerator.java b/app/src/main/java/cy/agorise/crystalwallet/apigenerator/BitsharesFaucetApiGenerator.java index 7ce7f5e..5b2b6d2 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/apigenerator/BitsharesFaucetApiGenerator.java +++ b/app/src/main/java/cy/agorise/crystalwallet/apigenerator/BitsharesFaucetApiGenerator.java @@ -219,7 +219,7 @@ public abstract class BitsharesFaucetApiGenerator { public interface IWebService { @Headers({"Content-Type: application/json"}) - @POST("/api/v1/accounts") + @POST("/faucet/api/v1/accounts") Call getReg(@Body Map params); } diff --git a/app/src/main/java/cy/agorise/crystalwallet/application/constant/BitsharesConstant.java b/app/src/main/java/cy/agorise/crystalwallet/application/constant/BitsharesConstant.java index 6783404..0b807fa 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/application/constant/BitsharesConstant.java +++ b/app/src/main/java/cy/agorise/crystalwallet/application/constant/BitsharesConstant.java @@ -32,7 +32,7 @@ public abstract class BitsharesConstant { //testnet faucet //public final static String FAUCET_URL = "http://185.208.208.147:5010"; - public final static String FAUCET_URL = "https://faucet.palmpay.io"; + public final static String FAUCET_URL = "https://de.palmpay.io"; public final static String EQUIVALENT_URL = "wss://bitshares.openledger.info/ws"; public final static BitsharesAsset[] SMARTCOINS = new BitsharesAsset[]{ diff --git a/app/src/main/java/cy/agorise/crystalwallet/dialogs/material/CrystalDialog.kt b/app/src/main/java/cy/agorise/crystalwallet/dialogs/material/CrystalDialog.kt index e21e0d2..4029e5e 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/dialogs/material/CrystalDialog.kt +++ b/app/src/main/java/cy/agorise/crystalwallet/dialogs/material/CrystalDialog.kt @@ -1,8 +1,6 @@ package cy.agorise.crystalwallet.dialogs.material import android.app.Activity -import cy.agorise.crystalwallet.R -import kotlinx.android.synthetic.main.account_seed_list.view.* /* * Dialog material that shows loading gif and and explicit message @@ -26,5 +24,5 @@ interface PositiveResponse{ fun onPositive() } interface NegativeResponse{ - fun onNegative() + fun onNegative(dialogMaterial:DialogMaterial) } \ No newline at end of file diff --git a/app/src/main/java/cy/agorise/crystalwallet/dialogs/material/DialogMaterial.kt b/app/src/main/java/cy/agorise/crystalwallet/dialogs/material/DialogMaterial.kt index 9f43713..e1ba64d 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/dialogs/material/DialogMaterial.kt +++ b/app/src/main/java/cy/agorise/crystalwallet/dialogs/material/DialogMaterial.kt @@ -20,16 +20,20 @@ open abstract class DialogMaterial{ * */ protected var activity:Activity; + /* + * Contains pointer to myself + * */ + protected var dialogMaterial:DialogMaterial; /* * Contains the response for positive button click * */ - var positiveResponse:PositiveResponse? = null + protected var positiveResponse:PositiveResponse? = null /* * Contains the response for negative button click * */ - var negativeResponse:NegativeResponse? = null + protected var negativeResponse:NegativeResponse? = null constructor(activity: Activity) { @@ -39,6 +43,8 @@ open abstract class DialogMaterial{ * */ this.activity = activity + dialogMaterial = this; + /* * Init the builder * */ @@ -80,7 +86,7 @@ open abstract class DialogMaterial{ * If response is not null deliver response * */ if(negativeResponse != null){ - negativeResponse!!.onNegative() + negativeResponse!!.onNegative(dialogMaterial) } } } @@ -142,6 +148,14 @@ open abstract class DialogMaterial{ this.builder.content(message) } + fun setOnPositive(onPositive:PositiveResponse){ + this.positiveResponse = onPositive + } + + fun setOnNegative(onNegative:NegativeResponse){ + this.negativeResponse = onNegative + } + fun setTitle(title: String) { this.builder.title(title) } diff --git a/app/src/main/java/cy/agorise/crystalwallet/dialogs/material/QuestionDialog.kt b/app/src/main/java/cy/agorise/crystalwallet/dialogs/material/QuestionDialog.kt new file mode 100644 index 0000000..88a48f4 --- /dev/null +++ b/app/src/main/java/cy/agorise/crystalwallet/dialogs/material/QuestionDialog.kt @@ -0,0 +1,61 @@ +package cy.agorise.crystalwallet.dialogs.material + +import android.app.Activity +import com.afollestad.materialdialogs.DialogAction +import com.afollestad.materialdialogs.MaterialDialog +import cy.agorise.crystalwallet.R + + + +/* +* This class is used to show a question dialog +* +* +* Use example: +* +* +* var questionDialog:QuestionDialog = QuestionDialog(globalActivity) + questionDialog.setText(getString(R.string.continue_question)) + questionDialog.setOnNegative(object : NegativeResponse{ + override fun onNegative(dialogMaterial: DialogMaterial) { + var test:String = "" + test = "" + dialogMaterial.dismiss() + } + }) + questionDialog.setOnPositive(object : PositiveResponse{ + override fun onPositive() { + var test:String = "" + test = "" + } + }) + questionDialog.show() + +* */ +class QuestionDialog : CrystalDialog { + + constructor(activity: Activity) : super(activity) { + + /* + * Create the buttons needed + * */ + this.builder.positiveText(activity.getString(R.string.ok)) + this.builder.negativeText(activity.getString(R.string.cancel)) + this.builder.onPositive(object : MaterialDialog.SingleButtonCallback{ + override fun onClick(dialog: MaterialDialog, which: DialogAction) { + if(positiveResponse != null){ + positiveResponse!!.onPositive() + } + } + + }) + this.builder.onNegative(object : MaterialDialog.SingleButtonCallback { + override fun onClick(dialog: MaterialDialog, which: DialogAction) { + if(negativeResponse != null){ + negativeResponse!!.onNegative(dialogMaterial) + } + } + + }) + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/backup_seed.xml b/app/src/main/res/layout/backup_seed.xml index 511b6b9..bff1e5d 100644 --- a/app/src/main/res/layout/backup_seed.xml +++ b/app/src/main/res/layout/backup_seed.xml @@ -44,6 +44,7 @@ android:layout_marginLeft="@dimen/activity_horizontal_margin" android:layout_marginRight="@dimen/activity_horizontal_margin" android:gravity="center" + android:text="" android:background="#00000000" android:textColor="@color/gray" /> @@ -68,20 +69,31 @@ android:layout_marginTop="35dp" android:layout_toLeftOf="@+id/btnCopy" android:background="?android:attr/selectableItemBackground" - android:text="@string/ok" + android:text="@string/cancel" android:textColor="#0099ff" />