Skip to content

Commit

Permalink
feat(BREAK): updated to AndroidX
Browse files Browse the repository at this point in the history
  • Loading branch information
MoonLeeeaf committed Jan 13, 2025
1 parent ae701c3 commit b45ca8b
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 48 deletions.
71 changes: 58 additions & 13 deletions .androidide/editor/openedFiles.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,77 @@
{
"allFiles": [
{
"file": "/storage/emulated/0/MoonLeaf/Projects/MndroLua/app/src/main/java/com/luaeditor2/common/AutoIndent.java",
"file": "/storage/emulated/0/MoonLeaf/Projects/MndroLua/moon3/src/main/java/moon3/app/Activity.java",
"selection": {
"end": {
"column": 63,
"index": 3208,
"line": 108
"column": 23,
"index": 4991,
"line": 159
},
"start": {
"column": 63,
"index": 3208,
"line": 108
"column": 23,
"index": 4991,
"line": 159
}
}
},
{
"file": "/storage/emulated/0/MoonLeaf/Projects/MndroLua/app/src/main/java/com/androlua/LuaActivity.java",
"selection": {
"end": {
"column": 32,
"index": 11613,
"line": 325
},
"start": {
"column": 32,
"index": 11613,
"line": 325
}
}
},
{
"file": "/storage/emulated/0/MoonLeaf/Projects/MndroLua/readme.md",
"selection": {
"end": {
"column": 10,
"index": 761,
"line": 27
},
"start": {
"column": 10,
"index": 761,
"line": 27
}
}
},
{
"file": "/storage/emulated/0/MoonLeaf/Projects/MndroLua/moon3/build.gradle",
"selection": {
"end": {
"column": 22,
"index": 216,
"line": 13
},
"start": {
"column": 22,
"index": 216,
"line": 13
}
}
},
{
"file": "/storage/emulated/0/MoonLeaf/Projects/MndroLua/app/build.gradle",
"selection": {
"end": {
"column": 9,
"index": 1457,
"line": 62
"column": 21,
"index": 389,
"line": 15
},
"start": {
"column": 9,
"index": 1457,
"line": 62
"column": 21,
"index": 389,
"line": 15
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
// 然而我需要最低兼容 sdk21, Shizuku并非必须
// 本程序所生成的软件将不能提交给 Google play(至少和我没任何关系)
targetSdk 30
versionCode 20000
versionName "2.0.0"
versionCode 30000
versionName "3.0.0"

vectorDrawables {
useSupportLibrary true
Expand Down Expand Up @@ -84,13 +84,15 @@ dependencies {
implementation 'com.android.support:support-annotations:28.0.0'

implementation project(":moon3")
implementation('androidx.appcompat:appcompat:1.1.0')

// Libraries
implementation 'org.lsposed.hiddenapibypass:hiddenapibypass:4.3'
implementation "dev.rikka.shizuku:api:13.1.5"
implementation "dev.rikka.shizuku:provider:13.1.5"

// Libraries & apk packing
implementation "net.lingala.zip4j:zip4j:2.11.5"

implementation "org.jdom:jdom:2.0.2"

implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/assets/javaapi/fiximport.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import "android.content.*"
import "layout"
classes=require "android"
activity.setTitle('需要导入的类')
import "autotheme"
activity.setTheme(autotheme())
activity.useDynamicColors()
--import "autotheme"
--activity.setTheme(autotheme())
activity.setContentView(loadlayout(layout))


function fiximport(path)
require "import"
import "android.app.*"
Expand Down
19 changes: 11 additions & 8 deletions app/src/main/assets/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ function onVersionChanged(n, o)
local dlg = MaterialDialog(activity)
local title = "欢迎回家~"
local msg = [[
MndroLua 3.0.0
破坏性修改: 本项目迁移 AndroidX, 所有的旧方法应该被修改 例如 getActionBar -> getSupportActionBar
MndroLua 2.0.0
Editor:
- 运行代码前只针对 .lua .aly 检查语法错误, 并不再直接跳转语法错误所在行(用 Snackbar Action 取代)
Expand Down Expand Up @@ -683,7 +686,7 @@ if e then
end
activity.getWindow().setSoftInputMode(0x10)

--activity.getActionBar().show()
--activity.getSupportActionBar().show()
history = {}
luahist = luajava.luadir .. "/lua.hist"
luadir = luajava.luaextdir .. "/" or "/sdcard/Document/MndroLua/"
Expand All @@ -704,7 +707,7 @@ if luaproject then
end
end

activity.getActionBar().setDisplayShowHomeEnabled(false)
-- activity.getSupportActionBar().setDisplayShowHomeEnabled(false)
luabindir = luajava.luaextdir .. "/bin/"
code = [===[
require "import"
Expand Down Expand Up @@ -951,7 +954,7 @@ function read(path)
end
editor.setText(str)

activity.getActionBar().setSubtitle(".." .. path:match("(/[^/]+/[^/]+)$"))
activity.getSupportActionBar().setSubtitle(".." .. path:match("(/[^/]+/[^/]+)$"))
luapath = path
if history[luapath] then
editor.setSelection(history[luapath])
Expand All @@ -967,7 +970,7 @@ function read(path)
write(luaconf, string.format("luapath=%q", path))
if luaproject and path:find(luaproject, 1, true) then
--FastToast.shortSnack(activity,"打开文件.").show()
activity.getActionBar().setSubtitle(path:sub(#luaproject))
activity.getSupportActionBar().setSubtitle(path:sub(#luaproject))
return
end

Expand All @@ -985,7 +988,7 @@ function read(path)
if e then
activity.setTitle(tostring(p.appname))
luaproject = dir
activity.getActionBar().setSubtitle(path:sub(#luaproject))
activity.getSupportActionBar().setSubtitle(path:sub(#luaproject))
write(luaproj, string.format("luaproject=%q", luaproject))
--FastToast.shortSnack(activity,"打开工程.").show()
else
Expand Down Expand Up @@ -1040,7 +1043,7 @@ function create_lua()
FastToast.shortSnack(activity,"打开文件: ".. luapath).show()
end
write(luaconf, string.format("luapath=%q", luapath))
activity.getActionBar().setSubtitle(".." .. luapath:match("(/[^/]+/[^/]+)$"))
activity.getSupportActionBar().setSubtitle(".." .. luapath:match("(/[^/]+/[^/]+)$"))
--create_dlg.hide()
end

Expand Down Expand Up @@ -1069,7 +1072,7 @@ function create_aly()
FastToast.shortSnack(activity,"打开文件: ".. luapath).show()
end
write(luaconf, string.format("luapath=%q", luapath))
activity.getActionBar().setSubtitle(".." .. luapath:match("(/[^/]+/[^/]+)$"))
activity.getSupportActionBar().setSubtitle(".." .. luapath:match("(/[^/]+/[^/]+)$"))
--create_dlg.hide()
end

Expand All @@ -1087,7 +1090,7 @@ function create_file()
FastToast.shortSnack(activity,"打开文件: ".. luapath).show()
end
write(luaconf, string.format("luapath=%q", luapath))
activity.getActionBar().setSubtitle(".." .. luapath:match("(/[^/]+/[^/]+)$"))
activity.getSupportActionBar().setSubtitle(".." .. luapath:match("(/[^/]+/[^/]+)$"))
--create_dlg.hide()
end

Expand Down
17 changes: 15 additions & 2 deletions app/src/main/java/com/androlua/LuaActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.view.WindowManager;
import android.webkit.MimeTypeMap;
import android.widget.ArrayListAdapter;
Expand Down Expand Up @@ -322,6 +323,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
if (onAccessibilityEvent.isFunction())
LuaAccessibilityService.onAccessibilityEvent = onAccessibilityEvent.getFunction();

invalidateOptionsMenu();
}

public void setFragment(Fragment fragment) {
Expand Down Expand Up @@ -965,20 +967,29 @@ public boolean onTouchEvent(MotionEvent event) {
return super.onTouchEvent(event);
}

// byd 这方法 不会主动调用
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// TODO: Implement this method
optionsMenu = menu;
runFunc("onCreateOptionsMenu", menu);
return super.onCreateOptionsMenu(menu);
Object ret = runFunc("onCreateOptionsMenu", menu);
// 不返回true的话 Memu是不会更新的
// 直接向前兼容得了
// if (ret != null && ret.getClass() == Boolean.class && (Boolean) ret)
return true;
// return super.onCreateOptionsMenu(menu);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {

// TODO: Implement this method
Object ret = null;
if (!item.hasSubMenu())
ret = runFunc("onOptionsItemSelected", item);
// 看不懂啥是featureId 凑合用用
if (!item.hasSubMenu())
runFunc("onMenuItemSelected", Window.FEATURE_OPTIONS_PANEL, item);
if (ret != null && ret.getClass() == Boolean.class && (Boolean) ret)
return true;
return super.onOptionsItemSelected(item);
Expand All @@ -988,13 +999,15 @@ public Menu getOptionsMenu() {
return optionsMenu;
}

/*
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
// TODO: Implement this method
if (!item.hasSubMenu())
runFunc("onMenuItemSelected", featureId, item);
return super.onMenuItemSelected(featureId, item);
}
*/

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
Expand Down
6 changes: 3 additions & 3 deletions moon3/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
// applicationId "moon3"
minSdk 21
targetSdk 34
versionCode 12000
versionName "1.2.0"
versionCode 20000
versionName "2.0.0"

vectorDrawables {
useSupportLibrary true
Expand All @@ -39,11 +39,11 @@ android {
}

dependencies {

// Moon3
implementation('com.google.android.material:material:1.10.0')
implementation('androidx.swiperefreshlayout:swiperefreshlayout:1.1.0')
implementation('androidx.viewpager:viewpager:1.0.0')
implementation('androidx.appcompat:appcompat:1.1.0')

implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
}
Loading

0 comments on commit b45ca8b

Please sign in to comment.