keys and other JS work
This commit is contained in:
parent
34ab660a3a
commit
de264de643
|
@ -1,5 +1,6 @@
|
|||
def taskRequests = getGradle().getStartParameter().getTaskRequests().toString().toLowerCase()
|
||||
def isFoss = taskRequests.contains("foss")
|
||||
def isOfficial = taskRequests.contains("official")
|
||||
|
||||
apply plugin: "com.android.application"
|
||||
apply plugin: 'kotlin-android'
|
||||
|
@ -143,7 +144,11 @@ android {
|
|||
applicationId "chat.rocket.reactnative"
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode VERSIONCODE as Integer
|
||||
if (isOfficial) {
|
||||
versionCode OFFICIAL_VERSIONCODE as Integer
|
||||
} else {
|
||||
versionCode VERSIONCODE as Integer
|
||||
}
|
||||
versionName "4.10.0"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
manifestPlaceholders = [BugsnagAPIKey: BugsnagAPIKey as String]
|
||||
|
@ -195,16 +200,19 @@ android {
|
|||
foss {
|
||||
dimension = "type"
|
||||
buildConfigField "boolean", "FDROID_BUILD", "true"
|
||||
buildConfigField "boolean", "OFFICIAL_BUILD", "false"
|
||||
}
|
||||
play {
|
||||
dimension = "type"
|
||||
buildConfigField "boolean", "FDROID_BUILD", "false"
|
||||
buildConfigField "boolean", "OFFICIAL_BUILD", "false"
|
||||
}
|
||||
official {
|
||||
dimension = "type"
|
||||
applicationId = "chat.rocket.android"
|
||||
resValue "string", "app_name", "Rocket Chat"
|
||||
buildConfigField "boolean", "FDROID_BUILD", "false"
|
||||
buildConfigField "boolean", "OFFICIAL_BUILD", "true"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,4 +31,7 @@ FLIPPER_VERSION=0.37.0
|
|||
|
||||
# App properties
|
||||
VERSIONCODE=999999999
|
||||
BugsnagAPIKey=""
|
||||
BugsnagAPIKey=""
|
||||
|
||||
OFFICIAL_VERSIONCODE=1
|
||||
OFFICIAL_BugsnagAPIKey="0e62781637138bc11e6ad3ca14c03899"
|
|
@ -0,0 +1,11 @@
|
|||
// 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';
|
||||
|
||||
export const IDENTIFIER = isIOS ? 'group.ios.chat.rocket' : 'rocket.chat';
|
||||
export const SERVERS = isIOS ? 'kServers' : 'ACCOUNTS_KEY';
|
||||
export const TOKEN = isIOS ? 'kAuthToken' : 'authToken';
|
||||
export const USER_ID = isIOS ? 'kUserId' : 'userId';
|
||||
export const SERVER_URL = isIOS ? 'kAuthServerURL' : 'serverUrl';
|
||||
export const SERVER_NAME = isIOS ? 'kServerName' : 'serverName';
|
||||
export const SERVER_ICON = isIOS ? 'kServerIconURL' : 'serverLogoUrl';
|
||||
export const ANDROID_PACKAGE_CONTEXT = 'chat.rocket.android';
|
|
@ -1,3 +1,8 @@
|
|||
import RNConfigReader from 'react-native-config-reader';
|
||||
|
||||
export const isFDroidBuild = RNConfigReader.FDROID_BUILD;
|
||||
// Checks for undefined values
|
||||
let fDroidBuild = RNConfigReader.FDROID_BUILD || false;
|
||||
let officialBuild = RNConfigReader.OFFICIAL_BUILD || false;
|
||||
|
||||
export const isOfficialBuild = officialBuild;
|
||||
export const isFDroidBuild = fDroidBuild;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import { getBundleId, isIOS } from '../utils/deviceInfo';
|
||||
import { isOfficialBuild } from './environment';
|
||||
|
||||
const APP_STORE_ID = '1272915472';
|
||||
let appStoreID = (isOfficialBuild) ? '1148741252' :'1272915472';
|
||||
const APP_STORE_ID = appStoreID;
|
||||
|
||||
export const PLAY_MARKET_LINK = `https://play.google.com/store/apps/details?id=${ getBundleId }`;
|
||||
export const FDROID_MARKET_LINK = 'https://f-droid.org/repo/chat.rocket.android_2057.apk'; // Once link is finalised, Update this
|
||||
|
|
11
app/index.js
11
app/index.js
|
@ -36,8 +36,8 @@ import Toast from './containers/Toast';
|
|||
import InAppNotification from './containers/InAppNotification';
|
||||
import { ActionSheetProvider } from './containers/ActionSheet';
|
||||
import debounce from './utils/debounce';
|
||||
import { isFDroidBuild } from './constants/environment';
|
||||
|
||||
import { isFDroidBuild, isOfficialBuild } from './constants/environment';
|
||||
import { IDENTIFIER, ANDROID_PACKAGE_CONTEXT } from './constants/credentials';
|
||||
|
||||
RNScreens.enableScreens();
|
||||
|
||||
|
@ -102,6 +102,13 @@ export default class Root extends React.Component {
|
|||
}
|
||||
|
||||
init = async() => {
|
||||
if (isOfficialBuild) {
|
||||
await RNUserDefaults.setName(IDENTIFIER);
|
||||
if (isAndroid) {
|
||||
await RNUserDefaults.setPackageContext(ANDROID_PACKAGE_CONTEXT);
|
||||
}
|
||||
}
|
||||
|
||||
RNUserDefaults.objectForKey(THEME_PREFERENCES_KEY).then(this.setTheme);
|
||||
const [notification, deepLinking] = await Promise.all([initializePushNotifications(), Linking.getInitialURL()]);
|
||||
const parsedDeepLinkingURL = parseDeepLinking(deepLinking);
|
||||
|
|
|
@ -18,6 +18,7 @@ import database from '../lib/database';
|
|||
import protectedFunction from '../lib/methods/helpers/protectedFunction';
|
||||
import { localAuthenticate } from '../utils/localAuthentication';
|
||||
import { appStart, ROOT_OUTSIDE, appReady } from '../actions/app';
|
||||
import { isOfficialBuild } from '../constants/environment';
|
||||
|
||||
export const initLocalSettings = function* initLocalSettings() {
|
||||
const sortPreferences = yield RocketChat.getSortPreferences();
|
||||
|
@ -29,9 +30,13 @@ export const initLocalSettings = function* initLocalSettings() {
|
|||
|
||||
const restore = function* restore() {
|
||||
try {
|
||||
let hasMigration;
|
||||
if (isIOS) {
|
||||
hasMigration = yield AsyncStorage.getItem('hasMigration');
|
||||
if (isOfficialBuild) {
|
||||
const hasMigration = yield AsyncStorage.getItem('hasMigration');
|
||||
} else {
|
||||
let hasMigration;
|
||||
if (isIOS) {
|
||||
hasMigration = yield AsyncStorage.getItem('hasMigration');
|
||||
}
|
||||
}
|
||||
|
||||
let { token, server } = yield all({
|
||||
|
|
|
@ -16,9 +16,12 @@ import database from '../lib/database';
|
|||
import log, { logServerVersion } from '../utils/log';
|
||||
import { extractHostname } from '../utils/server';
|
||||
import I18n from '../i18n';
|
||||
import { SERVERS, TOKEN, SERVER_URL } from '../constants/userDefaults';
|
||||
import {
|
||||
SERVERS, TOKEN, SERVER_URL, USER_ID
|
||||
} from '../constants/credentials';
|
||||
import { BASIC_AUTH_KEY, setBasicAuth } from '../utils/fetch';
|
||||
import { appStart, ROOT_INSIDE, ROOT_OUTSIDE } from '../actions/app';
|
||||
import { isOfficialBuild } from '../constants/environment';
|
||||
|
||||
const getServerInfo = function* getServerInfo({ server, raiseError = true }) {
|
||||
try {
|
||||
|
@ -84,12 +87,21 @@ const handleSelectServer = function* handleSelectServer({ server, version, fetch
|
|||
roles: userRecord.roles
|
||||
};
|
||||
} catch (e) {
|
||||
// We only run it if not has user on DB
|
||||
const servers = yield RNUserDefaults.objectForKey(SERVERS);
|
||||
const userCredentials = servers && servers.find(srv => srv[SERVER_URL] === server);
|
||||
user = userCredentials && {
|
||||
token: userCredentials[TOKEN]
|
||||
};
|
||||
if (isOfficialBuild) {
|
||||
// if not have user on db we check on native credentials
|
||||
const servers = yield RNUserDefaults.objectForKey(SERVERS);
|
||||
const userCredentials = servers && servers.find(srv => srv[SERVER_URL] === server);
|
||||
user = userCredentials && {
|
||||
token: userCredentials[TOKEN].length > userCredentials[USER_ID].length ? userCredentials[TOKEN] : userCredentials[USER_ID]
|
||||
};
|
||||
} else {
|
||||
// We only run it if not has user on DB
|
||||
const servers = yield RNUserDefaults.objectForKey('kServers');
|
||||
const userCredentials = servers && servers.find(srv => srv['kAuthServerURL'] === server);
|
||||
user = userCredentials && {
|
||||
token: userCredentials['kAuthToken']
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import RocketChat, { THEME_PREFERENCES_KEY } from './lib/rocketchat';
|
|||
import { ThemeContext } from './theme';
|
||||
import { localAuthenticate } from './utils/localAuthentication';
|
||||
import ScreenLockedView from './views/ScreenLockedView';
|
||||
import { IDENTIFIER, ANDROID_PACKAGE_CONTEXT } from './constants/credentials';
|
||||
|
||||
// Outside Stack
|
||||
import WithoutServersView from './views/WithoutServersView';
|
||||
|
@ -35,6 +36,7 @@ import { setCurrentScreen } from './utils/log';
|
|||
import AuthLoadingView from './views/AuthLoadingView';
|
||||
import { DimensionsContext } from './dimensions';
|
||||
import debounce from './utils/debounce';
|
||||
import { isOfficialBuild } from './constants/environment';
|
||||
|
||||
const Inside = createStackNavigator();
|
||||
const InsideStack = () => {
|
||||
|
@ -138,6 +140,13 @@ class Root extends React.Component {
|
|||
}
|
||||
|
||||
init = async() => {
|
||||
if (isOfficialBuild) {
|
||||
await RNUserDefaults.setName(IDENTIFIER);
|
||||
if (isAndroid) {
|
||||
await RNUserDefaults.setPackageContext(ANDROID_PACKAGE_CONTEXT);
|
||||
}
|
||||
}
|
||||
|
||||
RNUserDefaults.objectForKey(THEME_PREFERENCES_KEY).then(this.setTheme);
|
||||
const currentServer = await RNUserDefaults.get('currentServer');
|
||||
const token = await RNUserDefaults.get(RocketChat.TOKEN_KEY);
|
||||
|
|
Loading…
Reference in New Issue