From ed375c069a397bd61eaa13ca880c0352c65d02bb Mon Sep 17 00:00:00 2001 From: julien lengrand-lambert Date: Sun, 9 Feb 2014 17:08:11 +0100 Subject: [PATCH] Removes some of the strange html characters --- ...-10-18-activate-numpad-on-startup.markdown | 4 +- ...opencv-rect-expects-four-integers.markdown | 4 +- ...-growing-implementation-in-python.markdown | 36 +++--- ...nittest-assertraises-raises-error.markdown | 28 ++--- ...le-way-to-get-a-multilingual-blog.markdown | 22 ++-- ...ay-to-watermark-a-batch-of-images.markdown | 2 +- _posts/2011-12-28-programming-tips-2.markdown | 52 ++++----- ...imply-print-current-function-name.markdown | 4 +- ...nction-given-its-name-as-a-string.markdown | 2 +- ...2-02-29-profiling-a-python-script.markdown | 2 +- ...5-17-easily-change-file-separator.markdown | 4 +- ...of-lines-of-code-of-your-projects.markdown | 4 +- ...6-11-remove-all-your-thumbs-files.markdown | 2 +- ...ery-first-python-script-docfinder.markdown | 2 +- ...hanged-is-never-called-on-android.markdown | 14 +-- ...eline-in-your-android-application.markdown | 47 ++++---- ...ug-with-long-xml-files-in-android.markdown | 108 +++++++++--------- 17 files changed, 169 insertions(+), 168 deletions(-) diff --git a/_posts/2011-10-18-activate-numpad-on-startup.markdown b/_posts/2011-10-18-activate-numpad-on-startup.markdown index 2b2fa6c..a89d230 100644 --- a/_posts/2011-10-18-activate-numpad-on-startup.markdown +++ b/_posts/2011-10-18-activate-numpad-on-startup.markdown @@ -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]
That's all !
diff --git a/_posts/2011-10-27-opencv-rect-expects-four-integers.markdown b/_posts/2011-10-27-opencv-rect-expects-four-integers.markdown index 6a61ecc..be2b3e8 100644 --- a/_posts/2011-10-27-opencv-rect-expects-four-integers.markdown +++ b/_posts/2011-10-27-opencv-rect-expects-four-integers.markdown @@ -29,7 +29,7 @@ Here is an example : import cv -img = cv.LoadImage("test.jpg") +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 "newfile.py", line 8, in <module> + File "newfile.py", line 8, in cv.SetImageROI(img, roi) TypeError: CvRect argument 'rect' expects four integers [/python] diff --git a/_posts/2011-11-28-simple-region-growing-implementation-in-python.markdown b/_posts/2011-11-28-simple-region-growing-implementation-in-python.markdown index 5a48c99..e3335ab 100644 --- a/_posts/2011-11-28-simple-region-growing-implementation-in-python.markdown +++ b/_posts/2011-11-28-simple-region-growing-implementation-in-python.markdown @@ -208,38 +208,38 @@ import cv import numpy def simple_region_growing(img, seed, threshold=1): - """ + """ 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. - """ + """ try: dims = cv.GetSize(img) except TypeError: - raise TypeError("(%s) img : IplImage expected!" % (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("(%s) 8U image expected!" % (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("(%s) 1C image expected!" % (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("(%s) Int expected!" % (sys._getframe().f_code.co_name)) - elif threshold < 0: - raise ValueError("(%s) Positive value expected!" % (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("(%s) (x, y) variable expected!" % (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] ) < 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)) + 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<threshold and size<pix_area): + while(disttemp_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 = "tippy/data/gnu.jpg" +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="S") # 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, "Region Growing result") +do.display_single_image(out_img, "Region Growing result") [/python] As you can see, the implementation is rather short in code. diff --git a/_posts/2011-12-02-pythonunittest-assertraises-raises-error.markdown b/_posts/2011-12-02-pythonunittest-assertraises-raises-error.markdown index 40c2145..2995ff8 100644 --- a/_posts/2011-12-02-pythonunittest-assertraises-raises-error.markdown +++ b/_posts/2011-12-02-pythonunittest-assertraises-raises-error.markdown @@ -56,13 +56,13 @@ Let's say I want to create a (dum) function calculating the square value of a [python] def square_value(a): - """ + """ Returns the square value of a. - """ + """ try: out = a*a except TypeError: - raise TypeError("Input should be a string:") + 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): - """ + """ The class inherits from unittest - """ + """ def setUp(self): - """ + """ This method is called before each test - """ - self.false_int = "A" + """ + self.false_int = "A" def tearDown(self): - """ + """ This method is called after each test - """ + """ 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__ == "__main__": +if __name__ == "__main__": unittest.main() [/python]
    @@ -104,10 +104,10 @@ if __name__ == "__main__": ERROR: test_square_value (__main__.Test) ---------------------------------------------------------------------- Traceback (most recent call last): - File "test_dum_function.py", 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 "/home/jlengrand/Desktop/function.py", line 8, in square_value - raise TypeError("Input should be a string:") + File "/home/jlengrand/Desktop/function.py", line 8, in square_value + raise TypeError("Input should be a string:") TypeError: Input should be a string: ---------------------------------------------------------------------- diff --git a/_posts/2011-12-12-a-simple-way-to-get-a-multilingual-blog.markdown b/_posts/2011-12-12-a-simple-way-to-get-a-multilingual-blog.markdown index 18d8870..93db05a 100644 --- a/_posts/2011-12-12-a-simple-way-to-get-a-multilingual-blog.markdown +++ b/_posts/2011-12-12-a-simple-way-to-get-a-multilingual-blog.markdown @@ -64,8 +64,8 @@ To do this, you need two things :
[javascript] -<!-- Script créé par KevBrok ;-) --> -<script type="text/javascript">// <![CDATA[ + + [/javascript]
@@ -140,14 +140,14 @@ To do this, you need two things :
  • Then, Write down your article in both languages, 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 :
  • [javascript] -<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> +Français / English +
    +
    My article in english
    +
    +
    +
    Mon article en français
    +
    +
     [/javascript]
     
     
    diff --git a/_posts/2011-12-20-a-simple-way-to-watermark-a-batch-of-images.markdown b/_posts/2011-12-20-a-simple-way-to-watermark-a-batch-of-images.markdown index 67e4603..35d027c 100644 --- a/_posts/2011-12-20-a-simple-way-to-watermark-a-batch-of-images.markdown +++ b/_posts/2011-12-20-a-simple-way-to-watermark-a-batch-of-images.markdown @@ -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 "jardin des plantes" in Nantes"]picture of the "jardin des plantes" in Nantes[/caption] +[caption id="attachment_424" align="aligncenter" width="200" caption="picture of the "jardin des plantes" in Nantes"]picture of the [/caption] This script is in an early stage for now, and should be upgraded with time. You can check out the TODO list here.  diff --git a/_posts/2011-12-28-programming-tips-2.markdown b/_posts/2011-12-28-programming-tips-2.markdown index 867ed1a..362297b 100644 --- a/_posts/2011-12-28-programming-tips-2.markdown +++ b/_posts/2011-12-28-programming-tips-2.markdown @@ -135,7 +135,7 @@ The command to search for is start-stop-daemon, with start opti To avoid any output in stdout, use redirection: [bash] -$ command &> /dev/null& +$ command &> /dev/null& [/bash]
    @@ -166,7 +166,7 @@ Simply add the line [bash] -trap " 2 3 +trap " 2 3 [/bash] @@ -188,7 +188,7 @@ The operations can be performed with bc : [bash] -$ VAR=$(echo "2.2/ 10.65" | bc -l) +$ VAR=$(echo "2.2/ 10.65" | bc -l) [/bash] @@ -206,7 +206,7 @@ $ (ceil) INT=${VAR/.*} [bash] -$ "find ./ -name .svn -prune -o -type f -print | xargs grep -Hi" //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 = "my_one_line_command" +alias_name = "my_one_line_command" [/bash] @@ -251,7 +251,7 @@ Restart your terminal, you're done! [bash] -$ date -d "$FIRST_TIME" +"%s" +$ date -d "$FIRST_TIME" +"%s" [/bash] @@ -261,7 +261,7 @@ $ date -d "$FIRST_TIME" +"%s" [bash] -$ which //language// > my_script +$ which //language// > my_script [/bash] @@ -269,7 +269,7 @@ $ which //language// > my_script [bash] -$ which bash > my_script.sh +$ which bash > my_script.sh [/bash] @@ -291,7 +291,7 @@ $ file -i //unkown_file_type// $ cd //my_folder/// -$ find -name ".svn" -exec rm -rf {} \; +$ find -name ".svn" -exec rm -rf {} \; [/bash] @@ -407,7 +407,7 @@ in your .bashrc. It can be done simply in running the followin [bash] -$ echo "complete -cf sudo" > ~/.bashrc +$ echo "complete -cf sudo" > ~/.bashrc [/bash] @@ -533,7 +533,7 @@ file.open(file_name, 'a') try: print variable except NameError: - print "Error!" + print "Error!" [/python]
    @@ -563,9 +563,9 @@ a = b = c = 1+1 import sys def tutut(): - """ + """ Dum function displaying its name! - """ + """ print sys._getframe().f_code.co_name if __name__ == '__main__': @@ -613,13 +613,13 @@ with About variables :
      -
    • age -> value
    • -
    • &age -> pointer
    • +
    • age -> value
    • +
    • &age -> pointer
    About pointers :
      -
    • ptr -> ptr value(which is an address)
    • -
    • *ptr -> variable value placed in the address.
    • +
    • ptr -> ptr value(which is an address)
    • +
    • *ptr -> variable value placed in the address.
     If age is a variable :
      @@ -645,7 +645,7 @@ int age = 10; Those two are equivalent (used for structures):
        -
      • a->b
      • +
      • a->b
      • *(a.b)
      @@ -796,7 +796,7 @@ Memos and Tips about the Insert an horizontal line in a post : -Simply insert the <hr/> tag while in html edition mode . +Simply insert the
      tag
      while in html edition mode .
      @@ -998,7 +998,7 @@ This is done in two different steps :
      • Define the anchor. You should place the following code where you want the user to be redirected.
      -[html]your article <a name= "name_of_the_anchor"></a> here.[/html] +[html]your article
      here.[/html]
        @@ -1006,11 +1006,11 @@ This is done in two different steps :
      If the anchor is placed in the same page :
      -[html]<a href= »#name_of_the_anchor »>my highlighted text</a>[/html] +[html]my highlighted text[/html]
      If the anchor is in another page :
      -[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]my highlighted text +my highlighted text [/html] You can see the result everywhere on this page, in the topic listing :). diff --git a/_posts/2011-12-28-simply-print-current-function-name.markdown b/_posts/2011-12-28-simply-print-current-function-name.markdown index 4b65c7f..0b4751f 100644 --- a/_posts/2011-12-28-simply-print-current-function-name.markdown +++ b/_posts/2011-12-28-simply-print-current-function-name.markdown @@ -30,9 +30,9 @@ Here is how to print your function name as a string in Python : import sys def tutut(): - """ + """ Dum function displaying its name! - """ + """ print sys._getframe().f_code.co_name if __name__ == '__main__': diff --git a/_posts/2012-02-16-execute-a-function-given-its-name-as-a-string.markdown b/_posts/2012-02-16-execute-a-function-given-its-name-as-a-string.markdown index 727773b..8623f3d 100644 --- a/_posts/2012-02-16-execute-a-function-given-its-name-as-a-string.markdown +++ b/_posts/2012-02-16-execute-a-function-given-its-name-as-a-string.markdown @@ -35,7 +35,7 @@ Problem solved in 3 simple lines of code : [php] -post_func = loadstring("param = printf(\"Hello ! \")") +post_func = loadstring("param = printf(\"Hello ! \")") post_func() appli_repo = os.execute(param) diff --git a/_posts/2012-02-29-profiling-a-python-script.markdown b/_posts/2012-02-29-profiling-a-python-script.markdown index dea4f38..2a7b502 100644 --- a/_posts/2012-02-29-profiling-a-python-script.markdown +++ b/_posts/2012-02-29-profiling-a-python-script.markdown @@ -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("function()", "from __main__ import function") +t1 = timeit.Timer("function()", "from __main__ import function") print t1.timeit(1) [/python] diff --git a/_posts/2012-05-17-easily-change-file-separator.markdown b/_posts/2012-05-17-easily-change-file-separator.markdown index 70cf408..d53a149 100644 --- a/_posts/2012-05-17-easily-change-file-separator.markdown +++ b/_posts/2012-05-17-easily-change-file-separator.markdown @@ -30,7 +30,7 @@ Simply open a console and run this line [bash] -sed -e $"s/,/\ /g" myfile > newfile +sed -e $"s/,/\ /g" myfile > newfile [/bash] @@ -38,7 +38,7 @@ or more generally, [bash] -sed -e $"s/old_separator/new_separator/g" myfile > newfile +sed -e $"s/old_separator/new_separator/g" myfile > newfile [/bash] diff --git a/_posts/2012-05-22-count-the-number-of-lines-of-code-of-your-projects.markdown b/_posts/2012-05-22-count-the-number-of-lines-of-code-of-your-projects.markdown index ad1da27..bf72cc1 100644 --- a/_posts/2012-05-22-count-the-number-of-lines-of-code-of-your-projects.markdown +++ b/_posts/2012-05-22-count-the-number-of-lines-of-code-of-your-projects.markdown @@ -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 "*.py"` | 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 "*.py" | xargs wc -l +find . -name "*.py" | xargs wc -l [/bash] diff --git a/_posts/2012-06-11-remove-all-your-thumbs-files.markdown b/_posts/2012-06-11-remove-all-your-thumbs-files.markdown index e18d925..c26b3b8 100644 --- a/_posts/2012-06-11-remove-all-your-thumbs-files.markdown +++ b/_posts/2012-06-11-remove-all-your-thumbs-files.markdown @@ -33,7 +33,7 @@ So here is the magic solution to get rid of those parasites : [bash] -$ sudo find any_folder -name "Thumbs.db" -exec rm {} \; +$ sudo find any_folder -name "Thumbs.db" -exec rm {} \; [/bash] diff --git a/_posts/2012-06-17-my-very-first-python-script-docfinder.markdown b/_posts/2012-06-17-my-very-first-python-script-docfinder.markdown index 1586b6d..a73e296 100644 --- a/_posts/2012-06-17-my-very-first-python-script-docfinder.markdown +++ b/_posts/2012-06-17-my-very-first-python-script-docfinder.markdown @@ -48,7 +48,7 @@ import os import sys def scan_rep(repertoir, extension): - """scanne le rep courant pour trouver des tex""" + """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): diff --git a/_posts/2013-10-26-onlocationchanged-is-never-called-on-android.markdown b/_posts/2013-10-26-onlocationchanged-is-never-called-on-android.markdown index c9785d8..bff196a 100644 --- a/_posts/2013-10-26-onlocationchanged-is-never-called-on-android.markdown +++ b/_posts/2013-10-26-onlocationchanged-is-never-called-on-android.markdown @@ -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 = "DisplayGPSInfoActivity"; +private static final String TAG = "DisplayGPSInfoActivity"; private ViewFlipper vf; private LocationManager locationManager; private String provider; -@SuppressLint("NewApi") +@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, "GPS LocationChanged"); +Log.d(TAG, "GPS LocationChanged"); double lat = location.getLatitude(); double lng = location.getLongitude(); -Log.d(TAG, "Received GPS request for " + String.valueOf(lat) + "," + String.valueOf(lng) + " , ready to rumble!"); +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] -<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, "Resuming"); +Log.v(TAG, "Resuming"); locationManager.requestLocationUpdates(provider, 400, 1, this); } diff --git a/_posts/2013-10-30-integrate-a-twitter-timeline-in-your-android-application.markdown b/_posts/2013-10-30-integrate-a-twitter-timeline-in-your-android-application.markdown index 9d80645..76002ec 100644 --- a/_posts/2013-10-30-integrate-a-twitter-timeline-in-your-android-application.markdown +++ b/_posts/2013-10-30-integrate-a-twitter-timeline-in-your-android-application.markdown @@ -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] -<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> -[/html] +{% highlight html %} + + + +{% 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 = "TimeLineActivity"; + public static final String TAG = "TimeLineActivity"; - private static final String baseURl = "https://twitter.com"; + private static final String baseURl = "https://twitter.com"; - 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>"; + private static final String widgetInfo = "Tweets about \"#BresTram\" " + + ""; @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, "text/html", "UTF-8", 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] -<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" > + - <WebView - android:id="@+id/timeline_webview" - android:layout_width="fill_parent" - android:layout_height="fill_parent"/> + -</RelativeLayout> + [/xml] I used fill_parent because I wanted to give as much space as possible to the Webview. diff --git a/_posts/2014-01-29-strange-bug-with-long-xml-files-in-android.markdown b/_posts/2014-01-29-strange-bug-with-long-xml-files-in-android.markdown index f9f1f0c..eee06f8 100644 --- a/_posts/2014-01-29-strange-bug-with-long-xml-files-in-android.markdown +++ b/_posts/2014-01-29-strange-bug-with-long-xml-files-in-android.markdown @@ -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 %} -<?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: + + + + -<!-- Template is : --> + -<!-- -<array name="update0"> -<item>update title</item> -<item>update message</item> -</array> ---> + -<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 + + +"Mise à jour du site Bibus" + + +"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." -</item> -</string-array> +Merci d'avance, et désolé pour le dérangement." + + . . . -<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> + + + +"Mise à jour du 27 Janvier" + + +"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!" + + + +"BresTram was updated to version 1.5" + + +"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!" + + -<!-- Array containing a reference to all the messages --> -<array name="updates"> -<item>@array/update0</item> + + +@array/update0 . . . -<item>@array/update12</item> -</array> -</resources> +@array/update12 + + -[/xml] +{% endhighlight %} Basically, my update mechanism rely on two different things :
        @@ -115,7 +115,7 @@ The updater compares the value of the latest update 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. My 11th update wouldn't show up. Instead, it was the 8th being displayed!