-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(): release capacitor plugin for medias
- Loading branch information
0 parents
commit 62a47e1
Showing
45 changed files
with
2,418 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,8 @@ | ||
dist/ | ||
node_modules/ | ||
|
||
|
||
Pods | ||
Build | ||
*.iml | ||
.idea |
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 @@ | ||
|
||
Pod::Spec.new do |s| | ||
s.name = 'CapacitorMedia' | ||
s.version = '0.0.1' | ||
s.summary = 'Enable some media features for Capacitor, such as create albums, save videos and gifs.' | ||
s.license = 'MIT' | ||
s.homepage = 'https://github.com/stewwan/capacitor-media' | ||
s.author = 'Stewan Silva' | ||
s.source = { :git => 'https://github.com/stewwan/capacitor-media', :tag => s.version.to_s } | ||
s.source_files = 'ios/Plugin/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}' | ||
s.ios.deployment_target = '11.0' | ||
s.dependency 'Capacitor' | ||
end |
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,79 @@ | ||
# capacitor-media | ||
|
||
Capacitor plugin to activate media features such as saving videos and gifs into user's photo gallery | ||
|
||
## API | ||
|
||
- savePhoto | ||
- saveVideo | ||
- saveGif | ||
- createAlbum | ||
- getAlbums | ||
- getMedias `only ios for now` | ||
|
||
## Usage | ||
|
||
```js | ||
import { Media } from "capacitor-media"; | ||
const media = new Media(); | ||
|
||
// | ||
// Save video to a specfic album | ||
media | ||
.saveVideo({ path: "/path/to/the/file", album: "My Album" }) | ||
.then(console.log) | ||
.catch(console.log); | ||
|
||
// | ||
// Get a list of user albums | ||
media | ||
.getAlbums() | ||
.then(console.log) // -> { albums: [{name:'My Album'}, {name:'My Another Album'}]} | ||
.catch(console.log); | ||
``` | ||
|
||
## iOS setup | ||
|
||
- `ionic start my-cap-app --capacitor` | ||
- `cd my-cap-app` | ||
- `npm install —-save capacitor-media` | ||
- `mkdir www && touch www/index.html` | ||
- `npx cap add ios` | ||
- `npx cap open ios` | ||
- sign your app at xcode (general tab) | ||
|
||
> Tip: every time you change a native code you may need to clean up the cache (Product > Clean build folder) and then run the app again. | ||
## Android setup | ||
|
||
- `ionic start my-cap-app --capacitor` | ||
- `cd my-cap-app` | ||
- `npm install —-save capacitor-media` | ||
- `mkdir www && touch www/index.html` | ||
- `npx cap add android` | ||
- `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);` | ||
Now you should be set to go. Try to run your client using `ionic cap run android --livereload`. | ||
|
||
> Tip: every time you change a native code you may need to clean up the cache (Build > Clean Project | Build > Rebuild Project) and then run the app again. | ||
## Sample app | ||
|
||
(coming soon) | ||
|
||
## You may also like | ||
|
||
- [capacitor-intercom](https://github.com/stewwan/capacitor-intercom) | ||
- [capacitor-fcm](https://github.com/stewwan/capacitor-fcm) | ||
- [capacitor-twitter](https://github.com/stewwan/capacitor-twitter) | ||
|
||
Cheers 🍻 | ||
|
||
Follow me [@Twitter](https://twitter.com/StewanSilva) | ||
|
||
## License | ||
|
||
MIT |
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 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild |
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 @@ | ||
/build |
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,50 @@ | ||
buildscript { | ||
repositories { | ||
jcenter() | ||
google() | ||
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle:3.1.1' | ||
} | ||
} | ||
|
||
apply plugin: 'com.android.library' | ||
|
||
android { | ||
compileSdkVersion 27 | ||
defaultConfig { | ||
minSdkVersion 21 | ||
targetSdkVersion 27 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
lintOptions { | ||
abortOnError false | ||
} | ||
} | ||
|
||
repositories { | ||
google() | ||
jcenter() | ||
mavenCentral() | ||
maven { | ||
url "https://dl.bintray.com/ionic-team/capacitor" | ||
} | ||
} | ||
|
||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation 'ionic-team:capacitor-android:1+' | ||
testImplementation 'junit:junit:4.12' | ||
androidTestImplementation 'com.android.support.test:runner:1.0.1' | ||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.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,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
26 changes: 26 additions & 0 deletions
26
...apacitor-media/src/androidTest/java/com/getcapacitor/android/ExampleInstrumentedTest.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,26 @@ | ||
package com.getcapacitor.android; | ||
|
||
import android.content.Context; | ||
import android.support.test.InstrumentationRegistry; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
@Test | ||
public void useAppContext() throws Exception { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getTargetContext(); | ||
|
||
assertEquals("com.getcapacitor.android", appContext.getPackageName()); | ||
} | ||
} |
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,4 @@ | ||
|
||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="io.stewan.capacitor.media.capacitormedia"> | ||
</manifest> |
Oops, something went wrong.