--程序启动时会执行的事件☜MT管理打开复制粘贴到顶栏模板启动事件
--程序启动时会执行的事件☜MT管理打开复制粘贴到顶栏模板启动事件
--程序启动时会执行的事件☜MT管理打开复制粘贴到顶栏模板启动事件

require "import"
import "android.app.*"
import "android.widget.*"
import "android.view.*"
import "android.text.*"


decorViewClazz=Class.forName("com.android.internal.policy.DecorView")
field=decorViewClazz.getDeclaredField("mSemiTransparentStatusBarColor")
field.setAccessible(true)
field.setInt(this.getWindow().getDecorView(),0xffffffff)--Color.TRANSPARENT)

function serialize(obj)
local lua = ""
local t = type(obj)
if t == "number" then
lua = lua .. obj
elseif t == "boolean" then
lua = lua .. tostring(obj)
elseif t == "string" then
lua = lua .. string.format("%q", obj)
elseif t == "table" then
lua = lua .. "{\n"
for k, v in pairs(obj) do
lua = lua .. "[" .. serialize(k) .. "]=" .. serialize(v) .. ",\n"
end
local metatable = getmetatable(obj)
if metatable ~= nil and type(metatable.__index) == "table" then
for k, v in pairs(metatable.__index) do
lua = lua .. "[" .. serialize(k) .. "]=" .. serialize(v) .. ",\n"
end
end
lua = lua .. "}"
elseif t == "nil" then
return nil
else
error("can not serialize a " .. t .. " type.")
end
return lua
end

local function getStatusBarHeight()
local resid=activity.getResources().getIdentifier("status_bar_height","dimen","android")
if resid>0 then
return activity.getResources().getDimensionPixelSize(resid)
end
end

local function showMsg(title,msg)
local adlgb=AlertDialog.Builder(this)
if title then
adlgb.setTitle(title)
end
if msg then
adlgb.setMessage(msg)
end
adlgb.create().show()
end

function isEmpty(jdpuk)
if jdpuk and not type(jdpuk)=="string" then
jdpuk=tostring(jdpuk)
end
return (jdpuk and jdpuk:find("^$"))
end

local layout={
LinearLayout,
layout_width="fill",
layout_height="fill",
orientation="vertical",
{
LinearLayout,
layout_width="fill",
layout_height=getStatusBarHeight(),
orientation="horizontal",
background="#009688",
{
TextView,
layout_width="fill",
layout_height="fill",
layout_marginLeft="10dp",
layout_marginRight="10dp",
gravity="center",
text="Fuck you!",
textSize="12sp",
textColor="#FFFFFF",
},
},
{
ToolBar,
layout_width="fill",
layout_height="60dp",
background="#009688",
{
TextView,
layout_margin="15dp",
gravity="left|center",
text="服务数据生成器",
textSize="20sp",
textColor="#FFFFFF",
},
},
{
ScrollView,
layout_width="fill",
VerticalScrollBarEnabled=false,
{
LinearLayout,
layout_width="fill",
orientation="vertical",
layout_marginTop="10dp",
{
CardView,
layout_width="fill",
layout_height="match",
layout_margin="10dp",
radius="1dp",
elevation="3dp",
{
LinearLayout,
layout_width="fill",
padding="10dp",
orientation="vertical",
{
TextView,
layout_margin="10dp",
text="更新数据",
textSize="22dp",
textColor="#000000",
},
{
LinearLayout,
layout_width="fill",
layout_margin="15dp",
orientation="vertical",
{
EditText,
id="iVersion",
layout_width="fill",
hint="版本",
inputType="number",
singleLine=true,
},
{
LinearLayout,
orientation="horizontal",
{
CheckBox,
id="iUseVersionName",
--layout_width="fill",
text="使用版本名",
},
{
TextView,
layout_marginLeft="10dp",
text="了解详情",
textColor="#009688",
onClick=function()
showMsg("说明",[[
勾选则使用版本名,否则使用版本号。

首先,请您明确版本号与版本名的概念,了解其中的不同。
简单来说,版本名是展示给用户的信息,它可以随意定义,比如您可以将版本名设置为“假的版本”;版本号是展示给应用自身(或其它应用)逻辑的信息,通俗地说,就是代码用于判断应用版本的依据,为方便判断,它只能是数值,如无特殊需求,您只需确保新的版本号比旧的版本号数值更大即可。

程序在使用两种方式进行判断时稍有差异:
使用版本名时,将对本地版本名及服务端版本名进行比对,如果不同,则提示更新,当本地版本高于服务端版本时,由于判断机制,会导致出现降级的更新提示。
使用版本号时,由于版本号确定是数值,则通过版本号大小进行判断,如果本地版本号小于服务端版本号,则提示更新,不会出现降级的更新提示。

因此,如果您理解并掌握,建议您使用版本号。
您若不理解,也依然建议您使用版本号,您只需了解版本号必须为整数,且该数值新版本必须大于旧版本即可。
不过,决定权在您手中,您更愿意使用版本名还是版本号呢?可以在这个复选框作答。
]])
end
},
},
{
LinearLayout,
layout_height="10dp",
orientation="horizontal",
},
{
EditText,
id="iDownloadUrl",
layout_width="fill",
hint="下载地址",
singleLine=true,
},
{
LinearLayout,
layout_height="10dp",
orientation="horizontal",
},
{
EditText,
id="iChangeLog",
layout_width="fill",
hint="更新日志",
maxLines=5,
},
{
CheckBox,
id="iChangeLogUseHtml",
layout_width="fill",
text="启用HTML支持",
},
{
LinearLayout,
layout_height="10dp",
orientation="horizontal",
},
{
CheckBox,
id="iForce",
layout_width="fill",
text="强制更新",
},
--[[{
LinearLayout,
layout_height="10dp",
orientation="horizontal",
},]]
},
{
LinearLayout,
layout_width="fill",
orientation="vertical",
{
Button,
layout_width="80dp",
layout_height="50dp",
layout_gravity="right",
style="?android:attr/buttonBarButtonStyle",
background="#00000000",
text="提交",

Next
Pg.: 1 2


Back to home | File page

Subscribe | Register | Login | N