Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Commit #1

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# Flutter/Dart/Pub related
**/doc/api/
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/

# Web related
lib/generated_plugin_registrant.dart
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "interactive"
}
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
# amplify-flutter
# amplify-flutter

## Steps to run example android app:

1. `$ cd {project_dir}/packages/amplify_core/core/example/android`
2. Use team-provider file to init Amplify project
3. Install flutter sdk and Android Studio
4. `$ cd {project_dir}/packages/amplify_core/core/example`
5. `flutter run`
7 changes: 7 additions & 0 deletions packages/amplify_core/core/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DS_Store
.dart_tool/

.packages
.pub/

build/
10 changes: 10 additions & 0 deletions packages/amplify_core/core/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: f139b11009aeb8ed2a3a3aa8b0066e482709dde3
channel: stable

project_type: plugin
3 changes: 3 additions & 0 deletions packages/amplify_core/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 0.0.1

* TODO: Describe initial release.
1 change: 1 addition & 0 deletions packages/amplify_core/core/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TODO: Add your license here.
14 changes: 14 additions & 0 deletions packages/amplify_core/core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# core

A new flutter plugin project.

## Getting Started

This project is a starting point for a Flutter
[plug-in package](https://flutter.dev/developing-packages/),
a specialized package that includes platform-specific implementation code for
Android and/or iOS.

For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
6 changes: 6 additions & 0 deletions packages/amplify_core/core/android/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>
24 changes: 24 additions & 0 deletions packages/amplify_core/core/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures

#amplify
amplify/\#current-cloud-backend
amplify/.config/local-*
amplify/mock-data
amplify/backend/amplify-meta.json
amplify/backend/awscloudformation
build/
dist/
node_modules/
aws-exports.js
awsconfiguration.json
amplifyconfiguration.json
amplify-build-config.json
amplify-gradle-config.json
amplifyxc.config
23 changes: 23 additions & 0 deletions packages/amplify_core/core/android/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>core</name>
<comment>Project core created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>
52 changes: 52 additions & 0 deletions packages/amplify_core/core/android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
group 'com.amplify.flutter.core'
version '1.0'

buildscript {
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.amplifyframework:amplify-tools-gradle-plugin:0.2.1'
classpath 'com.amazonaws:aws-android-sdk-appsync-gradle-plugin:2.9.+'
}
}

rootProject.allprojects {
repositories {
google()
jcenter()
}
}

apply plugin: 'com.android.library'
apply plugin: 'com.amplifyframework.amplifytools'
apply plugin: 'com.amazonaws.appsync'

android {
compileSdkVersion 28

defaultConfig {
minSdkVersion 16
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
lintOptions {
disable 'InvalidPackage'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

dependencies {
implementation 'com.amplifyframework:core:0.10.0'
implementation 'com.amplifyframework:aws-storage-s3:0.10.0'
implementation 'com.amplifyframework:aws-api:0.10.0'
implementation 'com.amazonaws:aws-android-sdk-mobile-client:2.16.+'
implementation 'com.amazonaws:aws-android-sdk-appsync:2.9.+'
implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.0'
implementation 'org.eclipse.paho:org.eclipse.paho.android.service:1.1.1'
}
}
4 changes: 4 additions & 0 deletions packages/amplify_core/core/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
1 change: 1 addition & 0 deletions packages/amplify_core/core/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = 'core'
13 changes: 13 additions & 0 deletions packages/amplify_core/core/android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.amplify.flutter.core">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application>
<service android:name="org.eclipse.paho.android.service.MqttService" />

</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.amplify.flutter.core;


import android.app.Activity;
import android.content.Context;
import androidx.annotation.Nullable;
import com.amplifyframework.core.Amplify;


class Core {
private final Context applicationContext;
@Nullable private Activity activity;

Core(Context applicationContext, @Nullable Activity activity) {
System.out.println("JAVA CORE");
this.applicationContext = applicationContext;
this.activity = activity;
}

void setActivity(@Nullable Activity activity) {
this.activity = activity;
}

void configure() {}

Amplify getConfiguration() {
return new Amplify();
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package com.amplify.flutter.core;

import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.content.Context;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.embedding.engine.plugins.activity.ActivityAware;
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
import io.flutter.plugin.common.PluginRegistry.Registrar;
import com.amplifyframework.core.Amplify;


/**
* Plugin implementation that uses the new {@code io.flutter.embedding} package.
*
* <p>Instantiate this in an add to app scenario to gracefully handle activity and context changes.
*/
public final class CorePlugin implements FlutterPlugin, ActivityAware {
private static final String TAG = "CorePlugin";
@Nullable private MethodCallHandlerImpl methodCallHandler;
@Nullable private Core Core;
private Context applicationContext;

/**
* Registers a plugin implementation that uses the stable {@code io.flutter.plugin.common}
* package.
*
* <p>Calling this automatically initializes the plugin. However plugins initialized this way
* won't react to changes in activity or context, unlike {@link CorePlugin}.
// */
// public static void registerWith(Registrar registrar, Context context) {
// MethodCallHandlerImpl handler =
// new MethodCallHandlerImpl(new Core(registrar.context(), registrar.activity()), context);
// handler.startListening(registrar.messenger());
// }

@Override
public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) {
Core = new Core(binding.getApplicationContext(), /*activity=*/ null);
applicationContext = binding.getApplicationContext();
methodCallHandler = new MethodCallHandlerImpl(Core, applicationContext);
methodCallHandler.startListening(binding.getBinaryMessenger());
}

@Override
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
if (methodCallHandler == null) {
Log.wtf(TAG, "Already detached from the engine.");
return;
}

methodCallHandler.stopListening();
methodCallHandler = null;
Core = null;
}

@Override
public void onAttachedToActivity(@NonNull ActivityPluginBinding binding) {
if (methodCallHandler == null) {
Log.wtf(TAG, "Core was never set.");
return;
}

Core.setActivity(binding.getActivity());
}

@Override
public void onDetachedFromActivity() {
if (methodCallHandler == null) {
Log.wtf(TAG, "Core was never set.");
return;
}

Core.setActivity(null);
}

@Override
public void onDetachedFromActivityForConfigChanges() {
onDetachedFromActivity();
}

@Override
public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding binding) {
onAttachedToActivity(binding);
}
}