Skip to content

Commit 2c102ce

Browse files
author
zhangxiaoke
committed
refactory project structures
1 parent 98f6d00 commit 2c102ce

File tree

104 files changed

+1484
-102
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+1484
-102
lines changed
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
apply plugin: 'android-library'
2-
3-
dependencies {
4-
compile "com.android.support:support-v4:[18.0,)"
5-
compile 'com.google.code.gson:gson:2.2.+'
6-
}
7-
81
android {
92
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
103
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
@@ -21,5 +14,4 @@ android {
2114

2215
}
2316

24-
apply from: 'https://raw.github.com/mcxiaoke/gradle-mvn-push/master/gradle-mvn-push.gradle'
25-
17+
apply from: 'https://raw.github.com/mcxiaoke/gradle-mvn-push/master/gradle-mvn-push.gradle'

core/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apply plugin: 'android-library'
2+
3+
dependencies {
4+
compile "com.android.support:support-v4:+"
5+
}
6+
7+
apply from: '../base.gradle'
8+

core/gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
POM_NAME=CatCommons Library Core
2+
POM_ARTIFACT_ID=core
3+
POM_PACKAGING=aar

library/src/main/java/com/mcxiaoke/commons/utils/AssertUtils.java renamed to core/src/main/java/com/mcxiaoke/commons/utils/AssertUtils.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public static void notNull(Object object) {
165165
*
166166
* @param text the String to check
167167
* @param message the exception message to use if the assertion fails
168-
* @see StringUtils#hasLength
168+
* @see com.mcxiaoke.commons.utils.StringUtils#hasLength
169169
*/
170170
public static void hasLength(String text, String message) {
171171
if (!StringUtils.hasLength(text)) {
@@ -182,7 +182,7 @@ public static void hasLength(String text, String message) {
182182
* </pre>
183183
*
184184
* @param text the String to check
185-
* @see StringUtils#hasLength
185+
* @see com.mcxiaoke.commons.utils.StringUtils#hasLength
186186
*/
187187
public static void hasLength(String text) {
188188
hasLength(
@@ -201,7 +201,7 @@ public static void hasLength(String text) {
201201
*
202202
* @param text the String to check
203203
* @param message the exception message to use if the assertion fails
204-
* @see StringUtils#hasText
204+
* @see com.mcxiaoke.commons.utils.StringUtils#hasText
205205
*/
206206
public static void hasText(String text, String message) {
207207
if (!StringUtils.hasText(text)) {
@@ -219,7 +219,7 @@ public static void hasText(String text, String message) {
219219
* </pre>
220220
*
221221
* @param text the String to check
222-
* @see StringUtils#hasText
222+
* @see com.mcxiaoke.commons.utils.StringUtils#hasText
223223
*/
224224
public static void hasText(String text) {
225225
hasText(text,

library/src/main/java/com/mcxiaoke/commons/utils/SystemUtils.java renamed to core/src/main/java/com/mcxiaoke/commons/utils/SystemUtils.java

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
package com.mcxiaoke.commons.utils;
22

33
import android.annotation.TargetApi;
4+
import android.app.Activity;
5+
import android.app.ActivityManager;
6+
import android.content.ComponentName;
47
import android.content.Context;
58
import android.content.Intent;
9+
import android.content.pm.ActivityInfo;
610
import android.content.pm.PackageManager;
11+
import android.content.res.Configuration;
712
import android.net.Uri;
813
import android.os.AsyncTask;
914
import android.os.Build;
@@ -12,12 +17,14 @@
1217
import android.os.StatFs;
1318
import android.os.StrictMode;
1419
import android.view.View;
20+
import android.view.WindowManager;
1521
import android.view.inputmethod.InputMethodManager;
1622
import android.widget.EditText;
1723
import android.widget.Toast;
1824
import com.mcxiaoke.commons.BuildConfig;
1925

2026
import java.lang.reflect.Method;
27+
import java.util.List;
2128
import java.util.Set;
2229

2330
/**
@@ -181,6 +188,73 @@ public static String dumpIntent(Intent intent) {
181188
return builder.toString();
182189
}
183190

191+
/**
192+
* Checks whether the recording service is currently running.
193+
*
194+
* @param ctx the current context
195+
* @return true if the service is running, false otherwise
196+
*/
197+
public static boolean isServiceRunning(Context ctx, Class<?> cls) {
198+
ActivityManager activityManager = (ActivityManager) ctx
199+
.getSystemService(Context.ACTIVITY_SERVICE);
200+
List<ActivityManager.RunningServiceInfo> services = activityManager
201+
.getRunningServices(Integer.MAX_VALUE);
202+
203+
for (ActivityManager.RunningServiceInfo serviceInfo : services) {
204+
ComponentName componentName = serviceInfo.service;
205+
String serviceName = componentName.getClassName();
206+
if (serviceName.equals(cls.getName())) {
207+
return true;
208+
}
209+
}
210+
return false;
211+
}
212+
213+
public static void setFullScreen(final Activity activity,
214+
final boolean fullscreen) {
215+
if (fullscreen) {
216+
activity.getWindow().addFlags(
217+
WindowManager.LayoutParams.FLAG_FULLSCREEN);
218+
activity.getWindow().clearFlags(
219+
WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
220+
} else {
221+
activity.getWindow().addFlags(
222+
WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
223+
activity.getWindow().clearFlags(
224+
WindowManager.LayoutParams.FLAG_FULLSCREEN);
225+
}
226+
}
227+
228+
public static void setPortraitOrientation(final Activity activity,
229+
final boolean portrait) {
230+
if (portrait) {
231+
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
232+
} else {
233+
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
234+
}
235+
}
236+
237+
public static void lockScreenOrientation(final Activity context) {
238+
boolean portrait = false;
239+
if (portrait) {
240+
context.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
241+
} else {
242+
if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
243+
context.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
244+
}
245+
if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
246+
context.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
247+
}
248+
}
249+
}
250+
251+
public static void unlockScreenOrientation(final Activity context) {
252+
boolean portrait = false;
253+
if (!portrait) {
254+
context.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
255+
}
256+
}
257+
184258
public static boolean hasGingerbread() {
185259
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD;
186260
}

extras-abc/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

extras-abc/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apply plugin: 'android-library'
2+
3+
dependencies {
4+
compile 'com.android.support:appcompat-v7:+'
5+
compile "com.android.support:support-v4:+"
6+
}
7+
8+
apply from: '../base.gradle'

extras-abc/gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
POM_NAME=CatCommons Library Extras ABC
2+
POM_ARTIFACT_ID=extras-abc
3+
POM_PACKAGING=aar

extras-abc/proguard-rules.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /Users/mcxiaoke/develop/android-sdk-macosx/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the ProGuard
5+
# include property in project.properties.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.mcxiaoke.commons.extras.actionbarcompat">
3+
4+
<application />
5+
6+
</manifest>

0 commit comments

Comments
 (0)