forked from flutter/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move various first-party plugins into this repo (flutter#36)
* Added image_picker * Added firebase_analytics * Added firebase_storage * Added google_sign_in * Added firebase_auth * Added firebase_database
- Loading branch information
1 parent
c4a7224
commit 36f2948
Showing
219 changed files
with
7,629 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.DS_Store | ||
.atom/ | ||
.idea | ||
.packages | ||
.pub/ | ||
build/ | ||
ios/.generated/ | ||
packages | ||
pubspec.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Copyright 2017, the Flutter project authors. All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are | ||
met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided | ||
with the distribution. | ||
* Neither the name of Google Inc. nor the names of its | ||
contributors may be used to endorse or promote products derived | ||
from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Firebase Analytics for Flutter | ||
|
||
**WARNING: this is incomplete and highly experimental** | ||
|
||
This plugin allows Flutter apps use the Firebase Analytics API from their Dart | ||
code. | ||
|
||
## Getting Started | ||
|
||
The the `example` directory for a sample app using Firebase Analytics. | ||
|
||
To learn more about Flutter plugins, view our online | ||
[documentation](https://flutter.io/platform-plugins). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
/build | ||
/captures | ||
|
||
/gradle | ||
/gradlew | ||
/gradlew.bat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
group 'io.flutter.firebase_analytics' | ||
version '1.0-SNAPSHOT' | ||
|
||
buildscript { | ||
repositories { | ||
jcenter() | ||
} | ||
|
||
dependencies { | ||
classpath 'com.android.tools.build:gradle:2.3.0' | ||
} | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
jcenter() | ||
} | ||
} | ||
|
||
apply plugin: 'com.android.library' | ||
|
||
android { | ||
compileSdkVersion 25 | ||
buildToolsVersion '25.0.2' | ||
|
||
defaultConfig { | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
lintOptions { | ||
disable 'InvalidPackage' | ||
} | ||
dependencies { | ||
compile 'com.google.firebase:firebase-auth:10.2.1' | ||
compile 'com.google.firebase:firebase-analytics:10.2.1' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.gradle.jvmargs=-Xmx1536M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rootProject.name = 'firebase_analytics' |
11 changes: 11 additions & 0 deletions
11
packages/firebase_analytics/android/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="io.flutter.firebase_analytics" | ||
android:versionCode="1" | ||
android:versionName="0.0.1"> | ||
|
||
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="21" /> | ||
|
||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.WAKE_LOCK" /> | ||
</manifest> |
147 changes: 147 additions & 0 deletions
147
...nalytics/android/src/main/java/io/flutter/firebase_analytics/FirebaseAnalyticsPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
// Copyright 2017 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
package io.flutter.firebase_analytics; | ||
|
||
import java.util.Map; | ||
|
||
import com.google.firebase.FirebaseApp; | ||
import com.google.firebase.analytics.FirebaseAnalytics; | ||
|
||
import android.app.Activity; | ||
import android.os.Bundle; | ||
|
||
import io.flutter.plugin.common.MethodChannel; | ||
import io.flutter.plugin.common.MethodChannel.MethodCallHandler; | ||
import io.flutter.plugin.common.MethodChannel.Result; | ||
import io.flutter.plugin.common.MethodCall; | ||
import io.flutter.plugin.common.PluginRegistry; | ||
|
||
/** | ||
* Flutter plugin for Firebase Analytics. | ||
*/ | ||
public class FirebaseAnalyticsPlugin implements MethodCallHandler { | ||
private final Activity activity; | ||
private final FirebaseAnalytics firebaseAnalytics; | ||
|
||
public static void registerWith(PluginRegistry.Registrar registrar) { | ||
final MethodChannel channel = new MethodChannel(registrar.messenger(), "firebase_analytics"); | ||
channel.setMethodCallHandler(new FirebaseAnalyticsPlugin(registrar.activity())); | ||
} | ||
|
||
private FirebaseAnalyticsPlugin(Activity activity) { | ||
this.activity = activity; | ||
FirebaseApp.initializeApp(activity); | ||
this.firebaseAnalytics = FirebaseAnalytics.getInstance(activity); | ||
} | ||
|
||
@Override | ||
public void onMethodCall(MethodCall call, Result result) { | ||
switch (call.method) { | ||
case "logEvent": | ||
handleLogEvent(call, result); | ||
break; | ||
case "setUserId": | ||
handleSetUserId(call, result); | ||
break; | ||
case "setCurrentScreen": | ||
handleSetCurrentScreen(call, result); | ||
break; | ||
case "setAnalyticsCollectionEnabled": | ||
handleSetAnalyticsCollectionEnabled(call, result); | ||
break; | ||
case "setMinimumSessionDuration": | ||
handleSetMinimumSessionDuration(call, result); | ||
break; | ||
case "setSessionTimeoutDuration": | ||
handleSetSessionTimeoutDuration(call, result); | ||
break; | ||
case "setUserProperty": | ||
handleSetUserProperty(call, result); | ||
break; | ||
default: | ||
result.notImplemented(); | ||
break; | ||
} | ||
} | ||
|
||
private void handleLogEvent(MethodCall call, Result result) { | ||
@SuppressWarnings("unchecked") | ||
Map<String, Object> arguments = (Map<String, Object>) call.arguments; | ||
final String eventName = (String) arguments.get("name"); | ||
|
||
@SuppressWarnings("unchecked") | ||
final Bundle parameterBundle = createBundleFromMap((Map<String, Object>) arguments.get("parameters")); | ||
firebaseAnalytics.logEvent(eventName, parameterBundle); | ||
result.success(null); | ||
} | ||
|
||
private void handleSetUserId(MethodCall call, Result result) { | ||
final String id = (String) call.arguments; | ||
firebaseAnalytics.setUserId(id); | ||
result.success(null); | ||
} | ||
|
||
private void handleSetCurrentScreen(MethodCall call, Result result) { | ||
@SuppressWarnings("unchecked") | ||
Map<String, Object> arguments = (Map<String, Object>) call.arguments; | ||
final String screenName = (String) arguments.get("screenName"); | ||
final String screenClassOverride = (String) arguments.get("screenClassOverride"); | ||
|
||
firebaseAnalytics.setCurrentScreen(activity, screenName, screenClassOverride); | ||
result.success(null); | ||
} | ||
|
||
private void handleSetAnalyticsCollectionEnabled(MethodCall call, Result result) { | ||
final Boolean enabled = (Boolean) call.arguments; | ||
firebaseAnalytics.setAnalyticsCollectionEnabled(enabled); | ||
result.success(null); | ||
} | ||
|
||
private void handleSetMinimumSessionDuration(MethodCall call, Result result) { | ||
final Integer milliseconds = (Integer) call.arguments; | ||
firebaseAnalytics.setMinimumSessionDuration(milliseconds); | ||
result.success(null); | ||
} | ||
|
||
private void handleSetSessionTimeoutDuration(MethodCall call, Result result) { | ||
final Integer milliseconds = (Integer) call.arguments; | ||
firebaseAnalytics.setSessionTimeoutDuration(milliseconds); | ||
result.success(null); | ||
} | ||
|
||
private void handleSetUserProperty(MethodCall call, Result result) { | ||
@SuppressWarnings("unchecked") | ||
Map<String, Object> arguments = (Map<String, Object>) call.arguments; | ||
final String name = (String) arguments.get("name"); | ||
final String value = (String) arguments.get("value"); | ||
|
||
firebaseAnalytics.setUserProperty(name, value); | ||
result.success(null); | ||
} | ||
|
||
private static Bundle createBundleFromMap(Map<String, Object> map) { | ||
if (map == null) { | ||
return null; | ||
} | ||
|
||
Bundle bundle = new Bundle(); | ||
for (Map.Entry<String, Object> jsonParam : map.entrySet()) { | ||
final Object value = jsonParam.getValue(); | ||
final String key = jsonParam.getKey(); | ||
if (value instanceof String) { | ||
bundle.putString(key, (String) value); | ||
} else if (value instanceof Integer) { | ||
bundle.putInt(key, (Integer) value); | ||
} else if (value instanceof Double) { | ||
bundle.putDouble(key, (Double) value); | ||
} else if (value instanceof Boolean) { | ||
bundle.putBoolean(key, (Boolean) value); | ||
} else { | ||
throw new IllegalArgumentException("Unsupported value type: " + value.getClass().getCanonicalName()); | ||
} | ||
} | ||
return bundle; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.DS_Store | ||
.atom/ | ||
.idea | ||
.packages | ||
.pub/ | ||
build/ | ||
ios/.generated/ | ||
packages | ||
pubspec.lock | ||
.flutter-plugins |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# firebase_analytics_example | ||
|
||
Demonstrates how to use the firebase_analytics plugin. | ||
|
||
## Getting Started | ||
|
||
For help getting started with Flutter, view our online | ||
[documentation](http://flutter.io/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$/android"> | ||
<sourceFolder url="file://$MODULE_DIR$/android/app/src/main/java" isTestSource="false" /> | ||
</content> | ||
<orderEntry type="jdk" jdkName="Android API 25 Platform" jdkType="Android SDK" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="library" name="Flutter for Android" level="project" /> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
/build | ||
/captures | ||
|
||
/gradle | ||
/gradlew | ||
/gradlew.bat |
46 changes: 46 additions & 0 deletions
46
packages/firebase_analytics/example/android/app/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
def localProperties = new Properties() | ||
def localPropertiesFile = rootProject.file('local.properties') | ||
if (localPropertiesFile.exists()) { | ||
localPropertiesFile.withInputStream { stream -> | ||
localProperties.load(stream) | ||
} | ||
} | ||
|
||
def flutterRoot = localProperties.getProperty('flutter.sdk') | ||
if (flutterRoot == null) { | ||
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") | ||
} | ||
|
||
apply plugin: 'com.android.application' | ||
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" | ||
|
||
android { | ||
compileSdkVersion 25 | ||
buildToolsVersion '25.0.2' | ||
|
||
lintOptions { | ||
disable 'InvalidPackage' | ||
} | ||
|
||
defaultConfig { | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
// TODO: Add your own signing config for the release build. | ||
// Signing with the debug keys for now, so `flutter run --release` works. | ||
signingConfig signingConfigs.debug | ||
} | ||
} | ||
} | ||
|
||
flutter { | ||
source '../..' | ||
} | ||
|
||
dependencies { | ||
compile 'com.google.firebase:firebase-core:10.0.1' | ||
} | ||
|
||
apply plugin: 'com.google.gms.google-services' |
Oops, something went wrong.