Fix push notification styling backwards compatibility (#1729)
* Android Push notification style backwards compatible * Fix fastlane android release build
This commit is contained in:
parent
8673bc69c4
commit
64baa64057
6 changed files with 48 additions and 16 deletions
|
|
@ -1,4 +1,4 @@
|
|||
package com.mattermost.rnbeta.react_native_interface;
|
||||
package com.mattermost.react_native_interface;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.mattermost.rnbeta.react_native_interface;
|
||||
package com.mattermost.react_native_interface;
|
||||
|
||||
import com.facebook.react.bridge.Dynamic;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.mattermost.rnbeta.react_native_interface;
|
||||
package com.mattermost.react_native_interface;
|
||||
|
||||
import com.facebook.react.bridge.Promise;
|
||||
|
||||
|
|
@ -143,7 +143,15 @@ public class CustomPushNotification extends PushNotification {
|
|||
// First, get a builder initialized with defaults from the core class.
|
||||
final Notification.Builder notification = new Notification.Builder(mContext);
|
||||
Bundle bundle = mNotificationProps.asBundle();
|
||||
String title = bundle.getString("channel_name");
|
||||
String version = bundle.getString("version");
|
||||
|
||||
String title = null;
|
||||
if (version.equals("v2")) {
|
||||
title = bundle.getString("channel_name");
|
||||
} else {
|
||||
title = bundle.getString("title");
|
||||
}
|
||||
|
||||
if (android.text.TextUtils.isEmpty(title)) {
|
||||
ApplicationInfo appInfo = mContext.getApplicationInfo();
|
||||
title = mContext.getPackageManager().getApplicationLabel(appInfo).toString();
|
||||
|
|
@ -207,7 +215,13 @@ public class CustomPushNotification extends PushNotification {
|
|||
.setStyle(new Notification.BigTextStyle()
|
||||
.bigText(message));
|
||||
} else {
|
||||
String summaryTitle = String.format("(%d) %s", numMessages, title);
|
||||
String summaryTitle = null;
|
||||
|
||||
if (version.equals("v2")) {
|
||||
summaryTitle = String.format("(%d) %s", numMessages, title);
|
||||
} else {
|
||||
summaryTitle = String.format("%s (%d)", title, numMessages);
|
||||
}
|
||||
|
||||
Notification.InboxStyle style = new Notification.InboxStyle();
|
||||
List<Bundle> bundleArray = channelIdToNotification.get(channelId);
|
||||
|
|
@ -218,7 +232,9 @@ public class CustomPushNotification extends PushNotification {
|
|||
list = new ArrayList<Bundle>();
|
||||
}
|
||||
|
||||
style.addLine(message);
|
||||
if (version.equals("v2")) {
|
||||
style.addLine(message);
|
||||
}
|
||||
|
||||
for (Bundle data : list) {
|
||||
String msg = data.getString("message");
|
||||
|
|
@ -227,10 +243,17 @@ public class CustomPushNotification extends PushNotification {
|
|||
}
|
||||
}
|
||||
|
||||
notification
|
||||
.setContentTitle(summaryTitle)
|
||||
.setContentText(message)
|
||||
.setStyle(style);
|
||||
if (version.equals("v2")) {
|
||||
notification
|
||||
.setContentTitle(summaryTitle)
|
||||
.setContentText(message)
|
||||
.setStyle(style);
|
||||
} else {
|
||||
style.setBigContentTitle(message)
|
||||
.setSummaryText(String.format("+%d more", (numMessages - 1)));
|
||||
notification.setStyle(style)
|
||||
.setContentTitle(summaryTitle);
|
||||
}
|
||||
}
|
||||
|
||||
// Let's add a delete intent when the notification is dismissed
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ import com.facebook.react.bridge.ReactApplicationContext;
|
|||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
import com.facebook.react.bridge.WritableNativeMap;
|
||||
import com.mattermost.rnbeta.react_native_interface.AsyncStorageHelper;
|
||||
import com.mattermost.rnbeta.react_native_interface.KeysReadableArray;
|
||||
import com.mattermost.rnbeta.react_native_interface.ResolvePromise;
|
||||
import com.mattermost.react_native_interface.AsyncStorageHelper;
|
||||
import com.mattermost.react_native_interface.KeysReadableArray;
|
||||
import com.mattermost.react_native_interface.ResolvePromise;
|
||||
import com.oblador.keychain.KeychainModule;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
|
|||
|
|
@ -300,7 +300,7 @@ platform :android do
|
|||
|
||||
git_actions()
|
||||
|
||||
if ENV['MATTERMOST_WEBHOOK_URL']
|
||||
if ENV['MATTERMOST_WEBHOOK_URL'] && !ENV['MATTERMOST_WEBHOOK_URL'].nil? && !ENV['MATTERMOST_WEBHOOK_URL'].empty?
|
||||
pretext = '#### New Android beta published to Google Play'
|
||||
msg = '#android-beta available for testing, you can sign up as a beta tester [here](https://play.google.com/apps/testing/com.mattermost.rnbeta)'
|
||||
if !ENV['BETA_BUILD'].nil? && !ENV['BETA_BUILD'].empty? && ENV['BETA_BUILD'] != 'true'
|
||||
|
|
@ -342,14 +342,14 @@ platform :android do
|
|||
|
||||
android_install_path = "https://s3.#{ENV['AWS_REGION']}.amazonaws.com/#{ENV['AWS_BUCKET_NAME']}/android/#{abbreviated_commit_hash}.apk"
|
||||
|
||||
if ENV['MATTERMOST_WEBHOOK_URL']
|
||||
if ENV['MATTERMOST_WEBHOOK_URL'] && !ENV['MATTERMOST_WEBHOOK_URL'].nil? && !ENV['MATTERMOST_WEBHOOK_URL'].empty?
|
||||
msg = "QA build [#{abbreviated_commit_hash}](https://github.com/mattermost/mattermost-mobile/commit/#{abbreviated_commit_hash}) — Android: #{android_install_path}"
|
||||
mattermost(message: msg, username: 'Fastlane', icon_url: 'https://lh3.ggpht.com/XL0CrI8skkxnboGct-duyg-bZ_MxJDTrjczyjdU8OP2PM1dmj7SP4jL1K8JQeMIB3AM=w300')
|
||||
end
|
||||
end
|
||||
|
||||
error do |lane, exception|
|
||||
if ENV['MATTERMOST_WEBHOOK_URL']
|
||||
if ENV['MATTERMOST_WEBHOOK_URL'] && !ENV['MATTERMOST_WEBHOOK_URL'].nil? && !ENV['MATTERMOST_WEBHOOK_URL'].empty?
|
||||
send_message_for_android('', 'Unsuccessful Build', exception.message, [:lane], false)
|
||||
end
|
||||
end
|
||||
|
|
@ -410,6 +410,15 @@ platform :android do
|
|||
new_string: "package #{packageId};"
|
||||
)
|
||||
end
|
||||
|
||||
#
|
||||
Dir.glob('../android/app/src/main/java/com/mattermost/share/*.java') do |item|
|
||||
find_replace_string(
|
||||
path_to_file: item[1..-1],
|
||||
old_string: 'import com.mattermost.rnbeta.MainApplication;',
|
||||
new_string: "import #{packageId}.MainApplication;"
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue