mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-06 03:50:19 +02:00
sms account refilling: in progress
This commit is contained in:
parent
05cac34eb0
commit
18953a7706
15 changed files with 74 additions and 40 deletions
|
@ -17,6 +17,8 @@ DONE обработка ошибок при получении информац
|
|||
* resources synchronization
|
||||
|
||||
After 0.99:
|
||||
* password recovering
|
||||
* recover password if e-mail address is already in use
|
||||
DELAYED 'Refill account' item should be visible iff user is logged in
|
||||
* Авторегистрация
|
||||
* Автопокупка
|
||||
|
|
|
@ -2,10 +2,11 @@
|
|||
<!-- Czech FBReaderJ resources, by Marek Pavelka -->
|
||||
<resources>
|
||||
<node name="smsDialog">
|
||||
<node name="title" value="Refill account via SMS" toBeTranslated="true" />
|
||||
<node name="title" value="Refill account via text message" toBeTranslated="true" />
|
||||
<node name="youPay" value="You pay %s" toBeTranslated="true" />
|
||||
<node name="noPhoneInfo" value="Cannot obtain phone info for your device" toBeTranslated="true" />
|
||||
<node name="noCellularNetwork" value="Cellular network is not available" toBeTranslated="true" />
|
||||
<node name="youAreInRoaming" value="Text message account refilling is not available because your phone is in roaming mode" toBeTranslated="true" />
|
||||
</node>
|
||||
<node name="userRegistration">
|
||||
<node name="title" value="Registrace uživatele" />
|
||||
|
|
|
@ -3,10 +3,11 @@
|
|||
<!-- Updated by Ingolf Kübler 2010/11/17 -->
|
||||
<resources>
|
||||
<node name="smsDialog">
|
||||
<node name="title" value="Refill account via SMS" toBeTranslated="true" />
|
||||
<node name="title" value="Refill account via text message" toBeTranslated="true" />
|
||||
<node name="youPay" value="You pay %s" toBeTranslated="true" />
|
||||
<node name="noPhoneInfo" value="Cannot obtain phone info for your device" toBeTranslated="true" />
|
||||
<node name="noCellularNetwork" value="Cellular network is not available" toBeTranslated="true" />
|
||||
<node name="youAreInRoaming" value="Text message account refilling is not available because your phone is in roaming mode" toBeTranslated="true" />
|
||||
</node>
|
||||
<node name="userRegistration">
|
||||
<node name="title" value="Registrierter Benutzer" />
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<resources>
|
||||
<node name="smsDialog">
|
||||
<node name="title" value="Refill account via SMS" />
|
||||
<node name="title" value="Refill account via text message" />
|
||||
<node name="youPay" value="You pay %s" />
|
||||
<node name="noPhoneInfo" value="Cannot obtain phone info for your device" />
|
||||
<node name="noCellularNetwork" value="Cellular network is not available" />
|
||||
<node name="youAreInRoaming" value="Text message account refilling is not available because your phone is in roaming mode" />
|
||||
</node>
|
||||
<node name="userRegistration">
|
||||
<node name="title" value="Register User" />
|
||||
|
|
|
@ -5,10 +5,11 @@
|
|||
-->
|
||||
<resources>
|
||||
<node name="smsDialog">
|
||||
<node name="title" value="Refill account via SMS" toBeTranslated="true" />
|
||||
<node name="title" value="Refill account via text message" toBeTranslated="true" />
|
||||
<node name="youPay" value="You pay %s" toBeTranslated="true" />
|
||||
<node name="noPhoneInfo" value="Cannot obtain phone info for your device" toBeTranslated="true" />
|
||||
<node name="noCellularNetwork" value="Cellular network is not available" toBeTranslated="true" />
|
||||
<node name="youAreInRoaming" value="Text message account refilling is not available because your phone is in roaming mode" toBeTranslated="true" />
|
||||
</node>
|
||||
<node name="userRegistration">
|
||||
<node name="title" value="Inscription"/>
|
||||
|
|
|
@ -2,10 +2,11 @@
|
|||
<!-- Hungarian FBReaderJ resources, by L. B. Szabó. Based on FBReader translation by Sándor Gábor -->
|
||||
<resources>
|
||||
<node name="smsDialog">
|
||||
<node name="title" value="Refill account via SMS" toBeTranslated="true" />
|
||||
<node name="title" value="Refill account via text message" toBeTranslated="true" />
|
||||
<node name="youPay" value="You pay %s" toBeTranslated="true" />
|
||||
<node name="noPhoneInfo" value="Cannot obtain phone info for your device" toBeTranslated="true" />
|
||||
<node name="noCellularNetwork" value="Cellular network is not available" toBeTranslated="true" />
|
||||
<node name="youAreInRoaming" value="Text message account refilling is not available because your phone is in roaming mode" toBeTranslated="true" />
|
||||
</node>
|
||||
<node name="userRegistration">
|
||||
<node name="title" value="Felhasználó létrehozása" />
|
||||
|
|
|
@ -2,10 +2,11 @@
|
|||
<!-- Italian FBReaderJ resources, by Vytek and Neoxx from AndDev.it Translate Team -->
|
||||
<resources>
|
||||
<node name="smsDialog">
|
||||
<node name="title" value="Refill account via SMS" toBeTranslated="true" />
|
||||
<node name="title" value="Refill account via text message" toBeTranslated="true" />
|
||||
<node name="youPay" value="You pay %s" toBeTranslated="true" />
|
||||
<node name="noPhoneInfo" value="Cannot obtain phone info for your device" toBeTranslated="true" />
|
||||
<node name="noCellularNetwork" value="Cellular network is not available" toBeTranslated="true" />
|
||||
<node name="youAreInRoaming" value="Text message account refilling is not available because your phone is in roaming mode" toBeTranslated="true" />
|
||||
</node>
|
||||
<node name="userRegistration">
|
||||
<node name="title" value="Utente Registrato" />
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
<node name="youPay" value="Вы платите %s" />
|
||||
<node name="noPhoneInfo" value="Не удается получить информацию о телефоне" />
|
||||
<node name="noCellularNetwork" value="Сотовая сеть недоступна" />
|
||||
<node name="youAreInRoaming" value="Пополнение счета с помощью SMS невозможно, поскольку вы находитесь в роуминге" />
|
||||
</node>
|
||||
<node name="userRegistration">
|
||||
<node name="title" value="Новый пользователь" />
|
||||
|
|
|
@ -2,10 +2,11 @@
|
|||
<!-- Ukrainian FBReaderJ resources, by Dmytro Shevchenko -->
|
||||
<resources>
|
||||
<node name="smsDialog">
|
||||
<node name="title" value="Refill account via SMS" toBeTranslated="true" />
|
||||
<node name="title" value="Refill account via text message" toBeTranslated="true" />
|
||||
<node name="youPay" value="You pay %s" toBeTranslated="true" />
|
||||
<node name="noPhoneInfo" value="Cannot obtain phone info for your device" toBeTranslated="true" />
|
||||
<node name="noCellularNetwork" value="Cellular network is not available" toBeTranslated="true" />
|
||||
<node name="youAreInRoaming" value="Text message account refilling is not available because your phone is in roaming mode" toBeTranslated="true" />
|
||||
</node>
|
||||
<node name="userRegistration">
|
||||
<node name="title" value="Реєстрація нового користувача" />
|
||||
|
|
|
@ -2,10 +2,11 @@
|
|||
<!-- Vietnamese FBReaderJ resources, by Phạm Văn Hùng_Firestork -->
|
||||
<resources>
|
||||
<node name="smsDialog">
|
||||
<node name="title" value="Refill account via SMS" toBeTranslated="true" />
|
||||
<node name="title" value="Refill account via text message" toBeTranslated="true" />
|
||||
<node name="youPay" value="You pay %s" toBeTranslated="true" />
|
||||
<node name="noPhoneInfo" value="Cannot obtain phone info for your device" toBeTranslated="true" />
|
||||
<node name="noCellularNetwork" value="Cellular network is not available" toBeTranslated="true" />
|
||||
<node name="youAreInRoaming" value="Text message account refilling is not available because your phone is in roaming mode" toBeTranslated="true" />
|
||||
</node>
|
||||
<node name="userRegistration">
|
||||
<node name="title" value="Đăng ký" />
|
||||
|
|
|
@ -2,10 +2,11 @@
|
|||
<!-- Chinese FBReaderJ resources, by http://shucang.com/ -->
|
||||
<resources>
|
||||
<node name="smsDialog">
|
||||
<node name="title" value="Refill account via SMS" toBeTranslated="true" />
|
||||
<node name="title" value="Refill account via text message" toBeTranslated="true" />
|
||||
<node name="youPay" value="You pay %s" toBeTranslated="true" />
|
||||
<node name="noPhoneInfo" value="Cannot obtain phone info for your device" toBeTranslated="true" />
|
||||
<node name="noCellularNetwork" value="Cellular network is not available" toBeTranslated="true" />
|
||||
<node name="youAreInRoaming" value="Text message account refilling is not available because your phone is in roaming mode" toBeTranslated="true" />
|
||||
</node>
|
||||
<node name="userRegistration">
|
||||
<node name="title" value="注册用户" />
|
||||
|
|
|
@ -43,8 +43,8 @@ import org.geometerplus.zlibrary.core.xml.ZLStringMap;
|
|||
|
||||
public class SmsRefillingActivity extends Activity {
|
||||
private ZLResource myResource;
|
||||
private Button myOkButton;
|
||||
private SmsInfo mySelectedInfo;
|
||||
private String myUserId;
|
||||
|
||||
private Button findButton(int resourceId) {
|
||||
return (Button)findViewById(resourceId);
|
||||
|
@ -54,10 +54,9 @@ public class SmsRefillingActivity extends Activity {
|
|||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
|
||||
System.err.println("smsDialog");
|
||||
|
||||
ZLResourceFile.init(getApplicationContext());
|
||||
myResource = ZLResource.resource("smsDialog");
|
||||
myUserId = getIntent().getStringExtra("litres:userId");
|
||||
|
||||
setContentView(R.layout.sms_dialog);
|
||||
setTitle(myResource.getResource("title").getValue());
|
||||
|
@ -84,6 +83,7 @@ public class SmsRefillingActivity extends Activity {
|
|||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
// TODO: send SMS
|
||||
System.err.println("Sending message " + mySelectedInfo.Text + " to number " + mySelectedInfo.PhoneNumber);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
@ -117,6 +117,11 @@ public class SmsRefillingActivity extends Activity {
|
|||
}
|
||||
|
||||
private void setupListView() {
|
||||
if (myUserId == null || myUserId.length() == 0) {
|
||||
setError(myResource.getResource("noUserId").getValue());
|
||||
return;
|
||||
}
|
||||
|
||||
final TelephonyManager manager = (TelephonyManager)getSystemService(Activity.TELEPHONY_SERVICE);
|
||||
if (manager == null) {
|
||||
setError(myResource.getResource("noPhoneInfo").getValue());
|
||||
|
@ -129,9 +134,11 @@ public class SmsRefillingActivity extends Activity {
|
|||
return;
|
||||
}
|
||||
|
||||
// TODO: compare with SIM operator
|
||||
System.err.println(manager.getSimOperator());
|
||||
System.err.println(manager.getSimOperatorName());
|
||||
if (!operator.equals(manager.getSimOperator())) {
|
||||
setError(myResource.getResource("youAreInRoaming").getValue());
|
||||
return;
|
||||
}
|
||||
|
||||
String url = "http://data.fbreader.org/catalogs/litres/sms/smsinfo.php";
|
||||
url = ZLNetworkUtil.appendParameter(url, "mcc", operator.substring(0, 3));
|
||||
url = ZLNetworkUtil.appendParameter(url, "mnc", operator.substring(3));
|
||||
|
@ -215,6 +222,26 @@ public class SmsRefillingActivity extends Activity {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class SmsInfoXMLReader extends ZLXMLReaderAdapter {
|
||||
final ArrayList<SmsInfo> Infos = new ArrayList<SmsInfo>();
|
||||
String ErrorMessage;
|
||||
|
||||
@Override
|
||||
public boolean startElementHandler(String tag, ZLStringMap attributes) {
|
||||
if ("info".equals(tag)) {
|
||||
Infos.add(new SmsInfo(
|
||||
attributes.getValue("phone"),
|
||||
attributes.getValue("prefix") + " " + myUserId,
|
||||
attributes.getValue("sum"),
|
||||
attributes.getValue("cost")
|
||||
));
|
||||
} else if ("error".equals(tag)) {
|
||||
ErrorMessage = attributes.getValue("text");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SmsInfo {
|
||||
|
@ -230,25 +257,3 @@ class SmsInfo {
|
|||
Cost = cost;
|
||||
}
|
||||
}
|
||||
|
||||
class SmsInfoXMLReader extends ZLXMLReaderAdapter {
|
||||
private final String myUserId = "0001";
|
||||
|
||||
final ArrayList<SmsInfo> Infos = new ArrayList<SmsInfo>();
|
||||
String ErrorMessage;
|
||||
|
||||
@Override
|
||||
public boolean startElementHandler(String tag, ZLStringMap attributes) {
|
||||
if ("info".equals(tag)) {
|
||||
Infos.add(new SmsInfo(
|
||||
attributes.getValue("phoneNumber"),
|
||||
attributes.getValue("smsPrefix") + " " + myUserId,
|
||||
attributes.getValue("sum"),
|
||||
attributes.getValue("cost")
|
||||
));
|
||||
} else if ("error".equals(tag)) {
|
||||
ErrorMessage = attributes.getValue("text");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
package org.geometerplus.android.fbreader.network;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
|
@ -91,10 +93,17 @@ abstract class Util implements UserRegistrationConstants {
|
|||
|
||||
static void runSmsDialog(Activity activity, INetworkLink link) {
|
||||
try {
|
||||
activity.startActivity(new Intent(
|
||||
final Intent intent = new Intent(
|
||||
SMS_REFILLING_ACTION,
|
||||
Uri.parse(link.getLink(INetworkLink.URL_MAIN))
|
||||
));
|
||||
);
|
||||
final NetworkAuthenticationManager mgr = link.authenticationManager();
|
||||
if (mgr != null) {
|
||||
for (Map.Entry<String,String> entry : mgr.getSmsRefillingData().entrySet()) {
|
||||
intent.putExtra(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
activity.startActivity(intent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package org.geometerplus.fbreader.network.authentication;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.geometerplus.zlibrary.core.options.ZLStringOption;
|
||||
|
@ -30,7 +31,6 @@ import org.geometerplus.fbreader.network.authentication.litres.LitResAuthenticat
|
|||
|
||||
|
||||
public abstract class NetworkAuthenticationManager {
|
||||
|
||||
private static final HashMap<String, NetworkAuthenticationManager> ourManagers = new HashMap<String, NetworkAuthenticationManager>();
|
||||
|
||||
public static NetworkAuthenticationManager createManager(INetworkLink link, String sslCertificate, Class<? extends NetworkAuthenticationManager> managerClass) {
|
||||
|
@ -64,6 +64,7 @@ public abstract class NetworkAuthenticationManager {
|
|||
public abstract void authorise(String password) throws ZLNetworkException;
|
||||
public abstract void logOut();
|
||||
public abstract BookReference downloadReference(NetworkBookItem book);
|
||||
public abstract Map<String,String> getSmsRefillingData();
|
||||
|
||||
|
||||
public final boolean mayBeAuthorised(boolean useNetwork) {
|
||||
|
|
|
@ -408,4 +408,11 @@ public class LitResAuthenticationManager extends NetworkAuthenticationManager {
|
|||
final LitResPasswordRecoveryXMLReader xmlReader = new LitResPasswordRecoveryXMLReader(Link.getSiteName());
|
||||
ZLNetworkManager.Instance().perform(new LitResNetworkRequest(url, SSLCertificate, xmlReader));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,String> getSmsRefillingData() {
|
||||
final HashMap<String,String> map = new HashMap<String,String>();
|
||||
map.put("litres:userId", myUserIdOption.getValue());
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue