Przeglądaj źródła

release ver 1

03/01 2014
Ray Zhang 12 lat temu
rodzic
commit
877a79bd6b

+ 8 - 2
Apex/AndroidManifest.xml

@@ -2,7 +2,7 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.usai.apex"
     android:versionCode="1"
-    android:versionName="A140228" >
+    android:versionName="A140301" >
 
     <!-- Copied from Google Maps Library/AndroidManifest.xml. -->
     <uses-sdk
@@ -31,7 +31,10 @@
         android:theme="@android:style/Theme.Holo.Light" >
         <meta-data
             android:name="com.google.android.maps.v2.API_KEY"
-            android:value="AIzaSyARPN7VaYqWGe1PsgGqp1QlhOoTdiwTqq0" />
+            android:value="AIzaSyDdbk58Lx6QzaXcB_hNpSHVp3l_CJeNpoo" />
+<!--debug key         <meta-data
+            android:name="com.google.android.maps.v2.API_KEY"
+            android:value="AIzaSyARPN7VaYqWGe1PsgGqp1QlhOoTdiwTqq0" /> -->
         <meta-data
             android:name="com.google.android.gms.version"
             android:value="@integer/google_play_services_version" />
@@ -122,15 +125,18 @@
         </activity>
         <activity
             android:name="com.usai.apex.RetrievePasswordActivity"
+            android:screenOrientation="portrait"
             android:label="@string/title_activity_retrieve_password" >
         </activity>
         <activity
             android:name="com.usai.apex.ChangePasswordActivity"
             android:label="Change Password"
+            android:screenOrientation="portrait"
             android:windowSoftInputMode="adjustResize|stateVisible" >
         </activity>
         <activity
             android:name="com.usai.apex.AboutActivity"
+            android:screenOrientation="portrait"
             android:label="@string/title_activity_about" 
             >
         </activity>

+ 10 - 0
Apex/proguard-project.txt

@@ -23,3 +23,13 @@
 
 -dontwarn android.support.v4.** 
 -dontwarn com.google.android.gms.** 
+
+
+# Remove all Verbose/Debug logging
+-optimizations code/removal/simple,code/removal/advanced
+-dontobfuscate
+-assumenosideeffects class android.util.Log {
+    public static *** d(...);
+    public static *** v(...);
+    public static *** i(...);
+}

+ 2 - 1
Apex/project.properties

@@ -8,7 +8,8 @@
 # project structure.
 #
 # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
-proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+proguard.config=${sdk.dir}/tools/proguard/proguard-android-optimize.txt:proguard-project.txt
 
 # Project target.
 target=android-14

+ 1 - 1
Apex/res/layout/detail_fragment.xml

@@ -23,7 +23,7 @@
                 android:layout_width="fill_parent"
                 android:layout_height="wrap_content"
                 android:gravity="center_horizontal"
-                android:text="No content in this page"
+                android:text="No record in this page"
                 android:textAppearance="?android:attr/textAppearanceMedium"
                 android:visibility="gone" />
 

+ 2 - 0
Apex/res/layout/keymapping_item.xml

@@ -12,6 +12,7 @@
         android:gravity="center_vertical"
         android:layout_weight="1" 
         android:textStyle="bold"
+        android:textColor="#FF000000"
         android:background="@drawable/detail_item"/>
 
     <TextView
@@ -21,6 +22,7 @@
         android:gravity="center_vertical"
         android:text="Value" 
         android:layout_weight="1"
+        android:textColor="#FF000000"
         android:background="@drawable/detail_item"/>
 
 </LinearLayout>

+ 1 - 0
Apex/res/layout/list_item.xml

@@ -10,6 +10,7 @@
         android:layout_alignParentLeft="true"
         android:layout_alignParentTop="true"
         android:text="TextView" 
+        android:textColor="#FF000000"
         android:background="@drawable/detail_item"/>
 
 </RelativeLayout>

+ 1 - 0
Apex/res/values/strings.xml

@@ -11,6 +11,7 @@
     <string name="hello_world">Hello world!</string>
     <string name="msg_net_resulterror">An error occur on server</string>
     <string name="msg_net_error">Can not connect to server</string>
+    <string name="msg_ver_low">Client version is too low</string>
     <string name="msg_connection_none">No available connection </string>
     <string name="title_activity_apex">Apex Mobile</string>
     <string name="title_activity_direct_tracking">DirectTracking</string>

+ 1 - 1
Apex/src/com/usai/apex/AboutActivity.java

@@ -27,7 +27,7 @@ public class AboutActivity extends Activity
 	@Override
 	protected void onCreate(Bundle savedInstanceState)
 	{
-		Log.e("AboutActivity", "onCreate");
+		Log.d("AboutActivity", "onCreate");
 
 		super.onCreate(savedInstanceState);
 		setContentView(R.layout.activity_about);

+ 1 - 1
Apex/src/com/usai/apex/ApexActivity.java

@@ -40,7 +40,7 @@ public class ApexActivity extends FragmentActivity /*
 
 	@Override
 	protected void onCreate(Bundle savedInstanceState) {
-		Log.e("ApexActivity", "onCreate");
+		Log.d("ApexActivity", "onCreate");
 		super.onCreate(savedInstanceState);
 		setContentView(R.layout.activity_apex);
 		ActionBar bar = getActionBar();

+ 3 - 3
Apex/src/com/usai/apex/DetailActivity.java

@@ -46,7 +46,7 @@ public class DetailActivity extends FragmentActivity implements
 	@Override
 	protected void onCreate(Bundle savedInstanceState)
 	{
-		Log.e("DetailActivity", "onCreate");
+		Log.d("DetailActivity", "onCreate");
 
 		super.onCreate(savedInstanceState);
 
@@ -55,7 +55,7 @@ public class DetailActivity extends FragmentActivity implements
 		List<Fragment> fragments = getSupportFragmentManager().getFragments();
 		if (fragments != null)
 		{
-			Log.e("DetailActivity", "fragments count=" + fragments.size());
+			Log.d("DetailActivity", "fragments count=" + fragments.size());
 //			for (int i = 0; i < fragments.size(); i++)
 //				Log.e("DetailFragment", "fragment name="
 //						+ fragments.get(i).getTag());
@@ -158,7 +158,7 @@ public class DetailActivity extends FragmentActivity implements
 		f = getSupportFragmentManager().findFragmentById(tabmap.get(tag));
 		if (f == null)
 		{
-			Log.e("createTabContent", "create fragment" + tag);
+			Log.d("createTabContent", "create fragment" + tag);
 			f = new DetailFragment();
 
 			

+ 1 - 1
Apex/src/com/usai/apex/DetailFragment.java

@@ -470,7 +470,7 @@ public class DetailFragment extends Fragment implements OnClickListener /*
 
 		@Override
 		protected Boolean doInBackground(Void... params) {
-			Log.e("SearchTask", "doInBackground");
+			Log.d("SearchTask", "doInBackground");
 			if (!Network.NetworkIsAvailable())
 
 			{

+ 9 - 0
Apex/src/com/usai/apex/LoginFragment.java

@@ -379,6 +379,15 @@ public class LoginFragment extends Fragment/* implements OnClickListener */
 					toast.show();
 					return;
 				}
+				case Network.RESULT_VER_LOW:
+				{
+					Toast toast = Toast.makeText(getActivity()
+							.getApplicationContext(),
+							getText(R.string.msg_ver_low), Toast.LENGTH_LONG);
+					toast.setGravity(Gravity.CENTER, 0, 0);
+					toast.show();
+					return;
+				}
 				case Network.RESULT_ERROR:
 				// case Network.RESULT_RESPONSE_NULL:
 				{

+ 295 - 223
Apex/src/com/usai/apex/ResultActivity.java

@@ -50,24 +50,25 @@ import android.widget.TableRow;
 import android.widget.TextView;
 import android.widget.Toast;
 
-public class ResultActivity extends Activity {
-	String user = null;
-	String password = null;
-	String function_name = null;
-	private SearchTask m_task = null;
+public class ResultActivity extends Activity
+{
+	String				user			= null;
+	String				password		= null;
+	String				function_name	= null;
+	private SearchTask	m_task			= null;
 
-	int sel = -1;
+	int					sel				= -1;
 
-	Bundle searchParms = null;
-	SearchResult searchresult = new SearchResult();
+	Bundle				searchParms		= null;
+	SearchResult		searchresult	= new SearchResult();
 
-	SparseArray<String> showfieldmap = new SparseArray<String>();
+	SparseArray<String>	showfieldmap	= new SparseArray<String>();
 	// HashMap<Integer, String> showfieldmap = new HashMap<Integer, String>();
-	private TextView mStatusMessageView;
+	private TextView	mStatusMessageView;
 	// private View mSearchFormView;
-	private View footview;
-	private View mStatusView;
-	int actioncount=0;
+	private View		footview;
+	private View		mStatusView;
+	int					actioncount		= 0;
 
 	// private class resultAdapter extends SimpleAdapter
 	// {
@@ -75,49 +76,54 @@ public class ResultActivity extends Activity {
 	//
 	// }
 	@Override
-	protected void onCreate(Bundle savedInstanceState) {
+	protected void onCreate(Bundle savedInstanceState)
+	{
 		user = ApexTrackingApplication.get_user();
 		password = ApexTrackingApplication.get_pass();
 		function_name = getIntent().getStringExtra("function_name");
-		if(function_name.equals("Ocean Booking"))
+		if (function_name.equals("Ocean Booking"))
 			setTitle("Booking Result");
-		else if(function_name.equals("Ocean B/L info."))
+		else if (function_name.equals("Ocean B/L info."))
 			setTitle("B/L info. Result");
-		else if(function_name.equals("Container detail"))
+		else if (function_name.equals("Container detail"))
 			setTitle("Container Result");
-		else if(function_name.equals("Download Document"))
+		else if (function_name.equals("Download Document"))
 			setTitle("Document Result");
-		
+
 		searchParms = getIntent().getBundleExtra("searchParms");
 		super.onCreate(savedInstanceState);
 		setContentView(R.layout.activity_result);
-		
+
 		SQLiteDatabase db = dbUtil.OpenDB(ResultActivity.this, null, false);
-		Cursor cursor = db.query("actions_info",
-				new String[] { "count(*)" }, "function_name='"
-						+ function_name + "' and user='" + user + "'",
-				null, null, null, "priority", null);
-		if (cursor.moveToNext()) {
+		Cursor cursor = db
+				.query("actions_info", new String[] { "count(*)" },
+						"function_name='" + function_name + "' and user='"
+								+ user + "'", null, null, null, "priority",
+						null);
+		if (cursor.moveToNext())
+		{
 			actioncount = cursor.getInt(0);
 		}
 
 		dbUtil.CloseCursor(cursor);
 		dbUtil.CloseDB(db);
-				
-		
+
 		footview = findViewById(R.id.foot);
 		// mSearchFormView = findViewById(R.id.search_form);
 		Button btnnext = (Button) findViewById(R.id.btn_next);
-		btnnext.setOnClickListener(new View.OnClickListener() {
+		btnnext.setOnClickListener(new View.OnClickListener()
+		{
 
 			@Override
-			public void onClick(View v) {
+			public void onClick(View v)
+			{
 				// TextView tv_head = (TextView) findViewById(R.id.tv_head);
 
 				// searchresult.set_direction(1);
 				if (searchresult.get_totalcount() == -1)
 					requestdata(true);
-				else {
+				else
+				{
 					// if (searchresult.get_direction() == -1)
 					searchresult.set_offset(searchresult.get_offset() + 10);
 					requestdata(false);
@@ -127,15 +133,18 @@ public class ResultActivity extends Activity {
 		});
 
 		Button btnpre = (Button) findViewById(R.id.btn_pre);
-		btnpre.setOnClickListener(new View.OnClickListener() {
+		btnpre.setOnClickListener(new View.OnClickListener()
+		{
 
 			@Override
-			public void onClick(View v) {
+			public void onClick(View v)
+			{
 				// TextView tv_head = (TextView) findViewById(R.id.tv_head);
 				// searchresult.set_direction(-1);
 				if (searchresult.get_totalcount() == -1)
 					requestdata(true);
-				else {
+				else
+				{
 					searchresult.set_offset(searchresult.get_offset() - 10);
 					requestdata(false);
 				}
@@ -146,10 +155,12 @@ public class ResultActivity extends Activity {
 		mStatusMessageView = (TextView) findViewById(R.id.status_message);
 		LinearLayout ll = (LinearLayout) findViewById(R.id.ll_refresh);
 		Button btn_refresh = (Button) ll.findViewById(R.id.btn_refresh);
-		btn_refresh.setOnClickListener(new View.OnClickListener() {
+		btn_refresh.setOnClickListener(new View.OnClickListener()
+		{
 
 			@Override
-			public void onClick(View v) {
+			public void onClick(View v)
+			{
 				LinearLayout ll = (LinearLayout) findViewById(R.id.ll_refresh);
 				ll.setVisibility(View.INVISIBLE);
 				if (searchresult.get_totalcount() == -1)
@@ -163,11 +174,13 @@ public class ResultActivity extends Activity {
 		SharedPreferences RunOnce = getSharedPreferences("Apex", 0);
 
 		String vername;
-		try {
+		try
+		{
 			vername = getPackageManager().getPackageInfo("com.usai.apex", 0).versionName;
 			boolean bFirstRun = RunOnce.getBoolean("FirstRun" + vername
 					+ "_result", true);
-			if (bFirstRun) {
+			if (bFirstRun)
+			{
 				SharedPreferences.Editor editor = RunOnce.edit();
 				editor.putBoolean("FirstRun" + vername + "_result", false);
 				// Don't forget to commit your edits!!!
@@ -178,28 +191,31 @@ public class ResultActivity extends Activity {
 				startActivity(intent);
 
 			}
-		} catch (NameNotFoundException e) {
+		}
+		catch (NameNotFoundException e)
+		{
 			// TODO Auto-generated catch block
 			e.printStackTrace();
 		}
 		initTableHeader();
-		if(savedInstanceState!=null)
+		if (savedInstanceState != null)
 		{
-			searchresult=(SearchResult) savedInstanceState.getSerializable("searchresult");
-			if(searchresult.get_totalcount()==-1)
+			searchresult = (SearchResult) savedInstanceState
+					.getSerializable("searchresult");
+			if (searchresult.get_totalcount() == -1)
 				requestdata(true);
 			else
 				initTable();
 		}
 		else
-		requestdata(true);
+			requestdata(true);
 
 	}
 
 	@Override
 	protected void onDestroy()
 	{
-		if(m_task!=null)
+		if (m_task != null)
 			m_task.cancel(false);
 		super.onDestroy();
 	}
@@ -209,45 +225,47 @@ public class ResultActivity extends Activity {
 		// int loadcount = searchresult.get_count();
 		int totalcount = searchresult.get_totalcount();
 		TextView tv_head = (TextView) findViewById(R.id.head);
-		if (totalcount == 0) {
+		if (totalcount == 0)
+		{
 			tv_head.setText("0 record found");
 
 			return;
-		} else if(searchresult.get_totalcount()>2000)
+		}
+		else if (searchresult.get_totalcount() > 2000)
 		{
 			tv_head.setText("2000+ records");
 		}
 		else
 			tv_head.setText(/*
 							 * loadcount + "/" +
-							 */searchresult.get_totalcount()
-					+ " records");
+							 */searchresult.get_totalcount() + " records");
 		TableLayout tl = (TableLayout) findViewById(R.id.result_table);
 
 		tl.removeViews(1, tl.getChildCount() - 1);
 		// int newcount = loadcount - showcount + 1;// +1 header row
-		for (int i = 0; i < searchresult.get_recordscount(); i++) {
+		for (int i = 0; i < searchresult.get_recordscount(); i++)
+		{
 
 			TableRow recordRow = new TableRow(ResultActivity.this);
-			recordRow
-					.setOnLongClickListener(new View.OnLongClickListener() {
+			recordRow.setOnLongClickListener(new View.OnLongClickListener()
+			{
 
-						@Override
-						public boolean onLongClick(View v) {
-							// TODO Auto-generated method stub
-							// v.setBackgroundColor(Color.GRAY);
-							// v.showContextMenu();
-							// return true;
-							TableRow tr = (TableRow) v;
-							TextView tvno = (TextView) tr.getChildAt(0);
-							sel = Integer.parseInt(tvno.getText()
-									.toString()) % 10;
-							registerForContextMenu(v);
-							openContextMenu(v);
-							unregisterForContextMenu(v);
-							return true;
-						}
-					});
+				@Override
+				public boolean onLongClick(View v)
+				{
+					// TODO Auto-generated method stub
+					// v.setBackgroundColor(Color.GRAY);
+					// v.showContextMenu();
+					// return true;
+					TableRow tr = (TableRow) v;
+					TextView tvno = (TextView) tr.getChildAt(0);
+					sel = Integer.parseInt(tvno.getText().toString()) % 10;
+					registerForContextMenu(v);
+					openContextMenu(v);
+					unregisterForContextMenu(v);
+					return true;
+				}
+			});
 
 			// registerForContextMenu(recordRow);
 			// recordRow.setClickable(true);
@@ -264,9 +282,10 @@ public class ResultActivity extends Activity {
 			field.setPadding(10, 5, 10, 5);
 			field.setTextSize(20);
 			recordRow.addView(field);
-			for (int j = 0; j < showfieldmap.size(); j++) {
+			for (int j = 0; j < showfieldmap.size(); j++)
+			{
 				TextView field1 = new TextView(ResultActivity.this);
-				Log.d("onPostExecute", showfieldmap.get(j));
+//				Log.d("onPostExecute", showfieldmap.get(j));
 				String str = record.get(showfieldmap.get(j));
 				field1.setBackgroundResource(R.drawable.tableitem);
 				if (str.toLowerCase().trim().equals("null"))
@@ -276,73 +295,86 @@ public class ResultActivity extends Activity {
 
 				field1.setText(Html.fromHtml(str));
 
-				if(actioncount==0)
-				field1.setOnClickListener(new OnClickListener() {
-
-					@Override
-					public void onClick(View v) {
-						URLSpan span[] = ((TextView) v).getUrls();
-						if (span.length < 1)
-							return;
-						span[0].getURL();
-						Log.d("Text", span[0].getURL());
-
-						final DownloadManager downloadManager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
-
-						Uri uri = Uri.parse(span[0].getURL());
-						final Request request = new Request(uri);
-
-						// 设置允许使用的网络类型,这里是移动网络和wifi都可以
-						request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_MOBILE
-								| DownloadManager.Request.NETWORK_WIFI);
-
-						// 禁止发出通知,既后台下载,如果要使用这一句必须声明一个权限:android.permission.DOWNLOAD_WITHOUT_NOTIFICATION
-						// request.setShowRunningNotification(false);
-
-						// 不显示下载界面
-						request.setVisibleInDownloadsUi(false);
-						request.setNotificationVisibility(Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
-
-						/*
-						 * 设置下载后文件存放的位置,如果sdcard不可用,那么设置这个将报错,
-						 * 因此最好不设置如果sdcard可用,下载后的文件
-						 * 在/mnt/sdcard/Android/
-						 * data/packageName/files目录下面
-						 * ,如果sdcard不可用,设置了下面这个将报错,不设置,下载后的文件在/cache这个
-						 * 目录下面
-						 */
-						// request.setDestinationInExternalFilesDir(this,
-						// null, "tar.apk");
-						
-						AlertDialog.Builder builder = new Builder(ResultActivity.this);
-						builder.setMessage("Click start button to begin download");
-
-						builder.setTitle("Confirm download");
-
-						builder.setPositiveButton("Start", new Dialog.OnClickListener() {
-
-							@Override
-							public void onClick(DialogInterface dialog, int which) {
-								long id = downloadManager.enqueue(request);
-								dialog.dismiss();
-
-							}
-						});
-
-						builder.setNegativeButton("Cancel", new Dialog.OnClickListener() {
-		
-							@Override
-							public void onClick(DialogInterface dialog, int which) {
-								dialog.dismiss();
-							}
-						});
-
-						builder.create().show();
-						
-
-					}
-
-				});
+				if (actioncount == 0)
+					field1.setOnClickListener(new OnClickListener()
+					{
+
+						@Override
+						public void onClick(View v)
+						{
+//							if (true)
+//								return;
+							URLSpan span[] = ((TextView) v).getUrls();
+							if (span.length < 1)
+								return;
+							span[0].getURL();
+							Log.d("Text", span[0].getURL());
+
+							final DownloadManager downloadManager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
+
+							Uri uri = Uri.parse(span[0].getURL());
+							final Request request = new Request(uri);
+
+							// 设置允许使用的网络类型,这里是移动网络和wifi都可以
+							request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_MOBILE
+									| DownloadManager.Request.NETWORK_WIFI);
+
+							// 禁止发出通知,既后台下载,如果要使用这一句必须声明一个权限:android.permission.DOWNLOAD_WITHOUT_NOTIFICATION
+							// request.setShowRunningNotification(false);
+
+							// 不显示下载界面
+							request.setVisibleInDownloadsUi(false);
+							request.setNotificationVisibility(Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
+
+							/*
+							 * 设置下载后文件存放的位置,如果sdcard不可用,那么设置这个将报错,
+							 * 因此最好不设置如果sdcard可用,下载后的文件 在/mnt/sdcard/Android/
+							 * data/packageName/files目录下面
+							 * ,如果sdcard不可用,设置了下面这个将报错,不设置,下载后的文件在/cache这个 目录下面
+							 */
+							// request.setDestinationInExternalFilesDir(this,
+							// null, "tar.apk");
+
+							AlertDialog.Builder builder = new Builder(
+									ResultActivity.this);
+							builder.setMessage("Click start button to begin download");
+
+							builder.setTitle("Confirm download");
+
+							builder.setPositiveButton("Start",
+									new Dialog.OnClickListener()
+									{
+
+										@Override
+										public void onClick(
+												DialogInterface dialog,
+												int which)
+										{
+											long id = downloadManager
+													.enqueue(request);
+											dialog.dismiss();
+
+										}
+									});
+
+							builder.setNegativeButton("Cancel",
+									new Dialog.OnClickListener()
+									{
+
+										@Override
+										public void onClick(
+												DialogInterface dialog,
+												int which)
+										{
+											dialog.dismiss();
+										}
+									});
+
+							builder.create().show();
+
+						}
+
+					});
 				// field1.setText(str);
 				field1.setGravity(Gravity.CENTER);
 				field1.setPadding(10, 5, 10, 5);
@@ -359,29 +391,38 @@ public class ResultActivity extends Activity {
 		Button btnpre = (Button) findViewById(R.id.btn_pre);
 		if (searchresult.get_offset() == 0)
 			btnpre.setEnabled(false);
-		else {
+		else
+		{
 			btnpre.setEnabled(true);
 		}
 		if (searchresult.get_totalcount() - searchresult.get_offset() <= 10)
 			btnnext.setEnabled(false);
 		else
-			btnnext.setEnabled(true);		
+			btnnext.setEnabled(true);
 	}
-	private OnCreateContextMenuListener m_tableMenu = new OnCreateContextMenuListener() {
 
-		@Override
-		public void onCreateContextMenu(ContextMenu contextmenu, View view,
-				ContextMenuInfo contextmenuinfo) {
+	private OnCreateContextMenuListener	m_tableMenu	= new OnCreateContextMenuListener()
+													{
 
+														@Override
+														public void onCreateContextMenu(
+																ContextMenu contextmenu,
+																View view,
+																ContextMenuInfo contextmenuinfo)
+														{
 
-				contextmenu.add(Menu.NONE, 0, 0, "Detail");
+															contextmenu.add(
+																	Menu.NONE,
+																	0, 0,
+																	"Detail");
 
-		}
+														}
 
-	};
+													};
 
 	@Override
-	public boolean onContextItemSelected(MenuItem item) {
+	public boolean onContextItemSelected(MenuItem item)
+	{
 		// menuInfo = (AdapterContextMenuInfo) item.getMenuInfo();
 		// Log.d("table row select", sel+ "");
 
@@ -394,7 +435,8 @@ public class ResultActivity extends Activity {
 						+ function_name + "' and user='" + user + "'", null,
 				null, null, "priority", null);
 		int i = 0;
-		while (cursor.moveToNext()) {
+		while (cursor.moveToNext())
+		{
 			String name = cursor.getString(0);
 			Log.d("actionname", name);
 			intent.putExtra("action" + i, name);
@@ -422,7 +464,8 @@ public class ResultActivity extends Activity {
 	// super.onCreateContextMenu(menu, v, menuInfo);
 	// }
 
-	void initTableHeader() {
+	void initTableHeader()
+	{
 
 		TableLayout tl = (TableLayout) findViewById(R.id.result_table);
 		tl.setFocusable(true);
@@ -445,7 +488,8 @@ public class ResultActivity extends Activity {
 		btn.setPadding(0, 0, 0, 0);
 		btn.setText("No.");
 		headerRow.addView(btn);
-		while (cursor.moveToNext()) {
+		while (cursor.moveToNext())
+		{
 			String aname = cursor.getString(0);
 			Button btn1 = new Button(this);
 			btn1.setBackgroundResource(R.drawable.tablehead);
@@ -473,43 +517,48 @@ public class ResultActivity extends Activity {
 	}
 
 	@Override
-	public boolean onCreateOptionsMenu(Menu menu) {
+	public boolean onCreateOptionsMenu(Menu menu)
+	{
 		// Inflate the menu; this adds items to the action bar if it is present.
 		getMenuInflater().inflate(R.menu.result, menu);
 		return true;
 	}
 
 	@Override
-	public boolean onOptionsItemSelected(MenuItem item) {
+	public boolean onOptionsItemSelected(MenuItem item)
+	{
 		Intent intent = new Intent();
-		switch (item.getItemId()) {
-		case R.id.action_custom_fields:
-
-			intent.setClass(this, CustomizeFieldsActivity.class);
-			intent.putExtra("user", user);
-			// intent.putExtra("password", password);
-			intent.putExtra("function_name", function_name);
-			intent.putExtra("behavior", Network.BEHAVIOR_RESULT);
-			startActivity(intent);
-			break;
-		case R.id.action_help:
-			// Intent intent = new Intent();
-			intent.setClass(this, HelpActivity.class);
-			intent.putExtra("caller", "result");
-			// // intent.putExtra("password", password);
-			// intent.putExtra("function_name", function_name);
-			// intent.putExtra("behavior", Network.BEHAVIOR_SEARCH);
-			startActivity(intent);
-			break;
-		default:
-			break;
+		switch (item.getItemId())
+		{
+			case R.id.action_custom_fields:
+
+				intent.setClass(this, CustomizeFieldsActivity.class);
+				intent.putExtra("user", user);
+				// intent.putExtra("password", password);
+				intent.putExtra("function_name", function_name);
+				intent.putExtra("behavior", Network.BEHAVIOR_RESULT);
+				startActivity(intent);
+				break;
+			case R.id.action_help:
+				// Intent intent = new Intent();
+				intent.setClass(this, HelpActivity.class);
+				intent.putExtra("caller", "result");
+				// // intent.putExtra("password", password);
+				// intent.putExtra("function_name", function_name);
+				// intent.putExtra("behavior", Network.BEHAVIOR_SEARCH);
+				startActivity(intent);
+				break;
+			default:
+				break;
 		}
 		return super.onOptionsItemSelected(item);
 	}
 
-	public void requestdata(boolean requestcount) {
+	public void requestdata(boolean requestcount)
+	{
 
-		if (m_task != null) {
+		if (m_task != null)
+		{
 			return;
 		}
 		mStatusMessageView.setText("Loading");
@@ -519,20 +568,24 @@ public class ResultActivity extends Activity {
 
 	}
 
-	private void showProgress(final boolean show) {
+	private void showProgress(final boolean show)
+	{
 		// On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow
 		// for very easy animations. If available, use these APIs to fade-in
 		// the progress spinner.
-		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
+		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2)
+		{
 			int shortAnimTime = getResources().getInteger(
 					android.R.integer.config_shortAnimTime);
 
 			mStatusView.setVisibility(View.VISIBLE);
 			mStatusView.animate().setDuration(shortAnimTime)
 					.alpha(show ? 1 : 0)
-					.setListener(new AnimatorListenerAdapter() {
+					.setListener(new AnimatorListenerAdapter()
+					{
 						@Override
-						public void onAnimationEnd(Animator animation) {
+						public void onAnimationEnd(Animator animation)
+						{
 							mStatusView.setVisibility(show ? View.VISIBLE
 									: View.INVISIBLE);
 						}
@@ -540,9 +593,11 @@ public class ResultActivity extends Activity {
 
 			footview.setVisibility(View.VISIBLE);
 			footview.animate().setDuration(shortAnimTime).alpha(show ? 0 : 1)
-					.setListener(new AnimatorListenerAdapter() {
+					.setListener(new AnimatorListenerAdapter()
+					{
 						@Override
-						public void onAnimationEnd(Animator animation) {
+						public void onAnimationEnd(Animator animation)
+						{
 							footview.setVisibility(show ? View.INVISIBLE
 									: View.VISIBLE);
 						}
@@ -559,7 +614,9 @@ public class ResultActivity extends Activity {
 			// : View.VISIBLE);
 			// }
 			// });
-		} else {
+		}
+		else
+		{
 			// The ViewPropertyAnimator APIs are not available, so simply show
 			// and hide the relevant UI components.
 			mStatusView.setVisibility(show ? View.VISIBLE : View.INVISIBLE);
@@ -569,13 +626,14 @@ public class ResultActivity extends Activity {
 		}
 	}
 
-	public class SearchTask extends AsyncTask<Boolean, Void, Boolean> {
+	public class SearchTask extends AsyncTask<Boolean, Void, Boolean>
+	{
 		// int err_code = ERR_CODE_NONE;
-		int errorcode;
+		int	errorcode;
 
 		@Override
-		protected Boolean doInBackground(Boolean... params) {
-			
+		protected Boolean doInBackground(Boolean... params)
+		{
 
 			if (!Network.NetworkIsAvailable())
 
@@ -584,13 +642,17 @@ public class ResultActivity extends Activity {
 				return false;
 			}
 
-			if (params[0]) {
+			if (params[0])
+			{
 				int ret = Network.get_recordcount(user, password, searchParms);
-				if (ret >= 0) {
+				if (ret >= 0)
+				{
 					searchresult.put_totalcount(ret);
 					if (ret == 0)
 						return true;
-				} else {
+				}
+				else
+				{
 					errorcode = ret;
 					return false;
 				}
@@ -601,7 +663,8 @@ public class ResultActivity extends Activity {
 			searchParms.putString("offset", searchresult.get_offset() + "");
 
 			String jstr = Network.get_records(user, password, searchParms);
-			if (jstr == null || jstr.length() <= 0) {
+			if (jstr == null || jstr.length() <= 0)
+			{
 				// Log.d(TAG, "json is wrong");
 				errorcode = Network.RESULT_NET_ERROR;
 				return false;
@@ -610,7 +673,8 @@ public class ResultActivity extends Activity {
 			JSONObject jsobj;
 			//
 			// array = new JSONArray(json);
-			try {
+			try
+			{
 				jsobj = new JSONObject(jstr);
 				// if (searchresult.get_fieldscount() == 0)
 				// {
@@ -625,7 +689,9 @@ public class ResultActivity extends Activity {
 
 				return true;
 
-			} catch (JSONException e) {
+			}
+			catch (JSONException e)
+			{
 				// TODO Auto-generated catch block
 				e.printStackTrace();
 			}
@@ -635,59 +701,66 @@ public class ResultActivity extends Activity {
 		}
 
 		@Override
-		protected void onPostExecute(final Boolean success) {
+		protected void onPostExecute(final Boolean success)
+		{
 			Log.i("onPostExecute", "entry");
 			m_task = null;
 			showProgress(false);
 
-			switch (errorcode) {
-			case Network.RESULT_NET_NOTAVAILABLE: {
-				Toast toast = Toast.makeText(getApplicationContext(),
-						getText(R.string.msg_connection_none),
-						Toast.LENGTH_LONG);
-				toast.setGravity(Gravity.CENTER, 0, 0);
-				toast.show();
-				break;
-			}
-			case Network.RESULT_NET_ERROR: {
-				Toast toast = Toast.makeText(getApplicationContext(),
-						getText(R.string.msg_net_error), Toast.LENGTH_LONG);
-				toast.setGravity(Gravity.CENTER, 0, 0);
-				toast.show();
-				break;
-			}
-			case Network.RESULT_ERROR:
-			// case Network.RESULT_RESPONSE_NULL:
+			switch (errorcode)
 			{
-				Toast toast = Toast.makeText(getApplicationContext(),
-						getText(R.string.msg_net_resulterror),
-						Toast.LENGTH_LONG);
-				toast.setGravity(Gravity.CENTER, 0, 0);
-				toast.show();
-				break;
-			}
+				case Network.RESULT_NET_NOTAVAILABLE:
+				{
+					Toast toast = Toast.makeText(getApplicationContext(),
+							getText(R.string.msg_connection_none),
+							Toast.LENGTH_LONG);
+					toast.setGravity(Gravity.CENTER, 0, 0);
+					toast.show();
+					break;
+				}
+				case Network.RESULT_NET_ERROR:
+				{
+					Toast toast = Toast.makeText(getApplicationContext(),
+							getText(R.string.msg_net_error), Toast.LENGTH_LONG);
+					toast.setGravity(Gravity.CENTER, 0, 0);
+					toast.show();
+					break;
+				}
+				case Network.RESULT_ERROR:
+				// case Network.RESULT_RESPONSE_NULL:
+				{
+					Toast toast = Toast.makeText(getApplicationContext(),
+							getText(R.string.msg_net_resulterror),
+							Toast.LENGTH_LONG);
+					toast.setGravity(Gravity.CENTER, 0, 0);
+					toast.show();
+					break;
+				}
 
-			default:
-				break;
+				default:
+					break;
 			}
 
-			if (success) {
+			if (success)
+			{
 
 				initTable();
 
-			} else {
+			}
+			else
+			{
 				LinearLayout ll = (LinearLayout) findViewById(R.id.ll_refresh);
 				ll.setVisibility(View.VISIBLE);
 			}
 		}
 
 		@Override
-		protected void onCancelled() {
+		protected void onCancelled()
+		{
 			m_task = null;
 			showProgress(false);
 		}
 	}
-	
 
 	@Override
 	protected void onSaveInstanceState(Bundle outState)
@@ -696,5 +769,4 @@ public class ResultActivity extends Activity {
 		super.onSaveInstanceState(outState);
 	}
 
-
 }

+ 1 - 1
Apex/src/com/usai/apex/SearchActivity.java

@@ -108,7 +108,7 @@ public class SearchActivity extends ListActivity implements OnClickListener
 			final String field_type = cursor.getString(1);
 			final String name = cursor.getString(2);
 
-			Log.e("cursor val", "name=" + f0 + " , type=" + field_type);
+			Log.d("cursor val", "name=" + f0 + " , type=" + field_type);
 			final EditText edit = (EditText) view.findViewById(R.id.edit_val);
 			edit.setText(hashMap.get(name));
 			Log.v("from hashmap",

+ 3 - 3
Apex/src/com/usai/apex/ServiceLocationFragment.java

@@ -122,7 +122,7 @@ public class ServiceLocationFragment extends Fragment implements
 		if (fragment == null)
 		{
 			
-			Log.e("onActivityCreated","create support map fragment");
+			Log.d("onActivityCreated","create support map fragment");
 			fragment = new SupportMapFragment();// .newInstance();
 			fm.beginTransaction().replace(R.id.map, fragment).commit();
 		}
@@ -135,7 +135,7 @@ public class ServiceLocationFragment extends Fragment implements
 		if (map == null)
 		{
 			
-			Log.e("onResume","get map from fragment");
+			Log.d("onResume","get map from fragment");
 			map = fragment.getMap();
 			if (map != null)
 				setUpMap();
@@ -145,7 +145,7 @@ public class ServiceLocationFragment extends Fragment implements
 
 	private void setUpMap()
 	{
-		Log.e("setup map","setup map");
+		Log.d("setup map","setup map");
 		// // Hide the zoom controls as the button panel will cover it.
 		// map.getUiSettings().setZoomControlsEnabled(false);
 		//

+ 12 - 0
Apex/src/com/usai/util/Network.java

@@ -49,6 +49,7 @@ import org.json.JSONObject;
 import com.usai.apex.ApexTrackingApplication;
 import android.content.Context;
 import android.content.SharedPreferences.Editor;
+import android.content.pm.PackageManager.NameNotFoundException;
 import android.database.DatabaseUtils.InsertHelper;
 import android.database.sqlite.SQLiteDatabase;
 import android.database.sqlite.SQLiteStatement;
@@ -81,6 +82,7 @@ public class Network {
 	public static final int RESULT_USERAUTH_ERROR = -9;
 	public static final int RESULT_UPDATE_USERAUTH_ERROR = -11;
 	public static final int RESULT_SESSION_EXPIRED = -13;
+	public static final int RESULT_VER_LOW = -15;
 
 	public static String URL_UPDATE_AUTH = "https://ra.apexshipping.com/login.php";
 	public static String URL_REQUEST_COUNT = "https://ra.apexshipping.com/main.php";
@@ -550,6 +552,11 @@ public class Network {
 				}
 
 				JSONObject objheader = jsobj.getJSONObject("header");
+				String required_ver = objheader
+						.getString("client_ver");
+				String current_ver = ApexTrackingApplication.get_instance().getPackageManager().getPackageInfo("com.usai.apex", 0).versionName;
+				if(current_ver.compareTo(required_ver)<0)
+					return RESULT_VER_LOW;
 				// JSONObject objsessionid = jsobj.getJSONObject(1); // session
 				// id
 				// on
@@ -720,6 +727,11 @@ public class Network {
 			// TODO Auto-generated catch block
 			e1.printStackTrace();
 			Log.d(TAG, "json is wrong");
+		}
+		catch (NameNotFoundException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
 		} finally {
 			dbUtil.CloseDB(db);
 		}