Merge branch 'new/android-migration' of github.com:RocketChat/Rocket.Chat.ReactNative into new/android-migration

This commit is contained in:
Filipe Brito 2019-09-19 19:17:14 -03:00
commit 5439a7bec3
7 changed files with 36 additions and 10 deletions

1
.gitignore vendored
View File

@ -48,6 +48,7 @@ coverage/
buck-out/
\.buckd/
*.keystore
!debug.keystore
# fastlane
#

View File

@ -151,6 +151,12 @@ android {
keyPassword KEY_PASSWORD
}
}
debug {
storeFile project.rootProject.file('debug.keystore').getCanonicalFile()
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
}
splits {
abi {

View File

@ -2,15 +2,6 @@
package="chat.rocket.reactnative"
android:sharedUserId="chat.rocket.android">
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission-sdk-23 android:name="android.permission.VIBRATE" />
<application
android:name=".MainApplication"
android:allowBackup="true"
@ -28,6 +19,7 @@
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.DOWNLOAD_COMPLETE" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
@ -71,4 +63,14 @@
android:value="${BugsnagAPIKey}" />
</application>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission-sdk-23 android:name="android.permission.VIBRATE" />
</manifest>

View File

@ -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

BIN
android/debug.keystore Normal file

Binary file not shown.

View File

@ -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';

View File

@ -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];