mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 19:42:17 +02:00
MissingBookActivity in AndroidManifest, code cleanup
This commit is contained in:
parent
9d0166d9a7
commit
ee83a02cbc
7 changed files with 16 additions and 20 deletions
|
@ -212,6 +212,7 @@
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name="org.geometerplus.android.fbreader.preferences.EditBookInfoActivity" android:process=":library" android:theme="@style/FBReader.Activity" android:configChanges="orientation|keyboardHidden|screenSize"/>
|
<activity android:name="org.geometerplus.android.fbreader.preferences.EditBookInfoActivity" android:process=":library" android:theme="@style/FBReader.Activity" android:configChanges="orientation|keyboardHidden|screenSize"/>
|
||||||
|
<activity android:name="org.geometerplus.android.fbreader.sync.MissingBookActivity" android:process=":networkLibrary" android:theme="@style/FBReader.Dialog" android:configChanges="orientation|keyboardHidden|screenSize"/>
|
||||||
<activity android:name="org.geometerplus.android.fbreader.network.BookDownloader" android:process=":networkLibrary" android:theme="@android:style/Theme.NoDisplay">
|
<activity android:name="org.geometerplus.android.fbreader.network.BookDownloader" android:process=":networkLibrary" android:theme="@android:style/Theme.NoDisplay">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW"/>
|
<action android:name="android.intent.action.VIEW"/>
|
||||||
|
|
|
@ -212,6 +212,7 @@
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name="org.geometerplus.android.fbreader.preferences.EditBookInfoActivity" android:process=":library" android:theme="@style/FBReader.Activity" android:configChanges="orientation|keyboardHidden|screenSize"/>
|
<activity android:name="org.geometerplus.android.fbreader.preferences.EditBookInfoActivity" android:process=":library" android:theme="@style/FBReader.Activity" android:configChanges="orientation|keyboardHidden|screenSize"/>
|
||||||
|
<activity android:name="org.geometerplus.android.fbreader.sync.MissingBookActivity" android:process=":networkLibrary" android:theme="@style/FBReader.Dialog" android:configChanges="orientation|keyboardHidden|screenSize"/>
|
||||||
<activity android:name="org.geometerplus.android.fbreader.network.BookDownloader" android:process=":networkLibrary" android:theme="@android:style/Theme.NoDisplay">
|
<activity android:name="org.geometerplus.android.fbreader.network.BookDownloader" android:process=":networkLibrary" android:theme="@android:style/Theme.NoDisplay">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW"/>
|
<action android:name="android.intent.action.VIEW"/>
|
||||||
|
|
|
@ -96,7 +96,7 @@ class ProcessHyperlinkAction extends FBAndroidAction {
|
||||||
final boolean externalUrl;
|
final boolean externalUrl;
|
||||||
if (BookDownloader.acceptsUri(Uri.parse(url))) {
|
if (BookDownloader.acceptsUri(Uri.parse(url))) {
|
||||||
intent.setClass(BaseActivity, BookDownloader.class);
|
intent.setClass(BaseActivity, BookDownloader.class);
|
||||||
intent.putExtra(BookDownloaderService.SHOW_NOTIFICATIONS_KEY, BookDownloaderService.Notifications.ALL);
|
intent.putExtra(BookDownloaderService.Key.SHOW_NOTIFICATIONS, BookDownloaderService.Notifications.ALL);
|
||||||
externalUrl = false;
|
externalUrl = false;
|
||||||
} else {
|
} else {
|
||||||
externalUrl = true;
|
externalUrl = true;
|
||||||
|
|
|
@ -63,8 +63,8 @@ public class BookDownloader extends Activity {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!intent.hasExtra(BookDownloaderService.SHOW_NOTIFICATIONS_KEY)) {
|
if (!intent.hasExtra(BookDownloaderService.Key.SHOW_NOTIFICATIONS)) {
|
||||||
intent.putExtra(BookDownloaderService.SHOW_NOTIFICATIONS_KEY,
|
intent.putExtra(BookDownloaderService.Key.SHOW_NOTIFICATIONS,
|
||||||
BookDownloaderService.Notifications.ALREADY_DOWNLOADING);
|
BookDownloaderService.Notifications.ALREADY_DOWNLOADING);
|
||||||
}
|
}
|
||||||
if ("epub".equals(uri.getScheme())) {
|
if ("epub".equals(uri.getScheme())) {
|
||||||
|
|
|
@ -46,15 +46,14 @@ public class BookDownloaderService extends Service {
|
||||||
private final ZLNetworkContext myNetworkContext = new ServiceNetworkContext(this);
|
private final ZLNetworkContext myNetworkContext = new ServiceNetworkContext(this);
|
||||||
|
|
||||||
public interface Key {
|
public interface Key {
|
||||||
String BOOK_TITLE = "org.geometerplus.android.fbreader.network.Title";
|
String FROM_SYNC = "fbreader.downloader.from.sync";
|
||||||
String BOOK_MIME = "fbreader.book.mime";
|
String BOOK_TITLE = "fbreader.downloader.book.title";
|
||||||
|
String BOOK_KIND = "fbreader.downloader.book.kind";
|
||||||
|
String BOOK_MIME = "fbreader.downloader.book.mime";
|
||||||
|
String CLEAN_URL = "fbreader.downloader.clean.url";
|
||||||
|
String SHOW_NOTIFICATIONS = "fbreader.downloader.show.notifications";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String REFERENCE_TYPE_KEY = "org.geometerplus.android.fbreader.network.ReferenceType";
|
|
||||||
public static final String CLEAN_URL_KEY = "org.geometerplus.android.fbreader.network.CleanURL";
|
|
||||||
|
|
||||||
public static final String SHOW_NOTIFICATIONS_KEY = "org.geometerplus.android.fbreader.network.ShowNotifications";
|
|
||||||
|
|
||||||
public interface Notifications {
|
public interface Notifications {
|
||||||
int DOWNLOADING_STARTED = 0x0001;
|
int DOWNLOADING_STARTED = 0x0001;
|
||||||
int ALREADY_DOWNLOADING = 0x0002;
|
int ALREADY_DOWNLOADING = 0x0002;
|
||||||
|
@ -112,16 +111,16 @@ public class BookDownloaderService extends Service {
|
||||||
}
|
}
|
||||||
intent.setData(null);
|
intent.setData(null);
|
||||||
|
|
||||||
final int notifications = intent.getIntExtra(SHOW_NOTIFICATIONS_KEY, 0);
|
final int notifications = intent.getIntExtra(Key.SHOW_NOTIFICATIONS, 0);
|
||||||
|
|
||||||
final String url = uri.toString();
|
final String url = uri.toString();
|
||||||
final MimeType mime = MimeType.get(intent.getStringExtra(Key.BOOK_MIME));
|
final MimeType mime = MimeType.get(intent.getStringExtra(Key.BOOK_MIME));
|
||||||
UrlInfo.Type referenceType = (UrlInfo.Type)intent.getSerializableExtra(REFERENCE_TYPE_KEY);
|
UrlInfo.Type referenceType = (UrlInfo.Type)intent.getSerializableExtra(Key.BOOK_KIND);
|
||||||
if (referenceType == null) {
|
if (referenceType == null) {
|
||||||
referenceType = UrlInfo.Type.Book;
|
referenceType = UrlInfo.Type.Book;
|
||||||
}
|
}
|
||||||
|
|
||||||
String cleanURL = intent.getStringExtra(CLEAN_URL_KEY);
|
String cleanURL = intent.getStringExtra(Key.CLEAN_URL);
|
||||||
if (cleanURL == null) {
|
if (cleanURL == null) {
|
||||||
cleanURL = url;
|
cleanURL = url;
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,8 +134,8 @@ public abstract class Util implements UserRegistrationConstants {
|
||||||
new Intent(Intent.ACTION_VIEW, Uri.parse(ref.Url),
|
new Intent(Intent.ACTION_VIEW, Uri.parse(ref.Url),
|
||||||
activity.getApplicationContext(), BookDownloaderService.class)
|
activity.getApplicationContext(), BookDownloaderService.class)
|
||||||
.putExtra(BookDownloaderService.Key.BOOK_MIME, ref.Mime.toString())
|
.putExtra(BookDownloaderService.Key.BOOK_MIME, ref.Mime.toString())
|
||||||
.putExtra(BookDownloaderService.REFERENCE_TYPE_KEY, resolvedType)
|
.putExtra(BookDownloaderService.Key.BOOK_KIND, resolvedType)
|
||||||
.putExtra(BookDownloaderService.CLEAN_URL_KEY, ref.cleanUrl())
|
.putExtra(BookDownloaderService.Key.CLEAN_URL, ref.cleanUrl())
|
||||||
.putExtra(BookDownloaderService.Key.BOOK_TITLE, book.Title)
|
.putExtra(BookDownloaderService.Key.BOOK_TITLE, book.Title)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.geometerplus.android.fbreader.sync;
|
package org.geometerplus.android.fbreader.sync;
|
||||||
|
|
||||||
import android.app.NotificationManager;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -27,7 +26,6 @@ import android.view.View;
|
||||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||||
|
|
||||||
import org.geometerplus.android.fbreader.network.BookDownloaderService;
|
import org.geometerplus.android.fbreader.network.BookDownloaderService;
|
||||||
import org.geometerplus.android.fbreader.network.NetworkNotifications;
|
|
||||||
import org.geometerplus.android.fbreader.util.SimpleDialogActivity;
|
import org.geometerplus.android.fbreader.util.SimpleDialogActivity;
|
||||||
|
|
||||||
public class MissingBookActivity extends SimpleDialogActivity {
|
public class MissingBookActivity extends SimpleDialogActivity {
|
||||||
|
@ -48,9 +46,6 @@ public class MissingBookActivity extends SimpleDialogActivity {
|
||||||
|
|
||||||
okButton().setOnClickListener(new View.OnClickListener() {
|
okButton().setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
final NotificationManager notificationManager =
|
|
||||||
(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
|
|
||||||
notificationManager.cancel(NetworkNotifications.MISSING_BOOK_ID);
|
|
||||||
startService(intent);
|
startService(intent);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue