diff --git a/clients/android/app/build.gradle b/clients/android/app/build.gradle index ede569e63..4075334af 100644 --- a/clients/android/app/build.gradle +++ b/clients/android/app/build.gradle @@ -34,7 +34,7 @@ android { minSdkVersion 14 // Stay below API 26 for a while, because it deprecates the Notification Builder // constructor we're using. - targetSdkVersion 21 + targetSdkVersion 26 // integer. used by android to prevent downgrades. not seen by user. versionCode 4 // version shown to the user in play store. @@ -49,6 +49,6 @@ android { dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation 'com.android.support:appcompat-v7:25.0.0' - implementation 'com.android.support:support-compat:25.0.0' + implementation 'com.android.support:appcompat-v7:26.0.0' + implementation 'com.android.support:support-compat:26.0.0' } diff --git a/clients/android/app/src/main/AndroidManifest.xml b/clients/android/app/src/main/AndroidManifest.xml index 2bbf0815e..11f562d39 100644 --- a/clients/android/app/src/main/AndroidManifest.xml +++ b/clients/android/app/src/main/AndroidManifest.xml @@ -7,7 +7,7 @@ android:versionCode="2" android:versionName="0.6.1"> - + diff --git a/clients/android/app/src/main/java/org/camlistore/UploadService.java b/clients/android/app/src/main/java/org/camlistore/UploadService.java index 3e72032df..6db858d9a 100644 --- a/clients/android/app/src/main/java/org/camlistore/UploadService.java +++ b/clients/android/app/src/main/java/org/camlistore/UploadService.java @@ -31,6 +31,7 @@ import org.camlistore.UploadThread.CamputChunkUploadedMessage; import org.camlistore.UploadThread.CamputStatsMessage; import android.app.Notification; +import android.app.NotificationChannel; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; @@ -40,6 +41,7 @@ import android.content.Intent; import android.database.Cursor; import android.net.Uri; import android.net.wifi.WifiManager; +import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.os.FileObserver; @@ -72,6 +74,7 @@ public class UploadService extends Service { // thread exits private Notification.Builder mNotificationBuilder; // null until upload is // started/resumed + private NotificationChannel mNotificationChannel; private int mLastNotificationProgress = 0; // last computed value of the uploaded bytes, to avoid excessive notification updates private final Map mFileBytesRemain = new HashMap(); private final LinkedList mQueueList = new LinkedList(); @@ -130,11 +133,20 @@ public class UploadService extends Service { stackBuilder.addNextIntent(notificationIntent); PendingIntent pendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); - autoUploadNotif = - // TODO(mpl): use API 26 Constructor with a notification channel later, when - // Android >=8 is more widely distributed. - new Notification.Builder(this) - .setContentTitle(getText(R.string.notification_title)) + // Create the NotificationChannel, but only on API 26+ because + // the NotificationChannel class is new and not in the support library + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + mNotificationChannel = new NotificationChannel(getString(R.string.channel_id), + getText(R.string.channel_name), NotificationManager.IMPORTANCE_DEFAULT); + mNotificationChannel.setDescription(getString(R.string.channel_description)); + // Register the channel with the system; you can't change the importance + // or other notification behaviors after this + mNotificationManager.createNotificationChannel(mNotificationChannel); + autoUploadNotif = new Notification.Builder(this, getString(R.string.channel_id)); + } else { + autoUploadNotif = new Notification.Builder(this); + } + autoUploadNotif.setContentTitle(getText(R.string.notification_title)) .setContentText(notificationMessage()) .setSmallIcon(R.drawable.ic_stat_notify) .setContentIntent(pendingIntent); diff --git a/clients/android/app/src/main/res/values/strings.xml b/clients/android/app/src/main/res/values/strings.xml index 64f398927..b116648d1 100644 --- a/clients/android/app/src/main/res/values/strings.xml +++ b/clients/android/app/src/main/res/values/strings.xml @@ -37,7 +37,8 @@ Results Required SSID Perkeep auto-uploader - Perkeep channel - Perkeep channel + perkeep auto-upload channel + Auto-upload state + State of Perkeep auto-uploader diff --git a/clients/android/devenv/Dockerfile b/clients/android/devenv/Dockerfile index 158cdf9e5..1c381de6c 100644 --- a/clients/android/devenv/Dockerfile +++ b/clients/android/devenv/Dockerfile @@ -37,9 +37,9 @@ RUN echo y | $ANDROID_HOME/tools/bin/sdkmanager 'ndk-bundle' # Get Go stable release WORKDIR $GOPHER -RUN curl -O https://storage.googleapis.com/golang/go1.9.3.linux-amd64.tar.gz -RUN echo 'a4da5f4c07dfda8194c4621611aeb7ceaab98af0b38bfb29e1be2ebb04c3556c go1.9.3.linux-amd64.tar.gz' | sha256sum -c -RUN tar -xzf go1.9.3.linux-amd64.tar.gz +RUN curl -O https://storage.googleapis.com/golang/go1.11.linux-amd64.tar.gz +RUN echo 'b3fcf280ff86558e0559e185b601c9eade0fd24c900b4c63cd14d1d38613e499 go1.11.linux-amd64.tar.gz' | sha256sum -c +RUN tar -xzf go1.11.linux-amd64.tar.gz ENV GOPATH $GOPHER ENV GOROOT $GOPHER/go ENV PATH $PATH:$GOROOT/bin:$GOPHER/bin