Skip to content

Commit

Permalink
Merge pull request #228 from adeekshith/issue/222/remove-whatsapp-ori…
Browse files Browse the repository at this point in the history
…ginal-notification-2

Remove WhatsApp original notification and enable notification for new installs

public: Enable notification for new installs
public: Clicking on notification group now opens the app
  • Loading branch information
adeekshith authored Apr 26, 2021
2 parents 438c9ca + 5daca6b commit c8c3718
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 20 deletions.
6 changes: 6 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

<uses-permission android:name="android.permission.INTERNET" />

<queries>
<!-- Specific apps Watomatic interacts with. Required for Android 11+ -->
<package android:name="com.whatsapp" />
<package android:name="com.facebook.orca" />
</queries>

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,7 @@ public int onStartCommand(Intent intent, int flags, int startId) {
}

private void sendReply(StatusBarNotification sbn) {
NotificationWear notificationWear;
if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O){
notificationWear = extractQuickReplyNotification(sbn);
}else{
notificationWear = extractWearNotification(sbn);
}
NotificationWear notificationWear = extractWearNotification(sbn);
// Possibly transient or non-user notification from WhatsApp like
// "Checking for new messages" or "WhatsApp web is Active"
if (notificationWear.getRemoteInputs().isEmpty()) { return;}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,6 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c

createSupportedAppCheckboxes();

// TODO Hide incomplete facebook support issue #117
if (!Constants.BETA_FACEBOOK_SUPPORT_ENABLED) {
supportedAppsCard.setVisibility(View.GONE);
}

return view;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@ private void init () {
KEY_IS_SHOW_NOTIFICATIONS_ENABLED = thisAppContext.getString(R.string.pref_show_notification_replied_msg);

// For new installs, enable all the supported apps
if (Constants.BETA_FACEBOOK_SUPPORT_ENABLED) {
boolean newInstall = !_sharedPrefs.contains(KEY_SERVICE_ENABLED)
&& !_sharedPrefs.contains(KEY_SELECTED_APPS_ARR);
if (newInstall) {
setAppsAsEnabled(Constants.SUPPORTED_APPS);
}
boolean newInstall = !_sharedPrefs.contains(KEY_SERVICE_ENABLED)
&& !_sharedPrefs.contains(KEY_SELECTED_APPS_ARR);
if (newInstall) {
// Enable all supported apps for new install
setAppsAsEnabled(Constants.SUPPORTED_APPS);

// Set notifications ON for new installs
setShowNotificationPref(true);
}

if (isFirstInstall(thisAppContext)) {
Expand Down Expand Up @@ -194,6 +196,12 @@ public boolean isShowNotificationEnabled(){
return _sharedPrefs.getBoolean(KEY_IS_SHOW_NOTIFICATIONS_ENABLED,false);
}

public void setShowNotificationPref(boolean enabled){
SharedPreferences.Editor editor = _sharedPrefs.edit();
editor.putBoolean(KEY_IS_SHOW_NOTIFICATIONS_ENABLED, enabled);
editor.apply();
}

public int getGithubReleaseNotesId(){
return _sharedPrefs.getInt(KEY_GITHUB_RELEASE_NOTES_ID,0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void sendNotification(String title, String message, String packageName){
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(appContext, Constants.NOTIFICATION_CHANNEL_ID)
.setGroup("watomatic-" + packageName)
.setGroupSummary(false)
.setSmallIcon(R.drawable.ic_launcher_foreground)
.setSmallIcon(R.drawable.ic_logo_full)
.setContentTitle(title)
.setContentText(message)
.setAutoCancel(true)
Expand Down Expand Up @@ -99,8 +99,9 @@ public void sendNotification(String title, String message, String packageName){
NotificationCompat.Builder summaryNotificationBuilder = new NotificationCompat.Builder(appContext, Constants.NOTIFICATION_CHANNEL_ID)
.setGroup("watomatic-" + packageName)
.setGroupSummary(true)
.setSmallIcon(R.drawable.ic_launcher_foreground)
.setAutoCancel(true);
.setSmallIcon(R.drawable.ic_logo_full)
.setAutoCancel(true)
.setContentIntent(pIntent);
notificationManager.notify(notifId + 1, summaryNotificationBuilder.build());
}
} catch (JSONException e) {
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_logo_full.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:pathData="M88.65,2.098A6.675,6.675 0,0 0,82.785 5.533A6.675,6.675 0,0 0,83.945 13.531L78.9,22.268A50.06,42.758 0,0 0,52.723 16.617A50.06,42.758 0,0 0,27.879 22.885L23.443,15.201A6.675,6.675 0,0 0,24.547 7.104L24.428,6.908A6.675,6.675 0,0 0,18.834 3.762A6.675,6.675 0,0 0,15.283 4.746A6.675,6.675 0,0 0,13.041 13.875A6.675,6.675 0,0 0,20.553 16.867L24.973,24.525A50.06,42.758 0,0 0,3.947 60.088A50.06,42.758 0,0 0,17.752 88.85C17.546,93.514 16.604,99.004 5.105,105.902C13.011,105.043 14.13,107.619 32.01,97.771A50.06,42.758 0,0 0,54.426 102.117A50.06,42.758 0,0 0,104.061 59.361L104.031,57.906A50.06,42.758 0,0 0,81.855 23.832L86.838,15.201A6.675,6.675 0,0 0,94.4 12.109L94.512,11.908A6.675,6.675 0,0 0,91.811 2.908A6.675,6.675 0,0 0,88.65 2.098zM25.588,34.453L82.412,34.453C89.782,34.453 95.717,40.388 95.717,47.758L95.717,47.848C95.717,55.218 89.782,61.152 82.412,61.152L25.588,61.152C18.218,61.152 12.283,55.218 12.283,47.848L12.283,47.758C12.283,40.388 18.218,34.453 25.588,34.453zM25.594,36.121C19.145,36.121 13.953,41.315 13.953,47.764L13.953,47.842C13.953,54.29 19.145,59.482 25.594,59.482L82.406,59.482C88.855,59.482 94.047,54.29 94.047,47.842L94.047,47.764C94.047,41.315 88.855,36.121 82.406,36.121L25.594,36.121zM30.336,39.459A8.343,8.343 0,0 1,38.645 47.52L38.648,47.803A8.343,8.343 0,0 1,30.377 56.146A8.343,8.343 0,0 1,21.963 47.945A8.343,8.343 0,0 1,30.094 39.463A8.343,8.343 0,0 1,30.336 39.459zM77.725,39.459A8.343,8.343 0,0 1,86.033 47.52L86.037,47.803A8.343,8.343 0,0 1,77.766 56.146A8.343,8.343 0,0 1,69.352 47.945A8.343,8.343 0,0 1,77.48 39.463A8.343,8.343 0,0 1,77.725 39.459z"
android:strokeWidth="3.33731"
android:fillColor="#0192ea"/>
</vector>

0 comments on commit c8c3718

Please sign in to comment.