-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add conversation styling and shortcuts for Android 🤖 #47626
Merged
arosiclair
merged 16 commits into
Expensify:main
from
software-mansion-labs:conversation-style-notifications
Sep 16, 2024
Merged
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
ce49ad0
add conversation shortcuts and styling
staszekscp edd2587
Merge branch 'main' into conversation-style-notifications
Skalakid 676e2f7
Add Android native module
Skalakid 746b59a
Add dynamic shortcut clearing on signing out
Skalakid f7c30b0
Add iOS native module
Skalakid 0c41444
Merge branch 'main' into conversation-style-notifications
Skalakid ce11ee5
Undo patch changes
Skalakid c93af3c
Update JS module impoert
Skalakid c00ed8f
Add review changes
Skalakid 973934e
Add comment to iOS module
Skalakid 99d1162
Merge branch 'main' into conversation-style-notifications
Skalakid 7baac65
Merge branch 'main' into conversation-style-notifications
Skalakid bcfc0f5
Change shortcut reportID from string to long
Skalakid c8ac6fd
Merge branch 'main' into conversation-style-notifications
Skalakid 36cea30
Merge branch 'main' into conversation-style-notifications
Skalakid 729bc4a
Add review changes
Skalakid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...oid/app/src/main/java/com/expensify/chat/shortcutManagerModule/ShortcutManagerModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.expensify.chat.shortcutManagerModule; | ||
|
||
import static androidx.core.app.NotificationCompat.CATEGORY_MESSAGE; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.graphics.Bitmap; | ||
import android.net.Uri; | ||
import android.util.Log; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.core.app.Person; | ||
import androidx.core.content.pm.ShortcutInfoCompat; | ||
import androidx.core.content.pm.ShortcutManagerCompat; | ||
import androidx.core.graphics.drawable.IconCompat; | ||
|
||
import com.facebook.react.bridge.ReactApplicationContext; | ||
import com.facebook.react.bridge.ReactContextBaseJavaModule; | ||
import com.facebook.react.bridge.ReactMethod; | ||
|
||
import java.util.Collections; | ||
|
||
import com.expensify.chat.customairshipextender.CustomNotificationProvider; | ||
|
||
public class ShortcutManagerModule extends ReactContextBaseJavaModule { | ||
private ReactApplicationContext context; | ||
|
||
public ShortcutManagerModule(ReactApplicationContext context) { | ||
super(context); | ||
this.context = context; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public String getName() { | ||
return "ShortcutManager"; | ||
} | ||
|
||
@ReactMethod | ||
public void removeAllDynamicShortcuts() { | ||
ShortcutManagerUtils.removeAllDynamicShortcuts(context); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...id/app/src/main/java/com/expensify/chat/shortcutManagerModule/ShortcutManagerPackage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.expensify.chat.shortcutManagerModule; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import com.facebook.react.ReactPackage; | ||
import com.facebook.react.bridge.NativeModule; | ||
import com.facebook.react.bridge.ReactApplicationContext; | ||
import com.facebook.react.uimanager.ViewManager; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class ShortcutManagerPackage implements ReactPackage { | ||
|
||
@NonNull | ||
@Override | ||
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) { | ||
return Collections.emptyList(); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) { | ||
List<NativeModule> modules = new ArrayList<>(); | ||
modules.add(new ShortcutManagerModule(reactContext)); | ||
return modules; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
android/app/src/main/java/com/expensify/chat/shortcutManagerModule/ShortcutManagerUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.expensify.chat.shortcutManagerModule; | ||
|
||
import static androidx.core.app.NotificationCompat.CATEGORY_MESSAGE; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.graphics.Bitmap; | ||
import android.net.Uri; | ||
|
||
import androidx.core.app.Person; | ||
import androidx.core.content.pm.ShortcutInfoCompat; | ||
import androidx.core.content.pm.ShortcutManagerCompat; | ||
import androidx.core.graphics.drawable.IconCompat; | ||
|
||
import java.util.Collections; | ||
|
||
public class ShortcutManagerUtils { | ||
public static void removeAllDynamicShortcuts(Context context) { | ||
ShortcutManagerCompat.removeAllDynamicShortcuts(context); | ||
} | ||
|
||
public static void addDynamicShortcut(Context context, long reportID, String name, String accountID, Bitmap personIcon, Person person) { | ||
Intent intent = new Intent(Intent.ACTION_VIEW, | ||
Uri.parse("new-expensify://r/" + reportID)); | ||
|
||
ShortcutInfoCompat shortcutInfo = new ShortcutInfoCompat.Builder(context, accountID) | ||
.setShortLabel(name) | ||
.setLongLabel(name) | ||
.setCategories(Collections.singleton(CATEGORY_MESSAGE)) | ||
.setIntent(intent) | ||
.setLongLived(true) | ||
.setPerson(person) | ||
.setIcon(IconCompat.createWithBitmap(personIcon)) | ||
.build(); | ||
ShortcutManagerCompat.pushDynamicShortcut(context, shortcutInfo); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// RCTShortcutManagerModule.h | ||
#import <React/RCTBridgeModule.h> | ||
@interface RCTShortcutManagerModule : NSObject <RCTBridgeModule> | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// RCTCalendarModule.m | ||
// iOS doesn't have dynamic shortcuts like Android, so this module contains noop functions to prevent iOS from crashing | ||
#import "RCTShortcutManagerModule.h" | ||
|
||
@implementation RCTShortcutManagerModule | ||
|
||
RCT_EXPORT_METHOD(removeAllDynamicShortcuts){} | ||
|
||
RCT_EXPORT_MODULE(ShortcutManager); | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import {NativeModules} from 'react-native'; | ||
|
||
type ShortcutManagerModule = { | ||
removeAllDynamicShortcuts: () => void; | ||
}; | ||
|
||
const {ShortcutManager} = NativeModules; | ||
|
||
export type {ShortcutManagerModule}; | ||
|
||
export default ShortcutManager || | ||
({ | ||
removeAllDynamicShortcuts: () => {}, | ||
} as ShortcutManagerModule); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would probably be better to put this in PushNotification.deregister. Can we do a quick test to make sure it still works correctly from there?