mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-06-17 06:10:58 +00:00
Fix grid/list items being occluded by the navbar on Q with gestures off
This commit is contained in:
@@ -560,6 +560,7 @@ public class AppView extends Activity implements AdapterFragmentCallbacks {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
UiHelper.applyStatusBarPadding(listView);
|
||||||
registerForContextMenu(listView);
|
registerForContextMenu(listView);
|
||||||
listView.requestFocus();
|
listView.requestFocus();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -716,6 +716,7 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
UiHelper.applyStatusBarPadding(listView);
|
||||||
registerForContextMenu(listView);
|
registerForContextMenu(listView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ import android.preference.PreferenceManager;
|
|||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
import android.util.Range;
|
import android.util.Range;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import com.limelight.LimeLog;
|
import com.limelight.LimeLog;
|
||||||
import com.limelight.PcView;
|
import com.limelight.PcView;
|
||||||
@@ -121,9 +124,17 @@ public class StreamSettings extends Activity {
|
|||||||
.apply();
|
.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
UiHelper.applyStatusBarPadding(view);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
addPreferencesFromResource(R.xml.preferences);
|
addPreferencesFromResource(R.xml.preferences);
|
||||||
PreferenceScreen screen = getPreferenceScreen();
|
PreferenceScreen screen = getPreferenceScreen();
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import android.app.AlertDialog;
|
|||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
|
import android.graphics.Insets;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.WindowInsets;
|
import android.view.WindowInsets;
|
||||||
@@ -40,7 +41,24 @@ public class UiHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void notifyNewRootView(Activity activity)
|
public static void applyStatusBarPadding(View view) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
|
// This applies the padding that we omitted in notifyNewRootView() on Q
|
||||||
|
view.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
|
||||||
|
@Override
|
||||||
|
public WindowInsets onApplyWindowInsets(View view, WindowInsets windowInsets) {
|
||||||
|
view.setPadding(view.getPaddingLeft(),
|
||||||
|
view.getPaddingTop(),
|
||||||
|
view.getPaddingRight(),
|
||||||
|
windowInsets.getTappableElementInsets().bottom);
|
||||||
|
return windowInsets;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
view.requestApplyInsets();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void notifyNewRootView(final Activity activity)
|
||||||
{
|
{
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
// Allow this non-streaming activity to layout under notches.
|
// Allow this non-streaming activity to layout under notches.
|
||||||
@@ -55,13 +73,25 @@ public class UiHelper {
|
|||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
// Draw under the status bar on Android Q devices
|
// Draw under the status bar on Android Q devices
|
||||||
|
|
||||||
activity.getWindow().getDecorView().setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
|
// Using getDecorView() here breaks the translucent status/navigation bar when gestures are disabled
|
||||||
|
activity.findViewById(android.R.id.content).setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
|
||||||
@Override
|
@Override
|
||||||
public WindowInsets onApplyWindowInsets(View view, WindowInsets windowInsets) {
|
public WindowInsets onApplyWindowInsets(View view, WindowInsets windowInsets) {
|
||||||
view.setPadding(windowInsets.getSystemWindowInsetLeft(),
|
// Use the tappable insets so we can draw under the status bar in gesture mode
|
||||||
windowInsets.getSystemWindowInsetTop(),
|
Insets tappableInsets = windowInsets.getTappableElementInsets();
|
||||||
windowInsets.getSystemWindowInsetRight(),
|
view.setPadding(tappableInsets.left,
|
||||||
|
tappableInsets.top,
|
||||||
|
tappableInsets.right,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
|
// Show a translucent navigation bar if we can't tap there
|
||||||
|
if (tappableInsets.bottom != 0) {
|
||||||
|
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
|
||||||
|
}
|
||||||
|
|
||||||
return windowInsets;
|
return windowInsets;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,9 +3,6 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
|
||||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
|
||||||
android:paddingTop="@dimen/activity_vertical_margin"
|
|
||||||
tools:context=".PcView" >
|
tools:context=".PcView" >
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
@@ -25,6 +22,8 @@
|
|||||||
android:id="@+id/no_pc_found_layout"
|
android:id="@+id/no_pc_found_layout"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_centerHorizontal="true">
|
android:layout_centerHorizontal="true">
|
||||||
|
|||||||
@@ -8,4 +8,5 @@
|
|||||||
android:stretchMode="spacingWidthUniform"
|
android:stretchMode="spacingWidthUniform"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:focusableInTouchMode="true"
|
android:focusableInTouchMode="true"
|
||||||
|
android:clipToPadding="false"
|
||||||
android:gravity="center"/>
|
android:gravity="center"/>
|
||||||
@@ -8,4 +8,5 @@
|
|||||||
android:stretchMode="spacingWidthUniform"
|
android:stretchMode="spacingWidthUniform"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:focusableInTouchMode="true"
|
android:focusableInTouchMode="true"
|
||||||
|
android:clipToPadding="false"
|
||||||
android:gravity="center"/>
|
android:gravity="center"/>
|
||||||
@@ -1,19 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:orientation="vertical" android:layout_width="match_parent"
|
android:id="@+id/fragmentView"
|
||||||
android:layout_height="match_parent">
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
<ListView
|
android:fastScrollEnabled="true"
|
||||||
android:id="@+id/fragmentView"
|
android:longClickable="false"
|
||||||
android:layout_width="match_parent"
|
android:focusable="true"
|
||||||
android:layout_height="match_parent"
|
android:focusableInTouchMode="true"
|
||||||
android:background="@drawable/list_view_unselected"
|
android:stackFromBottom="false"
|
||||||
android:fastScrollEnabled="true"
|
android:clipToPadding="false"/>
|
||||||
android:longClickable="false"
|
|
||||||
android:focusable="true"
|
|
||||||
android:focusableInTouchMode="true"
|
|
||||||
android:stackFromBottom="false" >
|
|
||||||
|
|
||||||
</ListView>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
@@ -9,4 +9,5 @@
|
|||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:focusableInTouchMode="true"
|
android:focusableInTouchMode="true"
|
||||||
android:nextFocusLeft="@id/settingsButton"
|
android:nextFocusLeft="@id/settingsButton"
|
||||||
|
android:clipToPadding="false"
|
||||||
android:gravity="center"/>
|
android:gravity="center"/>
|
||||||
@@ -9,4 +9,5 @@
|
|||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:focusableInTouchMode="true"
|
android:focusableInTouchMode="true"
|
||||||
android:nextFocusLeft="@id/settingsButton"
|
android:nextFocusLeft="@id/settingsButton"
|
||||||
|
android:clipToPadding="false"
|
||||||
android:gravity="center"/>
|
android:gravity="center"/>
|
||||||
Reference in New Issue
Block a user