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

enable user to change wifi sleep policy on kalsms settings page for convenience

This commit is contained in:
Jesse Young 2011-09-19 10:19:34 -07:00
parent d720412061
commit 430aeca5e2
5 changed files with 76 additions and 23 deletions

View File

@ -14,6 +14,7 @@
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<application android:name="org.envaya.kalsms.App"
android:icon="@drawable/icon" android:label="@string/app_name">

24
README
View File

@ -1,24 +1,6 @@
KalSMS is an Android app that acts as a SMS and MMS gateway.
For more information, see http://youngj.github.com/KalSMS/
Features
--------
* Can be deployed almost anywhere in the world
* Designed to allow non-technical users to do all setup/maintenance
of deployed phones
* Can send outgoing SMS in excess of Android's limit of 100 messages
per app per hour by installing expansion packs
* Many different phones running KalSMS can be connected to a single server
(each phone could forward messages for a different mobile network)
* Authenticates with password shared between phone and server
* Retries forwarding messages after a delay if there is an error
(e.g. due to temporarily broken internet or GSM connection)
* Notifies the server of the status of outgoing messages
* Forwards incoming MMS messages (pictures/video/audio)
* Shows log messages to user to facilitate troubleshooting
* Can prevent incoming messages from being stored in Messaging inbox
* Can forward messages already received in Messaging inbox
License
-------
For more information and installation instructions,
see http://youngj.github.com/KalSMS/
The code is released under the MIT license; see LICENSE

View File

@ -24,4 +24,16 @@
<item>3600</item>
<item>0</item>
</string-array>
<string-array name="wifi_sleep_policies">
<item>disconnect when screen turns off</item>
<item>stay connected when plugged in</item>
<item>always stay connected</item>
</string-array>
<string-array name="wifi_sleep_policies_values">
<item>screen</item>
<item>plugged</item>
<item>never</item>
</string-array>
</resources>

View File

@ -18,7 +18,7 @@
<EditTextPreference
android:key="phone_number"
android:title="Your Phone Number"
android:title="Your phone number"
android:defaultValue=""
></EditTextPreference>
@ -43,4 +43,13 @@
android:summaryOn="Incoming SMS will be stored in Messaging inbox"
></CheckBoxPreference>
<ListPreference
android:key="wifi_sleep_policy"
android:title="Wi-Fi sleep policy"
android:defaultValue="never"
android:entries="@array/wifi_sleep_policies"
android:entryValues="@array/wifi_sleep_policies_values"
>
</ListPreference>
</PreferenceScreen>

View File

@ -8,6 +8,8 @@ import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceScreen;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
import android.view.Menu;
import org.envaya.kalsms.App;
import org.envaya.kalsms.R;
@ -50,6 +52,26 @@ public class Prefs extends PreferenceActivity implements OnSharedPreferenceChang
{
app.setOutgoingMessageAlarm();
}
else if (key.equals("wifi_sleep_policy"))
{
int value;
String valueStr = sharedPreferences.getString("wifi_sleep_policy", "screen");
if ("screen".equals(valueStr))
{
value = Settings.System.WIFI_SLEEP_POLICY_DEFAULT;
}
else if ("plugged".equals(valueStr))
{
value = Settings.System.WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED;
}
else
{
value = Settings.System.WIFI_SLEEP_POLICY_NEVER;
}
Settings.System.putInt(getContentResolver(),
Settings.System.WIFI_SLEEP_POLICY, value);
}
else if (key.equals("server_url"))
{
app.log("Server URL changed to: " + app.getDisplayString(app.getServerUrl()));
@ -73,7 +95,34 @@ public class Prefs extends PreferenceActivity implements OnSharedPreferenceChang
private void updatePrefSummary(Preference p)
{
if (p instanceof ListPreference) {
if ("wifi_sleep_policy".equals(p.getKey()))
{
int sleepPolicy;
try
{
sleepPolicy = Settings.System.getInt(this.getContentResolver(),
Settings.System.WIFI_SLEEP_POLICY);
}
catch (SettingNotFoundException ex)
{
sleepPolicy = Settings.System.WIFI_SLEEP_POLICY_DEFAULT;
}
switch (sleepPolicy)
{
case Settings.System.WIFI_SLEEP_POLICY_DEFAULT:
p.setSummary("Wi-Fi will disconnect when the phone sleeps");
break;
case Settings.System.WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED:
p.setSummary("Wi-Fi will disconnect when the phone sleeps unless it is plugged in");
break;
case Settings.System.WIFI_SLEEP_POLICY_NEVER:
p.setSummary("Wi-Fi will stay connected when the phone sleeps");
break;
}
}
else if (p instanceof ListPreference) {
p.setSummary(((ListPreference)p).getEntry());
}
else if (p instanceof EditTextPreference) {