Skip to content

Commit

Permalink
又不好用了
Browse files Browse the repository at this point in the history
  • Loading branch information
wrp committed Jan 28, 2024
1 parent f9a564b commit 5f02ca7
Show file tree
Hide file tree
Showing 17 changed files with 145 additions and 1,231 deletions.
16 changes: 8 additions & 8 deletions manager/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,14 @@ dependencies {
implementation("com.google.android.material:material:1.8.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")

implementation ("io.reactivex.rxjava2:rxandroid:2.0.1")
implementation ("io.reactivex.rxjava2:rxjava:2.1.8")
implementation ("com.squareup.retrofit2:retrofit:2.4.0")
implementation ("com.squareup.retrofit2:converter-gson:2.4.0")
// implementation ("com.squareup.retrofit2:converter-scalars:2.4.0")
implementation ("com.squareup.retrofit2:adapter-rxjava2:2.4.0")
// implementation ("com.squareup.okhttp3:logging-interceptor:4.10.0")
implementation( "com.jakewharton.rxrelay2:rxrelay:2.1.0")
// implementation ("io.reactivex.rxjava2:rxandroid:2.0.1")
// implementation ("io.reactivex.rxjava2:rxjava:2.1.8")
// implementation ("com.squareup.retrofit2:retrofit:2.4.0")
// implementation ("com.squareup.retrofit2:converter-gson:2.4.0")
// implementation ("com.squareup.retrofit2:adapter-rxjava2:2.4.0")
// implementation( "com.jakewharton.rxrelay2:rxrelay:2.1.0")

// implementation ("com.squareup.okhttp3:logging-interceptor:4.10.0")
// implementation ("com.squareup.okhttp3:okhttp:4.10.0")
// implementation ("com.squareup.okhttp:okhttp-urlconnection:2.2.0")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;

import me.weishu.kernelsu.bean.HttpResult;
import me.weishu.kernelsu.bean.LoginResult;
import me.weishu.kernelsu.databinding.LoginActivityBinding;
import me.weishu.kernelsu.net.CommonRetrofitManager;

import me.weishu.kernelsu.utils.SpUtils;

public class LoginActivity extends AppCompatActivity {
Expand All @@ -28,12 +27,10 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
inflate = LoginActivityBinding.inflate(getLayoutInflater());
setContentView(inflate.getRoot());
// startActivity(new Intent(LoginActivity.this, me.weishu.kernelsu.ui.MainActivity.class));
startActivity(new Intent(LoginActivity.this, me.weishu.kernelsu.ui.MainActivity.class));
String token = SpUtils.getInstance().getString("token", "");
if (!TextUtils.isEmpty(token)) {

startActivity(new Intent(LoginActivity.this,MainActivity.class));

finish();
return;
}
Expand All @@ -52,44 +49,44 @@ private void login() {
Toast.makeText(this, "请输入激活码", Toast.LENGTH_SHORT).show();
return;
}
Disposable subscribe = CommonRetrofitManager.getInstance().login(strCode).subscribe(new Consumer<LoginResult>() {
@Override
public void accept(LoginResult loginResult) throws Exception {

if (loginResult.getCode() == 1) {
String token = loginResult.getData().getToken();
// Settings.System.putString(LoginActivity.this.getContentResolver(), "token", token);
setToken(token);
SpUtils.getInstance().putString("token", token);

startActivity(new Intent(LoginActivity.this, MainActivity.class));
finish();
} else {
Toast.makeText(LoginActivity.this, "激活失败", Toast.LENGTH_SHORT).show();
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
throwable.printStackTrace();
Toast.makeText(LoginActivity.this, "激活失败", Toast.LENGTH_SHORT).show();
}
});
// Disposable subscribe = CommonRetrofitManager.getInstance().login(strCode).subscribe(new Consumer<LoginResult>() {
// @Override
// public void accept(LoginResult loginResult) throws Exception {
//
// if (loginResult.getCode() == 1) {
// String token = loginResult.getData().getToken();
//// Settings.System.putString(LoginActivity.this.getContentResolver(), "token", token);
// setToken(token);
// SpUtils.getInstance().putString("token", token);
//
// startActivity(new Intent(LoginActivity.this, MainActivity.class));
// finish();
// } else {
// Toast.makeText(LoginActivity.this, "激活失败", Toast.LENGTH_SHORT).show();
// }
// }
// }, new Consumer<Throwable>() {
// @Override
// public void accept(Throwable throwable) throws Exception {
// throwable.printStackTrace();
// Toast.makeText(LoginActivity.this, "激活失败", Toast.LENGTH_SHORT).show();
// }
// });

}

private void setToken(String token) {
CommonRetrofitManager.getInstance().setToken(token).subscribe(new Consumer<HttpResult>() {
@Override
public void accept(HttpResult result) throws Exception {

}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {

}
});
// CommonRetrofitManager.getInstance().setToken(token).subscribe(new Consumer<HttpResult>() {
// @Override
// public void accept(HttpResult result) throws Exception {
//
// }
// }, new Consumer<Throwable>() {
// @Override
// public void accept(Throwable throwable) throws Exception {
//
// }
// });
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import io.reactivex.functions.Consumer;

import me.weishu.kernelsu.R;
import me.weishu.kernelsu.bean.HttpResult;
import me.weishu.kernelsu.databinding.ActivityVpnSetBinding;

import me.weishu.kernelsu.net.CommonRetrofitManager;
import me.weishu.kernelsu.utils.ApiUtils;
//import me.weishu.kernelsu.utils.GsonUtils;
import me.weishu.kernelsu.utils.VpnUtils;
Expand Down Expand Up @@ -61,25 +60,25 @@ public void onClick(View view) {
}


CommonRetrofitManager.getInstance().startVpn(ip, port, userName, pwd).subscribe(new Consumer<HttpResult>() {
@Override
public void accept(HttpResult result) throws Exception {
if ("1".equals(result.getRet())) {
showMsg("开启成功");
} else {
showMsg("开启失败");
}
dialog.dismiss();
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
throwable.printStackTrace();
showMsg("开启失败");
dialog.dismiss();
}
});

// CommonRetrofitManager.getInstance().startVpn(ip, port, userName, pwd).subscribe(new Consumer<HttpResult>() {
// @Override
// public void accept(HttpResult result) throws Exception {
// if ("1".equals(result.getRet())) {
// showMsg("开启成功");
// } else {
// showMsg("开启失败");
// }
// dialog.dismiss();
// }
// }, new Consumer<Throwable>() {
// @Override
// public void accept(Throwable throwable) throws Exception {
// throwable.printStackTrace();
// showMsg("开启失败");
// dialog.dismiss();
// }
// });
//
}
});

Expand All @@ -94,24 +93,24 @@ public void onClick(View view) {
dialog.show();
}

CommonRetrofitManager.getInstance().closeVpn().subscribe(new Consumer<HttpResult>() {
@Override
public void accept(HttpResult result) throws Exception {
if ("1".equals(result.getRet())) {
showMsg("关闭成功");
} else {
showMsg("关闭失败");
}
dialog.dismiss();
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
throwable.printStackTrace();
showMsg("关闭失败");
dialog.dismiss();
}
});
// CommonRetrofitManager.getInstance().closeVpn().subscribe(new Consumer<HttpResult>() {
// @Override
// public void accept(HttpResult result) throws Exception {
// if ("1".equals(result.getRet())) {
// showMsg("关闭成功");
// } else {
// showMsg("关闭失败");
// }
// dialog.dismiss();
// }
// }, new Consumer<Throwable>() {
// @Override
// public void accept(Throwable throwable) throws Exception {
// throwable.printStackTrace();
// showMsg("关闭失败");
// dialog.dismiss();
// }
// });

}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@
import java.util.List;


import io.reactivex.functions.Consumer;
import me.weishu.kernelsu.R;
import me.weishu.kernelsu.bean.AppItem;
import me.weishu.kernelsu.bean.EventMessage;
import me.weishu.kernelsu.bean.HttpResult;
import me.weishu.kernelsu.databinding.FragmentBackupBinding;
import me.weishu.kernelsu.dialog.TaskInfoDialog;

import me.weishu.kernelsu.net.CommonRetrofitManager;

import me.weishu.kernelsu.utils.ApiUtils;
import me.weishu.kernelsu.utils.AppUtils;
import me.weishu.kernelsu.utils.EventCode;
Expand Down Expand Up @@ -108,22 +107,22 @@ private void backUp() throws Exception {

String pkgName = split[1];

CommonRetrofitManager.getInstance().backUpApp(pkgName).subscribe(new Consumer<HttpResult>() {
@Override
public void accept(HttpResult result) throws Exception {
if ("1".equals(result.getRet())) {
EventBus.getDefault().post(new EventMessage(EventCode.SET_TASK_INFO,"备份完成"));
}else{
EventBus.getDefault().post(new EventMessage(EventCode.SET_TASK_INFO,"备份失败"));
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
throwable.printStackTrace();
EventBus.getDefault().post(new EventMessage(EventCode.SET_TASK_INFO,"备份失败"));
}
});
// CommonRetrofitManager.getInstance().backUpApp(pkgName).subscribe(new Consumer<HttpResult>() {
// @Override
// public void accept(HttpResult result) throws Exception {
// if ("1".equals(result.getRet())) {
// EventBus.getDefault().post(new EventMessage(EventCode.SET_TASK_INFO,"备份完成"));
// }else{
// EventBus.getDefault().post(new EventMessage(EventCode.SET_TASK_INFO,"备份失败"));
// }
// }
// }, new Consumer<Throwable>() {
// @Override
// public void accept(Throwable throwable) throws Exception {
// throwable.printStackTrace();
// EventBus.getDefault().post(new EventMessage(EventCode.SET_TASK_INFO,"备份失败"));
// }
// });


}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
import java.util.ArrayList;


import io.reactivex.functions.Consumer;

import me.weishu.kernelsu.R;
import me.weishu.kernelsu.adapter.RestoreAdapter;
import me.weishu.kernelsu.bean.EventMessage;
import me.weishu.kernelsu.bean.HttpResult;
import me.weishu.kernelsu.databinding.FragmentResetBinding;
import me.weishu.kernelsu.dialog.TaskInfoDialog;

import me.weishu.kernelsu.net.CommonRetrofitManager;

import me.weishu.kernelsu.ui.util.KsuCli;
import me.weishu.kernelsu.utils.ApiUtils;
import me.weishu.kernelsu.utils.AppUtils;
Expand Down Expand Up @@ -159,22 +159,22 @@ private void resetApp(String fileName) throws Exception {

EventBus.getDefault().post(new EventMessage(EventCode.SET_TASK_INFO,"开始还原"));

CommonRetrofitManager.getInstance().restApp("com.mmbox.xbrowser",fileName).subscribe(new Consumer<HttpResult>() {
@Override
public void accept(HttpResult result) throws Exception {
if ("1".equals(result.getRet())) {
EventBus.getDefault().post(new EventMessage(EventCode.SET_TASK_INFO,"还原完成"));
}else{
EventBus.getDefault().post(new EventMessage(EventCode.SET_TASK_INFO,"还原失败"));
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
throwable.printStackTrace();
EventBus.getDefault().post(new EventMessage(EventCode.SET_TASK_INFO,"还原失败"));
}
});
// CommonRetrofitManager.getInstance().restApp("com.mmbox.xbrowser",fileName).subscribe(new Consumer<HttpResult>() {
// @Override
// public void accept(HttpResult result) throws Exception {
// if ("1".equals(result.getRet())) {
// EventBus.getDefault().post(new EventMessage(EventCode.SET_TASK_INFO,"还原完成"));
// }else{
// EventBus.getDefault().post(new EventMessage(EventCode.SET_TASK_INFO,"还原失败"));
// }
// }
// }, new Consumer<Throwable>() {
// @Override
// public void accept(Throwable throwable) throws Exception {
// throwable.printStackTrace();
// EventBus.getDefault().post(new EventMessage(EventCode.SET_TASK_INFO,"还原失败"));
// }
// });


}
Expand Down
Loading

0 comments on commit 5f02ca7

Please sign in to comment.