Remove useless in-app player

This commit is contained in:
Thomas 2022-01-27 18:32:37 +01:00
parent bccbab9729
commit c9de4e6c30
12 changed files with 74 additions and 464 deletions

View File

@ -7,8 +7,7 @@
android:name="android.permission.QUERY_ALL_PACKAGES"
tools:ignore="QueryAllPackagesPermission" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="false"
@ -25,7 +24,8 @@
android:name=".activities.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar"
tools:replace="android:label">
tools:replace="android:label"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
@ -281,13 +281,6 @@
android:label="@string/invidious_settings"
android:targetActivity=".activities.InvidiousSettingsActivity"
android:theme="@style/AppTheme" />
<activity-alias
android:name=".activities.WebviewPlayerActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:launchMode="singleTask"
android:targetActivity=".activities.WebviewPlayerActivity"
android:theme="@style/AppTheme" />
</application>
</manifest>

View File

@ -3,9 +3,11 @@
xmlns:tools="http://schemas.android.com/tools"
package="app.fedilab.nitterizeme">
<uses-permission
android:name="android.permission.QUERY_ALL_PACKAGES"
tools:ignore="QueryAllPackagesPermission" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="false"
@ -21,7 +23,8 @@
<activity
android:name=".activities.MainActivity"
android:label="@string/app_name_lite"
android:theme="@style/AppTheme.NoActionBar">
android:theme="@style/AppTheme.NoActionBar"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
@ -31,7 +34,8 @@
<activity
android:name=".activities.TransformActivity"
android:noHistory="true"
android:theme="@style/Theme.AppCompat.Translucent">
android:theme="@style/Theme.AppCompat.Translucent"
android:exported="true">
<!-- The app should handle these domains, more can be added here -->
<intent-filter>
@ -240,12 +244,6 @@
android:configChanges="orientation|screenSize"
android:label="@string/invidious_settings"
android:theme="@style/AppTheme" />
<activity
android:name=".activities.WebviewPlayerActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name_lite"
android:launchMode="singleTask"
android:theme="@style/AppTheme" />
</application>
</manifest>

View File

@ -14,6 +14,12 @@ package app.fedilab.nitterizeme.activities;
* You should have received a copy of the GNU General Public License along with UntrackMe; if not,
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.nitterizeme.activities.MainActivity.APP_PREFS;
import static app.fedilab.nitterizeme.helpers.Utils.INTENT_ACTION;
import static app.fedilab.nitterizeme.helpers.Utils.KILL_ACTIVITY;
import static app.fedilab.nitterizeme.helpers.Utils.LAST_USED_APP_PACKAGE;
import static app.fedilab.nitterizeme.helpers.Utils.URL_APP_PICKER;
import android.app.Activity;
import android.content.ClipData;
import android.content.ClipboardManager;
@ -39,12 +45,6 @@ import app.fedilab.nitterizeme.helpers.Utils;
import app.fedilab.nitterizeme.sqlite.DefaultAppDAO;
import app.fedilab.nitterizeme.sqlite.Sqlite;
import static app.fedilab.nitterizeme.activities.MainActivity.APP_PREFS;
import static app.fedilab.nitterizeme.helpers.Utils.INTENT_ACTION;
import static app.fedilab.nitterizeme.helpers.Utils.KILL_ACTIVITY;
import static app.fedilab.nitterizeme.helpers.Utils.LAST_USED_APP_PACKAGE;
import static app.fedilab.nitterizeme.helpers.Utils.URL_APP_PICKER;
public class AppsPickerActivity extends Activity {

View File

@ -14,6 +14,8 @@ package app.fedilab.nitterizeme.activities;
* You should have received a copy of the GNU General Public License along with UntrackMe; if not,
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.nitterizeme.helpers.Utils.KILL_ACTIVITY;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@ -40,8 +42,6 @@ import app.fedilab.nitterizeme.R;
import app.fedilab.nitterizeme.databinding.ActivityMainBinding;
import app.fedilab.nitterizeme.databinding.ContentMainBinding;
import static app.fedilab.nitterizeme.helpers.Utils.KILL_ACTIVITY;
public class MainActivity extends AppCompatActivity {
public static final String APP_PREFS = "app_prefs";
@ -69,7 +69,6 @@ public class MainActivity extends AppCompatActivity {
public static String DEFAULT_WIKILESS_HOST = "wikiless.org";
public static String DEFAULT_TEDDIT_HOST = "teddit.net";
public static String SET_GEO_URIS = "set_geo_uris";
public static String SET_EMBEDDED_PLAYER = "set_embedded_player";
BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
@Override
@ -112,7 +111,7 @@ public class MainActivity extends AppCompatActivity {
boolean scriberip_enabled = sharedpreferences.getBoolean(SET_SCRIBERIP_ENABLED, true);
boolean wikiless_enabled = sharedpreferences.getBoolean(SET_WIKILESS_ENABLED, true);
boolean geouri_enabled = sharedpreferences.getBoolean(SET_GEO_URIS, false);
boolean embedded_player = sharedpreferences.getBoolean(SET_EMBEDDED_PLAYER, false);
binding.enableNitter.setChecked(nitter_enabled);
binding.enableInvidious.setChecked(invidious_enabled);
@ -123,7 +122,6 @@ public class MainActivity extends AppCompatActivity {
binding.enableOsm.setChecked(osm_enabled);
nitterHost = sharedpreferences.getString(SET_NITTER_HOST, null);
invidiousHost = sharedpreferences.getString(SET_INVIDIOUS_HOST, null);
bibliogramHost = sharedpreferences.getString(SET_BIBLIOGRAM_HOST, null);
@ -140,7 +138,6 @@ public class MainActivity extends AppCompatActivity {
binding.groupCurrentWikiless.setVisibility(wikiless_enabled ? View.VISIBLE : View.GONE);
binding.groupCurrentOsm.setVisibility((osm_enabled && geouri_enabled) ? View.VISIBLE : View.GONE);
binding.enableGeoUris.setVisibility(osm_enabled ? View.VISIBLE : View.GONE);
binding.enableEmbedPlayer.setVisibility(invidious_enabled ? View.VISIBLE : View.GONE);
binding.enableInvidious.setOnCheckedChangeListener((buttonView, isChecked) -> {
SharedPreferences.Editor editor = sharedpreferences.edit();
@ -148,7 +145,6 @@ public class MainActivity extends AppCompatActivity {
editor.apply();
binding.groupCurrentInvidious.setVisibility(isChecked ? View.VISIBLE : View.GONE);
binding.groupCustomInvidious.setVisibility(View.GONE);
binding.enableEmbedPlayer.setVisibility(isChecked ? View.VISIBLE : View.GONE);
binding.buttonExpandInstanceInvidious.setRotation(0);
});
binding.enableNitter.setOnCheckedChangeListener((buttonView, isChecked) -> {
@ -377,7 +373,6 @@ public class MainActivity extends AppCompatActivity {
binding.groupCustomOsm.setVisibility(View.GONE);
}
binding.enableEmbedPlayer.setChecked(embedded_player);
binding.buttonSaveInstanceNitter.setOnClickListener(v -> {
SharedPreferences.Editor editor = sharedpreferences.edit();
if (binding.nitterInstance.getText() != null && binding.nitterInstance.getText().toString().trim().length() > 0) {
@ -494,11 +489,6 @@ public class MainActivity extends AppCompatActivity {
binding.osmIndications.setText(R.string.redirect_gm_to_osm);
}
});
binding.enableEmbedPlayer.setOnCheckedChangeListener((buttonView, isChecked) -> {
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putBoolean(SET_EMBEDDED_PLAYER, isChecked);
editor.apply();
});
sharedpreferences.registerOnSharedPreferenceChangeListener(
(sharedPreferences, key) -> {

View File

@ -14,6 +14,16 @@ package app.fedilab.nitterizeme.activities;
* You should have received a copy of the GNU General Public License along with UntrackMe; if not,
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.nitterizeme.activities.CheckAppActivity.shortener_domains;
import static app.fedilab.nitterizeme.helpers.Utils.KILL_ACTIVITY;
import static app.fedilab.nitterizeme.helpers.Utils.forwardToBrowser;
import static app.fedilab.nitterizeme.helpers.Utils.isRouted;
import static app.fedilab.nitterizeme.helpers.Utils.manageShortened;
import static app.fedilab.nitterizeme.helpers.Utils.manageShortenedShare;
import static app.fedilab.nitterizeme.helpers.Utils.remove_tracking_param;
import static app.fedilab.nitterizeme.helpers.Utils.routerEnabledForHost;
import static app.fedilab.nitterizeme.helpers.Utils.transformUrl;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
@ -31,16 +41,6 @@ import java.util.regex.Pattern;
import app.fedilab.nitterizeme.BuildConfig;
import app.fedilab.nitterizeme.helpers.Utils;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.shortener_domains;
import static app.fedilab.nitterizeme.helpers.Utils.KILL_ACTIVITY;
import static app.fedilab.nitterizeme.helpers.Utils.forwardToBrowser;
import static app.fedilab.nitterizeme.helpers.Utils.isRouted;
import static app.fedilab.nitterizeme.helpers.Utils.manageShortened;
import static app.fedilab.nitterizeme.helpers.Utils.manageShortenedShare;
import static app.fedilab.nitterizeme.helpers.Utils.remove_tracking_param;
import static app.fedilab.nitterizeme.helpers.Utils.routerEnabledForHost;
import static app.fedilab.nitterizeme.helpers.Utils.transformUrl;
public class TransformActivity extends Activity {

View File

@ -1,233 +0,0 @@
package app.fedilab.nitterizeme.activities;
/* Copyright 2020 Thomas Schneider
*
* This file is a part of UntrackMe
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* UntrackMe is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with UntrackMe; if not,
* see <http://www.gnu.org/licenses>. */
import android.Manifest;
import android.annotation.SuppressLint;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.webkit.WebView;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import java.io.IOException;
import app.fedilab.nitterizeme.R;
import app.fedilab.nitterizeme.helpers.PlayerChromeClient;
import app.fedilab.nitterizeme.helpers.Utils;
public class WebviewPlayerActivity extends AppCompatActivity {
private static final int EXTERNAL_STORAGE_REQUEST_CODE = 84;
private String videoUrl;
private WebView webView;
private RelativeLayout loader;
private BroadcastReceiver receive_data;
private FrameLayout webview_container;
private String streaming_url;
private String initialUrl;
@SuppressLint("SetJavaScriptEnabled")
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initialUrl = null;
Bundle b = getIntent().getExtras();
if (b != null) {
initialUrl = b.getString("url", null);
}
if (initialUrl == null) {
finish();
}
setContentView(R.layout.activity_webview_player);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
final ViewGroup videoLayout = findViewById(R.id.videoLayout);
webView = findViewById(R.id.webview);
webView.setBackgroundColor(Color.TRANSPARENT);
loader = findViewById(R.id.loader);
webview_container = findViewById(R.id.webview_container);
webView.getSettings().setJavaScriptEnabled(true);
PlayerChromeClient playerChromeClient = new PlayerChromeClient(WebviewPlayerActivity.this, webView, webview_container, videoLayout);
playerChromeClient.setOnToggledFullscreen(fullscreen -> {
if (fullscreen) {
videoLayout.setVisibility(View.VISIBLE);
WindowManager.LayoutParams attrs = getWindow().getAttributes();
attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
attrs.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
getWindow().setAttributes(attrs);
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
} else {
WindowManager.LayoutParams attrs = getWindow().getAttributes();
attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
attrs.flags &= ~WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
getWindow().setAttributes(attrs);
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
videoLayout.setVisibility(View.GONE);
}
});
receive_data = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Bundle b = intent.getExtras();
assert b != null;
streaming_url = b.getString("streaming_url", null);
if (streaming_url != null) {
webView.stopLoading();
webView.loadUrl(streaming_url);
loader.setVisibility(View.GONE);
webview_container.setVisibility(View.VISIBLE);
}
}
};
webView.setWebChromeClient(playerChromeClient);
LocalBroadcastManager.getInstance(WebviewPlayerActivity.this).registerReceiver(receive_data, new IntentFilter(Utils.RECEIVE_STREAMING_URL));
AsyncTask.execute(() -> {
try {
Document document = Jsoup
.connect(initialUrl).ignoreContentType(true).get();
Element video = document.select("video").first();
if (video != null) {
Element source = video.select("source").first();
if (source != null) {
videoUrl = source.absUrl("src");
runOnUiThread(() -> webView.loadUrl(videoUrl));
}
}
} catch (IOException e) {
e.printStackTrace();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_player, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_share && initialUrl != null) {
AsyncTask.execute(() -> {
try {
Document document = Jsoup
.connect(initialUrl).ignoreContentType(true).get();
Element metaTitle = document.select("meta[property=\"og:title\"]").first();
String title = metaTitle.attr("content");
Element metaMedia = document.select("meta[property=\"og:video:url\"]").first();
String media = metaMedia.attr("content");
Element metaDescription = document.select("meta[property=\"og:description\"]").first();
String description = metaDescription.attr("content");
runOnUiThread(() -> {
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, title);
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(media));
sendIntent.putExtra(Intent.EXTRA_TEXT, description + "\n\n" + initialUrl);
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, getString(R.string.share_with)));
});
} catch (IOException e) {
e.printStackTrace();
}
});
return true;
} else if (id == R.id.action_download && streaming_url != null) {
if (Build.VERSION.SDK_INT >= 23) {
if (ContextCompat.checkSelfPermission(WebviewPlayerActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(WebviewPlayerActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(WebviewPlayerActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, EXTERNAL_STORAGE_REQUEST_CODE);
} else {
Utils.manageDownloadsNoPopup(WebviewPlayerActivity.this, streaming_url);
}
} else {
Utils.manageDownloadsNoPopup(WebviewPlayerActivity.this, streaming_url);
}
return true;
} else if (id == android.R.id.home) {
finish();
}
return super.onOptionsItemSelected(item);
}
@Override
public void onPause() {
super.onPause();
if (webView != null) {
webView.onPause();
}
}
@Override
public void onResume() {
super.onResume();
if (webView != null) {
webView.onResume();
}
}
@Override
public void onDestroy() {
super.onDestroy();
if (receive_data != null) {
LocalBroadcastManager.getInstance(WebviewPlayerActivity.this).unregisterReceiver(receive_data);
}
if (webView != null) {
webView.stopLoading();
webView.destroy();
}
}
}

View File

@ -14,6 +14,14 @@ package app.fedilab.nitterizeme.adapters;
* You should have received a copy of the GNU General Public License along with UntrackMe; if not,
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.nitterizeme.activities.MainActivity.APP_PREFS;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_BIBLIOGRAM_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_INVIDIOUS_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_NITTER_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_SCRIBERIP_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_TEDDIT_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_WIKILESS_HOST;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
@ -35,14 +43,6 @@ import app.fedilab.nitterizeme.databinding.DrawerInstanceBinding;
import app.fedilab.nitterizeme.entities.Instance;
import app.fedilab.nitterizeme.helpers.Utils;
import static app.fedilab.nitterizeme.activities.MainActivity.APP_PREFS;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_BIBLIOGRAM_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_INVIDIOUS_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_NITTER_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_SCRIBERIP_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_TEDDIT_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_WIKILESS_HOST;
public class InstanceAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

View File

@ -15,8 +15,26 @@ package app.fedilab.nitterizeme.helpers;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.nitterizeme.activities.CheckAppActivity.bibliogram_instances;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.instagram_domains;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.invidious_instances;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.medium_domains;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.nitter_instances;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.outlook_safe_domain;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.reddit_domains;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.shortener_domains;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.twitter_domains;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.wikipedia_domains;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.youtube_domains;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_BIBLIOGRAM_ENABLED;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_INVIDIOUS_ENABLED;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_NITTER_ENABLED;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_SCRIBERIP_ENABLED;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_TEDDIT_ENABLED;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_TEDDIT_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_WIKILESS_ENABLED;
import android.app.Activity;
import android.app.DownloadManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@ -25,9 +43,7 @@ import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import android.os.Parcelable;
@ -38,7 +54,6 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.preference.PreferenceManager;
import org.json.JSONArray;
@ -56,14 +71,11 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
@ -76,28 +88,6 @@ import app.fedilab.nitterizeme.BuildConfig;
import app.fedilab.nitterizeme.R;
import app.fedilab.nitterizeme.activities.AppsPickerActivity;
import app.fedilab.nitterizeme.activities.MainActivity;
import app.fedilab.nitterizeme.activities.WebviewPlayerActivity;
import static android.content.Context.DOWNLOAD_SERVICE;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.bibliogram_instances;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.instagram_domains;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.invidious_instances;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.medium_domains;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.nitter_instances;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.outlook_safe_domain;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.reddit_domains;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.shortener_domains;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.twitter_domains;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.wikipedia_domains;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.youtube_domains;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_BIBLIOGRAM_ENABLED;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_EMBEDDED_PLAYER;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_INVIDIOUS_ENABLED;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_NITTER_ENABLED;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_SCRIBERIP_ENABLED;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_TEDDIT_ENABLED;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_TEDDIT_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_WIKILESS_ENABLED;
public class Utils {
@ -118,7 +108,6 @@ public class Utils {
public static final Pattern bibliogramAccountPattern = Pattern.compile("(m\\.|www\\.)?instagram.com(((?!/p/).)+)");
public static final Pattern maps = Pattern.compile("/maps/place/([^@]+@)?([\\d.,z]+).*");
public static final Pattern ampExtract = Pattern.compile("amp/s/(.*)");
public static final String RECEIVE_STREAMING_URL = "receive_streaming_url";
public static final Pattern outlookRedirect = Pattern.compile("(.*)safelinks\\.protection\\.outlook\\.com/?[?]?((?!url).)*url=([^&]+)");
private static final Pattern extractPlace = Pattern.compile("/maps/place/(((?!/data).)*)");
private static final Pattern googleRedirect = Pattern.compile("https?://(www\\.)?google(\\.\\w{2,})?(\\.\\w{2,})/url\\?(q=|q%3D)(.*)");
@ -849,36 +838,6 @@ public class Utils {
}
/**
* Manage downloads with URLs
*
* @param context Context
* @param url String download url
*/
public static void manageDownloadsNoPopup(final Context context, final String url) {
final DownloadManager.Request request;
try {
request = new DownloadManager.Request(Uri.parse(url.trim()));
} catch (Exception e) {
return;
}
try {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss", Locale.ENGLISH);
Date now = new Date();
final String fileName = "UntrackMe_" + formatter.format(now) + ".mp4";
request.allowScanningByMediaScanner();
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName);
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
DownloadManager dm = (DownloadManager) context.getSystemService(DOWNLOAD_SERVICE);
assert dm != null;
dm.enqueue(request);
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
/**
* Check if an app is installed
*
@ -1202,29 +1161,10 @@ public class Utils {
targetIntents.add(targetIntent);
}
SharedPreferences sharedpreferences = context.getSharedPreferences(MainActivity.APP_PREFS, Context.MODE_PRIVATE);
boolean embedded_player = sharedpreferences.getBoolean(SET_EMBEDDED_PLAYER, false);
if (Arrays.asList(invidious_instances).contains(Objects.requireNonNull(i.getData()).getHost()) && embedded_player) {
if (!i.getData().toString().contains("videoplayback")) {
Intent intentPlayer = new Intent(context, WebviewPlayerActivity.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
intentPlayer.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
}
intentPlayer.putExtra("url", i.getData().toString());
context.startActivity(intentPlayer);
} else {
Intent intentStreamingUrl = new Intent(Utils.RECEIVE_STREAMING_URL);
Bundle b = new Bundle();
b.putString("streaming_url", i.getData().toString());
intentStreamingUrl.putExtras(b);
LocalBroadcastManager.getInstance(context).sendBroadcast(intentStreamingUrl);
}
} else if (targetIntents.size() > 0) {
Intent chooserIntent = Intent.createChooser(targetIntents.remove(0), context.getString(R.string.open_with));
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetIntents.toArray(new Parcelable[]{}));
context.startActivity(chooserIntent);
}
Intent chooserIntent = Intent.createChooser(targetIntents.remove(0), context.getString(R.string.open_with));
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetIntents.toArray(new Parcelable[]{}));
context.startActivity(chooserIntent);
((Activity) context).finish();
} else {

View File

@ -14,6 +14,20 @@ package app.fedilab.nitterizeme.viewmodels;
* You should have received a copy of the GNU General Public License along with UntrackMe; if not,
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.nitterizeme.activities.MainActivity.APP_PREFS;
import static app.fedilab.nitterizeme.activities.MainActivity.DEFAULT_BIBLIOGRAM_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.DEFAULT_INVIDIOUS_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.DEFAULT_NITTER_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.DEFAULT_SCRIBERIP_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.DEFAULT_TEDDIT_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.DEFAULT_WIKILESS_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_BIBLIOGRAM_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_INVIDIOUS_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_NITTER_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_SCRIBERIP_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_TEDDIT_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_WIKILESS_HOST;
import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
@ -38,20 +52,6 @@ import javax.net.ssl.HttpsURLConnection;
import app.fedilab.nitterizeme.entities.Instance;
import static app.fedilab.nitterizeme.activities.MainActivity.APP_PREFS;
import static app.fedilab.nitterizeme.activities.MainActivity.DEFAULT_BIBLIOGRAM_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.DEFAULT_INVIDIOUS_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.DEFAULT_NITTER_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.DEFAULT_SCRIBERIP_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.DEFAULT_TEDDIT_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.DEFAULT_WIKILESS_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_BIBLIOGRAM_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_INVIDIOUS_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_NITTER_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_SCRIBERIP_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_TEDDIT_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_WIKILESS_HOST;
public class SearchInstanceVM extends AndroidViewModel {
private MutableLiveData<List<Instance>> instancesMLD;

View File

@ -1,52 +0,0 @@
<?xml version="1.0" encoding="utf-8"?><!--
/* Copyright 2020 Thomas Schneider
*
* This file is a part of UntrackMe
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* UntrackMe is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with UntrackMe; if not,
* see <http://www.gnu.org/licenses>. */
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black"
tools:context=".activities.WebviewPlayerActivity">
<FrameLayout
android:id="@+id/webview_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
<!-- View where the video will be shown when video goes fullscreen -->
<RelativeLayout
android:id="@+id/videoLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
<RelativeLayout
android:id="@+id/loader"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
</RelativeLayout>

View File

@ -315,15 +315,6 @@
app:barrierDirection="bottom"
app:constraint_referenced_ids="invidious_instance_container,button_save_instance_invidious" />
<CheckBox
android:id="@+id/enable_embed_player"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="@string/use_built_in_player"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/barrier_invidious_2" />
<androidx.constraintlayout.widget.Group
android:id="@+id/group_current_invidious"

View File

@ -1,17 +0,0 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="app.fedilab.nitterizeme.activities.WebviewPlayerActivity">
<item
android:id="@+id/action_share"
android:icon="@drawable/ic_share"
android:orderInCategory="1"
android:title="@string/share"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_download"
android:icon="@drawable/ic_download"
android:orderInCategory="2"
android:title="@string/download"
app:showAsAction="ifRoom" />
</menu>