diff --git a/android/no-op/build.gradle b/android/no-op/build.gradle new file mode 100644 index 000000000..7781a358f --- /dev/null +++ b/android/no-op/build.gradle @@ -0,0 +1,38 @@ +// Copyright (c) Facebook, Inc. and its affiliates. +// +// This source code is licensed under the MIT license found in the LICENSE file +// in the root directory of this source tree. + +apply plugin: 'com.android.library' +apply plugin: 'maven' + +android { + compileSdkVersion rootProject.compileSdkVersion + buildToolsVersion rootProject.buildToolsVersion + + defaultConfig { + minSdkVersion rootProject.minSdkVersion + targetSdkVersion rootProject.targetSdkVersion + } + + sourceSets { + test { + java { + exclude 'com/facebook/flipper/plugins/facebook/**' + } + } + } + + dependencies { + implementation deps.jsr305 + } +} + +apply from: rootProject.file('gradle/release.gradle') + +task sourcesJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + classifier = 'sources' +} + +artifacts.add('archives', sourcesJar) diff --git a/android/no-op/gradle.properties b/android/no-op/gradle.properties new file mode 100644 index 000000000..81e507267 --- /dev/null +++ b/android/no-op/gradle.properties @@ -0,0 +1,21 @@ +# +# Copyright 2014-present Facebook, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# 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. +# + +POM_NAME=Flipper NoOp +POM_DESCRIPTION=No-Open Implementation of the Flipper SDK for Android +POM_ARTIFACT_ID=flipper-noop +POM_PACKAGING=aar + diff --git a/android/no-op/src/main/AndroidManifest.xml b/android/no-op/src/main/AndroidManifest.xml new file mode 100644 index 000000000..fc20fad09 --- /dev/null +++ b/android/no-op/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + diff --git a/android/no-op/src/main/java/com/facebook/flipper/android/AndroidFlipperClient.java b/android/no-op/src/main/java/com/facebook/flipper/android/AndroidFlipperClient.java new file mode 100644 index 000000000..4f3015ecb --- /dev/null +++ b/android/no-op/src/main/java/com/facebook/flipper/android/AndroidFlipperClient.java @@ -0,0 +1,20 @@ +/* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + */ +package com.facebook.flipper.android; + +import android.content.Context; +import com.facebook.flipper.core.FlipperClient; + +public final class AndroidFlipperClient { + public static FlipperClient getInstance(Context context) { + return new NoOpAndroidFlipperClient(); + } + + public static FlipperClient getInstanceIfInitialized() { + return new NoOpAndroidFlipperClient(); + } +} diff --git a/android/no-op/src/main/java/com/facebook/flipper/android/NoOpAndroidFlipperClient.java b/android/no-op/src/main/java/com/facebook/flipper/android/NoOpAndroidFlipperClient.java new file mode 100644 index 000000000..a9e2450dd --- /dev/null +++ b/android/no-op/src/main/java/com/facebook/flipper/android/NoOpAndroidFlipperClient.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +package com.facebook.flipper.android; + +import com.facebook.flipper.core.FlipperClient; +import com.facebook.flipper.core.FlipperPlugin; +import javax.annotation.Nullable; + +public class NoOpAndroidFlipperClient implements FlipperClient { + + @Override + public void addPlugin(FlipperPlugin plugin) { + // no-op + } + + @Nullable + @Override + public T getPlugin(String id) { + return null; + } + + @Nullable + @Override + public T getPluginByClass(Class cls) { + return null; + } + + @Override + public void removePlugin(FlipperPlugin plugin) { + // no-op + } + + @Override + public void start() { + // no-op + } + + @Override + public void stop() { + // no-op + } + + @Override + public void unsubscribe() { + // no-op + } +} diff --git a/android/no-op/src/main/java/com/facebook/flipper/core/FlipperClient.java b/android/no-op/src/main/java/com/facebook/flipper/core/FlipperClient.java new file mode 100644 index 000000000..4d24f432c --- /dev/null +++ b/android/no-op/src/main/java/com/facebook/flipper/core/FlipperClient.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +package com.facebook.flipper.core; + +import javax.annotation.Nullable; + +public interface FlipperClient { + void addPlugin(FlipperPlugin plugin); + + @Nullable + T getPlugin(String id); + + @Nullable + T getPluginByClass(Class cls); + + void removePlugin(FlipperPlugin plugin); + + void start(); + + void stop(); + + void unsubscribe(); +} diff --git a/android/no-op/src/main/java/com/facebook/flipper/core/FlipperPlugin.java b/android/no-op/src/main/java/com/facebook/flipper/core/FlipperPlugin.java new file mode 100644 index 000000000..9b6d58b65 --- /dev/null +++ b/android/no-op/src/main/java/com/facebook/flipper/core/FlipperPlugin.java @@ -0,0 +1,10 @@ +/* + * Copyright (c) 2018-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +package com.facebook.flipper.core; + +public interface FlipperPlugin {} diff --git a/settings.gradle b/settings.gradle index bc72047c5..210a380a5 100644 --- a/settings.gradle +++ b/settings.gradle @@ -18,6 +18,7 @@ include ':glog' include ':libevent' include ':rsocket' include ':third-party' +include ':noop' project(':fbjni').projectDir = file('libs/fbjni') project(':easywsclient').projectDir = file('libs/easywsclient') @@ -30,3 +31,4 @@ project(':folly').projectDir = file('android/third-party/external/folly/') project(':libevent').projectDir = file('android/third-party/external/LibEvent/') project(':rsocket').projectDir = file('android/third-party/external/RSocket/') project(':third-party').projectDir = file('android/third-party/') +project(':noop').projectDir = file('android/no-op/')