Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Made quick action work also. Added icon and display text for it

Michael Rademaker027da5af957a
diff --git a/console/generic_app/android/app/src/main/res/drawable/ic_settings.xml b/console/generic_app/android/app/src/main/res/drawable/ic_settings.xml
new file mode 100644
index 000000000..697f873e0
--- /dev/null
+++ b/console/generic_app/android/app/src/main/res/drawable/ic_settings.xml
@@ -0,0 +1,5 @@
+<vector android:height="24dp" android:tint="#4C4C4C"
+ android:viewportHeight="24" android:viewportWidth="24"
+ android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="#4C4C4C" android:pathData="M19.14,12.94c0.04,-0.3 0.06,-0.61 0.06,-0.94c0,-0.32 -0.02,-0.64 -0.07,-0.94l2.03,-1.58c0.18,-0.14 0.23,-0.41 0.12,-0.61l-1.92,-3.32c-0.12,-0.22 -0.37,-0.29 -0.59,-0.22l-2.39,0.96c-0.5,-0.38 -1.03,-0.7 -1.62,-0.94L14.4,2.81c-0.04,-0.24 -0.24,-0.41 -0.48,-0.41h-3.84c-0.24,0 -0.43,0.17 -0.47,0.41L9.25,5.35C8.66,5.59 8.12,5.92 7.63,6.29L5.24,5.33c-0.22,-0.08 -0.47,0 -0.59,0.22L2.74,8.87C2.62,9.08 2.66,9.34 2.86,9.48l2.03,1.58C4.84,11.36 4.8,11.69 4.8,12s0.02,0.64 0.07,0.94l-2.03,1.58c-0.18,0.14 -0.23,0.41 -0.12,0.61l1.92,3.32c0.12,0.22 0.37,0.29 0.59,0.22l2.39,-0.96c0.5,0.38 1.03,0.7 1.62,0.94l0.36,2.54c0.05,0.24 0.24,0.41 0.48,0.41h3.84c0.24,0 0.44,-0.17 0.47,-0.41l0.36,-2.54c0.59,-0.24 1.13,-0.56 1.62,-0.94l2.39,0.96c0.22,0.08 0.47,0 0.59,-0.22l1.92,-3.32c0.12,-0.22 0.07,-0.47 -0.12,-0.61L19.14,12.94zM12,15.6c-1.98,0 -3.6,-1.62 -3.6,-3.6s1.62,-3.6 3.6,-3.6s3.6,1.62 3.6,3.6S13.98,15.6 12,15.6z"/>
+</vector>
diff --git a/console/generic_app/android/app/src/main/res/values-nl/strings.xml b/console/generic_app/android/app/src/main/res/values-nl/strings.xml
new file mode 100644
index 000000000..8ad7e21bf
--- /dev/null
+++ b/console/generic_app/android/app/src/main/res/values-nl/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="starting_page">Project veranderen</string>
+</resources>
\ No newline at end of file
diff --git a/console/generic_app/android/app/src/main/res/values/strings.xml b/console/generic_app/android/app/src/main/res/values/strings.xml
new file mode 100644
index 000000000..8d06dc15c
--- /dev/null
+++ b/console/generic_app/android/app/src/main/res/values/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="starting_page">Change project</string>
+</resources>
\ No newline at end of file
diff --git a/console/generic_app/ios/Podfile.lock b/console/generic_app/ios/Podfile.lock
index e06de97e0..5da8d9659 100644
--- a/console/generic_app/ios/Podfile.lock
+++ b/console/generic_app/ios/Podfile.lock
@@ -93,6 +93,8 @@ PODS:
- Flutter
- PromisesObjC (1.2.8)
- Protobuf (3.11.4)
+ - quick_actions (0.0.1):
+ - Flutter
- shared_preferences (0.0.1):
- Flutter
- shared_preferences_macos (0.0.1):
@@ -107,6 +109,7 @@ DEPENDENCIES:
- Flutter (from `Flutter`)
- flutter_geofence (from `.symlinks/plugins/flutter_geofence/ios`)
- permission_handler (from `.symlinks/plugins/permission_handler/ios`)
+ - quick_actions (from `.symlinks/plugins/quick_actions/ios`)
- shared_preferences (from `.symlinks/plugins/shared_preferences/ios`)
- shared_preferences_macos (from `.symlinks/plugins/shared_preferences_macos/ios`)
- shared_preferences_web (from `.symlinks/plugins/shared_preferences_web/ios`)
@@ -140,6 +143,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/flutter_geofence/ios"
permission_handler:
:path: ".symlinks/plugins/permission_handler/ios"
+ quick_actions:
+ :path: ".symlinks/plugins/quick_actions/ios"
shared_preferences:
:path: ".symlinks/plugins/shared_preferences/ios"
shared_preferences_macos:
@@ -170,6 +175,7 @@ SPEC CHECKSUMS:
permission_handler: eac8e15b4a1a3fba55b761d19f3f4e6b005d15b6
PromisesObjC: c119f3cd559f50b7ae681fa59dc1acd19173b7e6
Protobuf: 176220c526ad8bd09ab1fb40a978eac3fef665f7
+ quick_actions: 6cb2390c4dab0e737c94573c27e18d9666710720
shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d
shared_preferences_macos: f3f29b71ccbb56bf40c9dd6396c9acf15e214087
shared_preferences_web: 141cce0c3ed1a1c5bf2a0e44f52d31eeb66e5ea9
diff --git a/console/generic_app/ios/Runner.xcodeproj/project.pbxproj b/console/generic_app/ios/Runner.xcodeproj/project.pbxproj
index 9ae11962b..363f4b86e 100644
--- a/console/generic_app/ios/Runner.xcodeproj/project.pbxproj
+++ b/console/generic_app/ios/Runner.xcodeproj/project.pbxproj
@@ -275,6 +275,7 @@
"${BUILT_PRODUCTS_DIR}/Protobuf/protobuf.framework",
"${BUILT_PRODUCTS_DIR}/flutter_geofence/flutter_geofence.framework",
"${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework",
+ "${BUILT_PRODUCTS_DIR}/quick_actions/quick_actions.framework",
"${BUILT_PRODUCTS_DIR}/shared_preferences/shared_preferences.framework",
"${BUILT_PRODUCTS_DIR}/webview_flutter/webview_flutter.framework",
);
@@ -286,6 +287,7 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/protobuf.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_geofence.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nanopb.framework",
+ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/quick_actions.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/webview_flutter.framework",
);
diff --git a/console/generic_app/ios/Runner/AppDelegate.swift b/console/generic_app/ios/Runner/AppDelegate.swift
index 0f60691a8..baee1e57c 100644
--- a/console/generic_app/ios/Runner/AppDelegate.swift
+++ b/console/generic_app/ios/Runner/AppDelegate.swift
@@ -3,14 +3,22 @@ import Flutter
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
- override func application(
- _ application: UIApplication,
- didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
- ) -> Bool {
- GeneratedPluginRegistrant.register(with: self)
-
- UNUserNotificationCenter.current().delegate = self;
+ override func application(
+ _ application: UIApplication,
+ didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
+ ) -> Bool {
+ GeneratedPluginRegistrant.register(with: self)
+
+ UNUserNotificationCenter.current().delegate = self;
+
+ return super.application(application, didFinishLaunchingWithOptions: launchOptions)
+ }
- return super.application(application, didFinishLaunchingWithOptions: launchOptions)
- }
+ @available(iOS 9.0, *)
+ override func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
+ let controller = window.rootViewController as? FlutterViewController
+
+ let channel = FlutterMethodChannel(name: "plugins.flutter.io/quick_actions", binaryMessenger: controller! as! FlutterBinaryMessenger)
+ channel.invokeMethod("launch", arguments: shortcutItem.type)
+ }
}
diff --git a/console/generic_app/ios/Runner/Assets.xcassets/ic_settings.imageset/Contents.json b/console/generic_app/ios/Runner/Assets.xcassets/ic_settings.imageset/Contents.json
new file mode 100644
index 000000000..679782945
--- /dev/null
+++ b/console/generic_app/ios/Runner/Assets.xcassets/ic_settings.imageset/Contents.json
@@ -0,0 +1,21 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x"
+ },
+ {
+ "filename" : "cog.png",
+ "idiom" : "universal",
+ "scale" : "3x"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ }
+}
diff --git a/console/generic_app/ios/Runner/Assets.xcassets/ic_settings.imageset/cog.png b/console/generic_app/ios/Runner/Assets.xcassets/ic_settings.imageset/cog.png
new file mode 100644
index 000000000..7d7d8c246
Binary files /dev/null and b/console/generic_app/ios/Runner/Assets.xcassets/ic_settings.imageset/cog.png differ
diff --git a/console/generic_app/lib/config/CurrentConsoleAppConfig.dart b/console/generic_app/lib/config/CurrentConsoleAppConfig.dart
index 006fc08f9..ab7394ef0 100644
--- a/console/generic_app/lib/config/CurrentConsoleAppConfig.dart
+++ b/console/generic_app/lib/config/CurrentConsoleAppConfig.dart
@@ -18,8 +18,7 @@ class CurrentConsoleAppConfig {
this._primaryColor = appConfig.primaryColor;
this._secondaryColor = appConfig.secondaryColor;
this._links = appConfig.links;
- this._project;
- this._realm;
+ this._project = project;
}
String _realm;
diff --git a/console/generic_app/lib/generated/intl/messages_en.dart b/console/generic_app/lib/generated/intl/messages_en.dart
index 8244af1d8..b379a918b 100644
--- a/console/generic_app/lib/generated/intl/messages_en.dart
+++ b/console/generic_app/lib/generated/intl/messages_en.dart
@@ -24,7 +24,6 @@ class MessageLookup extends MessageLookupByLibrary {
"connect" : MessageLookupByLibrary.simpleMessage("Connect"),
"connectToYourApplication" : MessageLookupByLibrary.simpleMessage("Connect to your application"),
"project" : MessageLookupByLibrary.simpleMessage("Project"),
- "realm" : MessageLookupByLibrary.simpleMessage("Realm"),
- "startingPage" : MessageLookupByLibrary.simpleMessage("Starting page")
+ "realm" : MessageLookupByLibrary.simpleMessage("Realm")
};
}
diff --git a/console/generic_app/lib/generated/intl/messages_nl.dart b/console/generic_app/lib/generated/intl/messages_nl.dart
index bfd46de46..4120a7c12 100644
--- a/console/generic_app/lib/generated/intl/messages_nl.dart
+++ b/console/generic_app/lib/generated/intl/messages_nl.dart
@@ -24,7 +24,6 @@ class MessageLookup extends MessageLookupByLibrary {
"connect" : MessageLookupByLibrary.simpleMessage("Verbind"),
"connectToYourApplication" : MessageLookupByLibrary.simpleMessage("Verbind met jouw applicatie"),
"project" : MessageLookupByLibrary.simpleMessage("Project"),
- "realm" : MessageLookupByLibrary.simpleMessage("Realm"),
- "startingPage" : MessageLookupByLibrary.simpleMessage("Begin pagina")
+ "realm" : MessageLookupByLibrary.simpleMessage("Realm")
};
}
diff --git a/console/generic_app/lib/generated/l10n.dart b/console/generic_app/lib/generated/l10n.dart
index d6c67ceb3..6c716a701 100644
--- a/console/generic_app/lib/generated/l10n.dart
+++ b/console/generic_app/lib/generated/l10n.dart
@@ -73,15 +73,7 @@ class S {
);
}
- /// `Starting page`
- String get startingPage {
- return Intl.message(
- 'Starting page',
- name: 'startingPage',
- desc: '',
- args: [],
- );
- }
+ // skipped getter for the 'Change project' key
}
class AppLocalizationDelegate extends LocalizationsDelegate<S> {
diff --git a/console/generic_app/lib/l10n/intl_en.arb b/console/generic_app/lib/l10n/intl_en.arb
index 083c1419b..9757a4769 100644
--- a/console/generic_app/lib/l10n/intl_en.arb
+++ b/console/generic_app/lib/l10n/intl_en.arb
@@ -3,5 +3,5 @@
"project": "Project",
"realm": "Realm",
"connect": "Connect",
- "startingPage": "Starting page"
+ "Change project": "Change project"
}
\ No newline at end of file
diff --git a/console/generic_app/lib/l10n/intl_nl.arb b/console/generic_app/lib/l10n/intl_nl.arb
index 033395d55..6d60922b2 100644
--- a/console/generic_app/lib/l10n/intl_nl.arb
+++ b/console/generic_app/lib/l10n/intl_nl.arb
@@ -3,5 +3,5 @@
"project": "Project",
"realm": "Realm",
"connect": "Verbind",
- "startingPage": "Begin pagina"
+ "Change project": "Project wisselen"
}
\ No newline at end of file
diff --git a/console/generic_app/lib/main.dart b/console/generic_app/lib/main.dart
index 5740ccd61..ead0dd6ed 100644
--- a/console/generic_app/lib/main.dart
+++ b/console/generic_app/lib/main.dart
@@ -12,10 +12,12 @@ void main() {
});
}
class ORApp extends StatelessWidget {
+ static final GlobalKey<NavigatorState> navigatorKey = new GlobalKey<NavigatorState>();
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
+ navigatorKey: navigatorKey,
title: 'OR App',
theme: ThemeData(
primarySwatch: Colors.green,
diff --git a/console/generic_app/lib/ui/ProjectPage.dart b/console/generic_app/lib/ui/ProjectPage.dart
index 908795984..25d0ff9be 100644
--- a/console/generic_app/lib/ui/ProjectPage.dart
+++ b/console/generic_app/lib/ui/ProjectPage.dart
@@ -77,7 +77,7 @@ class _ProjectPageState extends State<ProjectPage> {
),
textInputAction: TextInputAction.next,
onChanged: (inputText) {
- _projectName = inputText;
+ _projectName = inputText.trim();
},
onSubmitted: (inputText) {
FocusScope.of(context).nextFocus();
@@ -99,7 +99,7 @@ class _ProjectPageState extends State<ProjectPage> {
),
textInputAction: TextInputAction.done,
onChanged: (inputText) {
- _realmName = inputText;
+ _realmName = inputText.trim();
},
onSubmitted: (inputText) {
_getConsoleAppConfig();
diff --git a/console/generic_app/lib/ui/SplashPage.dart b/console/generic_app/lib/ui/SplashPage.dart
index c5f71dd6a..68eba70d6 100644
--- a/console/generic_app/lib/ui/SplashPage.dart
+++ b/console/generic_app/lib/ui/SplashPage.dart
@@ -1,16 +1,15 @@
import 'dart:async';
-import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:generic_app/config/CurrentConsoleAppConfig.dart';
-import 'package:generic_app/generated/l10n.dart';
import 'package:generic_app/models/ConsoleAppConfig.dart';
import 'package:generic_app/network/ApiManager.dart';
import 'package:generic_app/ui/ProjectPage.dart';
import 'package:quick_actions/quick_actions.dart';
import 'package:shared_preferences/shared_preferences.dart';
+import '../main.dart';
import 'WebViewPage.dart';
class SplashPage extends StatefulWidget {
@@ -25,53 +24,45 @@ class _SplashPageState extends State<SplashPage> {
String _projectName;
String _realmName;
- String _shortCut;
-
@override
void initState() {
final QuickActions quickActions = QuickActions();
quickActions.setShortcutItems(<ShortcutItem>[
const ShortcutItem(
- type: 'project_page', localizedTitle: 'startingPage', icon: 'home'),
+ type: 'starting_page',
+ localizedTitle: 'Change project',
+ icon: 'ic_settings'),
]);
- quickActions.initialize((String shortcutType) {
- _shortCut = shortcutType;
+ quickActions.initialize((String shortcutType) async {
+ if (shortcutType == 'starting_page') {
+ ORApp.navigatorKey.currentState.pushReplacement(MaterialPageRoute(builder: (context) => ProjectPage()));
+ }
});
-
super.initState();
}
@override
Widget build(BuildContext context) {
- if (_shortCut != null && _shortCut == 'startingPage') {
- Future.delayed(
- Duration(seconds: 3),
- () => Navigator.pushReplacement(
- context, MaterialPageRoute(builder: (context) => ProjectPage())));
- return _splashIcon();
- } else {
- return new FutureBuilder(
- future: Future.delayed(Duration(seconds: 3), _getProjectData),
- builder: (BuildContext context, AsyncSnapshot snapshot) {
- if (snapshot.hasData) {
- Future.delayed(Duration.zero, () {
- if (snapshot.data) {
- Navigator.pushReplacement(
- context,
- MaterialPageRoute(
- builder: (context) => WebViewPage(
- initialUrl:
- CurrentConsoleAppConfig.instance.url)));
- } else {
- Navigator.pushReplacement(context,
- MaterialPageRoute(builder: (context) => ProjectPage()));
- }
- });
- }
- return _splashIcon();
- });
- }
+ return new FutureBuilder(
+ future: Future.delayed(Duration(seconds: 3), _getProjectData),
+ builder: (BuildContext context, AsyncSnapshot snapshot) {
+ if (snapshot.hasData) {
+ Future.delayed(Duration.zero, () {
+ if (snapshot.data) {
+ Navigator.pushReplacement(
+ context,
+ MaterialPageRoute(
+ builder: (context) => WebViewPage(
+ initialUrl: CurrentConsoleAppConfig.instance.url)));
+ } else {
+ Navigator.pushReplacement(context,
+ MaterialPageRoute(builder: (context) => ProjectPage()));
+ }
+ });
+ }
+ return _splashIcon();
+ });
}
Widget _splashIcon() {
@@ -79,7 +70,7 @@ class _SplashPageState extends State<SplashPage> {
body: Align(
alignment: Alignment.center,
child: Container(
- padding: EdgeInsets.all(50),
+ padding: EdgeInsets.all(100),
child: Image.asset('assets/images/or_splash.png',
fit: BoxFit.contain),
)));
@@ -90,16 +81,17 @@ class _SplashPageState extends State<SplashPage> {
_projectName = _sharedPreferences.getString("project");
_realmName = _sharedPreferences.getString("realm");
- bool hasData = _projectName != null && _realmName != null && _shortCut == null;
+ bool hasData = _projectName != null && _realmName != null;
if (hasData) {
hasData = await _getConsoleAppConfig();
}
- return hasData && _shortCut == null;
+ return hasData;
}
Future<bool> _getConsoleAppConfig() async {
- var apiManager = new ApiManager("https://$_projectName.openremote.io/api/$_realmName");
+ var apiManager =
+ new ApiManager("https://$_projectName.openremote.io/api/$_realmName");
return apiManager
.get(["app", "config"], ConsoleAppConfig.fromJson).then((value) {
CurrentConsoleAppConfig.instance.updateConfig(value, _projectName);
diff --git a/console/generic_app/pubspec.yaml b/console/generic_app/pubspec.yaml
index 758bf11af..4b2e5d760 100644
--- a/console/generic_app/pubspec.yaml
+++ b/console/generic_app/pubspec.yaml
@@ -11,7 +11,7 @@ description: Generic app of OpenRemote
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
-version: 1.0.0+3
+version: 1.0.0+4
environment:
sdk: ">=2.2.0 <3.0.0"