├── .gitignore ├── .idea ├── gradle.xml ├── misc.xml ├── modules.xml └── runConfigurations.xml ├── README.md ├── app ├── .gitignore ├── CMakeLists.txt ├── build.gradle ├── debug │ ├── app-debug.apk │ └── output.json ├── files │ └── keystore.jks ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── juzix │ │ └── com │ │ └── juwallet │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── cpp │ │ └── native-lib.cpp │ ├── java │ │ └── juzix │ │ │ └── com │ │ │ └── juwallet │ │ │ ├── AppFilePath.java │ │ │ ├── Constant.java │ │ │ ├── MainActivity.java │ │ │ ├── MyWalletUtil.java │ │ │ ├── app │ │ │ └── JuApplication.java │ │ │ ├── permission │ │ │ ├── PermisionsConstant.java │ │ │ ├── PermissionsManager.java │ │ │ └── PermissionsResultAction.java │ │ │ ├── qrcode │ │ │ ├── QrCodeEvent.java │ │ │ ├── QrcodeActivity.java │ │ │ └── QrcodeGen.java │ │ │ └── rx │ │ │ ├── BaseCallBack.java │ │ │ ├── BaseOberver.java │ │ │ ├── RxLogicHandler.java │ │ │ └── SimpleCallBack.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ └── activity_qrcode.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── juzix │ └── com │ └── juwallet │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 20 | 30 | 31 | 32 | 33 | 34 | 35 | 37 | 38 | 39 | 40 | 41 | 1.8 42 | 43 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ethwallet_java 2 | 基于以太坊区块链的轻钱包android客户端 3 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # For more information about using CMake with Android Studio, read the 2 | # documentation: https://d.android.com/studio/projects/add-native-code.html 3 | 4 | # Sets the minimum version of CMake required to build the native library. 5 | 6 | cmake_minimum_required(VERSION 3.4.1) 7 | 8 | # Creates and names a library, sets it as either STATIC 9 | # or SHARED, and provides the relative paths to its source code. 10 | # You can define multiple libraries, and CMake builds them for you. 11 | # Gradle automatically packages shared libraries with your APK. 12 | 13 | add_library( # Sets the name of the library. 14 | native-lib 15 | 16 | # Sets the library as a shared library. 17 | SHARED 18 | 19 | # Provides a relative path to your source file(s). 20 | src/main/cpp/native-lib.cpp ) 21 | 22 | # Searches for a specified prebuilt library and stores the path as a 23 | # variable. Because CMake includes system libraries in the search path by 24 | # default, you only need to specify the name of the public NDK library 25 | # you want to add. CMake verifies that the library exists before 26 | # completing its build. 27 | 28 | find_library( # Sets the name of the path variable. 29 | log-lib 30 | 31 | # Specifies the name of the NDK library that 32 | # you want CMake to locate. 33 | log ) 34 | 35 | # Specifies libraries CMake should link to your target library. You 36 | # can link multiple libraries, such as libraries you define in this 37 | # build script, prebuilt third-party libraries, or system libraries. 38 | 39 | target_link_libraries( # Specifies the target library. 40 | native-lib 41 | 42 | # Links the target library to the log library 43 | # included in the NDK. 44 | ${log-lib} ) -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 26 5 | defaultConfig { 6 | applicationId "juzix.com.juwallet" 7 | minSdkVersion 16 8 | targetSdkVersion 26 9 | versionCode 1 10 | multiDexEnabled true 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | externalNativeBuild { 14 | cmake { 15 | cppFlags "-std=c++11" 16 | } 17 | } 18 | } 19 | buildTypes { 20 | release { 21 | minifyEnabled false 22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 23 | } 24 | } 25 | externalNativeBuild { 26 | cmake { 27 | path "CMakeLists.txt" 28 | } 29 | } 30 | 31 | dexOptions { 32 | javaMaxHeapSize "6g" 33 | } 34 | lintOptions { 35 | checkReleaseBuilds false 36 | abortOnError false 37 | } 38 | } 39 | 40 | dependencies { 41 | implementation fileTree(dir: 'libs', include: ['*.jar']) 42 | implementation 'com.android.support:appcompat-v7:26.1.0' 43 | implementation 'com.android.support.constraint:constraint-layout:1.0.2' 44 | testImplementation 'junit:junit:4.12' 45 | androidTestImplementation 'com.android.support.test:runner:1.0.1' 46 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' 47 | implementation 'org.web3j:core:3.1.1-android' 48 | compile 'com.google.zxing:core:3.3.0' 49 | compile 'cn.bingoogolapple:bga-qrcodecore:1.1.7' 50 | compile 'cn.bingoogolapple:bga-zxing:1.1.7@aar' 51 | compile 'com.yanzhenjie:permission:1.0.8' 52 | compile 'com.android.support:multidex:1.0.1' 53 | compile 'io.reactivex.rxjava2:rxandroid:2.0.1' 54 | compile 'io.reactivex.rxjava2:rxjava:2.1.7' 55 | compile 'de.greenrobot:eventbus:2.4.0' 56 | compile 'com.zhouyou:rxeasyhttp:2.0.5' 57 | } 58 | -------------------------------------------------------------------------------- /app/debug/app-debug.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xime123/ethwallet_java/c3dc4ddecefdece08e5ffb55ca0577ee8272dc0a/app/debug/app-debug.apk -------------------------------------------------------------------------------- /app/debug/output.json: -------------------------------------------------------------------------------- 1 | [{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1},"path":"app-debug.apk","properties":{"packageId":"juzix.com.juwallet","split":"","minSdkVersion":"16"}}] -------------------------------------------------------------------------------- /app/files/keystore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xime123/ethwallet_java/c3dc4ddecefdece08e5ffb55ca0577ee8272dc0a/app/files/keystore.jks -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/juzix/com/juwallet/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package juzix.com.juwallet; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("juzix.com.juwallet", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/cpp/native-lib.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | extern "C" 5 | JNIEXPORT jstring 6 | 7 | JNICALL 8 | Java_juzix_com_juwallet_MainActivity_stringFromJNI( 9 | JNIEnv *env, 10 | jobject /* this */) { 11 | std::string hello = "Hello from C++"; 12 | return env->NewStringUTF(hello.c_str()); 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/java/juzix/com/juwallet/AppFilePath.java: -------------------------------------------------------------------------------- 1 | package juzix.com.juwallet; 2 | 3 | import android.content.Context; 4 | import android.os.Build; 5 | import android.os.Environment; 6 | import android.util.Log; 7 | 8 | import java.io.File; 9 | 10 | public class AppFilePath { 11 | 12 | 13 | public static String DATA_ROOT_DIR; // 数据文件根目录 14 | public static String DATA_ROOT_DIR_OUTER; // 外置卡中数据文件根目录(系统拍照等产生的文件,不允许存放到应用系统目录下) 15 | public static String CACHE_ROOT_DIR; // 缓存根目录 16 | public static String DB_ROOT_DIR; // 数据库根目录 17 | // 钱包文件外置存储目录 18 | public static String Wallet_DIR ; 19 | //walletTemp 20 | public static String Wallet_Tmp_DIR ; 21 | // 相片外置存储目录 22 | public static String picture ; 23 | public static void init(Context context) { 24 | 25 | final boolean innerFirst = false; 26 | // 优先使用app系统目录,即/data/data/com.pagoda.xxx/ 27 | if (innerFirst) { 28 | CACHE_ROOT_DIR = context.getCacheDir().getPath(); 29 | DATA_ROOT_DIR = context.getFilesDir().getPath(); 30 | DB_ROOT_DIR = context.getFilesDir().getParent(); 31 | 32 | String outerPath = getExternalFilesDir(context).getPath(); 33 | DATA_ROOT_DIR_OUTER = outerPath; 34 | 35 | 36 | } else { 37 | if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) 38 | || !Environment.isExternalStorageRemovable()) { 39 | CACHE_ROOT_DIR = getExternalCacheDir(context).getPath(); 40 | DATA_ROOT_DIR = getExternalFilesDir(context).getPath(); 41 | DATA_ROOT_DIR_OUTER = DATA_ROOT_DIR; 42 | DB_ROOT_DIR = DATA_ROOT_DIR; 43 | } else { 44 | CACHE_ROOT_DIR = context.getCacheDir().getPath(); 45 | DATA_ROOT_DIR = context.getFilesDir().getPath(); 46 | DB_ROOT_DIR = context.getFilesDir().getParent(); 47 | DATA_ROOT_DIR_OUTER = DATA_ROOT_DIR; 48 | } 49 | } 50 | Wallet_DIR= getExternalPrivatePath("juethwallet"); 51 | Wallet_Tmp_DIR=getExternalPrivatePath("wallettmp"); 52 | picture= getExternalPrivatePath("picture"); 53 | Log.d("Ville", "DataPath = [" + DATA_ROOT_DIR + "] \n" + 54 | "DBPath = [" + DB_ROOT_DIR + "] \n" + 55 | "DataPathOuter = [" + DATA_ROOT_DIR_OUTER + "]"); 56 | 57 | } 58 | 59 | /** 60 | * 这种目录下的文件在应用被卸载时也会跟着被删除 61 | * @param context 62 | * @return 63 | */ 64 | public static File getExternalFilesDir(Context context) { 65 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) { 66 | File path = context.getExternalFilesDir(null); 67 | 68 | if (path != null) { 69 | return path; 70 | } 71 | } 72 | final String filesDir = "/Android/data/" + context.getPackageName() + "/files/"; 73 | return new File(Environment.getExternalStorageDirectory().getPath() + filesDir); 74 | } 75 | /** 76 | * 这种目录下的文件在应用被卸载时也会跟着被删除 77 | * @param context 78 | * @return 79 | */ 80 | public static File getExternalCacheDir(Context context) { 81 | 82 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) { 83 | File path = context.getExternalCacheDir(); 84 | 85 | if (path != null) { 86 | return path; 87 | } 88 | } 89 | final String cacheDir = "/Android/data/" + context.getPackageName() + "/cache/"; 90 | return new File(Environment.getExternalStorageDirectory().getPath() + cacheDir); 91 | } 92 | 93 | 94 | /** 95 | * 这种目录下的文件在应用被卸载时不会被删除 96 | * 钱包等数据可以存放到这里 97 | * 98 | * @return 99 | */ 100 | public static String getExternalPrivatePath(String name) { 101 | String namedir = "/"+name+"/"; 102 | if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) 103 | || !Environment.isExternalStorageRemovable()) { 104 | 105 | return Environment.getExternalStorageDirectory().getPath() + namedir; 106 | } else { 107 | return new File(DATA_ROOT_DIR_OUTER, name).getPath(); 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /app/src/main/java/juzix/com/juwallet/Constant.java: -------------------------------------------------------------------------------- 1 | package juzix.com.juwallet; 2 | 3 | /** 4 | * Created by 徐敏 on 2018/1/3. 5 | */ 6 | 7 | public class Constant { 8 | public static final String WEB_URL="http://192.168.9.79:6795"; 9 | public static final String PASSWORD="111111"; 10 | public static final String WALLET_FILE_NAME="ju_wallet.json"; 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/java/juzix/com/juwallet/MainActivity.java: -------------------------------------------------------------------------------- 1 | package juzix.com.juwallet; 2 | 3 | import android.app.Dialog; 4 | import android.app.ProgressDialog; 5 | import android.content.Intent; 6 | import android.os.Bundle; 7 | import android.support.v7.app.AppCompatActivity; 8 | import android.text.TextUtils; 9 | import android.view.View; 10 | import android.widget.ImageView; 11 | import android.widget.TextView; 12 | import android.widget.Toast; 13 | 14 | import com.zhouyou.http.EasyHttp; 15 | import com.zhouyou.http.callback.CallBack; 16 | import com.zhouyou.http.exception.ApiException; 17 | 18 | import org.web3j.crypto.Credentials; 19 | import org.web3j.crypto.WalletUtils; 20 | import org.web3j.protocol.Web3j; 21 | import org.web3j.protocol.Web3jFactory; 22 | import org.web3j.protocol.core.DefaultBlockParameter; 23 | import org.web3j.protocol.core.methods.response.EthGetBalance; 24 | import org.web3j.protocol.core.methods.response.EthGetTransactionReceipt; 25 | import org.web3j.protocol.core.methods.response.TransactionReceipt; 26 | import org.web3j.protocol.http.HttpService; 27 | import org.web3j.tx.Transfer; 28 | import org.web3j.utils.Convert; 29 | 30 | import java.math.BigDecimal; 31 | import java.math.BigInteger; 32 | 33 | import de.greenrobot.event.EventBus; 34 | import io.reactivex.Observable; 35 | import io.reactivex.ObservableEmitter; 36 | import io.reactivex.ObservableOnSubscribe; 37 | import io.reactivex.Observer; 38 | import io.reactivex.android.schedulers.AndroidSchedulers; 39 | import io.reactivex.disposables.Disposable; 40 | import io.reactivex.schedulers.Schedulers; 41 | import juzix.com.juwallet.permission.PermisionsConstant; 42 | import juzix.com.juwallet.permission.PermissionsManager; 43 | import juzix.com.juwallet.permission.PermissionsResultAction; 44 | import juzix.com.juwallet.qrcode.QrCodeEvent; 45 | import juzix.com.juwallet.qrcode.QrcodeActivity; 46 | import juzix.com.juwallet.qrcode.QrcodeGen; 47 | import juzix.com.juwallet.rx.RxLogicHandler; 48 | import juzix.com.juwallet.rx.SimpleCallBack; 49 | 50 | 51 | public class MainActivity extends AppCompatActivity { 52 | 53 | private Credentials credentials; 54 | private String fromAddress; 55 | private String toAddress; 56 | private ImageView qrcodeIv; 57 | private TextView infoTv,errorTv; 58 | private Dialog dialog; 59 | @Override 60 | protected void onCreate(Bundle savedInstanceState) { 61 | super.onCreate(savedInstanceState); 62 | setContentView(R.layout.activity_main); 63 | EventBus.getDefault().register(this); 64 | qrcodeIv=findViewById(R.id.qrcode_iv); 65 | infoTv=findViewById(R.id.wallet_info_tv); 66 | errorTv=findViewById(R.id.error_info_tv); 67 | init(); 68 | } 69 | 70 | @Override 71 | protected void onDestroy() { 72 | super.onDestroy(); 73 | EventBus.getDefault().unregister(this); 74 | } 75 | 76 | private void init(){ 77 | loadWalletFile(); 78 | if(!TextUtils.isEmpty(this.getFromAddress())){ 79 | qrcodeIv.setImageBitmap(QrcodeGen.genQrcodeBitmap(150,this.getFromAddress())); 80 | } 81 | } 82 | 83 | /** 84 | * 扫码转账 85 | * @param view 86 | */ 87 | public void send(View view) { 88 | Intent intent=new Intent(this, QrcodeActivity.class); 89 | startActivity(intent); 90 | } 91 | 92 | /** 93 | * 加载钱包 94 | * @param view 95 | */ 96 | public void loadWallet(View view) { 97 | RxLogicHandler.doWork(new GetBalanceExcutor(),new GetBalanceCallBack()); 98 | } 99 | 100 | /** 101 | * 查询账户余额 102 | */ 103 | class GetBalanceExcutor implements RxLogicHandler.Excutor{ 104 | 105 | @Override 106 | public String excute() throws Exception { 107 | Web3j web3j = Web3jFactory.build(new HttpService(Constant.WEB_URL)); // defaults to http://localhost:8545/ 108 | EthGetBalance ethGetBalance= web3j.ethGetBalance(getFromAddress(), new DefaultBlockParameter() { 109 | @Override 110 | public String getValue() { 111 | return "latest"; 112 | } 113 | }).sendAsync().get(); 114 | BigInteger bigInteger=ethGetBalance.getBalance(); 115 | return bigInteger+""; 116 | } 117 | } 118 | 119 | /** 120 | * 查询账户余额回调处理 121 | */ 122 | class GetBalanceCallBack extends SimpleCallBack{ 123 | 124 | @Override 125 | protected void onSuccess(String s) { 126 | showInfoSafe(s); 127 | } 128 | 129 | @Override 130 | protected void onFailed(Throwable e) { 131 | showErrorInfoSafe("查询余额失败:"+e.getMessage() +" "+e.getCause()); 132 | } 133 | } 134 | 135 | /** 136 | * 创建钱包 137 | * @param view 138 | */ 139 | public void createWallet(View view) { 140 | Credentials credentials= MyWalletUtil.createWallet(); 141 | if(credentials==null){ 142 | showSafeToast("创建钱包失败!"); 143 | return; 144 | } 145 | this.setCredentials(credentials); 146 | this.setFromAddress(credentials.getAddress()); 147 | if(!TextUtils.isEmpty(this.getFromAddress())){ 148 | qrcodeIv.setImageBitmap(QrcodeGen.genQrcodeBitmap(150,this.getFromAddress())); 149 | } 150 | } 151 | 152 | 153 | 154 | /** 155 | * 转账 156 | */ 157 | private void sendTransaction(){ 158 | 159 | Observable.create(new ObservableOnSubscribe() { 160 | @Override 161 | public void subscribe(ObservableEmitter e) throws Exception { 162 | Web3j web3j = Web3jFactory.build(new HttpService(Constant.WEB_URL)); // defaults to http://localhost:8545/ 163 | TransactionReceipt transactionReceipt = Transfer.sendFunds(web3j, credentials, getToAddress(), BigDecimal.valueOf(1.0), Convert.Unit.ETHER).send(); 164 | 165 | String hash=transactionReceipt.getTransactionHash(); 166 | EthGetTransactionReceipt ethGetTransactionReceipt = 167 | web3j.ethGetTransactionReceipt(hash).sendAsync().get(); 168 | String info="hash="+hash+" \nvalue="+BigDecimal.valueOf(1.0)+"\ntoAddress="+getToAddress()+"\nformAddress="+getFromAddress(); 169 | e.onNext(info); 170 | e.onComplete(); 171 | } 172 | }).subscribeOn(Schedulers.io()) 173 | .observeOn(AndroidSchedulers.mainThread()) 174 | .subscribe(new Observer() { 175 | @Override 176 | public void onSubscribe(Disposable d) { 177 | showDialog("正在交易..."); 178 | } 179 | 180 | @Override 181 | public void onNext(String s) { 182 | showErrorInfoSafe(s); 183 | } 184 | 185 | @Override 186 | public void onError(Throwable e) { 187 | showErrorInfoSafe("交易失败:"+e.getMessage()+" cause="+e.getCause()); 188 | } 189 | 190 | @Override 191 | public void onComplete() { 192 | dismissDialog(); 193 | } 194 | }); 195 | 196 | } 197 | 198 | public String getFromAddress() { 199 | return fromAddress; 200 | } 201 | 202 | public void setFromAddress(String fromAddress) { 203 | this.fromAddress = fromAddress; 204 | } 205 | 206 | public String getToAddress() { 207 | return toAddress; 208 | } 209 | 210 | public void setToAddress(String toAddress) { 211 | this.toAddress = toAddress; 212 | } 213 | 214 | public Credentials getCredentials() { 215 | return credentials; 216 | } 217 | 218 | public void setCredentials(Credentials credentials) { 219 | this.credentials = credentials; 220 | } 221 | 222 | private void showSafeToast(final String msg){ 223 | runOnUiThread(new Runnable() { 224 | @Override 225 | public void run() { 226 | Toast.makeText(MainActivity.this,msg,Toast.LENGTH_LONG).show(); 227 | } 228 | }); 229 | } 230 | 231 | private void showErrorInfoSafe(final String msg){ 232 | runOnUiThread(new Runnable() { 233 | @Override 234 | public void run() { 235 | errorTv.setText(msg); 236 | } 237 | }); 238 | } 239 | /** 240 | * 收到对端钱包地址 开始转账 241 | * @param event 242 | */ 243 | public void onEventMainThread(QrCodeEvent event) { 244 | String addres=event.getResult(); 245 | this.setToAddress(addres); 246 | sendTransaction(); 247 | 248 | } 249 | 250 | 251 | private void loadWalletFile(){ 252 | PermissionsManager.getInstance().requestPermissionsIfNecessaryForResult(this, new String[]{PermisionsConstant.WRITE_EXTERNAL_STORAGE, PermisionsConstant.READ_EXTERNAL_STORAGE,PermisionsConstant.CAMERA}, new PermissionsResultAction() { 253 | @Override 254 | public void onGranted() { 255 | try { 256 | String source=AppFilePath.Wallet_DIR+Constant.WALLET_FILE_NAME; 257 | Credentials credentials = WalletUtils.loadCredentials(Constant.PASSWORD, source); 258 | MainActivity.this.setFromAddress(credentials.getAddress()); 259 | MainActivity.this.setCredentials(credentials); 260 | 261 | }catch (Exception e){ 262 | e.printStackTrace(); 263 | Toast.makeText(MainActivity.this,"加载钱包失败",Toast.LENGTH_LONG).show(); 264 | } 265 | } 266 | 267 | @Override 268 | public void onDenied(String permission) { 269 | finish(); 270 | } 271 | }); 272 | } 273 | 274 | private void showInfoSafe(final String value){ 275 | String info="钱包地址:"+getFromAddress()+"\n"+"钱包余额:"+value; 276 | 277 | infoTv.setText(info); 278 | } 279 | 280 | private void showDialog(String msg){ 281 | if(dialog==null) { 282 | dialog = new ProgressDialog(this); 283 | } 284 | dialog.show(); 285 | } 286 | 287 | private void dismissDialog(){ 288 | if(dialog!=null&&dialog.isShowing()){ 289 | dialog.dismiss(); 290 | } 291 | } 292 | 293 | /** 294 | * 测试查询交易记录 295 | * @param view 296 | */ 297 | public void testHis(View view) { 298 | EasyHttp.getInstance().setCertificates(); 299 | EasyHttp.get("/address/0x2de128a62cadc32097b5719807c16db2024a08da") 300 | .baseUrl("https://etherscan.io") 301 | .execute(new CallBack() { 302 | @Override 303 | public void onStart() { 304 | 305 | } 306 | 307 | @Override 308 | public void onCompleted() { 309 | 310 | } 311 | 312 | @Override 313 | public void onError(ApiException e) { 314 | 315 | } 316 | 317 | @Override 318 | public void onSuccess(String o) { 319 | 320 | } 321 | }); 322 | } 323 | } 324 | -------------------------------------------------------------------------------- /app/src/main/java/juzix/com/juwallet/MyWalletUtil.java: -------------------------------------------------------------------------------- 1 | package juzix.com.juwallet; 2 | 3 | import com.fasterxml.jackson.databind.ObjectMapper; 4 | 5 | import org.web3j.crypto.Credentials; 6 | import org.web3j.crypto.ECKeyPair; 7 | import org.web3j.crypto.Keys; 8 | import org.web3j.crypto.Wallet; 9 | import org.web3j.crypto.WalletFile; 10 | import org.web3j.protocol.ObjectMapperFactory; 11 | 12 | import java.io.File; 13 | import java.io.IOException; 14 | 15 | /** 16 | * Created by 徐敏 on 2018/1/3. 17 | */ 18 | 19 | public class MyWalletUtil { 20 | static ObjectMapper objectMapper = ObjectMapperFactory.getObjectMapper(); 21 | public static Credentials createWallet(){ 22 | ECKeyPair ecKeyPair = null; 23 | WalletFile walletFile = null; 24 | try { 25 | ecKeyPair = Keys.createEcKeyPair(); 26 | walletFile = Wallet.create(Constant.PASSWORD, ecKeyPair, 16, 1); // WalletUtils. .generateNewWalletFile(); 27 | } catch (Exception e) { 28 | e.printStackTrace(); 29 | return null; 30 | } 31 | 32 | 33 | 34 | File destination = new File(AppFilePath.Wallet_DIR, Constant.WALLET_FILE_NAME); 35 | 36 | //目录不存在则创建目录,创建不了则报错 37 | if (!createParentDir(destination)) { 38 | return null; 39 | } 40 | try { 41 | objectMapper.writeValue(destination, walletFile); 42 | } catch (IOException e) { 43 | e.printStackTrace(); 44 | return null; 45 | } 46 | 47 | return Credentials.create(ecKeyPair); 48 | } 49 | 50 | private static boolean createParentDir(File file) { 51 | //判断目标文件所在的目录是否存在 52 | if (!file.getParentFile().exists()) { 53 | //如果目标文件所在的目录不存在,则创建父目录 54 | System.out.println("目标文件所在目录不存在,准备创建"); 55 | if (!file.getParentFile().mkdirs()) { 56 | System.out.println("创建目标文件所在目录失败!"); 57 | return false; 58 | } 59 | } 60 | return true; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /app/src/main/java/juzix/com/juwallet/app/JuApplication.java: -------------------------------------------------------------------------------- 1 | package juzix.com.juwallet.app; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | import android.support.multidex.MultiDex; 6 | 7 | import com.zhouyou.http.EasyHttp; 8 | 9 | import juzix.com.juwallet.AppFilePath; 10 | 11 | /** 12 | * Created by 徐敏 on 2018/1/3. 13 | */ 14 | 15 | public class JuApplication extends Application { 16 | @Override 17 | public void onCreate() { 18 | super.onCreate(); 19 | AppFilePath.init(this); 20 | EasyHttp.init(this);//默认初始化 21 | } 22 | @Override 23 | public void attachBaseContext(Context base) { 24 | MultiDex.install(base); 25 | super.attachBaseContext(base); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/juzix/com/juwallet/permission/PermisionsConstant.java: -------------------------------------------------------------------------------- 1 | package juzix.com.juwallet.permission; 2 | 3 | import android.Manifest; 4 | 5 | /** 6 | * Created by soffice_user on 2015/9/6. 7 | */ 8 | public class PermisionsConstant { 9 | //permission 10 | //存储空间 11 | public static final String WRITE_EXTERNAL_STORAGE = Manifest.permission.WRITE_EXTERNAL_STORAGE; 12 | public static final String READ_EXTERNAL_STORAGE = Manifest.permission.READ_EXTERNAL_STORAGE; 13 | //通讯录 14 | public static final String READ_CONTACTS = "android.permission.READ_CONTACTS"; 15 | 16 | //摄像机 17 | public static final String CAMERA = "android.permission.CAMERA"; 18 | 19 | //日历 20 | public static final String READ_CALENDAR = "android.permission.READ_CALENDAR"; 21 | public static final String WRITE_CALENDAR = "android.permission.WRITE_CALENDAR"; 22 | //电话 23 | public static final String CALL_PHONE = "android.pefsdrmission.CALL_PHONE"; 24 | public static final String READ_PHONE_STATE = "android.pefsdrmission.CALL_PHONE"; 25 | public static final String READ_CALL_LOG = "android.pefsdrmission.CALL_PHONE"; 26 | public static final String WRITE_CALL_LOG = "android.pefsdrmission.CALL_PHONE"; 27 | public static final String ADD_VOICEMAIL = "android.pefsdrmission.CALL_PHONE"; 28 | public static final String USE_SIP = "android.pefsdrmission.CALL_PHONE"; 29 | public static final String PROCESS_OUTGOING_CALLS = "android.pefsdrmission.CALL_PHONE"; 30 | 31 | //地理位置 32 | public static final String ACCESS_COARSE_LOCATION = "android.permission.ACCESS_COARSE_LOCATION"; 33 | public static final String ACCESS_FIND_LOCATION = "android.permission.ACCESS_COARSE_LOCATION"; 34 | 35 | //麦克风 36 | public static final String READ_AUDIO = "android.permission.READ_AUDIO"; 37 | 38 | //传感器 39 | public static final String BODY_SENSORS = "android.permission.BODY_SENSORS"; 40 | 41 | 42 | //短信 43 | public static final String SEND_SMS = "android.permission.SEND_SMS"; 44 | public static final String RECEIVE_SMS = "android.permission.RECEIVE_SMS"; 45 | public static final String READ_SMS = "android.permission.READ_SMS"; 46 | public static final String RECEIVE_WAP_PUSH = "android.permission.RECEIVE_WAP_PUSH"; 47 | public static final String RECEIVE_MMS = "android.permission.RECEIVE_MMS"; 48 | public static final String READ_CELL_BROADCASTS = "android.permission.READ_CELL_BROADCASTS"; 49 | 50 | //蓝牙 51 | public static final String BLUETOOTH_ADMIN="android.permission.BLUETOOTH_ADMIN"; 52 | public static final String FIND_LOCATION="android.permission.ACCESS_FINE_LOCATION"; 53 | } 54 | -------------------------------------------------------------------------------- /app/src/main/java/juzix/com/juwallet/permission/PermissionsManager.java: -------------------------------------------------------------------------------- 1 | package juzix.com.juwallet.permission; 2 | 3 | import android.app.Activity; 4 | import android.content.DialogInterface; 5 | import android.support.annotation.NonNull; 6 | 7 | import com.yanzhenjie.alertdialog.AlertDialog; 8 | import com.yanzhenjie.permission.AndPermission; 9 | import com.yanzhenjie.permission.PermissionListener; 10 | import com.yanzhenjie.permission.Rationale; 11 | import com.yanzhenjie.permission.RationaleListener; 12 | import com.yanzhenjie.permission.RationaleRequest; 13 | 14 | import java.util.List; 15 | 16 | 17 | /** 18 | * Created by 徐敏 on 2017/8/19. 19 | */ 20 | 21 | public class PermissionsManager { 22 | 23 | private final static PermissionsManager instance=new PermissionsManager(); 24 | private PermissionsManager(){} 25 | public static PermissionsManager getInstance(){ 26 | return instance; 27 | } 28 | 29 | public void requestPermissionsIfNecessaryForResult(final Activity activity, String[]permissions, final PermissionsResultAction action){ 30 | RationaleRequest request = AndPermission.with(activity); 31 | // request.requestCode(100); 32 | request.permission(permissions); 33 | request.callback(new PermissionListener() { 34 | @Override 35 | public void onSucceed(int requestCode, @NonNull List grantPermissions) { 36 | if (action != null) { 37 | action.onGranted(); 38 | } 39 | } 40 | 41 | @Override 42 | public void onFailed(int requestCode, @NonNull List deniedPermissions) { 43 | // 用户否勾选了不再提示并且拒绝了权限,那么提示用户到设置中授权。 44 | if (AndPermission.hasAlwaysDeniedPermission(activity, deniedPermissions)) { 45 | AndPermission.defaultSettingDialog(activity, 0) 46 | .setTitle("权限申请失败") 47 | .setMessage("我们需要的一些权限申请失败,请您到设置页面手动授权,否则功能无法正常使用!") 48 | .setPositiveButton("设置") 49 | .show(); 50 | } else { 51 | if (action != null) { 52 | action.onDenied("permission denied"); 53 | } 54 | } 55 | } 56 | }); 57 | request.rationale(new RationaleListener() { 58 | @Override 59 | public void showRequestPermissionRationale(int requestCode, final Rationale rationale) { 60 | // 自定义对话框。 61 | AlertDialog.newBuilder(activity) 62 | .setTitle("授权已被拒绝") 63 | .setMessage("您已经拒绝过授权此权限,没有此权限功能无法正常使用,赶快授权此权限给我们!") 64 | .setPositiveButton("授权", new DialogInterface.OnClickListener() { 65 | @Override 66 | public void onClick(DialogInterface dialog, int which) { 67 | dialog.cancel(); 68 | rationale.resume(); 69 | } 70 | }) 71 | .setNegativeButton("拒绝", new DialogInterface.OnClickListener() { 72 | @Override 73 | public void onClick(DialogInterface dialog, int which) { 74 | dialog.cancel(); 75 | rationale.cancel(); 76 | } 77 | }).show(); 78 | } 79 | }); 80 | request.start(); 81 | 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /app/src/main/java/juzix/com/juwallet/permission/PermissionsResultAction.java: -------------------------------------------------------------------------------- 1 | package juzix.com.juwallet.permission; 2 | 3 | /** 4 | * Created by 徐敏 on 2017/8/19. 5 | */ 6 | 7 | public interface PermissionsResultAction { 8 | void onGranted(); 9 | void onDenied(String permission); 10 | } 11 | -------------------------------------------------------------------------------- /app/src/main/java/juzix/com/juwallet/qrcode/QrCodeEvent.java: -------------------------------------------------------------------------------- 1 | package juzix.com.juwallet.qrcode; 2 | 3 | /** 4 | * Created by 徐敏 on 2018/1/3. 5 | */ 6 | 7 | public class QrCodeEvent { 8 | private String result; 9 | 10 | public QrCodeEvent(String result) { 11 | this.result = result; 12 | } 13 | 14 | public String getResult() { 15 | return result; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/java/juzix/com/juwallet/qrcode/QrcodeActivity.java: -------------------------------------------------------------------------------- 1 | package juzix.com.juwallet.qrcode; 2 | 3 | import android.os.Bundle; 4 | import android.os.Vibrator; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.util.Log; 7 | import android.widget.Toast; 8 | 9 | import cn.bingoogolapple.qrcode.core.QRCodeView; 10 | import cn.bingoogolapple.qrcode.zxing.ZXingView; 11 | import de.greenrobot.event.EventBus; 12 | import juzix.com.juwallet.R; 13 | 14 | public class QrcodeActivity extends AppCompatActivity implements QRCodeView.Delegate{ 15 | private ZXingView mQRCodeView; 16 | private String TAG="QrcodeTestActivity"; 17 | @Override 18 | protected void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | setContentView(R.layout.activity_qrcode); 21 | mQRCodeView=(ZXingView)findViewById(R.id.zxingview); 22 | mQRCodeView.setDelegate(this); 23 | } 24 | 25 | 26 | @Override 27 | public void onScanQRCodeSuccess(String result) { 28 | Log.i(TAG, "result:" + result); 29 | // Toast.makeText(this, result, Toast.LENGTH_SHORT).show(); 30 | vibrate(); 31 | mQRCodeView.startSpot(); 32 | EventBus.getDefault().post(new QrCodeEvent(result)); 33 | finish(); 34 | } 35 | 36 | 37 | @Override 38 | protected void onStart() { 39 | super.onStart(); 40 | mQRCodeView.startCamera(); 41 | // mQRCodeView.startCamera(Camera.CameraInfo.CAMERA_FACING_FRONT); 42 | 43 | mQRCodeView.showScanRect(); 44 | } 45 | 46 | @Override 47 | protected void onResume() { 48 | super.onResume(); 49 | mQRCodeView.startSpot(); 50 | } 51 | 52 | @Override 53 | protected void onStop() { 54 | mQRCodeView.stopCamera(); 55 | super.onStop(); 56 | } 57 | 58 | @Override 59 | protected void onDestroy() { 60 | mQRCodeView.onDestroy(); 61 | super.onDestroy(); 62 | } 63 | @Override 64 | public void onScanQRCodeOpenCameraError() { 65 | Log.e(TAG, "打开相机出错"); 66 | Toast.makeText(this, "打开相机出错",Toast.LENGTH_LONG).show(); 67 | } 68 | 69 | private void vibrate() { 70 | Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE); 71 | vibrator.vibrate(200); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /app/src/main/java/juzix/com/juwallet/qrcode/QrcodeGen.java: -------------------------------------------------------------------------------- 1 | package juzix.com.juwallet.qrcode; 2 | 3 | import android.graphics.Bitmap; 4 | 5 | import cn.bingoogolapple.qrcode.zxing.QRCodeEncoder; 6 | 7 | /** 8 | * Created by 徐敏 on 2017/8/29. 9 | */ 10 | 11 | public class QrcodeGen { 12 | public static Bitmap genQrcodeBitmap(int dpWidth, String content){ 13 | Bitmap bitmap= QRCodeEncoder.syncEncodeQRCode(content, dpWidth); 14 | // String base64Bmp= BitmapUtil.encode2Base64ByBitmap(bitmap); 15 | return bitmap; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/java/juzix/com/juwallet/rx/BaseCallBack.java: -------------------------------------------------------------------------------- 1 | package juzix.com.juwallet.rx; 2 | 3 | /** 4 | * Created by 徐敏 on 2018/1/5. 5 | */ 6 | 7 | public abstract class BaseCallBack { 8 | protected abstract void onStart(); 9 | protected abstract void onSuccess(T t); 10 | protected abstract void onFailed(Throwable e); 11 | protected abstract void onCompleted(); 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/juzix/com/juwallet/rx/BaseOberver.java: -------------------------------------------------------------------------------- 1 | package juzix.com.juwallet.rx; 2 | 3 | import io.reactivex.Observer; 4 | import io.reactivex.disposables.Disposable; 5 | 6 | /** 7 | * Created by 徐敏 on 2018/1/5. 8 | */ 9 | 10 | public class BaseOberver implements Observer { 11 | protected BaseCallBack callBack; 12 | private Disposable disposable; 13 | public BaseOberver(BaseCallBack callBack) { 14 | this.callBack = callBack; 15 | } 16 | 17 | 18 | @Override 19 | public void onSubscribe(Disposable d) { 20 | this.disposable=d; 21 | callBack.onStart(); 22 | //如果是网络请求的 可以在这里做网络判断,如果网络没有连接 直接走onComplete或者onError 23 | } 24 | 25 | @Override 26 | public void onNext(T response) { 27 | callBack.onSuccess(response); 28 | } 29 | 30 | @Override 31 | public void onError(Throwable e) { 32 | //这里可以用ApiException代替,callBack.onFailed(ApiException e),ApiException处理这个异常。 33 | callBack.onFailed(e); 34 | //取消订阅 35 | if(disposable!=null&&!disposable.isDisposed()){ 36 | disposable.dispose(); 37 | } 38 | } 39 | 40 | @Override 41 | public void onComplete() { 42 | callBack.onCompleted(); 43 | if(disposable!=null&&!disposable.isDisposed()){ 44 | disposable.dispose(); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/src/main/java/juzix/com/juwallet/rx/RxLogicHandler.java: -------------------------------------------------------------------------------- 1 | package juzix.com.juwallet.rx; 2 | 3 | import io.reactivex.Observable; 4 | import io.reactivex.ObservableEmitter; 5 | import io.reactivex.ObservableOnSubscribe; 6 | 7 | /** 8 | * Created by 徐敏 on 2018/1/5. 9 | */ 10 | 11 | public class RxLogicHandler { 12 | public static void doWork(final Excutor excutor,BaseCallBack callBack){ 13 | Observable.create(new ObservableOnSubscribe() { 14 | @Override 15 | public void subscribe(ObservableEmitter e) throws Exception { 16 | T t=(T)excutor.excute(); 17 | e.onNext(t); 18 | e.onComplete(); 19 | } 20 | }).subscribe(new BaseOberver(callBack)); 21 | } 22 | 23 | public interface Excutor{ 24 | Result excute()throws Exception; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/juzix/com/juwallet/rx/SimpleCallBack.java: -------------------------------------------------------------------------------- 1 | package juzix.com.juwallet.rx; 2 | 3 | /** 4 | * Created by 徐敏 on 2018/1/5. 5 | * 只关心成功和失败的回调 6 | */ 7 | 8 | public abstract class SimpleCallBack extends BaseCallBack { 9 | @Override 10 | protected void onStart() { 11 | 12 | } 13 | 14 | @Override 15 | protected void onCompleted() { 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 11 | 16 | 21 | 26 | 31 | 36 | 41 | 46 | 51 | 56 | 61 | 66 | 71 | 76 | 81 | 86 | 91 | 96 | 101 | 106 | 111 | 116 | 121 | 126 | 131 | 136 | 141 | 146 | 151 | 156 | 161 | 166 | 171 | 172 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 14 | 17 | 26 | 36 | 37 | 38 | 39 | 52 | 63 | 68 | 78 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_qrcode.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xime123/ethwallet_java/c3dc4ddecefdece08e5ffb55ca0577ee8272dc0a/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xime123/ethwallet_java/c3dc4ddecefdece08e5ffb55ca0577ee8272dc0a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xime123/ethwallet_java/c3dc4ddecefdece08e5ffb55ca0577ee8272dc0a/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xime123/ethwallet_java/c3dc4ddecefdece08e5ffb55ca0577ee8272dc0a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xime123/ethwallet_java/c3dc4ddecefdece08e5ffb55ca0577ee8272dc0a/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xime123/ethwallet_java/c3dc4ddecefdece08e5ffb55ca0577ee8272dc0a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xime123/ethwallet_java/c3dc4ddecefdece08e5ffb55ca0577ee8272dc0a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xime123/ethwallet_java/c3dc4ddecefdece08e5ffb55ca0577ee8272dc0a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xime123/ethwallet_java/c3dc4ddecefdece08e5ffb55ca0577ee8272dc0a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xime123/ethwallet_java/c3dc4ddecefdece08e5ffb55ca0577ee8272dc0a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | juwallet 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/juzix/com/juwallet/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package juzix.com.juwallet; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | 5 | repositories { 6 | google() 7 | jcenter() 8 | } 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:3.0.1' 11 | 12 | 13 | // NOTE: Do not place your application dependencies here; they belong 14 | // in the individual module build.gradle files 15 | } 16 | } 17 | 18 | allprojects { 19 | repositories { 20 | google() 21 | jcenter() 22 | } 23 | } 24 | 25 | task clean(type: Delete) { 26 | delete rootProject.buildDir 27 | } 28 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | android.enableAapt2=false -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xime123/ethwallet_java/c3dc4ddecefdece08e5ffb55ca0577ee8272dc0a/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Jan 03 10:48:47 CST 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------