Skip to content
This repository has been archived by the owner on May 9, 2023. It is now read-only.

New Sample for ActivityResultContracts.RequestPermission() #8

Merged
merged 18 commits into from
Mar 15, 2021
Merged

New Sample for ActivityResultContracts.RequestPermission() #8

merged 18 commits into from
Mar 15, 2021

Conversation

Canato
Copy link
Contributor

@Canato Canato commented Sep 14, 2020

close #7

Description

  • Run permissions on Android 11
  • Usage of JAVA_8
  • Using appCompat version 1.3.0-alpha02
  • Usage of androidx libraries

Create to give a previous sample using the code from Request App Permissions

Obs:

  • The main change is on MainActivity.kt if compare with the other kotlin module.
  • Most snack bar now have action on it, because was not possible to see the snackbar before (change of activity) and this will bring clearness for the user of what is happening.
  • The name of the folder should be temporary until appCompat release 1.3 stable.

Open for folder name suggestion and/or any other code suggestion

Disclaimer

Already sign the license as noted on CONTRIBUTING.md. Waiting for answer

@nic0lette nic0lette self-requested a review September 15, 2020 18:45
@@ -0,0 +1,8 @@
## This file must *NOT* be checked into Version Control Systems,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't check this file into source control. :)

*/
class MainActivity : AppCompatActivity(), ActivityCompat.OnRequestPermissionsResultCallback {

private lateinit var layout: View
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please convert the sample to use view binding.

}

companion object {
private val TAG = "CameraPreview"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be const (and you could consider moving it to be a top level constant at the top of the file).

* Implementation is based directly on the documentation at
* http://developer.android.com/guide/topics/media/camera.html
*/
class CameraPreview @JvmOverloads constructor(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's probably no reason for the @JvmOverloads here, since this class isn't being consumed by any Java programming language callers.

// Create the Preview view and set it as the content of this Activity.
val cameraPreview = CameraPreview(this, null,
0, camera, cameraInfo, displayRotation)
findViewById<FrameLayout>(R.id.camera_preview).addView(cameraPreview)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please convert the class to use view binding.

* A safe way to get an instance of the Camera object.
*/
private fun getCameraInstance(cameraId: Int): Camera? {
var c: Camera? = null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps use a better name than c for the variable.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.basicpermissions">

<!-- BEGIN_INCLUDE(manifest) -->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider removing this comment (along with the END_INCLUDE one below)

status: PUBLISHED
technologies: [Android]
categories: [Permissions]
languages: [Java]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I forgot to note this: Please change this to [Kotlin] :)

@nic0lette
Copy link
Contributor

Thanks for the contribution! I know a bunch of the comments actually also apply to the existing Kotlin sample, but it would be nice to improve this one not only to use the activity result library but also other improvements :)

@Canato
Copy link
Contributor Author

Canato commented Sep 15, 2020

Thanks for the contribution! I know a bunch of the comments actually also apply to the existing Kotlin sample, but it would be nice to improve this one not only to use the activity result library but also other improvements :)

Hey @nic0lette thanks for the review.

One question, since this camera API is even the new one.
Would make sense to remove the camera files and just open the device camera? since the goal here are the permissions and not the camera.

If yes, I will remove and address the other comments

@nic0lette
Copy link
Contributor

One question, since this camera API is even the new one.
Would make sense to remove the camera files and just open the device camera? since the goal here are the permissions and not the camera.

I'm not sure. Yes, the goal is to show the permission flow, but it's nice to also see the result of it.

Let's leave the deprecated Camera API usage for now, and then update it to use CameraX in the future. (Even if you'd like to do that part, I think we should do it in a separate PR)

(The name for the sample (directory) is also a bit intense? How would you feel about something like PermissionsActivityResultKotlin or even ActivityResultBasicKotlin since it's in the permissions-samples repo?)

@Canato
Copy link
Contributor Author

Canato commented Sep 27, 2020

@nic0lette thanks for the tips. sorry for the long time until I address it.

Change the folder to PermissionsActivityResultKotlin much better name ^^

Thanks for pushing the view binding, I had not give the time before to check it and now I understand why is better compared with Kotlin Synthetic

Just add the new code, let me know anything!

@codingjeremy codingjeremy changed the base branch from master to main September 29, 2020 19:10
@Canato Canato requested a review from nic0lette October 7, 2020 20:50
@codingjeremy codingjeremy requested a review from tiembo October 9, 2020 22:18
@Canato
Copy link
Contributor Author

Canato commented Oct 20, 2020

Hey @codingjeremy sorry to disturb, not sure the best way of helping here. First time committing in the Android Repo, something I could do or need to do to help this PR?

@Canato
Copy link
Contributor Author

Canato commented Oct 30, 2020

@tiembo @nic0lette @codingjeremy I add the changes I saw in #11 let me know if something is off ^^
Thanks

@Canato
Copy link
Contributor Author

Canato commented Nov 17, 2020

Hey people any news? =D

Sorry to disturb @tiembo @codingjeremy

@AiezMansor
Copy link

AiezMansor commented Nov 18, 2020 via email

Merge pull request #1 from android/master
@Canato
Copy link
Contributor Author

Canato commented Nov 30, 2020

Added latest changes into my branch/PR
@tiembo @nic0lette @codingjeremy

@Canato
Copy link
Contributor Author

Canato commented Dec 23, 2020

Good day and almost merry Christmas

Any news here?
@nic0lette @nic0lette @codingjeremy @ggfan @owahltinez

@Canato
Copy link
Contributor Author

Canato commented Jan 14, 2021

Good morning and happy new year =D

Let me know if need more changes or we are waiting for the final release, appcompat is now on beta01

@Canato
Copy link
Contributor Author

Canato commented Feb 1, 2021

Thanks @themar7777 !

Just to let you know I cannot merge 😭

Only those with write access to this repository can merge pull requests.

Hahaha so feel free to merge it when you can =)

@Canato
Copy link
Contributor Author

Canato commented Feb 28, 2021

Hey @tiembo any news for this PR? =D

@nic0lette nic0lette merged commit 3fb0652 into android:main Mar 15, 2021
@nic0lette
Copy link
Contributor

Thank you for the sample. :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New ActivityResultContracts.RequestPermission() sample
4 participants