Feature/timber logging (#143)

* Added Timber for logging

* Replaced Log calls with timber

* added timber to licenses list

* PR suggestions
This commit is contained in:
Stephan Hagios 2017-11-25 15:49:07 +01:00 committed by m2049r
parent 92d867fbaa
commit d2429da044
22 changed files with 245 additions and 235 deletions

View File

@ -45,6 +45,7 @@ dependencies {
compile 'me.dm7.barcodescanner:zxing:1.9.8' compile 'me.dm7.barcodescanner:zxing:1.9.8'
compile "com.squareup.okhttp3:okhttp:$rootProject.ext.okHttpVersion" compile "com.squareup.okhttp3:okhttp:$rootProject.ext.okHttpVersion"
compile "com.jakewharton.timber:timber:$rootProject.ext.timberVersion"
testCompile "junit:junit:$rootProject.ext.junitVersion" testCompile "junit:junit:$rootProject.ext.junitVersion"
testCompile "org.mockito:mockito-all:$rootProject.ext.mockitoVersion" testCompile "org.mockito:mockito-all:$rootProject.ext.mockitoVersion"

View File

@ -13,6 +13,7 @@
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:supportsRtl="true" android:supportsRtl="true"
android:name=".XmrWalletApplication"
android:theme="@style/MyMaterialTheme"> android:theme="@style/MyMaterialTheme">
<activity <activity

View File

@ -22,7 +22,6 @@ import android.support.annotation.Nullable;
import android.support.design.widget.TextInputLayout; import android.support.design.widget.TextInputLayout;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.text.InputType; import android.text.InputType;
import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
@ -40,8 +39,9 @@ import com.m2049r.xmrwallet.util.Helper;
import java.io.File; import java.io.File;
import timber.log.Timber;
public class GenerateFragment extends Fragment { public class GenerateFragment extends Fragment {
static final String TAG = "GenerateFragment";
static final String TYPE = "type"; static final String TYPE = "type";
static final String TYPE_NEW = "new"; static final String TYPE_NEW = "new";
@ -366,7 +366,7 @@ public class GenerateFragment extends Fragment {
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
Log.d(TAG, "onResume()"); Timber.d("onResume()");
activityCallback.setTitle(getString(R.string.generate_title) + " - " + getType()); activityCallback.setTitle(getString(R.string.generate_title) + " - " + getType());
activityCallback.setToolbarButton(Toolbar.BUTTON_BACK); activityCallback.setToolbarButton(Toolbar.BUTTON_BACK);
@ -383,7 +383,7 @@ public class GenerateFragment extends Fragment {
case TYPE_VIEWONLY: case TYPE_VIEWONLY:
return getString(R.string.generate_wallet_type_view); return getString(R.string.generate_wallet_type_view);
default: default:
Log.e(TAG, "unknown type " + type); Timber.e("unknown type %s", type);
return "?"; return "?";
} }
} }

View File

@ -21,7 +21,6 @@ import android.os.AsyncTask;
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.Fragment;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -41,8 +40,9 @@ import com.m2049r.xmrwallet.model.WalletManager;
import com.m2049r.xmrwallet.util.Helper; import com.m2049r.xmrwallet.util.Helper;
import com.m2049r.xmrwallet.util.MoneroThreadPoolExecutor; import com.m2049r.xmrwallet.util.MoneroThreadPoolExecutor;
import timber.log.Timber;
public class GenerateReviewFragment extends Fragment { public class GenerateReviewFragment extends Fragment {
static final String TAG = "GenerateReviewFragment";
static final public String VIEW_TYPE_DETAILS = "details"; static final public String VIEW_TYPE_DETAILS = "details";
static final public String VIEW_TYPE_ACCEPT = "accept"; static final public String VIEW_TYPE_ACCEPT = "accept";
static final public String VIEW_TYPE_WALLET = "wallet"; static final public String VIEW_TYPE_WALLET = "wallet";
@ -264,7 +264,7 @@ public class GenerateReviewFragment extends Fragment {
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
Log.d(TAG, "onResume()"); Timber.d("onResume()");
String name = tvWalletName.getText().toString(); String name = tvWalletName.getText().toString();
if (name.isEmpty()) name = null; if (name.isEmpty()) name = null;
activityCallback.setTitle(name, getString(R.string.details_title)); activityCallback.setTitle(name, getString(R.string.details_title));

View File

@ -35,7 +35,6 @@ import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuItem; import android.view.MenuItem;
@ -67,10 +66,11 @@ import java.net.SocketAddress;
import java.nio.channels.FileChannel; import java.nio.channels.FileChannel;
import java.util.Date; import java.util.Date;
import timber.log.Timber;
public class LoginActivity extends SecureActivity public class LoginActivity extends SecureActivity
implements LoginFragment.Listener, GenerateFragment.Listener, implements LoginFragment.Listener, GenerateFragment.Listener,
GenerateReviewFragment.Listener, GenerateReviewFragment.AcceptListener, ReceiveFragment.Listener { GenerateReviewFragment.Listener, GenerateReviewFragment.AcceptListener, ReceiveFragment.Listener {
static final String TAG = "LoginActivity";
private static final String GENERATE_STACK = "gen"; private static final String GENERATE_STACK = "gen";
static final int DAEMON_TIMEOUT = 500; // deamon must respond in 500ms static final int DAEMON_TIMEOUT = 500; // deamon must respond in 500ms
@ -99,7 +99,7 @@ public class LoginActivity extends SecureActivity
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "onCreate()"); Timber.d("onCreate()");
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (savedInstanceState != null) { if (savedInstanceState != null) {
// we don't store anything ourselves // we don't store anything ourselves
@ -125,7 +125,7 @@ public class LoginActivity extends SecureActivity
break; break;
case Toolbar.BUTTON_NONE: case Toolbar.BUTTON_NONE:
default: default:
Log.e(TAG, "Button " + type + "pressed - how can this be?"); Timber.e("Button " + type + "pressed - how can this be?");
} }
} }
}); });
@ -133,7 +133,7 @@ public class LoginActivity extends SecureActivity
if (Helper.getWritePermission(this)) { if (Helper.getWritePermission(this)) {
if (savedInstanceState == null) startLoginFragment(); if (savedInstanceState == null) startLoginFragment();
} else { } else {
Log.i(TAG, "Waiting for permissions"); Timber.i("Waiting for permissions");
} }
} }
@ -157,7 +157,7 @@ public class LoginActivity extends SecureActivity
WalletNode aWalletNode = new WalletNode(walletName, daemon, testnet); WalletNode aWalletNode = new WalletNode(walletName, daemon, testnet);
new AsyncOpenWallet().execute(aWalletNode); new AsyncOpenWallet().execute(aWalletNode);
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
Log.e(TAG, ex.getLocalizedMessage()); Timber.e(ex.getLocalizedMessage());
Toast.makeText(this, ex.getLocalizedMessage(), Toast.LENGTH_SHORT).show(); Toast.makeText(this, ex.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
return false; return false;
} }
@ -167,7 +167,7 @@ public class LoginActivity extends SecureActivity
@Override @Override
public void onWalletDetails(final String walletName, boolean testnet) { public void onWalletDetails(final String walletName, boolean testnet) {
setNet(testnet); setNet(testnet);
Log.d(TAG, "details for wallet ." + walletName + "."); Timber.d("details for wallet ." + walletName + ".");
if (checkServiceRunning()) return; if (checkServiceRunning()) return;
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
@Override @Override
@ -183,7 +183,7 @@ public class LoginActivity extends SecureActivity
} }
}); });
} else { // this cannot really happen as we prefilter choices } else { // this cannot really happen as we prefilter choices
Log.e(TAG, "Wallet missing: " + walletName); Timber.e("Wallet missing: %s", walletName);
Toast.makeText(LoginActivity.this, getString(R.string.bad_wallet), Toast.LENGTH_SHORT).show(); Toast.makeText(LoginActivity.this, getString(R.string.bad_wallet), Toast.LENGTH_SHORT).show();
} }
break; break;
@ -205,7 +205,7 @@ public class LoginActivity extends SecureActivity
@Override @Override
public void onWalletReceive(String walletName, boolean testnet) { public void onWalletReceive(String walletName, boolean testnet) {
setNet(testnet); setNet(testnet);
Log.d(TAG, "receive for wallet ." + walletName + "."); Timber.d("receive for wallet ." + walletName + ".");
if (checkServiceRunning()) return; if (checkServiceRunning()) return;
final File walletFile = Helper.getWalletFile(this, walletName); final File walletFile = Helper.getWalletFile(this, walletName);
if (WalletManager.getInstance().walletExists(walletFile)) { if (WalletManager.getInstance().walletExists(walletFile)) {
@ -262,7 +262,7 @@ public class LoginActivity extends SecureActivity
@Override @Override
public void onWalletRename(final String walletName) { public void onWalletRename(final String walletName) {
Log.d(TAG, "rename for wallet ." + walletName + "."); Timber.d("rename for wallet ." + walletName + ".");
if (checkServiceRunning()) return; if (checkServiceRunning()) return;
LayoutInflater li = LayoutInflater.from(this); LayoutInflater li = LayoutInflater.from(this);
View promptsView = li.inflate(R.layout.prompt_rename, null); View promptsView = li.inflate(R.layout.prompt_rename, null);
@ -345,7 +345,7 @@ public class LoginActivity extends SecureActivity
File backupFolder = new File(getStorageRoot(), "backups"); File backupFolder = new File(getStorageRoot(), "backups");
if (!backupFolder.exists()) { if (!backupFolder.exists()) {
if (!backupFolder.mkdir()) { if (!backupFolder.mkdir()) {
Log.e(TAG, "Cannot create backup dir " + backupFolder.getAbsolutePath()); Timber.e("Cannot create backup dir %s", backupFolder.getAbsolutePath());
return false; return false;
} }
// make folder visible over USB/MTP // make folder visible over USB/MTP
@ -353,18 +353,18 @@ public class LoginActivity extends SecureActivity
} }
File walletFile = Helper.getWalletFile(LoginActivity.this, walletName); File walletFile = Helper.getWalletFile(LoginActivity.this, walletName);
File backupFile = new File(backupFolder, walletName); File backupFile = new File(backupFolder, walletName);
Log.d(TAG, "backup " + walletFile.getAbsolutePath() + " to " + backupFile.getAbsolutePath()); Timber.d("backup " + walletFile.getAbsolutePath() + " to " + backupFile.getAbsolutePath());
// TODO probably better to copy to a new file and then rename // TODO probably better to copy to a new file and then rename
// then if something fails we have the old backup at least // then if something fails we have the old backup at least
// or just create a new backup every time and keep n old backups // or just create a new backup every time and keep n old backups
boolean success = copyWallet(walletFile, backupFile, true, true); boolean success = copyWallet(walletFile, backupFile, true, true);
Log.d(TAG, "copyWallet is " + success); Timber.d("copyWallet is %s", success);
return success; return success;
} }
@Override @Override
public void onWalletBackup(String walletName) { public void onWalletBackup(String walletName) {
Log.d(TAG, "backup for wallet ." + walletName + "."); Timber.d("backup for wallet ." + walletName + ".");
new AsyncBackup().execute(walletName); new AsyncBackup().execute(walletName);
} }
@ -403,7 +403,7 @@ public class LoginActivity extends SecureActivity
@Override @Override
public void onWalletArchive(final String walletName) { public void onWalletArchive(final String walletName) {
Log.d(TAG, "archive for wallet ." + walletName + "."); Timber.d("archive for wallet ." + walletName + ".");
if (checkServiceRunning()) return; if (checkServiceRunning()) return;
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
@Override @Override
@ -428,7 +428,7 @@ public class LoginActivity extends SecureActivity
} }
void reloadWalletList() { void reloadWalletList() {
Log.d(TAG, "reloadWalletList()"); Timber.d("reloadWalletList()");
try { try {
LoginFragment loginFragment = (LoginFragment) LoginFragment loginFragment = (LoginFragment)
getSupportFragmentManager().findFragmentById(R.id.fragment_container); getSupportFragmentManager().findFragmentById(R.id.fragment_container);
@ -585,7 +585,7 @@ public class LoginActivity extends SecureActivity
@Override @Override
protected void onPause() { protected void onPause() {
Log.d(TAG, "onPause()"); Timber.d("onPause()");
super.onPause(); super.onPause();
} }
@ -626,7 +626,7 @@ public class LoginActivity extends SecureActivity
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
Log.d(TAG, "onResume()"); Timber.d("onResume()");
// wait for WalletService to finish // wait for WalletService to finish
if (WalletService.Running && (progressDialog == null)) { if (WalletService.Running && (progressDialog == null)) {
// and show a progress dialog, but only if there isn't one already // and show a progress dialog, but only if there isn't one already
@ -681,7 +681,7 @@ public class LoginActivity extends SecureActivity
} }
void startWallet(String walletName, String walletPassword) { void startWallet(String walletName, String walletPassword) {
Log.d(TAG, "startWallet()"); Timber.d("startWallet()");
Intent intent = new Intent(getApplicationContext(), WalletActivity.class); Intent intent = new Intent(getApplicationContext(), WalletActivity.class);
intent.putExtra(WalletActivity.REQUEST_ID, walletName); intent.putExtra(WalletActivity.REQUEST_ID, walletName);
intent.putExtra(WalletActivity.REQUEST_PW, walletPassword); intent.putExtra(WalletActivity.REQUEST_PW, walletPassword);
@ -689,7 +689,7 @@ public class LoginActivity extends SecureActivity
} }
void startDetails(File walletFile, String password, String type) { void startDetails(File walletFile, String password, String type) {
Log.d(TAG, "startDetails()"); Timber.d("startDetails()");
Bundle b = new Bundle(); Bundle b = new Bundle();
b.putString("path", walletFile.getAbsolutePath()); b.putString("path", walletFile.getAbsolutePath());
b.putString("password", password); b.putString("password", password);
@ -698,7 +698,7 @@ public class LoginActivity extends SecureActivity
} }
void startReceive(File walletFile, String password) { void startReceive(File walletFile, String password) {
Log.d(TAG, "startReceive()"); Timber.d("startReceive()");
Bundle b = new Bundle(); Bundle b = new Bundle();
b.putString("path", walletFile.getAbsolutePath()); b.putString("path", walletFile.getAbsolutePath());
b.putString("password", password); b.putString("password", password);
@ -707,7 +707,7 @@ public class LoginActivity extends SecureActivity
@Override @Override
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) { public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
Log.d(TAG, "onRequestPermissionsResult()"); Timber.d("onRequestPermissionsResult()");
switch (requestCode) { switch (requestCode) {
case Helper.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE: case Helper.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE:
// If request is cancelled, the result arrays are empty. // If request is cancelled, the result arrays are empty.
@ -716,7 +716,7 @@ public class LoginActivity extends SecureActivity
startLoginFragment = true; startLoginFragment = true;
} else { } else {
String msg = getString(R.string.message_strorage_not_permitted); String msg = getString(R.string.message_strorage_not_permitted);
Log.e(TAG, msg); Timber.e(msg);
Toast.makeText(this, msg, Toast.LENGTH_LONG).show(); Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
//throw new IllegalStateException(msg); //throw new IllegalStateException(msg);
} }
@ -740,24 +740,24 @@ public class LoginActivity extends SecureActivity
Fragment fragment = new LoginFragment(); Fragment fragment = new LoginFragment();
getSupportFragmentManager().beginTransaction() getSupportFragmentManager().beginTransaction()
.add(R.id.fragment_container, fragment).commit(); .add(R.id.fragment_container, fragment).commit();
Log.d(TAG, "LoginFragment added"); Timber.d("LoginFragment added");
} }
void startGenerateFragment(String type) { void startGenerateFragment(String type) {
Bundle extras = new Bundle(); Bundle extras = new Bundle();
extras.putString(GenerateFragment.TYPE, type); extras.putString(GenerateFragment.TYPE, type);
replaceFragment(new GenerateFragment(), GENERATE_STACK, extras); replaceFragment(new GenerateFragment(), GENERATE_STACK, extras);
Log.d(TAG, "GenerateFragment placed"); Timber.d("GenerateFragment placed");
} }
void startReviewFragment(Bundle extras) { void startReviewFragment(Bundle extras) {
replaceFragment(new GenerateReviewFragment(), null, extras); replaceFragment(new GenerateReviewFragment(), null, extras);
Log.d(TAG, "GenerateReviewFragment placed"); Timber.d("GenerateReviewFragment placed");
} }
void startReceiveFragment(Bundle extras) { void startReceiveFragment(Bundle extras) {
replaceFragment(new ReceiveFragment(), null, extras); replaceFragment(new ReceiveFragment(), null, extras);
Log.d(TAG, "ReceiveFragment placed"); Timber.d("ReceiveFragment placed");
} }
void replaceFragment(Fragment newFragment, String stackName, Bundle extras) { void replaceFragment(Fragment newFragment, String stackName, Bundle extras) {
@ -803,7 +803,7 @@ public class LoginActivity extends SecureActivity
protected Boolean doInBackground(Void... params) { protected Boolean doInBackground(Void... params) {
File newWalletFolder = getStorageRoot(); File newWalletFolder = getStorageRoot();
if (!newWalletFolder.isDirectory()) { if (!newWalletFolder.isDirectory()) {
Log.e(TAG, "Wallet dir " + newWalletFolder.getAbsolutePath() + "is not a directory"); Timber.e("Wallet dir " + newWalletFolder.getAbsolutePath() + "is not a directory");
return false; return false;
} }
File cacheFile = new File(newWalletFolder, walletName); File cacheFile = new File(newWalletFolder, walletName);
@ -811,7 +811,7 @@ public class LoginActivity extends SecureActivity
File addressFile = new File(newWalletFolder, walletName + ".address.txt"); File addressFile = new File(newWalletFolder, walletName + ".address.txt");
if (cacheFile.exists() || keysFile.exists() || addressFile.exists()) { if (cacheFile.exists() || keysFile.exists() || addressFile.exists()) {
Log.e(TAG, "Some wallet files already exist for " + cacheFile.getAbsolutePath()); Timber.e("Some wallet files already exist for %s", cacheFile.getAbsolutePath());
return false; return false;
} }
@ -820,7 +820,7 @@ public class LoginActivity extends SecureActivity
if (success) { if (success) {
return true; return true;
} else { } else {
Log.e(TAG, "Could not create new wallet in " + newWalletFile.getAbsolutePath()); Timber.e("Could not create new wallet in %s", newWalletFile.getAbsolutePath());
return false; return false;
} }
} }
@ -851,7 +851,7 @@ public class LoginActivity extends SecureActivity
getSupportFragmentManager().findFragmentById(R.id.fragment_container); getSupportFragmentManager().findFragmentById(R.id.fragment_container);
genFragment.walletGenerateError(); genFragment.walletGenerateError();
} catch (ClassCastException ex) { } catch (ClassCastException ex) {
Log.e(TAG, "walletGenerateError() but not in GenerateFragment"); Timber.e("walletGenerateError() but not in GenerateFragment");
} }
} }
@ -869,7 +869,7 @@ public class LoginActivity extends SecureActivity
.createWallet(aFile, password, MNEMONIC_LANGUAGE); .createWallet(aFile, password, MNEMONIC_LANGUAGE);
boolean success = (newWallet.getStatus() == Wallet.Status.Status_Ok); boolean success = (newWallet.getStatus() == Wallet.Status.Status_Ok);
if (!success) { if (!success) {
Log.e(TAG, newWallet.getErrorString()); Timber.e(newWallet.getErrorString());
toast(newWallet.getErrorString()); toast(newWallet.getErrorString());
} }
newWallet.close(); newWallet.close();
@ -889,7 +889,7 @@ public class LoginActivity extends SecureActivity
newWallet.setPassword(password); newWallet.setPassword(password);
success = success && newWallet.store(); success = success && newWallet.store();
} else { } else {
Log.e(TAG, newWallet.getErrorString()); Timber.e(newWallet.getErrorString());
toast(newWallet.getErrorString()); toast(newWallet.getErrorString());
} }
newWallet.close(); newWallet.close();
@ -912,7 +912,7 @@ public class LoginActivity extends SecureActivity
newWallet.setPassword(password); newWallet.setPassword(password);
success = success && newWallet.store(); success = success && newWallet.store();
} else { } else {
Log.e(TAG, newWallet.getErrorString()); Timber.e(newWallet.getErrorString());
toast(newWallet.getErrorString()); toast(newWallet.getErrorString());
} }
newWallet.close(); newWallet.close();
@ -943,17 +943,17 @@ public class LoginActivity extends SecureActivity
Toast.makeText(LoginActivity.this, Toast.makeText(LoginActivity.this,
getString(R.string.generate_wallet_created), Toast.LENGTH_SHORT).show(); getString(R.string.generate_wallet_created), Toast.LENGTH_SHORT).show();
} else { } else {
Log.e(TAG, "Wallet store failed to " + walletFile.getAbsolutePath()); Timber.e("Wallet store failed to %s", walletFile.getAbsolutePath());
Toast.makeText(LoginActivity.this, getString(R.string.generate_wallet_create_failed), Toast.LENGTH_LONG).show(); Toast.makeText(LoginActivity.this, getString(R.string.generate_wallet_create_failed), Toast.LENGTH_LONG).show();
} }
} }
Wallet.Status testWallet(String path, String password) { Wallet.Status testWallet(String path, String password) {
Log.d(TAG, "testing wallet " + path); Timber.d("testing wallet %s", path);
Wallet aWallet = WalletManager.getInstance().openWallet(path, password); Wallet aWallet = WalletManager.getInstance().openWallet(path, password);
if (aWallet == null) return Wallet.Status.Status_Error; // does this ever happen? if (aWallet == null) return Wallet.Status.Status_Error; // does this ever happen?
Wallet.Status status = aWallet.getStatus(); Wallet.Status status = aWallet.getStatus();
Log.d(TAG, "wallet tested " + aWallet.getStatus()); Timber.d("wallet tested %s", aWallet.getStatus());
aWallet.close(); aWallet.close();
return status; return status;
} }
@ -983,7 +983,7 @@ public class LoginActivity extends SecureActivity
try { try {
copyFile(new File(srcDir, srcName), new File(dstDir, dstName)); copyFile(new File(srcDir, srcName), new File(dstDir, dstName));
} catch (IOException ex) { } catch (IOException ex) {
Log.d(TAG, "CACHE " + ignoreCacheError); Timber.d("CACHE %s", ignoreCacheError);
if (!ignoreCacheError) { // ignore cache backup error if backing up (can be resynced) if (!ignoreCacheError) { // ignore cache backup error if backing up (can be resynced)
throw ex; throw ex;
} }
@ -992,7 +992,7 @@ public class LoginActivity extends SecureActivity
copyFile(new File(srcDir, srcName + ".address.txt"), new File(dstDir, dstName + ".address.txt")); copyFile(new File(srcDir, srcName + ".address.txt"), new File(dstDir, dstName + ".address.txt"));
success = true; success = true;
} catch (IOException ex) { } catch (IOException ex) {
Log.e(TAG, "wallet copy failed: " + ex.getMessage()); Timber.e("wallet copy failed: %s", ex.getMessage());
// try to rollback // try to rollback
deleteWallet(dstWallet); deleteWallet(dstWallet);
} }
@ -1001,7 +1001,7 @@ public class LoginActivity extends SecureActivity
// do our best to delete as much as possible of the wallet files // do our best to delete as much as possible of the wallet files
boolean deleteWallet(File walletFile) { boolean deleteWallet(File walletFile) {
Log.d(TAG, "deleteWallet " + walletFile.getAbsolutePath()); Timber.d("deleteWallet %s", walletFile.getAbsolutePath());
File dir = walletFile.getParentFile(); File dir = walletFile.getParentFile();
String name = walletFile.getName(); String name = walletFile.getName();
boolean success = true; boolean success = true;
@ -1014,7 +1014,7 @@ public class LoginActivity extends SecureActivity
if (addressFile.exists()) { if (addressFile.exists()) {
success = addressFile.delete() && success; success = addressFile.delete() && success;
} }
Log.d(TAG, "deleteWallet is " + success); Timber.d("deleteWallet is %s", success);
return success; return success;
} }
@ -1164,26 +1164,26 @@ public class LoginActivity extends SecureActivity
this.walletNode = params[0]; this.walletNode = params[0];
if (!walletNode.isValid()) return INVALID; if (!walletNode.isValid()) return INVALID;
Log.d(TAG, "checking " + walletNode.getAddress()); Timber.d("checking %s", walletNode.getAddress());
try { try {
long timeDA = new Date().getTime(); long timeDA = new Date().getTime();
SocketAddress address = new InetSocketAddress(walletNode.host, walletNode.port); SocketAddress address = new InetSocketAddress(walletNode.host, walletNode.port);
long timeDB = new Date().getTime(); long timeDB = new Date().getTime();
Log.d(TAG, "Resolving " + walletNode.host + " took " + (timeDB - timeDA) + "ms."); Timber.d("Resolving " + walletNode.host + " took " + (timeDB - timeDA) + "ms.");
Socket socket = new Socket(); Socket socket = new Socket();
long timeA = new Date().getTime(); long timeA = new Date().getTime();
socket.connect(address, LoginActivity.DAEMON_TIMEOUT); socket.connect(address, LoginActivity.DAEMON_TIMEOUT);
socket.close(); socket.close();
long timeB = new Date().getTime(); long timeB = new Date().getTime();
long time = timeB - timeA; long time = timeB - timeA;
Log.d(TAG, "Daemon " + walletNode.host + " is " + time + "ms away."); Timber.d("Daemon " + walletNode.host + " is " + time + "ms away.");
return (time < LoginActivity.DAEMON_TIMEOUT ? OK : TIMEOUT); return (time < LoginActivity.DAEMON_TIMEOUT ? OK : TIMEOUT);
} catch (IOException ex) { } catch (IOException ex) {
Log.d(TAG, "Cannot reach daemon " + walletNode.host + "/" + walletNode.port + " because " + ex.getMessage()); Timber.d("Cannot reach daemon " + walletNode.host + "/" + walletNode.port + " because " + ex.getMessage());
return IOEX; return IOEX;
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
Log.d(TAG, "Cannot reach daemon " + walletNode.host + "/" + walletNode.port + " because " + ex.getMessage()); Timber.d("Cannot reach daemon " + walletNode.host + "/" + walletNode.port + " because " + ex.getMessage());
return INVALID; return INVALID;
} }
} }
@ -1197,7 +1197,7 @@ public class LoginActivity extends SecureActivity
dismissProgressDialog(); dismissProgressDialog();
switch (result) { switch (result) {
case OK: case OK:
Log.d(TAG, "selected wallet is ." + walletNode.name + "."); Timber.d("selected wallet is ." + walletNode.name + ".");
// now it's getting real, check if wallet exists // now it's getting real, check if wallet exists
promptAndStart(walletNode); promptAndStart(walletNode);
break; break;

View File

@ -24,7 +24,6 @@ import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
@ -55,9 +54,10 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import timber.log.Timber;
public class LoginFragment extends Fragment implements WalletInfoAdapter.OnInteractionListener, public class LoginFragment extends Fragment implements WalletInfoAdapter.OnInteractionListener,
View.OnClickListener { View.OnClickListener {
private static final String TAG = "LoginFragment";
private WalletInfoAdapter adapter; private WalletInfoAdapter adapter;
@ -112,7 +112,7 @@ public class LoginFragment extends Fragment implements WalletInfoAdapter.OnInter
@Override @Override
public void onPause() { public void onPause() {
Log.d(TAG, "onPause()"); Timber.d("onPause()");
savePrefs(); savePrefs();
super.onPause(); super.onPause();
} }
@ -120,7 +120,7 @@ public class LoginFragment extends Fragment implements WalletInfoAdapter.OnInter
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
Log.d(TAG, "onResume()"); Timber.d("onResume()");
activityCallback.setTitle(null); activityCallback.setTitle(null);
activityCallback.setToolbarButton(Toolbar.BUTTON_DONATE); activityCallback.setToolbarButton(Toolbar.BUTTON_DONATE);
activityCallback.showNet(isTestnet()); activityCallback.showNet(isTestnet());
@ -129,7 +129,7 @@ public class LoginFragment extends Fragment implements WalletInfoAdapter.OnInter
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
Log.d(TAG, "onCreateView"); Timber.d("onCreateView");
View view = inflater.inflate(R.layout.fragment_login, container, false); View view = inflater.inflate(R.layout.fragment_login, container, false);
ivGunther = (ImageView) view.findViewById(R.id.ivGunther); ivGunther = (ImageView) view.findViewById(R.id.ivGunther);
@ -262,7 +262,7 @@ public class LoginFragment extends Fragment implements WalletInfoAdapter.OnInter
} }
public void loadList() { public void loadList() {
Log.d(TAG, "loadList()"); Timber.d("loadList()");
WalletManager mgr = WalletManager.getInstance(); WalletManager mgr = WalletManager.getInstance();
List<WalletManager.WalletInfo> walletInfos = List<WalletManager.WalletInfo> walletInfos =
mgr.findWallets(activityCallback.getStorageRoot()); mgr.findWallets(activityCallback.getStorageRoot());
@ -360,7 +360,7 @@ public class LoginFragment extends Fragment implements WalletInfoAdapter.OnInter
} }
void savePrefs(boolean usePreviousState) { void savePrefs(boolean usePreviousState) {
Log.d(TAG, "SAVE / " + usePreviousState); Timber.d("SAVE / %s", usePreviousState);
// save the daemon address for the net // save the daemon address for the net
boolean testnet = isTestnet() ^ usePreviousState; boolean testnet = isTestnet() ^ usePreviousState;
String daemon = getDaemon(); String daemon = getDaemon();
@ -383,7 +383,7 @@ public class LoginFragment extends Fragment implements WalletInfoAdapter.OnInter
} }
void setDaemon(NodeList nodeList) { void setDaemon(NodeList nodeList) {
Log.d(TAG, "setDaemon() " + nodeList.toString()); Timber.d("setDaemon() %s", nodeList.toString());
String[] nodes = nodeList.getNodes().toArray(new String[0]); String[] nodes = nodeList.getNodes().toArray(new String[0]);
nodeAdapter.clear(); nodeAdapter.clear();
nodeAdapter.addAll(nodes); nodeAdapter.addAll(nodes);

View File

@ -27,7 +27,6 @@ import android.support.v4.app.Fragment;
import android.text.Editable; import android.text.Editable;
import android.text.InputType; import android.text.InputType;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -57,8 +56,9 @@ import com.m2049r.xmrwallet.util.MoneroThreadPoolExecutor;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import timber.log.Timber;
public class ReceiveFragment extends Fragment { public class ReceiveFragment extends Fragment {
static final String TAG = "ReceiveFragment";
private ProgressBar pbProgress; private ProgressBar pbProgress;
private TextView tvAddress; private TextView tvAddress;
@ -111,7 +111,7 @@ public class ReceiveFragment extends Fragment {
evAmount.setOnNewAmountListener(new ExchangeView.OnNewAmountListener() { evAmount.setOnNewAmountListener(new ExchangeView.OnNewAmountListener() {
@Override @Override
public void onNewAmount(String xmr) { public void onNewAmount(String xmr) {
Log.d(TAG, "new amount = " + xmr); Timber.d("new amount = %s", xmr);
generateQr(); generateQr();
} }
}); });
@ -189,7 +189,7 @@ public class ReceiveFragment extends Fragment {
Bundle b = getArguments(); Bundle b = getArguments();
String address = b.getString("address"); String address = b.getString("address");
String walletName = b.getString("name"); String walletName = b.getString("name");
Log.d(TAG, "address=" + address + "/name=" + walletName); Timber.d("%s/%s",address, walletName);
if (address == null) { if (address == null) {
String path = b.getString("path"); String path = b.getString("path");
String password = b.getString("password"); String password = b.getString("password");
@ -227,7 +227,7 @@ public class ReceiveFragment extends Fragment {
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
Log.d(TAG, "onResume()"); Timber.d("onResume()");
listenerCallback.setToolbarButton(Toolbar.BUTTON_BACK); listenerCallback.setToolbarButton(Toolbar.BUTTON_BACK);
listenerCallback.setSubtitle(getString(R.string.receive_title)); listenerCallback.setSubtitle(getString(R.string.receive_title));
generateQr(); generateQr();
@ -236,7 +236,7 @@ public class ReceiveFragment extends Fragment {
private boolean isLoaded = false; private boolean isLoaded = false;
private void show(String name, String address) { private void show(String name, String address) {
Log.d(TAG, "name=" + name); Timber.d("name=%s", name);
isLoaded = true; isLoaded = true;
listenerCallback.setTitle(name); listenerCallback.setTitle(name);
tvAddress.setText(address); tvAddress.setText(address);
@ -296,14 +296,14 @@ public class ReceiveFragment extends Fragment {
} }
private void generateQr() { private void generateQr() {
Log.d(TAG, "GENQR"); Timber.d("GENQR");
String address = tvAddress.getText().toString(); String address = tvAddress.getText().toString();
String paymentId = etPaymentId.getEditText().getText().toString(); String paymentId = etPaymentId.getEditText().getText().toString();
String xmrAmount = evAmount.getAmount(); String xmrAmount = evAmount.getAmount();
Log.d(TAG, xmrAmount + "/" + paymentId + "/" + address); Timber.d("%s/%s/%s",xmrAmount, paymentId, address);
if ((xmrAmount == null) || !Wallet.isAddressValid(address, WalletManager.getInstance().isTestNet())) { if ((xmrAmount == null) || !Wallet.isAddressValid(address, WalletManager.getInstance().isTestNet())) {
clearQR(); clearQR();
Log.d(TAG, "CLEARQR"); Timber.d("CLEARQR");
return; return;
} }
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
@ -329,7 +329,7 @@ public class ReceiveFragment extends Fragment {
Bitmap qr = generate(text, size, size); Bitmap qr = generate(text, size, size);
if (qr != null) { if (qr != null) {
setQR(qr); setQR(qr);
Log.d(TAG, "SETQR"); Timber.d("SETQR");
etDummy.requestFocus(); etDummy.requestFocus();
Helper.hideKeyboard(getActivity()); Helper.hideKeyboard(getActivity());
} }
@ -419,7 +419,7 @@ public class ReceiveFragment extends Fragment {
@Override @Override
public void onPause() { public void onPause() {
Log.d(TAG, "onPause()"); Timber.d("onPause()");
super.onPause(); super.onPause();
} }
} }

View File

@ -20,7 +20,6 @@ import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -30,9 +29,9 @@ import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result; import com.google.zxing.Result;
import me.dm7.barcodescanner.zxing.ZXingScannerView; import me.dm7.barcodescanner.zxing.ZXingScannerView;
import timber.log.Timber;
public class ScannerFragment extends Fragment implements ZXingScannerView.ResultHandler { public class ScannerFragment extends Fragment implements ZXingScannerView.ResultHandler {
static final String TAG = "ScannerFragment";
private Listener activityCallback; private Listener activityCallback;
@ -44,7 +43,7 @@ public class ScannerFragment extends Fragment implements ZXingScannerView.Result
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Log.d(TAG, "onCreateView"); Timber.d("onCreateView");
mScannerView = new ZXingScannerView(getActivity()); mScannerView = new ZXingScannerView(getActivity());
return mScannerView; return mScannerView;
} }
@ -52,7 +51,7 @@ public class ScannerFragment extends Fragment implements ZXingScannerView.Result
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
Log.d(TAG, "onResume"); Timber.d("onResume");
mScannerView.setResultHandler(this); mScannerView.setResultHandler(this);
mScannerView.startCamera(); mScannerView.startCamera();
} }
@ -91,7 +90,7 @@ public class ScannerFragment extends Fragment implements ZXingScannerView.Result
@Override @Override
public void onPause() { public void onPause() {
Log.d(TAG, "onPause"); Timber.d("onPause");
mScannerView.stopCamera(); mScannerView.stopCamera();
super.onPause(); super.onPause();
} }

View File

@ -27,7 +27,6 @@ import android.support.v7.app.AlertDialog;
import android.text.Editable; import android.text.Editable;
import android.text.InputType; import android.text.InputType;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
@ -53,8 +52,9 @@ import com.m2049r.xmrwallet.util.BarcodeData;
import com.m2049r.xmrwallet.util.Helper; import com.m2049r.xmrwallet.util.Helper;
import com.m2049r.xmrwallet.util.TxData; import com.m2049r.xmrwallet.util.TxData;
import timber.log.Timber;
public class SendFragment extends Fragment { public class SendFragment extends Fragment {
static final String TAG = "SendFragment";
private EditText etDummy; private EditText etDummy;
@ -352,7 +352,7 @@ public class SendFragment extends Fragment {
int mixin = Mixins[sMixin.getSelectedItemPosition()]; int mixin = Mixins[sMixin.getSelectedItemPosition()];
int priorityIndex = sPriority.getSelectedItemPosition(); int priorityIndex = sPriority.getSelectedItemPosition();
PendingTransaction.Priority priority = Priorities[priorityIndex]; PendingTransaction.Priority priority = Priorities[priorityIndex];
Log.d(TAG, dst_addr + "/" + paymentId + "/" + amount + "/" + mixin + "/" + priority.toString()); Timber.d("%s/%s/%d/%d/%s", dst_addr, paymentId, amount, mixin, priority.toString());
TxData txData = new TxData( TxData txData = new TxData(
dst_addr, dst_addr,
paymentId, paymentId,
@ -426,12 +426,12 @@ public class SendFragment extends Fragment {
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
Log.d(TAG, "onResume"); Timber.d("onResume");
activityCallback.setToolbarButton(Toolbar.BUTTON_BACK); activityCallback.setToolbarButton(Toolbar.BUTTON_BACK);
activityCallback.setSubtitle(getString(R.string.send_title)); activityCallback.setSubtitle(getString(R.string.send_title));
BarcodeData data = activityCallback.popScannedData(); BarcodeData data = activityCallback.popScannedData();
if (data != null) { if (data != null) {
Log.d(TAG, "GOT DATA"); Timber.d("GOT DATA");
String scannedAddress = data.address; String scannedAddress = data.address;
if (scannedAddress != null) { if (scannedAddress != null) {
etAddress.getEditText().setText(scannedAddress); etAddress.getEditText().setText(scannedAddress);

View File

@ -44,7 +44,6 @@ import java.util.Set;
import java.util.TimeZone; import java.util.TimeZone;
public class TxFragment extends Fragment { public class TxFragment extends Fragment {
static final String TAG = "TxFragment";
static public final String ARG_INFO = "info"; static public final String ARG_INFO = "info";

View File

@ -31,7 +31,6 @@ import android.support.annotation.NonNull;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import android.view.MenuItem; import android.view.MenuItem;
import android.widget.Toast; import android.widget.Toast;
@ -50,12 +49,13 @@ import com.m2049r.xmrwallet.util.TxData;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import timber.log.Timber;
public class WalletActivity extends SecureActivity implements WalletFragment.Listener, public class WalletActivity extends SecureActivity implements WalletFragment.Listener,
WalletService.Observer, SendFragment.Listener, TxFragment.Listener, WalletService.Observer, SendFragment.Listener, TxFragment.Listener,
GenerateReviewFragment.ListenerWithWallet, GenerateReviewFragment.ListenerWithWallet,
GenerateReviewFragment.Listener, GenerateReviewFragment.Listener,
ScannerFragment.Listener, ReceiveFragment.Listener { ScannerFragment.Listener, ReceiveFragment.Listener {
private static final String TAG = "WalletActivity";
public static final String REQUEST_ID = "id"; public static final String REQUEST_ID = "id";
public static final String REQUEST_PW = "pw"; public static final String REQUEST_PW = "pw";
@ -74,7 +74,7 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
@Override @Override
public void setTitle(String title) { public void setTitle(String title) {
Log.d(TAG, "setTitle:" + title + "."); Timber.d("setTitle:%s.", title);
toolbar.setTitle(title); toolbar.setTitle(title);
} }
@ -108,7 +108,7 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
@Override @Override
protected void onStart() { protected void onStart() {
super.onStart(); super.onStart();
Log.d(TAG, "onStart()"); Timber.d( "onStart()");
} }
private void startWalletService() { private void startWalletService() {
@ -131,13 +131,13 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
@Override @Override
protected void onStop() { protected void onStop() {
Log.d(TAG, "onStop()"); Timber.d("onStop()");
super.onStop(); super.onStop();
} }
@Override @Override
protected void onDestroy() { protected void onDestroy() {
Log.d(TAG, "onDestroy()"); Timber.d("onDestroy()");
stopWalletService(); stopWalletService();
super.onDestroy(); super.onDestroy();
} }
@ -179,7 +179,7 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "onCreate()"); Timber.d("onCreate()");
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (savedInstanceState != null) { if (savedInstanceState != null) {
// activity restarted // activity restarted
@ -208,7 +208,7 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
Toast.makeText(WalletActivity.this, getString(R.string.label_donate), Toast.LENGTH_SHORT).show(); Toast.makeText(WalletActivity.this, getString(R.string.label_donate), Toast.LENGTH_SHORT).show();
case Toolbar.BUTTON_NONE: case Toolbar.BUTTON_NONE:
default: default:
Log.e(TAG, "Button " + type + "pressed - how can this be?"); Timber.e("Button " + type + "pressed - how can this be?");
} }
} }
}); });
@ -222,11 +222,11 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
Fragment walletFragment = new WalletFragment(); Fragment walletFragment = new WalletFragment();
getSupportFragmentManager().beginTransaction() getSupportFragmentManager().beginTransaction()
.add(R.id.fragment_container, walletFragment, WalletFragment.TAG).commit(); .add(R.id.fragment_container, walletFragment, WalletFragment.class.getName()).commit();
Log.d(TAG, "fragment added"); Timber.d("fragment added");
startWalletService(); startWalletService();
Log.d(TAG, "onCreate() done."); Timber.d("onCreate() done.");
} }
public Wallet getWallet() { public Wallet getWallet() {
@ -254,7 +254,7 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
} }
} }
updateProgress(); updateProgress();
Log.d(TAG, "CONNECTED"); Timber.d( "CONNECTED");
} }
public void onServiceDisconnected(ComponentName className) { public void onServiceDisconnected(ComponentName className) {
@ -264,7 +264,7 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
// see this happen. // see this happen.
mBoundService = null; mBoundService = null;
setTitle(getString(R.string.wallet_activity_name), getString(R.string.status_wallet_disconnected)); setTitle(getString(R.string.wallet_activity_name), getString(R.string.status_wallet_disconnected));
Log.d(TAG, "DISCONNECTED"); Timber.d( "DISCONNECTED");
} }
}; };
@ -280,7 +280,7 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
startService(intent); startService(intent);
bindService(intent, mConnection, Context.BIND_AUTO_CREATE); bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
mIsBound = true; mIsBound = true;
Log.d(TAG, "BOUND"); Timber.d( "BOUND");
} }
void disconnectWalletService() { void disconnectWalletService() {
@ -289,20 +289,20 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
mBoundService.setObserver(null); mBoundService.setObserver(null);
unbindService(mConnection); unbindService(mConnection);
mIsBound = false; mIsBound = false;
Log.d(TAG, "UNBOUND"); Timber.d( "UNBOUND");
} }
} }
@Override @Override
protected void onPause() { protected void onPause() {
Log.d(TAG, "onPause()"); Timber.d( "onPause()");
super.onPause(); super.onPause();
} }
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
Log.d(TAG, "onResume()"); Timber.d( "onResume()");
} }
private PowerManager.WakeLock wl = null; private PowerManager.WakeLock wl = null;
@ -313,9 +313,9 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
this.wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, getString(R.string.app_name)); this.wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, getString(R.string.app_name));
try { try {
wl.acquire(); wl.acquire();
Log.d(TAG, "WakeLock acquired"); Timber.d( "WakeLock acquired");
} catch (SecurityException ex) { } catch (SecurityException ex) {
Log.w(TAG, "WakeLock NOT acquired: " + ex.getLocalizedMessage()); Timber.w( "WakeLock NOT acquired: %s", ex.getLocalizedMessage());
wl = null; wl = null;
} }
} }
@ -324,7 +324,7 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
if ((wl == null) || !wl.isHeld()) return; if ((wl == null) || !wl.isHeld()) return;
wl.release(); wl.release();
wl = null; wl = null;
Log.d(TAG, "WakeLock released"); Timber.d( "WakeLock released");
} }
public void saveWallet() { public void saveWallet() {
@ -332,9 +332,9 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
Intent intent = new Intent(getApplicationContext(), WalletService.class); Intent intent = new Intent(getApplicationContext(), WalletService.class);
intent.putExtra(WalletService.REQUEST, WalletService.REQUEST_CMD_STORE); intent.putExtra(WalletService.REQUEST, WalletService.REQUEST_CMD_STORE);
startService(intent); startService(intent);
Log.d(TAG, "STORE request sent"); Timber.d( "STORE request sent");
} else { } else {
Log.e(TAG, "Service not bound"); Timber.e( "Service not bound");
} }
} }
@ -374,7 +374,7 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
try { try {
onRefreshed(getWallet(), true); onRefreshed(getWallet(), true);
} catch (IllegalStateException ex) { } catch (IllegalStateException ex) {
Log.e(TAG, ex.getLocalizedMessage()); Timber.e( ex.getLocalizedMessage());
} }
} }
@ -385,12 +385,12 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
// refresh and return if successful // refresh and return if successful
@Override @Override
public boolean onRefreshed(final Wallet wallet, final boolean full) { public boolean onRefreshed(final Wallet wallet, final boolean full) {
Log.d(TAG, "onRefreshed()"); Timber.d( "onRefreshed()");
try { try {
final WalletFragment walletFragment = (WalletFragment) final WalletFragment walletFragment = (WalletFragment)
getSupportFragmentManager().findFragmentByTag(WalletFragment.TAG); getSupportFragmentManager().findFragmentByTag(WalletFragment.class.getName());
if (wallet.isSynchronized()) { if (wallet.isSynchronized()) {
Log.d(TAG, "onRefreshed() synced"); Timber.d("onRefreshed() synced");
releaseWakeLock(); // the idea is to stay awake until synced releaseWakeLock(); // the idea is to stay awake until synced
if (!synced) { // first sync if (!synced) { // first sync
onProgress(-1); onProgress(-1);
@ -411,7 +411,7 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
return true; return true;
} catch (ClassCastException ex) { } catch (ClassCastException ex) {
// not in wallet fragment (probably send monero) // not in wallet fragment (probably send monero)
Log.d(TAG, ex.getLocalizedMessage()); Timber.d(ex.getLocalizedMessage());
// keep calm and carry on // keep calm and carry on
} }
return false; return false;
@ -478,7 +478,7 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
}); });
} catch (ClassCastException ex) { } catch (ClassCastException ex) {
// not in spend fragment // not in spend fragment
Log.d(TAG, ex.getLocalizedMessage()); Timber.d(ex.getLocalizedMessage());
// don't need the transaction any more // don't need the transaction any more
getWallet().disposePendingTransaction(); getWallet().disposePendingTransaction();
} }
@ -513,7 +513,7 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
}); });
} catch (ClassCastException ex) { } catch (ClassCastException ex) {
// not in tx fragment // not in tx fragment
Log.d(TAG, ex.getLocalizedMessage()); Timber.d(ex.getLocalizedMessage());
// never min // never min
} }
} }
@ -522,7 +522,7 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
public void onProgress(final String text) { public void onProgress(final String text) {
try { try {
final WalletFragment walletFragment = (WalletFragment) final WalletFragment walletFragment = (WalletFragment)
getSupportFragmentManager().findFragmentByTag(WalletFragment.TAG); getSupportFragmentManager().findFragmentByTag(WalletFragment.class.getName());
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
public void run() { public void run() {
walletFragment.setProgress(text); walletFragment.setProgress(text);
@ -530,7 +530,7 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
}); });
} catch (ClassCastException ex) { } catch (ClassCastException ex) {
// not in wallet fragment (probably send monero) // not in wallet fragment (probably send monero)
Log.d(TAG, ex.getLocalizedMessage()); Timber.d(ex.getLocalizedMessage());
// keep calm and carry on // keep calm and carry on
} }
} }
@ -539,7 +539,7 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
public void onProgress(final int n) { public void onProgress(final int n) {
try { try {
final WalletFragment walletFragment = (WalletFragment) final WalletFragment walletFragment = (WalletFragment)
getSupportFragmentManager().findFragmentByTag(WalletFragment.TAG); getSupportFragmentManager().findFragmentByTag(WalletFragment.class.getName());
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
public void run() { public void run() {
walletFragment.setProgress(n); walletFragment.setProgress(n);
@ -547,7 +547,7 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
}); });
} catch (ClassCastException ex) { } catch (ClassCastException ex) {
// not in wallet fragment (probably send monero) // not in wallet fragment (probably send monero)
Log.d(TAG, ex.getLocalizedMessage()); Timber.d(ex.getLocalizedMessage());
// keep calm and carry on // keep calm and carry on
} }
} }
@ -571,9 +571,9 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
intent.putExtra(WalletService.REQUEST, WalletService.REQUEST_CMD_SEND); intent.putExtra(WalletService.REQUEST, WalletService.REQUEST_CMD_SEND);
intent.putExtra(WalletService.REQUEST_CMD_SEND_NOTES, notes); intent.putExtra(WalletService.REQUEST_CMD_SEND_NOTES, notes);
startService(intent); startService(intent);
Log.d(TAG, "SEND TX request sent"); Timber.d("SEND TX request sent");
} else { } else {
Log.e(TAG, "Service not bound"); Timber.e("Service not bound");
} }
} }
@ -586,9 +586,9 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
intent.putExtra(WalletService.REQUEST_CMD_SETNOTE_TX, txId); intent.putExtra(WalletService.REQUEST_CMD_SETNOTE_TX, txId);
intent.putExtra(WalletService.REQUEST_CMD_SETNOTE_NOTES, notes); intent.putExtra(WalletService.REQUEST_CMD_SETNOTE_NOTES, notes);
startService(intent); startService(intent);
Log.d(TAG, "SET NOTE request sent"); Timber.d("SET NOTE request sent");
} else { } else {
Log.e(TAG, "Service not bound"); Timber.e("Service not bound");
} }
} }
@ -600,9 +600,9 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
intent.putExtra(WalletService.REQUEST, WalletService.REQUEST_CMD_TX); intent.putExtra(WalletService.REQUEST, WalletService.REQUEST_CMD_TX);
intent.putExtra(WalletService.REQUEST_CMD_TX_DATA, txData); intent.putExtra(WalletService.REQUEST_CMD_TX_DATA, txData);
startService(intent); startService(intent);
Log.d(TAG, "CREATE TX request sent"); Timber.d("CREATE TX request sent");
} else { } else {
Log.e(TAG, "Service not bound"); Timber.e("Service not bound");
} }
} }
@ -665,7 +665,7 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
fragment.shareTxInfo(); fragment.shareTxInfo();
} catch (ClassCastException ex) { } catch (ClassCastException ex) {
// not in wallet fragment // not in wallet fragment
Log.e(TAG, ex.getLocalizedMessage()); Timber.e(ex.getLocalizedMessage());
// keep calm and carry on // keep calm and carry on
} }
} }
@ -697,7 +697,7 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
if (Helper.getCameraPermission(this)) { if (Helper.getCameraPermission(this)) {
startScanFragment(); startScanFragment();
} else { } else {
Log.i(TAG, "Waiting for permissions"); Timber.i("Waiting for permissions");
} }
} }
@ -770,7 +770,7 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
@Override @Override
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[],
@NonNull int[] grantResults) { @NonNull int[] grantResults) {
Log.d(TAG, "onRequestPermissionsResult()"); Timber.d("onRequestPermissionsResult()");
switch (requestCode) { switch (requestCode) {
case Helper.PERMISSIONS_REQUEST_CAMERA: case Helper.PERMISSIONS_REQUEST_CAMERA:
// If request is cancelled, the result arrays are empty. // If request is cancelled, the result arrays are empty.
@ -779,7 +779,7 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
startScanFragment = true; startScanFragment = true;
} else { } else {
String msg = getString(R.string.message_camera_not_permitted); String msg = getString(R.string.message_camera_not_permitted);
Log.e(TAG, msg); Timber.e(msg);
Toast.makeText(this, msg, Toast.LENGTH_LONG).show(); Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
} }
break; break;
@ -793,7 +793,7 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
} }
void startReceive(String address) { void startReceive(String address) {
Log.d(TAG, "startReceive()"); Timber.d( "startReceive()");
Bundle b = new Bundle(); Bundle b = new Bundle();
b.putString("address", address); b.putString("address", address);
b.putString("name", getWalletName()); b.putString("name", getWalletName());
@ -802,6 +802,6 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
void startReceiveFragment(Bundle extras) { void startReceiveFragment(Bundle extras) {
replaceFragment(new ReceiveFragment(), null, extras); replaceFragment(new ReceiveFragment(), null, extras);
Log.d(TAG, "ReceiveFragment placed"); Timber.d( "ReceiveFragment placed");
} }
} }

View File

@ -23,7 +23,6 @@ import android.os.Looper;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -52,11 +51,10 @@ import com.m2049r.xmrwallet.util.OkHttpClientSingleton;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.List; import java.util.List;
import okhttp3.OkHttpClient; import timber.log.Timber;
public class WalletFragment extends Fragment public class WalletFragment extends Fragment
implements TransactionInfoAdapter.OnInteractionListener { implements TransactionInfoAdapter.OnInteractionListener {
public static final String TAG = "WalletFragment";
private TransactionInfoAdapter adapter; private TransactionInfoAdapter adapter;
private NumberFormat formatter = NumberFormat.getInstance(); private NumberFormat formatter = NumberFormat.getInstance();
@ -190,7 +188,7 @@ public class WalletFragment extends Fragment
@Override @Override
public void onError(final Exception e) { public void onError(final Exception e) {
Log.e(TAG, e.getLocalizedMessage()); Timber.e(e.getLocalizedMessage());
if (isAdded()) if (isAdded())
new Handler(Looper.getMainLooper()).post(new Runnable() { new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override @Override
@ -232,14 +230,14 @@ public class WalletFragment extends Fragment
public void exchange(final ExchangeRate exchangeRate) { public void exchange(final ExchangeRate exchangeRate) {
hideExchanging(); hideExchanging();
if (!"XMR".equals(exchangeRate.getBaseCurrency())) { if (!"XMR".equals(exchangeRate.getBaseCurrency())) {
Log.e(TAG, "Not XMR"); Timber.e("Not XMR");
sCurrency.setSelection(0, true); sCurrency.setSelection(0, true);
balanceCurrency = "XMR"; balanceCurrency = "XMR";
balanceRate = 1.0; balanceRate = 1.0;
} else { } else {
int spinnerPosition = ((ArrayAdapter) sCurrency.getAdapter()).getPosition(exchangeRate.getQuoteCurrency()); int spinnerPosition = ((ArrayAdapter) sCurrency.getAdapter()).getPosition(exchangeRate.getQuoteCurrency());
if (spinnerPosition < 0) { // requested currency not in list if (spinnerPosition < 0) { // requested currency not in list
Log.e(TAG, "Requested currency not in list " + exchangeRate.getQuoteCurrency()); Timber.e("Requested currency not in list %s", exchangeRate.getQuoteCurrency());
sCurrency.setSelection(0, true); sCurrency.setSelection(0, true);
} else { } else {
sCurrency.setSelection(spinnerPosition, true); sCurrency.setSelection(spinnerPosition, true);
@ -259,7 +257,7 @@ public class WalletFragment extends Fragment
// called from activity // called from activity
public void onRefreshed(final Wallet wallet, final boolean full) { public void onRefreshed(final Wallet wallet, final boolean full) {
Log.d(TAG, "onRefreshed()"); Timber.d("onRefreshed()");
if (full) { if (full) {
List<TransactionInfo> list = wallet.getHistory().getAll(); List<TransactionInfo> list = wallet.getHistory().getAll();
adapter.setInfos(list); adapter.setInfos(list);
@ -318,7 +316,7 @@ public class WalletFragment extends Fragment
String watchOnly = (wallet.isWatchOnly() ? getString(R.string.label_watchonly) : ""); String watchOnly = (wallet.isWatchOnly() ? getString(R.string.label_watchonly) : "");
walletSubtitle = wallet.getAddress().substring(0, 16) + "" + watchOnly; walletSubtitle = wallet.getAddress().substring(0, 16) + "" + watchOnly;
activityCallback.setTitle(walletTitle, walletSubtitle); activityCallback.setTitle(walletTitle, walletSubtitle);
Log.d(TAG, "wallet title is " + walletTitle); Timber.d("wallet title is %s", walletTitle);
} }
private long firstBlock = 0; private long firstBlock = 0;
@ -328,7 +326,7 @@ public class WalletFragment extends Fragment
private void updateStatus(Wallet wallet) { private void updateStatus(Wallet wallet) {
if (!isAdded()) return; if (!isAdded()) return;
Log.d(TAG, "updateStatus()"); Timber.d("updateStatus()");
if (walletTitle == null) { if (walletTitle == null) {
setActivityTitle(wallet); setActivityTitle(wallet);
} }
@ -413,7 +411,7 @@ public class WalletFragment extends Fragment
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
Log.d(TAG, "onResume()"); Timber.d("onResume()");
activityCallback.setTitle(walletTitle, walletSubtitle); activityCallback.setTitle(walletTitle, walletSubtitle);
activityCallback.setToolbarButton(Toolbar.BUTTON_CLOSE); activityCallback.setToolbarButton(Toolbar.BUTTON_CLOSE);
setProgress(syncProgress); setProgress(syncProgress);

View File

@ -0,0 +1,17 @@
package com.m2049r.xmrwallet;
import android.app.Application;
import timber.log.Timber;
public class XmrWalletApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
if (BuildConfig.DEBUG) {
Timber.plant(new Timber.DebugTree());
}
}
}

View File

@ -25,7 +25,6 @@ import android.support.design.widget.TextInputLayout;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -48,10 +47,9 @@ import com.m2049r.xmrwallet.util.OkHttpClientSingleton;
import java.util.Locale; import java.util.Locale;
import okhttp3.OkHttpClient; import timber.log.Timber;
public class ExchangeView extends LinearLayout { public class ExchangeView extends LinearLayout {
static final String TAG = "ExchangeView";
public boolean focus() { public boolean focus() {
return etAmount.requestFocus(); return etAmount.requestFocus();
@ -254,7 +252,7 @@ public class ExchangeView extends LinearLayout {
public boolean checkEnteredAmount() { public boolean checkEnteredAmount() {
boolean ok = true; boolean ok = true;
Log.d(TAG, "checkEnteredAmount"); Timber.d("checkEnteredAmount");
String amountEntry = etAmount.getEditText().getText().toString(); String amountEntry = etAmount.getEditText().getText().toString();
if (!amountEntry.isEmpty()) { if (!amountEntry.isEmpty()) {
try { try {
@ -307,7 +305,7 @@ public class ExchangeView extends LinearLayout {
@Override @Override
public void onError(final Exception e) { public void onError(final Exception e) {
Log.e(TAG, e.getLocalizedMessage()); Timber.e(e.getLocalizedMessage());
new Handler(Looper.getMainLooper()).post(new Runnable() { new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -338,7 +336,7 @@ public class ExchangeView extends LinearLayout {
} }
tvAmountB.setText(xmrAmount); tvAmountB.setText(xmrAmount);
} else { // no XMR currency - cannot happen! } else { // no XMR currency - cannot happen!
Log.e(TAG, "No XMR currency!"); Timber.e("No XMR currency!");
setXmr(null); setXmr(null);
notXmrAmount = null; notXmrAmount = null;
return; return;
@ -346,7 +344,7 @@ public class ExchangeView extends LinearLayout {
} }
boolean prepareExchange() { boolean prepareExchange() {
Log.d(TAG, "prepareExchange()"); Timber.d("prepareExchange()");
if (checkEnteredAmount()) { if (checkEnteredAmount()) {
String enteredAmount = etAmount.getEditText().getText().toString(); String enteredAmount = etAmount.getEditText().getText().toString();
if (!enteredAmount.isEmpty()) { if (!enteredAmount.isEmpty()) {
@ -356,7 +354,7 @@ public class ExchangeView extends LinearLayout {
cleanAmount = Helper.getDisplayAmount(Wallet.getAmountFromString(enteredAmount)); cleanAmount = Helper.getDisplayAmount(Wallet.getAmountFromString(enteredAmount));
setXmr(cleanAmount); setXmr(cleanAmount);
notXmrAmount = null; notXmrAmount = null;
Log.d(TAG, "cleanAmount = " + cleanAmount); Timber.d("cleanAmount = %s", cleanAmount);
} else if (getCurrencyB() == 0) { // we use B & 0 here for the else below ... } else if (getCurrencyB() == 0) { // we use B & 0 here for the else below ...
// sanitize the input // sanitize the input
double amountA = Double.parseDouble(enteredAmount); double amountA = Double.parseDouble(enteredAmount);
@ -364,12 +362,12 @@ public class ExchangeView extends LinearLayout {
setXmr(null); setXmr(null);
notXmrAmount = cleanAmount; notXmrAmount = cleanAmount;
} else { // no XMR currency - cannot happen! } else { // no XMR currency - cannot happen!
Log.e(TAG, "No XMR currency!"); Timber.e("No XMR currency!");
setXmr(null); setXmr(null);
notXmrAmount = null; notXmrAmount = null;
return false; return false;
} }
Log.d(TAG, "prepareExchange() " + cleanAmount); Timber.d("prepareExchange() %s", cleanAmount);
//etAmount.getEditText().setText(cleanAmount); // display what we use //etAmount.getEditText().setText(cleanAmount); // display what we use
} else { } else {
setXmr(""); setXmr("");
@ -399,7 +397,7 @@ public class ExchangeView extends LinearLayout {
if (!exchangeRate.getBaseCurrency().equals(enteredCurrencyA) if (!exchangeRate.getBaseCurrency().equals(enteredCurrencyA)
|| !exchangeRate.getQuoteCurrency().equals(enteredCurrencyB)) { || !exchangeRate.getQuoteCurrency().equals(enteredCurrencyB)) {
// something's wrong // something's wrong
Log.e(TAG, "Currencies don't match!"); Timber.e("Currencies don't match!");
return; return;
} }
if (prepareExchange()) { if (prepareExchange()) {

View File

@ -19,7 +19,6 @@ package com.m2049r.xmrwallet.layout;
import android.content.Context; import android.content.Context;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -37,8 +36,9 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.TimeZone; import java.util.TimeZone;
import timber.log.Timber;
public class TransactionInfoAdapter extends RecyclerView.Adapter<TransactionInfoAdapter.ViewHolder> { public class TransactionInfoAdapter extends RecyclerView.Adapter<TransactionInfoAdapter.ViewHolder> {
private static final String TAG = "TransactionInfoAdapter";
private final SimpleDateFormat DATETIME_FORMATTER = new SimpleDateFormat("yyyy-MM-dd HH:mm"); private final SimpleDateFormat DATETIME_FORMATTER = new SimpleDateFormat("yyyy-MM-dd HH:mm");
@ -96,11 +96,11 @@ public class TransactionInfoAdapter extends RecyclerView.Adapter<TransactionInfo
// as the TransactionInfo items are always recreated, we cannot recycle // as the TransactionInfo items are always recreated, we cannot recycle
this.infoItems.clear(); this.infoItems.clear();
if (data != null) { if (data != null) {
Log.d(TAG, "setInfos " + data.size()); Timber.d("setInfos %s", data.size());
infoItems.addAll(data); infoItems.addAll(data);
Collections.sort(infoItems); Collections.sort(infoItems);
} else { } else {
Log.d(TAG, "setInfos null"); Timber.d("setInfos null");
} }
notifyDataSetChanged(); notifyDataSetChanged();
} }

View File

@ -19,7 +19,6 @@ package com.m2049r.xmrwallet.layout;
import android.content.Context; import android.content.Context;
import android.support.v7.widget.PopupMenu; import android.support.v7.widget.PopupMenu;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
@ -38,8 +37,9 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.TimeZone; import java.util.TimeZone;
import timber.log.Timber;
public class WalletInfoAdapter extends RecyclerView.Adapter<WalletInfoAdapter.ViewHolder> { public class WalletInfoAdapter extends RecyclerView.Adapter<WalletInfoAdapter.ViewHolder> {
private static final String TAG = "WalletInfoAdapter";
private final SimpleDateFormat DATETIME_FORMATTER = new SimpleDateFormat("yyyy-MM-dd HH:mm"); private final SimpleDateFormat DATETIME_FORMATTER = new SimpleDateFormat("yyyy-MM-dd HH:mm");
@ -89,11 +89,11 @@ public class WalletInfoAdapter extends RecyclerView.Adapter<WalletInfoAdapter.Vi
// as the WalletInfo items are always recreated, we cannot recycle // as the WalletInfo items are always recreated, we cannot recycle
infoItems.clear(); infoItems.clear();
if (data != null) { if (data != null) {
Log.d(TAG, "setInfos " + data.size()); Timber.d("setInfos %s", data.size());
infoItems.addAll(data); infoItems.addAll(data);
Collections.sort(infoItems); Collections.sort(infoItems);
} else { } else {
Log.d(TAG, "setInfos null"); Timber.d("setInfos null");
} }
notifyDataSetChanged(); notifyDataSetChanged();
} }

View File

@ -16,21 +16,17 @@
package com.m2049r.xmrwallet.model; package com.m2049r.xmrwallet.model;
import android.support.annotation.NonNull;
import android.util.Log;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileReader; import java.io.FileReader;
import java.io.FilenameFilter; import java.io.FilenameFilter;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import timber.log.Timber;
public class WalletManager { public class WalletManager {
private final static String TAG = "WalletManager";
static { static {
System.loadLibrary("monerujo"); System.loadLibrary("monerujo");
@ -54,7 +50,7 @@ public class WalletManager {
} }
private void manageWallet(Wallet wallet) { private void manageWallet(Wallet wallet) {
Log.d(TAG, "Managing " + wallet.getName()); Timber.d("Managing %s", wallet.getName());
managedWallet = wallet; managedWallet = wallet;
} }
@ -68,7 +64,7 @@ public class WalletManager {
if (getWallet() != wallet) { if (getWallet() != wallet) {
throw new IllegalStateException(wallet.getName() + " not under management!"); throw new IllegalStateException(wallet.getName() + " not under management!");
} }
Log.d(TAG, "Unmanaging " + managedWallet.getName()); Timber.d("Unmanaging %s", managedWallet.getName());
managedWallet = null; managedWallet = null;
} }
@ -165,14 +161,14 @@ public class WalletManager {
info.path = wallet.getParentFile(); info.path = wallet.getParentFile();
info.name = wallet.getName(); info.name = wallet.getName();
File addressFile = new File(info.path, info.name + ".address.txt"); File addressFile = new File(info.path, info.name + ".address.txt");
//Log.d(TAG, addressFile.getAbsolutePath()); //Timber.d(addressFile.getAbsolutePath());
info.address = "??????"; info.address = "??????";
BufferedReader addressReader = null; BufferedReader addressReader = null;
try { try {
addressReader = new BufferedReader(new FileReader(addressFile)); addressReader = new BufferedReader(new FileReader(addressFile));
info.address = addressReader.readLine(); info.address = addressReader.readLine();
} catch (IOException ex) { } catch (IOException ex) {
Log.d(TAG, ex.getLocalizedMessage()); Timber.d(ex.getLocalizedMessage());
} finally { } finally {
if (addressReader != null) { if (addressReader != null) {
try { try {
@ -187,7 +183,7 @@ public class WalletManager {
public List<WalletInfo> findWallets(File path) { public List<WalletInfo> findWallets(File path) {
List<WalletInfo> wallets = new ArrayList<>(); List<WalletInfo> wallets = new ArrayList<>();
Log.d(TAG, "Scanning: " + path.getAbsolutePath()); Timber.d("Scanning: %s", path.getAbsolutePath());
File[] found = path.listFiles(new FilenameFilter() { File[] found = path.listFiles(new FilenameFilter() {
public boolean accept(File dir, String filename) { public boolean accept(File dir, String filename) {
return filename.endsWith(".keys"); return filename.endsWith(".keys");
@ -217,7 +213,7 @@ public class WalletManager {
} }
public void setDaemon(String address, boolean testnet, String username, String password) { public void setDaemon(String address, boolean testnet, String username, String password) {
//Log.d(TAG, "SETDAEMON " + username + "/" + password + "/" + address); //Timber.d("SETDAEMON " + username + "/" + password + "/" + address);
this.daemonAddress = address; this.daemonAddress = address;
this.testnet = testnet; this.testnet = testnet;
this.daemonUsername = username; this.daemonUsername = username;

View File

@ -27,7 +27,6 @@ import android.os.IBinder;
import android.os.Looper; import android.os.Looper;
import android.os.Message; import android.os.Message;
import android.os.Process; import android.os.Process;
import android.util.Log;
import com.m2049r.xmrwallet.R; import com.m2049r.xmrwallet.R;
import com.m2049r.xmrwallet.WalletActivity; import com.m2049r.xmrwallet.WalletActivity;
@ -38,10 +37,11 @@ import com.m2049r.xmrwallet.model.WalletManager;
import com.m2049r.xmrwallet.util.Helper; import com.m2049r.xmrwallet.util.Helper;
import com.m2049r.xmrwallet.util.TxData; import com.m2049r.xmrwallet.util.TxData;
import timber.log.Timber;
public class WalletService extends Service { public class WalletService extends Service {
public static boolean Running = false; public static boolean Running = false;
final static String TAG = "WalletService";
final static int NOTIFICATION_ID = 2049; final static int NOTIFICATION_ID = 2049;
public static final String REQUEST_WALLET = "wallet"; public static final String REQUEST_WALLET = "wallet";
@ -73,7 +73,7 @@ public class WalletService extends Service {
boolean updated = true; boolean updated = true;
void start() { void start() {
Log.d(TAG, "MyWalletListener.start()"); Timber.d("MyWalletListener.start()");
Wallet wallet = getWallet(); Wallet wallet = getWallet();
if (wallet == null) throw new IllegalStateException("No wallet!"); if (wallet == null) throw new IllegalStateException("No wallet!");
//acquireWakeLock(); //acquireWakeLock();
@ -82,7 +82,7 @@ public class WalletService extends Service {
} }
void stop() { void stop() {
Log.d(TAG, "MyWalletListener.stop()"); Timber.d("MyWalletListener.stop()");
Wallet wallet = getWallet(); Wallet wallet = getWallet();
if (wallet == null) throw new IllegalStateException("No wallet!"); if (wallet == null) throw new IllegalStateException("No wallet!");
wallet.pauseRefresh(); wallet.pauseRefresh();
@ -92,15 +92,15 @@ public class WalletService extends Service {
// WalletListener callbacks // WalletListener callbacks
public void moneySpent(String txId, long amount) { public void moneySpent(String txId, long amount) {
Log.d(TAG, "moneySpent() " + amount + " @ " + txId); Timber.d("moneySpent() %d @ %s", amount, txId);
} }
public void moneyReceived(String txId, long amount) { public void moneyReceived(String txId, long amount) {
Log.d(TAG, "moneyReceived() " + amount + " @ " + txId); Timber.d("moneyReceived() %d @ %s",amount, txId);
} }
public void unconfirmedMoneyReceived(String txId, long amount) { public void unconfirmedMoneyReceived(String txId, long amount) {
Log.d(TAG, "unconfirmedMoneyReceived() " + amount + " @ " + txId); Timber.d("unconfirmedMoneyReceived() %d @ %s", amount, txId);
} }
long lastBlockTime = 0; long lastBlockTime = 0;
@ -111,7 +111,7 @@ public class WalletService extends Service {
if (wallet == null) throw new IllegalStateException("No wallet!"); if (wallet == null) throw new IllegalStateException("No wallet!");
// don't flood with an update for every block ... // don't flood with an update for every block ...
if (lastBlockTime < System.currentTimeMillis() - 2000) { if (lastBlockTime < System.currentTimeMillis() - 2000) {
Log.d(TAG, "newBlock() @" + height + " with observer " + observer); Timber.d("newBlock() @ %d with observer %s", height, observer);
lastBlockTime = System.currentTimeMillis(); lastBlockTime = System.currentTimeMillis();
if (observer != null) { if (observer != null) {
boolean fullRefresh = false; boolean fullRefresh = false;
@ -134,14 +134,14 @@ public class WalletService extends Service {
} }
public void updated() { public void updated() {
Log.d(TAG, "updated()"); Timber.d("updated()");
Wallet wallet = getWallet(); Wallet wallet = getWallet();
if (wallet == null) throw new IllegalStateException("No wallet!"); if (wallet == null) throw new IllegalStateException("No wallet!");
updated = true; updated = true;
} }
public void refreshed() { public void refreshed() {
Log.d(TAG, "refreshed()"); Timber.d("refreshed()");
Wallet wallet = getWallet(); Wallet wallet = getWallet();
if (wallet == null) throw new IllegalStateException("No wallet!"); if (wallet == null) throw new IllegalStateException("No wallet!");
if (updated) { if (updated) {
@ -180,7 +180,7 @@ public class WalletService extends Service {
} }
} }
} }
//Log.d(TAG, "updated daemon status: " + daemonHeight + "/" + connectionStatus.toString()); //Timber.d("updated daemon status: " + daemonHeight + "/" + connectionStatus.toString());
} }
public long getDaemonHeight() { public long getDaemonHeight() {
@ -200,7 +200,7 @@ public class WalletService extends Service {
public void setObserver(Observer anObserver) { public void setObserver(Observer anObserver) {
observer = anObserver; observer = anObserver;
Log.d(TAG, "setObserver " + observer); Timber.d("setObserver %s", observer);
} }
public interface Observer { public interface Observer {
@ -266,9 +266,9 @@ public class WalletService extends Service {
@Override @Override
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
Log.d(TAG, "Handling " + msg.arg2); Timber.d("Handling %s", msg.arg2);
if (errorState) { if (errorState) {
Log.i(TAG, "In error state."); Timber.i("In error state.");
// also, we have already stopped ourselves // also, we have already stopped ourselves
return; return;
} }
@ -279,7 +279,7 @@ public class WalletService extends Service {
if (cmd.equals(REQUEST_CMD_LOAD)) { if (cmd.equals(REQUEST_CMD_LOAD)) {
String walletId = extras.getString(REQUEST_WALLET, null); String walletId = extras.getString(REQUEST_WALLET, null);
String walletPw = extras.getString(REQUEST_CMD_LOAD_PW, null); String walletPw = extras.getString(REQUEST_CMD_LOAD_PW, null);
Log.d(TAG, "LOAD wallet " + walletId); Timber.d("LOAD wallet %s", walletId);
if (walletId != null) { if (walletId != null) {
showProgress(getString(R.string.status_wallet_loading)); showProgress(getString(R.string.status_wallet_loading));
showProgress(10); showProgress(10);
@ -292,23 +292,23 @@ public class WalletService extends Service {
} }
} else if (cmd.equals(REQUEST_CMD_STORE)) { } else if (cmd.equals(REQUEST_CMD_STORE)) {
Wallet myWallet = getWallet(); Wallet myWallet = getWallet();
Log.d(TAG, "STORE wallet: " + myWallet.getName()); Timber.d("STORE wallet: %s", myWallet.getName());
boolean rc = myWallet.store(); boolean rc = myWallet.store();
Log.d(TAG, "wallet stored: " + myWallet.getName() + " with rc=" + rc); Timber.d("wallet stored: %s with rc=%b", myWallet.getName(), rc);
if (!rc) { if (!rc) {
Log.w(TAG, "Wallet store failed: " + myWallet.getErrorString()); Timber.w("Wallet store failed: %s", myWallet.getErrorString());
} }
if (observer != null) observer.onWalletStored(rc); if (observer != null) observer.onWalletStored(rc);
} else if (cmd.equals(REQUEST_CMD_TX)) { } else if (cmd.equals(REQUEST_CMD_TX)) {
Wallet myWallet = getWallet(); Wallet myWallet = getWallet();
Log.d(TAG, "CREATE TX for wallet: " + myWallet.getName()); Timber.d("CREATE TX for wallet: %s", myWallet.getName());
TxData txData = extras.getParcelable(REQUEST_CMD_TX_DATA); TxData txData = extras.getParcelable(REQUEST_CMD_TX_DATA);
PendingTransaction pendingTransaction = myWallet.createTransaction( PendingTransaction pendingTransaction = myWallet.createTransaction(
txData.dst_addr, txData.paymentId, txData.amount, txData.mixin, txData.priority); txData.dst_addr, txData.paymentId, txData.amount, txData.mixin, txData.priority);
PendingTransaction.Status status = pendingTransaction.getStatus(); PendingTransaction.Status status = pendingTransaction.getStatus();
Log.d(TAG, "transaction status " + status); Timber.d("transaction status %s", status);
if (status != PendingTransaction.Status.Status_Ok) { if (status != PendingTransaction.Status.Status_Ok) {
Log.w(TAG, "Create Transaction failed: " + pendingTransaction.getErrorString()); Timber.w("Create Transaction failed: %s", pendingTransaction.getErrorString());
} }
if (observer != null) { if (observer != null) {
observer.onCreatedTransaction(pendingTransaction); observer.onCreatedTransaction(pendingTransaction);
@ -317,12 +317,12 @@ public class WalletService extends Service {
} }
} else if (cmd.equals(REQUEST_CMD_SWEEP)) { } else if (cmd.equals(REQUEST_CMD_SWEEP)) {
Wallet myWallet = getWallet(); Wallet myWallet = getWallet();
Log.d(TAG, "SWEEP TX for wallet: " + myWallet.getName()); Timber.d("SWEEP TX for wallet: %s", myWallet.getName());
PendingTransaction pendingTransaction = myWallet.createSweepUnmixableTransaction(); PendingTransaction pendingTransaction = myWallet.createSweepUnmixableTransaction();
PendingTransaction.Status status = pendingTransaction.getStatus(); PendingTransaction.Status status = pendingTransaction.getStatus();
Log.d(TAG, "transaction status " + status); Timber.d("transaction status %s", status);
if (status != PendingTransaction.Status.Status_Ok) { if (status != PendingTransaction.Status.Status_Ok) {
Log.w(TAG, "Create Transaction failed: " + pendingTransaction.getErrorString()); Timber.w("Create Transaction failed: %s", pendingTransaction.getErrorString());
} }
if (observer != null) { if (observer != null) {
observer.onCreatedTransaction(pendingTransaction); observer.onCreatedTransaction(pendingTransaction);
@ -331,11 +331,11 @@ public class WalletService extends Service {
} }
} else if (cmd.equals(REQUEST_CMD_SEND)) { } else if (cmd.equals(REQUEST_CMD_SEND)) {
Wallet myWallet = getWallet(); Wallet myWallet = getWallet();
Log.d(TAG, "SEND TX for wallet: " + myWallet.getName()); Timber.d("SEND TX for wallet: %s", myWallet.getName());
PendingTransaction pendingTransaction = myWallet.getPendingTransaction(); PendingTransaction pendingTransaction = myWallet.getPendingTransaction();
if ((pendingTransaction == null) if ((pendingTransaction == null)
|| (pendingTransaction.getStatus() != PendingTransaction.Status.Status_Ok)) { || (pendingTransaction.getStatus() != PendingTransaction.Status.Status_Ok)) {
Log.e(TAG, "PendingTransaction is " + pendingTransaction.getStatus()); Timber.e("PendingTransaction is %s", pendingTransaction.getStatus());
myWallet.disposePendingTransaction(); // it's broken anyway myWallet.disposePendingTransaction(); // it's broken anyway
if (observer != null) observer.onSentTransaction(false); if (observer != null) observer.onSentTransaction(false);
return; return;
@ -350,29 +350,29 @@ public class WalletService extends Service {
myWallet.setUserNote(txid, notes); myWallet.setUserNote(txid, notes);
} }
boolean rc = myWallet.store(); boolean rc = myWallet.store();
Log.d(TAG, "wallet stored: " + myWallet.getName() + " with rc=" + rc); Timber.d("wallet stored: %s with rc=%b", myWallet.getName(), rc);
if (!rc) { if (!rc) {
Log.w(TAG, "Wallet store failed: " + myWallet.getErrorString()); Timber.w("Wallet store failed: %s", myWallet.getErrorString());
} }
if (observer != null) observer.onWalletStored(rc); if (observer != null) observer.onWalletStored(rc);
listener.updated = true; listener.updated = true;
} }
} else if (cmd.equals(REQUEST_CMD_SETNOTE)) { } else if (cmd.equals(REQUEST_CMD_SETNOTE)) {
Wallet myWallet = getWallet(); Wallet myWallet = getWallet();
Log.d(TAG, "SET NOTE for wallet: " + myWallet.getName()); Timber.d("SET NOTE for wallet: %s", myWallet.getName());
String txId = extras.getString(REQUEST_CMD_SETNOTE_TX); String txId = extras.getString(REQUEST_CMD_SETNOTE_TX);
String notes = extras.getString(REQUEST_CMD_SETNOTE_NOTES); String notes = extras.getString(REQUEST_CMD_SETNOTE_NOTES);
if ((txId != null) && (notes != null)) { if ((txId != null) && (notes != null)) {
boolean success = myWallet.setUserNote(txId, notes); boolean success = myWallet.setUserNote(txId, notes);
if (!success) { if (!success) {
Log.e(TAG, myWallet.getErrorString()); Timber.e(myWallet.getErrorString());
} }
if (observer != null) observer.onSetNotes(success); if (observer != null) observer.onSetNotes(success);
if (success) { if (success) {
boolean rc = myWallet.store(); boolean rc = myWallet.store();
Log.d(TAG, "wallet stored: " + myWallet.getName() + " with rc=" + rc); Timber.d("wallet stored: %s with rc=%b", myWallet.getName(), rc);
if (!rc) { if (!rc) {
Log.w(TAG, "Wallet store failed: " + myWallet.getErrorString()); Timber.w("Wallet store failed: %s", myWallet.getErrorString());
} }
if (observer != null) observer.onWalletStored(rc); if (observer != null) observer.onWalletStored(rc);
} }
@ -384,7 +384,7 @@ public class WalletService extends Service {
stop(); stop();
break; break;
default: default:
Log.e(TAG, "UNKNOWN " + msg.arg2); Timber.e("UNKNOWN %s", msg.arg2);
} }
} }
} }
@ -401,14 +401,14 @@ public class WalletService extends Service {
final Looper serviceLooper = thread.getLooper(); final Looper serviceLooper = thread.getLooper();
mServiceHandler = new WalletService.ServiceHandler(serviceLooper); mServiceHandler = new WalletService.ServiceHandler(serviceLooper);
Log.d(TAG, "Service created"); Timber.d("Service created");
} }
@Override @Override
public void onDestroy() { public void onDestroy() {
Log.d(TAG, "onDestroy()"); Timber.d("onDestroy()");
if (this.listener != null) { if (this.listener != null) {
Log.w(TAG, "onDestroy() with active listener"); Timber.w("onDestroy() with active listener");
// no need to stop() here because the wallet closing should have been triggered // no need to stop() here because the wallet closing should have been triggered
// through onUnbind() already // through onUnbind() already
} }
@ -430,7 +430,7 @@ public class WalletService extends Service {
// so we queue the open request // so we queue the open request
// this should not matter since the old activity is not getting updates // this should not matter since the old activity is not getting updates
// and the new one is not listening yet (although it will be bound) // and the new one is not listening yet (although it will be bound)
Log.d(TAG, "onStartCommand()"); Timber.d("onStartCommand()");
// For each start request, send a message to start a job and deliver the // For each start request, send a message to start a job and deliver the
// start ID so we know which request we're stopping when we finish the job // start ID so we know which request we're stopping when we finish the job
Message msg = mServiceHandler.obtainMessage(); Message msg = mServiceHandler.obtainMessage();
@ -449,28 +449,28 @@ public class WalletService extends Service {
@Override @Override
public IBinder onBind(Intent intent) { public IBinder onBind(Intent intent) {
// Very first client binds // Very first client binds
Log.d(TAG, "onBind()"); Timber.d("onBind()");
return mBinder; return mBinder;
} }
@Override @Override
public boolean onUnbind(Intent intent) { public boolean onUnbind(Intent intent) {
Log.d(TAG, "onUnbind()"); Timber.d("onUnbind()");
// All clients have unbound with unbindService() // All clients have unbound with unbindService()
Message msg = mServiceHandler.obtainMessage(); Message msg = mServiceHandler.obtainMessage();
msg.arg2 = STOP_SERVICE; msg.arg2 = STOP_SERVICE;
mServiceHandler.sendMessage(msg); mServiceHandler.sendMessage(msg);
Log.d(TAG, "onUnbind() message sent"); Timber.d("onUnbind() message sent");
return true; // true is important so that onUnbind is also called next time return true; // true is important so that onUnbind is also called next time
} }
private boolean start(String walletName, String walletPassword) { private boolean start(String walletName, String walletPassword) {
Log.d(TAG, "start()"); Timber.d("start()");
startNotfication(); startNotfication();
showProgress(getString(R.string.status_wallet_loading)); showProgress(getString(R.string.status_wallet_loading));
showProgress(10); showProgress(10);
if (listener == null) { if (listener == null) {
Log.d(TAG, "start() loadWallet"); Timber.d("start() loadWallet");
Wallet aWallet = loadWallet(walletName, walletPassword); Wallet aWallet = loadWallet(walletName, walletPassword);
if ((aWallet == null) || (aWallet.getConnectionStatus() != Wallet.ConnectionStatus.ConnectionStatus_Connected)) { if ((aWallet == null) || (aWallet.getConnectionStatus() != Wallet.ConnectionStatus.ConnectionStatus_Connected)) {
if (aWallet != null) aWallet.close(); if (aWallet != null) aWallet.close();
@ -484,19 +484,19 @@ public class WalletService extends Service {
showProgress(101); showProgress(101);
// if we try to refresh the history here we get occasional segfaults! // if we try to refresh the history here we get occasional segfaults!
// doesnt matter since we update as soon as we get a new block anyway // doesnt matter since we update as soon as we get a new block anyway
Log.d(TAG, "start() done"); Timber.d("start() done");
return true; return true;
} }
public void stop() { public void stop() {
Log.d(TAG, "stop()"); Timber.d("stop()");
setObserver(null); // in case it was not reset already setObserver(null); // in case it was not reset already
if (listener != null) { if (listener != null) {
listener.stop(); listener.stop();
Wallet myWallet = getWallet(); Wallet myWallet = getWallet();
Log.d(TAG, "stop() closing"); Timber.d("stop() closing");
myWallet.close(); myWallet.close();
Log.d(TAG, "stop() closed"); Timber.d("stop() closed");
listener = null; listener = null;
} }
stopForeground(true); stopForeground(true);
@ -507,7 +507,7 @@ public class WalletService extends Service {
private Wallet loadWallet(String walletName, String walletPassword) { private Wallet loadWallet(String walletName, String walletPassword) {
Wallet wallet = openWallet(walletName, walletPassword); Wallet wallet = openWallet(walletName, walletPassword);
if (wallet != null) { if (wallet != null) {
Log.d(TAG, "Using daemon " + WalletManager.getInstance().getDaemonAddress()); Timber.d("Using daemon %s", WalletManager.getInstance().getDaemonAddress());
showProgress(55); showProgress(55);
wallet.init(0); wallet.init(0);
showProgress(90); showProgress(90);
@ -520,17 +520,17 @@ public class WalletService extends Service {
showProgress(20); showProgress(20);
Wallet wallet = null; Wallet wallet = null;
WalletManager walletMgr = WalletManager.getInstance(); WalletManager walletMgr = WalletManager.getInstance();
Log.d(TAG, "WalletManager testnet=" + walletMgr.isTestNet()); Timber.d("WalletManager testnet=%s", walletMgr.isTestNet());
showProgress(30); showProgress(30);
if (walletMgr.walletExists(path)) { if (walletMgr.walletExists(path)) {
Log.d(TAG, "open wallet " + path); Timber.d("open wallet %s", path);
wallet = walletMgr.openWallet(path, walletPassword); wallet = walletMgr.openWallet(path, walletPassword);
showProgress(60); showProgress(60);
Log.d(TAG, "wallet opened"); Timber.d("wallet opened");
Wallet.Status status = wallet.getStatus(); Wallet.Status status = wallet.getStatus();
Log.d(TAG, "wallet status is " + status); Timber.d("wallet status is %s", status);
if (status != Wallet.Status.Status_Ok) { if (status != Wallet.Status.Status_Ok) {
Log.d(TAG, "wallet status is " + status); Timber.d("wallet status is %s", status);
WalletManager.getInstance().close(wallet); // TODO close() failed? WalletManager.getInstance().close(wallet); // TODO close() failed?
wallet = null; wallet = null;
// TODO what do we do with the progress?? // TODO what do we do with the progress??

View File

@ -31,7 +31,6 @@ import android.graphics.drawable.Drawable;
import android.graphics.drawable.VectorDrawable; import android.graphics.drawable.VectorDrawable;
import android.os.Environment; import android.os.Environment;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
@ -48,10 +47,9 @@ import java.util.Locale;
import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.HttpsURLConnection;
import okhttp3.OkHttpClient; import timber.log.Timber;
public class Helper { public class Helper {
static private final String TAG = "Helper";
static private final String WALLET_DIR = "monerujo"; static private final String WALLET_DIR = "monerujo";
static public int DISPLAY_DIGITS_INFO = 5; static public int DISPLAY_DIGITS_INFO = 5;
@ -60,17 +58,17 @@ public class Helper {
static public File getStorageRoot(Context context) { static public File getStorageRoot(Context context) {
if (!isExternalStorageWritable()) { if (!isExternalStorageWritable()) {
String msg = context.getString(R.string.message_strorage_not_writable); String msg = context.getString(R.string.message_strorage_not_writable);
Log.e(TAG, msg); Timber.e(msg);
throw new IllegalStateException(msg); throw new IllegalStateException(msg);
} }
File dir = new File(Environment.getExternalStorageDirectory(), WALLET_DIR); File dir = new File(Environment.getExternalStorageDirectory(), WALLET_DIR);
if (!dir.exists()) { if (!dir.exists()) {
Log.i(TAG, "Creating " + dir.getAbsolutePath()); Timber.i("Creating %s", dir.getAbsolutePath());
dir.mkdirs(); // try to make it dir.mkdirs(); // try to make it
} }
if (!dir.isDirectory()) { if (!dir.isDirectory()) {
String msg = "Directory " + dir.getAbsolutePath() + " does not exist."; String msg = "Directory " + dir.getAbsolutePath() + " does not exist.";
Log.e(TAG, msg); Timber.e(msg);
throw new IllegalStateException(msg); throw new IllegalStateException(msg);
} }
return dir; return dir;
@ -82,7 +80,7 @@ public class Helper {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
if (context.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) if (context.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
== PackageManager.PERMISSION_DENIED) { == PackageManager.PERMISSION_DENIED) {
Log.w(TAG, "Permission denied to WRITE_EXTERNAL_STORAGE - requesting it"); Timber.w("Permission denied to WRITE_EXTERNAL_STORAGE - requesting it");
String[] permissions = {Manifest.permission.WRITE_EXTERNAL_STORAGE}; String[] permissions = {Manifest.permission.WRITE_EXTERNAL_STORAGE};
context.requestPermissions(permissions, PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE); context.requestPermissions(permissions, PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
return false; return false;
@ -100,7 +98,7 @@ public class Helper {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
if (context.checkSelfPermission(Manifest.permission.CAMERA) if (context.checkSelfPermission(Manifest.permission.CAMERA)
== PackageManager.PERMISSION_DENIED) { == PackageManager.PERMISSION_DENIED) {
Log.w(TAG, "Permission denied for CAMERA - requesting it"); Timber.w("Permission denied for CAMERA - requesting it");
String[] permissions = {Manifest.permission.CAMERA}; String[] permissions = {Manifest.permission.CAMERA};
context.requestPermissions(permissions, PERMISSIONS_REQUEST_CAMERA); context.requestPermissions(permissions, PERMISSIONS_REQUEST_CAMERA);
return false; return false;
@ -115,7 +113,7 @@ public class Helper {
static public File getWalletFile(Context context, String aWalletName) { static public File getWalletFile(Context context, String aWalletName) {
File walletDir = getStorageRoot(context); File walletDir = getStorageRoot(context);
File f = new File(walletDir, aWalletName); File f = new File(walletDir, aWalletName);
Log.d(TAG, "wallet = " + f.getAbsolutePath() + " size=" + f.length()); Timber.d("wallet= %s size= %d", f.getAbsolutePath(), f.length());
return f; return f;
} }
@ -224,11 +222,11 @@ public class Helper {
} }
return sb.toString(); return sb.toString();
} catch (SocketTimeoutException ex) { } catch (SocketTimeoutException ex) {
Log.w(TAG, "C " + ex.getLocalizedMessage()); Timber.w("C %s", ex.getLocalizedMessage());
} catch (MalformedURLException ex) { } catch (MalformedURLException ex) {
Log.e(TAG, "A " + ex.getLocalizedMessage()); Timber.e("A %s", ex.getLocalizedMessage());
} catch (IOException ex) { } catch (IOException ex) {
Log.e(TAG, "B " + ex.getLocalizedMessage()); Timber.e("B %s", ex.getLocalizedMessage());
} finally { } finally {
if (urlConnection != null) { if (urlConnection != null) {
urlConnection.disconnect(); urlConnection.disconnect();

View File

@ -21,7 +21,6 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
public class NodeList { public class NodeList {
static private final String TAG = "NodeList";
private static final int MAX_SIZE = 5; private static final int MAX_SIZE = 5;
private List<String> nodes = new ArrayList<>(); private List<String> nodes = new ArrayList<>();

View File

@ -93,6 +93,9 @@
<h3>OkHttp</h3> <h3>OkHttp</h3>
Copyright (c) 2014 Square, Inc. Copyright (c) 2014 Square, Inc.
<h3>Timber</h3>
Copyright (c) 2013 Jake Wharton
<h3>com.google.zxing:core</h3> <h3>com.google.zxing:core</h3>
Copyright (c) 2012 ZXing authors Copyright (c) 2012 ZXing authors

View File

@ -30,4 +30,5 @@ ext {
okHttpVersion = '3.9.0' okHttpVersion = '3.9.0'
junitVersion = '4.12' junitVersion = '4.12'
mockitoVersion = '1.10.19' mockitoVersion = '1.10.19'
timberVersion = '4.6.0'
} }