parent
							
								
									aa052a8816
								
							
						
					
					
						commit
						c5759ba251
					
				| @ -1,32 +0,0 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <project version="4"> | ||||
|   <component name="WizardSettings"> | ||||
|     <option name="children"> | ||||
|       <map> | ||||
|         <entry key="vectorWizard"> | ||||
|           <value> | ||||
|             <PersistentState> | ||||
|               <option name="children"> | ||||
|                 <map> | ||||
|                   <entry key="vectorAssetStep"> | ||||
|                     <value> | ||||
|                       <PersistentState> | ||||
|                         <option name="values"> | ||||
|                           <map> | ||||
|                             <entry key="assetSourceType" value="FILE" /> | ||||
|                             <entry key="outputName" value="ic_info" /> | ||||
|                             <entry key="sourceFile" value="F:\SVG图标\info.svg" /> | ||||
|                           </map> | ||||
|                         </option> | ||||
|                       </PersistentState> | ||||
|                     </value> | ||||
|                   </entry> | ||||
|                 </map> | ||||
|               </option> | ||||
|             </PersistentState> | ||||
|           </value> | ||||
|         </entry> | ||||
|       </map> | ||||
|     </option> | ||||
|   </component> | ||||
| </project> | ||||
| @ -1,3 +0,0 @@ | ||||
| <component name="ProjectDictionaryState"> | ||||
|   <dictionary name="fengyue" /> | ||||
| </component> | ||||
| @ -1,36 +0,0 @@ | ||||
| <component name="InspectionProjectProfileManager"> | ||||
|   <profile version="1.0"> | ||||
|     <option name="myName" value="Project Default" /> | ||||
|     <inspection_tool class="JavaDoc" enabled="true" level="WARNING" enabled_by_default="true"> | ||||
|       <option name="TOP_LEVEL_CLASS_OPTIONS"> | ||||
|         <value> | ||||
|           <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" /> | ||||
|           <option name="REQUIRED_TAGS" value="" /> | ||||
|         </value> | ||||
|       </option> | ||||
|       <option name="INNER_CLASS_OPTIONS"> | ||||
|         <value> | ||||
|           <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" /> | ||||
|           <option name="REQUIRED_TAGS" value="" /> | ||||
|         </value> | ||||
|       </option> | ||||
|       <option name="METHOD_OPTIONS"> | ||||
|         <value> | ||||
|           <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" /> | ||||
|           <option name="REQUIRED_TAGS" value="@return@param@throws or @exception" /> | ||||
|         </value> | ||||
|       </option> | ||||
|       <option name="FIELD_OPTIONS"> | ||||
|         <value> | ||||
|           <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" /> | ||||
|           <option name="REQUIRED_TAGS" value="" /> | ||||
|         </value> | ||||
|       </option> | ||||
|       <option name="IGNORE_DEPRECATED" value="false" /> | ||||
|       <option name="IGNORE_JAVADOC_PERIOD" value="true" /> | ||||
|       <option name="IGNORE_DUPLICATED_THROWS" value="false" /> | ||||
|       <option name="IGNORE_POINT_TO_ITSELF" value="false" /> | ||||
|       <option name="myAdditionalJavadocTags" value="date" /> | ||||
|     </inspection_tool> | ||||
|   </profile> | ||||
| </component> | ||||
| @ -0,0 +1,189 @@ | ||||
| package xyz.fycz.myreader.ui.fragment | ||||
| 
 | ||||
| import android.content.DialogInterface | ||||
| import android.os.Bundle | ||||
| import android.view.LayoutInflater | ||||
| import android.view.View | ||||
| import android.view.ViewGroup | ||||
| import android.widget.NumberPicker | ||||
| import androidx.appcompat.app.AlertDialog | ||||
| import com.kongzue.dialogx.dialogs.BottomMenu | ||||
| import io.reactivex.disposables.Disposable | ||||
| import xyz.fycz.myreader.R | ||||
| import xyz.fycz.myreader.application.SysManager | ||||
| import xyz.fycz.myreader.base.BaseFragment | ||||
| import xyz.fycz.myreader.base.adapter2.onClick | ||||
| import xyz.fycz.myreader.base.observer.MySingleObserver | ||||
| import xyz.fycz.myreader.databinding.FragmentProxySettingBinding | ||||
| import xyz.fycz.myreader.model.sourceAnalyzer.BookSourceManager | ||||
| import xyz.fycz.myreader.ui.dialog.DialogCreator.OnMultiDialogListener | ||||
| import xyz.fycz.myreader.ui.dialog.MultiChoiceDialog | ||||
| import xyz.fycz.myreader.ui.dialog.MyAlertDialog | ||||
| import xyz.fycz.myreader.util.SharedPreUtils | ||||
| import xyz.fycz.myreader.util.ToastUtils | ||||
| 
 | ||||
| /** | ||||
|  * @author fengyue | ||||
|  * @date 2022/3/24 10:42 | ||||
|  */ | ||||
| class ProxyFragment : BaseFragment() { | ||||
| 
 | ||||
|     private lateinit var binding: FragmentProxySettingBinding | ||||
|     private var proxyType: Int = 0 | ||||
|     private var enableProxy: Boolean = false | ||||
|     private lateinit var proxyHost: String | ||||
|     private lateinit var proxyPort: String | ||||
|     private lateinit var proxyUsername: String | ||||
|     private lateinit var proxyPassword: String | ||||
|     private var mNoProxySourcesDia: AlertDialog? = null | ||||
|     private val proxyTypeArr = arrayOf("http", "socks5") | ||||
|     private val spu: SharedPreUtils = SharedPreUtils.getInstance() | ||||
| 
 | ||||
|     override fun bindView(inflater: LayoutInflater, container: ViewGroup?): View { | ||||
|         binding = FragmentProxySettingBinding.inflate(inflater, container, false) | ||||
|         return binding.root | ||||
|     } | ||||
| 
 | ||||
|     override fun initData(savedInstanceState: Bundle?) { | ||||
|         enableProxy = spu.getBoolean("enableProxy") | ||||
|         proxyType = spu.getInt("proxyType") | ||||
|         proxyHost = spu.getString("proxyHost") | ||||
|         proxyPort = spu.getString("proxyHost") | ||||
|         proxyUsername = spu.getString("proxyUsername") | ||||
|         proxyPassword = spu.getString("proxyPassword") | ||||
|     } | ||||
| 
 | ||||
|     override fun initWidget(savedInstanceState: Bundle?) { | ||||
|         binding.scEnableProxy.isChecked = enableProxy | ||||
|         if (enableProxy) binding.llContent.visibility = View.VISIBLE | ||||
|         binding.tvProxyType.text = proxyTypeArr[proxyType] | ||||
|         binding.tvProxyHost.text = proxyHost.ifEmpty { "请输入代理服务器地址" } | ||||
|         binding.tvProxyPort.text = proxyHost.ifEmpty { "请输入代理服务器端口" } | ||||
|         binding.tvProxyUsername.text = proxyHost.ifEmpty { "请输入代理认证用户名" } | ||||
|         binding.tvProxyPassword.text = proxyHost.ifEmpty { "请输入代理认证密码" } | ||||
|     } | ||||
| 
 | ||||
|     override fun initClick() { | ||||
|         binding.rlEnableProxy.onClick { | ||||
|             enableProxy = !enableProxy | ||||
|             binding.scEnableProxy.isChecked = enableProxy | ||||
|             spu.putBoolean("enableProxy", enableProxy) | ||||
|             binding.llContent.visibility = if (enableProxy) View.VISIBLE else View.GONE | ||||
|         } | ||||
| 
 | ||||
|         binding.llProxyType.onClick { | ||||
|             BottomMenu.show(getString(R.string.proxy_type), proxyTypeArr) | ||||
|                 .setSelection(proxyType) | ||||
|                 .setOnMenuItemClickListener { _: BottomMenu?, _: CharSequence?, which: Int -> | ||||
|                     proxyType = which | ||||
|                     SharedPreUtils.getInstance().putInt("proxyType", which) | ||||
|                     binding.tvProxyType.text = proxyTypeArr[which] | ||||
|                     false | ||||
|                 }.setCancelButton(R.string.cancel) | ||||
|         } | ||||
|         binding.llProxyHost.onClick { | ||||
|             var tem = "" | ||||
|             MyAlertDialog.createInputDia( | ||||
|                 context, getString(R.string.proxy_host), | ||||
|                 "", proxyHost, true, 100, | ||||
|                 { text: String -> tem = text } | ||||
|             ) { dialog: DialogInterface, _: Int -> | ||||
|                 proxyHost = tem | ||||
|                 binding.tvProxyHost.text = proxyHost | ||||
|                 spu.putString("proxyHost", proxyHost) | ||||
|                 dialog.dismiss() | ||||
|             } | ||||
|         } | ||||
|         binding.llProxyPort.onClick { | ||||
|             val view = | ||||
|                 LayoutInflater.from(context).inflate(R.layout.dialog_number_picker, null) | ||||
|             val threadPick = view.findViewById<NumberPicker>(R.id.number_picker) | ||||
|             threadPick.maxValue = 99999 | ||||
|             threadPick.minValue = 10 | ||||
|             threadPick.value = proxyPort.toInt() | ||||
|             threadPick.setOnScrollListener { _: NumberPicker?, _: Int -> } | ||||
|             MyAlertDialog.build(context) | ||||
|                 .setTitle(R.string.proxy_port) | ||||
|                 .setView(view) | ||||
|                 .setPositiveButton(R.string.confirm) { _: DialogInterface?, _: Int -> | ||||
|                     proxyPort = threadPick.value.toString() | ||||
|                     spu.putString("proxyPort", proxyPort) | ||||
|                     binding.tvProxyPort.text = proxyPort | ||||
|                 }.setNegativeButton(R.string.cancel, null) | ||||
|                 .show() | ||||
|         } | ||||
|         binding.llProxyUsername.onClick { | ||||
|             var tem = "" | ||||
|             MyAlertDialog.createInputDia( | ||||
|                 context, getString(R.string.proxy_username), | ||||
|                 "", proxyUsername, true, 100, | ||||
|                 { text: String -> tem = text } | ||||
|             ) { dialog: DialogInterface, _: Int -> | ||||
|                 proxyUsername = tem | ||||
|                 binding.tvProxyUsername.text = proxyUsername | ||||
|                 spu.putString("proxyUsername", proxyUsername) | ||||
|                 dialog.dismiss() | ||||
|             } | ||||
|         } | ||||
|         binding.llProxyPassword.onClick { | ||||
|             var tem = "" | ||||
|             MyAlertDialog.createInputDia( | ||||
|                 context, getString(R.string.proxy_password), | ||||
|                 "", proxyPassword, true, 100, | ||||
|                 { text: String -> tem = text } | ||||
|             ) { dialog: DialogInterface, _: Int -> | ||||
|                 proxyPassword = tem | ||||
|                 binding.tvProxyPassword.text = proxyPassword | ||||
|                 spu.putString("proxyPassword", proxyPassword) | ||||
|                 dialog.dismiss() | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         binding.llNoProxySources.onClick { | ||||
|             if (mNoProxySourcesDia != null) { | ||||
|                 mNoProxySourcesDia?.show() | ||||
|                 return@onClick | ||||
|             } | ||||
|             val sources = BookSourceManager.getAllBookSourceByOrderNum() | ||||
|             val mSourcesName = arrayOfNulls<CharSequence>(sources.size) | ||||
|             val isNoProxy = BooleanArray(sources.size) | ||||
|             var dSourceCount = 0 | ||||
|             for ((i, source) in sources.withIndex()) { | ||||
|                 mSourcesName[i] = source.sourceName | ||||
|                 val noProxy = source.getNoProxy() | ||||
|                 if (noProxy) dSourceCount++ | ||||
|                 isNoProxy[i] = noProxy | ||||
|             } | ||||
|             mNoProxySourcesDia = MultiChoiceDialog().create(context, getString(R.string.no_proxy_sources_tip), | ||||
|                 mSourcesName, isNoProxy, dSourceCount, | ||||
|                 { _: DialogInterface?, _: Int -> | ||||
|                     BookSourceManager.saveDatas(sources) | ||||
|                         .subscribe(object : MySingleObserver<Boolean?>() { | ||||
|                             override fun onSubscribe(d: Disposable) { | ||||
|                                 addDisposable(d) | ||||
|                             } | ||||
| 
 | ||||
|                             override fun onSuccess(aBoolean: Boolean) { | ||||
|                                 if (aBoolean) { | ||||
|                                     ToastUtils.showSuccess("保存成功") | ||||
|                                 } | ||||
|                             } | ||||
|                         }) | ||||
|                 }, null, object : OnMultiDialogListener { | ||||
|                     override fun onItemClick( | ||||
|                         dialog: DialogInterface, | ||||
|                         which: Int, | ||||
|                         isChecked: Boolean | ||||
|                     ) { | ||||
|                         sources[which].setNoProxy(isChecked) | ||||
|                     } | ||||
| 
 | ||||
|                     override fun onSelectAll(isSelectAll: Boolean) { | ||||
|                         for (source in sources) { | ||||
|                             source.setNoProxy(isSelectAll) | ||||
|                         } | ||||
|                     } | ||||
|                 }) | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,203 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     xmlns:tools="http://schemas.android.com/tools" | ||||
|     android:layout_width="match_parent" | ||||
|     android:layout_height="match_parent" | ||||
|     android:orientation="vertical"> | ||||
| 
 | ||||
|     <RelativeLayout | ||||
|         android:id="@+id/rl_enable_proxy" | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="50dp" | ||||
|         android:background="@drawable/selector_common_bg" | ||||
|         android:gravity="center" | ||||
|         android:paddingLeft="20dp" | ||||
|         android:paddingRight="20dp"> | ||||
| 
 | ||||
|         <TextView | ||||
|             android:layout_width="wrap_content" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:layout_centerVertical="true" | ||||
|             android:text="@string/enable_proxy" | ||||
|             android:textColor="@color/textSecondary" | ||||
|             android:textSize="@dimen/text_normal_size" /> | ||||
| 
 | ||||
|         <androidx.appcompat.widget.SwitchCompat | ||||
|             android:id="@+id/sc_enable_proxy" | ||||
|             android:layout_width="wrap_content" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:layout_alignParentEnd="true" | ||||
|             android:layout_centerVertical="true" | ||||
|             android:clickable="false" | ||||
|             android:longClickable="false" /> | ||||
|     </RelativeLayout> | ||||
| 
 | ||||
|     <View | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="15dp" /> | ||||
| 
 | ||||
|     <LinearLayout | ||||
|         android:id="@+id/ll_content" | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="match_parent" | ||||
|         android:orientation="vertical" | ||||
|         android:visibility="gone"> | ||||
| 
 | ||||
| 
 | ||||
|         <LinearLayout | ||||
|             android:id="@+id/ll_proxy_type" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="60dp" | ||||
|             android:background="@drawable/selector_common_bg" | ||||
|             android:orientation="vertical" | ||||
|             android:paddingLeft="20dp" | ||||
|             android:paddingTop="8dp" | ||||
|             android:paddingRight="20dp"> | ||||
| 
 | ||||
|             <TextView | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:text="@string/proxy_type" | ||||
|                 android:textColor="@color/textSecondary" | ||||
|                 android:textSize="@dimen/text_normal_size" /> | ||||
| 
 | ||||
|             <TextView | ||||
|                 android:id="@+id/tv_proxy_type" | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:paddingTop="5dp" | ||||
|                 android:textColor="@color/textAssist" | ||||
|                 tools:text="socks5" /> | ||||
|         </LinearLayout> | ||||
| 
 | ||||
|         <LinearLayout | ||||
|             android:id="@+id/ll_proxy_host" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="60dp" | ||||
|             android:background="@drawable/selector_common_bg" | ||||
|             android:orientation="vertical" | ||||
|             android:paddingLeft="20dp" | ||||
|             android:paddingTop="8dp" | ||||
|             android:paddingRight="20dp"> | ||||
| 
 | ||||
|             <TextView | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:text="@string/proxy_host" | ||||
|                 android:textColor="@color/textSecondary" | ||||
|                 android:textSize="@dimen/text_normal_size" /> | ||||
| 
 | ||||
|             <TextView | ||||
|                 android:id="@+id/tv_proxy_host" | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:paddingTop="5dp" | ||||
|                 android:textColor="@color/textAssist" | ||||
|                 tools:text="127.0.0.1" /> | ||||
|         </LinearLayout> | ||||
| 
 | ||||
|         <LinearLayout | ||||
|             android:id="@+id/ll_proxy_port" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="60dp" | ||||
|             android:background="@drawable/selector_common_bg" | ||||
|             android:orientation="vertical" | ||||
|             android:paddingLeft="20dp" | ||||
|             android:paddingTop="8dp" | ||||
|             android:paddingRight="20dp"> | ||||
| 
 | ||||
|             <TextView | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:text="@string/proxy_port" | ||||
|                 android:textColor="@color/textSecondary" | ||||
|                 android:textSize="@dimen/text_normal_size" /> | ||||
| 
 | ||||
|             <TextView | ||||
|                 android:id="@+id/tv_proxy_port" | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:paddingTop="5dp" | ||||
|                 android:textColor="@color/textAssist" | ||||
|                 tools:text="1080" /> | ||||
|         </LinearLayout> | ||||
| 
 | ||||
|         <LinearLayout | ||||
|             android:id="@+id/ll_proxy_username" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="60dp" | ||||
|             android:background="@drawable/selector_common_bg" | ||||
|             android:orientation="vertical" | ||||
|             android:paddingLeft="20dp" | ||||
|             android:paddingTop="8dp" | ||||
|             android:paddingRight="20dp"> | ||||
| 
 | ||||
|             <TextView | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:text="@string/proxy_username" | ||||
|                 android:textColor="@color/textSecondary" | ||||
|                 android:textSize="@dimen/text_normal_size" /> | ||||
| 
 | ||||
|             <TextView | ||||
|                 android:id="@+id/tv_proxy_username" | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:paddingTop="5dp" | ||||
|                 android:textColor="@color/textAssist" | ||||
|                 tools:text="输入你的代理认证用户名" /> | ||||
|         </LinearLayout> | ||||
| 
 | ||||
|         <LinearLayout | ||||
|             android:id="@+id/ll_proxy_password" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="60dp" | ||||
|             android:background="@drawable/selector_common_bg" | ||||
|             android:orientation="vertical" | ||||
|             android:paddingLeft="20dp" | ||||
|             android:paddingTop="8dp" | ||||
|             android:paddingRight="20dp"> | ||||
| 
 | ||||
|             <TextView | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:text="@string/proxy_password" | ||||
|                 android:textColor="@color/textSecondary" | ||||
|                 android:textSize="@dimen/text_normal_size" /> | ||||
| 
 | ||||
|             <TextView | ||||
|                 android:id="@+id/tv_proxy_password" | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:paddingTop="5dp" | ||||
|                 android:textColor="@color/textAssist" | ||||
|                 tools:text="输入你的代理认证密码" /> | ||||
|         </LinearLayout> | ||||
| 
 | ||||
|         <LinearLayout | ||||
|             android:id="@+id/ll_no_proxy_sources" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="60dp" | ||||
|             android:background="@drawable/selector_common_bg" | ||||
|             android:orientation="vertical" | ||||
|             android:paddingLeft="20dp" | ||||
|             android:paddingTop="8dp" | ||||
|             android:paddingRight="20dp"> | ||||
| 
 | ||||
|             <TextView | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:text="@string/no_proxy_sources" | ||||
|                 android:textColor="@color/textSecondary" | ||||
|                 android:textSize="@dimen/text_normal_size" /> | ||||
| 
 | ||||
|             <TextView | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:paddingTop="5dp" | ||||
|                 android:text="@string/no_proxy_sources_tip" | ||||
|                 android:textColor="@color/textAssist" /> | ||||
|         </LinearLayout> | ||||
|     </LinearLayout> | ||||
| 
 | ||||
| </LinearLayout> | ||||
					Loading…
					
					
				
		Reference in new issue