Skip to content

Commit

Permalink
Tablet layout tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
premnirmal committed Oct 20, 2021
1 parent f39134b commit b5a9b99
Show file tree
Hide file tree
Showing 14 changed files with 372 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
30 changes: 0 additions & 30 deletions app/src/main/res/layout-sw600dp-land/activity_paranormal.xml

This file was deleted.

16 changes: 0 additions & 16 deletions app/src/main/res/layout-sw600dp-land/activity_search.xml

This file was deleted.

97 changes: 97 additions & 0 deletions app/src/main/res/layout-sw600dp-land/fragment_home.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/default_bg"
>

<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipe_container"
android:layout_width="@dimen/tablet_width"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal|top"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/view_pager"
android:layout_width="@dimen/tablet_width"
android:layout_height="match_parent"
android:padding="4dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
>

<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/collapsingToolbarLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:contentScrim="@color/home_toolbar_scrim"
app:titleEnabled="false"
>

<ImageView
android:layout_width="match_parent"
android:layout_height="180dp"
android:scaleType="centerCrop"
android:src="@drawable/header_image"
app:layout_collapseMode="parallax"
/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="180dp"
android:layout_gravity="bottom"
android:gravity="bottom"
android:orientation="vertical"
app:layout_collapseMode="none"
>

<TextView
android:id="@+id/subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:gravity="start"
android:textColor="@color/text_1"
android:textSize="@dimen/text_size"
/>

<com.google.android.material.tabs.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabBackground="@color/tab_background"
app:tabGravity="fill"
app:tabIndicatorColor="@color/color_accent"
app:tabIndicatorHeight="2dp"
app:tabMode="fixed"
app:tabSelectedTextColor="@color/tab_text_selected"
app:tabTextAppearance="@style/TabTextAppearence"
app:tabTextColor="@color/tab_text"
/>
</LinearLayout>

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:title="@string/app_name"
app:titleTextAppearance="@style/ActionBarTitleText"
app:menu="@menu/menu_home"
/>
</com.google.android.material.appbar.CollapsingToolbarLayout>

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

</androidx.coordinatorlayout.widget.CoordinatorLayout>
94 changes: 94 additions & 0 deletions app/src/main/res/layout-sw600dp-land/fragment_news_feed.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/default_bg"
>

<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/transparent"
android:elevation="0dp"
app:elevation="0dp"
>

<View
android:layout_width="match_parent"
android:layout_height="10dp"
android:id="@+id/fake_status_bar"
android:background="@color/bg_toolbar"
/>

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/bg_toolbar"
android:elevation="0dp"
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
android:layout_width="@dimen/tablet_width"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal|top"
android:id="@+id/swipe_container"
app:layout_behavior="@string/appbar_scrolling_view_behavior">

<ViewFlipper
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/view_flipper"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>

<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="?actionBarSize"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:layout_marginBottom="?actionBarSize"
android:text="@string/error_fetching_news"
android:textColor="@color/color_accent"
android:textSize="@dimen/large_text"
style="@style/MediumTextView"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:layout_marginBottom="?actionBarSize"
android:text="@string/no_data"
android:textColor="@color/color_accent"
android:textSize="@dimen/large_text"
style="@style/MediumTextView"
/>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="?actionBarSize"
android:clipToPadding="false"
android:scrollbars="none"
/>
</ViewFlipper>

</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
69 changes: 69 additions & 0 deletions app/src/main/res/layout-sw600dp-land/fragment_search.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/default_bg"
android:layout_gravity="center_horizontal"
>

<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/transparent"
android:elevation="0dp"
app:elevation="0dp"
>

<View
android:layout_width="match_parent"
android:layout_height="10dp"
android:id="@+id/fake_status_bar"
android:background="@color/bg_toolbar"
/>

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/bg_toolbar"
android:elevation="0dp"
app:elevation="0dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:title="@string/action_search"
app:titleTextAppearance="@style/ActionBarTitleText"
/>

<EditText
android:id="@+id/search_view"
android:layout_gravity="center_horizontal|top"
android:layout_width="@dimen/tablet_width"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:layout_marginRight="5dp"
android:elevation="0dp"
android:hint="@string/enter_a_symbol"
android:imeOptions="actionDone"
android:inputType="textNoSuggestions|textCapCharacters"
android:lines="1"
android:maxLines="1"
android:paddingLeft="7dp"
android:paddingRight="7dp"
android:textAllCaps="true"
android:textSize="@dimen/large_text"
app:elevation="0dp"
app:layout_scrollFlags="enterAlways|snap"
/>
</com.google.android.material.appbar.AppBarLayout>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_gravity="center_horizontal|top"
android:layout_width="@dimen/tablet_width"
android:layout_height="wrap_content"
android:scrollbars="none"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
Loading

0 comments on commit b5a9b99

Please sign in to comment.