Added check update button (TODO: async)
This commit is contained in:
parent
44cb251cde
commit
dee03d79e1
@ -2,7 +2,12 @@ package org.itxtech.daedalus.fragment;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.ListPreference;
|
import android.preference.ListPreference;
|
||||||
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceFragment;
|
import android.preference.PreferenceFragment;
|
||||||
|
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.Daedalus;
|
||||||
import org.itxtech.daedalus.R;
|
import org.itxtech.daedalus.R;
|
||||||
import org.itxtech.daedalus.util.DnsServer;
|
import org.itxtech.daedalus.util.DnsServer;
|
||||||
@ -31,6 +36,24 @@ public class SettingsFragment extends PreferenceFragment {
|
|||||||
ListPreference secondaryServer = (ListPreference) findPreference("secondary_server");
|
ListPreference secondaryServer = (ListPreference) findPreference("secondary_server");
|
||||||
secondaryServer.setEntries(DnsServer.getDnsServerNames(Daedalus.getInstance()));
|
secondaryServer.setEntries(DnsServer.getDnsServerNames(Daedalus.getInstance()));
|
||||||
secondaryServer.setEntryValues(DnsServer.getDnsServerIds());
|
secondaryServer.setEntryValues(DnsServer.getDnsServerIds());
|
||||||
primaryServer.setDefaultValue(Daedalus.DNS_SERVERS.get(1).getId());
|
secondaryServer.setDefaultValue(Daedalus.DNS_SERVERS.get(1).getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
final View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
|
||||||
|
ListPreference checkUpdate = (ListPreference) findPreference("settings_check_update");
|
||||||
|
checkUpdate.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
Snackbar.make(view, R.string.notice_checking_update, Snackbar.LENGTH_LONG)
|
||||||
|
.setAction("Action", null).show();
|
||||||
|
//TODO: async check update
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return view;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
package org.itxtech.daedalus.view;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.preference.ListPreference;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author PeratX
|
||||||
|
*/
|
||||||
|
public class ClickPreference extends ListPreference {
|
||||||
|
|
||||||
|
public ClickPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClickPreference(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClickPreference(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onClick() {
|
||||||
|
}
|
||||||
|
}
|
@ -15,7 +15,7 @@
|
|||||||
<string name="server_east_china">华东</string>
|
<string name="server_east_china">华东</string>
|
||||||
<string name="server_north_china">华北</string>
|
<string name="server_north_china">华北</string>
|
||||||
<string name="secondary_server">备用 DNS 服务器</string>
|
<string name="secondary_server">备用 DNS 服务器</string>
|
||||||
<string name="notice_start_test">正在测试指定的 DNS 服务器</string>
|
<string name="notice_start_test">正在测试指定的 DNS 服务器……</string>
|
||||||
<string name="action_server_test">测试服务器</string>
|
<string name="action_server_test">测试服务器</string>
|
||||||
<string name="action_start_test">开始测试</string>
|
<string name="action_start_test">开始测试</string>
|
||||||
<string name="test_domain">测试域名:</string>
|
<string name="test_domain">测试域名:</string>
|
||||||
@ -30,4 +30,7 @@
|
|||||||
<string name="action_join_qqgroup">加入 CuteDNS! QQ群</string>
|
<string name="action_join_qqgroup">加入 CuteDNS! QQ群</string>
|
||||||
<string name="notice_join_group_failed">未安装手Q或当前版本不支持此操作。</string>
|
<string name="notice_join_group_failed">未安装手Q或当前版本不支持此操作。</string>
|
||||||
<string name="settings_notification">启用时显示通知</string>
|
<string name="settings_notification">启用时显示通知</string>
|
||||||
|
<string name="settings_check_update">检查更新</string>
|
||||||
|
<string name="settings_update_summary">通过 GitHub 检查更新</string>
|
||||||
|
<string name="notice_checking_update">正在检查更新……</string>
|
||||||
</resources>
|
</resources>
|
@ -14,7 +14,7 @@
|
|||||||
<string name="server_east_china">East China</string>
|
<string name="server_east_china">East China</string>
|
||||||
<string name="server_north_china">North China</string>
|
<string name="server_north_china">North China</string>
|
||||||
<string name="secondary_server">Secondary DNS server</string>
|
<string name="secondary_server">Secondary DNS server</string>
|
||||||
<string name="notice_start_test">Testing specified DNS server</string>
|
<string name="notice_start_test">Testing specified DNS server…</string>
|
||||||
<string name="action_server_test">Server test</string>
|
<string name="action_server_test">Server test</string>
|
||||||
<string name="action_start_test">Start test</string>
|
<string name="action_start_test">Start test</string>
|
||||||
<string name="test_domain">Test domain:</string>
|
<string name="test_domain">Test domain:</string>
|
||||||
@ -27,7 +27,10 @@
|
|||||||
<string name="action_visit_cutedns">Visit CuteDNS!</string>
|
<string name="action_visit_cutedns">Visit CuteDNS!</string>
|
||||||
<string name="action_visit_github">Visit Project home</string>
|
<string name="action_visit_github">Visit Project home</string>
|
||||||
<string name="action_join_qqgroup">Join QQ group</string>
|
<string name="action_join_qqgroup">Join QQ group</string>
|
||||||
<string name="notice_join_group_failed">QQ is not installed or this version of QQ does not support this operation.
|
<string name="notice_join_group_failed">QQ is not installed or current version does not support this operation.
|
||||||
</string>
|
</string>
|
||||||
<string name="settings_notification">Show notification when activated</string>
|
<string name="settings_notification">Show notification when activated</string>
|
||||||
|
<string name="settings_check_update">Check update</string>
|
||||||
|
<string name="settings_update_summary">Check update via GitHub</string>
|
||||||
|
<string name="notice_checking_update">Checking update…</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1,18 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<PreferenceCategory
|
|
||||||
android:key="settings_system"
|
|
||||||
android:title="@string/settings_system">
|
|
||||||
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="settings_boot"
|
|
||||||
android:title="@string/settings_boot"
|
|
||||||
android:defaultValue="false"/>
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="settings_notification"
|
|
||||||
android:title="@string/settings_notification"
|
|
||||||
android:defaultValue="true"/>
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="settings_server"
|
android:key="settings_server"
|
||||||
@ -28,4 +15,21 @@
|
|||||||
android:title="@string/secondary_server">
|
android:title="@string/secondary_server">
|
||||||
</ListPreference>
|
</ListPreference>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="settings_system"
|
||||||
|
android:title="@string/settings_system">
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:key="settings_boot"
|
||||||
|
android:title="@string/settings_boot"
|
||||||
|
android:defaultValue="false"/>
|
||||||
|
<SwitchPreference
|
||||||
|
android:key="settings_notification"
|
||||||
|
android:title="@string/settings_notification"
|
||||||
|
android:defaultValue="true"/>
|
||||||
|
<org.itxtech.daedalus.view.ClickPreference
|
||||||
|
android:key="settings_check_update"
|
||||||
|
android:title="@string/settings_check_update"
|
||||||
|
android:summary="@string/settings_update_summary"/>
|
||||||
|
</PreferenceCategory>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
Loading…
x
Reference in New Issue
Block a user