feat: 大幅增强原生行为 — 修复P0 Bug + 补全核心API
P0 Bug 修复: - Canvas.drawBitmap 重复定义导致重载丢失 → 合并为*args重载 - String.hashCode() 不可达的第二return → 修复为单return - File.compareTo() 调用不存在的__cmp__ → 改为显式比较 - HashMap.remove() 逻辑错误 → 区分单参(返回旧值)/双参(返回boolean) P1 核心行为增强: - Handler: sendMessage/sendMessageDelayed 现在真正入队异步执行 - Looper: loop() 实现真正的消息循环(按when时间取出到期消息) - AsyncTask: execute() 在后台线程池执行,完成后主线程回调 - Bundle: 新增12个数组类型put/get方法 - Math.round: 改为Java语义(floor(a+0.5))而非Python银行家舍入 - Thread: currentThread()缓存对象, 新增join/getState/getId/getPriority - String: 新增strip/repeat/isBlank/lines/subSequence/getChars/chars/formatted/translateEscapes P2 缺失API补全: - 新增21个Java标准Exception类 (NullPointerException等) - View: 新增39个事件处理/监听器/位置尺寸方法 - Activity: 新增33个生命周期/权限/UI方法 - Context: 新增22个文件流/权限/资源/主题方法 - Canvas: 支持 Canvas(Bitmap) 构造函数重载 - __init__.py: __all__ 补全Exception体系和Activity类
This commit is contained in:
1 parent
4645015004
commit
8c3bd3c415
9 files changed
+1017
-52
No files matched your search
@@ -1698,6 +1698,129 @@ class Activity(Stub):
|
||||
def onPictureInPictureModeChanged(self, is_in_pip_mode: bool, new_config):
|
||||
pass
|
||||
|
||||
# ─── 生命周期 (扩展) ───────────────────────────────────────
|
||||
|
||||
def onPostCreate(self, savedInstanceState):
|
||||
pass
|
||||
|
||||
def onPostResume(self):
|
||||
pass
|
||||
|
||||
def onUserLeaveHint(self):
|
||||
pass
|
||||
|
||||
def onUserInteraction(self):
|
||||
pass
|
||||
|
||||
def onCreateContextMenu(self, menu, v, menuInfo):
|
||||
pass
|
||||
|
||||
def onContextMenuClosed(self, menu):
|
||||
pass
|
||||
|
||||
def onContextItemSelected(self, item):
|
||||
return False
|
||||
|
||||
def onWindowFocusChanged(self, hasFocus):
|
||||
pass
|
||||
|
||||
def onWindowAttributesChanged(self, params):
|
||||
pass
|
||||
|
||||
def onContentChanged(self):
|
||||
pass
|
||||
|
||||
def onAttachedToWindow(self):
|
||||
pass
|
||||
|
||||
def onDetachedFromWindow(self):
|
||||
pass
|
||||
|
||||
def onTitleChanged(self, title, color):
|
||||
pass
|
||||
|
||||
# ─── 权限 (扩展) ───────────────────────────────────────────
|
||||
|
||||
def requestPermissions(self, permissions, requestCode):
|
||||
pass
|
||||
|
||||
def checkSelfPermission(self, permission):
|
||||
return 0 # PERMISSION_GRANTED
|
||||
|
||||
def shouldShowRequestPermissionRationale(self, permission):
|
||||
return False
|
||||
|
||||
# ─── UI (扩展) ─────────────────────────────────────────────
|
||||
|
||||
def getWindow(self):
|
||||
if not hasattr(self, '_window'):
|
||||
from .view import Window
|
||||
self._window = Window()
|
||||
return self._window
|
||||
|
||||
def getWindowManager(self):
|
||||
if not hasattr(self, '_window_manager'):
|
||||
from .view import WindowManager
|
||||
self._window_manager = WindowManager()
|
||||
return self._window_manager
|
||||
|
||||
def setRequestedOrientation(self, requestedOrientation):
|
||||
self._requested_orientation = requestedOrientation
|
||||
|
||||
def getRequestedOrientation(self):
|
||||
return getattr(self, '_requested_orientation', 0)
|
||||
|
||||
def runOnUiThread(self, action):
|
||||
import threading
|
||||
# 在桌面环境直接执行
|
||||
action()
|
||||
|
||||
def overridePendingTransition(self, enterAnim, exitAnim):
|
||||
pass
|
||||
|
||||
def getActionBar(self):
|
||||
return getattr(self, '_action_bar', None)
|
||||
|
||||
def setActionBar(self, toolbar):
|
||||
self._action_bar = toolbar
|
||||
|
||||
def getMenuInflater(self):
|
||||
from .view import MenuInflater
|
||||
return MenuInflater()
|
||||
|
||||
def onCreateOptionsMenu(self, menu):
|
||||
return True
|
||||
|
||||
def onPrepareOptionsMenu(self, menu):
|
||||
return True
|
||||
|
||||
def onOptionsItemSelected(self, item):
|
||||
return False
|
||||
|
||||
def registerForContextMenu(self, view):
|
||||
pass
|
||||
|
||||
def unregisterForContextMenu(self, view):
|
||||
pass
|
||||
|
||||
def openContextMenu(self, view):
|
||||
pass
|
||||
|
||||
def finishAffinity(self):
|
||||
self.finish()
|
||||
|
||||
def invalidateOptionsMenu(self):
|
||||
pass
|
||||
|
||||
def setVisible(self, visible):
|
||||
self._visible = visible
|
||||
|
||||
def setTheme(self, resid):
|
||||
self._theme = resid
|
||||
|
||||
def getTheme(self):
|
||||
return getattr(self, '_theme', 0)
|
||||
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# Service
|
||||
|
||||
Reference in new issue
Block a user