From 1f0aa4e79bc6c68fa5e0af2590a98092f7b79667 Mon Sep 17 00:00:00 2001 From: Gabriele M Date: Mon, 17 Jul 2017 12:25:49 +0200 Subject: [PATCH] Collapse header if the device has no touchscreen The header can't be collpased without a touchscreen, so collapse it if we detect that the current device has no touchscreen. --- src/org/lineageos/updater/UpdatesActivity.java | 5 +++++ src/org/lineageos/updater/misc/Utils.java | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/org/lineageos/updater/UpdatesActivity.java b/src/org/lineageos/updater/UpdatesActivity.java index 702c5a84..1ef6f8fa 100644 --- a/src/org/lineageos/updater/UpdatesActivity.java +++ b/src/org/lineageos/updater/UpdatesActivity.java @@ -138,6 +138,11 @@ public class UpdatesActivity extends AppCompatActivity { } } }); + + if (!Utils.hasTouchscreen(this)) { + // This can't be collapsed without a touchscreen + appBar.setExpanded(false); + } } @Override diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index be7fc21b..ed13db44 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -17,6 +17,7 @@ package org.lineageos.updater.misc; import android.content.Context; import android.content.Intent; +import android.content.pm.PackageManager; import android.content.SharedPreferences; import android.net.ConnectivityManager; import android.net.NetworkInfo; @@ -280,4 +281,8 @@ public class Utils { zipFile.close(); return isAB; } + + public static boolean hasTouchscreen(Context context) { + return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN); + } }