Skip to content
This repository was archived by the owner on Apr 9, 2021. It is now read-only.

added permission for WRITE_SETTINGS #332

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
Expand All @@ -20,6 +21,7 @@
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.loader.app.LoaderManager;
import androidx.loader.content.Loader;
Expand Down Expand Up @@ -119,7 +121,23 @@ public void chooseReceivingMethods() {

@OnClick(R.id.bSendForms)
public void selectForms() {
ActivityUtils.launchActivity(this, SendFormsActivity.class, false);
if (ActivityCompat.checkSelfPermission(getApplicationContext(),
Manifest.permission.WRITE_SETTINGS)
!= PackageManager.PERMISSION_GRANTED) {

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {

if (Settings.System.canWrite(getApplicationContext())) {
ActivityUtils.launchActivity(this, SendFormsActivity.class, false);
} else {
Intent intent = new Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS);
startActivity(intent);
}

} else {
ActivityUtils.launchActivity(this, SendFormsActivity.class, false);
}
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ public void send() {
}
}


private void setupSendingIntent(Intent intent) {
Long[] arr = selectedForms.toArray(new Long[selectedForms.size()]);
long[] a = ArrayUtils.toPrimitive(arr);
Expand Down