forked from Blankj/AndroidUtilCode
-
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
61 changed files
with
2,350 additions
and
87 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,8 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
.idea | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild |
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,27 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion rootProject.ext.android.compileSdkVersion | ||
buildToolsVersion rootProject.ext.android.buildToolsVersion | ||
|
||
defaultConfig { | ||
applicationId "com.blankj.androidutilcode" | ||
minSdkVersion rootProject.ext.android.minSdkVersion | ||
targetSdkVersion rootProject.ext.android.targetSdkVersion | ||
versionCode rootProject.ext.android.versionCode | ||
versionName rootProject.ext.android.versionName | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled true | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(include: ['*.jar'], dir: 'libs') | ||
compile project(':utilcode') | ||
compile rootProject.ext.deps.design | ||
compile rootProject.ext.deps.supportV4 | ||
} |
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. | ||
# By default, the flags in this file are appended to flags specified | ||
# in G:\Android_IDE\ADT\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 *; | ||
#} | ||
|
||
-keep class com.blankj.utilcode.** { *; } | ||
-keep classmembers class com.blankj.utilcode.** { *; } | ||
-dontwarn com.blankj.utilcode.** |
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,60 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.blankj.androidutilcode"> | ||
悲剧 | ||
<!--读写内存--> | ||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | ||
|
||
<!--network--> | ||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> | ||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> | ||
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE"/> | ||
<uses-permission android:name="android.permission.INTERNET"/> | ||
|
||
<!--phone--> | ||
<uses-permission android:name="android.permission.READ_PHONE_STATE"/> | ||
<uses-permission android:name="android.permission.CALL_PHONE"/> | ||
<uses-permission android:name="android.permission.SEND_SMS"/> | ||
<!--拨打电话--> | ||
<uses-permission android:name="android.permission.CALL_PHONE"/> | ||
<!--发送短信--> | ||
<uses-permission android:name="android.permission.SEND_SMS"/> | ||
<!--获取手机联系人--> | ||
<!--<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>--> | ||
<uses-permission android:name="android.permission.READ_CONTACTS"/> | ||
<!--获取短信--> | ||
<!--<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>--> | ||
<uses-permission android:name="android.permission.READ_SMS"/> | ||
|
||
<application | ||
android:name=".App" | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/my_app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name=".activities.ActivityActivity"/> | ||
<activity android:name=".activities.AppActivity"/> | ||
<activity android:name=".activities.CleanActivity"/> | ||
<activity android:name=".activities.DeviceActivity"/> | ||
<activity android:name=".activities.ImageActivity"/> | ||
<activity | ||
android:name=".activities.KeyboardActivity" | ||
android:windowSoftInputMode="stateHidden|adjustPan"/> | ||
<activity android:name=".activities.MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name=".activities.NetworkActivity"/> | ||
<activity android:name=".activities.PhoneActivity"/> | ||
<activity android:name=".activities.ProcessActivity"/> | ||
<activity android:name=".activities.SDCardActivity"/> | ||
<activity android:name=".activities.SnackbarActivity"/> | ||
<activity android:name=".activities.ToastActivity"/> | ||
</application> | ||
|
||
</manifest> |
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,35 @@ | ||
package com.blankj.androidutilcode; | ||
|
||
import android.app.Application; | ||
import android.os.Handler; | ||
import android.os.Message; | ||
|
||
import com.blankj.utilcode.utils.CrashUtils; | ||
import com.blankj.utilcode.utils.LogUtils; | ||
|
||
import java.lang.ref.WeakReference; | ||
|
||
/** | ||
* <pre> | ||
* author: Blankj | ||
* blog : http://blankj.com | ||
* time : 2016/10/12 | ||
* desc : | ||
* </pre> | ||
*/ | ||
public class App extends Application { | ||
|
||
private static App ourInstance; | ||
|
||
public static App getInstance() { | ||
return ourInstance; | ||
} | ||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
ourInstance = this; | ||
CrashUtils.getInstance().init(this); | ||
LogUtils.getBuilder(this).setTag("MyTag").setLog2FileSwitch(true).create(); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
app/src/main/java/com/blankj/androidutilcode/activities/ActivityActivity.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,53 @@ | ||
package com.blankj.androidutilcode.activities; | ||
|
||
import android.app.Activity; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.TextView; | ||
|
||
import com.blankj.androidutilcode.R; | ||
import com.blankj.utilcode.utils.ActivityUtils; | ||
import com.blankj.utilcode.utils.DeviceUtils; | ||
import com.blankj.utilcode.utils.IntentUtils; | ||
import com.blankj.utilcode.utils.ShellUtils; | ||
|
||
/** | ||
* <pre> | ||
* author: Blankj | ||
* blog : http://blankj.com | ||
* time : 2016/10/13 | ||
* desc : Activity工具类测试 | ||
* </pre> | ||
*/ | ||
|
||
public class ActivityActivity extends Activity | ||
implements View.OnClickListener { | ||
|
||
private String packageName; | ||
private String className; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_activity); | ||
|
||
packageName = this.getPackageName(); | ||
className = packageName + ".activities.ImageActivity"; | ||
|
||
TextView tvAboutActivity = (TextView) findViewById(R.id.tv_about_activity); | ||
|
||
findViewById(R.id.btn_launch_image_activity).setOnClickListener(this); | ||
|
||
boolean isExists = ActivityUtils.isActivityExists(this, packageName, className); | ||
tvAboutActivity.setText(String.format("Is ImageActivity Exists: %b", isExists)); | ||
} | ||
|
||
@Override | ||
public void onClick(View view) { | ||
switch (view.getId()) { | ||
case R.id.btn_launch_image_activity: | ||
ActivityUtils.launchActivity(this, packageName, className); | ||
break; | ||
} | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
app/src/main/java/com/blankj/androidutilcode/activities/AppActivity.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,81 @@ | ||
package com.blankj.androidutilcode.activities; | ||
|
||
import android.app.Activity; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.TextView; | ||
|
||
import com.blankj.androidutilcode.App; | ||
import com.blankj.androidutilcode.R; | ||
import com.blankj.utilcode.utils.AppUtils; | ||
|
||
/** | ||
* <pre> | ||
* author: Blankj | ||
* blog : http://blankj.com | ||
* time : 2016/10/13 | ||
* desc : App工具类测试 | ||
* </pre> | ||
*/ | ||
|
||
public class AppActivity extends Activity | ||
implements View.OnClickListener { | ||
|
||
private String appPath; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_app); | ||
|
||
appPath = AppUtils.getAppPath(this); | ||
|
||
TextView tvAboutApp = (TextView) findViewById(R.id.tv_about_app); | ||
|
||
findViewById(R.id.btn_install_app).setOnClickListener(this); | ||
findViewById(R.id.btn_install_app_silent).setOnClickListener(this); | ||
findViewById(R.id.btn_uninstall_app).setOnClickListener(this); | ||
findViewById(R.id.btn_uninstall_app_silent).setOnClickListener(this); | ||
findViewById(R.id.btn_launch_app).setOnClickListener(this); | ||
findViewById(R.id.btn_get_app_details_settings).setOnClickListener(this); | ||
|
||
tvAboutApp.setText(AppUtils.getAppInfo(this).toString() + | ||
"\nisInstallWeiXin: " + AppUtils.isInstallApp(this, "com.tencent.mm") + | ||
"\nisAppRoot: " + AppUtils.isAppRoot() + | ||
"\nisAppDebug: " + AppUtils.isAppDebug(this) + | ||
"\nisWeiXinAppDebug: " + AppUtils.isAppDebug(this, "com.tencent.mm") + | ||
"\nAppSignatureSHA1: " + AppUtils.getAppSignatureSHA1(this) + | ||
"\nisAppForeground: " + AppUtils.isAppForeground(this) + | ||
"\nisWeiXinForeground: " + AppUtils.isAppForeground(this, "com.tencent.mm") | ||
); | ||
} | ||
|
||
@Override | ||
public void onClick(View view) { | ||
switch (view.getId()) { | ||
case R.id.btn_install_app: | ||
AppUtils.installApp(this, appPath); | ||
break; | ||
case R.id.btn_install_app_silent: | ||
new Thread(new Runnable() { | ||
@Override | ||
public void run() { | ||
AppUtils.installAppSilent(App.getInstance(), appPath); | ||
} | ||
}).start(); | ||
break; | ||
case R.id.btn_uninstall_app: | ||
AppUtils.uninstallApp(this, this.getPackageName()); | ||
break; | ||
case R.id.btn_uninstall_app_silent: | ||
AppUtils.uninstallAppSilent(this, this.getPackageName(), false); | ||
break; | ||
case R.id.btn_launch_app: | ||
AppUtils.launchApp(this, this.getPackageName()); | ||
break; | ||
case R.id.btn_get_app_details_settings: | ||
AppUtils.getAppDetailsSettings(this); | ||
break; | ||
} | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
app/src/main/java/com/blankj/androidutilcode/activities/CleanActivity.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,69 @@ | ||
package com.blankj.androidutilcode.activities; | ||
|
||
import android.os.Bundle; | ||
import android.app.Activity; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.widget.Button; | ||
|
||
import com.blankj.androidutilcode.R; | ||
import com.blankj.utilcode.utils.CleanUtils; | ||
|
||
import java.io.File; | ||
|
||
/** | ||
* <pre> | ||
* author: Blankj | ||
* blog : http://blankj.com | ||
* time : 2016/9/29 | ||
* desc : Clean工具类测试 | ||
* </pre> | ||
*/ | ||
public class CleanActivity extends Activity | ||
implements View.OnClickListener { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_clean); | ||
|
||
Button btnCleanInternalCache = (Button) findViewById(R.id.btn_clean_internal_cache); | ||
Button btnCleanInternalFiles = (Button) findViewById(R.id.btn_clean_internal_files); | ||
Button btnCleanInternalDbs = (Button) findViewById(R.id.btn_clean_internal_databases); | ||
Button btnCleanInternalSP = (Button) findViewById(R.id.btn_clean_internal_sp); | ||
Button btnCleanExternalCache = (Button) findViewById(R.id.btn_clean_external_cache); | ||
|
||
btnCleanInternalCache.setOnClickListener(this); | ||
btnCleanInternalFiles.setOnClickListener(this); | ||
btnCleanInternalDbs.setOnClickListener(this); | ||
btnCleanInternalSP.setOnClickListener(this); | ||
btnCleanExternalCache.setOnClickListener(this); | ||
|
||
btnCleanInternalCache.setText(getCacheDir().getPath()); | ||
btnCleanInternalFiles.setText(getFilesDir().getPath()); | ||
btnCleanInternalDbs.setText(getFilesDir().getParent() + File.separator + "databases"); | ||
btnCleanInternalSP.setText(getFilesDir().getParent() + File.separator + "shared_prefs"); | ||
btnCleanExternalCache.setText(getExternalCacheDir().getPath()); | ||
} | ||
|
||
@Override | ||
public void onClick(View view) { | ||
switch (view.getId()) { | ||
case R.id.btn_clean_internal_cache: | ||
Log.d("cleanInternalCache", "" + CleanUtils.cleanInternalCache(this)); | ||
break; | ||
case R.id.btn_clean_internal_files: | ||
Log.d("cleanInternalFiles", "" + CleanUtils.cleanInternalFiles(this)); | ||
break; | ||
case R.id.btn_clean_internal_databases: | ||
Log.d("cleanInternalDbs", "" + CleanUtils.cleanInternalDbs(this)); | ||
break; | ||
case R.id.btn_clean_internal_sp: | ||
Log.d("cleanInternalSP", "" + CleanUtils.cleanInternalSP(this)); | ||
break; | ||
case R.id.btn_clean_external_cache: | ||
Log.d("cleanExternalCache", "" + CleanUtils.cleanExternalCache(this)); | ||
break; | ||
} | ||
} | ||
} |
Oops, something went wrong.