Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f246266
WIP: Adding structure to the settings screen
kcw-grunt Mar 4, 2025
a54b7ad
chore: wip setting compose compat with xml
andhikayuana Mar 5, 2025
84fe06a
WIP: Layouting items
kcw-grunt Mar 6, 2025
e9f32f9
WIP: Set more of the Settings theme
kcw-grunt Mar 6, 2025
a2c16a3
Add settings title localizations
kcw-grunt Mar 7, 2025
11b5864
Added symbols to the Currency in settings
kcw-grunt Mar 7, 2025
9386f2a
WIP; Adding more function
kcw-grunt Mar 8, 2025
bffe3e0
chore: adjust wide NavigationView
andhikayuana Mar 11, 2025
b2c47b7
chore: fix after rebase with develop
andhikayuana Mar 12, 2025
1451134
chore: centering transaction_details_item.xml
andhikayuana Mar 12, 2025
37bcdc5
chore: inject settingRepository to HomeSettingDrawerComposeView
andhikayuana Mar 12, 2025
90bff01
chore: refactor HomeSettingDrawerSheet
andhikayuana Mar 14, 2025
37086df
chore: refactor HomeSettingDrawerSheet
andhikayuana Mar 14, 2025
c649d6d
Updated Games section
kcw-grunt Mar 16, 2025
7709c17
Added more security section titles
kcw-grunt Mar 18, 2025
df4100f
Layout complete
kcw-grunt Mar 18, 2025
bc9195e
chore: remove unused code
andhikayuana Mar 19, 2025
52c093a
feat: implement update pin
andhikayuana Mar 19, 2025
4bfd2b9
feat: implement show seed phrase
andhikayuana Mar 19, 2025
1f05854
feat: implement share analytics data toggle
andhikayuana Mar 19, 2025
5ce0456
feat: implement blockchain sync from setting drawer
andhikayuana Mar 19, 2025
13aa961
feat: implement link open
andhikayuana Mar 19, 2025
12ab42e
Merge branch 'develop' into feat/add-settings-view-issue-93
kcw-grunt Mar 19, 2025
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
5 changes: 3 additions & 2 deletions app/src/main/java/com/brainwallet/data/model/AppSetting.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ data class AppSetting(
val languageCode: String = Language.ENGLISH.code,
val currency: CurrencyEntity = CurrencyEntity(
"USD",
"USD",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added the symbol parameter

-1f
"US Dollar",
-1f,
"$"
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ public class CurrencyEntity implements Serializable {
public String code;
public String name;
public float rate;
public String symbol;

public CurrencyEntity(String code, String name, float rate) {
public CurrencyEntity(String code, String name, float rate, String symbol) {
this.code = code;
this.name = name;
this.rate = rate;
this.symbol = symbol;
}

public CurrencyEntity() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ interface SettingRepository {
currencyDataSource.getCurrencyByIso(it)
?: return@let CurrencyEntity(
"USD",
"USD",
-1f
"US Dollar",
-1f,
"$"
)
}

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/brainwallet/di/Module.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.brainwallet.data.repository.SettingRepository
import com.brainwallet.data.source.RemoteConfigSource
import com.brainwallet.tools.manager.BRApiManager
import com.brainwallet.tools.sqlite.CurrencyDataSource
import com.brainwallet.ui.screens.home.SettingsViewModel
import com.brainwallet.ui.screens.inputwords.InputWordsViewModel
import com.brainwallet.ui.screens.setpasscode.SetPasscodeViewModel
import com.brainwallet.ui.screens.unlock.UnLockViewModel
Expand Down Expand Up @@ -36,6 +37,7 @@ val dataModule = module {

val viewModelModule = module {
viewModelOf(::WelcomeViewModel)
viewModelOf(::SettingsViewModel)
viewModel { InputWordsViewModel() }
viewModel { SetPasscodeViewModel() }
viewModel { UnLockViewModel() }
Expand Down
14 changes: 12 additions & 2 deletions app/src/main/java/com/brainwallet/navigation/LegacyNavigation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import android.content.Context
import android.content.Intent
import com.brainwallet.R
import com.brainwallet.presenter.activities.BreadActivity
import com.brainwallet.presenter.activities.LoginActivity
import com.brainwallet.ui.BrainwalletActivity
import timber.log.Timber

Expand All @@ -25,7 +24,7 @@ object LegacyNavigation {
auth: Boolean
) {
Timber.i("timber: startBreadActivity: %s", from.javaClass.name)
val intent = if (auth) BrainwalletActivity.createIntent(from, Route.UnLock)
val intent = if (auth) BrainwalletActivity.createIntent(from, Route.UnLock())
else Intent(from, BreadActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
from.startActivity(intent)
Expand All @@ -35,6 +34,17 @@ object LegacyNavigation {
}
}

@JvmStatic
fun restartBreadActivity(
context: Context
) {
Intent(context, BreadActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
}.also {
context.startActivity(it)
}
}

//open compose from old activity
@JvmStatic
@JvmOverloads
Expand Down
11 changes: 7 additions & 4 deletions app/src/main/java/com/brainwallet/navigation/MainNav.kt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ fun NavGraphBuilder.mainNavGraph(

composable<Route.SetPasscode> { navBackStackEntry ->
val route: Route.SetPasscode = navBackStackEntry.toRoute()
SetPasscodeScreen(onNavigate = onNavigate, passcode = route.passcode)
SetPasscodeScreen(
onNavigate = onNavigate,
passcode = route.passcode,
)
}
composable<Route.InputWords> { navBackStackEntry ->
val route: Route.InputWords = navBackStackEntry.toRoute()
Expand All @@ -98,16 +101,16 @@ fun NavGraphBuilder.mainNavGraph(
)
}


/**
* for now, still using old activity & fragment [com.brainwallet.presenter.activities.BreadActivity]
*/
// composable<Route.Home> {
// HomeScreen(onNavigate = onNavigate)
// }

composable<Route.UnLock> {
UnLockScreen(onNavigate = onNavigate)
composable<Route.UnLock> { navBackStackEntry ->
val route: Route.UnLock = navBackStackEntry.toRoute()
UnLockScreen(onNavigate = onNavigate, isUpdatePin = route.isUpdatePin)
}

//todo add more composable screens
Expand Down
8 changes: 6 additions & 2 deletions app/src/main/java/com/brainwallet/navigation/Route.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ sealed class Route : JavaSerializable {
@Serializable
object TopUp : Route()

@Serializable
object Settings : Route()

@Serializable
data class SetPasscode(
val passcode: List<Int> = emptyList()
val passcode: List<Int> = emptyList(),
val isUpdatePin: Boolean = false,
) : Route()

@Serializable
Expand All @@ -39,6 +43,6 @@ sealed class Route : JavaSerializable {
// object Home : Route()

@Serializable
object UnLock : Route()
data class UnLock(val isUpdatePin: Boolean = false) : Route()

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.ConstraintSet;
import androidx.core.app.ActivityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.transition.ChangeBounds;
import androidx.transition.Fade;
import androidx.transition.TransitionManager;
import androidx.transition.TransitionSet;

import com.brainwallet.BrainwalletApp;
import com.brainwallet.R;
import com.brainwallet.navigation.LegacyNavigation;
import com.brainwallet.navigation.Route;
import com.brainwallet.presenter.activities.settings.SettingsActivity;
import com.brainwallet.presenter.activities.settings.SyncBlockchainActivity;
import com.brainwallet.presenter.activities.util.BRActivity;
import com.brainwallet.presenter.customviews.BRNotificationBar;
import com.brainwallet.presenter.fragments.BuyTabFragment;
Expand All @@ -46,18 +50,23 @@
import com.brainwallet.tools.manager.InternetManager;
import com.brainwallet.tools.manager.SyncManager;
import com.brainwallet.tools.security.BitcoinUrlHandler;
import com.brainwallet.tools.security.PostAuth;
import com.brainwallet.tools.sqlite.TransactionDataSource;
import com.brainwallet.tools.threads.BRExecutor;
import com.brainwallet.tools.util.BRConstants;
import com.brainwallet.tools.util.BRCurrency;
import com.brainwallet.tools.util.BRExchange;
import com.brainwallet.tools.util.ExtensionKt;
import com.brainwallet.tools.util.Utils;
import com.brainwallet.ui.BrainwalletActivity;
import com.brainwallet.ui.screens.home.SettingsViewModel;
import com.brainwallet.ui.screens.home.composable.HomeSettingDrawerComposeView;
import com.brainwallet.util.PermissionUtil;
import com.brainwallet.wallet.BRPeerManager;
import com.brainwallet.wallet.BRWalletManager;
import com.google.android.gms.tasks.Task;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.android.material.navigation.NavigationView;
import com.google.android.play.core.review.ReviewInfo;
import com.google.android.play.core.review.ReviewManager;
import com.google.android.play.core.review.ReviewManagerFactory;
Expand Down Expand Up @@ -90,6 +99,9 @@ public class BreadActivity extends BRActivity implements BRWalletManager.OnBalan
private BottomNavigationView bottomNav;

private Handler mHandler = new Handler();
private NavigationView navigationDrawer;
private DrawerLayout drawerLayout;
private HomeSettingDrawerComposeView homeSettingDrawerComposeView;

public static BreadActivity getApp() {
return app;
Expand Down Expand Up @@ -220,7 +232,7 @@ private void setListeners() {
secondaryPrice.setOnClickListener(v -> swap());
menuBut.setOnClickListener(v -> {
if (BRAnimator.isClickAllowed()) {
BRAnimator.showMenuFragment(BreadActivity.this);
drawerLayout.open();
}
});
}
Expand Down Expand Up @@ -366,6 +378,33 @@ protected void onDestroy() {

private void initializeViews() {
menuBut = findViewById(R.id.menuBut);

navigationDrawer = findViewById(R.id.navigationDrawer);
drawerLayout = findViewById(R.id.drawerLayout);
homeSettingDrawerComposeView = findViewById(R.id.homeDrawerComposeView);
homeSettingDrawerComposeView.observeBus(message -> {
drawerLayout.close();
if (SettingsViewModel.LEGACY_EFFECT_ON_LOCK.equals(message.getMessage())) {
LegacyNavigation.startBreadActivity(this, true);
} else if (SettingsViewModel.LEGACY_EFFECT_ON_TOGGLE_DARK_MODE.equals(message.getMessage())) {
LegacyNavigation.restartBreadActivity(this);
} else if (SettingsViewModel.LEGACY_EFFECT_ON_SEC_UPDATE_PIN.equals(message.getMessage())) {
Intent intent = BrainwalletActivity.createIntent(this, new Route.UnLock(true));
intent.putExtra("noPin", true);
startActivity(intent);
} else if (SettingsViewModel.LEGACY_EFFECT_ON_SEED_PHRASE.equals(message.getMessage())) {
PostAuth.getInstance().onPhraseCheckAuth(this, true);
} else if (SettingsViewModel.LEGACY_EFFECT_ON_SHARE_ANALYTICS_DATA_TOGGLE.equals(message.getMessage())) {
boolean currentShareAnalyticsDataEnabled = BRSharedPrefs.getShareData(this);
BRSharedPrefs.putShareData(this, !currentShareAnalyticsDataEnabled);
} else if (SettingsViewModel.LEGACY_EFFECT_ON_SYNC.equals(message.getMessage())) {
Intent intent = new Intent(this, SyncBlockchainActivity.class);
startActivity(intent);
overridePendingTransition(R.anim.enter_from_right, R.anim.exit_to_left);
}
return null;
}); //since we are still using this BreadActivity, need to observe EventBus e.g. lock from [HomeSettingDrawerSheet]

bottomNav = findViewById(R.id.bottomNav);
bottomNav.getMenu().clear();
bottomNav.inflateMenu(isInUsa() ? R.menu.bottom_nav_menu_us : R.menu.bottom_nav_menu);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ private void populateItems() {

//toggle dark mode
boolean isDarkMode = settingRepository.isDarkMode();

items.add(new BRSettingsItem(getString(R.string.toggle_dark_mode), getString(isDarkMode ? androidx.appcompat.R.string.abc_capital_on : androidx.appcompat.R.string.abc_capital_off), v -> {
settingRepository.toggleDarkMode(!isDarkMode);
LegacyNavigation.openComposeScreen(SettingsActivity.this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public void onClick(BRDialogView brDialogView) {
BRExecutor.getInstance().forLightWeightBackgroundTasks().execute(new Runnable() {
@Override
public void run() {
///Dev: This is the structure to do full sync
BRSharedPrefs.putStartHeight(SyncBlockchainActivity.this, 0);
BRSharedPrefs.putAllowSpend(SyncBlockchainActivity.this, false);
BRPeerManager.getInstance().rescan();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ public static String url(Context context, Partner partner, String currency) {
String uuid = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
String prefix = partner == Partner.MOONPAY ? "/moonpay/buy" : "";
String baseUrl = ((BRApiManager) KoinJavaComponent.get(BRApiManager.class)).getBaseUrlProd();
return String.format(baseUrl + prefix + "?address=%s&code=%s&idate=%s&uid=%s", walletAddress, currency, timestamp, uuid);
String query = String.format(baseUrl + prefix + "?address=%s&code=%s&idate=%s&uid=%s", walletAddress, currency, timestamp, uuid);
return query;
}

private void closePayment() {
Expand Down
39 changes: 39 additions & 0 deletions app/src/main/java/com/brainwallet/tools/animation/BRAnimator.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.brainwallet.tools.animation;

import static androidx.databinding.DataBindingUtil.setContentView;

import android.Manifest;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
Expand All @@ -20,6 +22,7 @@

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.compose.ui.platform.ComposeView;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentActivity;
Expand Down Expand Up @@ -52,6 +55,8 @@ public class BRAnimator {
public static int SLIDE_ANIMATION_DURATION = 300;
public static boolean supportIsShowing;

private static boolean shouldShowSettingsComposable = false;

public static void showBreadSignal(FragmentActivity activity, String title, String iconDescription, int drawableId, BROnSignalCompletion completion) {
fragmentSignal = new FragmentSignal();
Bundle bundle = new Bundle();
Expand Down Expand Up @@ -242,6 +247,40 @@ public static void showMenuFragment(Activity app) {
transaction.commit();
}

public static void showSettingsScreen(Activity app) {

// Create a ComposeView
ComposeView composeView = new ComposeView(app);

// // Set the Composable function
// composeView.setContent(() -> {
// SettingsScreenKt.SettingsScreen(shouldShowSettingsComposable);
// return null;
// });
//
// // Set the ComposeView as the content view
// setContentView(composeView);
}

// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_main);
// ComposeView composeView = findViewById(R.id.compose_view);
// composeView.setViewCompositionStrategy(ViewCompositionStrategy.[Your choice here]);
// composeView.setContent{
// HomeKt.Home(
// // other function arguments
// );
// });
// }







public static boolean isClickAllowed() {
if (clickAllowed) {
clickAllowed = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,18 @@ private Set<CurrencyEntity> getCurrencies(Activity context) {
CurrencyEntity tmp = new CurrencyEntity();
try {
JSONObject tmpObj = (JSONObject) arr.get(i);
tmp.name = tmpObj.getString("code");
tmp.name = tmpObj.getString("name");
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix bug

tmp.code = tmpObj.getString("code");
tmp.rate = (float) tmpObj.getDouble("n");
if (tmp.code.equalsIgnoreCase(selectedISO)) {
BRSharedPrefs.putIso(context, tmp.code);
BRSharedPrefs.putCurrencyListPosition(context, i - 1);
}
set.add(tmp);
} catch (JSONException e) {
Timber.e(e);
}
set.add(tmp);

}
} else {
Timber.d("timber: getCurrencies: failed to get currencies");
Expand Down
Loading