diff --git a/app/build.gradle b/app/build.gradle
index dd8b7c5e..eabe325f 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -23,8 +23,8 @@ android {
applicationId 'com.stevenschoen.putionew'
minSdkVersion 19
targetSdkVersion 25
- versionCode 107
- versionName '4.0.5'
+ versionCode 108
+ versionName '4.0.6'
multiDexEnabled true
}
buildTypes {
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 3c04c95a..3ecafbbf 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -60,9 +60,10 @@
android:name="android.app.default_searchable"
android:value=".activities.Putio"/>
-
+
{
+ val title = cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_TITLE))
+ val uri = Uri.parse(cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI)))
+ val type = cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_MEDIA_TYPE))
+
+ val finishedIntent = Intent(this@PutioOpenFileService, FileFinishedActivity::class.java).apply {
+ addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+ putExtra(FileFinishedActivity.EXTRA_NAME, title)
+ putExtra(FileFinishedActivity.EXTRA_URI, uri)
+ putExtra(FileFinishedActivity.EXTRA_MEDIA_TYPE, type)
+ }
+ startActivity(finishedIntent)
+
+ stopSelf()
+ }
+ DownloadManager.STATUS_FAILED -> { }
+ DownloadManager.STATUS_PAUSED -> { }
+ DownloadManager.STATUS_PENDING -> { }
+ DownloadManager.STATUS_RUNNING -> { }
+ }
+ }
+ }
+ }
+
+ override fun onDestroy() {
+ unregisterReceiver(downloadReceiver)
+ }
+
+ override fun onBind(intent: Intent?): IBinder? {
+ return null
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/stevenschoen/putionew/PutioUtils.java b/app/src/main/java/com/stevenschoen/putionew/PutioUtils.java
index c5cd1ef1..4ee673b9 100644
--- a/app/src/main/java/com/stevenschoen/putionew/PutioUtils.java
+++ b/app/src/main/java/com/stevenschoen/putionew/PutioUtils.java
@@ -55,6 +55,7 @@
import java.net.SocketTimeoutException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import java.util.Locale;
@@ -199,14 +200,13 @@ public long[] call(Object... args) {
public void call(long[] downloadIds) {
switch (actionWhenDone) {
case ACTION_OPEN:
+ if (files.length > 1) {
+ throw new IllegalArgumentException("Download started with ACTION_OPEN but more than one file: " + Arrays.toString(files));
+ }
Intent serviceOpenIntent = new Intent(activity, PutioOpenFileService.class);
- serviceOpenIntent.putExtra("downloadIds", downloadIds);
- serviceOpenIntent.putExtra("id", files[0].id);
- serviceOpenIntent.putExtra("filename", files[0].name);
- serviceOpenIntent.putExtra("mode", actionWhenDone);
+ serviceOpenIntent.putExtra(PutioOpenFileService.EXTRA_DOWNLOAD_ID, downloadIds[0]);
activity.startService(serviceOpenIntent);
- Toast.makeText(activity, activity.getString(R.string.downloadwillopen),
- Toast.LENGTH_LONG).show();
+ Toast.makeText(activity, activity.getString(R.string.downloadwillopen), Toast.LENGTH_LONG).show();
break;
case ACTION_NOTHING:
Toast.makeText(activity, activity.getString(R.string.downloadstarted), Toast.LENGTH_SHORT).show();
diff --git a/app/src/main/java/com/stevenschoen/putionew/activities/FileFinished.java b/app/src/main/java/com/stevenschoen/putionew/activities/FileFinished.java
deleted file mode 100644
index 42ec0e8a..00000000
--- a/app/src/main/java/com/stevenschoen/putionew/activities/FileFinished.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package com.stevenschoen.putionew.activities;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.Button;
-import android.widget.TextView;
-
-import com.stevenschoen.putionew.PutioUtils;
-import com.stevenschoen.putionew.R;
-
-public class FileFinished extends Activity {
- private int mode;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setTheme(R.style.Putio_Dialog);
- setContentView(R.layout.dialog_filefinished);
-
- TextView textBody = (TextView) findViewById(R.id.text_downloadfinished_body);
- textBody.setText(String.format(getString(R.string.downloadfinishedbody), getIntent().getExtras().getString("filename")));
-
- mode = getIntent().getExtras().getInt("mode");
-
- Button buttonAction = (Button) findViewById(R.id.button_filefinished_action);
- switch (mode) {
- case PutioUtils.ACTION_OPEN:
- buttonAction.setText(getString(R.string.open));
- break;
- }
- buttonAction.setOnClickListener(new OnClickListener() {
-
- @Override
- public void onClick(View v) {
- int id = getIntent().getExtras().getInt("id");
- switch (mode) {
- case PutioUtils.ACTION_OPEN:
- PutioUtils.openDownloadedId(id, FileFinished.this);
- break;
- }
-
- finish();
- }
- });
-
- Button buttonOk = (Button) findViewById(R.id.button_filefinished_ok);
- buttonOk.setOnClickListener(new OnClickListener() {
-
- @Override
- public void onClick(View v) {
- finish();
- }
- });
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/stevenschoen/putionew/files/FileFinishedActivity.kt b/app/src/main/java/com/stevenschoen/putionew/files/FileFinishedActivity.kt
new file mode 100644
index 00000000..55147354
--- /dev/null
+++ b/app/src/main/java/com/stevenschoen/putionew/files/FileFinishedActivity.kt
@@ -0,0 +1,43 @@
+package com.stevenschoen.putionew.files
+
+import android.content.Intent
+import android.net.Uri
+import android.os.Bundle
+import android.support.v7.app.AppCompatActivity
+import android.widget.Button
+import android.widget.TextView
+import com.stevenschoen.putionew.R
+
+class FileFinishedActivity : AppCompatActivity() {
+
+ companion object {
+ const val EXTRA_NAME = "name"
+ const val EXTRA_URI = "uri"
+ const val EXTRA_MEDIA_TYPE = "type"
+ }
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.dialog_filefinished)
+
+ val name = intent.extras.getString(EXTRA_NAME)
+
+ val messageView = findViewById(R.id.text_downloadfinished_body) as TextView
+ messageView.text = String.format(getString(R.string.downloadfinishedbody), name)
+
+ val openView = findViewById(R.id.button_filefinished_action) as Button
+ openView.setOnClickListener {
+ val uri = intent.extras.getParcelable(EXTRA_URI)
+ val type = intent.extras.getString(EXTRA_MEDIA_TYPE)
+ val intent = Intent(Intent.ACTION_VIEW).apply {
+ setDataAndType(uri, type)
+ }
+ startActivity(Intent.createChooser(intent, null))
+
+ finish()
+ }
+
+ val okView = findViewById(R.id.button_filefinished_ok) as Button
+ okView.setOnClickListener { finish() }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/stevenschoen/putionew/files/FileListFragment.kt b/app/src/main/java/com/stevenschoen/putionew/files/FileListFragment.kt
index 9733db41..920ca03d 100644
--- a/app/src/main/java/com/stevenschoen/putionew/files/FileListFragment.kt
+++ b/app/src/main/java/com/stevenschoen/putionew/files/FileListFragment.kt
@@ -154,7 +154,7 @@ abstract class FileListFragment : Rx
val downloadFragment = Fragment.instantiate(context, DownloadIndividualOrZipFragment::class.java.name) as DownloadIndividualOrZipFragment
downloadFragment.show(childFragmentManager, FolderFragment.FRAGTAG_DOWNLOAD_INDIVIDUALORZIP)
} else if (checkedFiles.size == 1) {
- PutioApplication.get(context).putioUtils.downloadFiles(activity, PutioUtils.ACTION_NOTHING, *checkedFiles.toTypedArray())
+ PutioApplication.get(context).putioUtils.downloadFiles(activity, PutioUtils.ACTION_NOTHING, checkedFiles.first())
} else {
throw IllegalStateException("Download started with no file IDs!")
}
@@ -198,7 +198,6 @@ abstract class FileListFragment : Rx
}
override fun onDownloadSelected() {
selectionDownloadFiles()
- filesAdapter!!.clearChecked()
}
override fun onCopyLinkSelected() {
selectionCopyLinks()
@@ -243,6 +242,7 @@ abstract class FileListFragment : Rx
childFragment.callbacks = object : DownloadIndividualOrZipFragment.Callbacks {
override fun onIndividualSelected() {
PutioApplication.get(context).putioUtils.downloadFiles(activity, PutioUtils.ACTION_NOTHING, *getCheckedFiles().toTypedArray())
+ filesAdapter!!.clearChecked()
}
override fun onZipSelected() {
val checkedFiles = getCheckedFiles()
@@ -255,6 +255,7 @@ abstract class FileListFragment : Rx
error.printStackTrace()
Toast.makeText(context, R.string.network_error, Toast.LENGTH_SHORT).show()
})
+ filesAdapter!!.clearChecked()
}
override fun onCanceled() { }
}
diff --git a/app/src/main/java/com/stevenschoen/putionew/tv/TvActivity.java b/app/src/main/java/com/stevenschoen/putionew/tv/TvActivity.java
index 4bd6874e..34eac996 100644
--- a/app/src/main/java/com/stevenschoen/putionew/tv/TvActivity.java
+++ b/app/src/main/java/com/stevenschoen/putionew/tv/TvActivity.java
@@ -5,10 +5,10 @@
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
+import com.stevenschoen.putionew.LoginActivity;
import com.stevenschoen.putionew.PutioApplication;
import com.stevenschoen.putionew.PutioUtils;
import com.stevenschoen.putionew.R;
-import com.stevenschoen.putionew.activities.LoginActivity;
/**
* Created by simonreggiani on 15-01-10.
diff --git a/app/src/main/res/layout/dialog_filefinished.xml b/app/src/main/res/layout/dialog_filefinished.xml
index f6ddb25f..0e9505f8 100644
--- a/app/src/main/res/layout/dialog_filefinished.xml
+++ b/app/src/main/res/layout/dialog_filefinished.xml
@@ -1,53 +1,39 @@
-
+
-
+
-
+
-
+
-
-
-
-
-
-
-
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/dialog_redownload.xml b/app/src/main/res/layout/dialog_redownload.xml
index c5a2321b..b413b9d8 100644
--- a/app/src/main/res/layout/dialog_redownload.xml
+++ b/app/src/main/res/layout/dialog_redownload.xml
@@ -1,42 +1,43 @@
-
+
-
+
-
+
-
+
-
+
-
-
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/download_individualorzip.xml b/app/src/main/res/layout/download_individualorzip.xml
index b1ce8920..55d99d81 100644
--- a/app/src/main/res/layout/download_individualorzip.xml
+++ b/app/src/main/res/layout/download_individualorzip.xml
@@ -7,8 +7,10 @@
@@ -32,7 +34,7 @@
android:layout_marginBottom="16dp"
android:layout_marginTop="32dp"
android:text="@string/zip"
- app:layout_constraintBottom_toBottomOf="@+id/download_individualorzip_root"
+ app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/download_individualorzip_root"
app:layout_constraintTop_toBottomOf="@+id/download_individualorzip_body"/>
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index a612e011..fb861ffc 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -78,7 +78,10 @@