Skip to content

Commit

Permalink
modify notification
Browse files Browse the repository at this point in the history
  • Loading branch information
sunfusheng committed Feb 21, 2018
1 parent 6cb447a commit a9da435
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 6 deletions.
2 changes: 0 additions & 2 deletions FirUpdater/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:' + gradle.supportLibraryVersion
}

Expand Down
1 change: 1 addition & 0 deletions FirUpdater/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

<application>

Expand Down
20 changes: 20 additions & 0 deletions FirUpdater/src/main/java/com/sunfusheng/FirNotification.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
package com.sunfusheng;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.v4.app.NotificationCompat;

import static android.support.v4.app.NotificationCompat.DEFAULT_LIGHTS;
import static android.support.v4.app.NotificationCompat.VISIBILITY_PUBLIC;

/**
* @author sunfusheng on 2018/2/17.
*/
Expand All @@ -22,11 +29,24 @@ public void createBuilder(Context context) {
this.context = context;
manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
builder = new NotificationCompat.Builder(context, CHANNEL_ID);
builder.setTicker("正在下载");
builder.setSmallIcon(android.R.drawable.stat_sys_download);
Drawable icon = FirUpdaterUtils.getIcon(context);
if (icon != null && icon instanceof BitmapDrawable) {
builder.setLargeIcon(((BitmapDrawable) icon).getBitmap());
}
builder.setAutoCancel(false);
builder.setOngoing(true);
builder.setProgress(100, 0, false);
builder.setWhen(System.currentTimeMillis());
PendingIntent pendingIntent = PendingIntent.getActivity(context, 1, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT);
builder.setFullScreenIntent(pendingIntent, false);
builder.setVisibility(VISIBILITY_PUBLIC);
builder.setContentIntent(pendingIntent);
builder.setDefaults(DEFAULT_LIGHTS);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
builder.setPriority(Notification.PRIORITY_HIGH);
}
}

public void setContentTitle(String title) {
Expand Down
2 changes: 1 addition & 1 deletion Sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ dependencies {
implementation 'com.android.support:design:' + gradle.supportLibraryVersion
implementation 'com.sunfusheng:GroupRecyclerViewAdapter:1.0.2'
implementation project(":FirUpdater")
// implementation'com.sunfusheng:FirUpdater:1.0.3'
// implementation'com.sunfusheng:FirUpdater:1.0.4'
}
Binary file modified Sample/outputs/FirUpdater.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ buildscript {
repositories {
google()
jcenter()
// maven { url 'https://dl.bintray.com/sfsheng0322/maven' }
maven { url 'https://dl.bintray.com/sfsheng0322/maven' }
}

dependencies {
Expand All @@ -15,7 +15,7 @@ allprojects {
repositories {
google()
jcenter()
// maven { url 'https://dl.bintray.com/sfsheng0322/maven' }
maven { url 'https://dl.bintray.com/sfsheng0322/maven' }
}
}

Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ gradle.ext.supportLibraryVersion = '27.0.2'
gradle.ext.minSdkVersion = 14
gradle.ext.targetSdkVersion = 27
gradle.ext.versionCode = 5
gradle.ext.versionName = "1.0.4"
gradle.ext.versionName = '1.0.4'

0 comments on commit a9da435

Please sign in to comment.