LineageParts: Remove, add, move ...
* Modifiers
* Redundant casts
* Conditions that are always true
* Explicit types
* Unused / Unnecessary
* code
* variables
* initialization values
* imports
* parameters
* boxing
* Make global variables local
Change-Id: Icde9891f318b25c82d100b4c121d93643b2c03ac
diff --git a/src/org/lineageos/lineageparts/PartsUpdater.java b/src/org/lineageos/lineageparts/PartsUpdater.java
index 05c2350..76ea305 100644
--- a/src/org/lineageos/lineageparts/PartsUpdater.java
+++ b/src/org/lineageos/lineageparts/PartsUpdater.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2016 The CyanogenMod Project
+ * Copyright (C) 2022 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.
@@ -62,7 +63,7 @@
return null;
}
- if (clazz == null || !Refreshable.class.isAssignableFrom(clazz)) {
+ if (!Refreshable.class.isAssignableFrom(clazz)) {
return null;
}
@@ -99,8 +100,8 @@
}
public interface Refreshable extends SettingsHelper.OnSettingsChangeListener {
- public interface SummaryProvider {
- public String getSummary(Context context, String key);
+ interface SummaryProvider {
+ String getSummary(Context context, String key);
}
}
}
diff --git a/src/org/lineageos/lineageparts/SettingsPreferenceFragment.java b/src/org/lineageos/lineageparts/SettingsPreferenceFragment.java
index 25448f9..f8a5e47 100644
--- a/src/org/lineageos/lineageparts/SettingsPreferenceFragment.java
+++ b/src/org/lineageos/lineageparts/SettingsPreferenceFragment.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2010 The Android Open Source Project
- * 2020-2021 The LineageOS Project
+ * 2020-2022 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.
@@ -86,12 +86,11 @@
// Cache the content resolver for async callbacks
private ContentResolver mContentResolver;
- private String mPreferenceKey;
private boolean mPreferenceHighlighted = false;
private RecyclerView.Adapter mCurrentRootAdapter;
private boolean mIsDataSetObserverRegistered = false;
- private RecyclerView.AdapterDataObserver mDataSetObserver =
+ private final RecyclerView.AdapterDataObserver mDataSetObserver =
new RecyclerView.AdapterDataObserver() {
@Override
public void onChanged() {
@@ -106,7 +105,6 @@
private LayoutPreference mFooter;
private View mEmptyView;
- private LinearLayoutManager mLayoutManager;
private HighlightablePreferenceGroupAdapter mAdapter;
private ArrayMap<String, Preference> mPreferenceCache;
private boolean mAnimationAllowed;
@@ -126,8 +124,8 @@
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View root = super.onCreateView(inflater, container, savedInstanceState);
- mPinnedHeaderFrameLayout = (ViewGroup) root.findViewById(R.id.pinned_header);
- mButtonBar = (ViewGroup) root.findViewById(R.id.button_bar);
+ mPinnedHeaderFrameLayout = root.findViewById(R.id.pinned_header);
+ mButtonBar = root.findViewById(R.id.button_bar);
return root;
}
@@ -171,7 +169,6 @@
final Bundle args = getArguments();
if (args != null) {
- mPreferenceKey = args.getString(PartsActivity.EXTRA_FRAGMENT_ARG_KEY);
highlightPreferenceIfNeeded();
}
}
@@ -363,8 +360,7 @@
@Override
public RecyclerView.LayoutManager onCreateLayoutManager() {
- mLayoutManager = new LinearLayoutManager(getContext());
- return mLayoutManager;
+ return new LinearLayoutManager(getContext());
}
@Override
@@ -470,8 +466,7 @@
public void onAttach(Activity activity) {
super.onAttach(activity);
synchronized (mTriggerUris) {
- SettingsHelper.get(activity).startWatching(this,
- mTriggerUris.toArray(new Uri[mTriggerUris.size()]));
+ SettingsHelper.get(activity).startWatching(this, mTriggerUris.toArray(new Uri[0]));
}
}
@@ -495,7 +490,7 @@
mTriggerUris.addAll(Arrays.asList(contentUris));
if (!isDetached()) {
SettingsHelper.get(getActivity()).startWatching(this,
- mTriggerUris.toArray(new Uri[mTriggerUris.size()]));
+ mTriggerUris.toArray(new Uri[0]));
}
}
}
@@ -692,11 +687,11 @@
}
protected Button getBackButton() {
- return (Button) ((PartsActivity)getActivity()).getBackButton();
+ return ((PartsActivity)getActivity()).getBackButton();
}
protected Button getNextButton() {
- return (Button) ((PartsActivity)getActivity()).getNextButton();
+ return ((PartsActivity)getActivity()).getNextButton();
}
protected void showButtonBar(boolean show) {
diff --git a/src/org/lineageos/lineageparts/applications/LongScreenSettings.java b/src/org/lineageos/lineageparts/applications/LongScreenSettings.java
index af27bb4..5789460 100644
--- a/src/org/lineageos/lineageparts/applications/LongScreenSettings.java
+++ b/src/org/lineageos/lineageparts/applications/LongScreenSettings.java
@@ -28,7 +28,6 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
-import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.SectionIndexer;
@@ -43,9 +42,7 @@
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
public class LongScreenSettings extends SettingsPreferenceFragment
implements ApplicationsState.Callbacks {
@@ -54,10 +51,7 @@
private ApplicationsState mApplicationsState;
private ApplicationsState.Session mSession;
private ActivityFilter mActivityFilter;
- private Map<String, ApplicationsState.AppEntry> mEntryMap =
- new HashMap<String, ApplicationsState.AppEntry>();
- private ListView mUserListView;
private LongScreen mLongScreen;
@Override
@@ -88,9 +82,9 @@
public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
- mUserListView = (ListView) view.findViewById(R.id.user_list_view);
- mUserListView.setAdapter(mAllPackagesAdapter);
- mUserListView.setEmptyView(view.findViewById(R.id.user_list_empty_view));
+ ListView userListView = view.findViewById(R.id.user_list_view);
+ userListView.setAdapter(mAllPackagesAdapter);
+ userListView.setEmptyView(view.findViewById(R.id.user_list_empty_view));
}
@Override
@@ -173,10 +167,6 @@
}
mAllPackagesAdapter.setEntries(entries, sections, positions);
- mEntryMap.clear();
- for (ApplicationsState.AppEntry e : entries) {
- mEntryMap.put(e.info.packageName, e);
- }
}
private void rebuild() {
@@ -253,7 +243,7 @@
private void setEntries(List<ApplicationsState.AppEntry> entries,
List<String> sections, List<Integer> positions) {
mEntries = entries;
- mSections = sections.toArray(new String[sections.size()]);
+ mSections = sections.toArray(new String[0]);
mPositions = new int[positions.size()];
for (int i = 0; i < positions.size(); i++) {
mPositions[i] = positions.get(i);
@@ -296,15 +286,15 @@
}
private static class ViewHolder {
- private TextView title;
- private ImageView icon;
- private Switch state;
- private View rootView;
+ private final TextView title;
+ private final ImageView icon;
+ private final Switch state;
+ private final View rootView;
private ViewHolder(View view) {
- this.title = (TextView) view.findViewById(R.id.app_name);
- this.icon = (ImageView) view.findViewById(R.id.app_icon);
- this.state = (Switch) view.findViewById(R.id.state);
+ this.title = view.findViewById(R.id.app_name);
+ this.icon = view.findViewById(R.id.app_icon);
+ this.state = view.findViewById(R.id.state);
this.rootView = view;
view.setTag(this);
@@ -314,7 +304,7 @@
private class ActivityFilter implements ApplicationsState.AppFilter {
private final PackageManager mPackageManager;
- private final List<String> mLauncherResolveInfoList = new ArrayList<String>();
+ private final List<String> mLauncherResolveInfoList = new ArrayList<>();
private ActivityFilter(PackageManager packageManager) {
this.mPackageManager = packageManager;
diff --git a/src/org/lineageos/lineageparts/atv/KeyHandler.java b/src/org/lineageos/lineageparts/atv/KeyHandler.java
index 51a1b7e..f45ad46 100644
--- a/src/org/lineageos/lineageparts/atv/KeyHandler.java
+++ b/src/org/lineageos/lineageparts/atv/KeyHandler.java
@@ -19,7 +19,6 @@
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
import android.os.SystemProperties;
import android.provider.Settings;
import android.util.Log;
@@ -27,7 +26,6 @@
import com.android.internal.os.DeviceKeyHandler;
-import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
diff --git a/src/org/lineageos/lineageparts/contributors/ContributorsCloudFragment.java b/src/org/lineageos/lineageparts/contributors/ContributorsCloudFragment.java
index 1755afd..e9fb91c 100644
--- a/src/org/lineageos/lineageparts/contributors/ContributorsCloudFragment.java
+++ b/src/org/lineageos/lineageparts/contributors/ContributorsCloudFragment.java
@@ -140,7 +140,7 @@
LayoutInflater li = LayoutInflater.from(getContext());
convertView = li.inflate(R.layout.contributors_search_result, null);
ContributorsViewHolder viewHolder = new ContributorsViewHolder();
- viewHolder.mLabel = (TextView) convertView.findViewById(R.id.contributor_name);
+ viewHolder.mLabel = convertView.findViewById(R.id.contributor_name);
convertView.setTag(viewHolder);
}
@@ -191,7 +191,7 @@
@Override
protected void onPostExecute(Boolean result) {
- if (result == true) {
+ if (result) {
mImageView.setImageBitmap(mViewInfo.mBitmap);
mViewController.update();
if (mNotify) {
@@ -314,12 +314,12 @@
mLoadingView= v.findViewById(R.id.contributors_cloud_loading);
mFailedView= v.findViewById(R.id.contributors_cloud_failed);
- mImageView = (ImageView) v.findViewById(R.id.contributors_cloud_image);
+ mImageView = v.findViewById(R.id.contributors_cloud_image);
mViewController = new ContributorsCloudViewController(mImageView);
mViewController.setMaximumScale(20f);
mViewController.setMediumScale(7f);
- mSearchResults = (ListView) v.findViewById(R.id.contributors_cloud_search_results);
+ mSearchResults = v.findViewById(R.id.contributors_cloud_search_results);
mSearchAdapter = new ContributorsAdapter(getActivity());
mSearchResults.setAdapter(mSearchAdapter);
mSearchResults.setOnItemClickListener(new OnItemClickListener() {
@@ -346,7 +346,7 @@
if (args != null) {
String c = args.getString(PartsActivity.EXTRA_FRAGMENT_ARG_KEY);
if (c != null && c.startsWith(KEY_PREFIX)) {
- onContributorSelected(Integer.valueOf(c.substring(KEY_PREFIX.length())));
+ onContributorSelected(Integer.parseInt(c.substring(KEY_PREFIX.length())));
args.remove(PartsActivity.EXTRA_FRAGMENT_ARG_KEY);
}
}
@@ -575,8 +575,8 @@
int cy = ih / 2;
int cbx = bsize / 2;
int cby = bsize / 2;
- float cw = 0f;
- float ch = 0f;
+ float cw;
+ float ch;
if (r == 0) {
cw = translate(w, bsize, Math.min(iw, ih)) / 2;
ch = translate(h, bsize, Math.min(iw, ih)) / 2;
@@ -787,7 +787,7 @@
public static void extractContributorsCloudDatabase(Context context) {
final int BUFFER = 1024;
InputStream is = null;
- OutputStream os = null;
+ OutputStream os;
File databasePath = context.getDatabasePath(DB_NAME);
try {
databasePath.getParentFile().mkdir();
@@ -819,7 +819,7 @@
// Index the top 100 contributors, for fun :)
File dbPath = context.getDatabasePath(DB_NAME);
- SQLiteDatabase db = null;
+ SQLiteDatabase db;
try {
db = SQLiteDatabase.openDatabase(dbPath.getAbsolutePath(),
null, SQLiteDatabase.OPEN_READONLY);
@@ -829,9 +829,6 @@
}
} catch (Exception e) {
Log.e(TAG, e.getMessage(), e);
- if (db != null && db.isOpen()) {
- db.close();
- }
return null;
}
diff --git a/src/org/lineageos/lineageparts/contributors/ContributorsCloudViewController.java b/src/org/lineageos/lineageparts/contributors/ContributorsCloudViewController.java
index 277f36b..df68c1d 100644
--- a/src/org/lineageos/lineageparts/contributors/ContributorsCloudViewController.java
+++ b/src/org/lineageos/lineageparts/contributors/ContributorsCloudViewController.java
@@ -20,7 +20,6 @@
import android.annotation.SuppressLint;
import android.content.Context;
-import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.graphics.Matrix.ScaleToFit;
import android.graphics.RectF;
@@ -32,7 +31,6 @@
import android.view.VelocityTracker;
import android.view.View;
import android.view.ScaleGestureDetector.OnScaleGestureListener;
-import android.view.View.OnLongClickListener;
import android.view.ViewConfiguration;
import android.view.ViewParent;
import android.view.ViewTreeObserver;
@@ -70,11 +68,10 @@
static final int EDGE_RIGHT = 1;
static final int EDGE_BOTH = 2;
- private float mMinScale = DEFAULT_MIN_SCALE;
+ private final float mMinScale = DEFAULT_MIN_SCALE;
private float mMidScale = DEFAULT_MID_SCALE;
private float mMaxScale = DEFAULT_MAX_SCALE;
- private boolean mAllowParentInterceptOnEdge = true;
private boolean mBlockParentIntercept = false;
private static final int INVALID_POINTER_ID = -1;
@@ -106,24 +103,6 @@
}
/**
- * @return true if the ScaleType is supported.
- */
- private static boolean isSupportedScaleType(final ScaleType scaleType) {
- if (null == scaleType) {
- return false;
- }
-
- switch (scaleType) {
- case MATRIX:
- throw new IllegalArgumentException(scaleType.name()
- + " is not supported in PhotoView");
-
- default:
- return true;
- }
- }
-
- /**
* Set's the ImageView's ScaleType to Matrix.
*/
private static void setImageViewScaleTypeMatrix(ImageView imageView) {
@@ -229,18 +208,14 @@
private final float[] mMatrixValues = new float[9];
// Listeners
- private OnMatrixChangedListener mMatrixChangeListener;
private OnPhotoTapListener mPhotoTapListener;
private OnViewTapListener mViewTapListener;
- private OnLongClickListener mLongClickListener;
- private OnScaleChangeListener mScaleChangeListener;
private int mIvTop, mIvRight, mIvBottom, mIvLeft;
private FlingRunnable mCurrentFlingRunnable;
private int mScrollEdge = EDGE_BOTH;
private boolean mZoomEnabled;
- private ScaleType mScaleType = ScaleType.FIT_CENTER;
public ContributorsCloudViewController(ImageView imageView) {
this(imageView, true);
@@ -253,7 +228,6 @@
mImageView = new WeakReference<>(imageView);
- imageView.setDrawingCacheEnabled(true);
imageView.setOnTouchListener(this);
ViewTreeObserver observer = imageView.getViewTreeObserver();
@@ -294,38 +268,13 @@
mScaleDragDetector = new ScaleGestureDetector(imageView.getContext(), mScaleListener);
mGestureDetector = new GestureDetector(imageView.getContext(),
- new GestureDetector.SimpleOnGestureListener() {
-
- // forward long click listener
- @Override
- public void onLongPress(MotionEvent e) {
- if (null != mLongClickListener) {
- mLongClickListener.onLongClick(getImageView());
- }
- }
- });
+ new GestureDetector.SimpleOnGestureListener());
mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this));
// Finally, update the UI so that we're zoomable
setZoomable(zoomable);
}
- public void setOnDoubleTapListener(GestureDetector.OnDoubleTapListener newOnDoubleTapListener) {
- if (newOnDoubleTapListener != null) {
- this.mGestureDetector.setOnDoubleTapListener(newOnDoubleTapListener);
- } else {
- this.mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this));
- }
- }
-
- public void setOnScaleChangeListener(OnScaleChangeListener onScaleChangeListener) {
- this.mScaleChangeListener = onScaleChangeListener;
- }
-
- public boolean canZoom() {
- return mZoomEnabled;
- }
-
/**
* Clean-up the resources attached to this object. This needs to be called when the ImageView is
* no longer used. A good example is from {@link android.view.View#onDetachedFromWindow()} or
@@ -359,7 +308,6 @@
}
// Clear listeners too
- mMatrixChangeListener = null;
mPhotoTapListener = null;
mViewTapListener = null;
@@ -372,34 +320,6 @@
return getDisplayRect(getDrawMatrix());
}
- public boolean setDisplayMatrix(Matrix finalMatrix) {
- if (finalMatrix == null)
- throw new IllegalArgumentException("Matrix cannot be null");
-
- ImageView imageView = getImageView();
- if (null == imageView)
- return false;
-
- if (null == imageView.getDrawable())
- return false;
-
- mSuppMatrix.set(finalMatrix);
- setImageViewMatrix(getDrawMatrix());
- checkMatrixBounds();
-
- return true;
- }
-
- public void setRotationTo(float degrees) {
- mSuppMatrix.setRotate(degrees % 360);
- checkAndDisplayMatrix();
- }
-
- public void setRotationBy(float degrees) {
- mSuppMatrix.postRotate(degrees % 360);
- checkAndDisplayMatrix();
- }
-
public ImageView getImageView() {
ImageView imageView = null;
@@ -434,10 +354,6 @@
+ (float) Math.pow(getValue(mSuppMatrix, Matrix.MSKEW_Y), 2));
}
- public ScaleType getScaleType() {
- return mScaleType;
- }
-
public void onDrag(float dx, float dy) {
if (mScaleDragDetector.isInProgress()) {
return; // Do not drag if we are already scaling
@@ -461,8 +377,7 @@
* the edge, aka 'overscrolling', let the parent take over).
*/
ViewParent parent = imageView.getParent();
- if (mAllowParentInterceptOnEdge && !mScaleDragDetector.isInProgress()
- && !mBlockParentIntercept) {
+ if (!mScaleDragDetector.isInProgress() && !mBlockParentIntercept) {
if (mScrollEdge == EDGE_BOTH
|| (mScrollEdge == EDGE_LEFT && dx >= 1f)
|| (mScrollEdge == EDGE_RIGHT && dx <= -1f)) {
@@ -532,9 +447,6 @@
}
if (getScale() < mMaxScale || scaleFactor < 1f) {
- if (null != mScaleChangeListener) {
- mScaleChangeListener.onScaleChange(scaleFactor, focusX, focusY);
- }
mSuppMatrix.postScale(scaleFactor, scaleFactor, focusX, focusY);
checkAndDisplayMatrix();
}
@@ -600,15 +512,6 @@
return handled;
}
- public void setAllowParentInterceptOnEdge(boolean allow) {
- mAllowParentInterceptOnEdge = allow;
- }
-
- public void setMinimumScale(float minimumScale) {
- checkZoomLevels(minimumScale, mMidScale, mMaxScale);
- mMinScale = minimumScale;
- }
-
public void setMediumScale(float mediumScale) {
checkZoomLevels(mMinScale, mediumScale, mMaxScale);
mMidScale = mediumScale;
@@ -619,33 +522,10 @@
mMaxScale = maximumScale;
}
- public void setScaleLevels(float minimumScale, float mediumScale, float maximumScale) {
- checkZoomLevels(minimumScale, mediumScale, maximumScale);
- mMinScale = minimumScale;
- mMidScale = mediumScale;
- mMaxScale = maximumScale;
- }
-
- public void setOnLongClickListener(OnLongClickListener listener) {
- mLongClickListener = listener;
- }
-
- public void setOnMatrixChangeListener(OnMatrixChangedListener listener) {
- mMatrixChangeListener = listener;
- }
-
- public void setOnPhotoTapListener(OnPhotoTapListener listener) {
- mPhotoTapListener = listener;
- }
-
public OnPhotoTapListener getOnPhotoTapListener() {
return mPhotoTapListener;
}
- public void setOnViewTapListener(OnViewTapListener listener) {
- mViewTapListener = listener;
- }
-
public OnViewTapListener getOnViewTapListener() {
return mViewTapListener;
}
@@ -691,15 +571,6 @@
}
}
- public void setScaleType(ScaleType scaleType) {
- if (isSupportedScaleType(scaleType) && scaleType != mScaleType) {
- mScaleType = scaleType;
-
- // Finally update
- update();
- }
- }
-
public void setZoomable(boolean zoomable) {
mZoomEnabled = zoomable;
update();
@@ -722,10 +593,6 @@
}
}
- public Matrix getDisplayMatrix() {
- return new Matrix(getDrawMatrix());
- }
-
public Matrix getDrawMatrix() {
mDrawMatrix.set(mBaseMatrix);
mDrawMatrix.postConcat(mSuppMatrix);
@@ -779,17 +646,7 @@
final int viewHeight = getImageViewHeight(imageView);
if (height <= viewHeight) {
- switch (mScaleType) {
- case FIT_START:
- deltaY = -rect.top;
- break;
- case FIT_END:
- deltaY = viewHeight - height - rect.top;
- break;
- default:
- deltaY = (viewHeight - height) / 2 - rect.top;
- break;
- }
+ deltaY = (viewHeight - height) / 2 - rect.top;
} else if (rect.top > 0) {
deltaY = -rect.top;
} else if (rect.bottom < viewHeight) {
@@ -798,17 +655,7 @@
final int viewWidth = getImageViewWidth(imageView);
if (width <= viewWidth) {
- switch (mScaleType) {
- case FIT_START:
- deltaX = -rect.left;
- break;
- case FIT_END:
- deltaX = viewWidth - width - rect.left;
- break;
- default:
- deltaX = (viewWidth - width) / 2 - rect.left;
- break;
- }
+ deltaX = (viewWidth - width) / 2 - rect.left;
mScrollEdge = EDGE_BOTH;
} else if (rect.left > 0) {
mScrollEdge = EDGE_LEFT;
@@ -846,11 +693,6 @@
return null;
}
- public Bitmap getVisibleRectangleBitmap() {
- ImageView imageView = getImageView();
- return imageView == null ? null : imageView.getDrawingCache();
- }
-
public void setZoomTransitionDuration(int milliseconds) {
if (milliseconds < 0)
milliseconds = DEFAULT_ZOOM_DURATION;
@@ -884,14 +726,6 @@
checkImageViewScaleType();
imageView.setImageMatrix(matrix);
-
- // Call MatrixChangedListener if needed
- if (null != mMatrixChangeListener) {
- RectF displayRect = getDisplayRect(matrix);
- if (null != displayRect) {
- mMatrixChangeListener.onMatrixChanged(displayRect);
- }
- }
}
}
@@ -913,51 +747,10 @@
mBaseMatrix.reset();
- final float widthScale = viewWidth / drawableWidth;
- final float heightScale = viewHeight / drawableHeight;
+ RectF mTempSrc = new RectF(0, 0, drawableWidth, drawableHeight);
+ RectF mTempDst = new RectF(0, 0, viewWidth, viewHeight);
- if (mScaleType == ScaleType.CENTER) {
- mBaseMatrix.postTranslate((viewWidth - drawableWidth) / 2F,
- (viewHeight - drawableHeight) / 2F);
-
- } else if (mScaleType == ScaleType.CENTER_CROP) {
- float scale = Math.max(widthScale, heightScale);
- mBaseMatrix.postScale(scale, scale);
- mBaseMatrix.postTranslate((viewWidth - drawableWidth * scale) / 2F,
- (viewHeight - drawableHeight * scale) / 2F);
-
- } else if (mScaleType == ScaleType.CENTER_INSIDE) {
- float scale = Math.min(1.0f, Math.min(widthScale, heightScale));
- mBaseMatrix.postScale(scale, scale);
- mBaseMatrix.postTranslate((viewWidth - drawableWidth * scale) / 2F,
- (viewHeight - drawableHeight * scale) / 2F);
-
- } else {
- RectF mTempSrc = new RectF(0, 0, drawableWidth, drawableHeight);
- RectF mTempDst = new RectF(0, 0, viewWidth, viewHeight);
-
- switch (mScaleType) {
- case FIT_CENTER:
- mBaseMatrix
- .setRectToRect(mTempSrc, mTempDst, ScaleToFit.CENTER);
- break;
-
- case FIT_START:
- mBaseMatrix.setRectToRect(mTempSrc, mTempDst, ScaleToFit.START);
- break;
-
- case FIT_END:
- mBaseMatrix.setRectToRect(mTempSrc, mTempDst, ScaleToFit.END);
- break;
-
- case FIT_XY:
- mBaseMatrix.setRectToRect(mTempSrc, mTempDst, ScaleToFit.FILL);
- break;
-
- default:
- break;
- }
- }
+ mBaseMatrix.setRectToRect(mTempSrc, mTempDst, ScaleToFit.CENTER);
resetMatrix();
}
@@ -1109,7 +902,7 @@
*
* @author Chris Banes
*/
- public static interface OnMatrixChangedListener {
+ public interface OnMatrixChangedListener {
/**
* Callback for when the Matrix displaying the Drawable has changed. This could be because
* the View's bounds have changed, or the user has zoomed.
@@ -1120,28 +913,12 @@
}
/**
- * Interface definition for callback to be invoked when attached ImageView scale changes
- *
- * @author Marek Sebera
- */
- public static interface OnScaleChangeListener {
- /**
- * Callback for when the scale changes
- *
- * @param scaleFactor the scale factor (<1 for zoom out, >1 for zoom in)
- * @param focusX focal point X position
- * @param focusY focal point Y position
- */
- void onScaleChange(float scaleFactor, float focusX, float focusY);
- }
-
- /**
* Interface definition for a callback to be invoked when the Photo is tapped with a single
* tap.
*
* @author Chris Banes
*/
- public static interface OnPhotoTapListener {
+ public interface OnPhotoTapListener {
/**
* A callback to receive where the user taps on a photo. You will only receive a callback if
@@ -1162,7 +939,7 @@
*
* @author Chris Banes
*/
- public static interface OnViewTapListener {
+ public interface OnViewTapListener {
/**
* A callback to receive where the user taps on a ImageView. You will receive a callback if
diff --git a/src/org/lineageos/lineageparts/egg/octo/OctopusDrawable.java b/src/org/lineageos/lineageparts/egg/octo/OctopusDrawable.java
index 644206b..2b24d03 100644
--- a/src/org/lineageos/lineageparts/egg/octo/OctopusDrawable.java
+++ b/src/org/lineageos/lineageparts/egg/octo/OctopusDrawable.java
@@ -21,7 +21,6 @@
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
-import android.graphics.DashPathEffect;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
@@ -54,23 +53,22 @@
{-1f, 1f, 4f},
{0, 5f, 10f}};
- private Paint mPaint = new Paint();
- private Arm[] mArms = new Arm[4]; // 8
+ private final Paint mPaint = new Paint();
+ private final Arm[] mArms = new Arm[4]; // 8
final PointF mCenter = new PointF();
- private int mSizePx = 100;
final Matrix M = new Matrix();
final Matrix M_inv = new Matrix();
private TimeAnimator mDriftAnimation;
- private float[] mPtmp = new float[2];
- private float[] mScaledBounds = new float[2];
+ private final float[] mPtmp = new float[2];
+ private final float[] mScaledBounds = new float[2];
- private Drawable mEyeLogo;
+ private final Drawable mEyeLogo;
public static float randfrange(float a, float b) {
return (float) (Math.random() * (b - a) + a);
}
public static float clamp(float v, float a, float b) {
- return v < a ? a : v > b ? b : v;
+ return v < a ? a : Math.min(v, b);
}
public OctopusDrawable(Context context) {
@@ -90,9 +88,8 @@
}
public void setSizePx(int size) {
- mSizePx = size;
- M.setScale(mSizePx / BASE_SCALE, mSizePx / BASE_SCALE);
- TaperedPathStroke.setMinStep(8f * BASE_SCALE / mSizePx); // classic tentacles
+ M.setScale(size / BASE_SCALE, size / BASE_SCALE);
+ TaperedPathStroke.setMinStep(8f * BASE_SCALE / size); // classic tentacles
M.invert(M_inv);
}
@@ -103,17 +100,18 @@
static final float MAX_VY = 35f;
static final float JUMP_VY = -100f;
static final float MAX_VX = 15f;
- private float ax = 0f, ay = 30f;
+ float ax = 0f;
+ final float ay = 30f;
private float vx, vy;
- long nextjump = 0;
+ long nextJump = 0;
@Override
public void onTimeUpdate(TimeAnimator timeAnimator, long t, long dt) {
float t_sec = 0.001f * t;
float dt_sec = 0.001f * dt;
- if (t > nextjump) {
+ if (t > nextJump) {
vy = JUMP_VY;
- nextjump = t + (long) randfrange(5000, 10000);
+ nextJump = t + (long) randfrange(5000, 10000);
}
ax = (float) (MAX_VX * Math.sin(t_sec * .25f));
@@ -279,7 +277,7 @@
private class Link implements DynamicAnimation.OnAnimationUpdateListener {
final FloatValueHolder[] coords = new FloatValueHolder[2];
final SpringAnimation[] anims = new SpringAnimation[coords.length];
- private float dx, dy;
+ private final float dx, dy;
private boolean locked = false;
Link next;
@@ -345,7 +343,7 @@
private class Arm {
final Link link1, link2, link3;
- float max, min;
+ final float max, min;
public Arm(float x, float y, float dx1, float dy1, float dx2, float dy2,
float dx3, float dy3, float max, float min) {
diff --git a/src/org/lineageos/lineageparts/egg/octo/TaperedPathStroke.java b/src/org/lineageos/lineageparts/egg/octo/TaperedPathStroke.java
index 68bd233..7b97180 100644
--- a/src/org/lineageos/lineageparts/egg/octo/TaperedPathStroke.java
+++ b/src/org/lineageos/lineageparts/egg/octo/TaperedPathStroke.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2010 The Android Open Source Project
- * Copyright (C) 2017 The LineageOS Project
+ * Copyright (C) 2017-2022 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.
@@ -21,18 +21,12 @@
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PathMeasure;
-import android.os.Debug;
-
-import java.util.Arrays;
public class TaperedPathStroke {
static float sMinStepPx = 4f;
static PathMeasure pm = new PathMeasure();
static float[] pos = {0, 0};
static float[] tan = {0, 0};
- static float lerp(float t, float a, float b) {
- return a + t * (b - a);
- }
public static void setMinStep(float px) {
sMinStepPx = px;
}
diff --git a/src/org/lineageos/lineageparts/gestures/TouchscreenGestureSettings.java b/src/org/lineageos/lineageparts/gestures/TouchscreenGestureSettings.java
index 65346e7..23fa7c3 100644
--- a/src/org/lineageos/lineageparts/gestures/TouchscreenGestureSettings.java
+++ b/src/org/lineageos/lineageparts/gestures/TouchscreenGestureSettings.java
@@ -23,7 +23,6 @@
import android.os.Bundle;
import android.os.UserHandle;
import android.util.ArraySet;
-import android.util.Log;
import androidx.preference.ListPreference;
import androidx.preference.PreferenceManager;
@@ -219,7 +218,7 @@
@Override
public Set<String> getNonIndexableKeys(Context context) {
- final Set<String> result = new ArraySet<String>();
+ final Set<String> result = new ArraySet<>();
if (!isTouchscreenGesturesSupported(context)) {
result.add(KEY_TOUCHSCREEN_GESTURE_SETTINGS);
diff --git a/src/org/lineageos/lineageparts/input/BacklightTimeoutSeekBar.java b/src/org/lineageos/lineageparts/input/BacklightTimeoutSeekBar.java
index 9b6b94d..8528f2c 100644
--- a/src/org/lineageos/lineageparts/input/BacklightTimeoutSeekBar.java
+++ b/src/org/lineageos/lineageparts/input/BacklightTimeoutSeekBar.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2013 The CyanogenMod Project
+ * Copyright (C) 2022 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.
@@ -24,7 +25,6 @@
public class BacklightTimeoutSeekBar extends SeekBar {
private int mMax;
private int mGap;
- private boolean mUpdatingThumb;
public BacklightTimeoutSeekBar(Context context) {
super(context);
@@ -40,16 +40,12 @@
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
- mUpdatingThumb = true;
super.onSizeChanged(w, h, oldw, oldh);
- mUpdatingThumb = false;
}
@Override
public void setThumb(Drawable thumb) {
- mUpdatingThumb = true;
super.setThumb(thumb);
- mUpdatingThumb = false;
}
@Override
diff --git a/src/org/lineageos/lineageparts/input/ButtonBacklightBrightness.java b/src/org/lineageos/lineageparts/input/ButtonBacklightBrightness.java
index e5c1625..c814523 100644
--- a/src/org/lineageos/lineageparts/input/ButtonBacklightBrightness.java
+++ b/src/org/lineageos/lineageparts/input/ButtonBacklightBrightness.java
@@ -20,7 +20,6 @@
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
-import android.content.res.Resources;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
@@ -58,7 +57,7 @@
private SeekBar mTimeoutBar;
private TextView mTimeoutValue;
- private ContentResolver mResolver;
+ private final ContentResolver mResolver;
private int mOriginalTimeout;
@@ -132,16 +131,16 @@
protected void onBindDialogView(View view) {
super.onBindDialogView(view);
- mTimeoutContainer = (ViewGroup) view.findViewById(R.id.timeout_container);
- mTimeoutBar = (SeekBar) view.findViewById(R.id.timeout_seekbar);
- mTimeoutValue = (TextView) view.findViewById(R.id.timeout_value);
+ mTimeoutContainer = view.findViewById(R.id.timeout_container);
+ mTimeoutBar = view.findViewById(R.id.timeout_seekbar);
+ mTimeoutValue = view.findViewById(R.id.timeout_value);
mTimeoutBar.setMax(30);
mTimeoutBar.setOnSeekBarChangeListener(this);
mOriginalTimeout = getTimeout();
mTimeoutBar.setProgress(mOriginalTimeout);
handleTimeoutUpdate(mTimeoutBar.getProgress());
- ViewGroup buttonContainer = (ViewGroup) view.findViewById(R.id.button_container);
+ ViewGroup buttonContainer = view.findViewById(R.id.button_container);
if (mButtonBrightness != null) {
mButtonBrightness.init(buttonContainer);
} else {
@@ -149,7 +148,7 @@
mTimeoutContainer.setVisibility(View.GONE);
}
- ViewGroup keyboardContainer = (ViewGroup) view.findViewById(R.id.keyboard_container);
+ ViewGroup keyboardContainer = view.findViewById(R.id.keyboard_container);
if (mKeyboardBrightness != null) {
mKeyboardBrightness.init(keyboardContainer);
} else {
@@ -350,9 +349,9 @@
private class BrightnessControl implements
SeekBar.OnSeekBarChangeListener, CheckBox.OnCheckedChangeListener {
- private String mSetting;
- private boolean mIsSingleValue;
- private float mDefaultBrightness;
+ private final String mSetting;
+ private final boolean mIsSingleValue;
+ private final float mDefaultBrightness;
private CheckBox mCheckBox;
private SeekBar mSeekBar;
private TextView mValue;
@@ -372,13 +371,13 @@
if (mIsSingleValue) {
container.findViewById(R.id.seekbar_container).setVisibility(View.GONE);
- mCheckBox = (CheckBox) container.findViewById(R.id.backlight_switch);
+ mCheckBox = container.findViewById(R.id.backlight_switch);
mCheckBox.setChecked(brightness != 0.0f);
mCheckBox.setOnCheckedChangeListener(this);
} else {
container.findViewById(R.id.checkbox_container).setVisibility(View.GONE);
- mSeekBar = (SeekBar) container.findViewById(R.id.seekbar);
- mValue = (TextView) container.findViewById(R.id.value);
+ mSeekBar = container.findViewById(R.id.seekbar);
+ mValue = container.findViewById(R.id.value);
mSeekBar.setMax(100);
mSeekBar.setProgress((int)(brightness * 100.0f));
@@ -447,7 +446,7 @@
}
private class ButtonBrightnessControl extends BrightnessControl {
- private String mOnlyWhenPressedSetting;
+ private final String mOnlyWhenPressedSetting;
private CheckBox mOnlyWhenPressedCheckBox;
public ButtonBrightnessControl(String brightnessSetting, String onlyWhenPressedSetting,
@@ -461,7 +460,7 @@
super.init(container);
mOnlyWhenPressedCheckBox =
- (CheckBox) container.findViewById(R.id.backlight_only_when_pressed_switch);
+ container.findViewById(R.id.backlight_only_when_pressed_switch);
mOnlyWhenPressedCheckBox.setChecked(isOnlyWhenPressedEnabled());
mOnlyWhenPressedCheckBox.setOnCheckedChangeListener(this);
}
diff --git a/src/org/lineageos/lineageparts/input/ButtonSettings.java b/src/org/lineageos/lineageparts/input/ButtonSettings.java
index 8c3b886..bc4e6a8 100644
--- a/src/org/lineageos/lineageparts/input/ButtonSettings.java
+++ b/src/org/lineageos/lineageparts/input/ButtonSettings.java
@@ -22,13 +22,9 @@
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY;
import android.app.ActivityManager;
-import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
-import android.content.Intent;
import android.content.om.IOverlayManager;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.content.SharedPreferences;
import android.os.Bundle;
@@ -64,7 +60,6 @@
import static org.lineageos.internal.util.DeviceKeysConstants.*;
-import java.util.List;
import java.util.Set;
import lineageos.hardware.LineageHardwareManager;
@@ -141,10 +136,7 @@
private ListPreference mAppSwitchLongPressAction;
private SwitchPreference mCameraWakeScreen;
private SwitchPreference mCameraSleepOnRelease;
- private SwitchPreference mCameraLaunch;
private ListPreference mVolumeKeyCursorControl;
- private SwitchPreference mVolumeWakeScreen;
- private SwitchPreference mVolumeMusicControls;
private SwitchPreference mSwapVolumeButtons;
private SwitchPreference mVolumePanelOnLeft;
private SwitchPreference mDisableNavigationKeys;
@@ -156,7 +148,6 @@
private ListPreference mEdgeLongSwipeAction;
private SwitchPreference mPowerEndCall;
private SwitchPreference mHomeAnswerCall;
- private SwitchPreference mTorchLongPressPowerGesture;
private ListPreference mTorchLongPressPowerTimeout;
private SwitchPreference mSwapCapacitiveKeys;
private SwitchPreference mNavBarInverse;
@@ -197,7 +188,6 @@
final boolean showCameraWake = DeviceUtils.canWakeUsingCameraKey(getActivity());
final boolean showVolumeWake = DeviceUtils.canWakeUsingVolumeKeys(getActivity());
- boolean hasAnyBindableKey = false;
final PreferenceCategory powerCategory = prefScreen.findPreference(CATEGORY_POWER);
final PreferenceCategory homeCategory = prefScreen.findPreference(CATEGORY_HOME);
final PreferenceCategory backCategory = prefScreen.findPreference(CATEGORY_BACK);
@@ -212,7 +202,8 @@
mPowerEndCall = findPreference(KEY_POWER_END_CALL);
// Long press power while display is off to activate torchlight
- mTorchLongPressPowerGesture = findPreference(KEY_TORCH_LONG_PRESS_POWER_GESTURE);
+ SwitchPreference torchLongPressPowerGesture =
+ findPreference(KEY_TORCH_LONG_PRESS_POWER_GESTURE);
final int torchLongPressPowerTimeout = LineageSettings.System.getInt(resolver,
LineageSettings.System.TORCH_LONG_PRESS_POWER_TIMEOUT, 0);
mTorchLongPressPowerTimeout = initList(KEY_TORCH_LONG_PRESS_POWER_TIMEOUT,
@@ -291,7 +282,7 @@
mPowerEndCall = null;
}
if (!DeviceUtils.deviceSupportsFlashLight(getActivity())) {
- powerCategory.removePreference(mTorchLongPressPowerGesture);
+ powerCategory.removePreference(torchLongPressPowerGesture);
powerCategory.removePreference(mTorchLongPressPowerTimeout);
}
}
@@ -316,7 +307,6 @@
mHomeDoubleTapAction.setEnabled(false);
}
- hasAnyBindableKey = true;
}
if (!hasHomeKey || homeCategory.getPreferenceCount() == 0) {
prefScreen.removePreference(homeCategory);
@@ -332,7 +322,6 @@
mBackLongPressAction.setEnabled(false);
}
- hasAnyBindableKey = true;
}
if (!hasBackKey || backCategory.getPreferenceCount() == 0) {
prefScreen.removePreference(backCategory);
@@ -352,7 +341,6 @@
hasAssistKey ? Action.NOTHING : Action.APP_SWITCH);
mMenuLongPressAction = initList(KEY_MENU_LONG_PRESS, longPressAction);
- hasAnyBindableKey = true;
}
if (!hasMenuKey || menuCategory.getPreferenceCount() == 0) {
prefScreen.removePreference(menuCategory);
@@ -371,7 +359,6 @@
LineageSettings.System.KEY_ASSIST_LONG_PRESS_ACTION, Action.VOICE_SEARCH);
mAssistLongPressAction = initList(KEY_ASSIST_LONG_PRESS, longPressAction);
- hasAnyBindableKey = true;
}
if (!hasAssistKey || assistCategory.getPreferenceCount() == 0) {
prefScreen.removePreference(assistCategory);
@@ -389,7 +376,6 @@
mAppSwitchLongPressAction = initList(KEY_APP_SWITCH_LONG_PRESS,
appSwitchLongPressAction);
- hasAnyBindableKey = true;
}
if (!hasAppSwitchKey || appSwitchCategory.getPreferenceCount() == 0) {
prefScreen.removePreference(appSwitchCategory);
@@ -398,7 +384,6 @@
if (hasCameraKey) {
mCameraWakeScreen = findPreference(KEY_CAMERA_WAKE_SCREEN);
mCameraSleepOnRelease = findPreference(KEY_CAMERA_SLEEP_ON_RELEASE);
- mCameraLaunch = findPreference(KEY_CAMERA_LAUNCH);
if (!showCameraWake) {
prefScreen.removePreference(mCameraWakeScreen);
@@ -467,13 +452,13 @@
}
}
- mVolumeWakeScreen = findPreference(KEY_VOLUME_WAKE_SCREEN);
- mVolumeMusicControls = findPreference(KEY_VOLUME_MUSIC_CONTROLS);
+ SwitchPreference volumeWakeScreen = findPreference(KEY_VOLUME_WAKE_SCREEN);
+ SwitchPreference volumeMusicControls = findPreference(KEY_VOLUME_MUSIC_CONTROLS);
- if (mVolumeWakeScreen != null) {
- if (mVolumeMusicControls != null) {
- mVolumeMusicControls.setDependency(KEY_VOLUME_WAKE_SCREEN);
- mVolumeWakeScreen.setDisableDependentsState(true);
+ if (volumeWakeScreen != null) {
+ if (volumeMusicControls != null) {
+ volumeMusicControls.setDependency(KEY_VOLUME_WAKE_SCREEN);
+ volumeWakeScreen.setDisableDependentsState(true);
}
}
diff --git a/src/org/lineageos/lineageparts/input/PowerMenuActions.java b/src/org/lineageos/lineageparts/input/PowerMenuActions.java
index f29b76f..6ae26ef 100644
--- a/src/org/lineageos/lineageparts/input/PowerMenuActions.java
+++ b/src/org/lineageos/lineageparts/input/PowerMenuActions.java
@@ -39,7 +39,6 @@
import org.lineageos.lineageparts.SettingsPreferenceFragment;
import org.lineageos.lineageparts.utils.TelephonyUtils;
-import java.util.ArrayList;
import java.util.List;
import lineageos.app.LineageGlobalActions;
@@ -67,9 +66,7 @@
private boolean mForceEmergCheck = false;
Context mContext;
- private LockPatternUtils mLockPatternUtils;
private UserManager mUserManager;
- private List<String> mLocalUserConfig = new ArrayList<String>();
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -78,7 +75,6 @@
addPreferencesFromResource(R.xml.power_menu_settings);
getActivity().setTitle(R.string.power_menu_title);
mContext = getActivity().getApplicationContext();
- mLockPatternUtils = new LockPatternUtils(mContext);
mUserManager = UserManager.get(mContext);
mLineageGlobalActions = LineageGlobalActions.getInstance(mContext);
mEmergencyAffordanceManager = new EmergencyAffordanceManager(mContext);
@@ -105,8 +101,6 @@
mPowerMenuItemsCategory.removePreference(mEmergencyPref);
mEmergencyPref = null;
}
-
- mLocalUserConfig = mLineageGlobalActions.getLocalUserConfig();
}
@Override
diff --git a/src/org/lineageos/lineageparts/lineagestats/StatsUploadJobService.java b/src/org/lineageos/lineageparts/lineagestats/StatsUploadJobService.java
index 8526650..59af1ca 100644
--- a/src/org/lineageos/lineageparts/lineagestats/StatsUploadJobService.java
+++ b/src/org/lineageos/lineageparts/lineagestats/StatsUploadJobService.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2015 The CyanogenMod Project
- * 2017 The LineageOS project
+ * 2017-2022 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.
@@ -92,7 +92,7 @@
private class StatsUploadTask extends AsyncTask<Void, Void, Boolean> {
- private JobParameters mJobParams;
+ private final JobParameters mJobParams;
public StatsUploadTask(JobParameters jobParams) {
this.mJobParams = jobParams;
@@ -109,7 +109,6 @@
String deviceCountry = extras.getString(KEY_COUNTRY);
String deviceCarrier = extras.getString(KEY_CARRIER);
String deviceCarrierId = extras.getString(KEY_CARRIER_ID);
- long timeStamp = extras.getLong(KEY_TIMESTAMP);
boolean success = false;
int jobType = extras.getInt(KEY_JOB_TYPE, -1);
@@ -171,8 +170,7 @@
if (DEBUG) Log.d(TAG, "lineage server response code=" + responseCode);
final boolean success = responseCode == HttpURLConnection.HTTP_OK;
if (!success) {
- Log.w(TAG, "failed sending, server returned: " + getResponse(urlConnection,
- !success));
+ Log.w(TAG, "failed sending, server returned: " + getResponse(urlConnection));
}
return success;
} finally {
@@ -181,11 +179,9 @@
}
- private String getResponse(HttpURLConnection httpUrlConnection, boolean errorStream)
+ private String getResponse(HttpURLConnection httpUrlConnection)
throws IOException {
- InputStream responseStream = new BufferedInputStream(errorStream
- ? httpUrlConnection.getErrorStream()
- : httpUrlConnection.getInputStream());
+ InputStream responseStream = new BufferedInputStream(httpUrlConnection.getErrorStream());
BufferedReader responseStreamReader = new BufferedReader(
new InputStreamReader(responseStream));
diff --git a/src/org/lineageos/lineageparts/lineagestats/Utilities.java b/src/org/lineageos/lineageparts/lineagestats/Utilities.java
index d064d5f..9757367 100644
--- a/src/org/lineageos/lineageparts/lineagestats/Utilities.java
+++ b/src/org/lineageos/lineageparts/lineagestats/Utilities.java
@@ -27,7 +27,6 @@
import lineageos.providers.LineageSettings;
import java.math.BigInteger;
-import java.net.NetworkInterface;
import java.security.MessageDigest;
import java.util.Locale;
diff --git a/src/org/lineageos/lineageparts/livedisplay/DisplayColor.java b/src/org/lineageos/lineageparts/livedisplay/DisplayColor.java
index e66e979..5e40770 100644
--- a/src/org/lineageos/lineageparts/livedisplay/DisplayColor.java
+++ b/src/org/lineageos/lineageparts/livedisplay/DisplayColor.java
@@ -40,7 +40,6 @@
public class DisplayColor extends CustomDialogPreference<AlertDialog> {
private static final String TAG = "ColorCalibration";
- private final Context mContext;
private final LiveDisplayManager mLiveDisplay;
// These arrays must all match in length and order
@@ -56,7 +55,7 @@
R.id.color_blue_value
};
- private ColorSeekBar[] mSeekBars = new ColorSeekBar[SEEKBAR_ID.length];
+ private final ColorSeekBar[] mSeekBars = new ColorSeekBar[SEEKBAR_ID.length];
private final float[] mCurrentColors = new float[3];
private final float[] mOriginalColors = new float[3];
@@ -64,8 +63,7 @@
public DisplayColor(Context context, AttributeSet attrs) {
super(context, attrs);
- mContext = context;
- mLiveDisplay = LiveDisplayManager.getInstance(mContext);
+ mLiveDisplay = LiveDisplayManager.getInstance(context);
setDialogLayoutResource(R.layout.display_color_calibration);
}
@@ -88,8 +86,8 @@
System.arraycopy(mOriginalColors, 0, mCurrentColors, 0, 3);
for (int i = 0; i < SEEKBAR_ID.length; i++) {
- IntervalSeekBar seekBar = (IntervalSeekBar) view.findViewById(SEEKBAR_ID[i]);
- TextView value = (TextView) view.findViewById(SEEKBAR_VALUE_ID[i]);
+ IntervalSeekBar seekBar = view.findViewById(SEEKBAR_ID[i]);
+ TextView value = view.findViewById(SEEKBAR_VALUE_ID[i]);
mSeekBars[i] = new ColorSeekBar(seekBar, value, i);
mSeekBars[i].mSeekBar.setMinimum(0.1f);
mSeekBars[i].mSeekBar.setMaximum(1.0f);
@@ -197,9 +195,9 @@
}
private class ColorSeekBar implements SeekBar.OnSeekBarChangeListener {
- private int mIndex;
+ private final int mIndex;
private final IntervalSeekBar mSeekBar;
- private TextView mValue;
+ private final TextView mValue;
public ColorSeekBar(IntervalSeekBar seekBar, TextView value, int index) {
mSeekBar = seekBar;
diff --git a/src/org/lineageos/lineageparts/livedisplay/DisplayTemperature.java b/src/org/lineageos/lineageparts/livedisplay/DisplayTemperature.java
index bb1be6b..7aca559 100644
--- a/src/org/lineageos/lineageparts/livedisplay/DisplayTemperature.java
+++ b/src/org/lineageos/lineageparts/livedisplay/DisplayTemperature.java
@@ -81,12 +81,12 @@
mOriginalDayTemperature = mLiveDisplay.getDayColorTemperature();
mOriginalNightTemperature = mLiveDisplay.getNightColorTemperature();
- SeekBar day = (SeekBar) view.findViewById(R.id.day_temperature_seekbar);
- TextView dayText = (TextView) view.findViewById(R.id.day_temperature_value);
+ SeekBar day = view.findViewById(R.id.day_temperature_seekbar);
+ TextView dayText = view.findViewById(R.id.day_temperature_value);
mDayTemperature = new ColorTemperatureSeekBar(day, dayText);
- SeekBar night = (SeekBar) view.findViewById(R.id.night_temperature_seekbar);
- TextView nightText = (TextView) view.findViewById(R.id.night_temperature_value);
+ SeekBar night = view.findViewById(R.id.night_temperature_seekbar);
+ TextView nightText = view.findViewById(R.id.night_temperature_value);
mNightTemperature = new ColorTemperatureSeekBar(night, nightText);
mDayTemperature.setTemperature(mOriginalDayTemperature);
@@ -147,7 +147,7 @@
mOriginalDayTemperature = myState.originalDayTemperature;
mOriginalNightTemperature = myState.originalNightTemperature;
mDayTemperature.setTemperature(myState.currentDayTemperature);
- mNightTemperature.setTemperature(myState.currentNightTemperature);;
+ mNightTemperature.setTemperature(myState.currentNightTemperature);
updateTemperature(true);
}
diff --git a/src/org/lineageos/lineageparts/livedisplay/LiveDisplaySettings.java b/src/org/lineageos/lineageparts/livedisplay/LiveDisplaySettings.java
index 560d890..dd3aae1 100644
--- a/src/org/lineageos/lineageparts/livedisplay/LiveDisplaySettings.java
+++ b/src/org/lineageos/lineageparts/livedisplay/LiveDisplaySettings.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2015 The CyanogenMod Project
- * 2017-2021 The LineageOS Project
+ * 2017-2022 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.
@@ -102,27 +102,20 @@
private ListPreference mLiveDisplay;
- private SwitchPreference mAntiFlicker;
- private SwitchPreference mColorEnhancement;
- private SwitchPreference mLowPower;
private SwitchPreference mOutdoorMode;
private SwitchPreference mReadingMode;
- private PictureAdjustment mPictureAdjustment;
private DisplayTemperature mDisplayTemperature;
- private DisplayColor mDisplayColor;
private ListPreference mColorProfile;
private String[] mColorProfileSummaries;
- private String[] mModeEntries;
private String[] mModeValues;
private String[] mModeSummaries;
private boolean mHasDisplayModes = false;
private LiveDisplayManager mLiveDisplayManager;
- private LiveDisplayConfig mConfig;
private LineageHardwareManager mHardware;
@@ -135,7 +128,7 @@
mHardware = LineageHardwareManager.getInstance(getActivity());
mLiveDisplayManager = LiveDisplayManager.getInstance(getActivity());
- mConfig = mLiveDisplayManager.getConfig();
+ LiveDisplayConfig config = mLiveDisplayManager.getConfig();
addPreferencesFromResource(R.xml.livedisplay);
@@ -148,7 +141,7 @@
mLiveDisplay = findPreference(KEY_LIVE_DISPLAY);
mLiveDisplay.setValue(String.valueOf(adaptiveMode));
- mModeEntries = res.getStringArray(
+ String[] modeEntries = res.getStringArray(
org.lineageos.platform.internal.R.array.live_display_entries);
mModeValues = res.getStringArray(
org.lineageos.platform.internal.R.array.live_display_values);
@@ -157,7 +150,7 @@
int[] removeIdx = null;
// Remove outdoor mode from lists if there is no support
- if (!mConfig.hasFeature(MODE_OUTDOOR)) {
+ if (!config.hasFeature(MODE_OUTDOOR)) {
removeIdx = ArrayUtils.appendInt(removeIdx,
ArrayUtils.indexOf(mModeValues, String.valueOf(MODE_OUTDOOR)));
} else if (isNightDisplayAvailable) {
@@ -174,31 +167,31 @@
}
if (removeIdx != null) {
- String[] entriesTemp = new String[mModeEntries.length - removeIdx.length];
+ String[] entriesTemp = new String[modeEntries.length - removeIdx.length];
String[] valuesTemp = new String[mModeValues.length - removeIdx.length];
String[] summariesTemp = new String[mModeSummaries.length - removeIdx.length];
int j = 0;
- for (int i = 0; i < mModeEntries.length; i++) {
+ for (int i = 0; i < modeEntries.length; i++) {
if (ArrayUtils.contains(removeIdx, i)) {
continue;
}
- entriesTemp[j] = mModeEntries[i];
+ entriesTemp[j] = modeEntries[i];
valuesTemp[j] = mModeValues[i];
summariesTemp[j] = mModeSummaries[i];
j++;
}
- mModeEntries = entriesTemp;
+ modeEntries = entriesTemp;
mModeValues = valuesTemp;
mModeSummaries = summariesTemp;
}
- mLiveDisplay.setEntries(mModeEntries);
+ mLiveDisplay.setEntries(modeEntries);
mLiveDisplay.setEntryValues(mModeValues);
mLiveDisplay.setOnPreferenceChangeListener(this);
mDisplayTemperature = findPreference(KEY_LIVE_DISPLAY_TEMPERATURE);
if (isNightDisplayAvailable) {
- if (!mConfig.hasFeature(MODE_OUTDOOR)) {
+ if (!config.hasFeature(MODE_OUTDOOR)) {
liveDisplayPrefs.removePreference(mLiveDisplay);
}
liveDisplayPrefs.removePreference(mDisplayTemperature);
@@ -206,7 +199,7 @@
mColorProfile = findPreference(KEY_LIVE_DISPLAY_COLOR_PROFILE);
if (liveDisplayPrefs != null && mColorProfile != null
- && (!mConfig.hasFeature(FEATURE_DISPLAY_MODES) || !updateDisplayModes())) {
+ && (!config.hasFeature(FEATURE_DISPLAY_MODES) || !updateDisplayModes())) {
liveDisplayPrefs.removePreference(mColorProfile);
} else {
mHasDisplayModes = true;
@@ -216,7 +209,7 @@
mOutdoorMode = findPreference(KEY_LIVE_DISPLAY_AUTO_OUTDOOR_MODE);
if (liveDisplayPrefs != null && mOutdoorMode != null
// MODE_AUTO implies automatic outdoor mode on HWC2
- && (isNightDisplayAvailable || !mConfig.hasFeature(MODE_OUTDOOR))) {
+ && (isNightDisplayAvailable || !config.hasFeature(MODE_OUTDOOR))) {
liveDisplayPrefs.removePreference(mOutdoorMode);
mOutdoorMode = null;
}
@@ -230,39 +223,34 @@
mReadingMode.setOnPreferenceChangeListener(this);
}
- mLowPower = findPreference(KEY_LIVE_DISPLAY_LOW_POWER);
- if (advancedPrefs != null && mLowPower != null
- && !mConfig.hasFeature(FEATURE_CABC)) {
- advancedPrefs.removePreference(mLowPower);
- mLowPower = null;
+ SwitchPreference lowPower = findPreference(KEY_LIVE_DISPLAY_LOW_POWER);
+ if (advancedPrefs != null && lowPower != null
+ && !config.hasFeature(FEATURE_CABC)) {
+ advancedPrefs.removePreference(lowPower);
}
- mColorEnhancement = findPreference(KEY_LIVE_DISPLAY_COLOR_ENHANCE);
- if (advancedPrefs != null && mColorEnhancement != null
- && !mConfig.hasFeature(FEATURE_COLOR_ENHANCEMENT)) {
- advancedPrefs.removePreference(mColorEnhancement);
- mColorEnhancement = null;
+ SwitchPreference colorEnhancement = findPreference(KEY_LIVE_DISPLAY_COLOR_ENHANCE);
+ if (advancedPrefs != null && colorEnhancement != null
+ && !config.hasFeature(FEATURE_COLOR_ENHANCEMENT)) {
+ advancedPrefs.removePreference(colorEnhancement);
}
- mPictureAdjustment = findPreference(KEY_PICTURE_ADJUSTMENT);
- if (advancedPrefs != null && mPictureAdjustment != null &&
- !mConfig.hasFeature(FEATURE_PICTURE_ADJUSTMENT)) {
- advancedPrefs.removePreference(mPictureAdjustment);
- mPictureAdjustment = null;
+ PictureAdjustment pictureAdjustment = findPreference(KEY_PICTURE_ADJUSTMENT);
+ if (advancedPrefs != null && pictureAdjustment != null &&
+ !config.hasFeature(FEATURE_PICTURE_ADJUSTMENT)) {
+ advancedPrefs.removePreference(pictureAdjustment);
}
- mDisplayColor = findPreference(KEY_DISPLAY_COLOR);
- if (advancedPrefs != null && mDisplayColor != null &&
- !mConfig.hasFeature(FEATURE_COLOR_ADJUSTMENT)) {
- advancedPrefs.removePreference(mDisplayColor);
- mDisplayColor = null;
+ DisplayColor misplayColor = findPreference(KEY_DISPLAY_COLOR);
+ if (advancedPrefs != null && misplayColor != null &&
+ !config.hasFeature(FEATURE_COLOR_ADJUSTMENT)) {
+ advancedPrefs.removePreference(misplayColor);
}
- mAntiFlicker = findPreference(KEY_LIVE_DISPLAY_ANTI_FLICKER);
- if (liveDisplayPrefs != null && mAntiFlicker != null &&
+ SwitchPreference antiFlicker = findPreference(KEY_LIVE_DISPLAY_ANTI_FLICKER);
+ if (liveDisplayPrefs != null && antiFlicker != null &&
!mHardware.isSupported(LineageHardwareManager.FEATURE_ANTI_FLICKER)) {
- liveDisplayPrefs.removePreference(mAntiFlicker);
- mAntiFlicker = null;
+ liveDisplayPrefs.removePreference(antiFlicker);
}
}
diff --git a/src/org/lineageos/lineageparts/livedisplay/PictureAdjustment.java b/src/org/lineageos/lineageparts/livedisplay/PictureAdjustment.java
index 021a793..2492c89 100644
--- a/src/org/lineageos/lineageparts/livedisplay/PictureAdjustment.java
+++ b/src/org/lineageos/lineageparts/livedisplay/PictureAdjustment.java
@@ -44,7 +44,6 @@
public class PictureAdjustment extends CustomDialogPreference<AlertDialog> {
private static final String TAG = "PictureAdjustment";
- private final Context mContext;
private final LiveDisplayManager mLiveDisplay;
private final List<Range<Float>> mRanges;
@@ -63,7 +62,7 @@
R.id.adj_contrast_value
};
- private ColorSeekBar[] mSeekBars = new ColorSeekBar[SEEKBAR_ID.length];
+ private final ColorSeekBar[] mSeekBars = new ColorSeekBar[SEEKBAR_ID.length];
private final float[] mCurrentAdj = new float[5];
private final float[] mOriginalAdj = new float[5];
@@ -71,8 +70,7 @@
public PictureAdjustment(Context context, AttributeSet attrs) {
super(context, attrs);
- mContext = context;
- mLiveDisplay = LiveDisplayManager.getInstance(mContext);
+ mLiveDisplay = LiveDisplayManager.getInstance(context);
mRanges = mLiveDisplay.getConfig().getPictureAdjustmentRanges();
setDialogLayoutResource(R.layout.display_picture_adjustment);
@@ -102,8 +100,8 @@
System.arraycopy(mOriginalAdj, 0, mCurrentAdj, 0, 5);
for (int i = 0; i < SEEKBAR_ID.length; i++) {
- IntervalSeekBar seekBar = (IntervalSeekBar) view.findViewById(SEEKBAR_ID[i]);
- TextView value = (TextView) view.findViewById(SEEKBAR_VALUE_ID[i]);
+ IntervalSeekBar seekBar = view.findViewById(SEEKBAR_ID[i]);
+ TextView value = view.findViewById(SEEKBAR_VALUE_ID[i]);
final Range<Float> range = mRanges.get(i);
mSeekBars[i] = new ColorSeekBar(seekBar, range, value, i);
}
@@ -205,10 +203,10 @@
}
private class ColorSeekBar implements SeekBar.OnSeekBarChangeListener {
- private int mIndex;
+ private final int mIndex;
private final IntervalSeekBar mSeekBar;
- private TextView mValue;
- private Range<Float> mRange;
+ private final TextView mValue;
+ private final Range<Float> mRange;
public ColorSeekBar(IntervalSeekBar seekBar, Range<Float> range, TextView value,
int index) {
diff --git a/src/org/lineageos/lineageparts/logo/PlatLogoActivity.java b/src/org/lineageos/lineageparts/logo/PlatLogoActivity.java
index 77f1211..a0a4f1d 100644
--- a/src/org/lineageos/lineageparts/logo/PlatLogoActivity.java
+++ b/src/org/lineageos/lineageparts/logo/PlatLogoActivity.java
@@ -28,12 +28,8 @@
import android.graphics.ColorMatrixColorFilter;
import android.graphics.drawable.Drawable;
import android.graphics.Paint;
-import android.graphics.Path;
-import android.graphics.PorterDuff.Mode;
-import android.graphics.Rect;
import android.os.Bundle;
import android.util.Log;
-import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.MotionEvent.PointerCoords;
import android.view.View;
@@ -58,7 +54,7 @@
0, 0, 0, 1, 0 // alpha
};
private static final int BASE_SCALE = 50; // magic number scale multiple. Looks good on all DPI
- private static final long LONG_PRESS_TIMEOUT= new Long(ViewConfiguration.getLongPressTimeout());
+ private static final long LONG_PRESS_TIMEOUT = ViewConfiguration.getLongPressTimeout();
private class PBackground extends Drawable {
private float mRadius, mX, mY, mDP;
@@ -67,7 +63,7 @@
private float mOffset;
// LineageOS logo drawable
- private Drawable mLogo;
+ private final Drawable mLogo;
public PBackground(Context context) {
randomizePalette();
diff --git a/src/org/lineageos/lineageparts/notificationlight/AlphaPatternDrawable.java b/src/org/lineageos/lineageparts/notificationlight/AlphaPatternDrawable.java
index 3717363..5500b7c 100644
--- a/src/org/lineageos/lineageparts/notificationlight/AlphaPatternDrawable.java
+++ b/src/org/lineageos/lineageparts/notificationlight/AlphaPatternDrawable.java
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2010 Daniel Nilsson
* Copyright (C) 2012 The CyanogenMod Project
+ * Copyright (C) 2022 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.
@@ -34,11 +35,11 @@
*/
public class AlphaPatternDrawable extends Drawable {
- private int mRectangleSize = 10;
+ private final int mRectangleSize;
- private Paint mPaint = new Paint();
- private Paint mPaintWhite = new Paint();
- private Paint mPaintGray = new Paint();
+ private final Paint mPaint = new Paint();
+ private final Paint mPaintWhite = new Paint();
+ private final Paint mPaintGray = new Paint();
private int numRectanglesHorizontal;
private int numRectanglesVertical;
diff --git a/src/org/lineageos/lineageparts/notificationlight/ApplicationLightPreference.java b/src/org/lineageos/lineageparts/notificationlight/ApplicationLightPreference.java
index 2e3bba0..a380782 100644
--- a/src/org/lineageos/lineageparts/notificationlight/ApplicationLightPreference.java
+++ b/src/org/lineageos/lineageparts/notificationlight/ApplicationLightPreference.java
@@ -39,7 +39,7 @@
public class ApplicationLightPreference extends CustomDialogPreference<LightSettingsDialog>
implements View.OnLongClickListener {
- private static String TAG = "AppLightPreference";
+ private static final String TAG = "AppLightPreference";
public static final int DEFAULT_TIME = 1000;
public static final int DEFAULT_COLOR = 0xffffff;
@@ -62,7 +62,7 @@
private LightSettingsDialog mDialog;
public interface ItemLongClickListener {
- public boolean onItemLongClick(String key);
+ boolean onItemLongClick(String key);
}
private ItemLongClickListener mLongClickListener;
@@ -224,20 +224,10 @@
updatePreferenceViews();
}
- public void setOnValue(int value) {
- mOnValue = value;
- updatePreferenceViews();
- }
-
public int getOnValue() {
return mOnValue;
}
- public void setOffValue(int value) {
- mOffValue = value;
- updatePreferenceViews();
- }
-
public int getOffValue() {
return mOffValue;
}
@@ -257,16 +247,6 @@
updatePreferenceViews();
}
- public void setOnOffValue(int onValue, int offValue) {
- mOnValue = onValue;
- mOffValue = offValue;
- updatePreferenceViews();
- }
-
- public void setOnOffChangeable(boolean value) {
- mOnOffChangeable = value;
- }
-
public void setDefaultValues(int color, int onValue, int offValue) {
mDefaultColorValue = color;
mDefaultOnValue = onValue;
diff --git a/src/org/lineageos/lineageparts/notificationlight/BatteryBrightnessPreference.java b/src/org/lineageos/lineageparts/notificationlight/BatteryBrightnessPreference.java
index 589bed9..bccb63b 100644
--- a/src/org/lineageos/lineageparts/notificationlight/BatteryBrightnessPreference.java
+++ b/src/org/lineageos/lineageparts/notificationlight/BatteryBrightnessPreference.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The LineageOS Project
+ * Copyright (C) 2017-2022 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.
@@ -23,9 +23,9 @@
import lineageos.providers.LineageSettings;
public class BatteryBrightnessPreference extends BrightnessPreference {
- private static String TAG = "BatteryBrightnessPreference";
+ private static final String TAG = "BatteryBrightnessPreference";
- private Context mContext;
+ private final Context mContext;
public BatteryBrightnessPreference(Context context, AttributeSet attrs) {
super(context, attrs);
diff --git a/src/org/lineageos/lineageparts/notificationlight/BatteryBrightnessZenPreference.java b/src/org/lineageos/lineageparts/notificationlight/BatteryBrightnessZenPreference.java
index 68d4d17..b0eb32a 100644
--- a/src/org/lineageos/lineageparts/notificationlight/BatteryBrightnessZenPreference.java
+++ b/src/org/lineageos/lineageparts/notificationlight/BatteryBrightnessZenPreference.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The LineageOS Project
+ * Copyright (C) 2017-2022 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.
@@ -23,9 +23,9 @@
import lineageos.providers.LineageSettings;
public class BatteryBrightnessZenPreference extends BrightnessPreference {
- private static String TAG = "BatteryBrightnessZenPreference";
+ private static final String TAG = "BatteryBrightnessZenPreference";
- private Context mContext;
+ private final Context mContext;
public BatteryBrightnessZenPreference(Context context, AttributeSet attrs) {
super(context, attrs);
diff --git a/src/org/lineageos/lineageparts/notificationlight/BatteryLightSettings.java b/src/org/lineageos/lineageparts/notificationlight/BatteryLightSettings.java
index e3cc1ee..3f54935 100644
--- a/src/org/lineageos/lineageparts/notificationlight/BatteryLightSettings.java
+++ b/src/org/lineageos/lineageparts/notificationlight/BatteryLightSettings.java
@@ -55,7 +55,6 @@
private static final String BRIGHTNESS_PREFERENCE = "battery_light_brightness_level";
private static final String BRIGHTNESS_ZEN_PREFERENCE = "battery_light_brightness_level_zen";
- private PreferenceGroup mColorPrefs;
private ApplicationLightPreference mLowColorPref;
private ApplicationLightPreference mMediumColorPref;
private ApplicationLightPreference mFullColorPref;
@@ -67,9 +66,6 @@
private int mDefaultLowColor;
private int mDefaultMediumColor;
private int mDefaultFullColor;
- private int mBatteryBrightness;
- // liblights supports brightness control
- private boolean mHALAdjustableBrightness;
private boolean mMultiColorLed;
private static final int MENU_RESET = Menu.FIRST;
@@ -84,8 +80,9 @@
// Collect battery led capabilities.
mMultiColorLed =
LightsCapabilities.supports(context, LightsCapabilities.LIGHTS_RGB_BATTERY_LED);
- mHALAdjustableBrightness = LightsCapabilities.supports(
- context, LightsCapabilities.LIGHTS_ADJUSTABLE_BATTERY_LED_BRIGHTNESS);
+ // liblights supports brightness control
+ final boolean halAdjustableBrightness = LightsCapabilities.supports(context,
+ LightsCapabilities.LIGHTS_ADJUSTABLE_BATTERY_LED_BRIGHTNESS);
final boolean pulsatingLed = LightsCapabilities.supports(context,
LightsCapabilities.LIGHTS_PULSATING_LED);
final boolean segmentedBatteryLed = LightsCapabilities.supports(context,
@@ -111,7 +108,7 @@
mDefaultFullColor = res.getInteger(
com.android.internal.R.integer.config_notificationsBatteryFullARGB);
- mBatteryBrightness = mBatteryBrightnessPref.getBrightnessSetting();
+ int batteryBrightness = mBatteryBrightnessPref.getBrightnessSetting();
if (!pulsatingLed || segmentedBatteryLed) {
generalPrefs.removePreference(mPulseEnabledPref);
@@ -125,26 +122,23 @@
mLowColorPref = prefSet.findPreference(LOW_COLOR_PREF);
mLowColorPref.setOnPreferenceChangeListener(this);
mLowColorPref.setDefaultValues(mDefaultLowColor, 0, 0);
- mLowColorPref.setBrightness(mBatteryBrightness);
+ mLowColorPref.setBrightness(batteryBrightness);
mMediumColorPref = prefSet.findPreference(MEDIUM_COLOR_PREF);
mMediumColorPref.setOnPreferenceChangeListener(this);
mMediumColorPref.setDefaultValues(mDefaultMediumColor, 0, 0);
- mMediumColorPref.setBrightness(mBatteryBrightness);
+ mMediumColorPref.setBrightness(batteryBrightness);
mFullColorPref = prefSet.findPreference(FULL_COLOR_PREF);
mFullColorPref.setOnPreferenceChangeListener(this);
mFullColorPref.setDefaultValues(mDefaultFullColor, 0, 0);
- mFullColorPref.setBrightness(mBatteryBrightness);
+ mFullColorPref.setBrightness(batteryBrightness);
final BrightnessPreference.OnBrightnessChangedListener brightnessListener =
- new BrightnessPreference.OnBrightnessChangedListener() {
- @Override
- public void onBrightnessChanged(int brightness) {
- mLowColorPref.setBrightness(brightness);
- mMediumColorPref.setBrightness(brightness);
- mFullColorPref.setBrightness(brightness);
- }
+ brightness -> {
+ mLowColorPref.setBrightness(brightness);
+ mMediumColorPref.setBrightness(brightness);
+ mFullColorPref.setBrightness(brightness);
};
mBatteryBrightnessPref.setOnBrightnessChangedListener(brightnessListener);
} else {
@@ -153,7 +147,7 @@
}
// Remove battery LED brightness controls if we can't support them.
- if (!mMultiColorLed && !mHALAdjustableBrightness) {
+ if (!mMultiColorLed && !halAdjustableBrightness) {
prefSet.removePreference(prefSet.findPreference(BRIGHTNESS_SECTION));
}
diff --git a/src/org/lineageos/lineageparts/notificationlight/BrightnessPreference.java b/src/org/lineageos/lineageparts/notificationlight/BrightnessPreference.java
index 6df3f3f..d7ac5f4 100644
--- a/src/org/lineageos/lineageparts/notificationlight/BrightnessPreference.java
+++ b/src/org/lineageos/lineageparts/notificationlight/BrightnessPreference.java
@@ -16,10 +16,8 @@
package org.lineageos.lineageparts.notificationlight;
-import android.app.Dialog;
import android.app.Notification;
import android.app.NotificationManager;
-import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
@@ -28,7 +26,6 @@
import android.os.Message;
import android.os.Parcel;
import android.os.Parcelable;
-import android.os.UserHandle;
import android.util.AttributeSet;
import android.view.View;
import android.widget.SeekBar;
@@ -48,7 +45,7 @@
public class BrightnessPreference extends CustomDialogPreference<AlertDialog>
implements SeekBar.OnSeekBarChangeListener {
- private static String TAG = "BrightnessPreference";
+ private static final String TAG = "BrightnessPreference";
public static final int LIGHT_BRIGHTNESS_MINIMUM = 1;
public static final int LIGHT_BRIGHTNESS_MAXIMUM = 255;
@@ -74,13 +71,12 @@
private int mLedColor = DEFAULT_LED_COLOR;
private final Context mContext;
- private final Handler mHandler;
private final Notification.Builder mNotificationBuilder;
- private NotificationManager mNotificationManager;
+ private final NotificationManager mNotificationManager;
public interface OnBrightnessChangedListener {
- public void onBrightnessChanged(int brightness);
+ void onBrightnessChanged(int brightness);
}
private OnBrightnessChangedListener mListener;
@@ -93,9 +89,6 @@
mContext = context;
- // Message handler used for led notification update throttling.
- mHandler = new Handler(Looper.getMainLooper());
-
mNotificationManager = context.getSystemService(NotificationManager.class);
// Force lights on when screen is on and also force maximum brightness.
@@ -164,11 +157,11 @@
super.onBindDialogView(view);
// Locate text view for percentage value
- mDialogPercent = (TextView) view.findViewById(R.id.brightness_percent);
+ mDialogPercent = view.findViewById(R.id.brightness_percent);
mVisibleLedBrightness = 0; // LED notification is not showing.
- mBrightnessBar = (SeekBar) view.findViewById(R.id.brightness_seekbar);
+ mBrightnessBar = view.findViewById(R.id.brightness_seekbar);
mBrightnessBar.setMax(LIGHT_BRIGHTNESS_MAXIMUM);
mBrightnessBar.setMin(LIGHT_BRIGHTNESS_MINIMUM);
mBrightnessBar.setOnSeekBarChangeListener(this);
diff --git a/src/org/lineageos/lineageparts/notificationlight/ColorPickerView.java b/src/org/lineageos/lineageparts/notificationlight/ColorPickerView.java
index 10c78a8..3b63b1d 100644
--- a/src/org/lineageos/lineageparts/notificationlight/ColorPickerView.java
+++ b/src/org/lineageos/lineageparts/notificationlight/ColorPickerView.java
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2010 Daniel Nilsson
* Copyright (C) 2012 The CyanogenMod Project
+ * Copyright (C) 2022 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.
@@ -45,7 +46,7 @@
public class ColorPickerView extends View {
public interface OnColorChangedListener {
- public void onColorChanged(int color);
+ void onColorChanged(int color);
}
private final static int PANEL_SAT_VAL = 0;
@@ -104,9 +105,9 @@
private float mSat = 0f;
private float mVal = 0f;
- private String mAlphaSliderText = "Alpha";
- private int mSliderTrackerColor = 0xff1c1c1c;
- private int mBorderColor = 0xff6E6E6E;
+ private final static String ALPHA_SLIDER_TEXT = "Alpha";
+ private final static int SLIDER_TRACKER_COLOR = 0xff1c1c1c;
+ private final static int BORDER_COLOR = 0xff6E6E6E;
private boolean mShowAlphaPanel = false;
/*
@@ -177,7 +178,7 @@
mSatValTrackerPaint.setStrokeWidth(2f * mDensity);
mSatValTrackerPaint.setAntiAlias(true);
- mHueTrackerPaint.setColor(mSliderTrackerColor);
+ mHueTrackerPaint.setColor(SLIDER_TRACKER_COLOR);
mHueTrackerPaint.setStyle(Style.STROKE);
mHueTrackerPaint.setStrokeWidth(2f * mDensity);
mHueTrackerPaint.setAntiAlias(true);
@@ -225,7 +226,7 @@
});
if (BORDER_WIDTH_PX > 0) {
- mBorderPaint.setColor(mBorderColor);
+ mBorderPaint.setColor(BORDER_COLOR);
canvas.drawRect(mDrawingRect.left, mDrawingRect.top, rect.right + BORDER_WIDTH_PX,
rect.bottom + BORDER_WIDTH_PX, mBorderPaint);
}
@@ -248,8 +249,7 @@
Point p = satValToPoint(mSat, mVal);
mSatValTrackerPaint.setColor(0xff000000);
- canvas.drawCircle(p.x, p.y, PALETTE_CIRCLE_TRACKER_RADIUS - 1f * mDensity,
- mSatValTrackerPaint);
+ canvas.drawCircle(p.x, p.y, PALETTE_CIRCLE_TRACKER_RADIUS - mDensity, mSatValTrackerPaint);
mSatValTrackerPaint.setColor(0xffdddddd);
canvas.drawCircle(p.x, p.y, PALETTE_CIRCLE_TRACKER_RADIUS, mSatValTrackerPaint);
@@ -259,7 +259,7 @@
final RectF rect = mHueRect;
if (BORDER_WIDTH_PX > 0) {
- mBorderPaint.setColor(mBorderColor);
+ mBorderPaint.setColor(BORDER_COLOR);
canvas.drawRect(rect.left - BORDER_WIDTH_PX,
rect.top - BORDER_WIDTH_PX,
rect.right + BORDER_WIDTH_PX,
@@ -297,7 +297,7 @@
final RectF rect = mAlphaRect;
if (BORDER_WIDTH_PX > 0) {
- mBorderPaint.setColor(mBorderColor);
+ mBorderPaint.setColor(BORDER_COLOR);
canvas.drawRect(rect.left - BORDER_WIDTH_PX,
rect.top - BORDER_WIDTH_PX,
rect.right + BORDER_WIDTH_PX,
@@ -320,10 +320,8 @@
canvas.drawRect(rect, mAlphaPaint);
- if (mAlphaSliderText != null && mAlphaSliderText != "") {
- canvas.drawText(mAlphaSliderText, rect.centerX(), rect.centerY() + 4 * mDensity,
- mAlphaTextPaint);
- }
+ canvas.drawText(ALPHA_SLIDER_TEXT, rect.centerX(), rect.centerY() + 4 * mDensity,
+ mAlphaTextPaint);
float rectWidth = 4 * mDensity / 2;
Point p = alphaToPoint(mAlpha);
@@ -579,7 +577,6 @@
width = widthAllowed;
}
} else {
-
width = (int) (heightAllowed - ALPHA_PANEL_HEIGHT + HUE_PANEL_WIDTH);
if (width > widthAllowed && widthMode != MeasureSpec.UNSPECIFIED) {
@@ -693,21 +690,6 @@
}
/**
- * Set the color of the border surrounding all panels.
- */
- public void setBorderColor(int color) {
- mBorderColor = color;
- invalidate();
- }
-
- /**
- * Get the color of the border surrounding all panels.
- */
- public int getBorderColor() {
- return mBorderColor;
- }
-
- /**
* Get the current color this view is showing.
*
* @return the current color.
@@ -756,18 +738,6 @@
}
/**
- * Get the drawing offset of the color picker view. The drawing offset is
- * the distance from the side of a panel to the side of the view minus the
- * padding. Useful if you want to have your own panel below showing the
- * currently selected color and want to align it perfectly.
- *
- * @return The offset in pixels.
- */
- public float getDrawingOffset() {
- return mDrawingOffset;
- }
-
- /**
* Set if the user is allowed to adjust the alpha panel. Default is false.
* If it is set to false no alpha will be set.
*/
@@ -791,43 +761,4 @@
public boolean isAlphaSliderVisible() {
return mShowAlphaPanel;
}
-
- public void setSliderTrackerColor(int color) {
- mSliderTrackerColor = color;
- mHueTrackerPaint.setColor(mSliderTrackerColor);
- invalidate();
- }
-
- public int getSliderTrackerColor() {
- return mSliderTrackerColor;
- }
-
- /**
- * Set the text that should be shown in the alpha slider. Set to null to
- * disable text.
- *
- * @param res string resource id.
- */
- public void setAlphaSliderText(int res) {
- String text = getContext().getString(res);
- setAlphaSliderText(text);
- }
-
- /**
- * Set the text that should be shown in the alpha slider. Set to null to
- * disable text.
- *
- * @param text Text that should be shown.
- */
- public void setAlphaSliderText(String text) {
- mAlphaSliderText = text;
- invalidate();
- }
-
- /**
- * Get the current value of the text that will be shown in the alpha slider.
- */
- public String getAlphaSliderText() {
- return mAlphaSliderText;
- }
}
diff --git a/src/org/lineageos/lineageparts/notificationlight/LightSettingsDialog.java b/src/org/lineageos/lineageparts/notificationlight/LightSettingsDialog.java
index 985b7fa..e0f85cc 100644
--- a/src/org/lineageos/lineageparts/notificationlight/LightSettingsDialog.java
+++ b/src/org/lineageos/lineageparts/notificationlight/LightSettingsDialog.java
@@ -18,7 +18,6 @@
package org.lineageos.lineageparts.notificationlight;
-import android.app.Activity;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
@@ -64,8 +63,6 @@
private final static long LED_UPDATE_DELAY_MS = 250;
private ColorPickerView mColorPicker;
- private LinearLayout mColorPanel;
- private View mLightsDialogDivider;
private EditText mHexColorInput;
private ColorPanelView mNewColor;
@@ -127,14 +124,11 @@
mInflater = mContext.getSystemService(LayoutInflater.class);
View layout = mInflater.inflate(R.layout.dialog_light_settings, null);
- mColorPicker = (ColorPickerView) layout.findViewById(R.id.color_picker_view);
- mColorPanel = (LinearLayout) layout.findViewById(R.id.color_panel_view);
- mHexColorInput = (EditText) layout.findViewById(R.id.hex_color_input);
- mNewColor = (ColorPanelView) layout.findViewById(R.id.color_panel);
- mLightsDialogDivider = (View) layout.findViewById(R.id.lights_dialog_divider);
- mPulseSpeedOn = (Spinner) layout.findViewById(R.id.on_spinner);
- mPulseSpeedOff = (Spinner) layout.findViewById(R.id.off_spinner);
-
+ mColorPicker = layout.findViewById(R.id.color_picker_view);
+ mHexColorInput = layout.findViewById(R.id.hex_color_input);
+ mNewColor = layout.findViewById(R.id.color_panel);
+ mPulseSpeedOn = layout.findViewById(R.id.on_spinner);
+ mPulseSpeedOff = layout.findViewById(R.id.off_spinner);
mColorPicker.setOnColorChangedListener(this);
mColorPicker.setColor(color, true);
@@ -169,8 +163,10 @@
if (!LightsCapabilities.supports(
mContext, LightsCapabilities.LIGHTS_RGB_NOTIFICATION_LED)) {
mColorPicker.setVisibility(View.GONE);
- mColorPanel.setVisibility(View.GONE);
- mLightsDialogDivider.setVisibility(View.GONE);
+ LinearLayout colorPanel = layout.findViewById(R.id.color_panel_view);
+ colorPanel.setVisibility(View.GONE);
+ View lightsDialogDivider = layout.findViewById(R.id.lights_dialog_divider);
+ lightsDialogDivider.setVisibility(View.GONE);
}
mLedBrightness = brightness;
@@ -180,7 +176,7 @@
updateLed();
}
- private AdapterView.OnItemSelectedListener mPulseSelectionListener =
+ private final AdapterView.OnItemSelectedListener mPulseSelectionListener =
new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
@@ -354,16 +350,16 @@
}
class PulseSpeedAdapter extends BaseAdapter implements SpinnerAdapter {
- private ArrayList<Pair<String, Integer>> times;
+ private final ArrayList<Pair<String, Integer>> times;
public PulseSpeedAdapter(int timeNamesResource, int timeValuesResource) {
- times = new ArrayList<Pair<String, Integer>>();
+ times = new ArrayList<>();
String[] time_names = mContext.getResources().getStringArray(timeNamesResource);
String[] time_values = mContext.getResources().getStringArray(timeValuesResource);
for(int i = 0; i < time_values.length; ++i) {
- times.add(new Pair<String, Integer>(time_names[i], Integer.decode(time_values[i])));
+ times.add(new Pair<>(time_names[i], Integer.decode(time_values[i])));
}
}
diff --git a/src/org/lineageos/lineageparts/notificationlight/NotificationBrightnessPreference.java b/src/org/lineageos/lineageparts/notificationlight/NotificationBrightnessPreference.java
index 949ccda..ed2c78a 100644
--- a/src/org/lineageos/lineageparts/notificationlight/NotificationBrightnessPreference.java
+++ b/src/org/lineageos/lineageparts/notificationlight/NotificationBrightnessPreference.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The LineageOS Project
+ * Copyright (C) 2017-2022 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.
@@ -23,9 +23,9 @@
import lineageos.providers.LineageSettings;
public class NotificationBrightnessPreference extends BrightnessPreference {
- private static String TAG = "NotificationBrightnessPreference";
+ private static final String TAG = "NotificationBrightnessPreference";
- private Context mContext;
+ private final Context mContext;
public NotificationBrightnessPreference(Context context, AttributeSet attrs) {
super(context, attrs);
diff --git a/src/org/lineageos/lineageparts/notificationlight/NotificationBrightnessZenPreference.java b/src/org/lineageos/lineageparts/notificationlight/NotificationBrightnessZenPreference.java
index 44de892..600c159 100644
--- a/src/org/lineageos/lineageparts/notificationlight/NotificationBrightnessZenPreference.java
+++ b/src/org/lineageos/lineageparts/notificationlight/NotificationBrightnessZenPreference.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The LineageOS Project
+ * Copyright (C) 2017-2022 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.
@@ -23,9 +23,9 @@
import lineageos.providers.LineageSettings;
public class NotificationBrightnessZenPreference extends BrightnessPreference {
- private static String TAG = "NotificationBrightnessZenPreference";
+ private static final String TAG = "NotificationBrightnessZenPreference";
- private Context mContext;
+ private final Context mContext;
public NotificationBrightnessZenPreference(Context context, AttributeSet attrs) {
super(context, attrs);
diff --git a/src/org/lineageos/lineageparts/notificationlight/NotificationLightSettings.java b/src/org/lineageos/lineageparts/notificationlight/NotificationLightSettings.java
index cc06547..b016332 100644
--- a/src/org/lineageos/lineageparts/notificationlight/NotificationLightSettings.java
+++ b/src/org/lineageos/lineageparts/notificationlight/NotificationLightSettings.java
@@ -18,7 +18,6 @@
package org.lineageos.lineageparts.notificationlight;
import android.app.Dialog;
-import android.app.NotificationManager;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
@@ -82,7 +81,6 @@
private int mDefaultLedOff;
private PackageManager mPackageManager;
private PreferenceGroup mApplicationPrefList;
- private NotificationBrightnessPreference mNotificationBrightnessPref;
private SystemSettingMainSwitchPreference mEnabledPref;
private LineageSystemSettingSwitchPreference mCustomEnabledPref;
private LineageSystemSettingSwitchPreference mScreenOnLightsPref;
@@ -93,8 +91,6 @@
private PackageListAdapter mPackageAdapter;
private String mPackageList;
private Map<String, Package> mPackages;
- // liblights supports brightness control
- private boolean mHALAdjustableBrightness;
// Supports rgb color control
private boolean mMultiColorLed;
// Supports adjustable pulse
@@ -124,7 +120,8 @@
mDefaultLedOff = resources.getInteger(
com.android.internal.R.integer.config_defaultNotificationLedOff);
- mHALAdjustableBrightness = LightsCapabilities.supports(
+ // liblights supports brightness control
+ final boolean halAdjustableBrightness = LightsCapabilities.supports(
context, LightsCapabilities.LIGHTS_ADJUSTABLE_NOTIFICATION_LED_BRIGHTNESS);
mLedCanPulse = LightsCapabilities.supports(
context, LightsCapabilities.LIGHTS_PULSATING_LED);
@@ -139,14 +136,12 @@
mAutoGenerateColors = findPreference(LineageSettings.System.NOTIFICATION_LIGHT_COLOR_AUTO);
// Advanced light settings
- mNotificationBrightnessPref =
- findPreference(LineageSettings.System.NOTIFICATION_LIGHT_BRIGHTNESS_LEVEL);
mScreenOnLightsPref =
findPreference(LineageSettings.System.NOTIFICATION_LIGHT_SCREEN_ON);
mScreenOnLightsPref.setOnPreferenceChangeListener(this);
mCustomEnabledPref =
findPreference(LineageSettings.System.NOTIFICATION_LIGHT_PULSE_CUSTOM_ENABLE);
- if (!mMultiColorLed && !mHALAdjustableBrightness) {
+ if (!mMultiColorLed && !halAdjustableBrightness) {
removePreference(BRIGHTNESS_SECTION);
}
if (!mLedCanPulse && !mMultiColorLed) {
@@ -183,7 +178,7 @@
mPackageManager = getActivity().getPackageManager();
mPackageAdapter = new PackageListAdapter(getActivity());
- mPackages = new HashMap<String, Package>();
+ mPackages = new HashMap<>();
Preference addPreference = prefSet.findPreference(ADD_APPS);
addPreference.setOnPreferenceClickListener(preference -> {
@@ -399,13 +394,13 @@
}
}
- mPackageAdapter.setExcludedPackages(new HashSet<String>(mPackages.keySet()));
+ mPackageAdapter.setExcludedPackages(new HashSet<>(mPackages.keySet()));
return true;
}
private void savePackageList(boolean preferencesUpdated) {
- List<String> settings = new ArrayList<String>();
+ List<String> settings = new ArrayList<>();
for (Package app : mPackages.values()) {
settings.add(app.toString());
}
@@ -595,9 +590,8 @@
return null;
try {
- Package item = new Package(app[0], Integer.parseInt(values[0]), Integer
+ return new Package(app[0], Integer.parseInt(values[0]), Integer
.parseInt(values[1]), Integer.parseInt(values[2]));
- return item;
} catch (NumberFormatException e) {
return null;
}
diff --git a/src/org/lineageos/lineageparts/profiles/NFCProfileSelect.java b/src/org/lineageos/lineageparts/profiles/NFCProfileSelect.java
index 8dde72b..16e2fa0 100644
--- a/src/org/lineageos/lineageparts/profiles/NFCProfileSelect.java
+++ b/src/org/lineageos/lineageparts/profiles/NFCProfileSelect.java
@@ -40,16 +40,13 @@
private static final String TAG = "NFCProfileSelect";
- static final String EXTRA_PROFILE_UUID = "PROFILE_UUID";
+ private static final int DEFAULT_CHOICE = -1;
+
+ public static final String EXTRA_PROFILE_UUID = "PROFILE_UUID";
private ProfileManager mProfileManager;
-
private UUID mProfileUuid;
-
- final static int defaultChoice = -1;
-
- private int currentChoice = defaultChoice;
-
+ private int mCurrentChoice = DEFAULT_CHOICE;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -92,14 +89,14 @@
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- currentChoice = which;
+ mCurrentChoice = which;
}
});
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- if (currentChoice != defaultChoice) {
- Profile profile = profiles[currentChoice];
+ if (mCurrentChoice != DEFAULT_CHOICE) {
+ Profile profile = profiles[mCurrentChoice];
profile.addSecondaryUuid(mProfileUuid);
mProfileManager.updateProfile(profile);
Toast.makeText(NFCProfileSelect.this, R.string.profile_write_success,
diff --git a/src/org/lineageos/lineageparts/profiles/NFCProfileTagCallback.java b/src/org/lineageos/lineageparts/profiles/NFCProfileTagCallback.java
index 0ecae6f..6e2195e 100644
--- a/src/org/lineageos/lineageparts/profiles/NFCProfileTagCallback.java
+++ b/src/org/lineageos/lineageparts/profiles/NFCProfileTagCallback.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2014 The CyanogenMod Project
+ * Copyright (C) 2022 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.
@@ -18,5 +19,5 @@
import android.nfc.Tag;
public interface NFCProfileTagCallback {
- public void onTagRead(Tag tag);
+ void onTagRead(Tag tag);
}
diff --git a/src/org/lineageos/lineageparts/profiles/NFCProfileUtils.java b/src/org/lineageos/lineageparts/profiles/NFCProfileUtils.java
index b48ae68..2c1ca0e 100644
--- a/src/org/lineageos/lineageparts/profiles/NFCProfileUtils.java
+++ b/src/org/lineageos/lineageparts/profiles/NFCProfileUtils.java
@@ -99,9 +99,8 @@
for (int i = 8; i < 16; i++) {
lsb = (lsb << 8) | (byteArray[i] & 0xff);
}
- UUID result = new UUID(msb, lsb);
- return result;
+ return new UUID(msb, lsb);
}
/* Convert a UUID to a 16-byte array */
diff --git a/src/org/lineageos/lineageparts/profiles/NFCProfileWriter.java b/src/org/lineageos/lineageparts/profiles/NFCProfileWriter.java
index d651e9b..e5f40d8 100644
--- a/src/org/lineageos/lineageparts/profiles/NFCProfileWriter.java
+++ b/src/org/lineageos/lineageparts/profiles/NFCProfileWriter.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2012 The CyanogenMod Project
- * 2017-2018,2021 The LineageOS Project
+ * 2017-2018,2021-2022 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.
@@ -47,8 +47,6 @@
private NfcAdapter mNfcAdapter;
- private IntentFilter[] mWriteTagFilters;
-
private Profile mProfile;
private ProfileManager mProfileManager;
@@ -94,10 +92,10 @@
private void enableTagWriteMode() {
IntentFilter tagDetected = new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED);
- mWriteTagFilters = new IntentFilter[] {
- tagDetected
+ IntentFilter[] writeTagFilters = new IntentFilter[]{
+ tagDetected
};
- mNfcAdapter.enableForegroundDispatch(this, getPendingIntent(), mWriteTagFilters, null);
+ mNfcAdapter.enableForegroundDispatch(this, getPendingIntent(), writeTagFilters, null);
}
@Override
diff --git a/src/org/lineageos/lineageparts/profiles/NamePreference.java b/src/org/lineageos/lineageparts/profiles/NamePreference.java
deleted file mode 100644
index b8f3765..0000000
--- a/src/org/lineageos/lineageparts/profiles/NamePreference.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2012 The CyanogenMod Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.lineageos.lineageparts.profiles;
-
-import android.content.Context;
-import android.content.DialogInterface;
-import android.view.View;
-import android.widget.EditText;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import androidx.appcompat.app.AlertDialog;
-import androidx.preference.Preference;
-import androidx.preference.PreferenceViewHolder;
-
-import org.lineageos.lineageparts.R;
-
-public class NamePreference extends Preference implements
- View.OnClickListener, Preference.OnPreferenceChangeListener {
- private static final String TAG = NamePreference.class.getSimpleName();
-
- private TextView mNameView;
-
- private String mName;
-
- /**
- * @param context
- * @param title
- */
- public NamePreference(Context context, String name) {
- super(context);
- mName = name.toString();
- init();
- }
-
- /**
- * @param context
- */
- public NamePreference(Context context) {
- super(context);
- init();
- }
-
- @Override
- public void onBindViewHolder(PreferenceViewHolder holder) {
- super.onBindViewHolder(holder);
-
- View namePref = holder.findViewById(R.id.name_pref);
- if ((namePref != null) && namePref instanceof LinearLayout) {
- namePref.setOnClickListener(this);
- }
-
- mNameView = (TextView) holder.findViewById(R.id.title);
-
- updatePreferenceViews();
- }
-
- private void init() {
- setLayoutResource(R.layout.preference_name);
- }
-
- public void setName(String name) {
- mName = (name.toString());
- updatePreferenceViews();
- }
-
- public String getName() {
- return(mName.toString());
- }
-
- private void updatePreferenceViews() {
- if (mNameView != null) {
- mNameView.setText(mName.toString());
- }
- }
-
- @Override
- public void onClick(android.view.View v) {
- if (v != null) {
- Context context = getContext();
- if (context != null) {
- final EditText entry = new EditText(context);
- entry.setSingleLine();
- entry.setText(mName.toString());
-
- AlertDialog.Builder builder = new AlertDialog.Builder(context);
- builder.setTitle(R.string.rename_dialog_title);
- builder.setMessage(R.string.rename_dialog_message);
- builder.setView(entry, 34, 16, 34, 16);
- builder.setPositiveButton(android.R.string.ok,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- String value = entry.getText().toString();
- mName = value.toString();
- mNameView.setText(value.toString());
- callChangeListener(this);
- }
- });
- builder.setNegativeButton(android.R.string.cancel, null);
- AlertDialog dialog = builder.create();
- dialog.show();
- ((TextView)dialog.findViewById(android.R.id.message)).setTextAppearance(context,
- android.R.style.TextAppearance_DeviceDefault_Small);
- }
- }
- }
-
- @Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- callChangeListener(preference);
- return false;
- }
-}
diff --git a/src/org/lineageos/lineageparts/profiles/ProfilesSettings.java b/src/org/lineageos/lineageparts/profiles/ProfilesSettings.java
index 2e79407..81edda3 100644
--- a/src/org/lineageos/lineageparts/profiles/ProfilesSettings.java
+++ b/src/org/lineageos/lineageparts/profiles/ProfilesSettings.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2012 The CyanogenMod Project
- * 2017-2021 The LineageOS Project
+ * 2017-2022 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.
@@ -111,7 +111,7 @@
View v = LayoutInflater.from(getActivity())
.inflate(R.layout.empty_textview, (ViewGroup) view, true);
- TextView emptyTextView = (TextView) v.findViewById(R.id.empty);
+ TextView emptyTextView = v.findViewById(R.id.empty);
setEmptyView(emptyTextView);
}
diff --git a/src/org/lineageos/lineageparts/profiles/SeekBarVolumizer.java b/src/org/lineageos/lineageparts/profiles/SeekBarVolumizer.java
index 7174424..706ab78 100644
--- a/src/org/lineageos/lineageparts/profiles/SeekBarVolumizer.java
+++ b/src/org/lineageos/lineageparts/profiles/SeekBarVolumizer.java
@@ -17,7 +17,6 @@
package org.lineageos.lineageparts.profiles;
-import android.annotation.NonNull;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -62,7 +61,6 @@
private static final int MSG_GROUP_VOLUME_CHANGED = 1;
private final Handler mVolumeHandler = new VolumeHandler(Looper.getMainLooper());
- private AudioAttributes mAttributes;
private int mVolumeGroupId;
private final AudioManager.VolumeGroupCallback mVolumeGroupCallback =
@@ -89,8 +87,8 @@
private final int mMaxStreamVolume;
private final int mMinStreamVolume;
private final boolean mVoiceCapable;
- private boolean mAffectedByRingerMode;
- private boolean mNotificationOrRing;
+ private final boolean mAffectedByRingerMode;
+ private final boolean mNotificationOrRing;
private final Receiver mReceiver = new Receiver();
private Handler mHandler;
@@ -108,7 +106,7 @@
private int mVolumeBeforeMute = -1;
private int mRingerMode;
private int mZenMode;
- private boolean mPlaySample;
+ private final boolean mPlaySample;
private static final int MSG_SET_STREAM_VOLUME = 0;
private static final int MSG_START_SAMPLE = 1;
@@ -151,8 +149,6 @@
if (hasAudioProductStrategies()) {
mVolumeGroupId = getVolumeGroupIdForLegacyStreamType(mStreamType);
- mAttributes = getAudioAttributesForLegacyStreamType(
- mStreamType);
}
mMaxStreamVolume = mAudioManager.getStreamMaxVolume(mStreamType);
@@ -200,19 +196,6 @@
.orElse(AudioVolumeGroup.DEFAULT_VOLUME_GROUP);
}
- private @NonNull AudioAttributes getAudioAttributesForLegacyStreamType(int streamType) {
- for (final AudioProductStrategy productStrategy :
- AudioManager.getAudioProductStrategies()) {
- AudioAttributes aa = productStrategy.getAudioAttributesForLegacyStreamType(streamType);
- if (aa != null) {
- return aa;
- }
- }
- return new AudioAttributes.Builder()
- .setContentType(AudioAttributes.CONTENT_TYPE_UNKNOWN)
- .setUsage(AudioAttributes.USAGE_UNKNOWN).build();
- }
-
private static boolean isNotificationOrRing(int stream) {
return stream == AudioManager.STREAM_RING || stream == AudioManager.STREAM_NOTIFICATION;
}
@@ -483,7 +466,7 @@
if (mSeekBar != null) {
mLastProgress = msg.arg1;
mLastAudibleStreamVolume = msg.arg2;
- final boolean muted = ((Boolean)msg.obj).booleanValue();
+ final boolean muted = (Boolean) msg.obj;
if (muted != mMuted) {
mMuted = muted;
if (mCallback != null) {
@@ -496,7 +479,7 @@
}
public void postUpdateSlider(int volume, int lastAudibleVolume, boolean mute) {
- obtainMessage(UPDATE_SLIDER, volume, lastAudibleVolume, new Boolean(mute)).sendToTarget();
+ obtainMessage(UPDATE_SLIDER, volume, lastAudibleVolume, mute).sendToTarget();
}
}
diff --git a/src/org/lineageos/lineageparts/profiles/SetupActionsFragment.java b/src/org/lineageos/lineageparts/profiles/SetupActionsFragment.java
index 79ccfc0..2cfe572 100644
--- a/src/org/lineageos/lineageparts/profiles/SetupActionsFragment.java
+++ b/src/org/lineageos/lineageparts/profiles/SetupActionsFragment.java
@@ -19,7 +19,6 @@
import android.app.Activity;
import android.app.Dialog;
-import android.app.NotificationGroup;
import android.app.admin.DevicePolicyManager;
import android.bluetooth.BluetoothAdapter;
import android.content.ContentResolver;
@@ -28,7 +27,6 @@
import android.content.Intent;
import android.location.LocationManager;
import android.media.AudioManager;
-import android.media.RingtoneManager;
import android.net.ConnectivityManager;
import android.net.wifi.WifiManager;
import android.nfc.NfcManager;
@@ -37,9 +35,6 @@
import android.provider.Settings;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
-import android.telephony.SubscriptionInfo;
-import android.telephony.SubscriptionManager;
-import android.telephony.TelephonyManager;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
@@ -101,11 +96,7 @@
public class SetupActionsFragment extends SettingsPreferenceFragment
implements ItemListAdapter.OnItemClickListener {
- private static final int RINGTONE_REQUEST_CODE = 1000;
private static final int NEW_TRIGGER_REQUEST_CODE = 1001;
- private static final int SET_NETWORK_MODE_REQUEST_CODE = 1002;
-
- public static final String EXTRA_NETWORK_MODE_PICKED = "network_mode_picker::chosen_value";
private static final int MENU_REMOVE = Menu.FIRST;
private static final int MENU_FILL_PROFILE = Menu.FIRST + 1;
@@ -148,7 +139,7 @@
Profile.NotificationLightMode.ENABLE,
Profile.NotificationLightMode.DISABLE
};
- private List<Item> mItems = new ArrayList<Item>();
+ private final List<Item> mItems = new ArrayList<>();
public static SetupActionsFragment newInstance(Profile profile, boolean newProfile) {
SetupActionsFragment fragment = new SetupActionsFragment();
@@ -684,15 +675,6 @@
return builder.create();
}
- private void requestProfileRingMode() {
- // Launch the ringtone picker
- Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
- intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, false);
- intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true);
- intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_RINGTONE);
- startActivityForResult(intent, RINGTONE_REQUEST_CODE);
- }
-
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
@@ -804,11 +786,10 @@
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(VolumeStreamItem.getNameForStream(streamId));
- final AudioManager am = getActivity().getSystemService(AudioManager.class);
final LayoutInflater inflater = LayoutInflater.from(getActivity());
final View view = inflater.inflate(R.layout.dialog_profiles_volume_override, null);
- final SeekBar seekBar = (SeekBar) view.findViewById(R.id.seekbar);
- final CheckBox override = (CheckBox) view.findViewById(R.id.checkbox);
+ final SeekBar seekBar = view.findViewById(R.id.seekbar);
+ final CheckBox override = view.findViewById(R.id.checkbox);
override.setChecked(streamSettings.isOverride());
override.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
@@ -853,8 +834,8 @@
final LayoutInflater inflater = LayoutInflater.from(getActivity());
final View view = inflater.inflate(R.layout.dialog_profiles_brightness_override, null);
- final SeekBar seekBar = (SeekBar) view.findViewById(R.id.seekbar);
- final CheckBox override = (CheckBox) view.findViewById(R.id.checkbox);
+ final SeekBar seekBar = view.findViewById(R.id.seekbar);
+ final CheckBox override = view.findViewById(R.id.checkbox);
override.setChecked(brightnessSettings.isOverride());
override.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
@@ -891,7 +872,7 @@
LayoutInflater inflater = LayoutInflater.from(getActivity());
View dialogView = inflater.inflate(R.layout.profile_name_dialog, null);
- final EditText entry = (EditText) dialogView.findViewById(R.id.name);
+ final EditText entry = dialogView.findViewById(R.id.name);
entry.setText(mProfile.getName());
entry.setSelectAllOnFocus(true);
diff --git a/src/org/lineageos/lineageparts/profiles/SetupDefaultProfileReceiver.java b/src/org/lineageos/lineageparts/profiles/SetupDefaultProfileReceiver.java
deleted file mode 100644
index 06619ab..0000000
--- a/src/org/lineageos/lineageparts/profiles/SetupDefaultProfileReceiver.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2015 The CyanogenMod Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.lineageos.lineageparts.profiles;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-
-import lineageos.app.Profile;
-import lineageos.app.ProfileManager;
-import lineageos.providers.LineageSettings;
-
-import java.util.UUID;
-
-/*
-public class SetupDefaultProfileReceiver extends BroadcastReceiver {
-
- @Override
- public void onReceive(Context context, Intent intent) {
- if (LineageSettings.System.getInt(context.getContentResolver(),
- LineageSettings.System.SYSTEM_PROFILES_ENABLED, 1) == 1) {
- ProfileManager profileManager = ProfileManager.getInstance(context);
- Profile defaultProfile = profileManager.getProfile(
- UUID.fromString("0230226d-0d05-494a-a9bd-d222a1117655"));
- if (defaultProfile != null) {
- SetupActionsFragment.fillProfileWithCurrentSettings(context, defaultProfile);
- profileManager.updateProfile(defaultProfile);
- }
- }
- }
-}
-*/
diff --git a/src/org/lineageos/lineageparts/profiles/SetupTriggersFragment.java b/src/org/lineageos/lineageparts/profiles/SetupTriggersFragment.java
index e1d9233..cd9faf7 100644
--- a/src/org/lineageos/lineageparts/profiles/SetupTriggersFragment.java
+++ b/src/org/lineageos/lineageparts/profiles/SetupTriggersFragment.java
@@ -22,7 +22,6 @@
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
-import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -76,11 +75,6 @@
}
@Override
- public void onResume() {
- super.onResume();
- }
-
- @Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
final PartsActivity activity = (PartsActivity) getActivity();
@@ -114,7 +108,7 @@
View root = inflater.inflate(R.layout.fragment_setup_triggers, container, false);
mPager = (RtlCompatibleViewPager) root.findViewById(R.id.view_pager);
- mTabLayout = (SlidingTabLayout) root.findViewById(R.id.sliding_tabs);
+ mTabLayout = root.findViewById(R.id.sliding_tabs);
mAdapter = new TriggerPagerAdapter(getActivity(), getChildFragmentManager());
Bundle profileArgs = new Bundle();
diff --git a/src/org/lineageos/lineageparts/profiles/TriggerPagerAdapter.java b/src/org/lineageos/lineageparts/profiles/TriggerPagerAdapter.java
index 796478e..25dd1ae 100644
--- a/src/org/lineageos/lineageparts/profiles/TriggerPagerAdapter.java
+++ b/src/org/lineageos/lineageparts/profiles/TriggerPagerAdapter.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2014 The CyanogenMod Project
- * 2017,2019,2021 The LineageOS Project
+ * 2017-2022 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.
@@ -41,8 +41,7 @@
*/
public class TriggerPagerAdapter extends FragmentPagerAdapter {
- private final SparseArray<WeakReference<Fragment>> mFragmentArray =
- new SparseArray<WeakReference<Fragment>>();
+ private final SparseArray<WeakReference<Fragment>> mFragmentArray = new SparseArray<>();
private final List<Holder> mHolderList = Lists.newArrayList();
@@ -117,9 +116,8 @@
@Override
public Fragment getItem(final int position) {
final Holder mCurrentHolder = mHolderList.get(position);
- final Fragment mFragment = Fragment.instantiate(mFragmentActivity,
+ return Fragment.instantiate(mFragmentActivity,
mCurrentHolder.mClassName, mCurrentHolder.mParams);
- return mFragment;
}
/**
@@ -185,15 +183,15 @@
*/
NFC(NfcTriggerFragment.class, R.string.profile_tabs_nfc);
- private Class<? extends Fragment> mFragmentClass;
- private int mNameRes;
+ private final Class<? extends Fragment> mFragmentClass;
+ private final int mNameRes;
/**
* Constructor of <code>MusicFragments</code>
*
* @param fragmentClass The fragment class
*/
- private TriggerFragments(final Class<? extends Fragment> fragmentClass, int nameRes) {
+ TriggerFragments(final Class<? extends Fragment> fragmentClass, int nameRes) {
mFragmentClass = fragmentClass;
mNameRes = nameRes;
}
diff --git a/src/org/lineageos/lineageparts/profiles/actions/ItemListAdapter.java b/src/org/lineageos/lineageparts/profiles/actions/ItemListAdapter.java
index b3304ff..2ccece4 100644
--- a/src/org/lineageos/lineageparts/profiles/actions/ItemListAdapter.java
+++ b/src/org/lineageos/lineageparts/profiles/actions/ItemListAdapter.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2014 The CyanogenMod Project
- * 2020 The LineageOS Project
+ * 2020-2022 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.
@@ -30,9 +30,9 @@
public class ItemListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
implements View.OnClickListener {
- private LayoutInflater mInflater;
- private List<Item> mItems;
- private OnItemClickListener mItemClickListener;
+ private final LayoutInflater mInflater;
+ private final List<Item> mItems;
+ private final OnItemClickListener mItemClickListener;
public interface OnItemClickListener {
void onItemClick(Item item, int position);
@@ -107,8 +107,8 @@
}
public static class ItemViewHolder extends RecyclerView.ViewHolder {
- private TextView mTitleView;
- private TextView mSummaryView;
+ private final TextView mTitleView;
+ private final TextView mSummaryView;
private ItemViewHolder(View view) {
super(view);
diff --git a/src/org/lineageos/lineageparts/profiles/actions/item/AirplaneModeItem.java b/src/org/lineageos/lineageparts/profiles/actions/item/AirplaneModeItem.java
index fd6fc79..c909e6b 100644
--- a/src/org/lineageos/lineageparts/profiles/actions/item/AirplaneModeItem.java
+++ b/src/org/lineageos/lineageparts/profiles/actions/item/AirplaneModeItem.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2014 The CyanogenMod Project
- * 2020 The LineageOS Project
+ * 2020-2022 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.
@@ -23,7 +23,7 @@
import lineageos.profiles.AirplaneModeSettings;
public class AirplaneModeItem extends Item {
- AirplaneModeSettings mSettings;
+ private final AirplaneModeSettings mSettings;
public AirplaneModeItem(AirplaneModeSettings airplaneModeSettings) {
if (airplaneModeSettings == null) {
diff --git a/src/org/lineageos/lineageparts/profiles/actions/item/BrightnessItem.java b/src/org/lineageos/lineageparts/profiles/actions/item/BrightnessItem.java
index 1780d77..58241d5 100644
--- a/src/org/lineageos/lineageparts/profiles/actions/item/BrightnessItem.java
+++ b/src/org/lineageos/lineageparts/profiles/actions/item/BrightnessItem.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2015 The CyanogenMod Project
- * 2020 The LineageOS Project
+ * 2020-2022 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.
@@ -23,7 +23,7 @@
import lineageos.profiles.BrightnessSettings;
public class BrightnessItem extends Item {
- BrightnessSettings mSettings;
+ private final BrightnessSettings mSettings;
public BrightnessItem(BrightnessSettings brightnessSettings) {
if (brightnessSettings == null) {
diff --git a/src/org/lineageos/lineageparts/profiles/actions/item/ConnectionOverrideItem.java b/src/org/lineageos/lineageparts/profiles/actions/item/ConnectionOverrideItem.java
index 4a65f85..03ca87e 100644
--- a/src/org/lineageos/lineageparts/profiles/actions/item/ConnectionOverrideItem.java
+++ b/src/org/lineageos/lineageparts/profiles/actions/item/ConnectionOverrideItem.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2014 The CyanogenMod Project
- * 2020 The LineageOS Project
+ * 2020-2022 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,20 +17,15 @@
package org.lineageos.lineageparts.profiles.actions.item;
import android.content.Context;
-import android.telephony.SubscriptionManager;
import org.lineageos.lineageparts.R;
import lineageos.profiles.ConnectionSettings;
public class ConnectionOverrideItem extends Item {
- int mConnectionId;
- ConnectionSettings mConnectionSettings;
-
- public static final int Lineage_MODE_SYSTEM_DEFAULT = -1;
+ private final ConnectionSettings mConnectionSettings;
public ConnectionOverrideItem(int connectionId, ConnectionSettings settings) {
- mConnectionId = connectionId;
if (settings == null) {
settings = new ConnectionSettings(connectionId);
}
@@ -45,7 +40,7 @@
@Override
public String getSummary(Context context) {
int resId = R.string.profile_action_none;
- if (mConnectionSettings != null && mConnectionSettings.isOverride()) {
+ if (mConnectionSettings.isOverride()) {
if (mConnectionSettings.getValue() == 1) {
resId = R.string.profile_action_enable;
} else {
@@ -78,8 +73,4 @@
public ConnectionSettings getSettings() {
return mConnectionSettings;
}
-
- public int getConnectionType() {
- return mConnectionId;
- }
}
diff --git a/src/org/lineageos/lineageparts/profiles/actions/item/DisabledItem.java b/src/org/lineageos/lineageparts/profiles/actions/item/DisabledItem.java
index 6178c9e..aa8057e 100644
--- a/src/org/lineageos/lineageparts/profiles/actions/item/DisabledItem.java
+++ b/src/org/lineageos/lineageparts/profiles/actions/item/DisabledItem.java
@@ -17,9 +17,6 @@
package org.lineageos.lineageparts.profiles.actions.item;
import android.content.Context;
-import androidx.recyclerview.widget.RecyclerView;
-import android.view.LayoutInflater;
-import android.view.ViewGroup;
public class DisabledItem extends Item {
private final int mResTitle;
diff --git a/src/org/lineageos/lineageparts/profiles/actions/item/DozeModeItem.java b/src/org/lineageos/lineageparts/profiles/actions/item/DozeModeItem.java
index e1c8c7a..fe6f548 100644
--- a/src/org/lineageos/lineageparts/profiles/actions/item/DozeModeItem.java
+++ b/src/org/lineageos/lineageparts/profiles/actions/item/DozeModeItem.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2014 The CyanogenMod Project
- * 2020 The LineageOS Project
+ * 2020-2022 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.
@@ -23,7 +23,7 @@
import lineageos.app.Profile;
public class DozeModeItem extends Item {
- Profile mProfile;
+ private final Profile mProfile;
public DozeModeItem(Profile profile) {
mProfile = profile;
diff --git a/src/org/lineageos/lineageparts/profiles/actions/item/LockModeItem.java b/src/org/lineageos/lineageparts/profiles/actions/item/LockModeItem.java
index e27a343..81c9af5 100644
--- a/src/org/lineageos/lineageparts/profiles/actions/item/LockModeItem.java
+++ b/src/org/lineageos/lineageparts/profiles/actions/item/LockModeItem.java
@@ -23,7 +23,7 @@
import lineageos.app.Profile;
public class LockModeItem extends Item {
- Profile mProfile;
+ private final Profile mProfile;
public LockModeItem(Profile profile) {
mProfile = profile;
diff --git a/src/org/lineageos/lineageparts/profiles/actions/item/NotificationLightModeItem.java b/src/org/lineageos/lineageparts/profiles/actions/item/NotificationLightModeItem.java
index 044ffee..8bb35c3 100644
--- a/src/org/lineageos/lineageparts/profiles/actions/item/NotificationLightModeItem.java
+++ b/src/org/lineageos/lineageparts/profiles/actions/item/NotificationLightModeItem.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2014 The CyanogenMod Project
- * 2020 The LineageOS Project
+ * 2020-2022 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.
@@ -23,7 +23,7 @@
import lineageos.app.Profile;
public class NotificationLightModeItem extends Item {
- Profile mProfile;
+ private final Profile mProfile;
public NotificationLightModeItem(Profile profile) {
mProfile = profile;
diff --git a/src/org/lineageos/lineageparts/profiles/actions/item/ProfileNameItem.java b/src/org/lineageos/lineageparts/profiles/actions/item/ProfileNameItem.java
index 70bd551..5d8e324 100644
--- a/src/org/lineageos/lineageparts/profiles/actions/item/ProfileNameItem.java
+++ b/src/org/lineageos/lineageparts/profiles/actions/item/ProfileNameItem.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2014 The CyanogenMod Project
- * 2020 The LineageOS Project
+ * 2020-2022 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.
@@ -21,7 +21,7 @@
import lineageos.app.Profile;
public class ProfileNameItem extends Item {
- Profile mProfile;
+ private final Profile mProfile;
public ProfileNameItem(Profile profile) {
mProfile = profile;
diff --git a/src/org/lineageos/lineageparts/profiles/actions/item/RingModeItem.java b/src/org/lineageos/lineageparts/profiles/actions/item/RingModeItem.java
index 0a36982..9460503 100644
--- a/src/org/lineageos/lineageparts/profiles/actions/item/RingModeItem.java
+++ b/src/org/lineageos/lineageparts/profiles/actions/item/RingModeItem.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2014 The CyanogenMod Project
- * 2020 The LineageOS Project
+ * 2020-2022 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.
@@ -23,7 +23,7 @@
import lineageos.profiles.RingModeSettings;
public class RingModeItem extends Item {
- RingModeSettings mSettings;
+ private final RingModeSettings mSettings;
public RingModeItem(RingModeSettings ringModeSettings) {
if (ringModeSettings == null) {
diff --git a/src/org/lineageos/lineageparts/profiles/actions/item/TriggerItem.java b/src/org/lineageos/lineageparts/profiles/actions/item/TriggerItem.java
index a50c72d..8757b4d 100644
--- a/src/org/lineageos/lineageparts/profiles/actions/item/TriggerItem.java
+++ b/src/org/lineageos/lineageparts/profiles/actions/item/TriggerItem.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2014 The CyanogenMod Project
- * 2020 The LineageOS Project
+ * 2020-2022 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.
@@ -31,8 +31,8 @@
// not in Profile.TriggerType, but we need it.
public static final int NFC = 2;
- Profile mProfile;
- int mTriggerType;
+ private final Profile mProfile;
+ private final int mTriggerType;
public TriggerItem(Profile profile, int whichTrigger) {
mProfile = profile;
diff --git a/src/org/lineageos/lineageparts/profiles/actions/item/VolumeStreamItem.java b/src/org/lineageos/lineageparts/profiles/actions/item/VolumeStreamItem.java
index e3ece1d..6501494 100644
--- a/src/org/lineageos/lineageparts/profiles/actions/item/VolumeStreamItem.java
+++ b/src/org/lineageos/lineageparts/profiles/actions/item/VolumeStreamItem.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2014 The CyanogenMod Project
- * 2020 The LineageOS Project
+ * 2020-2022 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.
@@ -25,8 +25,8 @@
import lineageos.profiles.StreamSettings;
public class VolumeStreamItem extends Item {
- private int mStreamId;
- private StreamSettings mStreamSettings;
+ private final int mStreamId;
+ private final StreamSettings mStreamSettings;
public VolumeStreamItem(int streamId, StreamSettings streamSettings) {
mStreamId = streamId;
diff --git a/src/org/lineageos/lineageparts/profiles/triggers/AbstractTriggerListFragment.java b/src/org/lineageos/lineageparts/profiles/triggers/AbstractTriggerListFragment.java
index 5ab9689..76d4013 100644
--- a/src/org/lineageos/lineageparts/profiles/triggers/AbstractTriggerListFragment.java
+++ b/src/org/lineageos/lineageparts/profiles/triggers/AbstractTriggerListFragment.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2021 The LineageOS Project
+ * Copyright (C) 2020-2022 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.
@@ -16,7 +16,6 @@
package org.lineageos.lineageparts.profiles.triggers;
-import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
@@ -45,13 +44,13 @@
private ProfileManager mProfileManager;
private Profile mProfile;
- private List<AbstractTriggerItem> mTriggers = new ArrayList<>();
+ private final List<AbstractTriggerItem> mTriggers = new ArrayList<>();
private View mEmptyView;
private RecyclerView mRecyclerView;
private TriggerAdapter mAdapter;
- private TriggerAdapter.ItemClickListener mItemClickListener = item -> {
+ private final TriggerAdapter.ItemClickListener mItemClickListener = item -> {
final Resources res = getResources();
final String[] possibleEntries = res.getStringArray(getOptionArrayResId());
final String[] possibleValues = res.getStringArray(getOptionValuesArrayResId());
@@ -183,9 +182,9 @@
}
private static class TriggerViewHolder extends RecyclerView.ViewHolder {
- private TextView mTitleView;
- private TextView mDescView;
- private ImageView mIconView;
+ private final TextView mTitleView;
+ private final TextView mDescView;
+ private final ImageView mIconView;
public TriggerViewHolder(View view) {
super(view);
diff --git a/src/org/lineageos/lineageparts/profiles/triggers/BluetoothTriggerFragment.java b/src/org/lineageos/lineageparts/profiles/triggers/BluetoothTriggerFragment.java
index 9ca9929..f67915c 100644
--- a/src/org/lineageos/lineageparts/profiles/triggers/BluetoothTriggerFragment.java
+++ b/src/org/lineageos/lineageparts/profiles/triggers/BluetoothTriggerFragment.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2014 The CyanogenMod Project
- * 2020 The LineageOS Project
+ * 2020-2022 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,7 +20,6 @@
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.content.Intent;
-import android.content.res.Resources;
import android.os.Bundle;
import android.provider.Settings;
@@ -48,7 +47,6 @@
@Override
protected void onLoadTriggers(Profile profile, List<AbstractTriggerItem> triggers) {
- final Resources res = getResources();
final Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
if (!pairedDevices.isEmpty()) {
@@ -107,7 +105,7 @@
}
public static class BluetoothTrigger extends AbstractTriggerItem {
- private String mAddress;
+ private final String mAddress;
public BluetoothTrigger(BluetoothDevice device) {
mAddress = device.getAddress();
diff --git a/src/org/lineageos/lineageparts/profiles/triggers/NfcTriggerFragment.java b/src/org/lineageos/lineageparts/profiles/triggers/NfcTriggerFragment.java
index cf4a820..60b3df3 100644
--- a/src/org/lineageos/lineageparts/profiles/triggers/NfcTriggerFragment.java
+++ b/src/org/lineageos/lineageparts/profiles/triggers/NfcTriggerFragment.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2014 The CyanogenMod Project
- * 2017,2021 The LineageOS Project
+ * 2017,2021-2022 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.
@@ -42,7 +42,6 @@
Profile mProfile;
private NfcAdapter mNfcAdapter;
- private IntentFilter[] mWriteTagFilters;
public static NfcTriggerFragment newInstance(Profile profile) {
NfcTriggerFragment fragment = new NfcTriggerFragment();
@@ -100,8 +99,8 @@
private void enableTagWriteMode() {
IntentFilter tagDetected = new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED);
- mWriteTagFilters = new IntentFilter[] {
- tagDetected
+ IntentFilter[] writeTagFilters = new IntentFilter[]{
+ tagDetected
};
mNfcAdapter.enableForegroundDispatch(getActivity(), getPendingIntent(), writeTagFilters,
null);
diff --git a/src/org/lineageos/lineageparts/profiles/triggers/WifiTriggerFragment.java b/src/org/lineageos/lineageparts/profiles/triggers/WifiTriggerFragment.java
index 049930f..b068285 100644
--- a/src/org/lineageos/lineageparts/profiles/triggers/WifiTriggerFragment.java
+++ b/src/org/lineageos/lineageparts/profiles/triggers/WifiTriggerFragment.java
@@ -17,7 +17,6 @@
package org.lineageos.lineageparts.profiles.triggers;
import android.content.Intent;
-import android.content.res.Resources;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.os.Bundle;
@@ -47,7 +46,6 @@
@Override
protected void onLoadTriggers(Profile profile, List<AbstractTriggerItem> triggers) {
- final Resources res = getResources();
final List<WifiConfiguration> configs = mWifiManager.getConfiguredNetworks();
final HashSet<String> alreadyAdded = new HashSet<>();
diff --git a/src/org/lineageos/lineageparts/search/LineagePartsSearchIndexablesProvider.java b/src/org/lineageos/lineageparts/search/LineagePartsSearchIndexablesProvider.java
index 6c05721..0c191a7 100644
--- a/src/org/lineageos/lineageparts/search/LineagePartsSearchIndexablesProvider.java
+++ b/src/org/lineageos/lineageparts/search/LineagePartsSearchIndexablesProvider.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2016 The CyanogenMod Project
+ * Copyright (C) 2022 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.
@@ -209,7 +210,7 @@
return null;
}
- if (clazz == null || !Searchable.class.isAssignableFrom(clazz)) {
+ if (!Searchable.class.isAssignableFrom(clazz)) {
return null;
}
diff --git a/src/org/lineageos/lineageparts/search/Searchable.java b/src/org/lineageos/lineageparts/search/Searchable.java
index 03b27c8..637f82c 100644
--- a/src/org/lineageos/lineageparts/search/Searchable.java
+++ b/src/org/lineageos/lineageparts/search/Searchable.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2016 The CyanogenMod Project
+ * Copyright (C) 2022 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.
@@ -32,10 +33,10 @@
*/
public interface Searchable {
- public interface SearchIndexProvider {
+ interface SearchIndexProvider {
- public List<SearchIndexableRaw> getRawDataToIndex(Context context);
+ List<SearchIndexableRaw> getRawDataToIndex(Context context);
- public Set<String> getNonIndexableKeys(Context context);
+ Set<String> getNonIndexableKeys(Context context);
}
}
diff --git a/src/org/lineageos/lineageparts/statusbar/StatusBarSettings.java b/src/org/lineageos/lineageparts/statusbar/StatusBarSettings.java
index 7078dca..cbb63b4 100644
--- a/src/org/lineageos/lineageparts/statusbar/StatusBarSettings.java
+++ b/src/org/lineageos/lineageparts/statusbar/StatusBarSettings.java
@@ -64,7 +64,6 @@
private LineageSystemSettingListPreference mQuickPulldown;
private LineageSystemSettingListPreference mStatusBarClock;
private LineageSystemSettingListPreference mStatusBarAmPm;
- private LineageSystemSettingListPreference mStatusBarBattery;
private LineageSystemSettingListPreference mStatusBarBatteryShowPercent;
private PreferenceCategory mStatusBarBatteryCategory;
@@ -92,9 +91,10 @@
mStatusBarClockCategory = getPreferenceScreen().findPreference(CATEGORY_CLOCK);
mStatusBarBatteryShowPercent = findPreference(STATUS_BAR_SHOW_BATTERY_PERCENT);
- mStatusBarBattery = findPreference(STATUS_BAR_BATTERY_STYLE);
- mStatusBarBattery.setOnPreferenceChangeListener(this);
- enableStatusBarBatteryDependents(mStatusBarBattery.getIntValue(2));
+ LineageSystemSettingListPreference statusBarBattery =
+ findPreference(STATUS_BAR_BATTERY_STYLE);
+ statusBarBattery.setOnPreferenceChangeListener(this);
+ enableStatusBarBatteryDependents(statusBarBattery.getIntValue(2));
mStatusBarBatteryCategory = getPreferenceScreen().findPreference(CATEGORY_BATTERY);
diff --git a/src/org/lineageos/lineageparts/trust/TrustPreferences.java b/src/org/lineageos/lineageparts/trust/TrustPreferences.java
index 7540e58..a38b395 100644
--- a/src/org/lineageos/lineageparts/trust/TrustPreferences.java
+++ b/src/org/lineageos/lineageparts/trust/TrustPreferences.java
@@ -20,7 +20,6 @@
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.provider.Settings;
-import android.util.Log;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.ListPreference;
@@ -45,14 +44,11 @@
private LineageGlobalSettingListPreference mUsbRestrictorPref;
private ListPreference mSmsLimitPref;
- private PreferenceCategory mWarnScreen;
private SwitchPreference mWarnSELinuxPref;
private SwitchPreference mWarnKeysPref;
private TrustInterface mInterface;
- private int[] mSecurityLevel = new int[4];
-
@Override
public void onCreate(Bundle savedInstance) {
super.onCreate(savedInstance);
@@ -68,9 +64,9 @@
mUsbRestrictorPref = mToolsCategory.findPreference("trust_restrict_usb");
mSmsLimitPref = mToolsCategory.findPreference("sms_security_check_limit");
- mWarnScreen = findPreference("trust_category_warnings");
- mWarnSELinuxPref = mWarnScreen.findPreference("trust_warning_selinux");
- mWarnKeysPref = mWarnScreen.findPreference("trust_warning_keys");
+ PreferenceCategory warnScreen = findPreference("trust_category_warnings");
+ mWarnSELinuxPref = warnScreen.findPreference("trust_warning_selinux");
+ mWarnKeysPref = warnScreen.findPreference("trust_warning_keys");
mSELinuxPref.setOnPreferenceClickListener(p ->
showInfo(R.string.trust_feature_selinux_explain));
diff --git a/src/org/lineageos/lineageparts/utils/DeviceUtils.java b/src/org/lineageos/lineageparts/utils/DeviceUtils.java
index e0eb7a5..4a53445 100644
--- a/src/org/lineageos/lineageparts/utils/DeviceUtils.java
+++ b/src/org/lineageos/lineageparts/utils/DeviceUtils.java
@@ -21,7 +21,6 @@
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
-import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageInfo;
@@ -32,11 +31,9 @@
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraManager;
-import android.net.ConnectivityManager;
import android.nfc.NfcAdapter;
import android.os.Build;
import android.os.SystemProperties;
-import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.telephony.SubscriptionManager;
import android.text.TextUtils;
diff --git a/src/org/lineageos/lineageparts/widget/DialogCreatable.java b/src/org/lineageos/lineageparts/widget/DialogCreatable.java
index 31fc350..a725bea 100644
--- a/src/org/lineageos/lineageparts/widget/DialogCreatable.java
+++ b/src/org/lineageos/lineageparts/widget/DialogCreatable.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2010 The Android Open Source Project
+ * Copyright (C) 2022 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.
@@ -27,5 +28,5 @@
*/
public interface DialogCreatable {
- public Dialog onCreateDialog(int dialogId);
+ Dialog onCreateDialog(int dialogId);
}
diff --git a/src/org/lineageos/lineageparts/widget/HighlightablePreferenceGroupAdapter.java b/src/org/lineageos/lineageparts/widget/HighlightablePreferenceGroupAdapter.java
index 426799e..3e3975f 100644
--- a/src/org/lineageos/lineageparts/widget/HighlightablePreferenceGroupAdapter.java
+++ b/src/org/lineageos/lineageparts/widget/HighlightablePreferenceGroupAdapter.java
@@ -17,15 +17,12 @@
package org.lineageos.lineageparts.widget;
-import static org.lineageos.lineageparts.PartsActivity.EXTRA_FRAGMENT_ARG_KEY;
-
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ArgbEvaluator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Color;
-import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.util.TypedValue;
@@ -39,7 +36,6 @@
import androidx.recyclerview.widget.RecyclerView;
import org.lineageos.lineageparts.R;
-import org.lineageos.lineageparts.SettingsPreferenceFragment;
public class HighlightablePreferenceGroupAdapter extends PreferenceGroupAdapter {
@@ -128,10 +124,8 @@
return;
}
mFadeInAnimated = true;
- final int colorFrom = Color.WHITE;
- final int colorTo = mHighlightColor;
final ValueAnimator fadeInLoop = ValueAnimator.ofObject(
- new ArgbEvaluator(), colorFrom, colorTo);
+ new ArgbEvaluator(), Color.WHITE, mHighlightColor);
fadeInLoop.setDuration(HIGHLIGHT_FADE_IN_DURATION);
fadeInLoop.addUpdateListener(
animator -> v.setBackgroundColor((int) animator.getAnimatedValue()));
@@ -155,12 +149,10 @@
Log.d(TAG, "RemoveHighlight: Not highlighted - skipping");
return;
}
- int colorFrom = mHighlightColor;
- int colorTo = Color.WHITE;
v.setTag(R.id.preference_highlighted, false);
final ValueAnimator colorAnimation = ValueAnimator.ofObject(
- new ArgbEvaluator(), colorFrom, colorTo);
+ new ArgbEvaluator(), mHighlightColor, Color.WHITE);
colorAnimation.setDuration(HIGHLIGHT_FADE_OUT_DURATION);
colorAnimation.addUpdateListener(
animator -> v.setBackgroundColor((int) animator.getAnimatedValue()));
diff --git a/src/org/lineageos/lineageparts/widget/IntervalSeekBar.java b/src/org/lineageos/lineageparts/widget/IntervalSeekBar.java
index 2435df4..6bc6682 100644
--- a/src/org/lineageos/lineageparts/widget/IntervalSeekBar.java
+++ b/src/org/lineageos/lineageparts/widget/IntervalSeekBar.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2016 The CyanogenMod Project
- * 2017 The LineageOS Project
+ * 2017-2022 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.
@@ -31,8 +31,8 @@
public class IntervalSeekBar extends SeekBar {
private float mMin;
private float mMax;
- private float mDefault;
- private float mMultiplier;
+ private final float mDefault;
+ private final float mMultiplier;
public IntervalSeekBar(Context context, AttributeSet attrs) {
super(context, attrs);
diff --git a/src/org/lineageos/lineageparts/widget/PackageListAdapter.java b/src/org/lineageos/lineageparts/widget/PackageListAdapter.java
index d938dbc..e9ca3f9 100644
--- a/src/org/lineageos/lineageparts/widget/PackageListAdapter.java
+++ b/src/org/lineageos/lineageparts/widget/PackageListAdapter.java
@@ -44,9 +44,9 @@
import java.util.TreeSet;
public class PackageListAdapter extends BaseAdapter implements Runnable {
- private PackageManager mPm;
- private LayoutInflater mInflater;
- private List<PackageItem> mInstalledPackages = new LinkedList<PackageItem>();
+ private final PackageManager mPm;
+ private final LayoutInflater mInflater;
+ private final List<PackageItem> mInstalledPackages = new LinkedList<>();
private Set<String> mExcludedPackages = new HashSet<>();
// Packages which don't have launcher icons, but which we want to show nevertheless
@@ -73,7 +73,7 @@
public static class PackageItem implements Comparable<PackageItem> {
public final String packageName;
public final CharSequence title;
- private final TreeSet<CharSequence> activityTitles = new TreeSet<CharSequence>();
+ private final TreeSet<CharSequence> activityTitles = new TreeSet<>();
public final Drawable icon;
PackageItem(String packageName, CharSequence title, Drawable icon) {
@@ -126,9 +126,9 @@
convertView = mInflater.inflate(R.layout.preference_icon, null, false);
holder = new ViewHolder();
convertView.setTag(holder);
- holder.title = (TextView) convertView.findViewById(com.android.internal.R.id.title);
- holder.summary = (TextView) convertView.findViewById(com.android.internal.R.id.summary);
- holder.icon = (ImageView) convertView.findViewById(com.android.internal.R.id.icon);
+ holder.title = convertView.findViewById(com.android.internal.R.id.title);
+ holder.summary = convertView.findViewById(com.android.internal.R.id.summary);
+ holder.icon = convertView.findViewById(com.android.internal.R.id.icon);
}
PackageItem applicationInfo = getItem(position);
diff --git a/src/org/lineageos/lineageparts/widget/SlidingTabLayout.java b/src/org/lineageos/lineageparts/widget/SlidingTabLayout.java
index 778f67e..0be46ce 100644
--- a/src/org/lineageos/lineageparts/widget/SlidingTabLayout.java
+++ b/src/org/lineageos/lineageparts/widget/SlidingTabLayout.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2016 The Android Open Source Project
- * 2020 The LineageOS Project
+ * 2020-2022 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.
@@ -162,7 +162,7 @@
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
final int titleCount = mTitleView.getChildCount();
- if ((titleCount == 0) || (position < 0) || (position >= titleCount)) {
+ if (position < 0 || position >= titleCount) {
return;
}
onViewPagerPageChanged(position, positionOffset);