Update logged out panel ui
This commit is contained in:
@@ -14,12 +14,11 @@ import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import org.chromium.base.Log;
|
||||
import org.chromium.chrome.R;
|
||||
import org.chromium.chrome.browser.BraveRewardsBalance;
|
||||
import org.chromium.chrome.browser.BraveRewardsExternalWallet;
|
||||
import org.chromium.chrome.browser.BraveRewardsNativeWorker;
|
||||
import org.chromium.chrome.browser.BraveWalletProvider;
|
||||
@@ -27,9 +26,9 @@ import org.chromium.chrome.browser.app.BraveActivity;
|
||||
import org.chromium.chrome.browser.init.AsyncInitializationActivity;
|
||||
import org.chromium.ledger.mojom.WalletStatus;
|
||||
|
||||
public class BraveRewardsUserWalletActivity extends AsyncInitializationActivity {
|
||||
public class BraveRewardsUserWalletActivity
|
||||
extends AsyncInitializationActivity implements View.OnClickListener {
|
||||
private static final String TAG = "BraveRewards";
|
||||
public static final String DISCONNECT_WALLET_URL = "brave://rewards/#disconnect-wallet";
|
||||
public static final int UNDEFINED_WALLET_STATUS = -1;
|
||||
|
||||
private String walletType = BraveRewardsNativeWorker.getInstance().getExternalWalletType();
|
||||
@@ -45,34 +44,38 @@ public class BraveRewardsUserWalletActivity extends AsyncInitializationActivity
|
||||
ab.setDisplayHomeAsUpEnabled(true);
|
||||
ab.setDisplayShowTitleEnabled(false);
|
||||
|
||||
SetUIControls();
|
||||
setUIControls();
|
||||
|
||||
onInitialLayoutInflationComplete();
|
||||
}
|
||||
|
||||
private void SetUIControls() {
|
||||
private void setUIControls() {
|
||||
Intent intent = getIntent();
|
||||
final int status =
|
||||
intent.getIntExtra(BraveRewardsExternalWallet.STATUS, UNDEFINED_WALLET_STATUS);
|
||||
TextView txtUserId = (TextView) findViewById(R.id.user_id);
|
||||
TextView txtUserStatus = (TextView) findViewById(R.id.user_status);
|
||||
Button btnGotoProvider = (Button) findViewById(R.id.user_wallet_go_to_provider);
|
||||
btnGotoProvider.setText(
|
||||
String.format(getResources().getString(R.string.user_wallet_goto_provider),
|
||||
getWalletString(walletType)));
|
||||
Button btnGotoProvider = (Button) findViewById(R.id.provider_action);
|
||||
btnGotoProvider.setOnClickListener(this);
|
||||
String providerText = (status == WalletStatus.CONNECTED)
|
||||
? String.format(getResources().getString(R.string.user_wallet_goto_provider),
|
||||
getWalletString(walletType))
|
||||
: String.format(getResources().getString(R.string.login_provider),
|
||||
getWalletString(walletType));
|
||||
btnGotoProvider.setText(providerText);
|
||||
|
||||
switch (status) {
|
||||
case WalletStatus.CONNECTED:
|
||||
txtUserStatus.setText(BraveRewardsExternalWallet.WalletStatusToString(status));
|
||||
break;
|
||||
case WalletStatus.LOGGED_OUT:
|
||||
txtUserStatus.setText(BraveRewardsExternalWallet.WalletStatusToString(status));
|
||||
break;
|
||||
case UNDEFINED_WALLET_STATUS:
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
|
||||
SetBtnOpenUrlClickHandler(
|
||||
btnGotoProvider, intent.getStringExtra(BraveRewardsExternalWallet.ACCOUNT_URL));
|
||||
|
||||
String userId = intent.getStringExtra(BraveRewardsExternalWallet.USER_NAME);
|
||||
txtUserId.setText(userId);
|
||||
txtUserId.setCompoundDrawablesWithIntrinsicBounds(getWalletIcon(walletType), 0, 0, 0);
|
||||
@@ -98,13 +101,29 @@ public class BraveRewardsUserWalletActivity extends AsyncInitializationActivity
|
||||
}
|
||||
}
|
||||
|
||||
private void SetBtnOpenUrlClickHandler(Button btn, String url) {
|
||||
btn.setOnClickListener((View v) -> {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(BraveActivity.OPEN_URL, url);
|
||||
setResult(RESULT_OK, intent);
|
||||
finish();
|
||||
});
|
||||
@Override
|
||||
public void onClick(@NonNull View view) {
|
||||
if (view.getId() == R.id.provider_action) {
|
||||
if (getIntent() != null) {
|
||||
int walletStatus = getIntent().getIntExtra(
|
||||
BraveRewardsExternalWallet.STATUS, UNDEFINED_WALLET_STATUS);
|
||||
if (walletStatus == WalletStatus.CONNECTED) {
|
||||
if (getIntent().getStringExtra(BraveRewardsExternalWallet.ACCOUNT_URL)
|
||||
!= null) {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(BraveActivity.OPEN_URL,
|
||||
getIntent().getStringExtra(BraveRewardsExternalWallet.ACCOUNT_URL));
|
||||
setResult(RESULT_OK, intent);
|
||||
}
|
||||
} else if (walletStatus == WalletStatus.LOGGED_OUT) {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(BraveActivity.OPEN_URL,
|
||||
getIntent().getStringExtra(BraveRewardsExternalWallet.LOGIN_URL));
|
||||
setResult(RESULT_OK, intent);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -803,8 +803,10 @@ public class BraveRewardsPanel
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mBraveRewardsNativeWorker.DeleteNotification(mCurrentNotificationId);
|
||||
TabUtils.openUrlInNewTab(
|
||||
false, BraveActivity.BRAVE_REWARDS_SETTINGS_WALLET_VERIFICATION_URL);
|
||||
TabUtils.openUrlInNewTab(false,
|
||||
mExternalWallet != null
|
||||
? mExternalWallet.getLoginUrl()
|
||||
: BraveActivity.BRAVE_REWARDS_SETTINGS_WALLET_VERIFICATION_URL);
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
@@ -1930,16 +1932,10 @@ public class BraveRewardsPanel
|
||||
dismiss();
|
||||
break;
|
||||
case WalletStatus.CONNECTED:
|
||||
int requestCode = BraveConstants.USER_WALLET_ACTIVITY_REQUEST_CODE;
|
||||
Intent intent = BuildVerifyWalletActivityIntent(status);
|
||||
if (intent != null) {
|
||||
mActivity.startActivityForResult(intent, requestCode);
|
||||
}
|
||||
openUserWalletActivity(status);
|
||||
break;
|
||||
case WalletStatus.LOGGED_OUT:
|
||||
TabUtils.openUrlInNewTab(false,
|
||||
BraveActivity.BRAVE_REWARDS_SETTINGS_WALLET_VERIFICATION_URL);
|
||||
dismiss();
|
||||
openUserWalletActivity(status);
|
||||
break;
|
||||
default:
|
||||
Log.e(TAG, "Unexpected external wallet status");
|
||||
@@ -1949,6 +1945,14 @@ public class BraveRewardsPanel
|
||||
}));
|
||||
}
|
||||
|
||||
private void openUserWalletActivity(int walletStatus) {
|
||||
int requestCode = BraveConstants.USER_WALLET_ACTIVITY_REQUEST_CODE;
|
||||
Intent intent = BuildVerifyWalletActivityIntent(walletStatus);
|
||||
if (intent != null) {
|
||||
mActivity.startActivityForResult(intent, requestCode);
|
||||
}
|
||||
}
|
||||
|
||||
private void requestPublisherInfo() {
|
||||
Tab currentActiveTab = BraveRewardsHelper.currentActiveChromeTabbedActivityTab();
|
||||
if (currentActiveTab != null && !currentActiveTab.isIncognito()) {
|
||||
@@ -2212,6 +2216,7 @@ public class BraveRewardsPanel
|
||||
Class clazz = null;
|
||||
switch (status) {
|
||||
case WalletStatus.CONNECTED:
|
||||
case WalletStatus.LOGGED_OUT:
|
||||
clazz = BraveRewardsUserWalletActivity.class;
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -61,44 +61,12 @@
|
||||
</TextView>
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2dp"
|
||||
android:background="@color/user_wallet_background"
|
||||
android:contentDescription="@null"/>
|
||||
|
||||
<android.widget.Button
|
||||
android:id="@+id/user_wallet_btn1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:textAlignment="textStart"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="@android:color/holo_blue_dark"
|
||||
android:padding="12dp"
|
||||
android:visibility="gone">
|
||||
</android.widget.Button>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/user_wallet_btn2_separator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2dp"
|
||||
android:background="@color/user_wallet_background"
|
||||
android:contentDescription="@null"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<android.widget.Button
|
||||
android:id="@+id/user_wallet_btn2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:textAlignment="textStart"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="@android:color/holo_blue_dark"
|
||||
android:padding="12dp"
|
||||
android:visibility="gone">
|
||||
</android.widget.Button>
|
||||
|
||||
android:contentDescription="@null"/>
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2dp"
|
||||
@@ -106,14 +74,14 @@
|
||||
android:contentDescription="@null"/>
|
||||
|
||||
<android.widget.Button
|
||||
android:id="@+id/user_wallet_go_to_provider"
|
||||
android:id="@+id/provider_action"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:textAlignment="textStart"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="@android:color/holo_blue_dark"
|
||||
android:padding="12dp">
|
||||
</android.widget.Button>
|
||||
android:padding="12dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
@@ -1286,6 +1286,9 @@ Are you sure you want to do this?
|
||||
<message name="IDS_USER_WALLET_GOTO_PROVIDER">
|
||||
Go to my <ph name="WALLET_PROVIDER">%1$s</ph> account
|
||||
</message>
|
||||
<message name="IDS_LOGIN_PROVIDER">
|
||||
Log in to your <ph name="WALLET_PROVIDER">%1$s</ph> account
|
||||
</message>
|
||||
<message name="IDS_USER_WALLET_STATUS_NOT_CONNECTED">
|
||||
Not connected
|
||||
</message>
|
||||
|
||||
Reference in New Issue
Block a user