Fixed dns test snackbar time
This commit is contained in:
parent
07ae91b2ac
commit
0d88d6f75e
@ -28,16 +28,8 @@ import org.itxtech.daedalus.util.DnsServer;
|
||||
* (at your option) any later version.
|
||||
*/
|
||||
public class DnsServerConfigFragment extends ConfigFragment {
|
||||
private View view;
|
||||
private int index;
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
view = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -46,7 +38,7 @@ public class DnsServerConfigFragment extends ConfigFragment {
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
||||
EditTextPreference serverName = (EditTextPreference) findPreference("serverName");
|
||||
serverName.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@ -106,7 +98,7 @@ public class DnsServerConfigFragment extends ConfigFragment {
|
||||
String serverPort = ((EditTextPreference) findPreference("serverPort")).getText();
|
||||
|
||||
if (serverName.equals("") | serverAddress.equals("") | serverPort.equals("")) {
|
||||
Snackbar.make(view, R.string.notice_fill_in_all, Snackbar.LENGTH_LONG)
|
||||
Snackbar.make(getView(), R.string.notice_fill_in_all, Snackbar.LENGTH_LONG)
|
||||
.setAction("Action", null).show();
|
||||
break;
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ public class DnsTestFragment extends ToolbarFragment {
|
||||
startTestBut.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Snackbar.make(v, R.string.notice_start_test, Snackbar.LENGTH_LONG)
|
||||
Snackbar.make(v, R.string.notice_start_test, Snackbar.LENGTH_SHORT)
|
||||
.setAction("Action", null).show();
|
||||
startTestBut.setVisibility(View.INVISIBLE);
|
||||
|
||||
|
@ -6,9 +6,7 @@ import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.*;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import org.itxtech.daedalus.Daedalus;
|
||||
import org.itxtech.daedalus.R;
|
||||
import org.itxtech.daedalus.util.DnsServerHelper;
|
||||
@ -25,7 +23,6 @@ import org.itxtech.daedalus.util.DnsServerHelper;
|
||||
* (at your option) any later version.
|
||||
*/
|
||||
public class GlobalConfigFragment extends PreferenceFragment {
|
||||
private View view = null;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@ -46,7 +43,7 @@ public class GlobalConfigFragment extends PreferenceFragment {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
preference.setSummary(DnsServerHelper.getDescription((String) newValue, Daedalus.getInstance()));
|
||||
Snackbar.make(view, R.string.notice_need_restart, Snackbar.LENGTH_LONG)
|
||||
Snackbar.make(getView(), R.string.notice_need_restart, Snackbar.LENGTH_LONG)
|
||||
.setAction("Action", null).show();
|
||||
return true;
|
||||
}
|
||||
@ -60,7 +57,7 @@ public class GlobalConfigFragment extends PreferenceFragment {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
preference.setSummary(DnsServerHelper.getDescription((String) newValue, Daedalus.getInstance()));
|
||||
Snackbar.make(view, R.string.notice_need_restart, Snackbar.LENGTH_LONG)
|
||||
Snackbar.make(getView(), R.string.notice_need_restart, Snackbar.LENGTH_LONG)
|
||||
.setAction("Action", null).show();
|
||||
return true;
|
||||
}
|
||||
@ -121,12 +118,6 @@ public class GlobalConfigFragment extends PreferenceFragment {
|
||||
updateAdvancedOptions(advanced.isChecked());
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
return view;
|
||||
}
|
||||
|
||||
private void updateAdvancedOptions(boolean checked) {
|
||||
PreferenceCategory category = (PreferenceCategory) findPreference("settings_advanced");
|
||||
for (int i = 1; i < category.getPreferenceCount(); i++) {
|
||||
@ -143,18 +134,10 @@ public class GlobalConfigFragment extends PreferenceFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
if (view != null && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
Snackbar.make(view, R.string.notice_legacy_api, Snackbar.LENGTH_LONG)
|
||||
.setAction("Action", null).show();
|
||||
}
|
||||
}
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
|
||||
view = null;
|
||||
Snackbar.make(view, R.string.notice_legacy_api, Snackbar.LENGTH_LONG)
|
||||
.setAction("Action", null).show();
|
||||
}
|
||||
}
|
||||
|
@ -23,11 +23,9 @@ import org.itxtech.daedalus.activity.MainActivity;
|
||||
*/
|
||||
public class MainFragment extends ToolbarFragment {
|
||||
|
||||
private View view = null;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
view = inflater.inflate(R.layout.fragment_main, container, false);
|
||||
View view = inflater.inflate(R.layout.fragment_main, container, false);
|
||||
|
||||
Button but = (Button) view.findViewById(R.id.button_activate);
|
||||
but.setOnClickListener(new View.OnClickListener() {
|
||||
@ -50,13 +48,6 @@ public class MainFragment extends ToolbarFragment {
|
||||
toolbar.setTitle(R.string.action_home);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
view = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
@ -65,7 +56,7 @@ public class MainFragment extends ToolbarFragment {
|
||||
|
||||
private void updateUserInterface() {
|
||||
Log.d("DMainFragment", "updateInterface");
|
||||
Button but = (Button) view.findViewById(R.id.button_activate);
|
||||
Button but = (Button) getView().findViewById(R.id.button_activate);
|
||||
if (Daedalus.getInstance().isServiceActivated()) {
|
||||
but.setText(R.string.button_text_deactivate);
|
||||
} else {
|
||||
|
@ -40,7 +40,6 @@ public class RuleConfigFragment extends ConfigFragment {
|
||||
private Intent intent = null;
|
||||
private Thread mThread = null;
|
||||
private RuleConfigHandler mHandler = null;
|
||||
private View view;
|
||||
private int id;
|
||||
|
||||
public void setIntent(Intent intent) {
|
||||
@ -55,7 +54,6 @@ public class RuleConfigFragment extends ConfigFragment {
|
||||
intent = null;
|
||||
mHandler.shutdown();
|
||||
mHandler = null;
|
||||
view = null;
|
||||
}
|
||||
|
||||
private void stopThread() {
|
||||
@ -74,7 +72,7 @@ public class RuleConfigFragment extends ConfigFragment {
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
||||
mHandler = new RuleConfigHandler().setView(view);
|
||||
|
||||
@ -124,7 +122,7 @@ public class RuleConfigFragment extends ConfigFragment {
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
save();
|
||||
if (mThread == null) {
|
||||
Snackbar.make(view, R.string.notice_start_download, Snackbar.LENGTH_LONG)
|
||||
Snackbar.make(getView(), R.string.notice_start_download, Snackbar.LENGTH_LONG)
|
||||
.setAction("Action", null).show();
|
||||
mThread = new Thread(new Runnable() {
|
||||
@Override
|
||||
@ -152,7 +150,7 @@ public class RuleConfigFragment extends ConfigFragment {
|
||||
});
|
||||
mThread.start();
|
||||
} else {
|
||||
Snackbar.make(view, R.string.notice_now_downloading, Snackbar.LENGTH_LONG)
|
||||
Snackbar.make(getView(), R.string.notice_now_downloading, Snackbar.LENGTH_LONG)
|
||||
.setAction("Action", null).show();
|
||||
}
|
||||
return false;
|
||||
@ -214,7 +212,7 @@ public class RuleConfigFragment extends ConfigFragment {
|
||||
String ruleDownloadUrl = ((EditTextPreference) findPreference("ruleDownloadUrl")).getText();
|
||||
|
||||
if (ruleName.equals("") | ruleType.equals("") | ruleFilename.equals("") | ruleDownloadUrl.equals("")) {
|
||||
Snackbar.make(view, R.string.notice_fill_in_all, Snackbar.LENGTH_SHORT)
|
||||
Snackbar.make(getView(), R.string.notice_fill_in_all, Snackbar.LENGTH_SHORT)
|
||||
.setAction("Action", null).show();
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user