Fix Fragment lifecycle when rotation change, fix crash caused by conflict between input field and androidx.appcompat:1.4.0

This commit is contained in:
amauri 2024-04-17 17:19:20 +02:00
parent cb094228c6
commit f562317749
11 changed files with 104 additions and 134 deletions

195
README.md
View File

@ -1,47 +1,35 @@
# Android SDK Android SDK
===================
## Table of Contents ## Table of Contents
- [Import](#import)
- [Import](#import) - [Installation](#installation)
- [Installation](#installation) - [Project](#project)
- [Project](#project) - [Settings](#settings)
- [Settings](#settings) - [App](#app)
- [App](#app) - [Add fragment](#fragment)
- [Add fragment](#fragment) - [Troubleshooting](#troubleshooting)
- [Troubleshooting](#troubleshooting) - [Authors](#authors)
- [Authors](#authors)
<a name="import"></a> <a name="import"></a>
## Import ## Import
You must use git to download the sdk from [repository](https://github.com/tecnaviapress/newsmemory-android-sdk) You must use git to download the sdk from [repository](https://github.com/tecnaviapress/newsmemory-android-sdk)
1. The repository is private, to clone it you must generate an ssh key, see the [guide](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent) 1. The repository is private, to clone it you must generate an ssh key, see the [guide](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent)
2. Once the key is generate you must send to Tecnavia the public key and wait a confirmation that you are enabled 2. Once the key is generate you must send to Tecnavia the public key and wait a confirmation that you are enabled
3. Inside root folder run the following command, replace TAG with the latest release, see the list on [releases](https://github.com/tecnaviapress/newsmemory-android-sdk/releases) 3. Inside root folder run the following command, replace TAG with the latest release, see the list on [releases](https://github.com/tecnaviapress/newsmemory-android-sdk/releases)
```sh ```sh
git clone --depth 1 --brach TAG git@github.com:tecnaviapress/newsmemory-android-sdk.git git clone --depth 1 --brach TAG git@github.com:tecnaviapress/newsmemory-android-sdk.git
``` ```
4. if you already has the module you could update to another release by the following commands 4. if you already has the module you could update to another release by the following commands
```sh ```sh
cd newsmemory-android-sdk cd newsmemory-android-sdk
git checkout tags/TAG git checkout tags/TAG
``` ```
<a name="installation"></a> <a name="installation"></a>
## Installation ## Installation
<a name="project"></a> <a name="project"></a>
### Project Gradle ### Project Gradle
1. check main gradle repositories and dependencies 1. check main gradle repositories and dependencies
```java ```java
buildscript { buildscript {
repositories { repositories {
@ -58,13 +46,6 @@ buildscript {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0"
} }
//If photodraweeview:1.1.3 for some reason is not available from Maven force this version
configurations.all {
resolutionStrategy {
force "me.relex:photodraweeview:2.1.0"
}
}
} }
allprojects { allprojects {
@ -76,119 +57,117 @@ allprojects {
maven { maven {
url "https://jitpack.io" url "https://jitpack.io"
} }
//If photodraweeview:1.1.3 for some reason is not available from Maven force this version
configurations.all {
resolutionStrategy {
force "me.relex:photodraweeview:2.1.0"
}
}
} }
} }
``` ```
2. if you are using sdk for amazon and it is built for it add the following maven repository 2. if you are using sdk for amazon and it is built for it add the following maven repository
```java ```java
maven { maven {
url "https://s3.amazonaws.com/android-listener/mvn-repo" url "https://s3.amazonaws.com/android-listener/mvn-repo"
} }
``` ```
3. you could customize all dependencies version by updating the following variables, !pay attention, because the sdk may not starts or works properly add these variables to ext object in main gradle file, see below example. 3. you could customize all dependencies version by updating the following variables, !pay attention, because the sdk may not starts or works properly add these variables to ext object in main gradle file, see below example.
| variable | default | Description | | variable | default | Description |
| :--------------------------------------------------------------------------------------------------- | :-----: | :-------------------------------------------------------- | |:---------------------------------- |:-------:|:-------------------------------------------------------------- |
| compileSdk | 33 | | | compileSdk | 33 | |
| targetSdk | 33 | | | targetSdk | 33 | |
| minSdk | 24 | | | minSdk | 24 | |
| frescoVersion | 2.5.0 | used by react native to display some images | | frescoVersion | 2.5.0 | used by react native to display some images |
| soLoaderVersion | 0.10.1 | used to load needed system native libraries | | soLoaderVersion | 0.10.1 | used to load needed system native libraries |
| okHttpVersion | 4.9.2 | | | okHttpVersion | 4.9.2 | |
| glideVersion | 4.12.0 | | | glideVersion | 4.12.0 | |
| kotlinGradleVersion | 1.5.0 | | | kotlinGradleVersion | 1.5.0 | |
| kotlinVersion | 1.4.0 | | | kotlinVersion | 1.4.0 | |
| webkitVersion | 1.4.0 | | | webkitVersion | 1.4.0 | |
| androidxVersion | 1.5.0 | | | androidxVersion | 1.5.0 | |
| androidxWorkRuntimeVersion | 1.5.0 | | | androidxWorkRuntimeVersion | 1.5.0 | |
| androidxAnnotationVersion | 1.4.0 | | | androidxAnnotationVersion | 1.4.0 | |
| androidxViewpager2Version | 1.0.0 | | | androidxViewpager2Version | 1.0.0 | |
| androidxFragmentVersion | 1.4.1 | | | androidxFragmentVersion | 1.4.1 | |
| androidxBrowserVersion | 1.4.0 | | | androidxBrowserVersion | 1.4.0 | |
| androidxTransitionVersion | 1.1.0 | | | androidxTransitionVersion | 1.1.0 | |
| androidxCoordinatorlayoutVersion | 1.1.0 | | | androidxCoordinatorlayoutVersion | 1.1.0 | |
| androidxSwiperefreshlayoutVersion | 1.0.0 | | | androidxSwiperefreshlayoutVersion | 1.0.0 | |
| androidxAppcompatVersion | 1.0.2 | | | androidxAppcompatVersion | 1.0.2 | |
| androidxLegacySupportVersion | 1.0.0 | | | androidxLegacySupportVersion | 1.0.0 | |
| playServiceiidVersion | 17.0.0 | | | playServiceiidVersion | 17.0.0 | |
| playServiceBaseVersion | 18.0.1 | | | playServiceBaseVersion | 18.0.1 | |
| **The following variables are used if you include on of the optional library listed in description** | | **The following variables are used if you include on of the optional library listed in description** |
| playServiceAnalyticsVersion | 18.0.1 | react-native-google-analytics-bridge | | playServiceAnalyticsVersion | 18.0.1 | react-native-google-analytics-bridge |
| playServiceAdsVersion | 20.6.0 | react-native-prebid, react-native-dfp, react-native-admob | | playServiceAdsVersion | 20.6.0 | react-native-prebid, react-native-dfp, react-native-admob |
| playServiceMapsVersion | 17.0.0 | react-native-maps | | playServiceMapsVersion | 17.0.0 | react-native-maps |
| playBillingVersion | 5.0.0 | react-native-iap for google | | playBillingVersion | 5.0.0 | react-native-iap for google |
| amazonSdkVersion | 3.0.3 | react-native-iap for amazon | | amazonSdkVersion | 3.0.3 | react-native-iap for amazon |
```java ```java
ext { ext {
compileSdk 34 compileSdk = 34
androidxVersion "1.4.0" androidxVersion = "1.4.0"
... ...
} }
``` ```
<a name="settings"></a> <a name="settings"></a>
### Settings Gradle
### Settings Gradle
```java ```java
include ':newsmemory-android-sdk' include ':newsmemory-android-sdk'
``` ```
<a name="app"></a> <a name="app"></a>
### App Gradle ### App Gradle
add the following lines if missing add the following lines if missing
```java
```java
plugin: "com.android.application" plugin: "com.android.application"
apply plugin: "com.google.gms.google-services" apply plugin: "com.google.gms.google-services"
//add crashlytics only if the aar file is included //add crashlytics only if the aar file is included
apply plugin: 'com.google.firebase.crashlytics' apply plugin: 'com.google.firebase.crashlytics'
android{ android{
... ...
defaultConfig { defaultConfig {
... ...
//This line is required by react-native-iap, not included by default //This line is required by react-native-iap, not included by default
missingDimensionStrategy "store", "play" missingDimensionStrategy "store", "play"
} }
... ...
packagingOptions { packagingOptions {
pickFirst "lib/x86/libc++_shared.so" pickFirst "lib/x86/libc++_shared.so"
pickFirst "lib/x86_64/libc++_shared.so" pickFirst "lib/x86_64/libc++_shared.so"
pickFirst "lib/arm64-v8a/libc++_shared.so" pickFirst "lib/arm64-v8a/libc++_shared.so"
pickFirst "lib/armeabi-v7a/libc++_shared.so" pickFirst "lib/armeabi-v7a/libc++_shared.so"
} }
} }
dependencies{ dependencies{
implementation project(":newsmemory-android-sdk") implementation project(":newsmemory-android-sdk")
... ...
} }
``` ```
<a name="fragment"></a> <a name="fragment"></a>
## Add fragment to activity ## Add fragment to activity
```java ```java
public class YourActivity extends AppCompatActivity { public class YourActivity extends AppCompatActivity {
private TaFragment taFragment;
... ...
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
TaFragment fragment = new TaFragment() if(taFragment == null) {
taFragment = new TaFragment()
.setDelegate(new TaFragmentDelegate() { .setDelegate(new TaFragmentDelegate() {
@Override @Override
public void recreate() { public void recreate() {
@ -217,7 +196,7 @@ public class YourActivity extends AppCompatActivity {
//TODO implement it and return true if you consume the event //TODO implement it and return true if you consume the event
return false; return false;
} }
@Override @Override
public boolean handleTokenExpired(){ public boolean handleTokenExpired(){
//TODO implement it and return true if you consume the event //TODO implement it and return true if you consume the event
@ -225,10 +204,13 @@ public class YourActivity extends AppCompatActivity {
} }
}) })
.setBuildProps(getBuildProps()); .setBuildProps(getBuildProps());
} else {
taFragment = (TaFragment) getSupportFragmentManager().findFragmentByTag("TA_FRAGMENT");
}
getSupportFragmentManager() getSupportFragmentManager()
.beginTransaction() .beginTransaction()
.add(R.id.rnFragment, fragment) .replace(R.id.rnFragment, taFragment, "TA_FRAGMENT")
.commit(); .commit();
} }
@ -238,7 +220,7 @@ public class YourActivity extends AppCompatActivity {
bundle.putString(TaConstants.TA_MACHINE, "replace_with_server"); bundle.putString(TaConstants.TA_MACHINE, "replace_with_server");
bundle.putString(TaConstants.TA_LOCALE, "en"); bundle.putString(TaConstants.TA_LOCALE, "en");
bundle.putString(TaConstants.TA_TOKEN, "replace with a valid token"); bundle.putString(TaConstants.TA_TOKEN, "replace with a valid token");
//the value inside R.string will be available after first build //the value inside R.string will be avilable after first build
bundle.putString(TaConstants.TA_APP_VERSION_NAME, getString(com.tecnavia.sdk.R.string.APP_VERSION_NAME)); bundle.putString(TaConstants.TA_APP_VERSION_NAME, getString(com.tecnavia.sdk.R.string.APP_VERSION_NAME));
bundle.putString(TaConstants.TA_APP_VERSION_CODE, getString(com.tecnavia.sdk.R.string.APP_VERSION_CODE)); bundle.putString(TaConstants.TA_APP_VERSION_CODE, getString(com.tecnavia.sdk.R.string.APP_VERSION_CODE));
bundle.putString(TaConstants.TA_ANDROID_APP_ID,getString(com.tecnavia.sdk.R.string.ANDROID_APP_ID)); bundle.putString(TaConstants.TA_ANDROID_APP_ID,getString(com.tecnavia.sdk.R.string.ANDROID_APP_ID));
@ -252,13 +234,11 @@ public class YourActivity extends AppCompatActivity {
``` ```
the following constant is required by SDK to be authorized the following constant is required by SDK to be authorized
```java ```java
bundle.putString(TaConstants.TA_API_KEY, ""); bundle.putString(TaConstants.TA_API_KEY, "");
``` ```
the following constants are required by SDK otherwise there will be some inconsistencies and bugs the following constants are required by SDK otherwise there will be some inconsinstecies and bugs
```java ```java
bundle.putString(TaConstants.TA_APP_VERSION_NAME, getString(com.tecnavia.sdk.R.string.APP_VERSION_NAME)); bundle.putString(TaConstants.TA_APP_VERSION_NAME, getString(com.tecnavia.sdk.R.string.APP_VERSION_NAME));
bundle.putString(TaConstants.TA_APP_VERSION_CODE, getString(com.tecnavia.sdk.R.string.APP_VERSION_CODE)); bundle.putString(TaConstants.TA_APP_VERSION_CODE, getString(com.tecnavia.sdk.R.string.APP_VERSION_CODE));
@ -267,12 +247,11 @@ the following constants are required by SDK otherwise there will be some inconsi
bundle.putBoolean(TaConstants.TA_IS_ADDON, true); bundle.putBoolean(TaConstants.TA_IS_ADDON, true);
``` ```
1. The activity that load TaFragment must implement the following interface _DefaultHardwareBackBtnHandler_ 1. The activity that load TaFragment must implement the following interface *DefaultHardwareBackBtnHandler*
```java ```java
public class YourActivity extends AppCompatActivity implements DefaultHardwareBackBtnHandler { public class YourActivity extends AppCompatActivity implements DefaultHardwareBackBtnHandler {
... ...
@Override @Override
public void invokeDefaultOnBackPressed() { public void invokeDefaultOnBackPressed() {
//TODO handle finish //TODO handle finish
@ -280,13 +259,12 @@ public class YourActivity extends AppCompatActivity implements DefaultHardwareBa
} }
``` ```
2. you could extends activity class with TaActivity that already has an implementation of _DefaultHardwareBackBtnHandler_ but also add some other methods to force locale. 2. you could extends activity class with TaActivity that already has an implementation of *DefaultHardwareBackBtnHandler* but also add some other methods to force locale.
```java ```java
public class YourActivity extends TaActivity { public class YourActivity extends TaActivity {
... ...
} }
``` ```
## Troubleshooting Guide ## Troubleshooting Guide
@ -328,6 +306,5 @@ protected void onCreate(Bundle savedInstanceState) {
For more information, refer to this [GitHub issue comment](https://github.com/software-mansion/react-native-screens/issues/17#issuecomment-424704067). For more information, refer to this [GitHub issue comment](https://github.com/software-mansion/react-native-screens/issues/17#issuecomment-424704067).
## Authors ## Authors
Nicolò Aquilini, iOS Software developer, Tecnavia Nicolò Aquilini, iOS Software developer, Tecnavia
Andrea Mauri, Android Software developer, Tecnavia Andrea Mauri, Android Software developer, Tecnavia

View File

@ -55,7 +55,7 @@ publishing {
tareactnativeasyncstorageasyncstorage(MavenPublication) { tareactnativeasyncstorageasyncstorage(MavenPublication) {
groupId 'tecnavia' groupId 'tecnavia'
artifactId 'react-native-async-storage_async-storage' artifactId 'react-native-async-storage_async-storage'
version '1.17.9' version '1.23.1'
artifact("$libsDirName/react-native-async-storage_async-storage-release.aar") artifact("$libsDirName/react-native-async-storage_async-storage-release.aar")
} }
@ -164,20 +164,6 @@ publishing {
artifact("$libsDirName/react-native-html-to-pdf-release.aar") artifact("$libsDirName/react-native-html-to-pdf-release.aar")
} }
tareactnativeiapplay(MavenPublication) {
groupId 'tecnavia'
artifactId 'react-native-iap-play'
version '12.4.0'
artifact("$libsDirName/react-native-iap-play-release.aar")
}
tareactnativeiapamazon(MavenPublication) {
groupId 'tecnavia'
artifactId 'react-native-iap-amazon'
version '12.4.0'
artifact("$libsDirName/react-native-iap-amazon-release.aar")
}
tareactnativeidletimer(MavenPublication) { tareactnativeidletimer(MavenPublication) {
groupId 'tecnavia' groupId 'tecnavia'
artifactId 'react-native-idle-timer' artifactId 'react-native-idle-timer'
@ -335,7 +321,7 @@ publishing {
tatecnaviareactnativebridge(MavenPublication) { tatecnaviareactnativebridge(MavenPublication) {
groupId 'tecnavia' groupId 'tecnavia'
artifactId 'tecnavia_react-native-bridge' artifactId 'tecnavia_react-native-bridge'
version '1.2.15' version '1.2.20'
artifact("$libsDirName/tecnavia_react-native-bridge-release.aar") artifact("$libsDirName/tecnavia_react-native-bridge-release.aar")
} }
@ -388,6 +374,13 @@ publishing {
artifact("$libsDirName/tecnavia_react-native-web-analytics-release.aar") artifact("$libsDirName/tecnavia_react-native-web-analytics-release.aar")
} }
tatecnaviareactnativeworkaround(MavenPublication) {
groupId 'tecnavia'
artifactId 'tecnavia_react-native-workaround'
version '0.0.2'
artifact("$libsDirName/tecnavia_react-native-workaround-release.aar")
}
tatecnaviareactnativeziparchive(MavenPublication) { tatecnaviareactnativeziparchive(MavenPublication) {
groupId 'tecnavia' groupId 'tecnavia'
artifactId 'tecnavia_react-native-zip-archive' artifactId 'tecnavia_react-native-zip-archive'
@ -500,7 +493,7 @@ def amazonSdkVersion = safeExtGet("amazonSdkVersion", "3.0.3")
dependencies { dependencies {
implementation "tecnavia:react-native-android-open-settings:1.3.0" implementation "tecnavia:react-native-android-open-settings:1.3.0"
implementation "tecnavia:react-native-app-settings:2.0.1" implementation "tecnavia:react-native-app-settings:2.0.1"
implementation "tecnavia:react-native-async-storage_async-storage:1.17.9" implementation "tecnavia:react-native-async-storage_async-storage:1.23.1"
implementation "tecnavia:react-native-color-matrix-image-filters:5.2.10" implementation "tecnavia:react-native-color-matrix-image-filters:5.2.10"
implementation "tecnavia:react-native-community_art:1.2.0" implementation "tecnavia:react-native-community_art:1.2.0"
implementation "tecnavia:react-native-community_datetimepicker:6.7.5" implementation "tecnavia:react-native-community_datetimepicker:6.7.5"
@ -516,8 +509,6 @@ dependencies {
implementation "tecnavia:react-native-fs:2.20.0" implementation "tecnavia:react-native-fs:2.20.0"
implementation "tecnavia:react-native-gesture-handler:1.10.3" implementation "tecnavia:react-native-gesture-handler:1.10.3"
implementation "tecnavia:react-native-html-to-pdf:0.12.0" implementation "tecnavia:react-native-html-to-pdf:0.12.0"
playImplementation "tecnavia:react-native-iap-play:12.4.0"
amazonImplementation "tecnavia:react-native-iap-amazon:12.4.0"
implementation "tecnavia:react-native-idle-timer:2.1.6" implementation "tecnavia:react-native-idle-timer:2.1.6"
implementation "tecnavia:react-native-image-marker:0.9.2" implementation "tecnavia:react-native-image-marker:0.9.2"
implementation "tecnavia:react-native-linear-gradient:2.8.3" implementation "tecnavia:react-native-linear-gradient:2.8.3"
@ -540,7 +531,7 @@ dependencies {
implementation "tecnavia:react-native-volume-control:1.0.1" implementation "tecnavia:react-native-volume-control:1.0.1"
implementation "tecnavia:react-native-webview:11.17.2" implementation "tecnavia:react-native-webview:11.17.2"
implementation "tecnavia:rn-fetch-blob:0.11.2" implementation "tecnavia:rn-fetch-blob:0.11.2"
api "tecnavia:tecnavia_react-native-bridge:1.2.15" api "tecnavia:tecnavia_react-native-bridge:1.2.20"
implementation "tecnavia:tecnavia_react-native-default-preference:1.5.0" implementation "tecnavia:tecnavia_react-native-default-preference:1.5.0"
implementation "tecnavia:tecnavia_react-native-dfp:1.5.0" implementation "tecnavia:tecnavia_react-native-dfp:1.5.0"
implementation "tecnavia:tecnavia_react-native-geolocation:3.0.1" implementation "tecnavia:tecnavia_react-native-geolocation:3.0.1"
@ -548,6 +539,7 @@ dependencies {
implementation "tecnavia:tecnavia_react-native-pdf:5.1.6" implementation "tecnavia:tecnavia_react-native-pdf:5.1.6"
implementation "tecnavia:tecnavia_react-native-print:0.6.1" implementation "tecnavia:tecnavia_react-native-print:0.6.1"
implementation "tecnavia:tecnavia_react-native-web-analytics:1.0.0" implementation "tecnavia:tecnavia_react-native-web-analytics:1.0.0"
implementation "tecnavia:tecnavia_react-native-workaround:0.0.2"
implementation "tecnavia:tecnavia_react-native-zip-archive:5.2.0" implementation "tecnavia:tecnavia_react-native-zip-archive:5.2.0"
api "tecnavia:react-native:0.67.5" api "tecnavia:react-native:0.67.5"
implementation "tecnavia:hermes:1.0.0" implementation "tecnavia:hermes:1.0.0"
@ -603,8 +595,8 @@ dependencies {
//used by @firebase/app //used by @firebase/app
implementation "com.android.billingclient:billing-ktx:$playBillingVersion"
implementation "com.amazon.device:amazon-appstore-sdk:$amazonSdkVersion"
//firebase //firebase

View File

@ -1,7 +1,7 @@
android.useAndroidX=true android.useAndroidX=true
APP_NAME=Android SDK APP_NAME=Android SDK
APP_VERSION_NAME=3.12.01 APP_VERSION_NAME=3.12.05
APP_VERSION_CODE=1711618364614 APP_VERSION_CODE=1713363289503
ANDROID_APP_ID=com.tecnaviaapplication ANDROID_APP_ID=com.tecnaviaapplication
IS_ADDON=true IS_ADDON=true

Binary file not shown.

Binary file not shown.

View File

@ -58,4 +58,5 @@ com.wenkesj.voice.VoicePackage
com.reactnativecommunity.webview.RNCWebViewPackage com.reactnativecommunity.webview.RNCWebViewPackage
com.RNFetchBlob.RNFetchBlobPackage com.RNFetchBlob.RNFetchBlobPackage
com.blueconic.reactnative.BlueConicClientPackage com.blueconic.reactnative.BlueConicClientPackage
com.tecnavia.chartbeat.ChartBeatPackage com.tecnavia.chartbeat.ChartBeatPackage
com.tecnavia.workaround.WorkaroundPackage