Skip to content

Commit

Permalink
Merge pull request #503 from AiursoftWeb/dev
Browse files Browse the repository at this point in the history
Release 3.4.0
  • Loading branch information
Anduin2017 authored Jun 2, 2019
2 parents e01c32e + ce2b053 commit f5e4661
Show file tree
Hide file tree
Showing 16 changed files with 1,562 additions and 2,055 deletions.
3,269 changes: 1,358 additions & 1,911 deletions package-lock.json

Large diffs are not rendered by default.

63 changes: 31 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kahla",
"version": "3.3.1",
"version": "3.4.0",
"description": "Kahla is a cross-platform business messaging app.",
"author": "Aiursoft <postmaster@aiursoft.com> (https://www.aiursoft.com/)",
"build": {
Expand Down Expand Up @@ -64,17 +64,16 @@
"prod-zh": "npm run prebuild && ng build --base-href / --prod --i18n-locale zh --i18n-file ./src/messages.zh.xlf"
},
"dependencies": {
"@angular/animations": "7.2.4",
"@angular/common": "7.2.4",
"@angular/compiler": "7.2.4",
"@angular/core": "7.2.4",
"@angular/forms": "7.2.4",
"@angular/http": "7.2.4",
"@angular/platform-browser": "7.2.4",
"@angular/platform-browser-dynamic": "7.2.4",
"@angular/router": "7.2.4",
"autolinker": "^3.0.0",
"blueimp-load-image": "^2.20.1",
"@angular/animations": "8.0.0",
"@angular/common": "8.0.0",
"@angular/compiler": "8.0.0",
"@angular/core": "8.0.0",
"@angular/forms": "8.0.0",
"@angular/platform-browser": "8.0.0",
"@angular/platform-browser-dynamic": "8.0.0",
"@angular/router": "8.0.0",
"autolinker": "^3.0.5",
"blueimp-load-image": "^2.21.0",
"cordova-android": "^7.1.4",
"cordova-browser": "^6.0.0",
"cordova-ios": "^5.0.0",
Expand All @@ -85,32 +84,32 @@
"font-awesome": "^4.7.0",
"he": "^1.2.0",
"ngx-electron": "^2.1.1",
"rxjs": "^6.4.0",
"smoothscroll-polyfill": "^0.4.3",
"sweetalert2": "^8.0.7",
"zone.js": "^0.8.29"
"rxjs": "^6.5.2",
"smoothscroll-polyfill": "^0.4.4",
"sweetalert2": "^8.11.6",
"zone.js": "^0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.13.9",
"@angular-devkit/build-optimizer": "^0.13.1",
"@angular-devkit/core": "^7.3.1",
"@angular/cli": "7.3.1",
"@angular/compiler-cli": "^7.2.9",
"@angular/language-service": "7.2.4",
"@types/jasmine": "^3.3.8",
"@angular-devkit/build-angular": "^0.800.0",
"@angular-devkit/build-optimizer": "^0.800.0",
"@angular-devkit/core": "^8.0.0",
"@angular/cli": "8.0.0",
"@angular/compiler-cli": "^8.0.0",
"@angular/language-service": "8.0.0",
"@types/jasmine": "^3.3.13",
"@types/jasminewd2": "^2.0.6",
"@types/node": "^11.9.3",
"codelyzer": "^4.5.0",
"@types/node": "^12.0.3",
"codelyzer": "^5.0.1",
"cordova": "^9.0.0",
"electron": "^4.0.4",
"electron-builder": "^20.41.0",
"jasmine-core": "^3.3.0",
"jasmine-core": "^3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"node": "^11.15.0",
"ts-node": "^8.0.2",
"tslint": "~5.12.1",
"typescript": "^3.2.4",
"webpack": "^4.29.3"
"node": "^12.3.1",
"ts-node": "^8.2.0",
"tslint": "~5.16.0",
"typescript": "^3.4.5",
"webpack": "^4.32.2"
},
"cordova": {
"platforms": [
Expand All @@ -134,4 +133,4 @@
},
"homepage": "https://kahla.aiursoft.com",
"release": "build"
}
}
33 changes: 17 additions & 16 deletions src/app/Controllers/talking.component.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import {Component, OnInit, OnDestroy, ElementRef, ViewChild, HostListener} from '@angular/core';
import {ActivatedRoute, Params} from '@angular/router';
import {ConversationApiService} from '../Services/ConversationApiService';
import {Message} from '../Models/Message';
import {switchMap, map} from 'rxjs/operators';
import {AES} from 'crypto-js';
import { Component, OnInit, OnDestroy, ElementRef, ViewChild, HostListener } from '@angular/core';
import { ActivatedRoute, Params } from '@angular/router';
import { ConversationApiService } from '../Services/ConversationApiService';
import { Message } from '../Models/Message';
import { switchMap, map } from 'rxjs/operators';
import { AES } from 'crypto-js';
import Swal from 'sweetalert2';
import {Values} from '../values';
import {UploadService} from '../Services/UploadService';
import {MessageService} from '../Services/MessageService';
import {HeaderService} from '../Services/HeaderService';
import { Values } from '../values';
import { UploadService } from '../Services/UploadService';
import { MessageService } from '../Services/MessageService';
import { HeaderService } from '../Services/HeaderService';
import * as he from 'he';
import Autolinker from 'autolinker';
import {TimerService} from '../Services/TimerService';
import { TimerService } from '../Services/TimerService';
import { KahlaUser } from '../Models/KahlaUser';
import { ElectronService } from 'ngx-electron';

Expand Down Expand Up @@ -47,10 +47,10 @@ export class TalkingComponent implements OnInit, OnDestroy {
public showUserList = false;
public matchedUsers: Array<KahlaUser> = [];

@ViewChild('mainList') public mainList: ElementRef;
@ViewChild('imageInput') public imageInput;
@ViewChild('videoInput') public videoInput;
@ViewChild('fileInput') public fileInput;
@ViewChild('mainList', {static: false}) public mainList: ElementRef;
@ViewChild('imageInput', {static: false}) public imageInput;
@ViewChild('videoInput', {static: false}) public videoInput;
@ViewChild('fileInput', {static: false}) public fileInput;

constructor(
private route: ActivatedRoute,
Expand Down Expand Up @@ -166,7 +166,7 @@ export class TalkingComponent implements OnInit, OnDestroy {
}
});

if ( !/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
if (!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
inputElement.focus();
}

Expand Down Expand Up @@ -209,6 +209,7 @@ export class TalkingComponent implements OnInit, OnDestroy {
return;
}
const tempMessage = new Message();
tempMessage.isEmoji = this.messageService.checkEmoji(this.content);
tempMessage.content = he.encode(this.content);
tempMessage.content = Autolinker.link(tempMessage.content, {
stripPrefix: false,
Expand Down
2 changes: 1 addition & 1 deletion src/app/Controllers/userDetail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { HeaderService } from '../Services/HeaderService';
export class UserDetailComponent implements OnInit {
public user: KahlaUser;
public loadingImgURL = Values.loadingImgURL;
@ViewChild('imageInput') public imageInput;
@ViewChild('imageInput', {static: false}) public imageInput;
constructor(
private authApiService: AuthApiService,
private router: Router,
Expand Down
1 change: 1 addition & 0 deletions src/app/Models/Message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export class Message {
public sender: KahlaUser;
public sendTime: Date;
public content: string;
public isEmoji = false;
public read: boolean;
public local = false;
public avatarURL: string;
Expand Down
4 changes: 3 additions & 1 deletion src/app/Models/Themes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ export enum Themes {
kahlaLight,
kahlaDark,
sakuraLight,
sakuraDark
sakuraDark,
violetLight,
violetDark
}
46 changes: 12 additions & 34 deletions src/app/Services/MessageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,8 @@ export class MessageService {
if (fileKey === -1 || isNaN(fileKey)) {
t.content = '';
} else if (t.content.startsWith('[img]')) {
let imageWidth = Number(t.content.split('-')[2]),
imageHeight = Number(t.content.split('-')[1]);
let swap = 0;
if (t.content.substring(5).split('-')[3] === '6' || t.content.substring(5).split('-')[3] === '8' ||
t.content.substring(5).split('-')[3] === '5' || t.content.substring(5).split('-')[3] === '7') {
[imageWidth, imageHeight] = [imageHeight, imageWidth];
swap = 1;
}
let imageWidth = Number(t.content.split('-')[1]),
imageHeight = Number(t.content.split('-')[2]);
const ratio = imageHeight / imageWidth;
const realMaxWidth = Math.min(this.maxImageWidth, Math.floor(900 / ratio));

Expand All @@ -175,15 +169,15 @@ export class MessageService {
imageHeight = Math.floor(realMaxWidth * ratio);
}

t.content = `[img]${Values.fileAddress}${t.content.substring(5).split('-')[0]}-${
imageWidth}-${imageHeight}-${this.getOrientationClassName(t.content.substring(5).split('-')[3])}-${swap}`;
t.content = `[img]${Values.fileAddress}${t.content.substring(5).split('-')[0]}-${imageWidth}-${imageHeight}`;
}
} else if (t.content.match(/^\[(file|audio)\].*/)) {
const fileKey = this.uploadService.getFileKey(t.content);
if (fileKey === -1 || isNaN(fileKey)) {
t.content = '';
}
} else {
t.isEmoji = this.checkEmoji(t.content);
t.content = he.encode(t.content);
t.content = Autolinker.link(t.content, {
stripPrefix: false,
Expand Down Expand Up @@ -280,30 +274,6 @@ export class MessageService {
this.groupConversation = false;
}

private getOrientationClassName(exifValue: string): string {
switch (exifValue) {
case '0':
case '1':
return '';
case '2':
return 'flip';
case '3':
return 'bottom_right';
case '4':
return 'flip_bottom_right';
case '5':
return 'flip_right_top';
case '6':
return 'right_top';
case '7':
return 'flip_left_bottom';
case '8':
return 'left_bottom';
default:
return '';
}
}

private showNotification(event: NewMessageEvent): void {
if (!event.muted && event.sender.id !== this.me.id && this._electronService.isElectronApp) {
event.content = AES.decrypt(event.content, event.aesKey).toString(enc.Utf8);
Expand Down Expand Up @@ -358,4 +328,12 @@ export class MessageService {
atUsers.unshift(newMessageArry.join(' '));
return atUsers;
}

public checkEmoji(text: string): boolean {
if (text.length > 2) {
return false;
}
const regex = /(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])/g;
return regex.test(text);
}
}
10 changes: 10 additions & 0 deletions src/app/Services/ThemeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ export class ThemeService {
elementRef.nativeElement.ownerDocument.querySelector('meta[name=theme-color]')
.setAttribute('content', '#cf4c78');
break;
case Themes.violetLight:
elementRef.nativeElement.ownerDocument.body.className = 'theme-violet-light';
elementRef.nativeElement.ownerDocument.querySelector('meta[name=theme-color]')
.setAttribute('content', '#5F4B8B');
break;
case Themes.violetDark:
elementRef.nativeElement.ownerDocument.body.className = 'theme-violet-dark';
elementRef.nativeElement.ownerDocument.querySelector('meta[name=theme-color]')
.setAttribute('content', '#5F4B8B');
break;
case Themes.kahlaLight:
default:
elementRef.nativeElement.ownerDocument.body.className = 'theme-light';
Expand Down
9 changes: 6 additions & 3 deletions src/app/Services/UploadService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,15 @@ export class UploadService {
loadImage(
file,
function (img, data) {
let orientation = 0;
let orientation = 0, width = img.width, height = img.height;
if (data.exif) {
orientation = data.exif.get('Orientation');
if (orientation >= 5 && orientation <= 8) {
[width, height] = [height, width];
}
}
encedMessages = AES.encrypt(`[img]${(<UploadFile>response).fileKey}-${img.height}-${
img.width}-${orientation}`, aesKey).toString();
encedMessages = AES.encrypt(`[img]${(<UploadFile>response).fileKey}-${width}-${
height}-${orientation}`, aesKey).toString();
this.sendMessage(encedMessages, conversationID);
}.bind(this),
{meta: true}
Expand Down
4 changes: 3 additions & 1 deletion src/app/Styles/_themes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
@import 'themes/light';
@import 'themes/dark';
@import 'themes/sakura-light';
@import 'themes/sakura-dark';
@import 'themes/sakura-dark';
@import 'themes/violet-light';
@import 'themes/violet-dark';
54 changes: 13 additions & 41 deletions src/app/Styles/talking.scss
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,19 @@
white-space: pre-wrap;
}

&.single-emoji {
background-color: transparent !important;

&:after {
border-left: unset !important;
border-right: unset !important;
}

p {
font-size: 64px;
}
}

.loading {
color: #eeeeee;
}
Expand Down Expand Up @@ -393,47 +406,6 @@ a h5 {
@extend %primary-button;
}

.bottom_right {
transform: rotate(180deg);
}

.right_top {
transform: rotate(90deg);
position: absolute;
transform-origin: top left;
left: 100%;
}

.left_bottom {
transform: rotate(-90deg);
transform-origin: top right;
position: absolute;
right: 100%;
}

.flip_bottom_right {
transform: scaleX(-1) rotate(180deg);
}

.flip_right_top {
transform: scaleX(-1) rotate(90deg);
position: absolute;
transform-origin: top left;
left: 0;
}

.flip_left_bottom {
transform: scaleX(-1) rotate(-90deg);
position: absolute;
transform-origin: top right;
right: 0;
}

.flip {
transform: scaleX(-1);
}


.oneResult {
bottom: 0;
}
Loading

0 comments on commit f5e4661

Please sign in to comment.