Commit 56ddd643 authored by T Dev. D's avatar T Dev. D 😎
Browse files

Merge branch 'staging' of https://github.com/Samourai-Wallet/sentinel-android into staging

parents 188c0534 37b3fba8
......@@ -54,10 +54,10 @@ android {
minSdkVersion 21
applicationId 'com.samourai.sentinel.staging'
targetSdkVersion 28
versionCode 49
versionName '3.6'
resValue "string", "app_name", "Sentinel"
resValue "string", "version_name", "3.6"
versionCode 50
versionName '3.7'
resValue "string", "app_name", "Sentinel Staging"
resValue "string", "version_name", "3.7"
}
}
compileOptions {
......@@ -87,6 +87,7 @@ dependencies {
}
implementation 'com.yanzhenjie.zbar:camera:1.0.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
implementation 'com.auth0.android:jwtdecode:1.1.1'
implementation 'com.squareup.okhttp3:okhttp:3.13.1'
implementation 'com.squareup.okhttp3:logging-interceptor:3.9.1'
......
......@@ -39,7 +39,7 @@
</intent-filter>
</activity>
<activity android:name=".Network" android:label="Network" />
<activity android:name=".network.dojo.Network" android:theme="@style/AppThemeV2" android:label="Network" />
<receiver android:name=".tor.TorBroadCastReceiver" />
......@@ -76,6 +76,7 @@
<activity android:name="com.samourai.sentinel.BalanceActivity"
android:label="@string/app_name"
android:theme="@style/AppThemeV2"
android:configChanges="keyboardHidden|orientation|screenSize"
>
</activity>
......@@ -88,6 +89,7 @@
<activity android:name="com.samourai.sentinel.XPUBListActivity"
android:label="@string/app_name"
android:theme="@style/AppThemeV2"
android:configChanges="keyboardHidden|orientation|screenSize"
>
</activity>
......@@ -107,7 +109,7 @@
<activity android:name="com.samourai.sentinel.InsertActivity"
android:label="@string/app_name"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="@android:style/Theme.Holo.Dialog"
android:theme="@style/AppThemeV2Alert"
>
</activity>
......
......@@ -2,41 +2,19 @@ package com.samourai.sentinel;
import android.Manifest;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;
//import android.widget.Toast;
import com.dm.zbar.android.scanner.ZBarConstants;
import com.dm.zbar.android.scanner.ZBarScannerActivity;
import com.samourai.sentinel.access.AccessFactory;
import com.samourai.sentinel.network.dojo.Network;
import com.samourai.sentinel.permissions.PermissionsUtil;
import com.samourai.sentinel.util.AppUtil;
import com.samourai.sentinel.util.FormatsUtil;
import net.sourceforge.zbar.Symbol;
import org.bitcoinj.core.AddressFormatException;
import org.bitcoinj.core.Base58;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.nio.ByteBuffer;
public class InitActivity extends Activity {
......@@ -92,7 +70,7 @@ public class InitActivity extends Activity {
AppUtil.getInstance(InitActivity.this).doRestore();
}
if (id == R.id.action_network_init) {
startActivity(new Intent(this,Network.class));
startActivity(new Intent(this, Network.class));
}
else {
;
......
......@@ -5,21 +5,20 @@ import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Toast;
//import android.widget.Toast;
import com.dm.zbar.android.scanner.ZBarConstants;
import com.dm.zbar.android.scanner.ZBarScannerActivity;
import com.samourai.sentinel.access.AccessFactory;
import com.samourai.sentinel.codescanner.CameraFragmentBottomSheet;
import com.samourai.sentinel.util.FormatsUtil;
import net.sourceforge.zbar.Symbol;
import org.bitcoinj.core.AddressFormatException;
import org.bitcoinj.core.Base58;
import org.json.JSONException;
......@@ -27,7 +26,9 @@ import org.json.JSONException;
import java.io.IOException;
import java.nio.ByteBuffer;
public class InsertActivity extends Activity {
//import android.widget.Toast;
public class InsertActivity extends AppCompatActivity {
private final static int SCAN_XPUB = 2011;
private final static int INSERT_SEGWIT = 2012;
......@@ -37,13 +38,20 @@ public class InsertActivity extends Activity {
public final static int TYPE_SEGWIT_XPUB = 2;
private int storedType = 0;
private CameraFragmentBottomSheet cameraFragmentBottomSheet;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_insert);
setTitle(R.string.track_new);
// setTitle();
setSupportActionBar(findViewById(R.id.toolbar));
if(getSupportActionBar()!=null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(R.string.track_new);
}
InsertActivity.this.setFinishOnTouchOutside(false);
......@@ -78,7 +86,13 @@ public class InsertActivity extends Activity {
});
}
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == android.R.id.home) {
finish();
}
return (super.onOptionsItemSelected(menuItem));
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
......@@ -181,9 +195,28 @@ public class InsertActivity extends Activity {
}
private void doScan() {
Intent intent = new Intent(InsertActivity.this, ZBarScannerActivity.class);
intent.putExtra(ZBarConstants.SCAN_MODES, new int[]{Symbol.QRCODE});
startActivityForResult(intent, SCAN_XPUB);
cameraFragmentBottomSheet = new CameraFragmentBottomSheet();
cameraFragmentBottomSheet.show(this.getSupportFragmentManager(), cameraFragmentBottomSheet.getTag());
cameraFragmentBottomSheet.setQrCodeScanLisenter(code -> {
cameraFragmentBottomSheet.dismiss();
// this.connectToDojo(code);
if(code.startsWith("bitcoin:")) {
code = code.substring(8);
}
if(code.contains("?")) {
code = code.substring(0, code.indexOf("?"));
}
addXPUB(code, storedType);
});
//
//
//
// Intent intent = new Intent(InsertActivity.this, ZBarScannerActivity.class);
// intent.putExtra(ZBarConstants.SCAN_MODES, new int[]{Symbol.QRCODE});
// startActivityForResult(intent, SCAN_XPUB);
}
private void addXPUB(final String xpubStr, final int type) {
......
......@@ -8,6 +8,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import com.samourai.sentinel.api.APIFactory;
import com.samourai.sentinel.util.AppUtil;
import com.samourai.sentinel.util.WebUtil;
......@@ -77,6 +78,7 @@ public class InsertSegwitActivity extends Activity {
.add("xpub", params[0])
.add("type", "restore")
.add("segwit", "bip".concat(params[1]))
.add("at", APIFactory.getInstance(getApplicationContext()).getAccessToken())
.build();
......
......@@ -90,8 +90,7 @@ public class MainActivity2 extends Activity {
}
else {
feeThread();
exchangeRateThread();
if(PrefsUtil.getInstance(MainActivity2.this).getValue("popup_" + getResources().getString(R.string.version_name), false) == true) {
......@@ -185,7 +184,8 @@ public class MainActivity2 extends Activity {
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
feeThread();
exchangeRateThread();
}
BackgroundManager.get(MainActivity2.this).addListener(bgListener);
......
......@@ -18,6 +18,7 @@ import android.support.v4.content.FileProvider;
import android.support.v4.content.LocalBroadcastManager;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.Display;
import android.view.Menu;
import android.view.MenuItem;
......@@ -314,102 +315,89 @@ public class ReceiveActivity extends Activity {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
// menu.findItem(R.id.action_sweep).setVisible(false);
menu.findItem(R.id.action_settings).setVisible(false);
menu.findItem(R.id.action_sweep).setVisible(false);
getMenuInflater().inflate(R.menu.receive_menu, menu);
MenuItem itemShare = menu.findItem(R.id.action_share_receive).setVisible(true);
itemShare.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
itemShare.setOnMenuItemClickListener(item -> {
new AlertDialog.Builder(ReceiveActivity.this)
.setTitle(R.string.app_name)
.setMessage(R.string.receive_address_to_share)
.setCancelable(false)
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
new AlertDialog.Builder(ReceiveActivity.this)
.setTitle(R.string.app_name)
.setMessage(R.string.receive_address_to_share)
.setCancelable(false)
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
public void onClick(DialogInterface dialog, int whichButton) {
String strFileName = AppUtil.getInstance(ReceiveActivity.this).getReceiveQRFilename();
File file = new File(strFileName);
if(!file.exists()) {
try {
file.createNewFile();
}
catch(Exception e) {
Toast.makeText(ReceiveActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
String strFileName = AppUtil.getInstance(ReceiveActivity.this).getReceiveQRFilename();
File file = new File(strFileName);
if(!file.exists()) {
try {
file.createNewFile();
}
catch(Exception e) {
Toast.makeText(ReceiveActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
file.setReadable(true, false);
}
file.setReadable(true, false);
FileOutputStream fos = null;
try {
fos = new FileOutputStream(file);
}
catch(FileNotFoundException fnfe) {
;
}
android.content.ClipboardManager clipboard = (android.content.ClipboardManager)ReceiveActivity.this.getSystemService(Context.CLIPBOARD_SERVICE);
android.content.ClipData clip = null;
clip = android.content.ClipData.newPlainText("Receive address", addr);
clipboard.setPrimaryClip(clip);
if(file != null && fos != null) {
Bitmap bitmap = ((BitmapDrawable)ivQR.getDrawable()).getBitmap();
bitmap.compress(Bitmap.CompressFormat.PNG, 0, fos);
FileOutputStream fos = null;
try {
fos = new FileOutputStream(file);
fos.close();
}
catch(FileNotFoundException fnfe) {
catch(IOException ioe) {
;
}
android.content.ClipboardManager clipboard = (android.content.ClipboardManager)ReceiveActivity.this.getSystemService(android.content.Context.CLIPBOARD_SERVICE);
android.content.ClipData clip = null;
clip = android.content.ClipData.newPlainText("Receive address", addr);
clipboard.setPrimaryClip(clip);
if(file != null && fos != null) {
Bitmap bitmap = ((BitmapDrawable)ivQR.getDrawable()).getBitmap();
bitmap.compress(Bitmap.CompressFormat.PNG, 0, fos);
try {
fos.close();
}
catch(IOException ioe) {
;
}
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType("image/png");
if (android.os.Build.VERSION.SDK_INT >= 24) {
//From API 24 sending FIle on intent ,require custom file provider
intent.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(
ReceiveActivity.this,
getApplicationContext()
.getPackageName() + ".provider", file));
} else {
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
}
startActivity(Intent.createChooser(intent, ReceiveActivity.this.getText(R.string.send_payment_code)));
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType("image/png");
if (android.os.Build.VERSION.SDK_INT >= 24) {
//From API 24 sending FIle on intent ,require custom file provider
intent.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(
ReceiveActivity.this,
getApplicationContext()
.getPackageName() + ".provider", file));
} else {
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
}
startActivity(Intent.createChooser(intent, ReceiveActivity.this.getText(R.string.send_payment_code)));
}
}).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
}
public void onClick(DialogInterface dialog, int whichButton) {
}).setNegativeButton(R.string.no, (dialog, whichButton) -> {
;
}
}).show();
}).show();
return false;
}
return false;
});
MenuItem itemRefresh = menu.findItem(R.id.action_refresh).setVisible(false);
itemRefresh.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
itemRefresh.setOnMenuItemClickListener(item -> {
if (canRefresh) {
addr = SamouraiSentinel.getInstance(ReceiveActivity.this).getReceiveAddress();
canRefresh = false;
displayQRCode();
}
return false;
if (canRefresh) {
addr = SamouraiSentinel.getInstance(ReceiveActivity.this).getReceiveAddress();
canRefresh = false;
displayQRCode();
}
return false;
});
_menu = menu;
......@@ -489,40 +477,34 @@ public class ReceiveActivity extends Activity {
final Handler handler = new Handler();
new Thread(new Runnable() {
@Override
public void run() {
try {
final JSONObject jsonObject = APIFactory.getInstance(ReceiveActivity.this).getAddressInfo(addr);
handler.post(new Runnable() {
@Override
public void run() {
try {
if(jsonObject != null && jsonObject.has("addresses") && jsonObject.getJSONArray("addresses").length() > 0) {
JSONArray addrs = jsonObject.getJSONArray("addresses");
JSONObject _addr = addrs.getJSONObject(0);
if(_addr.has("n_tx") && _addr.getLong("n_tx") > 0L) {
Toast.makeText(ReceiveActivity.this, R.string.address_used_previously, Toast.LENGTH_SHORT).show();
canRefresh = true;
_menu.findItem(R.id.action_refresh).setVisible(true);
}
else {
canRefresh = false;
_menu.findItem(R.id.action_refresh).setVisible(false);
}
}
} catch (Exception e) {
new Thread(() -> {
try {
final JSONObject jsonObject = APIFactory.getInstance(ReceiveActivity.this).getAddressInfo(addr);
handler.post(() -> {
try {
if(jsonObject != null && jsonObject.has("addresses") && jsonObject.getJSONArray("addresses").length() > 0) {
JSONArray addrs = jsonObject.getJSONArray("addresses");
JSONObject _addr = addrs.getJSONObject(0);
if(_addr.has("n_tx") && _addr.getLong("n_tx") > 0L) {
Toast.makeText(ReceiveActivity.this, R.string.address_used_previously, Toast.LENGTH_SHORT).show();
canRefresh = true;
_menu.findItem(R.id.action_refresh).setVisible(true);
}
else {
canRefresh = false;
_menu.findItem(R.id.action_refresh).setVisible(false);
}
}
});
} catch (Exception e) {
canRefresh = false;
_menu.findItem(R.id.action_refresh).setVisible(false);
}
} catch (Exception e) {
canRefresh = false;
_menu.findItem(R.id.action_refresh).setVisible(false);
}
});
} catch (Exception e) {
canRefresh = false;
_menu.findItem(R.id.action_refresh).setVisible(false);
}
}).start();
}
......
......@@ -6,6 +6,7 @@ import android.util.Log;
//import android.util.Log;
import com.samourai.sentinel.crypto.AESUtil;
import com.samourai.sentinel.network.dojo.DojoUtil;
import com.samourai.sentinel.segwit.P2SH_P2WPKH;
import com.samourai.sentinel.segwit.SegwitAddress;
import com.samourai.sentinel.util.AddressFactory;
......@@ -214,6 +215,9 @@ public class SamouraiSentinel {
if(obj != null && obj.has("receives")) {
ReceiveLookAtUtil.getInstance().fromJSON(obj.getJSONArray("receives"));
}
if(obj != null && obj.has("dojo")) {
DojoUtil.getInstance(context).fromJSON(new JSONObject(obj.getString("dojo")));
}
}
catch(JSONException ex) {
......@@ -265,6 +269,16 @@ public class SamouraiSentinel {
obj.put("legacy", _addr);
obj.put("receives", ReceiveLookAtUtil.getInstance().toJSON());
obj.put("receives", ReceiveLookAtUtil.getInstance().toJSON());
if(DojoUtil.getInstance(context).getDojoParams() != null){
try {
obj.put("dojo", DojoUtil.getInstance(context).toJSON().toString());
} catch (JSONException e) {
e.printStackTrace();
}
}
return obj;
}
......
package com.samourai.sentinel;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.support.v7.app.AppCompatActivity;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.util.Log;
import android.util.Pair;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
//import android.util.Log;
import com.dm.zbar.android.scanner.ZBarConstants;
import com.dm.zbar.android.scanner.ZBarScannerActivity;
import com.baoyz.swipemenulistview.SwipeMenu;
import com.baoyz.swipemenulistview.SwipeMenuCreator;
import com.baoyz.swipemenulistview.SwipeMenuItem;
import com.baoyz.swipemenulistview.SwipeMenuListView;
import com.samourai.sentinel.api.APIFactory;
import com.samourai.sentinel.util.AppUtil;
import com.samourai.sentinel.util.FormatsUtil;
import com.samourai.sentinel.util.MonetaryUtil;
import com.samourai.sentinel.util.PrefsUtil;
import net.i2p.android.ext.floatingactionbutton.FloatingActionButton;
import net.sourceforge.zbar.Symbol;
import org.bitcoinj.core.AddressFormatException;
import org.bitcoinj.core.Base58;
import org.bitcoinj.core.Coin;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import com.samourai.sentinel.access.AccessFactory;
import com.baoyz.swipemenulistview.SwipeMenuCreator;