Skip to content

Commit

Permalink
Merge pull request #1 from imprakharshukla/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
imprakharshukla authored Aug 9, 2022
2 parents 1771e7a + aaebe04 commit 878a6b1
Show file tree
Hide file tree
Showing 31 changed files with 284 additions and 50 deletions.
15 changes: 7 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ android {
applicationId "com.techriz.andronix.donation"
minSdk 24
targetSdk 31
versionCode 13
versionName "2.0"
versionCode 14
versionName "3.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Expand Down Expand Up @@ -71,8 +71,8 @@ dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.3.5'

//Hilt
implementation "com.google.dagger:hilt-android:2.35"
kapt "com.google.dagger:hilt-android-compiler:2.35"
implementation "com.google.dagger:hilt-android:2.38.1"
kapt "com.google.dagger:hilt-compiler:2.38.1"
kapt 'androidx.hilt:hilt-compiler:1.0.0'


Expand Down Expand Up @@ -114,6 +114,7 @@ dependencies {
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'com.github.florent37:viewanimator:1.1.2'
implementation 'com.facebook.shimmer:shimmer:0.5.0'
implementation 'com.github.GrenderG:Toasty:1.5.2'

//NETWORKING
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
Expand All @@ -122,11 +123,9 @@ dependencies {
implementation 'com.squareup.okhttp3:logging-interceptor:4.2.1'

//BILLING
implementation 'com.android.billingclient:billing:3.0.2'
implementation 'com.android.billingclient:billing:4.0.0'
implementation "com.android.billingclient:billing-ktx:4.0.0"

//design
implementation 'com.google.android.material:material:1.5.0-alpha05'
implementation 'com.github.GrenderG:Toasty:1.5.2'

//images
implementation "io.coil-kt:coil:1.4.0"
Expand Down
14 changes: 9 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.techriz.andronix.donation">


<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.android.vending.BILLING" />

Expand All @@ -11,18 +10,23 @@
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/DarkTheme">
<activity
android:name=".MainActivity"
android:exported="true">
android:name=".ui.fragments.SplashActivity"
android:exported="true"
android:theme="@style/SplashAppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:exported="true">

</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)




binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package com.techriz.andronix.donation.di

import android.content.Context
import com.techriz.andronix.donation.ui.fragments.Loader
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.FragmentComponent
import dagger.hilt.android.qualifiers.ActivityContext
import dagger.hilt.android.scopes.FragmentScoped
import kotlinx.coroutines.ExperimentalCoroutinesApi
import studio.com.techriz.andronix.ui.Loader


@Module
@InstallIn(FragmentComponent::class)
object MiscModule {
object MiscModule {
@Provides
@FragmentScoped
fun providesLoader(@ActivityContext context: Context): Loader {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,11 @@ class BillingRepository @Inject constructor(
private suspend fun verifyPurchase(purchase: Purchase) {
try {
val response =
purchaseAPI.getPurchaseVerification(purchase.sku, purchase.purchaseToken, "true")
purchaseAPI.getPurchaseVerification(
purchase.skus.first(),
purchase.purchaseToken,
"true"
)
.awaitResponse()
if (response.isSuccessful && response.body() != null) {
response.body()?.orderID.let { orderIdFromServer ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.datastore.preferences.core.emptyPreferences
import androidx.datastore.preferences.core.stringPreferencesKey
import androidx.datastore.preferences.preferencesDataStore
import com.techriz.andronix.donation.utils.Constants.DARK_MODE
import com.techriz.andronix.donation.utils.Constants.LIGHT_MODE
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.catch
Expand All @@ -33,9 +34,7 @@ class SettingsRepository @Inject constructor(


suspend fun getTheme(): String {
val theme = context.settingsDataStore.getValueAsFlow(THEME_KEY, DARK_MODE).first()
println("GetTheme $theme")
return theme
return context.settingsDataStore.getValueAsFlow(THEME_KEY, DARK_MODE).first()
}

fun getThemeLive(): Flow<String> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.techriz.andronix.donation.ui.fragments

import android.annotation.SuppressLint
import android.os.Bundle
import android.text.method.LinkMovementMethod
import android.view.Gravity
import android.view.View
import android.widget.ImageView
Expand All @@ -22,6 +23,7 @@ import com.techriz.andronix.donation.R
import com.techriz.andronix.donation.databinding.DashboardFragmentBinding
import com.techriz.andronix.donation.databinding.LoginFirstSheetBinding
import com.techriz.andronix.donation.databinding.UserInfoBottomsheetBinding
import com.techriz.andronix.donation.utils.ActionUtils
import com.techriz.andronix.donation.utils.NavigationAnimations
import com.techriz.andronix.donation.utils.NavigationAnimations.safeNavigate
import com.techriz.andronix.donation.utils.SkuInfo
Expand All @@ -30,15 +32,27 @@ import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class DashboardFragment : Fragment(R.layout.dashboard_fragment) {
private val ANDRONIX_PLAY_STORE_URL: String = "https://play.andronix.app"
private lateinit var binding: DashboardFragmentBinding
val viewModel: DashboardViewModel by viewModels();
val viewModel: DashboardViewModel by viewModels()

@SuppressLint("WrongConstant")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

binding = DashboardFragmentBinding.bind(view)


binding.dashboardWarning.movementMethod = LinkMovementMethod.getInstance()
binding.dashboardWarning.text = viewModel.getWarningSpans(
requireContext().getString(
R.string.warning_text_dashboard
)
) {
ActionUtils.getBrowser(requireContext(), ANDRONIX_PLAY_STORE_URL)
}


binding.hamMenu.setOnClickListener {
val navDrawer = activity?.findViewById<DrawerLayout>(R.id.drawer_layout)
navDrawer?.let {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package com.techriz.andronix.donation.ui.fragments

import android.text.SpannableString
import android.text.Spanned
import android.text.style.ClickableSpan
import android.text.style.StyleSpan
import android.view.View
import androidx.lifecycle.ViewModel
import com.google.firebase.auth.ktx.auth
import com.google.firebase.ktx.Firebase
Expand Down Expand Up @@ -28,11 +33,39 @@ class DashboardViewModel @Inject constructor() : ViewModel() {
}

fun getUserPfp(): String {
val email = getUserEmail() ?: ('a'..'z').random() + (0..1000).random()
.toString() + ('a'..'z').random() + ('a'..'z').random()
val email = getUserEmail() ?: (('a'..'z').random() + (0..1000).random()
.toString() + ('a'..'z').random() + ('a'..'z').random())
return Firebase.auth.currentUser?.photoUrl?.toString()
?: "https://avatars.dicebear.com/api/jdenticon/$email.svg"
}

fun getWarningSpans(

text: String,
downloadLinkFunction: () -> Unit,
): SpannableString {
val ss = SpannableString(text)
val clickableSpan1: ClickableSpan = object : ClickableSpan() {
override fun onClick(widget: View) {
downloadLinkFunction()
}
}
val styleSpan = StyleSpan(android.graphics.Typeface.BOLD) // Span to make text bold

ss.setSpan(
clickableSpan1,
ss.indexOf("here"),
ss.indexOf("here") + 4,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
)
ss.setSpan(
styleSpan,
ss.indexOf("and"),
ss.indexOf("App"),
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
)
return ss
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.view.LayoutInflater
import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialog
import com.techriz.andronix.donation.R
import com.techriz.andronix.donation.databinding.LoaderSheetBinding
import javax.inject.Inject


class Loader(val context: Context) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.techriz.andronix.donation.ui.fragments

import android.content.Intent
import android.os.Bundle
import android.os.PersistableBundle
import android.widget.Toast
import androidx.activity.viewModels
import com.google.android.material.snackbar.Snackbar
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import androidx.navigation.findNavController
import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.navigateUp
import androidx.navigation.ui.setupActionBarWithNavController
import com.github.florent37.viewanimator.ViewAnimator
import com.techriz.andronix.donation.MainActivity
import com.techriz.andronix.donation.R
import com.techriz.andronix.donation.databinding.ActivitySplashBinding
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext

@AndroidEntryPoint
class SplashActivity : AppCompatActivity() {
lateinit var binding: ActivitySplashBinding

val viewModel: SplashViewModel by viewModels()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivitySplashBinding.inflate(layoutInflater)
setContentView(binding.root)
println("Executed!")
lifecycleScope.launch(Dispatchers.Main) {
viewModel.applyTheme()
animateLogo()
}
}

private fun animateLogo() {
ViewAnimator
.animate(binding.logo)
.pulse()
.duration(350)
.repeatCount(1)
.onStop {
lifecycleScope.launch {
this@SplashActivity.startActivity(
Intent(
this@SplashActivity,
MainActivity::class.java
)
)
finish()
}
}
.start()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.techriz.andronix.donation.ui.fragments;

import androidx.appcompat.app.AppCompatDelegate
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.techriz.andronix.donation.repository.SettingsRepository
import com.techriz.andronix.donation.utils.Constants.DARK_MODE
import com.techriz.andronix.donation.utils.Constants.DEVICE_MODE
import com.techriz.andronix.donation.utils.Constants.LIGHT_MODE

import javax.inject.Inject

import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.ExperimentalCoroutinesApi

@ExperimentalCoroutinesApi
@HiltViewModel
class SplashViewModel @Inject
constructor(val settingsRepository: SettingsRepository) : ViewModel() {

suspend fun applyTheme() {
when (settingsRepository.getTheme()) {
LIGHT_MODE -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
DARK_MODE -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
DEVICE_MODE -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import com.techriz.andronix.donation.R
import com.techriz.andronix.donation.databinding.LoginFragmentBinding
import com.techriz.andronix.donation.repository.AuthStateClass
import com.techriz.andronix.donation.repository.authLog
import com.techriz.andronix.donation.ui.fragments.Loader
import com.techriz.andronix.donation.utils.ActionUtils
import com.techriz.andronix.donation.utils.ActionUtils.showSnackbar
import com.techriz.andronix.donation.utils.Constants.ANDRONIX_PRIVACY
Expand All @@ -28,7 +29,7 @@ import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.onCompletion
import studio.com.techriz.andronix.ui.Loader

import studio.com.techriz.andronix.ui.PasswordResetFragment
import javax.inject.Inject

Expand All @@ -50,6 +51,7 @@ class LoginFragment : Fragment(R.layout.login_fragment) {
lateinit var passwordResetSheet: PasswordResetFragment

@Inject

lateinit var loader: Loader

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
Expand Down
Loading

0 comments on commit 878a6b1

Please sign in to comment.