FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
FilteredAppListTableView/PSFilteredAppListListController.m at master · devbug/FilteredAppListTableView · GitHub
devbug
FilteredAppListTableView
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
FilteredAppListTableView
/
PSFilteredAppListListController.m
Copy path
More file actions
More file actions
Latest commit
History
History
History
407 lines (326 loc) · 13.2 KB
Breadcrumbs
FilteredAppListTableView
/
PSFilteredAppListListController.m
Copy path
File metadata and controls
407 lines (326 loc) · 13.2 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
//
//
PSFilteredAppListListController.m
//
//
//
Copyright (c) 2014 deVbug
//
//
Permission is hereby granted, free of charge, to any person obtaining a copy
//
of this software and associated documentation files (the "Software"), to deal
//
in the Software without restriction, including without limitation the rights
//
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//
copies of the Software, and to permit persons to whom the Software is
//
furnished to do so, subject to the following conditions:
//
//
The above copyright notice and this permission notice shall be included in
//
all copies or substantial portions of the Software.
//
//
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//
THE SOFTWARE.
//
#
import
"
Preferences.h
"
#
import
"
PSFilteredAppListListController.h
"
#
import
"
_UIBackdropView.h
"
#
import
<
dlfcn.h
>
#
import
<
objc/runtime.h
>
@interface
UITableViewHeaderFooterView
(private_api)
@property
(
retain
,
nonatomic
) UIImage *backgroundImage;
@end
/*
*
* Backgrounder
*
* Copyright (C) 2008-2010 Lance Fetters (aka. ashikase)
* All rights reserved.
*
* edited by deVbug
*/
//
{{{
extern
NSArray
*
SBSCopyApplicationDisplayIdentifiers
(
BOOL
activeOnly,
BOOL
unknown);
extern
NSString
*
SBSCopyLocalizedApplicationNameForDisplayIdentifier
(
NSString
*identifier);
static
CFSetRef
(*pSBSCopyDisplayIdentifiers)() = NULL;
extern
NSString
*
SBSCopyBundlePathForDisplayIdentifier
(
NSString
*identifier);
NSInteger
compareDisplayNames
(
NSString
*a,
NSString
*b,
void
*context) {
NSInteger
ret;
NSString
*name_a =
SBSCopyLocalizedApplicationNameForDisplayIdentifier
(a);
NSString
*name_b =
SBSCopyLocalizedApplicationNameForDisplayIdentifier
(b);
ret = [name_a
caseInsensitiveCompare:
name_b];
[name_a
release
];
[name_b
release
];
return
ret;
}
NSArray
*
applicationDisplayIdentifiersForType
(FilteredAppType type) {
if
(pSBSCopyDisplayIdentifiers ==
NULL
)
pSBSCopyDisplayIdentifiers =
dlsym
(
RTLD_DEFAULT
,
"
SBSCopyDisplayIdentifiers
"
);
//
Get list of non-hidden applications
NSArray
*nonhidden = (pSBSCopyDisplayIdentifiers !=
NULL
? (
NSArray
*)(*pSBSCopyDisplayIdentifiers)() :
SBSCopyApplicationDisplayIdentifiers
(
NO
,
NO
));
//
Get list of hidden applications (assuming LibHide is installed)
NSArray
*hidden =
nil
;
NSString
*filePath = [
NSHomeDirectory
()
stringByAppendingPathComponent:
@"
Library/LibHide/hidden.plist
"
];
id
value = [[
NSDictionary
dictionaryWithContentsOfFile:
filePath]
objectForKey:
@"
Hidden
"
];
if
([value
isKindOfClass:
[
NSArray
class
]])
hidden = (
NSArray
*)value;
//
Record list of valid identifiers
NSMutableArray
*identifiers = [
NSMutableArray
array
];
for
(
NSArray
*array in [
NSArray
arrayWithObjects:
nonhidden, hidden,
nil
]) {
for
(
NSString
*identifier in array) {
FilteredAppType isType = FilteredAppUsers;
if
([identifier
hasPrefix:
@"
com.apple.webapp
"
])
isType = FilteredAppWebapp;
else
{
NSString
*path =
SBSCopyBundlePathForDisplayIdentifier
(identifier);
if
([path
hasPrefix:
@"
/Applications/
"
])
isType = FilteredAppSystem;
[path
release
];
}
if
((isType & type) ==
0
)
continue
;
//
Filter out non-apps and apps that are not executed directly
//
FIXME: Should Categories folders be in this list? Categories
//
folders are apps, but when used with CategoriesSB they are
//
non-apps.
if
(identifier
&& ![identifier
hasPrefix:
@"
jp.ashikase.springjumps.
"
])
//
&& ![identifier isEqualToString:@"com.iptm.bigboss.sbsettings"]
//
&& ![identifier isEqualToString:@"com.apple.webapp"])
[identifiers
addObject:
identifier];
}
}
//
Clean-up
[nonhidden
release
];
return
identifiers;
}
//
}}}
NSArray
*
applicationDisplayIdentifiers
() {
return
applicationDisplayIdentifiersForType
(FilteredAppAll);
}
@interface
PSFilteredAppListTableView
:
UITableView
@end
@implementation
PSFilteredAppListTableView
- (
id
)
initWithFrame
:
(CGRect)
frame
style
:
(UITableViewStyle)
style
{
self = [
super
initWithFrame:
frame
style:
UITableViewStylePlain];
return
self;
}
@end
@interface
PSFilteredAppListListController
()
@property
(
nonatomic
,
retain
)
NSMutableArray
*indexes;
@property
(
nonatomic
)
BOOL
isNeedsToReload;
@property
(
nonatomic
,
copy
)
NSString
*_title;
@end
@implementation
PSFilteredAppListListController
- (
void
)
setDefaultTextColor
{
self.
noneTextColor
= [UIColor
blackColor
];
self.
normalTextColor
= [UIColor
colorWithRed:
81
/
255.0
green:
102
/
255.0
blue:
145
/
255.0
alpha:
1
];
self.
forceTextColor
= [UIColor
colorWithRed:
181
/
255.0
green:
181
/
255.0
blue:
181
/
255.0
alpha:
1
];
}
- (
void
)
setTextColors
:
(UIColor *)
noneColor
normalTextColor
:
(UIColor *)
normalColor
forceTextColor
:
(UIColor *)
forceColor
{
self.
noneTextColor
= noneColor;
self.
normalTextColor
= normalColor;
self.
forceTextColor
= forceColor;
}
- (
void
)
dealloc
{
self.
noneTextColor
=
nil
;
self.
normalTextColor
=
nil
;
self.
forceTextColor
=
nil
;
self.
indexes
=
nil
;
self.
_title
=
nil
;
[
super
dealloc
];
}
- (
void
)
setNeedsToReload
{
_isNeedsToReload =
YES
;
}
- (
void
)
viewWillAppear
:
(
BOOL
)
animated
{
[
super
viewWillAppear:
animated];
if
(_isNeedsToReload) {
self.
specifiers
= [[
self
newAppSpecifiers
]
autorelease
];
_isNeedsToReload =
NO
;
}
}
- (
BOOL
)
edgeToEdgeCells
{
return
YES
;
}
- (
void
)
setTitle
:
(
NSString
*)
title
{
[
super
setTitle:
title];
if
(title)
self.
_title
= title;
}
- (
Class
)
tableViewClass
{
return
[PSFilteredAppListTableView
class
];
}
- (
NSMutableArray
*)
newAppSpecifiers
{
@autoreleasepool{
NSMutableArray
*__specifiers = [[
NSMutableArray
alloc
]
init
];
[_indexes
release
], _indexes =
nil
;
_indexes = [[
NSMutableArray
alloc
]
init
];
NSSet
*set = [
NSSet
setWithArray:
applicationDisplayIdentifiersForType
(_filteredAppType)];
NSArray
*sortedArray = [[set
allObjects
]
sortedArrayUsingFunction:
compareDisplayNames
context:
NULL
];
/*
*
* 0x3131 = 'ㄱ' 0x1100 = 'ᄀ'
* 0x3132 = 'ㄲ' 0x1101 = 'ᄁ'
* 0x3134 = 'ㄴ' 0x1102 = 'ᄂ'
* 0x3137 = 'ㄷ' 0x1103 = 'ᄃ'
* 0x3138 = 'ㄸ' 0x1104 = 'ᄄ'
* 0x3139 = 'ㄹ' 0x1105 = 'ᄅ'
* 0x3141 = 'ㅁ' 0x1106 = 'ᄆ'
* 0x3142 = 'ㅂ' 0x1107 = 'ᄇ'
* 0x3143 = 'ㅃ' 0x1108 = 'ᄈ'
* 0x3145 = 'ㅅ' 0x1109 = 'ᄉ'
* 0x3146 = 'ㅆ' 0x110A = 'ᄊ'
* 0x3147 = 'ㅇ' 0x110B = 'ᄋ'
* 0x3148 = 'ㅈ' 0x110C = 'ᄌ'
* 0x3149 = 'ㅉ' 0x110D = 'ᄍ'
* 0x314A = 'ㅊ' 0x110E = 'ᄎ'
* 0x314B = 'ㅋ' 0x110F = 'ᄏ'
* 0x314C = 'ㅌ' 0x1110 = 'ᄐ'
* 0x314D = 'ㅍ' 0x1111 = 'ᄑ'
* 0x314E = 'ㅎ' 0x1112 = 'ᄒ'
*
* 0x3131 : ㄱㄲㄴㄷㄸㄹㅁㅂㅃㅅㅆㅇㅈㅉㅊㅋㅌㅍㅎ
* 0x1100 : ᄀᄁᄂᄃᄄᄅᄆᄇᄈᄉᄊᄋᄌᄍᄎᄏᄐᄑᄒ
*
*/
//
http://pastebin.com/7YkT4dbk
//
한글 로마자 변환 프로그램 by 동성
NSString
*choCharset =
@"
ᄀᄁᄂᄃᄄᄅᄆᄇᄈᄉᄊᄋᄌᄍᄎᄏᄐᄑᄒ
"
;
unichar
header =
'
'
, temp;
for
(
NSString
*displayId in sortedArray) {
if
([_delegate
respondsToSelector:
@selector
(
isOtherFilteredForIdentifier:
)])
if
([_delegate
isOtherFilteredForIdentifier:
displayId])
continue
;
NSString
*name =
SBSCopyLocalizedApplicationNameForDisplayIdentifier
(displayId);
if
(name && name.
length
>
0
&&
strlen
([name
UTF8String
]) >
0
) {
@try
{
temp = [[name
uppercaseString
]
characterAtIndex:
0
];
[name
release
];
if
(
0xAC00
<= temp && temp <=
0xD7AF
) {
unsigned
int
choSung = (temp -
0xAC00
) / (
21
*
28
);
temp = [[choCharset
substringWithRange:
NSMakeRange
(choSung,
1
)]
characterAtIndex:
0
];
}
if
(header != temp) {
header = temp;
NSString
*index = [
NSString
stringWithCharacters:
&header
length:
1
];
[_indexes
addObject:
index];
[__specifiers
addObject:
[PSSpecifier
groupSpecifierWithName:
index]];
}
}
@catch
(
NSException
*e) {
//
}
@finally
{
//
}
}
if
([_indexes
count
] >
0
) {
[__specifiers
addObject:
[
self
getSpecifierForDisplayIdentifier:
displayId]];
}
}
return
__specifiers;
}
}
- (PSSpecifier *)
getSpecifierForDisplayIdentifier
:
(
NSString
*)
displayId
{
NSString
*name =
SBSCopyLocalizedApplicationNameForDisplayIdentifier
(displayId);
PSSpecifier *specifier = [PSSpecifier
preferenceSpecifierNamed:
(name && name.length !=
0
? name : displayId)
target:
self
set:
nil
get:
nil
detail:
Nil
cell:
PSButtonCell
edit:
nil
];
[specifier
setProperty:
[PSFilteredAppListCell
class
]
forKey:
PSCellClassKey];
[specifier
setProperty:
@(
YES
)
forKey:
PSLazyIconLoading];
[specifier
setProperty:
displayId
forKey:
PSLazyIconAppID];
[specifier
setProperty:
@(
YES
)
forKey:
PSLazyIconDontUnload];
[specifier
setProperty:
@(
YES
)
forKey:
@"
enabled
"
];
[specifier
setProperty:
@(
1
)
forKey:
PSAlignmentKey];
specifier.
buttonAction
=
@selector
(
selectAppItem:
);
[specifier
setProperty:
displayId
forKey:
@"
displayIdentifier
"
];
[specifier
setProperty:
@(_enableForceType)
forKey:
@"
enableForceType
"
];
[specifier
setProperty:
_noneTextColor
forKey:
@"
noneTextColor
"
];
[specifier
setProperty:
_normalTextColor
forKey:
@"
normalTextColor
"
];
[specifier
setProperty:
_forceTextColor
forKey:
@"
forceTextColor
"
];
FilteredListType filteredListType = FilteredListNone;
if
(_delegate) {
filteredListType = [_delegate
filteredListTypeForIdentifier:
displayId];
}
else
if
([
self
.specifier
propertyForKey:
@"
key
"
] && [
self
.specifier
propertyForKey:
@"
defaults
"
]) {
NSArray
*data = [PSRootController
readPreferenceValue:
self
.specifier];
if
([data
containsObject:
displayId])
filteredListType = FilteredListNormal;
}
[specifier
setProperty:
@(filteredListType)
forKey:
@"
filteredListType
"
];
return
specifier;
}
- (
id
)
specifiers
{
if
(!_specifiers) {
NSNumber
*n = [
self
.specifier
propertyForKey:
@"
enableForceType
"
];
if
(n) {
_enableForceType = [n
boolValue
];
}
n = [
self
.specifier
propertyForKey:
@"
filteredAppType
"
];
if
(n) {
_filteredAppType = [n
intValue
];
}
if
(_noneTextColor ==
nil
|| _normalTextColor ==
nil
|| _forceTextColor ==
nil
)
[
self
setDefaultTextColor
];
_specifiers = [
self
newAppSpecifiers
];
n = [
self
.specifier
propertyForKey:
@"
isPopover
"
];
if
(n) {
_isPopover = [n
boolValue
];
}
if
(_isPopover) {
self.
navigationItem
.
rightBarButtonItem
= [[[UIBarButtonItem
alloc
]
initWithBarButtonSystemItem:
UIBarButtonSystemItemCancel
target:
_delegate
action:
@selector
(
closeAppListView
)]
autorelease
];
self.
navigationItem
.
title
= self.
title
?: self.
_title
;
}
}
return
_specifiers;
}
- (
NSArray
*)
sectionIndexTitlesForTableView
:
(UITableView *)
tableView
{
return
_indexes;
}
- (
NSInteger
)
tableView
:
(UITableView *)
tableView
sectionForSectionIndexTitle
:
(
NSString
*)
title
atIndex
:
(
NSInteger
)
index
{
return
index;
}
- (
void
)
tableView
:
(UITableView *)
tableView
willDisplayHeaderView
:
(UIView *)
view
forSection
:
(
NSInteger
)
section
{
Class
UIBackdropView =
objc_getClass
(
"
_UIBackdropView
"
);
Class
HeaderFooterView =
objc_getClass
(
"
UITableViewHeaderFooterView
"
);
if
(HeaderFooterView !=
Nil
&& [view
isKindOfClass:
HeaderFooterView] && UIBackdropView !=
Nil
) {
UITableViewHeaderFooterView *tableViewHeaderFooterView = (UITableViewHeaderFooterView *)view;
if
(![tableViewHeaderFooterView.backgroundView
isKindOfClass:
UIBackdropView]) {
tableViewHeaderFooterView.
contentView
.
backgroundColor
= [UIColor
clearColor
];
tableViewHeaderFooterView.
tintColor
=
nil
;
if
([tableViewHeaderFooterView
respondsToSelector:
@selector
(
setBackgroundImage:
)])
tableViewHeaderFooterView.
backgroundImage
=
nil
;
_UIBackdropViewSettings *settings = [
objc_getClass
(
"
_UIBackdropViewSettings
"
)
settingsForStyle:
2070
];
settings.
grayscaleTintAlpha
=
0
.
0f
;
_UIBackdropView *backdropView = [[UIBackdropView
alloc
]
initWithSettings:
settings];
backdropView.
appliesOutputSettingsAnimationDuration
=
0
.
0f
;
backdropView.
computesColorSettings
=
NO
;
backdropView.
simulatesMasks
=
YES
;
tableViewHeaderFooterView.
backgroundView
= backdropView;
[backdropView
release
];
}
}
}
- (
void
)
selectAppItem
:
(PSSpecifier *)
specifier
{
NSIndexPath
*indexPath = [
self
indexPathForSpecifier:
specifier];
PSFilteredAppListCell *cell = (PSFilteredAppListCell *)[
self
.table
cellForRowAtIndexPath:
indexPath];
[cell
toggle
];
[
self
.table
deselectRowAtIndexPath:
indexPath
animated:
YES
];
if
(_enableForceType ==
NO
&& cell.
filteredListType
== FilteredListForce)
return
;
if
(_delegate) {
[_delegate
didSelectRowAtCell:
cell];
}
else
if
([
self
.specifier
propertyForKey:
@"
key
"
] && [
self
.specifier
propertyForKey:
@"
defaults
"
]) {
NSArray
*data = [PSRootController
readPreferenceValue:
self
.specifier];
NSMutableArray
*datas = [
NSMutableArray
arrayWithArray:
data];
if
(cell.
filteredListType
== FilteredListNone) {
[datas
removeObject:
cell.displayId];
}
else
if
(cell.
filteredListType
== FilteredListNormal) {
[datas
addObject:
cell.displayId];
}
[PSRootController
setPreferenceValue:
datas
specifier:
self
.specifier];
}
}
@end
Back
|
FazBrowse Home
|
New Git URL