Skip to content

Commit

Permalink
Add Android
Browse files Browse the repository at this point in the history
  • Loading branch information
hansemannn committed Oct 20, 2017
1 parent eb41f0d commit f247200
Show file tree
Hide file tree
Showing 11 changed files with 208 additions and 0 deletions.
29 changes: 29 additions & 0 deletions android/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>titanium-firebase-analytics</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.appcelerator.titanium.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.aptana.ide.core.unifiedBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>com.appcelerator.titanium.mobile.module.nature</nature>
<nature>com.aptana.projects.webnature</nature>
</natures>
</projectDescription>
8 changes: 8 additions & 0 deletions android/Resources/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Files in this folder are copied directory into the compiled product directory
when the Android app is compiled:

<project-dir>/build/android/bin/assets/Resources/

Files in this directory are copied directly on top of whatever files are already
in the build directory, so please be careful that your files don't clobber
essential project files or files from other modules.
56 changes: 56 additions & 0 deletions android/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<project name="titanium-firebase-analytics" default="dist">
<description>
Ant build script for Titanium Android module titanium-firebase-analytics
</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>
8 changes: 8 additions & 0 deletions android/java-sources.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"/Users/hknoechel/Documents/appcelerator_modules/titanium-firebase/titanium-firebase-analytics/android/src/firebase/analytics/TitaniumFirebaseAnalyticsModule.java"
"/Users/hknoechel/Documents/appcelerator_modules/titanium-firebase/titanium-firebase-analytics/android/build/generated/java/firebase/analytics/TitaniumFirebaseAnalyticsBootstrap.java"
"/Users/hknoechel/Documents/appcelerator_modules/titanium-firebase/titanium-firebase-analytics/android/build/generated/r/android/support/compat/R.java"
"/Users/hknoechel/Documents/appcelerator_modules/titanium-firebase/titanium-firebase-analytics/android/build/generated/r/android/support/design/R.java"
"/Users/hknoechel/Documents/appcelerator_modules/titanium-firebase/titanium-firebase-analytics/android/build/generated/r/android/support/v7/appcompat/R.java"
"/Users/hknoechel/Documents/appcelerator_modules/titanium-firebase/titanium-firebase-analytics/android/build/generated/r/android/support/v7/cardview/R.java"
"/Users/hknoechel/Documents/appcelerator_modules/titanium-firebase/titanium-firebase-analytics/android/build/generated/r/firebase/analytics/R.java"
"/Users/hknoechel/Documents/appcelerator_modules/titanium-firebase/titanium-firebase-analytics/android/build/generated/r/ti/modules/titanium/ui/R.java"
Binary file added android/lib/firebase-analytics-11.0.4.aar
Binary file not shown.
Binary file added android/lib/firebase-analytics-impl-11.0.4.aar
Binary file not shown.
18 changes: 18 additions & 0 deletions android/manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 1.0.0
apiversion: 3
architectures: armeabi-v7a x86
description: titanium-firebase-analytics
author: Hans Knoechel
license: Apache 2
copyright: Copyright (c) 2017 by Axway Appcelerator

# these should not be edited
name: titanium-firebase-analytics
moduleid: firebase.analytics
guid: a1f48874-bd3a-4378-b623-79012aad1d20
platform: android
minsdk: 6.2.2.GA
10 changes: 10 additions & 0 deletions android/platform/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Files in this folder are copied directory into the Android build directory
when the Android app is compiled:

<project-dir>/build/android

You can place files such as res strings or drawable files.

Files in this directory are copied directly on top of whatever files are already
in the build directory, so please be careful that your files don't clobber
essential project files or files from other modules.
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* This file was auto-generated by the Titanium Module SDK helper for Android
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2010 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 firebase.analytics;

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

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

import android.os.Bundle;

import com.google.firebase.analytics.FirebaseAnalytics;
import com.google.firebase.analytics.FirebaseAnalytics.Param;

@Kroll.module(name="TitaniumFirebaseAnalytics", id="firebase.analytics")
public class TitaniumFirebaseAnalyticsModule extends KrollModule
{
private static final String LCAT = "TitaniumFirebaseAnalyticsModule";
private static final boolean DBG = TiConfig.LOGD;

public TitaniumFirebaseAnalyticsModule()
{
super();
}

@Kroll.method
public void log(String name, KrollDict parameters)
{
Bundle bundle = new Bundle();

// TODO: Loop through all keys and set accordingly
if (parameters.containsKey(Param.ACHIEVEMENT_ID)) {
bundle.putString(Param.ACHIEVEMENT_ID, TiConvert.toString(parameters, Param.ACHIEVEMENT_ID));
}

FirebaseAnalytics.getInstance(TiApplication.getInstance().getApplicationContext()).
logEvent(name, bundle);
}

@Kroll.method @Kroll.setProperty
public void setUserPropertyString(KrollDict parameters)
{
FirebaseAnalytics.getInstance(TiApplication.getInstance().getApplicationContext()).
setUserProperty(TiConvert.toString(parameters, "name"), TiConvert.toString(parameters, "value"));
}

@Kroll.method @Kroll.setProperty
public void setScreenNameAndScreenClass(KrollDict parameters)
{
Log.e(LCAT, "Firebase.setScreenNameAndScreenClass() is not implemented on Android, yet!");
}
}

7 changes: 7 additions & 0 deletions android/timodule.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ti:module xmlns:ti="http://ti.appcelerator.org" xmlns:android="http://schemas.android.com/apk/res/android">
<android xmlns:android="http://schemas.android.com/apk/res/android" />
<modules>
<module platform="android">ti.playservices</module>
</modules>
</ti:module>
9 changes: 9 additions & 0 deletions assets/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Place your assets like PNG files in this directory and they will be packaged
with your module.

All JavaScript files in the assets directory are IGNORED except if you create a
file named "firebase.analytics.js" in this directory in which case it will be
wrapped by native code, compiled, and used as your module. This allows you to
run pure JavaScript modules that are pre-compiled.

Note: Mobile Web does not support this assets directory.

0 comments on commit f247200

Please sign in to comment.