Skip to content

Commit f26ca1c

Browse files
committed
Add AppKillerManager and Smart App Rate libraries.
Minor fixes and cleanup.
1 parent b40077f commit f26ca1c

File tree

15 files changed

+148
-98
lines changed

15 files changed

+148
-98
lines changed

app/build.gradle

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ android {
1313
minSdkVersion 21
1414
targetSdkVersion 28
1515
versionCode 1
16-
versionName "1.0"
16+
versionName "1.0.0"
1717
kapt {
1818
arguments {
1919
arg("room.schemaLocation", "$projectDir/schemas".toString())
@@ -23,8 +23,21 @@ android {
2323
}
2424
buildTypes {
2525
release {
26-
minifyEnabled false
26+
minifyEnabled true
2727
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
28+
android.applicationVariants.all { variant ->
29+
variant.outputs.all {
30+
outputFileName = "${variant.name}-${variant.versionName}.apk"
31+
}
32+
variant.assembleProvider.get().doLast {
33+
if (variant.mappingFile != null && variant.mappingFile.exists()) {
34+
def mappingFilename = "$archivesBaseName-$variant.baseName-mapping-${variant.versionName}.txt"
35+
(new File(variant.mappingFile.parent, mappingFilename)).delete()
36+
variant.mappingFile.renameTo(variant.mappingFile.parent +
37+
"/" + mappingFilename)
38+
}
39+
}
40+
}
2841
}
2942
}
3043
dataBinding {
@@ -37,7 +50,7 @@ ext {
3750
gson_version = "2.8.5"
3851
room_version = "2.1.0-alpha04"
3952
coroutines_version = "1.1.0"
40-
firebase_core_version = "16.0.6"
53+
firebase_core_version = "16.0.7"
4154
firebase_messaging_version = "17.3.4"
4255
firebase_jobdispatcher_version = "0.8.5"
4356
retrofit_version = "2.5.0"
@@ -47,6 +60,9 @@ ext {
4760
workmanager_version = "1.0.0-beta04"
4861
lifecycle_version = "2.1.0-alpha02"
4962
material_version = "1.0.0"
63+
safetynet_version = "16.0.0"
64+
appkillermanager_version = "2.1.1"
65+
smartapprate_version = "1.0.8"
5066
}
5167

5268
dependencies {
@@ -58,8 +74,8 @@ dependencies {
5874
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
5975

6076
testImplementation 'junit:junit:4.12'
61-
androidTestImplementation 'androidx.test:runner:1.1.1'
62-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
77+
androidTestImplementation 'androidx.test:runner:1.1.2-alpha01'
78+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.2-alpha01'
6379

6480
// ViewModel & LiveData
6581
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
@@ -103,7 +119,14 @@ dependencies {
103119
implementation "com.google.android.material:material:$material_version"
104120

105121
// Captcha
106-
implementation 'com.google.android.gms:play-services-safetynet:16.0.0'
122+
implementation "com.google.android.gms:play-services-safetynet:$safetynet_version"
123+
124+
// 3rd party
125+
// https://github.com/thelittlefireman/AppKillerManager/tree/master
126+
implementation "com.thelittlefireman:AppKillerManager:$appkillermanager_version"
127+
128+
// https://github.com/codemybrainsout/smart-app-rate
129+
implementation "com.codemybrainsout.rating:ratingdialog:$smartapprate_version"
107130
}
108131

109132
apply plugin: 'com.google.gms.google-services'

app/src/main/java/in/bitotsav/HomeActivity.kt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package `in`.bitotsav
22

33
import `in`.bitotsav.databinding.ActivityHomeBinding
4-
import `in`.bitotsav.events.ui.ScheduleViewModel
54
import `in`.bitotsav.shared.ui.UiUtilViewModel
6-
import `in`.bitotsav.shared.utils.getColorCompat
75
import android.os.Build
86
import android.os.Bundle
97
import android.util.TypedValue
@@ -14,6 +12,8 @@ import androidx.databinding.DataBindingUtil
1412
import androidx.navigation.Navigation
1513
import androidx.navigation.ui.setupWithNavController
1614
import com.google.android.material.bottomnavigation.BottomNavigationView
15+
import com.thelittlefireman.appkillermanager.managers.KillerManager
16+
import com.thelittlefireman.appkillermanager.ui.DialogKillerManagerBuilder
1717
import org.koin.androidx.viewmodel.ext.viewModel
1818

1919
class HomeActivity : AppCompatActivity() {
@@ -40,6 +40,11 @@ class HomeActivity : AppCompatActivity() {
4040
binding.lifecycleOwner = this
4141
handlePlatformLimitations()
4242
setupBottomNavMenu()
43+
44+
// AppKillerManager
45+
startDialog(KillerManager.Actions.ACTION_AUTOSTART)
46+
startDialog(KillerManager.Actions.ACTION_NOTIFICATIONS)
47+
startDialog(KillerManager.Actions.ACTION_POWERSAVING)
4348
}
4449

4550
private fun setupBottomNavMenu() {
@@ -57,4 +62,8 @@ class HomeActivity : AppCompatActivity() {
5762
}
5863
}
5964
}
65+
66+
private fun startDialog(actions: KillerManager.Actions) {
67+
DialogKillerManagerBuilder().setContext(this).setAction(actions).show()
68+
}
6069
}

app/src/main/java/in/bitotsav/events/data/Event.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ data class Event(
2525
@SerializedName("eventRules") val rules: String,
2626
@SerializedName("eventContact1Name") val contact1Name: String,
2727
@SerializedName("eventContact1Number") val contact1Number: Long,
28-
// TODO: This can be null or empty. Handle it in UI accordingly
28+
// This can be null or empty. Handle it in UI accordingly
2929
@SerializedName("eventContact2Name") val contact2Name: String? = null,
3030
@SerializedName("eventContact2Number") val contact2Number: Long? = null,
3131
@SerializedName("eventPoints1") val points1: Int,
@@ -40,12 +40,12 @@ data class Event(
4040
@SerializedName("eventPrize1") val prize1: Int,
4141
@SerializedName("eventPrize2") val prize2: Int,
4242
@SerializedName("eventPrize3") val prize3: Int,
43-
// TODO: Note: Default value is empty map
43+
// Note: Default value is empty map
4444
// eventPosition1: {
45-
// teamLeader: req.body.eventPosition1,
46-
// teamLeaderName: map[req.body.eventPosition1].name,
47-
// championshipTeam: (team1 != null) ? team1 : "-1",
48-
// points: (team1 != null) ? event.eventPoints1 : 0
45+
// teamLeader: String,
46+
// teamLeaderName: String,
47+
// championshipTeam: String = "-1",
48+
// points: String = 0
4949
//}
5050
@SerializedName("eventPosition1") val position1: Map<String, String>?,
5151
@SerializedName("eventPosition2") val position2: Map<String, String>?,

app/src/main/java/in/bitotsav/events/utils/EventRegistrationUtils.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fun registerForEventAsync(
3434
val response = request.await()
3535
Log.d(TAG, "Response Code: ${response.code()}")
3636
when (response.code()) {
37-
200 -> Log.d(TAG, "Registered for event $eventId")
37+
200 -> run { Log.d(TAG, "Registered for event $eventId") }
3838
404 -> throw Exception("Incorrect Bitotsav id and/or email id")
3939
405 -> throw Exception("All members don't belong to the same college")
4040
408 -> throw Exception("Registration for this event has been closed")
@@ -61,7 +61,7 @@ fun deregisterForEventAsync(
6161
val response = request.await()
6262
Log.d(TAG, "Response Code: ${response.code()}")
6363
when (response.code()) {
64-
200 -> Log.d(TAG, "De-registered for event $eventId")
64+
200 -> run { Log.d(TAG, "De-registered for event $eventId") }
6565
403 -> throw Exception("Not registered for this event or not the team leader")
6666
408 -> throw Exception("De-registration for this event has been closed")
6767
else -> throw Exception("Server is currently facing some issues. Try again later")

app/src/main/java/in/bitotsav/info/ui/InfoFragment.kt

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@ package `in`.bitotsav.info.ui
33
import `in`.bitotsav.R
44
import `in`.bitotsav.databinding.FragmentInfoBinding
55
import `in`.bitotsav.info.ui.InfoPageFragment.InfoPage
6-
import `in`.bitotsav.shared.utils.getColorCompat
6+
import android.content.Intent
7+
import android.net.Uri
78
import android.os.Bundle
89
import android.util.TypedValue
910
import android.view.LayoutInflater
1011
import android.view.View
1112
import android.view.ViewGroup
13+
import androidx.appcompat.content.res.AppCompatResources
1214
import androidx.fragment.app.Fragment
1315
import androidx.fragment.app.FragmentManager
1416
import androidx.fragment.app.FragmentPagerAdapter
17+
import com.codemybrainsout.ratingdialog.RatingDialog
1518
import org.koin.androidx.viewmodel.ext.sharedViewModel
1619

1720

@@ -40,6 +43,9 @@ class InfoFragment : Fragment() {
4043
infoPager.offscreenPageLimit = PAGES - 1
4144
infoPager.adapter = InfoPageAdapter(childFragmentManager)
4245
appBar.tabs.setupWithViewPager(infoPager)
46+
feedbackFab.setOnClickListener {
47+
feedback()
48+
}
4349
}
4450
.root
4551

@@ -57,4 +63,35 @@ class InfoFragment : Fragment() {
5763
}
5864
}
5965

66+
private fun feedback() {
67+
context?.let {
68+
val ratingDialog = RatingDialog.Builder(it)
69+
.icon(AppCompatResources.getDrawable(it, `in`.bitotsav.R.drawable.ic_bitotsav_red_24dp)!!)
70+
.threshold(4f)
71+
.title("How was your experience with us?")
72+
.positiveButtonText("Not Now")
73+
.negativeButtonText("Never")
74+
.formTitle("Submit Feedback")
75+
.formHint("Tell us where we can improve")
76+
.formSubmitText("Submit")
77+
.formCancelText("Cancel")
78+
.playstoreUrl("YOUR_URL")
79+
.onRatingBarFormSumbit { feedback ->
80+
val intent = Intent(Intent.ACTION_SENDTO).apply {
81+
data = Uri.parse("mailto:")
82+
putExtra(Intent.EXTRA_EMAIL, arrayOf("[email protected]"))
83+
putExtra(Intent.EXTRA_SUBJECT, "Bitotsav '19 App Feedback")
84+
putExtra(Intent.EXTRA_TEXT, feedback)
85+
}
86+
activity?.packageManager?.let { packageManager ->
87+
if (intent.resolveActivity(packageManager) != null) {
88+
startActivity(intent)
89+
}
90+
}
91+
}.build()
92+
93+
ratingDialog.show()
94+
}
95+
}
96+
6097
}
Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
package `in`.bitotsav.info.ui
22

33
import `in`.bitotsav.shared.ui.BaseViewModel
4-
import androidx.lifecycle.ViewModel
54

6-
class InfoViewModel : BaseViewModel() {
7-
8-
fun feedback() {
9-
10-
}
11-
12-
13-
14-
}
5+
class InfoViewModel : BaseViewModel()

app/src/main/java/in/bitotsav/notification/utils/FcmUtils.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ fun sendFcmTokenAsync(authToken: String, fcmToken: String): Deferred<Any> {
3333
return@async true
3434
} else {
3535
when (response.code()) {
36-
// TODO("Delete local token for 403")
3736
403 -> throw NonRetryableException("Fcm token missing or user authentication failed")
3837
409 -> throw NonRetryableException("Token already exists")
3938
else -> throw NetworkException("Unable to send token to server. Response code: ${response.code()}")
@@ -58,7 +57,6 @@ fun deleteFcmTokenAsync(authToken: String, fcmToken: String): Deferred<Any> {
5857
return@async true
5958
} else {
6059
when (response.code()) {
61-
// TODO("Delete local token for 403")
6260
403 -> throw NonRetryableException("Fcm token missing or user authentication failed")
6361
404 -> throw NonRetryableException("Token not found")
6462
else -> throw NetworkException("Unable to send token to server. Response code: ${response.code()}")

app/src/main/java/in/bitotsav/notification/utils/NotificationUtils.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ fun displayNotification(
3939
val bigTextStyle = NotificationCompat.BigTextStyle()
4040
bigTextStyle.bigText(content)
4141

42-
// TODO("Set small icon, large icon and color")
4342
val channelId = channel.id
4443
val notificationBuilder = NotificationCompat.Builder(context, channelId)
4544
.setSmallIcon(getIconByChannel(channel))

app/src/main/java/in/bitotsav/profile/utils/AuthUtils.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ fun registerAsync(
6464
val request = authService.registerAsync(body)
6565
val response = request.await()
6666
when (response.code()) {
67-
200 -> Log.d(TAG, "Registration Stage 1 complete")
67+
200 -> run { Log.d(TAG, "Registration Stage 1 complete") }
6868
403 -> throw AuthException("Captcha verification failed")
6969
409 -> throw AuthException("Email id is already registered")
7070
else -> throw NetworkException(
@@ -92,7 +92,7 @@ fun verifyAsync(
9292
val request = authService.verifyAsync(body)
9393
val response = request.await()
9494
when (response.code()) {
95-
200 -> Log.d(TAG, "Registration Stage 2: OTP verification complete")
95+
200 -> run { Log.d(TAG, "Registration Stage 2: OTP verification complete") }
9696

9797
403 -> throw AuthException("Incorrect OTP(s)")
9898
400 -> throw AuthException(

app/src/main/java/in/bitotsav/profile/utils/ProfileUtils.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ fun fetchProfileDetailsAsync(authToken: String): Deferred<Any> {
3636
val response = request.await()
3737
if (response.code() == 200) {
3838
Log.d(TAG, "Participant details received from server")
39-
// ("Store participant details here")
4039
// "teamMembers": [
4140
// {
4241
// "name": $name,

0 commit comments

Comments
 (0)