mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 02:39:23 +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 при скачивании книги, отображать Название книги вместо имени файла
|
DONE добавить Extra -- Book Title при скачивании книги, отображать Название книги вместо имени файла
|
||||||
|
|
||||||
* добавлять Tag и изменять Title для Demo-книжек
|
DONE добавлять Tag и изменять Title для Demo-книжек
|
||||||
DONE складывать в отдельный подкаталог Demos/
|
DONE складывать в отдельный подкаталог Demos/
|
||||||
DONE искать книги в этом каталоге (в Network Library)
|
DONE искать книги в этом каталоге (в Network Library)
|
||||||
DONE в методе Book.readMetaInfo() -- проверять путь к файлу и дописывать...
|
DONE в методе Book.readMetaInfo() -- проверять путь к файлу и дописывать...
|
||||||
|
|
||||||
* как быть, когда книга загружается по ссылке из другой книги: не видно notification'а
|
* как быть, когда книга загружается по ссылке из другой книги: не видно notification'а
|
||||||
** показывать всплывающий notification с текстом "загрузка началась"
|
DONE показывать всплывающий notification с текстом "загрузка началась"
|
||||||
** "книжка уже загружается"
|
** "книжка уже загружается"
|
||||||
|
|
||||||
* при загрузке из браузера также показывать
|
* при загрузке из браузера также показывать
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
<node name="contentSuccess" value="Download successful" />
|
<node name="contentSuccess" value="Download successful" />
|
||||||
<node name="contentError" value="Download unsuccessful" />
|
<node name="contentError" value="Download unsuccessful" />
|
||||||
<node name="untitled" value="<Untitled>" />
|
<node name="untitled" value="<Untitled>" />
|
||||||
|
<node name="downloadingStarted" value="Book downloading has been started" />
|
||||||
</node>
|
</node>
|
||||||
<node name="tocView">
|
<node name="tocView">
|
||||||
<node name="expandTree" value="Expand tree"/>
|
<node name="expandTree" value="Expand tree"/>
|
||||||
|
|
|
@ -56,7 +56,11 @@ public class BookDownloader extends Activity {
|
||||||
finish();
|
finish();
|
||||||
return;
|
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();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ import android.net.Uri;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.widget.RemoteViews;
|
import android.widget.RemoteViews;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
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 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 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 volatile int myServiceCounter;
|
||||||
|
|
||||||
private void doStart() {
|
private void doStart() {
|
||||||
|
@ -83,6 +94,8 @@ public class BookDownloaderService extends Service {
|
||||||
}
|
}
|
||||||
intent.setData(null);
|
intent.setData(null);
|
||||||
|
|
||||||
|
final int notifications = intent.getIntExtra(SHOW_NOTIFICATIONS_KEY, 0);
|
||||||
|
|
||||||
final String url = uri.toString();
|
final String url = uri.toString();
|
||||||
final int bookFormat = intent.getIntExtra(BOOK_FORMAT_KEY, BookReference.Format.NONE);
|
final int bookFormat = intent.getIntExtra(BOOK_FORMAT_KEY, BookReference.Format.NONE);
|
||||||
final int referenceType = intent.getIntExtra(REFERENCE_TYPE_KEY, BookReference.Type.UNKNOWN);
|
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) {
|
if (title == null || title.length() == 0) {
|
||||||
title = getResource().getResource("untitled").getValue();
|
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);
|
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.fbreader.network.NetworkLibrary;
|
||||||
|
|
||||||
import org.geometerplus.android.fbreader.network.BookDownloader;
|
import org.geometerplus.android.fbreader.network.BookDownloader;
|
||||||
|
import org.geometerplus.android.fbreader.network.BookDownloaderService;
|
||||||
|
|
||||||
public final class ZLAndroidLibrary extends ZLibrary {
|
public final class ZLAndroidLibrary extends ZLibrary {
|
||||||
private ZLAndroidActivity myActivity;
|
private ZLAndroidActivity myActivity;
|
||||||
|
@ -77,6 +78,7 @@ public final class ZLAndroidLibrary extends ZLibrary {
|
||||||
boolean externalUrl = true;
|
boolean externalUrl = true;
|
||||||
if (BookDownloader.acceptsUri(Uri.parse(reference))) {
|
if (BookDownloader.acceptsUri(Uri.parse(reference))) {
|
||||||
intent.setClass(myActivity, BookDownloader.class);
|
intent.setClass(myActivity, BookDownloader.class);
|
||||||
|
intent.putExtra(BookDownloaderService.SHOW_NOTIFICATIONS_KEY, BookDownloaderService.Notifications.ALL);
|
||||||
externalUrl = false;
|
externalUrl = false;
|
||||||
}
|
}
|
||||||
reference = NetworkLibrary.Instance().rewriteUrl(reference, externalUrl);
|
reference = NetworkLibrary.Instance().rewriteUrl(reference, externalUrl);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue