Skip to content

Commit 54e171f

Browse files
committed
fix theme
1 parent 9088b88 commit 54e171f

11 files changed

Lines changed: 139 additions & 142 deletions

File tree

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<application
2626
android:icon="@drawable/ic_menu_convert_csv"
2727
android:label="@string/app_name"
28+
android:theme="@style/Theme.AppCompat"
2829
tools:replace="android:label">
2930
<!-- aTrackDog metadata -->
3031
<meta-data
@@ -108,7 +109,7 @@
108109
android:label="@string/activity_account_title"
109110
android:launchMode="singleTask"
110111
android:parentActivityName=".InfoActivity"
111-
android:theme="@style/AppTheme.NoActionBar">
112+
android:theme="@style/Theme.AppCompat.NoActionBar">
112113
<intent-filter>
113114
<action android:name="android.intent.action.VIEW"/>
114115

app/src/main/java/org/openintents/convertcsv/blockstack/AccountActivity.kt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ class AccountActivity : AppCompatActivity() {
3333
setSupportActionBar(toolbar)
3434
supportActionBar!!.setDisplayHomeAsUpEnabled(true)
3535

36-
signInButton.isEnabled = false
37-
signOutButton.isEnabled = false
36+
setLoadingUI(true)
3837

3938
val ref: Ref<AccountActivity> = this.asReference()
4039

@@ -99,8 +98,8 @@ class AccountActivity : AppCompatActivity() {
9998
val signedIn = runOnV8Thread {
10099
blockstackSession().isUserSignedIn()
101100
}.await()
102-
signInButton.isEnabled = true
103-
signOutButton.isEnabled = true
101+
setLoadingUI(false)
102+
104103
if (signedIn) {
105104
signInButton.visibility = View.GONE
106105
signOutButton.visibility = View.VISIBLE
@@ -141,6 +140,7 @@ class AccountActivity : AppCompatActivity() {
141140
val authResponse = intent?.data?.getQueryParameter("authResponse")
142141
if (authResponse != null) {
143142
Log.d(TAG, "authResponse: ${authResponse}")
143+
setLoadingUI(true)
144144
runOnV8Thread {
145145
try {
146146
Log.d(TAG, "before signed in!")
@@ -162,6 +162,18 @@ class AccountActivity : AppCompatActivity() {
162162
}
163163
}
164164

165+
private fun setLoadingUI(loading: Boolean) {
166+
if (loading) {
167+
signInButton.isEnabled = false
168+
signOutButton.isEnabled = false
169+
accountDescription.visibility = View.VISIBLE
170+
} else {
171+
signInButton.isEnabled = true
172+
signOutButton.isEnabled = true
173+
accountDescription.visibility = View.INVISIBLE
174+
}
175+
}
176+
165177
override fun onOptionsItemSelected(item: MenuItem?): Boolean {
166178
if (item!!.itemId == android.R.id.home) {
167179
NavUtils.navigateUpFromSameTask(this)

app/src/main/java/org/openintents/convertcsv/blockstack/ConvertCSVProvider.kt

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -271,17 +271,6 @@ class ConvertCSVProvider : DocumentsProvider() {
271271
}
272272
// END_INCLUDE(query_search_documents)
273273

274-
// BEGIN_INCLUDE(open_document_thumbnail)
275-
@Throws(FileNotFoundException::class)
276-
override fun openDocumentThumbnail(documentId: String, sizeHint: Point,
277-
signal: CancellationSignal): AssetFileDescriptor {
278-
Log.v(TAG, "openDocumentThumbnail")
279-
280-
val file = getFileForDocId(documentId)
281-
val pfd = ParcelFileDescriptor.open(File("/"), ParcelFileDescriptor.MODE_READ_ONLY)
282-
return AssetFileDescriptor(pfd, 0, AssetFileDescriptor.UNKNOWN_LENGTH)
283-
}
284-
// END_INCLUDE(open_document_thumbnail)
285274

286275
// BEGIN_INCLUDE(query_document)
287276
@Throws(FileNotFoundException::class)
@@ -386,16 +375,18 @@ class ConvertCSVProvider : DocumentsProvider() {
386375
} else {
387376
val options = GetFileOptions()
388377
var getFileDone = false
389-
378+
var fileNotFound = false
390379
runOnV8Thread {
391380
mSession?.getFile(file.path, options) {
381+
Log.d(TAG, "getFile " + it.value)
392382
if (it.hasValue) {
393-
it.value
394383
if (it.value is String) {
395384
outputFile.writeText(it.value as String)
396385
} else {
397386
outputFile.writeBytes(it.value as ByteArray)
398387
}
388+
} else {
389+
fileNotFound = true
399390
}
400391
getFileDone = true
401392
}
@@ -405,6 +396,10 @@ class ConvertCSVProvider : DocumentsProvider() {
405396
Thread.sleep(500)
406397
}
407398

399+
if (fileNotFound) {
400+
throw FileNotFoundException(file.path)
401+
}
402+
408403
return ParcelFileDescriptor.open(outputFile, accessMode)
409404
}
410405
}
@@ -416,8 +411,7 @@ class ConvertCSVProvider : DocumentsProvider() {
416411
override fun createDocument(documentId: String, mimeType: String, displayName: String): String {
417412
Log.v(TAG, "createDocument")
418413

419-
val parent = getFileForDocId(documentId)
420-
val file = GaiaFile(parent!!.path + "/" + displayName, false)
414+
val file = GaiaFile(displayName, false)
421415
try {
422416
// TODO create file
423417
} catch (e: IOException) {
@@ -528,7 +522,7 @@ class ConvertCSVProvider : DocumentsProvider() {
528522

529523
if (mimeType.startsWith("image/")) {
530524
// Allow the image to be represented by a thumbnail rather than an icon
531-
flags = flags or Document.FLAG_SUPPORTS_THUMBNAIL
525+
flags = flags // TODO support Document.FLAG_SUPPORTS_THUMBNAIL
532526
}
533527

534528
val row = result.newRow()
@@ -553,12 +547,11 @@ class ConvertCSVProvider : DocumentsProvider() {
553547
*/
554548
@Throws(FileNotFoundException::class)
555549
private fun getFileForDocId(docId: String): GaiaFile? {
556-
var target = mBaseDir
557550
if (docId == ROOT) {
558-
return target
551+
return mBaseDir
559552
}
560553

561-
target = GaiaFile(docId, false)
554+
val target = GaiaFile(docId, false)
562555
return target
563556

564557
}

0 commit comments

Comments
 (0)