Improved custom dns server manage
This commit is contained in:
parent
8ab3c0ad9a
commit
7dcb8b2643
@ -33,7 +33,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* Daedalus Project
|
* Daedalus Project
|
||||||
*
|
*
|
||||||
* @author iTXTech
|
* @author iTX Technologies
|
||||||
* @link https://itxtech.org
|
* @link https://itxtech.org
|
||||||
* <p>
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -16,7 +16,7 @@ import org.itxtech.daedalus.fragment.DnsServerConfigFragment;
|
|||||||
/**
|
/**
|
||||||
* Daedalus Project
|
* Daedalus Project
|
||||||
*
|
*
|
||||||
* @author iTXTech
|
* @author iTX Technologies
|
||||||
* @link https://itxtech.org
|
* @link https://itxtech.org
|
||||||
* <p>
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -29,7 +29,7 @@ import org.itxtech.daedalus.fragment.*;
|
|||||||
/**
|
/**
|
||||||
* Daedalus Project
|
* Daedalus Project
|
||||||
*
|
*
|
||||||
* @author iTXTech
|
* @author iTX Technologies
|
||||||
* @link https://itxtech.org
|
* @link https://itxtech.org
|
||||||
* <p>
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -20,7 +20,7 @@ import java.util.Locale;
|
|||||||
/**
|
/**
|
||||||
* Daedalus Project
|
* Daedalus Project
|
||||||
*
|
*
|
||||||
* @author iTXTech
|
* @author iTX Technologies
|
||||||
* @link https://itxtech.org
|
* @link https://itxtech.org
|
||||||
* <p>
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -20,7 +20,7 @@ import org.itxtech.daedalus.util.DnsServer;
|
|||||||
/**
|
/**
|
||||||
* Daedalus Project
|
* Daedalus Project
|
||||||
*
|
*
|
||||||
* @author iTXTech
|
* @author iTX Technologies
|
||||||
* @link https://itxtech.org
|
* @link https://itxtech.org
|
||||||
* <p>
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -4,6 +4,7 @@ import android.app.Fragment;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.design.widget.FloatingActionButton;
|
import android.support.design.widget.FloatingActionButton;
|
||||||
|
import android.support.design.widget.Snackbar;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.support.v7.widget.helper.ItemTouchHelper;
|
import android.support.v7.widget.helper.ItemTouchHelper;
|
||||||
@ -19,7 +20,7 @@ import org.itxtech.daedalus.util.CustomDnsServer;
|
|||||||
/**
|
/**
|
||||||
* Daedalus Project
|
* Daedalus Project
|
||||||
*
|
*
|
||||||
* @author iTXTech
|
* @author iTX Technologies
|
||||||
* @link https://itxtech.org
|
* @link https://itxtech.org
|
||||||
* <p>
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
@ -29,10 +30,11 @@ import org.itxtech.daedalus.util.CustomDnsServer;
|
|||||||
*/
|
*/
|
||||||
public class DnsServersFragment extends Fragment {
|
public class DnsServersFragment extends Fragment {
|
||||||
private DnsServersFragment.DnsServerAdapter adapter;
|
private DnsServersFragment.DnsServerAdapter adapter;
|
||||||
|
private CustomDnsServer server = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.fragment_dns_servers, container, false);
|
final View view = inflater.inflate(R.layout.fragment_dns_servers, container, false);
|
||||||
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView_dns_servers);
|
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView_dns_servers);
|
||||||
LinearLayoutManager manager = new LinearLayoutManager(getActivity());
|
LinearLayoutManager manager = new LinearLayoutManager(getActivity());
|
||||||
recyclerView.setLayoutManager(manager);
|
recyclerView.setLayoutManager(manager);
|
||||||
@ -52,8 +54,11 @@ public class DnsServersFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
|
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
|
||||||
int position = viewHolder.getAdapterPosition();
|
int position = viewHolder.getAdapterPosition();
|
||||||
adapter.notifyItemRemoved(position);
|
server = Daedalus.configurations.getCustomDnsServers().get(position);
|
||||||
Daedalus.configurations.getCustomDnsServers().remove(position);
|
Daedalus.configurations.getCustomDnsServers().remove(position);
|
||||||
|
Snackbar.make(view, R.string.action_removed, Snackbar.LENGTH_LONG)
|
||||||
|
.setAction(R.string.action_undo, new SnackbarClickListener(position)).show();
|
||||||
|
adapter.notifyItemRemoved(position);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
itemTouchHelper.attachToRecyclerView(recyclerView);
|
itemTouchHelper.attachToRecyclerView(recyclerView);
|
||||||
@ -69,12 +74,27 @@ public class DnsServersFragment extends Fragment {
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class SnackbarClickListener implements View.OnClickListener {
|
||||||
|
private final int position;
|
||||||
|
|
||||||
|
private SnackbarClickListener(int position) {
|
||||||
|
this.position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Daedalus.configurations.getCustomDnsServers().add(position, server);
|
||||||
|
adapter.notifyItemInserted(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
|
|
||||||
Daedalus.configurations.save();
|
Daedalus.configurations.save();
|
||||||
adapter = null;
|
adapter = null;
|
||||||
|
server = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -100,7 +120,7 @@ public class DnsServersFragment extends Fragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_dns_servers, parent, false);
|
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_server, parent, false);
|
||||||
return new ViewHolder(view);
|
return new ViewHolder(view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ import java.util.Set;
|
|||||||
/**
|
/**
|
||||||
* Daedalus Project
|
* Daedalus Project
|
||||||
*
|
*
|
||||||
* @author iTXTech
|
* @author iTX Technologies
|
||||||
* @link https://itxtech.org
|
* @link https://itxtech.org
|
||||||
* <p>
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -25,7 +25,7 @@ import java.util.Date;
|
|||||||
/**
|
/**
|
||||||
* Daedalus Project
|
* Daedalus Project
|
||||||
*
|
*
|
||||||
* @author iTXTech
|
* @author iTX Technologies
|
||||||
* @link https://itxtech.org
|
* @link https://itxtech.org
|
||||||
* <p>
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -21,7 +21,7 @@ import org.itxtech.daedalus.util.DnsServerHelper;
|
|||||||
/**
|
/**
|
||||||
* Daedalus Project
|
* Daedalus Project
|
||||||
*
|
*
|
||||||
* @author iTXTech
|
* @author iTX Technologies
|
||||||
* @link https://itxtech.org
|
* @link https://itxtech.org
|
||||||
* <p>
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -16,7 +16,7 @@ import org.itxtech.daedalus.util.DnsServerHelper;
|
|||||||
/**
|
/**
|
||||||
* Daedalus Project
|
* Daedalus Project
|
||||||
*
|
*
|
||||||
* @author iTXTech
|
* @author iTX Technologies
|
||||||
* @link https://itxtech.org
|
* @link https://itxtech.org
|
||||||
* <p>
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -6,7 +6,7 @@ import org.itxtech.daedalus.service.DaedalusVpnService;
|
|||||||
/**
|
/**
|
||||||
* Daedalus Project
|
* Daedalus Project
|
||||||
*
|
*
|
||||||
* @author iTXTech
|
* @author iTX Technologies
|
||||||
* @link https://itxtech.org
|
* @link https://itxtech.org
|
||||||
* <p>
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -24,7 +24,7 @@ import java.util.LinkedList;
|
|||||||
/**
|
/**
|
||||||
* Daedalus Project
|
* Daedalus Project
|
||||||
*
|
*
|
||||||
* @author iTXTech
|
* @author iTX Technologies
|
||||||
* @link https://itxtech.org
|
* @link https://itxtech.org
|
||||||
* <p>
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -32,7 +32,7 @@ import java.util.Queue;
|
|||||||
/**
|
/**
|
||||||
* Daedalus Project
|
* Daedalus Project
|
||||||
*
|
*
|
||||||
* @author iTXTech
|
* @author iTX Technologies
|
||||||
* @link https://itxtech.org
|
* @link https://itxtech.org
|
||||||
* <p>
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -12,7 +12,7 @@ import org.itxtech.daedalus.util.DnsServerHelper;
|
|||||||
/**
|
/**
|
||||||
* Daedalus Project
|
* Daedalus Project
|
||||||
*
|
*
|
||||||
* @author iTXTech
|
* @author iTX Technologies
|
||||||
* @link https://itxtech.org
|
* @link https://itxtech.org
|
||||||
* <p>
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -12,7 +12,7 @@ import java.lang.reflect.Method;
|
|||||||
/**
|
/**
|
||||||
* Daedalus Project
|
* Daedalus Project
|
||||||
*
|
*
|
||||||
* @author iTXTech
|
* @author iTX Technologies
|
||||||
* @link https://itxtech.org
|
* @link https://itxtech.org
|
||||||
* <p>
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -27,7 +27,7 @@ import java.net.Inet4Address;
|
|||||||
/**
|
/**
|
||||||
* Daedalus Project
|
* Daedalus Project
|
||||||
*
|
*
|
||||||
* @author iTXTech
|
* @author iTX Technologies
|
||||||
* @link https://itxtech.org
|
* @link https://itxtech.org
|
||||||
* <p>
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -13,7 +13,7 @@ import java.util.ArrayList;
|
|||||||
/**
|
/**
|
||||||
* Daedalus Project
|
* Daedalus Project
|
||||||
*
|
*
|
||||||
* @author iTXTech
|
* @author iTX Technologies
|
||||||
* @link https://itxtech.org
|
* @link https://itxtech.org
|
||||||
* <p>
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -5,7 +5,7 @@ import org.itxtech.daedalus.Daedalus;
|
|||||||
/**
|
/**
|
||||||
* Daedalus Project
|
* Daedalus Project
|
||||||
*
|
*
|
||||||
* @author iTXTech
|
* @author iTX Technologies
|
||||||
* @link https://itxtech.org
|
* @link https://itxtech.org
|
||||||
* <p>
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -5,7 +5,7 @@ import android.content.Context;
|
|||||||
/**
|
/**
|
||||||
* Daedalus Project
|
* Daedalus Project
|
||||||
*
|
*
|
||||||
* @author iTXTech
|
* @author iTX Technologies
|
||||||
* @link https://itxtech.org
|
* @link https://itxtech.org
|
||||||
* <p>
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -10,7 +10,7 @@ import java.util.HashMap;
|
|||||||
/**
|
/**
|
||||||
* Daedalus Project
|
* Daedalus Project
|
||||||
*
|
*
|
||||||
* @author iTXTech
|
* @author iTX Technologies
|
||||||
* @link https://itxtech.org
|
* @link https://itxtech.org
|
||||||
* <p>
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -7,7 +7,7 @@ import java.util.ArrayList;
|
|||||||
/**
|
/**
|
||||||
* Daedalus Project
|
* Daedalus Project
|
||||||
*
|
*
|
||||||
* @author iTXTech
|
* @author iTX Technologies
|
||||||
* @link https://itxtech.org
|
* @link https://itxtech.org
|
||||||
* <p>
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -11,7 +11,7 @@ import java.util.HashMap;
|
|||||||
/**
|
/**
|
||||||
* Daedalus Project
|
* Daedalus Project
|
||||||
*
|
*
|
||||||
* @author iTXTech
|
* @author iTX Technologies
|
||||||
* @link https://itxtech.org
|
* @link https://itxtech.org
|
||||||
* <p>
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -15,7 +15,7 @@ import org.itxtech.daedalus.R;
|
|||||||
/**
|
/**
|
||||||
* Daedalus Project
|
* Daedalus Project
|
||||||
*
|
*
|
||||||
* @author iTXTech & MrFuFuFu
|
* @author iTX Technologies & MrFuFuFu
|
||||||
* @link https://itxtech.org
|
* @link https://itxtech.org
|
||||||
* <p>
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -9,7 +9,7 @@ import android.util.AttributeSet;
|
|||||||
/**
|
/**
|
||||||
* Daedalus Project
|
* Daedalus Project
|
||||||
*
|
*
|
||||||
* @author iTXTech
|
* @author iTX Technologies
|
||||||
* @link https://itxtech.org
|
* @link https://itxtech.org
|
||||||
* <p>
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
</android.support.design.widget.AppBarLayout>
|
</android.support.design.widget.AppBarLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<android.support.design.widget.CoordinatorLayout
|
||||||
android:id="@+id/id_content"
|
android:id="@+id/id_content"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
android:clickable="true"
|
||||||
|
android:foreground="?attr/selectableItemBackground"
|
||||||
app:cardCornerRadius="10dp"
|
app:cardCornerRadius="10dp"
|
||||||
app:cardPreventCornerOverlap="true"
|
app:cardPreventCornerOverlap="true"
|
||||||
app:cardUseCompatPadding="true">
|
app:cardUseCompatPadding="true">
|
@ -64,4 +64,6 @@
|
|||||||
<string name="apply">应用</string>
|
<string name="apply">应用</string>
|
||||||
<string name="notice_fill_in_all">请填写所有配置项。</string>
|
<string name="notice_fill_in_all">请填写所有配置项。</string>
|
||||||
<string name="settings_dns_over_tcp">DNS over TCP</string>
|
<string name="settings_dns_over_tcp">DNS over TCP</string>
|
||||||
|
<string name="action_removed">已移除。</string>
|
||||||
|
<string name="action_undo">撤销</string>
|
||||||
</resources>
|
</resources>
|
@ -64,4 +64,6 @@
|
|||||||
<string name="apply">Apply</string>
|
<string name="apply">Apply</string>
|
||||||
<string name="notice_fill_in_all">Please fill in all configuration items.</string>
|
<string name="notice_fill_in_all">Please fill in all configuration items.</string>
|
||||||
<string name="settings_dns_over_tcp">DNS over TCP</string>
|
<string name="settings_dns_over_tcp">DNS over TCP</string>
|
||||||
|
<string name="action_removed">Removed.</string>
|
||||||
|
<string name="action_undo">Undo</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user