正式版1.1版

新增备注功能
数据库更新
This commit is contained in:
Yutousama 2021-06-30 20:51:48 +08:00
parent e12cd888b5
commit ac900e5647
9 changed files with 73 additions and 17 deletions

View File

@ -3,6 +3,20 @@ plugins {
}
android {
signingConfigs {
debug {
storeFile file('D:\\AndroidKeys\\yutou.jks')
storePassword '34864394'
keyAlias 'yutou'
keyPassword '34864394'
}
yutou {
storeFile file('D:\\AndroidKeys\\yutou.jks')
storePassword '34864394'
keyAlias 'yutou'
keyPassword '34864394'
}
}
compileSdkVersion 30
buildToolsVersion "30.0.2"
@ -11,9 +25,10 @@ android {
minSdkVersion 23
targetSdkVersion 30
versionCode 1
versionName "1.0"
versionName "1.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
signingConfig signingConfigs.yutou
}
buildTypes {

View File

@ -2,6 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yutou.passmanage">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@mipmap/app_icon"

View File

@ -84,13 +84,15 @@ public class PassWordListAdapter extends RecyclerView.Adapter<PassWordListAdapte
private void showDialog(ToolsPassword data, int position) {
View view = LayoutInflater.from(context.getApplicationContext()).inflate(R.layout.dialog_add_passworld, null);
Button delete = view.findViewById(R.id.delete);
EditText title, account, password;
EditText title, account, password,info;
title = view.findViewById(R.id.title);
account = view.findViewById(R.id.account);
password = view.findViewById(R.id.myPassword);
info=view.findViewById(R.id.info);
title.setText(data.getTitle());
account.setText(data.getAccount());
password.setText(data.getPassword());
info.setText(data.getInfo());
delete.setVisibility(View.VISIBLE);
delete.setOnClickListener(new View.OnClickListener() {
@Override
@ -149,7 +151,7 @@ public class PassWordListAdapter extends RecyclerView.Adapter<PassWordListAdapte
.setTitle("查看信息")
.setView(view)
.setPositiveButton("更新", (dialog1, which) -> {
addPassword(title.getText().toString(), account.getText().toString(), password.getText().toString(), data.getId(), false, new NetworkInterface() {
addPassword(title.getText().toString(), account.getText().toString(), password.getText().toString(),info.getText().toString(), data.getId(), false, new NetworkInterface() {
@Override
public void httpGetData(Object data, int state) {
addDatabase(title.getText().toString(),

View File

@ -22,7 +22,7 @@ public class ToolsPassword{
private String password;
@Ignore
private String url;
@Ignore
@ColumnInfo
private String info;
@ColumnInfo
private Integer type;

View File

@ -14,8 +14,8 @@ public interface ToolsPasswordDao {
List<ToolsPassword> getAllAndRemove();
@Query("select * from ToolsPassword where remove=0")
List<ToolsPassword> getAll();
@Query("select * from ToolsPassword where title=:title and account=:account and password=:password")
ToolsPassword isExist(String title,String account,String password);
@Query("select * from ToolsPassword where title=:title and account=:account and password=:password and info=:info")
ToolsPassword isExist(String title,String account,String password,String info);
@Query("select * from ToolsPassword where title like :title and remove=0")
List<ToolsPassword> queryPassword(String title);
@Insert

View File

@ -157,15 +157,16 @@ public class MainActivity extends AppCompatActivity {
void showAddPasswordDialog() {
View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.dialog_add_passworld, null);
EditText title, account, password;
EditText title, account, password,info;
title = view.findViewById(R.id.title);
account = view.findViewById(R.id.account);
password = view.findViewById(R.id.myPassword);
info=view.findViewById(R.id.info);
AlertDialog dialog = new AlertDialog.Builder(MainActivity.this)
.setTitle("添加账号")
.setView(view)
.setPositiveButton("保存", (dialog1, which) -> {
addPassword(title.getText().toString(), account.getText().toString(), password.getText().toString(), -1, true, new NetworkInterface() {
addPassword(title.getText().toString(), account.getText().toString(), password.getText().toString(), info.getText().toString(),-1, true, new NetworkInterface() {
@Override
public void httpGetData(Object data, int state) {
addDatabase(title.getText().toString(),
@ -234,9 +235,8 @@ public class MainActivity extends AppCompatActivity {
new Thread(() -> {
List<ToolsPassword> list = dao.getAllAndRemove();
for (ToolsPassword password : list) {
System.out.println(JSONObject.toJSONString(password));
if (!password.isUpload() && !password.isRemove()) {
addPassword(password.getTitle(), password.getAccount(), password.getPassword(), -1, true, new NetworkInterface() {
addPassword(password.getTitle(), password.getAccount(), password.getPassword(),password.getInfo(), -1, true, new NetworkInterface() {
@Override
public void httpGetData(Object data, int state) {
new Thread(() -> {
@ -291,13 +291,14 @@ public class MainActivity extends AppCompatActivity {
NetworkTool.httpGet(NetworkTool.NetworkAPI.PASSWORD_ALL, new JSONObject(), new NetworkInterface() {
@Override
public void httpGetData(Object data, int state) {
data=((String)data).replace("desc","info");
JSONObject json = JSONObject.parseObject((String) data);
if (json.getInteger("code") == 0) {
List<ToolsPassword> list = JSONArray.parseArray(json.getJSONArray("data").toJSONString(), ToolsPassword.class);
new Thread(() -> {
try {
for (ToolsPassword password : list) {
if (dao.isExist(password.getTitle(), password.getAccount(), password.getPassword()) == null) {
if (dao.isExist(password.getTitle(), password.getAccount(), password.getPassword(),password.getInfo()) == null) {
password.setUpload(true);
dao.insert(password);
}
@ -306,7 +307,7 @@ public class MainActivity extends AppCompatActivity {
e.printStackTrace();
dao.clear();
for (ToolsPassword password : list) {
if (dao.isExist(password.getTitle(), password.getAccount(), password.getPassword()) == null) {
if (dao.isExist(password.getTitle(), password.getAccount(), password.getPassword(),password.getInfo()) == null) {
password.setUpload(true);
dao.insert(password);
}

View File

@ -8,6 +8,8 @@ import androidx.room.DatabaseConfiguration;
import androidx.room.InvalidationTracker;
import androidx.room.Room;
import androidx.room.RoomDatabase;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
import androidx.sqlite.db.SupportSQLiteOpenHelper;
import com.alibaba.fastjson.JSONObject;
@ -15,7 +17,7 @@ import com.yutou.passmanage.Datas.ToolsPassword;
import com.yutou.passmanage.Datas.ToolsPasswordDao;
import com.yutou.passmanage.Interfaces.NetworkInterface;
@Database(entities = {ToolsPassword.class}, version = 1,exportSchema = false)
@Database(entities = {ToolsPassword.class}, version = 2,exportSchema = false)
public abstract class RoomDatabaseManager extends RoomDatabase {
public abstract ToolsPasswordDao passwordDao();
@ -35,17 +37,26 @@ public abstract class RoomDatabaseManager extends RoomDatabase {
public void clearAllTables() {
}
private static final Migration update1to2=new Migration(1,2) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase database) {
database.execSQL("ALTER TABLE ToolsPassword ADD COLUMN `info` ` TEXT` ");
}
};
public static RoomDatabaseManager build(Context context) {
return Room.databaseBuilder(context.getApplicationContext(), RoomDatabaseManager.class, "password.db").build();
return Room.databaseBuilder(context.getApplicationContext(), RoomDatabaseManager.class, "password.db")
.addMigrations(update1to2)
.build();
}
public static void addPassword(String title, String account, String password,int id,boolean isAdd, NetworkInterface networkInterface) {
public static void addPassword(String title, String account, String password,String info,int id,boolean isAdd, NetworkInterface networkInterface) {
JSONObject json = new JSONObject();
json.put("title", title);
json.put("username", account);
json.put("password", password);
json.put("url", "");
json.put("info", "");
json.put("info", info);
json.put("type", "-1");
if(id!=-1){
json.put("id",id);

View File

@ -71,6 +71,32 @@
android:layout_weight="1"
android:ems="10"
android:hint="密码" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:text="备注" />
<EditText
android:id="@+id/info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:gravity="start|top"
android:hint="这里可以填写备注信息"
android:inputType="textMultiLine"
android:minLines="5" />
</LinearLayout>
<Button

View File

@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.2"
classpath 'com.android.tools.build:gradle:4.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files