Skip to content

Commit

Permalink
Add basic Android parity
Browse files Browse the repository at this point in the history
  • Loading branch information
hansemannn committed Apr 14, 2018
1 parent 7a0d204 commit 5fe135e
Show file tree
Hide file tree
Showing 627 changed files with 57,307 additions and 16 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Expand Up @@ -12,7 +12,7 @@ Copyright 2017-Present Appcelerator, Inc.
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitation s under the License.



Expand Down
59 changes: 48 additions & 11 deletions README.md
@@ -1,12 +1,36 @@
# Parse Live Query in Titanium

Use the Parse & Parse Live Query iOS SDK's in Axway Titanium! Read more about the Parse Live Query API
in the [official native repository](https://github.com/parse-community/ParseLiveQuery-iOS-OSX).
Use the Parse & Parse Live Query iOS and Android SDK's in Axway Titanium! Read more about the Parse Live Query API
in the official native repositories:

- iOS: https://github.com/parse-community/ParseLiveQuery-iOS-OSX
- Android: https://github.com/parse-community/ParseLiveQuery-Android

> Warning: While iOS is ready for production, Android is highly dependent on community contributions. Submit a pull request
to expose new features, e.g. query subscriptions.

## Requirements

- [x] Swift 4.1 or later (embedded into the hook in `hooks/`)
- [x] Titanium SDK 6.3.0 or later (7.1.0.GA used in testing)
- [x] iOS: Swift 4.1+ (embedded into the hook in `hooks/`), iOS 8+
- [x] Android: Gradle, Android 4.1+
- [x] Titanium SDK 6.3.0+ (7.0.0+ for Android)

## Setup

### iOS

No additional setup required.

### Android

Add the following to the `<android>` manifest section of the tiapp.xml:
```xml
<application ...>
...
<meta-data android:name="com.parse.SERVER_URL" android:value="YOUR_SERVER_URL" />
<meta-data android:name="com.parse.APPLICATION_ID" android:value="YOUR_APP_ID" />
</application>
```

## API'S

Expand All @@ -21,7 +45,7 @@ in the [official native repository](https://github.com/parse-community/ParseLive
- `server` (String)
- `localDatastoreEnabled` (Boolean)

##### `createClient(args: Dictionary)`
##### `createClient(args: Dictionary)` **iOS only**

- `applicationId` (String)
- `clientKey` (String)
Expand All @@ -33,7 +57,9 @@ in the [official native repository](https://github.com/parse-community/ParseLive
- `parameters` (Dictionary)
- `callback` (Function)

#### Constants
##### `clearAllCachedResults()`

#### Constants **iOS only**

##### EVENT_TYPE_ENTERED
##### EVENT_TYPE_LEFT
Expand All @@ -43,7 +69,7 @@ in the [official native repository](https://github.com/parse-community/ParseLive

---

### `Client`
### `Client` **iOS only**

#### Methods

Expand All @@ -62,7 +88,7 @@ in the [official native repository](https://github.com/parse-community/ParseLive
- `className` (String)
- `query` (String)

#### Events
#### Events **iOS only**

##### `subscribe`

Expand All @@ -85,7 +111,7 @@ in the [official native repository](https://github.com/parse-community/ParseLive

---

### `Query`
### `Query` **iOS only**

#### Initializer (`createQuery(args)`)

Expand All @@ -98,9 +124,11 @@ in the [official native repository](https://github.com/parse-community/ParseLive

- `callback` (Function)

##### `clearCachedResult()`

---

### `Object`
### `Object` **iOS only**

#### Properties

Expand All @@ -124,7 +152,9 @@ in the [official native repository](https://github.com/parse-community/ParseLive

##### `deleteObject()`

## Compile Swift Libraries
## Compile native libraries

### iOS

This project uses the following 5 Swift dependencies:

Expand Down Expand Up @@ -159,6 +189,12 @@ These steps are based on a [Shell Script](https://gist.github.com/cromandini/1a9

Note: In the future, this will all be done by CocoaPods. Make sure to follow [TIMOB-25927](https://jira.appcelerator.org/browse/TIMOB-25927) regarding Swift support in the SDK.

### Android

0. Install Gradle and go to `android/`
1. Run `gradle getDeps`
2. Validate that the libraries are copied to `lib/`

## Example

```js
Expand Down Expand Up @@ -186,6 +222,7 @@ btn1.addEventListener('click', function() {
});
});

// iOS only
btn2.addEventListener('click', function() {
var client = ParseLiveQuery.createClient({
applicationId: '',
Expand Down
26 changes: 26 additions & 0 deletions android/.clang-format
@@ -0,0 +1,26 @@
---
Language: Java
AccessModifierOffset: -4
AllowShortBlocksOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
# class, constructor, method should be next line
BreakBeforeBraces: Linux
# Keep '=' at end of line when wrapping, but move things like '&&', '||' to beginning of newline
BreakBeforeBinaryOperators: NonAssignment
# FIXME: break for brace after synchronized block, anonymous class declarations
BreakAfterJavaFieldAnnotations: true
ColumnLimit: 120
IndentCaseLabels: true
IndentWidth: 4
MaxEmptyLinesToKeep: 1
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpacesInParentheses: false
TabWidth: 4
UseTab: ForContinuationAndIndentation
SpaceAfterCStyleCast: true
# Spaces inside {} for array literals, i.e. "new Object[] { args }"
Cpp11BracedListStyle: false
ReflowComments: false
11 changes: 11 additions & 0 deletions android/.classpath
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="android/src"/>
<classpathentry kind="src" path="android/build/.apt_generated"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="/opt/android-sdk/platforms/android-23/android.jar"/>
<classpathentry kind="lib" path="/Users/hknoechel/Library/Application Support/Titanium/mobilesdk/osx/7.1.0.GA/android/titanium.jar"/>
<classpathentry kind="lib" path="/Users/hknoechel/Library/Application Support/Titanium/mobilesdk/osx/7.1.0.GA/android/kroll-common.jar"/>
<classpathentry kind="lib" path="/Users/hknoechel/Library/Application Support/Titanium/mobilesdk/osx/7.1.0.GA/android/kroll-apt.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Binary file added android/.gradle/4.6/fileChanges/last-build.bin
Binary file not shown.
Binary file added android/.gradle/4.6/fileContent/fileContent.lock
Binary file not shown.
Binary file added android/.gradle/4.6/fileHashes/fileHashes.bin
Binary file not shown.
Binary file added android/.gradle/4.6/fileHashes/fileHashes.lock
Binary file not shown.
Binary file added android/.gradle/4.6/taskHistory/taskHistory.bin
Binary file not shown.
Binary file added android/.gradle/4.6/taskHistory/taskHistory.lock
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions android/.gradle/buildOutputCleanup/cache.properties
@@ -0,0 +1,2 @@
#Sat Apr 14 12:08:02 CEST 2018
gradle.version=4.6
Binary file not shown.
Empty file.
7 changes: 7 additions & 0 deletions android/.settings/org.eclipse.jdt.apt.core.prefs
@@ -0,0 +1,7 @@
#Thu Sep 02 15:18:34 CDT 2010
eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=true
org.eclipse.jdt.apt.genSrcDir=.apt_generated
org.eclipse.jdt.apt.reconcileEnabled=true

org.eclipse.jdt.apt.processorOptions/kroll.jsonFile=titanium-parse-live-query.json
3 changes: 3 additions & 0 deletions android/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,3 @@
#Thu Sep 02 15:18:34 CDT 2010
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.processAnnotations=enabled
17 changes: 17 additions & 0 deletions android/build.gradle
@@ -0,0 +1,17 @@
apply plugin: 'java'

repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
compile 'com.parse:parse-livequery-android:1.0.5'
}

task getDeps(type: Copy) {
from sourceSets.main.runtimeClasspath
exclude 'support-*'
into 'lib/'
}
56 changes: 56 additions & 0 deletions android/build.xml
@@ -0,0 +1,56 @@
<project name="titanium-parse-live-query" default="dist">
<description>
Ant build script for Titanium Android module titanium-parse-live-query
</description>

<property name="ti.module.root" location="${basedir}"/>
<property file="build.properties" />

<!-- Make sure 'architectures' is in manifest file -->
<property file="${ti.module.root}/manifest" prefix="manifest"/>
<fail message="Missing required manifest key 'architectures'.">
<condition>
<not>
<isset property="manifest.architectures"/>
</not>
</condition>
</fail>

<fail message="Manifest key 'architectures' has no value.">
<condition>
<not>
<length string="${manifest.architectures}" trim="true" when="greater" length="0"/>
</not>
</condition>
</fail>

<!-- Copy documentation subdirectories -->
<mkdir dir="${basedir}/documentation"/>
<copy todir="${basedir}/documentation">
<fileset dir="${basedir}/../documentation"/>
</copy>

<!-- Copy example subdirectories -->
<mkdir dir="${basedir}/example"/>
<copy todir="${basedir}/example">
<fileset dir="${basedir}/../example"/>
</copy>

<!-- Copy assets subdirectories -->
<mkdir dir="${basedir}/assets"/>
<copy todir="${basedir}/assets">
<fileset dir="${basedir}/../assets"/>
</copy>

<!-- Copy license -->
<copy todir="${basedir}" file="${basedir}/../LICENSE"/>

<target name="cleancopy" description="Delete old copies">
<delete dir="${basedir}/documentation"/>
<delete dir="${basedir}/example"/>
<delete dir="${basedir}/assets"/>
<delete file="${basedir}/LICENSE"/>
</target>

<import file="${titanium.platform}/../module/android/build.xml"/>
</project>
2 changes: 2 additions & 0 deletions android/lib/README
@@ -0,0 +1,2 @@
You can place any .jar dependencies in this directory and they will be included
when your module is being compiled.
Binary file added android/lib/bolts-tasks-1.4.0.jar
Binary file not shown.
Binary file added android/lib/okhttp-3.6.0.jar
Binary file not shown.
Binary file added android/lib/okio-1.11.0.jar
Binary file not shown.
Binary file added android/lib/parse-android-1.14.1.jar
Binary file not shown.
Binary file added android/lib/parse-livequery-android-1.0.5.aar
Binary file not shown.
18 changes: 18 additions & 0 deletions android/manifest
@@ -0,0 +1,18 @@
#
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 1.0.0
apiversion: 4
architectures: arm64-v8a armeabi-v7a x86
description: titanium-parse-live-query
author: Hans Knöchel
license: Apache 2
copyright: Copyright (c) 2018 by Hans Knöchel

# these should not be edited
name: titanium-parse-live-query
moduleid: ti.livequery
guid: 78df4bfc-1945-4f8e-97a7-af483c88a8cf
platform: android
minsdk: 7.0.0
76 changes: 76 additions & 0 deletions android/src/ti/livequery/TitaniumParseLiveQueryModule.java
@@ -0,0 +1,76 @@
/**
* This file was auto-generated by the Titanium Module SDK helper for Android
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2018 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*
*/
package ti.livequery;

import com.parse.Parse;
import com.parse.ParseObject;
import com.parse.ParseQuery;

import org.appcelerator.kroll.KrollModule;
import org.appcelerator.kroll.KrollFunction;
import org.appcelerator.kroll.annotations.Kroll;
import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.common.Log;
import org.appcelerator.kroll.common.TiConfig;

import org.appcelerator.titanium.TiApplication;
import org.appcelerator.titanium.util.TiConvert;

@Kroll.module(name = "TitaniumParseLiveQuery", id = "ti.livequery")
public class TitaniumParseLiveQueryModule extends KrollModule
{
// Standard Debugging variables
private static final String LCAT = "TitaniumParseLiveQueryModule";
private static final boolean DBG = TiConfig.LOGD;

// Methods

@Kroll.method
public void initialize(KrollDict args)
{
String applicationId = (String) args.get("applicationId");
String clientKey = (String) args.get("clientKey");
String server = (String) args.get("server");
Boolean localDatastoreEnabled = TiConvert.toBoolean(args.get("localDatastoreEnabled"), false);

Parse.Configuration.Builder builder =
new Parse.Configuration.Builder(TiApplication.getInstance().getCurrentActivity())
.applicationId(applicationId)
.clientKey(clientKey)
.server(server);

if (localDatastoreEnabled) {
builder = builder.enableLocalDataStore();
}

Parse.initialize(builder.build());
}

@Kroll.method
public void saveObject(KrollDict object)
{
String className = (String) object.get("className");
KrollDict parameters = (KrollDict) object.get("parameters");
KrollFunction callback = (KrollFunction) object.get("callback");

ParseObject newObject = new ParseObject(className);

for (String key : parameters.keySet()) {
newObject.put(key, parameters.get(key));
}

newObject.saveInBackground();
}

@Kroll.method
public void clearAllCachedResults()
{
ParseQuery.clearAllCachedResults();
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -15,6 +15,10 @@

- (void)initialize:(id)args;

- (void)setLogLevel:(id)logLevel;

- (void)saveObject:(id)args;

- (void)clearAllCachedResults:(id)unused;

@end

0 comments on commit 5fe135e

Please sign in to comment.