android:layout_weight="3"
android:textColor="#ff000000"
android:textSize="24sp"
- android:text="location"
+ android:text="@string/location"
/>
<View
android:layout_width="match_parent"
android:layout_weight="3"
android:textColor="#ff000000"
android:textSize="24sp"
- android:text="phonecall"
+ android:text="@string/phonecall"
/>
<View
android:layout_width="match_parent"
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">WhereAmI</string>
+ <string name="location">Местоположение</string>
+ <string name="phonecall">Телефонный разговор</string>
<string name="updating">Обновление...</string>
<string name="failure">Неудача</string>
<string name="lasttry">Последнее обновление</string>
<string name="settings">Конфигурация</string>
<string name="fullscreentitle">Полный экран</string>
<string name="fullscreensummary">Полный экран или с индикаторами</string>
+ <string name="managewifititle">Управление WiFi</string>
+ <string name="managewifisummary">Отключать WiFi между обновлениями</string>
<string name="updatetitle">Периодичность обновления</string>
<string name="updatesummary">Как часто обновлять информацию</string>
<string-array name="month">
-<PreferenceScreen
- xmlns:android="http://schemas.android.com/apk/res/android">
+<?xml version="1.0" encoding="utf-8"?>
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference
android:key="fullscreen"
android:title="@string/fullscreentitle"
android:summary="@string/fullscreensummary"
android:defaultValue="false"
/>
+ <CheckBoxPreference
+ android:key="managewifi"
+ android:title="@string/managewifititle"
+ android:summary="@string/managewifisummary"
+ android:defaultValue="false"
+ />
<ListPreference
android:key="updateperiod"
android:title="@string/updatetitle"
public class WhereAmI extends Activity
{
private WifiManager wifiman;
+ private Boolean managewifi = false;
private Long updatedelay = 60000L;
private Integer runningtasks = 0;
private SharedPreferences prefs;
private Runnable updateInfo = new Runnable () {
public void run() {
Log.w("WhereAmI", "updateInfo starting");
- IntentFilter intentFilter =
- new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE");
- registerReceiver(connChanged,intentFilter);
- connChangedRegistered = true;
- boolean wifion = wifiman.setWifiEnabled(true);
- Log.w("WhereAmI", "enabling wifi result " + wifion);
+ if (managewifi) {
+ IntentFilter intentFilter =
+ new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE");
+ registerReceiver(connChanged,intentFilter);
+ connChangedRegistered = true;
+ boolean wifion = wifiman.setWifiEnabled(true);
+ Log.w("WhereAmI", "enabling wifi result " + wifion);
+ } else {
+ for (int i = 0; i < ut.length; i++) {
+ runningtasks++;
+ ut[i].launch();
+ }
+ }
mHandler.postDelayed(resetInfo, updatedelay);
mHandler.postDelayed(this, 60000);
}
tvs.setText(R.string.failtry);
tvs.append(tm.format(" %d/%m/%Y %H:%M:%S"));
}
- boolean wifion = wifiman.setWifiEnabled(false);
- Log.w("WhereAmI", "disabling wifi result " + wifion);
+ if (managewifi) {
+ boolean wifion = wifiman.setWifiEnabled(false);
+ Log.w("WhereAmI", "disabling wifi result " + wifion);
+ }
}
};
super.onResume();
prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean fullscreen = prefs.getBoolean("fullscreen", false);
+ managewifi = prefs.getBoolean("managewifi", false);
updatedelay = Long.parseLong(prefs.getString("updateperiod", "1200000"));
if (fullscreen) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);