Skip to content

Commit 522b581

Browse files
author
Nicholas Harrison
committed
Added google drive icons, some minor refactoring
1 parent c54f227 commit 522b581

21 files changed

+28
-77
lines changed

app/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ android {
9292
kotlinOptions {
9393
jvmTarget = 11
9494
}
95-
9695
packagingOptions {
9796
resources {
9897
excludes += ['META-INF/DEPENDENCIES', 'plugin.properties']
@@ -103,6 +102,10 @@ android {
103102
checkDependencies true
104103
disable 'MissingTranslation', 'MissingQuantity', 'ImpliedQuantity', 'InvalidPackage'
105104
}
105+
lint {
106+
disable 'MissingTranslation', 'MissingQuantity', 'ImpliedQuantity', 'InvalidPackage'
107+
}
108+
106109
}
107110

108111
dependencies {

app/src/main/java/com/orgzly/android/repos/GoogleDriveClient.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ public Drive getDriveService(GoogleSignInAccount googleAccount) {
8686
}
8787

8888
public Drive getDriveService() {
89-
if (mDriveService != null) return mDriveService;
9089
return getDriveService(getGoogleAccount());
9190
}
9291

@@ -249,7 +248,7 @@ public VersionedRook download(Uri repoUri, String fileName, java.io.File localFi
249248
if (e.getMessage() != null) {
250249
throw new IOException("Failed downloading Google Drive file " + uri + ": " + e.getMessage());
251250
} else {
252-
throw new IOException("Failed downloading Google Drive file " + uri + ": " + e.toString());
251+
throw new IOException("Failed downloading Google Drive file " + uri + ": " + e);
253252
}
254253
} finally {
255254
out.close();
@@ -303,7 +302,7 @@ public VersionedRook upload(java.io.File file, Uri repoUri, String fileName) thr
303302
if (e.getMessage() != null) {
304303
throw new IOException("Failed overwriting " + filePath + " on Google Drive: " + e.getMessage());
305304
} else {
306-
throw new IOException("Failed overwriting " + filePath + " on Google Drive: " + e.toString());
305+
throw new IOException("Failed overwriting " + filePath + " on Google Drive: " + e);
307306
}
308307
}
309308

@@ -337,7 +336,7 @@ public void delete(String path) throws IOException {
337336
if (e.getMessage() != null) {
338337
throw new IOException("Failed deleting " + path + " on Google Drive: " + e.getMessage());
339338
} else {
340-
throw new IOException("Failed deleting " + path + " on Google Drive: " + e.toString());
339+
throw new IOException("Failed deleting " + path + " on Google Drive: " + e);
341340
}
342341
}
343342
}
@@ -374,7 +373,7 @@ public VersionedRook move(Uri repoUri, Uri from, Uri to) throws IOException {
374373
if (e.getMessage() != null) { // TODO: Move this throwing to utils
375374
throw new IOException("Failed moving " + from + " to " + to + ": " + e.getMessage(), e);
376375
} else {
377-
throw new IOException("Failed moving " + from + " to " + to + ": " + e.toString(), e);
376+
throw new IOException("Failed moving " + from + " to " + to + ": " + e, e);
378377
}
379378
}
380379
}

app/src/main/java/com/orgzly/android/ui/repo/googledrive/GoogleDriveRepoActivity.kt

Lines changed: 13 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,18 @@ import com.orgzly.android.util.UriUtils
3030
import com.orgzly.databinding.ActivityRepoGoogleDriveBinding
3131
import javax.inject.Inject
3232

33-
import com.google.android.gms.auth.api.signin.GoogleSignIn;
34-
import com.google.android.gms.auth.api.signin.GoogleSignInClient;
35-
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
36-
import com.google.android.gms.common.api.Scope;
37-
import com.google.android.gms.tasks.Task;
38-
import com.google.android.gms.tasks.OnCompleteListener;
33+
import com.google.android.gms.auth.api.signin.GoogleSignIn
34+
import com.google.android.gms.auth.api.signin.GoogleSignInClient
35+
import com.google.android.gms.auth.api.signin.GoogleSignInOptions
36+
import com.google.android.gms.common.api.Scope
37+
import com.google.android.gms.tasks.Task
38+
import com.google.android.gms.tasks.OnCompleteListener
3939

40-
import com.google.api.services.drive.DriveScopes;
40+
import com.google.api.services.drive.DriveScopes
4141

42-
import androidx.annotation.NonNull;
42+
import androidx.annotation.NonNull
4343

44-
import android.util.Log;
44+
import android.util.Log
4545

4646
class GoogleDriveRepoActivity : CommonActivity() {
4747
private lateinit var binding: ActivityRepoGoogleDriveBinding
@@ -152,7 +152,7 @@ class GoogleDriveRepoActivity : CommonActivity() {
152152
{
153153
GoogleSignIn.getSignedInAccountFromIntent(result)
154154
.addOnSuccessListener { googleAccount ->
155-
Log.d(TAG, "Signed in as " + googleAccount.getEmail())
155+
Log.d(TAG, "Signed in as " + googleAccount.email)
156156
// Use the authenticated account to sign in to the Drive service.
157157
client.setDriveService(googleAccount)
158158
showSnackbar(R.string.message_google_drive_linked)
@@ -161,48 +161,6 @@ class GoogleDriveRepoActivity : CommonActivity() {
161161
}
162162
}
163163

164-
// Token stuff is handled by Google sign-in
165-
// private fun editAccessToken() {
166-
// @SuppressLint("InflateParams")
167-
// val view = layoutInflater.inflate(R.layout.dialog_simple_one_liner, null, false)
168-
//
169-
// val editView = view.findViewById<EditText>(R.id.dialog_input).apply {
170-
// setSelectAllOnFocus(true)
171-
//
172-
// setHint(R.string.access_token)
173-
//
174-
// client.token?.let {
175-
// setText(it)
176-
// }
177-
// }
178-
//
179-
// alertDialog = AlertDialog.Builder(this)
180-
// .setView(view)
181-
// .setTitle(R.string.access_token)
182-
// .setPositiveButton(R.string.set) { _, _ ->
183-
// editView.text.toString().let { value ->
184-
// if (TextUtils.isEmpty(value)) {
185-
// client.unlink(this)
186-
// } else {
187-
// client.setToken(value)
188-
// }
189-
// }
190-
// updateGoogleDriveLinkUnlinkButton()
191-
// }
192-
// .setNeutralButton(R.string.clear) { _, _ ->
193-
// client.unlink(this)
194-
// updateGoogleDriveLinkUnlinkButton()
195-
// }
196-
// .setNegativeButton(R.string.cancel) { _, _ -> }
197-
// .create().apply {
198-
// setOnShowListener {
199-
// ActivityUtils.openSoftKeyboard(this@GoogleDriveRepoActivity, editView)
200-
// }
201-
//
202-
// show()
203-
// }
204-
// }
205-
206164
public override fun onResume() {
207165
super.onResume()
208166

@@ -296,33 +254,18 @@ class GoogleDriveRepoActivity : CommonActivity() {
296254
}
297255
}
298256

299-
// /**
300-
// * Complete Google Drive linking.
301-
// * After starting Google Drive authentication, user will return to activity.
302-
// * We need to finish the process of authentication.
303-
// */
304-
// private fun googleDriveCompleteAuthentication() {
305-
// if (!isGoogleDriveLinked()) {
306-
// if (client.finishAuthentication()) {
307-
// showSnackbar(R.string.message_google_drive_linked)
308-
// }
309-
// } else {
310-
// showSnackbar(R.string.message_google_drive_linked)
311-
// }
312-
// }
313-
314257
private fun updateGoogleDriveLinkUnlinkButton() {
315258
if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG)
316259

317260
val resources = styledAttributes(R.styleable.Icons) { typedArray ->
318261
if (isGoogleDriveLinked()) {
319262
Pair(
320263
getString(R.string.repo_google_drive_button_linked),
321-
typedArray.getResourceId(R.styleable.Icons_oic_dropbox_linked, 0))
264+
typedArray.getResourceId(R.styleable.Icons_oic_google_drive_linked, 0))
322265
} else {
323266
Pair(
324267
getString(R.string.repo_google_drive_button_not_linked),
325-
typedArray.getResourceId(R.styleable.Icons_oic_dropbox_not_linked, 0))
268+
typedArray.getResourceId(R.styleable.Icons_oic_google_drive_not_linked, 0))
326269
}
327270
}
328271

@@ -345,7 +288,7 @@ class GoogleDriveRepoActivity : CommonActivity() {
345288

346289
private fun unlinkGoogleDrive() {
347290
gsiClient.revokeAccess()
348-
.addOnCompleteListener(this, OnCompleteListener<Void>() {
291+
.addOnCompleteListener(this, OnCompleteListener<Void> {
349292
fun onComplete(@NonNull task:Task<Void>) {
350293
Log.d(TAG, "Signed out")
351294
}
1.36 KB
Loading
3.39 KB
Loading
1.44 KB
Loading
1.03 KB
Loading
2.21 KB
Loading
1.08 KB
Loading
1.75 KB
Loading

0 commit comments

Comments
 (0)