lineage-sdk: Rewrite Lineage preference classes used in about phone view
* Now extending TextView to match Android P settings. Change-Id: Ieed7174a92e3801e6c782b39c36731a67ae1be59
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The LineageOS Project
|
||||
* Copyright (C) 2018 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,39 +17,22 @@
|
||||
package org.lineageos.internal.preference.deviceinfo;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.SystemProperties;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import lineageos.preference.SelfRemovingPreference;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.lineageos.platform.internal.R;
|
||||
|
||||
public class LineageAPIVersionPreference extends SelfRemovingPreference {
|
||||
private static final String TAG = "LineageAPIVersionPreference";
|
||||
public class LineageAPIVersionTextView extends TextView {
|
||||
private static final String TAG = "LineageAPIVersionTextView";
|
||||
|
||||
private static final String KEY_BUILD_DATE_PROP = "ro.build.date";
|
||||
|
||||
public LineageAPIVersionPreference(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
public LineageAPIVersionPreference(Context context, AttributeSet attrs) {
|
||||
public LineageAPIVersionTextView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public LineageAPIVersionPreference(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttached() {
|
||||
super.onAttached();
|
||||
|
||||
setTitle(R.string.lineage_api_level);
|
||||
final int sdk = lineageos.os.Build.LINEAGE_VERSION.SDK_INT;
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(lineageos.os.Build.getNameForSDKInt(sdk))
|
||||
.append(" (" + sdk + ")");
|
||||
setSummary(builder.toString());
|
||||
setText(builder.toString());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The LineageOS Project
|
||||
* Copyright (C) 2018 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,34 +19,19 @@ package org.lineageos.internal.preference.deviceinfo;
|
||||
import android.content.Context;
|
||||
import android.os.SystemProperties;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import lineageos.preference.SelfRemovingPreference;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.lineageos.platform.internal.R;
|
||||
|
||||
public class LineageBuildDatePreference extends SelfRemovingPreference {
|
||||
private static final String TAG = "LineageBuildDatePreference";
|
||||
public class LineageBuildDateTextView extends TextView {
|
||||
private static final String TAG = "LineageAPIVersionTextView";
|
||||
|
||||
private static final String KEY_BUILD_DATE_PROP = "ro.build.date";
|
||||
|
||||
public LineageBuildDatePreference(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
public LineageBuildDatePreference(Context context, AttributeSet attrs) {
|
||||
public LineageBuildDateTextView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public LineageBuildDatePreference(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttached() {
|
||||
super.onAttached();
|
||||
|
||||
setTitle(R.string.build_date);
|
||||
setSummary(SystemProperties.get(KEY_BUILD_DATE_PROP,
|
||||
setText(SystemProperties.get(KEY_BUILD_DATE_PROP,
|
||||
getContext().getResources().getString(R.string.unknown)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,8 +21,7 @@ import android.content.Context;
|
||||
import android.os.SystemProperties;
|
||||
import android.text.format.DateFormat;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import lineageos.preference.SelfRemovingPreference;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.lineageos.platform.internal.R;
|
||||
|
||||
@@ -31,41 +30,18 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
public class LineageVendorSecurityPatchPreference extends SelfRemovingPreference {
|
||||
public class LineageVendorSecurityPatchTextView extends TextView {
|
||||
private static final String TAG = "LineageVendorSecurityPatchTextView";
|
||||
|
||||
private static final String KEY_AOSP_VENDOR_SECURITY_PATCH =
|
||||
"ro.vendor.build.security_patch";
|
||||
|
||||
private static final String KEY_LINEAGE_VENDOR_SECURITY_PATCH =
|
||||
"ro.lineage.build.vendor_security_patch";
|
||||
|
||||
public LineageVendorSecurityPatchPreference(Context context, AttributeSet attrs,
|
||||
int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
public LineageVendorSecurityPatchPreference(Context context, AttributeSet attrs) {
|
||||
public LineageVendorSecurityPatchTextView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public LineageVendorSecurityPatchPreference(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttached() {
|
||||
super.onAttached();
|
||||
|
||||
setTitle(R.string.lineage_vendor_security_patch);
|
||||
setSummary(getVendorSecurityPatchLevel());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSummary(CharSequence summary) {
|
||||
if (summary.length() > 0) {
|
||||
super.setSummary(summary);
|
||||
} else {
|
||||
setAvailable(false);
|
||||
}
|
||||
setText(getVendorSecurityPatchLevel());
|
||||
}
|
||||
|
||||
private String getVendorSecurityPatchLevel() {
|
||||
@@ -84,7 +60,11 @@ public class LineageVendorSecurityPatchPreference extends SelfRemovingPreference
|
||||
} catch (ParseException e) {
|
||||
// parsing failed, use raw string
|
||||
}
|
||||
} else {
|
||||
patchLevel = getContext().getResources().getString(R.string.unknown);
|
||||
}
|
||||
|
||||
return patchLevel;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The LineageOS Project
|
||||
* Copyright (C) 2018 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,18 +20,15 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.SystemClock;
|
||||
import android.os.SystemProperties;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
|
||||
import lineageos.preference.SelfRemovingPreference;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.lineageos.platform.internal.R;
|
||||
|
||||
public class LineageVersionPreference extends SelfRemovingPreference
|
||||
implements Preference.OnPreferenceClickListener {
|
||||
|
||||
private static final String TAG = "LineageVersionPreference";
|
||||
public class LineageVersionTextView extends TextView implements View.OnClickListener {
|
||||
private static final String TAG = "LineageVersionTextView";
|
||||
|
||||
private static final String KEY_LINEAGE_VERSION_PROP = "ro.lineage.version";
|
||||
|
||||
@@ -41,36 +38,20 @@ public class LineageVersionPreference extends SelfRemovingPreference
|
||||
|
||||
private long[] mHits = new long[3];
|
||||
|
||||
public LineageVersionPreference(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
public LineageVersionPreference(Context context, AttributeSet attrs) {
|
||||
public LineageVersionTextView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public LineageVersionPreference(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttached() {
|
||||
super.onAttached();
|
||||
|
||||
setOnPreferenceClickListener(this);
|
||||
setTitle(R.string.lineage_version);
|
||||
setSummary(SystemProperties.get(KEY_LINEAGE_VERSION_PROP,
|
||||
setText(SystemProperties.get(KEY_LINEAGE_VERSION_PROP,
|
||||
getContext().getResources().getString(R.string.unknown)));
|
||||
setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
public void onClick(View v) {
|
||||
System.arraycopy(mHits, 1, mHits, 0, mHits.length - 1);
|
||||
mHits[mHits.length - 1] = SystemClock.uptimeMillis();
|
||||
if (mHits[0] >= (SystemClock.uptimeMillis() - 500)) {
|
||||
launchLogoActivity();
|
||||
}
|
||||
return true; // handled
|
||||
}
|
||||
|
||||
private void launchLogoActivity() {
|
||||
@@ -82,4 +63,5 @@ public class LineageVersionPreference extends SelfRemovingPreference
|
||||
Log.e(TAG, "Unable to start activity " + intent.toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user