Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaofengyi committed Sep 29, 2019
1 parent 55806f8 commit e3ea103
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Android/JNI/jni.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ hih

## JNIEnv

###简介
### 简介

**JNIEnv类型实际上代表了Java环境,通过这个JNIEnv* 指针,就可以对Java端的代码进行操作。**例如,创建Java类中的对象,调用Java对象的方法,获取Java对象中的属性等等。JNIEnv的指针会被JNI传入到本地方法的实现函数中来对Java端的代码进行操作。

Expand Down
26 changes: 24 additions & 2 deletions Android/WorkExperience/android.adatper.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@ https://www.jianshu.com/p/1302ad5a4b04

https://github.com/wildma/ScreenAdaptation/blob/master/app/src/main/res/values/dimens.xml

不能应对density变化?

2. 用限制性布局ConstraintLayout

少用dp值,多用百分比

可以应对density变化


> implementation 'com.android.support.constraint:constraint-layout:1.1.3'
```xml
Expand Down Expand Up @@ -44,13 +51,28 @@ https://github.com/wildma/ScreenAdaptation/blob/master/app/src/main/res/values/d
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintVertical_bias="0.55" />
<ImageView
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintHeight_default="percent"
app:layout_constraintHeight_percent="0.15"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintVertical_bias="0.7"
android:src="@drawable/testImg" />
</android.support.constraint.ConstraintLayout>
```

* 图片用.9; 多用相对布局,尽量不用绝对布局;
* 图片用.9或者svg; 多用相对布局,尽量不用绝对布局;





3. 通过gradle flavor选择不同的sourceset
3. 通过gradle flavor选择不同的sourceset
4. 用自适应textview
https://blog.csdn.net/Virgil_K2017/article/details/88725298
9 changes: 8 additions & 1 deletion Android/WorkExperience/launcher.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ private class PackageUpdatedTask {



###Android原生Launcher源码更多分析参考:
### Android原生Launcher源码更多分析参考:

* Android 7.0 Launcher3源码实现全解析

Expand All @@ -216,3 +216,10 @@ https://blog.csdn.net/kuaiguixs/article/details/78890509

https://github.com/FrannyZhao/LauncherDemo



衍生阅读:

Android Launcher 启动 Activity 的工作过程

https://blog.csdn.net/qian520ao/article/details/78156214
106 changes: 106 additions & 0 deletions Android/WorkExperience/set.default.IME.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
[TOC]

# Android 修改默认输入法

安卓会根据系统设置的国家地区locale选择匹配的输入法,比如当前是中国地区,匹配的输入法是中文输入法(如果系统里面安装了中文输入法的话)。

项目有个奇怪的需求是无论locale是哪里,默认的输入法都要是英文输入法。

那么就要修改framework层设置默认IME的代码了。

我只验证了安卓4.4.4,7.1.2,8.1.0这三个版本,思路都是一样的,就是找到设置默认IME的地方,返回我们想要的IME即可。

### 7.1.2 & 8.1.0

frameworks/base/core/java/com/android/internal/inputmethod/InputMethodUtils.java

```java
public InputMethodListBuilder fillImes(final ArrayList<InputMethodInfo> imis,
final Context context, final boolean checkDefaultAttribute,
@Nullable final Locale locale, final boolean checkCountry,
final String requiredSubtypeMode) {
for (int i = 0; i < imis.size(); ++i) {
final InputMethodInfo imi = imis.get(i);
Log.i(TAG, "fillImes imi " + imi.toString());
// 【开始】添加以下代码,设置默认IME
if (imi.getId().equals("com.android.inputmethod.latin/.LatinIME")) {
mInputMethodSet.clear();
mInputMethodSet.add(imi);
Log.i(TAG, "no matter what locale, just set LatinIME as default");
break;
}
//【结束】
if (isSystemImeThatHasSubtypeOf(imi, context, checkDefaultAttribute, locale,
checkCountry, requiredSubtypeMode)) {
mInputMethodSet.add(imi);
}
}
return this;
}

```



### 4.4.4

frameworks/base/core/java/com/android/internal/inputmethod/InputMethodUtils.java

```java
public static ArrayList<InputMethodInfo> getDefaultEnabledImes(
Context context, boolean isSystemReady, ArrayList<InputMethodInfo> imis) {
final ArrayList<InputMethodInfo> retval = new ArrayList<InputMethodInfo>();
boolean auxilialyImeAdded = false;
for (int i = 0; i < imis.size(); ++i) {
final InputMethodInfo imi = imis.get(i);
Log.i(TAG, "getDefaultEnabledImes imi " + imi.toString());
// 【开始】添加以下代码,设置默认IME
if (imi.getId().equals("com.android.inputmethod.latin/.LatinIME")) {
retval.clear();
retval.add(imi);
Log.i(TAG, "no matter what locale, just set LatinIME as default");
return retval;
}
//【结束】
if (isDefaultEnabledIme(isSystemReady, imi, context)) {
retval.add(imi);
if (imi.isAuxiliaryIme()) {
auxilialyImeAdded = true;
}
}
}
if (auxilialyImeAdded) {
return retval;
}
for (int i = 0; i < imis.size(); ++i) {
final InputMethodInfo imi = imis.get(i);
if (isSystemAuxilialyImeThatHashAutomaticSubtype(imi)) {
retval.add(imi);
}
}
return retval;
}

```

frameworks/base/services/java/com/android/server/InputMethodManagerService.java

```java
diff --git a/frameworks/base/services/java/com/android/server/InputMethodManagerService.java b/frameworks/base/services/java/com/android/server/InputMethodManagerService.java
index 16b2d4d..0ff5006 100755
--- a/frameworks/base/services/java/com/android/server/InputMethodManagerService.java
+++ b/frameworks/base/services/java/com/android/server/InputMethodManagerService.java
@@ -724,8 +724,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
InputMethodInfo defIm = null;
for (InputMethodInfo imi : mMethodList) {
if (defIm == null) {
- if (InputMethodUtils.isValidSystemDefaultIme(
- mSystemReady, imi, context)) {
+// if (InputMethodUtils.isValidSystemDefaultIme(
+// mSystemReady, imi, context)) {
+ if (imi.getId().equals("com.android.inputmethod.latin/.LatinIME")) {
defIm = imi;
Slog.i(TAG, "Selected default: " + imi.getId());
}

```
6 changes: 6 additions & 0 deletions Others/tmp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
安卓调色盘

https://blog.csdn.net/feiniyan4944/article/details/79036120

https://blog.csdn.net/CrazyMo_/article/details/53939823

6 changes: 6 additions & 0 deletions SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
* Array
* [Median Of Two Sorted Arrays](Algorithms/Array/median.of.two.sorted.arrays.md)
* [Two Sum](Algorithms/Array/two.sum.md)
* [Basic_knowledge](Algorithms/Array/basic_knowledge.md)
* [README](Algorithms/Array/README.md)
* [Shuffle](Algorithms/Array/shuffle.md)
* Sort
* [Ten Classic Sort](Algorithms/Sort/ten.classic.sort.md)
* Android
Expand All @@ -20,9 +23,12 @@
* [Add Custom Libarary](Android/WorkExperience/add.custom.libarary.md)
* [Android Adatper](Android/WorkExperience/android.adatper.md)
* [Force Landscape](Android/WorkExperience/force.landscape.md)
* [Launcher](Android/WorkExperience/launcher.md)
* [Set Default IME](Android/WorkExperience/set.default.IME.md)
* Basic_Knowledge
* [Shift](Basic_Knowledge/shift.md)
* CodeManagement
* [Git Useful Skills](CodeManagement/git.useful.skills.md)
* Others
* [Fangjia](Others/fangjia.md)
* [Gradle](Others/gradle.md)
2 changes: 1 addition & 1 deletion gen_summary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ rm -rf $summaryFile
tree Algorithms Android Basic_Knowledge CodeManagement Others | while read line
do
#echo $line
if [ "${line: 0-3}" == "pic" -o "${line: 0-3}" == "png" -o "${line: 0-3}" == "jpg" -o "${line: 0-3}" == "bmp" ]; then
if [ "${line: 0-3}" == "pic" -o "${line: 0-3}" == "png" -o "${line: 0-3}" == "jpg" -o "${line: 0-3}" == "bmp" -o "${line: 0-3}" == "JPG" -o "${line: 0-4}" == "webp" ]; then
continue
fi
if [ "$line" == "" ]; then
Expand Down

0 comments on commit e3ea103

Please sign in to comment.