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:supportsRtl="true"
android:theme="@style/AppTheme" android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning" tools:ignore="GoogleAppIndexingWarning"
android:resizeableActivity="true" android:debuggable="true">
android:debuggable="true"
android:supportsPictureInPicture="true">
<service <service
android:name=".LorieService" android:name=".LorieService"
android:enabled="true" android:enabled="true"
@ -33,7 +31,9 @@
<activity android:name=".MainActivity" <activity android:name=".MainActivity"
android:theme="@style/NoActionBar" android:theme="@style/NoActionBar"
android:launchMode="singleInstance" 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> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
@ -46,7 +46,9 @@
<activity <activity
android:theme="@style/Theme.AppCompat.DayNight" android:theme="@style/Theme.AppCompat.DayNight"
android:excludeFromRecents="true" android:excludeFromRecents="true"
android:name=".LoriePreferences" > android:name=".LoriePreferences"
android:supportsPictureInPicture="false"
android:resizeableActivity="true">
</activity> </activity>
<meta-data android:name="com.samsung.android.multidisplay.keep_process_alive" android:value="true"/> <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" /> <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; return;
} }
if (isInPictureInPictureMode()) {
if (getVisibility() != View.GONE)
setVisibility(View.GONE);
return;
}
Rect r = new Rect(); Rect r = new Rect();
getWindowVisibleDisplayFrame(r); getWindowVisibleDisplayFrame(r);

View File

@ -113,4 +113,11 @@ public class MainActivity extends AppCompatActivity {
@Override @Override
public void onBackPressed() {} 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"?> <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <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:defaultValue="true"
android:summary="Show keyboard with additional keys if soft keyboard is visible" android:summary="Show keyboard with additional keys if soft keyboard is visible"
android:key="showAdditionalKbd" /> android:key="showAdditionalKbd" />
<CheckBoxPreference android:title="Fullscreen mode"
<CheckBoxPreference
android:title="Fullscreen mode"
android:defaultValue="false" android:defaultValue="false"
android:key="fullscreen" /> android:key="fullscreen" />
<ListPreference <ListPreference
android:title="Touchscreen input mode" android:title="Touchscreen input mode"
android:key="touchMode" android:key="touchMode"
android:defaultValue="1" android:defaultValue="1"
android:entries="@array/touchscreenInputModesEntries" android:entries="@array/touchscreenInputModesEntries"
android:entryValues="@array/touchscreenInputModesValues" /> android:entryValues="@array/touchscreenInputModesValues" />
<CheckBoxPreference <CheckBoxPreference
android:title="Show IME with external keyboard" android:title="Show IME with external keyboard"
android:defaultValue="false" android:defaultValue="false"
@ -24,4 +30,10 @@
android:key="Reseed" android:key="Reseed"
android:summary="The screen size will be adjusted while Soft Keybourd is open. Additional Keybaord is not supported by this option." /> 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> </PreferenceScreen>