提交 0d163573 编写于 作者: S suhy

m

上级 7c3d39d2
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<runningDeviceTargetSelectedWithDropDown>
<Target>
<type value="RUNNING_DEVICE_TARGET" />
<deviceKey>
<Key>
<type value="VIRTUAL_DEVICE_PATH" />
<value value="D:\Android\.android\avd\Pixel_5_API_25.avd" />
</Key>
</deviceKey>
</Target>
</runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2021-12-15T09:47:18.615793700Z" />
</component>
</project>
\ No newline at end of file
......@@ -41,6 +41,18 @@
<entry key="..\:/Users/suhy/Desktop/github/Android/MyHomeWork/app/src/main/res/layout/fragment_news.xml" value="0.19972826086956522" />
<entry key="..\:/Users/suhy/Desktop/github/Android/MyHomeWork/app/src/main/res/layout/fragment_photo.xml" value="0.16964285714285715" />
<entry key="..\:/Users/suhy/Desktop/github/Android/MyHomeWork/app/src/main/res/layout/userhead_item.xml" value="0.14791666666666667" />
<entry key="..\:/Users/suhy/Desktop/github/schoolphoto/MyHomeWork/app/src/main/res/layout/activity_login.xml" value="0.1375" />
<entry key="..\:/Users/suhy/Desktop/github/schoolphoto/MyHomeWork/app/src/main/res/layout/activity_main.xml" value="0.1375" />
<entry key="..\:/Users/suhy/Desktop/github/schoolphoto/MyHomeWork/app/src/main/res/layout/activity_register.xml" value="0.264" />
<entry key="..\:/Users/suhy/Desktop/github/schoolphoto/MyHomeWork/app/src/main/res/layout/activity_user_information.xml" value="0.1375" />
<entry key="..\:/Users/suhy/Desktop/github/schoolphoto/MyHomeWork/app/src/main/res/layout/appbar.xml" value="0.1375" />
<entry key="..\:/Users/suhy/Desktop/github/schoolphoto/MyHomeWork/app/src/main/res/layout/drawer_header.xml" value="0.1375" />
<entry key="..\:/Users/suhy/Desktop/github/schoolphoto/MyHomeWork/app/src/main/res/layout/fragment_chat.xml" value="0.1375" />
<entry key="..\:/Users/suhy/Desktop/github/schoolphoto/MyHomeWork/app/src/main/res/layout/fragment_home.xml" value="0.1375" />
<entry key="..\:/Users/suhy/Desktop/github/schoolphoto/MyHomeWork/app/src/main/res/layout/recycler_item.xml" value="0.1375" />
<entry key="..\:/Users/suhy/Desktop/github/schoolphoto/MyHomeWork/app/src/main/res/layout/userhead_item.xml" value="0.4" />
<entry key="..\:/Users/suhy/Desktop/github/schoolphoto/MyHomeWork/app/src/main/res/menu/bottom_nav_menu.xml" value="0.1375" />
<entry key="..\:/Users/suhy/Desktop/github/schoolphoto/MyHomeWork/app/src/main/res/menu/menu_drawer.xml" value="0.1375" />
<entry key="..\:/Users/suhy/OneDrive/Android/MyHomeWork/app/src/main/res/layout/activity_login.xml" value="0.1096757852077001" />
<entry key="..\:/Users/suhy/OneDrive/Android/MyHomeWork/app/src/main/res/layout/activity_main.xml" value="0.264" />
<entry key="..\:/Users/suhy/OneDrive/Android/MyHomeWork/app/src/main/res/layout/fragment_chat.xml" value="0.2" />
......
package com.example.myhomework.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.StrictMode;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
......@@ -16,21 +12,11 @@ import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.airbnb.lottie.LottieAnimationView;
import com.example.myhomework.Global.GlobalMemory;
import com.example.myhomework.R;
import com.example.myhomework.Service.UserService;
import com.example.myhomework.Util.SaveIdPasswordUtil;
import com.example.myhomework.Utils.SaveIdPasswordUtils;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
......@@ -42,10 +28,7 @@ public class LoginActivity extends AppCompatActivity {
String errorString;
ImageView bg_login;
LottieAnimationView lottie;
static final Boolean LOGINSUCCESS=true,LOGINFAULT=true;
//Map<String,String> userInfo=getUserInfo(this);
static final Boolean LOGINSUCCESS=true,LOGINFAULT=false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -80,22 +63,14 @@ public class LoginActivity extends AppCompatActivity {
bg_login.animate().translationY(0).alpha(1).setDuration(2000).setStartDelay(400).start();
lottie.animate().translationY(0).alpha(0).setDuration(2000).setStartDelay(400).start();
////////////读取账户密码
Map<String,String> userInfo= SaveIdPasswordUtil.getUserInfo(this);
//读取账户密码
Map<String,String> userInfo= SaveIdPasswordUtils.getUserInfo(this);
userID.setText(userInfo.get("account"));
userPassWord.setText(userInfo.get("password"));
Toast.makeText(this,"读取成功",Toast.LENGTH_LONG).show();
login.setOnClickListener(v -> {
Intent intent=new Intent(LoginActivity.this,MainActivity.class);
if(loginCheck(userID,userPassWord)){
startActivity(intent);
finish();
}else{
Toast.makeText(LoginActivity.this,errorString,Toast.LENGTH_LONG).show();
}
loginCheck(userID,userPassWord);
});
register.setOnClickListener(v -> {
Intent intent=new Intent(LoginActivity.this,RegisterActivity.class);
startActivity(intent);
......@@ -104,29 +79,26 @@ public class LoginActivity extends AppCompatActivity {
//对账号密码做检验
private boolean loginCheck(EditText userID,EditText userPassWord){
//是否保存账号密码选项
chBOX = findViewById(R.id.checkBox_LoginActivity);
String name = userID.getText().toString();
String password = userPassWord.getText().toString();
boolean loginFlag= true;
UserService.Login(name,password,this);
if (TextUtils.isEmpty(name) || TextUtils.isEmpty(password)) {
errorString = "账户或密码为空";
//ApplicationContext.showToast(errorString);
return LOGINFAULT;
} else if (loginFlag) {
} else{
UserService.Login(name,password,this);
if(chBOX.isChecked()){
boolean isSaveSuccess=SaveIdPasswordUtil.saveUserInfo(this,name,password);
Toast.makeText(this,"保存成功",Toast.LENGTH_LONG).show();
if(SaveIdPasswordUtils.saveUserInfo(this,name,password)){
GlobalMemory.PrintLog("LoginActivity:账号密码保存成功");
}
}
else{
SaveIdPasswordUtil.delectUserInfo(this);
Toast.makeText(this,"账号密码未保存",Toast.LENGTH_LONG).show();
SaveIdPasswordUtils.delectUserInfo(this);
}
return LOGINSUCCESS;
} else {
errorString = "账户或密码错误";
return LOGINFAULT;
}
}
}
\ No newline at end of file
......@@ -22,6 +22,7 @@ import android.widget.Toast;
import com.example.myhomework.R;
import com.example.myhomework.Service.UserService;
import com.example.myhomework.databinding.AppbarBinding;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.example.myhomework.databinding.ActivityMainBinding;
import com.google.android.material.navigation.NavigationView;
......@@ -40,12 +41,14 @@ import okhttp3.Response;
public class MainActivity extends AppCompatActivity {
private ActivityMainBinding binding;
private AppbarBinding appbarBinding;
public static DrawerLayout drawerLayout;
public static MainActivity mainActivity;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityMainBinding.inflate(getLayoutInflater());
appbarBinding=AppbarBinding.inflate(getLayoutInflater());
mainActivity=this;
setContentView(binding.getRoot());
UserService.ResetUserData();
......@@ -55,18 +58,10 @@ public class MainActivity extends AppCompatActivity {
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_activity_main);
View headlayoutView=navigationView.inflateHeaderView(R.layout.drawer_header);
CircleImageView circleImageView=headlayoutView.findViewById(R.id.userhead_drawerlayout);
AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
R.id.page_news, R.id.page_photo,R.id.page_home)
.build();
appbarBinding.imageButtonUserHeadToolbar.setImageBitmap(UserService.userHeadBitmap);
NavigationUI.setupWithNavController(binding.navView, navController);
verifyStoragePermissions(this);
//Bitmap pngBM=getURLimage("http://47.98.173.217:8080");
circleImageView.setImageBitmap(UserService.userHeadBitmap);
//imageView.setImageBitmap(pngBM);
test();
}
public static Uri picuri;
public static String filename;
......
......@@ -11,54 +11,42 @@ import android.widget.EditText;
import android.widget.Toast;
import com.example.myhomework.R;
import com.example.myhomework.Service.UserService;
import com.example.myhomework.databinding.ActivityRegisterBinding;
public class RegisterActivity extends AppCompatActivity {
Button register1;
EditText UserID1,UserPassWord1,UserPassWord2;
Button register;
EditText UserName,UserPassWord1,UserPassWord2,UID;
String errorString;
static final Boolean REGISTERSUCCESS=true,REGISTERFAULT=false;
ActivityRegisterBinding binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
binding=ActivityRegisterBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
UID=binding.uid;
UserName=binding.username;
UserPassWord1=binding.password;
UserPassWord2=binding.password2;
register=binding.button;
UserID1 = findViewById(R.id.editText2);
UserPassWord1=findViewById(R.id.editText1);
UserPassWord2=findViewById(R.id.editText3);
register1=findViewById(R.id.button123);
register.setOnClickListener(v -> {
register1(UID,UserName,UserPassWord1,UserPassWord2);
register1.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Intent intent=new Intent(RegisterActivity.this,MainActivity.class);
if(register1(UserID1,UserPassWord1,UserPassWord2)){
startActivity(intent);
finish();
}else{
Toast.makeText(RegisterActivity.this,errorString,Toast.LENGTH_LONG).show();
}
}
});
}
private boolean register1(EditText UserID1,EditText UserPassWord1,EditText UserPassWord2) {
private void register1(EditText UID,EditText UserID1,EditText UserPassWord1,EditText UserPassWord2) {
//TODO注册检查
String uid=UID.getText().toString().trim();
String name = UserID1.getText().toString().trim();
String password1 = UserPassWord1.getText().toString().trim();
String password2 = UserPassWord2.getText().toString().trim();
if (TextUtils.isEmpty(name) || TextUtils.isEmpty(password1)||TextUtils.isEmpty(password2)) {
errorString = "账户或密码为空";
return REGISTERFAULT;
} else if (name.equals("abc") && password1.equals("123")&& password2.equals("123")) {
return REGISTERSUCCESS;
} else if (name.equals("def") && password1.equals("456")&& password2.equals("456")) {
return REGISTERSUCCESS;
if (TextUtils.isEmpty(uid) ||TextUtils.isEmpty(name) || TextUtils.isEmpty(password1)||TextUtils.isEmpty(password2)) {
Toast.makeText(this,"账号、用户名、密码不能为空",Toast.LENGTH_LONG).show();
} else if (!password1.equals(password2)) {
Toast.makeText(this,"两次密码不一致",Toast.LENGTH_LONG).show();
} else {
errorString = "注册失败";
return REGISTERFAULT;
UserService.Register(uid,name,password1,this);
}
}
}
\ No newline at end of file
......@@ -86,7 +86,6 @@ public class HomeFragment extends Fragment {
TextView pagename=mview.findViewById(R.id.textview_toolbar);
userHead2.setImageBitmap(UserService.userHeadBitmap);
userHead.setBackground(new BitmapDrawable(UserService.userHeadBitmap));
username.setText(UserService.GetUserNickName());
usertype.setText(UserService.GetUserType());
pagename.setText("主页");
......
package com.example.myhomework.Fragment;
import android.Manifest;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider;
import androidx.fragment.app.Fragment;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
......@@ -31,15 +18,13 @@ import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.example.myhomework.Activity.MainActivity;
import com.example.myhomework.R;
import com.example.myhomework.Util.PermissionsUtil;
import com.example.myhomework.Util.PhotoUtil;
import com.example.myhomework.Utils.PermissionsUtils;
import com.example.myhomework.Utils.PhotoUtils;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.UUID;
......@@ -105,7 +90,7 @@ public class PhotoFragment extends Fragment {
Button chooseFromAlbum = view.findViewById(R.id.choose_from_album);
picture = view.findViewById(R.id.picture);
PermissionsUtil.verifyStoragePermissions(getActivity());//获取权限
PermissionsUtils.verifyStoragePermissions(getActivity());//获取权限
takePhoto.setOnClickListener(v -> {
// 创建File对象,用于存储拍照后的图片
......@@ -134,7 +119,7 @@ public class PhotoFragment extends Fragment {
startActivity(intent);
});
chooseFromAlbum.setOnClickListener(v-> {
PhotoUtil.openAlbum(getActivity());
PhotoUtils.openAlbum(getActivity());
picture.setImageURI(MainActivity.picuri);
});
TextView PageName=view.findViewById(R.id.textview_toolbar);
......
package com.example.myhomework.Service;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.widget.Toast;
import com.example.myhomework.Activity.LoginActivity;
import com.example.myhomework.Activity.MainActivity;
import com.example.myhomework.Global.GlobalMemory;
import com.example.myhomework.Util.HttpUtil;
import com.example.myhomework.Util.JDBCUtil;
import com.example.myhomework.Utils.HttpUtils;
import com.example.myhomework.Utils.JDBCUtils;
import java.sql.Connection;
import java.sql.PreparedStatement;
......@@ -14,48 +19,124 @@ import java.sql.SQLException;
public class UserService {
private static String uid;
private static String userNickName;
private static UserType userType;
private static String userType;
private static String head;
public static Bitmap userHeadBitmap;
public static boolean Login(String id, String password){
boolean success=true;
boolean fail=false;
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
Connection connection = JDBCUtil.Connection();
String sql="SELECT * from user where uid="+id+"password="+password;
try {
preparedStatement=connection.prepareStatement(sql);
resultSet=preparedStatement.executeQuery();
if(resultSet.next()){
GlobalMemory.PrintLog(resultSet.getString(0));
return success;
private static String TAG="UserService:";
public static void Login(String id, String password, Activity activity){
new Thread(() -> {
Connection connection = JDBCUtils.Connection();
String sql="SELECT * from user where uid='"+id+"' and password='"+password+"'";
PreparedStatement preparedStatement;
ResultSet resultSet;
try {
preparedStatement=connection.prepareStatement(sql);
resultSet=preparedStatement.executeQuery();
if(resultSet.next()){
activity.startActivity(new Intent(activity, MainActivity.class));
activity.runOnUiThread(()-> Toast.makeText(activity,"登陆成功",Toast.LENGTH_LONG).show());
GlobalMemory.PrintLog(TAG+"登陆成功");
InitUserData(id);
activity.finish();
}else{
activity.runOnUiThread(()-> Toast.makeText(activity,"账号或密码错误",Toast.LENGTH_LONG).show());
}
}catch (Exception e){
GlobalMemory.PrintLog(TAG+e.getMessage());
GlobalMemory.PrintLog(TAG+sql);
}
}catch (Exception e){
GlobalMemory.PrintLog(e.getMessage());
}
return fail;
}).start();
}
public static void Register(String uid,String userNickName,String password,Activity activity){
new Thread(() -> {
Connection connection = JDBCUtils.Connection();
String sql="select * from user where uid='"+uid+"'";
PreparedStatement preparedStatement;
ResultSet resultSet;
try {
preparedStatement=connection.prepareStatement(sql);
resultSet=preparedStatement.executeQuery();
if(resultSet.next()){
activity.runOnUiThread(()->Toast.makeText(activity,"注册失败,该账号已被注册",Toast.LENGTH_LONG).show());
GlobalMemory.PrintLog(TAG+"注册失败,该账号已被注册");
return;
}
}catch (Exception e){
GlobalMemory.PrintLog(TAG+e.getMessage());
GlobalMemory.PrintLog(TAG+sql);
}
sql="insert into user values(?,?,'普通用户',?)";
try {
preparedStatement=connection.prepareStatement(sql);
preparedStatement.setString(1,uid);
preparedStatement.setString(2,userNickName);
preparedStatement.setString(3,password);
if(preparedStatement.executeUpdate()>=0){
activity.runOnUiThread(()->Toast.makeText(activity,"注册成功",Toast.LENGTH_LONG).show());
activity.startActivity(new Intent(activity, LoginActivity.class));
GlobalMemory.PrintLog(TAG+"注册成功");
activity.finish();
}else{
activity.runOnUiThread(()->Toast.makeText(activity,"注册失败,服务端连接失败",Toast.LENGTH_LONG).show());
GlobalMemory.PrintLog(TAG+"注册失败");
}
}catch (Exception e){
GlobalMemory.PrintLog(TAG+e.getMessage());
GlobalMemory.PrintLog(TAG+sql);
}
}).start();
}
private static void InitUserData(String _uid){
new Thread(() -> {
String muid=_uid;
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
Connection connection = JDBCUtils.Connection();
String sql = "SELECT * from user where uid='"+muid+"'";
GlobalMemory.PrintLog(sql);
try {
preparedStatement = connection.prepareStatement(sql);
resultSet = preparedStatement.executeQuery();
if (resultSet.next()) {
uid=resultSet.getString("uid");
userNickName=resultSet.getString("userNickName");
userType=resultSet.getString("userType");
head=resultSet.getString("head");
GlobalMemory.PrintLog("初始化\nuid:"+uid+"\nname"+userNickName+"\nhead:"+head);
}
} catch (SQLException e) {
GlobalMemory.PrintLog(TAG+e.getMessage());
} finally {
JDBCUtils.closeAll(resultSet,preparedStatement,connection);
}
}).start();
GetUserHead();
}
public static void ResetUserData(){
new Thread(() -> {
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
Connection connection = JDBCUtil.Connection();
String sql = "SELECT * from user;";
Connection connection = JDBCUtils.Connection();
String sql = "SELECT * from user where uid='"+uid+"'";
GlobalMemory.PrintLog(sql);
try {
preparedStatement = connection.prepareStatement(sql);
resultSet = preparedStatement.executeQuery();
if (resultSet.next()) {
uid=resultSet.getString("uid");
userNickName=resultSet.getString("userNickName");
userType=UserType.InitFromStr(resultSet.getString("userType"));
userType=resultSet.getString("userType");
head=resultSet.getString("head");
GlobalMemory.PrintLog("初始化\nuid:"+uid+"\nname"+userNickName+"\nhead:"+head);
}
} catch (SQLException e) {
GlobalMemory.PrintLog(TAG+e.getMessage());
} finally {
JDBCUtil.closeAll(resultSet,preparedStatement,connection);
JDBCUtils.closeAll(resultSet,preparedStatement,connection);
}
}).start();
GetUserHead();
}
public static String GetUid(){
return uid;
......@@ -64,23 +145,9 @@ public class UserService {
return userNickName;
}
public static String GetUserType(){
return userType.typeStr;
return userType;
}
public static void GetUserHead(){
userHeadBitmap= HttpUtil.getURLimage(GlobalMemory.FileServerUri+"/downloadFile/app_icon.png");
}
protected enum UserType{
Normal("普通用户",1),Admin("管理员",2);
private String typeStr;
private int index;
private UserType(String typeStr,int index){
this.typeStr=typeStr;this.index=index;}
public static UserType InitFromStr(String str){
switch (str){
case "普通用户":return Normal;
case "管理员":return Admin;
}
return null;
}
userHeadBitmap= HttpUtils.getURLimage(GlobalMemory.FileServerUri+"/downloadFile/"+head);
}
}
package com.example.myhomework.Util;
package com.example.myhomework.Utils;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
......@@ -15,7 +15,7 @@ import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
public class HttpUtil {
public class HttpUtils {
private static void HttpUtil(){}
public static String Post_file(String url,String filename,String pathname){
......
package com.example.myhomework.Util;
package com.example.myhomework.Utils;
import static com.example.myhomework.Global.GlobalMemory.*;
......@@ -9,21 +9,12 @@ import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class JDBCUtil {
public static JDBCUtil jdbcUtil=new JDBCUtil();
private JDBCUtil(){
}
@Override
protected void finalize() throws Throwable {
super.finalize();
}
public class JDBCUtils {
public static Connection Connection() {
Connection connection=null;
try {
String SDdriver = "com.mysql.cj.jdbc.Driver";
String SDdriver = "com.mysql.jdbc.Driver";
Class.forName(SDdriver);
connection=DriverManager.getConnection(DateBaseurl, MysqlUser, MysqlPassword);
Log.d(TAG, "连接成功"+DateBaseurl);
......
package com.example.myhomework.Util;
package com.example.myhomework.Utils;
import android.Manifest;
import android.app.Activity;
......@@ -6,7 +6,7 @@ import android.content.pm.PackageManager;
import androidx.core.app.ActivityCompat;
public class PermissionsUtil {
public class PermissionsUtils {
private static final int REQUEST_EXTERNAL_STORAGE = 1;
private static String[] PERMISSIONS_STORAGE = {
"android.permission.READ_EXTERNAL_STORAGE",
......
package com.example.myhomework.Util;
import static androidx.core.app.ActivityCompat.startActivityForResult;
package com.example.myhomework.Utils;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
......@@ -18,7 +16,7 @@ import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class PhotoUtil {
public class PhotoUtils {
public static void openAlbum(Activity activity) {
Intent intent = new Intent("android.intent.action.GET_CONTENT");
......
package com.example.myhomework.Util;
package com.example.myhomework.Utils;
import org.w3c.dom.*;
import java.io.FileInputStream;
import java.io.InputStream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
public class ReadXmlUtil {
public class ReadXmlUtils {
private static ReadXmlUtil readXmlUtil=new ReadXmlUtil();
private static ReadXmlUtils readXmlUtil=new ReadXmlUtils();
private static void ReadXmlUtil(){
......
package com.example.myhomework.Util;
package com.example.myhomework.Utils;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import java.util.HashMap;
import java.util.Map;
public class SaveIdPasswordUtil {
public class SaveIdPasswordUtils {
//保存账号密码到data.xml
public static boolean saveUserInfo(Context context, String account, String password){
......@@ -16,7 +15,6 @@ public class SaveIdPasswordUtil {
edit.putString("UserId",account);
edit.putString("UserPassWord",password);
edit.commit();
return true;
}
public static void delectUserInfo(Context context){
......
......@@ -39,9 +39,10 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.navigation.NavigationView
app:headerLayout="@layout/drawer_header"
android:id="@+id/navigation_view"
android:layout_width="260dp"
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="@menu/menu_drawer"/>
app:menu="@menu/bottom_nav_menu"/>
</androidx.drawerlayout.widget.DrawerLayout>
\ No newline at end of file
......@@ -8,11 +8,11 @@
android:background="@drawable/bg_register">
<EditText
android:id="@+id/editText2"
android:id="@+id/uid"
android:layout_width="282dp"
android:layout_height="54dp"
android:layout_marginTop="276dp"
android:hint="用户名"
android:hint="账号/邮箱"
android:maxLines="2"
android:textColor="#000000"
app:layout_constraintBottom_toBottomOf="parent"
......@@ -20,14 +20,29 @@
app:layout_constraintHorizontal_bias="0.519"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.007" />
app:layout_constraintVertical_bias="0.0" />
<EditText
android:id="@+id/editText1"
android:id="@+id/username"
android:layout_width="282dp"
android:layout_height="54dp"
android:layout_marginTop="276dp"
android:hint="用户名"
android:maxLines="2"
android:textColor="#000000"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.519"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.154" />
<EditText
android:id="@+id/password"
android:layout_width="282dp"
android:layout_height="54dp"
android:layout_marginTop="360dp"
android:hint="密码"
android:inputType="textPassword"
android:maxLines="2"
android:textColor="#000000"
app:layout_constraintBottom_toBottomOf="parent"
......@@ -35,28 +50,27 @@
app:layout_constraintHorizontal_bias="0.519"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.009" />
app:layout_constraintVertical_bias="0.123" />
<EditText
android:id="@+id/editText3"
android:id="@+id/password2"
android:layout_width="287dp"
android:layout_height="56dp"
android:editable="true"
android:hint="确认密码"
android:inputType="textPassword"
android:maxLines="2"
android:textColor="#000000"
app:layout_constraintBottom_toTopOf="@+id/button123"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.54"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editText2"
app:layout_constraintVertical_bias="0.806"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.684"
tools:ignore="Deprecated" />
<Button
android:id="@+id/button123"
android:id="@+id/button"
android:layout_width="357dp"
android:layout_height="74dp"
android:text="注册"
......
......@@ -3,18 +3,20 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_height="wrap_content"
android:background="@color/colorPrimary">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/userhead_drawerlayout"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/icon_head"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.50"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.7">
</de.hdodenhof.circleimageview.CircleImageView>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册