Some fixes
This commit is contained in:
parent
c3e475be6f
commit
fbbab1db68
|
@ -19,13 +19,10 @@
|
|||
tools:node="merge">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data android:scheme="file" />
|
||||
<data android:scheme="content" />
|
||||
<data android:host="*" />
|
||||
<data android:scheme="file" />
|
||||
<data android:mimeType="*/*" />
|
||||
<data android:pathPattern=".*\\.tubelab" />
|
||||
<data android:pathPattern=".*\\..*\\.tubelab" />
|
||||
|
|
|
@ -19,13 +19,10 @@
|
|||
tools:node="merge">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data android:scheme="file" />
|
||||
<data android:scheme="content" />
|
||||
<data android:host="*" />
|
||||
<data android:scheme="file" />
|
||||
<data android:mimeType="*/*" />
|
||||
<data android:pathPattern=".*\\.tubelab" />
|
||||
<data android:pathPattern=".*\\..*\\.tubelab" />
|
||||
|
|
|
@ -16,14 +16,15 @@ package app.fedilab.fedilabtube.helper;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.provider.OpenableColumns;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Scanner;
|
||||
|
||||
import app.fedilab.fedilabtube.PlaylistsActivity;
|
||||
import app.fedilab.fedilabtube.client.data.VideoPlaylistData;
|
||||
|
@ -72,23 +73,34 @@ public class PlaylistExportHelper {
|
|||
public static void manageIntentUrl(Activity activity, Intent intent) {
|
||||
if (intent.getData() != null) {
|
||||
String url = intent.getData().toString();
|
||||
if (url.endsWith(".json")) {
|
||||
File file = new File(url);
|
||||
StringBuilder text = new StringBuilder();
|
||||
|
||||
String filename = url;
|
||||
|
||||
if (url.startsWith("content://")) {
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
BufferedReader br = new BufferedReader(new FileReader(file));
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
text.append(line);
|
||||
text.append('\n');
|
||||
cursor = activity.getContentResolver().query(intent.getData(), null, null, null, null);
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
filename = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
|
||||
}
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
} finally {
|
||||
assert cursor != null;
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
String text = null;
|
||||
if (filename.endsWith(".tubelab")) {
|
||||
try {
|
||||
InputStream inputStream = activity.getContentResolver().openInputStream(intent.getData());
|
||||
Scanner s = new Scanner(inputStream).useDelimiter("\\A");
|
||||
text = s.hasNext() ? s.next() : "";
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (text.length() > 20) {
|
||||
if (text != null && text.length() > 20) {
|
||||
String finalText = text;
|
||||
new Thread(() -> {
|
||||
VideoPlaylistData.VideoPlaylistExport videoPlaylistExport = PlaylistExportHelper.restorePlaylistFromString(text.toString());
|
||||
VideoPlaylistData.VideoPlaylistExport videoPlaylistExport = PlaylistExportHelper.restorePlaylistFromString(finalText);
|
||||
if (videoPlaylistExport != null) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(activity.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
new ManagePlaylistsDAO(activity, db).insertPlaylist(videoPlaylistExport);
|
||||
|
|
|
@ -6,7 +6,7 @@ buildscript {
|
|||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.1.0'
|
||||
classpath 'com.android.tools.build:gradle:4.1.1'
|
||||
def nav_version = "2.3.0"
|
||||
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
|
|
Loading…
Reference in New Issue