Skip to content

Commit

Permalink
Fix depreciated screen width and height.
Browse files Browse the repository at this point in the history
  • Loading branch information
abalta committed Apr 6, 2022
1 parent dcdf92c commit 7317d61
Show file tree
Hide file tree
Showing 18 changed files with 550 additions and 43 deletions.
45 changes: 27 additions & 18 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
}

android {
compileSdkVersion 31
compileSdkVersion 32
buildToolsVersion "30.0.3"

defaultConfig {
applicationId "com.mobven.extensions"
minSdkVersion 21
targetSdkVersion 31
targetSdkVersion 32
versionCode 1
versionName "1.0"

Expand Down Expand Up @@ -40,7 +41,7 @@ android {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.1.0-beta04"
kotlinCompilerExtensionVersion = "1.2.0-alpha03"
}
packagingOptions {
resources {
Expand All @@ -54,39 +55,47 @@ dependencies {
implementation project(":extension")

implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
//Navigation
implementation 'androidx.navigation:navigation-fragment-ktx:2.4.0-beta02'
implementation 'androidx.navigation:navigation-ui-ktx:2.4.0-beta02'
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.0-alpha02'
implementation 'androidx.navigation:navigation-ui-ktx:2.5.0-alpha02'

// Integration with activities
implementation 'androidx.activity:activity-compose:1.4.0'
// Compose Material Design
implementation 'androidx.compose.material:material:1.0.5'
implementation 'androidx.compose.material:material:1.1.0'
// Tooling support (Previews, etc.)
implementation 'androidx.compose.ui:ui-tooling:1.0.5'
implementation "androidx.compose.ui:ui:1.0.5"
implementation "androidx.compose.ui:ui-tooling-preview:1.0.5"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.0'
implementation 'androidx.compose.ui:ui-tooling:1.1.0'
implementation "androidx.compose.ui:ui:1.1.0"
implementation "androidx.compose.ui:ui-tooling-preview:1.1.0"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.1'
implementation 'io.coil-kt:coil-compose:1.3.0'

implementation "androidx.recyclerview:recyclerview:1.2.0-alpha04"
implementation 'androidx.databinding:databinding-runtime:4.1.3'
implementation "androidx.core:core-splashscreen:1.0.0-alpha02"
implementation "androidx.recyclerview:recyclerview:1.3.0-alpha01"
implementation 'androidx.databinding:databinding-runtime:7.1.1'
implementation "androidx.core:core-splashscreen:1.0.0-beta01"

//Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0"

//Fuel
implementation "com.github.kittinunf.fuel:fuel-android:2.3.1"

implementation 'com.google.android.gms:play-services-maps:18.0.2'
implementation 'com.google.android.gms:play-services-location:19.0.1'

implementation 'com.google.code.gson:gson:2.8.9'

implementation "androidx.work:work-runtime-ktx:2.7.1"

implementation 'com.github.fondesa:kpermissions:3.3.0'

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.github.bumptech.glide:glide:4.12.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.0.5"
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.1.0"
kapt 'com.github.bumptech.glide:compiler:4.12.0'
}
30 changes: 20 additions & 10 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,22 @@

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.MobvenExtensions">
<activity android:name=".compose.layout.LayoutComposeActivity" />
<activity android:name=".onactivityresultapi.ChooseFromGalleryActivity" />
<activity android:name=".ViewExtDemoActivity" />
<receiver
android:name=".remindmethere.GeofenceBroadcastReceiver"
android:enabled="true"
android:exported="true"/>
<activity android:name=".recyclerview.concatadapter.ConcatExampleActivity" />
<activity android:name=".MainActivity">
<activity
android:name=".coroutine.CoroutineFundamentalsActivity"
android:exported="false" />
<activity
android:name=".compose.layout.LayoutComposeActivity"
android:exported="false" />
Expand All @@ -32,15 +31,26 @@
android:exported="false" />
<activity
android:name=".MainActivity"
android:theme="@style/Theme.MySplash"
android:exported="true">
android:exported="true"
android:theme="@style/Theme.MySplash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".compose.ComposePlaygroundActivity" />

<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />

<activity
android:name=".remindmethere.MapsActivity"
android:exported="false"
android:label="@string/title_activity_maps" />

<service android:name=".remindmethere.GeofenceForegroundService" android:foregroundServiceType="location" android:stopWithTask="false" />
</application>

</manifest>
</manifest>
1 change: 1 addition & 0 deletions app/src/main/java/com/mobven/extensions/Menu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ annotation class Menu {
const val LAYOUT_COMPOSE = "Compose Layout"
const val CONCAT_ADAPTER = "Concat Adapter"
const val DIFF_UTIL_LIST = "Diff Util RecyclerView"
const val GEOFENCE = "Geofence"
}
}
5 changes: 4 additions & 1 deletion app/src/main/java/com/mobven/extensions/MenuFragment.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mobven.extensions

import android.Manifest
import android.content.Intent
import android.os.Bundle
import android.util.Log
Expand All @@ -16,6 +17,7 @@ import com.mobven.extensions.compose.ComposePlaygroundActivity
import com.mobven.extensions.compose.layout.LayoutComposeActivity
import com.mobven.extensions.databinding.FragmentMenuBinding
import com.mobven.extensions.recyclerview.concatadapter.ConcatExampleActivity
import com.mobven.extensions.remindmethere.MapsActivity

class MenuFragment : Fragment() {

Expand Down Expand Up @@ -64,10 +66,11 @@ class MenuFragment : Fragment() {
Menu.SINGLE_SELECT_LIST -> findNavController().navigate(R.id.action_menuFragment_to_singleSelectableRecyclerView)
Menu.DIFF_UTIL_LIST -> findNavController().navigate(R.id.action_menuFragment_to_diffUtilRecyclerView)
Menu.VIEW_EXT -> findNavController().navigate(R.id.action_menuFragment_to_viewExtDemoActivity)
Menu.REQUEST_PERMISSIONS -> permissionChecker.launch(arrayOf(android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION, android.Manifest.permission.CAMERA, android.Manifest.permission.WRITE_EXTERNAL_STORAGE))
Menu.REQUEST_PERMISSIONS -> permissionChecker.launch(arrayOf(Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_BACKGROUND_LOCATION, Manifest.permission.WRITE_EXTERNAL_STORAGE))
Menu.COMPOSE_PLAYGROUND -> startActivity(Intent(requireContext(), ComposePlaygroundActivity::class.java))
Menu.LAYOUT_COMPOSE -> startActivity(Intent(requireContext(), LayoutComposeActivity::class.java))
Menu.CONCAT_ADAPTER -> startActivity(Intent(requireContext(), ConcatExampleActivity::class.java))
Menu.GEOFENCE -> startActivity(Intent(requireContext(), MapsActivity::class.java))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.mobven.extension.click
import com.mobven.extension.toast
import com.mobven.extensions.databinding.FragmentSingleSelectableRvBinding

class DiffUtilRecyclerViewFragment : Fragment() {

private var _binding: FragmentSingleSelectableRvBinding? = null
private val binding get() = _binding!!
private lateinit var adapter: MyDiffUtilAdapter

private val stars = listOf(
"Aldebaran",
Expand All @@ -34,11 +36,7 @@ class DiffUtilRecyclerViewFragment : Fragment() {
"Sombrero",
"Pinwheel",
"Cartwheel",
"Large Magellonic Cloud",
"Hoags Object",
"Centaurus A",
"Leo",
"Virgo Stellar Stream"
"Large Magellonic Cloud"
)

override fun onCreateView(
Expand All @@ -52,6 +50,9 @@ class DiffUtilRecyclerViewFragment : Fragment() {

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.btnDiffutil.click {
adapter.updateList(galaxies)
}
useDiffUtil()
}

Expand All @@ -62,15 +63,15 @@ class DiffUtilRecyclerViewFragment : Fragment() {
}

private fun useDiffUtil() {
val adapter = MyDiffUtilAdapter(galaxies)
adapter = MyDiffUtilAdapter(stars)
binding.apply {
rvSingleSelectable.adapter = adapter
rvSingleSelectable.setHasFixedSize(true)

adapter.itemClickListener = { _, name ->
requireContext().toast(name)
}
adapter.updateList(galaxies)
//adapter.updateList(galaxies)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.mobven.extensions.remindmethere

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.mobven.extensions.databinding.ActivityGeofenceBinding


class GeofenceActivity : AppCompatActivity() {

private lateinit var binding: ActivityGeofenceBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityGeofenceBinding.inflate(layoutInflater)
setContentView(binding.root)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.mobven.extensions.remindmethere

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log
import com.google.android.gms.location.Geofence
import com.google.android.gms.location.GeofenceStatusCodes
import com.google.android.gms.location.GeofencingEvent
import com.mobven.extension.toast

class GeofenceBroadcastReceiver : BroadcastReceiver() {

private val TAG = "GeofenceBroadcastReceiv"

override fun onReceive(context: Context, intent: Intent) {
val notificationHelper = NotificationHelper(context)
val geofencingEvent = GeofencingEvent.fromIntent(intent)

if (geofencingEvent.hasError()) {
val errorMessage = GeofenceStatusCodes
.getStatusCodeString(geofencingEvent.errorCode)
Log.e(TAG, errorMessage)
return
}

val geofenceList: List<Geofence>? = geofencingEvent.triggeringGeofences
geofenceList?.forEach {
Log.d(TAG, "onReceive: ${it.requestId}")
}

when (geofencingEvent.geofenceTransition) {
Geofence.GEOFENCE_TRANSITION_ENTER -> {
context.toast("GEOFENCE_TRANSITION_ENTER")
Log.d(TAG, "GEOFENCE_TRANSITION_ENTER")
notificationHelper.sendHighPriorityNotification(
"GEOFENCE_TRANSITION_ENTER",
"",
MapsActivity::class.java
)
}
Geofence.GEOFENCE_TRANSITION_EXIT -> {
context.toast("GEOFENCE_TRANSITION_EXIT")
Log.d(TAG, "GEOFENCE_TRANSITION_EXIT")
notificationHelper.sendHighPriorityNotification(
"GEOFENCE_TRANSITION_EXIT",
"",
MapsActivity::class.java
)
}
Geofence.GEOFENCE_TRANSITION_DWELL -> {
context.toast("GEOFENCE_TRANSITION_DWELL")
Log.d(TAG, "GEOFENCE_TRANSITION_DWELL")
notificationHelper.sendHighPriorityNotification(
"GEOFENCE_TRANSITION_DWELL",
"",
MapsActivity::class.java
)
}
}
}
}
Loading

0 comments on commit 7317d61

Please sign in to comment.