Skip to content

Commit

Permalink
Fix upload notification and bump version to 1.10 (11)
Browse files Browse the repository at this point in the history
  • Loading branch information
nning committed Jul 21, 2020
1 parent a9c9c06 commit a56984e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "net.orgizm.imgshr"
minSdkVersion 14
targetSdkVersion 28
versionCode 10
versionName "1.9"
versionCode 11
versionName "1.10"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

Expand Down
19 changes: 17 additions & 2 deletions app/src/main/java/net/orgizm/imgshr/ShareActivity.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package net.orgizm.imgshr;

import android.app.Activity;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
Expand Down Expand Up @@ -54,7 +56,16 @@ public void onCreate(Bundle savedInstanceState)
status = (TextView) findViewById(R.id.status);

nManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
nBuilder = new NotificationCompat.Builder(context);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Log.i("net.orgizm.imgshr", "ANDROID O");

NotificationChannel nChannel = new NotificationChannel("uploads", getString(R.string.notification_name), NotificationManager.IMPORTANCE_LOW);
nChannel.setDescription(getString(R.string.notification_description));
nManager.createNotificationChannel(nChannel);
}

nBuilder = new NotificationCompat.Builder(context, "uploads");

preferences = new Preferences(context);

Expand Down Expand Up @@ -129,7 +140,11 @@ public void run() {
@Override
public void run() {
try {
final String message = uploadImages(slug, nId);
String message = uploadImages(slug, nId);

if (message.equals("200 OK")) {
message = getString(R.string.upload_successful);
}

nBuilder.setContentText(message)
.setProgress(0, 0, false)
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@
<string name="add_gallery">Add gallery</string>
<string name="update_details">Update details</string>
<string name="share_url">Share URL</string>
<string name="notification_name">Image Uploads</string>
<string name="notification_description">Shows the image upload progress and status as notifications</string>
<string name="upload_successful">Upload successfully finished!</string>
</resources>

0 comments on commit a56984e

Please sign in to comment.