Skip to content

Commit

Permalink
fixed everything wrong with why fdroid wasnt building and then some, …
Browse files Browse the repository at this point in the history
…updated gradle wrapper using git, optimized code for java 1.8 (including converting anonymous java expressions to lambdas), reduced minSdkVersion to 14, bumped version to 1.2, blah blah blah (#106)

Signed-off-by: TacoTheDank <[email protected]>
  • Loading branch information
TacoTheDank authored and martykan committed Aug 30, 2018
1 parent bd6776e commit 2adae86
Show file tree
Hide file tree
Showing 26 changed files with 128 additions and 254 deletions.
53 changes: 2 additions & 51 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,54 +1,5 @@
*~

# Gradle
.gradle/
.gradle
build/
/*/build/

# User-specific configurations
local.properties

.idea
.idea/libraries/
.idea/runConfigurations.xml
.idea/gradle.xml
.idea/workspace.xml
.idea/tasks.xml
.idea/.name
.idea/compiler.xml
.idea/copyright/profiles_settings.xml
.idea/encodings.xml
.idea/misc.xml
.idea/modules.xml
.idea/scopes/scope_settings.xml
.idea/vcs.xml
*.iml

# OS-specific files
.DS_Store
.DS_Store?
._*
.Trashes
ehthumbs.db
Thumbs.db

# Built application files
*.apk
*.ap_

# Files for the Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/

local.properties
proguard/
*.log
.navigation/

.idea/
*.iml
1 change: 0 additions & 1 deletion app/.gitignore

This file was deleted.

24 changes: 16 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 28
buildToolsVersion '28.0.1'
buildToolsVersion '28.0.2'
defaultConfig {
applicationId "cz.martykan.webtube"
minSdkVersion 15
minSdkVersion 14
targetSdkVersion 28
versionCode 16
versionName "1.1.3"
versionCode 17
versionName "1.2"
}

lintOptions {
disable 'MissingTranslation'
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}

compileOptions {
Expand All @@ -22,16 +26,20 @@ android {

buildTypes {
release {
minifyEnabled false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
zipAlignEnabled true
}
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:28.0.0-beta01'
implementation 'com.android.support:design:28.0.0-beta01'
implementation 'info.guardianproject.netcipher:netcipher:2.0.0-alpha1'
implementation 'com.android.support:design:28.0.0-rc01'
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
implementation 'info.guardianproject.netcipher:netcipher:2.0.0-beta1'
implementation 'info.guardianproject.netcipher:netcipher-webkit:2.0.0-alpha1'
}
4 changes: 2 additions & 2 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /home/tomas/Android/Sdk/tools/proguard/proguard-android.txt
# in C:/Users/$USER/AppData/Local/Android/Sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# https://developer.android.com/studio/build/shrink-code.html

# Add any project specific keep options here:

Expand Down
9 changes: 7 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cz.martykan.webtube" android:installLocation="auto">
package="cz.martykan.webtube"
android:installLocation="auto">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.BLUETOOTH" />
Expand Down Expand Up @@ -70,7 +71,11 @@

</intent-filter>
</activity>
<activity android:name=".NotificationCloser" android:taskAffinity="" android:excludeFromRecents="true" android:theme="@android:style/Theme.Translucent.NoTitleBar"></activity>
<activity
android:name=".NotificationCloser"
android:excludeFromRecents="true"
android:taskAffinity=""
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<receiver android:name=".MediaButtonIntentReceiver">
<intent-filter android:priority="100000">
<action android:name="android.intent.action.MEDIA_BUTTON" />
Expand Down
27 changes: 11 additions & 16 deletions app/src/main/java/cz/martykan/webtube/BackgroundPlayHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import android.preference.PreferenceManager;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
import android.webkit.ValueCallback;
import android.webkit.WebView;

public class BackgroundPlayHelper {
Expand All @@ -32,13 +31,13 @@ public BackgroundPlayHelper (Context context, WebView webView) {
public void enableBackgroundPlay() {
SharedPreferences.Editor spedit = sp.edit();
spedit.putBoolean(PREF_BACKGROUND_PLAY_ENABLED, true);
spedit.commit();
spedit.apply();
}

public void disableBackgroundPlay() {
SharedPreferences.Editor spedit = sp.edit();
spedit.putBoolean(PREF_BACKGROUND_PLAY_ENABLED, false);
spedit.commit();
spedit.apply();
}

public boolean isBackgroundPlayEnabled() {
Expand All @@ -49,15 +48,12 @@ public void playInBackground() {
try {
if (webView.getUrl().contains("/watch")) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
webView.evaluateJavascript("(function() { if(document.getElementsByTagName('video')[0].paused == false) { return 'playing'; } else { return 'stopped'; } })();", new ValueCallback<String>() {
@Override
public void onReceiveValue(String value) {
Log.i("VALUE", value);
if (value.equals("\"playing\"")) {
showBackgroundPlaybackNotification();
}
}
});
webView.evaluateJavascript("(function() { if(document.getElementsByTagName('video')[0].paused == false) { return 'playing'; } else { return 'stopped'; } })();", value -> {
Log.i("VALUE", value);
if (value.equals("\"playing\"")) {
showBackgroundPlaybackNotification();
}
});
} else {
showBackgroundPlaybackNotification();
}
Expand All @@ -77,20 +73,19 @@ public void showBackgroundPlaybackNotification() {
.setContentTitle(context.getString(R.string.app_name))
.setContentText(webView.getTitle().replace(" - YouTube", ""))
.setAutoCancel(true)
.setContentIntent(
PendingIntent.getActivity(
.setContentIntent(PendingIntent.getActivity(
context,
NOTIFICATION_ID,
new Intent(context, MainActivity.class)
.setAction(Intent.ACTION_VIEW)
.setData(Uri.parse(webView.getUrl())),
PendingIntent.FLAG_UPDATE_CURRENT));
NotificationManager manager = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);
NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
manager.notify(NOTIFICATION_ID, builder.build());
}

public void hideBackgroundPlaybackNotification() {
NotificationManager manager = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);
NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
manager.cancel(NOTIFICATION_ID);
}
}
10 changes: 5 additions & 5 deletions app/src/main/java/cz/martykan/webtube/BookmarkManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public BookmarkManager(Context context, WebView webView) {
sp = PreferenceManager.getDefaultSharedPreferences(context);
}

public void initalizeBookmarks(NavigationView navigationView) {
public void initializeBookmarks(NavigationView navigationView) {
this.navigationView = navigationView;
bookmarkUrls = new ArrayList<>();
bookmarkTimelessUrls = new ArrayList<>();
Expand Down Expand Up @@ -86,11 +86,11 @@ public void addBookmark(String title, String url) {
bookmarksArray.put(new JSONObject("{'title':'" + title.replace("'", "\\'") + "','url':'" + url + "'}"));
SharedPreferences.Editor editor = sp.edit();
editor.putString("bookmarks", bookmarksArray.toString());
editor.commit();
editor.apply();
} catch (JSONException e) {
e.printStackTrace();
}
initalizeBookmarks(navigationView);
initializeBookmarks(navigationView);
}

public void removeBookmark(String title) {
Expand All @@ -110,11 +110,11 @@ public void removeBookmark(String title) {
}
SharedPreferences.Editor editor = sp.edit();
editor.putString("bookmarks", bookmarksArray.toString());
editor.commit();
editor.apply();
} catch (JSONException e) {
e.printStackTrace();
}
initalizeBookmarks(navigationView);
initializeBookmarks(navigationView);
}

public String getUrl(String title) {
Expand Down
35 changes: 15 additions & 20 deletions app/src/main/java/cz/martykan/webtube/BookmarkSelectedListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import android.support.v4.widget.DrawerLayout;
import android.util.Log;
import android.view.MenuItem;
import android.webkit.ValueCallback;
import android.webkit.WebView;

import java.io.UnsupportedEncodingException;
Expand All @@ -33,24 +32,21 @@ public boolean onNavigationItemSelected(final MenuItem menuItem) {
if (!webView.getTitle().equals("YouTube")) {
if (webView.getUrl().contains("/watch") && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
time = "0";
webView.evaluateJavascript("(function() { return document.getElementsByTagName('video')[0].currentTime; })();", new ValueCallback<String>() {
@Override
public void onReceiveValue(String value) {
Log.i("VALUE", value);
time = value;
String url = webView.getUrl();
try {
time = time.substring(0, time.indexOf("."));
} catch (Exception e) {
e.printStackTrace();
time = "0";
}
if (url.contains("&t=")) {
url = url.substring(0, url.indexOf("&t="));
}
bookmarkManager.addBookmark(webView.getTitle().replace(" - YouTube", ""), url + "&t=" + time);
}
});
webView.evaluateJavascript("(function() { return document.getElementsByTagName('video')[0].currentTime; })();", value -> {
Log.i("VALUE", value);
time = value;
String url = webView.getUrl();
try {
time = time.substring(0, time.indexOf("."));
} catch (Exception e) {
e.printStackTrace();
time = "0";
}
if (url.contains("&t=")) {
url = url.substring(0, url.indexOf("&t="));
}
bookmarkManager.addBookmark(webView.getTitle().replace(" - YouTube", ""), url + "&t=" + time);
});
} else {
bookmarkManager.addBookmark(webView.getTitle().replace(" - YouTube", ""), webView.getUrl());
}
Expand Down Expand Up @@ -90,5 +86,4 @@ public void onReceiveValue(String value) {
}
return true;
}

}
1 change: 0 additions & 1 deletion app/src/main/java/cz/martykan/webtube/Downloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,5 @@ public void download(String url) {
e.printStackTrace();
}
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.ytbmp4.com/search?q=" + encodedURL)));

}
}
1 change: 0 additions & 1 deletion app/src/main/java/cz/martykan/webtube/HeadSetReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ public void onReceive(Context context, Intent intent) {
}
}
}

}
Loading

0 comments on commit 2adae86

Please sign in to comment.