diff options
author | Torsten Grote <t@grobox.de> | 2020-03-06 10:59:13 -0300 |
---|---|---|
committer | Torsten Grote <t@grobox.de> | 2020-03-06 10:59:13 -0300 |
commit | 826c0167e37d25c2437d67d1d893586e9b9dadd5 (patch) | |
tree | c883dbca8aefb2a4880e44e09e0e01f64b121cdc | |
parent | 09b66e71b0fa0fd24ad3c4196ff545faaad6da14 (diff) | |
download | wallet-android-826c0167e37d25c2437d67d1d893586e9b9dadd5.tar.gz wallet-android-826c0167e37d25c2437d67d1d893586e9b9dadd5.tar.bz2 wallet-android-826c0167e37d25c2437d67d1d893586e9b9dadd5.zip |
Show version name and code in navigation drawer when dev mode is on
-rw-r--r-- | .gitlab-ci.yml | 4 | ||||
-rw-r--r-- | app/src/main/java/net/taler/wallet/MainActivity.kt | 12 | ||||
-rw-r--r-- | app/src/main/res/layout/activity_main.xml | 2 | ||||
-rw-r--r-- | app/src/main/res/layout/nav_header_main.xml | 55 |
4 files changed, 53 insertions, 20 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3cdba25..30b19d4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,9 +11,9 @@ stages: default: before_script: - - wget https://git.taler.net/wallet-android.git/plain/akono.aar?h=binary-deps -O akono/akono.aar + - wget "https://git.taler.net/wallet-android.git/plain/akono.aar?h=binary-deps" -O akono/akono.aar - mkdir -p app/src/main/assets - - wget https://git.taler.net/wallet-android.git/plain/taler-wallet-android.js?h=binary-deps -O app/src/main/assets/taler-wallet-android.js + - wget "https://git.taler.net/wallet-android.git/plain/taler-wallet-android.js?h=binary-deps" -O app/src/main/assets/taler-wallet-android.js test: stage: test diff --git a/app/src/main/java/net/taler/wallet/MainActivity.kt b/app/src/main/java/net/taler/wallet/MainActivity.kt index bca5e33..c2f20f7 100644 --- a/app/src/main/java/net/taler/wallet/MainActivity.kt +++ b/app/src/main/java/net/taler/wallet/MainActivity.kt @@ -16,6 +16,7 @@ package net.taler.wallet +import android.annotation.SuppressLint import android.content.BroadcastReceiver import android.content.Context import android.content.Intent @@ -24,8 +25,10 @@ import android.content.IntentFilter import android.os.Bundle import android.util.Log import android.view.MenuItem +import android.view.View.GONE import android.view.View.INVISIBLE import android.view.View.VISIBLE +import android.widget.TextView import androidx.activity.viewModels import androidx.appcompat.app.AppCompatActivity import androidx.core.view.GravityCompat.START @@ -41,6 +44,8 @@ import com.google.zxing.integration.android.IntentIntegrator import com.google.zxing.integration.android.IntentIntegrator.parseActivityResult import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.app_bar_main.* +import net.taler.wallet.BuildConfig.VERSION_CODE +import net.taler.wallet.BuildConfig.VERSION_NAME import net.taler.wallet.HostCardEmulatorService.Companion.HTTP_TUNNEL_RESPONSE import net.taler.wallet.HostCardEmulatorService.Companion.MERCHANT_NFC_CONNECTED import net.taler.wallet.HostCardEmulatorService.Companion.MERCHANT_NFC_DISCONNECTED @@ -54,6 +59,7 @@ class MainActivity : AppCompatActivity(), OnNavigationItemSelectedListener, private lateinit var nav: NavController + @SuppressLint("SetTextI18n") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) @@ -77,8 +83,14 @@ class MainActivity : AppCompatActivity(), OnNavigationItemSelectedListener, progress_bar.visibility = if (show) VISIBLE else INVISIBLE }) + val versionView: TextView = nav_view.getHeaderView(0).findViewById(R.id.versionView) model.devMode.observe(this, Observer { enabled -> nav_view.menu.findItem(R.id.nav_pending_operations).isVisible = enabled + if (enabled) { + @SuppressLint("SetTextI18n") + versionView.text = "$VERSION_NAME ($VERSION_CODE)" + versionView.visibility = VISIBLE + } else versionView.visibility = GONE }) if (intent.action == ACTION_VIEW) intent.dataString?.let { uri -> diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 7769fd3..0612306 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -33,7 +33,7 @@ android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" - android:fitsSystemWindows="true" + android:fitsSystemWindows="false" app:headerLayout="@layout/nav_header_main" app:menu="@menu/activity_main_drawer" /> diff --git a/app/src/main/res/layout/nav_header_main.xml b/app/src/main/res/layout/nav_header_main.xml index f21d6a3..5574c1f 100644 --- a/app/src/main/res/layout/nav_header_main.xml +++ b/app/src/main/res/layout/nav_header_main.xml @@ -14,39 +14,60 @@ ~ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> --> -<LinearLayout 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:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="@dimen/nav_header_height" + android:layout_height="wrap_content" android:background="@drawable/side_nav_bar" - android:gravity="bottom" - android:orientation="vertical" - android:paddingLeft="@dimen/activity_horizontal_margin" - android:paddingTop="@dimen/activity_vertical_margin" - android:paddingRight="@dimen/activity_horizontal_margin" - android:paddingBottom="@dimen/activity_vertical_margin" android:theme="@style/ThemeOverlay.AppCompat.Dark"> <ImageView - android:id="@+id/imageView" + android:id="@+id/talerLogoView" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:adjustViewBounds="false" + android:layout_margin="16dp" android:contentDescription="@string/nav_header_desc" - android:paddingTop="@dimen/nav_header_vertical_spacing" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" app:srcCompat="@mipmap/ic_launcher_round" /> <TextView - android:layout_width="match_parent" + android:id="@+id/gnuView" + android:layout_width="0dp" android:layout_height="wrap_content" - android:paddingTop="@dimen/nav_header_vertical_spacing" + android:layout_marginStart="16dp" + android:layout_marginTop="8dp" + android:layout_marginEnd="16dp" android:text="@string/nav_header_title" - android:textAppearance="@style/TextAppearance.AppCompat.Body1" /> + android:textAppearance="@style/TextAppearance.AppCompat.Body1" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/talerLogoView" /> <TextView - android:id="@+id/textView" + android:id="@+id/walletView" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="@string/nav_header_subtitle" /> + android:layout_marginStart="16dp" + android:layout_marginTop="4dp" + android:layout_marginBottom="16dp" + android:text="@string/nav_header_subtitle" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/gnuView" /> -</LinearLayout> + <TextView + android:id="@+id/versionView" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:layout_marginEnd="16dp" + app:layout_constraintBottom_toBottomOf="@+id/walletView" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.0" + app:layout_constraintStart_toEndOf="@+id/walletView" + app:layout_constraintTop_toTopOf="@+id/walletView" + tools:text="0.6.9-pre15" /> + +</androidx.constraintlayout.widget.ConstraintLayout> |