Now you can't modify the custom server when it is in using
This commit is contained in:
parent
62791ed5f9
commit
be7ab36d13
@ -10,6 +10,7 @@ import android.support.v4.graphics.drawable.DrawableCompat;
|
|||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import org.itxtech.daedalus.Daedalus;
|
||||||
import org.itxtech.daedalus.R;
|
import org.itxtech.daedalus.R;
|
||||||
import org.itxtech.daedalus.fragment.DnsServerConfigFragment;
|
import org.itxtech.daedalus.fragment.DnsServerConfigFragment;
|
||||||
|
|
||||||
@ -55,4 +56,11 @@ public class DnsServerConfigActivity extends AppCompatActivity {
|
|||||||
fragmentTransaction.replace(R.id.id_config, fragment);
|
fragmentTransaction.replace(R.id.id_config, fragment);
|
||||||
fragmentTransaction.commit();
|
fragmentTransaction.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
|
||||||
|
Daedalus.configurations.save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ import org.itxtech.daedalus.Daedalus;
|
|||||||
import org.itxtech.daedalus.R;
|
import org.itxtech.daedalus.R;
|
||||||
import org.itxtech.daedalus.activity.DnsServerConfigActivity;
|
import org.itxtech.daedalus.activity.DnsServerConfigActivity;
|
||||||
import org.itxtech.daedalus.util.CustomDnsServer;
|
import org.itxtech.daedalus.util.CustomDnsServer;
|
||||||
|
import org.itxtech.daedalus.util.DnsServerHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Daedalus Project
|
* Daedalus Project
|
||||||
@ -43,6 +44,11 @@ public class DnsServersFragment extends Fragment {
|
|||||||
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new ItemTouchHelper.Callback() {
|
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new ItemTouchHelper.Callback() {
|
||||||
@Override
|
@Override
|
||||||
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
|
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
|
||||||
|
if (viewHolder instanceof ViewHolder) {
|
||||||
|
if (DnsServerHelper.isInUsing(Daedalus.configurations.getCustomDnsServers().get(((ViewHolder) viewHolder).getIndex()))) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
return makeMovementFlags(0, ItemTouchHelper.START | ItemTouchHelper.END);
|
return makeMovementFlags(0, ItemTouchHelper.START | ItemTouchHelper.END);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,10 +147,16 @@ public class DnsServersFragment extends Fragment {
|
|||||||
this.index = index;
|
this.index = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getIndex() {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Daedalus.getInstance().startActivity(new Intent(Daedalus.getInstance(), DnsServerConfigActivity.class)
|
if (!DnsServerHelper.isInUsing(Daedalus.configurations.getCustomDnsServers().get(index))) {
|
||||||
.putExtra(DnsServerConfigActivity.LAUNCH_ACTION_CUSTOM_DNS_SERVER_ID, index));
|
Daedalus.getInstance().startActivity(new Intent(Daedalus.getInstance(), DnsServerConfigActivity.class)
|
||||||
|
.putExtra(DnsServerConfigActivity.LAUNCH_ACTION_CUSTOM_DNS_SERVER_ID, index));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public class Configurations {
|
|||||||
|
|
||||||
private int totalId;
|
private int totalId;
|
||||||
|
|
||||||
public int getNextId() {
|
int getNextId() {
|
||||||
if (totalId < CUSTOM_DNS_ID_START) {
|
if (totalId < CUSTOM_DNS_ID_START) {
|
||||||
totalId = CUSTOM_DNS_ID_START;
|
totalId = CUSTOM_DNS_ID_START;
|
||||||
}
|
}
|
||||||
|
@ -146,4 +146,8 @@ public class DnsServerHelper {
|
|||||||
}
|
}
|
||||||
return Daedalus.DNS_SERVERS.get(0).getStringDescription(context);
|
return Daedalus.DNS_SERVERS.get(0).getStringDescription(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isInUsing(CustomDnsServer server) {
|
||||||
|
return Daedalus.getInstance().isServiceActivated() && (server.getId().equals(getPrimary()) || server.getId().equals(getSecondary()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user