-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
高鑫
committed
Sep 29, 2019
0 parents
commit 958bcef
Showing
26 changed files
with
2,604 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# **AndroidAutoSize** 0.7.0 + 1.1.2 综合版本 | ||
|
||
本项目是解决低版本适配问题 解决 [#32错误](https://github.com/JessYanCoding/AndroidAutoSize/issues/32) | ||
|
||
不包含 | ||
|
||
``` | ||
FragmentManager.FragmentLifecycleCallbacks | ||
``` | ||
|
||
在AutoSize 0.7.0 的基础上 去掉了 fragment 适配 | ||
|
||
|
||
使用 AutoSizeCompat 类,使用以下代码即可解决所有屏幕适配失效的问题 | ||
|
||
``` | ||
@Override | ||
public Resources getResources() { | ||
//如果没有自定义需求用这个方法 | ||
AutoSizeCompat.autoConvertDensityOfGlobal((super.getResources()); | ||
//如果有自定义需求就用这个方法 | ||
AutoSizeCompat.autoConvertDensity((super.getResources(), 667, false); | ||
return super.getResources(); | ||
} | ||
AutoSizeConfig.getInstance().setExcludeFontScale(true); 一行代码即可实现 App 内的字体大小不跟随系统设置中字体大小的改 | ||
``` | ||
|
||
|
||
|
||
|
||
|
||
`注意:` 本项目是LIbrary 请使用 Module 方式导入项目使用 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
apply plugin: 'com.android.library' | ||
|
||
android { | ||
compileSdkVersion 28 | ||
buildToolsVersion "28.0.3" | ||
|
||
|
||
defaultConfig { | ||
minSdkVersion 14 | ||
targetSdkVersion 21 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
|
||
} | ||
|
||
dependencies { | ||
provided 'com.android.support:appcompat-v7:28.0.0' | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# 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 *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="me.jessyan.autosize"> | ||
<application> | ||
<provider | ||
android:name="me.jessyan.autosize.InitProvider" | ||
android:authorities="${applicationId}.init-Provider" | ||
android:exported="false" | ||
android:multiprocess="false" /> | ||
</application> | ||
</manifest> |
48 changes: 48 additions & 0 deletions
48
src/main/java/me/jessyan/autosize/ActivityLifecycleCallbacksImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// | ||
// Source code recreated from a .class file by IntelliJ IDEA | ||
// (powered by Fernflower decompiler) | ||
// | ||
|
||
package me.jessyan.autosize; | ||
|
||
import android.app.Activity; | ||
import android.app.Application.ActivityLifecycleCallbacks; | ||
import android.os.Bundle; | ||
|
||
public class ActivityLifecycleCallbacksImpl implements ActivityLifecycleCallbacks { | ||
private AutoAdaptStrategy mAutoAdaptStrategy; | ||
|
||
public ActivityLifecycleCallbacksImpl(AutoAdaptStrategy autoAdaptStrategy) { | ||
this.setAutoAdaptStrategy(autoAdaptStrategy); | ||
} | ||
|
||
@Override | ||
public void onActivityCreated(Activity activity, Bundle savedInstanceState) { | ||
if (this.mAutoAdaptStrategy != null) { | ||
this.mAutoAdaptStrategy.applyAdapt(activity,activity); | ||
} | ||
|
||
} | ||
@Override | ||
public void onActivityStarted(Activity activity) { | ||
} | ||
@Override | ||
public void onActivityResumed(Activity activity) { | ||
} | ||
@Override | ||
public void onActivityPaused(Activity activity) { | ||
} | ||
@Override | ||
public void onActivityStopped(Activity activity) { | ||
} | ||
@Override | ||
public void onActivitySaveInstanceState(Activity activity, Bundle outState) { | ||
} | ||
@Override | ||
public void onActivityDestroyed(Activity activity) { | ||
} | ||
|
||
public void setAutoAdaptStrategy(AutoAdaptStrategy autoAdaptStrategy) { | ||
this.mAutoAdaptStrategy = autoAdaptStrategy; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2018 JessYan | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package me.jessyan.autosize; | ||
|
||
import android.app.Activity; | ||
import android.app.Application; | ||
import android.support.v4.app.Fragment; | ||
import android.util.DisplayMetrics; | ||
|
||
/** | ||
* ================================================ | ||
* 屏幕适配逻辑策略类, 可通过 {@link AutoSizeConfig#init(Application, boolean, AutoAdaptStrategy)} | ||
* 和 {@link AutoSizeConfig#setAutoAdaptStrategy(AutoAdaptStrategy)} 切换策略 | ||
* | ||
* @see DefaultAutoAdaptStrategy | ||
* Created by JessYan on 2018/8/9 15:13 | ||
* <a href="mailto:[email protected]">Contact me</a> | ||
* <a href="https://github.com/JessYanCoding">Follow me</a> | ||
* ================================================ | ||
*/ | ||
public interface AutoAdaptStrategy { | ||
|
||
/** | ||
* 开始执行屏幕适配逻辑 | ||
* | ||
* @param target 需要屏幕适配的对象 (可能是 {@link Activity} 或者 {@link Fragment}) | ||
* @param activity 需要拿到当前的 {@link Activity} 才能修改 {@link DisplayMetrics#density} | ||
*/ | ||
void applyAdapt(Object target, Activity activity); | ||
} |
Oops, something went wrong.