From 43b5a233bc88b7bc1497757c44bf02ad3b71a902 Mon Sep 17 00:00:00 2001 From: Prem Nirmal Date: Thu, 16 Jun 2022 14:16:43 +0100 Subject: [PATCH] UI tweaks for api 32+ devices, and add more commit history --- app/build.gradle | 4 +- .../github/premnirmal/ticker/Extensions.kt | 10 ++ .../premnirmal/ticker/news/GraphActivity.kt | 8 +- .../ticker/news/QuoteDetailActivity.kt | 5 + .../activity_quote_detail.xml | 2 +- app/src/main/res/layout/activity_graph.xml | 106 +++++++++--------- .../main/res/layout/activity_quote_detail.xml | 1 + app/version.properties | 4 +- 8 files changed, 76 insertions(+), 64 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index bdeb13f3..7b76c967 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -43,9 +43,9 @@ def getOldGitVersion = { -> def stdout = new ByteArrayOutputStream() exec { if (Os.isFamily(Os.FAMILY_WINDOWS)) { - commandLine 'cmd', '/c', 'Powershell', "git tag --sort=-committerdate | Select-Object -first 5 | Select-Object -last 1" + commandLine 'cmd', '/c', 'Powershell', "git tag --sort=-committerdate | Select-Object -first 8 | Select-Object -last 1" } else { - commandLine 'sh', '-c', "git tag --sort=-committerdate | head -5 | tail -1" + commandLine 'sh', '-c', "git tag --sort=-committerdate | head -8 | tail -1" } standardOutput = stdout } diff --git a/app/src/main/kotlin/com/github/premnirmal/ticker/Extensions.kt b/app/src/main/kotlin/com/github/premnirmal/ticker/Extensions.kt index 0f7d169d..b3a5cb42 100644 --- a/app/src/main/kotlin/com/github/premnirmal/ticker/Extensions.kt +++ b/app/src/main/kotlin/com/github/premnirmal/ticker/Extensions.kt @@ -1,5 +1,6 @@ package com.github.premnirmal.ticker +import android.R.attr import android.app.Activity import android.content.Context import android.content.DialogInterface @@ -9,6 +10,7 @@ import android.graphics.Canvas import android.graphics.drawable.BitmapDrawable import android.graphics.drawable.Drawable import android.net.ConnectivityManager +import android.util.TypedValue import android.view.inputmethod.InputMethodManager import android.widget.EditText import android.widget.TextView @@ -57,6 +59,14 @@ fun Context.getStatusBarHeight(): Int { return result } +fun Context.getActionBarHeight(): Int { + val tv = TypedValue() + val result = if (theme.resolveAttribute(attr.actionBarSize, tv, true)) { + TypedValue.complexToDimensionPixelSize(tv.data, resources.displayMetrics) + } else 0 + return result +} + fun Context.getNavigationBarHeight(): Int { val resourceId: Int = resources.getIdentifier( "navigation_bar_height", diff --git a/app/src/main/kotlin/com/github/premnirmal/ticker/news/GraphActivity.kt b/app/src/main/kotlin/com/github/premnirmal/ticker/news/GraphActivity.kt index d78c8937..8e353d01 100644 --- a/app/src/main/kotlin/com/github/premnirmal/ticker/news/GraphActivity.kt +++ b/app/src/main/kotlin/com/github/premnirmal/ticker/news/GraphActivity.kt @@ -14,7 +14,7 @@ import com.github.premnirmal.ticker.network.data.Quote import com.github.premnirmal.ticker.showDialog import com.github.premnirmal.tickerwidget.R import kotlinx.android.synthetic.main.activity_graph.desc -import kotlinx.android.synthetic.main.activity_graph.graph_holder +import kotlinx.android.synthetic.main.activity_graph.graphView import kotlinx.android.synthetic.main.activity_graph.group_period import kotlinx.android.synthetic.main.activity_graph.max import kotlinx.android.synthetic.main.activity_graph.one_day @@ -89,7 +89,7 @@ class GraphActivity : BaseGraphActivity() { override fun fetchGraphData() { if (isNetworkOnline()) { - graph_holder.visibility = View.GONE + graphView.visibility = View.INVISIBLE progress.visibility = View.VISIBLE viewModel.fetchHistoricalDataByRange(ticker, range) } else { @@ -100,12 +100,12 @@ class GraphActivity : BaseGraphActivity() { override fun onGraphDataAdded(graphView: LineChart) { progress.visibility = View.GONE - graph_holder.visibility = View.VISIBLE + graphView.visibility = View.VISIBLE graphView.animateX(DURATION, Easing.EasingOption.EaseInOutCubic) } override fun onNoGraphData(graphView: LineChart) { progress.visibility = View.GONE - graph_holder.visibility = View.VISIBLE + graphView.visibility = View.VISIBLE } } \ No newline at end of file diff --git a/app/src/main/kotlin/com/github/premnirmal/ticker/news/QuoteDetailActivity.kt b/app/src/main/kotlin/com/github/premnirmal/ticker/news/QuoteDetailActivity.kt index db7fe6ef..13af70b0 100644 --- a/app/src/main/kotlin/com/github/premnirmal/ticker/news/QuoteDetailActivity.kt +++ b/app/src/main/kotlin/com/github/premnirmal/ticker/news/QuoteDetailActivity.kt @@ -29,6 +29,7 @@ import com.github.premnirmal.ticker.components.Injector import com.github.premnirmal.ticker.formatChange import com.github.premnirmal.ticker.formatChangePercent import com.github.premnirmal.ticker.formatNumber +import com.github.premnirmal.ticker.getActionBarHeight import com.github.premnirmal.ticker.getStatusBarHeight import com.github.premnirmal.ticker.isNetworkOnline import com.github.premnirmal.ticker.model.IHistoryProvider.Range @@ -60,6 +61,7 @@ import kotlinx.android.synthetic.main.activity_quote_detail.gradient import kotlinx.android.synthetic.main.activity_quote_detail.graphView import kotlinx.android.synthetic.main.activity_quote_detail.graph_container import kotlinx.android.synthetic.main.activity_quote_detail.group_period +import kotlinx.android.synthetic.main.activity_quote_detail.header_container import kotlinx.android.synthetic.main.activity_quote_detail.list_details import kotlinx.android.synthetic.main.activity_quote_detail.max import kotlinx.android.synthetic.main.activity_quote_detail.news_container @@ -124,6 +126,9 @@ class QuoteDetailActivity : BaseGraphActivity(), NewsFeedAdapter.NewsClickListen toolbar.updateLayoutParams { this.topMargin = insets.getInsets(WindowInsetsCompat.Type.systemBars()).top } + header_container.updateLayoutParams { + this.topMargin = getActionBarHeight() + insets.getInsets(WindowInsetsCompat.Type.systemBars()).top + } insets } if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) { diff --git a/app/src/main/res/layout-sw600dp-land/activity_quote_detail.xml b/app/src/main/res/layout-sw600dp-land/activity_quote_detail.xml index fca824d2..6b59676f 100644 --- a/app/src/main/res/layout-sw600dp-land/activity_quote_detail.xml +++ b/app/src/main/res/layout-sw600dp-land/activity_quote_detail.xml @@ -58,7 +58,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginEnd="4dp" - android:orientation="vertical" + android:id="@+id/header_container" app:layout_scrollFlags="scroll|exitUntilCollapsed" android:paddingBottom="?actionBarSize" > diff --git a/app/src/main/res/layout/activity_graph.xml b/app/src/main/res/layout/activity_graph.xml index 49f8dc10..5397ed62 100644 --- a/app/src/main/res/layout/activity_graph.xml +++ b/app/src/main/res/layout/activity_graph.xml @@ -1,74 +1,70 @@ - - + + + + + + - - - - - - - - - - - - - + app:layout_constraintBottom_toTopOf="@id/group_period" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/desc" + android:visibility="invisible" + tools:visibility="visible" + /> @@ -118,4 +114,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_quote_detail.xml b/app/src/main/res/layout/activity_quote_detail.xml index 4518104d..db1478af 100644 --- a/app/src/main/res/layout/activity_quote_detail.xml +++ b/app/src/main/res/layout/activity_quote_detail.xml @@ -47,6 +47,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="?attr/actionBarSize" + android:id="@+id/header_container" app:layout_collapseMode="parallax" app:layout_collapseParallaxMultiplier="1" > diff --git a/app/version.properties b/app/version.properties index 428a4dc4..38edcbc7 100644 --- a/app/version.properties +++ b/app/version.properties @@ -1,3 +1,3 @@ # this file is purely for f-droid because it cannot infer the version name/code from the git tag -versionName=3.9.779 -versionCode=300900779 \ No newline at end of file +versionName=3.9.780 +versionCode=300900780 \ No newline at end of file