Commit 1b89d78c authored by Emily Toop's avatar Emily Toop
Browse files

Bug 1585661 - Add messaging examples to Android Studio. r=agi

Differential Revision: https://phabricator.services.mozilla.com/D48565

--HG--
extra : moz-landing-system : lando
parent 4bce142d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
/build
+51 −0
Original line number Diff line number Diff line
buildDir "${topobjdir}/gradle/build/mobile/android/examples/messaging_example"

apply plugin: 'com.android.application'

apply from: "${topsrcdir}/mobile/android/gradle/product_flavors.gradle"

android {
    compileSdkVersion project.ext.compileSdkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    defaultConfig {
        applicationId "org.mozilla.geckoview.example.messaging"
        targetSdkVersion project.ext.targetSdkVersion
        minSdkVersion project.ext.minSdkVersion
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    // By default the android plugins ignores folders that start with `_`, but
    // we need those in web extensions.
    // See also:
    //  - https://issuetracker.google.com/issues/36911326
    //  - https://stackoverflow.com/questions/9206117/how-to-workaround-autoomitting-fiiles-folders-starting-with-underscore-in
    aaptOptions {
        ignoreAssetsPattern  '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
    }

    project.configureProductFlavors.delegate = it
    project.configureProductFlavors()
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "com.android.support:support-annotations:$support_library_version"
    implementation "com.android.support:appcompat-v7:$support_library_version"
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation project(path: ':geckoview')
}
+21 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="org.mozilla.geckoview.example.messaging">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
 No newline at end of file
+16 −0
Original line number Diff line number Diff line
{
  "manifest_version": 2,
  "name": "messaging",
  "version": "1.0",
  "description": "Example messaging web extension.",
  "content_scripts": [
    {
      "matches": ["*://*.twitter.com/*"],
      "js": ["messaging.js"]
    }
  ],
  "permissions": [
    "nativeMessaging",
    "geckoViewAddons"
  ]
}
+9 −0
Original line number Diff line number Diff line
let manifest = document.querySelector("head > link[rel=manifest]");
if (manifest) {
  fetch(manifest.href)
    .then(response => response.json())
    .then(json => {
      let message = { type: "WPAManifest", manifest: json };
      browser.runtime.sendNativeMessage("browser", message);
    });
}
Loading