| File was renamed from app/src/main/java/com/shsening/autouploadvideos/ActionKuaishou.kt |
| | |
| | | package com.shsening.autouploadvideos |
| | | package com.shsening.autouploadvideos.action |
| | | |
| | | |
| | | import android.app.Instrumentation |
| | | import android.content.Context |
| | | import android.os.SystemClock |
| | | import android.os.Handler |
| | | import com.shsening.autouploadvideos.UploadFragment |
| | | import com.shsening.autouploadvideos.UploadSessionActivity |
| | | import com.shsening.autouploadvideos.utils.Utils |
| | | import com.shsening.autouploadvideos.WebviewUtils |
| | | |
| | | class ActionKuaishou (private var fragment:UploadFragment, private var context:Context, private var threadHandler: Handler, private var videoInfo:Utils.VideoUploadTaskInfo){ |
| | | class ActionKuaishou (private var activity: UploadSessionActivity, private var threadHandler: Handler, private var videoInfo: Utils.VideoUploadTaskInfo) :PlatformActionInterface{ |
| | | |
| | | |
| | | private var webView = fragment.webView |
| | | private var webView = activity.sessionProfileWebView |
| | | |
| | | |
| | | var jsCode_CheckContentLoaded = """ |
| | |
| | | */ |
| | | private fun updatePostDescription(){ |
| | | |
| | | WebviewUtils.addValueToDiv(webView,"#work-description-edit",videoInfo.description) |
| | | WebviewUtils.addValueToDiv(webView, "#work-description-edit", videoInfo.description) |
| | | |
| | | // do not allow download |
| | | WebviewUtils.simpleElementClick(webView,"#setting-tours > div:nth-child(2) > div > label:nth-child(2)") |
| | | WebviewUtils.simpleElementClick( |
| | | webView, |
| | | "#setting-tours > div:nth-child(2) > div > label:nth-child(2)" |
| | | ) |
| | | |
| | | // do not show same city |
| | | WebviewUtils.simpleElementClick(webView,"#setting-tours > div:nth-child(2) > div > label:nth-child(3)") |
| | | WebviewUtils.simpleElementClick( |
| | | webView, |
| | | "#setting-tours > div:nth-child(2) > div > label:nth-child(3)" |
| | | ) |
| | | |
| | | //Scheduled publish |
| | | WebviewUtils.simpleElementClick(webView,"#setting-tours > div:nth-child(4) > div > div > label:nth-child(2)") |
| | | WebviewUtils.simpleElementClick( |
| | | webView, |
| | | "#setting-tours > div:nth-child(4) > div > div > label:nth-child(2)" |
| | | ) |
| | | |
| | | addValueToDatePickerInput(true,"#setting-tours > div:nth-child(4) > div > div:nth-child(2) > div > div > input",videoInfo.datetime) |
| | | // 在主线程中设置延迟执行 |
| | |
| | | } |
| | | |
| | | |
| | | fun checkIfContentLoaded() { |
| | | override fun checkIfContentLoaded() { |
| | | webView.postDelayed({ |
| | | webView.evaluateJavascript(jsCode_CheckContentLoaded) { result -> |
| | | if (result == "true") { |
| | |
| | | } |
| | | |
| | | private fun startToPublishVideo(){ |
| | | WebviewUtils.simpleElementClick(webView,jsPath_PublishVideo) |
| | | WebviewUtils.simpleElementClick(webView, jsPath_PublishVideo) |
| | | checkVideoPublishFinished() |
| | | } |
| | | private fun checkVideoUploadFinished(){ |
| | |
| | | webView.evaluateJavascript(jsCode_PublishVideo_Finished) { result -> |
| | | if (result == "true") { |
| | | // video published successfully!!! |
| | | fragment.startUploadSingleTask() |
| | | activity.checkAndStartNextTask() |
| | | } else { |
| | | // 元素不存在,1秒后再次检查 |
| | | webView.postDelayed({ |
| | |
| | | |
| | | var datetimes = Utils.validateAndReturnDateTime(targetValue) ?: return |
| | | |
| | | var dpPanelText = datetimes[0].toString()+"年"+Utils.getMonthAbbreviation(datetimes[1]); |
| | | var dpPanelText = datetimes[0].toString()+"年"+ Utils.getMonthAbbreviation(datetimes[1]); |
| | | |
| | | var dateRowColum = Utils.getDatePosition(datetimes[0],datetimes[1],datetimes[2])?:return; |
| | | var dateRowColum = Utils.getDatePosition(datetimes[0], datetimes[1], datetimes[2]) ?:return; |
| | | |
| | | val jsCode = """ |
| | | try { |
| | |
| | | |
| | | private fun simulateSwipeAndUploadVideo() { |
| | | val instrumentation = Instrumentation() |
| | | val displayMetrics = context.resources.displayMetrics |
| | | val displayMetrics = activity.resources.displayMetrics |
| | | val width = displayMetrics.widthPixels |
| | | val height = displayMetrics.heightPixels |
| | | |
| | |
| | | Thread { |
| | | Utils.instrumentationSwipe(instrumentation, startX, y, endX, y) |
| | | SystemClock.sleep(500) |
| | | Utils.instrumentationClick(instrumentation, width *4/5f, height *2/ 3f) |
| | | Utils.instrumentationClick(instrumentation, width * 4 / 5f, height * 2 / 3f) |
| | | // back to main thread |
| | | threadHandler.post { |
| | | checkVideoUploadFinished() |