Skip to content
Snippets Groups Projects
Commit c24cd790 authored by Francesco Andreuzzi's avatar Francesco Andreuzzi
Browse files

Contact permission not necessary

parent 35a2212b
No related branches found
No related tags found
No related merge requests found
package ohi.andre.consolelauncher.commands.raw;
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.support.v4.content.ContextCompat;
import ohi.andre.consolelauncher.R;
import ohi.andre.consolelauncher.commands.CommandAbstraction;
......@@ -11,6 +14,10 @@ public class call implements CommandAbstraction {
@Override
public String exec(ExecInfo info) {
if (ContextCompat.checkSelfPermission(info.context, Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
return info.res.getString(R.string.output_nopermissions);
}
String number = info.get(String.class, 0);
Uri uri = Uri.parse("tel:" + number);
Intent intent = new Intent(Intent.ACTION_CALL, uri);
......
package ohi.andre.consolelauncher.commands.raw;
import android.Manifest;
import android.content.pm.PackageManager;
import android.support.v4.content.ContextCompat;
import java.util.List;
import ohi.andre.consolelauncher.R;
......@@ -11,6 +15,10 @@ public class contacts implements CommandAbstraction {
@Override
public String exec(ExecInfo info) {
if (ContextCompat.checkSelfPermission(info.context, Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
return info.res.getString(R.string.output_nopermissions);
}
List<String> contacts = info.contacts.listNamesAndNumbers();
Tuils.addPrefix(contacts, " ");
Tuils.insertHeaders(contacts, false);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment