mirror of
https://codeberg.org/anoncontributorxmr/mysu.git
synced 2024-12-22 13:07:46 +00:00
Simplify code and fix bugs
This commit is contained in:
parent
66b92bb0b1
commit
d66e8976a5
6 changed files with 52 additions and 14 deletions
|
@ -90,7 +90,7 @@ public class MainActivity extends AppCompatActivity implements MoneroHandlerThre
|
|||
|
||||
@Override
|
||||
public void onConnectionFail() {
|
||||
System.out.println("CONNECT FAILED");
|
||||
Toast.makeText(this, R.string.connection_failed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -45,6 +45,7 @@ public class SettingsFragment extends Fragment implements PasswordBottomSheetDia
|
|||
Button displaySeedButton = view.findViewById(R.id.display_seed_button);
|
||||
TextView walletInfoTextView = view.findViewById(R.id.wallet_info_textview);
|
||||
SwitchCompat nightModeSwitch = view.findViewById(R.id.day_night_switch);
|
||||
SwitchCompat torSwitch = view.findViewById(R.id.tor_switch);
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append("Private view-key: " + wallet.getSecretViewKey()+"\n\n");
|
||||
|
@ -62,6 +63,15 @@ public class SettingsFragment extends Fragment implements PasswordBottomSheetDia
|
|||
}
|
||||
});
|
||||
|
||||
torSwitch.setChecked(PrefService.getInstance().getBoolean(Constants.PREF_USES_TOR, false));
|
||||
torSwitch.setOnCheckedChangeListener((compoundButton, b) -> {
|
||||
PrefService.getInstance().edit().putBoolean(Constants.PREF_USES_TOR, b).apply();
|
||||
|
||||
String proxy = b ? "127.0.0.1:9050" : "";
|
||||
WalletManager.getInstance().setProxy(proxy);
|
||||
WalletManager.getInstance().getWallet().setProxy(proxy);
|
||||
});
|
||||
|
||||
displaySeedButton.setOnClickListener(view1 -> {
|
||||
boolean usesPassword = PrefService.getInstance().getBoolean(Constants.PREF_USES_PASSWORD, false);
|
||||
if(usesPassword) {
|
||||
|
|
|
@ -26,6 +26,7 @@ import com.m2049r.xmrwallet.model.PendingTransaction;
|
|||
import com.m2049r.xmrwallet.model.Wallet;
|
||||
import com.m2049r.xmrwallet.model.WalletListener;
|
||||
import com.m2049r.xmrwallet.model.WalletManager;
|
||||
import com.m2049r.xmrwallet.util.Constants;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
@ -55,9 +56,15 @@ public class MoneroHandlerThread extends Thread implements WalletListener {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
WalletManager.getInstance().setProxy("127.0.0.1:9050");
|
||||
WalletManager.getInstance().setDaemon(Node.fromString(DefaultNodes.MONERUJO_ONION.getUri()));
|
||||
wallet.setProxy("127.0.0.1:9050");
|
||||
boolean usesTor = PrefService.getInstance().getBoolean(Constants.PREF_USES_TOR, false);
|
||||
if(usesTor) {
|
||||
String proxy = "127.0.0.1:9050";
|
||||
WalletManager.getInstance().setProxy(proxy);
|
||||
WalletManager.getInstance().setDaemon(Node.fromString(DefaultNodes.MONERUJO_ONION.getUri()));
|
||||
wallet.setProxy(proxy);
|
||||
} else {
|
||||
WalletManager.getInstance().setDaemon(Node.fromString(DefaultNodes.XMRTW.getUri()));
|
||||
}
|
||||
wallet.init(0);
|
||||
wallet.setListener(this);
|
||||
wallet.startRefresh();
|
||||
|
|
|
@ -4,4 +4,5 @@ public class Constants {
|
|||
public static final String WALLET_NAME = "xmr_wallet";
|
||||
public static final String MNEMONIC_LANGUAGE = "English";
|
||||
public static final String PREF_USES_PASSWORD = "pref_uses_password";
|
||||
public static final String PREF_USES_TOR = "pref_uses_tor";
|
||||
}
|
||||
|
|
|
@ -20,14 +20,14 @@
|
|||
android:id="@+id/display_seed_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Display recovery phrase"
|
||||
android:text="@string/display_recovery_phrase"
|
||||
android:layout_marginTop="16dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/night_mode_label"
|
||||
android:id="@+id/day_night_textview"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/night_mode"
|
||||
|
@ -36,14 +36,6 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/day_night_switch"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/wallet_info_textview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toBottomOf="@id/day_night_switch"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/day_night_switch"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -51,4 +43,29 @@
|
|||
app:layout_constraintTop_toBottomOf="@id/display_seed_button"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tor_textview"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/tor_switch_label"
|
||||
app:layout_constraintTop_toTopOf="@id/tor_switch"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tor_switch"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/tor_switch"/>
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/tor_switch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/day_night_switch"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/wallet_info_textview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toBottomOf="@id/tor_switch"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -546,4 +546,7 @@
|
|||
<string name="invalid_mnemonic_code">Invalid mnemonic</string>
|
||||
<string name="copied_to_clipboard">Copied to clipboard</string>
|
||||
<string name="night_mode">Night mode</string>
|
||||
<string name="display_recovery_phrase">Display recovery phrase</string>
|
||||
<string name="tor_switch_label">Enable Tor (requires Orbot or similar app)</string>
|
||||
<string name="connection_failed">Connection failed</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue