Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Lumen search (#394)

* Implement Search with onboarding on lumen

* adding missing file

* search engine icons and working cliqz integration

* translations
  • Loading branch information
chrmod authored and pavel-cliqz committed Jul 19, 2019
1 parent 453de99 commit bf8302827c5f207533c4961852824df55c8a0e6e
Showing with 529 additions and 74 deletions.
  1. +8 −0 Client.xcodeproj/project.pbxproj
  2. +1 −1 Cliqz/React Components/Engine.swift
  3. +3 −2 Cliqz/React Components/Modules/JSBridge.swift
  4. +7 −1 Cliqz/React Components/Modules/NativeDrawable.m
  5. +27 −0 Cliqz/React Components/Modules/Onboarding.swift
  6. +15 −0 Cliqz/React Components/Modules/OnboardingBridge.m
  7. +23 −0 Cliqz/Resources/Common.xcassets/ReactCards/ic_ez_bing.imageset/Contents.json
  8. BIN Cliqz/Resources/Common.xcassets/ReactCards/ic_ez_bing.imageset/bing@1x.png
  9. BIN Cliqz/Resources/Common.xcassets/ReactCards/ic_ez_bing.imageset/bing@2x.png
  10. BIN Cliqz/Resources/Common.xcassets/ReactCards/ic_ez_bing.imageset/bing@3x.png
  11. +23 −0 Cliqz/Resources/Common.xcassets/ReactCards/ic_ez_ddg.imageset/Contents.json
  12. BIN Cliqz/Resources/Common.xcassets/ReactCards/ic_ez_ddg.imageset/ddg@1x.png
  13. BIN Cliqz/Resources/Common.xcassets/ReactCards/ic_ez_ddg.imageset/ddg@2x.png
  14. BIN Cliqz/Resources/Common.xcassets/ReactCards/ic_ez_ddg.imageset/ddg@3x.png
  15. +23 −0 Cliqz/Resources/Common.xcassets/ReactCards/ic_ez_google.imageset/Contents.json
  16. BIN Cliqz/Resources/Common.xcassets/ReactCards/ic_ez_google.imageset/google@1x.png
  17. BIN Cliqz/Resources/Common.xcassets/ReactCards/ic_ez_google.imageset/google@2x.png
  18. BIN Cliqz/Resources/Common.xcassets/ReactCards/ic_ez_google.imageset/google@3x.png
  19. +9 −13 README.md
  20. +25 −0 js/i18n.js
  21. +35 −0 js/localization/de.json
  22. +35 −0 js/localization/en.json
  23. +112 −0 js/lumen-onboarding.js
  24. +144 −38 lumen.js
  25. +37 −18 package-lock.json
  26. +2 −1 package.json
@@ -212,6 +212,8 @@
28F596A11ACA13CA0071DDCC /* InfoTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28F596A01ACA13CA0071DDCC /* InfoTests.swift */; }; 28F596A11ACA13CA0071DDCC /* InfoTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28F596A01ACA13CA0071DDCC /* InfoTests.swift */; };
28F657EA1ABFCA7A00A608BD /* LiveAccountTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FA4363B1ABB8448008031D1 /* LiveAccountTest.swift */; }; 28F657EA1ABFCA7A00A608BD /* LiveAccountTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FA4363B1ABB8448008031D1 /* LiveAccountTest.swift */; };
28FDFF0C1C1F725800840F86 /* SeparatorTableCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28FDFF0B1C1F725800840F86 /* SeparatorTableCell.swift */; }; 28FDFF0C1C1F725800840F86 /* SeparatorTableCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28FDFF0B1C1F725800840F86 /* SeparatorTableCell.swift */; };
2979623922DF695E00604955 /* Onboarding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2979623822DF695E00604955 /* Onboarding.swift */; };
2979624322DF697900604955 /* OnboardingBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 2979624222DF697900604955 /* OnboardingBridge.m */; };
2C28F96C201B2D4C00ABA8A5 /* MailAppSettingsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C28F96B201B2D4C00ABA8A5 /* MailAppSettingsTests.swift */; }; 2C28F96C201B2D4C00ABA8A5 /* MailAppSettingsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C28F96B201B2D4C00ABA8A5 /* MailAppSettingsTests.swift */; };
2C2A5EF41E68469500F02659 /* PrivateBrowsingTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C2A5EF31E68469500F02659 /* PrivateBrowsingTest.swift */; }; 2C2A5EF41E68469500F02659 /* PrivateBrowsingTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C2A5EF31E68469500F02659 /* PrivateBrowsingTest.swift */; };
2C2A91291FA2410D002E36BD /* HistoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C2A91281FA2410D002E36BD /* HistoryTests.swift */; }; 2C2A91291FA2410D002E36BD /* HistoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C2A91281FA2410D002E36BD /* HistoryTests.swift */; };
@@ -1668,6 +1670,8 @@
28ED02281B262E0A003948B2 /* IndependentRecordSynchronizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = IndependentRecordSynchronizer.swift; path = Synchronizers/IndependentRecordSynchronizer.swift; sourceTree = "<group>"; }; 28ED02281B262E0A003948B2 /* IndependentRecordSynchronizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = IndependentRecordSynchronizer.swift; path = Synchronizers/IndependentRecordSynchronizer.swift; sourceTree = "<group>"; };
28F596A01ACA13CA0071DDCC /* InfoTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = InfoTests.swift; path = SyncTests/InfoTests.swift; sourceTree = "<group>"; }; 28F596A01ACA13CA0071DDCC /* InfoTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = InfoTests.swift; path = SyncTests/InfoTests.swift; sourceTree = "<group>"; };
28FDFF0B1C1F725800840F86 /* SeparatorTableCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SeparatorTableCell.swift; sourceTree = "<group>"; }; 28FDFF0B1C1F725800840F86 /* SeparatorTableCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SeparatorTableCell.swift; sourceTree = "<group>"; };
2979623822DF695E00604955 /* Onboarding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Onboarding.swift; sourceTree = "<group>"; };
2979624222DF697900604955 /* OnboardingBridge.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OnboardingBridge.m; sourceTree = "<group>"; };
2C28F96B201B2D4C00ABA8A5 /* MailAppSettingsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MailAppSettingsTests.swift; sourceTree = "<group>"; }; 2C28F96B201B2D4C00ABA8A5 /* MailAppSettingsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MailAppSettingsTests.swift; sourceTree = "<group>"; };
2C2A5EF31E68469500F02659 /* PrivateBrowsingTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PrivateBrowsingTest.swift; sourceTree = "<group>"; }; 2C2A5EF31E68469500F02659 /* PrivateBrowsingTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PrivateBrowsingTest.swift; sourceTree = "<group>"; };
2C2A91281FA2410D002E36BD /* HistoryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoryTests.swift; sourceTree = "<group>"; }; 2C2A91281FA2410D002E36BD /* HistoryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoryTests.swift; sourceTree = "<group>"; };
@@ -3518,6 +3522,8 @@
children = ( children = (
4F30F4F42051670C0049E4F6 /* AutoCompletion.swift */, 4F30F4F42051670C0049E4F6 /* AutoCompletion.swift */,
4F30F4F52051670C0049E4F6 /* AutoCompletionBridge.m */, 4F30F4F52051670C0049E4F6 /* AutoCompletionBridge.m */,
2979623822DF695E00604955 /* Onboarding.swift */,
2979624222DF697900604955 /* OnboardingBridge.m */,
4F30F4F62051670C0049E4F6 /* BrowserActions.swift */, 4F30F4F62051670C0049E4F6 /* BrowserActions.swift */,
4F30F4F72051670C0049E4F6 /* BrowserActionsBridge.m */, 4F30F4F72051670C0049E4F6 /* BrowserActionsBridge.m */,
4F30F4F82051670C0049E4F6 /* Crypto.swift */, 4F30F4F82051670C0049E4F6 /* Crypto.swift */,
@@ -6935,6 +6941,7 @@
E68AEDB01B18F81A00133D99 /* SwipeAnimator.swift in Sources */, E68AEDB01B18F81A00133D99 /* SwipeAnimator.swift in Sources */,
AFA1DE0C2088BE0500B27B8A /* BlockListFileManager.swift in Sources */, AFA1DE0C2088BE0500B27B8A /* BlockListFileManager.swift in Sources */,
1E23E61D22258D0B0004FAAF /* LegacyTelemetryHelper.swift in Sources */, 1E23E61D22258D0B0004FAAF /* LegacyTelemetryHelper.swift in Sources */,
2979624322DF697900604955 /* OnboardingBridge.m in Sources */,
4F30F50A2051670C0049E4F6 /* BrowserActions.swift in Sources */, 4F30F50A2051670C0049E4F6 /* BrowserActions.swift in Sources */,
1E2C435C21F89E8100891FB2 /* LumenDarkTheme.swift in Sources */, 1E2C435C21F89E8100891FB2 /* LumenDarkTheme.swift in Sources */,
3BF56D271CDBBE1F00AC4D75 /* SimpleToast.swift in Sources */, 3BF56D271CDBBE1F00AC4D75 /* SimpleToast.swift in Sources */,
@@ -7046,6 +7053,7 @@
4FE43F5B221EE96D00045527 /* WelcomeView.swift in Sources */, 4FE43F5B221EE96D00045527 /* WelcomeView.swift in Sources */,
1E3CBC152057D83700898B05 /* CliqzAppSettingsTableViewController.swift in Sources */, 1E3CBC152057D83700898B05 /* CliqzAppSettingsTableViewController.swift in Sources */,
D04CD718215EBD85004FF5B0 /* SettingsLoadingView.swift in Sources */, D04CD718215EBD85004FF5B0 /* SettingsLoadingView.swift in Sources */,
2979623922DF695E00604955 /* Onboarding.swift in Sources */,
D04CD74C216CF86B004FF5B0 /* InstructionsViewController.swift in Sources */, D04CD74C216CF86B004FF5B0 /* InstructionsViewController.swift in Sources */,
E49943F51AE6879C00BF9DE4 /* IntroViewController.swift in Sources */, E49943F51AE6879C00BF9DE4 /* IntroViewController.swift in Sources */,
); );
@@ -31,7 +31,7 @@ open class Engine {
let jsCodeLocation = Bundle.main.url(forResource: "jsengine.bundle", withExtension: "js") let jsCodeLocation = Bundle.main.url(forResource: "jsengine.bundle", withExtension: "js")
#endif #endif


rootView = RCTRootView( bundleURL: jsCodeLocation, moduleName: "ExtensionApp", initialProperties: nil, launchOptions: nil ) rootView = RCTRootView( bundleURL: jsCodeLocation, moduleName: "ExtensionApp", initialProperties: ["showSearchOnboarding": true], launchOptions: nil )
bridge = rootView.bridge bridge = rootView.bridge
//ConnectManager.sharedInstance.refresh() //ConnectManager.sharedInstance.refresh()
} }
@@ -59,7 +59,8 @@ class JSBridge : RCTEventEmitter {
} }


override open func supportedEvents() -> [String]! { override open func supportedEvents() -> [String]! {
return ["callAction", "publishEvent"] // TODO chrmod: clean native bridge
return ["action", "callAction", "publishEvent"]
} }


override open func constantsToExport() -> [AnyHashable : Any]! { override open func constantsToExport() -> [AnyHashable : Any]! {
@@ -118,7 +119,7 @@ class JSBridge : RCTEventEmitter {
self.eventCallbacks[actionId] = callback self.eventCallbacks[actionId] = callback
} }
// only send event - callback is handled in action reply // only send event - callback is handled in action reply
self.sendEvent(withName: "callAction", body: ["id": actionId, "action": functionName, "args": args]) self.sendEvent(withName: "action", body: ["id": actionId, "action": functionName, "args": args])


} }


@@ -11,13 +11,14 @@
#import <React/RCTViewManager.h> #import <React/RCTViewManager.h>


@interface NativeDrawable : RCTViewManager @interface NativeDrawable : RCTViewManager
@property BOOL hasTint;
@end @end


@implementation NativeDrawable @implementation NativeDrawable


RCT_EXPORT_MODULE() RCT_EXPORT_MODULE()


- (UIView *)view - (UIImageView *)view
{ {
UIImageView* imageView = [[UIImageView alloc] init]; UIImageView* imageView = [[UIImageView alloc] init];
[imageView setContentMode:UIViewContentModeScaleAspectFit]; [imageView setContentMode:UIViewContentModeScaleAspectFit];
@@ -30,6 +31,7 @@ - (UIView *)view
if (color != nil) { if (color != nil) {
view.image = [view.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; view.image = [view.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[view setTintColor: color]; [view setTintColor: color];
[self setHasTint:YES];
} }
else { else {
NSLog(@"color %@ is not valid", json); NSLog(@"color %@ is not valid", json);
@@ -41,6 +43,10 @@ - (UIView *)view
NSString *imageName = (NSString*)json; NSString *imageName = (NSString*)json;
if (imageName != nil) { if (imageName != nil) {
UIImage* image = [UIImage imageNamed:imageName]; UIImage* image = [UIImage imageNamed:imageName];
if (self.hasTint) {
image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
}

if (image != nil) { if (image != nil) {
[view setImage:image]; [view setImage:image];
} }
@@ -0,0 +1,27 @@
//
// Onboarding.swift
// Client
//
// Created by Khaled Tantawy on 17.07.19.
// Copyright © 2019 Cliqz. All rights reserved.
//
import React

@objc(Onboarding)
class Onboarding: RCTEventEmitter {

override static func requiresMainQueueSetup() -> Bool {
return false
}

@objc(tryLumenSearch:)
func tryLumenSearch(accepted: Bool) {
debugPrint("tryLumenSearch -- \(accepted)")
if accepted {
// TODO: PK this is try now case. Change Lumen to default search engine. UI will be handled by extenstion
} else {
// TODO: PK close cliqz search and open queary with default search engine
}
}
}
@@ -0,0 +1,15 @@
//
// OnboardingBridge.m
// Client
//
// Created by Khaled Tantawy on 17.07.19.
// Copyright © 2019 Cliqz. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <React/RCTBridgeModule.h>
@interface RCT_EXTERN_MODULE(Onboarding, NSObject)
RCT_EXTERN_METHOD(tryLumenSearch:(BOOL) accepted)
@end


@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "bing@1x.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "bing@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "bing@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "ddg@1x.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ddg@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ddg@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "google@1x.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "google@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "google@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -58,14 +58,9 @@ brew install carthage
4. Install Ruby `bundler`: 4. Install Ruby `bundler`:
```sh ```sh
sudo gem install bundler sudo gem install bundler
bundle install
```
5. Install [cocoadpods](https://cocoapods.org/) version **1.5.3**
```shell
sudo gem install cocoapods -v 1.5.3
``` ```
6. Fork the repository https://github.com/ghostery/browser-ios from GitHub UI 5. Fork the repository https://github.com/ghostery/browser-ios from GitHub UI
7. Clone the forked repository + add upstream remote: 6. Clone the forked repository + add upstream remote:
```shell ```shell
git clone https://github.com/YOUR_USERNAME/ghostery-ios git clone https://github.com/YOUR_USERNAME/ghostery-ios
cd ghostery-ios cd ghostery-ios
@@ -74,18 +69,19 @@ git fetch upstream
git checkout upstream/master git checkout upstream/master
git checkout -b my-working-branch git checkout -b my-working-branch
``` ```
8. Pull in the project dependencies: 7. Pull in the project dependencies:
```shell ```shell
sh ./bootstrap.sh sh ./bootstrap.sh
npm ci npm run bundle-ghostery
npm run bundle-lumen # Or for Cliqz: npm run bundle-cliqz
# Or for Ghostery: npm run bundle-ghostery # Or for Lumen: npm run bundle-lumen
rm -rf Pods rm -rf Pods
bundle install
bundle exec pod install bundle exec pod install
npm run postinstall npm run postinstall
``` ```
9. Open `Client.xcworkspace` in Xcode. 8. Open `Client.xcworkspace` in Xcode.
10. Build the `Fennec` scheme in Xcode. 9. Build the `Ghostery`/`Cliqz`/`Lumen` scheme in Xcode.


Note: When you run `bundle install`, you might get following error `An error occurred while installing unf_ext (0.0.7.5), and Bundler cannot continue.`. Above error happens with ruby 2.5.1. Just make sure to use 2.5.3 ruby version `rvm use 2.5.3` and problem will be fixed. Note: When you run `bundle install`, you might get following error `An error occurred while installing unf_ext (0.0.7.5), and Bundler cannot continue.`. Above error happens with ruby 2.5.1. Just make sure to use 2.5.3 ruby version `rvm use 2.5.3` and problem will be fixed.


@@ -0,0 +1,25 @@
import { NativeModules } from 'react-native';
import console from 'browser-core-lumen-ios/build/modules/core/console';

let translations;

export default function t(key) {
if (!translations) {
const locale = NativeModules.LocaleConstants.lang;
switch (locale) {
case 'de':
translations = require('./localization/de.json');
break;
default:
translations = require('./localization/en.json');
}
}
const translation = translations[key];

if (!translation) {
console.warn(`Cannot find translation for key "${key}"`);
return key;
}

return translation.message;
}
@@ -0,0 +1,35 @@
{
"search_no_results": {
"message": "KEINE TREFFER GEFUNDEN"
},
"search_footer": {
"message": "DIESE SUCHANFRAGE IST ANONYM"
},
"search_alternative_search_engines_info": {
"message": "Lumen Suche verlassen?"
},
"onboarding_title": {
"message": "Neu: Anonyme Suche"
},
"onboarding_description_line1": {
"message": "Jetzt aktivieren um anonym zu suchen."
},
"onboarding_description_line2": {
"message": "Dies kann jederzeit in den Einstellungen geändert werden."
},
"onboarding_action_accept": {
"message": "AUSPROBIEREN"
},
"onboarding_action_reject": {
"message": "NEIN, DANKE"
},
"onboarding_result_with_query": {
"message": "SUCHE AKTIVIERT"
},
"onboarding_result_without_query": {
"message": "EINFACH LOSTIPPEN"
},
"test": {
"message": "de"
}
}
@@ -0,0 +1,35 @@
{
"search_no_results": {
"message": "NO RESULTS FOUND"
},
"search_footer": {
"message": "THIS SEARCH QUERY IS ANONYMOUS"
},
"search_alternative_search_engines_info": {
"message": "Leave Lumen Search?"
},
"onboarding_title": {
"message": "New: Anonymous Search"
},
"onboarding_description_line1": {
"message": "Activate now to search anonymously."
},
"onboarding_description_line2": {
"message": "This can be changed anytime in settings."
},
"onboarding_action_accept": {
"message": "TRY NOW"
},
"onboarding_action_reject": {
"message": "NO, THANKS"
},
"onboarding_result_with_query": {
"message": "SEARCH ACTIVATED"
},
"onboarding_result_without_query": {
"message": "START TYPING"
},
"test": {
"message": "de"
}
}

0 comments on commit bf83028

Please sign in to comment.