mirror of
https://github.com/hmalik144/Weather-apps.git
synced 2025-12-10 02:05:20 +00:00
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:
@@ -20,8 +20,15 @@ android {
|
|||||||
testInstrumentationRunner "com.appttude.h_mal.atlas_weather.application.TestRunner"
|
testInstrumentationRunner "com.appttude.h_mal.atlas_weather.application.TestRunner"
|
||||||
vectorDrawables.useSupportLibrary = true
|
vectorDrawables.useSupportLibrary = true
|
||||||
|
|
||||||
buildConfigField "String", "ParamOne", "${paramOneEndPoint}"
|
Properties properties = new Properties()
|
||||||
buildConfigField "String", "ParamTwo", "${paramTwoEndPoint}"
|
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 {
|
android {
|
||||||
sourceSets{
|
sourceSets{
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ abstract class BaseDeclarationDialog(val context: Context): DeclarationBuilder {
|
|||||||
abstract override val link: String
|
abstract override val link: String
|
||||||
abstract override val message: 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 myMessage = buildMessage()
|
||||||
|
|
||||||
val builder = AlertDialog.Builder(context)
|
val builder = AlertDialog.Builder(context)
|
||||||
@@ -33,12 +35,14 @@ abstract class BaseDeclarationDialog(val context: Context): DeclarationBuilder {
|
|||||||
.setMessage(myMessage)
|
.setMessage(myMessage)
|
||||||
.setCancelable(false)
|
.setCancelable(false)
|
||||||
|
|
||||||
val alertDialog = builder.create()
|
dialog = builder.create()
|
||||||
alertDialog.show()
|
dialog.show()
|
||||||
|
|
||||||
// Make the textview clickable. Must be called after 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()
|
msgTxt?.movementMethod = LinkMovementMethod.getInstance()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun dismiss() = dialog.dismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ class HomeFragment : BaseFragment(R.layout.fragment_home) {
|
|||||||
|
|
||||||
private val viewModel by getFragmentViewModel<MainViewModel>()
|
private val viewModel by getFragmentViewModel<MainViewModel>()
|
||||||
|
|
||||||
|
lateinit var dialog: PermissionsDeclarationDialog
|
||||||
|
|
||||||
@SuppressLint("MissingPermission")
|
@SuppressLint("MissingPermission")
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
@@ -39,12 +41,7 @@ class HomeFragment : BaseFragment(R.layout.fragment_home) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
forecast_listview.adapter = recyclerAdapter
|
forecast_listview.adapter = recyclerAdapter
|
||||||
|
dialog = PermissionsDeclarationDialog(requireContext())
|
||||||
PermissionsDeclarationDialog(requireContext()).showDialog(agreeCallback = {
|
|
||||||
getPermissionResult(ACCESS_COARSE_LOCATION, LOCATION_PERMISSION_REQUEST) {
|
|
||||||
viewModel.fetchData()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
swipe_refresh.apply {
|
swipe_refresh.apply {
|
||||||
setOnRefreshListener {
|
setOnRefreshListener {
|
||||||
@@ -64,6 +61,21 @@ class HomeFragment : BaseFragment(R.layout.fragment_home) {
|
|||||||
viewModel.operationRefresh.observe(viewLifecycleOwner, refreshObserver(swipe_refresh))
|
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")
|
@SuppressLint("MissingPermission")
|
||||||
override fun permissionsGranted() {
|
override fun permissionsGranted() {
|
||||||
viewModel.fetchData()
|
viewModel.fetchData()
|
||||||
|
|||||||
@@ -17,5 +17,3 @@ org.gradle.jvmargs=-Xmx1536m
|
|||||||
# This option should only be used with decoupled projects. More details, visit
|
# This option should only be used with decoupled projects. More details, visit
|
||||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||||
# org.gradle.parallel=true
|
# org.gradle.parallel=true
|
||||||
paramOneEndPoint="ed03070baf705c1185fa40f245bf8cca"
|
|
||||||
paramTwoEndPoint="WkQ8IlFaKCpn6LfwqpjV2QygC878kSbJ"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user