Skip to content

Commit

Permalink
Fixed layout in devices without navigation bar Reduced Rarity size
Browse files Browse the repository at this point in the history
  • Loading branch information
edipo2s committed Feb 16, 2017
1 parent 3c6ce30 commit 145fa51
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ class CardActivity : BaseActivity() {
setContentView(R.layout.activity_card)
ActivityCompat.postponeEnterTransition(this)
snackbarNeedMargin = false
if (hasNavigationBar()) {
card_content.setBottomPaddingForNavigationBar()
card_info_content.setBottomPaddingForNavigationBar()
cardInfoSheetBehavior.peekHeight = resources.getDimensionPixelOffset(R.dimen.card_bottom_sheet_peek_height) +
resources.getDimensionPixelOffset(R.dimen.navigation_bar_height)
}

configureRecycleView()
loadCardInfo()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class FilterRarity(ctx: Context?, attrs: AttributeSet?, defStyleAttr: Int) :

val ANIM_DURATION: Long = 200
val rarityBGMinWidth by lazy { resources.getDimensionPixelSize(R.dimen.size_medium) }
val rarityBGMaxWidth by lazy { resources.getDimensionPixelSize(R.dimen.rarity_bg_max_width) }
val rarityBGMaxWidth by lazy { resources.getDimensionPixelSize(R.dimen.size_medium) * 5 }

var filterClick: ((CardRarity?) -> Unit)? = null
var collapseOnClick: Boolean = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ class DeckActivity : BaseActivity() {
layoutParams.topMargin = statusBarHeight
toolbar.layoutParams = layoutParams
}
if (hasNavigationBar()) {
deck_content.setBottomPaddingForNavigationBar()
deck_comment_content.setBottomPaddingForNavigationBar()
commentsSheetBehavior.peekHeight = resources.getDimensionPixelOffset(R.dimen.deck_comment_bottom_sheet_peek_height) +
resources.getDimensionPixelOffset(R.dimen.navigation_bar_height)
}

favorite = intent.getBooleanExtra(EXTRA_FAVORITE, false)
like = intent.getBooleanExtra(EXTRA_LIKE, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class SeasonsFragment : BaseFragment() {
season_best_rank_label.visibility = View.GONE.takeIf { noMatches } ?: View.VISIBLE
with(season_best_rank) {
val rankedGroup = rankedMatches.groupBy { it.legend }
text = (rankedGroup[true] ?: rankedGroup[false])?.minBy { it.rank }?.rank.toString()
text = "${(rankedGroup[true] ?: rankedGroup[false])?.minBy { it.rank }?.rank ?: 0}"
val legendIcon = R.drawable.ic_rank_legend.takeIf { rankedGroup[true] != null } ?: 0
setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, legendIcon)
visibility = View.GONE.takeIf { noMatches } ?: View.VISIBLE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import android.graphics.drawable.Drawable
import android.os.Bundle
import android.support.annotation.IntegerRes
import android.support.design.widget.BottomSheetBehavior
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.*
import android.widget.ImageView
import android.widget.ListPopupWindow
import android.widget.Spinner
Expand Down Expand Up @@ -153,4 +151,19 @@ fun ImageView.loadFromUrl(imageUrl: String, placeholder: Drawable? = null,

}

fun LocalDate.toYearMonth(): YearMonth = YearMonth.of(year, month)
fun LocalDate.toYearMonth(): YearMonth = YearMonth.of(year, month)

fun Context.hasNavigationBar(): Boolean {
val hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
val hasHomeKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_HOME);
return (!(hasBackKey && hasHomeKey))
}

fun View.setBottomPaddingForNavigationBar() {
var result = 0
val resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android")
if (resourceId > 0) {
result = resources.getDimensionPixelSize(resourceId)
}
setPadding(paddingLeft, paddingTop, paddingRight, result)
}
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_card.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
tools:ctx="com.ediposouza.teslesgendstracker.ui.cards.CardActivity">

<android.support.design.widget.CoordinatorLayout
android:id="@+id/card_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/navigation_bar_height">
android:layout_height="match_parent">

<LinearLayout
android:layout_width="match_parent"
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/res/layout/activity_deck.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
tools:ctx="com.ediposouza.teslesgendstracker.ui.decks.DeckActivity">

<android.support.design.widget.CoordinatorLayout
android:id="@+id/deck_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/navigation_bar_height">
android:layout_height="match_parent">

<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
Expand Down Expand Up @@ -158,10 +158,10 @@
app:layout_behavior="@string/bottom_sheet_behavior">

<RelativeLayout
android:id="@+id/deck_comment_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/default_margin"
android:paddingBottom="@dimen/card_bottom_sheet_margin_bottom">
android:layout_margin="@dimen/default_margin">

<TextView
android:layout_width="wrap_content"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/include_card_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
tools:showIn="@layout/activity_card">

<RelativeLayout
android:id="@+id/card_info_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/default_margin"
android:layout_marginEnd="@dimen/large_margin"
android:layout_marginStart="@dimen/large_margin"
android:layout_marginTop="@dimen/default_margin"
android:paddingBottom="@dimen/card_bottom_sheet_margin_bottom">
android:layout_marginTop="@dimen/default_margin">

<ImageView
android:id="@+id/card_favorite_btn"
Expand Down
16 changes: 8 additions & 8 deletions app/src/main/res/layout/itemlist_season.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:paddingBottom="@dimen/default_margin"
android:paddingStart="@dimen/default_margin"
android:paddingStart="@dimen/small_margin"
android:paddingTop="@dimen/default_margin">

<TextView
Expand Down Expand Up @@ -90,14 +90,14 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="@dimen/huge_margin"
android:layout_marginStart="@dimen/default_margin"
android:paddingBottom="@dimen/huge_margin"
android:paddingStart="@dimen/text_shadow_padding"
android:paddingTop="@dimen/text_shadow_padding"
android:rotation="-45"
android:text="@string/season_no_matches"
android:textColor="@android:color/darker_gray"
android:textSize="@dimen/font_huge"
android:textSize="@dimen/font_large"
android:textStyle="bold"
android:visibility="gone"
tools:visibility="visible" />
Expand All @@ -107,11 +107,11 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="@dimen/huge_margin"
android:layout_marginStart="@dimen/default_margin"
android:paddingBottom="@dimen/huge_margin"
android:rotation="-45"
android:text="@string/season_no_matches"
android:textSize="@dimen/font_huge"
android:textSize="@dimen/font_large"
android:textStyle="bold"
android:visibility="gone"
tools:visibility="visible" />
Expand All @@ -122,7 +122,7 @@
android:layout_height="wrap_content"
android:layout_alignStart="@id/season_matches_label"
android:layout_below="@id/season_matches_label"
android:layout_marginStart="@dimen/large_margin"
android:layout_marginStart="@dimen/default_margin"
android:layout_marginTop="@dimen/default_margin"
android:orientation="vertical">

Expand Down Expand Up @@ -154,7 +154,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@id/season_matches_layout"
android:layout_marginStart="@dimen/large_margin"
android:layout_marginStart="@dimen/default_margin"
android:layout_marginTop="@dimen/small_margin"
android:layout_toEndOf="@id/season_matches_layout"
android:textColor="@color/colorAccent"
Expand Down Expand Up @@ -198,7 +198,7 @@
android:layout_height="wrap_content"
android:layout_alignStart="@id/season_matches_label"
android:layout_below="@id/season_opponent_label"
android:layout_marginStart="@dimen/large_margin"
android:layout_marginStart="@dimen/default_margin"
android:layout_marginTop="@dimen/default_margin"
android:orientation="vertical">

Expand Down
20 changes: 12 additions & 8 deletions app/src/main/res/layout/widget_rarity_filter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,39 @@
<ImageView
android:id="@+id/rarity_filter_common"
style="@style/RarityItem"
android:layout_width="@dimen/size_medium"
android:layout_height="@dimen/size_medium"
android:layout_width="@dimen/rarity_icon_size"
android:layout_height="@dimen/rarity_icon_size"
android:layout_centerVertical="true"
android:layout_toEndOf="@id/rarity_filter"
android:src="@drawable/ic_rarity_common"
tools:visibility="visible" />

<ImageView
android:id="@+id/rarity_filter_rare"
style="@style/RarityItem"
android:layout_width="@dimen/size_medium"
android:layout_height="@dimen/size_medium"
android:layout_width="@dimen/rarity_icon_size"
android:layout_height="@dimen/rarity_icon_size"
android:layout_centerVertical="true"
android:layout_toEndOf="@id/rarity_filter_common"
android:src="@drawable/ic_rarity_rare"
tools:visibility="visible" />

<ImageView
android:id="@+id/rarity_filter_epic"
style="@style/RarityItem"
android:layout_width="@dimen/size_medium"
android:layout_height="@dimen/size_medium"
android:layout_width="@dimen/rarity_icon_size"
android:layout_height="@dimen/rarity_icon_size"
android:layout_centerVertical="true"
android:layout_toEndOf="@id/rarity_filter_rare"
android:src="@drawable/ic_rarity_epic"
tools:visibility="visible" />

<ImageView
android:id="@+id/rarity_filter_legendary"
style="@style/RarityItem"
android:layout_width="@dimen/size_medium"
android:layout_height="@dimen/size_medium"
android:layout_width="@dimen/rarity_icon_size"
android:layout_height="@dimen/rarity_icon_size"
android:layout_centerVertical="true"
android:layout_toEndOf="@id/rarity_filter_epic"
android:src="@drawable/ic_rarity_legendary"
tools:visibility="visible" />
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/menu/menu_import.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
android:id="@+id/menu_import"
android:icon="@drawable/ic_import"
android:title="@string/menu_import"
app:showAsAction="always" />
app:showAsAction="ifRoom" />

</menu>
2 changes: 1 addition & 1 deletion app/src/main/res/menu/menu_sets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
android:id="@+id/menu_sets"
android:icon="@drawable/ic_sets"
android:title="@string/menu_sets"
app:showAsAction="always">
app:showAsAction="ifRoom">

<menu>

Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<!-- navigation_bar_height + default_margin-->
<dimen name="filter_hide_height">56dp</dimen>
<dimen name="filter_great_margin_bottom">42dp</dimen>
<dimen name="rarity_bg_max_width">260dp</dimen>
<dimen name="rarity_icon_size">@dimen/size_normal</dimen>
<dimen name="rarity_background_radius">48dp</dimen>
<dimen name="statistics_attributes_attr_padding">@dimen/small_margin</dimen>
<dimen name="statistics_attributes_height">48dp</dimen>
Expand All @@ -47,7 +47,6 @@
<dimen name="card_card_margin_top">@dimen/status_bar_height</dimen>
<!-- transparent navigation_bar_height + 36dp-->
<dimen name="card_bottom_sheet_peek_height">36dp</dimen>
<dimen name="card_bottom_sheet_margin_bottom">@dimen/navigation_bar_height</dimen>

<!-- Deck -->
<dimen name="deck_height">88dp</dimen>
Expand Down

0 comments on commit 145fa51

Please sign in to comment.