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

self-service kiosk topup code; resources strings

This commit is contained in:
Nikolay Pultsin 2011-03-20 04:53:34 +00:00
parent 05020b0ca3
commit 2a08b9fd31
15 changed files with 58 additions and 42 deletions

View file

@ -78,6 +78,8 @@
<node name="signOut" value="Odhlásit (%s)"/>
<node name="topup" value="Doplnit účet (aktuálně: %s)"/>
<node name="topupTitle" value="Doplnit účet"/>
<node name="topupViaCreditCard" value="Credit card" toBeTranslated="true"/>
<node name="topupViaSelfServiceKiosk" value="Self-service kiosk" toBeTranslated="true"/>
<node name="topupViaSms" value="Textová zpráva"/>
<node name="topupViaBrowser" value="Otevřít stránku v prohlížeči"/>
<node name="topupSummary" value="Aktuálně: %s"/>

View file

@ -79,6 +79,8 @@
<node name="signOut" value="Ausloggen (%s)"/>
<node name="topup" value="Konto aufladen (derzeit: %s)"/>
<node name="topupTitle" value="Konto aufladen"/>
<node name="topupViaCreditCard" value="Credit card" toBeTranslated="true"/>
<node name="topupViaSelfServiceKiosk" value="Self-service kiosk" toBeTranslated="true"/>
<node name="topupViaSms" value="Text messages" toBeTranslated="true"/>
<node name="topupViaBrowser" value="Open page in browser" toBeTranslated="true"/>
<node name="topupSummary" value="Derzeit: %s"/>

View file

@ -77,6 +77,8 @@
<node name="signOut" value="Sign out (%s)"/>
<node name="topup" value="Top up account (currently: %s)"/>
<node name="topupTitle" value="Top up account"/>
<node name="topupViaCreditCard" value="Credit card"/>
<node name="topupViaSelfServiceKiosk" value="Self-service kiosk"/>
<node name="topupViaSms" value="Text messages"/>
<node name="topupViaBrowser" value="Open page in browser"/>
<node name="topupSummary" value="Currently: %s"/>

View file

@ -81,6 +81,8 @@
<node name="signOut" value="Déconnexion (%s)"/>
<node name="topup" value="Recréditer le compte (actuellement : %s)"/>
<node name="topupTitle" value="Recréditer le compte"/>
<node name="topupViaCreditCard" value="Credit card" toBeTranslated="true"/>
<node name="topupViaSelfServiceKiosk" value="Self-service kiosk" toBeTranslated="true"/>
<node name="topupViaSms" value="Messages texte"/>
<node name="topupViaBrowser" value="Ouvrir la page dans le navigateur"/>
<node name="topupSummary" value="Аctuellement : %s"/>

View file

@ -78,6 +78,8 @@
<node name="signOut" value="Saír (%s)"/>
<node name="topup" value="Actualizar a conta (actualmente: %s)"/>
<node name="topupTitle" value="Actualizar a conta"/>
<node name="topupViaCreditCard" value="Credit card" toBeTranslated="true"/>
<node name="topupViaSelfServiceKiosk" value="Self-service kiosk" toBeTranslated="true"/>
<node name="topupViaSms" value="Mensaxes de texto"/>
<node name="topupViaBrowser" value="Abrir a páxina no navegador"/>
<node name="topupSummary" value="Actualmente: %s"/>

View file

@ -78,6 +78,8 @@
<node name="signOut" value="Kijelentkezés (%s)"/>
<node name="topup" value="Számla feltöltése (Jelenleg: %s)"/>
<node name="topupTitle" value="Számla feltöltése"/>
<node name="topupViaCreditCard" value="Credit card" toBeTranslated="true"/>
<node name="topupViaSelfServiceKiosk" value="Self-service kiosk" toBeTranslated="true"/>
<node name="topupViaSms" value="SMS üzenetek"/>
<node name="topupViaBrowser" value="Oldal megnyitása böngészőben"/>
<node name="topupSummary" value="Jelenleg: %s"/>

View file

@ -78,6 +78,8 @@
<node name="signOut" value="Esci (%s)"/>
<node name="topup" value="Ricarica account (corrente: %s)"/>
<node name="topupTitle" value="Ricarica account"/>
<node name="topupViaCreditCard" value="Credit card" toBeTranslated="true"/>
<node name="topupViaSelfServiceKiosk" value="Self-service kiosk" toBeTranslated="true"/>
<node name="topupViaSms" value="Text messages" toBeTranslated="true"/>
<node name="topupViaBrowser" value="Open page in browser" toBeTranslated="true"/>
<node name="topupSummary" value="Corrente: %s"/>

View file

@ -78,6 +78,8 @@
<node name="signOut" value="Sign out (%s)" toBeTranslated="true"/>
<node name="topup" value="Top up account (currently: %s)" toBeTranslated="true"/>
<node name="topupTitle" value="Top up account" toBeTranslated="true"/>
<node name="topupViaCreditCard" value="Credit card" toBeTranslated="true"/>
<node name="topupViaSelfServiceKiosk" value="Self-service kiosk" toBeTranslated="true"/>
<node name="topupViaSms" value="Text messages" toBeTranslated="true"/>
<node name="topupViaBrowser" value="Open pagina in de browser" />
<node name="topupSummary" value="Currently: %s" toBeTranslated="true"/>

View file

@ -77,8 +77,10 @@
<node name="signOut" value="Выйти (%s)"/>
<node name="topup" value="Пополнить счёт (текущий счёт: %s)" />
<node name="topupTitle" value="Пополнить счёт"/>
<node name="topupViaSms" value="Варианты SMS"/>
<node name="topupViaBrowser" value="Окно браузера"/>
<node name="topupViaCreditCard" value="Кредитной картой"/>
<node name="topupViaSelfServiceKiosk" value="В платежном терминале"/>
<node name="topupViaSms" value="Платной SMS"/>
<node name="topupViaBrowser" value="В окне браузера"/>
<node name="topupSummary" value="Текущий счёт: %s"/>
<node name="alreadyDownloading" value="Книга загружается" />
<node name="alreadyDownloadingDemo" value="Фрагмент загружается" />

View file

@ -78,6 +78,8 @@
<node name="signOut" value="ออกจากระบบ (%s)"/>
<node name="topup" value="เติมเงินเข้าบัญชีผู้ใช้ (ปัจจุบันคือ: %s)"/>
<node name="topupTitle" value="เติมเงินเข้าบัญชี"/>
<node name="topupViaCreditCard" value="Credit card" toBeTranslated="true"/>
<node name="topupViaSelfServiceKiosk" value="Self-service kiosk" toBeTranslated="true"/>
<node name="topupViaSms" value="ข้อความ"/>
<node name="topupViaBrowser" value="เปิดในเว็บเบราว์เซอร์"/>
<node name="topupSummary" value="ปัจจุบัน: %s"/>

View file

@ -78,6 +78,8 @@
<node name="signOut" value="Вийти (%s)"/>
<node name="topup" value="Поповнити рахунок (поточний рахунок: %s)" />
<node name="topupTitle" value="Поповнити рахунок"/>
<node name="topupViaCreditCard" value="Credit card" toBeTranslated="true"/>
<node name="topupViaSelfServiceKiosk" value="Self-service kiosk" toBeTranslated="true"/>
<node name="topupViaSms" value="Text messages" toBeTranslated="true"/>
<node name="topupViaBrowser" value="Open page in browser" toBeTranslated="true"/>
<node name="topupSummary" value="Поточний рахунок: %s"/>

View file

@ -78,6 +78,8 @@
<node name="signOut" value="Đăng xuất (%s)"/>
<node name="topup" value="Làm đầy lại tài khoản (hiện tại: %s)"/>
<node name="topupTitle" value="Làm đầy lại tài khoản"/>
<node name="topupViaCreditCard" value="Credit card" toBeTranslated="true"/>
<node name="topupViaSelfServiceKiosk" value="Self-service kiosk" toBeTranslated="true"/>
<node name="topupViaSms" value="Tin nhắn"/>
<node name="topupViaBrowser" value="Mở trang trong trình duyệt"/>
<node name="topupSummary" value="Hiện tại: %s"/>

View file

@ -78,6 +78,8 @@
<node name="signOut" value="退出 (%s)"/>
<node name="topup" value="重新输入账号(目前: %s)" />
<node name="topupTitle" value="重新输入账号"/>
<node name="topupViaCreditCard" value="Credit card" toBeTranslated="true"/>
<node name="topupViaSelfServiceKiosk" value="Self-service kiosk" toBeTranslated="true"/>
<node name="topupViaSms" value="短消息"/>
<node name="topupViaBrowser" value="在浏览器中打开页面"/>
<node name="topupSummary" value="当前: %s"/>

View file

@ -33,6 +33,7 @@ class TopupActions extends NetworkTreeActions {
public static final int TOPUP_VIA_SMS_ITEM_ID = 0;
public static final int TOPUP_VIA_BROWSER_ITEM_ID = 1;
public static final int TOPUP_VIA_CREDIT_CARD_ITEM_ID = 2;
public static final int TOPUP_VIA_SELF_SERVICE_ITEM_ID = 3;
@Override
public boolean canHandleTree(NetworkTree tree) {
@ -47,12 +48,15 @@ class TopupActions extends NetworkTreeActions {
void buildContextMenu(Activity activity, ContextMenu menu, INetworkLink link) {
menu.setHeaderTitle(getTitleValue("topupTitle"));
if (Util.isCreditCardTopupSupported(activity, link)) {
if (Util.isTopupSupported(activity, link, Util.CREDIT_CARD_TOPUP_ACTION)) {
addMenuItem(menu, TOPUP_VIA_CREDIT_CARD_ITEM_ID, "topupViaCreditCard");
}
if (Util.isSmsTopupSupported(activity, link)) {
if (Util.isTopupSupported(activity, link, Util.SMS_TOPUP_ACTION)) {
addMenuItem(menu, TOPUP_VIA_SMS_ITEM_ID, "topupViaSms");
}
if (Util.isTopupSupported(activity, link, Util.SELF_SERVICE_KIOSK_TOPUP_ACTION)) {
addMenuItem(menu, TOPUP_VIA_SELF_SERVICE_ITEM_ID, "topupViaSelfServiceKiosk");
}
if (Util.isBrowserTopupSupported(activity, link)) {
addMenuItem(menu, TOPUP_VIA_BROWSER_ITEM_ID, "topupViaBrowser");
}
@ -63,13 +67,15 @@ class TopupActions extends NetworkTreeActions {
return getDefaultActionCode(activity, ((TopUpTree)tree).Item.Link);
}
private int getDefaultActionCode(Activity activity, INetworkLink link) {
final boolean sms = Util.isSmsTopupSupported(activity, link);
final boolean browser = Util.isBrowserTopupSupported(activity, link);
final boolean creditCard = Util.isCreditCardTopupSupported(activity, link);
final boolean sms = Util.isTopupSupported(activity, link, Util.SMS_TOPUP_ACTION);
final boolean creditCard = Util.isTopupSupported(activity, link, Util.CREDIT_CARD_TOPUP_ACTION);
final boolean selfService = Util.isTopupSupported(activity, link, Util.SELF_SERVICE_KIOSK_TOPUP_ACTION);
final int count =
(sms ? 1 : 0) +
(browser ? 1 : 0) +
(creditCard ? 1 : 0);
(creditCard ? 1 : 0) +
(selfService ? 1 : 0);
if (count > 1) {
return TREE_SHOW_CONTEXT_MENU;
@ -77,6 +83,8 @@ class TopupActions extends NetworkTreeActions {
return TOPUP_VIA_SMS_ITEM_ID;
} else if (creditCard) {
return TOPUP_VIA_CREDIT_CARD_ITEM_ID;
} else if (selfService) {
return TOPUP_VIA_SELF_SERVICE_ITEM_ID;
} else /* if (browser) */ {
return TOPUP_VIA_BROWSER_ITEM_ID;
}
@ -107,13 +115,16 @@ class TopupActions extends NetworkTreeActions {
Runnable topupRunnable = null;
switch (actionCode) {
case TOPUP_VIA_SMS_ITEM_ID:
topupRunnable = smsTopupRunnable(activity, link);
topupRunnable = topupRunnable(activity, link, Util.SMS_TOPUP_ACTION);
break;
case TOPUP_VIA_BROWSER_ITEM_ID:
topupRunnable = browserTopupRunnable(activity, link);
break;
case TOPUP_VIA_CREDIT_CARD_ITEM_ID:
topupRunnable = creditCardTopupRunnable(activity, link);
topupRunnable = topupRunnable(activity, link, Util.CREDIT_CARD_TOPUP_ACTION);
break;
case TOPUP_VIA_SELF_SERVICE_ITEM_ID:
topupRunnable = topupRunnable(activity, link, Util.SELF_SERVICE_KIOSK_TOPUP_ACTION);
break;
}
@ -135,18 +146,10 @@ class TopupActions extends NetworkTreeActions {
};
}
private static Runnable smsTopupRunnable(final Activity activity, final INetworkLink link) {
private static Runnable topupRunnable(final Activity activity, final INetworkLink link, final String action) {
return new Runnable() {
public void run() {
Util.runSmsTopupDialog(activity, link);
}
};
}
private static Runnable creditCardTopupRunnable(final Activity activity, final INetworkLink link) {
return new Runnable() {
public void run() {
Util.runCreditCardTopupDialog(activity, link);
Util.runTopupDialog(activity, link, action);
}
};
}

View file

@ -38,10 +38,12 @@ import org.geometerplus.android.util.PackageUtil;
abstract class Util implements UserRegistrationConstants {
private static final String REGISTRATION_ACTION =
"android.fbreader.action.NETWORK_LIBRARY_REGISTER";
private static final String SMS_TOPUP_ACTION =
static final String SMS_TOPUP_ACTION =
"android.fbreader.action.NETWORK_LIBRARY_SMS_REFILLING";
private static final String CREDIT_CARD_TOPUP_ACTION =
static final String CREDIT_CARD_TOPUP_ACTION =
"android.fbreader.action.NETWORK_LIBRARY_CREDIT_CARD_TOPUP";
static final String SELF_SERVICE_KIOSK_TOPUP_ACTION =
"android.fbreader.action.NETWORK_LIBRARY_SELF_SERVICE_KIOSK_TOPUP";
private static boolean testService(Activity activity, String action, String url) {
return url != null && PackageUtil.canBeStarted(activity, new Intent(action, Uri.parse(url)), true);
@ -88,35 +90,20 @@ abstract class Util implements UserRegistrationConstants {
static boolean isTopupSupported(Activity activity, INetworkLink link) {
return
isBrowserTopupSupported(activity, link) ||
isCreditCardTopupSupported(activity, link) ||
isSmsTopupSupported(activity, link);
isTopupSupported(activity, link, SMS_TOPUP_ACTION) ||
isTopupSupported(activity, link, CREDIT_CARD_TOPUP_ACTION) ||
isTopupSupported(activity, link, SELF_SERVICE_KIOSK_TOPUP_ACTION);
}
static boolean isSmsTopupSupported(Activity activity, INetworkLink link) {
static boolean isTopupSupported(Activity activity, INetworkLink link, String action) {
return testService(
activity,
SMS_TOPUP_ACTION,
action,
link.getUrlInfo(INetworkLink.URL_MAIN).URL
);
}
static boolean isCreditCardTopupSupported(Activity activity, INetworkLink link) {
return testService(
activity,
CREDIT_CARD_TOPUP_ACTION,
link.getUrlInfo(INetworkLink.URL_MAIN).URL
);
}
static void runSmsTopupDialog(Activity activity, INetworkLink link) {
runTopupDialog(activity, link, SMS_TOPUP_ACTION);
}
static void runCreditCardTopupDialog(Activity activity, INetworkLink link) {
runTopupDialog(activity, link, CREDIT_CARD_TOPUP_ACTION);
}
private static void runTopupDialog(Activity activity, INetworkLink link, String action) {
static void runTopupDialog(Activity activity, INetworkLink link, String action) {
try {
final Intent intent = new Intent(
action,