diff --git a/src/Logistics/.gitignore b/src/Logistics/.gitignore new file mode 100644 index 0000000..aa724b7 --- /dev/null +++ b/src/Logistics/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/src/Logistics/.idea/.gitignore b/src/Logistics/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/src/Logistics/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/src/Logistics/.idea/compiler.xml b/src/Logistics/.idea/compiler.xml new file mode 100644 index 0000000..fb7f4a8 --- /dev/null +++ b/src/Logistics/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/Logistics/.idea/deploymentTargetDropDown.xml b/src/Logistics/.idea/deploymentTargetDropDown.xml new file mode 100644 index 0000000..ccd930c --- /dev/null +++ b/src/Logistics/.idea/deploymentTargetDropDown.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Logistics/.idea/gradle.xml b/src/Logistics/.idea/gradle.xml new file mode 100644 index 0000000..526b4c2 --- /dev/null +++ b/src/Logistics/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/src/Logistics/.idea/misc.xml b/src/Logistics/.idea/misc.xml new file mode 100644 index 0000000..c718eea --- /dev/null +++ b/src/Logistics/.idea/misc.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/Logistics/.idea/vcs.xml b/src/Logistics/.idea/vcs.xml new file mode 100644 index 0000000..b2bdec2 --- /dev/null +++ b/src/Logistics/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/Logistics/app/.gitignore b/src/Logistics/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/src/Logistics/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/src/Logistics/app/build.gradle b/src/Logistics/app/build.gradle new file mode 100644 index 0000000..6bf05e2 --- /dev/null +++ b/src/Logistics/app/build.gradle @@ -0,0 +1,39 @@ +plugins { + id 'com.android.application' +} + +android { + compileSdk 32 + + defaultConfig { + applicationId "com.example.logistics" + minSdk 21 + targetSdk 32 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + + implementation 'androidx.appcompat:appcompat:1.3.0' + implementation 'com.google.android.material:material:1.4.0' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + implementation files('libs\\mysql-connector-java-5.0.7.jar') + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' +} \ No newline at end of file diff --git a/src/Logistics/app/libs/mysql-connector-java-5.0.7.jar b/src/Logistics/app/libs/mysql-connector-java-5.0.7.jar new file mode 100644 index 0000000..412138a Binary files /dev/null and b/src/Logistics/app/libs/mysql-connector-java-5.0.7.jar differ diff --git a/src/Logistics/app/src/androidTest/java/com/example/logistics/ExampleInstrumentedTest.java b/src/Logistics/app/src/androidTest/java/com/example/logistics/ExampleInstrumentedTest.java new file mode 100644 index 0000000..91ed906 --- /dev/null +++ b/src/Logistics/app/src/androidTest/java/com/example/logistics/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.example.logistics; + +import android.content.Context; + +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + assertEquals("com.example.logistics", appContext.getPackageName()); + } +} \ No newline at end of file diff --git a/src/Logistics/app/src/main/AndroidManifest.xml b/src/Logistics/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..414e4cc --- /dev/null +++ b/src/Logistics/app/src/main/AndroidManifest.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Logistics/app/src/main/java/com/example/logistics/dao/userDao.java b/src/Logistics/app/src/main/java/com/example/logistics/dao/userDao.java new file mode 100644 index 0000000..020590e --- /dev/null +++ b/src/Logistics/app/src/main/java/com/example/logistics/dao/userDao.java @@ -0,0 +1,139 @@ +package com.example.logistics.dao; + +import android.util.Log; + +import com.example.logistics.entity.User; +import com.example.logistics.mysqlconnection.DBOpenHelper; +import com.google.android.material.behavior.HideBottomViewOnScrollBehavior; + +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.HashMap; +import java.sql.ResultSet; +import java.sql.Connection; + +public class userDao { + + private static final String TAG = "userDao"; + + public int login(String username, String password){ + HashMap map = new HashMap<>(); + + Connection connection = DBOpenHelper.getConn(); + + int msg = 0; + try{ + String sql = "select * from users where username = ?"; + + if(connection != null){ + PreparedStatement ps = connection.prepareStatement(sql); + if(ps != null){ + Log.e(TAG, "username: " + username); + ps.setString(1,username); + ResultSet rs = ps.executeQuery(); + + int count = rs.getMetaData().getColumnCount(); + while(rs.next()){ + for(int i = 1; i <= count; i++){ + String field = rs.getMetaData().getColumnName(i); + map.put(field, rs.getString(field)); + } + } + connection.close(); + ps.close(); + + if(map.size() != 0){ + StringBuilder s = new StringBuilder(); + for(String key:map.keySet()){ + if(key.equals("password")){ + if(password.equals(map.get(key))){ + msg = 1; //password correct + }else{ + msg = 2; //password incorrect + } + break; + } + } + }else{ + Log.e(TAG, "result is null"); + msg = 3; //result is null + } + }else{ + Log.e(TAG, "ps is null"); + msg = 0; + } + }else{ + Log.e(TAG, "connection is null"); + msg = 0; + } + }catch (Exception e){ + e.printStackTrace(); + Log.d(TAG, "login bug: " + e.getMessage()); + msg = 0; + } + return msg; + } + + public User findUser(String username){ + + Connection connection = DBOpenHelper.getConn(); + User user = null; + try{ + String sql = "select * from users where username = ?"; + if(connection != null){ + PreparedStatement ps = connection.prepareStatement(sql); + if(ps != null){ + ps.setString(1, username); + ResultSet rs = ps.executeQuery(); + + while(rs.next()){ + int userId = rs.getInt(1); + String userName = rs.getString(2); + String passWord = rs.getString(3); + String phoneNum = rs.getString(4); + + user = new User(userId, userName, passWord, phoneNum); + } + } + } + } catch (SQLException throwables) { + throwables.printStackTrace(); + } + return user; + } + + public boolean register(User user){ + HashMap map = new HashMap<>(); + + Connection connection = DBOpenHelper.getConn(); + try{ + String sql = "insert into users(username, password, phonenum) values (?,?,?)"; + + if(connection != null){ + PreparedStatement ps = connection.prepareStatement(sql); + + if(ps != null){ + ps.setString(1, user.getUserName()); + ps.setString(2, user.getPassWord()); + ps.setString(3, user.getPhoneNum()); + + int rs = ps.executeUpdate(); + if(rs > 0){ + return true; + }else{ + return false; + } + }else{ + return false; + } + }else{ + return false; + } + }catch(Exception e){ + e.printStackTrace(); + Log.e(TAG, "异常 register"); + return false; + } + } + +} diff --git a/src/Logistics/app/src/main/java/com/example/logistics/entity/User.java b/src/Logistics/app/src/main/java/com/example/logistics/entity/User.java new file mode 100644 index 0000000..bec6082 --- /dev/null +++ b/src/Logistics/app/src/main/java/com/example/logistics/entity/User.java @@ -0,0 +1,52 @@ +package com.example.logistics.entity; + +public class User { + private int userId; + private String userName; + private String passWord; + private String phoneNum; + + public User(){ + + } + + public User(int id, String username, String password, String phonenum){ + this.userId = id; + this.userName = username; + this.passWord = password; + this.phoneNum = phonenum; + } + + public int getUserId(){ + return userId; + } + + public void setUserId(int id){ + this.userId = id; + } + + public String getUserName(){ + return userName; + } + + public void setUserName(String username){ + this.userName = username; + } + + public String getPassWord(){ + return passWord; + } + + public void setPassWord(String password){ + this.passWord = password; + } + + public String getPhoneNum(){ + return phoneNum; + } + + public void setPhoneNum(String phonenum){ + this.phoneNum = phonenum; + } + +} diff --git a/src/Logistics/app/src/main/java/com/example/logistics/mysqlconnection/DBOpenHelper.java b/src/Logistics/app/src/main/java/com/example/logistics/mysqlconnection/DBOpenHelper.java new file mode 100644 index 0000000..bfde32b --- /dev/null +++ b/src/Logistics/app/src/main/java/com/example/logistics/mysqlconnection/DBOpenHelper.java @@ -0,0 +1,28 @@ +package com.example.logistics.mysqlconnection; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; + +public class DBOpenHelper { + private static String diver = "com.mysql.jdbc.Driver"; + //加入utf-8是为了后面往表中输入中文,表中不会出现乱码的情况 + private static String url = "jdbc:mysql://49.235.83.73:3306/logistics?characterEncoding=utf-8"; + private static String user = "root";//用户名 + private static String password = "123";//密码 + /* + * 连接数据库 + * */ + public static Connection getConn(){ + Connection conn = null; + try { + Class.forName(diver); + conn = (Connection) DriverManager.getConnection(url,user,password);//获取连接 + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } catch (SQLException e) { + e.printStackTrace(); + } + return conn; + } +} \ No newline at end of file diff --git a/src/Logistics/app/src/main/java/com/example/logistics/tools/MD5Utils.java b/src/Logistics/app/src/main/java/com/example/logistics/tools/MD5Utils.java new file mode 100644 index 0000000..f6c065f --- /dev/null +++ b/src/Logistics/app/src/main/java/com/example/logistics/tools/MD5Utils.java @@ -0,0 +1,37 @@ +package com.example.logistics.tools; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +public class MD5Utils { + //md5 加密算法 + public static String md5(String text) { + MessageDigest digest = null; + try { + digest = MessageDigest.getInstance("md5"); + // 数组 byte[] result -> digest.digest( ); 文本 text.getBytes(); + byte[] result = digest.digest(text.getBytes()); + //创建StringBuilder对象 然后建议StringBuffer,安全性高 + //StringBuilder sb = new StringBuilder(); + StringBuffer sb = new StringBuffer(); + // result数组,digest.digest ( ); -> text.getBytes(); + // for 循环数组byte[] result; + for (byte b : result){ + // 0xff 为16进制 + int number = b & 0xff; + // number值 转换 字符串 Integer.toHexString( ); + String hex = Integer.toHexString(number); + if (hex.length() == 1){ + sb.append("0"+hex); + }else { + sb.append(hex); + } + } + //sb StringBuffer sb = new StringBuffer();对象实例化 + return sb.toString(); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + //发送异常return空字符串 + return ""; + } + } +} \ No newline at end of file diff --git a/src/Logistics/app/src/main/java/com/example/logistics/ui/Fragment3.java b/src/Logistics/app/src/main/java/com/example/logistics/ui/Fragment3.java new file mode 100644 index 0000000..495b6f1 --- /dev/null +++ b/src/Logistics/app/src/main/java/com/example/logistics/ui/Fragment3.java @@ -0,0 +1,4 @@ +package com.example.logistics.ui; + +public class Fragment3 { +} diff --git a/src/Logistics/app/src/main/java/com/example/logistics/ui/MainActivity.java b/src/Logistics/app/src/main/java/com/example/logistics/ui/MainActivity.java new file mode 100644 index 0000000..accf321 --- /dev/null +++ b/src/Logistics/app/src/main/java/com/example/logistics/ui/MainActivity.java @@ -0,0 +1,86 @@ +package com.example.logistics.ui; + +import com.example.logistics.R; +import com.example.logistics.dao.userDao; + +import android.annotation.SuppressLint; +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.util.Log; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.Toast; + + +public class MainActivity extends Activity { + + // 调用Actvity + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + Intent intent = new Intent(MainActivity.this, MenuActivity.class); + startActivity(intent); + Button loginButton = (Button) this.findViewById(R.id.LoginButton); + Button signUpButton = (Button) this.findViewById(R.id.SignUpButton); + + loginButton.setOnClickListener( + new View.OnClickListener() { + @Override + public void onClick(View v) { + login(v); + } + } + ); + signUpButton.setOnClickListener( + new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(MainActivity.this, SignUpActivity.class); + startActivity(intent); + } + } + ); + + } + + public void login(View view){ + EditText userName = (EditText) this.findViewById(R.id.UserNameEdit); + EditText passWord = (EditText) this.findViewById(R.id.PassWordEdit); + + new Thread(){ + @Override + public void run(){ + userDao userDao = new userDao(); + int msg = userDao.login(userName.getText().toString().trim(), passWord.getText().toString().trim()); + Log.e("MAin", "msg"); + hand1.sendEmptyMessage(msg); + if(msg == 1){ + Intent intent = new Intent(MainActivity.this, MenuActivity.class); + startActivity(intent); + } + } + }.start(); + } + + @SuppressLint("HandlerLeak") + final Handler hand1 = new Handler(){ + @Override + public void handleMessage(Message msg){ + if(msg.what == 0){ + Toast.makeText(getApplicationContext(), "登录失败", Toast.LENGTH_SHORT).show(); + }else if(msg.what == 1){ + Toast.makeText(getApplicationContext(), "登录成功", Toast.LENGTH_SHORT).show(); + }else if(msg.what == 2){ + Toast.makeText(getApplicationContext(), "密码错误", Toast.LENGTH_SHORT).show(); + }else if(msg.what == 3){ + Toast.makeText(getApplicationContext(), "账号不存在", Toast.LENGTH_SHORT).show(); + } + } + }; + +} \ No newline at end of file diff --git a/src/Logistics/app/src/main/java/com/example/logistics/ui/MenuActivity.java b/src/Logistics/app/src/main/java/com/example/logistics/ui/MenuActivity.java new file mode 100644 index 0000000..d8bcfba --- /dev/null +++ b/src/Logistics/app/src/main/java/com/example/logistics/ui/MenuActivity.java @@ -0,0 +1,82 @@ +package com.example.logistics.ui; + +import android.app.FragmentTransaction; +import android.os.Bundle; +import android.view.View; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.appcompat.app.AppCompatActivity; + +import com.example.logistics.R; + +public class MenuActivity extends AppCompatActivity implements View.OnClickListener{ + private LinearLayout ly_one,ly_two,ly_three; + private TextView mTextView1,mTextView2,mTextView3; + private TextView mTextNum1,mTextNum2,mTextNum3; + private ImageView mImageView; + + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_menu); + + bindView(); + ly_one.performClick(); + FragmentTransaction transaction = getFragmentManager().beginTransaction(); + MyFragment1 fg1 = new MyFragment1(); + transaction.add(R.id.fragment_container,fg1); + transaction.commit(); + } + + private void bindView() { + + ly_one = (LinearLayout)findViewById(R.id.ly_tab_menu_deal); + ly_two = (LinearLayout)findViewById(R.id.ly_tab_menu_poi); + ly_three = (LinearLayout)findViewById(R.id.ly_tab_menu_more); + + mTextView1 = (TextView)findViewById(R.id.tab_menu_deal); + mTextView2 = (TextView)findViewById(R.id.tab_menu_poi); + mTextView3 = (TextView)findViewById(R.id.tab_menu_more); + + mTextNum1 = (TextView)findViewById(R.id.tab_menu_deal_num); + mTextNum2 = (TextView)findViewById(R.id.tab_menu_poi_num); + mTextNum3 = (TextView)findViewById(R.id.tab_menu_more_num); + + + ly_one.setOnClickListener(this); + ly_two.setOnClickListener(this); + ly_three.setOnClickListener(this); + } + + //重置所有文本的选中状态 + private void setSelected() { + mTextView1.setSelected(false); + mTextView2.setSelected(false); + mTextView3.setSelected(false); + } + @Override + public void onClick(View v) { + switch (v.getId()) { + case R.id.ly_tab_menu_deal: + setSelected(); + mTextView1.setSelected(true); + mTextNum1.setVisibility(View.INVISIBLE); + break; + case R.id.ly_tab_menu_poi: + setSelected(); + mTextView2.setSelected(true); + mTextNum2.setVisibility(View.INVISIBLE); + break; + case R.id.ly_tab_menu_more: + setSelected(); + mTextView3.setSelected(true); + mTextNum3.setVisibility(View.INVISIBLE); + break; + } + } + +} diff --git a/src/Logistics/app/src/main/java/com/example/logistics/ui/MyFragment1.java b/src/Logistics/app/src/main/java/com/example/logistics/ui/MyFragment1.java new file mode 100644 index 0000000..783a124 --- /dev/null +++ b/src/Logistics/app/src/main/java/com/example/logistics/ui/MyFragment1.java @@ -0,0 +1,63 @@ +package com.example.logistics.ui; + + +import android.content.Context; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.Nullable; +import android.app.Fragment; + +import com.example.logistics.R; + +public class MyFragment1 extends Fragment implements View.OnClickListener{ + private Context mContext; + private Button btn_one; + private Button btn_two; + private Button btn_three; + private Button btn_four; + + public MyFragment1(){ + + } + @Nullable + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.fragment_my,container,false); + btn_one = (Button)view.findViewById(R.id.btn_one); + btn_two = (Button)view.findViewById(R.id.btn_two); + btn_three = (Button)view.findViewById(R.id.btn_three); + + btn_one.setOnClickListener(this); + btn_two.setOnClickListener(this); + btn_three.setOnClickListener(this); + return view; + } + + @Override + public void onClick(View v) { + switch(v.getId()){ + case R.id.btn_one: + TextView mTextViewDeal = (TextView)getActivity().findViewById(R.id.tab_menu_deal_num); + mTextViewDeal.setText("11"); + mTextViewDeal.setVisibility(View.VISIBLE); + break; + case R.id.btn_two: + TextView mTextViewPoi = (TextView)getActivity().findViewById(R.id.tab_menu_poi_num); + mTextViewPoi.setText("99"); + mTextViewPoi.setVisibility(View.VISIBLE); + break; + case R.id.btn_three: + TextView mTextViewMore = (TextView)getActivity().findViewById(R.id.tab_menu_more_num); + mTextViewMore.setText("999+"); + mTextViewMore.setVisibility(View.VISIBLE); + break; + } + } +} diff --git a/src/Logistics/app/src/main/java/com/example/logistics/ui/MyFragment2.java b/src/Logistics/app/src/main/java/com/example/logistics/ui/MyFragment2.java new file mode 100644 index 0000000..181b33f --- /dev/null +++ b/src/Logistics/app/src/main/java/com/example/logistics/ui/MyFragment2.java @@ -0,0 +1,4 @@ +package com.example.logistics.ui; + +public class MyFragment2 { +} diff --git a/src/Logistics/app/src/main/java/com/example/logistics/ui/SignUpActivity.java b/src/Logistics/app/src/main/java/com/example/logistics/ui/SignUpActivity.java new file mode 100644 index 0000000..f927349 --- /dev/null +++ b/src/Logistics/app/src/main/java/com/example/logistics/ui/SignUpActivity.java @@ -0,0 +1,115 @@ +package com.example.logistics.ui; + +import android.annotation.SuppressLint; +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.Toast; + +import com.example.logistics.R; +import com.example.logistics.dao.userDao; +import com.example.logistics.entity.User; + +public class SignUpActivity extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_sign_up); + + Button signUpButton = (Button) this.findViewById(R.id.SignUpButton); + Button backLoginButton = (Button) this.findViewById(R.id.BackLoginButton); + + signUpButton.setOnClickListener( + new View.OnClickListener() { + @Override + public void onClick(View v) { + register(v); + } + } + ); + // 返回登录按钮监听器 + backLoginButton.setOnClickListener( + new View.OnClickListener() { + @Override + public void onClick(View v) { + // 跳转到登录界面 + Intent intent = new Intent(SignUpActivity.this, MainActivity.class); + startActivity(intent); + } + } + ); + + } + + public void register(View view){ + EditText userName = (EditText) this.findViewById(R.id.UserNameEdit); + EditText passWord = (EditText) this.findViewById(R.id.PassWordEdit); + EditText passWordAgain = (EditText) this.findViewById(R.id.PassWordAgainEdit); + EditText phone = (EditText) this.findViewById(R.id.PhoneEdit); + + String strUserName = userName.getText().toString().trim(); + String strPassWord = passWord.getText().toString().trim(); + String strPassWordAgain = passWordAgain.getText().toString().trim(); + String strPhoneNumber = phone.getText().toString().trim(); + + if (strUserName.length() > 10) { + Toast.makeText(SignUpActivity.this, "用户名长度必须小于10!", Toast.LENGTH_SHORT).show(); + } else if (strUserName.length() == 0) { + Toast.makeText(SignUpActivity.this, "用户名不能为空!", Toast.LENGTH_SHORT).show(); + } else if (strPassWord.length() > 16) { + Toast.makeText(SignUpActivity.this, "密码长度必须小于16!", Toast.LENGTH_SHORT).show(); + } else if (strPassWord.length() == 0) { + Toast.makeText(SignUpActivity.this, "密码不能为空!", Toast.LENGTH_SHORT).show(); + } else if (!strPassWord.equals(strPassWordAgain)) { + Toast.makeText(SignUpActivity.this, "两次密码输入不一致!", Toast.LENGTH_SHORT).show(); + } else { + Toast.makeText(SignUpActivity.this, "注册成功!", Toast.LENGTH_SHORT).show(); + + User user = new User(); + user.setUserName(strUserName); + user.setPassWord(strPassWord); + user.setPhoneNum(strPhoneNumber); + + new Thread(){ + @Override + public void run(){ + int msg = 0; + userDao userDao = new userDao(); + + User uu = userDao.findUser(user.getUserName()); + + if(uu != null){ + msg = 1; //have this account + }else{ + boolean flag = userDao.register(user); + if(flag){ + msg = 2; + } + } + hand.sendEmptyMessage(msg); + } + }.start(); + } + } + + @SuppressLint("HandlerLeak") + final Handler hand = new Handler(){ + public void handleMessage(Message msg){ + if(msg.what == 0){ + Toast.makeText(getApplicationContext(), "注册失败", Toast.LENGTH_SHORT).show(); + }else if(msg.what == 1){ + Toast.makeText(getApplicationContext(), "该账号已存在,请换一个注册", Toast.LENGTH_SHORT).show(); + }else if(msg.what == 2){ + Toast.makeText(getApplicationContext(), "注册成功", Toast.LENGTH_SHORT).show(); + Intent intent = new Intent(SignUpActivity.this, MainActivity.class); + startActivity(intent); + } + } + }; + +} diff --git a/src/Logistics/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/src/Logistics/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/src/Logistics/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/Logistics/app/src/main/res/drawable/ic_launcher_background.xml b/src/Logistics/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/src/Logistics/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Logistics/app/src/main/res/drawable/logo.png b/src/Logistics/app/src/main/res/drawable/logo.png new file mode 100644 index 0000000..544c697 Binary files /dev/null and b/src/Logistics/app/src/main/res/drawable/logo.png differ diff --git a/src/Logistics/app/src/main/res/drawable/me.jpg b/src/Logistics/app/src/main/res/drawable/me.jpg new file mode 100644 index 0000000..1fc5593 Binary files /dev/null and b/src/Logistics/app/src/main/res/drawable/me.jpg differ diff --git a/src/Logistics/app/src/main/res/drawable/me.png b/src/Logistics/app/src/main/res/drawable/me.png new file mode 100644 index 0000000..a44ece2 Binary files /dev/null and b/src/Logistics/app/src/main/res/drawable/me.png differ diff --git a/src/Logistics/app/src/main/res/drawable/pickup.jpg b/src/Logistics/app/src/main/res/drawable/pickup.jpg new file mode 100644 index 0000000..9a6ee63 Binary files /dev/null and b/src/Logistics/app/src/main/res/drawable/pickup.jpg differ diff --git a/src/Logistics/app/src/main/res/drawable/search.png b/src/Logistics/app/src/main/res/drawable/search.png new file mode 100644 index 0000000..593168e Binary files /dev/null and b/src/Logistics/app/src/main/res/drawable/search.png differ diff --git a/src/Logistics/app/src/main/res/drawable/tab_menu_better.xml b/src/Logistics/app/src/main/res/drawable/tab_menu_better.xml new file mode 100644 index 0000000..4aeee76 --- /dev/null +++ b/src/Logistics/app/src/main/res/drawable/tab_menu_better.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/Logistics/app/src/main/res/drawable/tab_menu_text.xml b/src/Logistics/app/src/main/res/drawable/tab_menu_text.xml new file mode 100644 index 0000000..8705bd5 --- /dev/null +++ b/src/Logistics/app/src/main/res/drawable/tab_menu_text.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/Logistics/app/src/main/res/drawable/translucent_button.xml b/src/Logistics/app/src/main/res/drawable/translucent_button.xml new file mode 100644 index 0000000..0cf2590 --- /dev/null +++ b/src/Logistics/app/src/main/res/drawable/translucent_button.xml @@ -0,0 +1,10 @@ + + + + + + + \ No newline at end of file diff --git a/src/Logistics/app/src/main/res/drawable/translucent_edit.xml b/src/Logistics/app/src/main/res/drawable/translucent_edit.xml new file mode 100644 index 0000000..adb6e92 --- /dev/null +++ b/src/Logistics/app/src/main/res/drawable/translucent_edit.xml @@ -0,0 +1,10 @@ + + + + + + + \ No newline at end of file diff --git a/src/Logistics/app/src/main/res/layout/activity_main.xml b/src/Logistics/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..939e667 --- /dev/null +++ b/src/Logistics/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +