Browse Source

Version 1.3

*Added an option to add estimated time to the exact time.
Example: "48m ago • 09:41"

*Added an option to add minutes to "Xh ago"
Example: "5h 47m ago"

*You can also combine these two options to get something like this: "5h 47m ago • 09:41"

*Added an icon to the preferences.
beta-future-time
Gil Shahar 7 years ago
parent
commit
41180d2ffc
13 changed files with 314 additions and 10 deletions
  1. +2
    -0
      Makefile
  2. +47
    -9
      Tweak.xm
  3. +1
    -1
      control
  4. +20
    -0
      exacttimeprefs/ExactTimeprefs.mm
  5. +14
    -0
      exacttimeprefs/Makefile
  6. BIN
      exacttimeprefs/Resources/ExactTime@2x.png
  7. +82
    -0
      exacttimeprefs/Resources/ExactTimeprefs.plist
  8. +28
    -0
      exacttimeprefs/Resources/Info.plist
  9. +10
    -0
      exacttimeprefs/entry.plist
  10. BIN
      exacttimeprefs/obj/ExactTimeprefs.bundle/ExactTimeprefs
  11. +82
    -0
      exacttimeprefs/obj/ExactTimeprefs.bundle/ExactTimeprefs.plist
  12. +28
    -0
      exacttimeprefs/obj/ExactTimeprefs.bundle/Info.plist
  13. BIN
      exacttimeprefs/obj/ExactTimeprefs.mm.4bb0a109.o

+ 2
- 0
Makefile View File

@@ -8,3 +8,5 @@ include $(THEOS_MAKE_PATH)/tweak.mk

after-install::
install.exec "killall -9 SpringBoard"
SUBPROJECTS += exacttimeprefs
include $(THEOS_MAKE_PATH)/aggregate.mk

+ 47
- 9
Tweak.xm View File

@@ -8,24 +8,62 @@
@end

static bool is24h;
static NSString *settingsPath = @"/var/mobile/Library/Preferences/com.gilshahar7.exacttimeprefs.plist";


%hook NCLookHeaderContentView
-(void)_updateDateLabelFontForShortLook{
%orig;
NSDate *date = MSHookIvar<NSDate *>(self, "_date");
NSInteger format = MSHookIvar<NSInteger >(self, "_dateFormatStyle");
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:settingsPath];
CGFloat affectTime = [[prefs objectForKey:@"affectTime"] floatValue];
if((date != nil) && (format == 1)){
NCNotificationDateLabel *dateLabel = MSHookIvar<NCNotificationDateLabel *>(self, "_dateLabel");
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
if(is24h)
{
[dateFormatter setDateFormat:@"HH:mm"];
}else{
[dateFormatter setDateFormat:@"h:mm a"];
int timeSinceNow = (int)[date timeIntervalSinceNow];
timeSinceNow = timeSinceNow*-1;
bool addMinutes = [[prefs objectForKey:@"addMinutes"] boolValue];
bool addToCurrent = [[prefs objectForKey:@"addToCurrent"] boolValue];
int hours = timeSinceNow / 3600;
int minutes = (timeSinceNow % 3600) / 60;
if(addMinutes){
if(hours == 0){
if(minutes == 0){
}else{
dateLabel.text = [NSString stringWithFormat:@"%im ago", minutes];
}
}else{
if(minutes == 0){
dateLabel.text = [NSString stringWithFormat:@"%ih ago", hours];
} else{
dateLabel.text = [NSString stringWithFormat:@"%ih %im ago", hours, minutes];
}
}
}else if(addToCurrent){
if(hours == 0){
if(minutes == 0){
}else{
dateLabel.text = [NSString stringWithFormat:@"%im ago", minutes];
}
}else{
dateLabel.text = [NSString stringWithFormat:@"%ih ago", hours];
}
}
if((timeSinceNow/60) >= affectTime){
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
if(is24h){
[dateFormatter setDateFormat:@"HH:mm"];
}else{
[dateFormatter setDateFormat:@"h:mm a"];
}
if(addToCurrent && !([dateLabel.text isEqualToString:[dateFormatter stringFromDate:date]])){
dateLabel.text = [[dateLabel.text stringByAppendingString:@" • "] stringByAppendingString:[dateFormatter stringFromDate:date]];
}else{
dateLabel.text =[dateFormatter stringFromDate:date];
}
[dateLabel sizeToFit];
[dateFormatter release];
}
dateLabel.text = [dateFormatter stringFromDate:date];
[dateLabel sizeToFit];
[dateFormatter release];
}
}
-(void)dateLabelDidChange:(id)arg1{

+ 1
- 1
control View File

@@ -1,7 +1,7 @@
Package: com.gilshahar7.exacttime
Name: ExactTime
Depends: mobilesubstrate
Version: 1.0
Version: 1.3
Architecture: iphoneos-arm
Description: Shows the exact time of a notification.
Maintainer: gilshahar7

+ 20
- 0
exacttimeprefs/ExactTimeprefs.mm View File

@@ -0,0 +1,20 @@
#import <Preferences/Preferences.h>

@interface ExactTimeprefsListController: PSListController {
}
@end

@implementation ExactTimeprefsListController
- (id)specifiers {
if(_specifiers == nil) {
_specifiers = [[self loadSpecifiersFromPlistName:@"ExactTimeprefs" target:self] retain];
}
return _specifiers;
}

-(void)apply{
[self.view endEditing:YES];
}
@end

// vim:ft=objc

+ 14
- 0
exacttimeprefs/Makefile View File

@@ -0,0 +1,14 @@
ARCHS = armv7 arm64
include $(THEOS)/makefiles/common.mk

BUNDLE_NAME = ExactTimeprefs
ExactTimeprefs_FILES = ExactTimeprefs.mm
ExactTimeprefs_INSTALL_PATH = /Library/PreferenceBundles
ExactTimeprefs_FRAMEWORKS = UIKit
ExactTimeprefs_PRIVATE_FRAMEWORKS = Preferences

include $(THEOS_MAKE_PATH)/bundle.mk

internal-stage::
$(ECHO_NOTHING)mkdir -p $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences$(ECHO_END)
$(ECHO_NOTHING)cp entry.plist $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/ExactTimeprefs.plist$(ECHO_END)

BIN
exacttimeprefs/Resources/ExactTime@2x.png View File

Before After
Width: 58  |  Height: 58  |  Size: 1.1KB

+ 82
- 0
exacttimeprefs/Resources/ExactTimeprefs.plist View File

@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>items</key>
<array>
<dict>
<key>cell</key>
<string>PSGroupCell</string>
<key>footerText</key>
<string>Only show the exact time for notifications older than this value (0~240). Default value for stock iOS is 240 minutes (4 hours)</string>
</dict>
<dict>
<key>cell</key>
<string>PSEditTextCell</string>
<key>defaults</key>
<string>com.gilshahar7.exacttimeprefs</string>
<key>key</key>
<string>affectTime</string>
<key>default</key>
<string>10</string>
<key>isNumeric</key>
<true/>
<key>label</key>
<string>Affect after (in minutes)</string>
</dict>
<dict>
<key>cell</key>
<string>PSButtonCell</string>
<key>defaults</key> <string>com.gilshahar7.exacttimeprefs</string>
<key>label</key>
<string>Apply</string>
<key>action</key>
<string>apply</string>
</dict>
<dict>
<key>cell</key>
<string>PSGroupCell</string>
<key>footerText</key>
<string>This will add "Xh ago" where there is an exact time, separated by a ' • ' Note: this will override any language</string>
</dict>
<dict>
<key>cell</key>
<string>PSSwitchCell</string>
<key>default</key>
<false/>
<key>defaults</key>
<string>com.gilshahar7.exacttimeprefs</string>
<key>key</key>
<string>addToCurrent</string>
<key>label</key>
<string>Add estimated time to exact time</string>
</dict>
<dict>
<key>cell</key>
<string>PSGroupCell</string>
<key>footerText</key>
<string>This will add minutes to all "Xh ago" Note: this will override any language</string>
</dict>
<dict>
<key>cell</key>
<string>PSSwitchCell</string>
<key>default</key>
<false/>
<key>defaults</key>
<string>com.gilshahar7.exacttimeprefs</string>
<key>key</key>
<string>addMinutes</string>
<key>label</key>
<string>Change "2h ago" to "2h 17m ago"</string>
</dict>
<dict>
<key>cell</key>
<string>PSGroupCell</string>
<key>footerText</key>
<string>Made by: gilshahar7.</string>
</dict>
</array>
<key>title</key>
<string>ExactTime</string>
</dict>
</plist>

+ 28
- 0
exacttimeprefs/Resources/Info.plist View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>ExactTimeprefs</string>
<key>CFBundleIdentifier</key>
<string>com.gilshahar7.exacttimeprefs</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>DTPlatformName</key>
<string>iphoneos</string>
<key>MinimumOSVersion</key>
<string>3.0</string>
<key>NSPrincipalClass</key>
<string>ExactTimeprefsListController</string>
</dict>
</plist>

+ 10
- 0
exacttimeprefs/entry.plist View File

@@ -0,0 +1,10 @@
{
entry = {
bundle = ExactTimeprefs;
cell = PSLinkCell;
detail = ExactTimeprefsListController;
icon = ExactTime.png;
isController = 1;
label = ExactTime;
};
}

BIN
exacttimeprefs/obj/ExactTimeprefs.bundle/ExactTimeprefs View File


+ 82
- 0
exacttimeprefs/obj/ExactTimeprefs.bundle/ExactTimeprefs.plist View File

@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>items</key>
<array>
<dict>
<key>cell</key>
<string>PSGroupCell</string>
<key>footerText</key>
<string>Only show the exact time for notifications older than this value (0~240). Default value for stock iOS is 240 minutes (4 hours)</string>
</dict>
<dict>
<key>cell</key>
<string>PSEditTextCell</string>
<key>defaults</key>
<string>com.gilshahar7.exacttimeprefs</string>
<key>key</key>
<string>affectTime</string>
<key>default</key>
<string>10</string>
<key>isNumeric</key>
<true/>
<key>label</key>
<string>Affect after (in minutes)</string>
</dict>
<dict>
<key>cell</key>
<string>PSButtonCell</string>
<key>defaults</key> <string>com.gilshahar7.exacttimeprefs</string>
<key>label</key>
<string>Apply</string>
<key>action</key>
<string>apply</string>
</dict>
<dict>
<key>cell</key>
<string>PSGroupCell</string>
<key>footerText</key>
<string>This will add "Xh ago" where there is an exact time, separated by a ' • ' Note: this will override any language</string>
</dict>
<dict>
<key>cell</key>
<string>PSSwitchCell</string>
<key>default</key>
<false/>
<key>defaults</key>
<string>com.gilshahar7.exacttimeprefs</string>
<key>key</key>
<string>addToCurrent</string>
<key>label</key>
<string>Add estimated time to exact time</string>
</dict>
<dict>
<key>cell</key>
<string>PSGroupCell</string>
<key>footerText</key>
<string>This will add minutes to all "Xh ago" Note: this will override any language</string>
</dict>
<dict>
<key>cell</key>
<string>PSSwitchCell</string>
<key>default</key>
<false/>
<key>defaults</key>
<string>com.gilshahar7.exacttimeprefs</string>
<key>key</key>
<string>addMinutes</string>
<key>label</key>
<string>Change "2h ago" to "2h 17m ago"</string>
</dict>
<dict>
<key>cell</key>
<string>PSGroupCell</string>
<key>footerText</key>
<string>Made by: gilshahar7.</string>
</dict>
</array>
<key>title</key>
<string>ExactTime</string>
</dict>
</plist>

+ 28
- 0
exacttimeprefs/obj/ExactTimeprefs.bundle/Info.plist View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>ExactTimeprefs</string>
<key>CFBundleIdentifier</key>
<string>com.gilshahar7.exacttimeprefs</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>DTPlatformName</key>
<string>iphoneos</string>
<key>MinimumOSVersion</key>
<string>3.0</string>
<key>NSPrincipalClass</key>
<string>ExactTimeprefsListController</string>
</dict>
</plist>

BIN
exacttimeprefs/obj/ExactTimeprefs.mm.4bb0a109.o View File


Loading…
Cancel
Save