自定义了com.github.QuadFlask:colorpicker:0.0.15调色盘库
优化修复BUG
This commit is contained in:
parent
ed4145fb2d
commit
8aafd056be
10
.idea/deploymentTargetDropDown.xml
Normal file
10
.idea/deploymentTargetDropDown.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetDropDown">
|
||||
<value>
|
||||
<entry key="app">
|
||||
<State />
|
||||
</entry>
|
||||
</value>
|
||||
</component>
|
||||
</project>
|
|
@ -1,19 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="testRunner" value="GRADLE" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="jbr-17" />
|
||||
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/StatusBarUtil" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveExternalAnnotations" value="false" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
|
|
|
@ -1,77 +0,0 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="AndroidLintContentDescription" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="AndroidLintHardcodedText" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="AndroidLintNonConstantResourceId" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="AndroidLintSetTextI18n" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="ArgumentSelectionDefects" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="ArrayIndexOutOfBounds" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="AutoCloseableResource" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="METHOD_MATCHER_CONFIG" value="java.util.Formatter,format,java.io.Writer,append,com.google.common.base.Preconditions,checkNotNull,org.hibernate.Session,close,java.io.PrintWriter,printf,java.io.PrintStream,printf,okhttp3.Call,execute,android.app.DownloadManager,query,android.content.Context,obtainStyledAttributes" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="ClangTidy" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="ClangdErrorsAndWarnings" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="Clazy" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="ConstantConditionsOC" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="ConstantFunctionResult" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="ConstantParameter" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="DanglingPointer" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="DataFlowIssue" enabled="false" level="WARNING" enabled_by_default="false">
|
||||
<option name="SUGGEST_NULLABLE_ANNOTATIONS" value="false" />
|
||||
<option name="DONT_REPORT_TRUE_ASSERT_STATEMENTS" value="false" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="DeprecatedApi" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="DuplicateSwitchCase" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="EmptyDeclOrStmt" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="EndlessLoop" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="EqualityInConditionalOperator" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="FormatSpecifiers" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="FunctionImplicitDeclaration" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="HidesUpperScope" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="HidingNonVirtualFunction" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="IgnoreResultOfCall" enabled="false" level="WARNING" enabled_by_default="false">
|
||||
<option name="m_reportAllNonLibraryCalls" value="false" />
|
||||
<option name="callCheckString" value="java.io.File,.*,java.io.InputStream,read|skip|available|markSupported,java.io.Reader,read|skip|ready|markSupported,java.lang.AbstractStringBuilder,capacity|codePointAt|codePointBefore|codePointCount|indexOf|lastIndexOf|offsetByCodePoints|substring|subSequence,java.lang.Boolean,.*,java.lang.Byte,.*,java.lang.Character,.*,java.lang.Double,.*,java.lang.Float,.*,java.lang.Integer,.*,java.lang.Long,.*,java.lang.Math,.*,java.lang.Object,equals|hashCode|toString,java.lang.Short,.*,java.lang.StrictMath,.*,java.lang.String,.*,java.lang.Thread,interrupted,java.math.BigDecimal,.*,java.math.BigInteger,.*,java.net.InetAddress,.*,java.net.URI,.*,java.nio.channels.AsynchronousChannelGroup,.*,java.util.Arrays,.*,java.util.Collections,(?!addAll).*,java.util.List,of,java.util.Map,of|ofEntries|entry,java.util.Set,of,java.util.UUID,.*,java.util.concurrent.BlockingQueue,offer|remove,java.util.concurrent.CountDownLatch,await|getCount,java.util.concurrent.ExecutorService,awaitTermination|isShutdown|isTerminated,java.util.concurrent.ForkJoinPool,awaitQuiescence,java.util.concurrent.Semaphore,tryAcquire|availablePermits|isFair|hasQueuedThreads|getQueueLength|getQueuedThreads,java.util.concurrent.locks.Condition,await|awaitNanos|awaitUntil,java.util.concurrent.locks.Lock,tryLock|newCondition,java.util.regex.Matcher,pattern|toMatchResult|start|end|group|groupCount|matches|find|lookingAt|quoteReplacement|replaceAll|replaceFirst|regionStart|regionEnd|hasTransparentBounds|hasAnchoringBounds|hitEnd|requireEnd,java.util.regex.Pattern,.*,java.util.stream.BaseStream,.*,java.util.stream.DoubleStream,.*,java.util.stream.IntStream,.*,java.util.stream.LongStream,.*,java.util.stream.Stream,.*" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="ImplicitIntegerAndEnumConversion" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="ImplicitPointerAndIntegerConversion" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="IncompatibleEnums" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="IncompatibleInitializers" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="IncompatiblePointers" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="InnerClassMayBeStatic" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="KRUnspecifiedParameters" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="LocalValueEscapesScope" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="LoopDoesntUseConditionVariable" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="MissingReturn" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="MissingSwitchCase" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="NotImplementedFunctions" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="NotInitializedVariable" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="NotSuperclass" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="NullDereference" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="OCUnusedConcept" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="OCUnusedGlobalDeclaration" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="OCUnusedMacro" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="OCUnusedStruct" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="OCUnusedTemplateParameter" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="OCUnusedTypeAlias" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="PreprocessorComment" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="ResourceNotFound" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="SignednessMismatch" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="Simplify" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
|
||||
<option name="processCode" value="true" />
|
||||
<option name="processLiterals" value="true" />
|
||||
<option name="processComments" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="UnreachableCallsOfFunction" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="UnreachableCode" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="UnusedExpressionResult" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="UnusedLocalVariable" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="UnusedParameter" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="UnusedReturnValue" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="UnusedValue" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="ValueMayNotFitIntoReceiver" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="VirtualCallInCtorOrDtor" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
</profile>
|
||||
</component>
|
10
.idea/migrations.xml
Normal file
10
.idea/migrations.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectMigrations">
|
||||
<option name="MigrateToGradleLocalJavaHome">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
|
@ -1,11 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK" />
|
||||
<component name="VisualizationToolProject">
|
||||
<option name="state">
|
||||
<ProjectState>
|
||||
<option name="scale" value="0.3309002433090024" />
|
||||
</ProjectState>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
1
StatusBarUtil/.gitignore
vendored
Normal file
1
StatusBarUtil/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/build
|
25
StatusBarUtil/build.gradle
Normal file
25
StatusBarUtil/build.gradle
Normal file
|
@ -0,0 +1,25 @@
|
|||
apply plugin: 'com.android.library'
|
||||
version = "1.5.1"
|
||||
android {
|
||||
namespace 'com.jaeger.library'
|
||||
compileSdk 34
|
||||
resourcePrefix "statusbarutil_"
|
||||
defaultConfig {
|
||||
minSdkVersion 14
|
||||
//noinspection ExpiredTargetSdkVersion
|
||||
targetSdk 31
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||
implementation 'com.google.android.material:material:1.9.0'
|
||||
}
|
17
StatusBarUtil/proguard-rules.pro
vendored
Normal file
17
StatusBarUtil/proguard-rules.pro
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in /Users/Jaeger/Develop/android/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
6
StatusBarUtil/src/main/AndroidManifest.xml
Normal file
6
StatusBarUtil/src/main/AndroidManifest.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.jaeger.library">
|
||||
|
||||
<application />
|
||||
|
||||
</manifest>
|
|
@ -0,0 +1,726 @@
|
|||
package com.jaeger.library;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.IntRange;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* Created by Jaeger on 16/2/14.
|
||||
* <p>
|
||||
* Email: chjie.jaeger@gmail.com
|
||||
* GitHub: <a href="https://github.com/laobie">...</a>
|
||||
*/
|
||||
public class StatusBarUtil {
|
||||
|
||||
public static final int DEFAULT_STATUS_BAR_ALPHA = 112;
|
||||
private static final int FAKE_STATUS_BAR_VIEW_ID = R.id.statusbarutil_fake_status_bar_view;
|
||||
private static final int FAKE_TRANSLUCENT_VIEW_ID = R.id.statusbarutil_translucent_view;
|
||||
private static final int TAG_KEY_HAVE_SET_OFFSET = -123;
|
||||
|
||||
/**
|
||||
* 设置状态栏颜色
|
||||
*
|
||||
* @param activity 需要设置的 activity
|
||||
* @param color 状态栏颜色值
|
||||
*/
|
||||
public static void setColor(Activity activity, @ColorInt int color) {
|
||||
setColor(activity, color, DEFAULT_STATUS_BAR_ALPHA);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置状态栏颜色
|
||||
*
|
||||
* @param activity 需要设置的activity
|
||||
* @param color 状态栏颜色值
|
||||
* @param statusBarAlpha 状态栏透明度
|
||||
*/
|
||||
|
||||
public static void setColor(Activity activity, @ColorInt int color, @IntRange(from = 0, to = 255) int statusBarAlpha) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
activity.getWindow().setStatusBarColor(calculateStatusColor(color, statusBarAlpha));
|
||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
|
||||
View fakeStatusBarView = decorView.findViewById(FAKE_STATUS_BAR_VIEW_ID);
|
||||
if (fakeStatusBarView != null) {
|
||||
if (fakeStatusBarView.getVisibility() == View.GONE) {
|
||||
fakeStatusBarView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
fakeStatusBarView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
|
||||
} else {
|
||||
decorView.addView(createStatusBarView(activity, color, statusBarAlpha));
|
||||
}
|
||||
setRootView(activity);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 为滑动返回界面设置状态栏颜色
|
||||
*
|
||||
* @param activity 需要设置的activity
|
||||
* @param color 状态栏颜色值
|
||||
*/
|
||||
public static void setColorForSwipeBack(Activity activity, int color) {
|
||||
setColorForSwipeBack(activity, color, DEFAULT_STATUS_BAR_ALPHA);
|
||||
}
|
||||
|
||||
/**
|
||||
* 为滑动返回界面设置状态栏颜色
|
||||
*
|
||||
* @param activity 需要设置的activity
|
||||
* @param color 状态栏颜色值
|
||||
* @param statusBarAlpha 状态栏透明度
|
||||
*/
|
||||
public static void setColorForSwipeBack(Activity activity, @ColorInt int color,
|
||||
@IntRange(from = 0, to = 255) int statusBarAlpha) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
|
||||
ViewGroup contentView = ((ViewGroup) activity.findViewById(android.R.id.content));
|
||||
View rootView = contentView.getChildAt(0);
|
||||
int statusBarHeight = getStatusBarHeight(activity);
|
||||
if (rootView instanceof CoordinatorLayout) {
|
||||
final CoordinatorLayout coordinatorLayout = (CoordinatorLayout) rootView;
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
coordinatorLayout.setFitsSystemWindows(false);
|
||||
contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
|
||||
boolean isNeedRequestLayout = contentView.getPaddingTop() < statusBarHeight;
|
||||
if (isNeedRequestLayout) {
|
||||
contentView.setPadding(0, statusBarHeight, 0, 0);
|
||||
coordinatorLayout.post(coordinatorLayout::requestLayout);
|
||||
}
|
||||
} else {
|
||||
coordinatorLayout.setStatusBarBackgroundColor(calculateStatusColor(color, statusBarAlpha));
|
||||
}
|
||||
} else {
|
||||
contentView.setPadding(0, statusBarHeight, 0, 0);
|
||||
contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
|
||||
}
|
||||
setTransparentForWindow(activity);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置状态栏纯色 不加半透明效果
|
||||
*
|
||||
* @param activity 需要设置的 activity
|
||||
* @param color 状态栏颜色值
|
||||
*/
|
||||
public static void setColorNoTranslucent(Activity activity, @ColorInt int color) {
|
||||
setColor(activity, color, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置状态栏颜色(5.0以下无半透明效果,不建议使用)
|
||||
*
|
||||
* @param activity 需要设置的 activity
|
||||
* @param color 状态栏颜色值
|
||||
*/
|
||||
@Deprecated
|
||||
public static void setColorDiff(Activity activity, @ColorInt int color) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
|
||||
return;
|
||||
}
|
||||
transparentStatusBar(activity);
|
||||
ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);
|
||||
// 移除半透明矩形,以免叠加
|
||||
View fakeStatusBarView = contentView.findViewById(FAKE_STATUS_BAR_VIEW_ID);
|
||||
if (fakeStatusBarView != null) {
|
||||
if (fakeStatusBarView.getVisibility() == View.GONE) {
|
||||
fakeStatusBarView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
fakeStatusBarView.setBackgroundColor(color);
|
||||
} else {
|
||||
contentView.addView(createStatusBarView(activity, color));
|
||||
}
|
||||
setRootView(activity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 使状态栏半透明
|
||||
* <p>
|
||||
* 适用于图片作为背景的界面,此时需要图片填充到状态栏
|
||||
*
|
||||
* @param activity 需要设置的activity
|
||||
*/
|
||||
public static void setTranslucent(Activity activity) {
|
||||
setTranslucent(activity, DEFAULT_STATUS_BAR_ALPHA);
|
||||
}
|
||||
|
||||
/**
|
||||
* 使状态栏半透明
|
||||
* <p>
|
||||
* 适用于图片作为背景的界面,此时需要图片填充到状态栏
|
||||
*
|
||||
* @param activity 需要设置的activity
|
||||
* @param statusBarAlpha 状态栏透明度
|
||||
*/
|
||||
public static void setTranslucent(Activity activity, @IntRange(from = 0, to = 255) int statusBarAlpha) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
|
||||
return;
|
||||
}
|
||||
setTransparent(activity);
|
||||
addTranslucentView(activity, statusBarAlpha);
|
||||
}
|
||||
|
||||
/**
|
||||
* 针对根布局是 CoordinatorLayout, 使状态栏半透明
|
||||
* <p>
|
||||
* 适用于图片作为背景的界面,此时需要图片填充到状态栏
|
||||
*
|
||||
* @param activity 需要设置的activity
|
||||
* @param statusBarAlpha 状态栏透明度
|
||||
*/
|
||||
public static void setTranslucentForCoordinatorLayout(Activity activity, @IntRange(from = 0, to = 255) int statusBarAlpha) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
|
||||
return;
|
||||
}
|
||||
transparentStatusBar(activity);
|
||||
addTranslucentView(activity, statusBarAlpha);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置状态栏全透明
|
||||
*
|
||||
* @param activity 需要设置的activity
|
||||
*/
|
||||
public static void setTransparent(Activity activity) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
|
||||
return;
|
||||
}
|
||||
transparentStatusBar(activity);
|
||||
setRootView(activity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 使状态栏透明(5.0以上半透明效果,不建议使用)
|
||||
* <p>
|
||||
* 适用于图片作为背景的界面,此时需要图片填充到状态栏
|
||||
*
|
||||
* @param activity 需要设置的activity
|
||||
*/
|
||||
@Deprecated
|
||||
public static void setTranslucentDiff(Activity activity) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
// 设置状态栏透明
|
||||
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
setRootView(activity);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 为DrawerLayout 布局设置状态栏变色
|
||||
*
|
||||
* @param activity 需要设置的activity
|
||||
* @param drawerLayout DrawerLayout
|
||||
* @param color 状态栏颜色值
|
||||
*/
|
||||
public static void setColorForDrawerLayout(Activity activity, DrawerLayout drawerLayout, @ColorInt int color) {
|
||||
setColorForDrawerLayout(activity, drawerLayout, color, DEFAULT_STATUS_BAR_ALPHA);
|
||||
}
|
||||
|
||||
/**
|
||||
* 为DrawerLayout 布局设置状态栏颜色,纯色
|
||||
*
|
||||
* @param activity 需要设置的activity
|
||||
* @param drawerLayout DrawerLayout
|
||||
* @param color 状态栏颜色值
|
||||
*/
|
||||
public static void setColorNoTranslucentForDrawerLayout(Activity activity, DrawerLayout drawerLayout, @ColorInt int color) {
|
||||
setColorForDrawerLayout(activity, drawerLayout, color, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 为DrawerLayout 布局设置状态栏变色
|
||||
*
|
||||
* @param activity 需要设置的activity
|
||||
* @param drawerLayout DrawerLayout
|
||||
* @param color 状态栏颜色值
|
||||
* @param statusBarAlpha 状态栏透明度
|
||||
*/
|
||||
public static void setColorForDrawerLayout(Activity activity, DrawerLayout drawerLayout, @ColorInt int color,
|
||||
@IntRange(from = 0, to = 255) int statusBarAlpha) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
|
||||
return;
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||
} else {
|
||||
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
}
|
||||
// 生成一个状态栏大小的矩形
|
||||
// 添加 statusBarView 到布局中
|
||||
ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
|
||||
View fakeStatusBarView = contentLayout.findViewById(FAKE_STATUS_BAR_VIEW_ID);
|
||||
if (fakeStatusBarView != null) {
|
||||
if (fakeStatusBarView.getVisibility() == View.GONE) {
|
||||
fakeStatusBarView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
fakeStatusBarView.setBackgroundColor(color);
|
||||
} else {
|
||||
contentLayout.addView(createStatusBarView(activity, color), 0);
|
||||
}
|
||||
// 内容布局不是 LinearLayout 时,设置padding top
|
||||
if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) {
|
||||
contentLayout.getChildAt(1)
|
||||
.setPadding(contentLayout.getPaddingLeft(), getStatusBarHeight(activity) + contentLayout.getPaddingTop(),
|
||||
contentLayout.getPaddingRight(), contentLayout.getPaddingBottom());
|
||||
}
|
||||
// 设置属性
|
||||
setDrawerLayoutProperty(drawerLayout, contentLayout);
|
||||
addTranslucentView(activity, statusBarAlpha);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 DrawerLayout 属性
|
||||
*
|
||||
* @param drawerLayout DrawerLayout
|
||||
* @param drawerLayoutContentLayout DrawerLayout 的内容布局
|
||||
*/
|
||||
private static void setDrawerLayoutProperty(DrawerLayout drawerLayout, ViewGroup drawerLayoutContentLayout) {
|
||||
ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1);
|
||||
drawerLayout.setFitsSystemWindows(false);
|
||||
drawerLayoutContentLayout.setFitsSystemWindows(false);
|
||||
drawerLayoutContentLayout.setClipToPadding(true);
|
||||
drawer.setFitsSystemWindows(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 为DrawerLayout 布局设置状态栏变色(5.0以下无半透明效果,不建议使用)
|
||||
*
|
||||
* @param activity 需要设置的activity
|
||||
* @param drawerLayout DrawerLayout
|
||||
* @param color 状态栏颜色值
|
||||
*/
|
||||
@Deprecated
|
||||
public static void setColorForDrawerLayoutDiff(Activity activity, DrawerLayout drawerLayout, @ColorInt int color) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
// 生成一个状态栏大小的矩形
|
||||
ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
|
||||
View fakeStatusBarView = contentLayout.findViewById(FAKE_STATUS_BAR_VIEW_ID);
|
||||
if (fakeStatusBarView != null) {
|
||||
if (fakeStatusBarView.getVisibility() == View.GONE) {
|
||||
fakeStatusBarView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
fakeStatusBarView.setBackgroundColor(calculateStatusColor(color, DEFAULT_STATUS_BAR_ALPHA));
|
||||
} else {
|
||||
// 添加 statusBarView 到布局中
|
||||
contentLayout.addView(createStatusBarView(activity, color), 0);
|
||||
}
|
||||
// 内容布局不是 LinearLayout 时,设置padding top
|
||||
if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) {
|
||||
contentLayout.getChildAt(1).setPadding(0, getStatusBarHeight(activity), 0, 0);
|
||||
}
|
||||
// 设置属性
|
||||
setDrawerLayoutProperty(drawerLayout, contentLayout);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 为 DrawerLayout 布局设置状态栏透明
|
||||
*
|
||||
* @param activity 需要设置的activity
|
||||
* @param drawerLayout DrawerLayout
|
||||
*/
|
||||
public static void setTranslucentForDrawerLayout(Activity activity, DrawerLayout drawerLayout) {
|
||||
setTranslucentForDrawerLayout(activity, drawerLayout, DEFAULT_STATUS_BAR_ALPHA);
|
||||
}
|
||||
|
||||
/**
|
||||
* 为 DrawerLayout 布局设置状态栏透明
|
||||
*
|
||||
* @param activity 需要设置的activity
|
||||
* @param drawerLayout DrawerLayout
|
||||
*/
|
||||
public static void setTranslucentForDrawerLayout(Activity activity, DrawerLayout drawerLayout,
|
||||
@IntRange(from = 0, to = 255) int statusBarAlpha) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
|
||||
return;
|
||||
}
|
||||
setTransparentForDrawerLayout(activity, drawerLayout);
|
||||
addTranslucentView(activity, statusBarAlpha);
|
||||
}
|
||||
|
||||
/**
|
||||
* 为 DrawerLayout 布局设置状态栏透明
|
||||
*
|
||||
* @param activity 需要设置的activity
|
||||
* @param drawerLayout DrawerLayout
|
||||
*/
|
||||
public static void setTransparentForDrawerLayout(Activity activity, DrawerLayout drawerLayout) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
|
||||
return;
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||
} else {
|
||||
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
}
|
||||
|
||||
ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
|
||||
// 内容布局不是 LinearLayout 时,设置padding top
|
||||
if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) {
|
||||
contentLayout.getChildAt(1).setPadding(0, getStatusBarHeight(activity), 0, 0);
|
||||
}
|
||||
|
||||
// 设置属性
|
||||
setDrawerLayoutProperty(drawerLayout, contentLayout);
|
||||
}
|
||||
|
||||
/**
|
||||
* 为 DrawerLayout 布局设置状态栏透明(5.0以上半透明效果,不建议使用)
|
||||
*
|
||||
* @param activity 需要设置的activity
|
||||
* @param drawerLayout DrawerLayout
|
||||
*/
|
||||
@Deprecated
|
||||
public static void setTranslucentForDrawerLayoutDiff(Activity activity, DrawerLayout drawerLayout) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
// 设置状态栏透明
|
||||
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
// 设置内容布局属性
|
||||
ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
|
||||
contentLayout.setFitsSystemWindows(true);
|
||||
contentLayout.setClipToPadding(true);
|
||||
// 设置抽屉布局属性
|
||||
ViewGroup vg = (ViewGroup) drawerLayout.getChildAt(1);
|
||||
vg.setFitsSystemWindows(false);
|
||||
// 设置 DrawerLayout 属性
|
||||
drawerLayout.setFitsSystemWindows(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 为头部是 ImageView 的界面设置状态栏全透明
|
||||
*
|
||||
* @param activity 需要设置的activity
|
||||
* @param needOffsetView 需要向下偏移的 View
|
||||
*/
|
||||
public static void setTransparentForImageView(Activity activity, View needOffsetView) {
|
||||
setTranslucentForImageView(activity, 0, needOffsetView);
|
||||
}
|
||||
|
||||
/**
|
||||
* 为头部是 ImageView 的界面设置状态栏透明(使用默认透明度)
|
||||
*
|
||||
* @param activity 需要设置的activity
|
||||
* @param needOffsetView 需要向下偏移的 View
|
||||
*/
|
||||
public static void setTranslucentForImageView(Activity activity, View needOffsetView) {
|
||||
setTranslucentForImageView(activity, DEFAULT_STATUS_BAR_ALPHA, needOffsetView);
|
||||
}
|
||||
|
||||
/**
|
||||
* 为头部是 ImageView 的界面设置状态栏透明
|
||||
*
|
||||
* @param activity 需要设置的activity
|
||||
* @param statusBarAlpha 状态栏透明度
|
||||
* @param needOffsetView 需要向下偏移的 View
|
||||
*/
|
||||
public static void setTranslucentForImageView(Activity activity, @IntRange(from = 0, to = 255) int statusBarAlpha,
|
||||
View needOffsetView) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
|
||||
return;
|
||||
}
|
||||
setTransparentForWindow(activity);
|
||||
addTranslucentView(activity, statusBarAlpha);
|
||||
if (needOffsetView != null) {
|
||||
Object haveSetOffset = needOffsetView.getTag(TAG_KEY_HAVE_SET_OFFSET);
|
||||
if (haveSetOffset != null && (Boolean) haveSetOffset) {
|
||||
return;
|
||||
}
|
||||
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) needOffsetView.getLayoutParams();
|
||||
layoutParams.setMargins(layoutParams.leftMargin, layoutParams.topMargin + getStatusBarHeight(activity),
|
||||
layoutParams.rightMargin, layoutParams.bottomMargin);
|
||||
needOffsetView.setTag(TAG_KEY_HAVE_SET_OFFSET, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 为 fragment 头部是 ImageView 的设置状态栏透明
|
||||
*
|
||||
* @param activity fragment 对应的 activity
|
||||
* @param needOffsetView 需要向下偏移的 View
|
||||
*/
|
||||
public static void setTranslucentForImageViewInFragment(Activity activity, View needOffsetView) {
|
||||
setTranslucentForImageViewInFragment(activity, DEFAULT_STATUS_BAR_ALPHA, needOffsetView);
|
||||
}
|
||||
|
||||
/**
|
||||
* 为 fragment 头部是 ImageView 的设置状态栏透明
|
||||
*
|
||||
* @param activity fragment 对应的 activity
|
||||
* @param needOffsetView 需要向下偏移的 View
|
||||
*/
|
||||
public static void setTransparentForImageViewInFragment(Activity activity, View needOffsetView) {
|
||||
setTranslucentForImageViewInFragment(activity, 0, needOffsetView);
|
||||
}
|
||||
|
||||
/**
|
||||
* 为 fragment 头部是 ImageView 的设置状态栏透明
|
||||
*
|
||||
* @param activity fragment 对应的 activity
|
||||
* @param statusBarAlpha 状态栏透明度
|
||||
* @param needOffsetView 需要向下偏移的 View
|
||||
*/
|
||||
public static void setTranslucentForImageViewInFragment(Activity activity, @IntRange(from = 0, to = 255) int statusBarAlpha,
|
||||
View needOffsetView) {
|
||||
setTranslucentForImageView(activity, statusBarAlpha, needOffsetView);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
clearPreviousSetting(activity);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 隐藏伪状态栏 View
|
||||
*
|
||||
* @param activity 调用的 Activity
|
||||
*/
|
||||
public static void hideFakeStatusBarView(Activity activity) {
|
||||
ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
|
||||
View fakeStatusBarView = decorView.findViewById(FAKE_STATUS_BAR_VIEW_ID);
|
||||
if (fakeStatusBarView != null) {
|
||||
fakeStatusBarView.setVisibility(View.GONE);
|
||||
}
|
||||
View fakeTranslucentView = decorView.findViewById(FAKE_TRANSLUCENT_VIEW_ID);
|
||||
if (fakeTranslucentView != null) {
|
||||
fakeTranslucentView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.M)
|
||||
public static void setLightMode(Activity activity) {
|
||||
setMIUIStatusBarDarkIcon(activity, true);
|
||||
setMeizuStatusBarDarkIcon(activity, true);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.M)
|
||||
public static void setDarkMode(Activity activity) {
|
||||
setMIUIStatusBarDarkIcon(activity, false);
|
||||
setMeizuStatusBarDarkIcon(activity, false);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改 MIUI V6 以上状态栏颜色
|
||||
*/
|
||||
private static void setMIUIStatusBarDarkIcon(@NonNull Activity activity, boolean darkIcon) {
|
||||
Class<? extends Window> clazz = activity.getWindow().getClass();
|
||||
try {
|
||||
Class<?> layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams");
|
||||
Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE");
|
||||
int darkModeFlag = field.getInt(layoutParams);
|
||||
Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class);
|
||||
extraFlagField.invoke(activity.getWindow(), darkIcon ? darkModeFlag : 0, darkModeFlag);
|
||||
} catch (Exception e) {
|
||||
//e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改魅族状态栏字体颜色 Flyme 4.0
|
||||
*/
|
||||
private static void setMeizuStatusBarDarkIcon(@NonNull Activity activity, boolean darkIcon) {
|
||||
try {
|
||||
WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
|
||||
Field darkFlag = WindowManager.LayoutParams.class.getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON");
|
||||
Field meizuFlags = WindowManager.LayoutParams.class.getDeclaredField("meizuFlags");
|
||||
darkFlag.setAccessible(true);
|
||||
meizuFlags.setAccessible(true);
|
||||
int bit = darkFlag.getInt(null);
|
||||
int value = meizuFlags.getInt(lp);
|
||||
if (darkIcon) {
|
||||
value |= bit;
|
||||
} else {
|
||||
value &= ~bit;
|
||||
}
|
||||
meizuFlags.setInt(lp, value);
|
||||
activity.getWindow().setAttributes(lp);
|
||||
} catch (Exception e) {
|
||||
//e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.KITKAT)
|
||||
private static void clearPreviousSetting(Activity activity) {
|
||||
ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
|
||||
View fakeStatusBarView = decorView.findViewById(FAKE_STATUS_BAR_VIEW_ID);
|
||||
if (fakeStatusBarView != null) {
|
||||
decorView.removeView(fakeStatusBarView);
|
||||
ViewGroup rootView = (ViewGroup) ((ViewGroup) activity.findViewById(android.R.id.content)).getChildAt(0);
|
||||
rootView.setPadding(0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加半透明矩形条
|
||||
*
|
||||
* @param activity 需要设置的 activity
|
||||
* @param statusBarAlpha 透明值
|
||||
*/
|
||||
private static void addTranslucentView(Activity activity, @IntRange(from = 0, to = 255) int statusBarAlpha) {
|
||||
ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);
|
||||
View fakeTranslucentView = contentView.findViewById(FAKE_TRANSLUCENT_VIEW_ID);
|
||||
if (fakeTranslucentView != null) {
|
||||
if (fakeTranslucentView.getVisibility() == View.GONE) {
|
||||
fakeTranslucentView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
fakeTranslucentView.setBackgroundColor(Color.argb(statusBarAlpha, 0, 0, 0));
|
||||
} else {
|
||||
contentView.addView(createTranslucentStatusBarView(activity, statusBarAlpha));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成一个和状态栏大小相同的彩色矩形条
|
||||
*
|
||||
* @param activity 需要设置的 activity
|
||||
* @param color 状态栏颜色值
|
||||
* @return 状态栏矩形条
|
||||
*/
|
||||
private static View createStatusBarView(Activity activity, @ColorInt int color) {
|
||||
return createStatusBarView(activity, color, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成一个和状态栏大小相同的半透明矩形条
|
||||
*
|
||||
* @param activity 需要设置的activity
|
||||
* @param color 状态栏颜色值
|
||||
* @param alpha 透明值
|
||||
* @return 状态栏矩形条
|
||||
*/
|
||||
private static View createStatusBarView(Activity activity, @ColorInt int color, int alpha) {
|
||||
// 绘制一个和状态栏一样高的矩形
|
||||
View statusBarView = new View(activity);
|
||||
LinearLayout.LayoutParams params =
|
||||
new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getStatusBarHeight(activity));
|
||||
statusBarView.setLayoutParams(params);
|
||||
statusBarView.setBackgroundColor(calculateStatusColor(color, alpha));
|
||||
statusBarView.setId(FAKE_STATUS_BAR_VIEW_ID);
|
||||
return statusBarView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置根布局参数
|
||||
*/
|
||||
private static void setRootView(Activity activity) {
|
||||
ViewGroup parent = (ViewGroup) activity.findViewById(android.R.id.content);
|
||||
for (int i = 0, count = parent.getChildCount(); i < count; i++) {
|
||||
View childView = parent.getChildAt(i);
|
||||
if (childView instanceof ViewGroup) {
|
||||
childView.setFitsSystemWindows(true);
|
||||
((ViewGroup) childView).setClipToPadding(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置透明
|
||||
*/
|
||||
private static void setTransparentForWindow(Activity activity) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||
activity.getWindow()
|
||||
.getDecorView()
|
||||
.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
|
||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
activity.getWindow()
|
||||
.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 使状态栏透明
|
||||
*/
|
||||
@TargetApi(Build.VERSION_CODES.KITKAT)
|
||||
private static void transparentStatusBar(Activity activity) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
|
||||
activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||
} else {
|
||||
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建半透明矩形 View
|
||||
*
|
||||
* @param alpha 透明值
|
||||
* @return 半透明 View
|
||||
*/
|
||||
private static View createTranslucentStatusBarView(Activity activity, int alpha) {
|
||||
// 绘制一个和状态栏一样高的矩形
|
||||
View statusBarView = new View(activity);
|
||||
LinearLayout.LayoutParams params =
|
||||
new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getStatusBarHeight(activity));
|
||||
statusBarView.setLayoutParams(params);
|
||||
statusBarView.setBackgroundColor(Color.argb(alpha, 0, 0, 0));
|
||||
statusBarView.setId(FAKE_TRANSLUCENT_VIEW_ID);
|
||||
return statusBarView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取状态栏高度
|
||||
*
|
||||
* @param context context
|
||||
* @return 状态栏高度
|
||||
*/
|
||||
private static int getStatusBarHeight(Context context) {
|
||||
// 获得状态栏高度
|
||||
int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
|
||||
return context.getResources().getDimensionPixelSize(resourceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算状态栏颜色
|
||||
*
|
||||
* @param color color值
|
||||
* @param alpha alpha值
|
||||
* @return 最终的状态栏颜色
|
||||
*/
|
||||
private static int calculateStatusColor(@ColorInt int color, int alpha) {
|
||||
if (alpha == 0) {
|
||||
return color;
|
||||
}
|
||||
float a = 1 - alpha / 255f;
|
||||
int red = color >> 16 & 0xff;
|
||||
int green = color >> 8 & 0xff;
|
||||
int blue = color & 0xff;
|
||||
red = (int) (red * a + 0.5);
|
||||
green = (int) (green * a + 0.5);
|
||||
blue = (int) (blue * a + 0.5);
|
||||
return 0xff << 24 | red << 16 | green << 8 | blue;
|
||||
}
|
||||
}
|
5
StatusBarUtil/src/main/res/values/ids.xml
Normal file
5
StatusBarUtil/src/main/res/values/ids.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<item type="id" name="statusbarutil_fake_status_bar_view" />
|
||||
<item type="id" name="statusbarutil_translucent_view" />
|
||||
</resources>
|
|
@ -4,7 +4,7 @@ plugins {
|
|||
android {
|
||||
signingConfigs {
|
||||
debug {
|
||||
storeFile file('F:\\muqing.jks')
|
||||
storeFile file('../muqing.jks')
|
||||
storePassword 'muqing153'
|
||||
keyAlias 'muqing'
|
||||
keyPassword 'muqing153'
|
||||
|
@ -44,8 +44,8 @@ android {
|
|||
}
|
||||
dependencies {
|
||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||
|
||||
implementation 'com.google.android.material:material:1.9.0'
|
||||
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||
|
||||
implementation 'com.google.code.gson:gson:2.9.1'
|
||||
|
@ -61,5 +61,6 @@ dependencies {
|
|||
//修改音乐标签库
|
||||
implementation 'com.mpatric:mp3agic:0.9.1'
|
||||
|
||||
// implementation 'com.github.QuadFlask:colorpicker:0.0.15'
|
||||
// 沉浸式状态栏
|
||||
api project(path: ':StatusBarUtil')
|
||||
}
|
Binary file not shown.
|
@ -1,20 +0,0 @@
|
|||
{
|
||||
"version": 3,
|
||||
"artifactType": {
|
||||
"type": "APK",
|
||||
"kind": "Directory"
|
||||
},
|
||||
"applicationId": "com.muqingbfq",
|
||||
"variantName": "debug",
|
||||
"elements": [
|
||||
{
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"attributes": [],
|
||||
"versionCode": 1,
|
||||
"versionName": "1.9.5",
|
||||
"outputFile": "Cloud_music-debug-v1.9.5.apk"
|
||||
}
|
||||
],
|
||||
"elementType": "File"
|
||||
}
|
|
@ -1,10 +1,12 @@
|
|||
package com.muqingbfq;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
@ -16,6 +18,7 @@ import android.widget.ListView;
|
|||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.flexbox.AlignItems;
|
||||
|
@ -31,6 +34,7 @@ import com.muqingbfq.mq.FragmentActivity;
|
|||
import com.muqingbfq.mq.gj;
|
||||
import com.muqingbfq.mq.wj;
|
||||
import com.muqingbfq.mq.wl;
|
||||
import com.muqingbfq.view.Edit;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
@ -101,13 +105,14 @@ public class activity_search extends FragmentActivity {
|
|||
|
||||
});
|
||||
Object o = new Object();
|
||||
binding.editview.addTextChangedListener(new TextWatcher() {
|
||||
binding.editview.addTextChangedListener(new Edit.TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
binding.editview.iskong();
|
||||
if (TextUtils.isEmpty(s)) {
|
||||
listPopupWindow.setVisibility(View.GONE);
|
||||
return;
|
||||
|
@ -143,13 +148,13 @@ public class activity_search extends FragmentActivity {
|
|||
public void afterTextChanged(Editable s) {
|
||||
}
|
||||
});
|
||||
gj.tcjp(binding.editview);
|
||||
gj.tcjp(binding.editview.editText);
|
||||
}
|
||||
|
||||
public void dismiss() {
|
||||
binding.editview.clearFocus();
|
||||
listPopupWindow.setVisibility(View.GONE);
|
||||
gj.ycjp(binding.editview);
|
||||
gj.ycjp(binding.editview.editText);
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
|
@ -169,7 +174,8 @@ public class activity_search extends FragmentActivity {
|
|||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.home, menu);
|
||||
MenuItem sousuo = menu.add("搜索");
|
||||
sousuo.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
|
@ -178,7 +184,7 @@ public class activity_search extends FragmentActivity {
|
|||
int itemId = item.getItemId();
|
||||
if (itemId == android.R.id.home) {
|
||||
finish();
|
||||
} else if (itemId == R.id.menu_search) {
|
||||
} else if (itemId == 0) {
|
||||
start(binding.editview.getText().toString());
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
|
@ -213,6 +219,23 @@ public class activity_search extends FragmentActivity {
|
|||
if (json_list.isEmpty()) {
|
||||
binding.xxbj1.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
RecyclerView.ItemAnimator animator = new DefaultItemAnimator(){
|
||||
@Override
|
||||
public boolean animateRemove(RecyclerView.ViewHolder holder) {
|
||||
ObjectAnimator fadeAnimator = ObjectAnimator.ofFloat(holder.itemView, "alpha", 1f, 0f);
|
||||
fadeAnimator.setDuration(getRemoveDuration());
|
||||
fadeAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
dispatchRemoveFinished(holder);
|
||||
holder.itemView.setAlpha(1f);
|
||||
}
|
||||
});
|
||||
fadeAnimator.start();
|
||||
return false;
|
||||
}
|
||||
};
|
||||
binding.listRecycler.setItemAnimator(animator);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -236,7 +259,7 @@ public class activity_search extends FragmentActivity {
|
|||
.setPositiveButton("确定", (dialogInterface, i) -> {
|
||||
json_list.remove(keyword);
|
||||
wj.xrwb(wj.filesdri + wj.lishi_json, new Gson().toJson(json_list));
|
||||
notifyItemChanged(position);
|
||||
notifyItemRemoved(position);
|
||||
})
|
||||
.setNegativeButton("取消", null)
|
||||
.show();
|
||||
|
|
|
@ -62,7 +62,8 @@ public class resource {
|
|||
return new XM(id, name, coverImgUrl);
|
||||
}
|
||||
|
||||
public static void 排行榜(List<XM> list) {
|
||||
// 排行榜
|
||||
public static void leaderboard(List<XM> list) {
|
||||
String hq;
|
||||
try {
|
||||
if (wj.cz(wj.gd_phb)) {
|
||||
|
|
|
@ -5,7 +5,9 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
@ -53,6 +55,7 @@ public class gd extends com.muqingbfq.mq.FragmentActivity {
|
|||
super.onCreate(savedInstanceState);
|
||||
FragmentMp3Binding binding = FragmentMp3Binding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
Intent intent = getIntent();
|
||||
binding.title.setText(intent.getStringExtra("name"));
|
||||
adapter = new baseadapter(this, list);
|
||||
|
@ -79,7 +82,7 @@ public class gd extends com.muqingbfq.mq.FragmentActivity {
|
|||
public void run() {
|
||||
super.run();
|
||||
if (id.equals("排行榜")) {
|
||||
resource.排行榜(list);
|
||||
resource.leaderboard(list);
|
||||
} else {
|
||||
String hq = wl.hq("/search?keywords=" + id + "&limit=" + (k * 3) + "&type=1000");
|
||||
try {
|
||||
|
@ -103,7 +106,7 @@ public class gd extends com.muqingbfq.mq.FragmentActivity {
|
|||
|
||||
public static class baseadapter extends RecyclerView.Adapter<VH> {
|
||||
Context context;
|
||||
List<XM> list;
|
||||
public List<XM> list;
|
||||
|
||||
public baseadapter(Context context, List<XM> list) {
|
||||
this.context = context;
|
||||
|
@ -112,10 +115,108 @@ public class gd extends com.muqingbfq.mq.FragmentActivity {
|
|||
|
||||
boolean bool = false;
|
||||
|
||||
public baseadapter(Context context, List<XM> list, boolean bool) {
|
||||
public baseadapter(Context context, List<XM> list, boolean bool, RecyclerView recyclerView) {
|
||||
this.context = context;
|
||||
this.list = list;
|
||||
this.bool = bool;
|
||||
setrecycle(recyclerView);
|
||||
}
|
||||
|
||||
public void setrecycle(RecyclerView recyclerView) {
|
||||
|
||||
recyclerView.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
|
||||
final GestureDetector gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
|
||||
@Override
|
||||
public void onLongPress(@NonNull MotionEvent motionEvent) {
|
||||
View childView = recyclerView.findChildViewUnder(motionEvent.getX(), motionEvent.getY());
|
||||
if (childView != null) {
|
||||
int position = recyclerView.getChildAdapterPosition(childView);
|
||||
setonlong(position);
|
||||
// 处理长按事件,使用正确的位置position
|
||||
// ...
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e) {
|
||||
return gestureDetector.onTouchEvent(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void setonlong(int position) {
|
||||
XM xm = list.get(position);
|
||||
gj.sc(xm.name);
|
||||
String[] stringArray = context.getResources()
|
||||
.getStringArray(R.array.gd_list);
|
||||
if (!wj.cz(wj.gd + xm.id)) {
|
||||
stringArray = new String[]{"下载歌单"};
|
||||
}
|
||||
String[] finalStringArray = stringArray;
|
||||
new MaterialAlertDialogBuilder(context).
|
||||
setItems(stringArray, (dialog, id) -> {
|
||||
switch (finalStringArray[id]) {
|
||||
case "下载歌单":
|
||||
new Thread() {
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
String hq = playlist.gethq(xm.id);
|
||||
if (hq != null) {
|
||||
wj.xrwb(wj.gd + xm.id, hq);
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
if (wj.cz(wj.gd_xz)) {
|
||||
jsonObject = new JSONObject(Objects.requireNonNull(wj.dqwb(wj.gd_xz)));
|
||||
}
|
||||
XM fh = resource.Playlist_content(xm.id);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("name", fh.name);
|
||||
json.put("picUrl", fh.picurl);
|
||||
jsonObject.put(fh.id, json);
|
||||
wj.xrwb(wj.gd_xz, jsonObject.toString());
|
||||
main.handler.post(() -> {
|
||||
notifyItemChanged(position);
|
||||
wode.addlist(xm);
|
||||
});
|
||||
} catch (JSONException e) {
|
||||
gj.sc("list gd onclick thear " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
break;
|
||||
case "删除歌单":
|
||||
// 删除项目
|
||||
try {
|
||||
wj.sc(wj.gd + xm.id);
|
||||
JSONObject jsonObject = new JSONObject(Objects.requireNonNull(wj.dqwb(wj.gd_xz)));
|
||||
jsonObject.remove(xm.id);
|
||||
list.remove(xm);
|
||||
wj.xrwb(wj.gd_xz, jsonObject.toString());
|
||||
wode.removelist(xm);
|
||||
} catch (JSONException e) {
|
||||
gj.sc(e);
|
||||
}
|
||||
break;
|
||||
}
|
||||
// 在这里处理菜单项的点击事件
|
||||
}).show();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -140,10 +241,12 @@ public class gd extends com.muqingbfq.mq.FragmentActivity {
|
|||
if (bool) {
|
||||
holder.itemView.setOnClickListener(card);
|
||||
holder.bindingB.text2.setText(xm.message);
|
||||
holder.itemView.setOnLongClickListener(card);
|
||||
} else {
|
||||
holder.binding.image.setOnClickListener(card);
|
||||
holder.binding.image.setOnLongClickListener(card);
|
||||
holder.binding.image.setOnLongClickListener(v -> {
|
||||
setonlong(position);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
holder.title.setText(xm.name);
|
||||
holder.kg.setOnClickListener(view1 -> {
|
||||
|
@ -182,8 +285,7 @@ public class gd extends com.muqingbfq.mq.FragmentActivity {
|
|||
return list.size();
|
||||
}
|
||||
|
||||
class CARD implements View.OnClickListener
|
||||
, View.OnLongClickListener {
|
||||
class CARD implements View.OnClickListener {
|
||||
int position;
|
||||
|
||||
public CARD(int position) {
|
||||
|
@ -199,60 +301,6 @@ public class gd extends com.muqingbfq.mq.FragmentActivity {
|
|||
intent.putExtra("name", xm.name);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
XM xm = list.get(position);
|
||||
String[] stringArray = view.getResources()
|
||||
.getStringArray(R.array.gd_list);
|
||||
if (!wj.cz(wj.gd + xm.id)) {
|
||||
stringArray = new String[]{"下载歌单"};
|
||||
}
|
||||
new MaterialAlertDialogBuilder(view.getContext()).
|
||||
setItems(stringArray, (dialog, id) -> {
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (id == 0) {
|
||||
String hq = playlist.gethq(xm.id);
|
||||
if (hq != null) {
|
||||
wj.xrwb(wj.gd + xm.id, hq);
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
if (wj.cz(wj.gd_xz)) {
|
||||
jsonObject = new JSONObject(Objects.requireNonNull(wj.dqwb(wj.gd_xz)));
|
||||
}
|
||||
XM fh = resource.Playlist_content(xm.id);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("name", fh.name);
|
||||
json.put("picUrl", fh.picurl);
|
||||
jsonObject.put(fh.id, json);
|
||||
wj.xrwb(wj.gd_xz, jsonObject.toString());
|
||||
main.handler.post(() -> notifyItemChanged(position));
|
||||
} catch (JSONException e) {
|
||||
gj.sc("list gd onclick thear " + e);
|
||||
}
|
||||
}
|
||||
|
||||
} else if (id == 2) {
|
||||
wj.sc(wj.gd + xm.id);
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(Objects.requireNonNull(wj.dqwb(wj.gd_xz)));
|
||||
jsonObject.remove(xm.id);
|
||||
list.remove(xm);
|
||||
wj.xrwb(wj.gd_xz, jsonObject.toString());
|
||||
main.handler.post(() -> notifyItemChanged(position));
|
||||
} catch (JSONException e) {
|
||||
gj.sc(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
// 在这里处理菜单项的点击事件
|
||||
}).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -262,6 +310,7 @@ public class gd extends com.muqingbfq.mq.FragmentActivity {
|
|||
public ImageView kg;
|
||||
public CardImage image;
|
||||
public TextView title;
|
||||
|
||||
public VH(@NonNull ListGdBinding itemView) {
|
||||
super(itemView.getRoot());
|
||||
binding = itemView;
|
||||
|
@ -288,4 +337,6 @@ public class gd extends com.muqingbfq.mq.FragmentActivity {
|
|||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,13 +1,20 @@
|
|||
package com.muqingbfq.fragment;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
@ -17,11 +24,13 @@ import com.bumptech.glide.request.RequestOptions;
|
|||
import com.muqingbfq.MP3;
|
||||
import com.muqingbfq.R;
|
||||
import com.muqingbfq.XM;
|
||||
import com.muqingbfq.activity_search;
|
||||
import com.muqingbfq.api.resource;
|
||||
import com.muqingbfq.api.url;
|
||||
import com.muqingbfq.bfqkz;
|
||||
import com.muqingbfq.databinding.FragmentGdBinding;
|
||||
import com.muqingbfq.databinding.ListMp3ImageBinding;
|
||||
import com.muqingbfq.home;
|
||||
import com.muqingbfq.main;
|
||||
import com.muqingbfq.mq.gj;
|
||||
import com.muqingbfq.mq.wj;
|
||||
|
@ -38,12 +47,27 @@ public class gd_adapter extends Fragment {
|
|||
List<MP3> listmp3 = new ArrayList<>();
|
||||
|
||||
FragmentGdBinding binding;
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
setHasOptionsMenu(true);
|
||||
// 其他初始化代码...
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
binding = FragmentGdBinding.inflate(getLayoutInflater(), container, false);
|
||||
|
||||
//初始化工具栏
|
||||
((AppCompatActivity) requireActivity()).setSupportActionBar(binding.toolbar);
|
||||
DrawerLayout drawerLayout = home.appCompatActivity.findViewById(R.id.chct);
|
||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
||||
getActivity(), drawerLayout, binding.toolbar, R.string.app_name, R.string.app_name);
|
||||
drawerLayout.addDrawerListener(toggle);
|
||||
toggle.syncState();
|
||||
|
||||
binding.toolbar.setPadding(0, gj.getztl(getContext()), 0, 0);
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
|
||||
linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
|
||||
binding.recyclerview1.setHasFixedSize(true);
|
||||
|
@ -131,6 +155,21 @@ public class gd_adapter extends Fragment {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.home, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == R.id.menu_search) {
|
||||
Intent intent = new Intent(getContext(), activity_search.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
public void mp3list() {
|
||||
new Thread(){
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
|
|
|
@ -92,7 +92,9 @@ public class search extends Fragment {
|
|||
} else if (i == 1) {
|
||||
k = (int) (main.k / getResources().getDisplayMetrics().density + 0.5f) / 120;
|
||||
inflate.recyclerview.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
inflate.recyclerview.setAdapter(new gd.baseadapter(getContext(), xmList, true));
|
||||
inflate.recyclerview.setAdapter(new gd.baseadapter(getContext(),
|
||||
xmList, true, inflate.recyclerview));
|
||||
|
||||
}
|
||||
new start(name);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import android.widget.Toast;
|
|||
import com.muqingbfq.R;
|
||||
import com.muqingbfq.activity_about_software;
|
||||
import com.muqingbfq.clean.fragment_clean;
|
||||
import com.muqingbfq.login.cookie;
|
||||
import com.muqingbfq.mq.gj;
|
||||
|
||||
public class sz {
|
||||
|
|
|
@ -2,8 +2,12 @@ package com.muqingbfq.fragment;
|
|||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
@ -11,19 +15,28 @@ import android.widget.TextView;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.gson.Gson;
|
||||
import com.muqingbfq.R;
|
||||
import com.muqingbfq.XM;
|
||||
import com.muqingbfq.activity_search;
|
||||
import com.muqingbfq.api.playlist;
|
||||
import com.muqingbfq.api.resource;
|
||||
import com.muqingbfq.bfqkz;
|
||||
import com.muqingbfq.databinding.FragmentWdBinding;
|
||||
import com.muqingbfq.databinding.ListGdBBinding;
|
||||
import com.muqingbfq.home;
|
||||
import com.muqingbfq.login.user_logs;
|
||||
import com.muqingbfq.login.visitor;
|
||||
import com.muqingbfq.main;
|
||||
|
@ -36,6 +49,7 @@ import org.json.JSONObject;
|
|||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
@ -59,14 +73,55 @@ public class wode extends Fragment {
|
|||
{R.drawable.paihangbang, "排行榜", "排行榜"},
|
||||
{R.drawable.icon, "开发中", ""}
|
||||
};
|
||||
private final List<XM> list = new ArrayList<>();
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
public static baseadapter adaper;
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
setHasOptionsMenu(true);
|
||||
// 其他初始化代码...
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
binding = FragmentWdBinding.inflate(inflater, container, false);
|
||||
//初始化工具栏
|
||||
((AppCompatActivity) requireActivity()).setSupportActionBar(binding.toolbar);
|
||||
DrawerLayout drawerLayout = home.appCompatActivity.findViewById(R.id.chct);
|
||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
||||
getActivity(), drawerLayout, binding.toolbar, R.string.app_name, R.string.app_name);
|
||||
drawerLayout.addDrawerListener(toggle);
|
||||
toggle.syncState();
|
||||
|
||||
binding.appbar.setPadding(0, gj.getztl(getContext()), 0, 0);
|
||||
name = binding.text1;
|
||||
binding.toolbar.setTitle("");
|
||||
binding.appbar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
|
||||
boolean isCollapsed = false; // 标记是否处于折叠状态
|
||||
|
||||
@Override
|
||||
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
|
||||
if (Math.abs(verticalOffset) >= appBarLayout.getTotalScrollRange()) {
|
||||
// 完全折叠时的逻辑
|
||||
if (!isCollapsed) {
|
||||
// 处理完全折叠时的操作
|
||||
isCollapsed = true;
|
||||
binding.aaa.setVisibility(View.VISIBLE);
|
||||
binding.aaa.setText(name.getText());
|
||||
}
|
||||
} else {
|
||||
// 非折叠状态的逻辑
|
||||
if (isCollapsed) {
|
||||
// 处理非折叠状态的操作
|
||||
isCollapsed = false;
|
||||
binding.aaa.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
jieshao = binding.text2;
|
||||
imageView = binding.imageView;
|
||||
binding.cardview.setOnClickListener(v -> {
|
||||
|
@ -157,7 +212,7 @@ public class wode extends Fragment {
|
|||
}
|
||||
String finalStr = str;
|
||||
gj.ts(getContext(), "导入中");
|
||||
new Thread(){
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
|
@ -204,12 +259,14 @@ public class wode extends Fragment {
|
|||
}
|
||||
});
|
||||
binding.recyclerview2.setFocusable(false);
|
||||
binding.recyclerview2.setAdapter(new gd.baseadapter(getContext(), list, true));
|
||||
adaper = new baseadapter();
|
||||
binding.recyclerview2.setAdapter(adaper);
|
||||
sx();
|
||||
denglu();
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
|
||||
class VH extends RecyclerView.ViewHolder {
|
||||
public ImageView imageView;
|
||||
public TextView textView;
|
||||
|
@ -224,14 +281,14 @@ public class wode extends Fragment {
|
|||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void sx() {
|
||||
try {
|
||||
list.clear();
|
||||
adaper.list.clear();
|
||||
JSONObject date = new JSONObject(wj.dqwb(wj.gd_xz));
|
||||
for (Iterator<String> it = date.keys(); it.hasNext(); ) {
|
||||
String id = it.next();
|
||||
JSONObject jsonObject = date.getJSONObject(id);
|
||||
String name = jsonObject.getString("name");
|
||||
String picUrl = jsonObject.getString("picUrl");
|
||||
list.add(new XM(id, name, picUrl));
|
||||
adaper.list.add(new XM(id, name, picUrl));
|
||||
}
|
||||
main.handler.post(() -> binding.recyclerview2.getAdapter().notifyDataSetChanged());
|
||||
} catch (Exception e) {
|
||||
|
@ -239,6 +296,22 @@ public class wode extends Fragment {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public static void addlist(XM xm) {
|
||||
if (adaper != null&&!adaper.list.contains(xm)) {
|
||||
adaper.list.add(xm);
|
||||
adaper.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public static void removelist(XM xm) {
|
||||
if (adaper != null) {
|
||||
adaper.list.remove(xm);
|
||||
adaper.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setname(String string) {
|
||||
main.handler.post(() -> name.setText(string));
|
||||
}
|
||||
|
@ -266,4 +339,135 @@ public class wode extends Fragment {
|
|||
.error(R.drawable.ic_launcher_foreground)
|
||||
.into(binding.imageView);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.home, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == R.id.menu_search) {
|
||||
Intent intent = new Intent(getContext(), activity_search.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
class baseadapter extends RecyclerView.Adapter<gd.VH> {
|
||||
public List<XM> list = new ArrayList<>();
|
||||
@NonNull
|
||||
@Override
|
||||
public gd.VH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new gd.VH(ListGdBBinding.bind(LayoutInflater.from(getContext())
|
||||
.inflate(R.layout.list_gd_b, parent, false)));
|
||||
}
|
||||
|
||||
public void setList(List<XM> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull gd.VH holder, @SuppressLint("RecyclerView") int position) {
|
||||
XM xm = list.get(position);
|
||||
holder.itemView.setOnClickListener(v -> {
|
||||
XM xm1 = list.get(position);
|
||||
Intent intent = new Intent(getContext(), mp3.class);
|
||||
intent.putExtra("id", xm1.id);
|
||||
intent.putExtra("name", xm1.name);
|
||||
getContext().startActivity(intent);
|
||||
});
|
||||
holder.itemView.setOnLongClickListener(v -> {
|
||||
String[] stringArray = {"下载歌单", "删除歌单"};
|
||||
new MaterialAlertDialogBuilder(getContext()).
|
||||
setItems(stringArray, (dialog, id) -> {
|
||||
switch (stringArray[id]) {
|
||||
case "下载歌单":
|
||||
new Thread() {
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
String hq = playlist.gethq(xm.id);
|
||||
if (hq != null) {
|
||||
wj.xrwb(wj.gd + xm.id, hq);
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
if (wj.cz(wj.gd_xz)) {
|
||||
jsonObject = new JSONObject(Objects.requireNonNull(wj.dqwb(wj.gd_xz)));
|
||||
}
|
||||
XM fh = resource.Playlist_content(xm.id);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("name", fh.name);
|
||||
json.put("picUrl", fh.picurl);
|
||||
jsonObject.put(fh.id, json);
|
||||
wj.xrwb(wj.gd_xz, jsonObject.toString());
|
||||
main.handler.post(() -> notifyItemChanged(position));
|
||||
} catch (JSONException e) {
|
||||
gj.sc("list gd onclick thear " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
break;
|
||||
case "删除歌单":
|
||||
// 删除项目
|
||||
try {
|
||||
wj.sc(wj.gd + xm.id);
|
||||
JSONObject jsonObject = new JSONObject(Objects.requireNonNull(wj.dqwb(wj.gd_xz)));
|
||||
jsonObject.remove(xm.id);
|
||||
list.remove(xm);
|
||||
wj.xrwb(wj.gd_xz, jsonObject.toString());
|
||||
notifyItemRemoved(position);
|
||||
} catch (JSONException e) {
|
||||
gj.sc(e);
|
||||
}
|
||||
break;
|
||||
}
|
||||
// 在这里处理菜单项的点击事件
|
||||
}).show();
|
||||
return false;
|
||||
});
|
||||
|
||||
holder.bindingB.text2.setText(xm.message);
|
||||
holder.title.setText(xm.name);
|
||||
holder.kg.setOnClickListener(view1 -> {
|
||||
ImageView tx = (ImageView) view1;
|
||||
new Thread() {
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
boolean an = playlist.hq(bfqkz.list, xm.id);
|
||||
if (bfqkz.ms == 2) {
|
||||
Collections.shuffle(bfqkz.list);
|
||||
}
|
||||
main.handler.post(() -> {
|
||||
if (an) {
|
||||
com.muqingbfq.bfq_an.xyq();
|
||||
tx.setImageResource(R.drawable.bf);
|
||||
com.muqingbfq.fragment.gd.gdid = xm.id;
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
});
|
||||
}
|
||||
}.start();
|
||||
});
|
||||
Drawable color_kg = ContextCompat.getDrawable(getContext(), R.drawable.zt);
|
||||
if (xm.id.equals(com.muqingbfq.fragment.gd.gdid)) {
|
||||
color_kg = ContextCompat.getDrawable(getContext(), R.drawable.bf);
|
||||
}
|
||||
holder.kg.setImageDrawable(color_kg);
|
||||
// xm.picurl
|
||||
holder.image.setImageapply(xm.picurl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list.size();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,16 +6,13 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.os.Process;
|
||||
import android.support.v4.media.MediaBrowserCompat;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
|
@ -44,17 +41,11 @@ public class home extends AppCompatActivity {
|
|||
super.onCreate(savedInstanceState);
|
||||
binding = ActivityHomeBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
// binding.toolbar.setPadding(0, gj.getztl(this), 0, 0);
|
||||
DisplayMetrics dm = getResources().getDisplayMetrics();
|
||||
main.k = dm.widthPixels;
|
||||
main.g = dm.heightPixels;
|
||||
try {
|
||||
//初始化工具栏
|
||||
setSupportActionBar(binding.toolbar);
|
||||
DrawerLayout drawerLayout = findViewById(R.id.chct);
|
||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
||||
this, drawerLayout, binding.toolbar, R.string.app_name, R.string.app_name);
|
||||
drawerLayout.addDrawerListener(toggle);
|
||||
toggle.syncState();
|
||||
//初始化侧滑
|
||||
binding.chb.setNavigationItemSelectedListener(item -> {
|
||||
com.muqingbfq.fragment.sz.switch_sz(home.this, item.getItemId());
|
||||
|
@ -75,8 +66,6 @@ public class home extends AppCompatActivity {
|
|||
}
|
||||
//检测更新
|
||||
new gj.jianchagengxin(this);
|
||||
binding.editView.setOnClickListener(view ->
|
||||
startActivity(new Intent(this, activity_search.class)));
|
||||
UI();
|
||||
// startService(new Intent(this, FloatingLyricsService.class));
|
||||
} catch (Exception e) {
|
||||
|
@ -122,6 +111,7 @@ public class home extends AppCompatActivity {
|
|||
}
|
||||
return true;
|
||||
});
|
||||
Object o = new Object();
|
||||
binding.viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
|
@ -131,19 +121,15 @@ public class home extends AppCompatActivity {
|
|||
break;
|
||||
case 1:
|
||||
binding.tablayout.setSelectedItemId(R.id.c);
|
||||
new Thread() {
|
||||
/* new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
try {
|
||||
sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.toString();
|
||||
synchronized (o) {
|
||||
wode fragment = (wode) adapter.createFragment(position);
|
||||
fragment.sx();
|
||||
}
|
||||
wode fragment = (wode) adapter.createFragment(position);
|
||||
fragment.sx();
|
||||
}
|
||||
}.start();
|
||||
}.start();*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -169,25 +155,12 @@ public class home extends AppCompatActivity {
|
|||
.replace(R.id.bfq_db, new bfq_db())
|
||||
.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
moveTaskToBack(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.home, menu);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == R.id.menu_search) {
|
||||
Intent intent = new Intent(this, activity_search.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
/**
|
||||
* 连接状态的回调接口,连接成功时会调用onConnected()方法
|
||||
*/
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
package com.muqingbfq.login;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.muqingbfq.R;
|
||||
import com.muqingbfq.main;
|
||||
import com.muqingbfq.mq.FragmentActivity;
|
||||
import com.muqingbfq.mq.gj;
|
||||
import com.muqingbfq.mq.wl;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class cookie extends FragmentActivity {
|
||||
|
||||
View view_a, view_b;
|
||||
TextView textView;
|
||||
ImageView imageView;
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_cookie);
|
||||
view_a = findViewById(R.id.view1);
|
||||
view_b = findViewById(R.id.view2);
|
||||
view_a.setVisibility(View.GONE);
|
||||
|
||||
//view2 里面的控件
|
||||
textView = findViewById(R.id.textView);
|
||||
imageView = findViewById(R.id.imageView);
|
||||
// new erweima();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,9 +1,8 @@
|
|||
package com.muqingbfq.mq;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.Service;
|
||||
import android.app.usage.UsageStats;
|
||||
import android.app.usage.UsageStatsManager;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
|
@ -83,7 +82,6 @@ public class gj {
|
|||
/**
|
||||
* 复制文字到剪切板
|
||||
*
|
||||
* @param text
|
||||
*/
|
||||
public static void fz(Context context, String text) {
|
||||
ClipboardManager systemService =
|
||||
|
@ -173,4 +171,12 @@ public class gj {
|
|||
imm.hideSoftInputFromWindow(editText.getWindowToken(),
|
||||
InputMethodManager.HIDE_NOT_ALWAYS);
|
||||
}
|
||||
|
||||
public static int getztl(Context context) {
|
||||
// 获得状态栏高度
|
||||
@SuppressLint({"InternalInsetResource", "DiscouragedApi"}) int resourceId =
|
||||
context.getResources().
|
||||
getIdentifier("status_bar_height", "dimen", "android");
|
||||
return context.getResources().getDimensionPixelSize(resourceId);
|
||||
}
|
||||
}
|
173
app/src/main/java/com/muqingbfq/view/Edit.java
Normal file
173
app/src/main/java/com/muqingbfq/view/Edit.java
Normal file
|
@ -0,0 +1,173 @@
|
|||
package com.muqingbfq.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.RippleDrawable;
|
||||
import android.text.Editable;
|
||||
import android.text.NoCopySpan;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.muqingbfq.R;
|
||||
import com.muqingbfq.activity_search;
|
||||
|
||||
public class Edit extends LinearLayout {
|
||||
public Edit(@NonNull Context context) {
|
||||
super(context);
|
||||
initView();
|
||||
}
|
||||
|
||||
AttributeSet attrs;
|
||||
public Edit(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
this.attrs=attrs;
|
||||
initView();
|
||||
}
|
||||
|
||||
public Edit(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
this.attrs=attrs;
|
||||
initView();
|
||||
}
|
||||
|
||||
ImageView chahao;
|
||||
public EditText editText;
|
||||
|
||||
private void initView() {
|
||||
setGravity(Gravity.CENTER_VERTICAL);
|
||||
setBackgroundResource(R.drawable.ui_editview);
|
||||
setPadding(30, 10, 30, 10);
|
||||
//构建编辑框
|
||||
editText = new EditText(getContext());
|
||||
editText.setHint("搜索");
|
||||
editText.setSingleLine(true);
|
||||
editText.setBackground(null);
|
||||
editText.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
|
||||
addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence var1, int var2, int var3, int var4) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence var1, int var2, int var3, int var4) {
|
||||
iskong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable var1) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
ImageView imageView = new ImageView(getContext());
|
||||
imageView.setImageResource(R.drawable.sousuo);
|
||||
addView(imageView, (int) TypedValue.applyDimension(TypedValue.
|
||||
COMPLEX_UNIT_DIP, 26, getResources().getDisplayMetrics())
|
||||
, (int) TypedValue.applyDimension(TypedValue.
|
||||
COMPLEX_UNIT_DIP, 26, getResources().getDisplayMetrics()));
|
||||
|
||||
LayoutParams layoutParams = new LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
layoutParams.weight = 1;
|
||||
layoutParams.gravity = Gravity.CENTER;
|
||||
addView(editText, layoutParams);
|
||||
|
||||
chahao = new ImageView(getContext());
|
||||
chahao.setImageResource(R.drawable.chahao);
|
||||
Drawable rippleDrawable = new RippleDrawable(
|
||||
ContextCompat.getColorStateList(getContext(),R.color.bj),
|
||||
chahao.getBackground(),
|
||||
null
|
||||
);
|
||||
chahao.setBackground(rippleDrawable);
|
||||
chahao.setOnClickListener(view -> {
|
||||
editText.setText("");
|
||||
view.setVisibility(GONE);
|
||||
});
|
||||
addView(chahao, (int) TypedValue.applyDimension(TypedValue.
|
||||
COMPLEX_UNIT_DIP, 26, getResources().getDisplayMetrics())
|
||||
, (int) TypedValue.applyDimension(TypedValue.
|
||||
COMPLEX_UNIT_DIP, 26, getResources().getDisplayMetrics()));
|
||||
iskong();
|
||||
if (attrs != null) {
|
||||
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.Edit);
|
||||
boolean isEnabled = a.getBoolean(R.styleable.Edit_Enabled, true);
|
||||
if (!isEnabled) {
|
||||
removeView(editText);
|
||||
removeView(imageView);
|
||||
removeView(chahao);
|
||||
TextView textView = new TextView(getContext());
|
||||
textView.setTextColor(editText.getHintTextColors());
|
||||
textView.setText("搜索");
|
||||
|
||||
// 将 px 值转换为 sp
|
||||
float v = TypedValue.applyDimension(
|
||||
TypedValue.COMPLEX_UNIT_PX,
|
||||
editText.getTextSize(),
|
||||
getResources().getDisplayMetrics()
|
||||
) / getResources().getDisplayMetrics().scaledDensity;
|
||||
textView.setTextSize(v);
|
||||
setGravity(Gravity.CENTER);
|
||||
addView(textView);
|
||||
textView.setPadding(26, 26, 26, 26);
|
||||
setOnClickListener(view ->
|
||||
getContext().startActivity(new Intent(getContext(), activity_search.class)));
|
||||
}
|
||||
a.recycle();
|
||||
}
|
||||
}
|
||||
|
||||
public void addTextChangedListener(TextWatcher textWatcher) {
|
||||
editText.addTextChangedListener(textWatcher);
|
||||
}
|
||||
|
||||
public void iskong() {
|
||||
if (editText.getText().toString().isEmpty()) {
|
||||
chahao.setVisibility(GONE);
|
||||
} else {
|
||||
chahao.setVisibility(VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLayoutParams(ViewGroup.LayoutParams params) {
|
||||
// params.width = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
super.setLayoutParams(params);
|
||||
// setGravity(Gravity.CENTER_VERTICAL);
|
||||
}
|
||||
|
||||
public void setOnEditorActionListener(TextView.OnEditorActionListener a) {
|
||||
editText.setOnEditorActionListener(a);
|
||||
}
|
||||
|
||||
public void setText(String s) {
|
||||
editText.setText(s);
|
||||
}
|
||||
|
||||
public Editable getText() {
|
||||
return editText.getText();
|
||||
}
|
||||
|
||||
public interface TextWatcher extends NoCopySpan, android.text.TextWatcher {
|
||||
void beforeTextChanged(CharSequence var1, int var2, int var3, int var4);
|
||||
|
||||
void onTextChanged(CharSequence var1, int var2, int var3, int var4);
|
||||
|
||||
void afterTextChanged(Editable var1);
|
||||
}
|
||||
}
|
9
app/src/main/res/drawable/chahao.xml
Normal file
9
app/src/main/res/drawable/chahao.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="36dp"
|
||||
android:height="36dp"
|
||||
android:viewportWidth="1024"
|
||||
android:viewportHeight="1024">
|
||||
<path
|
||||
android:pathData="M240.5,180.2l271.5,271.5 271.5,-271.5a42.7,42.7 0,0 1,56.3 -3.5l4,3.5a42.7,42.7 0,0 1,0 60.3l-271.5,271.5 271.5,271.5a42.7,42.7 0,0 1,-56.3 63.9l-4,-3.5 -271.5,-271.5 -271.5,271.5 -4,3.5a42.7,42.7 0,0 1,-56.3 -63.9l271.5,-271.5 -271.5,-271.5a42.7,42.7 0,0 1,60.3 -60.3z"
|
||||
android:fillColor="#000000"/>
|
||||
</vector>
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="100dp"
|
||||
android:width="100dp"
|
||||
android:height="36dp"
|
||||
android:width="36dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context=".activity_about_software">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical">
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
|
|
|
@ -1,88 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical">
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:title="绑定网易云音乐"
|
||||
app:subtitle="(Cookie保存在本地)"/>
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:fillViewport="true">
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<LinearLayout
|
||||
android:id="@+id/view1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical">
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:autofillHints="name"
|
||||
android:hint="网易云账号/网易云邮箱"
|
||||
android:inputType="text"
|
||||
android:singleLine="true"
|
||||
tools:ignore="TextContrastCheck,VisualLintTextFieldSize" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
app:passwordToggleEnabled="true">
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:autofillHints="name"
|
||||
android:hint="密码"
|
||||
android:inputType="text"
|
||||
android:singleLine="true"
|
||||
tools:ignore="TextContrastCheck,VisualLintTextFieldSize" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="登录"
|
||||
tools:ignore="VisualLintButtonSize" />
|
||||
</LinearLayout>
|
||||
<RelativeLayout
|
||||
android:id="@+id/view2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="visible">
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="36dp"
|
||||
app:cardUseCompatPadding="true">
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/app_name"
|
||||
android:textSize="16sp"
|
||||
android:gravity="center_horizontal" />
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:src="@drawable/icon" />
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</LinearLayout>
|
|
@ -3,6 +3,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical">
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
android:id="@+id/home"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical"
|
||||
tools:context=".home">
|
||||
|
||||
|
@ -19,31 +18,6 @@
|
|||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?attr/actionBarSize">
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/editView"
|
||||
android:background="@drawable/ui_editview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp">
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:autofillHints=""
|
||||
android:enabled="false"
|
||||
android:gravity="center"
|
||||
android:text="@string/search"
|
||||
android:minHeight="48dp"
|
||||
android:paddingStart="3dp"
|
||||
android:paddingEnd="3dp"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</com.google.android.material.appbar.MaterialToolbar>
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/viewPager"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -70,6 +44,7 @@
|
|||
android:layout_gravity="start"
|
||||
app:headerLayout="@layout/fragment_sz"
|
||||
app:itemTextColor="@color/text"
|
||||
android:background="@color/ztl"
|
||||
app:menu="@menu/sz" />
|
||||
</androidx.drawerlayout.widget.DrawerLayout>
|
||||
</FrameLayout>
|
|
@ -2,6 +2,7 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical">
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
|
|
|
@ -10,20 +10,11 @@
|
|||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<EditText
|
||||
<com.muqingbfq.view.Edit
|
||||
android:id="@+id/editview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:autofillHints=""
|
||||
android:background="@drawable/ui_editview"
|
||||
android:hint="@string/search"
|
||||
android:imeOptions="actionSearch"
|
||||
android:inputType="text"
|
||||
android:minHeight="48dp"
|
||||
android:paddingStart="3dp"
|
||||
android:paddingEnd="3dp"
|
||||
tools:ignore="TextContrastCheck,VisualLintTextFieldSize" />
|
||||
android:enabled="false"/>
|
||||
</com.google.android.material.appbar.MaterialToolbar>
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context=".sz">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context=".yc">
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
|
|
|
@ -1,56 +1,82 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="6dp"
|
||||
android:text="每日趣荐"
|
||||
android:textSize="26sp" />
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardUseCompatPadding="true"
|
||||
app:contentPadding="6dp">
|
||||
android:minHeight="?attr/actionBarSize">
|
||||
|
||||
<com.muqingbfq.view.RecyclerViewH
|
||||
android:id="@+id/recyclerview1"
|
||||
<com.muqingbfq.view.Edit
|
||||
android:id="@+id/editView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusable="false"
|
||||
tools:itemCount="6" />
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
android:layout_margin="10dp"
|
||||
app:Enabled="false"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</com.google.android.material.appbar.MaterialToolbar>
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="6dp"
|
||||
android:text="每日一首"
|
||||
android:textSize="26sp" />
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardUseCompatPadding="true"
|
||||
app:contentPadding="6dp">
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerview2"
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="6dp"
|
||||
android:text="每日趣荐"
|
||||
android:textSize="26sp" />
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
</LinearLayout>
|
||||
android:layout_height="wrap_content"
|
||||
app:cardUseCompatPadding="true"
|
||||
app:contentPadding="6dp">
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
<com.muqingbfq.view.RecyclerViewH
|
||||
android:id="@+id/recyclerview1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusable="false"
|
||||
tools:itemCount="6" />
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="6dp"
|
||||
android:text="每日一首"
|
||||
android:textSize="26sp" />
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardUseCompatPadding="true"
|
||||
app:contentPadding="6dp">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerview2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
@ -3,7 +3,8 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context=".fragment.sz">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -1,88 +1,122 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/cardview"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/appbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardUseCompatPadding="true"
|
||||
app:contentPadding="6dp"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
android:id="@+id/collapsing"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp">
|
||||
<androidx.constraintlayout.utils.widget.ImageFilterView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="65dp"
|
||||
android:layout_height="65dp"
|
||||
android:layout_margin="6dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:round="16dp"
|
||||
app:srcCompat="@drawable/ic_launcher_foreground" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/app_name"
|
||||
android:textSize="26sp"/>
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/app_name"/>
|
||||
</LinearLayout>
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:layout_collapseMode="pin">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_horizontal">
|
||||
<TextView
|
||||
android:id="@+id/aaa"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/app_name"
|
||||
android:textSize="26sp"
|
||||
android:visibility="gone"
|
||||
app:layout_collapseMode="pin"/>
|
||||
</LinearLayout>
|
||||
</com.google.android.material.appbar.MaterialToolbar>
|
||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.constraintlayout.utils.widget.ImageFilterView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="65dp"
|
||||
android:layout_height="65dp"
|
||||
app:srcCompat="@drawable/ic_launcher_foreground"
|
||||
android:layout_margin="6dp"
|
||||
app:round="16dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/app_name"
|
||||
android:textSize="26sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/imageView" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/text1"
|
||||
android:text="@string/app_name"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/cardview2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
app:cardUseCompatPadding="true"
|
||||
app:contentPadding="6dp"
|
||||
app:layout_constraintTop_toBottomOf="@+id/cardview">
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerview1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
app:cardUseCompatPadding="true"
|
||||
app:contentPadding="6dp"
|
||||
app:layout_constraintTop_toBottomOf="@+id/cardview2">
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerview2"
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/cardview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"/>
|
||||
</RelativeLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</ScrollView>
|
||||
app:cardUseCompatPadding="true"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/cardview2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardUseCompatPadding="true"
|
||||
app:contentPadding="6dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/cardview">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerview1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
app:cardUseCompatPadding="true"
|
||||
app:contentPadding="6dp"
|
||||
app:layout_constraintTop_toBottomOf="@+id/cardview2">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerview2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
|
||||
</RelativeLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="ztl">#1C1B1F</color>
|
||||
<color name="text">@color/white</color>
|
||||
<color name="text_tm">#CCC2DC</color>
|
||||
<color name="bj">#2A2831</color>
|
||||
|
|
|
@ -7,5 +7,6 @@
|
|||
<!– Secondary brand color. –>
|
||||
<item name="colorOnSecondary">@color/text</item>-->
|
||||
<item name="android:windowLightStatusBar">false</item>
|
||||
|
||||
</style>
|
||||
</resources>
|
|
@ -28,4 +28,9 @@
|
|||
<declare-styleable name="AbsCustomSlider">
|
||||
<attr name="inVerticalOrientation" format="boolean"/>
|
||||
</declare-styleable>
|
||||
|
||||
|
||||
<declare-styleable name="Edit">
|
||||
<attr name="Enabled" format="boolean" />
|
||||
</declare-styleable>
|
||||
</resources>
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="ztl">#FFFBFE</color>
|
||||
<color name="purple_200">#0088FF</color>
|
||||
<color name="purple_500">#FF6200EE</color>
|
||||
<color name="purple_700">#FF3700B3</color>
|
||||
|
|
|
@ -4,22 +4,28 @@
|
|||
<!-- <item name="colorOnPrimary">@color/text</item>-->
|
||||
<!-- <item name="colorOnSecondary">@color/text</item>-->
|
||||
<item name="android:windowLightStatusBar">true</item>
|
||||
|
||||
</style>
|
||||
|
||||
<style name="Theme.start" parent="Theme.Material3.DayNight">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
<item name="android:statusBarColor">@color/bj</item>
|
||||
|
||||
<!-- 添加主题属性以启用沉浸式状态栏 -->
|
||||
<item name="android:windowTranslucentStatus">true</item>
|
||||
|
||||
<!-- <item name="android:statusBarColor">@color/ztl</item>-->
|
||||
<!-- 控件选中时的颜色,默认使用colorAccent -->
|
||||
<!-- <item name="android:colorControlActivated">#FF7F50</item>-->
|
||||
<!-- 设置文本颜色 -->
|
||||
<!--
|
||||
<item name="android:textColorPrimary">@color/text</item>
|
||||
<item name="android:colorPrimary">@color/bj</item>
|
||||
<item name="colorPrimaryDark">@color/bj</item>
|
||||
-->
|
||||
|
||||
<!--
|
||||
<item name="tabStyle">@style/Widget.App.TabLayout</item>
|
||||
<item name="toolbarStyle">@style/Widget.App.Toolbar</item>
|
||||
<item name="toolbarStyle">@style/Widget.App.Toolbar</item>-->
|
||||
</style>
|
||||
|
||||
<style name="ThemeOverlay.App.Toolbar" parent="">
|
||||
|
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,6 +1,6 @@
|
|||
#Sat Nov 18 17:46:31 CST 2023
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
|
||||
distributionUrl=https://mirrors.cloud.tencent.com/gradle/gradle-8.0-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
BIN
muqing.jks
Normal file
BIN
muqing.jks
Normal file
Binary file not shown.
|
@ -15,4 +15,5 @@ dependencyResolutionManagement {
|
|||
}
|
||||
|
||||
rootProject.name = "Cloud_music"
|
||||
include ':app'
|
||||
include ':app'
|
||||
include(':StatusBarUtil')
|
Loading…
Reference in New Issue
Block a user