shortlook 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 73ed8434d41927c2c24e3d914298af64a703b52a81acdd32a5bf02cb8b79a072
4
+ data.tar.gz: f408e42cb918044cc2edaa344e25addb577a9913fd0fa9b583f523159ad85b78
5
+ SHA512:
6
+ metadata.gz: c315d22416984e87439871431a76b808f1e6698dc979cb67740dbbb9c59aac9eeeeb3ad2d9c3bc764b004c38b162bc7998c0b0983792dfa41a9dd7867840b138
7
+ data.tar.gz: 7b8290763c14a16c8f47f90fc81bf6a7c2b81f53a97ae522cab12340f94f7e580550c89122774ba28fc3c35c56ba60c9c71e920f7c3d8400ed86dcdeb35fb80c
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ ShortLook-*/
10
+ .DS_Store
11
+ .rspec_status
12
+ config.yml
13
+ *.cast
14
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,16 @@
1
+ AllCops:
2
+ Exclude:
3
+ - bin/*
4
+ - spec/**/*
5
+
6
+ Metrics/MethodLength:
7
+ Max: 45
8
+
9
+ Metrics/AbcSize:
10
+ Max: 45
11
+
12
+ Metrics/LineLength:
13
+ Max: 200
14
+
15
+ Style/Documentation:
16
+ Enabled: false
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,92 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ shortlook (0.1.0)
5
+ lhc (~> 10.3)
6
+ pastel (~> 0.7.2)
7
+ thor (~> 0.20.0)
8
+ tty-command (~> 0.8.0)
9
+ tty-config (~> 0.3.0)
10
+ tty-prompt (~> 0.18.0)
11
+ tty-spinner (~> 0.9.0)
12
+
13
+ GEM
14
+ remote: https://rubygems.org/
15
+ specs:
16
+ activesupport (5.2.3)
17
+ concurrent-ruby (~> 1.0, >= 1.0.2)
18
+ i18n (>= 0.7, < 2)
19
+ minitest (~> 5.1)
20
+ tzinfo (~> 1.1)
21
+ addressable (2.6.0)
22
+ public_suffix (>= 2.0.2, < 4.0)
23
+ concurrent-ruby (1.1.5)
24
+ diff-lcs (1.3)
25
+ equatable (0.5.0)
26
+ ethon (0.12.0)
27
+ ffi (>= 1.3.0)
28
+ ffi (1.11.0)
29
+ i18n (1.6.0)
30
+ concurrent-ruby (~> 1.0)
31
+ lhc (10.3.0)
32
+ activesupport (>= 4.2)
33
+ addressable
34
+ typhoeus (>= 0.11)
35
+ minitest (5.11.3)
36
+ necromancer (0.4.0)
37
+ pastel (0.7.2)
38
+ equatable (~> 0.5.0)
39
+ tty-color (~> 0.4.0)
40
+ public_suffix (3.0.3)
41
+ rake (10.5.0)
42
+ rspec (3.7.0)
43
+ rspec-core (~> 3.7.0)
44
+ rspec-expectations (~> 3.7.0)
45
+ rspec-mocks (~> 3.7.0)
46
+ rspec-core (3.7.1)
47
+ rspec-support (~> 3.7.0)
48
+ rspec-expectations (3.7.0)
49
+ diff-lcs (>= 1.2.0, < 2.0)
50
+ rspec-support (~> 3.7.0)
51
+ rspec-mocks (3.7.0)
52
+ diff-lcs (>= 1.2.0, < 2.0)
53
+ rspec-support (~> 3.7.0)
54
+ rspec-support (3.7.1)
55
+ thor (0.20.3)
56
+ thread_safe (0.3.6)
57
+ timers (4.3.0)
58
+ tty-color (0.4.3)
59
+ tty-command (0.8.2)
60
+ pastel (~> 0.7.0)
61
+ tty-config (0.3.1)
62
+ tty-cursor (0.6.1)
63
+ tty-prompt (0.18.1)
64
+ necromancer (~> 0.4.0)
65
+ pastel (~> 0.7.0)
66
+ timers (~> 4.0)
67
+ tty-cursor (~> 0.6.0)
68
+ tty-reader (~> 0.5.0)
69
+ tty-reader (0.5.0)
70
+ tty-cursor (~> 0.6.0)
71
+ tty-screen (~> 0.6.4)
72
+ wisper (~> 2.0.0)
73
+ tty-screen (0.6.5)
74
+ tty-spinner (0.9.0)
75
+ tty-cursor (~> 0.6.0)
76
+ typhoeus (1.3.1)
77
+ ethon (>= 0.9.0)
78
+ tzinfo (1.2.5)
79
+ thread_safe (~> 0.1)
80
+ wisper (2.0.0)
81
+
82
+ PLATFORMS
83
+ ruby
84
+
85
+ DEPENDENCIES
86
+ bundler (~> 2.0)
87
+ rake (~> 10.0)
88
+ rspec (~> 3.0)
89
+ shortlook!
90
+
91
+ BUNDLED WITH
92
+ 2.0.1
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Marco Roth
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,85 @@
1
+ # Shortlook CLI
2
+
3
+ This is a CLI for scaffolding a ShortLook Provider
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'shortlook'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install shortlook
20
+
21
+ ## Usage
22
+
23
+ The usage of the generator is pretty straight forward:
24
+
25
+ ```bash
26
+ $ shortlook
27
+
28
+ Commands:
29
+ shortlook help [COMMAND] # Describe available commands or one specific command
30
+ shortlook provider NAME # Generate a scaffold ShortLook Provider
31
+ shortlook version # shortlook version
32
+ ```
33
+
34
+ To start the Provider generator use the `provider` command followed by the search term of the app you want to build a provider for:
35
+
36
+ ```bash
37
+ $ shortlook provider whatsapp
38
+
39
+ ( ● ) Fetching Apps for 'whatsapp'
40
+ Select the App you want to create a Provider for: (Use arrow keys, press Enter to select)
41
+ ‣ WhatsApp Messenger (net.whatsapp.WhatsApp)
42
+ WhatsApp Business (net.whatsapp.WhatsAppSMB)
43
+ What's the Pic? - Hidden Object Puzzle Pictures (com.wtfapps.explorer1)
44
+ Messenger for WhatsApp WebApp (com.limhong.messenger)
45
+ Emoji Free – Emoticons Art and Cool Fonts Keyboard (goatmem.emoji)
46
+ WatchUp - for WhatsApp (co.watchify.WatchUp2)
47
+
48
+ What's the name of your provider: (WhatsApp Messenger) __________
49
+
50
+ Select the type of the provider: (Use arrow keys, press Enter to select)
51
+ ‣ Contact Photo
52
+ Profile Picture
53
+ Photo
54
+ Cover
55
+
56
+ What's your name? (Marco Roth) __________
57
+
58
+ What's your bundle identifier prefix: (ch.marcoroth) __________
59
+
60
+ create ShortLook-WhatsAppMessenger
61
+ create ShortLook-WhatsAppMessenger/WhatsAppMessengerContactPhotoProvider.h
62
+ create ShortLook-WhatsAppMessenger/WhatsAppMessengerContactPhotoProvider.m
63
+ create ShortLook-WhatsAppMessenger/.gitignore
64
+ create ShortLook-WhatsAppMessenger/Info.plist
65
+ create ShortLook-WhatsAppMessenger/Makefile
66
+ create ShortLook-WhatsAppMessenger/README.md
67
+ create ShortLook-WhatsAppMessenger/ShortLook-API.h
68
+ create ShortLook-WhatsAppMessenger/control
69
+
70
+
71
+ ```
72
+
73
+ ## Development
74
+
75
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
76
+
77
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
78
+
79
+ ## Contributing
80
+
81
+ Bug reports and pull requests are welcome on GitHub at https://github.com/marcoroth/shortlook-cli. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
82
+
83
+ ## Copyright
84
+
85
+ Copyright (c) 2019 Marco Roth. See [MIT License](LICENSE.txt) for further details.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'shortlook'
5
+
6
+ require 'irb'
7
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
data/exe/shortlook ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ lib_path = File.expand_path('../lib', __dir__)
5
+ $LOAD_PATH.unshift(lib_path) unless $LOAD_PATH.include?(lib_path)
6
+ require 'shortlook/cli'
7
+
8
+ Signal.trap('INT') do
9
+ warn("\n#{caller.join("\n")}: interrupted")
10
+ exit(1)
11
+ end
12
+
13
+ begin
14
+ Shortlook::CLI.start
15
+ rescue Shortlook::CLI::Error => e
16
+ puts "ERROR: #{e.message}"
17
+ exit 1
18
+ end
data/lib/shortlook.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'shortlook/version'
2
+
3
+ module Shortlook
4
+ class Error < StandardError; end
5
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor'
4
+
5
+ module Shortlook
6
+ class CLI < Thor
7
+ include Thor::Actions
8
+
9
+ Error = Class.new(StandardError)
10
+
11
+ desc 'version', 'shortlook version'
12
+ def version
13
+ require_relative 'version'
14
+ puts "v#{Shortlook::VERSION}"
15
+ end
16
+ map %w[--version -v] => :version
17
+
18
+ def self.source_root
19
+ File.dirname(__FILE__)
20
+ end
21
+
22
+ def self.destination_root
23
+ File.dirname(__FILE__)
24
+ end
25
+
26
+ no_commands do
27
+ def class_name
28
+ @config[:class_name]
29
+ end
30
+
31
+ def bundle_id
32
+ @config[:bundle_id]
33
+ end
34
+
35
+ def provider_bundle_id
36
+ @config[:provider_bundle_id]
37
+ end
38
+
39
+ def name
40
+ @config[:name]
41
+ end
42
+
43
+ def type
44
+ @config[:type]
45
+ end
46
+
47
+ def author
48
+ @config[:author]
49
+ end
50
+
51
+ def provider_name
52
+ @config[:provider_name]
53
+ end
54
+ end
55
+
56
+ desc 'provider NAME', 'Generate a scaffold ShortLook Provider'
57
+ def provider(name)
58
+ require_relative 'commands/provider'
59
+ @config = Shortlook::Commands::Provider.new(name).execute
60
+
61
+ directory('templates/provider', provider_name)
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'forwardable'
4
+
5
+ module Shortlook
6
+ class Command
7
+ extend Forwardable
8
+
9
+ def_delegators :command, :run
10
+
11
+ # Execute this command
12
+ #
13
+ # @api public
14
+ def execute(*)
15
+ raise(
16
+ NotImplementedError,
17
+ "#{self.class}##{__method__} must be implemented"
18
+ )
19
+ end
20
+
21
+ # The interactive prompt
22
+ #
23
+ # @see http://www.rubydoc.info/gems/tty-prompt
24
+ #
25
+ # @api public
26
+ def prompt(**options)
27
+ require 'tty-prompt'
28
+ TTY::Prompt.new(options)
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'lhc'
4
+ require 'json'
5
+ require 'thor'
6
+
7
+ require 'tty-spinner'
8
+ require 'tty-config'
9
+
10
+ require_relative '../command'
11
+
12
+ module Shortlook
13
+ module Commands
14
+ class Provider < Shortlook::Command
15
+ include Thor::Actions
16
+
17
+ def initialize(name)
18
+ @name = name
19
+ end
20
+
21
+ def execute(*)
22
+ config = TTY::Config.new
23
+ spinner = TTY::Spinner.new(":spinner Fetching Apps for '#{@name}'", format: :bouncing_ball)
24
+ spinner.auto_spin
25
+
26
+ url = "https://itunes.apple.com/search?limit=10&media=software&term=#{@name}"
27
+ results = JSON.parse(LHC.get(url).body)['results']
28
+ choices = results.map { |r| { name: "#{r['trackName']} (#{r['bundleId']})", value: r } }
29
+
30
+ types = [
31
+ { name: 'Contact Photo', value: { name: 'ContactPhoto', display: 'Contact Photos', key: 'contact-photo' } },
32
+ { name: 'Profile Picture', value: { name: 'ProfilePicture', display: 'Profile Pictures', key: 'profile-picture' } },
33
+ { name: 'Photo', value: { name: 'Photo', display: 'Photos', key: 'photos' } },
34
+ { name: 'Cover', value: { name: 'Cover', display: 'Covers', key: 'covers' } }
35
+ ]
36
+
37
+ spinner.stop
38
+
39
+ begin
40
+ config.read('config.yml')
41
+ author = config.fetch(:author)
42
+ bundle_prefix = config.fetch(:bundle_prefix)
43
+ rescue TTY::Config::ReadError
44
+ config.filename = 'config'
45
+ author = ENV['USER']
46
+ bundle_prefix = 'ch.marcoroth'
47
+ end
48
+
49
+ selected = prompt.select('Select the App you want to create a Provider for:', choices)
50
+ name = prompt.ask('What\'s the name of your provider:', default: selected['trackName'])
51
+ type = prompt.select('Select the type of the provider:', types)
52
+ author = prompt.ask('What\'s your name?', default: author)
53
+ bundle_prefix = prompt.ask('What\'s your bundle identifier prefix:', default: bundle_prefix)
54
+
55
+ config.set(:author, value: author)
56
+ config.set(:bundle_prefix, value: bundle_prefix)
57
+ config.write
58
+
59
+ bundle_id = selected['bundleId']
60
+ provider_name = "ShortLook-#{name.delete(' ')}"
61
+ class_name = "#{name.delete(' ')}#{type[:name]}Provider"
62
+ provider_bundle_id = "#{bundle_prefix}.shortlook.plugin.#{type[:key]}.#{name.downcase.delete(' ')}"
63
+
64
+ {
65
+ name: name,
66
+ provider_name: provider_name,
67
+ class_name: class_name,
68
+ author: author,
69
+ type: type,
70
+ bundle_id: bundle_id,
71
+ provider_bundle_id: provider_bundle_id
72
+ }
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,5 @@
1
+ #import "ShortLook-API.h"
2
+
3
+ @interface <%= @config[:class_name] %> : NSObject <DDNotificationContactPhotoProviding>
4
+ - (DDNotificationContactPhotoPromiseOffer *)contactPhotoPromiseOfferForNotification:(DDUserNotification *)notification;
5
+ @end
@@ -0,0 +1,64 @@
1
+ #import "<%= class_name %>.h"
2
+
3
+ @interface UNNotificationAttachment
4
+ -(NSURL *)URL;
5
+ @end
6
+
7
+ @interface UNNotificationContent
8
+ -(NSArray *)attachments;
9
+ @end
10
+
11
+ @interface UNNotificationRequest
12
+ -(UNNotificationContent *)content;
13
+ @end
14
+
15
+ @interface UNNotification
16
+ -(UNNotificationRequest *)request;
17
+ @end
18
+
19
+ @interface NCNotificationRequest
20
+ -(NSString *)threadIdentifier;
21
+ -(UNNotification *)userNotification;
22
+ @end
23
+
24
+ static void debugAlert(NSString *title, NSString *message){
25
+ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
26
+ [alert show];
27
+ }
28
+
29
+ @implementation <%= class_name %>
30
+
31
+ - (DDNotificationContactPhotoPromiseOffer *)contactPhotoPromiseOfferForNotification:(DDUserNotification *)notification {
32
+ NCNotificationRequest *request = [notification request];
33
+ UNNotification *userNotification = [request userNotification];
34
+ UNNotificationRequest *notificationRequest = [userNotification request];
35
+ UNNotificationContent *content = [notificationRequest content];
36
+ UNNotificationAttachment *attachment = [content attachments][0];
37
+
38
+ NSString *imageURLStr;
39
+ // NSURL *imageURL;
40
+ UIImage *image;
41
+
42
+ if (attachment) {
43
+ image = [UIImage imageWithContentsOfFile:[attachment URL].path];
44
+ return [NSClassFromString(@"DDNotificationContactPhotoPromiseOffer") offerInstantlyResolvingPromiseWithPhotoIdentifier:imageURLStr image:image];
45
+ }
46
+
47
+ NSString *userNotificationStr = [NSString stringWithFormat:@"%@",[notification.request userNotification]];
48
+ NSString *applicationUserInfoStr = [NSString stringWithFormat:@"%@", [notification applicationUserInfo]];
49
+ NSString *userInfoStr = [NSString stringWithFormat:@"%@", [notification userInfo]];
50
+ NSString *notificationStr = [NSString stringWithFormat:@"%@", notification];
51
+ NSString *requestStr = [NSString stringWithFormat:@"%@", [notification request]];
52
+
53
+ debugAlert(@"<%= name %> userNotification", userNotificationStr);
54
+ debugAlert(@"<%= name %> applicationUserInfo", applicationUserInfoStr);
55
+ debugAlert(@"<%= name %> userInfo", userInfoStr);
56
+ debugAlert(@"<%= name %> notification", notificationStr);
57
+ debugAlert(@"<%= name %> request", requestStr);
58
+
59
+ return nil;
60
+ // return [NSClassFromString(@"DDNotificationContactPhotoPromiseOffer") offerInstantlyResolvingPromiseWithPhotoIdentifier:@imageURLStr image:image];
61
+ // return [NSClassFromString(@"DDNotificationContactPhotoPromiseOffer") offerDownloadingPromiseWithPhotoIdentifier:imageURLStr fromURL:imageURL];
62
+ }
63
+
64
+ @end
@@ -0,0 +1,13 @@
1
+ # gitignore for Theos
2
+
3
+ *.deb
4
+ _/
5
+ theos/
6
+ theos
7
+ .theos
8
+ packages/
9
+ ./packages/
10
+ obj/
11
+ ./obj/
12
+ obj
13
+ .DS_Store
@@ -0,0 +1,15 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleDisplayName</key>
6
+ <string><%= name %></string>
7
+ <key>DDNotificationExternalProviderClasses</key>
8
+ <dict>
9
+ <key><%= @config[:class_name] %></key>
10
+ <string><%= bundle_id %></string>
11
+ </dict>
12
+ <key>DDNotificationExternalProviderAPIVersion</key>
13
+ <integer>1</integer>
14
+ </dict>
15
+ </plist>
@@ -0,0 +1,20 @@
1
+ ARCHS = armv7 arm64 arm64e
2
+
3
+ include $(THEOS)/makefiles/common.mk
4
+
5
+ BUNDLE_NAME = <%= provider_name %>
6
+ $(BUNDLE_NAME)_CFLAGS = -fobjc-arc
7
+ $(BUNDLE_NAME)_FILES = $(wildcard *.m preferences/*.m)
8
+ $(BUNDLE_NAME)_FRAMEWORKS = UIKit
9
+ $(BUNDLE_NAME)_INSTALL_PATH = /Library/Dynastic/ShortLook/Plugins/ContactPhotoProviders
10
+
11
+ include $(THEOS_MAKE_PATH)/bundle.mk
12
+
13
+ BUNDLE_PATH = $($(BUNDLE_NAME)_INSTALL_PATH)/$(BUNDLE_NAME).bundle
14
+
15
+ internal-stage::
16
+ $(ECHO_NOTHING)mkdir -p $(THEOS_STAGING_DIR)$(BUNDLE_PATH)$(ECHO_END)
17
+ $(ECHO_NOTHING)cp Info.plist $(THEOS_STAGING_DIR)$(BUNDLE_PATH)/Info.plist$(ECHO_END)
18
+
19
+ after-install::
20
+ install.exec "killall -9 SpringBoard"
@@ -0,0 +1,5 @@
1
+ # <%= name %> <%= type[:display] %> Provider for ShortLook
2
+
3
+ Show <%= name %> <%= type[:display] %> in ShortLook when you receive a <%= name %> notification!
4
+
5
+ (This is not ShortLook itself, but a plugin for it)
@@ -0,0 +1,107 @@
1
+ //
2
+ // WARNING:
3
+ // This file contains the required headers to compile a tweak that
4
+ // interacts with ShortLook's contact photo API. Do not modify the
5
+ // headers within, or it could lead to unexpected behaviour.
6
+ //
7
+ // ---
8
+ //
9
+ // ShortLook-API.h
10
+ //
11
+ // Created by AppleBetas on 2018-05-18.
12
+ // Copyright © 2018 Dynastic Development. All rights reserved.
13
+ //
14
+
15
+ #import <UIKit/UIKit.h>
16
+ @class NCNotificationRequest, UNNotificationContent;
17
+
18
+ /// A ShortLook-displayable notification representing a real user notification sent by an application to the system.
19
+ @interface DDUserNotification : NSObject
20
+ /// A custom notification title, separate from the application's title.
21
+ @property (nonatomic, retain, readonly) NSString *notificationTitle;
22
+
23
+ /// A dictionary of any extra information included by ShortLook.
24
+ @property (nonatomic, retain) NSDictionary *userInfo;
25
+
26
+ /// The system notification request that created this notification.
27
+ @property (nonatomic, readonly, retain) NCNotificationRequest *request;
28
+
29
+ /// The user notification's content, sent by the application.
30
+ - (UNNotificationContent *)content;
31
+
32
+ /// A dictionary of any extra information provided by the application sending the notification.
33
+ - (NSDictionary *)applicationUserInfo;
34
+
35
+ /// The bundle identifier of the application this notification represents.
36
+ - (NSString *)senderIdentifier;
37
+ @end
38
+
39
+ /// An object representing settings for the photo to be provided by a promise.
40
+ @interface DDNotificationContactPhotoSettings: NSObject
41
+ /// The background colour to show for the contact photo view if the provided image contains any transparency.
42
+ @property (nonatomic, retain) UIColor *backgroundColor;
43
+
44
+ /// Whether or not ShortLook should automatically cache the returned image from your provider and use it for all future notifications with the same photo identifier and application.
45
+ @property (nonatomic, assign) BOOL usesCaching;
46
+ @end
47
+
48
+ /// A promise representing a commitment to providing a contact icon for a notification.
49
+ @interface DDNotificationContactPhotoPromise: NSObject
50
+ /// An object holding the settings pertaining to the photo to be displayed.
51
+ @property (nonatomic, retain) DDNotificationContactPhotoSettings *settings;
52
+
53
+ /// Whether or not this promise has already been resolved or rejected.
54
+ @property (nonatomic, readonly, assign) BOOL isComplete;
55
+
56
+ // MARK: - Provider methods
57
+
58
+ /// Resolve this promise with the provided image, notifying ShortLook that you have received your image.
59
+ /// - NOTE: This method should only be ran from within `addResolver:`.
60
+ - (void)resolveWithImage:(UIImage *)image;
61
+
62
+ /// Reject this promise, notifying ShortLook that you failed to receive an image.
63
+ /// - NOTE: This method should only be ran from within `addResolver:`.
64
+ - (void)reject;
65
+ @end
66
+
67
+ /// An offer to fulfill a promise representing a commitment to providing a contact icon for a notification.
68
+ @interface DDNotificationContactPhotoPromiseOffer: NSObject
69
+ /// A unique identifier for the photo that will be provided by this promise.
70
+ @property (nonatomic, readonly, retain) NSString *photoIdentifier;
71
+
72
+ /// A string to replace the notification's title with, if it is required for your provider's context. Set to "" to remove the provided notification's title.
73
+ @property (nonatomic, retain) NSString *titleOverride;
74
+
75
+ /// A string to replace the notification's subtitle with, if it is required for your provider's context. Set to "" to remove the provided notification's subtitle.
76
+ @property (nonatomic, retain) NSString *subtitleOverride;
77
+
78
+ /// A string to replace the notification's body with, if it is required for your provider's context. Set to "" to remove the provided notification's body.
79
+ @property (nonatomic, retain) NSString *bodyOverride;
80
+
81
+ /// Initialize a promise with the provided photo identifier.
82
+ - (instancetype)initWithPhotoIdentifier:(NSString *)photoIdentifier;
83
+
84
+ /// Create a promise offer that will return the image at the provided URL, if needed.
85
+ + (instancetype)offerDownloadingPromiseWithPhotoIdentifier:(NSString *)photoIdentifier fromURL:(NSURL *)url;
86
+
87
+ /// Create a promise offer that will return the image at the provided URL, if needed, with custom settings.
88
+ + (instancetype)offerDownloadingPromiseWithPhotoIdentifier:(NSString *)photoIdentifier fromURL:(NSURL *)url withSettings:(DDNotificationContactPhotoSettings *)settings;
89
+
90
+ /// Create a promise offer that will instantly return the provided image.
91
+ + (instancetype)offerInstantlyResolvingPromiseWithPhotoIdentifier:(NSString *)photoIdentifier image:(UIImage *)image;
92
+
93
+ /// Create a promise offer that will instantly return the provided image with custom settings.
94
+ + (instancetype)offerInstantlyResolvingPromiseWithPhotoIdentifier:(NSString *)photoIdentifier image:(UIImage *)image withSettings:(DDNotificationContactPhotoSettings *)settings;
95
+
96
+ /// Add the block that will run if your image is needed (as it will not be in some cases, such as if your image is already cached by ShortLook).
97
+ /// If your provider does any long-running or asynchronous operations, they should be done using this method.
98
+ /// Any code run inside the provider block will be performed on a background thread.
99
+ - (void)fulfillWithBlock:(void (^)(DDNotificationContactPhotoPromise *promise))block;
100
+ @end
101
+
102
+ /// An object that can provide contact photos for ShortLook notifications.
103
+ @protocol DDNotificationContactPhotoProviding <NSObject>
104
+ @required
105
+ /// Returns an offer to fulfill a promise to provide a contact photo for a notification.
106
+ - (DDNotificationContactPhotoPromiseOffer *)contactPhotoPromiseOfferForNotification:(DDUserNotification *)notification;
107
+ @end
@@ -0,0 +1,9 @@
1
+ Package: <%= provider_bundle_id %>
2
+ Name: <%= name %> <%= type[:display] %> for ShortLook
3
+ Depends: mobilesubstrate, co.dynastic.ios.tweak.shortlook
4
+ Version: 1.0.0
5
+ Architecture: iphoneos-arm
6
+ Description: Show <%= name %> <%= type[:display] %> in ShortLook when you receive a <%= name %> notification!
7
+ Maintainer: <%= author %>
8
+ Author: <%= author %>
9
+ Section: Tweaks (ShortLook)
@@ -0,0 +1,3 @@
1
+ module Shortlook
2
+ VERSION = '0.1.0'.freeze
3
+ end
data/shortlook.gemspec ADDED
@@ -0,0 +1,35 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ require 'shortlook/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'shortlook'
8
+ spec.license = 'MIT'
9
+ spec.version = Shortlook::VERSION
10
+ spec.authors = ['Marco Roth']
11
+ spec.email = ['marco.roth@intergga.ch']
12
+ spec.summary = 'ShortLook CLI for scaffoling a ShortLook Provider'
13
+ spec.description = 'ShortLook CLI for scaffoling a ShortLook Provider'
14
+ spec.homepage = 'https://github.com/marcoroth/shortlook-cli'
15
+
16
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
17
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ end
19
+
20
+ spec.bindir = 'exe'
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_dependency 'lhc', '~> 10.3'
25
+ spec.add_dependency 'pastel', '~> 0.7.2'
26
+ spec.add_dependency 'thor', '~> 0.20.0'
27
+ spec.add_dependency 'tty-command', '~> 0.8.0'
28
+ spec.add_dependency 'tty-config', '~> 0.3.0'
29
+ spec.add_dependency 'tty-prompt', '~> 0.18.0'
30
+ spec.add_dependency 'tty-spinner', '~> 0.9.0'
31
+
32
+ spec.add_development_dependency 'bundler', '~> 2.0'
33
+ spec.add_development_dependency 'rake', '~> 10.0'
34
+ spec.add_development_dependency 'rspec', '~> 3.0'
35
+ end
metadata ADDED
@@ -0,0 +1,209 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shortlook
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Marco Roth
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-05-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: lhc
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '10.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '10.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pastel
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.7.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.7.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: thor
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.20.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.20.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: tty-command
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.8.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.8.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: tty-config
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.3.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.3.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: tty-prompt
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.18.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.18.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: tty-spinner
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.9.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.9.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: bundler
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '2.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '2.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rake
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '10.0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '10.0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '3.0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '3.0'
153
+ description: ShortLook CLI for scaffoling a ShortLook Provider
154
+ email:
155
+ - marco.roth@intergga.ch
156
+ executables:
157
+ - shortlook
158
+ extensions: []
159
+ extra_rdoc_files: []
160
+ files:
161
+ - ".gitignore"
162
+ - ".rspec"
163
+ - ".rubocop.yml"
164
+ - Gemfile
165
+ - Gemfile.lock
166
+ - LICENSE.txt
167
+ - README.md
168
+ - Rakefile
169
+ - bin/console
170
+ - bin/setup
171
+ - exe/shortlook
172
+ - lib/shortlook.rb
173
+ - lib/shortlook/cli.rb
174
+ - lib/shortlook/command.rb
175
+ - lib/shortlook/commands/provider.rb
176
+ - lib/shortlook/templates/provider/%class_name%.h.tt
177
+ - lib/shortlook/templates/provider/%class_name%.m.tt
178
+ - lib/shortlook/templates/provider/.gitignore
179
+ - lib/shortlook/templates/provider/Info.plist.tt
180
+ - lib/shortlook/templates/provider/Makefile.tt
181
+ - lib/shortlook/templates/provider/README.md.tt
182
+ - lib/shortlook/templates/provider/ShortLook-API.h
183
+ - lib/shortlook/templates/provider/control.tt
184
+ - lib/shortlook/version.rb
185
+ - shortlook.gemspec
186
+ homepage: https://github.com/marcoroth/shortlook-cli
187
+ licenses:
188
+ - MIT
189
+ metadata: {}
190
+ post_install_message:
191
+ rdoc_options: []
192
+ require_paths:
193
+ - lib
194
+ required_ruby_version: !ruby/object:Gem::Requirement
195
+ requirements:
196
+ - - ">="
197
+ - !ruby/object:Gem::Version
198
+ version: '0'
199
+ required_rubygems_version: !ruby/object:Gem::Requirement
200
+ requirements:
201
+ - - ">="
202
+ - !ruby/object:Gem::Version
203
+ version: '0'
204
+ requirements: []
205
+ rubygems_version: 3.0.3
206
+ signing_key:
207
+ specification_version: 4
208
+ summary: ShortLook CLI for scaffoling a ShortLook Provider
209
+ test_files: []