Report abuse

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
#import <CoreFoundation/CoreFoundation.h>
#import <Foundation/Foundation.h>
#import <UIKit/CDStructures.h>
#import <UIKit/UIPushButton.h>
#import <UIKit/UIThreePartButton.h>
#import <UIKit/UINavigationBar.h>
#import <UIKit/UIWindow.h>
#import <UIKit/UIView-Hierarchy.h>
#import <UIKit/UIHardware.h>
#import <UIKit/UITable.h>
#import <UIKit/UITableCell.h>
#import <UIKit/UITableColumn.h>
#import <UIKit/UITextView.h>
#import <UIKit/UISegmentedControl.h>
#import "HelloApplication.h"


@implementation HelloApplication

- (BOOL)respondsToSelector:(SEL)selector {
  NSLog(@"respondsToSelector: %s", selector);
  return [super respondsToSelector:selector];
}

- (int) numberOfRowsInTable: (UITable *)table
{
    return [fileArray count];
}

- (UITableCell *) table: (UITable *)table cellForRow: (int)row column: (int)col
{
    return [fileArray objectAtIndex: row]; 
}

- (UITableCell *) table: (UITable *)table cellForRow: (int)row column: (int)col
    reusing: (BOOL) reusing
{
    return pbCell; 
}

- (void) segmentedControl: (UISegmentedControl *)segment selectedSegmentChanged: (int)seg
{
    NSLog(@"Selected segement: %i", seg);
}

- (void) applicationDidFinishLaunching: (id) unused
{
    
    NSString *imagePath = @"/var/root/Media/DCIM/100APPLE/";
    NSArray *myPhotos = [[NSFileManager defaultManager]directoryContentsAtPath: imagePath];
    
    UIWindow *window;

    window = [[UIWindow alloc] initWithContentRect: [UIHardware fullScreenApplicationContentRect]];
   
    struct CGRect rect = [UIHardware fullScreenApplicationContentRect];
    rect.origin.x = rect.origin.y = 0.0f;

    UIView *mainView;
    mainView = [[UIView alloc] initWithFrame: rect];

    // UIImage *fun = [[UIImage alloc]initWithContentsOfFile:@"/var/root/Media/DCIM/100APPLE/IMG_0063.JPG"];
    // UIImageView *funView = [[UIImageView alloc] initWithFrame: rect];
    // [funView setImage:fun];
    // [funView setAlpha:1.0];
    
    float segWidth = 200.0f;
    
    UISegmentedControl *modeSwitch = [[UISegmentedControl alloc] initWithFrame:CGRectMake(320.0f / 2.0f - (segWidth / 2.0f), 6.0f, segWidth, 30.0f) withStyle:2 withItems:nil];
    [modeSwitch insertSegment:0 withTitle:@"Mine" animated:NO];
    [modeSwitch insertSegment:1 withTitle:@"Flickr" animated:NO];
    [modeSwitch insertSegment:2 withTitle:@"Popular" animated:NO];
    // [modeSwitch insertSegment:0 withTitle:@"Install" animated:NO];
    // [modeSwitch insertSegment:1 withTitle:@"Update" animated:NO];
    // [modeSwitch insertSegment:2 withTitle:@"Uninstall" animated:NO];
    // [modeSwitch insertSegment:3 withTitle:@"Sources" animated:NO];
    [modeSwitch selectSegment:0];
    [modeSwitch setDelegate:self];

    UINavigationBar *bar = [[UINavigationBar alloc]initWithFrame: CGRectMake(0.0f, 0.0f, 320.0f, 43.0f)];

    UITextView *textView = [[UITextView alloc]initWithFrame: CGRectMake(0.0f, 0.0f, 320.0f, 480.0f)];
    [textView setEditable:YES];
    [textView setTextSize:14];
    
    NSEnumerator *enumerator = [myPhotos objectEnumerator];
    id anObject;
    NSDictionary *file;

    while (anObject = [enumerator nextObject]) {

        NSRange match = [anObject rangeOfString:@"IMG_0063"];
        int length = match.length;
        if (length > 0) {
            NSLog(@"Yes");
        }
        else {
            NSLog(@"NO");
        }
        NSString *filePath = [NSString localizedStringWithFormat:@"%@%@", imagePath, anObject];
        file = [[NSFileManager defaultManager] fileAttributesAtPath: filePath traverseLink:NO];
        
        NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys:
            anObject, @"name",
            [file objectForKey:@"NSFileModificationDate"], @"date",
            nil];
        NSLog(@"object: %@", dict);

    }

    pbCell = [[UIImageAndTextTableCell alloc] init];
    [pbCell setTitle: @"Hello world!\n"]; 
    [pbCell setImage: [[UIImage alloc] initWithContentsOfFile:@"/var/root/Media/DCIM/100APPLE/IMG_0063.THM"]];

    // UIPushButton *button = [[UIThreePartButton alloc] initWithTitle:
    //     @"Touch Me"];
    // buttonCell = [[UITableCell alloc] init];
    // [buttonCell addSubview: button];
    // [button sizeToFit];


    UITable *table = [[UITable alloc] initWithFrame: CGRectMake(0.0f, 48.0f, 320.0f, 480.0f - 16.0f - 32.0f)];
    UITableColumn *col = [[UITableColumn alloc] initWithTitle: @"HelloApp" identifier: @"hello" width: 320.0f];

    [table addTableColumn: col]; 
    [table setDataSource: self];
    [table setDelegate: self];
    [table reloadData];


    [window orderFront: self];
    [window makeKey: self];
    [window _setHidden: NO];
     
    [window setContentView: mainView];
    
    [mainView addSubview: textView];

    [mainView addSubview: table];
    [mainView addSubview: bar];
    [mainView addSubview: modeSwitch];
    
}

@end