├── .gitignore ├── LICENSE.md ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── jp │ │ └── yokomark │ │ └── remoteviews │ │ └── app │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── jp │ │ └── yokomark │ │ └── remoteviews │ │ └── app │ │ ├── MainActivity.java │ │ └── NotificationWatcher.java │ └── res │ ├── layout │ └── activity_main.xml │ ├── menu │ └── menu_main.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── reader ├── .gitignore ├── build.gradle ├── gradle.properties ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── jp │ │ └── yokomark │ │ └── remoteview │ │ └── reader │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ └── java │ └── jp │ └── yokomark │ └── remoteview │ └── reader │ ├── ActionMap.java │ ├── RemoteViewsInfo.java │ ├── RemoteViewsReader.java │ ├── action │ ├── BitmapReflectionAction.java │ ├── IntentContainer.java │ ├── PendingIntentContainer.java │ ├── ReflectionAction.java │ ├── ReflectionWithoutParamsAction.java │ ├── RemoteViewsAction.java │ ├── SetDrawableParamsAction.java │ ├── SetEmptyViewAction.java │ ├── SetLaunchPendingIntentAction.java │ ├── SetOnClickFillInIntentAction.java │ ├── SetOnClickPendingIntentAction.java │ ├── SetPendingIntentTemplateAction.java │ ├── SetRemoteViewsAdapterIntentAction.java │ ├── SetRemoteViewsAdapterListAction.java │ ├── TextViewDrawableAction.java │ ├── TextViewDrawableColorFilterAction.java │ ├── TextViewSizeAction.java │ ├── ViewGroupAction.java │ └── ViewPaddingAction.java │ ├── unmarshaller │ ├── BitmapReflectionActionUnmarshaller.java │ ├── ReflectionActionUnmarshaller.java │ ├── ReflectionWithoutParamsActionUnmarshaller.java │ ├── SetDrawableParamsActionUnmarshaller.java │ ├── SetEmptyViewActionUnmarshaller.java │ ├── SetLaunchPendingIntentActionUnmarshaller.java │ ├── SetOnClickFillInIntentActionUnmarshaller.java │ ├── SetOnClickPendingIntentActionUnmarshaller.java │ ├── SetPendingIntentTemplateActionUnmarshaller.java │ ├── SetRemoteViewsAdapterIntentActionUnmarshaller.java │ ├── SetRemoteViewsAdapterListActionUnmarshaller.java │ ├── TextViewDrawableActionUnmarshaller.java │ ├── TextViewDrawableColorFilterActionUnmarshaller.java │ ├── TextViewSizeActionUnmarshaller.java │ ├── UnknownActionUnmarshaller.java │ ├── Unmarshaller.java │ ├── ViewGroupActionUnmarshaller.java │ └── ViewPaddingActionUnmarshaller.java │ └── utils │ └── ClassUtils.java └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | # built application files 3 | *.apk 4 | *.ap_ 5 | 6 | # files for the dex VM 7 | *.dex 8 | 9 | # Java class files 10 | *.class 11 | 12 | # generated files 13 | bin/ 14 | gen/ 15 | build/ 16 | html/ 17 | # Local configuration file (sdk path, etc) 18 | local.properties 19 | 20 | .gradle 21 | 22 | # Eclipse project files 23 | .classpath 24 | .project 25 | 26 | # Android Studio 27 | .idea/ 28 | .gradle 29 | /*/local.properties 30 | /*/out 31 | /*/*/build 32 | /*/*/production 33 | *.iml 34 | *.iws 35 | *.ipr 36 | *~ 37 | *.swp 38 | 39 | # Mac temporary 40 | .DS_Store 41 | 42 | node_modules/ 43 | 44 | deploygate.properties 45 | 46 | # Crashlytics 47 | com_crashlytics_export_strings.xml 48 | crashlytics.properties 49 | crashlytics-build.properties 50 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RemoteViewsReader 2 | 3 | Read RemoteViews information with some black magic way. 4 | 5 | ## Reference 6 | 7 | See [RemoteViews](https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/java/android/widget/RemoteViews.java). 8 | 9 | ## Caution 10 | 11 | As of Android Pie, the system will notify you that you are using hidden APIs (in other words, non-SDK APIs) via reflection. 12 | This library aims to read remote view properties by reflection so you will see bunch of warnings if you use this library. 13 | And the severity of the warning may change in the future. 14 | 15 | ## Usage 16 | 17 | ### Read informations 18 | 19 | You can read `RemoteViews` information like this. 20 | 21 | ``` 22 | public class NotificationWatcher extends NotificationListenerService { 23 | @TargetApi(Build.VERSION_CODES.KITKAT) 24 | @Override 25 | public void onNotificationPosted(StatusBarNotification sbn) { 26 | super.onNotificationPosted(sbn); 27 | RemoteViews remoteViews = sbn.getNotification().contentView; 28 | RemoteViewsInfo info = RemoteViewsReader.read(this, remoteViews); 29 | 30 | // you can read informations from `info` object. 31 | } 32 | 33 | @Override 34 | public void onNotificationRemoved(StatusBarNotification sbn) { 35 | super.onNotificationRemoved(sbn); 36 | } 37 | } 38 | ``` 39 | 40 | `RemoteViewsInfo` contains following informations. 41 | 42 | 1. ApplicationInfo: An information about an application which have built this `RemoteViews`. 43 | 2. Actions: A list of actions the application have committed on `RemoteViews`. 44 | 3. Layout Id: An identity of the `RemoteViews` layout. 45 | 46 | ### Read Actions 47 | 48 | The operations for `RemoteViews` are stored as a list of `Action`. 49 | So you can find the action you want like this. 50 | 51 | ```java 52 | 53 | RemoteViewsInfo info = RemoteViewsReader.read(this, remoteViews); 54 | for (RemoteViewsAction action : info.getActions()) { 55 | 56 | } 57 | 58 | ``` 59 | 60 | RemoteViewsAction is an abstract type for each concrete operations. 61 | We have several types by default, according to AOSP implementation. 62 | 63 | - BitmapRefrectionAction 64 | Action for `RemoteViews#setImageBitmap()`. 65 | - RefrectionAction 66 | Action for various methods declared on `RemoteViews`. 67 | - RefrectionWithoutParamsAction 68 | Action for various methods without any parameters declared on `RemoteViews`. 69 | - SetDrawableParamsAction 70 | Action for `RemoteViews#setDrawableParameters()`. 71 | - SetEmptyViewAction 72 | Action for `RemoteViews#setEmptyView()`. 73 | - SetOnClickFillInIntentAction 74 | Action for `RemoteViews#setOnClickFillInIntent()`. 75 | - SetOnClickPendingIntentAction 76 | Action for `RemoteViews#setOnClickPendingIntent()`. 77 | - SetPendingIntentTemplateAction 78 | Action for `RemoteViews#setPendingIntentTemplate()`. 79 | - SetRemoteViewsAdapterIntentAction 80 | Action for `RemoteViews#setRemoteAdapter()`. 81 | - SetRemoteViewsAdapterListAction 82 | Action for `RemoteViews#setRemoteAdapter()`. 83 | - TextViewDrawableAction 84 | Action for `RemoteViews#setTextViewCompoundDrawables()` and `RemoteViews#setTextViewCompoundDrawablesRelative()`, . 85 | - TextViewDrawableColorFilterAction 86 | Action for `RemoteViews#setTextViewCompoundDrawablesRelativeColorFilter()`. 87 | - TextViewSizeAction 88 | Action for `RemoteViews#setTextViewTextSize()`. 89 | - ViewGroupAction 90 | Action for `RemoteViews#addView()` and `RemoteViews#remoteView()`. 91 | - ViewPaddingAction 92 | Action for `RemoteViews#setViewPadding()`. 93 | 94 | If you would like to use the specific type of action, you can deal with it like this. 95 | 96 | ```java 97 | 98 | RemoteViewsInfo info = RemoteViewsReader.read(this, remoteViews); 99 | for (RemoteViewsAction action : info.getActions()) { 100 | if (!(action instanceof BitmapRefrectionAction)) 101 | continue; 102 | BitmapRefrectionAction concrete = (BitmapRefrectionAction)action; 103 | Bitmap bmp = concrete.getBitmap(); 104 | } 105 | 106 | ``` 107 | 108 | ## Limitations 109 | 110 | Currently this library contains default actions in AOSP. 111 | I've found several types of additional customized actions on some devices, and they are not supported now. 112 | 113 | ## Download 114 | 115 | Via Gradle 116 | 117 | ``` 118 | implementation 'com.github.keithyokoma:RemoteViewsReader:1.3.0@aar' 119 | ``` 120 | 121 | ## License 122 | 123 | Apache License v2 124 | 125 | ``` 126 | Copyright (C) 2015 KeithYokoma, Inc. All rights reserved. 127 | 128 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 129 | this file except in compliance with the License. You may obtain a copy of the 130 | License at 131 | 132 | http://www.apache.org/licenses/LICENSE-2.0 133 | 134 | Unless required by applicable law or agreed to in writing, software distributed 135 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 136 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 137 | specific language governing permissions and limitations under the License. 138 | ``` 139 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | 6 | defaultConfig { 7 | applicationId "jp.yokomark.remoteviews.app" 8 | minSdkVersion 15 9 | targetSdkVersion 28 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | api project(':reader') 23 | api 'com.android.support:appcompat-v7:28.0.0-rc01' 24 | api fileTree(dir: 'libs', include: ['*.jar']) 25 | } 26 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/22.6.2/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 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/jp/yokomark/remoteviews/app/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteviews.app; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 22 | 23 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /app/src/main/java/jp/yokomark/remoteviews/app/MainActivity.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteviews.app; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.os.Bundle; 5 | import android.view.Menu; 6 | import android.view.MenuItem; 7 | 8 | public class MainActivity extends AppCompatActivity { 9 | 10 | @Override 11 | protected void onCreate(Bundle savedInstanceState) { 12 | super.onCreate(savedInstanceState); 13 | setContentView(R.layout.activity_main); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /app/src/main/java/jp/yokomark/remoteviews/app/NotificationWatcher.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteviews.app; 2 | 3 | import android.annotation.TargetApi; 4 | import android.os.Build; 5 | import android.service.notification.NotificationListenerService; 6 | import android.service.notification.StatusBarNotification; 7 | import android.util.Log; 8 | import android.widget.RemoteViews; 9 | 10 | import java.util.List; 11 | 12 | import jp.yokomark.remoteview.reader.RemoteViewsInfo; 13 | import jp.yokomark.remoteview.reader.RemoteViewsReader; 14 | import jp.yokomark.remoteview.reader.action.IntentContainer; 15 | import jp.yokomark.remoteview.reader.action.RemoteViewsAction; 16 | import jp.yokomark.remoteview.reader.action.ViewGroupAction; 17 | 18 | /** 19 | * @author KeishinYokomaku 20 | */ 21 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) 22 | public class NotificationWatcher extends NotificationListenerService { 23 | @Override 24 | public void onNotificationPosted(StatusBarNotification sbn) { 25 | RemoteViews views = sbn.getNotification().contentView; 26 | RemoteViewsInfo info = RemoteViewsReader.read(this, views); 27 | List actions = info.getActions(); 28 | dump(actions); 29 | } 30 | 31 | @Override 32 | public void onNotificationRemoved(StatusBarNotification sbn) {} 33 | 34 | private void dump(List actions) { 35 | for (RemoteViewsAction action : actions) { 36 | Log.v("NotificationWatcher", action.getActionName()); 37 | if (action instanceof IntentContainer) { 38 | IntentContainer p = (IntentContainer) action; 39 | Log.v("NotificationWatcher", p.getContentIntent().toString()); 40 | } else if (action instanceof ViewGroupAction) { 41 | ViewGroupAction v = (ViewGroupAction) action; 42 | RemoteViewsInfo nested = v.getNestedViewsInfo(this); 43 | if (nested != null) { 44 | Log.v("NotificationWatcher", "nested views found===="); 45 | dump(nested.getActions()); 46 | Log.v("NotificationWatcher", "======================"); 47 | } 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KeithYokoma/RemoteViewsReader/eee19d065e8854f13797d378f4284a581c4c3915/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KeithYokoma/RemoteViewsReader/eee19d065e8854f13797d378f4284a581c4c3915/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KeithYokoma/RemoteViewsReader/eee19d065e8854f13797d378f4284a581c4c3915/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KeithYokoma/RemoteViewsReader/eee19d065e8854f13797d378f4284a581c4c3915/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | app 3 | 4 | Hello world! 5 | Settings 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | google() 4 | jcenter() 5 | } 6 | dependencies { 7 | classpath 'com.android.tools.build:gradle:3.1.4' 8 | } 9 | } 10 | 11 | allprojects { 12 | repositories { 13 | google() 14 | jcenter() 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | VERSION_NAME=1.3.0 20 | VERSION_CODE=11 21 | GROUP=com.github.keithyokoma 22 | 23 | POM_DESCRIPTION=Read RemoteViews information with some black magic way. 24 | POM_URL=https://github.com/KeithYokoma/RemoteViewsReader 25 | POM_SCM_URL=https://github.com/KeithYokoma/RemoteViewsReader 26 | POM_SCM_CONNECTION=scm:git@github.com:KeithYokoma/RemoteViewsReader.git 27 | POM_SCM_DEV_CONNECTION=scm:git@github.com:KeithYokoma/RemoteViewsReader.git 28 | POM_LICENCE_NAME=The Apache Software License, Version 2.0 29 | POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt 30 | POM_LICENCE_DIST=repo 31 | POM_DEVELOPER_ID=KeithYokoma 32 | POM_DEVELOPER_NAME=KeithYokoma 33 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KeithYokoma/RemoteViewsReader/eee19d065e8854f13797d378f4284a581c4c3915/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Sep 13 12:40:59 PDT 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /reader/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /reader/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 28 5 | 6 | defaultConfig { 7 | minSdkVersion 15 8 | targetSdkVersion 28 9 | } 10 | lintOptions { 11 | checkReleaseBuilds false 12 | abortOnError false 13 | } 14 | compileOptions { 15 | sourceCompatibility JavaVersion.VERSION_1_8 16 | targetCompatibility JavaVersion.VERSION_1_8 17 | } 18 | } 19 | 20 | dependencies { 21 | implementation 'com.android.support:support-annotations:28.0.0-rc01' 22 | } 23 | 24 | apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle' 25 | 26 | afterEvaluate { 27 | androidJavadocs.classpath += project.android.libraryVariants.toList().first().javaCompile.classpath 28 | } -------------------------------------------------------------------------------- /reader/gradle.properties: -------------------------------------------------------------------------------- 1 | POM_NAME=RemoteViewsReader 2 | POM_ARTIFACT_ID=RemoteViewsReader 3 | POM_PACKAGING=aar -------------------------------------------------------------------------------- /reader/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/22.6.2/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 | #} 18 | -------------------------------------------------------------------------------- /reader/src/androidTest/java/jp/yokomark/remoteview/reader/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /reader/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/ActionMap.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader; 2 | 3 | import android.support.annotation.NonNull; 4 | 5 | import jp.yokomark.remoteview.reader.unmarshaller.BitmapReflectionActionUnmarshaller; 6 | import jp.yokomark.remoteview.reader.unmarshaller.ReflectionActionUnmarshaller; 7 | import jp.yokomark.remoteview.reader.unmarshaller.ReflectionWithoutParamsActionUnmarshaller; 8 | import jp.yokomark.remoteview.reader.unmarshaller.SetDrawableParamsActionUnmarshaller; 9 | import jp.yokomark.remoteview.reader.unmarshaller.SetEmptyViewActionUnmarshaller; 10 | import jp.yokomark.remoteview.reader.unmarshaller.SetLaunchPendingIntentActionUnmarshaller; 11 | import jp.yokomark.remoteview.reader.unmarshaller.SetOnClickFillInIntentActionUnmarshaller; 12 | import jp.yokomark.remoteview.reader.unmarshaller.SetOnClickPendingIntentActionUnmarshaller; 13 | import jp.yokomark.remoteview.reader.unmarshaller.SetPendingIntentTemplateActionUnmarshaller; 14 | import jp.yokomark.remoteview.reader.unmarshaller.SetRemoteViewsAdapterIntentActionUnmarshaller; 15 | import jp.yokomark.remoteview.reader.unmarshaller.SetRemoteViewsAdapterListActionUnmarshaller; 16 | import jp.yokomark.remoteview.reader.unmarshaller.TextViewDrawableActionUnmarshaller; 17 | import jp.yokomark.remoteview.reader.unmarshaller.TextViewDrawableColorFilterActionUnmarshaller; 18 | import jp.yokomark.remoteview.reader.unmarshaller.TextViewSizeActionUnmarshaller; 19 | import jp.yokomark.remoteview.reader.unmarshaller.UnknownActionUnmarshaller; 20 | import jp.yokomark.remoteview.reader.unmarshaller.Unmarshaller; 21 | import jp.yokomark.remoteview.reader.unmarshaller.ViewGroupActionUnmarshaller; 22 | import jp.yokomark.remoteview.reader.unmarshaller.ViewPaddingActionUnmarshaller; 23 | 24 | /** 25 | * @author KeishinYokomaku 26 | */ 27 | public enum ActionMap { 28 | SET_PENDING_INTENT("SetOnClickPendingIntent", 1, new SetOnClickPendingIntentActionUnmarshaller()), 29 | REFLECTION("ReflectionAction", 2, new ReflectionActionUnmarshaller()), 30 | SET_DRAWABLE_PARAMS("SetDrawableParamsAction", 3, new SetDrawableParamsActionUnmarshaller()), 31 | VIEW_GROUP("ViewGroupAction", 4, new ViewGroupActionUnmarshaller()), 32 | REFLECTION_WITHOUT_PARAMS("ReflectionWithoutParamsAction", 5, new ReflectionWithoutParamsActionUnmarshaller()), 33 | SET_EMPTY_VIEW("SetEmptyViewAction", 6, new SetEmptyViewActionUnmarshaller()), 34 | SET_PENDING_INTENT_TEMPLATE("SetPendingIntentTemplateAction", 8, new SetPendingIntentTemplateActionUnmarshaller()), 35 | SET_FILL_IN_INTENT("SetOnClickFillInIntent", 9, new SetOnClickFillInIntentActionUnmarshaller()), 36 | SET_REMOTE_VIEWS_ADAPTER_INTENT("SetRemoteViewsAdapterIntent", 10, new SetRemoteViewsAdapterIntentActionUnmarshaller()), 37 | TEXT_VIEW_DRAWABLE("TextViewDrawableAction", 11, new TextViewDrawableActionUnmarshaller()), 38 | BITMAP_REFLECTION("BitmapReflectionAction", 12, new BitmapReflectionActionUnmarshaller()), 39 | TEXT_VIEW_SIZE("TextViewSizeAction", 13, new TextViewSizeActionUnmarshaller()), 40 | VIEW_PADDING("ViewPaddingAction", 14, new ViewPaddingActionUnmarshaller()), 41 | SET_REMOTE_VIEWS_ADAPTER_LIST("SetRemoteViewsAdapterList", 15, new SetRemoteViewsAdapterListActionUnmarshaller()), 42 | TEXT_VIEW_DRAWABLE_COLOR_FILTER_ACTION("TextViewDrawableColorFilterAction", 17, new TextViewDrawableColorFilterActionUnmarshaller()), 43 | SET_LAUNCH_PENDING_INTENT("SetLaunchPendingIntent", 20, new SetLaunchPendingIntentActionUnmarshaller()), // why do you do that to us ms samsung? 44 | UNKNOWN("", 0, new UnknownActionUnmarshaller()); 45 | 46 | private final String simpleClassName; 47 | private final int tag; 48 | private final Unmarshaller unmarshaller; 49 | 50 | ActionMap(String simpleClassName, int tag, @NonNull Unmarshaller unmarshaller) { 51 | this.simpleClassName = simpleClassName; 52 | this.tag = tag; 53 | this.unmarshaller = unmarshaller; 54 | } 55 | 56 | public static ActionMap find(int tag, String simpleClassName) { 57 | for (ActionMap actionMap : values()) { 58 | if (actionMap.tag == tag || actionMap.simpleClassName.equals(simpleClassName)) { 59 | return actionMap; 60 | } 61 | } 62 | return UNKNOWN; 63 | } 64 | 65 | public int getTag() { 66 | return tag; 67 | } 68 | 69 | public Unmarshaller getUnmarshaller() { 70 | return unmarshaller; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/RemoteViewsInfo.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader; 2 | 3 | import android.content.pm.ApplicationInfo; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import jp.yokomark.remoteview.reader.action.RemoteViewsAction; 9 | 10 | /** 11 | * @author KeishinYokomaku 12 | */ 13 | public class RemoteViewsInfo { 14 | private final ApplicationInfo hostApplicaiton; 15 | private final int layoutId; 16 | private final List actions; 17 | 18 | public RemoteViewsInfo(ApplicationInfo hostApplicaiton, int layoutId, List actions) { 19 | this.hostApplicaiton = hostApplicaiton; 20 | this.layoutId = layoutId; 21 | this.actions = actions; 22 | } 23 | 24 | /* package */ static RemoteViewsInfo emptyActions(ApplicationInfo hostApplicaiton, int layoutId) { 25 | return new RemoteViewsInfo(hostApplicaiton, layoutId, new ArrayList()); 26 | } 27 | 28 | /* package */ static RemoteViewsInfo noInfo() { 29 | return new RemoteViewsInfo(null, 0, new ArrayList()); 30 | } 31 | 32 | public void addAction(RemoteViewsAction action) { 33 | actions.add(action); 34 | } 35 | 36 | public List getActions() { 37 | return actions; 38 | } 39 | 40 | public ApplicationInfo getHostApplicaiton() { 41 | return hostApplicaiton; 42 | } 43 | 44 | public int getLayoutId() { 45 | return layoutId; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/RemoteViewsReader.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader; 2 | 3 | import android.content.Context; 4 | import android.content.pm.ApplicationInfo; 5 | import android.os.Parcel; 6 | import android.os.Parcelable; 7 | import android.support.annotation.NonNull; 8 | import android.util.Log; 9 | import android.widget.RemoteViews; 10 | 11 | import java.lang.reflect.Field; 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | import jp.yokomark.remoteview.reader.action.RemoteViewsAction; 16 | import jp.yokomark.remoteview.reader.utils.ClassUtils; 17 | 18 | /** 19 | * @author KeishinYokomaku 20 | */ 21 | public class RemoteViewsReader { 22 | public static final String TAG = RemoteViewsReader.class.getSimpleName(); 23 | 24 | @SuppressWarnings("unchecked") 25 | public static @NonNull RemoteViewsInfo read(@NonNull Context context, @NonNull RemoteViews remoteViews) { 26 | if (remoteViews == null) { 27 | return RemoteViewsInfo.noInfo(); 28 | } 29 | Class clazz = ClassUtils.getRemoteViewsClass(remoteViews.getClass()); 30 | ApplicationInfo applicationInfo = ClassUtils.getApplicationInfo(context, remoteViews, clazz); 31 | int layoutId = remoteViews.getLayoutId(); 32 | try { 33 | Field actionsField = clazz.getDeclaredField("mActions"); 34 | actionsField.setAccessible(true); 35 | List list = (List) actionsField.get(remoteViews); 36 | if (list == null) 37 | return RemoteViewsInfo.emptyActions(applicationInfo, layoutId); 38 | List actions = new ArrayList<>(list.size()); 39 | for (Parcelable p : list) { 40 | Parcel action = Parcel.obtain(); 41 | p.writeToParcel(action, 0); 42 | action.setDataPosition(0); 43 | 44 | 45 | ActionMap mapped = ActionMap.find(action.readInt(), p.getClass().getSimpleName()); 46 | actions.add(mapped.getUnmarshaller().unmarshal(p, action)); 47 | } 48 | return new RemoteViewsInfo(applicationInfo, layoutId, actions); 49 | } catch (NoSuchFieldException e) { 50 | Log.e(TAG, "could not read the field: ", e); 51 | } catch (IllegalAccessException e) { 52 | Log.e(TAG, "could not access the member: ", e); 53 | } 54 | return RemoteViewsInfo.emptyActions(applicationInfo, layoutId); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/action/BitmapReflectionAction.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.action; 2 | 3 | import android.graphics.Bitmap; 4 | 5 | import jp.yokomark.remoteview.reader.ActionMap; 6 | 7 | /** 8 | * @author KeishinYokomaku 9 | */ 10 | public class BitmapReflectionAction extends RemoteViewsAction { 11 | public static final String TAG = BitmapReflectionAction.class.getSimpleName(); 12 | private final String methodName; 13 | private final Bitmap bitmap; 14 | 15 | public BitmapReflectionAction(int viewId, String methodName, Bitmap bitmap) { 16 | super(ActionMap.BITMAP_REFLECTION.getTag(), viewId); 17 | this.methodName = methodName; 18 | this.bitmap = bitmap; 19 | } 20 | 21 | @Override 22 | public String getActionName() { 23 | return "BitmapReflectionAction"; 24 | } 25 | 26 | public String getMethodName() { 27 | return methodName; 28 | } 29 | 30 | public Bitmap getBitmap() { 31 | return bitmap; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/action/IntentContainer.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.action; 2 | 3 | import android.content.Intent; 4 | import android.support.annotation.Nullable; 5 | 6 | /** 7 | * @author KeishinYokomaku 8 | */ 9 | public interface IntentContainer { 10 | @Nullable Intent getContentIntent(); 11 | } 12 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/action/PendingIntentContainer.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.action; 2 | 3 | import android.app.PendingIntent; 4 | import android.support.annotation.Nullable; 5 | 6 | /** 7 | * @author KeishinYokomaku 8 | */ 9 | public interface PendingIntentContainer extends IntentContainer { 10 | @Nullable 11 | PendingIntent getPendingIntent(); 12 | } 13 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/action/ReflectionAction.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.action; 2 | 3 | import jp.yokomark.remoteview.reader.ActionMap; 4 | 5 | /** 6 | * @author KeishinYokomaku 7 | */ 8 | public class ReflectionAction extends RemoteViewsAction { 9 | public static final String TAG = ReflectionAction.class.getSimpleName(); 10 | private final String methodName; 11 | private final Object value; 12 | 13 | public ReflectionAction(int viewId, String methodName, Object value) { 14 | super(ActionMap.REFLECTION.getTag(), viewId); 15 | this.methodName = methodName; 16 | this.value = value; 17 | } 18 | 19 | @Override 20 | public String getActionName() { 21 | return "ReflectionAction"; 22 | } 23 | 24 | public String getMethodName() { 25 | return methodName; 26 | } 27 | 28 | public Object getValue() { 29 | return value; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/action/ReflectionWithoutParamsAction.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.action; 2 | 3 | import jp.yokomark.remoteview.reader.ActionMap; 4 | 5 | /** 6 | * @author KeishinYokomaku 7 | */ 8 | public class ReflectionWithoutParamsAction extends RemoteViewsAction { 9 | public static final String TAG = ReflectionWithoutParamsAction.class.getSimpleName(); 10 | private final String methodName; 11 | 12 | public ReflectionWithoutParamsAction(int viewId, String methodName) { 13 | super(ActionMap.REFLECTION_WITHOUT_PARAMS.getTag(), viewId); 14 | this.methodName = methodName; 15 | } 16 | 17 | @Override 18 | public String getActionName() { 19 | return "ReflectionWithoutParamsAction"; 20 | } 21 | 22 | public String getMethodName() { 23 | return methodName; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/action/RemoteViewsAction.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.action; 2 | 3 | /** 4 | * @author KeishinYokomaku 5 | */ 6 | public abstract class RemoteViewsAction { 7 | private final int tag; 8 | private final int viewId; 9 | 10 | /* package */ RemoteViewsAction(int tag, int viewId) { 11 | this.tag = tag; 12 | this.viewId = viewId; 13 | } 14 | 15 | public int getTag() { 16 | return tag; 17 | } 18 | 19 | public int getViewId() { 20 | return viewId; 21 | } 22 | 23 | public abstract String getActionName(); 24 | } 25 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/action/SetDrawableParamsAction.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.action; 2 | 3 | import android.graphics.PorterDuff; 4 | 5 | import jp.yokomark.remoteview.reader.ActionMap; 6 | 7 | /** 8 | * @author KeishinYokomaku 9 | */ 10 | public class SetDrawableParamsAction extends RemoteViewsAction { 11 | public static final String TAG = SetDrawableParamsAction.class.getSimpleName(); 12 | private final boolean target; 13 | private final int alpha; 14 | private final int colorFilter; 15 | private final PorterDuff.Mode mode; 16 | private final int level; 17 | 18 | public SetDrawableParamsAction(int viewId, boolean target, int alpha, int colorFilter, PorterDuff.Mode mode, int level) { 19 | super(ActionMap.SET_DRAWABLE_PARAMS.getTag(), viewId); 20 | this.target = target; 21 | this.alpha = alpha; 22 | this.colorFilter = colorFilter; 23 | this.mode = mode; 24 | this.level = level; 25 | } 26 | 27 | @Override 28 | public String getActionName() { 29 | return "SetDrawableParams"; 30 | } 31 | 32 | public boolean isTarget() { 33 | return target; 34 | } 35 | 36 | public int getAlpha() { 37 | return alpha; 38 | } 39 | 40 | public int getColorFilter() { 41 | return colorFilter; 42 | } 43 | 44 | public PorterDuff.Mode getMode() { 45 | return mode; 46 | } 47 | 48 | public int getLevel() { 49 | return level; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/action/SetEmptyViewAction.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.action; 2 | 3 | import jp.yokomark.remoteview.reader.ActionMap; 4 | 5 | /** 6 | * @author KeishinYokomaku 7 | */ 8 | public class SetEmptyViewAction extends RemoteViewsAction { 9 | public static final String TAG = SetEmptyViewAction.class.getSimpleName(); 10 | private final int emptyViewId; 11 | 12 | public SetEmptyViewAction(int viewId, int emptyViewId) { 13 | super(ActionMap.SET_EMPTY_VIEW.getTag(), viewId); 14 | this.emptyViewId = emptyViewId; 15 | } 16 | 17 | @Override 18 | public String getActionName() { 19 | return "SetEmptyViewAction"; 20 | } 21 | 22 | public int getEmptyViewId() { 23 | return emptyViewId; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/action/SetLaunchPendingIntentAction.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.action; 2 | 3 | import android.app.PendingIntent; 4 | import android.content.Intent; 5 | import android.support.annotation.Nullable; 6 | import android.util.Log; 7 | 8 | import java.lang.reflect.InvocationTargetException; 9 | import java.lang.reflect.Method; 10 | 11 | import jp.yokomark.remoteview.reader.ActionMap; 12 | 13 | public class SetLaunchPendingIntentAction extends RemoteViewsAction implements PendingIntentContainer { 14 | public static final String TAG = SetLaunchPendingIntentAction.class.getSimpleName(); 15 | private final PendingIntent pendingIntent; 16 | 17 | public SetLaunchPendingIntentAction(int viewId, PendingIntent pendingIntent) { 18 | super(ActionMap.SET_PENDING_INTENT.getTag(), viewId); 19 | this.pendingIntent = pendingIntent; 20 | } 21 | 22 | @Override 23 | public String getActionName() { 24 | return "SetLaunchPendingIntentAction"; 25 | } 26 | 27 | @Override 28 | @Nullable 29 | public PendingIntent getPendingIntent() { 30 | return pendingIntent; 31 | } 32 | 33 | @Override 34 | @Nullable 35 | public Intent getContentIntent() { 36 | if (pendingIntent == null) 37 | return null; 38 | try { 39 | Method getIntent = pendingIntent.getClass().getDeclaredMethod("getIntent"); 40 | getIntent.setAccessible(true); 41 | return (Intent) getIntent.invoke(pendingIntent); 42 | } catch (NoSuchMethodException e) { 43 | Log.e(TAG, "", e); 44 | } catch (InvocationTargetException e) { 45 | Log.e(TAG, "", e); 46 | } catch (IllegalAccessException e) { 47 | Log.e(TAG, "", e); 48 | } 49 | return null; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/action/SetOnClickFillInIntentAction.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.action; 2 | 3 | import android.content.Intent; 4 | import android.support.annotation.Nullable; 5 | 6 | import jp.yokomark.remoteview.reader.ActionMap; 7 | 8 | /** 9 | * @author KeishinYokomaku 10 | */ 11 | public class SetOnClickFillInIntentAction extends RemoteViewsAction implements IntentContainer { 12 | public static final String TAG = SetOnClickFillInIntentAction.class.getSimpleName(); 13 | private final Intent intent; 14 | 15 | public SetOnClickFillInIntentAction(int viewId, Intent intent) { 16 | super(ActionMap.SET_FILL_IN_INTENT.getTag(), viewId); 17 | this.intent = intent; 18 | } 19 | 20 | @Override 21 | public String getActionName() { 22 | return "SetOnClickFillInIntentAction"; 23 | } 24 | 25 | @Override 26 | @Nullable 27 | public Intent getContentIntent() { 28 | return intent; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/action/SetOnClickPendingIntentAction.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.action; 2 | 3 | import android.app.PendingIntent; 4 | import android.content.Intent; 5 | import android.support.annotation.Nullable; 6 | import android.util.Log; 7 | 8 | import java.lang.reflect.InvocationTargetException; 9 | import java.lang.reflect.Method; 10 | 11 | import jp.yokomark.remoteview.reader.ActionMap; 12 | 13 | /** 14 | * @author KeishinYokomaku 15 | */ 16 | public class SetOnClickPendingIntentAction extends RemoteViewsAction implements PendingIntentContainer { 17 | public static final String TAG = SetOnClickPendingIntentAction.class.getSimpleName(); 18 | private final PendingIntent pendingIntent; 19 | 20 | public SetOnClickPendingIntentAction(int viewId, PendingIntent pendingIntent) { 21 | super(ActionMap.SET_PENDING_INTENT.getTag(), viewId); 22 | this.pendingIntent = pendingIntent; 23 | } 24 | 25 | @Override 26 | public String getActionName() { 27 | return "SetOnClickPendingIntentAction"; 28 | } 29 | 30 | @Override 31 | @Nullable 32 | public PendingIntent getPendingIntent() { 33 | return pendingIntent; 34 | } 35 | 36 | @Override 37 | @Nullable 38 | public Intent getContentIntent() { 39 | if (pendingIntent == null) 40 | return null; 41 | try { 42 | Method getIntent = pendingIntent.getClass().getDeclaredMethod("getIntent"); 43 | getIntent.setAccessible(true); 44 | return (Intent) getIntent.invoke(pendingIntent); 45 | } catch (NoSuchMethodException e) { 46 | Log.e(TAG, "", e); 47 | } catch (InvocationTargetException e) { 48 | Log.e(TAG, "", e); 49 | } catch (IllegalAccessException e) { 50 | Log.e(TAG, "", e); 51 | } 52 | return null; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/action/SetPendingIntentTemplateAction.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.action; 2 | 3 | import android.app.PendingIntent; 4 | import android.content.Intent; 5 | import android.support.annotation.Nullable; 6 | import android.util.Log; 7 | 8 | import java.lang.reflect.InvocationTargetException; 9 | import java.lang.reflect.Method; 10 | 11 | import jp.yokomark.remoteview.reader.ActionMap; 12 | 13 | /** 14 | * @author KeishinYokomaku 15 | */ 16 | public class SetPendingIntentTemplateAction extends RemoteViewsAction implements PendingIntentContainer { 17 | public static final String TAG = SetPendingIntentTemplateAction.class.getSimpleName(); 18 | private final PendingIntent pendingIntent; 19 | 20 | public SetPendingIntentTemplateAction(int viewId, PendingIntent pendingIntent) { 21 | super(ActionMap.SET_PENDING_INTENT_TEMPLATE.getTag(), viewId); 22 | this.pendingIntent = pendingIntent; 23 | } 24 | 25 | @Override 26 | public String getActionName() { 27 | return "SetPendingIntentTemplateAction"; 28 | } 29 | 30 | @Override 31 | @Nullable 32 | public PendingIntent getPendingIntent() { 33 | return pendingIntent; 34 | } 35 | 36 | @Override 37 | @Nullable 38 | public Intent getContentIntent() { 39 | if (pendingIntent == null) 40 | return null; 41 | try { 42 | Method getIntent = pendingIntent.getClass().getDeclaredMethod("getIntent"); 43 | getIntent.setAccessible(true); 44 | return (Intent) getIntent.invoke(pendingIntent); 45 | } catch (NoSuchMethodException e) { 46 | Log.e(TAG, "", e); 47 | } catch (InvocationTargetException e) { 48 | Log.e(TAG, "", e); 49 | } catch (IllegalAccessException e) { 50 | Log.e(TAG, "", e); 51 | } 52 | return null; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/action/SetRemoteViewsAdapterIntentAction.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.action; 2 | 3 | import android.content.Intent; 4 | import android.support.annotation.Nullable; 5 | 6 | import jp.yokomark.remoteview.reader.ActionMap; 7 | 8 | /** 9 | * @author KeishinYokomaku 10 | */ 11 | public class SetRemoteViewsAdapterIntentAction extends RemoteViewsAction implements IntentContainer { 12 | public static final String TAG = SetRemoteViewsAdapterIntentAction.class.getSimpleName(); 13 | private final Intent intent; 14 | 15 | public SetRemoteViewsAdapterIntentAction(int viewId, Intent intent) { 16 | super(ActionMap.SET_REMOTE_VIEWS_ADAPTER_INTENT.getTag(), viewId); 17 | this.intent = intent; 18 | } 19 | 20 | @Override 21 | public String getActionName() { 22 | return "SetRemoteViewsAdapterIntentAction"; 23 | } 24 | 25 | @Override 26 | @Nullable 27 | public Intent getContentIntent() { 28 | return intent; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/action/SetRemoteViewsAdapterListAction.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.action; 2 | 3 | import android.widget.RemoteViews; 4 | 5 | import java.util.List; 6 | 7 | import jp.yokomark.remoteview.reader.ActionMap; 8 | 9 | /** 10 | * @author KeishinYokomaku 11 | */ 12 | public class SetRemoteViewsAdapterListAction extends RemoteViewsAction { 13 | public static final String TAG = SetRemoteViewsAdapterListAction.class.getSimpleName(); 14 | private final int count; 15 | private final int viewTypeCount; 16 | private final List views; 17 | 18 | public SetRemoteViewsAdapterListAction(int viewId, int count, int viewTypeCount, List views) { 19 | super(ActionMap.SET_REMOTE_VIEWS_ADAPTER_LIST.getTag(), viewId); 20 | this.count = count; 21 | this.viewTypeCount = viewTypeCount; 22 | this.views = views; 23 | } 24 | 25 | @Override 26 | public String getActionName() { 27 | return "SetRemoteViewsAdapterListAction"; 28 | } 29 | 30 | public int getCount() { 31 | return count; 32 | } 33 | 34 | public int getViewTypeCount() { 35 | return viewTypeCount; 36 | } 37 | 38 | public List getViews() { 39 | return views; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/action/TextViewDrawableAction.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.action; 2 | 3 | import android.support.annotation.DrawableRes; 4 | 5 | import jp.yokomark.remoteview.reader.ActionMap; 6 | 7 | /** 8 | * @author KeishinYokomaku 9 | */ 10 | public class TextViewDrawableAction extends RemoteViewsAction { 11 | public static final String TAG = TextViewDrawableAction.class.getSimpleName(); 12 | private final boolean isRelative; 13 | private final int left; 14 | private final int top; 15 | private final int right; 16 | private final int bottom; 17 | 18 | public TextViewDrawableAction(int viewId, boolean isRelative, int left, int top, int right, int bottom) { 19 | super(ActionMap.TEXT_VIEW_DRAWABLE.getTag(), viewId); 20 | this.isRelative = isRelative; 21 | this.left = left; 22 | this.top = top; 23 | this.right = right; 24 | this.bottom = bottom; 25 | } 26 | 27 | @Override 28 | public String getActionName() { 29 | return "TextViewDrawableAction"; 30 | } 31 | 32 | public boolean isRelative() { 33 | return isRelative; 34 | } 35 | 36 | public @DrawableRes int getLeft() { 37 | return left; 38 | } 39 | 40 | public @DrawableRes int getTop() { 41 | return top; 42 | } 43 | 44 | public @DrawableRes int getRight() { 45 | return right; 46 | } 47 | 48 | public @DrawableRes int getBottom() { 49 | return bottom; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/action/TextViewDrawableColorFilterAction.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.action; 2 | 3 | import android.graphics.PorterDuff; 4 | 5 | import jp.yokomark.remoteview.reader.ActionMap; 6 | 7 | /** 8 | * @author KeishinYokomaku 9 | */ 10 | public class TextViewDrawableColorFilterAction extends RemoteViewsAction { 11 | public static final String TAG = TextViewDrawableColorFilterAction.class.getSimpleName(); 12 | private final boolean isRelative; 13 | private final int index; 14 | private final int color; 15 | private final PorterDuff.Mode mode; 16 | 17 | public TextViewDrawableColorFilterAction(int viewId, boolean isRelative, int index, int color, PorterDuff.Mode mode) { 18 | super(ActionMap.TEXT_VIEW_DRAWABLE_COLOR_FILTER_ACTION.getTag(), viewId); 19 | this.isRelative = isRelative; 20 | this.index = index; 21 | this.color = color; 22 | this.mode = mode; 23 | } 24 | 25 | @Override 26 | public String getActionName() { 27 | return "TextViewDrawableColorFilterAction"; 28 | } 29 | 30 | public boolean isRelative() { 31 | return isRelative; 32 | } 33 | 34 | public int getIndex() { 35 | return index; 36 | } 37 | 38 | public int getColor() { 39 | return color; 40 | } 41 | 42 | public PorterDuff.Mode getMode() { 43 | return mode; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/action/TextViewSizeAction.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.action; 2 | 3 | import jp.yokomark.remoteview.reader.ActionMap; 4 | 5 | /** 6 | * @author KeishinYokomaku 7 | */ 8 | public class TextViewSizeAction extends RemoteViewsAction { 9 | public static final String TAG = TextViewSizeAction.class.getSimpleName(); 10 | private final int units; 11 | private final float size; 12 | 13 | public TextViewSizeAction(int viewId, int units, float size) { 14 | super(ActionMap.TEXT_VIEW_SIZE.getTag(), viewId); 15 | this.units = units; 16 | this.size = size; 17 | } 18 | 19 | @Override 20 | public String getActionName() { 21 | return "TextViewSizeAction"; 22 | } 23 | 24 | public int getUnits() { 25 | return units; 26 | } 27 | 28 | public float getSize() { 29 | return size; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/action/ViewGroupAction.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.action; 2 | 3 | import android.content.Context; 4 | import android.widget.RemoteViews; 5 | 6 | import jp.yokomark.remoteview.reader.ActionMap; 7 | import jp.yokomark.remoteview.reader.RemoteViewsInfo; 8 | import jp.yokomark.remoteview.reader.RemoteViewsReader; 9 | 10 | /** 11 | * @author KeishinYokomaku 12 | */ 13 | public class ViewGroupAction extends RemoteViewsAction { 14 | public static final String TAG = ViewGroupAction.class.getSimpleName(); 15 | private final RemoteViews nested; 16 | 17 | public ViewGroupAction(int viewId, RemoteViews nested) { 18 | super(ActionMap.VIEW_GROUP.getTag(), viewId); 19 | this.nested = nested; 20 | } 21 | 22 | @Override 23 | public String getActionName() { 24 | return "ViewGroupAction"; 25 | } 26 | 27 | public RemoteViews getNestedViews() { 28 | return nested; 29 | } 30 | 31 | public RemoteViewsInfo getNestedViewsInfo(Context context) { 32 | if (nested == null) { 33 | return null; 34 | } 35 | return RemoteViewsReader.read(context, nested); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/action/ViewPaddingAction.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.action; 2 | 3 | import jp.yokomark.remoteview.reader.ActionMap; 4 | 5 | /** 6 | * @author KeishinYokomaku 7 | */ 8 | public class ViewPaddingAction extends RemoteViewsAction { 9 | public static final String TAG = ViewPaddingAction.class.getSimpleName(); 10 | private final int left; 11 | private final int top; 12 | private final int right; 13 | private final int bottom; 14 | 15 | public ViewPaddingAction(int viewId, int left, int top, int right, int bottom) { 16 | super(ActionMap.VIEW_PADDING.getTag(), viewId); 17 | this.left = left; 18 | this.top = top; 19 | this.right = right; 20 | this.bottom = bottom; 21 | } 22 | 23 | @Override 24 | public String getActionName() { 25 | return "ViewPaddingAction"; 26 | } 27 | 28 | public int getLeft() { 29 | return left; 30 | } 31 | 32 | public int getTop() { 33 | return top; 34 | } 35 | 36 | public int getRight() { 37 | return right; 38 | } 39 | 40 | public int getBottom() { 41 | return bottom; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/unmarshaller/BitmapReflectionActionUnmarshaller.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.unmarshaller; 2 | 3 | import android.graphics.Bitmap; 4 | import android.os.Parcel; 5 | import android.os.Parcelable; 6 | import android.util.Log; 7 | 8 | import java.lang.reflect.Field; 9 | 10 | import jp.yokomark.remoteview.reader.action.BitmapReflectionAction; 11 | 12 | /** 13 | * @author KeishinYokomaku 14 | */ 15 | public class BitmapReflectionActionUnmarshaller implements Unmarshaller { 16 | public static final String TAG = BitmapReflectionActionUnmarshaller.class.getSimpleName(); 17 | 18 | @Override 19 | public BitmapReflectionAction unmarshal(Parcelable p, Parcel action) { 20 | try { 21 | int id = action.readInt(); 22 | String methodName = action.readString(); 23 | Field bitmapField = p.getClass().getDeclaredField("bitmap"); 24 | bitmapField.setAccessible(true); 25 | Bitmap bitmap = (Bitmap) bitmapField.get(p); 26 | return new BitmapReflectionAction(id, methodName, bitmap); 27 | } catch (NoSuchFieldException e) { 28 | Log.e(TAG, "", e); 29 | } catch (IllegalAccessException e) { 30 | Log.e(TAG, "", e); 31 | } 32 | return null; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/unmarshaller/ReflectionActionUnmarshaller.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.unmarshaller; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | import android.util.Log; 6 | 7 | import java.lang.reflect.Field; 8 | 9 | import jp.yokomark.remoteview.reader.action.ReflectionAction; 10 | 11 | /** 12 | * @author KeishinYokomaku 13 | */ 14 | public class ReflectionActionUnmarshaller implements Unmarshaller { 15 | public static final String TAG = ReflectionActionUnmarshaller.class.getSimpleName(); 16 | 17 | @Override 18 | public ReflectionAction unmarshal(Parcelable p, Parcel action) { 19 | try { 20 | int id = action.readInt(); 21 | String methodName = action.readString(); 22 | Field valueField = p.getClass().getDeclaredField("value"); 23 | valueField.setAccessible(true); 24 | return new ReflectionAction(id, methodName, valueField.get(p)); 25 | } catch (NoSuchFieldException e) { 26 | Log.e(TAG, "", e); 27 | } catch (IllegalAccessException e) { 28 | Log.e(TAG, "", e); 29 | } 30 | return null; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/unmarshaller/ReflectionWithoutParamsActionUnmarshaller.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.unmarshaller; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | import jp.yokomark.remoteview.reader.action.ReflectionWithoutParamsAction; 7 | 8 | /** 9 | * @author KeishinYokomaku 10 | */ 11 | public class ReflectionWithoutParamsActionUnmarshaller implements Unmarshaller { 12 | public static final String TAG = ReflectionWithoutParamsActionUnmarshaller.class.getSimpleName(); 13 | 14 | @Override 15 | public ReflectionWithoutParamsAction unmarshal(Parcelable p, Parcel action) { 16 | int id = action.readInt(); 17 | String methodName = action.readString(); 18 | return new ReflectionWithoutParamsAction(id, methodName); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/unmarshaller/SetDrawableParamsActionUnmarshaller.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.unmarshaller; 2 | 3 | import android.graphics.PorterDuff; 4 | import android.os.Parcel; 5 | import android.os.Parcelable; 6 | 7 | import jp.yokomark.remoteview.reader.action.SetDrawableParamsAction; 8 | 9 | /** 10 | * @author KeishinYokomaku 11 | */ 12 | public class SetDrawableParamsActionUnmarshaller implements Unmarshaller { 13 | public static final String TAG = SetDrawableParamsActionUnmarshaller.class.getSimpleName(); 14 | 15 | @Override 16 | public SetDrawableParamsAction unmarshal(Parcelable p, Parcel action) { 17 | int id = action.readInt(); 18 | boolean target = action.readInt() == 1; 19 | int alpha = action.readInt(); 20 | int colorFilter = action.readInt(); 21 | boolean hasMode = action.readInt() == 1; 22 | PorterDuff.Mode mode = hasMode ? PorterDuff.Mode.valueOf(action.readString()) : null; 23 | int level = action.readInt(); 24 | return new SetDrawableParamsAction(id, target, alpha, colorFilter, mode, level); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/unmarshaller/SetEmptyViewActionUnmarshaller.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.unmarshaller; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | import jp.yokomark.remoteview.reader.action.SetEmptyViewAction; 7 | 8 | /** 9 | * @author KeishinYokomaku 10 | */ 11 | public class SetEmptyViewActionUnmarshaller implements Unmarshaller { 12 | public static final String TAG = SetEmptyViewActionUnmarshaller.class.getSimpleName(); 13 | 14 | @Override 15 | public SetEmptyViewAction unmarshal(Parcelable p, Parcel action) { 16 | int id = action.readInt(); 17 | int emptyViewId = action.readInt(); 18 | return new SetEmptyViewAction(id, emptyViewId); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/unmarshaller/SetLaunchPendingIntentActionUnmarshaller.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.unmarshaller; 2 | 3 | import android.app.PendingIntent; 4 | import android.os.Parcel; 5 | import android.os.Parcelable; 6 | import android.util.Log; 7 | 8 | import java.lang.reflect.Field; 9 | 10 | import jp.yokomark.remoteview.reader.action.SetLaunchPendingIntentAction; 11 | 12 | public class SetLaunchPendingIntentActionUnmarshaller implements Unmarshaller { 13 | public static final String TAG = SetLaunchPendingIntentActionUnmarshaller.class.getSimpleName(); 14 | 15 | @Override 16 | public SetLaunchPendingIntentAction unmarshal(Parcelable p, Parcel action) { 17 | try { 18 | int id = action.readInt(); 19 | Field nestedField = p.getClass().getDeclaredField("pendingIntent"); 20 | nestedField.setAccessible(true); 21 | PendingIntent pendingIntent = (PendingIntent) nestedField.get(p); 22 | return new SetLaunchPendingIntentAction(id, pendingIntent); 23 | } catch (NoSuchFieldException e) { 24 | Log.e(TAG, "", e); 25 | } catch (IllegalAccessException e) { 26 | Log.e(TAG, "", e); 27 | } 28 | return null; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/unmarshaller/SetOnClickFillInIntentActionUnmarshaller.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.unmarshaller; 2 | 3 | import android.content.Intent; 4 | import android.os.Parcel; 5 | import android.os.Parcelable; 6 | import android.util.Log; 7 | 8 | import java.lang.reflect.Field; 9 | 10 | import jp.yokomark.remoteview.reader.action.SetOnClickFillInIntentAction; 11 | 12 | /** 13 | * @author KeishinYokomaku 14 | */ 15 | public class SetOnClickFillInIntentActionUnmarshaller implements Unmarshaller { 16 | public static final String TAG = SetOnClickFillInIntentActionUnmarshaller.class.getSimpleName(); 17 | 18 | @Override 19 | public SetOnClickFillInIntentAction unmarshal(Parcelable p, Parcel action) { 20 | try { 21 | int id = action.readInt(); 22 | Field intentField = p.getClass().getDeclaredField("fillInIntent"); 23 | intentField.setAccessible(true); 24 | Intent intent = (Intent) intentField.get(p); 25 | return new SetOnClickFillInIntentAction(id, intent); 26 | } catch (IllegalAccessException e) { 27 | Log.e(TAG, "", e); 28 | } catch (NoSuchFieldException e) { 29 | Log.e(TAG, "", e); 30 | } 31 | return null; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/unmarshaller/SetOnClickPendingIntentActionUnmarshaller.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.unmarshaller; 2 | 3 | import android.app.PendingIntent; 4 | import android.os.Parcel; 5 | import android.os.Parcelable; 6 | import android.util.Log; 7 | 8 | import java.lang.reflect.Field; 9 | 10 | import jp.yokomark.remoteview.reader.action.SetOnClickPendingIntentAction; 11 | 12 | /** 13 | * @author KeishinYokomaku 14 | */ 15 | public class SetOnClickPendingIntentActionUnmarshaller implements Unmarshaller { 16 | public static final String TAG = SetOnClickPendingIntentActionUnmarshaller.class.getSimpleName(); 17 | 18 | @Override 19 | public SetOnClickPendingIntentAction unmarshal(Parcelable p, Parcel action) { 20 | try { 21 | int id = action.readInt(); 22 | Field nestedField = p.getClass().getDeclaredField("pendingIntent"); 23 | nestedField.setAccessible(true); 24 | PendingIntent pendingIntent = (PendingIntent) nestedField.get(p); 25 | return new SetOnClickPendingIntentAction(id, pendingIntent); 26 | } catch (NoSuchFieldException e) { 27 | Log.e(TAG, "", e); 28 | } catch (IllegalAccessException e) { 29 | Log.e(TAG, "", e); 30 | } 31 | return null; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/unmarshaller/SetPendingIntentTemplateActionUnmarshaller.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.unmarshaller; 2 | 3 | import android.app.PendingIntent; 4 | import android.os.Parcel; 5 | import android.os.Parcelable; 6 | import android.util.Log; 7 | 8 | import java.lang.reflect.Field; 9 | 10 | import jp.yokomark.remoteview.reader.action.SetPendingIntentTemplateAction; 11 | 12 | /** 13 | * @author KeishinYokomaku 14 | */ 15 | public class SetPendingIntentTemplateActionUnmarshaller implements Unmarshaller { 16 | public static final String TAG = SetPendingIntentTemplateActionUnmarshaller.class.getSimpleName(); 17 | 18 | @Override 19 | public SetPendingIntentTemplateAction unmarshal(Parcelable p, Parcel action) { 20 | try { 21 | int id = action.readInt(); 22 | Field nestedField = p.getClass().getDeclaredField("pendingIntentTemplate"); 23 | nestedField.setAccessible(true); 24 | PendingIntent pendingIntent = (PendingIntent) nestedField.get(p); 25 | return new SetPendingIntentTemplateAction(id, pendingIntent); 26 | } catch (NoSuchFieldException e) { 27 | Log.e(TAG, "", e); 28 | } catch (IllegalAccessException e) { 29 | Log.e(TAG, "", e); 30 | } 31 | return null; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/unmarshaller/SetRemoteViewsAdapterIntentActionUnmarshaller.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.unmarshaller; 2 | 3 | import android.content.Intent; 4 | import android.os.Parcel; 5 | import android.os.Parcelable; 6 | import android.util.Log; 7 | 8 | import java.lang.reflect.Field; 9 | 10 | import jp.yokomark.remoteview.reader.action.SetRemoteViewsAdapterIntentAction; 11 | 12 | /** 13 | * @author KeishinYokomaku 14 | */ 15 | public class SetRemoteViewsAdapterIntentActionUnmarshaller implements Unmarshaller { 16 | public static final String TAG = SetRemoteViewsAdapterIntentActionUnmarshaller.class.getSimpleName(); 17 | 18 | @Override 19 | public SetRemoteViewsAdapterIntentAction unmarshal(Parcelable p, Parcel action) { 20 | try { 21 | int id = action.readInt(); 22 | Field intentField = p.getClass().getDeclaredField("intent"); 23 | intentField.setAccessible(true); 24 | Intent intent = (Intent) intentField.get(p); 25 | return new SetRemoteViewsAdapterIntentAction(id, intent); 26 | } catch (IllegalAccessException e) { 27 | Log.e(TAG, "", e); 28 | } catch (NoSuchFieldException e) { 29 | Log.e(TAG, "", e); 30 | } 31 | return null; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/unmarshaller/SetRemoteViewsAdapterListActionUnmarshaller.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.unmarshaller; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | import android.widget.RemoteViews; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | import jp.yokomark.remoteview.reader.action.SetRemoteViewsAdapterListAction; 11 | 12 | /** 13 | * @author KeishinYokomaku 14 | */ 15 | public class SetRemoteViewsAdapterListActionUnmarshaller implements Unmarshaller { 16 | public static final String TAG = SetRemoteViewsAdapterListActionUnmarshaller.class.getSimpleName(); 17 | 18 | @Override 19 | public SetRemoteViewsAdapterListAction unmarshal(Parcelable p, Parcel action) { 20 | int id = action.readInt(); 21 | int viewTypeCount = action.readInt(); 22 | int count = action.readInt(); 23 | List list = new ArrayList<>(); 24 | for (int i = 0; i < count; i++) { 25 | RemoteViews rv = RemoteViews.CREATOR.createFromParcel(action); 26 | list.add(rv); 27 | } 28 | return new SetRemoteViewsAdapterListAction(id, count, viewTypeCount, list); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/unmarshaller/TextViewDrawableActionUnmarshaller.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.unmarshaller; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | import jp.yokomark.remoteview.reader.action.TextViewDrawableAction; 7 | 8 | /** 9 | * @author KeishinYokomaku 10 | */ 11 | public class TextViewDrawableActionUnmarshaller implements Unmarshaller { 12 | public static final String TAG = TextViewDrawableActionUnmarshaller.class.getSimpleName(); 13 | 14 | @Override 15 | public TextViewDrawableAction unmarshal(Parcelable p, Parcel action) { 16 | int id = action.readInt(); 17 | boolean relative = action.readInt() == 1; 18 | int left = action.readInt(); 19 | int top = action.readInt(); 20 | int right = action.readInt(); 21 | int bottom = action.readInt(); 22 | return new TextViewDrawableAction(id, relative, left, top, right, bottom); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/unmarshaller/TextViewDrawableColorFilterActionUnmarshaller.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.unmarshaller; 2 | 3 | import android.graphics.PorterDuff; 4 | import android.os.Parcel; 5 | import android.os.Parcelable; 6 | 7 | import jp.yokomark.remoteview.reader.action.TextViewDrawableColorFilterAction; 8 | 9 | /** 10 | * @author KeishinYokomaku 11 | */ 12 | public class TextViewDrawableColorFilterActionUnmarshaller implements Unmarshaller { 13 | public static final String TAG = TextViewDrawableColorFilterActionUnmarshaller.class.getSimpleName(); 14 | 15 | @Override 16 | public TextViewDrawableColorFilterAction unmarshal(Parcelable p, Parcel action) { 17 | int id = action.readInt(); 18 | boolean relative = action.readInt() == 1; 19 | int index = action.readInt(); 20 | int color = action.readInt(); 21 | PorterDuff.Mode mode = readPorterDuffMode(action); 22 | return new TextViewDrawableColorFilterAction(id, relative, index, color, mode); 23 | } 24 | 25 | private PorterDuff.Mode readPorterDuffMode(Parcel parcel) { 26 | int mode = parcel.readInt(); 27 | if (mode >= 0 && mode < PorterDuff.Mode.values().length) { 28 | return PorterDuff.Mode.values()[mode]; 29 | } else { 30 | return PorterDuff.Mode.CLEAR; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/unmarshaller/TextViewSizeActionUnmarshaller.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.unmarshaller; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | import jp.yokomark.remoteview.reader.action.TextViewSizeAction; 7 | 8 | /** 9 | * @author KeishinYokomaku 10 | */ 11 | public class TextViewSizeActionUnmarshaller implements Unmarshaller { 12 | @Override 13 | public TextViewSizeAction unmarshal(Parcelable p, Parcel action) { 14 | int id = action.readInt(); 15 | int units = action.readInt(); 16 | float size = action.readFloat(); 17 | return new TextViewSizeAction(id, units, size); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/unmarshaller/UnknownActionUnmarshaller.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.unmarshaller; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | import jp.yokomark.remoteview.reader.action.RemoteViewsAction; 7 | 8 | /** 9 | * @author KeishinYokomaku 10 | */ 11 | public class UnknownActionUnmarshaller implements Unmarshaller { 12 | public static final String TAG = UnknownActionUnmarshaller.class.getSimpleName(); 13 | 14 | @Override 15 | public RemoteViewsAction unmarshal(Parcelable p, Parcel action) { 16 | return null; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/unmarshaller/Unmarshaller.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.unmarshaller; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | import jp.yokomark.remoteview.reader.action.RemoteViewsAction; 7 | 8 | /** 9 | * @author KeishinYokomaku 10 | */ 11 | public interface Unmarshaller { 12 | RemoteViewsAction unmarshal(Parcelable p, Parcel action); 13 | } 14 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/unmarshaller/ViewGroupActionUnmarshaller.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.unmarshaller; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | import android.util.Log; 6 | import android.widget.RemoteViews; 7 | 8 | import java.lang.reflect.Field; 9 | 10 | import jp.yokomark.remoteview.reader.action.ViewGroupAction; 11 | 12 | /** 13 | * @author KeishinYokomaku 14 | */ 15 | public class ViewGroupActionUnmarshaller implements Unmarshaller { 16 | public static final String TAG = ViewGroupActionUnmarshaller.class.getSimpleName(); 17 | 18 | @Override 19 | public final ViewGroupAction unmarshal(Parcelable p, Parcel action) { 20 | try { 21 | int id = action.readInt(); 22 | Field nestedField = p.getClass().getDeclaredField("nestedViews"); 23 | nestedField.setAccessible(true); 24 | RemoteViews nested = (RemoteViews) nestedField.get(p); 25 | return new ViewGroupAction(id, nested); 26 | } catch (NoSuchFieldException e) { 27 | Log.e(TAG, "", e); 28 | } catch (IllegalAccessException e) { 29 | Log.e(TAG, "", e); 30 | } 31 | return null; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/unmarshaller/ViewPaddingActionUnmarshaller.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.unmarshaller; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | import jp.yokomark.remoteview.reader.action.ViewPaddingAction; 7 | 8 | /** 9 | * @author KeishinYokomaku 10 | */ 11 | public class ViewPaddingActionUnmarshaller implements Unmarshaller { 12 | public static final String TAG = ViewPaddingActionUnmarshaller.class.getSimpleName(); 13 | 14 | @Override 15 | public ViewPaddingAction unmarshal(Parcelable p, Parcel action) { 16 | int id = action.readInt(); 17 | int left = action.readInt(); 18 | int top = action.readInt(); 19 | int right = action.readInt(); 20 | int bottom = action.readInt(); 21 | return new ViewPaddingAction(id, left, top, right, bottom); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /reader/src/main/java/jp/yokomark/remoteview/reader/utils/ClassUtils.java: -------------------------------------------------------------------------------- 1 | package jp.yokomark.remoteview.reader.utils; 2 | 3 | import android.content.Context; 4 | import android.content.pm.ApplicationInfo; 5 | import android.content.pm.PackageManager; 6 | import android.os.Build; 7 | import android.support.annotation.Nullable; 8 | import android.util.Log; 9 | import android.widget.RemoteViews; 10 | 11 | import java.lang.reflect.Field; 12 | 13 | /** 14 | * @author KeishinYokomaku 15 | */ 16 | public final class ClassUtils { 17 | public static final String TAG = ClassUtils.class.getSimpleName(); 18 | 19 | private ClassUtils() { 20 | throw new AssertionError(); 21 | } 22 | 23 | public static Class getRemoteViewsClass(Class clazz) { 24 | if (clazz.equals(RemoteViews.class)) 25 | return clazz; 26 | Class superClass = clazz.getSuperclass(); 27 | while (!superClass.equals(RemoteViews.class)) { 28 | superClass = superClass.getSuperclass(); 29 | } 30 | return superClass; 31 | } 32 | 33 | public static @Nullable ApplicationInfo getApplicationInfo(Context context, RemoteViews remoteViews, Class clazz) { 34 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 35 | return getApplicationInfoLollipop(remoteViews, clazz); 36 | } else { 37 | return getApplicationInfoDefault(context, remoteViews, clazz); 38 | } 39 | } 40 | 41 | private static @Nullable ApplicationInfo getApplicationInfoLollipop(RemoteViews remoteViews, Class clazz) { 42 | try { 43 | Field applicationField = clazz.getDeclaredField("mApplication"); 44 | applicationField.setAccessible(true); 45 | return (ApplicationInfo) applicationField.get(remoteViews); 46 | } catch (NoSuchFieldException e) { 47 | Log.e(TAG, "no such field: ", e); 48 | return null; 49 | } catch (IllegalAccessException e) { 50 | Log.e(TAG, "cannot access to the field: ", e); 51 | return null; 52 | } 53 | } 54 | 55 | private static @Nullable ApplicationInfo getApplicationInfoDefault(Context context, RemoteViews remoteViews, Class clazz) { 56 | try { 57 | Field applicationField = clazz.getDeclaredField("mPackage"); 58 | applicationField.setAccessible(true); 59 | String pkg = (String) applicationField.get(remoteViews); 60 | PackageManager pm = context.getPackageManager(); 61 | return pm.getApplicationInfo(pkg, 0); 62 | } catch (NoSuchFieldException e) { 63 | Log.e(TAG, "no such field: ", e); 64 | return null; 65 | } catch (IllegalAccessException e) { 66 | Log.e(TAG, "cannot access to the field: ", e); 67 | return null; 68 | } catch (PackageManager.NameNotFoundException e) { 69 | Log.e(TAG, "no such package is installed: ", e); 70 | return null; 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':reader' 2 | --------------------------------------------------------------------------------