Browse Source

RA Image Android

去掉一些旧逻辑,修复部分bug。列表刷新仍然有问题。
Ray Zhang 8 years ago
parent
commit
1ba01fe6d7

+ 0 - 781
RA Image/app/src/main/java/com/usai/redant/raimage/LockerActivity.java

@@ -1,781 +0,0 @@
-package com.usai.redant.raimage;
-
-import android.animation.Animator;
-import android.animation.AnimatorListenerAdapter;
-import android.annotation.TargetApi;
-import android.app.Activity;
-import android.content.Intent;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.os.AsyncTask;
-import android.os.Build;
-import android.os.Bundle;
-import android.text.TextUtils;
-import android.util.Log;
-import android.view.Gravity;
-import android.view.KeyEvent;
-import android.view.View;
-import android.view.inputmethod.EditorInfo;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.ArrayAdapter;
-import android.widget.AutoCompleteTextView;
-import android.widget.EditText;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.usai.util.AES;
-import com.usai.util.Crypto;
-import com.usai.util.Network;
-import com.usai.util.dbUtil;
-
-/**
- * Activity which displays a login screen to the user, offering registration as
- * well.
- */
-public class LockerActivity extends Activity
-{
-	// public static final int ERR_CODE_NONE = 0;
-	// public static final int ERR_CODE_NULLRETURN = 1;
-	// public static final int ERR_CODE_NONETWORK = 2;
-
-	/**
-	 * A dummy authentication store containing known user names and passwords.
-	 * TODO: remove after connecting to a real authentication system.
-	 */
-	// private static final String[] DUMMY_CREDENTIALS = new String[] {
-	// "foo@example.com:hello", "bar@example.com:world" };
-
-	/**
-	 * The default email to populate the email field with.
-	 */
-	// public static final String EXTRA_EMAIL =
-	// "com.example.android.authenticatordemo.extra.EMAIL";
-	// public static final String EXTRA_USER = "Login_User";
-
-	/**
-	 * Keep track of the login task to ensure we can cancel it if requested.
-	 */
-	private UserLoginTask	mAuthTask	= null;
-	ArrayAdapter<String>		adapter							= null;
-	// SQLiteDatabase m_db;
-	// Values for email and password at the time of the login attempt.
-	private String			m_sName;
-	private String			m_sPassword;
-
-	// UI references.
-	private AutoCompleteTextView		m_etName;
-	private EditText		m_etPassword;
-	private View			mLoginFormView;
-	private View			mLoginStatusView;
-	private TextView		mLoginStatusMessageView;
-
-//	@Override
-//	protected void onDestroy()
-//	{
-//		// TODO Auto-generated method stub
-////		dbUtil.CloseDB(m_db);
-////		super.onDestroy();
-//
-//	}
-
-	@Override
-	protected void onCreate(Bundle savedInstanceState)
-	{
-		super.onCreate(savedInstanceState);
-
-		setContentView(R.layout.activity_locker);
-
-		// Set up the login form.
-		// m_sName = getIntent().getStringExtra(EXTRA_USER);
-		m_etName = (AutoCompleteTextView) findViewById(R.id.name);
-
-		// m_etName.setText(m_sName);
-
-		m_etPassword = (EditText) findViewById(R.id.password);
-		m_etPassword
-				.setOnEditorActionListener(new TextView.OnEditorActionListener()
-				{
-					@Override
-					public boolean onEditorAction(TextView textView, int id,
-							KeyEvent keyEvent)
-					{
-						if (id == R.id.login
-								|| id == EditorInfo.IME_ACTION_DONE)
-						{
-							InputMethodManager inputMethodManager = (InputMethodManager) getApplicationContext()
-									.getSystemService(INPUT_METHOD_SERVICE);
-
-							// EditText editText =
-							// (EditText)findViewById(R.id.xxxx);
-							inputMethodManager.hideSoftInputFromWindow(
-									m_etPassword.getWindowToken(), 0); // ����
-							attemptLogin();
-							return true;
-						}
-						return false;
-					}
-				});
-
-		mLoginFormView = findViewById(R.id.login_form);
-		mLoginStatusView = findViewById(R.id.login_status);
-		mLoginStatusMessageView = (TextView) findViewById(R.id.login_status_message);
-
-		findViewById(R.id.sign_in_button).setOnClickListener(
-				new View.OnClickListener()
-				{
-					@Override
-					public void onClick(View view)
-					{
-						attemptLogin();
-					}
-				});
-		adapter = new ArrayAdapter<String>(this,
-				android.R.layout.simple_list_item_1,
-				dbUtil.get_userlist());
-		m_etName.setAdapter(adapter);
-	}
-	@Override
-	public boolean onKeyDown(int keyCode, KeyEvent event)
-	{
-		if (keyCode == KeyEvent.KEYCODE_BACK)
-		{
-			// Intent myIntent = new Intent();
-			// myIntent = new Intent(EditActivity.this, tabActivity.class);
-			// startActivity(myIntent);
-			// this.finish();
-			return true;
-		}
-		return super.onKeyDown(keyCode, event);
-
-	}
-//	@Override
-//	public boolean onCreateOptionsMenu(Menu menu)
-//	{
-//		super.onCreateOptionsMenu(menu);
-//		getMenuInflater().inflate(R.menu.login, menu);
-//		return true;
-//	}
-
-	/**
-	 * Attempts to sign in or register the account specified by the login form.
-	 * If there are form errors (invalid email, missing fields, etc.), the
-	 * errors are presented and no actual login attempt is made.
-	 */
-	public void attemptLogin()
-	{
-		if (mAuthTask != null)
-		{
-			return;
-		}
-
-		// Reset errors.
-		m_etName.setError(null);
-		m_etPassword.setError(null);
-
-		// Store values at the time of the login attempt.
-		m_sName = m_etName.getText().toString();
-		m_sPassword = m_etPassword.getText().toString();
-
-		boolean cancel = false;
-		View focusView = null;
-
-		// Check for a valid password.
-		if (TextUtils.isEmpty(m_sPassword))
-		{
-			m_etPassword.setError(getString(R.string.error_field_required));
-			focusView = m_etPassword;
-			cancel = true;
-		}
-		else if (m_sPassword.length() < 4)
-		{
-			m_etPassword.setError(getString(R.string.error_invalid_password));
-			focusView = m_etPassword;
-			cancel = true;
-		}
-
-		// Check for a valid user name.
-		if (TextUtils.isEmpty(m_sName))
-		{
-			m_etName.setError(getString(R.string.error_field_required));
-			focusView = m_etName;
-			cancel = true;
-		}
-		// else if (!m_sName.contains("@")) {
-		// m_etName.setError(getString(R.string.error_invalid_email));
-		// focusView = m_etName;
-		// cancel = true;
-		// }
-
-		if (cancel)
-		{
-			// There was an error; don't attempt login and focus the first
-			// form field with an error.
-			focusView.requestFocus();
-		}
-		else
-		{
-			// Show a progress spinner, and kick off a background task to
-			// perform the user login attempt.
-			mLoginStatusMessageView.setText(R.string.login_progress_signing_in);
-			showProgress(true);
-			mAuthTask = new UserLoginTask();
-			mAuthTask.execute((Void) null);
-		}
-	}
-
-	/**
-	 * Shows the progress UI and hides the login form.
-	 */
-	@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
-	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)
-		{
-			int shortAnimTime = getResources().getInteger(
-					android.R.integer.config_shortAnimTime);
-
-			mLoginStatusView.setVisibility(View.VISIBLE);
-			mLoginStatusView.animate().setDuration(shortAnimTime)
-					.alpha(show ? 1 : 0)
-					.setListener(new AnimatorListenerAdapter()
-					{
-						@Override
-						public void onAnimationEnd(Animator animation)
-						{
-							mLoginStatusView.setVisibility(show ? View.VISIBLE
-									: View.GONE);
-						}
-					});
-
-			mLoginFormView.setVisibility(View.VISIBLE);
-			mLoginFormView.animate().setDuration(shortAnimTime)
-					.alpha(show ? 0 : 1)
-					.setListener(new AnimatorListenerAdapter()
-					{
-						@Override
-						public void onAnimationEnd(Animator animation)
-						{
-							mLoginFormView.setVisibility(show ? View.GONE
-									: View.VISIBLE);
-						}
-					});
-		}
-		else
-		{
-			// The ViewPropertyAnimator APIs are not available, so simply show
-			// and hide the relevant UI components.
-			mLoginStatusView.setVisibility(show ? View.VISIBLE : View.GONE);
-			mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
-		}
-	}
-
-	/**
-	 * Represents an asynchronous login/registration task used to authenticate
-	 * the user.
-	 */
-	public class UserLoginTask extends AsyncTask<Void, Void, Boolean>
-	{
-		// int err_code = ERR_CODE_NONE;
-		int	verifyuser	= Network.RESULT_TRUE;
-
-		// int netconnect;
-
-		@Override
-		protected Boolean doInBackground(Void... params)
-		{
-
-			verifyuser = Network.VerifyUser(m_sName, m_sPassword);
-			if (verifyuser == Network.RESULT_TRUE)
-				return true;
-			else
-				return false;
-		}
-
-		@Override
-		protected void onPostExecute(final Boolean success)
-		{
-			Log.i("onPostExecute", "entry");
-			mAuthTask = null;
-			showProgress(false);
-
-			if (success)
-			{
-				String encryptUser="";
-				String encryptPass="";
-				try
-				{
-					encryptUser=AES.encrypt("apexu", m_sName);
-					encryptPass= AES.encrypt("apexp", m_sPassword);
-				}
-				catch (Exception e1)
-				{
-					// TODO Auto-generated catch block
-					e1.printStackTrace();
-				}
-
-				SQLiteDatabase db = dbUtil.OpenDB(LockerActivity.this, null,
-						true);
-				Cursor cursor = db
-						.query("users", new String[] { "_id" }, "name='"
-								+ encryptUser + "'", null, null, null, "_id", null);
-				if (cursor.moveToNext())
-				{
-					int _id = cursor.getInt(0);
-					String sql = "update users set pass='" + encryptPass
-							+ "' where _id=" + _id;
-					db.execSQL(sql);
-				}
-				else
-				{
-					String sql = "insert into users(name,pass) values('"
-							+ encryptUser + "','" + encryptPass + "')";
-					db.execSQL(sql);
-				}
-				dbUtil.CloseCursor(cursor);
-				dbUtil.CloseDB(db);
-
-				RedAntApplication.user = m_sName;
-				RedAntApplication.password = m_sPassword;
-				Intent intent = new Intent();
-				setResult(Activity.RESULT_OK, intent);
-				finish();
-			}
-			else
-			{
-				switch (verifyuser)
-				{
-					case Network.RESULT_NET_ERROR:
-					case Network.RESULT_NET_NOTAVAILABLE:
-					{
-						SQLiteDatabase db = dbUtil.OpenDB(LockerActivity.this,
-								null, true);
-
-						String encryptUser="";
-						try
-						{
-							encryptUser=Crypto.encrypt("apexu", m_sName);
-						}
-						catch (Exception e1)
-						{
-							// TODO Auto-generated catch block
-							e1.printStackTrace();
-						}
-						Cursor cursor = db.query("users", new String[] {
-								"pass", "_id" }, "name= '" + encryptUser + "'",
-								null, null, null, "_id desc", null);
-						if (cursor.moveToNext())
-						{
-							String pass="";
-							try
-							{
-								pass = Crypto.decrypt("apexp", cursor.getString(0));
-							}
-							catch (Exception e)
-							{
-								// TODO Auto-generated catch block
-								e.printStackTrace();
-							}
-							if (pass.equals(m_sPassword))
-							{
-								dbUtil.CloseCursor(cursor);
-								dbUtil.CloseDB(db);
-								RedAntApplication.user = m_sName;
-								RedAntApplication.password = m_sPassword;
-								Intent intent = new Intent();
-								setResult(Activity.RESULT_OK, intent);
-								finish();
-
-							}
-							else
-							{
-								// wrong password
-								Toast toast = Toast.makeText(getApplicationContext(),
-										getText(R.string.msg_user_wrong),
-										Toast.LENGTH_LONG);
-								toast.setGravity(Gravity.CENTER, 0, 0);
-								toast.show();
-								m_etPassword
-								.setError(getString(R.string.error_incorrect_password));
-						m_etPassword.requestFocus();
-								dbUtil.CloseCursor(cursor);
-								dbUtil.CloseDB(db);
-							}
-						}
-						else
-						{//wrong user
-							Toast toast = Toast.makeText(getApplicationContext(),
-									getText(R.string.msg_user_wrong),
-									Toast.LENGTH_LONG);
-							toast.setGravity(Gravity.CENTER, 0, 0);
-							toast.show();
-							m_etPassword
-							.setError(getString(R.string.error_incorrect_password));
-					m_etPassword.requestFocus();
-							dbUtil.CloseCursor(cursor);
-							dbUtil.CloseDB(db);
-
-						}
-
-						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();
-//						return;
-//					}
-					case Network.RESULT_FALSE:
-					{
-						Toast toast = Toast.makeText(getApplicationContext(),
-								getText(R.string.msg_user_wrong),
-								Toast.LENGTH_LONG);
-						toast.setGravity(Gravity.CENTER, 0, 0);
-						toast.show();
-						m_etPassword
-						.setError(getString(R.string.error_incorrect_password));
-				m_etPassword.requestFocus();
-						return;
-					}
-
-					default:
-						break;
-				}
-
-
-			}
-		}
-
-		@Override
-		protected void onCancelled()
-		{
-			mAuthTask = null;
-			showProgress(false);
-		}
-	}	
-	
-//	/**
-//	 * A dummy authentication store containing known user names and passwords.
-//	 * TODO: remove after connecting to a real authentication system.
-//	 */
-//	// private static final String[] DUMMY_CREDENTIALS = new String[] {
-//	// "foo@example.com:hello", "bar@example.com:world" };
-//
-//	/**
-//	 * The default email to populate the email field with.
-//	 */
-//	public static final String	EXTRA_EMAIL	= "com.example.android.authenticatordemo.extra.EMAIL";
-//
-//	/**
-//	 * Keep track of the login task to ensure we can cancel it if requested.
-//	 */
-//	private UserLoginTask		mAuthTask	= null;
-//	ArrayAdapter<String>		adapter							= null;
-//	SQLiteDatabase				m_db;
-//	// Values for email and password at the time of the login attempt.
-//	private String				m_sName;
-//	private String				m_sPassword;
-//
-//	// UI references.
-//	private AutoCompleteTextView			m_etName;
-//	private EditText			m_etPassword;
-//	private View				mLoginFormView;
-//	private View				mLoginStatusView;
-//	private TextView			mLoginStatusMessageView;
-//
-//	@Override
-//	protected void onCreate(Bundle savedInstanceState)
-//	{
-//		super.onCreate(savedInstanceState);
-//		setContentView(R.layout.activity_locker);
-//
-//		// Set up the login form.
-//		// m_sName = getIntent().getStringExtra(EXTRA_USER);
-//		m_etName = (AutoCompleteTextView) findViewById(R.id.name);
-//
-//		// m_etName.setText(m_sName);
-//
-//		m_etPassword = (EditText) findViewById(R.id.password);
-//		m_etPassword
-//				.setOnEditorActionListener(new TextView.OnEditorActionListener()
-//				{
-//					@Override
-//					public boolean onEditorAction(TextView textView, int id,
-//							KeyEvent keyEvent)
-//					{
-//						Log.d("onEditorAction", "id=" + id + " keyevent="
-//								+ keyEvent);
-//						if (id == R.id.locker
-//								|| id == EditorInfo.IME_ACTION_DONE)
-//						{
-//							attemptLogin();
-//							return true;
-//						}
-//						return false;
-//					}
-//				});
-//
-//		mLoginFormView = findViewById(R.id.login_form);
-//		mLoginStatusView = findViewById(R.id.login_status);
-//		mLoginStatusMessageView = (TextView) findViewById(R.id.login_status_message);
-//
-//		findViewById(R.id.sign_in_button).setOnClickListener(
-//				new View.OnClickListener()
-//				{
-//					@Override
-//					public void onClick(View view)
-//					{
-//						attemptLogin();
-//					}
-//				});
-//		
-//		adapter = new ArrayAdapter<String>(this,
-//				android.R.layout.simple_list_item_1,
-//				dbUtil.get_userlist());
-//		m_etName.setAdapter(adapter);
-//	}
-//
-//	@Override
-//	public boolean onCreateOptionsMenu(Menu menu)
-//	{
-//		super.onCreateOptionsMenu(menu);
-//		getMenuInflater().inflate(R.menu.locker, menu);
-//		return true;
-//	}
-//
-//	@Override
-//	public boolean onKeyDown(int keyCode, KeyEvent event)
-//	{
-//		if (keyCode == KeyEvent.KEYCODE_BACK)
-//		{
-//			// Intent myIntent = new Intent();
-//			// myIntent = new Intent(EditActivity.this, tabActivity.class);
-//			// startActivity(myIntent);
-//			// this.finish();
-//			return true;
-//		}
-//		return super.onKeyDown(keyCode, event);
-//
-//	}
-//
-//	/**
-//	 * Attempts to sign in or register the account specified by the login form.
-//	 * If there are form errors (invalid email, missing fields, etc.), the
-//	 * errors are presented and no actual login attempt is made.
-//	 */
-//	public void attemptLogin()
-//	{
-//		if (mAuthTask != null)
-//		{
-//			return;
-//		}
-//
-//		// Reset errors.
-//		m_etName.setError(null);
-//		m_etPassword.setError(null);
-//
-//		// Store values at the time of the login attempt.
-//		m_sName = m_etName.getText().toString();
-//		m_sPassword = m_etPassword.getText().toString();
-//
-//		boolean cancel = false;
-//		View focusView = null;
-//
-//		// Check for a valid password.
-//		if (TextUtils.isEmpty(m_sPassword))
-//		{
-//			m_etPassword.setError(getString(R.string.error_field_required));
-//			focusView = m_etPassword;
-//			cancel = true;
-//		}
-//		else if (m_sPassword.length() < 4)
-//		{
-//			m_etPassword.setError(getString(R.string.error_invalid_password));
-//			focusView = m_etPassword;
-//			cancel = true;
-//		}
-//
-//		// Check for a valid user name.
-//		if (TextUtils.isEmpty(m_sName))
-//		{
-//			m_etName.setError(getString(R.string.error_field_required));
-//			focusView = m_etName;
-//			cancel = true;
-//		}
-//		// else if (!m_sName.contains("@")) {
-//		// m_etName.setError(getString(R.string.error_invalid_email));
-//		// focusView = m_etName;
-//		// cancel = true;
-//		// }
-//
-//		if (cancel)
-//		{
-//			// There was an error; don't attempt login and focus the first
-//			// form field with an error.
-//			focusView.requestFocus();
-//		}
-//		else
-//		{
-//			// Show a progress spinner, and kick off a background task to
-//			// perform the user login attempt.
-//			mLoginStatusMessageView.setText(R.string.login_progress_signing_in);
-//			showProgress(true);
-//			mAuthTask = new UserLoginTask();
-//			mAuthTask.execute((Void) null);
-//		}
-//	}
-//
-//	/**
-//	 * Shows the progress UI and hides the login form.
-//	 */
-//	@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
-//	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)
-//		{
-//			int shortAnimTime = getResources().getInteger(
-//					android.R.integer.config_shortAnimTime);
-//
-//			mLoginStatusView.setVisibility(View.VISIBLE);
-//			mLoginStatusView.animate().setDuration(shortAnimTime)
-//					.alpha(show ? 1 : 0)
-//					.setListener(new AnimatorListenerAdapter()
-//					{
-//						@Override
-//						public void onAnimationEnd(Animator animation)
-//						{
-//							mLoginStatusView.setVisibility(show ? View.VISIBLE
-//									: View.GONE);
-//						}
-//					});
-//
-//			mLoginFormView.setVisibility(View.VISIBLE);
-//			mLoginFormView.animate().setDuration(shortAnimTime)
-//					.alpha(show ? 0 : 1)
-//					.setListener(new AnimatorListenerAdapter()
-//					{
-//						@Override
-//						public void onAnimationEnd(Animator animation)
-//						{
-//							mLoginFormView.setVisibility(show ? View.GONE
-//									: View.VISIBLE);
-//						}
-//					});
-//		}
-//		else
-//		{
-//			// The ViewPropertyAnimator APIs are not available, so simply show
-//			// and hide the relevant UI components.
-//			mLoginStatusView.setVisibility(show ? View.VISIBLE : View.GONE);
-//			mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
-//		}
-//	}
-//
-//	/**
-//	 * Represents an asynchronous login/registration task used to authenticate
-//	 * the user.
-//	 */
-//	public class UserLoginTask extends AsyncTask<Void, Void, Boolean>
-//	{
-//		@Override
-//		protected Boolean doInBackground(Void... params)
-//		{
-//
-//			m_db = dbUtil.OpenDB(LockerActivity.this, null, true);
-//
-//			Cursor cursor = m_db.query("users", new String[] { "pass", "_id" },
-//					"name= '" + m_sName + "'", null, null, null, "_id desc",
-//					null);
-//			if (cursor.moveToNext())
-//			{
-//				// user exist in local db;
-//				// Log.d(TAG, "USER "+m_sName+" exist!");
-//				String pass = cursor.getString(0);
-//				if (pass.equals(m_sPassword))
-//					return true;
-//				else
-//				{
-//					return false;// wrong password
-//				}
-//			}
-//			else
-//			{
-//				// user not exist in local db;
-//				try
-//				{
-//					// Simulate network access.
-//					Thread.sleep(2000);
-//				}
-//				catch (InterruptedException e)
-//				{
-//					return false;
-//				}
-//				// TODO: register the new account here.
-//				// online check user here;
-//				if (true)// check pass create user in local db;
-//				{
-//					ContentValues cv = new ContentValues();
-//					cv.put("name", m_sName);
-//					cv.put("pass", m_sPassword);
-//
-//					m_db.insert("users", null, cv);
-//
-//					return true;
-//
-//				}
-//				else
-//				{
-//					// no user exist on the server;
-//					return false;
-//				}
-//			}
-//		}
-//
-//		@Override
-//		protected void onPostExecute(final Boolean success)
-//		{
-//			mAuthTask = null;
-//			showProgress(false);
-//
-//			if (success)
-//			{
-//
-//				// SharedPreferences.Editor editor = RunOnce.edit();
-//				// editor.putBoolean("FirstRun"+globalUtil.getVerName(this),
-//				// false);
-//				// // Don't forget to commit your edits!!!
-//				// editor.commit();
-//
-//				Intent intent = new Intent();
-//				intent.putExtra("user", m_sName);
-//				/*
-//				 * ����setResult������ʾ�ҽ�Intent���󷵻ظ�֮ǰ���Ǹ�Activity�������Ϳ���
-//				 * ��onActivityResult�����еõ�Intent����
-//				 */
-//				setResult(Activity.RESULT_OK, intent);
-//				finish();
-//			}
-//			else
-//			{
-//				m_etPassword
-//						.setError(getString(R.string.error_incorrect_password));
-//				m_etPassword.requestFocus();
-//			}
-//		}
-//
-//		@Override
-//		protected void onCancelled()
-//		{
-//			mAuthTask = null;
-//			showProgress(false);
-//		}
-//	}
-}

+ 0 - 540
RA Image/app/src/main/java/com/usai/redant/raimage/LoginActivity.java

@@ -1,540 +0,0 @@
-package com.usai.redant.raimage;
-
-import com.usai.util.Crypto;
-import com.usai.util.Network;
-import com.usai.util.dbUtil;
-import com.usai.util.dbgUtil;
-//import com.example.com.apex.usa.test1.R.id;
-//import com.example.com.apex.usa.test1.R.layout;
-//import com.example.com.apex.usa.test1.R.menu;
-//import com.example.com.apex.usa.test1.R.string;
-
-import android.animation.Animator;
-import android.animation.AnimatorListenerAdapter;
-import android.annotation.TargetApi;
-import android.app.Activity;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.os.AsyncTask;
-import android.os.Build;
-import android.os.Bundle;
-import android.text.TextUtils;
-import android.util.Log;
-import android.view.Gravity;
-import android.view.KeyEvent;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.inputmethod.EditorInfo;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.ArrayAdapter;
-import android.widget.AutoCompleteTextView;
-import android.widget.CheckBox;
-import android.widget.EditText;
-import android.widget.TextView;
-import android.widget.Toast;
-
-/**
- * Activity which displays a login screen to the user, offering registration as
- * well.
- */
-public class LoginActivity extends Activity
-{
-
-	// public static final int ERR_CODE_NONE = 0;
-	// public static final int ERR_CODE_NULLRETURN = 1;
-	// public static final int ERR_CODE_NONETWORK = 2;
-
-	/**
-	 * A dummy authentication store containing known user names and passwords.
-	 * TODO: remove after connecting to a real authentication system.
-	 */
-	// private static final String[] DUMMY_CREDENTIALS = new String[] {
-	// "foo@example.com:hello", "bar@example.com:world" };
-
-	/**
-	 * The default email to populate the email field with.
-	 */
-	// public static final String EXTRA_EMAIL =
-	// "com.example.android.authenticatordemo.extra.EMAIL";
-	// public static final String EXTRA_USER = "Login_User";
-
-	/**
-	 * Keep track of the login task to ensure we can cancel it if requested.
-	 */
-	private UserLoginTask			mAuthTask	= null;
-	ArrayAdapter<String>			adapter		= null;
-	// SQLiteDatabase m_db;
-	// Values for email and password at the time of the login attempt.
-	private String					m_sName;
-	private String					m_sPassword;
-
-	// UI references.
-	private AutoCompleteTextView	m_etName;
-	private EditText				m_etPassword;
-	private View					mLoginFormView;
-	private View					mLoginStatusView;
-	private TextView				mLoginStatusMessageView;
-	private CheckBox				m_cbSave;
-
-	// @Override
-	// protected void onDestroy()
-	// {
-	// // TODO Auto-generated method stub
-	// // dbUtil.CloseDB(m_db);
-	// // super.onDestroy();
-	//
-	// }
-
-	@Override
-	protected void onCreate(Bundle savedInstanceState)
-	{
-		super.onCreate(savedInstanceState);
-
-		setContentView(R.layout.activity_login);
-
-		// Set up the login form.
-		// m_sName = getIntent().getStringExtra(EXTRA_USER);
-		m_etName = (AutoCompleteTextView) findViewById(R.id.name);
-
-		// m_etName.setText(m_sName);
-
-		m_etPassword = (EditText) findViewById(R.id.password);
-
-		m_cbSave = (CheckBox) findViewById(R.id.cb_save);
-		SharedPreferences pref = RedAntApplication.getInstance()
-				.getSharedPreferences("POP", 0);
-		String u = pref.getString("user", null);
-		String p = pref.getString("password", null);
-		if (u != null && p != null)
-		{
-			try
-			{
-				m_etName.setText(Crypto.decrypt("apexu", u));
-				m_etPassword.setText(Crypto.decrypt("apexp", p));
-				m_cbSave.setChecked(true);
-			}
-			catch (Exception e)
-			{
-				// TODO Auto-generated catch block
-				e.printStackTrace();
-			}
-
-		}
-
-		m_etPassword
-				.setOnEditorActionListener(new TextView.OnEditorActionListener()
-				{
-					@Override
-					public boolean onEditorAction(TextView textView, int id,
-							KeyEvent keyEvent)
-					{
-						if (id == R.id.login
-								|| id == EditorInfo.IME_ACTION_DONE)
-						{
-							InputMethodManager inputMethodManager = (InputMethodManager) getApplicationContext()
-									.getSystemService(INPUT_METHOD_SERVICE);
-
-							// EditText editText =
-							// (EditText)findViewById(R.id.xxxx);
-							inputMethodManager.hideSoftInputFromWindow(
-									m_etPassword.getWindowToken(), 0); // ����
-							attemptLogin();
-							return true;
-						}
-						return false;
-					}
-				});
-
-		mLoginFormView = findViewById(R.id.login_form);
-		mLoginStatusView = findViewById(R.id.login_status);
-		mLoginStatusMessageView = (TextView) findViewById(R.id.login_status_message);
-
-		findViewById(R.id.sign_in_button).setOnClickListener(
-				new View.OnClickListener()
-				{
-					@Override
-					public void onClick(View view)
-					{
-						attemptLogin();
-					}
-				});
-		adapter = new ArrayAdapter<String>(this,
-				android.R.layout.simple_list_item_1, dbUtil.get_userlist());
-		m_etName.setAdapter(adapter);
-		
-		if(TextUtils.isEmpty(RedAntApplication.station_name))
-		{
-			Intent intent = new Intent();
-			intent.setClass(LoginActivity.this,ServerSettingActivity.class);
-			startActivity(intent);			
-		}
-	}
-
-	@Override
-	public boolean onCreateOptionsMenu(Menu menu)
-	{
-		super.onCreateOptionsMenu(menu);
-		getMenuInflater().inflate(R.menu.login, menu);
-		return true;
-	}
-
-	@Override
-	public boolean onOptionsItemSelected(MenuItem item)
-	{
-		// TODO Auto-generated method stub
-		switch (item.getItemId())
-		{
-			case R.id.action_about:
-			{
-				Intent intent = new Intent();
-				intent.setClass(LoginActivity.this, AboutActivity.class);
-				startActivity(intent);
-
-			}
-				break;
-			case R.id.action_server_settings:
-			{
-				Intent intent = new Intent();
-				intent.setClass(LoginActivity.this,ServerSettingActivity.class);
-				startActivity(intent);
-
-			}
-				break;
-			default:
-				break;
-		}
-		return super.onOptionsItemSelected(item);
-	}
-
-	/**
-	 * Attempts to sign in or register the account specified by the login form.
-	 * If there are form errors (invalid email, missing fields, etc.), the
-	 * errors are presented and no actual login attempt is made.
-	 */
-	public void attemptLogin()
-	{
-		if (mAuthTask != null)
-		{
-			return;
-		}
-
-		// Reset errors.
-		m_etName.setError(null);
-		m_etPassword.setError(null);
-
-		// Store values at the time of the login attempt.
-		m_sName = m_etName.getText().toString();
-		m_sPassword = m_etPassword.getText().toString();
-
-		boolean cancel = false;
-		View focusView = null;
-
-		// Check for a valid password.
-		if (TextUtils.isEmpty(m_sPassword))
-		{
-			m_etPassword.setError(getString(R.string.error_field_required));
-			focusView = m_etPassword;
-			cancel = true;
-		}
-		else if (m_sPassword.length() < 4)
-		{
-			m_etPassword.setError(getString(R.string.error_invalid_password));
-			focusView = m_etPassword;
-			cancel = true;
-		}
-
-		// Check for a valid user name.
-		if (TextUtils.isEmpty(m_sName))
-		{
-			m_etName.setError(getString(R.string.error_field_required));
-			focusView = m_etName;
-			cancel = true;
-		}
-		// else if (!m_sName.contains("@")) {
-		// m_etName.setError(getString(R.string.error_invalid_email));
-		// focusView = m_etName;
-		// cancel = true;
-		// }
-
-		if (cancel)
-		{
-			// There was an error; don't attempt login and focus the first
-			// form field with an error.
-			focusView.requestFocus();
-		}
-		else
-		{
-			// Show a progress spinner, and kick off a background task to
-			// perform the user login attempt.
-			mLoginStatusMessageView.setText(R.string.login_progress_signing_in);
-			showProgress(true);
-			mAuthTask = new UserLoginTask();
-			mAuthTask.execute((Void) null);
-		}
-	}
-
-	/**
-	 * Shows the progress UI and hides the login form.
-	 */
-	@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
-	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)
-		{
-			int shortAnimTime = getResources().getInteger(
-					android.R.integer.config_shortAnimTime);
-
-			mLoginStatusView.setVisibility(View.VISIBLE);
-			mLoginStatusView.animate().setDuration(shortAnimTime)
-					.alpha(show ? 1 : 0)
-					.setListener(new AnimatorListenerAdapter()
-					{
-						@Override
-						public void onAnimationEnd(Animator animation)
-						{
-							mLoginStatusView.setVisibility(show ? View.VISIBLE
-									: View.GONE);
-						}
-					});
-
-			mLoginFormView.setVisibility(View.VISIBLE);
-			mLoginFormView.animate().setDuration(shortAnimTime)
-					.alpha(show ? 0 : 1)
-					.setListener(new AnimatorListenerAdapter()
-					{
-						@Override
-						public void onAnimationEnd(Animator animation)
-						{
-							mLoginFormView.setVisibility(show ? View.GONE
-									: View.VISIBLE);
-						}
-					});
-		}
-		else
-		{
-			// The ViewPropertyAnimator APIs are not available, so simply show
-			// and hide the relevant UI components.
-			mLoginStatusView.setVisibility(show ? View.VISIBLE : View.GONE);
-			mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
-		}
-	}
-
-	/**
-	 * Represents an asynchronous login/registration task used to authenticate
-	 * the user.
-	 */
-	public class UserLoginTask extends AsyncTask<Void, Void, Boolean>
-	{
-		// int err_code = ERR_CODE_NONE;
-		int	verifyuser	= Network.RESULT_TRUE;
-
-		// int netconnect;
-
-		@Override
-		protected Boolean doInBackground(Void... params)
-		{
-
-			verifyuser = Network.VerifyUser(m_sName, m_sPassword);
-			if (verifyuser == Network.RESULT_TRUE)
-				return true;
-			else
-				return false;
-		}
-
-		@Override
-		protected void onPostExecute(final Boolean success)
-		{
-			Log.i("onPostExecute", "entry");
-			mAuthTask = null;
-			showProgress(false);
-
-			if (success)
-			{
-				String encryptUser = "";
-				String encryptPass = "";
-				try
-				{
-					encryptUser = Crypto.encrypt("apexu", m_sName);
-					encryptPass = Crypto.encrypt("apexp", m_sPassword);
-				}
-				catch (Exception e1)
-				{
-					// TODO Auto-generated catch block
-					e1.printStackTrace();
-				}
-
-				SQLiteDatabase db = dbUtil.OpenDB(LoginActivity.this, null,
-						true);
-				Cursor cursor = db.query("users", new String[] { "_id" },
-						"name='" + encryptUser + "'", null, null, null, "_id",
-						null);
-				if (cursor.moveToNext())
-				{
-					int _id = cursor.getInt(0);
-					String sql = "update users set pass='" + encryptPass
-							+ "' where _id=" + _id;
-					db.execSQL(sql);
-				}
-				else
-				{
-					String sql = "insert into users(name,pass) values('"
-							+ encryptUser + "','" + encryptPass + "')";
-					db.execSQL(sql);
-				}
-				dbUtil.CloseCursor(cursor);
-				dbUtil.CloseDB(db);
-
-				SharedPreferences pref = RedAntApplication.getInstance()
-						.getSharedPreferences("POP", 0);
-				SharedPreferences.Editor editor = pref.edit();
-
-				if (m_cbSave.isChecked()&&!TextUtils.isEmpty(encryptPass)&&!TextUtils.isEmpty(encryptUser))
-				{
-					editor.putString("user", encryptUser);
-					editor.putString("password", encryptPass);
-					editor.putBoolean("kepppass", true);
-				}
-				else
-				{
-					editor.putString("user", null);
-					editor.putString("password", null);
-					editor.putBoolean("kepppass", false);
-				}
-
-				editor.commit();
-
-				RedAntApplication.user = m_sName;
-				RedAntApplication.password = m_sPassword;
-				Intent intent = new Intent();
-				intent.setClass(LoginActivity.this, MainActivity.class);
-
-				dbgUtil.fileLog("user "+m_sName+" login @server "+RedAntApplication.active_address);
-				startActivity(intent);
-				finish();
-			}
-			else
-			{
-				switch (verifyuser)
-				{
-					case Network.RESULT_NET_ERROR:
-					case Network.RESULT_NET_NOTAVAILABLE:
-					{
-						SQLiteDatabase db = dbUtil.OpenDB(LoginActivity.this,
-								null, true);
-
-						String encryptUser = "";
-						try
-						{
-							encryptUser = Crypto.encrypt("apexu", m_sName);
-						}
-						catch (Exception e1)
-						{
-							// TODO Auto-generated catch block
-							e1.printStackTrace();
-						}
-						Cursor cursor = db.query("users", new String[] {
-								"pass", "_id" }, "name= '" + encryptUser + "'",
-								null, null, null, "_id desc", null);
-						if (cursor.moveToNext())
-						{
-							String pass = "";
-							try
-							{
-								pass = Crypto.decrypt("apexp",
-										cursor.getString(0));
-							}
-							catch (Exception e)
-							{
-								// TODO Auto-generated catch block
-								e.printStackTrace();
-							}
-							if (pass.equals(m_sPassword))
-							{
-								dbUtil.CloseCursor(cursor);
-								dbUtil.CloseDB(db);
-								RedAntApplication.user = m_sName;
-								RedAntApplication.password = m_sPassword;
-								Intent intent = new Intent();
-								intent.setClass(LoginActivity.this,
-										MainActivity.class);
-								dbgUtil.fileLog("user "+m_sName+" offline access @server "+RedAntApplication.active_address);
-								startActivity(intent);
-								finish();
-							}
-							else
-							{
-								// wrong password
-								Toast toast = Toast.makeText(
-										getApplicationContext(),
-										getText(R.string.msg_user_wrong),
-										Toast.LENGTH_LONG);
-								toast.setGravity(Gravity.CENTER, 0, 0);
-								toast.show();
-								m_etPassword
-										.setError(getString(R.string.error_incorrect_password));
-								m_etPassword.requestFocus();
-								dbUtil.CloseCursor(cursor);
-								dbUtil.CloseDB(db);
-							}
-						}
-						else
-						{// user not exist
-							Toast toast = Toast.makeText(
-									getApplicationContext(),
-									getText(R.string.msg_net_error),
-									Toast.LENGTH_LONG);
-							toast.setGravity(Gravity.CENTER, 0, 0);
-							toast.show();
-							m_etPassword
-									.setError(getString(R.string.error_incorrect_password));
-							m_etPassword.requestFocus();
-							dbUtil.CloseCursor(cursor);
-							dbUtil.CloseDB(db);
-
-						}
-
-						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();
-					// return;
-					// }
-					case Network.RESULT_FALSE:
-					{
-						Toast toast = Toast.makeText(getApplicationContext(),
-								getText(R.string.msg_user_wrong),
-								Toast.LENGTH_LONG);
-						toast.setGravity(Gravity.CENTER, 0, 0);
-						toast.show();
-						m_etPassword
-								.setError(getString(R.string.error_incorrect_password));
-						m_etPassword.requestFocus();
-						return;
-					}
-
-					default:
-						break;
-				}
-
-			}
-		}
-
-		@Override
-		protected void onCancelled()
-		{
-			mAuthTask = null;
-			showProgress(false);
-		}
-	}
-}

+ 0 - 133
RA Image/app/src/main/java/com/usai/util/Crypto.java

@@ -1,133 +0,0 @@
-package com.usai.util;
-
-import java.security.SecureRandom;
-
-import javax.crypto.Cipher;
-import javax.crypto.KeyGenerator;
-import javax.crypto.SecretKey;
-import javax.crypto.spec.SecretKeySpec;
-
-/**
- * Usage:
- * 
- * <pre>
- * String crypto = Crypto.encrypt(masterpassword, cleartext) 
- * ... 
- * String cleartext = Crypto.decrypt(masterpassword, crypto)
- * </pre>
- * 
- * @author ferenc.hechler
- */
-public class Crypto
-{
-//    public static SecretKeySpec setSecretKey(String password) throws Exception {
-//        SecretKeySpec key = null;
-//        KeyGenerator kgen = KeyGenerator.getInstance(ALGORITHM);
-//        SecureRandom sr = SecureRandom.getInstance("SHA1PRNG", "Crypto");
-//        sr.setSeed(password.getBytes());
-//        kgen.init(128, sr);
-//        SecretKey secretKey = kgen.generateKey();
-//        byte[] enCodeFormat = secretKey.getEncoded();
-//        key = new SecretKeySpec(enCodeFormat, SecretKeySpec.ALGORITHM);
-//
-//        return key;
-//    }
-
-	public static String encrypt(String seed, String cleartext)
-			throws Exception
-	{
-		byte[] rawKey = getRawKey(seed.getBytes());
-		byte[] result = encrypt(rawKey, cleartext.getBytes());
-		return toHex(result);
-	}
-
-	public static String decrypt(String seed, String encrypted)
-			throws Exception
-	{
-		byte[] rawKey = getRawKey(seed.getBytes());
-		byte[] enc = toByte(encrypted);
-		byte[] result = decrypt(rawKey, enc);
-		return new String(result);
-	}
-
-	private static byte[] getRawKey(byte[] seed) throws Exception
-	{
-		
-        KeyGenerator kgen = KeyGenerator.getInstance("AES");
-        SecureRandom sr = SecureRandom.getInstance("SHA1PRNG", "Crypto");
-        sr.setSeed(seed);
-        kgen.init(128, sr);
-        SecretKey secretKey = kgen.generateKey();	
-        byte[] enCodeFormat = secretKey.getEncoded();
-//        key = new SecretKeySpec(enCodeFormat, SecretKeySpec.ALGORITHM);
-        return enCodeFormat;
-//
-//        return key;	
-//		KeyGenerator kgen = KeyGenerator.getInstance("AES");
-//		SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
-//		sr.setSeed(seed);
-//		kgen.init(128, sr); // 192 and 256 bits may not be available
-//		SecretKey skey = kgen.generateKey();
-//		byte[] raw = skey.getEncoded();
-//		return raw;
-	}
-
-	private static byte[] encrypt(byte[] raw, byte[] clear) throws Exception
-	{
-		SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
-		Cipher cipher = Cipher.getInstance("AES");
-		cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
-		byte[] encrypted = cipher.doFinal(clear);
-		return encrypted;
-	}
-
-	private static byte[] decrypt(byte[] raw, byte[] encrypted)
-			throws Exception
-	{
-		SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
-		Cipher cipher = Cipher.getInstance("AES");
-		cipher.init(Cipher.DECRYPT_MODE, skeySpec);
-		byte[] decrypted = cipher.doFinal(encrypted);
-		return decrypted;
-	}
-
-	public static String toHex(String txt)
-	{
-		return toHex(txt.getBytes());
-	}
-
-	public static String fromHex(String hex)
-	{
-		return new String(toByte(hex));
-	}
-
-	public static byte[] toByte(String hexString)
-	{
-		int len = hexString.length() / 2;
-		byte[] result = new byte[len];
-		for (int i = 0; i < len; i++)
-			result[i] = Integer.valueOf(hexString.substring(2 * i, 2 * i + 2),
-					16).byteValue();
-		return result;
-	}
-
-	public static String toHex(byte[] buf)
-	{
-		if (buf == null)
-			return "";
-		StringBuffer result = new StringBuffer(2 * buf.length);
-		for (int i = 0; i < buf.length; i++)
-		{
-			appendHex(result, buf[i]);
-		}
-		return result.toString();
-	}
-
-	private final static String HEX = "0123456789ABCDEF";
-
-	private static void appendHex(StringBuffer sb, byte b)
-	{
-		sb.append(HEX.charAt((b >> 4) & 0x0f)).append(HEX.charAt(b & 0x0f));
-	}
-
-}

+ 0 - 536
RA Image/app/src/main/java/com/usai/util/dbUtil.java

@@ -1,536 +0,0 @@
-package com.usai.util;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.usai.redant.raimage.RedAntApplication;
-
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteDatabase.CursorFactory;
-import android.database.sqlite.SQLiteException;
-import android.net.Uri;
-import android.util.Log;
-
-public class dbUtil
-{
-
-	// public static final String ZONECODE
-	// public static final int FILTER_TYPE_MSG = 0;
-	// public static final int FILTER_TYPE_BOTH = 1;
-	// public static final int FILTER_TYPE_CALL = 2;
-
-	// public static final int RECORD_TYPE_CALL = 2;
-	// public static final int RECORD_TYPE_MSG = 1;
-	//
-	// public static final int NUMBER_TYPE_NULL = 0;
-	// public static final int NUMBER_TYPE_NORMAL = 1;
-	// public static final int NUMBER_TYPE_BLACK = 2;
-	// public static final int NUMBER_TYPE_WHITE = 3;
-	// public static final int NUMBER_TYPE_GRAY = 4;
-	// public static final int NUMBER_TYPE_UNKNOWN = 7;
-
-	// public static final int NUMBER_TYPE_CONTACT = 5;
-	// public static final int NUMBER_TYPE_SUSPECT = 6;
-
-	// public static final int FILTER_SOURCE_BLACKLIST = 0;
-	// public static final int FILTER_SOURCE_SINGLERING = 1;
-	// public static final int FILTER_SOURCE_KEYWORDS = 2;
-	// public static final int FILTER_SOURCE_NONUMBER = 3;
-
-	// public static void AddNumberToBlacklist(Context context, String Number) {
-	// SQLiteDatabase db;
-	// db = dbUtil.OpenDB(context, null, true);
-	// boolean bexist = isRecordExist(db, "user_numberlist", "number = '"
-	// + Number + "'");
-	// if (bexist == false) {
-	// ContentValues cv = new ContentValues();
-	// cv.put("number", Number);
-	// cv.put("type", dbUtil.NUMBER_TYPE_BLACK);
-	// cv.put("burntype", 3);
-	// cv.put("cimm", PhoneNumberUtils.toCallerIDMinMatch(Number));
-	// db.insert("user_numberlist", null, cv);
-	// }
-	// dbUtil.CloseDB(db);
-	// }
-
-	// public static int KeywordsFilter(Context context, String Msg) {
-	// int ret = -1;
-	// boolean bKeywordsFilter = context.getSharedPreferences("PhoneAsstPref",
-	// 0).getBoolean("KeywordsFilterPref", false);
-	//
-	// // = context.getSharedPreferences("PhoneAsstPref", 0)
-	// // .getBoolean("BlockUnknownNumber", false);
-	// if (bKeywordsFilter == false)
-	// return ret;
-	// SQLiteDatabase db = dbUtil.OpenDB(context, null, true);
-	//
-	// Cursor cursor = null;
-	// try {
-	//
-	// cursor = db.query("user_keywords", new String[] { "_id", "words" },
-	// null, null, null, null, "level desc", null);
-	//
-	// while (cursor.moveToNext()) {
-	// String keywords = cursor.getString(1);
-	// String[] spliter = keywords.split(" ");
-	//
-	// if (spliter.length == 0)
-	// continue;
-	//
-	// int ifound = spliter.length; // 关键字个数
-	// for (int idx = 0; idx < spliter.length; idx++) {
-	// // 兼容以前版本关键字有多空格情况;
-	// if (spliter[idx].equals("")) {
-	// ifound--; // 排除误计算的空数量
-	// continue;
-	// }
-	//
-	// if (Msg.indexOf(spliter[idx]) != -1) {
-	// ifound--;
-	// }
-	// }
-	// if (ifound == 0) {
-	// int id = cursor.getInt(0);
-	// db.execSQL("update " + "user_keywords"
-	// + " set level = level+1 where _id=" + id);
-	// ret = id;
-	// break;// break while
-	// }
-	//
-	// }
-	// } catch (SQLiteException e) {
-	// dbgUtil.Log(Log.ERROR, "sql_err", e.toString());
-	// } finally {
-	// dbUtil.CloseCursor(cursor);
-	// dbUtil.CloseDB(db);
-	// }
-	// return ret;
-	// }
-
-	// public static final int NUMBER_TYPE_UNKNOWN = 5;//no number ,hide number
-	// ect;
-	public static boolean isContentExist(Context context, Uri uri, String where)
-	{
-		boolean ret;
-		Cursor cursor = context.getContentResolver().query(uri, null, where,
-				null, null);
-		dbgUtil.dbgCursorInfo(cursor, context);
-		if (cursor.moveToNext())
-			ret = true;
-		else
-			ret = false;
-
-		dbUtil.CloseCursor(cursor);
-		return ret;
-	}
-
-	// public static int query_NumberType(SQLiteDatabase db, String number) {
-	// String cimm = PhoneNumberUtils.toCallerIDMinMatch(number);
-	// int ret = -1;
-	// Cursor cursor = db.query("user_numberlist", new String[] { "type",
-	// "number" }, "cimm = '" + cimm + "'", null, null, null, null);
-	// while (cursor.moveToNext()) {
-	// if (PhoneNumberUtils.compare(number, cursor.getString(1))) {
-	// dbgUtil.Log(
-	// Log.ERROR,
-	// "QUERY FROM user_numberlist",
-	// number + "=" + cursor.getString(1) + "type="
-	// + cursor.getInt(0));
-	// ret = cursor.getInt(0);
-	// break;
-	// }
-	// }
-	// CloseCursor(cursor);
-	// return ret;
-	// }
-
-	// static boolean isContact(Context context, String number) {
-	// // String cimm=PhoneNumberUtils.toCallerIDMinMatch(number);
-	// return dbUtil.isContentExist(context,
-	// // ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
-	// Uri.withAppendedPath(
-	// ContactsContract.PhoneLookup.CONTENT_FILTER_URI,
-	// Uri.encode(number)),
-	// // ContactsContract.CommonDataKinds.Phone.NUMBER + "= '" +
-	// // number+ "'");
-	// /* "min_match = '" + cimm+ "'" */null);
-	// }
-
-	// static boolean isSuspect(SQLiteDatabase db, String number) {
-	// return dbUtil.isRecordExist(db, "user_suspectlist", "number = '"
-	// + number + "'");
-	// }
-
-	// public static int get_CallNumberType_old(Context context,
-	// String incomingNumber)
-	// {
-	// int type = NUMBER_TYPE_NULL;
-	// SQLiteDatabase db = dbUtil.OpenDB(context, null, true);
-	//
-	// boolean bBlockUnknown = context
-	// .getSharedPreferences("PhoneAsstPref", 0).getBoolean(
-	// "BlockUnknownNumber", false);
-	// boolean bignorcontact = context
-	// .getSharedPreferences("PhoneAsstPref", 0).getBoolean(
-	// "IgnoreContact", false);
-
-	// if ((incomingNumber == null || incomingNumber.equals("")))
-	// if (bBlockUnknown)
-	// type = NUMBER_TYPE_BLACK;
-	// else
-	// type = NUMBER_TYPE_NORMAL;
-	// else
-	// {
-	// type = query_NumberType(db, incomingNumber);
-	// if (type == NUMBER_TYPE_WHITE)
-	// {
-	//
-	// }
-	// else
-	// if (bignorcontact && isContact(context, incomingNumber))
-	// {
-	// type = NUMBER_TYPE_CONTACT;
-	// dbgUtil.Log(Log.ERROR,null, "number type contact");
-	// }
-	// else
-	// if (type == NUMBER_TYPE_BLACK)
-	// {
-	// }
-	// else
-	// if (dbUtil.isRecordExist(db, "user_suspectlist",
-	// "number = '" + incomingNumber + "'"))
-	// {
-	// type = NUMBER_TYPE_SUSPECT;
-	// }
-	// else
-	// {
-	// type = NUMBER_TYPE_NORMAL;
-	//
-	// }
-	// }
-	// dbUtil.CloseDB(db);
-	//
-	// dbgUtil.Log(Log.ERROR,"get_CallNumberType",
-	// "number="+incomingNumber+" type="+type);
-	// return type;
-	//
-	// }
-
-	// public static NumberInfo get_NumberInfo(Context context,
-	// String incomingNumber)
-	// {
-	// NumberInfo numberInfo = new NumberInfo();
-	// numberInfo.incomingNumber = incomingNumber;
-	// SQLiteDatabase db = dbUtil.OpenDB(context, null, true);
-	//
-	// // boolean bBlockUnknown = context
-	// // .getSharedPreferences("PhoneAsstPref", 0).getBoolean(
-	// // "BlockUnknownNumber", false);
-	// // boolean bignorcontact = context
-	// // .getSharedPreferences("PhoneAsstPref", 0).getBoolean(
-	// // "IgnoreContact", false);
-	//
-	// // int type = NUMBER_TYPE_NULL;
-	// if (incomingNumber == null || incomingNumber.length() < 3)
-	// {
-	// numberInfo.BaseType = NUMBER_TYPE_UNKNOWN;
-	// }
-	// else
-	// {
-	// numberInfo.BaseType = query_NumberType(db, incomingNumber);
-	// if (numberInfo.BaseType == -1)// not in user_numberlist;
-	// {
-	// numberInfo.BaseType = NUMBER_TYPE_NORMAL;
-	//
-	// // else
-	// // if (isSuspect(db, incomingNumber))
-	// // {
-	// // type = NUMBER_TYPE_SUSPECT;
-	// //
-	// // }
-	// // else
-	// // {
-	// // type = NUMBER_TYPE_NORMAL;
-	// // }
-	// }
-	// if (isContact(context, incomingNumber))
-	// {
-	// numberInfo.isContact = true;
-	// // type = NUMBER_TYPE_CONTACT;
-	// }
-	// if (isSuspect(db, incomingNumber))
-	// {
-	// numberInfo.isSuspect = true;
-	//
-	// }
-	//
-	// // else
-	// // if (type == NUMBER_TYPE_BLACK)
-	// // {
-	// // if (isContact(context, incomingNumber))
-	// // {
-	// // type = NUMBER_TYPE_CONTACT;
-	// // }
-	// // }
-	// }
-	// dbUtil.CloseDB(db);
-	//
-	// dbgUtil.Log(Log.ERROR, "get_NumberInfo", "number=" + incomingNumber
-	// + " type=" + numberInfo.BaseType);
-	// return numberInfo;
-	//
-	// }
-
-	// public static int get_SmsNumberType(Context context, String
-	// incomingNumber)
-	// {
-	// SQLiteDatabase db = dbUtil.OpenDB(context, null, false);
-	//
-	// boolean bBlockUnknown = context
-	// .getSharedPreferences("PhoneAsstPref", 0).getBoolean(
-	// "BlockUnknownNumber", false);
-	// boolean bignorcontact = context
-	// .getSharedPreferences("PhoneAsstPref", 0).getBoolean(
-	// "IgnoreContact", false);
-	//
-	// int type = NUMBER_TYPE_NULL;
-	// if ((incomingNumber == null || incomingNumber.equals("")))
-	// if (bBlockUnknown)
-	// type = NUMBER_TYPE_BLACK;
-	// else
-	// type = NUMBER_TYPE_NORMAL;
-	// else
-	// {
-	// type = query_NumberType(db, incomingNumber);
-	// if (type == NUMBER_TYPE_WHITE)
-	// {
-	//
-	// }
-	// else
-	// if (bignorcontact && isContact(context, incomingNumber))
-	// {
-	// type = NUMBER_TYPE_CONTACT;
-	// dbgUtil.Log(Log.ERROR, null, "number type contact");
-	// }
-	// else
-	// if (type == NUMBER_TYPE_BLACK)
-	// {
-	// }
-	// else
-	// {
-	// type = NUMBER_TYPE_NORMAL;
-	//
-	// }
-	// }
-	// dbUtil.CloseDB(db);
-	//
-	// return type;
-	//
-	// }
-
-	public static void CloseDB(SQLiteDatabase db)
-	{
-		if (db == null)
-			return;
-		if (db.isOpen() == false)
-			return;
-		db.close();
-		return;
-
-	}
-
-	public static void CloseCursor(Cursor c)
-	{
-		if (c == null)
-			return;
-		if (c.isClosed())
-			return;
-		c.close();
-		return;
-
-	}
-
-	public static SQLiteDatabase OpenDB(Context context, CursorFactory factory,
-			boolean writable)
-	{
-
-		SqlOpenHelper dbHelper = new SqlOpenHelper(context, "redantpop.db",
-				factory, 2);
-		dbHelper.addInitSQL("create table users (" + "_id INTEGER PRIMARY KEY,"
-				+ "name varchar(20)," + "pass varchar(20))");
-
-		// dbHelper.addInitSQL("create table scan_records ("
-		// + "_id INTEGER PRIMARY KEY," + "submit BOOLEAN DEFAULT (0),"
-		// + "picker VARCHAR(20)," + "pid varchar(20))");
-
-		dbHelper.addInitSQL("create table pics (" + "_id INTEGER PRIMARY KEY,"
-				+ "picker varchar(20)," + "server varchar(20),"+ "err_code INTEGER ,"
-				+ "pid varchar(20),"+ "try_count INTEGER DEFAULT (0)," + "local_path varchar(256))");
-		
-//		dbHelper.addInitSQL("create table pids (" + "_id INTEGER PRIMARY KEY,"
-//				+ "picker varchar(20)," + "err_code INTEGER ,"
-//				+ "pid varchar(20))");
-
-		SQLiteDatabase db = dbHelper.OpenDB(writable);
-		return db;
-	}
-
-	public static void removeRecords(SQLiteDatabase db, String table,
-			String whereclause)
-	{
-		db.execSQL("delete from " + table + " where " + whereclause);
-	}
-
-	public static long addRecordsFromCursor(SQLiteDatabase db,
-			String tablename, Cursor source, String[] from, String[] to,
-			boolean dumpPrimaryKey, boolean dumpOneRecord)
-	{
-		int ret = -1;
-		ContentValues cv = new ContentValues();
-
-		if (from == null)
-			from = source.getColumnNames();
-
-		if (to == null)
-			to = source.getColumnNames();
-
-		if (from.length != to.length)// 字段数不匹配
-			return ret;
-
-		while (source.moveToNext())
-		{
-
-			for (int i = 0; i < from.length; i++)
-			{
-				if (from[i].equals("_id"))
-				{
-					if (dumpPrimaryKey)
-						cv.put(to[i], source.getInt(i));
-				}
-				else
-				{
-					cv.put(to[i], source.getString(i));
-				}
-
-			}
-			db.insert(tablename, null, cv);
-
-			if (dumpOneRecord)
-				break;
-		}
-
-		ret = 1;
-		return ret;
-
-	}
-
-	// public static long addRecord(SQLiteDatabase db, String table,
-	// ContentValues record)
-	// {
-	// long ret = -1;
-	// try
-	// {
-	// ret = db.insert(table, null, record);
-	// }
-	// catch (SQLiteException e)
-	// {
-	// dbgUtil.Log(Log.ERROR,"sql_err", e.toString());
-	//
-	// }
-	// return ret;
-	// }
-	public static List<String> get_userlist()
-	{
-		List<String> ret = new ArrayList<String>();
-		SQLiteDatabase db = OpenDB(RedAntApplication.getInstance()
-				.getApplicationContext(), null, false);
-		Cursor cursor = db.query(
-				"users",
-				new String[] { "name" },
-				null, null, null,
-				null, "name desc", null);
-
-		while (cursor.moveToNext())
-		{
-			String user="";
-			try
-			{
-				user = Crypto.decrypt("apexu", cursor.getString(0));
-			}
-			catch (Exception e)
-			{
-				// TODO Auto-generated catch block
-				e.printStackTrace();
-			}
-			ret.add(user);
-
-		}
-
-		CloseCursor(cursor);
-		CloseDB(db);
-		return ret;
-	}
-	public static boolean isTableEmpty(SQLiteDatabase db, String table)
-	{
-		boolean ret = true;
-
-		Cursor cursor = null;
-		try
-		{
-
-			cursor = db.query(table, new String[] { "*" }, null, null, null,
-					null, null, "1");
-			if (cursor.moveToNext())
-			{
-				// cursor.close();
-				ret = false;
-			}
-			else
-				ret = true;
-		}
-		catch (SQLiteException e)
-		{
-			Log.e("sql_err", e.toString());
-		}
-		finally
-		{
-			dbUtil.CloseCursor(cursor);
-		}
-		return ret;
-	}
-
-	public static boolean isRecordExist(SQLiteDatabase db, String table,
-			String where)
-	{
-		boolean ret = false;
-		Cursor cursor = null;
-		try
-		{
-
-			cursor = db.query(table, new String[] { "_id" }, where, null, null,
-					null, null, null);
-			if (cursor.moveToNext())
-				ret = true;
-			else
-				ret = false;
-		}
-		catch (SQLiteException e)
-		{
-			Log.e("sql_err", e.toString());
-
-		}
-		finally
-		{
-
-			dbUtil.CloseCursor(cursor);
-		}
-		return ret;
-
-	}
-
-	// if(isTableEmpty(db,"block_records"))
-
-}

+ 0 - 78
RA Image/app/src/main/res/layout/activity_locker.xml

@@ -1,78 +0,0 @@
-<merge xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    tools:context=".LockerActivity" >
-
-    <!-- Login progress -->
-
-    <LinearLayout
-        android:id="@+id/login_status"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_gravity="center"
-        android:gravity="center_horizontal"
-        android:orientation="vertical"
-        android:visibility="gone" >
-
-        <ProgressBar
-            style="?android:attr/progressBarStyleLarge"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginBottom="8dp" />
-
-        <TextView
-            android:id="@+id/login_status_message"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginBottom="16dp"
-            
-            android:text="@string/login_progress_signing_in"
-            android:textAppearance="?android:attr/textAppearanceMedium" />
-    </LinearLayout>
-
-    <!-- Login form -->
-
-    <ScrollView
-        android:id="@+id/login_form"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent" >
-
-        <LinearLayout
-            style="@style/LoginFormContainer"
-            android:orientation="vertical" >
-
-            <AutoCompleteTextView
-                android:id="@+id/name"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:imeOptions="flagNoExtractUi"
-                android:hint="@string/prompt_Name"
-                android:inputType="textAutoComplete"
-                android:maxLines="1"
-                android:singleLine="true" />
-
-            <EditText
-                android:id="@+id/password"
-                android:layout_width="match_parent"
-                android:imeOptions="flagNoExtractUi"
-                android:layout_height="wrap_content"
-                android:hint="@string/prompt_password"
-                android:imeActionId="@+id/locker"
-                android:imeActionLabel="@string/action_sign_in_short"
-
-                android:inputType="textPassword"
-                android:maxLines="1"
-                android:singleLine="true" />
-
-            <Button
-                android:id="@+id/sign_in_button"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_gravity="right"
-                android:layout_marginTop="16dp"
-                android:paddingLeft="32dp"
-                android:paddingRight="32dp"
-                android:text="@string/action_sign_in_short" />
-        </LinearLayout>
-    </ScrollView>
-
-</merge>

+ 0 - 96
RA Image/app/src/main/res/layout/activity_login.xml

@@ -1,96 +0,0 @@
-<merge xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    tools:context=".LoginActivity" >
-
-    <!-- Login progress -->
-
-    <LinearLayout
-        android:id="@+id/login_status"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_gravity="center"
-        android:gravity="center_horizontal"
-        android:orientation="vertical"
-        android:visibility="invisible">
-
-        <ProgressBar
-            style="?android:attr/progressBarStyleLarge"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginBottom="8dp" />
-
-        <TextView
-            android:id="@+id/login_status_message"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginBottom="16dp"
-
-            android:text="@string/login_progress_signing_in"
-            android:textAppearance="?android:attr/textAppearanceMedium" />
-    </LinearLayout>
-
-    <!-- Login form -->
-
-    <ScrollView
-        android:id="@+id/login_form"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:visibility="visible">
-
-        <LinearLayout
-            style="@style/LoginFormContainer"
-            android:orientation="vertical">
-
-            <AutoCompleteTextView
-                android:id="@+id/name"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:hint="@string/prompt_Name"
-                android:imeOptions="flagNoExtractUi"
-                android:inputType="textAutoComplete"
-                android:maxLines="1"
-                android:singleLine="true"
-                android:text="" />
-
-            <EditText
-                android:id="@+id/password"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:hint="@string/prompt_password"
-                android:imeActionId="@+id/login"
-                android:imeActionLabel="@string/action_sign_in_short"
-                android:imeOptions="flagNoExtractUi"
-                android:inputType="textPassword"
-                android:maxLines="1"
-                android:singleLine="true"
-                android:text="" />
-
-            <RelativeLayout
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_marginTop="16dp">
-
-                <CheckBox
-                    android:id="@+id/cb_save"
-                    android:layout_width="wrap_content"
-                    android:layout_height="match_parent"
-                    android:layout_alignParentLeft="true"
-                    android:layout_centerVertical="true"
-
-                    android:text="@string/str_savepass" />
-
-                <Button
-                    android:id="@+id/sign_in_button"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:layout_alignParentRight="true"
-                    android:layout_alignParentTop="true"
-                    android:gravity="right|center_vertical"
-                    android:paddingLeft="32dp"
-                    android:paddingRight="32dp"
-                    android:text="@string/action_sign_in_short" />
-            </RelativeLayout>
-        </LinearLayout>
-    </ScrollView>
-
-</merge>