| 1 | /* |
| 2 | * This is the source code of Telegram for Android v. 5.x.x. |
| 3 | * It is licensed under GNU GPL v. 2 or later. |
| 4 | * You should have received a copy of the license in this archive (see LICENSE). |
| 5 | * |
| 6 | * Copyright Nikolai Kudashov, 2013-2018. |
| 7 | */ |
| 8 | |
| 9 | package tw.nekomimi.nekogram; |
| 10 | |
| 11 | import android.content.Context; |
| 12 | import android.graphics.Canvas; |
| 13 | import android.graphics.PorterDuff; |
| 14 | import android.graphics.PorterDuffColorFilter; |
| 15 | import android.os.Build; |
| 16 | import android.text.InputType; |
| 17 | import android.text.TextUtils; |
| 18 | import android.util.TypedValue; |
| 19 | import android.view.Gravity; |
| 20 | import android.view.View; |
| 21 | import android.view.ViewGroup; |
| 22 | import android.view.inputmethod.EditorInfo; |
| 23 | import android.widget.FrameLayout; |
| 24 | import android.widget.ImageView; |
| 25 | import android.widget.LinearLayout; |
| 26 | import android.widget.ScrollView; |
| 27 | import android.widget.TextView; |
| 28 | |
| 29 | import com.v2ray.ang.V2RayConfig; |
| 30 | import com.v2ray.ang.dto.AngConfig; |
| 31 | |
| 32 | import org.telegram.messenger.AndroidUtilities; |
| 33 | import org.telegram.messenger.LocaleController; |
| 34 | import org.telegram.messenger.R; |
| 35 | import org.telegram.messenger.SharedConfig; |
| 36 | import org.telegram.messenger.Utilities; |
| 37 | import org.telegram.ui.ActionBar.ActionBar; |
| 38 | import org.telegram.ui.ActionBar.ActionBarMenuItem; |
| 39 | import org.telegram.ui.ActionBar.BaseFragment; |
| 40 | import org.telegram.ui.ActionBar.Theme; |
| 41 | import org.telegram.ui.ActionBar.ThemeDescription; |
| 42 | import org.telegram.ui.Cells.TextCheckCell; |
| 43 | import org.telegram.ui.Cells.TextInfoPrivacyCell; |
| 44 | import org.telegram.ui.Cells.TextSettingsCell; |
| 45 | import org.telegram.ui.Components.EditTextBoldCursor; |
| 46 | import org.telegram.ui.Components.LayoutHelper; |
| 47 | |
| 48 | import java.util.ArrayList; |
| 49 | |
| 50 | import cn.hutool.core.util.StrUtil; |
| 51 | import kotlin.Unit; |
| 52 | |
| 53 | public class VmessSettingsActivity extends BaseFragment { |
| 54 | |
| 55 | private EditTextBoldCursor[] inputFields; |
| 56 | |
| 57 | private EditTextBoldCursor ipField; |
| 58 | private EditTextBoldCursor portField; |
| 59 | private EditTextBoldCursor userIdField; |
| 60 | private EditTextBoldCursor alterIdField; |
| 61 | private TextSettingsCell securityField; |
| 62 | private TextSettingsCell networkField; |
| 63 | private TextSettingsCell headTypeField; |
| 64 | private EditTextBoldCursor requestHostField; |
| 65 | private EditTextBoldCursor pathField; |
| 66 | private TextCheckCell useTlsField; |
| 67 | private EditTextBoldCursor remarksField; |
| 68 | |
| 69 | private ScrollView scrollView; |
| 70 | private LinearLayout linearLayout2; |
| 71 | private LinearLayout inputFieldsContainer; |
| 72 | |
| 73 | private TextInfoPrivacyCell bottomCell; |
| 74 | private ActionBarMenuItem doneItem; |
| 75 | |
| 76 | private SharedConfig.VmessProxy currentProxyInfo; |
| 77 | private AngConfig.VmessBean currentBean; |
| 78 | |
| 79 | private boolean ignoreOnTextChange; |
| 80 | |
| 81 | private static final int done_button = 1; |
| 82 | |
| 83 | private static String[] securitySet = { "chacha20-poly1305","aes-128-gcm","auto","none","zero" }; |
| 84 | private static String[] networkSet = { "tcp","kcp","ws","h2","quic" }; |
| 85 | private static String[] headTypeSet = { "none","http","srtp","utp","wechat-video","dtls","wireguard" }; |
| 86 | |
| 87 | public class TypeCell extends FrameLayout { |
| 88 | |
| 89 | private TextView textView; |
| 90 | private ImageView checkImage; |
| 91 | private boolean needDivider; |
| 92 | |
| 93 | public TypeCell(Context context) { |
| 94 | super(context); |
| 95 | |
| 96 | setWillNotDraw(false); |
| 97 | |
| 98 | textView = new TextView(context); |
| 99 | textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText)); |
| 100 | textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); |
| 101 | textView.setLines(1); |
| 102 | textView.setMaxLines(1); |
| 103 | textView.setSingleLine(true); |
| 104 | textView.setEllipsize(TextUtils.TruncateAt.END); |
| 105 | textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); |
| 106 | addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 23 + 48 : 21, 0, LocaleController.isRTL ? 21 |
| 107 | |
| 108 | checkImage = new ImageView(context); |
| 109 | checkImage.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_featuredStickers_addedIcon), PorterDuff.Mode.SRC_IN)); |
| 110 | checkImage.setImageResource(R.drawable.sticker_added); |
| 111 | addView(checkImage, LayoutHelper.createFrame(19, 14, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 21, 0, 21, 0)); |
| 112 | |
| 113 | } |
| 114 | |
| 115 | @Override |
| 116 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
| 117 | super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(50) + (needDivider ? 1 : 0), MeasureSpec.EXACTLY)); |
| 118 | } |
| 119 | |
| 120 | public void setValue(String name, boolean checked, boolean divider) { |
| 121 | textView.setText(name); |
| 122 | checkImage.setVisibility(checked ? VISIBLE : INVISIBLE); |
| 123 | needDivider = divider; |
| 124 | } |
| 125 | |
| 126 | public void setTypeChecked(boolean value) { |
| 127 | checkImage.setVisibility(value ? VISIBLE : INVISIBLE); |
| 128 | } |
| 129 | |
| 130 | @Override |
| 131 | protected void onDraw(Canvas canvas) { |
| 132 | if (needDivider) { |
| 133 | canvas.drawLine(0, getMeasuredHeight() - 1, getMeasuredWidth(), getMeasuredHeight() - 1, Theme.dividerPaint); |
| 134 | } |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | public VmessSettingsActivity() { |
| 139 | super(); |
| 140 | currentBean = new AngConfig.VmessBean(); |
| 141 | currentBean.setConfigType(V2RayConfig.EConfigType.Vmess); |
| 142 | } |
| 143 | |
| 144 | public VmessSettingsActivity(SharedConfig.VmessProxy proxyInfo) { |
| 145 | super(); |
| 146 | currentProxyInfo = proxyInfo; |
| 147 | currentBean = proxyInfo.bean; |
| 148 | } |
| 149 | |
| 150 | |
| 151 | @Override |
| 152 | public void onResume() { |
| 153 | super.onResume(); |
| 154 | AndroidUtilities.requestAdjustResize(getParentActivity(), classGuid); |
| 155 | } |
| 156 | |
| 157 | @Override |
| 158 | public View createView(Context context) { |
| 159 | actionBar.setTitle(LocaleController.getString("ProxyDetails", R.string.ProxyDetails)); |
| 160 | actionBar.setBackButtonImage(R.drawable.ic_ab_back); |
| 161 | actionBar.setAllowOverlayTitle(false); |
| 162 | if (AndroidUtilities.isTablet()) { |
| 163 | actionBar.setOccupyStatusBar(false); |
| 164 | } |
| 165 | |
| 166 | actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { |
| 167 | @Override |
| 168 | public void onItemClick(int id) { |
| 169 | if (id == -1) { |
| 170 | finishFragment(); |
| 171 | } else if (id == done_button) { |
| 172 | |
| 173 | if (getParentActivity() == null) { |
| 174 | return; |
| 175 | } |
| 176 | |
| 177 | if (StrUtil.isBlank(ipField.getText())) { |
| 178 | |
| 179 | ipField.requestFocus(); |
| 180 | AndroidUtilities.showKeyboard(ipField); |
| 181 | |
| 182 | return; |
| 183 | |
| 184 | } |
| 185 | |
| 186 | if (StrUtil.isBlank(portField.getText())) { |
| 187 | |
| 188 | portField.requestFocus(); |
| 189 | AndroidUtilities.showKeyboard(portField); |
| 190 | |
| 191 | return; |
| 192 | |
| 193 | } |
| 194 | |
| 195 | if (StrUtil.isBlank(userIdField.getText())) { |
| 196 | |
| 197 | userIdField.requestFocus(); |
| 198 | AndroidUtilities.showKeyboard(userIdField); |
| 199 | |
| 200 | return; |
| 201 | |
| 202 | } |
| 203 | |
| 204 | if (StrUtil.isBlank(alterIdField.getText())) { |
| 205 | |
| 206 | alterIdField.requestFocus(); |
| 207 | AndroidUtilities.showKeyboard(alterIdField); |
| 208 | |
| 209 | return; |
| 210 | |
| 211 | } |
| 212 | |
| 213 | currentBean.setAddress(ipField.getText().toString()); |
| 214 | currentBean.setPort(Utilities.parseInt(portField.getText().toString())); |
| 215 | currentBean.setId(userIdField.getText().toString()); |
| 216 | currentBean.setAlterId(Utilities.parseInt(alterIdField.getText().toString())); |
| 217 | currentBean.setSecurity(securityField.getValueTextView().getText().toString()); |
| 218 | currentBean.setNetwork(networkField.getValueTextView().getText().toString()); |
| 219 | currentBean.setHeaderType(headTypeField.getValueTextView().getText().toString()); |
| 220 | currentBean.setRequestHost(requestHostField.getText().toString()); |
| 221 | currentBean.setPath(pathField.getText().toString()); |
| 222 | currentBean.setStreamSecurity(useTlsField.isChecked() ? "tls" : ""); |
| 223 | currentBean.setRemarks(remarksField.getText().toString()); |
| 224 | |
| 225 | if (currentProxyInfo == null) { |
| 226 | currentProxyInfo = new SharedConfig.VmessProxy(currentBean); |
| 227 | SharedConfig.addProxy(currentProxyInfo); |
| 228 | SharedConfig.setCurrentProxy(currentProxyInfo); |
| 229 | } else { |
| 230 | currentProxyInfo.proxyCheckPingId = 0; |
| 231 | currentProxyInfo.availableCheckTime = 0; |
| 232 | currentProxyInfo.ping = 0; |
| 233 | SharedConfig.saveProxyList(); |
| 234 | SharedConfig.setProxyEnable(false); |
| 235 | } |
| 236 | |
| 237 | finishFragment(); |
| 238 | |
| 239 | } |
| 240 | } |
| 241 | }); |
| 242 | |
| 243 | doneItem = actionBar.createMenu().addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56)); |
| 244 | doneItem.setContentDescription(LocaleController.getString("Done", R.string.Done)); |
| 245 | |
| 246 | fragmentView = new FrameLayout(context); |
| 247 | FrameLayout frameLayout = (FrameLayout) fragmentView; |
| 248 | fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray)); |
| 249 | |
| 250 | scrollView = new ScrollView(context); |
| 251 | scrollView.setFillViewport(true); |
| 252 | AndroidUtilities.setScrollViewEdgeEffectColor(scrollView, Theme.getColor(Theme.key_actionBarDefault)); |
| 253 | frameLayout.addView(scrollView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); |
| 254 | |
| 255 | linearLayout2 = new LinearLayout(context); |
| 256 | linearLayout2.setOrientation(LinearLayout.VERTICAL); |
| 257 | scrollView.addView(linearLayout2, new ScrollView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); |
| 258 | |
| 259 | inputFieldsContainer = new LinearLayout(context); |
| 260 | inputFieldsContainer.setOrientation(LinearLayout.VERTICAL); |
| 261 | inputFieldsContainer.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); |
| 262 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { |
| 263 | // bring to front for transitions |
| 264 | inputFieldsContainer.setElevation(AndroidUtilities.dp(1f)); |
| 265 | inputFieldsContainer.setOutlineProvider(null); |
| 266 | } |
| 267 | linearLayout2.addView(inputFieldsContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); |
| 268 | |
| 269 | inputFields = new EditTextBoldCursor[7]; |
| 270 | |
| 271 | for (int a = 0; a < 7; a++) { |
| 272 | FrameLayout container = new FrameLayout(context); |
| 273 | EditTextBoldCursor cursor = mkCursor(); |
| 274 | inputFields[a] = cursor; |
| 275 | cursor.setImeOptions(EditorInfo.IME_ACTION_NEXT | EditorInfo.IME_FLAG_NO_EXTRACT_UI); |
| 276 | switch (a) { |
| 277 | case 0: |
| 278 | ipField = cursor; |
| 279 | cursor.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); |
| 280 | cursor.setHintText(LocaleController.getString("UseProxyAddress", R.string.UseProxyAddress)); |
| 281 | cursor.setText(currentBean.getAddress()); |
| 282 | break; |
| 283 | case 1: |
| 284 | portField = cursor; |
| 285 | cursor.setInputType(InputType.TYPE_CLASS_NUMBER); |
| 286 | cursor.setHintText(LocaleController.getString("UseProxyPort", R.string.UseProxyPort)); |
| 287 | cursor.setText("" + currentBean.getPort()); |
| 288 | break; |
| 289 | case 2: |
| 290 | userIdField = cursor; |
| 291 | cursor.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); |
| 292 | cursor.setHintText(LocaleController.getString("VmessUserId", R.string.VmessUserId)); |
| 293 | cursor.setText(currentBean.getId()); |
| 294 | break; |
| 295 | case 3: |
| 296 | alterIdField = cursor; |
| 297 | cursor.setInputType(InputType.TYPE_CLASS_NUMBER); |
| 298 | cursor.setHintText(LocaleController.getString("VmessAlterId", R.string.VmessAlterId)); |
| 299 | cursor.setText("" + currentBean.getAlterId()); |
| 300 | break; |
| 301 | case 4: |
| 302 | requestHostField = cursor; |
| 303 | cursor.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); |
| 304 | cursor.setHintText(LocaleController.getString("VmessRequestHost", R.string.VmessRequestHost)); |
| 305 | cursor.setText(currentBean.getRequestHost()); |
| 306 | break; |
| 307 | case 5: |
| 308 | pathField = cursor; |
| 309 | cursor.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); |
| 310 | cursor.setHintText(LocaleController.getString("VmessPath", R.string.VmessPath)); |
| 311 | cursor.setText(currentBean.getPath()); |
| 312 | break; |
| 313 | case 6: |
| 314 | remarksField = cursor; |
| 315 | cursor.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); |
| 316 | cursor.setHintText(LocaleController.getString("ProxyRemarks", R.string.ProxyRemarks)); |
| 317 | cursor.setText(currentBean.getRemarks()); |
| 318 | break; |
| 319 | } |
| 320 | cursor.setSelection(cursor.length()); |
| 321 | |
| 322 | cursor.setPadding(0, 0, 0, 0); |
| 323 | container.addView(cursor, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 17, a == 0 ? 12 : 0, 17, 0)); |
| 324 | |
| 325 | } |
| 326 | |
| 327 | inputFieldsContainer.addView((View) ipField.getParent(), LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 64)); |
| 328 | inputFieldsContainer.addView((View) portField.getParent(), LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 64)); |
| 329 | inputFieldsContainer.addView((View) userIdField.getParent(), LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 64)); |
| 330 | inputFieldsContainer.addView((View) alterIdField.getParent(), LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 64)); |
| 331 | |
| 332 | FrameLayout container = new FrameLayout(context); |
| 333 | |
| 334 | securityField = new TextSettingsCell(context); |
| 335 | securityField.setBackground(Theme.getSelectorDrawable(false)); |
| 336 | securityField.setTextAndValue(LocaleController.getString("VmessSecurity", R.string.VmessSecurity), currentBean.getSecurity(), false); |
| 337 | container.addView(securityField, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 0)); |
| 338 | |
| 339 | securityField.setOnClickListener((v) -> { |
| 340 | |
| 341 | PopupBuilder select = new PopupBuilder(v); |
| 342 | |
| 343 | select.setItems(securitySet, (__,value) -> { |
| 344 | |
| 345 | securityField.getValueTextView().setText(value); |
| 346 | |
| 347 | return Unit.INSTANCE; |
| 348 | |
| 349 | }); |
| 350 | |
| 351 | select.show(); |
| 352 | |
| 353 | }); |
| 354 | |
| 355 | inputFieldsContainer.addView(container, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 64)); |
| 356 | |
| 357 | container = new FrameLayout(context); |
| 358 | networkField = new TextSettingsCell(context); |
| 359 | networkField.setBackground(Theme.getSelectorDrawable(false)); |
| 360 | networkField.setTextAndValue(LocaleController.getString("VmessNetwork", R.string.VmessNetwork), currentBean.getNetwork(), false); |
| 361 | container.addView(networkField, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 0)); |
| 362 | |
| 363 | networkField.setOnClickListener((v) -> { |
| 364 | |
| 365 | PopupBuilder select = new PopupBuilder(v); |
| 366 | |
| 367 | select.setItems(networkSet, (__,value) -> { |
| 368 | |
| 369 | networkField.getValueTextView().setText(value); |
| 370 | |
| 371 | return Unit.INSTANCE; |
| 372 | |
| 373 | }); |
| 374 | |
| 375 | select.show(); |
| 376 | |
| 377 | }); |
| 378 | |
| 379 | inputFieldsContainer.addView(container, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 64)); |
| 380 | |
| 381 | container = new FrameLayout(context); |
| 382 | headTypeField = new TextSettingsCell(context); |
| 383 | headTypeField.setBackground(Theme.getSelectorDrawable(false)); |
| 384 | headTypeField.setTextAndValue(LocaleController.getString("VmessHeadType", R.string.VmessHeadType), currentBean.getHeaderType(), false); |
| 385 | container.addView(headTypeField, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 0)); |
| 386 | |
| 387 | headTypeField.setOnClickListener((v) -> { |
| 388 | |
| 389 | PopupBuilder select = new PopupBuilder(v); |
| 390 | |
| 391 | select.setItems(headTypeSet, (__,value) -> { |
| 392 | |
| 393 | headTypeField.getValueTextView().setText(value); |
| 394 | |
| 395 | return Unit.INSTANCE; |
| 396 | |
| 397 | }); |
| 398 | |
| 399 | select.show(); |
| 400 | |
| 401 | }); |
| 402 | |
| 403 | inputFieldsContainer.addView(container, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 64)); |
| 404 | |
| 405 | inputFieldsContainer.addView((View) requestHostField.getParent(), LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 64)); |
| 406 | inputFieldsContainer.addView((View) pathField.getParent(), LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 64)); |
| 407 | |
| 408 | container = new FrameLayout(context); |
| 409 | useTlsField = new TextCheckCell(context); |
| 410 | useTlsField.setBackground(Theme.getSelectorDrawable(false)); |
| 411 | useTlsField.setTextAndCheck(LocaleController.getString("VmessTls", R.string.VmessTls), !StrUtil.isBlank(currentBean.getStreamSecurity()), false); |
| 412 | container.addView(useTlsField, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 0)); |
| 413 | |
| 414 | useTlsField.setOnClickListener((v) -> useTlsField.setChecked(!useTlsField.isChecked())); |
| 415 | |
| 416 | inputFieldsContainer.addView(container, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 64)); |
| 417 | |
| 418 | inputFieldsContainer.addView((View) remarksField.getParent(), LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 64)); |
| 419 | |
| 420 | bottomCell = new TextInfoPrivacyCell(context); |
| 421 | bottomCell.setBackground(Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow)); |
| 422 | bottomCell.setText(LocaleController.getString("ProxyInfoVmess", R.string.ProxyInfoVmess)); |
| 423 | linearLayout2.addView(bottomCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); |
| 424 | |
| 425 | return fragmentView; |
| 426 | |
| 427 | } |
| 428 | |
| 429 | EditTextBoldCursor mkCursor() { |
| 430 | |
| 431 | EditTextBoldCursor cursor = new EditTextBoldCursor(getParentActivity()); |
| 432 | cursor.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); |
| 433 | cursor.setHintColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText)); |
| 434 | cursor.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText)); |
| 435 | cursor.setBackground(null); |
| 436 | cursor.setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText)); |
| 437 | cursor.setCursorSize(AndroidUtilities.dp(20)); |
| 438 | cursor.setCursorWidth(1.5f); |
| 439 | cursor.setSingleLine(true); |
| 440 | cursor.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); |
| 441 | cursor.setHeaderHintColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueHeader)); |
| 442 | cursor.setTransformHintToHeader(true); |
| 443 | cursor.setLineColors(Theme.getColor(Theme.key_windowBackgroundWhiteInputField), Theme.getColor(Theme.key_windowBackgroundWhiteInputFieldActivated), Theme.getColor(Theme.key_windowBackgroundWhiteRedText3)); |
| 444 | return cursor; |
| 445 | |
| 446 | } |
| 447 | |
| 448 | @Override |
| 449 | protected void onTransitionAnimationEnd(boolean isOpen, boolean backward) { |
| 450 | if (isOpen && !backward && currentProxyInfo == null) { |
| 451 | ipField.requestFocus(); |
| 452 | AndroidUtilities.showKeyboard(ipField); |
| 453 | } |
| 454 | } |
| 455 | |
| 456 | @Override |
| 457 | public ArrayList<ThemeDescription> getThemeDescriptions() { |
| 458 | final ThemeDescription.ThemeDescriptionDelegate delegate = () -> { |
| 459 | if (inputFields != null) { |
| 460 | for (int i = 0; i < inputFields.length; i++) { |
| 461 | inputFields[i].setLineColors(Theme.getColor(Theme.key_windowBackgroundWhiteInputField), |
| 462 | Theme.getColor(Theme.key_windowBackgroundWhiteInputFieldActivated), |
| 463 | Theme.getColor(Theme.key_windowBackgroundWhiteRedText3)); |
| 464 | } |
| 465 | } |
| 466 | }; |
| 467 | ArrayList<ThemeDescription> arrayList = new ArrayList<>(); |
| 468 | arrayList.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundGray)); |
| 469 | arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_actionBarDefault)); |
| 470 | arrayList.add(new ThemeDescription(scrollView, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, Theme.key_actionBarDefault)); |
| 471 | arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_actionBarDefaultIcon)); |
| 472 | arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, null, null, Theme.key_actionBarDefaultTitle)); |
| 473 | arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarDefaultSelector)); |
| 474 | arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SEARCH, null, null, null, null, Theme.key_actionBarDefaultSearch)); |
| 475 | arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SEARCHPLACEHOLDER, null, null, null, null, Theme.key_actionBarDefaultSearchPlaceholder)); |
| 476 | arrayList.add(new ThemeDescription(inputFieldsContainer, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite)); |
| 477 | arrayList.add(new ThemeDescription(linearLayout2, 0, new Class[]{View.class}, Theme.dividerPaint, null, null, Theme.key_divider)); |
| 478 | |
| 479 | arrayList.add(new ThemeDescription(null, 0, null, null, null, null, delegate, Theme.key_windowBackgroundWhiteBlueText4)); |
| 480 | arrayList.add(new ThemeDescription(null, 0, null, null, null, null, delegate, Theme.key_windowBackgroundWhiteGrayText2)); |
| 481 | |
| 482 | |
| 483 | if (inputFields != null) { |
| 484 | for (int a = 0; a < inputFields.length; a++) { |
| 485 | arrayList.add(new ThemeDescription(inputFields[a], ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText)); |
| 486 | arrayList.add(new ThemeDescription(inputFields[a], ThemeDescription.FLAG_HINTTEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteHintText)); |
| 487 | arrayList.add(new ThemeDescription(inputFields[a], ThemeDescription.FLAG_HINTTEXTCOLOR | ThemeDescription.FLAG_PROGRESSBAR, null, null, null, null, Theme.key_windowBackgroundWhiteBlueHeader)); |
| 488 | arrayList.add(new ThemeDescription(inputFields[a], ThemeDescription.FLAG_CURSORCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText)); |
| 489 | arrayList.add(new ThemeDescription(null, 0, null, null, null, delegate, Theme.key_windowBackgroundWhiteInputField)); |
| 490 | arrayList.add(new ThemeDescription(null, 0, null, null, null, delegate, Theme.key_windowBackgroundWhiteInputFieldActivated)); |
| 491 | arrayList.add(new ThemeDescription(null, 0, null, null, null, delegate, Theme.key_windowBackgroundWhiteRedText3)); |
| 492 | } |
| 493 | } else { |
| 494 | arrayList.add(new ThemeDescription(null, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText)); |
| 495 | arrayList.add(new ThemeDescription(null, ThemeDescription.FLAG_HINTTEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteHintText)); |
| 496 | } |
| 497 | |
| 498 | arrayList.add(new ThemeDescription(bottomCell, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{TextInfoPrivacyCell.class}, null, null, null, Theme.key_windowBackgroundGrayShadow)); |
| 499 | arrayList.add(new ThemeDescription(bottomCell, 0, new Class[]{TextInfoPrivacyCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText4)); |
| 500 | arrayList.add(new ThemeDescription(bottomCell, ThemeDescription.FLAG_LINKCOLOR, new Class[]{TextInfoPrivacyCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteLinkText)); |
| 501 | |
| 502 | return arrayList; |
| 503 | } |
| 504 | } |
| 505 | |