From b5a9b99bfefe990b2dc569d2e96d3501bc334d29 Mon Sep 17 00:00:00 2001 From: Prem Nirmal Date: Wed, 20 Oct 2021 14:58:47 +0100 Subject: [PATCH] Tablet layout tweaks --- .../portfolio/search/SearchViewModel.kt | 3 +- .../ticker/settings/SettingsFragment.kt | 8 +- .../premnirmal/ticker/widget/StockWidget.kt | 11 +-- .../activity_paranormal.xml | 30 ------ .../layout-sw600dp-land/activity_search.xml | 16 --- .../res/layout-sw600dp-land/fragment_home.xml | 97 +++++++++++++++++++ .../fragment_news_feed.xml | 94 ++++++++++++++++++ .../layout-sw600dp-land/fragment_search.xml | 69 +++++++++++++ .../layout-sw600dp-land/fragment_widgets.xml | 61 ++++++++++++ app/src/main/res/layout/widget_5x1.xml | 25 +++++ app/src/main/res/values-night/colors.xml | 6 +- app/src/main/res/values-sw600dp/booleans.xml | 4 + app/src/main/res/values/booleans.xml | 4 + app/version.properties | 4 +- 14 files changed, 372 insertions(+), 60 deletions(-) delete mode 100644 app/src/main/res/layout-sw600dp-land/activity_paranormal.xml delete mode 100644 app/src/main/res/layout-sw600dp-land/activity_search.xml create mode 100644 app/src/main/res/layout-sw600dp-land/fragment_home.xml create mode 100644 app/src/main/res/layout-sw600dp-land/fragment_news_feed.xml create mode 100644 app/src/main/res/layout-sw600dp-land/fragment_search.xml create mode 100644 app/src/main/res/layout-sw600dp-land/fragment_widgets.xml create mode 100644 app/src/main/res/layout/widget_5x1.xml create mode 100644 app/src/main/res/values-sw600dp/booleans.xml create mode 100644 app/src/main/res/values/booleans.xml diff --git a/app/src/main/kotlin/com/github/premnirmal/ticker/portfolio/search/SearchViewModel.kt b/app/src/main/kotlin/com/github/premnirmal/ticker/portfolio/search/SearchViewModel.kt index b46c18fa..c009b5ae 100644 --- a/app/src/main/kotlin/com/github/premnirmal/ticker/portfolio/search/SearchViewModel.kt +++ b/app/src/main/kotlin/com/github/premnirmal/ticker/portfolio/search/SearchViewModel.kt @@ -20,7 +20,6 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.ensureActive import kotlinx.coroutines.launch import timber.log.Timber -import java.util.Locale import javax.inject.Inject class SearchViewModel : ViewModel() { @@ -47,7 +46,7 @@ class SearchViewModel : ViewModel() { val suggestions = stocksApi.getSuggestions(query) if (suggestions.wasSuccessful) { val suggestionList = suggestions.data.toMutableList() - val querySuggestion = SuggestionNet(query.toUpperCase(Locale.getDefault())) + val querySuggestion = SuggestionNet(query.uppercase()) if (!suggestionList.contains(querySuggestion)) { suggestionList.add(querySuggestion) } diff --git a/app/src/main/kotlin/com/github/premnirmal/ticker/settings/SettingsFragment.kt b/app/src/main/kotlin/com/github/premnirmal/ticker/settings/SettingsFragment.kt index cbf47b99..db2453a2 100644 --- a/app/src/main/kotlin/com/github/premnirmal/ticker/settings/SettingsFragment.kt +++ b/app/src/main/kotlin/com/github/premnirmal/ticker/settings/SettingsFragment.kt @@ -13,10 +13,12 @@ import android.content.pm.PackageManager import android.net.Uri import android.os.Build import android.os.Bundle +import android.view.Gravity import android.view.LayoutInflater import android.view.View import android.view.ViewGroup.MarginLayoutParams import android.widget.EditText +import android.widget.FrameLayout import android.widget.TimePicker import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatDelegate @@ -43,7 +45,7 @@ import com.github.premnirmal.ticker.showDialog import com.github.premnirmal.ticker.widget.WidgetDataProvider import com.github.premnirmal.tickerwidget.BuildConfig import com.github.premnirmal.tickerwidget.R -import kotlinx.android.synthetic.main.fragment_settings.* +import kotlinx.android.synthetic.main.fragment_settings.toolbar import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import org.threeten.bp.format.TextStyle.SHORT @@ -99,6 +101,10 @@ class SettingsFragment : PreferenceFragmentCompat(), ChildFragment, ) { super.onViewCreated(view, savedInstanceState) (toolbar.layoutParams as MarginLayoutParams).topMargin = requireContext().getStatusBarHeight() + if (resources.getBoolean(R.bool.isTablet)) { + listView.layoutParams.width = resources.getDimensionPixelSize(R.dimen.tablet_width) + (listView.layoutParams as FrameLayout.LayoutParams).gravity = Gravity.CENTER_HORIZONTAL or Gravity.TOP + } listView.addItemDecoration(DividerItemDecoration(activity, DividerItemDecoration.VERTICAL)) listView.isVerticalScrollBarEnabled = false setupSimplePreferencesScreen() diff --git a/app/src/main/kotlin/com/github/premnirmal/ticker/widget/StockWidget.kt b/app/src/main/kotlin/com/github/premnirmal/ticker/widget/StockWidget.kt index c0475050..3ebfcbfa 100644 --- a/app/src/main/kotlin/com/github/premnirmal/ticker/widget/StockWidget.kt +++ b/app/src/main/kotlin/com/github/premnirmal/ticker/widget/StockWidget.kt @@ -110,12 +110,11 @@ class StockWidget : AppWidgetProvider() { appWidgetId: Int ): RemoteViews = when { widgetDataProvider.dataForWidgetId(appWidgetId).widgetSizePref() == 1 -> RemoteViews(context.packageName, R.layout.widget_1x1) - min_width > 750 -> RemoteViews(context.packageName, R.layout.widget_4x1) - min_width > 500 -> RemoteViews(context.packageName, R.layout.widget_3x1) - min_width > 250 -> // 3x2 - RemoteViews(context.packageName, R.layout.widget_2x1) - else -> // 2x1 - RemoteViews(context.packageName, R.layout.widget_1x1) + min_width > 750 -> RemoteViews(context.packageName, R.layout.widget_5x1) + min_width > 550 -> RemoteViews(context.packageName, R.layout.widget_4x1) + min_width > 425 -> RemoteViews(context.packageName, R.layout.widget_3x1) + min_width > 150 -> RemoteViews(context.packageName, R.layout.widget_2x1) + else -> RemoteViews(context.packageName, R.layout.widget_1x1) } private fun getMinWidgetWidth(options: Bundle?): Int { diff --git a/app/src/main/res/layout-sw600dp-land/activity_paranormal.xml b/app/src/main/res/layout-sw600dp-land/activity_paranormal.xml deleted file mode 100644 index 104610d6..00000000 --- a/app/src/main/res/layout-sw600dp-land/activity_paranormal.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout-sw600dp-land/activity_search.xml b/app/src/main/res/layout-sw600dp-land/activity_search.xml deleted file mode 100644 index e4b24d49..00000000 --- a/app/src/main/res/layout-sw600dp-land/activity_search.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout-sw600dp-land/fragment_home.xml b/app/src/main/res/layout-sw600dp-land/fragment_home.xml new file mode 100644 index 00000000..763dc8f2 --- /dev/null +++ b/app/src/main/res/layout-sw600dp-land/fragment_home.xml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout-sw600dp-land/fragment_news_feed.xml b/app/src/main/res/layout-sw600dp-land/fragment_news_feed.xml new file mode 100644 index 00000000..74ab07f1 --- /dev/null +++ b/app/src/main/res/layout-sw600dp-land/fragment_news_feed.xml @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-sw600dp-land/fragment_search.xml b/app/src/main/res/layout-sw600dp-land/fragment_search.xml new file mode 100644 index 00000000..80975f0d --- /dev/null +++ b/app/src/main/res/layout-sw600dp-land/fragment_search.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-sw600dp-land/fragment_widgets.xml b/app/src/main/res/layout-sw600dp-land/fragment_widgets.xml new file mode 100644 index 00000000..00bfe5a0 --- /dev/null +++ b/app/src/main/res/layout-sw600dp-land/fragment_widgets.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/widget_5x1.xml b/app/src/main/res/layout/widget_5x1.xml new file mode 100644 index 00000000..e2ec5abf --- /dev/null +++ b/app/src/main/res/layout/widget_5x1.xml @@ -0,0 +1,25 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml index 24a1819e..26507f89 100644 --- a/app/src/main/res/values-night/colors.xml +++ b/app/src/main/res/values-night/colors.xml @@ -9,8 +9,8 @@ #191919 #191919 #000000 - @color/color_primary - @color/color_primary + @color/bg_toolbar + #2f2f2f #aaaa #1d1d1d #95000000 @@ -20,7 +20,7 @@ #009900 #98545454 #ffbdbdbd - @color/default_bg + @color/bg_toolbar @color/card_bg @color/card_bg #ffffff diff --git a/app/src/main/res/values-sw600dp/booleans.xml b/app/src/main/res/values-sw600dp/booleans.xml new file mode 100644 index 00000000..d3a0e92c --- /dev/null +++ b/app/src/main/res/values-sw600dp/booleans.xml @@ -0,0 +1,4 @@ + + + true + \ No newline at end of file diff --git a/app/src/main/res/values/booleans.xml b/app/src/main/res/values/booleans.xml new file mode 100644 index 00000000..f855de6a --- /dev/null +++ b/app/src/main/res/values/booleans.xml @@ -0,0 +1,4 @@ + + + false + \ No newline at end of file diff --git a/app/version.properties b/app/version.properties index 1be1d4a8..409b661a 100644 --- a/app/version.properties +++ b/app/version.properties @@ -1,2 +1,2 @@ -versionName=3.9.755 -versionCode=300900755 \ No newline at end of file +versionName=3.9.756 +versionCode=300900756 \ No newline at end of file