Skip to content

Commit

Permalink
Merge pull request #63 from TheXtremeLabs/feat/041-spring-choice
Browse files Browse the repository at this point in the history
Feat/041 spring choice
  • Loading branch information
MichaelStH authored Oct 5, 2021
2 parents 065724c + 747039b commit d9de49d
Show file tree
Hide file tree
Showing 87 changed files with 1,240 additions and 641 deletions.
16 changes: 9 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ android {
versionCode buildDateTime
versionName rootProject.ext.versionName

javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath false
}
}

// Enabling multidex support.
multiDexEnabled true

Expand Down Expand Up @@ -109,7 +103,7 @@ android {
}

kotlinOptions {
jvmTarget = "1.8"
jvmTarget = '1.8'
}

compileOptions {
Expand All @@ -118,6 +112,14 @@ android {
}
}

allprojects {
repositories {
flatDir {
dirs 'libs'
}
}
}

dependencies {

/////////////////////////////
Expand Down
18 changes: 14 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="Manifest.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />


<!-- User Data -->
Expand Down Expand Up @@ -146,6 +147,7 @@
<!-- ////////////// ACTIVITIES ////////////// -->
<activity
android:name=".ui.splashscreen.SplashScreenActivity"
android:exported="true"
android:theme="@style/Theme.TheLab.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down Expand Up @@ -194,6 +196,7 @@

<activity
android:name=".ui.contacts.ContactsActivity"
android:exported="true"
android:label="@string/activity_title_database_contacts"
android:parentActivityName=".ui.mainactivity.MainActivity"
android:theme="@style/Theme.TheLab.NoActionBar">
Expand Down Expand Up @@ -294,6 +297,7 @@

<activity
android:name=".ui.weather.WeatherActivity"
android:exported="true"
android:label="@string/activity_title_weather"
android:parentActivityName=".ui.mainactivity.MainActivity"
android:theme="@style/Theme.TheLab">
Expand Down Expand Up @@ -393,6 +397,7 @@
<receiver
android:name=".core.broadcast.TheLabBootBroadcastReceiver"
android:enabled="true"
android:exported="true"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
Expand All @@ -405,7 +410,8 @@
<!-- Connection -->
<receiver
android:name=".core.broadcast.ConnectivityReceiver"
android:enabled="true">
android:enabled="true"
android:exported="true">
<intent-filter>
<action
android:name="android.net.conn.CONNECTIVITY_CHANGE"
Expand All @@ -420,7 +426,9 @@

<!-- Media Receiver -->
<receiver android:name="androidx.mediarouter.media.MediaTransferReceiver" />
<receiver android:name="androidx.media.session.MediaButtonReceiver">
<receiver
android:name="androidx.media.session.MediaButtonReceiver"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
Expand Down Expand Up @@ -449,7 +457,9 @@
android:enabled="true"
android:exported="false" />

<service android:name=".core.service.MusicMediaPlaybackService">
<service
android:name=".core.service.MusicMediaPlaybackService"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
<action android:name="android.media.browse.MediaBrowserService" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class ConnectionLiveData(

override fun onActive() {
super.onActive()
@Suppress("DEPRECATION")
val filter = IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)
context.registerReceiver(networkReceiver, filter)
}
Expand All @@ -28,12 +29,16 @@ class ConnectionLiveData(
private val networkReceiver: BroadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent) {
if (intent.extras != null) {
@Suppress("DEPRECATION")
val activeNetwork =
intent.extras!![ConnectivityManager.EXTRA_NETWORK_INFO] as NetworkInfo?

@Suppress("DEPRECATION")
val isConnected = activeNetwork != null &&
activeNetwork.isConnectedOrConnecting

if (isConnected) {
@Suppress("DEPRECATION")
when (activeNetwork!!.type) {
ConnectivityManager.TYPE_WIFI ->
value = ConnectionModel(ConnectivityManager.TYPE_WIFI, true)
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/riders/thelab/core/location/GpsUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class GpsUtils(private val context: Context) {
this.mSettingsClient = LocationServices.getSettingsClient(mContext!!)
this.locationRequest = LocationRequest.create()
locationRequest?.priority = LocationRequest.PRIORITY_HIGH_ACCURACY
locationRequest?.interval = 10 * 1000
locationRequest?.fastestInterval = 2 * 1000
locationRequest?.interval = (10 * 1000).toLong()
locationRequest?.fastestInterval = (2 * 1000).toLong()

val builder: LocationSettingsRequest.Builder = LocationSettingsRequest.Builder()
.addLocationRequest(locationRequest!!)
Expand All @@ -58,7 +58,7 @@ class GpsUtils(private val context: Context) {
// GPS is already enable, callback GPS status through listener
onGpsListener.gpsStatus(true)
}
?.addOnFailureListener((context as Activity)) { exception ->
?.addOnFailureListener(context) { exception ->

when ((exception as ApiException).statusCode) {
LocationSettingsStatusCodes.RESOLUTION_REQUIRED -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import okio.GzipSink
import okio.buffer
import timber.log.Timber
import java.io.IOException
import java.util.*

class LabInterceptors {

Expand Down Expand Up @@ -41,11 +40,12 @@ class LabInterceptors {
Timber.d("Received response : %s", jsonResponse)

// Re-create the response before returning it because body can be read only once
@Suppress("DEPRECATION")
return response
.newBuilder()
.body(
ResponseBody.create(
Objects.requireNonNull(response.body)!!.contentType(),
response.body?.contentType(),
jsonResponse
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class FloatingViewService : Service() {

//Set the next button.
val nextButton = mFloatingView!!.findViewById<View>(R.id.next_btn) as ImageView
nextButton.setOnClickListener { v: View? ->
nextButton.setOnClickListener {
Toast.makeText(
this@FloatingViewService,
"Playing next song.",
Expand All @@ -107,7 +107,7 @@ class FloatingViewService : Service() {

//Set the pause button.
val prevButton = mFloatingView!!.findViewById<View>(R.id.prev_btn) as ImageView
prevButton.setOnClickListener { v: View? ->
prevButton.setOnClickListener {
Toast.makeText(
this@FloatingViewService,
"Playing previous song.",
Expand All @@ -119,15 +119,15 @@ class FloatingViewService : Service() {

//Set the close button
val closeButton = mFloatingView!!.findViewById<View>(R.id.close_button) as ImageView
closeButton.setOnClickListener { view: View? ->
closeButton.setOnClickListener {
collapsedView.visibility = View.VISIBLE
expandedView.visibility = View.GONE
}


//Open the application on thi button click
val openButton = mFloatingView!!.findViewById<View>(R.id.open_button) as ImageView
openButton.setOnClickListener { view: View? ->
openButton.setOnClickListener {
//Open the application click.
val intent = Intent(this@FloatingViewService, FloatingViewActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class MusicMediaPlaybackService : Service() {
//binder given to client
private val mBinder: IBinder = LocalBinder()

private lateinit var mMediaSessionCompat: MediaSessionCompat
private var mMediaSessionCompat: MediaSessionCompat? = null

override fun onBind(intent: Intent?): IBinder {
Timber.d("onBind()")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class TheLabBootService : Service() {
)

val mBuilder: NotificationCompat.Builder =
@Suppress("DEPRECATION")
NotificationCompat.Builder(this).apply {
setSmallIcon(R.mipmap.ic_lab_six_round)
setContentTitle(getString(R.string.notification_title))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class ExternalStorage {
return false
}

@Suppress("DEPRECATION")
fun getSdCardPath(): String {
return Environment.getExternalStorageDirectory().path + "/"
}
Expand Down Expand Up @@ -134,6 +135,7 @@ class ExternalStorage {
mMounts.clear()

if (map.isEmpty()) {
@Suppress("DEPRECATION")
map[SD_CARD] = Environment.getExternalStorageDirectory()
}
return map;
Expand Down
21 changes: 8 additions & 13 deletions app/src/main/java/com/riders/thelab/core/storage/FileManager.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.riders.thelab.core.storage

import android.content.Context
import android.graphics.BitmapFactory
import android.media.MediaMetadataRetriever
import android.os.Build
import android.os.Environment
import android.os.storage.StorageManager
Expand Down Expand Up @@ -103,25 +101,22 @@ class FileManager private constructor() {
}
}

fun getMetaDataImage() {
/*fun getMetaDataImage() {
val mmr = MediaMetadataRetriever()
// mmr.setDataSource(songsList.get(songIndex).get("songPath"))

val data = mmr.embeddedPicture
//coverart is an Imageview object
mmr.setDataSource(songsList.get(songIndex).get("songPath"))
// convert the byte array to a bitmap
//coverart is an Imageview object
val data = mmr.embeddedPicture
// convert the byte array to a bitmap
if (data != null) {
val bitmap = BitmapFactory.decodeByteArray(data, 0, data.size)
//coverart.setImageBitmap(bitmap) //associated cover art in bitmap
coverart.setImageBitmap(bitmap) //associated cover art in bitmap
} else {
//coverart.setImageResource(R.drawable.fallback_cover) //any default cover resourse folder
coverart.setImageResource(R.drawable.fallback_cover) //any default cover resourse folder
}
//coverart.setAdjustViewBounds(true)
//coverart.setLayoutParams(LinearLayout.LayoutParams(500, 500))
}
coverart.setAdjustViewBounds(true)
coverart.setLayoutParams(LinearLayout.LayoutParams(500, 500))
}*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class BrowserUtils private constructor() {

companion object {
fun isSameDomain(url: String, url1: String): Boolean {
return getRootDomainUrl(url.toLowerCase()) == getRootDomainUrl(url1.toLowerCase())
return getRootDomainUrl(url.lowercase()) == getRootDomainUrl(url1.lowercase())
}

private fun getRootDomainUrl(url: String): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ class LabAddressesUtils private constructor() {
}
}


fun buildAddress(address: Address): String? {
val finalCity = ""
val addressStringBuilder = StringBuilder()
val street = address.featureName + ", " + address.thoroughfare
val locality = address.locality
Expand All @@ -66,7 +64,8 @@ class LabAddressesUtils private constructor() {
.append(departmentName).append(" - ")
.append(regionName).append(" - ")
.append(countryName)
Timber.d(addressStringBuilder.toString())
val finalAddress = addressStringBuilder.toString()
Timber.d(finalAddress)
return locality
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ class LabCompatibilityManager private constructor() {
}

// TEST
fields = null
fields = VERSION_CODES::class.java.fields
val builder = StringBuilder()
builder.append("android : ").append(Build.VERSION.RELEASE)
fields = VERSION_CODES::class.java.fields

for (field in fields) {
val fieldName = field.name
var fieldValue = -1
Expand All @@ -159,7 +159,7 @@ class LabCompatibilityManager private constructor() {
.append("sdk=").append(fieldValue)
}
}
fields = null

Timber.e("OS: %s", builder.toString())
// TEST
return OSName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,8 @@ class LabDeviceManager private constructor() {

@SuppressLint("NewApi")
fun getScreenHeight(activity: Activity): Int {
var screenHeight = 0
screenHeight = if (LabCompatibilityManager.isAndroid10()
&& getModel().trim { it <= ' ' }.toLowerCase()
val screenHeight: Int = if (LabCompatibilityManager.isAndroid10()
&& getModel().trim { it <= ' ' }.lowercase()
.contains(Constants.EMULATOR_DEVICE_TAG)
) {
val metrics = getDisplayMetricsAndroid10(activity)
Expand All @@ -165,9 +164,8 @@ class LabDeviceManager private constructor() {

@SuppressLint("NewApi")
fun getScreenWidth(activity: Activity): Int {
var screenWidth = 0
screenWidth = if (LabCompatibilityManager.isAndroid10()
&& getModel().trim { it <= ' ' }.toLowerCase()
val screenWidth: Int = if (LabCompatibilityManager.isAndroid10()
&& getModel().trim { it <= ' ' }.lowercase()
.contains(Constants.EMULATOR_DEVICE_TAG)
) {
val metrics = getDisplayMetricsAndroid10(activity)
Expand All @@ -186,9 +184,10 @@ class LabDeviceManager private constructor() {
* @param activity
* @return
*/
fun getDisplayMetrics(activity: Activity): DisplayMetrics {
private fun getDisplayMetrics(activity: Activity): DisplayMetrics {
//Retrieve Screen's height and width
val metrics = DisplayMetrics()
@Suppress("DEPRECATION")
activity
.windowManager
.defaultDisplay
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ class LabLocationManager constructor(
// On pressing Settings button
alertDialog.setPositiveButton(
"Settings"
) { dialog: DialogInterface?, which: Int ->
) { _: DialogInterface?, _: Int ->
val intent = Intent(
Settings.ACTION_LOCATION_SOURCE_SETTINGS
)
Expand All @@ -277,7 +277,7 @@ class LabLocationManager constructor(
// on pressing cancel button
alertDialog.setNegativeButton(
"Cancel"
) { dialog: DialogInterface, which: Int -> dialog.cancel() }
) { dialog: DialogInterface, _: Int -> dialog.cancel() }

// Showing Alert Message
alertDialog.show()
Expand Down
Loading

0 comments on commit d9de49d

Please sign in to comment.