Coder Social home page Coder Social logo

ask's People

Contributors

00ec454 avatar bmutinda avatar bryant1410 avatar nikhil-z avatar omegaes avatar pinkeshdarji avatar pishguy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ask's Issues

Standard Fragment support

It would be great, if the Ask.on method also accepts android.app.Fragment and not only android.support.v4.app.Fragment.

Add listener "onFinished"

It would be great if you add a Listener, which will be called if the library has asked for all permissions.

Something like this:

Ask.on(this)
        .forPermissions(/* permisssions */)
        .withRationales(/* rationales */)
        .onFinished(new Ask.OnFinishedListener() {
            @Override
            public void onFinish() {
                Log.i("Activity", "Asked for all permissions");
            }
        })
        .go();

An activity flickers just before the launcher activity

I just followed the steps mentioned in README file, when the user grants the permission the application needs to be restarted; as none of the buttons stay in workable state(don't know why!). After restart it works perfectly fine except one thing- there's a movement of an activity just before the app's launcher activity which is clearly visible sliding out of the screen..

Crashing with my AppCompatActivity

Hi, when i am using Ask Library in my App, it is crashing, please find the details below.

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.beyondseek.ServicesAroundMe/com.vistrav.ask.AskActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
                                                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                                                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                                                   at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                                                   at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                   at android.os.Looper.loop(Looper.java:148)
                                                                                   at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                                   at java.lang.reflect.Method.invoke(Native Method)
                                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                                                Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
                                                                                   at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:343)
                                                                                   at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:312)
                                                                                   at android.support.v7.app.AppCompatDelegateImplV7.onPostCreate(AppCompatDelegateImplV7.java:167)
                                                                                   at android.support.v7.app.AppCompatActivity.onPostCreate(AppCompatActivity.java:98)
                                                                                   at android.app.Instrumentation.callActivityOnPostCreate(Instrumentation.java:1188)
                                                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2398)
                                                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                                                                   at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                                                   at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                   at android.os.Looper.loop(Looper.java:148) 
                                                                                   at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                                   at java.lang.reflect.Method.invoke(Native Method) 
                                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

The code in the onCreate of my Permissions Activity:

 Ask.on(PermissionAcitvity.this)
                .forPermissions(Manifest.permission.ACCESS_COARSE_LOCATION
                        , Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.CALL_PHONE,Manifest.permission.ACCESS_NETWORK_STATE,
                        Manifest.permission.ACCESS_WIFI_STATE, Manifest.permission.MANAGE_DOCUMENTS,
                        Manifest.permission.CALL_PHONE, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)
                .withRationales("Location permission need for map to work properly",
                        "In order to save file you will need to grant storage permission").go(); 

This is the App Theme that i am using:

<style name="AppTheme" parent="Theme.AppCompat.DayNight.DarkActionBar">

The compileSdkVersion is 24
And buildToolsVersion is '23.0.3'
Please help.

Android UI/Espresso test recording/playing

Hi!

When I try to record a test with Android Studio and Espresso UI, the clicks on the Permission dialog of ASK will NEVER be recorded and therefore never be replayed, so the test cannot start at all.

Is there a way to bypass it for tests only?

Rationals are not working in your code

I found your library very useful and easy to integrate , but when i tried to integrate this into my app I wasn't able to show rational messages . so if you please care to help reply to this
and another thing when camera permission is given it doesn't shows multiple permission there

Memory Leak : It holds reference to the Activity

Great library, I really appreciate it but I am having a slight problem
When we call

Ask.on(this)
.forPermissions()
.go();

It is actually holding the reference to the activity in Ask.on(), which is not garbage collected, what we can do about it?

Thanks

Caused by: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?

My logcat shows

Process: com.root5solutions.myapplication, PID: 12204 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.root5solutions.myapplication/com.root5solutions.myapplication.MainActivity}: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? at android.app.ContextImpl.startActivity(ContextImpl.java:672) at android.app.ContextImpl.startActivity(ContextImpl.java:659) at android.content.ContextWrapper.startActivity(ContextWrapper.java:331) at com.vistrav.ask.Ask.go(Ask.java:56) at com.root5solutions.myapplication.MainActivity.onCreate(MainActivity.java:104) at android.app.Activity.performCreate(Activity.java:6237) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)  at android.app.ActivityThread.-wrap11(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:148)  at android.app.ActivityThread.main(ActivityThread.java:5417)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

i tried to access permissions such as READ_CONTACT and GET_ACCOUNTSby using the code below

import android.Manifest;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.ContentResolver;
import android.database.Cursor;
import android.provider.BaseColumns;
import android.provider.ContactsContract;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

import com.vistrav.ask.Ask;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    private static final String TAG = "PM";
    ArrayList<String> alName = new ArrayList<String>();
    ArrayList<String> alContacts = new ArrayList<String>();
    ArrayList<String> alEmails = new ArrayList<String>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Ask.on(getApplicationContext())
                .forPermissions(Manifest.permission.GET_ACCOUNTS
                        , Manifest.permission.READ_CONTACTS) //one or more permissions
                .withRationales("Account permission need for app to work properly",
                        "Contact permission need for app to work properly") //optional
                .when(new Ask.Permission() {
                    @Override
                    public void granted(List<String> permissions) {
                        try {
                            Account[] accounts = AccountManager.get(getApplicationContext()).getAccountsByType("com.google");
                            for (Account account : accounts) {
                                String emailid = account.name;
                                Log.e("account", emailid);
                            }
                        } catch (Exception e) {
                            Log.e("Exception", "Exception:" + e);
                        }
                        ContentResolver cr = getApplicationContext().getContentResolver(); //Activity/Application android.content.Context
                        Cursor cursor = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
                        if (cursor.moveToFirst()) {
                            do {
                                String contactid = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
                                if (Integer.parseInt(cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0) {
                                    Cursor pCur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?", new String[]{contactid}, null);
                                    while (pCur.moveToNext()) {
                                        String contactName = pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
                                        String contactNumber = pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
                                        alContacts.add(contactNumber);
                                        alName.add(contactName);
                                        Log.e("Contact Name", contactName);
                                        Log.e("Contact Number", contactNumber);
                                        break;
                                    }
                                    pCur.close();
                                }

                            } while (cursor.moveToNext());
                        }
                        String emailIdOfContact = null;
                        cr = getApplicationContext().getContentResolver();
                        Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null,
                                null, null, null);
                        if (cur.getCount() > 0) {
                            while (cur.moveToNext()) {
                                String id = cur.getString(cur.getColumnIndex(BaseColumns._ID));

                                cr.query(
                                        ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
                                        null,
                                        ContactsContract.CommonDataKinds.Phone.CONTACT_ID
                                                + " = ?", new String[]{id}, null);

                                Cursor emails = cr.query(ContactsContract.CommonDataKinds.Email.CONTENT_URI, null,
                                        ContactsContract.CommonDataKinds.Email.CONTACT_ID + " = " + id, null, null);
                                while (emails.moveToNext()) {
                                    emailIdOfContact = emails.getString(emails.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA));
                                    alEmails.add(emailIdOfContact);
                                    Log.e("Email ID", emailIdOfContact);
                                }
                                emails.close();

                            }
                        }// end of contact name cursor
                        cur.close();
                        Log.e("ContactL Name", String.valueOf(alName));
                        Log.e("ContactL Number", String.valueOf(alContacts));
                        Log.e("ContactL Email", String.valueOf(alEmails));

                        Log.i(TAG, "granted :: " + permissions);
                    }

                    @Override
                    public void denied(List<String> permissions) {
                        Log.i(TAG, "denied :: " + permissions);
                    }
                }).go();
    }
}

Reprompt permission check after user denies

i had created a dialog box manually ,if user denies the permission, here if user press cancel button the whole app will close and my question is ,if user clicks ok button , how will i reprompt the permission check.??
should i write the whole permission code once again..?

 @Override
                    public void denied(List<String> permissions) {
                        showDialogOK("Get Accounts and Contact Permission required for this app",
                                    new DialogInterface.OnClickListener() {
                                        @Override
                                        public void onClick(DialogInterface dialog, int which) {
                                            switch (which) {
                                                case DialogInterface.BUTTON_POSITIVE:
                                                  // permission check again 
                                                  //but how
                                                    break;
                                                case DialogInterface.BUTTON_NEGATIVE:
                                                    // proceed with logic by disabling the related features or quit the app.
                                                    finish();
                                                    break;
                                            }
                                        }
                                    });
                        Log.i(TAG, "denied :: " + permissions);
                    }
                }).go();
    }
    private void showDialogOK(String message, DialogInterface.OnClickListener okListener) {
        new AlertDialog.Builder(this)
                .setMessage(message)
                .setPositiveButton("OK", okListener)
                .setNegativeButton("Cancel", okListener)
                .setIcon(R.mipmap.ic_launcher)
                .create()
                .show();
    }

Support Fragment

First of all thanks for this lib - What I was actually looking for however I have one concern.

From the implementation based on Fragment, I can see you used Fragment from
import android.app.Fragment however all my fragments are based on the android support lib .i.e. android.support.v4.app.Fragment .

Do you have any best way to handle this??

Permission callbacks not working (kotlin)

Using this pretty simple kotlin code:

    Ask.on(this)
            .id(1001)
            .forPermissions(Manifest.permission.ACCESS_FINE_LOCATION)
            .withRationales(getString(R.string.location_permission_rationale))
            .go()

    @AskGranted(Manifest.permission.ACCESS_FINE_LOCATION)
    fun mapAccessGranted(id: Int) {
      ...
    }

When running the app, permission is asked, but after OKing, mapAccessGranted is never called.

I have debugged the app and have found that, Ask.getAnnotatedMethod() gets called and seems to find the callback method OK, adding it to permissionMethodMapRef. So far so good.

However, when Ask.invokeMethod() is called, permissionMethodMapRef.get() is null, throwing the Exception at line 229.

Seems the WeakReference has been destroyed in the meantime.

Is this a kotlin specific issue? Any suggested workaround?

denied branch gets called if with permission granted

As you can see from the screenshot the denied method gets called even with the permissions array is empty.
denied

I suppose the easiest solution is wrapping

permissionObj.denied(deniedPermissions);

with

if (deniedPermissions.size() > 0) {
    permissionObj.denied(deniedPermissions);
}

Android 8.0

Has anyone found the issue with Android versions 8.0?
All the permission callbacks not working for Oneplus A300 running 8.0.

Disable rtl

plase disable rtl support in your manifest

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.