Skip to content

Commit

Permalink
a12 beta
Browse files Browse the repository at this point in the history
  • Loading branch information
rweichler committed Oct 19, 2019
1 parent d913994 commit 3482061
Show file tree
Hide file tree
Showing 19 changed files with 397 additions and 105 deletions.
9 changes: 3 additions & 6 deletions app/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ window:setRootViewController(VIEWCONTROLLER(function(m)
local super = nav.cell.mnew
function nav.cell.mnew(_)
local m = super(_)
m:textLabel():setFont(objc.UIFont:fontWithName_size('HelveticaNeue-Bold', 22))
m:textLabel():setFont(objc.UIFont:fontWithName_size('HelveticaNeue-Light', 18))
return m
end
local selected_view = objc.UIView:alloc():initWithFrame{{0, 0},{2, 44}}
Expand All @@ -149,10 +149,6 @@ window:setRootViewController(VIEWCONTROLLER(function(m)
local item = nav.items[section][row]
m:textLabel():setText(item.title)
m:imageView():setImage(item.icon)
if item.icon then
local siz = 22
m:imageView():setTransform(C.CGAffineTransformMakeScale(siz/item.icon:size().width, siz/item.icon:size().height))
end
if item.view == active then
m:addSubview(selected_view)
end
Expand Down Expand Up @@ -241,4 +237,5 @@ CHECK_UPDATE(function(json, err)
end)
end)

require 'autorun_loader'('app')
require 'page.crossfeed'
require 'page.compressor'
93 changes: 93 additions & 0 deletions app/page/compressor.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
-- put this into /var/tweak/com.r333d.eqe/lua/autorun/app/
-- load by restarting the EQE app

local str_esc = require 'str_esc'
local md = require 'md'

local page = {}
page.title = 'Compressor (beta)'
page.icon = IMG('radio-waves.png', PAGE_ICON_COLOR):retain()

local function ipc(s, safe)
s = str_esc(s)
if safe then
return IPC('return eqe.raw('..s..')')
else
return IPC('return eqe.raw('..s..', true)')
end
end

local pad = 11
local function create_switch(y, canvaswidth, title, m)
local target = ns.target:new()
target.switch = objc.UISwitch:alloc():init()
local s = target.switch:frame().size
local x = canvaswidth - s.width - pad*3
target.switch:setFrame{{x, y},s}
target.switch:setOnTintColor(COLOR(0x4bc2ffaa))
target.switch:setTintColor(COLOR(0xffffff55))
target.switch:addTarget_action_forControlEvents(target.m, target.sel, UIControlEventValueChanged)

target.label = objc.UILabel:alloc():init()
target.label:setFont(objc.UIFont:fontWithName_size('HelveticaNeue', 16))
target.label:setTextColor(COLOR(0xffffff8d))
target.label:setBackgroundColor(objc.UIColor:clearColor())
target.label:setText(title)
target.label:sizeToFit()
local switchS = s
local s = target.label:frame().size
target.label:setFrame{{x - s.width - pad, y + (switchS.height - s.height)/2},s}

m:view():addSubview(target.label)
m:view():addSubview(target.switch)
return target, y + target.switch:frame().size.height
end

function page:init()
local vc = VIEWCONTROLLER(function(m)
local frame = m:view():frame()
local width = frame.size.width

local y = 64

local enable, y = create_switch(y, width, 'Enabled', m)
function enable.onaction()
local on = objc.weirdbool(enable.switch:isOn())
ipc('compressor.enabled('..tostring(on)..')')
ipc('compressor.save()')
end
self.enable = enable

local r = md.new(width - pad*2)
self.helper_text = r.m
self.helper_text:setFrame{{pad, y + pad},{0,0}}
m:view():addSubview(self.helper_text)
r:init[[
This basically makes your audio more "level" and "loud". Good for listening to podcasts and that kinda stuff. [Wikipedia article](https://en.wikipedia.org/wiki/Dynamic_range_compression)
This is a super basic version of a compressor, it's literally just an enable switch with some super basic presets. There should be more options here but I don't know how compressors work.
If you know how to use a compressor, hop on the [Discord chat](https://discord.gg/RSJWAuX). I can show you the under-the-hood settings in Terminal.
This code is open source.
]]

end)
self.view = vc:view()
end

function page:refresh()
local enabled = ipc('return compressor.enabled()') == 'true'

self.enable.switch:setOn(enabled)
end

function page:hide(hiding)
if not hiding then
self:refresh()
end

end

Page.compressor = page
ADD_NAV_PAGE(page, Page.eqe)
199 changes: 199 additions & 0 deletions app/page/crossfeed.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
-- put this into /var/tweak/com.r333d.eqe/lua/autorun/app/
-- load by restarting the EQE app

local str_esc = require 'str_esc'
local md = require 'md'

local page = {}
page.title = 'Crossfeed (beta)'
page.icon = IMG('headphone.png', PAGE_ICON_COLOR):retain()

local function ipc(s, safe)
s = str_esc(s)
if safe then
return IPC('return eqe.raw('..s..')')
else
return IPC('return eqe.raw('..s..', true)')
end
end

local thumbImg = IMG('thumb.png'):retain()

local pad = 11
local function create_slider(y, width, title, m)
local self = {}
self.onchange = function() end
self.onfinish = function() end

self.label = objc.UILabel:alloc():initWithFrame{{pad,y},{width - pad*2,44}}
self.label:setFont(objc.UIFont:fontWithName_size('HelveticaNeue', 16))
self.label:setTextColor(COLOR(0xffffff8d))
self.label:setBackgroundColor(objc.UIColor:clearColor())
self.label:setText(title)

y = y + self.label:frame().size.height

self.slider = objc.EQEOBSlider:alloc():initWithFrame{{pad,y},{width - pad*2,44}}
self.slider:setThumbImage_forState(thumbImg, UIControlStateNormal)
self.slider:setMinimumTrackTintColor(COLOR(0xffffff80))
self.slider:setMaximumTrackTintColor(COLOR(0xffffff50))

local target = ns.target:new()
function target.onaction()
self.onfinish()
end
self.slider:addTarget_action_forControlEvents(target.m, target.sel, bit.bor(UIControlEventTouchUpInside, UIControlEventTouchUpOutside))

local target = ns.target:new()
function target.onaction()
self.onchange()
end
self.slider:addTarget_action_forControlEvents(target.m, target.sel, bit.bor(UIControlEventValueChanged))

local target = ns.target:new()
self.slider:addTarget_action_forControlEvents(target.m, target.sel, UIControlEventValueChanged)
function self.updatetext()
self.label:setText(title..': '..self.slider:value())
end
function target.onaction()
self.updatetext()
end

y = y + self.slider:frame().size.height

m:view():addSubview(self.slider)
m:view():addSubview(self.label)

return self, y
end

local function create_button(x, y, canvaswidth, title, m)
local height = 34
local width = canvaswidth*2/3
local button = ui.button:new()
button.m:setFrame{{x + (canvaswidth-width)/2, y},{width,height}}
button.m:layer():setCornerRadius(8)
button:setFont('HelveticaNeue', 16)
button:setColor(COLOR(0xff, 0xff, 0xff, 0xff*0.7))
button.m:setBackgroundColor(COLOR(0xff, 0xff, 0xff, 0xff*0.07))
button:setTitle(title)
m:view():addSubview(button.m)
return button, y + height
end

local function create_switch(y, canvaswidth, title, m)
local target = ns.target:new()
target.switch = objc.UISwitch:alloc():init()
local s = target.switch:frame().size
local x = canvaswidth - s.width - pad*3
target.switch:setFrame{{x, y},s}
target.switch:setOnTintColor(COLOR(0x4bc2ffaa))
target.switch:setTintColor(COLOR(0xffffff55))
target.switch:addTarget_action_forControlEvents(target.m, target.sel, UIControlEventValueChanged)

target.label = objc.UILabel:alloc():init()
target.label:setFont(objc.UIFont:fontWithName_size('HelveticaNeue', 16))
target.label:setTextColor(COLOR(0xffffff8d))
target.label:setBackgroundColor(objc.UIColor:clearColor())
target.label:setText(title)
target.label:sizeToFit()
local switchS = s
local s = target.label:frame().size
target.label:setFrame{{x - s.width - pad, y + (switchS.height - s.height)/2},s}

m:view():addSubview(target.label)
m:view():addSubview(target.switch)
return target, y + target.switch:frame().size.height
end

function page:init()
local vc = VIEWCONTROLLER(function(m)
local frame = m:view():frame()
local width = frame.size.width

local intensity, y = create_slider(64, width, 'Intensity', m)
intensity.slider:setMinimumValue(0)
intensity.slider:setMaximumValue(1)
function intensity.onchange()
ipc('crossfeed.intensity('..intensity.slider:value()..')')
end
function intensity.onfinish()
intensity.onchange()
ipc('crossfeed.save()')
end
self.intensity = intensity

local delay, y = create_slider(y, width, 'Delay (ms)', m)
delay.slider:setMinimumValue(0)
delay.slider:setMaximumValue(4)
function delay.onchange()
ipc('crossfeed.delay('..delay.slider:value()..')')
end
function delay.onfinish()
delay.onchange()
ipc('crossfeed.save()')
end
self.delay = delay

--[[
y = y + pad*2
self.save = create_button(0, y, width/2, 'Save', m)
local load, y = create_button(width/2, y, width/2, 'Load', m)
self.load = load
function self.save.ontoggle()
ipc('crossfeed.save()')
end
function self.load.ontoggle()
ipc('crossfeed.load()')
self:refresh()
end
]]

y = y + pad*2

local enable, y = create_switch(y, width, 'Enabled', m)
function enable.onaction()
local on = objc.weirdbool(enable.switch:isOn())
ipc('crossfeed.enabled('..tostring(on)..')', true)
end
self.enable = enable

local r = md.new(width - pad*2)
self.helper_text = r.m
self.helper_text:setFrame{{pad, y + pad},{0,0}}
m:view():addSubview(self.helper_text)
r:init[[
If you have no clue what this does, [here's a pretty good explanation](http://www.meier-audio.homepage.t-online.de/crossfeed.htm).
Basically, you should use this if you're using headphones, it makes it sound more "full" and "open", like speakers.
Credits to xC0nfused on [Discord](https://discord.gg/RSJWAuX) for helping make this. This code is open source.]]

end)
self.view = vc:view()
end

function page:refresh()
local intensity = tonumber(ipc('return crossfeed.intensity()'))
local delay = tonumber(ipc('return crossfeed.delay()'))
local enabled = ipc('return crossfeed.enabled()') == 'true'

self.intensity.slider:setValue(intensity)
self.intensity.updatetext()
self.delay.slider:setValue(delay)
self.delay.updatetext()
self.enable.switch:setOn(enabled)
end

function page:hide(hiding)
if not hiding then
self:refresh()
end

end

Page.crossfeed = page
ADD_NAV_PAGE(page, Page.eqe)
4 changes: 2 additions & 2 deletions app/page/history/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ function page:init()
function tbl.cell.onshow(_, m, section, row)
local item = items[row]
m:textLabel():setText(item.title)
local scale = 22
local scale = 32
scale = scale/math.max(item.icon:size().width, item.icon:size().height)
m:imageView():setTransform(C.CGAffineTransformMakeScale(scale, scale))
m:setImageViewSize{scale*item.icon:size().width, scale*item.icon:size().height}
m:imageView():setImage(item.icon)
end
function tbl.cell.onselect(_, section, row)
Expand Down
2 changes: 1 addition & 1 deletion app/page/history/top/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ return function(query, render)
if icon then
local scale = 22
scale = scale/math.max(icon:size().width, icon:size().height)
m:imageView():setTransform(C.CGAffineTransformMakeScale(scale, scale))
m:setImageViewSize{scale*icon:size().width, scale*icon:size().height}
end
end

Expand Down
4 changes: 2 additions & 2 deletions app/page/history/whitelist.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ return function(m)
m:accessoryView():setOn(app.enabled == 1 and true or false)

if icon then
local scale = 22
local scale = 32
scale = scale/math.max(icon:size().width, icon:size().height)
m:imageView():setTransform(C.CGAffineTransformMakeScale(scale, scale))
m:setImageViewSize{scale*icon:size().width, scale*icon:size().height}
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/page/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function page:init()
local items = {
{
title = 'Enable mediaserverd hook',
subtitle = 'When disabled, audio will not be processed. Basically the equivalent of disabling in iCleaner.',
subtitle = 'Handles processing of all audio.',
cb = function(enabled)
if enabled == nil then
return IPC('return GET_ENABLED()') == 'true'
Expand Down
7 changes: 1 addition & 6 deletions app/page/update.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,7 @@ function page:init()
end

local cydia_notice_text = "If you want, you can just update through Cydia. Both methods are compatible with each other."
local version_info_text
if string.find(EQE_TWEAK_VERSION, '%~beta') then
version_info_text = 'Current version: '..EQE_TWEAK_VERSION..'\ngit commit: '..string.sub(require 'config.default.git_commit', 1, 6)..'\n\nIf you are reporting an issue, please specify the git commit as well.'
else
version_info_text = 'Current version: '..EQE_TWEAK_VERSION
end
local version_info_text = 'Current version: '..EQE_TWEAK_VERSION

local cydia_notice = objc.UILabel:alloc():init()
cydia_notice:setColor(COLOR(0xffffff5d))
Expand Down
3 changes: 2 additions & 1 deletion app/ui/cell.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ function ui.cell:mnew()
self.m = m
objc.ref(m, self)

m:setImageViewSize{32, 32}
m:textLabel():setTextColor(objc.UIColor:whiteColor())
m:textLabel():setBackgroundColor(objc.UIColor:clearColor())
m:detailTextLabel():setTextColor(objc.UIColor:whiteColor())
Expand All @@ -49,7 +50,7 @@ end
function ui.cell:dealloc()
end

ui.cell.class = objc.GenerateClass('UITableViewCell')
ui.cell.class = objc.GenerateClass('EQEEditCell')
local class = ui.cell.class

function class.dealloc(m)
Expand Down
Loading

0 comments on commit 3482061

Please sign in to comment.