new logo settings

This commit is contained in:
JerryXiao 2023-11-24 01:24:39 +08:00
parent c1e6416c93
commit fabf362157
Signed by: Jerry
GPG key ID: 22618F758B5BE2E5
5 changed files with 69 additions and 11 deletions

View file

@ -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);

View file

@ -0,0 +1,24 @@
<!--
Copyright (C) 2021 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="128dp"
android:height="128dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@color/system_accent3_500"
android:pathData="M11,0.3c0.6,-0.3 1.4,-0.3 2,0l0.6,0.4c0.7,0.4 1.4,0.6 2.2,0.6l0.7,-0.1c0.7,0 1.4,0.3 1.8,0.9l0.3,0.6c0.4,0.7 1,1.2 1.7,1.5L21,4.5c0.7,0.3 1.1,0.9 1.2,1.7v0.7C22.2,7.7 22.5,8.4 23,9l0.4,0.5c0.4,0.6 0.5,1.3 0.2,2l-0.3,0.6c-0.3,0.7 -0.4,1.5 -0.3,2.3l0.1,0.7c0.1,0.7 -0.2,1.4 -0.7,1.9L22,17.5c-0.6,0.5 -1.1,1.1 -1.3,1.9L20.5,20c-0.2,0.7 -0.8,1.2 -1.5,1.4l-0.7,0.1c-0.8,0.2 -1.4,0.5 -2,1.1l-0.5,0.5c-0.5,0.5 -1.3,0.7 -2,0.5l-0.6,-0.2c-0.8,-0.2 -1.5,-0.2 -2.3,0l-0.6,0.2c-0.7,0.2 -1.5,0 -2,-0.5l-0.5,-0.5c-0.5,-0.5 -1.2,-0.9 -2,-1.1L5,21.4c-0.7,-0.2 -1.3,-0.7 -1.5,-1.4l-0.2,-0.7C3.1,18.6 2.6,18 2,17.5l-0.6,-0.4c-0.6,-0.5 -0.8,-1.2 -0.7,-1.9l0.1,-0.7c0.1,-0.8 0,-1.6 -0.3,-2.3l-0.3,-0.6c-0.3,-0.7 -0.2,-1.4 0.2,-2L1,9c0.5,-0.6 0.7,-1.4 0.8,-2.2V6.2C1.9,5.5 2.3,4.8 3,4.5l0.6,-0.3c0.7,-0.3 1.3,-0.9 1.7,-1.5l0.3,-0.6c0.4,-0.6 1.1,-1 1.8,-0.9l0.7,0.1c0.8,0 1.6,-0.2 2.2,-0.6L11,0.3z" />
</vector>

View file

@ -9,4 +9,6 @@
<string name="permission_denied_read_external_storage">读取存储空间权限被拒绝,壁纸将不会显示</string>
<string name="error_title">错误</string>
<string name="button_ok"></string>
</resources>
<string name="show_logo_title">显示徽标</string>
<string name="logo_text_title">自定义徽标文字</string>
</resources>

View file

@ -8,4 +8,6 @@
<string name="permission_denied_read_external_storage">Storage read permission denied, wallpaper can\'t be shown</string>
<string name="error_title">Error occurred</string>
<string name="button_ok">OK</string>
<string name="show_logo_title">Show logo</string>
<string name="logo_text_title">Custom text in logo</string>
</resources>

View file

@ -8,6 +8,16 @@
app:title="@string/dim_screen_title"
app:defaultValue="false" />
<SwitchPreferenceCompat
app:key="show_logo"
app:title="@string/show_logo_title"
app:defaultValue="true" />
<EditTextPreference
app:key="logo_text"
app:title="@string/logo_text_title"
app:defaultValue=""
app:useSimpleSummaryProvider="true" />
<ListPreference
app:defaultValue="10"