Skip to content

Commit 0d819c3

Browse files
AriesHoo@126.comAriesHoo@126.com
AriesHoo@126.com
authored and
AriesHoo@126.com
committed
调整启动页效果
1 parent 6639727 commit 0d819c3

File tree

10 files changed

+161
-44
lines changed

10 files changed

+161
-44
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ android {
7676
dependencies {
7777
implementation fileTree(include: ['*.jar'], dir: 'libs')
7878
implementation project(':library')
79-
// implementation 'com.github.AriesHoo:FastLib:2.3.2'
79+
// implementation 'com.github.AriesHoo:FastLib:2.3.3'
8080
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.3'
8181
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3'
8282
testImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3'

app/src/main/AndroidManifest.xml

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="com.aries.library.fast.demo">
3+
package="com.aries.library.fast.demo">
44

55
<!--<uses-feature android:name="android.hardware.screen.portrait"/>-->
66

7-
<uses-permission android:name="android.permission.INTERNET"/>
8-
<uses-permission android:name="android.permission.CAMERA"/>
9-
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
10-
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
11-
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
7+
<uses-permission android:name="android.permission.INTERNET" />
8+
<uses-permission android:name="android.permission.CAMERA" />
9+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
10+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
11+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
1212
<!-- AgentWeb 是默认启动定位 -->
13-
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
14-
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
15-
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
16-
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
17-
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
13+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
14+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
15+
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
16+
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
17+
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
1818

1919

2020
<application
2121
android:name=".App"
2222
android:allowBackup="true"
2323
android:icon="@drawable/ic_launcher"
24+
android:roundIcon="@drawable/ic_launcher"
2425
android:label="@string/app_name"
2526
android:supportsRtl="true"
2627
android:theme="@style/AppTheme">
@@ -33,7 +34,8 @@
3334
android:value="${app_channel}" />
3435
<meta-data
3536
android:name="BaiduMobAd_CHANNEL"
36-
android:value="${app_channel}"/>
37+
android:value="${app_channel}" />
38+
3739
<provider
3840
android:name="androidx.core.content.FileProvider"
3941
android:authorities="${applicationId}.fileprovider"
@@ -47,78 +49,79 @@
4749
<provider
4850
android:name="com.pgyersdk.PgyerProvider"
4951
android:authorities="${applicationId}.com.pgyer.provider"
50-
android:exported="false"/>
52+
android:exported="false" />
5153
<!-- 必填 -->
5254
<meta-data
5355
android:name="PGYER_APPID"
54-
android:value="${PGYER_ID}">
55-
</meta-data>
56+
android:value="${PGYER_ID}"></meta-data>
57+
5658
<activity
5759
android:name=".module.SplashActivity"
58-
android:configChanges="locale|layoutDirection|mcc|mnc">
60+
android:configChanges="locale|layoutDirection|mcc|mnc"
61+
android:theme="@style/NormalSplash">
5962
<intent-filter>
60-
<action android:name="android.intent.action.MAIN"/>
61-
<category android:name="android.intent.category.LAUNCHER"/>
63+
<action android:name="android.intent.action.MAIN" />
64+
<category android:name="android.intent.category.LAUNCHER" />
6265
</intent-filter>
6366
</activity>
6467
<activity
6568
android:name=".module.main.MainActivity"
66-
android:launchMode="singleTop"
67-
android:configChanges="locale|layoutDirection|mcc|mnc|orientation|screenSize"/>
69+
android:configChanges="locale|layoutDirection|mcc|mnc|orientation|screenSize"
70+
android:launchMode="singleTop" />
6871
<!-- 应用内浏览器 -->
6972
<activity
7073
android:name=".module.WebViewActivity"
7174
android:configChanges="locale|layoutDirection|mcc|mnc|orientation|screenSize"
7275
android:hardwareAccelerated="true"
73-
android:label="@string/fast_loading"/>
76+
android:label="@string/fast_loading" />
7477
<activity
7578
android:name=".module.WebAppActivity"
7679
android:configChanges="locale|layoutDirection|mcc|mnc|orientation|screenSize"
7780
android:hardwareAccelerated="true"
78-
android:label="@string/fast_loading"/>
81+
android:label="@string/fast_loading" />
7982
<activity
8083
android:name=".module.main.sample.TitleWithEditTextActivity"
8184
android:configChanges="locale|layoutDirection|mcc|mnc"
82-
android:label="Title+底部输入框测试"/>
85+
android:label="Title+底部输入框测试" />
8386
<activity
8487
android:name=".module.main.sample.ToastActivity"
85-
android:label="ToastUtil工具类示例"/>
88+
android:label="ToastUtil工具类示例" />
8689
<activity
8790
android:name=".module.main.sample.SingleFragmentActivity"
8891
android:configChanges="locale|layoutDirection|mcc|mnc"
89-
android:label="Activity直接嵌套Fragment懒加载效果"/>
92+
android:label="Activity直接嵌套Fragment懒加载效果" />
9093
<activity
9194
android:name=".module.main.sample.SwipeBackActivity"
9295
android:configChanges="locale|layoutDirection|mcc|mnc"
93-
android:label="微信滑动返回样式效果"/>
96+
android:label="微信滑动返回样式效果" />
9497
<activity
9598
android:name=".module.main.sample.QQTitleActivity"
9699
android:configChanges="locale|layoutDirection|mcc|mnc"
97-
android:label="QQ默认主题TitleBar背景渐变"/>
100+
android:label="QQ默认主题TitleBar背景渐变" />
98101
<activity
99102
android:name=".module.main.sample.ali.ALiPayMainActivity"
100103
android:configChanges="locale|layoutDirection|mcc|mnc"
101-
android:label="支付宝主界面效果"/>
104+
android:label="支付宝主界面效果" />
102105
<activity
103106
android:name=".module.main.sample.news.NewsMainActivity"
104107
android:configChanges="locale|layoutDirection|mcc|mnc"
105-
android:label="腾讯新闻主界面效果"/>
108+
android:label="腾讯新闻主界面效果" />
106109
<activity
107110
android:name=".module.main.sample.TestStatusActivity"
108111
android:configChanges="locale|layoutDirection|mcc|mnc"
109-
android:label="@string/test_status"/>
112+
android:label="@string/test_status" />
110113
<activity
111114
android:name=".module.main.sample.FastViewActivity"
112115
android:configChanges="locale|layoutDirection|mcc|mnc"
113-
android:label="模拟快速下拉刷新及TitleBarView统一设置"/>
116+
android:label="模拟快速下拉刷新及TitleBarView统一设置" />
114117
<activity
115118
android:name=".module.mine.SettingActivity"
116119
android:configChanges="locale|layoutDirection|mcc|mnc"
117-
android:label="@string/setting"/>
120+
android:label="@string/setting" />
118121
<activity
119122
android:name=".module.mine.ThirdLibraryActivity"
120123
android:configChanges="locale|layoutDirection|mcc|mnc"
121-
android:label="@string/third_part"/>
124+
android:label="@string/third_part" />
122125
</application>
123126

124127
</manifest>

app/src/main/java/com/aries/library/fast/demo/module/SplashActivity.java

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package com.aries.library.fast.demo.module;
22

3+
import android.animation.Animator;
4+
import android.animation.AnimatorListenerAdapter;
5+
import android.animation.AnimatorSet;
6+
import android.animation.ObjectAnimator;
37
import android.graphics.Color;
48
import android.os.Bundle;
59
import android.view.View;
@@ -16,6 +20,8 @@
1620
import com.aries.library.fast.retrofit.FastObserver;
1721
import com.aries.library.fast.util.FastStackUtil;
1822
import com.aries.library.fast.util.FastUtil;
23+
import com.aries.library.fast.util.SizeUtil;
24+
import com.aries.ui.helper.navigation.NavigationBarUtil;
1925
import com.aries.ui.util.DrawableUtil;
2026
import com.aries.ui.util.StatusBarUtil;
2127
import com.aries.ui.view.title.TitleBarView;
@@ -34,6 +40,10 @@ public class SplashActivity extends FastTitleActivity {
3440
@BindView(R.id.tv_appSplash) TextView tvApp;
3541
@BindView(R.id.tv_versionSplash) TextView tvVersion;
3642
@BindView(R.id.tv_copyRightSplash) TextView tvCopyRight;
43+
/**
44+
* 闪屏
45+
*/
46+
private long mDelayTime = 1800;
3747

3848
@Override
3949
public void beforeSetContentView() {
@@ -68,20 +78,72 @@ public void initView(Bundle savedInstanceState) {
6878
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
6979
}
7080
tvApp.setCompoundDrawablesWithIntrinsicBounds(null,
71-
DrawableUtil.setTintDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_launcher).mutate(), Color.WHITE)
81+
DrawableUtil.setTintDrawable(ContextCompat.getDrawable(mContext, R.drawable.img_splash).mutate(), Color.WHITE)
7282
, null, null);
7383
mContentView.setBackgroundResource(R.drawable.img_bg_login);
7484
tvVersion.setText("V" + FastUtil.getVersionName(mContext));
7585
tvVersion.setTextColor(Color.WHITE);
7686
tvCopyRight.setTextColor(Color.WHITE);
77-
RxJavaManager.getInstance().setTimer(2000)
87+
startAnimator();
88+
}
89+
90+
/**
91+
* 动画
92+
*/
93+
private void startAnimator() {
94+
float transY = (SizeUtil.getScreenHeight() + NavigationBarUtil.getNavigationBarHeight(this)) * 0.25f;
95+
//以控件自身所在的位置为原点,从下方距离原点200像素的位置移动到原点
96+
ObjectAnimator tranCenter = ObjectAnimator.ofFloat(tvVersion, "translationY", transY, 0);
97+
ObjectAnimator tranBottom = ObjectAnimator.ofFloat(tvCopyRight, "translationY", transY, 0);
98+
//将控件alpha属性从0变到1
99+
ObjectAnimator alphaCenter = ObjectAnimator.ofFloat(tvVersion, "alpha", 0, 1);
100+
ObjectAnimator alphaBottom = ObjectAnimator.ofFloat(tvCopyRight, "alpha", 0, 1);
101+
//初始化logo的移动和缩放动画
102+
103+
//logo由屏幕中间移动回原始位置
104+
ObjectAnimator tranLogo = ObjectAnimator.ofFloat(tvApp, "translationY", transY, 0);
105+
//ivLogo在X轴和Y轴上都由0.5倍缩放到原本尺寸
106+
ObjectAnimator scaleXLogo = ObjectAnimator.ofFloat(tvApp, "scaleX", 0.5f, 1f);
107+
ObjectAnimator scaleYLogo = ObjectAnimator.ofFloat(tvApp, "scaleY", 0.5f, 1f);
108+
AnimatorSet animatorSet = new AnimatorSet();
109+
animatorSet.setDuration(mDelayTime*2/3);
110+
animatorSet.play(tranLogo)
111+
.with(scaleXLogo)
112+
.with(scaleYLogo)
113+
.with(tranCenter)
114+
.with(tranBottom)
115+
.with(alphaCenter)
116+
.with(alphaBottom);
117+
animatorSet.start();
118+
119+
animatorSet.addListener(new AnimatorListenerAdapter() {
120+
@Override
121+
public void onAnimationEnd(Animator animation) {
122+
super.onAnimationEnd(animation);
123+
startGo();
124+
}
125+
});
126+
}
127+
128+
private void startGo() {
129+
RxJavaManager.getInstance().setTimer(mDelayTime/3)
78130
.compose(bindUntilEvent(ActivityEvent.DESTROY))
79131
.subscribe(new FastObserver<Long>() {
80132
@Override
81133
public void _onNext(Long entity) {
134+
if (isFinishing() || isDestroyed()) {
135+
return;
136+
}
82137
FastUtil.startActivity(mContext, MainActivity.class);
83138
finish();
84139
}
85140
});
86141
}
142+
143+
@Override
144+
public void onWindowFocusChanged(boolean hasFocus) {
145+
super.onWindowFocusChanged(hasFocus);
146+
StatusBarUtil.hideStatusBar(this,true);
147+
NavigationBarUtil.hideNavigationBar(this,true);
148+
}
87149
}
Loading
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item android:drawable="@drawable/img_bg_login" />
4+
<item>
5+
<bitmap
6+
android:gravity="center"
7+
android:src="@drawable/img_splash" />
8+
</item>
9+
</layer-list>

app/src/main/res/layout/activity_splash.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
android:layout_width="wrap_content"
2020
android:layout_height="wrap_content"
2121
android:drawablePadding="12dp"
22-
android:drawableTop="@drawable/ic_launcher"
22+
android:drawableTop="@drawable/img_splash"
2323
android:gravity="center"
2424
android:text="@string/app_name"
2525
android:textColor="@color/colorWhite"

app/src/main/res/values/styles.xml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<resources
2-
xmlns:tools="http://schemas.android.com/tools">
1+
<resources xmlns:tools="http://schemas.android.com/tools">
32

43
<!-- Base application theme. -->
54
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
@@ -14,6 +13,21 @@
1413
<item name="android:windowIsTranslucent">false</item>
1514
</style>
1615

16+
<style name="NormalSplash" parent="AppTheme">
17+
<item name="android:windowBackground">@drawable/layer_bg_splash</item>
18+
<item name="android:windowDisablePreview">false</item>
19+
<item name="android:windowNoDisplay">false</item>
20+
<item name="android:windowNoTitle">true</item>
21+
<item name="windowActionBar">false</item>
22+
<item name="windowNoTitle">true</item>
23+
<item name="android:windowLightStatusBar" tools:targetApi="M">true</item>
24+
<item name="android:windowLightNavigationBar" tools:targetApi="O_MR1">true</item>
25+
<item name="android:statusBarColor" tools:targetApi="lollipop">@color/transparent</item>
26+
<item name="android:navigationBarColor" tools:targetApi="lollipop">@color/transparent</item>
27+
<item name="android:windowFullscreen">false</item>
28+
<item name="android:windowContentOverlay">@null</item>
29+
</style>
30+
1731
<style name="SupperTextStyleItem">
1832
<item name="android:layout_width">match_parent</item>
1933
<item name="android:layout_height">wrap_content</item>

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ buildscript {
66
google()
77
}
88
dependencies {
9-
classpath 'com.android.tools.build:gradle:3.5.0'
9+
classpath 'com.android.tools.build:gradle:3.5.1'
1010
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
1111
}
1212
}
@@ -27,7 +27,7 @@ task clean(type: Delete) {
2727

2828
ext{
2929
compileSdkVersion = 28
30-
minSdkVersion = 16
30+
minSdkVersion = 17
3131
minLibSdkVersion = 15
3232
targetSdkVersion = 28
3333
supportVersion = "1.0.0"

library/src/main/AndroidManifest.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@
1717
android:name="android.support.FILE_PROVIDER_PATHS"
1818
android:resource="@xml/fast_file_path"/>
1919
</provider>
20+
<!--华为使用刘海区域申明-->
21+
<meta-data
22+
android:name="android.notch_support"
23+
android:value="true" />
24+
<!--小米使用刘海区域申明-->
25+
<meta-data
26+
android:name="notch.config"
27+
android:value="portrait|landscape" />
2028
<!--增加纵横比 全面屏适配-->
21-
<meta-data android:name="android.max_aspect" android:value="2.1"/>
29+
<meta-data android:name="android.max_aspect" android:value="2.4"/>
2230
</application>
2331
</manifest>

library/src/main/java/com/aries/library/fast/util/FastUtil.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public static Application getApplication() {
5757
try {
5858
//兼容android P,直接调用@hide注解的方法来获取application对象
5959
Application app = ActivityThread.currentApplication();
60-
LoggerManager.e("getApplication0:"+app);
60+
LoggerManager.e("getApplication0:" + app);
6161
if (app != null) {
6262
return app;
6363
}
@@ -66,7 +66,7 @@ public static Application getApplication() {
6666
try {
6767
//兼容android P,直接调用@hide注解的方法来获取application对象
6868
Application app = AppGlobals.getInitialApplication();
69-
LoggerManager.e("getApplication1:"+app);
69+
LoggerManager.e("getApplication1:" + app);
7070
if (app != null) {
7171
return app;
7272
}
@@ -335,6 +335,27 @@ public static void startActivity(Context context, Class<? extends Activity> acti
335335
startActivity(context, activity, null, isSingle);
336336
}
337337

338+
/**
339+
* 根据包名跳转应用
340+
*
341+
* @param context
342+
* @param packageName
343+
*/
344+
public static void startApp(Context context, String packageName) {
345+
if (context == null) {
346+
return;
347+
}
348+
Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage(packageName);
349+
if (launchIntent == null) {
350+
return;
351+
}
352+
Intent intent = new Intent(Intent.ACTION_MAIN);
353+
intent.addCategory(Intent.CATEGORY_LAUNCHER);
354+
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
355+
intent.setComponent(launchIntent.getComponent());
356+
context.startActivity(intent);
357+
}
358+
338359
/**
339360
* @param context 上下文
340361
* @param text 分享内容

0 commit comments

Comments
 (0)