removed api keys from gradle.properties files (#13)

* removed api keys from gradle.properties files
(cherry picked from commit e54dc864905eb5f8ef9374b9550d7def33fbfd1a)
* patched app.gradle
* fix to permissions dialog
This commit is contained in:
2022-06-10 01:16:16 +01:00
committed by GitHub
parent f7244ee015
commit 3d5cb4e9fe
4 changed files with 35 additions and 14 deletions

View File

@@ -20,8 +20,15 @@ android {
testInstrumentationRunner "com.appttude.h_mal.atlas_weather.application.TestRunner"
vectorDrawables.useSupportLibrary = true
buildConfigField "String", "ParamOne", "${paramOneEndPoint}"
buildConfigField "String", "ParamTwo", "${paramTwoEndPoint}"
Properties properties = new Properties()
if (project.rootProject.file('local.properties').canRead()) {
properties.load(project.rootProject.file('local.properties').newDataInputStream())
buildConfigField "String", "ParamOne", properties.getProperty('WEATHER_API')
buildConfigField "String", "ParamTwo", properties.getProperty('SEARCH_API')
} else {
buildConfigField "String", "ParamOne", System.getenv('WEATHER_API')
buildConfigField "String", "ParamTwo", System.getenv('SEARCH_API')
}
}
android {
sourceSets{

View File

@@ -20,7 +20,9 @@ abstract class BaseDeclarationDialog(val context: Context): DeclarationBuilder {
abstract override val link: String
abstract override val message: String
fun showDialog(agreeCallback: () -> Unit = { }, disagreeCallback: () -> Unit = { Unit }) {
lateinit var dialog: AlertDialog
fun showDialog(agreeCallback: () -> Unit = { }, disagreeCallback: () -> Unit = { }) {
val myMessage = buildMessage()
val builder = AlertDialog.Builder(context)
@@ -33,12 +35,14 @@ abstract class BaseDeclarationDialog(val context: Context): DeclarationBuilder {
.setMessage(myMessage)
.setCancelable(false)
val alertDialog = builder.create()
alertDialog.show()
dialog = builder.create()
dialog.show()
// Make the textview clickable. Must be called after show()
val msgTxt = alertDialog.findViewById<View>(android.R.id.message) as TextView?
val msgTxt = dialog.findViewById<View>(android.R.id.message) as TextView?
msgTxt?.movementMethod = LinkMovementMethod.getInstance()
}
fun dismiss() = dialog.dismiss()
}

View File

@@ -30,6 +30,8 @@ class HomeFragment : BaseFragment(R.layout.fragment_home) {
private val viewModel by getFragmentViewModel<MainViewModel>()
lateinit var dialog: PermissionsDeclarationDialog
@SuppressLint("MissingPermission")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
@@ -39,12 +41,7 @@ class HomeFragment : BaseFragment(R.layout.fragment_home) {
})
forecast_listview.adapter = recyclerAdapter
PermissionsDeclarationDialog(requireContext()).showDialog(agreeCallback = {
getPermissionResult(ACCESS_COARSE_LOCATION, LOCATION_PERMISSION_REQUEST) {
viewModel.fetchData()
}
})
dialog = PermissionsDeclarationDialog(requireContext())
swipe_refresh.apply {
setOnRefreshListener {
@@ -64,6 +61,21 @@ class HomeFragment : BaseFragment(R.layout.fragment_home) {
viewModel.operationRefresh.observe(viewLifecycleOwner, refreshObserver(swipe_refresh))
}
@SuppressLint("MissingPermission")
override fun onStart() {
super.onStart()
dialog.showDialog(agreeCallback = {
getPermissionResult(ACCESS_COARSE_LOCATION, LOCATION_PERMISSION_REQUEST) {
viewModel.fetchData()
}
})
}
override fun onStop() {
super.onStop()
dialog.dismiss()
}
@SuppressLint("MissingPermission")
override fun permissionsGranted() {
viewModel.fetchData()