Skip to content

Commit

Permalink
implemented notification with customization
Browse files Browse the repository at this point in the history
NMC-2250: Notification tray icon customized
  • Loading branch information
AkshayChaurasia98 authored and surinder-tsys committed Dec 16, 2024
1 parent 9f7370f commit 157b1d5
Show file tree
Hide file tree
Showing 15 changed files with 242 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ class GeneratePdfFromImagesWork(
.setContentText(message)
.setAutoCancel(true)

viewThemeUtils.androidx.themeNotificationCompatBuilder(appContext, notificationBuilder)
// NMC Customization
notificationBuilder.color = appContext.resources.getColor(R.color.primary, null)

notificationManager.notify(notificationId, notificationBuilder.build())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ class FilesExportWork(
.setContentTitle(message)
.setAutoCancel(true)

viewThemeUtils.androidx.themeNotificationCompatBuilder(appContext, notificationBuilder)
// NMC Customization
notificationBuilder.color = appContext.resources.getColor(R.color.primary, null)

val actionIntent = Intent(DownloadManager.ACTION_VIEW_DOWNLOADS).apply {
flags = FLAG_ACTIVITY_NEW_TASK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ class MediaFoldersDetectionWork constructor(
.setAutoCancel(true)
.setContentIntent(pendingIntent)

viewThemeUtils.androidx.themeNotificationCompatBuilder(context, notificationBuilder)
// NMC Customization
notificationBuilder.color = context.resources.getColor(R.color.primary, null)

val disableDetection = Intent(context, NotificationReceiver::class.java)
disableDetection.putExtra(NOTIFICATION_ID, notificationId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ class NotificationWork constructor(
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
.setContentIntent(pendingIntent)

viewThemeUtils.androidx.themeNotificationCompatBuilder(context, notificationBuilder)
// NMC Customization
notificationBuilder.color = context.resources.getColor(R.color.primary, null)

// Remove
if (notification.getActions().isEmpty()) {
Expand Down Expand Up @@ -219,9 +220,8 @@ class NotificationWork constructor(
.setAutoCancel(true)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setContentIntent(pendingIntent)
.also {
viewThemeUtils.androidx.themeNotificationCompatBuilder(context, it)
}
// NMC Customization
.setColor(context.resources.getColor(R.color.primary, null))
.build()
)
val notificationManager = NotificationManagerCompat.from(context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ class PlayerService : Service() {
AndroidInjection.inject(this)
player = Player(applicationContext, clientFactory, playerListener, audioManager)
notificationBuilder = NotificationCompat.Builder(this)
viewThemeUtils.androidx.themeNotificationCompatBuilder(this, notificationBuilder)
// NMC Customization
notificationBuilder.color = resources.getColor(R.color.primary, null)

val stop = Intent(this, PlayerService::class.java).apply {
action = ACTION_STOP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class AppNotificationManagerImpl @Inject constructor(
} else {
NotificationCompat.Builder(context)
}
viewThemeUtils.androidx.themeNotificationCompatBuilder(context, builder)
// NMC Customization
builder.color = context.resources.getColor(R.color.primary, null)
return builder
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,8 @@ private void notifyForgottenLocalFiles() {
private NotificationCompat.Builder createNotificationBuilder() {
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getContext());
notificationBuilder.setSmallIcon(R.drawable.notification_icon).setAutoCancel(true);
viewThemeUtils.androidx.themeNotificationCompatBuilder(getContext(), notificationBuilder);
// NMC Customization
notificationBuilder.setColor(getContext().getResources().getColor(R.color.primary, null));
return notificationBuilder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,17 @@ class NotificationsActivity : AppCompatActivity(), NotificationsContract.View, I
Snackbar.LENGTH_INDEFINITE
)
} else {
val pushValue = arbitraryDataProvider.getValue(accountName, PushUtils.KEY_PUSH)
// NMC Note -> Need to disable this error message for now as we will configure our
// own push notification server later not now
// once we will configure our server we will uncomment the below code.
/* val pushValue = arbitraryDataProvider.getValue(accountName, PushUtils.KEY_PUSH)
if (pushValue.isEmpty()) {
snackbar = Snackbar.make(
binding.emptyList.emptyListView,
R.string.push_notifications_temp_error,
Snackbar.LENGTH_INDEFINITE
)
}
}*/
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,11 @@ public void setButtons(NotificationViewHolder holder, Notification notification)
}
});

viewThemeUtils.material.colorMaterialButtonPrimaryFilled(button);
//NMC Customization
button.setBackgroundColor(ResourcesCompat.getColor(resources,
R.color.shared_with_me_color, null));
button.setTextColor(ResourcesCompat.getColor(resources,
R.color.white, null));
holder.binding.buttons.addView(button);
} else {
overflowActions.add(action);
Expand All @@ -220,8 +224,12 @@ public void setButtons(NotificationViewHolder holder, Notification notification)
moreButton.setBackgroundColor(ResourcesCompat.getColor(resources,
android.R.color.transparent,
null));
viewThemeUtils.material.colorMaterialButtonPrimaryBorderless(moreButton);

//NMC Customization
moreButton.setBackgroundColor(ResourcesCompat.getColor(resources,
android.R.color.transparent,
null));
moreButton.setTextColor(ResourcesCompat.getColor(resources,
R.color.shared_with_me_color, null));
moreButton.setAllCaps(false);

moreButton.setText(R.string.more);
Expand Down Expand Up @@ -263,12 +271,16 @@ public void setButtons(NotificationViewHolder holder, Notification notification)
final MaterialButton button = new MaterialButton(notificationsActivity);

if (action.primary) {
viewThemeUtils.material.colorMaterialButtonPrimaryFilled(button);
button.setBackgroundColor(ResourcesCompat.getColor(resources,
R.color.shared_with_me_color, null));
button.setTextColor(ResourcesCompat.getColor(resources,
R.color.white, null));
} else {
button.setBackgroundColor(ResourcesCompat.getColor(resources,
android.R.color.transparent,
null));
viewThemeUtils.material.colorMaterialButtonPrimaryBorderless(button);
button.setTextColor(ResourcesCompat.getColor(resources,
R.color.shared_with_me_color, null));
}

button.setAllCaps(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import android.os.HandlerThread;
import android.os.Process;

import com.owncloud.android.R;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.utils.theme.ViewThemeUtils;

Expand Down Expand Up @@ -56,7 +57,8 @@ private NotificationUtils() {
*/
public static NotificationCompat.Builder newNotificationBuilder(Context context, String channelId, final ViewThemeUtils viewThemeUtils) {
final NotificationCompat.Builder builder = new NotificationCompat.Builder(context, channelId);
viewThemeUtils.androidx.themeNotificationCompatBuilder(context, builder);
// NMC Customization
builder.setColor(context.getResources().getColor(R.color.primary, null));
return builder;
}

Expand Down
15 changes: 9 additions & 6 deletions app/src/main/res/drawable/ic_notification.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#333333"
android:viewportWidth="960"
android:viewportHeight="960">
android:tint="@color/notification_icon_color"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M160,760L160,680L240,680L240,400Q240,317 290,252.5Q340,188 420,168L420,140Q420,115 437.5,97.5Q455,80 480,80Q505,80 522.5,97.5Q540,115 540,140L540,168Q620,188 670,252.5Q720,317 720,400L720,680L800,680L800,760L160,760ZM480,880Q447,880 423.5,856.5Q400,833 400,800L560,800Q560,833 536.5,856.5Q513,880 480,880Z" />
</vector>
android:pathData="M21.25,17.25C19.6384,15.6405 18.6407,13.5179 18.43,11.25L18.27,9.5C18.0256,6.7093 15.9678,4.4152 13.22,3.87C13.665,3.2479 13.5706,2.3905 13.0009,1.8801C12.4313,1.3697 11.5687,1.3697 10.9991,1.8801C10.4294,2.3905 10.335,3.2479 10.78,3.87C8.0322,4.4152 5.9744,6.7093 5.73,9.5L5.57,11.255C5.3593,13.5229 4.3616,15.6455 2.75,17.255L2.75,17.255L2.75,19.755L8.25,19.755C8.245,19.8383 8.245,19.9217 8.25,20.005C8.25,22.0761 9.9289,23.755 12,23.755C14.0711,23.755 15.75,22.0761 15.75,20.005C15.755,19.9217 15.755,19.8383 15.75,19.755L21.25,19.755L21.25,17.25ZM14.25,20C14.25,21.2426 13.2426,22.25 12,22.25C10.7574,22.25 9.75,21.2426 9.75,20C9.7534,19.9162 9.7617,19.8328 9.775,19.75L14.225,19.75C14.2383,19.8328 14.2466,19.9162 14.25,20Z"
android:strokeWidth="1"
android:fillColor="#191919"
android:fillType="evenOdd"
android:strokeColor="#00000000"/>
</vector>
3 changes: 2 additions & 1 deletion app/src/main/res/layout/notification_list_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:paddingBottom="@dimen/standard_quarter_padding"
android:textColor="@color/secondary_text_color"
android:textSize="@dimen/text_size_13sp"
tools:text="@string/placeholder_sentence" />
Expand All @@ -69,7 +70,7 @@
android:id="@+id/buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/standard_quarter_margin"
android:layout_marginTop="@dimen/alternate_half_margin"
android:layout_marginEnd="@dimen/notification_list_item_grid_layout_left_start_margin"
android:columnCount="3"
android:gravity="start"
Expand Down
67 changes: 67 additions & 0 deletions app/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
<color name="icon_on_nc_grey">#ffffff</color>
<color name="foreground_highlight">#EAE0E5</color>

<!-- Notification Colors -->
<color name="notification_icon_color">@color/grey_30</color>

<!-- Multiselect backgrounds -->
<color name="action_mode_background">@color/appbar</color>
<color name="selected_item_background">#373535</color>
Expand All @@ -38,4 +41,68 @@
<color name="fontAppbar">@android:color/white</color>

<color name="actionbar_color">#101418</color>

<!-- NMC Colors -->
<color name="icon_color">#FFFFFF</color>
<color name="sort_text_color">@color/grey_30</color>
<color name="list_icon_color">@color/grey_30</color>
<color name="warning_icon_color">#CCCCCC</color>
<color name="divider_color">@color/grey_70</color>
<color name="spinner_bg_color">@color/grey_80</color>
<color name="refresh_layout_bg_color">#2D2D2D</color>
<color name="primary_button_disabled_color">@color/grey_70</color>
<color name="toolbar_divider_color">@color/grey_70</color>

<!-- Snackbar Colors -->
<color name="snackbar_bg_color">@color/grey_80</color>
<color name="snackbar_txt_color">@color/grey_0</color>

<!-- Alert Dialog Colors -->
<color name="alert_bg_color">@color/grey_80</color>
<color name="alert_txt_color">@color/grey_0</color>

<!-- NavigationView colors -->
<color name="nav_selected_bg_color">@color/grey_60</color>
<color name="nav_txt_unselected_color">@color/grey_0</color>
<color name="nav_txt_selected_color">@color/grey_0</color>
<color name="nav_icon_unselected_color">@color/grey_30</color>
<color name="nav_icon_selected_color">#FFFFFF</color>
<color name="nav_divider_color">@color/grey_30</color>
<color name="nav_bg_color">@color/grey_80</color>
<color name="drawer_quota_txt_color">#FFFFFF</color>

<!-- Bottom Sheet Colors -->
<color name="bottom_sheet_bg_color">@color/grey_80</color>
<color name="bottom_sheet_icon_color">@color/grey_30</color>
<color name="bottom_sheet_txt_color">@color/grey_0</color>

<!-- Popup Menu Colors -->
<color name="popup_menu_bg">@color/grey_80</color>
<color name="popup_menu_txt_color">@color/grey_0</color>
<color name="overflow_bg_color">@color/grey_80</color>

<!-- Switch Compat Colors -->
<color name="switch_thumb_disabled">@color/grey_70</color>
<color name="switch_track_disabled">@color/grey_60</color>

<!-- Checkbox Colors -->
<color name="checkbox_checked_disabled">@color/grey_70</color>
<color name="checkbox_unchecked_disabled">@color/grey_70</color>

<!-- Share Colors -->
<color name="share_title_txt_color">#FFFFFF</color>
<color name="share_subtitle_txt_color">@color/grey_30</color>
<color name="share_info_txt_color">@color/grey_0</color>
<color name="share_search_border_color">@color/grey_0</color>
<color name="share_btn_txt_color">@color/grey_0</color>
<color name="share_list_item_txt_color">@color/grey_0</color>
<color name="share_disabled_txt_color">@color/grey_60</color>
<color name="share_txt_color">@color/grey_0</color>
<color name="share_et_divider">#FFFFFF</color>

<!-- Scan Colors -->
<color name="scan_doc_bg_color">#121212</color>
<color name="scan_text_color">@color/grey_0</color>
<color name="scan_edit_bottom_color">@color/grey_80</color>
<color name="scan_count_bg_color">@color/grey_80</color>
</resources>
92 changes: 92 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
<color name="grey_600">#666666</color>
<color name="grey_800_transparent">#CC000000</color>

<!-- Notification Colors -->
<color name="notification_icon_color">#191919</color>

<!-- level colors for info notifications/visualisations -->
<color name="infolevel_warning">#e9322d</color>

Expand Down Expand Up @@ -78,4 +81,93 @@
<color name="fontSecondaryAppbar">#A5A5A5</color>

<color name="actionbar_color">#F7F9FF</color>

<!-- NMC Colors -->
<color name="icon_color">#191919</color>
<color name="sort_text_color">@color/primary</color>
<color name="list_icon_color">#191919</color>
<color name="warning_icon_color">#191919</color>
<color name="divider_color">@color/grey_30</color>
<color name="spinner_bg_color">@android:color/white</color>
<color name="refresh_layout_bg_color">#FFFFFF</color>
<color name="primary_button_disabled_color">@color/grey_0</color>
<color name="toolbar_divider_color">#CCCCCC</color>
<color name="et_highlight_color">#77c4ff</color>
<color name="white_trans_70">#B3FFFFFF</color>
<color name="progress_bar_background">@color/grey_10</color>

<!-- Grey Colors -->
<color name="dark_grey">#101010</color>
<color name="grey_0">#F2F2F2</color>
<color name="grey_10">#E5E5E5</color>
<color name="grey_30">#B2B2B2</color>
<color name="grey_60">#666666</color>
<color name="grey_70">#4C4C4C</color>
<color name="grey_80">#333333</color>

<!-- Snackbar Colors -->
<color name="snackbar_bg_color">@color/design_snackbar_background_color</color>
<color name="snackbar_txt_color">@color/white</color>

<!-- Alert Dialog Colors -->
<color name="alert_bg_color">#FFFFFF</color>
<color name="alert_txt_color">#191919</color>

<!-- NavigationView colors -->
<color name="nav_selected_bg_color">@color/grey_0</color>
<color name="nav_txt_unselected_color">#191919</color>
<color name="nav_txt_selected_color">@color/primary</color>
<color name="nav_icon_unselected_color">#191919</color>
<color name="nav_icon_selected_color">@color/primary</color>
<color name="nav_divider_color">@color/grey_30</color>
<color name="nav_bg_color">@color/white</color>
<color name="drawer_quota_txt_color">#191919</color>

<!-- Bottom Sheet Colors -->
<color name="bottom_sheet_bg_color">#FFFFFF</color>
<color name="bottom_sheet_icon_color">#191919</color>
<color name="bottom_sheet_txt_color">#191919</color>

<!-- Popup Menu Colors -->
<color name="popup_menu_bg">#FFFFFF</color>
<color name="popup_menu_txt_color">#191919</color>
<color name="overflow_bg_color">#FFFFFF</color>

<!-- Switch Compat Colors -->
<color name="switch_thumb_checked_enabled">@color/primary</color>
<color name="switch_track_checked_enabled">#F399C7</color>
<color name="switch_thumb_unchecked_enabled">#FFFFFF</color>
<color name="switch_track_unchecked_enabled">@color/grey_30</color>
<color name="switch_thumb_disabled">@color/grey_10</color>
<color name="switch_track_disabled">@color/grey_0</color>

<!-- Checkbox Colors -->
<color name="checkbox_checked_enabled">@color/primary</color>
<color name="checkbox_unchecked_enabled">@color/grey_30</color>
<color name="checkbox_checked_disabled">@color/grey_30</color>
<color name="checkbox_unchecked_disabled">#CCCCCC</color>

<!-- Share Colors -->
<color name="share_title_txt_color">#191919</color>
<color name="share_subtitle_txt_color">@color/grey_30</color>
<color name="share_info_txt_color">#191919</color>
<color name="share_search_border_color">#191919</color>
<color name="share_btn_txt_color">#191919</color>
<color name="share_list_item_txt_color">#191919</color>
<color name="share_disabled_txt_color">@color/grey_30</color>
<color name="share_txt_color">#191919</color>
<color name="share_et_divider">#000000</color>
<color name="share_warning_txt_color">#191919</color>
<color name="sharing_warning_bg_color">#F6E5EB</color>
<color name="sharing_warning_border_color">#C16F81</color>
<color name="share_color">#0D39DF</color>
<color name="shared_with_me_color">#0099ff</color>

<!-- Scan Colors -->
<color name="scan_doc_bg_color">@color/grey_0</color>
<color name="scan_text_color">#191919</color>
<color name="scan_edit_bottom_color">@color/grey_0</color>
<color name="scan_count_bg_color">@color/grey_30</color>
<color name="neptune">#77b6bb</color>
<color name="neptune_50">#5077b6bb</color>
</resources>
Loading

0 comments on commit 157b1d5

Please sign in to comment.