Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/org/adblockplus/android/Preferences.java

Issue 9643003: Improve manual proxy configuration (Closed)
Patch Set: Addressed review issues Created March 13, 2013, 8:48 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of the Adblock Plus, 2 * This file is part of the Adblock Plus,
3 * Copyright (C) 2006-2012 Eyeo GmbH 3 * Copyright (C) 2006-2012 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 proxyService.setEmptyIcon(hideIcon); 407 proxyService.setEmptyIcon(hideIcon);
408 } 408 }
409 super.onSharedPreferenceChanged(sharedPreferences, key); 409 super.onSharedPreferenceChanged(sharedPreferences, key);
410 } 410 }
411 411
412 private void showConfigurationMsg(String message) 412 private void showConfigurationMsg(String message)
413 { 413 {
414 ViewGroup grp = (ViewGroup) findViewById(R.id.grp_configuration); 414 ViewGroup grp = (ViewGroup) findViewById(R.id.grp_configuration);
415 TextView msg = (TextView) findViewById(R.id.txt_configuration); 415 TextView msg = (TextView) findViewById(R.id.txt_configuration);
416 msg.setText(Html.fromHtml(message)); 416 msg.setText(Html.fromHtml(message));
417 View btn = findViewById(R.id.btn_configuration);
418 btn.setVisibility(ProxyService.NATIVE_PROXY_SUPPORTED ? View.VISIBLE : View. GONE);
419 grp.setVisibility(View.VISIBLE); 417 grp.setVisibility(View.VISIBLE);
420 } 418 }
421 419
422 private void hideConfigurationMsg() 420 private void hideConfigurationMsg()
423 { 421 {
424 ViewGroup grp = (ViewGroup) findViewById(R.id.grp_configuration); 422 ViewGroup grp = (ViewGroup) findViewById(R.id.grp_configuration);
425 grp.setVisibility(View.GONE); 423 grp.setVisibility(View.GONE);
426 } 424 }
427 425
428 private BroadcastReceiver receiver = new BroadcastReceiver() 426 private BroadcastReceiver receiver = new BroadcastReceiver()
429 { 427 {
430 @Override 428 @Override
431 public void onReceive(Context context, Intent intent) 429 public void onReceive(Context context, Intent intent)
432 { 430 {
433 String action = intent.getAction(); 431 String action = intent.getAction();
434 Bundle extra = intent.getExtras(); 432 Bundle extra = intent.getExtras();
435 if (action.equals(ProxyService.BROADCAST_STATE_CHANGED)) 433 if (action.equals(ProxyService.BROADCAST_STATE_CHANGED))
436 { 434 {
437 if (extra.getBoolean("enabled")) 435 if (extra.getBoolean("enabled"))
438 { 436 {
439 // Service is enabled in manual mode 437 // Service is enabled in manual mode
440 if (extra.getBoolean("manual")) 438 if (extra.getBoolean("manual"))
441 { 439 {
442 // Proxy is properly configured 440 // Proxy is properly configured
443 if (extra.getBoolean("configured")) 441 if (extra.getBoolean("configured"))
444 hideConfigurationMsg(); 442 hideConfigurationMsg();
445 else 443 else
446 showConfigurationMsg(getString(R.string.msg_configuration, extra.g etInt("port"))); 444 showConfigurationMsg(getString(R.string.msg_configuration));
447 } 445 }
448 } 446 }
449 else 447 else
450 { 448 {
451 setFilteringEnabled(false); 449 setFilteringEnabled(false);
452 hideConfigurationMsg(); 450 hideConfigurationMsg();
453 } 451 }
454 } 452 }
455 if (action.equals(ProxyService.BROADCAST_PROXY_FAILED)) 453 if (action.equals(ProxyService.BROADCAST_PROXY_FAILED))
456 { 454 {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 } 527 }
530 528
531 private ServiceConnection proxyServiceConnection = new ServiceConnection() 529 private ServiceConnection proxyServiceConnection = new ServiceConnection()
532 { 530 {
533 public void onServiceConnected(ComponentName className, IBinder service) 531 public void onServiceConnected(ComponentName className, IBinder service)
534 { 532 {
535 proxyService = ((ProxyService.LocalBinder) service).getService(); 533 proxyService = ((ProxyService.LocalBinder) service).getService();
536 Log.d(TAG, "Proxy service connected"); 534 Log.d(TAG, "Proxy service connected");
537 535
538 if (proxyService.isManual() && proxyService.noTraffic()) 536 if (proxyService.isManual() && proxyService.noTraffic())
539 showConfigurationMsg(getString(R.string.msg_configuration, proxyService. port)); 537 showConfigurationMsg(getString(R.string.msg_configuration));
540 } 538 }
541 539
542 public void onServiceDisconnected(ComponentName className) 540 public void onServiceDisconnected(ComponentName className)
543 { 541 {
544 proxyService = null; 542 proxyService = null;
545 Log.d(TAG, "Proxy service disconnected"); 543 Log.d(TAG, "Proxy service disconnected");
546 } 544 }
547 }; 545 };
548 } 546 }
OLDNEW
« no previous file with comments | « src/org/adblockplus/android/ConfigurationActivity.java ('k') | src/org/adblockplus/android/ProxyConfigurationActivity.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld