mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-22 06:01:12 +00:00
Prepare Amzon store release
This commit is contained in:
parent
a103836942
commit
995ae058d1
6 changed files with 876 additions and 2 deletions
|
@ -132,6 +132,7 @@ android {
|
|||
dimension "all"
|
||||
buildConfigField "boolean", "BETA_RELEASE", "true"
|
||||
buildConfigField "boolean", "PLAY_STORE_RELEASE", "false"
|
||||
buildConfigField "boolean", "AMAZON_RELEASE", "false"
|
||||
buildConfigField "String", "PRO_FEATURES_URI", "\"https://email.faircode.eu/donate/\""
|
||||
buildConfigField "String", "CHANGELOG", "\"https://github.com/M66B/FairEmail/releases/\""
|
||||
buildConfigField "String", "GITHUB_LATEST_API", "\"https://api.github.com/repos/M66B/FairEmail/releases/latest\""
|
||||
|
@ -142,6 +143,7 @@ android {
|
|||
dimension "all"
|
||||
buildConfigField "boolean", "BETA_RELEASE", "true"
|
||||
buildConfigField "boolean", "PLAY_STORE_RELEASE", "false"
|
||||
buildConfigField "boolean", "AMAZON_RELEASE", "false"
|
||||
buildConfigField "String", "PRO_FEATURES_URI", "\"https://email.faircode.eu/donate/\""
|
||||
buildConfigField "String", "CHANGELOG", "\"https://github.com/M66B/FairEmail/releases/\""
|
||||
buildConfigField "String", "GITHUB_LATEST_API", "\"https://api.github.com/repos/M66B/FairEmail/releases/latest\""
|
||||
|
@ -153,6 +155,19 @@ android {
|
|||
//minSdkVersion 23
|
||||
buildConfigField "boolean", "BETA_RELEASE", "true"
|
||||
buildConfigField "boolean", "PLAY_STORE_RELEASE", "true"
|
||||
buildConfigField "boolean", "AMAZON_RELEASE", "false"
|
||||
buildConfigField "String", "PRO_FEATURES_URI", "\"https://email.faircode.eu/#pro\""
|
||||
buildConfigField "String", "CHANGELOG", "\"\""
|
||||
buildConfigField "String", "GITHUB_LATEST_API", "\"\""
|
||||
buildConfigField "String", "GITHUB_LATEST_URI", "\"\""
|
||||
buildConfigField "String", "GRAVATAR_URI", "\"\""
|
||||
}
|
||||
amazon {
|
||||
dimension "all"
|
||||
//minSdkVersion 23
|
||||
buildConfigField "boolean", "BETA_RELEASE", "true"
|
||||
buildConfigField "boolean", "PLAY_STORE_RELEASE", "false"
|
||||
buildConfigField "boolean", "AMAZON_RELEASE", "true"
|
||||
buildConfigField "String", "PRO_FEATURES_URI", "\"https://email.faircode.eu/#pro\""
|
||||
buildConfigField "String", "CHANGELOG", "\"\""
|
||||
buildConfigField "String", "GITHUB_LATEST_API", "\"\""
|
||||
|
@ -166,7 +181,7 @@ android {
|
|||
// Builds: release, debug
|
||||
// Flavors: github, fdroid, play
|
||||
if (variant.buildType.name == "debug" &&
|
||||
(flavors.contains("fdroid") || flavors.contains("play"))) {
|
||||
(flavors.contains("fdroid") || flavors.contains("play") || flavors.contains("_amazon"))) {
|
||||
setIgnore(true)
|
||||
}
|
||||
}
|
||||
|
@ -236,7 +251,7 @@ configurations.all {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
//implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
||||
def startup_version = "1.1.0-beta01"
|
||||
def annotation_version = "1.1.0"
|
||||
|
@ -380,6 +395,9 @@ dependencies {
|
|||
githubImplementation "com.android.billingclient:billing:$billingclient_version"
|
||||
playImplementation "com.android.billingclient:billing:$billingclient_version"
|
||||
|
||||
// https://developer.amazon.com/docs/in-app-purchasing/iap-get-started.html
|
||||
amazonImplementation files('lib/in-app-purchasing-2.0.76.jar')
|
||||
|
||||
// https://javaee.github.io/javamail/
|
||||
// https://projects.eclipse.org/projects/ee4j.javamail
|
||||
// https://mvnrepository.com/artifact/com.sun.mail
|
||||
|
|
BIN
app/lib/in-app-purchasing-2.0.76.jar
Normal file
BIN
app/lib/in-app-purchasing-2.0.76.jar
Normal file
Binary file not shown.
5
app/proguard-rules.pro
vendored
5
app/proguard-rules.pro
vendored
|
@ -132,3 +132,8 @@
|
|||
-keep class org.commonmark.** {*;}
|
||||
-keepnames class io.noties.markwon.** {*;}
|
||||
-keepnames class org.commonmark.** {*;}
|
||||
|
||||
#Amazon IAP
|
||||
-dontwarn com.amazon.**
|
||||
-keep class com.amazon.** {*;}
|
||||
-keepattributes *Annotation*
|
||||
|
|
479
app/src/amazon/AndroidManifest.xml
Normal file
479
app/src/amazon/AndroidManifest.xml
Normal file
|
@ -0,0 +1,479 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="eu.faircode.email"
|
||||
android:installLocation="internalOnly">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
|
||||
|
||||
<uses-permission android:name="com.android.vending.BILLING" />
|
||||
|
||||
<!-- OAuth -->
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||
<uses-permission
|
||||
android:name="android.permission.USE_CREDENTIALS"
|
||||
android:maxSdkVersion="22" />
|
||||
<uses-permission
|
||||
android:name="android.permission.READ_PROFILE"
|
||||
android:maxSdkVersion="22" />
|
||||
|
||||
<!-- https://developer.android.com/guide/topics/manifest/uses-feature-element#features-reference -->
|
||||
<uses-feature
|
||||
android:name="android.software.app_widgets"
|
||||
android:required="false" />
|
||||
<!--uses-feature
|
||||
android:name="android.software.webview"
|
||||
android:required="false" /-->
|
||||
<uses-feature
|
||||
android:name="android.hardware.camera"
|
||||
android:required="false" />
|
||||
<uses-feature
|
||||
android:name="android.hardware.fingerprint"
|
||||
android:required="false" />
|
||||
|
||||
<!-- Android 11: https://developer.android.com/preview/privacy/package-visibility -->
|
||||
<queries>
|
||||
<!-- Customtabs -->
|
||||
<!-- https://developers.google.com/web/updates/2020/07/custom-tabs-android-11#detecting_browsers_that_support_custom_tabs -->
|
||||
<intent>
|
||||
<action android:name="android.support.customtabs.action.CustomTabsService" />
|
||||
</intent>
|
||||
|
||||
<intent>
|
||||
<action android:name="android.intent.action.INSERT" />
|
||||
</intent>
|
||||
|
||||
<intent>
|
||||
<action android:name="android.intent.action.GET_CONTENT" />
|
||||
<category android:name="android.intent.category.OPENABLE" />
|
||||
<data android:mimeType="*/*" />
|
||||
</intent>
|
||||
|
||||
<intent>
|
||||
<action android:name="android.media.action.IMAGE_CAPTURE" />
|
||||
</intent>
|
||||
|
||||
<intent>
|
||||
<action android:name="android.provider.MediaStore.RECORD_SOUND" />
|
||||
</intent>
|
||||
|
||||
<package android:name="com.android.vending" />
|
||||
|
||||
<package android:name="org.sufficientlysecure.keychain" />
|
||||
<package android:name="org.sufficientlysecure.keychain.debug" />
|
||||
|
||||
<intent>
|
||||
<action android:name="org.openintents.openpgp.IOpenPgpService2" />
|
||||
</intent>
|
||||
|
||||
<!-- https://android-developers.googleblog.com/2015/10/in-app-translations-in-android.html -->
|
||||
<intent>
|
||||
<action android:name="android.intent.action.PROCESS_TEXT" />
|
||||
<data android:mimeType="text/plain" />
|
||||
</intent>
|
||||
|
||||
<package android:name="com.google.android.tts" />
|
||||
|
||||
<package android:name="com.amazon.sdktestclient" />
|
||||
</queries>
|
||||
|
||||
<application
|
||||
android:name=".ApplicationEx"
|
||||
android:allowBackup="false"
|
||||
android:appCategory="productivity"
|
||||
android:forceDarkAllowed="false"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:resizeableActivity="true"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppThemeBlueOrangeLight">
|
||||
<!-- https://developer.samsung.com/samsung-dex/modify-optimizing.html -->
|
||||
|
||||
<!-- https://developer.android.com/guide/webapps/managing-webview#metrics -->
|
||||
<meta-data
|
||||
android:name="android.webkit.WebView.MetricsOptOut"
|
||||
android:value="true" />
|
||||
<meta-data
|
||||
android:name="android.webkit.WebView.EnableSafeBrowsing"
|
||||
android:value="false" />
|
||||
<meta-data
|
||||
android:name="android.allow_multiple_resumed_activities"
|
||||
android:value="true" />
|
||||
<meta-data
|
||||
android:name="com.google.android.gms.car.application"
|
||||
android:resource="@xml/car"
|
||||
tools:node="remove" />
|
||||
<!-- https://play.google.com/about/auto/developer-distribution-agreement-addendum/ -->
|
||||
<meta-data
|
||||
android:name="com.bugsnag.android.API_KEY"
|
||||
android:value="9d2d57476a0614974449a3ec33f2604a" />
|
||||
|
||||
<activity
|
||||
android:name=".ActivityMain"
|
||||
android:excludeFromRecents="true"
|
||||
android:exported="true"
|
||||
android:launchMode="singleInstance"
|
||||
android:theme="@style/Theme.AppCompat.Translucent">
|
||||
|
||||
<meta-data
|
||||
android:name="android.app.shortcuts"
|
||||
android:resource="@xml/shortcuts" />
|
||||
<meta-data
|
||||
android:name="android.service.chooser.chooser_target_service"
|
||||
android:value="androidx.sharetarget.ChooserTargetServiceCompat" />
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="${applicationId}.REFRESH" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data android:scheme="message" />
|
||||
<data android:host="${applicationId}" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".ActivitySetup"
|
||||
android:exported="false"
|
||||
android:launchMode="singleTask"
|
||||
android:parentActivityName=".ActivityMain" />
|
||||
|
||||
<activity
|
||||
android:name=".ActivitySignature"
|
||||
android:exported="false"
|
||||
android:launchMode="singleTask"
|
||||
android:parentActivityName=".ActivitySetup" />
|
||||
|
||||
<activity
|
||||
android:name=".ActivityWidget"
|
||||
android:exported="true">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".ActivityWidgetSync"
|
||||
android:exported="true">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".ActivityWidgetUnified"
|
||||
android:exported="true">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".ActivityView"
|
||||
android:exported="false"
|
||||
android:launchMode="singleTask"
|
||||
android:parentActivityName=".ActivityMain" />
|
||||
|
||||
<activity
|
||||
android:name=".ActivitySearch"
|
||||
android:enabled="false"
|
||||
android:excludeFromRecents="true"
|
||||
android:exported="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_search"
|
||||
android:launchMode="singleTask"
|
||||
android:theme="@style/Theme.AppCompat.Translucent">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.PROCESS_TEXT" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:mimeType="text/plain" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".ActivityCompose"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTask"
|
||||
android:parentActivityName=".ActivityView">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data android:scheme="mailto" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SENDTO" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:scheme="mailto" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEND" />
|
||||
<action android:name="android.intent.action.SEND_MULTIPLE" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:mimeType="*/*" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".ActivityEML"
|
||||
android:exported="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:launchMode="singleTask">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
<data android:scheme="content" />
|
||||
<data android:mimeType="message/rfc822" />
|
||||
<data android:host="*" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
<data android:scheme="content" />
|
||||
<data android:mimeType="*/*" />
|
||||
<data android:host="*" />
|
||||
<data android:pathPattern=".*\\.eml" />
|
||||
<data android:pathPattern=".*\\..*\\.eml" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\.eml" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\..*\\.eml" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.eml" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".ActivityDSN"
|
||||
android:exported="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:launchMode="singleTask">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
<data android:scheme="content" />
|
||||
<data android:mimeType="message/delivery-status" />
|
||||
<data android:mimeType="message/disposition-notification" />
|
||||
<data android:mimeType="text/rfc822-headers" />
|
||||
<data android:host="*" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".ActivityBilling"
|
||||
android:exported="false"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:launchMode="singleTask" />
|
||||
|
||||
<activity
|
||||
android:name="net.openid.appauth.RedirectUriReceiverActivity"
|
||||
android:exported="true"
|
||||
tools:node="replace">
|
||||
<intent-filter android:autoVerify="true">
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data
|
||||
android:host="oauth.faircode.eu"
|
||||
android:scheme="https" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data android:scheme="eu.faircode.email" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<service
|
||||
android:name=".ServiceSynchronize"
|
||||
android:exported="false"
|
||||
android:foregroundServiceType="dataSync" />
|
||||
|
||||
<service
|
||||
android:name=".ServiceSend"
|
||||
android:exported="false"
|
||||
android:foregroundServiceType="dataSync" />
|
||||
|
||||
<service
|
||||
android:name=".ServiceUI"
|
||||
android:exported="false" />
|
||||
|
||||
<service
|
||||
android:name=".ServiceExternal"
|
||||
android:exported="true"
|
||||
android:foregroundServiceType="dataSync">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="${applicationId}.POLL" />
|
||||
<action android:name="${applicationId}.ENABLE" />
|
||||
<action android:name="${applicationId}.DISABLE" />
|
||||
<action android:name="${applicationId}.INTERVAL" />
|
||||
<action android:name="${applicationId}.DISCONNECT.ME" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<service
|
||||
android:name=".ServiceTileSynchronize"
|
||||
android:exported="true"
|
||||
android:icon="@drawable/twotone_sync_disabled_24"
|
||||
android:label="@string/app_name"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<service
|
||||
android:name=".ServiceTileUnseen"
|
||||
android:exported="true"
|
||||
android:icon="@drawable/twotone_mail_outline_24"
|
||||
android:label="@string/tile_unseen"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<service
|
||||
android:name=".ServicePowerControl"
|
||||
android:enabled="false"
|
||||
android:exported="true"
|
||||
android:label="@string/app_name"
|
||||
android:permission="android.permission.BIND_CONTROLS">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.controls.ControlsProviderService" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/fileprovider_paths" />
|
||||
</provider>
|
||||
|
||||
<receiver
|
||||
android:name=".Widget"
|
||||
android:exported="true"
|
||||
android:label="@string/title_widget_title_count">
|
||||
|
||||
<meta-data
|
||||
android:name="android.appwidget.provider"
|
||||
android:resource="@xml/widget" />
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver
|
||||
android:name=".WidgetUnified"
|
||||
android:exported="true"
|
||||
android:label="@string/title_widget_title_list">
|
||||
|
||||
<meta-data
|
||||
android:name="android.appwidget.provider"
|
||||
android:resource="@xml/widget_unified" />
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver
|
||||
android:name=".WidgetSync"
|
||||
android:exported="true"
|
||||
android:label="@string/title_widget_title_sync">
|
||||
|
||||
<meta-data
|
||||
android:name="android.appwidget.provider"
|
||||
android:resource="@xml/widget_sync" />
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<service
|
||||
android:name="WidgetUnifiedService"
|
||||
android:exported="true"
|
||||
android:permission="android.permission.BIND_REMOTEVIEWS" />
|
||||
|
||||
<receiver
|
||||
android:name=".ReceiverAutoStart"
|
||||
android:exported="true">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.app.action.SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver
|
||||
android:name="com.amazon.device.iap.ResponseReceiver"
|
||||
android:permission="com.amazon.inapp.purchasing.Permission.NOTIFY">
|
||||
<intent-filter>
|
||||
<action android:name="com.amazon.inapp.purchasing.NOTIFY" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
</application>
|
||||
</manifest>
|
368
app/src/amazon/java/eu/faircode/email/ActivityBilling.java
Normal file
368
app/src/amazon/java/eu/faircode/email/ActivityBilling.java
Normal file
|
@ -0,0 +1,368 @@
|
|||
package eu.faircode.email;
|
||||
|
||||
/*
|
||||
This file is part of FairEmail.
|
||||
|
||||
FairEmail 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.
|
||||
|
||||
FairEmail 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 FairEmail. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2018-2021 by Marcel Bokhorst (M66B)
|
||||
*/
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.lifecycle.LifecycleObserver;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.lifecycle.OnLifecycleEvent;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.amazon.device.iap.PurchasingListener;
|
||||
import com.amazon.device.iap.PurchasingService;
|
||||
import com.amazon.device.iap.model.FulfillmentResult;
|
||||
import com.amazon.device.iap.model.Product;
|
||||
import com.amazon.device.iap.model.ProductDataResponse;
|
||||
import com.amazon.device.iap.model.PurchaseResponse;
|
||||
import com.amazon.device.iap.model.PurchaseUpdatesResponse;
|
||||
import com.amazon.device.iap.model.Receipt;
|
||||
import com.amazon.device.iap.model.RequestId;
|
||||
import com.amazon.device.iap.model.UserDataResponse;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class ActivityBilling extends ActivityBase implements PurchasingListener, FragmentManager.OnBackStackChangedListener {
|
||||
private boolean standalone = false;
|
||||
private String currentUserId;
|
||||
private String currentMarketplace;
|
||||
private List<IBillingListener> listeners = new ArrayList<>();
|
||||
|
||||
static final String ACTION_PURCHASE = BuildConfig.APPLICATION_ID + ".ACTION_PURCHASE";
|
||||
static final String ACTION_PURCHASE_CONSUME = BuildConfig.APPLICATION_ID + ".ACTION_PURCHASE_CONSUME";
|
||||
static final String ACTION_PURCHASE_ERROR = BuildConfig.APPLICATION_ID + ".ACTION_PURCHASE_ERROR";
|
||||
|
||||
@Override
|
||||
@SuppressLint("MissingSuperCall")
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
onCreate(savedInstanceState, true);
|
||||
}
|
||||
|
||||
protected void onCreate(Bundle savedInstanceState, boolean standalone) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
this.standalone = standalone;
|
||||
|
||||
if (standalone) {
|
||||
setContentView(R.layout.activity_billing);
|
||||
|
||||
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
|
||||
fragmentTransaction.replace(R.id.content_frame, new FragmentPro()).addToBackStack("pro");
|
||||
fragmentTransaction.commit();
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
getSupportFragmentManager().addOnBackStackChangedListener(this);
|
||||
}
|
||||
|
||||
if (Helper.isAmazonInstall() || isTesting(this)) {
|
||||
Log.i("IAB start sandbox=" + PurchasingService.IS_SANDBOX_MODE);
|
||||
PurchasingService.registerListener(this.getApplicationContext(), this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackStackChanged() {
|
||||
if (getSupportFragmentManager().getBackStackEntryCount() == 0)
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
if (standalone) {
|
||||
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this);
|
||||
IntentFilter iff = new IntentFilter();
|
||||
iff.addAction(ACTION_PURCHASE);
|
||||
iff.addAction(ACTION_PURCHASE_CONSUME);
|
||||
iff.addAction(ACTION_PURCHASE_ERROR);
|
||||
lbm.registerReceiver(receiver, iff);
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
|
||||
if (standalone) {
|
||||
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this);
|
||||
lbm.unregisterReceiver(receiver);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
static String getSkuPro() {
|
||||
return BuildConfig.APPLICATION_ID.replace(".debug", "") + ".pro";
|
||||
}
|
||||
|
||||
static boolean isTesting(Context context) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
return (BuildConfig.DEBUG && prefs.getBoolean("test_iab", false));
|
||||
}
|
||||
|
||||
private static String getChallenge(Context context) throws NoSuchAlgorithmException {
|
||||
String android_id = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
|
||||
return Helper.sha256(android_id);
|
||||
}
|
||||
|
||||
private static String getResponse(Context context) throws NoSuchAlgorithmException {
|
||||
return Helper.sha256(BuildConfig.APPLICATION_ID.replace(".debug", "") + getChallenge(context));
|
||||
}
|
||||
|
||||
static boolean activatePro(Context context, Uri data) throws NoSuchAlgorithmException {
|
||||
String response = data.getQueryParameter("response");
|
||||
return activatePro(context, response);
|
||||
}
|
||||
|
||||
static boolean activatePro(Context context, String response) throws NoSuchAlgorithmException {
|
||||
String challenge = getChallenge(context);
|
||||
Log.i("IAB challenge=" + challenge);
|
||||
Log.i("IAB response=" + response);
|
||||
String expected = getResponse(context);
|
||||
if (expected.equals(response)) {
|
||||
Log.i("IAB response valid");
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
prefs.edit()
|
||||
.putBoolean("pro", true)
|
||||
.putBoolean("play_store", false)
|
||||
.apply();
|
||||
|
||||
WidgetUnified.updateData(context);
|
||||
return true;
|
||||
} else {
|
||||
Log.i("IAB response invalid");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static boolean isPro(Context context) {
|
||||
if (BuildConfig.DEBUG && false)
|
||||
return true;
|
||||
return PreferenceManager.getDefaultSharedPreferences(context)
|
||||
.getBoolean("pro", false);
|
||||
}
|
||||
|
||||
private BroadcastReceiver receiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
|
||||
if (ACTION_PURCHASE.equals(intent.getAction()))
|
||||
onPurchase(intent);
|
||||
else if (ACTION_PURCHASE_CONSUME.equals(intent.getAction()))
|
||||
onPurchaseConsume(intent);
|
||||
else if (ACTION_PURCHASE_ERROR.equals(intent.getAction()))
|
||||
onPurchaseError(intent);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private void onPurchase(Intent intent) {
|
||||
if (Helper.isAmazonInstall() || isTesting(this)) {
|
||||
String skuPro = getSkuPro();
|
||||
Log.i("IAB purchase SKU=" + skuPro);
|
||||
RequestId requestId = PurchasingService.purchase(skuPro);
|
||||
Log.i("IAB request=" + requestId);
|
||||
} else
|
||||
try {
|
||||
Uri uri = Uri.parse(BuildConfig.PRO_FEATURES_URI +
|
||||
"?challenge=" + getChallenge(this) +
|
||||
"&version=" + BuildConfig.VERSION_CODE);
|
||||
Helper.view(this, uri, true);
|
||||
} catch (NoSuchAlgorithmException ex) {
|
||||
Log.unexpectedError(getSupportFragmentManager(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void onPurchaseConsume(Intent intent) {
|
||||
PurchasingService.getPurchaseUpdates(true);
|
||||
}
|
||||
|
||||
private void onPurchaseError(Intent intent) {
|
||||
String message = intent.getStringExtra("message");
|
||||
Uri uri = Uri.parse(Helper.SUPPORT_URI);
|
||||
if (!TextUtils.isEmpty(message))
|
||||
uri = uri.buildUpon().appendQueryParameter("message", "IAB: " + message).build();
|
||||
Helper.view(this, uri, true);
|
||||
}
|
||||
|
||||
private void update() {
|
||||
if (Helper.isAmazonInstall() || isTesting(this)) {
|
||||
Log.i("IAB update");
|
||||
PurchasingService.getUserData();
|
||||
PurchasingService.getPurchaseUpdates(true); // TODO: reset?
|
||||
Set<String> skus = new HashSet<>();
|
||||
skus.add(getSkuPro());
|
||||
PurchasingService.getProductData(skus);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserDataResponse(UserDataResponse response) {
|
||||
Log.i("IAB user data status=" + response.getRequestStatus());
|
||||
|
||||
switch (response.getRequestStatus()) {
|
||||
case SUCCESSFUL:
|
||||
Log.i("IAB user=" + response.getUserData().toString().replace('\n', '|'));
|
||||
currentUserId = response.getUserData().getUserId();
|
||||
currentMarketplace = response.getUserData().getMarketplace();
|
||||
for (IBillingListener listener : listeners)
|
||||
listener.onConnected();
|
||||
break;
|
||||
|
||||
case FAILED:
|
||||
case NOT_SUPPORTED:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPurchaseUpdatesResponse(PurchaseUpdatesResponse response) {
|
||||
Log.i("IAB purchase updates status=" + response.getRequestStatus());
|
||||
|
||||
switch (response.getRequestStatus()) {
|
||||
case SUCCESSFUL:
|
||||
for (Receipt receipt : response.getReceipts())
|
||||
handle(receipt);
|
||||
|
||||
if (response.hasMore())
|
||||
PurchasingService.getPurchaseUpdates(false);
|
||||
break;
|
||||
|
||||
case FAILED:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProductDataResponse(ProductDataResponse response) {
|
||||
Log.i("IAB product data status=" + response.getRequestStatus());
|
||||
|
||||
switch (response.getRequestStatus()) {
|
||||
case SUCCESSFUL:
|
||||
for (final String sku : response.getUnavailableSkus())
|
||||
Log.i("IAB unavailable sku=" + sku);
|
||||
|
||||
Map<String, Product> products = response.getProductData();
|
||||
for (final String key : products.keySet()) {
|
||||
Product product = products.get(key);
|
||||
Log.i("IAB product=" + product.toString().replace('\n', '|'));
|
||||
if (getSkuPro().equals(product.getSku()))
|
||||
for (IBillingListener listener : listeners)
|
||||
listener.onSkuDetails(product.getSku(), product.getPrice());
|
||||
}
|
||||
break;
|
||||
|
||||
case FAILED:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPurchaseResponse(PurchaseResponse response) {
|
||||
Log.i("IAB purchase response status=" + response.getRequestStatus());
|
||||
|
||||
switch (response.getRequestStatus()) {
|
||||
case SUCCESSFUL:
|
||||
handle(response.getReceipt());
|
||||
break;
|
||||
|
||||
case FAILED:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void handle(Receipt receipt) {
|
||||
Log.i("IAB receipt=" + receipt.toString().replace('\n', '|') +
|
||||
" canceled=" + receipt.isCanceled() + "/" + receipt.getCancelDate());
|
||||
|
||||
if (getSkuPro().equals(receipt.getSku())) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
if (receipt.isCanceled()) {
|
||||
prefs.edit().remove("pro").apply();
|
||||
PurchasingService.notifyFulfillment(receipt.getReceiptId(), FulfillmentResult.UNAVAILABLE);
|
||||
} else {
|
||||
prefs.edit().putBoolean("pro", true).apply();
|
||||
PurchasingService.notifyFulfillment(receipt.getReceiptId(), FulfillmentResult.FULFILLED);
|
||||
}
|
||||
|
||||
WidgetUnified.updateData(this);
|
||||
|
||||
for (IBillingListener listener : listeners)
|
||||
listener.onPurchased(receipt.getSku(), !receipt.isCanceled());
|
||||
}
|
||||
}
|
||||
|
||||
interface IBillingListener {
|
||||
void onConnected();
|
||||
|
||||
void onDisconnected();
|
||||
|
||||
void onSkuDetails(String sku, String price);
|
||||
|
||||
void onPurchasePending(String sku);
|
||||
|
||||
void onPurchased(String sku, boolean purchased);
|
||||
|
||||
void onError(String message);
|
||||
}
|
||||
|
||||
void addBillingListener(final IBillingListener listener, LifecycleOwner owner) {
|
||||
Log.i("IAB adding billing listener=" + listener);
|
||||
listeners.add(listener);
|
||||
|
||||
update();
|
||||
|
||||
owner.getLifecycle().addObserver(new LifecycleObserver() {
|
||||
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
|
||||
public void onDestroyed() {
|
||||
Log.i("IAB removing billing listener=" + listener);
|
||||
listeners.remove(listener);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -471,6 +471,10 @@ public class Helper {
|
|||
return BuildConfig.PLAY_STORE_RELEASE;
|
||||
}
|
||||
|
||||
static boolean isAmazonInstall() {
|
||||
return BuildConfig.AMAZON_RELEASE;
|
||||
}
|
||||
|
||||
static boolean hasPlayStore(Context context) {
|
||||
if (hasPlayStore == null)
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue