Added android 10 dark theme support
This commit is contained in:
parent
46cdedce0b
commit
153f1bd9d0
33 changed files with 372 additions and 352 deletions
|
@ -9,8 +9,6 @@ import android.view.View
|
|||
import androidx.core.app.ShareCompat
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||
import code.name.monkey.retromusic.Constants.APP_INSTAGRAM_LINK
|
||||
import code.name.monkey.retromusic.Constants.APP_TELEGRAM_LINK
|
||||
import code.name.monkey.retromusic.Constants.APP_TWITTER_LINK
|
||||
|
@ -60,16 +58,13 @@ class AboutActivity : AbsBaseActivity(), View.OnClickListener {
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_about)
|
||||
|
||||
setStatusbarColorAuto()
|
||||
setNavigationbarColorAuto()
|
||||
setLightNavigationBar(true)
|
||||
|
||||
loadContributors()
|
||||
setUpToolbar()
|
||||
|
||||
setSupportActionBar(toolbar)
|
||||
appVersion.text = getAppVersion()
|
||||
|
||||
setUpView()
|
||||
}
|
||||
|
||||
|
@ -83,10 +78,9 @@ class AboutActivity : AbsBaseActivity(), View.OnClickListener {
|
|||
}
|
||||
|
||||
private fun setUpToolbar() {
|
||||
appBarLayout.setBackgroundColor(ThemeStore.primaryColor(this))
|
||||
toolbar.setBackgroundColor(ThemeStore.primaryColor(this))
|
||||
setSupportActionBar(toolbar)
|
||||
ToolbarContentTintHelper.colorBackButton(toolbar, ThemeStore.textColorSecondary(this))
|
||||
//appBarLayout.setBackgroundColor(ThemeStore.primaryColor(this))
|
||||
//toolbar.setBackgroundColor(ThemeStore.primaryColor(this))
|
||||
//ToolbarContentTintHelper.colorBackButton(toolbar, ThemeStore.textColorSecondary(this))
|
||||
}
|
||||
|
||||
private fun openUrl(url: String) {
|
||||
|
|
|
@ -9,7 +9,6 @@ import android.transition.Slide
|
|||
import android.view.*
|
||||
import android.view.animation.AnimationUtils
|
||||
import android.widget.ImageView
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
|
@ -85,7 +84,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView {
|
|||
|
||||
contentContainer?.setCardBackgroundColor(ColorStateList.valueOf(ThemeStore.primaryColor(this)))
|
||||
|
||||
ActivityCompat.postponeEnterTransition(this)
|
||||
postponeEnterTransition()
|
||||
|
||||
artistImage = findViewById(R.id.artistImage)
|
||||
|
||||
|
@ -169,7 +168,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView {
|
|||
}
|
||||
|
||||
override fun complete() {
|
||||
ActivityCompat.startPostponedEnterTransition(this)
|
||||
scheduleStartPostponedTransition(image)
|
||||
}
|
||||
|
||||
override fun album(album: Album) {
|
||||
|
@ -224,6 +223,16 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView {
|
|||
})
|
||||
}
|
||||
|
||||
private fun scheduleStartPostponedTransition(image: ImageView) {
|
||||
image.viewTreeObserver.addOnPreDrawListener(object : ViewTreeObserver.OnPreDrawListener {
|
||||
override fun onPreDraw(): Boolean {
|
||||
image.viewTreeObserver.removeOnPreDrawListener(this)
|
||||
startPostponedEnterTransition();
|
||||
return true;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun setColors(color: Int) {
|
||||
val themeColor = if (PreferenceUtil.getInstance(this).adaptiveColor) color
|
||||
else ThemeStore.accentColor(this)
|
||||
|
|
|
@ -78,28 +78,18 @@ open class SongAdapter @JvmOverloads constructor(
|
|||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val song = dataSet[position]
|
||||
|
||||
val isChecked = isChecked(song)
|
||||
holder.itemView.isActivated = isChecked
|
||||
|
||||
if (holder.title != null) {
|
||||
holder.title!!.text = getSongTitle(song)
|
||||
}
|
||||
if (holder.text != null) {
|
||||
holder.text!!.text = getSongText(song)
|
||||
}
|
||||
holder.title?.text = getSongTitle(song)
|
||||
holder.text?.text = getSongText(song)
|
||||
loadAlbumCover(song, holder)
|
||||
}
|
||||
|
||||
private fun setColors(color: Int, holder: ViewHolder) {
|
||||
if (holder.paletteColorContainer != null) {
|
||||
holder.paletteColorContainer!!.setBackgroundColor(color)
|
||||
if (holder.title != null) {
|
||||
holder.title!!.setTextColor(MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)))
|
||||
}
|
||||
if (holder.text != null) {
|
||||
holder.text!!.setTextColor(MaterialValueHelper.getSecondaryTextColor(activity, ColorUtil.isColorLight(color)))
|
||||
}
|
||||
holder.paletteColorContainer?.setBackgroundColor(color)
|
||||
holder.title?.setTextColor(MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)))
|
||||
holder.text?.setTextColor(MaterialValueHelper.getSecondaryTextColor(activity, ColorUtil.isColorLight(color)))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,11 +10,9 @@ import android.text.SpannableStringBuilder
|
|||
import android.text.style.ForegroundColorSpan
|
||||
import android.view.*
|
||||
import android.view.animation.DecelerateInterpolator
|
||||
import android.widget.Toast
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.fragments.base.AbsMusicServiceFragment
|
||||
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
|
||||
import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
|
||||
|
@ -46,8 +44,6 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
view.setBackgroundColor(ThemeStore.primaryColor(requireContext()))
|
||||
view.setOnTouchListener(FlingPlayBackController(requireContext()))
|
||||
//view.setOnClickListener(v -> NavigationUtil.gotoNowPlayingActivity(getContext()));
|
||||
setUpMiniPlayer()
|
||||
|
|
|
@ -30,8 +30,6 @@ import java.util.Objects;
|
|||
|
||||
import code.name.monkey.appthemehelper.ThemeStore;
|
||||
import code.name.monkey.appthemehelper.common.ATHToolbarActivity;
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil;
|
||||
import code.name.monkey.appthemehelper.util.TintHelper;
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper;
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.dialogs.CreatePlaylistDialog;
|
||||
|
@ -54,7 +52,6 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
|||
|
||||
private Toolbar toolbar;
|
||||
private AppBarLayout appBarLayout;
|
||||
private View contentContainer;
|
||||
private MaterialCardView toolbarContainer;
|
||||
|
||||
private MaterialCab cab;
|
||||
|
@ -89,9 +86,8 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
|||
@Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_library, container, false);
|
||||
disposable = new CompositeDisposable();
|
||||
contentContainer = view.findViewById(R.id.fragmentContainer);
|
||||
toolbarContainer = view.findViewById(R.id.toolbarContainer);
|
||||
appBarLayout = view.findViewById(R.id.appBarLayout);
|
||||
toolbarContainer = view.findViewById(R.id.toolbarContainer);
|
||||
toolbar = view.findViewById(R.id.toolbar);
|
||||
PreferenceUtil.getInstance(requireActivity()).registerOnSharedPreferenceChangedListener(this);
|
||||
return view;
|
||||
|
@ -149,17 +145,15 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
|||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private void setupToolbar() {
|
||||
int primaryColor = ThemeStore.Companion.primaryColor(getContext());
|
||||
TintHelper.setTintAuto(contentContainer, primaryColor, true);
|
||||
appBarLayout.setBackgroundColor(primaryColor);
|
||||
toolbar.setBackgroundColor(RetroColorUtil.toolbarColor(getMainActivity()));
|
||||
//int primaryColor = ThemeStore.Companion.primaryColor(getContext());
|
||||
//TintHelper.setTintAuto(contentContainer, primaryColor, true);
|
||||
//appBarLayout.setBackgroundColor(primaryColor);
|
||||
//toolbar.setBackgroundColor(RetroColorUtil.toolbarColor(getMainActivity()));
|
||||
toolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp);
|
||||
toolbar.setOnClickListener(v -> {
|
||||
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(getMainActivity(), toolbarContainer, getString(R.string.transition_toolbar));
|
||||
NavigationUtil.goToSearch(getMainActivity(), options);
|
||||
});
|
||||
appBarLayout.addOnOffsetChangedListener((appBarLayout, verticalOffset) ->
|
||||
getMainActivity().setLightStatusbar(!ATHUtil.INSTANCE.isWindowBackgroundDark(getContext())));
|
||||
getMainActivity().setSupportActionBar(toolbar);
|
||||
toolbar.setNavigationOnClickListener(v -> showMainMenu(OptionsSheetDialogFragment.LIBRARY));
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ class ArtistImageFetcher(
|
|||
} catch (ignore: IOException) {
|
||||
// can't do much about it
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,15 +20,11 @@ import code.name.monkey.retromusic.adapter.HomeAdapter.Companion.RECENT_ALBUMS
|
|||
import code.name.monkey.retromusic.adapter.HomeAdapter.Companion.RECENT_ARTISTS
|
||||
import code.name.monkey.retromusic.adapter.HomeAdapter.Companion.TOP_ALBUMS
|
||||
import code.name.monkey.retromusic.adapter.HomeAdapter.Companion.TOP_ARTISTS
|
||||
import code.name.monkey.retromusic.model.Album
|
||||
import code.name.monkey.retromusic.model.Artist
|
||||
import code.name.monkey.retromusic.model.Home
|
||||
import code.name.monkey.retromusic.model.Playlist
|
||||
import code.name.monkey.retromusic.mvp.BaseView
|
||||
import code.name.monkey.retromusic.mvp.Presenter
|
||||
import code.name.monkey.retromusic.mvp.PresenterImpl
|
||||
import code.name.monkey.retromusic.providers.interfaces.Repository
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.disposables.Disposable
|
||||
import javax.inject.Inject
|
||||
|
@ -44,16 +40,20 @@ interface HomeView : BaseView {
|
|||
interface HomePresenter : Presenter<HomeView> {
|
||||
fun loadSections()
|
||||
|
||||
|
||||
class HomePresenterImpl @Inject constructor(
|
||||
private val repository: Repository
|
||||
) : PresenterImpl<HomeView>(), HomePresenter {
|
||||
|
||||
val hashSet: HashSet<Home> = HashSet()
|
||||
|
||||
override fun loadSections() {
|
||||
/*loadRecentArtists()
|
||||
loadRecentArtists()
|
||||
loadRecentAlbums()
|
||||
loadTopArtists()
|
||||
loadATopAlbums()
|
||||
loadFavorite()*/
|
||||
loadHomeSection()
|
||||
loadFavorite()
|
||||
//loadHomeSection()
|
||||
}
|
||||
|
||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
|
@ -67,7 +67,7 @@ interface HomePresenter : Presenter<HomeView> {
|
|||
}
|
||||
}
|
||||
|
||||
/*private fun loadRecentArtists() {
|
||||
private fun loadRecentArtists() {
|
||||
disposable += repository.recentArtistsFlowable
|
||||
.subscribe {
|
||||
if (it.isNotEmpty()) hashSet.add(
|
||||
|
@ -140,9 +140,9 @@ interface HomePresenter : Presenter<HomeView> {
|
|||
))
|
||||
showData(ArrayList(hashSet))
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
private fun loadHomeSection() {
|
||||
/*private fun loadHomeSection() {
|
||||
val ob = listOf(repository.recentArtistsFlowable,
|
||||
repository.recentAlbumsFlowable,
|
||||
repository.topArtistsFlowable,
|
||||
|
@ -200,7 +200,7 @@ interface HomePresenter : Presenter<HomeView> {
|
|||
}.subscribe {
|
||||
view.sections(ArrayList(it))
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,18 +12,19 @@
|
|||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.loaders
|
||||
|
||||
package code.name.monkey.retromusic.util
|
||||
|
||||
import android.content.Context
|
||||
import code.name.monkey.retromusic.model.Playlist
|
||||
import code.name.monkey.retromusic.model.smartplaylist.AbsSmartPlaylist
|
||||
import code.name.monkey.retromusic.model.smartplaylist.HistoryPlaylist
|
||||
import code.name.monkey.retromusic.model.smartplaylist.LastAddedPlaylist
|
||||
import code.name.monkey.retromusic.model.smartplaylist.MyTopTracksPlaylist
|
||||
import io.reactivex.Observable
|
||||
|
||||
object HomeLoader {
|
||||
|
||||
import androidx.annotation.AttrRes
|
||||
|
||||
object AttrsUtil {
|
||||
@JvmOverloads
|
||||
fun resolveColor(context: Context, @AttrRes attr: Int, fallback: Int = 0): Int {
|
||||
val a = context.theme.obtainStyledAttributes(intArrayOf(attr))
|
||||
try {
|
||||
return a.getColor(0, fallback)
|
||||
} finally {
|
||||
a.recycle()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,195 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Paint;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.TypedValue;
|
||||
|
||||
import androidx.annotation.FontRes;
|
||||
|
||||
import com.google.android.material.textview.MaterialTextView;
|
||||
|
||||
import code.name.monkey.retromusic.R;
|
||||
|
||||
public class BaselineGridTextView extends MaterialTextView {
|
||||
|
||||
private final float FOUR_DIP;
|
||||
|
||||
private float lineHeightMultiplierHint = 1f;
|
||||
private float lineHeightHint = 0f;
|
||||
private boolean maxLinesByHeight = false;
|
||||
private int extraTopPadding = 0;
|
||||
private int extraBottomPadding = 0;
|
||||
private @FontRes
|
||||
int fontResId = 0;
|
||||
|
||||
public BaselineGridTextView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public BaselineGridTextView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, android.R.attr.textViewStyle);
|
||||
}
|
||||
|
||||
public BaselineGridTextView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
|
||||
final TypedArray a = context.obtainStyledAttributes(
|
||||
attrs, R.styleable.BaselineGridTextView, defStyleAttr, 0);
|
||||
|
||||
// first check TextAppearance for line height & font attributes
|
||||
if (a.hasValue(R.styleable.BaselineGridTextView_android_textAppearance)) {
|
||||
int textAppearanceId =
|
||||
a.getResourceId(R.styleable.BaselineGridTextView_android_textAppearance,
|
||||
android.R.style.TextAppearance);
|
||||
TypedArray ta = context.obtainStyledAttributes(
|
||||
textAppearanceId, R.styleable.BaselineGridTextView);
|
||||
parseTextAttrs(ta);
|
||||
ta.recycle();
|
||||
}
|
||||
|
||||
// then check view attrs
|
||||
parseTextAttrs(a);
|
||||
maxLinesByHeight = a.getBoolean(R.styleable.BaselineGridTextView_maxLinesByHeight, false);
|
||||
a.recycle();
|
||||
|
||||
FOUR_DIP = TypedValue.applyDimension(
|
||||
TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics());
|
||||
computeLineHeight();
|
||||
}
|
||||
|
||||
public float getLineHeightMultiplierHint() {
|
||||
return lineHeightMultiplierHint;
|
||||
}
|
||||
|
||||
public void setLineHeightMultiplierHint(float lineHeightMultiplierHint) {
|
||||
this.lineHeightMultiplierHint = lineHeightMultiplierHint;
|
||||
computeLineHeight();
|
||||
}
|
||||
|
||||
public float getLineHeightHint() {
|
||||
return lineHeightHint;
|
||||
}
|
||||
|
||||
public void setLineHeightHint(float lineHeightHint) {
|
||||
this.lineHeightHint = lineHeightHint;
|
||||
computeLineHeight();
|
||||
}
|
||||
|
||||
public boolean getMaxLinesByHeight() {
|
||||
return maxLinesByHeight;
|
||||
}
|
||||
|
||||
public void setMaxLinesByHeight(boolean maxLinesByHeight) {
|
||||
this.maxLinesByHeight = maxLinesByHeight;
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
public @FontRes
|
||||
int getFontResId() {
|
||||
return fontResId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCompoundPaddingTop() {
|
||||
// include extra padding to place the first line's baseline on the grid
|
||||
return super.getCompoundPaddingTop() + extraTopPadding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCompoundPaddingBottom() {
|
||||
// include extra padding to make the height a multiple of 4dp
|
||||
return super.getCompoundPaddingBottom() + extraBottomPadding;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
extraTopPadding = 0;
|
||||
extraBottomPadding = 0;
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
int height = getMeasuredHeight();
|
||||
height += ensureBaselineOnGrid();
|
||||
height += ensureHeightGridAligned(height);
|
||||
setMeasuredDimension(getMeasuredWidth(), height);
|
||||
checkMaxLines(height, MeasureSpec.getMode(heightMeasureSpec));
|
||||
}
|
||||
|
||||
private void parseTextAttrs(TypedArray a) {
|
||||
if (a.hasValue(R.styleable.BaselineGridTextView_lineHeightMultiplierHint)) {
|
||||
lineHeightMultiplierHint =
|
||||
a.getFloat(R.styleable.BaselineGridTextView_lineHeightMultiplierHint, 1f);
|
||||
}
|
||||
if (a.hasValue(R.styleable.BaselineGridTextView_lineHeightHint)) {
|
||||
lineHeightHint = a.getDimensionPixelSize(
|
||||
R.styleable.BaselineGridTextView_lineHeightHint, 0);
|
||||
}
|
||||
if (a.hasValue(R.styleable.BaselineGridTextView_android_fontFamily)) {
|
||||
fontResId = a.getResourceId(R.styleable.BaselineGridTextView_android_fontFamily, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures line height is a multiple of 4dp.
|
||||
*/
|
||||
private void computeLineHeight() {
|
||||
final Paint.FontMetrics fm = getPaint().getFontMetrics();
|
||||
final float fontHeight = Math.abs(fm.ascent - fm.descent) + fm.leading;
|
||||
final float desiredLineHeight = (lineHeightHint > 0)
|
||||
? lineHeightHint
|
||||
: lineHeightMultiplierHint * fontHeight;
|
||||
|
||||
final int baselineAlignedLineHeight =
|
||||
(int) ((FOUR_DIP * (float) Math.ceil(desiredLineHeight / FOUR_DIP)) + 0.5f);
|
||||
setLineSpacing(baselineAlignedLineHeight - fontHeight, 1f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the first line of text sits on the 4dp grid.
|
||||
*/
|
||||
private int ensureBaselineOnGrid() {
|
||||
float baseline = getBaseline();
|
||||
float gridAlign = baseline % FOUR_DIP;
|
||||
if (gridAlign != 0) {
|
||||
extraTopPadding = (int) (FOUR_DIP - Math.ceil(gridAlign));
|
||||
}
|
||||
return extraTopPadding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that height is a multiple of 4dp.
|
||||
*/
|
||||
private int ensureHeightGridAligned(int height) {
|
||||
float gridOverhang = height % FOUR_DIP;
|
||||
if (gridOverhang != 0) {
|
||||
extraBottomPadding = (int) (FOUR_DIP - Math.ceil(gridOverhang));
|
||||
}
|
||||
return extraBottomPadding;
|
||||
}
|
||||
|
||||
/**
|
||||
* When measured with an exact height, text can be vertically clipped mid-line. Prevent
|
||||
* this by setting the {@code maxLines} property based on the available space.
|
||||
*/
|
||||
private void checkMaxLines(int height, int heightMode) {
|
||||
if (!maxLinesByHeight || heightMode != MeasureSpec.EXACTLY) return;
|
||||
|
||||
int textHeight = height - getCompoundPaddingTop() - getCompoundPaddingBottom();
|
||||
int completeLines = (int) Math.floor(textHeight / getLineHeight());
|
||||
setMaxLines(completeLines);
|
||||
}
|
||||
}
|
|
@ -35,11 +35,11 @@ class WidthFitSquareCardView : MaterialCardView {
|
|||
}
|
||||
|
||||
override fun onMeasure(i: Int, i2: Int) {
|
||||
var i2 = i2
|
||||
var width = i2
|
||||
if (this.forceSquare) {
|
||||
i2 = i
|
||||
width = i
|
||||
}
|
||||
super.onMeasure(i, i2)
|
||||
super.onMeasure(i, width)
|
||||
}
|
||||
|
||||
private var forceSquare = true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue