Skip to content

Commit

Permalink
Design tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
premnirmal committed Jul 27, 2022
1 parent b8fef3f commit 921b8c4
Show file tree
Hide file tree
Showing 28 changed files with 65 additions and 77 deletions.
13 changes: 6 additions & 7 deletions app/src/main/kotlin/com/github/premnirmal/ticker/CustomTabs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ package com.github.premnirmal.ticker

import android.content.ActivityNotFoundException
import android.content.Context
import android.graphics.PorterDuff.Mode.SRC_IN
import android.net.Uri
import androidx.browser.customtabs.CustomTabColorSchemeParams
import androidx.browser.customtabs.CustomTabsIntent
import androidx.browser.customtabs.CustomTabsIntent.SHARE_STATE_ON
import androidx.core.content.ContextCompat
import com.github.premnirmal.ticker.settings.WebViewActivity
import com.github.premnirmal.tickerwidget.R
import com.google.android.material.elevation.SurfaceColors
import timber.log.Timber

object CustomTabs {
Expand All @@ -18,13 +17,13 @@ object CustomTabs {
url: String
) {
try {
val closeButton = ContextCompat.getDrawable(context, R.drawable.ic_close)!!
closeButton.setTint(ContextCompat.getColor(context, R.color.icon_tint))
closeButton.setTintMode(SRC_IN)
val color = SurfaceColors.SURFACE_2.getColor(context)
val customTabsIntent = CustomTabsIntent.Builder()
.setShareState(SHARE_STATE_ON)
.setShowTitle(true)
.setCloseButtonIcon(closeButton.toBitmap())
.setDefaultColorSchemeParams(
CustomTabColorSchemeParams.Builder().setToolbarColor(color).build()
)
.setExitAnimations(context, android.R.anim.fade_in, android.R.anim.fade_out)
.build()
customTabsIntent.launchUrl(context, Uri.parse(url))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ import com.github.premnirmal.ticker.ui.SpacingDecoration
import com.github.premnirmal.ticker.viewBinding
import com.github.premnirmal.ticker.widget.WidgetDataProvider
import com.github.premnirmal.tickerwidget.R
import com.github.premnirmal.tickerwidget.R.dimen
import com.github.premnirmal.tickerwidget.databinding.ActivityQuoteDetailBinding
import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.elevation.SurfaceColors
import com.robinhood.ticker.TickerUtils
import javax.inject.Inject
import kotlin.math.abs
Expand Down Expand Up @@ -116,6 +116,7 @@ class QuoteDetailActivity : BaseGraphActivity<ActivityQuoteDetailBinding>(), New
binding.change.setCharacterLists(TickerUtils.provideNumberList())
binding.changePercent.setCharacterLists(TickerUtils.provideNumberList())
if (resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) {
binding.gradient.setBackgroundColor(SurfaceColors.SURFACE_2.getColor(this))
binding.appBarLayout.addOnOffsetChangedListener(offsetChangedListener)
}
setupGraphView()
Expand Down Expand Up @@ -179,7 +180,7 @@ class QuoteDetailActivity : BaseGraphActivity<ActivityQuoteDetailBinding>(), New

private val offsetChangedListener = AppBarLayout.OnOffsetChangedListener { appBarLayout, verticalOffset ->
if (verticalOffset < -20) {
binding.gradient.alpha = abs(verticalOffset / appBarLayout.height.toFloat())
binding.gradient.alpha = abs(verticalOffset/appBarLayout.height.toFloat())
} else {
binding.gradient.alpha = 0f
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import android.os.Bundle
import android.os.Parcelable
import android.view.View
import android.widget.PopupMenu
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.ItemTouchHelper
Expand Down Expand Up @@ -88,7 +87,7 @@ class PortfolioFragment : BaseFragment<FragmentPortfolioBinding>(), ChildFragmen
popupWindow.setOnMenuItemClickListener { menuItem ->
when (menuItem.itemId) {
R.id.remove -> {
promptRemove(quote)
remove(quote)
}
}
true
Expand Down Expand Up @@ -141,19 +140,9 @@ class PortfolioFragment : BaseFragment<FragmentPortfolioBinding>(), ChildFragmen
stocksAdapter.refresh()
}

private fun promptRemove(quote: Quote?) {
quote?.let {
AlertDialog.Builder(requireContext())
.setTitle(R.string.remove)
.setMessage(getString(R.string.remove_prompt, it.symbol))
.setPositiveButton(R.string.remove) { dialog, _ ->
viewModel.removeStock(widgetId, it.symbol)
stocksAdapter.refresh()
dialog.dismiss()
}
.setNegativeButton(R.string.cancel) { dialog, _ -> dialog.dismiss() }
.show()
}
private fun remove(quote: Quote) {
viewModel.removeStock(widgetId, quote.symbol)
stocksAdapter.refresh()
}

override fun onSaveInstanceState(outState: Bundle) {
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout-land/activity_quote_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
android:layout_height="wrap_content"
app:layout_collapseMode="pin"
app:navigationIcon="?attr/homeAsUpIndicator"
app:titleTextAppearance="@style/ActionBarTitleText"
tools:title="AAPL"
tools:title="AAPL"
/>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout-sw600dp-land/activity_alerts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
android:layout_height="wrap_content"
app:title="@string/add_alerts"
app:navigationIcon="?attr/homeAsUpIndicator"
app:titleTextAppearance="@style/ActionBarTitleText"
/>
/>

</com.google.android.material.appbar.AppBarLayout>

Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout-sw600dp-land/activity_notes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
android:layout_height="wrap_content"
app:navigationIcon="?attr/homeAsUpIndicator"
app:title="@string/notes"
app:titleTextAppearance="@style/ActionBarTitleText"
app:menu="@menu/menu_notes"
app:menu="@menu/menu_notes"
/>

</com.google.android.material.appbar.AppBarLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:navigationIcon="?attr/homeAsUpIndicator"
app:titleTextAppearance="@style/ActionBarTitleText"
tools:title="AAPL"
tools:title="AAPL"
/>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout-sw600dp-land/fragment_news_feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
app:elevation="0dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:title="@string/news_feed"
app:titleTextAppearance="@style/ActionBarTitleText"
/>
/>
</com.google.android.material.appbar.AppBarLayout>

<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout-sw600dp-land/fragment_search.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
app:elevation="0dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:title="@string/action_search"
app:titleTextAppearance="@style/ActionBarTitleText"
/>
/>

<EditText
android:id="@+id/search_view"
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout-sw600dp-land/fragment_widgets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
android:elevation="0dp"
app:elevation="0dp"
app:title="@string/widgets"
app:titleTextAppearance="@style/ActionBarTitleText"
/>
/>
</com.google.android.material.appbar.AppBarLayout>

<LinearLayout
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/res/layout/activity_alerts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@

app:title="@string/add_alerts"
app:navigationIcon="?attr/homeAsUpIndicator"
app:titleTextAppearance="@style/ActionBarTitleText"
/>
/>

</com.google.android.material.appbar.AppBarLayout>

Expand Down Expand Up @@ -168,7 +167,7 @@
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="20dp"
android:text="@string/add"
android:text="@string/save"
/>

</LinearLayout>
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout/activity_db_viewer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@

app:layout_collapseMode="pin"
app:navigationIcon="?attr/homeAsUpIndicator"
app:titleTextAppearance="@style/ActionBarTitleText"
app:title="@string/db_viewer"
app:title="@string/db_viewer"
/>

<FrameLayout
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout/activity_notes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@

app:navigationIcon="?attr/homeAsUpIndicator"
app:title="@string/notes"
app:titleTextAppearance="@style/ActionBarTitleText"
app:menu="@menu/menu_notes"
app:menu="@menu/menu_notes"
/>

</com.google.android.material.appbar.AppBarLayout>
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout/activity_positions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@

app:title="@string/add_position"
app:navigationIcon="?attr/homeAsUpIndicator"
app:titleTextAppearance="@style/ActionBarTitleText"
/>
/>

</com.google.android.material.appbar.AppBarLayout>

Expand Down
14 changes: 6 additions & 8 deletions app/src/main/res/layout/activity_quote_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="1"
app:navigationIcon="?attr/homeAsUpIndicator"
app:titleTextAppearance="@style/ActionBarTitleText"
tools:title="AAPL"
tools:title="AAPL"
/>

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down Expand Up @@ -211,16 +209,16 @@
android:text="@string/max"/>

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

</androidx.constraintlayout.widget.ConstraintLayout>

<View
android:id="@+id/gradient"
android:layout_width="match_parent"
android:layout_height="match_parent"

app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="1"
android:alpha="0.0" />
android:alpha="0.0"
tools:background="?attr/colorAccent"
tools:alpha="0.5"
/>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout/activity_webview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:navigationIcon="?attr/homeAsUpIndicator"
app:titleTextAppearance="@style/ActionBarTitleText"
>
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/fragment_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
android:gravity="center_vertical"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:layout_marginStart="16dp"
android:textColor="?attr/colorOnSurfaceVariant"
android:textColor="?attr/colorOnSurface"
android:textSize="@dimen/text_size"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="1.0"
Expand Down Expand Up @@ -79,7 +79,7 @@
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:title="@string/app_name"
app:titleTextAppearance="@style/ActionBarTitleText"
app:titleTextAppearance="@style/ActionBarTitleText.Bold"
app:menu="@menu/menu_home"
/>
</com.google.android.material.appbar.CollapsingToolbarLayout>
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/fragment_news_feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>

<com.google.android.material.appbar.AppBarLayout
Expand All @@ -28,8 +29,7 @@
app:elevation="0dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:title="@string/news_feed"
app:titleTextAppearance="@style/ActionBarTitleText"
/>
/>
</com.google.android.material.appbar.AppBarLayout>

<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_portfolio.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
android:inAnimation="@android:anim/fade_in"
android:outAnimation="@android:anim/fade_out"
android:background="?attr/colorSurface"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>

<TextView
Expand All @@ -24,7 +25,6 @@
android:id="@+id/stockList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:scrollbars="none"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout/fragment_search.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
app:elevation="0dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:title="@string/action_search"
app:titleTextAppearance="@style/ActionBarTitleText"
/>
/>

<EditText
android:id="@+id/search_view"
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout/fragment_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
android:elevation="0dp"
app:elevation="0dp"
app:title="@string/app_settings"
app:titleTextAppearance="@style/ActionBarTitleText"
/>
/>

</com.google.android.material.appbar.AppBarLayout>

Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout/fragment_widgets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
android:elevation="0dp"
app:elevation="0dp"
app:title="@string/widgets"
app:titleTextAppearance="@style/ActionBarTitleText"
/>
/>
</com.google.android.material.appbar.AppBarLayout>

<LinearLayout
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/layout/preferences_footer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
android:gravity="center"
android:text="@string/checkout_open_source"
style="@style/Widget.StocksWidget.TextView.TitleMedium"
android:textAppearance="@style/TextAppearance.StocksWidget.TitleMedium"
android:textColor="?attr/colorAccent"
android:textAppearance="@style/TextAppearance.StocksWidget.TitleMedium"
android:textColor="?attr/colorPrimary"
/>

<include layout="@layout/divider"/>
Expand All @@ -35,7 +35,7 @@
android:gravity="center"
tools:text="v3.0.0"
style="@style/Widget.StocksWidget.TextView.Footer"
android:textAppearance="@style/TextAppearance.StocksWidget.Footer"
android:textAppearance="@style/TextAppearance.StocksWidget.Footer"
/>

</LinearLayout>
6 changes: 3 additions & 3 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@
<string name="equity_value">Equity Value</string>
<string name="value">Value</string>
<string name="price">Price</string>
<string name="add_position">Add Position</string>
<string name="add_position">Positions</string>
<string name="add">Add</string>
<string name="done">Done</string>
<string name="skip">Skip</string>
<string name="edit_position">Edit Position</string>
<string name="edit_position">Positions</string>
<string name="no_such_stock_in_portfolio">No such stock in your portfolio.</string>
<string name="remove">Remove</string>
<string name="move_to_different_widget">Move to different widget</string>
Expand Down Expand Up @@ -183,7 +183,7 @@
<string name="alert_dismiss">Dismiss</string>
<string name="alerts_disabled">Alerts disabled, check settings</string>
<string name="add_notes">Add Notes</string>
<string name="add_alerts">Add Alerts</string>
<string name="add_alerts">Alerts</string>
<string name="remove_holding">Are you sure you want to remove the entry %1$s from your portfolio?</string>
<string name="save">Save</string>
<string name="desc_channel_alerts">Stock alerts</string>
Expand Down
Loading

0 comments on commit 921b8c4

Please sign in to comment.