From d675e6b2c6a8c48e2bca19fa10e84b2d43c01c78 Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 22 Oct 2018 20:52:45 +0300 Subject: [PATCH] pgp --- app/build.gradle | 22 +-- .../bitshareswallet/BalancesFragment.java | 34 +++-- .../bitshareswallet/ConfirmOrderDialog.java | 3 + .../CreateAccountActivity.java | 91 ++++++------ .../bitshareswallet/ImportActivty.java | 6 +- .../bitshareswallet/LockActivity.java | 11 +- .../bitshareswallet/MainActivity.java | 24 ++-- .../bitshareswallet/OrdersFragment.java | 2 +- .../bitshareswallet/PinSetFragment.java | 8 +- .../QuotationCurrencyPairAdapter.java | 2 +- .../bitshareswallet/SendFragment.java | 3 - .../bitshareswallet/SettingsFragment.java | 6 +- .../TransactionSellBuyFragment.java | 17 ++- .../TransactionSellBuyPasswordDialog.java | 2 + .../wallet/BitsharesWalletWraper.java | 6 + .../here/dialog/TokenSelectAdapter.java | 64 +++++++++ .../starts/here/dialog/TokenSelectDialog.java | 7 + .../starts/here/servers/ServersFragment.java | 5 + .../here/servers/ServersRecyclerAdapter.java | 3 +- .../res/layout/activity_create_account.xml | 130 ++++-------------- .../res/layout/activity_import_activty.xml | 91 +++++------- app/src/main/res/layout/dialog_search.xml | 37 +++++ app/src/main/res/layout/item_token.xml | 23 ++++ app/src/main/res/layout/other_textinput.xml | 31 +++++ .../res/layout/recyclerview_item_balances.xml | 43 ++---- app/src/main/res/menu/navigation_bottom.xml | 5 - app/src/main/res/values/arrays.xml | 48 +++---- app/src/main/res/values/strings.xml | 11 +- app/src/main/res/xml/preferences.xml | 2 +- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 0 32 files changed, 405 insertions(+), 336 deletions(-) create mode 100644 app/src/main/java/com/good/code/starts/here/dialog/TokenSelectAdapter.java create mode 100644 app/src/main/java/com/good/code/starts/here/dialog/TokenSelectDialog.java create mode 100644 app/src/main/res/layout/dialog_search.xml create mode 100644 app/src/main/res/layout/item_token.xml create mode 100644 app/src/main/res/layout/other_textinput.xml mode change 100755 => 100644 gradlew diff --git a/app/build.gradle b/app/build.gradle index 9bf103f..c0c5b36 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,7 +4,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:3.1.4' + classpath 'com.android.tools.build:gradle:3.2.1' classpath 'io.sentry:sentry-android-gradle-plugin:1.7.5' } } @@ -18,12 +18,12 @@ repositories { } android { - compileSdkVersion 27 - buildToolsVersion '28.0.2' + compileSdkVersion 28 + buildToolsVersion '28.0.3' defaultConfig { applicationId "com.bitshares.bitshareswallet" minSdkVersion 15 - targetSdkVersion 27 + targetSdkVersion 28 versionCode 10201001 versionName "1.2.1.1" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" @@ -39,9 +39,9 @@ android { } buildTypes { release { - minifyEnabled true + minifyEnabled false //proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - proguardFiles 'proguard-rules.pro' + //proguardFiles 'proguard-rules.pro' } debug { applicationIdSuffix ".debug" @@ -96,12 +96,12 @@ dependencies { implementation 'io.sentry:sentry-android:1.7.5' //implementation "ch.acra:acra-http:5.1.3" - implementation 'com.android.support:appcompat-v7:27.1.1' + implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' - implementation 'com.android.support:support-v4:27.1.1' - implementation 'com.android.support:preference-v7:27.1.1' - implementation 'com.android.support:preference-v14:27.1.1' - implementation 'com.android.support:design:27.1.1' + implementation 'com.android.support:support-v4:28.0.0' + implementation 'com.android.support:preference-v7:28.0.0' + implementation 'com.android.support:preference-v14:28.0.0' + implementation 'com.android.support:design:28.0.0' implementation 'com.google.guava:guava:23.0-android' implementation 'com.madgag.spongycastle:core:1.56.0.0' implementation 'com.madgag.spongycastle:prov:1.56.0.0' diff --git a/app/src/main/java/com/bitshares/bitshareswallet/BalancesFragment.java b/app/src/main/java/com/bitshares/bitshareswallet/BalancesFragment.java index e1728db..9915b4c 100644 --- a/app/src/main/java/com/bitshares/bitshareswallet/BalancesFragment.java +++ b/app/src/main/java/com/bitshares/bitshareswallet/BalancesFragment.java @@ -7,6 +7,7 @@ import android.support.v4.app.Fragment; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -15,6 +16,8 @@ import com.bitshares.bitshareswallet.room.BitsharesBalanceAsset; import com.bitshares.bitshareswallet.viewmodel.WalletViewModel; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.List; import java.util.Locale; @@ -36,18 +39,12 @@ public class BalancesFragment extends BaseFragment { class BalanceItemViewHolder extends RecyclerView.ViewHolder { public View view; public TextView viewNumber; - public TextView viewUnit; - public TextView viewEqual; - public TextView viewConvertNumber; public TextView viewConvertUnit; public BalanceItemViewHolder(View itemView) { super(itemView); view = itemView; viewNumber = itemView.findViewById(R.id.textViewNumber); - viewUnit = itemView.findViewById(R.id.textViewUnit); - viewEqual = itemView.findViewById(R.id.textViewEqual); - viewConvertNumber = itemView.findViewById(R.id.textViewNumber2); viewConvertUnit = itemView.findViewById(R.id.textViewUnit2); } } @@ -64,21 +61,22 @@ public BalanceItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) @Override public void onBindViewHolder(BalanceItemViewHolder holder, int position) { BitsharesBalanceAsset bitsharesBalanceAsset = bitsharesBalanceAssetList.get(position); - String strBalances = String.format( + /*String strBalances = String.format( Locale.ENGLISH, "%.4f", (float)bitsharesBalanceAsset.amount / bitsharesBalanceAsset.quote_precision - ); - - holder.viewNumber.setText(strBalances); - holder.viewUnit.setText(bitsharesBalanceAsset.quote); - if (bitsharesBalanceAsset.quote.compareTo("FINTEH") != 0) { - int nResult = (int)Math.rint(bitsharesBalanceAsset.total / bitsharesBalanceAsset.base_precision); - - holder.viewEqual.setText("="); - holder.viewConvertNumber.setText(Integer.valueOf(nResult).toString()); - holder.viewConvertUnit.setText("FINTEH"); - } + );*/ + BigDecimal balance = new BigDecimal(bitsharesBalanceAsset.amount).setScale(String.valueOf(bitsharesBalanceAsset.quote_precision).length()-1, BigDecimal.ROUND_UNNECESSARY).divide(new BigDecimal(bitsharesBalanceAsset.quote_precision), RoundingMode.UNNECESSARY).stripTrailingZeros(); + + holder.viewNumber.setText(balance.toPlainString()); + //holder.viewUnit.setText(bitsharesBalanceAsset.quote); + //if (bitsharesBalanceAsset.quote.compareTo("FINTEH") != 0) { + //int nResult = (int)Math.rint(bitsharesBalanceAsset.total / bitsharesBalanceAsset.base_precision); + + //holder.viewEqual.setText("="); + //holder.viewConvertNumber.setText(Integer.valueOf(nResult).toString()); + holder.viewConvertUnit.setText(bitsharesBalanceAsset.quote); + //} } diff --git a/app/src/main/java/com/bitshares/bitshareswallet/ConfirmOrderDialog.java b/app/src/main/java/com/bitshares/bitshareswallet/ConfirmOrderDialog.java index d8cde2f..6292147 100644 --- a/app/src/main/java/com/bitshares/bitshareswallet/ConfirmOrderDialog.java +++ b/app/src/main/java/com/bitshares/bitshareswallet/ConfirmOrderDialog.java @@ -118,6 +118,9 @@ public ConfirmOrderDialog(Activity mActivity, ConfirmOrderData confirmOrderData) View view = mActivity.getLayoutInflater().inflate(R.layout.dialog_confirm_order, null); + TextView tokenText = (TextView) view.findViewById(R.id.dco_txt_target_coin_name); + tokenText.setText(confirmOrderData.getQuantityType() + ":"); + TextView txtOperation = (TextView) view.findViewById(R.id.dco_txt_operation); txtOperation.setText(confirmOrderData.getOperationName()); diff --git a/app/src/main/java/com/bitshares/bitshareswallet/CreateAccountActivity.java b/app/src/main/java/com/bitshares/bitshareswallet/CreateAccountActivity.java index 6ab3d5e..6ee2744 100644 --- a/app/src/main/java/com/bitshares/bitshareswallet/CreateAccountActivity.java +++ b/app/src/main/java/com/bitshares/bitshareswallet/CreateAccountActivity.java @@ -1,6 +1,7 @@ package com.bitshares.bitshareswallet; import android.content.Intent; +import android.support.design.widget.TextInputLayout; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; @@ -40,7 +41,7 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_create_account); - mToolbar = (Toolbar) findViewById(R.id.toolbar); + mToolbar = findViewById(R.id.toolbar); setSupportActionBar(mToolbar); mToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override @@ -64,33 +65,36 @@ public void onClick(View v) { public void onClick(View v) { mProcessHud.show(); - String strAccount = ((EditText)findViewById(R.id.editTextAccountName)).getText().toString(); - String strPassword = ((EditText)findViewById(R.id.editTextPassword)).getText().toString(); - String strPasswordConfirm = ((EditText)findViewById(R.id.editTextPasswordConfirm)).getText().toString(); + String strAccount = ((EditText)findViewById(R.id.accountNameET)).getText().toString(); + String strPassword = ((EditText)findViewById(R.id.passwordET)).getText().toString(); + String strPasswordConfirm = ((EditText)findViewById(R.id.passwordConfET)).getText().toString(); CheckBox checkBox = (CheckBox)findViewById(R.id.checkBoxConfirm); - TextView textViewAccountError = (TextView)findViewById(R.id.textViewErrorAccount); + /*TextView textViewAccountError = (TextView)findViewById(R.id.textViewErrorAccount); TextView textViewPasswordError = (TextView)findViewById(R.id.textViewErrorPasswrod); - TextView textViewPasswordConfirmError = (TextView)findViewById(R.id.textViewErrorInfo); + TextView textViewPasswordConfirmError = (TextView)findViewById(R.id.textViewErrorInfo);*/ + TextInputLayout textViewAccount = findViewById(R.id.accountNameIL); + TextInputLayout textViewPassword = findViewById(R.id.passwordIL); + TextInputLayout textViewPasswordConfirm = findViewById(R.id.passwordConfIL); boolean bError = false; if (strAccount.isEmpty()) { - textViewAccountError.setText(R.string.create_account_account_name_empty); + textViewAccount.setError(getString(R.string.create_account_account_name_empty)); bError = true; } if (strPassword.isEmpty()) { - textViewPasswordError.setText(R.string.create_account_password_empty); + textViewPassword.setError(getString(R.string.create_account_password_empty)); bError = true; } if (strPasswordConfirm.isEmpty()) { - textViewPasswordConfirmError.setText(R.string.create_account_password_confirm_empty); + textViewPasswordConfirm.setError(getString(R.string.create_account_password_confirm_empty)); bError = true; } - if (bError == false && textViewAccountError.getText().length() == 0 && textViewPasswordError.getText().length() == 0) { + if (bError == false && !textViewAccount.isErrorEnabled() && !textViewPassword.isErrorEnabled()) { if (checkBox.isChecked() == true) { processCreateAccount(strAccount, strPassword, strPasswordConfirm); } else { @@ -105,13 +109,8 @@ public void onClick(View v) { } }); - EditText editTextAccountName = (EditText)findViewById(R.id.editTextAccountName); - InputFilter lowercaseFilter = new InputFilter() { - @Override - public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { - return source.toString().toLowerCase(); - } - }; + EditText editTextAccountName = findViewById(R.id.accountNameET); + InputFilter lowercaseFilter = (source, start, end, dest, dstart, dend) -> source.toString().toLowerCase(); editTextAccountName.setFilters(new InputFilter[] {lowercaseFilter, new InputFilter.LengthFilter(63)}); editTextAccountName.addTextChangedListener(new TextWatcher() { @@ -132,16 +131,16 @@ public void afterTextChanged(Editable s) { return; } - TextView textViewError = (TextView)findViewById(R.id.textViewErrorAccount); + TextInputLayout textViewError = findViewById(R.id.accountNameIL); if (Character.isLetter(strAccountName.charAt(0)) == false) { - textViewError.setText(R.string.create_account_account_name_error_start_letter); - findViewById(R.id.imageViewAccountCheck).setVisibility(View.INVISIBLE); + textViewError.setError(getString(R.string.create_account_account_name_error_start_letter)); + //findViewById(R.id.imageViewAccountCheck).setVisibility(View.INVISIBLE); } else if (strAccountName.length() <= 4) { // 用户名太短 - textViewError.setText(R.string.create_account_account_name_too_short); - findViewById(R.id.imageViewAccountCheck).setVisibility(View.INVISIBLE); + textViewError.setError(getString(R.string.create_account_account_name_too_short)); + //findViewById(R.id.imageViewAccountCheck).setVisibility(View.INVISIBLE); } else if (strAccountName.endsWith("-")) { - textViewError.setText(R.string.create_account_account_name_error_dash_end); - findViewById(R.id.imageViewAccountCheck).setVisibility(View.INVISIBLE); + textViewError.setError(getString(R.string.create_account_account_name_error_dash_end)); + //findViewById(R.id.imageViewAccountCheck).setVisibility(View.INVISIBLE); } else { boolean bCombineAccount = false; for (char c : strAccountName.toCharArray()) { @@ -151,10 +150,11 @@ public void afterTextChanged(Editable s) { } if (bCombineAccount == false) { - textViewError.setText(R.string.create_account_account_name_error_full_letter); - findViewById(R.id.imageViewAccountCheck).setVisibility(View.INVISIBLE); + textViewError.setError(getString(R.string.create_account_account_name_error_full_letter)); + //findViewById(R.id.imageViewAccountCheck).setVisibility(View.INVISIBLE); } else { - textViewError.setText(""); + textViewError.setError(""); + textViewError.setErrorEnabled(false); //findViewById(R.id.imageViewAccountCheck).setVisibility(View.VISIBLE); processCheckAccount(strAccountName); } @@ -162,7 +162,7 @@ public void afterTextChanged(Editable s) { } }); - final EditText editTextPassword = (EditText)findViewById(R.id.editTextPassword); + final EditText editTextPassword = (EditText)findViewById(R.id.passwordET); editTextPassword.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { @@ -178,23 +178,24 @@ public void onTextChanged(CharSequence s, int start, int before, int count) { public void afterTextChanged(Editable s) { String strPassword = s.toString(); - TextView textViewError = (TextView)findViewById(R.id.textViewErrorPasswrod); + TextInputLayout textViewError = findViewById(R.id.passwordIL); if (strPassword.length() < 12) { - textViewError.setText(R.string.create_account_password_requirement); + textViewError.setError(getString(R.string.create_account_password_requirement)); } else { boolean bDigit = strPassword.matches(".*\\d+.*"); boolean bUpperCase = strPassword.matches(".*[A-Z]+.*"); boolean bLowerCase = strPassword.matches(".*[a-z]+.*"); - if ((bDigit && bUpperCase && bLowerCase) == false) { - textViewError.setText(R.string.create_account_password_requirement); + if (!(bDigit && bUpperCase && bLowerCase)) { + textViewError.setError(getString(R.string.create_account_password_requirement)); } else { - textViewError.setText(""); + textViewError.setError(""); + textViewError.setErrorEnabled(false); } } } }); - EditText editTextPasswordConfirm = (EditText)findViewById(R.id.editTextPasswordConfirm); + EditText editTextPasswordConfirm = findViewById(R.id.passwordConfET); editTextPasswordConfirm.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { @@ -211,13 +212,15 @@ public void afterTextChanged(Editable s) { String strPassword = editTextPassword.getText().toString(); String strPasswordConfirm = s.toString(); - TextView textViewErrorInfo = (TextView)findViewById(R.id.textViewErrorInfo); + TextInputLayout textViewErrorInfo = findViewById(R.id.passwordConfIL); if (strPassword.compareTo(strPasswordConfirm) == 0) { - findViewById(R.id.imageViewPasswordConfirmCheck).setVisibility(View.VISIBLE); - textViewErrorInfo.setText(""); + //findViewById(R.id.imageViewPasswordConfirmCheck).setVisibility(View.VISIBLE); + textViewErrorInfo.setError(""); + textViewErrorInfo.setErrorEnabled(false); } else { - findViewById(R.id.imageViewPasswordConfirmCheck).setVisibility(View.INVISIBLE); - textViewErrorInfo.setText(R.string.create_account_password_confirm_error); + textViewErrorInfo.setError(getString(R.string.pass_no_match)); + //findViewById(R.id.imageViewPasswordConfirmCheck).setVisibility(View.INVISIBLE); + //textViewErrorInfo.setText(R.string.create_account_password_confirm_error); } } }); @@ -343,14 +346,14 @@ public void run() { @Override public void run() { if (accountObect == null) { - findViewById(R.id.imageViewAccountCheck).setVisibility(View.VISIBLE); + //findViewById(R.id.imageViewAccountCheck).setVisibility(View.VISIBLE); } else { - EditText editTextAccount = (EditText)findViewById(R.id.editTextAccountName); + EditText editTextAccount = (EditText)findViewById(R.id.accountNameET); String strAccountName = editTextAccount.getText().toString(); if (strAccountName.compareTo(accountObect.name) == 0) { - TextView textViewError = (TextView) findViewById(R.id.textViewErrorAccount); - textViewError.setText(R.string.create_account_activity_account_object_exist); - findViewById(R.id.imageViewAccountCheck).setVisibility(View.INVISIBLE); + TextInputLayout textViewError = findViewById(R.id.accountNameIL); + textViewError.setError(getString(R.string.create_account_activity_account_object_exist)); + //findViewById(R.id.imageViewAccountCheck).setVisibility(View.INVISIBLE); } } } diff --git a/app/src/main/java/com/bitshares/bitshareswallet/ImportActivty.java b/app/src/main/java/com/bitshares/bitshareswallet/ImportActivty.java index 7a94058..59d9f71 100644 --- a/app/src/main/java/com/bitshares/bitshareswallet/ImportActivty.java +++ b/app/src/main/java/com/bitshares/bitshareswallet/ImportActivty.java @@ -78,8 +78,8 @@ public void onClick(View v) { // 将按钮转换成为进度条 mProcessHud.show(); - String strAccount = ((EditText)findViewById(R.id.editTextAccountName)).getText().toString(); - String strPassword = ((EditText)findViewById(R.id.editTextPassword)).getText().toString(); + String strAccount = ((EditText)findViewById(R.id.accountNameET)).getText().toString(); + String strPassword = ((EditText)findViewById(R.id.passwordET)).getText().toString(); String strPrivateKey = ((EditText)findViewById(R.id.editTextPrivateKey)).getText().toString(); if (mnModel == ACCOUNT_MODEL) { @@ -122,7 +122,7 @@ public void onClick(View v) { View layoutPrivateKey = findViewById(R.id.layoutPrivateKey); View layoutBrainKey = findViewById(R.id.layoutBrainKey); View layoutFileBin = findViewById(R.id.layoutFileBin); - View layoutAccountName = findViewById(R.id.layoutAccountName); + View layoutAccountName = findViewById(R.id.accountNameIL); mnModel = getIntent().getIntExtra("model", 0); switch (mnModel) { diff --git a/app/src/main/java/com/bitshares/bitshareswallet/LockActivity.java b/app/src/main/java/com/bitshares/bitshareswallet/LockActivity.java index 0709094..2901fcb 100644 --- a/app/src/main/java/com/bitshares/bitshareswallet/LockActivity.java +++ b/app/src/main/java/com/bitshares/bitshareswallet/LockActivity.java @@ -3,10 +3,12 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.os.Build; import android.os.Bundle; import android.preference.PreferenceManager; import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; +import android.util.Log; import android.webkit.WebSettings; import android.webkit.WebView; import android.widget.Toast; @@ -18,6 +20,14 @@ import com.bitshares.bitshareswallet.wallet.BitsharesWalletWraper; import com.bitshares.bitshareswallet.wallet.fc.crypto.sha256_object; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; + +import de.bitsharesmunich.graphenej.FileBin; +import de.bitsharesmunich.graphenej.Util; +import de.bitsharesmunich.graphenej.models.backup.WalletBackup; + public class LockActivity extends AppCompatActivity { private SharedPreferences preferences; @@ -25,7 +35,6 @@ public class LockActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - BitsharesWalletWraper bitsharesWalletWraper = BitsharesWalletWraper.getInstance(); if (bitsharesWalletWraper.load_wallet_file() != 0 || bitsharesWalletWraper.is_new()){ diff --git a/app/src/main/java/com/bitshares/bitshareswallet/MainActivity.java b/app/src/main/java/com/bitshares/bitshareswallet/MainActivity.java index 7f0b89c..8588676 100644 --- a/app/src/main/java/com/bitshares/bitshareswallet/MainActivity.java +++ b/app/src/main/java/com/bitshares/bitshareswallet/MainActivity.java @@ -109,7 +109,7 @@ protected void onNewIntent(Intent intent) { private void updateTitle(){ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(BitsharesApplication.getInstance()); - String strCurrencySetting = prefs.getString("quotation_currency_pair", "BTS:USD"); + String strCurrencySetting = prefs.getString("quotation_currency_pair", "FINTEH:USD"); String strAsset[] = strCurrencySetting.split(":"); try { @@ -169,7 +169,7 @@ protected void onCreate(Bundle savedInstanceState) { mExchangeFragment = ExchangeFragment.newInstance(); mMainFragmentPageAdapter.addFragment(mWalletFragment, "Wallet"); - mMainFragmentPageAdapter.addFragment(mQuotationFragment, "Quotation"); + //mMainFragmentPageAdapter.addFragment(mQuotationFragment, "Quotation"); mMainFragmentPageAdapter.addFragment(mExchangeFragment, "Exchange"); mViewPager.setAdapter(mMainFragmentPageAdapter); @@ -186,14 +186,18 @@ public void onPageSelected(int position) { if(lastTitle != null) getSupportActionBar().setTitle(lastTitle); lastTitle = null; } else if(position == 1) { - mBottomNavigation.setSelectedItemId(R.id.navigation_quotation); + /*mBottomNavigation.setSelectedItemId(R.id.navigation_quotation); if(lastTitle == null) lastTitle = mToolbar.getTitle().toString(); + mToolbar.setTitle("");*/ + mBottomNavigation.setSelectedItemId(R.id.navigation_exchange); + if (lastTitle == null) lastTitle = mToolbar.getTitle().toString(); mToolbar.setTitle(""); - } else if(position == 2) { + } + /*} else if(position == 2) { mBottomNavigation.setSelectedItemId(R.id.navigation_exchange); if(lastTitle == null) lastTitle = mToolbar.getTitle().toString(); mToolbar.setTitle(""); - } + }*/ setTitleVisible(position!=0); mMainFragmentPageAdapter.updatePagePosition(position); } @@ -217,6 +221,8 @@ public void onPageScrollStateChanged(int state) { Intent intentAbout = new Intent(MainActivity.this, AboutActivity.class); startActivity(intentAbout); break; + case R.id.backup: + //BitsharesWalletWraper.getInstance().get_account(). } mDrawerLayout.closeDrawer(GravityCompat.START); @@ -260,12 +266,12 @@ public void onPageScrollStateChanged(int state) { case R.id.navigation_wallet: mViewPager.setCurrentItem(0, true); return true; - case R.id.navigation_quotation: + case R.id.navigation_exchange: mViewPager.setCurrentItem(1, true); return true; - case R.id.navigation_exchange: + /*case R.id.navigation_exchange: mViewPager.setCurrentItem(2, true); - return true; + return true;*/ } return false; }); @@ -374,7 +380,7 @@ private void processChooseCurency(){ Resources res = getResources(); final String[] arrValues = res.getStringArray(R.array.quotation_currency_pair_values); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(BitsharesApplication.getInstance()); - String strCurrencySetting = prefs.getString("quotation_currency_pair", "BTS:USD"); + String strCurrencySetting = prefs.getString("quotation_currency_pair", "FINTEH:USD"); int currSelectIndex = 0; for(int i=0; i { int res = BitsharesWalletWraper.getInstance().unlock(editText.getText().toString()); diff --git a/app/src/main/java/com/bitshares/bitshareswallet/QuotationCurrencyPairAdapter.java b/app/src/main/java/com/bitshares/bitshareswallet/QuotationCurrencyPairAdapter.java index 1ba06cd..facda7b 100644 --- a/app/src/main/java/com/bitshares/bitshareswallet/QuotationCurrencyPairAdapter.java +++ b/app/src/main/java/com/bitshares/bitshareswallet/QuotationCurrencyPairAdapter.java @@ -186,7 +186,7 @@ public void notifyDataUpdated(List marketTickerList) { ); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext); - String strAssetPairConfig = prefs.getString("quotation_currency_pair", "BTS:USD"); + String strAssetPairConfig = prefs.getString("quotation_currency_pair", "FINTEH:USD"); for (int i = 0; i < bitsharesMarketTickerList.size(); ++i) { MarketTicker marketTicker = bitsharesMarketTickerList.get(i).marketTicker; String currencyPair = utils.getAssetSymbolDisply(marketTicker.quote) + ":" + diff --git a/app/src/main/java/com/bitshares/bitshareswallet/SendFragment.java b/app/src/main/java/com/bitshares/bitshareswallet/SendFragment.java index 4116e58..25c3d23 100644 --- a/app/src/main/java/com/bitshares/bitshareswallet/SendFragment.java +++ b/app/src/main/java/com/bitshares/bitshareswallet/SendFragment.java @@ -328,7 +328,6 @@ private void processSendClick(final View view) { String strMemo = ((EditText)view.findViewById(R.id.editTextMemo)).getText().toString(); processTransfer(strFrom, strTo, strQuantity, strSymbol, strMemo); } else { - AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); LayoutInflater layoutInflater = getActivity().getLayoutInflater(); final View viewGroup = layoutInflater.inflate(R.layout.dialog_password_confirm, null); @@ -397,8 +396,6 @@ private void processGetTransferToId(final String strAccount, final TextView text }); } - - public static void hideSoftKeyboard(View view, Context context) { if (view != null && context != null) { InputMethodManager imm = (InputMethodManager) context diff --git a/app/src/main/java/com/bitshares/bitshareswallet/SettingsFragment.java b/app/src/main/java/com/bitshares/bitshareswallet/SettingsFragment.java index 7939a3c..65a6350 100644 --- a/app/src/main/java/com/bitshares/bitshareswallet/SettingsFragment.java +++ b/app/src/main/java/com/bitshares/bitshareswallet/SettingsFragment.java @@ -22,13 +22,15 @@ public class SettingsFragment extends PreferenceFragmentCompat { public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { setPreferencesFromResource(R.xml.preferences, rootKey); - Preference preference = findPreference("currency_setting"); + findPreference("currency_setting").setVisible(false); + + /*Preference preference = findPreference("currency_setting"); preference.setOnPreferenceChangeListener((preference1, newValue) -> { Intent intent = new Intent(); intent.putExtra("setting_changed", "currency_setting"); getActivity().setResult(Activity.RESULT_OK, intent); return true; - }); + });*/ Preference pinPreference = findPreference("pin_settings"); pinPreference.setOnPreferenceClickListener(p -> { diff --git a/app/src/main/java/com/bitshares/bitshareswallet/TransactionSellBuyFragment.java b/app/src/main/java/com/bitshares/bitshareswallet/TransactionSellBuyFragment.java index f505ed3..a118ca6 100644 --- a/app/src/main/java/com/bitshares/bitshareswallet/TransactionSellBuyFragment.java +++ b/app/src/main/java/com/bitshares/bitshareswallet/TransactionSellBuyFragment.java @@ -443,7 +443,20 @@ public void onReject(AlertDialog dialog) { dialog.dismiss(); } }); - builder.show(); + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); + if(prefs.contains("pass")) { + if (BitsharesWalletWraper.getInstance().unlock(prefs.getString("pass", "")) == 0) { + if (transactionType == TRANSACTION_BUY) { + buy(pValue, qValue, buyTimeSec); + } else if (transactionType == TRANSACTION_SELL) { + sell(pValue, qValue, buyTimeSec); + } + } else { + Toast.makeText(getContext(), getContext().getString(R.string.password_invalid), Toast.LENGTH_LONG).show(); + } + } else { + builder.show(); + } } } @@ -518,7 +531,7 @@ private void updateMaxOrderCount(){ private void updateCurency(){ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); - String strAssetPair = prefs.getString("quotation_currency_pair", "BTS:USD"); + String strAssetPair = prefs.getString("quotation_currency_pair", "FINTEH:USD"); String strAsset[] = strAssetPair.split(":"); baseAsset = strAsset[1]; quoteAsset = strAsset[0]; diff --git a/app/src/main/java/com/bitshares/bitshareswallet/TransactionSellBuyPasswordDialog.java b/app/src/main/java/com/bitshares/bitshareswallet/TransactionSellBuyPasswordDialog.java index 20bfb65..952b1aa 100644 --- a/app/src/main/java/com/bitshares/bitshareswallet/TransactionSellBuyPasswordDialog.java +++ b/app/src/main/java/com/bitshares/bitshareswallet/TransactionSellBuyPasswordDialog.java @@ -1,7 +1,9 @@ package com.bitshares.bitshareswallet; import android.app.Activity; +import android.content.SharedPreferences; import android.support.v7.app.AlertDialog; +import android.support.v7.preference.PreferenceManager; import android.view.View; import android.widget.EditText; import android.widget.TextView; diff --git a/app/src/main/java/com/bitshares/bitshareswallet/wallet/BitsharesWalletWraper.java b/app/src/main/java/com/bitshares/bitshareswallet/wallet/BitsharesWalletWraper.java index 62cc91e..824b78d 100644 --- a/app/src/main/java/com/bitshares/bitshareswallet/wallet/BitsharesWalletWraper.java +++ b/app/src/main/java/com/bitshares/bitshareswallet/wallet/BitsharesWalletWraper.java @@ -150,6 +150,12 @@ private int save_wallet_file() { return mWalletApi.save_wallet_file(mstrWalletFilePath); } + private void serializeToBin() { + + //FileBin.serializeWalletBackup(bitsharesWalletWraper.) + + } + public synchronized int build_connect() { if (mnStatus == STATUS_INITIALIZED) { return 0; diff --git a/app/src/main/java/com/good/code/starts/here/dialog/TokenSelectAdapter.java b/app/src/main/java/com/good/code/starts/here/dialog/TokenSelectAdapter.java new file mode 100644 index 0000000..9d0ffa7 --- /dev/null +++ b/app/src/main/java/com/good/code/starts/here/dialog/TokenSelectAdapter.java @@ -0,0 +1,64 @@ +package com.good.code.starts.here.dialog; + +import android.support.annotation.NonNull; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import com.bitshares.bitshareswallet.R; + +import java.util.List; + +public class TokenSelectAdapter extends RecyclerView.Adapter { + + private List tokens; + private OnTokenSelectListener listener; + + public TokenSelectAdapter(List tokens) { + this.tokens = tokens; + } + + public void setListener(OnTokenSelectListener listener) { + this.listener = listener; + } + + @NonNull + @Override + public TokenViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) { + View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_server, viewGroup, false); + return new TokenViewHolder(view); + } + + @Override + public void onBindViewHolder(@NonNull TokenViewHolder tokenViewHolder, int i) { + tokenViewHolder.textView.setText(tokens.get(i)); + + tokenViewHolder.itemView.setOnClickListener(v -> { + if(listener != null) listener.onSelect(tokens.get(tokenViewHolder.getAdapterPosition())); + }); + } + + @Override + public int getItemCount() { + return tokens.size(); + } + + static class TokenViewHolder extends RecyclerView.ViewHolder { + + TextView textView; + + public TokenViewHolder(@NonNull View itemView) { + super(itemView); + textView = itemView.findViewById(R.id.itemText); + } + } + + public interface OnTokenSelectListener { + + public void onSelect(String token); + + } + +} diff --git a/app/src/main/java/com/good/code/starts/here/dialog/TokenSelectDialog.java b/app/src/main/java/com/good/code/starts/here/dialog/TokenSelectDialog.java new file mode 100644 index 0000000..1f95a11 --- /dev/null +++ b/app/src/main/java/com/good/code/starts/here/dialog/TokenSelectDialog.java @@ -0,0 +1,7 @@ +package com.good.code.starts.here.dialog; + +public class TokenSelectDialog { + + + +} diff --git a/app/src/main/java/com/good/code/starts/here/servers/ServersFragment.java b/app/src/main/java/com/good/code/starts/here/servers/ServersFragment.java index e774400..dc98f41 100644 --- a/app/src/main/java/com/good/code/starts/here/servers/ServersFragment.java +++ b/app/src/main/java/com/good/code/starts/here/servers/ServersFragment.java @@ -8,6 +8,7 @@ import android.support.design.widget.FloatingActionButton; import android.support.v4.app.Fragment; import android.support.v7.preference.PreferenceManager; +import android.support.v7.widget.DividerItemDecoration; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; @@ -91,6 +92,10 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c layoutManager.setOrientation(LinearLayoutManager.VERTICAL); recyclerView.setLayoutManager(layoutManager); + + DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(), LinearLayoutManager.VERTICAL); + recyclerView.addItemDecoration(dividerItemDecoration); + recyclerView.setAdapter(adapter); repository.get().observe(getActivity(), adapter::setNewData); diff --git a/app/src/main/java/com/good/code/starts/here/servers/ServersRecyclerAdapter.java b/app/src/main/java/com/good/code/starts/here/servers/ServersRecyclerAdapter.java index 6c78980..329952f 100644 --- a/app/src/main/java/com/good/code/starts/here/servers/ServersRecyclerAdapter.java +++ b/app/src/main/java/com/good/code/starts/here/servers/ServersRecyclerAdapter.java @@ -61,8 +61,7 @@ public void setNewData(List newServers) { @Override public ServerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { - View view = LayoutInflater.from(parent.getContext()) - .inflate(R.layout.item_server, parent, false); + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_server, parent, false); return new ServerViewHolder(view); } diff --git a/app/src/main/res/layout/activity_create_account.xml b/app/src/main/res/layout/activity_create_account.xml index 69cd882..f86c072 100644 --- a/app/src/main/res/layout/activity_create_account.xml +++ b/app/src/main/res/layout/activity_create_account.xml @@ -39,128 +39,52 @@ android:layout_height="match_parent" android:orientation="vertical"> - - - + android:layout_height="wrap_content"> - - - - - - - - - - + android:hint="@string/import_account_name" + android:inputType="text" /> - + - - - + app:passwordToggleEnabled="true"> - + - + + + app:passwordToggleEnabled="true"> - - - - - - - + - + android:layout_height="wrap_content"> - - - - + - - - - @@ -89,41 +70,40 @@ android:layout_height="wrap_content" android:layout_marginTop="8dp" android:inputType="textMultiLine" + android:hint="@string/label_file_path" android:lines="2" android:minLines="2" /> - - + - - - + + + + app:passwordToggleEnabled="true"> - + + - + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_token.xml b/app/src/main/res/layout/item_token.xml new file mode 100644 index 0000000..7bcc323 --- /dev/null +++ b/app/src/main/res/layout/item_token.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/other_textinput.xml b/app/src/main/res/layout/other_textinput.xml new file mode 100644 index 0000000..816049a --- /dev/null +++ b/app/src/main/res/layout/other_textinput.xml @@ -0,0 +1,31 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/recyclerview_item_balances.xml b/app/src/main/res/layout/recyclerview_item_balances.xml index 8185f34..93564fd 100644 --- a/app/src/main/res/layout/recyclerview_item_balances.xml +++ b/app/src/main/res/layout/recyclerview_item_balances.xml @@ -8,48 +8,25 @@ android:layout_width="match_parent" android:layout_height="60dp" android:layout_margin="8dp"> + - - - - - - + android:textStyle="bold" /> + + android:layout_alignParentEnd="true" + android:layout_centerVertical="true" /> - - - BTS:USD - BTS:CNY - BTC:BTS - BTC:USD - BTC:CNY - ETH:BTS - ETH:USD - ETH:CNY - HERO:BTS - OBITS:BTS - SMOKE:BTS - USDT:USD - OCT:CNY - YOYOW:CNY - DASH:BTS + FINTEH:USD + FINTEH:CNY + FINTEH:RUBLE + FINTEH:EUR + FINTEH:BTC + FINTEH:RUDEX.BTC + FINTEH:RUDEX.ETH + FINTEH:RUDEX.EOS + FINTEH:RUDEX.STEEM - BTS:USD - BTS:CNY - OPEN.BTC:BTS - OPEN.BTC:USD - OPEN.BTC:CNY - OPEN.ETH:BTS - OPEN.ETH:USD - OPEN.ETH:CNY - HERO:BTS - OBITS:BTS - SMOKE:BTS - OPEN.USDT:USD - OCT:CNY - YOYOW:CNY - OPEN.DASH:BTS + FINTEH:USD + FINTEH:CNY + FINTEH:RUBLE + FINTEH:EUR + FINTEH:BTC + FINTEH:RUDEX.BTC + FINTEH:RUDEX.ETH + FINTEH:RUDEX.EOS + FINTEH:RUDEX.STEEM diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d36bc16..8760752 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -117,8 +117,8 @@ Are you sure you want to cancel this order? Log out - Account Name: - Password: + Account Name + Password Memo: From: To: @@ -132,16 +132,16 @@ Choose a currency Choose a Full Node Api Server - File Path: + File Path Select File - Private Key: + Private Key bitCNY/BTS BTS bitCNY Sign Up - Confirm password: + Confirm password SIGN UP Failed to connect to server The account has already existed @@ -209,5 +209,6 @@ Wallet password Save You do not have the requested token! + Passwords do not match! diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 5f736cd..77da08d 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -25,7 +25,7 @@ android:dialogTitle="@string/quotation_cureency_select_dialog_title" android:entries="@array/quotation_currency_pair_options" android:entryValues="@array/quotation_currency_pair_values" - android:defaultValue="BTS:USD"/> + android:defaultValue="FINTEH:USD"/>