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

Delta Between Two Patch Sets: mobile/android/thirdparty/org/adblockplus/browser/AbpCheckBoxPreference.java

Issue 4920541991403520: Create a minimal settings UI (Closed)
Left Patch Set: Addressed issues Created March 22, 2015, 3:32 p.m.
Right Patch Set: Removed default case Created March 22, 2015, 9:23 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 { 43 {
44 super(context, attrs, defStyle); 44 super(context, attrs, defStyle);
45 } 45 }
46 46
47 @Override 47 @Override
48 protected void onAttachedToActivity() 48 protected void onAttachedToActivity()
49 { 49 {
50 super.onAttachedToActivity(); 50 super.onAttachedToActivity();
51 this.apiKey = this.getKey().substring(this.getKey().lastIndexOf(".api") + 4) ; 51 this.apiKey = this.getKey().substring(this.getKey().lastIndexOf(".api") + 4) ;
52 this.setEnabled(false); 52 this.setEnabled(false);
53 this.recheckValue(); 53 this.refreshValue();
54 } 54 }
55 55
56 private void recheckValue() 56 private void refreshValue()
57 { 57 {
58 AddOnBridge.queryBoolean(this, "get" + this.apiKey); 58 AddOnBridge.queryBoolean(this, this.apiKey);
59 } 59 }
60 60
61 @Override 61 @Override
62 protected void onClick() 62 protected void onClick()
63 { 63 {
64 super.onClick(); 64 super.onClick();
65 AddOnBridge.setBoolean(this, "set" + this.apiKey, this.isChecked()); 65 AddOnBridge.setBoolean(this, this.apiKey, this.isChecked());
66 this.recheckValue(); 66 this.refreshValue();
67 } 67 }
68 68
69 @Override 69 @Override
70 public void onApiRequestSucceeded(NativeJSObject jsObject) 70 public void onApiRequestSucceeded(NativeJSObject jsObject)
71 { 71 {
72 if (jsObject.has("value")) 72 if (jsObject.has("value"))
73 { 73 {
74 final boolean enabled = AddOnBridge.getBooleanFromJSObject(jsObject, "valu e", false); 74 final boolean enabled = AddOnBridge.getBooleanFromJsObject(jsObject, "valu e", false);
75 75
76 ThreadUtils.postToUiThread(new Runnable() 76 ThreadUtils.postToUiThread(new Runnable()
77 { 77 {
78 @Override 78 @Override
79 public void run() 79 public void run()
80 { 80 {
81 AbpCheckBoxPreference.this.setChecked(enabled); 81 AbpCheckBoxPreference.this.setChecked(enabled);
82 AbpCheckBoxPreference.this.setEnabled(true); 82 AbpCheckBoxPreference.this.setEnabled(true);
83 } 83 }
84 }); 84 });
85 } 85 }
86 } 86 }
87 87
88 @Override 88 @Override
89 public void onApiRequestFailed(String errorMessage) 89 public void onApiRequestFailed(String errorMessage)
90 { 90 {
91 // Currently ignored 91 // Currently ignored
92 } 92 }
93 } 93 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld