-
Notifications
You must be signed in to change notification settings - Fork 909
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
Show Bottomsheet when no notification permission #17002
Merged
sujitacharya2005
merged 1 commit into
master
from
27795_Show_Bottomsheetwhen_no_notification_permission
Feb 19, 2023
Merged
Changes from all commits
Commits
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
77 changes: 77 additions & 0 deletions
77
android/java/org/chromium/chrome/browser/notifications/RewardsYouAreNotEarningDialog.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,77 @@ | ||
/* Copyright (c) 2023 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
package org.chromium.chrome.browser.notifications; | ||
|
||
import android.graphics.Color; | ||
import android.graphics.drawable.ColorDrawable; | ||
import android.os.Bundle; | ||
import android.view.Gravity; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.view.Window; | ||
import android.view.WindowManager; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
|
||
import org.chromium.chrome.R; | ||
import org.chromium.chrome.browser.BraveDialogFragment; | ||
|
||
public class RewardsYouAreNotEarningDialog extends BraveDialogFragment { | ||
public static final String RewardsYouAreNotEarningDialogTAG = | ||
"RewardsYouAreNotEarningDialogTag"; | ||
|
||
public static RewardsYouAreNotEarningDialog newInstance() { | ||
RewardsYouAreNotEarningDialog fragment = new RewardsYouAreNotEarningDialog(); | ||
Bundle args = new Bundle(); | ||
fragment.setArguments(args); | ||
return fragment; | ||
} | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
} | ||
|
||
@Override | ||
public View onCreateView( | ||
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | ||
View view = inflater.inflate(R.layout.rewards_you_are_not_earning_dialog, container, false); | ||
if (getDialog() != null && getDialog().getWindow() != null) { | ||
getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); | ||
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); | ||
Window window = getDialog().getWindow(); | ||
WindowManager.LayoutParams wlp = window.getAttributes(); | ||
wlp.y = 50; | ||
wlp.gravity = Gravity.BOTTOM; | ||
wlp.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND; | ||
window.setAttributes(wlp); | ||
} | ||
return view; | ||
} | ||
|
||
@Override | ||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | ||
clickOnCloseButton(view); | ||
clickOnTurnOnButton(view); | ||
} | ||
|
||
private void clickOnCloseButton(View view) { | ||
ImageView closeButton = view.findViewById(R.id.notification_disabled_close_button); | ||
closeButton.setOnClickListener((v) -> { dismiss(); }); | ||
} | ||
|
||
private void clickOnTurnOnButton(View view) { | ||
TextView turnOnButton = view.findViewById(R.id.turn_on_button); | ||
turnOnButton.setOnClickListener((v) -> { | ||
dismiss(); | ||
BravePermissionUtils.notificationSettingPage(getContext()); | ||
}); | ||
} | ||
} |
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
10 changes: 10 additions & 0 deletions
10
android/java/res/drawable/ic_rewards_noti_warning_circle.xml
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,10 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="40dp" | ||
android:height="40dp" | ||
android:viewportWidth="40" | ||
android:viewportHeight="40"> | ||
<path | ||
android:pathData="M20,40C8.972,40 0,31.028 0,20C0,8.972 8.972,0 20,0C31.028,0 40,8.972 40,20C40,31.028 31.028,40 20,40ZM20,3.333C10.81,3.333 3.333,10.81 3.333,20C3.333,29.19 10.81,36.667 20,36.667C29.19,36.667 36.667,29.19 36.667,20C36.667,10.81 29.19,3.333 20,3.333ZM20,31.667C19.567,31.667 19.133,31.483 18.817,31.183C18.515,30.867 18.333,30.433 18.333,30C18.333,29.55 18.515,29.133 18.817,28.817C19.433,28.2 20.55,28.2 21.183,28.817C21.483,29.133 21.667,29.55 21.667,30C21.667,30.433 21.483,30.867 21.183,31.183C20.867,31.483 20.433,31.667 20,31.667ZM20,25C19.078,25 18.333,24.253 18.333,23.333V10C18.333,9.08 19.078,8.333 20,8.333C20.922,8.333 21.667,9.08 21.667,10V23.333C21.667,24.253 20.922,25 20,25Z" | ||
android:fillColor="#EA3A0D" | ||
android:fillType="evenOdd"/> | ||
</vector> |
12 changes: 12 additions & 0 deletions
12
android/java/res/drawable/you_are_not_earning_rewards_background.xml
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,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Copyright (c) 2023 The Brave Authors. All rights reserved. | ||
This Source Code Form is subject to the terms of the Mozilla Public | ||
License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
You can obtain one at https://mozilla.org/MPL/2.0/. | ||
--> | ||
|
||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
<solid android:color="@color/you_are_not_earning_rewards_bg_color" /> | ||
<corners android:radius="16dp" /> | ||
</shape> |
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
85 changes: 85 additions & 0 deletions
85
android/java/res/layout/rewards_notification_permission_request.xml
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,85 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:paddingTop="16dp" | ||
android:background="@drawable/notification_rationale_dialog_background" | ||
> | ||
|
||
<ImageView | ||
android:id="@+id/notification_img" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:contentDescription="@null" | ||
android:src="@drawable/ic_rewards_noti_warning_circle" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<TextView | ||
android:id="@+id/notification_permission_title_text" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center" | ||
android:layout_marginHorizontal="8dp" | ||
android:layout_marginTop="16dp" | ||
android:fontFamily="@font/poppins_500" | ||
android:text="@string/notifications_are_disabled" | ||
android:textAlignment="center" | ||
android:textColor="@color/rewards_panel_notification_text_color" | ||
android:textSize="16sp" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/notification_img" /> | ||
|
||
<TextView | ||
android:id="@+id/notification_permission_subtitle_text" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center_horizontal" | ||
android:layout_marginHorizontal="32dp" | ||
android:layout_marginTop="8dp" | ||
android:fontFamily="@font/poppins_400" | ||
android:text="@string/brave_rewards_may_not_work_while_notifications_are_disabled" | ||
android:textAlignment="center" | ||
android:textColor="@color/rewards_panel_notification_secondary_text_color" | ||
android:textSize="14sp" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/notification_permission_title_text" /> | ||
|
||
<TextView | ||
android:id="@+id/turnOnNotification" | ||
android:layout_width="match_parent" | ||
android:layout_height="44dp" | ||
android:layout_marginHorizontal="32dp" | ||
android:layout_marginTop="16dp" | ||
android:background="@drawable/blue_48_rounded_bg" | ||
android:clickable="true" | ||
android:focusable="true" | ||
android:fontFamily="@font/poppins_600" | ||
android:gravity="center" | ||
android:text="@string/stats_notification_on" | ||
android:textColor="@color/rewards_panel_notification_action_color" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/notification_permission_subtitle_text" /> | ||
|
||
<TextView | ||
android:id="@+id/close_text_button" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="24dp" | ||
android:layout_marginBottom="32dp" | ||
android:fontFamily="@font/poppins_400" | ||
android:text="@string/close_text" | ||
android:textColor="@color/rewards_panel_notification_secondary_text_color" | ||
android:textSize="16sp" | ||
android:layout_marginEnd="24dp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="@+id/turnOnNotification" | ||
app:layout_constraintTop_toBottomOf="@+id/turnOnNotification" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit : new line |
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.
nit : remove new line