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

SMS account refilling (in progress); updated TODO

This commit is contained in:
Nikolay Pultsin 2010-12-23 06:53:55 +00:00
parent 98470c95ae
commit 329a4eb0c1
16 changed files with 118 additions and 102 deletions

View file

@ -30,10 +30,35 @@ import org.geometerplus.fbreader.network.INetworkLink;
import org.geometerplus.fbreader.network.authentication.NetworkAuthenticationManager;
abstract class Util implements UserRegistrationConstants {
private static final String REGISTRATION_ACTION =
"android.fbreader.action.NETWORK_LIBRARY_REGISTER";
private static final String SMS_REFILLING_ACTION =
"android.fbreader.action.NETWORK_LIBRARY_SMS_REFILLING";
private static boolean testService(Activity activity, String action, String url) {
if (url == null) {
return false;
}
try {
activity.startActivity(new Intent(action + "_TEST", Uri.parse(url)));
return true;
} catch (ActivityNotFoundException e) {
return false;
}
}
static boolean isRegistrationSupported(Activity activity, INetworkLink link) {
return testService(
activity,
REGISTRATION_ACTION,
link.getLink(INetworkLink.URL_SIGN_UP)
);
}
static void runRegistrationDialog(Activity activity, INetworkLink link) {
try {
activity.startActivityForResult(new Intent(
"android.fbreader.action.NETWORK_LIBRARY_REGISTER",
REGISTRATION_ACTION,
Uri.parse(link.getLink(INetworkLink.URL_SIGN_UP))
), USER_REGISTRATION_REQUEST_CODE);
} catch (ActivityNotFoundException e) {
@ -53,4 +78,22 @@ abstract class Util implements UserRegistrationConstants {
}
}
}
static boolean isAccountRefillingSupported(Activity activity, INetworkLink link) {
return
isBrowserAccountRefillingSupported(activity, link) ||
isSmsAccountRefillingSupported(activity, link);
}
static boolean isSmsAccountRefillingSupported(Activity activity, INetworkLink link) {
return testService(
activity,
SMS_REFILLING_ACTION,
link.getLink(INetworkLink.URL_MAIN)
);
}
static boolean isBrowserAccountRefillingSupported(Activity activity, INetworkLink link) {
return link.getLink(INetworkLink.URL_REFILL_ACCOUNT) != null;
}
}