mirror of
https://gitee.com/willfree/min-vpn-client_v2.git
synced 2026-10-04 19:42:00 +08:00
测试设备管理的界面
This commit is contained in:
1 parent
2871d357e9
commit
03e507d1e2
14 files changed
+269
No files matched your search
@@ -75,6 +75,10 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// 制作listview
|
||||
// https://mvnrepository.com/artifact/com.android.support/appcompat-v7
|
||||
implementation 'com.android.support:appcompat-v7:28.0.0'
|
||||
|
||||
implementation files('libs/gmhelper.jar')
|
||||
implementation files('libs/BaiduLBS_Android.jar')
|
||||
implementation files('libs/min-dev-java-1.0-release.jar')
|
||||
|
||||
@@ -40,6 +40,9 @@
|
||||
<activity
|
||||
android:name=".activity.reset.ResetActivity"
|
||||
android:launchMode="singleTask" />
|
||||
<activity
|
||||
android:name=".utils.listview.ListActivity"
|
||||
android:launchMode="singleTask" />
|
||||
<service
|
||||
android:name=".services.MINVpnService"
|
||||
android:permission="android.permission.BIND_VPN_SERVICE">
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.pkusz.min_vpn_client.utils.DigestUtilKt;
|
||||
import com.pkusz.min_vpn_client.utils.KeyManager;
|
||||
import com.pkusz.min_vpn_client.utils.SafetyInfoUtil;
|
||||
import com.pkusz.min_vpn_client.utils.UuidUtil;
|
||||
import com.pkusz.min_vpn_client.utils.listview.ListActivity;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -84,6 +85,19 @@ public class LoginActivity extends MINVpnBaseActivity<LoginActivityPresenter>
|
||||
initView();
|
||||
// 测试唯一标识
|
||||
// System.out.println(UuidUtil.getAndroidDeviceUuid(this));
|
||||
// 显示设备信息
|
||||
try {
|
||||
Thread.sleep(3000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
showMachines();
|
||||
}
|
||||
|
||||
// 测试使用弹窗显示已在VMS进行绑定的设备
|
||||
private void showMachines(){
|
||||
System.out.println("跳转到设备信息界面");
|
||||
ContextExtensionKt.jumpTo(LoginActivity.this, ListActivity.class);
|
||||
}
|
||||
|
||||
private void initView(){
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.pkusz.min_vpn_client.utils.listview;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.pkusz.min_vpn_client.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
// 参考博文: https://www.jianshu.com/p/9806917d3d99
|
||||
// 参考代码: https://download.csdn.net/download/qq_34908107/9963852
|
||||
public class ListActivity extends AppCompatActivity {
|
||||
private RecyclerView mRecyclerView;
|
||||
private ImageView iv_add;
|
||||
private RecycleAdapter adapter;
|
||||
private List<String> list = new ArrayList<String>();
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_list);
|
||||
initView();
|
||||
initRecycle();
|
||||
iv_add.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// 添加自带默认动画
|
||||
adapter.addData(list.size());
|
||||
}
|
||||
});
|
||||
}
|
||||
private void initRecycle() {
|
||||
// 纵向滑动
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
|
||||
mRecyclerView.setLayoutManager(linearLayoutManager);
|
||||
// 获取数据,向适配器传数据,绑定适配器
|
||||
list = initData();
|
||||
adapter = new RecycleAdapter(ListActivity.this, list);
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
// 添加动画
|
||||
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
|
||||
}
|
||||
private void initView() {
|
||||
iv_add = (ImageView) findViewById(R.id.iv_add);
|
||||
mRecyclerView = (RecyclerView) findViewById(R.id.recyclerview);
|
||||
}
|
||||
|
||||
protected ArrayList<String> initData() {
|
||||
ArrayList<String> mDatas = new ArrayList<String>();
|
||||
for (int i = 0; i < 1; i++) {
|
||||
mDatas.add("我是商品" + i);
|
||||
}
|
||||
return mDatas;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.pkusz.min_vpn_client.utils.listview;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.pkusz.min_vpn_client.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by qzs on 2016/7/11.
|
||||
*/
|
||||
class RecycleAdapter extends RecyclerView.Adapter<RecycleAdapter.MyViewHolder> {
|
||||
private Context context;
|
||||
private List<String> list;
|
||||
|
||||
public RecycleAdapter(Context context, List<String> list) {
|
||||
this.context = context;
|
||||
this.list = list;
|
||||
}
|
||||
@Override
|
||||
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
MyViewHolder holder = new MyViewHolder(LayoutInflater.from(
|
||||
context).inflate(R.layout.item_home, parent,
|
||||
false));
|
||||
return holder;
|
||||
}
|
||||
@Override
|
||||
public void onBindViewHolder(MyViewHolder holder, final int position) {
|
||||
holder.tv.setText(list.get(position));
|
||||
holder.tv_delete.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (list.size() == 1) {
|
||||
Snackbar.make(v, "此条目不能删除", Snackbar.LENGTH_SHORT).show();
|
||||
} else {
|
||||
// 删除自带默认动画
|
||||
removeData(position);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list.size();
|
||||
}
|
||||
// 添加数据
|
||||
public void addData(int position) {
|
||||
// 在list中添加数据,并通知条目加入一条
|
||||
list.add(position, "我是商品" + position);
|
||||
//添加动画
|
||||
notifyItemInserted(position);
|
||||
}
|
||||
// 删除数据
|
||||
public void removeData(int position) {
|
||||
list.remove(position);
|
||||
//删除动画
|
||||
notifyItemRemoved(position);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
/**
|
||||
* ViewHolder的类,用于缓存控件
|
||||
*/
|
||||
class MyViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView tv, tv_delete;
|
||||
//因为删除有可能会删除中间条目,然后会造成角标越界,所以必须整体刷新一下!
|
||||
public MyViewHolder(View view) {
|
||||
super(view);
|
||||
tv = (TextView) view.findViewById(R.id.id_num);
|
||||
tv_delete = (TextView) view.findViewById(R.id.tv_delete);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<corners android:radius="8px"/>
|
||||
<solid android:color="#BD1B21"></solid>
|
||||
</shape>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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"
|
||||
android:background="#efefef"
|
||||
android:orientation="vertical"
|
||||
tools:context=".utils.listview.ListActivity">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="72dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:background="@drawable/str_huise">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_add"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginLeft="30dp"
|
||||
android:src="@mipmap/add" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="30dp"
|
||||
android:gravity="center_vertical"
|
||||
android:text="新增商品"
|
||||
android:textColor="#ffffff"
|
||||
android:textSize="56px" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"></androidx.recyclerview.widget.RecyclerView>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.cardview.widget.CardView 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"
|
||||
style="@style/news_summary_card_view"
|
||||
android:layout_margin="10dp"
|
||||
app:cardBackgroundColor="#ffffff"
|
||||
app:cardElevation="2dp">
|
||||
<!--app:cardCornerRadius="2dp"-->
|
||||
<!--app:contentPadding="0dp"-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="80dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/id_num"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:gravity="center"
|
||||
android:lines="2"
|
||||
android:textColor="#444444"
|
||||
android:textSize="20sp"
|
||||
tools:text="11111111111111" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"></View>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_delete"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="20dp"
|
||||
android:gravity="center"
|
||||
android:text="删除"
|
||||
android:textColor="#BD1B21"
|
||||
android:textSize="20sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 283 B |
Binary file not shown.
|
After Width: | Height: | Size: 283 B |
Binary file not shown.
|
After Width: | Height: | Size: 283 B |
Binary file not shown.
|
After Width: | Height: | Size: 283 B |
Binary file not shown.
|
After Width: | Height: | Size: 283 B |
@@ -52,4 +52,13 @@
|
||||
<item name="android:layout_height">match_parent</item>
|
||||
</style>
|
||||
|
||||
<style name="news_summary_card_view">
|
||||
<item name="android:layout_width">match_parent</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:layout_marginLeft">4dp</item>
|
||||
<item name="android:layout_marginRight">4dp</item>
|
||||
<item name="android:layout_marginTop">5dp</item>
|
||||
<item name="android:foreground">?android:attr/selectableItemBackground</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
Reference in new issue
Block a user