Skip to content

Commit

Permalink
UI tweaks for api 32+ devices, and add more commit history
Browse files Browse the repository at this point in the history
  • Loading branch information
premnirmal committed Jun 16, 2022
1 parent b12a50e commit 43b5a23
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 64 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/kotlin/com/github/premnirmal/ticker/Extensions.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -124,6 +126,9 @@ class QuoteDetailActivity : BaseGraphActivity(), NewsFeedAdapter.NewsClickListen
toolbar.updateLayoutParams<ViewGroup.MarginLayoutParams> {
this.topMargin = insets.getInsets(WindowInsetsCompat.Type.systemBars()).top
}
header_container.updateLayoutParams<ViewGroup.MarginLayoutParams> {
this.topMargin = getActionBarHeight() + insets.getInsets(WindowInsetsCompat.Type.systemBars()).top
}
insets
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
>
Expand Down
106 changes: 51 additions & 55 deletions app/src/main/res/layout/activity_graph.xml
Original file line number Diff line number Diff line change
@@ -1,74 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/graphActivityRoot"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/graph_bg"
android:orientation="vertical"
>

<FrameLayout
<ProgressBar
android:id="@+id/progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>

<TextView
android:id="@+id/tickerName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:textSize="20dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="GOOG"
style="@style/BoldTextView"
/>

<TextView
android:id="@+id/desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:textSize="14dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tickerName"
tools:text="GOOG"
style="@style/BoldTextView"
/>

<com.github.mikephil.charting.charts.LineChart
android:id="@+id/graphView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:padding="15dp"
>

<ProgressBar
android:id="@+id/progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
/>

<RelativeLayout
android:id="@+id/graph_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
>

<TextView
android:id="@+id/tickerName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_margin="3dp"
android:textSize="20dp"
tools:text="GOOG"
style="@style/BoldTextView"
/>

<TextView
android:id="@+id/desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tickerName"
android:layout_centerHorizontal="true"
android:layout_margin="3dp"
android:textSize="14dp"
tools:text="GOOG"
style="@style/BoldTextView"
/>

<com.github.mikephil.charting.charts.LineChart
android:id="@+id/graphView"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>

</RelativeLayout>
</FrameLayout>
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"
/>

<com.google.android.material.chip.ChipGroup
android:id="@+id/group_period"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/graphView"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="@dimen/quote_details_margin"
app:singleLine="true"
app:singleSelection="true"
app:selectionRequired="true">
Expand Down Expand Up @@ -118,4 +114,4 @@

</com.google.android.material.chip.ChipGroup>

</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_quote_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" >

Expand Down
4 changes: 2 additions & 2 deletions app/version.properties
Original file line number Diff line number Diff line change
@@ -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
versionName=3.9.780
versionCode=300900780

0 comments on commit 43b5a23

Please sign in to comment.