From 7228c87b0cf70521374d8254cebc2c41e8873c84 Mon Sep 17 00:00:00 2001 From: Javier Gamarra Date: Fri, 17 Jul 2015 11:49:20 +0200 Subject: [PATCH 001/365] LSR-291 delete duplication in gradle files --- android/library/build.gradle | 133 +++++++++++++----- android/library/core/build.gradle | 98 ------------- .../samples/addbookmarkscreenlet/build.gradle | 111 +-------------- android/viewsets/material/build.gradle | 109 +------------- android/viewsets/westeros/build.gradle | 108 +------------- 5 files changed, 102 insertions(+), 457 deletions(-) diff --git a/android/library/build.gradle b/android/library/build.gradle index 0ba7b999aa..08d737374e 100644 --- a/android/library/build.gradle +++ b/android/library/build.gradle @@ -1,26 +1,21 @@ -apply plugin: 'maven' - buildscript { repositories { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.2.3' + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2' classpath 'com.github.dcendents:android-maven-plugin:1.2' - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0' } } subprojects { repositories { - mavenLocal() maven { url 'https://repository.liferay.com/nexus/content/groups/liferay-ce' } jcenter() - mavenCentral() } configurations { @@ -35,39 +30,103 @@ subprojects { formatter group: 'org.apache.ant', name: 'ant', version: '1.8.2' } +} -// task format(type: JavaExec) { -// main = 'com.liferay.portal.tools.sourceformatter.SourceFormatter' -// classpath = configurations.formatter -// workingDir = 'src' -// } -// -// task formatResources(type: JavaExec) { -// main = format.main -// classpath = format.classpath -// workingDir = 'res' -// } -// -// task wrapper(type: Wrapper) { -// gradleVersion = '2.2.1' -// } -// -// uploadArchives { -// repositories.mavenDeployer { -// def deployPath = file(getProperty('aar.deployPath')) -// repository(url: "file://${deployPath.absolutePath}") -// pom.project { -// groupId 'com.liferay.mobile' -// artifactId 'liferay-screens' -// version "0.3.2" -// } -// } -// } +subprojects { + version = '1.1.0.beta2' + group = 'com.liferay.mobile' -} -allprojects { - repositories { - jcenter() + buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.github.dcendents:android-maven-plugin:1.2' + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2' + } + } + + apply plugin: 'com.android.library' + apply plugin: 'maven' + apply plugin: 'com.jfrog.bintray' + apply plugin: 'com.github.dcendents.android-maven' + + def siteUrl = 'https://github.com/liferay/liferay-screens' + def gitUrl = 'https://github.com/liferay/liferay-screens.git' + + task sourcesJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + classifier = 'sources' + } + + task javadoc(type: Javadoc) { + source = android.sourceSets.main.java.srcDirs +// classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) + } + + task javadocJar(type: Jar, dependsOn: javadoc) { + classifier = 'javadoc' + from javadoc.destinationDir + } + + artifacts { + archives javadocJar + archives sourcesJar + } + + install { + repositories.mavenInstaller { + // This generates POM.xml with proper parameters + pom { + project { + packaging 'aar' + + // Add your description here + name 'Liferay Screens for Android includes the component (screenlets) library and a sample project.' + url siteUrl + + // Set your license + licenses { + license { + name 'The Apache Software License, Version 2.0' + url 'http://www.apache.org/licenses/LICENSE-2.0.txt' + } + } + developers { + developer { + id '1' + name 'Javier Gamarra' + email 'nhpatt@gmail.com' + } + } + scm { + connection gitUrl + developerConnection gitUrl + url siteUrl + + } + } + } + } + } + + Properties properties = new Properties() + properties.load(project.rootProject.file('local.properties').newDataInputStream()) + + bintray { + user = properties.getProperty("bintray.user") + key = properties.getProperty("bintray.apikey") + + configurations = ['archives'] + pkg { +// userOrg = 'liferay' + repo = "liferay-mobile" + name = project.archivesBaseName + websiteUrl = siteUrl + vcsUrl = gitUrl + licenses = ["LGPL-2.1"] + publish = true + } } } \ No newline at end of file diff --git a/android/library/core/build.gradle b/android/library/core/build.gradle index f490326316..04ace46f50 100644 --- a/android/library/core/build.gradle +++ b/android/library/core/build.gradle @@ -1,5 +1,4 @@ apply plugin: 'com.android.library' -apply plugin: 'maven' android { compileSdkVersion 22 @@ -34,7 +33,6 @@ repositories { } jcenter() - mavenCentral() } dependencies { @@ -54,100 +52,4 @@ dependencies { testCompile "org.robolectric:robolectric:3.0-rc2" testCompile 'org.mockito:mockito-core:1.9.5' -} - -version = '1.1.0' -group = 'com.liferay.mobile' - -project.archivesBaseName = 'liferay-screens' - -buildscript { - repositories { - jcenter() - } - dependencies { - classpath 'com.github.dcendents:android-maven-plugin:1.2' - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0' - } -} - -apply plugin: 'com.github.dcendents.android-maven' - -def siteUrl = 'https://github.com/liferay/liferay-screens' -def gitUrl = 'https://github.com/liferay/liferay-screens.git' - -install { - repositories.mavenInstaller { - // This generates POM.xml with proper parameters - pom { - project { - packaging 'aar' - - // Add your description here - name 'Liferay Screens for Android includes the component (screenlets) library and a sample project.' - url siteUrl - - // Set your license - licenses { - license { - name 'The Apache Software License, Version 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - } - } - developers { - developer { - id '1' - name 'Javier Gamarra' - email 'nhpatt@gmail.com' - } - } - scm { - connection gitUrl - developerConnection gitUrl - url siteUrl - - } - } - } - } -} - -task sourcesJar(type: Jar) { - from android.sourceSets.main.java.srcDirs - classifier = 'sources' -} - -task javadoc(type: Javadoc) { - source = android.sourceSets.main.java.srcDirs -// classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} -artifacts { - archives javadocJar - archives sourcesJar -} - -apply plugin: 'com.jfrog.bintray' - -Properties properties = new Properties() -properties.load(project.rootProject.file('local.properties').newDataInputStream()) - -bintray { - user = properties.getProperty("bintray.user") - key = properties.getProperty("bintray.apikey") - - configurations = ['archives'] - pkg { -// userOrg = 'liferay' - repo = "liferay-mobile" - name = "liferay-screens" - websiteUrl = siteUrl - vcsUrl = gitUrl - licenses = ["LGPL-2.1"] - publish = true - } } \ No newline at end of file diff --git a/android/samples/addbookmarkscreenlet/build.gradle b/android/samples/addbookmarkscreenlet/build.gradle index cf801e92ee..79a93f0def 100644 --- a/android/samples/addbookmarkscreenlet/build.gradle +++ b/android/samples/addbookmarkscreenlet/build.gradle @@ -1,15 +1,5 @@ apply plugin: 'com.android.library' -buildscript { - repositories { - mavenCentral() - } - - dependencies { - classpath 'com.android.tools.build:gradle:1.2.3' - } -} - android { compileSdkVersion 22 buildToolsVersion "22.0.1" @@ -20,6 +10,7 @@ android { versionCode 1 versionName "1.0" } + buildTypes { release { minifyEnabled false @@ -32,104 +23,4 @@ dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.2.0' compile project (':liferay-screens') -} - -repositories { - jcenter() -} - -version = '1.1.0' -group = 'com.liferay.mobile' - -project.archivesBaseName = 'addbookmarkscreenlet' - -buildscript { - repositories { - jcenter() - } - dependencies { - classpath 'com.github.dcendents:android-maven-plugin:1.2' - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0' - } -} - -apply plugin: 'com.github.dcendents.android-maven' - -def siteUrl = 'https://github.com/liferay/liferay-screens' -def gitUrl = 'https://github.com/liferay/liferay-screens.git' - -install { - repositories.mavenInstaller { - // This generates POM.xml with proper parameters - pom { - project { - packaging 'aar' - - // Add your description here - name 'Liferay Screens for Android includes the component (screenlets) library and a sample project.' - url siteUrl - - // Set your license - licenses { - license { - name 'The Apache Software License, Version 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - } - } - developers { - developer { - id '1' - name 'Javier Gamarra' - email 'nhpatt@gmail.com' - } - } - scm { - connection gitUrl - developerConnection gitUrl - url siteUrl - - } - } - } - } -} - -task sourcesJar(type: Jar) { - from android.sourceSets.main.java.srcDirs - classifier = 'sources' -} - -task javadoc(type: Javadoc) { - source = android.sourceSets.main.java.srcDirs -// classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} -artifacts { - archives javadocJar - archives sourcesJar -} - -apply plugin: 'com.jfrog.bintray' - -Properties properties = new Properties() -properties.load(project.rootProject.file('local.properties').newDataInputStream()) - -bintray { - user = properties.getProperty("bintray.user") - key = properties.getProperty("bintray.apikey") - - configurations = ['archives'] - pkg { -// userOrg = 'liferay' - repo = "liferay-mobile" - name = "addbookmarkscreenlet" - websiteUrl = siteUrl - vcsUrl = gitUrl - licenses = ["LGPL-2.1"] - publish = true - } } \ No newline at end of file diff --git a/android/viewsets/material/build.gradle b/android/viewsets/material/build.gradle index 193ca8c51d..13ad3bd185 100644 --- a/android/viewsets/material/build.gradle +++ b/android/viewsets/material/build.gradle @@ -19,117 +19,12 @@ android { } } -repositories { - maven { - url 'https://repository.liferay.com/nexus/content/groups/liferay-ce' - } - - jcenter() - mavenCentral() -} - dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:22.0.0' - compile 'com.android.support:recyclerview-v7:22.0.0' + compile 'com.android.support:appcompat-v7:22.2.0' + compile 'com.android.support:recyclerview-v7:22.2.0' compile('de.keyboardsurfer.android.widget:crouton:1.8.5@aar') { exclude group: 'com.google.android', module: 'support-v4' } compile project(':liferay-screens') -} - -version = '1.1.0' -group = 'com.liferay.mobile' - -project.archivesBaseName = 'liferay-material-viewset' - -buildscript { - repositories { - jcenter() - } - dependencies { - classpath 'com.github.dcendents:android-maven-plugin:1.2' - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0' - } -} - -apply plugin: 'com.github.dcendents.android-maven' - -def siteUrl = 'https://github.com/liferay/liferay-screens' -def gitUrl = 'https://github.com/liferay/liferay-screens.git' - -install { - repositories.mavenInstaller { - // This generates POM.xml with proper parameters - pom { - project { - packaging 'aar' - - // Add your description here - name 'Liferay Screens for Android includes the component (screenlets) library and a sample project.' - url siteUrl - - // Set your license - licenses { - license { - name 'The Apache Software License, Version 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - } - } - developers { - developer { - id '1' - name 'Javier Gamarra' - email 'nhpatt@gmail.com' - } - } - scm { - connection gitUrl - developerConnection gitUrl - url siteUrl - - } - } - } - } -} - -task sourcesJar(type: Jar) { - from android.sourceSets.main.java.srcDirs - classifier = 'sources' -} - -task javadoc(type: Javadoc) { - source = android.sourceSets.main.java.srcDirs -// classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} -artifacts { - archives javadocJar - archives sourcesJar -} - -apply plugin: 'com.jfrog.bintray' - -Properties properties = new Properties() -properties.load(project.rootProject.file('local.properties').newDataInputStream()) - -bintray { - user = properties.getProperty("bintray.user") - key = properties.getProperty("bintray.apikey") - - configurations = ['archives'] - pkg { -// userOrg = 'liferay' - repo = "liferay-mobile" - name = "liferay-material-viewset" - websiteUrl = siteUrl - vcsUrl = gitUrl - licenses = ["LGPL-2.1"] - publish = true - } } \ No newline at end of file diff --git a/android/viewsets/westeros/build.gradle b/android/viewsets/westeros/build.gradle index 93e0736ee0..c5c87fac71 100644 --- a/android/viewsets/westeros/build.gradle +++ b/android/viewsets/westeros/build.gradle @@ -10,6 +10,7 @@ android { versionCode 1 versionName "1.0" } + buildTypes { release { minifyEnabled false @@ -18,116 +19,13 @@ android { } } -repositories { - jcenter() - maven { - url "http://dl.bintray.com/nhpatt/maven" - } -} - dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:22.0.0' - compile 'com.android.support:recyclerview-v7:22.0.0' + compile 'com.android.support:appcompat-v7:22.2.0' + compile 'com.android.support:recyclerview-v7:22.2.0' compile('de.keyboardsurfer.android.widget:crouton:1.8.5@aar') { exclude group: 'com.google.android', module: 'support-v4' } compile "com.daimajia.swipelayout:library:1.1.9@aar" compile project(':liferay-screens') -} - -version = '1.1.0' -group = 'com.liferay.mobile' - -project.archivesBaseName = 'liferay-westeros-viewset' - -buildscript { - repositories { - jcenter() - } - dependencies { - classpath 'com.github.dcendents:android-maven-plugin:1.2' - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0' - } -} - -apply plugin: 'com.github.dcendents.android-maven' - -def siteUrl = 'https://github.com/liferay/liferay-screens' -def gitUrl = 'https://github.com/liferay/liferay-screens.git' - -install { - repositories.mavenInstaller { - // This generates POM.xml with proper parameters - pom { - project { - packaging 'aar' - - // Add your description here - name 'Liferay Screens for Android includes the component (screenlets) library and a sample project.' - url siteUrl - - // Set your license - licenses { - license { - name 'The Apache Software License, Version 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - } - } - developers { - developer { - id '1' - name 'Javier Gamarra' - email 'nhpatt@gmail.com' - } - } - scm { - connection gitUrl - developerConnection gitUrl - url siteUrl - - } - } - } - } -} - -task sourcesJar(type: Jar) { - from android.sourceSets.main.java.srcDirs - classifier = 'sources' -} - -task javadoc(type: Javadoc) { - source = android.sourceSets.main.java.srcDirs -// classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} -artifacts { - archives javadocJar - archives sourcesJar -} - -apply plugin: 'com.jfrog.bintray' - -Properties properties = new Properties() -properties.load(project.rootProject.file('local.properties').newDataInputStream()) - -bintray { - user = properties.getProperty("bintray.user") - key = properties.getProperty("bintray.apikey") - - configurations = ['archives'] - pkg { -// userOrg = 'liferay' - repo = "liferay-mobile" - name = "liferay-westeros-viewset" - websiteUrl = siteUrl - vcsUrl = gitUrl - licenses = ["LGPL-2.1"] - publish = true - } } \ No newline at end of file From cc6bae3e2177c3be2f977d274541d2472dde0bc2 Mon Sep 17 00:00:00 2001 From: Javier Gamarra Date: Fri, 17 Jul 2015 11:49:40 +0200 Subject: [PATCH 002/365] LSR-291 bump versions of gradle plugin and specify auth --- android/library/build.gradle | 1 + android/library/core/build.gradle | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/android/library/build.gradle b/android/library/build.gradle index 08d737374e..127828178d 100644 --- a/android/library/build.gradle +++ b/android/library/build.gradle @@ -3,6 +3,7 @@ buildscript { jcenter() } dependencies { + classpath 'com.android.tools.build:gradle:1.3.0-beta4' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2' classpath 'com.github.dcendents:android-maven-plugin:1.2' } diff --git a/android/library/core/build.gradle b/android/library/core/build.gradle index 04ace46f50..9c40121270 100644 --- a/android/library/core/build.gradle +++ b/android/library/core/build.gradle @@ -44,7 +44,7 @@ dependencies { compile 'de.greenrobot:eventbus:2.4.0' compile 'com.squareup.picasso:picasso:2.5.0' - compile group: 'com.liferay.mobile', name: 'liferay-android-oauth', version: '1.+' + compile group: 'com.liferay.mobile', name: 'liferay-android-oauth', version: '1.0.3' compile('de.keyboardsurfer.android.widget:crouton:1.8.5@aar') { exclude group: 'com.google.android', module: 'support-v4' } From 4d0d5a72eb7ee06dd991490a8a9352c9f333b3b7 Mon Sep 17 00:00:00 2001 From: Javier Gamarra Date: Fri, 17 Jul 2015 12:08:05 +0200 Subject: [PATCH 003/365] =?UTF-8?q?LSR-291=20add=20jcenter=20in=20child=20?= =?UTF-8?q?repositories=20to=20don=E2=80=99t=20have=20to=20specify=20it=20?= =?UTF-8?q?in=20the=20projects?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/samples/addbookmarkscreenlet/build.gradle | 4 ++++ android/viewsets/material/build.gradle | 4 ++++ android/viewsets/westeros/build.gradle | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/android/samples/addbookmarkscreenlet/build.gradle b/android/samples/addbookmarkscreenlet/build.gradle index 79a93f0def..7743e89ab1 100644 --- a/android/samples/addbookmarkscreenlet/build.gradle +++ b/android/samples/addbookmarkscreenlet/build.gradle @@ -23,4 +23,8 @@ dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.2.0' compile project (':liferay-screens') +} + +repositories { + jcenter() } \ No newline at end of file diff --git a/android/viewsets/material/build.gradle b/android/viewsets/material/build.gradle index 13ad3bd185..9123512429 100644 --- a/android/viewsets/material/build.gradle +++ b/android/viewsets/material/build.gradle @@ -27,4 +27,8 @@ dependencies { exclude group: 'com.google.android', module: 'support-v4' } compile project(':liferay-screens') +} + +repositories { + jcenter() } \ No newline at end of file diff --git a/android/viewsets/westeros/build.gradle b/android/viewsets/westeros/build.gradle index c5c87fac71..9c35a8f338 100644 --- a/android/viewsets/westeros/build.gradle +++ b/android/viewsets/westeros/build.gradle @@ -28,4 +28,8 @@ dependencies { } compile "com.daimajia.swipelayout:library:1.1.9@aar" compile project(':liferay-screens') +} + +repositories { + jcenter() } \ No newline at end of file From a5765657c9f594042f6b6ac549f871cde12313d2 Mon Sep 17 00:00:00 2001 From: Javier Gamarra Date: Mon, 20 Jul 2015 16:53:22 +0200 Subject: [PATCH 004/365] LSR-291 changing group and company id to long value --- .../context/LiferayScreensContext.java | 2 +- .../screens/context/LiferayServerContext.java | 24 +++++++++++++++---- .../src/main/res/values/server_context.xml | 4 ++-- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/android/library/core/src/main/java/com/liferay/mobile/screens/context/LiferayScreensContext.java b/android/library/core/src/main/java/com/liferay/mobile/screens/context/LiferayScreensContext.java index c5909e7d61..2a82714870 100644 --- a/android/library/core/src/main/java/com/liferay/mobile/screens/context/LiferayScreensContext.java +++ b/android/library/core/src/main/java/com/liferay/mobile/screens/context/LiferayScreensContext.java @@ -26,7 +26,7 @@ public class LiferayScreensContext { public static void init(Context context) { _context = context.getApplicationContext(); - LiferayServerContext.loadFromResources(context.getResources()); + LiferayServerContext.loadFromResources(context.getResources(), context.getPackageName()); } /** diff --git a/android/library/core/src/main/java/com/liferay/mobile/screens/context/LiferayServerContext.java b/android/library/core/src/main/java/com/liferay/mobile/screens/context/LiferayServerContext.java index 2a14d9f924..e513a19206 100644 --- a/android/library/core/src/main/java/com/liferay/mobile/screens/context/LiferayServerContext.java +++ b/android/library/core/src/main/java/com/liferay/mobile/screens/context/LiferayServerContext.java @@ -23,10 +23,26 @@ */ public class LiferayServerContext { - public static void loadFromResources(Resources resources) { - LiferayServerContext.setCompanyId(resources.getInteger(R.integer.liferay_company_id)); - LiferayServerContext.setGroupId(resources.getInteger(R.integer.liferay_group_id)); - LiferayServerContext.setServer(resources.getString(R.string.liferay_server)); + public static void loadFromValues(long companyId, long groupId, String server) { + LiferayServerContext.setCompanyId(companyId); + LiferayServerContext.setGroupId(groupId); + LiferayServerContext.setServer(server); + } + + public static void loadFromResources(Resources resources, final String packageName) { + int companyIdentifier = resources.getIdentifier("liferay_company_id", "integer", packageName); + int groupIdentifier = resources.getIdentifier("liferay_group_id", "integer", packageName); + + long companyId = getValueFromIntegerOrString(resources, R.string.liferay_company_id, companyIdentifier); + long groupId = getValueFromIntegerOrString(resources, R.string.liferay_group_id, groupIdentifier); + + String server = resources.getString(R.string.liferay_server); + + loadFromValues(companyId, groupId, server); + } + + private static long getValueFromIntegerOrString(final Resources resources, final int stringId, int integerId) { + return integerId == 0 ? Long.valueOf(resources.getString(stringId)) : resources.getInteger(integerId); } public static long getCompanyId() { diff --git a/android/library/core/src/main/res/values/server_context.xml b/android/library/core/src/main/res/values/server_context.xml index 9652dcdd27..5083e935ab 100644 --- a/android/library/core/src/main/res/values/server_context.xml +++ b/android/library/core/src/main/res/values/server_context.xml @@ -1,8 +1,8 @@ - 10154 - 10181 + 10154 + 10181 http://192.168.56.1:8080 From 1f51200f6f40f00828d10a35b4e6d8333ec6b37d Mon Sep 17 00:00:00 2001 From: Javier Gamarra Date: Mon, 20 Jul 2015 16:55:01 +0200 Subject: [PATCH 005/365] LSR-291 add a default method to set long values in base screenlet --- .../mobile/screens/base/BaseScreenlet.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/android/library/core/src/main/java/com/liferay/mobile/screens/base/BaseScreenlet.java b/android/library/core/src/main/java/com/liferay/mobile/screens/base/BaseScreenlet.java index 40d7e4d404..43169eb84b 100644 --- a/android/library/core/src/main/java/com/liferay/mobile/screens/base/BaseScreenlet.java +++ b/android/library/core/src/main/java/com/liferay/mobile/screens/base/BaseScreenlet.java @@ -24,6 +24,7 @@ import com.liferay.mobile.screens.base.interactor.Interactor; import com.liferay.mobile.screens.base.view.BaseViewModel; import com.liferay.mobile.screens.context.LiferayScreensContext; +import com.liferay.mobile.screens.util.LiferayLogger; import java.util.HashMap; import java.util.Map; @@ -115,7 +116,7 @@ protected View getScreenletView() { } protected V getViewModel() { - return (V)_screenletView; + return (V) _screenletView; } protected int getDefaultLayoutId() { @@ -216,6 +217,23 @@ protected void onScreenletDetached() { protected abstract void onUserAction(String userActionName, I interactor, Object... args); + protected long getLongFromString(String value) { + return getLongFromStringWithDefaultValue(value, 0); + } + + protected long getLongFromStringWithDefaultValue(String value, long defaultValue) { + if (value == null) { + return defaultValue; + } + try { + return Long.valueOf(value); + } + catch (NumberFormatException e) { + LiferayLogger.e("You have supplied a string and we expected a long number", e); + throw e; + } + } + private static final String _STATE_SCREENLET_ID = "basescreenlet-screenletId"; private static final String _STATE_SUPER = "basescreenlet-super"; private static final String _STATE_INTERACTORS = "basescreenlet-interactors"; From 7638f3ee195b93ab972a0f37b33629e5d571bdf4 Mon Sep 17 00:00:00 2001 From: Javier Gamarra Date: Mon, 20 Jul 2015 16:57:47 +0200 Subject: [PATCH 006/365] LSR-291 change screenlet to use long versions --- .../screens/assetlist/AssetListScreenlet.java | 28 ++++--- .../ForgotPasswordScreenlet.java | 8 +- .../screens/auth/signup/SignUpScreenlet.java | 10 +-- .../screens/ddl/form/DDLFormScreenlet.java | 25 +++--- .../screens/ddl/list/DDLListScreenlet.java | 78 +++++++++---------- .../userportrait/UserPortraitScreenlet.java | 8 +- .../WebContentDisplayScreenlet.java | 8 +- 7 files changed, 83 insertions(+), 82 deletions(-) diff --git a/android/library/core/src/main/java/com/liferay/mobile/screens/assetlist/AssetListScreenlet.java b/android/library/core/src/main/java/com/liferay/mobile/screens/assetlist/AssetListScreenlet.java index d80e359437..364b69444d 100644 --- a/android/library/core/src/main/java/com/liferay/mobile/screens/assetlist/AssetListScreenlet.java +++ b/android/library/core/src/main/java/com/liferay/mobile/screens/assetlist/AssetListScreenlet.java @@ -47,26 +47,26 @@ public AssetListScreenlet(Context context, AttributeSet attributes, int defaultS super(context, attributes, defaultStyle); } - @Override - protected void loadRows(AssetListInteractor interactor, int startRow, int endRow, Locale locale) + @Override + protected void loadRows(AssetListInteractor interactor, int startRow, int endRow, Locale locale) throws Exception { interactor.loadRows(_groupId, _classNameId, startRow, endRow, locale); - } + } - public int getClassNameId() { + public long getClassNameId() { return _classNameId; } - public void setClassNameId(int classNameId) { + public void setClassNameId(long classNameId) { _classNameId = classNameId; } - public int getGroupId() { + public long getGroupId() { return _groupId; } - public void setGroupId(int groupId) { + public void setGroupId(long groupId) { _groupId = groupId; } @@ -76,9 +76,13 @@ protected View createScreenletView(Context context, AttributeSet attributes) { attributes, R.styleable.AssetListScreenlet, 0, 0); _classNameId = typedArray.getInt( R.styleable.AssetListScreenlet_classNameId, 0); - _groupId = typedArray.getInteger( - R.styleable.AssetListScreenlet_groupId, - (int) LiferayServerContext.getGroupId()); + + + long groupId = LiferayServerContext.getGroupId(); + + _groupId = getLongFromStringWithDefaultValue(typedArray.getString( + R.styleable.AssetListScreenlet_groupId), groupId); + typedArray.recycle(); return super.createScreenletView(context, attributes); @@ -89,7 +93,7 @@ protected AssetListInteractor createInteractor(String actionName) { return new AssetListInteractorImpl(getScreenletId()); } - private int _classNameId; - private int _groupId; + private long _classNameId; + private long _groupId; } \ No newline at end of file diff --git a/android/library/core/src/main/java/com/liferay/mobile/screens/auth/forgotpassword/ForgotPasswordScreenlet.java b/android/library/core/src/main/java/com/liferay/mobile/screens/auth/forgotpassword/ForgotPasswordScreenlet.java index bf489fc419..4ca1ae6798 100644 --- a/android/library/core/src/main/java/com/liferay/mobile/screens/auth/forgotpassword/ForgotPasswordScreenlet.java +++ b/android/library/core/src/main/java/com/liferay/mobile/screens/auth/forgotpassword/ForgotPasswordScreenlet.java @@ -16,9 +16,7 @@ import android.content.Context; import android.content.res.TypedArray; - import android.util.AttributeSet; - import android.view.LayoutInflater; import android.view.View; @@ -113,9 +111,9 @@ protected View createScreenletView(Context context, AttributeSet attributes) { TypedArray typedArray = context.getTheme().obtainStyledAttributes( attributes, R.styleable.ForgotPasswordScreenlet, 0, 0); - _companyId = typedArray.getInt( - R.styleable.ForgotPasswordScreenlet_companyId, - (int)LiferayServerContext.getCompanyId()); + _companyId = getLongFromStringWithDefaultValue(typedArray.getString( + R.styleable.ForgotPasswordScreenlet_companyId), + LiferayServerContext.getCompanyId()); _anonymousApiUserName = typedArray.getString( R.styleable.ForgotPasswordScreenlet_anonymousApiUserName); diff --git a/android/library/core/src/main/java/com/liferay/mobile/screens/auth/signup/SignUpScreenlet.java b/android/library/core/src/main/java/com/liferay/mobile/screens/auth/signup/SignUpScreenlet.java index 47d3fab77e..4c38d49d79 100644 --- a/android/library/core/src/main/java/com/liferay/mobile/screens/auth/signup/SignUpScreenlet.java +++ b/android/library/core/src/main/java/com/liferay/mobile/screens/auth/signup/SignUpScreenlet.java @@ -16,9 +16,7 @@ import android.content.Context; import android.content.res.TypedArray; - import android.util.AttributeSet; - import android.view.LayoutInflater; import android.view.View; @@ -31,7 +29,7 @@ import com.liferay.mobile.screens.context.LiferayServerContext; import com.liferay.mobile.screens.context.SessionContext; import com.liferay.mobile.screens.context.User; -import com.liferay.mobile.screens.context.storage.CredentialsStoreBuilder.*; +import com.liferay.mobile.screens.context.storage.CredentialsStoreBuilder.StorageType; import java.util.Locale; @@ -149,9 +147,9 @@ protected View createScreenletView(Context context, AttributeSet attributes) { TypedArray typedArray = context.getTheme().obtainStyledAttributes( attributes, R.styleable.SignUpScreenlet, 0, 0); - _companyId = typedArray.getInt( - R.styleable.SignUpScreenlet_companyId, - (int)LiferayServerContext.getCompanyId()); + _companyId = getLongFromStringWithDefaultValue(typedArray.getString( + R.styleable.SignUpScreenlet_companyId), + LiferayServerContext.getCompanyId()); _anonymousApiUserName = typedArray.getString( R.styleable.SignUpScreenlet_anonymousApiUserName); diff --git a/android/library/core/src/main/java/com/liferay/mobile/screens/ddl/form/DDLFormScreenlet.java b/android/library/core/src/main/java/com/liferay/mobile/screens/ddl/form/DDLFormScreenlet.java index 57391fbf1a..fb58f68ceb 100644 --- a/android/library/core/src/main/java/com/liferay/mobile/screens/ddl/form/DDLFormScreenlet.java +++ b/android/library/core/src/main/java/com/liferay/mobile/screens/ddl/form/DDLFormScreenlet.java @@ -26,9 +26,9 @@ import com.liferay.mobile.screens.base.BaseScreenlet; import com.liferay.mobile.screens.context.LiferayServerContext; import com.liferay.mobile.screens.context.SessionContext; +import com.liferay.mobile.screens.ddl.form.interactor.DDLFormBaseInteractor; import com.liferay.mobile.screens.ddl.form.interactor.add.DDLFormAddRecordInteractor; import com.liferay.mobile.screens.ddl.form.interactor.add.DDLFormAddRecordInteractorImpl; -import com.liferay.mobile.screens.ddl.form.interactor.DDLFormBaseInteractor; import com.liferay.mobile.screens.ddl.form.interactor.formload.DDLFormLoadInteractor; import com.liferay.mobile.screens.ddl.form.interactor.formload.DDLFormLoadInteractorImpl; import com.liferay.mobile.screens.ddl.form.interactor.recordload.DDLFormLoadRecordInteractor; @@ -379,21 +379,22 @@ protected View createScreenletView(Context context, AttributeSet attributes) { _showSubmitButton = typedArray.getBoolean( R.styleable.DDLFormScreenlet_showSubmitButton, true); - _groupId = typedArray.getInteger( - R.styleable.DDLFormScreenlet_groupId, - (int) LiferayServerContext.getGroupId()); + _groupId = getLongFromStringWithDefaultValue(typedArray.getString( + R.styleable.DDLFormScreenlet_groupId), + LiferayServerContext.getGroupId()); - _structureId = typedArray.getInteger(R.styleable.DDLFormScreenlet_structureId, 0); - _recordSetId = typedArray.getInteger(R.styleable.DDLFormScreenlet_recordSetId, 0); - _recordId = typedArray.getInteger(R.styleable.DDLFormScreenlet_recordId, 0); + _structureId = getLongFromString(typedArray.getString(R.styleable.DDLFormScreenlet_structureId)); + _recordSetId = getLongFromString(typedArray.getString(R.styleable.DDLFormScreenlet_recordSetId)); + _recordId = getLongFromString(typedArray.getString(R.styleable.DDLFormScreenlet_recordId)); _filePrefix = typedArray.getString(R.styleable.DDLFormScreenlet_filePrefix); - _repositoryId = typedArray.getInteger(R.styleable.DDLFormScreenlet_repositoryId, 0); - _folderId = typedArray.getInteger(R.styleable.DDLFormScreenlet_folderId, 0); + _repositoryId = getLongFromString(typedArray.getString(R.styleable.DDLFormScreenlet_repositoryId)); + _folderId = getLongFromString(typedArray.getString(R.styleable.DDLFormScreenlet_folderId)); - int defaultCreatorUserId = SessionContext.getLoggedUser() != null ? - (int) SessionContext.getLoggedUser().getId() : 0; + long defaultCreatorUserId = SessionContext.getLoggedUser() != null ? + SessionContext.getLoggedUser().getId() : 0; - _userId = typedArray.getInteger(R.styleable.DDLFormScreenlet_userId, defaultCreatorUserId); + _userId = getLongFromStringWithDefaultValue(typedArray.getString(R.styleable.DDLFormScreenlet_userId) + , defaultCreatorUserId); _record = new Record(getResources().getConfiguration().locale); _record.setStructureId(_structureId); diff --git a/android/library/core/src/main/java/com/liferay/mobile/screens/ddl/list/DDLListScreenlet.java b/android/library/core/src/main/java/com/liferay/mobile/screens/ddl/list/DDLListScreenlet.java index 15b4ae43ba..733f6d7c38 100644 --- a/android/library/core/src/main/java/com/liferay/mobile/screens/ddl/list/DDLListScreenlet.java +++ b/android/library/core/src/main/java/com/liferay/mobile/screens/ddl/list/DDLListScreenlet.java @@ -21,9 +21,9 @@ import com.liferay.mobile.screens.R; import com.liferay.mobile.screens.base.list.BaseListScreenlet; -import com.liferay.mobile.screens.ddl.list.interactor.DDLListInteractorListener; import com.liferay.mobile.screens.ddl.list.interactor.DDLListInteractor; import com.liferay.mobile.screens.ddl.list.interactor.DDLListInteractorImpl; +import com.liferay.mobile.screens.ddl.list.interactor.DDLListInteractorListener; import java.util.ArrayList; import java.util.List; @@ -54,43 +54,43 @@ protected void loadRows(DDLListInteractor interactor, int startRow, int endRow, interactor.loadRows(_recordSetId, _userId, startRow, endRow, locale); } - public int getRecordSetId() { - return _recordSetId; - } + public long getRecordSetId() { + return _recordSetId; + } - public void setRecordSetId(int recordSetId) { - _recordSetId = recordSetId; - } + public void setRecordSetId(long recordSetId) { + _recordSetId = recordSetId; + } - public int getUserId() { - return _userId; - } + public long getUserId() { + return _userId; + } - public void setUserId(int userId) { - _userId = userId; - } + public void setUserId(int userId) { + _userId = userId; + } - public List getLabelFields() { - return _labelFields; - } + public List getLabelFields() { + return _labelFields; + } - public void setLabelFields(List labelFields) { - _labelFields = labelFields; - } + public void setLabelFields(List labelFields) { + _labelFields = labelFields; + } @Override protected View createScreenletView(Context context, AttributeSet attributes) { - TypedArray typedArray = context.getTheme().obtainStyledAttributes( - attributes, R.styleable.DDLListScreenlet, 0, 0); - _recordSetId = typedArray.getInteger( - R.styleable.DDLListScreenlet_recordSetId, 0); - _userId = typedArray.getInteger( - R.styleable.DDLListScreenlet_userId, 0); - _labelFields = parse(typedArray.getString( - R.styleable.DDLListScreenlet_labelFields)); - typedArray.recycle(); - - return super.createScreenletView(context, attributes); + TypedArray typedArray = context.getTheme().obtainStyledAttributes( + attributes, R.styleable.DDLListScreenlet, 0, 0); + _recordSetId = getLongFromString(typedArray.getString( + R.styleable.DDLListScreenlet_recordSetId)); + _userId = getLongFromString(typedArray.getString( + R.styleable.DDLListScreenlet_userId)); + _labelFields = parse(typedArray.getString( + R.styleable.DDLListScreenlet_labelFields)); + typedArray.recycle(); + + return super.createScreenletView(context, attributes); } @Override @@ -103,16 +103,16 @@ private List parse(String labelFields) { throw new IllegalArgumentException("DDLListScreenlet must define 'labelFields' parameter"); } - List parsedFields = new ArrayList<>(); - for (String text : labelFields.split(",")) { - parsedFields.add(text.trim()); - } + List parsedFields = new ArrayList<>(); + for (String text : labelFields.split(",")) { + parsedFields.add(text.trim()); + } - return parsedFields; - } + return parsedFields; + } - private int _recordSetId; - private int _userId; - private List _labelFields; + private long _recordSetId; + private long _userId; + private List _labelFields; } \ No newline at end of file diff --git a/android/library/core/src/main/java/com/liferay/mobile/screens/userportrait/UserPortraitScreenlet.java b/android/library/core/src/main/java/com/liferay/mobile/screens/userportrait/UserPortraitScreenlet.java index c12dc3b19f..5b89a0a621 100644 --- a/android/library/core/src/main/java/com/liferay/mobile/screens/userportrait/UserPortraitScreenlet.java +++ b/android/library/core/src/main/java/com/liferay/mobile/screens/userportrait/UserPortraitScreenlet.java @@ -233,11 +233,11 @@ protected View createScreenletView(Context context, AttributeSet attributes) { _uuid = typedArray.getString(R.styleable.UserPortraitScreenlet_uuid); _editable = typedArray.getBoolean(R.styleable.UserPortraitScreenlet_editable, false); - int defaultUserId = 0; - if (SessionContext.hasSession() && _portraitId == 0 && _uuid == null) { - defaultUserId = (int) SessionContext.getLoggedUser().getId(); + _userId = typedArray.getInt(R.styleable.UserPortraitScreenlet_userId, 0); + + if (SessionContext.hasSession() && _portraitId == 0 && _uuid == null && _userId == 0) { + _userId = SessionContext.getLoggedUser().getId(); } - _userId = typedArray.getInt(R.styleable.UserPortraitScreenlet_userId, defaultUserId); int layoutId = typedArray.getResourceId( R.styleable.UserPortraitScreenlet_layoutId, getDefaultLayoutId()); diff --git a/android/library/core/src/main/java/com/liferay/mobile/screens/webcontentdisplay/WebContentDisplayScreenlet.java b/android/library/core/src/main/java/com/liferay/mobile/screens/webcontentdisplay/WebContentDisplayScreenlet.java index 25fe2d7ec4..61b35eb5fe 100644 --- a/android/library/core/src/main/java/com/liferay/mobile/screens/webcontentdisplay/WebContentDisplayScreenlet.java +++ b/android/library/core/src/main/java/com/liferay/mobile/screens/webcontentdisplay/WebContentDisplayScreenlet.java @@ -34,8 +34,8 @@ * @author Jose Manuel Navarro */ public class WebContentDisplayScreenlet - extends BaseScreenlet - implements WebContentDisplayListener { + extends BaseScreenlet + implements WebContentDisplayListener { public WebContentDisplayScreenlet(Context context) { super(context); @@ -114,8 +114,8 @@ protected View createScreenletView( _articleId = typedArray.getString(R.styleable.WebContentDisplayScreenlet_articleId); - _groupId = typedArray.getInt( - R.styleable.WebContentDisplayScreenlet_groupId, (int) LiferayServerContext.getGroupId()); + _groupId = getLongFromStringWithDefaultValue(typedArray.getString( + R.styleable.WebContentDisplayScreenlet_groupId), LiferayServerContext.getGroupId()); _javascriptEnabled = typedArray.getBoolean( R.styleable.WebContentDisplayScreenlet_javascriptEnabled, false); From 39a07ebc12628067c71a8a5a39a99a08d7205a8e Mon Sep 17 00:00:00 2001 From: Javier Gamarra Date: Mon, 20 Jul 2015 16:58:27 +0200 Subject: [PATCH 007/365] LSR-291 read values from JSON casting to long if necessary --- .../liferay/mobile/screens/context/User.java | 13 +++--------- .../mobile/screens/ddl/list/DDLEntry.java | 10 +++++++++ .../screens/ddl/model/DocumentRemoteFile.java | 4 ++-- .../liferay/mobile/screens/util/JSONUtil.java | 21 +++++++++++++------ 4 files changed, 30 insertions(+), 18 deletions(-) diff --git a/android/library/core/src/main/java/com/liferay/mobile/screens/context/User.java b/android/library/core/src/main/java/com/liferay/mobile/screens/context/User.java index 332e7b6f1f..105f9505f4 100644 --- a/android/library/core/src/main/java/com/liferay/mobile/screens/context/User.java +++ b/android/library/core/src/main/java/com/liferay/mobile/screens/context/User.java @@ -14,6 +14,7 @@ package com.liferay.mobile.screens.context; +import com.liferay.mobile.screens.util.JSONUtil; import com.liferay.mobile.screens.util.LiferayLogger; import org.json.JSONException; @@ -54,7 +55,7 @@ public User(JSONObject jsonObject) { } public long getId() { - return safeCastToLong(_attributes.get(USER_ID)); + return JSONUtil.safeCastToLong(_attributes.get(USER_ID)); } public String getUuid() { @@ -62,15 +63,7 @@ public String getUuid() { } public long getPortraitId() { - return safeCastToLong(_attributes.get(PORTRAIT_ID)); - } - - private long safeCastToLong(final Object o) { - if (o instanceof Integer) { - return (int) o; - } else { - return (long) o; - } + return JSONUtil.safeCastToLong(_attributes.get(PORTRAIT_ID)); } public String getFirstName() { diff --git a/android/library/core/src/main/java/com/liferay/mobile/screens/ddl/list/DDLEntry.java b/android/library/core/src/main/java/com/liferay/mobile/screens/ddl/list/DDLEntry.java index db7d794731..057005fefe 100644 --- a/android/library/core/src/main/java/com/liferay/mobile/screens/ddl/list/DDLEntry.java +++ b/android/library/core/src/main/java/com/liferay/mobile/screens/ddl/list/DDLEntry.java @@ -17,6 +17,8 @@ import android.os.Parcel; import android.os.Parcelable; +import com.liferay.mobile.screens.util.JSONUtil; + import java.util.HashMap; import java.util.Map; @@ -67,6 +69,14 @@ private DDLEntry(Parcel in) { in.readMap(_values, ClassLoader.getSystemClassLoader()); } + public long getRecordId() { + return JSONUtil.safeCastToLong(getAttributes("recordId")); + } + + public long getRecordSetId() { + return JSONUtil.safeCastToLong(getAttributes("recordSetId")); + } + private Map _values; } \ No newline at end of file diff --git a/android/library/core/src/main/java/com/liferay/mobile/screens/ddl/model/DocumentRemoteFile.java b/android/library/core/src/main/java/com/liferay/mobile/screens/ddl/model/DocumentRemoteFile.java index 92d954a617..4656a46973 100644 --- a/android/library/core/src/main/java/com/liferay/mobile/screens/ddl/model/DocumentRemoteFile.java +++ b/android/library/core/src/main/java/com/liferay/mobile/screens/ddl/model/DocumentRemoteFile.java @@ -36,8 +36,8 @@ public boolean isValid() { return _uuid != null; } - private Integer _groupId; + private long _groupId; private String _uuid; - private Integer _version; + private int _version; private String _title; } \ No newline at end of file diff --git a/android/library/core/src/main/java/com/liferay/mobile/screens/util/JSONUtil.java b/android/library/core/src/main/java/com/liferay/mobile/screens/util/JSONUtil.java index a77a7bfac9..17dc492513 100644 --- a/android/library/core/src/main/java/com/liferay/mobile/screens/util/JSONUtil.java +++ b/android/library/core/src/main/java/com/liferay/mobile/screens/util/JSONUtil.java @@ -14,16 +14,16 @@ package com.liferay.mobile.screens.util; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - /** * @author Silvio Santos */ @@ -55,15 +55,24 @@ public static Map toMap(JSONObject jsonObject) return map; } + public static long safeCastToLong(final Object o) { + if (o instanceof Integer) { + return (int) o; + } + else { + return (long) o; + } + } + private static Object _fromJson(Object object) throws JSONException { if (object == JSONObject.NULL) { return null; } else if (object instanceof JSONObject) { - return toMap((JSONObject)object); + return toMap((JSONObject) object); } else if (object instanceof JSONArray) { - return toList((JSONArray)object); + return toList((JSONArray) object); } else { return object; From ae7c3f8d4bdbfef82df857596a1848bcb08111f4 Mon Sep 17 00:00:00 2001 From: Javier Gamarra Date: Mon, 20 Jul 2015 16:58:38 +0200 Subject: [PATCH 008/365] LSR-291 adapt add bookmark --- .../mobile/screens/bookmark/AddBookmarkScreenlet.java | 8 ++++---- .../bookmark/interactor/AddBookmarkInteractor.java | 2 +- .../bookmark/interactor/AddBookmarkInteractorImpl.java | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/android/samples/addbookmarkscreenlet/src/main/java/com/liferay/mobile/screens/bookmark/AddBookmarkScreenlet.java b/android/samples/addbookmarkscreenlet/src/main/java/com/liferay/mobile/screens/bookmark/AddBookmarkScreenlet.java index 038d3a743b..463f8cae7b 100644 --- a/android/samples/addbookmarkscreenlet/src/main/java/com/liferay/mobile/screens/bookmark/AddBookmarkScreenlet.java +++ b/android/samples/addbookmarkscreenlet/src/main/java/com/liferay/mobile/screens/bookmark/AddBookmarkScreenlet.java @@ -57,7 +57,7 @@ protected View createScreenletView(Context context, AttributeSet attributes) { String defaultTitle = typedArray.getString(R.styleable.AddBookmarkScreenlet_defaultTitle); - _folderId = typedArray.getInteger(R.styleable.AddBookmarkScreenlet_folderId, 0); + _folderId = getLongFromString(typedArray.getString(R.styleable.AddBookmarkScreenlet_folderId)); typedArray.recycle(); @@ -86,11 +86,11 @@ protected void onUserAction(String userActionName, AddBookmarkInteractor interac } } - public Integer getFolderId() { + public long getFolderId() { return _folderId; } - public void setFolderId(Integer folderId) { + public void setFolderId(long folderId) { _folderId = folderId; } @@ -102,7 +102,7 @@ public void setListener(AddBookmarkListener listener) { _listener = listener; } - private Integer _folderId; + private long _folderId; private AddBookmarkListener _listener; } diff --git a/android/samples/addbookmarkscreenlet/src/main/java/com/liferay/mobile/screens/bookmark/interactor/AddBookmarkInteractor.java b/android/samples/addbookmarkscreenlet/src/main/java/com/liferay/mobile/screens/bookmark/interactor/AddBookmarkInteractor.java index 3d9c6fb7b9..2b2c906b12 100644 --- a/android/samples/addbookmarkscreenlet/src/main/java/com/liferay/mobile/screens/bookmark/interactor/AddBookmarkInteractor.java +++ b/android/samples/addbookmarkscreenlet/src/main/java/com/liferay/mobile/screens/bookmark/interactor/AddBookmarkInteractor.java @@ -7,6 +7,6 @@ */ public interface AddBookmarkInteractor extends Interactor { - void addBookmark(String url, String title, Integer folderId) throws Exception; + void addBookmark(String url, String title, long folderId) throws Exception; } diff --git a/android/samples/addbookmarkscreenlet/src/main/java/com/liferay/mobile/screens/bookmark/interactor/AddBookmarkInteractorImpl.java b/android/samples/addbookmarkscreenlet/src/main/java/com/liferay/mobile/screens/bookmark/interactor/AddBookmarkInteractorImpl.java index 37040d8133..206b8a891c 100644 --- a/android/samples/addbookmarkscreenlet/src/main/java/com/liferay/mobile/screens/bookmark/interactor/AddBookmarkInteractorImpl.java +++ b/android/samples/addbookmarkscreenlet/src/main/java/com/liferay/mobile/screens/bookmark/interactor/AddBookmarkInteractorImpl.java @@ -21,12 +21,12 @@ public AddBookmarkInteractorImpl(int targetScreenletId) { super(targetScreenletId); } - public void addBookmark(String url, String title, Integer folderId) throws Exception { + public void addBookmark(String url, String title, long folderId) throws Exception { if (url == null || url.isEmpty() || !URLUtil.isValidUrl(url)) { throw new IllegalArgumentException("Invalid url"); } - if (folderId == null || folderId == 0) { + if (folderId == 0) { throw new IllegalArgumentException("folderId not set"); } From b499a08ef57f2a16e2914537bf0d05be47c7b0d6 Mon Sep 17 00:00:00 2001 From: Javier Gamarra Date: Mon, 20 Jul 2015 16:58:57 +0200 Subject: [PATCH 009/365] LSR-291 adapt test-app --- .../screens/testapp/AssetListActivity.java | 2 +- .../mobile/screens/testapp/DDLFormActivity.java | 6 +++--- .../mobile/screens/testapp/DDLListActivity.java | 8 ++++---- .../src/main/res/layout/add_bookmark.xml | 2 +- .../test-app/src/main/res/layout/ddl_form.xml | 16 ++++++++-------- .../test-app/src/main/res/layout/ddl_list.xml | 4 ++-- .../test-app/src/main/res/layout/web_view.xml | 2 +- .../src/main/res/values/server_context.xml | 12 ++++++------ 8 files changed, 26 insertions(+), 26 deletions(-) diff --git a/android/samples/test-app/src/main/java/com/liferay/mobile/screens/testapp/AssetListActivity.java b/android/samples/test-app/src/main/java/com/liferay/mobile/screens/testapp/AssetListActivity.java index bfabe4a5b6..14ed1b8db3 100644 --- a/android/samples/test-app/src/main/java/com/liferay/mobile/screens/testapp/AssetListActivity.java +++ b/android/samples/test-app/src/main/java/com/liferay/mobile/screens/testapp/AssetListActivity.java @@ -38,7 +38,7 @@ protected void onCreate(Bundle savedInstanceState) { _screenlet = (AssetListScreenlet) getActiveScreenlet( R.id.asset_list_default, R.id.asset_list_material); - _screenlet.setClassNameId(getIntent().getIntExtra("classNameId", 20116)); + _screenlet.setClassNameId(getIntent().getLongExtra("classNameId", 20116)); _screenlet.setVisibility(View.VISIBLE); _screenlet.setListener(this); diff --git a/android/samples/test-app/src/main/java/com/liferay/mobile/screens/testapp/DDLFormActivity.java b/android/samples/test-app/src/main/java/com/liferay/mobile/screens/testapp/DDLFormActivity.java index 71d66795c3..bdd51b1cf0 100644 --- a/android/samples/test-app/src/main/java/com/liferay/mobile/screens/testapp/DDLFormActivity.java +++ b/android/samples/test-app/src/main/java/com/liferay/mobile/screens/testapp/DDLFormActivity.java @@ -130,9 +130,9 @@ protected void onRestoreInstanceState(Bundle savedInstanceState) { private void initScreenletFromIntent(Intent intent) { if (intent.hasExtra("recordId")) { - _screenlet.setRecordId(intent.getIntExtra("recordId", 0)); - _screenlet.setRecordSetId(intent.getIntExtra("recordSetId", 0)); - _screenlet.setStructureId(intent.getIntExtra("structureId", 0)); + _screenlet.setRecordId(intent.getLongExtra("recordId", 0)); + _screenlet.setRecordSetId(intent.getLongExtra("recordSetId", 0)); + _screenlet.setStructureId(intent.getLongExtra("structureId", 0)); } } diff --git a/android/samples/test-app/src/main/java/com/liferay/mobile/screens/testapp/DDLListActivity.java b/android/samples/test-app/src/main/java/com/liferay/mobile/screens/testapp/DDLListActivity.java index 671a53d19e..2e5f4e2123 100644 --- a/android/samples/test-app/src/main/java/com/liferay/mobile/screens/testapp/DDLListActivity.java +++ b/android/samples/test-app/src/main/java/com/liferay/mobile/screens/testapp/DDLListActivity.java @@ -71,8 +71,8 @@ public void onListItemSelected(DDLEntry element, View view) { } private void loadDDLForm(DDLEntry element) { - final Integer recordId = (Integer) (element.getAttributes("recordId")); - final Integer recordSetId = (Integer) (element.getAttributes("recordSetId")); + final long recordId = element.getRecordId(); + final long recordSetId = element.getRecordSetId(); try { Session session = SessionContext.createSessionFromCurrentSession(); @@ -85,7 +85,7 @@ private void loadDDLForm(DDLEntry element) { } } - private JSONObjectAsyncTaskCallback getCallback(final Integer recordId, final Integer recordSetId) { + private JSONObjectAsyncTaskCallback getCallback(final long recordId, final long recordSetId) { return new JSONObjectAsyncTaskCallback() { @Override @@ -94,7 +94,7 @@ public void onSuccess(JSONObject result) { Intent intent = getIntentWithTheme(DDLFormActivity.class); intent.putExtra("recordId", recordId); intent.putExtra("recordSetId", recordSetId); - intent.putExtra("structureId", result.getInt("DDMStructureId")); + intent.putExtra("structureId", result.getLong("DDMStructureId")); Crouton.clearCroutonsForActivity(DDLListActivity.this); diff --git a/android/samples/test-app/src/main/res/layout/add_bookmark.xml b/android/samples/test-app/src/main/res/layout/add_bookmark.xml index cb0cf61348..d4e0791801 100644 --- a/android/samples/test-app/src/main/res/layout/add_bookmark.xml +++ b/android/samples/test-app/src/main/res/layout/add_bookmark.xml @@ -9,6 +9,6 @@ android:id="@+id/bookmark_screenlet" android:layout_width="match_parent" android:layout_height="match_parent" - liferay:folderId="@integer/bookmark_folder" + liferay:folderId="@string/bookmark_folder" liferay:layoutId="@layout/bookmark_default"/> \ No newline at end of file diff --git a/android/samples/test-app/src/main/res/layout/ddl_form.xml b/android/samples/test-app/src/main/res/layout/ddl_form.xml index 56a4f44f31..dd86d4acbe 100644 --- a/android/samples/test-app/src/main/res/layout/ddl_form.xml +++ b/android/samples/test-app/src/main/res/layout/ddl_form.xml @@ -17,11 +17,11 @@ android:paddingTop="0dp" liferay:autoLoad="false" liferay:filePrefix="jre" - liferay:folderId="@integer/folder_id" + liferay:folderId="@string/folder_id" liferay:layoutId="@layout/ddl_form_default" - liferay:recordSetId="@integer/liferay_recordset_id" - liferay:repositoryId="@integer/repository_id" - liferay:structureId="@integer/liferay_structure_id"/> + liferay:recordSetId="@string/liferay_recordset_id" + liferay:repositoryId="@string/repository_id" + liferay:structureId="@string/liferay_structure_id"/> + liferay:structureId="@string/liferay_structure_id"/> \ No newline at end of file diff --git a/android/samples/test-app/src/main/res/layout/ddl_list.xml b/android/samples/test-app/src/main/res/layout/ddl_list.xml index a5e21e2616..cb21fd46e9 100644 --- a/android/samples/test-app/src/main/res/layout/ddl_list.xml +++ b/android/samples/test-app/src/main/res/layout/ddl_list.xml @@ -16,7 +16,7 @@ android:layout_height="match_parent" liferay:labelFields="@string/liferay_recordset_fields" liferay:layoutId="@layout/ddl_list_default" - liferay:recordSetId="@integer/liferay_recordset_id"/> + liferay:recordSetId="@string/liferay_recordset_id"/> + liferay:recordSetId="@string/liferay_recordset_id"/> \ No newline at end of file diff --git a/android/samples/test-app/src/main/res/layout/web_view.xml b/android/samples/test-app/src/main/res/layout/web_view.xml index 9b91833d12..a51485076c 100644 --- a/android/samples/test-app/src/main/res/layout/web_view.xml +++ b/android/samples/test-app/src/main/res/layout/web_view.xml @@ -13,7 +13,7 @@ android:id="@+id/web_view" android:layout_width="match_parent" android:layout_height="match_parent" - liferay:articleId="@integer/article_id" + liferay:articleId="@string/article_id" liferay:layoutId="@layout/webcontentdisplay_default"/> \ No newline at end of file diff --git a/android/samples/test-app/src/main/res/values/server_context.xml b/android/samples/test-app/src/main/res/values/server_context.xml index dd08543ce0..abae4c0c8b 100644 --- a/android/samples/test-app/src/main/res/values/server_context.xml +++ b/android/samples/test-app/src/main/res/values/server_context.xml @@ -11,17 +11,17 @@ anonymous1 - 20596 - 20591 + 20596 + 20591 Title - 20617 - 20525 + 20617 + 20525 - 20622 + 20622 - 20602 + 20602 f4adeb99-9ddf-4c9c-a408-347ce8be340a From 4883cabfc4cbb2ea7c5fae3f7df0f7f21efc379c Mon Sep 17 00:00:00 2001 From: Javier Gamarra Date: Mon, 20 Jul 2015 16:59:20 +0200 Subject: [PATCH 010/365] LSR-291 use screens directly to test push notifications with long values --- android/samples/pushnotifications/app/build.gradle | 5 ++--- android/samples/pushnotifications/settings.gradle | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/android/samples/pushnotifications/app/build.gradle b/android/samples/pushnotifications/app/build.gradle index 748d99382e..cc1606ed25 100644 --- a/android/samples/pushnotifications/app/build.gradle +++ b/android/samples/pushnotifications/app/build.gradle @@ -27,7 +27,6 @@ dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.2.0' - compile 'com.liferay.mobile:liferay-screens:1.1.0' - compile 'com.liferay.mobile:liferay-material-viewset:1.1.0' - + compile project(':liferay-screens') + compile project(':liferay-material-viewset') } diff --git a/android/samples/pushnotifications/settings.gradle b/android/samples/pushnotifications/settings.gradle index a81ab61fcf..00a7242954 100644 --- a/android/samples/pushnotifications/settings.gradle +++ b/android/samples/pushnotifications/settings.gradle @@ -1,9 +1,9 @@ include ':app' -//include 'liferay-screens' -//project(':liferay-screens').projectDir = new File(settingsDir, '../../library/core') -//project(':liferay-screens').name = 'liferay-screens' +include 'liferay-screens' +project(':liferay-screens').projectDir = new File(settingsDir, '../../library/core') +project(':liferay-screens').name = 'liferay-screens' -//include 'liferay-material-viewset' -//project(':liferay-material-viewset').projectDir = new File(settingsDir, '../../viewsets/material') -//project(':liferay-material-viewset').name = 'liferay-material-viewset' \ No newline at end of file +include 'liferay-material-viewset' +project(':liferay-material-viewset').projectDir = new File(settingsDir, '../../viewsets/material') +project(':liferay-material-viewset').name = 'liferay-material-viewset' \ No newline at end of file From 3624b0def12437ae603e55880dc08a82bf6a08c7 Mon Sep 17 00:00:00 2001 From: Javier Gamarra Date: Thu, 30 Jul 2015 13:12:33 +0200 Subject: [PATCH 011/365] LSR-298 new url and new build based on develop --- android/samples/bankofwesteros/build.gradle | 2 +- .../bankofwesteros/src/main/res/values/server_context.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/android/samples/bankofwesteros/build.gradle b/android/samples/bankofwesteros/build.gradle index 51d802ecf3..60b7b9807e 100644 --- a/android/samples/bankofwesteros/build.gradle +++ b/android/samples/bankofwesteros/build.gradle @@ -13,7 +13,7 @@ android { applicationId "com.liferay.mobile.screens.bankofwesteros" minSdkVersion 15 targetSdkVersion 22 - versionCode 3 + versionCode 4 versionName "1.0" } buildTypes { diff --git a/android/samples/bankofwesteros/src/main/res/values/server_context.xml b/android/samples/bankofwesteros/src/main/res/values/server_context.xml index a64bc31101..2aa5a88ae5 100644 --- a/android/samples/bankofwesteros/src/main/res/values/server_context.xml +++ b/android/samples/bankofwesteros/src/main/res/values/server_context.xml @@ -1,7 +1,7 @@ - https://screensdemo.liferay.com + https://demo.liferay.com/screens 20155 20525 From 91024853a37355f3bdbab5145320112c49237250 Mon Sep 17 00:00:00 2001 From: JM Date: Fri, 31 Jul 2015 14:16:26 +0200 Subject: [PATCH 012/365] LSR-299 Freeze dependencies --- LiferayScreens.podspec | 16 ++++----- ios/Framework/Podfile | 17 +++++----- ios/Framework/Podfile.lock | 69 +++++++++++++++++++++----------------- 3 files changed, 55 insertions(+), 47 deletions(-) diff --git a/LiferayScreens.podspec b/LiferayScreens.podspec index d6c9bd247b..1f54f989a6 100644 --- a/LiferayScreens.podspec +++ b/LiferayScreens.podspec @@ -52,20 +52,20 @@ Pod::Spec.new do |s| # Core s.dependency 'Liferay-iOS-SDK', '6.2.0.17' - s.dependency 'Liferay-OAuth' - s.dependency 'MBProgressHUD', '~> 0.9.1' - s.dependency 'SMXMLDocument' - s.dependency 'ODRefreshControl' + s.dependency 'Liferay-OAuth', '0.1.0' + s.dependency 'MBProgressHUD', '0.9.1' + s.dependency 'SMXMLDocument', '1.1' + s.dependency 'ODRefreshControl', '1.2' # Login & signup: save credentials - s.dependency 'KeychainAccess' + s.dependency 'KeychainAccess', '1.2.1' # UserPortrait s.dependency 'CryptoSwift' # DDLForm - s.dependency 'DTPickerPresenter' - s.dependency 'TNRadioButtonGroup' - s.dependency 'MDRadialProgress' + s.dependency 'DTPickerPresenter', '0.2.0' + s.dependency 'TNRadioButtonGroup', '0.4' + s.dependency 'MDRadialProgress', '1.3.2' end \ No newline at end of file diff --git a/ios/Framework/Podfile b/ios/Framework/Podfile index e7d6004473..beb5914436 100644 --- a/ios/Framework/Podfile +++ b/ios/Framework/Podfile @@ -6,21 +6,22 @@ use_frameworks! # Core pod 'Liferay-iOS-SDK', '6.2.0.17' -pod 'Liferay-OAuth' -pod 'MBProgressHUD', '~> 0.9.1' -pod 'SMXMLDocument' -pod 'ODRefreshControl' +pod 'Liferay-OAuth', '0.1.0' +pod 'MBProgressHUD', '0.9.1' +pod 'SMXMLDocument', '1.1' +pod 'ODRefreshControl', '1.2' +pod 'FMDB', '2.5' # Login & signup: save credentials -pod 'KeychainAccess' +pod 'KeychainAccess', '1.2.1' # UserPortrait pod 'CryptoSwift' # DDLForm -pod 'DTPickerPresenter' -pod 'TNRadioButtonGroup' -pod 'MDRadialProgress' +pod 'DTPickerPresenter', '0.2.0' +pod 'TNRadioButtonGroup', '0.4' +pod 'MDRadialProgress', '1.3.2' diff --git a/ios/Framework/Podfile.lock b/ios/Framework/Podfile.lock index 8797cdec0d..445dde39f0 100644 --- a/ios/Framework/Podfile.lock +++ b/ios/Framework/Podfile.lock @@ -1,67 +1,74 @@ PODS: - - AFNetworking (2.5.2): - - AFNetworking/NSURLConnection (= 2.5.2) - - AFNetworking/NSURLSession (= 2.5.2) - - AFNetworking/Reachability (= 2.5.2) - - AFNetworking/Security (= 2.5.2) - - AFNetworking/Serialization (= 2.5.2) - - AFNetworking/UIKit (= 2.5.2) - - AFNetworking/NSURLConnection (2.5.2): + - AFNetworking (2.5.4): + - AFNetworking/NSURLConnection (= 2.5.4) + - AFNetworking/NSURLSession (= 2.5.4) + - AFNetworking/Reachability (= 2.5.4) + - AFNetworking/Security (= 2.5.4) + - AFNetworking/Serialization (= 2.5.4) + - AFNetworking/UIKit (= 2.5.4) + - AFNetworking/NSURLConnection (2.5.4): - AFNetworking/Reachability - AFNetworking/Security - AFNetworking/Serialization - - AFNetworking/NSURLSession (2.5.2): + - AFNetworking/NSURLSession (2.5.4): - AFNetworking/Reachability - AFNetworking/Security - AFNetworking/Serialization - - AFNetworking/Reachability (2.5.2) - - AFNetworking/Security (2.5.2) - - AFNetworking/Serialization (2.5.2) - - AFNetworking/UIKit (2.5.2): + - AFNetworking/Reachability (2.5.4) + - AFNetworking/Security (2.5.4) + - AFNetworking/Serialization (2.5.4) + - AFNetworking/UIKit (2.5.4): - AFNetworking/NSURLConnection - AFNetworking/NSURLSession - - CryptoSwift (0.0.10) + - CryptoSwift (0.0.12) - DTPickerPresenter (0.2.0) + - FMDB (2.5): + - FMDB/standard (= 2.5) + - FMDB/common (2.5) + - FMDB/standard (2.5): + - FMDB/common - KeychainAccess (1.2.1) - Liferay-iOS-SDK (6.2.0.17): - AFNetworking (~> 2.5.0) - Liferay-OAuth (0.1.0): - Liferay-iOS-SDK (= 6.2.0.17) - MBProgressHUD (0.9.1) - - MDRadialProgress (1.3.1) - - Nocilla (0.9.0) - - ODRefreshControl (1.1.0) + - MDRadialProgress (1.3.2) + - Nocilla (0.10.0) + - ODRefreshControl (1.2) - SMXMLDocument (1.1) - SwiftTryCatch (0.0.1) - TNRadioButtonGroup (0.4) DEPENDENCIES: - CryptoSwift - - DTPickerPresenter - - KeychainAccess + - DTPickerPresenter (= 0.2.0) + - FMDB (= 2.5) + - KeychainAccess (= 1.2.1) - Liferay-iOS-SDK (= 6.2.0.17) - - Liferay-OAuth - - MBProgressHUD (~> 0.9.1) - - MDRadialProgress + - Liferay-OAuth (= 0.1.0) + - MBProgressHUD (= 0.9.1) + - MDRadialProgress (= 1.3.2) - Nocilla - - ODRefreshControl - - SMXMLDocument + - ODRefreshControl (= 1.2) + - SMXMLDocument (= 1.1) - SwiftTryCatch - - TNRadioButtonGroup + - TNRadioButtonGroup (= 0.4) SPEC CHECKSUMS: - AFNetworking: fefbce9660acb17f48ae0011292d4da0f457bf36 - CryptoSwift: 3b886d001f50deb65623a8967d68f6b8bf8d9ba1 + AFNetworking: 05edc0ac4c4c8cf57bcf4b84be5b0744b6d8e71e + CryptoSwift: 16f1b5a768057636275b76d1c43231c2abba9e80 DTPickerPresenter: 1976573e3475534559b6ec1dad64b2ece16c966d + FMDB: 96e8f1bcc1329e269330f99770ad4285d9003e52 KeychainAccess: 3d7922baf90762a976adb7f6030d74c1a4110a1d Liferay-iOS-SDK: 00b511b88592d07faade2bed8252c04193df565d Liferay-OAuth: 4e217d2e2483788324b16dce65c30884ec8eb1db MBProgressHUD: c47f2c166c126cf2ce36498d80f33e754d4e93ad - MDRadialProgress: 6af31db0315f1b687df825a73481a2a443182402 - Nocilla: d7d96e8a11e363f0d7c976d48b320c43d61fb471 - ODRefreshControl: 4c4c413bf70d2ea0c02a28ac0a0b3b4bf4dbfdea + MDRadialProgress: 1068574b9b4b870f64b605b07f734385bde5104d + Nocilla: ae0a2b05f3087b473624ac2b25903695df51246a + ODRefreshControl: 907e6149d72dde488d5917ccfabee5bd8d711a20 SMXMLDocument: e0d9fbf726a2a0921871b492966458acb3ad9689 SwiftTryCatch: fb6d2b34abe48efd69578dac919293a44f95b481 TNRadioButtonGroup: f5fb9b545d8913bbabe6a72ea1fa6fba4d833bb6 -COCOAPODS: 0.37.2 +COCOAPODS: 0.38.2 From 2689159b5b8811377cfd0f84dc28bca4d55d27fd Mon Sep 17 00:00:00 2001 From: JM Date: Mon, 3 Aug 2015 11:49:56 +0200 Subject: [PATCH 013/365] LSR-299 Use YapDatabase for persistence instead of plain sqlite --- LiferayScreens.podspec | 1 + ios/Framework/LiferayScreens.h | 2 ++ ios/Framework/Podfile | 2 +- ios/Framework/Podfile.lock | 21 +++++++++++++-------- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/LiferayScreens.podspec b/LiferayScreens.podspec index 1f54f989a6..32eb51015b 100644 --- a/LiferayScreens.podspec +++ b/LiferayScreens.podspec @@ -56,6 +56,7 @@ Pod::Spec.new do |s| s.dependency 'MBProgressHUD', '0.9.1' s.dependency 'SMXMLDocument', '1.1' s.dependency 'ODRefreshControl', '1.2' + s.dependency 'YapDatabase', '2.6.5' # Login & signup: save credentials s.dependency 'KeychainAccess', '1.2.1' diff --git a/ios/Framework/LiferayScreens.h b/ios/Framework/LiferayScreens.h index 45e0a792e8..f238cae3cf 100644 --- a/ios/Framework/LiferayScreens.h +++ b/ios/Framework/LiferayScreens.h @@ -21,3 +21,5 @@ FOUNDATION_EXPORT const unsigned char LiferayScreensVersionString[]; #import #import #import + +#import diff --git a/ios/Framework/Podfile b/ios/Framework/Podfile index beb5914436..397232203b 100644 --- a/ios/Framework/Podfile +++ b/ios/Framework/Podfile @@ -10,7 +10,7 @@ pod 'Liferay-OAuth', '0.1.0' pod 'MBProgressHUD', '0.9.1' pod 'SMXMLDocument', '1.1' pod 'ODRefreshControl', '1.2' -pod 'FMDB', '2.5' +pod 'YapDatabase', '2.6.5' # Login & signup: save credentials pod 'KeychainAccess', '1.2.1' diff --git a/ios/Framework/Podfile.lock b/ios/Framework/Podfile.lock index 445dde39f0..dc5bb90355 100644 --- a/ios/Framework/Podfile.lock +++ b/ios/Framework/Podfile.lock @@ -20,13 +20,13 @@ PODS: - AFNetworking/UIKit (2.5.4): - AFNetworking/NSURLConnection - AFNetworking/NSURLSession + - CocoaLumberjack (1.9.2): + - CocoaLumberjack/Extensions (= 1.9.2) + - CocoaLumberjack/Core (1.9.2) + - CocoaLumberjack/Extensions (1.9.2): + - CocoaLumberjack/Core - CryptoSwift (0.0.12) - DTPickerPresenter (0.2.0) - - FMDB (2.5): - - FMDB/standard (= 2.5) - - FMDB/common (2.5) - - FMDB/standard (2.5): - - FMDB/common - KeychainAccess (1.2.1) - Liferay-iOS-SDK (6.2.0.17): - AFNetworking (~> 2.5.0) @@ -39,11 +39,14 @@ PODS: - SMXMLDocument (1.1) - SwiftTryCatch (0.0.1) - TNRadioButtonGroup (0.4) + - YapDatabase (2.6.5): + - YapDatabase/standard (= 2.6.5) + - YapDatabase/standard (2.6.5): + - CocoaLumberjack (~> 1) DEPENDENCIES: - CryptoSwift - DTPickerPresenter (= 0.2.0) - - FMDB (= 2.5) - KeychainAccess (= 1.2.1) - Liferay-iOS-SDK (= 6.2.0.17) - Liferay-OAuth (= 0.1.0) @@ -54,12 +57,13 @@ DEPENDENCIES: - SMXMLDocument (= 1.1) - SwiftTryCatch - TNRadioButtonGroup (= 0.4) + - YapDatabase (= 2.6.5) SPEC CHECKSUMS: AFNetworking: 05edc0ac4c4c8cf57bcf4b84be5b0744b6d8e71e + CocoaLumberjack: 628fca2e88ef06f7cf6817309aa405f325d9a6fa CryptoSwift: 16f1b5a768057636275b76d1c43231c2abba9e80 DTPickerPresenter: 1976573e3475534559b6ec1dad64b2ece16c966d - FMDB: 96e8f1bcc1329e269330f99770ad4285d9003e52 KeychainAccess: 3d7922baf90762a976adb7f6030d74c1a4110a1d Liferay-iOS-SDK: 00b511b88592d07faade2bed8252c04193df565d Liferay-OAuth: 4e217d2e2483788324b16dce65c30884ec8eb1db @@ -70,5 +74,6 @@ SPEC CHECKSUMS: SMXMLDocument: e0d9fbf726a2a0921871b492966458acb3ad9689 SwiftTryCatch: fb6d2b34abe48efd69578dac919293a44f95b481 TNRadioButtonGroup: f5fb9b545d8913bbabe6a72ea1fa6fba4d833bb6 + YapDatabase: 814f9ff862a95c1e581d93335a4020482b69155b -COCOAPODS: 0.38.2 +COCOAPODS: 0.37.2 From 2ef7e0861d7fa85eb4715d8e8bb3bf7ad97a94dc Mon Sep 17 00:00:00 2001 From: JM Date: Mon, 3 Aug 2015 19:54:51 +0200 Subject: [PATCH 014/365] LSR-299 Add basic cache class --- ios/Framework/Core/Cache/ReadCache.swift | 70 +++++++++++++++++++ .../LiferayScreens.xcodeproj/project.pbxproj | 16 +++++ 2 files changed, 86 insertions(+) create mode 100644 ios/Framework/Core/Cache/ReadCache.swift diff --git a/ios/Framework/Core/Cache/ReadCache.swift b/ios/Framework/Core/Cache/ReadCache.swift new file mode 100644 index 0000000000..43c644abd3 --- /dev/null +++ b/ios/Framework/Core/Cache/ReadCache.swift @@ -0,0 +1,70 @@ +/** +* Copyright (c) 2000-present Liferay, Inc. All rights reserved. +* +* This library is free software; you can redistribute it and/or modify it under +* the terms of the GNU Lesser General Public License as published by the Free +* Software Foundation; either version 2.1 of the License, or (at your option) +* any later version. +* +* This library is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +* details. +*/ +import Foundation + + +@objc public class ReadCache: NSObject { + + private let tableSchemaDatabase = "lr_read_cache_" + + private var database: YapDatabase + private var readConnection: YapDatabaseConnection + private var writeConnection: YapDatabaseConnection + + + public init(name: String) { + let cacheFolderPath = NSSearchPathForDirectoriesInDomains(.CachesDirectory, .UserDomainMask, true)[0] as! String + let path = cacheFolderPath.stringByAppendingPathComponent(tableSchemaDatabase) + let dbPath = "\(path)_\(name))" + + database = YapDatabase(path: dbPath) + readConnection = database.newConnection() + writeConnection = database.newConnection() + + super.init() + } + + public func get(#collection: String, key: String, result: String -> Void) { + readConnection.readWithBlock { transaction -> Void in + if let value = transaction.objectForKey(key, inCollection: collection) as? NSObject { + result(value.description) + } + }; + } + + public func set(#collection: String, key: String, value: String) { + writeConnection.readWriteWithBlock { transaction -> Void in + transaction.setObject(value, forKey: key, inCollection: collection) + } + } + + public func remove(#collection: String, key: String) { + writeConnection.readWriteWithBlock { transaction -> Void in + transaction.removeObjectForKey(key, inCollection: collection) + } + } + + public func remove(#collection: String) { + writeConnection.readWriteWithBlock { transaction -> Void in + transaction.removeAllObjectsInCollection(collection) + } + } + + public func removeAll() { + writeConnection.readWriteWithBlock { transaction -> Void in + transaction.removeAllObjectsInAllCollections() + } + } + +} diff --git a/ios/Framework/LiferayScreens.xcodeproj/project.pbxproj b/ios/Framework/LiferayScreens.xcodeproj/project.pbxproj index 194b4cc285..07bde2bb99 100644 --- a/ios/Framework/LiferayScreens.xcodeproj/project.pbxproj +++ b/ios/Framework/LiferayScreens.xcodeproj/project.pbxproj @@ -266,6 +266,8 @@ 8839B88F1B0CD5C4006C18F1 /* GetUserByScreenNameOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8839B8881B0CD5C4006C18F1 /* GetUserByScreenNameOperation.swift */; }; 8839B8901B0CD5C4006C18F1 /* GetUserByUserIdOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8839B8891B0CD5C4006C18F1 /* GetUserByUserIdOperation.swift */; }; 8839B8911B0CD5C4006C18F1 /* GetUserByUserIdOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8839B8891B0CD5C4006C18F1 /* GetUserByUserIdOperation.swift */; }; + 8855F4C61B6F61E500E8E0E9 /* ReadCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8855F4C51B6F61E500E8E0E9 /* ReadCache.swift */; }; + 8855F4C71B6F61E500E8E0E9 /* ReadCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8855F4C51B6F61E500E8E0E9 /* ReadCache.swift */; }; 888DF5B11ACC9FC200EB7DA1 /* LoginScreenlet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881E60F11ACBE5F000862B9E /* LoginScreenlet.swift */; }; 888DF5B21ACC9FC200EB7DA1 /* LoginViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881E60F21ACBE5F000862B9E /* LoginViewModel.swift */; }; 888DF5B41ACC9FF100EB7DA1 /* LoginView_default.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881E61C31ACBFC3400862B9E /* LoginView_default.swift */; }; @@ -554,6 +556,7 @@ 8839B8871B0CD5C4006C18F1 /* GetUserByEmailOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetUserByEmailOperation.swift; sourceTree = ""; }; 8839B8881B0CD5C4006C18F1 /* GetUserByScreenNameOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetUserByScreenNameOperation.swift; sourceTree = ""; }; 8839B8891B0CD5C4006C18F1 /* GetUserByUserIdOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetUserByUserIdOperation.swift; sourceTree = ""; }; + 8855F4C51B6F61E500E8E0E9 /* ReadCache.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReadCache.swift; sourceTree = ""; }; 8892C6781ACB2E3300192232 /* LiferayScreens.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = LiferayScreens.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 8892C67C1ACB2E3300192232 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; 8892C67D1ACB2E3300192232 /* LiferayScreens.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LiferayScreens.h; sourceTree = SOURCE_ROOT; }; @@ -1266,6 +1269,14 @@ path = ServerOperations; sourceTree = ""; }; + 8855F4C41B6F619C00E8E0E9 /* Cache */ = { + isa = PBXGroup; + children = ( + 8855F4C51B6F61E500E8E0E9 /* ReadCache.swift */, + ); + path = Cache; + sourceTree = ""; + }; 8892C66E1ACB2E3300192232 = { isa = PBXGroup; children = ( @@ -1336,6 +1347,7 @@ 881E613F1ACBEDC600862B9E /* AssetListScreenlet */, 881E60DE1ACBE5F000862B9E /* Auth */, 881E60B41ACBE3FF00862B9E /* Base */, + 8855F4C41B6F619C00E8E0E9 /* Cache */, 8892C6B11ACBD95400192232 /* Context */, 881E614C1ACBEE0B00862B9E /* DDL */, 8892C6A41ACBD89400192232 /* Extensions */, @@ -1827,6 +1839,7 @@ 881E618E1ACBEE0B00862B9E /* DDLFieldDate.swift in Sources */, 881E61811ACBEE0B00862B9E /* LiferayDDLFormRecordLoadOperation.swift in Sources */, 88CA805B1B25AF48004C1D59 /* LoginInteractor.swift in Sources */, + 8855F4C61B6F61E500E8E0E9 /* ReadCache.swift in Sources */, 88CA80661B25D72A004C1D59 /* AuthType.swift in Sources */, 88CA806B1B25E953004C1D59 /* NSError+Screens.swift in Sources */, 881E61271ACBE5F000862B9E /* UserPortraitScreenlet.swift in Sources */, @@ -1999,6 +2012,7 @@ 88F888561B26E3E50084B5E8 /* BasicCredentialsStoreKeyChain.swift in Sources */, 881E61AE1ACBFB0400862B9E /* TestHelper.swift in Sources */, 881E62A41ACBFF4500862B9E /* NSLocale+CurrentLocale.swift in Sources */, + 8855F4C71B6F61E500E8E0E9 /* ReadCache.swift in Sources */, 881E629F1ACBFF2500862B9E /* SignUpViewModel.swift in Sources */, 881E62A21ACBFF4500862B9E /* Bool+Conversion.swift in Sources */, 881E629C1ACBFF1800862B9E /* ServerOperation.swift in Sources */, @@ -2197,6 +2211,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 70A86EF9E7113685C27BD9CA /* Pods.debug.xcconfig */; buildSettings = { + CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES; CLANG_ENABLE_MODULES = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; @@ -2215,6 +2230,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 0B440B87DE9DF08FCB1AA970 /* Pods.release.xcconfig */; buildSettings = { + CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES; CLANG_ENABLE_MODULES = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; From 97824662fb8453251e9cdc914920b1e3cf6e9f2f Mon Sep 17 00:00:00 2001 From: JM Date: Mon, 3 Aug 2015 19:55:30 +0200 Subject: [PATCH 015/365] LSR-299 Renamed --- .../Cache/{ReadCache.swift => CacheManager.swift} | 4 ++-- .../LiferayScreens.xcodeproj/project.pbxproj | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) rename ios/Framework/Core/Cache/{ReadCache.swift => CacheManager.swift} (95%) diff --git a/ios/Framework/Core/Cache/ReadCache.swift b/ios/Framework/Core/Cache/CacheManager.swift similarity index 95% rename from ios/Framework/Core/Cache/ReadCache.swift rename to ios/Framework/Core/Cache/CacheManager.swift index 43c644abd3..2de5c0b67e 100644 --- a/ios/Framework/Core/Cache/ReadCache.swift +++ b/ios/Framework/Core/Cache/CacheManager.swift @@ -14,9 +14,9 @@ import Foundation -@objc public class ReadCache: NSObject { +@objc public class CacheManager: NSObject { - private let tableSchemaDatabase = "lr_read_cache_" + private let tableSchemaDatabase = "lr_cache_" private var database: YapDatabase private var readConnection: YapDatabaseConnection diff --git a/ios/Framework/LiferayScreens.xcodeproj/project.pbxproj b/ios/Framework/LiferayScreens.xcodeproj/project.pbxproj index 07bde2bb99..7b5203a7b3 100644 --- a/ios/Framework/LiferayScreens.xcodeproj/project.pbxproj +++ b/ios/Framework/LiferayScreens.xcodeproj/project.pbxproj @@ -266,8 +266,8 @@ 8839B88F1B0CD5C4006C18F1 /* GetUserByScreenNameOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8839B8881B0CD5C4006C18F1 /* GetUserByScreenNameOperation.swift */; }; 8839B8901B0CD5C4006C18F1 /* GetUserByUserIdOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8839B8891B0CD5C4006C18F1 /* GetUserByUserIdOperation.swift */; }; 8839B8911B0CD5C4006C18F1 /* GetUserByUserIdOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8839B8891B0CD5C4006C18F1 /* GetUserByUserIdOperation.swift */; }; - 8855F4C61B6F61E500E8E0E9 /* ReadCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8855F4C51B6F61E500E8E0E9 /* ReadCache.swift */; }; - 8855F4C71B6F61E500E8E0E9 /* ReadCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8855F4C51B6F61E500E8E0E9 /* ReadCache.swift */; }; + 8855F4C61B6F61E500E8E0E9 /* CacheManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8855F4C51B6F61E500E8E0E9 /* CacheManager.swift */; }; + 8855F4C71B6F61E500E8E0E9 /* CacheManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8855F4C51B6F61E500E8E0E9 /* CacheManager.swift */; }; 888DF5B11ACC9FC200EB7DA1 /* LoginScreenlet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881E60F11ACBE5F000862B9E /* LoginScreenlet.swift */; }; 888DF5B21ACC9FC200EB7DA1 /* LoginViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881E60F21ACBE5F000862B9E /* LoginViewModel.swift */; }; 888DF5B41ACC9FF100EB7DA1 /* LoginView_default.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881E61C31ACBFC3400862B9E /* LoginView_default.swift */; }; @@ -556,7 +556,7 @@ 8839B8871B0CD5C4006C18F1 /* GetUserByEmailOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetUserByEmailOperation.swift; sourceTree = ""; }; 8839B8881B0CD5C4006C18F1 /* GetUserByScreenNameOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetUserByScreenNameOperation.swift; sourceTree = ""; }; 8839B8891B0CD5C4006C18F1 /* GetUserByUserIdOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetUserByUserIdOperation.swift; sourceTree = ""; }; - 8855F4C51B6F61E500E8E0E9 /* ReadCache.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReadCache.swift; sourceTree = ""; }; + 8855F4C51B6F61E500E8E0E9 /* CacheManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CacheManager.swift; sourceTree = ""; }; 8892C6781ACB2E3300192232 /* LiferayScreens.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = LiferayScreens.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 8892C67C1ACB2E3300192232 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; 8892C67D1ACB2E3300192232 /* LiferayScreens.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LiferayScreens.h; sourceTree = SOURCE_ROOT; }; @@ -1272,7 +1272,7 @@ 8855F4C41B6F619C00E8E0E9 /* Cache */ = { isa = PBXGroup; children = ( - 8855F4C51B6F61E500E8E0E9 /* ReadCache.swift */, + 8855F4C51B6F61E500E8E0E9 /* CacheManager.swift */, ); path = Cache; sourceTree = ""; @@ -1839,7 +1839,7 @@ 881E618E1ACBEE0B00862B9E /* DDLFieldDate.swift in Sources */, 881E61811ACBEE0B00862B9E /* LiferayDDLFormRecordLoadOperation.swift in Sources */, 88CA805B1B25AF48004C1D59 /* LoginInteractor.swift in Sources */, - 8855F4C61B6F61E500E8E0E9 /* ReadCache.swift in Sources */, + 8855F4C61B6F61E500E8E0E9 /* CacheManager.swift in Sources */, 88CA80661B25D72A004C1D59 /* AuthType.swift in Sources */, 88CA806B1B25E953004C1D59 /* NSError+Screens.swift in Sources */, 881E61271ACBE5F000862B9E /* UserPortraitScreenlet.swift in Sources */, @@ -2012,7 +2012,7 @@ 88F888561B26E3E50084B5E8 /* BasicCredentialsStoreKeyChain.swift in Sources */, 881E61AE1ACBFB0400862B9E /* TestHelper.swift in Sources */, 881E62A41ACBFF4500862B9E /* NSLocale+CurrentLocale.swift in Sources */, - 8855F4C71B6F61E500E8E0E9 /* ReadCache.swift in Sources */, + 8855F4C71B6F61E500E8E0E9 /* CacheManager.swift in Sources */, 881E629F1ACBFF2500862B9E /* SignUpViewModel.swift in Sources */, 881E62A21ACBFF4500862B9E /* Bool+Conversion.swift in Sources */, 881E629C1ACBFF1800862B9E /* ServerOperation.swift in Sources */, From d1f44c9fb6b34f05a190dc8712f33e35cfe2fcf5 Mon Sep 17 00:00:00 2001 From: JM Date: Tue, 4 Aug 2015 16:39:46 +0200 Subject: [PATCH 016/365] LSR-299 Add Cache manager singleton --- ios/Framework/Core/Cache/CacheManager.swift | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ios/Framework/Core/Cache/CacheManager.swift b/ios/Framework/Core/Cache/CacheManager.swift index 2de5c0b67e..1eaf014553 100644 --- a/ios/Framework/Core/Cache/CacheManager.swift +++ b/ios/Framework/Core/Cache/CacheManager.swift @@ -12,6 +12,7 @@ * details. */ import Foundation +import YapDatabase @objc public class CacheManager: NSObject { @@ -22,6 +23,11 @@ import Foundation private var readConnection: YapDatabaseConnection private var writeConnection: YapDatabaseConnection + private static var _instance = CacheManager(name: "shared") + + public class var sharedManager: CacheManager { + return _instance + } public init(name: String) { let cacheFolderPath = NSSearchPathForDirectoriesInDomains(.CachesDirectory, .UserDomainMask, true)[0] as! String @@ -35,11 +41,10 @@ import Foundation super.init() } - public func get(#collection: String, key: String, result: String -> Void) { + public func get(#collection: String, key: String, result: String? -> Void) { readConnection.readWithBlock { transaction -> Void in - if let value = transaction.objectForKey(key, inCollection: collection) as? NSObject { - result(value.description) - } + let value: AnyObject? = transaction.objectForKey(key, inCollection: collection) + result((value as? NSObject)?.description) }; } From 7fae2062f15097c63678bf45ca4730b08a72989e Mon Sep 17 00:00:00 2001 From: JM Date: Tue, 4 Aug 2015 16:40:41 +0200 Subject: [PATCH 017/365] LSR-299 Add cache operations at server interactor --- .../Core/Base/ServerOperationInteractor.swift | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/ios/Framework/Core/Base/ServerOperationInteractor.swift b/ios/Framework/Core/Base/ServerOperationInteractor.swift index 327240f7f6..778d277be5 100644 --- a/ios/Framework/Core/Base/ServerOperationInteractor.swift +++ b/ios/Framework/Core/Base/ServerOperationInteractor.swift @@ -23,9 +23,24 @@ public class ServerOperationInteractor: Interactor { self.completedOperation(operation) if let error = $0.lastError { - self.callOnFailure(error) + if error.domain == "NSURLErrorDomain" { + self.readFromCache(operation) { + self.completedOperation(operation) + + if let value = $0 { + self.callOnSuccess() + } + else { + self.callOnFailure(error) + } + } + } + else { + self.callOnFailure(error) + } } else { + self.writeToCache(operation) self.callOnSuccess() } } @@ -45,4 +60,11 @@ public class ServerOperationInteractor: Interactor { public func completedOperation(op: ServerOperation) { } + public func readFromCache(op: ServerOperation, result: String? -> Void) { + result(nil) + } + + public func writeToCache(op: ServerOperation) { + } + } From bb16271808cf5d92a7950000989cf454f745545f Mon Sep 17 00:00:00 2001 From: JM Date: Tue, 4 Aug 2015 16:41:04 +0200 Subject: [PATCH 018/365] LSR-299 Add cache support to WebContentDisplay screenlet --- .../WebContentDisplayLoadInteractor.swift | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/ios/Framework/Core/WebContentDisplayScreenlet/WebContentDisplayLoadInteractor.swift b/ios/Framework/Core/WebContentDisplayScreenlet/WebContentDisplayLoadInteractor.swift index 32ed078601..024f82ed8a 100644 --- a/ios/Framework/Core/WebContentDisplayScreenlet/WebContentDisplayLoadInteractor.swift +++ b/ios/Framework/Core/WebContentDisplayScreenlet/WebContentDisplayLoadInteractor.swift @@ -31,7 +31,34 @@ class WebContentDisplayLoadInteractor: ServerOperationInteractor { } override func completedOperation(op: ServerOperation) { - self.resultHTML = (op as! LiferayWebContentLoadOperation).resultHTML + self.resultHTML = (op as? LiferayWebContentLoadOperation)?.resultHTML + } + + override func readFromCache(op: ServerOperation, result: String? -> Void) { + if let loadOp = op as? LiferayWebContentLoadOperation, + groupId = loadOp.groupId, + articleId = loadOp.articleId { + + CacheManager.sharedManager.get( + collection: "group-\(groupId)", + key: "webcontent-\(articleId)") { + loadOp.resultHTML = $0 + result($0) + } + } + } + + override func writeToCache(op: ServerOperation) { + if let loadOp = op as? LiferayWebContentLoadOperation, + html = loadOp.resultHTML, + groupId = loadOp.groupId, + articleId = loadOp.articleId { + + CacheManager.sharedManager.set( + collection: "group-\(groupId)", + key: "webcontent-\(articleId)", + value: html) + } } } From 9b3d3de646616943d8b4cbe22a533dd7716e39ab Mon Sep 17 00:00:00 2001 From: JM Date: Wed, 5 Aug 2015 13:08:12 +0200 Subject: [PATCH 019/365] LSR-239 Move current HUD logic to a new class: MBProgressHUDPresenter This is a new abstraction to allow programmers to use different presenters for progress views --- .../Core/Base/BaseScreenlet+progress.swift | 221 ------------------ ios/Framework/Core/Base/BaseScreenlet.swift | 52 +++++ .../Core/Base/MBProgressHUDPresenter.swift | 179 ++++++++++++++ .../Core/Base/ProgressPresenter.swift | 49 ++++ ios/Framework/Core/Base/ServerOperation.swift | 32 +-- .../LiferayDDLFormSubmitOperation.swift | 2 +- ios/Framework/Core/Extensions/Global.swift | 11 + .../LiferayScreens.xcodeproj/project.pbxproj | 18 +- 8 files changed, 316 insertions(+), 248 deletions(-) delete mode 100644 ios/Framework/Core/Base/BaseScreenlet+progress.swift create mode 100644 ios/Framework/Core/Base/MBProgressHUDPresenter.swift create mode 100644 ios/Framework/Core/Base/ProgressPresenter.swift diff --git a/ios/Framework/Core/Base/BaseScreenlet+progress.swift b/ios/Framework/Core/Base/BaseScreenlet+progress.swift deleted file mode 100644 index e423eaecb3..0000000000 --- a/ios/Framework/Core/Base/BaseScreenlet+progress.swift +++ /dev/null @@ -1,221 +0,0 @@ -/** -* Copyright (c) 2000-present Liferay, Inc. All rights reserved. -* -* This library is free software; you can redistribute it and/or modify it under -* the terms of the GNU Lesser General Public License as published by the Free -* Software Foundation; either version 2.1 of the License, or (at your option) -* any later version. -* -* This library is distributed in the hope that it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -* details. -*/ -import Foundation - -#if LIFERAY_SCREENS_FRAMEWORK - import MBProgressHUD -#endif - - -internal let BaseScreenletHudLock = "hud-lock" - - -internal struct MBProgressHUDInstance { - - static var instance:MBProgressHUD? - static var touchHandler:HUDTouchHandler? - static var customView:UIView? { - didSet { - if instance != nil { - instance!.customView = customView - } - } - } - static var customColor:UIColor? { - didSet { - if instance != nil { - instance!.color = customColor - } - } - } - static var customOpacity:Float = 0.8 { - didSet { - if instance != nil { - instance!.opacity = customOpacity - } - } - } - -} - - -internal class HUDTouchHandler { - - internal dynamic func simpleTapDetected(recognizer:UIGestureRecognizer!) { - if let hud = recognizer.view as? MBProgressHUD { - hud.hide(true) - MBProgressHUDInstance.instance = nil - } - } -} - - -/*! - * This extension to BaseScreenlet adds methods to display an "In Progress" HUD. - */ -extension BaseScreenlet { - - public enum CloseMode { - - case ManualClose(Bool) - case AutocloseDelayed(Double, Bool) - case AutocloseComputedDelay(Bool) - - internal func allowCloseOnTouch() -> Bool { - var result = false - - switch self { - case .AutocloseComputedDelay(let touchClose): - result = touchClose - case .AutocloseDelayed(let delay, let touchClose): - result = touchClose - case .ManualClose(let touchClose): - result = touchClose - } - - return result - } - - } - - - public enum SpinnerMode { - - case IndeterminateSpinner - case DeterminateSpinner - case NoSpinner - - internal func toProgressModeHUD() -> MBProgressHUDMode { - switch self { - case IndeterminateSpinner: - return .Indeterminate - case DeterminateSpinner: - return .Determinate - case NoSpinner: - return .Text - } - } - - } - - - //MARK: Class methods - - public class func setHUDCustomView(newValue:UIView?) { - MBProgressHUDInstance.customView = newValue - } - - public class func setHUDCustomColor(newValue:UIColor?) { - MBProgressHUDInstance.customColor = newValue - } - - /* - * showHUDWithMessage shows an animated Progress HUD with the message and details provided. - */ - public func showHUDWithMessage(message:String?, - details:String? = nil, - closeMode:CloseMode = .ManualClose(false), - spinnerMode:SpinnerMode = .IndeterminateSpinner) { - - synchronized(BaseScreenletHudLock) { - if MBProgressHUDInstance.instance == nil { - MBProgressHUDInstance.instance = - MBProgressHUD.showHUDAddedTo(self.rootView(self), animated:true) - } - - MBProgressHUDInstance.instance?.customView = MBProgressHUDInstance.customView - MBProgressHUDInstance.instance?.color = MBProgressHUDInstance.customColor - MBProgressHUDInstance.instance!.mode = spinnerMode.toProgressModeHUD() - MBProgressHUDInstance.instance!.minShowTime = 0.5 - - if closeMode.allowCloseOnTouch() { - MBProgressHUDInstance.touchHandler = HUDTouchHandler() - MBProgressHUDInstance.instance!.addGestureRecognizer( - UITapGestureRecognizer( - target: MBProgressHUDInstance.touchHandler!, - action: "simpleTapDetected:")) - } - - if message != nil { - MBProgressHUDInstance.instance!.labelText = message - } - - MBProgressHUDInstance.instance!.detailsLabelText = (details ?? "") as String - - var closeDelay: Double? - - switch closeMode { - case .AutocloseComputedDelay(_): - closeDelay = Double.infinity - case .AutocloseDelayed(let delay, _): - closeDelay = delay - default: () - } - - MBProgressHUDInstance.instance!.show(true) - - if var delay = closeDelay { - if delay == Double.infinity { - // compute autodelay based on text's length - let len: Int = - count(MBProgressHUDInstance.instance!.labelText) + - count(MBProgressHUDInstance.instance!.detailsLabelText) - delay = 1.5 + (Double(len) * 0.01) - } - - MBProgressHUDInstance.instance!.hide(true, afterDelay: delay) - MBProgressHUDInstance.instance = nil - } - } - } - - public func showHUDAlert(#message: String, details: String? = nil) { - showHUDWithMessage(message, - details: details, - closeMode: .ManualClose(true), - spinnerMode: .NoSpinner) - } - - /* - * hideHUDWithMessage hides an existing animated Progress HUD displaying the message and - * details provided first for a few seconds, calculated based on the length of the message. - */ - public func hideHUDWithMessage(message:String, details:String? = nil) { - showHUDWithMessage(message, - details: details, - closeMode: .AutocloseComputedDelay(true), - spinnerMode: .NoSpinner) - } - - public func hideHUD() { - synchronized(BaseScreenletHudLock) { - if let instance = MBProgressHUDInstance.instance { - instance.hide(true) - MBProgressHUDInstance.instance = nil - } - } - } - - - //MARK: PRIVATE METHODS - - private func rootView(currentView:UIView) -> UIView { - if currentView.superview == nil { - return currentView; - } - - return rootView(currentView.superview!) - } - -} diff --git a/ios/Framework/Core/Base/BaseScreenlet.swift b/ios/Framework/Core/Base/BaseScreenlet.swift index eb0bc6d70d..489fa2a198 100644 --- a/ios/Framework/Core/Base/BaseScreenlet.swift +++ b/ios/Framework/Core/Base/BaseScreenlet.swift @@ -64,6 +64,8 @@ import QuartzCore private var _runningInteractors = [Interactor]() + private var _progressPresenter: ProgressPresenter? + //MARK: UIView @@ -75,6 +77,7 @@ import QuartzCore clipsToBounds = true screenletView = loadScreenletView() + _progressPresenter = MBProgressHUDPresenter() onCreated() } @@ -308,4 +311,53 @@ import QuartzCore return appliedTheme } + + // HUD + //MARK: Class methods + + public class func setHUDCustomView(newValue:UIView?) { + } + + public class func setHUDCustomColor(newValue:UIColor?) { + } + + public func showHUDWithMessage(message: String?, + details: String? = nil, + closeMode: ProgressCloseMode = .ManualClose, + spinnerMode: ProgressSpinnerMode = .IndeterminateSpinner) { + + assert(self._progressPresenter != nil, "ProgressPresenter must exist") + + _progressPresenter!.showHUDInView(self, + message: message, + details: details, + closeMode: closeMode, + spinnerMode: spinnerMode) + + } + + public func showHUDAlert(#message: String, details: String? = nil) { + assert(self._progressPresenter != nil, "ProgressPresenter must exist") + + _progressPresenter!.showHUDInView(self, + message: message, + details: details, + closeMode: .ManualClose_TouchClosable, + spinnerMode: .NoSpinner) + } + + public func hideHUDWithMessage(message:String, details:String? = nil) { + assert(self._progressPresenter != nil, "ProgressPresenter must exist") + + _progressPresenter!.hideHUDWithMessage(message) + } + + public func hideHUD() { + assert(self._progressPresenter != nil, "ProgressPresenter must exist") + + _progressPresenter!.hideHUD() + } + + + } diff --git a/ios/Framework/Core/Base/MBProgressHUDPresenter.swift b/ios/Framework/Core/Base/MBProgressHUDPresenter.swift new file mode 100644 index 0000000000..7c29bb8240 --- /dev/null +++ b/ios/Framework/Core/Base/MBProgressHUDPresenter.swift @@ -0,0 +1,179 @@ +/** +* Copyright (c) 2000-present Liferay, Inc. All rights reserved. +* +* This library is free software; you can redistribute it and/or modify it under +* the terms of the GNU Lesser General Public License as published by the Free +* Software Foundation; either version 2.1 of the License, or (at your option) +* any later version. +* +* This library is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +* details. +*/ +import Foundation + +#if LIFERAY_SCREENS_FRAMEWORK + import MBProgressHUD +#endif + + +internal let MBProgressHUDLock = "hud-lock" + + +@objc public class MBProgressHUDPresenter: ProgressPresenter { + + private var instance: MBProgressHUD? + + var customView: UIView? { + didSet { + instance!.customView = customView + } + } + + var customColor: UIColor? { + didSet { + instance!.color = customColor + } + } + + var customOpacity: Float = 0.8 { + didSet { + instance!.opacity = customOpacity + } + } + + internal dynamic func simpleTapDetected(recognizer: UIGestureRecognizer!) { + if let hud = recognizer.view as? MBProgressHUD { + hud.hide(true) + instance = nil + } + } + + public func showHUDInView(view: UIView) { + showHUDInView(view, + message: nil, + details: nil, + closeMode: .ManualClose, + spinnerMode: .IndeterminateSpinner) + } + + public func showHUDInView(view: UIView, message:String) { + showHUDInView(view, + message: message, + details: nil, + closeMode: .ManualClose, + spinnerMode: .IndeterminateSpinner) + } + + public func hideHUD() { + assert(self.instance != nil, "MBProgressHUD must exist") + + synchronized(MBProgressHUDLock) { + dispatch_in_main { + self.instance!.hide(true) + self.instance = nil + } + } + } + + public func hideHUDWithMessage(message: String) { + assert(self.instance != nil, "MBProgressHUD must exist") + + synchronized(MBProgressHUDLock) { + dispatch_in_main { + self.configureAndShowHUD(self.instance!, + message: message, + details: nil, + closeMode: .Autoclose_TouchClosable, + spinnerMode: .NoSpinner) + } + } + } + + public func showHUDInView(view: UIView, + message: String?, + details: String?, + closeMode: ProgressCloseMode, + spinnerMode: ProgressSpinnerMode) { + + synchronized(MBProgressHUDLock) { + dispatch_in_main { + if self.instance == nil { + self.instance = MBProgressHUD.showHUDAddedTo(view, animated:true) + } + + self.configureAndShowHUD(self.instance!, + message: message, + details: details, + closeMode: closeMode, + spinnerMode: spinnerMode) + } + } + } + + + //MARK: PRIVATE METHODS + + private func configureAndShowHUD(hud: MBProgressHUD, + message: String?, + details: String?, + closeMode: ProgressCloseMode, + spinnerMode: ProgressSpinnerMode) { + + let hud = self.instance! + + hud.customView = self.customView + hud.color = self.customColor + hud.mode = spinnerModeToProgressModeHUD(spinnerMode) + hud.minShowTime = 0.5 + + if closeMode == .ManualClose_TouchClosable + || closeMode == .Autoclose_TouchClosable { + hud.addGestureRecognizer( + UITapGestureRecognizer( + target: self, + action: "simpleTapDetected:")) + } + + if message != nil { + hud.labelText = message + } + + hud.detailsLabelText = (details ?? "") as String + + hud.show(true) + + if closeMode == .Autoclose_TouchClosable { + // compute autodelay based on text's length + let len = count(hud.labelText) + count(hud.detailsLabelText) + let closeDelay = 1.5 + (Double(len) * 0.01) + + hud.hide(true, afterDelay: closeDelay) + + self.instance = nil + } + } + + + private func rootView(currentView:UIView) -> UIView { + if currentView.superview == nil { + return currentView; + } + + return rootView(currentView.superview!) + } + + private func spinnerModeToProgressModeHUD(spinnerMode: ProgressSpinnerMode) -> MBProgressHUDMode { + switch spinnerMode { + case .IndeterminateSpinner: + return .Indeterminate + case .DeterminateSpinner: + return .Determinate + case .NoSpinner: + return .Text + } + } + +} + diff --git a/ios/Framework/Core/Base/ProgressPresenter.swift b/ios/Framework/Core/Base/ProgressPresenter.swift new file mode 100644 index 0000000000..dd65fec281 --- /dev/null +++ b/ios/Framework/Core/Base/ProgressPresenter.swift @@ -0,0 +1,49 @@ +/** +* Copyright (c) 2000-present Liferay, Inc. All rights reserved. +* +* This library is free software; you can redistribute it and/or modify it under +* the terms of the GNU Lesser General Public License as published by the Free +* Software Foundation; either version 2.1 of the License, or (at your option) +* any later version. +* +* This library is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +* details. +*/ +import Foundation + + +@objc public enum ProgressCloseMode: Int { + + case ManualClose + case ManualClose_TouchClosable + + case Autoclose + case Autoclose_TouchClosable +} + + +@objc public enum ProgressSpinnerMode: Int { + + case IndeterminateSpinner + case DeterminateSpinner + case NoSpinner + +} + +@objc public protocol ProgressPresenter { + + func showHUDInView(view: UIView) + func showHUDInView(view: UIView, message:String) + func showHUDInView(view: UIView, + message: String?, + details: String?, + closeMode: ProgressCloseMode, + spinnerMode: ProgressSpinnerMode) + + func hideHUD() + func hideHUDWithMessage(message:String) + +} + diff --git a/ios/Framework/Core/Base/ServerOperation.swift b/ios/Framework/Core/Base/ServerOperation.swift index cb2520a764..3178f4d8e8 100644 --- a/ios/Framework/Core/Base/ServerOperation.swift +++ b/ios/Framework/Core/Base/ServerOperation.swift @@ -152,8 +152,8 @@ public class ServerOperation: NSOperation { internal func showHUD( #message: String, details: String?, - closeMode: BaseScreenlet.CloseMode, - spinnerMode: BaseScreenlet.SpinnerMode) { + closeMode: ProgressCloseMode, + spinnerMode: ProgressSpinnerMode) { dispatch_async(dispatch_get_main_queue()) { self.screenlet.showHUDWithMessage(message, @@ -170,33 +170,25 @@ public class ServerOperation: NSOperation { } internal func hideHUD() { - dispatch_async(dispatch_get_main_queue()) { - self.screenlet.hideHUD() - } + self.screenlet.hideHUD() } internal func hideHUD(#message: String, details: String? = nil) { - dispatch_async(dispatch_get_main_queue()) { - self.screenlet.hideHUDWithMessage(message, details: details) - } + self.screenlet.hideHUDWithMessage(message, details: details) } internal func hideHUD(#errorMessage: String, details: String? = nil) { - dispatch_async(dispatch_get_main_queue()) { - self.screenlet.showHUDWithMessage(errorMessage, - details: details, - closeMode: .ManualClose(true), - spinnerMode:.NoSpinner) - } + self.screenlet.showHUDWithMessage(errorMessage, + details: details, + closeMode: .ManualClose_TouchClosable, + spinnerMode: .NoSpinner) } internal func hideHUD(#error: NSError, message: String, details: String? = nil) { - dispatch_async(dispatch_get_main_queue()) { - self.screenlet.showHUDWithMessage(message, - details: details, - closeMode:.ManualClose(true), - spinnerMode:.NoSpinner) - } + self.screenlet.showHUDWithMessage(message, + details: details, + closeMode: .ManualClose_TouchClosable, + spinnerMode: .NoSpinner) } diff --git a/ios/Framework/Core/DDL/FormScreenlet/ServerOperations/LiferayDDLFormSubmitOperation.swift b/ios/Framework/Core/DDL/FormScreenlet/ServerOperations/LiferayDDLFormSubmitOperation.swift index f836616ec2..e8f48314ad 100644 --- a/ios/Framework/Core/DDL/FormScreenlet/ServerOperations/LiferayDDLFormSubmitOperation.swift +++ b/ios/Framework/Core/DDL/FormScreenlet/ServerOperations/LiferayDDLFormSubmitOperation.swift @@ -58,7 +58,7 @@ public class LiferayDDLFormSubmitOperation: ServerOperation { if valid && !viewModel.validateForm(autoscroll: autoscrollOnValidation) { showHUD(message: LocalizedString("ddlform-screenlet", "validation", self), details: LocalizedString("ddlform-screenlet", "validation-details", self), - closeMode: .AutocloseDelayed(3.0, true), + closeMode: .Autoclose_TouchClosable, spinnerMode: .NoSpinner) valid = false diff --git a/ios/Framework/Core/Extensions/Global.swift b/ios/Framework/Core/Extensions/Global.swift index 93792458db..cbc3b35992 100644 --- a/ios/Framework/Core/Extensions/Global.swift +++ b/ios/Framework/Core/Extensions/Global.swift @@ -37,6 +37,17 @@ public func delayed(delay: NSTimeInterval, block: dispatch_block_t) { dispatch_after(time, dispatch_get_main_queue(), block) } +public func dispatch_in_main(block: dispatch_block_t) { + if NSThread.isMainThread() { + block() + } + else { + dispatch_async(dispatch_get_main_queue()) { + block() + } + } +} + public func LocalizedString(tableName: String, var key: String, obj: AnyObject) -> String { key = "\(tableName)-\(key)" diff --git a/ios/Framework/LiferayScreens.xcodeproj/project.pbxproj b/ios/Framework/LiferayScreens.xcodeproj/project.pbxproj index 194b4cc285..df4877bc6d 100644 --- a/ios/Framework/LiferayScreens.xcodeproj/project.pbxproj +++ b/ios/Framework/LiferayScreens.xcodeproj/project.pbxproj @@ -29,7 +29,6 @@ 880ACA8A1B0224A0007AD007 /* webcontentdisplay-screenlet.strings in Resources */ = {isa = PBXBuildFile; fileRef = 880ACA731B0224A0007AD007 /* webcontentdisplay-screenlet.strings */; }; 880ACA8B1B0224A0007AD007 /* liferay-server-context-sample.plist in Resources */ = {isa = PBXBuildFile; fileRef = 880ACA7C1B0224A0007AD007 /* liferay-server-context-sample.plist */; }; 880ACA8C1B0224A0007AD007 /* liferay-server-context-sample.plist in Resources */ = {isa = PBXBuildFile; fileRef = 880ACA7C1B0224A0007AD007 /* liferay-server-context-sample.plist */; }; - 881E60B81ACBE3FF00862B9E /* BaseScreenlet+progress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881E60B51ACBE3FF00862B9E /* BaseScreenlet+progress.swift */; }; 881E60B91ACBE3FF00862B9E /* BaseScreenlet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881E60B61ACBE3FF00862B9E /* BaseScreenlet.swift */; }; 881E60BA1ACBE3FF00862B9E /* BaseScreenletView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881E60B71ACBE3FF00862B9E /* BaseScreenletView.swift */; }; 881E60BF1ACBE43200862B9E /* Interactor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881E60BB1ACBE43200862B9E /* Interactor.swift */; }; @@ -198,7 +197,6 @@ 881E62961ACBFEFC00862B9E /* BaseListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881E60C81ACBE56700862B9E /* BaseListView.swift */; }; 881E62971ACBFF0400862B9E /* LiferayPaginationOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881E60CA1ACBE56700862B9E /* LiferayPaginationOperation.swift */; }; 881E62981ACBFF0800862B9E /* BaseListTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881E60CC1ACBE56700862B9E /* BaseListTableView.swift */; }; - 881E62991ACBFF1800862B9E /* BaseScreenlet+progress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881E60B51ACBE3FF00862B9E /* BaseScreenlet+progress.swift */; }; 881E629A1ACBFF1800862B9E /* Interactor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881E60BB1ACBE43200862B9E /* Interactor.swift */; }; 881E629B1ACBFF1800862B9E /* KeyboardManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881E60BC1ACBE43200862B9E /* KeyboardManager.swift */; }; 881E629C1ACBFF1800862B9E /* ServerOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881E60BD1ACBE43200862B9E /* ServerOperation.swift */; }; @@ -288,6 +286,10 @@ 88A2B7181ACDEC29000C2065 /* DDLListView_test.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88A2B7161ACDEC29000C2065 /* DDLListView_test.swift */; }; 88A2B7191ACDEC29000C2065 /* DDLListView_test.xib in Resources */ = {isa = PBXBuildFile; fileRef = 88A2B7171ACDEC29000C2065 /* DDLListView_test.xib */; }; 88A2B71E1ACDEF5D000C2065 /* LoginView_default.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881E61C31ACBFC3400862B9E /* LoginView_default.swift */; }; + 88B2730F1B7107F200477E5E /* ProgressPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88B2730E1B7107F200477E5E /* ProgressPresenter.swift */; }; + 88B273101B7107F200477E5E /* ProgressPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88B2730E1B7107F200477E5E /* ProgressPresenter.swift */; }; + 88B273151B7109E200477E5E /* MBProgressHUDPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88B273141B7109E200477E5E /* MBProgressHUDPresenter.swift */; }; + 88B273161B7109E200477E5E /* MBProgressHUDPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88B273141B7109E200477E5E /* MBProgressHUDPresenter.swift */; }; 88CA805B1B25AF48004C1D59 /* LoginInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88CA80581B25AF48004C1D59 /* LoginInteractor.swift */; }; 88CA805C1B25AF48004C1D59 /* LoginInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88CA80581B25AF48004C1D59 /* LoginInteractor.swift */; }; 88CA805D1B25AF48004C1D59 /* OAuthInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88CA80591B25AF48004C1D59 /* OAuthInteractor.swift */; }; @@ -373,7 +375,6 @@ 880ACA7A1B0224A0007AD007 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = "es.lproj/userportrait-screenlet.strings"; sourceTree = ""; }; 880ACA7B1B0224A0007AD007 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = "es.lproj/webcontentdisplay-screenlet.strings"; sourceTree = ""; }; 880ACA7C1B0224A0007AD007 /* liferay-server-context-sample.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "liferay-server-context-sample.plist"; sourceTree = ""; }; - 881E60B51ACBE3FF00862B9E /* BaseScreenlet+progress.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "BaseScreenlet+progress.swift"; sourceTree = ""; }; 881E60B61ACBE3FF00862B9E /* BaseScreenlet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseScreenlet.swift; sourceTree = ""; }; 881E60B71ACBE3FF00862B9E /* BaseScreenletView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseScreenletView.swift; sourceTree = ""; }; 881E60BB1ACBE43200862B9E /* Interactor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Interactor.swift; sourceTree = ""; }; @@ -571,6 +572,8 @@ 88A2B7131ACDEBB1000C2065 /* LoginView_test.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LoginView_test.xib; sourceTree = ""; }; 88A2B7161ACDEC29000C2065 /* DDLListView_test.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DDLListView_test.swift; sourceTree = ""; }; 88A2B7171ACDEC29000C2065 /* DDLListView_test.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = DDLListView_test.xib; sourceTree = ""; }; + 88B2730E1B7107F200477E5E /* ProgressPresenter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProgressPresenter.swift; sourceTree = ""; }; + 88B273141B7109E200477E5E /* MBProgressHUDPresenter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MBProgressHUDPresenter.swift; sourceTree = ""; }; 88CA80581B25AF48004C1D59 /* LoginInteractor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoginInteractor.swift; sourceTree = ""; }; 88CA80591B25AF48004C1D59 /* OAuthInteractor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OAuthInteractor.swift; sourceTree = ""; }; 88CA805A1B25AF48004C1D59 /* OAuthWebViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OAuthWebViewController.swift; sourceTree = ""; }; @@ -681,12 +684,13 @@ children = ( 881E60C51ACBE56700862B9E /* BaseListScreenlet */, 881E60B61ACBE3FF00862B9E /* BaseScreenlet.swift */, - 881E60B51ACBE3FF00862B9E /* BaseScreenlet+progress.swift */, 881E60B71ACBE3FF00862B9E /* BaseScreenletView.swift */, 881E60BB1ACBE43200862B9E /* Interactor.swift */, 881E60BC1ACBE43200862B9E /* KeyboardManager.swift */, 881E60BD1ACBE43200862B9E /* ServerOperation.swift */, 881E60BE1ACBE43200862B9E /* ServerOperationInteractor.swift */, + 88B2730E1B7107F200477E5E /* ProgressPresenter.swift */, + 88B273141B7109E200477E5E /* MBProgressHUDPresenter.swift */, ); name = Base; path = Core/Base; @@ -1878,6 +1882,7 @@ 881E623A1ACBFC3400862B9E /* DDLFieldDocumentlibraryTableCell_default.swift in Sources */, 881E60BA1ACBE3FF00862B9E /* BaseScreenletView.swift in Sources */, 8892C6AE1ACBD89400192232 /* NSLocale+CurrentLocale.swift in Sources */, + 88B2730F1B7107F200477E5E /* ProgressPresenter.swift in Sources */, 881E62401ACBFC3400862B9E /* DDLFieldSelectTableCell_default.swift in Sources */, 881E62381ACBFC3400862B9E /* DDLFieldDocumentlibraryPresenterViewController_default.swift in Sources */, 881E61131ACBE5F000862B9E /* LiferayForgotPasswordUserIdOperation.swift in Sources */, @@ -1896,7 +1901,6 @@ 881E61941ACBEE0B00862B9E /* DDLRecord.swift in Sources */, 8839B8801B0CD546006C18F1 /* LiferayUpdateCurrentUserOperation.swift in Sources */, 881E61861ACBEE0B00862B9E /* DDLListPageLoadInteractor.swift in Sources */, - 881E60B81ACBE3FF00862B9E /* BaseScreenlet+progress.swift in Sources */, 88CA80631B25D6EA004C1D59 /* BasicAuthBased.swift in Sources */, 8839B88A1B0CD5C4006C18F1 /* GetUserBaseOperation.swift in Sources */, 888DF5B21ACC9FC200EB7DA1 /* LoginViewModel.swift in Sources */, @@ -1905,6 +1909,7 @@ 881E61881ACBEE0B00862B9E /* DDLListViewModel.swift in Sources */, 881E60CD1ACBE56700862B9E /* BaseListPageLoadInteractor.swift in Sources */, 881E60BF1ACBE43200862B9E /* Interactor.swift in Sources */, + 88B273151B7109E200477E5E /* MBProgressHUDPresenter.swift in Sources */, 881E624D1ACBFC3400862B9E /* DefaultThemeConstants.swift in Sources */, 881E62471ACBFC3400862B9E /* DDLFormView_default.swift in Sources */, 881E61781ACBEE0B00862B9E /* DDLFormScreenlet.swift in Sources */, @@ -1922,7 +1927,6 @@ 8839B88B1B0CD5C4006C18F1 /* GetUserBaseOperation.swift in Sources */, 88A28EBB1B0DD1300040D7F6 /* NSBundle+discovery.swift in Sources */, 88DE25151AD2AB0A00714701 /* DDLFieldDocument_Tests.swift in Sources */, - 881E62991ACBFF1800862B9E /* BaseScreenlet+progress.swift in Sources */, 88DE25101AD2AB0A00714701 /* SessionContext_Basic_Tests.swift in Sources */, 88DE251C1AD2AB0A00714701 /* DDLRecord_FieldValues_Tests.swift in Sources */, 88DE250F1AD2AB0A00714701 /* LiferayServerContext_Load_Tests.swift in Sources */, @@ -1941,6 +1945,7 @@ 88DE25161AD2AB0A00714701 /* DDLFieldNumber_Tests.swift in Sources */, 881E62FA1ACC05B500862B9E /* DDLListPageLoadInteractor.swift in Sources */, 88A2B7141ACDEBB1000C2065 /* LoginView_test.swift in Sources */, + 88B273101B7107F200477E5E /* ProgressPresenter.swift in Sources */, 88DE251B1AD2AB0A00714701 /* DDLParser_i18n_Tests.swift in Sources */, 88CA80721B25EF69004C1D59 /* BaseCredentialsStoreKeyChain.swift in Sources */, 881E62F41ACC04BA00862B9E /* DDLValuesParser.swift in Sources */, @@ -1960,6 +1965,7 @@ 881E63051ACC06B900862B9E /* BaseLoginScreenletTestCase.swift in Sources */, 881E61A81ACBF97000862B9E /* uBDD.swift in Sources */, 88DE25181AD2AB0A00714701 /* DDLFieldStringWithOptions_Tests.swift in Sources */, + 88B273161B7109E200477E5E /* MBProgressHUDPresenter.swift in Sources */, 88CA806F1B25EE04004C1D59 /* CredentialsStore.swift in Sources */, 881E62E91ACC04A500862B9E /* DDLField+DataType.swift in Sources */, 881E629D1ACBFF1800862B9E /* ServerOperationInteractor.swift in Sources */, From c2781205c7a3b1ae9396b734550e07323f5cbaac Mon Sep 17 00:00:00 2001 From: JM Date: Wed, 5 Aug 2015 14:06:58 +0200 Subject: [PATCH 020/365] LSR-239 Progress presenter for default theme and creation pattern --- ios/Framework/Core/Base/BaseScreenlet.swift | 8 ++++- .../Core/Base/MBProgressHUDPresenter.swift | 2 +- .../Core/Base/ProgressPresenter.swift | 5 +++ .../LiferayScreens.xcodeproj/project.pbxproj | 6 ++++ .../LoginScreenlet/LoginView_default.swift | 3 -- .../Default/DefaultProgressPresenter.swift | 34 +++++++++++++++++++ 6 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 ios/Framework/Themes/Default/DefaultProgressPresenter.swift diff --git a/ios/Framework/Core/Base/BaseScreenlet.swift b/ios/Framework/Core/Base/BaseScreenlet.swift index 489fa2a198..dca760940b 100644 --- a/ios/Framework/Core/Base/BaseScreenlet.swift +++ b/ios/Framework/Core/Base/BaseScreenlet.swift @@ -77,7 +77,13 @@ import QuartzCore clipsToBounds = true screenletView = loadScreenletView() - _progressPresenter = MBProgressHUDPresenter() + + if let creator = screenletView as? ProgressPresenterCreator { + _progressPresenter = creator.createProgressPresenter() + } + else { + _progressPresenter = MBProgressHUDPresenter() + } onCreated() } diff --git a/ios/Framework/Core/Base/MBProgressHUDPresenter.swift b/ios/Framework/Core/Base/MBProgressHUDPresenter.swift index 7c29bb8240..9377cf3eb9 100644 --- a/ios/Framework/Core/Base/MBProgressHUDPresenter.swift +++ b/ios/Framework/Core/Base/MBProgressHUDPresenter.swift @@ -21,7 +21,7 @@ import Foundation internal let MBProgressHUDLock = "hud-lock" -@objc public class MBProgressHUDPresenter: ProgressPresenter { +@objc public class MBProgressHUDPresenter: NSObject, ProgressPresenter { private var instance: MBProgressHUD? diff --git a/ios/Framework/Core/Base/ProgressPresenter.swift b/ios/Framework/Core/Base/ProgressPresenter.swift index dd65fec281..0c17c31369 100644 --- a/ios/Framework/Core/Base/ProgressPresenter.swift +++ b/ios/Framework/Core/Base/ProgressPresenter.swift @@ -47,3 +47,8 @@ import Foundation } +@objc protocol ProgressPresenterCreator { + + func createProgressPresenter() -> ProgressPresenter + +} diff --git a/ios/Framework/LiferayScreens.xcodeproj/project.pbxproj b/ios/Framework/LiferayScreens.xcodeproj/project.pbxproj index df4877bc6d..b203c062ea 100644 --- a/ios/Framework/LiferayScreens.xcodeproj/project.pbxproj +++ b/ios/Framework/LiferayScreens.xcodeproj/project.pbxproj @@ -288,6 +288,8 @@ 88A2B71E1ACDEF5D000C2065 /* LoginView_default.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881E61C31ACBFC3400862B9E /* LoginView_default.swift */; }; 88B2730F1B7107F200477E5E /* ProgressPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88B2730E1B7107F200477E5E /* ProgressPresenter.swift */; }; 88B273101B7107F200477E5E /* ProgressPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88B2730E1B7107F200477E5E /* ProgressPresenter.swift */; }; + 88B273121B7109C300477E5E /* DefaultProgressPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88B273111B7109C300477E5E /* DefaultProgressPresenter.swift */; }; + 88B273131B7109C300477E5E /* DefaultProgressPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88B273111B7109C300477E5E /* DefaultProgressPresenter.swift */; }; 88B273151B7109E200477E5E /* MBProgressHUDPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88B273141B7109E200477E5E /* MBProgressHUDPresenter.swift */; }; 88B273161B7109E200477E5E /* MBProgressHUDPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88B273141B7109E200477E5E /* MBProgressHUDPresenter.swift */; }; 88CA805B1B25AF48004C1D59 /* LoginInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88CA80581B25AF48004C1D59 /* LoginInteractor.swift */; }; @@ -573,6 +575,7 @@ 88A2B7161ACDEC29000C2065 /* DDLListView_test.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DDLListView_test.swift; sourceTree = ""; }; 88A2B7171ACDEC29000C2065 /* DDLListView_test.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = DDLListView_test.xib; sourceTree = ""; }; 88B2730E1B7107F200477E5E /* ProgressPresenter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProgressPresenter.swift; sourceTree = ""; }; + 88B273111B7109C300477E5E /* DefaultProgressPresenter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DefaultProgressPresenter.swift; sourceTree = ""; }; 88B273141B7109E200477E5E /* MBProgressHUDPresenter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MBProgressHUDPresenter.swift; sourceTree = ""; }; 88CA80581B25AF48004C1D59 /* LoginInteractor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoginInteractor.swift; sourceTree = ""; }; 88CA80591B25AF48004C1D59 /* OAuthInteractor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OAuthInteractor.swift; sourceTree = ""; }; @@ -992,6 +995,7 @@ 881E61BB1ACBFC3400862B9E /* AssetListScreenlet */, 881E61BE1ACBFC3400862B9E /* Auth */, 881E61CB1ACBFC3400862B9E /* DDL */, + 88B273111B7109C300477E5E /* DefaultProgressPresenter.swift */, 881E61E91ACBFC3400862B9E /* DefaultThemeConstants.swift */, 881E61EA1ACBFC3400862B9E /* Resources */, 881E620A1ACBFC3400862B9E /* WebContentDisplayScreenlet */, @@ -1830,6 +1834,7 @@ 88CA80741B25F868004C1D59 /* OAuthCredentialsStoreKeyChain.swift in Sources */, 881E618E1ACBEE0B00862B9E /* DDLFieldDate.swift in Sources */, 881E61811ACBEE0B00862B9E /* LiferayDDLFormRecordLoadOperation.swift in Sources */, + 88B273121B7109C300477E5E /* DefaultProgressPresenter.swift in Sources */, 88CA805B1B25AF48004C1D59 /* LoginInteractor.swift in Sources */, 88CA80661B25D72A004C1D59 /* AuthType.swift in Sources */, 88CA806B1B25E953004C1D59 /* NSError+Screens.swift in Sources */, @@ -1967,6 +1972,7 @@ 88DE25181AD2AB0A00714701 /* DDLFieldStringWithOptions_Tests.swift in Sources */, 88B273161B7109E200477E5E /* MBProgressHUDPresenter.swift in Sources */, 88CA806F1B25EE04004C1D59 /* CredentialsStore.swift in Sources */, + 88B273131B7109C300477E5E /* DefaultProgressPresenter.swift in Sources */, 881E62E91ACC04A500862B9E /* DDLField+DataType.swift in Sources */, 881E629D1ACBFF1800862B9E /* ServerOperationInteractor.swift in Sources */, 881E61AC1ACBFAE100862B9E /* IntegrationTestCase.swift in Sources */, diff --git a/ios/Framework/Themes/Default/Auth/LoginScreenlet/LoginView_default.swift b/ios/Framework/Themes/Default/Auth/LoginScreenlet/LoginView_default.swift index 71164600e5..23c01efde9 100644 --- a/ios/Framework/Themes/Default/Auth/LoginScreenlet/LoginView_default.swift +++ b/ios/Framework/Themes/Default/Auth/LoginScreenlet/LoginView_default.swift @@ -60,7 +60,6 @@ public class LoginView_default: BaseScreenletView, LoginViewModel { } - //MARK: LoginViewModel public var userName: String? { @@ -90,8 +89,6 @@ public class LoginView_default: BaseScreenletView, LoginViewModel { setButtonDefaultStyle(loginButton) setButtonDefaultStyle(authorizeButton) - BaseScreenlet.setHUDCustomColor(DefaultThemeBasicBlue) - configureAuthType() } diff --git a/ios/Framework/Themes/Default/DefaultProgressPresenter.swift b/ios/Framework/Themes/Default/DefaultProgressPresenter.swift new file mode 100644 index 0000000000..1ce47b5340 --- /dev/null +++ b/ios/Framework/Themes/Default/DefaultProgressPresenter.swift @@ -0,0 +1,34 @@ +/** +* Copyright (c) 2000-present Liferay, Inc. All rights reserved. +* +* This library is free software; you can redistribute it and/or modify it under +* the terms of the GNU Lesser General Public License as published by the Free +* Software Foundation; either version 2.1 of the License, or (at your option) +* any later version. +* +* This library is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +* details. +*/ +import Foundation + + +@objc public class DefaultProgressPresenter: MBProgressHUDPresenter { + + override public init() { + super.init() + + self.customColor = DefaultThemeBasicBlue + } + +} + + +extension BaseScreenletView: ProgressPresenterCreator { + + public func createProgressPresenter() -> ProgressPresenter { + return DefaultProgressPresenter() + } + +} From 06c210141ea9056dd10e0c1c0b76ff88d5698077 Mon Sep 17 00:00:00 2001 From: JM Date: Wed, 5 Aug 2015 19:49:33 +0200 Subject: [PATCH 021/365] LSR-239 Changed presenter creation pattern --- ios/Framework/Core/Base/BaseScreenlet.swift | 13 +--------- .../Core/Base/BaseScreenletView.swift | 4 +++ .../Core/Base/MBProgressHUDPresenter.swift | 26 +++++-------------- .../Default/DefaultProgressPresenter.swift | 9 ------- 4 files changed, 12 insertions(+), 40 deletions(-) diff --git a/ios/Framework/Core/Base/BaseScreenlet.swift b/ios/Framework/Core/Base/BaseScreenlet.swift index dca760940b..8d15f85900 100644 --- a/ios/Framework/Core/Base/BaseScreenlet.swift +++ b/ios/Framework/Core/Base/BaseScreenlet.swift @@ -78,12 +78,7 @@ import QuartzCore screenletView = loadScreenletView() - if let creator = screenletView as? ProgressPresenterCreator { - _progressPresenter = creator.createProgressPresenter() - } - else { - _progressPresenter = MBProgressHUDPresenter() - } + _progressPresenter = screenletView?.createProgressPresenter() onCreated() } @@ -321,12 +316,6 @@ import QuartzCore // HUD //MARK: Class methods - public class func setHUDCustomView(newValue:UIView?) { - } - - public class func setHUDCustomColor(newValue:UIColor?) { - } - public func showHUDWithMessage(message: String?, details: String? = nil, closeMode: ProgressCloseMode = .ManualClose, diff --git a/ios/Framework/Core/Base/BaseScreenletView.swift b/ios/Framework/Core/Base/BaseScreenletView.swift index 51b49d361e..8f20290177 100644 --- a/ios/Framework/Core/Base/BaseScreenletView.swift +++ b/ios/Framework/Core/Base/BaseScreenletView.swift @@ -169,6 +169,10 @@ public class BaseScreenletView: UIView, UITextFieldDelegate { public func onFinishOperation() { } + public func createProgressPresenter() -> ProgressPresenter { + return MBProgressHUDPresenter() + } + public func userActionWithSender(sender: AnyObject?) { if let controlSender = sender as? UIControl { userAction(name: controlSender.restorationIdentifier, sender: sender) diff --git a/ios/Framework/Core/Base/MBProgressHUDPresenter.swift b/ios/Framework/Core/Base/MBProgressHUDPresenter.swift index 9377cf3eb9..fa3c2d1e24 100644 --- a/ios/Framework/Core/Base/MBProgressHUDPresenter.swift +++ b/ios/Framework/Core/Base/MBProgressHUDPresenter.swift @@ -25,23 +25,9 @@ internal let MBProgressHUDLock = "hud-lock" private var instance: MBProgressHUD? - var customView: UIView? { - didSet { - instance!.customView = customView - } - } - - var customColor: UIColor? { - didSet { - instance!.color = customColor - } - } - - var customOpacity: Float = 0.8 { - didSet { - instance!.opacity = customOpacity - } - } + var customView: UIView? + var customColor: UIColor? + var customOpacity = Float(0.8) internal dynamic func simpleTapDetected(recognizer: UIGestureRecognizer!) { if let hud = recognizer.view as? MBProgressHUD { @@ -123,8 +109,10 @@ internal let MBProgressHUDLock = "hud-lock" let hud = self.instance! - hud.customView = self.customView - hud.color = self.customColor + hud.customView = customView + hud.color = customColor + hud.opacity = customOpacity + hud.mode = spinnerModeToProgressModeHUD(spinnerMode) hud.minShowTime = 0.5 diff --git a/ios/Framework/Themes/Default/DefaultProgressPresenter.swift b/ios/Framework/Themes/Default/DefaultProgressPresenter.swift index 1ce47b5340..3e6155fe33 100644 --- a/ios/Framework/Themes/Default/DefaultProgressPresenter.swift +++ b/ios/Framework/Themes/Default/DefaultProgressPresenter.swift @@ -23,12 +23,3 @@ import Foundation } } - - -extension BaseScreenletView: ProgressPresenterCreator { - - public func createProgressPresenter() -> ProgressPresenter { - return DefaultProgressPresenter() - } - -} From 6a8a8ef0e88c45748a60b4b78c8ed38a3e2f40cd Mon Sep 17 00:00:00 2001 From: JM Date: Wed, 5 Aug 2015 19:53:51 +0200 Subject: [PATCH 022/365] LSR-239 Add ProgressPresenter to default and flat7 themes --- .../LiferayScreens.xcodeproj/project.pbxproj | 6 +++++ .../AssetListView_default.swift | 6 +++++ .../ForgotPasswordView_default.swift | 6 +++-- .../LoginScreenlet/LoginView_default.swift | 4 +++ .../SignUpScreenlet/SignUpView_default.swift | 7 +++-- .../FormScreenlet/DDLFormView_default.swift | 6 +++-- .../ListScreenlet/DDLListView_default.swift | 6 ++--- .../WebContentDisplayView_default.swift | 8 +++--- .../ForgotPasswordView_flat7.swift | 6 +++-- .../Auth/LoginScreenlet/LoginView_flat7.swift | 6 +++-- .../SignUpScreenlet/SignUpView_flat7.swift | 6 +++-- .../Themes/Flat7/Flat7ProgressPresenter.swift | 26 +++++++++++++++++++ .../Themes/Flat7/Flat7ThemeConstants.swift | 4 +-- 13 files changed, 75 insertions(+), 22 deletions(-) create mode 100644 ios/Framework/Themes/Flat7/Flat7ProgressPresenter.swift diff --git a/ios/Framework/LiferayScreens.xcodeproj/project.pbxproj b/ios/Framework/LiferayScreens.xcodeproj/project.pbxproj index b203c062ea..aab8901be5 100644 --- a/ios/Framework/LiferayScreens.xcodeproj/project.pbxproj +++ b/ios/Framework/LiferayScreens.xcodeproj/project.pbxproj @@ -29,6 +29,8 @@ 880ACA8A1B0224A0007AD007 /* webcontentdisplay-screenlet.strings in Resources */ = {isa = PBXBuildFile; fileRef = 880ACA731B0224A0007AD007 /* webcontentdisplay-screenlet.strings */; }; 880ACA8B1B0224A0007AD007 /* liferay-server-context-sample.plist in Resources */ = {isa = PBXBuildFile; fileRef = 880ACA7C1B0224A0007AD007 /* liferay-server-context-sample.plist */; }; 880ACA8C1B0224A0007AD007 /* liferay-server-context-sample.plist in Resources */ = {isa = PBXBuildFile; fileRef = 880ACA7C1B0224A0007AD007 /* liferay-server-context-sample.plist */; }; + 881AFC4A1B7278B700A6A59A /* Flat7ProgressPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881AFC491B7278B700A6A59A /* Flat7ProgressPresenter.swift */; }; + 881AFC4B1B7278B700A6A59A /* Flat7ProgressPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881AFC491B7278B700A6A59A /* Flat7ProgressPresenter.swift */; }; 881E60B91ACBE3FF00862B9E /* BaseScreenlet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881E60B61ACBE3FF00862B9E /* BaseScreenlet.swift */; }; 881E60BA1ACBE3FF00862B9E /* BaseScreenletView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881E60B71ACBE3FF00862B9E /* BaseScreenletView.swift */; }; 881E60BF1ACBE43200862B9E /* Interactor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881E60BB1ACBE43200862B9E /* Interactor.swift */; }; @@ -377,6 +379,7 @@ 880ACA7A1B0224A0007AD007 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = "es.lproj/userportrait-screenlet.strings"; sourceTree = ""; }; 880ACA7B1B0224A0007AD007 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = "es.lproj/webcontentdisplay-screenlet.strings"; sourceTree = ""; }; 880ACA7C1B0224A0007AD007 /* liferay-server-context-sample.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "liferay-server-context-sample.plist"; sourceTree = ""; }; + 881AFC491B7278B700A6A59A /* Flat7ProgressPresenter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Flat7ProgressPresenter.swift; sourceTree = ""; }; 881E60B61ACBE3FF00862B9E /* BaseScreenlet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseScreenlet.swift; sourceTree = ""; }; 881E60B71ACBE3FF00862B9E /* BaseScreenletView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseScreenletView.swift; sourceTree = ""; }; 881E60BB1ACBE43200862B9E /* Interactor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Interactor.swift; sourceTree = ""; }; @@ -1158,6 +1161,7 @@ isa = PBXGroup; children = ( 881E620E1ACBFC3400862B9E /* Auth */, + 881AFC491B7278B700A6A59A /* Flat7ProgressPresenter.swift */, 881E621B1ACBFC3400862B9E /* Flat7ThemeConstants.swift */, 881E621C1ACBFC3400862B9E /* Resources */, ); @@ -1905,6 +1909,7 @@ 881E622A1ACBFC3400862B9E /* ForgotPasswordView_default.swift in Sources */, 881E61941ACBEE0B00862B9E /* DDLRecord.swift in Sources */, 8839B8801B0CD546006C18F1 /* LiferayUpdateCurrentUserOperation.swift in Sources */, + 881AFC4A1B7278B700A6A59A /* Flat7ProgressPresenter.swift in Sources */, 881E61861ACBEE0B00862B9E /* DDLListPageLoadInteractor.swift in Sources */, 88CA80631B25D6EA004C1D59 /* BasicAuthBased.swift in Sources */, 8839B88A1B0CD5C4006C18F1 /* GetUserBaseOperation.swift in Sources */, @@ -1963,6 +1968,7 @@ 881E629B1ACBFF1800862B9E /* KeyboardManager.swift in Sources */, 881E628F1ACBFE8300862B9E /* BaseScreenlet.swift in Sources */, 8839B88F1B0CD5C4006C18F1 /* GetUserByScreenNameOperation.swift in Sources */, + 881AFC4B1B7278B700A6A59A /* Flat7ProgressPresenter.swift in Sources */, 881E62F81ACC050200862B9E /* DDLListViewModel.swift in Sources */, 88DE25191AD2AB0A00714701 /* DDLListScreenlet_ParseFields_Tests.swift in Sources */, 88CA80601B25AF48004C1D59 /* OAuthWebViewController.swift in Sources */, diff --git a/ios/Framework/Themes/Default/AssetListScreenlet/AssetListView_default.swift b/ios/Framework/Themes/Default/AssetListScreenlet/AssetListView_default.swift index c7b5468db5..6f80a0ddb3 100644 --- a/ios/Framework/Themes/Default/AssetListScreenlet/AssetListView_default.swift +++ b/ios/Framework/Themes/Default/AssetListScreenlet/AssetListView_default.swift @@ -16,6 +16,12 @@ import UIKit public class AssetListView_default: AssetListTableView { + //MARK: BaseScreenletView + + override public func createProgressPresenter() -> ProgressPresenter { + return DefaultProgressPresenter() + } + override public func doFillLoadedCell(#row: Int, cell: UITableViewCell, object:AnyObject) { if let entry = object as? AssetListScreenletEntry { cell.textLabel?.text = entry.title diff --git a/ios/Framework/Themes/Default/Auth/ForgotPasswordScreenlet/ForgotPasswordView_default.swift b/ios/Framework/Themes/Default/Auth/ForgotPasswordScreenlet/ForgotPasswordView_default.swift index bc8480595d..223f160b5e 100644 --- a/ios/Framework/Themes/Default/Auth/ForgotPasswordScreenlet/ForgotPasswordView_default.swift +++ b/ios/Framework/Themes/Default/Auth/ForgotPasswordScreenlet/ForgotPasswordView_default.swift @@ -59,8 +59,6 @@ public class ForgotPasswordView_default: BaseScreenletView, ForgotPasswordViewMo super.onCreated() setButtonDefaultStyle(requestPasswordButton) - - BaseScreenlet.setHUDCustomColor(DefaultThemeBasicBlue) } override public func onSetTranslations() { @@ -78,6 +76,10 @@ public class ForgotPasswordView_default: BaseScreenletView, ForgotPasswordViewMo requestPasswordButton!.enabled = true } + override public func createProgressPresenter() -> ProgressPresenter { + return DefaultProgressPresenter() + } + //MARK: UITextFieldDelegate diff --git a/ios/Framework/Themes/Default/Auth/LoginScreenlet/LoginView_default.swift b/ios/Framework/Themes/Default/Auth/LoginScreenlet/LoginView_default.swift index 23c01efde9..b7f72c7a82 100644 --- a/ios/Framework/Themes/Default/Auth/LoginScreenlet/LoginView_default.swift +++ b/ios/Framework/Themes/Default/Auth/LoginScreenlet/LoginView_default.swift @@ -112,6 +112,10 @@ public class LoginView_default: BaseScreenletView, LoginViewModel { authorizeButton?.enabled = true } + override public func createProgressPresenter() -> ProgressPresenter { + return DefaultProgressPresenter() + } + //MARK: UITextFieldDelegate diff --git a/ios/Framework/Themes/Default/Auth/SignUpScreenlet/SignUpView_default.swift b/ios/Framework/Themes/Default/Auth/SignUpScreenlet/SignUpView_default.swift index 832e4a1ffc..eb2eb857ab 100644 --- a/ios/Framework/Themes/Default/Auth/SignUpScreenlet/SignUpView_default.swift +++ b/ios/Framework/Themes/Default/Auth/SignUpScreenlet/SignUpView_default.swift @@ -48,8 +48,6 @@ public class SignUpView_default: BaseScreenletView, SignUpViewModel { setButtonDefaultStyle(signUpButton) scrollView?.contentSize = scrollView!.frame.size - - BaseScreenlet.setHUDCustomColor(DefaultThemeBasicBlue) } override public func onSetTranslations() { @@ -63,6 +61,11 @@ public class SignUpView_default: BaseScreenletView, SignUpViewModel { forState: .Normal) } + override public func createProgressPresenter() -> ProgressPresenter { + return DefaultProgressPresenter() + } + + //MARK: SignUpViewModel public var emailAddress: String? { diff --git a/ios/Framework/Themes/Default/DDL/FormScreenlet/DDLFormView_default.swift b/ios/Framework/Themes/Default/DDL/FormScreenlet/DDLFormView_default.swift index db5f5f313c..bab779ba75 100644 --- a/ios/Framework/Themes/Default/DDL/FormScreenlet/DDLFormView_default.swift +++ b/ios/Framework/Themes/Default/DDL/FormScreenlet/DDLFormView_default.swift @@ -22,8 +22,6 @@ public class DDLFormView_default: DDLFormTableView { super.onCreated() self.tableView?.alpha = 0.0 - - BaseScreenlet.setHUDCustomColor(DefaultThemeBasicBlue) } override public func onFinishOperation() { @@ -34,4 +32,8 @@ public class DDLFormView_default: DDLFormTableView { } } + override public func createProgressPresenter() -> ProgressPresenter { + return DefaultProgressPresenter() + } + } diff --git a/ios/Framework/Themes/Default/DDL/ListScreenlet/DDLListView_default.swift b/ios/Framework/Themes/Default/DDL/ListScreenlet/DDLListView_default.swift index 064cb30ad5..e3d4978957 100644 --- a/ios/Framework/Themes/Default/DDL/ListScreenlet/DDLListView_default.swift +++ b/ios/Framework/Themes/Default/DDL/ListScreenlet/DDLListView_default.swift @@ -67,10 +67,8 @@ public class DDLListView_default: BaseListTableView, DDLListViewModel { //MARK: DDLFormTableView - override public func onCreated() { - super.onCreated() - - BaseScreenlet.setHUDCustomColor(DefaultThemeBasicBlue) + override public func createProgressPresenter() -> ProgressPresenter { + return DefaultProgressPresenter() } } diff --git a/ios/Framework/Themes/Default/WebContentDisplayScreenlet/WebContentDisplayView_default.swift b/ios/Framework/Themes/Default/WebContentDisplayScreenlet/WebContentDisplayView_default.swift index ae0fb8d742..4d6b7f119b 100644 --- a/ios/Framework/Themes/Default/WebContentDisplayScreenlet/WebContentDisplayView_default.swift +++ b/ios/Framework/Themes/Default/WebContentDisplayScreenlet/WebContentDisplayView_default.swift @@ -26,12 +26,12 @@ public class WebContentDisplayView_default: BaseScreenletView, WebContentDisplay ".span2, .span3, .span4, .span6, .span8, .span10 { width: 100%; }" - //MARK: WebContentDisplayViewModel - - override public func onCreated() { - BaseScreenlet.setHUDCustomColor(DefaultThemeBasicBlue) + override public func createProgressPresenter() -> ProgressPresenter { + return DefaultProgressPresenter() } + //MARK: WebContentDisplayViewModel + public var htmlContent: String { get { return "" diff --git a/ios/Framework/Themes/Flat7/Auth/ForgotPasswordScreenlet/ForgotPasswordView_flat7.swift b/ios/Framework/Themes/Flat7/Auth/ForgotPasswordScreenlet/ForgotPasswordView_flat7.swift index df85e6daaa..a974b6d724 100644 --- a/ios/Framework/Themes/Flat7/Auth/ForgotPasswordScreenlet/ForgotPasswordView_flat7.swift +++ b/ios/Framework/Themes/Flat7/Auth/ForgotPasswordScreenlet/ForgotPasswordView_flat7.swift @@ -27,8 +27,6 @@ public class ForgotPasswordView_flat7: ForgotPasswordView_default { super.onCreated() setFlat7ButtonBackground(requestPasswordButton) - - BaseScreenlet.setHUDCustomColor(Flat7ThemeBasicGreen) } override public func onSetTranslations() { @@ -45,6 +43,10 @@ public class ForgotPasswordView_flat7: ForgotPasswordView_default { userNameField!.placeholder = ""; } + override public func createProgressPresenter() -> ProgressPresenter { + return Flat7ProgressPresenter() + } + //MARK: ForgotPasswordView diff --git a/ios/Framework/Themes/Flat7/Auth/LoginScreenlet/LoginView_flat7.swift b/ios/Framework/Themes/Flat7/Auth/LoginScreenlet/LoginView_flat7.swift index 7a0d7c8035..9dd27e9ef5 100644 --- a/ios/Framework/Themes/Flat7/Auth/LoginScreenlet/LoginView_flat7.swift +++ b/ios/Framework/Themes/Flat7/Auth/LoginScreenlet/LoginView_flat7.swift @@ -28,8 +28,6 @@ public class LoginView_flat7: LoginView_default { super.onCreated() setFlat7ButtonBackground(loginButton) - - BaseScreenlet.setHUDCustomColor(Flat7ThemeBasicGreen) } override public var userName: String? { @@ -53,6 +51,10 @@ public class LoginView_flat7: LoginView_default { passwordField!.placeholder = ""; } + override public func createProgressPresenter() -> ProgressPresenter { + return Flat7ProgressPresenter() + } + //MARK: UITextFieldDelegate diff --git a/ios/Framework/Themes/Flat7/Auth/SignUpScreenlet/SignUpView_flat7.swift b/ios/Framework/Themes/Flat7/Auth/SignUpScreenlet/SignUpView_flat7.swift index 66684a1f4e..956c05e9c7 100644 --- a/ios/Framework/Themes/Flat7/Auth/SignUpScreenlet/SignUpView_flat7.swift +++ b/ios/Framework/Themes/Flat7/Auth/SignUpScreenlet/SignUpView_flat7.swift @@ -30,8 +30,6 @@ public class SignUpView_flat7: SignUpView_default { super.onCreated() setFlat7ButtonBackground(signUpButton) - - BaseScreenlet.setHUDCustomColor(Flat7ThemeBasicGreen) } override public func onSetTranslations() { @@ -53,6 +51,10 @@ public class SignUpView_flat7: SignUpView_default { passwordField!.placeholder = ""; } + override public func createProgressPresenter() -> ProgressPresenter { + return Flat7ProgressPresenter() + } + //MARK: UITextFieldDelegate diff --git a/ios/Framework/Themes/Flat7/Flat7ProgressPresenter.swift b/ios/Framework/Themes/Flat7/Flat7ProgressPresenter.swift new file mode 100644 index 0000000000..285b832723 --- /dev/null +++ b/ios/Framework/Themes/Flat7/Flat7ProgressPresenter.swift @@ -0,0 +1,26 @@ +/** +* Copyright (c) 2000-present Liferay, Inc. All rights reserved. +* +* This library is free software; you can redistribute it and/or modify it under +* the terms of the GNU Lesser General Public License as published by the Free +* Software Foundation; either version 2.1 of the License, or (at your option) +* any later version. +* +* This library is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +* details. +*/ +import Foundation + + +@objc public class Flat7ProgressPresenter: MBProgressHUDPresenter { + + override public init() { + super.init() + + self.customColor = Flat7ThemeBasicGreen + } + +} + diff --git a/ios/Framework/Themes/Flat7/Flat7ThemeConstants.swift b/ios/Framework/Themes/Flat7/Flat7ThemeConstants.swift index 86e9e71da2..8d2c324766 100644 --- a/ios/Framework/Themes/Flat7/Flat7ThemeConstants.swift +++ b/ios/Framework/Themes/Flat7/Flat7ThemeConstants.swift @@ -14,10 +14,10 @@ import Foundation -let Flat7ThemeBasicGreen = UIColor(red: 39.0/255, green: 174.0/255, blue: 97.0/255, alpha: 1) +public let Flat7ThemeBasicGreen = UIColor(red: 39.0/255, green: 174.0/255, blue: 97.0/255, alpha: 1) -func setFlat7ButtonBackground(button: UIButton?) { +public func setFlat7ButtonBackground(button: UIButton?) { let stretchableImage = UIImage( named: "flat7-button", inBundle: NSBundle(forClass: BaseScreenlet.self), From 530b97ababb2526f151c11c7374a565bed791c5b Mon Sep 17 00:00:00 2001 From: JM Date: Wed, 5 Aug 2015 20:03:29 +0200 Subject: [PATCH 023/365] LSR-239 Renamed function --- ios/Framework/Core/Base/MBProgressHUDPresenter.swift | 6 +++--- ios/Framework/Core/Extensions/Global.swift | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ios/Framework/Core/Base/MBProgressHUDPresenter.swift b/ios/Framework/Core/Base/MBProgressHUDPresenter.swift index fa3c2d1e24..1a5e855422 100644 --- a/ios/Framework/Core/Base/MBProgressHUDPresenter.swift +++ b/ios/Framework/Core/Base/MBProgressHUDPresenter.swift @@ -56,7 +56,7 @@ internal let MBProgressHUDLock = "hud-lock" assert(self.instance != nil, "MBProgressHUD must exist") synchronized(MBProgressHUDLock) { - dispatch_in_main { + dispatch_main { self.instance!.hide(true) self.instance = nil } @@ -67,7 +67,7 @@ internal let MBProgressHUDLock = "hud-lock" assert(self.instance != nil, "MBProgressHUD must exist") synchronized(MBProgressHUDLock) { - dispatch_in_main { + dispatch_main { self.configureAndShowHUD(self.instance!, message: message, details: nil, @@ -84,7 +84,7 @@ internal let MBProgressHUDLock = "hud-lock" spinnerMode: ProgressSpinnerMode) { synchronized(MBProgressHUDLock) { - dispatch_in_main { + dispatch_main { if self.instance == nil { self.instance = MBProgressHUD.showHUDAddedTo(view, animated:true) } diff --git a/ios/Framework/Core/Extensions/Global.swift b/ios/Framework/Core/Extensions/Global.swift index cbc3b35992..9a528e79a5 100644 --- a/ios/Framework/Core/Extensions/Global.swift +++ b/ios/Framework/Core/Extensions/Global.swift @@ -37,7 +37,7 @@ public func delayed(delay: NSTimeInterval, block: dispatch_block_t) { dispatch_after(time, dispatch_get_main_queue(), block) } -public func dispatch_in_main(block: dispatch_block_t) { +public func dispatch_main(block: dispatch_block_t) { if NSThread.isMainThread() { block() } From 51e7c79a8d7069dc4806e5c94f3f6edc6b95b0b3 Mon Sep 17 00:00:00 2001 From: JM Date: Wed, 5 Aug 2015 20:04:46 +0200 Subject: [PATCH 024/365] LSR-239 Use new function --- ios/Framework/Core/Base/Interactor.swift | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/ios/Framework/Core/Base/Interactor.swift b/ios/Framework/Core/Base/Interactor.swift index a36345d63b..f0f6a8e88a 100644 --- a/ios/Framework/Core/Base/Interactor.swift +++ b/ios/Framework/Core/Base/Interactor.swift @@ -26,28 +26,16 @@ import UIKit } public func callOnSuccess() { - if NSThread.isMainThread() { - onSuccess?() - finish() - } - else { - dispatch_async(dispatch_get_main_queue()) { - self.onSuccess?() - self.finish() - } + dispatch_main { + self.onSuccess?() + self.finish() } } public func callOnFailure(error: NSError) { - if NSThread.isMainThread() { - onFailure?(error) - finish() - } - else { - dispatch_async(dispatch_get_main_queue()) { - self.onFailure?(error) - self.finish() - } + dispatch_main { + self.onFailure?(error) + self.finish() } } From 1a4c45e83840adcc8e0dc3ec66dce5ffde425d30 Mon Sep 17 00:00:00 2001 From: JM Date: Thu, 6 Aug 2015 16:47:25 +0200 Subject: [PATCH 025/365] =?UTF-8?q?LSR-239=20Action=20name=20isn=E2=80=99t?= =?UTF-8?q?=20optional=20anymore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ForgotPasswordScreenlet.swift | 2 +- .../Core/Auth/LoginScreenlet/LoginScreenlet.swift | 4 ++-- .../Core/Auth/SignUpScreenlet/SignUpScreenlet.swift | 4 ++-- .../UserPortraitScreenlet.swift | 4 ++-- ios/Framework/Core/Base/BaseScreenlet.swift | 8 +++++--- ios/Framework/Core/Base/BaseScreenletView.swift | 12 +++++++----- .../Core/DDL/FormScreenlet/DDLFormScreenlet.swift | 8 ++------ .../WebContentDisplayScreenlet.swift | 2 +- .../UserPortraitView_default.swift | 3 +-- 9 files changed, 23 insertions(+), 24 deletions(-) diff --git a/ios/Framework/Core/Auth/ForgotPasswordScreenlet/ForgotPasswordScreenlet.swift b/ios/Framework/Core/Auth/ForgotPasswordScreenlet/ForgotPasswordScreenlet.swift index 556ad23877..924211038a 100644 --- a/ios/Framework/Core/Auth/ForgotPasswordScreenlet/ForgotPasswordScreenlet.swift +++ b/ios/Framework/Core/Auth/ForgotPasswordScreenlet/ForgotPasswordScreenlet.swift @@ -67,7 +67,7 @@ import UIKit } } - override public func createInteractor(#name: String?, sender: AnyObject?) -> Interactor? { + override public func createInteractor(#name: String, sender: AnyObject?) -> Interactor? { let interactor = ForgotPasswordInteractor(screenlet: self) interactor.onSuccess = { diff --git a/ios/Framework/Core/Auth/LoginScreenlet/LoginScreenlet.swift b/ios/Framework/Core/Auth/LoginScreenlet/LoginScreenlet.swift index 1e2ad3bfa6..bec21f98c9 100644 --- a/ios/Framework/Core/Auth/LoginScreenlet/LoginScreenlet.swift +++ b/ios/Framework/Core/Auth/LoginScreenlet/LoginScreenlet.swift @@ -83,9 +83,9 @@ public class LoginScreenlet: BaseScreenlet, BasicAuthBasedType { } } - override public func createInteractor(#name: String?, sender: AnyObject?) -> Interactor? { + override public func createInteractor(#name: String, sender: AnyObject?) -> Interactor? { - switch name! { + switch name { case "login-action": return createLoginInteractor() case "oauth-action": diff --git a/ios/Framework/Core/Auth/SignUpScreenlet/SignUpScreenlet.swift b/ios/Framework/Core/Auth/SignUpScreenlet/SignUpScreenlet.swift index 7621cd614f..9d84220e1c 100644 --- a/ios/Framework/Core/Auth/SignUpScreenlet/SignUpScreenlet.swift +++ b/ios/Framework/Core/Auth/SignUpScreenlet/SignUpScreenlet.swift @@ -59,9 +59,9 @@ import UIKit //MARK: BaseScreenlet - override public func createInteractor(#name: String?, sender: AnyObject?) -> Interactor? { + override public func createInteractor(#name: String, sender: AnyObject?) -> Interactor? { - switch name! { + switch name { case "signup-action": return createSignUpInteractor() case "save-action": diff --git a/ios/Framework/Core/Auth/UserPortraitScreenlet/UserPortraitScreenlet.swift b/ios/Framework/Core/Auth/UserPortraitScreenlet/UserPortraitScreenlet.swift index a2fb15cdc3..685c6b95f3 100644 --- a/ios/Framework/Core/Auth/UserPortraitScreenlet/UserPortraitScreenlet.swift +++ b/ios/Framework/Core/Auth/UserPortraitScreenlet/UserPortraitScreenlet.swift @@ -123,11 +123,11 @@ public class UserPortraitScreenlet: BaseScreenlet { return startInteractor(interactor) } - override public func createInteractor(#name: String?, sender: AnyObject?) -> Interactor? { + override public func createInteractor(#name: String, sender: AnyObject?) -> Interactor? { let interactor: UploadUserPortraitInteractor? - switch name! { + switch name { case "upload-portrait": let image = sender as! UIImage let userId: Int64 diff --git a/ios/Framework/Core/Base/BaseScreenlet.swift b/ios/Framework/Core/Base/BaseScreenlet.swift index 8d15f85900..4c8f24f1f3 100644 --- a/ios/Framework/Core/Base/BaseScreenlet.swift +++ b/ios/Framework/Core/Base/BaseScreenlet.swift @@ -21,6 +21,8 @@ import QuartzCore */ @IBDesignable public class BaseScreenlet: UIView { + public static let DefaultAction = "defaultAction" + @IBInspectable public var themeName: String? { set { _themeName = (newValue ?? "default").lowercaseString @@ -193,7 +195,7 @@ import QuartzCore * Typically, it's called from TouchUpInside UI event or when the programmer wants to * start the interaction programatically. */ - public func performAction(#name: String?, sender: AnyObject? = nil) -> Bool { + public func performAction(#name: String, sender: AnyObject? = nil) -> Bool { if let interactor = createInteractor(name: name, sender: sender) { _runningInteractors.append(interactor) @@ -206,7 +208,7 @@ import QuartzCore } public func performDefaultAction() -> Bool { - return performAction(name: nil, sender: nil) + return performAction(name: BaseScreenlet.DefaultAction, sender: nil) } /* @@ -216,7 +218,7 @@ import QuartzCore return interactor.start() } - public func createInteractor(#name: String?, sender: AnyObject?) -> Interactor? { + public func createInteractor(#name: String, sender: AnyObject?) -> Interactor? { return nil } diff --git a/ios/Framework/Core/Base/BaseScreenletView.swift b/ios/Framework/Core/Base/BaseScreenletView.swift index 8f20290177..3ea8ad4fe5 100644 --- a/ios/Framework/Core/Base/BaseScreenletView.swift +++ b/ios/Framework/Core/Base/BaseScreenletView.swift @@ -30,7 +30,7 @@ public class BaseScreenletView: UIView, UITextFieldDelegate { public var themeName = "default" - internal var onPerformAction: ((String?, AnyObject?) -> Bool)? + internal var onPerformAction: ((String, AnyObject?) -> Bool)? deinit { @@ -152,11 +152,11 @@ public class BaseScreenletView: UIView, UITextFieldDelegate { * onPreAction is invoked just before any user action is invoked. * Override this method to decide whether or not the user action should be fired. */ - public func onPreAction(#name: String?, sender: AnyObject?) -> Bool { + public func onPreAction(#name: String, sender: AnyObject?) -> Bool { return true } - public func onSetDefaultDelegate(delegate:AnyObject, view:UIView) -> Bool { + public func onSetDefaultDelegate(delegate: AnyObject, view: UIView) -> Bool { return true } @@ -187,10 +187,12 @@ public class BaseScreenletView: UIView, UITextFieldDelegate { } public func userAction(#name: String?, sender: AnyObject?) { - if onPreAction(name: name, sender: sender) { + let actionName = name ?? BaseScreenlet.DefaultAction + + if onPreAction(name: actionName, sender: sender) { endEditing(true) - onPerformAction?(name, sender) + onPerformAction?(actionName, sender) } } diff --git a/ios/Framework/Core/DDL/FormScreenlet/DDLFormScreenlet.swift b/ios/Framework/Core/DDL/FormScreenlet/DDLFormScreenlet.swift index 117be60014..178254c2ed 100644 --- a/ios/Framework/Core/DDL/FormScreenlet/DDLFormScreenlet.swift +++ b/ios/Framework/Core/DDL/FormScreenlet/DDLFormScreenlet.swift @@ -122,12 +122,8 @@ import UIKit } } - override public func createInteractor(#name: String?, sender: AnyObject?) -> Interactor? { - if name == nil { - return nil - } - - switch name! { + override public func createInteractor(#name: String, sender: AnyObject?) -> Interactor? { + switch name { case LoadFormAction: return createLoadFormInteractor() case LoadRecordAction: diff --git a/ios/Framework/Core/WebContentDisplayScreenlet/WebContentDisplayScreenlet.swift b/ios/Framework/Core/WebContentDisplayScreenlet/WebContentDisplayScreenlet.swift index c3254a4a5c..d9724347b8 100644 --- a/ios/Framework/Core/WebContentDisplayScreenlet/WebContentDisplayScreenlet.swift +++ b/ios/Framework/Core/WebContentDisplayScreenlet/WebContentDisplayScreenlet.swift @@ -42,7 +42,7 @@ import UIKit } } - override public func createInteractor(#name: String?, sender: AnyObject?) -> Interactor? { + override public func createInteractor(#name: String, sender: AnyObject?) -> Interactor? { let interactor = WebContentDisplayLoadInteractor(screenlet: self) interactor.onSuccess = { diff --git a/ios/Framework/Themes/Default/Auth/UserPortraitScreenlet/UserPortraitView_default.swift b/ios/Framework/Themes/Default/Auth/UserPortraitScreenlet/UserPortraitView_default.swift index f5c16c18b6..66eaa6a9a7 100644 --- a/ios/Framework/Themes/Default/Auth/UserPortraitScreenlet/UserPortraitView_default.swift +++ b/ios/Framework/Themes/Default/Auth/UserPortraitScreenlet/UserPortraitView_default.swift @@ -111,9 +111,8 @@ public class UserPortraitView_default: BaseScreenletView, portraitImage?.layer.cornerRadius = DefaultThemeButtonCornerRadius } - override public func onPreAction(#name: String?, sender: AnyObject?) -> Bool { + override public func onPreAction(#name: String, sender: AnyObject?) -> Bool { if name == "edit-portrait" { - let takeNewPicture = LocalizedString("default", "userportrait-take-new-picture", self) let chooseExisting = LocalizedString("default", "userportrait-choose-existing-picture", self) From 7bb6a95a36740beab23941c8eba51a4579548f16 Mon Sep 17 00:00:00 2001 From: JM Date: Thu, 6 Aug 2015 16:55:50 +0200 Subject: [PATCH 026/365] LSR-239 Add synchronization code --- ios/Framework/Core/Base/BaseScreenlet.swift | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/ios/Framework/Core/Base/BaseScreenlet.swift b/ios/Framework/Core/Base/BaseScreenlet.swift index 4c8f24f1f3..39f0cfe37a 100644 --- a/ios/Framework/Core/Base/BaseScreenlet.swift +++ b/ios/Framework/Core/Base/BaseScreenlet.swift @@ -196,15 +196,26 @@ import QuartzCore * start the interaction programatically. */ public func performAction(#name: String, sender: AnyObject? = nil) -> Bool { - if let interactor = createInteractor(name: name, sender: sender) { + var result = false + + objc_sync_enter(_runningInteractors) + + if let interactor = self.createInteractor(name: name, sender: sender) { _runningInteractors.append(interactor) - return onAction(name: name, interactor: interactor, sender: sender) + result = self.onAction(name: name, interactor: interactor, sender: sender) + + if !result { + _runningInteractors.removeLast() + } + } + else { + println("WARN: No interactor created for action \(name)") } - println("WARN: No interactor created for action \(name)") + objc_sync_exit(_runningInteractors) - return false + return result } public func performDefaultAction() -> Bool { From f2dab9bedd4d8de8e5c93f2a19839becc0e2d935 Mon Sep 17 00:00:00 2001 From: JM Date: Thu, 6 Aug 2015 18:01:35 +0200 Subject: [PATCH 027/365] LSR-239 Remove message details --- ios/Framework/Core/Base/BaseScreenlet.swift | 15 +++++-------- .../Core/Base/MBProgressHUDPresenter.swift | 9 ++------ .../Core/Base/ProgressPresenter.swift | 9 ++------ ios/Framework/Core/Base/ServerOperation.swift | 22 ++++++++----------- .../DDL/FormScreenlet/DDLFormScreenlet.swift | 6 ++--- .../LiferayDDLFormSubmitOperation.swift | 1 - 6 files changed, 21 insertions(+), 41 deletions(-) diff --git a/ios/Framework/Core/Base/BaseScreenlet.swift b/ios/Framework/Core/Base/BaseScreenlet.swift index 39f0cfe37a..a36a75534e 100644 --- a/ios/Framework/Core/Base/BaseScreenlet.swift +++ b/ios/Framework/Core/Base/BaseScreenlet.swift @@ -330,38 +330,35 @@ import QuartzCore //MARK: Class methods public func showHUDWithMessage(message: String?, - details: String? = nil, closeMode: ProgressCloseMode = .ManualClose, spinnerMode: ProgressSpinnerMode = .IndeterminateSpinner) { - assert(self._progressPresenter != nil, "ProgressPresenter must exist") + assert(_progressPresenter != nil, "ProgressPresenter must exist") _progressPresenter!.showHUDInView(self, message: message, - details: details, closeMode: closeMode, spinnerMode: spinnerMode) } - public func showHUDAlert(#message: String, details: String? = nil) { - assert(self._progressPresenter != nil, "ProgressPresenter must exist") + public func showHUDAlert(#message: String) { + assert(_progressPresenter != nil, "ProgressPresenter must exist") _progressPresenter!.showHUDInView(self, message: message, - details: details, closeMode: .ManualClose_TouchClosable, spinnerMode: .NoSpinner) } - public func hideHUDWithMessage(message:String, details:String? = nil) { - assert(self._progressPresenter != nil, "ProgressPresenter must exist") + public func hideHUDWithMessage(message:String) { + assert(_progressPresenter != nil, "ProgressPresenter must exist") _progressPresenter!.hideHUDWithMessage(message) } public func hideHUD() { - assert(self._progressPresenter != nil, "ProgressPresenter must exist") + assert(_progressPresenter != nil, "ProgressPresenter must exist") _progressPresenter!.hideHUD() } diff --git a/ios/Framework/Core/Base/MBProgressHUDPresenter.swift b/ios/Framework/Core/Base/MBProgressHUDPresenter.swift index 1a5e855422..fee0e357e9 100644 --- a/ios/Framework/Core/Base/MBProgressHUDPresenter.swift +++ b/ios/Framework/Core/Base/MBProgressHUDPresenter.swift @@ -39,7 +39,6 @@ internal let MBProgressHUDLock = "hud-lock" public func showHUDInView(view: UIView) { showHUDInView(view, message: nil, - details: nil, closeMode: .ManualClose, spinnerMode: .IndeterminateSpinner) } @@ -47,7 +46,6 @@ internal let MBProgressHUDLock = "hud-lock" public func showHUDInView(view: UIView, message:String) { showHUDInView(view, message: message, - details: nil, closeMode: .ManualClose, spinnerMode: .IndeterminateSpinner) } @@ -70,7 +68,6 @@ internal let MBProgressHUDLock = "hud-lock" dispatch_main { self.configureAndShowHUD(self.instance!, message: message, - details: nil, closeMode: .Autoclose_TouchClosable, spinnerMode: .NoSpinner) } @@ -79,7 +76,6 @@ internal let MBProgressHUDLock = "hud-lock" public func showHUDInView(view: UIView, message: String?, - details: String?, closeMode: ProgressCloseMode, spinnerMode: ProgressSpinnerMode) { @@ -91,7 +87,6 @@ internal let MBProgressHUDLock = "hud-lock" self.configureAndShowHUD(self.instance!, message: message, - details: details, closeMode: closeMode, spinnerMode: spinnerMode) } @@ -103,7 +98,6 @@ internal let MBProgressHUDLock = "hud-lock" private func configureAndShowHUD(hud: MBProgressHUD, message: String?, - details: String?, closeMode: ProgressCloseMode, spinnerMode: ProgressSpinnerMode) { @@ -128,7 +122,8 @@ internal let MBProgressHUDLock = "hud-lock" hud.labelText = message } - hud.detailsLabelText = (details ?? "") as String + //TODO details + hud.detailsLabelText = ("DETAILS" ?? "") as String hud.show(true) diff --git a/ios/Framework/Core/Base/ProgressPresenter.swift b/ios/Framework/Core/Base/ProgressPresenter.swift index 0c17c31369..87328db016 100644 --- a/ios/Framework/Core/Base/ProgressPresenter.swift +++ b/ios/Framework/Core/Base/ProgressPresenter.swift @@ -15,35 +15,30 @@ import Foundation @objc public enum ProgressCloseMode: Int { - case ManualClose case ManualClose_TouchClosable - case Autoclose case Autoclose_TouchClosable } @objc public enum ProgressSpinnerMode: Int { - case IndeterminateSpinner case DeterminateSpinner case NoSpinner - } @objc public protocol ProgressPresenter { func showHUDInView(view: UIView) - func showHUDInView(view: UIView, message:String) + func showHUDInView(view: UIView, message: String) func showHUDInView(view: UIView, message: String?, - details: String?, closeMode: ProgressCloseMode, spinnerMode: ProgressSpinnerMode) func hideHUD() - func hideHUDWithMessage(message:String) + func hideHUDWithMessage(message: String) } diff --git a/ios/Framework/Core/Base/ServerOperation.swift b/ios/Framework/Core/Base/ServerOperation.swift index 3178f4d8e8..ea2abf17a2 100644 --- a/ios/Framework/Core/Base/ServerOperation.swift +++ b/ios/Framework/Core/Base/ServerOperation.swift @@ -145,27 +145,25 @@ public class ServerOperation: NSOperation { internal func showHUD(#message: String, details: String? = nil) { dispatch_async(dispatch_get_main_queue()) { - self.screenlet.showHUDWithMessage(message, details: details) + self.screenlet.showHUDWithMessage(message) } } internal func showHUD( #message: String, - details: String?, closeMode: ProgressCloseMode, spinnerMode: ProgressSpinnerMode) { - dispatch_async(dispatch_get_main_queue()) { + dispatch_main { self.screenlet.showHUDWithMessage(message, - details: details, closeMode: closeMode, spinnerMode: spinnerMode) } } internal func showValidationHUD(#message: String, details: String? = nil) { - dispatch_async(dispatch_get_main_queue()) { - self.screenlet.showHUDAlert(message: message, details: details) + dispatch_main { + self.screenlet.showHUDAlert(message: message) } } @@ -173,20 +171,18 @@ public class ServerOperation: NSOperation { self.screenlet.hideHUD() } - internal func hideHUD(#message: String, details: String? = nil) { - self.screenlet.hideHUDWithMessage(message, details: details) + internal func hideHUD(#message: String) { + self.screenlet.hideHUDWithMessage(message) } - internal func hideHUD(#errorMessage: String, details: String? = nil) { + internal func hideHUD(#errorMessage: String) { self.screenlet.showHUDWithMessage(errorMessage, - details: details, closeMode: .ManualClose_TouchClosable, spinnerMode: .NoSpinner) } - internal func hideHUD(#error: NSError, message: String, details: String? = nil) { + internal func hideHUD(#error: NSError, message: String) { self.screenlet.showHUDWithMessage(message, - details: details, closeMode: .ManualClose_TouchClosable, spinnerMode: .NoSpinner) } @@ -196,7 +192,7 @@ public class ServerOperation: NSOperation { private func callOnComplete() { if self.onComplete != nil { - dispatch_async(dispatch_get_main_queue()) { + dispatch_main { self.onComplete!(self) // this breaks the retain cycle between the op and 'onComplete' diff --git a/ios/Framework/Core/DDL/FormScreenlet/DDLFormScreenlet.swift b/ios/Framework/Core/DDL/FormScreenlet/DDLFormScreenlet.swift index 178254c2ed..68ff5f14e5 100644 --- a/ios/Framework/Core/DDL/FormScreenlet/DDLFormScreenlet.swift +++ b/ios/Framework/Core/DDL/FormScreenlet/DDLFormScreenlet.swift @@ -351,8 +351,7 @@ import UIKit ? "uploading-message-singular" : "uploading-message-plural" showHUDWithMessage( - LocalizedString("ddlform-screenlet", uploadMessage, self), - details: LocalizedString("ddlform-screenlet", "uploading-details", self)) + LocalizedString("ddlform-screenlet", uploadMessage, self)) return true @@ -377,8 +376,7 @@ import UIKit if let failedUploads = failedDocumentFields { if failedUploads.count > 0 { showHUDWithMessage( - LocalizedString("ddlform-screenlet", "uploading-retry", self), - details: LocalizedString("ddlform-screenlet", "uploading-retry-details", self)) + LocalizedString("ddlform-screenlet", "uploading-retry", self)) for failedDocumentField in failedUploads { performAction(name: UploadDocumentAction, sender: failedDocumentField) diff --git a/ios/Framework/Core/DDL/FormScreenlet/ServerOperations/LiferayDDLFormSubmitOperation.swift b/ios/Framework/Core/DDL/FormScreenlet/ServerOperations/LiferayDDLFormSubmitOperation.swift index e8f48314ad..b3fb1d80bf 100644 --- a/ios/Framework/Core/DDL/FormScreenlet/ServerOperations/LiferayDDLFormSubmitOperation.swift +++ b/ios/Framework/Core/DDL/FormScreenlet/ServerOperations/LiferayDDLFormSubmitOperation.swift @@ -57,7 +57,6 @@ public class LiferayDDLFormSubmitOperation: ServerOperation { if valid && !viewModel.validateForm(autoscroll: autoscrollOnValidation) { showHUD(message: LocalizedString("ddlform-screenlet", "validation", self), - details: LocalizedString("ddlform-screenlet", "validation-details", self), closeMode: .Autoclose_TouchClosable, spinnerMode: .NoSpinner) From 4c108f746d36ee748fce8d820c0a5956877087d2 Mon Sep 17 00:00:00 2001 From: JM Date: Thu, 6 Aug 2015 18:06:39 +0200 Subject: [PATCH 028/365] LSR-239 Add progressMessages in srceenlet view to configure the messages shown by the screenlet --- ios/Framework/Core/Base/BaseScreenlet.swift | 26 ++++++++++++++++--- .../Core/Base/BaseScreenletView.swift | 16 ++++++++++++ ios/Framework/Core/Base/Interactor.swift | 13 +++++++--- .../Core/Base/ProgressPresenter.swift | 9 ++++--- 4 files changed, 53 insertions(+), 11 deletions(-) diff --git a/ios/Framework/Core/Base/BaseScreenlet.swift b/ios/Framework/Core/Base/BaseScreenlet.swift index a36a75534e..4018cb6e8e 100644 --- a/ios/Framework/Core/Base/BaseScreenlet.swift +++ b/ios/Framework/Core/Base/BaseScreenlet.swift @@ -201,12 +201,19 @@ import QuartzCore objc_sync_enter(_runningInteractors) if let interactor = self.createInteractor(name: name, sender: sender) { - _runningInteractors.append(interactor) + if let message = screenletView?.progressMessageForAction(name, messageType: .Loading) { + showHUDWithMessage(message, + closeMode: .ManualClose, + spinnerMode: .IndeterminateSpinner) + } - result = self.onAction(name: name, interactor: interactor, sender: sender) + interactor.actionName = name + _runningInteractors.append(interactor) - if !result { + if !onAction(name: name, interactor: interactor, sender: sender) { _runningInteractors.removeLast() + + // validation message? } } else { @@ -233,12 +240,23 @@ import QuartzCore return nil } - public func endInteractor(interactor: Interactor) { + public func endInteractor(interactor: Interactor, success: Bool) { synchronized(_runningInteractors) { if let foundIndex = find(self._runningInteractors, interactor) { self._runningInteractors.removeAtIndex(foundIndex) } } + + let messageType = success ? ProgressMessageType.Success : ProgressMessageType.Failure + + if let msg = screenletView?.progressMessageForAction(interactor.actionName!, messageType: messageType) { + showHUDWithMessage(msg, + closeMode: success ? .Autoclose_TouchClosable : .ManualClose_TouchClosable, + spinnerMode: .NoSpinner) + } + else { + hideHUD() + } } /** diff --git a/ios/Framework/Core/Base/BaseScreenletView.swift b/ios/Framework/Core/Base/BaseScreenletView.swift index 3ea8ad4fe5..3260056c57 100644 --- a/ios/Framework/Core/Base/BaseScreenletView.swift +++ b/ios/Framework/Core/Base/BaseScreenletView.swift @@ -21,6 +21,8 @@ public class BaseScreenletView: UIView, UITextFieldDelegate { public weak var presentingViewController: UIViewController? + public var progressMessages: [String:ProgressMessages] { return [:] } + public var editable: Bool = true { didSet { @@ -173,6 +175,20 @@ public class BaseScreenletView: UIView, UITextFieldDelegate { return MBProgressHUDPresenter() } + public func progressMessageForAction(actionName: String, + messageType: ProgressMessageType) -> String? { + + let messages = progressMessages[actionName] ?? progressMessages[BaseScreenlet.DefaultAction] + + if let messages = messages { + if let message = messages[messageType] { + return message + } + } + + return nil + } + public func userActionWithSender(sender: AnyObject?) { if let controlSender = sender as? UIControl { userAction(name: controlSender.restorationIdentifier, sender: sender) diff --git a/ios/Framework/Core/Base/Interactor.swift b/ios/Framework/Core/Base/Interactor.swift index f0f6a8e88a..b531c445f2 100644 --- a/ios/Framework/Core/Base/Interactor.swift +++ b/ios/Framework/Core/Base/Interactor.swift @@ -16,11 +16,16 @@ import UIKit @objc public class Interactor: NSObject { + public var actionName: String? + public var onSuccess: (Void -> Void)? public var onFailure: (NSError -> Void)? + public var lastError: NSError? + public let screenlet: BaseScreenlet + public init(screenlet: BaseScreenlet) { self.screenlet = screenlet } @@ -28,14 +33,14 @@ import UIKit public func callOnSuccess() { dispatch_main { self.onSuccess?() - self.finish() + self.finishWithSuccess(true) } } public func callOnFailure(error: NSError) { dispatch_main { self.onFailure?(error) - self.finish() + self.finishWithSuccess(false) } } @@ -43,8 +48,8 @@ import UIKit return false } - private func finish() { - screenlet.endInteractor(self) + private func finishWithSuccess(success: Bool) { + screenlet.endInteractor(self, success: success) // break retain cycle onSuccess = nil diff --git a/ios/Framework/Core/Base/ProgressPresenter.swift b/ios/Framework/Core/Base/ProgressPresenter.swift index 87328db016..a395f10474 100644 --- a/ios/Framework/Core/Base/ProgressPresenter.swift +++ b/ios/Framework/Core/Base/ProgressPresenter.swift @@ -42,8 +42,11 @@ import Foundation } -@objc protocol ProgressPresenterCreator { - - func createProgressPresenter() -> ProgressPresenter +@objc public enum ProgressMessageType: Int { + case Loading + case Failure + case Success } + +public typealias ProgressMessages = [ProgressMessageType:String] From f02a327cb8c5237904e85cfb62ca3201678cef84 Mon Sep 17 00:00:00 2001 From: JM Date: Thu, 6 Aug 2015 18:12:32 +0200 Subject: [PATCH 029/365] =?UTF-8?q?LSR-239=20Remove=20parameters=E2=80=99?= =?UTF-8?q?=20default=20values?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Framework/Core/Base/BaseScreenlet.swift | 6 +++--- ios/Framework/Core/Base/ServerOperation.swift | 4 +++- .../Core/DDL/FormScreenlet/DDLFormScreenlet.swift | 10 ++++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ios/Framework/Core/Base/BaseScreenlet.swift b/ios/Framework/Core/Base/BaseScreenlet.swift index 4018cb6e8e..90b0abb034 100644 --- a/ios/Framework/Core/Base/BaseScreenlet.swift +++ b/ios/Framework/Core/Base/BaseScreenlet.swift @@ -348,8 +348,8 @@ import QuartzCore //MARK: Class methods public func showHUDWithMessage(message: String?, - closeMode: ProgressCloseMode = .ManualClose, - spinnerMode: ProgressSpinnerMode = .IndeterminateSpinner) { + closeMode: ProgressCloseMode, + spinnerMode: ProgressSpinnerMode) { assert(_progressPresenter != nil, "ProgressPresenter must exist") @@ -369,7 +369,7 @@ import QuartzCore spinnerMode: .NoSpinner) } - public func hideHUDWithMessage(message:String) { + public func hideHUDWithMessage(message: String) { assert(_progressPresenter != nil, "ProgressPresenter must exist") _progressPresenter!.hideHUDWithMessage(message) diff --git a/ios/Framework/Core/Base/ServerOperation.swift b/ios/Framework/Core/Base/ServerOperation.swift index ea2abf17a2..8b13d0b924 100644 --- a/ios/Framework/Core/Base/ServerOperation.swift +++ b/ios/Framework/Core/Base/ServerOperation.swift @@ -145,7 +145,9 @@ public class ServerOperation: NSOperation { internal func showHUD(#message: String, details: String? = nil) { dispatch_async(dispatch_get_main_queue()) { - self.screenlet.showHUDWithMessage(message) + self.screenlet.showHUDWithMessage(message, + closeMode: .ManualClose, + spinnerMode: .IndeterminateSpinner) } } diff --git a/ios/Framework/Core/DDL/FormScreenlet/DDLFormScreenlet.swift b/ios/Framework/Core/DDL/FormScreenlet/DDLFormScreenlet.swift index 68ff5f14e5..049987d91c 100644 --- a/ios/Framework/Core/DDL/FormScreenlet/DDLFormScreenlet.swift +++ b/ios/Framework/Core/DDL/FormScreenlet/DDLFormScreenlet.swift @@ -350,8 +350,9 @@ import UIKit let uploadMessage = (uploadCount == 1) ? "uploading-message-singular" : "uploading-message-plural" - showHUDWithMessage( - LocalizedString("ddlform-screenlet", uploadMessage, self)) + showHUDWithMessage(LocalizedString("ddlform-screenlet", uploadMessage, self), + closeMode: .ManualClose, + spinnerMode: .IndeterminateSpinner) return true @@ -375,8 +376,9 @@ import UIKit if let failedUploads = failedDocumentFields { if failedUploads.count > 0 { - showHUDWithMessage( - LocalizedString("ddlform-screenlet", "uploading-retry", self)) + showHUDWithMessage(LocalizedString("ddlform-screenlet", "uploading-retry", self), + closeMode: .ManualClose, + spinnerMode: .IndeterminateSpinner) for failedDocumentField in failedUploads { performAction(name: UploadDocumentAction, sender: failedDocumentField) From 6cfbbf63f665e5d70adfb413dac205f3497e7c16 Mon Sep 17 00:00:00 2001 From: JM Date: Thu, 6 Aug 2015 18:14:21 +0200 Subject: [PATCH 030/365] LSR-239 Change LoginScreenlet to new progress messages pattern --- .../ServerOperations/LiferayLoginByEmailOperation.swift | 8 -------- .../LiferayLoginByScreenNameOperation.swift | 8 -------- .../ServerOperations/LiferayLoginByUserIdOperation.swift | 8 -------- .../Core/Resources/en.lproj/login-screenlet.strings | 3 +-- .../Core/Resources/es.lproj/login-screenlet.strings | 3 +-- .../Default/Auth/LoginScreenlet/LoginView_default.swift | 7 +++++++ 6 files changed, 9 insertions(+), 28 deletions(-) diff --git a/ios/Framework/Core/Auth/LoginScreenlet/ServerOperations/LiferayLoginByEmailOperation.swift b/ios/Framework/Core/Auth/LoginScreenlet/ServerOperations/LiferayLoginByEmailOperation.swift index 2ea64b93dd..ac811786a8 100644 --- a/ios/Framework/Core/Auth/LoginScreenlet/ServerOperations/LiferayLoginByEmailOperation.swift +++ b/ios/Framework/Core/Auth/LoginScreenlet/ServerOperations/LiferayLoginByEmailOperation.swift @@ -16,14 +16,6 @@ import UIKit public class LiferayLoginByEmailOperation: GetUserByEmailOperation { - override public var hudLoadingMessage: HUDMessage? { - return (LocalizedString("login-screenlet", "loading-message", self), - details: LocalizedString("login-screenlet", "loading-details", self)) - } - override public var hudFailureMessage: HUDMessage? { - return (LocalizedString("login-screenlet", "loading-error", self), details: nil) - } - override internal func validateData() -> Bool { let valid = super.validateData() diff --git a/ios/Framework/Core/Auth/LoginScreenlet/ServerOperations/LiferayLoginByScreenNameOperation.swift b/ios/Framework/Core/Auth/LoginScreenlet/ServerOperations/LiferayLoginByScreenNameOperation.swift index 98e06a95fb..b4bcdb7607 100644 --- a/ios/Framework/Core/Auth/LoginScreenlet/ServerOperations/LiferayLoginByScreenNameOperation.swift +++ b/ios/Framework/Core/Auth/LoginScreenlet/ServerOperations/LiferayLoginByScreenNameOperation.swift @@ -16,14 +16,6 @@ import UIKit public class LiferayLoginByScreenNameOperation: GetUserByScreenNameOperation { - override public var hudLoadingMessage: HUDMessage? { - return (LocalizedString("login-screenlet", "loading-message", self), - details: LocalizedString("login-screenlet", "loading-details", self)) - } - override public var hudFailureMessage: HUDMessage? { - return (LocalizedString("login-screenlet", "loading-error", self), details: nil) - } - override internal func validateData() -> Bool { let valid = super.validateData() diff --git a/ios/Framework/Core/Auth/LoginScreenlet/ServerOperations/LiferayLoginByUserIdOperation.swift b/ios/Framework/Core/Auth/LoginScreenlet/ServerOperations/LiferayLoginByUserIdOperation.swift index 51ff1c661e..a5c7877d9f 100644 --- a/ios/Framework/Core/Auth/LoginScreenlet/ServerOperations/LiferayLoginByUserIdOperation.swift +++ b/ios/Framework/Core/Auth/LoginScreenlet/ServerOperations/LiferayLoginByUserIdOperation.swift @@ -16,14 +16,6 @@ import UIKit public class LiferayLoginByUserIdOperation: GetUserByUserIdOperation { - override public var hudLoadingMessage: HUDMessage? { - return (LocalizedString("login-screenlet", "loading-message", self), - details: LocalizedString("login-screenlet", "loading-details", self)) - } - override public var hudFailureMessage: HUDMessage? { - return (LocalizedString("login-screenlet", "loading-error", self), details: nil) - } - override internal func validateData() -> Bool { let valid = super.validateData() diff --git a/ios/Framework/Core/Resources/en.lproj/login-screenlet.strings b/ios/Framework/Core/Resources/en.lproj/login-screenlet.strings index b426ae5982..c4cd5682f6 100644 --- a/ios/Framework/Core/Resources/en.lproj/login-screenlet.strings +++ b/ios/Framework/Core/Resources/en.lproj/login-screenlet.strings @@ -1,4 +1,3 @@ -"login-screenlet-loading-message"="Signing in..."; -"login-screenlet-loading-details"="Wait few seconds..."; +"login-screenlet-loading-message"="Signing in...\nWait few seconds..."; "login-screenlet-loading-error"="Error signing in."; "login-screenlet-validation"="Enter the user name and password"; diff --git a/ios/Framework/Core/Resources/es.lproj/login-screenlet.strings b/ios/Framework/Core/Resources/es.lproj/login-screenlet.strings index 0d3cf3853a..890779f70a 100644 --- a/ios/Framework/Core/Resources/es.lproj/login-screenlet.strings +++ b/ios/Framework/Core/Resources/es.lproj/login-screenlet.strings @@ -1,4 +1,3 @@ -"login-screenlet-loading-message"="Enviando petición..."; -"login-screenlet-loading-details"="Espere unos segundos..."; +"login-screenlet-loading-message"="Enviando petición...\nEspere unos segundos..."; "login-screenlet-loading-error"="Error intentando entrar."; "login-screenlet-validation"="Introduzca usuario y contraseña"; diff --git a/ios/Framework/Themes/Default/Auth/LoginScreenlet/LoginView_default.swift b/ios/Framework/Themes/Default/Auth/LoginScreenlet/LoginView_default.swift index b7f72c7a82..4d46223432 100644 --- a/ios/Framework/Themes/Default/Auth/LoginScreenlet/LoginView_default.swift +++ b/ios/Framework/Themes/Default/Auth/LoginScreenlet/LoginView_default.swift @@ -25,6 +25,13 @@ public class LoginView_default: BaseScreenletView, LoginViewModel { @IBOutlet public weak var passwordBackground: UIImageView! @IBOutlet public weak var authorizeButton: UIButton! + override public var progressMessages: [String:ProgressMessages] { + return [ + BaseScreenlet.DefaultAction : + [.Loading : LocalizedString("login-screenlet", "loading-message", self), + .Failure : LocalizedString("login-screenlet", "loading-error", self)]] + } + //MARK: AuthBasedViewModel From a29fc6ed76efbe8ad799483a4aa897f385bbe5ae Mon Sep 17 00:00:00 2001 From: JM Date: Thu, 6 Aug 2015 18:19:05 +0200 Subject: [PATCH 031/365] LSR-239 Implement detail text --- ios/Framework/Core/Base/MBProgressHUDPresenter.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ios/Framework/Core/Base/MBProgressHUDPresenter.swift b/ios/Framework/Core/Base/MBProgressHUDPresenter.swift index fee0e357e9..a7790ed8ce 100644 --- a/ios/Framework/Core/Base/MBProgressHUDPresenter.swift +++ b/ios/Framework/Core/Base/MBProgressHUDPresenter.swift @@ -118,12 +118,12 @@ internal let MBProgressHUDLock = "hud-lock" action: "simpleTapDetected:")) } - if message != nil { - hud.labelText = message - } + let components = message?.componentsSeparatedByCharactersInSet(NSCharacterSet.newlineCharacterSet()) - //TODO details - hud.detailsLabelText = ("DETAILS" ?? "") as String + if let components = components { + hud.labelText = components[0] + hud.detailsLabelText = components.count > 1 ? components[1] : nil + } hud.show(true) From 70708f0f58160fb0eb904d7c3b4b676bacc238fa Mon Sep 17 00:00:00 2001 From: JM Date: Thu, 6 Aug 2015 18:24:11 +0200 Subject: [PATCH 032/365] LSR-239 Change WebContentDisplayScreenlet progress messages --- .../en.lproj/webcontentdisplay-screenlet.strings | 3 +-- .../es.lproj/webcontentdisplay-screenlet.strings | 3 +-- .../LiferayWebContentLoadOperation.swift | 9 --------- .../WebContentDisplayView_default.swift | 8 ++++++++ 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/ios/Framework/Core/Resources/en.lproj/webcontentdisplay-screenlet.strings b/ios/Framework/Core/Resources/en.lproj/webcontentdisplay-screenlet.strings index a3022f35a8..140fb10c8e 100644 --- a/ios/Framework/Core/Resources/en.lproj/webcontentdisplay-screenlet.strings +++ b/ios/Framework/Core/Resources/en.lproj/webcontentdisplay-screenlet.strings @@ -1,3 +1,2 @@ -"webcontentdisplay-screenlet-loading-message"="Loading..."; -"webcontentdisplay-screenlet-loading-details"="Wait few seconds..."; +"webcontentdisplay-screenlet-loading-message"="Loading...\nWait few seconds..."; "webcontentdisplay-screenlet-loading-error"="Error loading the content"; diff --git a/ios/Framework/Core/Resources/es.lproj/webcontentdisplay-screenlet.strings b/ios/Framework/Core/Resources/es.lproj/webcontentdisplay-screenlet.strings index 95f073dcc4..eb1af550c4 100644 --- a/ios/Framework/Core/Resources/es.lproj/webcontentdisplay-screenlet.strings +++ b/ios/Framework/Core/Resources/es.lproj/webcontentdisplay-screenlet.strings @@ -1,3 +1,2 @@ -"webcontentdisplay-screenlet-loading-message"="Cargando..."; -"webcontentdisplay-screenlet-loading-details"="Espere unos segundos..."; +"webcontentdisplay-screenlet-loading-message"="Cargando...\nEspere unos segundos..."; "webcontentdisplay-screenlet-loading-error"="Error cargando el contenido"; diff --git a/ios/Framework/Core/WebContentDisplayScreenlet/ServerOperations/LiferayWebContentLoadOperation.swift b/ios/Framework/Core/WebContentDisplayScreenlet/ServerOperations/LiferayWebContentLoadOperation.swift index b282075c9f..4d205a9a16 100644 --- a/ios/Framework/Core/WebContentDisplayScreenlet/ServerOperations/LiferayWebContentLoadOperation.swift +++ b/ios/Framework/Core/WebContentDisplayScreenlet/ServerOperations/LiferayWebContentLoadOperation.swift @@ -22,15 +22,6 @@ public class LiferayWebContentLoadOperation: ServerOperation { public var resultHTML: String? - override public var hudLoadingMessage: HUDMessage? { - return (LocalizedString("webcontentdisplay-screenlet", "loading-message", self), - details: LocalizedString("webcontentdisplay-screenlet", "loading-details", self)) - } - override public var hudFailureMessage: HUDMessage? { - return (LocalizedString("webcontentdisplay-screenlet", "loading-error", self), details: nil) - } - - //MARK: ServerOperation override func validateData() -> Bool { diff --git a/ios/Framework/Themes/Default/WebContentDisplayScreenlet/WebContentDisplayView_default.swift b/ios/Framework/Themes/Default/WebContentDisplayScreenlet/WebContentDisplayView_default.swift index 4d6b7f119b..bded0abbe3 100644 --- a/ios/Framework/Themes/Default/WebContentDisplayScreenlet/WebContentDisplayView_default.swift +++ b/ios/Framework/Themes/Default/WebContentDisplayScreenlet/WebContentDisplayView_default.swift @@ -18,6 +18,14 @@ public class WebContentDisplayView_default: BaseScreenletView, WebContentDisplay @IBOutlet public var webView: UIWebView? + override public var progressMessages: [String:ProgressMessages] { + return [ + BaseScreenlet.DefaultAction : + [.Loading : LocalizedString("webcontentdisplay-screenlet", "loading-message", self), + .Failure : LocalizedString("webcontentdisplay-screenlet", "loading-error", self)]] + } + + private let styles = ".MobileCSS {padding: 4%; width: 92%;} " + ".MobileCSS, .MobileCSS span, .MobileCSS p, .MobileCSS h1, .MobileCSS h2, .MobileCSS h3 { " + From e8dee663fd4fc61c7c3b309f563fa706e17a8c9f Mon Sep 17 00:00:00 2001 From: JM Date: Thu, 6 Aug 2015 18:28:21 +0200 Subject: [PATCH 033/365] LSR-239 Remove unused methods --- ios/Framework/Core/Base/BaseScreenlet.swift | 6 ---- .../Core/Base/MBProgressHUDPresenter.swift | 28 ------------------- .../Core/Base/ProgressPresenter.swift | 3 -- ios/Framework/Core/Base/ServerOperation.swift | 4 ++- 4 files changed, 3 insertions(+), 38 deletions(-) diff --git a/ios/Framework/Core/Base/BaseScreenlet.swift b/ios/Framework/Core/Base/BaseScreenlet.swift index 90b0abb034..5c84ab15d4 100644 --- a/ios/Framework/Core/Base/BaseScreenlet.swift +++ b/ios/Framework/Core/Base/BaseScreenlet.swift @@ -369,12 +369,6 @@ import QuartzCore spinnerMode: .NoSpinner) } - public func hideHUDWithMessage(message: String) { - assert(_progressPresenter != nil, "ProgressPresenter must exist") - - _progressPresenter!.hideHUDWithMessage(message) - } - public func hideHUD() { assert(_progressPresenter != nil, "ProgressPresenter must exist") diff --git a/ios/Framework/Core/Base/MBProgressHUDPresenter.swift b/ios/Framework/Core/Base/MBProgressHUDPresenter.swift index a7790ed8ce..7ae5e1b3c0 100644 --- a/ios/Framework/Core/Base/MBProgressHUDPresenter.swift +++ b/ios/Framework/Core/Base/MBProgressHUDPresenter.swift @@ -36,20 +36,6 @@ internal let MBProgressHUDLock = "hud-lock" } } - public func showHUDInView(view: UIView) { - showHUDInView(view, - message: nil, - closeMode: .ManualClose, - spinnerMode: .IndeterminateSpinner) - } - - public func showHUDInView(view: UIView, message:String) { - showHUDInView(view, - message: message, - closeMode: .ManualClose, - spinnerMode: .IndeterminateSpinner) - } - public func hideHUD() { assert(self.instance != nil, "MBProgressHUD must exist") @@ -61,19 +47,6 @@ internal let MBProgressHUDLock = "hud-lock" } } - public func hideHUDWithMessage(message: String) { - assert(self.instance != nil, "MBProgressHUD must exist") - - synchronized(MBProgressHUDLock) { - dispatch_main { - self.configureAndShowHUD(self.instance!, - message: message, - closeMode: .Autoclose_TouchClosable, - spinnerMode: .NoSpinner) - } - } - } - public func showHUDInView(view: UIView, message: String?, closeMode: ProgressCloseMode, @@ -159,4 +132,3 @@ internal let MBProgressHUDLock = "hud-lock" } } - diff --git a/ios/Framework/Core/Base/ProgressPresenter.swift b/ios/Framework/Core/Base/ProgressPresenter.swift index a395f10474..2d4e43e747 100644 --- a/ios/Framework/Core/Base/ProgressPresenter.swift +++ b/ios/Framework/Core/Base/ProgressPresenter.swift @@ -30,15 +30,12 @@ import Foundation @objc public protocol ProgressPresenter { - func showHUDInView(view: UIView) - func showHUDInView(view: UIView, message: String) func showHUDInView(view: UIView, message: String?, closeMode: ProgressCloseMode, spinnerMode: ProgressSpinnerMode) func hideHUD() - func hideHUDWithMessage(message: String) } diff --git a/ios/Framework/Core/Base/ServerOperation.swift b/ios/Framework/Core/Base/ServerOperation.swift index 8b13d0b924..69bfadcfd5 100644 --- a/ios/Framework/Core/Base/ServerOperation.swift +++ b/ios/Framework/Core/Base/ServerOperation.swift @@ -174,7 +174,9 @@ public class ServerOperation: NSOperation { } internal func hideHUD(#message: String) { - self.screenlet.hideHUDWithMessage(message) + self.screenlet.showHUDWithMessage(message, + closeMode: .ManualClose_TouchClosable, + spinnerMode: .NoSpinner) } internal func hideHUD(#errorMessage: String) { From 76fa5e660773ad29891aefcbe2c94a5e09fc1b3c Mon Sep 17 00:00:00 2001 From: JM Date: Thu, 6 Aug 2015 18:31:59 +0200 Subject: [PATCH 034/365] LSR-239 Remove HUD methods from ServerOperation --- ios/Framework/Core/Base/ServerOperation.swift | 80 ++----------------- .../LiferayDDLFormSubmitOperation.swift | 4 +- 2 files changed, 8 insertions(+), 76 deletions(-) diff --git a/ios/Framework/Core/Base/ServerOperation.swift b/ios/Framework/Core/Base/ServerOperation.swift index 69bfadcfd5..17d539a106 100644 --- a/ios/Framework/Core/Base/ServerOperation.swift +++ b/ios/Framework/Core/Base/ServerOperation.swift @@ -31,16 +31,14 @@ public class ServerOperation: NSOperation { } - + //TODO remove public typealias HUDMessage = (String, details: String?) - - - public var lastError: NSError? - public var hudLoadingMessage: HUDMessage? { return nil } public var hudFailureMessage: HUDMessage? { return nil } public var hudSuccessMessage: HUDMessage? { return nil } + public var lastError: NSError? + internal var screenlet: BaseScreenlet internal var onComplete: (ServerOperation -> Void)? @@ -143,55 +141,12 @@ public class ServerOperation: NSOperation { //MARK: HUD methods - internal func showHUD(#message: String, details: String? = nil) { - dispatch_async(dispatch_get_main_queue()) { - self.screenlet.showHUDWithMessage(message, - closeMode: .ManualClose, - spinnerMode: .IndeterminateSpinner) - } - } - - internal func showHUD( - #message: String, - closeMode: ProgressCloseMode, - spinnerMode: ProgressSpinnerMode) { - - dispatch_main { - self.screenlet.showHUDWithMessage(message, - closeMode: closeMode, - spinnerMode: spinnerMode) - } - } - internal func showValidationHUD(#message: String, details: String? = nil) { dispatch_main { self.screenlet.showHUDAlert(message: message) } } - internal func hideHUD() { - self.screenlet.hideHUD() - } - - internal func hideHUD(#message: String) { - self.screenlet.showHUDWithMessage(message, - closeMode: .ManualClose_TouchClosable, - spinnerMode: .NoSpinner) - } - - internal func hideHUD(#errorMessage: String) { - self.screenlet.showHUDWithMessage(errorMessage, - closeMode: .ManualClose_TouchClosable, - spinnerMode: .NoSpinner) - } - - internal func hideHUD(#error: NSError, message: String) { - self.screenlet.showHUDWithMessage(message, - closeMode: .ManualClose_TouchClosable, - spinnerMode: .NoSpinner) - } - - //MARK: Private methods private func callOnComplete() { @@ -206,35 +161,14 @@ public class ServerOperation: NSOperation { } private func prepareRun() { - self.screenlet.onStartOperation() - self.screenlet.screenletView?.onStartOperation() - - if let messageValue = hudLoadingMessage { - showHUD(message: messageValue.0, details: messageValue.details) + dispatch_main { + self.screenlet.onStartOperation() + self.screenlet.screenletView?.onStartOperation() } } private func finishRun() { - if let lastErrorValue = lastError { - if let messageValue = hudFailureMessage { - hideHUD(error: lastErrorValue, - message: messageValue.0, - details: messageValue.details) - } - else if hudLoadingMessage != nil { - hideHUD() - } - } - else { - if let messageValue = hudSuccessMessage { - hideHUD(message: messageValue.0, details: messageValue.details) - } - else if hudLoadingMessage != nil { - hideHUD() - } - } - - dispatch_async(dispatch_get_main_queue()) { + dispatch_main { self.screenlet.onFinishOperation() self.screenlet.screenletView?.onFinishOperation() } diff --git a/ios/Framework/Core/DDL/FormScreenlet/ServerOperations/LiferayDDLFormSubmitOperation.swift b/ios/Framework/Core/DDL/FormScreenlet/ServerOperations/LiferayDDLFormSubmitOperation.swift index b3fb1d80bf..84f0697845 100644 --- a/ios/Framework/Core/DDL/FormScreenlet/ServerOperations/LiferayDDLFormSubmitOperation.swift +++ b/ios/Framework/Core/DDL/FormScreenlet/ServerOperations/LiferayDDLFormSubmitOperation.swift @@ -56,9 +56,7 @@ public class LiferayDDLFormSubmitOperation: ServerOperation { valid = valid && !viewModel.values.isEmpty if valid && !viewModel.validateForm(autoscroll: autoscrollOnValidation) { - showHUD(message: LocalizedString("ddlform-screenlet", "validation", self), - closeMode: .Autoclose_TouchClosable, - spinnerMode: .NoSpinner) + showValidationHUD(message: LocalizedString("ddlform-screenlet", "validation", self)) valid = false } From abcf9d0b2a64005fad42a9a92d13f5ea126df492 Mon Sep 17 00:00:00 2001 From: JM Date: Thu, 6 Aug 2015 19:01:15 +0200 Subject: [PATCH 035/365] LSR-239 Change SignUpScreenlet to new progress messages --- .../ServerOperations/LiferaySignUpOperation.swift | 8 -------- .../LiferayUpdateCurrentUserOperation.swift | 8 -------- .../Core/Resources/de.lproj/signup-screenlet.strings | 6 ++---- .../Core/Resources/en.lproj/signup-screenlet.strings | 6 ++---- .../Core/Resources/es.lproj/signup-screenlet.strings | 6 ++---- .../Auth/SignUpScreenlet/SignUpView_default.swift | 11 +++++++++++ 6 files changed, 17 insertions(+), 28 deletions(-) diff --git a/ios/Framework/Core/Auth/SignUpScreenlet/ServerOperations/LiferaySignUpOperation.swift b/ios/Framework/Core/Auth/SignUpScreenlet/ServerOperations/LiferaySignUpOperation.swift index d0ece74f16..7efb38d03e 100644 --- a/ios/Framework/Core/Auth/SignUpScreenlet/ServerOperations/LiferaySignUpOperation.swift +++ b/ios/Framework/Core/Auth/SignUpScreenlet/ServerOperations/LiferaySignUpOperation.swift @@ -20,14 +20,6 @@ public class LiferaySignUpOperation: ServerOperation { public var resultUserAttributes: [String:AnyObject]? - override public var hudLoadingMessage: HUDMessage? { - return (LocalizedString("signup-screenlet", "loading-message", self), - details: LocalizedString("signup-screenlet", "loading-details", self)) - } - override public var hudFailureMessage: HUDMessage? { - return (LocalizedString("signup-screenlet", "loading-error", self), details: nil) - } - private var viewModel: SignUpViewModel { return screenlet.screenletView as! SignUpViewModel } diff --git a/ios/Framework/Core/Auth/SignUpScreenlet/ServerOperations/LiferayUpdateCurrentUserOperation.swift b/ios/Framework/Core/Auth/SignUpScreenlet/ServerOperations/LiferayUpdateCurrentUserOperation.swift index f655708a73..48200755f8 100644 --- a/ios/Framework/Core/Auth/SignUpScreenlet/ServerOperations/LiferayUpdateCurrentUserOperation.swift +++ b/ios/Framework/Core/Auth/SignUpScreenlet/ServerOperations/LiferayUpdateCurrentUserOperation.swift @@ -18,14 +18,6 @@ public class LiferayUpdateCurrentUserOperation: ServerOperation { public var resultUserAttributes: [String:AnyObject]? - override public var hudLoadingMessage: HUDMessage? { - return (LocalizedString("signup-screenlet", "saving-message", self), - details: LocalizedString("signup-screenlet", "saving-details", self)) - } - override public var hudFailureMessage: HUDMessage? { - return (LocalizedString("signup-screenlet", "saving-error", self), details: nil) - } - private var viewModel: SignUpViewModel { return screenlet.screenletView as! SignUpViewModel } diff --git a/ios/Framework/Core/Resources/de.lproj/signup-screenlet.strings b/ios/Framework/Core/Resources/de.lproj/signup-screenlet.strings index 509f893c68..f09bf54a95 100644 --- a/ios/Framework/Core/Resources/de.lproj/signup-screenlet.strings +++ b/ios/Framework/Core/Resources/de.lproj/signup-screenlet.strings @@ -1,7 +1,5 @@ -"signup-screenlet-loading-message"="Anmelden..."; -"signup-screenlet-saving-message"="Sending..."; -"signup-screenlet-loading-details"="Warte ein paar Sekunden..."; -"signup-screenlet-saving-details"="Warte ein paar Sekunden..."; +"signup-screenlet-loading-message"="Anmelden...\nWarte ein paar Sekunden..."; +"signup-screenlet-saving-message"="Sending...\nWarte ein paar Sekunden..."; "signup-screenlet-loading-error"="Anmeldefehler."; "signup-screenlet-saving-error"="Error sending data."; "signup-screenlet-validation"="Bitte geben Sie Ihre E-Mail Adresse ein"; diff --git a/ios/Framework/Core/Resources/en.lproj/signup-screenlet.strings b/ios/Framework/Core/Resources/en.lproj/signup-screenlet.strings index 3a853314e1..62d0c9b0cc 100644 --- a/ios/Framework/Core/Resources/en.lproj/signup-screenlet.strings +++ b/ios/Framework/Core/Resources/en.lproj/signup-screenlet.strings @@ -1,7 +1,5 @@ -"signup-screenlet-loading-message"="Signing up..."; -"signup-screenlet-saving-message"="Sending..."; -"signup-screenlet-loading-details"="Wait few seconds..."; -"signup-screenlet-saving-details"="Wait few seconds..."; +"signup-screenlet-loading-message"="Signing up...\nWait few seconds..."; +"signup-screenlet-saving-message"="Sending...\nWait few seconds..."; "signup-screenlet-loading-error"="Error signing up."; "signup-screenlet-saving-error"="Error sending data."; "signup-screenlet-validation"="Please, enter your email address at least"; diff --git a/ios/Framework/Core/Resources/es.lproj/signup-screenlet.strings b/ios/Framework/Core/Resources/es.lproj/signup-screenlet.strings index f1225b601f..2b221fe431 100644 --- a/ios/Framework/Core/Resources/es.lproj/signup-screenlet.strings +++ b/ios/Framework/Core/Resources/es.lproj/signup-screenlet.strings @@ -1,7 +1,5 @@ -"signup-screenlet-loading-message"="Registrando usuario..."; -"signup-screenlet-saving-message"="Enviando datos..."; -"signup-screenlet-loading-details"="Espere unos segundos..."; -"signup-screenlet-saving-details"="Espere unos segundos..."; +"signup-screenlet-loading-message"="Registrando usuario...\nEspere unos segundos..."; +"signup-screenlet-saving-message"="Enviando datos...\nEspere unos segundos..."; "signup-screenlet-loading-error"="Error registrando usuario"; "signup-screenlet-saving-error"="Error enviando datos"; "signup-screenlet-validation"="Introduce al menos el correo electrónico"; diff --git a/ios/Framework/Themes/Default/Auth/SignUpScreenlet/SignUpView_default.swift b/ios/Framework/Themes/Default/Auth/SignUpScreenlet/SignUpView_default.swift index eb2eb857ab..4158b60118 100644 --- a/ios/Framework/Themes/Default/Auth/SignUpScreenlet/SignUpView_default.swift +++ b/ios/Framework/Themes/Default/Auth/SignUpScreenlet/SignUpView_default.swift @@ -31,6 +31,17 @@ public class SignUpView_default: BaseScreenletView, SignUpViewModel { //MARK: BaseScreenletView + override public var progressMessages: [String:ProgressMessages] { + return [ + "signup-action" : + [.Loading : LocalizedString("signup-screenlet", "loading-message", self), + .Failure : LocalizedString("signup-screenlet", "loading-error", self)], + "save-action" : + [.Loading : LocalizedString("signup-screenlet", "saving-message", self), + .Failure : LocalizedString("signup-screenlet", "saving-error", self)], + ] + } + override public func onStartOperation() { signUpButton!.enabled = false } From 54c6a3a97992ff454fe32a041ccabdf4b02ee5f8 Mon Sep 17 00:00:00 2001 From: Javier Gamarra Date: Tue, 11 Aug 2015 12:17:07 +0200 Subject: [PATCH 036/365] LSR-294 rename web view to better match the screenlet name --- android/samples/test-app/src/main/AndroidManifest.xml | 2 +- .../liferay/mobile/screens/testapp/MainActivity.java | 10 +++++----- ...iewActivity.java => WebContentDisplayActivity.java} | 6 +++--- .../test-app/src/main/res/layout/activity_main.xml | 2 +- .../layout/{web_view.xml => web_content_display.xml} | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) rename android/samples/test-app/src/main/java/com/liferay/mobile/screens/testapp/{WebViewActivity.java => WebContentDisplayActivity.java} (87%) rename android/samples/test-app/src/main/res/layout/{web_view.xml => web_content_display.xml} (94%) diff --git a/android/samples/test-app/src/main/AndroidManifest.xml b/android/samples/test-app/src/main/AndroidManifest.xml index ffff8adca7..2b72dcce5f 100644 --- a/android/samples/test-app/src/main/AndroidManifest.xml +++ b/android/samples/test-app/src/main/AndroidManifest.xml @@ -28,7 +28,7 @@ - + diff --git a/android/samples/test-app/src/main/java/com/liferay/mobile/screens/testapp/MainActivity.java b/android/samples/test-app/src/main/java/com/liferay/mobile/screens/testapp/MainActivity.java index 32738fc369..73873b6d9d 100644 --- a/android/samples/test-app/src/main/java/com/liferay/mobile/screens/testapp/MainActivity.java +++ b/android/samples/test-app/src/main/java/com/liferay/mobile/screens/testapp/MainActivity.java @@ -16,17 +16,17 @@ protected void onCreate(Bundle state) { super.onCreate(state); setContentView(R.layout.activity_main); - findViewById(R.id.login).setOnClickListener(this); - findViewById(R.id.asset_list).setOnClickListener(this); findViewById(R.id.ddl_form).setOnClickListener(this); findViewById(R.id.ddl_list).setOnClickListener(this); + findViewById(R.id.asset_list).setOnClickListener(this); findViewById(R.id.sign_up).setOnClickListener(this); findViewById(R.id.forgot_password).setOnClickListener(this); findViewById(R.id.user_portrait).setOnClickListener(this); - findViewById(R.id.web_view).setOnClickListener(this); + findViewById(R.id.web_content_display).setOnClickListener(this); findViewById(R.id.add_bookmark).setOnClickListener(this); findViewById(R.id.login_full_screenlet).setOnClickListener(this); findViewById(R.id.change_theme).setOnClickListener(this); + findViewById(R.id.login).setOnClickListener(this); } @Override @@ -51,8 +51,8 @@ public void onClick(View v) { case R.id.user_portrait: DefaultAnimation.startActivityWithAnimation(this, getIntentWithTheme(UserPortraitActivity.class)); break; - case R.id.web_view: - DefaultAnimation.startActivityWithAnimation(this, getIntentWithTheme(WebViewActivity.class)); + case R.id.web_content_display: + DefaultAnimation.startActivityWithAnimation(this, getIntentWithTheme(WebContentDisplayActivity.class)); break; case R.id.add_bookmark: DefaultAnimation.startActivityWithAnimation(this, getIntentWithTheme(AddBookmarkActivity.class)); diff --git a/android/samples/test-app/src/main/java/com/liferay/mobile/screens/testapp/WebViewActivity.java b/android/samples/test-app/src/main/java/com/liferay/mobile/screens/testapp/WebContentDisplayActivity.java similarity index 87% rename from android/samples/test-app/src/main/java/com/liferay/mobile/screens/testapp/WebViewActivity.java rename to android/samples/test-app/src/main/java/com/liferay/mobile/screens/testapp/WebContentDisplayActivity.java index 39f5217a48..84e06f57fb 100644 --- a/android/samples/test-app/src/main/java/com/liferay/mobile/screens/testapp/WebViewActivity.java +++ b/android/samples/test-app/src/main/java/com/liferay/mobile/screens/testapp/WebContentDisplayActivity.java @@ -22,15 +22,15 @@ /** * @author Javier Gamarra */ -public class WebViewActivity extends ThemeActivity implements WebContentDisplayListener { +public class WebContentDisplayActivity extends ThemeActivity implements WebContentDisplayListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.web_view); + setContentView(R.layout.web_content_display); - WebContentDisplayScreenlet screenlet = (WebContentDisplayScreenlet) findViewById(R.id.web_view); + WebContentDisplayScreenlet screenlet = (WebContentDisplayScreenlet) findViewById(R.id.web_content_display); screenlet.setListener(this); } diff --git a/android/samples/test-app/src/main/res/layout/activity_main.xml b/android/samples/test-app/src/main/res/layout/activity_main.xml index 60fd55e6ee..4be16aedce 100644 --- a/android/samples/test-app/src/main/res/layout/activity_main.xml +++ b/android/samples/test-app/src/main/res/layout/activity_main.xml @@ -46,7 +46,7 @@ android:text="@string/user_portrait"/>