Adds manual tablet mode setting
Co-authored-by: TiA4f8R <74829229+TiA4f8R@users.noreply.github.com>
This commit is contained in:
parent
56cd84c1fe
commit
e01ef42d31
|
@ -12,8 +12,10 @@ import android.view.KeyEvent;
|
|||
import androidx.annotation.Dimension;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import org.schabi.newpipe.App;
|
||||
import org.schabi.newpipe.R;
|
||||
|
||||
public final class DeviceUtils {
|
||||
|
||||
|
@ -65,10 +67,18 @@ public final class DeviceUtils {
|
|||
}
|
||||
|
||||
public static boolean isTablet(@NonNull final Context context) {
|
||||
return (context
|
||||
.getResources()
|
||||
.getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK)
|
||||
>= Configuration.SCREENLAYOUT_SIZE_LARGE;
|
||||
final String tabletModeSetting = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
.getString(context.getString(R.string.tablet_mode_key), "");
|
||||
|
||||
if (tabletModeSetting.equals(context.getString(R.string.tablet_mode_on_key))) {
|
||||
return true;
|
||||
} else if (tabletModeSetting.equals(context.getString(R.string.tablet_mode_off_key))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// else automatically determine whether we are in a tablet or not
|
||||
return (context.getResources().getConfiguration().screenLayout
|
||||
& Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE;
|
||||
}
|
||||
|
||||
public static boolean isConfirmKey(final int keyCode) {
|
||||
|
|
|
@ -1220,5 +1220,22 @@
|
|||
<item>@string/grid</item>
|
||||
</string-array>
|
||||
|
||||
<string name="tablet_mode_key" translatable="false">tablet_mode</string>
|
||||
<string name="tablet_mode_value" translatable="false">@string/tablet_mode_auto_key</string>
|
||||
|
||||
<string name="tablet_mode_auto_key" translatable="false">auto</string>
|
||||
<string name="tablet_mode_on_key" translatable="false">on</string>
|
||||
<string name="tablet_mode_off_key" translatable="false">off</string>
|
||||
<string-array name="tablet_mode_values" translatable="false">
|
||||
<item>@string/tablet_mode_auto_key</item>
|
||||
<item>@string/tablet_mode_on_key</item>
|
||||
<item>@string/tablet_mode_off_key</item>
|
||||
</string-array>
|
||||
<string-array name="tablet_mode_description" translatable="false">
|
||||
<item>@string/auto</item>
|
||||
<item>@string/on</item>
|
||||
<item>@string/off</item>
|
||||
</string-array>
|
||||
|
||||
<string name="recaptcha_cookies_key" translatable="false">recaptcha_cookies_key</string>
|
||||
</resources>
|
||||
|
|
|
@ -742,5 +742,8 @@
|
|||
<string name="metadata_privacy_unlisted">Unlisted</string>
|
||||
<string name="metadata_privacy_private">Private</string>
|
||||
<string name="metadata_privacy_internal">Internal</string>
|
||||
<string name="open_website_license">Open Website</string>
|
||||
<string name="open_website_license">Open website</string>
|
||||
<string name="tablet_mode_title">Tablet mode</string>
|
||||
<string name="on">On</string>
|
||||
<string name="off">Off</string>
|
||||
</resources>
|
|
@ -43,4 +43,12 @@
|
|||
android:title="@string/caption_setting_title"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="@string/tablet_mode_auto_key"
|
||||
android:entries="@array/tablet_mode_description"
|
||||
android:entryValues="@array/tablet_mode_values"
|
||||
android:key="@string/tablet_mode_key"
|
||||
android:summary="%s"
|
||||
android:title="@string/tablet_mode_title"
|
||||
app:iconSpaceReserved="false" />
|
||||
</PreferenceScreen>
|
||||
|
|
Loading…
Reference in New Issue