Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changing permission request to later + My Contribution :) #5

Closed
JakePou opened this issue Mar 2, 2017 · 4 comments
Closed

changing permission request to later + My Contribution :) #5

JakePou opened this issue Mar 2, 2017 · 4 comments

Comments

@JakePou
Copy link

JakePou commented Mar 2, 2017

First and foremost, THANK YOU for providing this.

Currently, when I start the app, it'll ask for permission to access files. Due to the following line in onCreate:

if (ASWP_FUPLOAD) {
                if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                    ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 2);
                }
}

This doesn't make sense unless the app's entire purpose is to upload files. Otherwise, it'll confuse the user as to why the app is asking for permission. is it possible to move this request to After the user clicks Browse in an upload form?


And here is my tiny contribution, which will help the shouldOverrideUrlLoading method work on both new as well as old SDKs

//Overriding webview URLs
		@SuppressWarnings("deprecation")
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            boolean a = true;

           *******
        }

		@TargetApi(Build.VERSION_CODES.N)
		@Override
		public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
			String url = request.getUrl().toString();
            boolean a = true;
			*******
		}
@JakePou
Copy link
Author

JakePou commented Mar 3, 2017

Ghazi, is there a simple fix for this? I tried copy & pasting that line of code (ActivityCompat.requestPermissions()) in various parts of the code with no luck.

@mgks
Copy link
Owner

mgks commented Mar 4, 2017

Thank you for the contribution and suggesting for change in permissions Jake.

I've updated the codes and now you'll be able to handle permissions wherever you want with a new simple permission checker method introduced in the script.

Also, by default, permissions will be asked only when needed. ACCESS_FINE_LOCATION is onCreate as required, WRITE_EXTERNAL_STORAGE and CAMERA only when FileChooser method shoots.

Don't forget to tell me what you made of it.

@JakePou
Copy link
Author

JakePou commented Mar 7, 2017

First and foremost, thank you for your prompt reply!

I've updated the code and here is how it currently executes:
Step 1. I browse to the upload page inside the app
Step 2. Click Browse
Step 3. File Chooser pops up
Step 4. I select image
Step 5. Then it asks "app would like to access your files". (instead of at step 2)

I think this may be an issue with not the code, but the Android Emulator I'm using. I'm going to submit the app to Google Play and test on a real device. Will update you soon!

@JakePou
Copy link
Author

JakePou commented Mar 8, 2017

Works Great! Cheers.

@JakePou JakePou closed this as completed Mar 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants