From 764942c812ef6ddd1736b9cfb1d5706b50fb0773 Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Thu, 19 Sep 2019 15:55:23 -0300 Subject: [PATCH] Try to share credentials by shareUserId --- .gitignore | 1 + android/app/build.gradle | 6 ++++++ android/app/src/main/AndroidManifest.xml | 1 + .../chat/rocket/reactnative/MainApplication.java | 15 +++++++++++++++ android/debug.keystore | Bin 0 -> 2252 bytes app/constants/credentials.js | 2 +- app/sagas/init.js | 2 ++ 7 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 android/debug.keystore diff --git a/.gitignore b/.gitignore index 18b7c27b4..4899cde14 100644 --- a/.gitignore +++ b/.gitignore @@ -48,6 +48,7 @@ coverage/ buck-out/ \.buckd/ *.keystore +!debug.keystore # fastlane # diff --git a/android/app/build.gradle b/android/app/build.gradle index 5086c1de1..94c0e2596 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -151,6 +151,12 @@ android { keyPassword KEY_PASSWORD } } + debug { + storeFile project.rootProject.file('debug.keystore').getCanonicalFile() + storePassword "android" + keyAlias "androiddebugkey" + keyPassword "android" + } } splits { abi { diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index cf2faf448..76c97ae38 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,6 @@ diff --git a/android/app/src/main/java/chat/rocket/reactnative/MainApplication.java b/android/app/src/main/java/chat/rocket/reactnative/MainApplication.java index da2d6a82b..0ec4c2b02 100644 --- a/android/app/src/main/java/chat/rocket/reactnative/MainApplication.java +++ b/android/app/src/main/java/chat/rocket/reactnative/MainApplication.java @@ -4,6 +4,7 @@ import android.app.Application; import android.util.Log; import android.content.Context; import android.os.Bundle; +import android.content.SharedPreferences; import com.facebook.react.PackageList; import com.facebook.hermes.reactexecutor.HermesExecutorFactory; @@ -75,6 +76,20 @@ public class MainApplication extends Application implements ReactApplication, IN public void onCreate() { super.onCreate(); SoLoader.init(this, /* native exopackage */ false); + setupContext(); + } + + private void setupContext() { + try { + Context context = this.createPackageContext("chat.rocket.android", Context.CONTEXT_INCLUDE_CODE); + SharedPreferences pref = context.getSharedPreferences("chat.rocket.android", Context.MODE_PRIVATE); + String event = pref.getString("ACCOUNTS_KEY", null); + Log.d("ACCOUNTS_KEY", "Pegou ${event}"); + } catch (Exception e) { + String error = e.getMessage(); + Log.d("ACCOUNTS_KEY", "${error}"); + return; + } } @Override diff --git a/android/debug.keystore b/android/debug.keystore new file mode 100644 index 0000000000000000000000000000000000000000..30d607ced9d6ef1066c6a612832198223cd65847 GIT binary patch literal 2252 zcmchYc{J1uAI9f5V`h+j8%xH{y@VOAP{JDKYxACbDr}&2df9GAP@+AB;arHdj|W2 zhXnZe_4_+FfBbd|iHKgqd9CG!7bcaCQYz9D(+`RJa;E>Wc? z`&C&Xl->J5SPxx{DQg535fFlp4~;^ZE`iS#=9k_#7O$Uuaz~QQG%FB)DaAi7KU-hB z+xG3%A6I)hRRSwqrJU!P5!#I{QT`_%s-c$I2rpx8>niV$i&6Km*SWPM$ak(MyUGR3 zHAKQ^4ZM$+&jw_M{d*yL5Qpm;5V{xNXXqE!udMbNDp3ExV$9m)ypaRD^^=b6i0CwB zr&P*?9prRos1Au_dSUe}8KL&|RENqvT>K49)9I!yOq1wH`h>I%?N<8SSE=g9f1W=^ z$5Zl@h6l4*1pTj{voV`3&1npAxRM}P@JfPFNhGoQR~qHUhOTqsQjGn9xWt@UkD!^W zM8XBT`T1;4CFN)2gC31p8s{3Dopqp(n+`D};aT&%|@M z!LvchQ)WKd*u9Jdwt$Qf3@ni2lkHO2uSgbfQVL#yZ$Tl#B|~zb#S6NS$>wbbV)v~`oUFJlKd~W z#teMQsoUE9*%8C`FbX66W%6)eeNB)dNw!iGLtLVs*Q`@icxSJGKzkh`np%IoNE)w6 z$aAm^vYt0b%9W9k*F2rQ?Ym|lxlB;! z4@VE0_7%A~Ya!ldTrAn?W!_4pjya2x7K=J)j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F1?VMIUf@Q|Zc1!S4pBg=L0URNbT5xgX_ zn^)_B@fmVx)!-LKo{{h20WLks+c8-zJp#?u4K0w38#I~L)ixxrBP&-UQr=Y!?Qg`o zH%|Qy7#rn4@)SM3?Uv6x)Z{mHUQW|m0+~i(NPBVPl38<{bL5dq&vdGts&}(xot0gy z#qI!Xgn3Wtgl6BTEpddUM?^F0Pfh^E@X%krj7gUVo1uTF7vI8OAF{1d57@) b8oRZ37X& literal 0 HcmV?d00001 diff --git a/app/constants/credentials.js b/app/constants/credentials.js index b04ffd7e0..16fdaed41 100644 --- a/app/constants/credentials.js +++ b/app/constants/credentials.js @@ -1,5 +1,5 @@ // This file hosts the constants with the values used on native apps (User Defaults on iOS and Shared Preferences on Android). -import { isIOS } from '../utils/deviceInfo'; +import { isIOS, isAndroid } from '../utils/deviceInfo'; // TODO: remove it export const IDENTIFIER = isIOS ? 'group.ios.chat.rocket' : 'chat.rocket.android'; export const SERVERS = isIOS ? 'kServers' : 'ACCOUNTS_KEY'; diff --git a/app/sagas/init.js b/app/sagas/init.js index ca0374f7e..9012ff3b7 100644 --- a/app/sagas/init.js +++ b/app/sagas/init.js @@ -30,6 +30,8 @@ const restore = function* restore() { }); let servers = yield RNUserDefaults.objectForKey(SERVERS); + + console.log(servers); // if not have current if (servers && servers.length !== 0 && (!token || !server)) { server = servers[0][SERVER_URL];