Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

WIP: Add ancillary factory fragment #1703

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .build/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kiwicom/react-native-app-hotels",
"version": "0.0.53",
"version": "0.0.54",
"private": false,
"main": "index.js",
"dependencies": {
Expand Down
40 changes: 20 additions & 20 deletions android/playground/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ android {
keyAlias 'my-key-alias'
keyPassword 'kiwireactnative'
}
release {
// Just a fake keystore / fake password
storeFile file("playground-key.keystore")
storePassword 'kiwireactnative'
keyAlias 'my-key-alias'
keyPassword 'kiwireactnative'
}
// release {
// // Just a fake keystore / fake password
// storeFile file("playground-key.keystore")
// storePassword 'kiwireactnative'
// keyAlias 'my-key-alias'
// keyPassword 'kiwireactnative'
// }
}
buildTypes {
debug {
Expand All @@ -56,13 +56,13 @@ android {
signingConfig signingConfigs.stagingRelease
matchingFallbacks = ['release']
}
release {
buildConfigField "String", "CODEPUSH_KEY", "\"${productionCodePushKey}\""
buildConfigField "String", "CODEPUSH_VERSION", "\"${codePushVersion}\""
minifyEnabled false
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
// release {
// buildConfigField "String", "CODEPUSH_KEY", "\"${productionCodePushKey}\""
// buildConfigField "String", "CODEPUSH_VERSION", "\"${codePushVersion}\""
// minifyEnabled false
// signingConfig signingConfigs.release
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// }
}
compileOptions {
sourceCompatibility 1.8
Expand Down Expand Up @@ -108,12 +108,12 @@ dependencies {
exclude group: "com.google.firebase"
}

releaseImplementation("com.trinerdis.skypicker:rnkiwimobile:$rnKiwiMobileVersion-SNAPSHOT") {
exclude group: "com.android.support"
exclude group: "com.google.android.gms"
exclude group: "com.google.firebase"
}
releaseImplementation("com.kiwi.android:hermesvm:$hermesVmVersion-SNAPSHOT")
// releaseImplementation("com.trinerdis.skypicker:rnkiwimobile:$rnKiwiMobileVersion-SNAPSHOT") {
// exclude group: "com.android.support"
// exclude group: "com.google.android.gms"
// exclude group: "com.google.firebase"
// }
// releaseImplementation("com.kiwi.android:hermesvm:$hermesVmVersion-SNAPSHOT")

implementation "com.google.android.gms:play-services-maps:$playServicesMapsVersion"

Expand Down
2 changes: 2 additions & 0 deletions android/playground/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
</activity>
<activity android:name="com.kiwi.mobile.rnandroidplayground.HotelsActivityFragment">
</activity>
<activity android:name="com.kiwi.mobile.rnandroidplayground.AncillaryFactoryAcivity">
</activity>
<activity android:name=".HotelsStay22Activity" />
<activity android:name="com.kiwi.mobile.rnandroidplayground.AccountSettingsActivity" />
<activity android:name="com.kiwi.mobile.rnandroidplayground.AccountPriceAlertsActivity" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.kiwi.mobile.rnandroidplayground

import android.annotation.TargetApi
import android.os.Build
import android.os.Bundle
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler
import com.facebook.react.modules.core.PermissionAwareActivity
import androidx.appcompat.app.AppCompatActivity
import com.facebook.react.modules.core.PermissionListener


class AncillaryFactoryAcivity : AppCompatActivity(), DefaultHardwareBackBtnHandler, PermissionAwareActivity {

private var mPermissionListener: PermissionListener? = null

companion object {
fun getViewModelClass(): Class<AncillaryFactoryAcivity> =
AncillaryFactoryAcivity::class.java
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_fragment)

if (savedInstanceState == null) {
addFragment()
}
}

private fun addFragment() {
val fragmentManager = getSupportFragmentManager()
fragmentManager.beginTransaction().add(R.id.container_main, AncillaryFactoryFragment()).commit()
}

// region BackButton
override fun invokeDefaultOnBackPressed() {
super.onBackPressed()
}

override fun onBackPressed() {
(application as PlaygroundApplication).reactNativeHost.reactInstanceManager.onBackPressed()
}
// endregion

// region PermissionAwareActivity
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
if (mPermissionListener != null && mPermissionListener!!.onRequestPermissionsResult(requestCode, permissions, grantResults)) {
mPermissionListener = null
}
}

@TargetApi(Build.VERSION_CODES.M)
override fun requestPermissions(permissions: Array<String>, requestCode: Int, listener: PermissionListener) {
mPermissionListener = listener
requestPermissions(permissions, requestCode)
}
// endregion
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.kiwi.mobile.rnandroidplayground

import com.facebook.react.ReactNativeHost
import com.kiwi.rnkiwimobile.ancillaries.RNAncillaryFactoryFragment
import com.kiwi.rnkiwimobile.ancillaries.RNAncillaryFactoryInitialProperties


class AncillaryFactoryFragment: RNAncillaryFactoryFragment(
RNAncillaryFactoryInitialProperties(service = "fast_track", bookingId = 123, kwAuthToken = "mock")) {

override fun getReactNativeHost(): ReactNativeHost = (activity?.application as PlaygroundApplication).reactNativeHost
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ class HotelsActivityFragment : Activity(), DefaultHardwareBackBtnHandler, Permis
if (savedInstanceState == null) {
val hotelFragment = HotelsFragment()

fragmentManager
.beginTransaction()
.add(R.id.container_main, hotelFragment)
.commit()
// fragmentManager
// .beginTransaction()
// .add(R.id.container_main, hotelFragment)
// .commit()
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.kiwi.mobile.rnandroidplayground

import com.facebook.react.ReactNativeHost
import com.facebook.react.ReactNativeHost
import com.kiwi.rnkiwimobile.hotels.RNHotelsFragment

class HotelsFragment : RNHotelsFragment(HotelsData.getInitialProperties()) {
override fun getReactNativeHost(): ReactNativeHost = (activity.application as PlaygroundApplication).reactNativeHost
override fun getReactNativeHost(): ReactNativeHost = (activity?.application as PlaygroundApplication).reactNativeHost
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class MainActivity : AppCompatActivity() {
button_account_price_alerts.setOnClickListener {
startActivity(Intent(this, AccountPriceAlertsActivity.getViewModelClass()))
}

button_ancillary_factory.setOnClickListener {
startActivity(Intent(this, AncillaryFactoryAcivity.getViewModelClass()))
}
}

override fun onDestroy() {
Expand Down
6 changes: 6 additions & 0 deletions android/playground/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,10 @@
android:layout_height="wrap_content"
android:text="Account price alerts" />

<Button
android:id="@+id/button_ancillary_factory"
android:layout_width="199dp"
android:layout_height="wrap_content"
android:text="ancillary factory" />

</LinearLayout>
2 changes: 1 addition & 1 deletion android/rnkiwimobile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ dependencies {
def hermesPath = "../../node_modules/hermesvm/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
stagingReleaseImplementation files(hermesPath + "hermes-release.aar")
releaseImplementation "com.kiwi.android:hermesvm:$hermesVmVersion-SNAPSHOT"
// releaseImplementation "com.kiwi.android:hermesvm:$hermesVmVersion-SNAPSHOT"
implementation "com.kiwi.android:android-jsc:$jscVersion-SNAPSHOT"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ package com.kiwi.rnkiwimobile
* Copyright 2017 Agile Sports Technologies, Inc.
*/

import android.app.Fragment
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.facebook.react.ReactNativeHost
import com.facebook.react.ReactRootView
import com.facebook.react.devsupport.DoubleTapReloadRecognizer
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.kiwi.rnkiwimobile.ancillaries

import com.kiwi.rnkiwimobile.RNKiwiFragment;

abstract class RNAncillaryFactoryFragment(
initialProperties: RNAncillaryFactoryInitialProperties) : RNKiwiFragment(
RNAncillaryFactoryModule.getInitialProperties(initialProperties)) {

override fun getModuleName(): String {
return RNAncillaryFactoryModule.moduleName
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.kiwi.rnkiwimobile.ancillaries

data class RNAncillaryFactoryInitialProperties(
val service: String,
val bookingId: Int,
val kwAuthToken: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.kiwi.rnkiwimobile.ancillaries

import android.os.Bundle

object RNAncillaryFactoryModule {
const val jsEntryPoint = "app/native"
const val moduleName = "AncillaryFactory"

fun getInitialProperties(initialProperties: RNAncillaryFactoryInitialProperties): Bundle? {
return Bundle().apply {
putString("service", initialProperties.service)
putInt("bookingId", initialProperties.bookingId)
putString("kwAuthToken", initialProperties.kwAuthToken)
}

}

}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"test-runner": "jest"
},
"rnkiwimobile": {
"code-push-target-binary-version": "16.0.0"
"code-push-target-binary-version": "17.0.0"
},
"resolutions": {
"@adeira/js": "^0.2.0"
Expand Down