-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding fdroid flavor to build without GMS and Firebase (WPB-279…
…9) (#2727) Co-authored-by: Yamil Medina <yamilmedina@users.noreply.github.com> Co-authored-by: Mohamad Jaara <mohamad.jaara@wire.com>
- Loading branch information
1 parent
ff529ed
commit 0e0430d
Showing
24 changed files
with
355 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<!-- | ||
Wire | ||
Copyright (C) 2018 Wire Swiss GmbH | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
--> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
package="com.wire.android" | ||
android:sharedUserId="${sharedUserId}"> | ||
<application> | ||
<provider | ||
android:name="com.google.firebase.provider.FirebaseInitProvider" | ||
tools:node="remove" /> | ||
<meta-data | ||
android:name="com.google.android.gms.version" | ||
tools:node="remove" /> | ||
<service | ||
android:name=".services.WireFirebaseMessagingService" | ||
tools:node="remove" /> | ||
<meta-data | ||
android:name="com.wire.android.initializer.FirebaseInitializer" | ||
tools:node="remove" /> | ||
|
||
</application> | ||
</manifest> |
32 changes: 32 additions & 0 deletions
32
...ss/kotlin/com/wire/android/ui/home/messagecomposer/location/LocationPickerHelperFlavor.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,32 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2024 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.android.ui.home.messagecomposer.location | ||
|
||
import android.content.Context | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class LocationPickerHelperFlavor @Inject constructor(context: Context) : LocationPickerHelper(context) { | ||
suspend fun getLocation(onSuccess: (GeoLocatedAddress) -> Unit, onError: () -> Unit) { | ||
getLocationWithoutGms( | ||
onSuccess = onSuccess, | ||
onError = onError | ||
) | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
app/src/foss/kotlin/com/wire/android/util/extension/GoogleServices.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,30 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2023 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
* | ||
* | ||
*/ | ||
|
||
package com.wire.android.util.extension | ||
|
||
import android.content.Context | ||
|
||
fun Context.isGoogleServicesAvailable(): Boolean { | ||
val returnValue: Boolean = false | ||
return returnValue | ||
} | ||
|
||
fun Context.initGoogleFirebase() { /* Stub for compatibility */ } |
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
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
File renamed without changes.
File renamed without changes.
64 changes: 64 additions & 0 deletions
64
...ee/kotlin/com/wire/android/ui/home/messagecomposer/location/LocationPickerHelperFlavor.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,64 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2024 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.android.ui.home.messagecomposer.location | ||
|
||
import android.annotation.SuppressLint | ||
import android.content.Context | ||
import android.location.Geocoder | ||
import com.google.android.gms.location.LocationServices | ||
import com.google.android.gms.location.Priority | ||
import com.google.android.gms.tasks.CancellationTokenSource | ||
import com.wire.android.util.extension.isGoogleServicesAvailable | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
import kotlinx.coroutines.tasks.await | ||
|
||
@Singleton | ||
class LocationPickerHelperFlavor @Inject constructor(context: Context) : LocationPickerHelper(context) { | ||
|
||
suspend fun getLocation(onSuccess: (GeoLocatedAddress) -> Unit, onError: () -> Unit) { | ||
if (context.isGoogleServicesAvailable()) { | ||
getLocationWithGms( | ||
onSuccess = onSuccess, | ||
onError = onError | ||
) | ||
} else { | ||
getLocationWithoutGms( | ||
onSuccess = onSuccess, | ||
onError = onError | ||
) | ||
} | ||
} | ||
|
||
/** | ||
* Choosing the best location estimate by docs. | ||
* https://developer.android.com/develop/sensors-and-location/location/retrieve-current#BestEstimate | ||
*/ | ||
@SuppressLint("MissingPermission") | ||
private suspend fun getLocationWithGms(onSuccess: (GeoLocatedAddress) -> Unit, onError: () -> Unit) { | ||
if (isLocationServicesEnabled()) { | ||
val locationProvider = LocationServices.getFusedLocationProviderClient(context) | ||
val currentLocation = | ||
locationProvider.getCurrentLocation(Priority.PRIORITY_HIGH_ACCURACY, CancellationTokenSource().token).await() | ||
val address = Geocoder(context).getFromLocation(currentLocation.latitude, currentLocation.longitude, 1).orEmpty() | ||
onSuccess(GeoLocatedAddress(address.firstOrNull(), currentLocation)) | ||
} else { | ||
onError() | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
app/src/nonfree/kotlin/com/wire/android/util/extension/GoogleServices.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,31 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2023 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
* | ||
* | ||
*/ | ||
|
||
package com.wire.android.util.extension | ||
|
||
import android.content.Context | ||
|
||
import com.google.android.gms.common.ConnectionResult | ||
import com.google.android.gms.common.GoogleApiAvailability | ||
|
||
fun Context.isGoogleServicesAvailable(): Boolean { | ||
val status = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(this) | ||
return status == ConnectionResult.SUCCESS | ||
} |
Oops, something went wrong.