diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 921b192f..38bf48db 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -7,6 +7,7 @@
+
diff --git a/app/src/main/java/com/nutomic/syncthingandroid/activities/FirstStartActivity.java b/app/src/main/java/com/nutomic/syncthingandroid/activities/FirstStartActivity.java
index abe050d4..80ad9437 100644
--- a/app/src/main/java/com/nutomic/syncthingandroid/activities/FirstStartActivity.java
+++ b/app/src/main/java/com/nutomic/syncthingandroid/activities/FirstStartActivity.java
@@ -14,6 +14,7 @@ import android.Manifest;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
+
import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
@@ -29,8 +30,6 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
-import android.view.Window;
-import android.view.WindowManager;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -44,7 +43,6 @@ import com.nutomic.syncthingandroid.util.PermissionUtil;
import com.nutomic.syncthingandroid.util.Util;
import java.io.File;
-import java.io.IOException;
import org.apache.commons.io.FileUtils;
@@ -53,10 +51,13 @@ import javax.inject.Inject;
public class FirstStartActivity extends Activity {
private enum Slide {
+
INTRO(R.layout.activity_firststart_slide_intro),
+
STORAGE(R.layout.activity_firststart_slide_storage),
LOCATION(R.layout.activity_firststart_slide_location),
- API_LEVEL_30(R.layout.activity_firststart_slide_api_level_30);
+ API_LEVEL_30(R.layout.activity_firststart_slide_api_level_30),
+ NOTIFICATION(R.layout.activity_firststart_slide_notification);
public final int layout;
@@ -191,6 +192,17 @@ public class FirstStartActivity extends Activity {
return mPreferences.getBoolean(Constants.PREF_FIRST_START, true);
}
+ @TargetApi(33)
+ private boolean isNotificationPermissionGranted() {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
+ return true;
+ }
+
+ return ActivityCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED;
+
+ }
+
+
private boolean upgradedToApiLevel30() {
if (mPreferences.getBoolean(Constants.PREF_UPGRADED_TO_API_LEVEL_30, false)) {
return true;
@@ -234,6 +246,9 @@ public class FirstStartActivity extends Activity {
// Skip if running as root, as that circumvents any Android FS restrictions.
return upgradedToApiLevel30()
|| PreferenceManager.getDefaultSharedPreferences(this).getBoolean(Constants.PREF_USE_ROOT, false);
+ case NOTIFICATION:
+ return isNotificationPermissionGranted();
+
}
return false;
}
@@ -328,6 +343,15 @@ public class FirstStartActivity extends Activity {
}
});
break;
+ case NOTIFICATION:
+ Button notificationBtn = (Button) view.findViewById(R.id.btn_notification);
+ notificationBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ requestNotificationPermission();
+ }
+ });
+ break;
}
container.addView(view);
@@ -364,7 +388,7 @@ public class FirstStartActivity extends Activity {
* so that back navigation works as expected.
*/
if (mPreferences.getBoolean(Constants.PREF_START_INTO_WEB_GUI, false)) {
- startActivities(new Intent[] {mainIntent, new Intent(this, WebGuiActivity.class)});
+ startActivities(new Intent[]{mainIntent, new Intent(this, WebGuiActivity.class)});
} else {
startActivity(mainIntent);
}
@@ -389,6 +413,13 @@ public class FirstStartActivity extends Activity {
Constants.PermissionRequestType.LOCATION.ordinal());
}
+ @TargetApi(33)
+ private void requestNotificationPermission() {
+ if (ActivityCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) {
+ requestPermissions(new String[]{Manifest.permission.POST_NOTIFICATIONS}, 1);
+ }
+ }
+
private void requestStoragePermission() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
requestAllFilesAccessPermission();
diff --git a/app/src/main/res/drawable/baseline_notifications_active_24.xml b/app/src/main/res/drawable/baseline_notifications_active_24.xml
new file mode 100644
index 00000000..36e224c4
--- /dev/null
+++ b/app/src/main/res/drawable/baseline_notifications_active_24.xml
@@ -0,0 +1,7 @@
+
+
+
diff --git a/app/src/main/res/layout/activity_firststart_slide_notification.xml b/app/src/main/res/layout/activity_firststart_slide_notification.xml
new file mode 100644
index 00000000..26e41db1
--- /dev/null
+++ b/app/src/main/res/layout/activity_firststart_slide_notification.xml
@@ -0,0 +1,68 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 338c9ba6..c6f5c590 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -823,5 +823,8 @@ Please report any problems you encounter via Github.
Browse
No sub folder is selected
Share device ID with
+ Syncthing requires your permission to show you notifications.Those are used to let you know about a new device connecting, or a new folder sharing request.
+ Notification permission
+ Enable Notification Permission