Improved initial type
This commit is contained in:
parent
bb5c195283
commit
0a0be5815d
@ -175,11 +175,10 @@ public class DnsTestFragment extends ToolbarFragment {
|
|||||||
private static void stopThread() {
|
private static void stopThread() {
|
||||||
try {
|
try {
|
||||||
if (mThread != null) {
|
if (mThread != null) {
|
||||||
mThread.join(1);
|
mThread.interrupt();
|
||||||
mThread = null;
|
mThread = null;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception ignored) {
|
||||||
Log.e(TAG, e.toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ public class RuleConfigFragment extends ConfigFragment {
|
|||||||
String ruleDownloadUrl = ((EditTextPreference) findPreference("ruleDownloadUrl")).getText();
|
String ruleDownloadUrl = ((EditTextPreference) findPreference("ruleDownloadUrl")).getText();
|
||||||
|
|
||||||
if (ruleName.equals("") | ruleType.equals("") | ruleFilename.equals("") | ruleDownloadUrl.equals("")) {
|
if (ruleName.equals("") | ruleType.equals("") | ruleFilename.equals("") | ruleDownloadUrl.equals("")) {
|
||||||
Snackbar.make(view, R.string.notice_fill_in_all, Snackbar.LENGTH_LONG)
|
Snackbar.make(view, R.string.notice_fill_in_all, Snackbar.LENGTH_SHORT)
|
||||||
.setAction("Action", null).show();
|
.setAction("Action", null).show();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -318,7 +318,7 @@ public class RuleConfigFragment extends ConfigFragment {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
Snackbar.make(view, R.string.notice_downloaded, Snackbar.LENGTH_LONG)
|
Snackbar.make(view, R.string.notice_downloaded, Snackbar.LENGTH_SHORT)
|
||||||
.setAction("Action", null).show();
|
.setAction("Action", null).show();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ public class RulesFragment extends ToolbarFragment implements Toolbar.OnMenuItem
|
|||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
view = inflater.inflate(R.layout.fragment_rules, container, false);
|
view = inflater.inflate(R.layout.fragment_rules, container, false);
|
||||||
currentType = Rule.TYPE_HOSTS;
|
currentType = Daedalus.configurations.getUsingRuleType();
|
||||||
|
|
||||||
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView_rules);
|
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView_rules);
|
||||||
LinearLayoutManager manager = new LinearLayoutManager(getActivity());
|
LinearLayoutManager manager = new LinearLayoutManager(getActivity());
|
||||||
@ -107,6 +107,7 @@ public class RulesFragment extends ToolbarFragment implements Toolbar.OnMenuItem
|
|||||||
toolbar.inflateMenu(R.menu.rules);
|
toolbar.inflateMenu(R.menu.rules);
|
||||||
toolbar.setTitle(R.string.action_rules);
|
toolbar.setTitle(R.string.action_rules);
|
||||||
toolbar.setOnMenuItemClickListener(this);
|
toolbar.setOnMenuItemClickListener(this);
|
||||||
|
toolbar.getMenu().findItem(R.id.action_change_type).setTitle(Rule.getTypeById(currentType));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -116,11 +117,10 @@ public class RulesFragment extends ToolbarFragment implements Toolbar.OnMenuItem
|
|||||||
if (id == R.id.action_change_type) {
|
if (id == R.id.action_change_type) {
|
||||||
if (currentType == Rule.TYPE_HOSTS) {
|
if (currentType == Rule.TYPE_HOSTS) {
|
||||||
currentType = Rule.TYPE_DNAMASQ;
|
currentType = Rule.TYPE_DNAMASQ;
|
||||||
item.setTitle("DNSMasq");
|
|
||||||
} else if (currentType == Rule.TYPE_DNAMASQ) {
|
} else if (currentType == Rule.TYPE_DNAMASQ) {
|
||||||
currentType = Rule.TYPE_HOSTS;
|
currentType = Rule.TYPE_HOSTS;
|
||||||
item.setTitle("Hosts");
|
|
||||||
}
|
}
|
||||||
|
toolbar.getMenu().findItem(R.id.action_change_type).setTitle(Rule.getTypeById(currentType));
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -97,6 +97,24 @@ public class Configurations {
|
|||||||
return hostsRules;
|
return hostsRules;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getUsingRuleType() {
|
||||||
|
if (hostsRules != null && hostsRules.size() > 0) {
|
||||||
|
for (Rule rule : hostsRules) {
|
||||||
|
if (rule.isUsing()) {
|
||||||
|
return Rule.TYPE_HOSTS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (dnsmasqRules != null && dnsmasqRules.size() > 0) {
|
||||||
|
for (Rule rule : dnsmasqRules) {
|
||||||
|
if (rule.isUsing()) {
|
||||||
|
return Rule.TYPE_DNAMASQ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Rule.TYPE_HOSTS;
|
||||||
|
}
|
||||||
|
|
||||||
public static Configurations load(File file) {
|
public static Configurations load(File file) {
|
||||||
Configurations.file = file;
|
Configurations.file = file;
|
||||||
Configurations config = null;
|
Configurations config = null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user