-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
21 changed files
with
283 additions
and
21 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
64 changes: 64 additions & 0 deletions
64
dokit/src/main/java/com/hss01248/dokit/btns/AndroidConfigInfoDisplayBtn.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,64 @@ | ||
package com.hss01248.dokit.btns; | ||
|
||
import android.app.Activity; | ||
import android.content.DialogInterface; | ||
import android.content.res.Configuration; | ||
|
||
import androidx.appcompat.app.AlertDialog; | ||
|
||
import com.blankj.utilcode.util.ActivityUtils; | ||
import com.blankj.utilcode.util.GsonUtils; | ||
import com.blankj.utilcode.util.Utils; | ||
import com.hss01248.dokit.R; | ||
import com.hss01248.dokit.parts.ICustomButton; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* @Despciption todo | ||
* @Author hss | ||
* @Date 11/07/2022 14:29 | ||
* @Version 1.0 | ||
*/ | ||
public class AndroidConfigInfoDisplayBtn extends ICustomButton { | ||
@Override | ||
public int getName() { | ||
return R.string.tools_build_activity_info; | ||
} | ||
|
||
@Override | ||
public int getIcon() { | ||
return R.drawable.icon_info_testtool; | ||
} | ||
|
||
@Override | ||
public void onClick() { | ||
|
||
|
||
String msg = getAndroidConfig(); | ||
AlertDialog dialog = new AlertDialog.Builder(ActivityUtils.getTopActivity()) | ||
.setTitle("android Config信息") | ||
.setMessage(msg) | ||
.setPositiveButton("ok", new DialogInterface.OnClickListener() { | ||
@Override | ||
public void onClick(DialogInterface dialog, int which) { | ||
|
||
} | ||
}).create(); | ||
dialog.show(); | ||
} | ||
|
||
private static String getAndroidConfig() { | ||
Activity activity = ActivityUtils.getTopActivity(); | ||
Configuration activityConfiguration = activity.getResources().getConfiguration(); | ||
|
||
Configuration appConfiguration = Utils.getApp().getResources().getConfiguration(); | ||
|
||
Map map = new HashMap(); | ||
map.put("activityConfiguration",activityConfiguration); | ||
map.put("appConfiguration",appConfiguration); | ||
return GsonUtils.getGson("nice").toJson(map); | ||
} | ||
|
||
} |
87 changes: 87 additions & 0 deletions
87
dokit/src/main/java/com/hss01248/dokit/btns/BuildTypeInfoDisplayBtn.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,87 @@ | ||
package com.hss01248.dokit.btns; | ||
|
||
import android.content.DialogInterface; | ||
|
||
import androidx.appcompat.app.AlertDialog; | ||
|
||
import com.blankj.utilcode.util.ActivityUtils; | ||
import com.blankj.utilcode.util.LogUtils; | ||
import com.blankj.utilcode.util.Utils; | ||
import com.hss01248.dokit.R; | ||
import com.hss01248.dokit.parts.ICustomButton; | ||
|
||
import java.lang.reflect.Field; | ||
|
||
/** | ||
* @Despciption todo | ||
* @Author hss | ||
* @Date 11/07/2022 14:28 | ||
* @Version 1.0 | ||
*/ | ||
public class BuildTypeInfoDisplayBtn extends ICustomButton { | ||
@Override | ||
public int getName() { | ||
return R.string.tools_buildtype_info; | ||
} | ||
|
||
@Override | ||
public int getIcon() { | ||
return R.drawable.icon_info_testtool; | ||
} | ||
|
||
@Override | ||
public void onClick() { | ||
|
||
Class buildConfig = buildConfig(); | ||
String msg = "BuildConfig信息未能通过反射得到"; | ||
if(buildConfig != null){ | ||
Field[] declaredFields = buildConfig.getDeclaredFields(); | ||
if(declaredFields != null){ | ||
msg = buildConfig.getName()+":\n\n"; | ||
for (Field field : declaredFields) { | ||
field.setAccessible(true); | ||
try { | ||
msg += (field.getName().toLowerCase()+": "+field.get(buildConfig)+"\n"); | ||
}catch (Throwable throwable){ | ||
LogUtils.w(throwable); | ||
} | ||
} | ||
} | ||
} | ||
AlertDialog dialog = new AlertDialog.Builder(ActivityUtils.getTopActivity()) | ||
.setTitle("BuildConfig信息") | ||
.setMessage(msg) | ||
.setPositiveButton("ok", new DialogInterface.OnClickListener() { | ||
@Override | ||
public void onClick(DialogInterface dialog, int which) { | ||
|
||
} | ||
}).create(); | ||
dialog.show(); | ||
} | ||
|
||
private static Class buildConfig() { | ||
try { | ||
String name0 = Utils.getApp().getPackageName() + ".BuildConfig"; | ||
Class clazz = Class.forName(name0); | ||
return clazz; | ||
} catch (Throwable throwable) { | ||
LogUtils.d("getBuildType", "xx", throwable); | ||
String name = Utils.getApp().getClass().getName(); | ||
name = name.substring(0, name.lastIndexOf(".")); | ||
while (name.contains(".")){ | ||
String config = name + ".BuildConfig"; | ||
try { | ||
Class clazz = Class.forName(config); | ||
if(clazz != null){ | ||
return clazz; | ||
} | ||
} catch (ClassNotFoundException e) { | ||
LogUtils.i(e); | ||
} | ||
name = name.substring(0, name.lastIndexOf(".")); | ||
} | ||
return null; | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
dokit/src/main/java/com/hss01248/dokit/btns/GitBranchBtn.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,37 @@ | ||
package com.hss01248.dokit.btns; | ||
|
||
import com.blankj.utilcode.util.ReflectUtils; | ||
import com.blankj.utilcode.util.ToastUtils; | ||
import com.blankj.utilcode.util.Utils; | ||
import com.hss01248.dokit.R; | ||
import com.hss01248.dokit.parts.ICustomButton; | ||
|
||
/** | ||
* @Despciption todo | ||
* @Author hss | ||
* @Date 11/07/2022 14:21 | ||
* @Version 1.0 | ||
*/ | ||
public class GitBranchBtn extends ICustomButton { | ||
@Override | ||
public int getName() { | ||
return R.string.tools_show_branch; | ||
} | ||
|
||
@Override | ||
public int getIcon() { | ||
return R.drawable.icon_tool_git; | ||
} | ||
|
||
@Override | ||
public void onClick() { | ||
try { | ||
String str = ReflectUtils.reflect(Utils.getApp().getPackageName()+".BuildConfig").field("BRANCH").get(); | ||
ToastUtils.showLong(str); | ||
}catch (Throwable throwable){ | ||
throwable.printStackTrace(); | ||
ToastUtils.showLong("请在buildtype里配置: \n buildConfigField 'String', 'BRANCH', '\"' + getGitBranch() + '\"'"); | ||
} | ||
|
||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
dokit/src/main/java/com/hss01248/dokit/btns/GoAppSettingsBtn.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,28 @@ | ||
package com.hss01248.dokit.btns; | ||
|
||
import com.hss01248.dokit.InitForDokit; | ||
import com.hss01248.dokit.R; | ||
import com.hss01248.dokit.parts.ICustomButton; | ||
|
||
/** | ||
* @Despciption todo | ||
* @Author hss | ||
* @Date 11/07/2022 14:47 | ||
* @Version 1.0 | ||
*/ | ||
public class GoAppSettingsBtn extends ICustomButton { | ||
@Override | ||
public int getName() { | ||
return R.string.testkit_go_setting; | ||
} | ||
|
||
@Override | ||
public int getIcon() { | ||
return R.drawable.tools_go_settings; | ||
} | ||
|
||
@Override | ||
public void onClick() { | ||
InitForDokit.goAppSettings(); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
dokit/src/main/java/com/hss01248/dokit/btns/UserInfoDisplayBtn.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,47 @@ | ||
package com.hss01248.dokit.btns; | ||
|
||
import android.content.DialogInterface; | ||
|
||
import androidx.appcompat.app.AlertDialog; | ||
|
||
import com.blankj.utilcode.util.ActivityUtils; | ||
import com.hss01248.dokit.MyDokit; | ||
import com.hss01248.dokit.R; | ||
import com.hss01248.dokit.parts.ICustomButton; | ||
|
||
/** | ||
* @Despciption todo | ||
* @Author hss | ||
* @Date 11/07/2022 14:23 | ||
* @Version 1.0 | ||
*/ | ||
public class UserInfoDisplayBtn extends ICustomButton { | ||
@Override | ||
public int getName() { | ||
return R.string.tools_user_info; | ||
} | ||
|
||
@Override | ||
public int getIcon() { | ||
return R.drawable.icon_info_testtool; | ||
} | ||
|
||
@Override | ||
public void onClick() { | ||
String msg = "MyDokit.getConfig()未设置"; | ||
|
||
if( MyDokit.getConfig() != null){ | ||
msg = MyDokit.getConfig().getUserInfo(); | ||
} | ||
AlertDialog dialog = new AlertDialog.Builder(ActivityUtils.getTopActivity()) | ||
.setTitle("用户信息") | ||
.setMessage(msg) | ||
.setPositiveButton("ok", new DialogInterface.OnClickListener() { | ||
@Override | ||
public void onClick(DialogInterface dialog, int which) { | ||
|
||
} | ||
}).create(); | ||
dialog.show(); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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