正式版1.1版
新增备注功能 数据库更新
This commit is contained in:
parent
e12cd888b5
commit
ac900e5647
@ -3,6 +3,20 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
android {
|
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
|
compileSdkVersion 30
|
||||||
buildToolsVersion "30.0.2"
|
buildToolsVersion "30.0.2"
|
||||||
|
|
||||||
@ -11,9 +25,10 @@ android {
|
|||||||
minSdkVersion 23
|
minSdkVersion 23
|
||||||
targetSdkVersion 30
|
targetSdkVersion 30
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.1"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
signingConfig signingConfigs.yutou
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.yutou.passmanage">
|
package="com.yutou.passmanage">
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:icon="@mipmap/app_icon"
|
android:icon="@mipmap/app_icon"
|
||||||
|
@ -84,13 +84,15 @@ public class PassWordListAdapter extends RecyclerView.Adapter<PassWordListAdapte
|
|||||||
private void showDialog(ToolsPassword data, int position) {
|
private void showDialog(ToolsPassword data, int position) {
|
||||||
View view = LayoutInflater.from(context.getApplicationContext()).inflate(R.layout.dialog_add_passworld, null);
|
View view = LayoutInflater.from(context.getApplicationContext()).inflate(R.layout.dialog_add_passworld, null);
|
||||||
Button delete = view.findViewById(R.id.delete);
|
Button delete = view.findViewById(R.id.delete);
|
||||||
EditText title, account, password;
|
EditText title, account, password,info;
|
||||||
title = view.findViewById(R.id.title);
|
title = view.findViewById(R.id.title);
|
||||||
account = view.findViewById(R.id.account);
|
account = view.findViewById(R.id.account);
|
||||||
password = view.findViewById(R.id.myPassword);
|
password = view.findViewById(R.id.myPassword);
|
||||||
|
info=view.findViewById(R.id.info);
|
||||||
title.setText(data.getTitle());
|
title.setText(data.getTitle());
|
||||||
account.setText(data.getAccount());
|
account.setText(data.getAccount());
|
||||||
password.setText(data.getPassword());
|
password.setText(data.getPassword());
|
||||||
|
info.setText(data.getInfo());
|
||||||
delete.setVisibility(View.VISIBLE);
|
delete.setVisibility(View.VISIBLE);
|
||||||
delete.setOnClickListener(new View.OnClickListener() {
|
delete.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -149,7 +151,7 @@ public class PassWordListAdapter extends RecyclerView.Adapter<PassWordListAdapte
|
|||||||
.setTitle("查看信息")
|
.setTitle("查看信息")
|
||||||
.setView(view)
|
.setView(view)
|
||||||
.setPositiveButton("更新", (dialog1, which) -> {
|
.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
|
@Override
|
||||||
public void httpGetData(Object data, int state) {
|
public void httpGetData(Object data, int state) {
|
||||||
addDatabase(title.getText().toString(),
|
addDatabase(title.getText().toString(),
|
||||||
|
@ -22,7 +22,7 @@ public class ToolsPassword{
|
|||||||
private String password;
|
private String password;
|
||||||
@Ignore
|
@Ignore
|
||||||
private String url;
|
private String url;
|
||||||
@Ignore
|
@ColumnInfo
|
||||||
private String info;
|
private String info;
|
||||||
@ColumnInfo
|
@ColumnInfo
|
||||||
private Integer type;
|
private Integer type;
|
||||||
|
@ -14,8 +14,8 @@ public interface ToolsPasswordDao {
|
|||||||
List<ToolsPassword> getAllAndRemove();
|
List<ToolsPassword> getAllAndRemove();
|
||||||
@Query("select * from ToolsPassword where remove=0")
|
@Query("select * from ToolsPassword where remove=0")
|
||||||
List<ToolsPassword> getAll();
|
List<ToolsPassword> getAll();
|
||||||
@Query("select * from ToolsPassword where title=:title and account=:account and password=: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);
|
ToolsPassword isExist(String title,String account,String password,String info);
|
||||||
@Query("select * from ToolsPassword where title like :title and remove=0")
|
@Query("select * from ToolsPassword where title like :title and remove=0")
|
||||||
List<ToolsPassword> queryPassword(String title);
|
List<ToolsPassword> queryPassword(String title);
|
||||||
@Insert
|
@Insert
|
||||||
|
@ -157,15 +157,16 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
void showAddPasswordDialog() {
|
void showAddPasswordDialog() {
|
||||||
View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.dialog_add_passworld, null);
|
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);
|
title = view.findViewById(R.id.title);
|
||||||
account = view.findViewById(R.id.account);
|
account = view.findViewById(R.id.account);
|
||||||
password = view.findViewById(R.id.myPassword);
|
password = view.findViewById(R.id.myPassword);
|
||||||
|
info=view.findViewById(R.id.info);
|
||||||
AlertDialog dialog = new AlertDialog.Builder(MainActivity.this)
|
AlertDialog dialog = new AlertDialog.Builder(MainActivity.this)
|
||||||
.setTitle("添加账号")
|
.setTitle("添加账号")
|
||||||
.setView(view)
|
.setView(view)
|
||||||
.setPositiveButton("保存", (dialog1, which) -> {
|
.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
|
@Override
|
||||||
public void httpGetData(Object data, int state) {
|
public void httpGetData(Object data, int state) {
|
||||||
addDatabase(title.getText().toString(),
|
addDatabase(title.getText().toString(),
|
||||||
@ -234,9 +235,8 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
List<ToolsPassword> list = dao.getAllAndRemove();
|
List<ToolsPassword> list = dao.getAllAndRemove();
|
||||||
for (ToolsPassword password : list) {
|
for (ToolsPassword password : list) {
|
||||||
System.out.println(JSONObject.toJSONString(password));
|
|
||||||
if (!password.isUpload() && !password.isRemove()) {
|
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
|
@Override
|
||||||
public void httpGetData(Object data, int state) {
|
public void httpGetData(Object data, int state) {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
@ -291,13 +291,14 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
NetworkTool.httpGet(NetworkTool.NetworkAPI.PASSWORD_ALL, new JSONObject(), new NetworkInterface() {
|
NetworkTool.httpGet(NetworkTool.NetworkAPI.PASSWORD_ALL, new JSONObject(), new NetworkInterface() {
|
||||||
@Override
|
@Override
|
||||||
public void httpGetData(Object data, int state) {
|
public void httpGetData(Object data, int state) {
|
||||||
|
data=((String)data).replace("desc","info");
|
||||||
JSONObject json = JSONObject.parseObject((String) data);
|
JSONObject json = JSONObject.parseObject((String) data);
|
||||||
if (json.getInteger("code") == 0) {
|
if (json.getInteger("code") == 0) {
|
||||||
List<ToolsPassword> list = JSONArray.parseArray(json.getJSONArray("data").toJSONString(), ToolsPassword.class);
|
List<ToolsPassword> list = JSONArray.parseArray(json.getJSONArray("data").toJSONString(), ToolsPassword.class);
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
for (ToolsPassword password : list) {
|
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);
|
password.setUpload(true);
|
||||||
dao.insert(password);
|
dao.insert(password);
|
||||||
}
|
}
|
||||||
@ -306,7 +307,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
dao.clear();
|
dao.clear();
|
||||||
for (ToolsPassword password : list) {
|
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);
|
password.setUpload(true);
|
||||||
dao.insert(password);
|
dao.insert(password);
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,8 @@ import androidx.room.DatabaseConfiguration;
|
|||||||
import androidx.room.InvalidationTracker;
|
import androidx.room.InvalidationTracker;
|
||||||
import androidx.room.Room;
|
import androidx.room.Room;
|
||||||
import androidx.room.RoomDatabase;
|
import androidx.room.RoomDatabase;
|
||||||
|
import androidx.room.migration.Migration;
|
||||||
|
import androidx.sqlite.db.SupportSQLiteDatabase;
|
||||||
import androidx.sqlite.db.SupportSQLiteOpenHelper;
|
import androidx.sqlite.db.SupportSQLiteOpenHelper;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
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.Datas.ToolsPasswordDao;
|
||||||
import com.yutou.passmanage.Interfaces.NetworkInterface;
|
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 class RoomDatabaseManager extends RoomDatabase {
|
||||||
public abstract ToolsPasswordDao passwordDao();
|
public abstract ToolsPasswordDao passwordDao();
|
||||||
|
|
||||||
@ -35,17 +37,26 @@ public abstract class RoomDatabaseManager extends RoomDatabase {
|
|||||||
public void clearAllTables() {
|
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) {
|
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();
|
JSONObject json = new JSONObject();
|
||||||
json.put("title", title);
|
json.put("title", title);
|
||||||
json.put("username", account);
|
json.put("username", account);
|
||||||
json.put("password", password);
|
json.put("password", password);
|
||||||
json.put("url", "");
|
json.put("url", "");
|
||||||
json.put("info", "");
|
json.put("info", info);
|
||||||
json.put("type", "-1");
|
json.put("type", "-1");
|
||||||
if(id!=-1){
|
if(id!=-1){
|
||||||
json.put("id",id);
|
json.put("id",id);
|
||||||
|
@ -71,6 +71,32 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:ems="10"
|
android:ems="10"
|
||||||
android:hint="密码" />
|
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>
|
</LinearLayout>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
@ -5,7 +5,7 @@ buildscript {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
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
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
|
Loading…
Reference in New Issue
Block a user