From 9bf5016dd68744bfa7d892c43b086628826d7379 Mon Sep 17 00:00:00 2001
From: Soulter <37870767+Soulter@users.noreply.github.com>
Date: Sun, 1 May 2022 23:20:44 +0800
Subject: [PATCH] =?UTF-8?q?pref:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?=
=?UTF-8?q?=E7=BB=93=E6=9E=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/src/main/AndroidManifest.xml | 10 +-
.../{ => activity}/AddIDActivity.java | 23 +-
.../{ => activity}/IDLoginActivity.java | 13 +-
.../esndroid/{ => activity}/MainActivity.java | 305 +++++++-----------
.../{ => activity}/ServerLoginActivity.java | 4 +-
.../esndroid/{ => adapter}/IDListAdapter.java | 13 +-
.../{ => adapter}/MsgListAdapter.java | 7 +-
.../soulter/esndroid/{ => bean}/ESNBean.java | 2 +-
.../soulter/esndroid/{ => bean}/IDBean.java | 2 +-
.../soulter/esndroid/{ => bean}/MsgBean.java | 2 +-
.../esndroid/{ => service}/ConnService.java | 26 +-
app/src/main/res/layout/activity_add_i_d.xml | 2 +-
app/src/main/res/layout/activity_main.xml | 2 +-
13 files changed, 155 insertions(+), 256 deletions(-)
rename app/src/main/java/com/soulter/esndroid/{ => activity}/AddIDActivity.java (90%)
rename app/src/main/java/com/soulter/esndroid/{ => activity}/IDLoginActivity.java (94%)
rename app/src/main/java/com/soulter/esndroid/{ => activity}/MainActivity.java (59%)
rename app/src/main/java/com/soulter/esndroid/{ => activity}/ServerLoginActivity.java (98%)
rename app/src/main/java/com/soulter/esndroid/{ => adapter}/IDListAdapter.java (89%)
rename app/src/main/java/com/soulter/esndroid/{ => adapter}/MsgListAdapter.java (96%)
rename app/src/main/java/com/soulter/esndroid/{ => bean}/ESNBean.java (94%)
rename app/src/main/java/com/soulter/esndroid/{ => bean}/IDBean.java (93%)
rename app/src/main/java/com/soulter/esndroid/{ => bean}/MsgBean.java (96%)
rename app/src/main/java/com/soulter/esndroid/{ => service}/ConnService.java (95%)
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index b55c525..d7c2b9d 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -12,10 +12,10 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Esndroid">
-
-
-
-
+
+
+
+
@@ -24,7 +24,7 @@
diff --git a/app/src/main/java/com/soulter/esndroid/AddIDActivity.java b/app/src/main/java/com/soulter/esndroid/activity/AddIDActivity.java
similarity index 90%
rename from app/src/main/java/com/soulter/esndroid/AddIDActivity.java
rename to app/src/main/java/com/soulter/esndroid/activity/AddIDActivity.java
index 7ebb2df..031b49a 100644
--- a/app/src/main/java/com/soulter/esndroid/AddIDActivity.java
+++ b/app/src/main/java/com/soulter/esndroid/activity/AddIDActivity.java
@@ -1,44 +1,31 @@
-package com.soulter.esndroid;
+package com.soulter.esndroid.activity;
import androidx.annotation.Nullable;
-import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.cardview.widget.CardView;
import android.content.Context;
-import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
-import android.graphics.Typeface;
import android.os.Bundle;
-import android.os.Looper;
import android.util.Log;
-import android.view.Gravity;
import android.view.View;
import android.widget.AdapterView;
-import android.widget.Button;
-import android.widget.EditText;
-import android.widget.LinearLayout;
import android.widget.ListView;
-import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
+import com.soulter.esndroid.service.ConnService;
+import com.soulter.esndroid.bean.IDBean;
+import com.soulter.esndroid.R;
+import com.soulter.esndroid.adapter.IDListAdapter;
-import org.w3c.dom.Text;
-
-import java.lang.reflect.Field;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
-import conn.ESNSession;
-import conn.ISessionListener;
-import packs.PackRespNotification;
-import packs.PackResult;
-
/*
Author : Soulter
2021© Copyright reserved
diff --git a/app/src/main/java/com/soulter/esndroid/IDLoginActivity.java b/app/src/main/java/com/soulter/esndroid/activity/IDLoginActivity.java
similarity index 94%
rename from app/src/main/java/com/soulter/esndroid/IDLoginActivity.java
rename to app/src/main/java/com/soulter/esndroid/activity/IDLoginActivity.java
index 9506597..6237ebe 100644
--- a/app/src/main/java/com/soulter/esndroid/IDLoginActivity.java
+++ b/app/src/main/java/com/soulter/esndroid/activity/IDLoginActivity.java
@@ -1,24 +1,19 @@
-package com.soulter.esndroid;
+package com.soulter.esndroid.activity;
-import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
-import android.os.Looper;
import android.util.Log;
-import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
-import android.widget.LinearLayout;
import android.widget.ProgressBar;
-import android.widget.Toast;
import com.google.gson.Gson;
+import com.soulter.esndroid.bean.IDBean;
+import com.soulter.esndroid.R;
import java.util.ArrayList;
import java.util.List;
@@ -28,7 +23,7 @@
import packs.PackRespNotification;
import packs.PackResult;
-import static com.soulter.esndroid.ConnService.getStoredID;
+import static com.soulter.esndroid.service.ConnService.getStoredID;
/*
Author : Soulter
diff --git a/app/src/main/java/com/soulter/esndroid/MainActivity.java b/app/src/main/java/com/soulter/esndroid/activity/MainActivity.java
similarity index 59%
rename from app/src/main/java/com/soulter/esndroid/MainActivity.java
rename to app/src/main/java/com/soulter/esndroid/activity/MainActivity.java
index 596fb9f..5a47710 100644
--- a/app/src/main/java/com/soulter/esndroid/MainActivity.java
+++ b/app/src/main/java/com/soulter/esndroid/activity/MainActivity.java
@@ -1,4 +1,4 @@
-package com.soulter.esndroid;
+package com.soulter.esndroid.activity;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
@@ -6,28 +6,16 @@
import androidx.cardview.widget.CardView;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
-import android.app.NotificationChannel;
-import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.Context;
-import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
-import android.graphics.Color;
-import android.media.Image;
-import android.os.Build;
import android.os.Bundle;
-import android.os.Looper;
import android.os.StrictMode;
-import android.provider.Settings;
import android.util.Log;
import android.view.View;
-import android.view.WindowManager;
-import android.widget.Adapter;
-import android.widget.Button;
import android.widget.EditText;
-import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
@@ -37,27 +25,16 @@
import com.getbase.floatingactionbutton.FloatingActionButton;
import com.getbase.floatingactionbutton.FloatingActionsMenu;
-import com.google.gson.Gson;
-import com.google.gson.reflect.TypeToken;
+import com.soulter.esndroid.service.ConnService;
+import com.soulter.esndroid.bean.MsgBean;
+import com.soulter.esndroid.R;
+import com.soulter.esndroid.Utils;
+import com.soulter.esndroid.adapter.MsgListAdapter;
-import org.w3c.dom.Text;
-
-import java.lang.reflect.Type;
-import java.text.SimpleDateFormat;
import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.IllegalFormatCodePointException;
import java.util.List;
-import conn.ESNSession;
-import conn.ISessionListener;
-import packs.PackRespNotification;
-import packs.PackResult;
-
-import static com.soulter.esndroid.ConnService.getStoredID;
+import static com.soulter.esndroid.service.ConnService.getStoredID;
/*
Author : Soulter
@@ -172,12 +149,9 @@ public void onClick(View view) {
}
});
mainAcAddID.setVisibility(View.VISIBLE);
- mainAcAddID.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Intent intent = new Intent(MainActivity.this,IDLoginActivity.class);
- startActivityForResult(intent,REQUEST_CODE_MAIN_ADD_ID);
- }
+ mainAcAddID.setOnClickListener(view -> {
+ Intent intent = new Intent(MainActivity.this,IDLoginActivity.class);
+ startActivityForResult(intent,REQUEST_CODE_MAIN_ADD_ID);
});
}else{
mainCvM.setVisibility(View.VISIBLE);
@@ -206,137 +180,113 @@ public void onClick(View view) {
}
}
- addIDEntry.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Intent intent = new Intent(MainActivity.this,AddIDActivity.class);
- startActivityForResult(intent,REQUEST_CODE_ADD_ID);
- }
+ addIDEntry.setOnClickListener(view -> {
+ Intent intent = new Intent(MainActivity.this,AddIDActivity.class);
+ startActivityForResult(intent,REQUEST_CODE_ADD_ID);
});
- idLinkedStats.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
- if (userListDsp == null || userListDsp.toString().equals("")){
- builder.setTitle("状态")
- .setMessage("暂无信息")
- .show();
- }else{
- builder.setTitle("状态")
- .setMessage(userListDsp)
- .show();
- }
-
+ idLinkedStats.setOnClickListener(view -> {
+ AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
+ if (userListDsp == null || userListDsp.toString().equals("")){
+ builder.setTitle("状态")
+ .setMessage("暂无信息")
+ .show();
+ }else{
+ builder.setTitle("状态")
+ .setMessage(userListDsp)
+ .show();
}
- });
- newAAccountBtn.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (focusedUser != null){
- AlertDialog.Builder addIDDialog = new AlertDialog.Builder(MainActivity.this);
- final View newAccountView = (LinearLayout)getLayoutInflater().inflate(R.layout.new_a_account_dialog,null);
-
- addIDDialog
- .setView(newAccountView)
- .setNegativeButton("添加", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- EditText idUserInput = (EditText)newAccountView.findViewById(R.id.new_ac_dialog_user);
- EditText idPassInput = (EditText)newAccountView.findViewById(R.id.new_ac_dialog_pass);
- EditText idTypeInput = (EditText)newAccountView.findViewById(R.id.new_ac_dialog_type);
-
- String username = idUserInput.getText().toString();
- String passw = idPassInput.getText().toString();
- String type = idTypeInput.getText().toString();
-
- if(!username.equals("") && !passw.equals("") && !type.equals("")){
- if (focusedUser!=null){
- Intent intent = new Intent();
- intent.setAction(ACTION2);
- intent.putExtra(focus_user,focusedUser);
- intent.putExtra(feature_type_tag,onClickNewAcBtn);
- intent.putExtra(NewAcUser,username);
- intent.putExtra(NewAcPass,passw);
- intent.putExtra(NewAcType,type);
- LocalBroadcastManager.getInstance(MainActivity.this).sendBroadcast(intent);
- }else Toast.makeText(MainActivity.this,"当前未聚焦账户",Toast.LENGTH_LONG).show();
- }
- }
- }).show();
- }
+ });
+ newAAccountBtn.setOnClickListener(view -> {
+ if (focusedUser != null){
+ AlertDialog.Builder addIDDialog = new AlertDialog.Builder(MainActivity.this);
+ final View newAccountView = (LinearLayout)getLayoutInflater().inflate(R.layout.new_a_account_dialog,null);
+
+ addIDDialog
+ .setView(newAccountView)
+ .setNegativeButton("添加", (dialogInterface, i) -> {
+ EditText idUserInput = (EditText)newAccountView.findViewById(R.id.new_ac_dialog_user);
+ EditText idPassInput = (EditText)newAccountView.findViewById(R.id.new_ac_dialog_pass);
+ EditText idTypeInput = (EditText)newAccountView.findViewById(R.id.new_ac_dialog_type);
+
+ String username = idUserInput.getText().toString();
+ String passw = idPassInput.getText().toString();
+ String type = idTypeInput.getText().toString();
+
+ if(!username.equals("") && !passw.equals("") && !type.equals("")){
+ if (focusedUser!=null){
+ Intent intent = new Intent();
+ intent.setAction(ACTION2);
+ intent.putExtra(focus_user,focusedUser);
+ intent.putExtra(feature_type_tag,onClickNewAcBtn);
+ intent.putExtra(NewAcUser,username);
+ intent.putExtra(NewAcPass,passw);
+ intent.putExtra(NewAcType,type);
+ LocalBroadcastManager.getInstance(MainActivity.this).sendBroadcast(intent);
+ }else Toast.makeText(MainActivity.this,"当前未聚焦账户",Toast.LENGTH_LONG).show();
+ }
+ }).show();
}
- });
- removeAAccountBtn.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (focusedUser!=null){
- AlertDialog.Builder rmAccountDialog = new AlertDialog.Builder(MainActivity.this);
- final View rmAccountView = (LinearLayout)getLayoutInflater().inflate(R.layout.remove_a_account_dialog,null);
-
- rmAccountDialog
- .setView(rmAccountView)
- .setNegativeButton("推送", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- EditText username = (EditText)rmAccountView.findViewById(R.id.rm_account_username);
- String usernameStr = username.getText().toString();
-
-
- if(!usernameStr.equals("")) {
- if (focusedUser != null) {
- Intent intent = new Intent();
- intent.setAction(ACTION2);
- intent.putExtra(focus_user,focusedUser);
- intent.putExtra(feature_type_tag,onClickRemoveAcBtn);
- intent.putExtra(RemoveAcUser,usernameStr);
- LocalBroadcastManager.getInstance(MainActivity.this).sendBroadcast(intent);
- }
- }
+ });
+ removeAAccountBtn.setOnClickListener(view -> {
+ if (focusedUser!=null){
+ AlertDialog.Builder rmAccountDialog = new AlertDialog.Builder(MainActivity.this);
+ final View rmAccountView = (LinearLayout)getLayoutInflater().inflate(R.layout.remove_a_account_dialog,null);
+
+ rmAccountDialog
+ .setView(rmAccountView)
+ .setNegativeButton("推送", (dialogInterface, i) -> {
+ EditText username = (EditText)rmAccountView.findViewById(R.id.rm_account_username);
+ String usernameStr = username.getText().toString();
+
+
+ if(!usernameStr.equals("")) {
+ if (focusedUser != null) {
+ Intent intent = new Intent();
+ intent.setAction(ACTION2);
+ intent.putExtra(focus_user,focusedUser);
+ intent.putExtra(feature_type_tag,onClickRemoveAcBtn);
+ intent.putExtra(RemoveAcUser,usernameStr);
+ LocalBroadcastManager.getInstance(MainActivity.this).sendBroadcast(intent);
}
- }).show();
- }
+ }
+ }).show();
}
- });
- pushMsgBtn.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (focusedUser!=null){
- AlertDialog.Builder pushMsgDialog = new AlertDialog.Builder(MainActivity.this);
- final View pushMsgView = (LinearLayout)getLayoutInflater().inflate(R.layout.push_a_msg_dialog,null);
-
- pushMsgDialog
- .setView(pushMsgView)
- .setNegativeButton("推送", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- EditText titleInput = (EditText)pushMsgView.findViewById(R.id.push_msg_title);
- EditText contentInput = (EditText)pushMsgView.findViewById(R.id.push_msg_content);
- EditText targetInput = (EditText)pushMsgView.findViewById(R.id.push_msg_target);
-
- String title = titleInput.getText().toString();
- String content = contentInput.getText().toString();
- String target = targetInput.getText().toString();
-
- if(!title.equals("") && !content.equals("") && !target.equals("")) {
- if (focusedUser != null) {
- Intent intent = new Intent();
- intent.setAction(ACTION2);
- intent.putExtra(focus_user,focusedUser);
- intent.putExtra(feature_type_tag,onClickPushMsgBtn);
- intent.putExtra(PushTitle,title);
- intent.putExtra(PushContent,content);
- intent.putExtra(PushTarget,target);
- LocalBroadcastManager.getInstance(MainActivity.this).sendBroadcast(intent);
- }
- }
+ });
+ pushMsgBtn.setOnClickListener(view -> {
+ if (focusedUser!=null){
+ AlertDialog.Builder pushMsgDialog = new AlertDialog.Builder(MainActivity.this);
+ final View pushMsgView = (LinearLayout)getLayoutInflater().inflate(R.layout.push_a_msg_dialog,null);
+
+ pushMsgDialog
+ .setView(pushMsgView)
+ .setNegativeButton("推送", (dialogInterface, i) -> {
+ EditText titleInput = (EditText)pushMsgView.findViewById(R.id.push_msg_title);
+ EditText contentInput = (EditText)pushMsgView.findViewById(R.id.push_msg_content);
+ EditText targetInput = (EditText)pushMsgView.findViewById(R.id.push_msg_target);
+
+ String title = titleInput.getText().toString();
+ String content = contentInput.getText().toString();
+ String target = targetInput.getText().toString();
+
+ if(!title.equals("") && !content.equals("") && !target.equals("")) {
+ if (focusedUser != null) {
+ Intent intent = new Intent();
+ intent.setAction(ACTION2);
+ intent.putExtra(focus_user,focusedUser);
+ intent.putExtra(feature_type_tag,onClickPushMsgBtn);
+ intent.putExtra(PushTitle,title);
+ intent.putExtra(PushContent,content);
+ intent.putExtra(PushTarget,target);
+ LocalBroadcastManager.getInstance(MainActivity.this).sendBroadcast(intent);
}
- }).show();
- }
+ }
+
+ }).show();
}
});
@@ -417,12 +367,7 @@ public void onReceive(Context context, Intent intent) {
receivedMsg(msgBean);
}
if (intent.getIntExtra(ConnService.IDENTIFY_CODE,-1) == ConnService.LINKED_COUNT_CODE){
- idLinkedStats.post(new Runnable() {
- @Override
- public void run() {
- idLinkedStats.setText("已连接数:"+intent.getIntExtra(ConnService.BC_TAG_LINKED_COUNT,0)+" ");
- }
- });
+ idLinkedStats.post(() -> idLinkedStats.setText("已连接数:"+intent.getIntExtra(ConnService.BC_TAG_LINKED_COUNT,0)+" "));
}
if (intent.getIntExtra(ConnService.IDENTIFY_CODE,-1) == ConnService.LINKED_USER_CODE){
String username = intent.getStringExtra(ConnService.BC_TAG_LINKED_USER);
@@ -430,12 +375,7 @@ public void run() {
if (focusedUser != null) {
if (focusedUser.equals(username)) {
- idFocused.post(new Runnable() {
- @Override
- public void run() {
- idFocused.setText(" | 聚焦:" + focusedUser + " 类型" + types);
- }
- });
+ idFocused.post(() -> idFocused.setText(" | 聚焦:" + focusedUser + " 类型" + types));
openFeaturesFab.setVisibility(View.VISIBLE);
displayFeature(types);
}
@@ -451,8 +391,8 @@ public void receivedMsg(MsgBean msgBean){
for (int i=0;i msgListView.setAdapter(msgListAdapter));
}
public void displayFeature(String types){
if (types.contains("push")){
- pullMsgBtn.post(new Runnable() {
- @Override
- public void run() {
- pullMsgBtn.setVisibility(View.VISIBLE);
- }
- });
- pushMsgBtn.post(new Runnable() {
- @Override
- public void run() {
- pushMsgBtn.setVisibility(View.VISIBLE);
- }
- });
+ pullMsgBtn.post(() -> pullMsgBtn.setVisibility(View.VISIBLE));
+ pushMsgBtn.post(() -> pushMsgBtn.setVisibility(View.VISIBLE));
}
if (types.contains("pull")){
pullMsgBtn.post(new Runnable() {
@@ -542,10 +467,6 @@ protected void onResume() {
if (focusedUser!=null){
intent.putExtra(focus_user,focusedUser);
}else intent.putExtra(focus_user,"");
-
- if (!Utils.isServiceRunning(this,ConnService.CONN_SERVICE_NAME)){
-
- }
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/soulter/esndroid/ServerLoginActivity.java b/app/src/main/java/com/soulter/esndroid/activity/ServerLoginActivity.java
similarity index 98%
rename from app/src/main/java/com/soulter/esndroid/ServerLoginActivity.java
rename to app/src/main/java/com/soulter/esndroid/activity/ServerLoginActivity.java
index 3078b35..72fd686 100644
--- a/app/src/main/java/com/soulter/esndroid/ServerLoginActivity.java
+++ b/app/src/main/java/com/soulter/esndroid/activity/ServerLoginActivity.java
@@ -1,4 +1,4 @@
-package com.soulter.esndroid;
+package com.soulter.esndroid.activity;
import androidx.appcompat.app.AppCompatActivity;
@@ -11,6 +11,8 @@
import android.widget.EditText;
import android.widget.ProgressBar;
+import com.soulter.esndroid.R;
+
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.net.Socket;
diff --git a/app/src/main/java/com/soulter/esndroid/IDListAdapter.java b/app/src/main/java/com/soulter/esndroid/adapter/IDListAdapter.java
similarity index 89%
rename from app/src/main/java/com/soulter/esndroid/IDListAdapter.java
rename to app/src/main/java/com/soulter/esndroid/adapter/IDListAdapter.java
index 3f76887..fd12489 100644
--- a/app/src/main/java/com/soulter/esndroid/IDListAdapter.java
+++ b/app/src/main/java/com/soulter/esndroid/adapter/IDListAdapter.java
@@ -1,27 +1,22 @@
-package com.soulter.esndroid;
+package com.soulter.esndroid.adapter;
import android.content.Context;
import android.graphics.Typeface;
-import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
-import android.widget.ImageView;
-import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import com.soulter.esndroid.bean.IDBean;
+import com.soulter.esndroid.R;
+
import java.util.ArrayList;
import java.util.List;
-import conn.ESNSession;
-import conn.ISessionListener;
-import packs.PackRespNotification;
-import packs.PackResult;
-
/*
Author : Soulter
2021© Copyright reserved
diff --git a/app/src/main/java/com/soulter/esndroid/MsgListAdapter.java b/app/src/main/java/com/soulter/esndroid/adapter/MsgListAdapter.java
similarity index 96%
rename from app/src/main/java/com/soulter/esndroid/MsgListAdapter.java
rename to app/src/main/java/com/soulter/esndroid/adapter/MsgListAdapter.java
index 13db945..d4690bf 100644
--- a/app/src/main/java/com/soulter/esndroid/MsgListAdapter.java
+++ b/app/src/main/java/com/soulter/esndroid/adapter/MsgListAdapter.java
@@ -1,4 +1,4 @@
-package com.soulter.esndroid;
+package com.soulter.esndroid.adapter;
import android.content.Context;
import android.graphics.Typeface;
@@ -11,10 +11,9 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import org.w3c.dom.Text;
+import com.soulter.esndroid.bean.MsgBean;
+import com.soulter.esndroid.R;
-import java.util.Collection;
-import java.util.Collections;
import java.util.List;
/*
diff --git a/app/src/main/java/com/soulter/esndroid/ESNBean.java b/app/src/main/java/com/soulter/esndroid/bean/ESNBean.java
similarity index 94%
rename from app/src/main/java/com/soulter/esndroid/ESNBean.java
rename to app/src/main/java/com/soulter/esndroid/bean/ESNBean.java
index 82974bf..ad8e952 100644
--- a/app/src/main/java/com/soulter/esndroid/ESNBean.java
+++ b/app/src/main/java/com/soulter/esndroid/bean/ESNBean.java
@@ -1,4 +1,4 @@
-package com.soulter.esndroid;
+package com.soulter.esndroid.bean;
import java.io.Serializable;
import java.util.List;
diff --git a/app/src/main/java/com/soulter/esndroid/IDBean.java b/app/src/main/java/com/soulter/esndroid/bean/IDBean.java
similarity index 93%
rename from app/src/main/java/com/soulter/esndroid/IDBean.java
rename to app/src/main/java/com/soulter/esndroid/bean/IDBean.java
index 798f511..a1ee2a7 100644
--- a/app/src/main/java/com/soulter/esndroid/IDBean.java
+++ b/app/src/main/java/com/soulter/esndroid/bean/IDBean.java
@@ -1,4 +1,4 @@
-package com.soulter.esndroid;
+package com.soulter.esndroid.bean;
import java.util.List;
diff --git a/app/src/main/java/com/soulter/esndroid/MsgBean.java b/app/src/main/java/com/soulter/esndroid/bean/MsgBean.java
similarity index 96%
rename from app/src/main/java/com/soulter/esndroid/MsgBean.java
rename to app/src/main/java/com/soulter/esndroid/bean/MsgBean.java
index 03380cf..2e8cbcc 100644
--- a/app/src/main/java/com/soulter/esndroid/MsgBean.java
+++ b/app/src/main/java/com/soulter/esndroid/bean/MsgBean.java
@@ -1,4 +1,4 @@
-package com.soulter.esndroid;
+package com.soulter.esndroid.bean;
import java.io.Serializable;
diff --git a/app/src/main/java/com/soulter/esndroid/ConnService.java b/app/src/main/java/com/soulter/esndroid/service/ConnService.java
similarity index 95%
rename from app/src/main/java/com/soulter/esndroid/ConnService.java
rename to app/src/main/java/com/soulter/esndroid/service/ConnService.java
index 8cabfd6..17a5131 100644
--- a/app/src/main/java/com/soulter/esndroid/ConnService.java
+++ b/app/src/main/java/com/soulter/esndroid/service/ConnService.java
@@ -1,7 +1,5 @@
-package com.soulter.esndroid;
+package com.soulter.esndroid.service;
-import android.Manifest;
-import android.annotation.TargetApi;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
@@ -17,8 +15,6 @@
import android.os.IBinder;
import android.os.Looper;
import android.util.Log;
-import android.widget.ProgressBar;
-import android.widget.ThemedSpinnerAdapter;
import android.widget.Toast;
import androidx.annotation.Nullable;
@@ -27,9 +23,13 @@
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
+import com.soulter.esndroid.R;
+import com.soulter.esndroid.activity.MainActivity;
+import com.soulter.esndroid.bean.ESNBean;
+import com.soulter.esndroid.bean.IDBean;
+import com.soulter.esndroid.bean.MsgBean;
import java.lang.reflect.Type;
-import java.security.PublicKey;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -51,7 +51,7 @@ public class ConnService extends Service {
private int linkedCount = 0;
private int notifyId = 1;
private String focusedUser = "";
- public static final String CONN_SERVICE_NAME = "com.soulter.esndroid.ConnService";
+ public static final String CONN_SERVICE_NAME = "com.soulter.esndroid.service.ConnService";
public static final String BC_TAG_NEW_PULLED_MSG = "NEW_PULLED_MSG";
public static final String BC_TAG_LINKED_COUNT = "LINKED_COUNT";
public static final String BC_TAG_LINKED_USER = "LINKED_USER";
@@ -64,7 +64,7 @@ public class ConnService extends Service {
public static final int LINKED_USER_CODE = 3;
public static final int SEND_BASIC_INFO_CODE = 4;
private boolean isAppRunInBG = false;
- HashMap linkedAccountMap = new HashMap<>();
+ HashMap linkedAccountMap = new HashMap<>();
private LocalBroadcastManager mLocalBroadcastManager;
@@ -146,7 +146,7 @@ public void onReceive(Context context, Intent intent) {
String username = intent.getStringExtra(MainActivity.NewAcUser);
String passw = intent.getStringExtra(MainActivity.NewAcPass);
try {
- esnBean.esnSession.addAccount(username,passw,type);
+ esnBean.getEsnSession().addAccount(username,passw,type);
Gson gson = new Gson();
List idBeanList = getStoredID(spfs);
List types = new ArrayList<>();
@@ -176,7 +176,7 @@ public void onReceive(Context context, Intent intent) {
if (linkedAccountMap.get(intent.getStringExtra(MainActivity.focus_user)).getTypes().contains("account")){
ESNBean esnBean = linkedAccountMap.get(intent.getStringExtra(MainActivity.focus_user));
try {
- esnBean.esnSession.removeAccount(intent.getStringExtra(MainActivity.RemoveAcUser),true);
+ esnBean.getEsnSession().removeAccount(intent.getStringExtra(MainActivity.RemoveAcUser),true);
} catch (Exception e) {
Toast.makeText(ConnService.this,"删除失败",Toast.LENGTH_LONG).show();
e.printStackTrace();
@@ -191,7 +191,7 @@ public void onReceive(Context context, Intent intent) {
ESNBean esnBean = linkedAccountMap.get(intent.getStringExtra(MainActivity.focus_user));
try {
- esnBean.esnSession.pushNotification(intent.getStringExtra(MainActivity.PushTarget), intent.getStringExtra(MainActivity.PushTitle), intent.getStringExtra(MainActivity.PushContent));
+ esnBean.getEsnSession().pushNotification(intent.getStringExtra(MainActivity.PushTarget), intent.getStringExtra(MainActivity.PushTitle), intent.getStringExtra(MainActivity.PushContent));
} catch (Exception e) {
Toast.makeText(ConnService.this, "推送失败", Toast.LENGTH_LONG).show();
e.printStackTrace();
@@ -277,7 +277,7 @@ public void sessionLogout(PackResult packResult) {
receivedLinkedUserTypes(idBeans.get(position).userName,types.toString(),focusedUser);
ESNBean esnBean = new ESNBean(idBeans.get(position).userName,esnSession,types);
- linkedAccountMap.put(esnBean.username,esnBean);
+ linkedAccountMap.put(esnBean.getUsername(),esnBean);
esnSession.requestNotifications(0,500);
@@ -319,7 +319,7 @@ public static List getStoredID(SharedPreferences sp){
public void receivedMsg(String username,String title,String content,String time,String fromUser,int msgId){
MsgBean msgBean= new MsgBean(username,title,content,time,fromUser,msgId);
Bundle bundle = new Bundle();
- Log.v("lwl","接收到Msg:"+msgBean.content);
+ Log.v("lwl","接收到Msg:"+msgBean.getContent());
bundle.putSerializable(BC_TAG_NEW_PULLED_MSG,msgBean);
Intent intent = new Intent();
intent.setAction(ACTION);
diff --git a/app/src/main/res/layout/activity_add_i_d.xml b/app/src/main/res/layout/activity_add_i_d.xml
index 9f09613..8f6cb0a 100644
--- a/app/src/main/res/layout/activity_add_i_d.xml
+++ b/app/src/main/res/layout/activity_add_i_d.xml
@@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
- tools:context=".AddIDActivity"
+ tools:context=".activity.AddIDActivity"
android:orientation="vertical">
+tools:context=".activity.MainActivity">