-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain2.lua
More file actions
244 lines (236 loc) · 5.72 KB
/
main2.lua
File metadata and controls
244 lines (236 loc) · 5.72 KB
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
require "import"
import "android.app.*"
import "android.os.*"
import "android.widget.*"
import "android.view.*"
import "com.myopicmobile.textwarrior.common.*"
import "android.content.*"
import "android.text.SpannableString"
import "android.text.style.ForegroundColorSpan"
import "android.text.Spannable"
import "android.graphics.drawable.ColorDrawable"
import "autotheme"
import "mods.andlua"
import "mods.SnackerBar"
main7 = {
LinearLayout,
orientation = "horizontal",
backgroundColor = AndLuaB,
};
ztl()
classes = require "android"
activity.setContentView(loadlayout(main7))
ztt()
dir, path = ...
function fiximport(path)
require "import"
import "android.app.*"
import "android.os.*"
import "android.widget.*"
import "android.view.*"
import "com.myopicmobile.textwarrior.common.*"
import "mods.andlua"
if Night_mode then
else
ztt()
end
classes = require "android"
local searchpath = path:gsub("[^/]+%.lua", "?.lua;") .. path:gsub("[^/]+%.lua", "?.aly;")
local cache = {}
function checkclass(path, ret)
if cache[path] then
return
end
cache[path] = true
local f = io.open(path)
local str = f:read("a")
f:close()
if not str then
return
end
for s, e, t in str:gfind("(import \"[%w%.]+%*\")") do
end
for s, e, t in str:gfind("import \"([%w%.]+)\"") do
local p = package.searchpath(t, searchpath)
if p then
p5 = io.open(p):read("*a")
if string.byte(p5, 1) == 0x1b then
else
checkclass(p, ret)
end
end
end
local lex = LuaLexer(str)
local buf = {}
local last = nil
while true do
local t = lex.advance()
if not t then
break
end
if last ~= LuaTokenTypes.DOT and t == LuaTokenTypes.NAME then
local text = lex.yytext()
buf[text] = true
end
last = t
end
table.sort(buf)
for k, v in pairs(buf) do
k = "[%.$]" .. k .. "$"
for a, b in ipairs(classes) do
if string.find(b, k) then
if cache[b] == nil then
table.insert(ret, b)
cache[b] = true
end
end
end
end
end
local ret = {}
checkclass(path, ret)
return String(ret)
end
dir, path = ...
list = ListView(activity)
list.ChoiceMode = ListView.CHOICE_MODE_MULTIPLE;
task(fiximport, path, function(v)
rs = v
adp = ArrayListAdapter(activity, android.R.layout.simple_list_item_multiple_choice, v)
list.Adapter = adp
activity.setContentView(list)
end)
cm = activity.getSystemService(Context.CLIPBOARD_SERVICE)
function onOptionsItemSelected(item)
if item.Title == getLS("L_Copy") then
local buf = {}
local cs = list.getCheckedItemPositions()
local buf = {}
for n = 0, #rs - 1 do
if cs.get(n) then
table.insert(buf, string.format("import \"%s\"", rs[n]))
end
end
local str = table.concat(buf, "\n")
local cd = ClipData.newPlainText("label", str)
cm.setPrimaryClip(cd)
Toast.makeText(activity, getLS("L_Replicated_the_clipboard"), 1000).show()
else
for n = 0, #rs - 1 do
list.setItemChecked(n, not list.isItemChecked(n))
end
end
end
btl = {
LinearLayout,
layout_width = "fill",
elevation = "1dp",
layout_height = "55dp",
orientation = "horizontal",
{
LinearLayout,
layout_width = "55dp",
gravity = "center",
id = "Sideslip",
layout_height = "55dp",
layout_marginLeft = "-15dp",
{
ImageView,
layout_height = "25dp",
colorFilter = tonumber(bjzt()),
layout_width = "28dp",
src = "res/off.png",
},
},
{
LinearLayout,
layout_height = "fill",
layout_weight = "1",
orientation = "horizontal",
{
TextView,
layout_gravity = "center",
textSize = "18sp",
text = getLS("L_The_import_analysis"),
textColor = tonumber(bjzt()),
id = "bt",
singleLine = true,
},
},
{
LinearLayout,
layout_width = "55dp",
gravity = "center",
id = "c1",
layout_height = "55dp",
{
ImageView,
layout_height = "25dp",
colorFilter = tonumber(bjzt()),
layout_width = "28dp",
src = "res/ic_select_all.png",
},
},
{
LinearLayout,
layout_width = "55dp",
gravity = "center",
id = "c2",
layout_height = "55dp",
layout_marginRight = "-15dp",
{
ImageView,
layout_height = "22dp",
colorFilter = tonumber(bjzt()),
layout_width = "25dp",
src = "res/ic_copy.png",
},
},
{
LinearLayout,
layout_width = "0dp",
gravity = "center",
id = "menu2",
layout_height = "0dp",
},
};
activity.ActionBar.setDisplayShowCustomEnabled(true)
activity.ActionBar.setCustomView(loadlayout(btl))
activity.ActionBar.setBackgroundDrawable(ColorDrawable(AndLuaB1))
sp = SpannableString(getLS("L_The_import_analysis"))
sp.setSpan(ForegroundColorSpan(0xffffffff), 0, #sp, Spannable.SPAN_EXCLUSIVE_INCLUSIVE)
activity.ActionBar.setTitle(sp)
activity.ActionBar.setElevation(6)
activity.setTheme(android.R.style.Theme_Material_Light)
bw(Sideslip, 0x5FFFFFFF)
bw(c1, 0x5FFFFFFF)
bw(c2, 0x5FFFFFFF)
Sideslip.onClick = function()
activity.finish()
end
c2.onClick = function()
local buf = {}
local cs = list.getCheckedItemPositions()
local buf = {}
for n = 0, #rs - 1 do
if cs.get(n) then
table.insert(buf, string.format("import \"%s\"", rs[n]))
end
end
local str = table.concat(buf, "\n")
local cd = ClipData.newPlainText("label", str)
cm.setPrimaryClip(cd)
SnackerBar.build()
:msg(getLS("L_Replicated_the_clipboard"))
:actionText(getLS("L_OK"))
:action(function()
end)
:show()
end
c1.onClick = function()
for n = 0, #rs - 1 do
list.setItemChecked(n, not list.isItemChecked(n))
end
end
ztt()
list.setDividerHeight(0)