diff --git a/android/app/build.gradle b/android/app/build.gradle index 51986a2..342c10d 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -1,226 +1,222 @@ apply plugin: "com.android.application" import com.android.build.OutputFile /** * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets * and bundleReleaseJsAndAssets). * These basically call `react-native bundle` with the correct arguments during the Android build * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the * bundle directly from the development server. Below you can see all the possible configurations * and their defaults. If you decide to add a configuration block, make sure to add it before the * `apply from: "../../node_modules/react-native/react.gradle"` line. * * project.ext.react = [ * // the name of the generated asset file containing your JS bundle * bundleAssetName: "index.android.bundle", * * // the entry file for bundle generation * entryFile: "index.android.js", * * // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format * bundleCommand: "ram-bundle", * * // whether to bundle JS and assets in debug mode * bundleInDebug: false, * * // whether to bundle JS and assets in release mode * bundleInRelease: true, * * // whether to bundle JS and assets in another build variant (if configured). * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants * // The configuration property can be in the following formats * // 'bundleIn${productFlavor}${buildType}' * // 'bundleIn${buildType}' * // bundleInFreeDebug: true, * // bundleInPaidRelease: true, * // bundleInBeta: true, * * // whether to disable dev mode in custom build variants (by default only disabled in release) * // for example: to disable dev mode in the staging build type (if configured) * devDisabledInStaging: true, * // The configuration property can be in the following formats * // 'devDisabledIn${productFlavor}${buildType}' * // 'devDisabledIn${buildType}' * * // the root of your project, i.e. where "package.json" lives * root: "../../", * * // where to put the JS bundle asset in debug mode * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", * * // where to put the JS bundle asset in release mode * jsBundleDirRelease: "$buildDir/intermediates/assets/release", * * // where to put drawable resources / React Native assets, e.g. the ones you use via * // require('./image.png')), in debug mode * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", * * // where to put drawable resources / React Native assets, e.g. the ones you use via * // require('./image.png')), in release mode * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", * * // by default the gradle tasks are skipped if none of the JS files or assets change; this means * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to * // date; if you have any other folders that you want to ignore for performance reasons (gradle * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ * // for example, you might want to remove it from here. * inputExcludes: ["android/**", "ios/**"], * * // override which node gets called and with what additional arguments * nodeExecutableAndArgs: ["node"], * * // supply additional arguments to the packager * extraPackagerArgs: [] * ] */ project.ext.react = [ entryFile: "index.js", enableHermes: false, // clean and rebuild if changing ] apply from: "../../node_modules/react-native/react.gradle" /** * Set this to true to create two separate APKs instead of one: * - An APK that only works on ARM devices * - An APK that only works on x86 devices * The advantage is the size of the APK is reduced by about 4MB. * Upload all the APKs to the Play Store and people will download * the correct one based on the CPU architecture of their device. */ def enableSeparateBuildPerCPUArchitecture = false /** * Run Proguard to shrink the Java bytecode in release builds. */ def enableProguardInReleaseBuilds = false /** * The preferred build flavor of JavaScriptCore. * * For example, to use the international variant, you can use: * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` * * The international variant includes ICU i18n library and necessary data * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that * give correct results when using with locales other than en-US. Note that * this variant is about 6MiB larger per architecture than default. */ def jscFlavor = 'org.webkit:android-jsc:+' /** * Whether to enable the Hermes VM. * * This should be set on project.ext.react and mirrored here. If it is not set * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode * and the benefits of using Hermes will therefore be sharply reduced. */ def enableHermes = project.ext.react.get("enableHermes", false); // Load keystore def keystorePropertiesFile = rootProject.file("keystore.properties"); def keystoreProperties = new Properties() keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) android { compileSdkVersion rootProject.ext.compileSdkVersion compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } defaultConfig { applicationId "com.agprojects.sylk" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion missingDimensionStrategy "RNNotifications.reactNativeVersion", "reactNative60" versionCode 63 versionName "1.63.0" multiDexEnabled true } splits { abi { reset() enable enableSeparateBuildPerCPUArchitecture universalApk false // If true, also generate a universal APK include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" } } signingConfigs { debug { -// storeFile file('debug.keystore') -// storePassword 'android' -// keyAlias 'androiddebugkey' -// keyPassword 'android' - storeFile file(keystoreProperties['storeFile']) - storePassword keystoreProperties['storePassword'] - keyAlias keystoreProperties['keyAlias'] - keyPassword keystoreProperties['keyPassword'] + storeFile file('debug.keystore') + storePassword 'android' + keyAlias 'androiddebugkey' + keyPassword 'android' } release { storeFile file(keystoreProperties['storeFile']) storePassword keystoreProperties['storePassword'] keyAlias keystoreProperties['keyAlias'] keyPassword keystoreProperties['keyPassword'] } } buildTypes { debug { signingConfig signingConfigs.debug } release { // Caution! In production, you need to generate your own keystore file. // see https://facebook.github.io/react-native/docs/signed-apk-android. signingConfig signingConfigs.release minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" } } // applicationVariants are e.g. debug, release applicationVariants.all { variant -> variant.outputs.each { output -> // For each separate APK per architecture, set a unique version code as described here: // https://developer.android.com/studio/build/configure-apk-splits.html def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] def abi = output.getFilter(OutputFile.ABI) if (abi != null) { // null for the universal-debug, universal-release variants output.versionCodeOverride = versionCodes.get(abi) * 1048576 + defaultConfig.versionCode } } } } dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) implementation 'com.google.firebase:firebase-core:16.0.0' implementation "com.google.firebase:firebase-messaging:17.3.0" implementation "com.facebook.react:react-native:+" // From node_modules implementation "androidx.multidex:multidex:2.0.1" if (enableHermes) { def hermesPath = "../../node_modules/hermes-engine/android/"; debugImplementation files(hermesPath + "hermes-debug.aar") releaseImplementation files(hermesPath + "hermes-release.aar") } else { implementation jscFlavor } } // Run this once to be able to run the application with BUCK // puts all compile dependencies into folder libs for BUCK to use task copyDownloadableDepsToLibs(type: Copy) { from configurations.compile into 'libs' } apply plugin: 'com.google.gms.google-services' // Google Play services Gradle plugin apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) diff --git a/app/components/NavigationBar.js b/app/components/NavigationBar.js index 42daa27..d8085a8 100644 --- a/app/components/NavigationBar.js +++ b/app/components/NavigationBar.js @@ -1,224 +1,223 @@ import React, { Component } from 'react'; import { Linking, Image, Platform, View } from 'react-native'; import PropTypes from 'prop-types'; import autoBind from 'auto-bind'; import { Appbar, Menu, Divider, Text } from 'react-native-paper'; import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; import config from '../config'; import AboutModal from './AboutModal'; import CallMeMaybeModal from './CallMeMaybeModal'; import EditDisplayNameModal from './EditDisplayNameModal'; import styles from '../assets/styles/blink/_NavigationBar.scss'; const blinkLogo = require('../assets/images/blink-white-big.png'); class NavigationBar extends Component { constructor(props) { super(props); autoBind(this); this.state = { showAboutModal: false, showCallMeMaybeModal: false, showEditDisplayNameModal: false, registrationState: this.props.registrationState, connection: this.props.connection, proximity: this.props.proximity, mute: false, menuVisible: false, accountId: this.props.account ? this.props.account.id : null, displayName: this.props.displayName } this.menuRef = React.createRef(); } //getDerivedStateFromProps(nextProps, state) { UNSAFE_componentWillReceiveProps(nextProps) { if (nextProps.account !== null && nextProps.account.id !== this.state.accountId) { this.setState({accountId: nextProps.account.id}); } this.setState({registrationState: nextProps.registrationState, connection: nextProps.connection, displayName: nextProps.displayName, proximity: nextProps.proximity }); } handleMenu(event) { this.callUrl = `${config.publicUrl}/call/${this.state.accountId}`; switch (event) { case 'about': this.toggleAboutModal(); break; case 'callMeMaybe': this.toggleCallMeMaybeModal(); break; case 'displayName': this.toggleEditDisplayNameModal(); break; case 'speakerphone': this.props.toggleSpeakerPhone(); break; case 'proximity': this.props.toggleProximity(); break; case 'logOut': this.props.logout(); break; case 'logs': this.props.showLogs(); break; case 'preview': this.props.preview(); break; case 'checkUpdate': if (Platform.OS === 'android') { Linking.openURL('https://play.google.com/store/apps/details?id=com.agprojects.sylk'); } else { Linking.openURL('https://apps.apple.com/us/app/id1489960733'); } break; case 'settings': Linking.openURL(config.serverSettingsUrl); break; default: break; } this.setState({menuVisible: false}); } saveDisplayName(displayName) { if (!displayName) { return; } this.setState({displayName: displayName}); this.props.saveDisplayName(this.state.accountId, displayName); } toggleMute() { this.setState(prevState => ({mute: !prevState.mute})); this.props.toggleMute(); } toggleAboutModal() { this.setState({showAboutModal: !this.state.showAboutModal}); } toggleCallMeMaybeModal() { this.setState({showCallMeMaybeModal: !this.state.showCallMeMaybeModal}); } toggleEditDisplayNameModal() { this.setState({showEditDisplayNameModal: !this.state.showEditDisplayNameModal}); } render() { const muteIcon = this.state.mute ? 'bell-off' : 'bell'; let subtitleStyle = this.props.isTablet ? styles.tabletSubtitle: styles.subtitle; let titleStyle = this.props.isTablet ? styles.tabletTitle: styles.title; let statusIcon = null; let statusColor = 'green'; statusIcon = 'check-circle'; if (!this.state.connection || this.state.connection.state !== 'ready') { statusIcon = 'alert-circle'; statusColor = 'red'; } else if (this.state.registrationState !== 'registered') { statusIcon = 'alert-circle'; statusColor = 'orange'; } let callUrl = callUrl = config.publicUrl + "/call/" + this.state.accountId; let subtitle = 'Signed in as ' + this.state.accountId; let proximityTitle = this.state.proximity ? 'Disable proximity sensor' : 'Enable proximity sensor'; let proximityIcon = this.state.proximity ? 'ear-hearing-off' : 'ear-hearing'; // this.handleMenu('speakerphone')} icon="speaker" title="Toggle speakerphone" /> return ( {this.props.isTablet? {subtitle} : null} {statusIcon ? : null } this.setState({menuVisible: !this.state.menuVisible})} anchor={ this.setState({menuVisible: !this.state.menuVisible})} /> } > this.handleMenu('about')} icon="information" title="About Sylk" /> this.handleMenu('preview')} icon="video" title="Video preview" /> this.handleMenu('callMeMaybe')} icon="share" title="Call me, maybe?" /> this.handleMenu('displayName')} icon="rename-box" title="My display name" /> this.handleMenu('settings')} icon="wrench" title="Server settings..." /> this.handleMenu('logs')} icon="timeline-text-outline" title="Show logs" /> - this.handleMenu('speakerphone')} icon="speaker" title="Toggle speakerphone" /> this.handleMenu('proximity')} icon={proximityIcon} title={proximityTitle} /> this.handleMenu('checkUpdate')} icon="update" title="Check for updates..." /> this.handleMenu('logOut')} icon="logout" title="Sign out" /> ); } } NavigationBar.propTypes = { notificationCenter : PropTypes.func.isRequired, logout : PropTypes.func.isRequired, preview : PropTypes.func.isRequired, toggleSpeakerPhone : PropTypes.func.isRequired, toggleProximity : PropTypes.func.isRequired, saveDisplayName : PropTypes.func.isRequired, showLogs : PropTypes.func.isRequired, proximity : PropTypes.bool, displayName : PropTypes.string, account : PropTypes.object, connection : PropTypes.object, toggleMute : PropTypes.func, orientation : PropTypes.string, isTablet : PropTypes.bool }; export default NavigationBar; diff --git a/app/utils.js b/app/utils.js index 8ea256b..1bccfad 100644 --- a/app/utils.js +++ b/app/utils.js @@ -1,207 +1,207 @@ import uuidv4 from 'uuid/v4'; import SillyNames from './SillyNames'; import MaterialColors from './MaterialColors'; import { Clipboard, Dimensions } from 'react-native'; import Contacts from 'react-native-contacts'; const RNFS = require('react-native-fs'); const logfile = RNFS.DocumentDirectoryPath + '/logs.txt'; function log2file(text) { // append to logfile RNFS.appendFile(logfile, text + '\r\n', 'utf8') .then((success) => { console.log(text); }) .catch((err) => { console.log(err.message); }); } function isAnonymous(uri) { if (uri.indexOf('@guest.') > -1 || uri.indexOf('@anonymous.') > -1) { return true } if (uri.indexOf('@192.168.') > -1) { return true; } if (uri.indexOf('@10.') > -1) { return true; } return false; } function appendLeadingZeroes(n){ if (n <= 9) { return "0" + n; } return n; } function timestampedLog() { let current_datetime = new Date(); let formatted_date = current_datetime.getFullYear() + "-" + appendLeadingZeroes(current_datetime.getMonth() + 1) + "-" + appendLeadingZeroes(current_datetime.getDate()) + " " + appendLeadingZeroes(current_datetime.getHours()) + ":" + appendLeadingZeroes(current_datetime.getMinutes()) + ":" + appendLeadingZeroes(current_datetime.getSeconds()); let message = formatted_date; for (var i = 0; i < arguments.length; i++) { let txt = arguments[i] ? arguments[i].toString() : ''; message = message + ' ' + txt; } log2file(message); //console.log(message); } function generateUniqueId() { const uniqueId = uuidv4().replace(/-/g, '').slice(0, 16); return uniqueId; } function normalizeUri(uri, defaultDomain) { let targetUri = uri; let idx = targetUri.indexOf('@'); let username; let domain; if (idx !== -1) { username = targetUri.substring(0, idx); domain = targetUri.substring(idx + 1); } else { username = targetUri; domain = defaultDomain; } - username = username.replace(/[<>\s()\[\]\'\"\~\!\%\&\*\{\}\|\\]/g, ''); + username = username.replace(/[\s()-]/g, ''); return `${username}@${domain}`; } function copyToClipboard(text) { Clipboard.setString(text); return true; } function findContact(uri) { return new Promise((resolve, reject) => { //console.log('findContact') Contacts.checkPermission((err, permission) => { if (err) { //log the error console.log(err); return reject(err); } if (permission === 'authorized') { //console.log('HELLO', uri); Contacts.getContactsByEmailAddress(uri, (err, contacts) => { if (err) { console.log('error getting contacts by email') return reject(err); } if (contacts) { return resolve(contacts) } Contacts.getContactsMatchingString(uri, (err2, contacts2) => { if (err2) { console.log('error matching string') return reject(err2); } console.log(contacts); resolve(contacts2) }); }) } else { console.log('not authortised') reject(new Error('Not Authorised')) } }) }) } function generateSillyName() { const adjective = SillyNames.randomAdjective(); const number = Math.floor(Math.random() * 10); const noun1 = SillyNames.randomNoun(); const noun2 = SillyNames.randomNoun(); return adjective + noun1 + noun2 + number; } function generateMaterialColor(text) { return MaterialColors.generateColor(text); } function generateVideoTrack(stream, width = 640, height = 480) { // const audioCtx = new (window.AudioContext || window.webkitAudioContext)(); // const analyser = audioCtx.createAnalyser(); // const source = audioCtx.createMediaStreamSource(stream); // source.connect(analyser); // analyser.fftSize = 256; // const bufferLength = analyser.frequencyBinCount; // const dataArray = new Uint8Array(bufferLength); // const canvas = Object.assign(document.createElement('canvas'), {width, height}); // const ctx = canvas.getContext('2d'); // const img = new Image(); // const blinkLogo = new Image(); // img.addEventListener('load', () => { // draw(); // }); // const draw = () => { // if (stream.active) { // const drawVisual = requestAnimationFrame(draw); // } // analyser.getByteFrequencyData(dataArray); // ctx.fillStyle = 'rgb(35, 35, 35)'; // ctx.fillRect(0, 0, width, height); // ctx.filter = 'grayscale(100%) brightness(90%)'; // ctx.drawImage(blinkLogo, (width / 2) - 150, (height / 2) - 150, 300, 300); // ctx.filter = 'none'; // ctx.drawImage(img, (width / 2) - 45 , height / 3, 90, 90); // const barWidth = (width / bufferLength) * 2.5; // let barHeight; // let x = 0; // for(var i = 0; i < bufferLength; i++) { // barHeight = dataArray[i] / 2; // ctx.fillStyle = 'rgb(' + (barHeight + 100) + ', 50, 50)'; // ctx.fillRect(x, 2 * height / 3 - barHeight / 2, barWidth, barHeight); // x += barWidth + 1; // } // }; // img.src = 'assets/images/video-camera-slash.png'; // blinkLogo.src = 'assets/images/blink-white-big.png'; // const canvasStream = canvas.captureStream(); return Object.assign(stream.getVideoTracks()[0], {enabled: true}); } function getWindowHeight() { return Dimensions.get('window').height; } exports.copyToClipboard = copyToClipboard; exports.normalizeUri = normalizeUri; exports.generateSillyName = generateSillyName; exports.timestampedLog = timestampedLog; exports.appendLeadingZeroes = appendLeadingZeroes; exports.generateUniqueId = generateUniqueId; exports.generateMaterialColor = generateMaterialColor; exports.generateVideoTrack = generateVideoTrack; exports.getWindowHeight = getWindowHeight; exports.findContact = findContact; exports.findContact = findContact; exports.isAnonymous = isAnonymous; diff --git a/fastlane/metadata/android/en-US/changelogs/63.txt b/fastlane/metadata/android/en-US/changelogs/63.txt deleted file mode 100644 index 9d4b33c..0000000 --- a/fastlane/metadata/android/en-US/changelogs/63.txt +++ /dev/null @@ -1,9 +0,0 @@ - * Remove CallKeep listeners at unmount - * Added proximity sensor setting - * Hangup call when press back button - * Do not exit the app on back button press - * Stop handling network notifications if the app was unmounted - * Added logs panel - * Only bring up alert panel when push notification arrives - * Go to ready as soon as a new call comes in - * Increased Android version to v29