mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-24 04:45:32 -04:00
universal7885: Format Kotlin code using ktlint
* Also, refactor CameraLightSensor Signed-off-by: roynatech2544 <whiteshell2544@naver.com>
This commit is contained in:
parent
95d062a8b1
commit
3c7ca85990
35 changed files with 338 additions and 402 deletions
|
|
@ -13,38 +13,27 @@ import android.graphics.BitmapFactory
|
|||
import android.graphics.Color
|
||||
import android.graphics.ImageFormat
|
||||
import android.hardware.camera2.*
|
||||
import android.hardware.camera2.CameraManager.AvailabilityCallback
|
||||
import android.media.Image
|
||||
import android.media.ImageReader
|
||||
import android.net.Uri
|
||||
import android.os.*
|
||||
import android.provider.Settings
|
||||
import android.provider.Settings.SettingNotFoundException
|
||||
import android.util.Log
|
||||
import androidx.core.app.NotificationCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
open class CameraLightSensorService : Service() {
|
||||
var screenStateFilter: IntentFilter? = null
|
||||
class CameraLightSensorService : Service() {
|
||||
private lateinit var screenStateFilter: IntentFilter
|
||||
lateinit var mContext: Context
|
||||
private var mRegistered = false
|
||||
var destroy = false
|
||||
private var cameraDevice: CameraDevice? = null
|
||||
private var session: CameraCaptureSession? = null
|
||||
|
||||
@Volatile
|
||||
var avail = true
|
||||
private var imageReader: ImageReader? = null
|
||||
private var manager: CameraManager? = null
|
||||
private var mServiceStarted = false
|
||||
|
||||
@Volatile
|
||||
private var mLock = false
|
||||
private var mThreadRunning = false
|
||||
private lateinit var manager: CameraManager
|
||||
private lateinit var mCameraHandler: Handler
|
||||
private fun pushNotification(): Notification {
|
||||
val nm = mContext.getSystemService(NOTIFICATION_SERVICE) as NotificationManager
|
||||
val channel = NotificationChannel(
|
||||
mContext.basePackageName, "Useless Notification",
|
||||
mContext.basePackageName, "CameraLightSensor",
|
||||
NotificationManager.IMPORTANCE_NONE
|
||||
)
|
||||
channel.isBlockable = true
|
||||
|
|
@ -67,20 +56,7 @@ open class CameraLightSensorService : Service() {
|
|||
if (DEBUG) Log.d(TAG, "Destroying service")
|
||||
if (mRegistered) contentResolver!!.unregisterContentObserver(mSettingsObserver)
|
||||
mRegistered = false
|
||||
cameraDevice!!.close()
|
||||
if (session != null && avail) {
|
||||
try {
|
||||
session!!.abortCaptures()
|
||||
session!!.close()
|
||||
} catch (e: CameraAccessException) {
|
||||
Log.e(TAG, e.message)
|
||||
} catch (e2: IllegalStateException) {
|
||||
Log.e(TAG, "Session Already Closed")
|
||||
}
|
||||
}
|
||||
manager!!.unregisterAvailabilityCallback(availabilityCallback)
|
||||
avail = false
|
||||
destroy = true
|
||||
imageReader.close()
|
||||
stopForeground(true)
|
||||
super.onDestroy()
|
||||
}
|
||||
|
|
@ -92,14 +68,21 @@ open class CameraLightSensorService : Service() {
|
|||
private val mScreenStateReceiver: BroadcastReceiver = object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
if (intent.action == Intent.ACTION_USER_PRESENT) {
|
||||
onDisplayOn()
|
||||
mServiceStarted = true
|
||||
if (mPoolExecutor == null) {
|
||||
mPoolExecutor = ScheduledThreadPoolExecutor(4)
|
||||
mPoolExecutor!!.scheduleWithFixedDelay(
|
||||
mScheduler, 0, 2, TimeUnit.SECONDS
|
||||
)
|
||||
}
|
||||
} else if (intent.action == Intent.ACTION_SCREEN_OFF) {
|
||||
if (mServiceStarted) onDisplayOff()
|
||||
mServiceStarted = false
|
||||
if (mPoolExecutor != null) {
|
||||
mPoolExecutor!!.shutdown()
|
||||
mPoolExecutor = null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private val mScheduler = Runnable { readyCamera() }
|
||||
|
||||
// Make a listener for settings
|
||||
private var mSettingsObserver: ContentObserver =
|
||||
|
|
@ -116,11 +99,19 @@ open class CameraLightSensorService : Service() {
|
|||
) {
|
||||
registerReceiver(mScreenStateReceiver, screenStateFilter)
|
||||
mRegistered = true
|
||||
onDisplayOn()
|
||||
if (mPoolExecutor == null) {
|
||||
mPoolExecutor = ScheduledThreadPoolExecutor(4)
|
||||
mPoolExecutor!!.scheduleWithFixedDelay(
|
||||
mScheduler, 0, 2, TimeUnit.SECONDS
|
||||
)
|
||||
}
|
||||
} else {
|
||||
if (mRegistered) unregisterReceiver(mScreenStateReceiver)
|
||||
mRegistered = false
|
||||
onDisplayOff()
|
||||
if (mPoolExecutor != null) {
|
||||
mPoolExecutor!!.shutdown()
|
||||
mPoolExecutor = null
|
||||
}
|
||||
}
|
||||
} catch (e: SettingNotFoundException) {
|
||||
e.printStackTrace()
|
||||
|
|
@ -131,20 +122,6 @@ open class CameraLightSensorService : Service() {
|
|||
return true
|
||||
}
|
||||
}
|
||||
|
||||
private fun onDisplayOn() {
|
||||
if (DEBUG) Log.d(TAG, "Screen is on. Starting Service...")
|
||||
avail = true
|
||||
readyCamera()
|
||||
}
|
||||
|
||||
private fun onDisplayOff() {
|
||||
if (DEBUG) Log.d(TAG, "Screen is off. Stopping Service...")
|
||||
thread.interrupt()
|
||||
avail = false
|
||||
mThreadRunning = false
|
||||
}
|
||||
|
||||
private var cameraStateCallback: CameraDevice.StateCallback =
|
||||
object : CameraDevice.StateCallback() {
|
||||
override fun onOpened(camera: CameraDevice) {
|
||||
|
|
@ -164,24 +141,22 @@ open class CameraLightSensorService : Service() {
|
|||
private var sessionStateCallback: CameraCaptureSession.StateCallback =
|
||||
object : CameraCaptureSession.StateCallback() {
|
||||
override fun onReady(session: CameraCaptureSession) {
|
||||
if (!destroy) {
|
||||
this@CameraLightSensorService.session = session
|
||||
try {
|
||||
if (createCaptureRequest() == null) return
|
||||
try {
|
||||
session.capture(createCaptureRequest(), captureCallback, null)
|
||||
session.capture(createCaptureRequest(), null, mCameraHandler)
|
||||
} catch (e: CameraAccessException) {
|
||||
e.printStackTrace()
|
||||
} catch (e: IllegalStateException) {
|
||||
Log.w(TAG, "onReady: Session is NULL")
|
||||
}
|
||||
cameraDevice!!.close() session.close()
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "Camera is in use")
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onConfigured(session: CameraCaptureSession) {}
|
||||
override fun onConfigureFailed(session: CameraCaptureSession) {}
|
||||
}
|
||||
|
|
@ -198,12 +173,6 @@ open class CameraLightSensorService : Service() {
|
|||
e.printStackTrace()
|
||||
}
|
||||
img.close()
|
||||
if (DEBUG) Log.d(
|
||||
TAG,
|
||||
"ImageReader.OnImageAvailableListener: Closing Camera and Sessions.."
|
||||
)
|
||||
cameraDevice!!.close()
|
||||
session!!.close()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -212,16 +181,8 @@ open class CameraLightSensorService : Service() {
|
|||
manager = getSystemService(CAMERA_SERVICE) as CameraManager
|
||||
try {
|
||||
val pickedCamera = getCamera(manager)
|
||||
manager!!.registerAvailabilityCallback(availabilityCallback, null)
|
||||
manager!!.openCamera(pickedCamera, cameraStateCallback, null)
|
||||
imageReader =
|
||||
ImageReader.newInstance(50, 50, ImageFormat.JPEG, 2 /* images buffered */)
|
||||
imageReader?.setOnImageAvailableListener(onImageAvailableListener, null)
|
||||
if (!mThreadRunning) {
|
||||
val mMyThread = Thread(thread)
|
||||
mMyThread.start()
|
||||
mThreadRunning = true
|
||||
}
|
||||
manager.openCamera(pickedCamera, cameraStateCallback, mCameraHandler)
|
||||
imageReader.setOnImageAvailableListener(onImageAvailableListener, mCameraHandler)
|
||||
if (DEBUG) Log.d(TAG, "imageReader created")
|
||||
} catch (e: CameraAccessException) {
|
||||
Log.e(TAG, e.message)
|
||||
|
|
@ -244,13 +205,15 @@ open class CameraLightSensorService : Service() {
|
|||
}
|
||||
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
mContext = applicationContext
|
||||
val mCameraHandlerThread = HandlerThread("CameraLightSensor")
|
||||
mCameraHandlerThread.start()
|
||||
mCameraHandler = Handler(mCameraHandlerThread.looper)
|
||||
mContext = this
|
||||
@Suppress("SameParameterValue")
|
||||
startForeground(50, pushNotification(), ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA)
|
||||
batteryOptimization(mContext)
|
||||
mRegistered = false
|
||||
screenStateFilter = IntentFilter(Intent.ACTION_USER_PRESENT)
|
||||
screenStateFilter!!.addAction(Intent.ACTION_SCREEN_OFF)
|
||||
screenStateFilter.addAction(Intent.ACTION_SCREEN_OFF)
|
||||
try {
|
||||
if (Settings.System.getInt(contentResolver, Settings.System.SCREEN_BRIGHTNESS_MODE)
|
||||
== Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC
|
||||
|
|
@ -264,15 +227,13 @@ open class CameraLightSensorService : Service() {
|
|||
val setting = Settings.System.getUriFor(Settings.System.SCREEN_BRIGHTNESS_MODE)
|
||||
contentResolver?.registerContentObserver(setting, false, mSettingsObserver)
|
||||
if (DEBUG) Log.d(TAG, "onStartCommand flags $flags startId $startId")
|
||||
destroy = false
|
||||
avail = true
|
||||
startForeground(50, pushNotification())
|
||||
return START_STICKY
|
||||
}
|
||||
|
||||
override fun onCreate() {
|
||||
if (DEBUG) Log.d(TAG, "onCreate service")
|
||||
mContext = applicationContext
|
||||
mContext = this
|
||||
startForeground(50, pushNotification())
|
||||
super.onCreate()
|
||||
}
|
||||
|
|
@ -280,13 +241,12 @@ open class CameraLightSensorService : Service() {
|
|||
fun actOnReadyCameraDevice() {
|
||||
try {
|
||||
cameraDevice!!.createCaptureSession(
|
||||
listOf(imageReader!!.surface),
|
||||
listOf(imageReader.surface),
|
||||
sessionStateCallback,
|
||||
null
|
||||
mCameraHandler
|
||||
)
|
||||
} catch (e: CameraAccessException) {
|
||||
Log.e(TAG, e.message)
|
||||
mLock = false
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -307,54 +267,9 @@ open class CameraLightSensorService : Service() {
|
|||
builder.build()
|
||||
} catch (e: CameraAccessException) {
|
||||
Log.e(TAG, e.message)
|
||||
mLock = false
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
private var availabilityCallback: AvailabilityCallback = object : AvailabilityCallback() {
|
||||
override fun onCameraOpened(cameraId: String, packageId: String) {
|
||||
super.onCameraOpened(cameraId, packageId)
|
||||
Log.i(
|
||||
TAG, "CameraManager.AvailabilityCallback: Camera " + cameraId
|
||||
+ " Opened by Package " + packageId
|
||||
)
|
||||
mLock = true
|
||||
if (packageId == mContext.basePackageName) return
|
||||
avail = false
|
||||
}
|
||||
|
||||
override fun onCameraUnavailable(cameraId: String) {
|
||||
if (DEBUG) Log.i(TAG, "CameraManager.AvailabilityCallback : Camera NOT Available. ")
|
||||
avail = false
|
||||
super.onCameraUnavailable(cameraId)
|
||||
}
|
||||
|
||||
override fun onCameraAvailable(cameraId: String) {
|
||||
if (DEBUG) Log.i(TAG, "CameraManager.AvailabilityCallback : Camera IS Available. ")
|
||||
avail = true
|
||||
mLock = false
|
||||
super.onCameraAvailable(cameraId)
|
||||
}
|
||||
|
||||
override fun onCameraClosed(cameraId: String) {
|
||||
super.onCameraClosed(cameraId)
|
||||
}
|
||||
}
|
||||
var captureCallback: CameraCaptureSession.CaptureCallback =
|
||||
object : CameraCaptureSession.CaptureCallback() {
|
||||
override fun onCaptureSequenceCompleted(
|
||||
session: CameraCaptureSession,
|
||||
sequenceId: Int,
|
||||
frameNumber: Long
|
||||
) {
|
||||
if (DEBUG) Log.d(TAG, "captureCallback: Closing Session")
|
||||
super.onCaptureSequenceCompleted(session, sequenceId, frameNumber)
|
||||
cameraDevice!!.close()
|
||||
session.close()
|
||||
}
|
||||
}
|
||||
|
||||
private fun calculateBrightnessEstimate(bitmap: Bitmap, pixelSpacing: Int): Int {
|
||||
var r = 0
|
||||
var g = 0
|
||||
|
|
@ -382,7 +297,8 @@ open class CameraLightSensorService : Service() {
|
|||
val oldbrightness =
|
||||
Settings.System.getInt(contentResolver, Settings.System.SCREEN_BRIGHTNESS)
|
||||
if (DEBUG) Log.i(
|
||||
TAG, "AdjustBrightness: OldVal = " + oldbrightness + " NewVal = " +
|
||||
TAG,
|
||||
"AdjustBrightness: OldVal = " + oldbrightness + " NewVal = " +
|
||||
brightness + " Adjusting.."
|
||||
)
|
||||
var newbrightness = brightness
|
||||
|
|
@ -398,32 +314,13 @@ open class CameraLightSensorService : Service() {
|
|||
)
|
||||
}
|
||||
|
||||
private var thread = Thread {
|
||||
while (!Thread.currentThread().isInterrupted) {
|
||||
if (avail && !mLock) {
|
||||
SystemClock.sleep(DELAY.toLong())
|
||||
ContextCompat.getMainExecutor(mContext).execute { if (avail) readyCamera() }
|
||||
}else{
|
||||
SystemClock.sleep(DELAY.toLong() / 10) // For Fast Detection
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val imageReader =
|
||||
ImageReader.newInstance(50, 50, ImageFormat.JPEG, 2 /* images buffered */)
|
||||
protected val TAG: String = CameraLightSensorService::class.java.simpleName
|
||||
const val DEBUG = false
|
||||
protected const val CAMERA_CHOICE = CameraCharacteristics.LENS_FACING_FRONT
|
||||
private const val DELAY = 5 * 1000 // 5 Seconds
|
||||
fun batteryOptimization(context: Context?) {
|
||||
val intent = Intent()
|
||||
val packageName = context!!.packageName
|
||||
val pm = context.getSystemService(POWER_SERVICE) as PowerManager
|
||||
if (!pm.isIgnoringBatteryOptimizations(packageName)) {
|
||||
intent.action = Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
|
||||
intent.data = Uri.parse("package:$packageName")
|
||||
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
context.startActivity(intent)
|
||||
}
|
||||
}
|
||||
const val CAMERA_CHOICE = CameraCharacteristics.LENS_FACING_FRONT
|
||||
private var mPoolExecutor: ScheduledThreadPoolExecutor? = null
|
||||
private var mRegistered = false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@ import com.eurekateam.fmradio.enums.PlayState
|
|||
import com.eurekateam.fmradio.enums.PowerState
|
||||
import com.eurekateam.fmradio.fragments.MainFragment
|
||||
import com.eurekateam.fmradio.utils.Log
|
||||
import java.io.File
|
||||
|
||||
|
||||
class FMRadioService : Service() {
|
||||
private lateinit var mContext: Context
|
||||
|
|
@ -32,8 +30,7 @@ class FMRadioService : Service() {
|
|||
mAudioManager = getSystemService(AUDIO_SERVICE) as AudioManager
|
||||
mTracks = MainFragment.mTracks
|
||||
mIndex = MainFragment.getIndex()
|
||||
if (mTracks.isEmpty() || mIndex == -1)
|
||||
{
|
||||
if (mTracks.isEmpty() || mIndex == -1) {
|
||||
return super.onStartCommand(intent, flags, startId)
|
||||
}
|
||||
if (intent != null) {
|
||||
|
|
@ -110,8 +107,10 @@ class FMRadioService : Service() {
|
|||
val metadata = MediaMetadata.Builder()
|
||||
.putString(MediaMetadata.METADATA_KEY_TITLE, mTitle)
|
||||
.putString(MediaMetadata.METADATA_KEY_ARTIST, resources.getString(R.string.app_name))
|
||||
.putBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART,
|
||||
BitmapFactory.decodeResource(mContext.resources, R.drawable.ic_radio))
|
||||
.putBitmap(
|
||||
MediaMetadata.METADATA_KEY_ALBUM_ART,
|
||||
BitmapFactory.decodeResource(mContext.resources, R.drawable.ic_radio)
|
||||
)
|
||||
.build()
|
||||
mMediaSession.setMetadata(metadata)
|
||||
}
|
||||
|
|
@ -146,7 +145,8 @@ class FMRadioService : Service() {
|
|||
OutputState.OUTPUT_SPEAKER -> {
|
||||
Icon.createWithResource(this, R.drawable.ic_headphones)
|
||||
}
|
||||
}, "Output Configuration", output
|
||||
},
|
||||
"Output Configuration", output
|
||||
).build()
|
||||
val mPausePlayAction: Notification.Action = Notification.Action.Builder(
|
||||
when (mPlayState) {
|
||||
|
|
@ -156,7 +156,8 @@ class FMRadioService : Service() {
|
|||
PlayState.STATE_STOPPED -> {
|
||||
Icon.createWithResource(this, R.drawable.ic_play)
|
||||
}
|
||||
}, "Start/Stop", togglePlay
|
||||
},
|
||||
"Start/Stop", togglePlay
|
||||
|
||||
).build()
|
||||
val mRewindAction: Notification.Action = Notification.Action.Builder(
|
||||
|
|
@ -194,9 +195,9 @@ class FMRadioService : Service() {
|
|||
}
|
||||
private fun changeOutputDevice(output: OutputState) {
|
||||
if (output == OutputState.OUTPUT_SPEAKER) {
|
||||
mNativeFMInterface.setAudioRoute(false);
|
||||
mNativeFMInterface.setAudioRoute(false)
|
||||
} else if (output == OutputState.OUTPUT_HEADSET) {
|
||||
mNativeFMInterface.setAudioRoute(true);
|
||||
mNativeFMInterface.setAudioRoute(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import com.google.android.material.bottomnavigation.BottomNavigationView
|
|||
import com.google.android.material.color.DynamicColors
|
||||
import com.google.android.material.textview.MaterialTextView
|
||||
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
private lateinit var mIntent: Intent
|
||||
|
||||
|
|
@ -80,7 +79,8 @@ class MainActivity : AppCompatActivity() {
|
|||
val mAudioDeviceInfo = mAudioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS)
|
||||
for (i in mAudioDeviceInfo.indices) {
|
||||
if (mAudioDeviceInfo[i].type == AudioDeviceInfo.TYPE_WIRED_HEADSET ||
|
||||
mAudioDeviceInfo[i].type == AudioDeviceInfo.TYPE_WIRED_HEADPHONES) {
|
||||
mAudioDeviceInfo[i].type == AudioDeviceInfo.TYPE_WIRED_HEADPHONES
|
||||
) {
|
||||
MainFragment.mHeadSetPlugged = HeadsetState.HEADSET_STATE_CONNECTED
|
||||
Log.i("Wired Headphones detected")
|
||||
}
|
||||
|
|
@ -88,9 +88,12 @@ class MainActivity : AppCompatActivity() {
|
|||
if (MainFragment.mHeadSetPlugged != HeadsetState.HEADSET_STATE_CONNECTED) {
|
||||
mAlertTitle.text = getString(R.string.no_headphones_error)
|
||||
mAlertDesc.text = getString(R.string.no_headphones_error_desc)
|
||||
mAlertImage.setImageIcon(Icon.createWithResource(mAlertView.context,
|
||||
mAlertImage.setImageIcon(
|
||||
Icon.createWithResource(
|
||||
mAlertView.context,
|
||||
R.drawable.ic_headphones
|
||||
))
|
||||
)
|
||||
)
|
||||
AlertDialog.Builder(mAlertView.context)
|
||||
.setCancelable(false)
|
||||
.setView(mAlertView)
|
||||
|
|
@ -130,7 +133,8 @@ class MainActivity : AppCompatActivity() {
|
|||
val mAudioDeviceInfo = mAudioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS)
|
||||
for (i in mAudioDeviceInfo.indices) {
|
||||
if (mAudioDeviceInfo[i].type == AudioDeviceInfo.TYPE_WIRED_HEADSET ||
|
||||
mAudioDeviceInfo[i].type == AudioDeviceInfo.TYPE_WIRED_HEADPHONES){
|
||||
mAudioDeviceInfo[i].type == AudioDeviceInfo.TYPE_WIRED_HEADPHONES
|
||||
) {
|
||||
MainFragment.mHeadSetPlugged = HeadsetState.HEADSET_STATE_CONNECTED
|
||||
}
|
||||
}
|
||||
|
|
@ -138,9 +142,12 @@ class MainActivity : AppCompatActivity() {
|
|||
Log.w("onReceive: Headset Unplugged")
|
||||
mAlertTitle.text = getString(R.string.no_headphones_error)
|
||||
mAlertDesc.text = getString(R.string.no_headphones_error_desc)
|
||||
mAlertImage.setImageIcon(Icon.createWithResource(mAlertView.context,
|
||||
mAlertImage.setImageIcon(
|
||||
Icon.createWithResource(
|
||||
mAlertView.context,
|
||||
R.drawable.ic_headphones
|
||||
))
|
||||
)
|
||||
)
|
||||
val mAlertDialog = AlertDialog.Builder(mAlertView.context)
|
||||
mAlertDialog
|
||||
.setCancelable(false)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import android.graphics.*
|
|||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
|
||||
|
||||
class PebbleTextView(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : View(context, attrs, defStyleAttr) {
|
||||
constructor (context: Context) : this(context, null)
|
||||
constructor (context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
|
||||
|
|
@ -42,7 +41,8 @@ class PebbleTextView(context: Context, attrs: AttributeSet?, defStyleAttr: Int)
|
|||
* the text that should be that width
|
||||
*/
|
||||
private fun setTextSizeForWidth(
|
||||
paint: Paint, desiredWidth: Float,
|
||||
paint: Paint,
|
||||
desiredWidth: Float,
|
||||
text: String
|
||||
) {
|
||||
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ import android.widget.BaseAdapter
|
|||
import androidx.appcompat.widget.AppCompatImageView
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import com.eurekateam.fmradio.*
|
||||
import com.eurekateam.fmradio.NativeFMInterface
|
||||
import com.eurekateam.fmradio.fragments.MainFragment
|
||||
import com.eurekateam.fmradio.utils.FileUtilities
|
||||
import com.eurekateam.fmradio.utils.Log
|
||||
import com.eurekateam.fmradio.NativeFMInterface
|
||||
import com.google.android.material.textview.MaterialTextView
|
||||
|
||||
class ListViewAdapter(private val mContext: Context) : BaseAdapter() {
|
||||
|
|
@ -32,10 +32,13 @@ class ListViewAdapter (private val mContext: Context) : BaseAdapter() {
|
|||
override fun getView(id: Int, mConvertView: View?, parent: ViewGroup?): View {
|
||||
val mAnotherConvertView = mConvertView
|
||||
?: (mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater).inflate(
|
||||
R.layout.channel_list_items, parent, false)
|
||||
R.layout.channel_list_items, parent, false
|
||||
)
|
||||
mAnotherConvertView.findViewById<MaterialTextView>(R.id.channel_list_title).text =
|
||||
String.format(mContext.getString(R.string.fm_radio_freq),
|
||||
MainFragment.mTracks[id].toFloat() / 1000)
|
||||
String.format(
|
||||
mContext.getString(R.string.fm_radio_freq),
|
||||
MainFragment.mTracks[id].toFloat() / 1000
|
||||
)
|
||||
mAnotherConvertView.findViewById<MaterialTextView>(R.id.channel_list_title).setOnClickListener {
|
||||
mFMInterface.setFMFreq(MainFragment.fd, MainFragment.mTracks[id].toInt())
|
||||
MainFragment.mFreqCurrent = MainFragment.mTracks[id].toInt()
|
||||
|
|
@ -47,8 +50,10 @@ class ListViewAdapter (private val mContext: Context) : BaseAdapter() {
|
|||
}
|
||||
mAnotherConvertView.findViewById<AppCompatImageView>(R.id.star_button_list).let {
|
||||
val mStar = ResourcesCompat.getDrawable(mContext.resources, R.drawable.ic_star, mContext.theme)
|
||||
val mStarFilled = ResourcesCompat.getDrawable(mContext.resources,
|
||||
R.drawable.ic_star_filled, mContext.theme)
|
||||
val mStarFilled = ResourcesCompat.getDrawable(
|
||||
mContext.resources,
|
||||
R.drawable.ic_star_filled, mContext.theme
|
||||
)
|
||||
val mIndex = MainFragment.mTracks[id].toInt()
|
||||
if (MainFragment.mFavStats[mIndex] == null) {
|
||||
MainFragment.mFavStats.putIfAbsent(mIndex, false)
|
||||
|
|
@ -69,10 +74,18 @@ class ListViewAdapter (private val mContext: Context) : BaseAdapter() {
|
|||
private fun setCurrentFMChannel(mPosition: Int) {
|
||||
Log.i("Position: $mPosition")
|
||||
for (mItem in mListofViews) {
|
||||
mItem.value.setBackgroundColor(ResourcesCompat.getColor(mContext.resources,
|
||||
android.R.color.system_accent2_100, mContext.theme))
|
||||
mItem.value.setBackgroundColor(
|
||||
ResourcesCompat.getColor(
|
||||
mContext.resources,
|
||||
android.R.color.system_accent2_100, mContext.theme
|
||||
)
|
||||
)
|
||||
}
|
||||
mListofViews[mPosition]?.setBackgroundColor(ResourcesCompat.getColor(mContext.resources,
|
||||
android.R.color.system_accent3_400, mContext.theme))
|
||||
mListofViews[mPosition]?.setBackgroundColor(
|
||||
ResourcesCompat.getColor(
|
||||
mContext.resources,
|
||||
android.R.color.system_accent3_400, mContext.theme
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -12,7 +12,6 @@ import com.eurekateam.fmradio.R
|
|||
import com.eurekateam.fmradio.fragments.MainFragment
|
||||
import com.eurekateam.fmradio.utils.FileUtilities
|
||||
|
||||
|
||||
class PebbleLayoutAdapter(private val mContext: Context) : BaseAdapter() {
|
||||
private val mFavoriteList: MutableList<Int> = emptyList<Int>().toMutableList()
|
||||
init {
|
||||
|
|
@ -48,8 +47,10 @@ class PebbleLayoutAdapter (private val mContext: Context) : BaseAdapter() {
|
|||
)
|
||||
mAnotherConvertView.findViewById<PebbleTextView>(R.id.pebble_textview).apply {
|
||||
mText = (mFavoriteList[id].toFloat() / 1000).toString()
|
||||
mColor = ResourcesCompat.getColor(mContext.resources, android.R.color.system_accent1_400,
|
||||
mContext.theme)
|
||||
mColor = ResourcesCompat.getColor(
|
||||
mContext.resources, android.R.color.system_accent1_400,
|
||||
mContext.theme
|
||||
)
|
||||
setOnClickListener {
|
||||
mFMInterface.setFMFreq(MainFragment.fd, mFavoriteList[id])
|
||||
MainFragment.mFreqCurrent = mFavoriteList[id]
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ import kotlinx.coroutines.GlobalScope
|
|||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
class ChannelListFragment : Fragment(R.layout.activity_channel_list),
|
||||
class ChannelListFragment :
|
||||
Fragment(R.layout.activity_channel_list),
|
||||
View.OnClickListener {
|
||||
private lateinit var mListView: ListView
|
||||
private lateinit var mFloatingActionButton: FloatingActionButton
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.GridView
|
||||
import android.widget.ListView
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.eurekateam.fmradio.R
|
||||
import com.eurekateam.fmradio.adapters.PebbleLayoutAdapter
|
||||
|
|
|
|||
|
|
@ -30,8 +30,9 @@ import kotlinx.coroutines.launch
|
|||
import kotlinx.coroutines.withContext
|
||||
import java.text.DecimalFormat
|
||||
|
||||
|
||||
class MainFragment : Fragment(R.layout.fragment_main), View.OnClickListener,
|
||||
class MainFragment :
|
||||
Fragment(R.layout.fragment_main),
|
||||
View.OnClickListener,
|
||||
SeekBar.OnSeekBarChangeListener {
|
||||
private val mFMInterface = NativeFMInterface()
|
||||
private lateinit var mVolumeUp: FloatingActionButton
|
||||
|
|
@ -54,10 +55,14 @@ class MainFragment : Fragment(R.layout.fragment_main), View.OnClickListener,
|
|||
): View? {
|
||||
val mRootView = inflater.inflate(R.layout.fragment_main, container, false)
|
||||
super.onCreate(savedInstanceState)
|
||||
mStar = ResourcesCompat.getDrawable(requireContext().resources,
|
||||
R.drawable.ic_star, requireContext().theme)!!
|
||||
mStarFilled = ResourcesCompat.getDrawable(requireContext().resources,
|
||||
R.drawable.ic_star_filled, requireContext().theme)!!
|
||||
mStar = ResourcesCompat.getDrawable(
|
||||
requireContext().resources,
|
||||
R.drawable.ic_star, requireContext().theme
|
||||
)!!
|
||||
mStarFilled = ResourcesCompat.getDrawable(
|
||||
requireContext().resources,
|
||||
R.drawable.ic_star_filled, requireContext().theme
|
||||
)!!
|
||||
mAudioManager = requireContext().getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
mVolumeUp = mRootView.findViewById(R.id.volume_up)
|
||||
mVolumeDown = mRootView.findViewById(R.id.volume_down)
|
||||
|
|
@ -245,8 +250,8 @@ class MainFragment : Fragment(R.layout.fragment_main), View.OnClickListener,
|
|||
R.drawable.ic_volume_up
|
||||
)
|
||||
)
|
||||
val ret = mFMInterface.setAudioRoute(true);
|
||||
Log.i("mFMInterface.setAudioRoute return $ret");
|
||||
val ret = mFMInterface.setAudioRoute(true)
|
||||
Log.i("mFMInterface.setAudioRoute return $ret")
|
||||
} else if (mHeadset == OutputState.OUTPUT_SPEAKER) {
|
||||
mOutputSwitch.setImageIcon(
|
||||
Icon.createWithResource(
|
||||
|
|
@ -254,8 +259,8 @@ class MainFragment : Fragment(R.layout.fragment_main), View.OnClickListener,
|
|||
R.drawable.ic_headphones
|
||||
)
|
||||
)
|
||||
val ret = mFMInterface.setAudioRoute(false);
|
||||
Log.i("mFMInterface.setAudioRoute return $ret");
|
||||
val ret = mFMInterface.setAudioRoute(false)
|
||||
Log.i("mFMInterface.setAudioRoute return $ret")
|
||||
}
|
||||
if (mHeadset == OutputState.OUTPUT_HEADSET) {
|
||||
mHeadset = OutputState.OUTPUT_SPEAKER
|
||||
|
|
@ -290,7 +295,8 @@ class MainFragment : Fragment(R.layout.fragment_main), View.OnClickListener,
|
|||
val mTempFreq = mFMInterface.getBeforeChannel(fd)
|
||||
if (mTempFreq > mFMInterface.getFMLower(fd) && mTempFreq < mFMInterface.getFmUpper(
|
||||
fd
|
||||
)){
|
||||
)
|
||||
) {
|
||||
mFreqCurrent = mTempFreq
|
||||
}
|
||||
if (!mFMInterface.getSysfsSupport()) {
|
||||
|
|
@ -328,7 +334,8 @@ class MainFragment : Fragment(R.layout.fragment_main), View.OnClickListener,
|
|||
val mTempFreq = mFMInterface.getNextChannel(fd)
|
||||
if (mTempFreq > mFMInterface.getFMLower(fd) && mTempFreq < mFMInterface.getFmUpper(
|
||||
fd
|
||||
)){
|
||||
)
|
||||
) {
|
||||
mFreqCurrent = mTempFreq
|
||||
}
|
||||
if (!mFMInterface.getSysfsSupport()) {
|
||||
|
|
@ -420,5 +427,4 @@ class MainFragment : Fragment(R.layout.fragment_main), View.OnClickListener,
|
|||
}
|
||||
return mArray.toLongArray()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.eurekateam.fmradio.utils
|
||||
|
||||
|
||||
import android.util.Log
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -21,14 +21,22 @@ class BootReceiver : BroadcastReceiver() {
|
|||
System.loadLibrary("samsungparts_jni")
|
||||
// Battery
|
||||
Battery.chargeSysfs = if (mSharedPreferences
|
||||
.getBoolean(BatteryFragment.PREF_CHARGE, true)) 0 else 1
|
||||
Battery.setFastCharge(if (mSharedPreferences
|
||||
.getBoolean(BatteryFragment.PREF_FASTCHARGE, true)) 0 else 1)
|
||||
.getBoolean(BatteryFragment.PREF_CHARGE, true)
|
||||
) 0 else 1
|
||||
Battery.setFastCharge(
|
||||
if (mSharedPreferences
|
||||
.getBoolean(BatteryFragment.PREF_FASTCHARGE, true)
|
||||
) 0 else 1
|
||||
)
|
||||
// Dolby
|
||||
DolbyCore.setEnabled(mSharedPreferences
|
||||
.getBoolean(DolbyFragment.PREF_DOLBY_ENABLE, false))
|
||||
DolbyCore.setProfile(mSharedPreferences
|
||||
.getInt(DolbyFragment.PREF_DOLBY_PROFILE, 0))
|
||||
DolbyCore.setEnabled(
|
||||
mSharedPreferences
|
||||
.getBoolean(DolbyFragment.PREF_DOLBY_ENABLE, false)
|
||||
)
|
||||
DolbyCore.setProfile(
|
||||
mSharedPreferences
|
||||
.getInt(DolbyFragment.PREF_DOLBY_PROFILE, 0)
|
||||
)
|
||||
|
||||
// FlashLight
|
||||
Flashlight.setFlash(mSharedPreferences.getInt(FlashLightFragment.PREF_FLASHLIGHT, 5))
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ package com.eurekateam.samsungextras
|
|||
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import androidx.preference.PreferenceManager
|
||||
|
|
@ -26,8 +26,8 @@ import androidx.preference.SwitchPreference
|
|||
import com.eurekateam.samsungextras.battery.BatteryActivity
|
||||
import com.eurekateam.samsungextras.flashlight.FlashLightActivity
|
||||
import com.eurekateam.samsungextras.fps.FPSInfoService
|
||||
import com.eurekateam.samsungextras.interfaces.Display.GloveMode
|
||||
import com.eurekateam.samsungextras.interfaces.Display.DT2W
|
||||
import com.eurekateam.samsungextras.interfaces.Display.GloveMode
|
||||
import com.eurekateam.samsungextras.speaker.ClearSpeakerActivity
|
||||
|
||||
class DeviceSettings : PreferenceFragmentCompat(), Preference.OnPreferenceChangeListener {
|
||||
|
|
|
|||
|
|
@ -15,11 +15,11 @@
|
|||
*/
|
||||
package com.eurekateam.samsungextras.battery
|
||||
|
||||
import android.R.id.content
|
||||
import android.R.id.home
|
||||
import android.os.Bundle
|
||||
import android.view.MenuItem
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import android.R.id.content
|
||||
import android.R.id.home
|
||||
|
||||
class BatteryActivity : FragmentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
package com.eurekateam.samsungextras.battery
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import android.widget.Toast
|
||||
import androidx.preference.ListPreference
|
||||
|
|
@ -22,7 +23,6 @@ import androidx.preference.Preference
|
|||
import androidx.preference.PreferenceFragmentCompat
|
||||
import androidx.preference.PreferenceManager
|
||||
import androidx.preference.SwitchPreference
|
||||
import android.content.SharedPreferences
|
||||
import com.eurekateam.samsungextras.R
|
||||
import com.eurekateam.samsungextras.interfaces.Battery
|
||||
|
||||
|
|
|
|||
|
|
@ -16,10 +16,9 @@
|
|||
|
||||
package com.eurekateam.samsungextras.dolby
|
||||
|
||||
import android.os.Bundle
|
||||
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import android.R.id.content
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
|
||||
class DolbyActivity : FragmentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
|
|
|||
|
|
@ -18,9 +18,7 @@ package com.eurekateam.samsungextras.dolby
|
|||
|
||||
import android.content.Context
|
||||
import android.media.audiofx.AudioEffect
|
||||
|
||||
import com.eurekateam.samsungextras.dolby.DolbyFragment.Companion.PREF_DOLBY_MODES
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
object DolbyCore {
|
||||
|
|
@ -53,9 +51,11 @@ object DolbyCore {
|
|||
val profile = getProfile()
|
||||
val resourceName = PREF_DOLBY_MODES.filter { it.value == profile }.keys.first()
|
||||
|
||||
return context.resources.getString(context.resources.getIdentifier(
|
||||
return context.resources.getString(
|
||||
context.resources.getIdentifier(
|
||||
resourceName, "string", context.packageName
|
||||
))
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
fun setProfile(profile: Int) {
|
||||
|
|
|
|||
|
|
@ -16,19 +16,15 @@
|
|||
|
||||
package com.eurekateam.samsungextras.dolby
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import android.os.PerformanceHintManager
|
||||
import android.widget.Switch
|
||||
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import androidx.preference.PreferenceManager
|
||||
|
||||
import com.android.settingslib.widget.MainSwitchPreference
|
||||
import com.android.settingslib.widget.OnMainSwitchChangeListener
|
||||
import com.android.settingslib.widget.RadioButtonPreference
|
||||
|
||||
import com.eurekateam.samsungextras.R
|
||||
import android.content.SharedPreferences
|
||||
|
||||
class DolbyFragment : PreferenceFragmentCompat(), OnMainSwitchChangeListener {
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ package com.eurekateam.samsungextras.dolby
|
|||
import android.database.Cursor
|
||||
import android.database.MatrixCursor
|
||||
import android.provider.SearchIndexableResource
|
||||
import android.provider.SearchIndexablesProvider
|
||||
import android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_CLASS_NAME
|
||||
import android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_ICON_RESID
|
||||
import android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_INTENT_ACTION
|
||||
|
|
@ -30,6 +29,7 @@ import android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_RESID
|
|||
import android.provider.SearchIndexablesContract.INDEXABLES_RAW_COLUMNS
|
||||
import android.provider.SearchIndexablesContract.INDEXABLES_XML_RES_COLUMNS
|
||||
import android.provider.SearchIndexablesContract.NON_INDEXABLES_KEYS_COLUMNS
|
||||
import android.provider.SearchIndexablesProvider
|
||||
import com.eurekateam.samsungextras.R
|
||||
|
||||
class DolbySearchIndexablesProvider : SearchIndexablesProvider() {
|
||||
|
|
|
|||
|
|
@ -18,9 +18,7 @@ package com.eurekateam.samsungextras.dolby
|
|||
|
||||
import android.service.quicksettings.Tile
|
||||
import android.service.quicksettings.TileService
|
||||
|
||||
import androidx.preference.PreferenceManager
|
||||
|
||||
import com.eurekateam.samsungextras.dolby.DolbyFragment.Companion.PREF_DOLBY_ENABLE
|
||||
|
||||
class DolbyTile : TileService() {
|
||||
|
|
|
|||
|
|
@ -16,10 +16,10 @@
|
|||
package com.eurekateam.samsungextras.flashlight
|
||||
|
||||
import android.R.id.content
|
||||
import android.R.id.home
|
||||
import android.os.Bundle
|
||||
import android.view.MenuItem
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import android.R.id.home
|
||||
|
||||
class FlashLightActivity : FragmentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
|
|
|||
|
|
@ -15,13 +15,12 @@
|
|||
*/
|
||||
package com.eurekateam.samsungextras.flashlight
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.PerformanceHintManager
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import androidx.preference.PreferenceManager
|
||||
import android.content.SharedPreferences
|
||||
import com.eurekateam.samsungextras.R
|
||||
import com.eurekateam.samsungextras.interfaces.Flashlight
|
||||
import com.eurekateam.samsungextras.preferences.CustomSeekBarPreference
|
||||
|
|
|
|||
|
|
@ -78,8 +78,11 @@ open class FPSInfoService : Service() {
|
|||
val y = mPaddingTop - mAscent.toInt()
|
||||
val s = fPSInfoString
|
||||
canvas.drawText(
|
||||
s, (LEFT - mPaddingLeft - mMaxWidth).toFloat(), (
|
||||
y - 1).toFloat(), mOnlinePaint
|
||||
s, (LEFT - mPaddingLeft - mMaxWidth).toFloat(),
|
||||
(
|
||||
y - 1
|
||||
).toFloat(),
|
||||
mOnlinePaint
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,13 +34,18 @@ import androidx.preference.PreferenceViewHolder
|
|||
import androidx.preference.R
|
||||
|
||||
open class CustomSeekBarPreference @JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = TypedArrayUtils.getAttr(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = TypedArrayUtils.getAttr(
|
||||
context,
|
||||
R.attr.preferenceStyle,
|
||||
android.R.attr.preferenceStyle
|
||||
), defStyleRes: Int = 0
|
||||
) : Preference(context, attrs, defStyleAttr, defStyleRes), OnSeekBarChangeListener,
|
||||
View.OnClickListener, OnLongClickListener {
|
||||
),
|
||||
defStyleRes: Int = 0
|
||||
) : Preference(context, attrs, defStyleAttr, defStyleRes),
|
||||
OnSeekBarChangeListener,
|
||||
View.OnClickListener,
|
||||
OnLongClickListener {
|
||||
private val TAG: String = javaClass.name
|
||||
private var mInterval = 1
|
||||
private var mShowSign = false
|
||||
|
|
@ -114,8 +119,10 @@ open class CustomSeekBarPreference @JvmOverloads constructor(
|
|||
mValueTextView!!.text = context.getString(
|
||||
com.eurekateam.samsungextras.R.string.custom_seekbar_value,
|
||||
if (!mTrackingTouch || mContinuousUpdates) getTextValue(mValue) +
|
||||
(if (mDefaultValueExists && mValue == mDefaultValue) " (" +
|
||||
context.getString(com.eurekateam.samsungextras.R.string.custom_seekbar_default_value) + ")" else "") else getTextValue(
|
||||
(
|
||||
if (mDefaultValueExists && mValue == mDefaultValue) " (" +
|
||||
context.getString(com.eurekateam.samsungextras.R.string.custom_seekbar_default_value) + ")" else ""
|
||||
) else getTextValue(
|
||||
mTrackingValue
|
||||
)
|
||||
)
|
||||
|
|
@ -215,7 +222,8 @@ open class CustomSeekBarPreference @JvmOverloads constructor(
|
|||
if (mMaxValue - mMinValue > mInterval * 2 && mMaxValue + mMinValue < mValue * 2) Math.floorDiv(
|
||||
mMaxValue + mMinValue,
|
||||
2
|
||||
) else mMinValue, true
|
||||
) else mMinValue,
|
||||
true
|
||||
)
|
||||
}
|
||||
com.eurekateam.samsungextras.R.id.plus -> {
|
||||
|
|
@ -223,7 +231,8 @@ open class CustomSeekBarPreference @JvmOverloads constructor(
|
|||
if (mMaxValue - mMinValue > mInterval * 2 && mMaxValue + mMinValue > mValue * 2) -1 * Math.floorDiv(
|
||||
-1 * (mMaxValue + mMinValue),
|
||||
2
|
||||
) else mMaxValue, true
|
||||
) else mMaxValue,
|
||||
true
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue