Compare commits

..

No commits in common. "b12b3b9546c650aff8218be77f963a4fe64b9998" and "bfe65ac1a7223d6145250edd878e49e978cc3a50" have entirely different histories.

15 changed files with 195 additions and 173 deletions

View file

@ -87,6 +87,8 @@ dependencies {
implementation 'com.github.bilthon:graphenej:0.4.6'
implementation 'me.dm7.barcodescanner:zxing:1.9.8'
implementation 'com.github.sjaramillo10:AnimatedTabLayout:1.0.3'
implementation 'com.squareup.okhttp3:logging-interceptor:3.5.0'
implementation 'de.hdodenhof:circleimageview:2.2.0'

File diff suppressed because one or more lines are too long

View file

@ -70,7 +70,12 @@ public class LicenseActivity extends AppCompatActivity {
finish();
}
else{
wvEULA.loadUrl("file:///android_asset/crystal_eula.html");
/*
* Load the licence only if it is necesarry
* */
String html = getString(R.string.licence_html);
wvEULA.loadData(html, "text/html", "UTF-8");
}
}

View file

@ -1,19 +1,22 @@
package cy.agorise.crystalwallet.activities;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.sjaramillo10.animatedtablayout.AnimatedTabLayout;
import butterknife.BindView;
import butterknife.ButterKnife;
@ -34,7 +37,7 @@ public class SettingsActivity extends AppCompatActivity{
public ImageView ivGoBack;
@BindView(R.id.tabLayout)
public TabLayout tabLayout;
public AnimatedTabLayout tabLayout;
@BindView(R.id.pager)
public ViewPager mPager;

View file

@ -35,18 +35,14 @@ public abstract class GetEstimateFee {
call.enqueue(new Callback<JsonObject>() {
@Override
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
try {
listener.estimateFee((double) (response.body().get("2").getAsDouble()));
}catch (Exception e){
e.printStackTrace();
listener.fail();
}
}
@Override
public void onFailure(Call<JsonObject> call, Throwable t) {
listener.fail();
listener.estimateFee(-1);
}
});
}catch(Exception e){

View file

@ -97,8 +97,8 @@ class InsightApiServiceGenerator {
return chain.proceed(request);
}
});
sClientBuilder.readTimeout(30, TimeUnit.SECONDS);
sClientBuilder.connectTimeout(30, TimeUnit.SECONDS);
sClientBuilder.readTimeout(5, TimeUnit.MINUTES);
sClientBuilder.connectTimeout(5, TimeUnit.MINUTES);
OkHttpClient client = sClientBuilder.build();
Retrofit retrofit = sBuilder.client(client).build();
return retrofit.create(serviceClass);

View file

@ -52,8 +52,8 @@ public class CrystalApplication extends Application {
public static final String BITCOIN_SERVER_URLS[] ={
"https://testnet.blockexplorer.com/",
"https://test-insight.bitpay.com",
//"https://testnet.blockexplorer.com/",
//"https://insight.bitpay.com/"
};

View file

@ -28,6 +28,8 @@ import android.text.Editable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ImageView;
@ -127,6 +129,9 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
@BindView(R.id.gravatar)
CircularImageView userImg;
@BindView(R.id.viewCamera)
View viewCamera;
/* Flag to control when the camera is visible and when is hidden */
private boolean cameraVisible = false;
@ -137,7 +142,9 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
private FloatingActionButton fabSend;
private AlertDialog.Builder builder;
/* Dialog for loading */
/*
Dialog for loading
*/
private CrystalDialog crystalDialog;
public static SendTransactionFragment newInstance(long cryptoNetAccountId) {
@ -164,6 +171,7 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
//AlertDialog.Builder
builder = new AlertDialog.Builder(getActivity(), R.style.dialog_theme_full);
//builder.setTitle("Send");
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.send_transaction, null);
@ -171,7 +179,11 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
this.cryptoNetAccountId = getArguments().getLong("CRYPTO_NET_ACCOUNT_ID",-1);
/* Add style to the spinner android */
final Activity activity = getActivity();
/*
* Add style to the spinner android
* */
spFrom.setBackground(getContext().getDrawable(R.drawable.square_color));
if (this.cryptoNetAccountId != -1) {
@ -182,10 +194,36 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
List<CryptoNetAccount> cryptoNetAccounts = cryptoNetAccountListViewModel.getCryptoNetAccountList();
CryptoNetAccountAdapter fromSpinnerAdapter = new CryptoNetAccountAdapter(this.getContext(), android.R.layout.simple_spinner_item, cryptoNetAccounts);
/*
* If only one account block the control
* */
//if(cryptoNetAccounts.size()==1){
// spFrom.setEnabled(false);
//}
spFrom.setAdapter(fromSpinnerAdapter);
spFrom.setSelection(0);
setAccountUI();
/*
* Custom material spinner implementation
* */
//spFrom.setItems(cryptoNetAccounts);
//spFrom.setSelectedIndex(0);
//spFrom.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener<CryptoNetAccount>() {
// @Override
// public void onItemSelected(MaterialSpinner view, int position, long id, CryptoNetAccount item) {
// sendTransactionValidator.validate();
// }
//});
//spFrom.setOnNothingSelectedListener(new MaterialSpinner.OnNothingSelectedListener() {
// @Override public void onNothingSelected(MaterialSpinner spinner) {
// }
//});
// etFrom.setText(this.grapheneAccount.getName());
}
loadUserImage();
@ -226,7 +264,7 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
//cryptoCurrencyList.add(crypto1);
assetAdapter = new CryptoCurrencyAdapter(getContext(), android.R.layout.simple_spinner_item, cryptoCurrencyList);
CryptoCurrencyAdapter assetAdapter = new CryptoCurrencyAdapter(getContext(), android.R.layout.simple_spinner_item, cryptoCurrencyList);
spAsset.setAdapter(assetAdapter);
}
});
@ -302,7 +340,12 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
public void onResume() {
super.onResume();
mScannerView.setResultHandler(this);
mScannerView.startCamera();
// 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);
loadUserImage();
}
@ -378,6 +421,7 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
* */
private void showCamera(){
/* Change visibilities of views */
viewCamera.setVisibility(View.GONE);
mScannerView.setVisibility(View.VISIBLE);
/* Change icon */
@ -396,6 +440,7 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
* */
private void hideCamera(){
/* Change visibilities of views */
viewCamera.setVisibility(View.VISIBLE);
mScannerView.setVisibility(View.INVISIBLE);
/* Change icon */
@ -471,7 +516,10 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
if (fromAccountSelected.getCryptoNet() == CryptoNet.BITSHARES) {
/* This is only for graphene accounts. */
/*
* this is only for graphene accounts.
*
**/
GrapheneAccount grapheneAccountSelected = new GrapheneAccount(fromAccountSelected);
grapheneAccountSelected.loadInfo(db.grapheneAccountInfoDao().getByAccountId(fromAccountSelected.getId()));
@ -502,7 +550,6 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
throwable.printStackTrace();
}
} else {
crystalDialog.dismiss();
Toast.makeText(getContext(), getContext().getString(R.string.unable_to_send_amount), Toast.LENGTH_LONG);
}
}
@ -535,19 +582,22 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
throwable.printStackTrace();
}
} else {
crystalDialog.dismiss();
Toast.makeText(getContext(), getContext().getString(R.string.unable_to_send_amount), Toast.LENGTH_LONG);
}
}
});
}
/* If exists mode security show it and validate events in case of success or fail */
/*
* If exists mode scurity show it and valide events in case of success or fail
* */
CrystalSecurityMonitor.getInstance(this.getActivity()).callPasswordRequest(this.getActivity(), new OnResponse() {
@Override
public void onSuccess() {
/* Show loading dialog */
/*
* Show loading dialog
* */
crystalDialog = new CrystalDialog((Activity) getContext());
crystalDialog.setText("Sending");
crystalDialog.progress();
@ -578,6 +628,10 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
// Camera Permissions
private static final int REQUEST_CAMERA_PERMISSION = 1;
private static String[] PERMISSIONS_CAMERA = {
Manifest.permission.CAMERA
};
@Override
public void onValidationSucceeded(final ValidationField field) {

View file

@ -241,12 +241,11 @@ public class GeneralAccountManager implements CryptoAccountManager, CryptoNetInf
ccTransaction.setAccountId(address.getAccountId());
ccTransaction.setFrom(addr);
ccTransaction.setInput(false);
amount -= (long) (txi.fee * Math.pow(10, cryptoCoin.getPrecision()));
}
//if (ccTransaction.getAccountId() == address.getAccountId()) {
if (ccTransaction.getAccountId() == address.getAccountId()) {
amount -= (long) (vin.value * Math.pow(10, cryptoCoin.getPrecision()));
//}
}
}
if (ccTransaction.getFrom() == null || ccTransaction.getFrom().isEmpty()) {
@ -281,9 +280,9 @@ public class GeneralAccountManager implements CryptoAccountManager, CryptoNetInf
ccTransaction.setTo(addr);
}
//if (ccTransaction.getAccountId() == address.getAccountId()) {
if (ccTransaction.getAccountId() == address.getAccountId()) {
amount += (long) (vout.value * Math.pow(10, cryptoCoin.getPrecision()));
//}
}
} else {
//TOOD multiple send address
if (ccTransaction.getTo() == null || ccTransaction.getTo().isEmpty()) {
@ -310,7 +309,7 @@ public class GeneralAccountManager implements CryptoAccountManager, CryptoNetInf
btTransaction.setCryptoCoinTransactionId(ccId);
long btId = db.bitcoinTransactionDao().insertBitcoinTransaction(btTransaction)[0];
for (BitcoinTransactionGTxIO gtxio : gtxios) {
gtxio.setBitcoinTransactionId(ccId);
gtxio.setBitcoinTransactionId(btId);
db.bitcoinTransactionDao().insertBitcoinTransactionGTxIO(gtxio);
}
@ -375,37 +374,24 @@ public class GeneralAccountManager implements CryptoAccountManager, CryptoNetInf
//TODO check server connection
//TODO validate to address
System.out.println("GeneralAccount Manager Send request, asking fee");
InsightApiGenerator.getEstimateFee(this.cryptoCoin,new ApiRequest(1, new ApiRequestListener() {
@Override
public void success(Object answer, int idPetition) {
System.out.println("GeneralAccount Manager Send request, fee " + answer.toString());
try {
Transaction tx = new Transaction(cryptoCoin.getParameters());
long currentAmount = 0;
long fee = -1;
long feeRate = (long)(((double)answer) * Math.pow(10,cryptoCoin.getPrecision()));
fee = 226 * feeRate;
System.out.println("GeneralAccount Manager Send request getting utxos" );
CrystalDatabase db = CrystalDatabase.getAppDatabase(request.getContext());
db.bitcoinTransactionDao();
List<BitcoinTransactionGTxIO> utxos = getUtxos(request.getSourceAccount().getId(),db);
System.out.println("GeneralAccount Manager Send request utxos found " + utxos.size() );
for(BitcoinTransactionGTxIO utxo : utxos){
currentAmount += utxo.getAmount();
if(currentAmount >= request.getAmount() + fee) {
break;
}
}
if(currentAmount< request.getAmount() + fee){
System.out.println("GeneralAccount Manager Send request no balance" );
request.setStatus(BitcoinSendRequest.StatusCode.NO_BALANCE);
return;
}
AccountSeed seed = db.accountSeedDao().findById(request.getSourceAccount().getSeedId());
DeterministicKey purposeKey = HDKeyDerivation.deriveChildKey((DeterministicKey) seed.getPrivateKey(),
new ChildNumber(44, true));
@ -474,35 +460,23 @@ public class GeneralAccountManager implements CryptoAccountManager, CryptoNetInf
addrKey = HDKeyDerivation.deriveChildKey(externalKey, new ChildNumber((int) btAddress.getIndex(), true));
}
tx.addSignedInput(outPoint, script, addrKey, Transaction.SigHash.ALL, true);
currentAmount -= utxo.getAmount();
if(currentAmount<= 0){
break;
}
}
System.out.println("GeneralAccount Manager Send request rawtx " +Util.bytesToHex(tx.bitcoinSerialize()) );
InsightApiGenerator.broadcastTransaction(cryptoCoin,Util.bytesToHex(tx.bitcoinSerialize()),new ApiRequest(1, new ApiRequestListener() {
@Override
public void success(Object answer, int idPetition) {
System.out.println("GeneralAccount MAnager succed send");
request.setStatus(BitcoinSendRequest.StatusCode.SUCCEEDED);
}
@Override
public void fail(int idPetition) {
System.out.println("GeneralAccount MAnager succed fail");
request.setStatus(BitcoinSendRequest.StatusCode.PETITION_FAILED);
}
}));
}catch(Exception e){
System.out.println("GeneralAccount Manager Send request error ");
e.printStackTrace();
}
}
@Override
public void fail(int idPetition) {
System.out.println("GeneralAccount Manager Send request fee fail" );
request.setStatus(BitcoinSendRequest.StatusCode.NO_FEE);
}

View file

@ -14,8 +14,8 @@ import android.arch.persistence.room.ForeignKey;
primaryKeys = {"bitcoin_transaction_id", "io_index", "is_output"},
foreignKeys = {
@ForeignKey(
entity = CryptoCoinTransaction.class,
parentColumns = "id",
entity = BitcoinTransaction.class,
parentColumns = "crypto_coin_transaction_id",
childColumns = "bitcoin_transaction_id",
onDelete = ForeignKey.CASCADE
)

View file

@ -89,7 +89,7 @@ public class BitcoinSendRequest extends CryptoNetInfoRequest {
public void setStatus(StatusCode code){
this.status = code;
this.validate();
this._fireOnCarryOutEvent();
}
public StatusCode getStatus() {

View file

@ -79,12 +79,13 @@
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
<com.sjaramillo10.animatedtablayout.AnimatedTabLayout
android:id="@+id/tabLayout"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
app:tabBoldText="true"
app:tabMode="fixed" />
</RelativeLayout>

View file

@ -96,7 +96,7 @@
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
<com.sjaramillo10.animatedtablayout.AnimatedTabLayout
android:id="@+id/tabLayout"
android:layout_gravity="bottom"
android:background="@color/transparent"
@ -124,25 +124,21 @@
<android.support.design.widget.FloatingActionButton
android:id="@+id/fabReceive"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_gravity="start|bottom"
android:layout_marginBottom="-125dp"
android:layout_marginStart="-125dp"
app:fabCustomSize="250dp"
app:maxImageSize="200dp"
app:backgroundTint="@color/white"
app:srcCompat="@drawable/receive_icon" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fabSend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_gravity="end|bottom"
android:layout_marginBottom="-125dp"
android:layout_marginEnd="-125dp"
app:fabCustomSize="250dp"
app:maxImageSize="200dp"
app:backgroundTint="@color/white"
app:srcCompat="@drawable/send_icon" />

View file

@ -18,13 +18,6 @@
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5"/>
<android.support.constraint.Guideline
android:id="@+id/cameraVerticalGuideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.65"/>
<View
android:id="@+id/topView"
android:layout_width="match_parent"
@ -213,26 +206,13 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvMemoError" />
<View
android:id="@+id/viewCamera"
android:background="@color/black"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="16dp"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:visibility="visible"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintTop_toBottomOf="@+id/tvScan"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/cameraVerticalGuideline"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fabCloseCamera"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="32dp"
android:layout_height="32dp"
app:backgroundTint="@color/send_strong_orange"
app:fabCustomSize="32dp"
app:layout_constraintStart_toEndOf="@id/cameraVerticalGuideline"
app:fabSize="mini"
app:layout_constraintStart_toEndOf="@id/centeredVerticalGuideline"
app:layout_constraintTop_toBottomOf="@+id/tvScan"
app:srcCompat="@drawable/ok" />
@ -240,12 +220,26 @@
android:id="@+id/ivCamera"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="24dp"
android:layout_marginTop="16dp"
android:contentDescription="@string/camera_feed_to_scan_qr"
app:layout_constraintDimensionRatio="w,3:4"
app:layout_constraintTop_toTopOf="@+id/viewCamera"
app:layout_constraintBottom_toBottomOf="@id/viewCamera"
app:layout_constraintStart_toStartOf="@id/viewCamera"
app:layout_constraintEnd_toEndOf="@id/viewCamera" />
android:src="#666"
app:layout_constraintDimensionRatio="h,3:4"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/centeredVerticalGuideline"
app:layout_constraintTop_toTopOf="@+id/fabCloseCamera" />
<View
android:id="@+id/viewCamera"
android:background="@color/black"
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="visible"
android:src="#666"
app:layout_constraintTop_toTopOf="@id/ivCamera"
app:layout_constraintStart_toStartOf="@id/ivCamera"
app:layout_constraintEnd_toEndOf="@id/ivCamera"
app:layout_constraintBottom_toBottomOf="@+id/ivCamera"/>
<View
android:id="@+id/viewSend"
@ -254,16 +248,13 @@
android:layout_marginEnd="0dp"
android:background="@drawable/send_transaction_send_view"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/viewCamera"
app:layout_constraintBottom_toBottomOf="@id/viewCamera"/>
app:layout_constraintTop_toTopOf="@id/ivCamera" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/btnSend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_marginTop="24dp"
app:fabCustomSize="90dp"
app:maxImageSize="70dp"
app:backgroundTint="@color/send_strong_orange"
app:srcCompat="@drawable/ic_arrow_forward"
app:layout_constraintEnd_toEndOf="parent"

File diff suppressed because one or more lines are too long