View ContextExt.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
package com.shreyaspatil.callbackflownetwork | |
import android.content.Context | |
import android.net.ConnectivityManager | |
import android.net.Network | |
import android.net.NetworkCapabilities | |
import android.net.NetworkRequest | |
import kotlinx.coroutines.ExperimentalCoroutinesApi | |
import kotlinx.coroutines.channels.awaitClose | |
import kotlinx.coroutines.flow.MutableStateFlow |
View ContextExt.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
package com.shreyaspatil.callbackflownetwork | |
import android.content.Context | |
import android.net.ConnectivityManager | |
import android.net.Network | |
import android.net.NetworkCapabilities | |
import android.net.NetworkRequest | |
import kotlinx.coroutines.ExperimentalCoroutinesApi | |
import kotlinx.coroutines.channels.awaitClose | |
import kotlinx.coroutines.flow.MutableStateFlow |
View CellInfoExtractor.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
fun getCellInfo(info: CellInfoGsm): CellInfo { | |
val cellInfo = CellInfo() | |
cellInfo.radio = RadioType.GSM | |
info.cellIdentity.let { | |
val (mcc, mnc) = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { | |
Pair(it.mccString?.toInt() ?: 0, it.mncString?.toInt() ?: 0) | |
} else { | |
Pair(it.mcc, it.mnc) | |
} |
View CellInfoExtractor.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
fun getCurrentCellInfo(context: Context): List<CellInfo> { | |
val telephonyManager = context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager | |
val allCellInfo = telephonyManager.allCellInfo | |
return allCellInfo.mapNotNull { | |
when (it) { | |
is CellInfoGsm -> getCellInfo(it) | |
is CellInfoWcdma -> getCellInfo(it) | |
is CellInfoLte -> getCellInfo(it) | |
else -> null |
View UnwiredLabsService.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
interface UnwiredLabsService { | |
@POST("v2/process.php") | |
suspend fun getLocationByCellInfo(@Body cellInfo: CellInfo): Response<CellLocation> | |
companion object { | |
const val BASE_URL = "https://ap1.unwiredlabs.com/" | |
} | |
} |
View CellLocation.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
data class CellLocation( | |
val status: String, | |
val message: String?, | |
val accuracy: Int? = null, | |
val address: String? = null, | |
@Json(name = "lat") | |
val latitude: Double? = null, | |
@Json(name = "lon") |
View CellInfo.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
data class CellInfo( | |
val token: String = BuildConfig.OPENCELLID_API_KEY, | |
var radio: String? = null, | |
var mcc: Int? = null, | |
var mnc: Int? = null, | |
var cells: List<Cell> = emptyList(), | |
val address: Int = 1 | |
) | |
data class Cell( |
View feedback_list.dart
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
class _FeedbackListPageState extends State<FeedbackListPage> { | |
List<FeedbackForm> feedbackItems = List<FeedbackForm>(); | |
// Method to Submit Feedback and save it in Google Sheets | |
@override | |
void initState() { | |
super.initState(); | |
FormController().getFeedbackList().then((feedbackItems) { |
View form_controller.dart
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
/// Async function which loads feedback from endpoint URL and returns List. | |
Future<List<FeedbackForm>> getFeedbackList() async { | |
return await http.get(URL).then((response) { | |
var jsonFeedback = convert.jsonDecode(response.body) as List; | |
return jsonFeedback.map((json) => FeedbackForm.fromJson(json)).toList(); | |
}); | |
} |
View code.gs
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
function doGet(request){ | |
// Open Google Sheet using ID | |
var sheet = SpreadsheetApp.openById("1OOArrqjOqmD4GiJOWlluZ4woTMH_qaV6RKv4JXnT3Hk"); | |
// Get all values in active sheet | |
var values = sheet.getActiveSheet().getDataRange().getValues(); | |
var data = []; | |
// Iterate values in descending order | |
for (var i = values.length - 1; i >= 0; i--) { |
NewerOlder