mirror of
https://github.com/yuliskov/SmartTube.git
synced 2026-03-13 15:20:26 +08:00
Fix API 28+ GridLayoutManager navigation is totally broken
This commit is contained in:
Submodule MediaServiceCore updated: 7e0a31bee0...abf1a23900
@@ -57,8 +57,8 @@ android {
|
||||
applicationId "app.smarttube"
|
||||
minSdkVersion project.properties.minSdkVersion
|
||||
targetSdkVersion project.properties.targetSdkVersion
|
||||
versionCode 2293
|
||||
versionName "31.03"
|
||||
versionCode 2296
|
||||
versionName "31.06"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
buildConfigField "long", "TIMESTAMP", System.currentTimeMillis() + "L"
|
||||
|
||||
@@ -127,11 +127,11 @@ android {
|
||||
productFlavors {
|
||||
stbeta {
|
||||
applicationId "org.smarttube.beta"
|
||||
targetSdkVersion 27 // Since 28+ GridLayoutManager navigation is totally broken
|
||||
targetSdkVersion project.properties.compileSdkVersion
|
||||
}
|
||||
ststable {
|
||||
applicationId "org.smarttube.stable"
|
||||
targetSdkVersion 27 // Since 28+ GridLayoutManager navigation is totally broken
|
||||
targetSdkVersion project.properties.compileSdkVersion
|
||||
}
|
||||
stfdroid {
|
||||
applicationId "app.smarttube.fdroid"
|
||||
|
||||
@@ -18,6 +18,7 @@ import android.widget.TextView;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.liskovsoft.smartyoutubetv2.tv.R;
|
||||
import com.liskovsoft.smartyoutubetv2.tv.util.ViewUtil;
|
||||
|
||||
@SuppressLint("AppCompatCustomView")
|
||||
public class MarqueeTextViewCompat extends TextView {
|
||||
@@ -126,6 +127,8 @@ public class MarqueeTextViewCompat extends TextView {
|
||||
mTextView.setEllipsize(TruncateAt.END);
|
||||
|
||||
super.setEllipsize(TruncateAt.END); // Important: disable marquee on the container view
|
||||
|
||||
ViewUtil.fixApi28BrokenGridNavigation(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -244,4 +244,21 @@ public class ViewUtil {
|
||||
frameLayout.setLayoutParams(flp);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix SDK 28+ GridLayoutManager broken navigation when using Japanese fonts
|
||||
*/
|
||||
public static void fixApi28BrokenGridNavigation(TextView textView) {
|
||||
if (VERSION.SDK_INT >= 28) {
|
||||
// 1. Disable dynamic line spacing for special characters (prevents expansion for CJK glyphs)
|
||||
textView.setFallbackLineSpacing(false);
|
||||
}
|
||||
|
||||
// 2. Remove system font padding to ensure consistent baseline and height
|
||||
textView.setIncludeFontPadding(false);
|
||||
|
||||
// 3. Add fixed internal padding to create a "safe zone" for both Latin and Japanese text
|
||||
int paddingExtra = (int) (4 * textView.getResources().getDisplayMetrics().density);
|
||||
textView.setPadding(textView.getPaddingLeft(), paddingExtra, textView.getPaddingRight(), paddingExtra);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user