summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Bestas <mkbestas@lineageos.org>2022-02-07 16:29:24 +0200
committerMichael Bestas <mkbestas@lineageos.org>2022-02-07 16:30:05 +0200
commitd6b3c917d685888e353d01a05830e23a34418dfe (patch)
tree6dcd8e07b72038e1e149c06df0cffc7c7c1d1567
parent5f2f98387e910dc45d506fc1db9855764b83ace3 (diff)
AudioFX: Code style cleanup
* Format with AOSP code style in Android Studio Change-Id: I3d5e2f467347561009b98251a2e3ba04d9870079
-rw-r--r--src/org/lineageos/audiofx/AudioFxApplication.java1
-rw-r--r--src/org/lineageos/audiofx/Compatibility.java50
-rw-r--r--src/org/lineageos/audiofx/Constants.java10
-rw-r--r--src/org/lineageos/audiofx/Preset.java3
-rw-r--r--src/org/lineageos/audiofx/activity/ActivityMusic.java25
-rw-r--r--src/org/lineageos/audiofx/activity/ControlPanelPicker.java46
-rw-r--r--src/org/lineageos/audiofx/activity/EqualizerManager.java47
-rw-r--r--src/org/lineageos/audiofx/activity/MasterConfigControl.java32
-rw-r--r--src/org/lineageos/audiofx/activity/StateCallbacks.java32
-rw-r--r--src/org/lineageos/audiofx/backends/EffectSet.java69
-rw-r--r--src/org/lineageos/audiofx/backends/EffectSetWithAndroidEq.java2
-rw-r--r--src/org/lineageos/audiofx/backends/EffectsFactory.java4
-rw-r--r--src/org/lineageos/audiofx/backends/IEffectFactory.java5
-rw-r--r--src/org/lineageos/audiofx/eq/EqBarView.java5
-rw-r--r--src/org/lineageos/audiofx/eq/EqContainerView.java27
-rw-r--r--src/org/lineageos/audiofx/eq/EqSwipeController.java13
-rw-r--r--src/org/lineageos/audiofx/fragment/AudioFxBaseFragment.java9
-rw-r--r--src/org/lineageos/audiofx/fragment/AudioFxFragment.java10
-rw-r--r--src/org/lineageos/audiofx/fragment/ControlsFragment.java50
-rw-r--r--src/org/lineageos/audiofx/fragment/EqualizerFragment.java287
-rw-r--r--src/org/lineageos/audiofx/knobs/KnobCommander.java130
-rw-r--r--src/org/lineageos/audiofx/knobs/KnobContainer.java17
-rw-r--r--src/org/lineageos/audiofx/knobs/RadialKnob.java38
-rw-r--r--src/org/lineageos/audiofx/preset/InfinitePagerAdapter.java4
-rw-r--r--src/org/lineageos/audiofx/preset/InfiniteViewPager.java4
-rw-r--r--src/org/lineageos/audiofx/preset/PresetPagerAdapter.java1
-rw-r--r--src/org/lineageos/audiofx/receiver/ServiceDispatcher.java2
-rw-r--r--src/org/lineageos/audiofx/service/AudioFxService.java31
-rw-r--r--src/org/lineageos/audiofx/service/AudioOutputChangeListener.java11
-rw-r--r--src/org/lineageos/audiofx/service/DevicePreferenceManager.java19
-rw-r--r--src/org/lineageos/audiofx/service/SessionManager.java44
-rw-r--r--src/org/lineageos/audiofx/viewpagerindicator/CirclePageIndicator.java60
-rw-r--r--src/org/lineageos/audiofx/viewpagerindicator/PageIndicator.java4
-rw-r--r--src/org/lineageos/audiofx/widget/Biquad.java14
-rw-r--r--src/org/lineageos/audiofx/widget/EqualizerSurface.java99
35 files changed, 644 insertions, 561 deletions
diff --git a/src/org/lineageos/audiofx/AudioFxApplication.java b/src/org/lineageos/audiofx/AudioFxApplication.java
index 7079ee8..93b1c58 100644
--- a/src/org/lineageos/audiofx/AudioFxApplication.java
+++ b/src/org/lineageos/audiofx/AudioFxApplication.java
@@ -16,7 +16,6 @@
package org.lineageos.audiofx;
import android.app.Application;
-import android.util.Log;
public class AudioFxApplication extends Application {
diff --git a/src/org/lineageos/audiofx/Compatibility.java b/src/org/lineageos/audiofx/Compatibility.java
index e78d154..28c87ac 100644
--- a/src/org/lineageos/audiofx/Compatibility.java
+++ b/src/org/lineageos/audiofx/Compatibility.java
@@ -30,19 +30,17 @@ import android.media.audiofx.AudioEffect;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
+
import org.lineageos.audiofx.activity.ActivityMusic;
import java.util.List;
/**
- * Provide backwards compatibility for existing control panels.
- * There are two major parts to this:
- * - a BroadcastReceiver that listens for installed or removed packages, and
- * enables or disables control panel receivers as needed to ensure that only
- * one control panel package will receive the broadcasts that applications end
- * - a high priority control panel activity that redirects to the currently
- * selected control panel activity
- *
+ * Provide backwards compatibility for existing control panels. There are two major parts to this: -
+ * a BroadcastReceiver that listens for installed or removed packages, and enables or disables
+ * control panel receivers as needed to ensure that only one control panel package will receive the
+ * broadcasts that applications end - a high priority control panel activity that redirects to the
+ * currently selected control panel activity
*/
public class Compatibility {
@@ -52,9 +50,8 @@ public class Compatibility {
/**
- * This activity has an intent filter with the highest possible priority, so
- * it will always be chosen. It then looks up the correct control panel to
- * use and launches that.
+ * This activity has an intent filter with the highest possible priority, so it will always be
+ * chosen. It then looks up the correct control panel to use and launches that.
*/
public static class Redirector extends Activity {
@@ -88,13 +85,11 @@ public class Compatibility {
}
/**
- * This BroadcastReceiver responds to BOOT_COMPLETED, PACKAGE_ADDED,
- * PACKAGE_REPLACED and PACKAGE_REMOVED intents. When run, it checks
- * to see whether the active control panel needs to be updated:
- * - if there is no default, it picks one
- * - if a new control panel is installed, it becomes the default
- * It then enables the open/close receivers in the active control panel,
- * and disables them in the others.
+ * This BroadcastReceiver responds to BOOT_COMPLETED, PACKAGE_ADDED, PACKAGE_REPLACED and
+ * PACKAGE_REMOVED intents. When run, it checks to see whether the active control panel needs to
+ * be updated: - if there is no default, it picks one - if a new control panel is installed, it
+ * becomes the default It then enables the open/close receivers in the active control panel, and
+ * disables them in the others.
*/
public static class Receiver extends BroadcastReceiver {
@@ -150,13 +145,14 @@ public class Compatibility {
ResolveInfo otherPanel = null;
ResolveInfo thisPanel = null;
Intent i = new Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL);
- List<ResolveInfo> ris = mPackageManager.queryIntentActivities(i, PackageManager.GET_DISABLED_COMPONENTS);
+ List<ResolveInfo> ris = mPackageManager.queryIntentActivities(i,
+ PackageManager.GET_DISABLED_COMPONENTS);
log("found: " + ris.size());
SharedPreferences pref = Constants.getMusicFxPrefs(this);
String savedDefPackage = pref.getString(Constants.MUSICFX_DEFAULT_PACKAGE_KEY, null);
String savedDefName = pref.getString(Constants.MUSICFX_DEFAULT_PANEL_KEY, null);
log("saved default: " + savedDefName);
- for (ResolveInfo foo: ris) {
+ for (ResolveInfo foo : ris) {
if (foo.activityInfo.name.equals(Compatibility.Redirector.class.getName())) {
log("skipping " + foo);
continue;
@@ -171,7 +167,8 @@ public class Compatibility {
} else if (foo.activityInfo.packageName.equals(updatedPackage)) {
log("choosing newly installed package " + updatedPackage);
otherPanel = foo;
- } else if (otherPanel == null && !foo.activityInfo.packageName.equals(getPackageName())) {
+ } else if (otherPanel == null && !foo.activityInfo.packageName.equals(
+ getPackageName())) {
otherPanel = foo;
} else {
thisPanel = foo;
@@ -200,11 +197,13 @@ public class Compatibility {
private void setDefault(String defPackage, String defName) {
Intent i = new Intent(AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION);
- List<ResolveInfo> ris = mPackageManager.queryBroadcastReceivers(i, PackageManager.GET_DISABLED_COMPONENTS);
+ List<ResolveInfo> ris = mPackageManager.queryBroadcastReceivers(i,
+ PackageManager.GET_DISABLED_COMPONENTS);
setupReceivers(ris, defPackage);
// The open and close receivers are likely the same, but they may not be.
i = new Intent(AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION);
- ris = mPackageManager.queryBroadcastReceivers(i, PackageManager.GET_DISABLED_COMPONENTS);
+ ris = mPackageManager.queryBroadcastReceivers(i,
+ PackageManager.GET_DISABLED_COMPONENTS);
setupReceivers(ris, defPackage);
// Write the selected default to the prefs so that the Redirector activity
@@ -222,8 +221,9 @@ public class Compatibility {
// broadcast to newly enabled receivers, while sending "close session" to
// receivers that are about to be disabled. We could also consider just
// killing the process hosting the disabled components.
- for (ResolveInfo foo: ris) {
- ComponentName comp = new ComponentName(foo.activityInfo.packageName, foo.activityInfo.name);
+ for (ResolveInfo foo : ris) {
+ ComponentName comp = new ComponentName(foo.activityInfo.packageName,
+ foo.activityInfo.name);
if (foo.activityInfo.packageName.equals(defPackage)) {
log("enabling receiver " + foo);
mPackageManager.setComponentEnabledSetting(comp,
diff --git a/src/org/lineageos/audiofx/Constants.java b/src/org/lineageos/audiofx/Constants.java
index d5a0253..5410bd5 100644
--- a/src/org/lineageos/audiofx/Constants.java
+++ b/src/org/lineageos/audiofx/Constants.java
@@ -17,6 +17,7 @@ package org.lineageos.audiofx;
import android.content.Context;
import android.content.SharedPreferences;
+
import org.lineageos.audiofx.eq.EqUtils;
import java.util.ArrayList;
@@ -108,7 +109,8 @@ public class Constants {
}
public static void saveCustomPresets(Context ctx, List<Preset> presets) {
- final SharedPreferences.Editor presetPrefs = ctx.getSharedPreferences("custom_presets", 0).edit();
+ final SharedPreferences.Editor presetPrefs = ctx.getSharedPreferences("custom_presets",
+ 0).edit();
presetPrefs.clear();
StringBuffer presetNames = new StringBuffer();
@@ -132,7 +134,8 @@ public class Constants {
}
public static int[] getBandLevelRange(Context context) {
- String savedCenterFreqs = context.getSharedPreferences("global", 0).getString("equalizer.band_level_range", null);
+ String savedCenterFreqs = context.getSharedPreferences("global", 0).getString(
+ "equalizer.band_level_range", null);
if (savedCenterFreqs == null || savedCenterFreqs.isEmpty()) {
return new int[]{-1500, 1500};
} else {
@@ -146,7 +149,8 @@ public class Constants {
}
public static int[] getCenterFreqs(Context context, int eqBands) {
- String savedCenterFreqs = context.getSharedPreferences("global", 0).getString("equalizer.center_freqs",
+ String savedCenterFreqs = context.getSharedPreferences("global", 0).getString(
+ "equalizer.center_freqs",
EqUtils.getZeroedBandsString(eqBands));
String[] split = savedCenterFreqs.split(";");
int[] freqs = new int[split.length];
diff --git a/src/org/lineageos/audiofx/Preset.java b/src/org/lineageos/audiofx/Preset.java
index 5d3c0ba..64f2df1 100644
--- a/src/org/lineageos/audiofx/Preset.java
+++ b/src/org/lineageos/audiofx/Preset.java
@@ -17,6 +17,7 @@ package org.lineageos.audiofx;
import android.os.Parcel;
import android.os.Parcelable;
+
import org.lineageos.audiofx.eq.EqUtils;
public class Preset implements Parcelable {
@@ -63,7 +64,7 @@ public class Preset implements Parcelable {
return false;
}
- for(int i = 0; i < mLevels.length; i++) {
+ for (int i = 0; i < mLevels.length; i++) {
if (mLevels[i] != other.mLevels[i]) {
return false;
}
diff --git a/src/org/lineageos/audiofx/activity/ActivityMusic.java b/src/org/lineageos/audiofx/activity/ActivityMusic.java
index f467c2c..2e996b9 100644
--- a/src/org/lineageos/audiofx/activity/ActivityMusic.java
+++ b/src/org/lineageos/audiofx/activity/ActivityMusic.java
@@ -28,11 +28,10 @@ import android.view.View;
import android.view.ViewStub;
import android.widget.CompoundButton;
import android.widget.Switch;
-import org.lineageos.audiofx.AudioFxApplication;
+
import org.lineageos.audiofx.Constants;
import org.lineageos.audiofx.R;
import org.lineageos.audiofx.fragment.AudioFxFragment;
-import org.lineageos.audiofx.knobs.KnobCommander;
import org.lineageos.audiofx.service.AudioFxService;
import org.lineageos.audiofx.service.DevicePreferenceManager;
@@ -51,20 +50,21 @@ public class ActivityMusic extends Activity {
private boolean mWaitingForService = true;
private SharedPreferences.OnSharedPreferenceChangeListener mServiceReadyObserver;
- private CompoundButton.OnCheckedChangeListener mGlobalEnableToggleListener
+ private final CompoundButton.OnCheckedChangeListener mGlobalEnableToggleListener
= new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(final CompoundButton buttonView,
- final boolean isChecked) {
+ final boolean isChecked) {
mConfig.setCurrentDeviceEnabled(isChecked);
}
};
@Override
public void onCreate(final Bundle savedInstanceState) {
- if (DEBUG)
+ if (DEBUG) {
Log.i(TAG, "onCreate() called with "
+ "savedInstanceState = [" + savedInstanceState + "]");
+ }
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
@@ -81,7 +81,7 @@ public class ActivityMusic extends Activity {
mServiceReadyObserver = new SharedPreferences.OnSharedPreferenceChangeListener() {
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
- String key) {
+ String key) {
if (key.equals(Constants.SAVED_DEFAULTS) && defaultsSetup()) {
sharedPreferences.unregisterOnSharedPreferenceChangeListener(this);
mConfig.onResetDefaults();
@@ -112,7 +112,8 @@ public class ActivityMusic extends Activity {
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
- // should null it out if one was there, compat redirector with package will go through onCreate
+ // should null it out if one was there, compat redirector with package will go through
+ // onCreate
mCallingPackage = intent.getStringExtra(EXTRA_CALLING_PACKAGE);
}
@@ -140,7 +141,7 @@ public class ActivityMusic extends Activity {
ab.setCustomView(extraView, lp);
ab.setDisplayShowCustomEnabled(true);
- mCurrentDeviceToggle = (Switch) ab.getCustomView().findViewById(R.id.global_toggle);
+ mCurrentDeviceToggle = ab.getCustomView().findViewById(R.id.global_toggle);
mCurrentDeviceToggle.setOnCheckedChangeListener(mGlobalEnableToggleListener);
if (savedInstanceState == null && findViewById(R.id.main_fragment) != null) {
@@ -157,7 +158,7 @@ public class ActivityMusic extends Activity {
if (mConfig.hasMaxxAudio()) {
ab.setSubtitle(R.string.powered_by_maxx_audio);
} else if (mConfig.hasDts()) {
- final ViewStub stub = (ViewStub) ab.getCustomView().findViewById(R.id.logo_stub);
+ final ViewStub stub = ab.getCustomView().findViewById(R.id.logo_stub);
stub.setLayoutResource(R.layout.action_bar_dts_logo);
stub.inflate();
}
@@ -166,8 +167,10 @@ public class ActivityMusic extends Activity {
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
- if (DEBUG) Log.i(TAG, "onConfigurationChanged() called with "
- + "newConfig = [" + newConfig + "]");
+ if (DEBUG) {
+ Log.i(TAG, "onConfigurationChanged() called with "
+ + "newConfig = [" + newConfig + "]");
+ }
if (newConfig.orientation != getResources().getConfiguration().orientation) {
mCurrentDeviceToggle = null;
}
diff --git a/src/org/lineageos/audiofx/activity/ControlPanelPicker.java b/src/org/lineageos/audiofx/activity/ControlPanelPicker.java
index 1ccab78..f70ec9d 100644
--- a/src/org/lineageos/audiofx/activity/ControlPanelPicker.java
+++ b/src/org/lineageos/audiofx/activity/ControlPanelPicker.java
@@ -16,12 +16,6 @@
package org.lineageos.audiofx.activity;
-import com.android.internal.app.AlertActivity;
-import com.android.internal.app.AlertController;
-import com.android.internal.app.AlertController.AlertParams.OnPrepareListViewListener;
-import org.lineageos.audiofx.Compatibility;
-import org.lineageos.audiofx.Compatibility.Service;
-
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
@@ -33,6 +27,13 @@ import android.database.MatrixCursor;
import android.media.audiofx.AudioEffect;
import android.os.Bundle;
import android.widget.ListView;
+
+import com.android.internal.app.AlertActivity;
+import com.android.internal.app.AlertController;
+import com.android.internal.app.AlertController.AlertParams.OnPrepareListViewListener;
+
+import org.lineageos.audiofx.Compatibility;
+import org.lineageos.audiofx.Compatibility.Service;
import org.lineageos.audiofx.R;
import java.util.List;
@@ -40,31 +41,32 @@ import java.util.List;
/**
* shows a dialog that lets the user switch between control panels
*/
-public class ControlPanelPicker extends AlertActivity implements OnClickListener, OnPrepareListViewListener {
+public class ControlPanelPicker extends AlertActivity implements OnClickListener,
+ OnPrepareListViewListener {
-
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- String [] cols = new String [] { "_id", "title", "package", "name" };
+ String[] cols = new String[]{"_id", "title", "package", "name"};
MatrixCursor c = new MatrixCursor(cols);
PackageManager pmgr = getPackageManager();
Intent i = new Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL);
- List<ResolveInfo> ris = pmgr.queryIntentActivities(i, PackageManager.GET_DISABLED_COMPONENTS);
+ List<ResolveInfo> ris = pmgr.queryIntentActivities(i,
+ PackageManager.GET_DISABLED_COMPONENTS);
SharedPreferences pref = getSharedPreferences("musicfx", MODE_PRIVATE);
String savedDefPackage = pref.getString("defaultpanelpackage", null);
String savedDefName = pref.getString("defaultpanelname", null);
int cnt = -1;
int defpanelidx = 0;
- for (ResolveInfo foo: ris) {
+ for (ResolveInfo foo : ris) {
if (foo.activityInfo.name.equals(Compatibility.Redirector.class.getName())) {
continue;
}
CharSequence name = pmgr.getApplicationLabel(foo.activityInfo.applicationInfo);
- c.addRow(new Object [] { 0, name, foo.activityInfo.packageName, foo.activityInfo.name });
+ c.addRow(new Object[]{0, name, foo.activityInfo.packageName, foo.activityInfo.name});
cnt += 1;
if (foo.activityInfo.name.equals(savedDefName) &&
foo.activityInfo.packageName.equals(savedDefPackage) &&
@@ -73,7 +75,7 @@ public class ControlPanelPicker extends AlertActivity implements OnClickListener
defpanelidx = cnt;
}
}
-
+
final AlertController.AlertParams p = mAlertParams;
p.mCursor = c;
p.mOnClickListener = mItemClickListener;
@@ -85,7 +87,7 @@ public class ControlPanelPicker extends AlertActivity implements OnClickListener
p.mOnPrepareListViewListener = this;
p.mTitle = getString(R.string.picker_title);
p.mCheckedItem = defpanelidx;
-
+
setupAlert();
}
@@ -97,15 +99,15 @@ public class ControlPanelPicker extends AlertActivity implements OnClickListener
return getResources().getIdentifier("cancel", "string", "android");
}
- private DialogInterface.OnClickListener mItemClickListener =
- new DialogInterface.OnClickListener() {
+ private final DialogInterface.OnClickListener mItemClickListener =
+ new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- // Save the position of most recently clicked item
- mAlertParams.mCheckedItem = which;
- }
-
- };
+ public void onClick(DialogInterface dialog, int which) {
+ // Save the position of most recently clicked item
+ mAlertParams.mCheckedItem = which;
+ }
+
+ };
@Override
public void onClick(DialogInterface dialog, int which) {
diff --git a/src/org/lineageos/audiofx/activity/EqualizerManager.java b/src/org/lineageos/audiofx/activity/EqualizerManager.java
index 0ec055d..0667f19 100644
--- a/src/org/lineageos/audiofx/activity/EqualizerManager.java
+++ b/src/org/lineageos/audiofx/activity/EqualizerManager.java
@@ -54,7 +54,7 @@ public class EqualizerManager {
private float[] mCenterFreqs;
private float[] mGlobalLevels;
- private AtomicBoolean mAnimatingToCustom = new AtomicBoolean(false);
+ private final AtomicBoolean mAnimatingToCustom = new AtomicBoolean(false);
// whether we are in between presets, animating them and such
private boolean mChangingPreset = false;
@@ -69,7 +69,7 @@ public class EqualizerManager {
private static final int MSG_SAVE_PRESETS = 1;
private static final int MSG_SEND_EQ_OVERRIDE = 2;
- private Handler mHandler = new Handler(new Handler.Callback() {
+ private final Handler mHandler = new Handler(new Handler.Callback() {
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
@@ -77,11 +77,12 @@ public class EqualizerManager {
Constants.saveCustomPresets(mContext, mEqPresets);
break;
case MSG_SEND_EQ_OVERRIDE:
- mConfig.overrideEqLevels((short)msg.arg1, (short) msg.arg2);
+ mConfig.overrideEqLevels((short) msg.arg1, (short) msg.arg2);
break;
}
return true;
- }}, true);
+ }
+ }, true);
public EqualizerManager(Context context, MasterConfigControl config) {
mContext = context;
@@ -116,7 +117,8 @@ public class EqualizerManager {
mCenterFreqs = Arrays.copyOf(centerFreqsKHz, mNumBands);
System.arraycopy(centerFreqsKHz, 0, mCenterFreqs, 0, mNumBands);
mMinFreq = mCenterFreqs[0] / 2;
- mMaxFreq = (float) Math.pow(mCenterFreqs[mNumBands - 1], 2) / mCenterFreqs[mNumBands - 2] / 2;
+ mMaxFreq = (float) Math.pow(mCenterFreqs[mNumBands - 1], 2) / mCenterFreqs[mNumBands - 2]
+ / 2;
// setup equalizer presets
final int numPresets = Integer.parseInt(getGlobalPref("equalizer.number_of_presets", "0"));
@@ -124,9 +126,11 @@ public class EqualizerManager {
if (numPresets > 0) {
// add library-provided presets
String[] presetNames = getGlobalPref("equalizer.preset_names", "").split("\\|");
- mPredefinedPresets = presetNames.length + 1; // we consider first EQ to be part of predefined
+ mPredefinedPresets =
+ presetNames.length + 1; // we consider first EQ to be part of predefined
for (int i = 0; i < numPresets; i++) {
- mEqPresets.add(new Preset.StaticPreset(presetNames[i], getPersistedPresetLevels(i)));
+ mEqPresets.add(
+ new Preset.StaticPreset(presetNames[i], getPersistedPresetLevels(i)));
}
} else {
mPredefinedPresets = 1; // custom is predefined
@@ -237,7 +241,8 @@ public class EqualizerManager {
public int copyToCustom() {
updateGlobalLevels(mCurrentPreset);
if (DEBUG) {
- Log.w(TAG, "using levels from preset: " + mCurrentPreset + ": " + Arrays.toString(mGlobalLevels));
+ Log.w(TAG, "using levels from preset: " + mCurrentPreset + ": " + Arrays.toString(
+ mGlobalLevels));
}
String levels = EqUtils.floatLevelsToString(
@@ -245,9 +250,12 @@ public class EqualizerManager {
mEqPresets.get(mCurrentPreset).getLevels()));
setGlobalPref("custom", levels);
- ((Preset.PermCustomPreset) mEqPresets.get(mEQCustomPresetPosition)).setLevels(mGlobalLevels);
- if (DEBUG)
- Log.i(TAG, "copyToCustom() wrote current preset levels to index: " + mEQCustomPresetPosition);
+ ((Preset.PermCustomPreset) mEqPresets.get(mEQCustomPresetPosition)).setLevels(
+ mGlobalLevels);
+ if (DEBUG) {
+ Log.i(TAG, "copyToCustom() wrote current preset levels to index: "
+ + mEQCustomPresetPosition);
+ }
setPreset(mEQCustomPresetPosition);
savePresetsDelayed();
return mEQCustomPresetPosition;
@@ -256,20 +264,24 @@ public class EqualizerManager {
public int addPresetFromCustom() {
updateGlobalLevels(mEQCustomPresetPosition);
if (DEBUG) {
- Log.w(TAG, "using levels from preset: " + mCurrentPreset + ": " + Arrays.toString(mGlobalLevels));
+ Log.w(TAG, "using levels from preset: " + mCurrentPreset + ": " + Arrays.toString(
+ mGlobalLevels));
}
int writtenToIndex = addPreset(mGlobalLevels);
- if (DEBUG)
- Log.i(TAG, "addPresetFromCustom() wrote current preset levels to index: " + writtenToIndex);
+ if (DEBUG) {
+ Log.i(TAG, "addPresetFromCustom() wrote current preset levels to index: "
+ + writtenToIndex);
+ }
setPreset(writtenToIndex);
savePresetsDelayed();
return writtenToIndex;
}
/**
- * Loops through all presets. And finds the first preset that can be written to.
- * If one is not found, then one is inserted, and that new index is returned.
+ * Loops through all presets. And finds the first preset that can be written to. If one is not
+ * found, then one is inserted, and that new index is returned.
+ *
* @return the index that the levels were copied to
*/
private int addPreset(float[] levels) {
@@ -370,7 +382,8 @@ public class EqualizerManager {
private void updateEqControls() {
final boolean userPreset = isUserPreset();
- mConfig.getCallbacks().notifyEqControlStateChanged(mEQCustomPresetPosition == mCurrentPreset,
+ mConfig.getCallbacks().notifyEqControlStateChanged(
+ mEQCustomPresetPosition == mCurrentPreset,
userPreset, userPreset, userPreset);
}
diff --git a/src/org/lineageos/audiofx/activity/MasterConfigControl.java b/src/org/lineageos/audiofx/activity/MasterConfigControl.java
index 90ce1a1..aa9efe2 100644
--- a/src/org/lineageos/audiofx/activity/MasterConfigControl.java
+++ b/src/org/lineageos/audiofx/activity/MasterConfigControl.java
@@ -50,13 +50,13 @@ import java.util.List;
/**
* Master configuration class for AudioFX.
- *
- * Contains the main hub where data is stored for the current eq graph (which there should be
- * one of, thus only once instance of this class exists).
- *
+ * <p>
+ * Contains the main hub where data is stored for the current eq graph (which there should be one
+ * of, thus only once instance of this class exists).
+ * <p>
* Anyone can obtain an instance of this class. If one does not exist, a new one is created.
- * Immediately before the new instance creation happens, some defaults are pre-populated
- * with MasterConfigControl.saveDefaults(). That method doesn't ever have to be directly called.
+ * Immediately before the new instance creation happens, some defaults are pre-populated with
+ * MasterConfigControl.saveDefaults(). That method doesn't ever have to be directly called.
*/
public class MasterConfigControl {
@@ -107,7 +107,10 @@ public class MasterConfigControl {
mServiceConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder binder) {
- if (SERVICE_DEBUG) Log.i(TAG, "onServiceConnected refCount=" + mServiceRefCount);
+ if (SERVICE_DEBUG) {
+ Log.i(TAG,
+ "onServiceConnected refCount=" + mServiceRefCount);
+ }
mService = ((AudioFxService.LocalBinder) binder);
LocalBroadcastManager.getInstance(mContext).registerReceiver(
mDeviceChangeReceiver,
@@ -116,7 +119,10 @@ public class MasterConfigControl {
@Override
public void onServiceDisconnected(ComponentName name) {
- if (SERVICE_DEBUG) Log.w(TAG, "onServiceDisconnected refCount =" + mServiceRefCount);
+ if (SERVICE_DEBUG) {
+ Log.w(TAG,
+ "onServiceDisconnected refCount =" + mServiceRefCount);
+ }
LocalBroadcastManager.getInstance(mContext).unregisterReceiver(
mDeviceChangeReceiver);
mService = null;
@@ -124,7 +130,7 @@ public class MasterConfigControl {
};
Intent serviceIntent = new Intent(mContext, AudioFxService.class);
- conn = mContext.bindService(serviceIntent, mServiceConnection,
+ conn = mContext.bindService(serviceIntent, mServiceConnection,
Context.BIND_AUTO_CREATE);
}
if (conn) {
@@ -147,7 +153,7 @@ public class MasterConfigControl {
public boolean checkService() {
if (mService == null && mServiceRefCount == 0 && mShouldBindToService) {
- Log.e(TAG, "Service went away, rebinding");
+ Log.e(TAG, "Service went away, rebinding");
bindService();
}
return mService != null;
@@ -317,7 +323,8 @@ public class MasterConfigControl {
}
public void setReverbEnabled(boolean enable) {
- getPrefs().edit().putString(Constants.DEVICE_AUDIOFX_REVERB_PRESET, enable ? "1" : "0").apply();
+ getPrefs().edit().putString(Constants.DEVICE_AUDIOFX_REVERB_PRESET,
+ enable ? "1" : "0").apply();
updateService(AudioFxService.REVERB_CHANGED);
}
@@ -327,7 +334,7 @@ public class MasterConfigControl {
}
}
- public static String getDeviceDisplayString(Context context, AudioDeviceInfo info) {
+ public static String getDeviceDisplayString(Context context, AudioDeviceInfo info) {
int type = info == null ? -1 : info.getType();
switch (type) {
case TYPE_WIRED_HEADSET:
@@ -391,6 +398,7 @@ public class MasterConfigControl {
/**
* Set whether to automatically attempt to bind to the service.
+ *
* @param bindToService
*/
public void setAutoBindToService(boolean bindToService) {
diff --git a/src/org/lineageos/audiofx/activity/StateCallbacks.java b/src/org/lineageos/audiofx/activity/StateCallbacks.java
index e01b34f..d082732 100644
--- a/src/org/lineageos/audiofx/activity/StateCallbacks.java
+++ b/src/org/lineageos/audiofx/activity/StateCallbacks.java
@@ -28,37 +28,37 @@ public class StateCallbacks {
private final List<EqUpdatedCallback> mEqUpdateCallbacks = new ArrayList<EqUpdatedCallback>();
- private final List<DeviceChangedCallback> mDeviceChangedCallbacks = new ArrayList<DeviceChangedCallback>();
+ private final List<DeviceChangedCallback> mDeviceChangedCallbacks =
+ new ArrayList<DeviceChangedCallback>();
- private final List<EqControlStateCallback> mEqControlStateCallbacks = new ArrayList<EqControlStateCallback>();
+ private final List<EqControlStateCallback> mEqControlStateCallbacks =
+ new ArrayList<EqControlStateCallback>();
StateCallbacks(MasterConfigControl config) {
mConfig = config;
}
/**
- * Implement this callback to receive any changes called to the
- * MasterConfigControl instance
+ * Implement this callback to receive any changes called to the MasterConfigControl instance
*/
public interface EqUpdatedCallback {
/**
* A band level has been changed
*
- * @param band the band index which changed
- * @param dB the new decibel value
- * @param fromSystem whether the event was from the system or from the
- * user
+ * @param band the band index which changed
+ * @param dB the new decibel value
+ * @param fromSystem whether the event was from the system or from the user
*/
- public void onBandLevelChange(int band, float dB, boolean fromSystem);
+ void onBandLevelChange(int band, float dB, boolean fromSystem);
/**
* The preset has been set
*
* @param newPresetIndex the new preset index.
*/
- public void onPresetChanged(int newPresetIndex);
+ void onPresetChanged(int newPresetIndex);
- public void onPresetsChanged();
+ void onPresetsChanged();
}
public void addEqUpdatedCallback(EqUpdatedCallback callback) {
@@ -101,7 +101,7 @@ public class StateCallbacks {
* Callback for changes to visibility and state of the EQ
*/
public interface EqControlStateCallback {
- public void updateEqState(boolean saveVisible, boolean removeVisible,
+ void updateEqState(boolean saveVisible, boolean removeVisible,
boolean renameVisible, boolean unlockVisible);
}
@@ -127,12 +127,12 @@ public class StateCallbacks {
}
/**
- * Register this callback to receive notification when the output device
- * changes.
+ * Register this callback to receive notification when the output device changes.
*/
public interface DeviceChangedCallback {
- public void onDeviceChanged(AudioDeviceInfo device, boolean userChange);
- public void onGlobalDeviceToggle(boolean on);
+ void onDeviceChanged(AudioDeviceInfo device, boolean userChange);
+
+ void onGlobalDeviceToggle(boolean on);
}
diff --git a/src/org/lineageos/audiofx/backends/EffectSet.java b/src/org/lineageos/audiofx/backends/EffectSet.java
index 8a01b0d..893b9a8 100644
--- a/src/org/lineageos/audiofx/backends/EffectSet.java
+++ b/src/org/lineageos/audiofx/backends/EffectSet.java
@@ -19,8 +19,7 @@ import android.media.AudioDeviceInfo;
import android.util.Log;
/**
- * Helper class representing the full complement of effects attached to one
- * audio session.
+ * Helper class representing the full complement of effects attached to one audio session.
*/
public abstract class EffectSet {
@@ -47,32 +46,33 @@ public abstract class EffectSet {
}
/**
- * Called to do subclass-first initialization in case
- * an implementation has ordering restrictions.
- *
- * This call is wrapped in a try/catch - if an exception is thrown here,
- * a release will immediately be called.
+ * Called to do subclass-first initialization in case an implementation has ordering
+ * restrictions.
+ * <p>
+ * This call is wrapped in a try/catch - if an exception is thrown here, a release will
+ * immediately be called.
*/
- protected void onCreate() { }
+ protected void onCreate() {
+ }
/**
* Destroy all effects in this set.
- *
- * Attempting to use this object after calling release is
- * undefined behavior.
+ * <p>
+ * Attempting to use this object after calling release is undefined behavior.
*/
- public void release() { }
+ public void release() {
+ }
/**
* Returns the enumerated brand of this implementation
+ *
* @return brandId
*/
public abstract int getBrand();
/**
- * Called when the user toggles the engine on or off. If the
- * implementation has a built-in bypass mode, this is where
- * to use it.
+ * Called when the user toggles the engine on or off. If the implementation has a built-in
+ * bypass mode, this is where to use it.
*
* @param globalEnabled
*/
@@ -85,8 +85,7 @@ public abstract class EffectSet {
}
/**
- * Called when the output device has changed. All cached
- * data should be cleared at this point.
+ * Called when the output device has changed. All cached data should be cleared at this point.
*
* @param deviceInfo
*/
@@ -96,6 +95,7 @@ public abstract class EffectSet {
/**
* Return the current active output device
+ *
* @return deviceInfo
*/
public AudioDeviceInfo getDevice() {
@@ -103,31 +103,32 @@ public abstract class EffectSet {
}
/**
- * Begin bulk-update of parameters. This can be used if the
- * implementation supports operation in a transactional/atomic
- * manner. Parameter changes will immediately follow this call
- * and should be committed to the backend when the subsequent
- * commitUpdate() is called.
- *
+ * Begin bulk-update of parameters. This can be used if the implementation supports operation in
+ * a transactional/atomic manner. Parameter changes will immediately follow this call and should
+ * be committed to the backend when the subsequent commitUpdate() is called.
+ * <p>
* Optional.
*
* @return status - false on failure
*/
- public boolean beginUpdate() { return true; }
+ public boolean beginUpdate() {
+ return true;
+ }
/**
* Commit accumulated updates to the backend. See above.
- *
- * begin/commit are used when a large number of parameters need
- * to be sent to the backend, such as in the case of a device
- * switch or preset change. This can increase performance and
- * reduce click/pop issues.
- *
+ * <p>
+ * begin/commit are used when a large number of parameters need to be sent to the backend, such
+ * as in the case of a device switch or preset change. This can increase performance and reduce
+ * click/pop issues.
+ * <p>
* Optional.
*
* @return status - false on failure
*/
- public boolean commitUpdate() { return true; }
+ public boolean commitUpdate() {
+ return true;
+ }
/* ---- Top level effects begin here ---- */
@@ -221,10 +222,8 @@ public abstract class EffectSet {
}
/**
- * How long should we delay for when releasing the effects?
- * This helps certain effect implementations when the
- * app is reusing a session ID. By default this
- * behavior is disabled.
+ * How long should we delay for when releasing the effects? This helps certain effect
+ * implementations when the app is reusing a session ID. By default this behavior is disabled.
*/
public int getReleaseDelay() {
return 0;
diff --git a/src/org/lineageos/audiofx/backends/EffectSetWithAndroidEq.java b/src/org/lineageos/audiofx/backends/EffectSetWithAndroidEq.java
index 27eea4a..b756d89 100644
--- a/src/org/lineageos/audiofx/backends/EffectSetWithAndroidEq.java
+++ b/src/org/lineageos/audiofx/backends/EffectSetWithAndroidEq.java
@@ -84,7 +84,7 @@ public abstract class EffectSetWithAndroidEq extends EffectSet {
@Override
public void setEqualizerBandLevel(short band, float level) {
- setBandLevelSafe(band, (short)level);
+ setBandLevelSafe(band, (short) level);
}
@Override
diff --git a/src/org/lineageos/audiofx/backends/EffectsFactory.java b/src/org/lineageos/audiofx/backends/EffectsFactory.java
index cd9ca9c..e9e0320 100644
--- a/src/org/lineageos/audiofx/backends/EffectsFactory.java
+++ b/src/org/lineageos/audiofx/backends/EffectsFactory.java
@@ -1,10 +1,10 @@
package org.lineageos.audiofx.backends;
-import org.lineageos.audiofx.Constants;
-
import android.content.Context;
import android.media.AudioDeviceInfo;
+import org.lineageos.audiofx.Constants;
+
/**
* Creates an EffectSet appropriate for the current device
*/
diff --git a/src/org/lineageos/audiofx/backends/IEffectFactory.java b/src/org/lineageos/audiofx/backends/IEffectFactory.java
index 937478a..0f1399f 100644
--- a/src/org/lineageos/audiofx/backends/IEffectFactory.java
+++ b/src/org/lineageos/audiofx/backends/IEffectFactory.java
@@ -22,8 +22,9 @@ interface IEffectFactory {
/**
* Create a new EffectSet based on current stream parameters.
- * @param context context to create the effect with
- * @param sessionId session id to attach the effect to
+ *
+ * @param context context to create the effect with
+ * @param sessionId session id to attach the effect to
* @param currentDevice current device that the effect should initially setup for
* @return an {@link EffectSet}
*/
diff --git a/src/org/lineageos/audiofx/eq/EqBarView.java b/src/org/lineageos/audiofx/eq/EqBarView.java
index 19a2f55..38c8db0 100644
--- a/src/org/lineageos/audiofx/eq/EqBarView.java
+++ b/src/org/lineageos/audiofx/eq/EqBarView.java
@@ -117,8 +117,9 @@ public class EqBarView extends FrameLayout implements StateCallbacks.EqUpdatedCa
mUserInteracting = true;
if (DEBUG) Log.d(TAG, "initial level: " + mInitialLevel);
- mInitialLevel = (1 - (mPosY / mParentHeight)) * (mEqManager.getMinDB() - mEqManager.getMaxDB())
- - mEqManager.getMinDB();
+ mInitialLevel =
+ (1 - (mPosY / mParentHeight)) * (mEqManager.getMinDB() - mEqManager.getMaxDB())
+ - mEqManager.getMinDB();
updateWidth((int) (mNormalWidth * 2));
}
diff --git a/src/org/lineageos/audiofx/eq/EqContainerView.java b/src/org/lineageos/audiofx/eq/EqContainerView.java
index 5a692d5..0a6ef95 100644
--- a/src/org/lineageos/audiofx/eq/EqContainerView.java
+++ b/src/org/lineageos/audiofx/eq/EqContainerView.java
@@ -83,7 +83,7 @@ public class EqContainerView extends FrameLayout
private Handler mHandler;
- private Runnable mVibrateRunnable = new Runnable() {
+ private final Runnable mVibrateRunnable = new Runnable() {
@Override
public void run() {
Vibrator v = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
@@ -194,11 +194,11 @@ public class EqContainerView extends FrameLayout
getViewTreeObserver().addOnGlobalLayoutListener(
new ViewTreeObserver.OnGlobalLayoutListener() {
- @Override
- public void onGlobalLayout() {
- generateAndAddBars();
- }
- });
+ @Override
+ public void onGlobalLayout() {
+ generateAndAddBars();
+ }
+ });
}
@Override
@@ -210,14 +210,14 @@ public class EqContainerView extends FrameLayout
protected void onFinishInflate() {
super.onFinishInflate();
- mControls = (ViewGroup) findViewById(R.id.eq_controls);
+ mControls = findViewById(R.id.eq_controls);
- mLockBox = (CheckBox) findViewById(R.id.lock);
+ mLockBox = findViewById(R.id.lock);
mLockBox.setOnCheckedChangeListener(mEqManager.getLockChangeListener());
- mRenameControl = (ImageView) findViewById(R.id.rename);
- mRemoveControl = (ImageView) findViewById(R.id.remove);
- mSaveControl = (ImageView) findViewById(R.id.save);
+ mRenameControl = findViewById(R.id.rename);
+ mRemoveControl = findViewById(R.id.remove);
+ mSaveControl = findViewById(R.id.save);
}
@Override
@@ -352,8 +352,9 @@ public class EqContainerView extends FrameLayout
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
//---------------------------------------------------
- if (mFirstLayout)
+ if (mFirstLayout) {
return;
+ }
int dashY = bottom - mPaddingBottom - (mHeight / 2);
@@ -434,7 +435,7 @@ public class EqContainerView extends FrameLayout
private void updateSelectedBands() {
for (int i = 0; i < mEqManager.getNumBands(); i++) {
EqBandInfo tag = mBandInfo.get(i);
- final EqBarView bar = (EqBarView) findViewWithTag(tag);
+ final EqBarView bar = findViewWithTag(tag);
if (bar != null) {
final ViewPropertyAnimator barAnimation = bar.animate().withLayer();
if (mSelectedBands.isEmpty()) {
diff --git a/src/org/lineageos/audiofx/eq/EqSwipeController.java b/src/org/lineageos/audiofx/eq/EqSwipeController.java
index ec6cae1..08641ca 100644
--- a/src/org/lineageos/audiofx/eq/EqSwipeController.java
+++ b/src/org/lineageos/audiofx/eq/EqSwipeController.java
@@ -16,7 +16,6 @@
package org.lineageos.audiofx.eq;
import android.content.Context;
-import android.provider.Settings;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.VelocityTracker;
@@ -58,9 +57,9 @@ public class EqSwipeController extends LinearLayout {
@Override
protected void onFinishInflate() {
super.onFinishInflate();
- mEq = (EqContainerView) findViewById(R.id.eq_container);
+ mEq = findViewById(R.id.eq_container);
mPager = (InfiniteViewPager) findViewById(R.id.pager);
- mControls = (ViewGroup) findViewById(R.id.eq_controls);
+ mControls = findViewById(R.id.eq_controls);
}
@Override
@@ -69,12 +68,8 @@ public class EqSwipeController extends LinearLayout {
float y = event.getY();
// don't intercept touches over the EQ controls
- if (mControls.getRight() > x && mControls.getTop() < y
- && mControls.getBottom() > y && mControls.getLeft() < x) {
- return false;
- }
-
- return true;
+ return !(mControls.getRight() > x) || !(mControls.getTop() < y)
+ || !(mControls.getBottom() > y) || !(mControls.getLeft() < x);
}
@Override
diff --git a/src/org/lineageos/audiofx/fragment/AudioFxBaseFragment.java b/src/org/lineageos/audiofx/fragment/AudioFxBaseFragment.java
index 1bf84f4..459c1b0 100644
--- a/src/org/lineageos/audiofx/fragment/AudioFxBaseFragment.java
+++ b/src/org/lineageos/audiofx/fragment/AudioFxBaseFragment.java
@@ -18,8 +18,7 @@ package org.lineageos.audiofx.fragment;
import android.animation.Animator;
import android.app.Fragment;
import android.os.Bundle;
-import android.widget.CompoundButton;
-import org.lineageos.audiofx.activity.ActivityMusic;
+
import org.lineageos.audiofx.activity.MasterConfigControl;
public class AudioFxBaseFragment extends Fragment {
@@ -46,15 +45,15 @@ public class AudioFxBaseFragment extends Fragment {
}
public void animateBackgroundColorTo(Integer colorTo, Animator.AnimatorListener listener,
- AudioFxFragment.ColorUpdateListener updateListener) {
+ AudioFxFragment.ColorUpdateListener updateListener) {
if (mFrag != null) {
mFrag.animateBackgroundColorTo(colorTo, listener, updateListener);
}
}
/**
- * Call to change the color and propogate it up to the activity, which will call
- * {@link #updateFragmentBackgroundColors(int)}
+ * Call to change the color and propogate it up to the activity, which will call {@link
+ * #updateFragmentBackgroundColors(int)}
*
* @param color
*/
diff --git a/src/org/lineageos/audiofx/fragment/AudioFxFragment.java b/src/org/lineageos/audiofx/fragment/AudioFxFragment.java
index 12b3e4c..349f5a9 100644
--- a/src/org/lineageos/audiofx/fragment/AudioFxFragment.java
+++ b/src/org/lineageos/audiofx/fragment/AudioFxFragment.java
@@ -38,6 +38,7 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
+
import org.lineageos.audiofx.Compatibility;
import org.lineageos.audiofx.Constants;
import org.lineageos.audiofx.R;
@@ -83,7 +84,8 @@ public class AudioFxFragment extends Fragment implements StateCallbacks.DeviceCh
private AudioDeviceInfo mSystemDevice;
private AudioDeviceInfo mUserSelection;
- private final Map<MenuItem, AudioDeviceInfo> mMenuItems = new ArrayMap<MenuItem, AudioDeviceInfo>();
+ private final Map<MenuItem, AudioDeviceInfo> mMenuItems =
+ new ArrayMap<MenuItem, AudioDeviceInfo>();
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -165,7 +167,7 @@ public class AudioFxFragment extends Fragment implements StateCallbacks.DeviceCh
mCurrentBackgroundColor = !mConfig.isCurrentDeviceEnabled()
? mDisabledColor
: mEqManager.getAssociatedPresetColorHex(
- mEqManager.getCurrentPresetIndex());
+ mEqManager.getCurrentPresetIndex());
updateBackgroundColors(mCurrentBackgroundColor, false);
promptIfNotDefault();
@@ -416,7 +418,7 @@ public class AudioFxFragment extends Fragment implements StateCallbacks.DeviceCh
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
- mInterceptLayout = (InterceptableLinearLayout) view.findViewById(R.id.interceptable_layout);
+ mInterceptLayout = view.findViewById(R.id.interceptable_layout);
}
public void animateBackgroundColorTo(int colorTo, Animator.AnimatorListener listener,
@@ -482,7 +484,7 @@ public class AudioFxFragment extends Fragment implements StateCallbacks.DeviceCh
animateBackgroundColorTo(colorTo, animatorListener, null);
}
- private ValueAnimator.AnimatorUpdateListener mColorUpdateListener
+ private final ValueAnimator.AnimatorUpdateListener mColorUpdateListener
= new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
diff --git a/src/org/lineageos/audiofx/fragment/ControlsFragment.java b/src/org/lineageos/audiofx/fragment/ControlsFragment.java
index 22c7ac7..ded7b16 100644
--- a/src/org/lineageos/audiofx/fragment/ControlsFragment.java
+++ b/src/org/lineageos/audiofx/fragment/ControlsFragment.java
@@ -43,7 +43,7 @@ public class ControlsFragment extends AudioFxBaseFragment {
Switch mMaxxVolumeSwitch;
Switch mReverbSwitch;
- private CompoundButton.OnCheckedChangeListener mMaxxVolumeListener
+ private final CompoundButton.OnCheckedChangeListener mMaxxVolumeListener
= new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
@@ -53,7 +53,7 @@ public class ControlsFragment extends AudioFxBaseFragment {
}
};
- private CompoundButton.OnCheckedChangeListener mReverbListener
+ private final CompoundButton.OnCheckedChangeListener mReverbListener
= new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
@@ -72,14 +72,16 @@ public class ControlsFragment extends AudioFxBaseFragment {
@Override
public void onPause() {
- MasterConfigControl.getInstance(getActivity()).getCallbacks().removeDeviceChangedCallback(mKnobContainer);
+ MasterConfigControl.getInstance(getActivity()).getCallbacks().removeDeviceChangedCallback(
+ mKnobContainer);
super.onPause();
}
@Override
public void onResume() {
super.onResume();
- MasterConfigControl.getInstance(getActivity()).getCallbacks().addDeviceChangedCallback(mKnobContainer);
+ MasterConfigControl.getInstance(getActivity()).getCallbacks().addDeviceChangedCallback(
+ mKnobContainer);
}
@Override
@@ -117,28 +119,28 @@ public class ControlsFragment extends AudioFxBaseFragment {
private void updateSwitchColor(Switch view, int color) {
ColorStateList thumbStates = new ColorStateList(
- new int[][] {
- new int[] { -android.R.attr.state_enabled },
- new int[] { android.R.attr.state_checked },
- new int[] {}
+ new int[][]{
+ new int[]{-android.R.attr.state_enabled},
+ new int[]{android.R.attr.state_checked},
+ new int[]{}
},
- new int[] {
- color,
- color,
- Color.LTGRAY
+ new int[]{
+ color,
+ color,
+ Color.LTGRAY
}
);
ColorStateList trackStates = new ColorStateList(
- new int[][] {
- new int[] { -android.R.attr.state_enabled },
- new int[] { android.R.attr.state_checked },
- new int[] {}
+ new int[][]{
+ new int[]{-android.R.attr.state_enabled},
+ new int[]{android.R.attr.state_checked},
+ new int[]{}
},
- new int[] {
- color,
- color,
- Color.GRAY
+ new int[]{
+ color,
+ color,
+ Color.GRAY
}
);
@@ -150,7 +152,7 @@ public class ControlsFragment extends AudioFxBaseFragment {
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
- Bundle savedInstanceState) {
+ Bundle savedInstanceState) {
View root = inflater.inflate(mConfig.hasMaxxAudio() ? R.layout.controls_maxx_audio
: R.layout.controls_generic, container, false);
return root;
@@ -160,9 +162,9 @@ public class ControlsFragment extends AudioFxBaseFragment {
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
- mKnobContainer = (KnobContainer) view.findViewById(R.id.knob_container);
- mMaxxVolumeSwitch = (Switch) view.findViewById(R.id.maxx_volume_switch);
- mReverbSwitch = (Switch) view.findViewById(R.id.reverb_switch);
+ mKnobContainer = view.findViewById(R.id.knob_container);
+ mMaxxVolumeSwitch = view.findViewById(R.id.maxx_volume_switch);
+ mReverbSwitch = view.findViewById(R.id.reverb_switch);
updateFragmentBackgroundColors(getCurrentBackgroundColor());
diff --git a/src/org/lineageos/audiofx/fragment/EqualizerFragment.java b/src/org/lineageos/audiofx/fragment/EqualizerFragment.java
index cb97a8b..bd600b5 100644
--- a/src/org/lineageos/audiofx/fragment/EqualizerFragment.java
+++ b/src/org/lineageos/audiofx/fragment/EqualizerFragment.java
@@ -22,7 +22,6 @@ import android.annotation.Nullable;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
-import android.graphics.drawable.ColorDrawable;
import android.media.AudioDeviceInfo;
import android.os.Bundle;
import android.os.Handler;
@@ -179,9 +178,9 @@ public class EqualizerFragment extends AudioFxBaseFragment
renameDialog.setNegativeButton(android.R.string.cancel,
new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface d, int which) {
- }
- });
+ public void onClick(DialogInterface d, int which) {
+ }
+ });
// disable ok button if text is empty
final AlertDialog dialog = renameDialog.create();
@@ -196,11 +195,7 @@ public class EqualizerFragment extends AudioFxBaseFragment
@Override
public void afterTextChanged(Editable s) {
- if (s.length() == 0) {
- dialog.getButton(Dialog.BUTTON_POSITIVE).setEnabled(false);
- } else {
- dialog.getButton(Dialog.BUTTON_POSITIVE).setEnabled(true);
- }
+ dialog.getButton(Dialog.BUTTON_POSITIVE).setEnabled(s.length() != 0);
}
});
@@ -209,7 +204,7 @@ public class EqualizerFragment extends AudioFxBaseFragment
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
- Bundle savedInstanceState) {
+ Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.equalizer, container, false);
return root;
}
@@ -218,13 +213,14 @@ public class EqualizerFragment extends AudioFxBaseFragment
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
- mSelectedPositionBands = mEqManager.getPersistedPresetLevels(mEqManager.getCurrentPresetIndex());
+ mSelectedPositionBands = mEqManager.getPersistedPresetLevels(
+ mEqManager.getCurrentPresetIndex());
mSelectedPosition = mEqManager.getCurrentPresetIndex();
- mEqContainer = (EqContainerView) view.findViewById(R.id.eq_container);
+ mEqContainer = view.findViewById(R.id.eq_container);
mPresetPager = (InfiniteViewPager) view.findViewById(R.id.pager);
- mPresetPageIndicator = (CirclePageIndicator) view.findViewById(R.id.indicator);
- mFakePager = (ViewPager) view.findViewById(R.id.fake_pager);
+ mPresetPageIndicator = view.findViewById(R.id.indicator);
+ mFakePager = view.findViewById(R.id.fake_pager);
mEqContainer.findViewById(R.id.save).setOnClickListener(
new View.OnClickListener() {
@@ -359,7 +355,8 @@ public class EqualizerFragment extends AudioFxBaseFragment
if (DEBUG) Log.d(TAG, "mCurrentRealPage After: " + newPage);
mSelectedPositionBands = mEqManager.getPresetLevels(mSelectedPosition);
- final float[] targetBandLevels = mEqManager.getPresetLevels(mEqManager.getCurrentPresetIndex());
+ final float[] targetBandLevels = mEqManager.getPresetLevels(
+ mEqManager.getCurrentPresetIndex());
// do background transition manually as viewpager can't handle this bg change
final Integer colorTo = !mConfig.isCurrentDeviceEnabled()
@@ -410,7 +407,8 @@ public class EqualizerFragment extends AudioFxBaseFragment
float delta = targetBandLevels[i] - mSelectedPositionBands[i];
float newBandLevel = mSelectedPositionBands[i]
+ (delta * animator.getAnimatedFraction());
- //if (DEBUG_VIEWPAGER) Log.d(TAG, i + ", delta: " + delta + ", newBandLevel: " + newBandLevel);
+ //if (DEBUG_VIEWPAGER) Log.d(TAG, i + ", delta: " + delta + ", newBandLevel:
+ // " + newBandLevel);
mEqManager.setLevel(i, newBandLevel, true);
}
}
@@ -427,143 +425,160 @@ public class EqualizerFragment extends AudioFxBaseFragment
}
- private ViewPager.OnPageChangeListener mViewPageChangeListener = new ViewPager.OnPageChangeListener() {
-
- int mState;
- float mLastOffset;
- boolean mJustGotToCustomAndSettling;
+ private final ViewPager.OnPageChangeListener mViewPageChangeListener =
+ new ViewPager.OnPageChangeListener() {
- @Override
- public void onPageScrolled(int newPosition, float positionOffset, int positionOffsetPixels) {
- if (DEBUG_VIEWPAGER)
- Log.i(TAG, "onPageScrolled(" + newPosition + ", " + positionOffset + ", "
- + positionOffsetPixels + ")");
- Integer colorFrom;
- Integer colorTo;
+ int mState;
+ float mLastOffset;
+ boolean mJustGotToCustomAndSettling;
- if (newPosition == mAnimatingToRealPageTarget && mEqManager.isAnimatingToCustom()) {
- if (DEBUG_VIEWPAGER) Log.w(TAG, "settling var set to true");
- mJustGotToCustomAndSettling = true;
- mAnimatingToRealPageTarget = -1;
- }
+ @Override
+ public void onPageScrolled(int newPosition, float positionOffset,
+ int positionOffsetPixels) {
+ if (DEBUG_VIEWPAGER) {
+ Log.i(TAG, "onPageScrolled(" + newPosition + ", " + positionOffset + ", "
+ + positionOffsetPixels + ")");
+ }
+ Integer colorFrom;
+ Integer colorTo;
+
+ if (newPosition == mAnimatingToRealPageTarget
+ && mEqManager.isAnimatingToCustom()) {
+ if (DEBUG_VIEWPAGER) Log.w(TAG, "settling var set to true");
+ mJustGotToCustomAndSettling = true;
+ mAnimatingToRealPageTarget = -1;
+ }
- newPosition = newPosition % mDataAdapter.getCount();
+ newPosition = newPosition % mDataAdapter.getCount();
- if (mEqManager.isAnimatingToCustom() || mDeviceChanging) {
- if (DEBUG_VIEWPAGER)
- Log.i(TAG, "ignoring onPageScrolled because animating to custom or device is changing");
- return;
- }
+ if (mEqManager.isAnimatingToCustom() || mDeviceChanging) {
+ if (DEBUG_VIEWPAGER) {
+ Log.i(TAG,
+ "ignoring onPageScrolled because animating to custom or "
+ + "device is changing");
+ }
+ return;
+ }
- int toPos;
- if (mLastOffset - positionOffset > 0.8) { // this is needed for flings
- //Log.e(TAG, "OFFSET DIFF > 0.8! Setting selected position from: " + mSelectedPosition + " to " + newPosition);
- mSelectedPosition = newPosition;
- // mSelectedPositionBands will be reset by setPreset() below calling back to onPresetChanged()
+ int toPos;
+ if (mLastOffset - positionOffset > 0.8) { // this is needed for flings
+ //Log.e(TAG, "OFFSET DIFF > 0.8! Setting selected position from: " +
+ // mSelectedPosition + " to " + newPosition);
+ mSelectedPosition = newPosition;
+ // mSelectedPositionBands will be reset by setPreset() below calling back
+ // to onPresetChanged()
- mEqManager.setPreset(mSelectedPosition);
- }
+ mEqManager.setPreset(mSelectedPosition);
+ }
- if (newPosition < mSelectedPosition || (newPosition == mDataAdapter.getCount() - 1)
- && mSelectedPosition == 0) {
- // scrolling left <<<<<
- positionOffset = (1 - positionOffset);
- //Log.v(TAG, "<<<<<< positionOffset: " + positionOffset + " (last offset: " + mLastOffset + ")");
- toPos = newPosition;
- colorTo = mEqManager.getAssociatedPresetColorHex(toPos);
- } else {
- // scrolling right >>>>>
- //Log.v(TAG, ">>>>>>> positionOffset: " + positionOffset + " (last offset: " + mLastOffset + ")");
- toPos = newPosition + 1 % mDataAdapter.getCount();
- if (toPos >= mDataAdapter.getCount()) {
- toPos = 0;
- }
+ if (newPosition < mSelectedPosition
+ || (newPosition == mDataAdapter.getCount() - 1)
+ && mSelectedPosition == 0) {
+ // scrolling left <<<<<
+ positionOffset = (1 - positionOffset);
+ //Log.v(TAG, "<<<<<< positionOffset: " + positionOffset + " (last offset:
+ // " + mLastOffset + ")");
+ toPos = newPosition;
+ colorTo = mEqManager.getAssociatedPresetColorHex(toPos);
+ } else {
+ // scrolling right >>>>>
+ //Log.v(TAG, ">>>>>>> positionOffset: " + positionOffset + " (last
+ // offset: " + mLastOffset + ")");
+ toPos = newPosition + 1 % mDataAdapter.getCount();
+ if (toPos >= mDataAdapter.getCount()) {
+ toPos = 0;
+ }
- colorTo = mEqManager.getAssociatedPresetColorHex(toPos);
- }
+ colorTo = mEqManager.getAssociatedPresetColorHex(toPos);
+ }
- if (!mDeviceChanging && mConfig.isCurrentDeviceEnabled()) {
- colorFrom = mEqManager.getAssociatedPresetColorHex(mSelectedPosition);
- setBackgroundColor((Integer) mArgbEval.evaluate(positionOffset, colorFrom, colorTo),
- true);
- }
+ if (!mDeviceChanging && mConfig.isCurrentDeviceEnabled()) {
+ colorFrom = mEqManager.getAssociatedPresetColorHex(mSelectedPosition);
+ setBackgroundColor(
+ (Integer) mArgbEval.evaluate(positionOffset, colorFrom, colorTo),
+ true);
+ }
- if (mSelectedPositionBands == null) {
- mSelectedPositionBands = mEqManager.getPresetLevels(mSelectedPosition);
- }
- // get current bands
- float[] finalPresetLevels = mEqManager.getPresetLevels(toPos);
-
- final int N = mEqManager.getNumBands();
- for (int i = 0; i < N; i++) { // animate bands
- float delta = finalPresetLevels[i] - mSelectedPositionBands[i];
- float newBandLevel = mSelectedPositionBands[i] + (delta * positionOffset);
- //if (DEBUG_VIEWPAGER) Log.d(TAG, i + ", delta: " + delta + ", newBandLevel: " + newBandLevel);
- mEqManager.setLevel(i, newBandLevel, true);
- }
- mLastOffset = positionOffset;
+ if (mSelectedPositionBands == null) {
+ mSelectedPositionBands = mEqManager.getPresetLevels(mSelectedPosition);
+ }
+ // get current bands
+ float[] finalPresetLevels = mEqManager.getPresetLevels(toPos);
+
+ final int N = mEqManager.getNumBands();
+ for (int i = 0; i < N; i++) { // animate bands
+ float delta = finalPresetLevels[i] - mSelectedPositionBands[i];
+ float newBandLevel = mSelectedPositionBands[i] + (delta * positionOffset);
+ //if (DEBUG_VIEWPAGER) Log.d(TAG, i + ", delta: " + delta + ",
+ // newBandLevel: " + newBandLevel);
+ mEqManager.setLevel(i, newBandLevel, true);
+ }
+ mLastOffset = positionOffset;
- }
+ }
- @Override
- public void onPageSelected(int position) {
- if (DEBUG_VIEWPAGER) Log.i(TAG, "onPageSelected(" + position + ")");
- mCurrentRealPage = position;
- position = position % mDataAdapter.getCount();
- if (DEBUG_VIEWPAGER) Log.e(TAG, "onPageSelected(" + position + ")");
- mFakePager.setCurrentItem(position);
- mSelectedPosition = position;
- if (!mDeviceChanging) {
- mSelectedPositionBands = mEqManager.getPresetLevels(mSelectedPosition);
- }
- }
+ @Override
+ public void onPageSelected(int position) {
+ if (DEBUG_VIEWPAGER) Log.i(TAG, "onPageSelected(" + position + ")");
+ mCurrentRealPage = position;
+ position = position % mDataAdapter.getCount();
+ if (DEBUG_VIEWPAGER) Log.e(TAG, "onPageSelected(" + position + ")");
+ mFakePager.setCurrentItem(position);
+ mSelectedPosition = position;
+ if (!mDeviceChanging) {
+ mSelectedPositionBands = mEqManager.getPresetLevels(mSelectedPosition);
+ }
+ }
- @Override
- public void onPageScrollStateChanged(int newState) {
- mState = newState;
- if (mDeviceChanging) { // avoid setting unwanted presets during custom animations
- return;
- }
- if (DEBUG_VIEWPAGER)
- Log.w(TAG, "onPageScrollStateChanged(" + stateToString(newState) + ")");
+ @Override
+ public void onPageScrollStateChanged(int newState) {
+ mState = newState;
+ if (mDeviceChanging) { // avoid setting unwanted presets during custom
+ // animations
+ return;
+ }
+ if (DEBUG_VIEWPAGER) {
+ Log.w(TAG, "onPageScrollStateChanged(" + stateToString(newState) + ")");
+ }
- if (mJustGotToCustomAndSettling && mState == ViewPager.SCROLL_STATE_IDLE) {
- if (DEBUG_VIEWPAGER)
- Log.w(TAG, "onPageScrollChanged() setting animating to custom = false");
- mJustGotToCustomAndSettling = false;
- mEqManager.setChangingPresets(false);
- mEqManager.setAnimatingToCustom(false);
- } else {
- if (mState == ViewPager.SCROLL_STATE_IDLE) {
- animateBackgroundColorTo(!mConfig.isCurrentDeviceEnabled()
- ? getDisabledColor()
- : mEqManager.getAssociatedPresetColorHex(mSelectedPosition),
- null, null);
-
- mEqManager.setChangingPresets(false);
- mEqManager.setPreset(mSelectedPosition);
-
- } else {
- // not idle
- mEqManager.setChangingPresets(true);
+ if (mJustGotToCustomAndSettling && mState == ViewPager.SCROLL_STATE_IDLE) {
+ if (DEBUG_VIEWPAGER) {
+ Log.w(TAG, "onPageScrollChanged() setting animating to custom = false");
+ }
+ mJustGotToCustomAndSettling = false;
+ mEqManager.setChangingPresets(false);
+ mEqManager.setAnimatingToCustom(false);
+ } else {
+ if (mState == ViewPager.SCROLL_STATE_IDLE) {
+ animateBackgroundColorTo(!mConfig.isCurrentDeviceEnabled()
+ ? getDisabledColor()
+ : mEqManager.getAssociatedPresetColorHex(mSelectedPosition),
+ null, null);
+
+ mEqManager.setChangingPresets(false);
+ mEqManager.setPreset(mSelectedPosition);
+
+ } else {
+ // not idle
+ mEqManager.setChangingPresets(true);
+ }
+ }
}
- }
- }
- private String stateToString(int state) {
- switch (state) {
- case 0:
- return "STATE_IDLE";
- case 1:
- return "STATE_DRAGGING";
- case 2:
- return "STATE_SETTLING";
- default:
- return "STATE_WUT";
- }
- }
+ private String stateToString(int state) {
+ switch (state) {
+ case 0:
+ return "STATE_IDLE";
+ case 1:
+ return "STATE_DRAGGING";
+ case 2:
+ return "STATE_SETTLING";
+ default:
+ return "STATE_WUT";
+ }
+ }
- };
+ };
}
diff --git a/src/org/lineageos/audiofx/knobs/KnobCommander.java b/src/org/lineageos/audiofx/knobs/KnobCommander.java
index a02b90e..7179bdb 100644
--- a/src/org/lineageos/audiofx/knobs/KnobCommander.java
+++ b/src/org/lineageos/audiofx/knobs/KnobCommander.java
@@ -16,6 +16,7 @@
package org.lineageos.audiofx.knobs;
import android.content.Context;
+
import org.lineageos.audiofx.Constants;
import org.lineageos.audiofx.activity.MasterConfigControl;
import org.lineageos.audiofx.service.AudioFxService;
@@ -28,8 +29,8 @@ public class KnobCommander {
private static KnobCommander sInstance;
- private Context mContext;
- private MasterConfigControl mConfig;
+ private final Context mContext;
+ private final MasterConfigControl mConfig;
private KnobCommander(Context context) {
mContext = context;
@@ -45,10 +46,14 @@ public class KnobCommander {
public RadialKnob.OnKnobChangeListener getRadialKnobCallback(int whichKnob) {
switch (whichKnob) {
- case KNOB_TREBLE: return mTrebleKnobCallback;
- case KNOB_BASS: return mBassKnobCallback;
- case KNOB_VIRTUALIZER: return mVirtualizerCallback;
- default: return null;
+ case KNOB_TREBLE:
+ return mTrebleKnobCallback;
+ case KNOB_BASS:
+ return mBassKnobCallback;
+ case KNOB_VIRTUALIZER:
+ return mVirtualizerCallback;
+ default:
+ return null;
}
}
@@ -101,15 +106,19 @@ public class KnobCommander {
}
public int getVirtualizerStrength() {
- return Integer.valueOf(mConfig.getPrefs().getString(Constants.DEVICE_AUDIOFX_VIRTUALIZER_STRENGTH, "0")) / 10;
+ return Integer.valueOf(
+ mConfig.getPrefs().getString(Constants.DEVICE_AUDIOFX_VIRTUALIZER_STRENGTH, "0"))
+ / 10;
}
public int getBassStrength() {
- return Integer.valueOf(mConfig.getPrefs().getString(Constants.DEVICE_AUDIOFX_BASS_STRENGTH, "0")) / 10;
+ return Integer.valueOf(
+ mConfig.getPrefs().getString(Constants.DEVICE_AUDIOFX_BASS_STRENGTH, "0")) / 10;
}
public int getTrebleStrength() {
- return Integer.valueOf(mConfig.getPrefs().getString(Constants.DEVICE_AUDIOFX_TREBLE_STRENGTH, "0"));
+ return Integer.valueOf(
+ mConfig.getPrefs().getString(Constants.DEVICE_AUDIOFX_TREBLE_STRENGTH, "0"));
}
public void setTrebleEnabled(boolean on) {
@@ -119,7 +128,8 @@ public class KnobCommander {
public void setTrebleStrength(int value) {
// set parameter and state
- mConfig.getPrefs().edit().putString(Constants.DEVICE_AUDIOFX_TREBLE_STRENGTH, String.valueOf(value)).apply();
+ mConfig.getPrefs().edit().putString(Constants.DEVICE_AUDIOFX_TREBLE_STRENGTH,
+ String.valueOf(value)).apply();
mConfig.updateService(AudioFxService.TREBLE_BOOST_CHANGED);
}
@@ -130,63 +140,69 @@ public class KnobCommander {
public void setBassStrength(int value) {
// set parameter and state
- mConfig.getPrefs().edit().putString(Constants.DEVICE_AUDIOFX_BASS_STRENGTH, String.valueOf(value * 10)).apply();
+ mConfig.getPrefs().edit().putString(Constants.DEVICE_AUDIOFX_BASS_STRENGTH,
+ String.valueOf(value * 10)).apply();
mConfig.updateService(AudioFxService.BASS_BOOST_CHANGED);
}
public void setVirtualizerEnabled(boolean on) {
- mConfig.getPrefs().edit().putBoolean(Constants.DEVICE_AUDIOFX_VIRTUALIZER_ENABLE, on).apply();
+ mConfig.getPrefs().edit().putBoolean(Constants.DEVICE_AUDIOFX_VIRTUALIZER_ENABLE,
+ on).apply();
mConfig.updateService(AudioFxService.VIRTUALIZER_CHANGED);
}
public void setVirtualiserStrength(int value) {
// set parameter and state
- mConfig.getPrefs().edit().putString(Constants.DEVICE_AUDIOFX_VIRTUALIZER_STRENGTH, String.valueOf(value * 10)).apply();
+ mConfig.getPrefs().edit().putString(Constants.DEVICE_AUDIOFX_VIRTUALIZER_STRENGTH,
+ String.valueOf(value * 10)).apply();
mConfig.updateService(AudioFxService.VIRTUALIZER_CHANGED);
}
- private RadialKnob.OnKnobChangeListener mTrebleKnobCallback = new RadialKnob.OnKnobChangeListener() {
- @Override
- public void onValueChanged(RadialKnob knob, int value, boolean fromUser) {
- if (fromUser) {
- setTrebleStrength(value);
- }
- }
-
- @Override
- public boolean onSwitchChanged(RadialKnob knob, boolean on) {
- setTrebleEnabled(on);
- return true;
- }
- };
-
- private RadialKnob.OnKnobChangeListener mBassKnobCallback = new RadialKnob.OnKnobChangeListener() {
- @Override
- public void onValueChanged(RadialKnob knob, int value, boolean fromUser) {
- if (fromUser) {
- setBassStrength(value);
- }
- }
-
- @Override
- public boolean onSwitchChanged(RadialKnob knob, boolean on) {
- setBassEnabled(on);
- return true;
- }
- };
-
- private RadialKnob.OnKnobChangeListener mVirtualizerCallback = new RadialKnob.OnKnobChangeListener() {
- @Override
- public void onValueChanged(RadialKnob knob, int value, boolean fromUser) {
- if (fromUser) {
- setVirtualiserStrength(value);
- }
- }
-
- @Override
- public boolean onSwitchChanged(RadialKnob knob, boolean on) {
- setVirtualizerEnabled(on);
- return true;
- }
- };
+ private final RadialKnob.OnKnobChangeListener mTrebleKnobCallback =
+ new RadialKnob.OnKnobChangeListener() {
+ @Override
+ public void onValueChanged(RadialKnob knob, int value, boolean fromUser) {
+ if (fromUser) {
+ setTrebleStrength(value);
+ }
+ }
+
+ @Override
+ public boolean onSwitchChanged(RadialKnob knob, boolean on) {
+ setTrebleEnabled(on);
+ return true;
+ }
+ };
+
+ private final RadialKnob.OnKnobChangeListener mBassKnobCallback =
+ new RadialKnob.OnKnobChangeListener() {
+ @Override
+ public void onValueChanged(RadialKnob knob, int value, boolean fromUser) {
+ if (fromUser) {
+ setBassStrength(value);
+ }
+ }
+
+ @Override
+ public boolean onSwitchChanged(RadialKnob knob, boolean on) {
+ setBassEnabled(on);
+ return true;
+ }
+ };
+
+ private final RadialKnob.OnKnobChangeListener mVirtualizerCallback =
+ new RadialKnob.OnKnobChangeListener() {
+ @Override
+ public void onValueChanged(RadialKnob knob, int value, boolean fromUser) {
+ if (fromUser) {
+ setVirtualiserStrength(value);
+ }
+ }
+
+ @Override
+ public boolean onSwitchChanged(RadialKnob knob, boolean on) {
+ setVirtualizerEnabled(on);
+ return true;
+ }
+ };
}
diff --git a/src/org/lineageos/audiofx/knobs/KnobContainer.java b/src/org/lineageos/audiofx/knobs/KnobContainer.java
index 669949f..e629f76 100644
--- a/src/org/lineageos/audiofx/knobs/KnobContainer.java
+++ b/src/org/lineageos/audiofx/knobs/KnobContainer.java
@@ -127,13 +127,13 @@ public class KnobContainer extends LinearLayout
};
if (MasterConfigControl.getInstance(getContext()).hasMaxxAudio()) {
- mVirtualizerContainer = (ViewGroup) findViewById(R.id.virtualizer_knob_container);
- mBassContainer = (ViewGroup) findViewById(R.id.bass_knob_container);
- mTrebleContainer = (ViewGroup) findViewById(R.id.treble_knob_container);
+ mVirtualizerContainer = findViewById(R.id.virtualizer_knob_container);
+ mBassContainer = findViewById(R.id.bass_knob_container);
+ mTrebleContainer = findViewById(R.id.treble_knob_container);
}
if (mTrebleContainer != null) {
- mTrebleKnob = (RadialKnob) mTrebleContainer.findViewById(R.id.knob);
+ mTrebleKnob = mTrebleContainer.findViewById(R.id.knob);
mTrebleKnob.setTag(new KnobInfo(KnobCommander.KNOB_TREBLE, mTrebleKnob,
mTrebleContainer.findViewById(R.id.label)));
mTrebleKnob.setOnTouchListener(knobTouchListener);
@@ -145,8 +145,9 @@ public class KnobContainer extends LinearLayout
mTrebleKnob.setMax(100);
}
if (mBassContainer != null) {
- mBassKnob = (RadialKnob) mBassContainer.findViewById(R.id.knob);
- mBassKnob.setTag(new KnobInfo(KnobCommander.KNOB_BASS, mBassKnob, mBassContainer.findViewById(R.id.label)));
+ mBassKnob = mBassContainer.findViewById(R.id.knob);
+ mBassKnob.setTag(new KnobInfo(KnobCommander.KNOB_BASS, mBassKnob,
+ mBassContainer.findViewById(R.id.label)));
mBassKnob.setOnTouchListener(knobTouchListener);
mBassKnob.setOnKnobChangeListener(
KnobCommander.getInstance(getContext()).getRadialKnobCallback(
@@ -158,7 +159,7 @@ public class KnobContainer extends LinearLayout
}
if (mVirtualizerContainer != null) {
- mVirtualizerKnob = (RadialKnob) mVirtualizerContainer.findViewById(R.id.knob);
+ mVirtualizerKnob = mVirtualizerContainer.findViewById(R.id.knob);
mVirtualizerKnob.setTag(new KnobInfo(KnobCommander.KNOB_VIRTUALIZER, mVirtualizerKnob,
mVirtualizerContainer.findViewById(R.id.label)));
mVirtualizerKnob.setOnTouchListener(knobTouchListener);
@@ -179,7 +180,7 @@ public class KnobContainer extends LinearLayout
private ViewGroup addKnob(int whichKnob) {
ViewGroup knobContainer = (ViewGroup) LayoutInflater.from(mContext)
.inflate(R.layout.generic_knob_control, this, false);
- TextView label = (TextView) knobContainer.findViewById(R.id.label);
+ TextView label = knobContainer.findViewById(R.id.label);
int newContainerId = 0;
int knobLabelRes = 0;
diff --git a/src/org/lineageos/audiofx/knobs/RadialKnob.java b/src/org/lineageos/audiofx/knobs/RadialKnob.java
index 56062c3..7d15b64 100644
--- a/src/org/lineageos/audiofx/knobs/RadialKnob.java
+++ b/src/org/lineageos/audiofx/knobs/RadialKnob.java
@@ -47,7 +47,7 @@ import android.util.TypedValue;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
-import android.widget.Toast;
+
import org.lineageos.audiofx.R;
public class RadialKnob extends View {
@@ -81,16 +81,18 @@ public class RadialKnob extends View {
private float mLastY;
private boolean mMoved;
private int mWidth = 0;
- private RectF mRectF, mOuterRect = new RectF(), mInnerRect = new RectF();
+ private RectF mRectF;
+ private final RectF mOuterRect = new RectF();
+ private final RectF mInnerRect = new RectF();
private float mLastAngle;
private Long mLastVibrateTime;
private int mHighlightColor;
- private int mBackgroundArcColor;
- private int mBackgroundArcColorDisabled;
- private int mRectPadding;
- private int mStrokeWidth;
- private float mHandleWidth; // little square indicator where user touches
- private float mTextOffset;
+ private final int mBackgroundArcColor;
+ private final int mBackgroundArcColorDisabled;
+ private final int mRectPadding;
+ private final int mStrokeWidth;
+ private final float mHandleWidth; // little square indicator where user touches
+ private final float mTextOffset;
Path mPath = new Path();
PathMeasure mPathMeasure = new PathMeasure();
@@ -322,8 +324,10 @@ public class RadialKnob extends View {
float progress = (Float) animation.getAnimatedValue();
mProgress = progress;
mLastAngle = mProgress * MAX_DEGREES;
- if (DEBUG) Log.i(TAG, "onAnimationUpdate(): mProgress: "
- + mProgress + ", mLastAngle: " + mLastAngle);
+ if (DEBUG) {
+ Log.i(TAG, "onAnimationUpdate(): mProgress: "
+ + mProgress + ", mLastAngle: " + mLastAngle);
+ }
setProgress(mProgress);
if (mOnKnobChangeListener != null) {
@@ -365,8 +369,9 @@ public class RadialKnob extends View {
final boolean inDeadzone = inCircle(x, y, center, center, radius);
final boolean inOuterCircle = inCircle(x, y, center, center, radius + 70);
- if (DEBUG)
+ if (DEBUG) {
Log.d(TAG, "inOuterCircle: " + inOuterCircle + ", inDeadzone: " + inDeadzone);
+ }
final float delta = getDelta(x, y);
final float angle = angleWithOffset(x, y, DEGREE_OFFSET);
@@ -408,9 +413,10 @@ public class RadialKnob extends View {
} else if (angle > 90) {
mOffProgress = 0;
}
- if (DEBUG)
+ if (DEBUG) {
Log.d(TAG, "OFF, touching angle: " + angle +
", mOffProgress: " + mOffProgress + ", delta " + delta);
+ }
// we want at least 1%, how many degrees = 1%? + a little padding
final float onePercentInDegrees = (MAX_DEGREES / 100) + 1f;
if (mOffProgress > 15 && angle < MAX_DEGREES
@@ -537,15 +543,11 @@ public class RadialKnob extends View {
private static boolean inCircle(float x, float y, float circleCenterX, float circleCenterY,
- float circleRadius) {
+ float circleRadius) {
double dx = Math.pow(x - circleCenterX, 2);
double dy = Math.pow(y - circleCenterY, 2);
- if ((dx + dy) < Math.pow(circleRadius, 2)) {
- return true;
- } else {
- return false;
- }
+ return (dx + dy) < Math.pow(circleRadius, 2);
}
@Override
diff --git a/src/org/lineageos/audiofx/preset/InfinitePagerAdapter.java b/src/org/lineageos/audiofx/preset/InfinitePagerAdapter.java
index eaabd02..a363233 100644
--- a/src/org/lineageos/audiofx/preset/InfinitePagerAdapter.java
+++ b/src/org/lineageos/audiofx/preset/InfinitePagerAdapter.java
@@ -30,7 +30,7 @@ public class InfinitePagerAdapter extends PagerAdapter {
private static final String TAG = "InfinitePagerAdapter";
private static final boolean DEBUG = false;
- private PagerAdapter adapter;
+ private final PagerAdapter adapter;
public InfinitePagerAdapter(PagerAdapter adapter) {
this.adapter = adapter;
@@ -108,4 +108,4 @@ public class InfinitePagerAdapter extends PagerAdapter {
Log.d(TAG, message);
}
}
-} \ No newline at end of file
+}
diff --git a/src/org/lineageos/audiofx/preset/InfiniteViewPager.java b/src/org/lineageos/audiofx/preset/InfiniteViewPager.java
index c51ed27..b083ac4 100644
--- a/src/org/lineageos/audiofx/preset/InfiniteViewPager.java
+++ b/src/org/lineageos/audiofx/preset/InfiniteViewPager.java
@@ -27,8 +27,8 @@ import org.lineageos.audiofx.activity.EqualizerManager;
import org.lineageos.audiofx.activity.MasterConfigControl;
/**
- * A {@link ViewPager} that allows pseudo-infinite paging with a wrap-around effect. Should be used with an {@link
- * InfinitePagerAdapter}.
+ * A {@link ViewPager} that allows pseudo-infinite paging with a wrap-around effect. Should be used
+ * with an {@link InfinitePagerAdapter}.
*/
public class InfiniteViewPager extends ViewPager {
diff --git a/src/org/lineageos/audiofx/preset/PresetPagerAdapter.java b/src/org/lineageos/audiofx/preset/PresetPagerAdapter.java
index f7ad6f5..ee9167a 100644
--- a/src/org/lineageos/audiofx/preset/PresetPagerAdapter.java
+++ b/src/org/lineageos/audiofx/preset/PresetPagerAdapter.java
@@ -79,5 +79,4 @@ public class PresetPagerAdapter extends PagerAdapter {
}
-
}
diff --git a/src/org/lineageos/audiofx/receiver/ServiceDispatcher.java b/src/org/lineageos/audiofx/receiver/ServiceDispatcher.java
index cfd2bd4..9e9a35b 100644
--- a/src/org/lineageos/audiofx/receiver/ServiceDispatcher.java
+++ b/src/org/lineageos/audiofx/receiver/ServiceDispatcher.java
@@ -45,7 +45,7 @@ public class ServiceDispatcher extends BroadcastReceiver {
} else if (action.equals(LineageAudioManager.ACTION_AUDIO_SESSIONS_CHANGED)) {
// callback from LineageAudioService
- final AudioSessionInfo info = (AudioSessionInfo) intent.getParcelableExtra(
+ final AudioSessionInfo info = intent.getParcelableExtra(
LineageAudioManager.EXTRA_SESSION_INFO);
boolean added = intent.getBooleanExtra(LineageAudioManager.EXTRA_SESSION_ADDED, false);
service.putExtra(LineageAudioManager.EXTRA_SESSION_INFO, info);
diff --git a/src/org/lineageos/audiofx/service/AudioFxService.java b/src/org/lineageos/audiofx/service/AudioFxService.java
index a9e71ea..3368e8f 100644
--- a/src/org/lineageos/audiofx/service/AudioFxService.java
+++ b/src/org/lineageos/audiofx/service/AudioFxService.java
@@ -17,7 +17,6 @@ package org.lineageos.audiofx.service;
import android.app.Service;
import android.content.Intent;
-import android.content.res.Configuration;
import android.media.AudioDeviceInfo;
import android.media.AudioManager;
import android.media.audiofx.AudioEffect;
@@ -29,22 +28,19 @@ import android.util.Log;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
-import org.lineageos.audiofx.R;
-import org.lineageos.audiofx.activity.MasterConfigControl;
import org.lineageos.audiofx.backends.EffectSet;
import java.lang.ref.WeakReference;
-import java.util.Locale;
import lineageos.media.AudioSessionInfo;
import lineageos.media.LineageAudioManager;
/**
* This service is responsible for applying all requested effects from the AudioFX UI.
- *
- * Since the AudioFX UI allows for different configurations based on the current output device,
- * the service is also responsible for applying the effects properly based on user configuration,
- * and the current device output state.
+ * <p>
+ * Since the AudioFX UI allows for different configurations based on the current output device, the
+ * service is also responsible for applying the effects properly based on user configuration, and
+ * the current device output state.
*/
public class AudioFxService extends Service
implements AudioOutputChangeListener.AudioOutputChangedCallback {
@@ -59,13 +55,13 @@ public class AudioFxService extends Service
public static final String EXTRA_DEVICE = "device";
// flags for updateService to minimize DSP traffic
- public static final int EQ_CHANGED = 0x1;
- public static final int BASS_BOOST_CHANGED = 0x2;
- public static final int VIRTUALIZER_CHANGED = 0x4;
- public static final int TREBLE_BOOST_CHANGED = 0x8;
- public static final int VOLUME_BOOST_CHANGED = 0x10;
- public static final int REVERB_CHANGED = 0x20;
- public static final int ALL_CHANGED = 0xFF;
+ public static final int EQ_CHANGED = 0x1;
+ public static final int BASS_BOOST_CHANGED = 0x2;
+ public static final int VIRTUALIZER_CHANGED = 0x4;
+ public static final int TREBLE_BOOST_CHANGED = 0x8;
+ public static final int VOLUME_BOOST_CHANGED = 0x10;
+ public static final int REVERB_CHANGED = 0x20;
+ public static final int ALL_CHANGED = 0xFF;
// flags from audio.h, used by session callbacks
static final int AUDIO_OUTPUT_FLAG_FAST = 0x4;
@@ -173,7 +169,7 @@ public class AudioFxService extends Service
} else if (action.equals(LineageAudioManager.ACTION_AUDIO_SESSIONS_CHANGED)) {
- final AudioSessionInfo info = (AudioSessionInfo) intent.getParcelableExtra(
+ final AudioSessionInfo info = intent.getParcelableExtra(
LineageAudioManager.EXTRA_SESSION_INFO);
if (info != null && info.getSessionId() > 0) {
boolean added = intent.getBooleanExtra(
@@ -215,8 +211,9 @@ public class AudioFxService extends Service
mCurrentDevice = outputDevice;
- if (DEBUG)
+ if (DEBUG) {
Log.d(TAG, "Broadcasting device changed event");
+ }
// Update the UI with the change
Intent intent = new Intent(ACTION_DEVICE_OUTPUT_CHANGED);
diff --git a/src/org/lineageos/audiofx/service/AudioOutputChangeListener.java b/src/org/lineageos/audiofx/service/AudioOutputChangeListener.java
index c205907..abf0a00 100644
--- a/src/org/lineageos/audiofx/service/AudioOutputChangeListener.java
+++ b/src/org/lineageos/audiofx/service/AudioOutputChangeListener.java
@@ -39,10 +39,11 @@ public class AudioOutputChangeListener extends AudioDeviceCallback {
private final Handler mHandler;
private int mLastDevice = -1;
- private final ArrayList<AudioOutputChangedCallback> mCallbacks = new ArrayList<AudioOutputChangedCallback>();
+ private final ArrayList<AudioOutputChangedCallback> mCallbacks =
+ new ArrayList<AudioOutputChangedCallback>();
public interface AudioOutputChangedCallback {
- public void onAudioOutputChanged(boolean firstChange, AudioDeviceInfo outputDevice);
+ void onAudioOutputChanged(boolean firstChange, AudioDeviceInfo outputDevice);
}
public AudioOutputChangeListener(Context context, Handler handler) {
@@ -72,7 +73,7 @@ public class AudioOutputChangeListener extends AudioDeviceCallback {
private void callback() {
synchronized (mCallbacks) {
- final AudioDeviceInfo device = getCurrentDevice();
+ final AudioDeviceInfo device = getCurrentDevice();
if (device == null) {
Log.w(TAG, "Unable to determine audio device!");
@@ -84,7 +85,7 @@ public class AudioOutputChangeListener extends AudioDeviceCallback {
" type: " + device.getType() +
" name: " + device.getProductName() +
" address: " + device.getAddress() +
- " [" + device.toString() + "]");
+ " [" + device + "]");
mLastDevice = device.getId();
mHandler.post(new Runnable() {
@Override
@@ -135,7 +136,7 @@ public class AudioOutputChangeListener extends AudioDeviceCallback {
}
public AudioDeviceInfo getDeviceById(int id) {
- for (AudioDeviceInfo ai : mAudioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS)) {
+ for (AudioDeviceInfo ai : mAudioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS)) {
if (ai.getId() == id) {
return ai;
}
diff --git a/src/org/lineageos/audiofx/service/DevicePreferenceManager.java b/src/org/lineageos/audiofx/service/DevicePreferenceManager.java
index 173e46e..7c1e7b8 100644
--- a/src/org/lineageos/audiofx/service/DevicePreferenceManager.java
+++ b/src/org/lineageos/audiofx/service/DevicePreferenceManager.java
@@ -113,8 +113,8 @@ public class DevicePreferenceManager
/**
* This method sets some sane defaults for presets, device defaults, etc
* <p/>
- * First we read presets from the system, then adjusts some setting values
- * for some better defaults!
+ * First we read presets from the system, then adjusts some setting values for some better
+ * defaults!
*/
private void saveAndApplyDefaults(boolean overridePrevious) {
if (DEBUG) {
@@ -189,7 +189,8 @@ public class DevicePreferenceManager
editor.putBoolean(AUDIOFX_GLOBAL_HAS_VIRTUALIZER, temp.hasVirtualizer());
editor.putBoolean(AUDIOFX_GLOBAL_HAS_REVERB, temp.hasReverb());
editor.putBoolean(AUDIOFX_GLOBAL_HAS_BASSBOOST, temp.hasBassBoost());
- editor.putBoolean(AUDIOFX_GLOBAL_HAS_MAXXAUDIO, temp.getBrand() == Constants.EFFECT_TYPE_MAXXAUDIO);
+ editor.putBoolean(AUDIOFX_GLOBAL_HAS_MAXXAUDIO,
+ temp.getBrand() == Constants.EFFECT_TYPE_MAXXAUDIO);
editor.putBoolean(AUDIOFX_GLOBAL_HAS_DTS, temp.getBrand() == Constants.EFFECT_TYPE_DTS);
editor.commit();
temp.release();
@@ -199,7 +200,7 @@ public class DevicePreferenceManager
prefs
.edit()
.putInt(Constants.AUDIOFX_GLOBAL_PREFS_VERSION_INT,
- CURRENT_PREFS_INT_VERSION)
+ CURRENT_PREFS_INT_VERSION)
.putBoolean(Constants.SAVED_DEFAULTS, true)
.commit();
}
@@ -214,8 +215,8 @@ public class DevicePreferenceManager
}
/**
- * This method sets up some *persisted* defaults.
- * Prereq: saveDefaults() must have been run before this can apply its defaults properly.
+ * This method sets up some *persisted* defaults. Prereq: saveDefaults() must have been run
+ * before this can apply its defaults properly.
*/
private void applyDefaults(boolean overridePrevious) {
if (DEBUG) {
@@ -300,9 +301,9 @@ public class DevicePreferenceManager
int idx = findInList(smallSpeakers, presetNames);
if (idx >= 0) {
speakerPrefs.edit()
- .putBoolean(DEVICE_AUDIOFX_GLOBAL_ENABLE, true)
- .putString(DEVICE_AUDIOFX_EQ_PRESET, String.valueOf(idx))
- .commit();
+ .putBoolean(DEVICE_AUDIOFX_GLOBAL_ENABLE, true)
+ .putString(DEVICE_AUDIOFX_EQ_PRESET, String.valueOf(idx))
+ .commit();
}
}
diff --git a/src/org/lineageos/audiofx/service/SessionManager.java b/src/org/lineageos/audiofx/service/SessionManager.java
index 203de37..e1a1c68 100644
--- a/src/org/lineageos/audiofx/service/SessionManager.java
+++ b/src/org/lineageos/audiofx/service/SessionManager.java
@@ -111,14 +111,13 @@ class SessionManager implements AudioOutputChangeListener.AudioOutputChangedCall
}
/**
- * Callback which listens for session updates from AudioPolicyManager. This is a
- * feature added by LineageOS which notifies when sessions are created or
- * destroyed on a particular stream. This is independent of the standard control
- * intents and should not conflict with them. This feature may not be available on
- * all devices.
- *
- * Default logic is to do our best to only attach to music streams. We don't attach
- * to mono streams by default since these are usually notifications/ringtones/etc.
+ * Callback which listens for session updates from AudioPolicyManager. This is a feature added
+ * by LineageOS which notifies when sessions are created or destroyed on a particular stream.
+ * This is independent of the standard control intents and should not conflict with them. This
+ * feature may not be available on all devices.
+ * <p>
+ * Default logic is to do our best to only attach to music streams. We don't attach to mono
+ * streams by default since these are usually notifications/ringtones/etc.
*/
public boolean shouldHandleSession(AudioSessionInfo info) {
final boolean music = info.getStream() == AudioManager.STREAM_MUSIC;
@@ -131,7 +130,8 @@ class SessionManager implements AudioOutputChangeListener.AudioOutputChangedCall
synchronized (mAudioSessionsL) {
// Never auto-attach is someone is recording! We don't want to interfere
// with any sort of loopback mechanisms.
- final boolean recording = AudioSystem.isSourceActive(0) || AudioSystem.isSourceActive(6);
+ final boolean recording = AudioSystem.isSourceActive(0) || AudioSystem.isSourceActive(
+ 6);
if (recording) {
Log.w(TAG, "Recording in progress, not performing auto-attach!");
return;
@@ -180,7 +180,7 @@ class SessionManager implements AudioOutputChangeListener.AudioOutputChangedCall
/**
* Update the backend with our changed preferences.
- *
+ * <p>
* This must only be called from the HandlerThread!
*/
private void updateBackendLocked(int flags, EffectSet session) {
@@ -191,7 +191,8 @@ class SessionManager implements AudioOutputChangeListener.AudioOutputChangedCall
final SharedPreferences prefs = mDevicePrefs.getCurrentDevicePrefs();
if (DEBUG) {
- Log.i(TAG, "+++ updateBackend() called with flags=[" + flags + "], session=[" + session + "]");
+ Log.i(TAG, "+++ updateBackend() called with flags=[" + flags + "], session=[" + session
+ + "]");
}
if (session == null) {
@@ -220,7 +221,8 @@ class SessionManager implements AudioOutputChangeListener.AudioOutputChangedCall
session.enableEqualizer(true);
String savedPreset = prefs.getString(DEVICE_AUDIOFX_EQ_PRESET_LEVELS, null);
if (savedPreset != null) {
- session.setEqualizerLevelsDecibels(EqUtils.stringBandsToFloats(savedPreset));
+ session.setEqualizerLevelsDecibels(
+ EqUtils.stringBandsToFloats(savedPreset));
}
}
} catch (Exception e) {
@@ -279,7 +281,8 @@ class SessionManager implements AudioOutputChangeListener.AudioOutputChangedCall
try {
if ((flags & VOLUME_BOOST_CHANGED) > 0 && session.hasVolumeBoost()) {
// maxx volume
- session.enableVolumeBoost(prefs.getBoolean(DEVICE_AUDIOFX_MAXXVOLUME_ENABLE, false));
+ session.enableVolumeBoost(
+ prefs.getBoolean(DEVICE_AUDIOFX_MAXXVOLUME_ENABLE, false));
}
} catch (Exception e) {
Log.e(TAG, "Error enabling volume boost!", e);
@@ -291,7 +294,8 @@ class SessionManager implements AudioOutputChangeListener.AudioOutputChangedCall
}
}
if (DEBUG) {
- Log.i(TAG, "--- updateBackend() called with flags=[" + flags + "], session=[" + session + "]");
+ Log.i(TAG, "--- updateBackend() called with flags=[" + flags + "], session=[" + session
+ + "]");
}
}
@@ -320,7 +324,8 @@ class SessionManager implements AudioOutputChangeListener.AudioOutputChangedCall
session = new EffectsFactory()
.createEffectSet(mContext, sessionId, mCurrentDevice);
} catch (Exception e) {
- Log.e(TAG, "couldn't create effects for session id: " + sessionId, e);
+ Log.e(TAG, "couldn't create effects for session id: " + sessionId,
+ e);
break;
}
mAudioSessionsL.put(sessionId, session);
@@ -362,7 +367,8 @@ class SessionManager implements AudioOutputChangeListener.AudioOutputChangedCall
final int N = mAudioSessionsL.size();
for (int i = 0; i < N; i++) {
sessionId = mAudioSessionsL.keyAt(i);
- mHandler.obtainMessage(MSG_UPDATE_FOR_SESSION, flags, 0, sessionId).sendToTarget();
+ mHandler.obtainMessage(MSG_UPDATE_FOR_SESSION, flags, 0,
+ sessionId).sendToTarget();
}
break;
@@ -380,8 +386,10 @@ class SessionManager implements AudioOutputChangeListener.AudioOutputChangedCall
}
String device = getCurrentDeviceIdentifier();
- if (DEBUG) Log.i(TAG, "updating DSP for sessionId=" + sessionId +
- ", device=" + device + " flags=" + flags);
+ if (DEBUG) {
+ Log.i(TAG, "updating DSP for sessionId=" + sessionId +
+ ", device=" + device + " flags=" + flags);
+ }
session = mAudioSessionsL.get(sessionId);
if (session != null) {
diff --git a/src/org/lineageos/audiofx/viewpagerindicator/CirclePageIndicator.java b/src/org/lineageos/audiofx/viewpagerindicator/CirclePageIndicator.java
index 9d53d95..872e16e 100644
--- a/src/org/lineageos/audiofx/viewpagerindicator/CirclePageIndicator.java
+++ b/src/org/lineageos/audiofx/viewpagerindicator/CirclePageIndicator.java
@@ -16,6 +16,10 @@
*/
package org.lineageos.audiofx.viewpagerindicator;
+import static android.graphics.Paint.ANTI_ALIAS_FLAG;
+import static android.widget.LinearLayout.HORIZONTAL;
+import static android.widget.LinearLayout.VERTICAL;
+
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
@@ -34,13 +38,9 @@ import androidx.viewpager.widget.ViewPager;
import org.lineageos.audiofx.R;
-import static android.graphics.Paint.ANTI_ALIAS_FLAG;
-import static android.widget.LinearLayout.HORIZONTAL;
-import static android.widget.LinearLayout.VERTICAL;
-
/**
- * Draws circles (one for each view). The current view position is filled and
- * others are only stroked.
+ * Draws circles (one for each view). The current view position is filled and others are only
+ * stroked.
*/
public class CirclePageIndicator extends View implements PageIndicator {
private static final int INVALID_POINTER = -1;
@@ -81,25 +81,33 @@ public class CirclePageIndicator extends View implements PageIndicator {
final Resources res = getResources();
final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color);
final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color);
- final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
+ final int defaultOrientation = res.getInteger(
+ R.integer.default_circle_indicator_orientation);
final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color);
- final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width);
+ final float defaultStrokeWidth = res.getDimension(
+ R.dimen.default_circle_indicator_stroke_width);
final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered);
final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap);
//Retrieve styles attributes
- TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, 0);
+ TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator,
+ defStyle, 0);
mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered);
- mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation);
+ mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation,
+ defaultOrientation);
mPaintPageFill.setStyle(Style.FILL);
- mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor));
+ mPaintPageFill.setColor(
+ a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor));
mPaintStroke.setStyle(Style.STROKE);
- mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor));
- mPaintStroke.setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth));
+ mPaintStroke.setColor(
+ a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor));
+ mPaintStroke.setStrokeWidth(
+ a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth));
mPaintFill.setStyle(Style.FILL);
- mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor));
+ mPaintFill.setColor(
+ a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor));
mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius);
mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap);
@@ -151,7 +159,8 @@ public class CirclePageIndicator extends View implements PageIndicator {
break;
default:
- throw new IllegalArgumentException("Orientation must be either HORIZONTAL or VERTICAL.");
+ throw new IllegalArgumentException(
+ "Orientation must be either HORIZONTAL or VERTICAL.");
}
}
@@ -232,7 +241,8 @@ public class CirclePageIndicator extends View implements PageIndicator {
final float shortOffset = shortPaddingBefore + mRadius;
float longOffset = longPaddingBefore + mRadius;
if (mCentered) {
- longOffset += ((longSize - longPaddingBefore - longPaddingAfter) / 2.0f) - ((count * threeRadius) / 2.0f);
+ longOffset += ((longSize - longPaddingBefore - longPaddingAfter) / 2.0f) - (
+ (count * threeRadius) / 2.0f);
}
float dX;
@@ -255,7 +265,7 @@ public class CirclePageIndicator extends View implements PageIndicator {
}
// Only paint fill if not completely transparent
if (mPaintPageFill.getAlpha() > 0) {
- canvas.drawCircle(dX, dY, (float) (pageFillRadius/1.5f), mPaintPageFill);
+ canvas.drawCircle(dX, dY, pageFillRadius / 1.5f, mPaintPageFill);
}
// Only paint stroke if a stroke width was non-zero
@@ -295,7 +305,8 @@ public class CirclePageIndicator extends View implements PageIndicator {
break;
case MotionEvent.ACTION_MOVE: {
- final int activePointerIndex = MotionEventCompat.findPointerIndex(ev, mActivePointerId);
+ final int activePointerIndex = MotionEventCompat.findPointerIndex(ev,
+ mActivePointerId);
final float x = MotionEventCompat.getX(ev, activePointerIndex);
final float deltaX = x - mLastMotionX;
@@ -355,7 +366,8 @@ public class CirclePageIndicator extends View implements PageIndicator {
final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
mActivePointerId = MotionEventCompat.getPointerId(ev, newPointerIndex);
}
- mLastMotionX = MotionEventCompat.getX(ev, MotionEventCompat.findPointerIndex(ev, mActivePointerId));
+ mLastMotionX = MotionEventCompat.getX(ev,
+ MotionEventCompat.findPointerIndex(ev, mActivePointerId));
break;
}
@@ -454,8 +466,7 @@ public class CirclePageIndicator extends View implements PageIndicator {
/**
* Determines the width of this view
*
- * @param measureSpec
- * A measureSpec packed into an int
+ * @param measureSpec A measureSpec packed into an int
* @return The width of the view, honoring constraints from measureSpec
*/
private int measureLong(int measureSpec) {
@@ -469,7 +480,7 @@ public class CirclePageIndicator extends View implements PageIndicator {
} else {
//Calculate the width according the views count
final int count = mViewPager.getAdapter().getCount();
- result = (int)(getPaddingLeft() + getPaddingRight()
+ result = (int) (getPaddingLeft() + getPaddingRight()
+ (count * 2 * mRadius) + (count - 1) * mRadius + 1);
//Respect AT_MOST value if that was what is called for by measureSpec
if (specMode == MeasureSpec.AT_MOST) {
@@ -482,8 +493,7 @@ public class CirclePageIndicator extends View implements PageIndicator {
/**
* Determines the height of this view
*
- * @param measureSpec
- * A measureSpec packed into an int
+ * @param measureSpec A measureSpec packed into an int
* @return The height of the view, honoring constraints from measureSpec
*/
private int measureShort(int measureSpec) {
@@ -496,7 +506,7 @@ public class CirclePageIndicator extends View implements PageIndicator {
result = specSize;
} else {
//Measure the height
- result = (int)(2 * mRadius + getPaddingTop() + getPaddingBottom() + 1);
+ result = (int) (2 * mRadius + getPaddingTop() + getPaddingBottom() + 1);
//Respect AT_MOST value if that was what is called for by measureSpec
if (specMode == MeasureSpec.AT_MOST) {
result = Math.min(result, specSize);
diff --git a/src/org/lineageos/audiofx/viewpagerindicator/PageIndicator.java b/src/org/lineageos/audiofx/viewpagerindicator/PageIndicator.java
index 9e9fc7b..97bfa34 100644
--- a/src/org/lineageos/audiofx/viewpagerindicator/PageIndicator.java
+++ b/src/org/lineageos/audiofx/viewpagerindicator/PageIndicator.java
@@ -20,8 +20,8 @@ package org.lineageos.audiofx.viewpagerindicator;
import androidx.viewpager.widget.ViewPager;
/**
- * A PageIndicator is responsible to show an visual indicator on the total views
- * number and the current visible view.
+ * A PageIndicator is responsible to show an visual indicator on the total views number and the
+ * current visible view.
*/
public interface PageIndicator extends ViewPager.OnPageChangeListener {
/**
diff --git a/src/org/lineageos/audiofx/widget/Biquad.java b/src/org/lineageos/audiofx/widget/Biquad.java
index 216acde..d50dd42 100644
--- a/src/org/lineageos/audiofx/widget/Biquad.java
+++ b/src/org/lineageos/audiofx/widget/Biquad.java
@@ -26,15 +26,15 @@ public class Biquad {
public void setHighShelf(double centerFrequency, double samplingFrequency,
double dbGain, double slope) {
double w0 = 2 * Math.PI * centerFrequency / samplingFrequency;
- double a = Math.pow(10, dbGain/40);
+ double a = Math.pow(10, dbGain / 40);
double alpha = Math.sin(w0) / 2 * Math.sqrt((a + 1 / a) * (1 / slope - 1) + 2);
- mB0 = new Complex(a*((a+1) + (a-1) *Math.cos(w0) + 2*Math.sqrt(a)*alpha), 0);
- mB1 = new Complex(-2*a*((a-1) + (a+1)*Math.cos(w0)), 0);
- mB2 = new Complex(a*((a+1) + (a-1) *Math.cos(w0) - 2*Math.sqrt(a)*alpha), 0);
- mA0 = new Complex((a+1) - (a-1) *Math.cos(w0) + 2*Math.sqrt(a)*alpha, 0);
- mA1 = new Complex(2*((a-1) - (a+1) *Math.cos(w0)), 0);
- mA2 = new Complex((a+1) - (a-1) *Math.cos(w0) - 2*Math.sqrt(a)*alpha, 0);
+ mB0 = new Complex(a * ((a + 1) + (a - 1) * Math.cos(w0) + 2 * Math.sqrt(a) * alpha), 0);
+ mB1 = new Complex(-2 * a * ((a - 1) + (a + 1) * Math.cos(w0)), 0);
+ mB2 = new Complex(a * ((a + 1) + (a - 1) * Math.cos(w0) - 2 * Math.sqrt(a) * alpha), 0);
+ mA0 = new Complex((a + 1) - (a - 1) * Math.cos(w0) + 2 * Math.sqrt(a) * alpha, 0);
+ mA1 = new Complex(2 * ((a - 1) - (a + 1) * Math.cos(w0)), 0);
+ mA2 = new Complex((a + 1) - (a - 1) * Math.cos(w0) - 2 * Math.sqrt(a) * alpha, 0);
}
public Complex evaluateTransfer(Complex z) {
diff --git a/src/org/lineageos/audiofx/widget/EqualizerSurface.java b/src/org/lineageos/audiofx/widget/EqualizerSurface.java
index 3a11e7f..ea6934d 100644
--- a/src/org/lineageos/audiofx/widget/EqualizerSurface.java
+++ b/src/org/lineageos/audiofx/widget/EqualizerSurface.java
@@ -12,7 +12,7 @@
* 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.
- *
+ *
* - Original code by Antti S. Lankila for DSPManager
* - Modified extensively by cyanogen for multi-band support
*/
@@ -36,27 +36,27 @@ import android.util.Log;
import android.view.MotionEvent;
import android.view.SurfaceView;
import android.view.View;
-
import android.view.animation.DecelerateInterpolator;
+
import org.lineageos.audiofx.R;
import java.util.Arrays;
public class EqualizerSurface extends SurfaceView implements ValueAnimator.AnimatorUpdateListener {
- private static int SAMPLING_RATE = 44100;
+ private static final int SAMPLING_RATE = 44100;
private int mWidth;
private int mHeight;
private float mMinFreq = 10;
private float mMaxFreq = 21000;
-
+
private float mMinDB = -15;
private float mMaxDB = 15;
-
+
private int mNumBands = 6;
-
+
private float[] mLevels = new float[mNumBands];
private float[] mTargetLevels = new float[mNumBands];
private float[] mCenterFreqs = new float[mNumBands];
@@ -76,7 +76,8 @@ public class EqualizerSurface extends SurfaceView implements ValueAnimator.Anima
mWhite = new Paint();
mWhite.setColor(getResources().getColor(R.color.color_grey));
mWhite.setStyle(Style.STROKE);
- mWhite.setTextSize(mTextSize = context.getResources().getDimensionPixelSize(R.dimen.eq_label_text_size));
+ mWhite.setTextSize(mTextSize =
+ context.getResources().getDimensionPixelSize(R.dimen.eq_label_text_size));
mWhite.setTypeface(Typeface.DEFAULT_BOLD);
mWhite.setAntiAlias(true);
@@ -112,30 +113,31 @@ public class EqualizerSurface extends SurfaceView implements ValueAnimator.Anima
/**
* Listener for bands being modified via touch events
- *
- * Invoked with the index of the modified band, and the
- * new value in dB. If the widget is read-only, will set
- * changed = false.
- *
+ * <p>
+ * Invoked with the index of the modified band, and the new value in dB. If the widget is
+ * read-only, will set changed = false.
*/
public interface BandUpdatedListener {
- public void onBandUpdated(int band, float dB);
- public void onBandAnimating(int band, float dB);
- public void onBandAnimationCompleted();
+ void onBandUpdated(int band, float dB);
+
+ void onBandAnimating(int band, float dB);
+
+ void onBandAnimationCompleted();
}
-
+
public void setBandLevelRange(float minDB, float maxDB) {
mMinDB = minDB;
mMaxDB = maxDB;
}
-
+
public void setCenterFreqs(float[] centerFreqsKHz) {
mNumBands = centerFreqsKHz.length;
mLevels = new float[mNumBands];
mCenterFreqs = Arrays.copyOf(centerFreqsKHz, mNumBands);
System.arraycopy(centerFreqsKHz, 0, mCenterFreqs, 0, mNumBands);
mMinFreq = mCenterFreqs[0] / 2;
- mMaxFreq = (float) Math.pow(mCenterFreqs[mNumBands - 1], 2) / mCenterFreqs[mNumBands -2] / 2;
+ mMaxFreq = (float) Math.pow(mCenterFreqs[mNumBands - 1], 2) / mCenterFreqs[mNumBands - 2]
+ / 2;
}
public float[] softCopyLevels() {
@@ -161,7 +163,7 @@ public class EqualizerSurface extends SurfaceView implements ValueAnimator.Anima
mLevels = b.getFloatArray("levels");
}
*/
-
+
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
@@ -171,11 +173,11 @@ public class EqualizerSurface extends SurfaceView implements ValueAnimator.Anima
}
/**
- * Returns a color that is assumed to be blended against black background,
- * assuming close to sRGB behavior of screen (gamma 2.2 approximation).
+ * Returns a color that is assumed to be blended against black background, assuming close to
+ * sRGB behavior of screen (gamma 2.2 approximation).
*
* @param intensity desired physical intensity of color component
- * @param alpha alpha value of color component
+ * @param alpha alpha value of color component
*/
private static int gamma(float intensity, float alpha) {
/* intensity = (component * alpha)^2.2
@@ -203,26 +205,26 @@ public class EqualizerSurface extends SurfaceView implements ValueAnimator.Anima
* holo_blue < 0
* holo_blue_dark < 3
*/
- int[] responseColors = new int[] {
- res.getColor(R.color.eq_yellow),
- res.getColor(R.color.eq_green),
- res.getColor(R.color.eq_holo_bright),
- res.getColor(R.color.eq_holo_blue),
- res.getColor(R.color.eq_holo_dark)
+ int[] responseColors = new int[]{
+ res.getColor(R.color.eq_yellow),
+ res.getColor(R.color.eq_green),
+ res.getColor(R.color.eq_holo_bright),
+ res.getColor(R.color.eq_holo_blue),
+ res.getColor(R.color.eq_holo_dark)
};
- float[] responsePositions = new float[] {
- 0, 0.2f, 0.45f, 0.6f, 1f
+ float[] responsePositions = new float[]{
+ 0, 0.2f, 0.45f, 0.6f, 1f
};
mFrequencyResponseBg.setShader(new LinearGradient(0, 0, 0, mHeight - mTextSize,
responseColors, responsePositions, Shader.TileMode.CLAMP));
- int[] barColors = new int[] {
+ int[] barColors = new int[]{
res.getColor(R.color.cb_shader),
res.getColor(R.color.cb_shader_alpha)
};
- float[] barPositions = new float[] {
- 0.95f, 1f
+ float[] barPositions = new float[]{
+ 0.95f, 1f
};
// mControlBar.setShader(new LinearGradient(0, 0, 0, mHeight - mTextSize,
@@ -232,6 +234,7 @@ public class EqualizerSurface extends SurfaceView implements ValueAnimator.Anima
int mPasses = 140;
float[] mStartLevels;
float[] mDeltas;
+
public void setBands(float[] bands) {
if (mAnimation != null) {
mAnimation.cancel();
@@ -247,7 +250,7 @@ public class EqualizerSurface extends SurfaceView implements ValueAnimator.Anima
mDeltas[i] = mTargetLevels[i] - mStartLevels[i];
}
- mAnimation = ValueAnimator.ofFloat(0f,1f);
+ mAnimation = ValueAnimator.ofFloat(0f, 1f);
mAnimation.addUpdateListener(this);
mAnimation.addListener(new Animator.AnimatorListener() {
@Override
@@ -283,7 +286,7 @@ public class EqualizerSurface extends SurfaceView implements ValueAnimator.Anima
@Override
public void onAnimationUpdate(ValueAnimator animation) {
- final float fraction = (Float) animation.getAnimatedFraction();
+ final float fraction = animation.getAnimatedFraction();
// final float fraction = ((Float) (animation.getAnimatedValue())).floatValue();
for (int i = 0; i < mNumBands; i++) {
@@ -327,8 +330,8 @@ public class EqualizerSurface extends SurfaceView implements ValueAnimator.Anima
Path freqResponse = new Path();
Complex[] zn = new Complex[biquads.length];
// final int passes = 140;
- for (int i = 0; i < mPasses+1; i ++) {
- double freq = reverseProjectX(i / (float)mPasses);
+ for (int i = 0; i < mPasses + 1; i++) {
+ double freq = reverseProjectX(i / (float) mPasses);
double omega = freq / SAMPLING_RATE * Math.PI * 2;
Complex z = new Complex(Math.cos(omega), Math.sin(omega));
@@ -386,7 +389,7 @@ public class EqualizerSurface extends SurfaceView implements ValueAnimator.Anima
// canvas.drawText(String.format("%+d", (int)dB), 1, (y - 1), mWhite);
}
- for (int i = 0; i < mNumBands; i ++) {
+ for (int i = 0; i < mNumBands; i++) {
float freq = mCenterFreqs[i];
float x = projectX(freq) * mWidth;
@@ -399,28 +402,28 @@ public class EqualizerSurface extends SurfaceView implements ValueAnimator.Anima
int targetHeight = (mHeight);
- int halfX = mBarWidth/2;
+ int halfX = mBarWidth / 2;
if (y > targetHeight) {
int diff = (int) Math.abs(targetHeight - y);
- canvas.drawRect(x-halfX, y+diff, x+halfX, targetHeight, mControlBar);
+ canvas.drawRect(x - halfX, y + diff, x + halfX, targetHeight, mControlBar);
} else {
- canvas.drawRect(x-halfX, y, x+halfX, targetHeight, mControlBar);
+ canvas.drawRect(x - halfX, y, x + halfX, targetHeight, mControlBar);
}
canvas.drawText(frequencyText, x, mWhite.getTextSize(), mControlBarText);
- canvas.drawText(String.format("%+1.1f", mLevels[i]), x, y-1, mControlBarText);
+ canvas.drawText(String.format("%+1.1f", mLevels[i]), x, y - 1, mControlBarText);
}
}
public void registerBandUpdatedListener(BandUpdatedListener listener) {
mBandUpdatedListener = listener;
}
-
+
@Override
public boolean onTouchEvent(MotionEvent event) {
if (!isEnabled()) {
- return false;
+ return false;
}
float x = event.getX();
@@ -436,13 +439,13 @@ public class EqualizerSurface extends SurfaceView implements ValueAnimator.Anima
} else if (level > mMaxDB) {
level = mMaxDB;
}
-
+
setBand(band, level);
-
+
if (mBandUpdatedListener != null) {
mBandUpdatedListener.onBandUpdated(band, level);
}
-
+
return true;
}
@@ -477,7 +480,7 @@ public class EqualizerSurface extends SurfaceView implements ValueAnimator.Anima
public int findClosest(float px) {
int idx = 0;
float best = 1e9f;
- for (int i = 0; i < mNumBands; i ++) {
+ for (int i = 0; i < mNumBands; i++) {
float freq = mCenterFreqs[i];
float cx = projectX(freq) * mWidth;
float distance = Math.abs(cx - px);