This commit is contained in:
z583819556
2024-03-04 15:10:37 +08:00
parent c9860b5aa2
commit 0d65df5271
46 changed files with 1237 additions and 3 deletions

View File

@@ -32,7 +32,13 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.11.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation project(path:":netlibs")
api 'com.squareup.okhttp3:okhttp:3.14.9'
api 'com.squareup.retrofit2:retrofit:2.3.0'
api 'com.alibaba.fastjson2:fastjson2:2.0.47'
}

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
@@ -9,8 +9,28 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:usesCleartextTraffic="true"
android:supportsRtl="true"
android:theme="@style/Theme.NetTools"
tools:targetApi="31" />
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="um.64e40ee55488fe7b3afa2c96" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -0,0 +1,24 @@
package com.yutou.nettools;
import com.yutou.netlibs.http.API;
import java.util.HashMap;
public class Api extends API<HttpApi> {
public Api(String url) {
super(url);
}
public Api(String url, HashMap<String, String> params) {
super(url, params);
}
public static HttpApi getInstance(HashMap<String, String> params){
return new Api("http://tools.yutou233.cn",params).createAPI(HttpApi.class);
}
public static HttpApi getInstance(){
return new Api("http://tools.yutou233.cn").createAPI(HttpApi.class);
}
}

View File

@@ -0,0 +1,34 @@
package com.yutou.nettools;
public class Bean {
String url;
String version;
public Bean() {
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
@Override
public String toString() {
return "Bean{" +
"url='" + url + '\'' +
", version='" + version + '\'' +
'}';
}
}

View File

@@ -0,0 +1,24 @@
package com.yutou.nettools;
import com.yutou.netlibs.http.HttpBody;
import java.util.List;
import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;
public interface HttpApi {
@GET("/public/request.do")
Call<HttpBody<Bean>> getVersion();
@GET("tools/password/type/get/list.do")
Call<HttpBody<List<Password>>> getList(@Query("token")String token);
@FormUrlEncoded
@POST("/public/request.do")
Call<HttpBody<Bean>> postVersion(@Field("test")String data);
}

View File

@@ -0,0 +1,48 @@
package com.yutou.nettools;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.yutou.netlibs.http.HttpBody;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.button)
.setOnClickListener(v -> {
Api.getInstance().getList("")
.enqueue(new Callback<HttpBody<List<Password>>>() {
@Override
public void onResponse(Call<HttpBody<List<Password>>> call, Response<HttpBody<List<Password>>> response) {
System.out.println("response = " + response.body().getData());
}
@Override
public void onFailure(Call<HttpBody<List<Password>>> call, Throwable t) {
}
});
Api.getInstance().getVersion().enqueue(new Callback<HttpBody<Bean>>() {
@Override
public void onResponse(Call<HttpBody<Bean>> call, Response<HttpBody<Bean>> response) {
System.out.println("response = " + response.body().getData());
}
@Override
public void onFailure(Call<HttpBody<Bean>> call, Throwable t) {
}
});
});
}
}

View File

@@ -0,0 +1,101 @@
package com.yutou.nettools;
public class Password {
private int id;
private String info;
private String password; // 实际应用中,密码不应该以明文形式存储或传输
private String title;
private String titlePinyin;
private int type;
private int uid;
private String url;
private String username;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getInfo() {
return info;
}
public void setInfo(String info) {
this.info = info;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getTitlePinyin() {
return titlePinyin;
}
public void setTitlePinyin(String titlePinyin) {
this.titlePinyin = titlePinyin;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public int getUid() {
return uid;
}
public void setUid(int uid) {
this.uid = uid;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
@Override
public String toString() {
return "Password{" +
"id=" + id +
", info='" + info + '\'' +
", password='" + password + '\'' +
", title='" + title + '\'' +
", titlePinyin='" + titlePinyin + '\'' +
", type=" + type +
", uid=" + uid +
", url='" + url + '\'' +
", username='" + username + '\'' +
'}';
}
}

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="306dp"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>