Subversion Repository Public Repository

litesoft

Diff Revisions 728 vs 729 for /trunk/GWT_Sandbox/MultiModuleSingleSrc/main/android/src/org/litesoft/droid/PhoneGapActivity.java

Diff revisions: vs.
  @@ -1,6 +1,7 @@
1 1 package org.litesoft.droid;
2 2
3 3 import org.apache.cordova.*;
4 + import android.content.res.AssetManager;
4 5 import android.os.Bundle;
5 6
6 7 public class PhoneGapActivity extends DroidGap
  @@ -12,6 +13,37 @@
12 13 public void onCreate( Bundle savedInstanceState )
13 14 {
14 15 super.onCreate( savedInstanceState );
15 - super.loadUrl( "file:///android_asset/www/index.html" );
16 +
17 + loadUrl( "file:///android_asset/www/" + findIndexHtml( getValue("language", "en") ) );
18 + }
19 +
20 + private String getValue( String key, String defaultValue )
21 + {
22 + return getSharedPreferences( getApplicationInfo().packageName, MODE_PRIVATE ).getString( key, defaultValue );
23 + }
24 +
25 + private String findIndexHtml( String language )
26 + {
27 + AssetManager assetManager = getAssets();
28 + try
29 + {
30 + String[] files = assetManager.list( "www" );
31 + if ( files != null )
32 + {
33 + String toFind = "index-" + language + ".html";
34 + for ( String file : files )
35 + {
36 + if ( toFind.equals( file ) )
37 + {
38 + return file;
39 + }
40 + }
41 + }
42 + }
43 + catch ( Exception e )
44 + {
45 + // Fall Thru
46 + }
47 + return "index.html";
16 48 }
17 - }
49 + }