Skip to content

Commit 307dbe8

Browse files
author
hyb1996
committed
initial commit
0 parents  commit 307dbe8

File tree

105 files changed

+3942
-0
lines changed

Some content is hidden

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

105 files changed

+3942
-0
lines changed

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures
9+
.externalNativeBuild

.idea/compiler.xml

+22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/copyright/profiles_settings.xml

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/Project_Default.xml

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/profiles_settings.xml

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+61
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations.xml

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 25
5+
buildToolsVersion "25.0.2"
6+
defaultConfig {
7+
applicationId "com.stardust.scriptdroid"
8+
minSdkVersion 24
9+
//由于不知道在API24以上如何调起其他文件编辑器应用编辑文件,只能改到API23。FileProvider貌似只能查看编辑后不能保存?
10+
//参照ScriptFileOperation.Edit
11+
targetSdkVersion 23
12+
versionCode 1
13+
versionName "1.0"
14+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15+
jackOptions {
16+
enabled true
17+
}
18+
}
19+
buildTypes {
20+
release {
21+
minifyEnabled false
22+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
23+
}
24+
}
25+
compileOptions {
26+
sourceCompatibility JavaVersion.VERSION_1_8
27+
targetCompatibility JavaVersion.VERSION_1_8
28+
encoding = 'utf-8'
29+
}
30+
}
31+
32+
dependencies {
33+
compile fileTree(include: ['*.jar'], dir: 'libs')
34+
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
35+
exclude group: 'com.android.support', module: 'support-annotations'
36+
})
37+
compile 'com.android.support:appcompat-v7:25.0.0'
38+
compile 'com.android.support:design:25.0.0'
39+
testCompile 'junit:junit:4.12'
40+
compile 'com.afollestad.material-dialogs:core:0.9.2.3'
41+
compile 'com.google.code.gson:gson:2.8.0'
42+
compile 'com.sothree.slidinguppanel:library:3.3.1'
43+
}

app/proguard-rules.pro

+17
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 E:\YiBin\eclipse\Android_SDK_windows/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
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+
#}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.stardust.scriptdroid;
2+
3+
import android.content.Context;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.runner.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import static org.junit.Assert.*;
11+
12+
/**
13+
* Instrumentation test, which will execute on an Android device.
14+
*
15+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16+
*/
17+
@RunWith(AndroidJUnit4.class)
18+
public class ExampleInstrumentedTest {
19+
@Test
20+
public void useAppContext() throws Exception {
21+
// Context of the app under test.
22+
Context appContext = InstrumentationRegistry.getTargetContext();
23+
24+
assertEquals("com.stardust.scriptdroid", appContext.getPackageName());
25+
}
26+
}

app/src/main/AndroidManifest.xml

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.stardust.scriptdroid">
4+
5+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
6+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
7+
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
8+
<uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT"/>
9+
10+
<application
11+
android:allowBackup="true"
12+
android:icon="@drawable/script_droid"
13+
android:label="@string/app_name"
14+
android:supportsRtl="true"
15+
android:theme="@style/AppTheme">
16+
<activity
17+
android:name=".MainActivity"
18+
android:label="@string/app_name"
19+
android:theme="@style/AppTheme.NoActionBar">
20+
<intent-filter>
21+
<action android:name="android.intent.action.MAIN"/>
22+
23+
<category android:name="android.intent.category.LAUNCHER"/>
24+
</intent-filter>
25+
</activity>
26+
27+
<activity
28+
android:name=".ShortcutActivity"
29+
android:label="脚本执行机器人"
30+
android:theme="@style/AppTheme.NoActionBar">
31+
32+
<intent-filter>
33+
<action android:name="com.example.Project.Action"/>
34+
<category android:name="android.intent.category.DEFAULT"/>
35+
</intent-filter>
36+
</activity>
37+
38+
<service
39+
android:name=".action.ActionPerformService"
40+
android:enabled="true"
41+
android:exported="true"
42+
android:label="脚本执行机器人"
43+
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
44+
<intent-filter>
45+
<action android:name="android.accessibilityservice.AccessibilityService"/>
46+
</intent-filter>
47+
<meta-data
48+
android:name="android.accessibilityservice"
49+
android:resource="@xml/accessibility_service_config"/>
50+
51+
</service>
52+
53+
<service
54+
android:name="com.stardust.scriptdroid.tile.TileService"
55+
android:icon="@drawable/ic_accessibility_service"
56+
android:label="脚本辅助"
57+
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
58+
<intent-filter>
59+
<action
60+
android:name="android.service.quicksettings.action.QS_TILE"/>
61+
</intent-filter>
62+
</service>
63+
64+
<provider
65+
android:name="android.support.v4.content.FileProvider"
66+
android:authorities="com.stardust.scriptdroid.fileprovider"
67+
android:exported="false"
68+
android:grantUriPermissions="true">
69+
<meta-data
70+
android:name="android.support.FILE_PROVIDER_PATHS"
71+
android:resource="@xml/provider_paths"/>
72+
</provider>
73+
74+
</application>
75+
76+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.stardust.scriptdroid;
2+
3+
import android.os.Build;
4+
import android.support.v7.app.AppCompatActivity;
5+
import android.view.View;
6+
7+
import java.util.stream.Stream;
8+
9+
import static android.content.pm.PackageManager.PERMISSION_DENIED;
10+
11+
/**
12+
* Created by Stardust on 2017/1/23.
13+
*/
14+
15+
public class BaseActivity extends AppCompatActivity {
16+
17+
18+
@SuppressWarnings("unchecked")
19+
public <T extends View> T $(int resId) {
20+
return (T) findViewById(resId);
21+
}
22+
23+
protected void checkPermission(String... permissions) {
24+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
25+
String[] requestPermissions = Stream.of(permissions).filter(permission -> checkSelfPermission(permission) == PERMISSION_DENIED).toArray(String[]::new);
26+
27+
if (requestPermissions.length > 0)
28+
requestPermissions(requestPermissions, 0);
29+
}
30+
}
31+
32+
}

0 commit comments

Comments
 (0)