Skip to content
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

Remove rewards ac android #27163

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -337,13 +337,6 @@ public int getPublisherStatus(int tabId) {
}
}

public void includeInAutoContribution(int tabId, boolean exclude) {
synchronized (sLock) {
BraveRewardsNativeWorkerJni.get().includeInAutoContribution(
mNativeBraveRewardsNativeWorker, tabId, exclude);
}
}

public void removePublisherFromMap(int tabId) {
synchronized (sLock) {
BraveRewardsNativeWorkerJni.get().removePublisherFromMap(
Expand Down Expand Up @@ -406,20 +399,6 @@ public double getPublisherRecurrentDonationAmount(String publisher) {
}
}

public void getAutoContributeProperties() {
synchronized (sLock) {
BraveRewardsNativeWorkerJni.get().getAutoContributeProperties(
mNativeBraveRewardsNativeWorker);
}
}

public boolean isAutoContributeEnabled() {
synchronized (sLock) {
return BraveRewardsNativeWorkerJni.get().isAutoContributeEnabled(
mNativeBraveRewardsNativeWorker);
}
}

public void getReconcileStamp() {
synchronized (sLock) {
BraveRewardsNativeWorkerJni.get().getReconcileStamp(mNativeBraveRewardsNativeWorker);
Expand Down Expand Up @@ -539,27 +518,6 @@ public void recordPanelTrigger() {
}
}

public void setAutoContributeEnabled(boolean isSetAutoContributeEnabled) {
synchronized (sLock) {
BraveRewardsNativeWorkerJni.get().setAutoContributeEnabled(
mNativeBraveRewardsNativeWorker, isSetAutoContributeEnabled);
}
}

public void setAutoContributionAmount(double amount) {
synchronized (sLock) {
BraveRewardsNativeWorkerJni.get().setAutoContributionAmount(
mNativeBraveRewardsNativeWorker, amount);
}
}

public void getAutoContributionAmount() {
synchronized (sLock) {
BraveRewardsNativeWorkerJni.get().getAutoContributionAmount(
mNativeBraveRewardsNativeWorker);
}
}

public String getPayoutStatus() {
synchronized (sLock) {
return BraveRewardsNativeWorkerJni.get().getPayoutStatus(
Expand Down Expand Up @@ -648,20 +606,6 @@ public void onNotificationDeleted(String id) {
}
}

@CalledByNative
public void onGetAutoContributeProperties() {
for (BraveRewardsObserver observer : mObservers) {
observer.onGetAutoContributeProperties();
}
}

@CalledByNative
public void onGetAutoContributionAmount(double amount) {
for (BraveRewardsObserver observer : mObservers) {
observer.onGetAutoContributionAmount(amount);
}
}

@CalledByNative
public void onGetReconcileStamp(long timestamp) {
for (BraveRewardsObserver observer : mObservers) {
Expand Down Expand Up @@ -795,22 +739,33 @@ interface Natives {
double[] getTipChoices(long nativeBraveRewardsNativeWorker);

double getWalletRate(long nativeBraveRewardsNativeWorker);

void getPublisherInfo(long nativeBraveRewardsNativeWorker, int tabId, String host);

String getPublisherURL(long nativeBraveRewardsNativeWorker, int tabId);

String getCaptchaSolutionURL(
long nativeBraveRewardsNativeWorker, String paymentId, String captchaId);

String getAttestationURL(long nativeBraveRewardsNativeWorker);

String getAttestationURLWithPaymentId(
long nativeBraveRewardsNativeWorker, String paymentId);

String getPublisherFavIconURL(long nativeBraveRewardsNativeWorker, int tabId);

String getPublisherName(long nativeBraveRewardsNativeWorker, int tabId);

String getPublisherId(long nativeBraveRewardsNativeWorker, int tabId);

int getPublisherPercent(long nativeBraveRewardsNativeWorker, int tabId);

boolean getPublisherExcluded(long nativeBraveRewardsNativeWorker, int tabId);

int getPublisherStatus(long nativeBraveRewardsNativeWorker, int tabId);
void includeInAutoContribution(
long nativeBraveRewardsNativeWorker, int tabId, boolean exclude);

void removePublisherFromMap(long nativeBraveRewardsNativeWorker, int tabId);

void getCurrentBalanceReport(long nativeBraveRewardsNativeWorker);

void donate(
Expand All @@ -828,10 +783,6 @@ void donate(
boolean isCurrentPublisherInRecurrentDonations(
long nativeBraveRewardsNativeWorker, String publisher);

void getAutoContributeProperties(long nativeBraveRewardsNativeWorker);

boolean isAutoContributeEnabled(long nativeBraveRewardsNativeWorker);

void getReconcileStamp(long nativeBraveRewardsNativeWorker);

double getPublisherRecurrentDonationAmount(
Expand Down Expand Up @@ -859,15 +810,17 @@ boolean isCurrentPublisherInRecurrentDonations(
void recordPanelTrigger(long nativeBraveRewardsNativeWorker);

void createRewardsWallet(long nativeBraveRewardsNativeWorker, String countryCode);

void getRewardsParameters(long nativeBraveRewardsNativeWorker);

double getVbatDeadline(long nativeBraveRewardsNativeWorker);

void getUserType(long nativeBraveRewardsNativeWorker);

void fetchBalance(long nativeBraveRewardsNativeWorker);
void setAutoContributeEnabled(
long nativeBraveRewardsNativeWorker, boolean isSetAutoContributeEnabled);
void setAutoContributionAmount(long nativeBraveRewardsNativeWorker, double amount);
void getAutoContributionAmount(long nativeBraveRewardsNativeWorker);

void getAdsAccountStatement(long nativeBraveRewardsNativeWorker);

String getPayoutStatus(long nativeBraveRewardsNativeWorker);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,13 @@
import android.view.ViewGroup;
import android.webkit.URLUtil;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;

import androidx.appcompat.widget.AppCompatImageView;
import androidx.appcompat.widget.SwitchCompat;
import androidx.cardview.widget.CardView;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
Expand Down Expand Up @@ -173,7 +170,6 @@ public enum NotificationClickAction {
private LinearLayout mBtnSummary;
private ImageView mImgSummary;
private TextView mTextSummary;
private SwitchCompat mSwitchAutoContribute;

private Timer mPublisherFetcher;
private int mPublisherFetchesCount;
Expand Down Expand Up @@ -395,10 +391,10 @@ public void onClick(View v) {
mBtnSummary = mPopupView.findViewById(R.id.summary_btn);
mImgSummary = mPopupView.findViewById(R.id.summary_img);
mTextSummary = mPopupView.findViewById(R.id.summary_text);
mBtnSummary.setOnClickListener(view -> { showSummarySection(); });

mSwitchAutoContribute = mPopupView.findViewById(R.id.auto_contribution_switch);
mSwitchAutoContribute.setOnCheckedChangeListener(mAutoContributeSwitchListener);
mBtnSummary.setOnClickListener(
view -> {
showSummarySection();
});

showSummarySection();
mBtnTip.setEnabled(false);
Expand Down Expand Up @@ -1208,14 +1204,6 @@ private void showViewsBasedOnExternalWallet() {
}

// Generic UI changes
OnCheckedChangeListener mAutoContributeSwitchListener =
new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mBraveRewardsNativeWorker.includeInAutoContribution(mCurrentTabId, !isChecked);
}
};

View.OnClickListener mBraveRewardsOnboardingClickListener =
new View.OnClickListener() {
@Override
Expand Down Expand Up @@ -1992,36 +1980,7 @@ public void onPublisherInfo(int tabId) {
Integer.toString(mBraveRewardsNativeWorker.getPublisherPercent(mCurrentTabId))
+ "%";
mPublisherAttention.setText(percent);
if (mSwitchAutoContribute != null) {
mSwitchAutoContribute.setOnCheckedChangeListener(null);
mSwitchAutoContribute.setChecked(
!mBraveRewardsNativeWorker.getPublisherExcluded(mCurrentTabId));
mSwitchAutoContribute.setOnCheckedChangeListener(mAutoContributeSwitchListener);
}
updatePublisherStatus(mBraveRewardsNativeWorker.getPublisherStatus(mCurrentTabId));
mBraveRewardsNativeWorker.getAutoContributeProperties();
}

@Override
public void onGetAutoContributeProperties() {
if (mBraveRewardsNativeWorker != null) {
int publisherStatus = mBraveRewardsNativeWorker.getPublisherStatus(mCurrentTabId);
boolean shouldShow =
(mBraveRewardsNativeWorker.isAutoContributeEnabled()
&& publisherStatus != PublisherStatus.NOT_VERIFIED
&& publisherStatus != PublisherStatus.WEB3_ENABLED);
setAutoContributionvisibility(shouldShow);
}
}

private void setAutoContributionvisibility(boolean shouldShow) {
int visibility = shouldShow ? View.VISIBLE : View.GONE;
mPopupView.findViewById(R.id.attention_layout).setVisibility(visibility);
mPopupView.findViewById(R.id.auto_contribution_layout).setVisibility(visibility);
mPopupView.findViewById(R.id.divider_line).setVisibility(visibility);
mPopupView.findViewById(R.id.divider_line2).setVisibility(visibility);
mPopupView.findViewById(R.id.auto_contribute_summary_seperator).setVisibility(visibility);
mPopupView.findViewById(R.id.auto_contribute_summary_layout).setVisibility(visibility);
}

@Override
Expand Down Expand Up @@ -2107,10 +2066,6 @@ public void onClick(View v) {
infoCreatorNotVerified.setMovementMethod(LinkMovementMethod.getInstance());
infoCreatorNotVerified.setText(spannableLearnMore);
}
if (pubStatus == PublisherStatus.NOT_VERIFIED
|| pubStatus == PublisherStatus.WEB3_ENABLED) {
setAutoContributionvisibility(false);
}
}

@Override
Expand Down
27 changes: 0 additions & 27 deletions android/java/res/layout/brave_rewards_panel_tip_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,33 +68,6 @@
android:layout_height="1dp"
android:background="@color/rewards_divider_color" />

<LinearLayout
android:id="@+id/auto_contribution_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:visibility="gone"
android:orientation="horizontal">

<TextView
android:id="@+id/auto_contribution_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_weight="1"
android:text="@string/include_auto_contribute"
android:fontFamily="sans-serif-medium"
android:textColor="@color/rewards_panel_secondary_text_color"
android:textSize="16sp" />

<androidx.appcompat.widget.SwitchCompat
android:id="@+id/auto_contribution_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:theme="@style/BraveRewardsSwitchTheme" />

</LinearLayout>

<LinearLayout
android:id="@+id/monthly_contribution_layout"
android:layout_width="match_parent"
Expand Down
6 changes: 0 additions & 6 deletions android/java/res/values/brave_styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@
<item name="colorControlNormal">@color/schemes_on_surface_variant</item>
<item name="colorControlActivated">@color/schemes_primary</item>
</style>
<style name="BraveRewardsSwitchTheme">
<item name="colorControlActivated">@color/rewards_panel_action_color</item>
<item name="colorSwitchThumbNormal">@color/modern_grey_600</item>
<item name="android:colorForeground">@color/modern_grey_600</item>
<item name="switchStyle">@style/Widget.MaterialComponents.CompoundButton.Switch</item>
</style>

<style name="TippingSwitchTheme">
<item name="colorControlActivated">@color/rewards_panel_action_color</item>
Expand Down
25 changes: 0 additions & 25 deletions browser/brave_rewards/android/brave_rewards_native_worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,6 @@ int BraveRewardsNativeWorker::GetPublisherStatus(JNIEnv* env, uint64_t tabId) {
return res;
}

void BraveRewardsNativeWorker::IncludeInAutoContribution(JNIEnv* env,
uint64_t tabId,
bool exclude) {}

void BraveRewardsNativeWorker::RemovePublisherFromMap(JNIEnv* env,
uint64_t tabId) {
PublishersInfoMap::const_iterator iter(map_publishers_info_.find(tabId));
Expand Down Expand Up @@ -598,15 +594,6 @@ bool BraveRewardsNativeWorker::IsCurrentPublisherInRecurrentDonations(
map_recurrent_publishers_.end();
}

void BraveRewardsNativeWorker::GetAutoContributeProperties(JNIEnv* env) {
Java_BraveRewardsNativeWorker_onGetAutoContributeProperties(
env, weak_java_brave_rewards_native_worker_.get(env));
}

bool BraveRewardsNativeWorker::IsAutoContributeEnabled(JNIEnv* env) {
return false;
}

void BraveRewardsNativeWorker::GetReconcileStamp(JNIEnv* env) {
if (brave_rewards_service_) {
brave_rewards_service_->GetReconcileStamp(
Expand Down Expand Up @@ -744,14 +731,6 @@ void BraveRewardsNativeWorker::SetAdsPerHour(JNIEnv* env, jint value) {
static_cast<int64_t>(value));
}

void BraveRewardsNativeWorker::SetAutoContributionAmount(JNIEnv* env,
jdouble value) {}

void BraveRewardsNativeWorker::GetAutoContributionAmount(JNIEnv* env) {
Java_BraveRewardsNativeWorker_onGetAutoContributionAmount(
env, weak_java_brave_rewards_native_worker_.get(env), 0);
}

void BraveRewardsNativeWorker::GetExternalWallet(JNIEnv* env) {
if (brave_rewards_service_) {
brave_rewards_service_->GetExternalWallet(
Expand Down Expand Up @@ -945,10 +924,6 @@ void BraveRewardsNativeWorker::OnRefreshPublisher(
base::android::ConvertUTF8ToJavaString(env, publisher_key));
}

void BraveRewardsNativeWorker::SetAutoContributeEnabled(
JNIEnv* env,
bool isAutoContributeEnabled) {}

void BraveRewardsNativeWorker::RecordPanelTrigger(JNIEnv* env) {
if (brave_rewards_service_) {
brave_rewards_service_->GetP3AConversionMonitor()->RecordPanelTrigger(
Expand Down
11 changes: 0 additions & 11 deletions browser/brave_rewards/android/brave_rewards_native_worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ class BraveRewardsNativeWorker

void GetCurrentBalanceReport(JNIEnv* env);

void IncludeInAutoContribution(JNIEnv* env, uint64_t tabId, bool exclude);

void RemovePublisherFromMap(JNIEnv* env, uint64_t tabId);

void Donate(JNIEnv* env,
Expand All @@ -133,10 +131,6 @@ class BraveRewardsNativeWorker
JNIEnv* env,
const base::android::JavaParamRef<jstring>& publisher);

void GetAutoContributeProperties(JNIEnv* env);

bool IsAutoContributeEnabled(JNIEnv* env);

void GetReconcileStamp(JNIEnv* env);

void ResetTheWholeState(JNIEnv* env);
Expand All @@ -152,10 +146,6 @@ class BraveRewardsNativeWorker

void SetAdsPerHour(JNIEnv* env, jint value);

void SetAutoContributionAmount(JNIEnv* env, jdouble value);

void GetAutoContributionAmount(JNIEnv* env);

void GetExternalWallet(JNIEnv* env);

bool IsTermsOfServiceUpdateRequired(JNIEnv* env);
Expand Down Expand Up @@ -249,7 +239,6 @@ class BraveRewardsNativeWorker

void OnRefreshPublisher(const brave_rewards::mojom::PublisherStatus status,
const std::string& publisher_key);
void SetAutoContributeEnabled(JNIEnv* env, bool isAutoContributeEnabled);

private:
std::string StdStrStrMapToJsonString(
Expand Down
Loading
Loading