Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
  • Loading branch information
vnt-dev committed Aug 30, 2023
2 parents b70fdfc + fa124c8 commit 61c4275
Show file tree
Hide file tree
Showing 23 changed files with 92 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ public class ExampleInstrumentedTest {
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("top.wherewego.switchapp", appContext.getPackageName());
assertEquals("top.wherewego.vnt", appContext.getPackageName());
}
}
10 changes: 5 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -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"
package="top.wherewego.switchapp">
package="top.wherewego.vnt">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
Expand All @@ -13,7 +13,7 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.SwitchApp"
android:theme="@style/Theme.VntApp"
tools:targetApi="31">
<service
android:name=".MyVpnService"
Expand All @@ -30,15 +30,15 @@
<activity
android:name=".ConnectActivity"
android:exported="false"
android:theme="@style/Theme.SwitchApp.NoActionBar">
android:theme="@style/Theme.VntApp.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
<activity
android:name=".AddActivity"
android:exported="false"
android:theme="@style/Theme.SwitchApp.NoActionBar">
android:theme="@style/Theme.VntApp.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
Expand All @@ -47,7 +47,7 @@
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.SwitchApp.NoActionBar">
android:theme="@style/Theme.VntApp.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package top.wherewego.switchapp;
package top.wherewego.vnt;

import android.widget.EditText;
import android.widget.Spinner;
Expand All @@ -10,9 +10,9 @@

import java.util.UUID;

import top.wherewego.switchapp.app.AppActivity;
import top.wherewego.switchapp.app.AppApplication;
import top.wherewego.switchapp.util.SPUtils;
import top.wherewego.vnt.app.AppActivity;
import top.wherewego.vnt.app.AppApplication;
import top.wherewego.vnt.util.SPUtils;
import top.wherewego.vnt.jni.ConfigurationInfoBean;

public class AddActivity extends AppActivity {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package top.wherewego.switchapp;
package top.wherewego.vnt;

import android.annotation.SuppressLint;
import android.content.Intent;
Expand All @@ -19,8 +19,8 @@
import java.util.List;

import top.wherewego.base.BaseAdapter;
import top.wherewego.switchapp.adapter.ConnectAdapter;
import top.wherewego.switchapp.app.AppActivity;
import top.wherewego.vnt.adapter.ConnectAdapter;
import top.wherewego.vnt.app.AppActivity;
import top.wherewego.vnt.jni.ConfigurationInfoBean;
import top.wherewego.vnt.jni.DeviceBean;
import top.wherewego.widget.layout.WrapRecyclerView;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package top.wherewego.switchapp;
package top.wherewego.vnt;

import android.content.Intent;
import android.view.View;

import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.recyclerview.widget.RecyclerView;

import com.hjq.bar.OnTitleBarListener;
Expand All @@ -15,9 +16,10 @@
import com.scwang.smart.refresh.layout.listener.OnRefreshLoadMoreListener;

import top.wherewego.base.BaseAdapter;
import top.wherewego.switchapp.adapter.StatusAdapter;
import top.wherewego.switchapp.app.AppActivity;
import top.wherewego.switchapp.app.AppApplication;
import top.wherewego.vnt.adapter.StatusAdapter;
import top.wherewego.vnt.app.AppActivity;
import top.wherewego.vnt.app.AppApplication;
import top.wherewego.vnt.util.SPUtils;
import top.wherewego.vnt.jni.ConfigurationInfoBean;
import top.wherewego.widget.layout.WrapRecyclerView;

Expand Down Expand Up @@ -55,6 +57,19 @@ public void onRightClick(TitleBar titleBar) {

mAdapter = new StatusAdapter(this);
mAdapter.setOnItemClickListener(this);
mAdapter.setOnChildClickListener(R.id.iv_delete, (recyclerView, childView, position) -> {
AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.this)
.setTitle("")
.setMessage("是否选择删除该项?")
.setPositiveButton("确认", (dialog, id) -> {
String key = mAdapter.getItem(position).getKey();
deleteItem(key);
mAdapter.removeItem(position);
})
.setNegativeButton("取消", (dialog, id) -> dialog.cancel());
alert.show();

});
mRecyclerView.setAdapter(mAdapter);

mRefreshLayout.setOnRefreshLoadMoreListener(this);
Expand All @@ -67,6 +82,23 @@ public void onRightClick(TitleBar titleBar) {
});
}

public void deleteItem(String key){
String keyset = SPUtils.getString(getApplicationContext(), "keyset", "0");
StringBuilder newKeySet = new StringBuilder();
if (keyset.equals("0")) {
return;
} else {
String[] keys = keyset.split(",");
for (String s : keys) {
if (!s.equals(key)) {
newKeySet.append(s).append(",");
}
}
SPUtils.putString(getApplicationContext(), "keyset", newKeySet.toString());
}
SPUtils.deleteShare(getApplicationContext(),key);
}

@Override
protected void initData() {
//analogData();
Expand All @@ -80,6 +112,8 @@ protected void onResume() {
mRefreshLayout.finishRefresh();
}



@Override
public void onItemClick(RecyclerView recyclerView, View itemView, int position) {
selectConfigurationInfoBean = mAdapter.getItem(position);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package top.wherewego.switchapp;
package top.wherewego.vnt;

import android.content.Intent;
import android.content.IntentFilter;
Expand Down Expand Up @@ -77,7 +77,7 @@ public synchronized int onStartCommand(Intent intent, int flags, int startId) {
boolean isTcp = intent.getBooleanExtra("isTcp", false);
config = new Config(token, name, deviceId, server, stunServer, password.isEmpty() ? null : password, cipherModel, isTcp);
if (mThread == null) {
mThread = new Thread(this, "SwitchVPN");
mThread = new Thread(this, "VntVPN");
mThread.start();
}
break;
Expand Down Expand Up @@ -106,7 +106,7 @@ public void run() {
}
Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> {
Toast.makeText(getApplicationContext(), "Switch已停止", Toast.LENGTH_LONG).show();
Toast.makeText(getApplicationContext(), "Vnt已停止", Toast.LENGTH_LONG).show();
});
stop0();
eVnt = null;
Expand Down Expand Up @@ -182,7 +182,7 @@ private void run0() {
Builder builder = new Builder();
int prefixLength = IpUtils.subnetMaskToPrefixLength(connect.getVirtualNetmask());
String ipRoute = IpUtils.intToIpAddress(connect.getVirtualGateway() & connect.getVirtualNetmask());
builder.setSession("SwitchVPN")
builder.setSession("VntVPN")
.setBlocking(true)
.setMtu(1420)
.addAddress(ip, prefixLength)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
package top.wherewego.switchapp.action;

import androidx.annotation.StringRes;
package top.wherewego.vnt.action;


/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package top.wherewego.switchapp.adapter;
package top.wherewego.vnt.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;

import top.wherewego.switchapp.R;
import top.wherewego.switchapp.app.AppAdapter;
import top.wherewego.vnt.R;
import top.wherewego.vnt.app.AppAdapter;
import top.wherewego.vnt.jni.DeviceBean;

public final class ConnectAdapter extends AppAdapter<DeviceBean> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package top.wherewego.switchapp.adapter;
package top.wherewego.vnt.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;

import top.wherewego.switchapp.R;
import top.wherewego.switchapp.app.AppAdapter;
import top.wherewego.vnt.R;
import top.wherewego.vnt.app.AppAdapter;
import top.wherewego.vnt.jni.ConfigurationInfoBean;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
package top.wherewego.switchapp.app;
package top.wherewego.vnt.app;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;

import com.gyf.immersionbar.ImmersionBar;
import com.hjq.bar.TitleBar;
import top.wherewego.base.BaseActivity;
import top.wherewego.base.BaseDialog;
import top.wherewego.switchapp.R;
import top.wherewego.vnt.R;


/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package top.wherewego.switchapp.app;
package top.wherewego.vnt.app;

import android.content.Context;
import android.view.View;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package top.wherewego.switchapp.app;
package top.wherewego.vnt.app;

import android.app.Application;
import android.content.Context;
Expand All @@ -13,8 +13,8 @@

import java.util.ArrayList;

import top.wherewego.switchapp.R;
import top.wherewego.switchapp.util.SPUtils;
import top.wherewego.vnt.R;
import top.wherewego.vnt.util.SPUtils;
import top.wherewego.vnt.jni.ConfigurationInfoBean;

/**
Expand Down Expand Up @@ -45,7 +45,7 @@ protected void attachBaseContext(Context base) {
Log.d("swichapp", "attachBaseContext: s : " + s);
String json = SPUtils.getString(this, s, "0");
if (json.equals("0")) {
return;
continue;
}
ConfigurationInfoBean configurationInfoBean = new Gson().fromJson(json, ConfigurationInfoBean.class);
configList.add(configurationInfoBean);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package top.wherewego.switchapp.app;
package top.wherewego.vnt.app;


import top.wherewego.base.BaseFragment;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package top.wherewego.switchapp.util;
package top.wherewego.vnt.util;

import android.content.Context;
import android.content.SharedPreferences;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package top.wherewego.switchapp.widget;
package top.wherewego.vnt.widget;

import android.content.Context;
import android.util.AttributeSet;
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/layout/app_bar_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
tools:context="top.wherewego.vnt.MainActivity">

<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/Theme.SwitchApp.AppBarOverlay">
android:theme="@style/Theme.VntApp.AppBarOverlay">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/Theme.SwitchApp.PopupOverlay" />
app:popupTheme="@style/Theme.VntApp.PopupOverlay" />

</com.google.android.material.appbar.AppBarLayout>

Expand Down
10 changes: 9 additions & 1 deletion app/src/main/res/layout/status_config_info_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<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"

android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
Expand All @@ -17,6 +17,14 @@
android:orientation="vertical"
android:layout_margin="@dimen/dp_10">

<ImageView
android:id="@+id/iv_delete"
android:layout_width="@dimen/dp_20"
android:layout_height="@dimen/dp_20"
android:src="@mipmap/delete"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/tv_info_token"
android:layout_width="wrap_content"
Expand Down
Binary file added app/src/main/res/mipmap-hdpi/delete.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-hdpi/delete2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/src/main/res/values-night/themes.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.SwitchApp" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<style name="Theme.VntApp" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_200</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<resources>
<string name="app_name">SwitchApp</string>
<string name="app_name">VntApp</string>
<string name="navigation_drawer_open">Open navigation drawer</string>
<string name="navigation_drawer_close">Close navigation drawer</string>
<string name="nav_header_title">Switch App</string>
<string name="nav_header_title">Vnt App</string>
<string name="nav_header_subtitle"></string>
<string name="nav_header_desc">Navigation header</string>
<string name="action_settings">Settings</string>
Expand Down
Loading

0 comments on commit 61c4275

Please sign in to comment.