1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-06 03:50:19 +02:00

new 'add custom dialog activity'; 'opds' scheme support in AndroidManifest.xml

This commit is contained in:
Nikolay Pultsin 2011-02-24 04:38:20 +03:00
parent cd2f1954a7
commit 2ebb3ad9d1
17 changed files with 313 additions and 15 deletions

View file

@ -131,9 +131,17 @@
</intent-filter>
<meta-data android:name="android.app.searchable" android:resource="@xml/searchable" />
</activity>
<activity android:name="org.geometerplus.android.fbreader.network.NetworkLibraryActivity" android:process=":networkLibrary" android:configChanges="orientation|keyboardHidden">
<activity android:name="org.geometerplus.android.fbreader.network.NetworkLibraryActivity" android:process=":networkLibrary" android:launchMode="singleTask" android:configChanges="orientation|keyboardHidden">
<meta-data android:name="android.app.default_searchable" android:value="org.geometerplus.android.fbreader.network.NetworkSearchActivity" />
</activity>
<activity android:name="org.geometerplus.android.fbreader.network.AddCustomCatalogActivity" android:configChanges="orientation|keyboardHidden" android:theme="@android:style/Theme.Dialog">
<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:host="*" android:scheme="opds" />
</intent-filter>
</activity>
<activity android:name="org.geometerplus.android.fbreader.network.NetworkCatalogActivity" android:process=":networkLibrary" android:configChanges="orientation|keyboardHidden" />
<service android:name="org.geometerplus.android.fbreader.network.ItemsLoadingService" android:process=":networkLibrary" />
<activity android:name="org.geometerplus.android.fbreader.network.NetworkBookInfoActivity" android:process=":networkLibrary" android:configChanges="orientation|keyboardHidden" />

View file

@ -131,9 +131,17 @@
</intent-filter>
<meta-data android:name="android.app.searchable" android:resource="@xml/searchable" />
</activity>
<activity android:name="org.geometerplus.android.fbreader.network.NetworkLibraryActivity" android:process=":networkLibrary" android:configChanges="orientation|keyboardHidden">
<activity android:name="org.geometerplus.android.fbreader.network.NetworkLibraryActivity" android:process=":networkLibrary" android:launchMode="singleTask" android:configChanges="orientation|keyboardHidden">
<meta-data android:name="android.app.default_searchable" android:value="org.geometerplus.android.fbreader.network.NetworkSearchActivity" />
</activity>
<activity android:name="org.geometerplus.android.fbreader.network.AddCustomCatalogActivity" android:configChanges="orientation|keyboardHidden" android:theme="@android:style/Theme.Dialog">
<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:host="*" android:scheme="opds" />
</intent-filter>
</activity>
<activity android:name="org.geometerplus.android.fbreader.network.NetworkCatalogActivity" android:process=":networkLibrary" android:configChanges="orientation|keyboardHidden" />
<service android:name="org.geometerplus.android.fbreader.network.ItemsLoadingService" android:process=":networkLibrary" />
<activity android:name="org.geometerplus.android.fbreader.network.NetworkBookInfoActivity" android:process=":networkLibrary" android:configChanges="orientation|keyboardHidden" />

View file

@ -576,7 +576,7 @@
<node name="register" value="Přihlásit" />
</node>
<node name="CustomCatalogDialog">
<node name="title" value="Vlastní katalog" />
<node name="title" value="FBReader: add custom catalog" toBeTranslated="true" />
<node name="catalogTitle" value="Název" />
<node name="catalogUrl" value="URL" />
<node name="catalogSummary" value="Stručný obsah" />

View file

@ -577,7 +577,7 @@
<node name="register" value="Anmelden" />
</node>
<node name="CustomCatalogDialog">
<node name="title" value="Benutzerspezifischer Katalog" />
<node name="title" value="FBReader: add custom catalog" toBeTranslated="true" />
<node name="catalogTitle" value="Titel" />
<node name="catalogUrl" value="URL" />
<node name="catalogSummary" value="Zusammenfassung" />

View file

@ -575,7 +575,7 @@
<node name="register" value="Sign up" />
</node>
<node name="CustomCatalogDialog">
<node name="title" value="Custom catalog" />
<node name="title" value="FBReader: add custom catalog" />
<node name="catalogTitle" value="Title" />
<node name="catalogUrl" value="URL" />
<node name="catalogSummary" value="Summary" />

View file

@ -579,7 +579,7 @@
<node name="register" value="Inscription"/>
</node>
<node name="CustomCatalogDialog">
<node name="title" value="Catalogue personalisé" />
<node name="title" value="FBReader: add custom catalog" toBeTranslated="true" />
<node name="catalogTitle" value="Titre" />
<node name="catalogUrl" value="Adresse du catalogue sur le réseau" />
<node name="catalogSummary" value="Description" />

View file

@ -576,7 +576,7 @@
<node name="register" value="Rexistro" />
</node>
<node name="CustomCatalogDialog">
<node name="title" value="Catálogo personalizado" />
<node name="title" value="FBReader: add custom catalog" toBeTranslated="true" />
<node name="catalogTitle" value="Título" />
<node name="catalogUrl" value="URL" />
<node name="catalogSummary" value="Resumo" />

View file

@ -576,7 +576,7 @@
<node name="register" value="Regisztráció" />
</node>
<node name="CustomCatalogDialog">
<node name="title" value="Saját katalógus" />
<node name="title" value="FBReader: add custom catalog" toBeTranslated="true" />
<node name="catalogTitle" value="Cím" />
<node name="catalogUrl" value="URL" />
<node name="catalogSummary" value="Leírás" />

View file

@ -576,7 +576,7 @@
<node name="register" value="Registrati" />
</node>
<node name="CustomCatalogDialog">
<node name="title" value="Catalogo personalizzato" />
<node name="title" value="FBReader: add custom catalog" toBeTranslated="true" />
<node name="catalogTitle" value="Titolo" />
<node name="catalogUrl" value="URL" />
<node name="catalogSummary" value="Sommario" />

View file

@ -576,7 +576,7 @@
<node name="register" value="Registeren" />
</node>
<node name="CustomCatalogDialog">
<node name="title" value="Andere catalogus" />
<node name="title" value="FBReader: add custom catalog" toBeTranslated="true" />
<node name="catalogTitle" value="Titel" />
<node name="catalogUrl" value="URL" />
<node name="catalogSummary" value="Beschrijving" />

View file

@ -575,7 +575,7 @@
<node name="register" value="Зарегистрироваться" />
</node>
<node name="CustomCatalogDialog">
<node name="title" value="Пользовательский каталог" />
<node name="title" value="FBReader: добавление каталога" />
<node name="catalogTitle" value="Название" />
<node name="catalogUrl" value="URL" />
<node name="catalogSummary" value="Описание" />

View file

@ -576,7 +576,7 @@
<node name="register" value="ลงทะเบียน"/>
</node>
<node name="CustomCatalogDialog">
<node name="title" value="แคตตาล็อกที่กำหนดเอง"/>
<node name="title" value="FBReader: add custom catalog" toBeTranslated="true" />
<node name="catalogTitle" value="ชื่อแคตตาล็อก"/>
<node name="catalogUrl" value="URL"/>
<node name="catalogSummary" value="สรุป"/>

View file

@ -576,7 +576,7 @@
<node name="register" value="Зареєструватися" />
</node>
<node name="CustomCatalogDialog">
<node name="title" value="Користувацький каталог" />
<node name="title" value="FBReader: add custom catalog" toBeTranslated="true" />
<node name="catalogTitle" value="Назва" />
<node name="catalogUrl" value="URL" />
<node name="catalogSummary" value="Опис" />

View file

@ -576,7 +576,7 @@
<node name="register" value="Đăng ký" />
</node>
<node name="CustomCatalogDialog">
<node name="title" value="Tùy chỉnh catalo" />
<node name="title" value="FBReader: add custom catalog" toBeTranslated="true" />
<node name="catalogTitle" value="Tiêu đề" />
<node name="catalogUrl" value="URL" />
<node name="catalogSummary" value="Tóm tắt" />

View file

@ -576,7 +576,7 @@
<node name="register" value="注册" />
</node>
<node name="CustomCatalogDialog">
<node name="title" value="自定义书库目录" />
<node name="title" value="FBReader: add custom catalog" toBeTranslated="true" />
<node name="catalogTitle" value="目录名称" />
<node name="catalogUrl" value="目录网址" />
<node name="catalogSummary" value="简介" />

View file

@ -0,0 +1,164 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:orientation="vertical"
>
<RelativeLayout
android:id="@+id/add_custom_catalog_title_group"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/add_custom_catalog_title_label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:layout_alignParentTop="true"
/>
<TextView
android:id="@+id/add_custom_catalog_title_star"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="*"
android:textColor="#ffff0000"
android:layout_marginLeft="4dp"
android:layout_alignParentRight="true"
android:layout_below="@id/add_custom_catalog_title_label"
/>
<EditText
android:id="@+id/add_custom_catalog_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@id/add_custom_catalog_title_star"
android:layout_below="@id/add_custom_catalog_title_label"
/>
<TextView
android:id="@+id/add_custom_catalog_title_example"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:gravity="right"
android:layout_alignParentBottom="true"
android:layout_below="@id/add_custom_catalog_title"
/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/add_custom_catalog_url_group"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
>
<TextView
android:id="@+id/add_custom_catalog_url_label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:layout_alignParentTop="true"
/>
<TextView
android:id="@+id/add_custom_catalog_url_star"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="*"
android:textColor="#ffff0000"
android:layout_marginLeft="4dp"
android:layout_alignParentRight="true"
android:layout_below="@id/add_custom_catalog_url_label"
/>
<EditText
android:id="@+id/add_custom_catalog_url"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:inputType="textUri"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@id/add_custom_catalog_url_star"
android:layout_below="@id/add_custom_catalog_url_label"
/>
<TextView
android:id="@+id/add_custom_catalog_url_example"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:gravity="right"
android:layout_alignParentBottom="true"
android:layout_below="@id/add_custom_catalog_url"
/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/add_custom_catalog_summary_group"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
>
<TextView
android:id="@+id/add_custom_catalog_summary_label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:layout_alignParentTop="true"
/>
<EditText
android:id="@+id/add_custom_catalog_summary"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:layout_below="@id/add_custom_catalog_summary_label"
/>
<TextView
android:id="@+id/add_custom_catalog_summary_example"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:gravity="right"
android:layout_alignParentBottom="true"
android:layout_below="@id/add_custom_catalog_summary"
/>
</RelativeLayout>
<TextView
android:id="@+id/add_custom_catalog_error"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:textColor="#ff0000"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="20dp"
android:paddingBottom="10dp"
android:orientation="horizontal"
>
<Button
android:id="@+id/add_custom_catalog_ok_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_weight="1"
/>
<Button
android:id="@+id/add_custom_catalog_cancel_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_weight="1"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>

View file

@ -0,0 +1,118 @@
/*
* Copyright (C) 2010-2011 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
package org.geometerplus.android.fbreader.network;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.widget.TextView;
import org.geometerplus.zlibrary.core.resources.ZLResource;
import org.geometerplus.zlibrary.core.network.ZLNetworkException;
import org.geometerplus.zlibrary.ui.android.R;
import org.geometerplus.fbreader.network.ICustomNetworkLink;
import org.geometerplus.fbreader.network.opds.OPDSLinkReader;
import org.geometerplus.android.util.UIUtil;
public class AddCustomCatalogActivity extends Activity {
private ZLResource myResource;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
Thread.setDefaultUncaughtExceptionHandler(new org.geometerplus.zlibrary.ui.android.library.UncaughtExceptionHandler(this));
setContentView(R.layout.add_custom_catalog);
final ZLResource dialogResource = ZLResource.resource("dialog");
myResource = dialogResource.getResource("CustomCatalogDialog");
setTitle(myResource.getResource("title").getValue());
setTextFromResource(R.id.add_custom_catalog_title_label, "catalogTitle");
setTextFromResource(R.id.add_custom_catalog_url_label, "catalogUrl");
setTextFromResource(R.id.add_custom_catalog_summary_label, "catalogSummary");
setTextFromResource(R.id.add_custom_catalog_title_example, "catalogTitleExample");
setTextFromResource(R.id.add_custom_catalog_url_example, "catalogUrlExample");
setTextFromResource(R.id.add_custom_catalog_summary_example, "catalogSummaryExample");
final ZLResource buttonResource = dialogResource.getResource("button");
setText(R.id.add_custom_catalog_ok_button, buttonResource.getResource("ok").getValue());
setText(R.id.add_custom_catalog_cancel_button, buttonResource.getResource("cancel").getValue());
final Uri uri = getIntent().getData();
if (uri != null) {
loadInfoByUri(uri);
}
}
private void setText(int id, String text) {
((TextView)findViewById(id)).setText(text);
}
private void setTextFromResource(int id, String resourceKey) {
setText(id, myResource.getResource(resourceKey).getValue());
}
private void loadInfoByUri(Uri uri) {
String httpUrl = uri.toString();
if (uri.getScheme() == null) {
httpUrl = "http://" + httpUrl;
uri = Uri.parse(httpUrl);
} else if ("opds".equals(uri.getScheme())) {
httpUrl = "http" + uri.toString().substring(4);
}
setText(R.id.add_custom_catalog_url, httpUrl);
String siteName = uri.getHost();
if (siteName == null) {
setTextFromResource(R.id.add_custom_catalog_error, "invalidUrl");
return;
}
if (siteName.startsWith("www.")) {
siteName = siteName.substring(4);
}
final ICustomNetworkLink link =
OPDSLinkReader.createCustomLinkWithoutInfo(siteName, httpUrl);
final Runnable loadInfoRunnable = new Runnable() {
private String myError;
public void run() {
try {
link.reloadInfo();
} catch (ZLNetworkException e) {
myError = e.getMessage();
}
runOnUiThread(new Runnable() {
public void run() {
setText(R.id.add_custom_catalog_title, link.getTitle());
setText(R.id.add_custom_catalog_summary, link.getSummary());
setText(R.id.add_custom_catalog_error, myError);
}
});
}
};
UIUtil.wait("loadingCatalogInfo", loadInfoRunnable, this);
}
}