-
Notifications
You must be signed in to change notification settings - Fork 0
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 #20 from philippluxi/release/v0.4
[Release] - v0.4 - Release to Master
- Loading branch information
Showing
24 changed files
with
790 additions
and
324 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
75 changes: 0 additions & 75 deletions
75
app/src/main/java/com/archaeologicalfieldwork/activities/MapActivity.kt
This file was deleted.
Oops, something went wrong.
134 changes: 0 additions & 134 deletions
134
app/src/main/java/com/archaeologicalfieldwork/activities/SpotActivity.kt
This file was deleted.
Oops, something went wrong.
53 changes: 53 additions & 0 deletions
53
app/src/main/java/com/archaeologicalfieldwork/helpers/LocationHelpers.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,53 @@ | ||
package com.archaeologicalfieldwork.helpers | ||
|
||
import android.Manifest | ||
import android.annotation.SuppressLint | ||
import android.app.Activity | ||
import android.content.pm.PackageManager | ||
import android.util.Log | ||
import androidx.core.app.ActivityCompat | ||
import com.google.android.gms.location.LocationRequest | ||
|
||
val REQUEST_PERMISSIONS_REQUEST_CODE = 34 | ||
|
||
fun checkLocationPermissions(activity: Activity): Boolean { | ||
if (ActivityCompat.checkSelfPermission( | ||
activity, | ||
Manifest.permission.ACCESS_FINE_LOCATION | ||
) == PackageManager.PERMISSION_GRANTED | ||
) { | ||
return true | ||
} else { | ||
ActivityCompat.requestPermissions( | ||
activity, | ||
arrayOf(Manifest.permission.ACCESS_FINE_LOCATION), | ||
REQUEST_PERMISSIONS_REQUEST_CODE | ||
) | ||
return false | ||
} | ||
} | ||
|
||
fun isPermissionGranted(code: Int, grantResults: IntArray): Boolean { | ||
var permissionGranted = false; | ||
if (code == REQUEST_PERMISSIONS_REQUEST_CODE) { | ||
when { | ||
grantResults.isEmpty() -> Log.i("Location", "User interaction was cancelled.") | ||
(grantResults[0] == PackageManager.PERMISSION_GRANTED) -> { | ||
permissionGranted = true | ||
Log.i("Location", "Permission Granted.") | ||
} | ||
else -> Log.i("Location", "Permission Denied.") | ||
} | ||
} | ||
return permissionGranted | ||
} | ||
|
||
@SuppressLint("RestrictedApi") | ||
fun createDefaultLocationRequest(): LocationRequest { | ||
val locationRequest = LocationRequest().apply { | ||
interval = 10000 | ||
fastestInterval = 5000 | ||
priority = LocationRequest.PRIORITY_HIGH_ACCURACY | ||
} | ||
return locationRequest | ||
} |
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
22 changes: 22 additions & 0 deletions
22
app/src/main/java/com/archaeologicalfieldwork/views/BasePresenter.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,22 @@ | ||
package com.archaeologicalfieldwork.views | ||
|
||
import android.content.Intent | ||
import com.archaeologicalfieldwork.main.MainApp | ||
|
||
open class BasePresenter(var view: BaseView?) { | ||
|
||
var app: MainApp = view?.application as MainApp | ||
|
||
open fun doActivityResult(requestCode: Int, resultCode: Int, data: Intent) { | ||
} | ||
|
||
open fun doRequestPermissionsResult( | ||
requestCode: Int, | ||
permissions: Array<String>, | ||
grantResults: IntArray | ||
) { } | ||
|
||
open fun onDestroy() { | ||
view = null | ||
} | ||
} |
Oops, something went wrong.