5
0
mirror of https://github.com/cwinfo/envayasms.git synced 2024-12-04 12:35:32 +00:00

use kalsms version code in http requests

This commit is contained in:
Jesse Young 2011-09-19 21:42:57 -07:00
parent 4b0010ffda
commit 687400f91a
3 changed files with 28 additions and 17 deletions

View File

@ -8,6 +8,8 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri;
import android.os.Bundle;
import android.os.SystemClock;
@ -23,7 +25,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.http.client.HttpClient;
import org.apache.http.conn.params.ConnManagerParams;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
@ -96,6 +97,8 @@ public final class App extends Application {
private SpannableStringBuilder displayedLog = new SpannableStringBuilder();
private long lastLogTime;
private PackageInfo packageInfo;
// list of package names (e.g. org.envaya.kalsms, or org.envaya.kalsms.packXX)
// for this package and all expansion packs
private List<String> outgoingMessagePackages = new ArrayList<String>();
@ -119,6 +122,17 @@ public final class App extends Application {
outgoingMessagePackages.add(getPackageName());
try
{
packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
}
catch (NameNotFoundException ex)
{
// should not happen
logError("Error finding package info", ex);
return;
}
updateExpansionPacks();
log(Html.fromHtml(
@ -136,7 +150,7 @@ public final class App extends Application {
{
log(" " + sender);
}
}
}
mmsObserver = new MmsObserver(this);
mmsObserver.register();
@ -150,6 +164,12 @@ public final class App extends Application {
startService(new Intent(this, ForegroundService.class));
}
public PackageInfo getPackageInfo()
{
return packageInfo;
}
public synchronized String chooseOutgoingSmsPackage()
{
outgoingMessageCount++;

View File

@ -53,7 +53,7 @@ public class HttpTask extends AsyncTask<String, Void, HttpResponse> {
this.app = app;
this.url = app.getServerUrl();
params = new ArrayList<BasicNameValuePair>(Arrays.asList(paramsArr));
params.add(new BasicNameValuePair("version", "2"));
params.add(new BasicNameValuePair("version", "" + app.getPackageInfo().versionCode));
params.add(new BasicNameValuePair("phone_number", app.getPhoneNumber()));
}

View File

@ -1,10 +1,10 @@
package org.envaya.kalsms.ui;
import android.app.Activity;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.text.Html;
import android.widget.TextView;
import org.envaya.kalsms.App;
import org.envaya.kalsms.R;
public class Help extends Activity {
@ -16,19 +16,10 @@ public class Help extends Activity {
setContentView(R.layout.help);
TextView help = (TextView) this.findViewById(R.id.help);
String version;
try
{
version = this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionName;
}
catch (NameNotFoundException ex)
{
version = "(Unknown version)";
}
String html = "<b>KalSMS " + version + "</b><br /><br />"
App app = (App)getApplication();
String html = "<b>KalSMS " + app.getPackageInfo().versionName + "</b><br /><br />"
+ "KalSMS is a SMS gateway.<br /><br /> "
+ "It forwards all incoming SMS messages received by this phone to a server on the internet, "
+ "and also sends outgoing SMS messages from that server to other phones.<br /><br />"