require "import"
import "android.widget.*"
local text={
TextView,
id="tv",
layout_height="5%h",
layout_width="fill";
}
data={}
local jqb=service.getClipboardList()
for i=1,#jqb-1 do
table.insert(data,{tv=jqb})
end
adapter=LuaAdapter(this,data,text)
layout={
LinearLayout;
orientation="vertical";
layout_width="fill";
{
EditText;
id="edit";
layout_width="fill";
layout_height="10%h",
};
{LinearLayout;
orientation="horizontal";
{Button,
text="更新剪切板",
onClick=function()
service.copy(edit.text)
end,
layout_width="20%w";
};
{Button,
text="追加复制",
onClick=function()
service.appendCopy(edit.text)
end,
layout_width="20%w";
};
{Button,
text="添加到收藏",
onClick=function()
service.addFavorites(edit.text)
end,
layout_width="20%w";
};
{Button,
text="删除中文",
onClick=function()
local txt=edit.text
s=utf8.gsub(txt,"[\u4e00-\u9fa5-,。?!:;…()、“”—‘’【】《》]","")
edit.text=s
end,
layout_width="20%w";
};
{Button,
text="删除英文",
onClick=function()
local txt=edit.text
s=utf8.gsub(txt,"[a-zA-Z,%.%:%!%?%;]","")
edit.text=s
end,
layout_width="20%w";
};
};
{LinearLayout;
orientation="horizontal";
{Button,
text="删除空白",
onClick=function()
local txt=edit.text
s=utf8.gsub(txt,"[ ]","")
edit.text=s
end,
layout_width="16.6%w";
};
{Button,
text="删除空行",
onClick=function()
local txt=edit.text
h=utf8.gsub(txt,"\n+","\n")
h=utf8.gsub(h,"\r+","\r")
edit.text=h
end,
layout_width="16.6%w";
};
{Button,
text="删首空",
onClick=function()
local txt=edit.text
s=utf8.gsub(txt," *([^\n]*)","%1")
edit.text=s
end,
layout_width="16.6%w";
};
{Button,
text="删尾空",
onClick=function()
local txt=edit.text
s=utf8.gsub(txt,"[ ]+\n","\n")
s=utf8.gsub(s,"%s+$","")
edit.text=s
end,
layout_width="16.6%w";
};
{Button,
text="英文字母转小写",
onClick=function()
local s=edit.text
s=utf8.lower(s)
edit.text=s
end,
layout_width="16.6%w";
};
{Button,
text="英文字母转大写",
onClick=function()
local s=edit.text
s=utf8.upper(s)
edit.text=s
end,
layout_width="16.6%w";
};
};
{ ListView;
id="list";
layout_width="fill";
layout_height=-1,
};
}
dlg=LuaDialog(this)
.setView(loadlayout(layout))
.setButton("剪切板",function()
service.execute("剪切板",node)
end)
.setButton2("收藏夹",function()
service.execute("收藏夹",node)
end)
.show()
task(100,function()
service.execute("粘贴")
end)
list.adapter=adapter
list.onItemClick=function(l,v,p)
dlg.dismiss()
task(200,function()
service.paste(v.text)
end)
end
list.onItemLongClick=function(l,v,p)
edit.text=v.text
return true
end
return true
来自解说社区客户端 |