Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Wade
DnsChanger
Commits
4e17dac0
Commit
4e17dac0
authored
Apr 13, 2018
by
Daniel Wolf
Browse files
Do not create an entry if an entry with the same name already exists
parent
0419cef3
Changes
2
Show whitespace changes
Inline
Side-by-side
app/src/main/java/com/frostnerd/dnschanger/database/DatabaseHelper.java
View file @
4e17dac0
...
...
@@ -144,6 +144,10 @@ public class DatabaseHelper extends com.frostnerd.utils.database.DatabaseHelper
super
.
close
();
}
public
boolean
dnsEntryExists
(
String
name
){
return
select
(
DNSEntry
.
class
,
WhereCondition
.
equal
(
"name"
,
name
)).
size
()
!=
0
;
}
public
boolean
dnsRuleExists
(
@NonNull
String
host
){
return
this
.
rowExists
(
DNSRule
.
class
,
WhereCondition
.
equal
(
findColumn
(
DNSRule
.
class
,
"host"
),
host
));
}
...
...
app/src/main/java/com/frostnerd/dnschanger/dialogs/DNSCreationDialog.java
View file @
4e17dac0
...
...
@@ -15,6 +15,7 @@ import android.widget.Button;
import
android.widget.EditText
;
import
com.frostnerd.dnschanger.R
;
import
com.frostnerd.dnschanger.database.DatabaseHelper
;
import
com.frostnerd.dnschanger.database.entities.DNSEntry
;
import
com.frostnerd.dnschanger.database.entities.IPPortPair
;
import
com.frostnerd.dnschanger.util.PreferencesAccessor
;
...
...
@@ -119,7 +120,7 @@ public class DNSCreationDialog extends UtilityDialog {
@Override
public
void
onClick
(
View
v
)
{
if
(
isConfigurationValid
())
{
listener
.
onCreationFinished
(
ed_name
.
getText
().
toString
(),
dns1
,
dns2
,
dns1V6
,
dns2V6
);
listener
.
onCreationFinished
(
ed_name
.
getText
().
toString
()
.
trim
()
,
dns1
,
dns2
,
dns1V6
,
dns2V6
);
dismiss
();
}
else
{
vibrator
.
vibrate
(
300
);
...
...
@@ -204,6 +205,8 @@ public class DNSCreationDialog extends UtilityDialog {
@Override
public
void
afterTextChanged
(
Editable
s
)
{
if
(
s
.
toString
().
trim
().
equals
(
""
))
met_name
.
setIndicatorState
(
MaterialEditText
.
IndicatorState
.
INCORRECT
);
else
if
(
DatabaseHelper
.
getInstance
(
getContext
()).
dnsEntryExists
(
s
.
toString
().
trim
()))
met_name
.
setIndicatorState
(
MaterialEditText
.
IndicatorState
.
INCORRECT
);
else
met_name
.
setIndicatorState
(
MaterialEditText
.
IndicatorState
.
CORRECT
);
}
});
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment