Styling changes and optimizations

This commit is contained in:
pokkst 2022-11-08 00:21:57 -06:00
parent 2977a5d05d
commit 28a6fbb02c
No known key found for this signature in database
GPG key ID: 90C2ED85E67A50FF
15 changed files with 101 additions and 87 deletions

View file

@ -113,10 +113,10 @@ public class MainActivity extends AppCompatActivity implements MoneroHandlerThre
} }
@Override @Override
public void onRefresh() { public void onRefresh(long height) {
this.historyService.refreshHistory(); this.historyService.refreshHistory();
this.balanceService.refreshBalance(); this.balanceService.refreshBalance();
this.blockchainService.refreshBlockchain(); this.blockchainService.refreshBlockchain(height);
this.addressService.refreshAddresses(); this.addressService.refreshAddresses();
this.utxoService.refreshUtxos(); this.utxoService.refreshUtxos();
} }

View file

@ -89,7 +89,7 @@ public class ReceiveBottomSheetDialog extends BottomSheetDialogFragment {
if (bitMatrix.get(j, i)) { if (bitMatrix.get(j, i)) {
pixels[i * width + j] = night ? 0xffffffff : 0x00000000; pixels[i * width + j] = night ? 0xffffffff : 0x00000000;
} else { } else {
pixels[i * height + j] = night ? getResources().getColor(R.color.oled_colorBackground) : 0xffffffff; pixels[i * height + j] = getResources().getColor(R.color.oled_txBackgroundColor);
} }
} }
} }

View file

@ -137,15 +137,17 @@ public class OnboardingFragment extends Fragment {
PrefService.getInstance().edit().putBoolean(Constants.PREF_USES_TOR, b).apply(); PrefService.getInstance().edit().putBoolean(Constants.PREF_USES_TOR, b).apply();
if (b) { if (b) {
String proxyString = PrefService.getInstance().getString(Constants.PREF_PROXY, ""); String proxyString = PrefService.getInstance().getString(Constants.PREF_PROXY, "");
if (proxyString.contains(":")) { removeProxyTextListeners();
removeProxyTextListeners();
if (proxyString.contains(":")) {
String proxyAddress = proxyString.split(":")[0]; String proxyAddress = proxyString.split(":")[0];
String proxyPort = proxyString.split(":")[1]; String proxyPort = proxyString.split(":")[1];
initProxyStuff(proxyAddress, proxyPort); initProxyStuff(proxyAddress, proxyPort);
} else {
addProxyTextListeners(); initProxyStuff("127.0.0.1", "9050");
} }
addProxyTextListeners();
proxySettingsLayout.setVisibility(View.VISIBLE); proxySettingsLayout.setVisibility(View.VISIBLE);
} else { } else {
proxySettingsLayout.setVisibility(View.GONE); proxySettingsLayout.setVisibility(View.GONE);

View file

@ -14,6 +14,7 @@ public class BlockchainService extends ServiceBase {
public LiveData<Wallet.ConnectionStatus> connectionStatus = _connectionStatus; public LiveData<Wallet.ConnectionStatus> connectionStatus = _connectionStatus;
private long daemonHeight = 0; private long daemonHeight = 0;
private long lastDaemonHeightUpdateTimeMs = 0; private long lastDaemonHeightUpdateTimeMs = 0;
public static long GETHEIGHT_FETCH = -1;
public BlockchainService(MoneroHandlerThread thread) { public BlockchainService(MoneroHandlerThread thread) {
super(thread); super(thread);
@ -24,8 +25,8 @@ public class BlockchainService extends ServiceBase {
return instance; return instance;
} }
public void refreshBlockchain() { public void refreshBlockchain(long height) {
_currentHeight.postValue(getCurrentHeight()); _currentHeight.postValue(height == GETHEIGHT_FETCH ? getCurrentHeight() : height);
} }
public long getCurrentHeight() { public long getCurrentHeight() {

View file

@ -51,7 +51,7 @@ public class MoneroHandlerThread extends Thread implements WalletListener {
@Override @Override
public synchronized void start() { public synchronized void start() {
super.start(); super.start();
this.listener.onRefresh(); this.listener.onRefresh(BlockchainService.GETHEIGHT_FETCH);
} }
@Override @Override
@ -85,15 +85,17 @@ public class MoneroHandlerThread extends Thread implements WalletListener {
@Override @Override
public void newBlock(long height) { public void newBlock(long height) {
if(height % 100 == 0) { if(isEveryNthBlock(height, 100)) { // refresh services every 100 blocks downloaded
refresh(false); refresh(false, height);
} else if(isEveryNthBlock(height, 2160)) { // save wallet every 2160 blocks (~3 days)
wallet.store();
} }
BlockchainService.getInstance().setDaemonHeight(wallet.isSynchronized() ? height : 0); BlockchainService.getInstance().setDaemonHeight(wallet.isSynchronized() ? height : 0);
} }
@Override @Override
public void updated() { public void updated() {
refresh(false); refresh(false, BlockchainService.GETHEIGHT_FETCH);
} }
@Override @Override
@ -107,21 +109,22 @@ public class MoneroHandlerThread extends Thread implements WalletListener {
listener.onConnectionFail(); listener.onConnectionFail();
} }
} else { } else {
BlockchainService.getInstance().setDaemonHeight(wallet.getDaemonBlockChainHeight()); long height = wallet.getDaemonBlockChainHeight();
BlockchainService.getInstance().setDaemonHeight(height);
wallet.setSynchronized(); wallet.setSynchronized();
wallet.store(); wallet.store();
refresh(true); refresh(true, height);
} }
BlockchainService.getInstance().setConnectionStatus(status); BlockchainService.getInstance().setConnectionStatus(status);
} }
private void refresh(boolean refreshCoins) { private void refresh(boolean refreshCoins, long height) {
wallet.refreshHistory(); wallet.refreshHistory();
if (refreshCoins) { if (refreshCoins) {
wallet.refreshCoins(); wallet.refreshCoins();
} }
listener.onRefresh(); listener.onRefresh(height);
} }
public PendingTransaction createTx(String address, String amountStr, boolean sendAll, PendingTransaction.Priority feePriority, ArrayList<String> selectedUtxos) throws Exception { public PendingTransaction createTx(String address, String amountStr, boolean sendAll, PendingTransaction.Priority feePriority, ArrayList<String> selectedUtxos) throws Exception {
@ -156,8 +159,12 @@ public class MoneroHandlerThread extends Thread implements WalletListener {
return pendingTx.commit("", true); return pendingTx.commit("", true);
} }
private boolean isEveryNthBlock(long height, long interval) {
return height % interval == 0;
}
public interface Listener { public interface Listener {
void onRefresh(); void onRefresh(long height);
void onConnectionFail(); void onConnectionFail();
} }

View file

@ -6,6 +6,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:fillViewport="true" android:fillViewport="true"
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
android:background="@color/oled_txBackgroundColor"
android:padding="24dp"> android:padding="24dp">

View file

@ -6,6 +6,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:fillViewport="true" android:fillViewport="true"
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
android:background="@color/oled_txBackgroundColor"
android:padding="24dp"> android:padding="24dp">

View file

@ -5,6 +5,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:fillViewport="true" android:fillViewport="true"
android:background="@color/oled_txBackgroundColor"
android:padding="24dp"> android:padding="24dp">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout

View file

@ -2,7 +2,8 @@
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:background="@color/oled_txBackgroundColor">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout

View file

@ -6,6 +6,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:fillViewport="true" android:fillViewport="true"
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
android:background="@color/oled_txBackgroundColor"
android:padding="24dp"> android:padding="24dp">

View file

@ -4,6 +4,7 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/oled_txBackgroundColor"
android:fitsSystemWindows="true"> android:fitsSystemWindows="true">

View file

@ -1,77 +1,72 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:background="@color/oled_txBackgroundColor"
android:padding="16dp">
<androidx.constraintlayout.widget.ConstraintLayout <com.google.android.material.progressindicator.CircularProgressIndicator
android:layout_width="match_parent" android:id="@+id/pbConfirmations"
android:layout_height="match_parent"> android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:indeterminate="false"
android:max="10"
android:progress="8"
android:visibility="visible"
app:indicatorInset="0dp"
app:indicatorSize="30dp"
app:trackThickness="4dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/tx_amount"
app:layout_constraintBottom_toBottomOf="@id/tx_failed"/>
<com.google.android.material.progressindicator.CircularProgressIndicator <TextView
android:id="@+id/pbConfirmations" android:id="@+id/tvConfirmations"
android:layout_width="wrap_content" style="@style/MoneroText.Small"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_gravity="center" android:layout_height="wrap_content"
android:indeterminate="false" android:paddingBottom="1dp"
android:max="10" android:text="8"
android:progress="8" android:visibility="visible"
android:visibility="visible" app:layout_constraintTop_toTopOf="@id/pbConfirmations"
app:indicatorInset="0dp" app:layout_constraintBottom_toBottomOf="@id/pbConfirmations"
app:indicatorSize="30dp" app:layout_constraintStart_toStartOf="@id/pbConfirmations"
app:trackThickness="4dp" app:layout_constraintEnd_toEndOf="@id/pbConfirmations"/>
android:layout_marginStart="16dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/tx_amount"
app:layout_constraintBottom_toBottomOf="@id/tx_failed"/>
<TextView <TextView
android:id="@+id/tvConfirmations" android:id="@+id/tx_amount"
style="@style/MoneroText.Small" style="@style/MoneroText.PosAmount"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="1dp" tools:text="+ 999.999999"
android:text="8" android:layout_marginStart="8dp"
android:visibility="visible" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintTop_toTopOf="@id/pbConfirmations" app:layout_constraintStart_toEndOf="@id/pbConfirmations"
app:layout_constraintBottom_toBottomOf="@id/pbConfirmations" app:layout_constraintEnd_toStartOf="@id/tx_datetime"/>
app:layout_constraintStart_toStartOf="@id/pbConfirmations"
app:layout_constraintEnd_toEndOf="@id/pbConfirmations"/>
<TextView <TextView
android:id="@+id/tx_amount" android:id="@+id/tx_failed"
style="@style/MoneroText.PosAmount" style="@style/MoneroText.PosFee"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
tools:text="+ 999.999999" android:text="@string/tx_list_failed_text"
android:layout_marginTop="8dp" android:layout_marginStart="8dp"
android:layout_marginStart="8dp" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toEndOf="@id/pbConfirmations"
app:layout_constraintStart_toEndOf="@id/pbConfirmations" app:layout_constraintTop_toBottomOf="@id/tx_amount"/>
app:layout_constraintEnd_toStartOf="@id/tx_datetime"/>
<TextView <TextView
android:id="@+id/tx_failed" android:id="@+id/tx_datetime"
style="@style/MoneroText.PosFee" style="@style/MoneroText.PosDate"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/tx_list_failed_text" tools:text="2017-05-22 21:32"
android:layout_marginBottom="8dp" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginStart="8dp" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"/>
app:layout_constraintStart_toEndOf="@id/pbConfirmations" </androidx.constraintlayout.widget.ConstraintLayout>
app:layout_constraintTop_toBottomOf="@id/tx_amount"/>
<TextView
android:id="@+id/tx_datetime"
style="@style/MoneroText.PosDate"
android:layout_width="0dp"
android:layout_height="wrap_content"
tools:text="2017-05-22 21:32"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginEnd="16dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>

View file

@ -6,6 +6,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:fillViewport="true" android:fillViewport="true"
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
android:background="@color/oled_txBackgroundColor"
android:padding="24dp"> android:padding="24dp">

View file

@ -30,6 +30,7 @@
<color name="oled_colorOnError">#ffffff</color> <color name="oled_colorOnError">#ffffff</color>
<color name="edittext_bg_color">#202020</color> <color name="edittext_bg_color">#202020</color>
<color name="oled_locked_utxo">#956E43</color> <color name="oled_locked_utxo">#956E43</color>
<color name="oled_txBackgroundColor">#0E0E0E</color>
<!-- CLASSIC --> <!-- CLASSIC -->

View file

@ -31,6 +31,7 @@
<color name="edittext_bg_color">#CCCCCC</color> <color name="edittext_bg_color">#CCCCCC</color>
<color name="button_disabled_bg_color">#454545</color> <color name="button_disabled_bg_color">#454545</color>
<color name="oled_locked_utxo">#B5895A</color> <color name="oled_locked_utxo">#B5895A</color>
<color name="oled_txBackgroundColor">#F1F1F1</color>
<!-- CLASSIC --> <!-- CLASSIC -->