mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 10:49:24 +02:00
Book downloading has been started
notification
git-svn-id: https://only.mawhrin.net/repos/FBReaderJ/trunk@1163 6a642e6f-84f6-412e-ac94-c4a38d5a04b0
This commit is contained in:
parent
250e6a955e
commit
697c76e718
5 changed files with 30 additions and 3 deletions
|
@ -35,13 +35,13 @@ DONE кэширование картинок
|
|||
|
||||
DONE добавить Extra -- Book Title при скачивании книги, отображать Название книги вместо имени файла
|
||||
|
||||
* добавлять Tag и изменять Title для Demo-книжек
|
||||
DONE добавлять Tag и изменять Title для Demo-книжек
|
||||
DONE складывать в отдельный подкаталог Demos/
|
||||
DONE искать книги в этом каталоге (в Network Library)
|
||||
DONE в методе Book.readMetaInfo() -- проверять путь к файлу и дописывать...
|
||||
|
||||
* как быть, когда книга загружается по ссылке из другой книги: не видно notification'а
|
||||
** показывать всплывающий notification с текстом "загрузка началась"
|
||||
DONE показывать всплывающий notification с текстом "загрузка началась"
|
||||
** "книжка уже загружается"
|
||||
|
||||
* при загрузке из браузера также показывать
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
<node name="contentSuccess" value="Download successful" />
|
||||
<node name="contentError" value="Download unsuccessful" />
|
||||
<node name="untitled" value="<Untitled>" />
|
||||
<node name="downloadingStarted" value="Book downloading has been started" />
|
||||
</node>
|
||||
<node name="tocView">
|
||||
<node name="expandTree" value="Expand tree"/>
|
||||
|
|
|
@ -56,7 +56,11 @@ public class BookDownloader extends Activity {
|
|||
finish();
|
||||
return;
|
||||
}
|
||||
startService(new Intent(Intent.ACTION_DEFAULT, uri, this, BookDownloaderService.class));
|
||||
|
||||
startService(
|
||||
new Intent(Intent.ACTION_DEFAULT, uri, this, BookDownloaderService.class)
|
||||
.putExtras(intent.getExtras())
|
||||
);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ import android.net.Uri;
|
|||
import android.content.Intent;
|
||||
import android.content.Context;
|
||||
import android.widget.RemoteViews;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||
|
||||
|
@ -50,6 +51,16 @@ public class BookDownloaderService extends Service {
|
|||
public static final String CLEAN_URL_KEY = "org.geometerplus.android.fbreader.network.CleanURL";
|
||||
public static final String TITLE_KEY = "org.geometerplus.android.fbreader.network.Title";
|
||||
|
||||
public static final String SHOW_NOTIFICATIONS_KEY = "org.geometerplus.android.fbreader.network.ShowNotifications";
|
||||
|
||||
public interface Notifications {
|
||||
int DOWNLOAD_STARTED = 0x0001;
|
||||
int ALREADY_DOWNLOADING = 0x0002;
|
||||
|
||||
int ALL = 0x0003;
|
||||
}
|
||||
|
||||
|
||||
private volatile int myServiceCounter;
|
||||
|
||||
private void doStart() {
|
||||
|
@ -83,6 +94,8 @@ public class BookDownloaderService extends Service {
|
|||
}
|
||||
intent.setData(null);
|
||||
|
||||
final int notifications = intent.getIntExtra(SHOW_NOTIFICATIONS_KEY, 0);
|
||||
|
||||
final String url = uri.toString();
|
||||
final int bookFormat = intent.getIntExtra(BOOK_FORMAT_KEY, BookReference.Format.NONE);
|
||||
final int referenceType = intent.getIntExtra(REFERENCE_TYPE_KEY, BookReference.Type.UNKNOWN);
|
||||
|
@ -140,6 +153,13 @@ public class BookDownloaderService extends Service {
|
|||
if (title == null || title.length() == 0) {
|
||||
title = getResource().getResource("untitled").getValue();
|
||||
}
|
||||
if ((notifications & Notifications.DOWNLOAD_STARTED) != 0) {
|
||||
Toast.makeText(
|
||||
getApplicationContext(),
|
||||
getResource().getResource("downloadingStarted").getValue(),
|
||||
Toast.LENGTH_SHORT
|
||||
).show();
|
||||
}
|
||||
startFileDownload(url, fileFile, title);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.geometerplus.zlibrary.ui.android.dialogs.ZLAndroidDialogManager;
|
|||
import org.geometerplus.fbreader.network.NetworkLibrary;
|
||||
|
||||
import org.geometerplus.android.fbreader.network.BookDownloader;
|
||||
import org.geometerplus.android.fbreader.network.BookDownloaderService;
|
||||
|
||||
public final class ZLAndroidLibrary extends ZLibrary {
|
||||
private ZLAndroidActivity myActivity;
|
||||
|
@ -77,6 +78,7 @@ public final class ZLAndroidLibrary extends ZLibrary {
|
|||
boolean externalUrl = true;
|
||||
if (BookDownloader.acceptsUri(Uri.parse(reference))) {
|
||||
intent.setClass(myActivity, BookDownloader.class);
|
||||
intent.putExtra(BookDownloaderService.SHOW_NOTIFICATIONS_KEY, BookDownloaderService.Notifications.ALL);
|
||||
externalUrl = false;
|
||||
}
|
||||
reference = NetworkLibrary.Instance().rewriteUrl(reference, externalUrl);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue