Skip to content

Commit

Permalink
Merge pull request #24 from Mingyueyixi/v1.14/dev
Browse files Browse the repository at this point in the history
V1.14/dev
  • Loading branch information
Mingyueyixi authored Feb 21, 2023
2 parents 192a525 + 5487da5 commit 729ee43
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 21 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ jobs:
distribution: 'temurin'
cache: gradle

# debug
- name: Dump Env
run: env | sort

- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: |
echo "$GITHUB_CONTEXT"
- name: Grant execute permission for gradlew
run: chmod +x gradlew
# - name: Build with Gradle
Expand Down
14 changes: 9 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ def buildInfoJson = {
def lastedCommit = p.text.trim()
p.destroy()

def buildDate = new SimpleDateFormat("YYYY/MM/dd hh:mm:ss").format(new Date())
//github等服务器打包时,因时区不同,格式化的时间与本地时间对不上
//故直接保存毫秒
def buildTime = System.currentTimeMillis()

def gitBranch = currentBranch
def gitCommit = lastedCommit;

def jsonObj = new JSONObject()
jsonObj.put("time", buildDate)
jsonObj.put("time", buildTime)
jsonObj.put("branch", gitBranch)
jsonObj.put("commit", gitCommit)
return jsonObj.toString()
Expand Down Expand Up @@ -64,8 +67,8 @@ android {
applicationId "com.lu.wxmask"
minSdk 24
targetSdk 33
versionCode 14
versionName "1.13"
versionCode 15
versionName "1.14"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Expand Down Expand Up @@ -119,8 +122,9 @@ android {
applicationVariants.all { variant ->
def outputs = variant.outputs
def size = outputs.size()
def commit = new JSONObject(buildInfoJson).optString("commit").substring(0, 6)
outputs.eachWithIndex { Object output, int index ->
def fontName = "maskwechat-v${variant.versionName}-${variant.name}"
def fontName = "maskwechat-v${variant.versionName}-${commit}-${variant.name}"
if (size == 1) {
output.outputFileName = "${fontName}.apk"
} else {
Expand Down
24 changes: 24 additions & 0 deletions app/src/main/java/com/lu/wxmask/MaskAppBuildInfo.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.lu.wxmask

import android.util.Base64
import org.json.JSONObject
import java.text.SimpleDateFormat
import java.util.Locale

class MaskAppBuildInfo(
val buildTime: String,
val branch: String,
val commit: String,
) {
companion object {
fun of(): MaskAppBuildInfo {
val json = JSONObject(Base64.decode(BuildConfig.buildInfoJson64, Base64.DEFAULT).toString(Charsets.UTF_8))
return MaskAppBuildInfo(
SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.getDefault()).format(json.optLong("time")),
json.optString("branch"),
json.optString("commit").substring(0, 11)
)
}
}
}

24 changes: 21 additions & 3 deletions app/src/main/java/com/lu/wxmask/plugin/WXConfigPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;

import com.lu.lposed.api2.XC_MethodHook2;
import com.lu.lposed.api2.XposedHelpers2;
import com.lu.lposed.plugin.IPlugin;
import com.lu.magic.util.GsonUtil;
import com.lu.magic.util.ToastUtil;
import com.lu.magic.util.log.LogUtil;
import com.lu.wxmask.ClazzN;
import com.lu.wxmask.Constrant;
Expand All @@ -19,6 +21,7 @@
import com.lu.wxmask.plugin.ui.ConfigManagerUI;
import com.lu.wxmask.plugin.ui.EditMaskItemUI;
import com.lu.wxmask.plugin.ui.MaskUtil;
import com.lu.wxmask.route.MaskAppRouter;
import com.lu.wxmask.util.AppVersionUtil;
import com.lu.wxmask.util.ConfigUtil;

Expand Down Expand Up @@ -81,12 +84,27 @@ private void onEntryWechatUI(Activity activity, Intent intent) {
new AlertDialog.Builder(activity)
.setIcon(activity.getApplicationInfo().icon)
.setTitle("提示")
.setMessage("当前版本:" + AppVersionUtil.getVersionName() + "(" + AppVersionUtil.getVersionCode() + ")不支持,请到MaskWechat主页查看支持的版本")
.setPositiveButton("知道了", null)
.setMessage("当前WeiXin版本:" + AppVersionUtil.getVersionName() + "(" + AppVersionUtil.getVersionCode() + ")不支持,继续使用极可能无效,请到MaskWechat主页查看支持的版本")
.setNegativeButton("继续使用", (dialog, which) -> {
onEnterConfigUI(activity, intent);
})
.setPositiveButton("糊脸主页", (dialog, which) -> {
try {
String uri = "maskwechat://com.lu.wxmask/page/webView?&url=https://github.com/Mingyueyixi/MaskWechat";
Intent openIntent = Intent.parseUri(uri, Intent.URI_ALLOW_UNSAFE);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
activity.startActivity(openIntent);
} catch (Throwable e) {
ToastUtil.show("打开糊脸主页失败");
}
})
.show();

return;
}
onEnterConfigUI(activity, intent);
}

private void onEnterConfigUI(Activity activity, Intent intent) {
if (pluginMode == Constrant.VALUE_INTENT_PLUGIN_MODE_ADD && !isShowingAddConfigTipUI) {
showAddTipDialog(activity);
} else if (pluginMode == Constrant.VALUE_INTENT_PLUGIN_MODE_MANAGER) {
Expand Down
26 changes: 16 additions & 10 deletions app/src/main/java/com/lu/wxmask/ui/MainFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ import android.content.ComponentName
import android.content.Intent
import android.graphics.Color
import android.os.Bundle
import android.util.Base64
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.google.gson.JsonObject
import com.lu.magic.ui.BaseFragment
import com.lu.magic.ui.LifecycleAutoViewBinding
import com.lu.magic.util.SizeUtil
import com.lu.magic.util.ToastUtil
import com.lu.magic.util.kxt.toElseString
import com.lu.magic.util.log.LogUtil
import com.lu.magic.util.ripple.RectangleRippleBuilder
import com.lu.magic.util.ripple.RippleApplyUtil
import com.lu.magic.util.thread.AppExecutor
import com.lu.wxmask.BuildConfig
import com.lu.wxmask.ClazzN
import com.lu.wxmask.Constrant
import com.lu.wxmask.MaskAppBuildInfo
import com.lu.wxmask.R
import com.lu.wxmask.SelfHook
import com.lu.wxmask.adapter.AbsListAdapter
Expand All @@ -28,15 +28,13 @@ import com.lu.wxmask.config.AppConfigUtil
import com.lu.wxmask.databinding.FragmentMainBinding
import com.lu.wxmask.databinding.ItemIconTextBinding
import com.lu.wxmask.route.MaskAppRouter
import org.json.JSONObject


class MainFragment : BaseFragment() {
private var itemBinding: ItemIconTextBinding by LifecycleAutoViewBinding<MainFragment, ItemIconTextBinding>()
private var mainBinding: FragmentMainBinding by LifecycleAutoViewBinding<MainFragment, FragmentMainBinding>()
private val buildInfoJson by lazy {
JSONObject(Base64.decode(BuildConfig.buildInfoJson64, Base64.DEFAULT).toString(Charsets.UTF_8))
}
private val buildInfo = MaskAppBuildInfo.of()

private val donateCardId = 10086

private var mListAdapter: CommonListAdapter<Int, ItemBindingViewHolder>? = null
Expand Down Expand Up @@ -85,13 +83,16 @@ class MainFragment : BaseFragment() {
}
val position = getItem(position)
if (position == 1) {
vh.binding.tvItemTitleSub2.text = "提交哈希:" + buildInfoJson.optString("commit").subSequence(0, 11)
vh.binding.tvItemTitleSub3.text = "构建时间:" + buildInfoJson.optString("time")
vh.binding.tvItemTitleSub2.text = "代码分支:" + buildInfo.branch
vh.binding.tvItemTitleSub3.text = "提交哈希:" + buildInfo.commit
vh.binding.tvItemTitleSub4.text = "构建时间:" + buildInfo.buildTime
vh.binding.tvItemTitleSub2.visibility = View.VISIBLE
vh.binding.tvItemTitleSub3.visibility = View.VISIBLE
vh.binding.tvItemTitleSub4.visibility = View.VISIBLE
} else {
vh.binding.tvItemTitleSub2.visibility = View.GONE
vh.binding.tvItemTitleSub3.visibility = View.GONE
vh.binding.tvItemTitleSub4.visibility = View.GONE
}

when (position) {
Expand Down Expand Up @@ -121,9 +122,14 @@ class MainFragment : BaseFragment() {
}

donateCardId -> {
val donateCard = AppConfigUtil.config.mainUi?.donateCard
vh.binding.tvItemTitle.text = donateCard?.title.toElseString(
getString(R.string.donate)
)
vh.binding.tvItemTitleSub.text = donateCard?.des.toElseString(
getString(R.string.donate_description)
)
vh.binding.ivItemIcon.setImageResource(R.drawable.ic_icon_dollar)
vh.binding.tvItemTitle.setText(R.string.donate)
vh.binding.tvItemTitleSub.setText(R.string.donate_description)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import android.webkit.WebViewClient
import androidx.core.view.contains
import com.lu.magic.util.kxt.toElseEmptyString
import com.lu.magic.util.log.LogUtil
import com.lu.wxmask.BuildConfig
import com.lu.wxmask.route.MaskAppRouter
import java.net.URL

Expand All @@ -33,6 +34,9 @@ class WebViewComponent(context: Context) {
val webView = WebView(context)

init {
if (BuildConfig.DEBUG) {
WebView.setWebContentsDebuggingEnabled(true)
}
webView.settings.let {
it.domStorageEnabled = true
it.javaScriptEnabled = true
Expand Down
13 changes: 11 additions & 2 deletions app/src/main/res/layout/item_icon_text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
android:layout_marginStart="8dp"
android:gravity="left"
android:textSize="14sp"
tools:text="commit: c1271c3e" />
tools:text="代码分支: main" />

<TextView
android:id="@+id/tvItemTitleSub3"
Expand All @@ -69,7 +69,16 @@
android:layout_marginStart="8dp"
android:gravity="left"
android:textSize="14sp"
tools:text="日期: 2023/02/17" />
tools:text="提交哈希: c1271c3e" />

<TextView
android:id="@+id/tvItemTitleSub4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:gravity="left"
android:textSize="14sp"
tools:text="构建时间: 2023/02/17" />

</LinearLayout>

Expand Down
2 changes: 1 addition & 1 deletion res/raw/app_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"mainUi": {
"donateCard": {
"title": "打赏",
"des": "万水千山总是情,打赏一点也是情",
"des": "江湖冷暖总是情,鸡毛鸡粪也可行",
"show": true
},
"moduleCard": {
Expand Down

0 comments on commit 729ee43

Please sign in to comment.