commit 8c0555024216ade762c105e1080ced2e63c7059d Author: Roy Olav Purser Date: Tue Jun 15 13:38:01 2021 +0200 first commit diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..a753346 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,17 @@ +kind: pipeline +name: default +steps: +- name: compile-chrome + image: roypur/chrome-packer:latest + commands: + - ./pack-chrome.sh +- name: gitea_release + image: plugins/gitea-release + settings: + api_key: + from_secret: gitea_token + base_url: https://git.purser.it + title: ${DRONE_TAG} + files: chrome.crx + when: + event: tag diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e88340c --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.pyc +app/gradle/wrapper/* +app/gradlew +app/gradlew.bat +app/gradle.properties +app/build/* +app/app/build/* +app/app/release/* +app/.idea/* +app/.gradle/* +app/gradle/* +chrome/*.png +*.crx +sources.json diff --git a/android/app/build.gradle b/android/app/build.gradle new file mode 100644 index 0000000..3e1564b --- /dev/null +++ b/android/app/build.gradle @@ -0,0 +1,31 @@ +plugins { + id 'com.android.application' +} + +android { + compileSdkVersion 29 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "it.purser.stream" + minSdkVersion 25 + targetSdkVersion 29 + versionCode 109 + versionName "109.0" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + testImplementation 'junit:junit:4.+' +} diff --git a/android/app/proguard-rules.pro b/android/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/android/app/proguard-rules.pro @@ -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 \ No newline at end of file diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..d43e9db --- /dev/null +++ b/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/ic_launcher-playstore.png b/android/app/src/main/ic_launcher-playstore.png new file mode 100644 index 0000000..a61a702 Binary files /dev/null and b/android/app/src/main/ic_launcher-playstore.png differ diff --git a/android/app/src/main/java/it/purser/stream/ShareActivity.java b/android/app/src/main/java/it/purser/stream/ShareActivity.java new file mode 100644 index 0000000..966e0c4 --- /dev/null +++ b/android/app/src/main/java/it/purser/stream/ShareActivity.java @@ -0,0 +1,69 @@ +package it.purser.stream; + +import android.app.Activity; +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import java.util.TreeMap; +import java.util.Locale; + +public class ShareActivity extends Activity { + private class Upstream { + private Uri uri = null; + private String provider = null; + private Upstream(Uri uri, String provider) { + this.uri = uri; + this.provider = provider; + } + } + private Upstream getSharedLink() { + TreeMap domains = new TreeMap<>(); + domains.put("youtu.be", "youtube"); + domains.put("youtube.com", "youtube"); + domains.put("www.youtube.com", "youtube"); + domains.put("tv.nrk.no", "nrk"); + domains.put("nx12210.your-storageshare.de", "nextcloud"); + + Intent intent = getIntent(); + Bundle bundle = intent.getExtras(); + for(String key: bundle.keySet()) { + try { + String txt = (String) bundle.get(key); + Uri uri = Uri.parse(txt); + String host = uri.getHost().toLowerCase(Locale.ROOT); + if(domains.containsKey(host)) { + if(host.contains("youtube.com")) { + Uri.Builder builder = new Uri.Builder(); + builder.authority(host); + builder.scheme("https"); + String path = uri.getQueryParameter("v"); + if(path != null) { + builder.path(path); + return new Upstream(builder.build(), domains.get(host)); + } + } + return new Upstream(uri, domains.get(host)); + } + } catch(Exception e) {} + } + return null; + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + Upstream upstream = getSharedLink(); + if(upstream != null) { + Uri.Builder builder = new Uri.Builder(); + builder.authority("stream.purser.it"); + builder.scheme("https"); + builder.path(upstream.uri.getPath()); + builder.appendQueryParameter("provider", upstream.provider); + Intent launch = new Intent(Intent.ACTION_VIEW, builder.build()); + launch.setPackage("com.android.chrome"); + launch.putExtra("android.support.customtabs.extra.SESSION", "Proxy Stream"); + launch.putExtra("android.support.customtabs.extra.TOOLBAR_COLOR", 0xff0000); + startActivity(launch); + } + finish(); + } +} diff --git a/android/app/src/main/res/drawable/ic_launcher.xml b/android/app/src/main/res/drawable/ic_launcher.xml new file mode 100644 index 0000000..cb8b054 --- /dev/null +++ b/android/app/src/main/res/drawable/ic_launcher.xml @@ -0,0 +1,15 @@ + + + + + + diff --git a/android/app/src/main/res/values-night/themes.xml b/android/app/src/main/res/values-night/themes.xml new file mode 100644 index 0000000..3d57a7d --- /dev/null +++ b/android/app/src/main/res/values-night/themes.xml @@ -0,0 +1,4 @@ + + +