@@ -30,18 +30,18 @@ import com.orgzly.android.util.UriUtils
3030import com.orgzly.databinding.ActivityRepoGoogleDriveBinding
3131import 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
4646class 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 }
0 commit comments