Skip to content

Commit

Permalink
Merge pull request geeeeeeeeek#223 from geeeeeeeeek/feature/android-n…
Browse files Browse the repository at this point in the history
…ogat-support

Feature/android nogat support
  • Loading branch information
Zhongyi Tong authored Jan 27, 2017
2 parents 21fb800 + bb140eb commit f89b1d3
Show file tree
Hide file tree
Showing 13 changed files with 167 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 11 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
language: android
sudo: false
jdk: oraclejdk7
jdk: oraclejdk8
env:
matrix:
- ANDROID_TARGET=android-21 ANDROID_ABI=armeabi-v7a armeabi
- ANDROID_TARGET=android-25 ANDROID_ABI=armeabi-v7a armeabi
android:
components:
- platform-tools
- build-tools-21.1.2
- android-L
- tools
- build-tools-25.0.2
- android-N
- extra
licenses:
- android-sdk-license-.+
- '.+'
before_install:
- openssl aes-256-cbc -K $encrypted_6b42a8524af0_key -iv $encrypted_6b42a8524af0_iv
-in monkeytong.jks.enc -out monkeytong.jks -d
before_script:
- echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI
- emulator -avd test -no-skin -no-audio -no-window &
- adb wait-for-device
- adb shell input keyevent 82 &
- mkdir "$ANDROID_HOME/licenses" || true
- echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"
- echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"
- gem install fir-cli
script:
- ./gradlew assembleRelease
Expand Down
43 changes: 40 additions & 3 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
/build
/gradle.properties
*.apk
# Built application files
*.apk
*.ap_

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# Intellij
*.iml
.idea/

# Keystore files
*.jks
35 changes: 24 additions & 11 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,17 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-ads/8.4.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-basement/8.4.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-compat/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-core-ui/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-core-utils/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-fragment/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-media-compat/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-vector-drawable/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.tencent.bugly/crashreport_upgrade/1.2.2.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.tencent.bugly/nativecrashreport/3.1.2/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-runtime-classes" />
Expand All @@ -111,14 +117,21 @@
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
<orderEntry type="jdk" jdkName="Android API 25 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="play-services-ads-8.4.0" level="project" />
<orderEntry type="library" exported="" name="support-compat-25.1.0" level="project" />
<orderEntry type="library" exported="" name="support-fragment-25.1.0" level="project" />
<orderEntry type="library" exported="" name="animated-vector-drawable-25.1.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-25.1.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-25.1.0" level="project" />
<orderEntry type="library" exported="" name="nativecrashreport-3.1.2" level="project" />
<orderEntry type="library" exported="" name="crashreport_upgrade-1.2.2.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.0.0" level="project" />
<orderEntry type="library" exported="" name="play-services-basement-8.4.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.0.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-22.1.1" level="project" />
<orderEntry type="library" exported="" name="android-android-21" level="project" />
<orderEntry type="library" exported="" name="support-core-ui-25.1.0" level="project" />
<orderEntry type="library" exported="" name="support-media-compat-25.1.0" level="project" />
<orderEntry type="library" exported="" name="support-vector-drawable-25.1.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-25.1.0" level="project" />
<orderEntry type="library" exported="" name="support-core-utils-25.1.0" level="project" />
<orderEntry type="library" exported="" name="android-android-25" level="project" />
<orderEntry type="library" exported="" name="org.apache.http.legacy-android-25" level="project" />
</component>
</module>
30 changes: 16 additions & 14 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

compileSdkVersion 25
buildToolsVersion "25.0.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "xyz.monkeytong.hongbao"
minSdkVersion 16
targetSdkVersion 22
versionCode 5
minSdkVersion 19
targetSdkVersion 25
versionCode 4
versionName "v4.0.0"
ndk {
//设置支持的SO库架构
abiFilters 'armeabi' //, 'x86', 'armeabi-v7a', 'x86_64', 'arm64-v8a'
abiFilters 'armeabi', 'armeabi-v7a' //, 'x86', 'armeabi-v7a', 'x86_64', 'arm64-v8a'
}
}

Expand All @@ -34,10 +34,12 @@ android {
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
//compile 'com.tencent.bugly:crashreport:latest.release' //其中latest.release指代最新版本号,也可以指定明确的版本号,例如1.2.8
compile 'com.tencent.bugly:crashreport_upgrade:latest.release'//其中latest.release指代最新版本号,也可以指定明确的版本号,例如1.0.1
compile 'com.google.android.gms:play-services-ads:8.4.0'
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.tencent.bugly:crashreport_upgrade:latest.release'
//其中latest.release指代最新版本号,也可以指定明确的版本号,例如1.0.1
compile 'com.tencent.bugly:nativecrashreport:latest.release'
//其中latest.release指代最新版本号,也可以指定明确的版本号,例如2.2.0
compile 'com.android.support:support-v4:25.1.0'
compile 'com.android.support:appcompat-v7:25.1.0'
}
2 changes: 2 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-dontwarn com.tencent.bugly.**
-keep public class com.tencent.bugly.**{*;}
-keep class android.support.**{*;}
13 changes: 13 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
android:theme="@style/Base.Theme.AppCompat.Light"
android:launchMode="standard">
</activity>
<activity
android:name="com.tencent.bugly.beta.ui.BetaActivity"
android:theme="@android:style/Theme.Translucent" />
<service
android:name=".services.HongbaoService"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
Expand All @@ -40,6 +43,16 @@
<meta-data android:name="android.accessibilityservice"
android:resource="@xml/accessible_service_config"/>
</service>
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="xyz.monkeytong.hongbao.fileProvider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>

</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@
import android.view.Window;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityManager;
import android.widget.*;

import java.util.List;

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.tencent.bugly.Bugly;
import xyz.monkeytong.hongbao.R;
import xyz.monkeytong.hongbao.utils.ConnectivityUtil;
import xyz.monkeytong.hongbao.utils.UpdateTask;

import com.tencent.bugly.crashreport.CrashReport;
import java.util.List;


public class MainActivity extends Activity implements AccessibilityManager.AccessibilityStateChangeListener {
Expand All @@ -37,7 +35,8 @@ public class MainActivity extends Activity implements AccessibilityManager.Acces
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
CrashReport.initCrashReport(getApplicationContext(), "900019352", false);
//CrashReport.initCrashReport(getApplicationContext(), "900019352", false);
Bugly.init(getApplicationContext(), "900019352", false);
setContentView(R.layout.activity_main);
pluginStatusText = (TextView) findViewById(R.id.layout_control_accessibility_text);
pluginStatusIcon = (ImageView) findViewById(R.id.layout_control_accessibility_icon);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,10 @@

import android.annotation.TargetApi;
import android.app.Activity;
import android.app.DownloadManager;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
Expand All @@ -21,14 +14,10 @@
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import xyz.monkeytong.hongbao.R;
import xyz.monkeytong.hongbao.utils.DownloadUtil;
import xyz.monkeytong.hongbao.utils.UpdateTask;

/**
* Created by Zhongyi on 1/19/16.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package xyz.monkeytong.hongbao.services;

import android.accessibilityservice.AccessibilityService;
import android.accessibilityservice.GestureDescription;
import android.app.Notification;
import android.app.PendingIntent;
import android.content.ComponentName;
Expand All @@ -9,10 +10,12 @@
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Parcelable;
import android.graphics.Path;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.util.DisplayMetrics;
import xyz.monkeytong.hongbao.utils.HongbaoSignature;
import xyz.monkeytong.hongbao.utils.PowerUtil;

Expand Down Expand Up @@ -92,7 +95,7 @@ private void watchChat(AccessibilityEvent event) {
new Runnable() {
public void run() {
try {
mUnpackNode.performAction(AccessibilityNodeInfo.ACTION_CLICK);
openPacket();
} catch (Exception e) {
mMutex = false;
mLuckyMoneyPicked = false;
Expand All @@ -104,6 +107,42 @@ public void run() {
}
}

private void openPacket() {
DisplayMetrics metrics = getResources().getDisplayMetrics();
float dpi = metrics.density;
if (android.os.Build.VERSION.SDK_INT <= 23) {
mUnpackNode.performAction(AccessibilityNodeInfo.ACTION_CLICK);
} else {
if (android.os.Build.VERSION.SDK_INT > 23) {

Path path = new Path();
if (640 == dpi) {
path.moveTo(720, 1575);
} else {
path.moveTo(540, 1060);
}
GestureDescription.Builder builder = new GestureDescription.Builder();
GestureDescription gestureDescription = builder.addStroke(new GestureDescription.StrokeDescription(path, 450, 50)).build();
dispatchGesture(gestureDescription, new GestureResultCallback() {
@Override
public void onCompleted(GestureDescription gestureDescription) {
Log.d("test", "onCompleted");
mMutex = false;
super.onCompleted(gestureDescription);
}

@Override
public void onCancelled(GestureDescription gestureDescription) {
Log.d("test", "onCancelled");
mMutex = false;
super.onCancelled(gestureDescription);
}
}, null);

}
}
}

private void setCurrentActivityName(AccessibilityEvent event) {
if (event.getEventType() != AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
return;
Expand Down
15 changes: 5 additions & 10 deletions app/src/main/res/layout/activity_webview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" tools:context=".activities.WebViewActivity">
Expand Down Expand Up @@ -40,13 +39,9 @@
android:src="@mipmap/ic_open_in_browser" android:layout_alignParentRight="true"
android:layout_marginLeft="8dp" android:padding="8dp"/>
</RelativeLayout>
<RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent">
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/webView"
android:layout_gravity="center_horizontal"
android:foreground="#E46C62"/>
</RelativeLayout>

<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/webView"
android:layout_gravity="center_horizontal"/>
</LinearLayout>
7 changes: 7 additions & 0 deletions app/src/main/res/xml/provider_paths.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<!-- /storage/emulated/0/Download/${applicationId}/.beta/apk-->
<external-path name="beta_external_path" path="Download/"/>
<!--/storage/emulated/0/Android/data/${applicationId}/files/apk/-->
<external-path name="beta_external_files_path" path="Android/data/"/>
</paths>
Loading

0 comments on commit f89b1d3

Please sign in to comment.