Skip to content

Commit fcf3231

Browse files
committed
[ RELEASE ] 0.2.0
1 parent e625d41 commit fcf3231

File tree

74 files changed

+13798
-266
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+13798
-266
lines changed

LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

README.md

Lines changed: 15 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -4,107 +4,29 @@
44
55
*Only Android support now.*
66

7-
### - 0.0.7 to 0.1.0 migration
7+
### - 0.2.0 Release
88

9-
* progress name event changed to status
10-
11-
```Diff
12-
componentWillMount() {
13-
...
14-
- TorrentStreamer.addEventListener('progress', this.onProgress.bind(this))
15-
+ TorrentStreamer.addEventListener('status', this.onStatus.bind(this))
16-
...
17-
}
18-
```
19-
20-
* New params on status event
21-
22-
```Diff
23-
- onStatus({ data }) {
24-
+ onStatus({progress, buffer, downloadSpeed, seeds}) {
25-
...
26-
}
27-
```
9+
* Support react-native 0.60.x
10+
* TorrentStream-Android updated to
2811

2912
#### Integrate
3013

3114
##### Android
3215

3316
* Install via npm
34-
`npm i react-native-torrent-streamer --save-dev`
35-
36-
* Add dependency to `android/settings.gradle`
37-
```
38-
...
39-
include ':react-native-torrent-streamer'
40-
project(':react-native-torrent-streamer').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-torrent-streamer/android/torrent')
41-
```
42-
43-
* Add `android/app/build.gradle`
44-
```
45-
...
46-
dependencies {
47-
...
48-
compile project(':react-native-torrent-streamer')
49-
}
50-
```
51-
#### If you're using react-native 0.25~0.29, follow these steps
52-
53-
* Register module in `MainActivity.java`
54-
```Java
55-
import com.ghondar.torrentstreamer.*; // <--- import
56-
57-
@Override
58-
protected void onCreate(Bundle savedInstanceState) {
59-
super.onCreate(savedInstanceState);
60-
mReactRootView = new ReactRootView(this);
61-
62-
mReactInstanceManager = ReactInstanceManager.builder()
63-
.setApplication(getApplication())
64-
.setBundleAssetName("index.android.bundle")
65-
.setJSMainModuleName("index.android")
66-
.addPackage(new TorrentStreamerPackage()) // <------- here
67-
.addPackage(new MainReactPackage())
68-
.setUseDeveloperSupport(BuildConfig.DEBUG)
69-
.setInitialLifecycleState(LifecycleState.RESUMED)
70-
.build();
71-
72-
mReactRootView.startReactApplication(mReactInstanceManager, "doubanbook", null);
73-
74-
setContentView(mReactRootView);
75-
}
76-
```
77-
78-
#### If you're using react-native 0.30+, follow these steps
79-
80-
##### Register module in `MainApplication.java`
81-
```Java
82-
import com.ghondar.torrentstreamer.*; // <--- import
83-
84-
@Override
85-
protected List<ReactPackage> getPackages() {
86-
return Arrays.<ReactPackage>asList(
87-
new MainReactPackage(),
88-
new TorrentStreamerPackage() // <------- here
89-
);
90-
}
91-
```
92-
93-
#### If you are using react-native-torrent-streamer@0.1.0+
17+
`yarn add react-native-torrent-streamer`
9418

9519
* Add `android/build.gradle`
96-
``` Diff
20+
```Diff
21+
...
9722
allprojects {
98-
repositories {
99-
mavenLocal()
100-
jcenter()
101-
maven {
102-
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
103-
url "$rootDir/../node_modules/react-native/android"
104-
}
105-
+ maven { url "https://jitpack.io" }
106-
107-
}
23+
...
24+
dependencies {
25+
...
26+
+ maven {
27+
+ url("https://jitpack.io")
28+
+ }
29+
}
10830
}
10931
```
11032

@@ -124,7 +46,7 @@ export default class App extends Component<{}> {
12446
seeds: 0
12547
}
12648

127-
componentWillMount() {
49+
componentDidMount() {
12850
TorrentStreamer.addEventListener('error', this.onError)
12951
TorrentStreamer.addEventListener('status', this.onStatus.bind(this))
13052
TorrentStreamer.addEventListener('ready', this.onReady.bind(this))
@@ -178,7 +100,7 @@ export default class App extends Component<{}> {
178100
}
179101

180102
_handleStart() {
181-
TorrentStreamer.start('magnet:?xt=urn:btih:D60795899F8488E7E489BA642DEFBCE1B23C9DA0&dn=Kingsman%3A+The+Secret+Service+%282014%29+%5B720p%5D&tr=http%3A%2F%2Ftracker.yify-torrents.com%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.org%3A80&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Fopen.demonii.com%3A1337&tr=udp%3A%2F%2Fp4p.arenabg.ch%3A1337&tr=udp%3A%2F%2Fp4p.arenabg.com%3A1337')
103+
TorrentStreamer.start('magnet:?xt=urn:btih:88594aaacbde40ef3e2510c47374ec0aa396c08e&dn=bbb%5Fsunflower%5F1080p%5F30fps%5Fnormal.mp4&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80%2Fannounce&ws=http%3A%2F%2Fdistribution.bbb3d.renderfarming.net%2Fvideo%2Fmp4%2Fbbb%5Fsunflower%5F1080p%5F30fps%5Fnormal.mp4')
182104
}
183105

184106
_handleStop() {

android/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
README
2+
======
3+
4+
If you want to publish the lib as a maven dependency, follow these steps before publishing a new version to npm:
5+
6+
1. Be sure to have the Android [SDK](https://developer.android.com/studio/index.html) and [NDK](https://developer.android.com/ndk/guides/index.html) installed
7+
2. Be sure to have a `local.properties` file in this folder that points to the Android SDK and NDK
8+
```
9+
ndk.dir=/Users/{username}/Library/Android/sdk/ndk-bundle
10+
sdk.dir=/Users/{username}/Library/Android/sdk
11+
```
12+
3. Delete the `maven` folder
13+
4. Run `sudo ./gradlew installArchives`
14+
5. Verify that latest set of generated files is in the maven folder with the correct version number

android/build.gradle

Lines changed: 117 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,129 @@
1-
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2-
31
buildscript {
2+
ext.safeExtGet = {prop, fallback ->
3+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
4+
}
45
repositories {
6+
google()
57
jcenter()
68
}
9+
710
dependencies {
8-
classpath 'com.android.tools.build:gradle:1.3.1'
11+
// Matches recent template from React Native (0.60)
12+
// https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L16
13+
classpath("com.android.tools.build:gradle:${safeExtGet('gradlePluginVersion', '3.4.1')}")
14+
}
15+
}
16+
17+
apply plugin: 'com.android.library'
18+
apply plugin: 'maven'
19+
20+
// Matches values in recent template from React Native 0.59 / 0.60
21+
// https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L5-L9
22+
// https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L5-L9
23+
def DEFAULT_COMPILE_SDK_VERSION = 28
24+
def DEFAULT_BUILD_TOOLS_VERSION = "28.0.3"
25+
def DEFAULT_MIN_SDK_VERSION = 16
26+
def DEFAULT_TARGET_SDK_VERSION = 28
27+
28+
android {
29+
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
30+
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
31+
32+
defaultConfig {
33+
minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
34+
targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
35+
versionCode 1
36+
versionName "1.0"
37+
}
38+
lintOptions {
39+
abortOnError false
40+
}
41+
}
942

10-
// NOTE: Do not place your application dependencies here; they belong
11-
// in the individual module build.gradle files
43+
repositories {
44+
maven {
45+
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
46+
// Matches recent template from React Native 0.59 / 0.60
47+
// https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L30
48+
// https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L28
49+
url "$projectDir/../node_modules/react-native/android"
1250
}
51+
mavenCentral()
1352
}
1453

15-
allprojects {
16-
repositories {
17-
mavenLocal()
18-
jcenter()
19-
maven {
20-
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
21-
url "$projectDir/../../node_modules/react-native/android"
54+
dependencies {
55+
implementation fileTree(dir: 'libs', include: ['*.jar'])
56+
implementation "com.facebook.react:react-native:${safeExtGet('reactnativeVersion', '+')}"
57+
implementation "com.github.TorrentStream:TorrentStream-Android:2.4.0"
58+
}
59+
60+
def configureReactNativePom(def pom) {
61+
def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text)
62+
63+
pom.project {
64+
name packageJson.title
65+
artifactId packageJson.name
66+
version = packageJson.version
67+
group = "com.ghondar.torrentstreamer"
68+
description packageJson.description
69+
url packageJson.repository.baseUrl
70+
71+
licenses {
72+
license {
73+
name packageJson.license
74+
url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename
75+
distribution 'repo'
76+
}
77+
}
78+
79+
developers {
80+
developer {
81+
id packageJson.author.username
82+
name packageJson.author.name
83+
}
84+
}
85+
}
86+
}
87+
88+
afterEvaluate { project ->
89+
90+
task androidJavadoc(type: Javadoc) {
91+
source = android.sourceSets.main.java.srcDirs
92+
classpath += files(android.bootClasspath)
93+
classpath += files(project.getConfigurations().getByName('compile').asList())
94+
include '**/*.java'
95+
}
96+
97+
task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
98+
classifier = 'javadoc'
99+
from androidJavadoc.destinationDir
100+
}
101+
102+
task androidSourcesJar(type: Jar) {
103+
classifier = 'sources'
104+
from android.sourceSets.main.java.srcDirs
105+
include '**/*.java'
106+
}
107+
108+
android.libraryVariants.all { variant ->
109+
def name = variant.name.capitalize()
110+
task "jar${name}"(type: Jar, dependsOn: variant.javaCompile) {
111+
from variant.javaCompile.destinationDir
112+
}
113+
}
114+
115+
artifacts {
116+
archives androidSourcesJar
117+
archives androidJavadocJar
118+
}
119+
120+
task installArchives(type: Upload) {
121+
configuration = configurations.archives
122+
repositories.mavenDeployer {
123+
// Deploy to react-native-event-bridge/maven, ready to publish to npm
124+
repository url: "file://${projectDir}/../android/maven"
125+
126+
configureReactNativePom pom
22127
}
23128
}
24129
}
-51 KB
Binary file not shown.

android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 0 additions & 5 deletions
This file was deleted.

android/settings.gradle

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.ghondar.torrentstreamer">
3+
<uses-permission android:name="android.permission.INTERNET" />
4+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
5+
</manifest>

0 commit comments

Comments
 (0)