mirror of
https://github.com/etesync/android
synced 2025-01-09 15:20:57 +00:00
Ask for permissions on app launch.
This commit is contained in:
parent
36ee584e6a
commit
116094c7b9
@ -8,10 +8,12 @@
|
|||||||
|
|
||||||
package at.bitfire.davdroid.ui;
|
package at.bitfire.davdroid.ui;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.design.widget.FloatingActionButton;
|
import android.support.design.widget.FloatingActionButton;
|
||||||
import android.support.design.widget.NavigationView;
|
import android.support.design.widget.NavigationView;
|
||||||
|
import android.support.v4.app.ActivityCompat;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
import android.support.v4.app.FragmentTransaction;
|
||||||
import android.support.v4.view.GravityCompat;
|
import android.support.v4.view.GravityCompat;
|
||||||
import android.support.v4.widget.DrawerLayout;
|
import android.support.v4.widget.DrawerLayout;
|
||||||
@ -67,6 +69,8 @@ public class AccountsActivity extends AppCompatActivity implements NavigationVie
|
|||||||
Toast.makeText(this, "Server: " + serviceUrl.toString(), Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, "Server: " + serviceUrl.toString(), Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PermissionsActivity.requestAllPermissions(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
package at.bitfire.davdroid.ui;
|
package at.bitfire.davdroid.ui;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
@ -23,6 +24,7 @@ import at.bitfire.davdroid.R;
|
|||||||
import at.bitfire.davdroid.resource.LocalTaskList;
|
import at.bitfire.davdroid.resource.LocalTaskList;
|
||||||
|
|
||||||
public class PermissionsActivity extends AppCompatActivity {
|
public class PermissionsActivity extends AppCompatActivity {
|
||||||
|
final static private int REQUEST_CODE_ASK_MULTIPLE_PERMISSIONS = 124;
|
||||||
|
|
||||||
public static final String
|
public static final String
|
||||||
PERMISSION_READ_TASKS = "org.dmfs.permission.READ_TASKS",
|
PERMISSION_READ_TASKS = "org.dmfs.permission.READ_TASKS",
|
||||||
@ -96,4 +98,13 @@ public class PermissionsActivity extends AppCompatActivity {
|
|||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void requestAllPermissions(Activity activity) {
|
||||||
|
ActivityCompat.requestPermissions(activity, new String[] {
|
||||||
|
Manifest.permission.READ_CALENDAR,
|
||||||
|
Manifest.permission.WRITE_CALENDAR,
|
||||||
|
Manifest.permission.READ_CONTACTS,
|
||||||
|
Manifest.permission.WRITE_CONTACTS
|
||||||
|
}, REQUEST_CODE_ASK_MULTIPLE_PERMISSIONS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user