Skip to content

Commit

Permalink
fix(android): revamp platform. fixes #6
Browse files Browse the repository at this point in the history
  • Loading branch information
stewones committed Jul 1, 2020
1 parent 38a78e7 commit ebdce5b
Show file tree
Hide file tree
Showing 18 changed files with 72 additions and 68 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ npx cap sync
## Usage

```js
import { Media } from "@capacitor-community/media";
import { Media } from '@capacitor-community/media';
const media = new Media();

//
// Save video to a specfic album
media
.saveVideo({ path: "/path/to/the/file", album: "My Album" })
.saveVideo({ path: '/path/to/the/file', album: 'My Album' })
.then(console.log)
.catch(console.log);

Expand All @@ -82,7 +82,7 @@ media
Make sure you pass the correct album parameter according to the platform

```js
album: this.platform.is("ios") ? album.identifier : album.name;
album: this.platform.is('ios') ? album.identifier : album.name;
```

## iOS setup
Expand All @@ -107,7 +107,7 @@ album: this.platform.is("ios") ? album.identifier : album.name;
- `npx cap open android`
- `[extra step]` in android case we need to tell Capacitor to initialise the plugin:

> on your `MainActivity.java` file add `import io.stewan.capacitor.media.MediaPlugin;` and then inside the init callback `add(MediaPlugin.class);`
> on your `MainActivity.java` file add `import com.getcapacitor.community.media.MediaPlugin;` and then inside the init callback `add(MediaPlugin.class);`
Now you should be set to go. Try to run your client using `ionic cap run android --livereload`.

Expand Down
8 changes: 0 additions & 8 deletions android/.npmignore
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
53 changes: 53 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
ext {
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.12'
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.1'
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.2.0'
}

buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
}
}

apply plugin: 'com.android.library'

android {
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 29
defaultConfig {
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 21
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}

repositories {
google()
jcenter()
mavenCentral()
}


dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':capacitor-android')
testImplementation "junit:junit:$junitVersion"
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
implementation 'com.android.support:appcompat-v7:27.1.1'
}
1 change: 0 additions & 1 deletion android/capacitor-media/.npmignore

This file was deleted.

48 changes: 0 additions & 48 deletions android/capacitor-media/build.gradle

This file was deleted.

4 changes: 4 additions & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ org.gradle.jvmargs=-Xmx1536m
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

# Supports AndroidX
android.useAndroidX=true
android.enableJetifier=true
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
File renamed without changes.
Empty file removed android/scripts/release.sh
Empty file.
2 changes: 2 additions & 0 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include ':capacitor-android'
project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor')
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.getcapacitor.android;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -19,7 +20,7 @@ public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();

assertEquals("com.getcapacitor.android", appContext.getPackageName());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.stewan.capacitor.media.capacitormedia">
</manifest>
package="com.getcapacitor.community.media.media">
</manifest>

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.stewan.capacitor.media;
package com.getcapacitor.community.media;

import android.Manifest;
import android.content.Intent;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit ebdce5b

Please sign in to comment.