Skip to content

Commit c570800

Browse files
committed
Bump to v0.3.0. Fix error when entering decimal SC values. Change filesize conversion to use proper sizes for values (1000 instead of 1024). Other small things
1 parent 6ef3a4c commit c570800

File tree

16 files changed

+43
-34
lines changed

16 files changed

+43
-34
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ This app serves as an Android client for the decentralized cloud storage platfor
55
This app can:
66
* Run a Sia node on your device
77
* Interact with all wallet functionalities of the running node - create, send, receive, etc.
8-
* Coming soon: upload to and download from the Sia cloud storage network (in-progress on the develop branch)
9-
* Coming later: SPV functionality (a.k.a. "lite wallet") once Sia implements this feature
8+
* Interact with the renter module, including uploading to and downloading from the Sia network
9+
* Coming later: Function without entire blockchain, once Sia implements this feature
1010

1111
This app is developed independently by me. It is not an official Nebulous Labs product.
1212

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ android {
1515
applicationId "com.vandyke.sia"
1616
minSdkVersion 21
1717
targetSdkVersion 27
18-
versionCode 2010
19-
versionName "0.2.10"
18+
versionCode 3000
19+
versionName "0.3.0"
2020
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
2121
/* lets us not shrink debug builds, for faster build times. Not necessary for release builds, since we shrink those */
2222
multiDexEnabled true

app/src/main/java/com/vandyke/sia/dagger/ApiModule.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ApiModule {
2727
@Singleton
2828
fun provideSiaApi(): SiaApi {
2929
/* always return the actual api if it's a release build, so I don't accidentally release an update that uses the mock api */
30-
return if (!BuildConfig.DEBUG || false) {
30+
return if (!BuildConfig.DEBUG || true) {
3131
val clientBuilder = OkHttpClient.Builder()
3232
// .addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
3333
/* no read timeout because some Sia API calls can take a long time to return/respond */

app/src/main/java/com/vandyke/sia/data/remote/MockSiaApi.kt

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,22 +85,30 @@ class MockSiaApi : SiaApi {
8585

8686
private var renterData = RenterData(
8787
RenterSettingsData(RenterSettingsAllowanceData(
88-
BigDecimal("3629").toHastings(),
88+
BigDecimal("1769").toHastings(),
8989
50,
9090
12000,
9191
4000
9292
)),
9393
RenterFinancialMetricsData(
9494
System.currentTimeMillis(),
95-
BigDecimal("167").toHastings(),
96-
BigDecimal("154").toHastings(),
97-
BigDecimal("690").toHastings(),
98-
BigDecimal("274").toHastings(),
99-
BigDecimal("1085").toHastings()
95+
BigDecimal("16").toHastings(),
96+
BigDecimal("15").toHastings(),
97+
BigDecimal("673").toHastings(),
98+
BigDecimal("30").toHastings(),
99+
BigDecimal("1000").toHastings()
100100
),
101101
139000
102102
)
103103

104+
private var renterPrices = PricesData(
105+
System.currentTimeMillis(),
106+
BigDecimal("26").toHastings(),
107+
BigDecimal("82").toHastings(),
108+
BigDecimal("140").toHastings(),
109+
BigDecimal("75").toHastings()
110+
)
111+
104112
private val contracts = listOf(
105113
ContractData("dkvjsadkljfoweinfskjdnf", BigDecimal("143").toHastings(), BigDecimal("100").toHastings(), BigDecimal("156").toHastings(), BigDecimal("463").toHastings(),
106114
BigDecimal("56").toHastings(), BigDecimal("673").toHastings(), 130000, 200000,
@@ -212,7 +220,7 @@ class MockSiaApi : SiaApi {
212220

213221
override fun getScPrice(url: String): Single<ScValueData> {
214222
return Single.just(ScValueData(System.currentTimeMillis(),
215-
BigDecimal("0.01"), BigDecimal("0.02"), BigDecimal("0.03"),
223+
BigDecimal("0.012645"), BigDecimal("0.02"), BigDecimal("0.03"),
216224
BigDecimal("0.04"), BigDecimal("0.05"), BigDecimal("0.06"),
217225
BigDecimal("0.07"), BigDecimal("0.08"), BigDecimal("0.09"),
218226
BigDecimal("0.10")
@@ -244,12 +252,7 @@ class MockSiaApi : SiaApi {
244252
}
245253

246254
override fun renterPrices(): Single<PricesData> {
247-
return Single.just(PricesData(
248-
System.currentTimeMillis(),
249-
BigDecimal("26").toHastings(),
250-
BigDecimal("100").toHastings(),
251-
BigDecimal("200").toHastings(),
252-
BigDecimal("75").toHastings()))
255+
return Single.just(renterPrices)
253256
}
254257

255258
override fun renterRename(siapath: String, newSiaPath: String) = Completable.fromAction {

app/src/main/java/com/vandyke/sia/data/remote/SiaException.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ sealed class SiaException(msg: String) : Throwable(msg) {
2626
msg.contains("wallet has already been unlocked") -> WalletAlreadyUnlocked()
2727
msg.contains("wallet must be unlocked before it can be used") -> WalletLocked()
2828
msg.contains("provided encryption key is incorrect") -> WalletPasswordIncorrect()
29-
msg.contains("could not read 'amount'") -> CouldNotReadAmount()
29+
msg.contains("could not read amount") -> CouldNotReadAmount()
3030
msg.contains("a password must be provided to newpassword") -> NewPasswordRequired()
3131
msg.contains("could not read address") -> CouldNotReadAddress()
3232
msg.contains("transaction cannot have an output or payout that has zero value") -> ZeroAmount()

app/src/main/java/com/vandyke/sia/ui/main/MainActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ class MainActivity : AppCompatActivity() {
320320
AlertDialog.Builder(this)
321321
.setTitle("Notice")
322322
.setMessage("This is your first time loading the renter module, which will" +
323-
" take a significant amount of time; possibly over an hour. This is normal, and" +
323+
" take a significant amount of time. This is normal, and" +
324324
" subsequent starts of the renter module will be much, much quicker. You are free" +
325325
" to keep Sia in the background while it loads. Thanks for your patience!")
326326
.setPositiveButton(android.R.string.ok) { _, _ -> Prefs.viewedFirstTimeLoadingRenter = true }

app/src/main/java/com/vandyke/sia/ui/node/NodeStatusFragment.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.vandyke.sia.ui.node
22

3+
import android.content.Intent
34
import android.graphics.Typeface
45
import android.os.Bundle
56
import android.text.SpannableString
@@ -8,6 +9,7 @@ import android.text.style.StyleSpan
89
import android.view.View
910
import com.vandyke.sia.R
1011
import com.vandyke.sia.data.local.Prefs
12+
import com.vandyke.sia.data.siad.SiadService
1113
import com.vandyke.sia.data.siad.SiadSource
1214
import com.vandyke.sia.data.siad.SiadStatus
1315
import com.vandyke.sia.data.siad.SiadStatus.State.*
@@ -43,6 +45,8 @@ class NodeStatusFragment : BaseFragment() {
4345

4446
sia_button.setOnClickListener {
4547
Prefs.siaManuallyStopped = !Prefs.siaManuallyStopped
48+
if (!Prefs.siaManuallyStopped)
49+
context!!.startService(Intent(context, SiadService::class.java))
4650
}
4751

4852
siadStatus.state.observe(this) {

app/src/main/java/com/vandyke/sia/ui/renter/allowance/AllowanceFragment.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,15 @@ class AllowanceFragment : BaseFragment() {
135135

136136
// all the conversion logic below should probably be in a method called on the VM instead
137137
vm.setAllowance(funds = when (units) {
138-
"SC" -> text.toBigDecimal().toHastings()
138+
"SC" -> text.toBigDecimal().toHastings().stripDecimals()
139139

140140
Prefs.fiatCurrency -> {
141141
val rate = vm.scValue.value?.get(Prefs.fiatCurrency) ?: run {
142142
Light.error(allowance_swiperefresh, "Error converting ${Prefs.fiatCurrency} to SC", Snackbar.LENGTH_SHORT).show()
143143
return@editTextSpinnerDialog
144144
}
145145
val sc = text.toBigDecimal() / rate
146-
sc.toHastings()
146+
sc.toHastings().stripDecimals()
147147
}
148148

149149
/* GB accounts for uploading once, downloading once, and storing over the current period the entered amount,
@@ -159,9 +159,9 @@ class AllowanceFragment : BaseFragment() {
159159
return@editTextSpinnerDialog
160160
}
161161
val periodLengthMonths = SiaUtil.blocksToDays(allowance.period) / 30
162-
val desiredTb = text.toBigDecimal() / BigDecimal("1024")
162+
val desiredTb = text.toBigDecimal() / BigDecimal("1000")
163163
val totalPricePerTb = prices.downloadOneTerabyte + prices.uploadOneTerabyte + (prices.storageOneTerabyteMonth * periodLengthMonths.toBigDecimal())
164-
desiredTb * totalPricePerTb + (prices.formOneContract * allowance.hosts.toBigDecimal())
164+
(desiredTb * totalPricePerTb + (prices.formOneContract * allowance.hosts.toBigDecimal())).stripDecimals()
165165
}
166166

167167
else -> throw IllegalStateException()

app/src/main/java/com/vandyke/sia/ui/renter/allowance/AllowanceViewModel.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ class AllowanceViewModel
102102
consensusRepository.updateConsensus())
103103
.io()
104104
.main()
105-
.track(activeTasks)
106105
.track(refreshing)
107106
.subscribe({}, ::onError)
108107

app/src/main/java/com/vandyke/sia/ui/renter/files/view/fileupload/FileUploadDialog.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class FileUploadDialog : DialogFragment() {
4141
val path = FileUtils.getPath(context!!, it)
4242
if (path != null) {
4343
val size = File(path).length()
44-
totalSize += size.coerceAtLeast(1024 * 1024 * 40) // Sia's 40MB minimum filesize
44+
totalSize += size.coerceAtLeast(1000 * 1000 * 40) // Sia's 40MB minimum filesize
4545
FileUpload(path, size)
4646
} else {
4747
FileUpload(it.toString(), 0L)

0 commit comments

Comments
 (0)