Skip to content

Commit

Permalink
- update advanced settings ui
Browse files Browse the repository at this point in the history
 - move dev & prod urls into constants
  • Loading branch information
vsima committed Jan 27, 2023
1 parent 0187160 commit bb6d58a
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 12 deletions.
3 changes: 0 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ android {
archivesBaseName = "${versionName}(${versionCode})"

buildConfigField "String", "INFURA_KEY", "\"set the infura key here\""
buildConfigField "String", "LITEWALLET_API_URL_PROD", "\"https://api-prod.lite-wallet.org\""
buildConfigField "String", "LITEWALLET_API_URL_DEV", "\"https://api-dev.lite-wallet.org\""


// Similar to other properties in the defaultConfig block,
// you can configure the ndk block for each product flavor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,23 @@ public View getView(int position, @Nullable View convertView, @NonNull ViewGroup
case SWITCH:
v = inflater.inflate(settings_list_switch, parent, false);
View switchView = v.findViewById(R.id.item_switch);
View desc = v.findViewById(R.id.item_desc);
if (switchView instanceof SwitchCompat) {
((SwitchCompat) switchView).setChecked(item.isChecked);
switchView.setOnClickListener(item.listener);
switchView.setOnClickListener(view -> {
//relay click event to item.listener
item.listener.onClick(view);

if (desc instanceof TextView && view instanceof SwitchCompat) {
Boolean isChecked = ((SwitchCompat) view).isChecked();
((TextView) desc).setText(isChecked ?
getString(R.string.DeveloperMode_On) : getString(R.string.DeveloperMode_Off));
}
});
if (desc instanceof TextView) {
((TextView) desc).setText(item.isChecked ?
getString(R.string.DeveloperMode_On) : getString(R.string.DeveloperMode_Off));
}
}
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

import static com.breadwallet.tools.manager.BRSharedPrefs.PrefsServerMode.DEV;
import static com.breadwallet.tools.util.BRConstants.GEO_PERMISSIONS_REQUESTED;
import static com.breadwallet.tools.util.BRConstants.LITEWALLET_API_URL_DEV;
import static com.breadwallet.tools.util.BRConstants.LITEWALLET_API_URL_PROD;
import static com.breadwallet.tools.util.BRConstants.PREFS_LITEWALLET_SERVER_MODE;

import android.content.Context;
import android.content.SharedPreferences;

import com.breadwallet.BuildConfig;
import com.breadwallet.tools.util.BRConstants;

import org.json.JSONArray;
Expand Down Expand Up @@ -444,7 +445,7 @@ public static void inAppReviewDone(Context context) {
}

public enum PrefsServerMode {
DEV(BuildConfig.LITEWALLET_API_URL_DEV), PROD(BuildConfig.LITEWALLET_API_URL_PROD);
DEV(LITEWALLET_API_URL_DEV), PROD(LITEWALLET_API_URL_PROD);
public final String url;

PrefsServerMode(String url) {
Expand All @@ -466,5 +467,7 @@ public static void setApiServerMode(Context context, PrefsServerMode serverMode)
.edit().putString(PREFS_LITEWALLET_SERVER_MODE, serverMode.url).commit();
}

public static Boolean isApiServerModeDev(Context context) { return getApiServerMode(context) == DEV; }
public static Boolean isApiServerModeDev(Context context) {
return getApiServerMode(context) == DEV;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ public class BRConstants {

public static final String BLOCK_EXPLORER_BASE_URL = BuildConfig.LITECOIN_TESTNET ? "https://testnet.litecore.io/tx/" : "https://insight.litecore.io/tx/";


public static final String RESET_CARD_PWD_LINK = "https://litecoin.dashboard.getblockcard.com/password/forgot";

public static final String LITEWALLET_API_URL_PROD = "https://api-prod.lite-wallet.org";
public static final String LITEWALLET_API_URL_DEV = "https://api-dev.lite-wallet.org";

private BRConstants() {
}
Expand Down
22 changes: 19 additions & 3 deletions app/src/main/res/layout/settings_list_switch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,29 @@
android:layout_centerVertical="true"
android:layout_marginStart="24dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="24dp"
android:layout_marginBottom="16dp"
android:textColor="@color/almost_black"
android:textSize="@dimen/sub_header"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/item_switch"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="item title" />

<TextView
android:id="@+id/item_desc"
style="@style/BRBoldTextStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="24dp"
tools:text="item desc"
android:textColor="@color/almost_black"
android:textSize="@dimen/sub_header"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/item_switch"
app:layout_constraintStart_toEndOf="@+id/item_title"
app:layout_constraintTop_toTopOf="parent" />

<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/item_switch"
android:layout_width="wrap_content"
Expand All @@ -34,5 +47,8 @@
android:layout_marginEnd="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
app:trackTint="@color/colorPrimaryLight"
/>

</androidx.constraintlayout.widget.ConstraintLayout>
4 changes: 3 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@
<!-- Node Selector view title -->
<string name="NodeSelector.title">Litecoin Nodes</string>
<!-- Settings Developer mode title -->
<string name="DeveloperMode.title">Developer Mode</string>
<string name="DeveloperMode.title">Developer Mode : </string>
<string name="DeveloperMode.On">On</string>
<string name="DeveloperMode.Off">Off</string>
<!-- Bad Payment request alert title -->
<string name="PaymentProtocol.Errors.badPaymentRequest">Bad Payment Request</string>
<!-- Error opening payment protocol file message -->
Expand Down

0 comments on commit bb6d58a

Please sign in to comment.