Add activity-wise Multiwindow support

This commit is contained in:
suhan-paradkar 2021-07-11 10:08:53 +05:30 committed by Wisest_wizard
parent 0e83bc40d9
commit 6d0cbbf62d
4 changed files with 34 additions and 7 deletions

View File

@ -18,9 +18,7 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning"
android:resizeableActivity="true"
android:debuggable="true"
android:supportsPictureInPicture="true">
android:debuggable="true">
<service
android:name=".LorieService"
android:enabled="true"
@ -33,7 +31,9 @@
<activity android:name=".MainActivity"
android:theme="@style/NoActionBar"
android:launchMode="singleInstance"
android:configChanges="fontScale|orientation|screenSize|keyboard|keyboardHidden|layoutDirection|locale|mcc|mnc|navigation|screenLayout|touchscreen|uiMode|smallestScreenSize|density">
android:supportsPictureInPicture="true"
android:configChanges="fontScale|orientation|screenSize|keyboard|keyboardHidden|layoutDirection|locale|mcc|mnc|navigation|screenLayout|touchscreen|uiMode|smallestScreenSize|density"
android:resizeableActivity="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@ -46,7 +46,9 @@
<activity
android:theme="@style/Theme.AppCompat.DayNight"
android:excludeFromRecents="true"
android:name=".LoriePreferences" >
android:name=".LoriePreferences"
android:supportsPictureInPicture="false"
android:resizeableActivity="true">
</activity>
<meta-data android:name="com.samsung.android.multidisplay.keep_process_alive" android:value="true"/>
<meta-data android:name="android.allow_multiple_resumed_activities" android:value="true" />

View File

@ -70,6 +70,12 @@ public class AdditionalKeyboardView extends HorizontalScrollView implements View
return;
}
if (isInPictureInPictureMode()) {
if (getVisibility() != View.GONE)
setVisibility(View.GONE);
return;
}
Rect r = new Rect();
getWindowVisibleDisplayFrame(r);

View File

@ -113,4 +113,11 @@ public class MainActivity extends AppCompatActivity {
@Override
public void onBackPressed() {}
@Override
public void onUserLeaveHint () {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
if (preferences.getBooolean("PIP", true)) {
enterPictureInPictureMode();
}
}
}

View File

@ -1,18 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference android:title="Show additional keyboard"
<CheckBoxPreference
android:title="Show additional keyboard"
android:defaultValue="true"
android:summary="Show keyboard with additional keys if soft keyboard is visible"
android:key="showAdditionalKbd" />
<CheckBoxPreference android:title="Fullscreen mode"
<CheckBoxPreference
android:title="Fullscreen mode"
android:defaultValue="false"
android:key="fullscreen" />
<ListPreference
android:title="Touchscreen input mode"
android:key="touchMode"
android:defaultValue="1"
android:entries="@array/touchscreenInputModesEntries"
android:entryValues="@array/touchscreenInputModesValues" />
<CheckBoxPreference
android:title="Show IME with external keyboard"
android:defaultValue="false"
@ -24,4 +30,10 @@
android:key="Reseed"
android:summary="The screen size will be adjusted while Soft Keybourd is open. Additional Keybaord is not supported by this option." />
<CheckBoxPreference
android:title="PIP Mode"
android:defaultValue="true"
android:key="PIP"
android:summary="Show app in picture-in-picture mode when home button or recents button is pressed" />
</PreferenceScreen>