66 lines
2.6 KiB
Java
66 lines
2.6 KiB
Java
package androidx.core.view;
|
|
|
|
import android.R;
|
|
import android.content.Context;
|
|
import android.content.res.Resources;
|
|
import android.os.Build;
|
|
import android.util.Log;
|
|
import android.util.TypedValue;
|
|
import android.view.ViewConfiguration;
|
|
import java.lang.reflect.Method;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class ViewConfigurationCompat {
|
|
private static Method a;
|
|
|
|
static {
|
|
if (Build.VERSION.SDK_INT == 25) {
|
|
try {
|
|
a = ViewConfiguration.class.getDeclaredMethod("getScaledScrollFactor", new Class[0]);
|
|
} catch (Exception unused) {
|
|
Log.i("ViewConfigCompat", "Could not find method getScaledScrollFactor() on ViewConfiguration");
|
|
}
|
|
}
|
|
}
|
|
|
|
private static float a(ViewConfiguration viewConfiguration, Context context) {
|
|
Method method;
|
|
if (Build.VERSION.SDK_INT >= 25 && (method = a) != null) {
|
|
try {
|
|
return ((Integer) method.invoke(viewConfiguration, new Object[0])).intValue();
|
|
} catch (Exception unused) {
|
|
Log.i("ViewConfigCompat", "Could not find method getScaledScrollFactor() on ViewConfiguration");
|
|
}
|
|
}
|
|
TypedValue typedValue = new TypedValue();
|
|
if (context.getTheme().resolveAttribute(R.attr.listPreferredItemHeight, typedValue, true)) {
|
|
return typedValue.getDimension(context.getResources().getDisplayMetrics());
|
|
}
|
|
return 0.0f;
|
|
}
|
|
|
|
public static float b(ViewConfiguration viewConfiguration, Context context) {
|
|
return Build.VERSION.SDK_INT >= 26 ? viewConfiguration.getScaledHorizontalScrollFactor() : a(viewConfiguration, context);
|
|
}
|
|
|
|
public static float c(ViewConfiguration viewConfiguration, Context context) {
|
|
return Build.VERSION.SDK_INT >= 26 ? viewConfiguration.getScaledVerticalScrollFactor() : a(viewConfiguration, context);
|
|
}
|
|
|
|
public static boolean d(ViewConfiguration viewConfiguration, Context context) {
|
|
if (Build.VERSION.SDK_INT >= 28) {
|
|
return viewConfiguration.shouldShowMenuShortcutsWhenKeyboardPresent();
|
|
}
|
|
Resources resources = context.getResources();
|
|
int identifier = resources.getIdentifier("config_showMenuShortcutsWhenKeyboardPresent", "bool", "android");
|
|
return identifier != 0 && resources.getBoolean(identifier);
|
|
}
|
|
|
|
public static int a(ViewConfiguration viewConfiguration) {
|
|
if (Build.VERSION.SDK_INT >= 28) {
|
|
return viewConfiguration.getScaledHoverSlop();
|
|
}
|
|
return viewConfiguration.getScaledTouchSlop() / 2;
|
|
}
|
|
}
|