Removes some of the strange html characters

This commit is contained in:
julien lengrand-lambert
2014-02-09 17:08:11 +01:00
parent f9d26db223
commit ed375c069a
17 changed files with 169 additions and 168 deletions

View File

@@ -82,8 +82,8 @@ To run on startup, this module had to be added to the list of apps to be started
On my Openbox based Crunchbang, the solution was to edit my autostart.sh to add a new line :
[bash]
$ echo "(sleep 5s && numlock) &" \
>> ~/.config/openbox/autostart.sh
$ echo "(sleep 5s && numlock) &" \
>> ~/.config/openbox/autostart.sh
[/bash]
<div>That's all !</div>

View File

@@ -29,7 +29,7 @@ Here is an example :
import cv
img = cv.LoadImage(&quot;test.jpg&quot;)
img = cv.LoadImage("test.jpg")
dims = cv.GetSize(img)
roi = [0, 0, dims[0] / 2, dims[1] / 2 ]
cv.SetImageROI(img, roi)
@@ -39,7 +39,7 @@ You will get this result:
[python]
Traceback (most recent call last):
File &quot;newfile.py&quot;, line 8, in &lt;module&gt;
File "newfile.py", line 8, in <module>
cv.SetImageROI(img, roi)
TypeError: CvRect argument 'rect' expects four integers
[/python]

View File

@@ -208,38 +208,38 @@ import cv
import numpy
def simple_region_growing(img, seed, threshold=1):
&quot;&quot;&quot;
"""
A (very) simple implementation of region growing.
Extracts a region of the input image depending on a start position and a stop condition.
The input should be a single channel 8 bits image and the seed a pixel position (x, y).
The threshold corresponds to the difference between outside pixel intensity and mean intensity of region.
In case no new pixel is found, the growing stops.
Outputs a single channel 8 bits binary (0 or 255) image. Extracted region is highlighted in white.
&quot;&quot;&quot;
"""
try:
dims = cv.GetSize(img)
except TypeError:
raise TypeError(&quot;(%s) img : IplImage expected!&quot; % (sys._getframe().f_code.co_name))
raise TypeError("(%s) img : IplImage expected!" % (sys._getframe().f_code.co_name))
# img test
if not(img.depth == cv.IPL_DEPTH_8U):
raise TypeError(&quot;(%s) 8U image expected!&quot; % (sys._getframe().f_code.co_name))
raise TypeError("(%s) 8U image expected!" % (sys._getframe().f_code.co_name))
elif not(img.nChannels is 1):
raise TypeError(&quot;(%s) 1C image expected!&quot; % (sys._getframe().f_code.co_name))
raise TypeError("(%s) 1C image expected!" % (sys._getframe().f_code.co_name))
# threshold tests
if (not isinstance(threshold, int)) :
raise TypeError(&quot;(%s) Int expected!&quot; % (sys._getframe().f_code.co_name))
elif threshold &lt; 0:
raise ValueError(&quot;(%s) Positive value expected!&quot; % (sys._getframe().f_code.co_name))
raise TypeError("(%s) Int expected!" % (sys._getframe().f_code.co_name))
elif threshold < 0:
raise ValueError("(%s) Positive value expected!" % (sys._getframe().f_code.co_name))
# seed tests
if not((isinstance(seed, tuple)) and (len(seed) is 2) ) :
raise TypeError(&quot;(%s) (x, y) variable expected!&quot; % (sys._getframe().f_code.co_name))
raise TypeError("(%s) (x, y) variable expected!" % (sys._getframe().f_code.co_name))
if (seed[0] or seed[1] ) &lt; 0 :
raise ValueError(&quot;(%s) Seed should have positive values!&quot; % (sys._getframe().f_code.co_name))
elif ((seed[0] &gt; dims[0]) or (seed[1] &gt; dims[1])):
raise ValueError(&quot;(%s) Seed values greater than img size!&quot; % (sys._getframe().f_code.co_name))
if (seed[0] or seed[1] ) < 0 :
raise ValueError("(%s) Seed should have positive values!" % (sys._getframe().f_code.co_name))
elif ((seed[0] > dims[0]) or (seed[1] > dims[1])):
raise ValueError("(%s) Seed values greater than img size!" % (sys._getframe().f_code.co_name))
reg = cv.CreateImage( dims, cv.IPL_DEPTH_8U, 1)
cv.Zero(reg)
@@ -257,14 +257,14 @@ def simple_region_growing(img, seed, threshold=1):
cur_pix = [seed[0], seed[1]]
#Spreading
while(dist&lt;threshold and size&lt;pix_area):
while(dist<threshold and size<pix_area):
#adding pixels
for j in range(4):
#select new candidate
temp_pix = [cur_pix[0] +orient[j][0], cur_pix[1] +orient[j][1]]
#check if it belongs to the image
is_in_img = dims[0]&gt;temp_pix[0]&gt;0 and dims[1]&gt;temp_pix[1]&gt;0 #returns boolean
is_in_img = dims[0]>temp_pix[0]>0 and dims[1]>temp_pix[1]>0 #returns boolean
#candidate is taken if not already selected before
if (is_in_img and (reg[temp_pix[1], temp_pix[0]]==0)):
contour.append(temp_pix)
@@ -303,18 +303,18 @@ import tippy.display_operations as do
user_input = 0
img_name = &quot;tippy/data/gnu.jpg&quot;
img_name = "tippy/data/gnu.jpg"
threshold = 20
img = cv.LoadImage(img_name, cv.CV_LOAD_IMAGE_GRAYSCALE)
if user_input:
seed = bo.mouse_point(img, mode=&quot;S&quot;) # waits for user click to get seed
seed = bo.mouse_point(img, mode="S") # waits for user click to get seed
else:
seed = (70, 106)
out_img = se.simple_region_growing(img, seed, threshold)
do.display_single_image(out_img, &quot;Region Growing result&quot;)
do.display_single_image(out_img, "Region Growing result")
[/python]
As you can see, the implementation is rather short in code.

View File

@@ -56,13 +56,13 @@ Let's say I want to create a (dum) function calculating the square value of a
</ul>
[python]
def square_value(a):
&quot;&quot;&quot;
"""
Returns the square value of a.
&quot;&quot;&quot;
"""
try:
out = a*a
except TypeError:
raise TypeError(&quot;Input should be a string:&quot;)
raise TypeError("Input should be a string:")
return out
[/python]
@@ -73,19 +73,19 @@ def square_value(a):
import dum_function as df # import function module
import unittest
class Test(unittest.TestCase):
&quot;&quot;&quot;
"""
The class inherits from unittest
&quot;&quot;&quot;
"""
def setUp(self):
&quot;&quot;&quot;
"""
This method is called before each test
&quot;&quot;&quot;
self.false_int = &quot;A&quot;
"""
self.false_int = "A"
def tearDown(self):
&quot;&quot;&quot;
"""
This method is called after each test
&quot;&quot;&quot;
"""
pass
#---
## TESTS
@@ -93,7 +93,7 @@ class Test(unittest.TestCase):
# assertRaises(excClass, callableObj) prototype
self.assertRaises(TypeError, df.square_value(self.false_int))
if __name__ == &quot;__main__&quot;:
if __name__ == "__main__":
unittest.main()
[/python]
<ul>
@@ -104,10 +104,10 @@ if __name__ == &quot;__main__&quot;:
ERROR: test_square_value (__main__.Test)
----------------------------------------------------------------------
Traceback (most recent call last):
File &quot;test_dum_function.py&quot;, line 22, in test_square_value
File "test_dum_function.py", line 22, in test_square_value
self.assertRaises(TypeError, df.square_value(self.false_int))
File &quot;/home/jlengrand/Desktop/function.py&quot;, line 8, in square_value
raise TypeError(&quot;Input should be a string:&quot;)
File "/home/jlengrand/Desktop/function.py", line 8, in square_value
raise TypeError("Input should be a string:")
TypeError: Input should be a string:
----------------------------------------------------------------------

View File

@@ -64,8 +64,8 @@ To do this, you need two things :
</ul>
<div>[javascript]
&lt;!-- Script créé par KevBrok ;-) --&gt;
&lt;script type=&quot;text/javascript&quot;&gt;// &lt;![CDATA[
<!-- Script créé par KevBrok ;-) -->
<script type="text/javascript">// <![CDATA[
/*
* Montre / Cache un div
*/
@@ -132,7 +132,7 @@ To do this, you need two things :
}
}
}
// ]]&gt;&lt;/script&gt;
// ]]></script>
[/javascript]
</div>
@@ -140,14 +140,14 @@ To do this, you need two things :
<li>Then, <strong>Write down your article in both languages</strong>, one after the other in you editor. Each language should be placed in a separate div; and a button placed to switch from one language to the other. Here is an example :</li>
</ul>
<div>[javascript]
&lt;a href=&quot;javascript:InverseTout( 'mondiv' )&quot;&gt;Français / English&lt;/a&gt;&lt;/pre&gt;
&lt;div id=&quot;mondiv1&quot; class=&quot;cachediv&quot;&gt;
&lt;div style=&quot;border: 1px solid black; background-color: whitesmoke; margin-bottom: 2px;&quot;&gt;My article in english&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&quot;mondiv2&quot;&gt;
&lt;div style=&quot;border: 1px solid black; background-color: whitesmoke; margin-bottom: 2px;&quot;&gt;Mon article en français&lt;/div&gt;
&lt;/div&gt;
&lt;pre&gt;
<a href="javascript:InverseTout( 'mondiv' )">Français / English</a></pre>
<div id="mondiv1" class="cachediv">
<div style="border: 1px solid black; background-color: whitesmoke; margin-bottom: 2px;">My article in english</div>
</div>
<div id="mondiv2">
<div style="border: 1px solid black; background-color: whitesmoke; margin-bottom: 2px;">Mon article en français</div>
</div>
<pre>
[/javascript]
</div>

View File

@@ -43,7 +43,7 @@ As a bonus, the script automatically detects whether an image is in landscape or
Here is an example of the result :
[caption id="attachment_424" align="aligncenter" width="200" caption="picture of the &quot;jardin des plantes&quot; in Nantes"]<a href="http://www.lengrand.fr/wp-content/uploads/2011/12/pourquoi_le_bitume__by_jlengrand-d4dp4ha.jpg"><img class="size-medium wp-image-424" title="Pourquoi le bitume?" src="http://www.lengrand.fr/wp-content/uploads/2011/12/pourquoi_le_bitume__by_jlengrand-d4dp4ha-200x300.jpg" alt="picture of the &quot;jardin des plantes&quot; in Nantes" width="200" height="300" /></a>[/caption]
[caption id="attachment_424" align="aligncenter" width="200" caption="picture of the "jardin des plantes" in Nantes"]<a href="http://www.lengrand.fr/wp-content/uploads/2011/12/pourquoi_le_bitume__by_jlengrand-d4dp4ha.jpg"><img class="size-medium wp-image-424" title="Pourquoi le bitume?" src="http://www.lengrand.fr/wp-content/uploads/2011/12/pourquoi_le_bitume__by_jlengrand-d4dp4ha-200x300.jpg" alt="picture of the "jardin des plantes" in Nantes" width="200" height="300" /></a>[/caption]
This script is in an early stage for now, and should be upgraded with time. You can check out the <strong><a title="TODO list" href="https://github.com/jlengrand/batchWaterMarking">TODO list here. </a></strong>

View File

@@ -135,7 +135,7 @@ The command to search for is<strong> start-stop-daemon</strong>, with start opti
To avoid any output in stdout, use redirection:
[bash]
$ command &amp;&gt; /dev/null&amp;
$ command &amp;> /dev/null&amp;
[/bash]
<hr />
@@ -166,7 +166,7 @@ Simply add the line
[bash]
trap &quot; 2 3
trap " 2 3
[/bash]
@@ -188,7 +188,7 @@ The operations can be performed with bc :
[bash]
$ VAR=$(echo &quot;2.2/ 10.65&quot; | bc -l)
$ VAR=$(echo "2.2/ 10.65" | bc -l)
[/bash]
@@ -206,7 +206,7 @@ $ (ceil) INT=${VAR/.*}
[bash]
$ &quot;find ./ -name .svn -prune -o -type f -print | xargs grep -Hi&quot; //pattern//
$ "find ./ -name .svn -prune -o -type f -print | xargs grep -Hi" //pattern//
[/bash]
@@ -239,7 +239,7 @@ Simply add a new line at the end of the file :
[bash]
alias_name = &quot;my_one_line_command&quot;
alias_name = "my_one_line_command"
[/bash]
@@ -251,7 +251,7 @@ Restart your terminal, you're done!
[bash]
$ date -d &quot;$FIRST_TIME&quot; +&quot;%s&quot;
$ date -d "$FIRST_TIME" +"%s"
[/bash]
@@ -261,7 +261,7 @@ $ date -d &quot;$FIRST_TIME&quot; +&quot;%s&quot;
[bash]
$ which //language// &gt; my_script
$ which //language// > my_script
[/bash]
@@ -269,7 +269,7 @@ $ which //language// &gt; my_script
[bash]
$ which bash &gt; my_script.sh
$ which bash > my_script.sh
[/bash]
@@ -291,7 +291,7 @@ $ file -i //unkown_file_type//
$ cd //my_folder///
$ find -name &quot;.svn&quot; -exec rm -rf {} \;
$ find -name ".svn" -exec rm -rf {} \;
[/bash]
@@ -407,7 +407,7 @@ in your <strong>.bashrc. </strong>It can be done simply in running the followin
[bash]
$ echo &quot;complete -cf sudo&quot; &gt; ~/.bashrc
$ echo "complete -cf sudo" > ~/.bashrc
[/bash]
@@ -533,7 +533,7 @@ file.open(file_name, 'a')
try:
print variable
except NameError:
print &quot;Error!&quot;
print "Error!"
[/python]
<hr />
@@ -563,9 +563,9 @@ a = b = c = 1+1
import sys
def tutut():
&quot;&quot;&quot;
"""
Dum function displaying its name!
&quot;&quot;&quot;
"""
print sys._getframe().f_code.co_name
if __name__ == '__main__':
@@ -613,13 +613,13 @@ with
<span style="text-decoration: underline;">About variables</span> :
<ul>
<li>age -&gt; value</li>
<li>&amp;age -&gt; pointer</li>
<li>age -> value</li>
<li>&amp;age -> pointer</li>
</ul>
<span style="text-decoration: underline;">About pointers</span> :
<ul>
<li>ptr -&gt; ptr value(which is an address)</li>
<li>*ptr -&gt; variable value placed in the address.</li>
<li>ptr -> ptr value(which is an address)</li>
<li>*ptr -> variable value placed in the address.</li>
</ul>
<span style="text-decoration: underline;"> If <strong><em>age</em></strong> is a variable</span> :
<ul>
@@ -645,7 +645,7 @@ int age = 10;
<span style="color: #ff9900;">Those two are equivalent (used for structures):</span>
<ul>
<li>a-&gt;b</li>
<li>a->b</li>
<li>*(a.b)</li>
</ul>
@@ -796,7 +796,7 @@ Memos and Tips about the <strong><a title="External link to http://opencv.willow
Can be used to naviguate through pixels easily (and more efficiently than some openCV functions).
[c]
char *pImage = iplImage-&gt;ImageData
char *pImage = iplImage->ImageData
[/c]
<hr />
@@ -876,7 +876,7 @@ It should solve the problem.
</ul>
[bash]
$ svn cp trunk -&gt; new_branch
$ svn cp trunk -> new_branch
[/bash]
@@ -958,7 +958,7 @@ $ sudo apt-get install gprof
</ul>
[bash]
$ gprof your_binary gmon.out &gt;&gt; saved_report
$ gprof your_binary gmon.out >> saved_report
$ vim saved_report
@@ -988,7 +988,7 @@ Some very simple tips and hints for wordpress.
<span style="color: #ff9900;">Insert an horizontal line in a post :</span>
Simply insert the <strong>&lt;hr/&gt; tag</strong> while in <strong>html</strong> edition mode .
Simply insert the <strong><hr/> tag</strong> while in <strong>html</strong> edition mode .
<hr />
@@ -998,7 +998,7 @@ This is done in two different steps :
<ul>
<li><strong>Define the anchor</strong>. You should place the following code where you want the user to be redirected.</li>
</ul>
[html]your article &lt;a name= &quot;name_of_the_anchor&quot;&gt;&lt;/a&gt; here.[/html]
[html]your article <a name= "name_of_the_anchor"></a> here.[/html]
<ul>
@@ -1006,11 +1006,11 @@ This is done in two different steps :
</ul>
<div><span style="text-decoration: underline;">If the anchor is placed in the same page :</span></div>
[html]&lt;a href= »#name_of_the_anchor »&gt;my highlighted text&lt;/a&gt;[/html]
[html]<a href= »#name_of_the_anchor »>my highlighted text</a>[/html]
<div><span style="text-decoration: underline;">If the anchor is in another page :</span></div>
[html]&lt;a href= »http://www.website.fr/#name_of_the_anchor »&gt;my highlighted text&lt;/a&gt;
&lt;a href= »#name_of_the_anchor »&gt;my highlighted text&lt;/a&gt;
[html]<a href= »http://www.website.fr/#name_of_the_anchor »>my highlighted text</a>
<a href= »#name_of_the_anchor »>my highlighted text</a>
[/html]
<strong>You can see the result everywhere on this page, in the topic listing :).</strong>

View File

@@ -30,9 +30,9 @@ Here is how to <strong>print your function name as a string</strong> in Python :
import sys
def tutut():
&quot;&quot;&quot;
"""
Dum function displaying its name!
&quot;&quot;&quot;
"""
print sys._getframe().f_code.co_name
if __name__ == '__main__':

View File

@@ -35,7 +35,7 @@ Problem solved in 3 simple lines of code :
[php]
post_func = loadstring(&quot;param = printf(\&quot;Hello ! \&quot;)&quot;)
post_func = loadstring("param = printf(\"Hello ! \")")
post_func()
appli_repo = os.execute(param)

View File

@@ -48,7 +48,7 @@ If you want to avoid using a command line, or you don't have the profile module
[python]
import timeit
t1 = timeit.Timer(&quot;function()&quot;, &quot;from __main__ import function&quot;)
t1 = timeit.Timer("function()", "from __main__ import function")
print t1.timeit(1)
[/python]

View File

@@ -30,7 +30,7 @@ Simply open a console and run this line
[bash]
sed -e $&quot;s/,/\ /g&quot; myfile &gt; newfile
sed -e $"s/,/\ /g" myfile > newfile
[/bash]
@@ -38,7 +38,7 @@ or more generally,
[bash]
sed -e $&quot;s/old_separator/new_separator/g&quot; myfile &gt; newfile
sed -e $"s/old_separator/new_separator/g" myfile > newfile
[/bash]

View File

@@ -26,7 +26,7 @@ I found this simple command that will pop out the number of lines of code for a
[bash]
cat `find . -name &quot;*.py&quot;` | wc -l
cat `find . -name "*.py"` | wc -l
[/bash]
@@ -34,6 +34,6 @@ You can also do it for a whole folder
[bash]
find . -name &quot;*.py&quot; | xargs wc -l
find . -name "*.py" | xargs wc -l
[/bash]

View File

@@ -33,7 +33,7 @@ So here is the magic solution to get rid of those parasites :
[bash]
$ sudo find any_folder -name &quot;Thumbs.db&quot; -exec rm {} \;
$ sudo find any_folder -name "Thumbs.db" -exec rm {} \;
[/bash]

View File

@@ -48,7 +48,7 @@ import os
import sys
def scan_rep(repertoir, extension):
&quot;&quot;&quot;scanne le rep courant pour trouver des tex&quot;&quot;&quot;
"""scanne le rep courant pour trouver des tex"""
for racine, reps, fichiers in os.walk(repertoir, topdown=True):
for fichier in fichiers:
if fichier.endswith('.%s' % extension):

View File

@@ -53,14 +53,14 @@ Here is what my Activity would look like :
[java]
public class DisplayGPSInfoActivity extends BaseActivity implements LocationListener {
private static final String TAG = &quot;DisplayGPSInfoActivity&quot;;
private static final String TAG = "DisplayGPSInfoActivity";
private ViewFlipper vf;
private LocationManager locationManager;
private String provider;
@SuppressLint(&quot;NewApi&quot;)
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -82,10 +82,10 @@ Location location = locationManager.getLastKnownLocation(provider);
@Override
public void onLocationChanged(Location location) {
Log.d(TAG, &quot;GPS LocationChanged&quot;);
Log.d(TAG, "GPS LocationChanged");
double lat = location.getLatitude();
double lng = location.getLongitude();
Log.d(TAG, &quot;Received GPS request for &quot; + String.valueOf(lat) + &quot;,&quot; + String.valueOf(lng) + &quot; , ready to rumble!&quot;);
Log.d(TAG, "Received GPS request for " + String.valueOf(lat) + "," + String.valueOf(lng) + " , ready to rumble!");
// Do clever stuff here
}
@@ -102,8 +102,8 @@ Problem is, it is not. never. Ever. . .
After having verified hundred times that I had
[xml]
&lt;uses-permission android:name=&quot;android.permission.ACCESS_COARSE_LOCATION&quot; /&gt;
&lt;uses-permission android:name=&quot;android.permission.ACCESS_FINE_LOCATION&quot; /&gt;
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
[/xml]
@@ -117,7 +117,7 @@ Something like that would do the job :
@Override
protected void onResume() {
super.onResume();
Log.v(TAG, &quot;Resuming&quot;);
Log.v(TAG, "Resuming");
locationManager.requestLocationUpdates(provider, 400, 1, this);
}

View File

@@ -36,10 +36,11 @@ I started by creating a dedicated filter on the twitter account of BresTram.
This gives me two lines of code to integrate into the website of my choice :
[html]
&lt;a class=&quot;twitter-timeline&quot; href=&quot;https://twitter.com/search?q=%23BresTram&quot; data-widget-id=&quot;394415351972114432&quot;&gt;Tweets about &quot;#BresTram&quot;&lt;/a&gt;
&lt;script&gt;!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+&quot;://platform.twitter.com/widgets.js&quot;;fjs.parentNode.insertBefore(js,fjs);}}(document,&quot;script&quot;,&quot;twitter-wjs&quot;);&lt;/script&gt;
[/html]
{% highlight html %}
<a class="twitter-timeline" href="https://twitter.com/search?q=%23BresTram" data-widget-id="394415351972114432">Tweets about "#BresTram"</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
{% endhighlight %}
Then, I simply created a new Activity in my Application, that contains a webview.
@@ -51,12 +52,12 @@ import android.os.Bundle;
import android.webkit.WebView;
public class TimeLineActivity extends BaseActivity {
public static final String TAG = &quot;TimeLineActivity&quot;;
public static final String TAG = "TimeLineActivity";
private static final String baseURl = &quot;https://twitter.com&quot;;
private static final String baseURl = "https://twitter.com";
private static final String widgetInfo = &quot;&lt;a class=\&quot;twitter-timeline\&quot; href=\&quot;https://twitter.com/search?q=%23BresTram\&quot; data-widget-id=\&quot;394415351972114432\&quot;&gt;Tweets about \&quot;#BresTram\&quot;&lt;/a&gt; &quot; +
&quot;&lt;script&gt;!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+\&quot;://platform.twitter.com/widgets.js\&quot;;fjs.parentNode.insertBefore(js,fjs);}}(document,\&quot;script\&quot;,\&quot;twitter-wjs\&quot;);&lt;/script&gt;&quot;;
private static final String widgetInfo = "<a class=\"twitter-timeline\" href=\"https://twitter.com/search?q=%23BresTram\" data-widget-id=\"394415351972114432\">Tweets about \"#BresTram\"</a> " +
"<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+\"://platform.twitter.com/widgets.js\";fjs.parentNode.insertBefore(js,fjs);}}(document,\"script\",\"twitter-wjs\");</script>";
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -69,7 +70,7 @@ public class TimeLineActivity extends BaseActivity {
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadDataWithBaseURL(baseURl, widgetInfo, &quot;text/html&quot;, &quot;UTF-8&quot;, null);
webView.loadDataWithBaseURL(baseURl, widgetInfo, "text/html", "UTF-8", null);
}
/**
@@ -91,22 +92,22 @@ The background color method is needed to avoid the ugly white background behind
And here is the layout file :
[xml]
&lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
xmlns:tools=&quot;http://schemas.android.com/tools&quot;
android:layout_width=&quot;match_parent&quot;
android:layout_height=&quot;match_parent&quot;
android:paddingBottom=&quot;@dimen/activity_vertical_margin&quot;
android:paddingLeft=&quot;@dimen/activity_horizontal_margin&quot;
android:paddingRight=&quot;@dimen/activity_horizontal_margin&quot;
android:paddingTop=&quot;@dimen/activity_vertical_margin&quot;
tools:context=&quot;.TimeLineActivity&quot; &gt;
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".TimeLineActivity" >
&lt;WebView
android:id=&quot;@+id/timeline_webview&quot;
android:layout_width=&quot;fill_parent&quot;
android:layout_height=&quot;fill_parent&quot;/&gt;
<WebView
android:id="@+id/timeline_webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
&lt;/RelativeLayout&gt;
</RelativeLayout>
[/xml]
I used fill_parent because I wanted to give as much space as possible to the Webview.

View File

@@ -32,73 +32,73 @@ I decided to go for XML, for all the reasons above, and also because android sup
Here is how my update file would look like :
[xml]
{% highlight xml %}
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;resources&gt;
&lt;!-- This file contains all the update messages displayed to the user--&gt;
&lt;!-- To create a new update message:
<?xml version="1.0" encoding="utf-8">
<resources>
<!-- This file contains all the update messages displayed to the user-->
<!-- To create a new update message:
- Create a new update array, with a incremented update number
- Add a reference to this new array in the updates array
--&gt;
-->
&lt;!-- Template is : --&gt;
<!-- Template is : -->
&lt;!--
&lt;array name=&quot;update0&quot;&gt;
&lt;item&gt;update title&lt;/item&gt;
&lt;item&gt;update message&lt;/item&gt;
&lt;/array&gt;
--&gt;
<!--
<array name="update0">
<item>update title</item>
<item>update message</item>
</array>
-->
&lt;string-array name=&quot;update0&quot;&gt;
&lt;item&gt;
&quot;Mise à jour du site Bibus&quot;
&lt;/item&gt;
&lt;item&gt;
&quot;Bibus a récemment changé son protocole de communication pour les horaires temps réel.\n
<string-array name="update0">
<item>
"Mise à jour du site Bibus"
</item>
<item>
"Bibus a récemment changé son protocole de communication pour les horaires temps réel.\n
Il est donc en ce moment impossible pour BresTram de fonctionner correctement.\n
(Merci Lucas de m'avoir prévenu!)\n
Ceci est totalement indépendant de BresTram, et je fais mon possible pour corriger ceci au plus vite!\n
En attendant, si vous trouvez l'application utile, aidez-moi en votant sur le play store!\n
Merci d'avance, et désolé pour le dérangement.&quot;
&lt;/item&gt;
&lt;/string-array&gt;
Merci d'avance, et désolé pour le dérangement."
</item>
</string-array>
. . .
&lt;array name=&quot;update12&quot;&gt;
&lt;!-- French --&gt;
&lt;item&gt;
&quot;Mise à jour du 27 Janvier&quot;
&lt;/item&gt;
&lt;item&gt;
&quot;BresTram vient d'être mis à jour.\n\n&quot;
&quot;Un nouvel onglet a été ajouté pour vous permettre de faire des recherches par ligne de bus.\n&quot;
&quot;Il vous est maintenant possible de voir la liste de toutes les lignes possibles dans l'onglet lignes.\n\n&quot;
&quot;Cette nouvelle fonctionnalité est pour le moment encore en beta, il est donc possible que vous rencontriez des bugs.&quot;
&quot;Faites moi part de vos remarques sur le play store où sur le Twitter de l'application!&quot;
&lt;/item&gt;
&lt;!-- English --&gt;
&lt;item&gt;
&quot;BresTram was updated to version 1.5&quot;
&lt;/item&gt;
&lt;item&gt;
&quot;BresTram has been updated to the latest version.\n\n&quot;
&quot;A new tab has been added, that lists all bus lines and their associated bus stops.\n&quot;
&quot;This functionality is currently still in beta, and you might find bugs.\n\n&quot;
&quot;Let me know your suggestions on the playstore or the twitter of the application!&quot;
&lt;/item&gt;
&lt;/array&gt;
<array name="update12">
<!-- French -->
<item>
"Mise à jour du 27 Janvier"
</item>
<item>
"BresTram vient d'être mis à jour.\n\n"
"Un nouvel onglet a été ajouté pour vous permettre de faire des recherches par ligne de bus.\n"
"Il vous est maintenant possible de voir la liste de toutes les lignes possibles dans l'onglet lignes.\n\n"
"Cette nouvelle fonctionnalité est pour le moment encore en beta, il est donc possible que vous rencontriez des bugs."
"Faites moi part de vos remarques sur le play store où sur le Twitter de l'application!"
</item>
<!-- English -->
<item>
"BresTram was updated to version 1.5"
</item>
<item>
"BresTram has been updated to the latest version.\n\n"
"A new tab has been added, that lists all bus lines and their associated bus stops.\n"
"This functionality is currently still in beta, and you might find bugs.\n\n"
"Let me know your suggestions on the playstore or the twitter of the application!"
</item>
</array>
&lt;!-- Array containing a reference to all the messages --&gt;
&lt;array name=&quot;updates&quot;&gt;
&lt;item&gt;@array/update0&lt;/item&gt;
<!-- Array containing a reference to all the messages -->
<array name="updates">
<item>@array/update0</item>
. . .
&lt;item&gt;@array/update12&lt;/item&gt;
&lt;/array&gt;
&lt;/resources&gt;
<item>@array/update12</item>
</array>
</resources>
[/xml]
{% endhighlight %}
Basically, my update mechanism rely on two different things :
<ul>
@@ -115,7 +115,7 @@ The updater <strong>compares the value of the latest update</strong> <strong>wit
But basically, the java code of interest can be summarized in the few following lines :
[java]
{% highlight java %}
private Resources res;
// gets a reference to the array of updates
res = ctx.getResources();
@@ -130,7 +130,7 @@ But basically, the java code of interest can be summarized in the few following
public int getLatestVersion(){
return update_messages.length();
}
[/java]
{% endhighlight %}
But for some strange reason, things started acted weird last month. <strong>My 11th update wouldn't show up. Instead, it was the 8th being displayed!</strong>