diff --git a/app/src/main/java/com/jerryxiao/easterdream13/EasterDream.java b/app/src/main/java/com/jerryxiao/easterdream13/EasterDream.java index f6936fc..7a47fc9 100644 --- a/app/src/main/java/com/jerryxiao/easterdream13/EasterDream.java +++ b/app/src/main/java/com/jerryxiao/easterdream13/EasterDream.java @@ -22,12 +22,13 @@ import android.util.DisplayMetrics; import android.util.Log; import android.view.Gravity; import android.view.View; -import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.ImageView; import androidx.annotation.ChecksSdkIntAtLeast; +import androidx.appcompat.widget.AppCompatTextView; import androidx.core.app.ActivityCompat; +import androidx.core.widget.TextViewCompat; import androidx.preference.PreferenceManager; import java.util.ArrayList; @@ -36,6 +37,7 @@ import java.util.Timer; import java.util.TimerTask; public class EasterDream extends DreamService { + private static final float i_sqrt2_adj = (float) (1.0/Math.sqrt(2)) * 0.95f; private static String TAG = "EasterDream"; private SharedPreferences prefs; @@ -44,8 +46,6 @@ public class EasterDream extends DreamService { private FrameLayout lastDreamLayout = null; private boolean enabled = false; public void refresh() { - final ImageView mLogo; - final BubblesDrawable mBg; final FrameLayout dreamLayout = new FrameLayout(this); dreamLayout.setVisibility(View.GONE); @@ -57,14 +57,35 @@ public class EasterDream extends DreamService { final FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(widgetSize, widgetSize); lp.gravity = Gravity.CENTER; - mLogo = new ImageView(this); - mLogo.setVisibility(View.GONE); - mLogo.setImageResource(R.drawable.t_platlogo); - dreamLayout.addView(mLogo, lp); + final String logoString = prefs.getString("logo_text", ""); + final boolean showLogo = prefs.getBoolean("show_logo", true); - mBg = new BubblesDrawable(this); + if (showLogo) { + final ImageView mLogo = new ImageView(this); + mLogo.setVisibility(View.GONE); + mLogo.setImageResource(logoString.isEmpty() ? R.drawable.t_platlogo : R.drawable.t_platlogo_empty); + dreamLayout.addView(mLogo, lp); + mLogo.setVisibility(View.VISIBLE); + + if (!logoString.isEmpty()) { + final AppCompatTextView logoText = new AppCompatTextView(this); + logoText.setVisibility(View.GONE); + logoText.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL); + TextViewCompat.setAutoSizeTextTypeWithDefaults(logoText, TextViewCompat.AUTO_SIZE_TEXT_TYPE_UNIFORM); + logoText.setText(logoString); + logoText.setTextColor(0xffd6d6d6); + logoText.setBackgroundColor(0x00000000); + final int widgetSize2 = (int) (widgetSize * i_sqrt2_adj); + final FrameLayout.LayoutParams lp2 = new FrameLayout.LayoutParams(widgetSize2, widgetSize2); + lp2.gravity = Gravity.CENTER; + dreamLayout.addView(logoText, lp2); + logoText.setVisibility(View.VISIBLE); + } + } + + final BubblesDrawable mBg = new BubblesDrawable(this); mBg.setLevel(0); - mBg.avoid = widgetSize / 2; + mBg.avoid = showLogo ? widgetSize / 2 : 0; mBg.padding = 0.5f * dp; mBg.minR = 1 * dp; if (wallPaperDrawable != null) { @@ -75,7 +96,6 @@ public class EasterDream extends DreamService { } mBg.chooseEmojiSet(); - mLogo.setVisibility(View.VISIBLE); mBg.setLevel(10000); diff --git a/app/src/main/res/drawable/t_platlogo_empty.xml b/app/src/main/res/drawable/t_platlogo_empty.xml new file mode 100644 index 0000000..b60cac2 --- /dev/null +++ b/app/src/main/res/drawable/t_platlogo_empty.xml @@ -0,0 +1,24 @@ + + + + diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index a503682..c08e338 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -9,4 +9,6 @@ 读取存储空间权限被拒绝,壁纸将不会显示 错误 - \ No newline at end of file + 显示徽标 + 自定义徽标文字 + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index adbd129..6a629e7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -8,4 +8,6 @@ Storage read permission denied, wallpaper can\'t be shown Error occurred OK + Show logo + Custom text in logo diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 14ba8a1..1455c0f 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -8,6 +8,16 @@ app:title="@string/dim_screen_title" app:defaultValue="false" /> + + +