diff --git a/app/build.gradle b/app/build.gradle index 96757ea83..14d7f168a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -92,7 +92,6 @@ android { kotlinOptions { jvmTarget = 11 } - packagingOptions { resources { excludes += ['META-INF/DEPENDENCIES', 'plugin.properties'] @@ -103,6 +102,10 @@ android { checkDependencies true disable 'MissingTranslation', 'MissingQuantity', 'ImpliedQuantity', 'InvalidPackage' } + lint { + disable 'MissingTranslation', 'MissingQuantity', 'ImpliedQuantity', 'InvalidPackage' + } + } dependencies { diff --git a/app/src/main/java/com/orgzly/android/repos/GoogleDriveClient.java b/app/src/main/java/com/orgzly/android/repos/GoogleDriveClient.java index 7ea30fd6f..1da2e6b6d 100644 --- a/app/src/main/java/com/orgzly/android/repos/GoogleDriveClient.java +++ b/app/src/main/java/com/orgzly/android/repos/GoogleDriveClient.java @@ -86,7 +86,6 @@ public Drive getDriveService(GoogleSignInAccount googleAccount) { } public Drive getDriveService() { - if (mDriveService != null) return mDriveService; return getDriveService(getGoogleAccount()); } @@ -249,7 +248,7 @@ public VersionedRook download(Uri repoUri, String fileName, java.io.File localFi if (e.getMessage() != null) { throw new IOException("Failed downloading Google Drive file " + uri + ": " + e.getMessage()); } else { - throw new IOException("Failed downloading Google Drive file " + uri + ": " + e.toString()); + throw new IOException("Failed downloading Google Drive file " + uri + ": " + e); } } finally { out.close(); @@ -303,7 +302,7 @@ public VersionedRook upload(java.io.File file, Uri repoUri, String fileName) thr if (e.getMessage() != null) { throw new IOException("Failed overwriting " + filePath + " on Google Drive: " + e.getMessage()); } else { - throw new IOException("Failed overwriting " + filePath + " on Google Drive: " + e.toString()); + throw new IOException("Failed overwriting " + filePath + " on Google Drive: " + e); } } @@ -337,7 +336,7 @@ public void delete(String path) throws IOException { if (e.getMessage() != null) { throw new IOException("Failed deleting " + path + " on Google Drive: " + e.getMessage()); } else { - throw new IOException("Failed deleting " + path + " on Google Drive: " + e.toString()); + throw new IOException("Failed deleting " + path + " on Google Drive: " + e); } } } @@ -374,7 +373,7 @@ public VersionedRook move(Uri repoUri, Uri from, Uri to) throws IOException { if (e.getMessage() != null) { // TODO: Move this throwing to utils throw new IOException("Failed moving " + from + " to " + to + ": " + e.getMessage(), e); } else { - throw new IOException("Failed moving " + from + " to " + to + ": " + e.toString(), e); + throw new IOException("Failed moving " + from + " to " + to + ": " + e, e); } } } diff --git a/app/src/main/java/com/orgzly/android/ui/repo/googledrive/GoogleDriveRepoActivity.kt b/app/src/main/java/com/orgzly/android/ui/repo/googledrive/GoogleDriveRepoActivity.kt index 63928c993..01820ee17 100644 --- a/app/src/main/java/com/orgzly/android/ui/repo/googledrive/GoogleDriveRepoActivity.kt +++ b/app/src/main/java/com/orgzly/android/ui/repo/googledrive/GoogleDriveRepoActivity.kt @@ -30,18 +30,18 @@ import com.orgzly.android.util.UriUtils import com.orgzly.databinding.ActivityRepoGoogleDriveBinding import javax.inject.Inject -import com.google.android.gms.auth.api.signin.GoogleSignIn; -import com.google.android.gms.auth.api.signin.GoogleSignInClient; -import com.google.android.gms.auth.api.signin.GoogleSignInOptions; -import com.google.android.gms.common.api.Scope; -import com.google.android.gms.tasks.Task; -import com.google.android.gms.tasks.OnCompleteListener; +import com.google.android.gms.auth.api.signin.GoogleSignIn +import com.google.android.gms.auth.api.signin.GoogleSignInClient +import com.google.android.gms.auth.api.signin.GoogleSignInOptions +import com.google.android.gms.common.api.Scope +import com.google.android.gms.tasks.Task +import com.google.android.gms.tasks.OnCompleteListener -import com.google.api.services.drive.DriveScopes; +import com.google.api.services.drive.DriveScopes -import androidx.annotation.NonNull; +import androidx.annotation.NonNull -import android.util.Log; +import android.util.Log class GoogleDriveRepoActivity : CommonActivity() { private lateinit var binding: ActivityRepoGoogleDriveBinding @@ -152,7 +152,7 @@ class GoogleDriveRepoActivity : CommonActivity() { { GoogleSignIn.getSignedInAccountFromIntent(result) .addOnSuccessListener { googleAccount -> - Log.d(TAG, "Signed in as " + googleAccount.getEmail()) + Log.d(TAG, "Signed in as " + googleAccount.email) // Use the authenticated account to sign in to the Drive service. client.setDriveService(googleAccount) showSnackbar(R.string.message_google_drive_linked) @@ -161,48 +161,6 @@ class GoogleDriveRepoActivity : CommonActivity() { } } - // Token stuff is handled by Google sign-in - // private fun editAccessToken() { - // @SuppressLint("InflateParams") - // val view = layoutInflater.inflate(R.layout.dialog_simple_one_liner, null, false) - // - // val editView = view.findViewById(R.id.dialog_input).apply { - // setSelectAllOnFocus(true) - // - // setHint(R.string.access_token) - // - // client.token?.let { - // setText(it) - // } - // } - // - // alertDialog = AlertDialog.Builder(this) - // .setView(view) - // .setTitle(R.string.access_token) - // .setPositiveButton(R.string.set) { _, _ -> - // editView.text.toString().let { value -> - // if (TextUtils.isEmpty(value)) { - // client.unlink(this) - // } else { - // client.setToken(value) - // } - // } - // updateGoogleDriveLinkUnlinkButton() - // } - // .setNeutralButton(R.string.clear) { _, _ -> - // client.unlink(this) - // updateGoogleDriveLinkUnlinkButton() - // } - // .setNegativeButton(R.string.cancel) { _, _ -> } - // .create().apply { - // setOnShowListener { - // ActivityUtils.openSoftKeyboard(this@GoogleDriveRepoActivity, editView) - // } - // - // show() - // } - // } - public override fun onResume() { super.onResume() @@ -296,21 +254,6 @@ class GoogleDriveRepoActivity : CommonActivity() { } } - // /** - // * Complete Google Drive linking. - // * After starting Google Drive authentication, user will return to activity. - // * We need to finish the process of authentication. - // */ - // private fun googleDriveCompleteAuthentication() { - // if (!isGoogleDriveLinked()) { - // if (client.finishAuthentication()) { - // showSnackbar(R.string.message_google_drive_linked) - // } - // } else { - // showSnackbar(R.string.message_google_drive_linked) - // } - // } - private fun updateGoogleDriveLinkUnlinkButton() { if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG) @@ -318,11 +261,11 @@ class GoogleDriveRepoActivity : CommonActivity() { if (isGoogleDriveLinked()) { Pair( getString(R.string.repo_google_drive_button_linked), - typedArray.getResourceId(R.styleable.Icons_oic_dropbox_linked, 0)) + typedArray.getResourceId(R.styleable.Icons_oic_google_drive_linked, 0)) } else { Pair( getString(R.string.repo_google_drive_button_not_linked), - typedArray.getResourceId(R.styleable.Icons_oic_dropbox_not_linked, 0)) + typedArray.getResourceId(R.styleable.Icons_oic_google_drive_not_linked, 0)) } } @@ -345,7 +288,7 @@ class GoogleDriveRepoActivity : CommonActivity() { private fun unlinkGoogleDrive() { gsiClient.revokeAccess() - .addOnCompleteListener(this, OnCompleteListener() { + .addOnCompleteListener(this, OnCompleteListener { fun onComplete(@NonNull task:Task) { Log.d(TAG, "Signed out") } diff --git a/app/src/main/res/drawable-hdpi/cic_google_drive_black.png b/app/src/main/res/drawable-hdpi/cic_google_drive_black.png new file mode 100644 index 000000000..6b0c3f04c Binary files /dev/null and b/app/src/main/res/drawable-hdpi/cic_google_drive_black.png differ diff --git a/app/src/main/res/drawable-hdpi/cic_google_drive_color.png b/app/src/main/res/drawable-hdpi/cic_google_drive_color.png new file mode 100644 index 000000000..e6c65e7dc Binary files /dev/null and b/app/src/main/res/drawable-hdpi/cic_google_drive_color.png differ diff --git a/app/src/main/res/drawable-hdpi/cic_google_drive_white.png b/app/src/main/res/drawable-hdpi/cic_google_drive_white.png new file mode 100644 index 000000000..decfdb1f4 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/cic_google_drive_white.png differ diff --git a/app/src/main/res/drawable-mdpi/cic_google_drive_black.png b/app/src/main/res/drawable-mdpi/cic_google_drive_black.png new file mode 100644 index 000000000..d199d1c29 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/cic_google_drive_black.png differ diff --git a/app/src/main/res/drawable-mdpi/cic_google_drive_color.png b/app/src/main/res/drawable-mdpi/cic_google_drive_color.png new file mode 100644 index 000000000..631151494 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/cic_google_drive_color.png differ diff --git a/app/src/main/res/drawable-mdpi/cic_google_drive_white.png b/app/src/main/res/drawable-mdpi/cic_google_drive_white.png new file mode 100644 index 000000000..b576e39ec Binary files /dev/null and b/app/src/main/res/drawable-mdpi/cic_google_drive_white.png differ diff --git a/app/src/main/res/drawable-xhdpi/cic_google_drive_black.png b/app/src/main/res/drawable-xhdpi/cic_google_drive_black.png new file mode 100644 index 000000000..67c56f1b5 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/cic_google_drive_black.png differ diff --git a/app/src/main/res/drawable-xhdpi/cic_google_drive_color.png b/app/src/main/res/drawable-xhdpi/cic_google_drive_color.png new file mode 100644 index 000000000..c98e79930 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/cic_google_drive_color.png differ diff --git a/app/src/main/res/drawable-xhdpi/cic_google_drive_white.png b/app/src/main/res/drawable-xhdpi/cic_google_drive_white.png new file mode 100644 index 000000000..d6dcfece8 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/cic_google_drive_white.png differ diff --git a/app/src/main/res/drawable-xxhdpi/cic_google_drive_black.png b/app/src/main/res/drawable-xxhdpi/cic_google_drive_black.png new file mode 100644 index 000000000..7ff51f1aa Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/cic_google_drive_black.png differ diff --git a/app/src/main/res/drawable-xxhdpi/cic_google_drive_color.png b/app/src/main/res/drawable-xxhdpi/cic_google_drive_color.png new file mode 100644 index 000000000..f01295d64 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/cic_google_drive_color.png differ diff --git a/app/src/main/res/drawable-xxhdpi/cic_google_drive_white.png b/app/src/main/res/drawable-xxhdpi/cic_google_drive_white.png new file mode 100644 index 000000000..37e084377 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/cic_google_drive_white.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/cic_google_drive_black.png b/app/src/main/res/drawable-xxxhdpi/cic_google_drive_black.png new file mode 100644 index 000000000..c483dc92f Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/cic_google_drive_black.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/cic_google_drive_color.png b/app/src/main/res/drawable-xxxhdpi/cic_google_drive_color.png new file mode 100644 index 000000000..ed4a57250 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/cic_google_drive_color.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/cic_google_drive_white.png b/app/src/main/res/drawable-xxxhdpi/cic_google_drive_white.png new file mode 100644 index 000000000..283285112 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/cic_google_drive_white.png differ diff --git a/app/src/main/res/layout/activity_repo_google_drive.xml b/app/src/main/res/layout/activity_repo_google_drive.xml index 2ec891e16..5df9ef725 100644 --- a/app/src/main/res/layout/activity_repo_google_drive.xml +++ b/app/src/main/res/layout/activity_repo_google_drive.xml @@ -36,7 +36,7 @@ android:id="@+id/activity_repo_google_drive_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:src="?attr/oic_dropbox_not_linked" + android:src="?attr/oic_google_drive_not_linked" android:contentDescription="@string/google_drive" />