28 Updates for Patches
[webos-internals:modifications.git] / app-catalog / app-catalog-hide-app-vendors.patch
1 diff --git a/usr/palm/applications/com.palm.app.findapps/app/controllers/app-assistant.js b/usr/palm/applications/com.palm.app.findapps/app/controllers/app-assistant.js
2 index 8115472..26aec73 100644
3 --- a/usr/palm/applications/com.palm.app.findapps/app/controllers/app-assistant.js
4 +++ b/usr/palm/applications/com.palm.app.findapps/app/controllers/app-assistant.js
5 @@ -189,6 +189,10 @@ var DefaultStageAssistant = Class.create(
6                 var self = this;
7                 var menu = new Weave.Utilities.AppMenu()
8                         .addEdit()
9 +                       .addItem($L("Hide App Vendors"),
10 +                                function () {
11 +                                        self.controller.pushScene("hide");
12 +                                })
13                         .addItem($L('Preferences & Accounts'), 
14                                 function()
15                                 {
16 diff --git a/usr/palm/applications/com.palm.app.findapps/app/controllers/hide-assistant.js b/usr/palm/applications/com.palm.app.findapps/app/controllers/hide-assistant.js
17 new file mode 100644
18 index 0000000..0321579
19 --- /dev/null
20 +++ b/usr/palm/applications/com.palm.app.findapps/app/controllers/hide-assistant.js
21 @@ -0,0 +1,46 @@
22 +/*jslint browser: true, eqeqeq: true, undef: true */
23 +/******************************************************************************
24 +Lines above are for jslint, the JavaScript verifier.
25 +http://www.jslint.com/
26 +******************************************************************************/
27 +
28 +var HideAssistant = Class.create({
29 +       setup: function () {
30 +               this._addedPrefs = 
31 +                       this.controller.document.body.hasClassName("prefs") || 
32 +                       this.controller.document.body.addClassName("prefs");
33 +               this.hideListAttributes = {
34 +                       multiline: true,
35 +                       autoFocus: true,
36 +                       changeOnKeyPress: true,
37 +                       textCase: Mojo.Widget.steModeLowerCase
38 +               };
39 +               this.hideListModel = {
40 +                       value: HideList.items.join("\n")
41 +               };
42 +               this.controller.setupWidget("hide-list-text-field",
43 +                                           this.hideListAttributes,
44 +                                           this.hideListModel);
45 +
46 +               this.updateHandler = this.update.bindAsEventListener(this);
47 +               this.controller.listen("hide-list-text-field",
48 +                                      Mojo.Event.propertyChange,
49 +                                      this.updateHandler);
50 +
51 +       },
52 +       update: function () {
53 +               HideList.setFromString(this.hideListModel.value);
54 +       },
55 +       cleanup: function () {
56 +               Mojo.Log.error("CLEANUP");
57 +               this._addedPrefs !== true &&
58 +                       this.controller.document.body.removeClassName("prefs");
59 +               this.controller.stopListening("hide-list-text-field",
60 +                                             Mojo.Event.propertyChange,
61 +                                             this.updateHandler);
62 +       },
63 +       deactivate: function () {
64 +               Mojo.Log.error("DEACTIVATE");
65 +               this.update();
66 +       },
67 +});
68 diff --git a/usr/palm/applications/com.palm.app.findapps/app/controllers/search-assistant.js b/usr/palm/applications/com.palm.app.findapps/app/controllers/search-assistant.js
69 index 41fa796..7bda4d3 100644
70 --- a/usr/palm/applications/com.palm.app.findapps/app/controllers/search-assistant.js
71 +++ b/usr/palm/applications/com.palm.app.findapps/app/controllers/search-assistant.js
72 @@ -29,6 +29,8 @@ var SearchAssistant = Class.create(
73                 this._searchApps = this._searchApps.bindAsEventListener(this);
74                 this._formatAppDivider = this._formatAppDivider.bind(this);
75  
76 +               HideList.updateTests();
77 +
78                 // Set up the attributes & prepare this widget for lazy loading of data
79                 this._searchListAttr =
80                 {
81 @@ -146,6 +148,8 @@ var SearchAssistant = Class.create(
82                 this._appsSearch.button.addEventListener(Mojo.Event.tap, this._searchApps);
83                 // Refocus search field
84                 this._appsSearch.widget.mojo.focus();
85 +
86 +               HideList.updateTests();
87         },
88  
89         deactivate: function() 
90 @@ -296,6 +300,24 @@ var SearchAssistant = Class.create(
91                 model.formattedUpdate = (this._getApplicationInstalledState(model) == 'update' ? 'has-update' : '');
92                 // HACK - author fixup
93                 model.author = (model.author ? model.author : ' ');
94 +
95 +               var id = model.publicApplicationId;
96 +               var author = model.author;
97 +
98 +               model.unwanted = false;
99 +               if (HideList.test(id) || HideList.test(author)) {
100 +                       model.unwanted = true;
101 +               }
102 +               model.unwantedCSSClass = model.unwanted ? 
103 +                       (HideList.turdMode ? "turd" : "unwanted") : "";
104 +               if (model.unwanted) {
105 +                       if (HideList.turdMode) {
106 +                               model.appIcon = "http://webonastick.com/webos/images/turd-48x48.png";
107 +                       }
108 +                       else {
109 +                               model.appIcon = null;
110 +                       }
111 +               }
112         },
113         
114         _formatAppDivider: function(model)
115 diff --git a/usr/palm/applications/com.palm.app.findapps/app/model/hide-list.js b/usr/palm/applications/com.palm.app.findapps/app/model/hide-list.js
116 new file mode 100644
117 index 0000000..ca74a14
118 --- /dev/null
119 +++ b/usr/palm/applications/com.palm.app.findapps/app/model/hide-list.js
120 @@ -0,0 +1,101 @@
121 +/*jslint browser: true, eqeqeq: true, undef: true */
122 +/*global Mojo */
123 +/******************************************************************************
124 +Lines above are for jslint, the JavaScript verifier.
125 +http://www.jslint.com/
126 +******************************************************************************/
127 +
128 +if (!String.prototype.isNotBlank) {
129 +       String.prototype.isNotBlank = function () {
130 +               return (/\S/).test(this);
131 +       };
132 +}
133 +if (!String.prototype.trim) {
134 +       String.prototype.trim = function () {
135 +               return this.replace(/^\s+/, "").replace(/\s+$/, "");
136 +       };
137 +}
138 +if (!String.prototype.normalizeSpace) {
139 +       String.prototype.normalizeSpace = function () {
140 +               return this.trim().replace(/\s+/g, " ");
141 +       };
142 +}
143 +
144 +var HideList = {
145 +       isNotBlank: function (s) {
146 +               return s.isNotBlank();
147 +       },
148 +       normalizeSpace: function (s) {
149 +               return s.normalizeSpace();
150 +       },
151 +       
152 +       initialize: function () {
153 +               this.cookie = new Mojo.Model.Cookie("appCatalogHideList");
154 +               this.items = this.cookie.get() || [];
155 +       },
156 +       update: function () {
157 +               this.cookie.put(this.items);
158 +       },
159 +       setFromString: function (s) {
160 +               this.items = (s.split("\n").
161 +                             filter(this.isNotBlank, this).
162 +                             map(this.normalizeSpace, this));
163 +               this.update();
164 +       },
165 +       updateTests: function () {
166 +               var i;
167 +               this.tests = [];
168 +               this.turdMode = false;
169 +               for (i = 0; i < this.items.length; ++i) {
170 +                       var item = this.items[i];
171 +                       if (item === "*turd*") {
172 +                               this.turdMode = true;
173 +                       }
174 +                       else {
175 +                               this.tests.push(this.stringToTest(item));
176 +                       }
177 +               }
178 +       },
179 +       stringToTest: function (s) {
180 +               var f;
181 +               s = s.trim();
182 +               if (/^\/(.*)\/$/.test(s)) {
183 +                       s = RegExp.$1;
184 +                       var rx = new RegExp(s, 'i');
185 +                       f = function (vendorName) {
186 +                               if (vendorName === undefined ||
187 +                                   vendorName === null) {
188 +                                       return false;
189 +                               }
190 +                               return rx.test(vendorName);
191 +                       };
192 +                       return f;
193 +               }
194 +               else {
195 +                       s = s.normalizeSpace().toLowerCase();
196 +                       f = function (vendorName) {
197 +                               if (vendorName === undefined || 
198 +                                   vendorName === null) {
199 +                                       return false;
200 +                               }
201 +                               return (vendorName.
202 +                                       normalizeSpace().toLowerCase().
203 +                                       indexOf(s) !== -1);
204 +                       };
205 +                       return f;
206 +               }
207 +       },
208 +       test: function (vendorName) {
209 +               var i;
210 +               for (i = 0; i < this.tests.length; ++i) {
211 +                       var test = this.tests[i];
212 +                       if (test && test(vendorName)) {
213 +                               return true;
214 +                       }
215 +               }
216 +               return false;
217 +       }
218 +};
219 +
220 +HideList.initialize();
221 +
222 diff --git a/usr/palm/applications/com.palm.app.findapps/app/views/hide/hide-scene.html b/usr/palm/applications/com.palm.app.findapps/app/views/hide/hide-scene.html
223 new file mode 100644
224 index 0000000..1f12b9f
225 --- /dev/null
226 +++ b/usr/palm/applications/com.palm.app.findapps/app/views/hide/hide-scene.html
227 @@ -0,0 +1,19 @@
228 +<div class="palm-scene hide-scene">
229 +       <div class="palm-page-header multi-line">
230 +               <div class="palm-page-header-wrapper">
231 +                       <div class="title left">Hide App Vendors</div>
232 +               </div>
233 +       </div>
234 +
235 +       <p>Type the partial or complete names of app vendors whose
236 +       applications you do not wish to see, each on a separate line.</p>
237 +
238 +       <p>To use a regular expression, start and end with a slash.</p>
239 +
240 +       <p><b>To effect your changes, you will need to perform a new
241 +       search.</b></p>
242 +
243 +       <div class="hide-list-text-field" id="hide-list-text-field"
244 +                x-mojo-element="TextField"></div>
245 +
246 +</div>
247 diff --git a/usr/palm/applications/com.palm.app.findapps/app/views/search/search-appsummary.html b/usr/palm/applications/com.palm.app.findapps/app/views/search/search-appsummary.html
248 index 07d7a8c..cb73c28 100644
249 --- a/usr/palm/applications/com.palm.app.findapps/app/views/search/search-appsummary.html
250 +++ b/usr/palm/applications/com.palm.app.findapps/app/views/search/search-appsummary.html
251 @@ -1,5 +1,5 @@
252 -<div class="palm-row" x-mojo-tap-highlight='momentary'>
253 -       <div class="palm-row-wrapper padded">
254 +<div class="palm-row #{unwantedCSSClass}" x-mojo-tap-highlight='momentary'>
255 +       <div class="palm-row-wrapper padded #{unwantedCSSClass}">
256                 <div class="icon left search-result-app-icon #{formattedUpdate}">
257                         <div class="loadingicon"></div>
258                         <div class="update-badge"></div>
259 diff --git a/usr/palm/applications/com.palm.app.findapps/index-default.html b/usr/palm/applications/com.palm.app.findapps/index-default.html
260 index a77c2d7..851999e 100644
261 --- a/usr/palm/applications/com.palm.app.findapps/index-default.html
262 +++ b/usr/palm/applications/com.palm.app.findapps/index-default.html
263 @@ -7,6 +7,7 @@
264  <head>
265         <script src="/usr/palm/frameworks/mojo/mojo.js" x-mojo-version="1" xx-mojo-submission="trunk" type="text/javascript"></script>
266         <link href="stylesheets/appcatalog.css" rel="stylesheet" type="text/css" />
267 +       <link href="/media/internal/customizations/com.palm.app.findapps/stylesheets/appcatalog.css" rel="stylesheet" type="text/css" />
268  </head>
269  
270  <body class="wallpaper">
271 diff --git a/usr/palm/applications/com.palm.app.findapps/sources.json b/usr/palm/applications/com.palm.app.findapps/sources.json
272 index 9aad548..4405991 100644
273 --- a/usr/palm/applications/com.palm.app.findapps/sources.json
274 +++ b/usr/palm/applications/com.palm.app.findapps/sources.json
275 @@ -69,6 +69,9 @@
276      "source": "app\/controllers\/change-email-address-assistant.js"
277    },
278    {
279 +    "source": "app\/model\/hide-list.js"
280 +  },
281 +  {
282      "source": "app\/model\/profile-model.js"
283    },
284    {
285 @@ -102,6 +105,10 @@
286         "source": "\/usr\/lib\/luna\/luna-network\/ConnectionWidget.js"
287    },
288        {
289 +    "source": "app\/controllers\/hide-assistant.js",
290 +    "scenes": "hide"
291 +  },
292 +      {
293          "source": "app\/controllers\/prefs-assistant.js",
294          "scenes": "prefs"
295      },
296 diff --git a/usr/palm/applications/com.palm.app.findapps/stylesheets/appcatalog.css b/usr/palm/applications/com.palm.app.findapps/stylesheets/appcatalog.css
297 index 6db1994..65cc955 100644
298 --- a/usr/palm/applications/com.palm.app.findapps/stylesheets/appcatalog.css
299 +++ b/usr/palm/applications/com.palm.app.findapps/stylesheets/appcatalog.css
300 @@ -1579,3 +1579,37 @@ a:hover.table-of-contents {color: #1F00F0;}
301  /*     -webkit-box-sizing: border-box;   */
302  }      
303                         
304 \ No newline at end of file
305 +.palm-row.unwanted .palm-row-wrapper .title {
306 +       color: #447799; /* shade of blue roughly matching the scrim */
307 +}
308 +.palm-row.unwanted .palm-row-wrapper .subtitle {
309 +       color: #447799;
310 +}
311 +.palm-row.unwanted .palm-row-wrapper .search-result-price {
312 +       color: #447799;
313 +}
314 +.palm-row.unwanted .palm-row-wrapper .search-result-rating {
315 +       opacity: 0.5;
316 +}
317 +
318 +.palm-row.turd .palm-row-wrapper .title {
319 +       color: #cc8844; /* shade of brown roughly matching the icon */
320 +}
321 +.palm-row.turd .palm-row-wrapper .subtitle {
322 +       color: #cc8844;
323 +}
324 +.palm-row.turd .palm-row-wrapper .search-result-price {
325 +       color: #cc8844;
326 +}
327 +.palm-row.turd .palm-row-wrapper .search-result-rating {
328 +       opacity: 0.5;
329 +}
330 +
331 +.hide-scene p {
332 +       margin: 0;
333 +       padding: 0.5em 0.5em;
334 +}
335 +.hide-scene .hide-list-text-field {
336 +       background-color: white;
337 +}
338 +