diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index fb7f4a8..b589d56 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
new file mode 100644
index 0000000..7e340a7
--- /dev/null
+++ b/.idea/kotlinc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 58035e4..91219a1 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -7,7 +7,7 @@
-
+
diff --git a/app/src/main/java/io/arcblock/did_motif/MainActivity.kt b/app/src/main/java/io/arcblock/did_motif/MainActivity.kt
index f5183be..89a5bac 100644
--- a/app/src/main/java/io/arcblock/did_motif/MainActivity.kt
+++ b/app/src/main/java/io/arcblock/did_motif/MainActivity.kt
@@ -36,6 +36,7 @@ class MainActivity : AppCompatActivity() {
}
}
binding.identiconRg.check(5)
-
+ val color = DIDMotif.calculateColorOfAddress(address)
+ binding.bgColor.setBackgroundColor(color)
}
}
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 0778100..17303e7 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -92,5 +92,9 @@
android:text="Square"
/>
+
\ No newline at end of file
diff --git a/did-motif/build.gradle b/did-motif/build.gradle
index 522c37e..1a94d68 100644
--- a/did-motif/build.gradle
+++ b/did-motif/build.gradle
@@ -53,7 +53,16 @@ android {
}
dependencies {
- api 'io.arcblock.walletkit:walletkit:0.5.18'
+// api 'io.arcblock.walletkit:walletkit:0.5.18'
+ api('org.bitcoinj:bitcoinj-core:0.16.1') {
+ exclude group: 'com.google.protobuf'
+ exclude group: 'org.bouncycastle'
+ }
+ api('org.web3j:core:4.6.0-android')
+ api('io.arcblock.did:wallet-sdk:1.0.10') {
+ exclude group: 'org.web3j'
+ exclude group: 'org.bouncycastle'
+ }
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
@@ -102,8 +111,6 @@ publishing {
developers {
developer {
id = 'ArcBlock'
- name = 'ArcBlock'
- email = 'app@arcblock.io'
}
}
scm {
diff --git a/did-motif/src/main/java/io/arcblock/did_motif/didmotif/DIDMotif.kt b/did-motif/src/main/java/io/arcblock/did_motif/didmotif/DIDMotif.kt
index deb73ed..8026e33 100644
--- a/did-motif/src/main/java/io/arcblock/did_motif/didmotif/DIDMotif.kt
+++ b/did-motif/src/main/java/io/arcblock/did_motif/didmotif/DIDMotif.kt
@@ -43,40 +43,6 @@ class DIDMotif(
Hexagon
}
- private val bgColors = arrayListOf(
- "#E94E4E",
- "#E41115",
- "#E96B4E",
- "#E5502E",
- "#E98F4E",
- "#E57A2E",
- "#E98F4E",
- "#E5A82E",
- "#DACD5D",
- "#DAC825",
- "#BDD13D",
- "#C8E31C",
- "#AEE94E",
- "#7FD558",
- "#52CC19",
- "#4FC469",
- "#59DE9C",
- "#19CC73",
- "#5ED9D1",
- "#19CCC0",
- "#4ED7E9",
- "#19B7CC",
- "#45ACE8",
- "#1C97DE",
- "#4E68E9",
- "#2E4DE5",
- "#7F4EE9",
- "#682EE5",
- "#BE65E7",
- "#AF40E2",
- "#DF58C2",
- "#E94E8F",
- )
private val DEBUG_MODE = false
private val totalIndex = arrayListOf()
@@ -131,7 +97,7 @@ class DIDMotif(
address: String,
type: Shape? = null,
withAnimation: Boolean = true
- ) {
+ ): Int {
val info = if (address.address().length < 10) {
randomMotif()
} else try {
@@ -163,8 +129,10 @@ class DIDMotif(
} else {
invalidate()
}
+ return bgColor
}
+
private fun randomMotif(): Triple, RoleType> {
val colorIndexes = arrayListOf()
for (i in 0..31) {
@@ -266,4 +234,54 @@ class DIDMotif(
localPath.close()
return localPath
}
+
+
+ companion object {
+
+ private val bgColors = arrayListOf(
+ "#E94E4E",
+ "#E41115",
+ "#E96B4E",
+ "#E5502E",
+ "#E98F4E",
+ "#E57A2E",
+ "#E98F4E",
+ "#E5A82E",
+ "#DACD5D",
+ "#DAC825",
+ "#BDD13D",
+ "#C8E31C",
+ "#AEE94E",
+ "#7FD558",
+ "#52CC19",
+ "#4FC469",
+ "#59DE9C",
+ "#19CC73",
+ "#5ED9D1",
+ "#19CCC0",
+ "#4ED7E9",
+ "#19B7CC",
+ "#45ACE8",
+ "#1C97DE",
+ "#4E68E9",
+ "#2E4DE5",
+ "#7F4EE9",
+ "#682EE5",
+ "#BE65E7",
+ "#AF40E2",
+ "#DF58C2",
+ "#E94E8F",
+ )
+ fun calculateColorOfAddress(address: String) : Int {
+ val info = if (address.address().length < 10) {
+ return Color.parseColor(bgColors[0])
+ } else try {
+ DIDMotifUtils.getIndexFromDID(address)
+ } catch (e: Exception) {
+ // 如果发生异常,随机一个组合
+ return Color.parseColor(bgColors[0])
+ }
+ return Color.parseColor(bgColors[info.first])
+ }
+ }
}
\ No newline at end of file
diff --git a/version b/version
index ee90284..90a27f9 100644
--- a/version
+++ b/version
@@ -1 +1 @@
-1.0.4
+1.0.5