Skip to content

Commit

Permalink
Move getLogFontSize to activity instead of service.
Browse files Browse the repository at this point in the history
It's GUI related anyway, and avoids a NullPointerException when the
service is not bound yet.
Bump to 0.9.10.
Fixes #24.
  • Loading branch information
Vilbrekin committed Sep 10, 2014
1 parent 3664313 commit d1a6681
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 25 deletions.
4 changes: 2 additions & 2 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
package="org.poirsouille.tinc_gui"
android:versionCode="10"
android:versionName="0.9.9" >
android:versionCode="11"
android:versionName="0.9.10" >

<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.ACCESS_SUPERUSER" />
Expand Down
17 changes: 16 additions & 1 deletion src/org/poirsouille/tinc_gui/TincActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
Expand Down Expand Up @@ -263,7 +264,7 @@ private void updateStatus()

private void updateLog(String iData)
{
_logTextView.setTextSize(_service.getLogFontSize());
_logTextView.setTextSize(getLogFontSize());

if (_service != null)
{
Expand Down Expand Up @@ -345,5 +346,19 @@ public void run()
}
});
}

/**
* Get font size for log window
* clamp it to a suitable range (8 -100)
* @return
*/
public Integer getLogFontSize()
{
int aLogFontSize = Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(this).getString("pref_key_font_size_log", "" + 8));

return Math.max(8, Math.min(100, aLogFontSize));
}


}

22 changes: 0 additions & 22 deletions src/org/poirsouille/tinc_gui/TincdService.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import android.os.Binder;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.sax.StartElementListener;
import android.util.Log;

public class TincdService extends Service implements ICallback
Expand All @@ -66,7 +65,6 @@ public class TincdService extends Service implements ICallback
private List<String> _tempOutput = Collections.synchronizedList(new LinkedList<String>());
SharedPreferences _sharedPref;
public int _maxLogSize = 1000;
public int _fontsizelog = 8;
private OnSharedPreferenceChangeListener _prefChangeListener;
private final ConnectivityroadcastReceiver _broadcastReceiver = new ConnectivityroadcastReceiver();
private boolean _reconnectOnNetChange = false;
Expand Down Expand Up @@ -419,7 +417,6 @@ private void refreshPrefs(String iKey)
Log.d(Tools.TAG, "Refreshing preferences for key " + iKey);
_configPath = _sharedPref.getString("pref_key_config_path", _configPath);
_maxLogSize = Integer.parseInt(_sharedPref.getString("pref_key_max_log_size", "" + _maxLogSize));
_fontsizelog = Integer.parseInt(_sharedPref.getString("pref_key_font_size_log", "" + _fontsizelog));
_debugLvl = Integer.parseInt(_sharedPref.getString("pref_key_debug_level", "" + _debugLvl));
_useSU = _sharedPref.getBoolean("pref_key_super_user", _useSU);
_reconnectOnNetChange = _sharedPref.getBoolean("pref_key_force_reconnect", _reconnectOnNetChange);
Expand Down Expand Up @@ -522,25 +519,6 @@ public String getStatus()
return aStatus;
}

/**
* Get font size for log window
* clamp it to a suitable range (8 -100)
* @return
*/
public Integer getLogFontSize()
{
if(_fontsizelog <= 8)
{
_fontsizelog = 8;
}
if(_fontsizelog >= 100)
{
_fontsizelog = 100;
}

return _fontsizelog;
}

/**
* Check if there's anything left in context or tincd is running.
* Otherwise stop the service.
Expand Down

0 comments on commit d1a6681

Please sign in to comment.