mirror of https://github.com/perkeep/perkeep.git
clients/android: bump targetSdkVersion to 26
Because it is mandatory as of nov 2018: https://android-developers.googleblog.com/2017/12/improving-app-security-and-performance.html As the default Notification.Builder constructor is deprecated in API 26, this change also adds the use of the new constructor, which requires a notification channel Id. Note: since the users are now in full-control of the notifications, they can now choose to completely block the auto-upload notification channel. Given that the main goal of the notification was to keep the app in memory in order for auto-upload to work, one could expect that blocking the channel would defeat the notification's purpose. However, as far as I could test, auto-uploading seems to still be working even after disabling the channel, and letting the activity die (tip: in devoloper options, one can tick "Don't keep activities"). In fact, Perkeep Uploader still always runs as a service. Also build pk-put shipped in the app with Go 1.11. Fixes #1202 Change-Id: I8f98e0df742915cb504b6c1cfaa42ca6dc7b6189
This commit is contained in:
parent
ca7f2e57e3
commit
965aeaca33
|
@ -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'
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
android:versionCode="2"
|
||||
android:versionName="0.6.1">
|
||||
|
||||
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="25" />
|
||||
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="26" />
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
|
|
@ -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<QueuedFile, Long> mFileBytesRemain = new HashMap<QueuedFile, Long>();
|
||||
private final LinkedList<QueuedFile> mQueueList = new LinkedList<QueuedFile>();
|
||||
|
@ -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);
|
||||
|
|
|
@ -37,7 +37,8 @@
|
|||
<string name="results">Results</string>
|
||||
<string name="settings_auto_required_ssid">Required SSID</string>
|
||||
<string name="notification_title">Perkeep auto-uploader</string>
|
||||
<string name="channel_name">Perkeep channel</string>
|
||||
<string name="channel_description">Perkeep channel</string>
|
||||
<string name="channel_id">perkeep auto-upload channel</string>
|
||||
<string name="channel_name">Auto-upload state</string>
|
||||
<string name="channel_description">State of Perkeep auto-uploader</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue