diff --git a/README.md b/README.md index caf996c..c4221ef 100644 --- a/README.md +++ b/README.md @@ -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! diff --git a/android/market/convert.sh b/android/market/convert.sh index 40dd6c7..bbcb103 100755 --- a/android/market/convert.sh +++ b/android/market/convert.sh @@ -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 diff --git a/android/market/orig/ss1.png b/android/market/orig/ss1.png index 21d49cf..98f9223 100644 Binary files a/android/market/orig/ss1.png and b/android/market/orig/ss1.png differ diff --git a/android/market/orig/ss2.png b/android/market/orig/ss2.png index 2f622b7..100369b 100644 Binary files a/android/market/orig/ss2.png and b/android/market/orig/ss2.png differ diff --git a/android/market/orig/ss3.png b/android/market/orig/ss3.png new file mode 100644 index 0000000..9593cf4 Binary files /dev/null and b/android/market/orig/ss3.png differ diff --git a/android/market/ss1.png b/android/market/ss1.png index 08bdbf5..cabc68e 100644 Binary files a/android/market/ss1.png and b/android/market/ss1.png differ diff --git a/android/market/ss2.png b/android/market/ss2.png index a84b1a2..2e6be11 100644 Binary files a/android/market/ss2.png and b/android/market/ss2.png differ diff --git a/android/market/ss3.png b/android/market/ss3.png new file mode 100644 index 0000000..9adf77a Binary files /dev/null and b/android/market/ss3.png differ diff --git a/android/src/main/java/org/moparisthebest/pageplus/SMSReceiver.java b/android/src/main/java/org/moparisthebest/pageplus/SMSReceiver.java index 7680fbe..ebb8fe9 100644 --- a/android/src/main/java/org/moparisthebest/pageplus/SMSReceiver.java +++ b/android/src/main/java/org/moparisthebest/pageplus/SMSReceiver.java @@ -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 diff --git a/plugins/src/main/java/org/moparisthebest/pageplus/dto/Balance.java b/plugins/src/main/java/org/moparisthebest/pageplus/dto/Balance.java index 7754350..2368b57 100644 --- a/plugins/src/main/java/org/moparisthebest/pageplus/dto/Balance.java +++ b/plugins/src/main/java/org/moparisthebest/pageplus/dto/Balance.java @@ -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; diff --git a/plugins/src/main/java/org/moparisthebest/pageplus/plugins/PagePlusHTTP.java b/plugins/src/main/java/org/moparisthebest/pageplus/plugins/PagePlusHTTP.java index 475a8f3..9d44653 100755 --- a/plugins/src/main/java/org/moparisthebest/pageplus/plugins/PagePlusHTTP.java +++ b/plugins/src/main/java/org/moparisthebest/pageplus/plugins/PagePlusHTTP.java @@ -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();