1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-23 12:51:16 +00:00

Handle missing permissions when clicking notification (ref #871)

This commit is contained in:
Felix Ableitner 2017-03-31 12:59:36 +09:00
parent 6e1b689fa9
commit fddc555a31

View file

@ -24,6 +24,7 @@ import android.widget.Toast;
import com.android.PRNGFixes; import com.android.PRNGFixes;
import com.google.common.io.Files; import com.google.common.io.Files;
import com.nutomic.syncthingandroid.R; import com.nutomic.syncthingandroid.R;
import com.nutomic.syncthingandroid.activities.FirstStartActivity;
import com.nutomic.syncthingandroid.activities.MainActivity; import com.nutomic.syncthingandroid.activities.MainActivity;
import com.nutomic.syncthingandroid.http.PollWebGuiAvailableTask; import com.nutomic.syncthingandroid.http.PollWebGuiAvailableTask;
import com.nutomic.syncthingandroid.model.Folder; import com.nutomic.syncthingandroid.model.Folder;
@ -264,12 +265,15 @@ public class SyncthingService extends Service implements
if ((mCurrentState == State.ACTIVE || mCurrentState == State.STARTING) && if ((mCurrentState == State.ACTIVE || mCurrentState == State.STARTING) &&
!type.equals("none")) { !type.equals("none")) {
Context appContext = getApplicationContext(); Context appContext = getApplicationContext();
// Launch FirstStartActivity instead of MainActivity so we can request permission if
// necessary.
PendingIntent pi = PendingIntent.getActivity(appContext, 0,
new Intent(appContext, FirstStartActivity.class), 0);
NotificationCompat.Builder builder = new NotificationCompat.Builder(appContext) NotificationCompat.Builder builder = new NotificationCompat.Builder(appContext)
.setContentTitle(getString(R.string.syncthing_active)) .setContentTitle(getString(R.string.syncthing_active))
.setSmallIcon(R.drawable.ic_stat_notify) .setSmallIcon(R.drawable.ic_stat_notify)
.setOngoing(true) .setOngoing(true)
.setContentIntent(PendingIntent.getActivity(appContext, 0, .setContentIntent(pi);
new Intent(appContext, MainActivity.class), 0));
if (type.equals("low_priority")) if (type.equals("low_priority"))
builder.setPriority(NotificationCompat.PRIORITY_MIN); builder.setPriority(NotificationCompat.PRIORITY_MIN);