Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
catchpig committed Jan 26, 2018
2 parents 7adb1f5 + 368ca74 commit 8e9ed3e
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 124 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;
import conm.zhuazhu.common.utils.EncryptUtils;

import static org.junit.Assert.assertEquals;

/**
* Instrumented test, which will execute on an Android device.
Expand All @@ -23,4 +25,9 @@ public void useAppContext() throws Exception {

assertEquals("com.zhuazhu", appContext.getPackageName());
}
@Test
public void test(){
String m5 = EncryptUtils.encryptMD5ToString("123456");
System.out.println(m5);
}
}
10 changes: 9 additions & 1 deletion app/src/test/java/com/zhuazhu/ExampleUnitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import org.junit.Test;

import static org.junit.Assert.*;
import conm.zhuazhu.common.utils.EncryptUtils;

import static org.junit.Assert.assertEquals;

/**
* Example local unit test, which will execute on the development machine (host).
Expand All @@ -14,4 +16,10 @@ public class ExampleUnitTest {
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
@Test
public void test(){
String m5 = EncryptUtils.encryptMD5ToString("123456");

System.out.println(m5);
}
}
13 changes: 13 additions & 0 deletions common/src/main/java/conm/zhuazhu/common/utils/AppUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,19 @@ public static void exitApp() {
System.exit(0);
}

/**
* 获取meta-data的value
* @param key
* @return
* @throws PackageManager.NameNotFoundException
*/
public static String metaData(String key) throws PackageManager.NameNotFoundException {
ApplicationInfo applicationInfo = Utils.getApp().getPackageManager()
.getApplicationInfo(getAppPackageName(), PackageManager
.GET_META_DATA);
return applicationInfo.metaData.getString("key");
}

/**
* 获取 App 包名
*
Expand Down
53 changes: 0 additions & 53 deletions common/src/main/java/conm/zhuazhu/common/utils/MD5Utils.java

This file was deleted.

10 changes: 4 additions & 6 deletions common/src/main/java/conm/zhuazhu/common/utils/VibrateUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,22 @@ public class VibrateUtils {
/**
* {@link android.Manifest.permission#VIBRATE}.
*
* @param context
* @param milliseconds The number of milliseconds to vibrate.
*/
public static void vibrate(Context context, long milliseconds) {
Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
public static void vibrate(long milliseconds) {
Vibrator vibrator = (Vibrator) Utils.getApp().getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(milliseconds);
}

/**
* {@link android.Manifest.permission#VIBRATE}.
*
* @param context
* @param pattern an array of longs of times for which to turn the vibrator on or off.
* @param repeat the index into pattern at which to repeat, or -1 if
* you don't want to repeat.
*/
public static void vibrate(Context context, long[] pattern, int repeat) {
Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
public static void vibrate(long[] pattern, int repeat) {
Vibrator vibrator = (Vibrator) Utils.getApp().getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(pattern, repeat);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package conm.zhuazhu.common.utils;

import android.content.Context;
import android.media.MediaPlayer;
import android.support.annotation.RawRes;

Expand All @@ -13,13 +12,10 @@ public class VoiceUtils {

/**
* 播放语音
* @param context
* @param raw
*/
public static void play(Context context,@RawRes int raw){

MediaPlayer player = MediaPlayer.create(context,raw);

public static void play(@RawRes int raw){
MediaPlayer player = MediaPlayer.create(Utils.getApp(),raw);
player.start();
}
}
57 changes: 0 additions & 57 deletions common/src/main/java/conm/zhuazhu/common/utils/WindowUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import android.Manifest;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.support.v4.app.ActivityCompat;
import android.telephony.TelephonyManager;
Expand All @@ -17,61 +15,6 @@
*/

public class WindowUtils {
/**
* 获取meta-data的value
* @param context
* @param key
* @return
* @throws PackageManager.NameNotFoundException
*/
public static String metaData(Context context, String key) throws
PackageManager.NameNotFoundException {
ApplicationInfo applicationInfo = context.getPackageManager()
.getApplicationInfo(context.getPackageName(), PackageManager
.GET_META_DATA);
return applicationInfo.metaData.getString("key");
}

/**
* 获取版本code
*
* @param context
* @return
* @throws Exception
*/
public static int versionCode(Context context) throws Exception {
// 获取packagemanager的实例
PackageManager packageManager = context.getPackageManager();
// getPackageName()是你当前类的包名,0代表是获取版本信息
PackageInfo packInfo = packageManager.getPackageInfo(context
.getPackageName(), 0);
int version = packInfo.versionCode;
return version;
}

/**
* 获取版本
*
* @param context
* @return
* @throws Exception
*/
public static String versionName(Context context) {
// 获取packagemanager的实例
PackageManager packageManager = context.getPackageManager();
// getPackageName()是你当前类的包名,0代表是获取版本信息
PackageInfo packInfo = null;
try {
packInfo = packageManager.getPackageInfo(context.getPackageName()
, 0);
} catch (Exception e) {
e.printStackTrace();
}
if (packInfo == null) {
return null;
}
return packInfo.versionName;
}

/**
* 获取设备id
Expand Down

0 comments on commit 8e9ed3e

Please sign in to comment.