|
|
@ -2,39 +2,105 @@ package com.thankvinci.CloudKey.Fragment;
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.DialogInterface;
|
|
|
|
import android.content.DialogInterface;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
|
|
|
import android.os.Handler;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.View;
|
|
|
|
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
|
|
|
|
import android.widget.CheckBox;
|
|
|
|
import android.widget.EditText;
|
|
|
|
import android.widget.EditText;
|
|
|
|
|
|
|
|
import android.widget.TextView;
|
|
|
|
import android.widget.Toast;
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
import androidx.appcompat.app.AlertDialog;
|
|
|
|
import androidx.appcompat.app.AlertDialog;
|
|
|
|
import androidx.fragment.app.DialogFragment;
|
|
|
|
import androidx.fragment.app.DialogFragment;
|
|
|
|
|
|
|
|
|
|
|
|
import com.thankvinci.CloudKey.R;
|
|
|
|
import com.thankvinci.CloudKey.R;
|
|
|
|
|
|
|
|
import com.thankvinci.CloudKey.Utils.FileHandler;
|
|
|
|
|
|
|
|
import com.thankvinci.CloudKey.Utils.FileThread;
|
|
|
|
|
|
|
|
|
|
|
|
public class UnzipDialogFragment extends DialogFragment {
|
|
|
|
public class UnzipDialogFragment extends DialogFragment {
|
|
|
|
//点击压缩文件弹出来的Dialog
|
|
|
|
//点击压缩文件弹出来的Dialog
|
|
|
|
private UnzipDialogListener listener;
|
|
|
|
private UnzipDialogListener listener;
|
|
|
|
//源文件绝对路径,目标文件夹绝对路径和密码
|
|
|
|
//源文件绝对路径,目标文件夹绝对路径,md5码和密码
|
|
|
|
private EditText srcFile_edit;
|
|
|
|
private EditText srcFile_edit,desPath_edit,md5_edit,passwd_edit;
|
|
|
|
private EditText desPath_edit;
|
|
|
|
//用户勾选是否同意将密码上传到数据库
|
|
|
|
private EditText passwd_edit;
|
|
|
|
private CheckBox acceptPWD2SQL;
|
|
|
|
|
|
|
|
//用于判断密码来源是否是数据库,是的话勾选checkbox也不会进行上传操作
|
|
|
|
|
|
|
|
private boolean fromSQL;
|
|
|
|
|
|
|
|
//点击该文字就连接数据库查找密码
|
|
|
|
|
|
|
|
private TextView getPWD;
|
|
|
|
|
|
|
|
//解压的参数
|
|
|
|
|
|
|
|
private String srcFile,desPath,md5,passwd;
|
|
|
|
|
|
|
|
|
|
|
|
public interface UnzipDialogListener{
|
|
|
|
public interface UnzipDialogListener{
|
|
|
|
public void onDialogUnzipClicked();
|
|
|
|
public void onDialogUnzipClicked();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onCreate(Bundle savedInstanceState){
|
|
|
|
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
|
|
srcFile = getArguments().getString("srcFile");
|
|
|
|
|
|
|
|
desPath = getArguments().getString("desPath");
|
|
|
|
|
|
|
|
passwd = getArguments().getString("passwd");
|
|
|
|
|
|
|
|
}
|
|
|
|
public void setListener(UnzipDialogListener listener){
|
|
|
|
public void setListener(UnzipDialogListener listener){
|
|
|
|
this.listener = listener;
|
|
|
|
this.listener = listener;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public AlertDialog onCreateDialog(Bundle bundle){
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState) {
|
|
|
|
|
|
|
|
Toast.makeText(getActivity(),"onCreateView",Toast.LENGTH_SHORT).show();
|
|
|
|
|
|
|
|
return super.onCreateView(inflater, container, savedInstanceState);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public AlertDialog onCreateDialog(Bundle savedInstanceState){
|
|
|
|
|
|
|
|
Toast.makeText(getActivity(),"onCreateDialog",Toast.LENGTH_SHORT).show();
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
|
|
|
LayoutInflater inflater = requireActivity().getLayoutInflater();
|
|
|
|
LayoutInflater inflater = requireActivity().getLayoutInflater();
|
|
|
|
View view = inflater.inflate(R.layout.unzip_dialog,null);
|
|
|
|
View view = inflater.inflate(R.layout.unzip_dialog,null);
|
|
|
|
|
|
|
|
|
|
|
|
srcFile_edit = view.findViewById(R.id.src_edit);
|
|
|
|
srcFile_edit = view.findViewById(R.id.src_edit);
|
|
|
|
|
|
|
|
srcFile_edit.setText(srcFile);
|
|
|
|
|
|
|
|
srcFile_edit.setSelection(srcFile.length());
|
|
|
|
|
|
|
|
|
|
|
|
desPath_edit = view.findViewById(R.id.des_edit);
|
|
|
|
desPath_edit = view.findViewById(R.id.des_edit);
|
|
|
|
|
|
|
|
desPath_edit.setText(desPath);
|
|
|
|
|
|
|
|
desPath_edit.setSelection(desPath.length());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
passwd_edit = view.findViewById(R.id.pwd_edit);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
acceptPWD2SQL = view.findViewById(R.id.accept_pwd_2_sql);
|
|
|
|
|
|
|
|
getPWD = view.findViewById(R.id.getpwd);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
acceptPWD2SQL.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
|
|
|
if (acceptPWD2SQL.isChecked()){
|
|
|
|
|
|
|
|
Toast.makeText(getActivity(),"勾选同意",Toast.LENGTH_SHORT).show();
|
|
|
|
|
|
|
|
//网络线程
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
Toast.makeText(getActivity(),"取消勾选",Toast.LENGTH_SHORT).show();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
getPWD.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
|
|
|
//网络线程
|
|
|
|
|
|
|
|
Toast.makeText(getActivity(),"获取密码",Toast.LENGTH_SHORT).show();
|
|
|
|
|
|
|
|
Handler handler = new FileHandler(getActivity());
|
|
|
|
|
|
|
|
Thread ft = new Thread(new FileThread(handler,srcFile,desPath,null,FileHandler.FUNCTION_GET_MD5));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
builder.setView(view).setTitle("解压到当前路径").setPositiveButton("解压", new DialogInterface.OnClickListener() {
|
|
|
|
builder.setView(view).setTitle("解压到当前路径").setPositiveButton("解压", new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
|
|
|
if (acceptPWD2SQL.isChecked() && !fromSQL){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
listener.onDialogUnzipClicked();
|
|
|
|
listener.onDialogUnzipClicked();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
|
|
|
}).setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
|
|
@ -45,4 +111,7 @@ public class UnzipDialogFragment extends DialogFragment {
|
|
|
|
});;
|
|
|
|
});;
|
|
|
|
return builder.create();
|
|
|
|
return builder.create();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setPasswd(String passwd){
|
|
|
|
|
|
|
|
passwd_edit.setText(passwd);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|