Parse expiry date from website as well, added new screenshots

This commit is contained in:
moparisthebest 2013-03-06 21:26:42 -05:00
parent 5bea2330ab
commit b0134d4f13
11 changed files with 33 additions and 12 deletions

View File

@ -27,7 +27,8 @@ Android application icon © cluck's deSiGN studio [CC-BY-SA-3.0 (http://creative
Changelog
----------------------
0.5.2:
1. New icon custom made for this app by cluck's deSiGN studio and released under CC-BY-SA-3.0, thanks!
1. New icon custom made for this app by cluck's deSiGN studio and released under CC-BY-SA-3.0, thanks!
2. Parse balance expiry date from website as well.
0.5.1:
1. Page Plus requested I remove the app from the market because I am infringing on their IP, so this update changes the icon. New icon is © Nevit Dilmen [CC-BY-SA-3.0 or GFDL], via Wikimedia Commons
@ -88,4 +89,6 @@ Contributors
TODO:
----------------------
1. You suggest it, via a github issue or email!
1. Page plus sends dates in 3 different formats, '2013-06-21', 'June 21, 2013', and '6/21/2013',
perhaps parse those and display them in a single format?
2. You suggest it, via a github issue or email!

View File

@ -8,3 +8,4 @@ convert -background none -resize 48x48\! ./orig/owl.svg ../res/drawable-mdpi/i
# screen shots
convert -resize 480x854\! ./orig/ss1.png ss1.png
convert -resize 480x854\! ./orig/ss2.png ss2.png
convert -resize 480x854\! ./orig/ss3.png ss3.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 57 KiB

BIN
android/market/orig/ss3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 87 KiB

After

Width:  |  Height:  |  Size: 82 KiB

BIN
android/market/ss3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

View File

@ -7,6 +7,8 @@ import android.os.Bundle;
import android.telephony.SmsMessage;
import org.moparisthebest.pageplus.dto.Balance;
import static org.moparisthebest.pageplus.dto.Balance.regexStrip;
public class SMSReceiver extends BroadcastReceiver {
@Override
@ -29,15 +31,10 @@ public class SMSReceiver extends BroadcastReceiver {
// split string by newlines
final String[] msgLines = message.split("\n");
final Balance balance = new Balance();
final String regexStrip = "^[^:]*: ";
// get balance
balance.info[0] = String.format("%s (expires %s)",
msgLines[0].replaceFirst(regexStrip, ""),
msgLines[1].replaceFirst(regexStrip, ""));
balance.setBalance(msgLines[0], msgLines[1]);
// get plan
balance.info[1] = String.format("%s (expires %s)",
msgLines[2],
msgLines[3].replaceFirst(regexStrip, ""));
balance.setPlan(msgLines[2], msgLines[3]);
// get minutes
balance.info[2] = msgLines[4].replaceFirst(regexStrip, "");
// get text

View File

@ -3,8 +3,11 @@ package org.moparisthebest.pageplus.dto;
import java.util.Date;
public class Balance {
public static final String regexStrip = "^[^:]*: ";
private static final String[] names = new String[]{"Balance", "Plan", "Minutes", "SMS", "Data"};
private static String compactFormatDelim = "\n";
private static final String compactFormatDelim = "\n";
private static final String format = "%s (Expiring %s)";
public final String[] info = new String[names.length];
public String error = null;
@ -59,6 +62,20 @@ public class Balance {
return this;
}
public Balance setBalance(String balance, String date) {
this.info[0] = String.format(format,
balance == null ? "" : balance.replaceFirst(regexStrip, ""),
date == null ? "" : date.replaceFirst(regexStrip, ""));
return this;
}
public Balance setPlan(String plan, String date) {
this.info[1] = String.format(format,
plan == null ? "" : plan.replaceFirst(regexStrip, ""),
date == null ? "" : date.replaceFirst(regexStrip, ""));
return this;
}
public Balance setError(String error) {
this.error = error;
successDate = null;

View File

@ -104,14 +104,17 @@ public class PagePlusHTTP extends PPInfo {
}
//System.out.println("doc: " + doc.html());
int index = -1;
try {
ret.info[++index] = doc.select("span[id=ContentPlaceHolderDefault_mainContentArea_Item2_My Account Summary_5_Registred1_lblBalance]").first().text();
ret.setBalance(
doc.select("span[id=ContentPlaceHolderDefault_mainContentArea_Item2_My Account Summary_5_Registred1_lblBalance]").first().text(),
doc.select("span[id=ContentPlaceHolderDefault_mainContentArea_Item2_My Account Summary_5_Registred1_lblExpiryDate]").first().text()
);
} catch (Throwable e) {
//e.printStackTrace();
}
try {
final Element balance = doc.select("div[id=ContentPlaceHolderDefault_mainContentArea_Item2_My Account Summary_5_Registred1_divBundleDetails]").first();
int index = 0;
ret.info[++index] = balance.select("tr.tableHeading").first().text();
for (Element row : balance.select("tr.odd").first().select("td"))
ret.info[++index] = row.text();