-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from armancodv/settings-events
settings and events
- Loading branch information
Showing
48 changed files
with
682 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
app/src/main/java/com/armanco/integral/extensions/Context_extensions.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
app/src/main/java/com/armanco/integral/navigation/image/ImageViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.armanco.integral.navigation.image | ||
|
||
import androidx.lifecycle.MutableLiveData | ||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.viewModelScope | ||
import com.armanco.integral.managers.repository.FormulaRepository | ||
import com.armanco.integral.models.Formula | ||
import com.armanco.integral.utils.facade.EventFacade | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import kotlinx.coroutines.launch | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
class ImageViewModel @Inject constructor( | ||
private val eventFacade: EventFacade | ||
): ViewModel() { | ||
fun load() { | ||
eventFacade.screenView(ImageFragment::class.java.simpleName) | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
app/src/main/java/com/armanco/integral/navigation/settings/SettingsFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.armanco.integral.navigation.settings | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
import androidx.fragment.app.Fragment | ||
import androidx.fragment.app.viewModels | ||
import com.armanco.integral.R | ||
import com.armanco.integral.utils.extensions.goToGooglePlay | ||
import com.armanco.integral.utils.extensions.goToUrl | ||
import com.armanco.integral.utils.extensions.isPro | ||
import com.armanco.integral.utils.facade.ReviewFacade | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import kotlinx.android.synthetic.main.fragment_settings.* | ||
|
||
@AndroidEntryPoint | ||
class SettingsFragment: Fragment(R.layout.fragment_settings) { | ||
|
||
private val model: SettingsViewModel by viewModels() | ||
|
||
private val reviewFacade = ReviewFacade() | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
model.load() | ||
reviewFacade.init(context) | ||
proVersion?.visibility = if(isPro) View.GONE else View.VISIBLE | ||
proVersion?.onClick = { | ||
model.selectProVersion() | ||
activity?.goToGooglePlay("com.armanco.integral_pro") | ||
} | ||
reportBug?.onClick = { | ||
model.selectReportBug() | ||
activity?.goToUrl("https://github.com/armancodv/integral/issues") | ||
} | ||
contribute?.onClick = { | ||
model.selectContribute() | ||
activity?.goToUrl("https://github.com/armancodv/integral") | ||
} | ||
rate?.onClick = { | ||
model.selectRate() | ||
reviewFacade.showReview(activity) | ||
} | ||
reviewFacade.onFinished = { | ||
model.submitRate() | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
app/src/main/java/com/armanco/integral/navigation/settings/SettingsViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.armanco.integral.navigation.settings | ||
|
||
import androidx.lifecycle.MutableLiveData | ||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.viewModelScope | ||
import com.armanco.integral.managers.repository.FormulaRepository | ||
import com.armanco.integral.models.Formula | ||
import com.armanco.integral.utils.facade.EventFacade | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import kotlinx.coroutines.launch | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
class SettingsViewModel @Inject constructor( | ||
private val eventFacade: EventFacade | ||
): ViewModel() { | ||
|
||
fun load() { | ||
eventFacade.screenView(SettingsFragment::class.java.simpleName) | ||
} | ||
|
||
fun selectProVersion() { | ||
eventFacade.selectProVersion() | ||
} | ||
|
||
fun selectReportBug() { | ||
eventFacade.selectReportBug() | ||
} | ||
|
||
fun selectContribute() { | ||
eventFacade.selectContribute() | ||
} | ||
|
||
fun selectRate() { | ||
eventFacade.selectRate() | ||
} | ||
|
||
fun submitRate() { | ||
eventFacade.submitRate() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
app/src/main/java/com/armanco/integral/utils/extensions/Activity_extensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.armanco.integral.utils.extensions | ||
|
||
import android.app.Activity | ||
import android.content.ActivityNotFoundException | ||
import android.content.Intent | ||
import android.net.Uri | ||
|
||
|
||
fun Activity.goToGooglePlay(appPackageName: String) { | ||
val intent = try { | ||
Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=$appPackageName")) | ||
} catch (activityNotFoundException: ActivityNotFoundException) { | ||
Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=$appPackageName")) | ||
} | ||
startActivity(intent) | ||
} | ||
|
||
fun Activity.goToGooglePlay() { | ||
goToGooglePlay(packageName) | ||
} | ||
|
||
fun Activity.goToUrl(url: String?) { | ||
val uri = Uri.parse(url) | ||
val intent = Intent(Intent.ACTION_VIEW, uri) | ||
startActivity(intent) | ||
} |
Oops, something went wrong.